@funstack/ui 0.1.0-alpha.1 → 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion/accordion-context.mjs.map +1 -1
- package/dist/accordion/accordion-item.mjs +20 -6
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.mjs +4 -5
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +35 -16
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +6 -7
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/button/button.d.mts +78 -0
- package/dist/button/button.d.mts.map +1 -0
- package/dist/button/button.mjs +77 -0
- package/dist/button/button.mjs.map +1 -0
- package/dist/button/index.d.mts +3 -0
- package/dist/button/index.mjs +1 -0
- package/dist/checkbox/checkbox.d.mts +5 -3
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +27 -11
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +2 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +5 -3
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +2 -2
- package/dist/checkbox-group/checkbox-group-root.d.mts +5 -2
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +25 -6
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts +37 -0
- package/dist/combobox/combobox-clear.d.mts.map +1 -0
- package/dist/combobox/combobox-clear.mjs +64 -0
- package/dist/combobox/combobox-clear.mjs.map +1 -0
- package/dist/combobox/combobox-context.mjs +23 -0
- package/dist/combobox/combobox-context.mjs.map +1 -0
- package/dist/combobox/combobox-group.d.mts +72 -0
- package/dist/combobox/combobox-group.d.mts.map +1 -0
- package/dist/combobox/combobox-group.mjs +104 -0
- package/dist/combobox/combobox-group.mjs.map +1 -0
- package/dist/combobox/combobox-input.d.mts +42 -0
- package/dist/combobox/combobox-input.d.mts.map +1 -0
- package/dist/combobox/combobox-input.mjs +102 -0
- package/dist/combobox/combobox-input.mjs.map +1 -0
- package/dist/combobox/combobox-label.d.mts +22 -0
- package/dist/combobox/combobox-label.d.mts.map +1 -0
- package/dist/combobox/combobox-label.mjs +32 -0
- package/dist/combobox/combobox-label.mjs.map +1 -0
- package/dist/combobox/combobox-list.d.mts +37 -0
- package/dist/combobox/combobox-list.d.mts.map +1 -0
- package/dist/combobox/combobox-list.mjs +71 -0
- package/dist/combobox/combobox-list.mjs.map +1 -0
- package/dist/combobox/combobox-option.d.mts +45 -0
- package/dist/combobox/combobox-option.d.mts.map +1 -0
- package/dist/combobox/combobox-option.mjs +88 -0
- package/dist/combobox/combobox-option.mjs.map +1 -0
- package/dist/combobox/combobox-popup.d.mts +49 -0
- package/dist/combobox/combobox-popup.d.mts.map +1 -0
- package/dist/combobox/combobox-popup.mjs +91 -0
- package/dist/combobox/combobox-popup.mjs.map +1 -0
- package/dist/combobox/combobox-root.d.mts +135 -0
- package/dist/combobox/combobox-root.d.mts.map +1 -0
- package/dist/combobox/combobox-root.mjs +523 -0
- package/dist/combobox/combobox-root.mjs.map +1 -0
- package/dist/combobox/combobox-trigger.d.mts +40 -0
- package/dist/combobox/combobox-trigger.d.mts.map +1 -0
- package/dist/combobox/combobox-trigger.mjs +99 -0
- package/dist/combobox/combobox-trigger.mjs.map +1 -0
- package/dist/combobox/index.d.mts +36 -0
- package/dist/combobox/index.d.mts.map +1 -0
- package/dist/combobox/index.mjs +36 -0
- package/dist/combobox/index.mjs.map +1 -0
- package/dist/csp/csp-provider.d.mts +25 -0
- package/dist/csp/csp-provider.d.mts.map +1 -0
- package/dist/csp/csp-provider.mjs +24 -0
- package/dist/csp/csp-provider.mjs.map +1 -0
- package/dist/csp/index.d.mts +3 -0
- package/dist/csp/index.mjs +3 -0
- package/dist/csp/style-hashes.d.mts +19 -0
- package/dist/csp/style-hashes.d.mts.map +1 -0
- package/dist/csp/style-hashes.mjs +21 -0
- package/dist/csp/style-hashes.mjs.map +1 -0
- package/dist/dialog/dialog-close.d.mts +22 -10
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +41 -25
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts +23 -10
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +51 -32
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +10 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +118 -45
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +14 -8
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +68 -13
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +11 -5
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +16 -8
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +4 -2
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +4 -2
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/field/field-control.d.mts +33 -0
- package/dist/field/field-control.d.mts.map +1 -0
- package/dist/field/field-control.mjs +68 -0
- package/dist/field/field-control.mjs.map +1 -0
- package/dist/field/field-description.d.mts +24 -0
- package/dist/field/field-description.d.mts.map +1 -0
- package/dist/field/field-description.mjs +34 -0
- package/dist/field/field-description.mjs.map +1 -0
- package/dist/field/field-error.d.mts +30 -0
- package/dist/field/field-error.d.mts.map +1 -0
- package/dist/field/field-error.mjs +42 -0
- package/dist/field/field-error.mjs.map +1 -0
- package/dist/field/field-label.d.mts +25 -0
- package/dist/field/field-label.d.mts.map +1 -0
- package/dist/field/field-label.mjs +46 -0
- package/dist/field/field-label.mjs.map +1 -0
- package/dist/field/field-root.d.mts +53 -0
- package/dist/field/field-root.d.mts.map +1 -0
- package/dist/field/field-root.mjs +319 -0
- package/dist/field/field-root.mjs.map +1 -0
- package/dist/field/index.d.mts +18 -0
- package/dist/field/index.d.mts.map +1 -0
- package/dist/field/index.mjs +17 -0
- package/dist/field/index.mjs.map +1 -0
- package/dist/form/form-root.d.mts +58 -0
- package/dist/form/form-root.d.mts.map +1 -0
- package/dist/form/form-root.mjs +147 -0
- package/dist/form/form-root.mjs.map +1 -0
- package/dist/form/form-submit.d.mts +34 -0
- package/dist/form/form-submit.d.mts.map +1 -0
- package/dist/form/form-submit.mjs +53 -0
- package/dist/form/form-submit.mjs.map +1 -0
- package/dist/form/index.d.mts +11 -0
- package/dist/form/index.d.mts.map +1 -0
- package/dist/form/index.mjs +11 -0
- package/dist/form/index.mjs.map +1 -0
- package/dist/index.d.mts +79 -4
- package/dist/index.mjs +16 -1
- package/dist/internal/anchor-position.d.mts +11 -3
- package/dist/internal/anchor-position.d.mts.map +1 -1
- package/dist/internal/anchor-position.mjs +180 -6
- package/dist/internal/anchor-position.mjs.map +1 -1
- package/dist/internal/announce.mjs +53 -0
- package/dist/internal/announce.mjs.map +1 -0
- package/dist/internal/content-focus-probe.mjs +42 -0
- package/dist/internal/content-focus-probe.mjs.map +1 -0
- package/dist/internal/csp-context.mjs +8 -0
- package/dist/internal/csp-context.mjs.map +1 -0
- package/dist/internal/decimal.mjs +27 -0
- package/dist/internal/decimal.mjs.map +1 -0
- package/dist/internal/dev-warn.mjs +17 -0
- package/dist/internal/dev-warn.mjs.map +1 -0
- package/dist/internal/field-context.d.mts +19 -0
- package/dist/internal/field-context.d.mts.map +1 -0
- package/dist/internal/field-context.mjs +14 -0
- package/dist/internal/field-context.mjs.map +1 -0
- package/dist/internal/focus-first-invalid.mjs +67 -0
- package/dist/internal/focus-first-invalid.mjs.map +1 -0
- package/dist/internal/form-status-watcher.mjs +31 -0
- package/dist/internal/form-status-watcher.mjs.map +1 -0
- package/dist/internal/modal-registry.mjs +39 -0
- package/dist/internal/modal-registry.mjs.map +1 -0
- package/dist/internal/platform-attributes.d.mts +12 -1
- package/dist/internal/platform-attributes.d.mts.map +1 -1
- package/dist/internal/range-value.mjs +51 -0
- package/dist/internal/range-value.mjs.map +1 -0
- package/dist/internal/render-element.mjs +67 -0
- package/dist/internal/render-element.mjs.map +1 -0
- package/dist/internal/toolbar-context.mjs +17 -0
- package/dist/internal/toolbar-context.mjs.map +1 -0
- package/dist/internal/tooltip-warm.mjs +29 -0
- package/dist/internal/tooltip-warm.mjs.map +1 -0
- package/dist/internal/types.d.mts +11 -1
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-action-trigger.mjs +17 -6
- package/dist/internal/use-action-trigger.mjs.map +1 -1
- package/dist/internal/use-controllable-action.mjs +35 -13
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-exit-animation.mjs +26 -6
- package/dist/internal/use-exit-animation.mjs.map +1 -1
- package/dist/internal/use-field-control.mjs +109 -0
- package/dist/internal/use-field-control.mjs.map +1 -0
- package/dist/internal/use-form-owner-event.mjs +44 -0
- package/dist/internal/use-form-owner-event.mjs.map +1 -0
- package/dist/internal/use-form-reset.mjs +12 -31
- package/dist/internal/use-form-reset.mjs.map +1 -1
- package/dist/internal/use-hydrated-mount.mjs +21 -0
- package/dist/internal/use-hydrated-mount.mjs.map +1 -0
- package/dist/internal/use-latest.mjs +32 -0
- package/dist/internal/use-latest.mjs.map +1 -0
- package/dist/internal/use-modal-registration.mjs +47 -0
- package/dist/internal/use-modal-registration.mjs.map +1 -0
- package/dist/internal/use-native-group-reconciliation.mjs +6 -5
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-native-select-value.mjs +184 -0
- package/dist/internal/use-native-select-value.mjs.map +1 -0
- package/dist/internal/use-popover-popup.mjs +33 -28
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-root.mjs +59 -24
- package/dist/internal/use-popover-root.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.mjs +6 -5
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/use-render.mjs +12 -35
- package/dist/internal/use-render.mjs.map +1 -1
- package/dist/internal/use-resolved-placement.mjs +146 -0
- package/dist/internal/use-resolved-placement.mjs.map +1 -0
- package/dist/internal/use-roving-focus.mjs +301 -0
- package/dist/internal/use-roving-focus.mjs.map +1 -0
- package/dist/internal/validity.d.mts +24 -0
- package/dist/internal/validity.d.mts.map +1 -0
- package/dist/internal/validity.mjs +108 -0
- package/dist/internal/validity.mjs.map +1 -0
- package/dist/menu/index.d.mts +5 -1
- package/dist/menu/index.d.mts.map +1 -1
- package/dist/menu/index.mjs +5 -1
- package/dist/menu/index.mjs.map +1 -1
- package/dist/menu/menu-checkbox-item.mjs +2 -1
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +46 -0
- package/dist/menu/menu-context-trigger.d.mts.map +1 -0
- package/dist/menu/menu-context-trigger.mjs +405 -0
- package/dist/menu/menu-context-trigger.mjs.map +1 -0
- package/dist/menu/menu-context.mjs +44 -1
- package/dist/menu/menu-context.mjs.map +1 -1
- package/dist/menu/menu-dom.mjs +49 -3
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +4 -3
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-item.d.mts +6 -2
- package/dist/menu/menu-item.d.mts.map +1 -1
- package/dist/menu/menu-item.mjs +7 -4
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-popup.d.mts +36 -8
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +219 -22
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.mjs +10 -5
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.mjs +2 -1
- package/dist/menu/menu-radio-item.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +5 -0
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +57 -7
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +28 -12
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +8 -4
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +18 -7
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/meter/index.d.mts +24 -0
- package/dist/meter/index.d.mts.map +1 -0
- package/dist/meter/index.mjs +23 -0
- package/dist/meter/index.mjs.map +1 -0
- package/dist/meter/meter-context.mjs +13 -0
- package/dist/meter/meter-context.mjs.map +1 -0
- package/dist/meter/meter-indicator.d.mts +19 -0
- package/dist/meter/meter-indicator.d.mts.map +1 -0
- package/dist/meter/meter-indicator.mjs +25 -0
- package/dist/meter/meter-indicator.mjs.map +1 -0
- package/dist/meter/meter-label.d.mts +19 -0
- package/dist/meter/meter-label.d.mts.map +1 -0
- package/dist/meter/meter-label.mjs +28 -0
- package/dist/meter/meter-label.mjs.map +1 -0
- package/dist/meter/meter-region.d.mts +4 -0
- package/dist/meter/meter-region.d.mts.map +1 -0
- package/dist/meter/meter-region.mjs +39 -0
- package/dist/meter/meter-region.mjs.map +1 -0
- package/dist/meter/meter-root.d.mts +71 -0
- package/dist/meter/meter-root.d.mts.map +1 -0
- package/dist/meter/meter-root.mjs +83 -0
- package/dist/meter/meter-root.mjs.map +1 -0
- package/dist/meter/meter-track.d.mts +19 -0
- package/dist/meter/meter-track.d.mts.map +1 -0
- package/dist/meter/meter-track.mjs +25 -0
- package/dist/meter/meter-track.mjs.map +1 -0
- package/dist/meter/meter-value.d.mts +20 -0
- package/dist/meter/meter-value.d.mts.map +1 -0
- package/dist/meter/meter-value.mjs +29 -0
- package/dist/meter/meter-value.mjs.map +1 -0
- package/dist/number-field/index.d.mts +26 -0
- package/dist/number-field/index.d.mts.map +1 -0
- package/dist/number-field/index.mjs +26 -0
- package/dist/number-field/index.mjs.map +1 -0
- package/dist/number-field/number-field-arithmetic.mjs +78 -0
- package/dist/number-field/number-field-arithmetic.mjs.map +1 -0
- package/dist/number-field/number-field-context.d.mts +2 -0
- package/dist/number-field/number-field-context.mjs +13 -0
- package/dist/number-field/number-field-context.mjs.map +1 -0
- package/dist/number-field/number-field-decrement.d.mts +17 -0
- package/dist/number-field/number-field-decrement.d.mts.map +1 -0
- package/dist/number-field/number-field-decrement.mjs +20 -0
- package/dist/number-field/number-field-decrement.mjs.map +1 -0
- package/dist/number-field/number-field-format.mjs +279 -0
- package/dist/number-field/number-field-format.mjs.map +1 -0
- package/dist/number-field/number-field-increment.d.mts +37 -0
- package/dist/number-field/number-field-increment.d.mts.map +1 -0
- package/dist/number-field/number-field-increment.mjs +71 -0
- package/dist/number-field/number-field-increment.mjs.map +1 -0
- package/dist/number-field/number-field-input.d.mts +29 -0
- package/dist/number-field/number-field-input.d.mts.map +1 -0
- package/dist/number-field/number-field-input.mjs +163 -0
- package/dist/number-field/number-field-input.mjs.map +1 -0
- package/dist/number-field/number-field-label.d.mts +23 -0
- package/dist/number-field/number-field-label.d.mts.map +1 -0
- package/dist/number-field/number-field-label.mjs +47 -0
- package/dist/number-field/number-field-label.mjs.map +1 -0
- package/dist/number-field/number-field-root.d.mts +108 -0
- package/dist/number-field/number-field-root.d.mts.map +1 -0
- package/dist/number-field/number-field-root.mjs +523 -0
- package/dist/number-field/number-field-root.mjs.map +1 -0
- package/dist/number-field/use-step-button.mjs +112 -0
- package/dist/number-field/use-step-button.mjs.map +1 -0
- package/dist/popover/popover-close.d.mts +9 -3
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +13 -7
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +21 -7
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +23 -8
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.mjs +1 -1
- package/dist/popover/popover-trigger.d.mts +8 -4
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +3 -3
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/index.d.mts +24 -0
- package/dist/progress/index.d.mts.map +1 -0
- package/dist/progress/index.mjs +24 -0
- package/dist/progress/index.mjs.map +1 -0
- package/dist/progress/progress-context.mjs +13 -0
- package/dist/progress/progress-context.mjs.map +1 -0
- package/dist/progress/progress-indicator.d.mts +19 -0
- package/dist/progress/progress-indicator.d.mts.map +1 -0
- package/dist/progress/progress-indicator.mjs +29 -0
- package/dist/progress/progress-indicator.mjs.map +1 -0
- package/dist/progress/progress-label.d.mts +19 -0
- package/dist/progress/progress-label.d.mts.map +1 -0
- package/dist/progress/progress-label.mjs +30 -0
- package/dist/progress/progress-label.mjs.map +1 -0
- package/dist/progress/progress-root.d.mts +68 -0
- package/dist/progress/progress-root.d.mts.map +1 -0
- package/dist/progress/progress-root.mjs +80 -0
- package/dist/progress/progress-root.mjs.map +1 -0
- package/dist/progress/progress-track.d.mts +19 -0
- package/dist/progress/progress-track.d.mts.map +1 -0
- package/dist/progress/progress-track.mjs +29 -0
- package/dist/progress/progress-track.mjs.map +1 -0
- package/dist/progress/progress-value.d.mts +20 -0
- package/dist/progress/progress-value.d.mts.map +1 -0
- package/dist/progress/progress-value.mjs +33 -0
- package/dist/progress/progress-value.mjs.map +1 -0
- package/dist/radio-group/radio-group-item.mjs +2 -2
- package/dist/radio-group/radio-group-root.d.mts +4 -2
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +35 -9
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/index.d.mts +30 -0
- package/dist/select/index.d.mts.map +1 -0
- package/dist/select/index.mjs +30 -0
- package/dist/select/index.mjs.map +1 -0
- package/dist/select/select-context.mjs +13 -0
- package/dist/select/select-context.mjs.map +1 -0
- package/dist/select/select-dom.mjs +44 -0
- package/dist/select/select-dom.mjs.map +1 -0
- package/dist/select/select-group-label.d.mts +22 -0
- package/dist/select/select-group-label.d.mts.map +1 -0
- package/dist/select/select-group-label.mjs +39 -0
- package/dist/select/select-group-label.mjs.map +1 -0
- package/dist/select/select-group.d.mts +28 -0
- package/dist/select/select-group.d.mts.map +1 -0
- package/dist/select/select-group.mjs +47 -0
- package/dist/select/select-group.mjs.map +1 -0
- package/dist/select/select-option.d.mts +42 -0
- package/dist/select/select-option.d.mts.map +1 -0
- package/dist/select/select-option.mjs +65 -0
- package/dist/select/select-option.mjs.map +1 -0
- package/dist/select/select-root.d.mts +68 -0
- package/dist/select/select-root.d.mts.map +1 -0
- package/dist/select/select-root.mjs +114 -0
- package/dist/select/select-root.mjs.map +1 -0
- package/dist/select/select-separator.d.mts +20 -0
- package/dist/select/select-separator.d.mts.map +1 -0
- package/dist/select/select-separator.mjs +30 -0
- package/dist/select/select-separator.mjs.map +1 -0
- package/dist/select/select-trigger.d.mts +29 -0
- package/dist/select/select-trigger.d.mts.map +1 -0
- package/dist/select/select-trigger.mjs +48 -0
- package/dist/select/select-trigger.mjs.map +1 -0
- package/dist/select/select-value.d.mts +31 -0
- package/dist/select/select-value.d.mts.map +1 -0
- package/dist/select/select-value.mjs +101 -0
- package/dist/select/select-value.mjs.map +1 -0
- package/dist/slider/index.d.mts +32 -0
- package/dist/slider/index.d.mts.map +1 -0
- package/dist/slider/index.mjs +27 -0
- package/dist/slider/index.mjs.map +1 -0
- package/dist/slider/slider-arithmetic.mjs +104 -0
- package/dist/slider/slider-arithmetic.mjs.map +1 -0
- package/dist/slider/slider-context.mjs +13 -0
- package/dist/slider/slider-context.mjs.map +1 -0
- package/dist/slider/slider-indicator.d.mts +22 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -0
- package/dist/slider/slider-indicator.mjs +36 -0
- package/dist/slider/slider-indicator.mjs.map +1 -0
- package/dist/slider/slider-label.d.mts +23 -0
- package/dist/slider/slider-label.d.mts.map +1 -0
- package/dist/slider/slider-label.mjs +44 -0
- package/dist/slider/slider-label.mjs.map +1 -0
- package/dist/slider/slider-root.d.mts +111 -0
- package/dist/slider/slider-root.d.mts.map +1 -0
- package/dist/slider/slider-root.mjs +583 -0
- package/dist/slider/slider-root.mjs.map +1 -0
- package/dist/slider/slider-thumb.d.mts +58 -0
- package/dist/slider/slider-thumb.d.mts.map +1 -0
- package/dist/slider/slider-thumb.mjs +146 -0
- package/dist/slider/slider-thumb.mjs.map +1 -0
- package/dist/slider/slider-track.d.mts +29 -0
- package/dist/slider/slider-track.d.mts.map +1 -0
- package/dist/slider/slider-track.mjs +55 -0
- package/dist/slider/slider-track.mjs.map +1 -0
- package/dist/slider/slider-value.d.mts +34 -0
- package/dist/slider/slider-value.d.mts.map +1 -0
- package/dist/slider/slider-value.mjs +38 -0
- package/dist/slider/slider-value.mjs.map +1 -0
- package/dist/switch/switch.d.mts +5 -3
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +26 -10
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/tabs-indicator.mjs +2 -1
- package/dist/tabs/tabs-indicator.mjs.map +1 -1
- package/dist/tabs/tabs-list.mjs +1 -1
- package/dist/tabs/tabs-panel.mjs +1 -1
- package/dist/tabs/tabs-root.mjs +15 -5
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.mjs +3 -2
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/index.d.mts +25 -0
- package/dist/toast/index.d.mts.map +1 -0
- package/dist/toast/index.mjs +26 -0
- package/dist/toast/index.mjs.map +1 -0
- package/dist/toast/toast-action.d.mts +40 -0
- package/dist/toast/toast-action.d.mts.map +1 -0
- package/dist/toast/toast-action.mjs +67 -0
- package/dist/toast/toast-action.mjs.map +1 -0
- package/dist/toast/toast-close.d.mts +25 -0
- package/dist/toast/toast-close.d.mts.map +1 -0
- package/dist/toast/toast-close.mjs +47 -0
- package/dist/toast/toast-close.mjs.map +1 -0
- package/dist/toast/toast-context.mjs +19 -0
- package/dist/toast/toast-context.mjs.map +1 -0
- package/dist/toast/toast-description.d.mts +24 -0
- package/dist/toast/toast-description.d.mts.map +1 -0
- package/dist/toast/toast-description.mjs +35 -0
- package/dist/toast/toast-description.mjs.map +1 -0
- package/dist/toast/toast-root.d.mts +43 -0
- package/dist/toast/toast-root.d.mts.map +1 -0
- package/dist/toast/toast-root.mjs +205 -0
- package/dist/toast/toast-root.mjs.map +1 -0
- package/dist/toast/toast-title.d.mts +24 -0
- package/dist/toast/toast-title.d.mts.map +1 -0
- package/dist/toast/toast-title.mjs +33 -0
- package/dist/toast/toast-title.mjs.map +1 -0
- package/dist/toast/toast-viewport.d.mts +52 -0
- package/dist/toast/toast-viewport.d.mts.map +1 -0
- package/dist/toast/toast-viewport.mjs +644 -0
- package/dist/toast/toast-viewport.mjs.map +1 -0
- package/dist/toast/toast.d.mts +119 -0
- package/dist/toast/toast.d.mts.map +1 -0
- package/dist/toast/toast.mjs +157 -0
- package/dist/toast/toast.mjs.map +1 -0
- package/dist/toggle/toggle.d.mts +4 -1
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +16 -9
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/index.d.mts +16 -0
- package/dist/toggle-group/index.d.mts.map +1 -0
- package/dist/toggle-group/index.mjs +15 -0
- package/dist/toggle-group/index.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-context.d.mts +4 -0
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-context.mjs +13 -0
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-item.d.mts +51 -0
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-item.mjs +68 -0
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-root.d.mts +95 -0
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-root.mjs +211 -0
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -0
- package/dist/toolbar/index.d.mts +17 -0
- package/dist/toolbar/index.d.mts.map +1 -0
- package/dist/toolbar/index.mjs +17 -0
- package/dist/toolbar/index.mjs.map +1 -0
- package/dist/toolbar/toolbar-root.d.mts +38 -0
- package/dist/toolbar/toolbar-root.d.mts.map +1 -0
- package/dist/toolbar/toolbar-root.mjs +66 -0
- package/dist/toolbar/toolbar-root.mjs.map +1 -0
- package/dist/toolbar/toolbar-separator.d.mts +25 -0
- package/dist/toolbar/toolbar-separator.d.mts.map +1 -0
- package/dist/toolbar/toolbar-separator.mjs +31 -0
- package/dist/toolbar/toolbar-separator.mjs.map +1 -0
- package/dist/tooltip/index.d.mts +8 -5
- package/dist/tooltip/index.d.mts.map +1 -1
- package/dist/tooltip/index.mjs +6 -3
- package/dist/tooltip/index.mjs.map +1 -1
- package/dist/tooltip/tooltip-arrow.d.mts +30 -0
- package/dist/tooltip/tooltip-arrow.d.mts.map +1 -0
- package/dist/tooltip/tooltip-arrow.mjs +45 -0
- package/dist/tooltip/tooltip-arrow.mjs.map +1 -0
- package/dist/tooltip/tooltip-context.d.mts +7 -0
- package/dist/tooltip/tooltip-context.d.mts.map +1 -1
- package/dist/tooltip/tooltip-context.mjs +2 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts +27 -6
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +36 -7
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +18 -2
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +9 -2
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +23 -6
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/dist/tooltip/use-tooltip-interaction.mjs +126 -76
- package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
- package/package.json +14 -1
|
@@ -1,16 +1,190 @@
|
|
|
1
1
|
//#region src/internal/anchor-position.ts
|
|
2
2
|
/** Flip to the opposite side, then the other axis, then both, when the popup does not fit. */
|
|
3
3
|
const POSITION_TRY_FALLBACKS = "flip-block, flip-inline, flip-block flip-inline";
|
|
4
|
+
const SIDE_KEYWORD = {
|
|
5
|
+
top: "top",
|
|
6
|
+
bottom: "bottom",
|
|
7
|
+
left: "left",
|
|
8
|
+
right: "right",
|
|
9
|
+
"inline-start": "self-x-start",
|
|
10
|
+
"inline-end": "self-x-end"
|
|
11
|
+
};
|
|
4
12
|
/**
|
|
5
|
-
* The `position-area` for a side and an alignment (
|
|
6
|
-
* `bottom
|
|
7
|
-
*
|
|
13
|
+
* The `position-area` for a side and an alignment (the matrix of conventions 13.1):
|
|
14
|
+
* `bottom` + `center` is `bottom`, `bottom` + `start` is `bottom span-self-x-end`, `right` +
|
|
15
|
+
* `start` is `right span-bottom`, `inline-end` + `start` is `self-x-end span-bottom`.
|
|
8
16
|
*/
|
|
9
17
|
function positionArea(side, align) {
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
const keyword = SIDE_KEYWORD[side];
|
|
19
|
+
if (align === "center") return keyword;
|
|
20
|
+
return `${keyword} ${side === "top" || side === "bottom" ? align === "start" ? "span-self-x-end" : "span-self-x-start" : align === "start" ? "span-bottom" : "span-top"}`;
|
|
12
21
|
}
|
|
22
|
+
const AXIS_OF = {
|
|
23
|
+
top: "y",
|
|
24
|
+
bottom: "y",
|
|
25
|
+
left: "x",
|
|
26
|
+
right: "x"
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Parses a computed `position-area` (conventions 13.2) into the physical side the popup sits on
|
|
30
|
+
* and its alignment. Total: anything it cannot map returns `null` (`none`, an empty value, a
|
|
31
|
+
* vertical `writing-mode`, a corner cell, the cell over the anchor, an unknown keyword), and the
|
|
32
|
+
* part keeps the requested values. The engines serialise in grammar order, in any keyword group:
|
|
33
|
+
* `span-left top`, `span-all bottom` (Firefox's form of a flipped `bottom`), `self-end
|
|
34
|
+
* span-self-end`, `span-self-x-end bottom`, `self-x-start span-top`.
|
|
35
|
+
*
|
|
36
|
+
* `selfDirection` is the popup's computed `direction` (it resolves `self-*` tokens);
|
|
37
|
+
* `rootDirection` the root's (plain `x-*` / `inline-*` tokens, which a consumer `style` override
|
|
38
|
+
* may use), passed as a function so it is read only when such a token appears.
|
|
39
|
+
*/
|
|
40
|
+
function parsePositionArea(value, selfDirection, rootDirection, writingMode = "horizontal-tb") {
|
|
41
|
+
if (writingMode !== "horizontal-tb" || typeof value !== "string") return null;
|
|
42
|
+
const words = value.trim().split(/\s+/);
|
|
43
|
+
if (words.length > 2 || words[0] === "" || words[0] === "none") return null;
|
|
44
|
+
let root;
|
|
45
|
+
const rootDir = () => root ??= typeof rootDirection === "function" ? rootDirection() : rootDirection;
|
|
46
|
+
const tokens = [];
|
|
47
|
+
for (let index = 0; index < words.length; index++) {
|
|
48
|
+
const token = classify(words[index], index, words.length, selfDirection, rootDir);
|
|
49
|
+
if (token === null) return null;
|
|
50
|
+
tokens.push(token);
|
|
51
|
+
}
|
|
52
|
+
const sides = tokens.filter((t) => t.kind === "side");
|
|
53
|
+
if (sides.length !== 1) return null;
|
|
54
|
+
const side = sides[0].physical;
|
|
55
|
+
const span = tokens.find((t) => t.kind === "span");
|
|
56
|
+
if (span === void 0) return {
|
|
57
|
+
side,
|
|
58
|
+
align: "center"
|
|
59
|
+
};
|
|
60
|
+
const toward = span.physical;
|
|
61
|
+
if (AXIS_OF[toward] === AXIS_OF[side]) return null;
|
|
62
|
+
if (AXIS_OF[side] === "y") return {
|
|
63
|
+
side,
|
|
64
|
+
align: toward === (selfDirection === "rtl" ? "left" : "right") ? "start" : "end"
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
side,
|
|
68
|
+
align: toward === "bottom" ? "start" : "end"
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function classify(word, index, count, selfDirection, rootDirection) {
|
|
72
|
+
if (word === "center" || word === "span-all") return {
|
|
73
|
+
kind: "neutral",
|
|
74
|
+
physical: null
|
|
75
|
+
};
|
|
76
|
+
const span = word.startsWith("span-");
|
|
77
|
+
const physical = physicalOf(span ? word.slice(5) : word, index, count, selfDirection, rootDirection);
|
|
78
|
+
return physical === null ? null : {
|
|
79
|
+
kind: span ? "span" : "side",
|
|
80
|
+
physical
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The physical direction a keyword names, in `horizontal-tb`. Bare `start` / `end` /
|
|
85
|
+
* `self-start` / `self-end` are positional: the block axis first, the inline axis second; alone
|
|
86
|
+
* they name both axes (a corner, or a span over both), which the table does not describe.
|
|
87
|
+
*/
|
|
88
|
+
function physicalOf(name, index, count, selfDirection, rootDirection) {
|
|
89
|
+
switch (name) {
|
|
90
|
+
case "top":
|
|
91
|
+
case "bottom":
|
|
92
|
+
case "left":
|
|
93
|
+
case "right": return name;
|
|
94
|
+
case "y-start":
|
|
95
|
+
case "self-y-start":
|
|
96
|
+
case "y-self-start":
|
|
97
|
+
case "block-start":
|
|
98
|
+
case "self-block-start": return "top";
|
|
99
|
+
case "y-end":
|
|
100
|
+
case "self-y-end":
|
|
101
|
+
case "y-self-end":
|
|
102
|
+
case "block-end":
|
|
103
|
+
case "self-block-end": return "bottom";
|
|
104
|
+
case "self-x-start":
|
|
105
|
+
case "x-self-start":
|
|
106
|
+
case "self-inline-start": return inlineEdge("start", selfDirection);
|
|
107
|
+
case "self-x-end":
|
|
108
|
+
case "x-self-end":
|
|
109
|
+
case "self-inline-end": return inlineEdge("end", selfDirection);
|
|
110
|
+
case "x-start":
|
|
111
|
+
case "inline-start": return inlineEdge("start", rootDirection());
|
|
112
|
+
case "x-end":
|
|
113
|
+
case "inline-end": return inlineEdge("end", rootDirection());
|
|
114
|
+
case "start":
|
|
115
|
+
case "end":
|
|
116
|
+
case "self-start":
|
|
117
|
+
case "self-end": {
|
|
118
|
+
if (count !== 2) return null;
|
|
119
|
+
const edge = name.endsWith("start") ? "start" : "end";
|
|
120
|
+
if (index === 0) return edge === "start" ? "top" : "bottom";
|
|
121
|
+
return inlineEdge(edge, name.startsWith("self-") ? selfDirection : rootDirection());
|
|
122
|
+
}
|
|
123
|
+
default: return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function inlineEdge(edge, direction) {
|
|
127
|
+
return edge === "start" === (direction === "ltr") ? "left" : "right";
|
|
128
|
+
}
|
|
129
|
+
/** Custom property carrying the x coordinate of a point-placed popup (viewport px). */
|
|
130
|
+
const MENU_POINT_X = "--menu-point-x";
|
|
131
|
+
/** Custom property carrying the y coordinate of a point-placed popup (viewport px). */
|
|
132
|
+
const MENU_POINT_Y = "--menu-point-y";
|
|
133
|
+
/**
|
|
134
|
+
* Custom property carrying the vertical gap between the point and the menu: `0px` for a mouse or
|
|
135
|
+
* keyboard open, `16px` for a touch or pen open, which is placed above the finger (#88, 4.7).
|
|
136
|
+
*/
|
|
137
|
+
const MENU_POINT_GAP = "--menu-point-gap";
|
|
138
|
+
/** The gap of a touch or pen open (context-menu.md 4.7). */
|
|
139
|
+
const MENU_POINT_TOUCH_GAP = "16px";
|
|
140
|
+
/** The dedupe key of the shipped rules (`<style href precedence>`). */
|
|
141
|
+
const MENU_POINT_HREF = "@funstack/ui/menu-point";
|
|
142
|
+
/**
|
|
143
|
+
* The React stylesheet precedence bucket of the library's functional CSS. Fizz writes every
|
|
144
|
+
* same-precedence `<style>` of one server flush as a single element with the texts concatenated,
|
|
145
|
+
* which would match none of the per-href hashes in `STYLE_SHA256`: at most one shipped stylesheet
|
|
146
|
+
* in this bucket may render during server rendering (today the tooltip skip-delay rule; the menu
|
|
147
|
+
* point rules are client-only). A second one needs a precedence of its own (guard row in
|
|
148
|
+
* `csp/csp.test.tsx`).
|
|
149
|
+
*/
|
|
150
|
+
const FSUI_PRECEDENCE = "fsui";
|
|
151
|
+
const UP = `top: auto; bottom: calc(100% - var(${MENU_POINT_Y}) + var(${MENU_POINT_GAP}));`;
|
|
152
|
+
const DOWN = `bottom: auto; top: calc(var(${MENU_POINT_Y}) + var(${MENU_POINT_GAP}));`;
|
|
153
|
+
const LEFT = `left: auto; right: calc(100% - var(${MENU_POINT_X}));`;
|
|
154
|
+
const RIGHT = `right: auto; left: var(${MENU_POINT_X});`;
|
|
155
|
+
/**
|
|
156
|
+
* The `@position-try` options that mirror a point-placed popup around the point when it does not
|
|
157
|
+
* fit (context-menu.md 4.2, conventions 12). The base position is inline on the popup: the
|
|
158
|
+
* point's y below (mouse, keyboard) or above (touch, pen, with `--menu-point-gap`) the menu and,
|
|
159
|
+
* by the popup's direction, its left (LTR) or right (RTL) edge at the point's x. A menu names the
|
|
160
|
+
* three options that apply to its direction and pointer kind (`MENU_POINT_FALLBACKS`); the others
|
|
161
|
+
* are inert. Functional at-rules with no selectors: no element is styled. `100%` resolves against
|
|
162
|
+
* the viewport, the top layer's containing block, which `clientX` / `clientY` are measured in.
|
|
163
|
+
* Its SHA-256 is `STYLE_SHA256` in `@funstack/ui/csp` (a jsdom row recomputes it).
|
|
164
|
+
*/
|
|
165
|
+
const MENU_POINT_RULES = `/* @funstack/ui: placement of a menu at a point. Functional only: the base position is inline on the popup (below or above the point and, by direction, its left or right edge at the point); these options mirror it around the point when it does not fit. */
|
|
166
|
+
@position-try --fsui-menu-up { ${UP} }\n@position-try --fsui-menu-down { ${DOWN} }\n@position-try --fsui-menu-left { ${LEFT} }\n@position-try --fsui-menu-right { ${RIGHT} }\n@position-try --fsui-menu-up-left { ${UP} ${LEFT} }\n@position-try --fsui-menu-up-right { ${UP} ${RIGHT} }\n@position-try --fsui-menu-down-left { ${DOWN} ${LEFT} }\n@position-try --fsui-menu-down-right { ${DOWN} ${RIGHT} }\n`;
|
|
167
|
+
/**
|
|
168
|
+
* Two equivalent spellings of the point fallback list per direction and pointer kind
|
|
169
|
+
* (`MENU_POINT_FALLBACKS[direction][offset ? "touch" : "mouse"][generation % 2]`), alternated by
|
|
170
|
+
* the placement's generation: changing `position-try-fallbacks` clears the remembered "last
|
|
171
|
+
* successful position option", so a re-show at a new point does not keep the previous flip
|
|
172
|
+
* (design 4.3). The first two options are order-independent (only one of them can fix a given
|
|
173
|
+
* overflow). A move that changes direction or pointer kind changes the list either way.
|
|
174
|
+
* Mouse and keyboard: below the point, flipping up and across; touch and pen: above it, flipping
|
|
175
|
+
* across and down (4.7).
|
|
176
|
+
*/
|
|
177
|
+
const MENU_POINT_FALLBACKS = {
|
|
178
|
+
ltr: {
|
|
179
|
+
mouse: ["--fsui-menu-up, --fsui-menu-left, --fsui-menu-up-left", "--fsui-menu-left, --fsui-menu-up, --fsui-menu-up-left"],
|
|
180
|
+
touch: ["--fsui-menu-left, --fsui-menu-down, --fsui-menu-down-left", "--fsui-menu-down, --fsui-menu-left, --fsui-menu-down-left"]
|
|
181
|
+
},
|
|
182
|
+
rtl: {
|
|
183
|
+
mouse: ["--fsui-menu-up, --fsui-menu-right, --fsui-menu-up-right", "--fsui-menu-right, --fsui-menu-up, --fsui-menu-up-right"],
|
|
184
|
+
touch: ["--fsui-menu-right, --fsui-menu-down, --fsui-menu-down-right", "--fsui-menu-down, --fsui-menu-right, --fsui-menu-down-right"]
|
|
185
|
+
}
|
|
186
|
+
};
|
|
13
187
|
//#endregion
|
|
14
|
-
export { POSITION_TRY_FALLBACKS, positionArea };
|
|
188
|
+
export { FSUI_PRECEDENCE, MENU_POINT_FALLBACKS, MENU_POINT_GAP, MENU_POINT_HREF, MENU_POINT_RULES, MENU_POINT_TOUCH_GAP, MENU_POINT_X, MENU_POINT_Y, POSITION_TRY_FALLBACKS, parsePositionArea, positionArea };
|
|
15
189
|
|
|
16
190
|
//# sourceMappingURL=anchor-position.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-position.mjs","names":[],"sources":["../../src/internal/anchor-position.ts"],"sourcesContent":["// Placement of a popover against its implicit anchor (the invoker set by `commandfor`,\n// `interestfor` or `showPopover({ source })`): inline `position-area` from a side and an\n// alignment, plus `position-try-fallbacks` that flip it when it does not fit. Shared by Tooltip,\n// Popover and Menu (design/components/tooltip.md 7.1, popover.md 8).\n//\n// No \"use client\" directive: pure functions, importable from anywhere (conventions 7.1).\n\n/** Physical side of the anchor the popup is placed on. */\nexport type AnchorSide = \"top\" | \"bottom\" | \"left\" | \"right\";\n/** Alignment along that side. */\nexport type AnchorAlign = \"start\" | \"center\" | \"end\";\n\n/** Flip to the opposite side, then the other axis, then both, when the popup does not fit. */\nexport const POSITION_TRY_FALLBACKS = \"flip-block, flip-inline, flip-block flip-inline\";\n\n/**\n * The `position-area` for a side and an alignment (physical keywords): `bottom` + `center` is\n * `bottom`, `bottom` + `start` is `bottom span-right`, `right` + `start` is `right span-bottom`,\n * and so on.\n */\nexport function positionArea(side: AnchorSide, align: AnchorAlign): string {\n if (align === \"center\") return side;\n const vertical = side === \"top\" || side === \"bottom\";\n const span = vertical\n ? align === \"start\"\n ? \"span-right\"\n : \"span-left\"\n : align === \"start\"\n ? \"span-bottom\"\n : \"span-top\";\n return `${side} ${span}`;\n}\n"],"mappings":";;AAaA,MAAa,yBAAyB;;;;;;AAOtC,SAAgB,aAAa,MAAkB,OAA4B;CACzE,IAAI,UAAU,UAAU,OAAO;CAS/B,OAAO,GAAG,KAAK,GARE,SAAS,SAAS,SAAS,WAExC,UAAU,UACR,eACA,cACF,UAAU,UACR,gBACA;AAER"}
|
|
1
|
+
{"version":3,"file":"anchor-position.mjs","names":[],"sources":["../../src/internal/anchor-position.ts"],"sourcesContent":["// Placement of a popover against its implicit anchor (the invoker set by `commandfor`,\n// `interestfor` or `showPopover({ source })`): inline `position-area` from a side and an\n// alignment, plus `position-try-fallbacks` that flip it when it does not fit; and the parser that\n// reads back which option the browser applied. Shared by Tooltip, Popover and Menu\n// (design/conventions.md 13; design/components/tooltip.md 7.1, popover.md 8).\n//\n// Keyword policy (conventions 13.1): physical keywords and the `self-*` group only. A plain\n// logical keyword (`block-end`, `span-inline-end`) on a top-layer popup resolves against the\n// root's writing mode, so it would ignore a `dir=\"rtl\"` container; `self-x-*` resolves against the\n// popup's own (inherited) direction. Keyword groups are never mixed in one value.\n//\n// No \"use client\" directive: pure functions, importable from anywhere (conventions 7.1).\n\n/** A physical side of the anchor. */\nexport type PhysicalSide = \"top\" | \"bottom\" | \"left\" | \"right\";\n/**\n * Side of the anchor the popup is placed on: physical, or inline-logical (`inline-start` /\n * `inline-end` follow the popup's own `direction` through the `self-x-*` keywords).\n */\nexport type AnchorSide = PhysicalSide | \"inline-start\" | \"inline-end\";\n/**\n * Alignment along that side: inline-relative on a `top` / `bottom` side (`start`: the popup's\n * inline-start edge meets the anchor's), the top / bottom edges on the others.\n */\nexport type AnchorAlign = \"start\" | \"center\" | \"end\";\n/** A computed `direction`. */\nexport type Direction = \"ltr\" | \"rtl\";\n\n/** Flip to the opposite side, then the other axis, then both, when the popup does not fit. */\nexport const POSITION_TRY_FALLBACKS = \"flip-block, flip-inline, flip-block flip-inline\";\n\nconst SIDE_KEYWORD: Record<AnchorSide, string> = {\n top: \"top\",\n bottom: \"bottom\",\n left: \"left\",\n right: \"right\",\n \"inline-start\": \"self-x-start\",\n \"inline-end\": \"self-x-end\",\n};\n\n/**\n * The `position-area` for a side and an alignment (the matrix of conventions 13.1):\n * `bottom` + `center` is `bottom`, `bottom` + `start` is `bottom span-self-x-end`, `right` +\n * `start` is `right span-bottom`, `inline-end` + `start` is `self-x-end span-bottom`.\n */\nexport function positionArea(side: AnchorSide, align: AnchorAlign): string {\n const keyword = SIDE_KEYWORD[side];\n if (align === \"center\") return keyword;\n const horizontal = side === \"top\" || side === \"bottom\";\n const span = horizontal\n ? align === \"start\"\n ? \"span-self-x-end\"\n : \"span-self-x-start\"\n : align === \"start\"\n ? \"span-bottom\"\n : \"span-top\";\n return `${keyword} ${span}`;\n}\n\n// --- Reading back the applied option (conventions 13.2) --------------------------------------\n\n/** Where the browser placed a popup: a physical side and the alignment along it. */\nexport interface ResolvedPlacement {\n readonly side: PhysicalSide;\n readonly align: AnchorAlign;\n}\n\ntype Axis = \"x\" | \"y\";\n\ninterface Token {\n /** `side`: the cell is on that side; `span`: spans toward a direction; `neutral`: neither. */\n readonly kind: \"side\" | \"span\" | \"neutral\";\n /** The physical direction of a `side` or `span` token. */\n readonly physical: PhysicalSide | null;\n}\n\nconst AXIS_OF: Record<PhysicalSide, Axis> = { top: \"y\", bottom: \"y\", left: \"x\", right: \"x\" };\n\n/**\n * Parses a computed `position-area` (conventions 13.2) into the physical side the popup sits on\n * and its alignment. Total: anything it cannot map returns `null` (`none`, an empty value, a\n * vertical `writing-mode`, a corner cell, the cell over the anchor, an unknown keyword), and the\n * part keeps the requested values. The engines serialise in grammar order, in any keyword group:\n * `span-left top`, `span-all bottom` (Firefox's form of a flipped `bottom`), `self-end\n * span-self-end`, `span-self-x-end bottom`, `self-x-start span-top`.\n *\n * `selfDirection` is the popup's computed `direction` (it resolves `self-*` tokens);\n * `rootDirection` the root's (plain `x-*` / `inline-*` tokens, which a consumer `style` override\n * may use), passed as a function so it is read only when such a token appears.\n */\nexport function parsePositionArea(\n value: string | null | undefined,\n selfDirection: Direction,\n rootDirection: Direction | (() => Direction),\n writingMode: string = \"horizontal-tb\",\n): ResolvedPlacement | null {\n if (writingMode !== \"horizontal-tb\" || typeof value !== \"string\") return null;\n const words = value.trim().split(/\\s+/);\n if (words.length > 2 || words[0] === \"\" || words[0] === \"none\") return null;\n let root: Direction | undefined;\n const rootDir = (): Direction =>\n (root ??= typeof rootDirection === \"function\" ? rootDirection() : rootDirection);\n\n const tokens: Token[] = [];\n for (let index = 0; index < words.length; index++) {\n const token = classify(words[index]!, index, words.length, selfDirection, rootDir);\n if (token === null) return null;\n tokens.push(token);\n }\n\n const sides = tokens.filter((t) => t.kind === \"side\");\n // No side (the cell over the anchor) or two (a corner): not a placement of the table.\n if (sides.length !== 1) return null;\n const side = sides[0]!.physical!;\n const span = tokens.find((t) => t.kind === \"span\");\n if (span === undefined) return { side, align: \"center\" };\n const toward = span.physical!;\n if (AXIS_OF[toward] === AXIS_OF[side]) return null;\n if (AXIS_OF[side] === \"y\") {\n // Inline-relative: spanning toward the popup's inline-end puts the inline-start edges\n // together.\n const inlineEnd: PhysicalSide = selfDirection === \"rtl\" ? \"left\" : \"right\";\n return { side, align: toward === inlineEnd ? \"start\" : \"end\" };\n }\n return { side, align: toward === \"bottom\" ? \"start\" : \"end\" };\n}\n\nfunction classify(\n word: string,\n index: number,\n count: number,\n selfDirection: Direction,\n rootDirection: () => Direction,\n): Token | null {\n if (word === \"center\" || word === \"span-all\") return { kind: \"neutral\", physical: null };\n const span = word.startsWith(\"span-\");\n const physical = physicalOf(\n span ? word.slice(5) : word,\n index,\n count,\n selfDirection,\n rootDirection,\n );\n return physical === null ? null : { kind: span ? \"span\" : \"side\", physical };\n}\n\n/**\n * The physical direction a keyword names, in `horizontal-tb`. Bare `start` / `end` /\n * `self-start` / `self-end` are positional: the block axis first, the inline axis second; alone\n * they name both axes (a corner, or a span over both), which the table does not describe.\n */\nfunction physicalOf(\n name: string,\n index: number,\n count: number,\n selfDirection: Direction,\n rootDirection: () => Direction,\n): PhysicalSide | null {\n switch (name) {\n case \"top\":\n case \"bottom\":\n case \"left\":\n case \"right\":\n return name;\n // The block axis is top / bottom in horizontal-tb, whatever the direction.\n case \"y-start\":\n case \"self-y-start\":\n case \"y-self-start\":\n case \"block-start\":\n case \"self-block-start\":\n return \"top\";\n case \"y-end\":\n case \"self-y-end\":\n case \"y-self-end\":\n case \"block-end\":\n case \"self-block-end\":\n return \"bottom\";\n // The inline axis against the popup's own direction.\n case \"self-x-start\":\n case \"x-self-start\":\n case \"self-inline-start\":\n return inlineEdge(\"start\", selfDirection);\n case \"self-x-end\":\n case \"x-self-end\":\n case \"self-inline-end\":\n return inlineEdge(\"end\", selfDirection);\n // The inline axis against the containing block's (the root's, for a top-layer popup).\n case \"x-start\":\n case \"inline-start\":\n return inlineEdge(\"start\", rootDirection());\n case \"x-end\":\n case \"inline-end\":\n return inlineEdge(\"end\", rootDirection());\n case \"start\":\n case \"end\":\n case \"self-start\":\n case \"self-end\": {\n if (count !== 2) return null;\n const edge = name.endsWith(\"start\") ? \"start\" : \"end\";\n if (index === 0) return edge === \"start\" ? \"top\" : \"bottom\";\n return inlineEdge(edge, name.startsWith(\"self-\") ? selfDirection : rootDirection());\n }\n default:\n return null;\n }\n}\n\nfunction inlineEdge(edge: \"start\" | \"end\", direction: Direction): PhysicalSide {\n return (edge === \"start\") === (direction === \"ltr\") ? \"left\" : \"right\";\n}\n\n// --- Placement at a point (design/components/context-menu.md 4.2, conventions 12, 13.4) -------\n\n/** Custom property carrying the x coordinate of a point-placed popup (viewport px). */\nexport const MENU_POINT_X = \"--menu-point-x\";\n/** Custom property carrying the y coordinate of a point-placed popup (viewport px). */\nexport const MENU_POINT_Y = \"--menu-point-y\";\n/**\n * Custom property carrying the vertical gap between the point and the menu: `0px` for a mouse or\n * keyboard open, `16px` for a touch or pen open, which is placed above the finger (#88, 4.7).\n */\nexport const MENU_POINT_GAP = \"--menu-point-gap\";\n/** The gap of a touch or pen open (context-menu.md 4.7). */\nexport const MENU_POINT_TOUCH_GAP = \"16px\";\n\n/** The dedupe key of the shipped rules (`<style href precedence>`). */\nexport const MENU_POINT_HREF = \"@funstack/ui/menu-point\";\n/**\n * The React stylesheet precedence bucket of the library's functional CSS. Fizz writes every\n * same-precedence `<style>` of one server flush as a single element with the texts concatenated,\n * which would match none of the per-href hashes in `STYLE_SHA256`: at most one shipped stylesheet\n * in this bucket may render during server rendering (today the tooltip skip-delay rule; the menu\n * point rules are client-only). A second one needs a precedence of its own (guard row in\n * `csp/csp.test.tsx`).\n */\nexport const FSUI_PRECEDENCE = \"fsui\";\n\nconst UP = `top: auto; bottom: calc(100% - var(${MENU_POINT_Y}) + var(${MENU_POINT_GAP}));`;\nconst DOWN = `bottom: auto; top: calc(var(${MENU_POINT_Y}) + var(${MENU_POINT_GAP}));`;\nconst LEFT = `left: auto; right: calc(100% - var(${MENU_POINT_X}));`;\nconst RIGHT = `right: auto; left: var(${MENU_POINT_X});`;\n\n/**\n * The `@position-try` options that mirror a point-placed popup around the point when it does not\n * fit (context-menu.md 4.2, conventions 12). The base position is inline on the popup: the\n * point's y below (mouse, keyboard) or above (touch, pen, with `--menu-point-gap`) the menu and,\n * by the popup's direction, its left (LTR) or right (RTL) edge at the point's x. A menu names the\n * three options that apply to its direction and pointer kind (`MENU_POINT_FALLBACKS`); the others\n * are inert. Functional at-rules with no selectors: no element is styled. `100%` resolves against\n * the viewport, the top layer's containing block, which `clientX` / `clientY` are measured in.\n * Its SHA-256 is `STYLE_SHA256` in `@funstack/ui/csp` (a jsdom row recomputes it).\n */\nexport const MENU_POINT_RULES =\n \"/* @funstack/ui: placement of a menu at a point. Functional only: the base position is inline \" +\n \"on the popup (below or above the point and, by direction, its left or right edge at the \" +\n \"point); these options mirror it around the point when it does not fit. */\\n\" +\n `@position-try --fsui-menu-up { ${UP} }\\n` +\n `@position-try --fsui-menu-down { ${DOWN} }\\n` +\n `@position-try --fsui-menu-left { ${LEFT} }\\n` +\n `@position-try --fsui-menu-right { ${RIGHT} }\\n` +\n `@position-try --fsui-menu-up-left { ${UP} ${LEFT} }\\n` +\n `@position-try --fsui-menu-up-right { ${UP} ${RIGHT} }\\n` +\n `@position-try --fsui-menu-down-left { ${DOWN} ${LEFT} }\\n` +\n `@position-try --fsui-menu-down-right { ${DOWN} ${RIGHT} }\\n`;\n\n/**\n * Two equivalent spellings of the point fallback list per direction and pointer kind\n * (`MENU_POINT_FALLBACKS[direction][offset ? \"touch\" : \"mouse\"][generation % 2]`), alternated by\n * the placement's generation: changing `position-try-fallbacks` clears the remembered \"last\n * successful position option\", so a re-show at a new point does not keep the previous flip\n * (design 4.3). The first two options are order-independent (only one of them can fix a given\n * overflow). A move that changes direction or pointer kind changes the list either way.\n * Mouse and keyboard: below the point, flipping up and across; touch and pen: above it, flipping\n * across and down (4.7).\n */\nexport const MENU_POINT_FALLBACKS = {\n ltr: {\n mouse: [\n \"--fsui-menu-up, --fsui-menu-left, --fsui-menu-up-left\",\n \"--fsui-menu-left, --fsui-menu-up, --fsui-menu-up-left\",\n ],\n touch: [\n \"--fsui-menu-left, --fsui-menu-down, --fsui-menu-down-left\",\n \"--fsui-menu-down, --fsui-menu-left, --fsui-menu-down-left\",\n ],\n },\n rtl: {\n mouse: [\n \"--fsui-menu-up, --fsui-menu-right, --fsui-menu-up-right\",\n \"--fsui-menu-right, --fsui-menu-up, --fsui-menu-up-right\",\n ],\n touch: [\n \"--fsui-menu-right, --fsui-menu-down, --fsui-menu-down-right\",\n \"--fsui-menu-down, --fsui-menu-right, --fsui-menu-down-right\",\n ],\n },\n} as const;\n"],"mappings":";;AA6BA,MAAa,yBAAyB;AAEtC,MAAM,eAA2C;CAC/C,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACP,gBAAgB;CAChB,cAAc;AAChB;;;;;;AAOA,SAAgB,aAAa,MAAkB,OAA4B;CACzE,MAAM,UAAU,aAAa;CAC7B,IAAI,UAAU,UAAU,OAAO;CAS/B,OAAO,GAAG,QAAQ,GARC,SAAS,SAAS,SAAS,WAE1C,UAAU,UACR,oBACA,sBACF,UAAU,UACR,gBACA;AAER;AAmBA,MAAM,UAAsC;CAAE,KAAK;CAAK,QAAQ;CAAK,MAAM;CAAK,OAAO;AAAI;;;;;;;;;;;;;AAc3F,SAAgB,kBACd,OACA,eACA,eACA,cAAsB,iBACI;CAC1B,IAAI,gBAAgB,mBAAmB,OAAO,UAAU,UAAU,OAAO;CACzE,MAAM,QAAQ,MAAM,KAAK,CAAC,CAAC,MAAM,KAAK;CACtC,IAAI,MAAM,SAAS,KAAK,MAAM,OAAO,MAAM,MAAM,OAAO,QAAQ,OAAO;CACvE,IAAI;CACJ,MAAM,gBACH,SAAS,OAAO,kBAAkB,aAAa,cAAc,IAAI;CAEpE,MAAM,SAAkB,CAAC;CACzB,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,QAAQ,SAAS,MAAM,QAAS,OAAO,MAAM,QAAQ,eAAe,OAAO;EACjF,IAAI,UAAU,MAAM,OAAO;EAC3B,OAAO,KAAK,KAAK;CACnB;CAEA,MAAM,QAAQ,OAAO,QAAQ,MAAM,EAAE,SAAS,MAAM;CAEpD,IAAI,MAAM,WAAW,GAAG,OAAO;CAC/B,MAAM,OAAO,MAAM,EAAE,CAAE;CACvB,MAAM,OAAO,OAAO,MAAM,MAAM,EAAE,SAAS,MAAM;CACjD,IAAI,SAAS,KAAA,GAAW,OAAO;EAAE;EAAM,OAAO;CAAS;CACvD,MAAM,SAAS,KAAK;CACpB,IAAI,QAAQ,YAAY,QAAQ,OAAO,OAAO;CAC9C,IAAI,QAAQ,UAAU,KAIpB,OAAO;EAAE;EAAM,OAAO,YADU,kBAAkB,QAAQ,SAAS,WACtB,UAAU;CAAM;CAE/D,OAAO;EAAE;EAAM,OAAO,WAAW,WAAW,UAAU;CAAM;AAC9D;AAEA,SAAS,SACP,MACA,OACA,OACA,eACA,eACc;CACd,IAAI,SAAS,YAAY,SAAS,YAAY,OAAO;EAAE,MAAM;EAAW,UAAU;CAAK;CACvF,MAAM,OAAO,KAAK,WAAW,OAAO;CACpC,MAAM,WAAW,WACf,OAAO,KAAK,MAAM,CAAC,IAAI,MACvB,OACA,OACA,eACA,aACF;CACA,OAAO,aAAa,OAAO,OAAO;EAAE,MAAM,OAAO,SAAS;EAAQ;CAAS;AAC7E;;;;;;AAOA,SAAS,WACP,MACA,OACA,OACA,eACA,eACqB;CACrB,QAAQ,MAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,SACH,OAAO;EAET,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,oBACH,OAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,kBACH,OAAO;EAET,KAAK;EACL,KAAK;EACL,KAAK,qBACH,OAAO,WAAW,SAAS,aAAa;EAC1C,KAAK;EACL,KAAK;EACL,KAAK,mBACH,OAAO,WAAW,OAAO,aAAa;EAExC,KAAK;EACL,KAAK,gBACH,OAAO,WAAW,SAAS,cAAc,CAAC;EAC5C,KAAK;EACL,KAAK,cACH,OAAO,WAAW,OAAO,cAAc,CAAC;EAC1C,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,YAAY;GACf,IAAI,UAAU,GAAG,OAAO;GACxB,MAAM,OAAO,KAAK,SAAS,OAAO,IAAI,UAAU;GAChD,IAAI,UAAU,GAAG,OAAO,SAAS,UAAU,QAAQ;GACnD,OAAO,WAAW,MAAM,KAAK,WAAW,OAAO,IAAI,gBAAgB,cAAc,CAAC;EACpF;EACA,SACE,OAAO;CACX;AACF;AAEA,SAAS,WAAW,MAAuB,WAAoC;CAC7E,OAAQ,SAAS,aAAc,cAAc,SAAS,SAAS;AACjE;;AAKA,MAAa,eAAe;;AAE5B,MAAa,eAAe;;;;;AAK5B,MAAa,iBAAiB;;AAE9B,MAAa,uBAAuB;;AAGpC,MAAa,kBAAkB;;;;;;;;;AAS/B,MAAa,kBAAkB;AAE/B,MAAM,KAAK,sCAAsC,aAAa,UAAU,eAAe;AACvF,MAAM,OAAO,+BAA+B,aAAa,UAAU,eAAe;AAClF,MAAM,OAAO,sCAAsC,aAAa;AAChE,MAAM,QAAQ,0BAA0B,aAAa;;;;;;;;;;;AAYrD,MAAa,mBACX;iCAGkC,GAAG,uCACD,KAAK,uCACL,KAAK,wCACJ,MAAM,0CACJ,GAAG,GAAG,KAAK,2CACV,GAAG,GAAG,MAAM,4CACX,KAAK,GAAG,KAAK,6CACZ,KAAK,GAAG,MAAM;;;;;;;;;;;AAY1D,MAAa,uBAAuB;CAClC,KAAK;EACH,OAAO,CACL,yDACA,uDACF;EACA,OAAO,CACL,6DACA,2DACF;CACF;CACA,KAAK;EACH,OAAO,CACL,2DACA,yDACF;EACA,OAAO,CACL,+DACA,6DACF;CACF;AACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region src/internal/announce.ts
|
|
3
|
+
/** How long the fallback region keeps a message before it is cleared, so a repeat is spoken. */
|
|
4
|
+
const ANNOUNCE_CLEAR_DELAY = 1e3;
|
|
5
|
+
const REGION_STYLE = "position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap;";
|
|
6
|
+
let region = null;
|
|
7
|
+
let clearTimer;
|
|
8
|
+
let writeTimer;
|
|
9
|
+
function liveRegion(doc) {
|
|
10
|
+
if (region !== null && region.isConnected && region.ownerDocument === doc) return region;
|
|
11
|
+
const el = doc.createElement("div");
|
|
12
|
+
el.setAttribute("role", "status");
|
|
13
|
+
el.setAttribute("aria-live", "polite");
|
|
14
|
+
el.setAttribute("aria-atomic", "true");
|
|
15
|
+
el.setAttribute("data-fsui-announcer", "");
|
|
16
|
+
el.setAttribute("style", REGION_STYLE);
|
|
17
|
+
doc.body.append(el);
|
|
18
|
+
region = el;
|
|
19
|
+
return el;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Speaks `message` in the context of `element`: `element.ariaNotify(message)` where it exists,
|
|
23
|
+
* else the fallback live region (inserted on first use, cleared, then written
|
|
24
|
+
* `ANNOUNCE_WRITE_DELAY` ms later and cleared again after `ANNOUNCE_CLEAR_DELAY`). An empty
|
|
25
|
+
* message announces nothing; a newer message replaces one not yet written.
|
|
26
|
+
*/
|
|
27
|
+
function announce(element, message) {
|
|
28
|
+
if (message === "") return;
|
|
29
|
+
const notifying = element;
|
|
30
|
+
if (typeof notifying.ariaNotify === "function") {
|
|
31
|
+
notifying.ariaNotify(message);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const doc = element.ownerDocument;
|
|
35
|
+
if (doc.body === null) return;
|
|
36
|
+
const el = liveRegion(doc);
|
|
37
|
+
el.textContent = "";
|
|
38
|
+
if (clearTimer !== void 0) clearTimeout(clearTimer);
|
|
39
|
+
if (writeTimer !== void 0) clearTimeout(writeTimer);
|
|
40
|
+
clearTimer = void 0;
|
|
41
|
+
writeTimer = setTimeout(() => {
|
|
42
|
+
writeTimer = void 0;
|
|
43
|
+
el.textContent = message;
|
|
44
|
+
clearTimer = setTimeout(() => {
|
|
45
|
+
clearTimer = void 0;
|
|
46
|
+
el.textContent = "";
|
|
47
|
+
}, ANNOUNCE_CLEAR_DELAY);
|
|
48
|
+
}, 100);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { ANNOUNCE_CLEAR_DELAY, announce };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=announce.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announce.mjs","names":[],"sources":["../../src/internal/announce.ts"],"sourcesContent":["\"use client\";\n// Screen-reader announcements (design/components/number-field.md 8.3, conventions 8): through\n// `ariaNotify()` where the engine has it, otherwise through one module-level, visually hidden\n// `role=\"status\"` live region appended to `document.body` on first use. No part renders a live\n// region of its own for these announcements.\n\ntype NotifyingElement = Element & { ariaNotify?: (announcement: string) => void };\n\n/** How long the fallback region keeps a message before it is cleared, so a repeat is spoken. */\nexport const ANNOUNCE_CLEAR_DELAY = 1000;\n\nconst REGION_STYLE =\n \"position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; \" +\n \"overflow: hidden; clip-path: inset(50%); white-space: nowrap;\";\n\n/**\n * The delay between clearing the region and writing a message. A region inserted in the same task\n * as its first message is skipped by some screen readers, and an unchanged text is not spoken\n * again; clearing first and writing a tick later makes every message a fresh change.\n */\nexport const ANNOUNCE_WRITE_DELAY = 100;\n\nlet region: HTMLElement | null = null;\nlet clearTimer: ReturnType<typeof setTimeout> | undefined;\nlet writeTimer: ReturnType<typeof setTimeout> | undefined;\n\nfunction liveRegion(doc: Document): HTMLElement {\n if (region !== null && region.isConnected && region.ownerDocument === doc) return region;\n const el = doc.createElement(\"div\");\n el.setAttribute(\"role\", \"status\");\n el.setAttribute(\"aria-live\", \"polite\");\n el.setAttribute(\"aria-atomic\", \"true\");\n el.setAttribute(\"data-fsui-announcer\", \"\");\n el.setAttribute(\"style\", REGION_STYLE);\n doc.body.append(el);\n region = el;\n return el;\n}\n\n/**\n * Speaks `message` in the context of `element`: `element.ariaNotify(message)` where it exists,\n * else the fallback live region (inserted on first use, cleared, then written\n * `ANNOUNCE_WRITE_DELAY` ms later and cleared again after `ANNOUNCE_CLEAR_DELAY`). An empty\n * message announces nothing; a newer message replaces one not yet written.\n */\nexport function announce(element: Element, message: string): void {\n if (message === \"\") return;\n const notifying = element as NotifyingElement;\n if (typeof notifying.ariaNotify === \"function\") {\n notifying.ariaNotify(message);\n return;\n }\n const doc = element.ownerDocument;\n if (doc.body === null) return;\n const el = liveRegion(doc);\n el.textContent = \"\";\n if (clearTimer !== undefined) clearTimeout(clearTimer);\n if (writeTimer !== undefined) clearTimeout(writeTimer);\n clearTimer = undefined;\n writeTimer = setTimeout(() => {\n writeTimer = undefined;\n el.textContent = message;\n clearTimer = setTimeout(() => {\n clearTimer = undefined;\n el.textContent = \"\";\n }, ANNOUNCE_CLEAR_DELAY);\n }, ANNOUNCE_WRITE_DELAY);\n}\n"],"mappings":";;;AASA,MAAa,uBAAuB;AAEpC,MAAM,eACJ;AAUF,IAAI,SAA6B;AACjC,IAAI;AACJ,IAAI;AAEJ,SAAS,WAAW,KAA4B;CAC9C,IAAI,WAAW,QAAQ,OAAO,eAAe,OAAO,kBAAkB,KAAK,OAAO;CAClF,MAAM,KAAK,IAAI,cAAc,KAAK;CAClC,GAAG,aAAa,QAAQ,QAAQ;CAChC,GAAG,aAAa,aAAa,QAAQ;CACrC,GAAG,aAAa,eAAe,MAAM;CACrC,GAAG,aAAa,uBAAuB,EAAE;CACzC,GAAG,aAAa,SAAS,YAAY;CACrC,IAAI,KAAK,OAAO,EAAE;CAClB,SAAS;CACT,OAAO;AACT;;;;;;;AAQA,SAAgB,SAAS,SAAkB,SAAuB;CAChE,IAAI,YAAY,IAAI;CACpB,MAAM,YAAY;CAClB,IAAI,OAAO,UAAU,eAAe,YAAY;EAC9C,UAAU,WAAW,OAAO;EAC5B;CACF;CACA,MAAM,MAAM,QAAQ;CACpB,IAAI,IAAI,SAAS,MAAM;CACvB,MAAM,KAAK,WAAW,GAAG;CACzB,GAAG,cAAc;CACjB,IAAI,eAAe,KAAA,GAAW,aAAa,UAAU;CACrD,IAAI,eAAe,KAAA,GAAW,aAAa,UAAU;CACrD,aAAa,KAAA;CACb,aAAa,iBAAiB;EAC5B,aAAa,KAAA;EACb,GAAG,cAAc;EACjB,aAAa,iBAAiB;GAC5B,aAAa,KAAA;GACb,GAAG,cAAc;EACnB,GAAG,oBAAoB;CACzB,GAAA,GAAuB;AACzB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/internal/content-focus-probe.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Records, from its layout-effect cleanup, whether focus is inside the popup when the content
|
|
7
|
+
* goes away: React runs a deleted component's layout cleanups before it detaches the host nodes,
|
|
8
|
+
* so `document.activeElement` still names the focused element there.
|
|
9
|
+
*/
|
|
10
|
+
function ContentFocusProbe({ onDetach, children }) {
|
|
11
|
+
useLayoutEffect(() => onDetach, [onDetach]);
|
|
12
|
+
return children;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The content probe shared by the popover-like Popups (Popover, Menu) and Dialog.Popup: a
|
|
16
|
+
* library-driven close with `transition` unmounts the content, the focused Close part included,
|
|
17
|
+
* in the close commit, before the layout effect that hides the popup runs, so focus falls to
|
|
18
|
+
* `<body>` and the platform may restore nothing. The probe tells the owner that this happened.
|
|
19
|
+
*/
|
|
20
|
+
function useContentFocusProbe(popupRef) {
|
|
21
|
+
const lostFocus = useRef(false);
|
|
22
|
+
const record = useCallback(() => {
|
|
23
|
+
const element = popupRef.current;
|
|
24
|
+
if (element === null) return;
|
|
25
|
+
const active = element.ownerDocument.activeElement;
|
|
26
|
+
if (active !== null && active !== element && element.contains(active)) lostFocus.current = true;
|
|
27
|
+
}, [popupRef]);
|
|
28
|
+
return {
|
|
29
|
+
wrapContent: useCallback((children) => /* @__PURE__ */ jsx(ContentFocusProbe, {
|
|
30
|
+
onDetach: record,
|
|
31
|
+
children
|
|
32
|
+
}), [record]),
|
|
33
|
+
hadFocus: useCallback(() => lostFocus.current, []),
|
|
34
|
+
forget: useCallback(() => {
|
|
35
|
+
lostFocus.current = false;
|
|
36
|
+
}, [])
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { useContentFocusProbe };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=content-focus-probe.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-focus-probe.mjs","names":[],"sources":["../../src/internal/content-focus-probe.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useLayoutEffect, useRef } from \"react\";\nimport type { ReactNode, RefObject } from \"react\";\n\n/**\n * Records, from its layout-effect cleanup, whether focus is inside the popup when the content\n * goes away: React runs a deleted component's layout cleanups before it detaches the host nodes,\n * so `document.activeElement` still names the focused element there.\n */\nfunction ContentFocusProbe({\n onDetach,\n children,\n}: {\n onDetach: () => void;\n children?: ReactNode;\n}): ReactNode {\n useLayoutEffect(() => onDetach, [onDetach]);\n return children;\n}\n\nexport interface ContentFocusProbeHook {\n /**\n * Wraps the library-mode content of a top-layer popup: call it only while the content is\n * shown (`visible ? wrapContent(x) : null`), or inside the `<Activity>` for `keepMounted`.\n */\n readonly wrapContent: (children: ReactNode) => ReactNode;\n /**\n * Whether the wrapped content unmounted (or was hidden by `<Activity>`) while it held focus\n * since the last `forget()`. The owner reads it after its close\n * (design/components/popover.md 6.2 rule 2, design/components/dialog.md 6.2 rule 2).\n * Handlers and effects only.\n */\n readonly hadFocus: () => boolean;\n /**\n * Clear the record: on every open, after the owner used it, and whenever the content went\n * away while the popup stays open (not a close).\n */\n readonly forget: () => void;\n}\n\n/**\n * The content probe shared by the popover-like Popups (Popover, Menu) and Dialog.Popup: a\n * library-driven close with `transition` unmounts the content, the focused Close part included,\n * in the close commit, before the layout effect that hides the popup runs, so focus falls to\n * `<body>` and the platform may restore nothing. The probe tells the owner that this happened.\n */\nexport function useContentFocusProbe(\n popupRef: RefObject<HTMLElement | null>,\n): ContentFocusProbeHook {\n const lostFocus = useRef(false);\n\n const record = useCallback(() => {\n const element = popupRef.current;\n if (element === null) return;\n const active = element.ownerDocument.activeElement;\n if (active !== null && active !== element && element.contains(active)) {\n lostFocus.current = true;\n }\n }, [popupRef]);\n\n const wrapContent = useCallback(\n (children: ReactNode): ReactNode => (\n <ContentFocusProbe onDetach={record}>{children}</ContentFocusProbe>\n ),\n [record],\n );\n const hadFocus = useCallback(() => lostFocus.current, []);\n const forget = useCallback(() => {\n lostFocus.current = false;\n }, []);\n\n return { wrapContent, hadFocus, forget };\n}\n"],"mappings":";;;;;;;;;AASA,SAAS,kBAAkB,EACzB,UACA,YAIY;CACZ,sBAAsB,UAAU,CAAC,QAAQ,CAAC;CAC1C,OAAO;AACT;;;;;;;AA4BA,SAAgB,qBACd,UACuB;CACvB,MAAM,YAAY,OAAO,KAAK;CAE9B,MAAM,SAAS,kBAAkB;EAC/B,MAAM,UAAU,SAAS;EACzB,IAAI,YAAY,MAAM;EACtB,MAAM,SAAS,QAAQ,cAAc;EACrC,IAAI,WAAW,QAAQ,WAAW,WAAW,QAAQ,SAAS,MAAM,GAClE,UAAU,UAAU;CAExB,GAAG,CAAC,QAAQ,CAAC;CAab,OAAO;EAAE,aAXW,aACjB,aACC,oBAAC,mBAAD;GAAmB,UAAU;GAAS;EAA4B,CAAA,GAEpE,CAAC,MAAM,CAOU;EAAG,UALL,kBAAkB,UAAU,SAAS,CAAC,CAK1B;EAAG,QAJjB,kBAAkB;GAC/B,UAAU,UAAU;EACtB,GAAG,CAAC,CAEiC;CAAE;AACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csp-context.mjs","names":[],"sources":["../../src/internal/csp-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext } from \"react\";\n\n/** What `<CSPProvider>` gives the parts that render a hoisted `<style>` (conventions 12). */\nexport interface CSPContextValue {\n /** Forwarded as the `nonce` of every library `<style>`. */\n readonly nonce: string | undefined;\n}\n\nexport const CSPContext = createContext<CSPContextValue | null>(null);\n"],"mappings":";;;AASA,MAAa,aAAa,cAAsC,IAAI"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/internal/decimal.ts
|
|
2
|
+
/** Number of decimal places of `n` as written (`0.1` → 1, `1e-7` → 7, `5` → 0). */
|
|
3
|
+
function decimalsOf(n) {
|
|
4
|
+
if (!Number.isFinite(n)) return 0;
|
|
5
|
+
const text = String(n);
|
|
6
|
+
const exponent = /e-(\d+)$/i.exec(text);
|
|
7
|
+
if (exponent !== null) {
|
|
8
|
+
const mantissa = text.slice(0, exponent.index);
|
|
9
|
+
const dot = mantissa.indexOf(".");
|
|
10
|
+
return Number(exponent[1]) + (dot === -1 ? 0 : mantissa.length - dot - 1);
|
|
11
|
+
}
|
|
12
|
+
const dot = text.indexOf(".");
|
|
13
|
+
return dot === -1 ? 0 : text.length - dot - 1;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `value` rounded to `decimals` places through `toFixed` (decimal, not binary, rounding of the
|
|
17
|
+
* written digits: `roundTo(0.1 + 0.2, 1)` is `0.3`). `-0` becomes `0`.
|
|
18
|
+
*/
|
|
19
|
+
function roundTo(value, decimals) {
|
|
20
|
+
if (!Number.isFinite(value)) return value;
|
|
21
|
+
const result = decimals <= 0 ? Math.round(value) : Number(value.toFixed(Math.min(decimals, 100)));
|
|
22
|
+
return result === 0 ? 0 : result;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { decimalsOf, roundTo };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=decimal.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal.mjs","names":[],"sources":["../../src/internal/decimal.ts"],"sourcesContent":["// Decimal helpers shared by Slider and NumberField (design/components/number-field.md 5.4). No\n// directive: no React, no client-only API.\n\n/** Number of decimal places of `n` as written (`0.1` → 1, `1e-7` → 7, `5` → 0). */\nexport function decimalsOf(n: number): number {\n if (!Number.isFinite(n)) return 0;\n const text = String(n);\n const exponent = /e-(\\d+)$/i.exec(text);\n if (exponent !== null) {\n const mantissa = text.slice(0, exponent.index);\n const dot = mantissa.indexOf(\".\");\n return Number(exponent[1]) + (dot === -1 ? 0 : mantissa.length - dot - 1);\n }\n const dot = text.indexOf(\".\");\n return dot === -1 ? 0 : text.length - dot - 1;\n}\n\n/**\n * `value` rounded to `decimals` places through `toFixed` (decimal, not binary, rounding of the\n * written digits: `roundTo(0.1 + 0.2, 1)` is `0.3`). `-0` becomes `0`.\n */\nexport function roundTo(value: number, decimals: number): number {\n if (!Number.isFinite(value)) return value;\n // `toFixed` takes at most 100 digits; anything near that is already exact.\n const result = decimals <= 0 ? Math.round(value) : Number(value.toFixed(Math.min(decimals, 100)));\n return result === 0 ? 0 : result;\n}\n"],"mappings":";;AAIA,SAAgB,WAAW,GAAmB;CAC5C,IAAI,CAAC,OAAO,SAAS,CAAC,GAAG,OAAO;CAChC,MAAM,OAAO,OAAO,CAAC;CACrB,MAAM,WAAW,YAAY,KAAK,IAAI;CACtC,IAAI,aAAa,MAAM;EACrB,MAAM,WAAW,KAAK,MAAM,GAAG,SAAS,KAAK;EAC7C,MAAM,MAAM,SAAS,QAAQ,GAAG;EAChC,OAAO,OAAO,SAAS,EAAE,KAAK,QAAQ,KAAK,IAAI,SAAS,SAAS,MAAM;CACzE;CACA,MAAM,MAAM,KAAK,QAAQ,GAAG;CAC5B,OAAO,QAAQ,KAAK,IAAI,KAAK,SAAS,MAAM;AAC9C;;;;;AAMA,SAAgB,QAAQ,OAAe,UAA0B;CAC/D,IAAI,CAAC,OAAO,SAAS,KAAK,GAAG,OAAO;CAEpC,MAAM,SAAS,YAAY,IAAI,KAAK,MAAM,KAAK,IAAI,OAAO,MAAM,QAAQ,KAAK,IAAI,UAAU,GAAG,CAAC,CAAC;CAChG,OAAO,WAAW,IAAI,IAAI;AAC5B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/internal/dev-warn.ts
|
|
2
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
3
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4
|
+
/**
|
|
5
|
+
* Logs `message` through `console.error` once per `key` in development. Called during render,
|
|
6
|
+
* so a discarded render may warn; keys name the part and the condition (a Server Component has
|
|
7
|
+
* no element identity to key on).
|
|
8
|
+
*/
|
|
9
|
+
function warnOnce(key, message) {
|
|
10
|
+
if (!isDev || seen.has(key)) return;
|
|
11
|
+
seen.add(key);
|
|
12
|
+
console.error(message);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { warnOnce };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=dev-warn.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-warn.mjs","names":[],"sources":["../../src/internal/dev-warn.ts"],"sourcesContent":["// No \"use client\": usable during the render of a directive-free part that may run as a Server\n// Component, where an effect (`useDevWarning`) never runs (design/components/progress.md 8.1,\n// implementation note 14.3).\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nconst seen = new Set<string>();\n\n/**\n * Logs `message` through `console.error` once per `key` in development. Called during render,\n * so a discarded render may warn; keys name the part and the condition (a Server Component has\n * no element identity to key on).\n */\nexport function warnOnce(key: string, message: string): void {\n if (!isDev || seen.has(key)) return;\n seen.add(key);\n console.error(message);\n}\n\n/** Tests only: forget every key, so the next `warnOnce` warns again. */\nexport function resetWarnOnce(): void {\n seen.clear();\n}\n"],"mappings":";AAIA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,MAAM,uBAAO,IAAI,IAAY;;;;;;AAO7B,SAAgB,SAAS,KAAa,SAAuB;CAC3D,IAAI,CAAC,SAAS,KAAK,IAAI,GAAG,GAAG;CAC7B,KAAK,IAAI,GAAG;CACZ,QAAQ,MAAM,OAAO;AACvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FieldValidity } from "./validity.mjs";
|
|
2
|
+
//#region src/internal/field-context.d.ts
|
|
3
|
+
/** The state every Field part receives (design/components/field-form.md 4.1). */
|
|
4
|
+
export interface FieldState {
|
|
5
|
+
/** An error is shown: the control matches `:user-invalid`, or a server error for this field is shown. */
|
|
6
|
+
readonly invalid: boolean;
|
|
7
|
+
/** The messages shown: `[validationMessage]` for a native constraint, the strings `validate` returned for a custom one, the server's strings for a server error; `[]` while valid. */
|
|
8
|
+
readonly messages: readonly string[];
|
|
9
|
+
/** A snapshot of the control's `ValidityState` (all valid on the server and before the first read). */
|
|
10
|
+
readonly validity: FieldValidity;
|
|
11
|
+
/** `Field.Root disabled` or the control's own `disabled`. */
|
|
12
|
+
readonly disabled: boolean;
|
|
13
|
+
/** `Field.Root required` or the control's own `required`. */
|
|
14
|
+
readonly required: boolean;
|
|
15
|
+
/** The enclosing form's submission is in flight (`useFormStatus().pending`); `false` outside a form. */
|
|
16
|
+
readonly pending: boolean;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//# sourceMappingURL=field-context.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-context.d.mts","names":[],"sources":["../../src/internal/field-context.ts"],"mappings":";;;iBAKiB;;WAEN;;WAEA;;WAEA,UAAU;;WAEV;;WAEA;;WAEA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, use } from "react";
|
|
3
|
+
//#region src/internal/field-context.ts
|
|
4
|
+
const FieldContext = createContext(null);
|
|
5
|
+
function useFieldContext(part) {
|
|
6
|
+
const ctx = use(FieldContext);
|
|
7
|
+
if (ctx === null) throw new Error(`${part} must be rendered inside a Field.Root.`);
|
|
8
|
+
return ctx;
|
|
9
|
+
}
|
|
10
|
+
const FormContext = createContext(null);
|
|
11
|
+
//#endregion
|
|
12
|
+
export { FieldContext, FormContext, useFieldContext };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=field-context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-context.mjs","names":[],"sources":["../../src/internal/field-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { FieldValidity, FormErrors, ValidatableElement } from \"./validity.js\";\n\n/** The state every Field part receives (design/components/field-form.md 4.1). */\nexport interface FieldState {\n /** An error is shown: the control matches `:user-invalid`, or a server error for this field is shown. */\n readonly invalid: boolean;\n /** The messages shown: `[validationMessage]` for a native constraint, the strings `validate` returned for a custom one, the server's strings for a server error; `[]` while valid. */\n readonly messages: readonly string[];\n /** A snapshot of the control's `ValidityState` (all valid on the server and before the first read). */\n readonly validity: FieldValidity;\n /** `Field.Root disabled` or the control's own `disabled`. */\n readonly disabled: boolean;\n /** `Field.Root required` or the control's own `required`. */\n readonly required: boolean;\n /** The enclosing form's submission is in flight (`useFormStatus().pending`); `false` outside a form. */\n readonly pending: boolean;\n}\n\nexport interface FieldIds {\n readonly control: string;\n readonly label: string;\n readonly description: string;\n readonly error: string;\n}\n\n/** What a control reports to its Field (design 7.1). */\nexport interface FieldControlRegistration {\n /** The element the Field labels, describes and listens to (the input, or a group's fieldset). */\n readonly element: HTMLElement;\n /** `<label for>` can target it. Groups report `false`. */\n readonly labelable: boolean;\n /** The control's own `required` / `disabled` props (for the Field's `data-*` state). */\n readonly required: boolean;\n readonly disabled: boolean;\n /**\n * Where `validity`, `validationMessage` and the custom-validity slot are read and written when\n * that is not the registered element (NumberField: the hidden `input[type=number]` after the\n * visible text input). `:user-invalid`, the listeners and the focus target stay on `element`;\n * after writing the slot the Field mirrors this element's `validationMessage` into `element`\n * (design/components/field-form.md, amendment `validityElement`). Resolved on every read.\n */\n readonly validityElement?: (() => ValidatableElement | null) | undefined;\n}\n\nexport interface FieldContextValue {\n readonly ids: FieldIds;\n /** `Field.Root name`. */\n readonly name: string | undefined;\n /** `Field.Root disabled` / `required` (the props, not the merged state). */\n readonly disabled: boolean;\n readonly required: boolean;\n readonly state: FieldState;\n /** The registered control is labelable (default `true`, also before any registration). */\n readonly labelable: boolean;\n /** Registers the Field's control; returns the unregister function. The first one wins. */\n readonly registerControl: (registration: FieldControlRegistration) => () => void;\n /** A `Field.Error` is mounted (the Field may cancel the platform bubble). */\n readonly registerError: () => () => void;\n /**\n * The control's value changed in the DOM without an `input` / `change` event the Field could\n * hear (a Combobox selection, a CheckboxGroup's derived `required`, a rolled-back optimistic\n * value): re-reads the slot and the mirror after the commit that wrote it, and refreshes the\n * other Fields of the `Form.Root` (cross-field rules). `edit`: the user made the change, so a\n * shown server error is dismissed as by an `input` event. Call from a layout effect.\n */\n readonly notifyChange: (edit: boolean) => void;\n}\n\nexport const FieldContext = createContext<FieldContextValue | null>(null);\n\nexport function useFieldContext(part: string): FieldContextValue {\n const ctx = use(FieldContext);\n if (ctx === null) throw new Error(`${part} must be rendered inside a Field.Root.`);\n return ctx;\n}\n\n/** What a Field registers with its Form (design 3.5). */\nexport interface FormFieldRegistration {\n /** The control, or a group's first enabled (or checked) member. */\n readonly getFocusTarget: () => HTMLElement | null;\n /** The Field shows a server error at the latest commit. */\n readonly showsServerError: () => boolean;\n /** The server messages shown, for an announcement when focus does not move. */\n readonly serverMessages: () => readonly string[];\n /** Re-runs `validate` and re-reads validity (another Field's control changed). */\n readonly refresh: () => void;\n}\n\nexport interface FormContextValue {\n readonly errors: FormErrors | undefined;\n readonly registerField: (registration: FormFieldRegistration) => () => void;\n /**\n * The `FormData` of the submission in flight when the Form ran it itself (the intercepted path),\n * else `null`: the stale-value suppression of design 3.2 item 2 is computed against it.\n */\n readonly submittedData: () => FormData | null;\n /** Refreshes every registered Field except `source` (a change no DOM event carried). */\n readonly refreshFields: (source: FormFieldRegistration | null) => void;\n}\n\nexport const FormContext = createContext<FormContextValue | null>(null);\n"],"mappings":";;;AAsEA,MAAa,eAAe,cAAwC,IAAI;AAExE,SAAgB,gBAAgB,MAAiC;CAC/D,MAAM,MAAM,IAAI,YAAY;CAC5B,IAAI,QAAQ,MAAM,MAAM,IAAI,MAAM,GAAG,KAAK,uCAAuC;CACjF,OAAO;AACT;AA0BA,MAAa,cAAc,cAAuC,IAAI"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { sortByDocumentOrder } from "./validity.mjs";
|
|
2
|
+
//#region src/internal/focus-first-invalid.ts
|
|
3
|
+
/**
|
|
4
|
+
* Speaks `message` through `element.ariaNotify()` where the browser has it (design 5.3: the
|
|
5
|
+
* error is read when focus moves to the control; when focus is already there nothing would be
|
|
6
|
+
* read). Does nothing without `ariaNotify` or with an empty message.
|
|
7
|
+
*/
|
|
8
|
+
function announce(element, message) {
|
|
9
|
+
const notifying = element;
|
|
10
|
+
if (message === "" || typeof notifying.ariaNotify !== "function") return;
|
|
11
|
+
notifying.ariaNotify(message);
|
|
12
|
+
}
|
|
13
|
+
/** The submission attempt in progress: every target added during the current task. */
|
|
14
|
+
let batch = null;
|
|
15
|
+
/**
|
|
16
|
+
* Adds a control whose `invalid` event a Field cancelled during a submission attempt, and
|
|
17
|
+
* focuses the first collected control in document order in a microtask, so the result does not
|
|
18
|
+
* depend on the browser's dispatch order or on how many forms are on the page.
|
|
19
|
+
*
|
|
20
|
+
* The batch lives until the end of the task (a `setTimeout`), not just one microtask: when the
|
|
21
|
+
* browser dispatches the `invalid` events itself (a click on a submit button), it runs a
|
|
22
|
+
* microtask checkpoint after each listener, so the microtask of the first event runs before the
|
|
23
|
+
* second event fires. Every add therefore queues a focus of the batch's first target; later ones
|
|
24
|
+
* re-focus the same element, which is a no-op.
|
|
25
|
+
*
|
|
26
|
+
* Skips the focus when focus moved during the attempt to an element that is not one of the
|
|
27
|
+
* collected targets: a plain `<input required>` with no Field kept the platform's behaviour
|
|
28
|
+
* (bubble and focus), and the library does not fight it.
|
|
29
|
+
*/
|
|
30
|
+
function collectInvalid(target, message = "") {
|
|
31
|
+
if (target === null) return;
|
|
32
|
+
if (batch === null) {
|
|
33
|
+
batch = {
|
|
34
|
+
targets: [],
|
|
35
|
+
messages: /* @__PURE__ */ new Map(),
|
|
36
|
+
activeBefore: target.ownerDocument.activeElement,
|
|
37
|
+
moved: false,
|
|
38
|
+
announced: null
|
|
39
|
+
};
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
batch = null;
|
|
42
|
+
}, 0);
|
|
43
|
+
}
|
|
44
|
+
const current = batch;
|
|
45
|
+
if (!current.targets.includes(target)) current.targets.push(target);
|
|
46
|
+
current.messages.set(target, message);
|
|
47
|
+
queueMicrotask(() => focusFirst(current));
|
|
48
|
+
}
|
|
49
|
+
function focusFirst(current) {
|
|
50
|
+
const { targets, activeBefore } = current;
|
|
51
|
+
const connected = targets.filter((t) => t.isConnected);
|
|
52
|
+
if (connected.length === 0) return;
|
|
53
|
+
const active = connected[0].ownerDocument.activeElement;
|
|
54
|
+
if (active !== activeBefore && active !== null && !connected.includes(active)) return;
|
|
55
|
+
const first = sortByDocumentOrder(connected, (t) => t)[0];
|
|
56
|
+
if (active !== first) {
|
|
57
|
+
current.moved = true;
|
|
58
|
+
first.focus();
|
|
59
|
+
} else if (!current.moved && current.announced !== first) {
|
|
60
|
+
current.announced = first;
|
|
61
|
+
announce(first, current.messages.get(first) ?? "");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { announce, collectInvalid };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=focus-first-invalid.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-first-invalid.mjs","names":[],"sources":["../../src/internal/focus-first-invalid.ts"],"sourcesContent":["// Directive-free: the module-level first-invalid collector (design/components/field-form.md 2.5).\nimport { sortByDocumentOrder } from \"./validity.js\";\n\ninterface Batch {\n readonly targets: HTMLElement[];\n /** The message each target's Field shows, for the announcement when focus does not move. */\n readonly messages: Map<HTMLElement, string>;\n /** `document.activeElement` when the first target arrived. */\n readonly activeBefore: Element | null;\n /** The batch moved focus (later microtasks then re-focus, never announce). */\n moved: boolean;\n /** The target already announced. */\n announced: HTMLElement | null;\n}\n\ntype NotifyingElement = HTMLElement & { ariaNotify?: (announcement: string) => void };\n\n/**\n * Speaks `message` through `element.ariaNotify()` where the browser has it (design 5.3: the\n * error is read when focus moves to the control; when focus is already there nothing would be\n * read). Does nothing without `ariaNotify` or with an empty message.\n */\nexport function announce(element: HTMLElement, message: string): void {\n const notifying = element as NotifyingElement;\n if (message === \"\" || typeof notifying.ariaNotify !== \"function\") return;\n notifying.ariaNotify(message);\n}\n\n/** The submission attempt in progress: every target added during the current task. */\nlet batch: Batch | null = null;\n\n/**\n * Adds a control whose `invalid` event a Field cancelled during a submission attempt, and\n * focuses the first collected control in document order in a microtask, so the result does not\n * depend on the browser's dispatch order or on how many forms are on the page.\n *\n * The batch lives until the end of the task (a `setTimeout`), not just one microtask: when the\n * browser dispatches the `invalid` events itself (a click on a submit button), it runs a\n * microtask checkpoint after each listener, so the microtask of the first event runs before the\n * second event fires. Every add therefore queues a focus of the batch's first target; later ones\n * re-focus the same element, which is a no-op.\n *\n * Skips the focus when focus moved during the attempt to an element that is not one of the\n * collected targets: a plain `<input required>` with no Field kept the platform's behaviour\n * (bubble and focus), and the library does not fight it.\n */\nexport function collectInvalid(target: HTMLElement | null, message = \"\"): void {\n if (target === null) return;\n if (batch === null) {\n batch = {\n targets: [],\n messages: new Map(),\n activeBefore: target.ownerDocument.activeElement,\n moved: false,\n announced: null,\n };\n setTimeout(() => {\n batch = null;\n }, 0);\n }\n const current = batch;\n if (!current.targets.includes(target)) current.targets.push(target);\n current.messages.set(target, message);\n queueMicrotask(() => focusFirst(current));\n}\n\nfunction focusFirst(current: Batch): void {\n const { targets, activeBefore } = current;\n const connected = targets.filter((t) => t.isConnected);\n if (connected.length === 0) return;\n const active = connected[0]!.ownerDocument.activeElement;\n if (active !== activeBefore && active !== null && !connected.includes(active as HTMLElement)) {\n return;\n }\n const first = sortByDocumentOrder(connected, (t) => t)[0]!;\n if (active !== first) {\n current.moved = true;\n first.focus();\n } else if (!current.moved && current.announced !== first) {\n // Focus was already on the first invalid control (an implicit submission with Enter): the\n // cancelled bubble was the only announcement, so speak the message instead.\n current.announced = first;\n announce(first, current.messages.get(first) ?? \"\");\n }\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,SAAS,SAAsB,SAAuB;CACpE,MAAM,YAAY;CAClB,IAAI,YAAY,MAAM,OAAO,UAAU,eAAe,YAAY;CAClE,UAAU,WAAW,OAAO;AAC9B;;AAGA,IAAI,QAAsB;;;;;;;;;;;;;;;;AAiB1B,SAAgB,eAAe,QAA4B,UAAU,IAAU;CAC7E,IAAI,WAAW,MAAM;CACrB,IAAI,UAAU,MAAM;EAClB,QAAQ;GACN,SAAS,CAAC;GACV,0BAAU,IAAI,IAAI;GAClB,cAAc,OAAO,cAAc;GACnC,OAAO;GACP,WAAW;EACb;EACA,iBAAiB;GACf,QAAQ;EACV,GAAG,CAAC;CACN;CACA,MAAM,UAAU;CAChB,IAAI,CAAC,QAAQ,QAAQ,SAAS,MAAM,GAAG,QAAQ,QAAQ,KAAK,MAAM;CAClE,QAAQ,SAAS,IAAI,QAAQ,OAAO;CACpC,qBAAqB,WAAW,OAAO,CAAC;AAC1C;AAEA,SAAS,WAAW,SAAsB;CACxC,MAAM,EAAE,SAAS,iBAAiB;CAClC,MAAM,YAAY,QAAQ,QAAQ,MAAM,EAAE,WAAW;CACrD,IAAI,UAAU,WAAW,GAAG;CAC5B,MAAM,SAAS,UAAU,EAAE,CAAE,cAAc;CAC3C,IAAI,WAAW,gBAAgB,WAAW,QAAQ,CAAC,UAAU,SAAS,MAAqB,GACzF;CAEF,MAAM,QAAQ,oBAAoB,YAAY,MAAM,CAAC,CAAC,CAAC;CACvD,IAAI,WAAW,OAAO;EACpB,QAAQ,QAAQ;EAChB,MAAM,MAAM;CACd,OAAO,IAAI,CAAC,QAAQ,SAAS,QAAQ,cAAc,OAAO;EAGxD,QAAQ,YAAY;EACpB,SAAS,OAAO,QAAQ,SAAS,IAAI,KAAK,KAAK,EAAE;CACnD;AACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { useFormStatus } from "react-dom";
|
|
4
|
+
//#region src/internal/form-status-watcher.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Observes React's form channel (Dialog design 8.1, Field/Form design 3.2): rendered inside a
|
|
7
|
+
* `<form>`, `useFormStatus().pending` covers the action's whole transition, including the
|
|
8
|
+
* Suspense wait of what it re-renders. On `true → false` the submission settled without throwing
|
|
9
|
+
* (a rejection unmounts the form through the nearest Error Boundary, so the edge is never seen).
|
|
10
|
+
* Used by `Dialog.Form` and `Form.Root`.
|
|
11
|
+
*/
|
|
12
|
+
function FormStatusWatcher({ onPendingChange, onSettled }) {
|
|
13
|
+
const { pending } = useFormStatus();
|
|
14
|
+
const previous = useRef(false);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const was = previous.current;
|
|
17
|
+
previous.current = pending;
|
|
18
|
+
if (was === pending) return;
|
|
19
|
+
onPendingChange(pending);
|
|
20
|
+
if (was && !pending) onSettled();
|
|
21
|
+
}, [
|
|
22
|
+
pending,
|
|
23
|
+
onPendingChange,
|
|
24
|
+
onSettled
|
|
25
|
+
]);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { FormStatusWatcher };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=form-status-watcher.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-status-watcher.mjs","names":[],"sources":["../../src/internal/form-status-watcher.tsx"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { useFormStatus } from \"react-dom\";\n\nexport interface FormStatusWatcherProps {\n readonly onPendingChange: (pending: boolean) => void;\n readonly onSettled: () => void;\n}\n\n/**\n * Observes React's form channel (Dialog design 8.1, Field/Form design 3.2): rendered inside a\n * `<form>`, `useFormStatus().pending` covers the action's whole transition, including the\n * Suspense wait of what it re-renders. On `true → false` the submission settled without throwing\n * (a rejection unmounts the form through the nearest Error Boundary, so the edge is never seen).\n * Used by `Dialog.Form` and `Form.Root`.\n */\nexport function FormStatusWatcher({ onPendingChange, onSettled }: FormStatusWatcherProps) {\n const { pending } = useFormStatus();\n const previous = useRef(false);\n useEffect(() => {\n const was = previous.current;\n previous.current = pending;\n if (was === pending) return;\n onPendingChange(pending);\n if (was && !pending) onSettled();\n }, [pending, onPendingChange, onSettled]);\n return null;\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAgB,kBAAkB,EAAE,iBAAiB,aAAqC;CACxF,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,WAAW,OAAO,KAAK;CAC7B,gBAAgB;EACd,MAAM,MAAM,SAAS;EACrB,SAAS,UAAU;EACnB,IAAI,QAAQ,SAAS;EACrB,gBAAgB,OAAO;EACvB,IAAI,OAAO,CAAC,SAAS,UAAU;CACjC,GAAG;EAAC;EAAS;EAAiB;CAAS,CAAC;CACxC,OAAO;AACT"}
|