@funstack/ui 0.1.0-alpha.11 → 0.1.0-alpha.13
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 +6 -5
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +29 -14
- 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.map +1 -1
- package/dist/combobox/combobox-root.mjs +101 -106
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts +9 -6
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +36 -43
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.mjs +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 +5 -5
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +39 -103
- 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 +2 -1
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +27 -23
- 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 +22 -42
- 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 +2 -2
- package/dist/internal/anchor-position.mjs +1 -59
- package/dist/internal/anchor-position.mjs.map +1 -1
- package/dist/internal/announce.mjs +4 -42
- 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 +16 -7
- 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/pointer-capture.mjs +20 -0
- package/dist/internal/pointer-capture.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/trigger-ref.mjs +26 -0
- package/dist/internal/trigger-ref.mjs.map +1 -0
- package/dist/internal/types.d.mts +2 -0
- 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} +32 -39
- package/dist/internal/use-overlay-root.mjs.map +1 -0
- package/dist/internal/use-popover-popup.mjs +38 -80
- 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 +28 -24
- 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 +11 -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 +2 -17
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-gestures.mjs +166 -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 +38 -248
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.d.mts +2 -0
- package/dist/menu/menu-radio-item.d.mts.map +1 -1
- package/dist/menu/menu-radio-item.mjs +1 -0
- package/dist/menu/menu-radio-item.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 +12 -9
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +10 -11
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +14 -7
- 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 +3 -2
- 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 +10 -10
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +4 -2
- 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-root.d.mts.map +1 -1
- package/dist/toast/toast-root.mjs +2 -0
- package/dist/toast/toast-root.mjs.map +1 -1
- package/dist/toast/toast-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 +7 -3
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-item.mjs +6 -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,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 {
|
|
@@ -79,7 +80,7 @@ export interface NumberFieldRootProps extends Omit<ComponentPropsWithRef<"div">,
|
|
|
79
80
|
/** Native `required` on the hidden input (empty is `valueMissing`); or the Field's. */
|
|
80
81
|
required?: boolean;
|
|
81
82
|
/**
|
|
82
|
-
* What is announced (`ariaNotify()
|
|
83
|
+
* What is announced (`ariaNotify()`) after a key press, a wheel event, a
|
|
83
84
|
* click activation and a hold's release. Default: `(_, state) => state.text`. Return `null` to
|
|
84
85
|
* announce nothing.
|
|
85
86
|
*/
|
|
@@ -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"}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createActionDetails } from "../internal/action-details.mjs";
|
|
3
3
|
import { dataAttr } from "../internal/data-attr.mjs";
|
|
4
|
+
import { useSupersededRejection } from "../internal/use-superseded-rejection.mjs";
|
|
4
5
|
import { useActionTrigger } from "../internal/use-action-trigger.mjs";
|
|
5
|
-
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
6
6
|
import { mergeTokenLists } from "../internal/merge-props.mjs";
|
|
7
7
|
import { useRender } from "../internal/use-render.mjs";
|
|
8
8
|
import { transitionTypes } from "../internal/transition-types.mjs";
|
|
9
9
|
import { useLatest } from "../internal/use-latest.mjs";
|
|
10
10
|
import { useControllableAction } from "../internal/use-controllable-action.mjs";
|
|
11
11
|
import { FieldContext } from "../internal/field-context.mjs";
|
|
12
|
-
import { useFieldValueChange } from "../internal/use-field-control.mjs";
|
|
12
|
+
import { resolveFieldDefaults, useFieldValueChange } from "../internal/use-field-control.mjs";
|
|
13
13
|
import { useNativeGroupReconciliation } from "../internal/use-native-group-reconciliation.mjs";
|
|
14
|
-
import {
|
|
14
|
+
import { keyStep, stepValue } from "./number-field-arithmetic.mjs";
|
|
15
15
|
import { NumberFieldContext } from "./number-field-context.mjs";
|
|
16
16
|
import { announce } from "../internal/announce.mjs";
|
|
17
17
|
import { createNumberFormatter, formatKey } from "./number-field-format.mjs";
|
|
18
|
-
import {
|
|
18
|
+
import { useNumberFieldDevWarnings } from "./use-number-field-dev-warnings.mjs";
|
|
19
|
+
import { addTransitionType, use, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
19
20
|
import { jsx } from "react/jsx-runtime";
|
|
20
21
|
//#region src/number-field/number-field-root.tsx
|
|
21
|
-
const isDev = process.env.NODE_ENV !== "production";
|
|
22
22
|
const STEP_TYPES = transitionTypes("number-field", "change");
|
|
23
23
|
const COMMIT_TYPES = transitionTypes("number-field", "commit");
|
|
24
24
|
/** A finite number, or `null` (`NaN` / `Infinity` are treated as empty). */
|
|
@@ -30,8 +30,28 @@ function sanitize(value) {
|
|
|
30
30
|
function hiddenText(value) {
|
|
31
31
|
return value === null ? "" : String(value);
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Mount reconciliation's read of the visible input (design 4.5): the value the hydrated text
|
|
35
|
+
* means. The client's own formatting of `current` is `current`. Focused text is still being typed
|
|
36
|
+
* (even a partial `12,` or `-`): handed to `adoptDraft`, never overwritten under the caret; the
|
|
37
|
+
* blur commits or reverts it by the ordinary rule. Otherwise the parsed text, or, for another
|
|
38
|
+
* locale's formatting of the same value or text that is no number, `current` with the client's
|
|
39
|
+
* text written back (react-dom kept the hydrated DOM value).
|
|
40
|
+
*/
|
|
41
|
+
function readVisible(visible, current, formatter, adoptDraft) {
|
|
42
|
+
if (visible === null) return current;
|
|
43
|
+
const domText = visible.value;
|
|
44
|
+
if (domText === formatter.format(current)) return current;
|
|
45
|
+
if (visible.ownerDocument.activeElement === visible) {
|
|
46
|
+
adoptDraft(domText);
|
|
47
|
+
return current;
|
|
48
|
+
}
|
|
49
|
+
const parsed = formatter.parse(domText);
|
|
50
|
+
if (parsed === void 0 || Object.is(parsed, current)) {
|
|
51
|
+
visible.value = formatter.format(current);
|
|
52
|
+
return current;
|
|
53
|
+
}
|
|
54
|
+
return parsed;
|
|
35
55
|
}
|
|
36
56
|
/**
|
|
37
57
|
* Owns the number field's state (design/components/number-field.md 2): the committed value
|
|
@@ -66,9 +86,11 @@ function NumberFieldRoot(props) {
|
|
|
66
86
|
stepSize
|
|
67
87
|
]);
|
|
68
88
|
const fieldContext = use(FieldContext);
|
|
69
|
-
const disabled
|
|
70
|
-
|
|
71
|
-
|
|
89
|
+
const { disabled, required, name } = resolveFieldDefaults(fieldContext, {
|
|
90
|
+
name: nameProp,
|
|
91
|
+
disabled: disabledProp,
|
|
92
|
+
required: requiredProp
|
|
93
|
+
});
|
|
72
94
|
const fieldInvalid = fieldContext === null ? void 0 : fieldContext.state.invalid;
|
|
73
95
|
const id = useId();
|
|
74
96
|
const inputId = fieldContext?.ids.control ?? `${id}-input`;
|
|
@@ -88,7 +110,6 @@ function NumberFieldRoot(props) {
|
|
|
88
110
|
const holdRef = useRef(null);
|
|
89
111
|
const commitSeq = useRef(0);
|
|
90
112
|
const lastReason = useRef(null);
|
|
91
|
-
const shownRef = useRef(null);
|
|
92
113
|
const visibleRef = useRef(null);
|
|
93
114
|
const hiddenRef = useRef(null);
|
|
94
115
|
const clearDraft = useCallback(() => {
|
|
@@ -96,23 +117,26 @@ function NumberFieldRoot(props) {
|
|
|
96
117
|
draftRef.current = null;
|
|
97
118
|
setDraft(null);
|
|
98
119
|
}, []);
|
|
99
|
-
/**
|
|
100
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Writes `next` into the hidden input, then mirrors its validity onto the visible input, which
|
|
122
|
+
* is invalid exactly when the hidden one is (6.2).
|
|
123
|
+
*/
|
|
124
|
+
const syncHidden = useCallback((next) => {
|
|
101
125
|
const hidden = hiddenRef.current;
|
|
126
|
+
if (hidden !== null) {
|
|
127
|
+
const text = hiddenText(next);
|
|
128
|
+
if (hidden.value !== text) hidden.value = text;
|
|
129
|
+
}
|
|
102
130
|
const visible = visibleRef.current;
|
|
103
131
|
if (hidden === null || visible === null) return;
|
|
104
132
|
const message = hidden.validationMessage;
|
|
105
133
|
if (visible.validationMessage !== message) visible.setCustomValidity(message);
|
|
106
134
|
}, []);
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
mirror();
|
|
114
|
-
}, [mirror]);
|
|
115
|
-
const { pending: stepPending, run: runStep } = useActionTrigger({ ignoreWhilePending: false });
|
|
135
|
+
const captureSuperseded = useSupersededRejection();
|
|
136
|
+
const { pending: stepPending, run: runStep } = useActionTrigger({
|
|
137
|
+
ignoreWhilePending: false,
|
|
138
|
+
captureSuperseded
|
|
139
|
+
});
|
|
116
140
|
const runCommit = async (next, details) => {
|
|
117
141
|
const seq = ++commitSeq.current;
|
|
118
142
|
try {
|
|
@@ -134,7 +158,8 @@ function NumberFieldRoot(props) {
|
|
|
134
158
|
warn: {
|
|
135
159
|
component: "NumberField.Root",
|
|
136
160
|
prop: "value"
|
|
137
|
-
}
|
|
161
|
+
},
|
|
162
|
+
captureSuperseded
|
|
138
163
|
});
|
|
139
164
|
const { optimistic, committed, dispatch } = commitState;
|
|
140
165
|
const committedRef = useLatest(committed);
|
|
@@ -143,9 +168,8 @@ function NumberFieldRoot(props) {
|
|
|
143
168
|
const text = draft ?? formatter.format(shown);
|
|
144
169
|
const parsedDraft = draft === null ? void 0 : formatter.parse(draft);
|
|
145
170
|
const stepBase = parsedDraft === void 0 ? shown : parsedDraft;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
});
|
|
171
|
+
/** What the input shows, for handlers; also written by `step` ahead of the render. */
|
|
172
|
+
const shownRef = useLatest(shown);
|
|
149
173
|
const state = useMemo(() => ({
|
|
150
174
|
value: shown,
|
|
151
175
|
text,
|
|
@@ -187,7 +211,7 @@ function NumberFieldRoot(props) {
|
|
|
187
211
|
setLive({ value: next });
|
|
188
212
|
clearDraft();
|
|
189
213
|
setPendingSource(source);
|
|
190
|
-
|
|
214
|
+
syncHidden(next);
|
|
191
215
|
if (reason !== "dismiss") setStepHeld(true);
|
|
192
216
|
const { valueChangeAction: action, runStep: run } = latest.current;
|
|
193
217
|
if (action === void 0) return true;
|
|
@@ -202,7 +226,8 @@ function NumberFieldRoot(props) {
|
|
|
202
226
|
}, [
|
|
203
227
|
clearDraft,
|
|
204
228
|
latest,
|
|
205
|
-
|
|
229
|
+
shownRef,
|
|
230
|
+
syncHidden
|
|
206
231
|
]);
|
|
207
232
|
const announceValue = useCallback((next) => {
|
|
208
233
|
const visible = visibleRef.current;
|
|
@@ -235,7 +260,7 @@ function NumberFieldRoot(props) {
|
|
|
235
260
|
const openGesture = useCallback(() => {
|
|
236
261
|
gestureStart.current = { value: shownRef.current };
|
|
237
262
|
liveRef.current = shownRef.current;
|
|
238
|
-
}, []);
|
|
263
|
+
}, [shownRef]);
|
|
239
264
|
/** The value a key or a button steps from: the parsed draft if one is open, else the shown value. */
|
|
240
265
|
const resolveBase = useCallback(() => {
|
|
241
266
|
const open = draftRef.current;
|
|
@@ -245,7 +270,11 @@ function NumberFieldRoot(props) {
|
|
|
245
270
|
if (parsed !== void 0) return parsed;
|
|
246
271
|
}
|
|
247
272
|
return shownRef.current;
|
|
248
|
-
}, [
|
|
273
|
+
}, [
|
|
274
|
+
clearDraft,
|
|
275
|
+
latest,
|
|
276
|
+
shownRef
|
|
277
|
+
]);
|
|
249
278
|
/** A one-step gesture: a key press, a wheel event, a click activation. */
|
|
250
279
|
const oneStep = useCallback((compute, source, event) => {
|
|
251
280
|
const base = resolveBase();
|
|
@@ -283,6 +312,7 @@ function NumberFieldRoot(props) {
|
|
|
283
312
|
commit,
|
|
284
313
|
latest,
|
|
285
314
|
openGesture,
|
|
315
|
+
shownRef,
|
|
286
316
|
step
|
|
287
317
|
]);
|
|
288
318
|
const keyDown = useCallback((event) => {
|
|
@@ -293,33 +323,7 @@ function NumberFieldRoot(props) {
|
|
|
293
323
|
return;
|
|
294
324
|
}
|
|
295
325
|
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
296
|
-
|
|
297
|
-
switch (event.key) {
|
|
298
|
-
case "ArrowUp":
|
|
299
|
-
compute = event.shiftKey ? (v) => stepBy(v, large, b) : (v) => stepValue(v, 1, b);
|
|
300
|
-
break;
|
|
301
|
-
case "ArrowDown":
|
|
302
|
-
compute = event.shiftKey ? (v) => stepBy(v, -large, b) : (v) => stepValue(v, -1, b);
|
|
303
|
-
break;
|
|
304
|
-
case "PageUp":
|
|
305
|
-
compute = (v) => stepBy(v, large, b);
|
|
306
|
-
break;
|
|
307
|
-
case "PageDown":
|
|
308
|
-
compute = (v) => stepBy(v, -large, b);
|
|
309
|
-
break;
|
|
310
|
-
case "Home": {
|
|
311
|
-
if (event.shiftKey) break;
|
|
312
|
-
const target = boundValue("min", b);
|
|
313
|
-
if (target !== void 0) compute = () => target;
|
|
314
|
-
break;
|
|
315
|
-
}
|
|
316
|
-
case "End": {
|
|
317
|
-
if (event.shiftKey) break;
|
|
318
|
-
const target = boundValue("max", b);
|
|
319
|
-
if (target !== void 0) compute = () => target;
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
326
|
+
const compute = keyStep(event.key, event.shiftKey, b, large);
|
|
323
327
|
if (compute === null) return;
|
|
324
328
|
event.preventDefault();
|
|
325
329
|
oneStep(compute, "keyboard", event);
|
|
@@ -374,6 +378,7 @@ function NumberFieldRoot(props) {
|
|
|
374
378
|
latest,
|
|
375
379
|
openGesture,
|
|
376
380
|
resolveBase,
|
|
381
|
+
shownRef,
|
|
377
382
|
tickHold
|
|
378
383
|
]);
|
|
379
384
|
const activate = useCallback((direction, event) => {
|
|
@@ -392,24 +397,10 @@ function NumberFieldRoot(props) {
|
|
|
392
397
|
const resetTargetText = hiddenText(resetTarget());
|
|
393
398
|
const { onItemMounted } = useNativeGroupReconciliation({
|
|
394
399
|
element: hiddenRef,
|
|
395
|
-
readCurrent: () => {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
const domText = visible.value;
|
|
400
|
-
if (domText === formatter.format(current)) return current;
|
|
401
|
-
if (visible.ownerDocument.activeElement === visible) {
|
|
402
|
-
draftRef.current = domText;
|
|
403
|
-
setDraft(domText);
|
|
404
|
-
return current;
|
|
405
|
-
}
|
|
406
|
-
const parsed = formatter.parse(domText);
|
|
407
|
-
if (parsed === void 0 || Object.is(parsed, current)) {
|
|
408
|
-
visible.value = formatter.format(current);
|
|
409
|
-
return current;
|
|
410
|
-
}
|
|
411
|
-
return parsed;
|
|
412
|
-
},
|
|
400
|
+
readCurrent: () => readVisible(visibleRef.current, shownRef.current, formatter, (text) => {
|
|
401
|
+
draftRef.current = text;
|
|
402
|
+
setDraft(text);
|
|
403
|
+
}),
|
|
413
404
|
readDefault: () => {
|
|
414
405
|
clearDraft();
|
|
415
406
|
return resetTarget();
|
|
@@ -425,18 +416,17 @@ function NumberFieldRoot(props) {
|
|
|
425
416
|
if (visible !== null) visible.defaultValue = formatter.format(resetTarget());
|
|
426
417
|
}
|
|
427
418
|
});
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}, [locale, formatter]);
|
|
419
|
+
useNumberFieldDevWarnings({
|
|
420
|
+
value: valueProp,
|
|
421
|
+
defaultValue: defaultValueProp,
|
|
422
|
+
min,
|
|
423
|
+
max,
|
|
424
|
+
bounds,
|
|
425
|
+
stepValid,
|
|
426
|
+
largeStepValid,
|
|
427
|
+
formatter,
|
|
428
|
+
locale
|
|
429
|
+
});
|
|
440
430
|
useEffect(() => () => {
|
|
441
431
|
holdRef.current = null;
|
|
442
432
|
}, []);
|
|
@@ -463,9 +453,9 @@ function NumberFieldRoot(props) {
|
|
|
463
453
|
tickHold,
|
|
464
454
|
endHold,
|
|
465
455
|
activate,
|
|
466
|
-
|
|
456
|
+
syncHidden,
|
|
467
457
|
registerLabel,
|
|
468
|
-
|
|
458
|
+
onItemMounted
|
|
469
459
|
}), [
|
|
470
460
|
state,
|
|
471
461
|
bounds,
|
|
@@ -489,7 +479,7 @@ function NumberFieldRoot(props) {
|
|
|
489
479
|
tickHold,
|
|
490
480
|
endHold,
|
|
491
481
|
activate,
|
|
492
|
-
|
|
482
|
+
syncHidden,
|
|
493
483
|
registerLabel,
|
|
494
484
|
onItemMounted
|
|
495
485
|
]);
|
|
@@ -518,6 +508,6 @@ function NumberFieldRoot(props) {
|
|
|
518
508
|
}
|
|
519
509
|
NumberFieldRoot.displayName = "NumberFieldRoot";
|
|
520
510
|
//#endregion
|
|
521
|
-
export { NumberFieldRoot
|
|
511
|
+
export { NumberFieldRoot };
|
|
522
512
|
|
|
523
513
|
//# sourceMappingURL=number-field-root.mjs.map
|