vanjs-jsf 0.4.0 → 0.5.1

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/dist/JsfUtils.js CHANGED
@@ -8,3 +8,4 @@ export class JsfUtils {
8
8
  return null;
9
9
  }
10
10
  }
11
+ //# sourceMappingURL=JsfUtils.js.map
@@ -0,0 +1 @@
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"]}
@@ -1,2 +1,3 @@
1
1
  export class VanJSComponent {
2
2
  }
3
+ //# sourceMappingURL=VanJSComponent.js.map
@@ -0,0 +1 @@
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"]}
@@ -27,7 +27,6 @@ export declare class VanJsfField extends VanJSComponent {
27
27
  get class(): string;
28
28
  get errorClass(): string;
29
29
  get isRequired(): boolean;
30
- get codemirrorExtension(): Array<any>;
31
30
  get containerClass(): string;
32
31
  get containerId(): string;
33
32
  get titleClass(): string;
@@ -41,6 +40,22 @@ export declare class VanJsfField extends VanJSComponent {
41
40
  private renderLabel;
42
41
  private renderDescription;
43
42
  private renderError;
43
+ /**
44
+ * Lazily loads CodeMirror + ESLint and mounts a code editor into `parent`.
45
+ * These are the heaviest dependencies in the library; importing them only here
46
+ * keeps them out of the main bundle for forms that don't use a `code` field.
47
+ */
48
+ private mountCodeEditor;
49
+ /** Lazily loads Pikaday and attaches a date picker to `calendarInput`. */
50
+ private mountDatePicker;
51
+ /**
52
+ * Renders an editable list for an array property. json-schema-form reports
53
+ * arrays as an unusable "select", so we read the item schema from the field's
54
+ * scopedJsonSchema and render one input per element with add/remove controls.
55
+ * Supports scalar item types (number/integer/string/boolean). The value is kept
56
+ * in formValues as a real JS array.
57
+ */
58
+ private renderArray;
44
59
  render(): Element;
45
60
  isVanJsfFieldArray(fields: unknown): fields is VanJsfField[];
46
61
  }
@@ -1,13 +1,10 @@
1
1
  import van from "vanjs-core";
2
2
  import { VanJSComponent } from "./VanJSComponent";
3
3
  import { resolve } from "./theme";
4
- import pikaday from "pikaday";
5
- import { basicSetup, EditorView } from "codemirror";
6
- import { javascript, esLint } from "@codemirror/lang-javascript";
7
- import { json, jsonParseLinter } from "@codemirror/lang-json";
8
- import { lintGutter, linter, forEachDiagnostic } from "@codemirror/lint";
9
- import * as eslint from "eslint-linter-browserify";
10
- import globals from "globals";
4
+ // Heavy, field-type-specific dependencies (CodeMirror + ESLint for the `code`
5
+ // field, Pikaday for the `date` field) are loaded lazily via dynamic import inside
6
+ // the relevant renderers. This keeps them out of the main bundle so a form that
7
+ // only uses text/number/select/etc. never pays for them.
11
8
  const { div, p, input, label, textarea, legend, link, fieldset, span, select, option, button, strong, small } = van.tags;
12
9
  var FieldType;
13
10
  (function (FieldType) {
@@ -22,20 +19,78 @@ var FieldType;
22
19
  FieldType["fieldset"] = "fieldset";
23
20
  FieldType["file"] = "file";
24
21
  })(FieldType || (FieldType = {}));
25
- const eslintConfig = {
26
- // eslint configuration
27
- languageOptions: {
28
- globals: {
29
- ...globals.node,
30
- },
31
- parserOptions: {
32
- ecmaVersion: 2022,
33
- sourceType: "module",
34
- },
35
- },
36
- rules: {
37
- semi: ["error", "never"],
38
- },
22
+ /**
23
+ * Rules the `code` field lints with. These are ESLint's own `eslint:recommended` set, spelled
24
+ * out because `eslint-linter-browserify` ships no config resolver — a bare `Linter` with no
25
+ * `rules` reports parse errors and nothing else, which looks like a working editor while
26
+ * catching none of the mistakes people actually make.
27
+ *
28
+ * Stylistic rules are deliberately absent. A host embedding this editor has no say in the
29
+ * code style of whoever types into it, and flagging every semicolon as an error is worse than
30
+ * flagging nothing: the real diagnostics drown.
31
+ */
32
+ const ESLINT_RULES = {
33
+ "constructor-super": "error",
34
+ "for-direction": "error",
35
+ "getter-return": "error",
36
+ "no-async-promise-executor": "error",
37
+ "no-case-declarations": "error",
38
+ "no-class-assign": "error",
39
+ "no-compare-neg-zero": "error",
40
+ "no-cond-assign": "error",
41
+ "no-const-assign": "error",
42
+ "no-constant-binary-expression": "error",
43
+ "no-constant-condition": "error",
44
+ "no-control-regex": "error",
45
+ "no-debugger": "error",
46
+ "no-delete-var": "error",
47
+ "no-dupe-args": "error",
48
+ "no-dupe-class-members": "error",
49
+ "no-dupe-else-if": "error",
50
+ "no-dupe-keys": "error",
51
+ "no-duplicate-case": "error",
52
+ "no-empty": "error",
53
+ "no-empty-character-class": "error",
54
+ "no-empty-pattern": "error",
55
+ "no-empty-static-block": "error",
56
+ "no-ex-assign": "error",
57
+ "no-extra-boolean-cast": "error",
58
+ "no-fallthrough": "error",
59
+ "no-func-assign": "error",
60
+ "no-global-assign": "error",
61
+ "no-import-assign": "error",
62
+ "no-invalid-regexp": "error",
63
+ "no-irregular-whitespace": "error",
64
+ "no-loss-of-precision": "error",
65
+ "no-misleading-character-class": "error",
66
+ "no-new-native-nonconstructor": "error",
67
+ "no-nonoctal-decimal-escape": "error",
68
+ "no-obj-calls": "error",
69
+ "no-octal": "error",
70
+ "no-prototype-builtins": "error",
71
+ "no-redeclare": "error",
72
+ "no-regex-spaces": "error",
73
+ "no-self-assign": "error",
74
+ "no-setter-return": "error",
75
+ "no-shadow-restricted-names": "error",
76
+ "no-sparse-arrays": "error",
77
+ "no-this-before-super": "error",
78
+ "no-undef": "error",
79
+ "no-unexpected-multiline": "error",
80
+ "no-unreachable": "error",
81
+ "no-unsafe-finally": "error",
82
+ "no-unsafe-negation": "error",
83
+ "no-unsafe-optional-chaining": "error",
84
+ "no-unused-labels": "error",
85
+ "no-unused-private-class-members": "error",
86
+ "no-unused-vars": "error",
87
+ "no-useless-backreference": "error",
88
+ "no-useless-catch": "error",
89
+ "no-useless-escape": "error",
90
+ "no-with": "error",
91
+ "require-yield": "error",
92
+ "use-isnan": "error",
93
+ "valid-typeof": "error",
39
94
  };
40
95
  export class VanJsfField extends VanJSComponent {
41
96
  name;
@@ -76,50 +131,6 @@ export class VanJsfField extends VanJSComponent {
76
131
  get isRequired() {
77
132
  return this.field.required ?? false;
78
133
  }
79
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
- get codemirrorExtension() {
81
- const cmTheme = EditorView.theme({
82
- '.cm-content, .cm-gutter': {
83
- "min-height": "150px",
84
- },
85
- '.cm-content': {
86
- "min-height": "150px",
87
- },
88
- '.cm-gutters': {
89
- margin: '1px',
90
- },
91
- '.cm-scroller': {
92
- overflow: 'auto',
93
- },
94
- '.cm-wrap': {
95
- border: '1px solid silver',
96
- },
97
- });
98
- const extensions = [cmTheme, EditorView.updateListener.of((e) => {
99
- this.field.error = null;
100
- forEachDiagnostic(e.state, (diag) => {
101
- if (diag.severity === "error") {
102
- this.field.error = diag.message;
103
- }
104
- });
105
- this.handleChange(this, e.state.doc.toString());
106
- }), basicSetup, lintGutter()];
107
- switch (this.field.codemirrorType) {
108
- case "json":
109
- extensions.push(json(), linter(jsonParseLinter()));
110
- break;
111
- case "javascript":
112
- extensions.push(javascript(), linter(esLint(new eslint.Linter(), eslintConfig)));
113
- break;
114
- case "typescript":
115
- extensions.push(javascript({ typescript: true }), linter(esLint(new eslint.Linter(), eslintConfig)));
116
- break;
117
- default:
118
- extensions.push(javascript(), linter(esLint(new eslint.Linter(), eslintConfig)));
119
- break;
120
- }
121
- return extensions;
122
- }
123
134
  get containerClass() {
124
135
  return this.field.containerClass;
125
136
  }
@@ -167,6 +178,153 @@ export class VanJsfField extends VanJSComponent {
167
178
  renderError() {
168
179
  return p({ class: resolve(this.errorClass, this.theme.error) }, () => this.error);
169
180
  }
181
+ /**
182
+ * Lazily loads CodeMirror + ESLint and mounts a code editor into `parent`.
183
+ * These are the heaviest dependencies in the library; importing them only here
184
+ * keeps them out of the main bundle for forms that don't use a `code` field.
185
+ */
186
+ async mountCodeEditor(parent) {
187
+ const [{ basicSetup, EditorView }, { javascript, esLint }, { json, jsonParseLinter }, { lintGutter, linter, forEachDiagnostic }, eslint, globalsModule, { dracula },] = await Promise.all([
188
+ import("codemirror"),
189
+ import("@codemirror/lang-javascript"),
190
+ import("@codemirror/lang-json"),
191
+ import("@codemirror/lint"),
192
+ import("eslint-linter-browserify"),
193
+ import("globals"),
194
+ import("thememirror"),
195
+ ]);
196
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
197
+ const globals = globalsModule.default ?? globalsModule;
198
+ // A `code` field may declare the globals its host injects at runtime. Those names are in
199
+ // no environment preset, so without this every single one of them reads as `no-undef`.
200
+ const fieldGlobals = this.field.globals && typeof this.field.globals === "object" ? this.field.globals : {};
201
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
202
+ const eslintConfig = {
203
+ languageOptions: {
204
+ globals: { ...fieldGlobals, ...globals.node },
205
+ parserOptions: { ecmaVersion: 2022, sourceType: "module" },
206
+ },
207
+ rules: ESLINT_RULES,
208
+ };
209
+ const cmTheme = EditorView.theme({
210
+ '.cm-content, .cm-gutter': { "min-height": "150px" },
211
+ '.cm-content': { "min-height": "150px" },
212
+ '.cm-gutters': { margin: '1px' },
213
+ '.cm-scroller': { overflow: 'auto' },
214
+ '.cm-wrap': { border: '1px solid silver' },
215
+ });
216
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
217
+ const extensions = [dracula, cmTheme, EditorView.updateListener.of((e) => {
218
+ this.field.error = null;
219
+ forEachDiagnostic(e.state, (diag) => {
220
+ if (diag.severity === "error") {
221
+ this.field.error = diag.message;
222
+ }
223
+ });
224
+ this.handleChange(this, e.state.doc.toString());
225
+ }), basicSetup, lintGutter()];
226
+ switch (this.field.codemirrorType) {
227
+ case "json":
228
+ extensions.push(json(), linter(jsonParseLinter()));
229
+ break;
230
+ case "javascript":
231
+ extensions.push(javascript(), linter(esLint(new eslint.Linter(), eslintConfig)));
232
+ break;
233
+ case "typescript":
234
+ extensions.push(javascript({ typescript: true }), linter(esLint(new eslint.Linter(), eslintConfig)));
235
+ break;
236
+ default:
237
+ extensions.push(javascript(), linter(esLint(new eslint.Linter(), eslintConfig)));
238
+ break;
239
+ }
240
+ new EditorView({ doc: String(this.iniVal), parent, extensions });
241
+ }
242
+ /** Lazily loads Pikaday and attaches a date picker to `calendarInput`. */
243
+ async mountDatePicker(parent, calendarInput) {
244
+ const Pikaday = (await import("pikaday")).default;
245
+ new Pikaday({
246
+ field: calendarInput,
247
+ format: 'YYYY-MM-DD',
248
+ container: parent,
249
+ firstDay: 1,
250
+ toString(date) {
251
+ const day = date.getDate();
252
+ const month = date.getMonth() + 1;
253
+ const year = date.getFullYear();
254
+ return `${year}-${("0" + month).slice(-2)}-${("0" + day).slice(-2)}`;
255
+ },
256
+ parse(dateString) {
257
+ const parts = dateString.split('-');
258
+ const year = parseInt(parts[0], 10);
259
+ const month = parseInt(parts[1], 10) - 1;
260
+ const day = parseInt(parts[2], 10);
261
+ return new Date(year, month, day);
262
+ }
263
+ });
264
+ }
265
+ /**
266
+ * Renders an editable list for an array property. json-schema-form reports
267
+ * arrays as an unusable "select", so we read the item schema from the field's
268
+ * scopedJsonSchema and render one input per element with add/remove controls.
269
+ * Supports scalar item types (number/integer/string/boolean). The value is kept
270
+ * in formValues as a real JS array.
271
+ */
272
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
273
+ renderArray(props) {
274
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
275
+ const scoped = this.field.scopedJsonSchema;
276
+ const arraySchema = scoped?.properties?.[this.name] ?? {};
277
+ const itemSchema = arraySchema.items ?? { type: "string" };
278
+ const itemType = itemSchema.type ?? "string";
279
+ const isNumeric = itemType === "number" || itemType === "integer";
280
+ const isBoolean = itemType === "boolean";
281
+ const minItems = arraySchema.minItems ?? 0;
282
+ const maxItems = arraySchema.maxItems ?? Infinity;
283
+ const blank = () => (isNumeric ? 0 : isBoolean ? false : "");
284
+ const coerce = (raw) => (isNumeric ? (raw === "" ? "" : Number(raw)) : raw);
285
+ const values = Array.isArray(this.iniVal) ? [...this.iniVal] : [];
286
+ while (values.length < minItems)
287
+ values.push(blank());
288
+ // Bumped only on add/remove so typing into a row never re-renders it (avoids
289
+ // losing input focus on every keystroke).
290
+ const version = van.state(0);
291
+ const emit = () => this.handleChange(this, values.slice());
292
+ emit();
293
+ const itemClass = resolve(this.class, this.theme.input);
294
+ const rowInput = (i) => {
295
+ if (isBoolean) {
296
+ return input({
297
+ type: "checkbox",
298
+ class: itemClass,
299
+ checked: Boolean(values[i]),
300
+ onchange: (e) => { values[i] = e.target.checked; emit(); },
301
+ });
302
+ }
303
+ return input({
304
+ type: isNumeric ? "number" : "text",
305
+ class: itemClass,
306
+ value: String(values[i] ?? ""),
307
+ oninput: (e) => { values[i] = coerce(e.target.value); emit(); },
308
+ });
309
+ };
310
+ const rows = () => div({ class: this.theme.arrayItems || "jsf-array-items" }, values.map((_, i) => div({ class: this.theme.arrayRow || "jsf-array-row" }, rowInput(i), button({
311
+ type: "button",
312
+ class: this.theme.arrayRemoveButton || "jsf-array-remove",
313
+ disabled: values.length <= minItems,
314
+ onclick: () => { values.splice(i, 1); version.val++; emit(); },
315
+ }, "✕"))));
316
+ return div(props, this.renderLabel(), this.renderDescription(),
317
+ // Re-render the row list whenever an item is added or removed.
318
+ () => { void version.val; return rows(); }, button({
319
+ type: "button",
320
+ class: this.theme.arrayAddButton || "jsf-array-add",
321
+ onclick: () => { if (values.length < maxItems) {
322
+ values.push(blank());
323
+ version.val++;
324
+ emit();
325
+ } },
326
+ }, "+ Add"), this.renderError());
327
+ }
170
328
  render() {
171
329
  let el;
172
330
  const baseContainer = resolve(this.containerClass, this.theme.container);
@@ -175,6 +333,13 @@ export class VanJsfField extends VanJSComponent {
175
333
  const props = {
176
334
  class: () => this.isVisible ? containerCls : `${containerCls} jsf-hidden`.trim(),
177
335
  };
336
+ // json-schema-form reports arrays as inputType "select" with no options, which
337
+ // is not usable. Detect the array jsonType and render an editable repeatable
338
+ // list of scalar items instead.
339
+ if (this.field.jsonType === "array") {
340
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
341
+ return this.renderArray(props);
342
+ }
178
343
  switch (this.inputType) {
179
344
  case FieldType.text:
180
345
  el = div(props, this.renderLabel(), this.renderDescription(), input({
@@ -212,11 +377,9 @@ export class VanJsfField extends VanJSComponent {
212
377
  break;
213
378
  case FieldType.code:
214
379
  el = div(props, this.renderLabel(), this.renderDescription());
215
- new EditorView({
216
- doc: String(this.iniVal),
217
- parent: el,
218
- extensions: this.codemirrorExtension
219
- });
380
+ // CodeMirror + ESLint are loaded on demand; the editor mounts into `el`
381
+ // once the chunk resolves.
382
+ void this.mountCodeEditor(el);
220
383
  break;
221
384
  case FieldType.select:
222
385
  el = div(props, this.renderLabel(), this.renderDescription(), select({
@@ -238,25 +401,8 @@ export class VanJsfField extends VanJSComponent {
238
401
  div(props, this.renderLabel(), this.renderDescription(), calendarInput, this.renderError(),
239
402
  // External CDN dependency for Pikaday CSS — consider bundling for production
240
403
  link({ rel: "stylesheet", type: "text/css", href: "https://cdn.jsdelivr.net/npm/pikaday/css/pikaday.css" }));
241
- new pikaday({
242
- field: calendarInput,
243
- format: 'YYYY-MM-DD',
244
- container: el,
245
- firstDay: 1,
246
- toString(date) {
247
- const day = date.getDate();
248
- const month = date.getMonth() + 1;
249
- const year = date.getFullYear();
250
- return `${year}-${("0" + month).slice(-2)}-${("0" + day).slice(-2)}`;
251
- },
252
- parse(dateString) {
253
- const parts = dateString.split('-');
254
- const year = parseInt(parts[0], 10);
255
- const month = parseInt(parts[1], 10) - 1;
256
- const day = parseInt(parts[2], 10);
257
- return new Date(year, month, day);
258
- }
259
- });
404
+ // Pikaday is loaded on demand and attached to the input once available.
405
+ void this.mountDatePicker(el, calendarInput);
260
406
  break;
261
407
  }
262
408
  case FieldType.number:
@@ -430,3 +576,4 @@ export class VanJsfField extends VanJSComponent {
430
576
  return Array.isArray(fields) && fields.every(field => field instanceof VanJsfField);
431
577
  }
432
578
  }
579
+ //# sourceMappingURL=VanJsfField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VanJsfField.js","sourceRoot":"","sources":["../lib/VanJsfField.ts"],"names":[],"mappings":"AAAA,OAAO,GAAc,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAY,OAAO,EAAE,MAAM,SAAS,CAAC;AAC5C,8EAA8E;AAC9E,mFAAmF;AACnF,gFAAgF;AAChF,yDAAyD;AACzD,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;AAEzH,IAAK,SAWJ;AAXD,WAAK,SAAS;IACZ,0BAAa,CAAA;IACb,kCAAqB,CAAA;IACrB,0BAAa,CAAA;IACb,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;IACrB,8BAAiB,CAAA;IACjB,4BAAe,CAAA;IACf,0BAAa,CAAA;IACb,kCAAqB,CAAA;IACrB,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AAC,KAAK,CAAC,EAAE,CAAC,KAAK,YAAY,WAAW,CAAC,CAAC;IACtF,CAAC;CACF","sourcesContent":["import van, { State } from \"vanjs-core\";\nimport { VanJSComponent } from \"./VanJSComponent\";\nimport { JsfTheme, resolve } from \"./theme\";\n// Heavy, field-type-specific dependencies (CodeMirror + ESLint for the `code`\n// field, Pikaday for the `date` field) are loaded lazily via dynamic import inside\n// the relevant renderers. This keeps them out of the main bundle so a form that\n// only uses text/number/select/etc. never pays for them.\nconst { div, p, input, label, textarea, legend, link, fieldset, span, select, option, button, strong, small } = van.tags;\n\nenum FieldType {\n text = \"text\",\n password = \"password\",\n code = \"code\",\n number = \"number\",\n textarea = \"textarea\",\n select = \"select\",\n radio = \"radio\",\n date = \"date\",\n fieldset = \"fieldset\",\n file = \"file\"\n}\nexport interface Option {\n label: string;\n value: string;\n description?: string;\n img?: string;\n}\n\nexport type MultiType = string | number | boolean;\n\n/**\n * Rules the `code` field lints with. These are ESLint's own `eslint:recommended` set, spelled\n * out because `eslint-linter-browserify` ships no config resolver — a bare `Linter` with no\n * `rules` reports parse errors and nothing else, which looks like a working editor while\n * catching none of the mistakes people actually make.\n *\n * Stylistic rules are deliberately absent. A host embedding this editor has no say in the\n * code style of whoever types into it, and flagging every semicolon as an error is worse than\n * flagging nothing: the real diagnostics drown.\n */\nconst ESLINT_RULES: Record<string, \"error\"> = {\n \"constructor-super\": \"error\",\n \"for-direction\": \"error\",\n \"getter-return\": \"error\",\n \"no-async-promise-executor\": \"error\",\n \"no-case-declarations\": \"error\",\n \"no-class-assign\": \"error\",\n \"no-compare-neg-zero\": \"error\",\n \"no-cond-assign\": \"error\",\n \"no-const-assign\": \"error\",\n \"no-constant-binary-expression\": \"error\",\n \"no-constant-condition\": \"error\",\n \"no-control-regex\": \"error\",\n \"no-debugger\": \"error\",\n \"no-delete-var\": \"error\",\n \"no-dupe-args\": \"error\",\n \"no-dupe-class-members\": \"error\",\n \"no-dupe-else-if\": \"error\",\n \"no-dupe-keys\": \"error\",\n \"no-duplicate-case\": \"error\",\n \"no-empty\": \"error\",\n \"no-empty-character-class\": \"error\",\n \"no-empty-pattern\": \"error\",\n \"no-empty-static-block\": \"error\",\n \"no-ex-assign\": \"error\",\n \"no-extra-boolean-cast\": \"error\",\n \"no-fallthrough\": \"error\",\n \"no-func-assign\": \"error\",\n \"no-global-assign\": \"error\",\n \"no-import-assign\": \"error\",\n \"no-invalid-regexp\": \"error\",\n \"no-irregular-whitespace\": \"error\",\n \"no-loss-of-precision\": \"error\",\n \"no-misleading-character-class\": \"error\",\n \"no-new-native-nonconstructor\": \"error\",\n \"no-nonoctal-decimal-escape\": \"error\",\n \"no-obj-calls\": \"error\",\n \"no-octal\": \"error\",\n \"no-prototype-builtins\": \"error\",\n \"no-redeclare\": \"error\",\n \"no-regex-spaces\": \"error\",\n \"no-self-assign\": \"error\",\n \"no-setter-return\": \"error\",\n \"no-shadow-restricted-names\": \"error\",\n \"no-sparse-arrays\": \"error\",\n \"no-this-before-super\": \"error\",\n \"no-undef\": \"error\",\n \"no-unexpected-multiline\": \"error\",\n \"no-unreachable\": \"error\",\n \"no-unsafe-finally\": \"error\",\n \"no-unsafe-negation\": \"error\",\n \"no-unsafe-optional-chaining\": \"error\",\n \"no-unused-labels\": \"error\",\n \"no-unused-private-class-members\": \"error\",\n \"no-unused-vars\": \"error\",\n \"no-useless-backreference\": \"error\",\n \"no-useless-catch\": \"error\",\n \"no-useless-escape\": \"error\",\n \"no-with\": \"error\",\n \"require-yield\": \"error\",\n \"use-isnan\": \"error\",\n \"valid-typeof\": \"error\",\n};\n\nexport class VanJsfField extends VanJSComponent {\n name: string;\n field: Record<string, unknown>;\n iniVal: MultiType;\n handleChange: (field: VanJsfField, value: MultiType) => void;\n isVisibleState: State<boolean>;\n errorState: State<string>;\n theme: JsfTheme;\n layoutClass: string;\n /** Used by file fields to pass file metadata to formValues */\n fileNameValue: string = \"\";\n fileSizeValue: string = \"\";\n fileTypeValue: string = \"\";\n constructor(\n field: Record<string, unknown>,\n initVal: MultiType,\n handleChange: (field: VanJsfField, value: MultiType) => void,\n theme: JsfTheme = {},\n layoutClass: string = \"\",\n ) {\n super();\n this.field = field;\n this.name = field.name as string;\n this.iniVal = initVal;\n this.handleChange = handleChange;\n this.theme = theme;\n this.layoutClass = layoutClass;\n this.isVisibleState = van.state(this.field.isVisible as boolean);\n this.errorState = van.state(\"\");\n }\n\n get inputType(): string {\n return this.field.inputType as string;\n }\n get label(): string {\n return this.field.label as string;\n }\n get class(): string {\n return this.field.class as string;\n }\n get errorClass(): string {\n return this.field.errorClass as string;\n }\n get isRequired(): boolean {\n return this.field.required as boolean ?? false;\n }\n get containerClass(): string {\n return this.field.containerClass as string;\n }\n get containerId(): string {\n return this.field.containerId as string;\n }\n get titleClass(): string {\n return this.field.titleClass as string;\n }\n get descriptionClass(): string {\n return this.field.descriptionClass as string;\n }\n get description(): string {\n return this.field.description as string;\n }\n get options(): Option[] {\n return this.field.options as Option[];\n }\n get isVisible(): boolean {\n return this.isVisibleState.val;\n }\n set isVisible(val: boolean) {\n this.isVisibleState.val = val;\n }\n\n get error(): string {\n return this.errorState.val;\n }\n\n set error(val: string) {\n this.errorState.val = val;\n }\n\n private renderLabel(): Element {\n const cls = resolve(this.titleClass, this.theme.label);\n return label(\n { for: this.name, class: cls },\n this.label,\n this.isRequired\n ? span({ class: this.theme.requiredIndicator || \"\" }, \" *\")\n : null,\n );\n }\n\n private renderDescription(): Element | null {\n if (!this.description) return null;\n return div({\n id: `${this.name}-description`,\n class: resolve(this.descriptionClass, this.theme.description),\n }, this.description);\n }\n\n private renderError(): Element {\n return p({ class: resolve(this.errorClass, this.theme.error) }, () => this.error);\n }\n\n /**\n * Lazily loads CodeMirror + ESLint and mounts a code editor into `parent`.\n * These are the heaviest dependencies in the library; importing them only here\n * keeps them out of the main bundle for forms that don't use a `code` field.\n */\n private async mountCodeEditor(parent: HTMLElement): Promise<void> {\n const [\n { basicSetup, EditorView },\n { javascript, esLint },\n { json, jsonParseLinter },\n { lintGutter, linter, forEachDiagnostic },\n eslint,\n globalsModule,\n { dracula },\n ] = await Promise.all([\n import(\"codemirror\"),\n import(\"@codemirror/lang-javascript\"),\n import(\"@codemirror/lang-json\"),\n import(\"@codemirror/lint\"),\n import(\"eslint-linter-browserify\"),\n import(\"globals\"),\n import(\"thememirror\"),\n ]);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const globals: any = (globalsModule as any).default ?? globalsModule;\n // A `code` field may declare the globals its host injects at runtime. Those names are in\n // no environment preset, so without this every single one of them reads as `no-undef`.\n const fieldGlobals =\n this.field.globals && typeof this.field.globals === \"object\" ? this.field.globals : {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const eslintConfig: any = {\n languageOptions: {\n globals: { ...fieldGlobals, ...globals.node },\n parserOptions: { ecmaVersion: 2022, sourceType: \"module\" },\n },\n rules: ESLINT_RULES,\n };\n const cmTheme = EditorView.theme({\n '.cm-content, .cm-gutter': { \"min-height\": \"150px\" },\n '.cm-content': { \"min-height\": \"150px\" },\n '.cm-gutters': { margin: '1px' },\n '.cm-scroller': { overflow: 'auto' },\n '.cm-wrap': { border: '1px solid silver' },\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const extensions: any[] = [dracula, cmTheme, EditorView.updateListener.of((e) => {\n this.field.error = null;\n forEachDiagnostic(e.state, (diag) => {\n if (diag.severity === \"error\") {\n this.field.error = diag.message;\n }\n });\n this.handleChange(this, e.state.doc.toString());\n }), basicSetup, lintGutter()];\n switch (this.field.codemirrorType) {\n case \"json\": extensions.push(json(), linter(jsonParseLinter())); break;\n case \"javascript\": extensions.push(javascript(), linter(esLint(new eslint.Linter(), eslintConfig))); break;\n case \"typescript\": extensions.push(javascript({ typescript: true }), linter(esLint(new eslint.Linter(), eslintConfig))); break;\n default: extensions.push(javascript(), linter(esLint(new eslint.Linter(), eslintConfig))); break;\n }\n new EditorView({ doc: String(this.iniVal), parent, extensions });\n }\n\n /** Lazily loads Pikaday and attaches a date picker to `calendarInput`. */\n private async mountDatePicker(parent: HTMLElement, calendarInput: HTMLInputElement): Promise<void> {\n const Pikaday = (await import(\"pikaday\")).default;\n new Pikaday({\n field: calendarInput,\n format: 'YYYY-MM-DD',\n container: parent,\n firstDay: 1,\n toString(date: Date) {\n const day = date.getDate();\n const month = date.getMonth() + 1;\n const year = date.getFullYear();\n return `${year}-${(\"0\" + month).slice(-2)}-${(\"0\" + day).slice(-2)}`;\n },\n parse(dateString: string) {\n const parts = dateString.split('-');\n const year = parseInt(parts[0], 10);\n const month = parseInt(parts[1], 10) - 1;\n const day = parseInt(parts[2], 10);\n return new Date(year, month, day);\n }\n });\n }\n\n /**\n * Renders an editable list for an array property. json-schema-form reports\n * arrays as an unusable \"select\", so we read the item schema from the field's\n * scopedJsonSchema and render one input per element with add/remove controls.\n * Supports scalar item types (number/integer/string/boolean). The value is kept\n * in formValues as a real JS array.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private renderArray(props: Record<string, any>): Element {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const scoped = this.field.scopedJsonSchema as any;\n const arraySchema = scoped?.properties?.[this.name] ?? {};\n const itemSchema = arraySchema.items ?? { type: \"string\" };\n const itemType: string = itemSchema.type ?? \"string\";\n const isNumeric = itemType === \"number\" || itemType === \"integer\";\n const isBoolean = itemType === \"boolean\";\n const minItems: number = arraySchema.minItems ?? 0;\n const maxItems: number = arraySchema.maxItems ?? Infinity;\n\n const blank = (): MultiType => (isNumeric ? 0 : isBoolean ? false : \"\");\n const coerce = (raw: string): MultiType => (isNumeric ? (raw === \"\" ? \"\" : Number(raw)) : raw);\n\n const values: MultiType[] = Array.isArray(this.iniVal) ? [...(this.iniVal as MultiType[])] : [];\n while (values.length < minItems) values.push(blank());\n\n // Bumped only on add/remove so typing into a row never re-renders it (avoids\n // losing input focus on every keystroke).\n const version = van.state(0);\n const emit = () => this.handleChange(this, values.slice() as unknown as MultiType);\n emit();\n\n const itemClass = resolve(this.class, this.theme.input);\n\n const rowInput = (i: number): Element => {\n if (isBoolean) {\n return input({\n type: \"checkbox\",\n class: itemClass,\n checked: Boolean(values[i]),\n onchange: (e: Event) => { values[i] = (e.target as HTMLInputElement).checked; emit(); },\n });\n }\n return input({\n type: isNumeric ? \"number\" : \"text\",\n class: itemClass,\n value: String(values[i] ?? \"\"),\n oninput: (e: Event) => { values[i] = coerce((e.target as HTMLInputElement).value); emit(); },\n });\n };\n\n const rows = (): Element => div(\n { class: this.theme.arrayItems || \"jsf-array-items\" },\n values.map((_, i) =>\n div({ class: this.theme.arrayRow || \"jsf-array-row\" },\n rowInput(i),\n button({\n type: \"button\",\n class: this.theme.arrayRemoveButton || \"jsf-array-remove\",\n disabled: values.length <= minItems,\n onclick: () => { values.splice(i, 1); version.val++; emit(); },\n }, \"✕\"),\n )\n ),\n );\n\n return div(\n props,\n this.renderLabel(),\n this.renderDescription(),\n // Re-render the row list whenever an item is added or removed.\n () => { void version.val; return rows(); },\n button({\n type: \"button\",\n class: this.theme.arrayAddButton || \"jsf-array-add\",\n onclick: () => { if (values.length < maxItems) { values.push(blank()); version.val++; emit(); } },\n }, \"+ Add\"),\n this.renderError(),\n );\n }\n\n render(): Element {\n let el: Element;\n const baseContainer = resolve(this.containerClass, this.theme.container);\n const containerCls = this.layoutClass ? `${baseContainer} ${this.layoutClass}` : baseContainer;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const props: Record<string, any> = {\n class: () => this.isVisible ? containerCls : `${containerCls} jsf-hidden`.trim(),\n };\n // json-schema-form reports arrays as inputType \"select\" with no options, which\n // is not usable. Detect the array jsonType and render an editable repeatable\n // list of scalar items instead.\n if (this.field.jsonType === \"array\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return this.renderArray(props);\n }\n switch (this.inputType) {\n case FieldType.text:\n el = div(\n props,\n this.renderLabel(),\n this.renderDescription(),\n input({\n id: this.name,\n type: \"text\",\n class: resolve(this.class, this.theme.input),\n value: this.iniVal,\n oninput: (e: Event) => this.handleChange(this, (e.target as HTMLInputElement).value),\n }),\n this.renderError(),\n );\n break;\n\n case FieldType.password:\n // Password is rendered with type=\"password\" so the user agent\n // masks the value as it is typed. Otherwise behaves identically\n // to a text input — same theme.input class, same oninput\n // wiring. autocomplete=\"new-password\" hints to browsers that\n // this is a credential entry form, not a \"remember me\" field.\n el = div(\n props,\n this.renderLabel(),\n this.renderDescription(),\n input({\n id: this.name,\n type: \"password\",\n autocomplete: \"new-password\",\n class: resolve(this.class, this.theme.input),\n value: this.iniVal,\n oninput: (e: Event) => this.handleChange(this, (e.target as HTMLInputElement).value),\n }),\n this.renderError(),\n );\n break;\n\n case FieldType.textarea:\n el = div(\n props,\n this.renderLabel(),\n this.renderDescription(),\n textarea({\n id: this.name,\n name: this.name,\n class: resolve(this.class, this.theme.textarea),\n rows: this.field.rows as number,\n cols: this.field.columns as number,\n oninput: (e: Event) => this.handleChange(this, (e.target as HTMLTextAreaElement).value),\n }),\n this.renderError(),\n );\n break;\n case FieldType.code:\n el = div(\n props,\n this.renderLabel(),\n this.renderDescription(),\n );\n // CodeMirror + ESLint are loaded on demand; the editor mounts into `el`\n // once the chunk resolves.\n void this.mountCodeEditor(el as HTMLElement);\n break;\n case FieldType.select:\n el = div(\n props,\n this.renderLabel(),\n this.renderDescription(),\n select({\n id: this.name,\n name: this.name,\n class: resolve(this.class, this.theme.select),\n oninput: (e: Event) => this.handleChange(this, (e.target as HTMLSelectElement).value),\n },\n this.options?.map((opt: Option) =>\n option({ class: this.theme.option || \"\", value: opt.value },\n opt.label,\n opt.description,\n )\n )\n ),\n this.renderError(),\n );\n break;\n\n case FieldType.date: {\n const calendarInput = input({\n id: this.name,\n type: \"text\",\n class: resolve(this.class, this.theme.input),\n value: this.iniVal,\n onchange: (e: Event) => this.handleChange(this, (e.target as HTMLInputElement).value),\n });\n el =\n div(\n props,\n this.renderLabel(),\n this.renderDescription(),\n calendarInput,\n this.renderError(),\n // External CDN dependency for Pikaday CSS — consider bundling for production\n link({ rel: \"stylesheet\", type: \"text/css\", href: \"https://cdn.jsdelivr.net/npm/pikaday/css/pikaday.css\" })\n );\n // Pikaday is loaded on demand and attached to the input once available.\n void this.mountDatePicker(el as HTMLElement, calendarInput as HTMLInputElement);\n break;\n }\n case FieldType.number:\n el = div(\n props,\n this.renderLabel(),\n this.renderDescription(),\n input({\n id: this.name,\n type: \"number\",\n class: resolve(this.class, this.theme.input),\n value: this.iniVal,\n oninput: (e: Event) => {\n const val = (e.target as HTMLInputElement).value;\n this.handleChange(this, val === \"\" ? \"\" : Number(val));\n },\n }),\n this.renderError(),\n );\n break;\n case FieldType.fieldset:\n el = div(\n props,\n fieldset(\n { class: this.theme.fieldset || \"\" },\n legend({ class: resolve(this.titleClass, this.theme.legend || this.theme.label) }, this.label),\n this.renderDescription(),\n this.isVanJsfFieldArray(this.field.fields)\n ? this.field.fields.map((field: VanJsfField) => field.render())\n : null,\n ),\n );\n break;\n case FieldType.radio:\n el = div(\n props,\n legend({ class: resolve(this.titleClass, this.theme.legend || this.theme.label) }, this.label),\n this.renderDescription(),\n div(\n { class: this.theme.radioGroup || \"\" },\n this.options?.map((opt: Option) =>\n label(\n { class: this.theme.radioLabel || \"\" },\n input({\n type: \"radio\",\n name: this.name,\n class: resolve(this.class, this.theme.radioInput),\n value: opt.value,\n checked: this.iniVal === opt.value,\n onchange: (e: Event) => this.handleChange(this, (e.target as HTMLInputElement).value),\n }),\n opt.label,\n opt.description,\n )\n )\n ),\n this.renderError(),\n );\n break;\n case FieldType.file: {\n const accept = (this.field.accept as string) || \"\";\n const maxSizeMB = this.field.maxSizeMB as number | undefined;\n const readAs = (this.field.readAs as string) || \"auto\";\n\n const TEXT_EXTENSIONS = new Set([\n \"json\", \"csv\", \"tsv\", \"txt\", \"xml\", \"yaml\", \"yml\",\n \"log\", \"md\", \"html\", \"css\", \"js\", \"ts\", \"sql\", \"env\",\n ]);\n\n // Reactive states\n const fileNameState = van.state(\"\");\n const fileSizeState = van.state(\"\");\n const dragOverState = van.state(false);\n const readingState = van.state(false);\n\n const 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 const readFile = (file: File) => {\n this.error = \"\";\n\n // Validate size\n if (maxSizeMB && file.size > maxSizeMB * 1024 * 1024) {\n this.error = `File exceeds maximum size of ${maxSizeMB} MB`;\n return;\n }\n\n fileNameState.val = file.name;\n fileSizeState.val = formatSize(file.size);\n readingState.val = true;\n\n // Store metadata\n this.fileNameValue = file.name;\n this.fileSizeValue = String(file.size);\n this.fileTypeValue = file.type;\n\n const reader = new FileReader();\n reader.onload = () => {\n readingState.val = false;\n let result = reader.result as string;\n if (reader.result instanceof ArrayBuffer) {\n // Convert binary to base64 (applies to \"arrayBuffer\" and \"auto\" for binary files)\n const bytes = new Uint8Array(reader.result);\n let binary = \"\";\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n result = btoa(binary);\n }\n this.handleChange(this, result);\n };\n reader.onerror = () => {\n readingState.val = false;\n this.error = \"Error reading file\";\n };\n\n if (readAs === \"dataURL\") {\n reader.readAsDataURL(file);\n } else if (readAs === \"arrayBuffer\") {\n reader.readAsArrayBuffer(file);\n } else if (readAs === \"auto\") {\n const ext = file.name.split(\".\").pop()?.toLowerCase() ?? \"\";\n if (TEXT_EXTENSIONS.has(ext)) {\n reader.readAsText(file);\n } else {\n reader.readAsArrayBuffer(file);\n }\n } else {\n reader.readAsText(file);\n }\n };\n\n const clearFile = () => {\n fileNameState.val = \"\";\n fileSizeState.val = \"\";\n readingState.val = false;\n this.fileNameValue = \"\";\n this.fileSizeValue = \"\";\n this.fileTypeValue = \"\";\n this.error = \"\";\n this.handleChange(this, \"\");\n };\n\n const fileInput = input({\n type: \"file\",\n accept,\n style: \"display: none;\",\n onchange: (e: Event) => {\n const files = (e.target as HTMLInputElement).files;\n if (files && files[0]) readFile(files[0]);\n },\n });\n\n const dzBase = this.theme.dropZone || \"jsf-dropzone\";\n const dzActive = this.theme.dropZoneActive || \"jsf-dropzone-active\";\n\n const dropZone = div(\n {\n class: () => dragOverState.val ? `${dzBase} ${dzActive}` : dzBase,\n ondragover: (e: DragEvent) => { e.preventDefault(); dragOverState.val = true; },\n ondragleave: () => { dragOverState.val = false; },\n ondrop: (e: DragEvent) => {\n e.preventDefault();\n dragOverState.val = false;\n const files = e.dataTransfer?.files;\n if (files && files[0]) readFile(files[0]);\n },\n onclick: () => fileInput.click(),\n },\n p(\n { class: this.theme.dropZoneText || \"jsf-dropzone-text\" },\n accept\n ? `Drop a file here or click to browse (${accept})`\n : \"Drop a file here or click to browse\",\n ),\n );\n\n const fileInfoBar = (): Element => {\n return div(() => {\n const name = fileNameState.val;\n if (!name) return div();\n return div(\n { class: this.theme.fileInfoBar || \"jsf-file-info\" },\n strong({ class: this.theme.fileName || \"\" }, name),\n small({ class: this.theme.fileSize || \"jsf-file-size\" }, `(${fileSizeState.val})`),\n button({\n type: \"button\",\n class: this.theme.fileClearButton || \"jsf-file-clear\",\n onclick: (e: Event) => {\n e.stopPropagation();\n clearFile();\n (fileInput as HTMLInputElement).value = \"\";\n },\n }, \"Clear\"),\n );\n });\n };\n\n const readingIndicator = (): Element => {\n return div(() => {\n if (!readingState.val) return div();\n return div({ class: this.theme.fileReading || \"jsf-file-reading\" }, \"Reading file...\");\n });\n };\n\n el = div(\n props,\n this.renderLabel(),\n this.renderDescription(),\n fileInput,\n dropZone,\n fileInfoBar(),\n readingIndicator(),\n this.renderError(),\n );\n break;\n }\n default:\n el = div(\n { style: \"border: 1px dashed gray; padding: 8px;\" },\n `Field \"${this.name}\" unsupported: The type \"${this.inputType}\" has no UI component built yet.`\n );\n }\n return el;\n }\n isVanJsfFieldArray(fields: unknown): fields is VanJsfField[] {\n return Array.isArray(fields) && fields.every(field => field instanceof VanJsfField);\n }\n}\n"]}
@@ -140,3 +140,4 @@ export function jsform(attributes, ...children) {
140
140
  attributes.onchange = handleChange;
141
141
  return form(attributes, ...childrenWithFields);
142
142
  }
143
+ //# sourceMappingURL=VanJsfForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VanJsfForm.js","sourceRoot":"","sources":["../lib/VanJsfForm.ts"],"names":[],"mappings":"AAAA,OAAO,GAAc,MAAM,YAAY,CAAC;AAExC,OAAO,EACL,kBAAkB,GAInB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,WAAW,EAAa,MAAM,eAAe,CAAC;AAGvD,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;AAG1B,MAAM,UAAU;IACd,MAAM,CAAuB;IAC7B,MAAM,CAAsB;IAC5B,OAAO,CAA6B;IACpC,YAAY,CAAqB;IACjC,UAAU,CAAgB;IAC1B,UAAU,CAAsB;IAChC,KAAK,CAAW;IAChB,MAAM,CAAY;IAElB,YAAY,UAAgC,EAAE,MAA2B,EAAE,OAAwB,EAAE,QAAkB,EAAE,EAAE,SAAoB,EAAE;QAC/I,kFAAkF;QAClF,mDAAmD;QACnD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,qBAAqB;QACrB,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,SAAS,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,0BAA0B;QAC1B,MAAM,aAAa,GAAG,EAAE,GAAG,MAAM,EAAE,aAAa,EAAE,CAAC;QACnD,IAAI,CAAC,YAAY,GAAG,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,aAAa,CAAC;QA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AAE,CACf,CAAC;IACF,MAAM,kBAAkB,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,yCAAyC;IAC9F,MAAM,gBAAgB,GAAG,UAAU,CAAC,QAAQ,CAAC;IAC7C,MAAM,YAAY,GAAG,CAAC,CAAQ,EAAE,EAAE;QAChC,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;QAC1C,IAAI,gBAAgB;YAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC,CAAC;IACF,MAAM,gBAAgB,GAAG,UAAU,CAAC,QAAQ,CAAC;IAC7C,MAAM,YAAY,GAAG,CAAC,CAAQ,EAAE,EAAE;QAChC,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;QAC1C,IAAI,gBAAgB;YAAE,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC;IACF,UAAU,CAAC,QAAQ,GAAG,YAAY,CAAC;IACnC,UAAU,CAAC,QAAQ,GAAG,YAAY,CAAC;IACnC,OAAO,IAAI,CAAC,UAAU,EAAE,GAAG,kBAAkB,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import van, { State } from \"vanjs-core\";\n\nimport {\n createHeadlessForm,\n HeadlessFormOutput,\n Fields,\n JSONSchemaObjectType,\n} from \"@remoteoss/json-schema-form\";\n\nimport { VanJsfField, MultiType } from \"./VanJsfField\";\nimport { JsfTheme, JsfLayout } from \"./theme\";\n\nconst { form } = van.tags;\n\n\nclass VanJsfForm {\n schema: JSONSchemaObjectType;\n config: Record<string, any>;\n isValid: State<boolean> | undefined;\n headlessForm: HeadlessFormOutput;\n formFields: VanJsfField[];\n formValues: Record<string, any>;\n theme: JsfTheme;\n layout: JsfLayout;\n\n constructor(jsonSchema: JSONSchemaObjectType, config: Record<string, any>, isValid?: State<boolean>, theme: JsfTheme = {}, layout: JsfLayout = {}) {\n // Bind methods to instance. Needed to pass functions as props to child components\n //this.handleSubmit = this.handleSubmit.bind(this);\n this.handleFieldChange = this.handleFieldChange.bind(this);\n // Receive parameters\n this.schema = jsonSchema;\n this.config = config;\n this.isValid = isValid || undefined;\n this.theme = theme;\n this.layout = layout;\n // Working with parameters\n const initialValues = { ...config?.initialValues };\n this.headlessForm = createHeadlessForm(jsonSchema, config);\n this.config.initialValues = initialValues;\n // Read documentation about `getFieldsAndValuedFromJsf` method below\n const { vanJsfFields, formValues } = this.getFieldsAndValuesFromJsf(\n this.headlessForm,\n this.config.initialValues\n );\n this.formFields = vanJsfFields;\n this.formValues = formValues;\n }\n\n /**\n * Generates fields and their initial values from a headless JSON Schema Form (JSF).\n * This method processes the fields provided by the headless form, maps them to `VanJsfField` instances,\n * and initializes the corresponding form values.\n *\n * @param headlessForm - The output of the `createHeadlessForm` function, containing metadata and configuration for the form fields.\n * @param initialValues - A record object where the keys represent field names, and the values are the initial values for the fields.\n *\n * @returns An object containing:\n * - `vanJsfFields`: An array of `VanJsfField` instances representing the fields in the form.\n * - `formValues`: A record object mapping field names to their respective initial values.\n *\n * @remarks\n * - **Field Sets**: The method currently does not support field sets recursively. This needs to be implemented as part of future enhancements.\n * - **Default Values**:\n * - The default values are determined based on the following precedence:\n * 1. Value in `initialValues`.\n * 2. The `field.default` property.\n * 3. An empty string (`\"\"`) if neither is present.\n * - Note: The `field.default` property is not clearly documented in the JSF API. The documentation mentions `defaultValue` instead, but this is not observed in practice.\n *\n * @example\n * const { vanJsfFields, formValues } = getFieldsFromJsf(headlessForm, initialValues);\n * console.log(vanJsfFields); // Array of VanJsfField instances\n * console.log(formValues); // Record of field names and their initial values\n */\n getFieldsAndValuesFromJsf(\n headlessForm: HeadlessFormOutput,\n initialValues: Record<string, any>\n ): { vanJsfFields: VanJsfField[]; formValues: Record<string, any> } {\n const fields: Fields = headlessForm.fields;\n const formValues: Record<string, any> = {};\n const vanJsfFields: VanJsfField[] = this.processFields(fields, initialValues, formValues);\n\n return { vanJsfFields, formValues };\n }\n\n handleFieldChange(field: VanJsfField, value: MultiType) {\n this.formValues[field.name] = value;\n // For file fields, also store file metadata\n if (field.inputType === \"file\") {\n this.formValues[field.name + \"__fileName\"] = field.fileNameValue;\n this.formValues[field.name + \"__fileSize\"] = field.fileSizeValue;\n this.formValues[field.name + \"__fileType\"] = field.fileTypeValue;\n }\n this.config.formValues = this.formValues\n const { formErrors } = this.headlessForm.handleValidation(this.formValues);\n let extraError = false;\n this.formFields.forEach((f) => {\n f.isVisible = f.field.isVisible as boolean;\n f.error = formErrors?.[f.name] ?? \"\";\n if (f.field.error) {\n extraError = true\n }\n });\n if (this.isValid) {\n if (formErrors || extraError) {\n this.isValid.val = false\n } else {\n this.isValid.val = true\n }\n }\n\n }\n processFields(fields: any[], initialValues: any, formValues: any, parentPath: string = \"\"): VanJsfField[] {\n return fields.map((field) => {\n // Construct the full path for the field\n\n const fieldPath: string = parentPath ? `${parentPath}.${field.name}` : field.name;\n // Determine the initial value for the field\n const initVal = initialValues[fieldPath] || field.default || \"\";\n // Store the initial value in the form values map\n formValues[fieldPath] = initVal;\n\n // Check if the field has nested fields and process them recursively\n if (field.fields && field.fields.length > 0) {\n field.fields = this.processFields(field.fields, initialValues, formValues, fieldPath);\n }\n\n // Create and return a new VanJsfField instance for this field\n const fieldLayout = this.layout[fieldPath] || this.layout[field.name] || \"\";\n return new VanJsfField(field, initVal, this.handleFieldChange, this.theme, fieldLayout);\n });\n }\n}\nexport function jsform(\n attributes: Record<string, any>,\n ...children: any[]\n): HTMLFormElement {\n if (!attributes.schema) {\n throw new Error(\"JSON Schema is required\");\n }\n const config = attributes.config ?? { initialValues: {}, formValues: {} };\n if (!config.initialValues) config.initialValues = {};\n if (!config.formValues) config.formValues = {};\n const isValid = attributes.isValid;\n const theme: JsfTheme = attributes.theme ?? {};\n const layout: JsfLayout = attributes.layout ?? {};\n const vanJsfForm: VanJsfForm = new VanJsfForm(attributes.schema, config, isValid, theme, layout);\n const fields: Element[] = vanJsfForm.formFields.map((field: VanJsfField) =>\n field.render()\n );\n const childrenWithFields = [...fields, ...children]; // Concatenate fields with other children\n const originalOnSubmit = attributes.onsubmit;\n const handleSubmit = (e: Event) => {\n e.preventDefault();\n config.formValues = vanJsfForm.formValues;\n if (originalOnSubmit) originalOnSubmit(e);\n };\n const originalOnChange = attributes.onchange;\n const handleChange = (e: Event) => {\n e.preventDefault();\n config.formValues = vanJsfForm.formValues;\n if (originalOnChange) originalOnChange(vanJsfForm, e);\n };\n attributes.onsubmit = handleSubmit;\n attributes.onchange = handleChange;\n return form(attributes, ...childrenWithFields);\n}\n"]}
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { jsform } from "./VanJsfForm";
2
+ //# sourceMappingURL=index.js.map