@gridui/form 4.1.1 → 4.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/README.md CHANGED
@@ -3,10 +3,20 @@
3
3
  Core family. Public API: `ActionForm`, `ActionFormProps`, `Field`, `FieldGrid`, `FieldGridProps`, `FieldNote`, `FieldNoteProps`, `FieldProps`, `Fieldset`, `FieldsetProps`, `ListFieldControl`, `ListFieldControlProps`, `ListFieldProps`, `SearchForm`, `SearchFormProps`, `fieldClass`, `focusInvalidControl`, `runFormAction`, `useFormReset`, `useListField`.
4
4
 
5
5
  Import components from `@gridui/form` and load `@gridui/form/styles.css` after Theme.
6
- Load styles for any composed dependency used by this family. Applications own routes, labels, state persistence, and branding.
6
+ Applications own routes, labels, state persistence, and branding.
7
7
 
8
8
  See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/component-ownership.md) and [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-core/form/.changeset/history).
9
9
 
10
+ ## Styles
11
+
12
+ Load Theme once. Use `@gridui/form/styled` for automatic component CSS in
13
+ CSS-aware bundlers, or keep the CSS-free root import and load `@gridui/form/styles.css`.
14
+ Both entries expose the same root API. The standalone stylesheet includes component
15
+ dependency styles; Theme/reset remain separate. See the
16
+ [integration guide](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/usage/integration.md)
17
+ for static HTML loading, SSR limits, and avoiding duplicate CSS.
18
+
19
+
10
20
  ## Form controls
11
21
 
12
22
  Read [Fields and native controls](docs/guides/fields.md).
package/dist/index.js CHANGED
@@ -74,7 +74,7 @@ import { cva as cva3 } from "class-variance-authority";
74
74
  var fieldNoteStyles = cva3(cn3(
75
75
  "gridui-field-note",
76
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"
77
+ "gridui-u-form--data-[invalid='true']:text-status-danger-text"
78
78
  ));
79
79
 
80
80
  // src/field-note/field-note.tsx
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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-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"],
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-status-danger-text\",\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
5
  "mappings": ";AAOO,IAAM,gBAAgB,OACzB,QACA,YACgB;AAChB,MAAI;AACA,UAAM,OAAO;AAAA,EACjB,SAAS,OAAO;AACZ,QAAI,SAAS;AACT,cAAQ,KAAK;AAAA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AAO,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;;;AC3EA,SAAS,aAAa;AASf,IAAM,WAAW,CAAC,UAA2B,CAAC,MAAM;AACvD,QAAM,cAAc,MAAM;AAC1B,QAAM,EAAE,KAAK,aAAa,UAAU,OAAO,cAAc,OAAO,QAAQ,MAAM,IAAI;AAClF,QAAM,gBAAgB,GAAG,EAAE;AAC3B,QAAM,UAAU,GAAG,EAAE;AACrB,QAAM,cAAc;AAAA,IAChB,GAAG,oBAAI,IAAI;AAAA,MACP,GAAI,QAAQ,kBAAkB,GAAG,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
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
  }
package/dist/styled.js ADDED
@@ -0,0 +1,2 @@
1
+ import "./styles.local.css";
2
+ export * from "./index.js";
package/dist/styles.css CHANGED
@@ -60,6 +60,7 @@
60
60
  }
61
61
  .gridui-u-form--type-supporting {
62
62
  font: var(--gridui-type-supporting);
63
+ font-family: var(--gridui-font-body);
63
64
  letter-spacing: normal;
64
65
  }
