@funstack/ui 0.1.0-alpha.2 → 0.1.0-alpha.20
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-context.mjs.map +1 -1
- package/dist/accordion/accordion-item.d.mts +22 -4
- package/dist/accordion/accordion-item.d.mts.map +1 -1
- package/dist/accordion/accordion-item.mjs +32 -10
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.d.mts +19 -4
- package/dist/accordion/accordion-panel.d.mts.map +1 -1
- package/dist/accordion/accordion-panel.mjs +8 -6
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts +39 -5
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +75 -67
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts +12 -4
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +14 -28
- 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/alert-dialog/alert-dialog-action.d.mts +73 -0
- package/dist/alert-dialog/alert-dialog-action.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-action.mjs +23 -0
- package/dist/alert-dialog/alert-dialog-action.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-cancel.d.mts +31 -0
- package/dist/alert-dialog/alert-dialog-cancel.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-cancel.mjs +50 -0
- package/dist/alert-dialog/alert-dialog-cancel.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-context.mjs +24 -0
- package/dist/alert-dialog/alert-dialog-context.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-description.d.mts +25 -0
- package/dist/alert-dialog/alert-dialog-description.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-description.mjs +20 -0
- package/dist/alert-dialog/alert-dialog-description.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-form.d.mts +27 -0
- package/dist/alert-dialog/alert-dialog-form.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-form.mjs +22 -0
- package/dist/alert-dialog/alert-dialog-form.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-popup.d.mts +42 -0
- package/dist/alert-dialog/alert-dialog-popup.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-popup.mjs +53 -0
- package/dist/alert-dialog/alert-dialog-popup.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-root.d.mts +31 -0
- package/dist/alert-dialog/alert-dialog-root.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-root.mjs +22 -0
- package/dist/alert-dialog/alert-dialog-root.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-title.d.mts +23 -0
- package/dist/alert-dialog/alert-dialog-title.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-title.mjs +18 -0
- package/dist/alert-dialog/alert-dialog-title.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-trigger.d.mts +23 -0
- package/dist/alert-dialog/alert-dialog-trigger.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-trigger.mjs +18 -0
- package/dist/alert-dialog/alert-dialog-trigger.mjs.map +1 -0
- package/dist/alert-dialog/index.d.mts +33 -0
- package/dist/alert-dialog/index.d.mts.map +1 -0
- package/dist/alert-dialog/index.mjs +33 -0
- package/dist/alert-dialog/index.mjs.map +1 -0
- 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 +118 -0
- package/dist/button/button.d.mts.map +1 -0
- package/dist/button/button.mjs +98 -0
- package/dist/button/button.mjs.map +1 -0
- package/dist/button/index.d.mts +3 -0
- package/dist/button/index.mjs +1 -0
- package/dist/checkbox/checkbox.d.mts +32 -9
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +25 -50
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +20 -5
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +25 -27
- 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 +3 -6
- package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts +22 -5
- package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +17 -13
- package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +37 -7
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +102 -102
- 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/collapsible/collapsible-context.mjs +8 -0
- package/dist/collapsible/collapsible-context.mjs.map +1 -0
- package/dist/collapsible/collapsible-panel.d.mts +53 -0
- package/dist/collapsible/collapsible-panel.d.mts.map +1 -0
- package/dist/collapsible/collapsible-panel.mjs +41 -0
- package/dist/collapsible/collapsible-panel.mjs.map +1 -0
- package/dist/collapsible/collapsible-root.d.mts +108 -0
- package/dist/collapsible/collapsible-root.d.mts.map +1 -0
- package/dist/collapsible/collapsible-root.mjs +147 -0
- package/dist/collapsible/collapsible-root.mjs.map +1 -0
- package/dist/collapsible/collapsible-trigger.d.mts +45 -0
- package/dist/collapsible/collapsible-trigger.d.mts.map +1 -0
- package/dist/collapsible/collapsible-trigger.mjs +62 -0
- package/dist/collapsible/collapsible-trigger.mjs.map +1 -0
- package/dist/collapsible/index.d.mts +21 -0
- package/dist/collapsible/index.d.mts.map +1 -0
- package/dist/collapsible/index.mjs +21 -0
- package/dist/collapsible/index.mjs.map +1 -0
- package/dist/combobox/chip-text.mjs +24 -0
- package/dist/combobox/chip-text.mjs.map +1 -0
- package/dist/combobox/combobox-chips.d.mts +159 -0
- package/dist/combobox/combobox-chips.d.mts.map +1 -0
- package/dist/combobox/combobox-chips.mjs +198 -0
- package/dist/combobox/combobox-chips.mjs.map +1 -0
- package/dist/combobox/combobox-clear.d.mts +29 -5
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +17 -8
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-context.mjs +4 -5
- package/dist/combobox/combobox-context.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 +14 -3
- package/dist/combobox/combobox-group.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts +27 -5
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +53 -13
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-keyboard.mjs +127 -0
- package/dist/combobox/combobox-keyboard.mjs.map +1 -0
- package/dist/combobox/combobox-label.d.mts +18 -1
- package/dist/combobox/combobox-label.d.mts.map +1 -1
- package/dist/combobox/combobox-label.mjs +4 -1
- package/dist/combobox/combobox-label.mjs.map +1 -1
- package/dist/combobox/combobox-list.d.mts +15 -1
- package/dist/combobox/combobox-list.d.mts.map +1 -1
- package/dist/combobox/combobox-list.mjs +13 -13
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts +30 -5
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +9 -5
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts +24 -3
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +24 -29
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts +183 -43
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +476 -270
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts +36 -8
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +50 -41
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.d.mts +13 -5
- package/dist/combobox/index.d.mts.map +1 -1
- package/dist/combobox/index.mjs +13 -5
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/combobox/use-combobox-form.mjs +53 -0
- package/dist/combobox/use-combobox-form.mjs.map +1 -0
- package/dist/combobox/use-combobox-text.mjs +43 -0
- package/dist/combobox/use-combobox-text.mjs.map +1 -0
- package/dist/csp/csp-provider.d.mts +33 -0
- package/dist/csp/csp-provider.d.mts.map +1 -0
- package/dist/csp/csp-provider.mjs +26 -0
- package/dist/csp/csp-provider.mjs.map +1 -0
- package/dist/csp/index.d.mts +3 -0
- package/dist/csp/index.mjs +3 -0
- package/dist/csp/style-hashes.d.mts +21 -0
- package/dist/csp/style-hashes.d.mts.map +1 -0
- package/dist/csp/style-hashes.mjs +23 -0
- package/dist/csp/style-hashes.mjs.map +1 -0
- package/dist/dialog/dialog-close.d.mts +56 -12
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +52 -55
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.d.mts +2 -0
- package/dist/dialog/dialog-context.mjs +14 -2
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-description.d.mts +14 -1
- package/dist/dialog/dialog-description.d.mts.map +1 -1
- package/dist/dialog/dialog-description.mjs +10 -4
- package/dist/dialog/dialog-description.mjs.map +1 -1
- package/dist/dialog/dialog-dismiss.mjs +108 -0
- package/dist/dialog/dialog-dismiss.mjs.map +1 -0
- package/dist/dialog/dialog-form.d.mts +43 -11
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +64 -37
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +47 -14
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +167 -242
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +54 -19
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +74 -92
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-title.d.mts +13 -1
- package/dist/dialog/dialog-title.d.mts.map +1 -1
- package/dist/dialog/dialog-title.mjs +10 -4
- package/dist/dialog/dialog-title.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +30 -6
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +50 -28
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +7 -3
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +7 -3
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/docs/components/accordion.md +428 -0
- package/dist/docs/components/alert-dialog.md +546 -0
- package/dist/docs/components/button.md +511 -0
- package/dist/docs/components/checkbox-group.md +483 -0
- package/dist/docs/components/checkbox.md +373 -0
- package/dist/docs/components/collapsible.md +408 -0
- package/dist/docs/components/combobox.md +960 -0
- package/dist/docs/components/context-menu.md +524 -0
- package/dist/docs/components/dialog.md +694 -0
- package/dist/docs/components/field.md +765 -0
- package/dist/docs/components/hover-card.md +494 -0
- package/dist/docs/components/menu.md +670 -0
- package/dist/docs/components/meter.md +313 -0
- package/dist/docs/components/multi-select.md +622 -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 +670 -0
- package/dist/docs/components/separator.md +182 -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 +602 -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 +187 -0
- package/dist/docs/roadmap.md +144 -0
- package/dist/docs/why.md +104 -0
- package/dist/field/field-control.d.mts +65 -0
- package/dist/field/field-control.d.mts.map +1 -0
- package/dist/field/field-control.mjs +92 -0
- package/dist/field/field-control.mjs.map +1 -0
- package/dist/field/field-description.d.mts +35 -0
- package/dist/field/field-description.d.mts.map +1 -0
- package/dist/field/field-description.mjs +35 -0
- package/dist/field/field-description.mjs.map +1 -0
- package/dist/field/field-error.d.mts +42 -0
- package/dist/field/field-error.d.mts.map +1 -0
- package/dist/field/field-error.mjs +43 -0
- package/dist/field/field-error.mjs.map +1 -0
- package/dist/field/field-label.d.mts +39 -0
- package/dist/field/field-label.d.mts.map +1 -0
- package/dist/field/field-label.mjs +50 -0
- package/dist/field/field-label.mjs.map +1 -0
- package/dist/field/field-root.d.mts +72 -0
- package/dist/field/field-root.d.mts.map +1 -0
- package/dist/field/field-root.mjs +309 -0
- package/dist/field/field-root.mjs.map +1 -0
- package/dist/field/index.d.mts +27 -0
- package/dist/field/index.d.mts.map +1 -0
- package/dist/field/index.mjs +26 -0
- package/dist/field/index.mjs.map +1 -0
- package/dist/field/use-server-error-visibility.mjs +44 -0
- package/dist/field/use-server-error-visibility.mjs.map +1 -0
- package/dist/form/form-root.d.mts +74 -0
- package/dist/form/form-root.d.mts.map +1 -0
- package/dist/form/form-root.mjs +158 -0
- package/dist/form/form-root.mjs.map +1 -0
- package/dist/form/form-submit.d.mts +56 -0
- package/dist/form/form-submit.d.mts.map +1 -0
- package/dist/form/form-submit.mjs +53 -0
- package/dist/form/form-submit.mjs.map +1 -0
- package/dist/form/index.d.mts +18 -0
- package/dist/form/index.d.mts.map +1 -0
- package/dist/form/index.mjs +18 -0
- package/dist/form/index.mjs.map +1 -0
- package/dist/hover-card/hover-card-context.mjs +13 -0
- package/dist/hover-card/hover-card-context.mjs.map +1 -0
- package/dist/hover-card/hover-card-popup.d.mts +102 -0
- package/dist/hover-card/hover-card-popup.d.mts.map +1 -0
- package/dist/hover-card/hover-card-popup.mjs +80 -0
- package/dist/hover-card/hover-card-popup.mjs.map +1 -0
- package/dist/hover-card/hover-card-root.d.mts +94 -0
- package/dist/hover-card/hover-card-root.d.mts.map +1 -0
- package/dist/hover-card/hover-card-root.mjs +74 -0
- package/dist/hover-card/hover-card-root.mjs.map +1 -0
- package/dist/hover-card/hover-card-trigger.d.mts +65 -0
- package/dist/hover-card/hover-card-trigger.d.mts.map +1 -0
- package/dist/hover-card/hover-card-trigger.mjs +109 -0
- package/dist/hover-card/hover-card-trigger.mjs.map +1 -0
- package/dist/hover-card/index.d.mts +24 -0
- package/dist/hover-card/index.d.mts.map +1 -0
- package/dist/hover-card/index.mjs +24 -0
- package/dist/hover-card/index.mjs.map +1 -0
- package/dist/hover-card/use-hover-card-interest.mjs +242 -0
- package/dist/hover-card/use-hover-card-interest.mjs.map +1 -0
- package/dist/index.d.mts +100 -13
- package/dist/index.mjs +19 -1
- package/dist/internal/{action-details.mjs → action/action-details.mjs} +1 -1
- package/dist/internal/action/action-details.mjs.map +1 -0
- package/dist/internal/action/call-urgent-handler.mjs +32 -0
- package/dist/internal/action/call-urgent-handler.mjs.map +1 -0
- package/dist/internal/action/report-dropped.mjs +27 -0
- package/dist/internal/action/report-dropped.mjs.map +1 -0
- package/dist/internal/action/use-action-trigger.mjs +67 -0
- package/dist/internal/action/use-action-trigger.mjs.map +1 -0
- package/dist/internal/action/use-connected.mjs +24 -0
- package/dist/internal/action/use-connected.mjs.map +1 -0
- package/dist/internal/action/use-controllable-action.mjs +153 -0
- package/dist/internal/action/use-controllable-action.mjs.map +1 -0
- package/dist/internal/action/use-multiple-selection.mjs +83 -0
- package/dist/internal/action/use-multiple-selection.mjs.map +1 -0
- package/dist/internal/action/use-pure-trigger.mjs +34 -0
- package/dist/internal/action/use-pure-trigger.mjs.map +1 -0
- package/dist/internal/action/use-step-commit.mjs +147 -0
- package/dist/internal/action/use-step-commit.mjs.map +1 -0
- package/dist/internal/announce.mjs +20 -0
- package/dist/internal/announce.mjs.map +1 -0
- package/dist/internal/arrow-keys.mjs +21 -0
- package/dist/internal/arrow-keys.mjs.map +1 -0
- package/dist/internal/csp-context.mjs +8 -0
- package/dist/internal/csp-context.mjs.map +1 -0
- package/dist/internal/decimal.mjs +33 -0
- package/dist/internal/decimal.mjs.map +1 -0
- package/dist/internal/details-summary.mjs +56 -0
- package/dist/internal/details-summary.mjs.map +1 -0
- package/dist/internal/dev-warn.mjs +17 -0
- package/dist/internal/dev-warn.mjs.map +1 -0
- package/dist/internal/dom-order.mjs +17 -0
- package/dist/internal/dom-order.mjs.map +1 -0
- package/dist/internal/form/field-context.d.mts +19 -0
- package/dist/internal/form/field-context.d.mts.map +1 -0
- package/dist/internal/form/field-context.mjs +24 -0
- package/dist/internal/form/field-context.mjs.map +1 -0
- package/dist/internal/form/focus-first-invalid.mjs +67 -0
- package/dist/internal/form/focus-first-invalid.mjs.map +1 -0
- package/dist/internal/form/form-status-watcher.mjs +31 -0
- package/dist/internal/form/form-status-watcher.mjs.map +1 -0
- package/dist/internal/form/group-member.mjs +37 -0
- package/dist/internal/form/group-member.mjs.map +1 -0
- package/dist/internal/form/hidden-values.mjs +29 -0
- package/dist/internal/form/hidden-values.mjs.map +1 -0
- package/dist/internal/{sync-presence.mjs → form/sync-presence.mjs} +6 -2
- package/dist/internal/form/sync-presence.mjs.map +1 -0
- package/dist/internal/form/use-checkable-input.mjs +79 -0
- package/dist/internal/form/use-checkable-input.mjs.map +1 -0
- package/dist/internal/form/use-field-control.mjs +125 -0
- package/dist/internal/form/use-field-control.mjs.map +1 -0
- package/dist/internal/form/use-fieldset-group.mjs +46 -0
- package/dist/internal/form/use-fieldset-group.mjs.map +1 -0
- package/dist/internal/form/use-form-owner-event.mjs +44 -0
- package/dist/internal/form/use-form-owner-event.mjs.map +1 -0
- package/dist/internal/form/use-form-reset.mjs +39 -0
- package/dist/internal/form/use-form-reset.mjs.map +1 -0
- package/dist/internal/{use-native-checked.mjs → form/use-native-checked.mjs} +8 -9
- package/dist/internal/form/use-native-checked.mjs.map +1 -0
- package/dist/internal/{use-native-group-reconciliation.mjs → form/use-native-group-reconciliation.mjs} +15 -12
- package/dist/internal/form/use-native-group-reconciliation.mjs.map +1 -0
- package/dist/internal/{use-native-select-value.mjs → form/use-native-select-value.mjs} +8 -6
- package/dist/internal/form/use-native-select-value.mjs.map +1 -0
- package/dist/internal/form/validity.d.mts +35 -0
- package/dist/internal/form/validity.d.mts.map +1 -0
- package/dist/internal/form/validity.mjs +98 -0
- package/dist/internal/form/validity.mjs.map +1 -0
- package/dist/internal/overlay/anchor-position.d.mts +15 -0
- package/dist/internal/overlay/anchor-position.d.mts.map +1 -0
- package/dist/internal/overlay/anchor-position.mjs +132 -0
- package/dist/internal/overlay/anchor-position.mjs.map +1 -0
- package/dist/internal/overlay/content-focus-probe.mjs +42 -0
- package/dist/internal/overlay/content-focus-probe.mjs.map +1 -0
- package/dist/internal/overlay/css-transition-cut.mjs +66 -0
- package/dist/internal/overlay/css-transition-cut.mjs.map +1 -0
- package/dist/internal/overlay/focus-visible.mjs +26 -0
- package/dist/internal/overlay/focus-visible.mjs.map +1 -0
- package/dist/internal/overlay/invokers.mjs +63 -0
- package/dist/internal/overlay/invokers.mjs.map +1 -0
- package/dist/internal/overlay/modal-registry.mjs +39 -0
- package/dist/internal/overlay/modal-registry.mjs.map +1 -0
- package/dist/internal/overlay/overlay-popup.mjs +103 -0
- package/dist/internal/overlay/overlay-popup.mjs.map +1 -0
- package/dist/internal/overlay/overlay-show.mjs +73 -0
- package/dist/internal/overlay/overlay-show.mjs.map +1 -0
- package/dist/internal/overlay/popover-open.mjs +18 -0
- package/dist/internal/overlay/popover-open.mjs.map +1 -0
- package/dist/internal/overlay/trigger-ref.mjs +26 -0
- package/dist/internal/overlay/trigger-ref.mjs.map +1 -0
- package/dist/internal/overlay/use-apply-open-state.mjs +44 -0
- package/dist/internal/overlay/use-apply-open-state.mjs.map +1 -0
- package/dist/internal/{use-exit-animation.mjs → overlay/use-exit-animation.mjs} +28 -8
- package/dist/internal/overlay/use-exit-animation.mjs.map +1 -0
- package/dist/internal/overlay/use-interest-dismiss.mjs +85 -0
- package/dist/internal/overlay/use-interest-dismiss.mjs.map +1 -0
- package/dist/internal/overlay/use-modal-registration.mjs +47 -0
- package/dist/internal/overlay/use-modal-registration.mjs.map +1 -0
- package/dist/internal/overlay/use-overlay-close.mjs +72 -0
- package/dist/internal/overlay/use-overlay-close.mjs.map +1 -0
- package/dist/internal/overlay/use-overlay-root.d.mts +2 -0
- package/dist/internal/overlay/use-overlay-root.mjs +193 -0
- package/dist/internal/overlay/use-overlay-root.mjs.map +1 -0
- package/dist/internal/overlay/use-popover-popup.mjs +287 -0
- package/dist/internal/overlay/use-popover-popup.mjs.map +1 -0
- package/dist/internal/overlay/use-popover-trigger.d.mts +16 -0
- package/dist/internal/overlay/use-popover-trigger.d.mts.map +1 -0
- package/dist/internal/overlay/use-popover-trigger.mjs +142 -0
- package/dist/internal/overlay/use-popover-trigger.mjs.map +1 -0
- package/dist/internal/overlay/use-resolved-placement.mjs +162 -0
- package/dist/internal/overlay/use-resolved-placement.mjs.map +1 -0
- package/dist/internal/platform-attributes.d.mts +2 -1
- package/dist/internal/platform-attributes.d.mts.map +1 -1
- package/dist/internal/pointer-capture.mjs +20 -0
- package/dist/internal/pointer-capture.mjs.map +1 -0
- package/dist/internal/range-value.mjs +51 -0
- package/dist/internal/range-value.mjs.map +1 -0
- package/dist/internal/render-element.d.mts +2 -0
- package/dist/internal/render-element.mjs +123 -0
- package/dist/internal/render-element.mjs.map +1 -0
- package/dist/internal/shipped-styles.mjs +14 -0
- package/dist/internal/shipped-styles.mjs.map +1 -0
- package/dist/internal/toolbar-context.mjs +17 -0
- package/dist/internal/toolbar-context.mjs.map +1 -0
- package/dist/internal/transition-boundary.mjs +5 -9
- package/dist/internal/transition-boundary.mjs.map +1 -1
- package/dist/internal/typeahead.mjs +52 -0
- package/dist/internal/typeahead.mjs.map +1 -0
- package/dist/internal/types.d.mts +42 -9
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-active-option.mjs +51 -0
- package/dist/internal/use-active-option.mjs.map +1 -0
- package/dist/internal/use-deferred-leave.mjs +113 -0
- package/dist/internal/use-deferred-leave.mjs.map +1 -0
- package/dist/internal/use-dev-warning.mjs +8 -4
- package/dist/internal/use-dev-warning.mjs.map +1 -1
- package/dist/internal/use-element-check.mjs +39 -0
- package/dist/internal/use-element-check.mjs.map +1 -0
- package/dist/internal/use-item-order.mjs +42 -0
- package/dist/internal/use-item-order.mjs.map +1 -0
- package/dist/internal/use-latest.mjs +28 -0
- package/dist/internal/use-latest.mjs.map +1 -0
- package/dist/internal/use-merged-refs.mjs +19 -0
- package/dist/internal/use-merged-refs.mjs.map +1 -0
- package/dist/internal/use-mount-fixed.mjs +22 -0
- package/dist/internal/use-mount-fixed.mjs.map +1 -0
- package/dist/internal/use-name-warning.mjs +140 -0
- package/dist/internal/use-name-warning.mjs.map +1 -0
- package/dist/internal/use-native-focusgroup.mjs +19 -0
- package/dist/internal/use-native-focusgroup.mjs.map +1 -0
- package/dist/internal/use-option-registry.mjs +70 -0
- package/dist/internal/use-option-registry.mjs.map +1 -0
- package/dist/internal/use-register-count.mjs +27 -0
- package/dist/internal/use-register-count.mjs.map +1 -0
- package/dist/internal/use-render.d.mts +2 -0
- package/dist/internal/use-render.mjs +12 -35
- package/dist/internal/use-render.mjs.map +1 -1
- package/dist/internal/use-roving-focus.mjs +288 -0
- package/dist/internal/use-roving-focus.mjs.map +1 -0
- package/dist/internal/use-value-set.mjs +20 -0
- package/dist/internal/use-value-set.mjs.map +1 -0
- package/dist/internal/value-set.mjs +41 -0
- package/dist/internal/value-set.mjs.map +1 -0
- package/dist/menu/index.d.mts +8 -2
- package/dist/menu/index.d.mts.map +1 -1
- package/dist/menu/index.mjs +7 -1
- 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 +6 -3
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +63 -0
- package/dist/menu/menu-context-trigger.d.mts.map +1 -0
- package/dist/menu/menu-context-trigger.mjs +231 -0
- package/dist/menu/menu-context-trigger.mjs.map +1 -0
- package/dist/menu/menu-context.d.mts +1 -1
- package/dist/menu/menu-context.mjs +44 -1
- package/dist/menu/menu-context.mjs.map +1 -1
- package/dist/menu/menu-dom.mjs +35 -4
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-gestures.mjs +166 -0
- package/dist/menu/menu-gestures.mjs.map +1 -0
- 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 +15 -5
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-hover.mjs +0 -1
- package/dist/menu/menu-hover.mjs.map +1 -1
- package/dist/menu/menu-item.d.mts +42 -5
- package/dist/menu/menu-item.d.mts.map +1 -1
- package/dist/menu/menu-item.mjs +18 -9
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-outside.mjs +101 -0
- package/dist/menu/menu-outside.mjs.map +1 -0
- package/dist/menu/menu-point.mjs +85 -0
- package/dist/menu/menu-point.mjs.map +1 -0
- package/dist/menu/menu-popup.d.mts +68 -11
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +106 -116
- 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 +14 -7
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.d.mts +18 -0
- package/dist/menu/menu-radio-item.d.mts.map +1 -1
- package/dist/menu/menu-radio-item.mjs +5 -1
- package/dist/menu/menu-radio-item.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +61 -12
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +72 -17
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts +24 -9
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +48 -26
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +37 -16
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +39 -23
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/menu/use-menu-item.mjs +14 -16
- package/dist/menu/use-menu-item.mjs.map +1 -1
- package/dist/menu/use-menu-keyboard.mjs +68 -0
- package/dist/menu/use-menu-keyboard.mjs.map +1 -0
- package/dist/meter/index.d.mts +26 -0
- package/dist/meter/index.d.mts.map +1 -0
- package/dist/meter/index.mjs +25 -0
- package/dist/meter/index.mjs.map +1 -0
- package/dist/meter/meter-context.mjs +13 -0
- package/dist/meter/meter-context.mjs.map +1 -0
- package/dist/meter/meter-indicator.d.mts +30 -0
- package/dist/meter/meter-indicator.d.mts.map +1 -0
- package/dist/meter/meter-indicator.mjs +27 -0
- package/dist/meter/meter-indicator.mjs.map +1 -0
- package/dist/meter/meter-label.d.mts +30 -0
- package/dist/meter/meter-label.d.mts.map +1 -0
- package/dist/meter/meter-label.mjs +30 -0
- package/dist/meter/meter-label.mjs.map +1 -0
- package/dist/meter/meter-region.d.mts +9 -0
- package/dist/meter/meter-region.d.mts.map +1 -0
- package/dist/meter/meter-region.mjs +39 -0
- package/dist/meter/meter-region.mjs.map +1 -0
- package/dist/meter/meter-root.d.mts +113 -0
- package/dist/meter/meter-root.d.mts.map +1 -0
- package/dist/meter/meter-root.mjs +85 -0
- package/dist/meter/meter-root.mjs.map +1 -0
- package/dist/meter/meter-track.d.mts +30 -0
- package/dist/meter/meter-track.d.mts.map +1 -0
- package/dist/meter/meter-track.mjs +27 -0
- package/dist/meter/meter-track.mjs.map +1 -0
- package/dist/meter/meter-value.d.mts +34 -0
- package/dist/meter/meter-value.d.mts.map +1 -0
- package/dist/meter/meter-value.mjs +31 -0
- package/dist/meter/meter-value.mjs.map +1 -0
- package/dist/multi-select/index.d.mts +37 -0
- package/dist/multi-select/index.d.mts.map +1 -0
- package/dist/multi-select/index.mjs +37 -0
- package/dist/multi-select/index.mjs.map +1 -0
- package/dist/multi-select/multi-select-context.mjs +19 -0
- package/dist/multi-select/multi-select-context.mjs.map +1 -0
- package/dist/multi-select/multi-select-group.d.mts +120 -0
- package/dist/multi-select/multi-select-group.d.mts.map +1 -0
- package/dist/multi-select/multi-select-group.mjs +111 -0
- package/dist/multi-select/multi-select-group.mjs.map +1 -0
- package/dist/multi-select/multi-select-keyboard.mjs +145 -0
- package/dist/multi-select/multi-select-keyboard.mjs.map +1 -0
- package/dist/multi-select/multi-select-label.d.mts +42 -0
- package/dist/multi-select/multi-select-label.d.mts.map +1 -0
- package/dist/multi-select/multi-select-label.mjs +41 -0
- package/dist/multi-select/multi-select-label.mjs.map +1 -0
- package/dist/multi-select/multi-select-list.d.mts +47 -0
- package/dist/multi-select/multi-select-list.d.mts.map +1 -0
- package/dist/multi-select/multi-select-list.mjs +65 -0
- package/dist/multi-select/multi-select-list.mjs.map +1 -0
- package/dist/multi-select/multi-select-option.d.mts +68 -0
- package/dist/multi-select/multi-select-option.d.mts.map +1 -0
- package/dist/multi-select/multi-select-option.mjs +93 -0
- package/dist/multi-select/multi-select-option.mjs.map +1 -0
- package/dist/multi-select/multi-select-popup.d.mts +58 -0
- package/dist/multi-select/multi-select-popup.d.mts.map +1 -0
- package/dist/multi-select/multi-select-popup.mjs +71 -0
- package/dist/multi-select/multi-select-popup.mjs.map +1 -0
- package/dist/multi-select/multi-select-root.d.mts +125 -0
- package/dist/multi-select/multi-select-root.d.mts.map +1 -0
- package/dist/multi-select/multi-select-root.mjs +257 -0
- package/dist/multi-select/multi-select-root.mjs.map +1 -0
- package/dist/multi-select/multi-select-trigger.d.mts +66 -0
- package/dist/multi-select/multi-select-trigger.d.mts.map +1 -0
- package/dist/multi-select/multi-select-trigger.mjs +169 -0
- package/dist/multi-select/multi-select-trigger.mjs.map +1 -0
- package/dist/multi-select/multi-select-value.d.mts +57 -0
- package/dist/multi-select/multi-select-value.d.mts.map +1 -0
- package/dist/multi-select/multi-select-value.mjs +41 -0
- package/dist/multi-select/multi-select-value.mjs.map +1 -0
- package/dist/number-field/index.d.mts +29 -0
- package/dist/number-field/index.d.mts.map +1 -0
- package/dist/number-field/index.mjs +28 -0
- package/dist/number-field/index.mjs.map +1 -0
- package/dist/number-field/number-field-arithmetic.mjs +97 -0
- package/dist/number-field/number-field-arithmetic.mjs.map +1 -0
- package/dist/number-field/number-field-context.d.mts +7 -0
- package/dist/number-field/number-field-context.d.mts.map +1 -0
- package/dist/number-field/number-field-context.mjs +13 -0
- package/dist/number-field/number-field-context.mjs.map +1 -0
- package/dist/number-field/number-field-decrement.d.mts +19 -0
- package/dist/number-field/number-field-decrement.d.mts.map +1 -0
- package/dist/number-field/number-field-decrement.mjs +22 -0
- package/dist/number-field/number-field-decrement.mjs.map +1 -0
- package/dist/number-field/number-field-format.mjs +279 -0
- package/dist/number-field/number-field-format.mjs.map +1 -0
- package/dist/number-field/number-field-increment.d.mts +19 -0
- package/dist/number-field/number-field-increment.d.mts.map +1 -0
- package/dist/number-field/number-field-increment.mjs +22 -0
- package/dist/number-field/number-field-increment.mjs.map +1 -0
- package/dist/number-field/number-field-input.d.mts +38 -0
- package/dist/number-field/number-field-input.d.mts.map +1 -0
- package/dist/number-field/number-field-input.mjs +161 -0
- package/dist/number-field/number-field-input.mjs.map +1 -0
- package/dist/number-field/number-field-label.d.mts +33 -0
- package/dist/number-field/number-field-label.d.mts.map +1 -0
- package/dist/number-field/number-field-label.mjs +43 -0
- package/dist/number-field/number-field-label.mjs.map +1 -0
- package/dist/number-field/number-field-root.d.mts +157 -0
- package/dist/number-field/number-field-root.d.mts.map +1 -0
- package/dist/number-field/number-field-root.mjs +445 -0
- package/dist/number-field/number-field-root.mjs.map +1 -0
- package/dist/number-field/use-number-field-dev-warnings.mjs +28 -0
- package/dist/number-field/use-number-field-dev-warnings.mjs.map +1 -0
- package/dist/number-field/use-step-button.d.mts +44 -0
- package/dist/number-field/use-step-button.d.mts.map +1 -0
- package/dist/number-field/use-step-button.mjs +175 -0
- package/dist/number-field/use-step-button.mjs.map +1 -0
- package/dist/popover/index.d.mts +6 -4
- package/dist/popover/index.d.mts.map +1 -1
- package/dist/popover/index.mjs +6 -4
- package/dist/popover/index.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts +48 -8
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +41 -67
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-context.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 +64 -18
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +31 -36
- 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 +15 -10
- 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 +38 -18
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +14 -9
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/index.d.mts +26 -0
- package/dist/progress/index.d.mts.map +1 -0
- package/dist/progress/index.mjs +26 -0
- package/dist/progress/index.mjs.map +1 -0
- package/dist/progress/progress-context.mjs +13 -0
- package/dist/progress/progress-context.mjs.map +1 -0
- package/dist/progress/progress-indicator.d.mts +30 -0
- package/dist/progress/progress-indicator.d.mts.map +1 -0
- package/dist/progress/progress-indicator.mjs +31 -0
- package/dist/progress/progress-indicator.mjs.map +1 -0
- package/dist/progress/progress-label.d.mts +30 -0
- package/dist/progress/progress-label.d.mts.map +1 -0
- package/dist/progress/progress-label.mjs +32 -0
- package/dist/progress/progress-label.mjs.map +1 -0
- package/dist/progress/progress-root.d.mts +96 -0
- package/dist/progress/progress-root.d.mts.map +1 -0
- package/dist/progress/progress-root.mjs +82 -0
- package/dist/progress/progress-root.mjs.map +1 -0
- package/dist/progress/progress-track.d.mts +30 -0
- package/dist/progress/progress-track.d.mts.map +1 -0
- package/dist/progress/progress-track.mjs +31 -0
- package/dist/progress/progress-track.mjs.map +1 -0
- package/dist/progress/progress-value.d.mts +34 -0
- package/dist/progress/progress-value.d.mts.map +1 -0
- package/dist/progress/progress-value.mjs +35 -0
- package/dist/progress/progress-value.mjs.map +1 -0
- 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-context.mjs.map +1 -1
- package/dist/radio-group/radio-group-item.d.mts +21 -5
- package/dist/radio-group/radio-group-item.d.mts.map +1 -1
- package/dist/radio-group/radio-group-item.mjs +22 -25
- 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 +3 -6
- package/dist/radio-group/radio-group-label.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +34 -8
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +48 -39
- 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-dom.mjs +9 -18
- package/dist/select/select-dom.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 +5 -1
- 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 +8 -4
- 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 +4 -2
- package/dist/select/select-option.mjs.map +1 -1
- package/dist/select/select-root.d.mts +28 -3
- package/dist/select/select-root.d.mts.map +1 -1
- package/dist/select/select-root.mjs +39 -12
- 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 +5 -1
- 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 +5 -6
- package/dist/select/select-value.mjs.map +1 -1
- package/dist/separator/index.d.mts +3 -0
- package/dist/separator/index.mjs +1 -0
- package/dist/separator/separator.d.mts +58 -0
- package/dist/separator/separator.d.mts.map +1 -0
- package/dist/separator/separator.mjs +41 -0
- package/dist/separator/separator.mjs.map +1 -0
- package/dist/slider/index.d.mts +34 -0
- package/dist/slider/index.d.mts.map +1 -0
- package/dist/slider/index.mjs +29 -0
- package/dist/slider/index.mjs.map +1 -0
- package/dist/slider/slider-arithmetic.mjs +165 -0
- package/dist/slider/slider-arithmetic.mjs.map +1 -0
- package/dist/slider/slider-context.mjs +13 -0
- package/dist/slider/slider-context.mjs.map +1 -0
- package/dist/slider/slider-indicator.d.mts +34 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -0
- package/dist/slider/slider-indicator.mjs +38 -0
- package/dist/slider/slider-indicator.mjs.map +1 -0
- package/dist/slider/slider-label.d.mts +33 -0
- package/dist/slider/slider-label.d.mts.map +1 -0
- package/dist/slider/slider-label.mjs +40 -0
- package/dist/slider/slider-label.mjs.map +1 -0
- package/dist/slider/slider-root.d.mts +155 -0
- package/dist/slider/slider-root.d.mts.map +1 -0
- package/dist/slider/slider-root.mjs +434 -0
- package/dist/slider/slider-root.mjs.map +1 -0
- package/dist/slider/slider-thumb.d.mts +87 -0
- package/dist/slider/slider-thumb.d.mts.map +1 -0
- package/dist/slider/slider-thumb.mjs +150 -0
- package/dist/slider/slider-thumb.mjs.map +1 -0
- package/dist/slider/slider-track.d.mts +46 -0
- package/dist/slider/slider-track.d.mts.map +1 -0
- package/dist/slider/slider-track.mjs +57 -0
- package/dist/slider/slider-track.mjs.map +1 -0
- package/dist/slider/slider-value.d.mts +45 -0
- package/dist/slider/slider-value.d.mts.map +1 -0
- package/dist/slider/slider-value.mjs +41 -0
- package/dist/slider/slider-value.mjs.map +1 -0
- package/dist/slider/use-slider-dev-warnings.mjs +29 -0
- package/dist/slider/use-slider-dev-warnings.mjs.map +1 -0
- package/dist/slider/use-thumb-registry.mjs +51 -0
- package/dist/slider/use-thumb-registry.mjs.map +1 -0
- package/dist/switch/switch.d.mts +30 -9
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +24 -46
- 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 +7 -3
- 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 +4 -1
- 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 +12 -23
- package/dist/tabs/tabs-list.mjs.map +1 -1
- package/dist/tabs/tabs-panel.d.mts +22 -4
- package/dist/tabs/tabs-panel.d.mts.map +1 -1
- package/dist/tabs/tabs-panel.mjs +4 -2
- package/dist/tabs/tabs-panel.mjs.map +1 -1
- package/dist/tabs/tabs-root.d.mts +43 -8
- package/dist/tabs/tabs-root.d.mts.map +1 -1
- package/dist/tabs/tabs-root.mjs +23 -10
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.d.mts +25 -5
- package/dist/tabs/tabs-tab.d.mts.map +1 -1
- package/dist/tabs/tabs-tab.mjs +5 -2
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/{internal → tabs}/use-until-found.mjs +1 -1
- package/dist/tabs/use-until-found.mjs.map +1 -0
- package/dist/toast/index.d.mts +27 -0
- package/dist/toast/index.d.mts.map +1 -0
- package/dist/toast/index.mjs +28 -0
- package/dist/toast/index.mjs.map +1 -0
- package/dist/toast/toast-action.d.mts +86 -0
- package/dist/toast/toast-action.d.mts.map +1 -0
- package/dist/toast/toast-action.mjs +81 -0
- package/dist/toast/toast-action.mjs.map +1 -0
- package/dist/toast/toast-close.d.mts +52 -0
- package/dist/toast/toast-close.d.mts.map +1 -0
- package/dist/toast/toast-close.mjs +53 -0
- package/dist/toast/toast-close.mjs.map +1 -0
- package/dist/toast/toast-context.mjs +19 -0
- package/dist/toast/toast-context.mjs.map +1 -0
- package/dist/toast/toast-description.d.mts +39 -0
- package/dist/toast/toast-description.d.mts.map +1 -0
- package/dist/toast/toast-description.mjs +37 -0
- package/dist/toast/toast-description.mjs.map +1 -0
- package/dist/toast/toast-hotkey.mjs +27 -0
- package/dist/toast/toast-hotkey.mjs.map +1 -0
- package/dist/toast/toast-queue.mjs +137 -0
- package/dist/toast/toast-queue.mjs.map +1 -0
- package/dist/toast/toast-root.d.mts +63 -0
- package/dist/toast/toast-root.d.mts.map +1 -0
- package/dist/toast/toast-root.mjs +209 -0
- package/dist/toast/toast-root.mjs.map +1 -0
- package/dist/toast/toast-timers.mjs +65 -0
- package/dist/toast/toast-timers.mjs.map +1 -0
- package/dist/toast/toast-title.d.mts +38 -0
- package/dist/toast/toast-title.d.mts.map +1 -0
- package/dist/toast/toast-title.mjs +35 -0
- package/dist/toast/toast-title.mjs.map +1 -0
- package/dist/toast/toast-viewport.d.mts +81 -0
- package/dist/toast/toast-viewport.d.mts.map +1 -0
- package/dist/toast/toast-viewport.mjs +345 -0
- package/dist/toast/toast-viewport.mjs.map +1 -0
- package/dist/toast/toast.d.mts +162 -0
- package/dist/toast/toast.d.mts.map +1 -0
- package/dist/toast/toast.mjs +161 -0
- package/dist/toast/toast.mjs.map +1 -0
- package/dist/toast/use-modal-portal-host.mjs +52 -0
- package/dist/toast/use-modal-portal-host.mjs.map +1 -0
- package/dist/toast/use-toast-announcements.mjs +46 -0
- package/dist/toast/use-toast-announcements.mjs.map +1 -0
- package/dist/toast/use-toast-focus.mjs +75 -0
- package/dist/toast/use-toast-focus.mjs.map +1 -0
- package/dist/toast/use-toast-pauses.mjs +58 -0
- package/dist/toast/use-toast-pauses.mjs.map +1 -0
- package/dist/toggle/toggle.d.mts +26 -6
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +12 -6
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/index.d.mts +18 -0
- package/dist/toggle-group/index.d.mts.map +1 -0
- package/dist/toggle-group/index.mjs +17 -0
- package/dist/toggle-group/index.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-context.d.mts +6 -0
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-context.mjs +13 -0
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-item.d.mts +71 -0
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-item.mjs +69 -0
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-root.d.mts +156 -0
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-root.mjs +177 -0
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -0
- package/dist/toolbar/index.d.mts +19 -0
- package/dist/toolbar/index.d.mts.map +1 -0
- package/dist/toolbar/index.mjs +19 -0
- package/dist/toolbar/index.mjs.map +1 -0
- package/dist/toolbar/toolbar-root.d.mts +65 -0
- package/dist/toolbar/toolbar-root.d.mts.map +1 -0
- package/dist/toolbar/toolbar-root.mjs +67 -0
- package/dist/toolbar/toolbar-root.mjs.map +1 -0
- package/dist/toolbar/toolbar-separator.d.mts +38 -0
- package/dist/toolbar/toolbar-separator.d.mts.map +1 -0
- package/dist/toolbar/toolbar-separator.mjs +33 -0
- package/dist/toolbar/toolbar-separator.mjs.map +1 -0
- package/dist/tooltip/index.d.mts +10 -5
- package/dist/tooltip/index.d.mts.map +1 -1
- package/dist/tooltip/index.mjs +8 -3
- package/dist/tooltip/index.mjs.map +1 -1
- package/dist/tooltip/tooltip-arrow.d.mts +46 -0
- package/dist/tooltip/tooltip-arrow.d.mts.map +1 -0
- package/dist/tooltip/tooltip-arrow.mjs +47 -0
- package/dist/tooltip/tooltip-arrow.mjs.map +1 -0
- package/dist/tooltip/tooltip-context.d.mts +11 -0
- package/dist/tooltip/tooltip-context.d.mts.map +1 -1
- package/dist/tooltip/tooltip-context.mjs +2 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts +49 -7
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +37 -15
- 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 +29 -6
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +28 -3
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +26 -6
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/dist/tooltip/tooltip-warm.mjs +29 -0
- package/dist/tooltip/tooltip-warm.mjs.map +1 -0
- package/dist/tooltip/use-tooltip-interaction.mjs +128 -77
- package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
- package/package.json +27 -2
- package/skills/funstack-ui-knowledge/SKILL.md +80 -0
- package/dist/accordion/accordion-context.d.mts +0 -5
- package/dist/accordion/accordion-context.d.mts.map +0 -1
- package/dist/internal/action-details.mjs.map +0 -1
- package/dist/internal/anchor-position.d.mts +0 -7
- package/dist/internal/anchor-position.d.mts.map +0 -1
- package/dist/internal/anchor-position.mjs +0 -16
- package/dist/internal/anchor-position.mjs.map +0 -1
- package/dist/internal/sync-presence.mjs.map +0 -1
- package/dist/internal/use-action-trigger.mjs +0 -58
- package/dist/internal/use-action-trigger.mjs.map +0 -1
- package/dist/internal/use-controllable-action.mjs +0 -119
- package/dist/internal/use-controllable-action.mjs.map +0 -1
- package/dist/internal/use-exit-animation.mjs.map +0 -1
- package/dist/internal/use-form-reset.mjs +0 -54
- package/dist/internal/use-form-reset.mjs.map +0 -1
- package/dist/internal/use-native-checked.mjs.map +0 -1
- package/dist/internal/use-native-group-reconciliation.mjs.map +0 -1
- package/dist/internal/use-native-select-value.mjs.map +0 -1
- package/dist/internal/use-popover-popup.mjs +0 -274
- package/dist/internal/use-popover-popup.mjs.map +0 -1
- package/dist/internal/use-popover-root.d.mts +0 -2
- package/dist/internal/use-popover-root.mjs +0 -112
- package/dist/internal/use-popover-root.mjs.map +0 -1
- package/dist/internal/use-popover-trigger.mjs +0 -86
- package/dist/internal/use-popover-trigger.mjs.map +0 -1
- package/dist/internal/use-until-found.mjs.map +0 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
//#region src/toast/toast.ts
|
|
2
|
+
const internals = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
/** The command channel of `manager` (library-internal). */
|
|
4
|
+
function toastManagerInternals(manager) {
|
|
5
|
+
const value = internals.get(manager);
|
|
6
|
+
if (value === void 0) throw new TypeError("Toast.Viewport: `manager` must come from `createToastManager()`.");
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
10
|
+
let warnedServer = false;
|
|
11
|
+
/**
|
|
12
|
+
* Generated ids are unique across managers, so a Viewport whose `manager` prop changes never
|
|
13
|
+
* mistakes a late close from the old queue (an Undo settling) for one of the new queue's toasts.
|
|
14
|
+
*/
|
|
15
|
+
let nextId = 0;
|
|
16
|
+
/** On the server every method is a no-op, never buffered (design 13). */
|
|
17
|
+
function onServer() {
|
|
18
|
+
if (typeof document !== "undefined") return false;
|
|
19
|
+
if (isDev && !warnedServer) {
|
|
20
|
+
warnedServer = true;
|
|
21
|
+
console.error("toast(): called on the server. Toasts are client-only; the call does nothing. Return data from the Server Function and call `toast()` on the client.");
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
function resolveOptions(options, value) {
|
|
26
|
+
return typeof options === "function" ? options(value) : options;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates an isolated queue: `<Toast.Viewport manager={m}>` renders it. For a second React root,
|
|
30
|
+
* a micro-frontend, or a test that wants a clean queue. `toast` is the default manager.
|
|
31
|
+
*
|
|
32
|
+
* @see https://ui.funstack.work/components/toast
|
|
33
|
+
*/
|
|
34
|
+
function createToastManager() {
|
|
35
|
+
let listener = null;
|
|
36
|
+
let retained = [];
|
|
37
|
+
/** Commands issued before any Viewport subscribed (client only). */
|
|
38
|
+
let buffer = [];
|
|
39
|
+
/** Commands of the current tick, flushed together from one microtask. */
|
|
40
|
+
let batch = [];
|
|
41
|
+
let scheduled = false;
|
|
42
|
+
const flush = () => {
|
|
43
|
+
scheduled = false;
|
|
44
|
+
const commands = batch;
|
|
45
|
+
batch = [];
|
|
46
|
+
if (commands.length === 0) return;
|
|
47
|
+
if (listener !== null) listener.apply(commands);
|
|
48
|
+
else buffer.push(...commands);
|
|
49
|
+
};
|
|
50
|
+
const dispatch = (command) => {
|
|
51
|
+
batch.push(command);
|
|
52
|
+
if (scheduled) return;
|
|
53
|
+
scheduled = true;
|
|
54
|
+
queueMicrotask(flush);
|
|
55
|
+
};
|
|
56
|
+
const generateId = () => `fsui-toast-${++nextId}`;
|
|
57
|
+
const add = (options) => {
|
|
58
|
+
const id = options.id ?? generateId();
|
|
59
|
+
if (onServer()) return id;
|
|
60
|
+
dispatch({
|
|
61
|
+
kind: "add",
|
|
62
|
+
id,
|
|
63
|
+
options,
|
|
64
|
+
pending: false
|
|
65
|
+
});
|
|
66
|
+
return id;
|
|
67
|
+
};
|
|
68
|
+
const update = (id, options) => {
|
|
69
|
+
if (onServer()) return;
|
|
70
|
+
dispatch({
|
|
71
|
+
kind: "update",
|
|
72
|
+
id,
|
|
73
|
+
options,
|
|
74
|
+
settle: false
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
const dismiss = (id) => {
|
|
78
|
+
if (onServer()) return;
|
|
79
|
+
dispatch({
|
|
80
|
+
kind: "dismiss",
|
|
81
|
+
id
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const promise = (input, options) => {
|
|
85
|
+
const { success, error } = options;
|
|
86
|
+
if (onServer()) return Promise.resolve(input).then((value) => value, (reason) => {
|
|
87
|
+
if (error !== void 0) return void 0;
|
|
88
|
+
throw reason;
|
|
89
|
+
});
|
|
90
|
+
const id = options.id ?? options.pending.id ?? generateId();
|
|
91
|
+
dispatch({
|
|
92
|
+
kind: "add",
|
|
93
|
+
id,
|
|
94
|
+
options: options.pending,
|
|
95
|
+
pending: true
|
|
96
|
+
});
|
|
97
|
+
const settle = (options, value) => {
|
|
98
|
+
let resolved;
|
|
99
|
+
try {
|
|
100
|
+
resolved = resolveOptions(options, value);
|
|
101
|
+
} catch (thrown) {
|
|
102
|
+
dismiss(id);
|
|
103
|
+
throw thrown;
|
|
104
|
+
}
|
|
105
|
+
dispatch({
|
|
106
|
+
kind: "update",
|
|
107
|
+
id,
|
|
108
|
+
options: resolved,
|
|
109
|
+
settle: true
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
return Promise.resolve(input).then((value) => {
|
|
113
|
+
if (success === void 0) dismiss(id);
|
|
114
|
+
else settle(success, value);
|
|
115
|
+
return value;
|
|
116
|
+
}, (reason) => {
|
|
117
|
+
if (error === void 0) {
|
|
118
|
+
dismiss(id);
|
|
119
|
+
throw reason;
|
|
120
|
+
}
|
|
121
|
+
settle(error, reason);
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
const manager = Object.assign((options) => add(options), {
|
|
125
|
+
add,
|
|
126
|
+
promise,
|
|
127
|
+
update,
|
|
128
|
+
dismiss
|
|
129
|
+
});
|
|
130
|
+
internals.set(manager, {
|
|
131
|
+
subscribe: (next) => {
|
|
132
|
+
if (listener !== null && listener !== next) return null;
|
|
133
|
+
listener = next;
|
|
134
|
+
const handedOver = retained;
|
|
135
|
+
retained = [];
|
|
136
|
+
if (handedOver.length > 0) next.restore(handedOver);
|
|
137
|
+
const pending = buffer;
|
|
138
|
+
buffer = [];
|
|
139
|
+
if (pending.length > 0) next.apply(pending);
|
|
140
|
+
return () => {
|
|
141
|
+
if (listener !== next) return;
|
|
142
|
+
retained = next.retain();
|
|
143
|
+
listener = null;
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
isTaken: (candidate) => listener !== null && listener !== candidate
|
|
147
|
+
});
|
|
148
|
+
return manager;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The default toast manager: `toast({ title: "Saved" })` from anywhere on the client (action
|
|
152
|
+
* bodies, stores, effects). `<Toast.Viewport>` without `manager` renders it. On the server every
|
|
153
|
+
* call is a no-op.
|
|
154
|
+
*
|
|
155
|
+
* @see https://ui.funstack.work/components/toast
|
|
156
|
+
*/
|
|
157
|
+
const toast = createToastManager();
|
|
158
|
+
//#endregion
|
|
159
|
+
export { createToastManager, toast, toastManagerInternals };
|
|
160
|
+
|
|
161
|
+
//# sourceMappingURL=toast.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.mjs","names":[],"sources":["../../src/toast/toast.ts"],"sourcesContent":["// No \"use client\" directive: the manager uses no React and no DOM API beyond `queueMicrotask`,\n// so a Server Component may import `toast` (for its type, or to pass nothing) without a client\n// reference (design/components/toast.md 13). The parts are client modules.\nimport type { ReactNode } from \"react\";\nimport type { Action, ActionDetails, ChangeReason, UrgentHandler } from \"../internal/types.js\";\n\n/** Announcement priority and role of a toast. */\nexport type ToastPriority = \"normal\" | \"high\";\n\n/** The `action` of a toast: what `Toast.Action` renders and runs by default. */\nexport interface ToastActionOptions {\n /** The Action button's content. */\n readonly label: ReactNode;\n /**\n * Runs in the Action part's own transition (`data-pending` on the Action and the Root, the\n * timer paused). The toast closes with `reason: \"activate\"` when it resolves; a rejection\n * keeps the toast and reaches the nearest Error Boundary above the Viewport. A caught error\n * resolves the action and therefore closes the toast: rethrow after `toast.update` to keep it.\n */\n readonly action: Action<[details: ToastActionDetails]>;\n}\n\n/**\n * What `toast(options)` shows: the content and behaviour of one toast. `toast.update(id, options)`\n * takes a partial of it.\n *\n * @see https://ui.funstack.work/components/toast\n */\nexport interface ToastOptions {\n /**\n * Explicit id: an existing one updates that toast.\n *\n * @defaultValue generated\n */\n readonly id?: string | undefined;\n /** Rendered by `Toast.Title`, which names the Root (`aria-labelledby`). */\n readonly title?: ReactNode;\n /** Rendered by `Toast.Description`, which describes the Root (`aria-describedby`). */\n readonly description?: ReactNode;\n /** Free-form, rendered as `data-type` on the Root (`\"success\"`, `\"error\"`, ...). */\n readonly type?: string | undefined;\n /**\n * Announcement priority and role: `\"high\"` announces with `ariaNotify` priority `\"high\"` and\n * renders the Root as an `alertdialog`.\n *\n * @defaultValue `\"normal\"`\n */\n readonly priority?: ToastPriority | undefined;\n /**\n * Milliseconds before the toast closes with `reason: \"timeout\"`; `null` never. A timed action\n * toast must keep its action reachable elsewhere too (WCAG 2.2.1).\n *\n * @defaultValue the Viewport's `duration`, or `null` (persistent) when the toast has an `action`\n */\n readonly duration?: number | null | undefined;\n /**\n * A button the toast offers (Undo, Retry), rendered and run by `Toast.Action`. A toast with an\n * action is persistent unless `duration` is set.\n */\n readonly action?: ToastActionOptions | undefined;\n /**\n * A handler, not an action: called once when the toast leaves,\n * with the reason: `\"activate\"` (the Action part settled), `\"dismiss\"` (Close, Escape,\n * `toast.dismiss()`, a promise toast with no message for its outcome) or `\"timeout\"`. Called\n * synchronously where the close happens, outside any Transition, and not awaited: a slow\n * `deleteForReal` holds no other transition. May return a promise (a Server Function); a\n * rejection or a throw goes to `reportError`, never to an Error Boundary. Not called when the\n * Viewport unmounts.\n */\n readonly onClose?: UrgentHandler<ToastCloseDetails> | undefined;\n /**\n * The text `document.ariaNotify()` speaks for this toast; `null` announces nothing.\n *\n * @defaultValue the Viewport's `announce`, else the text of the toast's Title and Description\n */\n readonly announce?: ((toast: ToastItem) => string | null) | undefined;\n /** Anything the Viewport's children want to render. */\n readonly data?: unknown;\n}\n\n/** A toast in the queue, as the Viewport's `children(state)` receives it. */\nexport interface ToastItem extends ToastOptions {\n readonly id: string;\n /**\n * The promise given to `toast.promise` is unsettled, or an action dispatched through this\n * toast's Action part is in flight.\n */\n readonly pending: boolean;\n /** Closed; kept mounted (and `inert`) for its exit animation. */\n readonly ending: boolean;\n}\n\n/** Details passed to a toast's Action. */\nexport interface ToastActionDetails extends ActionDetails {\n /** The toast's id, so an inline action can `toast.update` or `toast.dismiss` its own toast. */\n readonly id: string;\n}\n\n/** Details passed to a toast's `onClose`. */\nexport interface ToastCloseDetails extends ActionDetails {\n /** The id of the toast that closed. */\n readonly id: string;\n /** `\"activate\"`, `\"dismiss\"` or `\"timeout\"`. */\n readonly reason: ChangeReason;\n}\n\n/**\n * The second argument of `toast.promise(promise, options)`: the toast to show while `promise` is\n * pending and the ones that replace it when it settles.\n *\n * @see https://ui.funstack.work/components/toast\n */\nexport interface ToastPromiseOptions<T> {\n /** Shown at once, with `data-pending`; no timer until the promise settles. */\n readonly pending: ToastOptions;\n /**\n * Replaces the toast when the promise fulfils; omitted: the toast is dismissed. A function that\n * throws dismisses the toast, and the returned promise rejects with what it threw.\n */\n readonly success?: ToastOptions | ((value: T) => ToastOptions) | undefined;\n /**\n * Replaces the toast when the promise rejects; the returned promise then resolves with\n * `undefined` (the toast is the handler). Omitted: the toast is dismissed and the returned\n * promise rejects with the same reason. A function that throws dismisses the toast, and the\n * returned promise rejects with what it threw.\n */\n readonly error?: ToastOptions | ((reason: unknown) => ToastOptions) | undefined;\n /**\n * Explicit id of the toast; an existing one is updated.\n *\n * @defaultValue generated\n */\n readonly id?: string | undefined;\n}\n\n/** The queue's input: `toast(options)` and its methods. */\nexport interface ToastManager {\n /** Adds a toast (or updates the one with `options.id`) and returns its id. */\n (options: ToastOptions): string;\n /**\n * The same as calling the manager: adds a toast (or updates the one with `options.id`) and\n * returns its id.\n */\n readonly add: (options: ToastOptions) => string;\n /**\n * Shows `options.pending` at once and swaps to `success` / `error` when `promise` settles.\n * Returns a promise that settles with `promise`, except that a rejection resolves with\n * `undefined` when `error` was given.\n */\n readonly promise: <T>(\n promise: PromiseLike<T>,\n options: ToastPromiseOptions<T>,\n ) => Promise<T | undefined>;\n /** Changes a toast in place (same position, same element). Unknown or closed ids are ignored. */\n readonly update: (id: string, options: Partial<ToastOptions>) => void;\n /** Closes one toast, or every toast when `id` is omitted, with `reason: \"dismiss\"`. */\n readonly dismiss: (id?: string) => void;\n}\n\n// --- Internal: the command channel between a manager and its Viewport --------------------------\n\n/** A queue mutation, applied by the subscribed Viewport (or buffered until one subscribes). */\nexport type ToastCommand =\n | {\n readonly kind: \"add\";\n readonly id: string;\n readonly options: ToastOptions;\n /** Added by `toast.promise`: pending until the promise settles. */\n readonly pending: boolean;\n }\n | {\n readonly kind: \"update\";\n readonly id: string;\n readonly options: Partial<ToastOptions>;\n /** A promise settle: the options replace the toast's (keeping its id), pending ends. */\n readonly settle: boolean;\n }\n | { readonly kind: \"dismiss\"; readonly id: string | undefined };\n\n/** What a Viewport hands its manager. */\nexport interface ToastListener {\n /**\n * Takes over the toasts a previous Viewport left behind (called on subscribe, before the\n * buffer is applied).\n */\n readonly restore: (toasts: readonly RetainedToast[]) => void;\n /** Applies a batch of commands, in dispatch order. */\n readonly apply: (commands: readonly ToastCommand[]) => void;\n /** The toasts to keep when this Viewport unsubscribes. */\n readonly retain: () => readonly RetainedToast[];\n}\n\n/** A retained queue entry: what a Viewport leaves behind when it unmounts (design 14 item 11). */\nexport interface RetainedToast {\n readonly options: ToastOptions & { readonly id: string };\n readonly pending: boolean;\n /**\n * The text last announced for it (`null`: silenced), so the next Viewport does not announce\n * it again; `undefined` when nothing was announced yet.\n */\n readonly announced?: string | null | undefined;\n}\n\nexport interface ToastManagerInternals {\n /**\n * Sets the listener, hands it the retained toasts and drains the buffer into it. Returns the\n * unsubscribe function, or `null` (changing nothing) when a different listener is subscribed:\n * the second-Viewport case.\n */\n readonly subscribe: (listener: ToastListener) => (() => void) | null;\n /** Whether a listener other than `listener` is subscribed (read during render). */\n readonly isTaken: (listener: ToastListener) => boolean;\n}\n\nconst internals = new WeakMap<ToastManager, ToastManagerInternals>();\n\n/** The command channel of `manager` (library-internal). */\nexport function toastManagerInternals(manager: ToastManager): ToastManagerInternals {\n const value = internals.get(manager);\n if (value === undefined) {\n throw new TypeError(\"Toast.Viewport: `manager` must come from `createToastManager()`.\");\n }\n return value;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nlet warnedServer = false;\n\n/**\n * Generated ids are unique across managers, so a Viewport whose `manager` prop changes never\n * mistakes a late close from the old queue (an Undo settling) for one of the new queue's toasts.\n */\nlet nextId = 0;\n\n/** On the server every method is a no-op, never buffered (design 13). */\nfunction onServer(): boolean {\n if (typeof document !== \"undefined\") return false;\n if (isDev && !warnedServer) {\n warnedServer = true;\n console.error(\n \"toast(): called on the server. Toasts are client-only; the call does nothing. Return data \" +\n \"from the Server Function and call `toast()` on the client.\",\n );\n }\n return true;\n}\n\n/** Resets the once-per-process server warning (tests only). */\nexport function resetToastServerWarning(): void {\n warnedServer = false;\n}\n\nfunction resolveOptions<V>(\n options: ToastOptions | ((value: V) => ToastOptions),\n value: V,\n): ToastOptions {\n return typeof options === \"function\" ? options(value) : options;\n}\n\n/**\n * Creates an isolated queue: `<Toast.Viewport manager={m}>` renders it. For a second React root,\n * a micro-frontend, or a test that wants a clean queue. `toast` is the default manager.\n *\n * @see https://ui.funstack.work/components/toast\n */\nexport function createToastManager(): ToastManager {\n let listener: ToastListener | null = null;\n let retained: readonly RetainedToast[] = [];\n /** Commands issued before any Viewport subscribed (client only). */\n let buffer: ToastCommand[] = [];\n /** Commands of the current tick, flushed together from one microtask. */\n let batch: ToastCommand[] = [];\n let scheduled = false;\n\n const flush = (): void => {\n scheduled = false;\n const commands = batch;\n batch = [];\n if (commands.length === 0) return;\n if (listener !== null) listener.apply(commands);\n else buffer.push(...commands);\n };\n\n // A microtask, not a synchronous dispatch: a call made inside a `startTransition` scope (an\n // action's sync prefix) is no longer inside it when the microtask runs, so the queue update is\n // urgent and shows at once even while the action is pending (design 3.4).\n const dispatch = (command: ToastCommand): void => {\n batch.push(command);\n if (scheduled) return;\n scheduled = true;\n queueMicrotask(flush);\n };\n\n const generateId = (): string => `fsui-toast-${++nextId}`;\n\n const add = (options: ToastOptions): string => {\n const id = options.id ?? generateId();\n if (onServer()) return id;\n dispatch({ kind: \"add\", id, options, pending: false });\n return id;\n };\n\n const update = (id: string, options: Partial<ToastOptions>): void => {\n if (onServer()) return;\n dispatch({ kind: \"update\", id, options, settle: false });\n };\n\n const dismiss = (id?: string): void => {\n if (onServer()) return;\n dispatch({ kind: \"dismiss\", id });\n };\n\n const promise = <T>(\n input: PromiseLike<T>,\n options: ToastPromiseOptions<T>,\n ): Promise<T | undefined> => {\n const { success, error } = options;\n if (onServer()) {\n return Promise.resolve(input).then(\n (value) => value,\n (reason: unknown) => {\n if (error !== undefined) return undefined;\n throw reason;\n },\n );\n }\n const id = options.id ?? options.pending.id ?? generateId();\n dispatch({ kind: \"add\", id, options: options.pending, pending: true });\n // The returned promise is built from the same `then`, so it settles in the same tick as the\n // toast's update and an awaiting action prop is pending exactly as long as the toast.\n // A `success` / `error` function that throws dismisses the toast (it must not stay pending\n // forever) and the returned promise rejects with what it threw: the operation's outcome is\n // known, but its message is not, and the `error` message would misreport a fulfilment.\n const settle = <V>(options: ToastOptions | ((value: V) => ToastOptions), value: V): void => {\n let resolved: ToastOptions;\n try {\n resolved = resolveOptions(options, value);\n } catch (thrown) {\n dismiss(id);\n throw thrown;\n }\n dispatch({ kind: \"update\", id, options: resolved, settle: true });\n };\n return Promise.resolve(input).then(\n (value) => {\n if (success === undefined) dismiss(id);\n else settle(success, value);\n return value;\n },\n (reason: unknown) => {\n if (error === undefined) {\n dismiss(id);\n throw reason;\n }\n settle(error, reason);\n return undefined;\n },\n );\n };\n\n const manager = Object.assign((options: ToastOptions) => add(options), {\n add,\n promise,\n update,\n dismiss,\n }) as ToastManager;\n\n internals.set(manager, {\n subscribe: (next) => {\n if (listener !== null && listener !== next) return null;\n listener = next;\n const handedOver = retained;\n retained = [];\n if (handedOver.length > 0) next.restore(handedOver);\n // Commands issued before this Viewport subscribed, in order.\n const pending = buffer;\n buffer = [];\n if (pending.length > 0) next.apply(pending);\n return () => {\n if (listener !== next) return;\n // The queue survives the Viewport (a route-level Viewport remounting on navigation does\n // not lose an Undo); timers and `onClose` calls do not.\n retained = next.retain();\n listener = null;\n };\n },\n isTaken: (candidate) => listener !== null && listener !== candidate,\n });\n\n return manager;\n}\n\n/**\n * The default toast manager: `toast({ title: \"Saved\" })` from anywhere on the client (action\n * bodies, stores, effects). `<Toast.Viewport>` without `manager` renders it. On the server every\n * call is a no-op.\n *\n * @see https://ui.funstack.work/components/toast\n */\nexport const toast: ToastManager = createToastManager();\n"],"mappings":";AAsNA,MAAM,4BAAY,IAAI,QAA6C;;AAGnE,SAAgB,sBAAsB,SAA8C;CAClF,MAAM,QAAQ,UAAU,IAAI,OAAO;CACnC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,UAAU,kEAAkE;CAExF,OAAO;AACT;AAEA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,IAAI,eAAe;;;;;AAMnB,IAAI,SAAS;;AAGb,SAAS,WAAoB;CAC3B,IAAI,OAAO,aAAa,aAAa,OAAO;CAC5C,IAAI,SAAS,CAAC,cAAc;EAC1B,eAAe;EACf,QAAQ,MACN,sJAEF;CACF;CACA,OAAO;AACT;AAOA,SAAS,eACP,SACA,OACc;CACd,OAAO,OAAO,YAAY,aAAa,QAAQ,KAAK,IAAI;AAC1D;;;;;;;AAQA,SAAgB,qBAAmC;CACjD,IAAI,WAAiC;CACrC,IAAI,WAAqC,CAAC;;CAE1C,IAAI,SAAyB,CAAC;;CAE9B,IAAI,QAAwB,CAAC;CAC7B,IAAI,YAAY;CAEhB,MAAM,cAAoB;EACxB,YAAY;EACZ,MAAM,WAAW;EACjB,QAAQ,CAAC;EACT,IAAI,SAAS,WAAW,GAAG;EAC3B,IAAI,aAAa,MAAM,SAAS,MAAM,QAAQ;OACzC,OAAO,KAAK,GAAG,QAAQ;CAC9B;CAKA,MAAM,YAAY,YAAgC;EAChD,MAAM,KAAK,OAAO;EAClB,IAAI,WAAW;EACf,YAAY;EACZ,eAAe,KAAK;CACtB;CAEA,MAAM,mBAA2B,cAAc,EAAE;CAEjD,MAAM,OAAO,YAAkC;EAC7C,MAAM,KAAK,QAAQ,MAAM,WAAW;EACpC,IAAI,SAAS,GAAG,OAAO;EACvB,SAAS;GAAE,MAAM;GAAO;GAAI;GAAS,SAAS;EAAM,CAAC;EACrD,OAAO;CACT;CAEA,MAAM,UAAU,IAAY,YAAyC;EACnE,IAAI,SAAS,GAAG;EAChB,SAAS;GAAE,MAAM;GAAU;GAAI;GAAS,QAAQ;EAAM,CAAC;CACzD;CAEA,MAAM,WAAW,OAAsB;EACrC,IAAI,SAAS,GAAG;EAChB,SAAS;GAAE,MAAM;GAAW;EAAG,CAAC;CAClC;CAEA,MAAM,WACJ,OACA,YAC2B;EAC3B,MAAM,EAAE,SAAS,UAAU;EAC3B,IAAI,SAAS,GACX,OAAO,QAAQ,QAAQ,KAAK,CAAC,CAAC,MAC3B,UAAU,QACV,WAAoB;GACnB,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;GAChC,MAAM;EACR,CACF;EAEF,MAAM,KAAK,QAAQ,MAAM,QAAQ,QAAQ,MAAM,WAAW;EAC1D,SAAS;GAAE,MAAM;GAAO;GAAI,SAAS,QAAQ;GAAS,SAAS;EAAK,CAAC;EAMrE,MAAM,UAAa,SAAsD,UAAmB;GAC1F,IAAI;GACJ,IAAI;IACF,WAAW,eAAe,SAAS,KAAK;GAC1C,SAAS,QAAQ;IACf,QAAQ,EAAE;IACV,MAAM;GACR;GACA,SAAS;IAAE,MAAM;IAAU;IAAI,SAAS;IAAU,QAAQ;GAAK,CAAC;EAClE;EACA,OAAO,QAAQ,QAAQ,KAAK,CAAC,CAAC,MAC3B,UAAU;GACT,IAAI,YAAY,KAAA,GAAW,QAAQ,EAAE;QAChC,OAAO,SAAS,KAAK;GAC1B,OAAO;EACT,IACC,WAAoB;GACnB,IAAI,UAAU,KAAA,GAAW;IACvB,QAAQ,EAAE;IACV,MAAM;GACR;GACA,OAAO,OAAO,MAAM;EAEtB,CACF;CACF;CAEA,MAAM,UAAU,OAAO,QAAQ,YAA0B,IAAI,OAAO,GAAG;EACrE;EACA;EACA;EACA;CACF,CAAC;CAED,UAAU,IAAI,SAAS;EACrB,YAAY,SAAS;GACnB,IAAI,aAAa,QAAQ,aAAa,MAAM,OAAO;GACnD,WAAW;GACX,MAAM,aAAa;GACnB,WAAW,CAAC;GACZ,IAAI,WAAW,SAAS,GAAG,KAAK,QAAQ,UAAU;GAElD,MAAM,UAAU;GAChB,SAAS,CAAC;GACV,IAAI,QAAQ,SAAS,GAAG,KAAK,MAAM,OAAO;GAC1C,aAAa;IACX,IAAI,aAAa,MAAM;IAGvB,WAAW,KAAK,OAAO;IACvB,WAAW;GACb;EACF;EACA,UAAU,cAAc,aAAa,QAAQ,aAAa;CAC5D,CAAC;CAED,OAAO;AACT;;;;;;;;AASA,MAAa,QAAsB,mBAAmB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getServerTopmostModal, getTopmostModal, subscribeModals } from "../internal/overlay/modal-registry.mjs";
|
|
3
|
+
import { useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
4
|
+
//#region src/toast/use-modal-portal-host.ts
|
|
5
|
+
/** No store: `useSyncExternalStore` only tells the hydration render from a client render. */
|
|
6
|
+
const subscribeNothing = () => () => {};
|
|
7
|
+
const onClient = () => true;
|
|
8
|
+
const onServerOrHydrating = () => false;
|
|
9
|
+
/**
|
|
10
|
+
* The element the region is portalled into for its whole client life. The library moves this
|
|
11
|
+
* element (between its inline anchor and the topmost modal dialog); React never sees the move, so
|
|
12
|
+
* the toasts keep their state (an Undo in flight stays pending). `display: contents`: no box.
|
|
13
|
+
*/
|
|
14
|
+
function createHost() {
|
|
15
|
+
if (typeof document === "undefined") return null;
|
|
16
|
+
const host = document.createElement("div");
|
|
17
|
+
host.style.display = "contents";
|
|
18
|
+
return host;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The Viewport's portal host (design/components/toast.md 4.3): in the topmost open modal
|
|
22
|
+
* `Dialog` (a region outside it would be inert), else at its inline anchor. Its layout effect
|
|
23
|
+
* moves the host and must run before the Viewport's region effect: a move hides the popover
|
|
24
|
+
* (removal steps), which that effect shows again in the same commit. `onMove` runs after a move.
|
|
25
|
+
*/
|
|
26
|
+
function useModalPortalHost(onMove) {
|
|
27
|
+
const container = useSyncExternalStore(subscribeModals, getTopmostModal, getServerTopmostModal);
|
|
28
|
+
const portalled = useSyncExternalStore(subscribeNothing, onClient, onServerOrHydrating);
|
|
29
|
+
const [host] = useState(createHost);
|
|
30
|
+
const anchorRef = useRef(null);
|
|
31
|
+
useLayoutEffect(() => {
|
|
32
|
+
if (host === null) return;
|
|
33
|
+
return () => host.remove();
|
|
34
|
+
}, [host]);
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
if (host === null || !portalled) return;
|
|
37
|
+
const target = container ?? anchorRef.current;
|
|
38
|
+
if (target === null || host.parentNode === target) return;
|
|
39
|
+
const moved = host.parentNode !== null;
|
|
40
|
+
target.append(host);
|
|
41
|
+
if (moved) onMove();
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
portalled,
|
|
45
|
+
host,
|
|
46
|
+
anchorRef
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { useModalPortalHost };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=use-modal-portal-host.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-modal-portal-host.mjs","names":[],"sources":["../../src/toast/use-modal-portal-host.ts"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect, useRef, useState, useSyncExternalStore } from \"react\";\nimport type { RefObject } from \"react\";\nimport {\n getServerTopmostModal,\n getTopmostModal,\n subscribeModals,\n} from \"../internal/overlay/modal-registry.js\";\n\n/** No store: `useSyncExternalStore` only tells the hydration render from a client render. */\nconst subscribeNothing = (): (() => void) => () => {};\nconst onClient = (): boolean => true;\nconst onServerOrHydrating = (): boolean => false;\n\n/**\n * The element the region is portalled into for its whole client life. The library moves this\n * element (between its inline anchor and the topmost modal dialog); React never sees the move, so\n * the toasts keep their state (an Undo in flight stays pending). `display: contents`: no box.\n */\nfunction createHost(): HTMLElement | null {\n if (typeof document === \"undefined\") return null;\n const host = document.createElement(\"div\");\n host.style.display = \"contents\";\n return host;\n}\n\nexport interface ModalPortalHost {\n /** `false` for the hydration render (and on the server): render the region inline. */\n readonly portalled: boolean;\n /** Portal into it when `portalled`; `null` without a document. */\n readonly host: HTMLElement | null;\n /** For the inline anchor element the host sits in while no modal is open. */\n readonly anchorRef: RefObject<HTMLDivElement | null>;\n}\n\n/**\n * The Viewport's portal host (design/components/toast.md 4.3): in the topmost open modal\n * `Dialog` (a region outside it would be inert), else at its inline anchor. Its layout effect\n * moves the host and must run before the Viewport's region effect: a move hides the popover\n * (removal steps), which that effect shows again in the same commit. `onMove` runs after a move.\n */\nexport function useModalPortalHost(onMove: () => void): ModalPortalHost {\n const container = useSyncExternalStore(subscribeModals, getTopmostModal, getServerTopmostModal);\n // The hydration render matches the server's inline region; every later render portals into\n // `host`, whose place the library changes without React noticing.\n const portalled = useSyncExternalStore(subscribeNothing, onClient, onServerOrHydrating);\n const [host] = useState(createHost);\n const anchorRef = useRef<HTMLDivElement | null>(null);\n\n useLayoutEffect(() => {\n if (host === null) return;\n return () => host.remove();\n }, [host]);\n\n useLayoutEffect(() => {\n if (host === null || !portalled) return;\n const target = container ?? anchorRef.current;\n if (target === null || host.parentNode === target) return;\n const moved = host.parentNode !== null;\n target.append(host);\n if (moved) onMove();\n });\n\n return { portalled, host, anchorRef };\n}\n"],"mappings":";;;;;AAUA,MAAM,+BAA6C,CAAC;AACpD,MAAM,iBAA0B;AAChC,MAAM,4BAAqC;;;;;;AAO3C,SAAS,aAAiC;CACxC,IAAI,OAAO,aAAa,aAAa,OAAO;CAC5C,MAAM,OAAO,SAAS,cAAc,KAAK;CACzC,KAAK,MAAM,UAAU;CACrB,OAAO;AACT;;;;;;;AAiBA,SAAgB,mBAAmB,QAAqC;CACtE,MAAM,YAAY,qBAAqB,iBAAiB,iBAAiB,qBAAqB;CAG9F,MAAM,YAAY,qBAAqB,kBAAkB,UAAU,mBAAmB;CACtF,MAAM,CAAC,QAAQ,SAAS,UAAU;CAClC,MAAM,YAAY,OAA8B,IAAI;CAEpD,sBAAsB;EACpB,IAAI,SAAS,MAAM;EACnB,aAAa,KAAK,OAAO;CAC3B,GAAG,CAAC,IAAI,CAAC;CAET,sBAAsB;EACpB,IAAI,SAAS,QAAQ,CAAC,WAAW;EACjC,MAAM,SAAS,aAAa,UAAU;EACtC,IAAI,WAAW,QAAQ,KAAK,eAAe,QAAQ;EACnD,MAAM,QAAQ,KAAK,eAAe;EAClC,OAAO,OAAO,IAAI;EAClB,IAAI,OAAO,OAAO;CACpB,CAAC;CAED,OAAO;EAAE;EAAW;EAAM;CAAU;AACtC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { announce } from "../internal/announce.mjs";
|
|
3
|
+
import { plainText } from "./toast-queue.mjs";
|
|
4
|
+
import { useRef } from "react";
|
|
5
|
+
//#region src/toast/use-toast-announcements.ts
|
|
6
|
+
/** `Toast.Viewport`'s announcements through `document.ariaNotify()` (design/components/toast.md 5). */
|
|
7
|
+
function useToastAnnouncements(regionRef) {
|
|
8
|
+
const lastAnnouncedRef = useRef(/* @__PURE__ */ new Map());
|
|
9
|
+
const announceBatch = useRef([]);
|
|
10
|
+
const flushAnnouncements = () => {
|
|
11
|
+
const batch = announceBatch.current;
|
|
12
|
+
announceBatch.current = [];
|
|
13
|
+
if (batch.length === 0) return;
|
|
14
|
+
const priority = batch.some((a) => a.priority === "high") ? "high" : "normal";
|
|
15
|
+
announce(regionRef.current?.ownerDocument ?? document, batch.map((a) => a.text).join(" "), priority);
|
|
16
|
+
};
|
|
17
|
+
const queueAnnouncement = (id, text, priority) => {
|
|
18
|
+
const map = lastAnnouncedRef.current;
|
|
19
|
+
if (map.has(id) && map.get(id) === text) return;
|
|
20
|
+
map.set(id, text);
|
|
21
|
+
if (text === null || text.trim() === "") return;
|
|
22
|
+
if (announceBatch.current.length === 0) queueMicrotask(flushAnnouncements);
|
|
23
|
+
announceBatch.current.push({
|
|
24
|
+
text,
|
|
25
|
+
priority
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const announceQueued = (queued, fallback) => {
|
|
29
|
+
for (const entry of queued) {
|
|
30
|
+
const id = entry.options.id;
|
|
31
|
+
if (lastAnnouncedRef.current.has(id)) continue;
|
|
32
|
+
const resolver = entry.options.announce ?? fallback;
|
|
33
|
+
const text = resolver ? resolver(entry.item) : [plainText(entry.options.title), plainText(entry.options.description)].filter((t) => t !== "").join(" ");
|
|
34
|
+
queueAnnouncement(id, text, entry.options.priority ?? "normal");
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
lastAnnouncedRef,
|
|
39
|
+
queueAnnouncement,
|
|
40
|
+
announceQueued
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { useToastAnnouncements };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=use-toast-announcements.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-toast-announcements.mjs","names":[],"sources":["../../src/toast/use-toast-announcements.ts"],"sourcesContent":["\"use client\";\nimport { useRef } from \"react\";\nimport type { RefObject } from \"react\";\nimport { announce as speak } from \"../internal/announce.js\";\nimport type { ToastItem, ToastPriority } from \"./toast.js\";\nimport { plainText } from \"./toast-queue.js\";\nimport type { Entry } from \"./toast-queue.js\";\n\nexport interface ToastAnnouncements {\n /** Per toast: the text last announced for it (`null`: nothing). The queue writes forget ids. */\n readonly lastAnnouncedRef: RefObject<Map<string, string | null>>;\n /**\n * Queues a toast's text, unless it is what was last announced for it. The texts queued in one\n * task are spoken together in a microtask, at the highest priority among them.\n */\n readonly queueAnnouncement: (id: string, text: string | null, priority: ToastPriority) => void;\n /**\n * Queued toasts are announced on add (design 5): from their plain-text fields, since they have\n * no DOM yet. `fallback` is the Viewport's `announce`.\n */\n readonly announceQueued: (\n queued: readonly Entry[],\n fallback: ((toast: ToastItem) => string | null) | undefined,\n ) => void;\n}\n\n/** `Toast.Viewport`'s announcements through `document.ariaNotify()` (design/components/toast.md 5). */\nexport function useToastAnnouncements(\n regionRef: RefObject<HTMLElement | null>,\n): ToastAnnouncements {\n const lastAnnouncedRef = useRef(new Map<string, string | null>());\n const announceBatch = useRef<{ text: string; priority: ToastPriority }[]>([]);\n\n const flushAnnouncements = (): void => {\n const batch = announceBatch.current;\n announceBatch.current = [];\n if (batch.length === 0) return;\n const priority = batch.some((a) => a.priority === \"high\") ? \"high\" : \"normal\";\n speak(\n regionRef.current?.ownerDocument ?? document,\n batch.map((a) => a.text).join(\" \"),\n priority,\n );\n };\n\n const queueAnnouncement = (id: string, text: string | null, priority: ToastPriority): void => {\n const map = lastAnnouncedRef.current;\n if (map.has(id) && map.get(id) === text) return;\n map.set(id, text);\n if (text === null || text.trim() === \"\") return;\n if (announceBatch.current.length === 0) queueMicrotask(flushAnnouncements);\n announceBatch.current.push({ text, priority });\n };\n\n const announceQueued = (\n queued: readonly Entry[],\n fallback: ((toast: ToastItem) => string | null) | undefined,\n ): void => {\n for (const entry of queued) {\n const id = entry.options.id;\n if (lastAnnouncedRef.current.has(id)) continue;\n const resolver = entry.options.announce ?? fallback;\n const text = resolver\n ? resolver(entry.item)\n : [plainText(entry.options.title), plainText(entry.options.description)]\n .filter((t) => t !== \"\")\n .join(\" \");\n queueAnnouncement(id, text, entry.options.priority ?? \"normal\");\n }\n };\n\n return { lastAnnouncedRef, queueAnnouncement, announceQueued };\n}\n"],"mappings":";;;;;;AA2BA,SAAgB,sBACd,WACoB;CACpB,MAAM,mBAAmB,uBAAO,IAAI,IAA2B,CAAC;CAChE,MAAM,gBAAgB,OAAoD,CAAC,CAAC;CAE5E,MAAM,2BAAiC;EACrC,MAAM,QAAQ,cAAc;EAC5B,cAAc,UAAU,CAAC;EACzB,IAAI,MAAM,WAAW,GAAG;EACxB,MAAM,WAAW,MAAM,MAAM,MAAM,EAAE,aAAa,MAAM,IAAI,SAAS;EACrE,SACE,UAAU,SAAS,iBAAiB,UACpC,MAAM,KAAK,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,GACjC,QACF;CACF;CAEA,MAAM,qBAAqB,IAAY,MAAqB,aAAkC;EAC5F,MAAM,MAAM,iBAAiB;EAC7B,IAAI,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,MAAM,MAAM;EACzC,IAAI,IAAI,IAAI,IAAI;EAChB,IAAI,SAAS,QAAQ,KAAK,KAAK,MAAM,IAAI;EACzC,IAAI,cAAc,QAAQ,WAAW,GAAG,eAAe,kBAAkB;EACzE,cAAc,QAAQ,KAAK;GAAE;GAAM;EAAS,CAAC;CAC/C;CAEA,MAAM,kBACJ,QACA,aACS;EACT,KAAK,MAAM,SAAS,QAAQ;GAC1B,MAAM,KAAK,MAAM,QAAQ;GACzB,IAAI,iBAAiB,QAAQ,IAAI,EAAE,GAAG;GACtC,MAAM,WAAW,MAAM,QAAQ,YAAY;GAC3C,MAAM,OAAO,WACT,SAAS,MAAM,IAAI,IACnB,CAAC,UAAU,MAAM,QAAQ,KAAK,GAAG,UAAU,MAAM,QAAQ,WAAW,CAAC,CAAC,CACnE,QAAQ,MAAM,MAAM,EAAE,CAAC,CACvB,KAAK,GAAG;GACf,kBAAkB,IAAI,MAAM,MAAM,QAAQ,YAAY,QAAQ;EAChE;CACF;CAEA,OAAO;EAAE;EAAkB;EAAmB;CAAe;AAC/D"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { compareDocumentOrder } from "../internal/dom-order.mjs";
|
|
3
|
+
import { matchesHotkey } from "./toast-hotkey.mjs";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
//#region src/toast/use-toast-focus.ts
|
|
6
|
+
/** Focus in and out of `Toast.Viewport`'s toasts (design/components/toast.md 7). */
|
|
7
|
+
function useToastFocus({ entriesRef, roots, regionRef }) {
|
|
8
|
+
const returnTargetRef = useRef(null);
|
|
9
|
+
const sortedRoots = (exclude) => {
|
|
10
|
+
const open = new Set(entriesRef.current.filter((e) => !e.ending).map((e) => e.options.id));
|
|
11
|
+
const list = [];
|
|
12
|
+
for (const [id, element] of roots.current) {
|
|
13
|
+
if (!open.has(id) || exclude?.has(id) || !element.isConnected) continue;
|
|
14
|
+
list.push({
|
|
15
|
+
id,
|
|
16
|
+
element
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return list.sort((a, b) => compareDocumentOrder(a.element, b.element));
|
|
20
|
+
};
|
|
21
|
+
const moveFocusOut = (closing) => {
|
|
22
|
+
const doc = regionRef.current?.ownerDocument ?? document;
|
|
23
|
+
const active = doc.activeElement;
|
|
24
|
+
if (!(active instanceof HTMLElement)) return;
|
|
25
|
+
const all = sortedRoots();
|
|
26
|
+
const index = all.findIndex(({ element }) => element.contains(active));
|
|
27
|
+
if (index === -1 || !closing.has(all[index].id)) return;
|
|
28
|
+
const after = all.slice(index + 1).find(({ id }) => !closing.has(id));
|
|
29
|
+
const before = all.slice(0, index).reverse().find(({ id }) => !closing.has(id));
|
|
30
|
+
const target = after ?? before;
|
|
31
|
+
if (target !== void 0) {
|
|
32
|
+
target.element.focus();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const stored = returnTargetRef.current;
|
|
36
|
+
if (stored !== null && stored.isConnected && !regionRef.current?.contains(stored)) {
|
|
37
|
+
stored.focus();
|
|
38
|
+
if (doc.activeElement === stored) return;
|
|
39
|
+
}
|
|
40
|
+
active.blur();
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
returnTargetRef,
|
|
44
|
+
sortedRoots,
|
|
45
|
+
moveFocusOut
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The hotkey that focuses the newest toast (design/components/toast.md 7), remembering where
|
|
50
|
+
* focus was as the return target.
|
|
51
|
+
*/
|
|
52
|
+
function useToastHotkey({ hotkey, rejected, regionRef, focus }) {
|
|
53
|
+
const { sortedRoots, returnTargetRef } = focus;
|
|
54
|
+
const hotkeyKey = hotkey === null ? null : hotkey.join("\0");
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (hotkeyKey === null || rejected) return;
|
|
57
|
+
const keys = hotkeyKey.split("\0");
|
|
58
|
+
const doc = regionRef.current?.ownerDocument ?? document;
|
|
59
|
+
const onKeyDown = (event) => {
|
|
60
|
+
if (event.defaultPrevented || !matchesHotkey(keys, event)) return;
|
|
61
|
+
const newest = sortedRoots().at(-1);
|
|
62
|
+
if (newest === void 0) return;
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
const active = doc.activeElement;
|
|
65
|
+
if (active instanceof HTMLElement && !regionRef.current?.contains(active)) returnTargetRef.current = active;
|
|
66
|
+
newest.element.focus();
|
|
67
|
+
};
|
|
68
|
+
doc.addEventListener("keydown", onKeyDown);
|
|
69
|
+
return () => doc.removeEventListener("keydown", onKeyDown);
|
|
70
|
+
}, [hotkeyKey, rejected]);
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { useToastFocus, useToastHotkey };
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=use-toast-focus.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-toast-focus.mjs","names":[],"sources":["../../src/toast/use-toast-focus.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\nimport { compareDocumentOrder } from \"../internal/dom-order.js\";\nimport { matchesHotkey } from \"./toast-hotkey.js\";\nimport type { Entry } from \"./toast-queue.js\";\n\nexport interface ToastFocusOptions {\n /** The Viewport's latest queue. */\n readonly entriesRef: RefObject<readonly Entry[]>;\n /** The mounted Roots by toast id. */\n readonly roots: RefObject<Map<string, HTMLElement>>;\n readonly regionRef: RefObject<HTMLElement | null>;\n}\n\nexport interface ToastFocus {\n /** Where focus goes back to once the last toast holding it leaves (design 7). */\n readonly returnTargetRef: RefObject<HTMLElement | null>;\n /** Open toasts' Root elements in document order. Reads refs only. */\n readonly sortedRoots: (exclude?: ReadonlySet<string>) => { id: string; element: HTMLElement }[];\n /**\n * Before toasts close: if focus is inside one of them, move it to the next toast, else the\n * previous one, else where it was before the region was entered, else the body (design 7).\n */\n readonly moveFocusOut: (closing: ReadonlySet<string>) => void;\n}\n\n/** Focus in and out of `Toast.Viewport`'s toasts (design/components/toast.md 7). */\nexport function useToastFocus({ entriesRef, roots, regionRef }: ToastFocusOptions): ToastFocus {\n const returnTargetRef = useRef<HTMLElement | null>(null);\n\n const sortedRoots = (exclude?: ReadonlySet<string>): { id: string; element: HTMLElement }[] => {\n const open = new Set(entriesRef.current.filter((e) => !e.ending).map((e) => e.options.id));\n const list: { id: string; element: HTMLElement }[] = [];\n for (const [id, element] of roots.current) {\n if (!open.has(id) || exclude?.has(id) || !element.isConnected) continue;\n list.push({ id, element });\n }\n return list.sort((a, b) => compareDocumentOrder(a.element, b.element));\n };\n\n const moveFocusOut = (closing: ReadonlySet<string>): void => {\n const doc = regionRef.current?.ownerDocument ?? document;\n const active = doc.activeElement;\n if (!(active instanceof HTMLElement)) return;\n const all = sortedRoots();\n const index = all.findIndex(({ element }) => element.contains(active));\n if (index === -1 || !closing.has(all[index]!.id)) return;\n const after = all.slice(index + 1).find(({ id }) => !closing.has(id));\n const before = all\n .slice(0, index)\n .reverse()\n .find(({ id }) => !closing.has(id));\n const target = after ?? before;\n if (target !== undefined) {\n target.element.focus();\n return;\n }\n const stored = returnTargetRef.current;\n if (stored !== null && stored.isConnected && !regionRef.current?.contains(stored)) {\n stored.focus();\n if (doc.activeElement === stored) return;\n }\n active.blur();\n };\n\n return { returnTargetRef, sortedRoots, moveFocusOut };\n}\n\nexport interface ToastHotkeyOptions {\n /** The Viewport's `hotkey`; `null` installs no listener. */\n readonly hotkey: readonly string[] | null;\n /** This Viewport renders nothing (another one renders the manager). */\n readonly rejected: boolean;\n readonly regionRef: RefObject<HTMLElement | null>;\n readonly focus: ToastFocus;\n}\n\n/**\n * The hotkey that focuses the newest toast (design/components/toast.md 7), remembering where\n * focus was as the return target.\n */\nexport function useToastHotkey({ hotkey, rejected, regionRef, focus }: ToastHotkeyOptions): void {\n const { sortedRoots, returnTargetRef } = focus;\n const hotkeyKey = hotkey === null ? null : hotkey.join(\"\\u0000\");\n useEffect(() => {\n if (hotkeyKey === null || rejected) return;\n const keys = hotkeyKey.split(\"\\u0000\");\n const doc = regionRef.current?.ownerDocument ?? document;\n const onKeyDown = (event: KeyboardEvent): void => {\n if (event.defaultPrevented || !matchesHotkey(keys, event)) return;\n const all = sortedRoots();\n const newest = all.at(-1);\n if (newest === undefined) return;\n event.preventDefault();\n const active = doc.activeElement;\n if (active instanceof HTMLElement && !regionRef.current?.contains(active)) {\n returnTargetRef.current = active;\n }\n newest.element.focus();\n };\n doc.addEventListener(\"keydown\", onKeyDown);\n return () => doc.removeEventListener(\"keydown\", onKeyDown);\n // oxlint-disable-next-line react-hooks/exhaustive-deps -- `sortedRoots` reads refs only\n }, [hotkeyKey, rejected]);\n}\n"],"mappings":";;;;;;AA4BA,SAAgB,cAAc,EAAE,YAAY,OAAO,aAA4C;CAC7F,MAAM,kBAAkB,OAA2B,IAAI;CAEvD,MAAM,eAAe,YAA0E;EAC7F,MAAM,OAAO,IAAI,IAAI,WAAW,QAAQ,QAAQ,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC;EACzF,MAAM,OAA+C,CAAC;EACtD,KAAK,MAAM,CAAC,IAAI,YAAY,MAAM,SAAS;GACzC,IAAI,CAAC,KAAK,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,CAAC,QAAQ,aAAa;GAC/D,KAAK,KAAK;IAAE;IAAI;GAAQ,CAAC;EAC3B;EACA,OAAO,KAAK,MAAM,GAAG,MAAM,qBAAqB,EAAE,SAAS,EAAE,OAAO,CAAC;CACvE;CAEA,MAAM,gBAAgB,YAAuC;EAC3D,MAAM,MAAM,UAAU,SAAS,iBAAiB;EAChD,MAAM,SAAS,IAAI;EACnB,IAAI,EAAE,kBAAkB,cAAc;EACtC,MAAM,MAAM,YAAY;EACxB,MAAM,QAAQ,IAAI,WAAW,EAAE,cAAc,QAAQ,SAAS,MAAM,CAAC;EACrE,IAAI,UAAU,MAAM,CAAC,QAAQ,IAAI,IAAI,MAAM,CAAE,EAAE,GAAG;EAClD,MAAM,QAAQ,IAAI,MAAM,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,IAAI,EAAE,CAAC;EACpE,MAAM,SAAS,IACZ,MAAM,GAAG,KAAK,CAAC,CACf,QAAQ,CAAC,CACT,MAAM,EAAE,SAAS,CAAC,QAAQ,IAAI,EAAE,CAAC;EACpC,MAAM,SAAS,SAAS;EACxB,IAAI,WAAW,KAAA,GAAW;GACxB,OAAO,QAAQ,MAAM;GACrB;EACF;EACA,MAAM,SAAS,gBAAgB;EAC/B,IAAI,WAAW,QAAQ,OAAO,eAAe,CAAC,UAAU,SAAS,SAAS,MAAM,GAAG;GACjF,OAAO,MAAM;GACb,IAAI,IAAI,kBAAkB,QAAQ;EACpC;EACA,OAAO,KAAK;CACd;CAEA,OAAO;EAAE;EAAiB;EAAa;CAAa;AACtD;;;;;AAeA,SAAgB,eAAe,EAAE,QAAQ,UAAU,WAAW,SAAmC;CAC/F,MAAM,EAAE,aAAa,oBAAoB;CACzC,MAAM,YAAY,WAAW,OAAO,OAAO,OAAO,KAAK,IAAQ;CAC/D,gBAAgB;EACd,IAAI,cAAc,QAAQ,UAAU;EACpC,MAAM,OAAO,UAAU,MAAM,IAAQ;EACrC,MAAM,MAAM,UAAU,SAAS,iBAAiB;EAChD,MAAM,aAAa,UAA+B;GAChD,IAAI,MAAM,oBAAoB,CAAC,cAAc,MAAM,KAAK,GAAG;GAE3D,MAAM,SADM,YACK,CAAC,CAAC,GAAG,EAAE;GACxB,IAAI,WAAW,KAAA,GAAW;GAC1B,MAAM,eAAe;GACrB,MAAM,SAAS,IAAI;GACnB,IAAI,kBAAkB,eAAe,CAAC,UAAU,SAAS,SAAS,MAAM,GACtE,gBAAgB,UAAU;GAE5B,OAAO,QAAQ,MAAM;EACvB;EACA,IAAI,iBAAiB,WAAW,SAAS;EACzC,aAAa,IAAI,oBAAoB,WAAW,SAAS;CAE3D,GAAG,CAAC,WAAW,QAAQ,CAAC;AAC1B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLatest } from "../internal/use-latest.mjs";
|
|
3
|
+
import { useCallback, useRef, useState } from "react";
|
|
4
|
+
//#region src/toast/use-toast-pauses.ts
|
|
5
|
+
function anyPause(sources) {
|
|
6
|
+
return sources.hover || sources.focus || sources.hidden || sources.blurred;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The pause sources of `Toast.Viewport` (design/components/toast.md 6): the pointer over the
|
|
10
|
+
* region, focus inside it, a hidden document, a blurred window. `syncTimers` re-syncs the timers
|
|
11
|
+
* after a change.
|
|
12
|
+
*/
|
|
13
|
+
function useToastPauses(syncTimers) {
|
|
14
|
+
const sources = useRef({
|
|
15
|
+
hover: false,
|
|
16
|
+
focus: false,
|
|
17
|
+
hidden: false,
|
|
18
|
+
blurred: false
|
|
19
|
+
});
|
|
20
|
+
const [paused, setPaused] = useState(false);
|
|
21
|
+
const setPause = (source, value) => {
|
|
22
|
+
if (sources.current[source] === value) return;
|
|
23
|
+
sources.current[source] = value;
|
|
24
|
+
syncTimers();
|
|
25
|
+
setPaused(anyPause(sources.current));
|
|
26
|
+
};
|
|
27
|
+
const setPauseRef = useLatest(setPause);
|
|
28
|
+
return {
|
|
29
|
+
paused,
|
|
30
|
+
holding: (source) => sources.current[source],
|
|
31
|
+
anyHeld: () => anyPause(sources.current),
|
|
32
|
+
setPause,
|
|
33
|
+
watch: useCallback((doc) => {
|
|
34
|
+
const view = doc.defaultView ?? window;
|
|
35
|
+
sources.current.hidden = doc.visibilityState === "hidden";
|
|
36
|
+
const onVisibility = () => setPauseRef.current("hidden", doc.visibilityState === "hidden");
|
|
37
|
+
const onWindowBlur = (event) => {
|
|
38
|
+
if (!(event.target instanceof Node)) setPauseRef.current("blurred", true);
|
|
39
|
+
};
|
|
40
|
+
const onWindowFocus = (event) => {
|
|
41
|
+
if (!(event.target instanceof Node)) setPauseRef.current("blurred", false);
|
|
42
|
+
};
|
|
43
|
+
doc.addEventListener("visibilitychange", onVisibility);
|
|
44
|
+
view.addEventListener("blur", onWindowBlur);
|
|
45
|
+
view.addEventListener("focus", onWindowFocus);
|
|
46
|
+
setPaused(anyPause(sources.current));
|
|
47
|
+
return () => {
|
|
48
|
+
doc.removeEventListener("visibilitychange", onVisibility);
|
|
49
|
+
view.removeEventListener("blur", onWindowBlur);
|
|
50
|
+
view.removeEventListener("focus", onWindowFocus);
|
|
51
|
+
};
|
|
52
|
+
}, [setPauseRef])
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { useToastPauses };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=use-toast-pauses.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-toast-pauses.mjs","names":[],"sources":["../../src/toast/use-toast-pauses.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useRef, useState } from \"react\";\nimport { useLatest } from \"../internal/use-latest.js\";\n\n/** The viewport-wide pause sources (design/components/toast.md 6). */\nexport interface PauseSources {\n hover: boolean;\n focus: boolean;\n hidden: boolean;\n blurred: boolean;\n}\n\nfunction anyPause(sources: PauseSources): boolean {\n return sources.hover || sources.focus || sources.hidden || sources.blurred;\n}\n\nexport interface ToastPauses {\n /** A pause holds, as of the last write (state, for `data-paused` and the Viewport's state). */\n readonly paused: boolean;\n /** Whether `source` holds now. Handlers and effects only. */\n readonly holding: (source: keyof PauseSources) => boolean;\n /** Whether any source holds now (the timers are halted). Handlers and effects only. */\n readonly anyHeld: () => boolean;\n /**\n * Sets a source. A change re-syncs the timers synchronously, in the event, before any timer\n * callback can run (design 14 item 9), then publishes `paused`.\n */\n readonly setPause: (source: keyof PauseSources, value: boolean) => void;\n /**\n * Reads the document's visibility, listens to it and to the window's own focus and blur, and\n * publishes `paused`. Returns the cleanup. For the Viewport's mount effect; stable.\n */\n readonly watch: (doc: Document) => () => void;\n}\n\n/**\n * The pause sources of `Toast.Viewport` (design/components/toast.md 6): the pointer over the\n * region, focus inside it, a hidden document, a blurred window. `syncTimers` re-syncs the timers\n * after a change.\n */\nexport function useToastPauses(syncTimers: () => void): ToastPauses {\n const sources = useRef<PauseSources>({\n hover: false,\n focus: false,\n hidden: false,\n blurred: false,\n });\n const [paused, setPaused] = useState(false);\n\n const setPause = (source: keyof PauseSources, value: boolean): void => {\n if (sources.current[source] === value) return;\n sources.current[source] = value;\n // Applied synchronously in the event, before any timer callback can run (design 14 item 9).\n syncTimers();\n setPaused(anyPause(sources.current));\n };\n const setPauseRef = useLatest(setPause);\n\n // Stable, so the Viewport's mount effect does not re-run for it.\n const watch = useCallback(\n (doc: Document): (() => void) => {\n const view = doc.defaultView ?? window;\n sources.current.hidden = doc.visibilityState === \"hidden\";\n const onVisibility = (): void =>\n setPauseRef.current(\"hidden\", doc.visibilityState === \"hidden\");\n // The window's own focus and blur; an element's (which do not bubble) never reach here.\n const onWindowBlur = (event: Event): void => {\n if (!(event.target instanceof Node)) setPauseRef.current(\"blurred\", true);\n };\n const onWindowFocus = (event: Event): void => {\n if (!(event.target instanceof Node)) setPauseRef.current(\"blurred\", false);\n };\n doc.addEventListener(\"visibilitychange\", onVisibility);\n view.addEventListener(\"blur\", onWindowBlur);\n view.addEventListener(\"focus\", onWindowFocus);\n setPaused(anyPause(sources.current));\n return () => {\n doc.removeEventListener(\"visibilitychange\", onVisibility);\n view.removeEventListener(\"blur\", onWindowBlur);\n view.removeEventListener(\"focus\", onWindowFocus);\n };\n },\n [setPauseRef],\n );\n\n return {\n paused,\n holding: (source) => sources.current[source],\n anyHeld: () => anyPause(sources.current),\n setPause,\n watch,\n };\n}\n"],"mappings":";;;;AAYA,SAAS,SAAS,SAAgC;CAChD,OAAO,QAAQ,SAAS,QAAQ,SAAS,QAAQ,UAAU,QAAQ;AACrE;;;;;;AA0BA,SAAgB,eAAe,YAAqC;CAClE,MAAM,UAAU,OAAqB;EACnC,OAAO;EACP,OAAO;EACP,QAAQ;EACR,SAAS;CACX,CAAC;CACD,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAE1C,MAAM,YAAY,QAA4B,UAAyB;EACrE,IAAI,QAAQ,QAAQ,YAAY,OAAO;EACvC,QAAQ,QAAQ,UAAU;EAE1B,WAAW;EACX,UAAU,SAAS,QAAQ,OAAO,CAAC;CACrC;CACA,MAAM,cAAc,UAAU,QAAQ;CA6BtC,OAAO;EACL;EACA,UAAU,WAAW,QAAQ,QAAQ;EACrC,eAAe,SAAS,QAAQ,OAAO;EACvC;EACA,OA/BY,aACX,QAAgC;GAC/B,MAAM,OAAO,IAAI,eAAe;GAChC,QAAQ,QAAQ,SAAS,IAAI,oBAAoB;GACjD,MAAM,qBACJ,YAAY,QAAQ,UAAU,IAAI,oBAAoB,QAAQ;GAEhE,MAAM,gBAAgB,UAAuB;IAC3C,IAAI,EAAE,MAAM,kBAAkB,OAAO,YAAY,QAAQ,WAAW,IAAI;GAC1E;GACA,MAAM,iBAAiB,UAAuB;IAC5C,IAAI,EAAE,MAAM,kBAAkB,OAAO,YAAY,QAAQ,WAAW,KAAK;GAC3E;GACA,IAAI,iBAAiB,oBAAoB,YAAY;GACrD,KAAK,iBAAiB,QAAQ,YAAY;GAC1C,KAAK,iBAAiB,SAAS,aAAa;GAC5C,UAAU,SAAS,QAAQ,OAAO,CAAC;GACnC,aAAa;IACX,IAAI,oBAAoB,oBAAoB,YAAY;IACxD,KAAK,oBAAoB,QAAQ,YAAY;IAC7C,KAAK,oBAAoB,SAAS,aAAa;GACjD;EACF,GACA,CAAC,WAAW,CAQR;CACN;AACF"}
|
package/dist/toggle/toggle.d.mts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ActionDetails, ChangeAction, RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
2
|
import { CSSProperties, ComponentPropsWithRef, ReactNode, ViewTransitionClass } from "react";
|
|
3
3
|
//#region src/toggle/toggle.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* State of `Toggle`, passed to the function forms of `className`, `style`, `children` and `render`.
|
|
6
|
+
*/
|
|
4
7
|
export interface ToggleState {
|
|
5
8
|
/** Optimistic pressed state: what the user sees, including an in-flight change. */
|
|
6
9
|
readonly pressed: boolean;
|
|
@@ -11,10 +14,19 @@ export interface ToggleState {
|
|
|
11
14
|
}
|
|
12
15
|
/** Details passed as the second argument of `pressedChangeAction`. */
|
|
13
16
|
export interface TogglePressedChangeDetails extends ActionDetails {}
|
|
17
|
+
/**
|
|
18
|
+
* Props of `Toggle`.
|
|
19
|
+
*
|
|
20
|
+
* @see https://ui.funstack.work/components/toggle
|
|
21
|
+
*/
|
|
14
22
|
export interface ToggleProps extends Omit<ComponentPropsWithRef<"button">, "onClick" | "type" | "aria-pressed" | "className" | "style" | "children"> {
|
|
15
23
|
/** Controlled pressed state. `undefined` means uncontrolled. */
|
|
16
24
|
pressed?: boolean;
|
|
17
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Initial pressed state in uncontrolled mode.
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue `false`
|
|
29
|
+
*/
|
|
18
30
|
defaultPressed?: boolean;
|
|
19
31
|
/**
|
|
20
32
|
* Called with the next pressed state on every user-initiated change. Runs inside the Toggle's
|
|
@@ -24,20 +36,26 @@ export interface ToggleProps extends Omit<ComponentPropsWithRef<"button">, "onCl
|
|
|
24
36
|
* `startTransition` (React limitation).
|
|
25
37
|
*/
|
|
26
38
|
pressedChangeAction?: ChangeAction<boolean, TogglePressedChangeDetails>;
|
|
27
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Never dispatches. Native `disabled` on a `<button>`; with a link or component `render`,
|
|
41
|
+
* `aria-disabled="true"` instead (the element stays focusable).
|
|
42
|
+
*
|
|
43
|
+
* @defaultValue `false`
|
|
44
|
+
*/
|
|
28
45
|
disabled?: boolean;
|
|
29
46
|
/**
|
|
30
47
|
* Forwarded as `default` to the Toggle's `<ViewTransition>`. Default: no boundary. Animates the
|
|
31
48
|
* commit that ends an action (and rollbacks), not the optimistic flip itself; animate the flip
|
|
32
49
|
* with a CSS `transition` on `[data-pressed]`.
|
|
33
50
|
*
|
|
34
|
-
* Static:
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* page cross-fades for about 250 ms and the next transition commit waits for it (issue #35).
|
|
51
|
+
* Static: setting or unsetting it remounts the element. Any value, `"none"` included, makes a
|
|
52
|
+
* mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms
|
|
53
|
+
* page cross-fade that the next transition waits for).
|
|
38
54
|
*/
|
|
39
55
|
transition?: ViewTransitionClass;
|
|
56
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
40
57
|
className?: StateValue<string | undefined, ToggleState>;
|
|
58
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
41
59
|
style?: StateValue<CSSProperties | undefined, ToggleState>;
|
|
42
60
|
/** Rendered from optimistic state inside the button; must not suspend. */
|
|
43
61
|
children?: StateValue<ReactNode, ToggleState>;
|
|
@@ -48,6 +66,8 @@ export interface ToggleProps extends Omit<ComponentPropsWithRef<"button">, "onCl
|
|
|
48
66
|
* A two-state button (WAI-ARIA "Button" pattern, toggle variant). Renders
|
|
49
67
|
* `<button type="button" aria-pressed>`; the pressed state flips optimistically and the element
|
|
50
68
|
* carries `data-pending` while `pressedChangeAction` is in flight.
|
|
69
|
+
*
|
|
70
|
+
* @see https://ui.funstack.work/components/toggle
|
|
51
71
|
*/
|
|
52
72
|
export declare function Toggle({ pressed, defaultPressed, pressedChangeAction, disabled, transition, className, style, children, render, ...rest }: ToggleProps): ReactNode;
|
|
53
73
|
export declare namespace Toggle {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.d.mts","names":[],"sources":["../../src/toggle/toggle.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"toggle.d.mts","names":[],"sources":["../../src/toggle/toggle.tsx"],"mappings":";;;;;;iBAmBiB;;WAEN;;WAEA;;WAEA;;;iBAIM,mCAAmC;;;;;;iBAUnC,oBAAoB,KACnC;;EAIA;;;;;;EAMA;;;;;;;;EAQA,sBAAsB,sBAAsB;;;;;;;EAO5C;;;;;;;;;;EAUA,aAAa;;EAEb,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,iCAAiC;;;;;;;;;wBAUvC,SACd,SACA,gBACA,qBACA,UACA,YACA,WACA,OACA,UACA,WACG,QACF,cAAW;yBAXE"}
|
package/dist/toggle/toggle.mjs
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { createActionDetails } from "../internal/action-details.mjs";
|
|
2
|
+
import { createActionDetails } from "../internal/action/action-details.mjs";
|
|
4
3
|
import { dataAttr } from "../internal/data-attr.mjs";
|
|
4
|
+
import { useTransitionBoundary } from "../internal/transition-boundary.mjs";
|
|
5
|
+
import { disabledButton, rendersButton } from "../internal/render-element.mjs";
|
|
6
|
+
import { useRender } from "../internal/use-render.mjs";
|
|
5
7
|
import { transitionTypes } from "../internal/transition-types.mjs";
|
|
6
|
-
import { useControllableAction } from "../internal/use-controllable-action.mjs";
|
|
7
|
-
import { rendersButton, useRender } from "../internal/use-render.mjs";
|
|
8
|
+
import { useControllableAction } from "../internal/action/use-controllable-action.mjs";
|
|
8
9
|
//#region src/toggle/toggle.tsx
|
|
9
10
|
/**
|
|
10
11
|
* A two-state button (WAI-ARIA "Button" pattern, toggle variant). Renders
|
|
11
12
|
* `<button type="button" aria-pressed>`; the pressed state flips optimistically and the element
|
|
12
13
|
* carries `data-pending` while `pressedChangeAction` is in flight.
|
|
14
|
+
*
|
|
15
|
+
* @see https://ui.funstack.work/components/toggle
|
|
13
16
|
*/
|
|
14
17
|
function Toggle({ pressed, defaultPressed, pressedChangeAction, disabled = false, transition, className, style, children, render, ...rest }) {
|
|
15
18
|
const { optimistic, pending, dispatch } = useControllableAction({
|
|
@@ -39,13 +42,16 @@ function Toggle({ pressed, defaultPressed, pressedChangeAction, disabled = false
|
|
|
39
42
|
type: "button"
|
|
40
43
|
} : rest,
|
|
41
44
|
libraryProps: {
|
|
42
|
-
disabled,
|
|
45
|
+
...disabledButton(render, disabled).props,
|
|
43
46
|
"aria-pressed": optimistic,
|
|
44
47
|
"data-pressed": dataAttr(optimistic),
|
|
45
48
|
"data-pending": dataAttr(pending),
|
|
46
49
|
"data-disabled": dataAttr(disabled),
|
|
47
50
|
onClick: (event) => {
|
|
48
|
-
if (disabled)
|
|
51
|
+
if (disabled) {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
49
55
|
dispatch(!optimistic, createActionDetails(event.nativeEvent, {}));
|
|
50
56
|
}
|
|
51
57
|
}
|