@timeax/form-palette 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/axios.d.ts +21 -0
- package/dist/adapters/axios.d.ts.map +1 -0
- package/dist/adapters/axios.js +74 -0
- package/dist/adapters/axios.js.map +1 -0
- package/dist/adapters/index.d.ts +35 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +74 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/inertia.d.ts +24 -0
- package/dist/adapters/inertia.d.ts.map +1 -0
- package/dist/adapters/inertia.js +126 -0
- package/dist/adapters/inertia.js.map +1 -0
- package/dist/core/adapter-registry.d.ts +30 -0
- package/dist/core/adapter-registry.d.ts.map +1 -0
- package/{src/core/adapter-registry.ts → dist/core/adapter-registry.js} +10 -28
- package/dist/core/adapter-registry.js.map +1 -0
- package/{src/core/bound/bind-host.ts → dist/core/bound/bind-host.d.ts} +2 -3
- package/dist/core/bound/bind-host.d.ts.map +1 -0
- package/dist/core/bound/bind-host.js +2 -0
- package/dist/core/bound/bind-host.js.map +1 -0
- package/dist/core/bound/observe-bound-field.d.ts +21 -0
- package/dist/core/bound/observe-bound-field.d.ts.map +1 -0
- package/dist/core/bound/observe-bound-field.js +116 -0
- package/dist/core/bound/observe-bound-field.js.map +1 -0
- package/dist/core/bound/wait-for-bound-field.d.ts +5 -0
- package/dist/core/bound/wait-for-bound-field.d.ts.map +1 -0
- package/dist/core/bound/wait-for-bound-field.js +35 -0
- package/dist/core/bound/wait-for-bound-field.js.map +1 -0
- package/{src/core/context.ts → dist/core/context.d.ts} +2 -6
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/context.js +11 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/core-provider.d.ts +22 -0
- package/dist/core/core-provider.d.ts.map +1 -0
- package/{src/core/core-provider.tsx → dist/core/core-provider.js} +209 -364
- package/dist/core/core-provider.js.map +1 -0
- package/dist/core/core-root.d.ts +26 -0
- package/dist/core/core-root.d.ts.map +1 -0
- package/dist/core/core-root.js +38 -0
- package/dist/core/core-root.js.map +1 -0
- package/dist/core/core-shell.d.ts +22 -0
- package/dist/core/core-shell.d.ts.map +1 -0
- package/dist/core/core-shell.js +8 -0
- package/dist/core/core-shell.js.map +1 -0
- package/{src/core/errors/error-strip.tsx → dist/core/errors/error-strip.d.ts} +2 -39
- package/dist/core/errors/error-strip.d.ts.map +1 -0
- package/dist/core/errors/error-strip.js +18 -0
- package/dist/core/errors/error-strip.js.map +1 -0
- package/dist/core/errors/index.d.ts +4 -0
- package/dist/core/errors/index.d.ts.map +1 -0
- package/dist/core/errors/index.js +4 -0
- package/dist/core/errors/index.js.map +1 -0
- package/dist/core/errors/map-error-bag.d.ts +24 -0
- package/dist/core/errors/map-error-bag.d.ts.map +1 -0
- package/{src/core/errors/map-error-bag.ts → dist/core/errors/map-error-bag.js} +10 -22
- package/dist/core/errors/map-error-bag.js.map +1 -0
- package/dist/core/errors/map-zod.d.ts +18 -0
- package/dist/core/errors/map-zod.d.ts.map +1 -0
- package/{src/core/errors/map-zod.ts → dist/core/errors/map-zod.js} +7 -19
- package/dist/core/errors/map-zod.js.map +1 -0
- package/dist/core/hooks/use-button.d.ts +73 -0
- package/dist/core/hooks/use-button.d.ts.map +1 -0
- package/dist/core/hooks/use-button.js +116 -0
- package/dist/core/hooks/use-button.js.map +1 -0
- package/dist/core/hooks/use-core-context.d.ts +9 -0
- package/dist/core/hooks/use-core-context.d.ts.map +1 -0
- package/{src/core/hooks/use-core-context.ts → dist/core/hooks/use-core-context.js} +3 -6
- package/dist/core/hooks/use-core-context.js.map +1 -0
- package/dist/core/hooks/use-core-utility.d.ts +1 -0
- package/dist/core/hooks/use-core-utility.d.ts.map +1 -0
- package/dist/core/hooks/use-core-utility.js +2 -0
- package/dist/core/hooks/use-core-utility.js.map +1 -0
- package/{src/core/hooks/use-core.ts → dist/core/hooks/use-core.d.ts} +9 -13
- package/dist/core/hooks/use-core.d.ts.map +1 -0
- package/dist/core/hooks/use-core.js +11 -0
- package/dist/core/hooks/use-core.js.map +1 -0
- package/dist/core/hooks/use-field.d.ts +141 -0
- package/dist/core/hooks/use-field.d.ts.map +1 -0
- package/dist/core/hooks/use-field.js +256 -0
- package/dist/core/hooks/use-field.js.map +1 -0
- package/dist/core/hooks/use-optional-field.d.ts +9 -0
- package/dist/core/hooks/use-optional-field.d.ts.map +1 -0
- package/dist/core/hooks/use-optional-field.js +146 -0
- package/dist/core/hooks/use-optional-field.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +11 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/registry/binder-registry.d.ts +38 -0
- package/dist/core/registry/binder-registry.d.ts.map +1 -0
- package/dist/core/registry/binder-registry.js +52 -0
- package/dist/core/registry/binder-registry.js.map +1 -0
- package/dist/core/registry/field-registry.d.ts +86 -0
- package/dist/core/registry/field-registry.d.ts.map +1 -0
- package/{src/core/registry/field-registry.ts → dist/core/registry/field-registry.js} +56 -70
- package/dist/core/registry/field-registry.js.map +1 -0
- package/dist/core/test.d.ts +2 -0
- package/dist/core/test.d.ts.map +1 -0
- package/dist/core/test.js +9 -0
- package/dist/core/test.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/index.ts → dist/index.js} +5 -47
- package/dist/index.js.map +1 -0
- package/{src/input/index.ts → dist/input/index.d.ts} +1 -2
- package/dist/input/index.d.ts.map +1 -0
- package/dist/input/index.js +3 -0
- package/dist/input/index.js.map +1 -0
- package/dist/input/input-field.d.ts +15 -0
- package/dist/input/input-field.d.ts.map +1 -0
- package/dist/input/input-field.js +413 -0
- package/dist/input/input-field.js.map +1 -0
- package/dist/input/input-layout-graph.d.ts +77 -0
- package/dist/input/input-layout-graph.d.ts.map +1 -0
- package/dist/input/input-layout-graph.js +108 -0
- package/dist/input/input-layout-graph.js.map +1 -0
- package/{src/input/input-props.ts → dist/input/input-props.d.ts} +22 -84
- package/dist/input/input-props.d.ts.map +1 -0
- package/dist/input/input-props.js +4 -0
- package/dist/input/input-props.js.map +1 -0
- package/dist/lib/get-global-countries.d.ts +3 -0
- package/dist/lib/get-global-countries.d.ts.map +1 -0
- package/dist/lib/get-global-countries.js +70 -0
- package/dist/lib/get-global-countries.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +6 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +2 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/shadcn-preset.d.ts +1 -0
- package/dist/presets/shadcn-preset.d.ts.map +1 -0
- package/dist/presets/shadcn-preset.js +2 -0
- package/dist/presets/shadcn-preset.js.map +1 -0
- package/dist/presets/shadcn-variants/checkbox.d.ts +212 -0
- package/dist/presets/shadcn-variants/checkbox.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/checkbox.js +315 -0
- package/dist/presets/shadcn-variants/checkbox.js.map +1 -0
- package/dist/presets/shadcn-variants/chips.d.ts +154 -0
- package/dist/presets/shadcn-variants/chips.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/chips.js +266 -0
- package/dist/presets/shadcn-variants/chips.js.map +1 -0
- package/dist/presets/shadcn-variants/color.d.ts +63 -0
- package/dist/presets/shadcn-variants/color.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/color.js +96 -0
- package/dist/presets/shadcn-variants/color.js.map +1 -0
- package/dist/presets/shadcn-variants/custom.d.ts +94 -0
- package/dist/presets/shadcn-variants/custom.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/custom.js +80 -0
- package/dist/presets/shadcn-variants/custom.js.map +1 -0
- package/dist/presets/shadcn-variants/date.d.ts +114 -0
- package/dist/presets/shadcn-variants/date.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/date.js +414 -0
- package/dist/presets/shadcn-variants/date.js.map +1 -0
- package/dist/presets/shadcn-variants/file.d.ts +79 -0
- package/dist/presets/shadcn-variants/file.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/file.js +289 -0
- package/dist/presets/shadcn-variants/file.js.map +1 -0
- package/dist/presets/shadcn-variants/keyvalue.d.ts +35 -0
- package/dist/presets/shadcn-variants/keyvalue.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/keyvalue.js +215 -0
- package/dist/presets/shadcn-variants/keyvalue.js.map +1 -0
- package/dist/presets/shadcn-variants/multiselect.d.ts +210 -0
- package/dist/presets/shadcn-variants/multiselect.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/multiselect.js +352 -0
- package/dist/presets/shadcn-variants/multiselect.js.map +1 -0
- package/dist/presets/shadcn-variants/number.d.ts +31 -0
- package/dist/presets/shadcn-variants/number.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/number.js +64 -0
- package/dist/presets/shadcn-variants/number.js.map +1 -0
- package/dist/presets/shadcn-variants/password.d.ts +195 -0
- package/dist/presets/shadcn-variants/password.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/password.js +296 -0
- package/dist/presets/shadcn-variants/password.js.map +1 -0
- package/dist/presets/shadcn-variants/phone.d.ts +69 -0
- package/dist/presets/shadcn-variants/phone.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/phone.js +308 -0
- package/dist/presets/shadcn-variants/phone.js.map +1 -0
- package/dist/presets/shadcn-variants/radio.d.ts +172 -0
- package/dist/presets/shadcn-variants/radio.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/radio.js +192 -0
- package/dist/presets/shadcn-variants/radio.js.map +1 -0
- package/dist/presets/shadcn-variants/select.d.ts +203 -0
- package/dist/presets/shadcn-variants/select.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/select.js +285 -0
- package/dist/presets/shadcn-variants/select.js.map +1 -0
- package/dist/presets/shadcn-variants/slider.d.ts +131 -0
- package/dist/presets/shadcn-variants/slider.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/slider.js +151 -0
- package/dist/presets/shadcn-variants/slider.js.map +1 -0
- package/dist/presets/shadcn-variants/text.d.ts +155 -0
- package/dist/presets/shadcn-variants/text.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/text.js +98 -0
- package/dist/presets/shadcn-variants/text.js.map +1 -0
- package/dist/presets/shadcn-variants/textarea.d.ts +18 -0
- package/dist/presets/shadcn-variants/textarea.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/textarea.js +24 -0
- package/dist/presets/shadcn-variants/textarea.js.map +1 -0
- package/dist/presets/shadcn-variants/toggle.d.ts +61 -0
- package/dist/presets/shadcn-variants/toggle.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/toggle.js +67 -0
- package/dist/presets/shadcn-variants/toggle.js.map +1 -0
- package/dist/presets/shadcn-variants/treeselect.d.ts +81 -0
- package/dist/presets/shadcn-variants/treeselect.d.ts.map +1 -0
- package/dist/presets/shadcn-variants/treeselect.js +317 -0
- package/dist/presets/shadcn-variants/treeselect.js.map +1 -0
- package/dist/presets/ui/badge.d.ts +10 -0
- package/dist/presets/ui/badge.d.ts.map +1 -0
- package/dist/presets/ui/badge.js +23 -0
- package/dist/presets/ui/badge.js.map +1 -0
- package/dist/presets/ui/button.d.ts +11 -0
- package/dist/presets/ui/button.d.ts.map +1 -0
- package/dist/presets/ui/button.js +34 -0
- package/dist/presets/ui/button.js.map +1 -0
- package/dist/presets/ui/calendar.d.ts +9 -0
- package/dist/presets/ui/calendar.d.ts.map +1 -0
- package/dist/presets/ui/calendar.js +76 -0
- package/dist/presets/ui/calendar.js.map +1 -0
- package/dist/presets/ui/checkbox.d.ts +18 -0
- package/dist/presets/ui/checkbox.d.ts.map +1 -0
- package/dist/presets/ui/checkbox.js +61 -0
- package/dist/presets/ui/checkbox.js.map +1 -0
- package/dist/presets/ui/custom.d.ts +1 -0
- package/dist/presets/ui/custom.d.ts.map +1 -0
- package/dist/presets/ui/custom.js +2 -0
- package/dist/presets/ui/custom.js.map +1 -0
- package/dist/presets/ui/dialog.d.ts +16 -0
- package/dist/presets/ui/dialog.d.ts.map +1 -0
- package/dist/presets/ui/dialog.js +36 -0
- package/dist/presets/ui/dialog.js.map +1 -0
- package/dist/presets/ui/field.d.ts +25 -0
- package/dist/presets/ui/field.d.ts.map +1 -0
- package/dist/presets/ui/field.js +76 -0
- package/dist/presets/ui/field.js.map +1 -0
- package/dist/presets/ui/input-mask.d.ts +34 -0
- package/dist/presets/ui/input-mask.d.ts.map +1 -0
- package/dist/presets/ui/input-mask.js +561 -0
- package/dist/presets/ui/input-mask.js.map +1 -0
- package/dist/presets/ui/input-otp.d.ts +12 -0
- package/dist/presets/ui/input-otp.d.ts.map +1 -0
- package/dist/presets/ui/input-otp.js +22 -0
- package/dist/presets/ui/input-otp.js.map +1 -0
- package/dist/presets/ui/input.d.ts +83 -0
- package/dist/presets/ui/input.d.ts.map +1 -0
- package/dist/presets/ui/input.js +436 -0
- package/dist/presets/ui/input.js.map +1 -0
- package/dist/presets/ui/label.d.ts +5 -0
- package/dist/presets/ui/label.d.ts.map +1 -0
- package/dist/presets/ui/label.js +8 -0
- package/dist/presets/ui/label.js.map +1 -0
- package/dist/presets/ui/number.d.ts +60 -0
- package/dist/presets/ui/number.d.ts.map +1 -0
- package/dist/presets/ui/number.js +1078 -0
- package/dist/presets/ui/number.js.map +1 -0
- package/dist/presets/ui/popover.d.ts +8 -0
- package/dist/presets/ui/popover.d.ts.map +1 -0
- package/dist/presets/ui/popover.js +17 -0
- package/dist/presets/ui/popover.js.map +1 -0
- package/dist/presets/ui/radio-group.d.ts +6 -0
- package/dist/presets/ui/radio-group.d.ts.map +1 -0
- package/dist/presets/ui/radio-group.js +12 -0
- package/dist/presets/ui/radio-group.js.map +1 -0
- package/dist/presets/ui/scroll-area.d.ts +6 -0
- package/dist/presets/ui/scroll-area.d.ts.map +1 -0
- package/dist/presets/ui/scroll-area.js +13 -0
- package/dist/presets/ui/scroll-area.js.map +1 -0
- package/dist/presets/ui/select.d.ts +21 -0
- package/dist/presets/ui/select.d.ts.map +1 -0
- package/dist/presets/ui/select.js +38 -0
- package/dist/presets/ui/select.js.map +1 -0
- package/dist/presets/ui/separator.d.ts +5 -0
- package/dist/presets/ui/separator.d.ts.map +1 -0
- package/dist/presets/ui/separator.js +9 -0
- package/dist/presets/ui/separator.js.map +1 -0
- package/dist/presets/ui/slider.d.ts +5 -0
- package/dist/presets/ui/slider.d.ts.map +1 -0
- package/dist/presets/ui/slider.js +14 -0
- package/dist/presets/ui/slider.js.map +1 -0
- package/dist/presets/ui/switch.d.ts +7 -0
- package/dist/presets/ui/switch.d.ts.map +1 -0
- package/dist/presets/ui/switch.js +9 -0
- package/dist/presets/ui/switch.js.map +1 -0
- package/dist/presets/ui/textarea.d.ts +76 -0
- package/dist/presets/ui/textarea.d.ts.map +1 -0
- package/dist/presets/ui/textarea.js +291 -0
- package/dist/presets/ui/textarea.js.map +1 -0
- package/dist/presets/ui/time-dropdowns.d.ts +58 -0
- package/dist/presets/ui/time-dropdowns.d.ts.map +1 -0
- package/dist/presets/ui/time-dropdowns.js +133 -0
- package/dist/presets/ui/time-dropdowns.js.map +1 -0
- package/{src/schema/adapter.ts → dist/schema/adapter.d.ts} +7 -35
- package/dist/schema/adapter.d.ts.map +1 -0
- package/dist/schema/adapter.js +3 -0
- package/dist/schema/adapter.js.map +1 -0
- package/{src/schema/core.ts → dist/schema/core.d.ts} +17 -117
- package/dist/schema/core.d.ts.map +1 -0
- package/dist/schema/core.js +4 -0
- package/dist/schema/core.js.map +1 -0
- package/dist/schema/field-map.d.ts +1 -0
- package/dist/schema/field-map.d.ts.map +1 -0
- package/dist/schema/field-map.js +2 -0
- package/dist/schema/field-map.js.map +1 -0
- package/{src/schema/field.ts → dist/schema/field.d.ts} +1 -34
- package/dist/schema/field.d.ts.map +1 -0
- package/dist/schema/field.js +4 -0
- package/dist/schema/field.js.map +1 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +2 -0
- package/dist/schema/index.js.map +1 -0
- package/{src/schema/input-field.ts → dist/schema/input-field.d.ts} +6 -43
- package/dist/schema/input-field.d.ts.map +1 -0
- package/dist/schema/input-field.js +3 -0
- package/dist/schema/input-field.js.map +1 -0
- package/dist/schema/presets.d.ts +1 -0
- package/dist/schema/presets.d.ts.map +1 -0
- package/dist/schema/presets.js +2 -0
- package/dist/schema/presets.js.map +1 -0
- package/{src/schema/variant.ts → dist/schema/variant.d.ts} +24 -64
- package/dist/schema/variant.d.ts.map +1 -0
- package/dist/schema/variant.js +3 -0
- package/dist/schema/variant.js.map +1 -0
- package/dist/variants/core/checkbox.d.ts +15 -0
- package/dist/variants/core/checkbox.d.ts.map +1 -0
- package/dist/variants/core/checkbox.js +27 -0
- package/dist/variants/core/checkbox.js.map +1 -0
- package/dist/variants/core/chips.d.ts +3 -0
- package/dist/variants/core/chips.d.ts.map +1 -0
- package/dist/variants/core/chips.js +20 -0
- package/dist/variants/core/chips.js.map +1 -0
- package/dist/variants/core/color.d.ts +3 -0
- package/dist/variants/core/color.d.ts.map +1 -0
- package/dist/variants/core/color.js +14 -0
- package/dist/variants/core/color.js.map +1 -0
- package/dist/variants/core/custom.d.ts +11 -0
- package/dist/variants/core/custom.d.ts.map +1 -0
- package/{src/variants/core/custom.tsx → dist/variants/core/custom.js} +15 -18
- package/dist/variants/core/custom.js.map +1 -0
- package/dist/variants/core/date.d.ts +3 -0
- package/dist/variants/core/date.d.ts.map +1 -0
- package/dist/variants/core/date.js +20 -0
- package/dist/variants/core/date.js.map +1 -0
- package/dist/variants/core/file.d.ts +3 -0
- package/dist/variants/core/file.d.ts.map +1 -0
- package/dist/variants/core/file.js +6 -0
- package/dist/variants/core/file.js.map +1 -0
- package/dist/variants/core/keyvalue.d.ts +3 -0
- package/dist/variants/core/keyvalue.d.ts.map +1 -0
- package/dist/variants/core/keyvalue.js +9 -0
- package/dist/variants/core/keyvalue.js.map +1 -0
- package/dist/variants/core/multiselect.d.ts +11 -0
- package/dist/variants/core/multiselect.d.ts.map +1 -0
- package/dist/variants/core/multiselect.js +15 -0
- package/dist/variants/core/multiselect.js.map +1 -0
- package/dist/variants/core/number.d.ts +38 -0
- package/dist/variants/core/number.d.ts.map +1 -0
- package/dist/variants/core/number.js +62 -0
- package/dist/variants/core/number.js.map +1 -0
- package/dist/variants/core/password.d.ts +11 -0
- package/dist/variants/core/password.d.ts.map +1 -0
- package/dist/variants/core/password.js +29 -0
- package/dist/variants/core/password.js.map +1 -0
- package/dist/variants/core/phone.d.ts +3 -0
- package/dist/variants/core/phone.d.ts.map +1 -0
- package/dist/variants/core/phone.js +14 -0
- package/dist/variants/core/phone.js.map +1 -0
- package/dist/variants/core/radio.d.ts +8 -0
- package/dist/variants/core/radio.d.ts.map +1 -0
- package/dist/variants/core/radio.js +34 -0
- package/dist/variants/core/radio.js.map +1 -0
- package/dist/variants/core/select.d.ts +5 -0
- package/dist/variants/core/select.d.ts.map +1 -0
- package/dist/variants/core/select.js +11 -0
- package/dist/variants/core/select.js.map +1 -0
- package/dist/variants/core/slider.d.ts +19 -0
- package/dist/variants/core/slider.d.ts.map +1 -0
- package/dist/variants/core/slider.js +36 -0
- package/dist/variants/core/slider.js.map +1 -0
- package/dist/variants/core/text.d.ts +38 -0
- package/dist/variants/core/text.d.ts.map +1 -0
- package/{src/variants/core/text.tsx → dist/variants/core/text.js} +4 -56
- package/dist/variants/core/text.js.map +1 -0
- package/dist/variants/core/textarea.d.ts +3 -0
- package/dist/variants/core/textarea.d.ts.map +1 -0
- package/dist/variants/core/textarea.js +20 -0
- package/dist/variants/core/textarea.js.map +1 -0
- package/dist/variants/core/toggle.d.ts +6 -0
- package/dist/variants/core/toggle.d.ts.map +1 -0
- package/dist/variants/core/toggle.js +41 -0
- package/dist/variants/core/toggle.js.map +1 -0
- package/dist/variants/core/treeselect.d.ts +4 -0
- package/dist/variants/core/treeselect.d.ts.map +1 -0
- package/dist/variants/core/treeselect.js +7 -0
- package/dist/variants/core/treeselect.js.map +1 -0
- package/dist/variants/helpers/selection-summary.d.ts +24 -0
- package/dist/variants/helpers/selection-summary.d.ts.map +1 -0
- package/dist/variants/helpers/selection-summary.js +105 -0
- package/dist/variants/helpers/selection-summary.js.map +1 -0
- package/dist/variants/index.d.ts +16 -0
- package/dist/variants/index.d.ts.map +1 -0
- package/{src/variants/index.ts → dist/variants/index.js} +7 -27
- package/dist/variants/index.js.map +1 -0
- package/dist/variants/registry.d.ts +19 -0
- package/dist/variants/registry.d.ts.map +1 -0
- package/dist/variants/registry.js +29 -0
- package/dist/variants/registry.js.map +1 -0
- package/dist/variants/select-shared.d.ts +1 -0
- package/dist/variants/select-shared.d.ts.map +1 -0
- package/dist/variants/select-shared.js +2 -0
- package/dist/variants/select-shared.js.map +1 -0
- package/{src/variants/shared.ts → dist/variants/shared.d.ts} +3 -22
- package/dist/variants/shared.d.ts.map +1 -0
- package/dist/variants/shared.js +3 -0
- package/dist/variants/shared.js.map +1 -0
- package/package.json +5 -5
- package/.scaffold-cache.json +0 -537
- package/src/.scaffold-cache.json +0 -544
- package/src/adapters/axios.ts +0 -117
- package/src/adapters/index.ts +0 -91
- package/src/adapters/inertia.ts +0 -187
- package/src/core/bound/observe-bound-field.ts +0 -172
- package/src/core/bound/wait-for-bound-field.ts +0 -57
- package/src/core/core-root.tsx +0 -72
- package/src/core/core-shell.tsx +0 -44
- package/src/core/errors/index.ts +0 -2
- package/src/core/hooks/use-button.ts +0 -220
- package/src/core/hooks/use-core-utility.ts +0 -0
- package/src/core/hooks/use-field.ts +0 -497
- package/src/core/hooks/use-optional-field.ts +0 -28
- package/src/core/index.ts +0 -0
- package/src/core/registry/binder-registry.ts +0 -82
- package/src/core/test.tsx +0 -17
- package/src/global.d.ts +0 -14
- package/src/input/input-field.tsx +0 -854
- package/src/input/input-layout-graph.ts +0 -230
- package/src/lib/get-global-countries.ts +0 -87
- package/src/lib/utils.ts +0 -6
- package/src/presets/index.ts +0 -0
- package/src/presets/shadcn-preset.ts +0 -0
- package/src/presets/shadcn-variants/checkbox.tsx +0 -849
- package/src/presets/shadcn-variants/chips.tsx +0 -756
- package/src/presets/shadcn-variants/color.tsx +0 -284
- package/src/presets/shadcn-variants/custom.tsx +0 -227
- package/src/presets/shadcn-variants/date.tsx +0 -796
- package/src/presets/shadcn-variants/file.tsx +0 -764
- package/src/presets/shadcn-variants/keyvalue.tsx +0 -556
- package/src/presets/shadcn-variants/multiselect.tsx +0 -1132
- package/src/presets/shadcn-variants/number.tsx +0 -176
- package/src/presets/shadcn-variants/password.tsx +0 -737
- package/src/presets/shadcn-variants/phone.tsx +0 -628
- package/src/presets/shadcn-variants/radio.tsx +0 -578
- package/src/presets/shadcn-variants/select.tsx +0 -956
- package/src/presets/shadcn-variants/slider.tsx +0 -622
- package/src/presets/shadcn-variants/text.tsx +0 -343
- package/src/presets/shadcn-variants/textarea.tsx +0 -66
- package/src/presets/shadcn-variants/toggle.tsx +0 -218
- package/src/presets/shadcn-variants/treeselect.tsx +0 -784
- package/src/presets/ui/badge.tsx +0 -46
- package/src/presets/ui/button.tsx +0 -60
- package/src/presets/ui/calendar.tsx +0 -214
- package/src/presets/ui/checkbox.tsx +0 -115
- package/src/presets/ui/custom.tsx +0 -0
- package/src/presets/ui/dialog.tsx +0 -141
- package/src/presets/ui/field.tsx +0 -246
- package/src/presets/ui/input-mask.tsx +0 -739
- package/src/presets/ui/input-otp.tsx +0 -77
- package/src/presets/ui/input.tsx +0 -1011
- package/src/presets/ui/label.tsx +0 -22
- package/src/presets/ui/number.tsx +0 -1370
- package/src/presets/ui/popover.tsx +0 -46
- package/src/presets/ui/radio-group.tsx +0 -43
- package/src/presets/ui/scroll-area.tsx +0 -56
- package/src/presets/ui/select.tsx +0 -190
- package/src/presets/ui/separator.tsx +0 -28
- package/src/presets/ui/slider.tsx +0 -61
- package/src/presets/ui/switch.tsx +0 -32
- package/src/presets/ui/textarea.tsx +0 -634
- package/src/presets/ui/time-dropdowns.tsx +0 -350
- package/src/schema/field-map.ts +0 -0
- package/src/schema/index.ts +0 -0
- package/src/schema/presets.ts +0 -0
- package/src/variants/core/checkbox.tsx +0 -54
- package/src/variants/core/chips.tsx +0 -22
- package/src/variants/core/color.tsx +0 -16
- package/src/variants/core/date.tsx +0 -25
- package/src/variants/core/file.tsx +0 -9
- package/src/variants/core/keyvalue.tsx +0 -12
- package/src/variants/core/multiselect.tsx +0 -28
- package/src/variants/core/number.tsx +0 -115
- package/src/variants/core/password.tsx +0 -35
- package/src/variants/core/phone.tsx +0 -16
- package/src/variants/core/radio.tsx +0 -38
- package/src/variants/core/select.tsx +0 -15
- package/src/variants/core/slider.tsx +0 -55
- package/src/variants/core/textarea.tsx +0 -22
- package/src/variants/core/toggle.tsx +0 -50
- package/src/variants/core/treeselect.tsx +0 -11
- package/src/variants/helpers/selection-summary.tsx +0 -236
- package/src/variants/registry.ts +0 -38
- package/src/variants/select-shared.ts +0 -0
- package/tsconfig.json +0 -14
package/src/adapters/index.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// src/adapters/index.ts
|
|
2
|
-
|
|
3
|
-
import axios from "axios";
|
|
4
|
-
import { registerAdapter } from "@/core/adapter-registry";
|
|
5
|
-
import type { AdapterKey } from "@/schema/adapter";
|
|
6
|
-
|
|
7
|
-
import { createAxiosAdapter } from "./axios";
|
|
8
|
-
import { createInertiaAdapter } from "./inertia";
|
|
9
|
-
|
|
10
|
-
// Re-export core adapter types + helpers so hosts can import from a single place.
|
|
11
|
-
export * from "@/schema/adapter";
|
|
12
|
-
export * from "@/core/adapter-registry";
|
|
13
|
-
|
|
14
|
-
// Re-export the concrete factories for hosts that want manual wiring.
|
|
15
|
-
export { createAxiosAdapter, createInertiaAdapter };
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Register the Axios adapter under the "axios" key.
|
|
19
|
-
*
|
|
20
|
-
* This performs a basic runtime check to make sure Axios is present.
|
|
21
|
-
* If Axios isn't available or doesn't look like a proper Axios instance,
|
|
22
|
-
* an error is thrown.
|
|
23
|
-
*/
|
|
24
|
-
export function registerAxiosAdapter(): void {
|
|
25
|
-
// Basic sanity check – if this fails, something is wrong with the axios import.
|
|
26
|
-
if (!axios || typeof axios.request !== "function") {
|
|
27
|
-
throw new Error(
|
|
28
|
-
"[form-palette] Axios does not appear to be available. " +
|
|
29
|
-
"Make sure 'axios' is installed and resolvable before calling registerAxiosAdapter()."
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
registerAdapter<"axios">("axios", createAxiosAdapter);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Register the Inertia adapter under the "inertia" key.
|
|
38
|
-
*
|
|
39
|
-
* This explicitly tests that '@inertiajs/react' can be imported and that
|
|
40
|
-
* it exposes a router with a .visit() method. If not, an error is thrown.
|
|
41
|
-
*
|
|
42
|
-
* Note:
|
|
43
|
-
* - This function is async because it uses dynamic import.
|
|
44
|
-
* - Call it at bootstrap time and await it:
|
|
45
|
-
*
|
|
46
|
-
* await registerInertiaAdapter();
|
|
47
|
-
*/
|
|
48
|
-
export async function registerInertiaAdapter(): Promise<void> {
|
|
49
|
-
try {
|
|
50
|
-
const mod: any = await import("@inertiajs/react");
|
|
51
|
-
const router = mod?.router ?? mod?.Inertia;
|
|
52
|
-
|
|
53
|
-
if (!router || typeof router.visit !== "function") {
|
|
54
|
-
throw new Error(
|
|
55
|
-
"[form-palette] '@inertiajs/react' was imported, " +
|
|
56
|
-
"but no router with a .visit() method was found."
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
} catch (error) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
"[form-palette] Failed to import '@inertiajs/react'. " +
|
|
62
|
-
"Cannot register the 'inertia' adapter. " +
|
|
63
|
-
"Make sure '@inertiajs/react' is installed and resolvable."
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
registerAdapter<"inertia">("inertia", createInertiaAdapter);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Optional helper: convenience registration for known adapter keys.
|
|
72
|
-
*
|
|
73
|
-
* This is purely ergonomic; you can also call registerAxiosAdapter /
|
|
74
|
-
* registerInertiaAdapter directly.
|
|
75
|
-
*/
|
|
76
|
-
export async function registerKnownAdapter(key: AdapterKey): Promise<void> {
|
|
77
|
-
switch (key) {
|
|
78
|
-
case "axios":
|
|
79
|
-
registerAxiosAdapter();
|
|
80
|
-
return;
|
|
81
|
-
case "inertia":
|
|
82
|
-
await registerInertiaAdapter();
|
|
83
|
-
return;
|
|
84
|
-
default:
|
|
85
|
-
// For now, we only special-case axios/inertia here.
|
|
86
|
-
// Other adapters can be registered by calling registerAdapter() directly.
|
|
87
|
-
throw new Error(
|
|
88
|
-
`[form-palette] registerKnownAdapter: adapter "${key}" is not handled here.`
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|
package/src/adapters/inertia.ts
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { VisitOptions, Page } from './../../../../node_modules/@inertiajs/core/types/types.d';
|
|
2
|
-
// src/adapters/inertia.ts
|
|
3
|
-
import type {
|
|
4
|
-
NamedAdapterFactory,
|
|
5
|
-
NamedAdapterConfig,
|
|
6
|
-
AdapterResult,
|
|
7
|
-
AdapterOk,
|
|
8
|
-
AdapterError,
|
|
9
|
-
} from "@/schema/adapter";
|
|
10
|
-
|
|
11
|
-
// (Adapters augmentation is above in the same file)
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Lazy-load the Inertia router from '@inertiajs/react'.
|
|
15
|
-
*
|
|
16
|
-
* This keeps '@inertiajs/react' out of the main bundle until an
|
|
17
|
-
* Inertia adapter is actually used.
|
|
18
|
-
*/
|
|
19
|
-
async function loadInertiaRouter() {
|
|
20
|
-
const mod: any = await import("@inertiajs/react");
|
|
21
|
-
const router = mod?.router ?? mod?.Inertia;
|
|
22
|
-
|
|
23
|
-
if (!router || typeof router.visit !== "function") {
|
|
24
|
-
throw new Error(
|
|
25
|
-
"[form-palette] Inertia router not found in @inertiajs/react"
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return router as {
|
|
30
|
-
visit: (url: string, options?: VisitOptions) => void;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Shape raw Inertia errors into something with `.errors`
|
|
36
|
-
* so Form Palette's autoErr branch can pick them up.
|
|
37
|
-
*/
|
|
38
|
-
function normalizeInertiaError(
|
|
39
|
-
raw: unknown
|
|
40
|
-
): { errors: Record<string, string | string[]> } | unknown {
|
|
41
|
-
if (
|
|
42
|
-
raw &&
|
|
43
|
-
typeof raw === "object" &&
|
|
44
|
-
"errors" in (raw as any) &&
|
|
45
|
-
typeof (raw as any).errors === "object"
|
|
46
|
-
) {
|
|
47
|
-
// Already in { errors: {...} } shape
|
|
48
|
-
return raw as any;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
raw &&
|
|
53
|
-
typeof raw === "object" &&
|
|
54
|
-
!("errors" in (raw as any))
|
|
55
|
-
) {
|
|
56
|
-
// Inertia usually passes the error bag directly to onError.
|
|
57
|
-
return { errors: raw as Record<string, string | string[]> };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return raw;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const createInertiaAdapter: NamedAdapterFactory<"inertia"> = (
|
|
64
|
-
config: NamedAdapterConfig<"inertia">
|
|
65
|
-
): AdapterResult<AdapterOk<"inertia">> => {
|
|
66
|
-
const { method, url, data, callbacks } = config;
|
|
67
|
-
|
|
68
|
-
const upperMethod = method.toUpperCase() as VisitOptions["method"];
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Build VisitOptions with callbacks wired to AdapterCallbacks
|
|
72
|
-
* + optional Promise resolve/reject.
|
|
73
|
-
*/
|
|
74
|
-
function buildOptions(
|
|
75
|
-
resolve?: (value: AdapterOk<"inertia">) => void,
|
|
76
|
-
reject?: (reason: AdapterError<"inertia">) => void,
|
|
77
|
-
extraOptions?: unknown
|
|
78
|
-
): VisitOptions {
|
|
79
|
-
const merged: VisitOptions = {
|
|
80
|
-
method: upperMethod,
|
|
81
|
-
//@ts-ignore
|
|
82
|
-
data,
|
|
83
|
-
onSuccess: (page: Page) => {
|
|
84
|
-
callbacks?.onSuccess?.(page as AdapterOk<"inertia">);
|
|
85
|
-
resolve?.(page as AdapterOk<"inertia">);
|
|
86
|
-
},
|
|
87
|
-
onError: (rawErrors: any) => {
|
|
88
|
-
const payload = normalizeInertiaError(rawErrors);
|
|
89
|
-
callbacks?.onError?.(payload as AdapterError<"inertia">);
|
|
90
|
-
reject?.(payload as AdapterError<"inertia">);
|
|
91
|
-
},
|
|
92
|
-
onFinish: () => {
|
|
93
|
-
callbacks?.onFinish?.();
|
|
94
|
-
},
|
|
95
|
-
...(extraOptions as VisitOptions | undefined),
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
return merged;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function submit(options?: unknown): void {
|
|
102
|
-
// Fire-and-forget; we still propagate callbacks and finish.
|
|
103
|
-
(async () => {
|
|
104
|
-
let finished = false;
|
|
105
|
-
const finish = () => {
|
|
106
|
-
if (finished) return;
|
|
107
|
-
finished = true;
|
|
108
|
-
callbacks?.onFinish?.();
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
const router = await loadInertiaRouter();
|
|
113
|
-
const visitOptions = buildOptions(undefined, undefined, options);
|
|
114
|
-
// NOTE: buildOptions already wires onFinish, so we
|
|
115
|
-
// call finish() only if the lazy import itself fails.
|
|
116
|
-
router.visit(url, visitOptions);
|
|
117
|
-
} catch (error) {
|
|
118
|
-
const payload = normalizeInertiaError(error);
|
|
119
|
-
callbacks?.onError?.(payload as AdapterError<"inertia">);
|
|
120
|
-
finish();
|
|
121
|
-
}
|
|
122
|
-
})();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function send(options?: unknown): Promise<AdapterOk<"inertia">> {
|
|
126
|
-
return new Promise(async (resolve, reject) => {
|
|
127
|
-
let finished = false;
|
|
128
|
-
const finish = () => {
|
|
129
|
-
if (finished) return;
|
|
130
|
-
finished = true;
|
|
131
|
-
callbacks?.onFinish?.();
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
try {
|
|
135
|
-
const router = await loadInertiaRouter();
|
|
136
|
-
const visitOptions = buildOptions(
|
|
137
|
-
(page) => {
|
|
138
|
-
// buildOptions' onFinish will call onFinish();
|
|
139
|
-
resolve(page);
|
|
140
|
-
},
|
|
141
|
-
(err) => {
|
|
142
|
-
reject(err);
|
|
143
|
-
},
|
|
144
|
-
options
|
|
145
|
-
);
|
|
146
|
-
router.visit(url, visitOptions);
|
|
147
|
-
} catch (error) {
|
|
148
|
-
const payload = normalizeInertiaError(error);
|
|
149
|
-
callbacks?.onError?.(payload as AdapterError<"inertia">);
|
|
150
|
-
finish();
|
|
151
|
-
reject(payload as AdapterError<"inertia">);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function run(options?: unknown): Promise<AdapterOk<"inertia">> {
|
|
157
|
-
// Same as send(), so the core can safely `await adapter.run()`
|
|
158
|
-
// if it wants, or ignore the promise if it doesn't care.
|
|
159
|
-
return send(options);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return {
|
|
163
|
-
submit,
|
|
164
|
-
send,
|
|
165
|
-
run,
|
|
166
|
-
};
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
declare module "@/schema/adapter" {
|
|
170
|
-
interface Adapters {
|
|
171
|
-
inertia: {
|
|
172
|
-
/**
|
|
173
|
-
* What adapter.send() resolves with for Inertia.
|
|
174
|
-
* This is the Page object passed to onSuccess.
|
|
175
|
-
*/
|
|
176
|
-
ok: Page<any>;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* What callbacks.onError receives for Inertia.
|
|
180
|
-
*
|
|
181
|
-
* We shape this as `{ errors: ErrorBag }` so Form Palette's
|
|
182
|
-
* autoErr branch can see `.errors`.
|
|
183
|
-
*/
|
|
184
|
-
err: { errors: Record<string, string | string[]> } | unknown;
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
// src/core/bound/observe-bound-field.ts
|
|
2
|
-
|
|
3
|
-
import type { Dict } from "@/schema/core";
|
|
4
|
-
import type { Field } from "@/schema/field";
|
|
5
|
-
import type { BindHost } from "@/core/bound/bind-host";
|
|
6
|
-
|
|
7
|
-
/** Get the live bound field (if mounted and present). */
|
|
8
|
-
export function getBoundField<V extends Dict>(
|
|
9
|
-
host: BindHost<V>,
|
|
10
|
-
bindId: string
|
|
11
|
-
): Field | undefined {
|
|
12
|
-
return host.getBind(bindId);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function hasBoundField<V extends Dict>(
|
|
16
|
-
host: BindHost<V>,
|
|
17
|
-
bindId: string
|
|
18
|
-
): boolean {
|
|
19
|
-
return !!getBoundField(host, bindId);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function readBoundValue<T = unknown, V extends Dict = Dict>(
|
|
23
|
-
host: BindHost<V>,
|
|
24
|
-
bindId: string
|
|
25
|
-
): T | undefined {
|
|
26
|
-
return getBoundField(host, bindId)?.value as T | undefined;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function setBoundValue<T = unknown, V extends Dict = Dict>(
|
|
30
|
-
host: BindHost<V>,
|
|
31
|
-
bindId: string,
|
|
32
|
-
value: T,
|
|
33
|
-
variant: string = "util"
|
|
34
|
-
): boolean {
|
|
35
|
-
const f = getBoundField(host, bindId);
|
|
36
|
-
if (!f) return false;
|
|
37
|
-
|
|
38
|
-
(f as any).value = value as unknown;
|
|
39
|
-
|
|
40
|
-
// optional: dirty/enable logic if host supports it
|
|
41
|
-
try {
|
|
42
|
-
host.controlButton?.();
|
|
43
|
-
} catch {
|
|
44
|
-
// ignore
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
(f as any).onChange?.(value, undefined, variant);
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function setBoundError<V extends Dict>(
|
|
52
|
-
_host: BindHost<V>, // host not strictly needed here
|
|
53
|
-
bindId: string,
|
|
54
|
-
msg: string
|
|
55
|
-
): boolean {
|
|
56
|
-
const f = _host.getBind(bindId);
|
|
57
|
-
if (!f) return false;
|
|
58
|
-
(f as any).error = msg ?? "";
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function validateBoundField<V extends Dict>(
|
|
63
|
-
host: BindHost<V>,
|
|
64
|
-
bindId: string,
|
|
65
|
-
report = true
|
|
66
|
-
): boolean {
|
|
67
|
-
const f = getBoundField(host, bindId);
|
|
68
|
-
if (!f) return false;
|
|
69
|
-
return !!(f as any).validate?.(report);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Observe a bound field for value/error + liveness.
|
|
74
|
-
*/
|
|
75
|
-
export function observeBoundField<T = unknown, V extends Dict = Dict>(
|
|
76
|
-
host: BindHost<V>,
|
|
77
|
-
bindId: string,
|
|
78
|
-
handler: (evt: {
|
|
79
|
-
exists: boolean;
|
|
80
|
-
field?: Field;
|
|
81
|
-
value?: T;
|
|
82
|
-
error?: string;
|
|
83
|
-
}) => void,
|
|
84
|
-
pollMs = 300
|
|
85
|
-
): () => void {
|
|
86
|
-
let current: Field | undefined = getBoundField(host, bindId);
|
|
87
|
-
let restoreOnChange: Field["onChange"] | undefined;
|
|
88
|
-
|
|
89
|
-
const fire = () => {
|
|
90
|
-
if (!current) {
|
|
91
|
-
handler({ exists: false });
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
handler({
|
|
96
|
-
exists: true,
|
|
97
|
-
field: current,
|
|
98
|
-
value: (current as any).value as T,
|
|
99
|
-
error: (current as any).error,
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const wire = () => {
|
|
104
|
-
const f = getBoundField(host, bindId);
|
|
105
|
-
|
|
106
|
-
if (f === current) return;
|
|
107
|
-
|
|
108
|
-
if (current && restoreOnChange) {
|
|
109
|
-
(current as any).onChange = restoreOnChange;
|
|
110
|
-
restoreOnChange = undefined;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
current = f;
|
|
114
|
-
|
|
115
|
-
if (current) {
|
|
116
|
-
restoreOnChange = (current as any).onChange;
|
|
117
|
-
(current as any).onChange = (
|
|
118
|
-
next: unknown,
|
|
119
|
-
prev: unknown,
|
|
120
|
-
variant: string
|
|
121
|
-
) => {
|
|
122
|
-
restoreOnChange?.(next, prev, variant);
|
|
123
|
-
handler({
|
|
124
|
-
exists: true,
|
|
125
|
-
field: current,
|
|
126
|
-
value: next as T,
|
|
127
|
-
error: (current as any).error,
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
fire();
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
// initial
|
|
136
|
-
wire();
|
|
137
|
-
|
|
138
|
-
let intervalId: number | undefined;
|
|
139
|
-
if (typeof window !== "undefined") {
|
|
140
|
-
intervalId = window.setInterval(wire, pollMs);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
let mo: MutationObserver | undefined;
|
|
144
|
-
if (
|
|
145
|
-
typeof MutationObserver !== "undefined" &&
|
|
146
|
-
typeof document !== "undefined"
|
|
147
|
-
) {
|
|
148
|
-
try {
|
|
149
|
-
mo = new MutationObserver(wire);
|
|
150
|
-
mo.observe(document.body, {
|
|
151
|
-
childList: true,
|
|
152
|
-
subtree: true,
|
|
153
|
-
});
|
|
154
|
-
} catch {
|
|
155
|
-
// ignore
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return () => {
|
|
160
|
-
if (typeof window !== "undefined" && typeof intervalId === "number") {
|
|
161
|
-
window.clearInterval(intervalId);
|
|
162
|
-
}
|
|
163
|
-
if (mo) {
|
|
164
|
-
mo.disconnect();
|
|
165
|
-
mo = undefined;
|
|
166
|
-
}
|
|
167
|
-
if (current && restoreOnChange) {
|
|
168
|
-
(current as any).onChange = restoreOnChange;
|
|
169
|
-
restoreOnChange = undefined;
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// src/core/bound/wait-for-bound-field.ts
|
|
2
|
-
|
|
3
|
-
import type { Dict } from "@/schema/core";
|
|
4
|
-
import type { Field } from "@/schema/field";
|
|
5
|
-
import type { BindHost } from "@/core/bound/bind-host";
|
|
6
|
-
import {
|
|
7
|
-
getBoundField,
|
|
8
|
-
observeBoundField,
|
|
9
|
-
} from "@/core/bound/observe-bound-field";
|
|
10
|
-
|
|
11
|
-
export function waitForBoundField<V extends Dict>(
|
|
12
|
-
host: BindHost<V>,
|
|
13
|
-
bindId: string,
|
|
14
|
-
timeoutMs = 5000
|
|
15
|
-
): Promise<Field> {
|
|
16
|
-
const existing = getBoundField(host, bindId);
|
|
17
|
-
if (existing) return Promise.resolve(existing);
|
|
18
|
-
|
|
19
|
-
return new Promise<Field>((resolve, reject) => {
|
|
20
|
-
let settled = false;
|
|
21
|
-
|
|
22
|
-
const settleResolve = (field: Field) => {
|
|
23
|
-
if (settled) return;
|
|
24
|
-
settled = true;
|
|
25
|
-
stop();
|
|
26
|
-
clearTimeout(to);
|
|
27
|
-
resolve(field);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const settleReject = (error: Error) => {
|
|
31
|
-
if (settled) return;
|
|
32
|
-
settled = true;
|
|
33
|
-
stop();
|
|
34
|
-
clearTimeout(to);
|
|
35
|
-
reject(error);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const stop = observeBoundField(
|
|
39
|
-
host,
|
|
40
|
-
bindId,
|
|
41
|
-
(e) => {
|
|
42
|
-
if (e.exists && e.field) {
|
|
43
|
-
settleResolve(e.field);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
150
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const to = setTimeout(() => {
|
|
50
|
-
settleReject(
|
|
51
|
-
new Error(
|
|
52
|
-
`waitForBoundField('${bindId}') timed out after ${timeoutMs}ms`
|
|
53
|
-
)
|
|
54
|
-
);
|
|
55
|
-
}, timeoutMs);
|
|
56
|
-
});
|
|
57
|
-
}
|
package/src/core/core-root.tsx
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
// src/core/core-root.tsx
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
import { useCore } from "@/core/hooks/use-core";
|
|
6
|
-
import { ErrorStrip } from "@/core/errors/error-strip";
|
|
7
|
-
import type { CoreContext, Dict } from "@/schema/core";
|
|
8
|
-
|
|
9
|
-
export interface CoreRootProps
|
|
10
|
-
extends React.FormHTMLAttributes<HTMLFormElement> {
|
|
11
|
-
/**
|
|
12
|
-
* If true, the global ErrorStrip will not be rendered automatically.
|
|
13
|
-
*/
|
|
14
|
-
noErrorStrip?: boolean;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Optional hook invoked after CoreRoot orchestrates the submit.
|
|
18
|
-
*
|
|
19
|
-
* - The native event is already `preventDefault()`-ed.
|
|
20
|
-
* - The adapter flow is triggered via `form.go(...)`.
|
|
21
|
-
* - Use this to tap into submit without breaking the core.
|
|
22
|
-
*/
|
|
23
|
-
onSubmitForm?(
|
|
24
|
-
event: React.FormEvent<HTMLFormElement>,
|
|
25
|
-
form: CoreContext<Dict>
|
|
26
|
-
): void | Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* CoreRoot: actual <form> element wired to the core runtime.
|
|
31
|
-
*
|
|
32
|
-
* Responsibilities:
|
|
33
|
-
* - Own the native submit event and prevent full-page navigation.
|
|
34
|
-
* - Delegate submit orchestration to form.go().
|
|
35
|
-
* - Optionally render the global ErrorStrip at the top.
|
|
36
|
-
*/
|
|
37
|
-
export function CoreRoot(props: CoreRootProps) {
|
|
38
|
-
const { noErrorStrip, onSubmitForm, children, ...rest } = props;
|
|
39
|
-
|
|
40
|
-
const form = useCore<Dict>();
|
|
41
|
-
|
|
42
|
-
const handleSubmit = React.useCallback(
|
|
43
|
-
(event: React.FormEvent<HTMLFormElement>) => {
|
|
44
|
-
event.preventDefault();
|
|
45
|
-
if (form.props.activateButtonOnChange && !form.isDirty()) return;
|
|
46
|
-
// Core submit orchestration (adapter-specific behaviour lives inside).
|
|
47
|
-
form.go();
|
|
48
|
-
|
|
49
|
-
// Optional host-level hook.
|
|
50
|
-
if (onSubmitForm) {
|
|
51
|
-
void onSubmitForm(event, form);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// If the host provided a native onSubmit prop, call it too.
|
|
55
|
-
if (typeof rest.onSubmit === "function") {
|
|
56
|
-
rest.onSubmit(event);
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
-
[form, onSubmitForm, rest.onSubmit]
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
// We intentionally override onSubmit so the core owns submit routing.
|
|
64
|
-
const { onSubmit: _ignored, ...passThrough } = rest;
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<form onSubmit={handleSubmit} {...passThrough}>
|
|
68
|
-
{!noErrorStrip && <ErrorStrip form={form} />}
|
|
69
|
-
{children}
|
|
70
|
-
</form>
|
|
71
|
-
);
|
|
72
|
-
}
|
package/src/core/core-shell.tsx
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// src/core/core-shell.tsx
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
import { CoreProvider } from "@/core/core-provider";
|
|
6
|
-
import { CoreRoot, type CoreRootProps } from "@/core/core-root";
|
|
7
|
-
|
|
8
|
-
import type { z } from "zod";
|
|
9
|
-
import type { AdapterKey } from "@/schema/adapter";
|
|
10
|
-
import type { CoreProps, Dict } from "@/schema/core";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Combined provider + form-root wrapper.
|
|
14
|
-
*
|
|
15
|
-
* Usage:
|
|
16
|
-
* <CoreShell adapter="local" schema={schema} formProps={{ className: "space-y-4" }}>
|
|
17
|
-
* {...fields + buttons...}
|
|
18
|
-
* </CoreShell>
|
|
19
|
-
*/
|
|
20
|
-
export interface CoreShellProps<
|
|
21
|
-
V extends Dict = Dict,
|
|
22
|
-
S extends z.ZodType | undefined = z.ZodType | undefined,
|
|
23
|
-
K extends AdapterKey = "local",
|
|
24
|
-
> extends CoreProps<V, S, K> {
|
|
25
|
-
/**
|
|
26
|
-
* Props passed directly to the underlying <form> element via CoreRoot.
|
|
27
|
-
*/
|
|
28
|
-
formProps?: CoreRootProps;
|
|
29
|
-
children?: React.ReactNode;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function CoreShell<
|
|
33
|
-
V extends Dict,
|
|
34
|
-
S extends z.ZodType | undefined,
|
|
35
|
-
K extends AdapterKey = "local",
|
|
36
|
-
>(props: CoreShellProps<V, S, K>) {
|
|
37
|
-
const { formProps, children, ...coreProps } = props;
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<CoreProvider<V, S, K> {...(coreProps as CoreProps<V, S, K>)}>
|
|
41
|
-
<CoreRoot {...(formProps ?? {})}>{children}</CoreRoot>
|
|
42
|
-
</CoreProvider>
|
|
43
|
-
);
|
|
44
|
-
}
|
package/src/core/errors/index.ts
DELETED