@funstack/ui 0.1.0-alpha.2 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion/accordion-context.mjs.map +1 -1
- package/dist/accordion/accordion-item.mjs +18 -4
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.mjs +2 -3
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +34 -15
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +4 -5
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/checkbox/checkbox.d.mts +5 -3
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +25 -9
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +2 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +3 -1
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +5 -2
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +24 -5
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/combobox/combobox-clear.mjs +2 -1
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-context.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts +3 -1
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +16 -2
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-list.mjs +3 -2
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +7 -2
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +20 -5
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +2 -1
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/dialog/dialog-close.d.mts +17 -10
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +33 -21
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts +23 -10
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +51 -32
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +10 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +117 -44
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +14 -8
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +67 -12
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +3 -2
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +2 -1
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +4 -2
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +4 -2
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/field/field-control.d.mts +33 -0
- package/dist/field/field-control.d.mts.map +1 -0
- package/dist/field/field-control.mjs +68 -0
- package/dist/field/field-control.mjs.map +1 -0
- package/dist/field/field-description.d.mts +24 -0
- package/dist/field/field-description.d.mts.map +1 -0
- package/dist/field/field-description.mjs +34 -0
- package/dist/field/field-description.mjs.map +1 -0
- package/dist/field/field-error.d.mts +30 -0
- package/dist/field/field-error.d.mts.map +1 -0
- package/dist/field/field-error.mjs +42 -0
- package/dist/field/field-error.mjs.map +1 -0
- package/dist/field/field-label.d.mts +25 -0
- package/dist/field/field-label.d.mts.map +1 -0
- package/dist/field/field-label.mjs +46 -0
- package/dist/field/field-label.mjs.map +1 -0
- package/dist/field/field-root.d.mts +53 -0
- package/dist/field/field-root.d.mts.map +1 -0
- package/dist/field/field-root.mjs +319 -0
- package/dist/field/field-root.mjs.map +1 -0
- package/dist/field/index.d.mts +18 -0
- package/dist/field/index.d.mts.map +1 -0
- package/dist/field/index.mjs +17 -0
- package/dist/field/index.mjs.map +1 -0
- package/dist/form/form-root.d.mts +58 -0
- package/dist/form/form-root.d.mts.map +1 -0
- package/dist/form/form-root.mjs +147 -0
- package/dist/form/form-root.mjs.map +1 -0
- package/dist/form/form-submit.d.mts +31 -0
- package/dist/form/form-submit.d.mts.map +1 -0
- package/dist/form/form-submit.mjs +53 -0
- package/dist/form/form-submit.mjs.map +1 -0
- package/dist/form/index.d.mts +11 -0
- package/dist/form/index.d.mts.map +1 -0
- package/dist/form/index.mjs +11 -0
- package/dist/form/index.mjs.map +1 -0
- package/dist/index.d.mts +53 -1
- package/dist/index.mjs +11 -1
- package/dist/internal/announce.mjs +53 -0
- package/dist/internal/announce.mjs.map +1 -0
- package/dist/internal/content-focus-probe.mjs +42 -0
- package/dist/internal/content-focus-probe.mjs.map +1 -0
- package/dist/internal/decimal.mjs +27 -0
- package/dist/internal/decimal.mjs.map +1 -0
- package/dist/internal/dev-warn.mjs +17 -0
- package/dist/internal/dev-warn.mjs.map +1 -0
- package/dist/internal/field-context.d.mts +19 -0
- package/dist/internal/field-context.d.mts.map +1 -0
- package/dist/internal/field-context.mjs +14 -0
- package/dist/internal/field-context.mjs.map +1 -0
- package/dist/internal/focus-first-invalid.mjs +67 -0
- package/dist/internal/focus-first-invalid.mjs.map +1 -0
- package/dist/internal/form-status-watcher.mjs +31 -0
- package/dist/internal/form-status-watcher.mjs.map +1 -0
- package/dist/internal/modal-registry.mjs +39 -0
- package/dist/internal/modal-registry.mjs.map +1 -0
- package/dist/internal/range-value.mjs +51 -0
- package/dist/internal/range-value.mjs.map +1 -0
- package/dist/internal/render-element.mjs +54 -0
- package/dist/internal/render-element.mjs.map +1 -0
- package/dist/internal/toolbar-context.mjs +17 -0
- package/dist/internal/toolbar-context.mjs.map +1 -0
- package/dist/internal/types.d.mts +3 -1
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-controllable-action.mjs +33 -15
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-exit-animation.mjs +26 -6
- package/dist/internal/use-exit-animation.mjs.map +1 -1
- package/dist/internal/use-field-control.mjs +109 -0
- package/dist/internal/use-field-control.mjs.map +1 -0
- package/dist/internal/use-form-owner-event.mjs +44 -0
- package/dist/internal/use-form-owner-event.mjs.map +1 -0
- package/dist/internal/use-form-reset.mjs +10 -33
- package/dist/internal/use-form-reset.mjs.map +1 -1
- package/dist/internal/use-latest.mjs +32 -0
- package/dist/internal/use-latest.mjs.map +1 -0
- package/dist/internal/use-modal-registration.mjs +47 -0
- package/dist/internal/use-modal-registration.mjs.map +1 -0
- package/dist/internal/use-native-group-reconciliation.mjs +6 -5
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-native-select-value.mjs +7 -5
- package/dist/internal/use-native-select-value.mjs.map +1 -1
- package/dist/internal/use-popover-popup.mjs +11 -24
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-root.mjs +58 -23
- package/dist/internal/use-popover-root.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.mjs +1 -1
- package/dist/internal/use-render.mjs +11 -34
- package/dist/internal/use-render.mjs.map +1 -1
- package/dist/internal/use-roving-focus.mjs +255 -0
- package/dist/internal/use-roving-focus.mjs.map +1 -0
- package/dist/internal/validity.d.mts +24 -0
- package/dist/internal/validity.d.mts.map +1 -0
- package/dist/internal/validity.mjs +108 -0
- package/dist/internal/validity.mjs.map +1 -0
- package/dist/menu/menu-checkbox-item.mjs +2 -1
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +3 -2
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-item.mjs +2 -1
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +7 -2
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.mjs +9 -4
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.mjs +2 -1
- package/dist/menu/menu-radio-item.mjs.map +1 -1
- package/dist/menu/menu-root.mjs +1 -1
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +2 -1
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +15 -4
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/meter/index.d.mts +24 -0
- package/dist/meter/index.d.mts.map +1 -0
- package/dist/meter/index.mjs +23 -0
- package/dist/meter/index.mjs.map +1 -0
- package/dist/meter/meter-context.mjs +13 -0
- package/dist/meter/meter-context.mjs.map +1 -0
- package/dist/meter/meter-indicator.d.mts +19 -0
- package/dist/meter/meter-indicator.d.mts.map +1 -0
- package/dist/meter/meter-indicator.mjs +25 -0
- package/dist/meter/meter-indicator.mjs.map +1 -0
- package/dist/meter/meter-label.d.mts +19 -0
- package/dist/meter/meter-label.d.mts.map +1 -0
- package/dist/meter/meter-label.mjs +28 -0
- package/dist/meter/meter-label.mjs.map +1 -0
- package/dist/meter/meter-region.d.mts +4 -0
- package/dist/meter/meter-region.d.mts.map +1 -0
- package/dist/meter/meter-region.mjs +39 -0
- package/dist/meter/meter-region.mjs.map +1 -0
- package/dist/meter/meter-root.d.mts +71 -0
- package/dist/meter/meter-root.d.mts.map +1 -0
- package/dist/meter/meter-root.mjs +83 -0
- package/dist/meter/meter-root.mjs.map +1 -0
- package/dist/meter/meter-track.d.mts +19 -0
- package/dist/meter/meter-track.d.mts.map +1 -0
- package/dist/meter/meter-track.mjs +25 -0
- package/dist/meter/meter-track.mjs.map +1 -0
- package/dist/meter/meter-value.d.mts +20 -0
- package/dist/meter/meter-value.d.mts.map +1 -0
- package/dist/meter/meter-value.mjs +29 -0
- package/dist/meter/meter-value.mjs.map +1 -0
- package/dist/number-field/index.d.mts +26 -0
- package/dist/number-field/index.d.mts.map +1 -0
- package/dist/number-field/index.mjs +26 -0
- package/dist/number-field/index.mjs.map +1 -0
- package/dist/number-field/number-field-arithmetic.mjs +78 -0
- package/dist/number-field/number-field-arithmetic.mjs.map +1 -0
- package/dist/number-field/number-field-context.d.mts +2 -0
- package/dist/number-field/number-field-context.mjs +13 -0
- package/dist/number-field/number-field-context.mjs.map +1 -0
- package/dist/number-field/number-field-decrement.d.mts +16 -0
- package/dist/number-field/number-field-decrement.d.mts.map +1 -0
- package/dist/number-field/number-field-decrement.mjs +19 -0
- package/dist/number-field/number-field-decrement.mjs.map +1 -0
- package/dist/number-field/number-field-format.mjs +279 -0
- package/dist/number-field/number-field-format.mjs.map +1 -0
- package/dist/number-field/number-field-increment.d.mts +32 -0
- package/dist/number-field/number-field-increment.d.mts.map +1 -0
- package/dist/number-field/number-field-increment.mjs +68 -0
- package/dist/number-field/number-field-increment.mjs.map +1 -0
- package/dist/number-field/number-field-input.d.mts +29 -0
- package/dist/number-field/number-field-input.d.mts.map +1 -0
- package/dist/number-field/number-field-input.mjs +163 -0
- package/dist/number-field/number-field-input.mjs.map +1 -0
- package/dist/number-field/number-field-label.d.mts +23 -0
- package/dist/number-field/number-field-label.d.mts.map +1 -0
- package/dist/number-field/number-field-label.mjs +47 -0
- package/dist/number-field/number-field-label.mjs.map +1 -0
- package/dist/number-field/number-field-root.d.mts +108 -0
- package/dist/number-field/number-field-root.d.mts.map +1 -0
- package/dist/number-field/number-field-root.mjs +523 -0
- package/dist/number-field/number-field-root.mjs.map +1 -0
- package/dist/number-field/use-step-button.mjs +107 -0
- package/dist/number-field/use-step-button.mjs.map +1 -0
- package/dist/popover/popover-close.mjs +2 -1
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +7 -2
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.mjs +1 -1
- package/dist/progress/index.d.mts +24 -0
- package/dist/progress/index.d.mts.map +1 -0
- package/dist/progress/index.mjs +24 -0
- package/dist/progress/index.mjs.map +1 -0
- package/dist/progress/progress-context.mjs +13 -0
- package/dist/progress/progress-context.mjs.map +1 -0
- package/dist/progress/progress-indicator.d.mts +19 -0
- package/dist/progress/progress-indicator.d.mts.map +1 -0
- package/dist/progress/progress-indicator.mjs +29 -0
- package/dist/progress/progress-indicator.mjs.map +1 -0
- package/dist/progress/progress-label.d.mts +19 -0
- package/dist/progress/progress-label.d.mts.map +1 -0
- package/dist/progress/progress-label.mjs +30 -0
- package/dist/progress/progress-label.mjs.map +1 -0
- package/dist/progress/progress-root.d.mts +68 -0
- package/dist/progress/progress-root.d.mts.map +1 -0
- package/dist/progress/progress-root.mjs +80 -0
- package/dist/progress/progress-root.mjs.map +1 -0
- package/dist/progress/progress-track.d.mts +19 -0
- package/dist/progress/progress-track.d.mts.map +1 -0
- package/dist/progress/progress-track.mjs +29 -0
- package/dist/progress/progress-track.mjs.map +1 -0
- package/dist/progress/progress-value.d.mts +20 -0
- package/dist/progress/progress-value.d.mts.map +1 -0
- package/dist/progress/progress-value.mjs +33 -0
- package/dist/progress/progress-value.mjs.map +1 -0
- package/dist/radio-group/radio-group-root.d.mts +4 -2
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +34 -8
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/select-group.d.mts.map +1 -1
- package/dist/select/select-group.mjs +6 -4
- package/dist/select/select-group.mjs.map +1 -1
- package/dist/select/select-root.d.mts +4 -2
- package/dist/select/select-root.d.mts.map +1 -1
- package/dist/select/select-root.mjs +26 -6
- package/dist/select/select-root.mjs.map +1 -1
- package/dist/slider/index.d.mts +32 -0
- package/dist/slider/index.d.mts.map +1 -0
- package/dist/slider/index.mjs +27 -0
- package/dist/slider/index.mjs.map +1 -0
- package/dist/slider/slider-arithmetic.mjs +104 -0
- package/dist/slider/slider-arithmetic.mjs.map +1 -0
- package/dist/slider/slider-context.mjs +13 -0
- package/dist/slider/slider-context.mjs.map +1 -0
- package/dist/slider/slider-indicator.d.mts +22 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -0
- package/dist/slider/slider-indicator.mjs +36 -0
- package/dist/slider/slider-indicator.mjs.map +1 -0
- package/dist/slider/slider-label.d.mts +23 -0
- package/dist/slider/slider-label.d.mts.map +1 -0
- package/dist/slider/slider-label.mjs +44 -0
- package/dist/slider/slider-label.mjs.map +1 -0
- package/dist/slider/slider-root.d.mts +111 -0
- package/dist/slider/slider-root.d.mts.map +1 -0
- package/dist/slider/slider-root.mjs +583 -0
- package/dist/slider/slider-root.mjs.map +1 -0
- package/dist/slider/slider-thumb.d.mts +58 -0
- package/dist/slider/slider-thumb.d.mts.map +1 -0
- package/dist/slider/slider-thumb.mjs +146 -0
- package/dist/slider/slider-thumb.mjs.map +1 -0
- package/dist/slider/slider-track.d.mts +29 -0
- package/dist/slider/slider-track.d.mts.map +1 -0
- package/dist/slider/slider-track.mjs +55 -0
- package/dist/slider/slider-track.mjs.map +1 -0
- package/dist/slider/slider-value.d.mts +34 -0
- package/dist/slider/slider-value.d.mts.map +1 -0
- package/dist/slider/slider-value.mjs +38 -0
- package/dist/slider/slider-value.mjs.map +1 -0
- package/dist/switch/switch.d.mts +5 -3
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +24 -8
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/tabs-indicator.mjs +2 -1
- package/dist/tabs/tabs-indicator.mjs.map +1 -1
- package/dist/tabs/tabs-root.mjs +13 -3
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.mjs +2 -1
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/index.d.mts +25 -0
- package/dist/toast/index.d.mts.map +1 -0
- package/dist/toast/index.mjs +26 -0
- package/dist/toast/index.mjs.map +1 -0
- package/dist/toast/toast-action.d.mts +39 -0
- package/dist/toast/toast-action.d.mts.map +1 -0
- package/dist/toast/toast-action.mjs +65 -0
- package/dist/toast/toast-action.mjs.map +1 -0
- package/dist/toast/toast-close.d.mts +25 -0
- package/dist/toast/toast-close.d.mts.map +1 -0
- package/dist/toast/toast-close.mjs +47 -0
- package/dist/toast/toast-close.mjs.map +1 -0
- package/dist/toast/toast-context.mjs +19 -0
- package/dist/toast/toast-context.mjs.map +1 -0
- package/dist/toast/toast-description.d.mts +24 -0
- package/dist/toast/toast-description.d.mts.map +1 -0
- package/dist/toast/toast-description.mjs +35 -0
- package/dist/toast/toast-description.mjs.map +1 -0
- package/dist/toast/toast-root.d.mts +43 -0
- package/dist/toast/toast-root.d.mts.map +1 -0
- package/dist/toast/toast-root.mjs +205 -0
- package/dist/toast/toast-root.mjs.map +1 -0
- package/dist/toast/toast-title.d.mts +24 -0
- package/dist/toast/toast-title.d.mts.map +1 -0
- package/dist/toast/toast-title.mjs +33 -0
- package/dist/toast/toast-title.mjs.map +1 -0
- package/dist/toast/toast-viewport.d.mts +52 -0
- package/dist/toast/toast-viewport.d.mts.map +1 -0
- package/dist/toast/toast-viewport.mjs +644 -0
- package/dist/toast/toast-viewport.mjs.map +1 -0
- package/dist/toast/toast.d.mts +119 -0
- package/dist/toast/toast.d.mts.map +1 -0
- package/dist/toast/toast.mjs +157 -0
- package/dist/toast/toast.mjs.map +1 -0
- package/dist/toggle/toggle.mjs +2 -1
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/index.d.mts +16 -0
- package/dist/toggle-group/index.d.mts.map +1 -0
- package/dist/toggle-group/index.mjs +15 -0
- package/dist/toggle-group/index.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-context.d.mts +4 -0
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-context.mjs +13 -0
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-item.d.mts +47 -0
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-item.mjs +63 -0
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-root.d.mts +95 -0
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-root.mjs +211 -0
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -0
- package/dist/toolbar/index.d.mts +18 -0
- package/dist/toolbar/index.d.mts.map +1 -0
- package/dist/toolbar/index.mjs +18 -0
- package/dist/toolbar/index.mjs.map +1 -0
- package/dist/toolbar/toolbar-button.d.mts +42 -0
- package/dist/toolbar/toolbar-button.d.mts.map +1 -0
- package/dist/toolbar/toolbar-button.mjs +50 -0
- package/dist/toolbar/toolbar-button.mjs.map +1 -0
- package/dist/toolbar/toolbar-root.d.mts +38 -0
- package/dist/toolbar/toolbar-root.d.mts.map +1 -0
- package/dist/toolbar/toolbar-root.mjs +66 -0
- package/dist/toolbar/toolbar-root.mjs.map +1 -0
- package/dist/toolbar/toolbar-separator.d.mts +25 -0
- package/dist/toolbar/toolbar-separator.d.mts.map +1 -0
- package/dist/toolbar/toolbar-separator.mjs +31 -0
- package/dist/toolbar/toolbar-separator.mjs.map +1 -0
- package/dist/tooltip/tooltip-popup.mjs +2 -1
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +16 -2
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +2 -1
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/package.json +10 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { dataAttr } from "../internal/data-attr.mjs";
|
|
3
|
+
import { rendersButton } from "../internal/render-element.mjs";
|
|
4
|
+
import { useRender } from "../internal/use-render.mjs";
|
|
5
|
+
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
6
|
+
import { isAtBound } from "./number-field-arithmetic.mjs";
|
|
7
|
+
import { useNumberFieldContext } from "./number-field-context.mjs";
|
|
8
|
+
import { useStepButton } from "./use-step-button.mjs";
|
|
9
|
+
//#region src/number-field/number-field-increment.tsx
|
|
10
|
+
const LABELS = {
|
|
11
|
+
increment: "Increase",
|
|
12
|
+
decrement: "Decrease"
|
|
13
|
+
};
|
|
14
|
+
/** Shared by `NumberField.Increment` and `NumberField.Decrement` (design 3.3, 4.3). */
|
|
15
|
+
function useStepButtonElement(direction, part, props) {
|
|
16
|
+
const { disabled: disabledProp = false, className, style, children, render, ...rest } = props;
|
|
17
|
+
const ctx = useNumberFieldContext(part);
|
|
18
|
+
const { state } = ctx;
|
|
19
|
+
const atBound = isAtBound(ctx.stepBase, direction === "increment" ? 1 : -1, ctx.bounds);
|
|
20
|
+
const disabled = disabledProp || state.disabled || state.readOnly || atBound;
|
|
21
|
+
const pending = ctx.pendingSource === direction;
|
|
22
|
+
const buttonState = {
|
|
23
|
+
pending,
|
|
24
|
+
disabled
|
|
25
|
+
};
|
|
26
|
+
const handlers = useStepButton(ctx, direction, disabled);
|
|
27
|
+
useDevWarning(rest["aria-label"] === "", `${part}: \`aria-label=""\` leaves the button without a name. Pass the label text instead (the default is "${LABELS[direction]}").`);
|
|
28
|
+
const props$ = {
|
|
29
|
+
...rest["aria-labelledby"] === void 0 ? { "aria-label": LABELS[direction] } : {},
|
|
30
|
+
...rest
|
|
31
|
+
};
|
|
32
|
+
return useRender({
|
|
33
|
+
defaultElement: "button",
|
|
34
|
+
render,
|
|
35
|
+
state: buttonState,
|
|
36
|
+
className,
|
|
37
|
+
style,
|
|
38
|
+
children,
|
|
39
|
+
props: props$,
|
|
40
|
+
libraryProps: {
|
|
41
|
+
...rendersButton(render) ? { type: "button" } : {},
|
|
42
|
+
tabIndex: -1,
|
|
43
|
+
"aria-controls": ctx.inputId,
|
|
44
|
+
disabled,
|
|
45
|
+
onPointerDown: handlers.onPointerDown,
|
|
46
|
+
onClick: handlers.onClick,
|
|
47
|
+
onContextMenu: handlers.onContextMenu,
|
|
48
|
+
"data-pending": dataAttr(pending),
|
|
49
|
+
"data-disabled": dataAttr(disabled)
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Steps the value up: `button[type=button][tabindex=-1]` with `aria-controls` → the input and the
|
|
55
|
+
* default `aria-label` `"Increase"`; one step at the press, then repeated while held, one commit
|
|
56
|
+
* at the release. Natively `disabled` when the next step would change nothing.
|
|
57
|
+
*
|
|
58
|
+
* Owned keys: `type`, `tabIndex`, `aria-controls`, `disabled`, `onPointerDown`, `onClick`,
|
|
59
|
+
* `onContextMenu`, `data-pending`, `data-disabled`.
|
|
60
|
+
*/
|
|
61
|
+
function NumberFieldIncrement(props) {
|
|
62
|
+
return useStepButtonElement("increment", "NumberField.Increment", props);
|
|
63
|
+
}
|
|
64
|
+
NumberFieldIncrement.displayName = "NumberFieldIncrement";
|
|
65
|
+
//#endregion
|
|
66
|
+
export { NumberFieldIncrement, useStepButtonElement };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=number-field-increment.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-field-increment.mjs","names":[],"sources":["../../src/number-field/number-field-increment.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { isAtBound } from \"./number-field-arithmetic.js\";\nimport { useNumberFieldContext } from \"./number-field-context.js\";\nimport type { StepDirection } from \"./number-field-context.js\";\nimport { useStepButton } from \"./use-step-button.js\";\n\nexport interface NumberFieldButtonState {\n /** The Root is pending and the latest step or commit came from this button. */\n readonly pending: boolean;\n /** The prop, the Root's `disabled` or `readOnly`, or the next step would change nothing. */\n readonly disabled: boolean;\n}\n\nexport interface NumberFieldIncrementProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n | \"type\"\n | \"tabIndex\"\n | \"disabled\"\n | \"onPointerDown\"\n | \"onClick\"\n | \"onContextMenu\"\n | \"aria-controls\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n disabled?: boolean;\n className?: StateValue<string | undefined, NumberFieldButtonState>;\n style?: StateValue<CSSProperties | undefined, NumberFieldButtonState>;\n children?: StateValue<ReactNode, NumberFieldButtonState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, NumberFieldButtonState>;\n}\n\nexport type NumberFieldDecrementProps = NumberFieldIncrementProps;\n\nconst LABELS: Record<StepDirection, string> = { increment: \"Increase\", decrement: \"Decrease\" };\n\n/** Shared by `NumberField.Increment` and `NumberField.Decrement` (design 3.3, 4.3). */\nexport function useStepButtonElement(\n direction: StepDirection,\n part: string,\n props: NumberFieldIncrementProps,\n): ReactNode {\n const { disabled: disabledProp = false, className, style, children, render, ...rest } = props;\n const ctx = useNumberFieldContext(part);\n const { state } = ctx;\n const atBound = isAtBound(ctx.stepBase, direction === \"increment\" ? 1 : -1, ctx.bounds);\n const disabled = disabledProp || state.disabled || state.readOnly || atBound;\n const pending = ctx.pendingSource === direction;\n const buttonState: NumberFieldButtonState = { pending, disabled };\n const handlers = useStepButton(ctx, direction, disabled);\n\n useDevWarning(\n rest[\"aria-label\"] === \"\",\n `${part}: \\`aria-label=\"\"\\` leaves the button without a name. Pass the label text instead ` +\n `(the default is \"${LABELS[direction]}\").`,\n );\n\n // The built-in name is a default the consumer's `aria-label` or `aria-labelledby` replaces.\n const props$ = {\n ...(rest[\"aria-labelledby\"] === undefined ? { \"aria-label\": LABELS[direction] } : {}),\n ...rest,\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, NumberFieldButtonState>({\n defaultElement: \"button\",\n render,\n state: buttonState,\n className,\n style,\n children,\n props: props$,\n libraryProps: {\n ...(rendersButton(render) ? { type: \"button\" as const } : {}),\n tabIndex: -1,\n \"aria-controls\": ctx.inputId,\n disabled,\n onPointerDown: handlers.onPointerDown,\n onClick: handlers.onClick,\n onContextMenu: handlers.onContextMenu,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n } as Partial<ComponentPropsWithRef<\"button\">> & DataAttributes,\n });\n}\n\n/**\n * Steps the value up: `button[type=button][tabindex=-1]` with `aria-controls` → the input and the\n * default `aria-label` `\"Increase\"`; one step at the press, then repeated while held, one commit\n * at the release. Natively `disabled` when the next step would change nothing.\n *\n * Owned keys: `type`, `tabIndex`, `aria-controls`, `disabled`, `onPointerDown`, `onClick`,\n * `onContextMenu`, `data-pending`, `data-disabled`.\n */\nexport function NumberFieldIncrement(props: NumberFieldIncrementProps) {\n return useStepButtonElement(\"increment\", \"NumberField.Increment\", props);\n}\n\nNumberFieldIncrement.displayName = \"NumberFieldIncrement\";\n"],"mappings":";;;;;;;;;AAyCA,MAAM,SAAwC;CAAE,WAAW;CAAY,WAAW;AAAW;;AAG7F,SAAgB,qBACd,WACA,MACA,OACW;CACX,MAAM,EAAE,UAAU,eAAe,OAAO,WAAW,OAAO,UAAU,QAAQ,GAAG,SAAS;CACxF,MAAM,MAAM,sBAAsB,IAAI;CACtC,MAAM,EAAE,UAAU;CAClB,MAAM,UAAU,UAAU,IAAI,UAAU,cAAc,cAAc,IAAI,IAAI,IAAI,MAAM;CACtF,MAAM,WAAW,gBAAgB,MAAM,YAAY,MAAM,YAAY;CACrE,MAAM,UAAU,IAAI,kBAAkB;CACtC,MAAM,cAAsC;EAAE;EAAS;CAAS;CAChE,MAAM,WAAW,cAAc,KAAK,WAAW,QAAQ;CAEvD,cACE,KAAK,kBAAkB,IACvB,GAAG,KAAK,qGACc,OAAO,WAAW,IAC1C;CAGA,MAAM,SAAS;EACb,GAAI,KAAK,uBAAuB,KAAA,IAAY,EAAE,cAAc,OAAO,WAAW,IAAI,CAAC;EACnF,GAAG;CACL;CAEA,OAAO,UAAmE;EACxE,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,GAAI,cAAc,MAAM,IAAI,EAAE,MAAM,SAAkB,IAAI,CAAC;GAC3D,UAAU;GACV,iBAAiB,IAAI;GACrB;GACA,eAAe,SAAS;GACxB,SAAS,SAAS;GAClB,eAAe,SAAS;GACxB,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;EACpC;CACF,CAAC;AACH;;;;;;;;;AAUA,SAAgB,qBAAqB,OAAkC;CACrE,OAAO,qBAAqB,aAAa,yBAAyB,KAAK;AACzE;AAEA,qBAAqB,cAAc"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { NumberFieldState } from "./number-field-root.mjs";
|
|
3
|
+
import { CSSProperties, ComponentPropsWithRef, Ref } from "react";
|
|
4
|
+
//#region src/number-field/number-field-input.d.ts
|
|
5
|
+
export interface NumberFieldInputProps extends Omit<ComponentPropsWithRef<"input">, "value" | "defaultValue" | "type" | "onChange" | "onKeyDown" | "onBlur" | "disabled" | "readOnly" | "required" | "name" | "form" | "min" | "max" | "step" | "pattern" | "aria-invalid" | "className" | "style" | "children"> {
|
|
6
|
+
/** The hidden native `<input type="number">` rendered after the visible input. */
|
|
7
|
+
hiddenInputRef?: Ref<HTMLInputElement>;
|
|
8
|
+
className?: StateValue<string | undefined, NumberFieldState>;
|
|
9
|
+
style?: StateValue<CSSProperties | undefined, NumberFieldState>;
|
|
10
|
+
/** Must render an `<input>` of type `text`, `search` or `tel`; the hidden input is rendered after it regardless. */
|
|
11
|
+
render?: RenderProp<ComponentPropsWithRef<"input">, NumberFieldState>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The visible text field (`input[type=text]`, the user's surface) **followed by** the visually
|
|
15
|
+
* hidden native `input[type=number]` that carries `name`, `form`, `min`, `max`, `step`,
|
|
16
|
+
* `required` and the canonical value (design/components/number-field.md 6). `ref` goes to the
|
|
17
|
+
* visible input, `hiddenInputRef` to the hidden one.
|
|
18
|
+
*
|
|
19
|
+
* Owned keys on the visible input: `id`, `type`, `value`, `disabled`, `readOnly`, `onChange`,
|
|
20
|
+
* `onKeyDown`, `onBlur`, `aria-invalid` and `aria-describedby` (Field, token-merged),
|
|
21
|
+
* `data-pending`, `data-disabled`, `data-invalid`. Defaults the consumer's own prop replaces:
|
|
22
|
+
* `inputMode`, `autoComplete="off"`, `autoCorrect="off"`, `spellCheck={false}`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function NumberFieldInput({ hiddenInputRef, className, style, render, ...rest }: NumberFieldInputProps): import("react").JSX.Element;
|
|
25
|
+
export declare namespace NumberFieldInput {
|
|
26
|
+
var displayName: string;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//# sourceMappingURL=number-field-input.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-field-input.d.mts","names":[],"sources":["../../src/number-field/number-field-input.tsx"],"mappings":";;;;iBA4BiB,8BAA8B,KAC7C;;EAsBA,iBAAiB,IAAI;EACrB,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,gCAAgC;;;;;;;;;;;;;wBAgCtC,mBACd,gBACA,WACA,OACA,WACG,QACF,wCAAqB,IAAA;yBANR"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { dataAttr } from "../internal/data-attr.mjs";
|
|
3
|
+
import { mergeRefs } from "../internal/merge-props.mjs";
|
|
4
|
+
import { useRender } from "../internal/use-render.mjs";
|
|
5
|
+
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
6
|
+
import { useFieldControl, useMergedRef } from "../internal/use-field-control.mjs";
|
|
7
|
+
import { useNumberFieldContext } from "./number-field-context.mjs";
|
|
8
|
+
import { hiddenText } from "./number-field-root.mjs";
|
|
9
|
+
import { isValidElement, useCallback, useEffectEvent, useLayoutEffect, useMemo, useRef } from "react";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region src/number-field/number-field-input.tsx
|
|
12
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
13
|
+
/** Visually hidden, unfocusable, out of the accessibility tree: the form's control (6.1). */
|
|
14
|
+
const HIDDEN_STYLE = {
|
|
15
|
+
position: "absolute",
|
|
16
|
+
width: "1px",
|
|
17
|
+
height: "1px",
|
|
18
|
+
margin: "-1px",
|
|
19
|
+
padding: 0,
|
|
20
|
+
border: 0,
|
|
21
|
+
opacity: 0,
|
|
22
|
+
overflow: "hidden",
|
|
23
|
+
clipPath: "inset(50%)",
|
|
24
|
+
pointerEvents: "none"
|
|
25
|
+
};
|
|
26
|
+
const TEXT_TYPES = [
|
|
27
|
+
"text",
|
|
28
|
+
"search",
|
|
29
|
+
"tel"
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* The visible text field (`input[type=text]`, the user's surface) **followed by** the visually
|
|
33
|
+
* hidden native `input[type=number]` that carries `name`, `form`, `min`, `max`, `step`,
|
|
34
|
+
* `required` and the canonical value (design/components/number-field.md 6). `ref` goes to the
|
|
35
|
+
* visible input, `hiddenInputRef` to the hidden one.
|
|
36
|
+
*
|
|
37
|
+
* Owned keys on the visible input: `id`, `type`, `value`, `disabled`, `readOnly`, `onChange`,
|
|
38
|
+
* `onKeyDown`, `onBlur`, `aria-invalid` and `aria-describedby` (Field, token-merged),
|
|
39
|
+
* `data-pending`, `data-disabled`, `data-invalid`. Defaults the consumer's own prop replaces:
|
|
40
|
+
* `inputMode`, `autoComplete="off"`, `autoCorrect="off"`, `spellCheck={false}`.
|
|
41
|
+
*/
|
|
42
|
+
function NumberFieldInput({ hiddenInputRef, className, style, render, ...rest }) {
|
|
43
|
+
const ctx = useNumberFieldContext("NumberField.Input");
|
|
44
|
+
const { state, visibleRef, hiddenRef, mirror, onInputMounted } = ctx;
|
|
45
|
+
const validityElement = useCallback(() => hiddenRef.current, [hiddenRef]);
|
|
46
|
+
const field = useFieldControl({
|
|
47
|
+
labelable: true,
|
|
48
|
+
name: ctx.name,
|
|
49
|
+
disabled: state.disabled,
|
|
50
|
+
required: state.required,
|
|
51
|
+
component: "NumberField.Input",
|
|
52
|
+
validityElement
|
|
53
|
+
});
|
|
54
|
+
const restName = rest.name;
|
|
55
|
+
useDevWarning(restName !== void 0, "NumberField.Input: `name` belongs on NumberField.Root (it goes to the hidden number input); on the visible input it would post the formatted text.");
|
|
56
|
+
const libraryRef = useCallback((element) => {
|
|
57
|
+
if (isDev) {
|
|
58
|
+
const type = element.tagName === "INPUT" ? element.type : "";
|
|
59
|
+
if (!TEXT_TYPES.includes(type)) console.error(`NumberField.Input: rendered <${element.tagName.toLowerCase()}${type === "" ? "" : ` type="${type}"`}>. Render an <input> of type "text", "search" or "tel": a number input would re-introduce the native parser.`);
|
|
60
|
+
}
|
|
61
|
+
visibleRef.current = element;
|
|
62
|
+
return () => {
|
|
63
|
+
if (visibleRef.current === element) visibleRef.current = null;
|
|
64
|
+
};
|
|
65
|
+
}, [visibleRef]);
|
|
66
|
+
const mergedRef = useMergedRef(libraryRef, field.ref);
|
|
67
|
+
const hiddenMergedRef = useMemo(() => mergeRefs(hiddenRef, hiddenInputRef), [hiddenRef, hiddenInputRef]);
|
|
68
|
+
useLayoutEffect(() => {
|
|
69
|
+
const hidden = hiddenRef.current;
|
|
70
|
+
if (hidden !== null) {
|
|
71
|
+
const text = hiddenText(state.value);
|
|
72
|
+
if (hidden.value !== text) hidden.value = text;
|
|
73
|
+
}
|
|
74
|
+
mirror();
|
|
75
|
+
});
|
|
76
|
+
useLayoutEffect(() => {
|
|
77
|
+
const hidden = hiddenRef.current;
|
|
78
|
+
if (hidden === null) return;
|
|
79
|
+
const onInvalid = (event) => event.preventDefault();
|
|
80
|
+
hidden.addEventListener("invalid", onInvalid);
|
|
81
|
+
return () => hidden.removeEventListener("invalid", onInvalid);
|
|
82
|
+
}, [hiddenRef]);
|
|
83
|
+
const onWheel = useEffectEvent((event) => {
|
|
84
|
+
ctx.wheel(event);
|
|
85
|
+
});
|
|
86
|
+
const { stepOnWheel } = ctx;
|
|
87
|
+
useLayoutEffect(() => {
|
|
88
|
+
const visible = visibleRef.current;
|
|
89
|
+
if (!stepOnWheel || visible === null) return;
|
|
90
|
+
visible.addEventListener("wheel", onWheel, { passive: false });
|
|
91
|
+
return () => visible.removeEventListener("wheel", onWheel);
|
|
92
|
+
}, [stepOnWheel, visibleRef]);
|
|
93
|
+
const mounted = useRef(false);
|
|
94
|
+
useLayoutEffect(() => {
|
|
95
|
+
if (mounted.current) return;
|
|
96
|
+
mounted.current = true;
|
|
97
|
+
onInputMounted();
|
|
98
|
+
}, [onInputMounted]);
|
|
99
|
+
const renderType = isValidElement(render) && typeof render.props.type === "string" ? render.props.type : void 0;
|
|
100
|
+
const type = renderType !== void 0 && TEXT_TYPES.includes(renderType) ? renderType : "text";
|
|
101
|
+
useDevWarning(renderType !== void 0 && !TEXT_TYPES.includes(renderType), `NumberField.Input: \`render\` has type="${renderType ?? ""}"; the visible input is rendered as type "text". A number input would re-introduce the native parser the NumberField exists to avoid.`);
|
|
102
|
+
const dataInvalid = ctx.fieldInvalid === void 0 ? {} : { "data-invalid": dataAttr(ctx.fieldInvalid) };
|
|
103
|
+
const libraryProps = {
|
|
104
|
+
...field.attributes,
|
|
105
|
+
id: ctx.inputId,
|
|
106
|
+
type,
|
|
107
|
+
value: state.text,
|
|
108
|
+
disabled: state.disabled,
|
|
109
|
+
readOnly: state.readOnly,
|
|
110
|
+
onChange: (event) => {
|
|
111
|
+
ctx.typed(event.currentTarget.value);
|
|
112
|
+
},
|
|
113
|
+
onKeyDown: (event) => {
|
|
114
|
+
ctx.keyDown(event.nativeEvent);
|
|
115
|
+
},
|
|
116
|
+
onBlur: (event) => {
|
|
117
|
+
ctx.commitDraft(event.nativeEvent);
|
|
118
|
+
},
|
|
119
|
+
"data-pending": dataAttr(state.pending),
|
|
120
|
+
"data-disabled": dataAttr(state.disabled),
|
|
121
|
+
...dataInvalid
|
|
122
|
+
};
|
|
123
|
+
const visible = useRender({
|
|
124
|
+
defaultElement: "input",
|
|
125
|
+
render,
|
|
126
|
+
state,
|
|
127
|
+
className,
|
|
128
|
+
style,
|
|
129
|
+
children: void 0,
|
|
130
|
+
props: {
|
|
131
|
+
inputMode: ctx.allowsFractions ? "decimal" : "numeric",
|
|
132
|
+
autoComplete: "off",
|
|
133
|
+
autoCorrect: "off",
|
|
134
|
+
spellCheck: false,
|
|
135
|
+
...rest
|
|
136
|
+
},
|
|
137
|
+
libraryProps,
|
|
138
|
+
ref: mergedRef
|
|
139
|
+
});
|
|
140
|
+
const { min, max, step } = ctx.bounds;
|
|
141
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [visible, /* @__PURE__ */ jsx("input", {
|
|
142
|
+
ref: hiddenMergedRef,
|
|
143
|
+
type: "number",
|
|
144
|
+
name: field.name,
|
|
145
|
+
form: ctx.form,
|
|
146
|
+
min,
|
|
147
|
+
max,
|
|
148
|
+
step,
|
|
149
|
+
required: field.required,
|
|
150
|
+
disabled: field.disabled,
|
|
151
|
+
readOnly: state.readOnly,
|
|
152
|
+
defaultValue: ctx.resetTargetText,
|
|
153
|
+
autoComplete: "off",
|
|
154
|
+
"aria-hidden": "true",
|
|
155
|
+
tabIndex: -1,
|
|
156
|
+
style: HIDDEN_STYLE
|
|
157
|
+
})] });
|
|
158
|
+
}
|
|
159
|
+
NumberFieldInput.displayName = "NumberFieldInput";
|
|
160
|
+
//#endregion
|
|
161
|
+
export { NumberFieldInput };
|
|
162
|
+
|
|
163
|
+
//# sourceMappingURL=number-field-input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-field-input.mjs","names":[],"sources":["../../src/number-field/number-field-input.tsx"],"sourcesContent":["\"use client\";\nimport {\n isValidElement,\n useCallback,\n useEffectEvent,\n useLayoutEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type {\n ChangeEvent,\n ComponentPropsWithRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n Ref,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { mergeRefs } from \"../internal/merge-props.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useFieldControl, useMergedRef } from \"../internal/use-field-control.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { hiddenText } from \"./number-field-root.js\";\nimport type { NumberFieldState } from \"./number-field-root.js\";\nimport { useNumberFieldContext } from \"./number-field-context.js\";\n\nexport interface NumberFieldInputProps extends Omit<\n ComponentPropsWithRef<\"input\">,\n | \"value\"\n | \"defaultValue\"\n | \"type\"\n | \"onChange\"\n | \"onKeyDown\"\n | \"onBlur\"\n | \"disabled\"\n | \"readOnly\"\n | \"required\"\n | \"name\"\n | \"form\"\n | \"min\"\n | \"max\"\n | \"step\"\n | \"pattern\"\n | \"aria-invalid\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** The hidden native `<input type=\"number\">` rendered after the visible input. */\n hiddenInputRef?: Ref<HTMLInputElement>;\n className?: StateValue<string | undefined, NumberFieldState>;\n style?: StateValue<CSSProperties | undefined, NumberFieldState>;\n /** Must render an `<input>` of type `text`, `search` or `tel`; the hidden input is rendered after it regardless. */\n render?: RenderProp<ComponentPropsWithRef<\"input\">, NumberFieldState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** Visually hidden, unfocusable, out of the accessibility tree: the form's control (6.1). */\nconst HIDDEN_STYLE: CSSProperties = {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n margin: \"-1px\",\n padding: 0,\n border: 0,\n opacity: 0,\n overflow: \"hidden\",\n clipPath: \"inset(50%)\",\n pointerEvents: \"none\",\n};\n\nconst TEXT_TYPES = [\"text\", \"search\", \"tel\"];\n\n/**\n * The visible text field (`input[type=text]`, the user's surface) **followed by** the visually\n * hidden native `input[type=number]` that carries `name`, `form`, `min`, `max`, `step`,\n * `required` and the canonical value (design/components/number-field.md 6). `ref` goes to the\n * visible input, `hiddenInputRef` to the hidden one.\n *\n * Owned keys on the visible input: `id`, `type`, `value`, `disabled`, `readOnly`, `onChange`,\n * `onKeyDown`, `onBlur`, `aria-invalid` and `aria-describedby` (Field, token-merged),\n * `data-pending`, `data-disabled`, `data-invalid`. Defaults the consumer's own prop replaces:\n * `inputMode`, `autoComplete=\"off\"`, `autoCorrect=\"off\"`, `spellCheck={false}`.\n */\nexport function NumberFieldInput({\n hiddenInputRef,\n className,\n style,\n render,\n ...rest\n}: NumberFieldInputProps) {\n const ctx = useNumberFieldContext(\"NumberField.Input\");\n const { state, visibleRef, hiddenRef, mirror, onInputMounted } = ctx;\n\n // --- The Field contract (design 7.1): the visible input registers, the hidden one validates.\n const validityElement = useCallback(() => hiddenRef.current, [hiddenRef]);\n const field = useFieldControl({\n labelable: true,\n name: ctx.name,\n disabled: state.disabled,\n required: state.required,\n component: \"NumberField.Input\",\n validityElement,\n });\n\n const restName = (rest as { name?: unknown }).name;\n useDevWarning(\n restName !== undefined,\n \"NumberField.Input: `name` belongs on NumberField.Root (it goes to the hidden number input); \" +\n \"on the visible input it would post the formatted text.\",\n );\n\n const libraryRef = useCallback(\n (element: HTMLElement) => {\n if (isDev) {\n const type = element.tagName === \"INPUT\" ? (element as HTMLInputElement).type : \"\";\n if (!TEXT_TYPES.includes(type)) {\n console.error(\n `NumberField.Input: rendered <${element.tagName.toLowerCase()}` +\n `${type === \"\" ? \"\" : ` type=\"${type}\"`}>. Render an <input> of type \"text\", ` +\n '\"search\" or \"tel\": a number input would re-introduce the native parser.',\n );\n }\n }\n visibleRef.current = element as HTMLInputElement;\n return () => {\n if (visibleRef.current === element) visibleRef.current = null;\n };\n },\n [visibleRef],\n );\n const mergedRef = useMergedRef<HTMLElement>(libraryRef, field.ref);\n\n const hiddenMergedRef = useMemo(\n () => mergeRefs<HTMLInputElement | null>(hiddenRef, hiddenInputRef),\n [hiddenRef, hiddenInputRef],\n );\n\n // After every commit: the hidden input holds the shown value (a rollback, a controlled change,\n // a reset) and the visible input mirrors its validity (a changed `min` / `max` / `required`).\n useLayoutEffect(() => {\n const hidden = hiddenRef.current;\n if (hidden !== null) {\n const text = hiddenText(state.value);\n if (hidden.value !== text) hidden.value = text;\n }\n mirror();\n });\n\n // The hidden input is never the one the browser reports on (6.3); the visible input is\n // invalid in the same cases and gets the report (or the Field handles it).\n useLayoutEffect(() => {\n const hidden = hiddenRef.current;\n if (hidden === null) return;\n const onInvalid = (event: Event) => event.preventDefault();\n hidden.addEventListener(\"invalid\", onInvalid);\n return () => hidden.removeEventListener(\"invalid\", onInvalid);\n }, [hiddenRef]);\n\n // React's `onWheel` is passive: a native, non-passive listener can stop the page scroll (4.4).\n const onWheel = useEffectEvent((event: WheelEvent) => {\n ctx.wheel(event);\n });\n const { stepOnWheel } = ctx;\n useLayoutEffect(() => {\n const visible = visibleRef.current;\n if (!stepOnWheel || visible === null) return;\n visible.addEventListener(\"wheel\", onWheel, { passive: false });\n return () => visible.removeEventListener(\"wheel\", onWheel);\n }, [stepOnWheel, visibleRef]);\n\n // A late mount (inside a Suspense boundary that hydrates after the Root) reconciles again.\n const mounted = useRef(false);\n useLayoutEffect(() => {\n if (mounted.current) return;\n mounted.current = true;\n onInputMounted();\n }, [onInputMounted]);\n\n const renderType =\n isValidElement<{ type?: unknown }>(render) && typeof render.props.type === \"string\"\n ? render.props.type\n : undefined;\n const type = renderType !== undefined && TEXT_TYPES.includes(renderType) ? renderType : \"text\";\n useDevWarning(\n renderType !== undefined && !TEXT_TYPES.includes(renderType),\n `NumberField.Input: \\`render\\` has type=\"${renderType ?? \"\"}\"; the visible input is ` +\n 'rendered as type \"text\". A number input would re-introduce the native parser the ' +\n \"NumberField exists to avoid.\",\n );\n\n const dataInvalid =\n ctx.fieldInvalid === undefined ? {} : { \"data-invalid\": dataAttr(ctx.fieldInvalid) };\n const libraryProps: ComponentPropsWithRef<\"input\"> & DataAttributes = {\n ...field.attributes,\n id: ctx.inputId,\n type,\n value: state.text,\n disabled: state.disabled,\n readOnly: state.readOnly,\n onChange: (event: ChangeEvent<HTMLInputElement>) => {\n ctx.typed(event.currentTarget.value);\n },\n onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => {\n ctx.keyDown(event.nativeEvent);\n },\n onBlur: (event: FocusEvent<HTMLInputElement>) => {\n ctx.commitDraft(event.nativeEvent);\n },\n \"data-pending\": dataAttr(state.pending),\n \"data-disabled\": dataAttr(state.disabled),\n ...dataInvalid,\n };\n\n const visible = useRender<ComponentPropsWithRef<\"input\">, NumberFieldState>({\n defaultElement: \"input\",\n render,\n state,\n className,\n style,\n children: undefined,\n props: {\n inputMode: ctx.allowsFractions ? \"decimal\" : \"numeric\",\n autoComplete: \"off\",\n autoCorrect: \"off\",\n spellCheck: false,\n ...rest,\n },\n libraryProps,\n ref: mergedRef,\n });\n\n const { min, max, step } = ctx.bounds;\n return (\n <>\n {visible}\n <input\n ref={hiddenMergedRef}\n type=\"number\"\n name={field.name}\n form={ctx.form}\n min={min}\n max={max}\n step={step}\n required={field.required}\n disabled={field.disabled}\n readOnly={state.readOnly}\n defaultValue={ctx.resetTargetText}\n autoComplete=\"off\"\n aria-hidden=\"true\"\n tabIndex={-1}\n style={HIDDEN_STYLE}\n />\n </>\n );\n}\n\nNumberFieldInput.displayName = \"NumberFieldInput\";\n"],"mappings":"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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { NumberFieldState } from "./number-field-root.mjs";
|
|
3
|
+
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
|
+
//#region src/number-field/number-field-label.d.ts
|
|
5
|
+
export interface NumberFieldLabelProps extends Omit<ComponentPropsWithRef<"label">, "htmlFor" | "id" | "className" | "style" | "children"> {
|
|
6
|
+
className?: StateValue<string | undefined, NumberFieldState>;
|
|
7
|
+
style?: StateValue<CSSProperties | undefined, NumberFieldState>;
|
|
8
|
+
children?: StateValue<ReactNode, NumberFieldState>;
|
|
9
|
+
/** Must render a `<label>`. */
|
|
10
|
+
render?: RenderProp<ComponentPropsWithRef<"label">, NumberFieldState>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The visible name of the field: `<label for>` naming the visible input; its id also names the
|
|
14
|
+
* Root group (`aria-labelledby`, emitted only while a Label is mounted).
|
|
15
|
+
*
|
|
16
|
+
* Owned keys: `id`, `htmlFor`, `data-pending`, `data-disabled`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function NumberFieldLabel({ className, style, children, render, ...rest }: NumberFieldLabelProps): ReactNode;
|
|
19
|
+
export declare namespace NumberFieldLabel {
|
|
20
|
+
var displayName: string;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//# sourceMappingURL=number-field-label.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-field-label.d.mts","names":[],"sources":["../../src/number-field/number-field-label.tsx"],"mappings":";;;;iBAWiB,8BAA8B,KAC7C;EAGA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,gCAAgC;;;;;;;;wBAStC,mBACd,WACA,OACA,UACA,WACG,QACF,wBAAqB;yBANR"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { dataAttr } from "../internal/data-attr.mjs";
|
|
3
|
+
import { useRender } from "../internal/use-render.mjs";
|
|
4
|
+
import { useNumberFieldContext } from "./number-field-context.mjs";
|
|
5
|
+
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
6
|
+
//#region src/number-field/number-field-label.tsx
|
|
7
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
8
|
+
/**
|
|
9
|
+
* The visible name of the field: `<label for>` naming the visible input; its id also names the
|
|
10
|
+
* Root group (`aria-labelledby`, emitted only while a Label is mounted).
|
|
11
|
+
*
|
|
12
|
+
* Owned keys: `id`, `htmlFor`, `data-pending`, `data-disabled`.
|
|
13
|
+
*/
|
|
14
|
+
function NumberFieldLabel({ className, style, children, render, ...rest }) {
|
|
15
|
+
const ctx = useNumberFieldContext("NumberField.Label");
|
|
16
|
+
const { registerLabel } = ctx;
|
|
17
|
+
useLayoutEffect(registerLabel, [registerLabel]);
|
|
18
|
+
const warned = useRef(false);
|
|
19
|
+
const libraryRef = useCallback((element) => {
|
|
20
|
+
if (isDev && !warned.current && element.tagName !== "LABEL") {
|
|
21
|
+
warned.current = true;
|
|
22
|
+
console.error(`NumberField.Label: expected a <label> element but got <${element.tagName.toLowerCase()}>. The Label names the input through \`for\`, which only a <label> has.`);
|
|
23
|
+
}
|
|
24
|
+
return () => {};
|
|
25
|
+
}, []);
|
|
26
|
+
return useRender({
|
|
27
|
+
defaultElement: "label",
|
|
28
|
+
render,
|
|
29
|
+
state: ctx.state,
|
|
30
|
+
className,
|
|
31
|
+
style,
|
|
32
|
+
children,
|
|
33
|
+
props: rest,
|
|
34
|
+
ref: libraryRef,
|
|
35
|
+
libraryProps: {
|
|
36
|
+
id: ctx.labelId,
|
|
37
|
+
htmlFor: ctx.inputId,
|
|
38
|
+
"data-pending": dataAttr(ctx.state.pending),
|
|
39
|
+
"data-disabled": dataAttr(ctx.state.disabled)
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
NumberFieldLabel.displayName = "NumberFieldLabel";
|
|
44
|
+
//#endregion
|
|
45
|
+
export { NumberFieldLabel };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=number-field-label.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-field-label.mjs","names":[],"sources":["../../src/number-field/number-field-label.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useLayoutEffect, useRef } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useNumberFieldContext } from \"./number-field-context.js\";\nimport type { NumberFieldState } from \"./number-field-root.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface NumberFieldLabelProps extends Omit<\n ComponentPropsWithRef<\"label\">,\n \"htmlFor\" | \"id\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, NumberFieldState>;\n style?: StateValue<CSSProperties | undefined, NumberFieldState>;\n children?: StateValue<ReactNode, NumberFieldState>;\n /** Must render a `<label>`. */\n render?: RenderProp<ComponentPropsWithRef<\"label\">, NumberFieldState>;\n}\n\n/**\n * The visible name of the field: `<label for>` naming the visible input; its id also names the\n * Root group (`aria-labelledby`, emitted only while a Label is mounted).\n *\n * Owned keys: `id`, `htmlFor`, `data-pending`, `data-disabled`.\n */\nexport function NumberFieldLabel({\n className,\n style,\n children,\n render,\n ...rest\n}: NumberFieldLabelProps) {\n const ctx = useNumberFieldContext(\"NumberField.Label\");\n const { registerLabel } = ctx;\n useLayoutEffect(registerLabel, [registerLabel]);\n\n const warned = useRef(false);\n const libraryRef = useCallback((element: HTMLElement) => {\n if (isDev && !warned.current && element.tagName !== \"LABEL\") {\n warned.current = true;\n console.error(\n `NumberField.Label: expected a <label> element but got <${element.tagName.toLowerCase()}>. ` +\n \"The Label names the input through `for`, which only a <label> has.\",\n );\n }\n return () => {};\n }, []);\n\n return useRender<ComponentPropsWithRef<\"label\">, NumberFieldState>({\n defaultElement: \"label\",\n render,\n state: ctx.state,\n className,\n style,\n children,\n props: rest,\n ref: libraryRef,\n libraryProps: {\n id: ctx.labelId,\n htmlFor: ctx.inputId,\n \"data-pending\": dataAttr(ctx.state.pending),\n \"data-disabled\": dataAttr(ctx.state.disabled),\n },\n });\n}\n\nNumberFieldLabel.displayName = \"NumberFieldLabel\";\n"],"mappings":";;;;;;AASA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;AAmBvC,SAAgB,iBAAiB,EAC/B,WACA,OACA,UACA,QACA,GAAG,QACqB;CACxB,MAAM,MAAM,sBAAsB,mBAAmB;CACrD,MAAM,EAAE,kBAAkB;CAC1B,gBAAgB,eAAe,CAAC,aAAa,CAAC;CAE9C,MAAM,SAAS,OAAO,KAAK;CAC3B,MAAM,aAAa,aAAa,YAAyB;EACvD,IAAI,SAAS,CAAC,OAAO,WAAW,QAAQ,YAAY,SAAS;GAC3D,OAAO,UAAU;GACjB,QAAQ,MACN,0DAA0D,QAAQ,QAAQ,YAAY,EAAE,wEAE1F;EACF;EACA,aAAa,CAAC;CAChB,GAAG,CAAC,CAAC;CAEL,OAAO,UAA4D;EACjE,gBAAgB;EAChB;EACA,OAAO,IAAI;EACX;EACA;EACA;EACA,OAAO;EACP,KAAK;EACL,cAAc;GACZ,IAAI,IAAI;GACR,SAAS,IAAI;GACb,gBAAgB,SAAS,IAAI,MAAM,OAAO;GAC1C,iBAAiB,SAAS,IAAI,MAAM,QAAQ;EAC9C;CACF,CAAC;AACH;AAEA,iBAAiB,cAAc"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ActionDetails, ChangeAction, ChangeReason, RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
3
|
+
//#region src/number-field/number-field-root.d.ts
|
|
4
|
+
/** Details passed as the second argument of both NumberField actions. */
|
|
5
|
+
export interface NumberFieldValueChangeDetails extends ActionDetails {
|
|
6
|
+
/**
|
|
7
|
+
* `"activate"`: the user typed, pressed a key, a button or turned the wheel (`details.event` is
|
|
8
|
+
* the `focusout` / Enter `keydown` of a typed value, the `keydown` of a key, the `pointerdown` /
|
|
9
|
+
* `pointerup` of a button (`undefined` for the repeats of a held button and for a hold that
|
|
10
|
+
* ended at its bound), the `wheel` event). `"platform"`: a form reset (the `reset`
|
|
11
|
+
* event) or text typed before hydration (`undefined`). `"dismiss"`: the commit action rejected
|
|
12
|
+
* and the field reverted to the committed value (uncontrolled; `valueChangeAction` only).
|
|
13
|
+
*/
|
|
14
|
+
readonly reason: ChangeReason;
|
|
15
|
+
/** What produced the value: typed text, a button, a key, the wheel; `null` for "platform" and "dismiss". */
|
|
16
|
+
readonly source: "input" | "increment" | "decrement" | "keyboard" | "wheel" | null;
|
|
17
|
+
}
|
|
18
|
+
/** The state every NumberField part's function props receive (one object, Field's precedent). */
|
|
19
|
+
export interface NumberFieldState {
|
|
20
|
+
/** The shown value: the gesture's value while one is open or in flight, else the optimistic value; `null` when empty. */
|
|
21
|
+
readonly value: number | null;
|
|
22
|
+
/** The shown text: the draft while the user is editing, else `value` formatted. */
|
|
23
|
+
readonly text: string;
|
|
24
|
+
/** A step or commit dispatched through this NumberField is in flight. */
|
|
25
|
+
readonly pending: boolean;
|
|
26
|
+
readonly disabled: boolean;
|
|
27
|
+
readonly readOnly: boolean;
|
|
28
|
+
readonly required: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface NumberFieldRootProps extends Omit<ComponentPropsWithRef<"div">, "defaultValue" | "role" | "className" | "style" | "children"> {
|
|
31
|
+
/** Controlled value; `null` is empty, `undefined` uncontrolled. */
|
|
32
|
+
value?: number | null;
|
|
33
|
+
/** Initial value in uncontrolled mode, and its form-reset target (latest). Default `null` (empty). */
|
|
34
|
+
defaultValue?: number | null;
|
|
35
|
+
/**
|
|
36
|
+
* Runs inside the Root's step transition on every step: the parse of typed text at commit,
|
|
37
|
+
* each key press, each tick of a hold, each wheel event, each platform change, and the revert
|
|
38
|
+
* after a rejected commit (`reason: "dismiss"`, uncontrolled). Keep it cheap: adopt the value
|
|
39
|
+
* (`setValue(next)` in the sync prefix is a transition update), start a deferred render.
|
|
40
|
+
*/
|
|
41
|
+
valueChangeAction?: ChangeAction<number | null, NumberFieldValueChangeDetails>;
|
|
42
|
+
/**
|
|
43
|
+
* Runs inside the Root's commit transition once per gesture: a typed text's blur or Enter, a
|
|
44
|
+
* hold's release, each key press, each wheel event, a form reset, text typed before hydration.
|
|
45
|
+
* Where the save goes; uncontrolled state is committed when it resolves and reverts when it
|
|
46
|
+
* rejects. May be a Server Function.
|
|
47
|
+
*/
|
|
48
|
+
valueCommitAction?: ChangeAction<number | null, NumberFieldValueChangeDetails>;
|
|
49
|
+
/** Native `min` on the hidden input (a constraint) and the lower bound of stepping. */
|
|
50
|
+
min?: number;
|
|
51
|
+
/** Native `max` on the hidden input (a constraint) and the upper bound of stepping. */
|
|
52
|
+
max?: number;
|
|
53
|
+
/** Native `step` and the stepping grid from `min` (else `0`). Default `1`, or `0.01` when `format.style` is `"percent"`. */
|
|
54
|
+
step?: number;
|
|
55
|
+
/** PageUp / PageDown and Shift+Arrow. Default `10 × step`. */
|
|
56
|
+
largeStep?: number;
|
|
57
|
+
/**
|
|
58
|
+
* `Intl.NumberFormatOptions` for the text: `style` `"decimal"` (default), `"percent"`,
|
|
59
|
+
* `"currency"` (with `currency`), `"unit"` (with `unit`); fraction digits, grouping, sign
|
|
60
|
+
* display. `notation: "compact"` is a dev warning (unparsable).
|
|
61
|
+
*/
|
|
62
|
+
format?: Intl.NumberFormatOptions;
|
|
63
|
+
/**
|
|
64
|
+
* BCP 47 tag(s). Default: the runtime's locale (`Intl.NumberFormat().resolvedOptions().locale`).
|
|
65
|
+
* Pass the page's `lang`; a dev warning fires when `document.documentElement.lang` disagrees
|
|
66
|
+
* and this prop is absent.
|
|
67
|
+
*/
|
|
68
|
+
locale?: string | readonly string[];
|
|
69
|
+
/** Step with the mouse wheel while the input is focused. Default `false`. */
|
|
70
|
+
stepOnWheel?: boolean;
|
|
71
|
+
/** Native `name` on the hidden input; defaults to the Field's `name` inside a `Field.Root`. */
|
|
72
|
+
name?: string;
|
|
73
|
+
/** Native `form` on the hidden input. */
|
|
74
|
+
form?: string;
|
|
75
|
+
/** Disables both inputs and the buttons; inherited by every part. */
|
|
76
|
+
disabled?: boolean;
|
|
77
|
+
/** Native `readonly` on both inputs; no stepping (buttons disabled, keys and wheel inert). */
|
|
78
|
+
readOnly?: boolean;
|
|
79
|
+
/** Native `required` on the hidden input (empty is `valueMissing`); or the Field's. */
|
|
80
|
+
required?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* What is announced (`ariaNotify()`, else a live region) after a key press, a wheel event, a
|
|
83
|
+
* click activation and a hold's release. Default: `(_, state) => state.text`. Return `null` to
|
|
84
|
+
* announce nothing.
|
|
85
|
+
*/
|
|
86
|
+
announce?: (value: number | null, state: NumberFieldState) => string | null;
|
|
87
|
+
className?: StateValue<string | undefined, NumberFieldState>;
|
|
88
|
+
style?: StateValue<CSSProperties | undefined, NumberFieldState>;
|
|
89
|
+
children?: StateValue<ReactNode, NumberFieldState>;
|
|
90
|
+
render?: RenderProp<ComponentPropsWithRef<"div">, NumberFieldState>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Owns the number field's state (design/components/number-field.md 2): the committed value
|
|
94
|
+
* through `useControllableAction` with `valueCommitAction` (once per gesture), each step through
|
|
95
|
+
* its own transition (`valueChangeAction`), the urgent draft text, the urgent value of the open
|
|
96
|
+
* gesture (`live`), the press-and-hold, the formatter and parser, the announcements, mount
|
|
97
|
+
* reconciliation and form reset (through the hidden input the Input renders).
|
|
98
|
+
*
|
|
99
|
+
* Owned keys (conventions 1.2): `role="group"`, `aria-labelledby` (token-merged: the consumer's,
|
|
100
|
+
* then `NumberField.Label`'s id while one is mounted, then a Field's label id), `data-pending`,
|
|
101
|
+
* `data-disabled`, `data-invalid` (inside a Field).
|
|
102
|
+
*/
|
|
103
|
+
export declare function NumberFieldRoot(props: NumberFieldRootProps): import("react").JSX.Element;
|
|
104
|
+
export declare namespace NumberFieldRoot {
|
|
105
|
+
var displayName: string;
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//# sourceMappingURL=number-field-root.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-field-root.d.mts","names":[],"sources":["../../src/number-field/number-field-root.tsx"],"mappings":";;;;iBA8CiB,sCAAsC;;;;;;;;;WAS5C,QAAQ;;WAER;;;iBAIM;;WAEN;;WAEA;;WAEA;WACA;WACA;WACA;;iBAGM,6BAA6B,KAC5C;;EAIA;;EAEA;;;;;;;EAOA,oBAAoB,4BAA4B;;;;;;;EAOhD,oBAAoB,4BAA4B;;EAEhD;;EAEA;;EAEA;;EAEA;;;;;;EAMA,SAAS,KAAK;;;;;;EAMd;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;EAMA,YAAY,sBAAsB,OAAO;EACzC,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;;wBAkCpC,gBAAgB,OAAO,uCAAoB,IAAA;yBAA3C"}
|