@funstack/ui 0.1.0-alpha.15 → 0.1.0-alpha.17
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 +3 -1
- 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 +46 -15
- package/dist/button/button.d.mts.map +1 -1
- package/dist/button/button.mjs +10 -6
- 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 +7 -1
- 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 +20 -1
- 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 +64 -17
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +11 -11
- 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 +9 -2
- 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 +31 -3
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +5 -2
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.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 +20 -2
- 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 +34 -8
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +14 -20
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +53 -25
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +12 -8
- 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 +19 -3
- 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 +7 -5
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +7 -5
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/docs/components/accordion.md +426 -0
- package/dist/docs/components/button.md +508 -0
- package/dist/docs/components/checkbox-group.md +483 -0
- package/dist/docs/components/checkbox.md +373 -0
- package/dist/docs/components/combobox.md +698 -0
- package/dist/docs/components/context-menu.md +524 -0
- package/dist/docs/components/dialog.md +692 -0
- package/dist/docs/components/field.md +587 -0
- package/dist/docs/components/menu.md +670 -0
- package/dist/docs/components/meter.md +313 -0
- package/dist/docs/components/number-field.md +528 -0
- package/dist/docs/components/popover.md +656 -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 +599 -0
- package/dist/docs/components/toggle-group.md +341 -0
- package/dist/docs/components/toggle.md +245 -0
- package/dist/docs/components/toolbar.md +390 -0
- package/dist/docs/components/tooltip.md +494 -0
- package/dist/docs/concepts/action-props.md +281 -0
- package/dist/docs/concepts/ai-agents.md +56 -0
- package/dist/docs/concepts/browser-owned-state.md +133 -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 +263 -0
- package/dist/docs/concepts/render.md +23 -0
- package/dist/docs/concepts/server-components.md +132 -0
- package/dist/docs/concepts/suspense.md +129 -0
- package/dist/docs/concepts/transitions.md +112 -0
- package/dist/docs/getting-started.md +102 -0
- package/dist/docs/index.md +182 -0
- package/dist/docs/roadmap.md +128 -0
- package/dist/docs/why.md +104 -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 +3 -2
- package/dist/internal/call-urgent-handler.mjs +37 -0
- package/dist/internal/call-urgent-handler.mjs.map +1 -0
- package/dist/internal/css-transition-cut.mjs +66 -0
- package/dist/internal/css-transition-cut.mjs.map +1 -0
- package/dist/internal/overlay-popup.mjs.map +1 -1
- package/dist/internal/report-dropped.mjs +45 -0
- package/dist/internal/report-dropped.mjs.map +1 -0
- package/dist/internal/types.d.mts +36 -7
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-action-trigger.mjs +32 -17
- package/dist/internal/use-action-trigger.mjs.map +1 -1
- package/dist/internal/use-controllable-action.mjs +52 -16
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-exit-animation.mjs +1 -1
- package/dist/internal/use-exit-animation.mjs.map +1 -1
- package/dist/internal/use-native-group-reconciliation.mjs +4 -2
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-overlay-close.mjs +10 -4
- package/dist/internal/use-overlay-close.mjs.map +1 -1
- package/dist/internal/use-overlay-root.mjs +40 -7
- package/dist/internal/use-overlay-root.mjs.map +1 -1
- package/dist/internal/use-popover-popup.mjs +22 -7
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.d.mts +2 -1
- package/dist/internal/use-popover-trigger.d.mts.map +1 -1
- package/dist/internal/use-popover-trigger.mjs +11 -3
- 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 +27 -3
- 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 +38 -5
- package/dist/menu/menu-item.d.mts.map +1 -1
- package/dist/menu/menu-item.mjs +12 -5
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-outside.mjs +2 -2
- package/dist/menu/menu-outside.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 +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 +49 -15
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +7 -4
- 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 +4 -8
- 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 +5 -3
- package/dist/popover/index.d.mts.map +1 -1
- package/dist/popover/index.mjs +5 -3
- package/dist/popover/index.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts +32 -3
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +6 -2
- 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 +36 -7
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +5 -2
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.d.mts +40 -18
- package/dist/popover/popover-root.d.mts.map +1 -1
- package/dist/popover/popover-root.mjs +11 -7
- 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 +4 -8
- 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 +42 -6
- package/dist/toast/toast-action.d.mts.map +1 -1
- package/dist/toast/toast-action.mjs +8 -4
- 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-context.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-queue.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 +17 -15
- package/dist/toast/toast-viewport.mjs.map +1 -1
- package/dist/toast/toast.d.mts +56 -13
- 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 +3 -1
- 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
- package/dist/internal/use-superseded-rejection.mjs +0 -47
- package/dist/internal/use-superseded-rejection.mjs.map +0 -1
package/dist/tabs/tabs-tab.d.mts
CHANGED
|
@@ -2,19 +2,35 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { TabsOrientation } from "./tabs-context.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode, ViewTransitionClass } from "react";
|
|
4
4
|
//#region src/tabs/tabs-tab.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* State of `Tabs.Tab`, passed to the function forms of `className`, `style`, `children` and
|
|
7
|
+
* `render`.
|
|
8
|
+
*/
|
|
5
9
|
export interface TabsTabState {
|
|
10
|
+
/** The Tab's `value` prop. */
|
|
6
11
|
readonly value: string;
|
|
7
12
|
/** Optimistic: true as soon as the user selects this tab, before the action settles. */
|
|
8
13
|
readonly selected: boolean;
|
|
9
14
|
/** The Root is pending and this tab is the optimistic target. */
|
|
10
15
|
readonly pending: boolean;
|
|
16
|
+
/** Disabled by its own prop or by the Root. */
|
|
11
17
|
readonly disabled: boolean;
|
|
18
|
+
/** The Root's `orientation`. */
|
|
12
19
|
readonly orientation: TabsOrientation;
|
|
13
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Props of `Tabs.Tab`.
|
|
23
|
+
*
|
|
24
|
+
* @see https://ui.funstack.work/components/tabs
|
|
25
|
+
*/
|
|
14
26
|
export interface TabsTabProps extends Omit<ComponentPropsWithRef<"button">, "onClick" | "onKeyDown" | "onFocus" | "id" | "value" | "className" | "style" | "children"> {
|
|
15
27
|
/** The value this tab selects. Must be unique within the Root. */
|
|
16
28
|
value: string;
|
|
17
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Focusable but inert: `aria-disabled="true"`, never dispatches.
|
|
31
|
+
*
|
|
32
|
+
* @defaultValue `false`
|
|
33
|
+
*/
|
|
18
34
|
disabled?: boolean;
|
|
19
35
|
/**
|
|
20
36
|
* Forwarded to the Tab's `<ViewTransition default>`. Default: no boundary. Fires only on the commit
|
|
@@ -26,10 +42,13 @@ export interface TabsTabProps extends Omit<ComponentPropsWithRef<"button">, "onC
|
|
|
26
42
|
* page cross-fade that the next transition waits for).
|
|
27
43
|
*/
|
|
28
44
|
transition?: ViewTransitionClass;
|
|
45
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
29
46
|
className?: StateValue<string | undefined, TabsTabState>;
|
|
47
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
30
48
|
style?: StateValue<CSSProperties | undefined, TabsTabState>;
|
|
31
49
|
/** Rendered from optimistic state; must not suspend. */
|
|
32
50
|
children?: StateValue<ReactNode, TabsTabState>;
|
|
51
|
+
/** Replace the default `<button>` (element form) or take over rendering (function form). */
|
|
33
52
|
render?: RenderProp<ComponentPropsWithRef<"button">, TabsTabState>;
|
|
34
53
|
}
|
|
35
54
|
/**
|
|
@@ -39,6 +58,8 @@ export interface TabsTabProps extends Omit<ComponentPropsWithRef<"button">, "onC
|
|
|
39
58
|
* Owned keys (conventions 1.2): `role`, `id`, `aria-selected`, `aria-controls` (token-merged),
|
|
40
59
|
* `aria-disabled`, `tabIndex`, `focusgroupstart` (with `experimental_focusgroup`), `data-selected`, `data-pending`, `data-disabled`,
|
|
41
60
|
* `data-orientation`, `onClick`, `onKeyDown`, `onFocus`.
|
|
61
|
+
*
|
|
62
|
+
* @see https://ui.funstack.work/components/tabs
|
|
42
63
|
*/
|
|
43
64
|
export declare function TabsTab({ value, disabled: disabledProp, transition, className, style, children, render, ...rest }: TabsTabProps): ReactNode;
|
|
44
65
|
export declare namespace TabsTab {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs-tab.d.mts","names":[],"sources":["../../src/tabs/tabs-tab.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tabs-tab.d.mts","names":[],"sources":["../../src/tabs/tabs-tab.tsx"],"mappings":";;;;;;;;iBAuBiB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,aAAa;;;;;;;iBAQP,qBAAqB,KACpC;;EAIA;;;;;;EAMA;;;;;;;;;;EAUA,aAAa;;EAEb,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;wBA6BvC,UACd,OACA,UAAU,cACV,YACA,WACA,OACA,UACA,WACG,QACF,eAAY;yBATC"}
|
package/dist/tabs/tabs-tab.mjs
CHANGED
|
@@ -23,6 +23,8 @@ function movedWithinList(event) {
|
|
|
23
23
|
* Owned keys (conventions 1.2): `role`, `id`, `aria-selected`, `aria-controls` (token-merged),
|
|
24
24
|
* `aria-disabled`, `tabIndex`, `focusgroupstart` (with `experimental_focusgroup`), `data-selected`, `data-pending`, `data-disabled`,
|
|
25
25
|
* `data-orientation`, `onClick`, `onKeyDown`, `onFocus`.
|
|
26
|
+
*
|
|
27
|
+
* @see https://ui.funstack.work/components/tabs
|
|
26
28
|
*/
|
|
27
29
|
function TabsTab({ value, disabled: disabledProp = false, transition, className, style, children, render, ...rest }) {
|
|
28
30
|
const ctx = useTabsContext("Tabs.Tab");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs-tab.mjs","names":[],"sources":["../../src/tabs/tabs-tab.tsx"],"sourcesContent":["\"use client\";\nimport { use } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { rendersButton, resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport { TabsListContext, useTabsContext } from \"./tabs-context.js\";\nimport type { TabsOrientation } from \"./tabs-context.js\";\nimport { anchorName, panelId, tabId } from \"./tabs-ids.js\";\n\nexport interface TabsTabState {\n readonly value: string;\n /** Optimistic: true as soon as the user selects this tab, before the action settles. */\n readonly selected: boolean;\n /** The Root is pending and this tab is the optimistic target. */\n readonly pending: boolean;\n readonly disabled: boolean;\n readonly orientation: TabsOrientation;\n}\n\nexport interface TabsTabProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"onKeyDown\" | \"onFocus\" | \"id\" | \"value\" | \"className\" | \"style\" | \"children\"\n> {\n /** The value this tab selects. Must be unique within the Root. */\n value: string;\n
|
|
1
|
+
{"version":3,"file":"tabs-tab.mjs","names":[],"sources":["../../src/tabs/tabs-tab.tsx"],"sourcesContent":["\"use client\";\nimport { use } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { rendersButton, resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport { TabsListContext, useTabsContext } from \"./tabs-context.js\";\nimport type { TabsOrientation } from \"./tabs-context.js\";\nimport { anchorName, panelId, tabId } from \"./tabs-ids.js\";\n\n/**\n * State of `Tabs.Tab`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface TabsTabState {\n /** The Tab's `value` prop. */\n readonly value: string;\n /** Optimistic: true as soon as the user selects this tab, before the action settles. */\n readonly selected: boolean;\n /** The Root is pending and this tab is the optimistic target. */\n readonly pending: boolean;\n /** Disabled by its own prop or by the Root. */\n readonly disabled: boolean;\n /** The Root's `orientation`. */\n readonly orientation: TabsOrientation;\n}\n\n/**\n * Props of `Tabs.Tab`.\n *\n * @see https://ui.funstack.work/components/tabs\n */\nexport interface TabsTabProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"onKeyDown\" | \"onFocus\" | \"id\" | \"value\" | \"className\" | \"style\" | \"children\"\n> {\n /** The value this tab selects. Must be unique within the Root. */\n value: string;\n /**\n * Focusable but inert: `aria-disabled=\"true\"`, never dispatches.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /**\n * Forwarded to the Tab's `<ViewTransition default>`. Default: no boundary. Fires only on the commit\n * that settles the action (or rolls it back), never on the optimistic selection; animate the\n * selection itself with a CSS `transition` on `[data-selected]`.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, TabsTabState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, TabsTabState>;\n /** Rendered from optimistic state; must not suspend. */\n children?: StateValue<ReactNode, TabsTabState>;\n /** Replace the default `<button>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, TabsTabState>;\n}\n\nfunction isActivationKey(event: KeyboardEvent): boolean {\n return (\n (event.key === \"Enter\" || event.key === \" \") &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey\n );\n}\n\n/** Focus came from another element inside the tab's own tablist (not from the list itself). */\nfunction movedWithinList(event: FocusEvent<HTMLElement>): boolean {\n const list = event.currentTarget.closest('[role=\"tablist\"]');\n const from = event.relatedTarget;\n return list !== null && from instanceof Node && from !== list && list.contains(from);\n}\n\n/**\n * A `button[role=tab]`. Renders the optimistic selection (`aria-selected`, `data-selected`,\n * roving `tabindex`) and carries `anchor-name` for the Indicator.\n *\n * Owned keys (conventions 1.2): `role`, `id`, `aria-selected`, `aria-controls` (token-merged),\n * `aria-disabled`, `tabIndex`, `focusgroupstart` (with `experimental_focusgroup`), `data-selected`, `data-pending`, `data-disabled`,\n * `data-orientation`, `onClick`, `onKeyDown`, `onFocus`.\n *\n * @see https://ui.funstack.work/components/tabs\n */\nexport function TabsTab({\n value,\n disabled: disabledProp = false,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: TabsTabProps) {\n const ctx = useTabsContext(\"Tabs.Tab\");\n const listCtx = use(TabsListContext);\n const selected = ctx.optimistic === value;\n const pending = ctx.pending && selected;\n const disabled = ctx.disabled || disabledProp;\n const anchor = anchorName(ctx.rootId, value);\n\n const state: TabsTabState = {\n value,\n selected,\n pending,\n disabled,\n orientation: ctx.orientation,\n };\n\n const element = useRender<ComponentPropsWithRef<\"button\">, TabsTabState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n // `anchor-name` sits under the consumer's style: the consumer wins (design 13.5).\n style: (s) => ({ anchorName: anchor, ...resolveStateValue(style, s) }),\n children,\n // `type=\"button\"` only on a real button (no form submission); an `<a>` must not get it.\n props: rendersButton(render) ? { ...rest, type: \"button\" } : rest,\n libraryProps: {\n role: \"tab\",\n id: tabId(ctx.rootId, value),\n \"aria-selected\": selected,\n \"aria-controls\": panelId(ctx.rootId, value),\n \"aria-disabled\": disabled ? true : undefined,\n // Roving tabindex, except on the native `focusgroup` path, where the browser owns the tab\n // stop and a negative tabindex would take the Tab out of the group (TabsListContextValue).\n tabIndex: selected ? 0 : listCtx?.nativeFocusgroup ? undefined : -1,\n // Always rendered with the flag (inert where unsupported), so markup is stable.\n ...(listCtx?.focusgroup === true && { focusgroupstart: selected ? \"\" : undefined }),\n \"data-selected\": dataAttr(selected),\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n \"data-orientation\": ctx.orientation,\n onClick: (event: MouseEvent<HTMLButtonElement>) => {\n if (disabled) return;\n ctx.select(value, event.nativeEvent, \"activate\");\n },\n // Enter and Space are handled on keydown so a `render`ed non-button element (a link)\n // behaves the same; `preventDefault` also stops the native click / navigation.\n onKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => {\n if (!isActivationKey(event)) return;\n event.preventDefault();\n if (disabled) return;\n ctx.select(value, event.nativeEvent, \"activate\");\n },\n // Automatic activation is selection-follows-focus (design 4.1), but only for focus that\n // moves between tabs inside this list (the arrow-key path, the native `focusgroup` path,\n // programmatic movement). Focus entering from outside never selects: the Tab key, window\n // re-activation, focus restore, `autoFocus`, and the List's own redirect when no tab is the\n // tab stop. A click still selects through `onClick`.\n onFocus: (event: FocusEvent<HTMLButtonElement>) => {\n if (ctx.activationMode !== \"automatic\" || disabled || selected) return;\n if (!movedWithinList(event)) return;\n ctx.select(value, event.nativeEvent, \"activate\");\n },\n },\n });\n\n return useTransitionBoundary(\"Tabs.Tab\", transition, element);\n}\n\nTabsTab.displayName = \"TabsTab\";\n"],"mappings":";;;;;;;;;AAyEA,SAAS,gBAAgB,OAA+B;CACtD,QACG,MAAM,QAAQ,WAAW,MAAM,QAAQ,QACxC,CAAC,MAAM,UACP,CAAC,MAAM,WACP,CAAC,MAAM;AAEX;;AAGA,SAAS,gBAAgB,OAAyC;CAChE,MAAM,OAAO,MAAM,cAAc,QAAQ,oBAAkB;CAC3D,MAAM,OAAO,MAAM;CACnB,OAAO,SAAS,QAAQ,gBAAgB,QAAQ,SAAS,QAAQ,KAAK,SAAS,IAAI;AACrF;;;;;;;;;;;AAYA,SAAgB,QAAQ,EACtB,OACA,UAAU,eAAe,OACzB,YACA,WACA,OACA,UACA,QACA,GAAG,QACY;CACf,MAAM,MAAM,eAAe,UAAU;CACrC,MAAM,UAAU,IAAI,eAAe;CACnC,MAAM,WAAW,IAAI,eAAe;CACpC,MAAM,UAAU,IAAI,WAAW;CAC/B,MAAM,WAAW,IAAI,YAAY;CACjC,MAAM,SAAS,WAAW,IAAI,QAAQ,KAAK;CAE3C,MAAM,QAAsB;EAC1B;EACA;EACA;EACA;EACA,aAAa,IAAI;CACnB;CAEA,MAAM,UAAU,UAAyD;EACvE,gBAAgB;EAChB;EACA;EACA;EAEA,QAAQ,OAAO;GAAE,YAAY;GAAQ,GAAG,kBAAkB,OAAO,CAAC;EAAE;EACpE;EAEA,OAAO,cAAc,MAAM,IAAI;GAAE,GAAG;GAAM,MAAM;EAAS,IAAI;EAC7D,cAAc;GACZ,MAAM;GACN,IAAI,MAAM,IAAI,QAAQ,KAAK;GAC3B,iBAAiB;GACjB,iBAAiB,QAAQ,IAAI,QAAQ,KAAK;GAC1C,iBAAiB,WAAW,OAAO,KAAA;GAGnC,UAAU,WAAW,IAAI,SAAS,mBAAmB,KAAA,IAAY;GAEjE,GAAI,SAAS,eAAe,QAAQ,EAAE,iBAAiB,WAAW,KAAK,KAAA,EAAU;GACjF,iBAAiB,SAAS,QAAQ;GAClC,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;GAClC,oBAAoB,IAAI;GACxB,UAAU,UAAyC;IACjD,IAAI,UAAU;IACd,IAAI,OAAO,OAAO,MAAM,aAAa,UAAU;GACjD;GAGA,YAAY,UAA4C;IACtD,IAAI,CAAC,gBAAgB,KAAK,GAAG;IAC7B,MAAM,eAAe;IACrB,IAAI,UAAU;IACd,IAAI,OAAO,OAAO,MAAM,aAAa,UAAU;GACjD;GAMA,UAAU,UAAyC;IACjD,IAAI,IAAI,mBAAmB,eAAe,YAAY,UAAU;IAChE,IAAI,CAAC,gBAAgB,KAAK,GAAG;IAC7B,IAAI,OAAO,OAAO,MAAM,aAAa,UAAU;GACjD;EACF;CACF,CAAC;CAED,OAAO,sBAAsB,YAAY,YAAY,OAAO;AAC9D;AAEA,QAAQ,cAAc"}
|
package/dist/toast/index.d.mts
CHANGED
|
@@ -11,6 +11,8 @@ import { ToastViewport, ToastViewportProps, ToastViewportState } from "./toast-v
|
|
|
11
11
|
* once, even while the action it reports on is pending); its output is `Toast.Viewport`
|
|
12
12
|
* (`section[popover=manual]`, rendered once) mapping `state.toasts` to `Toast.Root`
|
|
13
13
|
* (`div[role=dialog]`) > `Title`, `Description`, `Action` (an action prop, e.g. Undo), `Close`.
|
|
14
|
+
*
|
|
15
|
+
* @see https://ui.funstack.work/components/toast
|
|
14
16
|
*/
|
|
15
17
|
export declare const Toast: {
|
|
16
18
|
readonly Viewport: typeof ToastViewport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/toast/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/toast/index.ts"],"mappings":";;;;;;;;;;;;;;;;qBAea;WACX,iBAAQ;WACR,aAAI;WACJ,cAAK;WACL,oBAAW;WACX,eAAM;WACN,cAAK"}
|
package/dist/toast/index.mjs
CHANGED
|
@@ -11,6 +11,8 @@ import { ToastViewport } from "./toast-viewport.mjs";
|
|
|
11
11
|
* once, even while the action it reports on is pending); its output is `Toast.Viewport`
|
|
12
12
|
* (`section[popover=manual]`, rendered once) mapping `state.toasts` to `Toast.Root`
|
|
13
13
|
* (`div[role=dialog]`) > `Title`, `Description`, `Action` (an action prop, e.g. Undo), `Close`.
|
|
14
|
+
*
|
|
15
|
+
* @see https://ui.funstack.work/components/toast
|
|
14
16
|
*/
|
|
15
17
|
const Toast = {
|
|
16
18
|
Viewport: ToastViewport,
|
package/dist/toast/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/toast/index.ts"],"sourcesContent":["import { ToastAction } from \"./toast-action.js\";\nimport { ToastClose } from \"./toast-close.js\";\nimport { ToastDescription } from \"./toast-description.js\";\nimport { ToastRoot } from \"./toast-root.js\";\nimport { ToastTitle } from \"./toast-title.js\";\nimport { ToastViewport } from \"./toast-viewport.js\";\n\n/**\n * Toast notifications. The queue's input is the `toast()` function (urgent: a toast shows at\n * once, even while the action it reports on is pending); its output is `Toast.Viewport`\n * (`section[popover=manual]`, rendered once) mapping `state.toasts` to `Toast.Root`\n * (`div[role=dialog]`) > `Title`, `Description`, `Action` (an action prop, e.g. Undo), `Close`.\n */\nexport const Toast = {\n Viewport: ToastViewport,\n Root: ToastRoot,\n Title: ToastTitle,\n Description: ToastDescription,\n Action: ToastAction,\n Close: ToastClose,\n} as const;\n\nexport { toast, createToastManager } from \"./toast.js\";\nexport type {\n ToastOptions,\n ToastItem,\n ToastPriority,\n ToastActionOptions,\n ToastActionDetails,\n ToastCloseDetails,\n ToastPromiseOptions,\n ToastManager,\n} from \"./toast.js\";\nexport type { ToastViewportProps, ToastViewportState } from \"./toast-viewport.js\";\nexport type { ToastRootProps, ToastRootState } from \"./toast-root.js\";\nexport type { ToastTitleProps } from \"./toast-title.js\";\nexport type { ToastDescriptionProps } from \"./toast-description.js\";\nexport type { ToastActionProps, ToastActionState } from \"./toast-action.js\";\nexport type { ToastCloseProps, ToastCloseState } from \"./toast-close.js\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/toast/index.ts"],"sourcesContent":["import { ToastAction } from \"./toast-action.js\";\nimport { ToastClose } from \"./toast-close.js\";\nimport { ToastDescription } from \"./toast-description.js\";\nimport { ToastRoot } from \"./toast-root.js\";\nimport { ToastTitle } from \"./toast-title.js\";\nimport { ToastViewport } from \"./toast-viewport.js\";\n\n/**\n * Toast notifications. The queue's input is the `toast()` function (urgent: a toast shows at\n * once, even while the action it reports on is pending); its output is `Toast.Viewport`\n * (`section[popover=manual]`, rendered once) mapping `state.toasts` to `Toast.Root`\n * (`div[role=dialog]`) > `Title`, `Description`, `Action` (an action prop, e.g. Undo), `Close`.\n *\n * @see https://ui.funstack.work/components/toast\n */\nexport const Toast = {\n Viewport: ToastViewport,\n Root: ToastRoot,\n Title: ToastTitle,\n Description: ToastDescription,\n Action: ToastAction,\n Close: ToastClose,\n} as const;\n\nexport { toast, createToastManager } from \"./toast.js\";\nexport type {\n ToastOptions,\n ToastItem,\n ToastPriority,\n ToastActionOptions,\n ToastActionDetails,\n ToastCloseDetails,\n ToastPromiseOptions,\n ToastManager,\n} from \"./toast.js\";\nexport type { ToastViewportProps, ToastViewportState } from \"./toast-viewport.js\";\nexport type { ToastRootProps, ToastRootState } from \"./toast-root.js\";\nexport type { ToastTitleProps } from \"./toast-title.js\";\nexport type { ToastDescriptionProps } from \"./toast-description.js\";\nexport type { ToastActionProps, ToastActionState } from \"./toast-action.js\";\nexport type { ToastCloseProps, ToastCloseState } from \"./toast-close.js\";\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAa,QAAQ;CACnB,UAAU;CACV,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,OAAO;AACT"}
|
|
@@ -1,38 +1,74 @@
|
|
|
1
|
-
import { Action, RenderProp, StateValue } from "../internal/types.mjs";
|
|
1
|
+
import { Action, RenderProp, StateValue, WhilePending } from "../internal/types.mjs";
|
|
2
2
|
import { ToastActionDetails, ToastItem } from "./toast.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/toast/toast-action.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* State of `Toast.Action`, passed to the function forms of `className`, `style`, `children` and
|
|
7
|
+
* `render`.
|
|
8
|
+
*/
|
|
5
9
|
export interface ToastActionState {
|
|
6
10
|
/** This part's action is in flight. */
|
|
7
11
|
readonly pending: boolean;
|
|
12
|
+
/** The toast this Action belongs to. */
|
|
8
13
|
readonly toast: ToastItem;
|
|
9
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Props of `Toast.Action`.
|
|
17
|
+
*
|
|
18
|
+
* @see https://ui.funstack.work/components/toast
|
|
19
|
+
*/
|
|
10
20
|
export interface ToastActionProps extends Omit<ComponentPropsWithRef<"button">, "onClick" | "className" | "style" | "children"> {
|
|
11
21
|
/**
|
|
12
22
|
* Runs in this part's own transition: `data-pending` on the Action and the Root, the toast's
|
|
13
23
|
* timer paused. When it resolves the toast closes with `reason: "activate"` (unless
|
|
14
24
|
* `closeOnSettle` is `false`); a rejection keeps the toast and reaches the nearest Error
|
|
15
25
|
* Boundary above the Viewport. A caught error counts as success and closes the toast: rethrow
|
|
16
|
-
* after `toast.update`, or use `closeOnSettle={false}`.
|
|
26
|
+
* after `toast.update`, or use `closeOnSettle={false}`.
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue the toast's `action.action`
|
|
17
29
|
*/
|
|
18
30
|
action?: Action<[details: ToastActionDetails]>;
|
|
19
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Close the toast when the action resolves.
|
|
33
|
+
*
|
|
34
|
+
* @defaultValue `true`
|
|
35
|
+
*/
|
|
20
36
|
closeOnSettle?: boolean;
|
|
21
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* What a click does while this part's action is pending. `"ignore"`: nothing (the click is
|
|
39
|
+
* cancelled, `aria-disabled="true"` meanwhile): one Undo, one Retry. `"run"`: the action runs
|
|
40
|
+
* again; the Action and the Root stay `data-pending` and the timer paused until every run has
|
|
41
|
+
* settled. With `closeOnSettle` the toast then closes once, if the latest run resolved; a
|
|
42
|
+
* rejected latest run keeps it, as in `"ignore"` mode.
|
|
43
|
+
*
|
|
44
|
+
* @defaultValue `"ignore"`, or `"run"` with `closeOnSettle={false}`
|
|
45
|
+
*/
|
|
46
|
+
whilePending?: WhilePending;
|
|
47
|
+
/**
|
|
48
|
+
* The button's content, or a function of the part's state.
|
|
49
|
+
*
|
|
50
|
+
* @defaultValue the toast's `action.label`
|
|
51
|
+
*/
|
|
22
52
|
children?: StateValue<ReactNode, ToastActionState>;
|
|
53
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
23
54
|
className?: StateValue<string | undefined, ToastActionState>;
|
|
55
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
24
56
|
style?: StateValue<CSSProperties | undefined, ToastActionState>;
|
|
57
|
+
/** Replace the default `<button>` (element form) or take over rendering (function form). */
|
|
25
58
|
render?: RenderProp<ComponentPropsWithRef<"button">, ToastActionState>;
|
|
26
59
|
}
|
|
27
60
|
/**
|
|
28
61
|
* The toast's action button (Undo, Retry, View): a `button type="button"` whose `action` runs as
|
|
29
62
|
* a transition. Renders nothing when neither the part nor the toast has an action. Never natively
|
|
30
|
-
* disabled while pending: a second click meanwhile is ignored and the Action is `aria-disabled
|
|
63
|
+
* disabled while pending: a second click meanwhile is ignored and the Action is `aria-disabled`,
|
|
64
|
+
* unless `whilePending` is `"run"` (the default with `closeOnSettle={false}`).
|
|
31
65
|
*
|
|
32
66
|
* Owned keys (conventions 1.2): `type` (on a `<button>` only), `onClick`, `aria-disabled`,
|
|
33
67
|
* `data-pending`.
|
|
68
|
+
*
|
|
69
|
+
* @see https://ui.funstack.work/components/toast
|
|
34
70
|
*/
|
|
35
|
-
export declare function ToastAction({ action, closeOnSettle, children, className, style, render, ...rest }: ToastActionProps): ReactNode;
|
|
71
|
+
export declare function ToastAction({ action, closeOnSettle, whilePending, children, className, style, render, ...rest }: ToastActionProps): ReactNode;
|
|
36
72
|
export declare namespace ToastAction {
|
|
37
73
|
var displayName: string;
|
|
38
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-action.d.mts","names":[],"sources":["../../src/toast/toast-action.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"toast-action.d.mts","names":[],"sources":["../../src/toast/toast-action.tsx"],"mappings":";;;;;;;;iBAgBiB;;WAEN;;WAEA,OAAO;;;;;;;iBAQD,yBAAyB,KACxC;;;;;;;;;;EAYA,SAAS,QAAQ,SAAS;;;;;;EAM1B;;;;;;;;;;EAUA,eAAe;;;;;;EAMf,WAAW,WAAW,WAAW;;EAEjC,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;wBAcvC,cACd,QACA,eACA,cACA,UACA,WACA,OACA,WACG,QACF,mBAAgB;yBATH"}
|
|
@@ -10,14 +10,18 @@ import { useLayoutEffect, useState } from "react";
|
|
|
10
10
|
/**
|
|
11
11
|
* The toast's action button (Undo, Retry, View): a `button type="button"` whose `action` runs as
|
|
12
12
|
* a transition. Renders nothing when neither the part nor the toast has an action. Never natively
|
|
13
|
-
* disabled while pending: a second click meanwhile is ignored and the Action is `aria-disabled
|
|
13
|
+
* disabled while pending: a second click meanwhile is ignored and the Action is `aria-disabled`,
|
|
14
|
+
* unless `whilePending` is `"run"` (the default with `closeOnSettle={false}`).
|
|
14
15
|
*
|
|
15
16
|
* Owned keys (conventions 1.2): `type` (on a `<button>` only), `onClick`, `aria-disabled`,
|
|
16
17
|
* `data-pending`.
|
|
18
|
+
*
|
|
19
|
+
* @see https://ui.funstack.work/components/toast
|
|
17
20
|
*/
|
|
18
|
-
function ToastAction({ action, closeOnSettle = true, children, className, style, render, ...rest }) {
|
|
21
|
+
function ToastAction({ action, closeOnSettle = true, whilePending, children, className, style, render, ...rest }) {
|
|
19
22
|
const root = useToastRootContext("Toast.Action");
|
|
20
|
-
const
|
|
23
|
+
const ignoring = (whilePending ?? (closeOnSettle ? "ignore" : "run")) === "ignore";
|
|
24
|
+
const { pending, run } = useActionTrigger({ ignoreWhilePending: ignoring });
|
|
21
25
|
const [token] = useState(() => ({}));
|
|
22
26
|
const effective = action ?? root.toast.action?.action;
|
|
23
27
|
const { setActionPending } = root;
|
|
@@ -45,7 +49,7 @@ function ToastAction({ action, closeOnSettle = true, children, className, style,
|
|
|
45
49
|
const libraryProps = {
|
|
46
50
|
...rendersButton(render) && { type: "button" },
|
|
47
51
|
onClick,
|
|
48
|
-
"aria-disabled": pending ? true : void 0,
|
|
52
|
+
"aria-disabled": pending && ignoring ? true : void 0,
|
|
49
53
|
"data-pending": dataAttr(pending)
|
|
50
54
|
};
|
|
51
55
|
const element = useRender({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-action.mjs","names":[],"sources":["../../src/toast/toast-action.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect, useState } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { Action, RenderProp, StateValue } from \"../internal/types.js\";\nimport { useActionTrigger } from \"../internal/use-action-trigger.js\";\nimport { rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport type { ToastActionDetails, ToastItem } from \"./toast.js\";\nimport { useToastRootContext } from \"./toast-context.js\";\n\nexport interface ToastActionState {\n /** This part's action is in flight. */\n readonly pending: boolean;\n readonly toast: ToastItem;\n}\n\nexport interface ToastActionProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Runs in this part's own transition: `data-pending` on the Action and the Root, the toast's\n * timer paused. When it resolves the toast closes with `reason: \"activate\"` (unless\n * `closeOnSettle` is `false`); a rejection keeps the toast and reaches the nearest Error\n * Boundary above the Viewport. A caught error counts as success and closes the toast: rethrow\n * after `toast.update`, or use `closeOnSettle={false}
|
|
1
|
+
{"version":3,"file":"toast-action.mjs","names":[],"sources":["../../src/toast/toast-action.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect, useState } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { Action, RenderProp, StateValue, WhilePending } from \"../internal/types.js\";\nimport { useActionTrigger } from \"../internal/use-action-trigger.js\";\nimport { rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport type { ToastActionDetails, ToastItem } from \"./toast.js\";\nimport { useToastRootContext } from \"./toast-context.js\";\n\n/**\n * State of `Toast.Action`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface ToastActionState {\n /** This part's action is in flight. */\n readonly pending: boolean;\n /** The toast this Action belongs to. */\n readonly toast: ToastItem;\n}\n\n/**\n * Props of `Toast.Action`.\n *\n * @see https://ui.funstack.work/components/toast\n */\nexport interface ToastActionProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Runs in this part's own transition: `data-pending` on the Action and the Root, the toast's\n * timer paused. When it resolves the toast closes with `reason: \"activate\"` (unless\n * `closeOnSettle` is `false`); a rejection keeps the toast and reaches the nearest Error\n * Boundary above the Viewport. A caught error counts as success and closes the toast: rethrow\n * after `toast.update`, or use `closeOnSettle={false}`.\n *\n * @defaultValue the toast's `action.action`\n */\n action?: Action<[details: ToastActionDetails]>;\n /**\n * Close the toast when the action resolves.\n *\n * @defaultValue `true`\n */\n closeOnSettle?: boolean;\n /**\n * What a click does while this part's action is pending. `\"ignore\"`: nothing (the click is\n * cancelled, `aria-disabled=\"true\"` meanwhile): one Undo, one Retry. `\"run\"`: the action runs\n * again; the Action and the Root stay `data-pending` and the timer paused until every run has\n * settled. With `closeOnSettle` the toast then closes once, if the latest run resolved; a\n * rejected latest run keeps it, as in `\"ignore\"` mode.\n *\n * @defaultValue `\"ignore\"`, or `\"run\"` with `closeOnSettle={false}`\n */\n whilePending?: WhilePending;\n /**\n * The button's content, or a function of the part's state.\n *\n * @defaultValue the toast's `action.label`\n */\n children?: StateValue<ReactNode, ToastActionState>;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, ToastActionState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, ToastActionState>;\n /** Replace the default `<button>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ToastActionState>;\n}\n\n/**\n * The toast's action button (Undo, Retry, View): a `button type=\"button\"` whose `action` runs as\n * a transition. Renders nothing when neither the part nor the toast has an action. Never natively\n * disabled while pending: a second click meanwhile is ignored and the Action is `aria-disabled`,\n * unless `whilePending` is `\"run\"` (the default with `closeOnSettle={false}`).\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `onClick`, `aria-disabled`,\n * `data-pending`.\n *\n * @see https://ui.funstack.work/components/toast\n */\nexport function ToastAction({\n action,\n closeOnSettle = true,\n whilePending,\n children,\n className,\n style,\n render,\n ...rest\n}: ToastActionProps) {\n const root = useToastRootContext(\"Toast.Action\");\n // Mixed ownership (conventions 2.5.1): ignore while the library closes the toast after the\n // action; a toast that stays makes the Action a user-owned trigger.\n const ignoring = (whilePending ?? (closeOnSettle ? \"ignore\" : \"run\")) === \"ignore\";\n const { pending, run } = useActionTrigger({ ignoreWhilePending: ignoring });\n const [token] = useState(() => ({}));\n const effective = action ?? root.toast.action?.action;\n const { setActionPending } = root;\n\n // The Root (and through it the Viewport's timer) sees this part's pending state.\n useLayoutEffect(() => {\n if (!pending) return;\n setActionPending(token, true);\n return () => setActionPending(token, false);\n }, [pending, setActionPending, token]);\n\n const state: ToastActionState = { pending, toast: root.toast };\n\n const onClick = (event: MouseEvent<HTMLElement>): void => {\n if (effective === undefined || rest.disabled === true) return;\n const native = event.nativeEvent;\n const details = createActionDetails(native, { id: root.toast.id });\n // When ignoring, a second click while this Action's own run is in flight starts nothing and\n // is cancelled (the hook's guard): one Undo, one Retry.\n const started = run(\n () => effective(details),\n () => {\n // Closing is idempotent: a dismissal meanwhile already closed it.\n if (closeOnSettle) root.close(\"activate\", native);\n },\n );\n if (!started) event.preventDefault();\n };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n onClick,\n // Exactly while `data-pending` when ignoring. Owned, so an idle Action removes a render\n // element's own.\n \"aria-disabled\": pending && ignoring ? true : undefined,\n \"data-pending\": dataAttr(pending),\n };\n\n const element = useRender<ComponentPropsWithRef<\"button\">, ToastActionState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children: children ?? root.toast.action?.label,\n props: rest,\n libraryProps,\n });\n return effective === undefined ? null : element;\n}\n\nToastAction.displayName = \"ToastAction\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmFA,SAAgB,YAAY,EAC1B,QACA,gBAAgB,MAChB,cACA,UACA,WACA,OACA,QACA,GAAG,QACgB;CACnB,MAAM,OAAO,oBAAoB,cAAc;CAG/C,MAAM,YAAY,iBAAiB,gBAAgB,WAAW,YAAY;CAC1E,MAAM,EAAE,SAAS,QAAQ,iBAAiB,EAAE,oBAAoB,SAAS,CAAC;CAC1E,MAAM,CAAC,SAAS,gBAAgB,CAAC,EAAE;CACnC,MAAM,YAAY,UAAU,KAAK,MAAM,QAAQ;CAC/C,MAAM,EAAE,qBAAqB;CAG7B,sBAAsB;EACpB,IAAI,CAAC,SAAS;EACd,iBAAiB,OAAO,IAAI;EAC5B,aAAa,iBAAiB,OAAO,KAAK;CAC5C,GAAG;EAAC;EAAS;EAAkB;CAAK,CAAC;CAErC,MAAM,QAA0B;EAAE;EAAS,OAAO,KAAK;CAAM;CAE7D,MAAM,WAAW,UAAyC;EACxD,IAAI,cAAc,KAAA,KAAa,KAAK,aAAa,MAAM;EACvD,MAAM,SAAS,MAAM;EACrB,MAAM,UAAU,oBAAoB,QAAQ,EAAE,IAAI,KAAK,MAAM,GAAG,CAAC;EAUjE,IAAI,CAPY,UACR,UAAU,OAAO,SACjB;GAEJ,IAAI,eAAe,KAAK,MAAM,YAAY,MAAM;EAClD,CAES,GAAG,MAAM,eAAe;CACrC;CAEA,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EACvD;EAGA,iBAAiB,WAAW,WAAW,OAAO,KAAA;EAC9C,gBAAgB,SAAS,OAAO;CAClC;CAEA,MAAM,UAAU,UAA6D;EAC3E,gBAAgB;EAChB;EACA;EACA;EACA;EACA,UAAU,YAAY,KAAK,MAAM,QAAQ;EACzC,OAAO;EACP;CACF,CAAC;CACD,OAAO,cAAc,KAAA,IAAY,OAAO;AAC1C;AAEA,YAAY,cAAc"}
|
|
@@ -2,13 +2,27 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { ToastItem } from "./toast.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/toast/toast-close.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* State of `Toast.Close`, passed to the function forms of `className`, `style`, `children` and
|
|
7
|
+
* `render`.
|
|
8
|
+
*/
|
|
5
9
|
export interface ToastCloseState {
|
|
10
|
+
/** The toast this Close belongs to. */
|
|
6
11
|
readonly toast: ToastItem;
|
|
7
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Props of `Toast.Close`.
|
|
15
|
+
*
|
|
16
|
+
* @see https://ui.funstack.work/components/toast
|
|
17
|
+
*/
|
|
8
18
|
export interface ToastCloseProps extends Omit<ComponentPropsWithRef<"button">, "onClick" | "className" | "style" | "children"> {
|
|
19
|
+
/** Content, or a function of the part's state. */
|
|
9
20
|
children?: StateValue<ReactNode, ToastCloseState>;
|
|
21
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
10
22
|
className?: StateValue<string | undefined, ToastCloseState>;
|
|
23
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
11
24
|
style?: StateValue<CSSProperties | undefined, ToastCloseState>;
|
|
25
|
+
/** Replace the default `<button>` (element form) or take over rendering (function form). */
|
|
12
26
|
render?: RenderProp<ComponentPropsWithRef<"button">, ToastCloseState>;
|
|
13
27
|
}
|
|
14
28
|
/**
|
|
@@ -16,6 +30,8 @@ export interface ToastCloseProps extends Omit<ComponentPropsWithRef<"button">, "
|
|
|
16
30
|
* or text). No Invoker Command: `hide-popover` would hide the whole region.
|
|
17
31
|
*
|
|
18
32
|
* Owned keys (conventions 1.2): `type` (on a `<button>` only), `onClick`.
|
|
33
|
+
*
|
|
34
|
+
* @see https://ui.funstack.work/components/toast
|
|
19
35
|
*/
|
|
20
36
|
export declare function ToastClose({ children, className, style, render, ...rest }: ToastCloseProps): ReactNode;
|
|
21
37
|
export declare namespace ToastClose {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-close.d.mts","names":[],"sources":["../../src/toast/toast-close.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"toast-close.d.mts","names":[],"sources":["../../src/toast/toast-close.tsx"],"mappings":";;;;;;;;iBAeiB;;WAEN,OAAO;;;;;;;iBAQD,wBAAwB,KACvC;;EAIA,WAAW,WAAW,WAAW;;EAEjC,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,iCAAiC;;;;;;;;;;wBAWvC,aAAa,UAAU,WAAW,OAAO,WAAW,QAAQ,kBAAe;yBAA3E"}
|
|
@@ -10,6 +10,8 @@ const isDev = process.env.NODE_ENV !== "production";
|
|
|
10
10
|
* or text). No Invoker Command: `hide-popover` would hide the whole region.
|
|
11
11
|
*
|
|
12
12
|
* Owned keys (conventions 1.2): `type` (on a `<button>` only), `onClick`.
|
|
13
|
+
*
|
|
14
|
+
* @see https://ui.funstack.work/components/toast
|
|
13
15
|
*/
|
|
14
16
|
function ToastClose({ children, className, style, render, ...rest }) {
|
|
15
17
|
const root = useToastRootContext("Toast.Close");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-close.mjs","names":[],"sources":["../../src/toast/toast-close.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { TEXT_NAME, useNameWarning } from \"../internal/use-name-warning.js\";\nimport { rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport type { ToastItem } from \"./toast.js\";\nimport { useToastRootContext } from \"./toast-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ToastCloseState {\n readonly toast: ToastItem;\n}\n\nexport interface ToastCloseProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"className\" | \"style\" | \"children\"\n> {\n children?: StateValue<ReactNode, ToastCloseState>;\n className?: StateValue<string | undefined, ToastCloseState>;\n style?: StateValue<CSSProperties | undefined, ToastCloseState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ToastCloseState>;\n}\n\n/**\n * Dismisses the toast (`reason: \"dismiss\"`, the same as Escape). Label it yourself (`aria-label`\n * or text). No Invoker Command: `hide-popover` would hide the whole region.\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `onClick`.\n */\nexport function ToastClose({ children, className, style, render, ...rest }: ToastCloseProps) {\n const root = useToastRootContext(\"Toast.Close\");\n\n const devRef = useNameWarning(\n isDev && \"Toast.Close: the button has no accessible name. Give it text or an `aria-label`.\",\n TEXT_NAME,\n );\n\n const onClick = (event: MouseEvent<HTMLElement>): void => {\n if (rest.disabled === true) return;\n root.close(\"dismiss\", event.nativeEvent);\n };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n onClick,\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, ToastCloseState>({\n defaultElement: \"button\",\n render,\n state: { toast: root.toast },\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref: devRef,\n });\n}\n\nToastClose.displayName = \"ToastClose\";\n"],"mappings":";;;;;;AASA,MAAM,QAAQ,QAAQ,IAAI,aAAa
|
|
1
|
+
{"version":3,"file":"toast-close.mjs","names":[],"sources":["../../src/toast/toast-close.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { TEXT_NAME, useNameWarning } from \"../internal/use-name-warning.js\";\nimport { rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport type { ToastItem } from \"./toast.js\";\nimport { useToastRootContext } from \"./toast-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * State of `Toast.Close`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface ToastCloseState {\n /** The toast this Close belongs to. */\n readonly toast: ToastItem;\n}\n\n/**\n * Props of `Toast.Close`.\n *\n * @see https://ui.funstack.work/components/toast\n */\nexport interface ToastCloseProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"className\" | \"style\" | \"children\"\n> {\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, ToastCloseState>;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, ToastCloseState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, ToastCloseState>;\n /** Replace the default `<button>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ToastCloseState>;\n}\n\n/**\n * Dismisses the toast (`reason: \"dismiss\"`, the same as Escape). Label it yourself (`aria-label`\n * or text). No Invoker Command: `hide-popover` would hide the whole region.\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `onClick`.\n *\n * @see https://ui.funstack.work/components/toast\n */\nexport function ToastClose({ children, className, style, render, ...rest }: ToastCloseProps) {\n const root = useToastRootContext(\"Toast.Close\");\n\n const devRef = useNameWarning(\n isDev && \"Toast.Close: the button has no accessible name. Give it text or an `aria-label`.\",\n TEXT_NAME,\n );\n\n const onClick = (event: MouseEvent<HTMLElement>): void => {\n if (rest.disabled === true) return;\n root.close(\"dismiss\", event.nativeEvent);\n };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n onClick,\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, ToastCloseState>({\n defaultElement: \"button\",\n render,\n state: { toast: root.toast },\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref: devRef,\n });\n}\n\nToastClose.displayName = \"ToastClose\";\n"],"mappings":";;;;;;AASA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;AAsCvC,SAAgB,WAAW,EAAE,UAAU,WAAW,OAAO,QAAQ,GAAG,QAAyB;CAC3F,MAAM,OAAO,oBAAoB,aAAa;CAE9C,MAAM,SAAS,eACb,SAAS,oFACT,SACF;CAEA,MAAM,WAAW,UAAyC;EACxD,IAAI,KAAK,aAAa,MAAM;EAC5B,KAAK,MAAM,WAAW,MAAM,WAAW;CACzC;CAEA,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EACvD;CACF;CAEA,OAAO,UAA4D;EACjE,gBAAgB;EAChB;EACA,OAAO,EAAE,OAAO,KAAK,MAAM;EAC3B;EACA;EACA;EACA,OAAO;EACP;EACA,KAAK;CACP,CAAC;AACH;AAEA,WAAW,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-context.mjs","names":[],"sources":["../../src/toast/toast-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { ChangeReason } from \"../internal/types.js\";\nimport type { ToastRootState } from \"./toast-root.js\";\nimport type { ToastItem, ToastPriority } from \"./toast.js\";\n\n/** What a Root (and the parts under it) need from the Viewport. Stable for the Viewport's life. */\nexport interface ToastViewportContextValue {\n /** Close toasts (`ending: true`), moving focus out first and
|
|
1
|
+
{"version":3,"file":"toast-context.mjs","names":[],"sources":["../../src/toast/toast-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { ChangeReason } from \"../internal/types.js\";\nimport type { ToastRootState } from \"./toast-root.js\";\nimport type { ToastItem, ToastPriority } from \"./toast.js\";\n\n/** What a Root (and the parts under it) need from the Viewport. Stable for the Viewport's life. */\nexport interface ToastViewportContextValue {\n /** Close toasts (`ending: true`), moving focus out first and calling each `onClose`. */\n readonly close: (ids: readonly string[], reason: ChangeReason, event: Event | undefined) => void;\n /** Remove an ending toast once its exit animations finished. */\n readonly drop: (id: string) => void;\n /** An action dispatched through the toast's Action part is (no longer) in flight. */\n readonly setActionPending: (id: string, pending: boolean) => void;\n /** The toast's content is (no longer) suspended behind the Root's guard. */\n readonly setSuspended: (id: string, suspended: boolean) => void;\n /** The Root's element, for arrow keys, the hotkey and focus moves; `null` to unregister. */\n readonly registerRoot: (id: string, element: HTMLElement | null) => void;\n /** Focus the next (`1`) or previous (`-1`) toast's Root, without wrapping. */\n readonly focusSibling: (id: string, direction: 1 | -1) => void;\n /** Queue an announcement; skipped when `text` equals the last one announced for `id`. */\n readonly announce: (id: string, text: string | null, priority: ToastPriority) => void;\n /** The Viewport's `announce` prop, read at announcement time. */\n readonly announcer: () => ((toast: ToastItem) => string | null) | undefined;\n /**\n * The animations that ran in the toast before it was marked ending (kept until it is dropped\n * or replaced): its exit waits only for the others.\n */\n readonly exitBaseline: (id: string) => ReadonlySet<Animation> | undefined;\n}\n\nexport const ToastViewportContext = createContext<ToastViewportContextValue | null>(null);\n\nexport function useToastViewportContext(part: string): ToastViewportContextValue {\n const context = use(ToastViewportContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Toast.Viewport.`);\n }\n return context;\n}\n\n/** What the parts inside a Root need. */\nexport interface ToastRootContextValue {\n readonly toast: ToastItem;\n readonly ids: { readonly title: string; readonly description: string };\n /** Root state, so Title and Description can resolve their function props against it. */\n readonly state: ToastRootState;\n readonly registerTitle: (element: HTMLElement | null) => void;\n readonly registerDescription: (element: HTMLElement | null) => void;\n /** An Action part's run is (no longer) in flight; `token` identifies the part. */\n readonly setActionPending: (token: object, pending: boolean) => void;\n /**\n * A Title or Description committed: mounted, or shown again by a Suspense boundary inside the\n * Root (the consumer's skeleton), so the Root announces the text that now exists.\n */\n readonly contentCommitted: () => void;\n /** The Suspense guard mounted (`true`) or unmounted (`false`). */\n readonly setSuspended: (suspended: boolean) => void;\n /** Close this toast. */\n readonly close: (reason: ChangeReason, event: Event | undefined) => void;\n}\n\nexport const ToastRootContext = createContext<ToastRootContextValue | null>(null);\n\nexport function useToastRootContext(part: string): ToastRootContextValue {\n const context = use(ToastRootContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Toast.Root.`);\n }\n return context;\n}\n"],"mappings":";;;AA+BA,MAAa,uBAAuB,cAAgD,IAAI;AAExF,SAAgB,wBAAwB,MAAyC;CAC/E,MAAM,UAAU,IAAI,oBAAoB;CACxC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,2CAA2C;CAErE,OAAO;AACT;AAuBA,MAAa,mBAAmB,cAA4C,IAAI;AAEhF,SAAgB,oBAAoB,MAAqC;CACvE,MAAM,UAAU,IAAI,gBAAgB;CACpC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,uCAAuC;CAEjE,OAAO;AACT"}
|
|
@@ -2,11 +2,24 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { ToastRootState } from "./toast-root.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/toast/toast-description.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props of `Toast.Description`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ui.funstack.work/components/toast
|
|
9
|
+
*/
|
|
5
10
|
export interface ToastDescriptionProps extends Omit<ComponentPropsWithRef<"p">, "id" | "className" | "style" | "children"> {
|
|
6
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* The description shown, or a function of the part's state. Without either, nothing is
|
|
13
|
+
* rendered.
|
|
14
|
+
*
|
|
15
|
+
* @defaultValue the toast's `description`
|
|
16
|
+
*/
|
|
7
17
|
children?: StateValue<ReactNode, ToastRootState>;
|
|
18
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
8
19
|
className?: StateValue<string | undefined, ToastRootState>;
|
|
20
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
9
21
|
style?: StateValue<CSSProperties | undefined, ToastRootState>;
|
|
22
|
+
/** Replace the default `<p>` (element form) or take over rendering (function form). */
|
|
10
23
|
render?: RenderProp<ComponentPropsWithRef<"p">, ToastRootState>;
|
|
11
24
|
}
|
|
12
25
|
/**
|
|
@@ -15,6 +28,8 @@ export interface ToastDescriptionProps extends Omit<ComponentPropsWithRef<"p">,
|
|
|
15
28
|
* default announcement.
|
|
16
29
|
*
|
|
17
30
|
* Owned key (conventions 1.2): `id`.
|
|
31
|
+
*
|
|
32
|
+
* @see https://ui.funstack.work/components/toast
|
|
18
33
|
*/
|
|
19
34
|
export declare function ToastDescription({ children, className, style, render, ...rest }: ToastDescriptionProps): ReactNode;
|
|
20
35
|
export declare namespace ToastDescription {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-description.d.mts","names":[],"sources":["../../src/toast/toast-description.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"toast-description.d.mts","names":[],"sources":["../../src/toast/toast-description.tsx"],"mappings":";;;;;;;;;iBAaiB,8BAA8B,KAC7C;;;;;;;EASA,WAAW,WAAW,WAAW;;EAEjC,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,4BAA4B;;;;;;;;;;;wBAYlC,mBACd,UACA,WACA,OACA,WACG,QACF,wBAAqB;yBANR"}
|
|
@@ -9,6 +9,8 @@ import { useLayoutEffect } from "react";
|
|
|
9
9
|
* default announcement.
|
|
10
10
|
*
|
|
11
11
|
* Owned key (conventions 1.2): `id`.
|
|
12
|
+
*
|
|
13
|
+
* @see https://ui.funstack.work/components/toast
|
|
12
14
|
*/
|
|
13
15
|
function ToastDescription({ children, className, style, render, ...rest }) {
|
|
14
16
|
const root = useToastRootContext("Toast.Description");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-description.mjs","names":[],"sources":["../../src/toast/toast-description.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useToastRootContext } from \"./toast-context.js\";\nimport type { ToastRootState } from \"./toast-root.js\";\n\nexport interface ToastDescriptionProps extends Omit<\n ComponentPropsWithRef<\"p\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n
|
|
1
|
+
{"version":3,"file":"toast-description.mjs","names":[],"sources":["../../src/toast/toast-description.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useToastRootContext } from \"./toast-context.js\";\nimport type { ToastRootState } from \"./toast-root.js\";\n\n/**\n * Props of `Toast.Description`.\n *\n * @see https://ui.funstack.work/components/toast\n */\nexport interface ToastDescriptionProps extends Omit<\n ComponentPropsWithRef<\"p\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * The description shown, or a function of the part's state. Without either, nothing is\n * rendered.\n *\n * @defaultValue the toast's `description`\n */\n children?: StateValue<ReactNode, ToastRootState>;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, ToastRootState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, ToastRootState>;\n /** Replace the default `<p>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"p\">, ToastRootState>;\n}\n\n/**\n * The toast's description: a `p` whose id the Root references with `aria-describedby`. Renders\n * nothing when the part has no `children` and the toast no `description`. Its text is part of the\n * default announcement.\n *\n * Owned key (conventions 1.2): `id`.\n *\n * @see https://ui.funstack.work/components/toast\n */\nexport function ToastDescription({\n children,\n className,\n style,\n render,\n ...rest\n}: ToastDescriptionProps) {\n const root = useToastRootContext(\"Toast.Description\");\n const content = children ?? root.toast.description;\n // Mounted, or revealed by a Suspense boundary inside the Root: announce the text now present.\n const { contentCommitted } = root;\n useLayoutEffect(() => contentCommitted(), [contentCommitted]);\n const element = useRender<ComponentPropsWithRef<\"p\">, ToastRootState>({\n defaultElement: \"p\",\n render,\n state: root.state,\n className,\n style,\n children: content,\n props: rest,\n libraryProps: { id: root.ids.description },\n ref: root.registerDescription,\n });\n return content == null || content === false ? null : element;\n}\n\nToastDescription.displayName = \"ToastDescription\";\n"],"mappings":";;;;;;;;;;;;;;AAyCA,SAAgB,iBAAiB,EAC/B,UACA,WACA,OACA,QACA,GAAG,QACqB;CACxB,MAAM,OAAO,oBAAoB,mBAAmB;CACpD,MAAM,UAAU,YAAY,KAAK,MAAM;CAEvC,MAAM,EAAE,qBAAqB;CAC7B,sBAAsB,iBAAiB,GAAG,CAAC,gBAAgB,CAAC;CAC5D,MAAM,UAAU,UAAsD;EACpE,gBAAgB;EAChB;EACA,OAAO,KAAK;EACZ;EACA;EACA,UAAU;EACV,OAAO;EACP,cAAc,EAAE,IAAI,KAAK,IAAI,YAAY;EACzC,KAAK,KAAK;CACZ,CAAC;CACD,OAAO,WAAW,QAAQ,YAAY,QAAQ,OAAO;AACvD;AAEA,iBAAiB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-queue.mjs","names":[],"sources":["../../src/toast/toast-queue.ts"],"sourcesContent":["// The Viewport's queue model (design/components/toast.md 8, 12): entries, their public items, and\n// which of them render. No \"use client\" directive: pure (conventions 7.1).\nimport type { ToastCommand, ToastItem, ToastOptions } from \"./toast.js\";\n\n/** One queue entry: the toast's options and the flags its `ToastItem` is built from. */\nexport interface Entry {\n readonly options: ToastOptions & { readonly id: string };\n readonly promisePending: boolean;\n readonly actionPending: boolean;\n readonly ending: boolean;\n /** The public item, rebuilt whenever any of the above changes (stable identity otherwise). */\n readonly item: ToastItem;\n}\n\nexport function makeEntry(\n options: ToastOptions & { readonly id: string },\n flags: { promisePending: boolean; actionPending: boolean; ending: boolean },\n): Entry {\n return {\n options,\n ...flags,\n item: {\n ...options,\n id: options.id,\n pending: flags.promisePending || flags.actionPending,\n ending: flags.ending,\n },\n };\n}\n\nexport function withFlags(\n entry: Entry,\n flags: Partial<{ promisePending: boolean; actionPending: boolean; ending: boolean }>,\n): Entry {\n return makeEntry(entry.options, {\n promisePending: flags.promisePending ?? entry.promisePending,\n actionPending: flags.actionPending ?? entry.actionPending,\n ending: flags.ending ?? entry.ending,\n });\n}\n\n/** Rendered entries (the first `limit` open ones plus every ending one) and the queued count. */\nexport function partition(\n entries: readonly Entry[],\n limit: number,\n): { visible: Entry[]; queued: Entry[] } {\n const visible: Entry[] = [];\n const queued: Entry[] = [];\n let open = 0;\n for (const entry of entries) {\n if (entry.ending) visible.push(entry);\n else if (open < limit) {\n visible.push(entry);\n open++;\n } else queued.push(entry);\n }\n return { visible, queued };\n}\n\n/** Plain text of a `ReactNode` that is text (queued toasts have no DOM to read yet). */\nexport function plainText(node: unknown): string {\n if (typeof node === \"string\") return node;\n if (typeof node === \"number\" || typeof node === \"bigint\") return String(node);\n if (Array.isArray(node)) return node.map(plainText).join(\"\");\n return \"\";\n}\n\nexport interface AppliedCommands {\n readonly next: readonly Entry[];\n /** The open toasts the batch dismissed, in order (their `
|
|
1
|
+
{"version":3,"file":"toast-queue.mjs","names":[],"sources":["../../src/toast/toast-queue.ts"],"sourcesContent":["// The Viewport's queue model (design/components/toast.md 8, 12): entries, their public items, and\n// which of them render. No \"use client\" directive: pure (conventions 7.1).\nimport type { ToastCommand, ToastItem, ToastOptions } from \"./toast.js\";\n\n/** One queue entry: the toast's options and the flags its `ToastItem` is built from. */\nexport interface Entry {\n readonly options: ToastOptions & { readonly id: string };\n readonly promisePending: boolean;\n readonly actionPending: boolean;\n readonly ending: boolean;\n /** The public item, rebuilt whenever any of the above changes (stable identity otherwise). */\n readonly item: ToastItem;\n}\n\nexport function makeEntry(\n options: ToastOptions & { readonly id: string },\n flags: { promisePending: boolean; actionPending: boolean; ending: boolean },\n): Entry {\n return {\n options,\n ...flags,\n item: {\n ...options,\n id: options.id,\n pending: flags.promisePending || flags.actionPending,\n ending: flags.ending,\n },\n };\n}\n\nexport function withFlags(\n entry: Entry,\n flags: Partial<{ promisePending: boolean; actionPending: boolean; ending: boolean }>,\n): Entry {\n return makeEntry(entry.options, {\n promisePending: flags.promisePending ?? entry.promisePending,\n actionPending: flags.actionPending ?? entry.actionPending,\n ending: flags.ending ?? entry.ending,\n });\n}\n\n/** Rendered entries (the first `limit` open ones plus every ending one) and the queued count. */\nexport function partition(\n entries: readonly Entry[],\n limit: number,\n): { visible: Entry[]; queued: Entry[] } {\n const visible: Entry[] = [];\n const queued: Entry[] = [];\n let open = 0;\n for (const entry of entries) {\n if (entry.ending) visible.push(entry);\n else if (open < limit) {\n visible.push(entry);\n open++;\n } else queued.push(entry);\n }\n return { visible, queued };\n}\n\n/** Plain text of a `ReactNode` that is text (queued toasts have no DOM to read yet). */\nexport function plainText(node: unknown): string {\n if (typeof node === \"string\") return node;\n if (typeof node === \"number\" || typeof node === \"bigint\") return String(node);\n if (Array.isArray(node)) return node.map(plainText).join(\"\");\n return \"\";\n}\n\nexport interface AppliedCommands {\n readonly next: readonly Entry[];\n /** The open toasts the batch dismissed, in order (their `onClose` handlers run). */\n readonly dismissed: readonly Entry[];\n /** Dismissed ids that leave the DOM: not those replaced by a later add with the id. */\n readonly leaving: ReadonlySet<string>;\n /**\n * Ids whose announcement and exit baseline start over: dismissed before they rendered, or an\n * ending toast replaced by a new one with its id (listed in `replaced` too).\n */\n readonly forgotten: readonly string[];\n /** Ending toasts replaced by a new add with their id: their timer starts over. */\n readonly replaced: readonly string[];\n /** The batch added a toast (the region re-raises). */\n readonly added: boolean;\n /** Ids of updates that found no toast (a promise settle excepted). */\n readonly missing: readonly string[];\n}\n\n/**\n * Applies a batch of manager commands to the queue. Dismissals apply in order: each closes the\n * toasts open at that point of the batch, never one added after it. A dismissed toast with a\n * rendered Root (`isRendered`) turns ending; one never rendered (queued beyond `limit`, or added\n * in this tick) leaves at once instead of mounting once as an ending Root. An add with the id of\n * an open toast updates it (\"one toast per key\"); with the id of an ending one it replaces it\n * (the keyed Root may be reused): a fresh timer, a fresh announcement, no exit.\n */\nexport function applyCommands(\n entries: readonly Entry[],\n commands: readonly ToastCommand[],\n isRendered: (id: string) => boolean,\n): AppliedCommands {\n const next = [...entries];\n const dismissed: Entry[] = [];\n const forgotten: string[] = [];\n const replaced: string[] = [];\n const missing: string[] = [];\n let added = false;\n for (const command of commands) {\n if (command.kind === \"dismiss\") {\n for (let i = 0; i < next.length; i++) {\n const entry = next[i]!;\n if (entry.ending) continue;\n const id = entry.options.id;\n if (command.id !== undefined && id !== command.id) continue;\n dismissed.push(entry);\n if (isRendered(id)) {\n next[i] = withFlags(entry, { ending: true });\n } else {\n next.splice(i--, 1);\n forgotten.push(id);\n }\n }\n continue;\n }\n const index = next.findIndex((e) => e.options.id === command.id);\n const existing = index === -1 ? undefined : next[index]!;\n if (command.kind === \"add\") {\n const options = { ...command.options, id: command.id };\n if (existing !== undefined && !existing.ending) {\n next[index] = makeEntry(\n { ...existing.options, ...options },\n {\n promisePending: command.pending || existing.promisePending,\n actionPending: existing.actionPending,\n ending: false,\n },\n );\n continue;\n }\n if (existing !== undefined) {\n next.splice(index, 1);\n replaced.push(command.id);\n forgotten.push(command.id);\n }\n next.push(\n makeEntry(options, {\n promisePending: command.pending,\n actionPending: false,\n ending: false,\n }),\n );\n added = true;\n } else {\n if (existing === undefined) {\n if (!command.settle) missing.push(command.id);\n continue;\n }\n if (existing.ending) continue;\n const options = command.settle\n ? { ...command.options, id: command.id }\n : { ...existing.options, ...command.options, id: command.id };\n next[index] = makeEntry(options, {\n promisePending: command.settle ? false : existing.promisePending,\n actionPending: existing.actionPending,\n ending: false,\n });\n }\n }\n const stays = new Set(next.filter((e) => !e.ending).map((e) => e.options.id));\n const leaving = new Set(dismissed.map((e) => e.options.id).filter((id) => !stays.has(id)));\n return { next, dismissed, leaving, forgotten, replaced, added, missing };\n}\n"],"mappings":";AAcA,SAAgB,UACd,SACA,OACO;CACP,OAAO;EACL;EACA,GAAG;EACH,MAAM;GACJ,GAAG;GACH,IAAI,QAAQ;GACZ,SAAS,MAAM,kBAAkB,MAAM;GACvC,QAAQ,MAAM;EAChB;CACF;AACF;AAEA,SAAgB,UACd,OACA,OACO;CACP,OAAO,UAAU,MAAM,SAAS;EAC9B,gBAAgB,MAAM,kBAAkB,MAAM;EAC9C,eAAe,MAAM,iBAAiB,MAAM;EAC5C,QAAQ,MAAM,UAAU,MAAM;CAChC,CAAC;AACH;;AAGA,SAAgB,UACd,SACA,OACuC;CACvC,MAAM,UAAmB,CAAC;CAC1B,MAAM,SAAkB,CAAC;CACzB,IAAI,OAAO;CACX,KAAK,MAAM,SAAS,SAClB,IAAI,MAAM,QAAQ,QAAQ,KAAK,KAAK;MAC/B,IAAI,OAAO,OAAO;EACrB,QAAQ,KAAK,KAAK;EAClB;CACF,OAAO,OAAO,KAAK,KAAK;CAE1B,OAAO;EAAE;EAAS;CAAO;AAC3B;;AAGA,SAAgB,UAAU,MAAuB;CAC/C,IAAI,OAAO,SAAS,UAAU,OAAO;CACrC,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU,OAAO,OAAO,IAAI;CAC5E,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO,KAAK,IAAI,SAAS,CAAC,CAAC,KAAK,EAAE;CAC3D,OAAO;AACT;;;;;;;;;AA6BA,SAAgB,cACd,SACA,UACA,YACiB;CACjB,MAAM,OAAO,CAAC,GAAG,OAAO;CACxB,MAAM,YAAqB,CAAC;CAC5B,MAAM,YAAsB,CAAC;CAC7B,MAAM,WAAqB,CAAC;CAC5B,MAAM,UAAoB,CAAC;CAC3B,IAAI,QAAQ;CACZ,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,QAAQ,SAAS,WAAW;GAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;IACpC,MAAM,QAAQ,KAAK;IACnB,IAAI,MAAM,QAAQ;IAClB,MAAM,KAAK,MAAM,QAAQ;IACzB,IAAI,QAAQ,OAAO,KAAA,KAAa,OAAO,QAAQ,IAAI;IACnD,UAAU,KAAK,KAAK;IACpB,IAAI,WAAW,EAAE,GACf,KAAK,KAAK,UAAU,OAAO,EAAE,QAAQ,KAAK,CAAC;SACtC;KACL,KAAK,OAAO,KAAK,CAAC;KAClB,UAAU,KAAK,EAAE;IACnB;GACF;GACA;EACF;EACA,MAAM,QAAQ,KAAK,WAAW,MAAM,EAAE,QAAQ,OAAO,QAAQ,EAAE;EAC/D,MAAM,WAAW,UAAU,KAAK,KAAA,IAAY,KAAK;EACjD,IAAI,QAAQ,SAAS,OAAO;GAC1B,MAAM,UAAU;IAAE,GAAG,QAAQ;IAAS,IAAI,QAAQ;GAAG;GACrD,IAAI,aAAa,KAAA,KAAa,CAAC,SAAS,QAAQ;IAC9C,KAAK,SAAS,UACZ;KAAE,GAAG,SAAS;KAAS,GAAG;IAAQ,GAClC;KACE,gBAAgB,QAAQ,WAAW,SAAS;KAC5C,eAAe,SAAS;KACxB,QAAQ;IACV,CACF;IACA;GACF;GACA,IAAI,aAAa,KAAA,GAAW;IAC1B,KAAK,OAAO,OAAO,CAAC;IACpB,SAAS,KAAK,QAAQ,EAAE;IACxB,UAAU,KAAK,QAAQ,EAAE;GAC3B;GACA,KAAK,KACH,UAAU,SAAS;IACjB,gBAAgB,QAAQ;IACxB,eAAe;IACf,QAAQ;GACV,CAAC,CACH;GACA,QAAQ;EACV,OAAO;GACL,IAAI,aAAa,KAAA,GAAW;IAC1B,IAAI,CAAC,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,EAAE;IAC5C;GACF;GACA,IAAI,SAAS,QAAQ;GAIrB,KAAK,SAAS,UAHE,QAAQ,SACpB;IAAE,GAAG,QAAQ;IAAS,IAAI,QAAQ;GAAG,IACrC;IAAE,GAAG,SAAS;IAAS,GAAG,QAAQ;IAAS,IAAI,QAAQ;GAAG,GAC7B;IAC/B,gBAAgB,QAAQ,SAAS,QAAQ,SAAS;IAClD,eAAe,SAAS;IACxB,QAAQ;GACV,CAAC;EACH;CACF;CACA,MAAM,QAAQ,IAAI,IAAI,KAAK,QAAQ,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC;CAE5E,OAAO;EAAE;EAAM;EAAW,SAAA,IADN,IAAI,UAAU,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CACxD;EAAG;EAAW;EAAU;EAAO;CAAQ;AACzE"}
|
|
@@ -2,26 +2,44 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { ToastItem, ToastPriority } from "./toast.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/toast/toast-root.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* State of `Toast.Root`, `Toast.Title`, `Toast.Description`, passed to the function forms of
|
|
7
|
+
* `className`, `style`, `children` and `render`.
|
|
8
|
+
*/
|
|
5
9
|
export interface ToastRootState {
|
|
10
|
+
/** The toast this Root renders (the Root's `toast` prop). */
|
|
6
11
|
readonly toast: ToastItem;
|
|
7
12
|
/** `toast.pending`: its promise is unsettled or its Action runs. */
|
|
8
13
|
readonly pending: boolean;
|
|
9
14
|
/** `toast.ending`: closed, kept for its exit animation. */
|
|
10
15
|
readonly ending: boolean;
|
|
16
|
+
/** `toast.type`, rendered as `data-type`. */
|
|
11
17
|
readonly type: string | undefined;
|
|
18
|
+
/** `toast.priority`, resolved (`"normal"` when absent). */
|
|
12
19
|
readonly priority: ToastPriority;
|
|
13
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Props of `Toast.Root`.
|
|
23
|
+
*
|
|
24
|
+
* @see https://ui.funstack.work/components/toast
|
|
25
|
+
*/
|
|
14
26
|
export interface ToastRootProps extends Omit<ComponentPropsWithRef<"div">, "role" | "className" | "style" | "children" | "onKeyDown"> {
|
|
15
27
|
/** The toast to render: an item of the Viewport's `state.toasts`. */
|
|
16
28
|
toast: ToastItem;
|
|
29
|
+
/** Content, or a function of the part's state. */
|
|
17
30
|
children?: StateValue<ReactNode, ToastRootState>;
|
|
31
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
18
32
|
className?: StateValue<string | undefined, ToastRootState>;
|
|
33
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
19
34
|
style?: StateValue<CSSProperties | undefined, ToastRootState>;
|
|
35
|
+
/** Replace the default `<div>` (element form) or take over rendering (function form). */
|
|
20
36
|
render?: RenderProp<ComponentPropsWithRef<"div">, ToastRootState>;
|
|
21
37
|
/**
|
|
22
38
|
* Rendered by the Root's own Suspense guard while `children` suspend, in place of the
|
|
23
39
|
* invisible default. The toast's timer and announcement wait for the reveal either way.
|
|
24
40
|
* Parts inside it (a visually hidden `<Toast.Title>` giving the toast a name) gate nothing.
|
|
41
|
+
*
|
|
42
|
+
* @defaultValue `null`
|
|
25
43
|
*/
|
|
26
44
|
fallback?: ReactNode;
|
|
27
45
|
}
|
|
@@ -34,6 +52,8 @@ export interface ToastRootProps extends Omit<ComponentPropsWithRef<"div">, "role
|
|
|
34
52
|
*
|
|
35
53
|
* Owned keys (conventions 1.2): `role`, `tabIndex`, `aria-labelledby`, `aria-describedby`,
|
|
36
54
|
* `inert`, `data-type`, `data-pending`, `data-ending`, `onKeyDown`.
|
|
55
|
+
*
|
|
56
|
+
* @see https://ui.funstack.work/components/toast
|
|
37
57
|
*/
|
|
38
58
|
export declare function ToastRoot({ toast: item, children, className, style, render, fallback, ...rest }: ToastRootProps): import("react").JSX.Element;
|
|
39
59
|
export declare namespace ToastRoot {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-root.d.mts","names":[],"sources":["../../src/toast/toast-root.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"toast-root.d.mts","names":[],"sources":["../../src/toast/toast-root.tsx"],"mappings":";;;;;;;;iBAkBiB;;WAEN,OAAO;;WAEP;;WAEA;;WAEA;;WAEA,UAAU;;;;;;;iBAQJ,uBAAuB,KACtC;;EAIA,OAAO;;EAEP,WAAW,WAAW,WAAW;;EAEjC,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,8BAA8B;;;;;;;;EAQlD,WAAW;;;;;;;;;;;;;;wBA6BG,YACd,OAAO,MACP,UACA,WACA,OACA,QACA,aACG,QACF,iCAAc,IAAA;yBARD"}
|
|
@@ -31,6 +31,8 @@ function SuspenseGuard({ children }) {
|
|
|
31
31
|
*
|
|
32
32
|
* Owned keys (conventions 1.2): `role`, `tabIndex`, `aria-labelledby`, `aria-describedby`,
|
|
33
33
|
* `inert`, `data-type`, `data-pending`, `data-ending`, `onKeyDown`.
|
|
34
|
+
*
|
|
35
|
+
* @see https://ui.funstack.work/components/toast
|
|
34
36
|
*/
|
|
35
37
|
function ToastRoot({ toast: item, children, className, style, render, fallback = null, ...rest }) {
|
|
36
38
|
const viewport = useToastViewportContext("Toast.Root");
|