@funstack/ui 0.1.0-alpha.1 → 0.1.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion/accordion-context.mjs.map +1 -1
- package/dist/accordion/accordion-item.mjs +20 -6
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.mjs +4 -5
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +35 -16
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +6 -7
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/button/button.d.mts +78 -0
- package/dist/button/button.d.mts.map +1 -0
- package/dist/button/button.mjs +77 -0
- package/dist/button/button.mjs.map +1 -0
- package/dist/button/index.d.mts +3 -0
- package/dist/button/index.mjs +1 -0
- package/dist/checkbox/checkbox.d.mts +5 -3
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +27 -11
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +2 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +5 -3
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +2 -2
- package/dist/checkbox-group/checkbox-group-root.d.mts +5 -2
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +25 -6
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts +37 -0
- package/dist/combobox/combobox-clear.d.mts.map +1 -0
- package/dist/combobox/combobox-clear.mjs +64 -0
- package/dist/combobox/combobox-clear.mjs.map +1 -0
- package/dist/combobox/combobox-context.mjs +23 -0
- package/dist/combobox/combobox-context.mjs.map +1 -0
- package/dist/combobox/combobox-group.d.mts +72 -0
- package/dist/combobox/combobox-group.d.mts.map +1 -0
- package/dist/combobox/combobox-group.mjs +104 -0
- package/dist/combobox/combobox-group.mjs.map +1 -0
- package/dist/combobox/combobox-input.d.mts +42 -0
- package/dist/combobox/combobox-input.d.mts.map +1 -0
- package/dist/combobox/combobox-input.mjs +102 -0
- package/dist/combobox/combobox-input.mjs.map +1 -0
- package/dist/combobox/combobox-label.d.mts +22 -0
- package/dist/combobox/combobox-label.d.mts.map +1 -0
- package/dist/combobox/combobox-label.mjs +32 -0
- package/dist/combobox/combobox-label.mjs.map +1 -0
- package/dist/combobox/combobox-list.d.mts +37 -0
- package/dist/combobox/combobox-list.d.mts.map +1 -0
- package/dist/combobox/combobox-list.mjs +71 -0
- package/dist/combobox/combobox-list.mjs.map +1 -0
- package/dist/combobox/combobox-option.d.mts +45 -0
- package/dist/combobox/combobox-option.d.mts.map +1 -0
- package/dist/combobox/combobox-option.mjs +88 -0
- package/dist/combobox/combobox-option.mjs.map +1 -0
- package/dist/combobox/combobox-popup.d.mts +49 -0
- package/dist/combobox/combobox-popup.d.mts.map +1 -0
- package/dist/combobox/combobox-popup.mjs +91 -0
- package/dist/combobox/combobox-popup.mjs.map +1 -0
- package/dist/combobox/combobox-root.d.mts +136 -0
- package/dist/combobox/combobox-root.d.mts.map +1 -0
- package/dist/combobox/combobox-root.mjs +523 -0
- package/dist/combobox/combobox-root.mjs.map +1 -0
- package/dist/combobox/combobox-trigger.d.mts +40 -0
- package/dist/combobox/combobox-trigger.d.mts.map +1 -0
- package/dist/combobox/combobox-trigger.mjs +99 -0
- package/dist/combobox/combobox-trigger.mjs.map +1 -0
- package/dist/combobox/index.d.mts +36 -0
- package/dist/combobox/index.d.mts.map +1 -0
- package/dist/combobox/index.mjs +36 -0
- package/dist/combobox/index.mjs.map +1 -0
- package/dist/csp/csp-provider.d.mts +25 -0
- package/dist/csp/csp-provider.d.mts.map +1 -0
- package/dist/csp/csp-provider.mjs +24 -0
- package/dist/csp/csp-provider.mjs.map +1 -0
- package/dist/csp/index.d.mts +3 -0
- package/dist/csp/index.mjs +3 -0
- package/dist/csp/style-hashes.d.mts +19 -0
- package/dist/csp/style-hashes.d.mts.map +1 -0
- package/dist/csp/style-hashes.mjs +21 -0
- package/dist/csp/style-hashes.mjs.map +1 -0
- package/dist/dialog/dialog-close.d.mts +22 -10
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +41 -25
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts +23 -10
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +51 -32
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +10 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +118 -45
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +14 -8
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +68 -13
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +11 -5
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +16 -8
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +4 -2
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +4 -2
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/field/field-control.d.mts +33 -0
- package/dist/field/field-control.d.mts.map +1 -0
- package/dist/field/field-control.mjs +68 -0
- package/dist/field/field-control.mjs.map +1 -0
- package/dist/field/field-description.d.mts +24 -0
- package/dist/field/field-description.d.mts.map +1 -0
- package/dist/field/field-description.mjs +34 -0
- package/dist/field/field-description.mjs.map +1 -0
- package/dist/field/field-error.d.mts +30 -0
- package/dist/field/field-error.d.mts.map +1 -0
- package/dist/field/field-error.mjs +42 -0
- package/dist/field/field-error.mjs.map +1 -0
- package/dist/field/field-label.d.mts +25 -0
- package/dist/field/field-label.d.mts.map +1 -0
- package/dist/field/field-label.mjs +46 -0
- package/dist/field/field-label.mjs.map +1 -0
- package/dist/field/field-root.d.mts +53 -0
- package/dist/field/field-root.d.mts.map +1 -0
- package/dist/field/field-root.mjs +319 -0
- package/dist/field/field-root.mjs.map +1 -0
- package/dist/field/index.d.mts +18 -0
- package/dist/field/index.d.mts.map +1 -0
- package/dist/field/index.mjs +17 -0
- package/dist/field/index.mjs.map +1 -0
- package/dist/form/form-root.d.mts +58 -0
- package/dist/form/form-root.d.mts.map +1 -0
- package/dist/form/form-root.mjs +147 -0
- package/dist/form/form-root.mjs.map +1 -0
- package/dist/form/form-submit.d.mts +34 -0
- package/dist/form/form-submit.d.mts.map +1 -0
- package/dist/form/form-submit.mjs +53 -0
- package/dist/form/form-submit.mjs.map +1 -0
- package/dist/form/index.d.mts +11 -0
- package/dist/form/index.d.mts.map +1 -0
- package/dist/form/index.mjs +11 -0
- package/dist/form/index.mjs.map +1 -0
- package/dist/index.d.mts +79 -4
- package/dist/index.mjs +16 -1
- package/dist/internal/anchor-position.d.mts +11 -3
- package/dist/internal/anchor-position.d.mts.map +1 -1
- package/dist/internal/anchor-position.mjs +180 -6
- package/dist/internal/anchor-position.mjs.map +1 -1
- package/dist/internal/announce.mjs +53 -0
- package/dist/internal/announce.mjs.map +1 -0
- package/dist/internal/content-focus-probe.mjs +42 -0
- package/dist/internal/content-focus-probe.mjs.map +1 -0
- package/dist/internal/csp-context.mjs +8 -0
- package/dist/internal/csp-context.mjs.map +1 -0
- package/dist/internal/decimal.mjs +27 -0
- package/dist/internal/decimal.mjs.map +1 -0
- package/dist/internal/dev-warn.mjs +17 -0
- package/dist/internal/dev-warn.mjs.map +1 -0
- package/dist/internal/field-context.d.mts +19 -0
- package/dist/internal/field-context.d.mts.map +1 -0
- package/dist/internal/field-context.mjs +14 -0
- package/dist/internal/field-context.mjs.map +1 -0
- package/dist/internal/focus-first-invalid.mjs +67 -0
- package/dist/internal/focus-first-invalid.mjs.map +1 -0
- package/dist/internal/form-status-watcher.mjs +31 -0
- package/dist/internal/form-status-watcher.mjs.map +1 -0
- package/dist/internal/modal-registry.mjs +39 -0
- package/dist/internal/modal-registry.mjs.map +1 -0
- package/dist/internal/platform-attributes.d.mts +12 -1
- package/dist/internal/platform-attributes.d.mts.map +1 -1
- package/dist/internal/range-value.mjs +51 -0
- package/dist/internal/range-value.mjs.map +1 -0
- package/dist/internal/render-element.mjs +67 -0
- package/dist/internal/render-element.mjs.map +1 -0
- package/dist/internal/toolbar-context.mjs +17 -0
- package/dist/internal/toolbar-context.mjs.map +1 -0
- package/dist/internal/tooltip-warm.mjs +29 -0
- package/dist/internal/tooltip-warm.mjs.map +1 -0
- package/dist/internal/types.d.mts +11 -1
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-action-trigger.mjs +17 -6
- package/dist/internal/use-action-trigger.mjs.map +1 -1
- package/dist/internal/use-controllable-action.mjs +35 -13
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-exit-animation.mjs +26 -6
- package/dist/internal/use-exit-animation.mjs.map +1 -1
- package/dist/internal/use-field-control.mjs +109 -0
- package/dist/internal/use-field-control.mjs.map +1 -0
- package/dist/internal/use-form-owner-event.mjs +44 -0
- package/dist/internal/use-form-owner-event.mjs.map +1 -0
- package/dist/internal/use-form-reset.mjs +12 -31
- package/dist/internal/use-form-reset.mjs.map +1 -1
- package/dist/internal/use-hydrated-mount.mjs +21 -0
- package/dist/internal/use-hydrated-mount.mjs.map +1 -0
- package/dist/internal/use-latest.mjs +32 -0
- package/dist/internal/use-latest.mjs.map +1 -0
- package/dist/internal/use-modal-registration.mjs +47 -0
- package/dist/internal/use-modal-registration.mjs.map +1 -0
- package/dist/internal/use-native-group-reconciliation.mjs +6 -5
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-native-select-value.mjs +184 -0
- package/dist/internal/use-native-select-value.mjs.map +1 -0
- package/dist/internal/use-popover-popup.mjs +33 -28
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-root.mjs +59 -24
- package/dist/internal/use-popover-root.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.mjs +6 -5
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/use-render.mjs +12 -35
- package/dist/internal/use-render.mjs.map +1 -1
- package/dist/internal/use-resolved-placement.mjs +146 -0
- package/dist/internal/use-resolved-placement.mjs.map +1 -0
- package/dist/internal/use-roving-focus.mjs +301 -0
- package/dist/internal/use-roving-focus.mjs.map +1 -0
- package/dist/internal/validity.d.mts +24 -0
- package/dist/internal/validity.d.mts.map +1 -0
- package/dist/internal/validity.mjs +108 -0
- package/dist/internal/validity.mjs.map +1 -0
- package/dist/menu/index.d.mts +5 -1
- package/dist/menu/index.d.mts.map +1 -1
- package/dist/menu/index.mjs +5 -1
- package/dist/menu/index.mjs.map +1 -1
- package/dist/menu/menu-checkbox-item.mjs +2 -1
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +46 -0
- package/dist/menu/menu-context-trigger.d.mts.map +1 -0
- package/dist/menu/menu-context-trigger.mjs +405 -0
- package/dist/menu/menu-context-trigger.mjs.map +1 -0
- package/dist/menu/menu-context.mjs +44 -1
- package/dist/menu/menu-context.mjs.map +1 -1
- package/dist/menu/menu-dom.mjs +49 -3
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +4 -3
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-item.d.mts +6 -2
- package/dist/menu/menu-item.d.mts.map +1 -1
- package/dist/menu/menu-item.mjs +7 -4
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-popup.d.mts +36 -8
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +219 -22
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.mjs +10 -5
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.mjs +2 -1
- package/dist/menu/menu-radio-item.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +5 -0
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +57 -7
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +28 -12
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +8 -4
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +18 -7
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/meter/index.d.mts +24 -0
- package/dist/meter/index.d.mts.map +1 -0
- package/dist/meter/index.mjs +23 -0
- package/dist/meter/index.mjs.map +1 -0
- package/dist/meter/meter-context.mjs +13 -0
- package/dist/meter/meter-context.mjs.map +1 -0
- package/dist/meter/meter-indicator.d.mts +19 -0
- package/dist/meter/meter-indicator.d.mts.map +1 -0
- package/dist/meter/meter-indicator.mjs +25 -0
- package/dist/meter/meter-indicator.mjs.map +1 -0
- package/dist/meter/meter-label.d.mts +19 -0
- package/dist/meter/meter-label.d.mts.map +1 -0
- package/dist/meter/meter-label.mjs +28 -0
- package/dist/meter/meter-label.mjs.map +1 -0
- package/dist/meter/meter-region.d.mts +4 -0
- package/dist/meter/meter-region.d.mts.map +1 -0
- package/dist/meter/meter-region.mjs +39 -0
- package/dist/meter/meter-region.mjs.map +1 -0
- package/dist/meter/meter-root.d.mts +71 -0
- package/dist/meter/meter-root.d.mts.map +1 -0
- package/dist/meter/meter-root.mjs +83 -0
- package/dist/meter/meter-root.mjs.map +1 -0
- package/dist/meter/meter-track.d.mts +19 -0
- package/dist/meter/meter-track.d.mts.map +1 -0
- package/dist/meter/meter-track.mjs +25 -0
- package/dist/meter/meter-track.mjs.map +1 -0
- package/dist/meter/meter-value.d.mts +20 -0
- package/dist/meter/meter-value.d.mts.map +1 -0
- package/dist/meter/meter-value.mjs +29 -0
- package/dist/meter/meter-value.mjs.map +1 -0
- package/dist/number-field/index.d.mts +26 -0
- package/dist/number-field/index.d.mts.map +1 -0
- package/dist/number-field/index.mjs +26 -0
- package/dist/number-field/index.mjs.map +1 -0
- package/dist/number-field/number-field-arithmetic.mjs +78 -0
- package/dist/number-field/number-field-arithmetic.mjs.map +1 -0
- package/dist/number-field/number-field-context.d.mts +2 -0
- package/dist/number-field/number-field-context.mjs +13 -0
- package/dist/number-field/number-field-context.mjs.map +1 -0
- package/dist/number-field/number-field-decrement.d.mts +17 -0
- package/dist/number-field/number-field-decrement.d.mts.map +1 -0
- package/dist/number-field/number-field-decrement.mjs +20 -0
- package/dist/number-field/number-field-decrement.mjs.map +1 -0
- package/dist/number-field/number-field-format.mjs +279 -0
- package/dist/number-field/number-field-format.mjs.map +1 -0
- package/dist/number-field/number-field-increment.d.mts +37 -0
- package/dist/number-field/number-field-increment.d.mts.map +1 -0
- package/dist/number-field/number-field-increment.mjs +71 -0
- package/dist/number-field/number-field-increment.mjs.map +1 -0
- package/dist/number-field/number-field-input.d.mts +29 -0
- package/dist/number-field/number-field-input.d.mts.map +1 -0
- package/dist/number-field/number-field-input.mjs +163 -0
- package/dist/number-field/number-field-input.mjs.map +1 -0
- package/dist/number-field/number-field-label.d.mts +23 -0
- package/dist/number-field/number-field-label.d.mts.map +1 -0
- package/dist/number-field/number-field-label.mjs +47 -0
- package/dist/number-field/number-field-label.mjs.map +1 -0
- package/dist/number-field/number-field-root.d.mts +108 -0
- package/dist/number-field/number-field-root.d.mts.map +1 -0
- package/dist/number-field/number-field-root.mjs +523 -0
- package/dist/number-field/number-field-root.mjs.map +1 -0
- package/dist/number-field/use-step-button.mjs +112 -0
- package/dist/number-field/use-step-button.mjs.map +1 -0
- package/dist/popover/popover-close.d.mts +9 -3
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +13 -7
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +21 -7
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +23 -8
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.mjs +1 -1
- package/dist/popover/popover-trigger.d.mts +8 -4
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +3 -3
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/index.d.mts +24 -0
- package/dist/progress/index.d.mts.map +1 -0
- package/dist/progress/index.mjs +24 -0
- package/dist/progress/index.mjs.map +1 -0
- package/dist/progress/progress-context.mjs +13 -0
- package/dist/progress/progress-context.mjs.map +1 -0
- package/dist/progress/progress-indicator.d.mts +19 -0
- package/dist/progress/progress-indicator.d.mts.map +1 -0
- package/dist/progress/progress-indicator.mjs +29 -0
- package/dist/progress/progress-indicator.mjs.map +1 -0
- package/dist/progress/progress-label.d.mts +19 -0
- package/dist/progress/progress-label.d.mts.map +1 -0
- package/dist/progress/progress-label.mjs +30 -0
- package/dist/progress/progress-label.mjs.map +1 -0
- package/dist/progress/progress-root.d.mts +68 -0
- package/dist/progress/progress-root.d.mts.map +1 -0
- package/dist/progress/progress-root.mjs +80 -0
- package/dist/progress/progress-root.mjs.map +1 -0
- package/dist/progress/progress-track.d.mts +19 -0
- package/dist/progress/progress-track.d.mts.map +1 -0
- package/dist/progress/progress-track.mjs +29 -0
- package/dist/progress/progress-track.mjs.map +1 -0
- package/dist/progress/progress-value.d.mts +20 -0
- package/dist/progress/progress-value.d.mts.map +1 -0
- package/dist/progress/progress-value.mjs +33 -0
- package/dist/progress/progress-value.mjs.map +1 -0
- package/dist/radio-group/radio-group-item.mjs +2 -2
- package/dist/radio-group/radio-group-root.d.mts +4 -2
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +35 -9
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/index.d.mts +30 -0
- package/dist/select/index.d.mts.map +1 -0
- package/dist/select/index.mjs +30 -0
- package/dist/select/index.mjs.map +1 -0
- package/dist/select/select-context.mjs +13 -0
- package/dist/select/select-context.mjs.map +1 -0
- package/dist/select/select-dom.mjs +44 -0
- package/dist/select/select-dom.mjs.map +1 -0
- package/dist/select/select-group-label.d.mts +22 -0
- package/dist/select/select-group-label.d.mts.map +1 -0
- package/dist/select/select-group-label.mjs +39 -0
- package/dist/select/select-group-label.mjs.map +1 -0
- package/dist/select/select-group.d.mts +28 -0
- package/dist/select/select-group.d.mts.map +1 -0
- package/dist/select/select-group.mjs +47 -0
- package/dist/select/select-group.mjs.map +1 -0
- package/dist/select/select-option.d.mts +42 -0
- package/dist/select/select-option.d.mts.map +1 -0
- package/dist/select/select-option.mjs +65 -0
- package/dist/select/select-option.mjs.map +1 -0
- package/dist/select/select-root.d.mts +68 -0
- package/dist/select/select-root.d.mts.map +1 -0
- package/dist/select/select-root.mjs +114 -0
- package/dist/select/select-root.mjs.map +1 -0
- package/dist/select/select-separator.d.mts +20 -0
- package/dist/select/select-separator.d.mts.map +1 -0
- package/dist/select/select-separator.mjs +30 -0
- package/dist/select/select-separator.mjs.map +1 -0
- package/dist/select/select-trigger.d.mts +29 -0
- package/dist/select/select-trigger.d.mts.map +1 -0
- package/dist/select/select-trigger.mjs +48 -0
- package/dist/select/select-trigger.mjs.map +1 -0
- package/dist/select/select-value.d.mts +31 -0
- package/dist/select/select-value.d.mts.map +1 -0
- package/dist/select/select-value.mjs +101 -0
- package/dist/select/select-value.mjs.map +1 -0
- package/dist/slider/index.d.mts +32 -0
- package/dist/slider/index.d.mts.map +1 -0
- package/dist/slider/index.mjs +27 -0
- package/dist/slider/index.mjs.map +1 -0
- package/dist/slider/slider-arithmetic.mjs +104 -0
- package/dist/slider/slider-arithmetic.mjs.map +1 -0
- package/dist/slider/slider-context.mjs +13 -0
- package/dist/slider/slider-context.mjs.map +1 -0
- package/dist/slider/slider-indicator.d.mts +22 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -0
- package/dist/slider/slider-indicator.mjs +36 -0
- package/dist/slider/slider-indicator.mjs.map +1 -0
- package/dist/slider/slider-label.d.mts +23 -0
- package/dist/slider/slider-label.d.mts.map +1 -0
- package/dist/slider/slider-label.mjs +44 -0
- package/dist/slider/slider-label.mjs.map +1 -0
- package/dist/slider/slider-root.d.mts +111 -0
- package/dist/slider/slider-root.d.mts.map +1 -0
- package/dist/slider/slider-root.mjs +583 -0
- package/dist/slider/slider-root.mjs.map +1 -0
- package/dist/slider/slider-thumb.d.mts +58 -0
- package/dist/slider/slider-thumb.d.mts.map +1 -0
- package/dist/slider/slider-thumb.mjs +146 -0
- package/dist/slider/slider-thumb.mjs.map +1 -0
- package/dist/slider/slider-track.d.mts +29 -0
- package/dist/slider/slider-track.d.mts.map +1 -0
- package/dist/slider/slider-track.mjs +55 -0
- package/dist/slider/slider-track.mjs.map +1 -0
- package/dist/slider/slider-value.d.mts +34 -0
- package/dist/slider/slider-value.d.mts.map +1 -0
- package/dist/slider/slider-value.mjs +38 -0
- package/dist/slider/slider-value.mjs.map +1 -0
- package/dist/switch/switch.d.mts +5 -3
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +26 -10
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/tabs-indicator.mjs +2 -1
- package/dist/tabs/tabs-indicator.mjs.map +1 -1
- package/dist/tabs/tabs-list.mjs +1 -1
- package/dist/tabs/tabs-panel.mjs +1 -1
- package/dist/tabs/tabs-root.mjs +15 -5
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.mjs +3 -2
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/index.d.mts +25 -0
- package/dist/toast/index.d.mts.map +1 -0
- package/dist/toast/index.mjs +26 -0
- package/dist/toast/index.mjs.map +1 -0
- package/dist/toast/toast-action.d.mts +40 -0
- package/dist/toast/toast-action.d.mts.map +1 -0
- package/dist/toast/toast-action.mjs +67 -0
- package/dist/toast/toast-action.mjs.map +1 -0
- package/dist/toast/toast-close.d.mts +25 -0
- package/dist/toast/toast-close.d.mts.map +1 -0
- package/dist/toast/toast-close.mjs +47 -0
- package/dist/toast/toast-close.mjs.map +1 -0
- package/dist/toast/toast-context.mjs +19 -0
- package/dist/toast/toast-context.mjs.map +1 -0
- package/dist/toast/toast-description.d.mts +24 -0
- package/dist/toast/toast-description.d.mts.map +1 -0
- package/dist/toast/toast-description.mjs +35 -0
- package/dist/toast/toast-description.mjs.map +1 -0
- package/dist/toast/toast-root.d.mts +43 -0
- package/dist/toast/toast-root.d.mts.map +1 -0
- package/dist/toast/toast-root.mjs +205 -0
- package/dist/toast/toast-root.mjs.map +1 -0
- package/dist/toast/toast-title.d.mts +24 -0
- package/dist/toast/toast-title.d.mts.map +1 -0
- package/dist/toast/toast-title.mjs +33 -0
- package/dist/toast/toast-title.mjs.map +1 -0
- package/dist/toast/toast-viewport.d.mts +52 -0
- package/dist/toast/toast-viewport.d.mts.map +1 -0
- package/dist/toast/toast-viewport.mjs +644 -0
- package/dist/toast/toast-viewport.mjs.map +1 -0
- package/dist/toast/toast.d.mts +119 -0
- package/dist/toast/toast.d.mts.map +1 -0
- package/dist/toast/toast.mjs +157 -0
- package/dist/toast/toast.mjs.map +1 -0
- package/dist/toggle/toggle.d.mts +4 -1
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +16 -9
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/index.d.mts +16 -0
- package/dist/toggle-group/index.d.mts.map +1 -0
- package/dist/toggle-group/index.mjs +15 -0
- package/dist/toggle-group/index.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-context.d.mts +4 -0
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-context.mjs +13 -0
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-item.d.mts +51 -0
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-item.mjs +68 -0
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-root.d.mts +95 -0
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-root.mjs +211 -0
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -0
- package/dist/toolbar/index.d.mts +17 -0
- package/dist/toolbar/index.d.mts.map +1 -0
- package/dist/toolbar/index.mjs +17 -0
- package/dist/toolbar/index.mjs.map +1 -0
- package/dist/toolbar/toolbar-root.d.mts +38 -0
- package/dist/toolbar/toolbar-root.d.mts.map +1 -0
- package/dist/toolbar/toolbar-root.mjs +66 -0
- package/dist/toolbar/toolbar-root.mjs.map +1 -0
- package/dist/toolbar/toolbar-separator.d.mts +25 -0
- package/dist/toolbar/toolbar-separator.d.mts.map +1 -0
- package/dist/toolbar/toolbar-separator.mjs +31 -0
- package/dist/toolbar/toolbar-separator.mjs.map +1 -0
- package/dist/tooltip/index.d.mts +8 -5
- package/dist/tooltip/index.d.mts.map +1 -1
- package/dist/tooltip/index.mjs +6 -3
- package/dist/tooltip/index.mjs.map +1 -1
- package/dist/tooltip/tooltip-arrow.d.mts +30 -0
- package/dist/tooltip/tooltip-arrow.d.mts.map +1 -0
- package/dist/tooltip/tooltip-arrow.mjs +45 -0
- package/dist/tooltip/tooltip-arrow.mjs.map +1 -0
- package/dist/tooltip/tooltip-context.d.mts +7 -0
- package/dist/tooltip/tooltip-context.d.mts.map +1 -1
- package/dist/tooltip/tooltip-context.mjs +2 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts +27 -6
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +36 -7
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +18 -2
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +9 -2
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +23 -6
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/dist/tooltip/use-tooltip-interaction.mjs +126 -76
- package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
- package/package.json +14 -1
|
@@ -0,0 +1,644 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createActionDetails } from "../internal/action-details.mjs";
|
|
3
|
+
import { dataAttr } from "../internal/data-attr.mjs";
|
|
4
|
+
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
5
|
+
import { useRender } from "../internal/use-render.mjs";
|
|
6
|
+
import { useLatest } from "../internal/use-latest.mjs";
|
|
7
|
+
import { DialogContext } from "../dialog/dialog-context.mjs";
|
|
8
|
+
import { animationBaseline } from "../internal/use-exit-animation.mjs";
|
|
9
|
+
import { getServerTopmostModal, getTopmostModal, subscribeModals } from "../internal/modal-registry.mjs";
|
|
10
|
+
import { ToastViewportContext } from "./toast-context.mjs";
|
|
11
|
+
import { toast, toastManagerInternals } from "./toast.mjs";
|
|
12
|
+
import { use, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, useTransition } from "react";
|
|
13
|
+
import { createPortal } from "react-dom";
|
|
14
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
//#region src/toast/toast-viewport.tsx
|
|
16
|
+
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
|
+
/** Document order. */
|
|
96
|
+
function byDocumentPosition(a, b) {
|
|
97
|
+
if (a === b) return 0;
|
|
98
|
+
return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
99
|
+
}
|
|
100
|
+
function anyPause(sources) {
|
|
101
|
+
return sources.hover || sources.focus || sources.hidden || sources.blurred;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The toast region: a `<section popover="manual">` named "Notifications (F8)", shown in the top
|
|
105
|
+
* layer while it has toasts. Owns the queue (urgent state fed by `toast()`), the timers and their
|
|
106
|
+
* pausing, the hotkey, focus return, announcements through `document.ariaNotify()`, and the move
|
|
107
|
+
* into the topmost open modal `Dialog` (a region outside it would be inert).
|
|
108
|
+
*
|
|
109
|
+
* Owned keys (conventions 1.2): `popover`, `aria-label` (the consumer's own `aria-label` wins
|
|
110
|
+
* verbatim), `data-paused`, `data-empty`, and the pointer / focus handlers.
|
|
111
|
+
*/
|
|
112
|
+
function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DEFAULT_HOTKEY, announce, children, className, style, render, ...rest }) {
|
|
113
|
+
const [entries, setEntries] = useState([]);
|
|
114
|
+
const entriesRef = useRef(entries);
|
|
115
|
+
const listener = useRef(null);
|
|
116
|
+
listener.current ??= {
|
|
117
|
+
restore: (toasts) => handlers.current.restore(toasts),
|
|
118
|
+
apply: (commands) => handlers.current.apply(commands),
|
|
119
|
+
retain: () => handlers.current.retain()
|
|
120
|
+
};
|
|
121
|
+
const [rejected, setRejected] = useState(() => toastManagerInternals(manager).isTaken(listener.current));
|
|
122
|
+
const [, startCloseTransition] = useTransition();
|
|
123
|
+
const regionRef = useRef(null);
|
|
124
|
+
const roots = useRef(/* @__PURE__ */ new Map());
|
|
125
|
+
const suspended = useRef(/* @__PURE__ */ new Set());
|
|
126
|
+
const timers = useRef(/* @__PURE__ */ new Map());
|
|
127
|
+
const pauses = useRef({
|
|
128
|
+
hover: false,
|
|
129
|
+
focus: false,
|
|
130
|
+
hidden: false,
|
|
131
|
+
blurred: false
|
|
132
|
+
});
|
|
133
|
+
const [paused, setPaused] = useState(false);
|
|
134
|
+
/** Where focus goes back to once the last toast holding it leaves (design 7). */
|
|
135
|
+
const returnTarget = useRef(null);
|
|
136
|
+
const lastAnnounced = useRef(/* @__PURE__ */ new Map());
|
|
137
|
+
/** Per closing toast: the animations already running before `data-ending` applied. */
|
|
138
|
+
const exitBaselines = useRef(/* @__PURE__ */ new Map());
|
|
139
|
+
const announceBatch = useRef([]);
|
|
140
|
+
const addedSinceEffect = useRef(false);
|
|
141
|
+
const mounted = useRef(false);
|
|
142
|
+
const latest = useLatest({
|
|
143
|
+
limit,
|
|
144
|
+
duration,
|
|
145
|
+
hotkey,
|
|
146
|
+
announce
|
|
147
|
+
});
|
|
148
|
+
const container = useSyncExternalStore(subscribeModals, getTopmostModal, getServerTopmostModal);
|
|
149
|
+
const write = (next) => {
|
|
150
|
+
entriesRef.current = next;
|
|
151
|
+
setEntries(next);
|
|
152
|
+
};
|
|
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
|
+
const syncTimers = () => {
|
|
159
|
+
const map = timers.current;
|
|
160
|
+
const { visible } = partition(entriesRef.current, latest.current.limit);
|
|
161
|
+
const now = Date.now();
|
|
162
|
+
const live = /* @__PURE__ */ new Set();
|
|
163
|
+
const halted = !mounted.current || anyPause(pauses.current);
|
|
164
|
+
for (const entry of visible) {
|
|
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
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const setPause = (source, value) => {
|
|
203
|
+
if (pauses.current[source] === value) return;
|
|
204
|
+
pauses.current[source] = value;
|
|
205
|
+
syncTimers();
|
|
206
|
+
setPaused(anyPause(pauses.current));
|
|
207
|
+
};
|
|
208
|
+
/** Open toasts' Root elements in document order. */
|
|
209
|
+
const sortedRoots = (exclude) => {
|
|
210
|
+
const open = new Set(entriesRef.current.filter((e) => !e.ending).map((e) => e.options.id));
|
|
211
|
+
const list = [];
|
|
212
|
+
for (const [id, element] of roots.current) {
|
|
213
|
+
if (!open.has(id) || exclude?.has(id) || !element.isConnected) continue;
|
|
214
|
+
list.push({
|
|
215
|
+
id,
|
|
216
|
+
element
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return list.sort((a, b) => byDocumentPosition(a.element, b.element));
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Before toasts close: if focus is inside one of them, move it to the next toast, else the
|
|
223
|
+
* previous one, else where it was before the region was entered, else the body (design 7).
|
|
224
|
+
*/
|
|
225
|
+
const moveFocusOut = (closing) => {
|
|
226
|
+
const doc = regionRef.current?.ownerDocument ?? document;
|
|
227
|
+
const active = doc.activeElement;
|
|
228
|
+
if (!(active instanceof HTMLElement)) return;
|
|
229
|
+
const all = sortedRoots();
|
|
230
|
+
const index = all.findIndex(({ element }) => element.contains(active));
|
|
231
|
+
if (index === -1 || !closing.has(all[index].id)) return;
|
|
232
|
+
const after = all.slice(index + 1).find(({ id }) => !closing.has(id));
|
|
233
|
+
const before = all.slice(0, index).reverse().find(({ id }) => !closing.has(id));
|
|
234
|
+
const target = after ?? before;
|
|
235
|
+
if (target !== void 0) {
|
|
236
|
+
target.element.focus();
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const stored = returnTarget.current;
|
|
240
|
+
if (stored !== null && stored.isConnected && !regionRef.current?.contains(stored)) {
|
|
241
|
+
stored.focus();
|
|
242
|
+
if (doc.activeElement === stored) return;
|
|
243
|
+
}
|
|
244
|
+
active.blur();
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Records the animations running in each closing toast before `data-ending` applies: the exit
|
|
248
|
+
* waits only for the ones the ending state started, not for a running progress bar.
|
|
249
|
+
*/
|
|
250
|
+
const snapshotExitBaselines = (ids) => {
|
|
251
|
+
for (const id of ids) {
|
|
252
|
+
const element = roots.current.get(id);
|
|
253
|
+
if (element === void 0) continue;
|
|
254
|
+
exitBaselines.current.set(id, animationBaseline(element));
|
|
255
|
+
}
|
|
256
|
+
};
|
|
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
|
+
const scheduleCloseActions = (closed, reason, event) => {
|
|
263
|
+
for (const entry of closed) {
|
|
264
|
+
const closeAction = entry.options.closeAction;
|
|
265
|
+
if (closeAction === void 0) continue;
|
|
266
|
+
const details = createActionDetails(event, {
|
|
267
|
+
id: entry.options.id,
|
|
268
|
+
reason
|
|
269
|
+
});
|
|
270
|
+
queueMicrotask(() => {
|
|
271
|
+
if (!mounted.current) return;
|
|
272
|
+
startCloseTransition(async () => {
|
|
273
|
+
await closeAction(details);
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const close = (ids, reason, event) => {
|
|
279
|
+
const wanted = new Set(ids);
|
|
280
|
+
const closing = entriesRef.current.filter((e) => !e.ending && wanted.has(e.options.id));
|
|
281
|
+
if (closing.length === 0) return;
|
|
282
|
+
const closingIds = new Set(closing.map((e) => e.options.id));
|
|
283
|
+
moveFocusOut(closingIds);
|
|
284
|
+
snapshotExitBaselines(closingIds);
|
|
285
|
+
write(entriesRef.current.map((e) => closingIds.has(e.options.id) ? withFlags(e, { ending: true }) : e));
|
|
286
|
+
syncTimers();
|
|
287
|
+
scheduleCloseActions(closing, reason, event);
|
|
288
|
+
};
|
|
289
|
+
const drop = (id) => {
|
|
290
|
+
const next = entriesRef.current.filter((e) => !(e.ending && e.options.id === id));
|
|
291
|
+
if (next.length === entriesRef.current.length) return;
|
|
292
|
+
lastAnnounced.current.delete(id);
|
|
293
|
+
exitBaselines.current.delete(id);
|
|
294
|
+
write(next);
|
|
295
|
+
};
|
|
296
|
+
const apply = (commands) => {
|
|
297
|
+
const next = [...entriesRef.current];
|
|
298
|
+
const dismissed = [];
|
|
299
|
+
for (const command of commands) {
|
|
300
|
+
if (command.kind === "dismiss") {
|
|
301
|
+
for (let i = 0; i < next.length; i++) {
|
|
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
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (dismissed.length === 0) {
|
|
367
|
+
write(next);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const stays = new Set(next.filter((e) => !e.ending).map((e) => e.options.id));
|
|
371
|
+
const leaving = new Set(dismissed.map((e) => e.options.id).filter((id) => !stays.has(id)));
|
|
372
|
+
moveFocusOut(leaving);
|
|
373
|
+
snapshotExitBaselines(leaving);
|
|
374
|
+
write(next);
|
|
375
|
+
syncTimers();
|
|
376
|
+
scheduleCloseActions(dismissed, "dismiss", void 0);
|
|
377
|
+
};
|
|
378
|
+
const setActionPending = (id, pending) => {
|
|
379
|
+
const index = entriesRef.current.findIndex((e) => e.options.id === id);
|
|
380
|
+
if (index === -1) return;
|
|
381
|
+
const entry = entriesRef.current[index];
|
|
382
|
+
if (entry.actionPending === pending) return;
|
|
383
|
+
const next = [...entriesRef.current];
|
|
384
|
+
next[index] = withFlags(entry, { actionPending: pending });
|
|
385
|
+
write(next);
|
|
386
|
+
};
|
|
387
|
+
const flushAnnouncements = () => {
|
|
388
|
+
const batch = announceBatch.current;
|
|
389
|
+
announceBatch.current = [];
|
|
390
|
+
if (batch.length === 0) return;
|
|
391
|
+
const doc = regionRef.current?.ownerDocument ?? document;
|
|
392
|
+
if (typeof doc.ariaNotify !== "function") return;
|
|
393
|
+
const priority = batch.some((a) => a.priority === "high") ? "high" : "normal";
|
|
394
|
+
doc.ariaNotify(batch.map((a) => a.text).join(" "), { priority });
|
|
395
|
+
};
|
|
396
|
+
const queueAnnouncement = (id, text, priority) => {
|
|
397
|
+
const map = lastAnnounced.current;
|
|
398
|
+
if (map.has(id) && map.get(id) === text) return;
|
|
399
|
+
map.set(id, text);
|
|
400
|
+
if (text === null || text.trim() === "") return;
|
|
401
|
+
if (announceBatch.current.length === 0) queueMicrotask(flushAnnouncements);
|
|
402
|
+
announceBatch.current.push({
|
|
403
|
+
text,
|
|
404
|
+
priority
|
|
405
|
+
});
|
|
406
|
+
};
|
|
407
|
+
const restore = (toasts) => {
|
|
408
|
+
if (entriesRef.current.length > 0) return;
|
|
409
|
+
for (const t of toasts) if (t.announced !== void 0) lastAnnounced.current.set(t.options.id, t.announced);
|
|
410
|
+
write(toasts.map((t) => makeEntry(t.options, {
|
|
411
|
+
promisePending: t.pending,
|
|
412
|
+
actionPending: false,
|
|
413
|
+
ending: false
|
|
414
|
+
})));
|
|
415
|
+
addedSinceEffect.current = true;
|
|
416
|
+
};
|
|
417
|
+
const retain = () => {
|
|
418
|
+
const announced = lastAnnounced.current;
|
|
419
|
+
return entriesRef.current.filter((e) => !e.ending).map((e) => ({
|
|
420
|
+
options: e.options,
|
|
421
|
+
pending: e.promisePending,
|
|
422
|
+
announced: announced.has(e.options.id) ? announced.get(e.options.id) : void 0
|
|
423
|
+
}));
|
|
424
|
+
};
|
|
425
|
+
/** Forgets the queue of the previous manager (its own copy is retained by that manager). */
|
|
426
|
+
const reset = () => {
|
|
427
|
+
moveFocusOut(new Set(entriesRef.current.filter((e) => !e.ending).map((e) => e.options.id)));
|
|
428
|
+
for (const timer of timers.current.values()) if (timer.handle !== null) clearTimeout(timer.handle);
|
|
429
|
+
timers.current.clear();
|
|
430
|
+
lastAnnounced.current.clear();
|
|
431
|
+
exitBaselines.current.clear();
|
|
432
|
+
write([]);
|
|
433
|
+
};
|
|
434
|
+
const handlers = useLatest({
|
|
435
|
+
apply,
|
|
436
|
+
restore,
|
|
437
|
+
retain,
|
|
438
|
+
reset,
|
|
439
|
+
close,
|
|
440
|
+
drop,
|
|
441
|
+
setActionPending,
|
|
442
|
+
queueAnnouncement,
|
|
443
|
+
setPause,
|
|
444
|
+
syncTimers
|
|
445
|
+
});
|
|
446
|
+
const context = useMemo(() => ({
|
|
447
|
+
close: (ids, reason, event) => handlers.current.close(ids, reason, event),
|
|
448
|
+
drop: (id) => handlers.current.drop(id),
|
|
449
|
+
setActionPending: (id, pending) => handlers.current.setActionPending(id, pending),
|
|
450
|
+
setSuspended: (id, value) => {
|
|
451
|
+
if (value) suspended.current.add(id);
|
|
452
|
+
else suspended.current.delete(id);
|
|
453
|
+
handlers.current.syncTimers();
|
|
454
|
+
},
|
|
455
|
+
registerRoot: (id, element) => {
|
|
456
|
+
if (element === null) roots.current.delete(id);
|
|
457
|
+
else roots.current.set(id, element);
|
|
458
|
+
},
|
|
459
|
+
focusSibling: (id, direction) => {
|
|
460
|
+
const all = sortedRoots();
|
|
461
|
+
const index = all.findIndex((r) => r.id === id);
|
|
462
|
+
if (index === -1) return;
|
|
463
|
+
all[index + direction]?.element.focus();
|
|
464
|
+
},
|
|
465
|
+
announce: (id, text, priority) => handlers.current.queueAnnouncement(id, text, priority),
|
|
466
|
+
exitBaseline: (id) => exitBaselines.current.get(id),
|
|
467
|
+
announcer: () => latest.current.announce
|
|
468
|
+
}), [handlers, latest]);
|
|
469
|
+
const subscribedManager = useRef(null);
|
|
470
|
+
useEffect(() => {
|
|
471
|
+
if (subscribedManager.current !== null && subscribedManager.current !== manager) handlers.current.reset();
|
|
472
|
+
subscribedManager.current = manager;
|
|
473
|
+
const unsubscribe = toastManagerInternals(manager).subscribe(listener.current);
|
|
474
|
+
if (unsubscribe === null) {
|
|
475
|
+
setRejected(true);
|
|
476
|
+
if (isDev) console.error("Toast.Viewport: another Toast.Viewport already renders this manager; this one renders nothing. Use one Viewport per manager, or `createToastManager()` for a second queue.");
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
setRejected(false);
|
|
480
|
+
return unsubscribe;
|
|
481
|
+
}, [manager, handlers]);
|
|
482
|
+
useEffect(() => {
|
|
483
|
+
if (rejected) return;
|
|
484
|
+
mounted.current = true;
|
|
485
|
+
const doc = regionRef.current?.ownerDocument ?? document;
|
|
486
|
+
const view = doc.defaultView ?? window;
|
|
487
|
+
pauses.current.hidden = doc.visibilityState === "hidden";
|
|
488
|
+
const onVisibility = () => handlers.current.setPause("hidden", doc.visibilityState === "hidden");
|
|
489
|
+
const onWindowBlur = (event) => {
|
|
490
|
+
if (!(event.target instanceof Node)) handlers.current.setPause("blurred", true);
|
|
491
|
+
};
|
|
492
|
+
const onWindowFocus = (event) => {
|
|
493
|
+
if (!(event.target instanceof Node)) handlers.current.setPause("blurred", false);
|
|
494
|
+
};
|
|
495
|
+
doc.addEventListener("visibilitychange", onVisibility);
|
|
496
|
+
view.addEventListener("blur", onWindowBlur);
|
|
497
|
+
view.addEventListener("focus", onWindowFocus);
|
|
498
|
+
handlers.current.syncTimers();
|
|
499
|
+
setPaused(anyPause(pauses.current));
|
|
500
|
+
const map = timers.current;
|
|
501
|
+
return () => {
|
|
502
|
+
mounted.current = false;
|
|
503
|
+
doc.removeEventListener("visibilitychange", onVisibility);
|
|
504
|
+
view.removeEventListener("blur", onWindowBlur);
|
|
505
|
+
view.removeEventListener("focus", onWindowFocus);
|
|
506
|
+
for (const timer of map.values()) if (timer.handle !== null) clearTimeout(timer.handle);
|
|
507
|
+
map.clear();
|
|
508
|
+
};
|
|
509
|
+
}, [handlers, rejected]);
|
|
510
|
+
const hotkeyKey = hotkey === null ? null : hotkey.join("\0");
|
|
511
|
+
useEffect(() => {
|
|
512
|
+
if (hotkeyKey === null || rejected) return;
|
|
513
|
+
const keys = hotkeyKey.split("\0");
|
|
514
|
+
const doc = regionRef.current?.ownerDocument ?? document;
|
|
515
|
+
const onKeyDown = (event) => {
|
|
516
|
+
if (event.defaultPrevented || !matchesHotkey(keys, event)) return;
|
|
517
|
+
const newest = sortedRoots().at(-1);
|
|
518
|
+
if (newest === void 0) return;
|
|
519
|
+
event.preventDefault();
|
|
520
|
+
const active = doc.activeElement;
|
|
521
|
+
if (active instanceof HTMLElement && !regionRef.current?.contains(active)) returnTarget.current = active;
|
|
522
|
+
newest.element.focus();
|
|
523
|
+
};
|
|
524
|
+
doc.addEventListener("keydown", onKeyDown);
|
|
525
|
+
return () => doc.removeEventListener("keydown", onKeyDown);
|
|
526
|
+
}, [hotkeyKey, rejected]);
|
|
527
|
+
const portalled = useSyncExternalStore(subscribeNothing, onClient, onServerOrHydrating);
|
|
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
|
+
});
|
|
542
|
+
useLayoutEffect(() => {
|
|
543
|
+
const region = regionRef.current;
|
|
544
|
+
const current = entriesRef.current;
|
|
545
|
+
if (pauses.current.focus && (region === null || !region.contains(region.ownerDocument.activeElement))) {
|
|
546
|
+
returnTarget.current = null;
|
|
547
|
+
setPause("focus", false);
|
|
548
|
+
}
|
|
549
|
+
if (region !== null && region.isConnected && region.hasAttribute("popover")) {
|
|
550
|
+
let open = false;
|
|
551
|
+
try {
|
|
552
|
+
open = region.matches(":popover-open");
|
|
553
|
+
} catch {
|
|
554
|
+
open = false;
|
|
555
|
+
}
|
|
556
|
+
try {
|
|
557
|
+
if (current.length > 0) {
|
|
558
|
+
if (!open) region.showPopover();
|
|
559
|
+
else if (addedSinceEffect.current) {
|
|
560
|
+
region.hidePopover();
|
|
561
|
+
region.showPopover();
|
|
562
|
+
}
|
|
563
|
+
} else if (open) region.hidePopover();
|
|
564
|
+
} catch {}
|
|
565
|
+
}
|
|
566
|
+
if (current.length === 0 && pauses.current.hover) setPause("hover", false);
|
|
567
|
+
addedSinceEffect.current = false;
|
|
568
|
+
const { visible, queued } = partition(current, latest.current.limit);
|
|
569
|
+
for (const entry of queued) {
|
|
570
|
+
const id = entry.options.id;
|
|
571
|
+
if (lastAnnounced.current.has(id)) continue;
|
|
572
|
+
const resolver = entry.options.announce ?? latest.current.announce;
|
|
573
|
+
const text = resolver ? resolver(entry.item) : [plainText(entry.options.title), plainText(entry.options.description)].filter((t) => t !== "").join(" ");
|
|
574
|
+
queueAnnouncement(id, text, entry.options.priority ?? "normal");
|
|
575
|
+
}
|
|
576
|
+
for (const entry of visible) if (entry.ending && !roots.current.has(entry.options.id)) drop(entry.options.id);
|
|
577
|
+
syncTimers();
|
|
578
|
+
});
|
|
579
|
+
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).");
|
|
581
|
+
const { visible, queued } = partition(entries, limit);
|
|
582
|
+
const state = {
|
|
583
|
+
toasts: visible.map((e) => e.item),
|
|
584
|
+
queued: queued.length,
|
|
585
|
+
paused
|
|
586
|
+
};
|
|
587
|
+
const regionCallbackRef = useCallback((element) => {
|
|
588
|
+
regionRef.current = element;
|
|
589
|
+
return () => {
|
|
590
|
+
if (regionRef.current === element) regionRef.current = null;
|
|
591
|
+
};
|
|
592
|
+
}, []);
|
|
593
|
+
const onPointerEnter = () => setPause("hover", true);
|
|
594
|
+
const onPointerLeave = () => setPause("hover", false);
|
|
595
|
+
const onFocus = (event) => {
|
|
596
|
+
const region = event.currentTarget;
|
|
597
|
+
const from = event.relatedTarget;
|
|
598
|
+
if (!(from instanceof Node) || !region.contains(from)) returnTarget.current ??= from instanceof HTMLElement ? from : null;
|
|
599
|
+
setPause("focus", true);
|
|
600
|
+
};
|
|
601
|
+
const onBlur = (event) => {
|
|
602
|
+
const to = event.relatedTarget;
|
|
603
|
+
if (to instanceof Node && event.currentTarget.contains(to)) return;
|
|
604
|
+
returnTarget.current = null;
|
|
605
|
+
setPause("focus", false);
|
|
606
|
+
};
|
|
607
|
+
const libraryProps = {
|
|
608
|
+
popover: "manual",
|
|
609
|
+
"aria-label": rest["aria-label"] ?? regionLabel(hotkey),
|
|
610
|
+
"data-paused": dataAttr(paused),
|
|
611
|
+
"data-empty": dataAttr(state.toasts.length === 0),
|
|
612
|
+
onPointerEnter,
|
|
613
|
+
onPointerLeave,
|
|
614
|
+
onFocus,
|
|
615
|
+
onBlur
|
|
616
|
+
};
|
|
617
|
+
const region = useRender({
|
|
618
|
+
defaultElement: "section",
|
|
619
|
+
render,
|
|
620
|
+
state,
|
|
621
|
+
className,
|
|
622
|
+
style,
|
|
623
|
+
children,
|
|
624
|
+
props: rest,
|
|
625
|
+
libraryProps,
|
|
626
|
+
ref: regionCallbackRef
|
|
627
|
+
});
|
|
628
|
+
if (rejected) return null;
|
|
629
|
+
const content = /* @__PURE__ */ jsx(ToastViewportContext, {
|
|
630
|
+
value: context,
|
|
631
|
+
children: region
|
|
632
|
+
});
|
|
633
|
+
if (!portalled || host === null) return content;
|
|
634
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
635
|
+
ref: anchorRef,
|
|
636
|
+
style: ANCHOR_STYLE
|
|
637
|
+
}), createPortal(content, host)] });
|
|
638
|
+
}
|
|
639
|
+
const ANCHOR_STYLE = { display: "contents" };
|
|
640
|
+
ToastViewport.displayName = "ToastViewport";
|
|
641
|
+
//#endregion
|
|
642
|
+
export { ToastViewport };
|
|
643
|
+
|
|
644
|
+
//# sourceMappingURL=toast-viewport.mjs.map
|