@shikiform/react 0.1.0 → 0.2.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/dist/{chunk-EYDJ6I7P.js → chunk-DQHRLKQS.js} +49 -30
- package/dist/chunk-DQHRLKQS.js.map +1 -0
- package/dist/index.d.ts +23 -14
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +25 -4
- package/dist/internal.js +1 -1
- package/dist/{use-watch-BZlpyvHw.d.ts → use-watch-9vSz8P44.d.ts} +50 -77
- package/package.json +2 -2
- package/dist/chunk-EYDJ6I7P.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentProps, MouseEvent, ReactNode, ComponentType } from 'react';
|
|
3
|
-
import { R as ResetState, F as FormSubmitHandlers, S as SubmitState, C as CheckedFieldProps, a as FieldProps, A as ArrayContainerSlot, b as ArrayKey, U as UseFieldOptions, c as FieldBinding, d as ArrayHandle, e as UseFormOptions } from './use-watch-
|
|
4
|
-
export { f as ArrayErrors, g as ArrayField, h as
|
|
5
|
-
import { FieldPath, PathValue, ArrayPath, ArrayItemOf, Draft, DefaultSubmit, FieldsInput, FormOptions, FormInstance, ResolveSubmit, Pattern } from '@shikiform/core/internal';
|
|
3
|
+
import { R as ResetState, F as FormSubmitHandlers, S as SubmitState, C as CheckedFieldProps, a as FieldProps, A as ArrayContainerSlot, b as ArrayKey, T as TreeNodeRender, U as UseFieldOptions, c as FieldBinding, d as ArrayHandle, e as UseFormOptions, D as DragProps } from './use-watch-9vSz8P44.js';
|
|
4
|
+
export { f as ArrayErrors, g as ArrayField, h as ArrayScopeValue, B as BlurFlag, i as BlurOn, j as ClickEvent, k as ComponentStatics, l as ConnectEnhancer, m as ConnectFieldProps, n as ConnectedComponent, o as Field, p as FieldComponents, q as FieldDecorators, r as FieldGroup, s as FieldGroupHandle, t as FieldKit, u as FieldKitDecorator, v as FieldKitSpec, w as FieldPropKey, x as FieldSlot, y as FieldStateKey, z as Form, E as FormDomProps, G as FormProps, O as ObjectField, P as PropsMapping, H as PropsTransform, I as RegisteredComponentSlot, J as RegisteredDecoratorSlot, K as RegisteredSlot, L as ScopeValue, M as TreeField, N as UI, Q as UIProps, V as UiBinding, W as UseResetOptions, X as UseSubmitOptions, Y as Watch, Z as connect, _ as mapProps, $ as useArray, a0 as useArrayErrors, a1 as useArrayField, a2 as useField, a3 as useFieldGroup, a4 as useFieldGroupErrors, a5 as useForm, a6 as useFormContext, a7 as useFormMessage, a8 as useIndex, a9 as useRecord, aa as useReset, ab as useSubmit, ac as useTreeNode, ad as useWatch } from './use-watch-9vSz8P44.js';
|
|
5
|
+
import { FieldPath, PathValue, ArrayPath, ArrayItemOf, Draft, DefaultSubmit, FieldsInput, FormOptions, FormInstance, ResolveSubmit, Pattern, Pos, MoveResult } from '@shikiform/core/internal';
|
|
6
6
|
export { ArrayItemOf, Display, Draft, EffectDef, EnumBinding, EnumOption, EnumSource, FieldEnum, FieldError, FieldPath, FieldSpec, FieldUiSpec, FormInstance, FormMessageKey, FormMessages, FormOptions, MessageArgs, MessageBase, MessageParams, MessageTemplate, MoveResult, NoParams, NormalizePath, PathValue, Pattern, Pos, RowContext, RowDraft, Rule, RulesInput, ShikiConflictError, ShikiCycleError, ShikiUsageError, SubmitResult, SubmitValues, TemplatePath, TreeMoveParams, UiDisplay, UiDraft, UiName, UiNames, ValidateCtx, ValidateTrigger, ValuePath, createForm, defineEffects, enUS, get, getDefaultMessages, set, setDefaultMessages, zhCN } from '@shikiform/core';
|
|
7
7
|
|
|
8
8
|
type ButtonPass = Omit<ComponentProps<'button'>, 'onClick' | 'type' | 'disabled' | 'children'>;
|
|
@@ -80,6 +80,12 @@ type ScopeFields<T> = {
|
|
|
80
80
|
};
|
|
81
81
|
children?: (row: ArrayKey & ScopeFields<ArrayItemOf<T, N & string>>) => ReactNode;
|
|
82
82
|
}) => ReactNode;
|
|
83
|
+
TreeField: <N extends ArrayPath<T>>(props: {
|
|
84
|
+
name: N;
|
|
85
|
+
childrenKey?: string;
|
|
86
|
+
rowKey?: string;
|
|
87
|
+
children: (node: TreeNodeRender & ScopeFields<ArrayItemOf<T, N & string>>) => ReactNode;
|
|
88
|
+
}) => ReactNode;
|
|
83
89
|
};
|
|
84
90
|
/**
|
|
85
91
|
* {@link typed}'s return: {@link ScopeFields} for the form root plus typed hooks.
|
|
@@ -228,16 +234,19 @@ interface FieldDecoratorOptions {
|
|
|
228
234
|
declare function useFieldDecorator(options?: FieldDecoratorOptions): FieldDecorator;
|
|
229
235
|
|
|
230
236
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
237
|
+
* Tree handle. `move(from, to)` uses final `pos` coordinates and refuses a move into a descendant (the result says why).
|
|
238
|
+
* `dragProps(pos)` is the HTML5 drag-and-drop props for the node at that coordinate (source and drop target);
|
|
239
|
+
* dropping node A on node B is `move(A, B)`, so cross-parent moves keep the node id and its field state.
|
|
240
|
+
* Subscribes to structure only.
|
|
234
241
|
*/
|
|
235
|
-
declare function
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
declare function useTreeField(name: string, opts?: {
|
|
243
|
+
childrenKey?: string;
|
|
244
|
+
rowKey?: string;
|
|
245
|
+
}): {
|
|
246
|
+
path: string;
|
|
247
|
+
value: any[];
|
|
248
|
+
move: (from: Pos, to: Pos) => MoveResult;
|
|
249
|
+
dragProps: (at: Pos) => DragProps;
|
|
250
|
+
};
|
|
242
251
|
|
|
243
|
-
export { ArrayContainerSlot, ArrayHandle, ArrayKey, FieldBinding, type FieldDecorator, type FieldDecoratorOptions, FieldProps, FormSubmitHandlers, Reset, type ResetProps, ResetState, type ScopeFields, Submit, type SubmitProps, SubmitState, type TypedForm, UseFieldOptions, UseFormOptions,
|
|
252
|
+
export { ArrayContainerSlot, ArrayHandle, ArrayKey, FieldBinding, type FieldDecorator, type FieldDecoratorOptions, FieldProps, FormSubmitHandlers, Reset, type ResetProps, ResetState, type ScopeFields, Submit, type SubmitProps, SubmitState, TreeNodeRender, type TypedForm, UseFieldOptions, UseFormOptions, typed, useFieldDecorator, useTreeField };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useSubmit, useFormMessage, useReset, useForm, Watch, useWatch, useArrayField, useField, Field, ArrayField, ObjectField, useFieldContextOrNull } from './chunk-
|
|
2
|
-
export { ArrayField,
|
|
1
|
+
import { useSubmit, useFormMessage, useReset, useForm, Watch, useWatch, useArrayField, useField, Field, ArrayField, ObjectField, TreeField, useFieldContextOrNull } from './chunk-DQHRLKQS.js';
|
|
2
|
+
export { ArrayField, Field, FieldGroup, FieldKit, Form, ObjectField, TreeField, UI, Watch, connect, mapProps, useArray, useArrayErrors, useArrayField, useField, useFieldGroup, useFieldGroupErrors, useForm, useFormContext, useFormMessage, useIndex, useRecord, useReset, useSubmit, useTreeField, useTreeNode, useWatch } from './chunk-DQHRLKQS.js';
|
|
3
3
|
import { isValidElement, cloneElement } from 'react';
|
|
4
4
|
import { createForm, ShikiUsageError } from '@shikiform/core/internal';
|
|
5
5
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -88,7 +88,10 @@ function TypedArrayField({ children, ...props }) {
|
|
|
88
88
|
function TypedObjectField({ children, ...props }) {
|
|
89
89
|
return /* @__PURE__ */ jsx(ObjectField, { ...props, children: typeof children === "function" ? children(scope) : children });
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
function TypedTreeField({ children, ...props }) {
|
|
92
|
+
return /* @__PURE__ */ jsx(TreeField, { ...props, children: (node) => children({ ...node, ...scope }) });
|
|
93
|
+
}
|
|
94
|
+
var scope = { Field, ObjectField: TypedObjectField, ArrayField: TypedArrayField, TreeField: TypedTreeField };
|
|
92
95
|
var handles = { ...scope, useField, useArrayField, useWatch, Watch, createForm, useForm };
|
|
93
96
|
var NO_FIELD = '[shikiform] useFieldDecorator() reads the surrounding <Field>, but this component is not inside one. Render it as a <Field decorator> (or inside <Field name="\u2026">), or pass the binding: useFieldDecorator({ field }).';
|
|
94
97
|
function present(value) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/buttons.tsx","../src/factory/typed.tsx","../src/hooks/use-field-decorator.ts"],"names":["jsx","ShikiUsageError"],"mappings":";;;;;;;AAgBA,SAAS,UAAU,KAAA,EAA8D;AAC/E,EAAA,OAAO;AAAA,IACL,MAAM,KAAA,CAAM,IAAA;AAAA,IACZ,UAAU,KAAA,CAAM,QAAA;AAAA,IAChB,WAAA,EAAa,MAAM,WAAW,CAAA;AAAA,IAC9B,cAAA,EAAgB,MAAM,cAAc,CAAA;AAAA,IACpC,SAAS,KAAA,CAAM;AAAA,GACjB;AACF;AAMA,SAAS,YAAA,CAAa,KAAA,EAAkB,QAAA,EAA2B,MAAA,EAA8B;AAC/F,EAAA,IAAI,CAAC,cAAA,CAAe,KAAK,CAAA,EAAG;AAC1B,IAAA,MAAM,IAAI,eAAA;AAAA,MACR,CAAA,YAAA,EAAe,MAAM,CAAA,+CAAA,EAAkD,MAAM,2CAAiC,MAAM,CAAA,EAAA;AAAA,KACtH;AAAA,EACF;AACA,EAAA,MAAM,MAAA,GAAU,KAAA,CAAM,KAAA,IAAS,EAAC;AAChC,EAAA,MAAM,OAAA,GAAU,CAAC,KAAA,KAAmC;AAClD,IAAA,MAAA,CAAO,UAAU,KAAK,CAAA;AACtB,IAAA,IAAI,CAAC,KAAA,CAAM,gBAAA,EAAkB,QAAA,CAAS,QAAQ,KAAK,CAAA;AAAA,EACrD,CAAA;AACA,EAAA,OAAO,aAAa,KAAA,EAAgD;AAAA,IAClE,GAAG,QAAA;AAAA,IACH,GAAG,MAAA;AAAA,IACH,OAAA;AAAA,IACA,IAAA,EAAM,MAAA,CAAO,IAAA,IAAQ,QAAA,CAAS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,OAAA,EAAS,IAAA,EAAM,SAAQ,GAAI,MAAA;AAAA,IACvD,YAAA,EAAc,SAAA,GAAY,EAAE,EAAA,EAAI,WAAU,GAAI,MAAA;AAAA,IAC9C,OAAA,EAAS;AAAA,MACP,IAAI,KAAA,CAAM,EAAA;AAAA,MACV,KAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAA;AAAA,MACA,KAAA,EAAO,OAAO,CAAC,CAAA;AAAA,MACf,UAAU,KAAA,CAAM,QAAA;AAAA,MAChB,UAAU,KAAA,CAAM,QAAA;AAAA,MAChB,QAAQ,KAAA,CAAM,MAAA;AAAA,MACd,cAAA,EAAgB,UAAU,IAAA,GAAO,MAAA;AAAA,MACjC,eAAA,EAAiB,KAAA,CAAM,QAAA,GAAW,IAAA,GAAO,MAAA;AAAA,MACzC,kBAAA,EAAoB,WAAA;AAAA,MACpB,mBAAA,EAAqB;AAAA;AACvB,GACF;AACF","file":"index.js","sourcesContent":["import { Children, cloneElement, isValidElement, type ComponentProps, type MouseEvent, type ReactElement, type ReactNode } from 'react'\nimport { ShikiUsageError } from '@shikiform/core/internal'\nimport { useFormMessage } from '../hooks/use-form-message'\nimport { useReset, useSubmit, type ResetState, type SubmitState, type UseResetOptions, type UseSubmitOptions } from '../hooks/use-submit'\nimport type { FormSubmitHandlers } from './fields'\n\ntype ButtonPass = Omit<ComponentProps<'button'>, 'onClick' | 'type' | 'disabled' | 'children'>\n\ntype AsChildBehavior = {\n type: 'submit' | 'button'\n disabled?: boolean\n 'aria-busy'?: true\n 'data-loading'?: ''\n onClick: (event: MouseEvent<HTMLElement>) => void\n}\n\nfunction buttonDom(state: SubmitState<MouseEvent<HTMLElement>>): AsChildBehavior {\n return {\n type: state.type,\n disabled: state.disabled,\n 'aria-busy': state['aria-busy'],\n 'data-loading': state['data-loading'],\n onClick: state.onClick,\n }\n}\n\n/**\n * Put `behavior` on a single element child. The child's own props win, except `onClick` (child, then ours,\n * unless the child calls `preventDefault`) and `disabled` / `type` / busy flags (child wins only when set).\n */\nfunction mergeAsChild(child: ReactNode, behavior: AsChildBehavior, caller: string): ReactElement {\n if (!isValidElement(child)) {\n throw new ShikiUsageError(\n `[shikiform] ${caller} asChild expects a single React element, e.g. <${caller} asChild><button>保存</button></${caller}>.`,\n )\n }\n const theirs = (child.props ?? {}) as Record<string, any>\n const onClick = (event: MouseEvent<HTMLElement>) => {\n theirs.onClick?.(event)\n if (!event.defaultPrevented) behavior.onClick(event)\n }\n return cloneElement(child as ReactElement<Record<string, unknown>>, {\n ...behavior,\n ...theirs,\n onClick,\n type: theirs.type ?? behavior.type,\n disabled: theirs.disabled ?? ('disabled' in behavior ? behavior.disabled : undefined),\n 'aria-busy': theirs['aria-busy'] ?? ('aria-busy' in behavior ? behavior['aria-busy'] : undefined),\n 'data-loading': theirs['data-loading'] ?? ('data-loading' in behavior ? behavior['data-loading'] : undefined),\n })\n}\n\nexport type SubmitProps<T = any> = FormSubmitHandlers<T> & ButtonPass & {\n /**\n * Render your own element and merge submit behavior onto it.\n * `<Submit asChild><button>保存</button></Submit>`.\n */\n asChild?: boolean\n /** Button label, a render prop that receives {@link SubmitState}, or the `asChild` element. */\n children?: ReactNode | ((state: SubmitState<MouseEvent<HTMLButtonElement>>) => ReactNode)\n /** Overrides `!$canSubmit`. */\n disabled?: boolean\n /** Runs first. `preventDefault` skips a self-managed submit (`onSubmit` passed). */\n onClick?: (event: MouseEvent<HTMLButtonElement>) => void\n}\n\n/**\n * Headless submit control for the surrounding form. No Ant Design.\n *\n * - Render prop: `{(state) => <button type={state.type} disabled={state.disabled} onClick={state.onClick}>保存</button>}`.\n * - `asChild`: behavior is merged onto the single child (`disabled`, `type`, `aria-busy`, `data-loading`, `onClick`).\n * - Otherwise a native `<button>`. Label defaults to `messages.submit` (`提交`).\n *\n * Without `onSubmit` the button is `type=\"submit\"` and `<Form onSubmit>` handles it (Enter works the same).\n * With `onSubmit` the click runs `form.submit` itself, so it also works outside a `<form>` element.\n */\nexport function Submit<T = any>({\n asChild, children, onSubmit, onInvalid, onSubmitError, onClick, disabled, className, ...rest\n}: SubmitProps<T>) {\n const options: UseSubmitOptions<T, MouseEvent<HTMLButtonElement>> = { onSubmit, onInvalid, onSubmitError, onClick, disabled }\n const state = useSubmit<T, MouseEvent<HTMLButtonElement>>(options)\n const t = useFormMessage()\n if (typeof children === 'function') return <>{children(state)}</>\n if (asChild) return mergeAsChild(children, buttonDom(state as SubmitState<MouseEvent<HTMLElement>>), 'Submit')\n return (\n <button\n {...rest}\n className={className}\n type={state.type}\n disabled={state.disabled}\n aria-busy={state['aria-busy']}\n data-loading={state['data-loading']}\n onClick={state.onClick}\n >\n {children ?? t('submit')}\n </button>\n )\n}\n\nexport type ResetProps<T = any> = Omit<ButtonPass, 'onClick'> & {\n /** Reset to these values and make them the new initial values (`form.reset(values)`). Default: the current initial values. */\n values?: T\n /**\n * Called after `form.reset`, with the restored values. Use it to query again.\n * `onClick` still runs first; `preventDefault` skips the reset and this callback.\n */\n afterReset?: (values: T) => void\n /** Runs before the reset. `preventDefault` skips the reset. */\n onClick?: (event: MouseEvent<HTMLButtonElement>) => void\n asChild?: boolean\n children?: ReactNode | ((state: ResetState<MouseEvent<HTMLButtonElement>>) => ReactNode)\n className?: string\n disabled?: boolean\n}\n\n/**\n * Headless reset control for the surrounding form: `form.reset()` on click. No Ant Design.\n * `type` is `'button'` so the browser's native reset does not bypass the store.\n * Label defaults to `messages.reset` (`重置`). `afterReset` runs after the values are restored.\n *\n * ```tsx\n * <Reset afterReset={(values) => search(values)} asChild><button>重置</button></Reset>\n * ```\n */\nexport function Reset<T = any>({ asChild, children, values, afterReset, onClick, className, disabled, ...rest }: ResetProps<T>) {\n const options: UseResetOptions<T, MouseEvent<HTMLButtonElement>> = { values, afterReset, onClick, disabled }\n const state = useReset<T, MouseEvent<HTMLButtonElement>>(options)\n const t = useFormMessage()\n if (typeof children === 'function') return <>{children(state)}</>\n if (asChild) {\n return mergeAsChild(children, {\n type: 'button',\n disabled: state.disabled,\n onClick: state.onClick as (event: MouseEvent<HTMLElement>) => void,\n }, 'Reset')\n }\n return (\n <button {...rest} className={className} type=\"button\" disabled={state.disabled} onClick={state.onClick}>\n {children ?? t('reset')}\n </button>\n )\n}\n","import type { ComponentType, ReactNode } from 'react'\nimport { createForm, type DefaultSubmit, type FieldsInput, type FormInstance, type FormOptions, type ResolveSubmit } from '@shikiform/core/internal'\nimport type { ArrayItemOf, ArrayPath, Draft, FieldPath, PathValue } from '@shikiform/core/internal'\nimport { useForm, type UseFormOptions } from '../hooks/use-form'\nimport { ArrayField, Field, ObjectField, Watch, type ArrayContainerSlot, type CheckedFieldProps, type FieldProps } from '../components/fields'\nimport { useArrayField, type ArrayHandle, type ArrayKey } from '../hooks/use-array'\nimport { useField, type FieldBinding, type UseFieldOptions } from '../hooks/use-field'\nimport { useWatch } from '../hooks/use-watch'\n\n/**\n * Field components whose names are checked against `T`, the value at the current scope.\n * Names stay relative at runtime, exactly like the plain components: these are the same components with types.\n * `ArrayField` hands each row the same set typed as one row; `ObjectField` hands its function children the set\n * typed as that object.\n */\nexport type ScopeFields<T> = {\n Field: <N extends FieldPath<T>, C extends ComponentType<any> = ComponentType<any>, D extends ComponentType<any> = ComponentType<any>>(\n props: CheckedFieldProps<T, N, C, D>,\n ) => ReactNode\n ObjectField: <N extends FieldPath<T>>(props: {\n name: N\n display?: FieldProps['display']\n children?: ReactNode | ((scope: ScopeFields<NonNullable<PathValue<T, N & string>>>) => ReactNode)\n }) => ReactNode\n ArrayField: <N extends ArrayPath<T>, C extends ComponentType<any> = ComponentType<any>>(props: {\n name: N\n rowKey?: string\n component?: ArrayContainerSlot<C>\n virtualScroll?: { height: number; rowHeight?: number; overscan?: number }\n children?: (row: ArrayKey & ScopeFields<ArrayItemOf<T, N & string>>) => ReactNode\n }) => ReactNode\n}\n\n/**\n * {@link typed}'s return: {@link ScopeFields} for the form root plus typed hooks.\n * `useField` / `useArrayField` names are relative to the calling component's scope, typed against `T`.\n * `useWatch` / `Watch` select from the root draft (`Draft<TRoot>`).\n */\ntype FieldsOf<T, F> = { fields?: F & FieldsInput<T> }\n\nexport type TypedForm<T, TRoot = T> = ScopeFields<T> & {\n useField: <N extends FieldPath<T>>(name: N, options?: UseFieldOptions<PathValue<T, N & string>>) => FieldBinding<PathValue<T, N & string>>\n useArrayField: <N extends ArrayPath<T>>(name: N, rowKey?: string) => ArrayHandle<ArrayItemOf<T, N & string>>\n useWatch: <S>(select: (d: Draft<TRoot>) => S) => S\n Watch: <S>(props: { select: (d: Draft<TRoot>) => S; children: (value: S) => ReactNode }) => ReactNode\n /**\n * Same `createForm`, with `T` already fixed, so `fields` still decides which `virtual` / `none` paths are optional\n * on submit. `createForm<T>(options)` does not: its submit type is `T`.\n */\n createForm: <TSubmit = DefaultSubmit, const F extends FieldsInput<T> = {}>(\n options?: Omit<FormOptions<T>, 'fields'> & FieldsOf<T, F>,\n ) => FormInstance<T, ResolveSubmit<T, TSubmit, F>>\n /** Same `useForm`. See {@link TypedForm.createForm}. `useForm()` with no arguments is not this; it is an empty form. */\n useForm: <TSubmit = DefaultSubmit, const F extends FieldsInput<T> = {}>(\n options?: Omit<UseFormOptions<T>, 'fields'> & FieldsOf<T, F>,\n ) => FormInstance<T, ResolveSubmit<T, TSubmit, F>>\n}\n\n/**\n * The name-checked field components and hooks for one form.\n * No new runtime: each member is the plain component / hook with the form's types, so names still resolve\n * relative to the enclosing scope.\n *\n * ```tsx\n * const form = useForm({ initialValues: { email: '', items: [{ name: '' }] } })\n * const F = typed(form)\n * <Form form={form}>\n * <F.Field name=\"email\" /> // 'emial' does not compile\n * <F.ArrayField name=\"items\">\n * {(row) => <row.Field name=\"name\" />} // checked against one item, binds items.<i>.name\n * </F.ArrayField>\n * <F.Watch select={(d) => d.$canSubmit}>{(ok) => <button disabled={!ok}>提交</button>}</F.Watch>\n * </Form>\n * ```\n *\n * `typed<Row>()` (no form) types a component that renders inside a scope — a row, or a reusable fragment under an\n * `<ObjectField name=\"address\">`: `typed<Address>().Field`. Its `useWatch` still reads the root draft; pass the\n * root as the second argument (`typed<Row, Values>()`) to type it.\n * The same object has `createForm` / `useForm`: `typed<Values>().useForm({ fields })` keeps `Values` and still infers\n * which `fields` paths are optional on submit. `useForm<Values>(options)` does not.\n */\nexport function typed<T, TRoot = T>(): TypedForm<T, TRoot>\nexport function typed<T>(form: FormInstance<T, any>): TypedForm<T>\nexport function typed(_form?: FormInstance<any, any>): TypedForm<any> {\n return handles\n}\n\nfunction TypedArrayField({ children, ...props }: { name: string; rowKey?: string; component?: ArrayContainerSlot; virtualScroll?: { height: number; rowHeight?: number; overscan?: number }; children?: (row: any) => ReactNode }) {\n return <ArrayField {...props}>{children ? (row) => children({ ...row, ...scope }) : undefined}</ArrayField>\n}\nfunction TypedObjectField({ children, ...props }: { name: string; display?: FieldProps['display']; children?: ReactNode | ((scope: any) => ReactNode) }) {\n return <ObjectField {...props}>{typeof children === 'function' ? children(scope) : children}</ObjectField>\n}\n\nconst scope = { Field, ObjectField: TypedObjectField, ArrayField: TypedArrayField }\nconst handles = { ...scope, useField, useArrayField, useWatch, Watch, createForm, useForm } as unknown as TypedForm<any>\n","import type { ReactNode } from 'react'\nimport type { Pattern } from '@shikiform/core/internal'\nimport { ShikiUsageError } from '@shikiform/core/internal'\nimport { useFieldContextOrNull } from '../field-context'\nimport type { FieldBinding } from './use-field'\n\n/**\n * What {@link useFieldDecorator} returns. Library-agnostic: no Ant Design props.\n * Spread `labelProps` / `errorProps` / `descriptionProps` in your own markup, or spread `control`\n * onto a widget that draws its own label and error (Mantine).\n */\nexport interface FieldDecorator {\n /** DOM id of the control (`htmlFor` / `aria-*` point here). */\n id: string\n /** `options.label` when passed, otherwise the field title. */\n label: ReactNode\n /** `options.description` when passed, otherwise the field description. */\n description: ReactNode\n /**\n * Whether to show the required mark. The field's `required`, hidden in `readPretty`, unless `asterisk` forces it.\n */\n required: boolean\n errors: readonly string[]\n warnings: readonly string[]\n /** `errors[0]`, for a control that takes one error string. */\n error: string | undefined\n /** True when `errors` is non-empty. Warnings alone are not invalid. */\n invalid: boolean\n validating: boolean\n disabled: boolean\n readOnly: boolean\n pattern: Pattern\n /** Space-separated ids for `aria-describedby`. Undefined when there is nothing to point at. */\n describedBy: string | undefined\n /** Spread onto `<label>`. `htmlFor` is omitted in `readPretty` (the view is text). */\n labelProps: { id: string; htmlFor?: string }\n /** Spread onto the description element. Undefined when there is no description. */\n descriptionProps: { id: string } | undefined\n /** Spread onto the error element. Undefined when there is no error. */\n errorProps: { id: string; role: 'alert' } | undefined\n /** Spread onto the warning element. Undefined when errors win or there is no warning. */\n warningProps: { id: string } | undefined\n /**\n * Props for a control that draws its own label and error. Do not also spread this onto a `connect()`ed\n * control: `connect` already sets `id`, `disabled`, `readOnly`, and `onBlur`.\n */\n control: {\n id: string\n label: ReactNode\n description: ReactNode\n required: boolean\n error: string | undefined\n disabled: boolean\n readOnly: boolean\n onBlur: () => void\n 'aria-invalid': true | undefined\n 'aria-required': true | undefined\n 'aria-describedby': string | undefined\n 'aria-errormessage': string | undefined\n }\n}\n\nexport interface FieldDecoratorOptions {\n /** A binding from `useField(name)`. Default: the surrounding `<Field>`. */\n field?: FieldBinding<any>\n /** Wins over the field title. */\n label?: ReactNode\n /** Wins over the field description. */\n description?: ReactNode\n /** Force the required mark on (`true`) or off (`false`). Default: `field.required`, hidden in `readPretty`. */\n asterisk?: boolean\n}\n\nconst NO_FIELD =\n '[shikiform] useFieldDecorator() reads the surrounding <Field>, but this component is not inside one. ' +\n 'Render it as a <Field decorator> (or inside <Field name=\"…\">), or pass the binding: useFieldDecorator({ field }).'\n\nfunction present(value: ReactNode): boolean {\n return value != null && value !== false && value !== ''\n}\n\n/**\n * Label, required mark, description, and errors for the current field, as plain data (not Ant Design props).\n * One hook covers a decorator (`labelProps` + children + `errorProps`) and a control that draws its own\n * chrome (`control`, the Mantine shape). Must run inside `<Field>`, or be given `options.field`.\n *\n * ```tsx\n * function FormItem({ children }: { children?: ReactNode }) {\n * const d = useFieldDecorator()\n * return (\n * <div>\n * <label {...d.labelProps}>{d.label}{d.required && <span>*</span>}</label>\n * {children}\n * {d.descriptionProps && <p {...d.descriptionProps}>{d.description}</p>}\n * {d.errorProps && <p {...d.errorProps}>{d.errors.join('、')}</p>}\n * </div>\n * )\n * }\n * ```\n */\nexport function useFieldDecorator(options?: FieldDecoratorOptions): FieldDecorator {\n const contextual = useFieldContextOrNull()\n const field = options?.field ?? contextual\n if (!field) throw new ShikiUsageError(NO_FIELD)\n const label = options && options.label !== undefined ? options.label : field.title\n const description = options && options.description !== undefined ? options.description : field.description\n const required = options?.asterisk !== undefined ? options.asterisk : field.required && field.pattern !== 'readPretty'\n const errors = field.errors\n const warnings = field.warnings\n const invalid = errors.length > 0\n const errorId = invalid ? `${field.id}-error` : undefined\n const warningId = !invalid && warnings.length > 0 ? `${field.id}-warning` : undefined\n const descriptionId = present(description) ? `${field.id}-description` : undefined\n const describedBy = [descriptionId, errorId ?? warningId].filter(Boolean).join(' ') || undefined\n const labelProps: FieldDecorator['labelProps'] = { id: `${field.id}-label` }\n if (field.pattern !== 'readPretty') labelProps.htmlFor = field.id\n return {\n id: field.id,\n label,\n description,\n required,\n errors,\n warnings,\n error: errors[0],\n invalid,\n validating: field.validating,\n disabled: field.disabled,\n readOnly: field.readOnly,\n pattern: field.pattern,\n describedBy,\n labelProps,\n descriptionProps: descriptionId ? { id: descriptionId } : undefined,\n errorProps: errorId ? { id: errorId, role: 'alert' } : undefined,\n warningProps: warningId ? { id: warningId } : undefined,\n control: {\n id: field.id,\n label,\n description,\n required,\n error: errors[0],\n disabled: field.disabled,\n readOnly: field.readOnly,\n onBlur: field.onBlur,\n 'aria-invalid': invalid ? true : undefined,\n 'aria-required': field.required ? true : undefined,\n 'aria-describedby': describedBy,\n 'aria-errormessage': errorId,\n },\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/buttons.tsx","../src/factory/typed.tsx","../src/hooks/use-field-decorator.ts"],"names":["jsx","ShikiUsageError"],"mappings":";;;;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AA;AAAA,IACvD,YAAA,EAAc,SAAA,GAAY,EAAE,EAAA,EAAI,WAAU,GAAI,MAAA;AAAA,IAC9C,OAAA,EAAS;AAAA,MACP,IAAI,KAAA,CAAM,EAAA;AAAA,MACV,KAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAA;AAAA,MACA,KAAA,EAAO,OAAO,CAAC,CAAA;AAAA,MACf,UAAU,KAAA,CAAM,QAAA;AAAA,MAChB,UAAU,KAAA,CAAM,QAAA;AAAA,MAChB,QAAQ,KAAA,CAAM,MAAA;AAAA,MACd,cAAA,EAAgB,UAAU,IAAA,GAAO,MAAA;AAAA,MACjC,eAAA,EAAiB,KAAA,CAAM,QAAA,GAAW,IAAA,GAAO,MAAA;AAAA,MACzC,kBAAA,EAAoB,WAAA;AAAA,MACpB,mBAAA,EAAqB;AAAA;AACvB,GACF;AACF","file":"index.js","sourcesContent":["import { Children, cloneElement, isValidElement, type ComponentProps, type MouseEvent, type ReactElement, type ReactNode } from 'react'\nimport { ShikiUsageError } from '@shikiform/core/internal'\nimport { useFormMessage } from '../hooks/use-form-message'\nimport { useReset, useSubmit, type ResetState, type SubmitState, type UseResetOptions, type UseSubmitOptions } from '../hooks/use-submit'\nimport type { FormSubmitHandlers } from './fields'\n\ntype ButtonPass = Omit<ComponentProps<'button'>, 'onClick' | 'type' | 'disabled' | 'children'>\n\ntype AsChildBehavior = {\n type: 'submit' | 'button'\n disabled?: boolean\n 'aria-busy'?: true\n 'data-loading'?: ''\n onClick: (event: MouseEvent<HTMLElement>) => void\n}\n\nfunction buttonDom(state: SubmitState<MouseEvent<HTMLElement>>): AsChildBehavior {\n return {\n type: state.type,\n disabled: state.disabled,\n 'aria-busy': state['aria-busy'],\n 'data-loading': state['data-loading'],\n onClick: state.onClick,\n }\n}\n\n/**\n * Put `behavior` on a single element child. The child's own props win, except `onClick` (child, then ours,\n * unless the child calls `preventDefault`) and `disabled` / `type` / busy flags (child wins only when set).\n */\nfunction mergeAsChild(child: ReactNode, behavior: AsChildBehavior, caller: string): ReactElement {\n if (!isValidElement(child)) {\n throw new ShikiUsageError(\n `[shikiform] ${caller} asChild expects a single React element, e.g. <${caller} asChild><button>保存</button></${caller}>.`,\n )\n }\n const theirs = (child.props ?? {}) as Record<string, any>\n const onClick = (event: MouseEvent<HTMLElement>) => {\n theirs.onClick?.(event)\n if (!event.defaultPrevented) behavior.onClick(event)\n }\n return cloneElement(child as ReactElement<Record<string, unknown>>, {\n ...behavior,\n ...theirs,\n onClick,\n type: theirs.type ?? behavior.type,\n disabled: theirs.disabled ?? ('disabled' in behavior ? behavior.disabled : undefined),\n 'aria-busy': theirs['aria-busy'] ?? ('aria-busy' in behavior ? behavior['aria-busy'] : undefined),\n 'data-loading': theirs['data-loading'] ?? ('data-loading' in behavior ? behavior['data-loading'] : undefined),\n })\n}\n\nexport type SubmitProps<T = any> = FormSubmitHandlers<T> & ButtonPass & {\n /**\n * Render your own element and merge submit behavior onto it.\n * `<Submit asChild><button>保存</button></Submit>`.\n */\n asChild?: boolean\n /** Button label, a render prop that receives {@link SubmitState}, or the `asChild` element. */\n children?: ReactNode | ((state: SubmitState<MouseEvent<HTMLButtonElement>>) => ReactNode)\n /** Overrides `!$canSubmit`. */\n disabled?: boolean\n /** Runs first. `preventDefault` skips a self-managed submit (`onSubmit` passed). */\n onClick?: (event: MouseEvent<HTMLButtonElement>) => void\n}\n\n/**\n * Headless submit control for the surrounding form. No Ant Design.\n *\n * - Render prop: `{(state) => <button type={state.type} disabled={state.disabled} onClick={state.onClick}>保存</button>}`.\n * - `asChild`: behavior is merged onto the single child (`disabled`, `type`, `aria-busy`, `data-loading`, `onClick`).\n * - Otherwise a native `<button>`. Label defaults to `messages.submit` (`提交`).\n *\n * Without `onSubmit` the button is `type=\"submit\"` and `<Form onSubmit>` handles it (Enter works the same).\n * With `onSubmit` the click runs `form.submit` itself, so it also works outside a `<form>` element.\n */\nexport function Submit<T = any>({\n asChild, children, onSubmit, onInvalid, onSubmitError, onClick, disabled, className, ...rest\n}: SubmitProps<T>) {\n const options: UseSubmitOptions<T, MouseEvent<HTMLButtonElement>> = { onSubmit, onInvalid, onSubmitError, onClick, disabled }\n const state = useSubmit<T, MouseEvent<HTMLButtonElement>>(options)\n const t = useFormMessage()\n if (typeof children === 'function') return <>{children(state)}</>\n if (asChild) return mergeAsChild(children, buttonDom(state as SubmitState<MouseEvent<HTMLElement>>), 'Submit')\n return (\n <button\n {...rest}\n className={className}\n type={state.type}\n disabled={state.disabled}\n aria-busy={state['aria-busy']}\n data-loading={state['data-loading']}\n onClick={state.onClick}\n >\n {children ?? t('submit')}\n </button>\n )\n}\n\nexport type ResetProps<T = any> = Omit<ButtonPass, 'onClick'> & {\n /** Reset to these values and make them the new initial values (`form.reset(values)`). Default: the current initial values. */\n values?: T\n /**\n * Called after `form.reset`, with the restored values. Use it to query again.\n * `onClick` still runs first; `preventDefault` skips the reset and this callback.\n */\n afterReset?: (values: T) => void\n /** Runs before the reset. `preventDefault` skips the reset. */\n onClick?: (event: MouseEvent<HTMLButtonElement>) => void\n asChild?: boolean\n children?: ReactNode | ((state: ResetState<MouseEvent<HTMLButtonElement>>) => ReactNode)\n className?: string\n disabled?: boolean\n}\n\n/**\n * Headless reset control for the surrounding form: `form.reset()` on click. No Ant Design.\n * `type` is `'button'` so the browser's native reset does not bypass the store.\n * Label defaults to `messages.reset` (`重置`). `afterReset` runs after the values are restored.\n *\n * ```tsx\n * <Reset afterReset={(values) => search(values)} asChild><button>重置</button></Reset>\n * ```\n */\nexport function Reset<T = any>({ asChild, children, values, afterReset, onClick, className, disabled, ...rest }: ResetProps<T>) {\n const options: UseResetOptions<T, MouseEvent<HTMLButtonElement>> = { values, afterReset, onClick, disabled }\n const state = useReset<T, MouseEvent<HTMLButtonElement>>(options)\n const t = useFormMessage()\n if (typeof children === 'function') return <>{children(state)}</>\n if (asChild) {\n return mergeAsChild(children, {\n type: 'button',\n disabled: state.disabled,\n onClick: state.onClick as (event: MouseEvent<HTMLElement>) => void,\n }, 'Reset')\n }\n return (\n <button {...rest} className={className} type=\"button\" disabled={state.disabled} onClick={state.onClick}>\n {children ?? t('reset')}\n </button>\n )\n}\n","import type { ComponentType, ReactNode } from 'react'\nimport { createForm, type DefaultSubmit, type FieldsInput, type FormInstance, type FormOptions, type ResolveSubmit } from '@shikiform/core/internal'\nimport type { ArrayItemOf, ArrayPath, Draft, FieldPath, PathValue } from '@shikiform/core/internal'\nimport { useForm, type UseFormOptions } from '../hooks/use-form'\nimport { ArrayField, Field, ObjectField, TreeField, Watch, type ArrayContainerSlot, type CheckedFieldProps, type FieldProps, type TreeNodeRender } from '../components/fields'\nimport { useArrayField, type ArrayHandle, type ArrayKey } from '../hooks/use-array'\nimport { useField, type FieldBinding, type UseFieldOptions } from '../hooks/use-field'\nimport { useWatch } from '../hooks/use-watch'\n\n/**\n * Field components whose names are checked against `T`, the value at the current scope.\n * Names stay relative at runtime, exactly like the plain components: these are the same components with types.\n * `ArrayField` hands each row the same set typed as one row; `ObjectField` hands its function children the set\n * typed as that object.\n */\nexport type ScopeFields<T> = {\n Field: <N extends FieldPath<T>, C extends ComponentType<any> = ComponentType<any>, D extends ComponentType<any> = ComponentType<any>>(\n props: CheckedFieldProps<T, N, C, D>,\n ) => ReactNode\n ObjectField: <N extends FieldPath<T>>(props: {\n name: N\n display?: FieldProps['display']\n children?: ReactNode | ((scope: ScopeFields<NonNullable<PathValue<T, N & string>>>) => ReactNode)\n }) => ReactNode\n ArrayField: <N extends ArrayPath<T>, C extends ComponentType<any> = ComponentType<any>>(props: {\n name: N\n rowKey?: string\n component?: ArrayContainerSlot<C>\n virtualScroll?: { height: number; rowHeight?: number; overscan?: number }\n children?: (row: ArrayKey & ScopeFields<ArrayItemOf<T, N & string>>) => ReactNode\n }) => ReactNode\n TreeField: <N extends ArrayPath<T>>(props: {\n name: N\n childrenKey?: string\n rowKey?: string\n children: (node: TreeNodeRender & ScopeFields<ArrayItemOf<T, N & string>>) => ReactNode\n }) => ReactNode\n}\n\n/**\n * {@link typed}'s return: {@link ScopeFields} for the form root plus typed hooks.\n * `useField` / `useArrayField` names are relative to the calling component's scope, typed against `T`.\n * `useWatch` / `Watch` select from the root draft (`Draft<TRoot>`).\n */\ntype FieldsOf<T, F> = { fields?: F & FieldsInput<T> }\n\nexport type TypedForm<T, TRoot = T> = ScopeFields<T> & {\n useField: <N extends FieldPath<T>>(name: N, options?: UseFieldOptions<PathValue<T, N & string>>) => FieldBinding<PathValue<T, N & string>>\n useArrayField: <N extends ArrayPath<T>>(name: N, rowKey?: string) => ArrayHandle<ArrayItemOf<T, N & string>>\n useWatch: <S>(select: (d: Draft<TRoot>) => S) => S\n Watch: <S>(props: { select: (d: Draft<TRoot>) => S; children: (value: S) => ReactNode }) => ReactNode\n /**\n * Same `createForm`, with `T` already fixed, so `fields` still decides which `virtual` / `none` paths are optional\n * on submit. `createForm<T>(options)` does not: its submit type is `T`.\n */\n createForm: <TSubmit = DefaultSubmit, const F extends FieldsInput<T> = {}>(\n options?: Omit<FormOptions<T>, 'fields'> & FieldsOf<T, F>,\n ) => FormInstance<T, ResolveSubmit<T, TSubmit, F>>\n /** Same `useForm`. See {@link TypedForm.createForm}. `useForm()` with no arguments is not this; it is an empty form. */\n useForm: <TSubmit = DefaultSubmit, const F extends FieldsInput<T> = {}>(\n options?: Omit<UseFormOptions<T>, 'fields'> & FieldsOf<T, F>,\n ) => FormInstance<T, ResolveSubmit<T, TSubmit, F>>\n}\n\n/**\n * The name-checked field components and hooks for one form.\n * No new runtime: each member is the plain component / hook with the form's types, so names still resolve\n * relative to the enclosing scope.\n *\n * ```tsx\n * const form = useForm({ initialValues: { email: '', items: [{ name: '' }] } })\n * const F = typed(form)\n * <Form form={form}>\n * <F.Field name=\"email\" /> // 'emial' does not compile\n * <F.ArrayField name=\"items\">\n * {(row) => <row.Field name=\"name\" />} // checked against one item, binds items.<i>.name\n * </F.ArrayField>\n * <F.Watch select={(d) => d.$canSubmit}>{(ok) => <button disabled={!ok}>提交</button>}</F.Watch>\n * </Form>\n * ```\n *\n * `typed<Row>()` (no form) types a component that renders inside a scope — a row, or a reusable fragment under an\n * `<ObjectField name=\"address\">`: `typed<Address>().Field`. Its `useWatch` still reads the root draft; pass the\n * root as the second argument (`typed<Row, Values>()`) to type it.\n * The same object has `createForm` / `useForm`: `typed<Values>().useForm({ fields })` keeps `Values` and still infers\n * which `fields` paths are optional on submit. `useForm<Values>(options)` does not.\n */\nexport function typed<T, TRoot = T>(): TypedForm<T, TRoot>\nexport function typed<T>(form: FormInstance<T, any>): TypedForm<T>\nexport function typed(_form?: FormInstance<any, any>): TypedForm<any> {\n return handles\n}\n\nfunction TypedArrayField({ children, ...props }: { name: string; rowKey?: string; component?: ArrayContainerSlot; virtualScroll?: { height: number; rowHeight?: number; overscan?: number }; children?: (row: any) => ReactNode }) {\n return <ArrayField {...props}>{children ? (row) => children({ ...row, ...scope }) : undefined}</ArrayField>\n}\nfunction TypedObjectField({ children, ...props }: { name: string; display?: FieldProps['display']; children?: ReactNode | ((scope: any) => ReactNode) }) {\n return <ObjectField {...props}>{typeof children === 'function' ? children(scope) : children}</ObjectField>\n}\nfunction TypedTreeField({ children, ...props }: { name: string; childrenKey?: string; rowKey?: string; children: (node: any) => ReactNode }) {\n return <TreeField {...props}>{(node) => children({ ...node, ...scope })}</TreeField>\n}\n\nconst scope = { Field, ObjectField: TypedObjectField, ArrayField: TypedArrayField, TreeField: TypedTreeField }\nconst handles = { ...scope, useField, useArrayField, useWatch, Watch, createForm, useForm } as unknown as TypedForm<any>\n","import type { ReactNode } from 'react'\nimport type { Pattern } from '@shikiform/core/internal'\nimport { ShikiUsageError } from '@shikiform/core/internal'\nimport { useFieldContextOrNull } from '../field-context'\nimport type { FieldBinding } from './use-field'\n\n/**\n * What {@link useFieldDecorator} returns. Library-agnostic: no Ant Design props.\n * Spread `labelProps` / `errorProps` / `descriptionProps` in your own markup, or spread `control`\n * onto a widget that draws its own label and error (Mantine).\n */\nexport interface FieldDecorator {\n /** DOM id of the control (`htmlFor` / `aria-*` point here). */\n id: string\n /** `options.label` when passed, otherwise the field title. */\n label: ReactNode\n /** `options.description` when passed, otherwise the field description. */\n description: ReactNode\n /**\n * Whether to show the required mark. The field's `required`, hidden in `readPretty`, unless `asterisk` forces it.\n */\n required: boolean\n errors: readonly string[]\n warnings: readonly string[]\n /** `errors[0]`, for a control that takes one error string. */\n error: string | undefined\n /** True when `errors` is non-empty. Warnings alone are not invalid. */\n invalid: boolean\n validating: boolean\n disabled: boolean\n readOnly: boolean\n pattern: Pattern\n /** Space-separated ids for `aria-describedby`. Undefined when there is nothing to point at. */\n describedBy: string | undefined\n /** Spread onto `<label>`. `htmlFor` is omitted in `readPretty` (the view is text). */\n labelProps: { id: string; htmlFor?: string }\n /** Spread onto the description element. Undefined when there is no description. */\n descriptionProps: { id: string } | undefined\n /** Spread onto the error element. Undefined when there is no error. */\n errorProps: { id: string; role: 'alert' } | undefined\n /** Spread onto the warning element. Undefined when errors win or there is no warning. */\n warningProps: { id: string } | undefined\n /**\n * Props for a control that draws its own label and error. Do not also spread this onto a `connect()`ed\n * control: `connect` already sets `id`, `disabled`, `readOnly`, and `onBlur`.\n */\n control: {\n id: string\n label: ReactNode\n description: ReactNode\n required: boolean\n error: string | undefined\n disabled: boolean\n readOnly: boolean\n onBlur: () => void\n 'aria-invalid': true | undefined\n 'aria-required': true | undefined\n 'aria-describedby': string | undefined\n 'aria-errormessage': string | undefined\n }\n}\n\nexport interface FieldDecoratorOptions {\n /** A binding from `useField(name)`. Default: the surrounding `<Field>`. */\n field?: FieldBinding<any>\n /** Wins over the field title. */\n label?: ReactNode\n /** Wins over the field description. */\n description?: ReactNode\n /** Force the required mark on (`true`) or off (`false`). Default: `field.required`, hidden in `readPretty`. */\n asterisk?: boolean\n}\n\nconst NO_FIELD =\n '[shikiform] useFieldDecorator() reads the surrounding <Field>, but this component is not inside one. ' +\n 'Render it as a <Field decorator> (or inside <Field name=\"…\">), or pass the binding: useFieldDecorator({ field }).'\n\nfunction present(value: ReactNode): boolean {\n return value != null && value !== false && value !== ''\n}\n\n/**\n * Label, required mark, description, and errors for the current field, as plain data (not Ant Design props).\n * One hook covers a decorator (`labelProps` + children + `errorProps`) and a control that draws its own\n * chrome (`control`, the Mantine shape). Must run inside `<Field>`, or be given `options.field`.\n *\n * ```tsx\n * function FormItem({ children }: { children?: ReactNode }) {\n * const d = useFieldDecorator()\n * return (\n * <div>\n * <label {...d.labelProps}>{d.label}{d.required && <span>*</span>}</label>\n * {children}\n * {d.descriptionProps && <p {...d.descriptionProps}>{d.description}</p>}\n * {d.errorProps && <p {...d.errorProps}>{d.errors.join('、')}</p>}\n * </div>\n * )\n * }\n * ```\n */\nexport function useFieldDecorator(options?: FieldDecoratorOptions): FieldDecorator {\n const contextual = useFieldContextOrNull()\n const field = options?.field ?? contextual\n if (!field) throw new ShikiUsageError(NO_FIELD)\n const label = options && options.label !== undefined ? options.label : field.title\n const description = options && options.description !== undefined ? options.description : field.description\n const required = options?.asterisk !== undefined ? options.asterisk : field.required && field.pattern !== 'readPretty'\n const errors = field.errors\n const warnings = field.warnings\n const invalid = errors.length > 0\n const errorId = invalid ? `${field.id}-error` : undefined\n const warningId = !invalid && warnings.length > 0 ? `${field.id}-warning` : undefined\n const descriptionId = present(description) ? `${field.id}-description` : undefined\n const describedBy = [descriptionId, errorId ?? warningId].filter(Boolean).join(' ') || undefined\n const labelProps: FieldDecorator['labelProps'] = { id: `${field.id}-label` }\n if (field.pattern !== 'readPretty') labelProps.htmlFor = field.id\n return {\n id: field.id,\n label,\n description,\n required,\n errors,\n warnings,\n error: errors[0],\n invalid,\n validating: field.validating,\n disabled: field.disabled,\n readOnly: field.readOnly,\n pattern: field.pattern,\n describedBy,\n labelProps,\n descriptionProps: descriptionId ? { id: descriptionId } : undefined,\n errorProps: errorId ? { id: errorId, role: 'alert' } : undefined,\n warningProps: warningId ? { id: warningId } : undefined,\n control: {\n id: field.id,\n label,\n description,\n required,\n error: errors[0],\n disabled: field.disabled,\n readOnly: field.readOnly,\n onBlur: field.onBlur,\n 'aria-invalid': invalid ? true : undefined,\n 'aria-required': field.required ? true : undefined,\n 'aria-describedby': describedBy,\n 'aria-errormessage': errorId,\n },\n }\n}\n"]}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
import { c as FieldBinding } from './use-watch-
|
|
2
|
-
export {
|
|
1
|
+
import { c as FieldBinding, L as ScopeValue } from './use-watch-9vSz8P44.js';
|
|
2
|
+
export { ae as ArrayContext, g as ArrayField, b as ArrayKey, af as ArrayScope, B as BlurFlag, i as BlurOn, k as ComponentStatics, l as ConnectEnhancer, m as ConnectFieldProps, n as ConnectedComponent, D as DragProps, ag as FieldContext, r as FieldGroup, ah as FieldGroupContext, ai as FieldGroupStore, w as FieldPropKey, y as FieldStateKey, z as Form, aj as FormContext, F as FormSubmitHandlers, ak as PropsEnhancer, P as PropsMapping, H as PropsTransform, al as RowScope, am as RowWrapContext, an as ScopeContext, ao as UiNodeContext, Z as connect, _ as mapProps, $ as useArray, ap as useArrayAt, a0 as useArrayErrors, aq as useFieldGroupRegistration, a5 as useForm, a7 as useFormMessage, ar as useGroupsErrors, a8 as useIndex, a9 as useRecord, as as useRequiredForm, aa as useReset, at as useScope, ab as useSubmit, au as useUiNodeOrNull, ad as useWatch, av as valueFromEvent } from './use-watch-9vSz8P44.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
|
-
import '@shikiform/core/internal';
|
|
5
|
+
import { FormEngine } from '@shikiform/core/internal';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Windowed list. `@tanstack/react-virtual` is the scroll engine.
|
|
9
|
+
* Pass the row as `children(index)` — the row should subscribe to its own fields,
|
|
10
|
+
* so a cell edit does not re-render the other mounted rows.
|
|
11
|
+
*/
|
|
12
|
+
declare function VirtualRows({ count, height, rowHeight, overscan, children, }: {
|
|
13
|
+
count: number;
|
|
14
|
+
height: number;
|
|
15
|
+
rowHeight?: number;
|
|
16
|
+
overscan?: number;
|
|
17
|
+
children: (index: number) => ReactNode;
|
|
18
|
+
}): react.JSX.Element;
|
|
6
19
|
|
|
7
20
|
/**
|
|
8
21
|
* Internal, outside-field tolerant read: the surrounding field, or `null`. For components (`FormItem`, `connect`)
|
|
@@ -24,4 +37,12 @@ declare function IdPrefixProvider({ prefix, children }: {
|
|
|
24
37
|
*/
|
|
25
38
|
declare function useAutoIdPrefix(explicit?: string): string;
|
|
26
39
|
|
|
27
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a field name against the enclosing `<ObjectField>` / `<ArrayField>` / row scope (names are always
|
|
42
|
+
* relative to it). In development, a name that repeats the scope (`items.0.name` inside the `items.0` row) throws
|
|
43
|
+
* {@link ShikiUsageError} instead of silently binding `items.0.items.0.name` (#30): it fires only when the joined
|
|
44
|
+
* path holds no value while the name read from the root does.
|
|
45
|
+
*/
|
|
46
|
+
declare function resolveName(form: FormEngine<any, any>, scope: ScopeValue, name: string): string;
|
|
47
|
+
|
|
48
|
+
export { FieldBinding, IdPrefixProvider, VirtualRows, resolveName, useAutoIdPrefix, useFieldContextOrNull };
|
package/dist/internal.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ArrayContext, ArrayField, FieldGroup, FieldGroupStore, Form, FormContext, IdPrefixProvider, RowScope, RowWrapContext, ScopeContext,
|
|
1
|
+
export { ArrayContext, ArrayField, ArrayScope, FieldContext, FieldGroup, FieldGroupContext, FieldGroupStore, Form, FormContext, IdPrefixProvider, RowScope, RowWrapContext, ScopeContext, UiNodeContext, VirtualRows, connect, mapProps, resolveName, useArray, useArrayAt, useArrayErrors, useAutoIdPrefix, useFieldContextOrNull, useFieldGroupRegistration, useForm, useFormMessage, useGroupsErrors, useIndex, useRecord, useRequiredForm, useReset, useScope, useSubmit, useUiNodeOrNull, useWatch, valueFromEvent } from './chunk-DQHRLKQS.js';
|
|
2
2
|
//# sourceMappingURL=internal.js.map
|
|
3
3
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ComponentType, ReactNode, ComponentProps,
|
|
3
|
-
import { Display, Pattern, EnumOption, UiName, FieldEnum, RulesInput, FieldPath, PathValue,
|
|
2
|
+
import { ComponentType, ReactNode, ComponentProps, FormHTMLAttributes, FunctionComponent, ComponentClass, ForwardRefExoticComponent, Ref, DragEvent } from 'react';
|
|
3
|
+
import { Display, Pattern, EnumOption, UiName, FieldEnum, RulesInput, FieldPath, PathValue, ArrayPath, FieldError, FormInstance, Pos, Draft, FormOptions, DefaultSubmit, FieldsInput, ResolveSubmit, ArrayItemOf, FormEngine, UiDisplay, MoveResult, FormMessageKey, MessageArgs } from '@shikiform/core/internal';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Register the controls your app passes to `<Field component="Input">` (module augmentation):
|
|
@@ -105,6 +105,10 @@ interface FieldBinding<TValue> {
|
|
|
105
105
|
*/
|
|
106
106
|
ui?: string;
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Internal (re-exported by `../field-context`, never from a package entry). The field a `<Field>` is rendering; `useField()` with no name reads it (Formily's field context).
|
|
110
|
+
*/
|
|
111
|
+
declare const FieldContext: react.Context<FieldBinding<any> | null>;
|
|
108
112
|
/**
|
|
109
113
|
* A `component` / `decorator` slot: the component, or `[Component, props]` (Formily style). On `<Field>` / `typed().Field`
|
|
110
114
|
* / `row.Field` / `<UI>`, `C` is inferred from the component and the props are checked against it (all optional: the field
|
|
@@ -218,30 +222,6 @@ declare function useField(name: string, options?: UseFieldOptions): FieldBinding
|
|
|
218
222
|
declare function useField<TScope>(name: FieldPath<TScope>, options?: UseFieldOptions<PathValue<TScope, FieldPath<TScope> & string>>): FieldBinding<PathValue<TScope, FieldPath<TScope> & string>>;
|
|
219
223
|
declare function useField<TScope, N extends FieldPath<TScope>>(name: N, options?: UseFieldOptions<PathValue<TScope, N & string>>): FieldBinding<PathValue<TScope, N & string>>;
|
|
220
224
|
|
|
221
|
-
/** HTML5 drag-and-drop props for one row / node: the same object serves as drag source and drop target. */
|
|
222
|
-
interface DragProps {
|
|
223
|
-
draggable: true;
|
|
224
|
-
onDragStart: (event: DragEvent) => void;
|
|
225
|
-
onDragOver: (event: DragEvent) => void;
|
|
226
|
-
onDrop: (event: DragEvent) => void;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Tree handle. `move(from, to)` uses final `pos` coordinates and refuses a move into a descendant (the result says why).
|
|
231
|
-
* `dragProps(pos)` is the HTML5 drag-and-drop props for the node at that coordinate (source and drop target);
|
|
232
|
-
* dropping node A on node B is `move(A, B)`, so cross-parent moves keep the node id and its field state.
|
|
233
|
-
* Subscribes to structure only.
|
|
234
|
-
*/
|
|
235
|
-
declare function useTreeField(name: string, opts?: {
|
|
236
|
-
childrenKey?: string;
|
|
237
|
-
rowKey?: string;
|
|
238
|
-
}): {
|
|
239
|
-
path: string;
|
|
240
|
-
value: any[];
|
|
241
|
-
move: (from: Pos, to: Pos) => MoveResult;
|
|
242
|
-
dragProps: (at: Pos) => DragProps;
|
|
243
|
-
};
|
|
244
|
-
|
|
245
225
|
/** Submit callbacks of `<Form>` (and the antd `Submit` button's own `onSubmit`). */
|
|
246
226
|
interface FormSubmitHandlers<T> {
|
|
247
227
|
/** Called with the submit values after validation passes. May be async; the submit waits for it. */
|
|
@@ -421,13 +401,29 @@ declare function RowScope({ path, index, itemKey, pos, children, }: {
|
|
|
421
401
|
pos?: Pos;
|
|
422
402
|
children?: ReactNode;
|
|
423
403
|
}): react.JSX.Element;
|
|
424
|
-
/**
|
|
404
|
+
/** Rendered tree node passed to `<TreeField>{(node) => …}</TreeField>`. */
|
|
405
|
+
interface TreeNodeRender {
|
|
406
|
+
path: string;
|
|
407
|
+
pos: Pos;
|
|
408
|
+
index: number;
|
|
409
|
+
key: string;
|
|
410
|
+
depth: number;
|
|
411
|
+
children: ReactNode;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* The owner of a tree path. Walks the tree recursively, wraps each node in a row scope keyed by the node id
|
|
415
|
+
* (`rowKey`, else `id`, else a stable object identity), and hands `children` the pre-rendered subtree as `node.children`
|
|
416
|
+
* (`null` on leaves) so the caller decides where to place it (`<li><NodeRow />{node.children && <ul>{node.children}</ul>}</li>`).
|
|
417
|
+
* Inside a node, relative `<Field name="name">` / `useField('name')`, {@link useRecord} and {@link useTreeNode} read
|
|
418
|
+
* that node, and field state / errors follow the node across moves.
|
|
419
|
+
* `<TreeField<Values> name="menu">` checks the name; `typed(form).TreeField` also types the node's fields.
|
|
420
|
+
*/
|
|
425
421
|
declare function TreeField<TScope = any>({ name, childrenKey, rowKey, children, }: {
|
|
426
422
|
name: ArrayPath<TScope>;
|
|
427
423
|
childrenKey?: string;
|
|
428
424
|
rowKey?: string;
|
|
429
|
-
children: (
|
|
430
|
-
}):
|
|
425
|
+
children: (node: TreeNodeRender) => ReactNode;
|
|
426
|
+
}): react.JSX.Element;
|
|
431
427
|
/**
|
|
432
428
|
* Render `children` with the current selector value. Same selectors and typing as {@link useWatch}:
|
|
433
429
|
* an unannotated `select={(d) => d.$canSubmit}` compiles (`d` is untyped); `typed(form).Watch` or
|
|
@@ -558,6 +554,7 @@ type PropsMapping<P = any, F = any> = Partial<Record<FieldPropKey | FieldStateKe
|
|
|
558
554
|
/** Control `onChange` arguments → the value stored on the field. Default: {@link valueFromEvent}. */
|
|
559
555
|
parse?: ParseFn<P, F>;
|
|
560
556
|
blurOn?: BlurOn;
|
|
557
|
+
readPretty?: ComponentType<any> | readonly [ComponentType<any>, Record<string, unknown>?];
|
|
561
558
|
};
|
|
562
559
|
/** `true` when `P` is `any` (not a concrete props type). `unknown` is not `any`. */
|
|
563
560
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
@@ -601,13 +598,12 @@ type PropsEnhancer = {
|
|
|
601
598
|
transforms: PropsTransform[];
|
|
602
599
|
/** Present when this mapping names a blur fallback, renames `onBlur`, or drops it on purpose. */
|
|
603
600
|
blur?: BlurFlag;
|
|
601
|
+
readPretty?: {
|
|
602
|
+
component: ComponentType<any>;
|
|
603
|
+
props?: Record<string, unknown>;
|
|
604
|
+
};
|
|
604
605
|
};
|
|
605
|
-
type
|
|
606
|
-
kind: 'readPretty';
|
|
607
|
-
component: ComponentType<any>;
|
|
608
|
-
props?: Record<string, unknown>;
|
|
609
|
-
};
|
|
610
|
-
type ConnectEnhancer = PropsEnhancer | ReadPrettyEnhancer;
|
|
606
|
+
type ConnectEnhancer = PropsEnhancer;
|
|
611
607
|
/** Props every connected control accepts besides its own. */
|
|
612
608
|
interface ConnectFieldProps {
|
|
613
609
|
/** Field name relative to the current scope. Omit it inside a `<Field>`, which supplies the field. */
|
|
@@ -626,27 +622,6 @@ type ComponentStatics<C> = Omit<C, keyof FunctionComponent<any> | keyof Componen
|
|
|
626
622
|
* `target.value` otherwise; anything else (a number, an array, `null`) is the value itself.
|
|
627
623
|
*/
|
|
628
624
|
declare function valueFromEvent(...args: any[]): unknown;
|
|
629
|
-
/**
|
|
630
|
-
* Map a field binding plus caller props onto a control's props. Pure; this is all `connect` does per render,
|
|
631
|
-
* exported so a hook user (`useField`) gets the identical mapping without a wrapper component:
|
|
632
|
-
*
|
|
633
|
-
* ```tsx
|
|
634
|
-
* const field = useField('email', { required: true })
|
|
635
|
-
* return <input {...mapFieldProps(field, { placeholder: 'Email' })} />
|
|
636
|
-
* ```
|
|
637
|
-
*
|
|
638
|
-
* - `value` → the field value (`format`, when set, turns it into the control's value after the other mapping);
|
|
639
|
-
* `onChange` → `field.onChange(parse(...args))` (default {@link valueFromEvent}), then the caller's handler
|
|
640
|
-
* with the original arguments; `onBlur` → `field.onBlur()`, then the caller's handler.
|
|
641
|
-
* - `disabled` / `readOnly` are OR-ed with the caller's prop. Several keys may target one prop (`readOnly: 'disabled'`).
|
|
642
|
-
* - `status` is not passed unless mapped (`{ status: 'status' }`): then `'error'` with errors, `'warning'` with only
|
|
643
|
-
* warnings; an explicit caller `status` wins. Ant Design controls that paint `status` opt in; others should not.
|
|
644
|
-
* - `options` (enum, tree nodes keep `children`) and `loading` are passed only when mapped; an explicit caller prop wins.
|
|
645
|
-
* - `blurOn` calls `field.onBlur()` from another prop and does not pass `onBlur` (see {@link BlurOn}).
|
|
646
|
-
* - `readPretty` without a `mapReadPretty` view is treated as `readOnly`.
|
|
647
|
-
* - `field.componentProps` (`fields` ← JSX ← `$componentProps`) are merged under `props`.
|
|
648
|
-
*/
|
|
649
|
-
declare function mapFieldProps(field: FieldBinding<any>, props: Record<string, any>, ...mappers: Array<PropsMapping | PropsTransform>): Record<string, any>;
|
|
650
625
|
/** A mapping that does not convert values. `format` / `parse` take the codec overload so `connect` can check them. */
|
|
651
626
|
type MapArg = Omit<PropsMapping, 'format' | 'parse'> | PropsTransform;
|
|
652
627
|
type BlurFrom<A extends readonly unknown[]> = A extends readonly [infer H, ...infer R] ? H extends {
|
|
@@ -676,7 +651,6 @@ type MapPropsResult<A extends readonly unknown[]> = [
|
|
|
676
651
|
* ```
|
|
677
652
|
*
|
|
678
653
|
* `blurOn` keeps `validateTrigger: 'onBlur'` alive when the control never calls `onBlur`.
|
|
679
|
-
* `mapBlur('onOpenChange')` is the same decision as its own enhancer.
|
|
680
654
|
* Put `format` / `parse` on the first object so `connect` can check them against the control.
|
|
681
655
|
*/
|
|
682
656
|
type CodecMapping<P, F> = PropsMapping<P, F> & ({
|
|
@@ -686,22 +660,6 @@ type CodecMapping<P, F> = PropsMapping<P, F> & ({
|
|
|
686
660
|
});
|
|
687
661
|
declare function mapProps<P, F>(mapping: CodecMapping<P, F>, ...rest: Array<PropsMapping<P, F> | PropsTransform>): CodecEnhancer<P, F>;
|
|
688
662
|
declare function mapProps<const A extends readonly MapArg[]>(...args: A): MapPropsResult<A>;
|
|
689
|
-
/**
|
|
690
|
-
* Blur fallback as its own enhancer (same as `mapProps({ blurOn })`).
|
|
691
|
-
* Use it when the control's props type has no `onBlur` — `connect` requires one of these, or `onBlur: false`.
|
|
692
|
-
*
|
|
693
|
-
* ```ts
|
|
694
|
-
* connect(LobeSelect, mapBlur('onOpenChange'), mapProps({ options: 'options' }))
|
|
695
|
-
* ```
|
|
696
|
-
*/
|
|
697
|
-
declare function mapBlur(on: BlurOn): PropsEnhancer & {
|
|
698
|
-
blur: BlurOn;
|
|
699
|
-
};
|
|
700
|
-
/**
|
|
701
|
-
* Render `component` instead of the control when the field pattern is `readPretty` (Formily `mapReadPretty`).
|
|
702
|
-
* It receives the caller props plus `value` and `options` (the enum).
|
|
703
|
-
*/
|
|
704
|
-
declare function mapReadPretty(component: ComponentType<any>, props?: Record<string, unknown>): ReadPrettyEnhancer;
|
|
705
663
|
/**
|
|
706
664
|
* Props of a component, from its call signature. `unknown` when the signature can't be read
|
|
707
665
|
* (then blur is not required — a typed `onBlur` is what the check can see).
|
|
@@ -717,7 +675,7 @@ type AnyBlur<E extends readonly unknown[]> = E extends readonly [infer H, ...inf
|
|
|
717
675
|
blur: BlurFlag;
|
|
718
676
|
} ? true : AnyBlur<R> : false;
|
|
719
677
|
type DemandBlur<C> = C & {
|
|
720
|
-
readonly __shikiConnectBlurFallback: 'This control has no onBlur, so onBlur validation would never run. Pass mapProps({ blurOn: "onChange" | "onOpenChange" | { prop, when? } })
|
|
678
|
+
readonly __shikiConnectBlurFallback: 'This control has no onBlur, so onBlur validation would never run. Pass mapProps({ blurOn: "onChange" | "onOpenChange" | { prop, when? } }) or mapProps({ onBlur: false }) to opt out.';
|
|
721
679
|
};
|
|
722
680
|
type BlurTarget<C, E extends readonly unknown[]> = HasOnBlurProp<C> extends true ? C : AnyBlur<E> extends true ? C : DemandBlur<C>;
|
|
723
681
|
type ValueOfProps<C> = C extends ComponentType<infer P> ? (P extends {
|
|
@@ -744,7 +702,7 @@ type NoCodec<E> = E extends {
|
|
|
744
702
|
* (so `$componentProps.placeholder = …` in a reaction reaches the control).
|
|
745
703
|
*
|
|
746
704
|
* A control whose props type has no `onBlur` must say where blur validation goes
|
|
747
|
-
* (`mapProps({ blurOn })` /
|
|
705
|
+
* (`mapProps({ blurOn })` / `mapProps({ onBlur: false })`). Otherwise `validateTrigger: 'onBlur'`
|
|
748
706
|
* would never run and TypeScript would not complain. `blurOn: 'onOpenChange'` treats a popup close (`false`) as blur;
|
|
749
707
|
* `blurOn: 'onChange'` blurs after every change.
|
|
750
708
|
*
|
|
@@ -805,6 +763,14 @@ type UseFormArg<T, F> = Omit<UseFormOptions<T>, 'fields'> & {
|
|
|
805
763
|
};
|
|
806
764
|
declare function useForm<T = any, TSubmit = DefaultSubmit, const F extends FieldsInput<T> = {}>(options?: UseFormArg<T, F>): FormInstance<T, ResolveSubmit<T, TSubmit, F>>;
|
|
807
765
|
|
|
766
|
+
/** HTML5 drag-and-drop props for one row / node: the same object serves as drag source and drop target. */
|
|
767
|
+
interface DragProps {
|
|
768
|
+
draggable: true;
|
|
769
|
+
onDragStart: (event: DragEvent) => void;
|
|
770
|
+
onDragOver: (event: DragEvent) => void;
|
|
771
|
+
onDrop: (event: DragEvent) => void;
|
|
772
|
+
}
|
|
773
|
+
|
|
808
774
|
/** One rendered row. `key` is the row id, or a stable identity when the row has none. */
|
|
809
775
|
interface ArrayKey {
|
|
810
776
|
key: string;
|
|
@@ -947,6 +913,8 @@ interface UIProps<C extends ComponentType<any> = ComponentType<any>, D extends C
|
|
|
947
913
|
/** Rendered inside `component` (or alone), or a render prop `(ui) => …`. */
|
|
948
914
|
children?: ReactNode | ((ui: UiBinding) => ReactNode);
|
|
949
915
|
}
|
|
916
|
+
/** Internal: the `<UI>` whose decorator is rendering (`FormItem` reads `title` / `description` from it). */
|
|
917
|
+
declare const UiNodeContext: react.Context<UiBinding | null>;
|
|
950
918
|
/** Internal: the surrounding `<UI>`, or `null`. */
|
|
951
919
|
declare function useUiNodeOrNull(): UiBinding | null;
|
|
952
920
|
/**
|
|
@@ -976,7 +944,7 @@ declare function useRecord<TRow = any>(): TRow;
|
|
|
976
944
|
* The tree node this component renders in: `path`, `pos`, `index` (last segment of `pos`), the reactive `record`,
|
|
977
945
|
* plus `move(from, to)` and `dragProps(pos)` — the same node operations the tree handle gives, bound to the tree the
|
|
978
946
|
* node belongs to (found by registering with the nearest tree, like `useArray()` does for arrays).
|
|
979
|
-
*
|
|
947
|
+
* Render inside `<TreeField>` (which wraps each node in its row scope).
|
|
980
948
|
* Throws outside a node.
|
|
981
949
|
*/
|
|
982
950
|
declare function useTreeNode<TNode = any>(): {
|
|
@@ -1019,6 +987,11 @@ declare class FieldGroupStore implements FieldGroupHandle {
|
|
|
1019
987
|
add(path: string): () => void;
|
|
1020
988
|
private changed;
|
|
1021
989
|
}
|
|
990
|
+
/** Internal: `add(path)` registers into the nearest group and every group around it. */
|
|
991
|
+
interface GroupRegistrar {
|
|
992
|
+
add(path: string): () => void;
|
|
993
|
+
}
|
|
994
|
+
declare const FieldGroupContext: react.Context<GroupRegistrar | null>;
|
|
1022
995
|
/** Create a group handle that lives as long as the component (pass it to {@link FieldGroup}). */
|
|
1023
996
|
declare function useFieldGroup(): FieldGroupHandle;
|
|
1024
997
|
/**
|
|
@@ -1071,4 +1044,4 @@ declare function useFormMessage(): <K extends FormMessageKey>(key: K, ...params:
|
|
|
1071
1044
|
declare function useWatch<T>(): <S>(select: (d: Draft<T>) => S) => S;
|
|
1072
1045
|
declare function useWatch<T = any, S = unknown>(select: (d: Draft<T>) => S): S;
|
|
1073
1046
|
|
|
1074
|
-
export {
|
|
1047
|
+
export { useArray as $, type ArrayContainerSlot as A, type BlurFlag as B, type CheckedFieldProps as C, type DragProps as D, type FormDomProps as E, type FormSubmitHandlers as F, type FormProps as G, type PropsTransform as H, type RegisteredComponentSlot as I, type RegisteredDecoratorSlot as J, type RegisteredSlot as K, type ScopeValue as L, TreeField as M, UI as N, ObjectField as O, type PropsMapping as P, type UIProps as Q, type ResetState as R, type SubmitState as S, type TreeNodeRender as T, type UseFieldOptions as U, type UiBinding as V, type UseResetOptions as W, type UseSubmitOptions as X, Watch as Y, connect as Z, mapProps as _, type FieldProps as a, useArrayErrors as a0, useArrayField as a1, useField as a2, useFieldGroup as a3, useFieldGroupErrors as a4, useForm as a5, useFormContext as a6, useFormMessage as a7, useIndex as a8, useRecord as a9, useReset as aa, useSubmit as ab, useTreeNode as ac, useWatch as ad, ArrayContext as ae, ArrayScope as af, FieldContext as ag, FieldGroupContext as ah, FieldGroupStore as ai, FormContext as aj, type PropsEnhancer as ak, RowScope as al, RowWrapContext as am, ScopeContext as an, UiNodeContext as ao, useArrayAt as ap, useFieldGroupRegistration as aq, useGroupsErrors as ar, useRequiredForm as as, useScope as at, useUiNodeOrNull as au, valueFromEvent as av, type ArrayKey as b, type FieldBinding as c, type ArrayHandle as d, type UseFormOptions as e, type ArrayErrors as f, ArrayField as g, type ArrayScopeValue as h, type BlurOn as i, type ClickEvent as j, type ComponentStatics as k, type ConnectEnhancer as l, type ConnectFieldProps as m, type ConnectedComponent as n, Field as o, type FieldComponents as p, type FieldDecorators as q, FieldGroup as r, type FieldGroupHandle as s, FieldKit as t, type FieldKitDecorator as u, type FieldKitSpec as v, type FieldPropKey as w, type FieldSlot as x, type FieldStateKey as y, Form as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikiform/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Headless React bindings for ShikiForm. Re-exports @shikiform/core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@shikiform/core": "0.
|
|
28
|
+
"@shikiform/core": "0.2.0",
|
|
29
29
|
"@tanstack/react-virtual": "^3.13.12"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|