release: WRNexusJS 0.8.3
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { Card } from "@wrnexus/ui"
|
||||
|
||||
component UploadDropzone {
|
||||
props {
|
||||
store: string = "default"
|
||||
@@ -6,6 +8,7 @@ component UploadDropzone {
|
||||
maxBytes: number = 0
|
||||
multiple: boolean = false
|
||||
field: string = "file"
|
||||
invalidate: string = "uploads"
|
||||
label: string = "Drag files here or click to browse"
|
||||
title: string = "Upload files"
|
||||
description: string = "Files are validated and uploaded securely."
|
||||
@@ -15,7 +18,7 @@ component UploadDropzone {
|
||||
}
|
||||
view {
|
||||
<Card {...attrs} title='{title}' description='{description}' color='{color}' size='{size}' class='{class}'>
|
||||
<div data-uploader='{store}' data-endpoint='{endpoint}' data-accept='{accept}' data-max='{maxBytes}' data-multiple='{multiple}' data-field='{field}' data-label='{label}'></div>
|
||||
<div data-uploader='{store}' data-endpoint='{endpoint}' data-accept='{accept}' data-max='{maxBytes}' data-multiple='{multiple}' data-field='{field}' data-label='{label}' data-invalidate='{invalidate}'></div>
|
||||
</Card>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Alert, Badge, Card } from "@wrnexus/ui"
|
||||
|
||||
component UploadStatus {
|
||||
props {
|
||||
files: unknown[] = []
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/uploader",
|
||||
"version": "0.8.2",
|
||||
"version": "0.8.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -92,6 +92,10 @@ export const UPLOAD_RUNTIME = `
|
||||
var accept = root.getAttribute("data-accept") || "";
|
||||
var maxBytes = parseInt(root.getAttribute("data-max") || "0", 10) || 0;
|
||||
var field = root.getAttribute("data-field") || (multiple ? "files" : "file");
|
||||
var invalidate = String(root.getAttribute("data-invalidate") || "")
|
||||
.split(",")
|
||||
.map(function (tag) { return tag.trim(); })
|
||||
.filter(Boolean);
|
||||
var promptText = root.getAttribute("data-label") || "Drag files here or click to browse";
|
||||
|
||||
root.classList.add("wire-uploader");
|
||||
@@ -183,6 +187,11 @@ export const UPLOAD_RUNTIME = `
|
||||
ui.fill.style.width = "100%";
|
||||
ui.status.textContent = "\\u2713 Uploaded";
|
||||
root.dispatchEvent(new CustomEvent("wrnexus:upload", { bubbles: true, detail: { file: file, result: info } }));
|
||||
if (invalidate.length) {
|
||||
window.dispatchEvent(new CustomEvent("wrnexus:cache:invalidate", {
|
||||
detail: { tags: invalidate, source: "uploader", file: file, result: info }
|
||||
}));
|
||||
}
|
||||
}
|
||||
function fail(ui, msg, file) {
|
||||
ui.li.classList.add("is-error");
|
||||
|
||||
Reference in New Issue
Block a user