@gridui/form 4.0.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,75 +9,20 @@ See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/
9
9
 
10
10
  ## Form controls
11
11
 
12
- `@gridui/form` owns field presentation, ActionForm, shared form state helpers, and FieldGrid/SearchForm arrangements. Input and Label belong to `@gridui/input`; Select and Combobox belong to `@gridui/select`; FilePicker belongs to `@gridui/file-picker`.
13
- Inputs preserve native form constraints, refs, labels, descriptions and invalid
14
- state; controls use 2.75rem standard or 2.25rem small sizing. Select accepts explicit
15
- options with managed keyboard navigation, focus, and native form integration. `Field`, `Fieldset`, and
16
- `FieldNote` own field grouping and error presentation. Input Label owns label/icon alignment.
17
- Fieldset keeps native disabled propagation and legend semantics.
18
-
19
- `FilePicker` owns the bordered surface, drag state, native input, and optional
20
- selection button. Callers supply `inputId`, `accept`, labels, hint, icon,
21
- `disabled`, and `onFile`; `drop` enables drag-and-drop. Omitting `action` retains
22
- the visible native input. `onFile` may return a promise. FilePicker owns its native input ref and clears
23
- selection after that callback settles, including errors and cancelled
24
- replacement. `onFileError(error)` receives synchronous reader exceptions and promise
25
- rejections after input cleanup. Without a handler, failures are logged to the
26
- console instead of becoming unhandled promise rejections. This permits repeated selection of the same file without DOM
27
- access in business controllers. Parsing and exported bytes remain application-owned. Optional
28
- `confirmSelection` requests native confirmation before replacing a pending file.
29
- Invalid borders use the danger color token; keyboard focus remains owned by the theme.
30
-
12
+ Read [Fields and native controls](docs/guides/fields.md).
31
13
 
32
14
  ## Form arrangements
33
15
 
34
- Import `FieldGrid` and `SearchForm` from `@gridui/form`.
35
- FieldGrid supplies full-width field spans, two columns above 24rem, and one
36
- column at or below 24rem. SearchForm aligns fields and submit actions.
37
- Use `<Field grow>` or `<FieldGrid grow>` for a flexible search region; other
38
- children retain their own sizing. Layout containers do not style arbitrary divs,
39
- labels, or icons. Use Input's `<Label icon={...}>` for label/icon alignment.
40
- Migration: add `grow` to former implicitly stretched SearchForm children and
41
- use Label instead of relying on FieldGrid to restyle native labels.
42
- Both forward native props and refs. The corresponding Core families own labels, constraints, invalid
43
- state, field notes, and native fieldset semantics; applications own values,
44
- validation, and submission actions. These local form arrangements do not own
45
- page frames or shared region seams.
46
-
16
+ Read [Form arrangements and search](docs/guides/search-form.md).
47
17
 
48
18
  ## Declarative action boundaries
49
19
 
