@funstack/ui 0.1.0-alpha.11 → 0.1.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion/accordion-context.mjs.map +1 -1
- package/dist/accordion/accordion-item.d.mts +3 -4
- package/dist/accordion/accordion-item.d.mts.map +1 -1
- package/dist/accordion/accordion-item.mjs +10 -4
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.d.mts +3 -4
- package/dist/accordion/accordion-panel.d.mts.map +1 -1
- package/dist/accordion/accordion-panel.mjs +2 -1
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts +3 -3
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +8 -19
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts +3 -4
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +5 -3
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/button/button.d.mts +4 -2
- package/dist/button/button.d.mts.map +1 -1
- package/dist/button/button.mjs +3 -2
- package/dist/button/button.mjs.map +1 -1
- package/dist/checkbox/checkbox.d.mts +4 -5
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +16 -59
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +3 -4
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +21 -27
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.mjs +1 -6
- package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts +3 -4
- package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +12 -10
- package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +74 -101
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +5 -6
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-context.mjs.map +1 -1
- package/dist/combobox/combobox-group.d.mts.map +1 -1
- package/dist/combobox/combobox-group.mjs +2 -1
- package/dist/combobox/combobox-group.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +14 -7
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-list.d.mts.map +1 -1
- package/dist/combobox/combobox-list.mjs +6 -10
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +2 -1
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +9 -25
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +30 -102
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +6 -25
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.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 +3 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +37 -98
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +30 -118
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +13 -16
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/field/field-control.mjs +6 -13
- package/dist/field/field-control.mjs.map +1 -1
- package/dist/field/field-description.d.mts.map +1 -1
- package/dist/field/field-description.mjs +1 -2
- package/dist/field/field-description.mjs.map +1 -1
- package/dist/field/field-error.d.mts.map +1 -1
- package/dist/field/field-error.mjs +1 -2
- package/dist/field/field-error.mjs.map +1 -1
- package/dist/field/field-label.d.mts.map +1 -1
- package/dist/field/field-label.mjs +3 -11
- package/dist/field/field-label.mjs.map +1 -1
- package/dist/field/field-root.mjs +21 -41
- package/dist/field/field-root.mjs.map +1 -1
- package/dist/field/index.mjs +1 -1
- package/dist/field/use-server-error-visibility.mjs +44 -0
- package/dist/field/use-server-error-visibility.mjs.map +1 -0
- package/dist/form/form-root.d.mts.map +1 -1
- package/dist/form/form-root.mjs +6 -7
- package/dist/form/form-root.mjs.map +1 -1
- package/dist/form/form-submit.d.mts +1 -1
- package/dist/form/form-submit.mjs +4 -10
- package/dist/form/form-submit.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/internal/anchor-position.mjs +1 -59
- package/dist/internal/anchor-position.mjs.map +1 -1
- package/dist/internal/announce.mjs.map +1 -1
- package/dist/internal/arrow-keys.mjs +21 -0
- package/dist/internal/arrow-keys.mjs.map +1 -0
- package/dist/internal/decimal.mjs +7 -1
- package/dist/internal/decimal.mjs.map +1 -1
- package/dist/internal/dom-order.mjs +17 -0
- package/dist/internal/dom-order.mjs.map +1 -0
- package/dist/internal/field-context.d.mts.map +1 -1
- package/dist/internal/field-context.mjs +11 -1
- package/dist/internal/field-context.mjs.map +1 -1
- package/dist/internal/focus-first-invalid.mjs +1 -1
- package/dist/internal/focus-first-invalid.mjs.map +1 -1
- package/dist/internal/group-member.mjs +37 -0
- package/dist/internal/group-member.mjs.map +1 -0
- package/dist/internal/overlay-popup.mjs +103 -0
- package/dist/internal/overlay-popup.mjs.map +1 -0
- package/dist/internal/popover-open.mjs +18 -0
- package/dist/internal/popover-open.mjs.map +1 -0
- package/dist/internal/render-element.d.mts +2 -0
- package/dist/internal/render-element.mjs +20 -2
- package/dist/internal/render-element.mjs.map +1 -1
- package/dist/internal/shipped-styles.mjs +14 -0
- package/dist/internal/shipped-styles.mjs.map +1 -0
- package/dist/internal/sync-presence.mjs +5 -1
- package/dist/internal/sync-presence.mjs.map +1 -1
- package/dist/internal/toolbar-context.mjs.map +1 -1
- package/dist/internal/tooltip-warm.mjs +1 -1
- package/dist/internal/tooltip-warm.mjs.map +1 -1
- package/dist/internal/transition-boundary.mjs +1 -1
- package/dist/internal/transition-boundary.mjs.map +1 -1
- package/dist/internal/types.d.mts +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} +28 -39
- package/dist/internal/use-overlay-root.mjs.map +1 -0
- package/dist/internal/use-popover-popup.mjs +32 -78
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.d.mts +15 -0
- package/dist/internal/use-popover-trigger.d.mts.map +1 -0
- package/dist/internal/use-popover-trigger.mjs +13 -17
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/use-register-count.mjs +24 -0
- package/dist/internal/use-register-count.mjs.map +1 -0
- package/dist/internal/use-render.d.mts +2 -0
- package/dist/internal/use-render.mjs +2 -2
- package/dist/internal/use-render.mjs.map +1 -1
- package/dist/internal/use-resolved-placement.mjs +38 -22
- package/dist/internal/use-resolved-placement.mjs.map +1 -1
- package/dist/internal/use-roving-focus.mjs +5 -18
- package/dist/internal/use-roving-focus.mjs.map +1 -1
- package/dist/internal/use-superseded-rejection.mjs +47 -0
- package/dist/internal/use-superseded-rejection.mjs.map +1 -0
- package/dist/internal/validity.mjs +1 -13
- package/dist/internal/validity.mjs.map +1 -1
- package/dist/internal/value-set.mjs +41 -0
- package/dist/internal/value-set.mjs.map +1 -0
- package/dist/menu/index.d.mts +1 -1
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +2 -7
- package/dist/menu/menu-context-trigger.d.mts.map +1 -1
- package/dist/menu/menu-context-trigger.mjs +10 -187
- package/dist/menu/menu-context-trigger.mjs.map +1 -1
- package/dist/menu/menu-context.d.mts +1 -1
- package/dist/menu/menu-context.mjs +1 -1
- package/dist/menu/menu-context.mjs.map +1 -1
- package/dist/menu/menu-dom.mjs +1 -2
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-gestures.mjs +167 -0
- package/dist/menu/menu-gestures.mjs.map +1 -0
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +2 -1
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-hover.mjs +0 -1
- package/dist/menu/menu-hover.mjs.map +1 -1
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-outside.mjs +101 -0
- package/dist/menu/menu-outside.mjs.map +1 -0
- package/dist/menu/menu-point.mjs +85 -0
- package/dist/menu/menu-point.mjs.map +1 -0
- package/dist/menu/menu-popup.d.mts +6 -7
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +37 -248
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +10 -0
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +10 -8
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +6 -6
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +4 -9
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +8 -6
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/menu/use-menu-item.mjs +14 -16
- package/dist/menu/use-menu-item.mjs.map +1 -1
- package/dist/menu/use-menu-keyboard.mjs +88 -0
- package/dist/menu/use-menu-keyboard.mjs.map +1 -0
- package/dist/meter/meter-root.mjs +1 -1
- package/dist/number-field/index.d.mts +2 -1
- package/dist/number-field/index.d.mts.map +1 -1
- package/dist/number-field/index.mjs +2 -2
- package/dist/number-field/index.mjs.map +1 -1
- package/dist/number-field/number-field-arithmetic.mjs +30 -11
- package/dist/number-field/number-field-arithmetic.mjs.map +1 -1
- package/dist/number-field/number-field-context.d.mts +6 -1
- package/dist/number-field/number-field-context.d.mts.map +1 -0
- package/dist/number-field/number-field-context.mjs.map +1 -1
- package/dist/number-field/number-field-decrement.d.mts +1 -1
- package/dist/number-field/number-field-decrement.mjs +1 -1
- package/dist/number-field/number-field-decrement.mjs.map +1 -1
- package/dist/number-field/number-field-increment.d.mts +2 -22
- package/dist/number-field/number-field-increment.d.mts.map +1 -1
- package/dist/number-field/number-field-increment.mjs +2 -53
- package/dist/number-field/number-field-increment.mjs.map +1 -1
- package/dist/number-field/number-field-input.d.mts.map +1 -1
- package/dist/number-field/number-field-input.mjs +18 -22
- package/dist/number-field/number-field-input.mjs.map +1 -1
- package/dist/number-field/number-field-label.d.mts.map +1 -1
- package/dist/number-field/number-field-label.mjs +3 -9
- package/dist/number-field/number-field-label.mjs.map +1 -1
- package/dist/number-field/number-field-root.d.mts +2 -1
- package/dist/number-field/number-field-root.d.mts.map +1 -1
- package/dist/number-field/number-field-root.mjs +81 -91
- package/dist/number-field/number-field-root.mjs.map +1 -1
- package/dist/number-field/use-number-field-dev-warnings.mjs +28 -0
- package/dist/number-field/use-number-field-dev-warnings.mjs.map +1 -0
- package/dist/number-field/use-step-button.d.mts +24 -0
- package/dist/number-field/use-step-button.d.mts.map +1 -0
- package/dist/number-field/use-step-button.mjs +57 -3
- package/dist/number-field/use-step-button.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +28 -67
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-context.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +9 -6
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +13 -36
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.mjs +4 -3
- package/dist/popover/popover-root.mjs.map +1 -1
- package/dist/popover/popover-trigger.d.mts +4 -8
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +2 -1
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/progress-root.mjs +1 -1
- package/dist/radio-group/radio-group-context.mjs.map +1 -1
- package/dist/radio-group/radio-group-item.d.mts +3 -4
- package/dist/radio-group/radio-group-item.d.mts.map +1 -1
- package/dist/radio-group/radio-group-item.mjs +20 -25
- package/dist/radio-group/radio-group-item.mjs.map +1 -1
- package/dist/radio-group/radio-group-label.mjs +1 -6
- package/dist/radio-group/radio-group-label.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +1 -1
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +21 -40
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/select-dom.mjs +9 -18
- package/dist/select/select-dom.mjs.map +1 -1
- package/dist/select/select-option.mjs +1 -1
- package/dist/select/select-root.mjs +3 -2
- package/dist/select/select-root.mjs.map +1 -1
- package/dist/slider/slider-arithmetic.mjs +74 -13
- package/dist/slider/slider-arithmetic.mjs.map +1 -1
- package/dist/slider/slider-context.mjs.map +1 -1
- package/dist/slider/slider-label.d.mts.map +1 -1
- package/dist/slider/slider-label.mjs +3 -9
- package/dist/slider/slider-label.mjs.map +1 -1
- package/dist/slider/slider-root.d.mts +2 -2
- package/dist/slider/slider-root.d.mts.map +1 -1
- package/dist/slider/slider-root.mjs +36 -116
- package/dist/slider/slider-root.mjs.map +1 -1
- package/dist/slider/slider-thumb.d.mts.map +1 -1
- package/dist/slider/slider-thumb.mjs +8 -6
- package/dist/slider/slider-thumb.mjs.map +1 -1
- package/dist/slider/slider-value.d.mts.map +1 -1
- package/dist/slider/slider-value.mjs +2 -1
- package/dist/slider/slider-value.mjs.map +1 -1
- package/dist/slider/use-slider-dev-warnings.mjs +29 -0
- package/dist/slider/use-slider-dev-warnings.mjs.map +1 -0
- package/dist/slider/use-thumb-registry.mjs +51 -0
- package/dist/slider/use-thumb-registry.mjs.map +1 -0
- package/dist/switch/switch.d.mts +4 -5
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +15 -55
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/tabs-context.d.mts +2 -3
- package/dist/tabs/tabs-context.d.mts.map +1 -1
- package/dist/tabs/tabs-context.mjs.map +1 -1
- package/dist/tabs/tabs-list.d.mts.map +1 -1
- package/dist/tabs/tabs-list.mjs +9 -22
- package/dist/tabs/tabs-list.mjs.map +1 -1
- package/dist/tabs/tabs-panel.d.mts +3 -4
- package/dist/tabs/tabs-panel.d.mts.map +1 -1
- package/dist/tabs/tabs-panel.mjs.map +1 -1
- package/dist/tabs/tabs-root.d.mts +4 -3
- package/dist/tabs/tabs-root.d.mts.map +1 -1
- package/dist/tabs/tabs-root.mjs +2 -1
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.d.mts +3 -4
- package/dist/tabs/tabs-tab.d.mts.map +1 -1
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/toast-action.mjs.map +1 -1
- package/dist/toast/toast-close.d.mts.map +1 -1
- package/dist/toast/toast-close.mjs +2 -8
- package/dist/toast/toast-close.mjs.map +1 -1
- package/dist/toast/toast-context.mjs.map +1 -1
- package/dist/toast/toast-hotkey.mjs +27 -0
- package/dist/toast/toast-hotkey.mjs.map +1 -0
- package/dist/toast/toast-queue.mjs +137 -0
- package/dist/toast/toast-queue.mjs.map +1 -0
- package/dist/toast/toast-timers.mjs +65 -0
- package/dist/toast/toast-timers.mjs.map +1 -0
- package/dist/toast/toast-viewport.d.mts.map +1 -1
- package/dist/toast/toast-viewport.mjs +30 -235
- package/dist/toast/toast-viewport.mjs.map +1 -1
- package/dist/toast/toast.mjs +1 -1
- package/dist/toast/toast.mjs.map +1 -1
- package/dist/toast/use-modal-portal-host.mjs +52 -0
- package/dist/toast/use-modal-portal-host.mjs.map +1 -0
- package/dist/toggle/toggle.d.mts +3 -4
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +7 -10
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-context.d.mts +2 -1
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-item.d.mts +5 -3
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-item.mjs +5 -7
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-root.mjs +29 -64
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
- package/dist/toolbar/toolbar-root.d.mts +2 -2
- package/dist/toolbar/toolbar-root.d.mts.map +1 -1
- package/dist/toolbar/toolbar-root.mjs +3 -4
- package/dist/toolbar/toolbar-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-context.d.mts +1 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +6 -15
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +2 -2
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +2 -1
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +3 -2
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/dist/tooltip/use-tooltip-interaction.mjs +4 -3
- package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/accordion/accordion-context.d.mts +0 -5
- package/dist/accordion/accordion-context.d.mts.map +0 -1
- package/dist/internal/use-popover-root.mjs.map +0 -1
- /package/dist/internal/{use-popover-root.d.mts → use-overlay-root.d.mts} +0 -0
|
@@ -1,7 +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 {
|
|
4
|
+
import { useElementCheck } from "../internal/use-element-check.mjs";
|
|
5
|
+
import { useMergedRefs } from "../internal/use-merged-refs.mjs";
|
|
6
|
+
import { useFieldControl } from "../internal/use-field-control.mjs";
|
|
5
7
|
import { optionId, useComboboxContext } from "./combobox-context.mjs";
|
|
6
8
|
import { isValidElement, useCallback } from "react";
|
|
7
9
|
//#region src/combobox/combobox-input.tsx
|
|
@@ -30,18 +32,23 @@ function ComboboxInput({ className, style, render, ...rest }) {
|
|
|
30
32
|
stale: ctx.stale,
|
|
31
33
|
disabled: ctx.disabled
|
|
32
34
|
};
|
|
35
|
+
const checkElement = useElementCheck(isDev && ((element) => {
|
|
36
|
+
const type = element.tagName === "INPUT" ? element.type : "";
|
|
37
|
+
return type !== "text" && type !== "search" ? `Combobox.Input: rendered <${element.tagName.toLowerCase()}${type === "" ? "" : ` type="${type}"`}>. Render an <input> of type "text" or "search": \`role="combobox"\`, \`aria-activedescendant\` and the caret keys depend on it.` : null;
|
|
38
|
+
}));
|
|
33
39
|
const ref = useCallback((element) => {
|
|
34
|
-
|
|
35
|
-
const type = element.tagName === "INPUT" ? element.type : "";
|
|
36
|
-
if (type !== "text" && type !== "search") console.error(`Combobox.Input: rendered <${element.tagName.toLowerCase()}${type === "" ? "" : ` type="${type}"`}>. Render an <input> of type "text" or "search": \`role="combobox"\`, \`aria-activedescendant\` and the caret keys depend on it.`);
|
|
37
|
-
}
|
|
40
|
+
checkElement?.(element);
|
|
38
41
|
inputRef.current = element;
|
|
39
42
|
triggerRef.current = element;
|
|
40
43
|
return () => {
|
|
41
44
|
if (inputRef.current === element) inputRef.current = null;
|
|
42
45
|
if (triggerRef.current === element) triggerRef.current = null;
|
|
43
46
|
};
|
|
44
|
-
}, [
|
|
47
|
+
}, [
|
|
48
|
+
checkElement,
|
|
49
|
+
inputRef,
|
|
50
|
+
triggerRef
|
|
51
|
+
]);
|
|
45
52
|
const field = useFieldControl({
|
|
46
53
|
labelable: true,
|
|
47
54
|
required: rest.required,
|
|
@@ -50,7 +57,7 @@ function ComboboxInput({ className, style, render, ...rest }) {
|
|
|
50
57
|
component: "Combobox.Input"
|
|
51
58
|
});
|
|
52
59
|
const fieldRef = field.ref;
|
|
53
|
-
const mergedRef =
|
|
60
|
+
const mergedRef = useMergedRefs(ref, fieldRef);
|
|
54
61
|
const searchType = isValidElement(render) && render.props.type === "search";
|
|
55
62
|
const libraryProps = {
|
|
56
63
|
...field.attributes,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-input.mjs","names":[],"sources":["../../src/combobox/combobox-input.tsx"],"sourcesContent":["\"use client\";\nimport { isValidElement, useCallback } from \"react\";\nimport type {\n ChangeEvent,\n ComponentPropsWithRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useFieldControl
|
|
1
|
+
{"version":3,"file":"combobox-input.mjs","names":[],"sources":["../../src/combobox/combobox-input.tsx"],"sourcesContent":["\"use client\";\nimport { isValidElement, useCallback } from \"react\";\nimport type {\n ChangeEvent,\n ComponentPropsWithRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n} 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 { 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 { optionId, useComboboxContext } from \"./combobox-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ComboboxInputState {\n /** Optimistic selection. */\n readonly value: string | null;\n /** The urgent text. */\n readonly inputValue: string;\n /** Optimistic open state. */\n readonly open: boolean;\n /** The Root is pending (a selection or an open in flight). */\n readonly pending: boolean;\n /** The results shown are for an older text. */\n readonly stale: boolean;\n readonly disabled: boolean;\n}\n\nexport interface ComboboxInputProps extends Omit<\n ComponentPropsWithRef<\"input\">,\n | \"value\"\n | \"defaultValue\"\n | \"onChange\"\n | \"onInput\"\n | \"onKeyDown\"\n | \"onBlur\"\n | \"onClick\"\n | \"role\"\n | \"aria-autocomplete\"\n | \"aria-expanded\"\n | \"aria-controls\"\n | \"aria-activedescendant\"\n | \"autoComplete\"\n | \"disabled\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Native `required`: empty text is `valueMissing`. */\n required?: boolean;\n className?: StateValue<string | undefined, ComboboxInputState>;\n style?: StateValue<CSSProperties | undefined, ComboboxInputState>;\n /** Must render an `<input>` of type `text` or `search`. */\n render?: RenderProp<ComponentPropsWithRef<\"input\">, ComboboxInputState>;\n}\n\n/**\n * The text field: `<input role=\"combobox\" aria-autocomplete=\"list\" aria-expanded aria-controls\n * aria-activedescendant autocomplete=\"off\">`. DOM focus stays here while the active option moves\n * virtually (design 7.1). Its text is the Root's urgent `inputValue`; typing opens the listbox.\n *\n * Owned keys (conventions 1.2): `id`, `type`, `role`, `value`, `autoComplete`,\n * `aria-autocomplete`, `aria-expanded`, `aria-controls` (token-merged), `aria-activedescendant`,\n * `disabled`, `onChange`, `onKeyDown`, `onBlur`, `onClick`, `data-open`, `data-pending`,\n * `data-selected`, `data-stale`, `data-disabled`; inside a `Field.Root` (whose control id it\n * takes) also `required` (own or the Field's), `aria-describedby` (token-merged), `aria-invalid`\n * and `data-invalid`.\n */\nexport function ComboboxInput({ className, style, render, ...rest }: ComboboxInputProps) {\n const ctx = useComboboxContext(\"Combobox.Input\");\n const { popover, ids, inputRef } = ctx;\n const { triggerRef } = popover;\n\n const state: ComboboxInputState = {\n value: ctx.value,\n inputValue: ctx.inputValue,\n open: popover.optimistic,\n pending: ctx.pending,\n stale: ctx.stale,\n disabled: ctx.disabled,\n };\n\n const checkElement = useElementCheck(\n isDev &&\n ((element) => {\n const type = element.tagName === \"INPUT\" ? (element as HTMLInputElement).type : \"\";\n return type !== \"text\" && type !== \"search\"\n ? `Combobox.Input: rendered <${element.tagName.toLowerCase()}` +\n `${type === \"\" ? \"\" : ` type=\"${type}\"`}>. Render an <input> of type \"text\" or ` +\n '\"search\": `role=\"combobox\"`, `aria-activedescendant` and the caret keys depend on it.'\n : null;\n }),\n );\n const ref = useCallback(\n (element: HTMLElement) => {\n checkElement?.(element);\n inputRef.current = element as HTMLInputElement;\n // The popover's \"trigger\" is the input: `showPopover({ source: input })` anchors the\n // listbox to it and makes clicks on it not light-dismiss (design 5.1).\n triggerRef.current = element;\n return () => {\n if (inputRef.current === element) inputRef.current = null;\n if (triggerRef.current === element) triggerRef.current = null;\n };\n },\n [checkElement, inputRef, triggerRef],\n );\n\n // Inside a Field.Root (design/components/field-form.md 7.2) the Input is the Field's control:\n // the Root already took the Field's id for it; `required` and the ARIA wiring land here.\n const field = useFieldControl({\n labelable: true,\n required: rest.required,\n disabled: ctx.disabled,\n id: rest.id,\n component: \"Combobox.Input\",\n });\n const fieldRef = field.ref;\n const mergedRef = useMergedRefs<HTMLElement>(ref, fieldRef);\n\n const searchType = isValidElement<{ type?: unknown }>(render) && render.props.type === \"search\";\n\n const libraryProps: ComponentPropsWithRef<\"input\"> & DataAttributes = {\n ...field.attributes,\n ...(field.inField && { required: field.required }),\n id: ids.input,\n type: searchType ? \"search\" : \"text\",\n role: \"combobox\",\n value: ctx.inputValue,\n autoComplete: \"off\",\n \"aria-autocomplete\": \"list\",\n \"aria-expanded\": popover.optimistic,\n \"aria-controls\": ids.list,\n \"aria-activedescendant\":\n ctx.activeValue === null ? undefined : optionId(ids.optionPrefix, ctx.activeValue),\n disabled: ctx.disabled,\n onChange: (event: ChangeEvent<HTMLInputElement>) => {\n ctx.typed(event.currentTarget.value, event.nativeEvent);\n },\n onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => {\n ctx.keyDown(event.nativeEvent);\n },\n onBlur: (event: FocusEvent<HTMLInputElement>) => {\n ctx.focusOut(event.nativeEvent);\n },\n onClick: (event: MouseEvent<HTMLInputElement>) => {\n ctx.inputClick(event.nativeEvent);\n },\n \"data-open\": dataAttr(popover.optimistic),\n \"data-pending\": dataAttr(state.pending),\n \"data-selected\": dataAttr(ctx.value !== null),\n \"data-stale\": dataAttr(ctx.stale),\n \"data-disabled\": dataAttr(ctx.disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"input\">, ComboboxInputState>({\n defaultElement: \"input\",\n render,\n state,\n className,\n style,\n children: undefined,\n props: rest,\n libraryProps,\n ref: mergedRef,\n });\n}\n\nComboboxInput.displayName = \"ComboboxInput\";\n"],"mappings":";;;;;;;;;AAmBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;AAwDvC,SAAgB,cAAc,EAAE,WAAW,OAAO,QAAQ,GAAG,QAA4B;CACvF,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,EAAE,SAAS,KAAK,aAAa;CACnC,MAAM,EAAE,eAAe;CAEvB,MAAM,QAA4B;EAChC,OAAO,IAAI;EACX,YAAY,IAAI;EAChB,MAAM,QAAQ;EACd,SAAS,IAAI;EACb,OAAO,IAAI;EACX,UAAU,IAAI;CAChB;CAEA,MAAM,eAAe,gBACnB,WACI,YAAY;EACZ,MAAM,OAAO,QAAQ,YAAY,UAAW,QAA6B,OAAO;EAChF,OAAO,SAAS,UAAU,SAAS,WAC/B,6BAA6B,QAAQ,QAAQ,YAAY,IACpD,SAAS,KAAK,KAAK,UAAU,KAAK,GAAG,oIAE1C;CACN,EACJ;CACA,MAAM,MAAM,aACT,YAAyB;EACxB,eAAe,OAAO;EACtB,SAAS,UAAU;EAGnB,WAAW,UAAU;EACrB,aAAa;GACX,IAAI,SAAS,YAAY,SAAS,SAAS,UAAU;GACrD,IAAI,WAAW,YAAY,SAAS,WAAW,UAAU;EAC3D;CACF,GACA;EAAC;EAAc;EAAU;CAAU,CACrC;CAIA,MAAM,QAAQ,gBAAgB;EAC5B,WAAW;EACX,UAAU,KAAK;EACf,UAAU,IAAI;EACd,IAAI,KAAK;EACT,WAAW;CACb,CAAC;CACD,MAAM,WAAW,MAAM;CACvB,MAAM,YAAY,cAA2B,KAAK,QAAQ;CAE1D,MAAM,aAAa,eAAmC,MAAM,KAAK,OAAO,MAAM,SAAS;CAEvF,MAAM,eAAgE;EACpE,GAAG,MAAM;EACT,GAAI,MAAM,WAAW,EAAE,UAAU,MAAM,SAAS;EAChD,IAAI,IAAI;EACR,MAAM,aAAa,WAAW;EAC9B,MAAM;EACN,OAAO,IAAI;EACX,cAAc;EACd,qBAAqB;EACrB,iBAAiB,QAAQ;EACzB,iBAAiB,IAAI;EACrB,yBACE,IAAI,gBAAgB,OAAO,KAAA,IAAY,SAAS,IAAI,cAAc,IAAI,WAAW;EACnF,UAAU,IAAI;EACd,WAAW,UAAyC;GAClD,IAAI,MAAM,MAAM,cAAc,OAAO,MAAM,WAAW;EACxD;EACA,YAAY,UAA2C;GACrD,IAAI,QAAQ,MAAM,WAAW;EAC/B;EACA,SAAS,UAAwC;GAC/C,IAAI,SAAS,MAAM,WAAW;EAChC;EACA,UAAU,UAAwC;GAChD,IAAI,WAAW,MAAM,WAAW;EAClC;EACA,aAAa,SAAS,QAAQ,UAAU;EACxC,gBAAgB,SAAS,MAAM,OAAO;EACtC,iBAAiB,SAAS,IAAI,UAAU,IAAI;EAC5C,cAAc,SAAS,IAAI,KAAK;EAChC,iBAAiB,SAAS,IAAI,QAAQ;CACxC;CAEA,OAAO,UAA8D;EACnE,gBAAgB;EAChB;EACA;EACA;EACA;EACA,UAAU,KAAA;EACV,OAAO;EACP;EACA,KAAK;CACP,CAAC;AACH;AAEA,cAAc,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-list.d.mts","names":[],"sources":["../../src/combobox/combobox-list.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"combobox-list.d.mts","names":[],"sources":["../../src/combobox/combobox-list.tsx"],"mappings":";;;iBAiBiB;;WAEN;;WAEA;;WAEA;;iBAGM,0BAA0B,KACzC;EAGA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;;;;EAK9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;wBAapC,eAAe,WAAW,OAAO,UAAU,WAAW,QAAQ,oBAAiB;yBAA/E"}
|
|
@@ -3,8 +3,9 @@ import { dataAttr } from "../internal/data-attr.mjs";
|
|
|
3
3
|
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
4
4
|
import { resolveStateValue } from "../internal/render-element.mjs";
|
|
5
5
|
import { useRender } from "../internal/use-render.mjs";
|
|
6
|
+
import { useNameWarning } from "../internal/use-name-warning.mjs";
|
|
6
7
|
import { ComboboxListContext, ComboboxPopupContext, useComboboxContext } from "./combobox-context.mjs";
|
|
7
|
-
import { use, useCallback
|
|
8
|
+
import { use, useCallback } from "react";
|
|
8
9
|
import { jsx } from "react/jsx-runtime";
|
|
9
10
|
//#region src/combobox/combobox-list.tsx
|
|
10
11
|
const isDev = process.env.NODE_ENV !== "production";
|
|
@@ -21,21 +22,16 @@ const isDev = process.env.NODE_ENV !== "production";
|
|
|
21
22
|
function ComboboxList({ className, style, children, render, ...rest }) {
|
|
22
23
|
const ctx = useComboboxContext("Combobox.List");
|
|
23
24
|
const inPopup = use(ComboboxPopupContext);
|
|
24
|
-
useDevWarning(!inPopup, "Combobox.List: rendered outside a Combobox.Popup. The listbox must be inside the Popup, which is the element the library shows and hides.");
|
|
25
|
+
useDevWarning(!inPopup, isDev && "Combobox.List: rendered outside a Combobox.Popup. The listbox must be inside the Popup, which is the element the library shows and hides.");
|
|
25
26
|
const { listRef } = ctx;
|
|
26
|
-
const
|
|
27
|
+
const checkName = useNameWarning(isDev && "Combobox.List: the listbox has no accessible name. Render a Combobox.Label, or give the List an `aria-label` / `aria-labelledby`.");
|
|
27
28
|
const ref = useCallback((element) => {
|
|
28
29
|
listRef.current = element;
|
|
29
|
-
|
|
30
|
-
if (warnedName.current || !element.isConnected) return;
|
|
31
|
-
if (element.hasAttribute("aria-labelledby") || element.hasAttribute("aria-label")) return;
|
|
32
|
-
warnedName.current = true;
|
|
33
|
-
console.error("Combobox.List: the listbox has no accessible name. Render a Combobox.Label, or give the List an `aria-label` / `aria-labelledby`.");
|
|
34
|
-
});
|
|
30
|
+
checkName?.(element);
|
|
35
31
|
return () => {
|
|
36
32
|
if (listRef.current === element) listRef.current = null;
|
|
37
33
|
};
|
|
38
|
-
}, [listRef]);
|
|
34
|
+
}, [listRef, checkName]);
|
|
39
35
|
const state = {
|
|
40
36
|
query: ctx.query,
|
|
41
37
|
stale: ctx.stale,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-list.mjs","names":[],"sources":["../../src/combobox/combobox-list.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback
|
|
1
|
+
{"version":3,"file":"combobox-list.mjs","names":[],"sources":["../../src/combobox/combobox-list.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback } 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 { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useNameWarning } from \"../internal/use-name-warning.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport {\n ComboboxListContext,\n ComboboxPopupContext,\n useComboboxContext,\n} from \"./combobox-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ComboboxListState {\n /** The deferred text the results are for: render the Options for it. */\n readonly query: string;\n /** The results shown are for an older text (`aria-busy`). */\n readonly stale: boolean;\n /** No option is mounted and the results are settled. */\n readonly empty: boolean;\n}\n\nexport interface ComboboxListProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"role\" | \"aria-busy\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxListState>;\n style?: StateValue<CSSProperties | undefined, ComboboxListState>;\n /**\n * Usually a function of `{ query }` rendering the Options for it, under your own `<Suspense>`\n * for an async search. The previous results stay visible while the next ones load.\n */\n children?: StateValue<ReactNode, ComboboxListState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxListState>;\n}\n\n/**\n * The listbox: `<div role=\"listbox\" aria-labelledby={label}>` (only while a `Combobox.Label` is\n * mounted), the element the input's `aria-controls` names. Its children are the results for the\n * deferred `query` (the library filters nothing, design 6.1); while they are for an older text it\n * carries `aria-busy=\"true\"` and `data-stale`. Contains only Options and Groups; a `Status`\n * rendered as a Suspense fallback inside it marks the results as loading (`aria-busy=\"true\"`).\n *\n * Owned keys (conventions 1.2): `id`, `role`, `aria-labelledby` (token-merged), `aria-busy`,\n * `data-stale`, `data-empty`.\n */\nexport function ComboboxList({ className, style, children, render, ...rest }: ComboboxListProps) {\n const ctx = useComboboxContext(\"Combobox.List\");\n const inPopup = use(ComboboxPopupContext);\n useDevWarning(\n !inPopup,\n isDev &&\n \"Combobox.List: rendered outside a Combobox.Popup. The listbox must be inside the Popup, \" +\n \"which is the element the library shows and hides.\",\n );\n const { listRef } = ctx;\n // A mounted Label registers in a layout effect whose re-render is flushed before the check's\n // microtask, so `aria-labelledby` is in the DOM by then if it ever will be.\n const checkName = useNameWarning(\n isDev &&\n \"Combobox.List: the listbox has no accessible name. Render a Combobox.Label, or give \" +\n \"the List an `aria-label` / `aria-labelledby`.\",\n );\n\n const ref = useCallback(\n (element: HTMLElement) => {\n listRef.current = element;\n checkName?.(element);\n return () => {\n if (listRef.current === element) listRef.current = null;\n };\n },\n [listRef, checkName],\n );\n\n const state: ComboboxListState = { query: ctx.query, stale: ctx.stale, empty: ctx.empty };\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: ctx.ids.list,\n role: \"listbox\",\n ...(ctx.hasLabel\n ? { \"aria-labelledby\": ctx.ids.label }\n : ctx.fieldLabelId !== undefined && { \"aria-labelledby\": ctx.fieldLabelId }),\n \"aria-busy\": ctx.stale || ctx.loading ? true : undefined,\n \"data-stale\": dataAttr(ctx.stale),\n \"data-empty\": dataAttr(ctx.empty),\n };\n\n return useRender<ComponentPropsWithRef<\"div\">, ComboboxListState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children: (s) => (\n <ComboboxListContext value={true}>{resolveStateValue(children, s)}</ComboboxListContext>\n ),\n props: rest,\n libraryProps,\n ref,\n });\n}\n\nComboboxList.displayName = \"ComboboxList\";\n"],"mappings":";;;;;;;;;;AAeA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;AAmCvC,SAAgB,aAAa,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QAA2B;CAC/F,MAAM,MAAM,mBAAmB,eAAe;CAC9C,MAAM,UAAU,IAAI,oBAAoB;CACxC,cACE,CAAC,SACD,SACE,2IAEJ;CACA,MAAM,EAAE,YAAY;CAGpB,MAAM,YAAY,eAChB,SACE,mIAEJ;CAEA,MAAM,MAAM,aACT,YAAyB;EACxB,QAAQ,UAAU;EAClB,YAAY,OAAO;EACnB,aAAa;GACX,IAAI,QAAQ,YAAY,SAAS,QAAQ,UAAU;EACrD;CACF,GACA,CAAC,SAAS,SAAS,CACrB;CAEA,MAAM,QAA2B;EAAE,OAAO,IAAI;EAAO,OAAO,IAAI;EAAO,OAAO,IAAI;CAAM;CAExF,MAAM,eAA8D;EAClE,IAAI,IAAI,IAAI;EACZ,MAAM;EACN,GAAI,IAAI,WACJ,EAAE,mBAAmB,IAAI,IAAI,MAAM,IACnC,IAAI,iBAAiB,KAAA,KAAa,EAAE,mBAAmB,IAAI,aAAa;EAC5E,aAAa,IAAI,SAAS,IAAI,UAAU,OAAO,KAAA;EAC/C,cAAc,SAAS,IAAI,KAAK;EAChC,cAAc,SAAS,IAAI,KAAK;CAClC;CAEA,OAAO,UAA2D;EAChE,gBAAgB;EAChB;EACA;EACA;EACA;EACA,WAAW,MACT,oBAAC,qBAAD;GAAqB,OAAO;GAAO,UAAA,kBAAkB,UAAU,CAAC;EAAuB,CAAA;EAEzF,OAAO;EACP;EACA;CACF,CAAC;AACH;AAEA,aAAa,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-option.d.mts","names":[],"sources":["../../src/combobox/combobox-option.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"combobox-option.d.mts","names":[],"sources":["../../src/combobox/combobox-option.tsx"],"mappings":";;;iBAkBiB;WACN;;WAEA;;WAEA;;WAEA;WACA;;iBAGM,4BAA4B,KAC3C;;EAcA;;;;;EAKA;;EAEA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;wBAepC,iBACd,OACA,OACA,UACA,WACA,OACA,UACA,WACG,QACF,sBAAmB;yBATN"}
|
|
@@ -5,6 +5,7 @@ import { useRender } from "../internal/use-render.mjs";
|
|
|
5
5
|
import { ComboboxListContext, optionId, useComboboxContext } from "./combobox-context.mjs";
|
|
6
6
|
import { use, useCallback, useLayoutEffect, useRef } from "react";
|
|
7
7
|
//#region src/combobox/combobox-option.tsx
|
|
8
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
8
9
|
const preventDefault = (event) => event.preventDefault();
|
|
9
10
|
/**
|
|
10
11
|
* One result: `<div role="option" id aria-selected>`, never focused (virtual focus through the
|
|
@@ -19,7 +20,7 @@ const preventDefault = (event) => event.preventDefault();
|
|
|
19
20
|
function ComboboxOption({ value, label, disabled = false, className, style, children, render, ...rest }) {
|
|
20
21
|
const ctx = useComboboxContext("Combobox.Option");
|
|
21
22
|
const inList = use(ComboboxListContext);
|
|
22
|
-
useDevWarning(!inList, "Combobox.Option: rendered outside a Combobox.List. Options belong in the listbox.");
|
|
23
|
+
useDevWarning(!inList, isDev && "Combobox.Option: rendered outside a Combobox.List. Options belong in the listbox.");
|
|
23
24
|
const { registerOption } = ctx;
|
|
24
25
|
const elementRef = useRef(null);
|
|
25
26
|
const ref = useCallback((element) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-option.mjs","names":[],"sources":["../../src/combobox/combobox-option.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback, useLayoutEffect, useRef } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\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 { useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { ComboboxListContext, optionId, useComboboxContext } from \"./combobox-context.js\";\n\nexport interface ComboboxOptionState {\n readonly value: string;\n /** Optimistic: this option's value is the (optimistic) selection. */\n readonly selected: boolean;\n /** `aria-activedescendant` points here (urgent). */\n readonly active: boolean;\n /** The selection is pending and this option is its optimistic target. */\n readonly pending: boolean;\n readonly disabled: boolean;\n}\n\nexport interface ComboboxOptionProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"id\"\n | \"role\"\n | \"aria-selected\"\n | \"aria-disabled\"\n | \"onClick\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"onPointerMove\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** The selection this option stands for. Unique within the Combobox; also its id fragment. */\n value: string;\n /**\n * The text written into the input when this option is accepted. Default: the element's\n * trimmed `textContent` at that moment. Not used for matching: the library filters nothing.\n */\n label?: string;\n /** `aria-disabled`: shown, skipped by the arrow keys, never accepted. */\n disabled?: boolean;\n className?: StateValue<string | undefined, ComboboxOptionState>;\n style?: StateValue<CSSProperties | undefined, ComboboxOptionState>;\n /** Rendered from optimistic state; must not suspend. */\n children?: StateValue<ReactNode, ComboboxOptionState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxOptionState>;\n}\n\nconst preventDefault = (event: { preventDefault(): void }) => event.preventDefault();\n\n/**\n * One result: `<div role=\"option\" id aria-selected>`, never focused (virtual focus through the\n * input's `aria-activedescendant`). A click (or Enter while it is active) accepts it: the input\n * text becomes its label at once, it shows `data-selected` and `data-pending`, and the listbox\n * closes when `valueChangeAction` settles. Hovering makes it active.\n *\n * Owned keys (conventions 1.2): `id` (derived from `value`), `role`, `aria-selected`,\n * `aria-disabled`, `onClick`, `onPointerDown`, `onMouseDown`, `onPointerMove`, `data-selected`,\n * `data-active`, `data-pending`, `data-disabled`.\n */\nexport function ComboboxOption({\n value,\n label,\n disabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxOptionProps) {\n const ctx = useComboboxContext(\"Combobox.Option\");\n const inList = use(ComboboxListContext);\n useDevWarning(\n !inList,\n \"Combobox.Option: rendered outside a Combobox.List. Options belong in the listbox.\",\n );\n const { registerOption } = ctx;\n\n const elementRef = useRef<HTMLElement | null>(null);\n const ref = useCallback((element: HTMLElement) => {\n elementRef.current = element;\n return () => {\n if (elementRef.current === element) elementRef.current = null;\n };\n }, []);\n\n // Registration (design 14): the Root's registry drives the arrow keys, `Empty`, the active\n // option's revalidation, the announcements and the label cache.\n useLayoutEffect(() => {\n const element = elementRef.current;\n if (element === null) return;\n return registerOption(value, { element, label, disabled });\n }, [registerOption, value, label, disabled]);\n\n const selected = ctx.value === value;\n const state: ComboboxOptionState = {\n value,\n selected,\n active: ctx.activeValue === value,\n pending: ctx.valuePending && selected,\n disabled,\n };\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: optionId(ctx.ids.optionPrefix, value),\n role: \"option\",\n \"aria-selected\": selected,\n \"aria-disabled\": disabled ? true : undefined,\n onClick: (event: MouseEvent<HTMLDivElement>) => {\n if (disabled) return;\n ctx.accept(value, event.nativeEvent);\n },\n // The input keeps focus (design 7.1), also for an Option rendered outside a Popup.\n onPointerDown: (event: PointerEvent<HTMLDivElement>) => preventDefault(event),\n onMouseDown: (event: MouseEvent<HTMLDivElement>) => preventDefault(event),\n onPointerMove: () => {\n if (!disabled && ctx.activeValue !== value) ctx.setActive(value);\n },\n \"data-selected\": dataAttr(selected),\n \"data-active\": dataAttr(state.active),\n \"data-pending\": dataAttr(state.pending),\n \"data-disabled\": dataAttr(disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"div\">, ComboboxOptionState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref,\n });\n}\n\nComboboxOption.displayName = \"ComboboxOption\";\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"combobox-option.mjs","names":[],"sources":["../../src/combobox/combobox-option.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback, useLayoutEffect, useRef } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\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 { useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { ComboboxListContext, optionId, useComboboxContext } from \"./combobox-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ComboboxOptionState {\n readonly value: string;\n /** Optimistic: this option's value is the (optimistic) selection. */\n readonly selected: boolean;\n /** `aria-activedescendant` points here (urgent). */\n readonly active: boolean;\n /** The selection is pending and this option is its optimistic target. */\n readonly pending: boolean;\n readonly disabled: boolean;\n}\n\nexport interface ComboboxOptionProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"id\"\n | \"role\"\n | \"aria-selected\"\n | \"aria-disabled\"\n | \"onClick\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"onPointerMove\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** The selection this option stands for. Unique within the Combobox; also its id fragment. */\n value: string;\n /**\n * The text written into the input when this option is accepted. Default: the element's\n * trimmed `textContent` at that moment. Not used for matching: the library filters nothing.\n */\n label?: string;\n /** `aria-disabled`: shown, skipped by the arrow keys, never accepted. */\n disabled?: boolean;\n className?: StateValue<string | undefined, ComboboxOptionState>;\n style?: StateValue<CSSProperties | undefined, ComboboxOptionState>;\n /** Rendered from optimistic state; must not suspend. */\n children?: StateValue<ReactNode, ComboboxOptionState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxOptionState>;\n}\n\nconst preventDefault = (event: { preventDefault(): void }) => event.preventDefault();\n\n/**\n * One result: `<div role=\"option\" id aria-selected>`, never focused (virtual focus through the\n * input's `aria-activedescendant`). A click (or Enter while it is active) accepts it: the input\n * text becomes its label at once, it shows `data-selected` and `data-pending`, and the listbox\n * closes when `valueChangeAction` settles. Hovering makes it active.\n *\n * Owned keys (conventions 1.2): `id` (derived from `value`), `role`, `aria-selected`,\n * `aria-disabled`, `onClick`, `onPointerDown`, `onMouseDown`, `onPointerMove`, `data-selected`,\n * `data-active`, `data-pending`, `data-disabled`.\n */\nexport function ComboboxOption({\n value,\n label,\n disabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxOptionProps) {\n const ctx = useComboboxContext(\"Combobox.Option\");\n const inList = use(ComboboxListContext);\n useDevWarning(\n !inList,\n isDev && \"Combobox.Option: rendered outside a Combobox.List. Options belong in the listbox.\",\n );\n const { registerOption } = ctx;\n\n const elementRef = useRef<HTMLElement | null>(null);\n const ref = useCallback((element: HTMLElement) => {\n elementRef.current = element;\n return () => {\n if (elementRef.current === element) elementRef.current = null;\n };\n }, []);\n\n // Registration (design 14): the Root's registry drives the arrow keys, `Empty`, the active\n // option's revalidation, the announcements and the label cache.\n useLayoutEffect(() => {\n const element = elementRef.current;\n if (element === null) return;\n return registerOption(value, { element, label, disabled });\n }, [registerOption, value, label, disabled]);\n\n const selected = ctx.value === value;\n const state: ComboboxOptionState = {\n value,\n selected,\n active: ctx.activeValue === value,\n pending: ctx.valuePending && selected,\n disabled,\n };\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: optionId(ctx.ids.optionPrefix, value),\n role: \"option\",\n \"aria-selected\": selected,\n \"aria-disabled\": disabled ? true : undefined,\n onClick: (event: MouseEvent<HTMLDivElement>) => {\n if (disabled) return;\n ctx.accept(value, event.nativeEvent);\n },\n // The input keeps focus (design 7.1), also for an Option rendered outside a Popup.\n onPointerDown: (event: PointerEvent<HTMLDivElement>) => preventDefault(event),\n onMouseDown: (event: MouseEvent<HTMLDivElement>) => preventDefault(event),\n onPointerMove: () => {\n if (!disabled && ctx.activeValue !== value) ctx.setActive(value);\n },\n \"data-selected\": dataAttr(selected),\n \"data-active\": dataAttr(state.active),\n \"data-pending\": dataAttr(state.pending),\n \"data-disabled\": dataAttr(disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"div\">, ComboboxOptionState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref,\n });\n}\n\nComboboxOption.displayName = \"ComboboxOption\";\n"],"mappings":";;;;;;;AAgBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AA2CvC,MAAM,kBAAkB,UAAsC,MAAM,eAAe;;;;;;;;;;;AAYnF,SAAgB,eAAe,EAC7B,OACA,OACA,WAAW,OACX,WACA,OACA,UACA,QACA,GAAG,QACmB;CACtB,MAAM,MAAM,mBAAmB,iBAAiB;CAChD,MAAM,SAAS,IAAI,mBAAmB;CACtC,cACE,CAAC,QACD,SAAS,mFACX;CACA,MAAM,EAAE,mBAAmB;CAE3B,MAAM,aAAa,OAA2B,IAAI;CAClD,MAAM,MAAM,aAAa,YAAyB;EAChD,WAAW,UAAU;EACrB,aAAa;GACX,IAAI,WAAW,YAAY,SAAS,WAAW,UAAU;EAC3D;CACF,GAAG,CAAC,CAAC;CAIL,sBAAsB;EACpB,MAAM,UAAU,WAAW;EAC3B,IAAI,YAAY,MAAM;EACtB,OAAO,eAAe,OAAO;GAAE;GAAS;GAAO;EAAS,CAAC;CAC3D,GAAG;EAAC;EAAgB;EAAO;EAAO;CAAQ,CAAC;CAE3C,MAAM,WAAW,IAAI,UAAU;CAC/B,MAAM,QAA6B;EACjC;EACA;EACA,QAAQ,IAAI,gBAAgB;EAC5B,SAAS,IAAI,gBAAgB;EAC7B;CACF;CAEA,MAAM,eAA8D;EAClE,IAAI,SAAS,IAAI,IAAI,cAAc,KAAK;EACxC,MAAM;EACN,iBAAiB;EACjB,iBAAiB,WAAW,OAAO,KAAA;EACnC,UAAU,UAAsC;GAC9C,IAAI,UAAU;GACd,IAAI,OAAO,OAAO,MAAM,WAAW;EACrC;EAEA,gBAAgB,UAAwC,eAAe,KAAK;EAC5E,cAAc,UAAsC,eAAe,KAAK;EACxE,qBAAqB;GACnB,IAAI,CAAC,YAAY,IAAI,gBAAgB,OAAO,IAAI,UAAU,KAAK;EACjE;EACA,iBAAiB,SAAS,QAAQ;EAClC,eAAe,SAAS,MAAM,MAAM;EACpC,gBAAgB,SAAS,MAAM,OAAO;EACtC,iBAAiB,SAAS,QAAQ;CACpC;CAEA,OAAO,UAA6D;EAClE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;CACF,CAAC;AACH;AAEA,eAAe,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-popup.d.mts","names":[],"sources":["../../src/combobox/combobox-popup.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"combobox-popup.d.mts","names":[],"sources":["../../src/combobox/combobox-popup.tsx"],"mappings":";;;iBAqBiB;;WAEN;;WAEA;;WAEA;;iBAGM,2BAA2B,KAC1C;;;;;EAeA;;;;;;;;EAQA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;;;wBAiBpC,gBACd,aACA,YACA,WACA,OACA,UACA,WACG,QACF,qBAAkB;yBARL"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { dataAttr } from "../internal/data-attr.mjs";
|
|
3
|
-
import { ToolbarContext } from "../internal/toolbar-context.mjs";
|
|
4
3
|
import { useTransitionBoundary } from "../internal/transition-boundary.mjs";
|
|
5
|
-
import { mergeRefs } from "../internal/merge-props.mjs";
|
|
6
4
|
import { resolveStateValue } from "../internal/render-element.mjs";
|
|
7
5
|
import { useRender } from "../internal/use-render.mjs";
|
|
6
|
+
import { useElementCheck } from "../internal/use-element-check.mjs";
|
|
7
|
+
import { useMergedRefs } from "../internal/use-merged-refs.mjs";
|
|
8
8
|
import { usePopoverPopup } from "../internal/use-popover-popup.mjs";
|
|
9
9
|
import { ComboboxPopupContext, useComboboxContext } from "./combobox-context.mjs";
|
|
10
|
-
import { Activity, useCallback, useMemo } from "react";
|
|
11
10
|
import { jsx } from "react/jsx-runtime";
|
|
12
11
|
//#region src/combobox/combobox-popup.tsx
|
|
13
12
|
const isDev = process.env.NODE_ENV !== "production";
|
|
@@ -27,18 +26,14 @@ const preventDefault = (event) => event.preventDefault();
|
|
|
27
26
|
function ComboboxPopup({ keepMounted, transition, className, style, children, render, ...rest }) {
|
|
28
27
|
const ctx = useComboboxContext("Combobox.Popup");
|
|
29
28
|
const { popover } = ctx;
|
|
30
|
-
const { setElement,
|
|
29
|
+
const { setElement, renderContent } = usePopoverPopup(popover, {
|
|
31
30
|
part: "Combobox.Popup",
|
|
32
|
-
initialFocus: void 0,
|
|
33
31
|
resolveInitialFocus: () => null,
|
|
34
32
|
keepMounted,
|
|
35
33
|
transition
|
|
36
34
|
});
|
|
37
|
-
const devRef =
|
|
38
|
-
|
|
39
|
-
return () => {};
|
|
40
|
-
}, []);
|
|
41
|
-
const ref = useMemo(() => mergeRefs(setElement, devRef), [setElement, devRef]);
|
|
35
|
+
const devRef = useElementCheck(isDev && ((element) => element.tagName !== "DIV" ? `Combobox.Popup: rendered a <${element.tagName.toLowerCase()}>. Render a <div>: a <dialog popover> runs the dialog focusing steps and takes focus out of the input.` : null));
|
|
36
|
+
const ref = useMergedRefs(setElement, devRef);
|
|
42
37
|
const state = {
|
|
43
38
|
open: popover.committed,
|
|
44
39
|
stale: ctx.stale,
|
|
@@ -51,21 +46,10 @@ function ComboboxPopup({ keepMounted, transition, className, style, children, re
|
|
|
51
46
|
onMouseDown: (event) => preventDefault(event),
|
|
52
47
|
"data-stale": dataAttr(ctx.stale)
|
|
53
48
|
};
|
|
54
|
-
const content = (s) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
children: wrapContent(resolveStateValue(children, s))
|
|
59
|
-
});
|
|
60
|
-
else node = visible ? wrapContent(resolveStateValue(children, s)) : null;
|
|
61
|
-
return /* @__PURE__ */ jsx(ComboboxPopupContext, {
|
|
62
|
-
value: true,
|
|
63
|
-
children: /* @__PURE__ */ jsx(ToolbarContext, {
|
|
64
|
-
value: null,
|
|
65
|
-
children: node
|
|
66
|
-
})
|
|
67
|
-
});
|
|
68
|
-
};
|
|
49
|
+
const content = (s) => /* @__PURE__ */ jsx(ComboboxPopupContext, {
|
|
50
|
+
value: true,
|
|
51
|
+
children: renderContent(() => resolveStateValue(children, s))
|
|
52
|
+
});
|
|
69
53
|
const element = useRender({
|
|
70
54
|
defaultElement: "div",
|
|
71
55
|
render,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-popup.mjs","names":[],"sources":["../../src/combobox/combobox-popup.tsx"],"sourcesContent":["\"use client\";\nimport
|
|
1
|
+
{"version":3,"file":"combobox-popup.mjs","names":[],"sources":["../../src/combobox/combobox-popup.tsx"],"sourcesContent":["\"use client\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { usePopoverPopup } from \"../internal/use-popover-popup.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { ComboboxPopupContext, useComboboxContext } from \"./combobox-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ComboboxPopupState {\n /** Committed open state. Read `:popover-open` for the DOM truth. */\n readonly open: boolean;\n /** The results shown are for an older text. */\n readonly stale: boolean;\n /** The deferred text the results are for. */\n readonly query: string;\n}\n\nexport interface ComboboxPopupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"id\"\n | \"popover\"\n | \"onToggle\"\n | \"onBeforeToggle\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * `false` (default): the children are not rendered while the listbox is closed. `true`: they\n * stay mounted inside `<Activity mode=\"hidden\">`.\n */\n keepMounted?: boolean;\n /**\n * Forwarded to the `<ViewTransition default>` around the popover element itself. Animates\n * library-driven opens and closes (typing, the Trigger, an accepted option) in every engine;\n * dismissals are the browser's (CSS only). **A deferred results render also activates the\n * boundary** (React: updates from `useDeferredValue` animate), so use a type map with\n * `default: \"none\"` unless every result change should cross-fade. Static.\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, ComboboxPopupState>;\n style?: StateValue<CSSProperties | undefined, ComboboxPopupState>;\n children?: StateValue<ReactNode, ComboboxPopupState>;\n /** Must render a `<div>`: a `<dialog>` would pull focus out of the input. */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxPopupState>;\n}\n\nconst preventDefault = (event: { preventDefault(): void }) => event.preventDefault();\n\n/**\n * The listbox's container: `<div popover=\"auto\">`, opened by the library with\n * `showPopover({ source: input })` and placed below (or, flipped, above) the input with CSS\n * Anchor Positioning, at least as wide as the input. Focus never enters it: a press anywhere in\n * it is `preventDefault()`ed so the input keeps focus (design 7.1). Holds the `List` and, outside\n * it, `Empty` and `Status`. Style it with `:popover-open`; it emits `data-stale` but no\n * `data-open`.\n *\n * Owned keys (conventions 1.2): `id`, `popover`, `onPointerDown`, `onMouseDown`, `data-stale`.\n * Inline `position-area`, `position-try-fallbacks` and `min-width` sit under the consumer's\n * `style` (`style={{ positionTryFallbacks: \"none\" }}` removes the flip).\n */\nexport function ComboboxPopup({\n keepMounted,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxPopupProps) {\n const ctx = useComboboxContext(\"Combobox.Popup\");\n const { popover } = ctx;\n\n const { setElement, renderContent } = usePopoverPopup(popover, {\n part: \"Combobox.Popup\",\n // Focus stays in the input: nothing inside the popup is ever focused.\n resolveInitialFocus: () => null,\n keepMounted,\n transition,\n });\n\n const devRef = useElementCheck(\n isDev &&\n ((element) =>\n element.tagName !== \"DIV\"\n ? `Combobox.Popup: rendered a <${element.tagName.toLowerCase()}>. Render a <div>: a ` +\n \"<dialog popover> runs the dialog focusing steps and takes focus out of the input.\"\n : null),\n );\n const ref = useMergedRefs(setElement, devRef);\n\n const state: ComboboxPopupState = {\n open: popover.committed,\n stale: ctx.stale,\n query: ctx.query,\n };\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: popover.ids.popup,\n popover: \"auto\",\n onPointerDown: (event: PointerEvent<HTMLDivElement>) => preventDefault(event),\n onMouseDown: (event: MouseEvent<HTMLDivElement>) => preventDefault(event),\n \"data-stale\": dataAttr(ctx.stale),\n };\n\n const content = (s: ComboboxPopupState): ReactNode => (\n <ComboboxPopupContext value={true}>\n {renderContent(() => resolveStateValue(children, s))}\n </ComboboxPopupContext>\n );\n\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxPopupState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // `self-*` keywords resolve against the popup's own inherited direction, so a `dir=\"rtl\"`\n // page or container flips the listbox with no JS; plain logical keywords would follow the\n // root only (design 7.2, conventions 13.1). The consumer wins.\n style: (s) => ({\n positionArea: \"self-block-end span-self-inline-end\",\n positionTryFallbacks: \"flip-block\",\n minWidth: \"anchor-size(width)\",\n ...resolveStateValue(style, s),\n }),\n children: content,\n props: rest,\n libraryProps,\n ref,\n });\n\n return useTransitionBoundary(\"Combobox.Popup\", transition, element);\n}\n\nComboboxPopup.displayName = \"ComboboxPopup\";\n"],"mappings":";;;;;;;;;;;AAmBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AA2CvC,MAAM,kBAAkB,UAAsC,MAAM,eAAe;;;;;;;;;;;;;AAcnF,SAAgB,cAAc,EAC5B,aACA,YACA,WACA,OACA,UACA,QACA,GAAG,QACkB;CACrB,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,YAAY,kBAAkB,gBAAgB,SAAS;EAC7D,MAAM;EAEN,2BAA2B;EAC3B;EACA;CACF,CAAC;CAED,MAAM,SAAS,gBACb,WACI,YACA,QAAQ,YAAY,QAChB,+BAA+B,QAAQ,QAAQ,YAAY,EAAE,0GAE7D,KACV;CACA,MAAM,MAAM,cAAc,YAAY,MAAM;CAE5C,MAAM,QAA4B;EAChC,MAAM,QAAQ;EACd,OAAO,IAAI;EACX,OAAO,IAAI;CACb;CAEA,MAAM,eAA8D;EAClE,IAAI,QAAQ,IAAI;EAChB,SAAS;EACT,gBAAgB,UAAwC,eAAe,KAAK;EAC5E,cAAc,UAAsC,eAAe,KAAK;EACxE,cAAc,SAAS,IAAI,KAAK;CAClC;CAEA,MAAM,WAAW,MACf,oBAAC,sBAAD;EAAsB,OAAO;EAC1B,UAAA,oBAAoB,kBAAkB,UAAU,CAAC,CAAC;CAC/B,CAAA;CAGxB,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA;EACA;EAIA,QAAQ,OAAO;GACb,cAAc;GACd,sBAAsB;GACtB,UAAU;GACV,GAAG,kBAAkB,OAAO,CAAC;EAC/B;EACA,UAAU;EACV,OAAO;EACP;EACA;CACF,CAAC;CAED,OAAO,sBAAsB,kBAAkB,YAAY,OAAO;AACpE;AAEA,cAAc,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-root.d.mts","names":[],"sources":["../../src/combobox/combobox-root.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"combobox-root.d.mts","names":[],"sources":["../../src/combobox/combobox-root.tsx"],"mappings":";;;;iBAuCiB,mCAAmC;;;;;;;WAOzC,QAAQ;;WAER;;;iBAIM,wCAAwC;;;;;;;WAO9C,QAAQ;;;iBAIF,kCAAkC;;;;;;;WAOxC,QAAQ;;iBAGF;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;;iBAGM;;EAEf;;EAEA;;;;;;;;EAQA,oBAAoB,4BAA4B;;EAGhD;;;;;EAKA;;;;;;;;;EASA,qBAAqB,4BAA4B;;EAGjD;;EAEA;;;;;EAKA,mBAAmB,sBAAsB;;;;;;;EAQzC;;;;;EAKA;;EAEA;;EAEA;;;;;;;EAOA,YAAY,eAAe,OAAO;;EAGlC;;EAEA;;EAEA;EACA,WAAW,WAAW,WAAW;;;;;;;;;;;wBAkDnB,aAAa,OAAO,oCAAiB,IAAA;yBAArC"}
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
import { createActionDetails } from "../internal/action-details.mjs";
|
|
3
3
|
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
4
4
|
import { resolveStateValue } from "../internal/render-element.mjs";
|
|
5
|
+
import { transitionTypes } from "../internal/transition-types.mjs";
|
|
6
|
+
import { useLatest } from "../internal/use-latest.mjs";
|
|
5
7
|
import { useControllableAction } from "../internal/use-controllable-action.mjs";
|
|
8
|
+
import { isPopoverOpen } from "../internal/popover-open.mjs";
|
|
6
9
|
import { FieldContext } from "../internal/field-context.mjs";
|
|
7
10
|
import { useFieldValueChange } from "../internal/use-field-control.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { usePopoverRoot } from "../internal/use-popover-root.mjs";
|
|
11
|
+
import { popoverDetails, useOverlayRoot } from "../internal/use-overlay-root.mjs";
|
|
10
12
|
import { ComboboxContext } from "./combobox-context.mjs";
|
|
13
|
+
import { useComboboxForm } from "./use-combobox-form.mjs";
|
|
14
|
+
import { useOptionRegistry } from "./use-option-registry.mjs";
|
|
11
15
|
import { use, useCallback, useDeferredValue, useEffect, useId, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
12
16
|
import { flushSync } from "react-dom";
|
|
13
17
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -18,16 +22,8 @@ function defaultComboboxAnnouncement(count) {
|
|
|
18
22
|
if (count === 1) return "1 result";
|
|
19
23
|
return `${count} results`;
|
|
20
24
|
}
|
|
21
|
-
const VALUE_TRANSITION_TYPES =
|
|
25
|
+
const VALUE_TRANSITION_TYPES = transitionTypes("combobox", "select");
|
|
22
26
|
const isDev = process.env.NODE_ENV !== "production";
|
|
23
|
-
function isPopoverOpen(element) {
|
|
24
|
-
if (element === null) return false;
|
|
25
|
-
try {
|
|
26
|
-
return element.matches(":popover-open");
|
|
27
|
-
} catch {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
27
|
function isThenable(value) {
|
|
32
28
|
return typeof value === "object" && value !== null && typeof value.then === "function";
|
|
33
29
|
}
|
|
@@ -53,20 +49,17 @@ function ComboboxRoot(props) {
|
|
|
53
49
|
list: `${id}-list`,
|
|
54
50
|
optionPrefix: `${id}-option-`
|
|
55
51
|
}), [id, fieldControlId]);
|
|
56
|
-
const popover =
|
|
52
|
+
const popover = useOverlayRoot({
|
|
57
53
|
component: "combobox",
|
|
58
54
|
part: "Combobox.Root",
|
|
59
55
|
mode: "library",
|
|
60
56
|
open,
|
|
61
57
|
defaultOpen,
|
|
62
|
-
openChangeAction
|
|
63
|
-
|
|
64
|
-
const propsRef = useRef(props);
|
|
65
|
-
const popoverRef = useRef(popover);
|
|
66
|
-
useInsertionEffect(() => {
|
|
67
|
-
propsRef.current = props;
|
|
68
|
-
popoverRef.current = popover;
|
|
58
|
+
openChangeAction,
|
|
59
|
+
details: popoverDetails
|
|
69
60
|
});
|
|
61
|
+
const propsRef = useLatest(props);
|
|
62
|
+
const popoverRef = useLatest(popover);
|
|
70
63
|
const inputRef = useRef(null);
|
|
71
64
|
const listRef = useRef(null);
|
|
72
65
|
const hiddenRef = useRef(null);
|
|
@@ -91,7 +84,7 @@ function ComboboxRoot(props) {
|
|
|
91
84
|
warnedThenable.current = true;
|
|
92
85
|
console.error("Combobox.Root: `onInputValueChange` returned a promise. It is the urgent lane: it is not awaited. Fetch in a transition instead (`valueChangeAction`, or `useDeferredValue` of `inputValue`).");
|
|
93
86
|
}
|
|
94
|
-
}, []);
|
|
87
|
+
}, [propsRef]);
|
|
95
88
|
const [labels] = useState(() => {
|
|
96
89
|
const map = /* @__PURE__ */ new Map();
|
|
97
90
|
const initialValue = value !== void 0 ? value : defaultValue ?? null;
|
|
@@ -102,7 +95,6 @@ function ComboboxRoot(props) {
|
|
|
102
95
|
const dispatchSeq = useRef(0);
|
|
103
96
|
const [dispatchMeta] = useState(() => /* @__PURE__ */ new WeakMap());
|
|
104
97
|
const textRecord = useRef(null);
|
|
105
|
-
const committedRef = useRef(null);
|
|
106
98
|
const runValueAction = async (next, details) => {
|
|
107
99
|
const meta = dispatchMeta.get(details);
|
|
108
100
|
try {
|
|
@@ -132,9 +124,7 @@ function ComboboxRoot(props) {
|
|
|
132
124
|
prop: "value"
|
|
133
125
|
}
|
|
134
126
|
});
|
|
135
|
-
|
|
136
|
-
committedRef.current = selection.committed;
|
|
137
|
-
});
|
|
127
|
+
const committedRef = useLatest(selection.committed);
|
|
138
128
|
/** The next change of the optimistic selection comes from the user (a dispatch). */
|
|
139
129
|
const userEdit = useRef(false);
|
|
140
130
|
const dispatchValue = (next, event, fields, options) => {
|
|
@@ -160,38 +150,7 @@ function ComboboxRoot(props) {
|
|
|
160
150
|
userEdit.current = false;
|
|
161
151
|
return edit;
|
|
162
152
|
});
|
|
163
|
-
const
|
|
164
|
-
const [optionCount, setOptionCount] = useState(0);
|
|
165
|
-
const [statusCount, setStatusCount] = useState(0);
|
|
166
|
-
const statusCountRef = useRef(0);
|
|
167
|
-
const [labelCount, setLabelCount] = useState(0);
|
|
168
|
-
const warnedDuplicate = useRef(false);
|
|
169
|
-
const registerOption = useCallback((optionValue, entry) => {
|
|
170
|
-
const existing = registry.get(optionValue);
|
|
171
|
-
if (isDev && !warnedDuplicate.current && existing !== void 0 && existing.element !== entry.element && existing.element.isConnected) {
|
|
172
|
-
warnedDuplicate.current = true;
|
|
173
|
-
console.error(`Combobox.Option: two options have the value ${JSON.stringify(optionValue)}. Option ids are derived from the value, so they must be unique within one Combobox.`);
|
|
174
|
-
}
|
|
175
|
-
registry.set(optionValue, entry);
|
|
176
|
-
labels.set(optionValue, entry.label ?? (entry.element.textContent ?? "").trim());
|
|
177
|
-
setOptionCount(registry.size);
|
|
178
|
-
return () => {
|
|
179
|
-
if (registry.get(optionValue) === entry) registry.delete(optionValue);
|
|
180
|
-
setOptionCount(registry.size);
|
|
181
|
-
};
|
|
182
|
-
}, [registry, labels]);
|
|
183
|
-
const registerStatus = useCallback(() => {
|
|
184
|
-
statusCountRef.current += 1;
|
|
185
|
-
setStatusCount((count) => count + 1);
|
|
186
|
-
return () => {
|
|
187
|
-
statusCountRef.current -= 1;
|
|
188
|
-
setStatusCount((count) => count - 1);
|
|
189
|
-
};
|
|
190
|
-
}, []);
|
|
191
|
-
const registerLabel = useCallback(() => {
|
|
192
|
-
setLabelCount((count) => count + 1);
|
|
193
|
-
return () => setLabelCount((count) => count - 1);
|
|
194
|
-
}, []);
|
|
153
|
+
const { registry, optionCount, statusCount, statusCountRef, labelCount, registerOption, registerStatus, registerLabel, orderedOptions } = useOptionRegistry(labels);
|
|
195
154
|
const [activeValue, setActiveValue] = useState(null);
|
|
196
155
|
const activeRef = useRef(null);
|
|
197
156
|
const setActive = useCallback((next) => {
|
|
@@ -200,15 +159,6 @@ function ComboboxRoot(props) {
|
|
|
200
159
|
}, []);
|
|
201
160
|
const pendingEdge = useRef(null);
|
|
202
161
|
const autoArmed = useRef(true);
|
|
203
|
-
const orderedOptions = useCallback(() => {
|
|
204
|
-
const options = [];
|
|
205
|
-
for (const [optionValue, entry] of registry) options.push({
|
|
206
|
-
value: optionValue,
|
|
207
|
-
...entry
|
|
208
|
-
});
|
|
209
|
-
options.sort((a, b) => a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
210
|
-
return options;
|
|
211
|
-
}, [registry]);
|
|
212
162
|
const loading = statusCount > 0;
|
|
213
163
|
const empty = optionCount === 0 && !stale && !loading;
|
|
214
164
|
useLayoutEffect(() => {
|
|
@@ -271,45 +221,26 @@ function ComboboxRoot(props) {
|
|
|
271
221
|
const message = (propsRef.current.announce ?? defaultComboboxAnnouncement)(count, state);
|
|
272
222
|
if (message !== null) list.ariaNotify(message);
|
|
273
223
|
});
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return hiddenRef.current ?? inputRef.current;
|
|
286
|
-
},
|
|
287
|
-
set current(_ignored) {}
|
|
288
|
-
}), []);
|
|
289
|
-
useFormReset(formElement, (event) => {
|
|
290
|
-
const domText = inputRef.current?.value ?? inputDefaultValue;
|
|
291
|
-
if (domText !== textRef.current) writeText(domText, "platform", event);
|
|
292
|
-
setResync((n) => n + 1);
|
|
293
|
-
if (valueResetTarget !== selection.optimistic) dispatchValue(valueResetTarget, event, {
|
|
224
|
+
useComboboxForm({
|
|
225
|
+
value,
|
|
226
|
+
defaultValue,
|
|
227
|
+
inputValue: inputValueProp,
|
|
228
|
+
defaultInputValue,
|
|
229
|
+
inputRef,
|
|
230
|
+
hiddenRef,
|
|
231
|
+
textRef,
|
|
232
|
+
writeText,
|
|
233
|
+
optimistic: selection.optimistic,
|
|
234
|
+
resetValue: (next, event) => dispatchValue(next, event, {
|
|
294
235
|
reason: "platform",
|
|
295
236
|
custom: false
|
|
296
237
|
}, {
|
|
297
238
|
close: false,
|
|
298
239
|
text: void 0
|
|
299
|
-
})
|
|
300
|
-
}, () => {
|
|
301
|
-
const input = inputRef.current;
|
|
302
|
-
if (input !== null && input.defaultValue !== inputDefaultValue) input.defaultValue = inputDefaultValue;
|
|
240
|
+
})
|
|
303
241
|
});
|
|
304
|
-
const reconciled = useRef(false);
|
|
305
|
-
useLayoutEffect(() => {
|
|
306
|
-
if (reconciled.current) return;
|
|
307
|
-
reconciled.current = true;
|
|
308
|
-
const input = inputRef.current;
|
|
309
|
-
if (input !== null && input.value !== textRef.current) writeText(input.value, "platform", void 0);
|
|
310
|
-
}, [writeText]);
|
|
311
242
|
const [missingText] = useState(() => (value ?? defaultValue ?? null) !== null && inputValueProp === void 0 && defaultInputValue === void 0);
|
|
312
|
-
useDevWarning(missingText, "Combobox.Root: `value` / `defaultValue` is set but neither `inputValue` nor `defaultInputValue` is: the input will show no text for the selection. The library never derives the text from the value; pass the selected option's label as well.");
|
|
243
|
+
useDevWarning(missingText, isDev && "Combobox.Root: `value` / `defaultValue` is set but neither `inputValue` nor `defaultInputValue` is: the input will show no text for the selection. The library never derives the text from the value; pass the selected option's label as well.");
|
|
313
244
|
const accept = (optionValue, event) => {
|
|
314
245
|
if (disabled) return;
|
|
315
246
|
const entry = registry.get(optionValue);
|
|
@@ -451,10 +382,7 @@ function ComboboxRoot(props) {
|
|
|
451
382
|
const label = labelFor(selection.optimistic);
|
|
452
383
|
if (textRef.current !== label) writeText(label, "dismiss", event);
|
|
453
384
|
};
|
|
454
|
-
const leaveRef =
|
|
455
|
-
useInsertionEffect(() => {
|
|
456
|
-
leaveRef.current = leave;
|
|
457
|
-
});
|
|
385
|
+
const leaveRef = useLatest(leave);
|
|
458
386
|
const focusOut = (event) => {
|
|
459
387
|
const input = inputRef.current;
|
|
460
388
|
const popup = popover.popupRef.current;
|
|
@@ -518,6 +446,6 @@ function ComboboxRoot(props) {
|
|
|
518
446
|
}
|
|
519
447
|
ComboboxRoot.displayName = "ComboboxRoot";
|
|
520
448
|
//#endregion
|
|
521
|
-
export { ComboboxRoot
|
|
449
|
+
export { ComboboxRoot };
|
|
522
450
|
|
|
523
451
|
//# sourceMappingURL=combobox-root.mjs.map
|