@funstack/ui 0.1.0-alpha.19 → 0.1.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion/accordion-item.mjs +2 -2
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +3 -20
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/alert-dialog/alert-dialog-action.d.mts +73 -0
- package/dist/alert-dialog/alert-dialog-action.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-action.mjs +23 -0
- package/dist/alert-dialog/alert-dialog-action.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-cancel.d.mts +31 -0
- package/dist/alert-dialog/alert-dialog-cancel.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-cancel.mjs +50 -0
- package/dist/alert-dialog/alert-dialog-cancel.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-context.mjs +24 -0
- package/dist/alert-dialog/alert-dialog-context.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-description.d.mts +25 -0
- package/dist/alert-dialog/alert-dialog-description.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-description.mjs +20 -0
- package/dist/alert-dialog/alert-dialog-description.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-form.d.mts +27 -0
- package/dist/alert-dialog/alert-dialog-form.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-form.mjs +22 -0
- package/dist/alert-dialog/alert-dialog-form.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-popup.d.mts +42 -0
- package/dist/alert-dialog/alert-dialog-popup.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-popup.mjs +53 -0
- package/dist/alert-dialog/alert-dialog-popup.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-root.d.mts +31 -0
- package/dist/alert-dialog/alert-dialog-root.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-root.mjs +22 -0
- package/dist/alert-dialog/alert-dialog-root.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-title.d.mts +23 -0
- package/dist/alert-dialog/alert-dialog-title.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-title.mjs +18 -0
- package/dist/alert-dialog/alert-dialog-title.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-trigger.d.mts +23 -0
- package/dist/alert-dialog/alert-dialog-trigger.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-trigger.mjs +18 -0
- package/dist/alert-dialog/alert-dialog-trigger.mjs.map +1 -0
- package/dist/alert-dialog/index.d.mts +33 -0
- package/dist/alert-dialog/index.d.mts.map +1 -0
- package/dist/alert-dialog/index.mjs +33 -0
- package/dist/alert-dialog/index.mjs.map +1 -0
- package/dist/checkbox-group/checkbox-group-parent.mjs +1 -1
- package/dist/collapsible/collapsible-context.mjs +8 -0
- package/dist/collapsible/collapsible-context.mjs.map +1 -0
- package/dist/collapsible/collapsible-panel.d.mts +53 -0
- package/dist/collapsible/collapsible-panel.d.mts.map +1 -0
- package/dist/collapsible/collapsible-panel.mjs +41 -0
- package/dist/collapsible/collapsible-panel.mjs.map +1 -0
- package/dist/collapsible/collapsible-root.d.mts +108 -0
- package/dist/collapsible/collapsible-root.d.mts.map +1 -0
- package/dist/collapsible/collapsible-root.mjs +147 -0
- package/dist/collapsible/collapsible-root.mjs.map +1 -0
- package/dist/collapsible/collapsible-trigger.d.mts +45 -0
- package/dist/collapsible/collapsible-trigger.d.mts.map +1 -0
- package/dist/collapsible/collapsible-trigger.mjs +62 -0
- package/dist/collapsible/collapsible-trigger.mjs.map +1 -0
- package/dist/collapsible/index.d.mts +21 -0
- package/dist/collapsible/index.d.mts.map +1 -0
- package/dist/collapsible/index.mjs +21 -0
- package/dist/collapsible/index.mjs.map +1 -0
- package/dist/combobox/chip-text.mjs +24 -0
- package/dist/combobox/chip-text.mjs.map +1 -0
- package/dist/combobox/combobox-chips.d.mts +159 -0
- package/dist/combobox/combobox-chips.d.mts.map +1 -0
- package/dist/combobox/combobox-chips.mjs +198 -0
- package/dist/combobox/combobox-chips.mjs.map +1 -0
- package/dist/combobox/combobox-clear.d.mts +5 -2
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +3 -1
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-context.mjs +4 -5
- package/dist/combobox/combobox-context.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts +10 -3
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +13 -5
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-keyboard.mjs +50 -4
- package/dist/combobox/combobox-keyboard.mjs.map +1 -1
- package/dist/combobox/combobox-list.d.mts +1 -1
- package/dist/combobox/combobox-list.mjs +2 -1
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts +5 -2
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +4 -3
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts +127 -35
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +396 -44
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/index.d.mts +8 -2
- package/dist/combobox/index.d.mts.map +1 -1
- package/dist/combobox/index.mjs +7 -1
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/combobox/use-combobox-form.mjs +2 -3
- package/dist/combobox/use-combobox-form.mjs.map +1 -1
- package/dist/dialog/dialog-close.d.mts +9 -5
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +19 -8
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.d.mts +2 -0
- package/dist/dialog/dialog-context.mjs +14 -2
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-description.d.mts +2 -1
- package/dist/dialog/dialog-description.d.mts.map +1 -1
- package/dist/dialog/dialog-description.mjs +8 -4
- package/dist/dialog/dialog-description.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts +2 -1
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +11 -6
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +2 -1
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +23 -14
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +2 -1
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +15 -5
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-title.d.mts +2 -1
- package/dist/dialog/dialog-title.d.mts.map +1 -1
- package/dist/dialog/dialog-title.mjs +8 -4
- package/dist/dialog/dialog-title.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +2 -1
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +14 -9
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/docs/components/accordion.md +2 -0
- package/dist/docs/components/alert-dialog.md +546 -0
- package/dist/docs/components/collapsible.md +408 -0
- package/dist/docs/components/combobox.md +288 -26
- package/dist/docs/components/dialog.md +7 -5
- package/dist/docs/components/field.md +180 -3
- package/dist/docs/components/hover-card.md +494 -0
- package/dist/docs/components/multi-select.md +622 -0
- package/dist/docs/components/number-field.md +1 -1
- package/dist/docs/components/popover.md +4 -4
- package/dist/docs/components/select.md +9 -1
- package/dist/docs/components/separator.md +182 -0
- package/dist/docs/components/slider.md +1 -1
- package/dist/docs/components/tooltip.md +1 -1
- package/dist/docs/concepts/experimental.md +3 -3
- package/dist/docs/concepts/server-components.md +1 -1
- package/dist/docs/index.md +7 -2
- package/dist/docs/roadmap.md +8 -0
- package/dist/field/field-control.d.mts +13 -4
- package/dist/field/field-control.d.mts.map +1 -1
- package/dist/field/field-control.mjs +39 -10
- package/dist/field/field-control.mjs.map +1 -1
- package/dist/field/field-label.d.mts +6 -2
- package/dist/field/field-label.d.mts.map +1 -1
- package/dist/field/field-label.mjs +12 -2
- package/dist/field/field-label.mjs.map +1 -1
- package/dist/field/field-root.mjs +9 -1
- package/dist/field/field-root.mjs.map +1 -1
- package/dist/hover-card/hover-card-context.mjs +13 -0
- package/dist/hover-card/hover-card-context.mjs.map +1 -0
- package/dist/hover-card/hover-card-popup.d.mts +102 -0
- package/dist/hover-card/hover-card-popup.d.mts.map +1 -0
- package/dist/hover-card/hover-card-popup.mjs +80 -0
- package/dist/hover-card/hover-card-popup.mjs.map +1 -0
- package/dist/hover-card/hover-card-root.d.mts +94 -0
- package/dist/hover-card/hover-card-root.d.mts.map +1 -0
- package/dist/hover-card/hover-card-root.mjs +74 -0
- package/dist/hover-card/hover-card-root.mjs.map +1 -0
- package/dist/hover-card/hover-card-trigger.d.mts +65 -0
- package/dist/hover-card/hover-card-trigger.d.mts.map +1 -0
- package/dist/hover-card/hover-card-trigger.mjs +109 -0
- package/dist/hover-card/hover-card-trigger.mjs.map +1 -0
- package/dist/hover-card/index.d.mts +24 -0
- package/dist/hover-card/index.d.mts.map +1 -0
- package/dist/hover-card/index.mjs +24 -0
- package/dist/hover-card/index.mjs.map +1 -0
- package/dist/hover-card/use-hover-card-interest.mjs +242 -0
- package/dist/hover-card/use-hover-card-interest.mjs.map +1 -0
- package/dist/index.d.mts +38 -9
- package/dist/index.mjs +6 -1
- package/dist/internal/action/use-multiple-selection.mjs +83 -0
- package/dist/internal/action/use-multiple-selection.mjs.map +1 -0
- package/dist/internal/details-summary.mjs +56 -0
- package/dist/internal/details-summary.mjs.map +1 -0
- package/dist/internal/form/field-context.mjs.map +1 -1
- package/dist/internal/form/hidden-values.mjs +29 -0
- package/dist/internal/form/hidden-values.mjs.map +1 -0
- package/dist/internal/form/validity.mjs +3 -1
- package/dist/internal/form/validity.mjs.map +1 -1
- package/dist/internal/overlay/use-interest-dismiss.mjs +2 -1
- package/dist/internal/overlay/use-interest-dismiss.mjs.map +1 -1
- package/dist/internal/overlay/use-overlay-close.mjs +5 -3
- package/dist/internal/overlay/use-overlay-close.mjs.map +1 -1
- package/dist/internal/overlay/use-overlay-root.mjs +4 -1
- package/dist/internal/overlay/use-overlay-root.mjs.map +1 -1
- package/dist/internal/overlay/use-popover-popup.mjs +20 -7
- package/dist/internal/overlay/use-popover-popup.mjs.map +1 -1
- package/dist/internal/overlay/use-popover-trigger.d.mts +1 -1
- package/dist/internal/typeahead.mjs +52 -0
- package/dist/internal/typeahead.mjs.map +1 -0
- package/dist/{combobox → internal}/use-active-option.mjs +8 -6
- package/dist/internal/use-active-option.mjs.map +1 -0
- package/dist/{combobox → internal}/use-deferred-leave.mjs +20 -12
- package/dist/internal/use-deferred-leave.mjs.map +1 -0
- package/dist/internal/use-name-warning.mjs +57 -1
- package/dist/internal/use-name-warning.mjs.map +1 -1
- package/dist/internal/use-option-registry.mjs +70 -0
- package/dist/internal/use-option-registry.mjs.map +1 -0
- package/dist/menu/use-menu-keyboard.mjs +7 -27
- package/dist/menu/use-menu-keyboard.mjs.map +1 -1
- package/dist/multi-select/index.d.mts +37 -0
- package/dist/multi-select/index.d.mts.map +1 -0
- package/dist/multi-select/index.mjs +37 -0
- package/dist/multi-select/index.mjs.map +1 -0
- package/dist/multi-select/multi-select-context.mjs +19 -0
- package/dist/multi-select/multi-select-context.mjs.map +1 -0
- package/dist/multi-select/multi-select-group.d.mts +120 -0
- package/dist/multi-select/multi-select-group.d.mts.map +1 -0
- package/dist/multi-select/multi-select-group.mjs +111 -0
- package/dist/multi-select/multi-select-group.mjs.map +1 -0
- package/dist/multi-select/multi-select-keyboard.mjs +145 -0
- package/dist/multi-select/multi-select-keyboard.mjs.map +1 -0
- package/dist/multi-select/multi-select-label.d.mts +42 -0
- package/dist/multi-select/multi-select-label.d.mts.map +1 -0
- package/dist/multi-select/multi-select-label.mjs +41 -0
- package/dist/multi-select/multi-select-label.mjs.map +1 -0
- package/dist/multi-select/multi-select-list.d.mts +47 -0
- package/dist/multi-select/multi-select-list.d.mts.map +1 -0
- package/dist/multi-select/multi-select-list.mjs +65 -0
- package/dist/multi-select/multi-select-list.mjs.map +1 -0
- package/dist/multi-select/multi-select-option.d.mts +68 -0
- package/dist/multi-select/multi-select-option.d.mts.map +1 -0
- package/dist/multi-select/multi-select-option.mjs +93 -0
- package/dist/multi-select/multi-select-option.mjs.map +1 -0
- package/dist/multi-select/multi-select-popup.d.mts +58 -0
- package/dist/multi-select/multi-select-popup.d.mts.map +1 -0
- package/dist/multi-select/multi-select-popup.mjs +71 -0
- package/dist/multi-select/multi-select-popup.mjs.map +1 -0
- package/dist/multi-select/multi-select-root.d.mts +125 -0
- package/dist/multi-select/multi-select-root.d.mts.map +1 -0
- package/dist/multi-select/multi-select-root.mjs +257 -0
- package/dist/multi-select/multi-select-root.mjs.map +1 -0
- package/dist/multi-select/multi-select-trigger.d.mts +66 -0
- package/dist/multi-select/multi-select-trigger.d.mts.map +1 -0
- package/dist/multi-select/multi-select-trigger.mjs +169 -0
- package/dist/multi-select/multi-select-trigger.mjs.map +1 -0
- package/dist/multi-select/multi-select-value.d.mts +57 -0
- package/dist/multi-select/multi-select-value.d.mts.map +1 -0
- package/dist/multi-select/multi-select-value.mjs +41 -0
- package/dist/multi-select/multi-select-value.mjs.map +1 -0
- package/dist/number-field/number-field-root.mjs +1 -1
- package/dist/number-field/use-step-button.d.mts.map +1 -1
- package/dist/number-field/use-step-button.mjs +11 -2
- package/dist/number-field/use-step-button.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts +6 -3
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +3 -2
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-popup.mjs +1 -1
- package/dist/select/select-root.d.mts +1 -1
- package/dist/select/select-root.d.mts.map +1 -1
- package/dist/select/select-root.mjs +5 -1
- package/dist/select/select-root.mjs.map +1 -1
- package/dist/separator/index.d.mts +3 -0
- package/dist/separator/index.mjs +1 -0
- package/dist/separator/separator.d.mts +58 -0
- package/dist/separator/separator.d.mts.map +1 -0
- package/dist/separator/separator.mjs +41 -0
- package/dist/separator/separator.mjs.map +1 -0
- package/dist/slider/slider-root.mjs +1 -0
- package/dist/slider/slider-root.mjs.map +1 -1
- package/dist/toast/toast-viewport.mjs +1 -1
- package/package.json +6 -1
- package/skills/funstack-ui-knowledge/SKILL.md +14 -9
- package/dist/combobox/use-active-option.mjs.map +0 -1
- package/dist/combobox/use-deferred-leave.mjs.map +0 -1
- package/dist/combobox/use-option-registry.mjs +0 -52
- package/dist/combobox/use-option-registry.mjs.map +0 -1
|
@@ -222,7 +222,7 @@ In library mode, opening and [a part's close](../concepts/browser-owned-state.md
|
|
|
222
222
|
### <a id="other-openers"></a>Other ways to open and close
|
|
223
223
|
|
|
224
224
|
- **[Foreign invokers](../concepts/browser-owned-state.md#foreign-invoker) and scripts:** in library mode any open that the library did not start (a `<button commandfor command="show-popover">`, a `<button popovertarget>`, a script `showPopover()`) is cancelled at `beforetoggle` and dispatched with that `ToggleEvent`. A foreign close happens natively, so it is a fact: `onOpenChange(false)` with `"activate"` and a `hide-popover` or `toggle-popover` command's `CommandEvent`, or a `<button popovertarget>`'s `beforetoggle` `ToggleEvent`, whose `source` is the button. Escape, a click outside and a script `hidePopover()` are `"dismiss"` facts.
|
|
225
|
-
- **
|
|
225
|
+
- **Interest invokers (Chromium):** a `<button interestfor>` of your own naming the Popup, one that does nothing else to it, opens it on interest (hover or keyboard focus) through the library, and in library mode the Popup hides again on lost interest: a `"dismiss"` fact, `onOpenChange(false)`, whose `details.event` is the `loseinterest` event (its `source` is the button). Lost interest while the open is still pending cancels it (a request, `openChangeAction(false, { reason: "dismiss" })`, superseding the open). A Trigger-click open stays open on lost interest, as in the platform, and focus is not returned to the Trigger after a lost-interest hide. Do not add `interestfor` to the Trigger itself: HTML's author guidance rules out one element that shows the same rich content on interest and on activation, so "hover to preview, click to pin" is not a pattern the library recommends. For a hover preview in every engine, use [HoverCard](hover-card.md); for a name or description (`role="tooltip"` content), use [Tooltip](tooltip.md).
|
|
226
226
|
|
|
227
227
|
## Props
|
|
228
228
|
|
|
@@ -279,7 +279,7 @@ A click on a `<button>` Trigger while open is a part's close; a second click dur
|
|
|
279
279
|
|
|
280
280
|
| Prop | Type | Default | Description |
|
|
281
281
|
| - | - | - | - |
|
|
282
|
-
| `action` | `Action<[details: ActionDetails]>` | – | Runs in this button's own transition (`data-pending` on it), then closes the popover: in library mode through the Root (`openChangeAction(false)` awaited, view transition if set), in JS-free mode with `hidePopover()`. A rejection reaches the nearest Error Boundary above the button and leaves the popover open. A second click while it is pending is ignored, and the button is `aria-disabled="true"` meanwhile, unless `whilePending` is `"run"`. Without `action` in JS-free mode the button is a native `command="hide-popover"` invoker. |
|
|
282
|
+
| `action` | `Action<[details: ActionDetails]>` | – | Runs in this button's own transition (`data-pending` on it), then closes the popover: in library mode through the Root (`openChangeAction(false)` awaited, view transition if set), in JS-free mode with `hidePopover()`. A rejection reaches the nearest Error Boundary above the button and leaves the popover open. A second click while it is pending is ignored, and the button is `aria-disabled="true"` meanwhile, unless `whilePending` is `"run"`. With `action` the button renders no `commandfor` / `command`, so a click before hydration does nothing (rather than hiding the popover without running the action). Without `action` in JS-free mode the button is a native `command="hide-popover"` invoker. |
|
|
283
283
|
| `whilePending` | `"run" \| "ignore"` | `"ignore"` | What a click, Enter or Space does while this part's `action` is pending. `"ignore"`: nothing (the click is cancelled, `aria-disabled="true"` meanwhile). `"run"`: the action runs again (`data-pending` until every run has settled, no `aria-disabled`); the popover closes once the last run has settled, and only if the latest run resolved: a rejection leaves it open in both modes. No effect without `action`. See [A second click while pending](../concepts/pending-and-optimistic.md#second-click). |
|
|
284
284
|
| `disabled` | `boolean` | `false` | Native `disabled`; owned, so a `render` element cannot re-enable it. With a link or component `render` where the Close handles the click (library mode, or with `action`), `aria-disabled="true"` instead (the element stays focusable). A host link is `aria-disabled` in every mode (it cannot be natively disabled), and its click is cancelled. |
|
|
285
285
|
| `className` | `string \| ((state: PopoverCloseState) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
@@ -288,7 +288,7 @@ A click on a `<button>` Trigger while open is a part's close; a second click dur
|
|
|
288
288
|
| `render` | `ReactElement \| ((props, state: PopoverCloseState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
|
|
289
289
|
|
|
290
290
|
- **State**: `PopoverCloseState` is `{ pending, disabled }`.
|
|
291
|
-
- **Owned**: `type` (on a `<button>` only), `disabled`, `aria-disabled`, `commandfor`, `command` (not on a link or other non-button host element), `onClick` (library mode, or with `action`), `data-pending`, `data-disabled`; a `render` element cannot re-enable a disabled Close.
|
|
291
|
+
- **Owned**: `type` (on a `<button>` only), `disabled`, `aria-disabled`, `commandfor`, `command` (not with `action`, and not on a link or other non-button host element), `onClick` (library mode, or with `action`), `data-pending`, `data-disabled`; a `render` element cannot re-enable a disabled Close.
|
|
292
292
|
|
|
293
293
|
In library mode the click is always intercepted, so every Close goes through the Root. By default (`whilePending="ignore"`) a second click while the action is pending is ignored (and cancelled), and the button is `aria-disabled="true"` for as long as it shows `data-pending` (the action and the hide); never natively disabled, so it keeps focus. To hide at once and finish the work in the background, do not return the promise: `action={() => { void apply(); }}`. If the user dismisses the popover and opens it again while the action runs, the action's close is dropped: it belonged to the earlier open. Popovers have no return value.
|
|
294
294
|
|
|
@@ -554,7 +554,7 @@ JS-free mode: the browser owns everything through the Trigger's `popovertarget`
|
|
|
554
554
|
|
|
555
555
|
Concept: [Server Components](../concepts/server-components.md#before-hydration)
|
|
556
556
|
|
|
557
|
-
JS-free mode: everything, including `autoFocus` in server-rendered markup. Library mode: the Trigger opens the popover natively, but the content is not in the HTML yet; on hydration the Popup finds it open, dispatches `openChangeAction(true)` with `reason: "platform"` and the content mounts.
|
|
557
|
+
JS-free mode: everything, including `autoFocus` in server-rendered markup, except a `Popover.Close` with `action`, which does nothing until hydration. Library mode: the Trigger opens the popover natively, but the content is not in the HTML yet; on hydration the Popup finds it open, dispatches `openChangeAction(true)` with `reason: "platform"` and the content mounts.
|
|
558
558
|
|
|
559
559
|
### The [platform paths](../concepts/browser-owned-state.md#platform-path)
|
|
560
560
|
|
|
@@ -238,7 +238,7 @@ import { Select } from "@funstack/ui/select";
|
|
|
238
238
|
- **State**: `SelectRootState` is `{ value, pending, disabled }`; `value` is optimistic.
|
|
239
239
|
- **Owned**: `value`, `disabled`, `onChange`, `data-pending`, `data-disabled`. Inside a `Field.Root` also `id`, `name`, `required`, `aria-invalid`, `aria-describedby` and `data-invalid`.
|
|
240
240
|
|
|
241
|
-
`multiple` and `size` are not accepted
|
|
241
|
+
`multiple` and `size` are not accepted (a type error; `multiple` is dropped with a development warning): for several values see [Several values](#several-values). `id`, `aria-*`, `onFocus` and other select props pass through.
|
|
242
242
|
|
|
243
243
|
`SelectValueChangeDetails`: `{ reason, event }`. `reason` is `"activate"` for a pick (pointer, keyboard, typeahead or autofill; `event` is the native `change`) and `"platform"` for a form reset (`event` is the `reset` event) or a pick made before hydration (no event).
|
|
244
244
|
|
|
@@ -597,6 +597,14 @@ export function SelectForm() {
|
|
|
597
597
|
|
|
598
598
|
The [two channels](../concepts/action-props.md#form-channel) are independent and may be combined. Every dispatch adds the view transition type `fsui-select`; no part takes a `transition` prop, since the picker and the button's copy are drawn by the browser. An action-less Select is a working native select before hydration, including the copy into the button.
|
|
599
599
|
|
|
600
|
+
## Several values
|
|
601
|
+
|
|
602
|
+
Select is the browser's control, and no stable engine has a styleable multi-select drop-down yet (`<select multiple>` is still a list box). So a select for several values is another component, [MultiSelect](multi-select.md): the library's own listbox on a popover, with the same action, pending and form conventions. It needs JavaScript and does not open before hydration, which is why it is not a prop here: `<Select.Root multiple>` is a type error and warns in development. When the native multi drop-down ships everywhere, it is the name it will take.
|
|
603
|
+
|
|
604
|
+
- A few choices shown in the page: [CheckboxGroup](checkbox-group.md).
|
|
605
|
+
- A drop-down of choices, the selection summarised in the button: [MultiSelect](multi-select.md).
|
|
606
|
+
- A searchable list with removable chips: [Combobox multiple](combobox.md#multiple).
|
|
607
|
+
|
|
600
608
|
## Styling
|
|
601
609
|
|
|
602
610
|
The library ships no CSS. These recipes cover the opt-in, the button, the picker, its options and an open/close animation. Engines without customizable select ignore all of it except the plain properties on the select.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Separator
|
|
2
|
+
|
|
3
|
+
A line between two pieces of content (WAI-ARIA `separator`). It has no state, no action and nothing pending: what it adds over a bare `<hr>` is the vertical case (`aria-orientation` plus a styling hook), the decorative case (`role="none"`) and a name for your styled layer. Directive-free, so a Server Component renders it.
|
|
4
|
+
|
|
5
|
+
```tsx title="SeparatorLayout.tsx"
|
|
6
|
+
// No "use client": a Server Component, and Separator runs on the server with it (the part is
|
|
7
|
+
// directive-free). A semantic separator between two sections of an article, and decorative
|
|
8
|
+
// vertical lines between the links of a breadcrumb, where "separator" would only be noise.
|
|
9
|
+
import { Separator } from "@funstack/ui/separator";
|
|
10
|
+
|
|
11
|
+
export function SeparatorLayout() {
|
|
12
|
+
return (
|
|
13
|
+
<div className="demo-separator-card">
|
|
14
|
+
<nav aria-label="Breadcrumb" className="demo-separator-crumbs">
|
|
15
|
+
<a href="/">Docs</a>
|
|
16
|
+
<Separator orientation="vertical" decorative className="demo-separator" />
|
|
17
|
+
<a href="/getting-started">Getting started</a>
|
|
18
|
+
<Separator orientation="vertical" decorative className="demo-separator" />
|
|
19
|
+
<span aria-current="page">Separator</span>
|
|
20
|
+
</nav>
|
|
21
|
+
<section>
|
|
22
|
+
<h4>Release notes</h4>
|
|
23
|
+
<p>Separator is a plain line with a name, an orientation and a decorative mode.</p>
|
|
24
|
+
</section>
|
|
25
|
+
{/* Semantic: a thematic break that a screen reader announces. */}
|
|
26
|
+
<Separator className={(s) => `demo-separator demo-separator-${s.orientation}`} />
|
|
27
|
+
<section>
|
|
28
|
+
<h4>Comments</h4>
|
|
29
|
+
<p>No comments yet.</p>
|
|
30
|
+
</section>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```css title="separator.css"
|
|
37
|
+
/* Separator: an <hr> keeps its user-agent margins, border and border-derived height, so the
|
|
38
|
+
recipe resets them and draws the line from data-orientation. */
|
|
39
|
+
.demo-separator {
|
|
40
|
+
margin: 0;
|
|
41
|
+
border: 0;
|
|
42
|
+
background: var(--color-border);
|
|
43
|
+
flex: none;
|
|
44
|
+
}
|
|
45
|
+
.demo-separator[data-orientation="horizontal"] {
|
|
46
|
+
block-size: 1px;
|
|
47
|
+
inline-size: 100%;
|
|
48
|
+
}
|
|
49
|
+
.demo-separator[data-orientation="vertical"] {
|
|
50
|
+
inline-size: 1px;
|
|
51
|
+
align-self: stretch;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.demo-separator-card {
|
|
55
|
+
display: grid;
|
|
56
|
+
gap: 0.75rem;
|
|
57
|
+
inline-size: min(28rem, 100%);
|
|
58
|
+
}
|
|
59
|
+
.demo-separator-card h4 {
|
|
60
|
+
margin: 0 0 0.25rem;
|
|
61
|
+
}
|
|
62
|
+
.demo-separator-card p {
|
|
63
|
+
margin: 0;
|
|
64
|
+
color: var(--color-text-secondary);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.demo-separator-crumbs {
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
gap: 0.6rem;
|
|
71
|
+
font-size: 0.9rem;
|
|
72
|
+
}
|
|
73
|
+
.demo-separator-crumbs .demo-separator {
|
|
74
|
+
block-size: 1em;
|
|
75
|
+
align-self: center;
|
|
76
|
+
transform: rotate(20deg);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
This example is a Server Component (no `"use client"`), and so is `Separator`: the function `className` ran on the server.
|
|
81
|
+
|
|
82
|
+
## Anatomy
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { Separator } from "@funstack/ui/separator";
|
|
86
|
+
|
|
87
|
+
<article>…</article>
|
|
88
|
+
<Separator /> {/* hr aria-orientation="horizontal" */}
|
|
89
|
+
<article>…</article>
|
|
90
|
+
|
|
91
|
+
<nav aria-label="Breadcrumb">
|
|
92
|
+
<a href="/">Home</a>
|
|
93
|
+
<Separator orientation="vertical" decorative /> {/* hr role="none" data-orientation="vertical" */}
|
|
94
|
+
<a href="/docs">Docs</a>
|
|
95
|
+
</nav>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
One plain component, no parts. It renders `<hr>`, which is void: there is no `children` prop.
|
|
99
|
+
|
|
100
|
+
## Props
|
|
101
|
+
|
|
102
|
+
| Prop | Type | Default | Description |
|
|
103
|
+
| - | - | - | - |
|
|
104
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | The direction of the line itself. A vertical separator sits between things laid out in a row. Rendered as `aria-orientation` (both values) and `data-orientation`. |
|
|
105
|
+
| `decorative` | `boolean` | `false` | A visual line with no meaning: `role="none"` and no `aria-orientation`. Leave it `false` when the line marks a real break a sighted reader would describe ("the comments start here"); set it for a line that only tidies a row or a list. |
|
|
106
|
+
| `className` | `string \| ((state: SeparatorState) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
107
|
+
| `style` | `CSSProperties \| ((state: SeparatorState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
|
|
108
|
+
| `render` | `ReactElement \| ((props, state: SeparatorState) => ReactNode)` | – | Replace the `<hr>` (element form) or take over rendering (function form). Another element must carry `role="separator"` itself unless `decorative`. |
|
|
109
|
+
|
|
110
|
+
- **State**: `SeparatorState` is `{ orientation, decorative }`, the two props (`orientation` defaults to `"horizontal"`).
|
|
111
|
+
- **Owned**: `aria-orientation`, `data-orientation`, and `role` while `decorative` (`"none"`, which wins over a `render` element's own).
|
|
112
|
+
|
|
113
|
+
Every other `<hr>` prop passes through, `ref` included. While not decorative no `role` is rendered, so `render={<div role="separator" />}` keeps the one it carries.
|
|
114
|
+
|
|
115
|
+
## Data attributes
|
|
116
|
+
|
|
117
|
+
| Hook | Meaning |
|
|
118
|
+
| - | - |
|
|
119
|
+
| `data-orientation` | `"horizontal"` or `"vertical"`, always (decorative too). |
|
|
120
|
+
| `aria-orientation` | The same value; absent while `decorative`. |
|
|
121
|
+
| `[role="none"]` | `decorative` (there is no `data-decorative`). |
|
|
122
|
+
|
|
123
|
+
## Keyboard and ARIA
|
|
124
|
+
|
|
125
|
+
| Case | Rendered | Announced |
|
|
126
|
+
| - | - | - |
|
|
127
|
+
| default | `hr[aria-orientation=horizontal]` | separator |
|
|
128
|
+
| `orientation="vertical"` | `hr[aria-orientation=vertical]` | separator, vertical where the screen reader says so |
|
|
129
|
+
| `decorative` | `hr[role=none]` | nothing |
|
|
130
|
+
|
|
131
|
+
- Not focusable, no keyboard interaction, in every case.
|
|
132
|
+
- Inside a [Menu](menu.md), a [Toolbar](toolbar.md) or a [Select](select.md), use `Menu.Separator`, `Toolbar.Separator` (it takes the orientation perpendicular to the toolbar's) or `Select.Separator`.
|
|
133
|
+
- Inside a listbox ([Combobox](combobox.md), [MultiSelect](multi-select.md)) a `separator` is not allowed, but a `role="none"` element is: `<Separator decorative />` between options or groups is valid, a semantic one is not.
|
|
134
|
+
- A line with a word in it ("or") is `render={<div role="separator">or</div>}`. The children of a separator are presentational, so the word is not announced: right for "or", wrong for anything that matters.
|
|
135
|
+
|
|
136
|
+
## Transition types
|
|
137
|
+
|
|
138
|
+
Concept: [Transitions & ViewTransition](../concepts/transitions.md#transition-types)
|
|
139
|
+
|
|
140
|
+
None: the separator never changes on its own, and it takes no `transition` prop.
|
|
141
|
+
|
|
142
|
+
## Optimistic and pending
|
|
143
|
+
|
|
144
|
+
Concept: [Pending & optimistic state](../concepts/pending-and-optimistic.md)
|
|
145
|
+
|
|
146
|
+
None: no state, no action, nothing pending.
|
|
147
|
+
|
|
148
|
+
## Suspense
|
|
149
|
+
|
|
150
|
+
Concept: [Suspense](../concepts/suspense.md)
|
|
151
|
+
|
|
152
|
+
Nothing specific: the separator renders no content region.
|
|
153
|
+
|
|
154
|
+
## Browser-owned state
|
|
155
|
+
|
|
156
|
+
Concept: [Browser-owned state](../concepts/browser-owned-state.md)
|
|
157
|
+
|
|
158
|
+
None.
|
|
159
|
+
|
|
160
|
+
## Before hydration
|
|
161
|
+
|
|
162
|
+
Concept: [Server Components](../concepts/server-components.md#before-hydration)
|
|
163
|
+
|
|
164
|
+
Everything: there is no behaviour. The component is itself a Server Component; rendered by one, it runs once, on the server, function `className`, `style` and `render` included.
|
|
165
|
+
|
|
166
|
+
## Recipes
|
|
167
|
+
|
|
168
|
+
### CSS
|
|
169
|
+
|
|
170
|
+
The library ships no CSS. An `<hr>` has user-agent margins, a border and a border-derived height, so reset them:
|
|
171
|
+
|
|
172
|
+
```css
|
|
173
|
+
.separator { margin: 0; border: 0; background: var(--line); flex: none; }
|
|
174
|
+
.separator[data-orientation="horizontal"] { block-size: 1px; inline-size: 100%; }
|
|
175
|
+
.separator[data-orientation="vertical"] { inline-size: 1px; align-self: stretch; }
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Tailwind: `data-[orientation=horizontal]:h-px data-[orientation=vertical]:w-px`.
|
|
179
|
+
|
|
180
|
+
### Inside a Toolbar
|
|
181
|
+
|
|
182
|
+
A standalone `Separator` does not read the Toolbar's orientation (that would make it a client component). It works there, but stays horizontal unless told otherwise; use `Toolbar.Separator`.
|
|
@@ -237,7 +237,7 @@ The thumb under the pointer is **urgent**: it moves in the same event, while a c
|
|
|
237
237
|
| `getAriaValueText` | `(value: number, index: number) => string` | – | `aria-valuetext` for each thumb, from the value it shows. For values whose number alone is not meaningful. |
|
|
238
238
|
| `name` | `string` | – | Form field name for every thumb's input (a Thumb's own `name` wins). Several thumbs post several entries: read them with `FormData.getAll()`. |
|
|
239
239
|
| `form` | `string` | – | The `form` attribute for every thumb's input. |
|
|
240
|
-
| `disabled` | `boolean` | `false` | Disables every input (not submitted) and the pointer. |
|
|
240
|
+
| `disabled` | `boolean` | `false` | Disables every input (not submitted) and the pointer. An ancestor `<fieldset disabled>` does the same (the pointer reads the inputs' `:disabled`), but `data-disabled` and `state.disabled` stay this prop's. |
|
|
241
241
|
| `className` | `string \| ((state: SliderRootState<T>) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
242
242
|
| `style` | `CSSProperties \| ((state: SliderRootState<T>) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
|
|
243
243
|
| `children` | `ReactNode \| ((state: SliderRootState<T>) => ReactNode)` | – | The parts. The function form receives the shown value; must not suspend. |
|
|
@@ -338,7 +338,7 @@ Render it inside `Tooltip.Popup`.
|
|
|
338
338
|
|
|
339
339
|
- The popup has `role="tooltip"`; the trigger gets `aria-describedby` or `aria-labelledby` per `provides`, and no `aria-expanded`. The relation works while the popup is hidden, so screen readers announce the text on focus in every engine.
|
|
340
340
|
- The trigger must be focusable. A natively `disabled` button never shows a tooltip; use `aria-disabled="true"` on a control that needs one.
|
|
341
|
-
- Tooltips must not contain interactive content.
|
|
341
|
+
- Tooltips must not contain interactive content. For a rich preview with links and buttons, use a [HoverCard](hover-card.md); for content the user works in, a dialog or popover.
|
|
342
342
|
- Do not put the only copy of important information in a tooltip: touch users may never see it.
|
|
343
343
|
|
|
344
344
|
In development, the library warns when `provides="name"` is combined with an `aria-label`, when the trigger is not focusable, and when the popup contains focusable content.
|
|
@@ -11,9 +11,9 @@ The flags today. What each one does is documented in the props table of the part
|
|
|
11
11
|
| Prop | Platform feature | Native path today | Documented on |
|
|
12
12
|
| - | - | - | - |
|
|
13
13
|
| `experimental_focusgroup` | `focusgroup` | Chromium 150+ | [Tabs.List](../components/tabs.md#props), [Toolbar.Root](../components/toolbar.md#props), [ToggleGroup.Root](../components/toggle-group.md#props), [Menu.Popup](../components/menu.md#props) |
|
|
14
|
-
| `experimental_interpolateSize` | `interpolate-size` | Chromium | [Accordion.Root](../components/accordion.md#props) |
|
|
15
|
-
| `experimental_interestFor` | `interestfor` | Chromium | [Tooltip.Trigger](../components/tooltip.md#props), [Tooltip skip-delay](../components/tooltip.md#skip-delay) |
|
|
16
|
-
| `experimental_hint` | `popover="hint"` | Chromium, Firefox (Safari 27.0 treats it as `manual`) | [Tooltip.Popup](../components/tooltip.md#props) |
|
|
14
|
+
| `experimental_interpolateSize` | `interpolate-size` | Chromium | [Accordion.Root](../components/accordion.md#props), [Collapsible.Root](../components/collapsible.md#props) |
|
|
15
|
+
| `experimental_interestFor` | `interestfor` | Chromium | [Tooltip.Trigger](../components/tooltip.md#props), [Tooltip skip-delay](../components/tooltip.md#skip-delay), [HoverCard.Trigger](../components/hover-card.md#props) |
|
|
16
|
+
| `experimental_hint` | `popover="hint"` | Chromium, Firefox (Safari 27.0 treats it as `manual`) | [Tooltip.Popup](../components/tooltip.md#props), [HoverCard.Popup](../components/hover-card.md#props) |
|
|
17
17
|
| `experimental_closedBy` | `closedby` | Chromium, Firefox | [Dialog.Popup](../components/dialog.md#props) |
|
|
18
18
|
|
|
19
19
|
```tsx
|
|
@@ -26,7 +26,7 @@ export function Settings() {
|
|
|
26
26
|
}
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
Compound parts find their Root through context, and a Server Component cannot read context, so parts are client modules. The exceptions are [Progress](../components/progress.md) and [Meter](../components/meter.md): their Roots have no `"use client"` (they only compute, then render a context provider created in a client module), so a Server Component renders the Root on the server, may pass it function props, and only the small context module and the parts reach the browser.
|
|
29
|
+
Compound parts find their Root through context, and a Server Component cannot read context, so parts are client modules. The exceptions are [Progress](../components/progress.md) and [Meter](../components/meter.md): their Roots have no `"use client"` (they only compute, then render a context provider created in a client module), so a Server Component renders the Root on the server, may pass it function props, and only the small context module and the parts reach the browser. [Separator](../components/separator.md) is directive-free too and reads no context at all: rendered by a Server Component, it runs on the server, function props included, and sends no code to the browser.
|
|
30
30
|
|
|
31
31
|
A framework that renders several server payloads into one page must give each its own `identifierPrefix`, or server-rendered ids from different payloads can collide.
|
|
32
32
|
|
package/dist/docs/index.md
CHANGED
|
@@ -118,7 +118,7 @@ npm install @funstack/ui@alpha
|
|
|
118
118
|
|
|
119
119
|
React 19.3 or later. Supported browsers: **the latest stable Blink, WebKit and Gecko. No fallbacks.** Platform features not yet in all three are opt-in [experimental props](concepts/experimental.md).
|
|
120
120
|
|
|
121
|
-
Components: [Button](components/button.md), [Toggle](components/toggle.md), [ToggleGroup](components/toggle-group.md), [Toolbar](components/toolbar.md), [Tabs](components/tabs.md), [Accordion](components/accordion.md), [Tooltip](components/tooltip.md), [Popover](components/popover.md), [Dialog](components/dialog.md), [Menu](components/menu.md), [Context menu (Menu)](components/context-menu.md), [Toast](components/toast.md), [Field and Form](components/field.md), [Checkbox](components/checkbox.md), [CheckboxGroup](components/checkbox-group.md), [RadioGroup](components/radio-group.md), [Switch](components/switch.md), [Select](components/select.md), [Combobox](components/combobox.md), [Slider](components/slider.md), [NumberField](components/number-field.md), [Progress](components/progress.md)
|
|
121
|
+
Components: [Button](components/button.md), [Toggle](components/toggle.md), [ToggleGroup](components/toggle-group.md), [Toolbar](components/toolbar.md), [Tabs](components/tabs.md), [Accordion](components/accordion.md), [Collapsible](components/collapsible.md), [Tooltip](components/tooltip.md), [HoverCard](components/hover-card.md), [Popover](components/popover.md), [Dialog](components/dialog.md), [AlertDialog](components/alert-dialog.md), [Menu](components/menu.md), [Context menu (Menu)](components/context-menu.md), [Toast](components/toast.md), [Field and Form](components/field.md), [Checkbox](components/checkbox.md), [CheckboxGroup](components/checkbox-group.md), [RadioGroup](components/radio-group.md), [Switch](components/switch.md), [Select](components/select.md), [Combobox](components/combobox.md), [MultiSelect](components/multi-select.md), [Slider](components/slider.md), [NumberField](components/number-field.md), [Progress](components/progress.md), [Meter](components/meter.md) and [Separator](components/separator.md). More are coming; see the [roadmap](roadmap.md).
|
|
122
122
|
|
|
123
123
|
## The FUNSTACK family
|
|
124
124
|
|
|
@@ -159,9 +159,12 @@ FUNSTACK UI is part of the FUNSTACK family, which aims to be the most modern Rea
|
|
|
159
159
|
- [Toolbar](components/toolbar.md): A WAI-ARIA toolbar with one Tab stop and arrow keys over any focusable children: toggles, menu buttons, links, inputs. No wrapper parts.
|
|
160
160
|
- [Tabs](components/tabs.md): Tabs with optimistic selection, committed panels that may suspend, automatic or manual activation, an anchor-positioned indicator, and find-in-page support.
|
|
161
161
|
- [Accordion](components/accordion.md): An accordion built on \<details>/\<summary>: no JavaScript when you need no state; actions, optimistic data-open and Suspense-friendly panels when you do.
|
|
162
|
+
- [Collapsible](components/collapsible.md): One disclosure built on \<details>/\<summary>: no JavaScript when you need no state; actions, optimistic data-open and Suspense-friendly content when you do.
|
|
162
163
|
- [Tooltip](components/tooltip.md): A tooltip built on the Popover API and CSS Anchor Positioning, with a native interestfor path in Chromium. Open state belongs to the browser.
|
|
164
|
+
- [HoverCard](components/hover-card.md): A rich preview that appears when the user rests the pointer on a link or focuses it: the open is a transition, so the content loads on interest and the card appears when it is ready; every close is a fact.
|
|
163
165
|
- [Popover](components/popover.md): A non-modal popover on the Popover API: JS-free when you need no state; a transition-driven open, library-owned closes with a ViewTransition exit in every engine, and Suspense-ready content when you do.
|
|
164
166
|
- [Dialog](components/dialog.md): A dialog built on \<dialog> and Invoker Commands: JS-free when you need no state; a transition-driven open with a pending trigger, Suspense-ready content, and library-owned closes with a ViewTransition exit in every engine when you do.
|
|
167
|
+
- [AlertDialog](components/alert-dialog.md): A Dialog with alert defaults: role alertdialog, always modal, no light dismiss, focus on Cancel. The confirm button runs your async action with its own pending state, closes when it resolves and stays open when it rejects.
|
|
165
168
|
- [Menu](components/menu.md): A menu button on the Popover API: items whose actions run in their own transition with pending state, optimistic checkbox and radio items, the APG keyboard model with typeahead, and submenus with hover intent.
|
|
166
169
|
- [Context menu (Menu)](components/context-menu.md): Menu.ContextTrigger: a region whose right-click, Shift+F10 or touch long-press opens a Menu at the pointer, with the menu's pending items, optimistic checkbox and radio items and submenus unchanged.
|
|
167
170
|
- [Toast](components/toast.md): Notifications fed by a toast() function and rendered by your own Viewport: an urgent queue that shows while the action it reports on is still pending, promise toasts, an Undo action prop, an onClose handler for the Undo window, ariaNotify announcements, and a region that stays interactive above modal dialogs.
|
|
@@ -171,11 +174,13 @@ FUNSTACK UI is part of the FUNSTACK family, which aims to be the most modern Rea
|
|
|
171
174
|
- [RadioGroup](components/radio-group.md): A radio group of native \<input type=radio> in a \<fieldset>: native keyboard and forms, an async valueChangeAction, optimistic checked state and data-pending.
|
|
172
175
|
- [Switch](components/switch.md): An on/off switch rendered as a native \<input type=checkbox role=switch>: optimistic checked state, data-pending while checkedChangeAction runs, native form participation.
|
|
173
176
|
- [Select](components/select.md): A real \<select>, progressively enhanced with customizable select (appearance: base-select): native forms, keyboard and pickers, an async valueChangeAction, optimistic selection and data-pending.
|
|
174
|
-
- [Combobox](components/combobox.md): An editable combobox with list autocomplete: urgent typing, results from a deferred query inside Suspense, aria-activedescendant, an async valueChangeAction with the option pending, free text, forms and ariaNotify.
|
|
177
|
+
- [Combobox](components/combobox.md): An editable combobox with list autocomplete: urgent typing, results from a deferred query inside Suspense, aria-activedescendant, an async valueChangeAction with the option pending, free text, multiple selection with chips, forms and ariaNotify.
|
|
178
|
+
- [MultiSelect](components/multi-select.md): A select-only combobox with a multi-select listbox: a button that shows the selection, options that load on open inside Suspense, a pick that toggles with an optimistic selection and the option pending, the open state as actions and facts, forms and required.
|
|
175
179
|
- [Slider](components/slider.md): A slider on a visually hidden native \<input type=range> per thumb: every step a transition, each gesture saved once with rollback, multi-thumb, vertical and RTL.
|
|
176
180
|
- [NumberField](components/number-field.md): A text field that holds a number: typed in the user's locale, stepped with keys and press-and-hold buttons, posted as a plain number through a hidden native number input, saved once per gesture with rollback.
|
|
177
181
|
- [Progress](components/progress.md): A progress bar on div\[role=progressbar]: the display of someone else's action, correct in every lane, localised aria-valuetext, and a Root that is itself a Server Component.
|
|
178
182
|
- [Meter](components/meter.md): A gauge on div\[role=meter] with the platform's low / high / optimum regions, localised aria-valuetext, and a Root that is itself a Server Component.
|
|
183
|
+
- [Separator](components/separator.md): A line between two pieces of content: an hr with aria-orientation and data-orientation, a decorative mode, and a component that is itself a Server Component.
|
|
179
184
|
|
|
180
185
|
### Resources
|
|
181
186
|
|
package/dist/docs/roadmap.md
CHANGED
|
@@ -10,6 +10,14 @@ Alpha releases (`0.1.0-alpha.N`) are published on npm under the `alpha` dist-tag
|
|
|
10
10
|
|
|
11
11
|
Changes an upgrade may notice, newest first. Each component page documents the current behaviour.
|
|
12
12
|
|
|
13
|
+
- A `Dialog.Close` or `Popover.Close` with an `action` no longer renders `commandfor` / `command` ([#182](https://github.com/uhyo/funstack-ui/issues/182)). A click before hydration used to close the dialog or popover natively without running the action; it now does nothing until the page has hydrated, and then runs the action and closes. A Close without `action` is unchanged (a native invoker). Selectors on `[command]` no longer match such a button.
|
|
14
|
+
|
|
15
|
+
- New component [AlertDialog](components/alert-dialog.md) ([#167](https://github.com/uhyo/funstack-ui/issues/167)): a Dialog with `role="alertdialog"`, no light dismiss and focus on Cancel, whose `Action` runs an async action and closes when it resolves. Development messages of a Dialog part outside its Root now name the Root of its own namespace.
|
|
16
|
+
|
|
17
|
+
- New component [Separator](components/separator.md) ([#169](https://github.com/uhyo/funstack-ui/issues/169)). `Field.Control` no longer throws outside a `Field.Root`: it renders the plain control and accepts `id`. A Slider's Track and Thumb and NumberField's Increment / Decrement no longer move or dispatch inside a `<fieldset disabled>` ([#180](https://github.com/uhyo/funstack-ui/issues/180)); before, a drag or a press still changed the value although the browser had disabled the inputs.
|
|
18
|
+
|
|
19
|
+
- New component [MultiSelect](components/multi-select.md) ([#165](https://github.com/uhyo/funstack-ui/issues/165)). `<Select.Root multiple>`, already a type error, no longer reaches the `<select>`: the attribute is dropped with a development warning that names MultiSelect. `Field.Label` focuses a button control (MultiSelect's Trigger) instead of clicking it.
|
|
20
|
+
|
|
13
21
|
- A disabled `Button` whose click the browser acts on (`type="submit"` or `"reset"`, the `formAction` default, `commandfor` / `popoverTarget`, with or without `action`) keeps native `disabled` also with a component or `<input>` `render`, as `Form.Submit` does; it used to render `aria-disabled`, which does not stop a submission or command before hydration ([#158](https://github.com/uhyo/funstack-ui/issues/158)). Inside a `Toolbar.Root` or with `focusableWhenDisabled` nothing changes. A natively disabled `Button`, `Dialog.Close`, `Popover.Close` or `Toast.Action` that is also pending no longer adds `aria-disabled`: native `disabled` wins. A disabled JS-free Trigger or Close of a Dialog or Popover rendered as a host link renders `aria-disabled` instead of a meaningless `disabled` attribute, and its click is cancelled (the link no longer navigates after hydration).
|
|
14
22
|
|
|
15
23
|
- Three alignments with the library-wide rules ([#157](https://github.com/uhyo/funstack-ui/issues/157)):
|
|
@@ -8,6 +8,11 @@ import { CSSProperties, ComponentPropsWithRef } from "react";
|
|
|
8
8
|
* @see https://ui.funstack.work/components/field
|
|
9
9
|
*/
|
|
10
10
|
export interface FieldControlProps extends Omit<ComponentPropsWithRef<"input">, "id" | "aria-invalid" | "className" | "style" | "children"> {
|
|
11
|
+
/**
|
|
12
|
+
* Native `id`, used outside a `Field.Root` only. Inside one the Field owns the id (so that
|
|
13
|
+
* `Field.Label` can point at it) and this prop is ignored with a development warning.
|
|
14
|
+
*/
|
|
15
|
+
id?: string;
|
|
11
16
|
/**
|
|
12
17
|
* Native `name`.
|
|
13
18
|
*
|
|
@@ -42,13 +47,17 @@ export interface FieldControlProps extends Omit<ComponentPropsWithRef<"input">,
|
|
|
42
47
|
* `required` from the Field unless given. Everything else passes through, including `onChange`
|
|
43
48
|
* / `value` for a controlled input; the Field's listeners are native and run independently.
|
|
44
49
|
*
|
|
45
|
-
* Owned keys (conventions 1.2): `id`, `name`, `disabled`, `required`,
|
|
46
|
-
* `aria-describedby` (token-merged), `data-invalid`, `data-disabled`,
|
|
47
|
-
* `data-pending`.
|
|
50
|
+
* Owned keys inside a Field (conventions 1.2): `id`, `name`, `disabled`, `required`,
|
|
51
|
+
* `aria-invalid`, `aria-describedby` (token-merged), `data-invalid`, `data-disabled`,
|
|
52
|
+
* `data-required`, `data-pending`.
|
|
53
|
+
*
|
|
54
|
+
* Outside a `Field.Root` it is the plain native control: every prop passes through (`id`
|
|
55
|
+
* included), the library adds no attribute, and the function props receive a state that is
|
|
56
|
+
* never invalid or pending, with `disabled` / `required` from the own props.
|
|
48
57
|
*
|
|
49
58
|
* @see https://ui.funstack.work/components/field
|
|
50
59
|
*/
|
|
51
|
-
export declare function FieldControl({ name, disabled, required, className, style, render, ...
|
|
60
|
+
export declare function FieldControl({ id: consumerId, name, disabled, required, className, style, render, ...props }: FieldControlProps): import("react").ReactNode;
|
|
52
61
|
export declare namespace FieldControl {
|
|
53
62
|
var displayName: string;
|
|
54
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-control.d.mts","names":[],"sources":["../../src/field/field-control.tsx"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"field-control.d.mts","names":[],"sources":["../../src/field/field-control.tsx"],"mappings":";;;;;;;;;iBAmBiB,0BAA0B,KACzC;;;;;EAOA;;;;;;EAMA;;;;;;;EAOA;;;;;;;EAOA;;EAEA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,gCAAgC;;;;;;;;;;;;;;;;;;;wBA8CtC,eACd,IAAI,YACJ,MACA,UACA,UACA,WACA,OACA,WACG,SACF,oCAAiB;yBATJ"}
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
import { useRender } from "../internal/use-render.mjs";
|
|
3
3
|
import { useElementCheck } from "../internal/use-element-check.mjs";
|
|
4
4
|
import { useMergedRefs } from "../internal/use-merged-refs.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { FieldContext, fieldDataAttributes } from "../internal/form/field-context.mjs";
|
|
6
6
|
import { useFieldControl } from "../internal/form/use-field-control.mjs";
|
|
7
|
+
import { VALID } from "../internal/form/validity.mjs";
|
|
8
|
+
import { use } from "react";
|
|
7
9
|
//#region src/field/field-control.tsx
|
|
8
10
|
const isDev = process.env.NODE_ENV !== "production";
|
|
9
11
|
const CONTROL_TAGS = /* @__PURE__ */ new Set([
|
|
@@ -12,21 +14,42 @@ const CONTROL_TAGS = /* @__PURE__ */ new Set([
|
|
|
12
14
|
"SELECT"
|
|
13
15
|
]);
|
|
14
16
|
/**
|
|
17
|
+
* The states the function props receive outside a `Field.Root` (design/components/field-form.md
|
|
18
|
+
* 4.3): never invalid or pending (no validation without a Field), with `disabled` / `required`
|
|
19
|
+
* from the control's own props, as inside a Field and as a standalone Checkbox reports them.
|
|
20
|
+
* One frozen object per combination, indexed `disabled * 2 + required`.
|
|
21
|
+
*/
|
|
22
|
+
const NO_MESSAGES = Object.freeze([]);
|
|
23
|
+
const STANDALONE_STATES = [false, true].flatMap((disabled) => [false, true].map((required) => Object.freeze({
|
|
24
|
+
invalid: false,
|
|
25
|
+
messages: NO_MESSAGES,
|
|
26
|
+
validity: VALID,
|
|
27
|
+
disabled,
|
|
28
|
+
required,
|
|
29
|
+
pending: false
|
|
30
|
+
})));
|
|
31
|
+
function standaloneState(disabled, required) {
|
|
32
|
+
return STANDALONE_STATES[(disabled === true ? 2 : 0) + (required === true ? 1 : 0)];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
15
35
|
* The field's native control: an `<input>` (or a `<textarea>` / `<select>` through `render`)
|
|
16
36
|
* wired to the Field: `id` for the Label, `aria-describedby` (the consumer's tokens, the
|
|
17
37
|
* description, the error while shown), an explicit `aria-invalid`, and `name` / `disabled` /
|
|
18
38
|
* `required` from the Field unless given. Everything else passes through, including `onChange`
|
|
19
39
|
* / `value` for a controlled input; the Field's listeners are native and run independently.
|
|
20
40
|
*
|
|
21
|
-
* Owned keys (conventions 1.2): `id`, `name`, `disabled`, `required`,
|
|
22
|
-
* `aria-describedby` (token-merged), `data-invalid`, `data-disabled`,
|
|
23
|
-
* `data-pending`.
|
|
41
|
+
* Owned keys inside a Field (conventions 1.2): `id`, `name`, `disabled`, `required`,
|
|
42
|
+
* `aria-invalid`, `aria-describedby` (token-merged), `data-invalid`, `data-disabled`,
|
|
43
|
+
* `data-required`, `data-pending`.
|
|
44
|
+
*
|
|
45
|
+
* Outside a `Field.Root` it is the plain native control: every prop passes through (`id`
|
|
46
|
+
* included), the library adds no attribute, and the function props receive a state that is
|
|
47
|
+
* never invalid or pending, with `disabled` / `required` from the own props.
|
|
24
48
|
*
|
|
25
49
|
* @see https://ui.funstack.work/components/field
|
|
26
50
|
*/
|
|
27
|
-
function FieldControl({ name, disabled, required, className, style, render, ...
|
|
28
|
-
const ctx =
|
|
29
|
-
const { id: consumerId, ...props } = rest;
|
|
51
|
+
function FieldControl({ id: consumerId, name, disabled, required, className, style, render, ...props }) {
|
|
52
|
+
const ctx = use(FieldContext);
|
|
30
53
|
const field = useFieldControl({
|
|
31
54
|
labelable: true,
|
|
32
55
|
name,
|
|
@@ -40,12 +63,18 @@ function FieldControl({ name, disabled, required, className, style, render, ...r
|
|
|
40
63
|
return useRender({
|
|
41
64
|
defaultElement: "input",
|
|
42
65
|
render,
|
|
43
|
-
state: ctx.state,
|
|
66
|
+
state: ctx === null ? standaloneState(disabled, required) : ctx.state,
|
|
44
67
|
className,
|
|
45
68
|
style,
|
|
46
69
|
children: void 0,
|
|
47
|
-
props
|
|
48
|
-
|
|
70
|
+
props: ctx === null ? {
|
|
71
|
+
...props,
|
|
72
|
+
id: consumerId,
|
|
73
|
+
name,
|
|
74
|
+
disabled,
|
|
75
|
+
required
|
|
76
|
+
} : props,
|
|
77
|
+
libraryProps: ctx === null ? void 0 : {
|
|
49
78
|
id: field.id,
|
|
50
79
|
name: field.name,
|
|
51
80
|
disabled: field.disabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-control.mjs","names":[],"sources":["../../src/field/field-control.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"field-control.mjs","names":[],"sources":["../../src/field/field-control.tsx"],"sourcesContent":["\"use client\";\nimport { use } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties } from \"react\";\nimport { FieldContext, fieldDataAttributes } from \"../internal/form/field-context.js\";\nimport type { FieldState } from \"../internal/form/field-context.js\";\nimport { VALID } from \"../internal/form/validity.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useFieldControl } from \"../internal/form/use-field-control.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Props of `Field.Control`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport interface FieldControlProps extends Omit<\n ComponentPropsWithRef<\"input\">,\n \"id\" | \"aria-invalid\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Native `id`, used outside a `Field.Root` only. Inside one the Field owns the id (so that\n * `Field.Label` can point at it) and this prop is ignored with a development warning.\n */\n id?: string;\n /**\n * Native `name`.\n *\n * @defaultValue the Field's `name`\n */\n name?: string;\n /**\n * Native `disabled`. Owned. Also `true` when the Field is disabled: an explicit `false` does not\n * override the Field.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /**\n * Native `required`. Owned. Also `true` when the Field is required: an explicit `false` does not\n * override the Field.\n *\n * @defaultValue `false`\n */\n required?: boolean;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, FieldState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, FieldState>;\n /** Must render an `<input>`, `<textarea>` or `<select>`: `render={<textarea rows={3} />}`. */\n render?: RenderProp<ComponentPropsWithRef<\"input\">, FieldState>;\n}\n\nconst CONTROL_TAGS = new Set([\"INPUT\", \"TEXTAREA\", \"SELECT\"]);\n\n/**\n * The states the function props receive outside a `Field.Root` (design/components/field-form.md\n * 4.3): never invalid or pending (no validation without a Field), with `disabled` / `required`\n * from the control's own props, as inside a Field and as a standalone Checkbox reports them.\n * One frozen object per combination, indexed `disabled * 2 + required`.\n */\nconst NO_MESSAGES: readonly string[] = Object.freeze([]);\nconst STANDALONE_STATES: readonly FieldState[] = [false, true].flatMap((disabled) =>\n [false, true].map((required) =>\n Object.freeze({\n invalid: false,\n messages: NO_MESSAGES,\n validity: VALID,\n disabled,\n required,\n pending: false,\n }),\n ),\n);\n\nfunction standaloneState(disabled: boolean | undefined, required: boolean | undefined) {\n return STANDALONE_STATES[(disabled === true ? 2 : 0) + (required === true ? 1 : 0)]!;\n}\n\n/**\n * The field's native control: an `<input>` (or a `<textarea>` / `<select>` through `render`)\n * wired to the Field: `id` for the Label, `aria-describedby` (the consumer's tokens, the\n * description, the error while shown), an explicit `aria-invalid`, and `name` / `disabled` /\n * `required` from the Field unless given. Everything else passes through, including `onChange`\n * / `value` for a controlled input; the Field's listeners are native and run independently.\n *\n * Owned keys inside a Field (conventions 1.2): `id`, `name`, `disabled`, `required`,\n * `aria-invalid`, `aria-describedby` (token-merged), `data-invalid`, `data-disabled`,\n * `data-required`, `data-pending`.\n *\n * Outside a `Field.Root` it is the plain native control: every prop passes through (`id`\n * included), the library adds no attribute, and the function props receive a state that is\n * never invalid or pending, with `disabled` / `required` from the own props.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport function FieldControl({\n id: consumerId,\n name,\n disabled,\n required,\n className,\n style,\n render,\n ...props\n}: FieldControlProps) {\n const ctx = use(FieldContext);\n const field = useFieldControl({\n labelable: true,\n name,\n disabled,\n required,\n id: consumerId,\n component: \"Field.Control\",\n });\n const checkElement = useElementCheck(\n isDev &&\n ((el) =>\n !CONTROL_TAGS.has(el.tagName)\n ? \"Field.Control: expected to render an <input>, <textarea> or <select> but got \" +\n `<${el.tagName.toLowerCase()}>. Validation, labelling and form participation need a ` +\n \"native form control.\"\n : null),\n );\n const ref = useMergedRefs<HTMLElement>(checkElement, field.ref);\n\n return useRender<ComponentPropsWithRef<\"input\">, FieldState>({\n defaultElement: \"input\",\n render,\n state: ctx === null ? standaloneState(disabled, required) : ctx.state,\n className,\n style,\n children: undefined,\n // Outside a Field the own props are ordinary pass-through: a `render` element's own `id` /\n // `disabled` / `required` win over them, as for any pass-through prop (conventions 1.2).\n props: ctx === null ? { ...props, id: consumerId, name, disabled, required } : props,\n libraryProps:\n ctx === null\n ? undefined\n : {\n id: field.id,\n name: field.name,\n disabled: field.disabled,\n required: field.required,\n ...field.attributes,\n ...fieldDataAttributes(ctx.state),\n },\n ref,\n });\n}\n\nFieldControl.displayName = \"FieldControl\";\n"],"mappings":";;;;;;;;;AAYA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AA4CvC,MAAM,+BAAe,IAAI,IAAI;CAAC;CAAS;CAAY;AAAQ,CAAC;;;;;;;AAQ5D,MAAM,cAAiC,OAAO,OAAO,CAAC,CAAC;AACvD,MAAM,oBAA2C,CAAC,OAAO,IAAI,CAAC,CAAC,SAAS,aACtE,CAAC,OAAO,IAAI,CAAC,CAAC,KAAK,aACjB,OAAO,OAAO;CACZ,SAAS;CACT,UAAU;CACV,UAAU;CACV;CACA;CACA,SAAS;AACX,CAAC,CACH,CACF;AAEA,SAAS,gBAAgB,UAA+B,UAA+B;CACrF,OAAO,mBAAmB,aAAa,OAAO,IAAI,MAAM,aAAa,OAAO,IAAI;AAClF;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,aAAa,EAC3B,IAAI,YACJ,MACA,UACA,UACA,WACA,OACA,QACA,GAAG,SACiB;CACpB,MAAM,MAAM,IAAI,YAAY;CAC5B,MAAM,QAAQ,gBAAgB;EAC5B,WAAW;EACX;EACA;EACA;EACA,IAAI;EACJ,WAAW;CACb,CAAC;CACD,MAAM,eAAe,gBACnB,WACI,OACA,CAAC,aAAa,IAAI,GAAG,OAAO,IACxB,iFACI,GAAG,QAAQ,YAAY,EAAE,+EAE7B,KACV;CACA,MAAM,MAAM,cAA2B,cAAc,MAAM,GAAG;CAE9D,OAAO,UAAsD;EAC3D,gBAAgB;EAChB;EACA,OAAO,QAAQ,OAAO,gBAAgB,UAAU,QAAQ,IAAI,IAAI;EAChE;EACA;EACA,UAAU,KAAA;EAGV,OAAO,QAAQ,OAAO;GAAE,GAAG;GAAO,IAAI;GAAY;GAAM;GAAU;EAAS,IAAI;EAC/E,cACE,QAAQ,OACJ,KAAA,IACA;GACE,IAAI,MAAM;GACV,MAAM,MAAM;GACZ,UAAU,MAAM;GAChB,UAAU,MAAM;GAChB,GAAG,MAAM;GACT,GAAG,oBAAoB,IAAI,KAAK;EAClC;EACN;CACF,CAAC;AACH;AAEA,aAAa,cAAc"}
|
|
@@ -22,8 +22,12 @@ export interface FieldLabelProps extends Omit<ComponentPropsWithRef<"label">, "h
|
|
|
22
22
|
* RadioGroup or CheckboxGroup `<fieldset>`) it renders no `for` once the group registered, and
|
|
23
23
|
* the group names itself with `aria-labelledby` → this id (design 4.2).
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* A `<label for>` on a `<button>` forwards a click to it. For a button control (MultiSelect's
|
|
26
|
+
* Trigger, multi-select.md B.10) the click is cancelled and the button is focused instead, as a
|
|
27
|
+
* label focuses a `<select>` without opening it.
|
|
28
|
+
*
|
|
29
|
+
* Owned keys (conventions 1.2): `id`, `htmlFor`, `onClick` (composed), `data-invalid`,
|
|
30
|
+
* `data-disabled`, `data-required`, `data-pending`.
|
|
27
31
|
*
|
|
28
32
|
* @see https://ui.funstack.work/components/field
|
|
29
33
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-label.d.mts","names":[],"sources":["../../src/field/field-label.tsx"],"mappings":";;;;;;;;;iBAeiB,wBAAwB,KACvC;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,gCAAgC
|
|
1
|
+
{"version":3,"file":"field-label.d.mts","names":[],"sources":["../../src/field/field-label.tsx"],"mappings":";;;;;;;;;iBAeiB,wBAAwB,KACvC;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,gCAAgC;;;;;;;;;;;;;;;;wBAiBtC,aAAa,WAAW,OAAO,UAAU,WAAW,QAAQ,kBAAe;yBAA3E"}
|
|
@@ -9,8 +9,12 @@ const isDev = process.env.NODE_ENV !== "production";
|
|
|
9
9
|
* RadioGroup or CheckboxGroup `<fieldset>`) it renders no `for` once the group registered, and
|
|
10
10
|
* the group names itself with `aria-labelledby` → this id (design 4.2).
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* A `<label for>` on a `<button>` forwards a click to it. For a button control (MultiSelect's
|
|
13
|
+
* Trigger, multi-select.md B.10) the click is cancelled and the button is focused instead, as a
|
|
14
|
+
* label focuses a `<select>` without opening it.
|
|
15
|
+
*
|
|
16
|
+
* Owned keys (conventions 1.2): `id`, `htmlFor`, `onClick` (composed), `data-invalid`,
|
|
17
|
+
* `data-disabled`, `data-required`, `data-pending`.
|
|
14
18
|
*
|
|
15
19
|
* @see https://ui.funstack.work/components/field
|
|
16
20
|
*/
|
|
@@ -28,6 +32,12 @@ function FieldLabel({ className, style, children, render, ...rest }) {
|
|
|
28
32
|
libraryProps: {
|
|
29
33
|
id: ctx.ids.label,
|
|
30
34
|
htmlFor: ctx.labelable ? ctx.ids.control : void 0,
|
|
35
|
+
onClick: (event) => {
|
|
36
|
+
const control = ctx.controlElement();
|
|
37
|
+
if (!(control instanceof HTMLButtonElement) || event.defaultPrevented) return;
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
if (!control.disabled) control.focus();
|
|
40
|
+
},
|
|
31
41
|
...fieldDataAttributes(ctx.state)
|
|
32
42
|
},
|
|
33
43
|
ref
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-label.mjs","names":[],"sources":["../../src/field/field-label.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { fieldDataAttributes, useFieldContext } from \"../internal/form/field-context.js\";\nimport type { FieldState } from \"../internal/form/field-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Props of `Field.Label`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport interface FieldLabelProps extends Omit<\n ComponentPropsWithRef<\"label\">,\n \"htmlFor\" | \"id\" | \"className\" | \"style\" | \"children\"\n> {\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, FieldState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, FieldState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, FieldState>;\n /** Must render a `<label>`. */\n render?: RenderProp<ComponentPropsWithRef<\"label\">, FieldState>;\n}\n\n/**\n * The field's visible name: `<label for>` pointing at the control. For a group control (a\n * RadioGroup or CheckboxGroup `<fieldset>`) it renders no `for` once the group registered, and\n * the group names itself with `aria-labelledby` → this id (design 4.2).\n *\n * Owned keys (conventions 1.2): `id`, `htmlFor`, `
|
|
1
|
+
{"version":3,"file":"field-label.mjs","names":[],"sources":["../../src/field/field-label.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport { fieldDataAttributes, useFieldContext } from \"../internal/form/field-context.js\";\nimport type { FieldState } from \"../internal/form/field-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Props of `Field.Label`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport interface FieldLabelProps extends Omit<\n ComponentPropsWithRef<\"label\">,\n \"htmlFor\" | \"id\" | \"className\" | \"style\" | \"children\"\n> {\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, FieldState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, FieldState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, FieldState>;\n /** Must render a `<label>`. */\n render?: RenderProp<ComponentPropsWithRef<\"label\">, FieldState>;\n}\n\n/**\n * The field's visible name: `<label for>` pointing at the control. For a group control (a\n * RadioGroup or CheckboxGroup `<fieldset>`) it renders no `for` once the group registered, and\n * the group names itself with `aria-labelledby` → this id (design 4.2).\n *\n * A `<label for>` on a `<button>` forwards a click to it. For a button control (MultiSelect's\n * Trigger, multi-select.md B.10) the click is cancelled and the button is focused instead, as a\n * label focuses a `<select>` without opening it.\n *\n * Owned keys (conventions 1.2): `id`, `htmlFor`, `onClick` (composed), `data-invalid`,\n * `data-disabled`, `data-required`, `data-pending`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport function FieldLabel({ className, style, children, render, ...rest }: FieldLabelProps) {\n const ctx = useFieldContext(\"Field.Label\");\n const ref = useElementCheck(\n isDev &&\n ((el) =>\n el.tagName !== \"LABEL\"\n ? `Field.Label: expected to render a <label> element but got <${el.tagName.toLowerCase()}>. ` +\n \"Label activation and the control's accessible name need a real <label>.\"\n : null),\n );\n return useRender<ComponentPropsWithRef<\"label\">, FieldState>({\n defaultElement: \"label\",\n render,\n state: ctx.state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n id: ctx.ids.label,\n htmlFor: ctx.labelable ? ctx.ids.control : undefined,\n onClick: (event: MouseEvent<HTMLLabelElement>) => {\n const control = ctx.controlElement();\n if (!(control instanceof HTMLButtonElement) || event.defaultPrevented) return;\n event.preventDefault();\n if (!control.disabled) control.focus();\n },\n ...fieldDataAttributes(ctx.state),\n },\n ref,\n });\n}\n\nFieldLabel.displayName = \"FieldLabel\";\n"],"mappings":";;;;;AAQA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;;AAmCvC,SAAgB,WAAW,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QAAyB;CAC3F,MAAM,MAAM,gBAAgB,aAAa;CACzC,MAAM,MAAM,gBACV,WACI,OACA,GAAG,YAAY,UACX,8DAA8D,GAAG,QAAQ,YAAY,EAAE,8EAEvF,KACV;CACA,OAAO,UAAsD;EAC3D,gBAAgB;EAChB;EACA,OAAO,IAAI;EACX;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,IAAI,IAAI,IAAI;GACZ,SAAS,IAAI,YAAY,IAAI,IAAI,UAAU,KAAA;GAC3C,UAAU,UAAwC;IAChD,MAAM,UAAU,IAAI,eAAe;IACnC,IAAI,EAAE,mBAAmB,sBAAsB,MAAM,kBAAkB;IACvE,MAAM,eAAe;IACrB,IAAI,CAAC,QAAQ,UAAU,QAAQ,MAAM;GACvC;GACA,GAAG,oBAAoB,IAAI,KAAK;EAClC;EACA;CACF,CAAC;AACH;AAEA,WAAW,cAAc"}
|