@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
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,22 @@ import { AccordionPanelProps, AccordionPanelState } from "./accordion/accordion-
|
|
|
5
5
|
import { AccordionRootExclusiveProps, AccordionRootMultipleProps, AccordionRootProps, AccordionRootState, AccordionValueChangeDetails } from "./accordion/accordion-root.mjs";
|
|
6
6
|
import { AccordionTriggerProps, AccordionTriggerState } from "./accordion/accordion-trigger.mjs";
|
|
7
7
|
import { Accordion } from "./accordion/index.mjs";
|
|
8
|
+
import { DialogCloseDetails, DialogCloseProps, DialogCloseState } from "./dialog/dialog-close.mjs";
|
|
9
|
+
import { AlertDialogActionDetails, AlertDialogActionProps, AlertDialogActionState } from "./alert-dialog/alert-dialog-action.mjs";
|
|
10
|
+
import { AlertDialogCancelDetails, AlertDialogCancelProps, AlertDialogCancelState } from "./alert-dialog/alert-dialog-cancel.mjs";
|
|
11
|
+
import { DialogPopupProps, DialogPopupState } from "./dialog/dialog-popup.mjs";
|
|
12
|
+
import { DialogDescriptionProps, DialogDescriptionState } from "./dialog/dialog-description.mjs";
|
|
13
|
+
import { AlertDialogDescriptionProps, AlertDialogDescriptionState } from "./alert-dialog/alert-dialog-description.mjs";
|
|
14
|
+
import { DialogFormProps, DialogFormState } from "./dialog/dialog-form.mjs";
|
|
15
|
+
import { AlertDialogFormProps, AlertDialogFormState } from "./alert-dialog/alert-dialog-form.mjs";
|
|
16
|
+
import { AlertDialogPopupProps, AlertDialogPopupState } from "./alert-dialog/alert-dialog-popup.mjs";
|
|
17
|
+
import { DialogOpenChangeDetails, DialogRootProps, DialogRootState } from "./dialog/dialog-root.mjs";
|
|
18
|
+
import { AlertDialogOpenChangeDetails, AlertDialogRootProps, AlertDialogRootState } from "./alert-dialog/alert-dialog-root.mjs";
|
|
19
|
+
import { DialogTitleProps, DialogTitleState } from "./dialog/dialog-title.mjs";
|
|
20
|
+
import { AlertDialogTitleProps, AlertDialogTitleState } from "./alert-dialog/alert-dialog-title.mjs";
|
|
21
|
+
import { DialogTriggerProps, DialogTriggerState } from "./dialog/dialog-trigger.mjs";
|
|
22
|
+
import { AlertDialogTriggerProps, AlertDialogTriggerState } from "./alert-dialog/alert-dialog-trigger.mjs";
|
|
23
|
+
import { AlertDialog } from "./alert-dialog/index.mjs";
|
|
8
24
|
import { Button, ButtonActionDetails, ButtonProps, ButtonState } from "./button/button.mjs";
|
|
9
25
|
import "./button/index.mjs";
|
|
10
26
|
import { CheckboxGroupItemProps, CheckboxGroupItemState } from "./checkbox-group/checkbox-group-item.mjs";
|
|
@@ -14,6 +30,11 @@ import { CheckboxGroupParentProps, CheckboxGroupParentState } from "./checkbox-g
|
|
|
14
30
|
import { CheckboxGroup } from "./checkbox-group/index.mjs";
|
|
15
31
|
import { Checkbox, CheckboxCheckedChangeDetails, CheckboxProps, CheckboxState } from "./checkbox/checkbox.mjs";
|
|
16
32
|
import "./checkbox/index.mjs";
|
|
33
|
+
import { CollapsiblePanelProps, CollapsiblePanelState } from "./collapsible/collapsible-panel.mjs";
|
|
34
|
+
import { CollapsibleOpenChangeDetails, CollapsibleRootProps, CollapsibleRootState } from "./collapsible/collapsible-root.mjs";
|
|
35
|
+
import { CollapsibleTriggerProps, CollapsibleTriggerState } from "./collapsible/collapsible-trigger.mjs";
|
|
36
|
+
import { Collapsible } from "./collapsible/index.mjs";
|
|
37
|
+
import { ComboboxChipProps, ComboboxChipRemoveProps, ComboboxChipRemoveState, ComboboxChipState, ComboboxChipsProps, ComboboxChipsState } from "./combobox/combobox-chips.mjs";
|
|
17
38
|
import { ComboboxClearProps, ComboboxClearState } from "./combobox/combobox-clear.mjs";
|
|
18
39
|
import { ComboboxListProps, ComboboxListState } from "./combobox/combobox-list.mjs";
|
|
19
40
|
import { ComboboxEmptyProps, ComboboxEmptyState, ComboboxGroupLabelProps, ComboboxGroupLabelState, ComboboxGroupProps, ComboboxGroupState, ComboboxStatusProps, ComboboxStatusState } from "./combobox/combobox-group.mjs";
|
|
@@ -21,19 +42,12 @@ import { ComboboxInputProps, ComboboxInputState } from "./combobox/combobox-inpu
|
|
|
21
42
|
import { ComboboxLabelProps, ComboboxLabelState } from "./combobox/combobox-label.mjs";
|
|
22
43
|
import { ComboboxOptionProps, ComboboxOptionState } from "./combobox/combobox-option.mjs";
|
|
23
44
|
import { ComboboxPopupProps, ComboboxPopupState } from "./combobox/combobox-popup.mjs";
|
|
24
|
-
import { ComboboxInputValueChangeDetails, ComboboxOpenChangeDetails, ComboboxRootProps, ComboboxRootState, ComboboxValueChangeDetails } from "./combobox/combobox-root.mjs";
|
|
45
|
+
import { ComboboxInputValueChangeDetails, ComboboxMultipleProps, ComboboxMultipleRootState, ComboboxMultipleValueChangeDetails, ComboboxOpenChangeDetails, ComboboxRootProps, ComboboxRootState, ComboboxSingleProps, ComboboxValueChangeDetails } from "./combobox/combobox-root.mjs";
|
|
25
46
|
import { ComboboxTriggerProps, ComboboxTriggerState } from "./combobox/combobox-trigger.mjs";
|
|
26
47
|
import { Combobox } from "./combobox/index.mjs";
|
|
27
48
|
import { CSPProvider, CSPProviderProps } from "./csp/csp-provider.mjs";
|
|
28
49
|
import { STYLE_SHA256 } from "./csp/style-hashes.mjs";
|
|
29
50
|
import "./csp/index.mjs";
|
|
30
|
-
import { DialogCloseDetails, DialogCloseProps, DialogCloseState } from "./dialog/dialog-close.mjs";
|
|
31
|
-
import { DialogPopupProps, DialogPopupState } from "./dialog/dialog-popup.mjs";
|
|
32
|
-
import { DialogDescriptionProps, DialogDescriptionState } from "./dialog/dialog-description.mjs";
|
|
33
|
-
import { DialogFormProps, DialogFormState } from "./dialog/dialog-form.mjs";
|
|
34
|
-
import { DialogOpenChangeDetails, DialogRootProps, DialogRootState } from "./dialog/dialog-root.mjs";
|
|
35
|
-
import { DialogTitleProps, DialogTitleState } from "./dialog/dialog-title.mjs";
|
|
36
|
-
import { DialogTriggerProps, DialogTriggerState } from "./dialog/dialog-trigger.mjs";
|
|
37
51
|
import { Dialog } from "./dialog/index.mjs";
|
|
38
52
|
import { FieldErrorValue, FieldValidity, FormErrors } from "./internal/form/validity.mjs";
|
|
39
53
|
import { FieldState } from "./internal/form/field-context.mjs";
|
|
@@ -46,12 +60,18 @@ import { Field } from "./field/index.mjs";
|
|
|
46
60
|
import { FormRootProps, FormRootState } from "./form/form-root.mjs";
|
|
47
61
|
import { FormSubmitProps, FormSubmitState } from "./form/form-submit.mjs";
|
|
48
62
|
import { Form } from "./form/index.mjs";
|
|
63
|
+
import { HoverCardAlign, HoverCardPopupProps, HoverCardPopupState, HoverCardSide } from "./hover-card/hover-card-popup.mjs";
|
|
64
|
+
import { HoverCardOpenChangeDetails, HoverCardRootProps, HoverCardRootState } from "./hover-card/hover-card-root.mjs";
|
|
65
|
+
import { HoverCardTriggerProps, HoverCardTriggerState } from "./hover-card/hover-card-trigger.mjs";
|
|
66
|
+
import { HoverCard } from "./hover-card/index.mjs";
|
|
49
67
|
import { Toggle, TogglePressedChangeDetails, ToggleProps, ToggleState } from "./toggle/toggle.mjs";
|
|
50
68
|
import "./toggle/index.mjs";
|
|
51
69
|
import { ToggleGroupOrientation } from "./toggle-group/toggle-group-context.mjs";
|
|
52
70
|
import { ToggleGroupItemProps, ToggleGroupItemState } from "./toggle-group/toggle-group-item.mjs";
|
|
53
71
|
import { ToggleGroupExclusiveProps, ToggleGroupMultipleProps, ToggleGroupRootProps, ToggleGroupRootState, ToggleGroupValueChangeDetails } from "./toggle-group/toggle-group-root.mjs";
|
|
54
72
|
import { ToggleGroup } from "./toggle-group/index.mjs";
|
|
73
|
+
import { Separator, SeparatorOrientation, SeparatorProps, SeparatorState } from "./separator/separator.mjs";
|
|
74
|
+
import "./separator/index.mjs";
|
|
55
75
|
import { ToolbarOrientation, ToolbarRootProps, ToolbarRootState } from "./toolbar/toolbar-root.mjs";
|
|
56
76
|
import { ToolbarSeparatorProps, ToolbarSeparatorState } from "./toolbar/toolbar-separator.mjs";
|
|
57
77
|
import { Toolbar } from "./toolbar/index.mjs";
|
|
@@ -100,6 +120,15 @@ import { SelectSeparatorProps } from "./select/select-separator.mjs";
|
|
|
100
120
|
import { SelectTriggerProps } from "./select/select-trigger.mjs";
|
|
101
121
|
import { SelectValueProps } from "./select/select-value.mjs";
|
|
102
122
|
import { Select } from "./select/index.mjs";
|
|
123
|
+
import { MultiSelectListProps, MultiSelectListState } from "./multi-select/multi-select-list.mjs";
|
|
124
|
+
import { MultiSelectEmptyProps, MultiSelectEmptyState, MultiSelectGroupLabelProps, MultiSelectGroupLabelState, MultiSelectGroupProps, MultiSelectGroupState, MultiSelectStatusProps, MultiSelectStatusState } from "./multi-select/multi-select-group.mjs";
|
|
125
|
+
import { MultiSelectLabelProps, MultiSelectLabelState } from "./multi-select/multi-select-label.mjs";
|
|
126
|
+
import { MultiSelectOptionProps, MultiSelectOptionState } from "./multi-select/multi-select-option.mjs";
|
|
127
|
+
import { MultiSelectPopupProps, MultiSelectPopupState } from "./multi-select/multi-select-popup.mjs";
|
|
128
|
+
import { MultiSelectOpenChangeDetails, MultiSelectRootProps, MultiSelectRootState, MultiSelectValueChangeDetails } from "./multi-select/multi-select-root.mjs";
|
|
129
|
+
import { MultiSelectTriggerProps, MultiSelectTriggerState } from "./multi-select/multi-select-trigger.mjs";
|
|
130
|
+
import { MultiSelectValueProps, MultiSelectValueState } from "./multi-select/multi-select-value.mjs";
|
|
131
|
+
import { MultiSelect } from "./multi-select/index.mjs";
|
|
103
132
|
import { ToastActionDetails, ToastActionOptions, ToastCloseDetails, ToastItem, ToastManager, ToastOptions, ToastPriority, ToastPromiseOptions, createToastManager, toast } from "./toast/toast.mjs";
|
|
104
133
|
import { ToastActionProps, ToastActionState } from "./toast/toast-action.mjs";
|
|
105
134
|
import { ToastCloseProps, ToastCloseState } from "./toast/toast-close.mjs";
|
|
@@ -133,4 +162,4 @@ import { MeterLabelProps } from "./meter/meter-label.mjs";
|
|
|
133
162
|
import { MeterTrackProps } from "./meter/meter-track.mjs";
|
|
134
163
|
import { MeterValueProps } from "./meter/meter-value.mjs";
|
|
135
164
|
import { Meter } from "./meter/index.mjs";
|
|
136
|
-
export { Accordion, type AccordionItemProps, type AccordionItemState, type AccordionPanelProps, type AccordionPanelState, type AccordionRootExclusiveProps, type AccordionRootMultipleProps, type AccordionRootProps, type AccordionRootState, type AccordionTriggerProps, type AccordionTriggerState, type AccordionValueChangeDetails, type Action, type ActionDetails, Button, type ButtonActionDetails, type ButtonProps, type ButtonState, CSPProvider, type CSPProviderProps, type ChangeAction, type ChangeReason, Checkbox, type CheckboxCheckedChangeDetails, CheckboxGroup, type CheckboxGroupItemProps, type CheckboxGroupItemState, type CheckboxGroupLabelProps, type CheckboxGroupParentProps, type CheckboxGroupParentState, type CheckboxGroupRootProps, type CheckboxGroupRootState, type CheckboxGroupValueChangeDetails, type CheckboxProps, type CheckboxState, Combobox, type ComboboxClearProps, type ComboboxClearState, type ComboboxEmptyProps, type ComboboxEmptyState, type ComboboxGroupLabelProps, type ComboboxGroupLabelState, type ComboboxGroupProps, type ComboboxGroupState, type ComboboxInputProps, type ComboboxInputState, type ComboboxInputValueChangeDetails, type ComboboxLabelProps, type ComboboxLabelState, type ComboboxListProps, type ComboboxListState, type ComboboxOpenChangeDetails, type ComboboxOptionProps, type ComboboxOptionState, type ComboboxPopupProps, type ComboboxPopupState, type ComboboxRootProps, type ComboboxRootState, type ComboboxStatusProps, type ComboboxStatusState, type ComboboxTriggerProps, type ComboboxTriggerState, type ComboboxValueChangeDetails, Dialog, type DialogCloseDetails, type DialogCloseProps, type DialogCloseState, type DialogDescriptionProps, type DialogDescriptionState, type DialogFormProps, type DialogFormState, type DialogOpenChangeDetails, type DialogPopupProps, type DialogPopupState, type DialogRootProps, type DialogRootState, type DialogTitleProps, type DialogTitleState, type DialogTriggerProps, type DialogTriggerState, Field, type FieldControlProps, type FieldDescriptionProps, type FieldErrorProps, type FieldErrorValue, type FieldLabelProps, type FieldRootProps, type FieldState, type FieldValidate, type FieldValidity, Form, type FormErrors, type FormRootProps, type FormRootState, type FormSubmitProps, type FormSubmitState, Menu, type MenuAlign, type MenuCheckboxItemProps, type MenuCheckboxItemState, type MenuContextTriggerProps, type MenuContextTriggerState, type MenuGroupLabelProps, type MenuGroupLabelState, type MenuGroupProps, type MenuGroupState, type MenuItemDetails, type MenuItemProps, type MenuItemState, type MenuOpenChangeDetails, type MenuPopupProps, type MenuPopupState, type MenuRadioGroupProps, type MenuRadioGroupState, type MenuRadioItemProps, type MenuRadioItemState, type MenuRootProps, type MenuRootState, type MenuSeparatorProps, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerProps, type MenuSubmenuTriggerState, type MenuTriggerProps, type MenuTriggerState, Meter, type MeterIndicatorProps, type MeterLabelProps, type MeterRegion, type MeterRootProps, type MeterState, type MeterTrackProps, type MeterValueProps, NumberField, type NumberFieldButtonState, type NumberFieldDecrementProps, type NumberFieldIncrementProps, type NumberFieldInputProps, type NumberFieldLabelProps, type NumberFieldRootProps, type NumberFieldState, type NumberFieldValueChangeDetails, Popover, type PopoverAlign, type PopoverCloseProps, type PopoverCloseState, type PopoverDescriptionProps, type PopoverDescriptionState, type PopoverOpenChangeDetails, type PopoverPopupProps, type PopoverPopupState, type PopoverRootProps, type PopoverRootState, type PopoverSide, type PopoverTitleProps, type PopoverTitleState, type PopoverTriggerProps, type PopoverTriggerState, Progress, type ProgressIndicatorProps, type ProgressLabelProps, type ProgressRootProps, type ProgressState, type ProgressTrackProps, type ProgressValueProps, RadioGroup, type RadioGroupItemProps, type RadioGroupItemState, type RadioGroupLabelProps, type RadioGroupRootProps, type RadioGroupRootState, type RadioGroupValueChangeDetails, type RenderProp, STYLE_SHA256, Select, type SelectGroupLabelProps, type SelectGroupProps, type SelectOptionProps, type SelectOptionState, type SelectRootProps, type SelectRootState, type SelectSeparatorProps, type SelectTriggerProps, type SelectValueChangeDetails, type SelectValueProps, Slider, type SliderIndicatorProps, type SliderIndicatorState, type SliderLabelProps, type SliderOrientation, type SliderRootProps, type SliderRootState, type SliderThumbProps, type SliderThumbState, type SliderTrackProps, type SliderTrackState, type SliderValue, type SliderValueChangeDetails, type SliderValueCommitDetails, type SliderValueProps, type SliderValueState, type StateValue, Switch, type SwitchCheckedChangeDetails, type SwitchProps, type SwitchState, Tabs, type TabsActivationMode, type TabsIndicatorProps, type TabsIndicatorState, type TabsListProps, type TabsListState, type TabsOrientation, type TabsPanelProps, type TabsPanelState, type TabsRootProps, type TabsRootState, type TabsTabProps, type TabsTabState, type TabsValueChangeDetails, Toast, type ToastActionDetails, type ToastActionOptions, type ToastActionProps, type ToastActionState, type ToastCloseDetails, type ToastCloseProps, type ToastCloseState, type ToastDescriptionProps, type ToastItem, type ToastManager, type ToastOptions, type ToastPriority, type ToastPromiseOptions, type ToastRootProps, type ToastRootState, type ToastTitleProps, type ToastViewportProps, type ToastViewportState, Toggle, ToggleGroup, type ToggleGroupExclusiveProps, type ToggleGroupItemProps, type ToggleGroupItemState, type ToggleGroupMultipleProps, type ToggleGroupOrientation, type ToggleGroupRootProps, type ToggleGroupRootState, type ToggleGroupValueChangeDetails, type TogglePressedChangeDetails, type ToggleProps, type ToggleState, Toolbar, type ToolbarOrientation, type ToolbarRootProps, type ToolbarRootState, type ToolbarSeparatorProps, type ToolbarSeparatorState, Tooltip, type TooltipAlign, type TooltipArrowProps, type TooltipArrowState, type TooltipPopupProps, type TooltipPopupState, type TooltipProvides, type TooltipRootProps, type TooltipRootState, type TooltipSide, type TooltipTriggerProps, type TooltipTriggerState, type UrgentChangeHandler, type UrgentHandler, type WhilePending, createToastManager, toast };
|
|
165
|
+
export { Accordion, type AccordionItemProps, type AccordionItemState, type AccordionPanelProps, type AccordionPanelState, type AccordionRootExclusiveProps, type AccordionRootMultipleProps, type AccordionRootProps, type AccordionRootState, type AccordionTriggerProps, type AccordionTriggerState, type AccordionValueChangeDetails, type Action, type ActionDetails, AlertDialog, type AlertDialogActionDetails, type AlertDialogActionProps, type AlertDialogActionState, type AlertDialogCancelDetails, type AlertDialogCancelProps, type AlertDialogCancelState, type AlertDialogDescriptionProps, type AlertDialogDescriptionState, type AlertDialogFormProps, type AlertDialogFormState, type AlertDialogOpenChangeDetails, type AlertDialogPopupProps, type AlertDialogPopupState, type AlertDialogRootProps, type AlertDialogRootState, type AlertDialogTitleProps, type AlertDialogTitleState, type AlertDialogTriggerProps, type AlertDialogTriggerState, Button, type ButtonActionDetails, type ButtonProps, type ButtonState, CSPProvider, type CSPProviderProps, type ChangeAction, type ChangeReason, Checkbox, type CheckboxCheckedChangeDetails, CheckboxGroup, type CheckboxGroupItemProps, type CheckboxGroupItemState, type CheckboxGroupLabelProps, type CheckboxGroupParentProps, type CheckboxGroupParentState, type CheckboxGroupRootProps, type CheckboxGroupRootState, type CheckboxGroupValueChangeDetails, type CheckboxProps, type CheckboxState, Collapsible, type CollapsibleOpenChangeDetails, type CollapsiblePanelProps, type CollapsiblePanelState, type CollapsibleRootProps, type CollapsibleRootState, type CollapsibleTriggerProps, type CollapsibleTriggerState, Combobox, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxChipRemoveState, type ComboboxChipState, type ComboboxChipsProps, type ComboboxChipsState, type ComboboxClearProps, type ComboboxClearState, type ComboboxEmptyProps, type ComboboxEmptyState, type ComboboxGroupLabelProps, type ComboboxGroupLabelState, type ComboboxGroupProps, type ComboboxGroupState, type ComboboxInputProps, type ComboboxInputState, type ComboboxInputValueChangeDetails, type ComboboxLabelProps, type ComboboxLabelState, type ComboboxListProps, type ComboboxListState, type ComboboxMultipleProps, type ComboboxMultipleRootState, type ComboboxMultipleValueChangeDetails, type ComboboxOpenChangeDetails, type ComboboxOptionProps, type ComboboxOptionState, type ComboboxPopupProps, type ComboboxPopupState, type ComboboxRootProps, type ComboboxRootState, type ComboboxSingleProps, type ComboboxStatusProps, type ComboboxStatusState, type ComboboxTriggerProps, type ComboboxTriggerState, type ComboboxValueChangeDetails, Dialog, type DialogCloseDetails, type DialogCloseProps, type DialogCloseState, type DialogDescriptionProps, type DialogDescriptionState, type DialogFormProps, type DialogFormState, type DialogOpenChangeDetails, type DialogPopupProps, type DialogPopupState, type DialogRootProps, type DialogRootState, type DialogTitleProps, type DialogTitleState, type DialogTriggerProps, type DialogTriggerState, Field, type FieldControlProps, type FieldDescriptionProps, type FieldErrorProps, type FieldErrorValue, type FieldLabelProps, type FieldRootProps, type FieldState, type FieldValidate, type FieldValidity, Form, type FormErrors, type FormRootProps, type FormRootState, type FormSubmitProps, type FormSubmitState, HoverCard, type HoverCardAlign, type HoverCardOpenChangeDetails, type HoverCardPopupProps, type HoverCardPopupState, type HoverCardRootProps, type HoverCardRootState, type HoverCardSide, type HoverCardTriggerProps, type HoverCardTriggerState, Menu, type MenuAlign, type MenuCheckboxItemProps, type MenuCheckboxItemState, type MenuContextTriggerProps, type MenuContextTriggerState, type MenuGroupLabelProps, type MenuGroupLabelState, type MenuGroupProps, type MenuGroupState, type MenuItemDetails, type MenuItemProps, type MenuItemState, type MenuOpenChangeDetails, type MenuPopupProps, type MenuPopupState, type MenuRadioGroupProps, type MenuRadioGroupState, type MenuRadioItemProps, type MenuRadioItemState, type MenuRootProps, type MenuRootState, type MenuSeparatorProps, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerProps, type MenuSubmenuTriggerState, type MenuTriggerProps, type MenuTriggerState, Meter, type MeterIndicatorProps, type MeterLabelProps, type MeterRegion, type MeterRootProps, type MeterState, type MeterTrackProps, type MeterValueProps, MultiSelect, type MultiSelectEmptyProps, type MultiSelectEmptyState, type MultiSelectGroupLabelProps, type MultiSelectGroupLabelState, type MultiSelectGroupProps, type MultiSelectGroupState, type MultiSelectLabelProps, type MultiSelectLabelState, type MultiSelectListProps, type MultiSelectListState, type MultiSelectOpenChangeDetails, type MultiSelectOptionProps, type MultiSelectOptionState, type MultiSelectPopupProps, type MultiSelectPopupState, type MultiSelectRootProps, type MultiSelectRootState, type MultiSelectStatusProps, type MultiSelectStatusState, type MultiSelectTriggerProps, type MultiSelectTriggerState, type MultiSelectValueChangeDetails, type MultiSelectValueProps, type MultiSelectValueState, NumberField, type NumberFieldButtonState, type NumberFieldDecrementProps, type NumberFieldIncrementProps, type NumberFieldInputProps, type NumberFieldLabelProps, type NumberFieldRootProps, type NumberFieldState, type NumberFieldValueChangeDetails, Popover, type PopoverAlign, type PopoverCloseProps, type PopoverCloseState, type PopoverDescriptionProps, type PopoverDescriptionState, type PopoverOpenChangeDetails, type PopoverPopupProps, type PopoverPopupState, type PopoverRootProps, type PopoverRootState, type PopoverSide, type PopoverTitleProps, type PopoverTitleState, type PopoverTriggerProps, type PopoverTriggerState, Progress, type ProgressIndicatorProps, type ProgressLabelProps, type ProgressRootProps, type ProgressState, type ProgressTrackProps, type ProgressValueProps, RadioGroup, type RadioGroupItemProps, type RadioGroupItemState, type RadioGroupLabelProps, type RadioGroupRootProps, type RadioGroupRootState, type RadioGroupValueChangeDetails, type RenderProp, STYLE_SHA256, Select, type SelectGroupLabelProps, type SelectGroupProps, type SelectOptionProps, type SelectOptionState, type SelectRootProps, type SelectRootState, type SelectSeparatorProps, type SelectTriggerProps, type SelectValueChangeDetails, type SelectValueProps, Separator, type SeparatorOrientation, type SeparatorProps, type SeparatorState, Slider, type SliderIndicatorProps, type SliderIndicatorState, type SliderLabelProps, type SliderOrientation, type SliderRootProps, type SliderRootState, type SliderThumbProps, type SliderThumbState, type SliderTrackProps, type SliderTrackState, type SliderValue, type SliderValueChangeDetails, type SliderValueCommitDetails, type SliderValueProps, type SliderValueState, type StateValue, Switch, type SwitchCheckedChangeDetails, type SwitchProps, type SwitchState, Tabs, type TabsActivationMode, type TabsIndicatorProps, type TabsIndicatorState, type TabsListProps, type TabsListState, type TabsOrientation, type TabsPanelProps, type TabsPanelState, type TabsRootProps, type TabsRootState, type TabsTabProps, type TabsTabState, type TabsValueChangeDetails, Toast, type ToastActionDetails, type ToastActionOptions, type ToastActionProps, type ToastActionState, type ToastCloseDetails, type ToastCloseProps, type ToastCloseState, type ToastDescriptionProps, type ToastItem, type ToastManager, type ToastOptions, type ToastPriority, type ToastPromiseOptions, type ToastRootProps, type ToastRootState, type ToastTitleProps, type ToastViewportProps, type ToastViewportState, Toggle, ToggleGroup, type ToggleGroupExclusiveProps, type ToggleGroupItemProps, type ToggleGroupItemState, type ToggleGroupMultipleProps, type ToggleGroupOrientation, type ToggleGroupRootProps, type ToggleGroupRootState, type ToggleGroupValueChangeDetails, type TogglePressedChangeDetails, type ToggleProps, type ToggleState, Toolbar, type ToolbarOrientation, type ToolbarRootProps, type ToolbarRootState, type ToolbarSeparatorProps, type ToolbarSeparatorState, Tooltip, type TooltipAlign, type TooltipArrowProps, type TooltipArrowState, type TooltipPopupProps, type TooltipPopupState, type TooltipProvides, type TooltipRootProps, type TooltipRootState, type TooltipSide, type TooltipTriggerProps, type TooltipTriggerState, type UrgentChangeHandler, type UrgentHandler, type WhilePending, createToastManager, toast };
|
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { Button } from "./button/button.mjs";
|
|
2
2
|
import { Toggle } from "./toggle/toggle.mjs";
|
|
3
3
|
import { ToggleGroup } from "./toggle-group/index.mjs";
|
|
4
|
+
import { Separator } from "./separator/separator.mjs";
|
|
4
5
|
import { Toolbar } from "./toolbar/index.mjs";
|
|
5
6
|
import { Accordion } from "./accordion/index.mjs";
|
|
7
|
+
import { Collapsible } from "./collapsible/index.mjs";
|
|
6
8
|
import { Tabs } from "./tabs/index.mjs";
|
|
7
9
|
import { Tooltip } from "./tooltip/index.mjs";
|
|
10
|
+
import { HoverCard } from "./hover-card/index.mjs";
|
|
8
11
|
import { Switch } from "./switch/switch.mjs";
|
|
9
12
|
import { Checkbox } from "./checkbox/checkbox.mjs";
|
|
10
13
|
import { Dialog } from "./dialog/index.mjs";
|
|
14
|
+
import { AlertDialog } from "./alert-dialog/index.mjs";
|
|
11
15
|
import { Popover } from "./popover/index.mjs";
|
|
12
16
|
import { Menu } from "./menu/index.mjs";
|
|
13
17
|
import { RadioGroup } from "./radio-group/index.mjs";
|
|
14
18
|
import { CheckboxGroup } from "./checkbox-group/index.mjs";
|
|
15
19
|
import { Select } from "./select/index.mjs";
|
|
16
20
|
import { Combobox } from "./combobox/index.mjs";
|
|
21
|
+
import { MultiSelect } from "./multi-select/index.mjs";
|
|
17
22
|
import { createToastManager, toast } from "./toast/toast.mjs";
|
|
18
23
|
import { Toast } from "./toast/index.mjs";
|
|
19
24
|
import { Slider } from "./slider/index.mjs";
|
|
@@ -24,4 +29,4 @@ import { Progress } from "./progress/index.mjs";
|
|
|
24
29
|
import { Meter } from "./meter/index.mjs";
|
|
25
30
|
import { CSPProvider } from "./csp/csp-provider.mjs";
|
|
26
31
|
import { STYLE_SHA256 } from "./csp/style-hashes.mjs";
|
|
27
|
-
export { Accordion, Button, CSPProvider, Checkbox, CheckboxGroup, Combobox, Dialog, Field, Form, Menu, Meter, NumberField, Popover, Progress, RadioGroup, STYLE_SHA256, Select, Slider, Switch, Tabs, Toast, Toggle, ToggleGroup, Toolbar, Tooltip, createToastManager, toast };
|
|
32
|
+
export { Accordion, AlertDialog, Button, CSPProvider, Checkbox, CheckboxGroup, Collapsible, Combobox, Dialog, Field, Form, HoverCard, Menu, Meter, MultiSelect, NumberField, Popover, Progress, RadioGroup, STYLE_SHA256, Select, Separator, Slider, Switch, Tabs, Toast, Toggle, ToggleGroup, Toolbar, Tooltip, createToastManager, toast };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createActionDetails } from "./action-details.mjs";
|
|
3
|
+
import { transitionTypes } from "../transition-types.mjs";
|
|
4
|
+
import { intendedValue, useControllableAction } from "./use-controllable-action.mjs";
|
|
5
|
+
import { EMPTY_SET, applyPatch, setsEqual } from "../value-set.mjs";
|
|
6
|
+
import { useValueSet } from "../use-value-set.mjs";
|
|
7
|
+
import { useMemo, useRef } from "react";
|
|
8
|
+
//#region src/internal/action/use-multiple-selection.ts
|
|
9
|
+
/**
|
|
10
|
+
* The set-valued selection of a listbox component, `Combobox.Root multiple` and
|
|
11
|
+
* `MultiSelect.Root` (design/components/combobox.md 15.4, multi-select.md B.6): a set-valued
|
|
12
|
+
* owner under the shared rules (conventions 2.2, 2.5, 3.3), with CheckboxGroup's machinery. The
|
|
13
|
+
* patch reducer re-bases stacked optimistic changes and replays the resolved ones in dispatch
|
|
14
|
+
* order; a form reset is the one absolute dispatch. The order is the value's own (a JS `Set`
|
|
15
|
+
* keeps insertion order): the order of `value` / `defaultValue`, then the picks, appended.
|
|
16
|
+
*
|
|
17
|
+
* Always called by the Root (hooks are unconditional); with `enabled: false` it receives no
|
|
18
|
+
* props and never dispatches.
|
|
19
|
+
*/
|
|
20
|
+
function useMultipleSelection({ component, part, enabled, value, defaultValue, valueChangeAction, resetFields }) {
|
|
21
|
+
const controlledSet = useValueSet(enabled ? value : void 0);
|
|
22
|
+
const defaultSet = useValueSet(enabled ? defaultValue : void 0);
|
|
23
|
+
const { optimistic, committed, pending, dispatch, latestInFlight } = useControllableAction({
|
|
24
|
+
controlled: controlledSet,
|
|
25
|
+
defaultValue: defaultSet,
|
|
26
|
+
initialValue: EMPTY_SET,
|
|
27
|
+
action: enabled && valueChangeAction ? (next, details) => valueChangeAction([...next], details) : void 0,
|
|
28
|
+
transitionTypes: (_next, _prev, details) => [
|
|
29
|
+
...transitionTypes(component),
|
|
30
|
+
...details.added.length > 0 ? [`fsui-${component}-select`] : [],
|
|
31
|
+
...details.removed.length > 0 ? [`fsui-${component}-deselect`] : []
|
|
32
|
+
],
|
|
33
|
+
reducer: (prev, _next, details) => applyPatch(prev, details),
|
|
34
|
+
warn: {
|
|
35
|
+
component: part,
|
|
36
|
+
prop: "value"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const key = JSON.stringify([...optimistic]);
|
|
40
|
+
const values = useMemo(() => JSON.parse(key), [key]);
|
|
41
|
+
/** The latest dispatch was a form reset (CheckboxGroup #151). */
|
|
42
|
+
const latestIsReset = useRef(false);
|
|
43
|
+
const change = (patch, fields, event) => {
|
|
44
|
+
const added = patch.added.filter((v, i) => !optimistic.has(v) && patch.added.indexOf(v) === i);
|
|
45
|
+
const removed = patch.removed.filter((v) => optimistic.has(v));
|
|
46
|
+
if (added.length === 0 && removed.length === 0) return false;
|
|
47
|
+
const ordered = [...optimistic].filter((v) => removed.includes(v));
|
|
48
|
+
const { reason, ...extra } = fields;
|
|
49
|
+
const details = createActionDetails(event, {
|
|
50
|
+
reason,
|
|
51
|
+
added,
|
|
52
|
+
removed: ordered,
|
|
53
|
+
...extra
|
|
54
|
+
});
|
|
55
|
+
latestIsReset.current = false;
|
|
56
|
+
dispatch(applyPatch(optimistic, details), details);
|
|
57
|
+
return true;
|
|
58
|
+
};
|
|
59
|
+
const reset = (target, event) => {
|
|
60
|
+
const from = intendedValue(latestInFlight, optimistic);
|
|
61
|
+
if (setsEqual(from, target) && !(controlledSet === void 0 && latestInFlight() !== null && !latestIsReset.current)) return;
|
|
62
|
+
const details = createActionDetails(event, {
|
|
63
|
+
reason: "platform",
|
|
64
|
+
added: [...target].filter((v) => !from.has(v)),
|
|
65
|
+
removed: [...from].filter((v) => !target.has(v)),
|
|
66
|
+
...resetFields
|
|
67
|
+
});
|
|
68
|
+
latestIsReset.current = true;
|
|
69
|
+
dispatch(new Set(target), details, { whole: true });
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
optimistic,
|
|
73
|
+
committed,
|
|
74
|
+
values,
|
|
75
|
+
pending,
|
|
76
|
+
change,
|
|
77
|
+
reset
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
export { useMultipleSelection };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=use-multiple-selection.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-multiple-selection.mjs","names":[],"sources":["../../../src/internal/action/use-multiple-selection.ts"],"sourcesContent":["\"use client\";\nimport { useMemo, useRef } from \"react\";\nimport { createActionDetails } from \"./action-details.js\";\nimport { intendedValue, useControllableAction } from \"./use-controllable-action.js\";\nimport { transitionTypes } from \"../transition-types.js\";\nimport type { ActionDetails, ChangeAction, ChangeReason } from \"../types.js\";\nimport { useValueSet } from \"../use-value-set.js\";\nimport { applyPatch, EMPTY_SET, setsEqual } from \"../value-set.js\";\nimport type { SetPatch, ValueSet } from \"../value-set.js\";\n\n/**\n * The details of a set-valued listbox selection (Combobox `multiple`, MultiSelect): the reason,\n * the diff, and the component's own fields (`Extra`; Combobox: `custom`).\n */\nexport type MultipleSelectionDetails<Extra extends object> = ActionDetails & {\n readonly reason: ChangeReason;\n /** Values this dispatch added, in the order they join the value. */\n readonly added: readonly string[];\n /** Values this dispatch removed, in value order. */\n readonly removed: readonly string[];\n} & Readonly<Extra>;\n\nexport interface MultipleSelectionOptions<Extra extends object> {\n /** The transition-type stem (`\"combobox\"` gives `fsui-combobox`, `fsui-combobox-select`, …). */\n readonly component: string;\n /** Public name of the Root for the development warnings (`\"Combobox.Root\"`). */\n readonly part: string;\n /** `false`: the hook is idle (no value, no action); Combobox in single mode. */\n readonly enabled: boolean;\n readonly value: readonly string[] | undefined;\n readonly defaultValue: readonly string[] | undefined;\n readonly valueChangeAction: ChangeAction<string[], MultipleSelectionDetails<Extra>> | undefined;\n /** The component's own fields of a form reset's details (Combobox: `{ custom: false }`). */\n readonly resetFields: Extra;\n}\n\nexport interface MultipleSelection<Extra extends object> {\n /** The optimistic selection, insertion-ordered: the pick order (combobox.md 15.2). */\n readonly optimistic: ValueSet;\n readonly committed: ValueSet;\n /** `optimistic` as a list, stable while its contents are. */\n readonly values: readonly string[];\n /** The value action is in flight. */\n readonly pending: boolean;\n /**\n * One user change on top of the optimistic selection (combobox.md 15.3, 15.4). Parts of the\n * patch that change nothing are dropped; nothing is dispatched for an empty patch. Returns\n * whether it dispatched.\n */\n readonly change: (\n patch: SetPatch,\n fields: { readonly reason: ChangeReason } & Extra,\n event: Event | undefined,\n ) => boolean;\n /** A form reset to `target` (combobox.md 15.4, 15.8): absolute, `\"platform\"`. */\n readonly reset: (target: ValueSet, event: Event) => void;\n}\n\n/**\n * The set-valued selection of a listbox component, `Combobox.Root multiple` and\n * `MultiSelect.Root` (design/components/combobox.md 15.4, multi-select.md B.6): a set-valued\n * owner under the shared rules (conventions 2.2, 2.5, 3.3), with CheckboxGroup's machinery. The\n * patch reducer re-bases stacked optimistic changes and replays the resolved ones in dispatch\n * order; a form reset is the one absolute dispatch. The order is the value's own (a JS `Set`\n * keeps insertion order): the order of `value` / `defaultValue`, then the picks, appended.\n *\n * Always called by the Root (hooks are unconditional); with `enabled: false` it receives no\n * props and never dispatches.\n */\nexport function useMultipleSelection<Extra extends object>({\n component,\n part,\n enabled,\n value,\n defaultValue,\n valueChangeAction,\n resetFields,\n}: MultipleSelectionOptions<Extra>): MultipleSelection<Extra> {\n type Details = MultipleSelectionDetails<Extra>;\n const controlledSet = useValueSet(enabled ? value : undefined);\n const defaultSet = useValueSet(enabled ? defaultValue : undefined);\n\n const { optimistic, committed, pending, dispatch, latestInFlight } = useControllableAction<\n ValueSet,\n Details\n >({\n controlled: controlledSet,\n defaultValue: defaultSet,\n initialValue: EMPTY_SET,\n action:\n enabled && valueChangeAction\n ? (next, details) => valueChangeAction([...next], details)\n : undefined,\n transitionTypes: (_next, _prev, details) => [\n ...transitionTypes(component),\n ...(details.added.length > 0 ? [`fsui-${component}-select`] : []),\n ...(details.removed.length > 0 ? [`fsui-${component}-deselect`] : []),\n ],\n // A patch, re-based on the committed set; also how the uncontrolled commit is folded over\n // the resolved dispatches (#150). A form reset is dispatched `whole` and bypasses it.\n reducer: (prev, _next, details) => applyPatch(prev, details),\n warn: { component: part, prop: \"value\" },\n });\n\n const key = JSON.stringify([...optimistic]);\n const values = useMemo(() => JSON.parse(key) as string[], [key]);\n\n /** The latest dispatch was a form reset (CheckboxGroup #151). */\n const latestIsReset = useRef(false);\n\n const change: MultipleSelection<Extra>[\"change\"] = (patch, fields, event) => {\n const added = patch.added.filter((v, i) => !optimistic.has(v) && patch.added.indexOf(v) === i);\n const removed = patch.removed.filter((v) => optimistic.has(v));\n if (added.length === 0 && removed.length === 0) return false;\n // `removed` in value order (combobox.md 15.2).\n const ordered = [...optimistic].filter((v) => removed.includes(v));\n const { reason, ...extra } = fields;\n const details = createActionDetails(event, {\n reason,\n added,\n removed: ordered,\n ...(extra as Extra),\n }) as Details;\n latestIsReset.current = false;\n dispatch(applyPatch(optimistic, details), details);\n return true;\n };\n\n const reset: MultipleSelection<Extra>[\"reset\"] = (target, event) => {\n const from = intendedValue(latestInFlight, optimistic);\n // While a change is in flight the reset is dispatched even when it equals the intended\n // value: the replay applies it absolutely, so an earlier change that rejects later cannot\n // roll the selection back past the reset (conventions 3.3, last rule). Controlled: the\n // parent decides, no replay.\n const equal = setsEqual(from, target);\n if (\n equal &&\n !(controlledSet === undefined && latestInFlight() !== null && !latestIsReset.current)\n ) {\n return;\n }\n const details = createActionDetails(event, {\n reason: \"platform\" as const,\n added: [...target].filter((v) => !from.has(v)),\n removed: [...from].filter((v) => !target.has(v)),\n ...resetFields,\n }) as Details;\n latestIsReset.current = true;\n dispatch(new Set(target), details, { whole: true });\n };\n\n return { optimistic, committed, values, pending, change, reset };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqEA,SAAgB,qBAA2C,EACzD,WACA,MACA,SACA,OACA,cACA,mBACA,eAC4D;CAE5D,MAAM,gBAAgB,YAAY,UAAU,QAAQ,KAAA,CAAS;CAC7D,MAAM,aAAa,YAAY,UAAU,eAAe,KAAA,CAAS;CAEjE,MAAM,EAAE,YAAY,WAAW,SAAS,UAAU,mBAAmB,sBAGnE;EACA,YAAY;EACZ,cAAc;EACd,cAAc;EACd,QACE,WAAW,qBACN,MAAM,YAAY,kBAAkB,CAAC,GAAG,IAAI,GAAG,OAAO,IACvD,KAAA;EACN,kBAAkB,OAAO,OAAO,YAAY;GAC1C,GAAG,gBAAgB,SAAS;GAC5B,GAAI,QAAQ,MAAM,SAAS,IAAI,CAAC,QAAQ,UAAU,QAAQ,IAAI,CAAC;GAC/D,GAAI,QAAQ,QAAQ,SAAS,IAAI,CAAC,QAAQ,UAAU,UAAU,IAAI,CAAC;EACrE;EAGA,UAAU,MAAM,OAAO,YAAY,WAAW,MAAM,OAAO;EAC3D,MAAM;GAAE,WAAW;GAAM,MAAM;EAAQ;CACzC,CAAC;CAED,MAAM,MAAM,KAAK,UAAU,CAAC,GAAG,UAAU,CAAC;CAC1C,MAAM,SAAS,cAAc,KAAK,MAAM,GAAG,GAAe,CAAC,GAAG,CAAC;;CAG/D,MAAM,gBAAgB,OAAO,KAAK;CAElC,MAAM,UAA8C,OAAO,QAAQ,UAAU;EAC3E,MAAM,QAAQ,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,IAAI,CAAC,KAAK,MAAM,MAAM,QAAQ,CAAC,MAAM,CAAC;EAC7F,MAAM,UAAU,MAAM,QAAQ,QAAQ,MAAM,WAAW,IAAI,CAAC,CAAC;EAC7D,IAAI,MAAM,WAAW,KAAK,QAAQ,WAAW,GAAG,OAAO;EAEvD,MAAM,UAAU,CAAC,GAAG,UAAU,CAAC,CAAC,QAAQ,MAAM,QAAQ,SAAS,CAAC,CAAC;EACjE,MAAM,EAAE,QAAQ,GAAG,UAAU;EAC7B,MAAM,UAAU,oBAAoB,OAAO;GACzC;GACA;GACA,SAAS;GACT,GAAI;EACN,CAAC;EACD,cAAc,UAAU;EACxB,SAAS,WAAW,YAAY,OAAO,GAAG,OAAO;EACjD,OAAO;CACT;CAEA,MAAM,SAA4C,QAAQ,UAAU;EAClE,MAAM,OAAO,cAAc,gBAAgB,UAAU;EAMrD,IADc,UAAU,MAAM,MAExB,KACJ,EAAE,kBAAkB,KAAA,KAAa,eAAe,MAAM,QAAQ,CAAC,cAAc,UAE7E;EAEF,MAAM,UAAU,oBAAoB,OAAO;GACzC,QAAQ;GACR,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;GAC7C,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,QAAQ,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC;GAC/C,GAAG;EACL,CAAC;EACD,cAAc,UAAU;EACxB,SAAS,IAAI,IAAI,MAAM,GAAG,SAAS,EAAE,OAAO,KAAK,CAAC;CACpD;CAEA,OAAO;EAAE;EAAY;EAAW;EAAQ;EAAS;EAAQ;CAAM;AACjE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useElementCheck } from "./use-element-check.mjs";
|
|
3
|
+
//#region src/internal/details-summary.ts
|
|
4
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
5
|
+
const NESTED_INTERACTIVE = "a[href], button, label, input, select, textarea, [contenteditable]:not([contenteditable='false'])";
|
|
6
|
+
/**
|
|
7
|
+
* Nested controls with an activation behaviour of their own. The browser runs theirs instead of
|
|
8
|
+
* the summary's (no toggle), so their click must keep its default: navigation, check, submit.
|
|
9
|
+
*/
|
|
10
|
+
const SELF_ACTIVATING = "a[href], button, label, input:is([type='button'], [type='submit'], [type='reset'], [type='image'], [type='checkbox'], [type='radio'], [type='file'], [type='color'])";
|
|
11
|
+
/** The interactive descendant of the summary that was clicked (a link in the heading), if any. */
|
|
12
|
+
function nestedInteractive(target, summary) {
|
|
13
|
+
if (!(target instanceof Element) || target === summary) return null;
|
|
14
|
+
const interactive = target.closest(NESTED_INTERACTIVE);
|
|
15
|
+
return interactive !== null && interactive !== summary && summary.contains(interactive) ? interactive : null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The click rule of a `<summary>` Trigger whose click the library handles (library mode, or a
|
|
19
|
+
* disabled Trigger in JS-free mode). Returns `true` when the click is a toggle request: it has
|
|
20
|
+
* been cancelled, so the browser does not touch `open`, and the caller dispatches unless
|
|
21
|
+
* disabled. Returns `false` for a click on interactive content nested in the summary, which never
|
|
22
|
+
* toggles: a control without an activation behaviour of its own (text input, select, textarea,
|
|
23
|
+
* contenteditable) would let the click fall through to the summary's toggle, so that click is
|
|
24
|
+
* cancelled; focus and pickers happen on mousedown and are unaffected. Self-activating controls
|
|
25
|
+
* (links, buttons, checkboxes) already pre-empt the summary's behaviour and keep their default.
|
|
26
|
+
*/
|
|
27
|
+
function interceptSummaryClick(event) {
|
|
28
|
+
const nested = nestedInteractive(event.target, event.currentTarget);
|
|
29
|
+
if (nested !== null) {
|
|
30
|
+
if (!nested.matches(SELF_ACTIVATING)) event.preventDefault();
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The development check of a part that must render a `<details>` (`Accordion.Item`,
|
|
38
|
+
* `Collapsible.Root`); `part` is its public name and `semantics` the platform behaviours the
|
|
39
|
+
* part relies on, named in the message. Pass `semantics` as `isDev && "..."` so the text folds
|
|
40
|
+
* away in production, where the hook is a no-op returning `undefined` (`useElementCheck`). Call
|
|
41
|
+
* the result from the part's own ref.
|
|
42
|
+
*/
|
|
43
|
+
function useDetailsCheck(part, semantics) {
|
|
44
|
+
return useElementCheck(isDev && ((element) => element.tagName !== "DETAILS" ? `${part}: expected to render a <details> element but got <${element.tagName.toLowerCase()}>. The platform semantics (${String(semantics)}) need a real <details>.` : null));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The development check of a part that must render a `<summary>` (`Accordion.Trigger`,
|
|
48
|
+
* `Collapsible.Trigger`); see {@link useDetailsCheck}.
|
|
49
|
+
*/
|
|
50
|
+
function useSummaryCheck(part) {
|
|
51
|
+
return useElementCheck(isDev && ((element) => element.tagName !== "SUMMARY" ? `${part}: expected to render a <summary> element but got <${element.tagName.toLowerCase()}>. Only a <summary> toggles its parent <details>.` : null));
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { interceptSummaryClick, useDetailsCheck, useSummaryCheck };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=details-summary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"details-summary.mjs","names":[],"sources":["../../src/internal/details-summary.ts"],"sourcesContent":["\"use client\";\nimport type { MouseEvent } from \"react\";\nimport { useElementCheck } from \"./use-element-check.js\";\nimport type { ElementCheck } from \"./use-element-check.js\";\n\n// The `<details>` / `<summary>` pair shared by Accordion (Item and Trigger) and Collapsible (Root\n// and Trigger): the Trigger's click rule (accordion.md 2.2, collapsible.md 2.2) and the\n// development checks of the rendered elements. The state side is not shared: an Accordion owns a\n// set, a Collapsible one boolean.\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nconst NESTED_INTERACTIVE =\n \"a[href], button, label, input, select, textarea, [contenteditable]:not([contenteditable='false'])\";\n\n/**\n * Nested controls with an activation behaviour of their own. The browser runs theirs instead of\n * the summary's (no toggle), so their click must keep its default: navigation, check, submit.\n */\nconst SELF_ACTIVATING =\n \"a[href], button, label, input:is([type='button'], [type='submit'], [type='reset'], \" +\n \"[type='image'], [type='checkbox'], [type='radio'], [type='file'], [type='color'])\";\n\n/** The interactive descendant of the summary that was clicked (a link in the heading), if any. */\nfunction nestedInteractive(target: EventTarget | null, summary: HTMLElement): Element | null {\n if (!(target instanceof Element) || target === summary) return null;\n const interactive = target.closest(NESTED_INTERACTIVE);\n return interactive !== null && interactive !== summary && summary.contains(interactive)\n ? interactive\n : null;\n}\n\n/**\n * The click rule of a `<summary>` Trigger whose click the library handles (library mode, or a\n * disabled Trigger in JS-free mode). Returns `true` when the click is a toggle request: it has\n * been cancelled, so the browser does not touch `open`, and the caller dispatches unless\n * disabled. Returns `false` for a click on interactive content nested in the summary, which never\n * toggles: a control without an activation behaviour of its own (text input, select, textarea,\n * contenteditable) would let the click fall through to the summary's toggle, so that click is\n * cancelled; focus and pickers happen on mousedown and are unaffected. Self-activating controls\n * (links, buttons, checkboxes) already pre-empt the summary's behaviour and keep their default.\n */\nexport function interceptSummaryClick(event: MouseEvent<HTMLElement>): boolean {\n const nested = nestedInteractive(event.target, event.currentTarget);\n if (nested !== null) {\n if (!nested.matches(SELF_ACTIVATING)) event.preventDefault();\n return false;\n }\n event.preventDefault();\n return true;\n}\n\n/**\n * The development check of a part that must render a `<details>` (`Accordion.Item`,\n * `Collapsible.Root`); `part` is its public name and `semantics` the platform behaviours the\n * part relies on, named in the message. Pass `semantics` as `isDev && \"...\"` so the text folds\n * away in production, where the hook is a no-op returning `undefined` (`useElementCheck`). Call\n * the result from the part's own ref.\n */\nexport function useDetailsCheck(\n part: string,\n semantics: string | false,\n): ElementCheck<HTMLDetailsElement> | undefined {\n return useElementCheck<HTMLDetailsElement>(\n isDev &&\n ((element) =>\n element.tagName !== \"DETAILS\"\n ? `${part}: expected to render a <details> element but got <${element.tagName.toLowerCase()}>. ` +\n `The platform semantics (${String(semantics)}) need a real <details>.`\n : null),\n );\n}\n\n/**\n * The development check of a part that must render a `<summary>` (`Accordion.Trigger`,\n * `Collapsible.Trigger`); see {@link useDetailsCheck}.\n */\nexport function useSummaryCheck(part: string): ElementCheck<HTMLElement> | undefined {\n return useElementCheck(\n isDev &&\n ((element) =>\n element.tagName !== \"SUMMARY\"\n ? `${part}: expected to render a <summary> element but got <${element.tagName.toLowerCase()}>. ` +\n \"Only a <summary> toggles its parent <details>.\"\n : null),\n );\n}\n"],"mappings":";;;AAUA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,MAAM,qBACJ;;;;;AAMF,MAAM,kBACJ;;AAIF,SAAS,kBAAkB,QAA4B,SAAsC;CAC3F,IAAI,EAAE,kBAAkB,YAAY,WAAW,SAAS,OAAO;CAC/D,MAAM,cAAc,OAAO,QAAQ,kBAAkB;CACrD,OAAO,gBAAgB,QAAQ,gBAAgB,WAAW,QAAQ,SAAS,WAAW,IAClF,cACA;AACN;;;;;;;;;;;AAYA,SAAgB,sBAAsB,OAAyC;CAC7E,MAAM,SAAS,kBAAkB,MAAM,QAAQ,MAAM,aAAa;CAClE,IAAI,WAAW,MAAM;EACnB,IAAI,CAAC,OAAO,QAAQ,eAAe,GAAG,MAAM,eAAe;EAC3D,OAAO;CACT;CACA,MAAM,eAAe;CACrB,OAAO;AACT;;;;;;;;AASA,SAAgB,gBACd,MACA,WAC8C;CAC9C,OAAO,gBACL,WACI,YACA,QAAQ,YAAY,YAChB,GAAG,KAAK,oDAAoD,QAAQ,QAAQ,YAAY,EAAE,6BAC/D,OAAO,SAAS,EAAE,4BAC7C,KACV;AACF;;;;;AAMA,SAAgB,gBAAgB,MAAqD;CACnF,OAAO,gBACL,WACI,YACA,QAAQ,YAAY,YAChB,GAAG,KAAK,oDAAoD,QAAQ,QAAQ,YAAY,EAAE,qDAE1F,KACV;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-context.mjs","names":[],"sources":["../../../src/internal/form/field-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport { dataAttr } from \"../data-attr.js\";\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, `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\n/** The four state attributes every Field part renders (design 6.1). */\nexport function fieldDataAttributes(state: FieldState) {\n return {\n \"data-invalid\": dataAttr(state.invalid),\n \"data-disabled\": dataAttr(state.disabled),\n \"data-required\": dataAttr(state.required),\n \"data-pending\": dataAttr(state.pending),\n };\n}\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"field-context.mjs","names":[],"sources":["../../../src/internal/form/field-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport { dataAttr } from \"../data-attr.js\";\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, `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 /**\n * The registered control's element, or `null` (handlers only): `Field.Label` focuses a\n * `<button>` control instead of activating it (MultiSelect, multi-select.md B.10).\n */\n readonly controlElement: () => HTMLElement | null;\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\n/** The four state attributes every Field part renders (design 6.1). */\nexport function fieldDataAttributes(state: FieldState) {\n return {\n \"data-invalid\": dataAttr(state.invalid),\n \"data-disabled\": dataAttr(state.disabled),\n \"data-required\": dataAttr(state.required),\n \"data-pending\": dataAttr(state.pending),\n };\n}\n"],"mappings":";;;;AA4EA,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;;AAGtE,SAAgB,oBAAoB,OAAmB;CACrD,OAAO;EACL,gBAAgB,SAAS,MAAM,OAAO;EACtC,iBAAiB,SAAS,MAAM,QAAQ;EACxC,iBAAiB,SAAS,MAAM,QAAQ;EACxC,gBAAgB,SAAS,MAAM,OAAO;CACxC;AACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
//#region src/internal/form/hidden-values.tsx
|
|
3
|
+
/**
|
|
4
|
+
* The form value of a set-valued Root that has no form element of its own, Combobox `multiple`
|
|
5
|
+
* and MultiSelect (design/components/combobox.md 15.8, multi-select.md B.10; conventions 1.1):
|
|
6
|
+
* one `<input type="hidden" name value>` per value, in value order. An empty selection keeps one
|
|
7
|
+
* nameless input, which posts nothing but is still the form-associated element of the reset
|
|
8
|
+
* listener and an enclosing Field.
|
|
9
|
+
*/
|
|
10
|
+
function HiddenValues({ name, form, values, inputRef }) {
|
|
11
|
+
if (name === void 0) return null;
|
|
12
|
+
if (values.length === 0) return /* @__PURE__ */ jsx("input", {
|
|
13
|
+
ref: inputRef,
|
|
14
|
+
type: "hidden",
|
|
15
|
+
form,
|
|
16
|
+
value: ""
|
|
17
|
+
}, "");
|
|
18
|
+
return values.map((v, i) => /* @__PURE__ */ jsx("input", {
|
|
19
|
+
ref: i === 0 ? inputRef : void 0,
|
|
20
|
+
type: "hidden",
|
|
21
|
+
name,
|
|
22
|
+
form,
|
|
23
|
+
value: v
|
|
24
|
+
}, `v:${v}`));
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { HiddenValues };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=hidden-values.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hidden-values.mjs","names":[],"sources":["../../../src/internal/form/hidden-values.tsx"],"sourcesContent":["// No \"use client\" directive: a plain component with no hook, rendered by the client Roots that\n// use it (conventions 7.1).\nimport type { ReactNode, Ref } from \"react\";\n\nexport interface HiddenValuesProps {\n /** The `name` of every input; `undefined` renders nothing. */\n readonly name: string | undefined;\n readonly form: string | undefined;\n /** The optimistic selection, in value order. */\n readonly values: readonly string[];\n /** Attached to the first input: the form-associated element of the reset listener and a Field. */\n readonly inputRef: Ref<HTMLInputElement>;\n}\n\n/**\n * The form value of a set-valued Root that has no form element of its own, Combobox `multiple`\n * and MultiSelect (design/components/combobox.md 15.8, multi-select.md B.10; conventions 1.1):\n * one `<input type=\"hidden\" name value>` per value, in value order. An empty selection keeps one\n * nameless input, which posts nothing but is still the form-associated element of the reset\n * listener and an enclosing Field.\n */\nexport function HiddenValues({ name, form, values, inputRef }: HiddenValuesProps): ReactNode {\n if (name === undefined) return null;\n if (values.length === 0)\n return <input key=\"\" ref={inputRef} type=\"hidden\" form={form} value=\"\" />;\n return values.map((v, i) => (\n <input\n key={`v:${v}`}\n ref={i === 0 ? inputRef : undefined}\n type=\"hidden\"\n name={name}\n form={form}\n value={v}\n />\n ));\n}\n"],"mappings":";;;;;;;;;AAqBA,SAAgB,aAAa,EAAE,MAAM,MAAM,QAAQ,YAA0C;CAC3F,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,IAAI,OAAO,WAAW,GACpB,OAAO,oBAAC,SAAD;EAAc,KAAK;EAAU,MAAK;EAAe;EAAM,OAAM;CAAI,GAAtD,EAAsD;CAC1E,OAAO,OAAO,KAAK,GAAG,MACpB,oBAAC,SAAD;EAEE,KAAK,MAAM,IAAI,WAAW,KAAA;EAC1B,MAAK;EACC;EACA;EACN,OAAO;CACR,GANM,KAAK,GAMX,CACF;AACH"}
|
|
@@ -80,13 +80,15 @@ function validityElementOf(el) {
|
|
|
80
80
|
return controls.find((c) => c.willValidate && c.name !== "") ?? controls.find((c) => c.willValidate) ?? controls[0] ?? null;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* What the Field focuses (design 2.5): the control itself
|
|
83
|
+
* What the Field focuses (design 2.5): the control itself (a form control or a button), or for a
|
|
84
|
+
* group the checked radio if
|
|
84
85
|
* any, else the first enabled named member (a group's first item, not a CheckboxGroup Parent,
|
|
85
86
|
* which has no name), else the first enabled member.
|
|
86
87
|
*/
|
|
87
88
|
function focusTargetOf(el) {
|
|
88
89
|
if (el === null) return null;
|
|
89
90
|
if (isValidatable(el)) return el;
|
|
91
|
+
if (el instanceof HTMLButtonElement) return el;
|
|
90
92
|
const members = (el instanceof HTMLFieldSetElement ? [...el.elements] : [...el.querySelectorAll("input, select, textarea, button")]).filter((m) => m instanceof HTMLElement && !m.disabled && m.type !== "hidden");
|
|
91
93
|
return members.find((m) => m instanceof HTMLInputElement && m.type === "radio" && m.checked) ?? members.find((m) => isValidatable(m) && m.name !== "") ?? members.find(isValidatable) ?? members[0] ?? null;
|
|
92
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validity.mjs","names":[],"sources":["../../../src/internal/form/validity.ts"],"sourcesContent":["// Directive-free helpers for Field and Form (design/components/field-form.md 2, 14): the validity\n// snapshot, error-value normalisation, the `:user-invalid` read and the element resolution.\n\n/** A field error: a message, several messages, or nothing (`\"\"`, `[]`, `null`, `undefined`). */\nexport type FieldErrorValue = string | readonly string[] | null | undefined;\n\n/** Field errors keyed by field `name` (usually `state.errors` from `useActionState`). */\nexport type FormErrors = Readonly<Record<string, FieldErrorValue>>;\n\n/**\n * A plain, serialisable snapshot of the control's `ValidityState` (all `false` and\n * `valid: true` on the server and before the first read).\n */\nexport interface FieldValidity {\n /** A required control has no value. */\n readonly valueMissing: boolean;\n /** The value does not match the `type` (email, url). */\n readonly typeMismatch: boolean;\n /** The value does not match `pattern`. */\n readonly patternMismatch: boolean;\n /** The value is longer than `maxLength`. */\n readonly tooLong: boolean;\n /** The value is shorter than `minLength`. */\n readonly tooShort: boolean;\n /** The value is below `min`. */\n readonly rangeUnderflow: boolean;\n /** The value is above `max`. */\n readonly rangeOverflow: boolean;\n /** The value is not on the `step` grid. */\n readonly stepMismatch: boolean;\n /** The browser cannot convert the input to a value. */\n readonly badInput: boolean;\n /** A custom message is set (`validate` or a shown server error). */\n readonly customError: boolean;\n /** No constraint is violated. */\n readonly valid: boolean;\n}\n\nconst VALIDITY_KEYS = [\n \"valueMissing\",\n \"typeMismatch\",\n \"patternMismatch\",\n \"tooLong\",\n \"tooShort\",\n \"rangeUnderflow\",\n \"rangeOverflow\",\n \"stepMismatch\",\n \"badInput\",\n \"customError\",\n \"valid\",\n] as const satisfies readonly (keyof FieldValidity)[];\n\nexport const VALID: FieldValidity = Object.freeze({\n valueMissing: false,\n typeMismatch: false,\n patternMismatch: false,\n tooLong: false,\n tooShort: false,\n rangeUnderflow: false,\n rangeOverflow: false,\n stepMismatch: false,\n badInput: false,\n customError: false,\n valid: true,\n});\n\nexport function snapshotValidity(validity: ValidityState): FieldValidity {\n const result = {} as Record<keyof FieldValidity, boolean>;\n for (const key of VALIDITY_KEYS) result[key] = validity[key];\n return result;\n}\n\nexport function validityEquals(a: FieldValidity, b: FieldValidity): boolean {\n return VALIDITY_KEYS.every((key) => a[key] === b[key]);\n}\n\nconst NONE: readonly string[] = Object.freeze([]);\n\n/** `\"\"`, `[]`, `null` and `undefined` mean no error; empty strings inside an array are dropped. */\nexport function normaliseErrorValue(value: FieldErrorValue): readonly string[] {\n if (value === null || value === undefined || value === \"\") return NONE;\n if (typeof value === \"string\") return [value];\n const list = value.filter((v) => typeof v === \"string\" && v !== \"\");\n return list.length === 0 ? NONE : list;\n}\n\n/** Some entry of `errors` is a non-empty error. */\nexport function hasAnyError(errors: FormErrors | undefined): boolean {\n if (errors === undefined) return false;\n return Object.values(errors).some((v) => normaliseErrorValue(v).length > 0);\n}\n\nlet userInvalidSupport: boolean | undefined;\n\n/**\n * Whether the environment implements `:user-invalid` (every engine the library supports does).\n * Decided once per module, so the read is not on a hot path.\n *\n * Detected with `CSS.supports(\"selector(:user-invalid)\")` rather than by `matches()` throwing:\n * jsdom 30's selector engine knows the name and silently answers `false` (it does not throw), and\n * its `CSS.supports` reports `false`, so the fallback engages there and nowhere else\n * (memo/developer/field-form.md).\n */\nexport function supportsUserInvalid(): boolean {\n if (userInvalidSupport === undefined) {\n try {\n userInvalidSupport =\n typeof CSS !== \"undefined\" &&\n typeof CSS.supports === \"function\" &&\n CSS.supports(\"selector(:user-invalid)\");\n } catch {\n userInvalidSupport = false;\n }\n }\n return userInvalidSupport;\n}\n\n/** An element that takes part in constraint validation. */\nexport type ValidatableElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n\nfunction isValidatable(el: Element): el is ValidatableElement {\n return (\n el instanceof HTMLInputElement ||\n el instanceof HTMLSelectElement ||\n el instanceof HTMLTextAreaElement\n );\n}\n\n/**\n * Where `validity`, `validationMessage`, `:user-invalid` and `setCustomValidity` are read and\n * written (design 7.1): the element itself when it is a form control, else the first named\n * `willValidate` member of a `<fieldset>` (a group's first enabled item, not a CheckboxGroup\n * Parent, which has no name), else the first `input` / `select` / `textarea` inside.\n */\nexport function validityElementOf(el: Element | null): ValidatableElement | null {\n if (el === null) return null;\n if (isValidatable(el)) return el;\n const members =\n el instanceof HTMLFieldSetElement\n ? [...el.elements]\n : [...el.querySelectorAll(\"input, select, textarea\")];\n const controls = members.filter(isValidatable);\n return (\n controls.find((c) => c.willValidate && c.name !== \"\") ??\n controls.find((c) => c.willValidate) ??\n controls[0] ??\n null\n );\n}\n\n/**\n * What the Field focuses (design 2.5): the control itself, or for a group the checked radio if\n * any, else the first enabled named member (a group's first item, not a CheckboxGroup Parent,\n * which has no name), else the first enabled member.\n */\nexport function focusTargetOf(el: Element | null): HTMLElement | null {\n if (el === null) return null;\n if (isValidatable(el)) return el;\n const members = (\n el instanceof HTMLFieldSetElement\n ? [...el.elements]\n : [...el.querySelectorAll(\"input, select, textarea, button\")]\n ).filter(\n (m): m is HTMLElement =>\n m instanceof HTMLElement &&\n !(m as HTMLInputElement).disabled &&\n (m as HTMLInputElement).type !== \"hidden\",\n );\n const checkedRadio = members.find(\n (m) => m instanceof HTMLInputElement && m.type === \"radio\" && m.checked,\n );\n return (\n checkedRadio ??\n members.find((m) => isValidatable(m) && m.name !== \"\") ??\n members.find(isValidatable) ??\n members[0] ??\n null\n );\n}\n"],"mappings":";AAsCA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,QAAuB,OAAO,OAAO;CAChD,cAAc;CACd,cAAc;CACd,iBAAiB;CACjB,SAAS;CACT,UAAU;CACV,gBAAgB;CAChB,eAAe;CACf,cAAc;CACd,UAAU;CACV,aAAa;CACb,OAAO;AACT,CAAC;AAED,SAAgB,iBAAiB,UAAwC;CACvE,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,OAAO,eAAe,OAAO,OAAO,SAAS;CACxD,OAAO;AACT;AAEA,SAAgB,eAAe,GAAkB,GAA2B;CAC1E,OAAO,cAAc,OAAO,QAAQ,EAAE,SAAS,EAAE,IAAI;AACvD;AAEA,MAAM,OAA0B,OAAO,OAAO,CAAC,CAAC;;AAGhD,SAAgB,oBAAoB,OAA2C;CAC7E,IAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,UAAU,IAAI,OAAO;CAClE,IAAI,OAAO,UAAU,UAAU,OAAO,CAAC,KAAK;CAC5C,MAAM,OAAO,MAAM,QAAQ,MAAM,OAAO,MAAM,YAAY,MAAM,EAAE;CAClE,OAAO,KAAK,WAAW,IAAI,OAAO;AACpC;;AAGA,SAAgB,YAAY,QAAyC;CACnE,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC,MAAM,MAAM,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E;AAEA,IAAI;;;;;;;;;;AAWJ,SAAgB,sBAA+B;CAC7C,IAAI,uBAAuB,KAAA,GACzB,IAAI;EACF,qBACE,OAAO,QAAQ,eACf,OAAO,IAAI,aAAa,cACxB,IAAI,SAAS,yBAAyB;CAC1C,QAAQ;EACN,qBAAqB;CACvB;CAEF,OAAO;AACT;AAKA,SAAS,cAAc,IAAuC;CAC5D,OACE,cAAc,oBACd,cAAc,qBACd,cAAc;AAElB;;;;;;;AAQA,SAAgB,kBAAkB,IAA+C;CAC/E,IAAI,OAAO,MAAM,OAAO;CACxB,IAAI,cAAc,EAAE,GAAG,OAAO;CAK9B,MAAM,YAHJ,cAAc,sBACV,CAAC,GAAG,GAAG,QAAQ,IACf,CAAC,GAAG,GAAG,iBAAiB,yBAAyB,CAAC,EAAA,CAC/B,OAAO,aAAa;CAC7C,OACE,SAAS,MAAM,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,KACpD,SAAS,MAAM,MAAM,EAAE,YAAY,KACnC,SAAS,MACT;AAEJ
|
|
1
|
+
{"version":3,"file":"validity.mjs","names":[],"sources":["../../../src/internal/form/validity.ts"],"sourcesContent":["// Directive-free helpers for Field and Form (design/components/field-form.md 2, 14): the validity\n// snapshot, error-value normalisation, the `:user-invalid` read and the element resolution.\n\n/** A field error: a message, several messages, or nothing (`\"\"`, `[]`, `null`, `undefined`). */\nexport type FieldErrorValue = string | readonly string[] | null | undefined;\n\n/** Field errors keyed by field `name` (usually `state.errors` from `useActionState`). */\nexport type FormErrors = Readonly<Record<string, FieldErrorValue>>;\n\n/**\n * A plain, serialisable snapshot of the control's `ValidityState` (all `false` and\n * `valid: true` on the server and before the first read).\n */\nexport interface FieldValidity {\n /** A required control has no value. */\n readonly valueMissing: boolean;\n /** The value does not match the `type` (email, url). */\n readonly typeMismatch: boolean;\n /** The value does not match `pattern`. */\n readonly patternMismatch: boolean;\n /** The value is longer than `maxLength`. */\n readonly tooLong: boolean;\n /** The value is shorter than `minLength`. */\n readonly tooShort: boolean;\n /** The value is below `min`. */\n readonly rangeUnderflow: boolean;\n /** The value is above `max`. */\n readonly rangeOverflow: boolean;\n /** The value is not on the `step` grid. */\n readonly stepMismatch: boolean;\n /** The browser cannot convert the input to a value. */\n readonly badInput: boolean;\n /** A custom message is set (`validate` or a shown server error). */\n readonly customError: boolean;\n /** No constraint is violated. */\n readonly valid: boolean;\n}\n\nconst VALIDITY_KEYS = [\n \"valueMissing\",\n \"typeMismatch\",\n \"patternMismatch\",\n \"tooLong\",\n \"tooShort\",\n \"rangeUnderflow\",\n \"rangeOverflow\",\n \"stepMismatch\",\n \"badInput\",\n \"customError\",\n \"valid\",\n] as const satisfies readonly (keyof FieldValidity)[];\n\nexport const VALID: FieldValidity = Object.freeze({\n valueMissing: false,\n typeMismatch: false,\n patternMismatch: false,\n tooLong: false,\n tooShort: false,\n rangeUnderflow: false,\n rangeOverflow: false,\n stepMismatch: false,\n badInput: false,\n customError: false,\n valid: true,\n});\n\nexport function snapshotValidity(validity: ValidityState): FieldValidity {\n const result = {} as Record<keyof FieldValidity, boolean>;\n for (const key of VALIDITY_KEYS) result[key] = validity[key];\n return result;\n}\n\nexport function validityEquals(a: FieldValidity, b: FieldValidity): boolean {\n return VALIDITY_KEYS.every((key) => a[key] === b[key]);\n}\n\nconst NONE: readonly string[] = Object.freeze([]);\n\n/** `\"\"`, `[]`, `null` and `undefined` mean no error; empty strings inside an array are dropped. */\nexport function normaliseErrorValue(value: FieldErrorValue): readonly string[] {\n if (value === null || value === undefined || value === \"\") return NONE;\n if (typeof value === \"string\") return [value];\n const list = value.filter((v) => typeof v === \"string\" && v !== \"\");\n return list.length === 0 ? NONE : list;\n}\n\n/** Some entry of `errors` is a non-empty error. */\nexport function hasAnyError(errors: FormErrors | undefined): boolean {\n if (errors === undefined) return false;\n return Object.values(errors).some((v) => normaliseErrorValue(v).length > 0);\n}\n\nlet userInvalidSupport: boolean | undefined;\n\n/**\n * Whether the environment implements `:user-invalid` (every engine the library supports does).\n * Decided once per module, so the read is not on a hot path.\n *\n * Detected with `CSS.supports(\"selector(:user-invalid)\")` rather than by `matches()` throwing:\n * jsdom 30's selector engine knows the name and silently answers `false` (it does not throw), and\n * its `CSS.supports` reports `false`, so the fallback engages there and nowhere else\n * (memo/developer/field-form.md).\n */\nexport function supportsUserInvalid(): boolean {\n if (userInvalidSupport === undefined) {\n try {\n userInvalidSupport =\n typeof CSS !== \"undefined\" &&\n typeof CSS.supports === \"function\" &&\n CSS.supports(\"selector(:user-invalid)\");\n } catch {\n userInvalidSupport = false;\n }\n }\n return userInvalidSupport;\n}\n\n/** An element that takes part in constraint validation. */\nexport type ValidatableElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n\nfunction isValidatable(el: Element): el is ValidatableElement {\n return (\n el instanceof HTMLInputElement ||\n el instanceof HTMLSelectElement ||\n el instanceof HTMLTextAreaElement\n );\n}\n\n/**\n * Where `validity`, `validationMessage`, `:user-invalid` and `setCustomValidity` are read and\n * written (design 7.1): the element itself when it is a form control, else the first named\n * `willValidate` member of a `<fieldset>` (a group's first enabled item, not a CheckboxGroup\n * Parent, which has no name), else the first `input` / `select` / `textarea` inside.\n */\nexport function validityElementOf(el: Element | null): ValidatableElement | null {\n if (el === null) return null;\n if (isValidatable(el)) return el;\n const members =\n el instanceof HTMLFieldSetElement\n ? [...el.elements]\n : [...el.querySelectorAll(\"input, select, textarea\")];\n const controls = members.filter(isValidatable);\n return (\n controls.find((c) => c.willValidate && c.name !== \"\") ??\n controls.find((c) => c.willValidate) ??\n controls[0] ??\n null\n );\n}\n\n/**\n * What the Field focuses (design 2.5): the control itself (a form control or a button), or for a\n * group the checked radio if\n * any, else the first enabled named member (a group's first item, not a CheckboxGroup Parent,\n * which has no name), else the first enabled member.\n */\nexport function focusTargetOf(el: Element | null): HTMLElement | null {\n if (el === null) return null;\n if (isValidatable(el)) return el;\n // A button control (MultiSelect's Trigger, whose validity lives on a hidden element).\n if (el instanceof HTMLButtonElement) return el;\n const members = (\n el instanceof HTMLFieldSetElement\n ? [...el.elements]\n : [...el.querySelectorAll(\"input, select, textarea, button\")]\n ).filter(\n (m): m is HTMLElement =>\n m instanceof HTMLElement &&\n !(m as HTMLInputElement).disabled &&\n (m as HTMLInputElement).type !== \"hidden\",\n );\n const checkedRadio = members.find(\n (m) => m instanceof HTMLInputElement && m.type === \"radio\" && m.checked,\n );\n return (\n checkedRadio ??\n members.find((m) => isValidatable(m) && m.name !== \"\") ??\n members.find(isValidatable) ??\n members[0] ??\n null\n );\n}\n"],"mappings":";AAsCA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,QAAuB,OAAO,OAAO;CAChD,cAAc;CACd,cAAc;CACd,iBAAiB;CACjB,SAAS;CACT,UAAU;CACV,gBAAgB;CAChB,eAAe;CACf,cAAc;CACd,UAAU;CACV,aAAa;CACb,OAAO;AACT,CAAC;AAED,SAAgB,iBAAiB,UAAwC;CACvE,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,OAAO,eAAe,OAAO,OAAO,SAAS;CACxD,OAAO;AACT;AAEA,SAAgB,eAAe,GAAkB,GAA2B;CAC1E,OAAO,cAAc,OAAO,QAAQ,EAAE,SAAS,EAAE,IAAI;AACvD;AAEA,MAAM,OAA0B,OAAO,OAAO,CAAC,CAAC;;AAGhD,SAAgB,oBAAoB,OAA2C;CAC7E,IAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,UAAU,IAAI,OAAO;CAClE,IAAI,OAAO,UAAU,UAAU,OAAO,CAAC,KAAK;CAC5C,MAAM,OAAO,MAAM,QAAQ,MAAM,OAAO,MAAM,YAAY,MAAM,EAAE;CAClE,OAAO,KAAK,WAAW,IAAI,OAAO;AACpC;;AAGA,SAAgB,YAAY,QAAyC;CACnE,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC,MAAM,MAAM,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E;AAEA,IAAI;;;;;;;;;;AAWJ,SAAgB,sBAA+B;CAC7C,IAAI,uBAAuB,KAAA,GACzB,IAAI;EACF,qBACE,OAAO,QAAQ,eACf,OAAO,IAAI,aAAa,cACxB,IAAI,SAAS,yBAAyB;CAC1C,QAAQ;EACN,qBAAqB;CACvB;CAEF,OAAO;AACT;AAKA,SAAS,cAAc,IAAuC;CAC5D,OACE,cAAc,oBACd,cAAc,qBACd,cAAc;AAElB;;;;;;;AAQA,SAAgB,kBAAkB,IAA+C;CAC/E,IAAI,OAAO,MAAM,OAAO;CACxB,IAAI,cAAc,EAAE,GAAG,OAAO;CAK9B,MAAM,YAHJ,cAAc,sBACV,CAAC,GAAG,GAAG,QAAQ,IACf,CAAC,GAAG,GAAG,iBAAiB,yBAAyB,CAAC,EAAA,CAC/B,OAAO,aAAa;CAC7C,OACE,SAAS,MAAM,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,KACpD,SAAS,MAAM,MAAM,EAAE,YAAY,KACnC,SAAS,MACT;AAEJ;;;;;;;AAQA,SAAgB,cAAc,IAAwC;CACpE,IAAI,OAAO,MAAM,OAAO;CACxB,IAAI,cAAc,EAAE,GAAG,OAAO;CAE9B,IAAI,cAAc,mBAAmB,OAAO;CAC5C,MAAM,WACJ,cAAc,sBACV,CAAC,GAAG,GAAG,QAAQ,IACf,CAAC,GAAG,GAAG,iBAAiB,iCAAiC,CAAC,EAAA,CAC9D,QACC,MACC,aAAa,eACb,CAAE,EAAuB,YACxB,EAAuB,SAAS,QACrC;CAIA,OAHqB,QAAQ,MAC1B,MAAM,aAAa,oBAAoB,EAAE,SAAS,WAAW,EAAE,OAGrD,KACX,QAAQ,MAAM,MAAM,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,KACrD,QAAQ,KAAK,aAAa,KAC1B,QAAQ,MACR;AAEJ"}
|
|
@@ -14,7 +14,7 @@ import { useCallback, useRef } from "react";
|
|
|
14
14
|
* task and runs only if the popup is still shown and still meant to be open, and returns no focus
|
|
15
15
|
* to the Trigger. A pending interest open is cancelled instead.
|
|
16
16
|
*/
|
|
17
|
-
function useInterestDismiss(ctx) {
|
|
17
|
+
function useInterestDismiss(ctx, options = {}) {
|
|
18
18
|
const isLibrary = ctx.mode === "library";
|
|
19
19
|
const { popupRef } = ctx;
|
|
20
20
|
const interestInvoker = useRef(null);
|
|
@@ -44,6 +44,7 @@ function useInterestDismiss(ctx) {
|
|
|
44
44
|
event
|
|
45
45
|
});
|
|
46
46
|
interestHide.current = true;
|
|
47
|
+
options.beforeHide?.(element);
|
|
47
48
|
element.hidePopover();
|
|
48
49
|
}, 0);
|
|
49
50
|
} else if (ctx.intended()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-interest-dismiss.mjs","names":[],"sources":["../../../src/internal/overlay/use-interest-dismiss.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useRef } from \"react\";\nimport { eventSource } from \"./invokers.js\";\nimport { isPopoverOpen } from \"./popover-open.js\";\nimport type { PopoverRootValue } from \"./use-overlay-root.js\";\n\nexport interface InterestDismiss {\n /** `interest` at the popup: remembers the button that has interest in it. */\n onInterest(event: Event): void;\n /** `loseinterest` at the popup: the lost-interest hide (see `useInterestDismiss`). */\n onLoseInterest(event: Event): void;\n /** The opening `beforetoggle` the Root routes: whether it is the interest invoker's open. */\n noteOpen(event: ToggleEvent): void;\n /** The popup's `toggle` reported it hidden: the interest open is over. */\n noteClosed(): void;\n /** Whether the hide whose `toggle` arrived was the lost-interest hide; clears it. */\n takeLostInterest(): boolean;\n /** The popup element detached: cancels a pending hide and forgets everything. Stable. */\n reset(): void;\n}\n\n/**\n * Lost interest of an `interestfor` button naming the popup (library mode; Chromium; popover.md\n * lost-interest amendment), for `usePopoverPopup`. The platform hides only a popover its own\n * interest show opened (`invokedVia == kInterest`), and the library cancels that show and\n * re-shows with `showPopover({ source })`, so the platform never hides: the library does, as a\n * dismissal. Chromium also fires `loseinterest` from inside every hide of the popup while the\n * button has interest (Escape, script, the library's own close), before the state flips, and a\n * `hidePopover()` called from there re-enters the hide and loses its `toggle`: the hide waits one\n * task and runs only if the popup is still shown and still meant to be open, and returns no focus\n * to the Trigger. A pending interest open is cancelled instead.\n */\nexport function useInterestDismiss(ctx: PopoverRootValue): InterestDismiss {\n const isLibrary = ctx.mode === \"library\";\n const { popupRef } = ctx;\n // The button that has interest in the popup (`InterestEvent.source`), whether the current open\n // was that button's interest open, the task that hides the popup on its lost interest, and\n // whether the hide in flight is that one.\n const interestInvoker = useRef<Element | null>(null);\n const interestOpen = useRef(false);\n const interestHideTask = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const interestHide = useRef(false);\n\n const onInterest = (event: Event): void => {\n const element = popupRef.current;\n if (!isLibrary || element === null || event.target !== element) return;\n interestInvoker.current = eventSource(event);\n };\n\n const onLoseInterest = (event: Event): void => {\n const element = popupRef.current;\n if (!isLibrary || element === null || event.target !== element) return;\n const source = eventSource(event);\n if (source === null || source !== interestInvoker.current) return;\n interestInvoker.current = null;\n if (!interestOpen.current) return;\n if (isPopoverOpen(element)) {\n clearTimeout(interestHideTask.current);\n interestHideTask.current = setTimeout(() => {\n interestHideTask.current = undefined;\n if (!isPopoverOpen(element) || !ctx.intended()) return;\n // Interest regained meanwhile (the pointer came back): the popup stays.\n if (interestInvoker.current !== null) return;\n // Recorded right before the hide, so its one-task clear cannot run first.\n ctx.recordCloseIntent({ reason: \"dismiss\", event });\n interestHide.current = true;\n element.hidePopover();\n }, 0);\n } else if (ctx.intended()) {\n interestOpen.current = false;\n ctx.requestClose(event, \"dismiss\");\n }\n };\n\n const noteOpen = (event: ToggleEvent): void => {\n // Chromium dispatches `interest` and then the interest show in one step, so a show whose\n // `source` is the remembered interest invoker is that button's interest open.\n const source = eventSource(event);\n interestOpen.current = source !== null && source === interestInvoker.current;\n };\n\n const noteClosed = (): void => {\n interestOpen.current = false;\n };\n\n const takeLostInterest = (): boolean => {\n const lostInterest = interestHide.current;\n interestHide.current = false;\n return lostInterest;\n };\n\n const reset = useCallback((): void => {\n clearTimeout(interestHideTask.current);\n interestHideTask.current = undefined;\n interestHide.current = false;\n interestInvoker.current = null;\n interestOpen.current = false;\n }, []);\n\n return { onInterest, onLoseInterest, noteOpen, noteClosed, takeLostInterest, reset };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,SAAgB,
|
|
1
|
+
{"version":3,"file":"use-interest-dismiss.mjs","names":[],"sources":["../../../src/internal/overlay/use-interest-dismiss.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useRef } from \"react\";\nimport { eventSource } from \"./invokers.js\";\nimport { isPopoverOpen } from \"./popover-open.js\";\nimport type { PopoverRootValue } from \"./use-overlay-root.js\";\n\nexport interface InterestDismiss {\n /** `interest` at the popup: remembers the button that has interest in it. */\n onInterest(event: Event): void;\n /** `loseinterest` at the popup: the lost-interest hide (see `useInterestDismiss`). */\n onLoseInterest(event: Event): void;\n /** The opening `beforetoggle` the Root routes: whether it is the interest invoker's open. */\n noteOpen(event: ToggleEvent): void;\n /** The popup's `toggle` reported it hidden: the interest open is over. */\n noteClosed(): void;\n /** Whether the hide whose `toggle` arrived was the lost-interest hide; clears it. */\n takeLostInterest(): boolean;\n /** The popup element detached: cancels a pending hide and forgets everything. Stable. */\n reset(): void;\n}\n\n/**\n * Lost interest of an `interestfor` button naming the popup (library mode; Chromium; popover.md\n * lost-interest amendment), for `usePopoverPopup`. The platform hides only a popover its own\n * interest show opened (`invokedVia == kInterest`), and the library cancels that show and\n * re-shows with `showPopover({ source })`, so the platform never hides: the library does, as a\n * dismissal. Chromium also fires `loseinterest` from inside every hide of the popup while the\n * button has interest (Escape, script, the library's own close), before the state flips, and a\n * `hidePopover()` called from there re-enters the hide and loses its `toggle`: the hide waits one\n * task and runs only if the popup is still shown and still meant to be open, and returns no focus\n * to the Trigger. A pending interest open is cancelled instead.\n */\nexport function useInterestDismiss(\n ctx: PopoverRootValue,\n options: {\n /**\n * Called right before the lost-interest `hidePopover()` (HoverCard: blur focus inside the\n * popup, so a `hint` popover cannot restore it to the Trigger; hover-card.md 6.2).\n */\n readonly beforeHide?: ((popup: HTMLElement) => void) | undefined;\n } = {},\n): InterestDismiss {\n const isLibrary = ctx.mode === \"library\";\n const { popupRef } = ctx;\n // The button that has interest in the popup (`InterestEvent.source`), whether the current open\n // was that button's interest open, the task that hides the popup on its lost interest, and\n // whether the hide in flight is that one.\n const interestInvoker = useRef<Element | null>(null);\n const interestOpen = useRef(false);\n const interestHideTask = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const interestHide = useRef(false);\n\n const onInterest = (event: Event): void => {\n const element = popupRef.current;\n if (!isLibrary || element === null || event.target !== element) return;\n interestInvoker.current = eventSource(event);\n };\n\n const onLoseInterest = (event: Event): void => {\n const element = popupRef.current;\n if (!isLibrary || element === null || event.target !== element) return;\n const source = eventSource(event);\n if (source === null || source !== interestInvoker.current) return;\n interestInvoker.current = null;\n if (!interestOpen.current) return;\n if (isPopoverOpen(element)) {\n clearTimeout(interestHideTask.current);\n interestHideTask.current = setTimeout(() => {\n interestHideTask.current = undefined;\n if (!isPopoverOpen(element) || !ctx.intended()) return;\n // Interest regained meanwhile (the pointer came back): the popup stays.\n if (interestInvoker.current !== null) return;\n // Recorded right before the hide, so its one-task clear cannot run first.\n ctx.recordCloseIntent({ reason: \"dismiss\", event });\n interestHide.current = true;\n options.beforeHide?.(element);\n element.hidePopover();\n }, 0);\n } else if (ctx.intended()) {\n interestOpen.current = false;\n ctx.requestClose(event, \"dismiss\");\n }\n };\n\n const noteOpen = (event: ToggleEvent): void => {\n // Chromium dispatches `interest` and then the interest show in one step, so a show whose\n // `source` is the remembered interest invoker is that button's interest open.\n const source = eventSource(event);\n interestOpen.current = source !== null && source === interestInvoker.current;\n };\n\n const noteClosed = (): void => {\n interestOpen.current = false;\n };\n\n const takeLostInterest = (): boolean => {\n const lostInterest = interestHide.current;\n interestHide.current = false;\n return lostInterest;\n };\n\n const reset = useCallback((): void => {\n clearTimeout(interestHideTask.current);\n interestHideTask.current = undefined;\n interestHide.current = false;\n interestInvoker.current = null;\n interestOpen.current = false;\n }, []);\n\n return { onInterest, onLoseInterest, noteOpen, noteClosed, takeLostInterest, reset };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,SAAgB,mBACd,KACA,UAMI,CAAC,GACY;CACjB,MAAM,YAAY,IAAI,SAAS;CAC/B,MAAM,EAAE,aAAa;CAIrB,MAAM,kBAAkB,OAAuB,IAAI;CACnD,MAAM,eAAe,OAAO,KAAK;CACjC,MAAM,mBAAmB,OAAkD,KAAA,CAAS;CACpF,MAAM,eAAe,OAAO,KAAK;CAEjC,MAAM,cAAc,UAAuB;EACzC,MAAM,UAAU,SAAS;EACzB,IAAI,CAAC,aAAa,YAAY,QAAQ,MAAM,WAAW,SAAS;EAChE,gBAAgB,UAAU,YAAY,KAAK;CAC7C;CAEA,MAAM,kBAAkB,UAAuB;EAC7C,MAAM,UAAU,SAAS;EACzB,IAAI,CAAC,aAAa,YAAY,QAAQ,MAAM,WAAW,SAAS;EAChE,MAAM,SAAS,YAAY,KAAK;EAChC,IAAI,WAAW,QAAQ,WAAW,gBAAgB,SAAS;EAC3D,gBAAgB,UAAU;EAC1B,IAAI,CAAC,aAAa,SAAS;EAC3B,IAAI,cAAc,OAAO,GAAG;GAC1B,aAAa,iBAAiB,OAAO;GACrC,iBAAiB,UAAU,iBAAiB;IAC1C,iBAAiB,UAAU,KAAA;IAC3B,IAAI,CAAC,cAAc,OAAO,KAAK,CAAC,IAAI,SAAS,GAAG;IAEhD,IAAI,gBAAgB,YAAY,MAAM;IAEtC,IAAI,kBAAkB;KAAE,QAAQ;KAAW;IAAM,CAAC;IAClD,aAAa,UAAU;IACvB,QAAQ,aAAa,OAAO;IAC5B,QAAQ,YAAY;GACtB,GAAG,CAAC;EACN,OAAO,IAAI,IAAI,SAAS,GAAG;GACzB,aAAa,UAAU;GACvB,IAAI,aAAa,OAAO,SAAS;EACnC;CACF;CAEA,MAAM,YAAY,UAA6B;EAG7C,MAAM,SAAS,YAAY,KAAK;EAChC,aAAa,UAAU,WAAW,QAAQ,WAAW,gBAAgB;CACvE;CAEA,MAAM,mBAAyB;EAC7B,aAAa,UAAU;CACzB;CAEA,MAAM,yBAAkC;EACtC,MAAM,eAAe,aAAa;EAClC,aAAa,UAAU;EACvB,OAAO;CACT;CAUA,OAAO;EAAE;EAAY;EAAgB;EAAU;EAAY;EAAkB,OAR/D,kBAAwB;GACpC,aAAa,iBAAiB,OAAO;GACrC,iBAAiB,UAAU,KAAA;GAC3B,aAAa,UAAU;GACvB,gBAAgB,UAAU;GAC1B,aAAa,UAAU;EACzB,GAAG,CAAC,CAE6E;CAAE;AACrF"}
|
|
@@ -8,7 +8,8 @@ import { useElementCheck } from "../use-element-check.mjs";
|
|
|
8
8
|
const isDev = process.env.NODE_ENV !== "production";
|
|
9
9
|
/**
|
|
10
10
|
* The Close part of a popover-like or dialog overlay (design/components/popover.md 3.4,
|
|
11
|
-
* dialog.md 3.4): `<button type="button" commandfor command
|
|
11
|
+
* dialog.md 3.4): `<button type="button" commandfor command>` without `action`, a plain
|
|
12
|
+
* `<button type="button">` with one (#182). In JS-free mode without `action`
|
|
12
13
|
* the browser runs the command. Otherwise the click is cancelled, refused while disabled, and
|
|
13
14
|
* `close` runs, after the `action` when there is one, inside this part's own transition; a
|
|
14
15
|
* second click meanwhile starts nothing (`whilePending`, default `"ignore"`) or runs the action
|
|
@@ -18,6 +19,7 @@ const isDev = process.env.NODE_ENV !== "production";
|
|
|
18
19
|
*/
|
|
19
20
|
function useOverlayClose(options) {
|
|
20
21
|
const { part, noun, isLibrary, popupId, command, action, disabled, render } = options;
|
|
22
|
+
const nativeCommand = action === void 0;
|
|
21
23
|
const trigger = usePureTrigger({
|
|
22
24
|
whilePending: options.whilePending,
|
|
23
25
|
defaultWhilePending: "ignore",
|
|
@@ -41,8 +43,8 @@ function useOverlayClose(options) {
|
|
|
41
43
|
const libraryProps = {
|
|
42
44
|
...rendersButton(render) && { type: "button" },
|
|
43
45
|
disabled: disabledProps.props.disabled,
|
|
44
|
-
commandfor: disabledProps.invoker && rendersButton(render) ? popupId : void 0,
|
|
45
|
-
command: disabledProps.invoker && rendersButton(render) ? command : void 0,
|
|
46
|
+
commandfor: nativeCommand && disabledProps.invoker && rendersButton(render) ? popupId : void 0,
|
|
47
|
+
command: nativeCommand && disabledProps.invoker && rendersButton(render) ? command : void 0,
|
|
46
48
|
...options.ownProps,
|
|
47
49
|
...installClick && { onClick },
|
|
48
50
|
...!installClick && !disabledProps.invoker && { onClick: cancelClick },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-overlay-close.mjs","names":[],"sources":["../../../src/internal/overlay/use-overlay-close.ts"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport { dataAttr } from \"../data-attr.js\";\nimport type { Action, ActionDetails, RenderProp, StateValue, WhilePending } from \"../types.js\";\nimport { useElementCheck } from \"../use-element-check.js\";\nimport { usePureTrigger } from \"../action/use-pure-trigger.js\";\nimport { cancelClick, disabledButton, rendersButton, useRender } from \"../use-render.js\";\nimport type { DataAttributes } from \"../use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The state of Popover.Close and Dialog.Close. */\nexport interface OverlayCloseState {\n /** The `action` is in flight. */\n readonly pending: boolean;\n readonly disabled: boolean;\n}\n\nexport interface OverlayCloseOptions<Details extends ActionDetails> {\n /** Public name of the part (`\"Popover.Close\"`). */\n readonly part: string;\n /** What the part closes, for the development warning (`\"popover\"`). */\n readonly noun: string;\n readonly isLibrary: boolean;\n /** The popup's id (`commandfor`) and the native command. */\n readonly popupId: string;\n readonly command: \"hide-popover\" | \"request-close\";\n readonly openGeneration: () => number;\n readonly action: Action<[details: Details]> | undefined;\n /** The part's `whilePending` prop; `\"ignore\"` when omitted (conventions 2.5.1). */\n readonly whilePending: WhilePending | undefined;\n /** The `action`'s details, built at the click. */\n readonly details: (event: Event) => Details;\n /** The close after the action (or at once without one): through the Root, or natively. */\n readonly close: (event: Event) => void;\n /** Owned keys after `command` (Dialog.Close's `value`). */\n readonly ownProps?: ComponentPropsWithRef<\"button\">;\n readonly disabled: boolean;\n readonly className: StateValue<string | undefined, OverlayCloseState> | undefined;\n readonly style: StateValue<CSSProperties | undefined, OverlayCloseState> | undefined;\n readonly children: StateValue<ReactNode, OverlayCloseState> | undefined;\n readonly render: RenderProp<ComponentPropsWithRef<\"button\">, OverlayCloseState> | undefined;\n readonly rest: Omit<ComponentPropsWithRef<\"button\">, \"className\" | \"style\" | \"children\">;\n}\n\n/**\n * The Close part of a popover-like or dialog overlay (design/components/popover.md 3.4,\n * dialog.md 3.4): `<button type=\"button\" commandfor command
|
|
1
|
+
{"version":3,"file":"use-overlay-close.mjs","names":[],"sources":["../../../src/internal/overlay/use-overlay-close.ts"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport { dataAttr } from \"../data-attr.js\";\nimport type { Action, ActionDetails, RenderProp, StateValue, WhilePending } from \"../types.js\";\nimport { useElementCheck } from \"../use-element-check.js\";\nimport { usePureTrigger } from \"../action/use-pure-trigger.js\";\nimport { cancelClick, disabledButton, rendersButton, useRender } from \"../use-render.js\";\nimport type { DataAttributes } from \"../use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The state of Popover.Close and Dialog.Close. */\nexport interface OverlayCloseState {\n /** The `action` is in flight. */\n readonly pending: boolean;\n readonly disabled: boolean;\n}\n\nexport interface OverlayCloseOptions<Details extends ActionDetails> {\n /** Public name of the part (`\"Popover.Close\"`). */\n readonly part: string;\n /** What the part closes, for the development warning (`\"popover\"`). */\n readonly noun: string;\n readonly isLibrary: boolean;\n /** The popup's id (`commandfor`) and the native command. */\n readonly popupId: string;\n readonly command: \"hide-popover\" | \"request-close\";\n readonly openGeneration: () => number;\n readonly action: Action<[details: Details]> | undefined;\n /** The part's `whilePending` prop; `\"ignore\"` when omitted (conventions 2.5.1). */\n readonly whilePending: WhilePending | undefined;\n /** The `action`'s details, built at the click. */\n readonly details: (event: Event) => Details;\n /** The close after the action (or at once without one): through the Root, or natively. */\n readonly close: (event: Event) => void;\n /** Owned keys after `command` (Dialog.Close's `value`). */\n readonly ownProps?: ComponentPropsWithRef<\"button\">;\n readonly disabled: boolean;\n readonly className: StateValue<string | undefined, OverlayCloseState> | undefined;\n readonly style: StateValue<CSSProperties | undefined, OverlayCloseState> | undefined;\n readonly children: StateValue<ReactNode, OverlayCloseState> | undefined;\n readonly render: RenderProp<ComponentPropsWithRef<\"button\">, OverlayCloseState> | undefined;\n readonly rest: Omit<ComponentPropsWithRef<\"button\">, \"className\" | \"style\" | \"children\">;\n}\n\n/**\n * The Close part of a popover-like or dialog overlay (design/components/popover.md 3.4,\n * dialog.md 3.4): `<button type=\"button\" commandfor command>` without `action`, a plain\n * `<button type=\"button\">` with one (#182). In JS-free mode without `action`\n * the browser runs the command. Otherwise the click is cancelled, refused while disabled, and\n * `close` runs, after the `action` when there is one, inside this part's own transition; a\n * second click meanwhile starts nothing (`whilePending`, default `\"ignore\"`) or runs the action\n * again (`\"run\"`; the close happens once, after the last run and only if the latest one\n * resolved), and a close whose open was superseded by a\n * newer one (dismissed and re-opened meanwhile) is dropped (the open-generation guard).\n */\nexport function useOverlayClose<Details extends ActionDetails>(\n options: OverlayCloseOptions<Details>,\n): ReactNode {\n const { part, noun, isLibrary, popupId, command, action, disabled, render } = options;\n // A Close with `action` is no native invoker (#182, alert-dialog.md 3.2): before hydration a\n // click would close the popup without running the action. It renders a plain button, and the\n // click handler is the only thing that closes it.\n const nativeCommand = action === undefined;\n // The library owns the close, so a Close ignores clicks while pending by default (2.5.1).\n const trigger = usePureTrigger({\n whilePending: options.whilePending,\n defaultWhilePending: \"ignore\",\n openGeneration: options.openGeneration,\n });\n const { pending } = trigger;\n const installClick = isLibrary || action !== undefined;\n // JS-free mode without `action` is the browser's command, which only native `disabled` stops.\n const disabledProps = disabledButton(render, disabled, { handlesClick: installClick });\n\n const ref = useElementCheck(\n isDev &&\n ((element) =>\n !installClick && element.tagName !== \"BUTTON\"\n ? `${part}: rendered a <${element.tagName.toLowerCase()}> in JS-free mode without ` +\n `\\`action\\`. Only a <button> runs \\`command=\"${command}\"\\`; this element will not ` +\n `close the ${noun}.`\n : null),\n [installClick],\n );\n\n const onClick = (event: MouseEvent<HTMLElement>) => {\n // Cancelling the click cancels the command.\n event.preventDefault();\n if (disabled) return;\n const native = event.nativeEvent;\n if (action === undefined) {\n options.close(native);\n return;\n }\n const details = options.details(native);\n // An ignored run needs no extra cancel: the click is already cancelled above.\n trigger.run(\n () => action(details),\n () => options.close(native),\n );\n };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n // Owned: a render element must not re-enable a disabled Close.\n disabled: disabledProps.props.disabled,\n // Only on a button (or a component, assumed to render one): another element is no invoker.\n // Not rendered with `action` (above).\n commandfor:\n nativeCommand && disabledProps.invoker && rendersButton(render) ? popupId : undefined,\n command: nativeCommand && disabledProps.invoker && rendersButton(render) ? command : undefined,\n ...options.ownProps,\n ...(installClick && { onClick }),\n // JS-free mode without `action`, disabled in the `aria-disabled` branch (a host link):\n // nothing native stops the click, so it is cancelled (a disabled link must not navigate).\n ...(!installClick && !disabledProps.invoker && { onClick: cancelClick }),\n // Exactly while `data-pending` when ignoring: a Close that will not act is unavailable to\n // AT; one that runs again is not; native `disabled` wins. Owned, so an idle Close removes a\n // render element's own.\n ...trigger.pendingProps(disabledProps.props),\n \"data-disabled\": dataAttr(disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, OverlayCloseState>({\n defaultElement: \"button\",\n render,\n state: { pending, disabled },\n className: options.className,\n style: options.style,\n children: options.children,\n props: options.rest,\n libraryProps,\n ref,\n });\n}\n"],"mappings":";;;;;;;AASA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;AA+CvC,SAAgB,gBACd,SACW;CACX,MAAM,EAAE,MAAM,MAAM,WAAW,SAAS,SAAS,QAAQ,UAAU,WAAW;CAI9E,MAAM,gBAAgB,WAAW,KAAA;CAEjC,MAAM,UAAU,eAAe;EAC7B,cAAc,QAAQ;EACtB,qBAAqB;EACrB,gBAAgB,QAAQ;CAC1B,CAAC;CACD,MAAM,EAAE,YAAY;CACpB,MAAM,eAAe,aAAa,WAAW,KAAA;CAE7C,MAAM,gBAAgB,eAAe,QAAQ,UAAU,EAAE,cAAc,aAAa,CAAC;CAErF,MAAM,MAAM,gBACV,WACI,YACA,CAAC,gBAAgB,QAAQ,YAAY,WACjC,GAAG,KAAK,gBAAgB,QAAQ,QAAQ,YAAY,EAAE,wEACP,QAAQ,uCAC1C,KAAK,KAClB,OACR,CAAC,YAAY,CACf;CAEA,MAAM,WAAW,UAAmC;EAElD,MAAM,eAAe;EACrB,IAAI,UAAU;EACd,MAAM,SAAS,MAAM;EACrB,IAAI,WAAW,KAAA,GAAW;GACxB,QAAQ,MAAM,MAAM;GACpB;EACF;EACA,MAAM,UAAU,QAAQ,QAAQ,MAAM;EAEtC,QAAQ,UACA,OAAO,OAAO,SACd,QAAQ,MAAM,MAAM,CAC5B;CACF;CAEA,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EAEvD,UAAU,cAAc,MAAM;EAG9B,YACE,iBAAiB,cAAc,WAAW,cAAc,MAAM,IAAI,UAAU,KAAA;EAC9E,SAAS,iBAAiB,cAAc,WAAW,cAAc,MAAM,IAAI,UAAU,KAAA;EACrF,GAAG,QAAQ;EACX,GAAI,gBAAgB,EAAE,QAAQ;EAG9B,GAAI,CAAC,gBAAgB,CAAC,cAAc,WAAW,EAAE,SAAS,YAAY;EAItE,GAAG,QAAQ,aAAa,cAAc,KAAK;EAC3C,iBAAiB,SAAS,QAAQ;CACpC;CAEA,OAAO,UAA8D;EACnE,gBAAgB;EAChB;EACA,OAAO;GAAE;GAAS;EAAS;EAC3B,WAAW,QAAQ;EACnB,OAAO,QAAQ;EACf,UAAU,QAAQ;EAClB,OAAO,QAAQ;EACf;EACA;CACF,CAAC;AACH"}
|