65
66
  .gridui-u-form--wrap-anywhere {
@@ -68,8 +69,8 @@
68
69
  .gridui-u-form--text-muted {
69
70
  color: var(--gridui-muted);
70
71
  }
71
- .gridui-u-form--data-\[invalid\=\'true\'\]\:text-danger-foreground[data-invalid='true'] {
72
- color: var(--gridui-danger-foreground);
72
+ .gridui-u-form--data-\[invalid\=\'true\'\]\:text-status-danger-text[data-invalid='true'] {
73
+ color: var(--gridui-status-danger-text);
73
74
  }
74
75
  :is(.gridui-u-form--\*\:data-\[span\=\'full\'\]\:col-span-full > *)[data-span='full'] {
75
76
  grid-column: 1 / -1;
@@ -0,0 +1,101 @@
1
+ /*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
2
+ @layer properties;
3
+ @layer theme, base, components, utilities;
4
+ @layer theme {
5
+ :root, :host {
6
+ --spacing: 0.25rem;
7
+ }
8
+ }
9
+ @layer utilities {
10
+ .gridui-u-form--sr-only {
11
+ position: absolute;
12
+ width: 1px;
13
+ height: 1px;
14
+ padding: 0;
15
+ margin: -1px;
16
+ overflow: hidden;
17
+ clip-path: inset(50%);
18
+ white-space: nowrap;
19
+ border-width: 0;
20
+ }
21
+ .gridui-u-form--m-0 {
22
+ margin: 0px;
23
+ }
24
+ .gridui-u-form--flex {
25
+ display: flex;
26
+ }
27
+ .gridui-u-form--grid {
28
+ display: grid;
29
+ }
30
+ .gridui-u-form--min-w-0 {
31
+ min-width: 0px;
32
+ }
33
+ .gridui-u-form--flex-1 {
34
+ flex: 1;
35
+ }
36
+ .gridui-u-form--basis-48 {
37
+ flex-basis: calc(var(--spacing) * 48);
38
+ }
39
+ .gridui-u-form--grid-cols-2 {
40
+ grid-template-columns: repeat(2, minmax(0, 1fr));
41
+ }
42
+ .gridui-u-form--flex-wrap {
43
+ flex-wrap: wrap;
44
+ }
45
+ .gridui-u-form--items-end {
46
+ align-items: flex-end;
47
+ }
48
+ .gridui-u-form--gap-gridui-8 {
49
+ gap: var(--gridui-space-8);
50
+ }
51
+ .gridui-u-form--gap-gridui-16 {
52
+ gap: var(--gridui-space-16);
53
+ }
54
+ .gridui-u-form--border-0 {
55
+ border-style: var(--tw-border-style);
56
+ border-width: 0px;
57
+ }
58
+ .gridui-u-form--p-0 {
59
+ padding: 0px;
60
+ }
61
+ .gridui-u-form--type-supporting {
62
+ font: var(--gridui-type-supporting);
63
+ font-family: var(--gridui-font-body);
64
+ letter-spacing: normal;
65
+ }
66
+ .gridui-u-form--wrap-anywhere {
67
+ overflow-wrap: anywhere;
68
+ }
69
+ .gridui-u-form--text-muted {
70
+ color: var(--gridui-muted);
71
+ }
72
+ .gridui-u-form--data-\[invalid\=\'true\'\]\:text-status-danger-text[data-invalid='true'] {
73
+ color: var(--gridui-status-danger-text);
74
+ }
75
+ :is(.gridui-u-form--\*\:data-\[span\=\'full\'\]\:col-span-full > *)[data-span='full'] {
76
+ grid-column: 1 / -1;
77
+ }
78
+ .gridui-u-form--\[\&\>legend\]\:mb-gridui-24 > legend {
79
+ margin-bottom: var(--gridui-space-24);
80
+ }
81
+ .gridui-u-form--\[\&\>legend\]\:p-0 > legend {
82
+ padding: 0px;
83
+ }
84
+ @media (max-width:24rem) {
85
+ .gridui-u-form--\[\@media\(max-width\:24rem\)\]\:grid-cols-\[1fr\] {
86
+ grid-template-columns: 1fr;
87
+ }
88
+ }
89
+ }
90
+ @property --tw-border-style {
91
+ syntax: "*";
92
+ inherits: false;
93
+ initial-value: solid;
94
+ }
95
+ @layer properties {
96
+ @supports ((-webkit-hyphens: none) and (not (margin-trim: block))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
97
+ *, ::before, ::after, ::backdrop {
98
+ --tw-border-style: solid;
99
+ }
100
+ }
101
+ }
package/docs/catalog.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "name": "@gridui/form",
4
- "version": "4.1.1",
4
+ "version": "4.2.0",
5
5
  "category": "core",
6
6
  "description": "GridUI React form",
7
7
  "usage": "Read Fields and native controls.",
@@ -147,13 +147,16 @@
147
147
  "@gridui/theme/styles.css",
148
148
  "@gridui/form/styles.css"
149
149
  ],
150
+ "styledImport": "@gridui/form/styled",
150
151
  "examples": [
151
152
  "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/custom-controls.mdx",
152
153
  "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/field-associations.mdx",
153
154
  "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/filter-layouts.mdx",
155
+ "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/getting-started.mdx",
154
156
  "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/submission.mdx",
155
157
  "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/action-form.stories.tsx",
156
158
  "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/field-counter.stories.tsx",
159
+ "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/field.stories.tsx",
157
160
  "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/search-form.stories.tsx"
158
161
  ]
159
162
  }
@@ -1,7 +1,7 @@
1
1
  <!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
2
2
  # FieldNote
3
3
 
4
- Compose FieldNote with Input inside the same @gridui/form component family.
4
+ Compose FieldNote with ActionForm inside the same @gridui/form component family.
5
5
 
6
6
  Import from ``@gridui/form`` and load Theme before this family's stylesheet.
7
7
 
@@ -13,7 +13,7 @@ import "@gridui/form/styles.css";
13
13
 
14
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
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.
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
17
 
18
18
  ## API
19
19
 
@@ -1,7 +1,7 @@
1
1
  <!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
2
2
  # Field
3
3
 
4
- Compose Field with ActionForm inside the same @gridui/form component family.
4
+ Groups a control with its label and feedback. Use useField to connect rendered help and validation messages.
5
5
 
6
6
  Import from ``@gridui/form`` and load Theme before this family's stylesheet.
7
7
 
@@ -13,7 +13,7 @@ import "@gridui/form/styles.css";
13
13
 
14
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
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.
16
+ The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/form/stories/field.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
17
17
 
18
18
  ## API
19
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridui/form",
3
- "version": "4.1.1",
3
+ "version": "4.2.0",
4
4
  "description": "GridUI React form",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -10,14 +10,19 @@
10
10
  "docs"
11
11
  ],
12
12
  "sideEffects": [
13
- "**/*.css"
13
+ "**/*.css",
14
+ "./dist/styled.js"
14
15
  ],
15
16
  "exports": {
16
17
  ".": {
17
18
  "types": "./dist/index.d.ts",
18
19
  "import": "./dist/index.js"
19
20
  },
20
- "./styles.css": "./dist/styles.css"
21
+ "./styles.css": "./dist/styles.css",
22
+ "./styled": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/styled.js"
25
+ }
21
26
  },
22
27
  "publishConfig": {
23
28
  "access": "public"
@@ -28,21 +33,21 @@
28
33
  },
29
34
  "dependencies": {
30
35
  "@gridui/style-utils": "^4.0.0",
31
- "@gridui/theme": "^2.5.3",
36
+ "@gridui/theme": "^4.0.0",
32
37
  "class-variance-authority": "0.7.1"
33
38
  },
34
39
  "devDependencies": {
35
40
  "@gridui-internal/configuration": "0.0.0-internal",
36
- "@gridui/button": "4.1.0",
37
- "@gridui/input": "3.0.1",
41
+ "@gridui/button": "5.2.0",
42
+ "@gridui/input": "4.1.0",
38
43
  "@jest/globals": "30.5.2",
39
- "@storybook/react-vite": "10.6.6",
44
+ "@storybook/react-vite": "10.6.7",
40
45
  "@types/jest": "30.0.0",
41
46
  "@types/node": "26.6.6",
42
47
  "@types/react": "19.3.0",
43
48
  "@types/react-dom": "19.3.0",
44
49
  "jest": "30.5.2",
45
- "lucide-react": "1.70.0",
50
+ "lucide-react": "1.72.0",
46
51
  "react": "19.3.1",
47
52
  "react-dom": "19.3.1",
48
53
  "typescript": "6.0.3"
@@ -50,7 +55,6 @@
50
55
  "scripts": {
51
56
  "build": "node ../../scripts/compilation/package.ts",
52
57
  "compile": "tsc --project tsconfig.json",
53
- "test": "jest",
54
- "coverage": "jest --coverage"
58
+ "test": "jest"
55
59
  }
56
60
  }