@funstack/ui 0.1.0-alpha.15 → 0.1.0-alpha.17
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 +22 -1
- package/dist/accordion/accordion-item.d.mts +19 -0
- package/dist/accordion/accordion-item.d.mts.map +1 -1
- package/dist/accordion/accordion-item.mjs +2 -0
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.d.mts +16 -0
- package/dist/accordion/accordion-panel.d.mts.map +1 -1
- package/dist/accordion/accordion-panel.mjs +2 -0
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts +36 -2
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +3 -1
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts +9 -0
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +2 -0
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/accordion/index.d.mts +2 -0
- package/dist/accordion/index.d.mts.map +1 -1
- package/dist/accordion/index.mjs +2 -0
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/bin/skill-installer.d.mts +1 -0
- package/dist/bin/skill-installer.mjs +12 -0
- package/dist/bin/skill-installer.mjs.map +1 -0
- package/dist/button/button.d.mts +46 -15
- package/dist/button/button.d.mts.map +1 -1
- package/dist/button/button.mjs +10 -6
- package/dist/button/button.mjs.map +1 -1
- package/dist/checkbox/checkbox.d.mts +25 -3
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +2 -0
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +15 -0
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.d.mts +10 -0
- package/dist/checkbox-group/checkbox-group-label.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts +19 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +31 -4
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +7 -1
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/checkbox-group/index.d.mts +2 -0
- package/dist/checkbox-group/index.d.mts.map +1 -1
- package/dist/checkbox-group/index.mjs +2 -0
- package/dist/checkbox-group/index.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts +18 -0
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +2 -0
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-group.d.mts +49 -1
- package/dist/combobox/combobox-group.d.mts.map +1 -1
- package/dist/combobox/combobox-group.mjs +11 -1
- package/dist/combobox/combobox-group.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts +11 -0
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +2 -0
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-label.d.mts +16 -0
- package/dist/combobox/combobox-label.d.mts.map +1 -1
- package/dist/combobox/combobox-label.mjs +2 -0
- package/dist/combobox/combobox-label.mjs.map +1 -1
- package/dist/combobox/combobox-list.d.mts +14 -0
- package/dist/combobox/combobox-list.d.mts.map +1 -1
- package/dist/combobox/combobox-list.mjs +2 -0
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts +25 -3
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +2 -0
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts +20 -1
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +2 -0
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts +64 -17
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +11 -11
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts +16 -0
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +9 -2
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.d.mts +2 -0
- package/dist/combobox/index.d.mts.map +1 -1
- package/dist/combobox/index.mjs +2 -0
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/csp/csp-provider.d.mts +8 -0
- package/dist/csp/csp-provider.d.mts.map +1 -1
- package/dist/csp/csp-provider.mjs +2 -0
- package/dist/csp/csp-provider.mjs.map +1 -1
- package/dist/csp/style-hashes.d.mts +2 -0
- package/dist/csp/style-hashes.d.mts.map +1 -1
- package/dist/csp/style-hashes.mjs +2 -0
- package/dist/csp/style-hashes.mjs.map +1 -1
- package/dist/dialog/dialog-close.d.mts +31 -3
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +5 -2
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-description.d.mts +12 -0
- package/dist/dialog/dialog-description.d.mts.map +1 -1
- package/dist/dialog/dialog-description.mjs +2 -0
- package/dist/dialog/dialog-description.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts +20 -2
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +2 -0
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +34 -8
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +14 -20
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +53 -25
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +12 -8
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-title.d.mts +11 -0
- package/dist/dialog/dialog-title.d.mts.map +1 -1
- package/dist/dialog/dialog-title.mjs +2 -0
- package/dist/dialog/dialog-title.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +19 -3
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +2 -0
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +7 -5
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +7 -5
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/docs/components/accordion.md +426 -0
- package/dist/docs/components/button.md +508 -0
- package/dist/docs/components/checkbox-group.md +483 -0
- package/dist/docs/components/checkbox.md +373 -0
- package/dist/docs/components/combobox.md +698 -0
- package/dist/docs/components/context-menu.md +524 -0
- package/dist/docs/components/dialog.md +692 -0
- package/dist/docs/components/field.md +587 -0
- package/dist/docs/components/menu.md +670 -0
- package/dist/docs/components/meter.md +313 -0
- package/dist/docs/components/number-field.md +528 -0
- package/dist/docs/components/popover.md +656 -0
- package/dist/docs/components/progress.md +450 -0
- package/dist/docs/components/radio-group.md +457 -0
- package/dist/docs/components/select.md +662 -0
- package/dist/docs/components/slider.md +558 -0
- package/dist/docs/components/switch.md +311 -0
- package/dist/docs/components/tabs.md +473 -0
- package/dist/docs/components/toast.md +599 -0
- package/dist/docs/components/toggle-group.md +341 -0
- package/dist/docs/components/toggle.md +245 -0
- package/dist/docs/components/toolbar.md +390 -0
- package/dist/docs/components/tooltip.md +494 -0
- package/dist/docs/concepts/action-props.md +281 -0
- package/dist/docs/concepts/ai-agents.md +56 -0
- package/dist/docs/concepts/browser-owned-state.md +133 -0
- package/dist/docs/concepts/content-security-policy.md +69 -0
- package/dist/docs/concepts/experimental.md +36 -0
- package/dist/docs/concepts/pending-and-optimistic.md +263 -0
- package/dist/docs/concepts/render.md +23 -0
- package/dist/docs/concepts/server-components.md +132 -0
- package/dist/docs/concepts/suspense.md +129 -0
- package/dist/docs/concepts/transitions.md +112 -0
- package/dist/docs/getting-started.md +102 -0
- package/dist/docs/index.md +182 -0
- package/dist/docs/roadmap.md +128 -0
- package/dist/docs/why.md +104 -0
- package/dist/field/field-control.d.mts +26 -3
- package/dist/field/field-control.d.mts.map +1 -1
- package/dist/field/field-control.mjs +2 -0
- package/dist/field/field-control.mjs.map +1 -1
- package/dist/field/field-description.d.mts +11 -0
- package/dist/field/field-description.d.mts.map +1 -1
- package/dist/field/field-description.mjs +2 -0
- package/dist/field/field-description.mjs.map +1 -1
- package/dist/field/field-error.d.mts +14 -2
- package/dist/field/field-error.d.mts.map +1 -1
- package/dist/field/field-error.mjs +2 -0
- package/dist/field/field-error.mjs.map +1 -1
- package/dist/field/field-label.d.mts +10 -0
- package/dist/field/field-label.d.mts.map +1 -1
- package/dist/field/field-label.mjs +2 -0
- package/dist/field/field-label.mjs.map +1 -1
- package/dist/field/field-root.d.mts +21 -2
- package/dist/field/field-root.d.mts.map +1 -1
- package/dist/field/field-root.mjs +2 -0
- package/dist/field/field-root.mjs.map +1 -1
- package/dist/field/index.d.mts +9 -0
- package/dist/field/index.d.mts.map +1 -1
- package/dist/field/index.mjs +9 -0
- package/dist/field/index.mjs.map +1 -1
- package/dist/form/form-root.d.mts +17 -1
- package/dist/form/form-root.d.mts.map +1 -1
- package/dist/form/form-root.mjs +2 -0
- package/dist/form/form-root.mjs.map +1 -1
- package/dist/form/form-submit.d.mts +18 -0
- package/dist/form/form-submit.d.mts.map +1 -1
- package/dist/form/form-submit.mjs +2 -0
- package/dist/form/form-submit.mjs.map +1 -1
- package/dist/form/index.d.mts +7 -0
- package/dist/form/index.d.mts.map +1 -1
- package/dist/form/index.mjs +7 -0
- package/dist/form/index.mjs.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/internal/call-urgent-handler.mjs +37 -0
- package/dist/internal/call-urgent-handler.mjs.map +1 -0
- package/dist/internal/css-transition-cut.mjs +66 -0
- package/dist/internal/css-transition-cut.mjs.map +1 -0
- package/dist/internal/overlay-popup.mjs.map +1 -1
- package/dist/internal/report-dropped.mjs +45 -0
- package/dist/internal/report-dropped.mjs.map +1 -0
- package/dist/internal/types.d.mts +36 -7
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-action-trigger.mjs +32 -17
- package/dist/internal/use-action-trigger.mjs.map +1 -1
- package/dist/internal/use-controllable-action.mjs +52 -16
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-exit-animation.mjs +1 -1
- package/dist/internal/use-exit-animation.mjs.map +1 -1
- package/dist/internal/use-native-group-reconciliation.mjs +4 -2
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-overlay-close.mjs +10 -4
- package/dist/internal/use-overlay-close.mjs.map +1 -1
- package/dist/internal/use-overlay-root.mjs +40 -7
- package/dist/internal/use-overlay-root.mjs.map +1 -1
- package/dist/internal/use-popover-popup.mjs +22 -7
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.d.mts +2 -1
- package/dist/internal/use-popover-trigger.d.mts.map +1 -1
- package/dist/internal/use-popover-trigger.mjs +11 -3
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/validity.d.mts +11 -0
- package/dist/internal/validity.d.mts.map +1 -1
- package/dist/internal/validity.mjs.map +1 -1
- package/dist/menu/index.d.mts +2 -0
- package/dist/menu/index.d.mts.map +1 -1
- package/dist/menu/index.mjs +2 -0
- package/dist/menu/index.mjs.map +1 -1
- package/dist/menu/menu-checkbox-item.d.mts +27 -3
- package/dist/menu/menu-checkbox-item.d.mts.map +1 -1
- package/dist/menu/menu-checkbox-item.mjs +2 -0
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +24 -2
- package/dist/menu/menu-context-trigger.d.mts.map +1 -1
- package/dist/menu/menu-context-trigger.mjs +2 -0
- package/dist/menu/menu-context-trigger.mjs.map +1 -1
- package/dist/menu/menu-group.d.mts +36 -1
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +9 -1
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-item.d.mts +38 -5
- package/dist/menu/menu-item.d.mts.map +1 -1
- package/dist/menu/menu-item.mjs +12 -5
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-outside.mjs +2 -2
- package/dist/menu/menu-outside.mjs.map +1 -1
- package/dist/menu/menu-popup.d.mts +36 -8
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +2 -0
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.d.mts +20 -1
- package/dist/menu/menu-radio-group.d.mts.map +1 -1
- package/dist/menu/menu-radio-group.mjs +2 -0
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.d.mts +16 -0
- package/dist/menu/menu-radio-item.d.mts.map +1 -1
- package/dist/menu/menu-radio-item.mjs +2 -0
- package/dist/menu/menu-radio-item.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +49 -15
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +7 -4
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts +13 -0
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +2 -0
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +15 -0
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +2 -0
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/meter/index.d.mts +2 -0
- package/dist/meter/index.d.mts.map +1 -1
- package/dist/meter/index.mjs +2 -0
- package/dist/meter/index.mjs.map +1 -1
- package/dist/meter/meter-indicator.d.mts +11 -0
- package/dist/meter/meter-indicator.d.mts.map +1 -1
- package/dist/meter/meter-indicator.mjs +2 -0
- package/dist/meter/meter-indicator.mjs.map +1 -1
- package/dist/meter/meter-label.d.mts +11 -0
- package/dist/meter/meter-label.d.mts.map +1 -1
- package/dist/meter/meter-label.mjs +2 -0
- package/dist/meter/meter-label.mjs.map +1 -1
- package/dist/meter/meter-region.d.mts +5 -0
- package/dist/meter/meter-region.d.mts.map +1 -1
- package/dist/meter/meter-region.mjs.map +1 -1
- package/dist/meter/meter-root.d.mts +52 -10
- package/dist/meter/meter-root.d.mts.map +1 -1
- package/dist/meter/meter-root.mjs +2 -0
- package/dist/meter/meter-root.mjs.map +1 -1
- package/dist/meter/meter-track.d.mts +11 -0
- package/dist/meter/meter-track.d.mts.map +1 -1
- package/dist/meter/meter-track.mjs +2 -0
- package/dist/meter/meter-track.mjs.map +1 -1
- package/dist/meter/meter-value.d.mts +15 -1
- package/dist/meter/meter-value.d.mts.map +1 -1
- package/dist/meter/meter-value.mjs +2 -0
- package/dist/meter/meter-value.mjs.map +1 -1
- package/dist/number-field/index.d.mts +2 -0
- package/dist/number-field/index.d.mts.map +1 -1
- package/dist/number-field/index.mjs +2 -0
- package/dist/number-field/index.mjs.map +1 -1
- package/dist/number-field/number-field-decrement.d.mts +2 -0
- package/dist/number-field/number-field-decrement.d.mts.map +1 -1
- package/dist/number-field/number-field-decrement.mjs +2 -0
- package/dist/number-field/number-field-decrement.mjs.map +1 -1
- package/dist/number-field/number-field-increment.d.mts +2 -0
- package/dist/number-field/number-field-increment.d.mts.map +1 -1
- package/dist/number-field/number-field-increment.mjs +2 -0
- package/dist/number-field/number-field-increment.mjs.map +1 -1
- package/dist/number-field/number-field-input.d.mts +9 -0
- package/dist/number-field/number-field-input.d.mts.map +1 -1
- package/dist/number-field/number-field-input.mjs +2 -0
- package/dist/number-field/number-field-input.mjs.map +1 -1
- package/dist/number-field/number-field-label.d.mts +10 -0
- package/dist/number-field/number-field-label.d.mts.map +1 -1
- package/dist/number-field/number-field-label.mjs +2 -0
- package/dist/number-field/number-field-label.mjs.map +1 -1
- package/dist/number-field/number-field-root.d.mts +62 -14
- package/dist/number-field/number-field-root.d.mts.map +1 -1
- package/dist/number-field/number-field-root.mjs +4 -8
- package/dist/number-field/number-field-root.mjs.map +1 -1
- package/dist/number-field/use-step-button.d.mts +20 -0
- package/dist/number-field/use-step-button.d.mts.map +1 -1
- package/dist/number-field/use-step-button.mjs.map +1 -1
- package/dist/popover/index.d.mts +5 -3
- package/dist/popover/index.d.mts.map +1 -1
- package/dist/popover/index.mjs +5 -3
- package/dist/popover/index.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts +32 -3
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +6 -2
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-description.d.mts +12 -0
- package/dist/popover/popover-description.d.mts.map +1 -1
- package/dist/popover/popover-description.mjs +2 -0
- package/dist/popover/popover-description.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +36 -7
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +5 -2
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.d.mts +40 -18
- package/dist/popover/popover-root.d.mts.map +1 -1
- package/dist/popover/popover-root.mjs +11 -7
- package/dist/popover/popover-root.mjs.map +1 -1
- package/dist/popover/popover-title.d.mts +11 -0
- package/dist/popover/popover-title.d.mts.map +1 -1
- package/dist/popover/popover-title.mjs +2 -0
- package/dist/popover/popover-title.mjs.map +1 -1
- package/dist/popover/popover-trigger.d.mts +15 -0
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +2 -0
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/index.d.mts +2 -0
- package/dist/progress/index.d.mts.map +1 -1
- package/dist/progress/index.mjs +2 -0
- package/dist/progress/index.mjs.map +1 -1
- package/dist/progress/progress-indicator.d.mts +11 -0
- package/dist/progress/progress-indicator.d.mts.map +1 -1
- package/dist/progress/progress-indicator.mjs +2 -0
- package/dist/progress/progress-indicator.mjs.map +1 -1
- package/dist/progress/progress-label.d.mts +11 -0
- package/dist/progress/progress-label.d.mts.map +1 -1
- package/dist/progress/progress-label.mjs +2 -0
- package/dist/progress/progress-label.mjs.map +1 -1
- package/dist/progress/progress-root.d.mts +36 -8
- package/dist/progress/progress-root.d.mts.map +1 -1
- package/dist/progress/progress-root.mjs +2 -0
- package/dist/progress/progress-root.mjs.map +1 -1
- package/dist/progress/progress-track.d.mts +11 -0
- package/dist/progress/progress-track.d.mts.map +1 -1
- package/dist/progress/progress-track.mjs +2 -0
- package/dist/progress/progress-track.mjs.map +1 -1
- package/dist/progress/progress-value.d.mts +15 -1
- package/dist/progress/progress-value.d.mts.map +1 -1
- package/dist/progress/progress-value.mjs +2 -0
- package/dist/progress/progress-value.mjs.map +1 -1
- package/dist/radio-group/index.d.mts +2 -0
- package/dist/radio-group/index.d.mts.map +1 -1
- package/dist/radio-group/index.mjs +2 -0
- package/dist/radio-group/index.mjs.map +1 -1
- package/dist/radio-group/radio-group-item.d.mts +18 -1
- package/dist/radio-group/radio-group-item.d.mts.map +1 -1
- package/dist/radio-group/radio-group-item.mjs +2 -0
- package/dist/radio-group/radio-group-item.mjs.map +1 -1
- package/dist/radio-group/radio-group-label.d.mts +10 -0
- package/dist/radio-group/radio-group-label.d.mts.map +1 -1
- package/dist/radio-group/radio-group-label.mjs +2 -0
- package/dist/radio-group/radio-group-label.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +29 -5
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +2 -0
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/index.d.mts +2 -0
- package/dist/select/index.d.mts.map +1 -1
- package/dist/select/index.mjs +2 -0
- package/dist/select/index.mjs.map +1 -1
- package/dist/select/select-group-label.d.mts +10 -0
- package/dist/select/select-group-label.d.mts.map +1 -1
- package/dist/select/select-group-label.mjs +2 -0
- package/dist/select/select-group-label.mjs.map +1 -1
- package/dist/select/select-group.d.mts +15 -1
- package/dist/select/select-group.d.mts.map +1 -1
- package/dist/select/select-group.mjs +2 -0
- package/dist/select/select-group.mjs.map +1 -1
- package/dist/select/select-option.d.mts +19 -1
- package/dist/select/select-option.d.mts.map +1 -1
- package/dist/select/select-option.mjs +2 -0
- package/dist/select/select-option.mjs.map +1 -1
- package/dist/select/select-root.d.mts +24 -1
- package/dist/select/select-root.d.mts.map +1 -1
- package/dist/select/select-root.mjs +2 -0
- package/dist/select/select-root.mjs.map +1 -1
- package/dist/select/select-separator.d.mts +9 -0
- package/dist/select/select-separator.d.mts.map +1 -1
- package/dist/select/select-separator.mjs +2 -0
- package/dist/select/select-separator.mjs.map +1 -1
- package/dist/select/select-trigger.d.mts +9 -0
- package/dist/select/select-trigger.d.mts.map +1 -1
- package/dist/select/select-trigger.mjs +2 -0
- package/dist/select/select-trigger.mjs.map +1 -1
- package/dist/select/select-value.d.mts +9 -0
- package/dist/select/select-value.d.mts.map +1 -1
- package/dist/select/select-value.mjs +2 -0
- package/dist/select/select-value.mjs.map +1 -1
- package/dist/slider/index.d.mts +2 -0
- package/dist/slider/index.d.mts.map +1 -1
- package/dist/slider/index.mjs +2 -0
- package/dist/slider/index.mjs.map +1 -1
- package/dist/slider/slider-indicator.d.mts +12 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -1
- package/dist/slider/slider-indicator.mjs +2 -0
- package/dist/slider/slider-indicator.mjs.map +1 -1
- package/dist/slider/slider-label.d.mts +11 -1
- package/dist/slider/slider-label.d.mts.map +1 -1
- package/dist/slider/slider-label.mjs +2 -0
- package/dist/slider/slider-label.mjs.map +1 -1
- package/dist/slider/slider-root.d.mts +53 -9
- package/dist/slider/slider-root.d.mts.map +1 -1
- package/dist/slider/slider-root.mjs +4 -8
- package/dist/slider/slider-root.mjs.map +1 -1
- package/dist/slider/slider-thumb.d.mts +32 -3
- package/dist/slider/slider-thumb.d.mts.map +1 -1
- package/dist/slider/slider-thumb.mjs +2 -0
- package/dist/slider/slider-thumb.mjs.map +1 -1
- package/dist/slider/slider-track.d.mts +17 -0
- package/dist/slider/slider-track.d.mts.map +1 -1
- package/dist/slider/slider-track.mjs +2 -0
- package/dist/slider/slider-track.mjs.map +1 -1
- package/dist/slider/slider-value.d.mts +11 -0
- package/dist/slider/slider-value.d.mts.map +1 -1
- package/dist/slider/slider-value.mjs +2 -0
- package/dist/slider/slider-value.mjs.map +1 -1
- package/dist/switch/switch.d.mts +23 -3
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +2 -0
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/index.d.mts +2 -0
- package/dist/tabs/index.d.mts.map +1 -1
- package/dist/tabs/index.mjs +2 -0
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/tabs/tabs-context.d.mts +5 -0
- package/dist/tabs/tabs-context.d.mts.map +1 -1
- package/dist/tabs/tabs-context.mjs.map +1 -1
- package/dist/tabs/tabs-indicator.d.mts +17 -0
- package/dist/tabs/tabs-indicator.d.mts.map +1 -1
- package/dist/tabs/tabs-indicator.mjs +2 -0
- package/dist/tabs/tabs-indicator.mjs.map +1 -1
- package/dist/tabs/tabs-list.d.mts +19 -1
- package/dist/tabs/tabs-list.d.mts.map +1 -1
- package/dist/tabs/tabs-list.mjs +2 -0
- package/dist/tabs/tabs-list.mjs.map +1 -1
- package/dist/tabs/tabs-panel.d.mts +19 -0
- package/dist/tabs/tabs-panel.d.mts.map +1 -1
- package/dist/tabs/tabs-panel.mjs +2 -0
- package/dist/tabs/tabs-panel.mjs.map +1 -1
- package/dist/tabs/tabs-root.d.mts +39 -5
- package/dist/tabs/tabs-root.d.mts.map +1 -1
- package/dist/tabs/tabs-root.mjs +2 -0
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.d.mts +22 -1
- package/dist/tabs/tabs-tab.d.mts.map +1 -1
- package/dist/tabs/tabs-tab.mjs +2 -0
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/index.d.mts +2 -0
- package/dist/toast/index.d.mts.map +1 -1
- package/dist/toast/index.mjs +2 -0
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toast/toast-action.d.mts +42 -6
- package/dist/toast/toast-action.d.mts.map +1 -1
- package/dist/toast/toast-action.mjs +8 -4
- package/dist/toast/toast-action.mjs.map +1 -1
- package/dist/toast/toast-close.d.mts +16 -0
- package/dist/toast/toast-close.d.mts.map +1 -1
- package/dist/toast/toast-close.mjs +2 -0
- package/dist/toast/toast-close.mjs.map +1 -1
- package/dist/toast/toast-context.mjs.map +1 -1
- package/dist/toast/toast-description.d.mts +16 -1
- package/dist/toast/toast-description.d.mts.map +1 -1
- package/dist/toast/toast-description.mjs +2 -0
- package/dist/toast/toast-description.mjs.map +1 -1
- package/dist/toast/toast-queue.mjs.map +1 -1
- package/dist/toast/toast-root.d.mts +20 -0
- package/dist/toast/toast-root.d.mts.map +1 -1
- package/dist/toast/toast-root.mjs +2 -0
- package/dist/toast/toast-root.mjs.map +1 -1
- package/dist/toast/toast-title.d.mts +15 -1
- package/dist/toast/toast-title.d.mts.map +1 -1
- package/dist/toast/toast-title.mjs +2 -0
- package/dist/toast/toast-title.mjs.map +1 -1
- package/dist/toast/toast-viewport.d.mts +34 -5
- package/dist/toast/toast-viewport.d.mts.map +1 -1
- package/dist/toast/toast-viewport.mjs +17 -15
- package/dist/toast/toast-viewport.mjs.map +1 -1
- package/dist/toast/toast.d.mts +56 -13
- package/dist/toast/toast.d.mts.map +1 -1
- package/dist/toast/toast.mjs +4 -0
- package/dist/toast/toast.mjs.map +1 -1
- package/dist/toggle/toggle.d.mts +20 -2
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +2 -0
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/index.d.mts +2 -0
- package/dist/toggle-group/index.d.mts.map +1 -1
- package/dist/toggle-group/index.mjs +2 -0
- package/dist/toggle-group/index.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-context.d.mts +1 -0
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-item.d.mts +16 -0
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-item.mjs +2 -0
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-root.d.mts +73 -12
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-root.mjs +3 -1
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
- package/dist/toolbar/index.d.mts +2 -0
- package/dist/toolbar/index.d.mts.map +1 -1
- package/dist/toolbar/index.mjs +2 -0
- package/dist/toolbar/index.mjs.map +1 -1
- package/dist/toolbar/toolbar-root.d.mts +30 -3
- package/dist/toolbar/toolbar-root.d.mts.map +1 -1
- package/dist/toolbar/toolbar-root.mjs +2 -0
- package/dist/toolbar/toolbar-root.mjs.map +1 -1
- package/dist/toolbar/toolbar-separator.d.mts +13 -0
- package/dist/toolbar/toolbar-separator.d.mts.map +1 -1
- package/dist/toolbar/toolbar-separator.mjs +2 -0
- package/dist/toolbar/toolbar-separator.mjs.map +1 -1
- package/dist/tooltip/index.d.mts +2 -0
- package/dist/tooltip/index.d.mts.map +1 -1
- package/dist/tooltip/index.mjs +2 -0
- package/dist/tooltip/index.mjs.map +1 -1
- package/dist/tooltip/tooltip-arrow.d.mts +16 -0
- package/dist/tooltip/tooltip-arrow.d.mts.map +1 -1
- package/dist/tooltip/tooltip-arrow.mjs +2 -0
- package/dist/tooltip/tooltip-arrow.mjs.map +1 -1
- package/dist/tooltip/tooltip-context.d.mts +4 -0
- package/dist/tooltip/tooltip-context.d.mts.map +1 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts +24 -3
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +2 -0
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.d.mts +24 -2
- package/dist/tooltip/tooltip-root.d.mts.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +2 -0
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +18 -1
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +2 -0
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/package.json +9 -1
- package/skills/funstack-ui-knowledge/SKILL.md +75 -0
- package/dist/internal/use-superseded-rejection.mjs +0 -47
- package/dist/internal/use-superseded-rejection.mjs.map +0 -1
package/dist/docs/why.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Why FUNSTACK UI
|
|
2
|
+
|
|
3
|
+
React 18 brought transitions and Suspense for data fetching. React 19 added actions and `useOptimistic`, and React 19.3 made `<ViewTransition>` stable. FUNSTACK UI is a headless component library that uses them for you, so the async work around every button, tab and dialog is already done.
|
|
4
|
+
|
|
5
|
+
## <a id="async-react"></a>Built for Async React
|
|
6
|
+
|
|
7
|
+
Async React is the React team's name for using these features together (the [Async React talks at React Conf 2025](https://react.dev/blog/2025/10/16/react-conf-2025-recap)). The idea is good async UX built in: while data loads or a request runs, the screen stays responsive, shows what is pending, and switches to the result when it is ready, without each app wiring that by hand.
|
|
8
|
+
|
|
9
|
+
FUNSTACK UI bets on this idea and is **Async React-native**: the components start the transitions, show optimistic and pending state and wait for Suspense themselves. You get good async UI by using them, without wiring it yourself.
|
|
10
|
+
|
|
11
|
+
## What you stop writing
|
|
12
|
+
|
|
13
|
+
- **[No pending flags](concepts/pending-and-optimistic.md)**
|
|
14
|
+
|
|
15
|
+
Every component with an action sets `data-pending` while the action runs, until its result is on screen. Style it in CSS.
|
|
16
|
+
|
|
17
|
+
- **[No onChange + useTransition + useOptimistic](concepts/action-props.md)**
|
|
18
|
+
|
|
19
|
+
Pass an async function as an action prop. The component runs it in a transition, shows the new value at once, and rolls it back if the action fails. Errors go to your Error Boundary.
|
|
20
|
+
|
|
21
|
+
- **[No races between fast clicks](concepts/action-props.md#overlapping-actions)**
|
|
22
|
+
|
|
23
|
+
The display always shows the latest click. Uncontrolled state commits only the latest one, so a slow response to an older click never overwrites a newer choice.
|
|
24
|
+
|
|
25
|
+
- **[No fallback flashes](concepts/suspense.md)**
|
|
26
|
+
|
|
27
|
+
When the next tab, accordion item or dialog loads data, the current screen stays as it is and the trigger shows pending until the new content is ready.
|
|
28
|
+
|
|
29
|
+
- **[No JavaScript copies of the browser](concepts/browser-owned-state.md)**
|
|
30
|
+
|
|
31
|
+
Popups use the Popover API, `<dialog>` and CSS Anchor Positioning; form controls are native inputs. The browser handles the top layer and Escape, and popovers close on a click outside natively.
|
|
32
|
+
|
|
33
|
+
- **[No animation glue](concepts/transitions.md)**
|
|
34
|
+
|
|
35
|
+
Pass `transition` to a part and it renders React's `<ViewTransition>`. Each change is tagged with a transition type, such as `fsui-tabs-next`, so you can animate by direction.
|
|
36
|
+
|
|
37
|
+
## Before and after
|
|
38
|
+
|
|
39
|
+
A favourite button that saves to a server. By hand:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
const [pressed, setPressed] = useState(initial);
|
|
43
|
+
const [optimistic, setOptimistic] = useOptimistic(pressed);
|
|
44
|
+
const [isPending, startTransition] = useTransition();
|
|
45
|
+
|
|
46
|
+
<button
|
|
47
|
+
aria-pressed={optimistic}
|
|
48
|
+
data-pending={isPending ? "" : undefined}
|
|
49
|
+
onClick={() => {
|
|
50
|
+
const next = !optimistic;
|
|
51
|
+
startTransition(async () => {
|
|
52
|
+
setOptimistic(next);
|
|
53
|
+
await saveFavorite(next);
|
|
54
|
+
startTransition(() => setPressed(next));
|
|
55
|
+
});
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
Favorite
|
|
59
|
+
</button>
|
|
60
|
+
// ...and a slow save from an earlier click can still overwrite a later one.
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
With FUNSTACK UI:
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
<Toggle defaultPressed={initial} pressedChangeAction={(next) => saveFavorite(next)}>
|
|
67
|
+
Favorite
|
|
68
|
+
</Toggle>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Same optimistic flip and `data-pending`, plus latest-click-wins and transition types for animation. Try it on the [home page](index.md).
|
|
72
|
+
|
|
73
|
+
## Compared with other headless libraries
|
|
74
|
+
|
|
75
|
+
Most established headless React libraries were designed before React's async features, and support a wide range of browsers. They are mature and a safe choice. FUNSTACK UI takes a different approach:
|
|
76
|
+
|
|
77
|
+
| | Typical headless library | FUNSTACK UI |
|
|
78
|
+
| - | - | - |
|
|
79
|
+
| **Callbacks** | Event handlers (`onValueChange`, `onOpenChange`). Transitions, optimistic state and pending flags are yours to add. | [Action props](concepts/action-props.md): run in a transition, may be async. Optimistic and pending state built in. |
|
|
80
|
+
| **Popups** | JavaScript for positioning, layering and dismissal, so older browsers work too. | The [platform](concepts/browser-owned-state.md): Popover API, `<dialog>`, CSS Anchor Positioning. Some components work before hydration. |
|
|
81
|
+
| **Animation** | CSS, with exit-animation states built in. No `<ViewTransition>` integration. | CSS, plus `<ViewTransition>` through the parts' `transition` prop ([Transitions](concepts/transitions.md)). |
|
|
82
|
+
| **Browsers** | Wide support, including older versions. | Latest stable Chrome, Edge, Safari and Firefox. No fallbacks. |
|
|
83
|
+
|
|
84
|
+
## Who it is for
|
|
85
|
+
|
|
86
|
+
### Choose it if
|
|
87
|
+
|
|
88
|
+
- Your app uses React 19.3 or later, with actions, Suspense or [Server Components](concepts/server-components.md).
|
|
89
|
+
- Your controls save to a server and should feel instant.
|
|
90
|
+
- You only need to support current browsers.
|
|
91
|
+
- You want to write your own CSS: no styles, no theme, no provider.
|
|
92
|
+
|
|
93
|
+
### Look elsewhere (for now) if
|
|
94
|
+
|
|
95
|
+
- You need older browsers or older Safari versions.
|
|
96
|
+
- You need a stable API today.
|
|
97
|
+
- You want styled components out of the box.
|
|
98
|
+
- You need a component that is not here yet (see the [roadmap](roadmap.md)).
|
|
99
|
+
|
|
100
|
+
## Next
|
|
101
|
+
|
|
102
|
+
- [Getting started](getting-started.md): install, import, style.
|
|
103
|
+
- [Action props](concepts/action-props.md): the idea everything else builds on.
|
|
104
|
+
- [Using with AI agents](concepts/ai-agents.md): give your coding agent the full docs.
|
|
@@ -2,14 +2,35 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { FieldState } from "../internal/field-context.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef } from "react";
|
|
4
4
|
//#region src/field/field-control.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props of `Field.Control`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ui.funstack.work/components/field
|
|
9
|
+
*/
|
|
5
10
|
export interface FieldControlProps extends Omit<ComponentPropsWithRef<"input">, "id" | "aria-invalid" | "className" | "style" | "children"> {
|
|
6
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Native `name`.
|
|
13
|
+
*
|
|
14
|
+
* @defaultValue the Field's `name`
|
|
15
|
+
*/
|
|
7
16
|
name?: string;
|
|
8
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Native `disabled`. Owned. Also `true` when the Field is disabled: an explicit `false` does not
|
|
19
|
+
* override the Field.
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue `false`
|
|
22
|
+
*/
|
|
9
23
|
disabled?: boolean;
|
|
10
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Native `required`. Owned. Also `true` when the Field is required: an explicit `false` does not
|
|
26
|
+
* override the Field.
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue `false`
|
|
29
|
+
*/
|
|
11
30
|
required?: boolean;
|
|
31
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
12
32
|
className?: StateValue<string | undefined, FieldState>;
|
|
33
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
13
34
|
style?: StateValue<CSSProperties | undefined, FieldState>;
|
|
14
35
|
/** Must render an `<input>`, `<textarea>` or `<select>`: `render={<textarea rows={3} />}`. */
|
|
15
36
|
render?: RenderProp<ComponentPropsWithRef<"input">, FieldState>;
|
|
@@ -24,6 +45,8 @@ export interface FieldControlProps extends Omit<ComponentPropsWithRef<"input">,
|
|
|
24
45
|
* Owned keys (conventions 1.2): `id`, `name`, `disabled`, `required`, `aria-invalid`,
|
|
25
46
|
* `aria-describedby` (token-merged), `data-invalid`, `data-disabled`, `data-required`,
|
|
26
47
|
* `data-pending`.
|
|
48
|
+
*
|
|
49
|
+
* @see https://ui.funstack.work/components/field
|
|
27
50
|
*/
|
|
28
51
|
export declare function FieldControl({ name, disabled, required, className, style, render, ...rest }: FieldControlProps): import("react").ReactNode;
|
|
29
52
|
export declare namespace FieldControl {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-control.d.mts","names":[],"sources":["../../src/field/field-control.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"field-control.d.mts","names":[],"sources":["../../src/field/field-control.tsx"],"mappings":";;;;;;;;;iBAiBiB,0BAA0B,KACzC;;;;;;EAQA;;;;;;;EAOA;;;;;;;EAOA;;EAEA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,gCAAgC;;;;;;;;;;;;;;;wBAkBtC,eACd,MACA,UACA,UACA,WACA,OACA,WACG,QACF,oCAAiB;yBARJ"}
|
|
@@ -21,6 +21,8 @@ const CONTROL_TAGS = /* @__PURE__ */ new Set([
|
|
|
21
21
|
* Owned keys (conventions 1.2): `id`, `name`, `disabled`, `required`, `aria-invalid`,
|
|
22
22
|
* `aria-describedby` (token-merged), `data-invalid`, `data-disabled`, `data-required`,
|
|
23
23
|
* `data-pending`.
|
|
24
|
+
*
|
|
25
|
+
* @see https://ui.funstack.work/components/field
|
|
24
26
|
*/
|
|
25
27
|
function FieldControl({ name, disabled, required, className, style, render, ...rest }) {
|
|
26
28
|
const ctx = useFieldContext("Field.Control");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-control.mjs","names":[],"sources":["../../src/field/field-control.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties } from \"react\";\nimport { fieldDataAttributes, useFieldContext } from \"../internal/field-context.js\";\nimport type { FieldState } from \"../internal/field-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useFieldControl } from \"../internal/use-field-control.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface FieldControlProps extends Omit<\n ComponentPropsWithRef<\"input\">,\n \"id\" | \"aria-invalid\" | \"className\" | \"style\" | \"children\"\n> {\n
|
|
1
|
+
{"version":3,"file":"field-control.mjs","names":[],"sources":["../../src/field/field-control.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties } from \"react\";\nimport { fieldDataAttributes, useFieldContext } from \"../internal/field-context.js\";\nimport type { FieldState } from \"../internal/field-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useFieldControl } from \"../internal/use-field-control.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Props of `Field.Control`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport interface FieldControlProps extends Omit<\n ComponentPropsWithRef<\"input\">,\n \"id\" | \"aria-invalid\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Native `name`.\n *\n * @defaultValue the Field's `name`\n */\n name?: string;\n /**\n * Native `disabled`. Owned. Also `true` when the Field is disabled: an explicit `false` does not\n * override the Field.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /**\n * Native `required`. Owned. Also `true` when the Field is required: an explicit `false` does not\n * override the Field.\n *\n * @defaultValue `false`\n */\n required?: boolean;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, FieldState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, FieldState>;\n /** Must render an `<input>`, `<textarea>` or `<select>`: `render={<textarea rows={3} />}`. */\n render?: RenderProp<ComponentPropsWithRef<\"input\">, FieldState>;\n}\n\nconst CONTROL_TAGS = new Set([\"INPUT\", \"TEXTAREA\", \"SELECT\"]);\n\n/**\n * The field's native control: an `<input>` (or a `<textarea>` / `<select>` through `render`)\n * wired to the Field: `id` for the Label, `aria-describedby` (the consumer's tokens, the\n * description, the error while shown), an explicit `aria-invalid`, and `name` / `disabled` /\n * `required` from the Field unless given. Everything else passes through, including `onChange`\n * / `value` for a controlled input; the Field's listeners are native and run independently.\n *\n * Owned keys (conventions 1.2): `id`, `name`, `disabled`, `required`, `aria-invalid`,\n * `aria-describedby` (token-merged), `data-invalid`, `data-disabled`, `data-required`,\n * `data-pending`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport function FieldControl({\n name,\n disabled,\n required,\n className,\n style,\n render,\n ...rest\n}: FieldControlProps) {\n const ctx = useFieldContext(\"Field.Control\");\n // `id` is not in the props type (the Field owns it); a JS caller's is ignored with a warning.\n const { id: consumerId, ...props } = rest as typeof rest & { id?: string };\n const field = useFieldControl({\n labelable: true,\n name,\n disabled,\n required,\n id: consumerId,\n component: \"Field.Control\",\n });\n const checkElement = useElementCheck(\n isDev &&\n ((el) =>\n !CONTROL_TAGS.has(el.tagName)\n ? \"Field.Control: expected to render an <input>, <textarea> or <select> but got \" +\n `<${el.tagName.toLowerCase()}>. Validation, labelling and form participation need a ` +\n \"native form control.\"\n : null),\n );\n const ref = useMergedRefs<HTMLElement>(checkElement, field.ref);\n\n return useRender<ComponentPropsWithRef<\"input\">, FieldState>({\n defaultElement: \"input\",\n render,\n state: ctx.state,\n className,\n style,\n children: undefined,\n props,\n libraryProps: {\n id: field.id,\n name: field.name,\n disabled: field.disabled,\n required: field.required,\n ...field.attributes,\n ...fieldDataAttributes(ctx.state),\n },\n ref,\n });\n}\n\nFieldControl.displayName = \"FieldControl\";\n"],"mappings":";;;;;;;AAUA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAuCvC,MAAM,+BAAe,IAAI,IAAI;CAAC;CAAS;CAAY;AAAQ,CAAC;;;;;;;;;;;;;;AAe5D,SAAgB,aAAa,EAC3B,MACA,UACA,UACA,WACA,OACA,QACA,GAAG,QACiB;CACpB,MAAM,MAAM,gBAAgB,eAAe;CAE3C,MAAM,EAAE,IAAI,YAAY,GAAG,UAAU;CACrC,MAAM,QAAQ,gBAAgB;EAC5B,WAAW;EACX;EACA;EACA;EACA,IAAI;EACJ,WAAW;CACb,CAAC;CACD,MAAM,eAAe,gBACnB,WACI,OACA,CAAC,aAAa,IAAI,GAAG,OAAO,IACxB,iFACI,GAAG,QAAQ,YAAY,EAAE,+EAE7B,KACV;CACA,MAAM,MAAM,cAA2B,cAAc,MAAM,GAAG;CAE9D,OAAO,UAAsD;EAC3D,gBAAgB;EAChB;EACA,OAAO,IAAI;EACX;EACA;EACA,UAAU,KAAA;EACV;EACA,cAAc;GACZ,IAAI,MAAM;GACV,MAAM,MAAM;GACZ,UAAU,MAAM;GAChB,UAAU,MAAM;GAChB,GAAG,MAAM;GACT,GAAG,oBAAoB,IAAI,KAAK;EAClC;EACA;CACF,CAAC;AACH;AAEA,aAAa,cAAc"}
|
|
@@ -2,10 +2,19 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { FieldState } from "../internal/field-context.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/field/field-description.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props of `Field.Description`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ui.funstack.work/components/field
|
|
9
|
+
*/
|
|
5
10
|
export interface FieldDescriptionProps extends Omit<ComponentPropsWithRef<"p">, "id" | "className" | "style" | "children"> {
|
|
11
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
6
12
|
className?: StateValue<string | undefined, FieldState>;
|
|
13
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
7
14
|
style?: StateValue<CSSProperties | undefined, FieldState>;
|
|
15
|
+
/** Content, or a function of the part's state. */
|
|
8
16
|
children?: StateValue<ReactNode, FieldState>;
|
|
17
|
+
/** Replace the default `<p>` (element form) or take over rendering (function form). */
|
|
9
18
|
render?: RenderProp<ComponentPropsWithRef<"p">, FieldState>;
|
|
10
19
|
}
|
|
11
20
|
/**
|
|
@@ -15,6 +24,8 @@ export interface FieldDescriptionProps extends Omit<ComponentPropsWithRef<"p">,
|
|
|
15
24
|
*
|
|
16
25
|
* Owned keys (conventions 1.2): `id`, `data-invalid`, `data-disabled`, `data-required`,
|
|
17
26
|
* `data-pending`.
|
|
27
|
+
*
|
|
28
|
+
* @see https://ui.funstack.work/components/field
|
|
18
29
|
*/
|
|
19
30
|
export declare function FieldDescription({ className, style, children, render, ...rest }: FieldDescriptionProps): ReactNode;
|
|
20
31
|
export declare namespace FieldDescription {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-description.d.mts","names":[],"sources":["../../src/field/field-description.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"field-description.d.mts","names":[],"sources":["../../src/field/field-description.tsx"],"mappings":";;;;;;;;;iBAYiB,8BAA8B,KAC7C;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,4BAA4B;;;;;;;;;;;;wBAalC,mBACd,WACA,OACA,UACA,WACG,QACF,wBAAqB;yBANR"}
|
|
@@ -9,6 +9,8 @@ import { fieldDataAttributes, useFieldContext } from "../internal/field-context.
|
|
|
9
9
|
*
|
|
10
10
|
* Owned keys (conventions 1.2): `id`, `data-invalid`, `data-disabled`, `data-required`,
|
|
11
11
|
* `data-pending`.
|
|
12
|
+
*
|
|
13
|
+
* @see https://ui.funstack.work/components/field
|
|
12
14
|
*/
|
|
13
15
|
function FieldDescription({ className, style, children, render, ...rest }) {
|
|
14
16
|
const ctx = useFieldContext("Field.Description");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-description.mjs","names":[],"sources":["../../src/field/field-description.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { fieldDataAttributes, useFieldContext } from \"../internal/field-context.js\";\nimport type { FieldState } from \"../internal/field-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\nexport interface FieldDescriptionProps extends Omit<\n ComponentPropsWithRef<\"p\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, FieldState>;\n style?: StateValue<CSSProperties | undefined, FieldState>;\n children?: StateValue<ReactNode, FieldState>;\n render?: RenderProp<ComponentPropsWithRef<\"p\">, FieldState>;\n}\n\n/**\n * Help text for the field: a `<p>` whose id the control always lists in `aria-describedby`\n * (a dangling reference when no Description is rendered is skipped by assistive technology, so\n * nothing registers and the server HTML is exact).\n *\n * Owned keys (conventions 1.2): `id`, `data-invalid`, `data-disabled`, `data-required`,\n * `data-pending`.\n */\nexport function FieldDescription({\n className,\n style,\n children,\n render,\n ...rest\n}: FieldDescriptionProps) {\n const ctx = useFieldContext(\"Field.Description\");\n return useRender<ComponentPropsWithRef<\"p\">, FieldState>({\n defaultElement: \"p\",\n render,\n state: ctx.state,\n className,\n style,\n children,\n props: rest,\n libraryProps: { id: ctx.ids.description, ...fieldDataAttributes(ctx.state) },\n });\n}\n\nFieldDescription.displayName = \"FieldDescription\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"field-description.mjs","names":[],"sources":["../../src/field/field-description.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { fieldDataAttributes, useFieldContext } from \"../internal/field-context.js\";\nimport type { FieldState } from \"../internal/field-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\n/**\n * Props of `Field.Description`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport interface FieldDescriptionProps extends Omit<\n ComponentPropsWithRef<\"p\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, FieldState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, FieldState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, FieldState>;\n /** Replace the default `<p>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"p\">, FieldState>;\n}\n\n/**\n * Help text for the field: a `<p>` whose id the control always lists in `aria-describedby`\n * (a dangling reference when no Description is rendered is skipped by assistive technology, so\n * nothing registers and the server HTML is exact).\n *\n * Owned keys (conventions 1.2): `id`, `data-invalid`, `data-disabled`, `data-required`,\n * `data-pending`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport function FieldDescription({\n className,\n style,\n children,\n render,\n ...rest\n}: FieldDescriptionProps) {\n const ctx = useFieldContext(\"Field.Description\");\n return useRender<ComponentPropsWithRef<\"p\">, FieldState>({\n defaultElement: \"p\",\n render,\n state: ctx.state,\n className,\n style,\n children,\n props: rest,\n libraryProps: { id: ctx.ids.description, ...fieldDataAttributes(ctx.state) },\n });\n}\n\nFieldDescription.displayName = \"FieldDescription\";\n"],"mappings":";;;;;;;;;;;;;;AAoCA,SAAgB,iBAAiB,EAC/B,WACA,OACA,UACA,QACA,GAAG,QACqB;CACxB,MAAM,MAAM,gBAAgB,mBAAmB;CAC/C,OAAO,UAAkD;EACvD,gBAAgB;EAChB;EACA,OAAO,IAAI;EACX;EACA;EACA;EACA,OAAO;EACP,cAAc;GAAE,IAAI,IAAI,IAAI;GAAa,GAAG,oBAAoB,IAAI,KAAK;EAAE;CAC7E,CAAC;AACH;AAEA,iBAAiB,cAAc"}
|
|
@@ -2,15 +2,25 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { FieldState } from "../internal/field-context.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/field/field-error.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props of `Field.Error`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ui.funstack.work/components/field
|
|
9
|
+
*/
|
|
5
10
|
export interface FieldErrorProps extends Omit<ComponentPropsWithRef<"div">, "id" | "className" | "style" | "children"> {
|
|
11
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
6
12
|
className?: StateValue<string | undefined, FieldState>;
|
|
13
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
7
14
|
style?: StateValue<CSSProperties | undefined, FieldState>;
|
|
8
15
|
/**
|
|
9
|
-
* Rendered only while `state.invalid`.
|
|
10
|
-
*
|
|
16
|
+
* Rendered only while `state.invalid`. A function gets the state:
|
|
17
|
+
* `({ validity, messages }) => validity.valueMissing ? "Enter your email" : messages.join(" ")`.
|
|
11
18
|
* Must not suspend (urgent render, design 2.4).
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue `state.messages` joined by a space
|
|
12
21
|
*/
|
|
13
22
|
children?: StateValue<ReactNode, FieldState>;
|
|
23
|
+
/** Replace the default `<div>` (element form) or take over rendering (function form). */
|
|
14
24
|
render?: RenderProp<ComponentPropsWithRef<"div">, FieldState>;
|
|
15
25
|
}
|
|
16
26
|
/**
|
|
@@ -21,6 +31,8 @@ export interface FieldErrorProps extends Omit<ComponentPropsWithRef<"div">, "id"
|
|
|
21
31
|
*
|
|
22
32
|
* Owned keys (conventions 1.2): `id`, `data-invalid`, `data-disabled`, `data-required`,
|
|
23
33
|
* `data-pending`.
|
|
34
|
+
*
|
|
35
|
+
* @see https://ui.funstack.work/components/field
|
|
24
36
|
*/
|
|
25
37
|
export declare function FieldError({ className, style, children, render, ...rest }: FieldErrorProps): ReactNode;
|
|
26
38
|
export declare namespace FieldError {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-error.d.mts","names":[],"sources":["../../src/field/field-error.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"field-error.d.mts","names":[],"sources":["../../src/field/field-error.tsx"],"mappings":";;;;;;;;;iBAaiB,wBAAwB,KACvC;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;;;;;;;EAQ9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;;wBAkBpC,aACd,WACA,OACA,UACA,WACG,QACF,kBAAe;yBANF"}
|
|
@@ -14,6 +14,8 @@ function defaultChildren(state) {
|
|
|
14
14
|
*
|
|
15
15
|
* Owned keys (conventions 1.2): `id`, `data-invalid`, `data-disabled`, `data-required`,
|
|
16
16
|
* `data-pending`.
|
|
17
|
+
*
|
|
18
|
+
* @see https://ui.funstack.work/components/field
|
|
17
19
|
*/
|
|
18
20
|
function FieldError({ className, style, children = defaultChildren, render, ...rest }) {
|
|
19
21
|
const ctx = useFieldContext("Field.Error");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-error.mjs","names":[],"sources":["../../src/field/field-error.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { fieldDataAttributes, useFieldContext } from \"../internal/field-context.js\";\nimport type { FieldState } from \"../internal/field-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\nexport interface FieldErrorProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, FieldState>;\n style?: StateValue<CSSProperties | undefined, FieldState>;\n /**\n * Rendered only while `state.invalid`.
|
|
1
|
+
{"version":3,"file":"field-error.mjs","names":[],"sources":["../../src/field/field-error.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { fieldDataAttributes, useFieldContext } from \"../internal/field-context.js\";\nimport type { FieldState } from \"../internal/field-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\n/**\n * Props of `Field.Error`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport interface FieldErrorProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, FieldState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, FieldState>;\n /**\n * Rendered only while `state.invalid`. A function gets the state:\n * `({ validity, messages }) => validity.valueMissing ? \"Enter your email\" : messages.join(\" \")`.\n * Must not suspend (urgent render, design 2.4).\n *\n * @defaultValue `state.messages` joined by a space\n */\n children?: StateValue<ReactNode, FieldState>;\n /** Replace the default `<div>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, FieldState>;\n}\n\nfunction defaultChildren(state: FieldState): ReactNode {\n return state.messages.join(\" \");\n}\n\n/**\n * The field's error message: a `div` rendered only while an error is shown, whose id the control\n * then lists in `aria-describedby`. No role and no live region: the library focuses the first\n * invalid control after a submission attempt, and focus reads the description (design 4.2).\n * Its presence lets the Field cancel the platform's validation bubble.\n *\n * Owned keys (conventions 1.2): `id`, `data-invalid`, `data-disabled`, `data-required`,\n * `data-pending`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport function FieldError({\n className,\n style,\n children = defaultChildren,\n render,\n ...rest\n}: FieldErrorProps) {\n const ctx = useFieldContext(\"Field.Error\");\n const { registerError } = ctx;\n useLayoutEffect(registerError, [registerError]);\n const element = useRender<ComponentPropsWithRef<\"div\">, FieldState>({\n defaultElement: \"div\",\n render,\n state: ctx.state,\n className,\n style,\n children,\n props: rest,\n libraryProps: { id: ctx.ids.error, ...fieldDataAttributes(ctx.state) },\n });\n return ctx.state.invalid ? element : null;\n}\n\nFieldError.displayName = \"FieldError\";\n"],"mappings":";;;;;AAiCA,SAAS,gBAAgB,OAA8B;CACrD,OAAO,MAAM,SAAS,KAAK,GAAG;AAChC;;;;;;;;;;;;AAaA,SAAgB,WAAW,EACzB,WACA,OACA,WAAW,iBACX,QACA,GAAG,QACe;CAClB,MAAM,MAAM,gBAAgB,aAAa;CACzC,MAAM,EAAE,kBAAkB;CAC1B,gBAAgB,eAAe,CAAC,aAAa,CAAC;CAC9C,MAAM,UAAU,UAAoD;EAClE,gBAAgB;EAChB;EACA,OAAO,IAAI;EACX;EACA;EACA;EACA,OAAO;EACP,cAAc;GAAE,IAAI,IAAI,IAAI;GAAO,GAAG,oBAAoB,IAAI,KAAK;EAAE;CACvE,CAAC;CACD,OAAO,IAAI,MAAM,UAAU,UAAU;AACvC;AAEA,WAAW,cAAc"}
|
|
@@ -2,9 +2,17 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { FieldState } from "../internal/field-context.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/field/field-label.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props of `Field.Label`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ui.funstack.work/components/field
|
|
9
|
+
*/
|
|
5
10
|
export interface FieldLabelProps extends Omit<ComponentPropsWithRef<"label">, "htmlFor" | "id" | "className" | "style" | "children"> {
|
|
11
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
6
12
|
className?: StateValue<string | undefined, FieldState>;
|
|
13
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
7
14
|
style?: StateValue<CSSProperties | undefined, FieldState>;
|
|
15
|
+
/** Content, or a function of the part's state. */
|
|
8
16
|
children?: StateValue<ReactNode, FieldState>;
|
|
9
17
|
/** Must render a `<label>`. */
|
|
10
18
|
render?: RenderProp<ComponentPropsWithRef<"label">, FieldState>;
|
|
@@ -16,6 +24,8 @@ export interface FieldLabelProps extends Omit<ComponentPropsWithRef<"label">, "h
|
|
|
16
24
|
*
|
|
17
25
|
* Owned keys (conventions 1.2): `id`, `htmlFor`, `data-invalid`, `data-disabled`,
|
|
18
26
|
* `data-required`, `data-pending`.
|
|
27
|
+
*
|
|
28
|
+
* @see https://ui.funstack.work/components/field
|
|
19
29
|
*/
|
|
20
30
|
export declare function FieldLabel({ className, style, children, render, ...rest }: FieldLabelProps): ReactNode;
|
|
21
31
|
export declare namespace FieldLabel {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-label.d.mts","names":[],"sources":["../../src/field/field-label.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"field-label.d.mts","names":[],"sources":["../../src/field/field-label.tsx"],"mappings":";;;;;;;;;iBAeiB,wBAAwB,KACvC;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,gCAAgC;;;;;;;;;;;;wBAatC,aAAa,WAAW,OAAO,UAAU,WAAW,QAAQ,kBAAe;yBAA3E"}
|
|
@@ -11,6 +11,8 @@ const isDev = process.env.NODE_ENV !== "production";
|
|
|
11
11
|
*
|
|
12
12
|
* Owned keys (conventions 1.2): `id`, `htmlFor`, `data-invalid`, `data-disabled`,
|
|
13
13
|
* `data-required`, `data-pending`.
|
|
14
|
+
*
|
|
15
|
+
* @see https://ui.funstack.work/components/field
|
|
14
16
|
*/
|
|
15
17
|
function FieldLabel({ className, style, children, render, ...rest }) {
|
|
16
18
|
const ctx = useFieldContext("Field.Label");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-label.mjs","names":[],"sources":["../../src/field/field-label.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { fieldDataAttributes, useFieldContext } from \"../internal/field-context.js\";\nimport type { FieldState } from \"../internal/field-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface FieldLabelProps extends Omit<\n ComponentPropsWithRef<\"label\">,\n \"htmlFor\" | \"id\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, FieldState>;\n style?: StateValue<CSSProperties | undefined, FieldState>;\n children?: StateValue<ReactNode, FieldState>;\n /** Must render a `<label>`. */\n render?: RenderProp<ComponentPropsWithRef<\"label\">, FieldState>;\n}\n\n/**\n * The field's visible name: `<label for>` pointing at the control. For a group control (a\n * RadioGroup or CheckboxGroup `<fieldset>`) it renders no `for` once the group registered, and\n * the group names itself with `aria-labelledby` → this id (design 4.2).\n *\n * Owned keys (conventions 1.2): `id`, `htmlFor`, `data-invalid`, `data-disabled`,\n * `data-required`, `data-pending`.\n */\nexport function FieldLabel({ className, style, children, render, ...rest }: FieldLabelProps) {\n const ctx = useFieldContext(\"Field.Label\");\n const ref = useElementCheck(\n isDev &&\n ((el) =>\n el.tagName !== \"LABEL\"\n ? `Field.Label: expected to render a <label> element but got <${el.tagName.toLowerCase()}>. ` +\n \"Label activation and the control's accessible name need a real <label>.\"\n : null),\n );\n return useRender<ComponentPropsWithRef<\"label\">, FieldState>({\n defaultElement: \"label\",\n render,\n state: ctx.state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n id: ctx.ids.label,\n htmlFor: ctx.labelable ? ctx.ids.control : undefined,\n ...fieldDataAttributes(ctx.state),\n },\n ref,\n });\n}\n\nFieldLabel.displayName = \"FieldLabel\";\n"],"mappings":";;;;;AAQA,MAAM,QAAQ,QAAQ,IAAI,aAAa
|
|
1
|
+
{"version":3,"file":"field-label.mjs","names":[],"sources":["../../src/field/field-label.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { fieldDataAttributes, useFieldContext } from \"../internal/field-context.js\";\nimport type { FieldState } from \"../internal/field-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Props of `Field.Label`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport interface FieldLabelProps extends Omit<\n ComponentPropsWithRef<\"label\">,\n \"htmlFor\" | \"id\" | \"className\" | \"style\" | \"children\"\n> {\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, FieldState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, FieldState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, FieldState>;\n /** Must render a `<label>`. */\n render?: RenderProp<ComponentPropsWithRef<\"label\">, FieldState>;\n}\n\n/**\n * The field's visible name: `<label for>` pointing at the control. For a group control (a\n * RadioGroup or CheckboxGroup `<fieldset>`) it renders no `for` once the group registered, and\n * the group names itself with `aria-labelledby` → this id (design 4.2).\n *\n * Owned keys (conventions 1.2): `id`, `htmlFor`, `data-invalid`, `data-disabled`,\n * `data-required`, `data-pending`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport function FieldLabel({ className, style, children, render, ...rest }: FieldLabelProps) {\n const ctx = useFieldContext(\"Field.Label\");\n const ref = useElementCheck(\n isDev &&\n ((el) =>\n el.tagName !== \"LABEL\"\n ? `Field.Label: expected to render a <label> element but got <${el.tagName.toLowerCase()}>. ` +\n \"Label activation and the control's accessible name need a real <label>.\"\n : null),\n );\n return useRender<ComponentPropsWithRef<\"label\">, FieldState>({\n defaultElement: \"label\",\n render,\n state: ctx.state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n id: ctx.ids.label,\n htmlFor: ctx.labelable ? ctx.ids.control : undefined,\n ...fieldDataAttributes(ctx.state),\n },\n ref,\n });\n}\n\nFieldLabel.displayName = \"FieldLabel\";\n"],"mappings":";;;;;AAQA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;AA+BvC,SAAgB,WAAW,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QAAyB;CAC3F,MAAM,MAAM,gBAAgB,aAAa;CACzC,MAAM,MAAM,gBACV,WACI,OACA,GAAG,YAAY,UACX,8DAA8D,GAAG,QAAQ,YAAY,EAAE,8EAEvF,KACV;CACA,OAAO,UAAsD;EAC3D,gBAAgB;EAChB;EACA,OAAO,IAAI;EACX;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,IAAI,IAAI,IAAI;GACZ,SAAS,IAAI,YAAY,IAAI,IAAI,UAAU,KAAA;GAC3C,GAAG,oBAAoB,IAAI,KAAK;EAClC;EACA;CACF,CAAC;AACH;AAEA,WAAW,cAAc"}
|
|
@@ -9,12 +9,25 @@ import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
|
9
9
|
* `null` / `undefined` / `""` for none.
|
|
10
10
|
*/
|
|
11
11
|
export type FieldValidate = (value: string, formData: FormData) => FieldErrorValue;
|
|
12
|
+
/**
|
|
13
|
+
* Props of `Field.Root`.
|
|
14
|
+
*
|
|
15
|
+
* @see https://ui.funstack.work/components/field
|
|
16
|
+
*/
|
|
12
17
|
export interface FieldRootProps extends Omit<ComponentPropsWithRef<"div">, "className" | "style" | "children"> {
|
|
13
18
|
/** Form field name: the control's default `name`, the key in `Form.Root errors`, and the entry `validate` reads. */
|
|
14
19
|
name?: string;
|
|
15
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Disables the control (native `disabled`) and marks every part `data-disabled`.
|
|
22
|
+
*
|
|
23
|
+
* @defaultValue `false`
|
|
24
|
+
*/
|
|
16
25
|
disabled?: boolean;
|
|
17
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Makes the control `required` (native) and marks every part `data-required`.
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue `false`
|
|
30
|
+
*/
|
|
18
31
|
required?: boolean;
|
|
19
32
|
/**
|
|
20
33
|
* A custom constraint, written into the control with `setCustomValidity`. Sync. Receives the
|
|
@@ -30,9 +43,13 @@ export interface FieldRootProps extends Omit<ComponentPropsWithRef<"div">, "clas
|
|
|
30
43
|
* `validate` is rendered from a client component.
|
|
31
44
|
*/
|
|
32
45
|
validate?: FieldValidate;
|
|
46
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
33
47
|
className?: StateValue<string | undefined, FieldState>;
|
|
48
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
34
49
|
style?: StateValue<CSSProperties | undefined, FieldState>;
|
|
50
|
+
/** Content, or a function of the part's state. */
|
|
35
51
|
children?: StateValue<ReactNode, FieldState>;
|
|
52
|
+
/** Replace the default `<div>` (element form) or take over rendering (function form). */
|
|
36
53
|
render?: RenderProp<ComponentPropsWithRef<"div">, FieldState>;
|
|
37
54
|
}
|
|
38
55
|
/**
|
|
@@ -43,6 +60,8 @@ export interface FieldRootProps extends Omit<ComponentPropsWithRef<"div">, "clas
|
|
|
43
60
|
* Field has no action of its own.
|
|
44
61
|
*
|
|
45
62
|
* Owned keys (conventions 1.2): `data-invalid`, `data-disabled`, `data-required`, `data-pending`.
|
|
63
|
+
*
|
|
64
|
+
* @see https://ui.funstack.work/components/field
|
|
46
65
|
*/
|
|
47
66
|
export declare function FieldRoot({ name, disabled, required, validate, className, style, children, render, ...rest }: FieldRootProps): import("react").JSX.Element;
|
|
48
67
|
export declare namespace FieldRoot {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-root.d.mts","names":[],"sources":["../../src/field/field-root.tsx"],"mappings":";;;;;;;;;;YAiDY,iBAAiB,eAAe,UAAU,aAAa
|
|
1
|
+
{"version":3,"file":"field-root.d.mts","names":[],"sources":["../../src/field/field-root.tsx"],"mappings":";;;;;;;;;;YAiDY,iBAAiB,eAAe,UAAU,aAAa;;;;;;iBAOlD,uBAAuB,KACtC;;EAIA;;;;;;EAMA;;;;;;EAMA;;;;;;;;;;;;;;EAcA,WAAW;;EAEX,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;;wBA4CpC,YACd,MACA,UACA,UACA,UACA,WACA,OACA,UACA,WACG,QACF,iCAAc,IAAA;yBAVD"}
|
|
@@ -34,6 +34,8 @@ function entryStrings(entries) {
|
|
|
34
34
|
* Field has no action of its own.
|
|
35
35
|
*
|
|
36
36
|
* Owned keys (conventions 1.2): `data-invalid`, `data-disabled`, `data-required`, `data-pending`.
|
|
37
|
+
*
|
|
38
|
+
* @see https://ui.funstack.work/components/field
|
|
37
39
|
*/
|
|
38
40
|
function FieldRoot({ name, disabled = false, required = false, validate, className, style, children, render, ...rest }) {
|
|
39
41
|
const parent = use(FieldContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-root.mjs","names":[],"sources":["../../src/field/field-root.tsx"],"sourcesContent":["\"use client\";\nimport {\n use,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode, RefObject } from \"react\";\nimport { useFormStatus } from \"react-dom\";\nimport { FieldContext, fieldDataAttributes, FormContext } from \"../internal/field-context.js\";\nimport type {\n FieldContextValue,\n FieldControlRegistration,\n FieldState,\n FormFieldRegistration,\n} from \"../internal/field-context.js\";\nimport { collectInvalid } from \"../internal/focus-first-invalid.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useFormOwnerEvent } from \"../internal/use-form-owner-event.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useServerErrorVisibility } from \"./use-server-error-visibility.js\";\nimport {\n focusTargetOf,\n normaliseErrorValue,\n snapshotValidity,\n supportsUserInvalid,\n VALID,\n validityElementOf,\n validityEquals,\n} from \"../internal/validity.js\";\nimport type { FieldErrorValue, FieldValidity, ValidatableElement } from \"../internal/validity.js\";\nimport { arraysEqual } from \"../internal/value-set.js\";\n\nexport type { FieldState } from \"../internal/field-context.js\";\nexport type { FieldValidity } from \"../internal/validity.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * A custom constraint: receives the field's submitted value (`formData.get(name)` as a string,\n * `\"\"` when absent) and the whole form's `FormData`. Return a message (or several) for an error,\n * `null` / `undefined` / `\"\"` for none.\n */\nexport type FieldValidate = (value: string, formData: FormData) => FieldErrorValue;\n\nexport interface FieldRootProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"className\" | \"style\" | \"children\"\n> {\n /** Form field name: the control's default `name`, the key in `Form.Root errors`, and the entry `validate` reads. */\n name?: string;\n /** Disables the control (native `disabled`) and marks every part `data-disabled`. */\n disabled?: boolean;\n /** Makes the control `required` (native) and marks every part `data-required`. */\n required?: boolean;\n /**\n * A custom constraint, written into the control with `setCustomValidity`. Sync. Receives the\n * field's submitted value (`formData.get(name)` as a string, `\"\"` when absent) and the whole\n * form's `FormData`, so a cross-field rule can read the other field. Runs at mount, on every\n * `input` / `change` in the form (and a FUNSTACK control's value change), on blur, after a\n * reset, on a submission attempt, and in every commit in which this prop changed identity, so\n * a rule that reads outside state (a list that loads, a sibling value in React state) updates\n * on render. An inline function therefore re-runs on every render of the Field; wrap it in\n * `useCallback` to re-run only when its inputs change. Return a string\n * or strings for an error, `null` / `undefined` / `\"\"` for none. Shown when the platform's\n * `:user-invalid` heuristic says so, like a native constraint. Not serialisable: a Field with\n * `validate` is rendered from a client component.\n */\n validate?: FieldValidate;\n className?: StateValue<string | undefined, FieldState>;\n style?: StateValue<CSSProperties | undefined, FieldState>;\n children?: StateValue<ReactNode, FieldState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, FieldState>;\n}\n\n/** The urgent mirror of browser-owned validity (design 2.4). */\ninterface Mirror {\n readonly userInvalid: boolean;\n readonly validity: FieldValidity;\n readonly messages: readonly string[];\n}\n\nconst NONE: readonly string[] = Object.freeze([]);\nconst INITIAL_MIRROR: Mirror = { userInvalid: false, validity: VALID, messages: NONE };\n\ninterface RefreshOptions {\n /** The user edited the control: the server message is dropped from the slot at once. */\n readonly dismiss?: boolean;\n /** After a form reset: the user-validity flag is clear again. */\n readonly reset?: boolean;\n}\n\nfunction mirrorEquals(a: Mirror, b: Mirror): boolean {\n return (\n a.userInvalid === b.userInvalid &&\n validityEquals(a.validity, b.validity) &&\n arraysEqual(a.messages, b.messages)\n );\n}\n\n/** `FormData` entries as comparable strings; a `File` counts as unchanged (design 3.2 item 2). */\nfunction entryStrings(entries: readonly FormDataEntryValue[]): string[] {\n return entries.map((entry) => (typeof entry === \"string\" ? entry : \"\\u0000file\"));\n}\n\n/**\n * The field: a `div` that owns the ids, the urgent validity mirror, the custom-validity slot\n * (`validate` and the server error), the control registration and the native listeners\n * (design/components/field-form.md 2, 14). `data-pending` is the enclosing form's submission\n * (`useFormStatus`), the one part that folds the form channel into its own state, because a\n * Field has no action of its own.\n *\n * Owned keys (conventions 1.2): `data-invalid`, `data-disabled`, `data-required`, `data-pending`.\n */\nexport function FieldRoot({\n name,\n disabled = false,\n required = false,\n validate,\n className,\n style,\n children,\n render,\n ...rest\n}: FieldRootProps) {\n const parent = use(FieldContext);\n const form = use(FormContext);\n useDevWarning(\n parent !== null,\n isDev &&\n \"Field.Root: nested inside another Field.Root. A control registers with the nearest Field \" +\n \"only; give each control its own, sibling Field.\",\n );\n useDevWarning(\n validate !== undefined && name === undefined,\n isDev &&\n \"Field.Root: `validate` without `name`. `validate` receives `formData.get(name)`, which is \" +\n 'always \"\" without a name.',\n );\n\n const id = useId();\n const ids = useMemo(\n () => ({\n control: `${id}-control`,\n label: `${id}-label`,\n description: `${id}-description`,\n error: `${id}-error`,\n }),\n [id],\n );\n\n const { pending: formPending } = useFormStatus();\n\n // --- Registration -------------------------------------------------------------------------\n\n const controlRef = useRef<FieldControlRegistration | null>(null);\n const [control, setControl] = useState<FieldControlRegistration | null>(null);\n const warnedTwoControls = useRef(false);\n const registerControl = useCallback((registration: FieldControlRegistration) => {\n const current = controlRef.current;\n if (current !== null && current.element !== registration.element) {\n if (isDev && !warnedTwoControls.current) {\n warnedTwoControls.current = true;\n console.error(\n \"Field.Root: two form controls registered in one Field. The first one is the \" +\n \"Field's control; give each control its own Field.Root.\",\n );\n }\n return () => {};\n }\n controlRef.current = registration;\n setControl(registration);\n return () => {\n if (controlRef.current !== registration) return;\n controlRef.current = null;\n setControl(null);\n };\n }, []);\n\n const errorCount = useRef(0);\n const registerError = useCallback(() => {\n errorCount.current += 1;\n if (isDev && errorCount.current === 2) {\n console.error(\n \"Field.Error: two Field.Error parts in one Field.Root. Render one; its function \" +\n \"`children` receives `validity` for per-constraint wording.\",\n );\n }\n return () => {\n errorCount.current -= 1;\n };\n }, []);\n\n // --- Server errors: shown, dismissed, re-armed, suppressed (design 3.4) -------------------\n\n const errors = form?.errors;\n const serverMessages = useMemo(\n () => normaliseErrorValue(name === undefined ? undefined : errors?.[name]),\n [errors, name],\n );\n const serverKey = serverMessages.join(\"\\n\");\n const { serverShown, dismiss, setSuppressNext } = useServerErrorVisibility(\n formPending,\n serverMessages,\n );\n\n // --- The mirror -----------------------------------------------------------------------------\n\n const [mirror, setMirror] = useState<Mirror>(INITIAL_MIRROR);\n /** The last mirror written: `refresh` compares against it, so an unchanged read renders nothing. */\n const mirrorRef = useRef<Mirror>(INITIAL_MIRROR);\n /** jsdom fallback for `:user-invalid` (design 2.2): `invalid` fired, cleared by a reset. */\n const attempted = useRef(false);\n /** The element the slot was last written on (a group's first member can change). */\n const slotElement = useRef<ValidatableElement | null>(null);\n\n const latest = useLatest({ name, validate, serverMessages, serverShown, formPending, form });\n\n /** Re-reads the slot and the mirror; returns the messages the Field shows for the control. */\n const refresh = useCallback(\n (options: RefreshOptions = {}): readonly string[] => {\n const registration = controlRef.current;\n if (registration === null) return NONE;\n // The element whose validity is real (field-form.md, `validityElement`) and the\n // element whose `:user-invalid` the user's interaction sets; the same for every control but\n // NumberField.\n const surface = validityElementOf(registration.element);\n const el = registration.validityElement?.() ?? surface;\n if (el === null) return NONE;\n const { name, validate, serverMessages, serverShown, formPending, form } = latest.current;\n\n const owner = el.form;\n const formData = owner === null ? new FormData() : new FormData(owner);\n const entry = name === undefined ? null : formData.get(name);\n const value = typeof entry === \"string\" ? entry : \"\";\n const custom = validate === undefined ? NONE : normaliseErrorValue(validate(value, formData));\n\n // The slot (design 2.1): the server message while shown, else `validate`'s.\n const showServer = serverShown && options.dismiss !== true;\n if (slotElement.current !== null && slotElement.current !== el) {\n slotElement.current.setCustomValidity(\"\");\n }\n slotElement.current = el;\n el.setCustomValidity(showServer ? serverMessages.join(\"\\n\") : custom.join(\"\\n\"));\n // Mirror onto the surface so its `:user-invalid` read below sees the new state (the control\n // writes the same derived value after each of its own writes).\n if (\n surface !== null &&\n surface !== el &&\n surface.validationMessage !== el.validationMessage\n ) {\n surface.setCustomValidity(el.validationMessage);\n }\n\n if (options.reset === true) attempted.current = false;\n const userInvalid = supportsUserInvalid()\n ? (surface ?? el).matches(\":user-invalid\")\n : attempted.current && !el.validity.valid;\n const validity = snapshotValidity(el.validity);\n const messages = validity.valid\n ? NONE\n : validity.customError && !showServer && custom.length > 0\n ? custom\n : el.validationMessage === \"\"\n ? NONE\n : [el.validationMessage];\n const next: Mirror = { userInvalid, validity, messages };\n // Only a change schedules a render (a `focusout` with nothing new causes none).\n if (!mirrorEquals(mirrorRef.current, next)) {\n mirrorRef.current = next;\n setMirror(next);\n }\n\n // Stale-value suppression (design 3.2 item 2): while the Form's own submission is in\n // flight, an error is about the value it sent; compare with what the field holds now.\n const submitted = formPending && name !== undefined ? (form?.submittedData() ?? null) : null;\n if (submitted !== null && name !== undefined) {\n setSuppressNext(\n !arraysEqual(entryStrings(formData.getAll(name)), entryStrings(submitted.getAll(name))),\n );\n }\n return showServer ? serverMessages : messages;\n },\n [latest, setSuppressNext],\n );\n\n // The slot follows the server error and `validate` (and is written once the control is known).\n // Keyed on `validate`'s identity (design 2.1): a rule reading outside state updates in the\n // commit that changed it. An inline function re-runs on every render (documented: `useCallback`\n // avoids it); the form's own values are covered by the listeners below.\n useLayoutEffect(() => {\n refresh();\n }, [refresh, control, serverShown, serverKey, validate]);\n\n // Clear the slot when the control goes away (it may be reused outside the Field).\n useLayoutEffect(\n () => () => {\n slotElement.current?.setCustomValidity(\"\");\n slotElement.current = null;\n },\n [],\n );\n\n // The control's own events (capture, so a group's members are seen on its fieldset).\n const element = control?.element ?? null;\n useLayoutEffect(() => {\n if (element === null) return;\n const onEdit = () => {\n dismiss();\n refresh({ dismiss: true });\n };\n const onBlur = () => refresh();\n const onInvalid = (event: Event) => {\n const target = event.target as ValidatableElement;\n // A submission attempt sets user validity before validating; `checkValidity()` and\n // `reportValidity()` do not (design 2.5). The fallback cannot tell them apart.\n const attempt = supportsUserInvalid() ? target.matches(\":user-invalid\") : true;\n if (!supportsUserInvalid()) attempted.current = true;\n if (attempt && errorCount.current > 0) {\n event.preventDefault();\n const messages = refresh();\n collectInvalid(focusTargetOf(element), messages.join(\" \"), target);\n return;\n }\n refresh();\n };\n element.addEventListener(\"input\", onEdit, true);\n element.addEventListener(\"change\", onEdit, true);\n element.addEventListener(\"focusout\", onBlur, true);\n element.addEventListener(\"invalid\", onInvalid, true);\n return () => {\n element.removeEventListener(\"input\", onEdit, true);\n element.removeEventListener(\"change\", onEdit, true);\n element.removeEventListener(\"focusout\", onBlur, true);\n element.removeEventListener(\"invalid\", onInvalid, true);\n };\n }, [element, refresh, dismiss]);\n\n // The form owner's events: another field's edit re-runs `validate` (cross-field rules); a reset\n // clears the user-validity flag, re-read when the controls hold their reset values.\n const ownerRef = useMemo<RefObject<Element | null>>(\n () => ({\n get current() {\n return controlRef.current?.element ?? null;\n },\n set current(_ignored) {},\n }),\n [],\n );\n const onOwnerEdit = (event: Event) => {\n const target = event.target;\n if (target instanceof Node && controlRef.current?.element.contains(target) === true) return;\n refresh();\n };\n useFormOwnerEvent(ownerRef, \"input\", onOwnerEdit);\n useFormOwnerEvent(ownerRef, \"change\", onOwnerEdit);\n // A new submission sends the current values: nothing differs from it yet (a queued second\n // submit arrives while the status stays pending, so the pending edge alone would miss it).\n useFormOwnerEvent(ownerRef, \"submit\", () => {\n setSuppressNext(false);\n });\n useFormOwnerEvent(ownerRef, \"reset\", (event) => {\n queueMicrotask(() => {\n if (event.defaultPrevented) return;\n refresh({ reset: true });\n });\n });\n\n // Registration with the Form, for the first-error focus after a settle (design 3.5) and the\n // refresh of the other Fields on a change no DOM event carried.\n const registerField = form?.registerField;\n const formRegistration = useRef<FormFieldRegistration | null>(null);\n useLayoutEffect(() => {\n if (registerField === undefined) return;\n const registration: FormFieldRegistration = {\n getFocusTarget: () => focusTargetOf(controlRef.current?.element ?? null),\n showsServerError: () => latest.current.serverShown,\n serverMessages: () => latest.current.serverMessages,\n refresh: () => {\n refresh();\n },\n };\n formRegistration.current = registration;\n const unregister = registerField(registration);\n return () => {\n unregister();\n if (formRegistration.current === registration) formRegistration.current = null;\n };\n }, [registerField, latest, refresh]);\n\n const notifyChange = useCallback(\n (edit: boolean) => {\n if (edit) dismiss();\n refresh(edit ? { dismiss: true } : {});\n latest.current.form?.refreshFields(formRegistration.current);\n },\n [refresh, latest, dismiss],\n );\n\n // Development: a Field around something that is not a form control (Toggle, Menu, ...).\n useEffect(() => {\n if (!isDev || controlRef.current !== null) return;\n console.error(\n \"Field.Root: no form control registered. Render a Field.Control or a FUNSTACK form \" +\n \"control (Checkbox, Switch, RadioGroup, CheckboxGroup, Select, Combobox, Slider, \" +\n \"NumberField) inside it.\",\n );\n }, []);\n\n const invalid = mirror.userInvalid || serverShown;\n const messages = serverShown ? serverMessages : mirror.userInvalid ? mirror.messages : NONE;\n const validity = mirror.validity;\n const stateDisabled = disabled || (control?.disabled ?? false);\n const stateRequired = required || (control?.required ?? false);\n // Memoised: the context value (and so every part) changes only with the state.\n const memoState = useMemo<FieldState>(\n () => ({\n invalid,\n messages,\n validity,\n disabled: stateDisabled,\n required: stateRequired,\n pending: formPending,\n }),\n [invalid, messages, validity, stateDisabled, stateRequired, formPending],\n );\n\n const labelable = control?.labelable ?? true;\n const context = useMemo<FieldContextValue>(\n () => ({\n ids,\n name,\n disabled,\n required,\n state: memoState,\n labelable,\n registerControl,\n registerError,\n notifyChange,\n }),\n [\n ids,\n name,\n disabled,\n required,\n memoState,\n labelable,\n registerControl,\n registerError,\n notifyChange,\n ],\n );\n\n const element$ = useRender<ComponentPropsWithRef<\"div\">, FieldState>({\n defaultElement: \"div\",\n render,\n state: memoState,\n className,\n style,\n children,\n props: rest,\n libraryProps: fieldDataAttributes(memoState),\n });\n\n return <FieldContext value={context}>{element$}</FieldContext>;\n}\n\nFieldRoot.displayName = \"FieldRoot\";\n"],"mappings":";;;;;;;;;;;;;;AA0CA,M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AM,UAAU,eACP;EACL;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,WAAW,UAAoD;EACnE,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc,oBAAoB,SAAS;CAC7C,CAAC;CAED,OAAO,oBAAC,cAAD;EAAc,OAAO;EAAU,UAAA;CAAuB,CAAA;AAC/D;AAEA,UAAU,cAAc"}
|
|
1
|
+
{"version":3,"file":"field-root.mjs","names":[],"sources":["../../src/field/field-root.tsx"],"sourcesContent":["\"use client\";\nimport {\n use,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode, RefObject } from \"react\";\nimport { useFormStatus } from \"react-dom\";\nimport { FieldContext, fieldDataAttributes, FormContext } from \"../internal/field-context.js\";\nimport type {\n FieldContextValue,\n FieldControlRegistration,\n FieldState,\n FormFieldRegistration,\n} from \"../internal/field-context.js\";\nimport { collectInvalid } from \"../internal/focus-first-invalid.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useFormOwnerEvent } from \"../internal/use-form-owner-event.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useServerErrorVisibility } from \"./use-server-error-visibility.js\";\nimport {\n focusTargetOf,\n normaliseErrorValue,\n snapshotValidity,\n supportsUserInvalid,\n VALID,\n validityElementOf,\n validityEquals,\n} from \"../internal/validity.js\";\nimport type { FieldErrorValue, FieldValidity, ValidatableElement } from \"../internal/validity.js\";\nimport { arraysEqual } from \"../internal/value-set.js\";\n\nexport type { FieldState } from \"../internal/field-context.js\";\nexport type { FieldValidity } from \"../internal/validity.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * A custom constraint: receives the field's submitted value (`formData.get(name)` as a string,\n * `\"\"` when absent) and the whole form's `FormData`. Return a message (or several) for an error,\n * `null` / `undefined` / `\"\"` for none.\n */\nexport type FieldValidate = (value: string, formData: FormData) => FieldErrorValue;\n\n/**\n * Props of `Field.Root`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport interface FieldRootProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"className\" | \"style\" | \"children\"\n> {\n /** Form field name: the control's default `name`, the key in `Form.Root errors`, and the entry `validate` reads. */\n name?: string;\n /**\n * Disables the control (native `disabled`) and marks every part `data-disabled`.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /**\n * Makes the control `required` (native) and marks every part `data-required`.\n *\n * @defaultValue `false`\n */\n required?: boolean;\n /**\n * A custom constraint, written into the control with `setCustomValidity`. Sync. Receives the\n * field's submitted value (`formData.get(name)` as a string, `\"\"` when absent) and the whole\n * form's `FormData`, so a cross-field rule can read the other field. Runs at mount, on every\n * `input` / `change` in the form (and a FUNSTACK control's value change), on blur, after a\n * reset, on a submission attempt, and in every commit in which this prop changed identity, so\n * a rule that reads outside state (a list that loads, a sibling value in React state) updates\n * on render. An inline function therefore re-runs on every render of the Field; wrap it in\n * `useCallback` to re-run only when its inputs change. Return a string\n * or strings for an error, `null` / `undefined` / `\"\"` for none. Shown when the platform's\n * `:user-invalid` heuristic says so, like a native constraint. Not serialisable: a Field with\n * `validate` is rendered from a client component.\n */\n validate?: FieldValidate;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, FieldState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, FieldState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, FieldState>;\n /** Replace the default `<div>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, FieldState>;\n}\n\n/** The urgent mirror of browser-owned validity (design 2.4). */\ninterface Mirror {\n readonly userInvalid: boolean;\n readonly validity: FieldValidity;\n readonly messages: readonly string[];\n}\n\nconst NONE: readonly string[] = Object.freeze([]);\nconst INITIAL_MIRROR: Mirror = { userInvalid: false, validity: VALID, messages: NONE };\n\ninterface RefreshOptions {\n /** The user edited the control: the server message is dropped from the slot at once. */\n readonly dismiss?: boolean;\n /** After a form reset: the user-validity flag is clear again. */\n readonly reset?: boolean;\n}\n\nfunction mirrorEquals(a: Mirror, b: Mirror): boolean {\n return (\n a.userInvalid === b.userInvalid &&\n validityEquals(a.validity, b.validity) &&\n arraysEqual(a.messages, b.messages)\n );\n}\n\n/** `FormData` entries as comparable strings; a `File` counts as unchanged (design 3.2 item 2). */\nfunction entryStrings(entries: readonly FormDataEntryValue[]): string[] {\n return entries.map((entry) => (typeof entry === \"string\" ? entry : \"\\u0000file\"));\n}\n\n/**\n * The field: a `div` that owns the ids, the urgent validity mirror, the custom-validity slot\n * (`validate` and the server error), the control registration and the native listeners\n * (design/components/field-form.md 2, 14). `data-pending` is the enclosing form's submission\n * (`useFormStatus`), the one part that folds the form channel into its own state, because a\n * Field has no action of its own.\n *\n * Owned keys (conventions 1.2): `data-invalid`, `data-disabled`, `data-required`, `data-pending`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport function FieldRoot({\n name,\n disabled = false,\n required = false,\n validate,\n className,\n style,\n children,\n render,\n ...rest\n}: FieldRootProps) {\n const parent = use(FieldContext);\n const form = use(FormContext);\n useDevWarning(\n parent !== null,\n isDev &&\n \"Field.Root: nested inside another Field.Root. A control registers with the nearest Field \" +\n \"only; give each control its own, sibling Field.\",\n );\n useDevWarning(\n validate !== undefined && name === undefined,\n isDev &&\n \"Field.Root: `validate` without `name`. `validate` receives `formData.get(name)`, which is \" +\n 'always \"\" without a name.',\n );\n\n const id = useId();\n const ids = useMemo(\n () => ({\n control: `${id}-control`,\n label: `${id}-label`,\n description: `${id}-description`,\n error: `${id}-error`,\n }),\n [id],\n );\n\n const { pending: formPending } = useFormStatus();\n\n // --- Registration -------------------------------------------------------------------------\n\n const controlRef = useRef<FieldControlRegistration | null>(null);\n const [control, setControl] = useState<FieldControlRegistration | null>(null);\n const warnedTwoControls = useRef(false);\n const registerControl = useCallback((registration: FieldControlRegistration) => {\n const current = controlRef.current;\n if (current !== null && current.element !== registration.element) {\n if (isDev && !warnedTwoControls.current) {\n warnedTwoControls.current = true;\n console.error(\n \"Field.Root: two form controls registered in one Field. The first one is the \" +\n \"Field's control; give each control its own Field.Root.\",\n );\n }\n return () => {};\n }\n controlRef.current = registration;\n setControl(registration);\n return () => {\n if (controlRef.current !== registration) return;\n controlRef.current = null;\n setControl(null);\n };\n }, []);\n\n const errorCount = useRef(0);\n const registerError = useCallback(() => {\n errorCount.current += 1;\n if (isDev && errorCount.current === 2) {\n console.error(\n \"Field.Error: two Field.Error parts in one Field.Root. Render one; its function \" +\n \"`children` receives `validity` for per-constraint wording.\",\n );\n }\n return () => {\n errorCount.current -= 1;\n };\n }, []);\n\n // --- Server errors: shown, dismissed, re-armed, suppressed (design 3.4) -------------------\n\n const errors = form?.errors;\n const serverMessages = useMemo(\n () => normaliseErrorValue(name === undefined ? undefined : errors?.[name]),\n [errors, name],\n );\n const serverKey = serverMessages.join(\"\\n\");\n const { serverShown, dismiss, setSuppressNext } = useServerErrorVisibility(\n formPending,\n serverMessages,\n );\n\n // --- The mirror -----------------------------------------------------------------------------\n\n const [mirror, setMirror] = useState<Mirror>(INITIAL_MIRROR);\n /** The last mirror written: `refresh` compares against it, so an unchanged read renders nothing. */\n const mirrorRef = useRef<Mirror>(INITIAL_MIRROR);\n /** jsdom fallback for `:user-invalid` (design 2.2): `invalid` fired, cleared by a reset. */\n const attempted = useRef(false);\n /** The element the slot was last written on (a group's first member can change). */\n const slotElement = useRef<ValidatableElement | null>(null);\n\n const latest = useLatest({ name, validate, serverMessages, serverShown, formPending, form });\n\n /** Re-reads the slot and the mirror; returns the messages the Field shows for the control. */\n const refresh = useCallback(\n (options: RefreshOptions = {}): readonly string[] => {\n const registration = controlRef.current;\n if (registration === null) return NONE;\n // The element whose validity is real (field-form.md, `validityElement`) and the\n // element whose `:user-invalid` the user's interaction sets; the same for every control but\n // NumberField.\n const surface = validityElementOf(registration.element);\n const el = registration.validityElement?.() ?? surface;\n if (el === null) return NONE;\n const { name, validate, serverMessages, serverShown, formPending, form } = latest.current;\n\n const owner = el.form;\n const formData = owner === null ? new FormData() : new FormData(owner);\n const entry = name === undefined ? null : formData.get(name);\n const value = typeof entry === \"string\" ? entry : \"\";\n const custom = validate === undefined ? NONE : normaliseErrorValue(validate(value, formData));\n\n // The slot (design 2.1): the server message while shown, else `validate`'s.\n const showServer = serverShown && options.dismiss !== true;\n if (slotElement.current !== null && slotElement.current !== el) {\n slotElement.current.setCustomValidity(\"\");\n }\n slotElement.current = el;\n el.setCustomValidity(showServer ? serverMessages.join(\"\\n\") : custom.join(\"\\n\"));\n // Mirror onto the surface so its `:user-invalid` read below sees the new state (the control\n // writes the same derived value after each of its own writes).\n if (\n surface !== null &&\n surface !== el &&\n surface.validationMessage !== el.validationMessage\n ) {\n surface.setCustomValidity(el.validationMessage);\n }\n\n if (options.reset === true) attempted.current = false;\n const userInvalid = supportsUserInvalid()\n ? (surface ?? el).matches(\":user-invalid\")\n : attempted.current && !el.validity.valid;\n const validity = snapshotValidity(el.validity);\n const messages = validity.valid\n ? NONE\n : validity.customError && !showServer && custom.length > 0\n ? custom\n : el.validationMessage === \"\"\n ? NONE\n : [el.validationMessage];\n const next: Mirror = { userInvalid, validity, messages };\n // Only a change schedules a render (a `focusout` with nothing new causes none).\n if (!mirrorEquals(mirrorRef.current, next)) {\n mirrorRef.current = next;\n setMirror(next);\n }\n\n // Stale-value suppression (design 3.2 item 2): while the Form's own submission is in\n // flight, an error is about the value it sent; compare with what the field holds now.\n const submitted = formPending && name !== undefined ? (form?.submittedData() ?? null) : null;\n if (submitted !== null && name !== undefined) {\n setSuppressNext(\n !arraysEqual(entryStrings(formData.getAll(name)), entryStrings(submitted.getAll(name))),\n );\n }\n return showServer ? serverMessages : messages;\n },\n [latest, setSuppressNext],\n );\n\n // The slot follows the server error and `validate` (and is written once the control is known).\n // Keyed on `validate`'s identity (design 2.1): a rule reading outside state updates in the\n // commit that changed it. An inline function re-runs on every render (documented: `useCallback`\n // avoids it); the form's own values are covered by the listeners below.\n useLayoutEffect(() => {\n refresh();\n }, [refresh, control, serverShown, serverKey, validate]);\n\n // Clear the slot when the control goes away (it may be reused outside the Field).\n useLayoutEffect(\n () => () => {\n slotElement.current?.setCustomValidity(\"\");\n slotElement.current = null;\n },\n [],\n );\n\n // The control's own events (capture, so a group's members are seen on its fieldset).\n const element = control?.element ?? null;\n useLayoutEffect(() => {\n if (element === null) return;\n const onEdit = () => {\n dismiss();\n refresh({ dismiss: true });\n };\n const onBlur = () => refresh();\n const onInvalid = (event: Event) => {\n const target = event.target as ValidatableElement;\n // A submission attempt sets user validity before validating; `checkValidity()` and\n // `reportValidity()` do not (design 2.5). The fallback cannot tell them apart.\n const attempt = supportsUserInvalid() ? target.matches(\":user-invalid\") : true;\n if (!supportsUserInvalid()) attempted.current = true;\n if (attempt && errorCount.current > 0) {\n event.preventDefault();\n const messages = refresh();\n collectInvalid(focusTargetOf(element), messages.join(\" \"), target);\n return;\n }\n refresh();\n };\n element.addEventListener(\"input\", onEdit, true);\n element.addEventListener(\"change\", onEdit, true);\n element.addEventListener(\"focusout\", onBlur, true);\n element.addEventListener(\"invalid\", onInvalid, true);\n return () => {\n element.removeEventListener(\"input\", onEdit, true);\n element.removeEventListener(\"change\", onEdit, true);\n element.removeEventListener(\"focusout\", onBlur, true);\n element.removeEventListener(\"invalid\", onInvalid, true);\n };\n }, [element, refresh, dismiss]);\n\n // The form owner's events: another field's edit re-runs `validate` (cross-field rules); a reset\n // clears the user-validity flag, re-read when the controls hold their reset values.\n const ownerRef = useMemo<RefObject<Element | null>>(\n () => ({\n get current() {\n return controlRef.current?.element ?? null;\n },\n set current(_ignored) {},\n }),\n [],\n );\n const onOwnerEdit = (event: Event) => {\n const target = event.target;\n if (target instanceof Node && controlRef.current?.element.contains(target) === true) return;\n refresh();\n };\n useFormOwnerEvent(ownerRef, \"input\", onOwnerEdit);\n useFormOwnerEvent(ownerRef, \"change\", onOwnerEdit);\n // A new submission sends the current values: nothing differs from it yet (a queued second\n // submit arrives while the status stays pending, so the pending edge alone would miss it).\n useFormOwnerEvent(ownerRef, \"submit\", () => {\n setSuppressNext(false);\n });\n useFormOwnerEvent(ownerRef, \"reset\", (event) => {\n queueMicrotask(() => {\n if (event.defaultPrevented) return;\n refresh({ reset: true });\n });\n });\n\n // Registration with the Form, for the first-error focus after a settle (design 3.5) and the\n // refresh of the other Fields on a change no DOM event carried.\n const registerField = form?.registerField;\n const formRegistration = useRef<FormFieldRegistration | null>(null);\n useLayoutEffect(() => {\n if (registerField === undefined) return;\n const registration: FormFieldRegistration = {\n getFocusTarget: () => focusTargetOf(controlRef.current?.element ?? null),\n showsServerError: () => latest.current.serverShown,\n serverMessages: () => latest.current.serverMessages,\n refresh: () => {\n refresh();\n },\n };\n formRegistration.current = registration;\n const unregister = registerField(registration);\n return () => {\n unregister();\n if (formRegistration.current === registration) formRegistration.current = null;\n };\n }, [registerField, latest, refresh]);\n\n const notifyChange = useCallback(\n (edit: boolean) => {\n if (edit) dismiss();\n refresh(edit ? { dismiss: true } : {});\n latest.current.form?.refreshFields(formRegistration.current);\n },\n [refresh, latest, dismiss],\n );\n\n // Development: a Field around something that is not a form control (Toggle, Menu, ...).\n useEffect(() => {\n if (!isDev || controlRef.current !== null) return;\n console.error(\n \"Field.Root: no form control registered. Render a Field.Control or a FUNSTACK form \" +\n \"control (Checkbox, Switch, RadioGroup, CheckboxGroup, Select, Combobox, Slider, \" +\n \"NumberField) inside it.\",\n );\n }, []);\n\n const invalid = mirror.userInvalid || serverShown;\n const messages = serverShown ? serverMessages : mirror.userInvalid ? mirror.messages : NONE;\n const validity = mirror.validity;\n const stateDisabled = disabled || (control?.disabled ?? false);\n const stateRequired = required || (control?.required ?? false);\n // Memoised: the context value (and so every part) changes only with the state.\n const memoState = useMemo<FieldState>(\n () => ({\n invalid,\n messages,\n validity,\n disabled: stateDisabled,\n required: stateRequired,\n pending: formPending,\n }),\n [invalid, messages, validity, stateDisabled, stateRequired, formPending],\n );\n\n const labelable = control?.labelable ?? true;\n const context = useMemo<FieldContextValue>(\n () => ({\n ids,\n name,\n disabled,\n required,\n state: memoState,\n labelable,\n registerControl,\n registerError,\n notifyChange,\n }),\n [\n ids,\n name,\n disabled,\n required,\n memoState,\n labelable,\n registerControl,\n registerError,\n notifyChange,\n ],\n );\n\n const element$ = useRender<ComponentPropsWithRef<\"div\">, FieldState>({\n defaultElement: \"div\",\n render,\n state: memoState,\n className,\n style,\n children,\n props: rest,\n libraryProps: fieldDataAttributes(memoState),\n });\n\n return <FieldContext value={context}>{element$}</FieldContext>;\n}\n\nFieldRoot.displayName = \"FieldRoot\";\n"],"mappings":";;;;;;;;;;;;;;AA0CA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AA+DvC,MAAM,OAA0B,OAAO,OAAO,CAAC,CAAC;AAChD,MAAM,iBAAyB;CAAE,aAAa;CAAO,UAAU;CAAO,UAAU;AAAK;AASrF,SAAS,aAAa,GAAW,GAAoB;CACnD,OACE,EAAE,gBAAgB,EAAE,eACpB,eAAe,EAAE,UAAU,EAAE,QAAQ,KACrC,YAAY,EAAE,UAAU,EAAE,QAAQ;AAEtC;;AAGA,SAAS,aAAa,SAAkD;CACtE,OAAO,QAAQ,KAAK,UAAW,OAAO,UAAU,WAAW,QAAQ,QAAa;AAClF;;;;;;;;;;;;AAaA,SAAgB,UAAU,EACxB,MACA,WAAW,OACX,WAAW,OACX,UACA,WACA,OACA,UACA,QACA,GAAG,QACc;CACjB,MAAM,SAAS,IAAI,YAAY;CAC/B,MAAM,OAAO,IAAI,WAAW;CAC5B,cACE,WAAW,MACX,SACE,0IAEJ;CACA,cACE,aAAa,KAAA,KAAa,SAAS,KAAA,GACnC,SACE,uHAEJ;CAEA,MAAM,KAAK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AE,SAAS,KAAK,IAAI,CAAC,CAAC;EACrC,OAAO,QAAQ,MAAM,cAAc,iBAAiB,OAAO;CAC7D,GACA;EAAC;EAAS;EAAQ;CAAO,CAC3B;CAGA,gBAAgB;EACd,IAAI,CAAC,SAAS,WAAW,YAAY,MAAM;EAC3C,QAAQ,MACN,2LAGF;CACF,GAAG,CAAC,CAAC;CAEL,MAAM,UAAU,OAAO,eAAe;CACtC,MAAM,WAAW,cAAc,iBAAiB,OAAO,cAAc,OAAO,WAAW;CACvF,MAAM,WAAW,OAAO;CACxB,MAAM,gBAAgB,aAAa,SAAS,YAAY;CACxD,MAAM,gBAAgB,aAAa,SAAS,YAAY;CAExD,MAAM,YAAY,eACT;EACL;EACA;EACA;EACA,UAAU;EACV,UAAU;EACV,SAAS;CACX,IACA;EAAC;EAAS;EAAU;EAAU;EAAe;EAAe;CAAW,CACzE;CAEA,MAAM,YAAY,SAAS,aAAa;CACxC,MAAM,UAAU,eACP;EACL;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,WAAW,UAAoD;EACnE,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc,oBAAoB,SAAS;CAC7C,CAAC;CAED,OAAO,oBAAC,cAAD;EAAc,OAAO;EAAU,UAAA;CAAuB,CAAA;AAC/D;AAEA,UAAU,cAAc"}
|
package/dist/field/index.d.mts
CHANGED
|
@@ -6,6 +6,15 @@ import { FieldError, FieldErrorProps } from "./field-error.mjs";
|
|
|
6
6
|
import { FieldLabel, FieldLabelProps } from "./field-label.mjs";
|
|
7
7
|
import { FieldRoot, FieldRootProps, FieldValidate } from "./field-root.mjs";
|
|
8
8
|
//#region src/field/index.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Field (labelled, described, validated form control): `Root` (`div`, owns the ids and the field's
|
|
11
|
+
* state) > `Label` (`label[for]`), `Control` (`input`, or any FUNSTACK form control in its place),
|
|
12
|
+
* `Description` (`p`), `Error` (`div`, rendered only while invalid). The browser's constraint
|
|
13
|
+
* validation and `:user-invalid` decide when an error shows; the library adds the ARIA wiring, a
|
|
14
|
+
* styleable error, and server errors from `Form.Root`.
|
|
15
|
+
*
|
|
16
|
+
* @see https://ui.funstack.work/components/field
|
|
17
|
+
*/
|
|
9
18
|
export declare const Field: {
|
|
10
19
|
readonly Root: typeof FieldRoot;
|
|
11
20
|
readonly Label: typeof FieldLabel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/field/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/field/index.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAea;WACX,aAAI;WACJ,cAAK;WACL,gBAAO;WACP,oBAAW;WACX,cAAK"}
|