@uniform-ts/core 0.0.6 → 0.0.8
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 +20 -17
- package/dist/field-KKjnXn-d.d.mts +748 -0
- package/dist/field-KKjnXn-d.d.ts +748 -0
- package/dist/index.d.mts +53 -721
- package/dist/index.d.ts +53 -721
- package/dist/index.js +108 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +109 -51
- package/dist/index.mjs.map +1 -1
- package/dist/locales/en.d.mts +8 -0
- package/dist/locales/en.d.ts +8 -0
- package/dist/locales/en.js +24 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/en.mjs +22 -0
- package/dist/locales/en.mjs.map +1 -0
- package/dist/locales/es.d.mts +8 -0
- package/dist/locales/es.d.ts +8 -0
- package/dist/locales/es.js +24 -0
- package/dist/locales/es.js.map +1 -0
- package/dist/locales/es.mjs +22 -0
- package/dist/locales/es.mjs.map +1 -0
- package/dist/locales/he.d.mts +8 -0
- package/dist/locales/he.d.ts +8 -0
- package/dist/locales/he.js +24 -0
- package/dist/locales/he.js.map +1 -0
- package/dist/locales/he.mjs +22 -0
- package/dist/locales/he.mjs.map +1 -0
- package/package.json +20 -6
package/README.md
CHANGED
|
@@ -45,7 +45,9 @@ UniForm introspects the schema, renders appropriate inputs, validates with Zod,
|
|
|
45
45
|
|
|
46
46
|
**`createAutoForm(defaults)`** — factory that bakes in your design system defaults (components, classNames, fieldWrapper) once, so you don't repeat them on every form.
|
|
47
47
|
|
|
48
|
-
**`
|
|
48
|
+
**`useArrayField(fieldName)`** — a React hook for external array controls (toolbars, section headers, sticky footers) inside the `<AutoForm>` tree. It returns `append/remove/move/...` from `useFieldArray` plus `rowCount`, `canAdd`, and `atMin` derived from the array's `minItems`/`maxItems`.
|
|
49
|
+
|
|
50
|
+
**`components`** — a registry mapping Zod types (`string`, `number`, `boolean`, etc.) to your own input components. Pass a component directly on a field via `fields` for one-off overrides. For custom components, type field values precisely with `FieldProps<Value>` (for example, `FieldProps<number>` for a rating widget).
|
|
49
51
|
|
|
50
52
|
**`fields`** — per-field overrides using dot-notated paths. Control labels, descriptions, ordering, sections, conditions, and custom components without touching the schema.
|
|
51
53
|
|
|
@@ -64,31 +66,32 @@ UniForm introspects the schema, renders appropriate inputs, validates with Zod,
|
|
|
64
66
|
|
|
65
67
|
## Core Props
|
|
66
68
|
|
|
67
|
-
| Prop | Type | Description
|
|
68
|
-
| --------------- | ---------------------------------------- |
|
|
69
|
-
| `form` | `UniForm<TSchema>` | Schema + onChange handlers from `createForm()`
|
|
70
|
-
| `onSubmit` | `(values) => void \| Promise<void>` | Called with typed values after successful validation
|
|
71
|
-
| `defaultValues` | `Partial<...>` or `() => Promise<...>` | Initial values; async function shows `loadingFallback`
|
|
72
|
-
| `components` | `ComponentRegistry` | Map Zod types to your input components
|
|
73
|
-
| `fields` | `Record<string, FieldOverride>` | Per-field label, description, order, section, condition
|
|
74
|
-
| `fieldWrapper` | `React.ComponentType<FieldWrapperProps>` | Custom wrapper around every scalar field
|
|
75
|
-
| `layout` | `LayoutSlots` | Replace form/section/object/array wrappers, submit button, array rows
|
|
76
|
-
| `classNames` | `FormClassNames` | CSS classes for form, fields, labels, errors, fieldset/legend wrappers
|
|
77
|
-
| `ref` | `React.Ref<AutoFormHandle>` | Imperative `reset`, `submit`, `setValues`, `getValues`
|
|
78
|
-
| `persistKey` | `string` | Auto-save form state to `localStorage` under this key
|
|
79
|
-
| `labels` | `FormLabels` | Override built-in UI strings for i18n
|
|
69
|
+
| Prop | Type | Description |
|
|
70
|
+
| --------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
71
|
+
| `form` | `UniForm<TSchema>` | Schema + onChange handlers from `createForm()` |
|
|
72
|
+
| `onSubmit` | `(values) => void \| Promise<void>` | Called with typed values after successful validation |
|
|
73
|
+
| `defaultValues` | `Partial<...>` or `() => Promise<...>` | Initial values; async function shows `loadingFallback` |
|
|
74
|
+
| `components` | `ComponentRegistry` | Map Zod types to your input components |
|
|
75
|
+
| `fields` | `Record<string, FieldOverride>` | Per-field label, description, order, section, condition |
|
|
76
|
+
| `fieldWrapper` | `React.ComponentType<FieldWrapperProps>` | Custom wrapper around every scalar field |
|
|
77
|
+
| `layout` | `LayoutSlots` | Replace form/section/object/array wrappers, submit button, array rows. Set `null` on omittable slots (submit/array buttons) to hide them |
|
|
78
|
+
| `classNames` | `FormClassNames` | CSS classes for form, fields, labels, errors, fieldset/legend wrappers |
|
|
79
|
+
| `ref` | `React.Ref<AutoFormHandle>` | Imperative `reset`, `submit`, `setValues`, `getValues` |
|
|
80
|
+
| `persistKey` | `string` | Auto-save form state to `localStorage` under this key |
|
|
81
|
+
| `labels` | `FormLabels` | Override built-in UI strings for i18n; import a ready-made locale pack from `@uniform-ts/core/locales/{en,he,es}` |
|
|
80
82
|
|
|
81
83
|
## Features
|
|
82
84
|
|
|
83
85
|
- **Full Zod V4 support** — scalars, enums, objects, arrays, optionals, defaults, unions, discriminated unions
|
|
84
86
|
- **react-hook-form** under the hood — performant, uncontrolled forms with `zodResolver`
|
|
85
87
|
- **Section grouping** — group fields into named sections via `meta.section`
|
|
86
|
-
- **Conditional fields** — show/hide fields based on form values; hidden
|
|
87
|
-
- **Array fields** — movable, duplicable, collapsible rows; `minItems`/`maxItems` from Zod schema
|
|
88
|
+
- **Conditional fields** — show/hide fields based on form values; `hidden` and row-local sibling conditions work inside array rows too
|
|
89
|
+
- **Array fields** — movable, duplicable, collapsible rows; `minItems`/`maxItems` from Zod schema; per-row conditional fields
|
|
90
|
+
- **External array controls** — use `useArrayField('path.to.array')` to place Add/Remove controls outside the default array block while staying in sync with schema limits
|
|
88
91
|
- **Programmatic control** — `reset()`, `submit()`, `setValues()`, `getValues()`, `setErrors()`, `focus()` via ref
|
|
89
92
|
- **Form persistence** — auto-save to `localStorage` (or custom storage) with configurable debounce
|
|
90
93
|
- **Pluggable coercion** — automatic `string → number`, `string → Date` with customizable coercion map
|
|
91
|
-
- **i18n** — override every hard-coded UI string via `labels` prop
|
|
94
|
+
- **i18n** — override every hard-coded UI string (including aria labels) via `labels` prop; import a ready-made locale pack and optionally spread-override individual keys
|
|
92
95
|
- **Tree-shakeable** — ESM + CJS builds via tsup
|
|
93
96
|
|
|
94
97
|
## Documentation
|