@funstack/ui 0.1.0-alpha.10 → 0.1.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion/accordion-context.mjs.map +1 -1
- package/dist/accordion/accordion-item.d.mts +3 -4
- package/dist/accordion/accordion-item.d.mts.map +1 -1
- package/dist/accordion/accordion-item.mjs +10 -4
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.d.mts +3 -4
- package/dist/accordion/accordion-panel.d.mts.map +1 -1
- package/dist/accordion/accordion-panel.mjs +2 -1
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts +3 -3
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +8 -19
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts +3 -4
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +5 -3
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/button/button.d.mts +4 -2
- package/dist/button/button.d.mts.map +1 -1
- package/dist/button/button.mjs +3 -2
- package/dist/button/button.mjs.map +1 -1
- package/dist/checkbox/checkbox.d.mts +4 -5
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +16 -59
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +3 -4
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +21 -27
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.mjs +1 -6
- package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts +3 -4
- package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +12 -10
- package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +74 -101
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +5 -6
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-context.mjs.map +1 -1
- package/dist/combobox/combobox-group.d.mts.map +1 -1
- package/dist/combobox/combobox-group.mjs +2 -1
- package/dist/combobox/combobox-group.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +14 -7
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-list.d.mts.map +1 -1
- package/dist/combobox/combobox-list.mjs +6 -10
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +2 -1
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +9 -25
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts +11 -10
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +37 -109
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +6 -25
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.d.mts +2 -2
- package/dist/combobox/index.mjs +3 -3
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/combobox/use-combobox-form.mjs +56 -0
- package/dist/combobox/use-combobox-form.mjs.map +1 -0
- package/dist/combobox/use-option-registry.mjs +62 -0
- package/dist/combobox/use-option-registry.mjs.map +1 -0
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +29 -62
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +5 -4
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +3 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +37 -98
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +30 -118
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +13 -16
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/field/field-control.mjs +6 -13
- package/dist/field/field-control.mjs.map +1 -1
- package/dist/field/field-description.d.mts.map +1 -1
- package/dist/field/field-description.mjs +1 -2
- package/dist/field/field-description.mjs.map +1 -1
- package/dist/field/field-error.d.mts.map +1 -1
- package/dist/field/field-error.mjs +1 -2
- package/dist/field/field-error.mjs.map +1 -1
- package/dist/field/field-label.d.mts.map +1 -1
- package/dist/field/field-label.mjs +3 -11
- package/dist/field/field-label.mjs.map +1 -1
- package/dist/field/field-root.mjs +21 -41
- package/dist/field/field-root.mjs.map +1 -1
- package/dist/field/index.mjs +1 -1
- package/dist/field/use-server-error-visibility.mjs +44 -0
- package/dist/field/use-server-error-visibility.mjs.map +1 -0
- package/dist/form/form-root.d.mts.map +1 -1
- package/dist/form/form-root.mjs +6 -7
- package/dist/form/form-root.mjs.map +1 -1
- package/dist/form/form-submit.d.mts +1 -1
- package/dist/form/form-submit.mjs +4 -10
- package/dist/form/form-submit.mjs.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/internal/anchor-position.mjs +1 -59
- package/dist/internal/anchor-position.mjs.map +1 -1
- package/dist/internal/announce.mjs.map +1 -1
- package/dist/internal/arrow-keys.mjs +21 -0
- package/dist/internal/arrow-keys.mjs.map +1 -0
- package/dist/internal/decimal.mjs +7 -1
- package/dist/internal/decimal.mjs.map +1 -1
- package/dist/internal/dom-order.mjs +17 -0
- package/dist/internal/dom-order.mjs.map +1 -0
- package/dist/internal/field-context.d.mts.map +1 -1
- package/dist/internal/field-context.mjs +11 -1
- package/dist/internal/field-context.mjs.map +1 -1
- package/dist/internal/focus-first-invalid.mjs +1 -1
- package/dist/internal/focus-first-invalid.mjs.map +1 -1
- package/dist/internal/group-member.mjs +37 -0
- package/dist/internal/group-member.mjs.map +1 -0
- package/dist/internal/overlay-popup.mjs +103 -0
- package/dist/internal/overlay-popup.mjs.map +1 -0
- package/dist/internal/popover-open.mjs +18 -0
- package/dist/internal/popover-open.mjs.map +1 -0
- package/dist/internal/render-element.d.mts +2 -0
- package/dist/internal/render-element.mjs +20 -2
- package/dist/internal/render-element.mjs.map +1 -1
- package/dist/internal/shipped-styles.mjs +14 -0
- package/dist/internal/shipped-styles.mjs.map +1 -0
- package/dist/internal/sync-presence.mjs +5 -1
- package/dist/internal/sync-presence.mjs.map +1 -1
- package/dist/internal/toolbar-context.mjs.map +1 -1
- package/dist/internal/tooltip-warm.mjs +1 -1
- package/dist/internal/tooltip-warm.mjs.map +1 -1
- package/dist/internal/transition-boundary.mjs +1 -1
- package/dist/internal/transition-boundary.mjs.map +1 -1
- package/dist/internal/types.d.mts +8 -6
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-action-trigger.mjs +5 -23
- package/dist/internal/use-action-trigger.mjs.map +1 -1
- package/dist/internal/use-checkable-input.mjs +79 -0
- package/dist/internal/use-checkable-input.mjs.map +1 -0
- package/dist/internal/use-controllable-action.mjs +16 -24
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-dev-warning.mjs +8 -4
- package/dist/internal/use-dev-warning.mjs.map +1 -1
- package/dist/internal/use-element-check.mjs +39 -0
- package/dist/internal/use-element-check.mjs.map +1 -0
- package/dist/internal/use-exit-animation.mjs +1 -1
- package/dist/internal/use-exit-animation.mjs.map +1 -1
- package/dist/internal/use-field-control.mjs +28 -12
- package/dist/internal/use-field-control.mjs.map +1 -1
- package/dist/internal/use-fieldset-group.mjs +46 -0
- package/dist/internal/use-fieldset-group.mjs.map +1 -0
- package/dist/internal/use-form-reset.mjs +1 -5
- package/dist/internal/use-form-reset.mjs.map +1 -1
- package/dist/internal/use-item-order.mjs +42 -0
- package/dist/internal/use-item-order.mjs.map +1 -0
- package/dist/internal/use-latest.mjs +4 -8
- package/dist/internal/use-latest.mjs.map +1 -1
- package/dist/internal/use-merged-refs.mjs +19 -0
- package/dist/internal/use-merged-refs.mjs.map +1 -0
- package/dist/internal/use-name-warning.mjs +84 -0
- package/dist/internal/use-name-warning.mjs.map +1 -0
- package/dist/internal/use-native-checked.mjs +4 -6
- package/dist/internal/use-native-checked.mjs.map +1 -1
- package/dist/internal/use-native-focusgroup.mjs +19 -0
- package/dist/internal/use-native-focusgroup.mjs.map +1 -0
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-overlay-close.mjs +63 -0
- package/dist/internal/use-overlay-close.mjs.map +1 -0
- package/dist/internal/{use-popover-root.mjs → use-overlay-root.mjs} +28 -39
- package/dist/internal/use-overlay-root.mjs.map +1 -0
- package/dist/internal/use-popover-popup.mjs +32 -78
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.d.mts +15 -0
- package/dist/internal/use-popover-trigger.d.mts.map +1 -0
- package/dist/internal/use-popover-trigger.mjs +13 -17
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/use-register-count.mjs +24 -0
- package/dist/internal/use-register-count.mjs.map +1 -0
- package/dist/internal/use-render.d.mts +2 -0
- package/dist/internal/use-render.mjs +2 -2
- package/dist/internal/use-render.mjs.map +1 -1
- package/dist/internal/use-resolved-placement.mjs +38 -22
- package/dist/internal/use-resolved-placement.mjs.map +1 -1
- package/dist/internal/use-roving-focus.mjs +5 -18
- package/dist/internal/use-roving-focus.mjs.map +1 -1
- package/dist/internal/use-superseded-rejection.mjs +47 -0
- package/dist/internal/use-superseded-rejection.mjs.map +1 -0
- package/dist/internal/validity.mjs +1 -13
- package/dist/internal/validity.mjs.map +1 -1
- package/dist/internal/value-set.mjs +41 -0
- package/dist/internal/value-set.mjs.map +1 -0
- package/dist/menu/index.d.mts +1 -1
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +2 -7
- package/dist/menu/menu-context-trigger.d.mts.map +1 -1
- package/dist/menu/menu-context-trigger.mjs +10 -187
- package/dist/menu/menu-context-trigger.mjs.map +1 -1
- package/dist/menu/menu-context.d.mts +1 -1
- package/dist/menu/menu-context.mjs +1 -1
- package/dist/menu/menu-context.mjs.map +1 -1
- package/dist/menu/menu-dom.mjs +1 -2
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-gestures.mjs +167 -0
- package/dist/menu/menu-gestures.mjs.map +1 -0
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +2 -1
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-hover.mjs +0 -1
- package/dist/menu/menu-hover.mjs.map +1 -1
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-outside.mjs +101 -0
- package/dist/menu/menu-outside.mjs.map +1 -0
- package/dist/menu/menu-point.mjs +85 -0
- package/dist/menu/menu-point.mjs.map +1 -0
- package/dist/menu/menu-popup.d.mts +6 -7
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +37 -248
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +10 -0
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +10 -8
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +6 -6
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +4 -9
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +8 -6
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/menu/use-menu-item.mjs +14 -16
- package/dist/menu/use-menu-item.mjs.map +1 -1
- package/dist/menu/use-menu-keyboard.mjs +88 -0
- package/dist/menu/use-menu-keyboard.mjs.map +1 -0
- package/dist/meter/meter-root.mjs +1 -1
- package/dist/number-field/index.d.mts +2 -1
- package/dist/number-field/index.d.mts.map +1 -1
- package/dist/number-field/index.mjs +2 -2
- package/dist/number-field/index.mjs.map +1 -1
- package/dist/number-field/number-field-arithmetic.mjs +30 -11
- package/dist/number-field/number-field-arithmetic.mjs.map +1 -1
- package/dist/number-field/number-field-context.d.mts +6 -1
- package/dist/number-field/number-field-context.d.mts.map +1 -0
- package/dist/number-field/number-field-context.mjs.map +1 -1
- package/dist/number-field/number-field-decrement.d.mts +1 -1
- package/dist/number-field/number-field-decrement.mjs +1 -1
- package/dist/number-field/number-field-decrement.mjs.map +1 -1
- package/dist/number-field/number-field-increment.d.mts +2 -22
- package/dist/number-field/number-field-increment.d.mts.map +1 -1
- package/dist/number-field/number-field-increment.mjs +2 -53
- package/dist/number-field/number-field-increment.mjs.map +1 -1
- package/dist/number-field/number-field-input.d.mts.map +1 -1
- package/dist/number-field/number-field-input.mjs +18 -22
- package/dist/number-field/number-field-input.mjs.map +1 -1
- package/dist/number-field/number-field-label.d.mts.map +1 -1
- package/dist/number-field/number-field-label.mjs +3 -9
- package/dist/number-field/number-field-label.mjs.map +1 -1
- package/dist/number-field/number-field-root.d.mts +2 -1
- package/dist/number-field/number-field-root.d.mts.map +1 -1
- package/dist/number-field/number-field-root.mjs +81 -91
- package/dist/number-field/number-field-root.mjs.map +1 -1
- package/dist/number-field/use-number-field-dev-warnings.mjs +28 -0
- package/dist/number-field/use-number-field-dev-warnings.mjs.map +1 -0
- package/dist/number-field/use-step-button.d.mts +24 -0
- package/dist/number-field/use-step-button.d.mts.map +1 -0
- package/dist/number-field/use-step-button.mjs +57 -3
- package/dist/number-field/use-step-button.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +28 -67
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-context.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +9 -6
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +13 -36
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.mjs +4 -3
- package/dist/popover/popover-root.mjs.map +1 -1
- package/dist/popover/popover-trigger.d.mts +4 -8
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +2 -1
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/progress-root.mjs +1 -1
- package/dist/radio-group/radio-group-context.mjs.map +1 -1
- package/dist/radio-group/radio-group-item.d.mts +3 -4
- package/dist/radio-group/radio-group-item.d.mts.map +1 -1
- package/dist/radio-group/radio-group-item.mjs +20 -25
- package/dist/radio-group/radio-group-item.mjs.map +1 -1
- package/dist/radio-group/radio-group-label.mjs +1 -6
- package/dist/radio-group/radio-group-label.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +1 -1
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +21 -40
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/select-dom.mjs +9 -18
- package/dist/select/select-dom.mjs.map +1 -1
- package/dist/select/select-option.mjs +1 -1
- package/dist/select/select-root.mjs +3 -2
- package/dist/select/select-root.mjs.map +1 -1
- package/dist/slider/slider-arithmetic.mjs +74 -13
- package/dist/slider/slider-arithmetic.mjs.map +1 -1
- package/dist/slider/slider-context.mjs.map +1 -1
- package/dist/slider/slider-label.d.mts.map +1 -1
- package/dist/slider/slider-label.mjs +3 -9
- package/dist/slider/slider-label.mjs.map +1 -1
- package/dist/slider/slider-root.d.mts +2 -2
- package/dist/slider/slider-root.d.mts.map +1 -1
- package/dist/slider/slider-root.mjs +36 -116
- package/dist/slider/slider-root.mjs.map +1 -1
- package/dist/slider/slider-thumb.d.mts.map +1 -1
- package/dist/slider/slider-thumb.mjs +8 -6
- package/dist/slider/slider-thumb.mjs.map +1 -1
- package/dist/slider/slider-value.d.mts.map +1 -1
- package/dist/slider/slider-value.mjs +2 -1
- package/dist/slider/slider-value.mjs.map +1 -1
- package/dist/slider/use-slider-dev-warnings.mjs +29 -0
- package/dist/slider/use-slider-dev-warnings.mjs.map +1 -0
- package/dist/slider/use-thumb-registry.mjs +51 -0
- package/dist/slider/use-thumb-registry.mjs.map +1 -0
- package/dist/switch/switch.d.mts +4 -5
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +15 -55
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/tabs-context.d.mts +2 -3
- package/dist/tabs/tabs-context.d.mts.map +1 -1
- package/dist/tabs/tabs-context.mjs.map +1 -1
- package/dist/tabs/tabs-list.d.mts.map +1 -1
- package/dist/tabs/tabs-list.mjs +9 -22
- package/dist/tabs/tabs-list.mjs.map +1 -1
- package/dist/tabs/tabs-panel.d.mts +3 -4
- package/dist/tabs/tabs-panel.d.mts.map +1 -1
- package/dist/tabs/tabs-panel.mjs.map +1 -1
- package/dist/tabs/tabs-root.d.mts +4 -3
- package/dist/tabs/tabs-root.d.mts.map +1 -1
- package/dist/tabs/tabs-root.mjs +2 -1
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.d.mts +3 -4
- package/dist/tabs/tabs-tab.d.mts.map +1 -1
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/toast-action.mjs.map +1 -1
- package/dist/toast/toast-close.d.mts.map +1 -1
- package/dist/toast/toast-close.mjs +2 -8
- package/dist/toast/toast-close.mjs.map +1 -1
- package/dist/toast/toast-context.mjs.map +1 -1
- package/dist/toast/toast-hotkey.mjs +27 -0
- package/dist/toast/toast-hotkey.mjs.map +1 -0
- package/dist/toast/toast-queue.mjs +137 -0
- package/dist/toast/toast-queue.mjs.map +1 -0
- package/dist/toast/toast-timers.mjs +65 -0
- package/dist/toast/toast-timers.mjs.map +1 -0
- package/dist/toast/toast-viewport.d.mts.map +1 -1
- package/dist/toast/toast-viewport.mjs +30 -235
- package/dist/toast/toast-viewport.mjs.map +1 -1
- package/dist/toast/toast.mjs +1 -1
- package/dist/toast/toast.mjs.map +1 -1
- package/dist/toast/use-modal-portal-host.mjs +52 -0
- package/dist/toast/use-modal-portal-host.mjs.map +1 -0
- package/dist/toggle/toggle.d.mts +3 -4
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +7 -10
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-context.d.mts +2 -1
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-item.d.mts +5 -3
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-item.mjs +5 -7
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-root.mjs +29 -64
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
- package/dist/toolbar/toolbar-root.d.mts +2 -2
- package/dist/toolbar/toolbar-root.d.mts.map +1 -1
- package/dist/toolbar/toolbar-root.mjs +3 -4
- package/dist/toolbar/toolbar-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-context.d.mts +1 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +6 -15
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +2 -2
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +2 -1
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +3 -2
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/dist/tooltip/use-tooltip-interaction.mjs +4 -3
- package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/accordion/accordion-context.d.mts +0 -5
- package/dist/accordion/accordion-context.d.mts.map +0 -1
- package/dist/internal/use-popover-root.mjs.map +0 -1
- /package/dist/internal/{use-popover-root.d.mts → use-overlay-root.d.mts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-close.mjs","names":[],"sources":["../../src/toast/toast-close.tsx"],"sourcesContent":["\"use client\";\nimport {
|
|
1
|
+
{"version":3,"file":"toast-close.mjs","names":[],"sources":["../../src/toast/toast-close.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { TEXT_NAME, useNameWarning } from \"../internal/use-name-warning.js\";\nimport { rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport type { ToastItem } from \"./toast.js\";\nimport { useToastRootContext } from \"./toast-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ToastCloseState {\n readonly toast: ToastItem;\n}\n\nexport interface ToastCloseProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"className\" | \"style\" | \"children\"\n> {\n children?: StateValue<ReactNode, ToastCloseState>;\n className?: StateValue<string | undefined, ToastCloseState>;\n style?: StateValue<CSSProperties | undefined, ToastCloseState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ToastCloseState>;\n}\n\n/**\n * Dismisses the toast (`reason: \"dismiss\"`, the same as Escape). Label it yourself (`aria-label`\n * or text). No Invoker Command: `hide-popover` would hide the whole region.\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `onClick`.\n */\nexport function ToastClose({ children, className, style, render, ...rest }: ToastCloseProps) {\n const root = useToastRootContext(\"Toast.Close\");\n\n const devRef = useNameWarning(\n isDev && \"Toast.Close: the button has no accessible name. Give it text or an `aria-label`.\",\n TEXT_NAME,\n );\n\n const onClick = (event: MouseEvent<HTMLElement>): void => {\n if (rest.disabled === true) return;\n root.close(\"dismiss\", event.nativeEvent);\n };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n onClick,\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, ToastCloseState>({\n defaultElement: \"button\",\n render,\n state: { toast: root.toast },\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref: devRef,\n });\n}\n\nToastClose.displayName = \"ToastClose\";\n"],"mappings":";;;;;;AASA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;AAsBvC,SAAgB,WAAW,EAAE,UAAU,WAAW,OAAO,QAAQ,GAAG,QAAyB;CAC3F,MAAM,OAAO,oBAAoB,aAAa;CAE9C,MAAM,SAAS,eACb,SAAS,oFACT,SACF;CAEA,MAAM,WAAW,UAAyC;EACxD,IAAI,KAAK,aAAa,MAAM;EAC5B,KAAK,MAAM,WAAW,MAAM,WAAW;CACzC;CAEA,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EACvD;CACF;CAEA,OAAO,UAA4D;EACjE,gBAAgB;EAChB;EACA,OAAO,EAAE,OAAO,KAAK,MAAM;EAC3B;EACA;EACA;EACA,OAAO;EACP;EACA,KAAK;CACP,CAAC;AACH;AAEA,WAAW,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-context.mjs","names":[],"sources":["../../src/toast/toast-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { ChangeReason } from \"../internal/types.js\";\nimport type { ToastItem, ToastPriority } from \"./toast.js\";\n\n/** What a Root (and the parts under it) need from the Viewport. Stable for the Viewport's life. */\nexport interface ToastViewportContextValue {\n /** Close toasts (`ending: true`), moving focus out first and scheduling `closeAction`. */\n readonly close: (ids: readonly string[], reason: ChangeReason, event: Event | undefined) => void;\n /** Remove an ending toast once its exit animations finished. */\n readonly drop: (id: string) => void;\n /** An action dispatched through the toast's Action part is (no longer) in flight. */\n readonly setActionPending: (id: string, pending: boolean) => void;\n /** The toast's content is (no longer) suspended behind the Root's guard. */\n readonly setSuspended: (id: string, suspended: boolean) => void;\n /** The Root's element, for arrow keys, the hotkey and focus moves; `null` to unregister. */\n readonly registerRoot: (id: string, element: HTMLElement | null) => void;\n /** Focus the next (`1`) or previous (`-1`) toast's Root, without wrapping. */\n readonly focusSibling: (id: string, direction: 1 | -1) => void;\n /** Queue an announcement; skipped when `text` equals the last one announced for `id`. */\n readonly announce: (id: string, text: string | null, priority: ToastPriority) => void;\n /** The Viewport's `announce` prop, read at announcement time. */\n readonly announcer: () => ((toast: ToastItem) => string | null) | undefined;\n /**\n * The animations that ran in the toast before it was marked ending (kept until it is dropped\n * or replaced): its exit waits only for the others.\n */\n readonly exitBaseline: (id: string) => ReadonlySet<Animation> | undefined;\n}\n\nexport const ToastViewportContext = createContext<ToastViewportContextValue | null>(null);\n\nexport function useToastViewportContext(part: string): ToastViewportContextValue {\n const context = use(ToastViewportContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Toast.Viewport.`);\n }\n return context;\n}\n\n/** What the parts inside a Root need. */\nexport interface ToastRootContextValue {\n readonly toast: ToastItem;\n readonly ids: { readonly title: string; readonly description: string };\n /** Root state, so Title and Description can resolve their function props against it. */\n readonly state:
|
|
1
|
+
{"version":3,"file":"toast-context.mjs","names":[],"sources":["../../src/toast/toast-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { ChangeReason } from \"../internal/types.js\";\nimport type { ToastRootState } from \"./toast-root.js\";\nimport type { ToastItem, ToastPriority } from \"./toast.js\";\n\n/** What a Root (and the parts under it) need from the Viewport. Stable for the Viewport's life. */\nexport interface ToastViewportContextValue {\n /** Close toasts (`ending: true`), moving focus out first and scheduling `closeAction`. */\n readonly close: (ids: readonly string[], reason: ChangeReason, event: Event | undefined) => void;\n /** Remove an ending toast once its exit animations finished. */\n readonly drop: (id: string) => void;\n /** An action dispatched through the toast's Action part is (no longer) in flight. */\n readonly setActionPending: (id: string, pending: boolean) => void;\n /** The toast's content is (no longer) suspended behind the Root's guard. */\n readonly setSuspended: (id: string, suspended: boolean) => void;\n /** The Root's element, for arrow keys, the hotkey and focus moves; `null` to unregister. */\n readonly registerRoot: (id: string, element: HTMLElement | null) => void;\n /** Focus the next (`1`) or previous (`-1`) toast's Root, without wrapping. */\n readonly focusSibling: (id: string, direction: 1 | -1) => void;\n /** Queue an announcement; skipped when `text` equals the last one announced for `id`. */\n readonly announce: (id: string, text: string | null, priority: ToastPriority) => void;\n /** The Viewport's `announce` prop, read at announcement time. */\n readonly announcer: () => ((toast: ToastItem) => string | null) | undefined;\n /**\n * The animations that ran in the toast before it was marked ending (kept until it is dropped\n * or replaced): its exit waits only for the others.\n */\n readonly exitBaseline: (id: string) => ReadonlySet<Animation> | undefined;\n}\n\nexport const ToastViewportContext = createContext<ToastViewportContextValue | null>(null);\n\nexport function useToastViewportContext(part: string): ToastViewportContextValue {\n const context = use(ToastViewportContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Toast.Viewport.`);\n }\n return context;\n}\n\n/** What the parts inside a Root need. */\nexport interface ToastRootContextValue {\n readonly toast: ToastItem;\n readonly ids: { readonly title: string; readonly description: string };\n /** Root state, so Title and Description can resolve their function props against it. */\n readonly state: ToastRootState;\n readonly registerTitle: (element: HTMLElement | null) => void;\n readonly registerDescription: (element: HTMLElement | null) => void;\n /** An Action part's run is (no longer) in flight; `token` identifies the part. */\n readonly setActionPending: (token: object, pending: boolean) => void;\n /**\n * A Title or Description committed: mounted, or shown again by a Suspense boundary inside the\n * Root (the consumer's skeleton), so the Root announces the text that now exists.\n */\n readonly contentCommitted: () => void;\n /** The Suspense guard mounted (`true`) or unmounted (`false`). */\n readonly setSuspended: (suspended: boolean) => void;\n /** Close this toast. */\n readonly close: (reason: ChangeReason, event: Event | undefined) => void;\n}\n\nexport const ToastRootContext = createContext<ToastRootContextValue | null>(null);\n\nexport function useToastRootContext(part: string): ToastRootContextValue {\n const context = use(ToastRootContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Toast.Root.`);\n }\n return context;\n}\n"],"mappings":";;;AA+BA,MAAa,uBAAuB,cAAgD,IAAI;AAExF,SAAgB,wBAAwB,MAAyC;CAC/E,MAAM,UAAU,IAAI,oBAAoB;CACxC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,2CAA2C;CAErE,OAAO;AACT;AAuBA,MAAa,mBAAmB,cAA4C,IAAI;AAEhF,SAAgB,oBAAoB,MAAqC;CACvE,MAAM,UAAU,IAAI,gBAAgB;CACpC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,uCAAuC;CAEjE,OAAO;AACT"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/toast/toast-hotkey.ts
|
|
2
|
+
const DEFAULT_HOTKEY = ["F8"];
|
|
3
|
+
const MODIFIER_NAMES = {
|
|
4
|
+
altKey: "Alt",
|
|
5
|
+
ctrlKey: "Ctrl",
|
|
6
|
+
metaKey: "Meta",
|
|
7
|
+
shiftKey: "Shift"
|
|
8
|
+
};
|
|
9
|
+
/** `["altKey", "KeyT"]` → `"Alt+T"`, `["F8"]` → `"F8"`. */
|
|
10
|
+
function hotkeyLabel(hotkey) {
|
|
11
|
+
return hotkey.map((key) => MODIFIER_NAMES[key] ?? key.replace(/^Key(?=[A-Z]$)/, "").replace(/^Digit/, "")).join("+");
|
|
12
|
+
}
|
|
13
|
+
/** The region's built-in accessible name (conventions 11): `"Notifications (F8)"`. */
|
|
14
|
+
function regionLabel(hotkey) {
|
|
15
|
+
if (hotkey === null || hotkey.length === 0) return "Notifications";
|
|
16
|
+
return `Notifications (${hotkeyLabel(hotkey)})`;
|
|
17
|
+
}
|
|
18
|
+
/** The listed keys and modifiers, and no unlisted modifier (Ctrl+F8 is not F8). */
|
|
19
|
+
function matchesHotkey(hotkey, event) {
|
|
20
|
+
const flags = event;
|
|
21
|
+
for (const modifier of Object.keys(MODIFIER_NAMES)) if (flags[modifier] === true !== hotkey.includes(modifier)) return false;
|
|
22
|
+
return hotkey.every((key) => key in MODIFIER_NAMES || event.code === key);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { DEFAULT_HOTKEY, matchesHotkey, regionLabel };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=toast-hotkey.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast-hotkey.mjs","names":[],"sources":["../../src/toast/toast-hotkey.ts"],"sourcesContent":["// The Viewport's hotkey (design/components/toast.md 7) and the region name built from it. No\n// \"use client\" directive: pure (conventions 7.1).\n\nexport const DEFAULT_HOTKEY: readonly string[] = [\"F8\"];\n\nconst MODIFIER_NAMES: Readonly<Record<string, string>> = {\n altKey: \"Alt\",\n ctrlKey: \"Ctrl\",\n metaKey: \"Meta\",\n shiftKey: \"Shift\",\n};\n\n/** `[\"altKey\", \"KeyT\"]` → `\"Alt+T\"`, `[\"F8\"]` → `\"F8\"`. */\nfunction hotkeyLabel(hotkey: readonly string[]): string {\n return hotkey\n .map((key) => MODIFIER_NAMES[key] ?? key.replace(/^Key(?=[A-Z]$)/, \"\").replace(/^Digit/, \"\"))\n .join(\"+\");\n}\n\n/** The region's built-in accessible name (conventions 11): `\"Notifications (F8)\"`. */\nexport function regionLabel(hotkey: readonly string[] | null): string {\n if (hotkey === null || hotkey.length === 0) return \"Notifications\";\n return `Notifications (${hotkeyLabel(hotkey)})`;\n}\n\n/** The listed keys and modifiers, and no unlisted modifier (Ctrl+F8 is not F8). */\nexport function matchesHotkey(hotkey: readonly string[], event: KeyboardEvent): boolean {\n const flags = event as unknown as Record<string, unknown>;\n for (const modifier of Object.keys(MODIFIER_NAMES)) {\n if ((flags[modifier] === true) !== hotkey.includes(modifier)) return false;\n }\n return hotkey.every((key) => key in MODIFIER_NAMES || event.code === key);\n}\n"],"mappings":";AAGA,MAAa,iBAAoC,CAAC,IAAI;AAEtD,MAAM,iBAAmD;CACvD,QAAQ;CACR,SAAS;CACT,SAAS;CACT,UAAU;AACZ;;AAGA,SAAS,YAAY,QAAmC;CACtD,OAAO,OACJ,KAAK,QAAQ,eAAe,QAAQ,IAAI,QAAQ,kBAAkB,EAAE,CAAC,CAAC,QAAQ,UAAU,EAAE,CAAC,CAAC,CAC5F,KAAK,GAAG;AACb;;AAGA,SAAgB,YAAY,QAA0C;CACpE,IAAI,WAAW,QAAQ,OAAO,WAAW,GAAG,OAAO;CACnD,OAAO,kBAAkB,YAAY,MAAM,EAAE;AAC/C;;AAGA,SAAgB,cAAc,QAA2B,OAA+B;CACtF,MAAM,QAAQ;CACd,KAAK,MAAM,YAAY,OAAO,KAAK,cAAc,GAC/C,IAAK,MAAM,cAAc,SAAU,OAAO,SAAS,QAAQ,GAAG,OAAO;CAEvE,OAAO,OAAO,OAAO,QAAQ,OAAO,kBAAkB,MAAM,SAAS,GAAG;AAC1E"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
//#region src/toast/toast-queue.ts
|
|
2
|
+
function makeEntry(options, flags) {
|
|
3
|
+
return {
|
|
4
|
+
options,
|
|
5
|
+
...flags,
|
|
6
|
+
item: {
|
|
7
|
+
...options,
|
|
8
|
+
id: options.id,
|
|
9
|
+
pending: flags.promisePending || flags.actionPending,
|
|
10
|
+
ending: flags.ending
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function withFlags(entry, flags) {
|
|
15
|
+
return makeEntry(entry.options, {
|
|
16
|
+
promisePending: flags.promisePending ?? entry.promisePending,
|
|
17
|
+
actionPending: flags.actionPending ?? entry.actionPending,
|
|
18
|
+
ending: flags.ending ?? entry.ending
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/** Rendered entries (the first `limit` open ones plus every ending one) and the queued count. */
|
|
22
|
+
function partition(entries, limit) {
|
|
23
|
+
const visible = [];
|
|
24
|
+
const queued = [];
|
|
25
|
+
let open = 0;
|
|
26
|
+
for (const entry of entries) if (entry.ending) visible.push(entry);
|
|
27
|
+
else if (open < limit) {
|
|
28
|
+
visible.push(entry);
|
|
29
|
+
open++;
|
|
30
|
+
} else queued.push(entry);
|
|
31
|
+
return {
|
|
32
|
+
visible,
|
|
33
|
+
queued
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Plain text of a `ReactNode` that is text (queued toasts have no DOM to read yet). */
|
|
37
|
+
function plainText(node) {
|
|
38
|
+
if (typeof node === "string") return node;
|
|
39
|
+
if (typeof node === "number" || typeof node === "bigint") return String(node);
|
|
40
|
+
if (Array.isArray(node)) return node.map(plainText).join("");
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Applies a batch of manager commands to the queue. Dismissals apply in order: each closes the
|
|
45
|
+
* toasts open at that point of the batch, never one added after it. A dismissed toast with a
|
|
46
|
+
* rendered Root (`isRendered`) turns ending; one never rendered (queued beyond `limit`, or added
|
|
47
|
+
* in this tick) leaves at once instead of mounting once as an ending Root. An add with the id of
|
|
48
|
+
* an open toast updates it ("one toast per key"); with the id of an ending one it replaces it
|
|
49
|
+
* (the keyed Root may be reused): a fresh timer, a fresh announcement, no exit.
|
|
50
|
+
*/
|
|
51
|
+
function applyCommands(entries, commands, isRendered) {
|
|
52
|
+
const next = [...entries];
|
|
53
|
+
const dismissed = [];
|
|
54
|
+
const forgotten = [];
|
|
55
|
+
const replaced = [];
|
|
56
|
+
const missing = [];
|
|
57
|
+
let added = false;
|
|
58
|
+
for (const command of commands) {
|
|
59
|
+
if (command.kind === "dismiss") {
|
|
60
|
+
for (let i = 0; i < next.length; i++) {
|
|
61
|
+
const entry = next[i];
|
|
62
|
+
if (entry.ending) continue;
|
|
63
|
+
const id = entry.options.id;
|
|
64
|
+
if (command.id !== void 0 && id !== command.id) continue;
|
|
65
|
+
dismissed.push(entry);
|
|
66
|
+
if (isRendered(id)) next[i] = withFlags(entry, { ending: true });
|
|
67
|
+
else {
|
|
68
|
+
next.splice(i--, 1);
|
|
69
|
+
forgotten.push(id);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const index = next.findIndex((e) => e.options.id === command.id);
|
|
75
|
+
const existing = index === -1 ? void 0 : next[index];
|
|
76
|
+
if (command.kind === "add") {
|
|
77
|
+
const options = {
|
|
78
|
+
...command.options,
|
|
79
|
+
id: command.id
|
|
80
|
+
};
|
|
81
|
+
if (existing !== void 0 && !existing.ending) {
|
|
82
|
+
next[index] = makeEntry({
|
|
83
|
+
...existing.options,
|
|
84
|
+
...options
|
|
85
|
+
}, {
|
|
86
|
+
promisePending: command.pending || existing.promisePending,
|
|
87
|
+
actionPending: existing.actionPending,
|
|
88
|
+
ending: false
|
|
89
|
+
});
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (existing !== void 0) {
|
|
93
|
+
next.splice(index, 1);
|
|
94
|
+
replaced.push(command.id);
|
|
95
|
+
forgotten.push(command.id);
|
|
96
|
+
}
|
|
97
|
+
next.push(makeEntry(options, {
|
|
98
|
+
promisePending: command.pending,
|
|
99
|
+
actionPending: false,
|
|
100
|
+
ending: false
|
|
101
|
+
}));
|
|
102
|
+
added = true;
|
|
103
|
+
} else {
|
|
104
|
+
if (existing === void 0) {
|
|
105
|
+
if (!command.settle) missing.push(command.id);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (existing.ending) continue;
|
|
109
|
+
next[index] = makeEntry(command.settle ? {
|
|
110
|
+
...command.options,
|
|
111
|
+
id: command.id
|
|
112
|
+
} : {
|
|
113
|
+
...existing.options,
|
|
114
|
+
...command.options,
|
|
115
|
+
id: command.id
|
|
116
|
+
}, {
|
|
117
|
+
promisePending: command.settle ? false : existing.promisePending,
|
|
118
|
+
actionPending: existing.actionPending,
|
|
119
|
+
ending: false
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const stays = new Set(next.filter((e) => !e.ending).map((e) => e.options.id));
|
|
124
|
+
return {
|
|
125
|
+
next,
|
|
126
|
+
dismissed,
|
|
127
|
+
leaving: new Set(dismissed.map((e) => e.options.id).filter((id) => !stays.has(id))),
|
|
128
|
+
forgotten,
|
|
129
|
+
replaced,
|
|
130
|
+
added,
|
|
131
|
+
missing
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { applyCommands, makeEntry, partition, plainText, withFlags };
|
|
136
|
+
|
|
137
|
+
//# sourceMappingURL=toast-queue.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast-queue.mjs","names":[],"sources":["../../src/toast/toast-queue.ts"],"sourcesContent":["// The Viewport's queue model (design/components/toast.md 8, 12): entries, their public items, and\n// which of them render. No \"use client\" directive: pure (conventions 7.1).\nimport type { ToastCommand, ToastItem, ToastOptions } from \"./toast.js\";\n\n/** One queue entry: the toast's options and the flags its `ToastItem` is built from. */\nexport interface Entry {\n readonly options: ToastOptions & { readonly id: string };\n readonly promisePending: boolean;\n readonly actionPending: boolean;\n readonly ending: boolean;\n /** The public item, rebuilt whenever any of the above changes (stable identity otherwise). */\n readonly item: ToastItem;\n}\n\nexport function makeEntry(\n options: ToastOptions & { readonly id: string },\n flags: { promisePending: boolean; actionPending: boolean; ending: boolean },\n): Entry {\n return {\n options,\n ...flags,\n item: {\n ...options,\n id: options.id,\n pending: flags.promisePending || flags.actionPending,\n ending: flags.ending,\n },\n };\n}\n\nexport function withFlags(\n entry: Entry,\n flags: Partial<{ promisePending: boolean; actionPending: boolean; ending: boolean }>,\n): Entry {\n return makeEntry(entry.options, {\n promisePending: flags.promisePending ?? entry.promisePending,\n actionPending: flags.actionPending ?? entry.actionPending,\n ending: flags.ending ?? entry.ending,\n });\n}\n\n/** Rendered entries (the first `limit` open ones plus every ending one) and the queued count. */\nexport function partition(\n entries: readonly Entry[],\n limit: number,\n): { visible: Entry[]; queued: Entry[] } {\n const visible: Entry[] = [];\n const queued: Entry[] = [];\n let open = 0;\n for (const entry of entries) {\n if (entry.ending) visible.push(entry);\n else if (open < limit) {\n visible.push(entry);\n open++;\n } else queued.push(entry);\n }\n return { visible, queued };\n}\n\n/** Plain text of a `ReactNode` that is text (queued toasts have no DOM to read yet). */\nexport function plainText(node: unknown): string {\n if (typeof node === \"string\") return node;\n if (typeof node === \"number\" || typeof node === \"bigint\") return String(node);\n if (Array.isArray(node)) return node.map(plainText).join(\"\");\n return \"\";\n}\n\nexport interface AppliedCommands {\n readonly next: readonly Entry[];\n /** The open toasts the batch dismissed, in order (their `closeAction`s run). */\n readonly dismissed: readonly Entry[];\n /** Dismissed ids that leave the DOM: not those replaced by a later add with the id. */\n readonly leaving: ReadonlySet<string>;\n /**\n * Ids whose announcement and exit baseline start over: dismissed before they rendered, or an\n * ending toast replaced by a new one with its id (listed in `replaced` too).\n */\n readonly forgotten: readonly string[];\n /** Ending toasts replaced by a new add with their id: their timer starts over. */\n readonly replaced: readonly string[];\n /** The batch added a toast (the region re-raises). */\n readonly added: boolean;\n /** Ids of updates that found no toast (a promise settle excepted). */\n readonly missing: readonly string[];\n}\n\n/**\n * Applies a batch of manager commands to the queue. Dismissals apply in order: each closes the\n * toasts open at that point of the batch, never one added after it. A dismissed toast with a\n * rendered Root (`isRendered`) turns ending; one never rendered (queued beyond `limit`, or added\n * in this tick) leaves at once instead of mounting once as an ending Root. An add with the id of\n * an open toast updates it (\"one toast per key\"); with the id of an ending one it replaces it\n * (the keyed Root may be reused): a fresh timer, a fresh announcement, no exit.\n */\nexport function applyCommands(\n entries: readonly Entry[],\n commands: readonly ToastCommand[],\n isRendered: (id: string) => boolean,\n): AppliedCommands {\n const next = [...entries];\n const dismissed: Entry[] = [];\n const forgotten: string[] = [];\n const replaced: string[] = [];\n const missing: string[] = [];\n let added = false;\n for (const command of commands) {\n if (command.kind === \"dismiss\") {\n for (let i = 0; i < next.length; i++) {\n const entry = next[i]!;\n if (entry.ending) continue;\n const id = entry.options.id;\n if (command.id !== undefined && id !== command.id) continue;\n dismissed.push(entry);\n if (isRendered(id)) {\n next[i] = withFlags(entry, { ending: true });\n } else {\n next.splice(i--, 1);\n forgotten.push(id);\n }\n }\n continue;\n }\n const index = next.findIndex((e) => e.options.id === command.id);\n const existing = index === -1 ? undefined : next[index]!;\n if (command.kind === \"add\") {\n const options = { ...command.options, id: command.id };\n if (existing !== undefined && !existing.ending) {\n next[index] = makeEntry(\n { ...existing.options, ...options },\n {\n promisePending: command.pending || existing.promisePending,\n actionPending: existing.actionPending,\n ending: false,\n },\n );\n continue;\n }\n if (existing !== undefined) {\n next.splice(index, 1);\n replaced.push(command.id);\n forgotten.push(command.id);\n }\n next.push(\n makeEntry(options, {\n promisePending: command.pending,\n actionPending: false,\n ending: false,\n }),\n );\n added = true;\n } else {\n if (existing === undefined) {\n if (!command.settle) missing.push(command.id);\n continue;\n }\n if (existing.ending) continue;\n const options = command.settle\n ? { ...command.options, id: command.id }\n : { ...existing.options, ...command.options, id: command.id };\n next[index] = makeEntry(options, {\n promisePending: command.settle ? false : existing.promisePending,\n actionPending: existing.actionPending,\n ending: false,\n });\n }\n }\n const stays = new Set(next.filter((e) => !e.ending).map((e) => e.options.id));\n const leaving = new Set(dismissed.map((e) => e.options.id).filter((id) => !stays.has(id)));\n return { next, dismissed, leaving, forgotten, replaced, added, missing };\n}\n"],"mappings":";AAcA,SAAgB,UACd,SACA,OACO;CACP,OAAO;EACL;EACA,GAAG;EACH,MAAM;GACJ,GAAG;GACH,IAAI,QAAQ;GACZ,SAAS,MAAM,kBAAkB,MAAM;GACvC,QAAQ,MAAM;EAChB;CACF;AACF;AAEA,SAAgB,UACd,OACA,OACO;CACP,OAAO,UAAU,MAAM,SAAS;EAC9B,gBAAgB,MAAM,kBAAkB,MAAM;EAC9C,eAAe,MAAM,iBAAiB,MAAM;EAC5C,QAAQ,MAAM,UAAU,MAAM;CAChC,CAAC;AACH;;AAGA,SAAgB,UACd,SACA,OACuC;CACvC,MAAM,UAAmB,CAAC;CAC1B,MAAM,SAAkB,CAAC;CACzB,IAAI,OAAO;CACX,KAAK,MAAM,SAAS,SAClB,IAAI,MAAM,QAAQ,QAAQ,KAAK,KAAK;MAC/B,IAAI,OAAO,OAAO;EACrB,QAAQ,KAAK,KAAK;EAClB;CACF,OAAO,OAAO,KAAK,KAAK;CAE1B,OAAO;EAAE;EAAS;CAAO;AAC3B;;AAGA,SAAgB,UAAU,MAAuB;CAC/C,IAAI,OAAO,SAAS,UAAU,OAAO;CACrC,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU,OAAO,OAAO,IAAI;CAC5E,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO,KAAK,IAAI,SAAS,CAAC,CAAC,KAAK,EAAE;CAC3D,OAAO;AACT;;;;;;;;;AA6BA,SAAgB,cACd,SACA,UACA,YACiB;CACjB,MAAM,OAAO,CAAC,GAAG,OAAO;CACxB,MAAM,YAAqB,CAAC;CAC5B,MAAM,YAAsB,CAAC;CAC7B,MAAM,WAAqB,CAAC;CAC5B,MAAM,UAAoB,CAAC;CAC3B,IAAI,QAAQ;CACZ,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,QAAQ,SAAS,WAAW;GAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;IACpC,MAAM,QAAQ,KAAK;IACnB,IAAI,MAAM,QAAQ;IAClB,MAAM,KAAK,MAAM,QAAQ;IACzB,IAAI,QAAQ,OAAO,KAAA,KAAa,OAAO,QAAQ,IAAI;IACnD,UAAU,KAAK,KAAK;IACpB,IAAI,WAAW,EAAE,GACf,KAAK,KAAK,UAAU,OAAO,EAAE,QAAQ,KAAK,CAAC;SACtC;KACL,KAAK,OAAO,KAAK,CAAC;KAClB,UAAU,KAAK,EAAE;IACnB;GACF;GACA;EACF;EACA,MAAM,QAAQ,KAAK,WAAW,MAAM,EAAE,QAAQ,OAAO,QAAQ,EAAE;EAC/D,MAAM,WAAW,UAAU,KAAK,KAAA,IAAY,KAAK;EACjD,IAAI,QAAQ,SAAS,OAAO;GAC1B,MAAM,UAAU;IAAE,GAAG,QAAQ;IAAS,IAAI,QAAQ;GAAG;GACrD,IAAI,aAAa,KAAA,KAAa,CAAC,SAAS,QAAQ;IAC9C,KAAK,SAAS,UACZ;KAAE,GAAG,SAAS;KAAS,GAAG;IAAQ,GAClC;KACE,gBAAgB,QAAQ,WAAW,SAAS;KAC5C,eAAe,SAAS;KACxB,QAAQ;IACV,CACF;IACA;GACF;GACA,IAAI,aAAa,KAAA,GAAW;IAC1B,KAAK,OAAO,OAAO,CAAC;IACpB,SAAS,KAAK,QAAQ,EAAE;IACxB,UAAU,KAAK,QAAQ,EAAE;GAC3B;GACA,KAAK,KACH,UAAU,SAAS;IACjB,gBAAgB,QAAQ;IACxB,eAAe;IACf,QAAQ;GACV,CAAC,CACH;GACA,QAAQ;EACV,OAAO;GACL,IAAI,aAAa,KAAA,GAAW;IAC1B,IAAI,CAAC,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,EAAE;IAC5C;GACF;GACA,IAAI,SAAS,QAAQ;GAIrB,KAAK,SAAS,UAHE,QAAQ,SACpB;IAAE,GAAG,QAAQ;IAAS,IAAI,QAAQ;GAAG,IACrC;IAAE,GAAG,SAAS;IAAS,GAAG,QAAQ;IAAS,IAAI,QAAQ;GAAG,GAC7B;IAC/B,gBAAgB,QAAQ,SAAS,QAAQ,SAAS;IAClD,eAAe,SAAS;IACxB,QAAQ;GACV,CAAC;EACH;CACF;CACA,MAAM,QAAQ,IAAI,IAAI,KAAK,QAAQ,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC;CAE5E,OAAO;EAAE;EAAM;EAAW,SAAA,IADN,IAAI,UAAU,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CACxD;EAAG;EAAW;EAAU;EAAO;CAAQ;AACzE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/toast/toast-timers.ts
|
|
2
|
+
/** A toast's own `duration`, else none with an action (it waits for the user), else the default. */
|
|
3
|
+
function effectiveDuration(entry, defaultDuration) {
|
|
4
|
+
const own = entry.options.duration;
|
|
5
|
+
if (own !== void 0) return own;
|
|
6
|
+
return entry.options.action !== void 0 ? null : defaultDuration;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Matches the timers to the rendered entries: starts or resumes the timer of each open, timed
|
|
10
|
+
* toast that is not pending, suspended or halted, pauses the others keeping their remaining
|
|
11
|
+
* time, and drops the timers of toasts no longer rendered (or no longer timed).
|
|
12
|
+
*/
|
|
13
|
+
function syncToastTimers(map, visible, sync) {
|
|
14
|
+
const now = Date.now();
|
|
15
|
+
const live = /* @__PURE__ */ new Set();
|
|
16
|
+
for (const entry of visible) {
|
|
17
|
+
if (entry.ending) continue;
|
|
18
|
+
const id = entry.options.id;
|
|
19
|
+
const ms = effectiveDuration(entry, sync.defaultDuration);
|
|
20
|
+
if (ms === null) continue;
|
|
21
|
+
live.add(id);
|
|
22
|
+
let timer = map.get(id);
|
|
23
|
+
if (timer === void 0 || timer.duration !== ms) {
|
|
24
|
+
if (timer?.handle != null) clearTimeout(timer.handle);
|
|
25
|
+
timer = {
|
|
26
|
+
duration: ms,
|
|
27
|
+
remaining: ms,
|
|
28
|
+
startedAt: 0,
|
|
29
|
+
handle: null
|
|
30
|
+
};
|
|
31
|
+
map.set(id, timer);
|
|
32
|
+
}
|
|
33
|
+
const run = !sync.halted && !entry.item.pending && !sync.suspended.has(id);
|
|
34
|
+
if (run && timer.handle === null) {
|
|
35
|
+
const current = timer;
|
|
36
|
+
current.startedAt = now;
|
|
37
|
+
current.handle = setTimeout(() => {
|
|
38
|
+
current.handle = null;
|
|
39
|
+
current.remaining = 0;
|
|
40
|
+
sync.expire(id);
|
|
41
|
+
}, Math.max(0, current.remaining));
|
|
42
|
+
} else if (!run && timer.handle !== null) {
|
|
43
|
+
clearTimeout(timer.handle);
|
|
44
|
+
timer.handle = null;
|
|
45
|
+
timer.remaining -= now - timer.startedAt;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
for (const [id, timer] of map) {
|
|
49
|
+
if (live.has(id)) continue;
|
|
50
|
+
if (timer.handle !== null) clearTimeout(timer.handle);
|
|
51
|
+
map.delete(id);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Stops and forgets the timer of `id`, or every timer. */
|
|
55
|
+
function clearToastTimers(map, id) {
|
|
56
|
+
for (const [key, timer] of map) {
|
|
57
|
+
if (id !== void 0 && key !== id) continue;
|
|
58
|
+
if (timer.handle !== null) clearTimeout(timer.handle);
|
|
59
|
+
map.delete(key);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { clearToastTimers, syncToastTimers };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=toast-timers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast-timers.mjs","names":[],"sources":["../../src/toast/toast-timers.ts"],"sourcesContent":["// The Viewport's per-toast timers (design/components/toast.md 6). No \"use client\" directive: pure\n// (conventions 7.1); the Viewport keeps the map in a ref.\nimport type { Entry } from \"./toast-queue.js\";\n\nexport interface ToastTimer {\n /** The duration the timer was started with; a different effective duration restarts it. */\n readonly duration: number;\n remaining: number;\n startedAt: number;\n handle: ReturnType<typeof setTimeout> | null;\n}\n\nexport interface TimerSync {\n /** A viewport-wide pause holds, or the Viewport is not mounted: no timer runs. */\n readonly halted: boolean;\n /** Toasts whose content suspends: their timer waits. */\n readonly suspended: ReadonlySet<string>;\n /** The Viewport's `duration`. */\n readonly defaultDuration: number | null;\n /** A timer ran out. */\n readonly expire: (id: string) => void;\n}\n\n/** A toast's own `duration`, else none with an action (it waits for the user), else the default. */\nfunction effectiveDuration(entry: Entry, defaultDuration: number | null): number | null {\n const own = entry.options.duration;\n if (own !== undefined) return own;\n return entry.options.action !== undefined ? null : defaultDuration;\n}\n\n/**\n * Matches the timers to the rendered entries: starts or resumes the timer of each open, timed\n * toast that is not pending, suspended or halted, pauses the others keeping their remaining\n * time, and drops the timers of toasts no longer rendered (or no longer timed).\n */\nexport function syncToastTimers(\n map: Map<string, ToastTimer>,\n visible: readonly Entry[],\n sync: TimerSync,\n): void {\n const now = Date.now();\n const live = new Set<string>();\n for (const entry of visible) {\n if (entry.ending) continue;\n const id = entry.options.id;\n const ms = effectiveDuration(entry, sync.defaultDuration);\n if (ms === null) continue;\n live.add(id);\n let timer = map.get(id);\n if (timer === undefined || timer.duration !== ms) {\n if (timer?.handle != null) clearTimeout(timer.handle);\n timer = { duration: ms, remaining: ms, startedAt: 0, handle: null };\n map.set(id, timer);\n }\n const run = !sync.halted && !entry.item.pending && !sync.suspended.has(id);\n if (run && timer.handle === null) {\n const current = timer;\n current.startedAt = now;\n current.handle = setTimeout(\n () => {\n current.handle = null;\n current.remaining = 0;\n sync.expire(id);\n },\n Math.max(0, current.remaining),\n );\n } else if (!run && timer.handle !== null) {\n clearTimeout(timer.handle);\n timer.handle = null;\n timer.remaining -= now - timer.startedAt;\n }\n }\n for (const [id, timer] of map) {\n if (live.has(id)) continue;\n if (timer.handle !== null) clearTimeout(timer.handle);\n map.delete(id);\n }\n}\n\n/** Stops and forgets the timer of `id`, or every timer. */\nexport function clearToastTimers(map: Map<string, ToastTimer>, id?: string): void {\n for (const [key, timer] of map) {\n if (id !== undefined && key !== id) continue;\n if (timer.handle !== null) clearTimeout(timer.handle);\n map.delete(key);\n }\n}\n"],"mappings":";;AAwBA,SAAS,kBAAkB,OAAc,iBAA+C;CACtF,MAAM,MAAM,MAAM,QAAQ;CAC1B,IAAI,QAAQ,KAAA,GAAW,OAAO;CAC9B,OAAO,MAAM,QAAQ,WAAW,KAAA,IAAY,OAAO;AACrD;;;;;;AAOA,SAAgB,gBACd,KACA,SACA,MACM;CACN,MAAM,MAAM,KAAK,IAAI;CACrB,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,SAAS,SAAS;EAC3B,IAAI,MAAM,QAAQ;EAClB,MAAM,KAAK,MAAM,QAAQ;EACzB,MAAM,KAAK,kBAAkB,OAAO,KAAK,eAAe;EACxD,IAAI,OAAO,MAAM;EACjB,KAAK,IAAI,EAAE;EACX,IAAI,QAAQ,IAAI,IAAI,EAAE;EACtB,IAAI,UAAU,KAAA,KAAa,MAAM,aAAa,IAAI;GAChD,IAAI,OAAO,UAAU,MAAM,aAAa,MAAM,MAAM;GACpD,QAAQ;IAAE,UAAU;IAAI,WAAW;IAAI,WAAW;IAAG,QAAQ;GAAK;GAClE,IAAI,IAAI,IAAI,KAAK;EACnB;EACA,MAAM,MAAM,CAAC,KAAK,UAAU,CAAC,MAAM,KAAK,WAAW,CAAC,KAAK,UAAU,IAAI,EAAE;EACzE,IAAI,OAAO,MAAM,WAAW,MAAM;GAChC,MAAM,UAAU;GAChB,QAAQ,YAAY;GACpB,QAAQ,SAAS,iBACT;IACJ,QAAQ,SAAS;IACjB,QAAQ,YAAY;IACpB,KAAK,OAAO,EAAE;GAChB,GACA,KAAK,IAAI,GAAG,QAAQ,SAAS,CAC/B;EACF,OAAO,IAAI,CAAC,OAAO,MAAM,WAAW,MAAM;GACxC,aAAa,MAAM,MAAM;GACzB,MAAM,SAAS;GACf,MAAM,aAAa,MAAM,MAAM;EACjC;CACF;CACA,KAAK,MAAM,CAAC,IAAI,UAAU,KAAK;EAC7B,IAAI,KAAK,IAAI,EAAE,GAAG;EAClB,IAAI,MAAM,WAAW,MAAM,aAAa,MAAM,MAAM;EACpD,IAAI,OAAO,EAAE;CACf;AACF;;AAGA,SAAgB,iBAAiB,KAA8B,IAAmB;CAChF,KAAK,MAAM,CAAC,KAAK,UAAU,KAAK;EAC9B,IAAI,OAAO,KAAA,KAAa,QAAQ,IAAI;EACpC,IAAI,MAAM,WAAW,MAAM,aAAa,MAAM,MAAM;EACpD,IAAI,OAAO,GAAG;CAChB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-viewport.d.mts","names":[],"sources":["../../src/toast/toast-viewport.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"toast-viewport.d.mts","names":[],"sources":["../../src/toast/toast-viewport.tsx"],"mappings":";;;;iBA0CiB;;WAEN,iBAAiB;;WAEjB;;WAEA;;iBAGM,2BAA2B,KAC1C;;EAYA,UAAU;;EAEV;;EAEA;;;;;;EAMA;;;;;EAKA,YAAY,OAAO;;EAEnB,WAAW,WAAW,WAAW;EACjC,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,kCAAkC;;;;;;;;;;;wBAiCxC,gBACd,SACA,OACA,UACA,QACA,UACA,UACA,WACA,OACA,WACG,QACF,qCAAkB,IAAA;yBAXL"}
|
|
@@ -4,94 +4,20 @@ import { dataAttr } from "../internal/data-attr.mjs";
|
|
|
4
4
|
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
5
5
|
import { useRender } from "../internal/use-render.mjs";
|
|
6
6
|
import { useLatest } from "../internal/use-latest.mjs";
|
|
7
|
+
import { isPopoverOpen } from "../internal/popover-open.mjs";
|
|
7
8
|
import { DialogContext } from "../dialog/dialog-context.mjs";
|
|
8
9
|
import { animationBaseline } from "../internal/use-exit-animation.mjs";
|
|
9
|
-
import { getServerTopmostModal, getTopmostModal, subscribeModals } from "../internal/modal-registry.mjs";
|
|
10
10
|
import { ToastViewportContext } from "./toast-context.mjs";
|
|
11
11
|
import { toast, toastManagerInternals } from "./toast.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { DEFAULT_HOTKEY, matchesHotkey, regionLabel } from "./toast-hotkey.mjs";
|
|
13
|
+
import { clearToastTimers, syncToastTimers } from "./toast-timers.mjs";
|
|
14
|
+
import { useModalPortalHost } from "./use-modal-portal-host.mjs";
|
|
15
|
+
import { applyCommands, makeEntry, partition, plainText, withFlags } from "./toast-queue.mjs";
|
|
16
|
+
import { use, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useTransition } from "react";
|
|
13
17
|
import { createPortal } from "react-dom";
|
|
14
18
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
19
|
//#region src/toast/toast-viewport.tsx
|
|
16
20
|
const isDev = process.env.NODE_ENV !== "production";
|
|
17
|
-
const DEFAULT_HOTKEY = ["F8"];
|
|
18
|
-
const MODIFIER_NAMES = {
|
|
19
|
-
altKey: "Alt",
|
|
20
|
-
ctrlKey: "Ctrl",
|
|
21
|
-
metaKey: "Meta",
|
|
22
|
-
shiftKey: "Shift"
|
|
23
|
-
};
|
|
24
|
-
/** `["altKey", "KeyT"]` → `"Alt+T"`, `["F8"]` → `"F8"`. */
|
|
25
|
-
function hotkeyLabel(hotkey) {
|
|
26
|
-
return hotkey.map((key) => MODIFIER_NAMES[key] ?? key.replace(/^Key(?=[A-Z]$)/, "").replace(/^Digit/, "")).join("+");
|
|
27
|
-
}
|
|
28
|
-
/** The region's built-in accessible name (conventions 11): `"Notifications (F8)"`. */
|
|
29
|
-
function regionLabel(hotkey) {
|
|
30
|
-
if (hotkey === null || hotkey.length === 0) return "Notifications";
|
|
31
|
-
return `Notifications (${hotkeyLabel(hotkey)})`;
|
|
32
|
-
}
|
|
33
|
-
/** The listed keys and modifiers, and no unlisted modifier (Ctrl+F8 is not F8). */
|
|
34
|
-
function matchesHotkey(hotkey, event) {
|
|
35
|
-
const flags = event;
|
|
36
|
-
for (const modifier of Object.keys(MODIFIER_NAMES)) if (flags[modifier] === true !== hotkey.includes(modifier)) return false;
|
|
37
|
-
return hotkey.every((key) => key in MODIFIER_NAMES || event.code === key);
|
|
38
|
-
}
|
|
39
|
-
/** No store: `useSyncExternalStore` only tells the hydration render from a client render. */
|
|
40
|
-
const subscribeNothing = () => () => {};
|
|
41
|
-
const onClient = () => true;
|
|
42
|
-
const onServerOrHydrating = () => false;
|
|
43
|
-
/**
|
|
44
|
-
* The element the region is portalled into for its whole client life. The library moves this
|
|
45
|
-
* element (between its inline anchor and the topmost modal dialog); React never sees the move, so
|
|
46
|
-
* the toasts keep their state (an Undo in flight stays pending). `display: contents`: no box.
|
|
47
|
-
*/
|
|
48
|
-
function createHost() {
|
|
49
|
-
if (typeof document === "undefined") return null;
|
|
50
|
-
const host = document.createElement("div");
|
|
51
|
-
host.style.display = "contents";
|
|
52
|
-
return host;
|
|
53
|
-
}
|
|
54
|
-
function makeEntry(options, flags) {
|
|
55
|
-
return {
|
|
56
|
-
options,
|
|
57
|
-
...flags,
|
|
58
|
-
item: {
|
|
59
|
-
...options,
|
|
60
|
-
id: options.id,
|
|
61
|
-
pending: flags.promisePending || flags.actionPending,
|
|
62
|
-
ending: flags.ending
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function withFlags(entry, flags) {
|
|
67
|
-
return makeEntry(entry.options, {
|
|
68
|
-
promisePending: flags.promisePending ?? entry.promisePending,
|
|
69
|
-
actionPending: flags.actionPending ?? entry.actionPending,
|
|
70
|
-
ending: flags.ending ?? entry.ending
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/** Rendered entries (the first `limit` open ones plus every ending one) and the queued count. */
|
|
74
|
-
function partition(entries, limit) {
|
|
75
|
-
const visible = [];
|
|
76
|
-
const queued = [];
|
|
77
|
-
let open = 0;
|
|
78
|
-
for (const entry of entries) if (entry.ending) visible.push(entry);
|
|
79
|
-
else if (open < limit) {
|
|
80
|
-
visible.push(entry);
|
|
81
|
-
open++;
|
|
82
|
-
} else queued.push(entry);
|
|
83
|
-
return {
|
|
84
|
-
visible,
|
|
85
|
-
queued
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
/** Plain text of a `ReactNode` that is text (queued toasts have no DOM to read yet). */
|
|
89
|
-
function plainText(node) {
|
|
90
|
-
if (typeof node === "string") return node;
|
|
91
|
-
if (typeof node === "number" || typeof node === "bigint") return String(node);
|
|
92
|
-
if (Array.isArray(node)) return node.map(plainText).join("");
|
|
93
|
-
return "";
|
|
94
|
-
}
|
|
95
21
|
/** Document order. */
|
|
96
22
|
function byDocumentPosition(a, b) {
|
|
97
23
|
if (a === b) return 0;
|
|
@@ -145,59 +71,17 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
|
|
|
145
71
|
hotkey,
|
|
146
72
|
announce
|
|
147
73
|
});
|
|
148
|
-
const container = useSyncExternalStore(subscribeModals, getTopmostModal, getServerTopmostModal);
|
|
149
74
|
const write = (next) => {
|
|
150
75
|
entriesRef.current = next;
|
|
151
76
|
setEntries(next);
|
|
152
77
|
};
|
|
153
|
-
const effectiveDuration = (entry) => {
|
|
154
|
-
const own = entry.options.duration;
|
|
155
|
-
if (own !== void 0) return own;
|
|
156
|
-
return entry.options.action !== void 0 ? null : latest.current.duration;
|
|
157
|
-
};
|
|
158
78
|
const syncTimers = () => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (entry.ending) continue;
|
|
166
|
-
const id = entry.options.id;
|
|
167
|
-
const ms = effectiveDuration(entry);
|
|
168
|
-
if (ms === null) continue;
|
|
169
|
-
live.add(id);
|
|
170
|
-
let timer = map.get(id);
|
|
171
|
-
if (timer === void 0 || timer.duration !== ms) {
|
|
172
|
-
if (timer?.handle != null) clearTimeout(timer.handle);
|
|
173
|
-
timer = {
|
|
174
|
-
duration: ms,
|
|
175
|
-
remaining: ms,
|
|
176
|
-
startedAt: 0,
|
|
177
|
-
handle: null
|
|
178
|
-
};
|
|
179
|
-
map.set(id, timer);
|
|
180
|
-
}
|
|
181
|
-
const run = !halted && !entry.item.pending && !suspended.current.has(id);
|
|
182
|
-
if (run && timer.handle === null) {
|
|
183
|
-
const current = timer;
|
|
184
|
-
current.startedAt = now;
|
|
185
|
-
current.handle = setTimeout(() => {
|
|
186
|
-
current.handle = null;
|
|
187
|
-
current.remaining = 0;
|
|
188
|
-
close([id], "timeout", void 0);
|
|
189
|
-
}, Math.max(0, current.remaining));
|
|
190
|
-
} else if (!run && timer.handle !== null) {
|
|
191
|
-
clearTimeout(timer.handle);
|
|
192
|
-
timer.handle = null;
|
|
193
|
-
timer.remaining -= now - timer.startedAt;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
for (const [id, timer] of map) {
|
|
197
|
-
if (live.has(id)) continue;
|
|
198
|
-
if (timer.handle !== null) clearTimeout(timer.handle);
|
|
199
|
-
map.delete(id);
|
|
200
|
-
}
|
|
79
|
+
syncToastTimers(timers.current, partition(entriesRef.current, latest.current.limit).visible, {
|
|
80
|
+
halted: !mounted.current || anyPause(pauses.current),
|
|
81
|
+
suspended: suspended.current,
|
|
82
|
+
defaultDuration: latest.current.duration,
|
|
83
|
+
expire: (id) => close([id], "timeout", void 0)
|
|
84
|
+
});
|
|
201
85
|
};
|
|
202
86
|
const setPause = (source, value) => {
|
|
203
87
|
if (pauses.current[source] === value) return;
|
|
@@ -254,11 +138,6 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
|
|
|
254
138
|
exitBaselines.current.set(id, animationBaseline(element));
|
|
255
139
|
}
|
|
256
140
|
};
|
|
257
|
-
const clearTimer = (id) => {
|
|
258
|
-
const timer = timers.current.get(id);
|
|
259
|
-
if (timer?.handle != null) clearTimeout(timer.handle);
|
|
260
|
-
timers.current.delete(id);
|
|
261
|
-
};
|
|
262
141
|
const scheduleCloseActions = (closed, reason, event) => {
|
|
263
142
|
for (const entry of closed) {
|
|
264
143
|
const closeAction = entry.options.closeAction;
|
|
@@ -294,86 +173,23 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
|
|
|
294
173
|
write(next);
|
|
295
174
|
};
|
|
296
175
|
const apply = (commands) => {
|
|
297
|
-
const
|
|
298
|
-
const
|
|
299
|
-
for (const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
const entry = next[i];
|
|
303
|
-
if (entry.ending) continue;
|
|
304
|
-
const id = entry.options.id;
|
|
305
|
-
if (command.id !== void 0 && id !== command.id) continue;
|
|
306
|
-
dismissed.push(entry);
|
|
307
|
-
if (roots.current.has(id)) next[i] = withFlags(entry, { ending: true });
|
|
308
|
-
else {
|
|
309
|
-
next.splice(i--, 1);
|
|
310
|
-
lastAnnounced.current.delete(id);
|
|
311
|
-
exitBaselines.current.delete(id);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
continue;
|
|
315
|
-
}
|
|
316
|
-
const index = next.findIndex((e) => e.options.id === command.id);
|
|
317
|
-
const existing = index === -1 ? void 0 : next[index];
|
|
318
|
-
if (command.kind === "add") {
|
|
319
|
-
const options = {
|
|
320
|
-
...command.options,
|
|
321
|
-
id: command.id
|
|
322
|
-
};
|
|
323
|
-
if (existing !== void 0 && !existing.ending) {
|
|
324
|
-
next[index] = makeEntry({
|
|
325
|
-
...existing.options,
|
|
326
|
-
...options
|
|
327
|
-
}, {
|
|
328
|
-
promisePending: command.pending || existing.promisePending,
|
|
329
|
-
actionPending: existing.actionPending,
|
|
330
|
-
ending: false
|
|
331
|
-
});
|
|
332
|
-
continue;
|
|
333
|
-
}
|
|
334
|
-
if (existing !== void 0) {
|
|
335
|
-
next.splice(index, 1);
|
|
336
|
-
clearTimer(command.id);
|
|
337
|
-
lastAnnounced.current.delete(command.id);
|
|
338
|
-
exitBaselines.current.delete(command.id);
|
|
339
|
-
}
|
|
340
|
-
next.push(makeEntry(options, {
|
|
341
|
-
promisePending: command.pending,
|
|
342
|
-
actionPending: false,
|
|
343
|
-
ending: false
|
|
344
|
-
}));
|
|
345
|
-
addedSinceEffect.current = true;
|
|
346
|
-
} else {
|
|
347
|
-
if (existing === void 0) {
|
|
348
|
-
if (isDev && !command.settle) console.error(`toast.update: no toast with id "${command.id}"; the update is ignored.`);
|
|
349
|
-
continue;
|
|
350
|
-
}
|
|
351
|
-
if (existing.ending) continue;
|
|
352
|
-
next[index] = makeEntry(command.settle ? {
|
|
353
|
-
...command.options,
|
|
354
|
-
id: command.id
|
|
355
|
-
} : {
|
|
356
|
-
...existing.options,
|
|
357
|
-
...command.options,
|
|
358
|
-
id: command.id
|
|
359
|
-
}, {
|
|
360
|
-
promisePending: command.settle ? false : existing.promisePending,
|
|
361
|
-
actionPending: existing.actionPending,
|
|
362
|
-
ending: false
|
|
363
|
-
});
|
|
364
|
-
}
|
|
176
|
+
const result = applyCommands(entriesRef.current, commands, (id) => roots.current.has(id));
|
|
177
|
+
for (const id of result.replaced) clearToastTimers(timers.current, id);
|
|
178
|
+
for (const id of result.forgotten) {
|
|
179
|
+
lastAnnounced.current.delete(id);
|
|
180
|
+
exitBaselines.current.delete(id);
|
|
365
181
|
}
|
|
366
|
-
if (
|
|
367
|
-
|
|
182
|
+
if (result.added) addedSinceEffect.current = true;
|
|
183
|
+
if (isDev) for (const id of result.missing) console.error(`toast.update: no toast with id "${id}"; the update is ignored.`);
|
|
184
|
+
if (result.dismissed.length === 0) {
|
|
185
|
+
write(result.next);
|
|
368
186
|
return;
|
|
369
187
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
snapshotExitBaselines(leaving);
|
|
374
|
-
write(next);
|
|
188
|
+
moveFocusOut(result.leaving);
|
|
189
|
+
snapshotExitBaselines(result.leaving);
|
|
190
|
+
write(result.next);
|
|
375
191
|
syncTimers();
|
|
376
|
-
scheduleCloseActions(dismissed, "dismiss", void 0);
|
|
192
|
+
scheduleCloseActions(result.dismissed, "dismiss", void 0);
|
|
377
193
|
};
|
|
378
194
|
const setActionPending = (id, pending) => {
|
|
379
195
|
const index = entriesRef.current.findIndex((e) => e.options.id === id);
|
|
@@ -425,8 +241,7 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
|
|
|
425
241
|
/** Forgets the queue of the previous manager (its own copy is retained by that manager). */
|
|
426
242
|
const reset = () => {
|
|
427
243
|
moveFocusOut(new Set(entriesRef.current.filter((e) => !e.ending).map((e) => e.options.id)));
|
|
428
|
-
|
|
429
|
-
timers.current.clear();
|
|
244
|
+
clearToastTimers(timers.current);
|
|
430
245
|
lastAnnounced.current.clear();
|
|
431
246
|
exitBaselines.current.clear();
|
|
432
247
|
write([]);
|
|
@@ -503,8 +318,7 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
|
|
|
503
318
|
doc.removeEventListener("visibilitychange", onVisibility);
|
|
504
319
|
view.removeEventListener("blur", onWindowBlur);
|
|
505
320
|
view.removeEventListener("focus", onWindowFocus);
|
|
506
|
-
|
|
507
|
-
map.clear();
|
|
321
|
+
clearToastTimers(map);
|
|
508
322
|
};
|
|
509
323
|
}, [handlers, rejected]);
|
|
510
324
|
const hotkeyKey = hotkey === null ? null : hotkey.join("\0");
|
|
@@ -524,21 +338,7 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
|
|
|
524
338
|
doc.addEventListener("keydown", onKeyDown);
|
|
525
339
|
return () => doc.removeEventListener("keydown", onKeyDown);
|
|
526
340
|
}, [hotkeyKey, rejected]);
|
|
527
|
-
const portalled =
|
|
528
|
-
const [host] = useState(createHost);
|
|
529
|
-
const anchorRef = useRef(null);
|
|
530
|
-
useLayoutEffect(() => {
|
|
531
|
-
if (host === null) return;
|
|
532
|
-
return () => host.remove();
|
|
533
|
-
}, [host]);
|
|
534
|
-
useLayoutEffect(() => {
|
|
535
|
-
if (host === null || !portalled) return;
|
|
536
|
-
const target = container ?? anchorRef.current;
|
|
537
|
-
if (target === null || host.parentNode === target) return;
|
|
538
|
-
const moved = host.parentNode !== null;
|
|
539
|
-
target.append(host);
|
|
540
|
-
if (moved) setPause("hover", false);
|
|
541
|
-
});
|
|
341
|
+
const { portalled, host, anchorRef } = useModalPortalHost(() => setPause("hover", false));
|
|
542
342
|
useLayoutEffect(() => {
|
|
543
343
|
const region = regionRef.current;
|
|
544
344
|
const current = entriesRef.current;
|
|
@@ -547,12 +347,7 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
|
|
|
547
347
|
setPause("focus", false);
|
|
548
348
|
}
|
|
549
349
|
if (region !== null && region.isConnected && region.hasAttribute("popover")) {
|
|
550
|
-
|
|
551
|
-
try {
|
|
552
|
-
open = region.matches(":popover-open");
|
|
553
|
-
} catch {
|
|
554
|
-
open = false;
|
|
555
|
-
}
|
|
350
|
+
const open = isPopoverOpen(region);
|
|
556
351
|
try {
|
|
557
352
|
if (current.length > 0) {
|
|
558
353
|
if (!open) region.showPopover();
|
|
@@ -577,7 +372,7 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
|
|
|
577
372
|
syncTimers();
|
|
578
373
|
});
|
|
579
374
|
const insideDialog = use(DialogContext) !== null;
|
|
580
|
-
useDevWarning(insideDialog, "Toast.Viewport: rendered inside a Dialog. The region would close with the dialog; render the Viewport once near the root of the app (it moves into open modal Dialogs by itself).");
|
|
375
|
+
useDevWarning(insideDialog, isDev && "Toast.Viewport: rendered inside a Dialog. The region would close with the dialog; render the Viewport once near the root of the app (it moves into open modal Dialogs by itself).");
|
|
581
376
|
const { visible, queued } = partition(entries, limit);
|
|
582
377
|
const state = {
|
|
583
378
|
toasts: visible.map((e) => e.item),
|