foldkit-form 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +149 -15
- package/dist/index.d.ts +30 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -10
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +5 -1
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js.map +1 -1
- package/package.json +4 -4
package/dist/input.d.ts
CHANGED
|
@@ -189,13 +189,17 @@ export type BundleControlSpec<Args, Model, Message extends {
|
|
|
189
189
|
* submit made meanwhile waits, as it waits for a check, and goes when the work
|
|
190
190
|
* lands or ends. Default: never. Give `settled` beside it: a stored form shown
|
|
191
191
|
* again has no work in flight, and one left busy would hold every submit back,
|
|
192
|
-
* so `
|
|
192
|
+
* so `busy` without it is a type error, and refused when the control is made.
|
|
193
193
|
*/
|
|
194
194
|
readonly busy?: (model: Model) => boolean;
|
|
195
195
|
} & ([Args] extends [void] ? {
|
|
196
196
|
readonly args?: undefined;
|
|
197
197
|
} : {
|
|
198
198
|
readonly args: Args;
|
|
199
|
+
}) & ({
|
|
200
|
+
readonly busy?: undefined;
|
|
201
|
+
} | {
|
|
202
|
+
readonly settled: (model: Model) => Model;
|
|
199
203
|
});
|
|
200
204
|
/** A relation picker: what it chooses from, and whether it searches. */
|
|
201
205
|
export interface RelationData {
|
package/dist/input.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","names":[],"sources":["../src/input.ts"],"mappings":";;;;;;;;YAmBY,2BAA2B;;;;;;YAO3B;;iBAGK,QAAQ;;WAEd;WACA,OAAO;;WAEP;;;;;WAKA;;WAEA,MAAM;;;;;;EAOf,OAAO,eAAe,MAAM;;;;;;EAM5B,WAAW,OAAO,uBAAuB,MAAM;;;;;EAK/C,QAAQ,gBAAgB,MAAM;;WAErB;;;;;WAKA,UAAU;;;iBAIJ;WACN;WACA,UAAU;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,aAAM,WAAY,4BAAyC;;;;;EAY9D,KAAA,SAAA,YAAO;;;;;;;EAQH,UAAA,QAAA,aAAW,QAAU,OAAO,QAAM"}
|
package/dist/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","names":[],"sources":["../src/input.ts"],"sourcesContent":["/**\n * Controls: what edits one key of a form, described without a renderer.\n *\n * There is one primitive. A control is a `kind` (a name), the draft the Model\n * holds while the user edits, and whatever data its kind needs. `Input.text()`\n * and `Input.toggle()` are values of it, made by `Input.kind`, which is what an\n * application calls for a date picker or a rich text editor. The kinds here are\n * a collection, not a special case. Which DOM, component, or design system\n * draws a kind is the application's.\n */\nimport { Schema, SchemaAST } from 'effect'\nimport type { Bundle } from 'foldkit-bundle'\nimport { SchemaShape, type AnyEntity, type InputMember } from 'foldkit-entity'\nimport { Metadata } from 'foldkit-metadata'\n\n/**\n * What a control holds while it is edited, which is not the value it submits: a\n * number being typed is text, and an unchosen relation is the empty string.\n */\nexport type Draft = string | boolean | ReadonlyArray<string>\n\n/**\n * The draft a control holds. `rows` is a nested key: rows of a form, not a\n * draft. `model` is a control backed by a Bundle (`Input.bundle`): its draft is\n * the Bundle's Model.\n */\nexport type DraftKind = 'text' | 'flag' | 'list' | 'rows' | 'model'\n\n/** What edits one key: the primitive every kind of control is a value of. */\nexport interface Control<Data = unknown> {\n /** The name a renderer is found by. */\n readonly kind: string\n readonly draft: DraftKind\n /** Whether a view draws it. A control carried and submitted, not shown, is `false`. */\n readonly shown: boolean\n /**\n * Whether the form also holds what the user typed to find a choice, which the\n * application reads as the input of the query that lists the choices.\n */\n readonly searches: boolean\n /** What this kind needs: a select's options, a relation's target. */\n readonly data: Data\n /**\n * For a `text` draft: the value the key's schema is given, when that is not the\n * text itself, read with the control's `data` (a select's options). `undefined`\n * means the text does not read as one.\n */\n // A method, so a control of any data is a `Control<unknown>`.\n parse?(draft: string, data: Data): unknown\n /**\n * For a `list` draft: the value the key's schema is given, read with the\n * control's `data` (a choice group's options). `undefined` means one of the\n * chosen values is not one of them.\n */\n parseList?(draft: ReadonlyArray<string>, data: Data): unknown\n /**\n * For a `text` draft: the text a value is shown as when the form is filled\n * with it, the inverse of `parse`. Default `String(value)`.\n */\n format?(value: unknown, data: Data): string\n /** What to say when `parse` gives `undefined`. */\n readonly unparsed?: string | undefined\n /**\n * For a `text` draft: another key of the form this one is written from until\n * the author writes it themselves. A slug follows a title.\n */\n readonly follows?: Follows | undefined\n}\n\n/** Which key a draft follows, and what it makes of that key's text. */\nexport interface Follows {\n readonly key: string\n readonly through: (text: string) => string\n}\n\n/** A kind of control: how its values are made, and how one is told from another. */\nexport interface ControlKind<Data> {\n readonly kind: string\n readonly of: (data: Data) => Control<Data>\n readonly is: (control: Control) => control is Control<Data>\n}\n\n/**\n * Under `inputs`, in place of a control: a change to the control the form would\n * have resolved, such as giving the key's relation picker a search.\n */\nexport interface ControlChange {\n readonly change: (resolved: Control | undefined, key: string) => Control\n}\n\nexport const isControlChange = (value: Control | ControlChange): value is ControlChange =>\n 'change' in value\n\n/** One row of a nested key: a Model of the nested form, under an id that outlives reordering. */\nexport interface FormRow<Model = unknown> {\n readonly id: string\n readonly model: Model\n}\n\n/** What a view needs of a nested form to draw its rows. Every form `Form.make` returns is one. */\nexport interface NestedForm {\n readonly controls: ReadonlyArray<{\n readonly key: string\n readonly control: Control\n readonly label: string\n readonly description: string | undefined\n readonly required: boolean\n }>\n readonly field: (model: never, key: never) => unknown\n readonly rows: (model: never, key: never) => ReadonlyArray<FormRow>\n readonly search: (model: never, key: never) => string\n readonly isFollowing: (model: never, key: never) => boolean\n /** A key edited by a control backed by a Bundle: its state, with the Bundle's Model as the value. */\n readonly control: (key: never) => { readonly field: (model: never) => unknown }\n readonly Message: {\n readonly Changed: (payload: never) => unknown\n readonly Control: (payload: never) => unknown\n readonly Blurred: (payload: never) => unknown\n readonly Searched: (payload: never) => unknown\n readonly Toggled: (payload: never) => unknown\n readonly Nested: (payload: never) => unknown\n readonly RowAdded: (payload: never) => unknown\n readonly RowRemoved: (payload: never) => unknown\n }\n}\n\n/**\n * What every kind's spec says, whatever its draft holds. The draft decides which\n * hooks a spec may carry, so a hook that draft can never reach is a type error\n * rather than a hook that is silently never called.\n */\ninterface ControlSpec<Data, Draft extends DraftKind> {\n readonly draft: Draft\n readonly shown?: boolean\n readonly searches?: boolean | ((data: Data) => boolean)\n readonly unparsed?: string\n}\n\n/** A text draft: read by `parse`, shown by `format`. */\ninterface TextSpec<Data> extends ControlSpec<Data, 'text'> {\n /** The value the text stands for, given the control's data; `undefined` when it stands for none. */\n readonly parse?: (draft: string, data: Data) => unknown\n /** The text a value is shown as when the form is filled with it. */\n readonly format?: (value: unknown, data: Data) => string\n readonly parseList?: never\n}\n\n/** A list draft: each chosen value as text, read by `parseList`. */\ninterface ListSpec<Data> extends ControlSpec<Data, 'list'> {\n /** The value the chosen values stand for, given the control's data; `undefined` when one is not allowed. */\n readonly parseList?: (draft: ReadonlyArray<string>, data: Data) => unknown\n readonly parse?: never\n readonly format?: never\n}\n\n/** A draft with nothing to read or show: a flag, rows, or a Bundle's Model. */\ninterface PlainSpec<Data> extends ControlSpec<Data, 'flag' | 'rows' | 'model'> {\n readonly parse?: never\n readonly parseList?: never\n readonly format?: never\n}\n\n/** What `Input.kind` takes. */\ntype Spec<Data> = TextSpec<Data> | ListSpec<Data> | PlainSpec<Data>\n\n/** A kind of control. The kinds below are made with it, and so is an application's. */\nconst kind = <Data = Record<string, never>>(name: string, spec: Spec<Data>): ControlKind<Data> => {\n return {\n kind: name,\n of: data =>\n Object.freeze({\n kind: name,\n draft: spec.draft,\n shown: spec.shown ?? true,\n searches:\n typeof spec.searches === 'function' ? spec.searches(data) : (spec.searches ?? false),\n data,\n // The hooks the spec's own draft can reach; its type carries no others.\n ...(spec.draft === 'text'\n ? {\n ...(spec.parse === undefined ? {} : { parse: spec.parse }),\n ...(spec.format === undefined ? {} : { format: spec.format }),\n }\n : spec.draft === 'list'\n ? { ...(spec.parseList === undefined ? {} : { parseList: spec.parseList }) }\n : {}),\n unparsed: spec.unparsed,\n }),\n is: (control): control is Control<Data> => control.kind === name,\n }\n}\n\n/**\n * What a control backed by a Bundle carries: the Bundle, its args, and how the\n * key's value is read from its Model and written into it.\n */\nexport interface BundleData<Model = any, Value = any> {\n readonly bundle: Bundle.AnyBundle\n readonly args: unknown\n /** The value the key validates and submits. `undefined` or `null` is nothing entered. */\n readonly value: (model: Model) => Value | null | undefined\n /** The Model showing a value the form was given, from the Model the control holds. */\n readonly fill: (model: Model, value: Value) => Model\n /** The Model with nothing in flight, for a stored form shown again. */\n readonly settled: (model: Model) => Model\n /** Whether work the key's value waits on is in flight: a submit waits for it, as for a check. */\n readonly busy: (model: Model) => boolean\n}\n\n/**\n * A control backed by a Bundle. Its draft is the Bundle's Model, its Messages\n * reach it through the form, and its Commands, Subscriptions and Resources are\n * the form's.\n */\nexport interface BundleControl<Model, Message, Value, Resources = {}> extends Control<\n BundleData<Model, Value>\n> {\n readonly draft: 'model'\n /** Type-only: the Bundle's Message, for `form.control(key).send`. Never set. */\n readonly Message?: Message\n /** Type-only: the Bundle's Resources, which a runtime running the form must provide. Never set. */\n readonly Resources?: Resources\n}\n\n/** What `Input.bundle` takes: the Bundle, then how the key's value lives in its Model. */\nexport type BundleControlSpec<\n Args,\n Model,\n Message extends { readonly _tag: string },\n Value,\n Resources extends Bundle.ResourceEntries<Model, Message> = {},\n> = {\n /**\n * The Bundle. Its Commands may need no services, and it has no OutMessage: a\n * form key has no parent to hand one to, and an OutMessage is never dropped\n * by omission.\n */\n readonly bundle: Bundle.Bundle<any, Args, Model, Message, never, never, any, any, Resources, any>\n /** The value the key validates and submits. `undefined` or `null` is nothing entered. */\n readonly value: (model: Model) => Value | null | undefined\n /** The Model showing a value the form was given (`fill`), from the Model the control holds. */\n readonly fill: (model: Model, value: Value) => Model\n /** The Model with nothing in flight, for a stored form shown again. Default: as it is. */\n readonly settled?: (model: Model) => Model\n /**\n * Whether work the key's value waits on is in flight, such as an upload. A\n * submit made meanwhile waits, as it waits for a check, and goes when the work\n * lands or ends. Default: never. Give `settled` beside it: a stored form shown\n * again has no work in flight, and one left busy would hold every submit back,\n * so `Input.bundle` refuses `busy` without it.\n */\n readonly busy?: (model: Model) => boolean\n} & ([Args] extends [void] ? { readonly args?: undefined } : { readonly args: Args })\n\n/** A relation picker: what it chooses from, and whether it searches. */\nexport interface RelationData {\n readonly target: AnyEntity\n readonly search: boolean\n}\n\n/** A nested key: how many rows it may hold, and the form each row is a Model of. */\nexport interface NestedData {\n readonly cardinality: 'one' | 'many'\n /** Whether the rows may be none: always for a `many`, for a `one` when its schema admits nothing. */\n readonly optional: boolean\n readonly form: NestedForm\n}\n\nconst nothing: Record<string, never> = Object.freeze({})\n\nconst Text = kind('Text', { draft: 'text' })\nconst Hidden = kind('Hidden', { draft: 'text', shown: false })\nconst Multiline = kind('Multiline', { draft: 'text' })\nconst Number_ = kind('Number', {\n draft: 'text',\n // `Number(' ')` is 0, which nobody typed: a number's draft of spaces is nothing.\n parse: draft => {\n const value = globalThis.Number(draft)\n return draft.trim() === '' || !globalThis.Number.isFinite(value) ? undefined : value\n },\n unparsed: 'Enter a number',\n})\nconst Toggle = kind('Toggle', { draft: 'flag' })\n\n/**\n * A kind over a fixed set whose draft is each option's text, refusing a set in\n * which two options share a text (`'1'` and `1`): a draft could not tell them\n * apart, and would store whichever came first.\n */\nconst spelledApart = <Data extends { readonly options: ReadonlyArray<string | number> }>(\n made: ControlKind<Data>,\n): ControlKind<Data> => ({\n ...made,\n of: data => {\n const seen = new Map<string, string | number>()\n for (const option of data.options) {\n const text = String(option)\n const earlier = seen.get(text)\n if (earlier !== undefined && earlier !== option)\n throw new Error(\n `Input.${made.kind}: the options ${JSON.stringify(earlier)} and ${JSON.stringify(option)} are both drawn as \"${text}\", so a choice cannot tell them apart`,\n )\n seen.set(text, option)\n }\n return made.of(data)\n },\n})\n/**\n * One of a fixed set, text or numbers. The draft is the option as text, as a\n * `<select>` holds it; the value is the option itself, so `3` is stored as `3`.\n */\nconst Select = spelledApart(\n kind<{ readonly options: ReadonlyArray<string | number> }>('Select', {\n draft: 'text',\n parse: (draft, data) => data.options.find(option => String(option) === draft),\n unparsed: 'Choose one of the options',\n }),\n)\n/**\n * One or more of a fixed set, text or numbers. The draft is each chosen option\n * as text, as a group of checkboxes holds them; the value is the options\n * themselves, so `3` is stored as `3`.\n */\nconst Choices = spelledApart(\n kind<{ readonly options: ReadonlyArray<string | number> }>('Choices', {\n draft: 'list',\n parseList: (draft, data) => {\n const chosen = draft.map(text => data.options.find(option => String(option) === text))\n return chosen.some(option => option === undefined) ? undefined : chosen\n },\n unparsed: 'Choose from the options',\n }),\n)\nconst RelationOne = kind<RelationData>('RelationOne', {\n draft: 'text',\n searches: data => data.search,\n})\nconst RelationMany = kind<RelationData>('RelationMany', {\n draft: 'list',\n searches: data => data.search,\n})\nconst Nested = kind<NestedData>('Nested', { draft: 'rows' })\n\nconst key = Metadata.key<Control>('foldkit-form/input', {\n // The last control attached wins: a later annotation refines an earlier one.\n merge: controls => controls.slice(-1),\n summarize: control => control.kind,\n})\n\n/** The options a schema is a union of, when every member is a string or number literal. */\nconst optionsOf = (ast: SchemaAST.AST): ReadonlyArray<string | number> | undefined => {\n const literals = SchemaAST.isLiteral(ast) ? [ast] : SchemaAST.isUnion(ast) ? ast.types : []\n const values = literals.map(member => (SchemaAST.isLiteral(member) ? member.literal : undefined))\n const options = values.filter(\n (value): value is string | number => typeof value === 'string' || typeof value === 'number',\n )\n return options.length > 0 && options.length === values.length ? options : undefined\n}\n\n// Optional text is still text, so `null` and `undefined` are set aside first.\nconst fromSchema = (schema: Schema.Top): Control | undefined => {\n const members = SchemaShape.present(schema.ast)\n const [only] = members\n if (members.length === 1 && only !== undefined) {\n if (SchemaAST.isString(only)) return Text.of(nothing)\n if (SchemaAST.isNumber(only)) return Number_.of(nothing)\n if (SchemaAST.isBoolean(only)) return Toggle.of(nothing)\n // A list of literals is as unambiguous as a union of them: any number of them.\n if (SchemaAST.isArrays(only) && only.rest.length === 1) {\n const items = optionsOf(only.rest[0]!)\n if (items !== undefined) return Choices.of({ options: items })\n }\n }\n const literals = members.map(member => (SchemaAST.isLiteral(member) ? member.literal : undefined))\n const options = literals.filter(\n (literal): literal is string | number =>\n typeof literal === 'string' || typeof literal === 'number',\n )\n return options.length > 0 && options.length === literals.length\n ? Select.of({ options })\n : undefined\n}\n\nexport const Input = {\n /**\n * A kind of control. `Input.kind<{ min: string }>('Date', { draft: 'text' })`\n * gives `.of(data)` to make one and `.is(control)` to tell one, exactly as the\n * kinds below were made. A view draws it once it is given a renderer for `Date`.\n */\n kind,\n\n // The kinds this package resolves to. A view finds its renderer by `kind`.\n Text,\n Hidden,\n Multiline,\n Number: Number_,\n Toggle,\n Select,\n Choices,\n RelationOne,\n RelationMany,\n Nested,\n\n /**\n * A control backed by a Bundle, for a draft that is a Model of its own: a\n * color picker with a popover, a page builder, a rich-text editor. The key's\n * draft is the Bundle's Model; `value` reads what the key validates and\n * submits from it, and `fill` writes a given value into it. The Bundle's\n * Messages travel as the form's `Control` Message, and its Commands,\n * Subscriptions and Resources become the form's.\n */\n bundle: <\n Args,\n Model,\n Message extends { readonly _tag: string },\n Value,\n Resources extends Bundle.ResourceEntries<Model, Message> = {},\n >(\n kind: string,\n spec: BundleControlSpec<Args, Model, Message, Value, Resources>,\n ): BundleControl<Model, Message, Value, Resources> => {\n if (spec.busy !== undefined && spec.settled === undefined)\n throw new Error(\n `Input.bundle(\"${kind}\"): give busy a settled too, or a stored form shown again waits for good`,\n )\n return Object.freeze({\n kind,\n draft: 'model' as const,\n shown: true,\n searches: false,\n data: Object.freeze({\n bundle: spec.bundle as Bundle.AnyBundle,\n args: spec.args,\n value: spec.value,\n fill: spec.fill,\n settled: spec.settled ?? ((model: Model) => model),\n busy: spec.busy ?? (() => false),\n }),\n })\n },\n\n /** Whether a control is backed by a Bundle, whatever its kind is called. */\n isBundle: (control: Control): control is Control<BundleData> => control.draft === 'model',\n\n text: (): Control => Text.of(nothing),\n /** Carried and submitted, not shown: the id of the thing being edited. Set it with `fill`. */\n hidden: (): Control => Hidden.of(nothing),\n multiline: (): Control => Multiline.of(nothing),\n number: (): Control => Number_.of(nothing),\n toggle: (): Control => Toggle.of(nothing),\n select: (options: ReadonlyArray<string | number>): Control => Select.of({ options }),\n /**\n * Any number of a fixed set, text or numbers. A key typed\n * `Schema.Array(Schema.Literals([...]))` resolves to one without asking; name\n * it here for a set the schema cannot spell.\n */\n choices: (options: ReadonlyArray<string | number>): Control => Choices.of({ options }),\n /**\n * A picker of one of `target`, for a value that is not a relation of the\n * form's Entity: a page Builder's Block prop that holds an id. A relation key\n * resolves to its picker without asking.\n */\n relationOne: (target: AnyEntity): Control => RelationOne.of({ target, search: false }),\n /** A picker of any number of `target`, as `relationOne` is of one. */\n relationMany: (target: AnyEntity): Control => RelationMany.of({ target, search: false }),\n\n /**\n * For a relation key, under `inputs`: its picker, with a search. Too many to\n * list is the usual case for a relation; the form holds the search text, and\n * the query that lists the options takes it as input.\n */\n search: (): ControlChange => ({\n change: (resolved, inputKey) => {\n if (resolved !== undefined && RelationOne.is(resolved))\n return RelationOne.of({ ...resolved.data, search: true })\n if (resolved !== undefined && RelationMany.is(resolved))\n return RelationMany.of({ ...resolved.data, search: true })\n throw new Error(`\"${inputKey}\" is not a relation, so it has no picker to search`)\n },\n }),\n\n /**\n * Under `inputs`: the key's own control, following another key. Until the\n * author writes this key, its draft is `through` of that key's text, rewritten\n * as that key is edited; once they write it, it is theirs. Emptying it hands\n * it back. A form filled with a value for it does not follow: an address that\n * is already published must not move because its title did.\n */\n following: (key: string, through: (text: string) => string = text => text): ControlChange => ({\n change: (resolved, inputKey) => {\n if (resolved === undefined || resolved.draft !== 'text')\n throw new Error(`\"${inputKey}\" holds no text, so it cannot follow \"${key}\"`)\n return Object.freeze({ ...resolved, follows: { key, through } })\n },\n }),\n\n /**\n * Entity metadata: the control a member is edited with wherever it appears,\n * e.g. `Entity.annotateMembers({ body: Input.of(Input.multiline()) })`.\n */\n of: (control: Control) => key.of(control),\n\n /**\n * The control for one input key, from the most to the least explicit source:\n * the member's `Input.of` metadata, the relation it writes, then the shape of\n * its schema. `undefined` when none of them says, which a form reports rather\n * than guessing.\n */\n resolve: (member: InputMember, schema: Schema.Top): Control | undefined => {\n switch (member._tag) {\n case 'Unmapped':\n return fromSchema(schema)\n // A nested key is not a control to choose: the form builds it from the nested input.\n case 'NestedInput':\n return undefined\n case 'Field':\n return key.get(member.metadata)[0] ?? fromSchema(schema)\n case 'RelationInput': {\n const { relation } = member\n const [explicit] = key.get(relation.metadata)\n if (explicit !== undefined) return explicit\n const data = { target: relation.target(), search: false }\n return relation.cardinality === 'many' ? RelationMany.of(data) : RelationOne.of(data)\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;AA0FA,MAAa,mBAAmB,UAC9B,YAAY;;AA2Ed,MAAM,QAAsC,MAAc,SAAwC;CAChG,OAAO;EACL,MAAM;EACN,KAAI,SACF,OAAO,OAAO;GACZ,MAAM;GACN,OAAO,KAAK;GACZ,OAAO,KAAK,SAAS;GACrB,UACE,OAAO,KAAK,aAAa,aAAa,KAAK,SAAS,IAAI,IAAK,KAAK,YAAY;GAChF;GAEA,GAAI,KAAK,UAAU,SACf;IACE,GAAI,KAAK,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM;IACxD,GAAI,KAAK,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO;GAC7D,IACA,KAAK,UAAU,SACb,EAAE,GAAI,KAAK,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,KAAK,UAAU,EAAG,IACzE,CAAC;GACP,UAAU,KAAK;EACjB,CAAC;EACH,KAAK,YAAsC,QAAQ,SAAS;CAC9D;AACF;AA8EA,MAAM,UAAiC,OAAO,OAAO,CAAC,CAAC;AAEvD,MAAM,OAAO,KAAK,QAAQ,EAAE,OAAO,OAAO,CAAC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,QAAQ,GACnD,OAAO,YAAY,GAAG;GAAE,GAAG,SAAS;GAAM,QAAQ;EAAK,CAAC;EAC1D,IAAI,aAAa,KAAA,KAAa,aAAa,GAAG,QAAQ,GACpD,OAAO,aAAa,GAAG;GAAE,GAAG,SAAS;GAAM,QAAQ;EAAK,CAAC;EAC3D,MAAM,IAAI,MAAM,IAAI,SAAS,mDAAmD;CAClF,EACF;;;;;;;;CASA,YAAY,KAAa,WAAoC,SAAQ,UAAyB,EAC5F,SAAS,UAAU,aAAa;EAC9B,IAAI,aAAa,KAAA,KAAa,SAAS,UAAU,QAC/C,MAAM,IAAI,MAAM,IAAI,SAAS,wCAAwC,IAAI,EAAE;EAC7E,OAAO,OAAO,OAAO;GAAE,GAAG;GAAU,SAAS;IAAE;IAAK;GAAQ;EAAE,CAAC;CACjE,EACF;;;;;CAMA,KAAK,YAAqB,IAAI,GAAG,OAAO;;;;;;;CAQxC,UAAU,QAAqB,WAA4C;EACzE,QAAQ,OAAO,MAAf;GACE,KAAK,YACH,OAAO,WAAW,MAAM;GAE1B,KAAK,eACH;GACF,KAAK,SACH,OAAO,IAAI,IAAI,OAAO,QAAQ,CAAC,CAAC,MAAM,WAAW,MAAM;GACzD,KAAK,iBAAiB;IACpB,MAAM,EAAE,aAAa;IACrB,MAAM,CAAC,YAAY,IAAI,IAAI,SAAS,QAAQ;IAC5C,IAAI,aAAa,KAAA,GAAW,OAAO;IACnC,MAAM,OAAO;KAAE,QAAQ,SAAS,OAAO;KAAG,QAAQ;IAAM;IACxD,OAAO,SAAS,gBAAgB,SAAS,aAAa,GAAG,IAAI,IAAI,YAAY,GAAG,IAAI;GACtF;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"input.js","names":[],"sources":["../src/input.ts"],"sourcesContent":["/**\n * Controls: what edits one key of a form, described without a renderer.\n *\n * There is one primitive. A control is a `kind` (a name), the draft the Model\n * holds while the user edits, and whatever data its kind needs. `Input.text()`\n * and `Input.toggle()` are values of it, made by `Input.kind`, which is what an\n * application calls for a date picker or a rich text editor. The kinds here are\n * a collection, not a special case. Which DOM, component, or design system\n * draws a kind is the application's.\n */\nimport { Schema, SchemaAST } from 'effect'\nimport type { Bundle } from 'foldkit-bundle'\nimport { SchemaShape, type AnyEntity, type InputMember } from 'foldkit-entity'\nimport { Metadata } from 'foldkit-metadata'\n\n/**\n * What a control holds while it is edited, which is not the value it submits: a\n * number being typed is text, and an unchosen relation is the empty string.\n */\nexport type Draft = string | boolean | ReadonlyArray<string>\n\n/**\n * The draft a control holds. `rows` is a nested key: rows of a form, not a\n * draft. `model` is a control backed by a Bundle (`Input.bundle`): its draft is\n * the Bundle's Model.\n */\nexport type DraftKind = 'text' | 'flag' | 'list' | 'rows' | 'model'\n\n/** What edits one key: the primitive every kind of control is a value of. */\nexport interface Control<Data = unknown> {\n /** The name a renderer is found by. */\n readonly kind: string\n readonly draft: DraftKind\n /** Whether a view draws it. A control carried and submitted, not shown, is `false`. */\n readonly shown: boolean\n /**\n * Whether the form also holds what the user typed to find a choice, which the\n * application reads as the input of the query that lists the choices.\n */\n readonly searches: boolean\n /** What this kind needs: a select's options, a relation's target. */\n readonly data: Data\n /**\n * For a `text` draft: the value the key's schema is given, when that is not the\n * text itself, read with the control's `data` (a select's options). `undefined`\n * means the text does not read as one.\n */\n // A method, so a control of any data is a `Control<unknown>`.\n parse?(draft: string, data: Data): unknown\n /**\n * For a `list` draft: the value the key's schema is given, read with the\n * control's `data` (a choice group's options). `undefined` means one of the\n * chosen values is not one of them.\n */\n parseList?(draft: ReadonlyArray<string>, data: Data): unknown\n /**\n * For a `text` draft: the text a value is shown as when the form is filled\n * with it, the inverse of `parse`. Default `String(value)`.\n */\n format?(value: unknown, data: Data): string\n /** What to say when `parse` gives `undefined`. */\n readonly unparsed?: string | undefined\n /**\n * For a `text` draft: another key of the form this one is written from until\n * the author writes it themselves. A slug follows a title.\n */\n readonly follows?: Follows | undefined\n}\n\n/** Which key a draft follows, and what it makes of that key's text. */\nexport interface Follows {\n readonly key: string\n readonly through: (text: string) => string\n}\n\n/** A kind of control: how its values are made, and how one is told from another. */\nexport interface ControlKind<Data> {\n readonly kind: string\n readonly of: (data: Data) => Control<Data>\n readonly is: (control: Control) => control is Control<Data>\n}\n\n/**\n * Under `inputs`, in place of a control: a change to the control the form would\n * have resolved, such as giving the key's relation picker a search.\n */\nexport interface ControlChange {\n readonly change: (resolved: Control | undefined, key: string) => Control\n}\n\nexport const isControlChange = (value: Control | ControlChange): value is ControlChange =>\n 'change' in value\n\n/** One row of a nested key: a Model of the nested form, under an id that outlives reordering. */\nexport interface FormRow<Model = unknown> {\n readonly id: string\n readonly model: Model\n}\n\n/** What a view needs of a nested form to draw its rows. Every form `Form.make` returns is one. */\nexport interface NestedForm {\n readonly controls: ReadonlyArray<{\n readonly key: string\n readonly control: Control\n readonly label: string\n readonly description: string | undefined\n readonly required: boolean\n }>\n readonly field: (model: never, key: never) => unknown\n readonly rows: (model: never, key: never) => ReadonlyArray<FormRow>\n readonly search: (model: never, key: never) => string\n readonly isFollowing: (model: never, key: never) => boolean\n /** A key edited by a control backed by a Bundle: its state, with the Bundle's Model as the value. */\n readonly control: (key: never) => { readonly field: (model: never) => unknown }\n readonly Message: {\n readonly Changed: (payload: never) => unknown\n readonly Control: (payload: never) => unknown\n readonly Blurred: (payload: never) => unknown\n readonly Searched: (payload: never) => unknown\n readonly Toggled: (payload: never) => unknown\n readonly Nested: (payload: never) => unknown\n readonly RowAdded: (payload: never) => unknown\n readonly RowRemoved: (payload: never) => unknown\n }\n}\n\n/**\n * What every kind's spec says, whatever its draft holds. The draft decides which\n * hooks a spec may carry, so a hook that draft can never reach is a type error\n * rather than a hook that is silently never called.\n */\ninterface ControlSpec<Data, Draft extends DraftKind> {\n readonly draft: Draft\n readonly shown?: boolean\n readonly searches?: boolean | ((data: Data) => boolean)\n readonly unparsed?: string\n}\n\n/** A text draft: read by `parse`, shown by `format`. */\ninterface TextSpec<Data> extends ControlSpec<Data, 'text'> {\n /** The value the text stands for, given the control's data; `undefined` when it stands for none. */\n readonly parse?: (draft: string, data: Data) => unknown\n /** The text a value is shown as when the form is filled with it. */\n readonly format?: (value: unknown, data: Data) => string\n readonly parseList?: never\n}\n\n/** A list draft: each chosen value as text, read by `parseList`. */\ninterface ListSpec<Data> extends ControlSpec<Data, 'list'> {\n /** The value the chosen values stand for, given the control's data; `undefined` when one is not allowed. */\n readonly parseList?: (draft: ReadonlyArray<string>, data: Data) => unknown\n readonly parse?: never\n readonly format?: never\n}\n\n/** A draft with nothing to read or show: a flag, rows, or a Bundle's Model. */\ninterface PlainSpec<Data> extends ControlSpec<Data, 'flag' | 'rows' | 'model'> {\n readonly parse?: never\n readonly parseList?: never\n readonly format?: never\n}\n\n/** What `Input.kind` takes. */\ntype Spec<Data> = TextSpec<Data> | ListSpec<Data> | PlainSpec<Data>\n\n/** A kind of control. The kinds below are made with it, and so is an application's. */\nconst kind = <Data = Record<string, never>>(name: string, spec: Spec<Data>): ControlKind<Data> => {\n return {\n kind: name,\n of: data =>\n Object.freeze({\n kind: name,\n draft: spec.draft,\n shown: spec.shown ?? true,\n searches:\n typeof spec.searches === 'function' ? spec.searches(data) : (spec.searches ?? false),\n data,\n // The hooks the spec's own draft can reach; its type carries no others.\n ...(spec.draft === 'text'\n ? {\n ...(spec.parse === undefined ? {} : { parse: spec.parse }),\n ...(spec.format === undefined ? {} : { format: spec.format }),\n }\n : spec.draft === 'list'\n ? { ...(spec.parseList === undefined ? {} : { parseList: spec.parseList }) }\n : {}),\n unparsed: spec.unparsed,\n }),\n is: (control): control is Control<Data> => control.kind === name,\n }\n}\n\n/**\n * What a control backed by a Bundle carries: the Bundle, its args, and how the\n * key's value is read from its Model and written into it.\n */\nexport interface BundleData<Model = any, Value = any> {\n readonly bundle: Bundle.AnyBundle\n readonly args: unknown\n /** The value the key validates and submits. `undefined` or `null` is nothing entered. */\n readonly value: (model: Model) => Value | null | undefined\n /** The Model showing a value the form was given, from the Model the control holds. */\n readonly fill: (model: Model, value: Value) => Model\n /** The Model with nothing in flight, for a stored form shown again. */\n readonly settled: (model: Model) => Model\n /** Whether work the key's value waits on is in flight: a submit waits for it, as for a check. */\n readonly busy: (model: Model) => boolean\n}\n\n/**\n * A control backed by a Bundle. Its draft is the Bundle's Model, its Messages\n * reach it through the form, and its Commands, Subscriptions and Resources are\n * the form's.\n */\nexport interface BundleControl<Model, Message, Value, Resources = {}> extends Control<\n BundleData<Model, Value>\n> {\n readonly draft: 'model'\n /** Type-only: the Bundle's Message, for `form.control(key).send`. Never set. */\n readonly Message?: Message\n /** Type-only: the Bundle's Resources, which a runtime running the form must provide. Never set. */\n readonly Resources?: Resources\n}\n\n/** What `Input.bundle` takes: the Bundle, then how the key's value lives in its Model. */\nexport type BundleControlSpec<\n Args,\n Model,\n Message extends { readonly _tag: string },\n Value,\n Resources extends Bundle.ResourceEntries<Model, Message> = {},\n> = {\n /**\n * The Bundle. Its Commands may need no services, and it has no OutMessage: a\n * form key has no parent to hand one to, and an OutMessage is never dropped\n * by omission.\n */\n readonly bundle: Bundle.Bundle<any, Args, Model, Message, never, never, any, any, Resources, any>\n /** The value the key validates and submits. `undefined` or `null` is nothing entered. */\n readonly value: (model: Model) => Value | null | undefined\n /** The Model showing a value the form was given (`fill`), from the Model the control holds. */\n readonly fill: (model: Model, value: Value) => Model\n /** The Model with nothing in flight, for a stored form shown again. Default: as it is. */\n readonly settled?: (model: Model) => Model\n /**\n * Whether work the key's value waits on is in flight, such as an upload. A\n * submit made meanwhile waits, as it waits for a check, and goes when the work\n * lands or ends. Default: never. Give `settled` beside it: a stored form shown\n * again has no work in flight, and one left busy would hold every submit back,\n * so `busy` without it is a type error, and refused when the control is made.\n */\n readonly busy?: (model: Model) => boolean\n} & ([Args] extends [void] ? { readonly args?: undefined } : { readonly args: Args }) &\n // Naming no other type, this leaves the value's inference to `value` and `fill`\n // for every spec it admits; a spec it refuses is reported at the call.\n ({ readonly busy?: undefined } | { readonly settled: (model: Model) => Model })\n\n/** A relation picker: what it chooses from, and whether it searches. */\nexport interface RelationData {\n readonly target: AnyEntity\n readonly search: boolean\n}\n\n/** A nested key: how many rows it may hold, and the form each row is a Model of. */\nexport interface NestedData {\n readonly cardinality: 'one' | 'many'\n /** Whether the rows may be none: always for a `many`, for a `one` when its schema admits nothing. */\n readonly optional: boolean\n readonly form: NestedForm\n}\n\nconst nothing: Record<string, never> = Object.freeze({})\n\nconst Text = kind('Text', { draft: 'text' })\nconst Hidden = kind('Hidden', { draft: 'text', shown: false })\nconst Multiline = kind('Multiline', { draft: 'text' })\nconst Number_ = kind('Number', {\n draft: 'text',\n // `Number(' ')` is 0, which nobody typed: a number's draft of spaces is nothing.\n parse: draft => {\n const value = globalThis.Number(draft)\n return draft.trim() === '' || !globalThis.Number.isFinite(value) ? undefined : value\n },\n unparsed: 'Enter a number',\n})\nconst Toggle = kind('Toggle', { draft: 'flag' })\n\n/**\n * A kind over a fixed set whose draft is each option's text, refusing a set in\n * which two options share a text (`'1'` and `1`): a draft could not tell them\n * apart, and would store whichever came first.\n */\nconst spelledApart = <Data extends { readonly options: ReadonlyArray<string | number> }>(\n made: ControlKind<Data>,\n): ControlKind<Data> => ({\n ...made,\n of: data => {\n const seen = new Map<string, string | number>()\n for (const option of data.options) {\n const text = String(option)\n const earlier = seen.get(text)\n if (earlier !== undefined && earlier !== option)\n throw new Error(\n `Input.${made.kind}: the options ${JSON.stringify(earlier)} and ${JSON.stringify(option)} are both drawn as \"${text}\", so a choice cannot tell them apart`,\n )\n seen.set(text, option)\n }\n return made.of(data)\n },\n})\n/**\n * One of a fixed set, text or numbers. The draft is the option as text, as a\n * `<select>` holds it; the value is the option itself, so `3` is stored as `3`.\n */\nconst Select = spelledApart(\n kind<{ readonly options: ReadonlyArray<string | number> }>('Select', {\n draft: 'text',\n parse: (draft, data) => data.options.find(option => String(option) === draft),\n unparsed: 'Choose one of the options',\n }),\n)\n/**\n * One or more of a fixed set, text or numbers. The draft is each chosen option\n * as text, as a group of checkboxes holds them; the value is the options\n * themselves, so `3` is stored as `3`.\n */\nconst Choices = spelledApart(\n kind<{ readonly options: ReadonlyArray<string | number> }>('Choices', {\n draft: 'list',\n parseList: (draft, data) => {\n const chosen = draft.map(text => data.options.find(option => String(option) === text))\n return chosen.some(option => option === undefined) ? undefined : chosen\n },\n unparsed: 'Choose from the options',\n }),\n)\nconst RelationOne = kind<RelationData>('RelationOne', {\n draft: 'text',\n searches: data => data.search,\n})\nconst RelationMany = kind<RelationData>('RelationMany', {\n draft: 'list',\n searches: data => data.search,\n})\nconst Nested = kind<NestedData>('Nested', { draft: 'rows' })\n\nconst key = Metadata.key<Control>('foldkit-form/input', {\n // The last control attached wins: a later annotation refines an earlier one.\n merge: controls => controls.slice(-1),\n summarize: control => control.kind,\n})\n\n/** The options a schema is a union of, when every member is a string or number literal. */\nconst optionsOf = (ast: SchemaAST.AST): ReadonlyArray<string | number> | undefined => {\n const literals = SchemaAST.isLiteral(ast) ? [ast] : SchemaAST.isUnion(ast) ? ast.types : []\n const values = literals.map(member => (SchemaAST.isLiteral(member) ? member.literal : undefined))\n const options = values.filter(\n (value): value is string | number => typeof value === 'string' || typeof value === 'number',\n )\n return options.length > 0 && options.length === values.length ? options : undefined\n}\n\n// Optional text is still text, so `null` and `undefined` are set aside first.\nconst fromSchema = (schema: Schema.Top): Control | undefined => {\n const members = SchemaShape.present(schema.ast)\n const [only] = members\n if (members.length === 1 && only !== undefined) {\n if (SchemaAST.isString(only)) return Text.of(nothing)\n if (SchemaAST.isNumber(only)) return Number_.of(nothing)\n if (SchemaAST.isBoolean(only)) return Toggle.of(nothing)\n // A list of literals is as unambiguous as a union of them: any number of them.\n if (SchemaAST.isArrays(only) && only.rest.length === 1) {\n const items = optionsOf(only.rest[0]!)\n if (items !== undefined) return Choices.of({ options: items })\n }\n }\n const literals = members.map(member => (SchemaAST.isLiteral(member) ? member.literal : undefined))\n const options = literals.filter(\n (literal): literal is string | number =>\n typeof literal === 'string' || typeof literal === 'number',\n )\n return options.length > 0 && options.length === literals.length\n ? Select.of({ options })\n : undefined\n}\n\nexport const Input = {\n /**\n * A kind of control. `Input.kind<{ min: string }>('Date', { draft: 'text' })`\n * gives `.of(data)` to make one and `.is(control)` to tell one, exactly as the\n * kinds below were made. A view draws it once it is given a renderer for `Date`.\n */\n kind,\n\n // The kinds this package resolves to. A view finds its renderer by `kind`.\n Text,\n Hidden,\n Multiline,\n Number: Number_,\n Toggle,\n Select,\n Choices,\n RelationOne,\n RelationMany,\n Nested,\n\n /**\n * A control backed by a Bundle, for a draft that is a Model of its own: a\n * color picker with a popover, a page builder, a rich-text editor. The key's\n * draft is the Bundle's Model; `value` reads what the key validates and\n * submits from it, and `fill` writes a given value into it. The Bundle's\n * Messages travel as the form's `Control` Message, and its Commands,\n * Subscriptions and Resources become the form's.\n */\n bundle: <\n Args,\n Model,\n Message extends { readonly _tag: string },\n Value,\n Resources extends Bundle.ResourceEntries<Model, Message> = {},\n >(\n kind: string,\n spec: BundleControlSpec<Args, Model, Message, Value, Resources>,\n ): BundleControl<Model, Message, Value, Resources> => {\n if (spec.busy !== undefined && spec.settled === undefined)\n throw new Error(\n `Input.bundle(\"${kind}\"): give busy a settled too, or a stored form shown again waits for good`,\n )\n return Object.freeze({\n kind,\n draft: 'model' as const,\n shown: true,\n searches: false,\n data: Object.freeze({\n bundle: spec.bundle as Bundle.AnyBundle,\n args: spec.args,\n value: spec.value,\n fill: spec.fill,\n settled: spec.settled ?? ((model: Model) => model),\n busy: spec.busy ?? (() => false),\n }),\n })\n },\n\n /** Whether a control is backed by a Bundle, whatever its kind is called. */\n isBundle: (control: Control): control is Control<BundleData> => control.draft === 'model',\n\n text: (): Control => Text.of(nothing),\n /** Carried and submitted, not shown: the id of the thing being edited. Set it with `fill`. */\n hidden: (): Control => Hidden.of(nothing),\n multiline: (): Control => Multiline.of(nothing),\n number: (): Control => Number_.of(nothing),\n toggle: (): Control => Toggle.of(nothing),\n select: (options: ReadonlyArray<string | number>): Control => Select.of({ options }),\n /**\n * Any number of a fixed set, text or numbers. A key typed\n * `Schema.Array(Schema.Literals([...]))` resolves to one without asking; name\n * it here for a set the schema cannot spell.\n */\n choices: (options: ReadonlyArray<string | number>): Control => Choices.of({ options }),\n /**\n * A picker of one of `target`, for a value that is not a relation of the\n * form's Entity: a page Builder's Block prop that holds an id. A relation key\n * resolves to its picker without asking.\n */\n relationOne: (target: AnyEntity): Control => RelationOne.of({ target, search: false }),\n /** A picker of any number of `target`, as `relationOne` is of one. */\n relationMany: (target: AnyEntity): Control => RelationMany.of({ target, search: false }),\n\n /**\n * For a relation key, under `inputs`: its picker, with a search. Too many to\n * list is the usual case for a relation; the form holds the search text, and\n * the query that lists the options takes it as input.\n */\n search: (): ControlChange => ({\n change: (resolved, inputKey) => {\n if (resolved !== undefined && RelationOne.is(resolved))\n return RelationOne.of({ ...resolved.data, search: true })\n if (resolved !== undefined && RelationMany.is(resolved))\n return RelationMany.of({ ...resolved.data, search: true })\n throw new Error(`\"${inputKey}\" is not a relation, so it has no picker to search`)\n },\n }),\n\n /**\n * Under `inputs`: the key's own control, following another key. Until the\n * author writes this key, its draft is `through` of that key's text, rewritten\n * as that key is edited; once they write it, it is theirs. Emptying it hands\n * it back. A form filled with a value for it does not follow: an address that\n * is already published must not move because its title did.\n */\n following: (key: string, through: (text: string) => string = text => text): ControlChange => ({\n change: (resolved, inputKey) => {\n if (resolved === undefined || resolved.draft !== 'text')\n throw new Error(`\"${inputKey}\" holds no text, so it cannot follow \"${key}\"`)\n return Object.freeze({ ...resolved, follows: { key, through } })\n },\n }),\n\n /**\n * Entity metadata: the control a member is edited with wherever it appears,\n * e.g. `Entity.annotateMembers({ body: Input.of(Input.multiline()) })`.\n */\n of: (control: Control) => key.of(control),\n\n /**\n * The control for one input key, from the most to the least explicit source:\n * the member's `Input.of` metadata, the relation it writes, then the shape of\n * its schema. `undefined` when none of them says, which a form reports rather\n * than guessing.\n */\n resolve: (member: InputMember, schema: Schema.Top): Control | undefined => {\n switch (member._tag) {\n case 'Unmapped':\n return fromSchema(schema)\n // A nested key is not a control to choose: the form builds it from the nested input.\n case 'NestedInput':\n return undefined\n case 'Field':\n return key.get(member.metadata)[0] ?? fromSchema(schema)\n case 'RelationInput': {\n const { relation } = member\n const [explicit] = key.get(relation.metadata)\n if (explicit !== undefined) return explicit\n const data = { target: relation.target(), search: false }\n return relation.cardinality === 'many' ? RelationMany.of(data) : RelationOne.of(data)\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;AA0FA,MAAa,mBAAmB,UAC9B,YAAY;;AA2Ed,MAAM,QAAsC,MAAc,SAAwC;CAChG,OAAO;EACL,MAAM;EACN,KAAI,SACF,OAAO,OAAO;GACZ,MAAM;GACN,OAAO,KAAK;GACZ,OAAO,KAAK,SAAS;GACrB,UACE,OAAO,KAAK,aAAa,aAAa,KAAK,SAAS,IAAI,IAAK,KAAK,YAAY;GAChF;GAEA,GAAI,KAAK,UAAU,SACf;IACE,GAAI,KAAK,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM;IACxD,GAAI,KAAK,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO;GAC7D,IACA,KAAK,UAAU,SACb,EAAE,GAAI,KAAK,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,KAAK,UAAU,EAAG,IACzE,CAAC;GACP,UAAU,KAAK;EACjB,CAAC;EACH,KAAK,YAAsC,QAAQ,SAAS;CAC9D;AACF;AAiFA,MAAM,UAAiC,OAAO,OAAO,CAAC,CAAC;AAEvD,MAAM,OAAO,KAAK,QAAQ,EAAE,OAAO,OAAO,CAAC;AAC3C,MAAM,SAAS,KAAK,UAAU;CAAE,OAAO;CAAQ,OAAO;AAAM,CAAC;AAC7D,MAAM,YAAY,KAAK,aAAa,EAAE,OAAO,OAAO,CAAC;AACrD,MAAM,UAAU,KAAK,UAAU;CAC7B,OAAO;CAEP,QAAO,UAAS;EACd,MAAM,QAAQ,WAAW,OAAO,KAAK;EACrC,OA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mDAAmD;CAClF,EACF;;;;;;;;CASA,YAAY,KAAa,WAAoC,SAAQ,UAAyB,EAC5F,SAAS,UAAU,aAAa;EAC9B,IAAI,aAAa,KAAA,KAAa,SAAS,UAAU,QAC/C,MAAM,IAAI,MAAM,IAAI,SAAS,wCAAwC,IAAI,EAAE;EAC7E,OAAO,OAAO,OAAO;GAAE,GAAG;GAAU,SAAS;IAAE;IAAK;GAAQ;EAAE,CAAC;CACjE,EACF;;;;;CAMA,KAAK,YAAqB,IAAI,GAAG,OAAO;;;;;;;CAQxC,UAAU,QAAqB,WAA4C;EACzE,QAAQ,OAAO,MAAf;GACE,KAAK,YACH,OAAO,WAAW,MAAM;GAE1B,KAAK,eACH;GACF,KAAK,SACH,OAAO,IAAI,IAAI,OAAO,QAAQ,CAAC,CAAC,MAAM,WAAW,MAAM;GACzD,KAAK,iBAAiB;IACpB,MAAM,EAAE,aAAa;IACrB,MAAM,CAAC,YAAY,IAAI,IAAI,SAAS,QAAQ;IAC5C,IAAI,aAAa,KAAA,GAAW,OAAO;IACnC,MAAM,OAAO;KAAE,QAAQ,SAAS,OAAO;KAAG,QAAQ;IAAM;IACxD,OAAO,SAAS,gBAAgB,SAAS,aAAa,GAAG,IAAI,IAAI,YAAY,GAAG,IAAI;GACtF;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit-form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Forms for Foldkit: a Bundle over core field validation, built from an operation's input and the Entity it writes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foldkit",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"LICENSE"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"foldkit-
|
|
43
|
-
"foldkit-
|
|
44
|
-
"foldkit-
|
|
42
|
+
"foldkit-bundle": "0.12.0",
|
|
43
|
+
"foldkit-metadata": "0.1.0",
|
|
44
|
+
"foldkit-entity": "0.17.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"effect": "^4.1.0",
|