@funstack/ui 0.1.0-alpha.10 → 0.1.0-alpha.12
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.d.mts +3 -4
- package/dist/accordion/accordion-item.d.mts.map +1 -1
- package/dist/accordion/accordion-item.mjs +10 -4
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.d.mts +3 -4
- package/dist/accordion/accordion-panel.d.mts.map +1 -1
- package/dist/accordion/accordion-panel.mjs +2 -1
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts +3 -3
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +8 -19
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts +3 -4
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +5 -3
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/button/button.d.mts +4 -2
- package/dist/button/button.d.mts.map +1 -1
- package/dist/button/button.mjs +3 -2
- package/dist/button/button.mjs.map +1 -1
- package/dist/checkbox/checkbox.d.mts +4 -5
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +16 -59
- 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 +3 -4
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +21 -27
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.mjs +1 -6
- package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts +3 -4
- package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +12 -10
- package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +74 -101
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +5 -6
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-context.mjs.map +1 -1
- package/dist/combobox/combobox-group.d.mts.map +1 -1
- package/dist/combobox/combobox-group.mjs +2 -1
- package/dist/combobox/combobox-group.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +14 -7
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-list.d.mts.map +1 -1
- package/dist/combobox/combobox-list.mjs +6 -10
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +2 -1
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +9 -25
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts +11 -10
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +37 -109
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +6 -25
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.d.mts +2 -2
- package/dist/combobox/index.mjs +3 -3
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/combobox/use-combobox-form.mjs +56 -0
- package/dist/combobox/use-combobox-form.mjs.map +1 -0
- package/dist/combobox/use-option-registry.mjs +62 -0
- package/dist/combobox/use-option-registry.mjs.map +1 -0
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +29 -62
- 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.map +1 -1
- package/dist/dialog/dialog-form.mjs +5 -4
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +3 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +37 -98
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +30 -118
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +13 -16
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/field/field-control.mjs +6 -13
- package/dist/field/field-control.mjs.map +1 -1
- package/dist/field/field-description.d.mts.map +1 -1
- package/dist/field/field-description.mjs +1 -2
- package/dist/field/field-description.mjs.map +1 -1
- package/dist/field/field-error.d.mts.map +1 -1
- package/dist/field/field-error.mjs +1 -2
- package/dist/field/field-error.mjs.map +1 -1
- package/dist/field/field-label.d.mts.map +1 -1
- package/dist/field/field-label.mjs +3 -11
- package/dist/field/field-label.mjs.map +1 -1
- package/dist/field/field-root.mjs +21 -41
- package/dist/field/field-root.mjs.map +1 -1
- package/dist/field/index.mjs +1 -1
- package/dist/field/use-server-error-visibility.mjs +44 -0
- package/dist/field/use-server-error-visibility.mjs.map +1 -0
- package/dist/form/form-root.d.mts.map +1 -1
- package/dist/form/form-root.mjs +6 -7
- package/dist/form/form-root.mjs.map +1 -1
- package/dist/form/form-submit.d.mts +1 -1
- package/dist/form/form-submit.mjs +4 -10
- package/dist/form/form-submit.mjs.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/internal/anchor-position.mjs +1 -59
- package/dist/internal/anchor-position.mjs.map +1 -1
- package/dist/internal/announce.mjs.map +1 -1
- package/dist/internal/arrow-keys.mjs +21 -0
- package/dist/internal/arrow-keys.mjs.map +1 -0
- package/dist/internal/decimal.mjs +7 -1
- package/dist/internal/decimal.mjs.map +1 -1
- package/dist/internal/dom-order.mjs +17 -0
- package/dist/internal/dom-order.mjs.map +1 -0
- package/dist/internal/field-context.d.mts.map +1 -1
- package/dist/internal/field-context.mjs +11 -1
- package/dist/internal/field-context.mjs.map +1 -1
- package/dist/internal/focus-first-invalid.mjs +1 -1
- package/dist/internal/focus-first-invalid.mjs.map +1 -1
- package/dist/internal/group-member.mjs +37 -0
- package/dist/internal/group-member.mjs.map +1 -0
- package/dist/internal/overlay-popup.mjs +103 -0
- package/dist/internal/overlay-popup.mjs.map +1 -0
- package/dist/internal/popover-open.mjs +18 -0
- package/dist/internal/popover-open.mjs.map +1 -0
- package/dist/internal/render-element.d.mts +2 -0
- package/dist/internal/render-element.mjs +20 -2
- package/dist/internal/render-element.mjs.map +1 -1
- package/dist/internal/shipped-styles.mjs +14 -0
- package/dist/internal/shipped-styles.mjs.map +1 -0
- package/dist/internal/sync-presence.mjs +5 -1
- package/dist/internal/sync-presence.mjs.map +1 -1
- package/dist/internal/toolbar-context.mjs.map +1 -1
- package/dist/internal/tooltip-warm.mjs +1 -1
- package/dist/internal/tooltip-warm.mjs.map +1 -1
- package/dist/internal/transition-boundary.mjs +1 -1
- package/dist/internal/transition-boundary.mjs.map +1 -1
- package/dist/internal/types.d.mts +8 -6
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-action-trigger.mjs +5 -23
- package/dist/internal/use-action-trigger.mjs.map +1 -1
- package/dist/internal/use-checkable-input.mjs +79 -0
- package/dist/internal/use-checkable-input.mjs.map +1 -0
- package/dist/internal/use-controllable-action.mjs +16 -24
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-dev-warning.mjs +8 -4
- package/dist/internal/use-dev-warning.mjs.map +1 -1
- package/dist/internal/use-element-check.mjs +39 -0
- package/dist/internal/use-element-check.mjs.map +1 -0
- package/dist/internal/use-exit-animation.mjs +1 -1
- package/dist/internal/use-exit-animation.mjs.map +1 -1
- package/dist/internal/use-field-control.mjs +28 -12
- package/dist/internal/use-field-control.mjs.map +1 -1
- package/dist/internal/use-fieldset-group.mjs +46 -0
- package/dist/internal/use-fieldset-group.mjs.map +1 -0
- package/dist/internal/use-form-reset.mjs +1 -5
- package/dist/internal/use-form-reset.mjs.map +1 -1
- package/dist/internal/use-item-order.mjs +42 -0
- package/dist/internal/use-item-order.mjs.map +1 -0
- package/dist/internal/use-latest.mjs +4 -8
- package/dist/internal/use-latest.mjs.map +1 -1
- package/dist/internal/use-merged-refs.mjs +19 -0
- package/dist/internal/use-merged-refs.mjs.map +1 -0
- package/dist/internal/use-name-warning.mjs +84 -0
- package/dist/internal/use-name-warning.mjs.map +1 -0
- package/dist/internal/use-native-checked.mjs +4 -6
- package/dist/internal/use-native-checked.mjs.map +1 -1
- package/dist/internal/use-native-focusgroup.mjs +19 -0
- package/dist/internal/use-native-focusgroup.mjs.map +1 -0
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-overlay-close.mjs +63 -0
- package/dist/internal/use-overlay-close.mjs.map +1 -0
- package/dist/internal/{use-popover-root.mjs → use-overlay-root.mjs} +28 -39
- package/dist/internal/use-overlay-root.mjs.map +1 -0
- package/dist/internal/use-popover-popup.mjs +32 -78
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.d.mts +15 -0
- package/dist/internal/use-popover-trigger.d.mts.map +1 -0
- package/dist/internal/use-popover-trigger.mjs +13 -17
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/use-register-count.mjs +24 -0
- package/dist/internal/use-register-count.mjs.map +1 -0
- package/dist/internal/use-render.d.mts +2 -0
- package/dist/internal/use-render.mjs +2 -2
- package/dist/internal/use-render.mjs.map +1 -1
- package/dist/internal/use-resolved-placement.mjs +38 -22
- package/dist/internal/use-resolved-placement.mjs.map +1 -1
- package/dist/internal/use-roving-focus.mjs +5 -18
- package/dist/internal/use-roving-focus.mjs.map +1 -1
- package/dist/internal/use-superseded-rejection.mjs +47 -0
- package/dist/internal/use-superseded-rejection.mjs.map +1 -0
- package/dist/internal/validity.mjs +1 -13
- package/dist/internal/validity.mjs.map +1 -1
- package/dist/internal/value-set.mjs +41 -0
- package/dist/internal/value-set.mjs.map +1 -0
- package/dist/menu/index.d.mts +1 -1
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +2 -7
- package/dist/menu/menu-context-trigger.d.mts.map +1 -1
- package/dist/menu/menu-context-trigger.mjs +10 -187
- package/dist/menu/menu-context-trigger.mjs.map +1 -1
- package/dist/menu/menu-context.d.mts +1 -1
- package/dist/menu/menu-context.mjs +1 -1
- package/dist/menu/menu-context.mjs.map +1 -1
- package/dist/menu/menu-dom.mjs +1 -2
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-gestures.mjs +167 -0
- package/dist/menu/menu-gestures.mjs.map +1 -0
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +2 -1
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-hover.mjs +0 -1
- package/dist/menu/menu-hover.mjs.map +1 -1
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-outside.mjs +101 -0
- package/dist/menu/menu-outside.mjs.map +1 -0
- package/dist/menu/menu-point.mjs +85 -0
- package/dist/menu/menu-point.mjs.map +1 -0
- package/dist/menu/menu-popup.d.mts +6 -7
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +37 -248
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +10 -0
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +10 -8
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +6 -6
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +4 -9
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +8 -6
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/menu/use-menu-item.mjs +14 -16
- package/dist/menu/use-menu-item.mjs.map +1 -1
- package/dist/menu/use-menu-keyboard.mjs +88 -0
- package/dist/menu/use-menu-keyboard.mjs.map +1 -0
- package/dist/meter/meter-root.mjs +1 -1
- package/dist/number-field/index.d.mts +2 -1
- package/dist/number-field/index.d.mts.map +1 -1
- package/dist/number-field/index.mjs +2 -2
- package/dist/number-field/index.mjs.map +1 -1
- package/dist/number-field/number-field-arithmetic.mjs +30 -11
- package/dist/number-field/number-field-arithmetic.mjs.map +1 -1
- package/dist/number-field/number-field-context.d.mts +6 -1
- package/dist/number-field/number-field-context.d.mts.map +1 -0
- package/dist/number-field/number-field-context.mjs.map +1 -1
- package/dist/number-field/number-field-decrement.d.mts +1 -1
- package/dist/number-field/number-field-decrement.mjs +1 -1
- package/dist/number-field/number-field-decrement.mjs.map +1 -1
- package/dist/number-field/number-field-increment.d.mts +2 -22
- package/dist/number-field/number-field-increment.d.mts.map +1 -1
- package/dist/number-field/number-field-increment.mjs +2 -53
- package/dist/number-field/number-field-increment.mjs.map +1 -1
- package/dist/number-field/number-field-input.d.mts.map +1 -1
- package/dist/number-field/number-field-input.mjs +18 -22
- package/dist/number-field/number-field-input.mjs.map +1 -1
- package/dist/number-field/number-field-label.d.mts.map +1 -1
- package/dist/number-field/number-field-label.mjs +3 -9
- package/dist/number-field/number-field-label.mjs.map +1 -1
- package/dist/number-field/number-field-root.d.mts +2 -1
- package/dist/number-field/number-field-root.d.mts.map +1 -1
- package/dist/number-field/number-field-root.mjs +81 -91
- package/dist/number-field/number-field-root.mjs.map +1 -1
- package/dist/number-field/use-number-field-dev-warnings.mjs +28 -0
- package/dist/number-field/use-number-field-dev-warnings.mjs.map +1 -0
- package/dist/number-field/use-step-button.d.mts +24 -0
- package/dist/number-field/use-step-button.d.mts.map +1 -0
- package/dist/number-field/use-step-button.mjs +57 -3
- package/dist/number-field/use-step-button.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +28 -67
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-context.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +9 -6
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +13 -36
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.mjs +4 -3
- package/dist/popover/popover-root.mjs.map +1 -1
- package/dist/popover/popover-trigger.d.mts +4 -8
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +2 -1
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/progress-root.mjs +1 -1
- package/dist/radio-group/radio-group-context.mjs.map +1 -1
- package/dist/radio-group/radio-group-item.d.mts +3 -4
- package/dist/radio-group/radio-group-item.d.mts.map +1 -1
- package/dist/radio-group/radio-group-item.mjs +20 -25
- package/dist/radio-group/radio-group-item.mjs.map +1 -1
- package/dist/radio-group/radio-group-label.mjs +1 -6
- package/dist/radio-group/radio-group-label.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +1 -1
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +21 -40
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/select-dom.mjs +9 -18
- package/dist/select/select-dom.mjs.map +1 -1
- package/dist/select/select-option.mjs +1 -1
- package/dist/select/select-root.mjs +3 -2
- package/dist/select/select-root.mjs.map +1 -1
- package/dist/slider/slider-arithmetic.mjs +74 -13
- package/dist/slider/slider-arithmetic.mjs.map +1 -1
- package/dist/slider/slider-context.mjs.map +1 -1
- package/dist/slider/slider-label.d.mts.map +1 -1
- package/dist/slider/slider-label.mjs +3 -9
- package/dist/slider/slider-label.mjs.map +1 -1
- package/dist/slider/slider-root.d.mts +2 -2
- package/dist/slider/slider-root.d.mts.map +1 -1
- package/dist/slider/slider-root.mjs +36 -116
- package/dist/slider/slider-root.mjs.map +1 -1
- package/dist/slider/slider-thumb.d.mts.map +1 -1
- package/dist/slider/slider-thumb.mjs +8 -6
- package/dist/slider/slider-thumb.mjs.map +1 -1
- package/dist/slider/slider-value.d.mts.map +1 -1
- package/dist/slider/slider-value.mjs +2 -1
- package/dist/slider/slider-value.mjs.map +1 -1
- package/dist/slider/use-slider-dev-warnings.mjs +29 -0
- package/dist/slider/use-slider-dev-warnings.mjs.map +1 -0
- package/dist/slider/use-thumb-registry.mjs +51 -0
- package/dist/slider/use-thumb-registry.mjs.map +1 -0
- package/dist/switch/switch.d.mts +4 -5
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +15 -55
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/tabs-context.d.mts +2 -3
- package/dist/tabs/tabs-context.d.mts.map +1 -1
- package/dist/tabs/tabs-context.mjs.map +1 -1
- package/dist/tabs/tabs-list.d.mts.map +1 -1
- package/dist/tabs/tabs-list.mjs +9 -22
- package/dist/tabs/tabs-list.mjs.map +1 -1
- package/dist/tabs/tabs-panel.d.mts +3 -4
- package/dist/tabs/tabs-panel.d.mts.map +1 -1
- package/dist/tabs/tabs-panel.mjs.map +1 -1
- package/dist/tabs/tabs-root.d.mts +4 -3
- package/dist/tabs/tabs-root.d.mts.map +1 -1
- package/dist/tabs/tabs-root.mjs +2 -1
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.d.mts +3 -4
- package/dist/tabs/tabs-tab.d.mts.map +1 -1
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/toast-action.mjs.map +1 -1
- package/dist/toast/toast-close.d.mts.map +1 -1
- package/dist/toast/toast-close.mjs +2 -8
- package/dist/toast/toast-close.mjs.map +1 -1
- package/dist/toast/toast-context.mjs.map +1 -1
- package/dist/toast/toast-hotkey.mjs +27 -0
- package/dist/toast/toast-hotkey.mjs.map +1 -0
- package/dist/toast/toast-queue.mjs +137 -0
- package/dist/toast/toast-queue.mjs.map +1 -0
- package/dist/toast/toast-timers.mjs +65 -0
- package/dist/toast/toast-timers.mjs.map +1 -0
- package/dist/toast/toast-viewport.d.mts.map +1 -1
- package/dist/toast/toast-viewport.mjs +30 -235
- package/dist/toast/toast-viewport.mjs.map +1 -1
- package/dist/toast/toast.mjs +1 -1
- package/dist/toast/toast.mjs.map +1 -1
- package/dist/toast/use-modal-portal-host.mjs +52 -0
- package/dist/toast/use-modal-portal-host.mjs.map +1 -0
- package/dist/toggle/toggle.d.mts +3 -4
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +7 -10
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-context.d.mts +2 -1
- 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 +5 -3
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-item.mjs +5 -7
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-root.mjs +29 -64
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
- package/dist/toolbar/toolbar-root.d.mts +2 -2
- package/dist/toolbar/toolbar-root.d.mts.map +1 -1
- package/dist/toolbar/toolbar-root.mjs +3 -4
- package/dist/toolbar/toolbar-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-context.d.mts +1 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +6 -15
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +2 -2
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +2 -1
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +3 -2
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/dist/tooltip/use-tooltip-interaction.mjs +4 -3
- package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/accordion/accordion-context.d.mts +0 -5
- package/dist/accordion/accordion-context.d.mts.map +0 -1
- package/dist/internal/use-popover-root.mjs.map +0 -1
- /package/dist/internal/{use-popover-root.d.mts → use-overlay-root.d.mts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field-arithmetic.mjs","names":[],"sources":["../../src/number-field/number-field-arithmetic.ts"],"sourcesContent":["// Stepping arithmetic of NumberField (design/components/number-field.md 5.5). No directive: no\n// React, no client-only API. The spec's `stepUp(n)` / `stepDown(n)` (snap off-grid values in the\n// stepping direction, clamp into `[min, max]` on the grid), not the native UI stepping.\nimport {
|
|
1
|
+
{"version":3,"file":"number-field-arithmetic.mjs","names":[],"sources":["../../src/number-field/number-field-arithmetic.ts"],"sourcesContent":["// Stepping arithmetic of NumberField (design/components/number-field.md 5.5). No directive: no\n// React, no client-only API. The spec's `stepUp(n)` / `stepDown(n)` (snap off-grid values in the\n// stepping direction, clamp into `[min, max]` on the grid), not the native UI stepping.\nimport { EPSILON, gridDecimals, roundTo } from \"../internal/decimal.js\";\n\nexport interface StepBounds {\n readonly min: number | undefined;\n readonly max: number | undefined;\n /** Positive. */\n readonly step: number;\n}\n\nfunction decimalsFor(bounds: StepBounds): number {\n return gridDecimals(bounds.step, bounds.min ?? 0);\n}\n\n/** The largest grid point `≤ max` (an unreachable `max` stays unreachable: `0..5` by `2` is `4`). */\nfunction gridMax(max: number, base: number, step: number): number {\n return base + Math.floor((max - base) / step + EPSILON) * step;\n}\n\nfunction clampAndGuard(\n result: number,\n current: number | null,\n direction: number,\n bounds: StepBounds,\n): number {\n const { min, max, step } = bounds;\n const base = min ?? 0;\n let next = result;\n if (max !== undefined && next > max + EPSILON) next = gridMax(max, base, step);\n if (min !== undefined && next < min - EPSILON) next = min;\n next = roundTo(next, decimalsFor(bounds));\n // 4. A step that would move against its direction changes nothing (an empty value has no\n // direction to keep: empty + ArrowDown with `min 3` is `3`, design 5.5).\n if (current !== null) {\n if (direction > 0 && next < current) return current;\n if (direction < 0 && next > current) return current;\n }\n return next;\n}\n\n/**\n * `current` stepped `n` times (`n > 0` up, `n < 0` down): empty counts as `0`; the step base is\n * `min` (else `0`); an off-grid value snaps to the nearest grid point in the stepping direction,\n * which counts as one step; the result is clamped to `[min, max]` on the grid and rounded to the\n * decimals of `step` and `min`. When the clamp would move the value against the direction, the\n * value is returned unchanged.\n */\nexport function stepValue(current: number | null, n: number, bounds: StepBounds): number {\n const { min, step } = bounds;\n const value = current ?? 0;\n const base = min ?? 0;\n const index = (value - base) / step;\n const nearest = Math.round(index);\n let target: number;\n if (Math.abs(index - nearest) <= EPSILON * Math.max(1, Math.abs(index))) {\n target = nearest + n;\n } else if (n > 0) {\n target = Math.ceil(index) + (n - 1);\n } else {\n target = Math.floor(index) + (n + 1);\n }\n return clampAndGuard(base + target * step, current, n, bounds);\n}\n\n/**\n * `current` moved by `delta` (PageUp / PageDown, Shift+Arrow: `± largeStep`). A whole number of\n * steps is `stepValue(current, delta / step)`; otherwise the value moves by `delta` and snaps to\n * the grid toward the start (never past `delta`), at least one step.\n */\nexport function stepBy(current: number | null, delta: number, bounds: StepBounds): number {\n const { min, step } = bounds;\n const ratio = delta / step;\n if (Math.abs(ratio - Math.round(ratio)) <= EPSILON * Math.max(1, Math.abs(ratio))) {\n return stepValue(current, Math.round(ratio), bounds);\n }\n const value = current ?? 0;\n const base = min ?? 0;\n const index = (value + delta - base) / step;\n let target = delta > 0 ? Math.floor(index + EPSILON) : Math.ceil(index - EPSILON);\n const start = (value - base) / step;\n if (delta > 0 && target <= start + EPSILON) target = Math.floor(start + EPSILON) + 1;\n if (delta < 0 && target >= start - EPSILON) target = Math.ceil(start - EPSILON) - 1;\n return clampAndGuard(base + target * step, current, delta, bounds);\n}\n\n/** The bound a Home / End key moves to: `min`, or the largest grid point `≤ max`. */\nexport function boundValue(which: \"min\" | \"max\", bounds: StepBounds): number | undefined {\n const { min, max, step } = bounds;\n if (which === \"min\") return min;\n if (max === undefined) return undefined;\n if (min !== undefined && max < min) return min;\n return roundTo(gridMax(max, min ?? 0, step), decimalsFor(bounds));\n}\n\n/** The next step in `direction` would change nothing (a button at its bound). Empty never is. */\nexport function isAtBound(value: number | null, direction: 1 | -1, bounds: StepBounds): boolean {\n if (value === null) return false;\n return stepValue(value, direction, bounds) === value;\n}\n\n/**\n * The step a key makes (design 4.2) from the value it steps from: ArrowUp / ArrowDown one step\n * (with Shift `± largeStep`), PageUp / PageDown `± largeStep`, Home / End the bound\n * (`boundValue`; nothing without one, and nothing with Shift, which selects text). `null`: the key\n * is not a NumberField key.\n */\nexport function keyStep(\n key: string,\n shiftKey: boolean,\n bounds: StepBounds,\n largeStep: number,\n): ((base: number | null) => number | null) | null {\n switch (key) {\n case \"ArrowUp\":\n return shiftKey ? (v) => stepBy(v, largeStep, bounds) : (v) => stepValue(v, 1, bounds);\n case \"ArrowDown\":\n return shiftKey ? (v) => stepBy(v, -largeStep, bounds) : (v) => stepValue(v, -1, bounds);\n case \"PageUp\":\n return (v) => stepBy(v, largeStep, bounds);\n case \"PageDown\":\n return (v) => stepBy(v, -largeStep, bounds);\n case \"Home\":\n case \"End\": {\n if (shiftKey) return null;\n const target = boundValue(key === \"Home\" ? \"min\" : \"max\", bounds);\n return target === undefined ? null : () => target;\n }\n default:\n return null;\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import "./number-field-root.mjs";
|
|
2
|
-
import { RefObject } from "react";
|
|
2
|
+
import { RefObject } from "react";
|
|
3
|
+
//#region src/number-field/number-field-context.d.ts
|
|
4
|
+
/** What produced a step or a commit (`details.source`). */
|
|
5
|
+
export type NumberFieldSource = "input" | "increment" | "decrement" | "keyboard" | "wheel" | null;
|
|
6
|
+
//#endregion
|
|
7
|
+
//# sourceMappingURL=number-field-context.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-field-context.d.mts","names":[],"sources":["../../src/number-field/number-field-context.ts"],"mappings":";;;;YAUY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field-context.mjs","names":[],"sources":["../../src/number-field/number-field-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { StepBounds } from \"./number-field-arithmetic.js\";\nimport type { NumberFieldState } from \"./number-field-root.js\";\n\n/** A step button's direction. */\nexport type StepDirection = \"increment\" | \"decrement\";\n\n/** What produced a step or a commit (`details.source`). */\nexport type NumberFieldSource = \"input\" | \"increment\" | \"decrement\" | \"keyboard\" | \"wheel\" | null;\n\nexport interface NumberFieldContextValue {\n /** The state every part's function props receive. */\n readonly state: NumberFieldState;\n readonly bounds: StepBounds;\n /** What a button steps from: the parsed draft while one is open, else the shown value. */\n readonly stepBase: number | null;\n /** The Root is pending and the latest step or commit came from this source. */\n readonly pendingSource: NumberFieldSource;\n /** Ids: the visible input (the Root's, or a Field's control id) and the Label. */\n readonly inputId: string;\n readonly labelId: string;\n readonly name: string | undefined;\n readonly form: string | undefined;\n /** `inputmode=\"decimal\"` rather than `\"numeric\"` (8.5). */\n readonly allowsFractions: boolean;\n readonly stepOnWheel: boolean;\n /** The hidden input's `defaultValue`: the reset target as `String(number)` or `\"\"`. */\n readonly resetTargetText: string;\n /** Inside a `Field.Root`: `data-invalid` on the Root and the Input. */\n readonly fieldInvalid: boolean | undefined;\n readonly visibleRef: RefObject<HTMLInputElement | null>;\n readonly hiddenRef: RefObject<HTMLInputElement | null>;\n\n /** `input` on the visible input: the urgent draft. */\n readonly typed: (text: string) => void;\n /** `focusout` on the visible input: commit the draft (4.1). */\n readonly commitDraft: (event: Event) => void;\n /** `keydown` on the visible input (4.2). */\n readonly keyDown: (event: KeyboardEvent) => void;\n /** The native `wheel` listener on the visible input (4.4). */\n readonly wheel: (event: WheelEvent) => void;\n /** `pointerdown` on a button: the first step; `false` when no hold is open afterwards. */\n readonly beginHold: (direction: StepDirection, event: Event) => boolean;\n /** One tick of the hold; `false` when the hold ended (the bound was reached). */\n readonly tickHold: (direction: StepDirection, event: Event | undefined) => boolean;\n /** The hold's release (or cancel): one commit. */\n readonly endHold: (direction: StepDirection, event: Event) => void;\n /** A click with no pointer gesture (assistive technology): step + commit. */\n readonly activate: (direction: StepDirection, event: Event) => void;\n
|
|
1
|
+
{"version":3,"file":"number-field-context.mjs","names":[],"sources":["../../src/number-field/number-field-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { StepBounds } from \"./number-field-arithmetic.js\";\nimport type { NumberFieldState } from \"./number-field-root.js\";\n\n/** A step button's direction. */\nexport type StepDirection = \"increment\" | \"decrement\";\n\n/** What produced a step or a commit (`details.source`). */\nexport type NumberFieldSource = \"input\" | \"increment\" | \"decrement\" | \"keyboard\" | \"wheel\" | null;\n\nexport interface NumberFieldContextValue {\n /** The state every part's function props receive. */\n readonly state: NumberFieldState;\n readonly bounds: StepBounds;\n /** What a button steps from: the parsed draft while one is open, else the shown value. */\n readonly stepBase: number | null;\n /** The Root is pending and the latest step or commit came from this source. */\n readonly pendingSource: NumberFieldSource;\n /** Ids: the visible input (the Root's, or a Field's control id) and the Label. */\n readonly inputId: string;\n readonly labelId: string;\n readonly name: string | undefined;\n readonly form: string | undefined;\n /** `inputmode=\"decimal\"` rather than `\"numeric\"` (8.5). */\n readonly allowsFractions: boolean;\n readonly stepOnWheel: boolean;\n /** The hidden input's `defaultValue`: the reset target as `String(number)` or `\"\"`. */\n readonly resetTargetText: string;\n /** Inside a `Field.Root`: `data-invalid` on the Root and the Input. */\n readonly fieldInvalid: boolean | undefined;\n readonly visibleRef: RefObject<HTMLInputElement | null>;\n readonly hiddenRef: RefObject<HTMLInputElement | null>;\n\n /** `input` on the visible input: the urgent draft. */\n readonly typed: (text: string) => void;\n /** `focusout` on the visible input: commit the draft (4.1). */\n readonly commitDraft: (event: Event) => void;\n /** `keydown` on the visible input (4.2). */\n readonly keyDown: (event: KeyboardEvent) => void;\n /** The native `wheel` listener on the visible input (4.4). */\n readonly wheel: (event: WheelEvent) => void;\n /** `pointerdown` on a button: the first step; `false` when no hold is open afterwards. */\n readonly beginHold: (direction: StepDirection, event: Event) => boolean;\n /** One tick of the hold; `false` when the hold ended (the bound was reached). */\n readonly tickHold: (direction: StepDirection, event: Event | undefined) => boolean;\n /** The hold's release (or cancel): one commit. */\n readonly endHold: (direction: StepDirection, event: Event) => void;\n /** A click with no pointer gesture (assistive technology): step + commit. */\n readonly activate: (direction: StepDirection, event: Event) => void;\n /**\n * Writes a value into the hidden input, then mirrors its `validationMessage` onto the visible\n * input (6.2).\n */\n readonly syncHidden: (value: number | null) => void;\n /** Called by the Label from a layout effect; returns the unregistration. */\n readonly registerLabel: () => () => void;\n /** Called by the Input from its mount layout effect (late mount reconciliation). */\n readonly onItemMounted: () => void;\n}\n\nexport const NumberFieldContext = createContext<NumberFieldContextValue | null>(null);\n\nexport function useNumberFieldContext(part: string): NumberFieldContextValue {\n const context = use(NumberFieldContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a NumberField.Root.`);\n }\n return context;\n}\n"],"mappings":";;;AA8DA,MAAa,qBAAqB,cAA8C,IAAI;AAEpF,SAAgB,sBAAsB,MAAuC;CAC3E,MAAM,UAAU,IAAI,kBAAkB;CACtC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,6CAA6C;CAEvE,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NumberFieldDecrementProps } from "./
|
|
1
|
+
import { NumberFieldDecrementProps } from "./use-step-button.mjs";
|
|
2
2
|
//#region src/number-field/number-field-decrement.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Steps the value down: `button[type=button][tabindex=-1]` with `aria-controls` → the input and
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useStepButtonElement } from "./
|
|
2
|
+
import { useStepButtonElement } from "./use-step-button.mjs";
|
|
3
3
|
//#region src/number-field/number-field-decrement.tsx
|
|
4
4
|
/**
|
|
5
5
|
* Steps the value down: `button[type=button][tabindex=-1]` with `aria-controls` → the input and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field-decrement.mjs","names":[],"sources":["../../src/number-field/number-field-decrement.tsx"],"sourcesContent":["\"use client\";\nimport { useStepButtonElement } from \"./
|
|
1
|
+
{"version":3,"file":"number-field-decrement.mjs","names":[],"sources":["../../src/number-field/number-field-decrement.tsx"],"sourcesContent":["\"use client\";\nimport { useStepButtonElement } from \"./use-step-button.js\";\nimport type { NumberFieldDecrementProps } from \"./use-step-button.js\";\n\nexport type { NumberFieldDecrementProps } from \"./use-step-button.js\";\n\n/**\n * Steps the value down: `button[type=button][tabindex=-1]` with `aria-controls` → the input and\n * the default `aria-label` `\"Decrease\"`; one step at the press, then repeated while held, one\n * commit at the release. Natively `disabled` when the next step would change nothing\n * (`aria-disabled` with a link or component `render`).\n *\n * Owned keys: `type`, `tabIndex`, `aria-controls`, `disabled`, `aria-disabled` (link or component\n * `render`), `onPointerDown`, `onClick`, `onContextMenu`, `data-pending`, `data-disabled`.\n */\nexport function NumberFieldDecrement(props: NumberFieldDecrementProps) {\n return useStepButtonElement(\"decrement\", \"NumberField.Decrement\", props);\n}\n\nNumberFieldDecrement.displayName = \"NumberFieldDecrement\";\n"],"mappings":";;;;;;;;;;;;AAeA,SAAgB,qBAAqB,OAAkC;CACrE,OAAO,qBAAqB,aAAa,yBAAyB,KAAK;AACzE;AAEA,qBAAqB,cAAc"}
|
|
@@ -1,25 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./number-field-context.mjs";
|
|
3
|
-
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
1
|
+
import { NumberFieldButtonState, NumberFieldDecrementProps, NumberFieldIncrementProps } from "./use-step-button.mjs";
|
|
4
2
|
//#region src/number-field/number-field-increment.d.ts
|
|
5
|
-
export interface NumberFieldButtonState {
|
|
6
|
-
/** The Root is pending and the latest step or commit came from this button. */
|
|
7
|
-
readonly pending: boolean;
|
|
8
|
-
/** The prop, the Root's `disabled` or `readOnly`, or the next step would change nothing. */
|
|
9
|
-
readonly disabled: boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface NumberFieldIncrementProps extends Omit<ComponentPropsWithRef<"button">, "type" | "tabIndex" | "disabled" | "onPointerDown" | "onClick" | "onContextMenu" | "aria-controls" | "className" | "style" | "children"> {
|
|
12
|
-
/**
|
|
13
|
-
* Never steps. Native `disabled` on a `<button>` (also at the bound and under `readOnly`); with
|
|
14
|
-
* a link or component `render`, `aria-disabled="true"` instead.
|
|
15
|
-
*/
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
className?: StateValue<string | undefined, NumberFieldButtonState>;
|
|
18
|
-
style?: StateValue<CSSProperties | undefined, NumberFieldButtonState>;
|
|
19
|
-
children?: StateValue<ReactNode, NumberFieldButtonState>;
|
|
20
|
-
render?: RenderProp<ComponentPropsWithRef<"button">, NumberFieldButtonState>;
|
|
21
|
-
}
|
|
22
|
-
export type NumberFieldDecrementProps = NumberFieldIncrementProps;
|
|
23
3
|
/**
|
|
24
4
|
* Steps the value up: `button[type=button][tabindex=-1]` with `aria-controls` → the input and the
|
|
25
5
|
* default `aria-label` `"Increase"`; one step at the press, then repeated while held, one commit
|
|
@@ -29,7 +9,7 @@ export type NumberFieldDecrementProps = NumberFieldIncrementProps;
|
|
|
29
9
|
* Owned keys: `type`, `tabIndex`, `aria-controls`, `disabled`, `aria-disabled` (link or component
|
|
30
10
|
* `render`), `onPointerDown`, `onClick`, `onContextMenu`, `data-pending`, `data-disabled`.
|
|
31
11
|
*/
|
|
32
|
-
export declare function NumberFieldIncrement(props: NumberFieldIncrementProps): ReactNode;
|
|
12
|
+
export declare function NumberFieldIncrement(props: NumberFieldIncrementProps): import("react").ReactNode;
|
|
33
13
|
export declare namespace NumberFieldIncrement {
|
|
34
14
|
var displayName: string;
|
|
35
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field-increment.d.mts","names":[],"sources":["../../src/number-field/number-field-increment.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"number-field-increment.d.mts","names":[],"sources":["../../src/number-field/number-field-increment.tsx"],"mappings":";;;;;;;;;;;wBAmBgB,qBAAqB,OAAO,4CAAyB;yBAArD"}
|
|
@@ -1,57 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
4
|
-
import { isHostButton, rendersButton } from "../internal/render-element.mjs";
|
|
5
|
-
import { useRender } from "../internal/use-render.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";
|
|
2
|
+
import { useStepButtonElement } from "./use-step-button.mjs";
|
|
9
3
|
//#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
|
-
const focusable = !isHostButton(render);
|
|
28
|
-
useDevWarning(rest["aria-label"] === "", `${part}: \`aria-label=""\` leaves the button without a name. Pass the label text instead (the default is "${LABELS[direction]}").`);
|
|
29
|
-
const props$ = {
|
|
30
|
-
...rest["aria-labelledby"] === void 0 ? { "aria-label": LABELS[direction] } : {},
|
|
31
|
-
...rest
|
|
32
|
-
};
|
|
33
|
-
return useRender({
|
|
34
|
-
defaultElement: "button",
|
|
35
|
-
render,
|
|
36
|
-
state: buttonState,
|
|
37
|
-
className,
|
|
38
|
-
style,
|
|
39
|
-
children,
|
|
40
|
-
props: props$,
|
|
41
|
-
libraryProps: {
|
|
42
|
-
...rendersButton(render) ? { type: "button" } : {},
|
|
43
|
-
tabIndex: -1,
|
|
44
|
-
"aria-controls": ctx.inputId,
|
|
45
|
-
disabled: focusable ? void 0 : disabled,
|
|
46
|
-
...focusable && { "aria-disabled": disabled ? true : void 0 },
|
|
47
|
-
onPointerDown: handlers.onPointerDown,
|
|
48
|
-
onClick: handlers.onClick,
|
|
49
|
-
onContextMenu: handlers.onContextMenu,
|
|
50
|
-
"data-pending": dataAttr(pending),
|
|
51
|
-
"data-disabled": dataAttr(disabled)
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
4
|
/**
|
|
56
5
|
* Steps the value up: `button[type=button][tabindex=-1]` with `aria-controls` → the input and the
|
|
57
6
|
* default `aria-label` `"Increase"`; one step at the press, then repeated while held, one commit
|
|
@@ -66,6 +15,6 @@ function NumberFieldIncrement(props) {
|
|
|
66
15
|
}
|
|
67
16
|
NumberFieldIncrement.displayName = "NumberFieldIncrement";
|
|
68
17
|
//#endregion
|
|
69
|
-
export { NumberFieldIncrement
|
|
18
|
+
export { NumberFieldIncrement };
|
|
70
19
|
|
|
71
20
|
//# sourceMappingURL=number-field-increment.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field-increment.mjs","names":[],"sources":["../../src/number-field/number-field-increment.tsx"],"sourcesContent":["\"use client\";\nimport
|
|
1
|
+
{"version":3,"file":"number-field-increment.mjs","names":[],"sources":["../../src/number-field/number-field-increment.tsx"],"sourcesContent":["\"use client\";\nimport { useStepButtonElement } from \"./use-step-button.js\";\nimport type { NumberFieldIncrementProps } from \"./use-step-button.js\";\n\nexport type {\n NumberFieldButtonState,\n NumberFieldIncrementProps,\n NumberFieldDecrementProps,\n} from \"./use-step-button.js\";\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 (`aria-disabled`\n * with a link or component `render`).\n *\n * Owned keys: `type`, `tabIndex`, `aria-controls`, `disabled`, `aria-disabled` (link or component\n * `render`), `onPointerDown`, `onClick`, `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":";;;;;;;;;;;;AAmBA,SAAgB,qBAAqB,OAAkC;CACrE,OAAO,qBAAqB,aAAa,yBAAyB,KAAK;AACzE;AAEA,qBAAqB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field-input.d.mts","names":[],"sources":["../../src/number-field/number-field-input.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"number-field-input.d.mts","names":[],"sources":["../../src/number-field/number-field-input.tsx"],"mappings":";;;;iBAuBiB,8BAA8B,KAC7C;;EAsBA,iBAAiB,IAAI;EACrB,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,gCAAgC;;;;;;;;;;;;;wBA8BtC,mBACd,gBACA,WACA,OACA,WACG,QACF,wCAAqB,IAAA;yBANR"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { dataAttr } from "../internal/data-attr.mjs";
|
|
3
3
|
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
4
|
-
import { mergeRefs } from "../internal/merge-props.mjs";
|
|
5
4
|
import { useRender } from "../internal/use-render.mjs";
|
|
6
|
-
import {
|
|
5
|
+
import { useElementCheck } from "../internal/use-element-check.mjs";
|
|
6
|
+
import { useMergedRefs } from "../internal/use-merged-refs.mjs";
|
|
7
|
+
import { useFieldControl } from "../internal/use-field-control.mjs";
|
|
7
8
|
import { useNumberFieldContext } from "./number-field-context.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { isValidElement, useCallback, useEffectEvent, useLayoutEffect, useMemo, useRef } from "react";
|
|
9
|
+
import { isValidElement, useCallback, useEffectEvent, useLayoutEffect, useRef } from "react";
|
|
10
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
//#region src/number-field/number-field-input.tsx
|
|
12
12
|
const isDev = process.env.NODE_ENV !== "production";
|
|
@@ -41,7 +41,7 @@ const TEXT_TYPES = [
|
|
|
41
41
|
*/
|
|
42
42
|
function NumberFieldInput({ hiddenInputRef, className, style, render, ...rest }) {
|
|
43
43
|
const ctx = useNumberFieldContext("NumberField.Input");
|
|
44
|
-
const { state, visibleRef, hiddenRef,
|
|
44
|
+
const { state, visibleRef, hiddenRef, syncHidden, onItemMounted } = ctx;
|
|
45
45
|
const validityElement = useCallback(() => hiddenRef.current, [hiddenRef]);
|
|
46
46
|
const field = useFieldControl({
|
|
47
47
|
labelable: true,
|
|
@@ -52,26 +52,22 @@ function NumberFieldInput({ hiddenInputRef, className, style, render, ...rest })
|
|
|
52
52
|
validityElement
|
|
53
53
|
});
|
|
54
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.");
|
|
55
|
+
useDevWarning(restName !== void 0, isDev && "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 checkElement = useElementCheck(isDev && ((element) => {
|
|
57
|
+
const type = element.tagName === "INPUT" ? element.type : "";
|
|
58
|
+
return !TEXT_TYPES.includes(type) ? `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.` : null;
|
|
59
|
+
}));
|
|
56
60
|
const libraryRef = useCallback((element) => {
|
|
57
|
-
|
|
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
|
+
checkElement?.(element);
|
|
61
62
|
visibleRef.current = element;
|
|
62
63
|
return () => {
|
|
63
64
|
if (visibleRef.current === element) visibleRef.current = null;
|
|
64
65
|
};
|
|
65
|
-
}, [visibleRef]);
|
|
66
|
-
const mergedRef =
|
|
67
|
-
const hiddenMergedRef =
|
|
66
|
+
}, [checkElement, visibleRef]);
|
|
67
|
+
const mergedRef = useMergedRefs(libraryRef, field.ref);
|
|
68
|
+
const hiddenMergedRef = useMergedRefs(hiddenRef, hiddenInputRef);
|
|
68
69
|
useLayoutEffect(() => {
|
|
69
|
-
|
|
70
|
-
if (hidden !== null) {
|
|
71
|
-
const text = hiddenText(state.value);
|
|
72
|
-
if (hidden.value !== text) hidden.value = text;
|
|
73
|
-
}
|
|
74
|
-
mirror();
|
|
70
|
+
syncHidden(state.value);
|
|
75
71
|
});
|
|
76
72
|
useLayoutEffect(() => {
|
|
77
73
|
const hidden = hiddenRef.current;
|
|
@@ -94,11 +90,11 @@ function NumberFieldInput({ hiddenInputRef, className, style, render, ...rest })
|
|
|
94
90
|
useLayoutEffect(() => {
|
|
95
91
|
if (mounted.current) return;
|
|
96
92
|
mounted.current = true;
|
|
97
|
-
|
|
98
|
-
}, [
|
|
93
|
+
onItemMounted();
|
|
94
|
+
}, [onItemMounted]);
|
|
99
95
|
const renderType = isValidElement(render) && typeof render.props.type === "string" ? render.props.type : void 0;
|
|
100
96
|
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.`);
|
|
97
|
+
useDevWarning(renderType !== void 0 && !TEXT_TYPES.includes(renderType), isDev && `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
98
|
const dataInvalid = ctx.fieldInvalid === void 0 ? {} : { "data-invalid": dataAttr(ctx.fieldInvalid) };
|
|
103
99
|
const libraryProps = {
|
|
104
100
|
...field.attributes,
|
|
@@ -1 +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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"}
|
|
1
|
+
{"version":3,"file":"number-field-input.mjs","names":[],"sources":["../../src/number-field/number-field-input.tsx"],"sourcesContent":["\"use client\";\nimport { isValidElement, useCallback, useEffectEvent, useLayoutEffect, useRef } 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 type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.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\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport type { NumberFieldState } from \"./number-field-root.js\";\nimport { useNumberFieldContext } from \"./number-field-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\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\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, syncHidden, onItemMounted } = 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 isDev &&\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 checkElement = useElementCheck(\n isDev &&\n ((element) => {\n const type = element.tagName === \"INPUT\" ? (element as HTMLInputElement).type : \"\";\n return !TEXT_TYPES.includes(type)\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 : null;\n }),\n );\n const libraryRef = useCallback(\n (element: HTMLElement) => {\n checkElement?.(element);\n visibleRef.current = element as HTMLInputElement;\n return () => {\n if (visibleRef.current === element) visibleRef.current = null;\n };\n },\n [checkElement, visibleRef],\n );\n const mergedRef = useMergedRefs<HTMLElement>(libraryRef, field.ref);\n\n const hiddenMergedRef = useMergedRefs<HTMLInputElement | null>(hiddenRef, hiddenInputRef);\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 syncHidden(state.value);\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 onItemMounted();\n }, [onItemMounted]);\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 isDev &&\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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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field-label.d.mts","names":[],"sources":["../../src/number-field/number-field-label.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"number-field-label.d.mts","names":[],"sources":["../../src/number-field/number-field-label.tsx"],"mappings":";;;;iBAYiB,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"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { dataAttr } from "../internal/data-attr.mjs";
|
|
3
3
|
import { useRender } from "../internal/use-render.mjs";
|
|
4
|
+
import { useElementCheck } from "../internal/use-element-check.mjs";
|
|
4
5
|
import { useNumberFieldContext } from "./number-field-context.mjs";
|
|
5
|
-
import {
|
|
6
|
+
import { useLayoutEffect } from "react";
|
|
6
7
|
//#region src/number-field/number-field-label.tsx
|
|
7
8
|
const isDev = process.env.NODE_ENV !== "production";
|
|
8
9
|
/**
|
|
@@ -15,14 +16,7 @@ function NumberFieldLabel({ className, style, children, render, ...rest }) {
|
|
|
15
16
|
const ctx = useNumberFieldContext("NumberField.Label");
|
|
16
17
|
const { registerLabel } = ctx;
|
|
17
18
|
useLayoutEffect(registerLabel, [registerLabel]);
|
|
18
|
-
const
|
|
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
|
-
}, []);
|
|
19
|
+
const libraryRef = useElementCheck(isDev && ((element) => element.tagName !== "LABEL" ? `NumberField.Label: expected a <label> element but got <${element.tagName.toLowerCase()}>. The Label names the input through \`for\`, which only a <label> has.` : null));
|
|
26
20
|
return useRender({
|
|
27
21
|
defaultElement: "label",
|
|
28
22
|
render,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field-label.mjs","names":[],"sources":["../../src/number-field/number-field-label.tsx"],"sourcesContent":["\"use client\";\nimport {
|
|
1
|
+
{"version":3,"file":"number-field-label.mjs","names":[],"sources":["../../src/number-field/number-field-label.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect } 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 { useElementCheck } from \"../internal/use-element-check.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 libraryRef = useElementCheck(\n isDev &&\n ((element) =>\n element.tagName !== \"LABEL\"\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 : null),\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":";;;;;;;AAUA,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,aAAa,gBACjB,WACI,YACA,QAAQ,YAAY,UAChB,0DAA0D,QAAQ,QAAQ,YAAY,EAAE,2EAExF,KACV;CAEA,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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ActionDetails, ChangeAction, ChangeReason, RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { NumberFieldSource } from "./number-field-context.mjs";
|
|
2
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
3
4
|
//#region src/number-field/number-field-root.d.ts
|
|
4
5
|
/** Details passed as the second argument of both NumberField actions. */
|
|
@@ -13,7 +14,7 @@ export interface NumberFieldValueChangeDetails extends ActionDetails {
|
|
|
13
14
|
*/
|
|
14
15
|
readonly reason: ChangeReason;
|
|
15
16
|
/** What produced the value: typed text, a button, a key, the wheel; `null` for "platform" and "dismiss". */
|
|
16
|
-
readonly source:
|
|
17
|
+
readonly source: NumberFieldSource;
|
|
17
18
|
}
|
|
18
19
|
/** The state every NumberField part's function props receive (one object, Field's precedent). */
|
|
19
20
|
export interface NumberFieldState {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field-root.d.mts","names":[],"sources":["../../src/number-field/number-field-root.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"number-field-root.d.mts","names":[],"sources":["../../src/number-field/number-field-root.tsx"],"mappings":";;;;;iBA+CiB,sCAAsC;;;;;;;;;WAS5C,QAAQ;;WAER,QAAQ;;;iBAIF;;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;;;;;;;;;;;;;wBAyDpC,gBAAgB,OAAO,uCAAoB,IAAA;yBAA3C"}
|