@funstack/ui 0.1.0-alpha.15 → 0.1.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -1
- package/dist/accordion/accordion-item.d.mts +19 -0
- package/dist/accordion/accordion-item.d.mts.map +1 -1
- package/dist/accordion/accordion-item.mjs +2 -0
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.d.mts +16 -0
- package/dist/accordion/accordion-panel.d.mts.map +1 -1
- package/dist/accordion/accordion-panel.mjs +2 -0
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts +36 -2
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +2 -0
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts +9 -0
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +2 -0
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/accordion/index.d.mts +2 -0
- package/dist/accordion/index.d.mts.map +1 -1
- package/dist/accordion/index.mjs +2 -0
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/bin/skill-installer.d.mts +1 -0
- package/dist/bin/skill-installer.mjs +12 -0
- package/dist/bin/skill-installer.mjs.map +1 -0
- package/dist/button/button.d.mts +25 -7
- package/dist/button/button.d.mts.map +1 -1
- package/dist/button/button.mjs +2 -0
- package/dist/button/button.mjs.map +1 -1
- package/dist/checkbox/checkbox.d.mts +25 -3
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +2 -0
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +15 -0
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.d.mts +10 -0
- package/dist/checkbox-group/checkbox-group-label.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts +19 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +31 -4
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/checkbox-group/index.d.mts +2 -0
- package/dist/checkbox-group/index.d.mts.map +1 -1
- package/dist/checkbox-group/index.mjs +2 -0
- package/dist/checkbox-group/index.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts +18 -0
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +2 -0
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-group.d.mts +49 -1
- package/dist/combobox/combobox-group.d.mts.map +1 -1
- package/dist/combobox/combobox-group.mjs +11 -1
- package/dist/combobox/combobox-group.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts +11 -0
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +2 -0
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-label.d.mts +16 -0
- package/dist/combobox/combobox-label.d.mts.map +1 -1
- package/dist/combobox/combobox-label.mjs +2 -0
- package/dist/combobox/combobox-label.mjs.map +1 -1
- package/dist/combobox/combobox-list.d.mts +14 -0
- package/dist/combobox/combobox-list.d.mts.map +1 -1
- package/dist/combobox/combobox-list.mjs +2 -0
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts +25 -3
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +2 -0
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts +16 -0
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +2 -0
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts +49 -12
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +2 -0
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts +16 -0
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +2 -0
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.d.mts +2 -0
- package/dist/combobox/index.d.mts.map +1 -1
- package/dist/combobox/index.mjs +2 -0
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/csp/csp-provider.d.mts +8 -0
- package/dist/csp/csp-provider.d.mts.map +1 -1
- package/dist/csp/csp-provider.mjs +2 -0
- package/dist/csp/csp-provider.mjs.map +1 -1
- package/dist/csp/style-hashes.d.mts +2 -0
- package/dist/csp/style-hashes.d.mts.map +1 -1
- package/dist/csp/style-hashes.mjs +2 -0
- package/dist/csp/style-hashes.mjs.map +1 -1
- package/dist/dialog/dialog-close.d.mts +18 -0
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +2 -0
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-description.d.mts +12 -0
- package/dist/dialog/dialog-description.d.mts.map +1 -1
- package/dist/dialog/dialog-description.mjs +2 -0
- package/dist/dialog/dialog-description.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts +18 -1
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +2 -0
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +25 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +2 -0
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +15 -1
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +2 -0
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-title.d.mts +11 -0
- package/dist/dialog/dialog-title.d.mts.map +1 -1
- package/dist/dialog/dialog-title.mjs +2 -0
- package/dist/dialog/dialog-title.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +16 -0
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +2 -0
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +2 -0
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +2 -0
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/docs/components/accordion.md +426 -0
- package/dist/docs/components/button.md +464 -0
- package/dist/docs/components/checkbox-group.md +474 -0
- package/dist/docs/components/checkbox.md +373 -0
- package/dist/docs/components/combobox.md +635 -0
- package/dist/docs/components/context-menu.md +524 -0
- package/dist/docs/components/dialog.md +686 -0
- package/dist/docs/components/field.md +587 -0
- package/dist/docs/components/menu.md +589 -0
- package/dist/docs/components/meter.md +313 -0
- package/dist/docs/components/number-field.md +528 -0
- package/dist/docs/components/popover.md +591 -0
- package/dist/docs/components/progress.md +450 -0
- package/dist/docs/components/radio-group.md +457 -0
- package/dist/docs/components/select.md +662 -0
- package/dist/docs/components/slider.md +558 -0
- package/dist/docs/components/switch.md +311 -0
- package/dist/docs/components/tabs.md +473 -0
- package/dist/docs/components/toast.md +576 -0
- package/dist/docs/components/toggle-group.md +341 -0
- package/dist/docs/components/toggle.md +245 -0
- package/dist/docs/components/toolbar.md +389 -0
- package/dist/docs/components/tooltip.md +494 -0
- package/dist/docs/concepts/action-props.md +251 -0
- package/dist/docs/concepts/ai-agents.md +56 -0
- package/dist/docs/concepts/browser-owned-state.md +118 -0
- package/dist/docs/concepts/content-security-policy.md +69 -0
- package/dist/docs/concepts/experimental.md +36 -0
- package/dist/docs/concepts/pending-and-optimistic.md +250 -0
- package/dist/docs/concepts/server-components.md +118 -0
- package/dist/docs/concepts/suspense.md +124 -0
- package/dist/docs/concepts/transitions.md +118 -0
- package/dist/docs/getting-started.md +115 -0
- package/dist/docs/index.md +181 -0
- package/dist/docs/roadmap.md +74 -0
- package/dist/docs/why.md +100 -0
- package/dist/field/field-control.d.mts +26 -3
- package/dist/field/field-control.d.mts.map +1 -1
- package/dist/field/field-control.mjs +2 -0
- package/dist/field/field-control.mjs.map +1 -1
- package/dist/field/field-description.d.mts +11 -0
- package/dist/field/field-description.d.mts.map +1 -1
- package/dist/field/field-description.mjs +2 -0
- package/dist/field/field-description.mjs.map +1 -1
- package/dist/field/field-error.d.mts +14 -2
- package/dist/field/field-error.d.mts.map +1 -1
- package/dist/field/field-error.mjs +2 -0
- package/dist/field/field-error.mjs.map +1 -1
- package/dist/field/field-label.d.mts +10 -0
- package/dist/field/field-label.d.mts.map +1 -1
- package/dist/field/field-label.mjs +2 -0
- package/dist/field/field-label.mjs.map +1 -1
- package/dist/field/field-root.d.mts +21 -2
- package/dist/field/field-root.d.mts.map +1 -1
- package/dist/field/field-root.mjs +2 -0
- package/dist/field/field-root.mjs.map +1 -1
- package/dist/field/index.d.mts +9 -0
- package/dist/field/index.d.mts.map +1 -1
- package/dist/field/index.mjs +9 -0
- package/dist/field/index.mjs.map +1 -1
- package/dist/form/form-root.d.mts +17 -1
- package/dist/form/form-root.d.mts.map +1 -1
- package/dist/form/form-root.mjs +2 -0
- package/dist/form/form-root.mjs.map +1 -1
- package/dist/form/form-submit.d.mts +18 -0
- package/dist/form/form-submit.d.mts.map +1 -1
- package/dist/form/form-submit.mjs +2 -0
- package/dist/form/form-submit.mjs.map +1 -1
- package/dist/form/index.d.mts +7 -0
- package/dist/form/index.d.mts.map +1 -1
- package/dist/form/index.mjs +7 -0
- package/dist/form/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/internal/types.d.mts +3 -0
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-popover-trigger.d.mts +1 -0
- package/dist/internal/use-popover-trigger.d.mts.map +1 -1
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/validity.d.mts +11 -0
- package/dist/internal/validity.d.mts.map +1 -1
- package/dist/internal/validity.mjs.map +1 -1
- package/dist/menu/index.d.mts +2 -0
- package/dist/menu/index.d.mts.map +1 -1
- package/dist/menu/index.mjs +2 -0
- package/dist/menu/index.mjs.map +1 -1
- package/dist/menu/menu-checkbox-item.d.mts +26 -2
- package/dist/menu/menu-checkbox-item.d.mts.map +1 -1
- package/dist/menu/menu-checkbox-item.mjs +2 -0
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +24 -2
- package/dist/menu/menu-context-trigger.d.mts.map +1 -1
- package/dist/menu/menu-context-trigger.mjs +2 -0
- package/dist/menu/menu-context-trigger.mjs.map +1 -1
- package/dist/menu/menu-group.d.mts +36 -1
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +9 -1
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-item.d.mts +23 -1
- package/dist/menu/menu-item.d.mts.map +1 -1
- package/dist/menu/menu-item.mjs +2 -0
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-popup.d.mts +33 -8
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +2 -0
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.d.mts +20 -1
- package/dist/menu/menu-radio-group.d.mts.map +1 -1
- package/dist/menu/menu-radio-group.mjs +2 -0
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.d.mts +16 -0
- package/dist/menu/menu-radio-item.d.mts.map +1 -1
- package/dist/menu/menu-radio-item.mjs +2 -0
- package/dist/menu/menu-radio-item.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +22 -3
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +2 -0
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts +13 -0
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +2 -0
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +15 -0
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +2 -0
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/meter/index.d.mts +2 -0
- package/dist/meter/index.d.mts.map +1 -1
- package/dist/meter/index.mjs +2 -0
- package/dist/meter/index.mjs.map +1 -1
- package/dist/meter/meter-indicator.d.mts +11 -0
- package/dist/meter/meter-indicator.d.mts.map +1 -1
- package/dist/meter/meter-indicator.mjs +2 -0
- package/dist/meter/meter-indicator.mjs.map +1 -1
- package/dist/meter/meter-label.d.mts +11 -0
- package/dist/meter/meter-label.d.mts.map +1 -1
- package/dist/meter/meter-label.mjs +2 -0
- package/dist/meter/meter-label.mjs.map +1 -1
- package/dist/meter/meter-region.d.mts +5 -0
- package/dist/meter/meter-region.d.mts.map +1 -1
- package/dist/meter/meter-region.mjs.map +1 -1
- package/dist/meter/meter-root.d.mts +52 -10
- package/dist/meter/meter-root.d.mts.map +1 -1
- package/dist/meter/meter-root.mjs +2 -0
- package/dist/meter/meter-root.mjs.map +1 -1
- package/dist/meter/meter-track.d.mts +11 -0
- package/dist/meter/meter-track.d.mts.map +1 -1
- package/dist/meter/meter-track.mjs +2 -0
- package/dist/meter/meter-track.mjs.map +1 -1
- package/dist/meter/meter-value.d.mts +15 -1
- package/dist/meter/meter-value.d.mts.map +1 -1
- package/dist/meter/meter-value.mjs +2 -0
- package/dist/meter/meter-value.mjs.map +1 -1
- package/dist/number-field/index.d.mts +2 -0
- package/dist/number-field/index.d.mts.map +1 -1
- package/dist/number-field/index.mjs +2 -0
- package/dist/number-field/index.mjs.map +1 -1
- package/dist/number-field/number-field-decrement.d.mts +2 -0
- package/dist/number-field/number-field-decrement.d.mts.map +1 -1
- package/dist/number-field/number-field-decrement.mjs +2 -0
- package/dist/number-field/number-field-decrement.mjs.map +1 -1
- package/dist/number-field/number-field-increment.d.mts +2 -0
- package/dist/number-field/number-field-increment.d.mts.map +1 -1
- package/dist/number-field/number-field-increment.mjs +2 -0
- package/dist/number-field/number-field-increment.mjs.map +1 -1
- package/dist/number-field/number-field-input.d.mts +9 -0
- package/dist/number-field/number-field-input.d.mts.map +1 -1
- package/dist/number-field/number-field-input.mjs +2 -0
- package/dist/number-field/number-field-input.mjs.map +1 -1
- package/dist/number-field/number-field-label.d.mts +10 -0
- package/dist/number-field/number-field-label.d.mts.map +1 -1
- package/dist/number-field/number-field-label.mjs +2 -0
- package/dist/number-field/number-field-label.mjs.map +1 -1
- package/dist/number-field/number-field-root.d.mts +62 -14
- package/dist/number-field/number-field-root.d.mts.map +1 -1
- package/dist/number-field/number-field-root.mjs +2 -0
- package/dist/number-field/number-field-root.mjs.map +1 -1
- package/dist/number-field/use-step-button.d.mts +20 -0
- package/dist/number-field/use-step-button.d.mts.map +1 -1
- package/dist/number-field/use-step-button.mjs.map +1 -1
- package/dist/popover/index.d.mts +2 -0
- package/dist/popover/index.d.mts.map +1 -1
- package/dist/popover/index.mjs +2 -0
- package/dist/popover/index.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts +18 -0
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +2 -0
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-description.d.mts +12 -0
- package/dist/popover/popover-description.d.mts.map +1 -1
- package/dist/popover/popover-description.mjs +2 -0
- package/dist/popover/popover-description.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +30 -4
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +2 -0
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.d.mts +9 -0
- package/dist/popover/popover-root.d.mts.map +1 -1
- package/dist/popover/popover-root.mjs +2 -0
- package/dist/popover/popover-root.mjs.map +1 -1
- package/dist/popover/popover-title.d.mts +11 -0
- package/dist/popover/popover-title.d.mts.map +1 -1
- package/dist/popover/popover-title.mjs +2 -0
- package/dist/popover/popover-title.mjs.map +1 -1
- package/dist/popover/popover-trigger.d.mts +15 -0
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +2 -0
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/index.d.mts +2 -0
- package/dist/progress/index.d.mts.map +1 -1
- package/dist/progress/index.mjs +2 -0
- package/dist/progress/index.mjs.map +1 -1
- package/dist/progress/progress-indicator.d.mts +11 -0
- package/dist/progress/progress-indicator.d.mts.map +1 -1
- package/dist/progress/progress-indicator.mjs +2 -0
- package/dist/progress/progress-indicator.mjs.map +1 -1
- package/dist/progress/progress-label.d.mts +11 -0
- package/dist/progress/progress-label.d.mts.map +1 -1
- package/dist/progress/progress-label.mjs +2 -0
- package/dist/progress/progress-label.mjs.map +1 -1
- package/dist/progress/progress-root.d.mts +36 -8
- package/dist/progress/progress-root.d.mts.map +1 -1
- package/dist/progress/progress-root.mjs +2 -0
- package/dist/progress/progress-root.mjs.map +1 -1
- package/dist/progress/progress-track.d.mts +11 -0
- package/dist/progress/progress-track.d.mts.map +1 -1
- package/dist/progress/progress-track.mjs +2 -0
- package/dist/progress/progress-track.mjs.map +1 -1
- package/dist/progress/progress-value.d.mts +15 -1
- package/dist/progress/progress-value.d.mts.map +1 -1
- package/dist/progress/progress-value.mjs +2 -0
- package/dist/progress/progress-value.mjs.map +1 -1
- package/dist/radio-group/index.d.mts +2 -0
- package/dist/radio-group/index.d.mts.map +1 -1
- package/dist/radio-group/index.mjs +2 -0
- package/dist/radio-group/index.mjs.map +1 -1
- package/dist/radio-group/radio-group-item.d.mts +18 -1
- package/dist/radio-group/radio-group-item.d.mts.map +1 -1
- package/dist/radio-group/radio-group-item.mjs +2 -0
- package/dist/radio-group/radio-group-item.mjs.map +1 -1
- package/dist/radio-group/radio-group-label.d.mts +10 -0
- package/dist/radio-group/radio-group-label.d.mts.map +1 -1
- package/dist/radio-group/radio-group-label.mjs +2 -0
- package/dist/radio-group/radio-group-label.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +29 -5
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +2 -0
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/index.d.mts +2 -0
- package/dist/select/index.d.mts.map +1 -1
- package/dist/select/index.mjs +2 -0
- package/dist/select/index.mjs.map +1 -1
- package/dist/select/select-group-label.d.mts +10 -0
- package/dist/select/select-group-label.d.mts.map +1 -1
- package/dist/select/select-group-label.mjs +2 -0
- package/dist/select/select-group-label.mjs.map +1 -1
- package/dist/select/select-group.d.mts +15 -1
- package/dist/select/select-group.d.mts.map +1 -1
- package/dist/select/select-group.mjs +2 -0
- package/dist/select/select-group.mjs.map +1 -1
- package/dist/select/select-option.d.mts +19 -1
- package/dist/select/select-option.d.mts.map +1 -1
- package/dist/select/select-option.mjs +2 -0
- package/dist/select/select-option.mjs.map +1 -1
- package/dist/select/select-root.d.mts +24 -1
- package/dist/select/select-root.d.mts.map +1 -1
- package/dist/select/select-root.mjs +2 -0
- package/dist/select/select-root.mjs.map +1 -1
- package/dist/select/select-separator.d.mts +9 -0
- package/dist/select/select-separator.d.mts.map +1 -1
- package/dist/select/select-separator.mjs +2 -0
- package/dist/select/select-separator.mjs.map +1 -1
- package/dist/select/select-trigger.d.mts +9 -0
- package/dist/select/select-trigger.d.mts.map +1 -1
- package/dist/select/select-trigger.mjs +2 -0
- package/dist/select/select-trigger.mjs.map +1 -1
- package/dist/select/select-value.d.mts +9 -0
- package/dist/select/select-value.d.mts.map +1 -1
- package/dist/select/select-value.mjs +2 -0
- package/dist/select/select-value.mjs.map +1 -1
- package/dist/slider/index.d.mts +2 -0
- package/dist/slider/index.d.mts.map +1 -1
- package/dist/slider/index.mjs +2 -0
- package/dist/slider/index.mjs.map +1 -1
- package/dist/slider/slider-indicator.d.mts +12 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -1
- package/dist/slider/slider-indicator.mjs +2 -0
- package/dist/slider/slider-indicator.mjs.map +1 -1
- package/dist/slider/slider-label.d.mts +11 -1
- package/dist/slider/slider-label.d.mts.map +1 -1
- package/dist/slider/slider-label.mjs +2 -0
- package/dist/slider/slider-label.mjs.map +1 -1
- package/dist/slider/slider-root.d.mts +53 -9
- package/dist/slider/slider-root.d.mts.map +1 -1
- package/dist/slider/slider-root.mjs +2 -0
- package/dist/slider/slider-root.mjs.map +1 -1
- package/dist/slider/slider-thumb.d.mts +32 -3
- package/dist/slider/slider-thumb.d.mts.map +1 -1
- package/dist/slider/slider-thumb.mjs +2 -0
- package/dist/slider/slider-thumb.mjs.map +1 -1
- package/dist/slider/slider-track.d.mts +17 -0
- package/dist/slider/slider-track.d.mts.map +1 -1
- package/dist/slider/slider-track.mjs +2 -0
- package/dist/slider/slider-track.mjs.map +1 -1
- package/dist/slider/slider-value.d.mts +11 -0
- package/dist/slider/slider-value.d.mts.map +1 -1
- package/dist/slider/slider-value.mjs +2 -0
- package/dist/slider/slider-value.mjs.map +1 -1
- package/dist/switch/switch.d.mts +23 -3
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +2 -0
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/index.d.mts +2 -0
- package/dist/tabs/index.d.mts.map +1 -1
- package/dist/tabs/index.mjs +2 -0
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/tabs/tabs-context.d.mts +5 -0
- package/dist/tabs/tabs-context.d.mts.map +1 -1
- package/dist/tabs/tabs-context.mjs.map +1 -1
- package/dist/tabs/tabs-indicator.d.mts +17 -0
- package/dist/tabs/tabs-indicator.d.mts.map +1 -1
- package/dist/tabs/tabs-indicator.mjs +2 -0
- package/dist/tabs/tabs-indicator.mjs.map +1 -1
- package/dist/tabs/tabs-list.d.mts +19 -1
- package/dist/tabs/tabs-list.d.mts.map +1 -1
- package/dist/tabs/tabs-list.mjs +2 -0
- package/dist/tabs/tabs-list.mjs.map +1 -1
- package/dist/tabs/tabs-panel.d.mts +19 -0
- package/dist/tabs/tabs-panel.d.mts.map +1 -1
- package/dist/tabs/tabs-panel.mjs +2 -0
- package/dist/tabs/tabs-panel.mjs.map +1 -1
- package/dist/tabs/tabs-root.d.mts +39 -5
- package/dist/tabs/tabs-root.d.mts.map +1 -1
- package/dist/tabs/tabs-root.mjs +2 -0
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.d.mts +22 -1
- package/dist/tabs/tabs-tab.d.mts.map +1 -1
- package/dist/tabs/tabs-tab.mjs +2 -0
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/index.d.mts +2 -0
- package/dist/toast/index.d.mts.map +1 -1
- package/dist/toast/index.mjs +2 -0
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toast/toast-action.d.mts +28 -3
- package/dist/toast/toast-action.d.mts.map +1 -1
- package/dist/toast/toast-action.mjs +2 -0
- package/dist/toast/toast-action.mjs.map +1 -1
- package/dist/toast/toast-close.d.mts +16 -0
- package/dist/toast/toast-close.d.mts.map +1 -1
- package/dist/toast/toast-close.mjs +2 -0
- package/dist/toast/toast-close.mjs.map +1 -1
- package/dist/toast/toast-description.d.mts +16 -1
- package/dist/toast/toast-description.d.mts.map +1 -1
- package/dist/toast/toast-description.mjs +2 -0
- package/dist/toast/toast-description.mjs.map +1 -1
- package/dist/toast/toast-root.d.mts +20 -0
- package/dist/toast/toast-root.d.mts.map +1 -1
- package/dist/toast/toast-root.mjs +2 -0
- package/dist/toast/toast-root.mjs.map +1 -1
- package/dist/toast/toast-title.d.mts +15 -1
- package/dist/toast/toast-title.d.mts.map +1 -1
- package/dist/toast/toast-title.mjs +2 -0
- package/dist/toast/toast-title.mjs.map +1 -1
- package/dist/toast/toast-viewport.d.mts +34 -5
- package/dist/toast/toast-viewport.d.mts.map +1 -1
- package/dist/toast/toast-viewport.mjs +2 -0
- package/dist/toast/toast-viewport.mjs.map +1 -1
- package/dist/toast/toast.d.mts +46 -6
- package/dist/toast/toast.d.mts.map +1 -1
- package/dist/toast/toast.mjs +4 -0
- package/dist/toast/toast.mjs.map +1 -1
- package/dist/toggle/toggle.d.mts +20 -2
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +2 -0
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/index.d.mts +2 -0
- package/dist/toggle-group/index.d.mts.map +1 -1
- package/dist/toggle-group/index.mjs +2 -0
- package/dist/toggle-group/index.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-context.d.mts +1 -0
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-item.d.mts +16 -0
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-item.mjs +2 -0
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-root.d.mts +73 -12
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-root.mjs +2 -0
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
- package/dist/toolbar/index.d.mts +2 -0
- package/dist/toolbar/index.d.mts.map +1 -1
- package/dist/toolbar/index.mjs +2 -0
- package/dist/toolbar/index.mjs.map +1 -1
- package/dist/toolbar/toolbar-root.d.mts +30 -3
- package/dist/toolbar/toolbar-root.d.mts.map +1 -1
- package/dist/toolbar/toolbar-root.mjs +2 -0
- package/dist/toolbar/toolbar-root.mjs.map +1 -1
- package/dist/toolbar/toolbar-separator.d.mts +13 -0
- package/dist/toolbar/toolbar-separator.d.mts.map +1 -1
- package/dist/toolbar/toolbar-separator.mjs +2 -0
- package/dist/toolbar/toolbar-separator.mjs.map +1 -1
- package/dist/tooltip/index.d.mts +2 -0
- package/dist/tooltip/index.d.mts.map +1 -1
- package/dist/tooltip/index.mjs +2 -0
- package/dist/tooltip/index.mjs.map +1 -1
- package/dist/tooltip/tooltip-arrow.d.mts +16 -0
- package/dist/tooltip/tooltip-arrow.d.mts.map +1 -1
- package/dist/tooltip/tooltip-arrow.mjs +2 -0
- package/dist/tooltip/tooltip-arrow.mjs.map +1 -1
- package/dist/tooltip/tooltip-context.d.mts +4 -0
- package/dist/tooltip/tooltip-context.d.mts.map +1 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts +24 -3
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +2 -0
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.d.mts +24 -2
- package/dist/tooltip/tooltip-root.d.mts.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +2 -0
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +18 -1
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +2 -0
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/package.json +9 -1
- package/skills/funstack-ui-knowledge/SKILL.md +75 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# Action props
|
|
2
|
+
|
|
3
|
+
FUNSTACK UI has no `onClick`, `onChange` or `onValueChange`, with [one exception, below](#urgent-lane). Interactive props are _actions_: callbacks that the component runs inside its own transition and awaits.
|
|
4
|
+
|
|
5
|
+
An <a id="action"></a>action is a function prop that the component calls when the user (or the browser) asks for something, inside a React transition the component starts for it. To dispatch is to start that transition and call the action once; every click, key press or platform change that asks for a change is one dispatch. A transition is React's way to mark an update as non-urgent, so it can keep the current UI on screen while the update is prepared (see [Transitions & ViewTransition](transitions.md)).
|
|
6
|
+
|
|
7
|
+
## Terms
|
|
8
|
+
|
|
9
|
+
- **Settle**: An action settles when its promise resolves or rejects (a synchronous action settles when it returns). `data-pending` stays on until the settle and the render it causes have committed.
|
|
10
|
+
- **<a id="adopt"></a>Adopt**: A controlled parent adopts a dispatched value by setting its controlled prop to it (in the synchronous part of the action, or inside `startTransition` after an `await`).
|
|
11
|
+
- **Veto**: A controlled parent refuses a change by not adopting the value: when the action settles, the optimistic value snaps back to the committed one. Only library-owned changes can be vetoed; a [dismissal](browser-owned-state.md#dismissal) cannot.
|
|
12
|
+
- **<a id="form-channel"></a>Form channel**: React's own form machinery: `<form action>`, `useFormStatus`, `useActionState` and the automatic reset after a successful action. Independent of a control's change action; see [Form actions are a separate channel](#form-actions).
|
|
13
|
+
|
|
14
|
+
## Naming
|
|
15
|
+
|
|
16
|
+
A controllable state `x` always comes as a triple: `x` (controlled), `defaultX` (uncontrolled initial value) and `xChangeAction`.
|
|
17
|
+
|
|
18
|
+
Example: [Toggle](../components/toggle.md)
|
|
19
|
+
|
|
20
|
+
A Toggle's state is `pressed`, so its props are `pressed`, `defaultPressed` and `pressedChangeAction`. Each component page lists its own triple in its props table.
|
|
21
|
+
|
|
22
|
+
A part that performs one task rather than changing a state (a [pure trigger](pending-and-optimistic.md#pure-trigger)) takes a plain `action` (`Dialog.Close action`: run this, then close). A state that the consumer derives and the library only mirrors is a controlled-only prop with no default and no action (`Checkbox indeterminate`).
|
|
23
|
+
|
|
24
|
+
`undefined` always means "uncontrolled"; "nothing selected" is `null`. Switching between controlled and uncontrolled after mount is not supported (development warning).
|
|
25
|
+
|
|
26
|
+
## Signature
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
type Action<Args extends readonly unknown[] = []> = (...args: Args) => unknown;
|
|
30
|
+
|
|
31
|
+
interface ActionDetails {
|
|
32
|
+
/** The DOM event that caused the action, or undefined. */
|
|
33
|
+
readonly event: Event | undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type ChangeAction<T, Details extends ActionDetails = ActionDetails> =
|
|
37
|
+
Action<[next: T, details: Details]>;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The first argument is the next value, so the common case stays short. The second is a `details` object with the native DOM event (not React's synthetic one) and any component-specific fields, such as `reason` (below) or Dialog's `returnValue`. The return type is `unknown`: return a promise and the component awaits it, return anything else and it is ignored. That means a function that returns data (a Server Function, a `fetch`) type-checks without wrapping.
|
|
41
|
+
|
|
42
|
+
Example: [Toggle](../components/toggle.md)
|
|
43
|
+
|
|
44
|
+
A change action that returns data, and (on [Tabs](../components/tabs.md)) one that returns nothing:
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
<Toggle pressedChangeAction={(pressed) => api.setFavorite(id, pressed)}>Favorite</Toggle>
|
|
48
|
+
<Tabs.Root defaultValue="general" valueChangeAction={(tab) => analytics.track(tab)}>...</Tabs.Root>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## `details.reason`
|
|
52
|
+
|
|
53
|
+
Components that can change for more than one reason say why, with one library-wide vocabulary (the public type `ChangeReason`):
|
|
54
|
+
|
|
55
|
+
| reason | Meaning | details.event |
|
|
56
|
+
| - | - | - |
|
|
57
|
+
| `"activate"` | The user acted on one of the component's parts: a click, Enter or Space, focus in automatic activation, a Close button or a form submit. | The native `click`, `keydown` or `focusin` event. For checkboxes and radios always the `click`, including Space and arrow keys. |
|
|
58
|
+
| `"platform"` | The browser changed the state by itself: find-in-page, a form reset, or an interaction before hydration found on mount. Never a direct user interaction (a click, key press or touch). | The platform event (`beforematch`, `toggle`, `reset`), or `undefined` on mount. |
|
|
59
|
+
| `"dismiss"` | The user closed the component without one of its parts: Escape, Android back, an assistive-technology dismiss, a click outside. Also a [Toast](../components/toast.md)'s Close part, which only means "go away". | The platform's `close` event; for Toast the click or keydown. |
|
|
60
|
+
| `"timeout"` | The library's own timer closed the component: a [Toast](../components/toast.md) whose `duration` elapsed. No user interaction, no platform event. | `undefined` |
|
|
61
|
+
|
|
62
|
+
A component uses only the reasons that can happen to it; its page lists them in the description of its change action. A `"platform"` dispatch goes through the same action as a user one, so a controlled parent hears about a form reset and decides whether to adopt it. See [Browser-owned state](browser-owned-state.md).
|
|
63
|
+
|
|
64
|
+
## What happens on a click
|
|
65
|
+
|
|
66
|
+
In one transition of its own, the component tags the transition with its [transition types](transitions.md#transition-types), sets the [optimistic value](pending-and-optimistic.md#optimistic), awaits your action, and, when it is uncontrolled and this is still the latest dispatch, commits the new value.
|
|
67
|
+
|
|
68
|
+
Example: [Toggle](../components/toggle.md)
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
startTransition(async () => {
|
|
72
|
+
addTransitionType("fsui-toggle"); // plus fsui-toggle-press / -release
|
|
73
|
+
setOptimistic(next); // the button flips immediately
|
|
74
|
+
await pressedChangeAction?.(next, details);
|
|
75
|
+
// uncontrolled: commit `next` now, if this is still the latest dispatch
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
What you can rely on:
|
|
80
|
+
|
|
81
|
+
- **Sync or async.** The action is awaited; `data-pending` stays on until the promise settles _and_ the resulting render has committed (including a Suspense wait).
|
|
82
|
+
- **The synchronous part runs during the event.** `details.event.preventDefault()` works there, and a `setState` there is a transition update.
|
|
83
|
+
- **Disabled parts never dispatch** for user interaction, and no-op interactions (clicking the tab that is already selected) do not dispatch either. (A form reset still reaches a disabled native input: the browser resets disabled inputs too, and the form's author asked for it.)
|
|
84
|
+
- **Parts are never natively disabled while pending.** A trigger that changes state sets `data-pending` and takes every click: a second click is a new intent (below). A [pure trigger](pending-and-optimistic.md#pure-trigger) ignores a second activation while its own action is pending and is `aria-disabled="true"` meanwhile, so a double click never runs a save twice (see [A second click while pending](pending-and-optimistic.md#second-click)).
|
|
85
|
+
|
|
86
|
+
## After an `await`, wrap state updates yourself
|
|
87
|
+
|
|
88
|
+
This is a React rule, and the library cannot hide it: a `setState` that runs after your own `await` is no longer part of the transition. Wrap it in `startTransition`.
|
|
89
|
+
|
|
90
|
+
Example: [Tabs](../components/tabs.md)
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
// Controlled, local state: set it in the synchronous part.
|
|
94
|
+
<Tabs.Root value={tab} valueChangeAction={(next) => { setTab(next); }}>
|
|
95
|
+
|
|
96
|
+
// Controlled, server-backed: adopt the value on success, re-wrapped after the await.
|
|
97
|
+
<Tabs.Root
|
|
98
|
+
value={tab}
|
|
99
|
+
valueChangeAction={async (next) => {
|
|
100
|
+
await saveTab(next);
|
|
101
|
+
startTransition(() => setTab(next));
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## <a id="await-only"></a>Await only what the UI must wait for
|
|
107
|
+
|
|
108
|
+
While an async action is pending, React holds _every_ transition in the app that started meanwhile and commits them together. A two-second awaited save in one Toggle also delays a router navigation. Background work that the UI need not wait for should not be returned:
|
|
109
|
+
|
|
110
|
+
Example: [Tabs](../components/tabs.md)
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
// The panel switches immediately; the save runs in the background.
|
|
114
|
+
valueChangeAction={(next) => { void saveSelection(next); }}
|
|
115
|
+
|
|
116
|
+
// The panel switches when the save succeeds; the tab shows pending meanwhile.
|
|
117
|
+
valueChangeAction={async (next) => { await saveSelection(next); }}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Errors go to Error Boundaries
|
|
121
|
+
|
|
122
|
+
An action that throws or rejects reaches the nearest Error Boundary above the component that owns the transition (the [state owner](pending-and-optimistic.md#state-owner): usually the `Root`, or a single-element component such as a Toggle). The library never swallows an error. The optimistic state reverts automatically, and uncontrolled state is only written after success, so a failed action leaves it untouched.
|
|
123
|
+
|
|
124
|
+
For inline error UI instead, catch inside the action. A caught error makes the action resolve, which counts as success: in uncontrolled mode the new value is committed. Use controlled mode when the parent must be able to veto.
|
|
125
|
+
|
|
126
|
+
Example: [Toggle](../components/toggle.md)
|
|
127
|
+
|
|
128
|
+
The left Toggle catches its errors inline; the right one lets them reach a boundary.
|
|
129
|
+
|
|
130
|
+
```tsx title="ToggleErrors.tsx"
|
|
131
|
+
"use client";
|
|
132
|
+
import { startTransition, useRef, useState } from "react";
|
|
133
|
+
import { Toggle } from "@funstack/ui/toggle";
|
|
134
|
+
import { DemoErrorBoundary } from "./DemoErrorBoundary.js";
|
|
135
|
+
import { fakeSave } from "./fake-api.js";
|
|
136
|
+
|
|
137
|
+
// Two ways to handle a failing action.
|
|
138
|
+
export function ToggleErrors() {
|
|
139
|
+
return (
|
|
140
|
+
<div className="demo-row">
|
|
141
|
+
<ControlledWithInlineError />
|
|
142
|
+
<DemoErrorBoundary>
|
|
143
|
+
<Toggle
|
|
144
|
+
className="demo-toggle"
|
|
145
|
+
pressedChangeAction={(next) => fakeSave(`notify=${next}`, { fail: true })}
|
|
146
|
+
>
|
|
147
|
+
{({ pending }) => (
|
|
148
|
+
<>{pending && <span className="demo-spinner" aria-hidden />}Notify me</>
|
|
149
|
+
)}
|
|
150
|
+
</Toggle>
|
|
151
|
+
</DemoErrorBoundary>
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Controlled, "update on success": the parent adopts the value only after the save succeeds.
|
|
157
|
+
// Every second save fails; the error is caught inside the action, so the Toggle snaps back.
|
|
158
|
+
function ControlledWithInlineError() {
|
|
159
|
+
const [pinned, setPinned] = useState(false);
|
|
160
|
+
const [error, setError] = useState<string | null>(null);
|
|
161
|
+
const saves = useRef(0);
|
|
162
|
+
return (
|
|
163
|
+
<span>
|
|
164
|
+
<Toggle
|
|
165
|
+
className="demo-toggle"
|
|
166
|
+
pressed={pinned}
|
|
167
|
+
pressedChangeAction={async (next) => {
|
|
168
|
+
setError(null); // sync prefix: already a Transition update
|
|
169
|
+
try {
|
|
170
|
+
await fakeSave(`pinned=${next}`, { fail: ++saves.current % 2 === 0 });
|
|
171
|
+
// After an await, wrap state updates in startTransition yourself.
|
|
172
|
+
startTransition(() => setPinned(next));
|
|
173
|
+
} catch (e) {
|
|
174
|
+
startTransition(() => setError(e instanceof Error ? e.message : String(e)));
|
|
175
|
+
}
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
{({ pending }) => <>{pending && <span className="demo-spinner" aria-hidden />}Pin</>}
|
|
179
|
+
</Toggle>
|
|
180
|
+
{error && <span className="demo-inline-error"> {error}</span>}
|
|
181
|
+
</span>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## <a id="overlapping-actions"></a>Overlapping actions: the latest intent wins
|
|
187
|
+
|
|
188
|
+
React neither cancels nor orders overlapping transitions: two actions started one after the other run at the same time, and either may finish first. The components handle this: the optimistic state always shows the most recent click, and uncontrolled state is committed only for the most recently dispatched action, even if an older one resolves later. The components have no queue and no abort signal; if you need to cancel a request, keep an `AbortController` in a ref inside your action.
|
|
189
|
+
|
|
190
|
+
If your actions must run in order, one after another, or each must build on the result of the one before (reducer-style accumulation), use React's [`useActionState`](https://react.dev/reference/react/useActionState) and call its dispatch function from the component's action. React queues those calls and runs them sequentially, passing each the state the previous one returned. Drive the component in controlled mode from that state:
|
|
191
|
+
|
|
192
|
+
Example: [Toggle](../components/toggle.md)
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
const [pressed, dispatch] = useActionState(async (_previous: boolean, next: boolean) => {
|
|
196
|
+
await api.setFavorite(id, next); // runs only after the previous call has finished
|
|
197
|
+
return next;
|
|
198
|
+
}, initial);
|
|
199
|
+
|
|
200
|
+
<Toggle pressed={pressed} pressedChangeAction={(next) => dispatch(next)}>Favorite</Toggle>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The component stays pending and keeps showing the latest optimistic value until the queue has drained. React's rules for the queue apply: when one call throws, React skips the calls still queued behind it and the error goes to the nearest Error Boundary above the component that called `useActionState`.
|
|
204
|
+
|
|
205
|
+
React would silently drop the rejection of a superseded (older) action. The library catches it and rethrows it from render, so it still reaches the same Error Boundary as a failure of the latest action.
|
|
206
|
+
|
|
207
|
+
## Server Functions work directly
|
|
208
|
+
|
|
209
|
+
A Server Function (`"use server"`) can be passed straight to any action prop, from a Server Component or a Client Component. `details` is a plain object of serialisable fields; `event` is served by a proxy and is not an own property, so React's serialiser never sees it. The server receives `(next, details)` with `details.event` undefined and every other field intact.
|
|
210
|
+
|
|
211
|
+
Example: [Toggle](../components/toggle.md)
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
// app/post.tsx: a Server Component
|
|
215
|
+
import { Toggle } from "@funstack/ui/toggle";
|
|
216
|
+
import { setFavorite } from "./actions"; // "use server"
|
|
217
|
+
|
|
218
|
+
<Toggle defaultPressed={post.favorited} pressedChangeAction={setFavorite.bind(null, post.id)}>
|
|
219
|
+
Favorite
|
|
220
|
+
</Toggle>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
> **Costs of the virtual event**
|
|
224
|
+
>
|
|
225
|
+
> `Object.keys(details)`, spreading and `JSON.stringify` do not include `event`; `"event" in details` and `details.event` do. `structuredClone(details)` throws. In tests, assert `details.event` directly rather than `toEqual({ event })`.
|
|
226
|
+
|
|
227
|
+
## <a id="form-actions"></a>Form actions are a separate channel
|
|
228
|
+
|
|
229
|
+
`<form action>`, `useFormStatus` and React's automatic form reset are React's form channel. A control's change action is per control and runs in the control's own transition. The two are independent:
|
|
230
|
+
|
|
231
|
+
- A native form control (a Switch, for example) inside `<form action={serverFn}>` needs no change action: with a `name` it posts its value like any native input, and `useFormStatus().pending` covers the submit.
|
|
232
|
+
- A control never folds `useFormStatus` into its own `pending`: that would mark every control in the form pending during a submit. Read `useFormStatus` in your own `className` function, or style `form:has(...)`.
|
|
233
|
+
- "Autosave on change" is `checkedChangeAction={saveSetting}`; "submit on change" is `checkedChangeAction={() => formRef.current?.requestSubmit()}`.
|
|
234
|
+
- A part may observe the form channel for a platform side effect: `Dialog.Form` closes its dialog once the form action has settled. It never wraps your action, so a Server Function keeps React's progressive enhancement.
|
|
235
|
+
- While a form action is pending, a control's transition waits for it, and the reverse: React commits them together.
|
|
236
|
+
|
|
237
|
+
## <a id="urgent-lane"></a>The urgent lane
|
|
238
|
+
|
|
239
|
+
One kind of state cannot be a transition: the text of a controlled text input, which React must update in the same event as the keystroke. Such a state keeps the `x` / `defaultX` pair (`inputValue` / `defaultInputValue` on [Combobox](../components/combobox.md)), but its callback is a handler, not an action: `onInputValueChange`, typed:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
/** Called synchronously, outside any Transition, and not awaited. */
|
|
243
|
+
type UrgentChangeHandler<T, Details extends ActionDetails = ActionDetails> =
|
|
244
|
+
(next: T, details: Details) => void;
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Nothing is pending or optimistic for it: the DOM already holds the value when it runs, so `(next) => setText(next)` is the whole controlled pattern. Everything the urgent value drives leaves the urgent lane at once (a deferred query, an open, a selection). A returned promise is ignored and warned about in development. It is the library's one `on*` prop, and it is one on purpose: `fooAction` always means a handler the component runs in a transition, so a callback that must not run in one is named like the plain React handler it is. Nothing else the library defines is an `on*`prop.
|
|
248
|
+
|
|
249
|
+
## What about native handlers?
|
|
250
|
+
|
|
251
|
+
DOM event props that a part does not use itself pass through to the element (an `onPointerEnter` on a Tab, an `onClick` on a Tooltip trigger). They are the platform's API, not the library's. Handlers the part does install (for example `onClick` on a Toggle) are removed from its props type so they cannot be clobbered by accident.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Using with AI agents
|
|
2
|
+
|
|
3
|
+
FUNSTACK UI's API differs from other headless libraries: action props instead of `onChange`, `render` instead of `asChild`, transitions you do not start yourself. An agent that guesses from other libraries gets these wrong. Give it the documentation instead.
|
|
4
|
+
|
|
5
|
+
## Install the agent skill
|
|
6
|
+
|
|
7
|
+
An [agent skill](https://agentskills.io) is a Markdown file that an agent loads when a task needs it. `@funstack/ui` ships one, named `funstack-ui-knowledge`, and an installer that copies it into your project. Run it in your project's root, with `@funstack/ui` installed:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx -p @funstack/ui@alpha funstack-ui-skill-installer
|
|
11
|
+
# or
|
|
12
|
+
pnpm dlx --package @funstack/ui@alpha funstack-ui-skill-installer
|
|
13
|
+
# or
|
|
14
|
+
yarn dlx -p @funstack/ui@alpha funstack-ui-skill-installer
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The installer asks which agent you use (Claude Code, Codex, GitHub Copilot, Cursor and others, or a custom path) and copies the skill into that agent's skills directory, for example `.claude/skills/funstack-ui-knowledge/`. In a script or CI, where there is no terminal to ask in, it reads the target directory from `SKILL_INSTALL_PATH` instead:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
SKILL_INSTALL_PATH=./.claude/skills npx -p @funstack/ui@alpha funstack-ui-skill-installer
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
In an interactive terminal the variable is ignored and the prompt appears; add `< /dev/null` to the command to use the variable there.
|
|
24
|
+
|
|
25
|
+
The skill is short, so the agent can load it whole. It contains:
|
|
26
|
+
|
|
27
|
+
- The mental model: action props, optimistic and pending state, Suspense, transitions.
|
|
28
|
+
- The mistakes agents make most often, such as writing `onValueChange` or wrapping actions in `startTransition`.
|
|
29
|
+
- A one-line index of every component, with its import path and parts.
|
|
30
|
+
- A pointer to the full documentation bundled in the package (below).
|
|
31
|
+
|
|
32
|
+
Re-run the installer after upgrading `@funstack/ui` to update the skill. Commit the copied files if your team shares the agent setup.
|
|
33
|
+
|
|
34
|
+
## Docs in the package
|
|
35
|
+
|
|
36
|
+
The npm package contains this whole site as Markdown, matching the installed version. The skill points the agent at its index:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
node_modules/@funstack/ui/dist/docs/index.md
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
You can also point an agent at this file directly, without the skill. Because it comes from the installed package, it does not drift from the code the agent is writing against.
|
|
43
|
+
|
|
44
|
+
## Docs on the web
|
|
45
|
+
|
|
46
|
+
The same Markdown is published on this site:
|
|
47
|
+
|
|
48
|
+
| URL | Contents |
|
|
49
|
+
| - | - |
|
|
50
|
+
| `https://ui.funstack.work/llms.txt` | An index of every page with a one-line description, in the [llms.txt](https://llmstxt.org) format. |
|
|
51
|
+
| `https://ui.funstack.work/llms-full.txt` | Every page in one file, in sidebar order. |
|
|
52
|
+
| Any page URL plus `.md` | That page as Markdown, for example `https://ui.funstack.work/components/dialog.md`. |
|
|
53
|
+
|
|
54
|
+
> **Which version?**
|
|
55
|
+
>
|
|
56
|
+
> The site documents the latest release. If your project pins an older alpha, prefer the docs in `node_modules`.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Browser-owned state
|
|
2
|
+
|
|
3
|
+
"Transition by default" is about state the library owns. Some state belongs to the browser, which changes it before React hears about it. FUNSTACK UI prefers that state whenever the platform offers it, because it is the only way a component can work without JavaScript.
|
|
4
|
+
|
|
5
|
+
## Terms
|
|
6
|
+
|
|
7
|
+
- **Library-owned state**: State held in React and changed only by the library, usually inside the [state owner](pending-and-optimistic.md#state-owner)'s transition after the user acts on a [trigger](pending-and-optimistic.md#trigger). Some library-owned state is urgent instead (typed text, a toast queue): still the library's, but not a transition.
|
|
8
|
+
- **Browser-owned state**: State held in the DOM and changed by the browser itself: whether a `<details>` is open, whether a popover is in the top layer (the layer the browser draws above the whole page), whether a dialog is shown. The library reads it; it does not keep a copy in React state.
|
|
9
|
+
- **<a id="dismissal"></a>Dismissal**: Closing something without one of its parts: Escape, the Android back gesture, an assistive-technology dismiss, a click outside, or another top-layer element opening (the Popover API calls the last two light dismiss).
|
|
10
|
+
- **<a id="invoker"></a>Invoker**: A button that names a popover or dialog by id, so that the browser itself opens or closes it on click, without JavaScript: through `popovertarget` (the Popover API) or through `commandfor` and `command` (Invoker Commands). A `<button>` or an `<input type="button">` / `<input type="reset">` can be one; a disabled button and a submit button inside a form are not. See [Triggers of a popup](#popup-triggers).
|
|
11
|
+
- **<a id="foreign-invoker"></a>Foreign invoker**: An invoker of your own that targets a component's popup or dialog, but is not one of the component's parts.
|
|
12
|
+
- **<a id="platform-path"></a>Platform path**: A change the browser makes to library-owned state on its own, without a click the library sees: a form reset, find-in-page opening an item, a click before hydration. The component dispatches it like a user change, with `details.reason: "platform"`, and re-applies the committed state afterwards.
|
|
13
|
+
- **Notification**: A change action called after the browser has already made the change (a dismissal, a platform path). It is still awaited, but the UI did not wait for it: nothing can be vetoed, only re-applied.
|
|
14
|
+
- **<a id="parts-close"></a>A part's close**: A close the user asks one of the component's parts for (a Close button, the Trigger, a form submit). It is library-owned: dispatched in a transition, awaited, vetoable and animatable. The opposite of a dismissal.
|
|
15
|
+
- **<a id="js-free-mode"></a>JS-free mode and library mode**: Some components can run either way. In **JS-free mode** (no controlled or default state and no change action), the browser owns the state and the library adds no behaviour on the native path. In **library mode** (any of those props), the state is library-owned. See [Two modes](#two-modes).
|
|
16
|
+
|
|
17
|
+
## Two kinds of state
|
|
18
|
+
|
|
19
|
+
| | Library-owned | Browser-owned |
|
|
20
|
+
| - | - | - |
|
|
21
|
+
| Who changes it | the library, inside its transition | the browser (hover, light dismiss, Escape, find-in-page, a summary click, an [invoker](#invoker)) |
|
|
22
|
+
| Optimistic state | React state ([optimistic](pending-and-optimistic.md#optimistic), `useOptimistic`) | the DOM itself |
|
|
23
|
+
| Action prop | awaited; the UI waits for it | a notification after the fact, or none |
|
|
24
|
+
| Styling | `data-*` attributes | pseudo-classes: `:popover-open`, `:open` |
|
|
25
|
+
| Animation | `transition` prop (`<ViewTransition>`) | CSS: `@starting-style`, `transition-behavior: allow-discrete` |
|
|
26
|
+
|
|
27
|
+
The library never mirrors browser-owned state into React state. It reads the DOM when it needs to, and it does not duplicate a pseudo-class with a data attribute. State that nobody persists or awaits (whether a hint is showing) is left to the browser entirely, with no prop and no action. One read is mirrored: whether a popup is shown, where no native element exposes it to assistive technology: on a Trigger that is no invoker, and on the Combobox input (see [Triggers of a popup](#popup-triggers)). Each component page says what it leaves to the browser in its **Browser-owned state** section.
|
|
28
|
+
|
|
29
|
+
Example: [Tooltip](../components/tooltip.md)
|
|
30
|
+
|
|
31
|
+
A tooltip's visibility is not application state. The popup is a `popover` in the top layer, so Tooltip has no `open` prop, no action and no `data-open`: `:popover-open` already says it. Style and animate it in CSS:
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
.tip { opacity: 0; transition: opacity 120ms, display 120ms allow-discrete, overlay 120ms allow-discrete; }
|
|
35
|
+
.tip:popover-open {
|
|
36
|
+
opacity: 1;
|
|
37
|
+
@starting-style { opacity: 0; }
|
|
38
|
+
}
|
|
39
|
+
/* The trigger of an open tooltip: the popup is its next sibling. */
|
|
40
|
+
.trigger:has(+ .tip:popover-open) { outline: 1px solid; }
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## <a id="two-modes"></a>Two modes, one anatomy
|
|
44
|
+
|
|
45
|
+
Some components built on a native element that does the whole interaction offer both (their pages have a **Two modes** section). Without any controlled value, default value or change action it runs in [JS-free mode](#js-free-mode): the browser owns the state and nothing runs when it changes. Add any of them and the component switches to **library mode**: the native interaction is intercepted, the state is React state changed in a transition, and triggers get optimistic data attributes and `data-pending`. The parts and the markup are the same in both. The mode is decided on the first render; switching between them later is not supported (development warning).
|
|
46
|
+
|
|
47
|
+
The browser can still change the state in library mode (find-in-page, a text fragment, a click before hydration). The component turns that into a regular dispatch with `details.reason === "platform"`, and once the action settles it re-applies the committed state to the DOM, so a controlled parent that refuses the change gets its state back.
|
|
48
|
+
|
|
49
|
+
Example: [Accordion](../components/accordion.md)
|
|
50
|
+
|
|
51
|
+
An Accordion without `value`, `defaultValue` and `valueChangeAction` leaves every `<details open>` to the browser, and `exclusive` renders the native `name` group. With any of them, the summary click is intercepted and open state changes in a transition.
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
// JS-free: the browser owns open state.
|
|
55
|
+
<Accordion.Root exclusive>...</Accordion.Root>
|
|
56
|
+
|
|
57
|
+
// Library mode: transitions, actions, optimistic state.
|
|
58
|
+
<Accordion.Root exclusive defaultValue={null} valueChangeAction={save}>...</Accordion.Root>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Parts vs dismissals
|
|
62
|
+
|
|
63
|
+
For something that opens and closes in library mode, ownership is split by **who asked**. Opening, and a close the user asks one of the component's parts for, belong to the library: the click, submit or command is cancelled and dispatched in a transition, the action is awaited, a controlled parent can refuse it, and it can animate with a view transition. A [dismissal](#dismissal) belongs to the browser: the element closes natively and at once, the change action is called afterwards as a notification with `reason: "dismiss"`, and a controlled parent that refuses cannot keep it open (it can only open it again).
|
|
64
|
+
|
|
65
|
+
The line sits where the platform lets the library cancel a step freely: a part's click (which cancels its command), a `command` event, a form's `submit`. A dismissal goes through a close request instead, whose `cancel` the browser honours only once per user activation, and a user who pressed Escape expects the element to go away now. So the library never promises to hold a dismissal.
|
|
66
|
+
|
|
67
|
+
Example: [Dialog](../components/dialog.md)
|
|
68
|
+
|
|
69
|
+
A library-mode Dialog opens through its Trigger and closes through its Close parts and `Dialog.Form` after `openChangeAction` resolves. Escape or a click outside closes it at once, and `openChangeAction(false, details)` follows with `reason: "dismiss"`; a controlled parent that keeps `open` gets the dialog re-opened once the action settles.
|
|
70
|
+
|
|
71
|
+
## <a id="popup-triggers"></a>Triggers of a popup
|
|
72
|
+
|
|
73
|
+
A component whose popup is a popover has a **Trigger**: the part that opens and closes it. A Trigger rendered as a `<button>` names the popup with `popovertarget`, which makes it the popup's [invoker](#invoker). That relationship gives it three things from the browser:
|
|
74
|
+
|
|
75
|
+
- It can open the popup before hydration and with JavaScript off.
|
|
76
|
+
- A press on it is not a click outside: light dismiss spares the invoker of an open popover, so the Trigger's click can close the popup as [a part's close](#parts-close), awaited and animated.
|
|
77
|
+
- The browser exposes the popover's expanded or collapsed state on it. The Trigger therefore renders no `aria-expanded`; [ARIA in HTML](https://w3c.github.io/html-aria/) forbids the attribute on an element with `popovertarget`.
|
|
78
|
+
|
|
79
|
+
A component may give up one of these on purpose; its page says so.
|
|
80
|
+
|
|
81
|
+
Only a `<button>` can be the Trigger's invoker. A Trigger rendered as a link or another element works through the library's click handler instead, and has none of the above: it renders `aria-expanded` itself, from whether the popup is shown; and a press on it while the popup is open counts as a click outside, so light dismiss closes the popup before the click arrives. That close is not awaited, a controlled parent cannot refuse it, and there is no exit transition. A development warning says so. A disabled Trigger that stays focusable (it renders `aria-disabled`) is no invoker either, so that nothing native can open the popup.
|
|
82
|
+
|
|
83
|
+
**Two kinds of open state on a Trigger.** What assistive technology hears is whether the popup is shown. In library mode, `data-open` is the [optimistic](pending-and-optimistic.md#optimistic) state: it flips at the click, while an open that waits for an action or for content is still pending. Style click feedback with `[data-open]` and `[data-pending]`, never with `[aria-expanded]`, which a `<button>` Trigger does not have. An element that controls a popup without being its invoker, such as the Combobox input, renders `aria-expanded` from the shown popup too.
|
|
84
|
+
|
|
85
|
+
**One Trigger per Root.** The library anchors the popup to its Trigger or returns focus to it, so a Root has one. A second Trigger in the same Root is not supported (development warning); use a Root per trigger.
|
|
86
|
+
|
|
87
|
+
**Foreign invokers.** A [foreign invoker](#foreign-invoker) still works in library mode. An open through it is routed through the library like the Trigger's, so the action runs and the content loads first. A close through it is reported with `reason: "activate"`, because the user asked for it; each component page says whether that close is awaited or a notification. A component that keeps focus in its popup or its input does not lose it when you press a foreign invoker: the invoker's own close is the only one.
|
|
88
|
+
|
|
89
|
+
Example: [Popover](../components/popover.md)
|
|
90
|
+
|
|
91
|
+
A `Popover.Trigger` renders `<button popovertarget>` with no `aria-expanded`. Its styling hook is `data-open`; on a page that never hydrates, select on the popup that follows it:
|
|
92
|
+
|
|
93
|
+
```css
|
|
94
|
+
.trigger[data-open] { color: var(--accent); }
|
|
95
|
+
/* Without JavaScript: the Popup right after the Trigger. */
|
|
96
|
+
.trigger:has(+ :popover-open) { color: var(--accent); }
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## <a id="native-inputs"></a>Native inputs: the DOM is the optimistic state
|
|
100
|
+
|
|
101
|
+
A form control built on a real `<input>` has library-owned state, but the browser flips the input before any JavaScript runs, and after every event react-dom restores a controlled input to its current props. Only the synchronous optimistic state has rendered by then, so such a control renders the input from the optimistic value. That is a **correctness requirement**: an input driven by committed state would snap back right after the click and stay wrong for as long as the action runs. As a consequence the native pseudo-class (`:checked`) and the data attribute agree, and assistive technology hears the new state at once.
|
|
102
|
+
|
|
103
|
+
Example: [Switch](../components/switch.md)
|
|
104
|
+
|
|
105
|
+
A Switch renders `<input type="checkbox" role="switch">` with `checked={optimistic}`, so `:checked` and `data-checked` agree from the click on.
|
|
106
|
+
|
|
107
|
+
The browser can still change a native input without a click the library sees. Each case is a regular dispatch with `details.reason === "platform"`, and afterwards the DOM follows the decision:
|
|
108
|
+
|
|
109
|
+
- **Form reset**: a reset button, `form.reset()`, or React's automatic reset after a successful `<form action>`. Uncontrolled, the target is the latest default value; controlled, the browser's mount-time value is offered to the parent, which adopts it or not.
|
|
110
|
+
- **Mount reconciliation**: a click before hydration, or Firefox restoring form state on reload. React keeps the DOM value when hydrating and fires nothing, so the component compares on mount and dispatches once (once per group for a group of inputs).
|
|
111
|
+
|
|
112
|
+
## Consumer-owned, mirrored state
|
|
113
|
+
|
|
114
|
+
A fourth kind of state is **consumer-owned and mirrored**: the parent derives it, there is no default and no action, and the library only writes it to the DOM after every commit. Where the browser clears it on a click, the library stops writing it while an action is pending.
|
|
115
|
+
|
|
116
|
+
Example: [Checkbox](../components/checkbox.md)
|
|
117
|
+
|
|
118
|
+
`indeterminate` is derived by a "select all" parent from its rows. The library writes the DOM property after every commit and suspends it while an action is pending, because the browser clears it on the click.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Content Security Policy
|
|
2
|
+
|
|
3
|
+
FUNSTACK UI ships no visual CSS, but it does use inline styles for placement and two tiny functional stylesheets. Under a `style-src` that lists nonces or hashes instead of `'unsafe-inline'`, here is what each needs. Everything is exported from `@funstack/ui/csp` (and the root entry).
|
|
4
|
+
|
|
5
|
+
## What the library puts in the page
|
|
6
|
+
|
|
7
|
+
| Mechanism | Example | Under a strict style-src |
|
|
8
|
+
| - | - | - |
|
|
9
|
+
| Inline `style` set on the client | the point of a context menu, `position-area` after an update | Allowed: React writes the `style` prop through the CSSOM, which CSP does not govern. |
|
|
10
|
+
| Inline `style` in server-rendered HTML | `position-area` of an anchored popup, Tooltip's `interest-delay-*` | Blocked without `style-src-attr 'unsafe-inline'` (as for every library that renders inline styles). Blocked, the popup is placed by your stylesheet only until React updates the attribute, and a custom tooltip delay falls back to the browser's. |
|
|
11
|
+
| Hoisted `<style>` elements | the two stylesheets below | Blocked unless the text matches a `'sha256-…'` source or the element carries your nonce. |
|
|
12
|
+
|
|
13
|
+
## The shipped stylesheets and their hashes
|
|
14
|
+
|
|
15
|
+
Each is a constant string rendered as a React hoisted `<style>` (one per page, deduplicated by its `href`), only by the part that needs it. Their base64 SHA-256 is exported as `STYLE_SHA256`, keyed by `href`; a test recomputes it from the CSS, so it cannot drift from what the parts render.
|
|
16
|
+
|
|
17
|
+
| href | Rendered by | When | style-src source |
|
|
18
|
+
| - | - | - | - |
|
|
19
|
+
| `@funstack/ui/menu-point` | `Menu.Popup` | On the client, the first time a menu opens at a point (`Menu.ContextTrigger`) without `side={null}` | `'sha256-Wm5aBRstuZ3S9kDs0IbldhidU/prqpIW69jEAS0N9mc='` |
|
|
20
|
+
| `@funstack/ui/tooltip-warm` | `Tooltip.Trigger` | With `experimental_interestFor` only, during server rendering too | `'sha256-nFBZGhNvo46ITrlBb48hELUAyWzpeIdJCziCectFQa4='` |
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
Content-Security-Policy: style-src 'self' 'sha256-Wm5aBRstuZ3S9kDs0IbldhidU/prqpIW69jEAS0N9mc=' 'sha256-nFBZGhNvo46ITrlBb48hELUAyWzpeIdJCziCectFQa4='; style-src-attr 'unsafe-inline'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { STYLE_SHA256 } from "@funstack/ui/csp";
|
|
28
|
+
|
|
29
|
+
const styleSources = Object.values(STYLE_SHA256).map((hash) => `'sha256-${hash}'`);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Hashes need no code and suit static sites (FUNSTACK Static's output, a CDN): the values only change with a library release, so compute the header from `STYLE_SHA256` at build time rather than copying them.
|
|
33
|
+
|
|
34
|
+
## Nonces: CSPProvider
|
|
35
|
+
|
|
36
|
+
With a per-response nonce, render `<CSPProvider nonce>` once around the app. Every part that renders a hoisted `<style>` puts the nonce on it. It is the library's only provider, and its prop is serialisable, so a Server Component layout that knows the nonce renders it directly.
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { CSPProvider } from "@funstack/ui/csp";
|
|
40
|
+
|
|
41
|
+
export function Layout({ nonce, children }: { nonce: string; children: React.ReactNode }) {
|
|
42
|
+
return <CSPProvider nonce={nonce}>{children}</CSPProvider>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Server: pass the same value as React's style nonce.
|
|
46
|
+
renderToReadableStream(<App nonce={nonce} />, { nonce: { script: nonce, style: nonce } });
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> **Pass the same value as React's nonce.style**
|
|
50
|
+
>
|
|
51
|
+
> During server rendering React (19.3) checks a hoisted `<style>` against the `nonce: { style }` render option:
|
|
52
|
+
>
|
|
53
|
+
> - Same value on the element and the option: written with the nonce.
|
|
54
|
+
> - **If you pass `nonce.style`, render `<CSPProvider>` with the same value; without it React drops the rule** (the element has no nonce), and so does a different value.
|
|
55
|
+
> - No `nonce` option, or the string form `nonce: "…"` (scripts only): the rule is written **without** a nonce, so a nonce policy blocks it in the browser.
|
|
56
|
+
>
|
|
57
|
+
> This matters for the tooltip stylesheet, which can render on the server; the menu stylesheet is only ever inserted on the client.
|
|
58
|
+
|
|
59
|
+
| Prop | Type | Default | Description |
|
|
60
|
+
| - | - | - | - |
|
|
61
|
+
| `nonce` | `string` | – | The nonce of your `style-src`, forwarded as the `nonce` of every library `<style>`. Use the value you pass as React's `nonce.style`. |
|
|
62
|
+
| `children` | `ReactNode` | – | Your app. |
|
|
63
|
+
|
|
64
|
+
The library does not read a `<meta property="csp-nonce">` on its own: the server render needs the value in props anyway.
|
|
65
|
+
|
|
66
|
+
## If a stylesheet is blocked
|
|
67
|
+
|
|
68
|
+
- **Menu point rules**: a context menu still opens at the pointer, but it never flips at the viewport edges.
|
|
69
|
+
- **Tooltip skip-delay rule**: on Chromium's native path (`experimental_interestFor`) the next tooltip waits its `delay` instead of opening at once (the Trigger's `var(--fsui-tooltip-warm, 0)` falls back to `0`, not to the browser's own delay). The JS path does not use the stylesheet.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Experimental features
|
|
2
|
+
|
|
3
|
+
FUNSTACK UI supports the latest stable Blink, WebKit and Gecko, with no fallbacks for older browsers. Features that have not shipped in all three yet are still used, but only when you ask for them.
|
|
4
|
+
|
|
5
|
+
## `experimental_*` props
|
|
6
|
+
|
|
7
|
+
A feature inside an existing component is an `experimental_<feature>` prop on the part that uses it, off by default. The prefix follows React's naming for unstable APIs. It is greppable, it sits at the call site where you make the browser-support decision, and when the feature reaches every engine the prop is removed: the type error tells you exactly where to delete it.
|
|
8
|
+
|
|
9
|
+
The flags today. What each one does is documented in the props table of the part that takes it; this is the index.
|
|
10
|
+
|
|
11
|
+
| Prop | Platform feature | Native path today | Documented on |
|
|
12
|
+
| - | - | - | - |
|
|
13
|
+
| `experimental_focusgroup` | `focusgroup` | Chromium 150+ | [Tabs.List](../components/tabs.md#props), [Toolbar.Root](../components/toolbar.md#props), [ToggleGroup.Root](../components/toggle-group.md#props), [Menu.Popup](../components/menu.md#props) |
|
|
14
|
+
| `experimental_interpolateSize` | `interpolate-size` | Chromium | [Accordion.Root](../components/accordion.md#props) |
|
|
15
|
+
| `experimental_interestFor` | `interestfor` | Chromium | [Tooltip.Trigger](../components/tooltip.md#props), [Tooltip skip-delay](../components/tooltip.md#skip-delay) |
|
|
16
|
+
| `experimental_hint` | `popover="hint"` | Chromium, Firefox (Safari 27.0 treats it as `manual`) | [Tooltip.Popup](../components/tooltip.md#props) |
|
|
17
|
+
| `experimental_closedBy` | `closedby` | Chromium, Firefox | [Dialog.Popup](../components/dialog.md#props) |
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
<Tabs.List experimental_focusgroup aria-label="Settings">...</Tabs.List>
|
|
21
|
+
<Accordion.Root experimental_interpolateSize>...</Accordion.Root>
|
|
22
|
+
<Tooltip.Trigger experimental_interestFor>Save</Tooltip.Trigger>
|
|
23
|
+
<Tooltip.Popup experimental_hint>Saves the document</Tooltip.Popup>
|
|
24
|
+
<Dialog.Popup lightDismiss experimental_closedBy>...</Dialog.Popup>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Rules
|
|
28
|
+
|
|
29
|
+
- **Flags never change markup between server and client.** Feature detection (`"focusGroup" in HTMLElement.prototype`, `"interestForElement" in element`) runs in an effect, and only when the flag is on.
|
|
30
|
+
- **The baseline keeps working underneath.** A flag for a feature that would silently do nothing elsewhere keeps the JavaScript path active in engines without it.
|
|
31
|
+
- **No provider, no global switch.** The browser-support decision belongs next to the markup, and Server Components cannot create context anyway.
|
|
32
|
+
- Two features with different graduation paths are two props, so each can be removed on its own.
|
|
33
|
+
|
|
34
|
+
## `@funstack/ui/experimental`
|
|
35
|
+
|
|
36
|
+
A whole component that cannot exist without a flagged feature would ship from an `@funstack/ui/experimental` subpath. None does yet: every current component has a baseline that works in all engines.
|