@whatsaaaa/form-builder-vue 0.1.2 → 0.1.4
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/index.d.ts +7 -39
- package/dist/index.js +9 -126
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
+
import { FieldNode, FieldNode as FieldNode$1, FieldPath, FieldPath as FieldPath$1, FieldRole, JsonField as JsonField$1, JsonForm, JsonFormSchema, JsonFormSchema as JsonFormSchema$1, SchemaBuilder, TypedJsonFormSchema, TypedJsonFormSchema as TypedJsonFormSchema$1, ValueKind } from "@whatsaaaa/form-builder-schema";
|
|
1
2
|
import { Component, PropType, VNode } from "vue";
|
|
2
3
|
import { FieldElementProps, FormSchema, FormStore, ValidationMode } from "@formisch/vue";
|
|
3
|
-
import { JsonField as JsonField$1, JsonForm, SchemaBuilder, ValueKind } from "@whatsaaaa/form-builder-schema";
|
|
4
|
-
import { GenericSchema } from "valibot";
|
|
5
4
|
/** Your component for each field type, by type name: `{ text: TextInput, group: Fieldset }`. */
|
|
6
5
|
type FieldComponents = Record<string, Component>;
|
|
7
|
-
/** A field's Formisch path, with real indexes: `['lines', 0, 'quantity']`. */
|
|
8
|
-
type FieldPath = readonly (string | number)[];
|
|
9
6
|
/** The props of a component for a display element, like a heading. */
|
|
10
7
|
interface DisplayFieldProps {
|
|
11
8
|
field: JsonField$1;
|
|
@@ -13,7 +10,7 @@ interface DisplayFieldProps {
|
|
|
13
10
|
/** The props of a component for a field with a value. */
|
|
14
11
|
interface ValueFieldProps {
|
|
15
12
|
field: JsonField$1;
|
|
16
|
-
path: FieldPath;
|
|
13
|
+
path: FieldPath$1;
|
|
17
14
|
/** The kind of the value, e.g. `'number'`. */
|
|
18
15
|
kind: ValueKind;
|
|
19
16
|
/** True when the definition makes the field required. */
|
|
@@ -30,7 +27,7 @@ interface ValueFieldProps {
|
|
|
30
27
|
/** The props of a component for a container of kind `object`, like the built-in group. */
|
|
31
28
|
interface GroupFieldProps {
|
|
32
29
|
field: JsonField$1;
|
|
33
|
-
path: FieldPath;
|
|
30
|
+
path: FieldPath$1;
|
|
34
31
|
}
|
|
35
32
|
/** The slots of a group component: its default slot renders the group's fields. */
|
|
36
33
|
interface GroupFieldSlots {
|
|
@@ -39,7 +36,7 @@ interface GroupFieldSlots {
|
|
|
39
36
|
/** The props of a component for a container of kind `array`, like the built-in array. */
|
|
40
37
|
interface ArrayFieldProps {
|
|
41
38
|
field: JsonField$1;
|
|
42
|
-
path: FieldPath;
|
|
39
|
+
path: FieldPath$1;
|
|
43
40
|
/** One id per item, to use as its `key`. */
|
|
44
41
|
items: string[];
|
|
45
42
|
/** The array's own error messages, e.g. from `maxLength`, or null. */
|
|
@@ -55,26 +52,6 @@ interface ArrayFieldSlots {
|
|
|
55
52
|
index: number;
|
|
56
53
|
}): VNode[];
|
|
57
54
|
}
|
|
58
|
-
/**
|
|
59
|
-
* How `<JsonFields>` renders a field: a `value` field has an input, a `group` or an `array` holds
|
|
60
|
-
* fields, and a `display` element, like a heading, has no value.
|
|
61
|
-
*/
|
|
62
|
-
type FieldRole = 'value' | 'group' | 'array' | 'display';
|
|
63
|
-
/** One field of a definition, with the fields inside it when it is a container. */
|
|
64
|
-
interface FieldNode {
|
|
65
|
-
readonly field: JsonField$1;
|
|
66
|
-
/** The field's type, e.g. `'text'`. */
|
|
67
|
-
readonly type: string;
|
|
68
|
-
readonly role: FieldRole;
|
|
69
|
-
/** The kind of the field's value, e.g. `'number'`, or `'none'` for a display element. */
|
|
70
|
-
readonly kind: ValueKind;
|
|
71
|
-
/** The kind of the items, for a field of kind `array` whose type has one. */
|
|
72
|
-
readonly itemKind: ValueKind | undefined;
|
|
73
|
-
/** Where the value is, with `'*'` for each array index: `['lines', '*', 'quantity']`. */
|
|
74
|
-
readonly dataPath: readonly (string | number)[];
|
|
75
|
-
/** The fields of a group, or of one item of an array. */
|
|
76
|
-
readonly children: readonly FieldNode[];
|
|
77
|
-
}
|
|
78
55
|
interface UseJsonFormOptions {
|
|
79
56
|
/** Builds the schema and knows your own types and rules. Defaults to `createSchemaBuilder()`. */
|
|
80
57
|
builder?: SchemaBuilder;
|
|
@@ -85,17 +62,8 @@ interface UseJsonFormOptions {
|
|
|
85
62
|
/** When a field is validated again after that, as in Formisch. */
|
|
86
63
|
revalidate?: Exclude<ValidationMode, 'initial'>;
|
|
87
64
|
}
|
|
88
|
-
/** The schema of a definition, as the builder builds it. */
|
|
89
|
-
type JsonFormSchema = ReturnType<SchemaBuilder['build']>;
|
|
90
|
-
/**
|
|
91
|
-
* The schema type of `useJsonForm<TInput, TOutput>`: your types, so Formisch's paths and values
|
|
92
|
-
* are checked. An interface works too, which Formisch's own constraint wouldn't take as it is.
|
|
93
|
-
*/
|
|
94
|
-
type TypedJsonFormSchema<TInput extends object, TOutput extends object = TInput> = GenericSchema<Plain<TInput>, Plain<TOutput>>;
|
|
95
|
-
/** The same type as an object literal type, which has the index signature Formisch requires. */
|
|
96
|
-
type Plain<T> = { [K in keyof T]: T[K]; };
|
|
97
65
|
/** What `useJsonForm` returns. Pass it to `<JsonFields>`. */
|
|
98
|
-
interface JsonFormInstance<TSchema extends FormSchema = JsonFormSchema> {
|
|
66
|
+
interface JsonFormInstance<TSchema extends FormSchema = JsonFormSchema$1> {
|
|
99
67
|
/** The Formisch form: pass it to Formisch's `<Form :of>`, or to any of its methods. */
|
|
100
68
|
readonly form: FormStore<TSchema>;
|
|
101
69
|
readonly definition: JsonForm;
|
|
@@ -103,7 +71,7 @@ interface JsonFormInstance<TSchema extends FormSchema = JsonFormSchema> {
|
|
|
103
71
|
/** The components from the options, if any. */
|
|
104
72
|
readonly components: FieldComponents | undefined;
|
|
105
73
|
/** The definition's fields as a tree, the way `<JsonFields>` renders them. */
|
|
106
|
-
readonly fields: readonly FieldNode[];
|
|
74
|
+
readonly fields: readonly FieldNode$1[];
|
|
107
75
|
}
|
|
108
76
|
/** Any form `useJsonForm` returns, typed or not: what the components take. */
|
|
109
77
|
type AnyJsonFormInstance = JsonFormInstance<FormSchema>;
|
|
@@ -118,7 +86,7 @@ export declare function useJsonForm(definition: JsonForm, options?: UseJsonFormO
|
|
|
118
86
|
* The same, with the form typed by your input type, and output type when it differs, so Formisch's
|
|
119
87
|
* paths and values are checked. The types are yours to keep in step with the definition.
|
|
120
88
|
*/
|
|
121
|
-
export declare function useJsonForm<TInput extends object, TOutput extends object = TInput>(definition: JsonForm, options?: UseJsonFormOptions): JsonFormInstance<TypedJsonFormSchema<TInput, TOutput>>;
|
|
89
|
+
export declare function useJsonForm<TInput extends object, TOutput extends object = TInput>(definition: JsonForm, options?: UseJsonFormOptions): JsonFormInstance<TypedJsonFormSchema$1<TInput, TOutput>>;
|
|
122
90
|
/**
|
|
123
91
|
* Renders one field of a `useJsonForm` form, wherever you put it inside Formisch's `<Form>`. A
|
|
124
92
|
* group or an array comes with its fields. Leave the field out of `<JsonFields>` with `except`.
|
package/dist/index.js
CHANGED
|
@@ -1,51 +1,6 @@
|
|
|
1
|
+
import { allFields, coerceInput, createSchemaBuilder, dotPathOf, findField, isRequired, toFieldPath } from "@whatsaaaa/form-builder-schema";
|
|
1
2
|
import { defineComponent, h } from "vue";
|
|
2
3
|
import { insert, move, remove, useField, useFieldArray, useForm } from "@formisch/vue";
|
|
3
|
-
import { createSchemaBuilder } from "@whatsaaaa/form-builder-schema";
|
|
4
|
-
// src/field-paths.ts
|
|
5
|
-
/**
|
|
6
|
-
* A field's path as `only`, `except` and `<JsonField>` name it: `'address.city'`, or
|
|
7
|
-
* `'lines.*.quantity'` for a field of an array's items. Undefined for a field without a name.
|
|
8
|
-
*/
|
|
9
|
-
const pathOf = (node) => node.field.name === void 0 ? void 0 : node.dataPath.join(".");
|
|
10
|
-
/** Every field of the tree, in document order, a container before its fields. */
|
|
11
|
-
function* allFields(nodes) {
|
|
12
|
-
for (const node of nodes) {
|
|
13
|
-
yield node;
|
|
14
|
-
yield* allFields(node.children);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* The field at `path`. A path that names no field is a mistake in the code, so it throws. With
|
|
19
|
-
* `placed`, the field is rendered on its own, which a field of an array's items can't be: it has no
|
|
20
|
-
* index outside its item.
|
|
21
|
-
*/
|
|
22
|
-
function findField(nodes, path, placed) {
|
|
23
|
-
const node = [...allFields(nodes)].find((candidate) => pathOf(candidate) === path);
|
|
24
|
-
if (!node) throw new TypeError(`No field at "${path}" in the definition.`);
|
|
25
|
-
if (placed && node.dataPath.includes("*")) {
|
|
26
|
-
const array = path.slice(0, path.indexOf(".*"));
|
|
27
|
-
throw new TypeError(`"${path}" is in an array's items, so it can't be placed on its own. Place "${array}" instead.`);
|
|
28
|
-
}
|
|
29
|
-
return node;
|
|
30
|
-
}
|
|
31
|
-
// src/item-input.ts
|
|
32
|
-
/**
|
|
33
|
-
* The input of a new item of an array, from the defaults in the definition: an object of its
|
|
34
|
-
* fields' input, or the input of the item field for a list of single values.
|
|
35
|
-
*/
|
|
36
|
-
function itemInput(builder, array) {
|
|
37
|
-
const fields = array.children.map((child) => child.field);
|
|
38
|
-
const [only] = array.children;
|
|
39
|
-
if (array.children.length === 1 && only?.role !== "display" && only?.dataPath.at(-1) === "*") return initialInput(builder, [{
|
|
40
|
-
...only.field,
|
|
41
|
-
name: "item"
|
|
42
|
-
}]).item;
|
|
43
|
-
return initialInput(builder, fields);
|
|
44
|
-
}
|
|
45
|
-
const initialInput = (builder, fields) => builder.getInitialInput({
|
|
46
|
-
version: "1",
|
|
47
|
-
fields
|
|
48
|
-
});
|
|
49
4
|
// src/array-field.ts
|
|
50
5
|
/** Connects a container of kind `array` to Formisch, and renders your component for it. */
|
|
51
6
|
const ArrayField = defineComponent({
|
|
@@ -79,7 +34,7 @@ const ArrayField = defineComponent({
|
|
|
79
34
|
const methods = {
|
|
80
35
|
add: () => insert(props.of.form, {
|
|
81
36
|
path: path(),
|
|
82
|
-
initialInput:
|
|
37
|
+
initialInput: props.of.builder.getItemInput(props.node.field)
|
|
83
38
|
}),
|
|
84
39
|
remove: (index) => remove(props.of.form, {
|
|
85
40
|
path: path(),
|
|
@@ -103,39 +58,6 @@ const ArrayField = defineComponent({
|
|
|
103
58
|
};
|
|
104
59
|
}
|
|
105
60
|
});
|
|
106
|
-
// src/coerce-input.ts
|
|
107
|
-
/**
|
|
108
|
-
* Turns what an input element gives into what the field's schema expects: `'5'` into `5` for a
|
|
109
|
-
* number, and a `FileList` into a file, or an array of files for a field of kind `array`. Anything
|
|
110
|
-
* else is passed through, and the schema reports it.
|
|
111
|
-
*/
|
|
112
|
-
function coerceInput(input, kind, itemKind) {
|
|
113
|
-
if (kind === "array") {
|
|
114
|
-
const items = isFileList(input) ? Array.from(input) : input;
|
|
115
|
-
if (!Array.isArray(items) || itemKind === void 0) return items;
|
|
116
|
-
return items.map((item) => coerceInput(item, itemKind));
|
|
117
|
-
}
|
|
118
|
-
if (isFileList(input)) return kind === "file" ? input[0] ?? void 0 : input;
|
|
119
|
-
if (kind === "number" && typeof input === "string") return toNumber(input);
|
|
120
|
-
return input;
|
|
121
|
-
}
|
|
122
|
-
/** An empty string means no value. One that isn't a number stays a string, for the schema. */
|
|
123
|
-
function toNumber(input) {
|
|
124
|
-
if (input.trim() === "") return void 0;
|
|
125
|
-
const number = Number(input);
|
|
126
|
-
return Number.isNaN(number) ? input : number;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* A `FileList`, or anything shaped like one: an array-like whose items are all files. Checked by
|
|
130
|
-
* shape rather than with `instanceof FileList`, because a `File[]` from a component that spread the
|
|
131
|
-
* list, or from a DOM shim like happy-dom whose `DataTransfer.files` is an array, should count too.
|
|
132
|
-
* `File` only exists in a browser, so check for it before using it, e.g. during SSR.
|
|
133
|
-
*/
|
|
134
|
-
function isFileList(value) {
|
|
135
|
-
if (typeof File === "undefined" || typeof value !== "object" || value === null) return false;
|
|
136
|
-
if (value instanceof File || typeof value.length !== "number") return false;
|
|
137
|
-
return Array.from(value).every((item) => item instanceof File);
|
|
138
|
-
}
|
|
139
61
|
// src/value-field.ts
|
|
140
62
|
/** Connects a field with a value to Formisch, and renders your component for it. */
|
|
141
63
|
const ValueField = defineComponent({
|
|
@@ -161,7 +83,7 @@ const ValueField = defineComponent({
|
|
|
161
83
|
setup(props) {
|
|
162
84
|
const field = useField(() => props.of.form, () => ({ path: props.path }));
|
|
163
85
|
const setInput = (input) => {
|
|
164
|
-
field.input = coerceInput(input, props.node
|
|
86
|
+
field.input = coerceInput(input, props.node);
|
|
165
87
|
};
|
|
166
88
|
return () => {
|
|
167
89
|
const fieldProps = {
|
|
@@ -178,7 +100,6 @@ const ValueField = defineComponent({
|
|
|
178
100
|
};
|
|
179
101
|
}
|
|
180
102
|
});
|
|
181
|
-
const isRequired = (field) => field.required === true || typeof field.required === "object" && field.required !== null;
|
|
182
103
|
// src/render-fields.ts
|
|
183
104
|
/** The components from the props, or else the ones `useJsonForm` got. */
|
|
184
105
|
function resolveComponents(components, of) {
|
|
@@ -206,7 +127,7 @@ function renderFields(ctx, nodes, indexes) {
|
|
|
206
127
|
}
|
|
207
128
|
function renderField(ctx, node, indexes, position) {
|
|
208
129
|
const component = ctx.components[node.type];
|
|
209
|
-
const path =
|
|
130
|
+
const path = toFieldPath(node.dataPath, indexes);
|
|
210
131
|
const key = node.field.name ?? `#${position}`;
|
|
211
132
|
switch (node.role) {
|
|
212
133
|
case "display": return h(component, {
|
|
@@ -235,11 +156,6 @@ function renderField(ctx, node, indexes, position) {
|
|
|
235
156
|
});
|
|
236
157
|
}
|
|
237
158
|
}
|
|
238
|
-
/** The field's data path, with each `'*'` replaced by the index of the item it is in. */
|
|
239
|
-
function toPath(dataPath, indexes) {
|
|
240
|
-
let next = 0;
|
|
241
|
-
return dataPath.map((key) => key === "*" ? indexes[next++] ?? key : key);
|
|
242
|
-
}
|
|
243
159
|
// src/json-field.ts
|
|
244
160
|
/**
|
|
245
161
|
* Renders one field of a `useJsonForm` form, wherever you put it inside Formisch's `<Form>`. A
|
|
@@ -262,7 +178,7 @@ const JsonField = defineComponent({
|
|
|
262
178
|
components: { type: Object }
|
|
263
179
|
},
|
|
264
180
|
setup(props) {
|
|
265
|
-
const node = findField(props.of.fields, props.path, true);
|
|
181
|
+
const node = findField(props.of.fields, props.path, { placed: true });
|
|
266
182
|
const ctx = {
|
|
267
183
|
of: props.of,
|
|
268
184
|
components: resolveComponents(props.components, props.of),
|
|
@@ -296,11 +212,11 @@ const JsonFields = defineComponent({
|
|
|
296
212
|
setup(props) {
|
|
297
213
|
const fields = props.of.fields;
|
|
298
214
|
const except = new Set(props.except);
|
|
299
|
-
for (const path of except) findField(fields, path
|
|
215
|
+
for (const path of except) findField(fields, path);
|
|
300
216
|
const ctx = {
|
|
301
217
|
of: props.of,
|
|
302
218
|
components: resolveComponents(props.components, props.of),
|
|
303
|
-
skip: (node) => except.has(
|
|
219
|
+
skip: (node) => except.has(dotPathOf(node) ?? "")
|
|
304
220
|
};
|
|
305
221
|
const nodes = props.only ? onlyFields(fields, props.only) : fields;
|
|
306
222
|
checkComponents(ctx, nodes);
|
|
@@ -309,42 +225,9 @@ const JsonFields = defineComponent({
|
|
|
309
225
|
});
|
|
310
226
|
/** The fields `only` names, in the order of the definition, each once. */
|
|
311
227
|
function onlyFields(fields, only) {
|
|
312
|
-
const named = new Set(only.map((path) => findField(fields, path, true)));
|
|
228
|
+
const named = new Set(only.map((path) => findField(fields, path, { placed: true })));
|
|
313
229
|
return [...allFields(fields)].filter((node) => named.has(node));
|
|
314
230
|
}
|
|
315
|
-
// src/field-tree.ts
|
|
316
|
-
/**
|
|
317
|
-
* The fields of a definition that builds, as a tree. It comes from the builder's `walkFields`, so
|
|
318
|
-
* your own container types are in it too.
|
|
319
|
-
*/
|
|
320
|
-
function fieldTree(builder, definition) {
|
|
321
|
-
const roots = [];
|
|
322
|
-
const lists = [roots];
|
|
323
|
-
for (const walked of builder.walkFields(definition)) {
|
|
324
|
-
const children = [];
|
|
325
|
-
lists.length = walked.depth + 1;
|
|
326
|
-
lists.at(-1)?.push(toNode(walked, builder, children));
|
|
327
|
-
lists.push(children);
|
|
328
|
-
}
|
|
329
|
-
return roots;
|
|
330
|
-
}
|
|
331
|
-
function toNode(walked, builder, children) {
|
|
332
|
-
const kind = walked.kind;
|
|
333
|
-
return {
|
|
334
|
-
field: walked.field,
|
|
335
|
-
type: walked.type,
|
|
336
|
-
role: roleOf(kind, builder.fieldTypes[walked.type]?.container === true),
|
|
337
|
-
kind,
|
|
338
|
-
itemKind: walked.itemKind,
|
|
339
|
-
dataPath: walked.dataPath,
|
|
340
|
-
children
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
function roleOf(kind, container) {
|
|
344
|
-
if (kind === "none") return "display";
|
|
345
|
-
if (!container) return "value";
|
|
346
|
-
return kind === "array" ? "array" : "group";
|
|
347
|
-
}
|
|
348
231
|
// src/use-json-form.ts
|
|
349
232
|
function useJsonForm(definition, options = {}) {
|
|
350
233
|
const builder = options.builder ?? createSchemaBuilder();
|
|
@@ -360,7 +243,7 @@ function useJsonForm(definition, options = {}) {
|
|
|
360
243
|
definition,
|
|
361
244
|
builder,
|
|
362
245
|
components,
|
|
363
|
-
fields:
|
|
246
|
+
fields: builder.getFieldTree(definition)
|
|
364
247
|
};
|
|
365
248
|
}
|
|
366
249
|
export { JsonField, JsonFields, useJsonForm };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/field-paths.ts","../src/item-input.ts","../src/array-field.ts","../src/coerce-input.ts","../src/value-field.ts","../src/render-fields.ts","../src/json-field.ts","../src/json-fields.ts","../src/field-tree.ts","../src/use-json-form.ts"],"sourcesContent":["import type { FieldNode } from './field-tree'\n\n/**\n * A field's path as `only`, `except` and `<JsonField>` name it: `'address.city'`, or\n * `'lines.*.quantity'` for a field of an array's items. Undefined for a field without a name.\n */\nexport const pathOf = (node: FieldNode): string | undefined =>\n node.field.name === undefined ? undefined : node.dataPath.join('.')\n\n/** Every field of the tree, in document order, a container before its fields. */\nexport function* allFields(nodes: readonly FieldNode[]): Generator<FieldNode, void, undefined> {\n for (const node of nodes) {\n yield node\n yield* allFields(node.children)\n }\n}\n\n/**\n * The field at `path`. A path that names no field is a mistake in the code, so it throws. With\n * `placed`, the field is rendered on its own, which a field of an array's items can't be: it has no\n * index outside its item.\n */\nexport function findField(nodes: readonly FieldNode[], path: string, placed: boolean): FieldNode {\n const node = [...allFields(nodes)].find((candidate) => pathOf(candidate) === path)\n if (!node) throw new TypeError(`No field at \"${path}\" in the definition.`)\n if (placed && node.dataPath.includes('*')) {\n const array = path.slice(0, path.indexOf('.*'))\n throw new TypeError(\n `\"${path}\" is in an array's items, so it can't be placed on its own. Place \"${array}\" instead.`,\n )\n }\n return node\n}\n","import type { JsonField, SchemaBuilder } from '@whatsaaaa/form-builder-schema'\nimport type { FieldNode } from './field-tree'\n\n/**\n * The input of a new item of an array, from the defaults in the definition: an object of its\n * fields' input, or the input of the item field for a list of single values.\n */\nexport function itemInput(builder: SchemaBuilder, array: FieldNode): unknown {\n const fields = array.children.map((child) => child.field)\n const [only] = array.children\n // The field of a list of single values has no name: its value is the item itself.\n if (array.children.length === 1 && only?.role !== 'display' && only?.dataPath.at(-1) === '*') {\n return initialInput(builder, [{ ...only.field, name: 'item' }]).item\n }\n return initialInput(builder, fields)\n}\n\nconst initialInput = (builder: SchemaBuilder, fields: JsonField[]) =>\n builder.getInitialInput({ version: '1', fields })\n","import { insert, move, remove, useFieldArray } from '@formisch/vue'\nimport { type Component, defineComponent, h, type PropType, type VNode } from 'vue'\nimport type { ArrayFieldProps, FieldPath } from './field-components'\nimport type { FieldNode } from './field-tree'\nimport { itemInput } from './item-input'\nimport type { AnyJsonFormInstance } from './use-json-form'\n\n/** Connects a container of kind `array` to Formisch, and renders your component for it. */\nexport const ArrayField = defineComponent({\n name: 'ArrayField',\n props: {\n of: { type: Object as PropType<AnyJsonFormInstance>, required: true },\n node: { type: Object as PropType<FieldNode>, required: true },\n path: { type: Array as PropType<FieldPath>, required: true },\n component: { type: [Object, Function] as PropType<Component>, required: true },\n /** Renders the fields of the item at `index`. */\n renderItem: { type: Function as PropType<(index: number) => VNode[]>, required: true },\n },\n setup(props) {\n // The path comes from the definition at runtime, so the schema's types can't check it.\n const path = () => props.path as never\n const array = useFieldArray(\n () => props.of.form,\n () => ({ path: path() }),\n )\n\n const methods = {\n // A new item starts with the defaults of its fields, like the items of a new form.\n add: () =>\n insert(props.of.form, {\n path: path(),\n initialInput: itemInput(props.of.builder, props.node) as never,\n }),\n remove: (index: number) => remove(props.of.form, { path: path(), at: index }),\n move: (from: number, to: number) => move(props.of.form, { path: path(), from, to }),\n }\n\n return () => {\n const fieldProps: ArrayFieldProps = {\n field: props.node.field,\n path: props.path,\n items: array.items,\n errors: array.errors,\n ...methods,\n }\n return h(props.component, fieldProps, {\n default: ({ index }: { index: number }) => props.renderItem(index),\n })\n }\n },\n})\n","import type { ValueKind } from '@whatsaaaa/form-builder-schema'\n\n/**\n * Turns what an input element gives into what the field's schema expects: `'5'` into `5` for a\n * number, and a `FileList` into a file, or an array of files for a field of kind `array`. Anything\n * else is passed through, and the schema reports it.\n */\nexport function coerceInput(input: unknown, kind: ValueKind, itemKind?: ValueKind): unknown {\n if (kind === 'array') {\n const items = isFileList(input) ? Array.from(input) : input\n if (!Array.isArray(items) || itemKind === undefined) return items\n return items.map((item: unknown) => coerceInput(item, itemKind))\n }\n if (isFileList(input)) return kind === 'file' ? (input[0] ?? undefined) : input\n if (kind === 'number' && typeof input === 'string') return toNumber(input)\n return input\n}\n\n/** An empty string means no value. One that isn't a number stays a string, for the schema. */\nfunction toNumber(input: string): number | string | undefined {\n if (input.trim() === '') return undefined\n const number = Number(input)\n return Number.isNaN(number) ? input : number\n}\n\n/**\n * A `FileList`, or anything shaped like one: an array-like whose items are all files. Checked by\n * shape rather than with `instanceof FileList`, because a `File[]` from a component that spread the\n * list, or from a DOM shim like happy-dom whose `DataTransfer.files` is an array, should count too.\n * `File` only exists in a browser, so check for it before using it, e.g. during SSR.\n */\nfunction isFileList(value: unknown): value is ArrayLike<File> {\n if (typeof File === 'undefined' || typeof value !== 'object' || value === null) return false\n if (value instanceof File || typeof (value as ArrayLike<unknown>).length !== 'number')\n return false\n return Array.from(value as ArrayLike<unknown>).every((item) => item instanceof File)\n}\n","import { useField } from '@formisch/vue'\nimport type { JsonField } from '@whatsaaaa/form-builder-schema'\nimport { type Component, defineComponent, h, type PropType } from 'vue'\nimport { coerceInput } from './coerce-input'\nimport type { FieldPath, ValueFieldProps } from './field-components'\nimport type { FieldNode } from './field-tree'\nimport type { AnyJsonFormInstance } from './use-json-form'\n\n/** Connects a field with a value to Formisch, and renders your component for it. */\nexport const ValueField = defineComponent({\n name: 'ValueField',\n props: {\n of: { type: Object as PropType<AnyJsonFormInstance>, required: true },\n node: { type: Object as PropType<FieldNode>, required: true },\n path: { type: Array as PropType<FieldPath>, required: true },\n component: { type: [Object, Function] as PropType<Component>, required: true },\n },\n setup(props) {\n // The path comes from the definition at runtime, so the schema's types can't check it.\n const field = useField(\n () => props.of.form,\n () => ({ path: props.path as never }),\n )\n\n const setInput = (input: unknown) => {\n field.input = coerceInput(input, props.node.kind, props.node.itemKind) as never\n }\n\n return () => {\n const fieldProps: ValueFieldProps = {\n field: props.node.field,\n path: props.path,\n kind: props.node.kind,\n required: isRequired(props.node.field),\n input: field.input,\n errors: field.errors,\n inputProps: field.props,\n setInput,\n }\n return h(props.component, fieldProps)\n }\n },\n})\n\nconst isRequired = (field: JsonField) =>\n field.required === true || (typeof field.required === 'object' && field.required !== null)\n","import { type Component, h, type VNode } from 'vue'\nimport { ArrayField } from './array-field'\nimport type { FieldComponents, FieldPath } from './field-components'\nimport type { FieldNode } from './field-tree'\nimport type { AnyJsonFormInstance } from './use-json-form'\nimport { ValueField } from './value-field'\n\n/** What `<JsonFields>` and `<JsonField>` render with. */\nexport interface RenderContext {\n of: AnyJsonFormInstance\n components: FieldComponents\n /** True for a field that isn't rendered, and so neither are the fields inside it. */\n skip: (node: FieldNode) => boolean\n}\n\n/** The components from the props, or else the ones `useJsonForm` got. */\nexport function resolveComponents(\n components: FieldComponents | undefined,\n of: AnyJsonFormInstance,\n): FieldComponents {\n const resolved = components ?? of.components\n if (!resolved) {\n throw new TypeError('No field components. Pass them to useJsonForm, or to the component.')\n }\n return resolved\n}\n\n/** Throws for the field types that would render without a component, naming each once. */\nexport function checkComponents(ctx: RenderContext, nodes: readonly FieldNode[]): void {\n const missing = new Set<string>()\n const visit = (node: FieldNode) => {\n if (ctx.skip(node)) return\n if (!Object.hasOwn(ctx.components, node.type)) missing.add(node.type)\n node.children.forEach(visit)\n }\n nodes.forEach(visit)\n if (!missing.size) return\n\n // A missing component is a mistake in the code, not in the definition, so it throws early.\n const names = [...missing].map((type) => `\"${type}\"`).join(', ')\n const [noun, pronoun] = missing.size > 1 ? ['types', 'them'] : ['type', 'it']\n throw new TypeError(\n `No component for the field ${noun} ${names}. Add ${pronoun} to the components.`,\n )\n}\n\n/** `indexes` are the indexes of the array items the fields are in, outermost first. */\nexport function renderFields(\n ctx: RenderContext,\n nodes: readonly FieldNode[],\n indexes: readonly number[],\n): VNode[] {\n return nodes\n .filter((node) => !ctx.skip(node))\n .map((node, position) => renderField(ctx, node, indexes, position))\n}\n\nexport function renderField(\n ctx: RenderContext,\n node: FieldNode,\n indexes: readonly number[],\n position: number,\n): VNode {\n const component = ctx.components[node.type] as Component\n const path = toPath(node.dataPath, indexes)\n const key = node.field.name ?? `#${position}`\n switch (node.role) {\n case 'display':\n return h(component, { key, field: node.field })\n case 'group':\n return h(\n component,\n { key, field: node.field, path },\n { default: () => renderFields(ctx, node.children, indexes) },\n )\n case 'array':\n return h(ArrayField, {\n key,\n of: ctx.of,\n node,\n path,\n component,\n renderItem: (index: number) => renderFields(ctx, node.children, [...indexes, index]),\n })\n case 'value':\n return h(ValueField, { key, of: ctx.of, node, path, component })\n }\n}\n\n/** The field's data path, with each `'*'` replaced by the index of the item it is in. */\nfunction toPath(dataPath: FieldNode['dataPath'], indexes: readonly number[]): FieldPath {\n let next = 0\n return dataPath.map((key) => (key === '*' ? (indexes[next++] ?? key) : key))\n}\n","import { defineComponent, type PropType } from 'vue'\nimport type { FieldComponents } from './field-components'\nimport { findField } from './field-paths'\nimport {\n checkComponents,\n type RenderContext,\n renderField,\n resolveComponents,\n} from './render-fields'\nimport type { AnyJsonFormInstance } from './use-json-form'\n\n/**\n * Renders one field of a `useJsonForm` form, wherever you put it inside Formisch's `<Form>`. A\n * group or an array comes with its fields. Leave the field out of `<JsonFields>` with `except`.\n */\nexport const JsonField = defineComponent({\n name: 'JsonField',\n props: {\n /** What `useJsonForm` returned. */\n of: { type: Object as PropType<AnyJsonFormInstance>, required: true },\n /** The field's path: `'email'`, or `'address.city'` for a field of a group. */\n path: { type: String, required: true },\n /** Defaults to the components `useJsonForm` got. */\n components: { type: Object as PropType<FieldComponents> },\n },\n setup(props) {\n const node = findField(props.of.fields, props.path, true)\n const ctx: RenderContext = {\n of: props.of,\n components: resolveComponents(props.components, props.of),\n skip: () => false,\n }\n checkComponents(ctx, [node])\n\n return () => renderField(ctx, node, [], 0)\n },\n})\n","import { defineComponent, type PropType } from 'vue'\nimport type { FieldComponents } from './field-components'\nimport { allFields, findField, pathOf } from './field-paths'\nimport type { FieldNode } from './field-tree'\nimport {\n checkComponents,\n type RenderContext,\n renderFields,\n resolveComponents,\n} from './render-fields'\nimport type { AnyJsonFormInstance } from './use-json-form'\n\n/**\n * Renders the fields of a `useJsonForm` form with your components, one per field type. It renders\n * nothing of its own, so put it inside Formisch's `<Form>` with your own submit button. `only` and\n * `except` are read when it sets up.\n */\nexport const JsonFields = defineComponent({\n name: 'JsonFields',\n props: {\n /** What `useJsonForm` returned. */\n of: { type: Object as PropType<AnyJsonFormInstance>, required: true },\n /** Defaults to the components `useJsonForm` got. */\n components: { type: Object as PropType<FieldComponents> },\n /** Renders only these fields, by path, in the order of the definition. */\n only: { type: Array as PropType<readonly string[]> },\n /** Leaves out these fields, by path, e.g. the ones you place with `<JsonField>`. */\n except: { type: Array as PropType<readonly string[]> },\n },\n setup(props) {\n const fields = props.of.fields\n const except = new Set(props.except)\n // A path that names no field is a typo, so check them even though nothing uses the result.\n for (const path of except) findField(fields, path, false)\n\n const ctx: RenderContext = {\n of: props.of,\n components: resolveComponents(props.components, props.of),\n skip: (node) => except.has(pathOf(node) ?? ''),\n }\n const nodes = props.only ? onlyFields(fields, props.only) : fields\n checkComponents(ctx, nodes)\n\n return () => renderFields(ctx, nodes, [])\n },\n})\n\n/** The fields `only` names, in the order of the definition, each once. */\nfunction onlyFields(fields: readonly FieldNode[], only: readonly string[]): FieldNode[] {\n const named = new Set(only.map((path) => findField(fields, path, true)))\n return [...allFields(fields)].filter((node) => named.has(node))\n}\n","import type {\n JsonField,\n JsonForm,\n SchemaBuilder,\n ValueKind,\n WalkedField,\n} from '@whatsaaaa/form-builder-schema'\n\n/**\n * How `<JsonFields>` renders a field: a `value` field has an input, a `group` or an `array` holds\n * fields, and a `display` element, like a heading, has no value.\n */\nexport type FieldRole = 'value' | 'group' | 'array' | 'display'\n\n/** One field of a definition, with the fields inside it when it is a container. */\nexport interface FieldNode {\n readonly field: JsonField\n /** The field's type, e.g. `'text'`. */\n readonly type: string\n readonly role: FieldRole\n /** The kind of the field's value, e.g. `'number'`, or `'none'` for a display element. */\n readonly kind: ValueKind\n /** The kind of the items, for a field of kind `array` whose type has one. */\n readonly itemKind: ValueKind | undefined\n /** Where the value is, with `'*'` for each array index: `['lines', '*', 'quantity']`. */\n readonly dataPath: readonly (string | number)[]\n /** The fields of a group, or of one item of an array. */\n readonly children: readonly FieldNode[]\n}\n\n/**\n * The fields of a definition that builds, as a tree. It comes from the builder's `walkFields`, so\n * your own container types are in it too.\n */\nexport function fieldTree(builder: SchemaBuilder, definition: JsonForm): FieldNode[] {\n const roots: FieldNode[] = []\n // The list each depth adds its fields to. A container comes before its fields, so the list at a\n // field's depth is the one its parent opened.\n const lists: FieldNode[][] = [roots]\n for (const walked of builder.walkFields(definition)) {\n const children: FieldNode[] = []\n lists.length = walked.depth + 1\n lists.at(-1)?.push(toNode(walked, builder, children))\n lists.push(children)\n }\n return roots\n}\n\nfunction toNode(walked: WalkedField, builder: SchemaBuilder, children: FieldNode[]): FieldNode {\n // The definition builds, so the builder gave every field its kind.\n const kind = walked.kind as ValueKind\n return {\n field: walked.field,\n type: walked.type,\n role: roleOf(kind, builder.fieldTypes[walked.type]?.container === true),\n kind,\n itemKind: walked.itemKind,\n dataPath: walked.dataPath,\n children,\n }\n}\n\nfunction roleOf(kind: ValueKind, container: boolean): FieldRole {\n if (kind === 'none') return 'display'\n if (!container) return 'value'\n return kind === 'array' ? 'array' : 'group'\n}\n","import { type FormSchema, type FormStore, useForm, type ValidationMode } from '@formisch/vue'\nimport {\n createSchemaBuilder,\n type JsonForm,\n type SchemaBuilder,\n} from '@whatsaaaa/form-builder-schema'\nimport type { GenericSchema } from 'valibot'\nimport type { FieldComponents } from './field-components'\nimport { type FieldNode, fieldTree } from './field-tree'\n\nexport interface UseJsonFormOptions {\n /** Builds the schema and knows your own types and rules. Defaults to `createSchemaBuilder()`. */\n builder?: SchemaBuilder\n /** Your component for each field type, so `<JsonFields>` and `<JsonField>` don't need them. */\n components?: FieldComponents\n /** When a field is validated the first time, as in Formisch. */\n validate?: ValidationMode\n /** When a field is validated again after that, as in Formisch. */\n revalidate?: Exclude<ValidationMode, 'initial'>\n}\n\n/** The schema of a definition, as the builder builds it. */\nexport type JsonFormSchema = ReturnType<SchemaBuilder['build']>\n\n/**\n * The schema type of `useJsonForm<TInput, TOutput>`: your types, so Formisch's paths and values\n * are checked. An interface works too, which Formisch's own constraint wouldn't take as it is.\n */\nexport type TypedJsonFormSchema<\n TInput extends object,\n TOutput extends object = TInput,\n> = GenericSchema<Plain<TInput>, Plain<TOutput>>\n\n/** The same type as an object literal type, which has the index signature Formisch requires. */\ntype Plain<T> = { [K in keyof T]: T[K] }\n\n/** What `useJsonForm` returns. Pass it to `<JsonFields>`. */\nexport interface JsonFormInstance<TSchema extends FormSchema = JsonFormSchema> {\n /** The Formisch form: pass it to Formisch's `<Form :of>`, or to any of its methods. */\n readonly form: FormStore<TSchema>\n readonly definition: JsonForm\n readonly builder: SchemaBuilder\n /** The components from the options, if any. */\n readonly components: FieldComponents | undefined\n /** The definition's fields as a tree, the way `<JsonFields>` renders them. */\n readonly fields: readonly FieldNode[]\n}\n\n/** Any form `useJsonForm` returns, typed or not: what the components take. */\nexport type AnyJsonFormInstance = JsonFormInstance<FormSchema>\n\n/**\n * A Formisch form for a definition, with its schema and initial input from the builder. A\n * definition with issues throws the builder's `DefinitionError`, so run `validate()` first when it\n * comes from outside your code. The definition is read once: give the form a new `:key` to use\n * another one.\n */\nexport function useJsonForm(definition: JsonForm, options?: UseJsonFormOptions): JsonFormInstance\n/**\n * The same, with the form typed by your input type, and output type when it differs, so Formisch's\n * paths and values are checked. The types are yours to keep in step with the definition.\n */\nexport function useJsonForm<TInput extends object, TOutput extends object = TInput>(\n definition: JsonForm,\n options?: UseJsonFormOptions,\n): JsonFormInstance<TypedJsonFormSchema<TInput, TOutput>>\nexport function useJsonForm(\n definition: JsonForm,\n options: UseJsonFormOptions = {},\n): JsonFormInstance {\n const builder = options.builder ?? createSchemaBuilder()\n const form = useForm({\n schema: builder.build(definition),\n initialInput: builder.getInitialInput(definition),\n validate: options.validate,\n revalidate: options.revalidate,\n })\n const { components } = options\n return { form, definition, builder, components, fields: fieldTree(builder, definition) }\n}\n"],"mappings":";;;;;;;;AAMA,MAAa,UAAU,SACrB,KAAK,MAAM,SAAS,KAAA,IAAY,KAAA,IAAY,KAAK,SAAS,KAAK,GAAG;;AAGpE,UAAiB,UAAU,OAAoE;CAC7F,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM;EACN,OAAO,UAAU,KAAK,QAAQ;CAChC;AACF;;;;;;AAOA,SAAgB,UAAU,OAA6B,MAAc,QAA4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","../src/json-field.ts","../src/json-fields.ts","../src/use-json-form.ts"],"sourcesContent":["import { insert, move, remove, useFieldArray } from '@formisch/vue'\nimport type { FieldNode, FieldPath } from '@whatsaaaa/form-builder-schema'\nimport { type Component, defineComponent, h, type PropType, type VNode } from 'vue'\nimport type { ArrayFieldProps } from './field-components'\nimport type { AnyJsonFormInstance } from './use-json-form'\n\n/** Connects a container of kind `array` to Formisch, and renders your component for it. */\nexport const ArrayField = defineComponent({\n name: 'ArrayField',\n props: {\n of: { type: Object as PropType<AnyJsonFormInstance>, required: true },\n node: { type: Object as PropType<FieldNode>, required: true },\n path: { type: Array as PropType<FieldPath>, required: true },\n component: { type: [Object, Function] as PropType<Component>, required: true },\n /** Renders the fields of the item at `index`. */\n renderItem: { type: Function as PropType<(index: number) => VNode[]>, required: true },\n },\n setup(props) {\n // The path comes from the definition at runtime, so the schema's types can't check it.\n const path = () => props.path as never\n const array = useFieldArray(\n () => props.of.form,\n () => ({ path: path() }),\n )\n\n const methods = {\n // A new item starts with the defaults of its fields, like the items of a new form.\n add: () =>\n insert(props.of.form, {\n path: path(),\n initialInput: props.of.builder.getItemInput(props.node.field) as never,\n }),\n remove: (index: number) => remove(props.of.form, { path: path(), at: index }),\n move: (from: number, to: number) => move(props.of.form, { path: path(), from, to }),\n }\n\n return () => {\n const fieldProps: ArrayFieldProps = {\n field: props.node.field,\n path: props.path,\n items: array.items,\n errors: array.errors,\n ...methods,\n }\n return h(props.component, fieldProps, {\n default: ({ index }: { index: number }) => props.renderItem(index),\n })\n }\n },\n})\n","import { useField } from '@formisch/vue'\nimport {\n coerceInput,\n type FieldNode,\n type FieldPath,\n isRequired,\n} from '@whatsaaaa/form-builder-schema'\nimport { type Component, defineComponent, h, type PropType } from 'vue'\nimport type { ValueFieldProps } from './field-components'\nimport type { AnyJsonFormInstance } from './use-json-form'\n\n/** Connects a field with a value to Formisch, and renders your component for it. */\nexport const ValueField = defineComponent({\n name: 'ValueField',\n props: {\n of: { type: Object as PropType<AnyJsonFormInstance>, required: true },\n node: { type: Object as PropType<FieldNode>, required: true },\n path: { type: Array as PropType<FieldPath>, required: true },\n component: { type: [Object, Function] as PropType<Component>, required: true },\n },\n setup(props) {\n // The path comes from the definition at runtime, so the schema's types can't check it.\n const field = useField(\n () => props.of.form,\n () => ({ path: props.path as never }),\n )\n\n const setInput = (input: unknown) => {\n field.input = coerceInput(input, props.node) as never\n }\n\n return () => {\n const fieldProps: ValueFieldProps = {\n field: props.node.field,\n path: props.path,\n kind: props.node.kind,\n required: isRequired(props.node.field),\n input: field.input,\n errors: field.errors,\n inputProps: field.props,\n setInput,\n }\n return h(props.component, fieldProps)\n }\n },\n})\n","import { type FieldNode, toFieldPath } from '@whatsaaaa/form-builder-schema'\nimport { type Component, h, type VNode } from 'vue'\nimport { ArrayField } from './array-field'\nimport type { FieldComponents } from './field-components'\nimport type { AnyJsonFormInstance } from './use-json-form'\nimport { ValueField } from './value-field'\n\n/** What `<JsonFields>` and `<JsonField>` render with. */\nexport interface RenderContext {\n of: AnyJsonFormInstance\n components: FieldComponents\n /** True for a field that isn't rendered, and so neither are the fields inside it. */\n skip: (node: FieldNode) => boolean\n}\n\n/** The components from the props, or else the ones `useJsonForm` got. */\nexport function resolveComponents(\n components: FieldComponents | undefined,\n of: AnyJsonFormInstance,\n): FieldComponents {\n const resolved = components ?? of.components\n if (!resolved) {\n throw new TypeError('No field components. Pass them to useJsonForm, or to the component.')\n }\n return resolved\n}\n\n/** Throws for the field types that would render without a component, naming each once. */\nexport function checkComponents(ctx: RenderContext, nodes: readonly FieldNode[]): void {\n const missing = new Set<string>()\n const visit = (node: FieldNode) => {\n if (ctx.skip(node)) return\n if (!Object.hasOwn(ctx.components, node.type)) missing.add(node.type)\n node.children.forEach(visit)\n }\n nodes.forEach(visit)\n if (!missing.size) return\n\n // A missing component is a mistake in the code, not in the definition, so it throws early.\n const names = [...missing].map((type) => `\"${type}\"`).join(', ')\n const [noun, pronoun] = missing.size > 1 ? ['types', 'them'] : ['type', 'it']\n throw new TypeError(\n `No component for the field ${noun} ${names}. Add ${pronoun} to the components.`,\n )\n}\n\n/** `indexes` are the indexes of the array items the fields are in, outermost first. */\nexport function renderFields(\n ctx: RenderContext,\n nodes: readonly FieldNode[],\n indexes: readonly number[],\n): VNode[] {\n return nodes\n .filter((node) => !ctx.skip(node))\n .map((node, position) => renderField(ctx, node, indexes, position))\n}\n\nexport function renderField(\n ctx: RenderContext,\n node: FieldNode,\n indexes: readonly number[],\n position: number,\n): VNode {\n const component = ctx.components[node.type] as Component\n const path = toFieldPath(node.dataPath, indexes)\n const key = node.field.name ?? `#${position}`\n switch (node.role) {\n case 'display':\n return h(component, { key, field: node.field })\n case 'group':\n return h(\n component,\n { key, field: node.field, path },\n { default: () => renderFields(ctx, node.children, indexes) },\n )\n case 'array':\n return h(ArrayField, {\n key,\n of: ctx.of,\n node,\n path,\n component,\n renderItem: (index: number) => renderFields(ctx, node.children, [...indexes, index]),\n })\n case 'value':\n return h(ValueField, { key, of: ctx.of, node, path, component })\n }\n}\n","import { findField } from '@whatsaaaa/form-builder-schema'\nimport { defineComponent, type PropType } from 'vue'\nimport type { FieldComponents } from './field-components'\nimport {\n checkComponents,\n type RenderContext,\n renderField,\n resolveComponents,\n} from './render-fields'\nimport type { AnyJsonFormInstance } from './use-json-form'\n\n/**\n * Renders one field of a `useJsonForm` form, wherever you put it inside Formisch's `<Form>`. A\n * group or an array comes with its fields. Leave the field out of `<JsonFields>` with `except`.\n */\nexport const JsonField = defineComponent({\n name: 'JsonField',\n props: {\n /** What `useJsonForm` returned. */\n of: { type: Object as PropType<AnyJsonFormInstance>, required: true },\n /** The field's path: `'email'`, or `'address.city'` for a field of a group. */\n path: { type: String, required: true },\n /** Defaults to the components `useJsonForm` got. */\n components: { type: Object as PropType<FieldComponents> },\n },\n setup(props) {\n const node = findField(props.of.fields, props.path, { placed: true })\n const ctx: RenderContext = {\n of: props.of,\n components: resolveComponents(props.components, props.of),\n skip: () => false,\n }\n checkComponents(ctx, [node])\n\n return () => renderField(ctx, node, [], 0)\n },\n})\n","import { allFields, dotPathOf, type FieldNode, findField } from '@whatsaaaa/form-builder-schema'\nimport { defineComponent, type PropType } from 'vue'\nimport type { FieldComponents } from './field-components'\nimport {\n checkComponents,\n type RenderContext,\n renderFields,\n resolveComponents,\n} from './render-fields'\nimport type { AnyJsonFormInstance } from './use-json-form'\n\n/**\n * Renders the fields of a `useJsonForm` form with your components, one per field type. It renders\n * nothing of its own, so put it inside Formisch's `<Form>` with your own submit button. `only` and\n * `except` are read when it sets up.\n */\nexport const JsonFields = defineComponent({\n name: 'JsonFields',\n props: {\n /** What `useJsonForm` returned. */\n of: { type: Object as PropType<AnyJsonFormInstance>, required: true },\n /** Defaults to the components `useJsonForm` got. */\n components: { type: Object as PropType<FieldComponents> },\n /** Renders only these fields, by path, in the order of the definition. */\n only: { type: Array as PropType<readonly string[]> },\n /** Leaves out these fields, by path, e.g. the ones you place with `<JsonField>`. */\n except: { type: Array as PropType<readonly string[]> },\n },\n setup(props) {\n const fields = props.of.fields\n const except = new Set(props.except)\n // A path that names no field is a typo, so check them even though nothing uses the result.\n for (const path of except) findField(fields, path)\n\n const ctx: RenderContext = {\n of: props.of,\n components: resolveComponents(props.components, props.of),\n skip: (node) => except.has(dotPathOf(node) ?? ''),\n }\n const nodes = props.only ? onlyFields(fields, props.only) : fields\n checkComponents(ctx, nodes)\n\n return () => renderFields(ctx, nodes, [])\n },\n})\n\n/** The fields `only` names, in the order of the definition, each once. */\nfunction onlyFields(fields: readonly FieldNode[], only: readonly string[]): FieldNode[] {\n const named = new Set(only.map((path) => findField(fields, path, { placed: true })))\n return [...allFields(fields)].filter((node) => named.has(node))\n}\n","import { type FormSchema, type FormStore, useForm, type ValidationMode } from '@formisch/vue'\nimport {\n createSchemaBuilder,\n type FieldNode,\n type JsonForm,\n type JsonFormSchema,\n type SchemaBuilder,\n type TypedJsonFormSchema,\n} from '@whatsaaaa/form-builder-schema'\nimport type { FieldComponents } from './field-components'\n\nexport interface UseJsonFormOptions {\n /** Builds the schema and knows your own types and rules. Defaults to `createSchemaBuilder()`. */\n builder?: SchemaBuilder\n /** Your component for each field type, so `<JsonFields>` and `<JsonField>` don't need them. */\n components?: FieldComponents\n /** When a field is validated the first time, as in Formisch. */\n validate?: ValidationMode\n /** When a field is validated again after that, as in Formisch. */\n revalidate?: Exclude<ValidationMode, 'initial'>\n}\n\n/** What `useJsonForm` returns. Pass it to `<JsonFields>`. */\nexport interface JsonFormInstance<TSchema extends FormSchema = JsonFormSchema> {\n /** The Formisch form: pass it to Formisch's `<Form :of>`, or to any of its methods. */\n readonly form: FormStore<TSchema>\n readonly definition: JsonForm\n readonly builder: SchemaBuilder\n /** The components from the options, if any. */\n readonly components: FieldComponents | undefined\n /** The definition's fields as a tree, the way `<JsonFields>` renders them. */\n readonly fields: readonly FieldNode[]\n}\n\n/** Any form `useJsonForm` returns, typed or not: what the components take. */\nexport type AnyJsonFormInstance = JsonFormInstance<FormSchema>\n\n/**\n * A Formisch form for a definition, with its schema and initial input from the builder. A\n * definition with issues throws the builder's `DefinitionError`, so run `validate()` first when it\n * comes from outside your code. The definition is read once: give the form a new `:key` to use\n * another one.\n */\nexport function useJsonForm(definition: JsonForm, options?: UseJsonFormOptions): JsonFormInstance\n/**\n * The same, with the form typed by your input type, and output type when it differs, so Formisch's\n * paths and values are checked. The types are yours to keep in step with the definition.\n */\nexport function useJsonForm<TInput extends object, TOutput extends object = TInput>(\n definition: JsonForm,\n options?: UseJsonFormOptions,\n): JsonFormInstance<TypedJsonFormSchema<TInput, TOutput>>\nexport function useJsonForm(\n definition: JsonForm,\n options: UseJsonFormOptions = {},\n): JsonFormInstance {\n const builder = options.builder ?? createSchemaBuilder()\n const form = useForm({\n schema: builder.build(definition),\n initialInput: builder.getInitialInput(definition),\n validate: options.validate,\n revalidate: options.revalidate,\n })\n const { components } = options\n return { form, definition, builder, components, fields: builder.getFieldTree(definition) }\n}\n"],"mappings":";;;;;AAOA,MAAa,aAAa,gBA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|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Render JSON form definitions with Formisch and your own Vue components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"form",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@whatsaaaa/form-builder-schema": "^0.
|
|
36
|
+
"@whatsaaaa/form-builder-schema": "^0.12.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@arethetypeswrong/cli": "^0.18.5",
|