@funstack/ui 0.1.0-alpha.1 → 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion/accordion-context.mjs.map +1 -1
- package/dist/accordion/accordion-item.mjs +20 -6
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.mjs +4 -5
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +35 -16
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +6 -7
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/button/button.d.mts +78 -0
- package/dist/button/button.d.mts.map +1 -0
- package/dist/button/button.mjs +77 -0
- package/dist/button/button.mjs.map +1 -0
- package/dist/button/index.d.mts +3 -0
- package/dist/button/index.mjs +1 -0
- package/dist/checkbox/checkbox.d.mts +5 -3
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +27 -11
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +2 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +5 -3
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +2 -2
- package/dist/checkbox-group/checkbox-group-root.d.mts +5 -2
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +25 -6
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts +37 -0
- package/dist/combobox/combobox-clear.d.mts.map +1 -0
- package/dist/combobox/combobox-clear.mjs +64 -0
- package/dist/combobox/combobox-clear.mjs.map +1 -0
- package/dist/combobox/combobox-context.mjs +23 -0
- package/dist/combobox/combobox-context.mjs.map +1 -0
- package/dist/combobox/combobox-group.d.mts +72 -0
- package/dist/combobox/combobox-group.d.mts.map +1 -0
- package/dist/combobox/combobox-group.mjs +104 -0
- package/dist/combobox/combobox-group.mjs.map +1 -0
- package/dist/combobox/combobox-input.d.mts +42 -0
- package/dist/combobox/combobox-input.d.mts.map +1 -0
- package/dist/combobox/combobox-input.mjs +102 -0
- package/dist/combobox/combobox-input.mjs.map +1 -0
- package/dist/combobox/combobox-label.d.mts +22 -0
- package/dist/combobox/combobox-label.d.mts.map +1 -0
- package/dist/combobox/combobox-label.mjs +32 -0
- package/dist/combobox/combobox-label.mjs.map +1 -0
- package/dist/combobox/combobox-list.d.mts +37 -0
- package/dist/combobox/combobox-list.d.mts.map +1 -0
- package/dist/combobox/combobox-list.mjs +71 -0
- package/dist/combobox/combobox-list.mjs.map +1 -0
- package/dist/combobox/combobox-option.d.mts +45 -0
- package/dist/combobox/combobox-option.d.mts.map +1 -0
- package/dist/combobox/combobox-option.mjs +88 -0
- package/dist/combobox/combobox-option.mjs.map +1 -0
- package/dist/combobox/combobox-popup.d.mts +49 -0
- package/dist/combobox/combobox-popup.d.mts.map +1 -0
- package/dist/combobox/combobox-popup.mjs +91 -0
- package/dist/combobox/combobox-popup.mjs.map +1 -0
- package/dist/combobox/combobox-root.d.mts +135 -0
- package/dist/combobox/combobox-root.d.mts.map +1 -0
- package/dist/combobox/combobox-root.mjs +523 -0
- package/dist/combobox/combobox-root.mjs.map +1 -0
- package/dist/combobox/combobox-trigger.d.mts +40 -0
- package/dist/combobox/combobox-trigger.d.mts.map +1 -0
- package/dist/combobox/combobox-trigger.mjs +99 -0
- package/dist/combobox/combobox-trigger.mjs.map +1 -0
- package/dist/combobox/index.d.mts +36 -0
- package/dist/combobox/index.d.mts.map +1 -0
- package/dist/combobox/index.mjs +36 -0
- package/dist/combobox/index.mjs.map +1 -0
- package/dist/csp/csp-provider.d.mts +25 -0
- package/dist/csp/csp-provider.d.mts.map +1 -0
- package/dist/csp/csp-provider.mjs +24 -0
- package/dist/csp/csp-provider.mjs.map +1 -0
- package/dist/csp/index.d.mts +3 -0
- package/dist/csp/index.mjs +3 -0
- package/dist/csp/style-hashes.d.mts +19 -0
- package/dist/csp/style-hashes.d.mts.map +1 -0
- package/dist/csp/style-hashes.mjs +21 -0
- package/dist/csp/style-hashes.mjs.map +1 -0
- package/dist/dialog/dialog-close.d.mts +22 -10
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +41 -25
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts +23 -10
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +51 -32
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +10 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +118 -45
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +14 -8
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +68 -13
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +11 -5
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +16 -8
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +4 -2
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +4 -2
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/field/field-control.d.mts +33 -0
- package/dist/field/field-control.d.mts.map +1 -0
- package/dist/field/field-control.mjs +68 -0
- package/dist/field/field-control.mjs.map +1 -0
- package/dist/field/field-description.d.mts +24 -0
- package/dist/field/field-description.d.mts.map +1 -0
- package/dist/field/field-description.mjs +34 -0
- package/dist/field/field-description.mjs.map +1 -0
- package/dist/field/field-error.d.mts +30 -0
- package/dist/field/field-error.d.mts.map +1 -0
- package/dist/field/field-error.mjs +42 -0
- package/dist/field/field-error.mjs.map +1 -0
- package/dist/field/field-label.d.mts +25 -0
- package/dist/field/field-label.d.mts.map +1 -0
- package/dist/field/field-label.mjs +46 -0
- package/dist/field/field-label.mjs.map +1 -0
- package/dist/field/field-root.d.mts +53 -0
- package/dist/field/field-root.d.mts.map +1 -0
- package/dist/field/field-root.mjs +319 -0
- package/dist/field/field-root.mjs.map +1 -0
- package/dist/field/index.d.mts +18 -0
- package/dist/field/index.d.mts.map +1 -0
- package/dist/field/index.mjs +17 -0
- package/dist/field/index.mjs.map +1 -0
- package/dist/form/form-root.d.mts +58 -0
- package/dist/form/form-root.d.mts.map +1 -0
- package/dist/form/form-root.mjs +147 -0
- package/dist/form/form-root.mjs.map +1 -0
- package/dist/form/form-submit.d.mts +34 -0
- package/dist/form/form-submit.d.mts.map +1 -0
- package/dist/form/form-submit.mjs +53 -0
- package/dist/form/form-submit.mjs.map +1 -0
- package/dist/form/index.d.mts +11 -0
- package/dist/form/index.d.mts.map +1 -0
- package/dist/form/index.mjs +11 -0
- package/dist/form/index.mjs.map +1 -0
- package/dist/index.d.mts +79 -4
- package/dist/index.mjs +16 -1
- package/dist/internal/anchor-position.d.mts +11 -3
- package/dist/internal/anchor-position.d.mts.map +1 -1
- package/dist/internal/anchor-position.mjs +180 -6
- package/dist/internal/anchor-position.mjs.map +1 -1
- package/dist/internal/announce.mjs +53 -0
- package/dist/internal/announce.mjs.map +1 -0
- package/dist/internal/content-focus-probe.mjs +42 -0
- package/dist/internal/content-focus-probe.mjs.map +1 -0
- package/dist/internal/csp-context.mjs +8 -0
- package/dist/internal/csp-context.mjs.map +1 -0
- package/dist/internal/decimal.mjs +27 -0
- package/dist/internal/decimal.mjs.map +1 -0
- package/dist/internal/dev-warn.mjs +17 -0
- package/dist/internal/dev-warn.mjs.map +1 -0
- package/dist/internal/field-context.d.mts +19 -0
- package/dist/internal/field-context.d.mts.map +1 -0
- package/dist/internal/field-context.mjs +14 -0
- package/dist/internal/field-context.mjs.map +1 -0
- package/dist/internal/focus-first-invalid.mjs +67 -0
- package/dist/internal/focus-first-invalid.mjs.map +1 -0
- package/dist/internal/form-status-watcher.mjs +31 -0
- package/dist/internal/form-status-watcher.mjs.map +1 -0
- package/dist/internal/modal-registry.mjs +39 -0
- package/dist/internal/modal-registry.mjs.map +1 -0
- package/dist/internal/platform-attributes.d.mts +12 -1
- package/dist/internal/platform-attributes.d.mts.map +1 -1
- package/dist/internal/range-value.mjs +51 -0
- package/dist/internal/range-value.mjs.map +1 -0
- package/dist/internal/render-element.mjs +67 -0
- package/dist/internal/render-element.mjs.map +1 -0
- package/dist/internal/toolbar-context.mjs +17 -0
- package/dist/internal/toolbar-context.mjs.map +1 -0
- package/dist/internal/tooltip-warm.mjs +29 -0
- package/dist/internal/tooltip-warm.mjs.map +1 -0
- package/dist/internal/types.d.mts +11 -1
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-action-trigger.mjs +17 -6
- package/dist/internal/use-action-trigger.mjs.map +1 -1
- package/dist/internal/use-controllable-action.mjs +35 -13
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-exit-animation.mjs +26 -6
- package/dist/internal/use-exit-animation.mjs.map +1 -1
- package/dist/internal/use-field-control.mjs +109 -0
- package/dist/internal/use-field-control.mjs.map +1 -0
- package/dist/internal/use-form-owner-event.mjs +44 -0
- package/dist/internal/use-form-owner-event.mjs.map +1 -0
- package/dist/internal/use-form-reset.mjs +12 -31
- package/dist/internal/use-form-reset.mjs.map +1 -1
- package/dist/internal/use-hydrated-mount.mjs +21 -0
- package/dist/internal/use-hydrated-mount.mjs.map +1 -0
- package/dist/internal/use-latest.mjs +32 -0
- package/dist/internal/use-latest.mjs.map +1 -0
- package/dist/internal/use-modal-registration.mjs +47 -0
- package/dist/internal/use-modal-registration.mjs.map +1 -0
- package/dist/internal/use-native-group-reconciliation.mjs +6 -5
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-native-select-value.mjs +184 -0
- package/dist/internal/use-native-select-value.mjs.map +1 -0
- package/dist/internal/use-popover-popup.mjs +33 -28
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-root.mjs +59 -24
- package/dist/internal/use-popover-root.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.mjs +6 -5
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/use-render.mjs +12 -35
- package/dist/internal/use-render.mjs.map +1 -1
- package/dist/internal/use-resolved-placement.mjs +146 -0
- package/dist/internal/use-resolved-placement.mjs.map +1 -0
- package/dist/internal/use-roving-focus.mjs +301 -0
- package/dist/internal/use-roving-focus.mjs.map +1 -0
- package/dist/internal/validity.d.mts +24 -0
- package/dist/internal/validity.d.mts.map +1 -0
- package/dist/internal/validity.mjs +108 -0
- package/dist/internal/validity.mjs.map +1 -0
- package/dist/menu/index.d.mts +5 -1
- package/dist/menu/index.d.mts.map +1 -1
- package/dist/menu/index.mjs +5 -1
- package/dist/menu/index.mjs.map +1 -1
- package/dist/menu/menu-checkbox-item.mjs +2 -1
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +46 -0
- package/dist/menu/menu-context-trigger.d.mts.map +1 -0
- package/dist/menu/menu-context-trigger.mjs +405 -0
- package/dist/menu/menu-context-trigger.mjs.map +1 -0
- package/dist/menu/menu-context.mjs +44 -1
- package/dist/menu/menu-context.mjs.map +1 -1
- package/dist/menu/menu-dom.mjs +49 -3
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +4 -3
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-item.d.mts +6 -2
- package/dist/menu/menu-item.d.mts.map +1 -1
- package/dist/menu/menu-item.mjs +7 -4
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-popup.d.mts +36 -8
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +219 -22
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.mjs +10 -5
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.mjs +2 -1
- package/dist/menu/menu-radio-item.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +5 -0
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +57 -7
- 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 +28 -12
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +8 -4
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +18 -7
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/meter/index.d.mts +24 -0
- package/dist/meter/index.d.mts.map +1 -0
- package/dist/meter/index.mjs +23 -0
- package/dist/meter/index.mjs.map +1 -0
- package/dist/meter/meter-context.mjs +13 -0
- package/dist/meter/meter-context.mjs.map +1 -0
- package/dist/meter/meter-indicator.d.mts +19 -0
- package/dist/meter/meter-indicator.d.mts.map +1 -0
- package/dist/meter/meter-indicator.mjs +25 -0
- package/dist/meter/meter-indicator.mjs.map +1 -0
- package/dist/meter/meter-label.d.mts +19 -0
- package/dist/meter/meter-label.d.mts.map +1 -0
- package/dist/meter/meter-label.mjs +28 -0
- package/dist/meter/meter-label.mjs.map +1 -0
- package/dist/meter/meter-region.d.mts +4 -0
- package/dist/meter/meter-region.d.mts.map +1 -0
- package/dist/meter/meter-region.mjs +39 -0
- package/dist/meter/meter-region.mjs.map +1 -0
- package/dist/meter/meter-root.d.mts +71 -0
- package/dist/meter/meter-root.d.mts.map +1 -0
- package/dist/meter/meter-root.mjs +83 -0
- package/dist/meter/meter-root.mjs.map +1 -0
- package/dist/meter/meter-track.d.mts +19 -0
- package/dist/meter/meter-track.d.mts.map +1 -0
- package/dist/meter/meter-track.mjs +25 -0
- package/dist/meter/meter-track.mjs.map +1 -0
- package/dist/meter/meter-value.d.mts +20 -0
- package/dist/meter/meter-value.d.mts.map +1 -0
- package/dist/meter/meter-value.mjs +29 -0
- package/dist/meter/meter-value.mjs.map +1 -0
- package/dist/number-field/index.d.mts +26 -0
- package/dist/number-field/index.d.mts.map +1 -0
- package/dist/number-field/index.mjs +26 -0
- package/dist/number-field/index.mjs.map +1 -0
- package/dist/number-field/number-field-arithmetic.mjs +78 -0
- package/dist/number-field/number-field-arithmetic.mjs.map +1 -0
- package/dist/number-field/number-field-context.d.mts +2 -0
- package/dist/number-field/number-field-context.mjs +13 -0
- package/dist/number-field/number-field-context.mjs.map +1 -0
- package/dist/number-field/number-field-decrement.d.mts +17 -0
- package/dist/number-field/number-field-decrement.d.mts.map +1 -0
- package/dist/number-field/number-field-decrement.mjs +20 -0
- package/dist/number-field/number-field-decrement.mjs.map +1 -0
- package/dist/number-field/number-field-format.mjs +279 -0
- package/dist/number-field/number-field-format.mjs.map +1 -0
- package/dist/number-field/number-field-increment.d.mts +37 -0
- package/dist/number-field/number-field-increment.d.mts.map +1 -0
- package/dist/number-field/number-field-increment.mjs +71 -0
- package/dist/number-field/number-field-increment.mjs.map +1 -0
- package/dist/number-field/number-field-input.d.mts +29 -0
- package/dist/number-field/number-field-input.d.mts.map +1 -0
- package/dist/number-field/number-field-input.mjs +163 -0
- package/dist/number-field/number-field-input.mjs.map +1 -0
- package/dist/number-field/number-field-label.d.mts +23 -0
- package/dist/number-field/number-field-label.d.mts.map +1 -0
- package/dist/number-field/number-field-label.mjs +47 -0
- package/dist/number-field/number-field-label.mjs.map +1 -0
- package/dist/number-field/number-field-root.d.mts +108 -0
- package/dist/number-field/number-field-root.d.mts.map +1 -0
- package/dist/number-field/number-field-root.mjs +523 -0
- package/dist/number-field/number-field-root.mjs.map +1 -0
- package/dist/number-field/use-step-button.mjs +112 -0
- package/dist/number-field/use-step-button.mjs.map +1 -0
- package/dist/popover/popover-close.d.mts +9 -3
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +13 -7
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +21 -7
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +23 -8
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.mjs +1 -1
- package/dist/popover/popover-trigger.d.mts +8 -4
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +3 -3
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/index.d.mts +24 -0
- package/dist/progress/index.d.mts.map +1 -0
- package/dist/progress/index.mjs +24 -0
- package/dist/progress/index.mjs.map +1 -0
- package/dist/progress/progress-context.mjs +13 -0
- package/dist/progress/progress-context.mjs.map +1 -0
- package/dist/progress/progress-indicator.d.mts +19 -0
- package/dist/progress/progress-indicator.d.mts.map +1 -0
- package/dist/progress/progress-indicator.mjs +29 -0
- package/dist/progress/progress-indicator.mjs.map +1 -0
- package/dist/progress/progress-label.d.mts +19 -0
- package/dist/progress/progress-label.d.mts.map +1 -0
- package/dist/progress/progress-label.mjs +30 -0
- package/dist/progress/progress-label.mjs.map +1 -0
- package/dist/progress/progress-root.d.mts +68 -0
- package/dist/progress/progress-root.d.mts.map +1 -0
- package/dist/progress/progress-root.mjs +80 -0
- package/dist/progress/progress-root.mjs.map +1 -0
- package/dist/progress/progress-track.d.mts +19 -0
- package/dist/progress/progress-track.d.mts.map +1 -0
- package/dist/progress/progress-track.mjs +29 -0
- package/dist/progress/progress-track.mjs.map +1 -0
- package/dist/progress/progress-value.d.mts +20 -0
- package/dist/progress/progress-value.d.mts.map +1 -0
- package/dist/progress/progress-value.mjs +33 -0
- package/dist/progress/progress-value.mjs.map +1 -0
- package/dist/radio-group/radio-group-item.mjs +2 -2
- package/dist/radio-group/radio-group-root.d.mts +4 -2
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +35 -9
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/index.d.mts +30 -0
- package/dist/select/index.d.mts.map +1 -0
- package/dist/select/index.mjs +30 -0
- package/dist/select/index.mjs.map +1 -0
- package/dist/select/select-context.mjs +13 -0
- package/dist/select/select-context.mjs.map +1 -0
- package/dist/select/select-dom.mjs +44 -0
- package/dist/select/select-dom.mjs.map +1 -0
- package/dist/select/select-group-label.d.mts +22 -0
- package/dist/select/select-group-label.d.mts.map +1 -0
- package/dist/select/select-group-label.mjs +39 -0
- package/dist/select/select-group-label.mjs.map +1 -0
- package/dist/select/select-group.d.mts +28 -0
- package/dist/select/select-group.d.mts.map +1 -0
- package/dist/select/select-group.mjs +47 -0
- package/dist/select/select-group.mjs.map +1 -0
- package/dist/select/select-option.d.mts +42 -0
- package/dist/select/select-option.d.mts.map +1 -0
- package/dist/select/select-option.mjs +65 -0
- package/dist/select/select-option.mjs.map +1 -0
- package/dist/select/select-root.d.mts +68 -0
- package/dist/select/select-root.d.mts.map +1 -0
- package/dist/select/select-root.mjs +114 -0
- package/dist/select/select-root.mjs.map +1 -0
- package/dist/select/select-separator.d.mts +20 -0
- package/dist/select/select-separator.d.mts.map +1 -0
- package/dist/select/select-separator.mjs +30 -0
- package/dist/select/select-separator.mjs.map +1 -0
- package/dist/select/select-trigger.d.mts +29 -0
- package/dist/select/select-trigger.d.mts.map +1 -0
- package/dist/select/select-trigger.mjs +48 -0
- package/dist/select/select-trigger.mjs.map +1 -0
- package/dist/select/select-value.d.mts +31 -0
- package/dist/select/select-value.d.mts.map +1 -0
- package/dist/select/select-value.mjs +101 -0
- package/dist/select/select-value.mjs.map +1 -0
- package/dist/slider/index.d.mts +32 -0
- package/dist/slider/index.d.mts.map +1 -0
- package/dist/slider/index.mjs +27 -0
- package/dist/slider/index.mjs.map +1 -0
- package/dist/slider/slider-arithmetic.mjs +104 -0
- package/dist/slider/slider-arithmetic.mjs.map +1 -0
- package/dist/slider/slider-context.mjs +13 -0
- package/dist/slider/slider-context.mjs.map +1 -0
- package/dist/slider/slider-indicator.d.mts +22 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -0
- package/dist/slider/slider-indicator.mjs +36 -0
- package/dist/slider/slider-indicator.mjs.map +1 -0
- package/dist/slider/slider-label.d.mts +23 -0
- package/dist/slider/slider-label.d.mts.map +1 -0
- package/dist/slider/slider-label.mjs +44 -0
- package/dist/slider/slider-label.mjs.map +1 -0
- package/dist/slider/slider-root.d.mts +111 -0
- package/dist/slider/slider-root.d.mts.map +1 -0
- package/dist/slider/slider-root.mjs +583 -0
- package/dist/slider/slider-root.mjs.map +1 -0
- package/dist/slider/slider-thumb.d.mts +58 -0
- package/dist/slider/slider-thumb.d.mts.map +1 -0
- package/dist/slider/slider-thumb.mjs +146 -0
- package/dist/slider/slider-thumb.mjs.map +1 -0
- package/dist/slider/slider-track.d.mts +29 -0
- package/dist/slider/slider-track.d.mts.map +1 -0
- package/dist/slider/slider-track.mjs +55 -0
- package/dist/slider/slider-track.mjs.map +1 -0
- package/dist/slider/slider-value.d.mts +34 -0
- package/dist/slider/slider-value.d.mts.map +1 -0
- package/dist/slider/slider-value.mjs +38 -0
- package/dist/slider/slider-value.mjs.map +1 -0
- package/dist/switch/switch.d.mts +5 -3
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +26 -10
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/tabs-indicator.mjs +2 -1
- package/dist/tabs/tabs-indicator.mjs.map +1 -1
- package/dist/tabs/tabs-list.mjs +1 -1
- package/dist/tabs/tabs-panel.mjs +1 -1
- package/dist/tabs/tabs-root.mjs +15 -5
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.mjs +3 -2
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/index.d.mts +25 -0
- package/dist/toast/index.d.mts.map +1 -0
- package/dist/toast/index.mjs +26 -0
- package/dist/toast/index.mjs.map +1 -0
- package/dist/toast/toast-action.d.mts +40 -0
- package/dist/toast/toast-action.d.mts.map +1 -0
- package/dist/toast/toast-action.mjs +67 -0
- package/dist/toast/toast-action.mjs.map +1 -0
- package/dist/toast/toast-close.d.mts +25 -0
- package/dist/toast/toast-close.d.mts.map +1 -0
- package/dist/toast/toast-close.mjs +47 -0
- package/dist/toast/toast-close.mjs.map +1 -0
- package/dist/toast/toast-context.mjs +19 -0
- package/dist/toast/toast-context.mjs.map +1 -0
- package/dist/toast/toast-description.d.mts +24 -0
- package/dist/toast/toast-description.d.mts.map +1 -0
- package/dist/toast/toast-description.mjs +35 -0
- package/dist/toast/toast-description.mjs.map +1 -0
- package/dist/toast/toast-root.d.mts +43 -0
- package/dist/toast/toast-root.d.mts.map +1 -0
- package/dist/toast/toast-root.mjs +205 -0
- package/dist/toast/toast-root.mjs.map +1 -0
- package/dist/toast/toast-title.d.mts +24 -0
- package/dist/toast/toast-title.d.mts.map +1 -0
- package/dist/toast/toast-title.mjs +33 -0
- package/dist/toast/toast-title.mjs.map +1 -0
- package/dist/toast/toast-viewport.d.mts +52 -0
- package/dist/toast/toast-viewport.d.mts.map +1 -0
- package/dist/toast/toast-viewport.mjs +644 -0
- package/dist/toast/toast-viewport.mjs.map +1 -0
- package/dist/toast/toast.d.mts +119 -0
- package/dist/toast/toast.d.mts.map +1 -0
- package/dist/toast/toast.mjs +157 -0
- package/dist/toast/toast.mjs.map +1 -0
- package/dist/toggle/toggle.d.mts +4 -1
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +16 -9
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/index.d.mts +16 -0
- package/dist/toggle-group/index.d.mts.map +1 -0
- package/dist/toggle-group/index.mjs +15 -0
- package/dist/toggle-group/index.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-context.d.mts +4 -0
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-context.mjs +13 -0
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-item.d.mts +51 -0
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-item.mjs +68 -0
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-root.d.mts +95 -0
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-root.mjs +211 -0
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -0
- package/dist/toolbar/index.d.mts +17 -0
- package/dist/toolbar/index.d.mts.map +1 -0
- package/dist/toolbar/index.mjs +17 -0
- package/dist/toolbar/index.mjs.map +1 -0
- package/dist/toolbar/toolbar-root.d.mts +38 -0
- package/dist/toolbar/toolbar-root.d.mts.map +1 -0
- package/dist/toolbar/toolbar-root.mjs +66 -0
- package/dist/toolbar/toolbar-root.mjs.map +1 -0
- package/dist/toolbar/toolbar-separator.d.mts +25 -0
- package/dist/toolbar/toolbar-separator.d.mts.map +1 -0
- package/dist/toolbar/toolbar-separator.mjs +31 -0
- package/dist/toolbar/toolbar-separator.mjs.map +1 -0
- package/dist/tooltip/index.d.mts +8 -5
- package/dist/tooltip/index.d.mts.map +1 -1
- package/dist/tooltip/index.mjs +6 -3
- package/dist/tooltip/index.mjs.map +1 -1
- package/dist/tooltip/tooltip-arrow.d.mts +30 -0
- package/dist/tooltip/tooltip-arrow.d.mts.map +1 -0
- package/dist/tooltip/tooltip-arrow.mjs +45 -0
- package/dist/tooltip/tooltip-arrow.mjs.map +1 -0
- package/dist/tooltip/tooltip-context.d.mts +7 -0
- package/dist/tooltip/tooltip-context.d.mts.map +1 -1
- package/dist/tooltip/tooltip-context.mjs +2 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts +27 -6
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +36 -7
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +18 -2
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +9 -2
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +23 -6
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/dist/tooltip/use-tooltip-interaction.mjs +126 -76
- package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
- package/package.json +14 -1
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createActionDetails } from "../internal/action-details.mjs";
|
|
3
|
+
import { dataAttr } from "../internal/data-attr.mjs";
|
|
4
|
+
import { useActionTrigger } from "../internal/use-action-trigger.mjs";
|
|
5
|
+
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
6
|
+
import { mergeTokenLists } from "../internal/merge-props.mjs";
|
|
7
|
+
import { resolveStateValue } from "../internal/render-element.mjs";
|
|
8
|
+
import { useRender } from "../internal/use-render.mjs";
|
|
9
|
+
import { transitionTypes } from "../internal/transition-types.mjs";
|
|
10
|
+
import { useLatest } from "../internal/use-latest.mjs";
|
|
11
|
+
import { useControllableAction } from "../internal/use-controllable-action.mjs";
|
|
12
|
+
import { FieldContext } from "../internal/field-context.mjs";
|
|
13
|
+
import { useFieldControl, useFieldValueChange, useMergedRef } from "../internal/use-field-control.mjs";
|
|
14
|
+
import { useNativeGroupReconciliation } from "../internal/use-native-group-reconciliation.mjs";
|
|
15
|
+
import { SliderContext } from "./slider-context.mjs";
|
|
16
|
+
import { clampToNeighbours, equalValues, isMaxReachable, isOnGrid, nearestThumb, percent, platformDefault, sanitize } from "./slider-arithmetic.mjs";
|
|
17
|
+
import { addTransitionType, use, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
18
|
+
import { jsx } from "react/jsx-runtime";
|
|
19
|
+
//#region src/slider/slider-root.tsx
|
|
20
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
21
|
+
const STEP_TYPES = transitionTypes("slider", "change");
|
|
22
|
+
const COMMIT_TYPES = transitionTypes("slider", "commit");
|
|
23
|
+
function toArray(value) {
|
|
24
|
+
return typeof value === "number" ? [value] : value;
|
|
25
|
+
}
|
|
26
|
+
function shapeOf(value) {
|
|
27
|
+
if (value === void 0) return void 0;
|
|
28
|
+
return typeof value === "number" ? "number" : "array";
|
|
29
|
+
}
|
|
30
|
+
function replaceAt(values, index, value) {
|
|
31
|
+
return values.map((v, i) => i === index ? value : v);
|
|
32
|
+
}
|
|
33
|
+
/** Writes each registered input's `defaultValue` (the attribute a form reset restores). */
|
|
34
|
+
function writeDefaults(registry, target) {
|
|
35
|
+
for (const [index, input] of registry) {
|
|
36
|
+
const entry = target[index];
|
|
37
|
+
if (entry !== void 0) input.defaultValue = String(entry);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Owns the slider's state (design/components/slider.md 2): the committed value through
|
|
42
|
+
* `useControllableAction` with `valueCommitAction` (once per gesture), each step through its own
|
|
43
|
+
* transition (`valueChangeAction`), and the value a gesture has reached in the urgent lane
|
|
44
|
+
* (`live`), which the thumbs show while a pointer is captured or anything is in flight. Also the
|
|
45
|
+
* pointer gesture, the Thumb registry, mount reconciliation and form reset, and the geometry
|
|
46
|
+
* custom properties `--slider-start`, `--slider-end` and `--slider-value-<i>`.
|
|
47
|
+
*
|
|
48
|
+
* Owned keys (conventions 1.2): `role` (`"group"` with several thumbs), `aria-labelledby` (the
|
|
49
|
+
* Label's id while a Label is mounted and there are several thumbs; token-merged with the
|
|
50
|
+
* consumer's), `data-pending`, `data-dragging`, `data-orientation`, `data-disabled`. The custom
|
|
51
|
+
* properties are merged into `style`, where the consumer's entries win.
|
|
52
|
+
*
|
|
53
|
+
* Inside a `Field.Root` (design 9.4) the Root calls `useFieldControl`: with one thumb, Thumb 0's
|
|
54
|
+
* input is the Field's labelable control; with several, the Root registers itself as the group
|
|
55
|
+
* and also owns the Field label in `aria-labelledby`, the Field's `aria-describedby` and
|
|
56
|
+
* `data-invalid`. `name` / `disabled` default from the Field.
|
|
57
|
+
*/
|
|
58
|
+
function SliderRootImpl(props) {
|
|
59
|
+
const { value, defaultValue, valueChangeAction, valueCommitAction, min = 0, max = 100, step: stepProp = 1, minStepsBetweenThumbs = 0, orientation = "horizontal", getAriaValueText, name: nameProp, form, disabled: disabledProp = false, className, style, children, render, ...rest } = props;
|
|
60
|
+
const stepValid = Number.isFinite(stepProp) && stepProp > 0;
|
|
61
|
+
const step = stepValid ? stepProp : 1;
|
|
62
|
+
const gap = Math.max(0, minStepsBetweenThumbs) * step;
|
|
63
|
+
const id = useId();
|
|
64
|
+
const labelId = `${id}-label`;
|
|
65
|
+
const [shape] = useState(() => shapeOf(value ?? defaultValue) ?? "number");
|
|
66
|
+
const fromArray = useCallback((values) => shape === "number" ? values[0] : values, [shape]);
|
|
67
|
+
const [live, setLive] = useState(null);
|
|
68
|
+
const [gestureThumb, setGestureThumb] = useState(null);
|
|
69
|
+
/**
|
|
70
|
+
* A step was taken and its gesture's commit has not been dispatched yet. Holds `live` on
|
|
71
|
+
* screen between a key's native `input` and `change` when no step transition runs (no
|
|
72
|
+
* `valueChangeAction`): otherwise react-dom restores the controlled input to the old value
|
|
73
|
+
* after `input`, and Firefox then fires no `change`.
|
|
74
|
+
*/
|
|
75
|
+
const [stepHeld, setStepHeld] = useState(false);
|
|
76
|
+
const [pendingThumb, setPendingThumb] = useState(null);
|
|
77
|
+
/** The value of the latest step, read by the commit in the same or a later event. */
|
|
78
|
+
const liveRef = useRef(null);
|
|
79
|
+
/** The shown value when the open gesture began; `null` when no gesture is open. */
|
|
80
|
+
const gestureStart = useRef(null);
|
|
81
|
+
const activeGesture = useRef(null);
|
|
82
|
+
const commitSeq = useRef(0);
|
|
83
|
+
const trackRef = useRef(null);
|
|
84
|
+
const runCommit = async (next, details) => {
|
|
85
|
+
const seq = ++commitSeq.current;
|
|
86
|
+
try {
|
|
87
|
+
await valueCommitAction?.(next, details);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (value === void 0 && seq === commitSeq.current) {
|
|
90
|
+
await void 0;
|
|
91
|
+
stepTo(toArray(committedRef.current), null, "dismiss", void 0);
|
|
92
|
+
}
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const commitState = useControllableAction({
|
|
97
|
+
controlled: value,
|
|
98
|
+
defaultValue,
|
|
99
|
+
initialValue: platformDefault(min, max, step),
|
|
100
|
+
action: runCommit,
|
|
101
|
+
transitionTypes: () => COMMIT_TYPES,
|
|
102
|
+
warn: {
|
|
103
|
+
component: "Slider.Root",
|
|
104
|
+
prop: "value"
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
const { optimistic, committed, dispatch } = commitState;
|
|
108
|
+
const committedRef = useLatest(committed);
|
|
109
|
+
const { pending: stepPending, run: runStep } = useActionTrigger({ ignoreWhilePending: false });
|
|
110
|
+
const optimisticValues = useMemo(() => toArray(optimistic), [optimistic]);
|
|
111
|
+
const shown = (gestureThumb !== null || stepHeld || stepPending || commitState.pending) && live !== null ? live : optimisticValues;
|
|
112
|
+
const pending = stepPending || commitState.pending;
|
|
113
|
+
const thumbCount = shown.length;
|
|
114
|
+
const field = useFieldControl({
|
|
115
|
+
labelable: thumbCount === 1,
|
|
116
|
+
name: nameProp,
|
|
117
|
+
disabled: disabledProp,
|
|
118
|
+
component: "Slider.Root"
|
|
119
|
+
});
|
|
120
|
+
const fieldName = use(FieldContext)?.name;
|
|
121
|
+
const name = field.name;
|
|
122
|
+
const disabled = field.disabled;
|
|
123
|
+
const fieldId = field.id;
|
|
124
|
+
const thumbId = useCallback((index) => index === 0 && fieldId !== void 0 ? fieldId : `${id}-thumb-${index}`, [id, fieldId]);
|
|
125
|
+
const rootRef = useMergedRef(void 0, thumbCount > 1 ? field.ref : void 0);
|
|
126
|
+
useDevWarning(field.inField && field.required, "Slider.Root: a range is never empty, so `required` on the enclosing Field.Root has no effect on the slider.");
|
|
127
|
+
/**
|
|
128
|
+
* The reason of the latest change the user or the platform made, consumed by the Field
|
|
129
|
+
* notification below: `"activate"` dismisses a shown server error, a rollback does not.
|
|
130
|
+
*/
|
|
131
|
+
const lastReason = useRef(null);
|
|
132
|
+
useFieldValueChange(optimisticValues.join("\0"), () => {
|
|
133
|
+
const edit = lastReason.current === "activate";
|
|
134
|
+
lastReason.current = null;
|
|
135
|
+
return edit;
|
|
136
|
+
});
|
|
137
|
+
const { "aria-labelledby": fieldLabelledBy, "aria-describedby": fieldDescribedBy, "aria-invalid": fieldInvalid, "data-invalid": fieldDataInvalid } = field.attributes;
|
|
138
|
+
const inField = field.inField;
|
|
139
|
+
const fieldRef = field.ref;
|
|
140
|
+
const fieldWiring = useMemo(() => {
|
|
141
|
+
if (!inField) return null;
|
|
142
|
+
const single = thumbCount === 1;
|
|
143
|
+
return {
|
|
144
|
+
inputRef: single ? fieldRef : void 0,
|
|
145
|
+
describedBy: single ? fieldDescribedBy : void 0,
|
|
146
|
+
invalid: fieldInvalid,
|
|
147
|
+
dataInvalid: fieldDataInvalid,
|
|
148
|
+
name: fieldName
|
|
149
|
+
};
|
|
150
|
+
}, [
|
|
151
|
+
inField,
|
|
152
|
+
fieldRef,
|
|
153
|
+
thumbCount,
|
|
154
|
+
fieldDescribedBy,
|
|
155
|
+
fieldInvalid,
|
|
156
|
+
fieldDataInvalid,
|
|
157
|
+
fieldName
|
|
158
|
+
]);
|
|
159
|
+
/** What the thumbs show, for handlers; also written by `stepTo` ahead of the render. */
|
|
160
|
+
const shownRef = useLatest(shown);
|
|
161
|
+
const latest = useLatest({
|
|
162
|
+
valueChangeAction,
|
|
163
|
+
fromArray,
|
|
164
|
+
runStep,
|
|
165
|
+
min,
|
|
166
|
+
max,
|
|
167
|
+
step,
|
|
168
|
+
gap,
|
|
169
|
+
orientation,
|
|
170
|
+
disabled
|
|
171
|
+
});
|
|
172
|
+
const stepTo = useCallback((next, thumb, reason, event) => {
|
|
173
|
+
if (equalValues(next, shownRef.current)) return false;
|
|
174
|
+
liveRef.current = next;
|
|
175
|
+
shownRef.current = next;
|
|
176
|
+
lastReason.current = reason;
|
|
177
|
+
setLive(next);
|
|
178
|
+
setPendingThumb(thumb);
|
|
179
|
+
if (reason !== "dismiss") setStepHeld(true);
|
|
180
|
+
const { valueChangeAction: action, fromArray: toValue, runStep: run } = latest.current;
|
|
181
|
+
if (action === void 0) return true;
|
|
182
|
+
run(() => {
|
|
183
|
+
for (const type of STEP_TYPES) addTransitionType(type);
|
|
184
|
+
return action?.(toValue(next), createActionDetails(event, {
|
|
185
|
+
reason,
|
|
186
|
+
thumb
|
|
187
|
+
}));
|
|
188
|
+
});
|
|
189
|
+
return true;
|
|
190
|
+
}, [latest, shownRef]);
|
|
191
|
+
const commitGesture = useCallback((thumb, reason, event) => {
|
|
192
|
+
const start = gestureStart.current;
|
|
193
|
+
gestureStart.current = null;
|
|
194
|
+
setStepHeld(false);
|
|
195
|
+
const next = liveRef.current;
|
|
196
|
+
if (start === null || next === null || equalValues(next, start)) return;
|
|
197
|
+
lastReason.current = reason;
|
|
198
|
+
setPendingThumb(thumb);
|
|
199
|
+
dispatch(latest.current.fromArray(next), createActionDetails(event, {
|
|
200
|
+
reason,
|
|
201
|
+
thumb
|
|
202
|
+
}));
|
|
203
|
+
}, [dispatch, latest]);
|
|
204
|
+
const [registry] = useState(() => /* @__PURE__ */ new Map());
|
|
205
|
+
const warnedDuplicate = useRef(false);
|
|
206
|
+
const warnedForm = useRef(false);
|
|
207
|
+
const registerThumb = useCallback((index, input) => {
|
|
208
|
+
const existing = registry.get(index);
|
|
209
|
+
if (isDev && existing !== void 0 && existing !== input && !warnedDuplicate.current) {
|
|
210
|
+
warnedDuplicate.current = true;
|
|
211
|
+
console.error(`Slider.Thumb: two Thumbs have \`index={${index}}\`. Each value needs exactly one Thumb; give every Thumb a distinct index.`);
|
|
212
|
+
}
|
|
213
|
+
if (isDev && !warnedForm.current) {
|
|
214
|
+
for (const other of registry.values()) if (other !== input && other.form !== input.form) {
|
|
215
|
+
warnedForm.current = true;
|
|
216
|
+
console.error("Slider.Thumb: the thumbs of one Slider belong to different forms (a Thumb's `form` prop). A form reset is followed through the first thumb's form only; keep every thumb in one form.");
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
registry.set(index, input);
|
|
221
|
+
return () => {
|
|
222
|
+
if (registry.get(index) === input) registry.delete(index);
|
|
223
|
+
};
|
|
224
|
+
}, [registry]);
|
|
225
|
+
/** The first registered input: the form-associated element the reset subscription follows. */
|
|
226
|
+
const formElement = useMemo(() => ({
|
|
227
|
+
get current() {
|
|
228
|
+
let first = null;
|
|
229
|
+
let firstIndex = Number.POSITIVE_INFINITY;
|
|
230
|
+
for (const [index, input] of registry) if (index < firstIndex) {
|
|
231
|
+
firstIndex = index;
|
|
232
|
+
first = input;
|
|
233
|
+
}
|
|
234
|
+
return first;
|
|
235
|
+
},
|
|
236
|
+
set current(_ignored) {}
|
|
237
|
+
}), [registry]);
|
|
238
|
+
const [labelCount, setLabelCount] = useState(0);
|
|
239
|
+
const labelCountRef = useRef(0);
|
|
240
|
+
const registerLabel = useCallback(() => {
|
|
241
|
+
labelCountRef.current += 1;
|
|
242
|
+
setLabelCount((count) => count + 1);
|
|
243
|
+
return () => {
|
|
244
|
+
labelCountRef.current -= 1;
|
|
245
|
+
setLabelCount((count) => count - 1);
|
|
246
|
+
};
|
|
247
|
+
}, []);
|
|
248
|
+
const [mountValue] = useState(value);
|
|
249
|
+
const resetTarget = () => value !== void 0 ? toArray(mountValue ?? value) : toArray(defaultValue ?? platformDefault(min, max, step));
|
|
250
|
+
const readCurrent = () => shownRef.current.map((v, index) => {
|
|
251
|
+
const input = registry.get(index);
|
|
252
|
+
if (input === void 0) return v;
|
|
253
|
+
const read = Number(input.value);
|
|
254
|
+
return Number.isFinite(read) ? read : v;
|
|
255
|
+
});
|
|
256
|
+
const { onItemMounted } = useNativeGroupReconciliation({
|
|
257
|
+
element: formElement,
|
|
258
|
+
readCurrent,
|
|
259
|
+
readDefault: resetTarget,
|
|
260
|
+
base: () => shownRef.current,
|
|
261
|
+
equals: (a, b) => {
|
|
262
|
+
const reference = shownRef.current;
|
|
263
|
+
return equalValues(sanitize(a, reference, min, max, step, gap), sanitize(b, reference, min, max, step, gap));
|
|
264
|
+
},
|
|
265
|
+
onPlatformChange: (next, event) => {
|
|
266
|
+
if (next.length !== shownRef.current.length) return;
|
|
267
|
+
const before = shownRef.current;
|
|
268
|
+
gestureStart.current = before;
|
|
269
|
+
liveRef.current = before;
|
|
270
|
+
stepTo(next, null, "platform", event);
|
|
271
|
+
commitGesture(null, "platform", event);
|
|
272
|
+
},
|
|
273
|
+
onResetEvent: () => {
|
|
274
|
+
writeDefaults(registry, resetTarget());
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
const inputStep = useCallback((index, raw, event) => {
|
|
278
|
+
if (!Number.isFinite(raw)) return;
|
|
279
|
+
const before = shownRef.current;
|
|
280
|
+
if (index >= before.length) return;
|
|
281
|
+
if (stepTo(replaceAt(before, index, raw), index, "activate", event)) {
|
|
282
|
+
if (gestureStart.current === null) gestureStart.current = before;
|
|
283
|
+
}
|
|
284
|
+
}, [shownRef, stepTo]);
|
|
285
|
+
const inputCommit = useCallback((index, event) => {
|
|
286
|
+
if (activeGesture.current !== null) return;
|
|
287
|
+
commitGesture(index, "activate", event);
|
|
288
|
+
}, [commitGesture]);
|
|
289
|
+
const inputKeyDown = useCallback((index, event) => {
|
|
290
|
+
const { orientation: axis, disabled: off, min: lo, max: hi, step: inc, gap: g } = latest.current;
|
|
291
|
+
if (off) return;
|
|
292
|
+
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
293
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
294
|
+
let increaseKey;
|
|
295
|
+
if (axis === "vertical") increaseKey = "ArrowRight";
|
|
296
|
+
else {
|
|
297
|
+
const input = event.currentTarget;
|
|
298
|
+
if (input === null || getComputedStyle(input).direction !== "rtl") return;
|
|
299
|
+
increaseKey = "ArrowLeft";
|
|
300
|
+
}
|
|
301
|
+
event.preventDefault();
|
|
302
|
+
const before = shownRef.current;
|
|
303
|
+
const current = before[index];
|
|
304
|
+
if (current === void 0) return;
|
|
305
|
+
const delta = event.key === increaseKey ? inc : -inc;
|
|
306
|
+
const next = replaceAt(before, index, clampToNeighbours(before, index, current + delta, lo, hi, inc, g));
|
|
307
|
+
if (activeGesture.current !== null) {
|
|
308
|
+
stepTo(next, index, "activate", event);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
gestureStart.current = before;
|
|
312
|
+
liveRef.current = before;
|
|
313
|
+
stepTo(next, index, "activate", event);
|
|
314
|
+
commitGesture(index, "activate", event);
|
|
315
|
+
}, [
|
|
316
|
+
commitGesture,
|
|
317
|
+
latest,
|
|
318
|
+
shownRef,
|
|
319
|
+
stepTo
|
|
320
|
+
]);
|
|
321
|
+
const warnedNoTrack = useRef(false);
|
|
322
|
+
const beginGesture = useCallback((index, event, element) => {
|
|
323
|
+
const { disabled: off } = latest.current;
|
|
324
|
+
if (off || event.button !== 0 || activeGesture.current !== null) return;
|
|
325
|
+
const track = trackRef.current;
|
|
326
|
+
if (track === null) {
|
|
327
|
+
if (isDev && !warnedNoTrack.current) {
|
|
328
|
+
warnedNoTrack.current = true;
|
|
329
|
+
console.error("Slider.Thumb: a pointer press needs a Slider.Track to map the pointer to a value. Without a Track the slider is keyboard-only.");
|
|
330
|
+
}
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
event.preventDefault();
|
|
334
|
+
const rtl = getComputedStyle(track).direction === "rtl";
|
|
335
|
+
const valueAt = (clientX, clientY) => {
|
|
336
|
+
const { min: lo, max: hi, orientation: axis } = latest.current;
|
|
337
|
+
const rect = (trackRef.current ?? track).getBoundingClientRect();
|
|
338
|
+
let fraction;
|
|
339
|
+
if (axis === "vertical") fraction = rect.height > 0 ? (rect.bottom - clientY) / rect.height : 0;
|
|
340
|
+
else {
|
|
341
|
+
fraction = rect.width > 0 ? (clientX - rect.left) / rect.width : 0;
|
|
342
|
+
if (rtl) fraction = 1 - fraction;
|
|
343
|
+
}
|
|
344
|
+
fraction = Math.min(1, Math.max(0, fraction));
|
|
345
|
+
return lo + fraction * (hi - lo);
|
|
346
|
+
};
|
|
347
|
+
const moveTo = (thumb, raw, cause) => {
|
|
348
|
+
const { min: lo, max: hi, step: inc, gap: g } = latest.current;
|
|
349
|
+
const before = shownRef.current;
|
|
350
|
+
if (thumb >= before.length) return;
|
|
351
|
+
stepTo(replaceAt(before, thumb, clampToNeighbours(before, thumb, raw, lo, hi, inc, g)), thumb, "activate", cause);
|
|
352
|
+
};
|
|
353
|
+
const start = valueAt(event.clientX, event.clientY);
|
|
354
|
+
const startValues = shownRef.current;
|
|
355
|
+
let tied = null;
|
|
356
|
+
if (index !== null) {
|
|
357
|
+
const at = startValues[index];
|
|
358
|
+
if (at !== void 0) {
|
|
359
|
+
let first = index;
|
|
360
|
+
let last = index;
|
|
361
|
+
while (first > 0 && equalValues([startValues[first - 1]], [at])) first -= 1;
|
|
362
|
+
while (last < startValues.length - 1 && equalValues([startValues[last + 1]], [at])) last += 1;
|
|
363
|
+
if (first !== last) tied = {
|
|
364
|
+
first,
|
|
365
|
+
last,
|
|
366
|
+
at
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const resolveTie = (raw) => {
|
|
371
|
+
if (tied === null) return null;
|
|
372
|
+
if (raw > tied.at) return tied.last;
|
|
373
|
+
if (raw < tied.at) return tied.first;
|
|
374
|
+
return null;
|
|
375
|
+
};
|
|
376
|
+
/** The thumb the gesture moves; `null` while a press on stacked thumbs is undecided. */
|
|
377
|
+
let decided = index === null ? nearestThumb(startValues, start) : tied ? resolveTie(start) : index;
|
|
378
|
+
/** The thumb shown as dragging and focused meanwhile. */
|
|
379
|
+
let thumb = decided ?? index ?? 0;
|
|
380
|
+
const pointerId = event.pointerId;
|
|
381
|
+
try {
|
|
382
|
+
element.setPointerCapture(pointerId);
|
|
383
|
+
} catch {}
|
|
384
|
+
const decide = (raw) => {
|
|
385
|
+
if (decided !== null) return true;
|
|
386
|
+
decided = resolveTie(raw);
|
|
387
|
+
if (decided === null) return false;
|
|
388
|
+
if (decided !== thumb) {
|
|
389
|
+
thumb = decided;
|
|
390
|
+
setGestureThumb(thumb);
|
|
391
|
+
registry.get(thumb)?.focus({ focusVisible: false });
|
|
392
|
+
}
|
|
393
|
+
return true;
|
|
394
|
+
};
|
|
395
|
+
const follow = (pointerEvent) => {
|
|
396
|
+
const raw = valueAt(pointerEvent.clientX, pointerEvent.clientY);
|
|
397
|
+
if (decide(raw)) moveTo(thumb, raw, pointerEvent);
|
|
398
|
+
};
|
|
399
|
+
const onMove = (moveEvent) => {
|
|
400
|
+
if (moveEvent.pointerId !== pointerId) return;
|
|
401
|
+
follow(moveEvent);
|
|
402
|
+
};
|
|
403
|
+
const onEnd = (endEvent) => {
|
|
404
|
+
if (endEvent.pointerId !== pointerId) return;
|
|
405
|
+
detach();
|
|
406
|
+
if (endEvent.type === "pointerup") follow(endEvent);
|
|
407
|
+
activeGesture.current = null;
|
|
408
|
+
setGestureThumb(null);
|
|
409
|
+
commitGesture(thumb, "activate", endEvent);
|
|
410
|
+
};
|
|
411
|
+
const detach = () => {
|
|
412
|
+
element.removeEventListener("pointermove", onMove);
|
|
413
|
+
element.removeEventListener("pointerup", onEnd);
|
|
414
|
+
element.removeEventListener("pointercancel", onEnd);
|
|
415
|
+
element.removeEventListener("lostpointercapture", onEnd);
|
|
416
|
+
};
|
|
417
|
+
element.addEventListener("pointermove", onMove);
|
|
418
|
+
element.addEventListener("pointerup", onEnd);
|
|
419
|
+
element.addEventListener("pointercancel", onEnd);
|
|
420
|
+
element.addEventListener("lostpointercapture", onEnd);
|
|
421
|
+
activeGesture.current = {
|
|
422
|
+
pointerId,
|
|
423
|
+
detach
|
|
424
|
+
};
|
|
425
|
+
setGestureThumb(thumb);
|
|
426
|
+
gestureStart.current = shownRef.current;
|
|
427
|
+
liveRef.current = shownRef.current;
|
|
428
|
+
setLive(shownRef.current);
|
|
429
|
+
registry.get(thumb)?.focus({ focusVisible: false });
|
|
430
|
+
if (decided !== null) moveTo(thumb, start, event);
|
|
431
|
+
}, [
|
|
432
|
+
commitGesture,
|
|
433
|
+
latest,
|
|
434
|
+
registry,
|
|
435
|
+
shownRef,
|
|
436
|
+
stepTo
|
|
437
|
+
]);
|
|
438
|
+
useEffect(() => () => {
|
|
439
|
+
activeGesture.current?.detach();
|
|
440
|
+
activeGesture.current = null;
|
|
441
|
+
}, []);
|
|
442
|
+
useDevWarning(!stepValid, `Slider.Root: \`step\` must be a positive number (got ${String(stepProp)}); using 1.`);
|
|
443
|
+
useDevWarning(stepValid && !isMaxReachable(min, max, step), `Slider.Root: \`max\` (${max}) is not on the step grid from \`min\` (${min}) with \`step\` ${step}: it is unreachable, as on a native range. The last reachable value is the last step below \`max\`.`);
|
|
444
|
+
const given = value ?? defaultValue;
|
|
445
|
+
const givenValues = given === void 0 ? [] : toArray(given);
|
|
446
|
+
useDevWarning(givenValues.some((v) => !isOnGrid(v, min, max, step)), `Slider.Root: the ${value !== void 0 ? "`value`" : "`defaultValue`"} (${givenValues.join(", ")}) is off the step grid or outside \`min\` / \`max\`. It is rendered as given and the browser sanitises it; the first user step snaps it.`);
|
|
447
|
+
useDevWarning(givenValues.some((v, i) => i > 0 && v < givenValues[i - 1]), `Slider.Root: the values (${givenValues.join(", ")}) must be in ascending order; the thumbs would be rendered crossed.`);
|
|
448
|
+
const currentShape = shapeOf(given);
|
|
449
|
+
useDevWarning(currentShape !== void 0 && currentShape !== shape, "Slider.Root: the value changed shape between a number and an array after mount. The shape is fixed at mount; remount the Slider (a `key`) to change the number of thumbs.");
|
|
450
|
+
const unnamedGroup = shown.length > 1 && !inField && rest["aria-label"] === void 0 && rest["aria-labelledby"] === void 0;
|
|
451
|
+
const warnedGroupName = useRef(false);
|
|
452
|
+
useEffect(() => {
|
|
453
|
+
if (!isDev || warnedGroupName.current || !unnamedGroup || labelCountRef.current > 0) return;
|
|
454
|
+
warnedGroupName.current = true;
|
|
455
|
+
console.error("Slider.Root: a slider with several thumbs is a `group` and needs a name: render a Slider.Label, or pass `aria-label` / `aria-labelledby` to the Root.");
|
|
456
|
+
}, [unnamedGroup]);
|
|
457
|
+
const count = shown.length;
|
|
458
|
+
const percents = shown.map((v) => percent(v, min, max));
|
|
459
|
+
const geometry = {
|
|
460
|
+
"--slider-start": count > 1 ? `${percents[0] ?? 0}%` : "0%",
|
|
461
|
+
"--slider-end": `${percents[count - 1] ?? 0}%`
|
|
462
|
+
};
|
|
463
|
+
percents.forEach((p, index) => {
|
|
464
|
+
geometry[`--slider-value-${index}`] = `${p}%`;
|
|
465
|
+
});
|
|
466
|
+
const shownValue = fromArray(shown);
|
|
467
|
+
const dragging = gestureThumb !== null;
|
|
468
|
+
const state = useMemo(() => ({
|
|
469
|
+
value: shownValue,
|
|
470
|
+
values: shown,
|
|
471
|
+
pending,
|
|
472
|
+
dragging,
|
|
473
|
+
orientation,
|
|
474
|
+
disabled,
|
|
475
|
+
min,
|
|
476
|
+
max,
|
|
477
|
+
step
|
|
478
|
+
}), [
|
|
479
|
+
shownValue,
|
|
480
|
+
shown,
|
|
481
|
+
pending,
|
|
482
|
+
dragging,
|
|
483
|
+
orientation,
|
|
484
|
+
disabled,
|
|
485
|
+
min,
|
|
486
|
+
max,
|
|
487
|
+
step
|
|
488
|
+
]);
|
|
489
|
+
const context = useMemo(() => ({
|
|
490
|
+
state,
|
|
491
|
+
shown,
|
|
492
|
+
shownValue,
|
|
493
|
+
min,
|
|
494
|
+
max,
|
|
495
|
+
step,
|
|
496
|
+
gap,
|
|
497
|
+
orientation,
|
|
498
|
+
disabled,
|
|
499
|
+
pending,
|
|
500
|
+
draggingThumb: gestureThumb,
|
|
501
|
+
pendingThumb,
|
|
502
|
+
name,
|
|
503
|
+
form,
|
|
504
|
+
getAriaValueText,
|
|
505
|
+
labelId,
|
|
506
|
+
thumbId,
|
|
507
|
+
trackRef,
|
|
508
|
+
inputStep,
|
|
509
|
+
inputCommit,
|
|
510
|
+
inputKeyDown,
|
|
511
|
+
beginGesture,
|
|
512
|
+
registerThumb,
|
|
513
|
+
registerLabel,
|
|
514
|
+
onItemMounted,
|
|
515
|
+
field: fieldWiring
|
|
516
|
+
}), [
|
|
517
|
+
state,
|
|
518
|
+
shown,
|
|
519
|
+
shownValue,
|
|
520
|
+
min,
|
|
521
|
+
max,
|
|
522
|
+
step,
|
|
523
|
+
gap,
|
|
524
|
+
orientation,
|
|
525
|
+
disabled,
|
|
526
|
+
pending,
|
|
527
|
+
gestureThumb,
|
|
528
|
+
pendingThumb,
|
|
529
|
+
name,
|
|
530
|
+
form,
|
|
531
|
+
getAriaValueText,
|
|
532
|
+
labelId,
|
|
533
|
+
thumbId,
|
|
534
|
+
inputStep,
|
|
535
|
+
inputCommit,
|
|
536
|
+
inputKeyDown,
|
|
537
|
+
beginGesture,
|
|
538
|
+
registerThumb,
|
|
539
|
+
registerLabel,
|
|
540
|
+
onItemMounted,
|
|
541
|
+
fieldWiring
|
|
542
|
+
]);
|
|
543
|
+
const labelledBy = count > 1 ? mergeTokenLists(fieldLabelledBy, labelCount > 0 ? labelId : void 0) : "";
|
|
544
|
+
const libraryProps = {
|
|
545
|
+
role: count > 1 ? "group" : void 0,
|
|
546
|
+
...labelledBy !== "" ? { "aria-labelledby": labelledBy } : {},
|
|
547
|
+
...count > 1 && fieldDescribedBy !== void 0 ? { "aria-describedby": fieldDescribedBy } : {},
|
|
548
|
+
...inField ? { "data-invalid": fieldDataInvalid } : {},
|
|
549
|
+
"data-pending": dataAttr(pending),
|
|
550
|
+
"data-dragging": dataAttr(dragging),
|
|
551
|
+
"data-orientation": orientation,
|
|
552
|
+
"data-disabled": dataAttr(disabled)
|
|
553
|
+
};
|
|
554
|
+
const element = useRender({
|
|
555
|
+
defaultElement: "div",
|
|
556
|
+
render,
|
|
557
|
+
state,
|
|
558
|
+
className,
|
|
559
|
+
style: (s) => ({
|
|
560
|
+
...geometry,
|
|
561
|
+
...resolveStateValue(style, s)
|
|
562
|
+
}),
|
|
563
|
+
children,
|
|
564
|
+
props: rest,
|
|
565
|
+
libraryProps,
|
|
566
|
+
ref: rootRef
|
|
567
|
+
});
|
|
568
|
+
return /* @__PURE__ */ jsx(SliderContext, {
|
|
569
|
+
value: context,
|
|
570
|
+
children: element
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
SliderRootImpl.displayName = "SliderRoot";
|
|
574
|
+
/**
|
|
575
|
+
* `Slider.Root`. Overloaded so that the value's shape is inferred from `value` / `defaultValue`
|
|
576
|
+
* as `number` or `readonly number[]` (an array literal would otherwise infer a mutable
|
|
577
|
+
* `number[]`), and every action and state function receives that shape (design 3.1).
|
|
578
|
+
*/
|
|
579
|
+
const SliderRoot = SliderRootImpl;
|
|
580
|
+
//#endregion
|
|
581
|
+
export { SliderRoot };
|
|
582
|
+
|
|
583
|
+
//# sourceMappingURL=slider-root.mjs.map
|