50
- [`useAsyncAction` from `@gridui/button`](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/README.md#action-helpers)
51
- owns pending state and scheduling for caller-owned actions. `ActionForm` from
52
- `@gridui/form` prevents native form navigation and invokes its declared
53
- `onAction` unless disabled. Native form
54
- validation still runs before submission. `onActionError(error)` receives synchronous
55
- exceptions and promise rejections; without a handler, failures are logged to the
56
- console. Applications own visible feedback. `Input.onValueChange` exposes text
57
- values directly; native onChange props remain available for browser-level
58
- consumers.
59
-
20
+ Read [Action forms and asynchronous submission](docs/guides/action-form.md).
60
21
 
61
22
  ## Native form collaborators
62
23
 
63
- `useFormReset(elementRef, onReset, form?)` observes cancellable native resets using
64
- the element's current form owner, including forms mounted later, replacement
65
- forms, and controls moved between forms. Native controls supply their own form
66
- association; composite roots use the optional form ID or their closest form.
67
- The callback runs after native reset and cancellation handlers. Pending callbacks
68
- are discarded on unmount or reassociation. Value ownership remains with each
69
- control: selection families can request controlled resets, while ordinary
70
- controlled inputs leave reset policy to their caller.
24
+ Read [Native form state and reset](docs/guides/form-state.md).
71
25
 
72
- `focusInvalidControl(event, focus)` cancels the native invalid action for a hidden
73
- input/select mirror and invokes the visible-control focus callback only when that
74
- mirror is the form's first participating invalid control. Applications still own
75
- validation messages and invalid appearance.
26
+ [Component reference](docs/reference/README.md) contains focused API pages for each public component.
76
27
 
77
- `ListFieldControl` renders the hidden multiple select shared by MultiSelect and
78
- TagInput. It forwards `ref`, `name`, `form`, `required`, and `disabled`, accepts
79
- `value` and caller-owned option children, and routes native changes through
80
- `onValueChange` and invalid focus through `onInvalidFocus`. Pair it with
81
- `useListField` for controlled/local values and cancellable reset synchronization.
82
- Option membership, unavailable values, tag parsing, and visible focus targets
83
- remain caller-owned. Single-value SelectionForm remains Select-owned.
28
+ Use `useField` for native label/help/error associations and `FieldCounter` for localized native-length feedback. See [fields](docs/guides/fields.md#associations-and-counters).
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Form
4
+ * @namespace FieldCounter
5
+ * @description Field Counter
6
+ */
7
+ import { type FieldNoteProps } from "../field-note/field-note";
8
+ import type { FC, ReactNode } from "react";
9
+ export type FieldCounterProps = Omit<FieldNoteProps, "children" | "invalid"> & {
10
+ readonly value: string;
11
+ readonly maxLength?: number;
12
+ readonly formatCount: (count: number, maxLength: number | undefined) => ReactNode;
13
+ };
14
+ export declare const FieldCounter: FC<FieldCounterProps>;
package/dist/index.d.ts CHANGED
@@ -10,6 +10,8 @@ export { runFormAction } from "./action-form/run-action";
10
10
  export type { FieldProps } from "./field/field";
11
11
  export { Field } from "./field/field";
12
12
  export { fieldClass } from "./field/style";
13
+ export type { FieldCounterProps } from "./field-counter/field-counter";
14
+ export { FieldCounter } from "./field-counter/field-counter";
13
15
  export type { FieldGridProps } from "./field-grid/field-grid";
14
16
  export { FieldGrid } from "./field-grid/field-grid";
15
17
  export type { FieldNoteProps } from "./field-note/field-note";
@@ -24,3 +26,5 @@ export { focusInvalidControl } from "./shared/focus-invalid-control";
24
26
  export { useFormReset } from "./shared/use-form-reset";
25
27
  export type { ListFieldProps } from "./shared/use-list-field";
26
28
  export { useListField } from "./shared/use-list-field";
29
+ export type { UseFieldOptions } from "./use-field/use-field";
30
+ export { useField } from "./use-field/use-field";
package/dist/index.js CHANGED
@@ -68,54 +68,71 @@ var Field = (props) => {
68
68
  );
69
69
  };
70
70
 
71
- // src/field-grid/style.ts
71
+ // src/field-note/style.ts
72
72
  import { cn as cn3 } from "@gridui/style-utils";
73
73
  import { cva as cva3 } from "class-variance-authority";
74
- var fieldGridStyles = cva3(cn3(
75
- "gridui-field-grid",
76
- "gridui-u-form--grid gridui-u-form--grid-cols-2 gridui-u-form--gap-gridui-16",
77
- "gridui-u-form--*:data-[span='full']:col-span-full",
78
- "gridui-u-form--[@media(max-width:24rem)]:grid-cols-[1fr]"
74
+ var fieldNoteStyles = cva3(cn3(
75
+ "gridui-field-note",
76
+ "gridui-u-form--text-muted gridui-u-form--type-supporting gridui-u-form--wrap-anywhere",
77
+ "gridui-u-form--data-[invalid='true']:text-danger-foreground"
79
78
  ));
80
79
 
81
- // src/field-grid/field-grid.tsx
80
+ // src/field-note/field-note.tsx
82
81
  import { cn as cn4 } from "@gridui/style-utils";
83
82
  import { jsx as jsx3 } from "react/jsx-runtime";
84
- var FieldGrid = (props) => {
85
- const { grow = false, className, ...restProps } = props;
83
+ var FieldNote = (props) => {
84
+ const {
85
+ invalid = false,
86
+ className,
87
+ ...restProps
88
+ } = props;
86
89
  return /* @__PURE__ */ jsx3(
87
- "div",
90
+ "span",
88
91
  {
89
92
  ...restProps,
90
- className: cn4(fieldGridStyles(), fieldSizingStyles({ grow }), className)
93
+ className: cn4(fieldNoteStyles(), className),
94
+ "data-invalid": invalid
91
95
  }
92
96
  );
93
97
  };
94
98
 
95
- // src/field-note/style.ts
99
+ // src/field-counter/field-counter.tsx
100
+ import { jsx as jsx4 } from "react/jsx-runtime";
101
+ var FieldCounter = (props) => {
102
+ const { value, maxLength, formatCount, ...restProps } = props;
103
+ if (maxLength !== void 0 && (!Number.isSafeInteger(maxLength) || maxLength < 0)) {
104
+ throw new RangeError("FieldCounter maxLength must be a nonnegative integer.");
105
+ }
106
+ return /* @__PURE__ */ jsx4(
107
+ FieldNote,
108
+ {
109
+ ...restProps,
110
+ invalid: maxLength !== void 0 && value.length > maxLength,
111
+ children: formatCount(value.length, maxLength)
112
+ }
113
+ );
114
+ };
115
+
116
+ // src/field-grid/style.ts
96
117
  import { cn as cn5 } from "@gridui/style-utils";
97
118
  import { cva as cva4 } from "class-variance-authority";
98
- var fieldNoteStyles = cva4(cn5(
99
- "gridui-field-note",
100
- "gridui-u-form--text-muted gridui-u-form--type-supporting gridui-u-form--wrap-anywhere",
101
- "gridui-u-form--data-[invalid='true']:text-danger-foreground"
119
+ var fieldGridStyles = cva4(cn5(
120
+ "gridui-field-grid",
121
+ "gridui-u-form--grid gridui-u-form--grid-cols-2 gridui-u-form--gap-gridui-16",
122
+ "gridui-u-form--*:data-[span='full']:col-span-full",
123
+ "gridui-u-form--[@media(max-width:24rem)]:grid-cols-[1fr]"
102
124
  ));
103
125
 
104
- // src/field-note/field-note.tsx
126
+ // src/field-grid/field-grid.tsx
105
127
  import { cn as cn6 } from "@gridui/style-utils";
106
- import { jsx as jsx4 } from "react/jsx-runtime";
107
- var FieldNote = (props) => {
108
- const {
109
- invalid = false,
110
- className,
111
- ...restProps
112
- } = props;
113
- return /* @__PURE__ */ jsx4(
114
- "span",
128
+ import { jsx as jsx5 } from "react/jsx-runtime";
129
+ var FieldGrid = (props) => {
130
+ const { grow = false, className, ...restProps } = props;
131
+ return /* @__PURE__ */ jsx5(
132
+ "div",
115
133
  {
116
134
  ...restProps,
117
- className: cn6(fieldNoteStyles(), className),
118
- "data-invalid": invalid
135
+ className: cn6(fieldGridStyles(), fieldSizingStyles({ grow }), className)
119
136
  }
120
137
  );
121
138
  };
@@ -131,10 +148,10 @@ var fieldsetStyles = cva5(cn7(
131
148
 
132
149
  // src/fieldset/fieldset.tsx
133
150
  import { cn as cn8 } from "@gridui/style-utils";
134
- import { jsx as jsx5 } from "react/jsx-runtime";
151
+ import { jsx as jsx6 } from "react/jsx-runtime";
135
152
  var Fieldset = (props) => {
136
153
  const { className, ...restProps } = props;
137
- return /* @__PURE__ */ jsx5(
154
+ return /* @__PURE__ */ jsx6(
138
155
  "fieldset",
139
156
  {
140
157
  ...restProps,
@@ -157,10 +174,10 @@ var focusInvalidControl = (event, focus) => {
157
174
  };
158
175
 
159
176
  // src/list-field-control/list-field-control.tsx
160
- import { jsx as jsx6 } from "react/jsx-runtime";
177
+ import { jsx as jsx7 } from "react/jsx-runtime";
161
178
  var ListFieldControl = (props) => {
162
179
  const { onValueChange, onInvalidFocus, ...restProps } = props;
163
- return /* @__PURE__ */ jsx6(
180
+ return /* @__PURE__ */ jsx7(
164
181
  "select",
165
182
  {
166
183
  ...restProps,
@@ -190,10 +207,10 @@ var searchFormStyles = cva6(cn9(
190
207
 
191
208
  // src/search-form/search-form.tsx
192
209
  import { cn as cn10 } from "@gridui/style-utils";
193
- import { jsx as jsx7 } from "react/jsx-runtime";
210
+ import { jsx as jsx8 } from "react/jsx-runtime";
194
211
  var SearchForm = (props) => {
195
212
  const { className, ...restProps } = props;
196
- return /* @__PURE__ */ jsx7(
213
+ return /* @__PURE__ */ jsx8(
197
214
  "form",
198
215
  {
199
216
  ...restProps,
@@ -314,9 +331,39 @@ var useListField = (props, onReset) => {
314
331
  available
315
332
  };
316
333
  };
334
+
335
+ // src/use-field/use-field.ts
336
+ import { useId } from "react";
337
+ var useField = (options = {}) => {
338
+ const generatedId = useId();
339
+ const { id = generatedId, invalid = false, description = false, error = false } = options;
340
+ const descriptionId = `${id}-description`;
341
+ const errorId = `${id}-error`;
342
+ const describedBy = [
343
+ .../* @__PURE__ */ new Set([
344
+ ...options["aria-describedby"]?.split(/\s+/).filter(Boolean) ?? [],
345
+ ...description ? [descriptionId] : [],
346
+ ...invalid && error ? [errorId] : []
347
+ ])
348
+ ].join(" ") || void 0;
349
+ return {
350
+ controlProps: {
351
+ id,
352
+ "aria-invalid": invalid,
353
+ "aria-describedby": describedBy
354
+ },
355
+ labelProps: { htmlFor: id },
356
+ descriptionProps: { id: descriptionId },
357
+ errorProps: {
358
+ id: errorId,
359
+ invalid
360
+ }
361
+ };
362
+ };
317
363
  export {
318
364
  ActionForm,
319
365
  Field,
366
+ FieldCounter,
320
367
  FieldGrid,
321
368
  FieldNote,
322
369
  Fieldset,
@@ -325,6 +372,7 @@ export {
325
372
  fieldClass,
326
373
  focusInvalidControl,
327
374
  runFormAction,
375
+ useField,
328
376
  useFormReset,
329
377
  useListField
330
378
  };
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/action-form/run-action.ts", "../src/action-form/action-form.tsx", "../src/shared/field-sizing.ts", "../src/field/style.ts", "../src/field/field.tsx", "../src/field-grid/style.ts", "../src/field-grid/field-grid.tsx", "../src/field-note/style.ts", "../src/field-note/field-note.tsx", "../src/fieldset/style.ts", "../src/fieldset/fieldset.tsx", "../src/shared/focus-invalid-control.ts", "../src/list-field-control/list-field-control.tsx", "../src/search-form/style.ts", "../src/search-form/search-form.tsx", "../src/shared/use-form-reset.ts", "../src/shared/use-list-field.ts"],
4
- "sourcesContent": ["/**\n * @author WMXPY\n * @package Form\n * @namespace ActionForm\n * @description Run Action\n */\n\nexport const runFormAction = async (\n action: () => void | Promise<void>,\n onError?: (error: unknown) => void,\n): Promise<void> => {\n try {\n await action();\n } catch (error) {\n if (onError) {\n onError(error);\n } else {\n console.error(error);\n }\n }\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace ActionForm\n * @description Action Form\n */\n\nimport { runFormAction } from \"./run-action\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ActionFormProps = Omit<ComponentPropsWithRef<\"form\">, \"onSubmit\"> & {\n readonly onAction: () => void | Promise<void>;\n readonly onActionError?: (error: unknown) => void;\n readonly disabled?: boolean;\n};\n\nexport const ActionForm: FC<ActionFormProps> = (props: ActionFormProps) => {\n const {\n onAction,\n onActionError,\n disabled = false,\n ...restProps\n } = props;\n return (<form\n {...restProps}\n onSubmit={(event) => {\n event.preventDefault();\n if (!disabled) {\n void runFormAction(onAction, onActionError);\n }\n }}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Field Sizing\n */\n\nimport { cva } from \"class-variance-authority\";\nimport type { ComponentPropsWithRef } from \"react\";\n\nexport type FieldSizingOptions = ComponentPropsWithRef<\"div\"> & {\n readonly grow?: boolean;\n};\n\nexport const fieldSizingStyles = cva(\"\", {\n variants: {\n grow: { true: \"gridui-u-form--flex-1 gridui-u-form--basis-48\" },\n },\n});\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Field\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldStyles = cva(cn(\n \"gridui-field\",\n \"gridui-u-form--grid gridui-u-form--min-w-0 gridui-u-form--gap-gridui-8\",\n));\n\nexport const fieldClass = (className?: string): string => {\n return cn(fieldStyles(), className);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Field\n * @description Field\n */\n\nimport { type FieldSizingOptions, fieldSizingStyles } from \"../shared/field-sizing\";\nimport { fieldClass } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type FieldProps = FieldSizingOptions & {\n readonly span?: \"auto\" | \"full\";\n};\n\nexport const Field: FC<FieldProps> = (props: FieldProps) => {\n const { span = \"auto\", grow = false, className, ...restProps } = props;\n return (<div\n {...restProps}\n className={cn(fieldClass(), fieldSizingStyles({ grow }), className)}\n data-span={span}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldGrid\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldGridStyles = cva(cn(\n \"gridui-field-grid\",\n \"gridui-u-form--grid gridui-u-form--grid-cols-2 gridui-u-form--gap-gridui-16\",\n \"gridui-u-form--*:data-[span='full']:col-span-full\",\n \"gridui-u-form--[@media(max-width:24rem)]:grid-cols-[1fr]\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldGrid\n * @description Field Grid\n */\n\nimport { type FieldSizingOptions, fieldSizingStyles } from \"../shared/field-sizing\";\nimport { fieldGridStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type FieldGridProps = FieldSizingOptions;\n\nexport const FieldGrid: FC<FieldGridProps> = (props: FieldGridProps) => {\n const { grow = false, className, ...restProps } = props;\n return (<div\n {...restProps}\n className={cn(fieldGridStyles(), fieldSizingStyles({ grow }), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldNote\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldNoteStyles = cva(cn(\n \"gridui-field-note\",\n \"gridui-u-form--text-muted gridui-u-form--type-supporting gridui-u-form--wrap-anywhere\",\n \"gridui-u-form--data-[invalid='true']:text-danger-foreground\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldNote\n * @description Field Note\n */\n\nimport { fieldNoteStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type FieldNoteProps = ComponentPropsWithRef<\"span\"> & {\n readonly invalid?: boolean;\n};\n\nexport const FieldNote: FC<FieldNoteProps> = (props: FieldNoteProps) => {\n const {\n invalid = false,\n className,\n ...restProps\n } = props;\n return (<span\n {...restProps}\n className={cn(fieldNoteStyles(), className)}\n data-invalid={invalid}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Fieldset\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldsetStyles = cva(cn(\n \"gridui-fieldset\",\n \"gridui-u-form--min-w-0 gridui-u-form--m-0 gridui-u-form--p-0 gridui-u-form--border-0\",\n \"gridui-u-form--[&>legend]:mb-gridui-24 gridui-u-form--[&>legend]:p-0\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Fieldset\n * @description Fieldset\n */\n\nimport { fieldsetStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type FieldsetProps = ComponentPropsWithRef<\"fieldset\">;\n\nexport const Fieldset: FC<FieldsetProps> = (props: FieldsetProps) => {\n const { className, ...restProps } = props;\n return (<fieldset\n {...restProps}\n className={cn(fieldsetStyles(), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Focus Invalid Control\n */\n\nimport type { SyntheticEvent } from \"react\";\n\nexport const focusInvalidControl = (\n event: SyntheticEvent<HTMLInputElement | HTMLSelectElement>,\n focus: () => void,\n): void => {\n event.preventDefault();\n const control = event.currentTarget;\n const owner = control.form;\n const firstInvalid = owner && Array.from(owner.elements).find(element => {\n return \"willValidate\" in element && element.willValidate && element.matches(\":invalid\");\n });\n if (!owner || firstInvalid === control) {\n focus();\n }\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace ListFieldControl\n * @description List Field Control\n */\n\nimport { focusInvalidControl } from \"../shared/focus-invalid-control\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ListFieldControlProps = Pick<ComponentPropsWithRef<\"select\">, \"name\" | \"form\" | \"disabled\" | \"required\" | \"ref\" | \"children\"> & {\n readonly value: readonly string[];\n readonly onValueChange?: (value: string[]) => void;\n readonly onInvalidFocus: () => void;\n};\n\nexport const ListFieldControl: FC<ListFieldControlProps> = (props: ListFieldControlProps) => {\n const { onValueChange, onInvalidFocus, ...restProps } = props;\n return (<select\n {...restProps}\n multiple\n className=\"gridui-u-form--sr-only\"\n aria-hidden=\"true\"\n tabIndex={-1}\n onChange={event => {\n onValueChange?.(Array.from(event.currentTarget.selectedOptions, option => {\n return option.value;\n }));\n }}\n onInvalid={event => {\n focusInvalidControl(event, onInvalidFocus);\n }}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace SearchForm\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const searchFormStyles = cva(cn(\n \"gridui-search-form\",\n \"gridui-u-form--flex gridui-u-form--flex-wrap gridui-u-form--items-end gridui-u-form--gap-gridui-16\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace SearchForm\n * @description Search Form\n */\n\nimport { searchFormStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type SearchFormProps = ComponentPropsWithRef<\"form\">;\n\nexport const SearchForm: FC<SearchFormProps> = (props: SearchFormProps) => {\n const { className, ...restProps } = props;\n return (<form\n {...restProps}\n className={cn(searchFormStyles(), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Use Form Reset\n */\n\nimport { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\n\ntype ResetElement = HTMLElement & {\n readonly form?: HTMLFormElement | null;\n};\n\nconst formOwner = (element: ResetElement, form?: string): Element | null => {\n if (element.form !== undefined) {\n return element.form;\n }\n return form === undefined ? element.closest(\"form\") : element.ownerDocument.getElementById(form);\n};\n\nexport const useFormReset = (element: RefObject<ResetElement | null>, onReset: () => void, form?: string): void => {\n const latest = useRef(onReset);\n useLayoutEffect(() => {\n latest.current = onReset;\n });\n useEffect(() => {\n const document = element.current?.ownerDocument;\n if (!document) {\n return;\n }\n const pending = new Set<ReturnType<typeof setTimeout>>();\n const reset = (event: Event): void => {\n const control = element.current;\n if (!control || event.target !== formOwner(control, form)) {\n return;\n }\n // Native reset runs after dispatch; React bubbling handlers can cancel it.\n const timer = setTimeout(() => {\n pending.delete(timer);\n const current = element.current;\n if (!event.defaultPrevented && current && event.target === formOwner(current, form)) {\n latest.current();\n }\n }, 0);\n pending.add(timer);\n };\n document.addEventListener(\"reset\", reset, true);\n return () => {\n document.removeEventListener(\"reset\", reset, true);\n pending.forEach(timer => {\n clearTimeout(timer);\n });\n };\n }, [\n element,\n form,\n ]);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Use List Field\n */\n\nimport { useFormReset } from \"./use-form-reset\";\nimport { useLayoutEffect, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\n\nexport type ListFieldProps = {\n readonly value?: readonly string[] | undefined;\n readonly defaultValue?: readonly string[] | undefined;\n readonly onValueChange?: ((value: string[]) => void) | undefined;\n readonly disabled?: boolean | undefined;\n readonly readOnly?: boolean | undefined;\n readonly form?: string | undefined;\n};\n\nexport const useListField = (props: ListFieldProps, onReset: () => void) => {\n const { value, defaultValue = [], onValueChange, disabled, readOnly, form } = props;\n const [\n local,\n setLocal,\n ] = useState(() => {\n return [...new Set(defaultValue)];\n });\n const selected = [...new Set(value ?? local)];\n const initial = useRef(selected);\n const native = useRef<HTMLSelectElement>(null);\n const control = useRef<HTMLElement>(null);\n const available = () => {\n return !disabled && !readOnly && !control.current?.matches(\":disabled\");\n };\n const update = (next: readonly string[]) => {\n const unique = [...new Set(next)];\n if (selected.length === unique.length && selected.every((entry, index) => {\n return entry === unique[index];\n })) {\n return;\n }\n if (value === undefined) {\n setLocal(unique);\n }\n onValueChange?.(unique);\n };\n const latest = useRef({\n update,\n onReset,\n selected,\n });\n useLayoutEffect(() => {\n latest.current = {\n update,\n onReset,\n selected,\n };\n });\n useFormReset(native, () => {\n flushSync(() => {\n latest.current.update(initial.current);\n latest.current.onReset();\n });\n if (native.current) {\n for (const option of native.current.options) {\n option.selected = latest.current.selected.includes(option.value);\n }\n }\n }, form);\n const change = (next: readonly string[]) => {\n if (available()) {\n update(next);\n }\n };\n return {\n selected,\n native,\n control,\n change,\n available,\n };\n};\n"],
5
- "mappings": ";AAOO,IAAM,gBAAgB,OACzB,QACA,YACgB;AAChB,MAAI;AACA,UAAM,OAAO;AAAA,EACjB,SAAS,OAAO;AACZ,QAAI,SAAS;AACT,cAAQ,KAAK;AAAA,IACjB,OAAO;AACH,cAAQ,MAAM,KAAK;AAAA,IACvB;AAAA,EACJ;AACJ;;;ACGY;AAPL,IAAM,aAAkC,CAAC,UAA2B;AACvE,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,GAAG;AA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SAA4B;AACxC,UAAM,SAAS,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;AAChC,QAAI,SAAS,WAAW,OAAO,UAAU,SAAS,MAAM,CAAC,OAAO,UAAU;AACtE,aAAO,UAAU,OAAO,KAAK;AAAA,IACjC,CAAC,GAAG;AACA;AAAA,IACJ;AACA,QAAI,UAAU,QAAW;AACrB,eAAS,MAAM;AAAA,IACnB;AACA,oBAAgB,MAAM;AAAA,EAC1B;AACA,QAAM,SAASA,QAAO;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACJ,CAAC;AACD,EAAAD,iBAAgB,MAAM;AAClB,WAAO,UAAU;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAAA,EACJ,CAAC;AACD,eAAa,QAAQ,MAAM;AACvB,cAAU,MAAM;AACZ,aAAO,QAAQ,OAAO,QAAQ,OAAO;AACrC,aAAO,QAAQ,QAAQ;AAAA,IAC3B,CAAC;AACD,QAAI,OAAO,SAAS;AAChB,iBAAW,UAAU,OAAO,QAAQ,SAAS;AACzC,eAAO,WAAW,OAAO,QAAQ,SAAS,SAAS,OAAO,KAAK;AAAA,MACnE;AAAA,IACJ;AAAA,EACJ,GAAG,IAAI;AACP,QAAM,SAAS,CAAC,SAA4B;AACxC,QAAI,UAAU,GAAG;AACb,aAAO,IAAI;AAAA,IACf;AAAA,EACJ;AACA,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;",
6
- "names": ["cva", "cn", "jsx", "cn", "cva", "cn", "jsx", "cn", "cva", "cn", "jsx", "cn", "cva", "cn", "jsx", "jsx", "cn", "cva", "cn", "jsx", "useLayoutEffect", "useRef"]
3
+ "sources": ["../src/action-form/run-action.ts", "../src/action-form/action-form.tsx", "../src/shared/field-sizing.ts", "../src/field/style.ts", "../src/field/field.tsx", "../src/field-note/style.ts", "../src/field-note/field-note.tsx", "../src/field-counter/field-counter.tsx", "../src/field-grid/style.ts", "../src/field-grid/field-grid.tsx", "../src/fieldset/style.ts", "../src/fieldset/fieldset.tsx", "../src/shared/focus-invalid-control.ts", "../src/list-field-control/list-field-control.tsx", "../src/search-form/style.ts", "../src/search-form/search-form.tsx", "../src/shared/use-form-reset.ts", "../src/shared/use-list-field.ts", "../src/use-field/use-field.ts"],
4
+ "sourcesContent": ["/**\n * @author WMXPY\n * @package Form\n * @namespace ActionForm\n * @description Run Action\n */\n\nexport const runFormAction = async (\n action: () => void | Promise<void>,\n onError?: (error: unknown) => void,\n): Promise<void> => {\n try {\n await action();\n } catch (error) {\n if (onError) {\n onError(error);\n } else {\n console.error(error);\n }\n }\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace ActionForm\n * @description Action Form\n */\n\nimport { runFormAction } from \"./run-action\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ActionFormProps = Omit<ComponentPropsWithRef<\"form\">, \"onSubmit\"> & {\n readonly onAction: () => void | Promise<void>;\n readonly onActionError?: (error: unknown) => void;\n readonly disabled?: boolean;\n};\n\nexport const ActionForm: FC<ActionFormProps> = (props: ActionFormProps) => {\n const {\n onAction,\n onActionError,\n disabled = false,\n ...restProps\n } = props;\n return (<form\n {...restProps}\n onSubmit={(event) => {\n event.preventDefault();\n if (!disabled) {\n void runFormAction(onAction, onActionError);\n }\n }}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Field Sizing\n */\n\nimport { cva } from \"class-variance-authority\";\nimport type { ComponentPropsWithRef } from \"react\";\n\nexport type FieldSizingOptions = ComponentPropsWithRef<\"div\"> & {\n readonly grow?: boolean;\n};\n\nexport const fieldSizingStyles = cva(\"\", {\n variants: {\n grow: { true: \"gridui-u-form--flex-1 gridui-u-form--basis-48\" },\n },\n});\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Field\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldStyles = cva(cn(\n \"gridui-field\",\n \"gridui-u-form--grid gridui-u-form--min-w-0 gridui-u-form--gap-gridui-8\",\n));\n\nexport const fieldClass = (className?: string): string => {\n return cn(fieldStyles(), className);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Field\n * @description Field\n */\n\nimport { type FieldSizingOptions, fieldSizingStyles } from \"../shared/field-sizing\";\nimport { fieldClass } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type FieldProps = FieldSizingOptions & {\n readonly span?: \"auto\" | \"full\";\n};\n\nexport const Field: FC<FieldProps> = (props: FieldProps) => {\n const { span = \"auto\", grow = false, className, ...restProps } = props;\n return (<div\n {...restProps}\n className={cn(fieldClass(), fieldSizingStyles({ grow }), className)}\n data-span={span}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldNote\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldNoteStyles = cva(cn(\n \"gridui-field-note\",\n \"gridui-u-form--text-muted gridui-u-form--type-supporting gridui-u-form--wrap-anywhere\",\n \"gridui-u-form--data-[invalid='true']:text-danger-foreground\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldNote\n * @description Field Note\n */\n\nimport { fieldNoteStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type FieldNoteProps = ComponentPropsWithRef<\"span\"> & {\n readonly invalid?: boolean;\n};\n\nexport const FieldNote: FC<FieldNoteProps> = (props: FieldNoteProps) => {\n const {\n invalid = false,\n className,\n ...restProps\n } = props;\n return (<span\n {...restProps}\n className={cn(fieldNoteStyles(), className)}\n data-invalid={invalid}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldCounter\n * @description Field Counter\n */\n\nimport { FieldNote, type FieldNoteProps } from \"../field-note/field-note\";\nimport type { FC, ReactNode } from \"react\";\n\nexport type FieldCounterProps = Omit<FieldNoteProps, \"children\" | \"invalid\"> & {\n readonly value: string;\n readonly maxLength?: number;\n readonly formatCount: (count: number, maxLength: number | undefined) => ReactNode;\n};\nexport const FieldCounter: FC<FieldCounterProps> = (props: FieldCounterProps) => {\n const { value, maxLength, formatCount, ...restProps } = props;\n if (maxLength !== undefined && (!Number.isSafeInteger(maxLength) || maxLength < 0)) {\n throw new RangeError(\"FieldCounter maxLength must be a nonnegative integer.\");\n }\n return (<FieldNote\n {...restProps}\n invalid={maxLength !== undefined && value.length > maxLength}\n >\n {formatCount(value.length, maxLength)}\n </FieldNote>);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldGrid\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldGridStyles = cva(cn(\n \"gridui-field-grid\",\n \"gridui-u-form--grid gridui-u-form--grid-cols-2 gridui-u-form--gap-gridui-16\",\n \"gridui-u-form--*:data-[span='full']:col-span-full\",\n \"gridui-u-form--[@media(max-width:24rem)]:grid-cols-[1fr]\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace FieldGrid\n * @description Field Grid\n */\n\nimport { type FieldSizingOptions, fieldSizingStyles } from \"../shared/field-sizing\";\nimport { fieldGridStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type FieldGridProps = FieldSizingOptions;\n\nexport const FieldGrid: FC<FieldGridProps> = (props: FieldGridProps) => {\n const { grow = false, className, ...restProps } = props;\n return (<div\n {...restProps}\n className={cn(fieldGridStyles(), fieldSizingStyles({ grow }), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Fieldset\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const fieldsetStyles = cva(cn(\n \"gridui-fieldset\",\n \"gridui-u-form--min-w-0 gridui-u-form--m-0 gridui-u-form--p-0 gridui-u-form--border-0\",\n \"gridui-u-form--[&>legend]:mb-gridui-24 gridui-u-form--[&>legend]:p-0\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Fieldset\n * @description Fieldset\n */\n\nimport { fieldsetStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type FieldsetProps = ComponentPropsWithRef<\"fieldset\">;\n\nexport const Fieldset: FC<FieldsetProps> = (props: FieldsetProps) => {\n const { className, ...restProps } = props;\n return (<fieldset\n {...restProps}\n className={cn(fieldsetStyles(), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Focus Invalid Control\n */\n\nimport type { SyntheticEvent } from \"react\";\n\nexport const focusInvalidControl = (\n event: SyntheticEvent<HTMLInputElement | HTMLSelectElement>,\n focus: () => void,\n): void => {\n event.preventDefault();\n const control = event.currentTarget;\n const owner = control.form;\n const firstInvalid = owner && Array.from(owner.elements).find(element => {\n return \"willValidate\" in element && element.willValidate && element.matches(\":invalid\");\n });\n if (!owner || firstInvalid === control) {\n focus();\n }\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace ListFieldControl\n * @description List Field Control\n */\n\nimport { focusInvalidControl } from \"../shared/focus-invalid-control\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ListFieldControlProps = Pick<ComponentPropsWithRef<\"select\">, \"name\" | \"form\" | \"disabled\" | \"required\" | \"ref\" | \"children\"> & {\n readonly value: readonly string[];\n readonly onValueChange?: (value: string[]) => void;\n readonly onInvalidFocus: () => void;\n};\n\nexport const ListFieldControl: FC<ListFieldControlProps> = (props: ListFieldControlProps) => {\n const { onValueChange, onInvalidFocus, ...restProps } = props;\n return (<select\n {...restProps}\n multiple\n className=\"gridui-u-form--sr-only\"\n aria-hidden=\"true\"\n tabIndex={-1}\n onChange={event => {\n onValueChange?.(Array.from(event.currentTarget.selectedOptions, option => {\n return option.value;\n }));\n }}\n onInvalid={event => {\n focusInvalidControl(event, onInvalidFocus);\n }}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace SearchForm\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const searchFormStyles = cva(cn(\n \"gridui-search-form\",\n \"gridui-u-form--flex gridui-u-form--flex-wrap gridui-u-form--items-end gridui-u-form--gap-gridui-16\",\n));\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace SearchForm\n * @description Search Form\n */\n\nimport { searchFormStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type SearchFormProps = ComponentPropsWithRef<\"form\">;\n\nexport const SearchForm: FC<SearchFormProps> = (props: SearchFormProps) => {\n const { className, ...restProps } = props;\n return (<form\n {...restProps}\n className={cn(searchFormStyles(), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Use Form Reset\n */\n\nimport { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\n\ntype ResetElement = HTMLElement & {\n readonly form?: HTMLFormElement | null;\n};\n\nconst formOwner = (element: ResetElement, form?: string): Element | null => {\n if (element.form !== undefined) {\n return element.form;\n }\n return form === undefined ? element.closest(\"form\") : element.ownerDocument.getElementById(form);\n};\n\nexport const useFormReset = (element: RefObject<ResetElement | null>, onReset: () => void, form?: string): void => {\n const latest = useRef(onReset);\n useLayoutEffect(() => {\n latest.current = onReset;\n });\n useEffect(() => {\n const document = element.current?.ownerDocument;\n if (!document) {\n return;\n }\n const pending = new Set<ReturnType<typeof setTimeout>>();\n const reset = (event: Event): void => {\n const control = element.current;\n if (!control || event.target !== formOwner(control, form)) {\n return;\n }\n // Native reset runs after dispatch; React bubbling handlers can cancel it.\n const timer = setTimeout(() => {\n pending.delete(timer);\n const current = element.current;\n if (!event.defaultPrevented && current && event.target === formOwner(current, form)) {\n latest.current();\n }\n }, 0);\n pending.add(timer);\n };\n document.addEventListener(\"reset\", reset, true);\n return () => {\n document.removeEventListener(\"reset\", reset, true);\n pending.forEach(timer => {\n clearTimeout(timer);\n });\n };\n }, [\n element,\n form,\n ]);\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace Shared\n * @description Use List Field\n */\n\nimport { useFormReset } from \"./use-form-reset\";\nimport { useLayoutEffect, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\n\nexport type ListFieldProps = {\n readonly value?: readonly string[] | undefined;\n readonly defaultValue?: readonly string[] | undefined;\n readonly onValueChange?: ((value: string[]) => void) | undefined;\n readonly disabled?: boolean | undefined;\n readonly readOnly?: boolean | undefined;\n readonly form?: string | undefined;\n};\n\nexport const useListField = (props: ListFieldProps, onReset: () => void) => {\n const { value, defaultValue = [], onValueChange, disabled, readOnly, form } = props;\n const [\n local,\n setLocal,\n ] = useState(() => {\n return [...new Set(defaultValue)];\n });\n const selected = [...new Set(value ?? local)];\n const initial = useRef(selected);\n const native = useRef<HTMLSelectElement>(null);\n const control = useRef<HTMLElement>(null);\n const available = () => {\n return !disabled && !readOnly && !control.current?.matches(\":disabled\");\n };\n const update = (next: readonly string[]) => {\n const unique = [...new Set(next)];\n if (selected.length === unique.length && selected.every((entry, index) => {\n return entry === unique[index];\n })) {\n return;\n }\n if (value === undefined) {\n setLocal(unique);\n }\n onValueChange?.(unique);\n };\n const latest = useRef({\n update,\n onReset,\n selected,\n });\n useLayoutEffect(() => {\n latest.current = {\n update,\n onReset,\n selected,\n };\n });\n useFormReset(native, () => {\n flushSync(() => {\n latest.current.update(initial.current);\n latest.current.onReset();\n });\n if (native.current) {\n for (const option of native.current.options) {\n option.selected = latest.current.selected.includes(option.value);\n }\n }\n }, form);\n const change = (next: readonly string[]) => {\n if (available()) {\n update(next);\n }\n };\n return {\n selected,\n native,\n control,\n change,\n available,\n };\n};\n", "/**\n * @author WMXPY\n * @package Form\n * @namespace UseField\n * @description Use Field\n */\n\nimport { useId } from \"react\";\n\nexport type UseFieldOptions = {\n readonly id?: string | undefined;\n readonly invalid?: boolean | undefined;\n readonly description?: boolean | undefined;\n readonly error?: boolean | undefined;\n readonly \"aria-describedby\"?: string | undefined;\n};\nexport const useField = (options: UseFieldOptions = {}) => {\n const generatedId = useId();\n const { id = generatedId, invalid = false, description = false, error = false } = options;\n const descriptionId = `${id}-description`;\n const errorId = `${id}-error`;\n const describedBy = [\n ...new Set([\n ...(options[\"aria-describedby\"]?.split(/\\s+/).filter(Boolean) ?? []),\n ...(description ? [descriptionId] : []),\n ...(invalid && error ? [errorId] : []),\n ]),\n ].join(\" \") || undefined;\n return {\n controlProps: {\n id,\n \"aria-invalid\": invalid,\n \"aria-describedby\": describedBy,\n },\n labelProps: { htmlFor: id },\n descriptionProps: { id: descriptionId },\n errorProps: {\n id: errorId,\n invalid,\n },\n };\n};\n"],
5
+ "mappings": ";AAOO,IAAM,gBAAgB,OACzB,QACA,YACgB;AAChB,MAAI;AACA,UAAM,OAAO;AAAA,EACjB,SAAS,OAAO;AACZ,QAAI,SAAS;AACT,cAAQ,KAAK;AAAA,IACjB,OAAO;AACH,cAAQ,MAAM,KAAK;AAAA,IACvB;AAAA,EACJ;AACJ;;;ACGY;AAPL,IAAM,aAAkC,CAAC,UAA2B;AACvE,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,GAAG;AAAA,EACP,IAAI;AACJ,SAAQ;AAAA,IAAC;AAAA;AAAA,MACJ,GAAG;AAAA,MACJ,UAAU,CAAC,UAAU;AACjB,cAAM,eAAe;AACrB,YAAI,CAAC,UAAU;AACX,eAAK,cAAc,UAAU,aAAa;AAAA,QAC9C;AAAA,MACJ;AAAA;AAAA,EACJ;AACJ;;;ACzBA,SAAS,WAAW;AAOb,IAAM,oBAAoB,IAAI,IAAI;AAAA,EACrC,UAAU;AAAA,IACN,MAAM,EAAE,MAAM,gDAAgD;AAAA,EAClE;AACJ,CAAC;;;ACXD,SAAS,UAAU;AACnB,SAAS,OAAAA,YAAW;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AG,MAAM,KAAK,EAAE,OAAO,OAAO,KAAK,CAAC;AAAA,MAClE,GAAI,cAAc,CAAC,aAAa,IAAI,CAAC;AAAA,MACrC,GAAI,WAAW,QAAQ,CAAC,OAAO,IAAI,CAAC;AAAA,IACxC,CAAC;AAAA,EACL,EAAE,KAAK,GAAG,KAAK;AACf,SAAO;AAAA,IACH,cAAc;AAAA,MACV;AAAA,MACA,gBAAgB;AAAA,MAChB,oBAAoB;AAAA,IACxB;AAAA,IACA,YAAY,EAAE,SAAS,GAAG;AAAA,IAC1B,kBAAkB,EAAE,IAAI,cAAc;AAAA,IACtC,YAAY;AAAA,MACR,IAAI;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
6
+ "names": ["cva", "cn", "jsx", "cn", "cva", "cn", "jsx", "jsx", "cn", "cva", "cn", "jsx", "cn", "cva", "cn", "jsx", "jsx", "cn", "cva", "cn", "jsx", "useLayoutEffect", "useRef"]
7
7
  }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Form
4
+ * @namespace UseField
5
+ * @description Use Field
6
+ */
7
+ export type UseFieldOptions = {
8
+ readonly id?: string | undefined;
9
+ readonly invalid?: boolean | undefined;
10
+ readonly description?: boolean | undefined;
11
+ readonly error?: boolean | undefined;
12
+ readonly "aria-describedby"?: string | undefined;
13
+ };
14
+ export declare const useField: (options?: UseFieldOptions) => {
15
+ controlProps: {
16
+ id: string;
17
+ "aria-invalid": boolean;
18
+ "aria-describedby": string | undefined;
19
+ };
20
+ labelProps: {
21
+ htmlFor: string;
22
+ };
23
+ descriptionProps: {
24
+ id: string;
25
+ };
26
+ errorProps: {
27
+ id: string;
28
+ invalid: boolean;
29
+ };
30
+ };
package/docs/catalog.json CHANGED
@@ -1,12 +1,25 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "name": "@gridui/form",
4
- "version": "4.0.0",
4
+ "version": "4.1.1",
5
5
  "category": "core",
6
6
  "description": "GridUI React form",
7
- "usage": "`@gridui/form` owns field presentation, ActionForm, shared form state helpers, and FieldGrid/SearchForm arrangements. Input and Label belong to `@gridui/input`; Select and Combobox belong to `@gridui/select`; FilePicker belongs to `@gridui/file-picker`. Inputs preserve native form constraints, refs, labels, descriptions and invalid state; controls use 2.75rem standard or 2.25rem small sizing. Select accepts explicit options with managed keyboard navigation, focus, and native form integration. `Field`, `Fieldset`, and `FieldNote` own field grouping and error presentation. Input Label owns label/icon alignment. Fieldset keeps native disabled propagation and legend semantics.",
7
+ "usage": "Read Fields and native controls.",
8
8
  "documentation": [
9
- "README.md"
9
+ "README.md",
10
+ "docs/guides/action-form.md",
11
+ "docs/guides/fields.md",
12
+ "docs/guides/form-state.md",
13
+ "docs/guides/search-form.md",
14
+ "docs/reference/README.md",
15
+ "docs/reference/action-form.md",
16
+ "docs/reference/field-counter.md",
17
+ "docs/reference/field-grid.md",
18
+ "docs/reference/field-note.md",
19
+ "docs/reference/field.md",
20
+ "docs/reference/fieldset.md",
21
+ "docs/reference/list-field-control.md",
22
+ "docs/reference/search-form.md"
10
23
  ],
11
24
  "exports": [
12
25
  {
@@ -29,6 +42,16 @@
29
42
  "kind": "function",
30
43
  "importPath": "@gridui/form"
31
44
  },
45
+ {
46
+ "name": "FieldCounter",
47
+ "kind": "component",
48
+ "importPath": "@gridui/form"
49
+ },
50
+ {
51
+ "name": "FieldCounterProps",
52
+ "kind": "type",
53
+ "importPath": "@gridui/form"
54
+ },
32
55
  {
33
56
  "name": "FieldGrid",
34
57
  "kind": "component",
@@ -99,6 +122,16 @@
99
122
  "kind": "type",
100
123
  "importPath": "@gridui/form"
101
124
  },
125
+ {
126
+ "name": "useField",
127
+ "kind": "function",
128
+ "importPath": "@gridui/form"
129
+ },
130
+ {
131
+ "name": "UseFieldOptions",
132
+ "kind": "type",
133
+ "importPath": "@gridui/form"
134
+ },
102
135
  {
103
136
  "name": "useFormReset",
104
137
  "kind": "function",
@@ -115,7 +148,12 @@
115
148
  "@gridui/form/styles.css"
116
149
  ],
117
150
  "examples": [
151
+ "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/custom-controls.mdx",
152
+ "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/field-associations.mdx",
153
+ "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/filter-layouts.mdx",
154
+ "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/submission.mdx",
118
155
  "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/action-form.stories.tsx",
156
+ "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/field-counter.stories.tsx",
119
157
  "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/search-form.stories.tsx"
120
158
  ]
121
159
  }
@@ -0,0 +1,11 @@
1
+ # Action forms and asynchronous submission
2
+
3
+ [`useAsyncAction` from `@gridui/button`](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/README.md#action-helpers)
4
+ owns pending state and scheduling for caller-owned actions. `ActionForm` from
5
+ `@gridui/form` prevents native form navigation and invokes its declared
6
+ `onAction` unless disabled. Native form
7
+ validation still runs before submission. `onActionError(error)` receives synchronous
8
+ exceptions and promise rejections; without a handler, failures are logged to the
9
+ console. Applications own visible feedback. `Input.onValueChange` exposes text
10
+ values directly; native onChange props remain available for browser-level
11
+ consumers.
@@ -0,0 +1,35 @@
1
+ # Fields and native controls
2
+
3
+ `@gridui/form` owns field presentation, ActionForm, shared form state helpers, and FieldGrid/SearchForm arrangements. Input and Label belong to `@gridui/input`; Select and Combobox belong to `@gridui/select`; FilePicker belongs to `@gridui/file-picker`.
4
+ Inputs preserve native form constraints, refs, labels, descriptions and invalid
5
+ state; controls use 2.75rem standard or 2.25rem small sizing. Select accepts explicit
6
+ options with managed keyboard navigation, focus, and native form integration. `Field`, `Fieldset`, and
7
+ `FieldNote` own field grouping and error presentation. Input Label owns label/icon alignment.
8
+ Fieldset keeps native disabled propagation and legend semantics.
9
+
10
+ `FilePicker` owns the bordered surface, drag state, native input, and optional
11
+ selection button. Callers supply `inputId`, `accept`, labels, hint, icon,
12
+ `disabled`, and `onFile`; `drop` enables drag-and-drop. Omitting `action` retains
13
+ the visible native input. `onFile` may return a promise. FilePicker owns its native input ref and clears
14
+ selection after that callback settles, including errors and cancelled
15
+ replacement. `onFileError(error)` receives synchronous reader exceptions and promise
16
+ rejections after input cleanup. Without a handler, failures are logged to the
17
+ console instead of becoming unhandled promise rejections. This permits repeated selection of the same file without DOM
18
+ access in business controllers. Parsing and exported bytes remain application-owned. Optional
19
+ `confirmSelection` requests native confirmation before replacing a pending file.
20
+ Invalid borders use the danger color token; keyboard focus remains owned by the theme.
21
+
22
+ ## Associations and counters
23
+
24
+ `useField({ id, invalid, description, error, "aria-describedby" })` returns
25
+ `controlProps`, `labelProps`, `descriptionProps` and `errorProps`. Supply explicit
26
+ booleans only for help/error elements actually rendered. Error IDs participate
27
+ only while invalid. Existing external description IDs are retained and deduplicated.
28
+ The caller's id wins; otherwise React useId supplies a stable SSR identity.
29
+ Spread each result onto its corresponding control, Label or FieldNote. The hook
30
+ owns no validation, values, submission, touched state or error announcements.
31
+
32
+ `FieldCounter` receives value, optional maxLength and required localized
33
+ `formatCount(count, maxLength)`. It counts UTF-16 code units, matching native
34
+ maxLength, and marks externally supplied over-limit values. It never truncates
35
+ input or announces every keystroke. Connect its id through aria-describedby.
@@ -0,0 +1,23 @@
1
+ # Native form state and reset
2
+
3
+ `useFormReset(elementRef, onReset, form?)` observes cancellable native resets using
4
+ the element's current form owner, including forms mounted later, replacement
5
+ forms, and controls moved between forms. Native controls supply their own form
6
+ association; composite roots use the optional form ID or their closest form.
7
+ The callback runs after native reset and cancellation handlers. Pending callbacks
8
+ are discarded on unmount or reassociation. Value ownership remains with each
9
+ control: selection families can request controlled resets, while ordinary
10
+ controlled inputs leave reset policy to their caller.
11
+
12
+ `focusInvalidControl(event, focus)` cancels the native invalid action for a hidden
13
+ input/select mirror and invokes the visible-control focus callback only when that
14
+ mirror is the form's first participating invalid control. Applications still own
15
+ validation messages and invalid appearance.
16
+
17
+ `ListFieldControl` renders the hidden multiple select shared by MultiSelect and
18
+ TagInput. It forwards `ref`, `name`, `form`, `required`, and `disabled`, accepts
19
+ `value` and caller-owned option children, and routes native changes through
20
+ `onValueChange` and invalid focus through `onInvalidFocus`. Pair it with
21
+ `useListField` for controlled/local values and cancellable reset synchronization.
22
+ Option membership, unavailable values, tag parsing, and visible focus targets
23
+ remain caller-owned. Single-value SelectionForm remains Select-owned.
@@ -0,0 +1,14 @@
1
+ # Form arrangements and search
2
+
3
+ Import `FieldGrid` and `SearchForm` from `@gridui/form`.
4
+ FieldGrid supplies full-width field spans, two columns above 24rem, and one
5
+ column at or below 24rem. SearchForm aligns fields and submit actions.
6
+ Use `<Field grow>` or `<FieldGrid grow>` for a flexible search region; other
7
+ children retain their own sizing. Layout containers do not style arbitrary divs,
8
+ labels, or icons. Use Input's `<Label icon={...}>` for label/icon alignment.
9
+ Migration: add `grow` to former implicitly stretched SearchForm children and
10
+ use Label instead of relying on FieldGrid to restyle native labels.
11
+ Both forward native props and refs. The corresponding Core families own labels, constraints, invalid
12
+ state, field notes, and native fieldset semantics; applications own values,
13
+ validation, and submission actions. These local form arrangements do not own
14
+ page frames or shared region seams.
@@ -0,0 +1,11 @@
1
+ <!-- Generated by pnpm docs:storybook. -->
2
+ # Component reference
3
+
4
+ - [ActionForm](action-form.md)
5
+ - [Field](field.md)
6
+ - [FieldCounter](field-counter.md)
7
+ - [FieldGrid](field-grid.md)
8
+ - [FieldNote](field-note.md)
9
+ - [Fieldset](fieldset.md)
10
+ - [ListFieldControl](list-field-control.md)
11
+ - [SearchForm](search-form.md)
@@ -0,0 +1,71 @@
1
+ <!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
2
+ # ActionForm
3
+
4
+ Invokes an action after native form validation. Pair it with useAsyncAction for pending state and application-owned save feedback.
5
+
6
+ Import from ``@gridui/form`` and load Theme before this family's stylesheet.
7
+
8
+ ```tsx
9
+ import { ActionForm } from "@gridui/form";
10
+ import "@gridui/theme/styles.css";
11
+ import "@gridui/form/styles.css";
12
+ ```
13
+
14
+ Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/README.md) for shared behavior and stylesheet dependencies.
15
+
16
+ The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/action-form.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
17
+
18
+ ## API
19
+
20
+ The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
21
+
22
+ ### children
23
+
24
+ ``ReactNode`` · Optional
25
+
26
+ Content rendered inside the component.
27
+
28
+ ### onFocus
29
+
30
+ ``(event: FocusEvent<HTMLFormElement, Element>): void`` · Optional
31
+
32
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
33
+
34
+ ### onBlur
35
+
36
+ ``(event: FocusEvent<HTMLFormElement, Element>): void`` · Optional
37
+
38
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
39
+
40
+ ### onChange
41
+
42
+ ``(event: ChangeEvent<HTMLFormElement, Element>): void`` · Optional
43
+
44
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
45
+
46
+ ### onClick
47
+
48
+ ``(event: MouseEvent<HTMLFormElement, MouseEvent>): void`` · Optional
49
+
50
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
51
+
52
+ ### onAction
53
+
54
+ ``(): void | Promise<void>`` · Required
55
+
56
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
57
+
58
+ ### onActionError
59
+
60
+ ``(error: unknown): void`` · Optional
61
+
62
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
63
+
64
+ ### disabled
65
+
66
+ ``boolean | undefined`` · Optional
67
+
68
+ Default: ``false``
69
+
70
+ Prevents interaction when enabled.
71
+
@@ -0,0 +1,65 @@
1
+ <!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
2
+ # FieldCounter
3
+
4
+ Displays a caller-localized count using the same UTF-16 units as native maxLength. Associate it with a field as help text.
5
+
6
+ Import from ``@gridui/form`` and load Theme before this family's stylesheet.
7
+
8
+ ```tsx
9
+ import { FieldCounter } from "@gridui/form";
10
+ import "@gridui/theme/styles.css";
11
+ import "@gridui/form/styles.css";
12
+ ```
13
+
14
+ Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/README.md) for shared behavior and stylesheet dependencies.
15
+
16
+ The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/field-counter.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
17
+
18
+ ## API
19
+
20
+ The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
21
+
22
+ ### onFocus
23
+
24
+ ``(event: FocusEvent<HTMLSpanElement, Element>): void`` · Optional
25
+
26
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
27
+
28
+ ### onBlur
29
+
30
+ ``(event: FocusEvent<HTMLSpanElement, Element>): void`` · Optional
31
+
32
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
33
+
34
+ ### onChange
35
+
36
+ ``(event: ChangeEvent<HTMLSpanElement, Element>): void`` · Optional
37
+
38
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
39
+
40
+ ### onSubmit
41
+
42
+ ``(event: SubmitEvent<HTMLSpanElement>): void`` · Optional
43
+
44
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
45
+
46
+ ### onClick
47
+
48
+ ``(event: MouseEvent<HTMLSpanElement, MouseEvent>): void`` · Optional
49
+
50
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
51
+
52
+ ### value
53
+
54
+ ``string`` · Required
55
+
56
+ Controlled value. Pair with the corresponding change callback.
57
+
58
+ ### maxLength
59
+
60
+ ``number | undefined`` · Optional
61
+
62
+ ### formatCount
63
+
64
+ ``(count: number, maxLength: number | undefined) => ReactNode`` · Required
65
+
@@ -0,0 +1,61 @@
1
+ <!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
2
+ # FieldGrid
3
+
4
+ Public FieldGrid component from @gridui/form. See the package guide for its composition contract.
5
+
6
+ Import from ``@gridui/form`` and load Theme before this family's stylesheet.
7
+
8
+ ```tsx
9
+ import { FieldGrid } from "@gridui/form";
10
+ import "@gridui/theme/styles.css";
11
+ import "@gridui/form/styles.css";
12
+ ```
13
+
14
+ Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/README.md) for shared behavior and stylesheet dependencies.
15
+
16
+ ## API
17
+
18
+ The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
19
+
20
+ ### children
21
+
22
+ ``ReactNode`` · Optional
23
+
24
+ Content rendered inside the component.
25
+
26
+ ### onFocus
27
+
28
+ ``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
29
+
30
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
31
+
32
+ ### onBlur
33
+
34
+ ``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
35
+
36
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
37
+
38
+ ### onChange
39
+
40
+ ``(event: ChangeEvent<HTMLDivElement, Element>): void`` · Optional
41
+
42
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
43
+
44
+ ### onSubmit
45
+
46
+ ``(event: SubmitEvent<HTMLDivElement>): void`` · Optional
47
+
48
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
49
+
50
+ ### onClick
51
+
52
+ ``(event: MouseEvent<HTMLDivElement, MouseEvent>): void`` · Optional
53
+
54
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
55
+
56
+ ### grow
57
+
58
+ ``boolean | undefined`` · Optional
59
+
60
+ Default: ``false``
61
+
@@ -0,0 +1,63 @@
1
+ <!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
2
+ # FieldNote
3
+
4
+ Compose FieldNote with Input inside the same @gridui/form component family.
5
+
6
+ Import from ``@gridui/form`` and load Theme before this family's stylesheet.
7
+
8
+ ```tsx
9
+ import { FieldNote } from "@gridui/form";
10
+ import "@gridui/theme/styles.css";
11
+ import "@gridui/form/styles.css";
12
+ ```
13
+
14
+ Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/README.md) for shared behavior and stylesheet dependencies.
15
+
16
+ The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/storybook/scenarios/controls/input.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
17
+
18
+ ## API
19
+
20
+ The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
21
+
22
+ ### children
23
+
24
+ ``ReactNode`` · Optional
25
+
26
+ Content rendered inside the component.
27
+
28
+ ### onFocus
29
+
30
+ ``(event: FocusEvent<HTMLSpanElement, Element>): void`` · Optional
31
+
32
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
33
+
34
+ ### onBlur
35
+
36
+ ``(event: FocusEvent<HTMLSpanElement, Element>): void`` · Optional
37
+
38
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
39
+
40
+ ### onChange
41
+
42
+ ``(event: ChangeEvent<HTMLSpanElement, Element>): void`` · Optional
43
+
44
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
45
+
46
+ ### onSubmit
47
+
48
+ ``(event: SubmitEvent<HTMLSpanElement>): void`` · Optional
49
+
50
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
51
+
52
+ ### onClick
53
+
54
+ ``(event: MouseEvent<HTMLSpanElement, MouseEvent>): void`` · Optional
55
+
56
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
57
+
58
+ ### invalid
59
+
60
+ ``boolean | undefined`` · Optional
61
+
62
+ Default: ``false``
63
+
@@ -0,0 +1,69 @@
1
+ <!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
2
+ # Field
3
+
4
+ Compose Field with ActionForm inside the same @gridui/form component family.
5
+
6
+ Import from ``@gridui/form`` and load Theme before this family's stylesheet.
7
+
8
+ ```tsx
9
+ import { Field } from "@gridui/form";
10
+ import "@gridui/theme/styles.css";
11
+ import "@gridui/form/styles.css";
12
+ ```
13
+
14
+ Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/README.md) for shared behavior and stylesheet dependencies.
15
+
16
+ The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/action-form.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
17
+
18
+ ## API
19
+
20
+ The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
21
+
22
+ ### children
23
+
24
+ ``ReactNode`` · Optional
25
+
26
+ Content rendered inside the component.
27
+
28
+ ### onFocus
29
+
30
+ ``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
31
+
32
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
33
+
34
+ ### onBlur
35
+
36
+ ``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
37
+
38
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
39
+
40
+ ### onChange
41
+
42
+ ``(event: ChangeEvent<HTMLDivElement, Element>): void`` · Optional
43
+
44
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
45
+
46
+ ### onSubmit
47
+
48
+ ``(event: SubmitEvent<HTMLDivElement>): void`` · Optional
49
+
50
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
51
+
52
+ ### onClick
53
+
54
+ ``(event: MouseEvent<HTMLDivElement, MouseEvent>): void`` · Optional
55
+
56
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
57
+
58
+ ### grow
59
+
60
+ ``boolean | undefined`` · Optional
61
+
62
+ Default: ``false``
63
+
64
+ ### span
65
+
66
+ ``"auto" | "full" | undefined`` · Optional
67
+
68
+ Default: ``"auto"``
69
+
@@ -0,0 +1,57 @@
1
+ <!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
2
+ # Fieldset
3
+
4
+ Compose Fieldset with ActionForm inside the same @gridui/form component family.
5
+
6
+ Import from ``@gridui/form`` and load Theme before this family's stylesheet.
7
+
8
+ ```tsx
9
+ import { Fieldset } from "@gridui/form";
10
+ import "@gridui/theme/styles.css";
11
+ import "@gridui/form/styles.css";
12
+ ```
13
+
14
+ Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/README.md) for shared behavior and stylesheet dependencies.
15
+
16
+ The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/action-form.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
17
+
18
+ ## API
19
+
20
+ The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
21
+
22
+ ### children
23
+
24
+ ``ReactNode`` · Optional
25
+
26
+ Content rendered inside the component.
27
+
28
+ ### onFocus
29
+
30
+ ``(event: FocusEvent<HTMLFieldSetElement, Element>): void`` · Optional
31
+
32
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
33
+
34
+ ### onBlur
35
+
36
+ ``(event: FocusEvent<HTMLFieldSetElement, Element>): void`` · Optional
37
+
38
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
39
+
40
+ ### onChange
41
+
42
+ ``(event: ChangeEvent<HTMLFieldSetElement, Element>): void`` · Optional
43
+
44
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
45
+
46
+ ### onSubmit
47
+
48
+ ``(event: SubmitEvent<HTMLFieldSetElement>): void`` · Optional
49
+
50
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
51
+
52
+ ### onClick
53
+
54
+ ``(event: MouseEvent<HTMLFieldSetElement, MouseEvent>): void`` · Optional
55
+
56
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
57
+
@@ -0,0 +1,43 @@
1
+ <!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
2
+ # ListFieldControl
3
+
4
+ Public ListFieldControl component from @gridui/form. See the package guide for its composition contract.
5
+
6
+ Import from ``@gridui/form`` and load Theme before this family's stylesheet.
7
+
8
+ ```tsx
9
+ import { ListFieldControl } from "@gridui/form";
10
+ import "@gridui/theme/styles.css";
11
+ import "@gridui/form/styles.css";
12
+ ```
13
+
14
+ Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/README.md) for shared behavior and stylesheet dependencies.
15
+
16
+ ## API
17
+
18
+ The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
19
+
20
+ ### children
21
+
22
+ ``ReactNode`` · Optional
23
+
24
+ Content rendered inside the component.
25
+
26
+ ### value
27
+
28
+ ``readonly string[]`` · Required
29
+
30
+ Controlled value. Pair with the corresponding change callback.
31
+
32
+ ### onValueChange
33
+
34
+ ``(value: string[]): void`` · Optional
35
+
36
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
37
+
38
+ ### onInvalidFocus
39
+
40
+ ``(): void`` · Required
41
+
42
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
43
+
@@ -0,0 +1,57 @@
1
+ <!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
2
+ # SearchForm
3
+
4
+ Combines a search field with submission behavior. Use it when users explicitly submit a query to search a collection.
5
+
6
+ Import from ``@gridui/form`` and load Theme before this family's stylesheet.
7
+
8
+ ```tsx
9
+ import { SearchForm } from "@gridui/form";
10
+ import "@gridui/theme/styles.css";
11
+ import "@gridui/form/styles.css";
12
+ ```
13
+
14
+ Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/README.md) for shared behavior and stylesheet dependencies.
15
+
16
+ The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/search-form.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
17
+
18
+ ## API
19
+
20
+ The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
21
+
22
+ ### children
23
+
24
+ ``ReactNode`` · Optional
25
+
26
+ Content rendered inside the component.
27
+
28
+ ### onFocus
29
+
30
+ ``(event: FocusEvent<HTMLFormElement, Element>): void`` · Optional
31
+
32
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
33
+
34
+ ### onBlur
35
+
36
+ ``(event: FocusEvent<HTMLFormElement, Element>): void`` · Optional
37
+
38
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
39
+
40
+ ### onChange
41
+
42
+ ``(event: ChangeEvent<HTMLFormElement, Element>): void`` · Optional
43
+
44
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
45
+
46
+ ### onSubmit
47
+
48
+ ``(event: SubmitEvent<HTMLFormElement>): void`` · Optional
49
+
50
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
51
+
52
+ ### onClick
53
+
54
+ ``(event: MouseEvent<HTMLFormElement, MouseEvent>): void`` · Optional
55
+
56
+ Called when the corresponding interaction occurs; inspect the arguments in Actions.
57
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridui/form",
3
- "version": "4.0.0",
3
+ "version": "4.1.1",
4
4
  "description": "GridUI React form",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -27,14 +27,14 @@
27
27
  "react-dom": "^19.2.0"
28
28
  },
29
29
  "dependencies": {
30
- "@gridui/style-utils": "^3.0.0",
30
+ "@gridui/style-utils": "^4.0.0",
31
31
  "@gridui/theme": "^2.5.3",
32
32
  "class-variance-authority": "0.7.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@gridui-internal/configuration": "0.0.0-internal",
36
- "@gridui/button": "4.0.0",
37
- "@gridui/input": "2.0.0",
36
+ "@gridui/button": "4.1.0",
37
+ "@gridui/input": "3.0.1",
38
38
  "@jest/globals": "30.5.2",
39
39
  "@storybook/react-vite": "10.6.6",
40
40
  "@types/jest": "30.0.0",