@funstack/ui 0.1.0-alpha.15 → 0.1.0-alpha.16
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/README.md +22 -1
- package/dist/accordion/accordion-item.d.mts +19 -0
- package/dist/accordion/accordion-item.d.mts.map +1 -1
- package/dist/accordion/accordion-item.mjs +2 -0
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.d.mts +16 -0
- package/dist/accordion/accordion-panel.d.mts.map +1 -1
- package/dist/accordion/accordion-panel.mjs +2 -0
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts +36 -2
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +2 -0
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts +9 -0
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +2 -0
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/accordion/index.d.mts +2 -0
- package/dist/accordion/index.d.mts.map +1 -1
- package/dist/accordion/index.mjs +2 -0
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/bin/skill-installer.d.mts +1 -0
- package/dist/bin/skill-installer.mjs +12 -0
- package/dist/bin/skill-installer.mjs.map +1 -0
- package/dist/button/button.d.mts +25 -7
- package/dist/button/button.d.mts.map +1 -1
- package/dist/button/button.mjs +2 -0
- package/dist/button/button.mjs.map +1 -1
- package/dist/checkbox/checkbox.d.mts +25 -3
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +2 -0
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +15 -0
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.d.mts +10 -0
- package/dist/checkbox-group/checkbox-group-label.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts +19 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +31 -4
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/checkbox-group/index.d.mts +2 -0
- package/dist/checkbox-group/index.d.mts.map +1 -1
- package/dist/checkbox-group/index.mjs +2 -0
- package/dist/checkbox-group/index.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts +18 -0
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +2 -0
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-group.d.mts +49 -1
- package/dist/combobox/combobox-group.d.mts.map +1 -1
- package/dist/combobox/combobox-group.mjs +11 -1
- package/dist/combobox/combobox-group.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts +11 -0
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +2 -0
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-label.d.mts +16 -0
- package/dist/combobox/combobox-label.d.mts.map +1 -1
- package/dist/combobox/combobox-label.mjs +2 -0
- package/dist/combobox/combobox-label.mjs.map +1 -1
- package/dist/combobox/combobox-list.d.mts +14 -0
- package/dist/combobox/combobox-list.d.mts.map +1 -1
- package/dist/combobox/combobox-list.mjs +2 -0
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts +25 -3
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +2 -0
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts +16 -0
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +2 -0
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts +49 -12
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +2 -0
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts +16 -0
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +2 -0
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.d.mts +2 -0
- package/dist/combobox/index.d.mts.map +1 -1
- package/dist/combobox/index.mjs +2 -0
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/csp/csp-provider.d.mts +8 -0
- package/dist/csp/csp-provider.d.mts.map +1 -1
- package/dist/csp/csp-provider.mjs +2 -0
- package/dist/csp/csp-provider.mjs.map +1 -1
- package/dist/csp/style-hashes.d.mts +2 -0
- package/dist/csp/style-hashes.d.mts.map +1 -1
- package/dist/csp/style-hashes.mjs +2 -0
- package/dist/csp/style-hashes.mjs.map +1 -1
- package/dist/dialog/dialog-close.d.mts +18 -0
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +2 -0
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-description.d.mts +12 -0
- package/dist/dialog/dialog-description.d.mts.map +1 -1
- package/dist/dialog/dialog-description.mjs +2 -0
- package/dist/dialog/dialog-description.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts +18 -1
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +2 -0
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +25 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +2 -0
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +15 -1
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +2 -0
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-title.d.mts +11 -0
- package/dist/dialog/dialog-title.d.mts.map +1 -1
- package/dist/dialog/dialog-title.mjs +2 -0
- package/dist/dialog/dialog-title.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +16 -0
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +2 -0
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +2 -0
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +2 -0
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/docs/components/accordion.md +426 -0
- package/dist/docs/components/button.md +464 -0
- package/dist/docs/components/checkbox-group.md +474 -0
- package/dist/docs/components/checkbox.md +373 -0
- package/dist/docs/components/combobox.md +635 -0
- package/dist/docs/components/context-menu.md +524 -0
- package/dist/docs/components/dialog.md +686 -0
- package/dist/docs/components/field.md +587 -0
- package/dist/docs/components/menu.md +589 -0
- package/dist/docs/components/meter.md +313 -0
- package/dist/docs/components/number-field.md +528 -0
- package/dist/docs/components/popover.md +591 -0
- package/dist/docs/components/progress.md +450 -0
- package/dist/docs/components/radio-group.md +457 -0
- package/dist/docs/components/select.md +662 -0
- package/dist/docs/components/slider.md +558 -0
- package/dist/docs/components/switch.md +311 -0
- package/dist/docs/components/tabs.md +473 -0
- package/dist/docs/components/toast.md +576 -0
- package/dist/docs/components/toggle-group.md +341 -0
- package/dist/docs/components/toggle.md +245 -0
- package/dist/docs/components/toolbar.md +389 -0
- package/dist/docs/components/tooltip.md +494 -0
- package/dist/docs/concepts/action-props.md +251 -0
- package/dist/docs/concepts/ai-agents.md +56 -0
- package/dist/docs/concepts/browser-owned-state.md +118 -0
- package/dist/docs/concepts/content-security-policy.md +69 -0
- package/dist/docs/concepts/experimental.md +36 -0
- package/dist/docs/concepts/pending-and-optimistic.md +250 -0
- package/dist/docs/concepts/server-components.md +118 -0
- package/dist/docs/concepts/suspense.md +124 -0
- package/dist/docs/concepts/transitions.md +118 -0
- package/dist/docs/getting-started.md +115 -0
- package/dist/docs/index.md +181 -0
- package/dist/docs/roadmap.md +74 -0
- package/dist/docs/why.md +100 -0
- package/dist/field/field-control.d.mts +26 -3
- package/dist/field/field-control.d.mts.map +1 -1
- package/dist/field/field-control.mjs +2 -0
- package/dist/field/field-control.mjs.map +1 -1
- package/dist/field/field-description.d.mts +11 -0
- package/dist/field/field-description.d.mts.map +1 -1
- package/dist/field/field-description.mjs +2 -0
- package/dist/field/field-description.mjs.map +1 -1
- package/dist/field/field-error.d.mts +14 -2
- package/dist/field/field-error.d.mts.map +1 -1
- package/dist/field/field-error.mjs +2 -0
- package/dist/field/field-error.mjs.map +1 -1
- package/dist/field/field-label.d.mts +10 -0
- package/dist/field/field-label.d.mts.map +1 -1
- package/dist/field/field-label.mjs +2 -0
- package/dist/field/field-label.mjs.map +1 -1
- package/dist/field/field-root.d.mts +21 -2
- package/dist/field/field-root.d.mts.map +1 -1
- package/dist/field/field-root.mjs +2 -0
- package/dist/field/field-root.mjs.map +1 -1
- package/dist/field/index.d.mts +9 -0
- package/dist/field/index.d.mts.map +1 -1
- package/dist/field/index.mjs +9 -0
- package/dist/field/index.mjs.map +1 -1
- package/dist/form/form-root.d.mts +17 -1
- package/dist/form/form-root.d.mts.map +1 -1
- package/dist/form/form-root.mjs +2 -0
- package/dist/form/form-root.mjs.map +1 -1
- package/dist/form/form-submit.d.mts +18 -0
- package/dist/form/form-submit.d.mts.map +1 -1
- package/dist/form/form-submit.mjs +2 -0
- package/dist/form/form-submit.mjs.map +1 -1
- package/dist/form/index.d.mts +7 -0
- package/dist/form/index.d.mts.map +1 -1
- package/dist/form/index.mjs +7 -0
- package/dist/form/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/internal/types.d.mts +3 -0
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-popover-trigger.d.mts +1 -0
- package/dist/internal/use-popover-trigger.d.mts.map +1 -1
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/validity.d.mts +11 -0
- package/dist/internal/validity.d.mts.map +1 -1
- package/dist/internal/validity.mjs.map +1 -1
- package/dist/menu/index.d.mts +2 -0
- package/dist/menu/index.d.mts.map +1 -1
- package/dist/menu/index.mjs +2 -0
- package/dist/menu/index.mjs.map +1 -1
- package/dist/menu/menu-checkbox-item.d.mts +26 -2
- package/dist/menu/menu-checkbox-item.d.mts.map +1 -1
- package/dist/menu/menu-checkbox-item.mjs +2 -0
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +24 -2
- package/dist/menu/menu-context-trigger.d.mts.map +1 -1
- package/dist/menu/menu-context-trigger.mjs +2 -0
- package/dist/menu/menu-context-trigger.mjs.map +1 -1
- package/dist/menu/menu-group.d.mts +36 -1
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +9 -1
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-item.d.mts +23 -1
- package/dist/menu/menu-item.d.mts.map +1 -1
- package/dist/menu/menu-item.mjs +2 -0
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-popup.d.mts +33 -8
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +2 -0
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.d.mts +20 -1
- package/dist/menu/menu-radio-group.d.mts.map +1 -1
- package/dist/menu/menu-radio-group.mjs +2 -0
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.d.mts +16 -0
- package/dist/menu/menu-radio-item.d.mts.map +1 -1
- package/dist/menu/menu-radio-item.mjs +2 -0
- package/dist/menu/menu-radio-item.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +22 -3
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +2 -0
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts +13 -0
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +2 -0
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +15 -0
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +2 -0
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/meter/index.d.mts +2 -0
- package/dist/meter/index.d.mts.map +1 -1
- package/dist/meter/index.mjs +2 -0
- package/dist/meter/index.mjs.map +1 -1
- package/dist/meter/meter-indicator.d.mts +11 -0
- package/dist/meter/meter-indicator.d.mts.map +1 -1
- package/dist/meter/meter-indicator.mjs +2 -0
- package/dist/meter/meter-indicator.mjs.map +1 -1
- package/dist/meter/meter-label.d.mts +11 -0
- package/dist/meter/meter-label.d.mts.map +1 -1
- package/dist/meter/meter-label.mjs +2 -0
- package/dist/meter/meter-label.mjs.map +1 -1
- package/dist/meter/meter-region.d.mts +5 -0
- package/dist/meter/meter-region.d.mts.map +1 -1
- package/dist/meter/meter-region.mjs.map +1 -1
- package/dist/meter/meter-root.d.mts +52 -10
- package/dist/meter/meter-root.d.mts.map +1 -1
- package/dist/meter/meter-root.mjs +2 -0
- package/dist/meter/meter-root.mjs.map +1 -1
- package/dist/meter/meter-track.d.mts +11 -0
- package/dist/meter/meter-track.d.mts.map +1 -1
- package/dist/meter/meter-track.mjs +2 -0
- package/dist/meter/meter-track.mjs.map +1 -1
- package/dist/meter/meter-value.d.mts +15 -1
- package/dist/meter/meter-value.d.mts.map +1 -1
- package/dist/meter/meter-value.mjs +2 -0
- package/dist/meter/meter-value.mjs.map +1 -1
- package/dist/number-field/index.d.mts +2 -0
- package/dist/number-field/index.d.mts.map +1 -1
- package/dist/number-field/index.mjs +2 -0
- package/dist/number-field/index.mjs.map +1 -1
- package/dist/number-field/number-field-decrement.d.mts +2 -0
- package/dist/number-field/number-field-decrement.d.mts.map +1 -1
- package/dist/number-field/number-field-decrement.mjs +2 -0
- package/dist/number-field/number-field-decrement.mjs.map +1 -1
- package/dist/number-field/number-field-increment.d.mts +2 -0
- package/dist/number-field/number-field-increment.d.mts.map +1 -1
- package/dist/number-field/number-field-increment.mjs +2 -0
- package/dist/number-field/number-field-increment.mjs.map +1 -1
- package/dist/number-field/number-field-input.d.mts +9 -0
- package/dist/number-field/number-field-input.d.mts.map +1 -1
- package/dist/number-field/number-field-input.mjs +2 -0
- package/dist/number-field/number-field-input.mjs.map +1 -1
- package/dist/number-field/number-field-label.d.mts +10 -0
- package/dist/number-field/number-field-label.d.mts.map +1 -1
- package/dist/number-field/number-field-label.mjs +2 -0
- package/dist/number-field/number-field-label.mjs.map +1 -1
- package/dist/number-field/number-field-root.d.mts +62 -14
- package/dist/number-field/number-field-root.d.mts.map +1 -1
- package/dist/number-field/number-field-root.mjs +2 -0
- package/dist/number-field/number-field-root.mjs.map +1 -1
- package/dist/number-field/use-step-button.d.mts +20 -0
- package/dist/number-field/use-step-button.d.mts.map +1 -1
- package/dist/number-field/use-step-button.mjs.map +1 -1
- package/dist/popover/index.d.mts +2 -0
- package/dist/popover/index.d.mts.map +1 -1
- package/dist/popover/index.mjs +2 -0
- package/dist/popover/index.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts +18 -0
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +2 -0
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-description.d.mts +12 -0
- package/dist/popover/popover-description.d.mts.map +1 -1
- package/dist/popover/popover-description.mjs +2 -0
- package/dist/popover/popover-description.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +30 -4
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +2 -0
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.d.mts +9 -0
- package/dist/popover/popover-root.d.mts.map +1 -1
- package/dist/popover/popover-root.mjs +2 -0
- package/dist/popover/popover-root.mjs.map +1 -1
- package/dist/popover/popover-title.d.mts +11 -0
- package/dist/popover/popover-title.d.mts.map +1 -1
- package/dist/popover/popover-title.mjs +2 -0
- package/dist/popover/popover-title.mjs.map +1 -1
- package/dist/popover/popover-trigger.d.mts +15 -0
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +2 -0
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/index.d.mts +2 -0
- package/dist/progress/index.d.mts.map +1 -1
- package/dist/progress/index.mjs +2 -0
- package/dist/progress/index.mjs.map +1 -1
- package/dist/progress/progress-indicator.d.mts +11 -0
- package/dist/progress/progress-indicator.d.mts.map +1 -1
- package/dist/progress/progress-indicator.mjs +2 -0
- package/dist/progress/progress-indicator.mjs.map +1 -1
- package/dist/progress/progress-label.d.mts +11 -0
- package/dist/progress/progress-label.d.mts.map +1 -1
- package/dist/progress/progress-label.mjs +2 -0
- package/dist/progress/progress-label.mjs.map +1 -1
- package/dist/progress/progress-root.d.mts +36 -8
- package/dist/progress/progress-root.d.mts.map +1 -1
- package/dist/progress/progress-root.mjs +2 -0
- package/dist/progress/progress-root.mjs.map +1 -1
- package/dist/progress/progress-track.d.mts +11 -0
- package/dist/progress/progress-track.d.mts.map +1 -1
- package/dist/progress/progress-track.mjs +2 -0
- package/dist/progress/progress-track.mjs.map +1 -1
- package/dist/progress/progress-value.d.mts +15 -1
- package/dist/progress/progress-value.d.mts.map +1 -1
- package/dist/progress/progress-value.mjs +2 -0
- package/dist/progress/progress-value.mjs.map +1 -1
- package/dist/radio-group/index.d.mts +2 -0
- package/dist/radio-group/index.d.mts.map +1 -1
- package/dist/radio-group/index.mjs +2 -0
- package/dist/radio-group/index.mjs.map +1 -1
- package/dist/radio-group/radio-group-item.d.mts +18 -1
- package/dist/radio-group/radio-group-item.d.mts.map +1 -1
- package/dist/radio-group/radio-group-item.mjs +2 -0
- package/dist/radio-group/radio-group-item.mjs.map +1 -1
- package/dist/radio-group/radio-group-label.d.mts +10 -0
- package/dist/radio-group/radio-group-label.d.mts.map +1 -1
- package/dist/radio-group/radio-group-label.mjs +2 -0
- package/dist/radio-group/radio-group-label.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +29 -5
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +2 -0
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/index.d.mts +2 -0
- package/dist/select/index.d.mts.map +1 -1
- package/dist/select/index.mjs +2 -0
- package/dist/select/index.mjs.map +1 -1
- package/dist/select/select-group-label.d.mts +10 -0
- package/dist/select/select-group-label.d.mts.map +1 -1
- package/dist/select/select-group-label.mjs +2 -0
- package/dist/select/select-group-label.mjs.map +1 -1
- package/dist/select/select-group.d.mts +15 -1
- package/dist/select/select-group.d.mts.map +1 -1
- package/dist/select/select-group.mjs +2 -0
- package/dist/select/select-group.mjs.map +1 -1
- package/dist/select/select-option.d.mts +19 -1
- package/dist/select/select-option.d.mts.map +1 -1
- package/dist/select/select-option.mjs +2 -0
- package/dist/select/select-option.mjs.map +1 -1
- package/dist/select/select-root.d.mts +24 -1
- package/dist/select/select-root.d.mts.map +1 -1
- package/dist/select/select-root.mjs +2 -0
- package/dist/select/select-root.mjs.map +1 -1
- package/dist/select/select-separator.d.mts +9 -0
- package/dist/select/select-separator.d.mts.map +1 -1
- package/dist/select/select-separator.mjs +2 -0
- package/dist/select/select-separator.mjs.map +1 -1
- package/dist/select/select-trigger.d.mts +9 -0
- package/dist/select/select-trigger.d.mts.map +1 -1
- package/dist/select/select-trigger.mjs +2 -0
- package/dist/select/select-trigger.mjs.map +1 -1
- package/dist/select/select-value.d.mts +9 -0
- package/dist/select/select-value.d.mts.map +1 -1
- package/dist/select/select-value.mjs +2 -0
- package/dist/select/select-value.mjs.map +1 -1
- package/dist/slider/index.d.mts +2 -0
- package/dist/slider/index.d.mts.map +1 -1
- package/dist/slider/index.mjs +2 -0
- package/dist/slider/index.mjs.map +1 -1
- package/dist/slider/slider-indicator.d.mts +12 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -1
- package/dist/slider/slider-indicator.mjs +2 -0
- package/dist/slider/slider-indicator.mjs.map +1 -1
- package/dist/slider/slider-label.d.mts +11 -1
- package/dist/slider/slider-label.d.mts.map +1 -1
- package/dist/slider/slider-label.mjs +2 -0
- package/dist/slider/slider-label.mjs.map +1 -1
- package/dist/slider/slider-root.d.mts +53 -9
- package/dist/slider/slider-root.d.mts.map +1 -1
- package/dist/slider/slider-root.mjs +2 -0
- package/dist/slider/slider-root.mjs.map +1 -1
- package/dist/slider/slider-thumb.d.mts +32 -3
- package/dist/slider/slider-thumb.d.mts.map +1 -1
- package/dist/slider/slider-thumb.mjs +2 -0
- package/dist/slider/slider-thumb.mjs.map +1 -1
- package/dist/slider/slider-track.d.mts +17 -0
- package/dist/slider/slider-track.d.mts.map +1 -1
- package/dist/slider/slider-track.mjs +2 -0
- package/dist/slider/slider-track.mjs.map +1 -1
- package/dist/slider/slider-value.d.mts +11 -0
- package/dist/slider/slider-value.d.mts.map +1 -1
- package/dist/slider/slider-value.mjs +2 -0
- package/dist/slider/slider-value.mjs.map +1 -1
- package/dist/switch/switch.d.mts +23 -3
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +2 -0
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/index.d.mts +2 -0
- package/dist/tabs/index.d.mts.map +1 -1
- package/dist/tabs/index.mjs +2 -0
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/tabs/tabs-context.d.mts +5 -0
- package/dist/tabs/tabs-context.d.mts.map +1 -1
- package/dist/tabs/tabs-context.mjs.map +1 -1
- package/dist/tabs/tabs-indicator.d.mts +17 -0
- package/dist/tabs/tabs-indicator.d.mts.map +1 -1
- package/dist/tabs/tabs-indicator.mjs +2 -0
- package/dist/tabs/tabs-indicator.mjs.map +1 -1
- package/dist/tabs/tabs-list.d.mts +19 -1
- package/dist/tabs/tabs-list.d.mts.map +1 -1
- package/dist/tabs/tabs-list.mjs +2 -0
- package/dist/tabs/tabs-list.mjs.map +1 -1
- package/dist/tabs/tabs-panel.d.mts +19 -0
- package/dist/tabs/tabs-panel.d.mts.map +1 -1
- package/dist/tabs/tabs-panel.mjs +2 -0
- package/dist/tabs/tabs-panel.mjs.map +1 -1
- package/dist/tabs/tabs-root.d.mts +39 -5
- package/dist/tabs/tabs-root.d.mts.map +1 -1
- package/dist/tabs/tabs-root.mjs +2 -0
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.d.mts +22 -1
- package/dist/tabs/tabs-tab.d.mts.map +1 -1
- package/dist/tabs/tabs-tab.mjs +2 -0
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/index.d.mts +2 -0
- package/dist/toast/index.d.mts.map +1 -1
- package/dist/toast/index.mjs +2 -0
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toast/toast-action.d.mts +28 -3
- package/dist/toast/toast-action.d.mts.map +1 -1
- package/dist/toast/toast-action.mjs +2 -0
- package/dist/toast/toast-action.mjs.map +1 -1
- package/dist/toast/toast-close.d.mts +16 -0
- package/dist/toast/toast-close.d.mts.map +1 -1
- package/dist/toast/toast-close.mjs +2 -0
- package/dist/toast/toast-close.mjs.map +1 -1
- package/dist/toast/toast-description.d.mts +16 -1
- package/dist/toast/toast-description.d.mts.map +1 -1
- package/dist/toast/toast-description.mjs +2 -0
- package/dist/toast/toast-description.mjs.map +1 -1
- package/dist/toast/toast-root.d.mts +20 -0
- package/dist/toast/toast-root.d.mts.map +1 -1
- package/dist/toast/toast-root.mjs +2 -0
- package/dist/toast/toast-root.mjs.map +1 -1
- package/dist/toast/toast-title.d.mts +15 -1
- package/dist/toast/toast-title.d.mts.map +1 -1
- package/dist/toast/toast-title.mjs +2 -0
- package/dist/toast/toast-title.mjs.map +1 -1
- package/dist/toast/toast-viewport.d.mts +34 -5
- package/dist/toast/toast-viewport.d.mts.map +1 -1
- package/dist/toast/toast-viewport.mjs +2 -0
- package/dist/toast/toast-viewport.mjs.map +1 -1
- package/dist/toast/toast.d.mts +46 -6
- package/dist/toast/toast.d.mts.map +1 -1
- package/dist/toast/toast.mjs +4 -0
- package/dist/toast/toast.mjs.map +1 -1
- package/dist/toggle/toggle.d.mts +20 -2
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +2 -0
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/index.d.mts +2 -0
- package/dist/toggle-group/index.d.mts.map +1 -1
- package/dist/toggle-group/index.mjs +2 -0
- package/dist/toggle-group/index.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-context.d.mts +1 -0
- 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 +16 -0
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-item.mjs +2 -0
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-root.d.mts +73 -12
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-root.mjs +2 -0
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
- package/dist/toolbar/index.d.mts +2 -0
- package/dist/toolbar/index.d.mts.map +1 -1
- package/dist/toolbar/index.mjs +2 -0
- package/dist/toolbar/index.mjs.map +1 -1
- package/dist/toolbar/toolbar-root.d.mts +30 -3
- package/dist/toolbar/toolbar-root.d.mts.map +1 -1
- package/dist/toolbar/toolbar-root.mjs +2 -0
- package/dist/toolbar/toolbar-root.mjs.map +1 -1
- package/dist/toolbar/toolbar-separator.d.mts +13 -0
- package/dist/toolbar/toolbar-separator.d.mts.map +1 -1
- package/dist/toolbar/toolbar-separator.mjs +2 -0
- package/dist/toolbar/toolbar-separator.mjs.map +1 -1
- package/dist/tooltip/index.d.mts +2 -0
- package/dist/tooltip/index.d.mts.map +1 -1
- package/dist/tooltip/index.mjs +2 -0
- package/dist/tooltip/index.mjs.map +1 -1
- package/dist/tooltip/tooltip-arrow.d.mts +16 -0
- package/dist/tooltip/tooltip-arrow.d.mts.map +1 -1
- package/dist/tooltip/tooltip-arrow.mjs +2 -0
- package/dist/tooltip/tooltip-arrow.mjs.map +1 -1
- package/dist/tooltip/tooltip-context.d.mts +4 -0
- package/dist/tooltip/tooltip-context.d.mts.map +1 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts +24 -3
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +2 -0
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.d.mts +24 -2
- package/dist/tooltip/tooltip-root.d.mts.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +2 -0
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +18 -1
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +2 -0
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/package.json +9 -1
- package/skills/funstack-ui-knowledge/SKILL.md +75 -0
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
# Toast
|
|
2
|
+
|
|
3
|
+
Toasts report on something that already happened or is happening elsewhere. The input is a function, `toast()`, callable from anywhere: an action body, a store, an effect. The output is yours: a `Toast.Viewport` rendered once maps the queue to parts. The queue is the library's first state that is **urgent by design**: React holds every transition while an async action is pending, so a toast pushed as a transition would appear only after the action it reports on. Toast spends its Async React budget elsewhere: a toast that follows a promise, an Undo that is an ordinary action prop with `data-pending`, a `closeAction` that knows whether the Undo window was used, and a Suspense guard so a toast whose content suspends does not blank the page.
|
|
4
|
+
|
|
5
|
+
```tsx title="ToastArchive.tsx"
|
|
6
|
+
"use client";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { Menu } from "@funstack/ui/menu";
|
|
9
|
+
import { toast } from "@funstack/ui/toast";
|
|
10
|
+
import { fakeSave } from "./fake-api.js";
|
|
11
|
+
|
|
12
|
+
// One promise feeds both the menu item and the toast: `toast.promise` shows "Archiving…" at once
|
|
13
|
+
// (data-pending on the toast), swaps to the success or error toast when the fake server call
|
|
14
|
+
// settles, and returns a promise that settles with it, so the item stays pending exactly as long
|
|
15
|
+
// and the menu closes when it is done. The success toast's Undo is an action prop: pending while
|
|
16
|
+
// it runs, then the toast closes. With `error` given, a failure is the toast's to show: the
|
|
17
|
+
// returned promise resolves and nothing reaches an Error Boundary.
|
|
18
|
+
export function ToastArchive() {
|
|
19
|
+
const [fail, setFail] = useState(false);
|
|
20
|
+
return (
|
|
21
|
+
<div className="demo-stack">
|
|
22
|
+
<div className="demo-row">
|
|
23
|
+
<span>Quarterly report.pdf</span>
|
|
24
|
+
<Menu.Root>
|
|
25
|
+
<Menu.Trigger className="demo-button" aria-label="Actions for Quarterly report.pdf">
|
|
26
|
+
{({ pending }) => (pending ? <span className="demo-spinner" aria-hidden /> : "⋯")}
|
|
27
|
+
</Menu.Trigger>
|
|
28
|
+
<Menu.Popup className="demo-menu">
|
|
29
|
+
<Menu.Item
|
|
30
|
+
action={() =>
|
|
31
|
+
toast.promise(fakeSave("the archive", { ms: 1500, fail }), {
|
|
32
|
+
pending: { title: "Archiving…" },
|
|
33
|
+
success: {
|
|
34
|
+
title: "Archived",
|
|
35
|
+
description: "Quarterly report.pdf",
|
|
36
|
+
type: "success",
|
|
37
|
+
action: {
|
|
38
|
+
label: "Undo",
|
|
39
|
+
action: () => fakeSave("the undo", { ms: 800 }),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
error: (e) => ({
|
|
43
|
+
title: "Could not archive",
|
|
44
|
+
description: e instanceof Error ? e.message : String(e),
|
|
45
|
+
type: "error",
|
|
46
|
+
priority: "high",
|
|
47
|
+
}),
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
>
|
|
51
|
+
{({ pending }) => (pending ? "Archiving…" : "Archive")}
|
|
52
|
+
</Menu.Item>
|
|
53
|
+
<Menu.Item action={() => toast({ title: "Link copied" })}>Copy link</Menu.Item>
|
|
54
|
+
</Menu.Popup>
|
|
55
|
+
</Menu.Root>
|
|
56
|
+
</div>
|
|
57
|
+
<label className="demo-row">
|
|
58
|
+
<input type="checkbox" checked={fail} onChange={(e) => setFail(e.target.checked)} />
|
|
59
|
+
Make Archive fail
|
|
60
|
+
</label>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```css title="toast.css"
|
|
67
|
+
/* Toast: the Viewport is a <section popover="manual">, shown in the top layer while it has toasts
|
|
68
|
+
(`:popover-open`, `data-paused`). Roots carry `data-pending`, `data-ending` and `data-type`.
|
|
69
|
+
Enter with @starting-style, exit on [data-ending]: the library keeps the toast until its
|
|
70
|
+
transitions finish. */
|
|
71
|
+
|
|
72
|
+
.demo-toasts {
|
|
73
|
+
position: fixed;
|
|
74
|
+
inset: auto 1rem 1rem auto;
|
|
75
|
+
margin: 0;
|
|
76
|
+
padding: 0;
|
|
77
|
+
border: 0;
|
|
78
|
+
inline-size: min(22rem, calc(100vw - 2rem));
|
|
79
|
+
overflow: visible;
|
|
80
|
+
background: transparent;
|
|
81
|
+
color: var(--color-text);
|
|
82
|
+
/* The region's box never blocks the page; the toasts take pointer events. */
|
|
83
|
+
pointer-events: none;
|
|
84
|
+
}
|
|
85
|
+
.demo-toast-slot {
|
|
86
|
+
display: grid;
|
|
87
|
+
grid-template-rows: 1fr;
|
|
88
|
+
transition: grid-template-rows 200ms;
|
|
89
|
+
}
|
|
90
|
+
/* Collapse the gap a leaving toast leaves behind. */
|
|
91
|
+
.demo-toast-slot:has([data-ending]) {
|
|
92
|
+
grid-template-rows: 0fr;
|
|
93
|
+
}
|
|
94
|
+
.demo-toast {
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: start;
|
|
97
|
+
gap: 0.5rem;
|
|
98
|
+
min-block-size: 0;
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
margin-block-start: 0.5rem;
|
|
101
|
+
padding: 0.75rem 0.75rem 0.75rem 1rem;
|
|
102
|
+
border: 1px solid var(--color-border);
|
|
103
|
+
border-radius: 8px;
|
|
104
|
+
background: var(--color-bg);
|
|
105
|
+
box-shadow: 0 12px 40px rgb(0 0 0 / 0.25);
|
|
106
|
+
pointer-events: auto;
|
|
107
|
+
transition:
|
|
108
|
+
opacity 200ms,
|
|
109
|
+
translate 200ms;
|
|
110
|
+
}
|
|
111
|
+
@starting-style {
|
|
112
|
+
.demo-toast {
|
|
113
|
+
opacity: 0;
|
|
114
|
+
translate: 0 1rem;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
.demo-toast[data-ending] {
|
|
118
|
+
opacity: 0;
|
|
119
|
+
translate: 0 1rem;
|
|
120
|
+
}
|
|
121
|
+
.demo-toast[data-pending] {
|
|
122
|
+
cursor: progress;
|
|
123
|
+
}
|
|
124
|
+
.demo-toast[data-pending] .demo-toast-title::after {
|
|
125
|
+
content: " ⏳";
|
|
126
|
+
}
|
|
127
|
+
.demo-toast[data-type="success"] {
|
|
128
|
+
border-inline-start: 4px solid #16a34a;
|
|
129
|
+
}
|
|
130
|
+
.demo-toast[data-type="error"] {
|
|
131
|
+
border-inline-start: 4px solid #dc2626;
|
|
132
|
+
}
|
|
133
|
+
.demo-toast:focus-visible {
|
|
134
|
+
outline: 2px solid var(--color-accent, #4f46e5);
|
|
135
|
+
outline-offset: 2px;
|
|
136
|
+
}
|
|
137
|
+
.demo-toast-text {
|
|
138
|
+
flex: 1;
|
|
139
|
+
}
|
|
140
|
+
.demo-toast-title {
|
|
141
|
+
font-weight: 600;
|
|
142
|
+
}
|
|
143
|
+
.demo-toast-description {
|
|
144
|
+
margin: 0.15rem 0 0;
|
|
145
|
+
font-size: 0.875em;
|
|
146
|
+
opacity: 0.8;
|
|
147
|
+
}
|
|
148
|
+
.demo-toast-action[data-pending] {
|
|
149
|
+
cursor: progress;
|
|
150
|
+
opacity: 0.7;
|
|
151
|
+
}
|
|
152
|
+
.demo-toast-close {
|
|
153
|
+
border: 0;
|
|
154
|
+
padding: 0 0.4em;
|
|
155
|
+
background: none;
|
|
156
|
+
color: inherit;
|
|
157
|
+
font: inherit;
|
|
158
|
+
font-size: 1.2em;
|
|
159
|
+
line-height: 1.4;
|
|
160
|
+
cursor: pointer;
|
|
161
|
+
}
|
|
162
|
+
.demo-toast-queued {
|
|
163
|
+
margin: 0.25rem 0 0;
|
|
164
|
+
text-align: end;
|
|
165
|
+
font-size: 0.8em;
|
|
166
|
+
opacity: 0.8;
|
|
167
|
+
}
|
|
168
|
+
.demo-toast-list {
|
|
169
|
+
margin: 0;
|
|
170
|
+
padding: 0;
|
|
171
|
+
list-style: none;
|
|
172
|
+
}
|
|
173
|
+
.demo-toast-list li {
|
|
174
|
+
display: flex;
|
|
175
|
+
align-items: center;
|
|
176
|
+
justify-content: space-between;
|
|
177
|
+
gap: 1rem;
|
|
178
|
+
max-inline-size: 20rem;
|
|
179
|
+
padding: 0.25rem 0;
|
|
180
|
+
}
|
|
181
|
+
@media (prefers-reduced-motion: reduce) {
|
|
182
|
+
.demo-toast,
|
|
183
|
+
.demo-toast-slot {
|
|
184
|
+
transition: none;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Anatomy
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { Toast, toast } from "@funstack/ui/toast";
|
|
193
|
+
|
|
194
|
+
// Once, near the root of the app (from a Client Component: children is a function).
|
|
195
|
+
<Toast.Viewport> {/* section[popover=manual][aria-label="Notifications (F8)"] */}
|
|
196
|
+
{({ toasts }) =>
|
|
197
|
+
toasts.map((t) => (
|
|
198
|
+
<Toast.Root key={t.id} toast={t}> {/* div[role=dialog|alertdialog][tabindex=0] */}
|
|
199
|
+
<Toast.Title /> {/* div: t.title */}
|
|
200
|
+
<Toast.Description /> {/* p: t.description, nothing when absent */}
|
|
201
|
+
<Toast.Action /> {/* button: t.action, nothing when absent */}
|
|
202
|
+
<Toast.Close aria-label="Close">×</Toast.Close>
|
|
203
|
+
</Toast.Root>
|
|
204
|
+
))
|
|
205
|
+
}
|
|
206
|
+
</Toast.Viewport>
|
|
207
|
+
|
|
208
|
+
// Anywhere on the client:
|
|
209
|
+
toast({ title: "Link copied" });
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
This page's Viewport, which every example on it feeds:
|
|
213
|
+
|
|
214
|
+
```tsx title="ToastNotifications.tsx"
|
|
215
|
+
"use client";
|
|
216
|
+
import { Toast } from "@funstack/ui/toast";
|
|
217
|
+
import type { ToastItem } from "@funstack/ui/toast";
|
|
218
|
+
|
|
219
|
+
// The toast region, rendered once (here: once on this page; in an app, near the root). It is a
|
|
220
|
+
// `<section popover="manual">` in the top layer, shown while it has toasts, and moves into an
|
|
221
|
+
// open modal Dialog by itself. The Viewport's children map the queue to parts.
|
|
222
|
+
function renderToast(t: ToastItem) {
|
|
223
|
+
return (
|
|
224
|
+
<div className="demo-toast-slot" key={t.id}>
|
|
225
|
+
<Toast.Root toast={t} className="demo-toast">
|
|
226
|
+
<div className="demo-toast-text">
|
|
227
|
+
<Toast.Title className="demo-toast-title" />
|
|
228
|
+
<Toast.Description className="demo-toast-description" />
|
|
229
|
+
</div>
|
|
230
|
+
<Toast.Action className="demo-button demo-toast-action">
|
|
231
|
+
{({ pending }) => (pending ? "Undoing…" : t.action?.label)}
|
|
232
|
+
</Toast.Action>
|
|
233
|
+
<Toast.Close className="demo-toast-close" aria-label="Close">
|
|
234
|
+
×
|
|
235
|
+
</Toast.Close>
|
|
236
|
+
</Toast.Root>
|
|
237
|
+
</div>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function ToastNotifications() {
|
|
242
|
+
return (
|
|
243
|
+
<Toast.Viewport className="demo-toasts">
|
|
244
|
+
{({ toasts, queued }) => (
|
|
245
|
+
<>
|
|
246
|
+
{toasts.map(renderToast)}
|
|
247
|
+
{queued > 0 && <p className="demo-toast-queued">+{queued} more</p>}
|
|
248
|
+
</>
|
|
249
|
+
)}
|
|
250
|
+
</Toast.Viewport>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
- **No Provider.** `toast` is bound to a module-level default manager; a Viewport without `manager` renders it. A second Viewport on the same manager warns and renders nothing. `createToastManager()` makes an isolated queue (a second React root, a test) for `<Toast.Viewport manager={m}>`.
|
|
256
|
+
- **No list element, no Portal part.** Toasts are focusable `dialog`s (`alertdialog` for `priority: "high"`) named by their Title and described by their Description. The region is wherever the Viewport is rendered; its only move (into a modal dialog) is the library's. On the client it sits inside two `display: contents` wrappers: an anchor where the Viewport is rendered, and the element the library moves.
|
|
257
|
+
- The Title is a `div`, not a heading: transient notifications stay out of heading navigation.
|
|
258
|
+
- Calls made before the Viewport mounts are buffered and shown when it does. A Viewport that unmounts leaves its toasts with the manager for the next one (timers stop; no `closeAction` runs).
|
|
259
|
+
|
|
260
|
+
## How it works
|
|
261
|
+
|
|
262
|
+
### The urgent queue
|
|
263
|
+
|
|
264
|
+
Every queue change (add, update, dismiss, the drop after an exit animation) is a normal, urgent update. `toast()` dispatches from a microtask, so a call inside a `startTransition` scope, the sync prefix of an action included, escapes the scope and shows at once; calls keep their order. Everything a toast _drives_ is a transition as usual: its Action's action and its `closeAction`.
|
|
265
|
+
|
|
266
|
+
```tsx title="ToastUrgent.tsx"
|
|
267
|
+
"use client";
|
|
268
|
+
import { useTransition } from "react";
|
|
269
|
+
import { toast } from "@funstack/ui/toast";
|
|
270
|
+
import { sleep } from "./fake-api.js";
|
|
271
|
+
|
|
272
|
+
// React holds every transition update while an async action is pending anywhere in the app. A
|
|
273
|
+
// toast pushed as a transition would therefore appear only after the action it reports on. The
|
|
274
|
+
// queue is urgent instead: `toast()` dispatches from a microtask, so the "Saving…" toast shows at
|
|
275
|
+
// once, from inside the action's own transition, while the button is still pending.
|
|
276
|
+
export function ToastUrgent() {
|
|
277
|
+
const [pending, startTransition] = useTransition();
|
|
278
|
+
return (
|
|
279
|
+
<div className="demo-row">
|
|
280
|
+
<button
|
|
281
|
+
type="button"
|
|
282
|
+
className="demo-button"
|
|
283
|
+
data-pending={pending ? "" : undefined}
|
|
284
|
+
onClick={() =>
|
|
285
|
+
startTransition(async () => {
|
|
286
|
+
const id = toast({ title: "Saving…", duration: null });
|
|
287
|
+
await sleep(2000);
|
|
288
|
+
toast.update(id, { title: "Saved", type: "success", duration: 3000 });
|
|
289
|
+
})
|
|
290
|
+
}
|
|
291
|
+
>
|
|
292
|
+
{pending ? "Saving (2 s)…" : "Save"}
|
|
293
|
+
</button>
|
|
294
|
+
<button
|
|
295
|
+
type="button"
|
|
296
|
+
className="demo-button"
|
|
297
|
+
onClick={() => {
|
|
298
|
+
for (let i = 1; i <= 5; i++) toast({ title: `Message ${i} of 5` });
|
|
299
|
+
}}
|
|
300
|
+
>
|
|
301
|
+
Burst of five
|
|
302
|
+
</button>
|
|
303
|
+
</div>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
`limit` (default 3) toasts render at once; later ones wait in order and show as earlier ones leave. Nothing is dropped, so an Undo is never lost to a burst. `state.queued` counts the waiting ones. A `toast()` with an existing `id` updates that toast in place ("one toast per key").
|
|
309
|
+
|
|
310
|
+
### Promise toasts
|
|
311
|
+
|
|
312
|
+
`toast.promise(promise, { pending, success, error })` shows `pending` at once with `data-pending` and no timer, and replaces it with `success` or `error` (options, or functions of the value / the reason) when the promise settles: same toast, same element, announced again. It returns a promise that settles with the input in the same tick, so `action={() => toast.promise(save(), …)}` keeps the part that started the work pending for exactly as long.
|
|
313
|
+
|
|
314
|
+
| The promise | Toast | Returned promise |
|
|
315
|
+
| - | - | - |
|
|
316
|
+
| fulfils, `success` given | replaced by `success` | resolves with the value |
|
|
317
|
+
| fulfils, no `success` | dismissed (`reason: "dismiss"`) | resolves with the value |
|
|
318
|
+
| rejects, `error` given | replaced by `error` | **resolves** with `undefined`: the toast is the handler |
|
|
319
|
+
| rejects, no `error` | dismissed | rejects with the reason (the action prop's Error Boundary gets it) |
|
|
320
|
+
| a `success` / `error` function throws | dismissed (never left pending) | rejects with what the function threw |
|
|
321
|
+
|
|
322
|
+
### Undo and closeAction
|
|
323
|
+
|
|
324
|
+
`Toast.Action` is a [pure trigger](../concepts/pending-and-optimistic.md#pure-trigger), like `Menu.Item`. While its action runs the Action and the Root carry `data-pending` and the toast's timer is paused; when it resolves the toast closes with `reason: "activate"` (unless `closeOnSettle={false}`). A rejection keeps the toast and reaches the nearest Error Boundary **above the Viewport**: put one around the list.
|
|
325
|
+
|
|
326
|
+
> **A caught error closes the toast**
|
|
327
|
+
>
|
|
328
|
+
> A `catch` inside the action resolves it, and a resolved action closes the toast, so a "Could not undo" written with `toast.update` in the `catch` is never seen. Rethrow after the update (the toast stays; the boundary above the Viewport gets the error), or use `closeOnSettle={false}` and `toast.dismiss(details.id)` on success.
|
|
329
|
+
|
|
330
|
+
A toast's `closeAction` runs once when it leaves, in the Viewport's transition, after the toast is already gone: `"activate"` (its Action settled), `"dismiss"` (Close, Escape, `toast.dismiss()`, a promise toast with no message for its outcome) or `"timeout"`. That is the "do later, unless undone" pattern:
|
|
331
|
+
|
|
332
|
+
```tsx title="ToastUndoWindow.tsx"
|
|
333
|
+
"use client";
|
|
334
|
+
import { startTransition, useState } from "react";
|
|
335
|
+
import { toast } from "@funstack/ui/toast";
|
|
336
|
+
import { sleep } from "./fake-api.js";
|
|
337
|
+
|
|
338
|
+
const initial = ["Groceries", "Dentist", "Call Ada"];
|
|
339
|
+
|
|
340
|
+
// "Do later, unless undone": the item leaves the list at once (local state), and the toast is the
|
|
341
|
+
// grace period. `closeAction` runs when the toast leaves, with the reason: "activate" when Undo
|
|
342
|
+
// was used, otherwise ("timeout", or "dismiss" through Close, Escape or toast.dismiss()) the
|
|
343
|
+
// deletion is committed. Hover or focus the toast to pause its 6 second timer.
|
|
344
|
+
export function ToastUndoWindow() {
|
|
345
|
+
const [items, setItems] = useState(initial);
|
|
346
|
+
const [log, setLog] = useState<readonly string[]>([]);
|
|
347
|
+
const note = (line: string) => startTransition(() => setLog((l) => [line, ...l].slice(0, 3)));
|
|
348
|
+
|
|
349
|
+
const remove = (name: string) => {
|
|
350
|
+
setItems((list) => list.filter((item) => item !== name));
|
|
351
|
+
toast({
|
|
352
|
+
title: `Deleted “${name}”`,
|
|
353
|
+
duration: 6000,
|
|
354
|
+
action: {
|
|
355
|
+
label: "Undo",
|
|
356
|
+
action: () => startTransition(() => setItems((list) => [...list, name])),
|
|
357
|
+
},
|
|
358
|
+
closeAction: async ({ reason }) => {
|
|
359
|
+
if (reason === "activate") {
|
|
360
|
+
note(`Restored ${name}`);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
await sleep(300); // the real delete request
|
|
364
|
+
note(`Deleted ${name} for good (${reason})`);
|
|
365
|
+
},
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
return (
|
|
370
|
+
<div className="demo-stack">
|
|
371
|
+
<ul className="demo-toast-list">
|
|
372
|
+
{items.map((name) => (
|
|
373
|
+
<li key={name}>
|
|
374
|
+
<span>{name}</span>
|
|
375
|
+
<button type="button" className="demo-button" onClick={() => remove(name)}>
|
|
376
|
+
Delete
|
|
377
|
+
</button>
|
|
378
|
+
</li>
|
|
379
|
+
))}
|
|
380
|
+
{items.length === 0 && (
|
|
381
|
+
<li>
|
|
382
|
+
<button type="button" className="demo-button" onClick={() => setItems(initial)}>
|
|
383
|
+
Reset list
|
|
384
|
+
</button>
|
|
385
|
+
</li>
|
|
386
|
+
)}
|
|
387
|
+
</ul>
|
|
388
|
+
<ul className="demo-readout">
|
|
389
|
+
{log.map((line, i) => (
|
|
390
|
+
<li key={i}>{line}</li>
|
|
391
|
+
))}
|
|
392
|
+
</ul>
|
|
393
|
+
</div>
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Timers
|
|
399
|
+
|
|
400
|
+
A toast's timer starts once it is visible (within `limit`), its content has rendered and it is not pending, and resumes with the remaining time after a pause. Timers pause while the pointer is over the region, focus is inside it, the document is hidden or the window is blurred (`data-paused`), and per toast while it is pending. Elapsing closes the toast with `reason: "timeout"`. Pausing helps sighted users; the persistent default for action toasts and the hotkey are what give screen-reader users time to reach an Undo.
|
|
401
|
+
|
|
402
|
+
## Props
|
|
403
|
+
|
|
404
|
+
### `toast(options)` and the manager
|
|
405
|
+
|
|
406
|
+
| Prop | Type | Default | Description |
|
|
407
|
+
| - | - | - | - |
|
|
408
|
+
| `toast(options)` | `(options: ToastOptions) => string` | – | Adds a toast and returns its id (or updates the toast with `options.id`). Also `toast.add`. |
|
|
409
|
+
| `toast.promise` | `<T>(promise: PromiseLike<T>, options: ToastPromiseOptions<T>) => Promise<T \| undefined>` | – | `{ pending, success?, error?, id? }`; `success` / `error` are options or functions of the value / reason. See the table above. |
|
|
410
|
+
| `toast.update` | `(id: string, options: Partial<ToastOptions>) => void` | – | Changes a toast in place; `undefined` removes a field. Ignored for a closed toast; an unknown id warns in development. |
|
|
411
|
+
| `toast.dismiss` | `(id?: string) => void` | – | Closes one toast, or all, with `reason: "dismiss"`. Idempotent. |
|
|
412
|
+
| `createToastManager` | `() => ToastManager` | – | An isolated queue with the same shape, for `Toast.Viewport manager`. |
|
|
413
|
+
|
|
414
|
+
On the server every method is a no-op with a development warning, and nothing is buffered (a module-level queue would be shared between requests). Return data from a Server Function and call `toast()` on the client.
|
|
415
|
+
|
|
416
|
+
### `ToastOptions`
|
|
417
|
+
|
|
418
|
+
| Prop | Type | Default | Description |
|
|
419
|
+
| - | - | - | - |
|
|
420
|
+
| `title` | `ReactNode` | – | Rendered by `Toast.Title`; part of the default announcement. |
|
|
421
|
+
| `description` | `ReactNode` | – | Rendered by `Toast.Description`; part of the default announcement. |
|
|
422
|
+
| `id` | `string` | `generated` | An existing id updates that toast. |
|
|
423
|
+
| `type` | `string` | – | Free-form (`"success"`, `"error"`), rendered as `data-type` on the Root. |
|
|
424
|
+
| `priority` | `"normal" \| "high"` | `"normal"` | `"high"`: announced with `ariaNotify` priority `"high"`, Root role `alertdialog`. |
|
|
425
|
+
| `duration` | `number \| null` | `Viewport duration; null with an action` | Milliseconds until the toast closes with `reason: "timeout"`; `null` never. A toast with an `action` is persistent unless you set it; if you do, keep the action reachable elsewhere too (WCAG 2.2.1). |
|
|
426
|
+
| `action` | `{ label: ReactNode; action: Action<[ToastActionDetails]> }` | – | What `Toast.Action` renders and runs. `details.id` is the toast's id, so an inline action can update or dismiss its own toast. |
|
|
427
|
+
| `closeAction` | `Action<[ToastCloseDetails]>` | – | Runs once when the toast leaves, in the Viewport's transition; `details.reason` is `"activate"`, `"dismiss"` or `"timeout"`. Not called when the Viewport unmounts. |
|
|
428
|
+
| `announce` | `(toast: ToastItem) => string \| null` | – | The text `ariaNotify` speaks for this toast; `null` for nothing. Wins over the Viewport's `announce`. |
|
|
429
|
+
| `data` | `unknown` | – | Anything your Viewport children want to render. |
|
|
430
|
+
|
|
431
|
+
`ToastItem`, what `state.toasts` holds: the options plus `id`, `pending` (its promise is unsettled or its Action runs) and `ending` (closed, kept for its exit animation).
|
|
432
|
+
|
|
433
|
+
### `Toast.Viewport`
|
|
434
|
+
|
|
435
|
+
| Prop | Type | Default | Description |
|
|
436
|
+
| - | - | - | - |
|
|
437
|
+
| `manager` | `ToastManager` | `toast` | The queue to render. |
|
|
438
|
+
| `limit` | `number` | `3` | Toasts rendered at once; the rest wait in order. |
|
|
439
|
+
| `duration` | `number \| null` | `5000` | Default `duration` of a toast without an `action`. |
|
|
440
|
+
| `hotkey` | `string[] \| null` | `["F8"]` | `event.code` values and modifier names (`"altKey"`, `"ctrlKey"`, `"metaKey"`, `"shiftKey"`) that focus the newest toast, with no other modifier held (Ctrl+F8 is not F8). Also names the region (`"Notifications (Alt+T)"`). `null` installs no listener. |
|
|
441
|
+
| `announce` | `(toast: ToastItem) => string \| null` | – | The announcement text for every toast (localisation). Default: the text of its Title and Description. |
|
|
442
|
+
| `aria-label` | `string` | `"Notifications (F8)"` | The region's name; yours is used verbatim. |
|
|
443
|
+
| `className` | `string \| ((state: ToastViewportState) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
444
|
+
| `style` | `CSSProperties \| ((state: ToastViewportState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
|
|
445
|
+
| `children` | `ReactNode \| ((state: ToastViewportState) => ReactNode)` | – | Usually a function of the state that maps `state.toasts` to `Toast.Root`s. |
|
|
446
|
+
| `render` | `ReactElement \| ((props, state: ToastViewportState) => ReactNode)` | – | Replace the default \<section> (element form) or take over rendering (function form). |
|
|
447
|
+
|
|
448
|
+
- **State**: `ToastViewportState` is `{ toasts, queued, paused }`; `toasts` is chronological (oldest first) and includes the ones animating out; `paused` is true while a viewport-wide pause holds.
|
|
449
|
+
- **Owned**: `popover` (`"manual"`), `aria-label` (your own wins verbatim), `data-paused`, `data-empty`, and the pointer and focus handlers.
|
|
450
|
+
|
|
451
|
+
### `Toast.Root`
|
|
452
|
+
|
|
453
|
+
| Prop | Type | Default | Description |
|
|
454
|
+
| - | - | - | - |
|
|
455
|
+
| `toast` | `ToastItem` | – | Required. An item of `state.toasts`; key the Root (or its wrapper) on `toast.id`. |
|
|
456
|
+
| `fallback` | `ReactNode` | `null` | Shown inside the Root while its children suspend (a skeleton). The timer and the announcement wait for the reveal; the Root is not `data-pending` meanwhile. Parts inside it (a visually hidden `Toast.Title`) name the toast but gate nothing. |
|
|
457
|
+
| `className` | `string \| ((state: ToastRootState) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
458
|
+
| `style` | `CSSProperties \| ((state: ToastRootState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
|
|
459
|
+
| `children` | `ReactNode \| ((state: ToastRootState) => ReactNode)` | – | Content, or a function of the part's state. |
|
|
460
|
+
| `render` | `ReactElement \| ((props, state: ToastRootState) => ReactNode)` | – | Replace the default \<div> (element form) or take over rendering (function form). |
|
|
461
|
+
|
|
462
|
+
- **State**: `ToastRootState` is `{ toast, pending, ending, type, priority }`.
|
|
463
|
+
- **Owned**: `role` (`dialog`, or `alertdialog` for `priority: "high"`), `tabIndex`, `aria-labelledby`, `aria-describedby`, `inert` (while ending), `onKeyDown`, `data-type`, `data-pending`, `data-ending`.
|
|
464
|
+
|
|
465
|
+
`Toast.Title` (`div`) and `Toast.Description` (`p`) take the same function props against the Root's state; their `children` default to `toast.title` / `toast.description`, and the Description renders nothing when it has neither.
|
|
466
|
+
|
|
467
|
+
### `Toast.Action`
|
|
468
|
+
|
|
469
|
+
| Prop | Type | Default | Description |
|
|
470
|
+
| - | - | - | - |
|
|
471
|
+
| `action` | `Action<[ToastActionDetails]>` | `toast.action.action` | Runs in this part's transition. The part renders nothing when neither it nor the toast has an action. |
|
|
472
|
+
| `closeOnSettle` | `boolean` | `true` | Close the toast (`reason: "activate"`) when the action resolves. |
|
|
473
|
+
| `className` | `string \| ((state: ToastActionState) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
474
|
+
| `style` | `CSSProperties \| ((state: ToastActionState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
|
|
475
|
+
| `children` | `ReactNode \| ((state: ToastActionState) => ReactNode)` | – | Default: `toast.action.label`. |
|
|
476
|
+
| `render` | `ReactElement \| ((props, state: ToastActionState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
|
|
477
|
+
|
|
478
|
+
- **State**: `ToastActionState` is `{ pending, toast }`.
|
|
479
|
+
- **Owned**: `type` (on a `<button>` only), `onClick`, `aria-disabled`, `data-pending`.
|
|
480
|
+
|
|
481
|
+
A second click while the action is pending is ignored (and cancelled): one Undo, one Retry. The Action is `aria-disabled="true"` while it shows `data-pending`, never natively disabled, so it keeps focus.
|
|
482
|
+
|
|
483
|
+
### `Toast.Close`
|
|
484
|
+
|
|
485
|
+
| Prop | Type | Default | Description |
|
|
486
|
+
| - | - | - | - |
|
|
487
|
+
| `className` | `string \| ((state: ToastCloseState) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
488
|
+
| `style` | `CSSProperties \| ((state: ToastCloseState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
|
|
489
|
+
| `children` | `ReactNode \| ((state: ToastCloseState) => ReactNode)` | – | Content, or a function of the part's state. |
|
|
490
|
+
| `render` | `ReactElement \| ((props, state: ToastCloseState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
|
|
491
|
+
|
|
492
|
+
- **State**: `ToastCloseState` is `{ toast }`.
|
|
493
|
+
- **Owned**: `type` (on a `<button>` only), `onClick`.
|
|
494
|
+
|
|
495
|
+
Closes the toast with `reason: "dismiss"`, like Escape. Give it a name (text or `aria-label`); development warns otherwise.
|
|
496
|
+
|
|
497
|
+
## Data attributes
|
|
498
|
+
|
|
499
|
+
| Hook | On | Meaning |
|
|
500
|
+
| - | - | - |
|
|
501
|
+
| `data-pending` | Root, Action | The toast's promise is unsettled, or its Action's action runs (not set while its content merely suspends) |
|
|
502
|
+
| `aria-disabled` | Action | `"true"` while `data-pending`: a second click is ignored |
|
|
503
|
+
| `data-ending` | Root | Closed, kept (and `inert`) until the animations the ending state started finish |
|
|
504
|
+
| `data-type` | Root | The toast's `type` |
|
|
505
|
+
| `data-paused` | Viewport | A viewport-wide timer pause holds; pause a progress bar with it |
|
|
506
|
+
| `data-empty` | Viewport | No toasts rendered |
|
|
507
|
+
|
|
508
|
+
## Keyboard and ARIA
|
|
509
|
+
|
|
510
|
+
| Key | Where | Behaviour |
|
|
511
|
+
| - | - | - |
|
|
512
|
+
| F8 (`hotkey`) | anywhere | Focus the newest toast; nothing (and no `preventDefault`) without toasts |
|
|
513
|
+
| Tab / Shift+Tab | region | Through each toast and its buttons in DOM order; nothing is trapped |
|
|
514
|
+
| ArrowDown / ArrowUp | a toast | Next / previous toast, no wrap. Elements inside that use the arrow keys themselves keep them: text, number, date, range and radio inputs, `textarea`, `select`, contenteditable, and the `textbox`, `combobox`, `spinbutton` and `slider` roles |
|
|
515
|
+
| Escape | a toast | Dismiss it |
|
|
516
|
+
| Enter / Space | Action, Close | Native button activation |
|
|
517
|
+
|
|
518
|
+
- When the toast holding focus closes, focus moves to the next toast, else the previous one, else back to where it was before the region was entered (by F8 or Tab), else the body.
|
|
519
|
+
- F8, not F6: F6 is the browsers' pane-cycling key. Change it with `hotkey`.
|
|
520
|
+
- **Announcements** go through `document.ariaNotify()`, never a live region: after the toast's content has rendered, again when an update changes its text, with `priority: "high"` for high-priority toasts; several toasts in one tick become one announcement. Dismissals are silent. A queued toast is announced when it is added.
|
|
521
|
+
|
|
522
|
+
## Transition types
|
|
523
|
+
|
|
524
|
+
Concept: [Transitions & ViewTransition](../concepts/transitions.md#transition-types)
|
|
525
|
+
|
|
526
|
+
None. Every Toast commit is urgent (so a toast shows even while an async action holds every transition), no part takes a `transition` prop, and React starts view transitions for transition commits only. Animate with CSS (`@starting-style`, `[data-ending]`).
|
|
527
|
+
|
|
528
|
+
## Optimistic and pending
|
|
529
|
+
|
|
530
|
+
Concept: [Pending & optimistic state](../concepts/pending-and-optimistic.md)
|
|
531
|
+
|
|
532
|
+
No optimistic state. `data-pending` is on the Root while the toast's promise is unsettled or its Action's action runs, and on that Action, which is a [pure trigger](../concepts/pending-and-optimistic.md#pure-trigger).
|
|
533
|
+
|
|
534
|
+
## Suspense
|
|
535
|
+
|
|
536
|
+
Concept: [Suspense](../concepts/suspense.md)
|
|
537
|
+
|
|
538
|
+
Toast content may suspend; each Root has its own boundary and a `fallback` prop.
|
|
539
|
+
|
|
540
|
+
Toast content may suspend (`title: <UserName id={id} />`). Each Root wraps its children in its own Suspense boundary, so a suspending toast does not pull the Viewport into the nearest boundary above it (a toast mounts urgently, where that boundary would show its fallback). While the content suspends the Root shows its `fallback` prop (nothing by default), in the same frame as the `toast()` call; the timer does not run and nothing is announced. On the reveal the toast announces its Title and Description and its timer starts. An update whose new content suspends shows the `fallback` again and pauses the timer until the next reveal.
|
|
541
|
+
|
|
542
|
+
```tsx
|
|
543
|
+
<Toast.Root key={t.id} toast={t} fallback={<ToastSkeleton />}>
|
|
544
|
+
<Toast.Title />
|
|
545
|
+
<Toast.Description />
|
|
546
|
+
</Toast.Root>
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
Use `fallback` rather than your own `<Suspense>` inside the Root: the toast is still announced when your boundary reveals its Title and Description, but its timer starts at once, because the library cannot see your boundary's fallback.
|
|
550
|
+
|
|
551
|
+
## Browser-owned state
|
|
552
|
+
|
|
553
|
+
Concept: [Browser-owned state](../concepts/browser-owned-state.md)
|
|
554
|
+
|
|
555
|
+
The region is a `popover="manual"` in the top layer, shown while it has toasts and never light-dismissed. Its stack is library-owned.
|
|
556
|
+
|
|
557
|
+
### Top layer and modal dialogs
|
|
558
|
+
|
|
559
|
+
The region is `popover="manual"`: shown while it has toasts, it neither closes an open menu or popover nor is closed by one, and it has no light dismiss. A toast added while a later menu or popover covers the region raises it to the top again. A top-layer element outside an open modal `<dialog>` is inert, so while a [Dialog](dialog.md) is open as a modal the region moves into it (and back when it closes): an Undo stays clickable. The move keeps the toasts' React state (an Undo in flight stays pending), but it is a DOM move: the toasts' enter animation plays again and focus inside a toast is lost. Dialogs the library did not open are not detected.
|
|
560
|
+
|
|
561
|
+
## Before hydration
|
|
562
|
+
|
|
563
|
+
Concept: [Server Components](../concepts/server-components.md#before-hydration)
|
|
564
|
+
|
|
565
|
+
Toasts appear only after hydration.
|
|
566
|
+
|
|
567
|
+
`<Toast.Viewport>` takes a function child, so render it from a Client Component file that a Server Component layout includes. On the server it renders the empty region. `toast()` is client code: a Server Function returns data and the client calls `toast()` with it (in the action that called it, or in an effect on `useActionState`'s result).
|
|
568
|
+
|
|
569
|
+
## Styling
|
|
570
|
+
|
|
571
|
+
Enter with `@starting-style`, exit on `[data-ending]`: the library keeps a closed toast mounted until the animations (transitions included) that `[data-ending]` started finish. Animations already running in the toast, such as a progress bar paused with `data-paused`, are not waited for. Toasts never use `<ViewTransition>` and no part has a `transition` prop: every Toast commit is urgent, and react-dom starts view transitions for transition commits only. Make the region's box click-through with `pointer-events: none` and give it back to the toasts; stack visually with `flex-direction: column-reverse` and `:nth-last-child()`.
|
|
572
|
+
|
|
573
|
+
## Browser notes
|
|
574
|
+
|
|
575
|
+
- `ariaNotify` is in Chrome 141, Firefox 150 and Safari 27; where it is missing nothing is announced and nothing throws.
|
|
576
|
+
- No swipe to dismiss yet: Close, Escape and the timer cover WCAG 2.5.1.
|