vanjs-jsf 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -15
- package/dist/VanJsfField.d.ts +40 -57
- package/dist/VanJsfField.js +124 -566
- package/dist/VanJsfField.js.map +1 -1
- package/dist/VanJsfForm.d.ts +82 -1
- package/dist/VanJsfForm.js +213 -119
- package/dist/VanJsfForm.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/jsf-defaults.css +80 -0
- package/dist/schema.d.ts +13 -0
- package/dist/schema.js +29 -0
- package/dist/schema.js.map +1 -0
- package/dist/theme.d.ts +20 -2
- package/dist/theme.js +12 -1
- package/dist/theme.js.map +1 -1
- package/dist/types.d.ts +83 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +10 -0
- package/dist/util.js +17 -0
- package/dist/util.js.map +1 -0
- package/dist/values.d.ts +11 -0
- package/dist/values.js +51 -0
- package/dist/values.js.map +1 -0
- package/dist/widgets/array.d.ts +16 -0
- package/dist/widgets/array.js +108 -0
- package/dist/widgets/array.js.map +1 -0
- package/dist/widgets/basic.d.ts +2 -0
- package/dist/widgets/basic.js +97 -0
- package/dist/widgets/basic.js.map +1 -0
- package/dist/widgets/choice.d.ts +2 -0
- package/dist/widgets/choice.js +127 -0
- package/dist/widgets/choice.js.map +1 -0
- package/dist/widgets/code.d.ts +2 -0
- package/dist/widgets/code.js +146 -0
- package/dist/widgets/code.js.map +1 -0
- package/dist/widgets/date.d.ts +3 -0
- package/dist/widgets/date.js +43 -0
- package/dist/widgets/date.js.map +1 -0
- package/dist/widgets/file.d.ts +6 -0
- package/dist/widgets/file.js +130 -0
- package/dist/widgets/file.js.map +1 -0
- package/dist/widgets/index.d.ts +3 -0
- package/dist/widgets/index.js +22 -0
- package/dist/widgets/index.js.map +1 -0
- package/package.json +19 -17
- package/dist/JsfUtils.d.ts +0 -4
- package/dist/JsfUtils.js +0 -11
- package/dist/JsfUtils.js.map +0 -1
- package/dist/VanJSComponent.d.ts +0 -3
- package/dist/VanJSComponent.js +0 -3
- package/dist/VanJSComponent.js.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import van from "vanjs-core";
|
|
2
|
+
import { resolve } from "../theme";
|
|
3
|
+
import { emptyToUndefined } from "../values";
|
|
4
|
+
import { compact, toText } from "../util";
|
|
5
|
+
const { input } = van.tags;
|
|
6
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
7
|
+
/**
|
|
8
|
+
* Pikaday is loaded only when a field asks for it (`picker: "pikaday"`). Its stylesheet is the
|
|
9
|
+
* host's to include (`import "pikaday/css/pikaday.css"`): loading it from a CDN at runtime
|
|
10
|
+
* breaks under a strict CSP and depends on a third party being up.
|
|
11
|
+
*/
|
|
12
|
+
async function mountPikaday(ctx, field) {
|
|
13
|
+
const Pikaday = (await import("pikaday")).default;
|
|
14
|
+
new Pikaday({
|
|
15
|
+
field,
|
|
16
|
+
container: field.parentElement ?? undefined,
|
|
17
|
+
firstDay: 1,
|
|
18
|
+
minDate: ctx.field.minDate ? new Date(String(ctx.field.minDate)) : undefined,
|
|
19
|
+
maxDate: ctx.field.maxDate ? new Date(String(ctx.field.maxDate)) : undefined,
|
|
20
|
+
toString: (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`,
|
|
21
|
+
parse: (s) => {
|
|
22
|
+
const [y, m, d] = s.split("-").map((p) => parseInt(p, 10));
|
|
23
|
+
return new Date(y, m - 1, d);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** Native `<input type="date">` by default; the value is always `YYYY-MM-DD`. */
|
|
28
|
+
export const dateWidget = (ctx) => {
|
|
29
|
+
const usePikaday = ctx.field.picker === "pikaday";
|
|
30
|
+
const el = input(compact({
|
|
31
|
+
...ctx.attrs(),
|
|
32
|
+
type: usePikaday ? "text" : "date",
|
|
33
|
+
class: resolve(ctx.field.class, ctx.theme.input),
|
|
34
|
+
value: toText(ctx.getValue()),
|
|
35
|
+
min: usePikaday ? undefined : ctx.field.minDate,
|
|
36
|
+
max: usePikaday ? undefined : ctx.field.maxDate,
|
|
37
|
+
onchange: (e) => ctx.setValue(emptyToUndefined(e.target.value)),
|
|
38
|
+
}));
|
|
39
|
+
if (usePikaday)
|
|
40
|
+
queueMicrotask(() => void mountPikaday(ctx, el));
|
|
41
|
+
return [ctx.label(), ctx.description(), el, ctx.errorMessage()];
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../lib/widgets/date.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;AAE3B,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAEtD;;;;GAIG;AACH,KAAK,UAAU,YAAY,CAAC,GAAkB,EAAE,KAAuB;IACrE,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;IAClD,IAAI,OAAO,CAAC;QACV,KAAK;QACL,SAAS,EAAE,KAAK,CAAC,aAAa,IAAI,SAAS;QAC3C,QAAQ,EAAE,CAAC;QACX,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAA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AC,QAAQ,EAAE,CAAC;QAC7B,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO;QAC/C,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO;QAC/C,QAAQ,EAAE,CAAC,CAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAE,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAC,CAAC;KAC7F,CAAC,CAAqB,CAAC;IACxB,IAAI,UAAU;QAAE,cAAc,CAAC,GAAG,EAAE,CAAC,KAAK,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC","sourcesContent":["import van from \"vanjs-core\";\nimport type { Widget, WidgetContext } from \"../types\";\nimport { resolve } from \"../theme\";\nimport { emptyToUndefined } from \"../values\";\nimport { compact, toText } from \"../util\";\n\nconst { input } = van.tags;\n\nconst pad = (n: number) => String(n).padStart(2, \"0\");\n\n/**\n * Pikaday is loaded only when a field asks for it (`picker: \"pikaday\"`). Its stylesheet is the\n * host's to include (`import \"pikaday/css/pikaday.css\"`): loading it from a CDN at runtime\n * breaks under a strict CSP and depends on a third party being up.\n */\nasync function mountPikaday(ctx: WidgetContext, field: HTMLInputElement): Promise<void> {\n const Pikaday = (await import(\"pikaday\")).default;\n new Pikaday({\n field,\n container: field.parentElement ?? undefined,\n firstDay: 1,\n minDate: ctx.field.minDate ? new Date(String(ctx.field.minDate)) : undefined,\n maxDate: ctx.field.maxDate ? new Date(String(ctx.field.maxDate)) : undefined,\n toString: (d: Date) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`,\n parse: (s: string) => {\n const [y, m, d] = s.split(\"-\").map((p) => parseInt(p, 10));\n return new Date(y, m - 1, d);\n },\n });\n}\n\n/** Native `<input type=\"date\">` by default; the value is always `YYYY-MM-DD`. */\nexport const dateWidget: Widget = (ctx) => {\n const usePikaday = ctx.field.picker === \"pikaday\";\n const el = input(compact({\n ...ctx.attrs(),\n type: usePikaday ? \"text\" : \"date\",\n class: resolve(ctx.field.class, ctx.theme.input),\n value: toText(ctx.getValue()),\n min: usePikaday ? undefined : ctx.field.minDate,\n max: usePikaday ? undefined : ctx.field.maxDate,\n onchange: (e: Event) => ctx.setValue(emptyToUndefined((e.target as HTMLInputElement).value)),\n })) as HTMLInputElement;\n if (usePikaday) queueMicrotask(() => void mountPikaday(ctx, el));\n return [ctx.label(), ctx.description(), el, ctx.errorMessage()];\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Widget } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Drag & drop zone that reads the file in the browser. The content becomes the value; name,
|
|
4
|
+
* size and MIME type go next to it as `<name>__fileName`, `__fileSize` and `__fileType`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const fileWidget: Widget;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import van from "vanjs-core";
|
|
2
|
+
import { template } from "../util";
|
|
3
|
+
const { button, div, input, p, small, strong } = van.tags;
|
|
4
|
+
const TEXT_EXTENSIONS = new Set([
|
|
5
|
+
"json", "csv", "tsv", "txt", "xml", "yaml", "yml",
|
|
6
|
+
"log", "md", "html", "css", "js", "ts", "sql", "env",
|
|
7
|
+
]);
|
|
8
|
+
const formatSize = (bytes) => {
|
|
9
|
+
if (bytes < 1024)
|
|
10
|
+
return `${bytes} B`;
|
|
11
|
+
if (bytes < 1024 * 1024)
|
|
12
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
13
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
14
|
+
};
|
|
15
|
+
/** Base64 of a buffer, in chunks: one char at a time is quadratic on large files. */
|
|
16
|
+
const toBase64 = (buf) => {
|
|
17
|
+
const bytes = new Uint8Array(buf);
|
|
18
|
+
let binary = "";
|
|
19
|
+
for (let i = 0; i < bytes.length; i += 0x8000) {
|
|
20
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
|
|
21
|
+
}
|
|
22
|
+
return btoa(binary);
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Drag & drop zone that reads the file in the browser. The content becomes the value; name,
|
|
26
|
+
* size and MIME type go next to it as `<name>__fileName`, `__fileSize` and `__fileType`.
|
|
27
|
+
*/
|
|
28
|
+
export const fileWidget = (ctx) => {
|
|
29
|
+
const f = ctx.field;
|
|
30
|
+
const { theme, texts } = ctx;
|
|
31
|
+
const accept = typeof f.accept === "string" ? f.accept : "";
|
|
32
|
+
const maxSizeMB = typeof f.maxSizeMB === "number" ? f.maxSizeMB : undefined;
|
|
33
|
+
const readAs = typeof f.readAs === "string" ? f.readAs : "auto";
|
|
34
|
+
const locked = Boolean(f.readOnly || f.disabled);
|
|
35
|
+
const fileName = van.state("");
|
|
36
|
+
const fileSize = van.state("");
|
|
37
|
+
const dragOver = van.state(false);
|
|
38
|
+
const reading = van.state(false);
|
|
39
|
+
const setMeta = (name, size, type) => {
|
|
40
|
+
ctx.setMeta("fileName", name);
|
|
41
|
+
ctx.setMeta("fileSize", size === undefined ? undefined : String(size));
|
|
42
|
+
ctx.setMeta("fileType", type);
|
|
43
|
+
};
|
|
44
|
+
const readFile = (file) => {
|
|
45
|
+
if (maxSizeMB && file.size > maxSizeMB * 1024 * 1024) {
|
|
46
|
+
ctx.setWidgetError(template(texts.fileTooLarge, { max: maxSizeMB }));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
ctx.setWidgetError("");
|
|
50
|
+
fileName.val = file.name;
|
|
51
|
+
fileSize.val = formatSize(file.size);
|
|
52
|
+
reading.val = true;
|
|
53
|
+
const reader = new FileReader();
|
|
54
|
+
reader.onload = () => {
|
|
55
|
+
reading.val = false;
|
|
56
|
+
const result = reader.result instanceof ArrayBuffer ? toBase64(reader.result) : String(reader.result ?? "");
|
|
57
|
+
setMeta(file.name, file.size, file.type);
|
|
58
|
+
ctx.setValue(result);
|
|
59
|
+
};
|
|
60
|
+
reader.onerror = () => {
|
|
61
|
+
reading.val = false;
|
|
62
|
+
ctx.setWidgetError(texts.fileReadError);
|
|
63
|
+
};
|
|
64
|
+
const ext = file.name.split(".").pop()?.toLowerCase() ?? "";
|
|
65
|
+
if (readAs === "dataURL")
|
|
66
|
+
reader.readAsDataURL(file);
|
|
67
|
+
else if (readAs === "arrayBuffer" || (readAs === "auto" && !TEXT_EXTENSIONS.has(ext)))
|
|
68
|
+
reader.readAsArrayBuffer(file);
|
|
69
|
+
else
|
|
70
|
+
reader.readAsText(file);
|
|
71
|
+
};
|
|
72
|
+
const fileInput = input({
|
|
73
|
+
type: "file",
|
|
74
|
+
id: ctx.id,
|
|
75
|
+
name: ctx.path.join("."),
|
|
76
|
+
accept,
|
|
77
|
+
disabled: locked,
|
|
78
|
+
style: "display: none;",
|
|
79
|
+
onchange: (e) => {
|
|
80
|
+
const files = e.target.files;
|
|
81
|
+
if (files?.[0])
|
|
82
|
+
readFile(files[0]);
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
const clear = (e) => {
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
fileName.val = "";
|
|
88
|
+
fileSize.val = "";
|
|
89
|
+
reading.val = false;
|
|
90
|
+
fileInput.value = "";
|
|
91
|
+
ctx.setWidgetError("");
|
|
92
|
+
setMeta();
|
|
93
|
+
ctx.setValue(undefined);
|
|
94
|
+
};
|
|
95
|
+
const dzBase = theme.dropZone || "jsf-dropzone";
|
|
96
|
+
const dzActive = theme.dropZoneActive || "jsf-dropzone-active";
|
|
97
|
+
const browse = () => { if (!locked)
|
|
98
|
+
fileInput.click(); };
|
|
99
|
+
const dropZone = div({
|
|
100
|
+
class: () => (dragOver.val ? `${dzBase} ${dzActive}` : dzBase),
|
|
101
|
+
role: "button",
|
|
102
|
+
tabindex: locked ? "-1" : "0",
|
|
103
|
+
"aria-labelledby": `${ctx.id}-label`,
|
|
104
|
+
"aria-describedby": ctx.attrs()["aria-describedby"],
|
|
105
|
+
ondragover: (e) => { e.preventDefault(); dragOver.val = !locked; },
|
|
106
|
+
ondragleave: () => { dragOver.val = false; },
|
|
107
|
+
ondrop: (e) => {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
dragOver.val = false;
|
|
110
|
+
const files = e.dataTransfer?.files;
|
|
111
|
+
if (!locked && files?.[0])
|
|
112
|
+
readFile(files[0]);
|
|
113
|
+
},
|
|
114
|
+
onclick: browse,
|
|
115
|
+
onkeydown: (e) => {
|
|
116
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
browse();
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
}, p({ class: theme.dropZoneText || "jsf-dropzone-text" }, accept ? template(texts.dropFileAccept, { accept }) : texts.dropFile));
|
|
122
|
+
const infoBar = () => fileName.val
|
|
123
|
+
? div({ class: theme.fileInfoBar || "jsf-file-info" }, strong({ class: theme.fileName || "" }, fileName.val), small({ class: theme.fileSize || "jsf-file-size" }, `(${fileSize.val})`), button({ type: "button", class: theme.fileClearButton || "jsf-file-clear", onclick: clear }, texts.clearFile))
|
|
124
|
+
: div();
|
|
125
|
+
const readingIndicator = () => reading.val
|
|
126
|
+
? div({ class: theme.fileReading || "jsf-file-reading" }, texts.readingFile)
|
|
127
|
+
: div();
|
|
128
|
+
return [ctx.label(), ctx.description(), fileInput, dropZone, infoBar, readingIndicator, ctx.errorMessage()];
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../lib/widgets/file.ts"],"names":[],"mappings":"AAAA,OAAO,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,CAAC,CAAC,GAAG,EAAE,CAAC;IAEV,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;AAC9G,CAAC,CAAC","sourcesContent":["import van from \"vanjs-core\";\nimport type { Widget } from \"../types\";\nimport { template } from \"../util\";\n\nconst { button, div, input, p, small, strong } = van.tags;\n\nconst TEXT_EXTENSIONS = new Set([\n \"json\", \"csv\", \"tsv\", \"txt\", \"xml\", \"yaml\", \"yml\",\n \"log\", \"md\", \"html\", \"css\", \"js\", \"ts\", \"sql\", \"env\",\n]);\n\nconst formatSize = (bytes: number): string => {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n};\n\n/** Base64 of a buffer, in chunks: one char at a time is quadratic on large files. */\nconst toBase64 = (buf: ArrayBuffer): string => {\n const bytes = new Uint8Array(buf);\n let binary = \"\";\n for (let i = 0; i < bytes.length; i += 0x8000) {\n binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));\n }\n return btoa(binary);\n};\n\n/**\n * Drag & drop zone that reads the file in the browser. The content becomes the value; name,\n * size and MIME type go next to it as `<name>__fileName`, `__fileSize` and `__fileType`.\n */\nexport const fileWidget: Widget = (ctx) => {\n const f = ctx.field;\n const { theme, texts } = ctx;\n const accept = typeof f.accept === \"string\" ? f.accept : \"\";\n const maxSizeMB = typeof f.maxSizeMB === \"number\" ? f.maxSizeMB : undefined;\n const readAs = typeof f.readAs === \"string\" ? f.readAs : \"auto\";\n const locked = Boolean(f.readOnly || f.disabled);\n\n const fileName = van.state(\"\");\n const fileSize = van.state(\"\");\n const dragOver = van.state(false);\n const reading = van.state(false);\n\n const setMeta = (name?: string, size?: number, type?: string) => {\n ctx.setMeta(\"fileName\", name);\n ctx.setMeta(\"fileSize\", size === undefined ? undefined : String(size));\n ctx.setMeta(\"fileType\", type);\n };\n\n const readFile = (file: File) => {\n if (maxSizeMB && file.size > maxSizeMB * 1024 * 1024) {\n ctx.setWidgetError(template(texts.fileTooLarge, { max: maxSizeMB }));\n return;\n }\n ctx.setWidgetError(\"\");\n fileName.val = file.name;\n fileSize.val = formatSize(file.size);\n reading.val = true;\n\n const reader = new FileReader();\n reader.onload = () => {\n reading.val = false;\n const result = reader.result instanceof ArrayBuffer ? toBase64(reader.result) : String(reader.result ?? \"\");\n setMeta(file.name, file.size, file.type);\n ctx.setValue(result);\n };\n reader.onerror = () => {\n reading.val = false;\n ctx.setWidgetError(texts.fileReadError);\n };\n\n const ext = file.name.split(\".\").pop()?.toLowerCase() ?? \"\";\n if (readAs === \"dataURL\") reader.readAsDataURL(file);\n else if (readAs === \"arrayBuffer\" || (readAs === \"auto\" && !TEXT_EXTENSIONS.has(ext))) reader.readAsArrayBuffer(file);\n else reader.readAsText(file);\n };\n\n const fileInput = input({\n type: \"file\",\n id: ctx.id,\n name: ctx.path.join(\".\"),\n accept,\n disabled: locked,\n style: \"display: none;\",\n onchange: (e: Event) => {\n const files = (e.target as HTMLInputElement).files;\n if (files?.[0]) readFile(files[0]);\n },\n }) as HTMLInputElement;\n\n const clear = (e: Event) => {\n e.stopPropagation();\n fileName.val = \"\";\n fileSize.val = \"\";\n reading.val = false;\n fileInput.value = \"\";\n ctx.setWidgetError(\"\");\n setMeta();\n ctx.setValue(undefined);\n };\n\n const dzBase = theme.dropZone || \"jsf-dropzone\";\n const dzActive = theme.dropZoneActive || \"jsf-dropzone-active\";\n const browse = () => { if (!locked) fileInput.click(); };\n\n const dropZone = div(\n {\n class: () => (dragOver.val ? `${dzBase} ${dzActive}` : dzBase),\n role: \"button\",\n tabindex: locked ? \"-1\" : \"0\",\n \"aria-labelledby\": `${ctx.id}-label`,\n \"aria-describedby\": ctx.attrs()[\"aria-describedby\"] as string,\n ondragover: (e: DragEvent) => { e.preventDefault(); dragOver.val = !locked; },\n ondragleave: () => { dragOver.val = false; },\n ondrop: (e: DragEvent) => {\n e.preventDefault();\n dragOver.val = false;\n const files = e.dataTransfer?.files;\n if (!locked && files?.[0]) readFile(files[0]);\n },\n onclick: browse,\n onkeydown: (e: KeyboardEvent) => {\n if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); browse(); }\n },\n },\n p(\n { class: theme.dropZoneText || \"jsf-dropzone-text\" },\n accept ? template(texts.dropFileAccept, { accept }) : texts.dropFile,\n ),\n );\n\n const infoBar = () => fileName.val\n ? div(\n { class: theme.fileInfoBar || \"jsf-file-info\" },\n strong({ class: theme.fileName || \"\" }, fileName.val),\n small({ class: theme.fileSize || \"jsf-file-size\" }, `(${fileSize.val})`),\n button({ type: \"button\", class: theme.fileClearButton || \"jsf-file-clear\", onclick: clear }, texts.clearFile),\n )\n : div();\n\n const readingIndicator = () => reading.val\n ? div({ class: theme.fileReading || \"jsf-file-reading\" }, texts.readingFile)\n : div();\n\n return [ctx.label(), ctx.description(), fileInput, dropZone, infoBar, readingIndicator, ctx.errorMessage()];\n};\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import van from "vanjs-core";
|
|
2
|
+
import { resolve } from "../theme";
|
|
3
|
+
import { basicWidgets } from "./basic";
|
|
4
|
+
import { choiceWidgets } from "./choice";
|
|
5
|
+
import { dateWidget } from "./date";
|
|
6
|
+
import { codeWidget } from "./code";
|
|
7
|
+
import { fileWidget } from "./file";
|
|
8
|
+
import { arrayWidget, groupArrayWidget } from "./array";
|
|
9
|
+
const { fieldset, legend } = van.tags;
|
|
10
|
+
const fieldsetWidget = (ctx) => fieldset({ class: ctx.theme.fieldset || "" }, legend({ class: resolve(ctx.field.titleClass, ctx.theme.legend || ctx.theme.label) }, ctx.field.label ?? ""), ctx.description(), ...ctx.renderChildren(), ctx.errorMessage());
|
|
11
|
+
/** Built-in widgets, keyed by input type. A `widgets` entry passed to `jsform()` overrides any of them. */
|
|
12
|
+
export const builtinWidgets = {
|
|
13
|
+
...basicWidgets,
|
|
14
|
+
...choiceWidgets,
|
|
15
|
+
date: dateWidget,
|
|
16
|
+
code: codeWidget,
|
|
17
|
+
file: fileWidget,
|
|
18
|
+
fieldset: fieldsetWidget,
|
|
19
|
+
array: arrayWidget,
|
|
20
|
+
"group-array": groupArrayWidget,
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;AAEtC,MAAM,cAAc,GAAW,CAAC,GAAG,EAAE,EAAE,CACrC,QAAQ,CACN,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,EAAE,EACnC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,EAC5G,GAAG,CAAC,WAAW,EAAE,EACjB,GAAG,GAAG,CAAC,cAAc,EAAE,EACvB,GAAG,CAAC,YAAY,EAAE,CACnB,CAAC;AAEJ,2GAA2G;AAC3G,MAAM,CAAC,MAAM,cAAc,GAA2B;IACpD,GAAG,YAAY;IACf,GAAG,aAAa;IAChB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,cAAc;IACxB,KAAK,EAAE,WAAW;IAClB,aAAa,EAAE,gBAAgB;CAChC,CAAC","sourcesContent":["import van from \"vanjs-core\";\nimport type { Widget } from \"../types\";\nimport { resolve } from \"../theme\";\nimport { basicWidgets } from \"./basic\";\nimport { choiceWidgets } from \"./choice\";\nimport { dateWidget } from \"./date\";\nimport { codeWidget } from \"./code\";\nimport { fileWidget } from \"./file\";\nimport { arrayWidget, groupArrayWidget } from \"./array\";\n\nconst { fieldset, legend } = van.tags;\n\nconst fieldsetWidget: Widget = (ctx) =>\n fieldset(\n { class: ctx.theme.fieldset || \"\" },\n legend({ class: resolve(ctx.field.titleClass, ctx.theme.legend || ctx.theme.label) }, ctx.field.label ?? \"\"),\n ctx.description(),\n ...ctx.renderChildren(),\n ctx.errorMessage(),\n );\n\n/** Built-in widgets, keyed by input type. A `widgets` entry passed to `jsform()` overrides any of them. */\nexport const builtinWidgets: Record<string, Widget> = {\n ...basicWidgets,\n ...choiceWidgets,\n date: dateWidget,\n code: codeWidget,\n file: fileWidget,\n fieldset: fieldsetWidget,\n array: arrayWidget,\n \"group-array\": groupArrayWidget,\n};\n"]}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"form",
|
|
9
9
|
"ui-library"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.6.0",
|
|
12
12
|
"author": {
|
|
13
13
|
"name": "Carlos Prados",
|
|
14
14
|
"email": "carlos.prados@gmail.com"
|
|
@@ -26,28 +26,30 @@
|
|
|
26
26
|
"build": "tsc -p tsconfig.build.json && cp lib/jsf-defaults.css dist/jsf-defaults.css",
|
|
27
27
|
"dev": "vite",
|
|
28
28
|
"lint": "eslint lib/",
|
|
29
|
-
"lint:fix": "eslint lib/ --fix"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"typescript": "^5.7.3"
|
|
29
|
+
"lint:fix": "eslint lib/ --fix",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:watch": "vitest"
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
|
-
"@codemirror/lang-javascript": "^6.2.
|
|
36
|
-
"@codemirror/lang-json": "^6.0.
|
|
37
|
-
"@codemirror/lint": "^6.
|
|
38
|
-
"@remoteoss/json-schema-form": "^0.
|
|
39
|
-
"codemirror": "^6.0.
|
|
40
|
-
"eslint-linter-browserify": "^
|
|
41
|
-
"globals": "^17.
|
|
34
|
+
"@codemirror/lang-javascript": "^6.2.5",
|
|
35
|
+
"@codemirror/lang-json": "^6.0.2",
|
|
36
|
+
"@codemirror/lint": "^6.9.8",
|
|
37
|
+
"@remoteoss/json-schema-form": "^0.12.5-beta.0",
|
|
38
|
+
"codemirror": "^6.0.2",
|
|
39
|
+
"eslint-linter-browserify": "^10.16.0",
|
|
40
|
+
"globals": "^17.15.0",
|
|
42
41
|
"pikaday": "^1.8.2",
|
|
43
42
|
"thememirror": "^2.0.1",
|
|
44
|
-
"vanjs-core": "^1.
|
|
43
|
+
"vanjs-core": "^1.6.2"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@eslint/js": "^10.0.1",
|
|
48
|
-
"@types/pikaday": "^1.7.
|
|
49
|
-
"eslint": "^10.
|
|
50
|
-
"
|
|
51
|
-
"
|
|
47
|
+
"@types/pikaday": "^1.7.10",
|
|
48
|
+
"eslint": "^10.16.0",
|
|
49
|
+
"happy-dom": "^21.0.4",
|
|
50
|
+
"typescript": "^6.0.3",
|
|
51
|
+
"typescript-eslint": "^8.74.0",
|
|
52
|
+
"vite": "^8.4.1",
|
|
53
|
+
"vitest": "^5.1.2"
|
|
52
54
|
}
|
|
53
55
|
}
|
package/dist/JsfUtils.d.ts
DELETED
package/dist/JsfUtils.js
DELETED
package/dist/JsfUtils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JsfUtils.js","sourceRoot":"","sources":["../lib/JsfUtils.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,QAAQ;IACnB,MAAM,CAAC,iBAAiB,CACtB,MAAc,EACd,IAAY;QAEZ,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;gBAChE,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { Fields } from \"@remoteoss/json-schema-form\";\n\nexport class JsfUtils {\n static getJsfFieldByName(\n fields: Fields,\n name: string\n ): Record<string, unknown> | null {\n for (const field of fields) {\n if (typeof field[\"name\"] === \"string\" && field[\"name\"] === name) {\n return field;\n }\n }\n return null;\n }\n}\n"]}
|
package/dist/VanJSComponent.d.ts
DELETED
package/dist/VanJSComponent.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VanJSComponent.js","sourceRoot":"","sources":["../lib/VanJSComponent.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,cAAc;CAEnC","sourcesContent":["export abstract class VanJSComponent {\n abstract render(): Element;\n}\n"]}
|