@mortenbrudvik/waveui 0.4.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1221 -173
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/components/button/Button.cjs +2 -0
- package/dist/components/button/Button.cjs.map +1 -0
- package/dist/components/button/Button.mjs +50 -0
- package/dist/components/button/Button.mjs.map +1 -0
- package/dist/components/button/Button.semantics.cjs +2 -0
- package/dist/components/button/Button.semantics.cjs.map +1 -0
- package/dist/components/button/Button.semantics.mjs +61 -0
- package/dist/components/button/Button.semantics.mjs.map +1 -0
- package/dist/components/button/Button.slots.cjs +2 -0
- package/dist/components/button/Button.slots.cjs.map +1 -0
- package/dist/components/button/Button.slots.mjs +47 -0
- package/dist/components/button/Button.slots.mjs.map +1 -0
- package/dist/components/button/CompoundButton.cjs +2 -0
- package/dist/components/button/CompoundButton.cjs.map +1 -0
- package/dist/components/button/CompoundButton.mjs +53 -0
- package/dist/components/button/CompoundButton.mjs.map +1 -0
- package/dist/components/button/Link.cjs +2 -0
- package/dist/components/button/Link.cjs.map +1 -0
- package/dist/components/button/Link.mjs +37 -0
- package/dist/components/button/Link.mjs.map +1 -0
- package/dist/components/button/MenuButton.cjs +2 -0
- package/dist/components/button/MenuButton.cjs.map +1 -0
- package/dist/components/button/MenuButton.mjs +45 -0
- package/dist/components/button/MenuButton.mjs.map +1 -0
- package/dist/components/button/SplitButton.cjs +2 -0
- package/dist/components/button/SplitButton.cjs.map +1 -0
- package/dist/components/button/SplitButton.mjs +66 -0
- package/dist/components/button/SplitButton.mjs.map +1 -0
- package/dist/components/button/ToggleButton.cjs +2 -0
- package/dist/components/button/ToggleButton.cjs.map +1 -0
- package/dist/components/button/ToggleButton.mjs +65 -0
- package/dist/components/button/ToggleButton.mjs.map +1 -0
- package/dist/components/button/Toolbar.cjs +2 -0
- package/dist/components/button/Toolbar.cjs.map +1 -0
- package/dist/components/button/Toolbar.context.cjs +2 -0
- package/dist/components/button/Toolbar.context.cjs.map +1 -0
- package/dist/components/button/Toolbar.context.mjs +31 -0
- package/dist/components/button/Toolbar.context.mjs.map +1 -0
- package/dist/components/button/Toolbar.mjs +63 -0
- package/dist/components/button/Toolbar.mjs.map +1 -0
- package/dist/components/button/Toolbar.parts.cjs +2 -0
- package/dist/components/button/Toolbar.parts.cjs.map +1 -0
- package/dist/components/button/Toolbar.parts.mjs +131 -0
- package/dist/components/button/Toolbar.parts.mjs.map +1 -0
- package/dist/components/button/buttonStyles.cjs +2 -0
- package/dist/components/button/buttonStyles.cjs.map +1 -0
- package/dist/components/button/buttonStyles.mjs +39 -0
- package/dist/components/button/buttonStyles.mjs.map +1 -0
- package/dist/components/data-display/Avatar.cjs +2 -0
- package/dist/components/data-display/Avatar.cjs.map +1 -0
- package/dist/components/data-display/Avatar.mjs +157 -0
- package/dist/components/data-display/Avatar.mjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.cjs +2 -0
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.mjs +134 -0
- package/dist/components/data-display/AvatarGroup.mjs.map +1 -0
- package/dist/components/data-display/Badge.cjs +2 -0
- package/dist/components/data-display/Badge.cjs.map +1 -0
- package/dist/components/data-display/Badge.colors.cjs +2 -0
- package/dist/components/data-display/Badge.colors.cjs.map +1 -0
- package/dist/components/data-display/Badge.colors.mjs +58 -0
- package/dist/components/data-display/Badge.colors.mjs.map +1 -0
- package/dist/components/data-display/Badge.mjs +32 -0
- package/dist/components/data-display/Badge.mjs.map +1 -0
- package/dist/components/data-display/CounterBadge.cjs +2 -0
- package/dist/components/data-display/CounterBadge.cjs.map +1 -0
- package/dist/components/data-display/CounterBadge.mjs +28 -0
- package/dist/components/data-display/CounterBadge.mjs.map +1 -0
- package/dist/components/data-display/Divider.cjs +2 -0
- package/dist/components/data-display/Divider.cjs.map +1 -0
- package/dist/components/data-display/Divider.mjs +52 -0
- package/dist/components/data-display/Divider.mjs.map +1 -0
- package/dist/components/data-display/Image.cjs +2 -0
- package/dist/components/data-display/Image.cjs.map +1 -0
- package/dist/components/data-display/Image.mjs +32 -0
- package/dist/components/data-display/Image.mjs.map +1 -0
- package/dist/components/data-display/InfoLabel.cjs +2 -0
- package/dist/components/data-display/InfoLabel.cjs.map +1 -0
- package/dist/components/data-display/InfoLabel.mjs +104 -0
- package/dist/components/data-display/InfoLabel.mjs.map +1 -0
- package/dist/components/data-display/List.cjs +2 -0
- package/dist/components/data-display/List.cjs.map +1 -0
- package/dist/components/data-display/List.mjs +381 -0
- package/dist/components/data-display/List.mjs.map +1 -0
- package/dist/components/data-display/List.registry.cjs +2 -0
- package/dist/components/data-display/List.registry.cjs.map +1 -0
- package/dist/components/data-display/List.registry.mjs +101 -0
- package/dist/components/data-display/List.registry.mjs.map +1 -0
- package/dist/components/data-display/Persona.cjs +2 -0
- package/dist/components/data-display/Persona.cjs.map +1 -0
- package/dist/components/data-display/Persona.mjs +48 -0
- package/dist/components/data-display/Persona.mjs.map +1 -0
- package/dist/components/data-display/PresenceBadge.cjs +2 -0
- package/dist/components/data-display/PresenceBadge.cjs.map +1 -0
- package/dist/components/data-display/PresenceBadge.mjs +71 -0
- package/dist/components/data-display/PresenceBadge.mjs.map +1 -0
- package/dist/components/data-display/Tag.cjs +2 -0
- package/dist/components/data-display/Tag.cjs.map +1 -0
- package/dist/components/data-display/Tag.mjs +147 -0
- package/dist/components/data-display/Tag.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.cjs +2 -0
- package/dist/components/feedback/MessageBar.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.mjs +144 -0
- package/dist/components/feedback/MessageBar.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.cjs +2 -0
- package/dist/components/feedback/MessageBar.status.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.mjs +45 -0
- package/dist/components/feedback/MessageBar.status.mjs.map +1 -0
- package/dist/components/feedback/ProgressBar.cjs +2 -0
- package/dist/components/feedback/ProgressBar.cjs.map +1 -0
- package/dist/components/feedback/ProgressBar.mjs +72 -0
- package/dist/components/feedback/ProgressBar.mjs.map +1 -0
- package/dist/components/feedback/Skeleton.cjs +2 -0
- package/dist/components/feedback/Skeleton.cjs.map +1 -0
- package/dist/components/feedback/Skeleton.mjs +47 -0
- package/dist/components/feedback/Skeleton.mjs.map +1 -0
- package/dist/components/feedback/Spinner.cjs +2 -0
- package/dist/components/feedback/Spinner.cjs.map +1 -0
- package/dist/components/feedback/Spinner.mjs +60 -0
- package/dist/components/feedback/Spinner.mjs.map +1 -0
- package/dist/components/feedback/Toast.cjs +2 -0
- package/dist/components/feedback/Toast.cjs.map +1 -0
- package/dist/components/feedback/Toast.mjs +347 -0
- package/dist/components/feedback/Toast.mjs.map +1 -0
- package/dist/components/input/Checkbox.cjs +2 -0
- package/dist/components/input/Checkbox.cjs.map +1 -0
- package/dist/components/input/Checkbox.mjs +96 -0
- package/dist/components/input/Checkbox.mjs.map +1 -0
- package/dist/components/input/ColorPicker.cjs +6 -0
- package/dist/components/input/ColorPicker.cjs.map +1 -0
- package/dist/components/input/ColorPicker.mjs +236 -0
- package/dist/components/input/ColorPicker.mjs.map +1 -0
- package/dist/components/input/Combobox.cjs +2 -0
- package/dist/components/input/Combobox.cjs.map +1 -0
- package/dist/components/input/Combobox.expand.cjs +2 -0
- package/dist/components/input/Combobox.expand.cjs.map +1 -0
- package/dist/components/input/Combobox.expand.mjs +38 -0
- package/dist/components/input/Combobox.expand.mjs.map +1 -0
- package/dist/components/input/Combobox.mjs +187 -0
- package/dist/components/input/Combobox.mjs.map +1 -0
- package/dist/components/input/DatePicker.cjs +2 -0
- package/dist/components/input/DatePicker.cjs.map +1 -0
- package/dist/components/input/DatePicker.mjs +340 -0
- package/dist/components/input/DatePicker.mjs.map +1 -0
- package/dist/components/input/Dropdown.cjs +2 -0
- package/dist/components/input/Dropdown.cjs.map +1 -0
- package/dist/components/input/Dropdown.mjs +128 -0
- package/dist/components/input/Dropdown.mjs.map +1 -0
- package/dist/components/input/Field.cjs +2 -0
- package/dist/components/input/Field.cjs.map +1 -0
- package/dist/components/input/Field.mjs +200 -0
- package/dist/components/input/Field.mjs.map +1 -0
- package/dist/components/input/Input.cjs +2 -0
- package/dist/components/input/Input.cjs.map +1 -0
- package/dist/components/input/Input.mjs +81 -0
- package/dist/components/input/Input.mjs.map +1 -0
- package/dist/components/input/Label.cjs +2 -0
- package/dist/components/input/Label.cjs.map +1 -0
- package/dist/components/input/Label.mjs +28 -0
- package/dist/components/input/Label.mjs.map +1 -0
- package/dist/components/input/Option.cjs +2 -0
- package/dist/components/input/Option.cjs.map +1 -0
- package/dist/components/input/Option.mjs +169 -0
- package/dist/components/input/Option.mjs.map +1 -0
- package/dist/components/input/RadioGroup.cjs +2 -0
- package/dist/components/input/RadioGroup.cjs.map +1 -0
- package/dist/components/input/RadioGroup.mjs +139 -0
- package/dist/components/input/RadioGroup.mjs.map +1 -0
- package/dist/components/input/Rating.cjs +2 -0
- package/dist/components/input/Rating.cjs.map +1 -0
- package/dist/components/input/Rating.mjs +196 -0
- package/dist/components/input/Rating.mjs.map +1 -0
- package/dist/components/input/SearchBox.cjs +2 -0
- package/dist/components/input/SearchBox.cjs.map +1 -0
- package/dist/components/input/SearchBox.mjs +205 -0
- package/dist/components/input/SearchBox.mjs.map +1 -0
- package/dist/components/input/Select.cjs +2 -0
- package/dist/components/input/Select.cjs.map +1 -0
- package/dist/components/input/Select.mjs +33 -0
- package/dist/components/input/Select.mjs.map +1 -0
- package/dist/components/input/Slider.cjs +2 -0
- package/dist/components/input/Slider.cjs.map +1 -0
- package/dist/components/input/Slider.mjs +79 -0
- package/dist/components/input/Slider.mjs.map +1 -0
- package/dist/components/input/SpinButton.cjs +2 -0
- package/dist/components/input/SpinButton.cjs.map +1 -0
- package/dist/components/input/SpinButton.mjs +157 -0
- package/dist/components/input/SpinButton.mjs.map +1 -0
- package/dist/components/input/SwatchPicker.cjs +2 -0
- package/dist/components/input/SwatchPicker.cjs.map +1 -0
- package/dist/components/input/SwatchPicker.mjs +113 -0
- package/dist/components/input/SwatchPicker.mjs.map +1 -0
- package/dist/components/input/Switch.cjs +2 -0
- package/dist/components/input/Switch.cjs.map +1 -0
- package/dist/components/input/Switch.mjs +92 -0
- package/dist/components/input/Switch.mjs.map +1 -0
- package/dist/components/input/TagPicker.cjs +2 -0
- package/dist/components/input/TagPicker.cjs.map +1 -0
- package/dist/components/input/TagPicker.mjs +249 -0
- package/dist/components/input/TagPicker.mjs.map +1 -0
- package/dist/components/input/Textarea.cjs +2 -0
- package/dist/components/input/Textarea.cjs.map +1 -0
- package/dist/components/input/Textarea.mjs +32 -0
- package/dist/components/input/Textarea.mjs.map +1 -0
- package/dist/components/input/TimePicker.cjs +2 -0
- package/dist/components/input/TimePicker.cjs.map +1 -0
- package/dist/components/input/TimePicker.mjs +292 -0
- package/dist/components/input/TimePicker.mjs.map +1 -0
- package/dist/components/input/colorUtils.cjs +2 -0
- package/dist/components/input/colorUtils.cjs.map +1 -0
- package/dist/components/input/colorUtils.mjs +96 -0
- package/dist/components/input/colorUtils.mjs.map +1 -0
- package/dist/components/input/dateUtils.cjs +2 -0
- package/dist/components/input/dateUtils.cjs.map +1 -0
- package/dist/components/input/dateUtils.mjs +250 -0
- package/dist/components/input/dateUtils.mjs.map +1 -0
- package/dist/components/input/pickerStyles.cjs +2 -0
- package/dist/components/input/pickerStyles.cjs.map +1 -0
- package/dist/components/input/pickerStyles.mjs +10 -0
- package/dist/components/input/pickerStyles.mjs.map +1 -0
- package/dist/components/internal/HiddenInput.cjs +2 -0
- package/dist/components/internal/HiddenInput.cjs.map +1 -0
- package/dist/components/internal/HiddenInput.mjs +88 -0
- package/dist/components/internal/HiddenInput.mjs.map +1 -0
- package/dist/components/layout/Accordion.cjs +2 -0
- package/dist/components/layout/Accordion.cjs.map +1 -0
- package/dist/components/layout/Accordion.mjs +236 -0
- package/dist/components/layout/Accordion.mjs.map +1 -0
- package/dist/components/layout/Card.cjs +2 -0
- package/dist/components/layout/Card.cjs.map +1 -0
- package/dist/components/layout/Card.mjs +121 -0
- package/dist/components/layout/Card.mjs.map +1 -0
- package/dist/components/layout/Carousel.cjs +2 -0
- package/dist/components/layout/Carousel.cjs.map +1 -0
- package/dist/components/layout/Carousel.mjs +205 -0
- package/dist/components/layout/Carousel.mjs.map +1 -0
- package/dist/components/layout/Flex.cjs +2 -0
- package/dist/components/layout/Flex.cjs.map +1 -0
- package/dist/components/layout/Flex.mjs +54 -0
- package/dist/components/layout/Flex.mjs.map +1 -0
- package/dist/components/layout/Grid.cjs +2 -0
- package/dist/components/layout/Grid.cjs.map +1 -0
- package/dist/components/layout/Grid.mjs +62 -0
- package/dist/components/layout/Grid.mjs.map +1 -0
- package/dist/components/layout/Overflow.cjs +2 -0
- package/dist/components/layout/Overflow.cjs.map +1 -0
- package/dist/components/layout/Overflow.mjs +269 -0
- package/dist/components/layout/Overflow.mjs.map +1 -0
- package/dist/components/layout/Stack.cjs +2 -0
- package/dist/components/layout/Stack.cjs.map +1 -0
- package/dist/components/layout/Stack.mjs +39 -0
- package/dist/components/layout/Stack.mjs.map +1 -0
- package/dist/components/layout/TabList.cjs +2 -0
- package/dist/components/layout/TabList.cjs.map +1 -0
- package/dist/components/layout/TabList.mjs +238 -0
- package/dist/components/layout/TabList.mjs.map +1 -0
- package/dist/components/layout/Tree.cjs +2 -0
- package/dist/components/layout/Tree.cjs.map +1 -0
- package/dist/components/layout/Tree.mjs +220 -0
- package/dist/components/layout/Tree.mjs.map +1 -0
- package/dist/components/layout/disclosureIds.cjs +2 -0
- package/dist/components/layout/disclosureIds.cjs.map +1 -0
- package/dist/components/layout/disclosureIds.mjs +12 -0
- package/dist/components/layout/disclosureIds.mjs.map +1 -0
- package/dist/components/motion/Presence.cjs +2 -0
- package/dist/components/motion/Presence.cjs.map +1 -0
- package/dist/components/motion/Presence.mjs +35 -0
- package/dist/components/motion/Presence.mjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.cjs +2 -0
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.mjs +144 -0
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -0
- package/dist/components/navigation/Menu.cjs +2 -0
- package/dist/components/navigation/Menu.cjs.map +1 -0
- package/dist/components/navigation/Menu.context.cjs +2 -0
- package/dist/components/navigation/Menu.context.cjs.map +1 -0
- package/dist/components/navigation/Menu.context.mjs +82 -0
- package/dist/components/navigation/Menu.context.mjs.map +1 -0
- package/dist/components/navigation/Menu.group.cjs +2 -0
- package/dist/components/navigation/Menu.group.cjs.map +1 -0
- package/dist/components/navigation/Menu.group.mjs +58 -0
- package/dist/components/navigation/Menu.group.mjs.map +1 -0
- package/dist/components/navigation/Menu.items.cjs +2 -0
- package/dist/components/navigation/Menu.items.cjs.map +1 -0
- package/dist/components/navigation/Menu.items.mjs +127 -0
- package/dist/components/navigation/Menu.items.mjs.map +1 -0
- package/dist/components/navigation/Menu.link.cjs +2 -0
- package/dist/components/navigation/Menu.link.cjs.map +1 -0
- package/dist/components/navigation/Menu.link.mjs +41 -0
- package/dist/components/navigation/Menu.link.mjs.map +1 -0
- package/dist/components/navigation/Menu.mjs +27 -0
- package/dist/components/navigation/Menu.mjs.map +1 -0
- package/dist/components/navigation/Menu.popover.cjs +2 -0
- package/dist/components/navigation/Menu.popover.cjs.map +1 -0
- package/dist/components/navigation/Menu.popover.mjs +231 -0
- package/dist/components/navigation/Menu.popover.mjs.map +1 -0
- package/dist/components/navigation/Menu.root.cjs +2 -0
- package/dist/components/navigation/Menu.root.cjs.map +1 -0
- package/dist/components/navigation/Menu.root.mjs +308 -0
- package/dist/components/navigation/Menu.root.mjs.map +1 -0
- package/dist/components/navigation/Menu.selectable.cjs +2 -0
- package/dist/components/navigation/Menu.selectable.cjs.map +1 -0
- package/dist/components/navigation/Menu.selectable.mjs +89 -0
- package/dist/components/navigation/Menu.selectable.mjs.map +1 -0
- package/dist/components/navigation/Menu.shared.cjs +2 -0
- package/dist/components/navigation/Menu.shared.cjs.map +1 -0
- package/dist/components/navigation/Menu.shared.mjs +23 -0
- package/dist/components/navigation/Menu.shared.mjs.map +1 -0
- package/dist/components/navigation/Menu.splitGroup.cjs +2 -0
- package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -0
- package/dist/components/navigation/Menu.splitGroup.mjs +51 -0
- package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -0
- package/dist/components/navigation/Menu.trigger.cjs +2 -0
- package/dist/components/navigation/Menu.trigger.cjs.map +1 -0
- package/dist/components/navigation/Menu.trigger.mjs +79 -0
- package/dist/components/navigation/Menu.trigger.mjs.map +1 -0
- package/dist/components/navigation/Nav.cjs +2 -0
- package/dist/components/navigation/Nav.cjs.map +1 -0
- package/dist/components/navigation/Nav.mjs +276 -0
- package/dist/components/navigation/Nav.mjs.map +1 -0
- package/dist/components/navigation/Pagination.cjs +2 -0
- package/dist/components/navigation/Pagination.cjs.map +1 -0
- package/dist/components/navigation/Pagination.mjs +110 -0
- package/dist/components/navigation/Pagination.mjs.map +1 -0
- package/dist/components/navigation/Stepper.cjs +2 -0
- package/dist/components/navigation/Stepper.cjs.map +1 -0
- package/dist/components/navigation/Stepper.mjs +204 -0
- package/dist/components/navigation/Stepper.mjs.map +1 -0
- package/dist/components/overlays/Dialog.cjs +2 -0
- package/dist/components/overlays/Dialog.cjs.map +1 -0
- package/dist/components/overlays/Dialog.mjs +180 -0
- package/dist/components/overlays/Dialog.mjs.map +1 -0
- package/dist/components/overlays/Dialog.shared.cjs +2 -0
- package/dist/components/overlays/Dialog.shared.cjs.map +1 -0
- package/dist/components/overlays/Dialog.shared.mjs +227 -0
- package/dist/components/overlays/Dialog.shared.mjs.map +1 -0
- package/dist/components/overlays/Drawer.cjs +2 -0
- package/dist/components/overlays/Drawer.cjs.map +1 -0
- package/dist/components/overlays/Drawer.mjs +192 -0
- package/dist/components/overlays/Drawer.mjs.map +1 -0
- package/dist/components/overlays/Popover.cjs +2 -0
- package/dist/components/overlays/Popover.cjs.map +1 -0
- package/dist/components/overlays/Popover.mjs +365 -0
- package/dist/components/overlays/Popover.mjs.map +1 -0
- package/dist/components/overlays/Popover.shared.cjs +2 -0
- package/dist/components/overlays/Popover.shared.cjs.map +1 -0
- package/dist/components/overlays/Popover.shared.mjs +182 -0
- package/dist/components/overlays/Popover.shared.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.mjs +181 -0
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -0
- package/dist/components/overlays/Tooltip.cjs +2 -0
- package/dist/components/overlays/Tooltip.cjs.map +1 -0
- package/dist/components/overlays/Tooltip.mjs +160 -0
- package/dist/components/overlays/Tooltip.mjs.map +1 -0
- package/dist/components/portal/Portal.cjs +2 -0
- package/dist/components/portal/Portal.cjs.map +1 -0
- package/dist/components/portal/Portal.mjs +45 -0
- package/dist/components/portal/Portal.mjs.map +1 -0
- package/dist/components/provider/WaveProvider.cjs +2 -0
- package/dist/components/provider/WaveProvider.cjs.map +1 -0
- package/dist/components/provider/WaveProvider.mjs +51 -0
- package/dist/components/provider/WaveProvider.mjs.map +1 -0
- package/dist/components/table/DataGrid.cjs +2 -0
- package/dist/components/table/DataGrid.cjs.map +1 -0
- package/dist/components/table/DataGrid.mjs +489 -0
- package/dist/components/table/DataGrid.mjs.map +1 -0
- package/dist/components/table/Table.cjs +2 -0
- package/dist/components/table/Table.cjs.map +1 -0
- package/dist/components/table/Table.mjs +99 -0
- package/dist/components/table/Table.mjs.map +1 -0
- package/dist/components/table/useGridNavigation.cjs +2 -0
- package/dist/components/table/useGridNavigation.cjs.map +1 -0
- package/dist/components/table/useGridNavigation.mjs +336 -0
- package/dist/components/table/useGridNavigation.mjs.map +1 -0
- package/dist/components/typography/Text.cjs +2 -0
- package/dist/components/typography/Text.cjs.map +1 -0
- package/dist/components/typography/Text.mjs +38 -0
- package/dist/components/typography/Text.mjs.map +1 -0
- package/dist/hooks/useAnnounce.cjs +2 -0
- package/dist/hooks/useAnnounce.cjs.map +1 -0
- package/dist/hooks/useAnnounce.mjs +88 -0
- package/dist/hooks/useAnnounce.mjs.map +1 -0
- package/dist/hooks/useCheckedValues.cjs +2 -0
- package/dist/hooks/useCheckedValues.cjs.map +1 -0
- package/dist/hooks/useCheckedValues.mjs +102 -0
- package/dist/hooks/useCheckedValues.mjs.map +1 -0
- package/dist/hooks/useContextMenuAnchor.cjs +2 -0
- package/dist/hooks/useContextMenuAnchor.cjs.map +1 -0
- package/dist/hooks/useContextMenuAnchor.mjs +132 -0
- package/dist/hooks/useContextMenuAnchor.mjs.map +1 -0
- package/dist/hooks/useControllable.cjs +2 -0
- package/dist/hooks/useControllable.cjs.map +1 -0
- package/dist/hooks/useControllable.mjs +37 -0
- package/dist/hooks/useControllable.mjs.map +1 -0
- package/dist/hooks/useDirection.cjs +2 -0
- package/dist/hooks/useDirection.cjs.map +1 -0
- package/dist/hooks/useDirection.mjs +57 -0
- package/dist/hooks/useDirection.mjs.map +1 -0
- package/dist/hooks/useDismiss.cjs +2 -0
- package/dist/hooks/useDismiss.cjs.map +1 -0
- package/dist/hooks/useDismiss.mjs +57 -0
- package/dist/hooks/useDismiss.mjs.map +1 -0
- package/dist/hooks/useEventCallback.cjs +2 -0
- package/dist/hooks/useEventCallback.cjs.map +1 -0
- package/dist/hooks/useEventCallback.mjs +16 -0
- package/dist/hooks/useEventCallback.mjs.map +1 -0
- package/dist/hooks/useFieldControl.cjs +2 -0
- package/dist/hooks/useFieldControl.cjs.map +1 -0
- package/dist/hooks/useFieldControl.mjs +62 -0
- package/dist/hooks/useFieldControl.mjs.map +1 -0
- package/dist/hooks/useFocusTrap.cjs +2 -0
- package/dist/hooks/useFocusTrap.cjs.map +1 -0
- package/dist/hooks/useFocusTrap.mjs +266 -0
- package/dist/hooks/useFocusTrap.mjs.map +1 -0
- package/dist/hooks/useFormReset.cjs +2 -0
- package/dist/hooks/useFormReset.cjs.map +1 -0
- package/dist/hooks/useFormReset.mjs +33 -0
- package/dist/hooks/useFormReset.mjs.map +1 -0
- package/dist/hooks/useHoverIntent.cjs +2 -0
- package/dist/hooks/useHoverIntent.cjs.map +1 -0
- package/dist/hooks/useHoverIntent.mjs +201 -0
- package/dist/hooks/useHoverIntent.mjs.map +1 -0
- package/dist/hooks/useId.cjs +2 -0
- package/dist/hooks/useId.cjs.map +1 -0
- package/dist/hooks/useId.mjs +11 -0
- package/dist/hooks/useId.mjs.map +1 -0
- package/dist/hooks/useIsClient.cjs +2 -0
- package/dist/hooks/useIsClient.cjs.map +1 -0
- package/dist/hooks/useIsClient.mjs +19 -0
- package/dist/hooks/useIsClient.mjs.map +1 -0
- package/dist/hooks/useListbox.cjs +2 -0
- package/dist/hooks/useListbox.cjs.map +1 -0
- package/dist/hooks/useListbox.mjs +492 -0
- package/dist/hooks/useListbox.mjs.map +1 -0
- package/dist/hooks/useMergedRefs.cjs +2 -0
- package/dist/hooks/useMergedRefs.cjs.map +1 -0
- package/dist/hooks/useMergedRefs.mjs +57 -0
- package/dist/hooks/useMergedRefs.mjs.map +1 -0
- package/dist/hooks/useModalIsolation.cjs +2 -0
- package/dist/hooks/useModalIsolation.cjs.map +1 -0
- package/dist/hooks/useModalIsolation.mjs +87 -0
- package/dist/hooks/useModalIsolation.mjs.map +1 -0
- package/dist/hooks/useModalLayer.cjs +2 -0
- package/dist/hooks/useModalLayer.cjs.map +1 -0
- package/dist/hooks/useModalLayer.mjs +30 -0
- package/dist/hooks/useModalLayer.mjs.map +1 -0
- package/dist/hooks/usePopupPosition.cjs +2 -0
- package/dist/hooks/usePopupPosition.cjs.map +1 -0
- package/dist/hooks/usePopupPosition.mjs +117 -0
- package/dist/hooks/usePopupPosition.mjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.cjs +2 -0
- package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.mjs +24 -0
- package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -0
- package/dist/hooks/usePresence.cjs +2 -0
- package/dist/hooks/usePresence.cjs.map +1 -0
- package/dist/hooks/usePresence.mjs +136 -0
- package/dist/hooks/usePresence.mjs.map +1 -0
- package/dist/hooks/usePreserveFocus.cjs +2 -0
- package/dist/hooks/usePreserveFocus.cjs.map +1 -0
- package/dist/hooks/usePreserveFocus.mjs +50 -0
- package/dist/hooks/usePreserveFocus.mjs.map +1 -0
- package/dist/hooks/useRestoreFocus.cjs +2 -0
- package/dist/hooks/useRestoreFocus.cjs.map +1 -0
- package/dist/hooks/useRestoreFocus.mjs +271 -0
- package/dist/hooks/useRestoreFocus.mjs.map +1 -0
- package/dist/hooks/useRovingTabIndex.cjs +2 -0
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -0
- package/dist/hooks/useRovingTabIndex.mjs +389 -0
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -0
- package/dist/hooks/useScrollLock.cjs +2 -0
- package/dist/hooks/useScrollLock.cjs.map +1 -0
- package/dist/hooks/useScrollLock.mjs +71 -0
- package/dist/hooks/useScrollLock.mjs.map +1 -0
- package/dist/hooks/useTriggerElement.cjs +2 -0
- package/dist/hooks/useTriggerElement.cjs.map +1 -0
- package/dist/hooks/useTriggerElement.mjs +126 -0
- package/dist/hooks/useTriggerElement.mjs.map +1 -0
- package/dist/hooks/useTypeahead.cjs +2 -0
- package/dist/hooks/useTypeahead.cjs.map +1 -0
- package/dist/hooks/useTypeahead.mjs +38 -0
- package/dist/hooks/useTypeahead.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9099 -0
- package/dist/index.d.ts +7688 -1027
- package/dist/index.mjs +91 -5695
- package/dist/lib/aria.cjs +2 -0
- package/dist/lib/aria.cjs.map +1 -0
- package/dist/lib/aria.mjs +29 -0
- package/dist/lib/aria.mjs.map +1 -0
- package/dist/lib/children.cjs +2 -0
- package/dist/lib/children.cjs.map +1 -0
- package/dist/lib/children.mjs +37 -0
- package/dist/lib/children.mjs.map +1 -0
- package/dist/lib/cn.cjs +2 -0
- package/dist/lib/cn.cjs.map +1 -0
- package/dist/lib/cn.mjs +64 -0
- package/dist/lib/cn.mjs.map +1 -0
- package/dist/lib/composeEventHandlers.cjs +2 -0
- package/dist/lib/composeEventHandlers.cjs.map +1 -0
- package/dist/lib/composeEventHandlers.mjs +11 -0
- package/dist/lib/composeEventHandlers.mjs.map +1 -0
- package/dist/lib/dev.cjs +2 -0
- package/dist/lib/dev.cjs.map +1 -0
- package/dist/lib/dev.mjs +42 -0
- package/dist/lib/dev.mjs.map +1 -0
- package/dist/lib/direction.cjs +2 -0
- package/dist/lib/direction.cjs.map +1 -0
- package/dist/lib/direction.mjs +35 -0
- package/dist/lib/direction.mjs.map +1 -0
- package/dist/lib/events.cjs +2 -0
- package/dist/lib/events.cjs.map +1 -0
- package/dist/lib/events.mjs +31 -0
- package/dist/lib/events.mjs.map +1 -0
- package/dist/lib/focus.cjs +2 -0
- package/dist/lib/focus.cjs.map +1 -0
- package/dist/lib/focus.mjs +119 -0
- package/dist/lib/focus.mjs.map +1 -0
- package/dist/lib/globalRegistry.cjs +2 -0
- package/dist/lib/globalRegistry.cjs.map +1 -0
- package/dist/lib/globalRegistry.mjs +13 -0
- package/dist/lib/globalRegistry.mjs.map +1 -0
- package/dist/lib/icons.cjs +2 -0
- package/dist/lib/icons.cjs.map +1 -0
- package/dist/lib/icons.mjs +254 -0
- package/dist/lib/icons.mjs.map +1 -0
- package/dist/lib/labelInName.cjs +2 -0
- package/dist/lib/labelInName.cjs.map +1 -0
- package/dist/lib/labelInName.mjs +54 -0
- package/dist/lib/labelInName.mjs.map +1 -0
- package/dist/lib/layers.cjs +2 -0
- package/dist/lib/layers.cjs.map +1 -0
- package/dist/lib/layers.mjs +224 -0
- package/dist/lib/layers.mjs.map +1 -0
- package/dist/lib/mergeProps.cjs +2 -0
- package/dist/lib/mergeProps.cjs.map +1 -0
- package/dist/lib/mergeProps.mjs +21 -0
- package/dist/lib/mergeProps.mjs.map +1 -0
- package/dist/lib/mergeRefs.cjs +2 -0
- package/dist/lib/mergeRefs.cjs.map +1 -0
- package/dist/lib/mergeRefs.mjs +29 -0
- package/dist/lib/mergeRefs.mjs.map +1 -0
- package/dist/lib/renderTrigger.cjs +2 -0
- package/dist/lib/renderTrigger.cjs.map +1 -0
- package/dist/lib/renderTrigger.mjs +29 -0
- package/dist/lib/renderTrigger.mjs.map +1 -0
- package/dist/lib/slot.cjs +2 -0
- package/dist/lib/slot.cjs.map +1 -0
- package/dist/lib/slot.mjs +122 -0
- package/dist/lib/slot.mjs.map +1 -0
- package/dist/lib/styles.cjs +2 -0
- package/dist/lib/styles.cjs.map +1 -0
- package/dist/lib/styles.mjs +16 -0
- package/dist/lib/styles.mjs.map +1 -0
- package/dist/lib/theme.cjs +2 -0
- package/dist/lib/theme.cjs.map +1 -0
- package/dist/lib/theme.mjs +16 -0
- package/dist/lib/theme.mjs.map +1 -0
- package/dist/preflight.css +2 -0
- package/dist/styles.css +2 -0
- package/package.json +149 -100
- package/src/styles/animations.css +7 -39
- package/src/styles/base.css +103 -0
- package/src/styles/globals.css +10 -22
- package/src/styles/legacy-tokens.css +184 -0
- package/src/styles/preflight.css +7 -0
- package/src/styles/styles.css +32 -0
- package/src/styles/tailwind.css +17 -0
- package/src/styles/tokens.css +561 -221
- package/src/styles/variants.css +29 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataGrid.mjs","names":["useId","_Fragment","useId$1","React","DEFAULT_SELECT_ALL_LABEL","DEFAULT_SELECTION_HEADER_LABEL","createSelectionStore","selected","initial","registered","selectedRegistered","selectAll","singleMode","initialSingleMode","singleId","rowListeners","selectAllListeners","notify","listener","listeners","getSingleId","first","rowId","onRegistrationChange","previous","updateSelectAll","next","subscribeTo","count","done","remaining","items","item","single","createHeaderSlotRegistry","slots","update","nextCell","slot","getCell","cell","DataGridContext","DataGridSortContext","DataGridSectionContext","DataGridHeaderSlotsContext","DataGridHeaderRowHintContext","INERT_CONTEXT","INERT_SORT_CONTEXT","useDataGridContext","reportMissingContext","component","useDataGridSortContext","EMPTY_ITEMS","toItems","keys","sameItems","a","b","index","renderFlatChild","node","key","warnDuplicateRowId","cellBase","selectionCell","nativeControl","DataGridRoot","sortProp","sortColumnProp","sortDirectionProp","selectedItemsProp","rest","props","usesSortApi","defaultSort","sortApiMode","setSortApiMode","objectCallbacks","legacySortControlled","warnDeprecated","defaultSortColumn","defaultSortDirection","mixedSortApi","warnOnce","legacyHalves","setLegacyHalves","legacyControlledSort","column","legacyDefaultSort","sort","setSort","useControllable","onSortChange","requestSort","columnId","sortContext","onSelectionChange","legacySelected","selectedKeys","legacyDefaultSelected","defaultSelectedKeys","controlledSelected","resolveDeprecatedProp","defaultSelected","defaultSelectedItems","setSelected","onSelectedItemsChange","selectionMode","store","toggleRow","effective","selectedCount","toggleAll","all","radioName","selectAllLabel","labels","selectionHeaderLabel","context","useGridNavigation","mergedRef","useMergedRefs","ref","gridRef","content","children","flatChildren","columns","flattenChildren","isElementOfType","DataGridHeader","isCaption","Fragment","DataGridHeaderCell","child","containerClassName","containerLabel","containerLabelledBy","containerRest","containerProps","containerHasRole","droppedContainerName","cn","className","composeEventHandlers","onKeyDown","gridProps","onFocus","onBlur","DataGridSelectionHeaderCell","state","inputRef","clicks","setClicks","focusRingInset","INERT_HEADER_SLOTS","DataGridSelectionHeaderSlot","cellRef","getIsFirst","initialFirst","getServerIsFirst","isFirst","withSelectionHeaderSlots","visit","nodes","thead","setThead","isDev","row","sortIcon","direction","sortColumnId","sortable","sortedDirection","sortOnButtonClick","button","event","onClick","DataGridBody","DataGridRow","section","firstHeaderRowHint","inHeader","selectable","labelId","getSelected","isSelected","unregister","unlabelled","selectionLabel","handleKeyDown","target","labelledBy","idCellIndex","firstCellIndex","DataGridCell","firstCell","needsLabel","selectionCellElement","forcedColors","DataGrid"],"sources":["../../../src/components/table/DataGrid.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport {\n isDev,\n reportMissingContext,\n resolveDeprecatedProp,\n warnDeprecated,\n warnOnce,\n} from '../../lib/dev';\nimport { focusRingInset, forcedColors } from '../../lib/styles';\nimport type { SelectionMode } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useGridNavigation } from './useGridNavigation';\n\nexport type SortDirection = 'ascending' | 'descending';\n\n/** The sort state of a DataGrid: the sorted column and its direction. */\nexport interface DataGridSort {\n /** The `columnId` of the sorted column. */\n columnId: string;\n /** The sort direction. */\n direction: SortDirection;\n}\n\n/** Defines a column in the DataGrid. */\nexport interface DataGridColumn {\n /** Unique identifier for the column (the header cell's `columnId`). */\n id: string;\n /** Display label for the column header. */\n label: string;\n /** Whether the column supports sorting. */\n sortable?: boolean;\n}\n\n/** The built-in text of a DataGrid, for localization (see `DataGridBaseProps.labels`). */\nexport interface DataGridLabels {\n /** Accessible name of the select-all checkbox in the header (`selectionMode=\"multiple\"`).\n * @default 'Select all rows'\n */\n selectAll?: string;\n /**\n * Visually hidden text of the selection column's header cell (`selectionMode=\"single\"`), which\n * names that column.\n * @default 'Selection'\n */\n selectionHeader?: string;\n}\n\nconst DEFAULT_SELECT_ALL_LABEL = 'Select all rows';\nconst DEFAULT_SELECTION_HEADER_LABEL = 'Selection';\n\n/** Props of every DataGrid, whatever sort API it uses. */\nexport interface DataGridBaseProps extends React.HTMLAttributes<HTMLTableElement> {\n /**\n * Column definitions. When given and no `DataGrid.Header` child is present, the header row\n * (including the selection column) is rendered from them: `id` becomes the header cell's\n * `columnId`, `label` its content, `sortable` makes it a sort button.\n */\n columns?: readonly DataGridColumn[];\n /**\n * Row selection mode. `'multiple'` adds a checkbox column with a \"Select all rows\" header\n * checkbox; `'single'` adds a radio column (its header reads \"Selection\" to assistive\n * technology). `labels` localizes both texts.\n * @default 'none'\n */\n selectionMode?: 'none' | SelectionMode;\n /**\n * The name of the select-all checkbox and the header text of the selection column, for\n * localization. Unset members keep their English defaults. Rows are named with their own\n * `selectionLabel`.\n */\n labels?: DataGridLabels;\n /**\n * Controlled selected row ids (`DataGrid.Row` `rowId`). In single mode pass at most one id: with\n * several, only the first one whose row is rendered is selected (a development warning says so).\n */\n selectedItems?: readonly string[];\n /** Initially selected row ids (uncontrolled). In single mode, at most one (see `selectedItems`). */\n defaultSelectedItems?: readonly string[];\n /**\n * Called with the new selected row ids when the selection changes. Ids of rows that are not\n * rendered are left out of the reported selection and of the select-all state, so the next\n * change drops them. Until that change an uncontrolled grid still holds such an id: a row\n * re-added with the same `rowId` before then is shown selected again.\n */\n onSelectedItemsChange?: (selectedItems: string[]) => void;\n /** @deprecated Use `selectedItems` (an array). A `Set` or an array is accepted. */\n selectedKeys?: ReadonlySet<string> | readonly string[];\n /** @deprecated Use `defaultSelectedItems` (an array). A `Set` or an array is accepted. */\n defaultSelectedKeys?: ReadonlySet<string> | readonly string[];\n /** @deprecated Use `onSelectedItemsChange`, which receives an array. Both are called. */\n onSelectionChange?: (keys: Set<string>) => void;\n /**\n * Props for the wrapper `<div>` around the `<table>`: a horizontally scrollable container\n * (`overflow-x-auto`). Use it for its className, style (e.g. a max height) or ref. The wrapper\n * is not a tab stop (the grid's own cell tab stop scrolls it) and has no role, so its\n * `aria-label`/`aria-labelledby` are applied only together with a `role` (e.g. `'region'`);\n * without one they are dropped with a development warning. Name the grid with `aria-label`.\n */\n containerProps?: Omit<React.ComponentPropsWithRef<'div'>, 'children'>;\n /** DataGrid header, body, and row elements. */\n children: React.ReactNode;\n /** Ref to the `<table role=\"grid\">` element. */\n ref?: React.Ref<HTMLTableElement>;\n}\n\ninterface NoDeprecatedSortProps {\n sortColumn?: never;\n defaultSortColumn?: never;\n sortDirection?: never;\n defaultSortDirection?: never;\n}\n\n/** The 0.5 sort API, controlled: `sort` + `onSortChange(sort)`. */\nexport interface DataGridControlledSortProps extends NoDeprecatedSortProps {\n /** The controlled sort, or `null` for an unsorted grid. */\n sort: DataGridSort | null;\n /** Initial sort while `sort` is not given yet. */\n defaultSort?: DataGridSort | null;\n /**\n * Called with the new sort when a sortable header is activated. Sorting is controlled: the\n * consumer reorders the rows.\n */\n onSortChange?: (sort: DataGridSort) => void;\n}\n\n/** The 0.5 sort API, uncontrolled: `defaultSort` (`null` for none) + `onSortChange(sort)`. */\nexport interface DataGridUncontrolledSortProps extends NoDeprecatedSortProps {\n sort?: undefined;\n /** The initial sort, or `null` for an initially unsorted grid. */\n defaultSort: DataGridSort | null;\n /**\n * Called with the new sort when a sortable header is activated. Sorting is controlled: the\n * consumer reorders the rows.\n */\n onSortChange?: (sort: DataGridSort) => void;\n}\n\n/**\n * The 0.4 sort API: `onSortChange(columnId, direction)` and the deprecated `sortColumn`/\n * `sortDirection` props. It applies whenever neither `sort` nor `defaultSort` is given. As in 0.4,\n * the column and the direction can be controlled independently: the half that is not controlled is\n * kept internally and follows every sort request (mixed control, warned in development).\n */\nexport interface DataGridLegacySortProps {\n sort?: undefined;\n defaultSort?: undefined;\n /**\n * @deprecated Use `sort` (`{ columnId, direction }` or `null`). Without `sortDirection`, the\n * direction is kept internally (it toggles on repeated clicks).\n */\n sortColumn?: string;\n /** @deprecated Use `defaultSort`. */\n defaultSortColumn?: string;\n /**\n * @deprecated Use `sort`. Without `sortColumn`, the column is kept internally (it follows the\n * clicked header, starting from `defaultSortColumn`).\n */\n sortDirection?: SortDirection;\n /** @deprecated Use `defaultSort`. */\n defaultSortDirection?: SortDirection;\n /**\n * Called when a sortable header is activated, with the 0.4 arguments. Pass `sort` or\n * `defaultSort` to receive a `DataGridSort` object instead: `defaultSort={null}` turns the\n * object form on for an initially unsorted grid. A `sort` that is still `undefined` (e.g. while\n * data loads) does not: pass `sort={sort ?? null}`.\n *\n * @example\n * <DataGrid defaultSort={null} onSortChange={(sort) => setSort(sort)}>…</DataGrid>\n */\n onSortChange?: (columnId: string, direction: SortDirection) => void;\n}\n\n/**\n * Properties for the DataGrid component. The sort props form a union: `sort`/`defaultSort` with\n * `onSortChange(sort)` (0.5), or the 0.4 form `onSortChange(columnId, direction)` with the\n * deprecated `sortColumn`/`sortDirection`/`defaultSortColumn`/`defaultSortDirection`. The two\n * cannot be mixed.\n */\nexport type DataGridProps = DataGridBaseProps &\n (DataGridControlledSortProps | DataGridUncontrolledSortProps | DataGridLegacySortProps);\n\n/** Properties for the DataGridHeader sub-component. */\nexport interface DataGridHeaderProps extends React.HTMLAttributes<HTMLTableSectionElement> {\n /**\n * Header row elements. Each `<tr>` child (also inside a Fragment) gets the selection column's\n * header cell prepended when the grid is selectable; a header row rendered by another component\n * should be a `DataGrid.Row`, which adds the cell itself. With several header rows (a grouped\n * header), only the first one gets the \"Select all rows\" control; later rows get an empty cell.\n */\n children: React.ReactNode;\n /** Ref to the `<thead>` element. */\n ref?: React.Ref<HTMLTableSectionElement>;\n}\n\n/** Properties for the DataGridHeaderCell sub-component. */\nexport interface DataGridHeaderCellProps extends React.ThHTMLAttributes<HTMLTableCellElement> {\n /** Column ID used for sort tracking. Required for `sortable`. */\n columnId?: string;\n /**\n * Whether this column can be sorted. The content is rendered inside a `<button>`; the header\n * cell carries `aria-sort`. Ignored (with a development warning) without `columnId`.\n * @default false\n */\n sortable?: boolean;\n /** Header cell content. */\n children: React.ReactNode;\n /** Ref to the `<th>` element. */\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\n/** Properties for the DataGridBody sub-component. */\nexport interface DataGridBodyProps extends React.HTMLAttributes<HTMLTableSectionElement> {\n /** DataGrid row elements. */\n children: React.ReactNode;\n /** Ref to the `<tbody>` element. */\n ref?: React.Ref<HTMLTableSectionElement>;\n}\n\n/** Properties for the DataGridRow sub-component. */\nexport interface DataGridRowProps extends React.HTMLAttributes<HTMLTableRowElement> {\n /**\n * Unique identifier for this row, used for selection (rows that share one are selected together;\n * a duplicate warns in development). A selectable grid renders no selection control (and warns\n * in development) for a row without it.\n */\n rowId?: string;\n /**\n * Accessible name of the row's selection control. Defaults to the row's first child that is a\n * `DataGrid.Cell`, `<td>` or `<th>` element (`aria-labelledby`); a cell that another component\n * renders is not seen, so pass `selectionLabel` when the row's first cell is one. Without such a\n * child the control is named \"Select row\" (with a development warning).\n */\n selectionLabel?: string;\n /** DataGrid cell elements. */\n children: React.ReactNode;\n /** Ref to the `<tr>` element. */\n ref?: React.Ref<HTMLTableRowElement>;\n}\n\n/** Properties for the DataGridCell sub-component. */\nexport interface DataGridCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {\n /** Cell content. */\n children: React.ReactNode;\n /** Ref to the `<td>` element. */\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\n// ---------------------------------------------------------------------------\n// Selection store\n// ---------------------------------------------------------------------------\n\ntype SelectAllState = 'all' | 'some' | 'none';\n\n/**\n * Selection state shared with the rows through `useSyncExternalStore`, so toggling one row\n * re-renders only that row (and the select-all header cell). The root pushes the committed\n * selection in a layout effect; rows register their ids. The effective selection is always\n * `selected ∩ registered`, derived on read (no pruning effect).\n *\n * @internal Not exported from the package (exported for its unit tests).\n */\nexport interface SelectionStore {\n /**\n * Row subscription: notified only when the selection changes. Rows registering or unregistering\n * notify no row, so adding or removing k of n rows costs O(k), not O(k·n); the one exception is\n * single mode with several selected ids, where a row registering can move the selected row.\n */\n subscribe(listener: () => void): () => void;\n /**\n * Select-all subscription: notified only when {@link getSelectAllState} changes (through the\n * selection or through rows registering and unregistering).\n */\n subscribeSelectAll(listener: () => void): () => void;\n /** Registers a rendered row id; returns the unregister function. */\n register(rowId: string): () => void;\n /** How many rendered rows are registered with `rowId` (more than one: a duplicate). */\n countRegistrations(rowId: string): number;\n /** Sets the committed selection (layout effect of the root). */\n setSelected(items: readonly string[]): void;\n /**\n * Sets whether the grid is in single mode (layout effect of the root). Only then do rows\n * registering or unregistering re-check the one selected row of single mode and notify the rows.\n */\n setSingleMode(single: boolean): void;\n /**\n * Whether the row is selected. With `single`, only one row is: the first selected id (in\n * selection order) whose row is registered, else the first selected id (before any row\n * registered: the server render and the first client render).\n */\n isSelected(rowId: string, single?: boolean): boolean;\n /** Whether all, some or none of the registered rows are selected. O(1). */\n getSelectAllState(): SelectAllState;\n /** Registered row ids in registration order. */\n getRegistered(): string[];\n /** `items` restricted to registered rows (order of `items`). */\n prune(items: readonly string[]): string[];\n}\n\n/**\n * Creates the {@link SelectionStore} of one DataGrid.\n *\n * @internal Not exported from the package (exported for its unit tests).\n */\nexport function createSelectionStore(\n initial: readonly string[],\n initialSingleMode = false,\n): SelectionStore {\n let selected: ReadonlySet<string> = new Set(initial);\n /** Registered row id -> number of rows registered with it. */\n const registered = new Map<string, number>();\n /** How many registered row ids are selected (kept up to date, so select-all is O(1)). */\n let selectedRegistered = 0;\n let selectAll: SelectAllState = 'none';\n let singleMode = initialSingleMode;\n /** The one selected row of single mode (see `isSelected`); `undefined`: not computed yet. */\n let singleId: string | null | undefined;\n const rowListeners = new Set<() => void>();\n const selectAllListeners = new Set<() => void>();\n\n const notify = (listeners: Set<() => void>) => {\n for (const listener of Array.from(listeners)) listener();\n };\n\n /** Computed on read: O(selected ids) once per change, and only in single mode. */\n const getSingleId = (): string | null => {\n if (singleId !== undefined) return singleId;\n let first: string | null = null;\n for (const rowId of selected) {\n if (registered.has(rowId)) {\n first = rowId;\n break;\n }\n first ??= rowId;\n }\n singleId = first;\n return first;\n };\n\n /**\n * A row id registered or unregistered. With several selected ids, the one selected row of\n * single mode can move: in single mode it is re-checked and the rows are notified if it moved.\n */\n const onRegistrationChange = (rowId: string) => {\n if (selected.size < 2 || !selected.has(rowId)) return;\n const previous = singleId;\n singleId = undefined;\n if (singleMode && getSingleId() !== previous) notify(rowListeners);\n };\n\n const updateSelectAll = () => {\n const next: SelectAllState =\n selectedRegistered === 0 ? 'none' : selectedRegistered === registered.size ? 'all' : 'some';\n if (next === selectAll) return;\n selectAll = next;\n notify(selectAllListeners);\n };\n\n const subscribeTo = (listeners: Set<() => void>) => (listener: () => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n };\n\n return {\n subscribe: subscribeTo(rowListeners),\n subscribeSelectAll: subscribeTo(selectAllListeners),\n register(rowId) {\n const count = registered.get(rowId) ?? 0;\n registered.set(rowId, count + 1);\n if (count === 0 && selected.has(rowId)) selectedRegistered += 1;\n updateSelectAll();\n if (count === 0) onRegistrationChange(rowId);\n let done = false;\n return () => {\n if (done) return;\n done = true;\n const remaining = (registered.get(rowId) ?? 0) - 1;\n if (remaining > 0) {\n registered.set(rowId, remaining);\n return;\n }\n registered.delete(rowId);\n if (selected.has(rowId)) selectedRegistered -= 1;\n updateSelectAll();\n onRegistrationChange(rowId);\n };\n },\n setSelected(items) {\n const next = new Set(items);\n if (next.size === selected.size && items.every((item) => selected.has(item))) return;\n selected = next;\n singleId = undefined;\n selectedRegistered = 0;\n for (const rowId of next) if (registered.has(rowId)) selectedRegistered += 1;\n notify(rowListeners);\n updateSelectAll();\n },\n setSingleMode(single) {\n singleMode = single;\n },\n isSelected(rowId, single = false) {\n return single ? getSingleId() === rowId : selected.has(rowId);\n },\n countRegistrations(rowId) {\n return registered.get(rowId) ?? 0;\n },\n getSelectAllState() {\n return selectAll;\n },\n getRegistered() {\n return Array.from(registered.keys());\n },\n prune(items) {\n return items.filter((item) => registered.has(item));\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Header selection slots\n// ---------------------------------------------------------------------------\n\n/**\n * The selection column's header slots of one `DataGrid.Header`, one per header row. Only the first\n * slot in document order renders the \"Select all rows\" control (the \"Selection\" text in single\n * mode); the others render an empty cell, so a grouped header (several header rows) has one control\n * and every header row keeps the selection column.\n */\ninterface HeaderSlotRegistry {\n subscribe(listener: () => void): () => void;\n /** Registers a slot and a getter for its current cell; returns the unregister function. */\n register(slot: object, getCell: () => Element | null): () => void;\n /** The first slot in document order, or `null` while no slot is registered. */\n getFirst(): object | null;\n /** Re-checks the order: header rows can move without a slot mounting or unmounting. */\n refresh(): void;\n}\n\nfunction createHeaderSlotRegistry(): HeaderSlotRegistry {\n const slots = new Map<object, () => Element | null>();\n const listeners = new Set<() => void>();\n let first: object | null = null;\n\n const update = () => {\n let next: object | null = null;\n let nextCell: Element | null = null;\n for (const [slot, getCell] of slots) {\n const cell = getCell();\n if (!cell) {\n // A slot whose cell is being replaced (control <-> empty cell): keep the current order\n // until the next registration or header commit sees every cell again.\n if (first !== null && slots.has(first)) return;\n continue;\n }\n if (!nextCell || cell.compareDocumentPosition(nextCell) & Node.DOCUMENT_POSITION_FOLLOWING) {\n next = slot;\n nextCell = cell;\n }\n }\n if (next === null) next = slots.keys().next().value ?? null;\n if (next === first) return;\n first = next;\n for (const listener of Array.from(listeners)) listener();\n };\n\n return {\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n register(slot, getCell) {\n slots.set(slot, getCell);\n update();\n return () => {\n slots.delete(slot);\n update();\n };\n },\n getFirst: () => first,\n refresh: update,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Contexts\n// ---------------------------------------------------------------------------\n\ninterface DataGridContextValue {\n selectionMode: 'none' | SelectionMode;\n store: SelectionStore;\n /** Toggles one row (single mode: selects it alone, or clears it). */\n toggleRow: (rowId: string) => void;\n /** Selects every rendered row, or clears the selection when all are selected. */\n toggleAll: () => void;\n /** Shared `name` of the single-mode radios (they are kept out of any form with `form=\"\"`). */\n radioName: string;\n /** Name of the select-all checkbox (multiple mode). */\n selectAllLabel: string;\n /** Hidden header text of the selection column (single mode). */\n selectionHeaderLabel: string;\n}\n\ninterface DataGridSortContextValue {\n sort: DataGridSort | null;\n requestSort: (columnId: string) => void;\n}\n\ntype DataGridSection = 'header' | 'body';\n\nconst DataGridContext = React.createContext<DataGridContextValue | null>(null);\nconst DataGridSortContext = React.createContext<DataGridSortContextValue | null>(null);\n/** Whether a row is rendered in the header or the body (rows in a header get a header cell). */\nconst DataGridSectionContext = React.createContext<DataGridSection>('body');\n/** The header's selection slots (see {@link HeaderSlotRegistry}). */\nconst DataGridHeaderSlotsContext = React.createContext<HeaderSlotRegistry | null>(null);\n/**\n * Whether the header row below is the header's first row, as far as the header can tell from its\n * children. Only the initial (and server) render uses it; the slots then follow the DOM order.\n */\nconst DataGridHeaderRowHintContext = React.createContext(true);\n\nconst INERT_STORE = createSelectionStore([]);\nconst INERT_CONTEXT: DataGridContextValue = {\n selectionMode: 'none',\n store: INERT_STORE,\n toggleRow: () => {},\n toggleAll: () => {},\n radioName: '',\n selectAllLabel: DEFAULT_SELECT_ALL_LABEL,\n selectionHeaderLabel: DEFAULT_SELECTION_HEADER_LABEL,\n};\nconst INERT_SORT_CONTEXT: DataGridSortContextValue = { sort: null, requestSort: () => {} };\n\nfunction useDataGridContext(component: string): DataGridContextValue {\n const ctx = React.useContext(DataGridContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid');\n return INERT_CONTEXT;\n}\n\nfunction useDataGridSortContext(component: string): DataGridSortContextValue {\n const ctx = React.useContext(DataGridSortContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid');\n return INERT_SORT_CONTEXT;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst EMPTY_ITEMS: readonly string[] = [];\n\nfunction toItems(\n keys: ReadonlySet<string> | readonly string[] | undefined,\n): readonly string[] | undefined {\n return keys === undefined ? undefined : Array.from(keys);\n}\n\nfunction sameItems(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((item, index) => item === b[index]);\n}\n\n/** A child of {@link flattenChildren} under its flattened key (unique across the flattened list). */\nfunction renderFlatChild({ key, node }: { key: string; node: React.ReactNode }): React.ReactNode {\n return <React.Fragment key={key}>{node}</React.Fragment>;\n}\n\nfunction warnDuplicateRowId(rowId: string): void {\n warnOnce(\n `DataGrid:duplicate-rowId:${rowId}`,\n `DataGrid: several rows share the rowId \"${rowId}\". Row ids must be unique within a ` +\n 'DataGrid; rows with the same rowId are selected and deselected together.',\n );\n}\n\nconst cellBase = 'px-4 py-3 border-b border-border';\nconst selectionCell = 'w-10 px-3 py-3 border-b border-border';\nconst nativeControl = 'accent-primary cursor-pointer';\n\n// ---------------------------------------------------------------------------\n// DataGrid\n// ---------------------------------------------------------------------------\n\n// The component-level JSDoc sits on the exported `DataGrid` below.\nconst DataGridRoot = (props: DataGridProps) => {\n const {\n sort: sortProp,\n defaultSort,\n sortColumn: sortColumnProp,\n defaultSortColumn,\n sortDirection: sortDirectionProp,\n defaultSortDirection,\n onSortChange,\n selectionMode = 'none',\n selectedItems: selectedItemsProp,\n defaultSelectedItems,\n onSelectedItemsChange,\n selectedKeys,\n defaultSelectedKeys,\n onSelectionChange,\n labels,\n columns,\n containerProps,\n children,\n className,\n onKeyDown,\n onFocus,\n onBlur,\n ref,\n ...rest\n } = props;\n\n // --- sort -----------------------------------------------------------------\n /** 0.5 API: `onSortChange(sort)`. Sticky once `sort`/`defaultSort` was given. */\n const usesSortApi = sortProp !== undefined || defaultSort !== undefined;\n const [sortApiMode, setSortApiMode] = React.useState(usesSortApi);\n if (usesSortApi && !sortApiMode) setSortApiMode(true);\n const objectCallbacks = sortApiMode || usesSortApi;\n\n const legacySortControlled = sortColumnProp !== undefined || sortDirectionProp !== undefined;\n if (sortColumnProp !== undefined) warnDeprecated('DataGrid', 'sortColumn', 'sort');\n if (sortDirectionProp !== undefined) warnDeprecated('DataGrid', 'sortDirection', 'sort');\n if (defaultSortColumn !== undefined) {\n warnDeprecated('DataGrid', 'defaultSortColumn', 'defaultSort');\n }\n if (defaultSortDirection !== undefined) {\n warnDeprecated('DataGrid', 'defaultSortDirection', 'defaultSort');\n }\n const mixedSortApi =\n usesSortApi &&\n (legacySortControlled || defaultSortColumn !== undefined || defaultSortDirection !== undefined);\n\n React.useEffect(() => {\n if (mixedSortApi) {\n warnOnce(\n 'DataGrid:mixed-sort',\n 'DataGrid: do not mix `sort`/`defaultSort` with the deprecated `sortColumn`/`sortDirection`/' +\n '`defaultSortColumn`/`defaultSortDirection`. `sort`/`defaultSort` win.',\n );\n }\n }, [mixedSortApi]);\n // 0.4 mixed control: `sortColumn` and `sortDirection` are controlled independently. The half the\n // parent does not control is kept here (seeded from its default) and follows every sort request,\n // as 0.4 did, so repeated clicks still alternate and aria-sort shows what was reported.\n React.useEffect(() => {\n if (usesSortApi) return;\n if (sortColumnProp !== undefined && sortDirectionProp === undefined) {\n warnOnce(\n 'DataGrid:sortColumn-without-sortDirection',\n 'DataGrid: `sortColumn` is controlled but `sortDirection` is not (mixed control). The ' +\n 'direction is kept internally and toggles on repeated clicks, as in 0.4. Pass `sort` ' +\n '(`{ columnId, direction }`) to control both.',\n );\n } else if (sortDirectionProp !== undefined && sortColumnProp === undefined) {\n warnOnce(\n 'DataGrid:sortDirection-without-sortColumn',\n 'DataGrid: `sortDirection` is controlled but `sortColumn` is not (mixed control). The ' +\n 'column is kept internally and follows the clicked header, as in 0.4. Pass `sort` ' +\n '(`{ columnId, direction }`) to control both.',\n );\n }\n }, [usesSortApi, sortColumnProp, sortDirectionProp]);\n\n /** The uncontrolled halves of the 0.4 sort props (used while the other half is controlled). */\n const [legacyHalves, setLegacyHalves] = React.useState<{\n column: string;\n direction: SortDirection;\n }>(() => ({\n column: defaultSortColumn ?? '',\n direction: defaultSortDirection ?? 'ascending',\n }));\n\n const legacyControlledSort = React.useMemo<DataGridSort | null | undefined>(() => {\n if (sortColumnProp === undefined && sortDirectionProp === undefined) return undefined;\n const column = sortColumnProp ?? legacyHalves.column;\n return column === ''\n ? null\n : { columnId: column, direction: sortDirectionProp ?? legacyHalves.direction };\n }, [sortColumnProp, sortDirectionProp, legacyHalves]);\n\n const legacyDefaultSort = React.useMemo<DataGridSort | null>(\n () =>\n defaultSortColumn\n ? { columnId: defaultSortColumn, direction: defaultSortDirection ?? 'ascending' }\n : null,\n [defaultSortColumn, defaultSortDirection],\n );\n\n const controlledSort = usesSortApi ? sortProp : legacyControlledSort;\n const initialSort = defaultSort !== undefined ? defaultSort : legacyDefaultSort;\n\n const emitSortChange = (next: DataGridSort | null) => {\n if (!next) return;\n if (!usesSortApi) {\n setLegacyHalves((previous) =>\n previous.column === next.columnId && previous.direction === next.direction\n ? previous\n : { column: next.columnId, direction: next.direction },\n );\n }\n if (!onSortChange) return;\n if (objectCallbacks) {\n (onSortChange as (sort: DataGridSort) => void)(next);\n } else {\n const legacy = onSortChange as (columnId: string, direction: SortDirection) => void;\n legacy(next.columnId, next.direction);\n }\n };\n\n const [sort, setSort] = useControllable<DataGridSort | null>(\n controlledSort,\n initialSort,\n emitSortChange,\n );\n\n const requestSort = React.useCallback(\n (columnId: string) => {\n setSort((previous) => ({\n columnId,\n direction:\n previous?.columnId === columnId && previous.direction === 'ascending'\n ? 'descending'\n : 'ascending',\n }));\n },\n [setSort],\n );\n\n const sortContext = React.useMemo<DataGridSortContextValue>(\n () => ({ sort, requestSort }),\n [sort, requestSort],\n );\n\n // --- selection ------------------------------------------------------------\n if (onSelectionChange !== undefined) {\n warnDeprecated('DataGrid', 'onSelectionChange', 'onSelectedItemsChange');\n }\n const legacySelected = React.useMemo(() => toItems(selectedKeys), [selectedKeys]);\n const legacyDefaultSelected = React.useMemo(\n () => toItems(defaultSelectedKeys),\n [defaultSelectedKeys],\n );\n const controlledSelected = resolveDeprecatedProp(\n 'DataGrid',\n selectedItemsProp,\n legacySelected,\n 'selectedKeys',\n 'selectedItems',\n );\n const defaultSelected =\n resolveDeprecatedProp(\n 'DataGrid',\n defaultSelectedItems,\n legacyDefaultSelected,\n 'defaultSelectedKeys',\n 'defaultSelectedItems',\n ) ?? EMPTY_ITEMS;\n\n const emitSelectionChange = (next: readonly string[]) => {\n onSelectedItemsChange?.([...next]);\n onSelectionChange?.(new Set(next));\n };\n\n const [selected, setSelected] = useControllable<readonly string[]>(\n controlledSelected,\n defaultSelected,\n emitSelectionChange,\n );\n\n const single = selectionMode === 'single';\n const [store] = React.useState(() => createSelectionStore(selected, single));\n React.useLayoutEffect(() => {\n store.setSelected(selected);\n }, [store, selected]);\n React.useLayoutEffect(() => {\n store.setSingleMode(single);\n }, [store, single]);\n\n const toggleRow = React.useCallback(\n (rowId: string) => {\n setSelected((previous) => {\n const effective = store.prune(previous);\n let next: string[];\n if (single) {\n // Single mode shows the first selected row that is rendered (see the store).\n next = effective[0] === rowId ? [] : [rowId];\n } else {\n next = effective.includes(rowId)\n ? effective.filter((item) => item !== rowId)\n : [...effective, rowId];\n }\n return sameItems(next, previous) ? previous : next;\n });\n },\n [single, setSelected, store],\n );\n\n const selectedCount = selected.length;\n React.useEffect(() => {\n if (single && selectedCount > 1) {\n warnOnce(\n 'DataGrid:single-several-selected',\n `DataGrid: a single-selection grid (selectionMode \"single\") has ${selectedCount} selected row ids; only the first one that is rendered is selected. Pass at most one id in \\`selectedItems\\`/\\`defaultSelectedItems\\`, or use selectionMode=\"multiple\".`,\n );\n }\n }, [single, selectedCount]);\n\n const toggleAll = React.useCallback(() => {\n setSelected((previous) => {\n const effective = store.prune(previous);\n const all = store.getRegistered();\n const allSelected = all.length > 0 && all.every((rowId) => effective.includes(rowId));\n const next = allSelected ? [] : all;\n return sameItems(next, previous) ? previous : next;\n });\n }, [setSelected, store]);\n\n const radioName = useId('wave-datagrid-selection');\n const selectAllLabel = labels?.selectAll ?? DEFAULT_SELECT_ALL_LABEL;\n const selectionHeaderLabel = labels?.selectionHeader ?? DEFAULT_SELECTION_HEADER_LABEL;\n\n const context = React.useMemo<DataGridContextValue>(\n () => ({\n selectionMode,\n store,\n toggleRow,\n toggleAll,\n radioName,\n selectAllLabel,\n selectionHeaderLabel,\n }),\n [selectionMode, store, toggleRow, toggleAll, radioName, selectAllLabel, selectionHeaderLabel],\n );\n\n // --- keyboard -------------------------------------------------------------\n const { gridRef, gridProps } = useGridNavigation();\n const mergedRef = useMergedRefs<HTMLTableElement>(ref, gridRef);\n\n // --- header from columns ----------------------------------------------------\n let content: React.ReactNode = children;\n const flatChildren = columns ? flattenChildren(children) : [];\n if (columns && !flatChildren.some(({ node }) => isElementOfType(node, DataGridHeader))) {\n // A `<caption>` stays the table's first child, before the generated header.\n const isCaption = ({ node }: { node: React.ReactNode }) => isElementOfType(node, 'caption');\n content = (\n <>\n {flatChildren.filter(isCaption).map(renderFlatChild)}\n <DataGridHeader>\n <tr>\n {columns.map((column) => (\n <DataGridHeaderCell key={column.id} columnId={column.id} sortable={column.sortable}>\n {column.label}\n </DataGridHeaderCell>\n ))}\n </tr>\n </DataGridHeader>\n {flatChildren.filter((child) => !isCaption(child)).map(renderFlatChild)}\n </>\n );\n }\n\n const {\n className: containerClassName,\n 'aria-label': containerLabel,\n 'aria-labelledby': containerLabelledBy,\n ...containerRest\n } = containerProps ?? {};\n // The wrapper has no role of its own, and a name is prohibited on a role-less `<div>`: the\n // consumer's name is kept only together with a role.\n const containerHasRole = containerRest.role !== undefined;\n const droppedContainerName =\n !containerHasRole && (containerLabel !== undefined || containerLabelledBy !== undefined);\n\n React.useEffect(() => {\n if (droppedContainerName) {\n warnOnce(\n 'DataGrid:container-name-without-role',\n 'DataGrid: `containerProps[\"aria-label\"]`/`[\"aria-labelledby\"]` is ignored because the ' +\n 'wrapper has no role. Name the grid itself (`aria-label` on DataGrid), or pass a ' +\n '`role` (e.g. \"region\") in `containerProps` too.',\n );\n }\n }, [droppedContainerName]);\n\n return (\n <DataGridContext.Provider value={context}>\n <DataGridSortContext.Provider value={sortContext}>\n <div\n {...containerRest}\n aria-label={containerHasRole ? containerLabel : undefined}\n aria-labelledby={containerHasRole ? containerLabelledBy : undefined}\n className={cn('overflow-x-auto rounded-md border border-border', containerClassName)}\n >\n <table\n ref={mergedRef}\n role=\"grid\"\n aria-multiselectable={selectionMode === 'multiple' || undefined}\n className={cn('w-full border-separate border-spacing-0', className)}\n {...rest}\n onKeyDown={composeEventHandlers(onKeyDown, gridProps.onKeyDown)}\n onFocus={composeEventHandlers(onFocus, gridProps.onFocus, {\n checkDefaultPrevented: false,\n })}\n onBlur={composeEventHandlers(onBlur, gridProps.onBlur, {\n checkDefaultPrevented: false,\n })}\n >\n {content}\n </table>\n </div>\n </DataGridSortContext.Provider>\n </DataGridContext.Provider>\n );\n};\nDataGridRoot.displayName = 'DataGrid';\n\n// ---------------------------------------------------------------------------\n// Selection header cell (internal)\n// ---------------------------------------------------------------------------\n\nfunction DataGridSelectionHeaderCell({\n selectionMode,\n ref,\n}: {\n selectionMode: SelectionMode;\n ref?: React.Ref<HTMLTableCellElement>;\n}) {\n const { store, toggleAll, selectAllLabel, selectionHeaderLabel } =\n useDataGridContext('DataGrid.Header');\n const state = React.useSyncExternalStore(\n store.subscribeSelectAll,\n store.getSelectAllState,\n store.getSelectAllState,\n );\n const inputRef = React.useRef<HTMLInputElement>(null);\n // A click clears the checkbox's `indeterminate` flag (checkbox activation does) and React restores\n // only `checked`, so the flag is re-applied after every click, also when the select-all state\n // stays the same (a controlled parent that keeps the selection partial, or ignores the change).\n const [clicks, setClicks] = React.useState(0);\n\n React.useLayoutEffect(() => {\n if (inputRef.current) inputRef.current.indeterminate = state === 'some';\n }, [state, clicks]);\n\n return (\n <th\n ref={ref}\n scope=\"col\"\n data-selection-cell=\"\"\n className={cn(selectionCell, 'text-start', focusRingInset)}\n >\n {selectionMode === 'multiple' ? (\n <input\n ref={inputRef}\n type=\"checkbox\"\n aria-label={selectAllLabel}\n checked={state === 'all'}\n onChange={() => {\n setClicks((count) => count + 1);\n toggleAll();\n }}\n className={cn(nativeControl, focusRingInset)}\n />\n ) : (\n <span className=\"sr-only\">{selectionHeaderLabel}</span>\n )}\n </th>\n );\n}\n\nconst INERT_HEADER_SLOTS: HeaderSlotRegistry = {\n subscribe: () => () => {},\n register: () => () => {},\n getFirst: () => null,\n refresh: () => {},\n};\n\n/**\n * The selection column's cell of one header row: the select-all header cell in the header's first\n * row (document order), an empty cell in every later row. `initialFirst` is the header's guess from\n * its children, used until the slots are registered (the initial and the server render).\n */\nfunction DataGridSelectionHeaderSlot({\n selectionMode,\n initialFirst,\n}: {\n selectionMode: SelectionMode;\n initialFirst: boolean;\n}) {\n const slots = React.useContext(DataGridHeaderSlotsContext) ?? INERT_HEADER_SLOTS;\n const [slot] = React.useState(() => ({}));\n const cellRef = React.useRef<HTMLTableCellElement | null>(null);\n\n const getIsFirst = React.useCallback(() => {\n const first = slots.getFirst();\n return first === null ? initialFirst : first === slot;\n }, [slots, slot, initialFirst]);\n const getServerIsFirst = React.useCallback(() => initialFirst, [initialFirst]);\n const isFirst = React.useSyncExternalStore(slots.subscribe, getIsFirst, getServerIsFirst);\n\n React.useLayoutEffect(() => slots.register(slot, () => cellRef.current), [slots, slot]);\n\n return isFirst ? (\n <DataGridSelectionHeaderCell ref={cellRef} selectionMode={selectionMode} />\n ) : (\n <td ref={cellRef} data-selection-cell=\"\" className={cn(selectionCell, focusRingInset)} />\n );\n}\n\n// ---------------------------------------------------------------------------\n// Sub-components\n// ---------------------------------------------------------------------------\n\n/**\n * Prepends the selection column's header slot (or `null`) to every `<tr>` in `children`, looking\n * inside Fragments, and tells every other element child (a `DataGrid.Row`, or a component that\n * renders one) whether it is the header's first row. Every row gets the same child shape in every\n * selection mode, so switching `selectionMode` does not remount the header cells.\n */\nfunction withSelectionHeaderSlots(\n children: React.ReactNode,\n selectionMode: 'none' | SelectionMode,\n): React.ReactNode {\n let first = true;\n const visit = (nodes: React.ReactNode): React.ReactNode =>\n React.Children.map(nodes, (child) => {\n if (isElementOfType<{ children?: React.ReactNode }>(child, React.Fragment)) {\n return React.cloneElement(child, undefined, visit(child.props.children));\n }\n if (!React.isValidElement(child)) return child;\n const isFirst = first;\n first = false;\n if (isElementOfType<{ children?: React.ReactNode }>(child, 'tr')) {\n const slot =\n selectionMode === 'none' ? null : (\n <DataGridSelectionHeaderSlot selectionMode={selectionMode} initialFirst={isFirst} />\n );\n return React.cloneElement(child, undefined, slot, child.props.children);\n }\n return (\n <DataGridHeaderRowHintContext.Provider value={isFirst}>\n {child}\n </DataGridHeaderRowHintContext.Provider>\n );\n });\n return visit(children);\n}\n\n/**\n * The grid's `<thead>`. When the grid is selectable, it prepends the selection column's header\n * cell to each `<tr>` child, also inside a Fragment: the first header row gets the \"Select all\n * rows\" checkbox (multiple mode) or the \"Selection\" header (single mode; DataGrid's `labels`\n * localizes both), later rows of a grouped header an empty cell. A header row rendered by another\n * component cannot get it (a development warning says so): use `DataGrid.Row` for such a row,\n * which adds the cell itself.\n */\nconst DataGridHeader = ({ children, className, ref, ...rest }: DataGridHeaderProps) => {\n const { selectionMode } = useDataGridContext('DataGrid.Header');\n const [thead, setThead] = React.useState<HTMLTableSectionElement | null>(null);\n const mergedRef = useMergedRefs<HTMLTableSectionElement>(ref, setThead);\n const [slots] = React.useState(createHeaderSlotRegistry);\n const content = withSelectionHeaderSlots(children, selectionMode);\n\n // Every commit, after the rows' slots registered: header rows can move without a slot mounting.\n React.useLayoutEffect(() => {\n slots.refresh();\n });\n\n // Every commit: header rows can come from components the header cannot see into.\n React.useEffect(() => {\n if (!isDev || !thead || selectionMode === 'none') return;\n const missing = Array.from(thead.rows).some(\n (row) => row.cells.length > 0 && !row.cells[0].hasAttribute('data-selection-cell'),\n );\n if (missing) {\n warnOnce(\n 'DataGrid.Header:missing-selection-cell',\n 'DataGrid.Header: a header row has no selection column header cell, so the header has one ' +\n 'column fewer than the selectable rows. Render header rows as `<tr>` children of ' +\n 'DataGrid.Header (a Fragment is fine), or use `DataGrid.Row` for a header row that ' +\n 'another component renders.',\n );\n }\n });\n\n return (\n <DataGridSectionContext.Provider value=\"header\">\n <DataGridHeaderSlotsContext.Provider value={slots}>\n <thead ref={mergedRef} className={cn('bg-card', className)} {...rest}>\n {content}\n </thead>\n </DataGridHeaderSlotsContext.Provider>\n </DataGridSectionContext.Provider>\n );\n};\nDataGridHeader.displayName = 'DataGridHeader';\n\nconst sortIcon = (direction: SortDirection) => (\n <svg\n className=\"h-3 w-3 shrink-0\"\n viewBox=\"0 0 12 12\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n {direction === 'ascending' ? <path d=\"M6 2L10 8H2L6 2Z\" /> : <path d=\"M6 10L2 4H10L6 10Z\" />}\n </svg>\n);\n\n/**\n * A column header cell. A `sortable` header (with a `columnId`) renders its content inside a\n * `<button type=\"button\">` that toggles the sort; the `<th>` carries `aria-sort`. A consumer\n * `onClick` (on the `<th>`) runs before the sort, and calling `preventDefault()` in it cancels the\n * sort (also for Enter/Space on the button, which click it).\n */\nconst DataGridHeaderCell = ({\n columnId,\n sortable = false,\n children,\n className,\n onClick,\n ref,\n ...rest\n}: DataGridHeaderCellProps) => {\n const { sort, requestSort } = useDataGridSortContext('DataGrid.HeaderCell');\n /** The column this header sorts, or `undefined` when it is not sortable. */\n const sortColumnId = sortable && columnId ? columnId : undefined;\n const sortedDirection =\n sortColumnId !== undefined && sort?.columnId === sortColumnId ? sort.direction : null;\n\n // The sort runs from the `<th>` once the button's click bubbled up to it, composed after the\n // consumer's `onClick` (C-COMPOSE): the consumer runs first and can cancel with preventDefault().\n // The sort button is the `<th>`'s only child; clicks elsewhere in the cell do not sort.\n const sortOnButtonClick = (event: React.MouseEvent<HTMLTableCellElement>) => {\n const button = event.currentTarget.firstElementChild;\n if (\n sortColumnId !== undefined &&\n button?.localName === 'button' &&\n button.contains(event.target as Node)\n ) {\n requestSort(sortColumnId);\n }\n };\n\n React.useEffect(() => {\n if (sortable && !columnId) {\n warnOnce(\n 'DataGrid.HeaderCell:sortable-without-columnId',\n 'DataGrid.HeaderCell: `sortable` needs a `columnId`; the header is rendered as not sortable.',\n );\n }\n }, [sortable, columnId]);\n\n return (\n <th\n ref={ref}\n scope=\"col\"\n aria-sort={sortColumnId !== undefined ? (sortedDirection ?? 'none') : undefined}\n className={cn(\n cellBase,\n 'text-start align-middle font-semibold text-caption-1 uppercase tracking-wider',\n focusRingInset,\n sortColumnId !== undefined && 'p-0 hover:bg-subtle-hover',\n className,\n )}\n {...rest}\n onClick={\n sortColumnId !== undefined ? composeEventHandlers(onClick, sortOnButtonClick) : onClick\n }\n >\n {sortColumnId !== undefined ? (\n <button\n type=\"button\"\n className={cn(\n 'inline-flex w-full cursor-pointer select-none items-center gap-1 border-0 bg-transparent px-4 py-3 text-start text-inherit [font:inherit] uppercase tracking-wider',\n focusRingInset,\n )}\n >\n {children}\n {sortedDirection && sortIcon(sortedDirection)}\n </button>\n ) : (\n <span className=\"inline-flex items-center gap-1\">{children}</span>\n )}\n </th>\n );\n};\nDataGridHeaderCell.displayName = 'DataGridHeaderCell';\n\n/** The grid's `<tbody>`. */\nconst DataGridBody = ({ children, className, ref, ...rest }: DataGridBodyProps) => (\n <DataGridSectionContext.Provider value=\"body\">\n <tbody ref={ref} className={className} {...rest}>\n {children}\n </tbody>\n </DataGridSectionContext.Provider>\n);\nDataGridBody.displayName = 'DataGridBody';\n\n/**\n * A grid row. In a selectable grid it starts with a selection cell (checkbox or radio) named\n * after the row's first cell (or `selectionLabel`); Space on one of its cells toggles the row.\n */\nconst DataGridRow = ({\n rowId,\n selectionLabel,\n children,\n className,\n onKeyDown,\n ref,\n ...rest\n}: DataGridRowProps) => {\n const { selectionMode, store, toggleRow, radioName } = useDataGridContext('DataGrid.Row');\n const section = React.useContext(DataGridSectionContext);\n const firstHeaderRowHint = React.useContext(DataGridHeaderRowHintContext);\n const inHeader = section === 'header';\n const selectable = selectionMode !== 'none' && !inHeader;\n const labelId = useId('wave-datagrid-row-label');\n\n const single = selectionMode === 'single';\n const getSelected = React.useCallback(\n () => rowId !== undefined && store.isSelected(rowId, single),\n [rowId, store, single],\n );\n // Notified only when the selection changes (in multiple mode, rows registering notify no row).\n const isSelected = React.useSyncExternalStore(store.subscribe, getSelected, getSelected);\n\n React.useLayoutEffect(() => {\n if (rowId === undefined || inHeader) return;\n const unregister = store.register(rowId);\n if (isDev && store.countRegistrations(rowId) > 1) warnDuplicateRowId(rowId);\n return unregister;\n }, [store, rowId, inHeader]);\n\n React.useEffect(() => {\n if (selectable && rowId === undefined) {\n warnOnce(\n 'DataGrid.Row:missing-rowId',\n 'DataGrid.Row: a selectable grid needs a `rowId` on every row; this row has no selection control.',\n );\n }\n }, [selectable, rowId]);\n\n const unlabelled = selectable && rowId !== undefined && selectionLabel === undefined;\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTableRowElement>) => {\n if (!selectable || rowId === undefined || event.key !== ' ') return;\n const target = event.target as Element;\n // Only keys pressed on the row itself or on one of its own cells, never on a nested widget.\n if (target !== event.currentTarget && target.parentElement !== event.currentTarget) return;\n event.preventDefault();\n toggleRow(rowId);\n };\n\n // Name the selection control after the first cell (its own id, or a generated one). The children\n // are always flattened (Fragments too) and rendered under their flattened keys, whatever the\n // mode, so the keys stay the same when `selectionMode`, `selectionLabel` or `rowId` change and\n // the cells are not remounted.\n const flatChildren = flattenChildren(children);\n let labelledBy: string | undefined;\n let idCellIndex = -1;\n if (unlabelled) {\n const firstCellIndex = flatChildren.findIndex(({ node }) =>\n isElementOfType(node, DataGridCell, 'td', 'th'),\n );\n if (firstCellIndex >= 0) {\n const firstCell = flatChildren[firstCellIndex].node as React.ReactElement<{ id?: string }>;\n labelledBy = firstCell.props.id ?? labelId;\n if (firstCell.props.id === undefined) idCellIndex = firstCellIndex;\n }\n }\n const content = flatChildren.map(({ key, node }, index) =>\n renderFlatChild({\n key,\n node:\n index === idCellIndex\n ? React.cloneElement(node as React.ReactElement<{ id?: string }>, { id: labelId })\n : node,\n }),\n );\n\n const needsLabel = unlabelled && labelledBy === undefined;\n React.useEffect(() => {\n if (needsLabel) {\n warnOnce(\n 'DataGrid.Row:selection-label',\n 'DataGrid.Row: no child is a `DataGrid.Cell`, `<td>` or `<th>` element, so the row selection control is named \"Select row\". Pass `selectionLabel` (a cell rendered by another component is not seen).',\n );\n }\n }, [needsLabel]);\n\n let selectionCellElement: React.ReactNode = null;\n if (inHeader && selectionMode !== 'none') {\n selectionCellElement = (\n <DataGridSelectionHeaderSlot\n selectionMode={selectionMode}\n initialFirst={firstHeaderRowHint}\n />\n );\n } else if (selectable) {\n selectionCellElement = (\n <td role=\"gridcell\" data-selection-cell=\"\" className={cn(selectionCell, focusRingInset)}>\n {rowId !== undefined && (\n <input\n type={selectionMode === 'multiple' ? 'checkbox' : 'radio'}\n name={selectionMode === 'single' ? radioName : undefined}\n // The shared name groups the radios. `form=\"\"` matches no form, so they have no form\n // owner (still one group: same name, both ownerless) and never add a generated field\n // to an enclosing form's submission.\n form={selectionMode === 'single' ? '' : undefined}\n checked={isSelected}\n onChange={() => toggleRow(rowId)}\n aria-label={selectionLabel ?? (labelledBy ? undefined : 'Select row')}\n aria-labelledby={selectionLabel === undefined ? labelledBy : undefined}\n className={cn(nativeControl, focusRingInset)}\n />\n )}\n </td>\n );\n }\n\n return (\n <tr\n ref={ref}\n className={cn(\n !inHeader &&\n 'hover:bg-subtle-hover data-[selected]:bg-selected transition-colors motion-reduce:transition-none',\n selectable && isSelected && forcedColors.selectedContainer,\n className,\n )}\n aria-selected={selectable ? isSelected : undefined}\n data-selected={selectable && isSelected ? '' : undefined}\n {...rest}\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n >\n {selectionCellElement}\n {content}\n </tr>\n );\n};\nDataGridRow.displayName = 'DataGridRow';\n\n/** A grid cell (`<td>`), focusable through the grid's keyboard navigation. */\nconst DataGridCell = ({ children, className, ref, ...rest }: DataGridCellProps) => (\n <td\n ref={ref}\n role=\"gridcell\"\n className={cn(cellBase, 'text-body-1', focusRingInset, className)}\n {...rest}\n >\n {children}\n </td>\n);\nDataGridCell.displayName = 'DataGridCell';\n\nexport { DataGridHeader, DataGridHeaderCell, DataGridBody, DataGridRow, DataGridCell };\n\n/**\n * An interactive data table (`role=\"grid\"`) following the APG Grid pattern: one tab stop,\n * arrow-key navigation between cells (Home/End, Ctrl+Home/Ctrl+End, PageUp/PageDown; Up/Down keep\n * the visual column, so a grouped header with spanning cells works), Enter/F2 to interact with a\n * cell's widgets and Escape to return to the cell. A composite widget in a cell (a Toolbar,\n * RadioGroup, TabList, …) is entered with Enter/F2 like a text field; it manages its own tab\n * indexes, so it keeps its own Tab stop. Supports sortable columns (controlled sorting:\n * `onSortChange` reports the new sort and the consumer reorders the rows) and single or multiple\n * row selection with a select-all header checkbox.\n *\n * Sub-components are available as `DataGrid.Header`, `DataGrid.HeaderCell`, `DataGrid.Body`,\n * `DataGrid.Row` and `DataGrid.Cell` in client components, and as the flat exports\n * `DataGridHeader`, `DataGridHeaderCell`, `DataGridBody`, `DataGridRow` and `DataGridCell` (the\n * form React Server Components can import).\n */\nexport const DataGrid = /* @__PURE__ */ Object.assign(DataGridRoot, {\n Header: DataGridHeader,\n HeaderCell: DataGridHeaderCell,\n Body: DataGridBody,\n Row: DataGridRow,\n Cell: DataGridCell,\n});\n"],"mappings":";;;;;;;;;;;;;AAoDA,IAAMI,IAA2B,mBAC3BC,IAAiC;AA+PvC,SAAgBC,EACd,GACA,IAAoB,IACJ;CAChB,IAAIC,IAAgC,IAAI,IAAIC,CAAO,GAE7CC,oBAAa,IAAI,IAAoB,GAEvCC,IAAqB,GACrBC,IAA4B,QAC5BC,IAAaC,GAEbC,GACEC,oBAAe,IAAI,IAAgB,GACnCC,oBAAqB,IAAI,IAAgB,GAEzCC,KAAU,MAA+B;EAC7C,KAAK,IAAMC,KAAY,MAAM,KAAKC,CAAS,GAAG,EAAS;CACzD,GAGMC,UAAmC;EACvC,IAAIN,MAAa,KAAA,GAAW,OAAOA;EACnC,IAAIO,IAAuB;EAC3B,KAAK,IAAMC,KAASf,GAAU;GAC5B,IAAIE,EAAW,IAAIa,CAAK,GAAG;IACzB,IAAQA;IACR;GACF;GACA,MAAUA;EACZ;EAEA,OADA,IAAWD,GACJA;CACT,GAMME,KAAwB,MAAkB;EAC9C,IAAIhB,EAAS,OAAO,KAAK,CAACA,EAAS,IAAIe,CAAK,GAAG;EAC/C,IAAME,IAAWV;EAEjB,AADA,IAAW,KAAA,GACPF,KAAcQ,EAAY,MAAMI,KAAUP,EAAOF,CAAY;CACnE,GAEMU,UAAwB;EAC5B,IAAMC,IACJhB,MAAuB,IAAI,SAASA,MAAuBD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,WAAWyE,EAAqBC,GAAW6C,CAAa;EAX1D,UAAA,CAaGQ,GACA1E,CACC;;AAER;AACA,EAAY,cAAc;AAG1B,IAAMuE,KAAgB,EAAE,aAAU,cAAW,QAAK,GAAG5H,QACnD,kBAAC,MAAD;CACO;CACL,MAAK;CACL,WAAWuE,EAAG/E,GAAU,eAAe2F,GAAgBX,CAAS;CAChE,GAAIxE;CAEH;AACC,CAAA;AAEN,EAAa,cAAc;AAmB3B,IAAaiI,IAA2B,uBAAO,OAAOtI,GAAc;CAClE,QAAQgE;CACR,YAAYG;CACZ,MAAM6C;CACN,KAAKC;CACL,MAAMgB;AACR,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../hooks/useId.cjs"),a=require("../../hooks/useMergedRefs.cjs");require("../../lib/styles.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=()=>()=>{};function l(e){let t=o.useCallback(t=>{if(!e||typeof ResizeObserver>`u`)return()=>{};let n=new ResizeObserver(t);n.observe(e);for(let t of Array.from(e.children))n.observe(t);return()=>n.disconnect()},[e]),n=o.useCallback(()=>e?e.scrollWidth>e.clientWidth:!1,[e]);return o.useSyncExternalStore(e?t:c,n,()=>!1)}function u(e){return n.isElementOfType(e,`caption`)}var d=({striped:e=!1,containerProps:c,children:d,className:f,ref:p,...m})=>{let{className:h,ref:g,"aria-label":_,"aria-labelledby":v,...y}=c??{},[b,x]=o.useState(null),S=a.useMergedRefs(g,x),C=l(b),w=i.useId(`wave-table-caption`),T=n.flattenChildren(d),E=T.findIndex(({node:e})=>u(e)),D=E>=0?T[E].node:null,O=D?D.props.id??w:void 0,k=D&&D.props.id===void 0?T.map(({key:e,node:t},n)=>(0,s.jsx)(o.Fragment,{children:n===E?o.cloneElement(D,{id:w}):t},e)):d,A=_?void 0:v??O,j=!!(_||A),M=C&&j,N=y.role;return o.useEffect(()=>{C&&!j&&r.warnOnce(`Table:unnamed-scroll-region`,`Table: the table scrolls horizontally but its scroll region has no name. Add a <caption> or containerProps["aria-label"].`)},[C,j]),(0,s.jsx)(`div`,{...y,ref:S,role:M?`region`:N,tabIndex:C?0:y.tabIndex,"aria-label":C||N!==void 0?_:void 0,"aria-labelledby":M?A:N===void 0?void 0:v,className:t.cn(`overflow-x-auto rounded-md border border-border`,C&&`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,h),children:(0,s.jsx)(`table`,{ref:p,"data-striped":e?``:void 0,className:t.cn(`w-full border-separate border-spacing-0`,e&&`[:where(&>tbody>tr:nth-child(odd))]:bg-card`,f),...m,children:k})})};d.displayName=`Table`;var f=({children:e,className:n,ref:r,...i})=>(0,s.jsx)(`thead`,{ref:r,...i,className:t.cn(`bg-card`,n),children:e});f.displayName=`TableHeader`;var p=({children:e,className:n,ref:r,...i})=>(0,s.jsx)(`th`,{ref:r,scope:`col`,className:t.cn(`px-4 py-3 text-start font-semibold text-caption-1 uppercase tracking-wider border-b border-border`,n),...i,children:e});p.displayName=`TableHeaderCell`;var m=e=>(r.warnDeprecated(`Table`,`Table.Head`,`Table.Header`),(0,s.jsx)(f,{...e}));m.displayName=`TableHead`;var h=e=>(r.warnDeprecated(`Table`,`Table.HeadCell`,`Table.HeaderCell`),(0,s.jsx)(p,{...e}));h.displayName=`TableHeadCell`;var g=({children:e,className:t,ref:n,...r})=>(0,s.jsx)(`tbody`,{ref:n,...r,className:t,children:e});g.displayName=`TableBody`;var _=({children:e,className:n,ref:r,...i})=>(0,s.jsx)(`tr`,{ref:r,className:t.cn(`hover:bg-subtle-hover transition-colors motion-reduce:transition-none`,n),...i,children:e});_.displayName=`TableRow`;var v=({children:e,className:n,ref:r,...i})=>(0,s.jsx)(`td`,{ref:r,className:t.cn(`px-4 py-3 text-body-1 border-b border-border`,n),...i,children:e});v.displayName=`TableCell`;var y=Object.assign(d,{Header:f,HeaderCell:p,Head:m,HeadCell:h,Body:g,Row:_,Cell:v});exports.Table=y,exports.TableBody=g,exports.TableCell=v,exports.TableHead=m,exports.TableHeadCell=h,exports.TableHeader=f,exports.TableHeaderCell=p,exports.TableRow=_;
|
|
2
|
+
//# sourceMappingURL=Table.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.cjs","names":["React","isElementOfType","useMergedRefs","useId","flattenChildren","cn","require_runtime","require_cn","require_children","require_dev","require_useId","require_useMergedRefs","react","react_jsx_runtime","noopSubscribe","useHorizontalOverflow","subscribe","wrapper","observer","onChange","child","getSnapshot","isCaption","node","TableRoot","props","containerClassName","containerRef","containerLabel","containerLabelledBy","containerRest","containerProps","setWrapper","wrapperRef","scrollable","generatedCaptionId","flatChildren","children","captionIndex","caption","captionId","content","index","key","regionLabelledBy","named","isRegion","consumerRole","striped","className","TableHeader","rest","TableHeaderCell","TableHead","TableHeadCell","TableBody","TableRow","TableCell","Table"],"sources":["../../../src/components/table/Table.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { focusRing } from '../../lib/styles';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\n\n/** Properties for the Table component. */\nexport interface TableProps extends React.HTMLAttributes<HTMLTableElement> {\n /**\n * Whether to apply alternating row background colors (odd body rows). The stripe has zero\n * specificity, so a row's own background class (`<Table.Row className=\"bg-selected\">`) and its\n * hover color win over it.\n * @default false\n */\n striped?: boolean;\n /**\n * Props for the wrapper `<div>` around the `<table>`: a horizontally scrollable container\n * (`overflow-x-auto`). Use it for its className, style, ref or `aria-label`. While the table\n * scrolls horizontally, the wrapper is a keyboard-focusable `role=\"region\"` named by\n * `containerProps['aria-label']`/`['aria-labelledby']`, else by the table's `<caption>`. While\n * it does not scroll, the wrapper has no role and its `aria-label`/`aria-labelledby` are left\n * off, unless you also pass a `role` in `containerProps` (then they are always applied).\n */\n containerProps?: Omit<React.ComponentPropsWithRef<'div'>, 'children'>;\n /** Table caption, header, body and row elements. */\n children: React.ReactNode;\n /** Ref to the `<table>` element. */\n ref?: React.Ref<HTMLTableElement>;\n}\n\n/** Properties for the TableHeader sub-component. */\nexport interface TableHeaderProps extends React.HTMLAttributes<HTMLTableSectionElement> {\n /** Table header row elements. */\n children: React.ReactNode;\n /** Ref to the `<thead>` element. */\n ref?: React.Ref<HTMLTableSectionElement>;\n}\n\n/** Properties for the TableHeaderCell sub-component. */\nexport interface TableHeaderCellProps extends React.ThHTMLAttributes<HTMLTableCellElement> {\n /** Header cell content. */\n children: React.ReactNode;\n /** Ref to the `<th>` element. */\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\n/** @deprecated Use `TableHeaderProps` (`Table.Header`). */\nexport type TableHeadProps = TableHeaderProps;\n\n/** @deprecated Use `TableHeaderCellProps` (`Table.HeaderCell`). */\nexport type TableHeadCellProps = TableHeaderCellProps;\n\n/** Properties for the TableBody sub-component. */\nexport interface TableBodyProps extends React.HTMLAttributes<HTMLTableSectionElement> {\n /** Table row elements. */\n children: React.ReactNode;\n /** Ref to the `<tbody>` element. */\n ref?: React.Ref<HTMLTableSectionElement>;\n}\n\n/** Properties for the TableRow sub-component. */\nexport interface TableRowProps extends React.HTMLAttributes<HTMLTableRowElement> {\n /** Table cell elements. */\n children: React.ReactNode;\n /** Ref to the `<tr>` element. */\n ref?: React.Ref<HTMLTableRowElement>;\n}\n\n/** Properties for the TableCell sub-component. */\nexport interface TableCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {\n /** Cell content. */\n children: React.ReactNode;\n /** Ref to the `<td>` element. */\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\nconst noopSubscribe = () => () => {};\n\n/**\n * Whether `wrapper` scrolls horizontally, as an external store: a `ResizeObserver` on the wrapper\n * and the table re-checks `scrollWidth > clientWidth`. Without `ResizeObserver` (server, old\n * browsers, jsdom) the value is read on each render.\n */\nfunction useHorizontalOverflow(wrapper: HTMLDivElement | null): boolean {\n const subscribe = React.useCallback(\n (onChange: () => void) => {\n if (!wrapper || typeof ResizeObserver === 'undefined') return () => {};\n const observer = new ResizeObserver(onChange);\n observer.observe(wrapper);\n for (const child of Array.from(wrapper.children)) observer.observe(child);\n return () => observer.disconnect();\n },\n [wrapper],\n );\n const getSnapshot = React.useCallback(\n () => (wrapper ? wrapper.scrollWidth > wrapper.clientWidth : false),\n [wrapper],\n );\n return React.useSyncExternalStore(wrapper ? subscribe : noopSubscribe, getSnapshot, () => false);\n}\n\nfunction isCaption(node: React.ReactNode): node is React.ReactElement<{ id?: string }> {\n return isElementOfType(node, 'caption');\n}\n\n// The component-level JSDoc sits on the exported `Table` below.\nconst TableRoot = ({\n striped = false,\n containerProps,\n children,\n className,\n ref,\n ...props\n}: TableProps) => {\n const {\n className: containerClassName,\n ref: containerRef,\n 'aria-label': containerLabel,\n 'aria-labelledby': containerLabelledBy,\n ...containerRest\n } = containerProps ?? {};\n\n const [wrapper, setWrapper] = React.useState<HTMLDivElement | null>(null);\n const wrapperRef = useMergedRefs<HTMLDivElement>(containerRef, setWrapper);\n const scrollable = useHorizontalOverflow(wrapper);\n\n // Name the scroll region after the caption (also one inside a Fragment): keep its id, or give it\n // one. The flattened children are then rendered under their flattened keys.\n const generatedCaptionId = useId('wave-table-caption');\n const flatChildren = flattenChildren(children);\n const captionIndex = flatChildren.findIndex(({ node }) => isCaption(node));\n const caption =\n captionIndex >= 0\n ? (flatChildren[captionIndex].node as React.ReactElement<{ id?: string }>)\n : null;\n const captionId = caption ? (caption.props.id ?? generatedCaptionId) : undefined;\n const content =\n caption && caption.props.id === undefined\n ? flatChildren.map(({ key, node }, index) => (\n <React.Fragment key={key}>\n {index === captionIndex\n ? React.cloneElement(caption, { id: generatedCaptionId })\n : node}\n </React.Fragment>\n ))\n : children;\n\n const regionLabelledBy = containerLabel ? undefined : (containerLabelledBy ?? captionId);\n const named = Boolean(containerLabel || regionLabelledBy);\n const isRegion = scrollable && named;\n /** A role the consumer gave the wrapper: their name goes with it even while nothing scrolls. */\n const consumerRole = containerRest.role;\n\n React.useEffect(() => {\n if (scrollable && !named) {\n warnOnce(\n 'Table:unnamed-scroll-region',\n 'Table: the table scrolls horizontally but its scroll region has no name. Add a <caption> or containerProps[\"aria-label\"].',\n );\n }\n }, [scrollable, named]);\n\n return (\n <div\n {...containerRest}\n ref={wrapperRef}\n role={isRegion ? 'region' : consumerRole}\n tabIndex={scrollable ? 0 : containerRest.tabIndex}\n aria-label={scrollable || consumerRole !== undefined ? containerLabel : undefined}\n aria-labelledby={\n isRegion ? regionLabelledBy : consumerRole !== undefined ? containerLabelledBy : undefined\n }\n className={cn(\n 'overflow-x-auto rounded-md border border-border',\n scrollable && focusRing,\n containerClassName,\n )}\n >\n <table\n ref={ref}\n data-striped={striped ? '' : undefined}\n className={cn(\n 'w-full border-separate border-spacing-0',\n // `:where()` keeps the stripe at specificity 0, so any row class wins (C-CLASS).\n striped && '[:where(&>tbody>tr:nth-child(odd))]:bg-card',\n className,\n )}\n {...props}\n >\n {content}\n </table>\n </div>\n );\n};\nTableRoot.displayName = 'Table';\n\n/** The table's `<thead>`. */\nconst TableHeader = ({ children, className, ref, ...rest }: TableHeaderProps) => (\n <thead ref={ref} {...rest} className={cn('bg-card', className)}>\n {children}\n </thead>\n);\nTableHeader.displayName = 'TableHeader';\n\n/** A column header cell (`<th scope=\"col\">`). */\nconst TableHeaderCell = ({ children, className, ref, ...props }: TableHeaderCellProps) => (\n <th\n ref={ref}\n scope=\"col\"\n className={cn(\n 'px-4 py-3 text-start font-semibold text-caption-1 uppercase tracking-wider border-b border-border',\n className,\n )}\n {...props}\n >\n {children}\n </th>\n);\nTableHeaderCell.displayName = 'TableHeaderCell';\n\n/** @deprecated Use `Table.Header` (`TableHeader`). */\nconst TableHead = (props: TableHeadProps) => {\n warnDeprecated('Table', 'Table.Head', 'Table.Header');\n return <TableHeader {...props} />;\n};\nTableHead.displayName = 'TableHead';\n\n/** @deprecated Use `Table.HeaderCell` (`TableHeaderCell`). */\nconst TableHeadCell = (props: TableHeadCellProps) => {\n warnDeprecated('Table', 'Table.HeadCell', 'Table.HeaderCell');\n return <TableHeaderCell {...props} />;\n};\nTableHeadCell.displayName = 'TableHeadCell';\n\n/** The table's `<tbody>`. */\nconst TableBody = ({ children, className, ref, ...rest }: TableBodyProps) => (\n <tbody ref={ref} {...rest} className={className}>\n {children}\n </tbody>\n);\nTableBody.displayName = 'TableBody';\n\n/** A table row. Striping comes from the table (`striped`), so rows need no context. */\nconst TableRow = ({ children, className, ref, ...props }: TableRowProps) => (\n <tr\n ref={ref}\n className={cn(\n 'hover:bg-subtle-hover transition-colors motion-reduce:transition-none',\n className,\n )}\n {...props}\n >\n {children}\n </tr>\n);\nTableRow.displayName = 'TableRow';\n\n/** A data cell (`<td>`). */\nconst TableCell = ({ children, className, ref, ...props }: TableCellProps) => (\n <td\n ref={ref}\n className={cn('px-4 py-3 text-body-1 border-b border-border', className)}\n {...props}\n >\n {children}\n </td>\n);\nTableCell.displayName = 'TableCell';\n\nexport { TableHeader, TableHeaderCell, TableHead, TableHeadCell, TableBody, TableRow, TableCell };\n\n/**\n * A non-interactive data table with an optional striped body. The table sits in a horizontally\n * scrollable wrapper; while it scrolls, the wrapper is a focusable region (named by\n * `containerProps` or the `<caption>`) so keyboard users can scroll it.\n *\n * Sub-components are available as `Table.Header`, `Table.HeaderCell`, `Table.Body`, `Table.Row`\n * and `Table.Cell` in client components, and as the flat exports `TableHeader`,\n * `TableHeaderCell`, `TableBody`, `TableRow` and `TableCell` (the form React Server Components\n * can import). `Table.Head`/`Table.HeadCell` (`TableHead`/`TableHeadCell`) are deprecated aliases.\n */\nexport const Table = /* @__PURE__ */ Object.assign(TableRoot, {\n Header: TableHeader,\n HeaderCell: TableHeaderCell,\n /** @deprecated Use `Table.Header`. */\n Head: TableHead,\n /** @deprecated Use `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,EAAA,IAAA,CAAC,KAAD,CACO,MACL,MAAM,MACN,UAAWR,EAAAA,GACT,oGACA4C,CACF,EACA,GAAIxB,EAEH,UACC,CAAA,EAEN,EAAgB,YAAc,kBAG9B,IAAM4B,EAAa,IACjB5C,EAAA,eAAe,QAAS,aAAc,cAAc,GAC7C,EAAAI,EAAA,IAAA,CAACqC,EAAD,CAAa,GAAIzB,CAAQ,CAAA,GAElC,EAAU,YAAc,YAGxB,IAAM6B,EAAiB,IACrB7C,EAAA,eAAe,QAAS,iBAAkB,kBAAkB,GACrD,EAAAI,EAAA,IAAA,CAACuC,EAAD,CAAiB,GAAI3B,CAAQ,CAAA,GAEtC,EAAc,YAAc,gBAG5B,IAAM8B,GAAa,CAAE,WAAU,YAAW,MAAK,GAAGJ,MAChD,EAAAtC,EAAA,IAAA,CAAC,QAAD,CAAY,MAAK,GAAIsC,EAAiB,YACnC,UACI,CAAA,EAET,EAAU,YAAc,YAGxB,IAAMK,GAAY,CAAE,WAAU,YAAW,MAAK,GAAG/B,MAC/C,EAAAZ,EAAA,IAAA,CAAC,KAAD,CACO,MACL,UAAWR,EAAAA,GACT,wEACA4C,CACF,EACA,GAAIxB,EAEH,UACC,CAAA,EAEN,EAAS,YAAc,WAGvB,IAAMgC,GAAa,CAAE,WAAU,YAAW,MAAK,GAAGhC,MAChD,EAAAZ,EAAA,IAAA,CAAC,KAAD,CACO,MACL,UAAWR,EAAAA,GAAG,+CAAgD4C,CAAS,EACvE,GAAIxB,EAEH,UACC,CAAA,EAEN,EAAU,YAAc,YAcxB,IAAaiC,EAAwB,OAAO,OAAOlC,EAAW,CAC5D,OAAQ0B,EACR,WAAYE,EAEZ,KAAMC,EAEN,SAAUC,EACV,KAAMC,EACN,IAAKC,EACL,KAAMC,CACR,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
|
|
4
|
+
import { warnDeprecated as r, warnOnce as i } from "../../lib/dev.mjs";
|
|
5
|
+
import { useId as a } from "../../hooks/useId.mjs";
|
|
6
|
+
import { useMergedRefs as o } from "../../hooks/useMergedRefs.mjs";
|
|
7
|
+
import "../../lib/styles.mjs";
|
|
8
|
+
import * as s from "react";
|
|
9
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components/table/Table.tsx
|
|
11
|
+
var l = () => () => {};
|
|
12
|
+
function u(e) {
|
|
13
|
+
let t = s.useCallback((t) => {
|
|
14
|
+
if (!e || typeof ResizeObserver > "u") return () => {};
|
|
15
|
+
let n = new ResizeObserver(t);
|
|
16
|
+
n.observe(e);
|
|
17
|
+
for (let t of Array.from(e.children)) n.observe(t);
|
|
18
|
+
return () => n.disconnect();
|
|
19
|
+
}, [e]), n = s.useCallback(() => e ? e.scrollWidth > e.clientWidth : !1, [e]);
|
|
20
|
+
return s.useSyncExternalStore(e ? t : l, n, () => !1);
|
|
21
|
+
}
|
|
22
|
+
function d(e) {
|
|
23
|
+
return n(e, "caption");
|
|
24
|
+
}
|
|
25
|
+
var f = ({ striped: n = !1, containerProps: r, children: l, className: f, ref: p, ...m }) => {
|
|
26
|
+
let { className: h, ref: g, "aria-label": _, "aria-labelledby": v, ...y } = r ?? {}, [b, x] = s.useState(null), S = o(g, x), C = u(b), w = a("wave-table-caption"), T = t(l), E = T.findIndex(({ node: e }) => d(e)), D = E >= 0 ? T[E].node : null, O = D ? D.props.id ?? w : void 0, k = D && D.props.id === void 0 ? T.map(({ key: e, node: t }, n) => /* @__PURE__ */ c(s.Fragment, { children: n === E ? s.cloneElement(D, { id: w }) : t }, e)) : l, A = _ ? void 0 : v ?? O, j = !!(_ || A), M = C && j, N = y.role;
|
|
27
|
+
return s.useEffect(() => {
|
|
28
|
+
C && !j && i("Table:unnamed-scroll-region", "Table: the table scrolls horizontally but its scroll region has no name. Add a <caption> or containerProps[\"aria-label\"].");
|
|
29
|
+
}, [C, j]), /* @__PURE__ */ c("div", {
|
|
30
|
+
...y,
|
|
31
|
+
ref: S,
|
|
32
|
+
role: M ? "region" : N,
|
|
33
|
+
tabIndex: C ? 0 : y.tabIndex,
|
|
34
|
+
"aria-label": C || N !== void 0 ? _ : void 0,
|
|
35
|
+
"aria-labelledby": M ? A : N === void 0 ? void 0 : v,
|
|
36
|
+
className: e("overflow-x-auto rounded-md border border-border", C && "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", h),
|
|
37
|
+
children: /* @__PURE__ */ c("table", {
|
|
38
|
+
ref: p,
|
|
39
|
+
"data-striped": n ? "" : void 0,
|
|
40
|
+
className: e("w-full border-separate border-spacing-0", n && "[:where(&>tbody>tr:nth-child(odd))]:bg-card", f),
|
|
41
|
+
...m,
|
|
42
|
+
children: k
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
f.displayName = "Table";
|
|
47
|
+
var p = ({ children: t, className: n, ref: r, ...i }) => /* @__PURE__ */ c("thead", {
|
|
48
|
+
ref: r,
|
|
49
|
+
...i,
|
|
50
|
+
className: e("bg-card", n),
|
|
51
|
+
children: t
|
|
52
|
+
});
|
|
53
|
+
p.displayName = "TableHeader";
|
|
54
|
+
var m = ({ children: t, className: n, ref: r, ...i }) => /* @__PURE__ */ c("th", {
|
|
55
|
+
ref: r,
|
|
56
|
+
scope: "col",
|
|
57
|
+
className: e("px-4 py-3 text-start font-semibold text-caption-1 uppercase tracking-wider border-b border-border", n),
|
|
58
|
+
...i,
|
|
59
|
+
children: t
|
|
60
|
+
});
|
|
61
|
+
m.displayName = "TableHeaderCell";
|
|
62
|
+
var h = (e) => (r("Table", "Table.Head", "Table.Header"), /* @__PURE__ */ c(p, { ...e }));
|
|
63
|
+
h.displayName = "TableHead";
|
|
64
|
+
var g = (e) => (r("Table", "Table.HeadCell", "Table.HeaderCell"), /* @__PURE__ */ c(m, { ...e }));
|
|
65
|
+
g.displayName = "TableHeadCell";
|
|
66
|
+
var _ = ({ children: e, className: t, ref: n, ...r }) => /* @__PURE__ */ c("tbody", {
|
|
67
|
+
ref: n,
|
|
68
|
+
...r,
|
|
69
|
+
className: t,
|
|
70
|
+
children: e
|
|
71
|
+
});
|
|
72
|
+
_.displayName = "TableBody";
|
|
73
|
+
var v = ({ children: t, className: n, ref: r, ...i }) => /* @__PURE__ */ c("tr", {
|
|
74
|
+
ref: r,
|
|
75
|
+
className: e("hover:bg-subtle-hover transition-colors motion-reduce:transition-none", n),
|
|
76
|
+
...i,
|
|
77
|
+
children: t
|
|
78
|
+
});
|
|
79
|
+
v.displayName = "TableRow";
|
|
80
|
+
var y = ({ children: t, className: n, ref: r, ...i }) => /* @__PURE__ */ c("td", {
|
|
81
|
+
ref: r,
|
|
82
|
+
className: e("px-4 py-3 text-body-1 border-b border-border", n),
|
|
83
|
+
...i,
|
|
84
|
+
children: t
|
|
85
|
+
});
|
|
86
|
+
y.displayName = "TableCell";
|
|
87
|
+
var b = /* @__PURE__ */ Object.assign(f, {
|
|
88
|
+
Header: p,
|
|
89
|
+
HeaderCell: m,
|
|
90
|
+
Head: h,
|
|
91
|
+
HeadCell: g,
|
|
92
|
+
Body: _,
|
|
93
|
+
Row: v,
|
|
94
|
+
Cell: y
|
|
95
|
+
});
|
|
96
|
+
//#endregion
|
|
97
|
+
export { b as Table, _ as TableBody, y as TableCell, h as TableHead, g as TableHeadCell, p as TableHeader, m as TableHeaderCell, v as TableRow };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=Table.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.mjs","names":["useId","useId$1","React","noopSubscribe","useHorizontalOverflow","subscribe","wrapper","observer","onChange","child","getSnapshot","isCaption","isElementOfType","node","TableRoot","props","containerClassName","containerRef","containerLabel","containerLabelledBy","containerRest","containerProps","setWrapper","wrapperRef","useMergedRefs","scrollable","generatedCaptionId","flatChildren","flattenChildren","children","captionIndex","caption","captionId","content","index","key","regionLabelledBy","named","isRegion","consumerRole","warnOnce","cn","striped","className","TableHeader","rest","TableHeaderCell","TableHead","warnDeprecated","TableHeadCell","TableBody","TableRow","TableCell","Table"],"sources":["../../../src/components/table/Table.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { focusRing } from '../../lib/styles';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\n\n/** Properties for the Table component. */\nexport interface TableProps extends React.HTMLAttributes<HTMLTableElement> {\n /**\n * Whether to apply alternating row background colors (odd body rows). The stripe has zero\n * specificity, so a row's own background class (`<Table.Row className=\"bg-selected\">`) and its\n * hover color win over it.\n * @default false\n */\n striped?: boolean;\n /**\n * Props for the wrapper `<div>` around the `<table>`: a horizontally scrollable container\n * (`overflow-x-auto`). Use it for its className, style, ref or `aria-label`. While the table\n * scrolls horizontally, the wrapper is a keyboard-focusable `role=\"region\"` named by\n * `containerProps['aria-label']`/`['aria-labelledby']`, else by the table's `<caption>`. While\n * it does not scroll, the wrapper has no role and its `aria-label`/`aria-labelledby` are left\n * off, unless you also pass a `role` in `containerProps` (then they are always applied).\n */\n containerProps?: Omit<React.ComponentPropsWithRef<'div'>, 'children'>;\n /** Table caption, header, body and row elements. */\n children: React.ReactNode;\n /** Ref to the `<table>` element. */\n ref?: React.Ref<HTMLTableElement>;\n}\n\n/** Properties for the TableHeader sub-component. */\nexport interface TableHeaderProps extends React.HTMLAttributes<HTMLTableSectionElement> {\n /** Table header row elements. */\n children: React.ReactNode;\n /** Ref to the `<thead>` element. */\n ref?: React.Ref<HTMLTableSectionElement>;\n}\n\n/** Properties for the TableHeaderCell sub-component. */\nexport interface TableHeaderCellProps extends React.ThHTMLAttributes<HTMLTableCellElement> {\n /** Header cell content. */\n children: React.ReactNode;\n /** Ref to the `<th>` element. */\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\n/** @deprecated Use `TableHeaderProps` (`Table.Header`). */\nexport type TableHeadProps = TableHeaderProps;\n\n/** @deprecated Use `TableHeaderCellProps` (`Table.HeaderCell`). */\nexport type TableHeadCellProps = TableHeaderCellProps;\n\n/** Properties for the TableBody sub-component. */\nexport interface TableBodyProps extends React.HTMLAttributes<HTMLTableSectionElement> {\n /** Table row elements. */\n children: React.ReactNode;\n /** Ref to the `<tbody>` element. */\n ref?: React.Ref<HTMLTableSectionElement>;\n}\n\n/** Properties for the TableRow sub-component. */\nexport interface TableRowProps extends React.HTMLAttributes<HTMLTableRowElement> {\n /** Table cell elements. */\n children: React.ReactNode;\n /** Ref to the `<tr>` element. */\n ref?: React.Ref<HTMLTableRowElement>;\n}\n\n/** Properties for the TableCell sub-component. */\nexport interface TableCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {\n /** Cell content. */\n children: React.ReactNode;\n /** Ref to the `<td>` element. */\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\nconst noopSubscribe = () => () => {};\n\n/**\n * Whether `wrapper` scrolls horizontally, as an external store: a `ResizeObserver` on the wrapper\n * and the table re-checks `scrollWidth > clientWidth`. Without `ResizeObserver` (server, old\n * browsers, jsdom) the value is read on each render.\n */\nfunction useHorizontalOverflow(wrapper: HTMLDivElement | null): boolean {\n const subscribe = React.useCallback(\n (onChange: () => void) => {\n if (!wrapper || typeof ResizeObserver === 'undefined') return () => {};\n const observer = new ResizeObserver(onChange);\n observer.observe(wrapper);\n for (const child of Array.from(wrapper.children)) observer.observe(child);\n return () => observer.disconnect();\n },\n [wrapper],\n );\n const getSnapshot = React.useCallback(\n () => (wrapper ? wrapper.scrollWidth > wrapper.clientWidth : false),\n [wrapper],\n );\n return React.useSyncExternalStore(wrapper ? subscribe : noopSubscribe, getSnapshot, () => false);\n}\n\nfunction isCaption(node: React.ReactNode): node is React.ReactElement<{ id?: string }> {\n return isElementOfType(node, 'caption');\n}\n\n// The component-level JSDoc sits on the exported `Table` below.\nconst TableRoot = ({\n striped = false,\n containerProps,\n children,\n className,\n ref,\n ...props\n}: TableProps) => {\n const {\n className: containerClassName,\n ref: containerRef,\n 'aria-label': containerLabel,\n 'aria-labelledby': containerLabelledBy,\n ...containerRest\n } = containerProps ?? {};\n\n const [wrapper, setWrapper] = React.useState<HTMLDivElement | null>(null);\n const wrapperRef = useMergedRefs<HTMLDivElement>(containerRef, setWrapper);\n const scrollable = useHorizontalOverflow(wrapper);\n\n // Name the scroll region after the caption (also one inside a Fragment): keep its id, or give it\n // one. The flattened children are then rendered under their flattened keys.\n const generatedCaptionId = useId('wave-table-caption');\n const flatChildren = flattenChildren(children);\n const captionIndex = flatChildren.findIndex(({ node }) => isCaption(node));\n const caption =\n captionIndex >= 0\n ? (flatChildren[captionIndex].node as React.ReactElement<{ id?: string }>)\n : null;\n const captionId = caption ? (caption.props.id ?? generatedCaptionId) : undefined;\n const content =\n caption && caption.props.id === undefined\n ? flatChildren.map(({ key, node }, index) => (\n <React.Fragment key={key}>\n {index === captionIndex\n ? React.cloneElement(caption, { id: generatedCaptionId })\n : node}\n </React.Fragment>\n ))\n : children;\n\n const regionLabelledBy = containerLabel ? undefined : (containerLabelledBy ?? captionId);\n const named = Boolean(containerLabel || regionLabelledBy);\n const isRegion = scrollable && named;\n /** A role the consumer gave the wrapper: their name goes with it even while nothing scrolls. */\n const consumerRole = containerRest.role;\n\n React.useEffect(() => {\n if (scrollable && !named) {\n warnOnce(\n 'Table:unnamed-scroll-region',\n 'Table: the table scrolls horizontally but its scroll region has no name. Add a <caption> or containerProps[\"aria-label\"].',\n );\n }\n }, [scrollable, named]);\n\n return (\n <div\n {...containerRest}\n ref={wrapperRef}\n role={isRegion ? 'region' : consumerRole}\n tabIndex={scrollable ? 0 : containerRest.tabIndex}\n aria-label={scrollable || consumerRole !== undefined ? containerLabel : undefined}\n aria-labelledby={\n isRegion ? regionLabelledBy : consumerRole !== undefined ? containerLabelledBy : undefined\n }\n className={cn(\n 'overflow-x-auto rounded-md border border-border',\n scrollable && focusRing,\n containerClassName,\n )}\n >\n <table\n ref={ref}\n data-striped={striped ? '' : undefined}\n className={cn(\n 'w-full border-separate border-spacing-0',\n // `:where()` keeps the stripe at specificity 0, so any row class wins (C-CLASS).\n striped && '[:where(&>tbody>tr:nth-child(odd))]:bg-card',\n className,\n )}\n {...props}\n >\n {content}\n </table>\n </div>\n );\n};\nTableRoot.displayName = 'Table';\n\n/** The table's `<thead>`. */\nconst TableHeader = ({ children, className, ref, ...rest }: TableHeaderProps) => (\n <thead ref={ref} {...rest} className={cn('bg-card', className)}>\n {children}\n </thead>\n);\nTableHeader.displayName = 'TableHeader';\n\n/** A column header cell (`<th scope=\"col\">`). */\nconst TableHeaderCell = ({ children, className, ref, ...props }: TableHeaderCellProps) => (\n <th\n ref={ref}\n scope=\"col\"\n className={cn(\n 'px-4 py-3 text-start font-semibold text-caption-1 uppercase tracking-wider border-b border-border',\n className,\n )}\n {...props}\n >\n {children}\n </th>\n);\nTableHeaderCell.displayName = 'TableHeaderCell';\n\n/** @deprecated Use `Table.Header` (`TableHeader`). */\nconst TableHead = (props: TableHeadProps) => {\n warnDeprecated('Table', 'Table.Head', 'Table.Header');\n return <TableHeader {...props} />;\n};\nTableHead.displayName = 'TableHead';\n\n/** @deprecated Use `Table.HeaderCell` (`TableHeaderCell`). */\nconst TableHeadCell = (props: TableHeadCellProps) => {\n warnDeprecated('Table', 'Table.HeadCell', 'Table.HeaderCell');\n return <TableHeaderCell {...props} />;\n};\nTableHeadCell.displayName = 'TableHeadCell';\n\n/** The table's `<tbody>`. */\nconst TableBody = ({ children, className, ref, ...rest }: TableBodyProps) => (\n <tbody ref={ref} {...rest} className={className}>\n {children}\n </tbody>\n);\nTableBody.displayName = 'TableBody';\n\n/** A table row. Striping comes from the table (`striped`), so rows need no context. */\nconst TableRow = ({ children, className, ref, ...props }: TableRowProps) => (\n <tr\n ref={ref}\n className={cn(\n 'hover:bg-subtle-hover transition-colors motion-reduce:transition-none',\n className,\n )}\n {...props}\n >\n {children}\n </tr>\n);\nTableRow.displayName = 'TableRow';\n\n/** A data cell (`<td>`). */\nconst TableCell = ({ children, className, ref, ...props }: TableCellProps) => (\n <td\n ref={ref}\n className={cn('px-4 py-3 text-body-1 border-b border-border', className)}\n {...props}\n >\n {children}\n </td>\n);\nTableCell.displayName = 'TableCell';\n\nexport { TableHeader, TableHeaderCell, TableHead, TableHeadCell, TableBody, TableRow, TableCell };\n\n/**\n * A non-interactive data table with an optional striped body. The table sits in a horizontally\n * scrollable wrapper; while it scrolls, the wrapper is a focusable region (named by\n * `containerProps` or the `<caption>`) so keyboard users can scroll it.\n *\n * Sub-components are available as `Table.Header`, `Table.HeaderCell`, `Table.Body`, `Table.Row`\n * and `Table.Cell` in client components, and as the flat exports `TableHeader`,\n * `TableHeaderCell`, `TableBody`, `TableRow` and `TableCell` (the form React Server Components\n * can import). `Table.Head`/`Table.HeadCell` (`TableHead`/`TableHeadCell`) are deprecated aliases.\n */\nexport const Table = /* @__PURE__ */ Object.assign(TableRoot, {\n Header: TableHeader,\n HeaderCell: TableHeaderCell,\n /** @deprecated Use `Table.Header`. */\n Head: TableHead,\n /** @deprecated Use `Table.HeaderCell`. */\n HeadCell: TableHeadCell,\n Body: TableBody,\n Row: TableRow,\n Cell: TableCell,\n});\n"],"mappings":";;;;;;;;;;AA8EA,IAAMG,gBAA4B,CAAC;AAOnC,SAASC,EAAsB,GAAyC;CACtE,IAAMC,IAAYH,EAAM,aACrB,MAAyB;EACxB,IAAI,CAACI,KAAW,OAAO,iBAAmB,KAAa,aAAa,CAAC;EACrE,IAAMC,IAAW,IAAI,eAAeC,CAAQ;EAC5C,EAAS,QAAQF,CAAO;EACxB,KAAK,IAAMG,KAAS,MAAM,KAAKH,EAAQ,QAAQ,GAAG,EAAS,QAAQG,CAAK;EACxE,aAAaF,EAAS,WAAW;CACnC,GACA,CAACD,CAAO,CACV,GACMI,IAAcR,EAAM,kBACjBI,IAAUA,EAAQ,cAAcA,EAAQ,cAAc,IAC7D,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,KAAa,EAAE,aAAU,cAAW,QAAK,GAAGrC,QAChD,kBAAC,MAAD;CACO;CACL,WAAW0B,EAAG,gDAAgDE,CAAS;CACvE,GAAI5B;CAEH;AACC,CAAA;AAEN,EAAU,cAAc;AAcxB,IAAasC,IAAwB,uBAAO,OAAOvC,GAAW;CAC5D,QAAQ8B;CACR,YAAYE;CAEZ,MAAMC;CAEN,UAAUE;CACV,MAAMC;CACN,KAAKC;CACL,MAAMC;AACR,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/direction.cjs"),n=require("../../lib/focus.cjs");let r=require("react");r=e.__toESM(r,1);var i=new Set([`checkbox`,`radio`,`button`,`submit`,`reset`,`image`,`file`,`color`]),a=new Set([`textbox`,`searchbox`,`combobox`,`spinbutton`,`slider`]),o=[`[data-roving-container]`,...[`toolbar`,`radiogroup`,`listbox`,`grid`,`treegrid`,`tablist`,`menu`,`menubar`,`tree`].map(e=>`[role="${e}"]`)].join(`, `),s=`${n.FOCUSABLE_SELECTOR}, ${o}`,c=[`disabled`,`tabindex`,`hidden`,`inert`,`type`,`contenteditable`,`role`,`data-roving-container`,`aria-selected`];function l(e){let t=e.localName;if(t===`textarea`||t===`select`)return!0;if(t===`input`)return!i.has(e.type);let n=e.getAttribute(`contenteditable`);if(n!==null&&n!==`false`)return!0;let r=e.getAttribute(`role`);return r!==null&&a.has(r)}function u(e){return e.matches(o)}function d(e,t){if(e===t)return!1;for(let n=e.parentElement;n&&n!==t;n=n.parentElement)if(u(n))return!0;return!1}function f(e){let t=e.querySelector(`[tabindex="0"]`);return t&&n.isFocusable(t)?t:n.getFirstTabbable(e,{includeContainer:!0})}function p(e){return e.localName===`input`&&e.type===`hidden`||e.matches(`:disabled`)?!1:e.closest(`[hidden], [inert]`)===null}function m(e){if(!e.name)return!1;let t=e.getRootNode();if(typeof t.querySelectorAll!=`function`)return!1;let n=t.querySelectorAll(`input[type="radio"]:checked`);for(let t of Array.from(n))if(t!==e&&t.name===e.name&&t.form===e.form)return!0;return!1}function h(e){return e.localName===`td`||e.localName===`th`}function g(e){return e.getRootNode().activeElement===e}function _(e,t){let n=t instanceof Element?t:null;for(;n&&n!==e;){if(h(n)&&n.closest(`table`)===e)return n;n=n.parentElement}return null}function v(e){return Array.from(e.rows).filter(e=>e.cells.length>0&&!e.hidden)}var y=1e3;function b(e){let t=new Map(e.map((e,t)=>[e,t])),n=e.map(()=>[]),r=(e,t,r,i)=>{for(let a=0;a<r;a+=1)n[e][t+a]=i};return e.forEach((e,i)=>{let a=n[i],o=0;for(let n of Array.from(e.cells)){for(;a[o];)o+=1;let s=Math.min(Math.max(n.colSpan,1),y);r(i,o,s,n);let c=n.rowSpan===0?1/0:n.rowSpan-1;for(let i=e.nextElementSibling;i&&c>0;i=i.nextElementSibling){if(i.localName!==`tr`)continue;--c;let e=t.get(i);e!==void 0&&r(e,o,s,n)}o+=s}}),n}function x(e,t){for(let n=Math.min(t,e.length-1);n>=0;--n){let t=e[n];if(t)return t}return null}function S(e,t,n){if(t instanceof Element){h(t)&&t.closest(`table`)===e&&n.add(t);for(let r of Array.from(t.querySelectorAll(`td, th`)))r.closest(`table`)===e&&n.add(r)}}function C(e={}){let i=Math.max(1,e.pageSize??10),[a,o]=r.useState(null),y=r.useRef(null),C=r.useRef(null),[w]=r.useState(()=>new WeakSet),[T]=r.useState(()=>new WeakMap),[E]=r.useState(()=>new WeakSet),D=r.useRef(i);r.useLayoutEffect(()=>{D.current=i},[i]);let O=r.useCallback((e,t)=>{let r=[],i=null;for(let a of Array.from(e.querySelectorAll(s))){if(i&&i.contains(a))continue;if(u(a)){i=a,(t?f(a)!==null:p(a))&&r.push({element:a,composite:!0});continue}let e=a.getAttribute(`tabindex`);e!==null&&Number(e)<0&&!w.has(a)||(t?n.isFocusable(a):p(a))&&r.push({element:a,composite:!1})}return r},[w]),k=r.useCallback((e,t,n)=>{if(t.length!==1)return e;let[{element:r,composite:i}]=t;return i||l(r)||n&&r instanceof HTMLInputElement&&r.type===`radio`&&!r.checked&&m(r)?e:r},[]),A=r.useCallback((e,t)=>{let n=String(t);e.getAttribute(`tabindex`)!==n&&(T.set(e,n),e.setAttribute(`tabindex`,n)),w.add(e)},[w,T]),j=r.useCallback((e,t,n)=>{let r=O(e,t);if(n){E.delete(e),A(e,-1);for(let e of r)e.composite||A(e.element,0);return}let i=k(e,r,t),a=!1;i===e?(E.delete(e),A(e,t?0:-1)):w.has(e)&&g(e)?(a=!0,E.add(e),A(e,t?0:-1)):w.has(e)&&(E.delete(e),w.delete(e),e.hasAttribute(`tabindex`)&&(T.set(e,null),e.removeAttribute(`tabindex`)));for(let e of r){if(e.composite)continue;let n=e.element===i&&t&&!a;A(e.element,n?0:-1)}},[k,O,E,A,w,T]),M=r.useCallback((e,t)=>{let n=v(e),r=y.current,i=new Set;if((!r||!r.isConnected||!n.includes(r.parentElement))&&(r=n[0]?.cells[0]??null,y.current=r,r&&i.add(r)),C.current!==null&&C.current!==r){let e=C.current;C.current=null,i.add(e)}let a=C.current;if(t===void 0)for(let e of n)for(let t of Array.from(e.cells))i.add(t);else for(let e of t)e&&i.add(e);for(let t of i)t.isConnected&&_(e,t)===t&&j(t,t===r,t===a)},[j]);r.useLayoutEffect(()=>{if(!a||(M(a),typeof MutationObserver>`u`))return;let e=new MutationObserver(e=>{let t=!1,n=!1,r=new Set;for(let i of e){let e=i.target;if(!(e instanceof Element)||d(e,a))continue;if(i.type===`attributes`){if(i.attributeName===`tabindex`&&T.has(e)&&T.get(e)===e.getAttribute(`tabindex`))continue;t=!0;let o=_(a,e);o?r.add(o):e.localName===`tr`?S(a,e,r):n=!0;continue}t=!0;let o=_(a,e);if(o){r.add(o);continue}for(let e of Array.from(i.addedNodes))S(a,e,r)}t&&(y.current&&r.add(y.current),M(a,n?void 0:r))});return e.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:c}),()=>e.disconnect()},[a,M,T]);let N=r.useCallback((e,t,n)=>{let r=y.current,i=C.current;y.current=t,C.current=n?t:null,M(e,[r,i,t])},[M]),P=r.useCallback((e,t)=>{N(e,t,!1),k(t,O(t,!0),!0).focus()},[N,k,O]),F=r.useCallback(e=>{let n=e.currentTarget;if(e.defaultPrevented)return;let r=_(n,e.target);if(!r)return;let i=O(r,!0),a=k(r,i,!1),o=e.target===r;if(!o&&e.target!==a){e.key===`Escape`&&(e.preventDefault(),P(n,r));return}if(e.altKey||e.metaKey)return;if((e.key===`Enter`||e.key===`F2`)&&o){let t=null;for(let e of i)if(t=e.composite?f(e.element):e.element,t)break;if(!t)return;e.preventDefault(),N(n,r,!0),t.focus();return}let s=v(n),c=s.findIndex(e=>e===r.parentElement);if(c<0)return;let l=Array.from(s[c].cells).indexOf(r),u=s.length-1,d=e.ctrlKey,p=null,m=null;switch(e.key){case`ArrowLeft`:case`ArrowRight`:if(d)break;p=[c,l+(t.getArrowIntent(e.key,{orientation:`horizontal`,dir:t.getDirection(n)})===`next`?1:-1)];break;case`ArrowDown`:d||(m=[c+1,1]);break;case`ArrowUp`:d||(m=[c-1,-1]);break;case`Home`:p=d?[0,0]:[c,0];break;case`End`:p=d?[u,1/0]:[c,1/0];break;case`PageDown`:d||(m=[Math.min(c+D.current,u),1]);break;case`PageUp`:d||(m=[Math.max(c-D.current,0),-1])}if(!p&&!m)return;e.preventDefault();let h=null;if(m){let e=b(s),t=Math.max(e[c].indexOf(r),0);for(let n=m[0];n>=0&&n<=u;n+=m[1]){let i=x(e[n],t);if(i&&i!==r){h=i;break}}}else if(p){let[e,t]=p,n=s[e].cells;h=t===1/0?n[n.length-1]:n.item(t)}h&&h!==r&&P(n,h)},[N,P,k,O]),I=r.useCallback(e=>{let t=e.currentTarget,n=e.target,r=_(t,n);if(!r)return;let i=n!==r&&n!==k(r,O(r,!0),!1);N(t,r,i)},[N,k,O]),L=r.useCallback(e=>{let t=e.currentTarget,n=e.target,r=[];n instanceof Element&&h(n)&&E.has(n)&&r.push(n);let i=e.relatedTarget,a=C.current;a!==null&&!(i instanceof Node&&t.contains(i))&&(C.current=null,r.push(a)),r.length>0&&M(t,r)},[E,M]);return{gridRef:o,gridProps:r.useMemo(()=>({onKeyDown:F,onFocus:I,onBlur:L}),[L,I,F])}}exports.isTextEntryElement=l,exports.useGridNavigation=C;
|
|
2
|
+
//# sourceMappingURL=useGridNavigation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGridNavigation.cjs","names":["FOCUSABLE_SELECTOR","isFocusable","getFirstTabbable","React","getArrowIntent","getDirection","require_runtime","require_direction","require_focus","react","NON_TEXT_INPUT_TYPES","KEY_CONSUMING_ROLES","COMPOSITE_SELECTOR","role","WIDGET_CANDIDATE_SELECTOR","OBSERVED_ATTRIBUTES","isTextEntryElement","tag","el","editable","isNestedComposite","isInsideNestedComposite","node","grid","getCompositeEntry","stop","composite","isLikelyFocusable","hasCheckedPeer","radio","root","checked","other","isCellElement","isFocused","getCell","getRows","row","MAX_COL_SPAN","getColumnMap","indexOf","rows","index","map","cover","offset","colSpan","rowIndex","column","cell","own","remaining","next","covered","getCellAtColumn","rowMap","collectCells","into","useGridNavigation","pageSize","options","setGrid","activeCellRef","interactionCellRef","stamped","written","retained","pageSizeRef","getWidgets","widgets","precise","tabIndex","getTarget","element","checkRadioGroup","setTabIndex","value","syncCell","isActive","isInteraction","widget","target","keepCell","isStop","sync","table","active","targets","previous","interaction","cells","observer","relevant","all","dirty","record","records","activate","previousActive","previousInteraction","focusCell","onKeyDown","event","widgetTarget","onCell","entry","columnIndex","lastRow","ctrl","vertical","destination","columns","candidate","nextRow","nextColumn","rowCells","onFocus","onBlur","left"],"sources":["../../../src/components/table/useGridNavigation.ts"],"sourcesContent":["import * as React from 'react';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { FOCUSABLE_SELECTOR, getFirstTabbable, isFocusable } from '../../lib/focus';\n\n/** Options of {@link useGridNavigation}. */\nexport interface UseGridNavigationOptions {\n /**\n * How many rows PageUp and PageDown move focus.\n * @default 10\n */\n pageSize?: number;\n}\n\n/** Handlers {@link useGridNavigation} needs on the grid element (compose them with the consumer's). */\nexport interface GridNavigationHandlers {\n onKeyDown: React.KeyboardEventHandler<HTMLTableElement>;\n onFocus: React.FocusEventHandler<HTMLTableElement>;\n onBlur: React.FocusEventHandler<HTMLTableElement>;\n}\n\n/** Result of {@link useGridNavigation}. */\nexport interface UseGridNavigationResult {\n /** Callback ref for the `<table role=\"grid\">` element. Stable identity. */\n gridRef: React.RefCallback<HTMLTableElement>;\n /** Keyboard and focus handlers for the grid element. Stable identities. */\n gridProps: GridNavigationHandlers;\n}\n\n/** Input types that do not take arrow or character keys, so a lone one can be a cell's focus target. */\nconst NON_TEXT_INPUT_TYPES: ReadonlySet<string> = new Set([\n 'checkbox',\n 'radio',\n 'button',\n 'submit',\n 'reset',\n 'image',\n 'file',\n 'color',\n]);\n\n/** Widget roles that use arrow or character keys themselves (treated like text entry). */\nconst KEY_CONSUMING_ROLES: ReadonlySet<string> = new Set([\n 'textbox',\n 'searchbox',\n 'combobox',\n 'spinbutton',\n 'slider',\n]);\n\n/**\n * Roles of composite widgets that manage their own children (and usually their tab indexes): an\n * element with one of them, or with `data-roving-container`, is a nested composite. Close to the\n * list of `useRovingTabIndex`, which is kept separately and differs on purpose: here a `toolbar`\n * is a composite (a toolbar in a cell is one widget), while `spinbutton` is not (it is one\n * focusable control that uses the arrow keys, handled by `KEY_CONSUMING_ROLES` like a text\n * field). Keep both lists in mind when adding a role.\n */\nconst COMPOSITE_ROLES: readonly string[] = [\n 'toolbar',\n 'radiogroup',\n 'listbox',\n 'grid',\n 'treegrid',\n 'tablist',\n 'menu',\n 'menubar',\n 'tree',\n];\n\nconst COMPOSITE_SELECTOR = [\n '[data-roving-container]',\n ...COMPOSITE_ROLES.map((role) => `[role=\"${role}\"]`),\n].join(', ');\n\n/** Every element that can be a cell widget: a focusable element or a nested composite root. */\nconst WIDGET_CANDIDATE_SELECTOR = `${FOCUSABLE_SELECTOR}, ${COMPOSITE_SELECTOR}`;\n\n/**\n * Attributes whose changes can change a cell's widgets or the grid's rows. `aria-selected` on a row\n * signals a selection change, which can change the active cell's target (radio groups).\n */\nconst OBSERVED_ATTRIBUTES = [\n 'disabled',\n 'tabindex',\n 'hidden',\n 'inert',\n 'type',\n 'contenteditable',\n 'role',\n 'data-roving-container',\n 'aria-selected',\n];\n\n/**\n * Whether `el` is a text-entry control (or another widget that uses arrow keys itself): a text-like\n * `input`, `textarea`, `select`, a `contenteditable` element, or an element with role textbox,\n * searchbox, combobox, spinbutton or slider. Such widgets are never a cell's navigation target: the\n * cell takes focus and Enter/F2 moves into the widget, so the arrow keys keep moving the caret.\n */\nexport function isTextEntryElement(el: Element): boolean {\n const tag = el.localName;\n if (tag === 'textarea' || tag === 'select') return true;\n if (tag === 'input') return !NON_TEXT_INPUT_TYPES.has((el as HTMLInputElement).type);\n const editable = el.getAttribute('contenteditable');\n if (editable !== null && editable !== 'false') return true;\n const role = el.getAttribute('role');\n return role !== null && KEY_CONSUMING_ROLES.has(role);\n}\n\n/** Whether `el` is a nested composite widget (own roving container or a composite role). */\nfunction isNestedComposite(el: Element): boolean {\n return el.matches(COMPOSITE_SELECTOR);\n}\n\n/** Whether `node` is strictly inside a nested composite of `grid` (the composite root excluded). */\nfunction isInsideNestedComposite(node: Element, grid: HTMLTableElement): boolean {\n if (node === grid) return false;\n for (let el = node.parentElement; el && el !== grid; el = el.parentElement) {\n if (isNestedComposite(el)) return true;\n }\n return false;\n}\n\n/**\n * The element a nested composite is entered at: its own tab stop (`tabindex=\"0\"`), else its first\n * tabbable element (the root itself when it is the focusable element).\n */\nfunction getCompositeEntry(composite: HTMLElement): HTMLElement | null {\n const stop = composite.querySelector<HTMLElement>('[tabindex=\"0\"]');\n if (stop && isFocusable(stop)) return stop;\n return getFirstTabbable(composite, { includeContainer: true });\n}\n\n/**\n * A cheap focusability check for cells that do not hold the tab stop: no style reads, only the\n * attributes that take an element out of the focus order. The cell that holds (or receives) the tab\n * stop is checked precisely with `isFocusable`.\n */\nfunction isLikelyFocusable(el: HTMLElement): boolean {\n if (el.localName === 'input' && (el as HTMLInputElement).type === 'hidden') return false;\n if (el.matches(':disabled')) return false;\n return el.closest('[hidden], [inert]') === null;\n}\n\n/** Whether another radio of `radio`'s named group is checked (the browser's tab stop of the group). */\nfunction hasCheckedPeer(radio: HTMLInputElement): boolean {\n if (!radio.name) return false;\n const root = radio.getRootNode() as Document | ShadowRoot;\n if (typeof root.querySelectorAll !== 'function') return false;\n const checked = root.querySelectorAll<HTMLInputElement>('input[type=\"radio\"]:checked');\n for (const other of Array.from(checked)) {\n if (other !== radio && other.name === radio.name && other.form === radio.form) return true;\n }\n return false;\n}\n\nfunction isCellElement(el: Element): el is HTMLTableCellElement {\n return el.localName === 'td' || el.localName === 'th';\n}\n\n/** Whether `el` is the focused element of its document (or shadow root). */\nfunction isFocused(el: Element): boolean {\n return (el.getRootNode() as Partial<DocumentOrShadowRoot>).activeElement === el;\n}\n\n/** The cell of `grid` that contains `node` (a nested table's cells belong to the outer cell). */\nfunction getCell(grid: HTMLTableElement, node: EventTarget | null): HTMLTableCellElement | null {\n let el: Element | null = node instanceof Element ? node : null;\n while (el && el !== grid) {\n if (isCellElement(el) && el.closest('table') === grid) return el;\n el = el.parentElement;\n }\n return null;\n}\n\n/** The rows of `grid` (header, body and footer rows; a nested table's rows are not included). */\nfunction getRows(grid: HTMLTableElement): HTMLTableRowElement[] {\n return Array.from(grid.rows).filter((row) => row.cells.length > 0 && !row.hidden);\n}\n\n/** Browsers clamp `colSpan` to 1..1000 (`rowSpan` 0 covers the rest of its row group). */\nconst MAX_COL_SPAN = 1000;\n\n/** Per row, the cell covering each visual column (see {@link getColumnMap}). */\ntype ColumnMap = ReadonlyArray<ReadonlyArray<HTMLTableCellElement | undefined>>;\n\n/**\n * The HTML table model of `rows`: per row, the cell covering each visual column, with `colSpan` and\n * `rowSpan` counted. A row span covers the next rows of its row group in the DOM (a hidden row\n * counts, but gets no entry). A column no cell covers is empty. O(number of cells).\n */\nfunction getColumnMap(rows: readonly HTMLTableRowElement[]): ColumnMap {\n const indexOf = new Map<Element, number>(rows.map((row, index) => [row, index]));\n const map: Array<Array<HTMLTableCellElement | undefined>> = rows.map(() => []);\n const cover = (rowIndex: number, column: number, colSpan: number, cell: HTMLTableCellElement) => {\n for (let offset = 0; offset < colSpan; offset += 1) map[rowIndex][column + offset] = cell;\n };\n rows.forEach((row, rowIndex) => {\n const own = map[rowIndex];\n let column = 0;\n for (const cell of Array.from(row.cells)) {\n while (own[column]) column += 1;\n const colSpan = Math.min(Math.max(cell.colSpan, 1), MAX_COL_SPAN);\n cover(rowIndex, column, colSpan, cell);\n let remaining = cell.rowSpan === 0 ? Infinity : cell.rowSpan - 1;\n for (\n let next = row.nextElementSibling;\n next && remaining > 0;\n next = next.nextElementSibling\n ) {\n if (next.localName !== 'tr') continue;\n remaining -= 1;\n const covered = indexOf.get(next);\n if (covered !== undefined) cover(covered, column, colSpan, cell);\n }\n column += colSpan;\n }\n });\n return map;\n}\n\n/** The cell of a row (as {@link getColumnMap} maps it) at `column`, else the last one before it. */\nfunction getCellAtColumn(\n rowMap: ReadonlyArray<HTMLTableCellElement | undefined>,\n column: number,\n): HTMLTableCellElement | null {\n for (let index = Math.min(column, rowMap.length - 1); index >= 0; index -= 1) {\n const cell = rowMap[index];\n if (cell) return cell;\n }\n return null;\n}\n\n/** The grid cells in `node` (itself, or its descendants that belong to `grid`). */\nfunction collectCells(grid: HTMLTableElement, node: Node, into: Set<HTMLTableCellElement>): void {\n if (!(node instanceof Element)) return;\n if (isCellElement(node) && node.closest('table') === grid) into.add(node);\n for (const el of Array.from(node.querySelectorAll<HTMLTableCellElement>('td, th'))) {\n if (el.closest('table') === grid) into.add(el);\n }\n}\n\n/** A widget of a cell: a focusable element, or a nested composite counted as one widget. */\ninterface CellWidget {\n /** The focusable element, or the nested composite's root. */\n element: HTMLElement;\n /** A nested composite: the grid never writes `tabindex` on or inside it. */\n composite: boolean;\n}\n\n/**\n * Grid keyboard model of the APG Grid pattern for a `<table role=\"grid\">` (DataGrid).\n *\n * - **One tab stop.** Exactly one cell of the grid is in the tab order (initially the first cell).\n * Its focus target is its only focusable widget when that widget is not a text-entry control\n * (a checkbox, a sort button, a link); otherwise — no widget, several widgets, a text-entry\n * control or a nested composite — the cell itself. An unchecked radio whose named group has a\n * checked radio is not a target either (browsers skip it in the Tab order), so its cell is.\n * Every other cell and every widget inside a cell gets `tabindex=\"-1\"`. Rows are never focusable.\n * When a widget becomes the target of the focused cell (Space on the cell checks its radio), the\n * cell keeps focus and the tab stop (removing its `tabindex` would blur it) while its target stays\n * at `tabindex=\"-1\"`; the target takes the tab stop once the cell is blurred.\n * - **Navigation mode** (focus on a cell or on its target widget): ArrowLeft/ArrowRight (the\n * previous/next cell of the row, mirrored in RTL), ArrowUp/ArrowDown, Home/End (first/last cell\n * of the row), Ctrl+Home/Ctrl+End (first cell of the grid / last cell of the last row) and\n * PageUp/PageDown ({@link UseGridNavigationOptions.pageSize} rows) move focus between cells.\n * ArrowUp/ArrowDown and PageUp/PageDown keep the visual column (`colSpan` and `rowSpan` counted,\n * so a grouped header works), clamped to a shorter row. Space and Enter on a target widget reach\n * the widget.\n * - **Interaction mode**: Enter or F2 on a cell that is its own target moves focus into its first\n * widget; clicking a widget that is not the cell's target (a text input) enters it too. The\n * grid keys are then ignored, so the arrow keys move the caret, and Tab moves between the cell's\n * widgets. Escape returns focus to the cell. Leaving the grid ends interaction mode.\n * - **Nested composites** (an element with `data-roving-container` or role toolbar, radiogroup,\n * listbox, grid, treegrid, tablist, menu, menubar or tree) count as one widget that uses the arrow\n * keys: its cell takes focus, and Enter/F2 enters the composite at its own tab stop. The grid never\n * writes `tabindex` on or inside a composite (the composite manages its own), so a composite\n * keeps its own Tab stop — the same documented limitation as `useRovingTabIndex`.\n *\n * Keys are ignored when the event's default was prevented (a widget that handled the key, a\n * consumer handler), or with Alt/Meta held. The tab indexes are written to the DOM (layout effect\n * plus a `MutationObserver`), so rows and widgets added later are covered without a re-render. Focus\n * moves re-sync only the cells involved, the observer only the cells that changed, and the grid's\n * own `tabindex` writes do not trigger a re-sync.\n *\n * Internal to the table package.\n */\nexport function useGridNavigation(options: UseGridNavigationOptions = {}): UseGridNavigationResult {\n const pageSize = Math.max(1, options.pageSize ?? 10);\n const [grid, setGrid] = React.useState<HTMLTableElement | null>(null);\n /** The cell that holds the tab stop. */\n const activeCellRef = React.useRef<HTMLTableCellElement | null>(null);\n /** The cell whose widgets are being interacted with, or `null` (navigation mode). */\n const interactionCellRef = React.useRef<HTMLTableCellElement | null>(null);\n /** Elements whose `tabindex` this hook wrote. */\n const [stamped] = React.useState(() => new WeakSet<Element>());\n /** The `tabindex` value this hook last wrote per element (`null`: removed), to skip own records. */\n const [written] = React.useState(() => new WeakMap<Element, string | null>());\n /**\n * Cells kept focusable (holding the tab stop, their target at -1) because they were focused when\n * a widget became their target (a radio that got checked, a widget added): they lose the\n * attribute once blurred.\n */\n const [retained] = React.useState(() => new WeakSet<Element>());\n const pageSizeRef = React.useRef(pageSize);\n\n React.useLayoutEffect(() => {\n pageSizeRef.current = pageSize;\n }, [pageSize]);\n\n /**\n * The widgets of `cell` in DOM order. `precise` checks focusability with `isFocusable` (style\n * reads); otherwise only attributes are checked (cells that do not hold the tab stop).\n */\n const getWidgets = React.useCallback(\n (cell: HTMLTableCellElement, precise: boolean): CellWidget[] => {\n const widgets: CellWidget[] = [];\n let composite: HTMLElement | null = null;\n for (const el of Array.from(cell.querySelectorAll<HTMLElement>(WIDGET_CANDIDATE_SELECTOR))) {\n // Descendants of a nested composite belong to it (candidates come in document order).\n if (composite && composite.contains(el)) continue;\n if (isNestedComposite(el)) {\n composite = el;\n const available = precise ? getCompositeEntry(el) !== null : isLikelyFocusable(el);\n if (available) widgets.push({ element: el, composite: true });\n continue;\n }\n const tabIndex = el.getAttribute('tabindex');\n // An author tabindex=\"-1\" (not written by this hook) opts the element out.\n if (tabIndex !== null && Number(tabIndex) < 0 && !stamped.has(el)) continue;\n if (precise ? isFocusable(el) : isLikelyFocusable(el)) {\n widgets.push({ element: el, composite: false });\n }\n }\n return widgets;\n },\n [stamped],\n );\n\n /**\n * The element of `cell` that takes focus in navigation mode. `checkRadioGroup` applies the radio\n * group rule, which only decides where the tab stop goes (the cell that holds it); a focused\n * lone radio is in navigation mode either way.\n */\n const getTarget = React.useCallback(\n (cell: HTMLTableCellElement, widgets: CellWidget[], checkRadioGroup: boolean): HTMLElement => {\n if (widgets.length !== 1) return cell;\n const [{ element, composite }] = widgets;\n if (composite || isTextEntryElement(element)) return cell;\n if (\n checkRadioGroup &&\n element instanceof HTMLInputElement &&\n element.type === 'radio' &&\n !element.checked &&\n hasCheckedPeer(element)\n ) {\n return cell;\n }\n return element;\n },\n [],\n );\n\n const setTabIndex = React.useCallback(\n (el: HTMLElement, value: 0 | -1) => {\n const next = String(value);\n if (el.getAttribute('tabindex') !== next) {\n written.set(el, next);\n el.setAttribute('tabindex', next);\n }\n stamped.add(el);\n },\n [stamped, written],\n );\n\n /** Writes the tab indexes of one cell and its widgets (only attributes that change). */\n const syncCell = React.useCallback(\n (cell: HTMLTableCellElement, isActive: boolean, isInteraction: boolean) => {\n const widgets = getWidgets(cell, isActive);\n if (isInteraction) {\n retained.delete(cell);\n setTabIndex(cell, -1);\n for (const widget of widgets) {\n if (!widget.composite) setTabIndex(widget.element, 0);\n }\n return;\n }\n const target = getTarget(cell, widgets, isActive);\n /** The focused cell stands in for its target until it is blurred (see below). */\n let keepCell = false;\n if (target === cell) {\n retained.delete(cell);\n setTabIndex(cell, isActive ? 0 : -1);\n } else if (stamped.has(cell) && isFocused(cell)) {\n // A widget became the focused cell's target (its radio got checked, a widget was added).\n // Removing the tabindex of the focused element blurs it (browsers move focus to the body,\n // which ends the grid session), so the cell stays focusable and stays the grid's position.\n // It keeps the tab stop (`tabindex=\"0\"`, when active) and its target stays at -1: the grid\n // still has exactly one Tab stop even if focus is lost without a focusout, and Tab and\n // Shift+Tab from the cell leave the grid (nothing after or before it inside is tabbable).\n // Once the cell is blurred, onBlur re-syncs it and the target takes the tab stop.\n keepCell = true;\n retained.add(cell);\n setTabIndex(cell, isActive ? 0 : -1);\n } else if (stamped.has(cell)) {\n // The cell's widget is its target: the cell itself is not focusable.\n retained.delete(cell);\n stamped.delete(cell);\n if (cell.hasAttribute('tabindex')) {\n written.set(cell, null);\n cell.removeAttribute('tabindex');\n }\n }\n for (const widget of widgets) {\n if (widget.composite) continue;\n const isStop = widget.element === target && isActive && !keepCell;\n setTabIndex(widget.element, isStop ? 0 : -1);\n }\n },\n [getTarget, getWidgets, retained, setTabIndex, stamped, written],\n );\n\n /**\n * Re-resolves the active cell (the first cell when it is gone) and syncs `cells` — every cell\n * when omitted. A new active cell is always synced.\n */\n const sync = React.useCallback(\n (table: HTMLTableElement, cells?: Iterable<HTMLTableCellElement | null>) => {\n const rows = getRows(table);\n let active = activeCellRef.current;\n const targets = new Set<HTMLTableCellElement>();\n if (\n !active ||\n !active.isConnected ||\n !rows.includes(active.parentElement as HTMLTableRowElement)\n ) {\n active = rows[0]?.cells[0] ?? null;\n activeCellRef.current = active;\n if (active) targets.add(active);\n }\n if (interactionCellRef.current !== null && interactionCellRef.current !== active) {\n const previous = interactionCellRef.current;\n interactionCellRef.current = null;\n targets.add(previous);\n }\n const interaction = interactionCellRef.current;\n\n if (cells === undefined) {\n for (const row of rows) for (const cell of Array.from(row.cells)) targets.add(cell);\n } else {\n for (const cell of cells) if (cell) targets.add(cell);\n }\n for (const cell of targets) {\n if (!cell.isConnected || getCell(table, cell) !== cell) continue;\n syncCell(cell, cell === active, cell === interaction);\n }\n },\n [syncCell],\n );\n\n React.useLayoutEffect(() => {\n if (!grid) return;\n sync(grid);\n if (typeof MutationObserver === 'undefined') return;\n const observer = new MutationObserver((records) => {\n let relevant = false;\n let all = false;\n const dirty = new Set<HTMLTableCellElement>();\n for (const record of records) {\n const target = record.target;\n if (!(target instanceof Element)) continue;\n // A nested composite manages its own items (and their tab indexes).\n if (isInsideNestedComposite(target, grid)) continue;\n if (record.type === 'attributes') {\n // The record of one of our own writes.\n if (\n record.attributeName === 'tabindex' &&\n written.has(target) &&\n written.get(target) === target.getAttribute('tabindex')\n ) {\n continue;\n }\n relevant = true;\n const cell = getCell(grid, target);\n if (cell) dirty.add(cell);\n else if (target.localName === 'tr') collectCells(grid, target, dirty);\n else all = true;\n continue;\n }\n relevant = true;\n const cell = getCell(grid, target);\n if (cell) {\n dirty.add(cell);\n continue;\n }\n // Rows, sections or cells added (removed ones need no sync; `sync` re-resolves the\n // active cell when it went away).\n for (const node of Array.from(record.addedNodes)) collectCells(grid, node, dirty);\n }\n if (!relevant) return;\n // The active cell's target can depend on other cells (a radio group whose checked radio\n // changed, reflected by the rows' `aria-selected`), so it is always re-checked.\n if (activeCellRef.current) dirty.add(activeCellRef.current);\n sync(grid, all ? undefined : dirty);\n });\n observer.observe(grid, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: OBSERVED_ATTRIBUTES,\n });\n return () => observer.disconnect();\n }, [grid, sync, written]);\n\n /**\n * Makes `cell` the active cell (in interaction mode when `interaction`) and re-syncs only the\n * cells involved: the previous active and interaction cells and `cell`.\n */\n const activate = React.useCallback(\n (table: HTMLTableElement, cell: HTMLTableCellElement, interaction: boolean) => {\n const previousActive = activeCellRef.current;\n const previousInteraction = interactionCellRef.current;\n activeCellRef.current = cell;\n interactionCellRef.current = interaction ? cell : null;\n sync(table, [previousActive, previousInteraction, cell]);\n },\n [sync],\n );\n\n const focusCell = React.useCallback(\n (table: HTMLTableElement, cell: HTMLTableCellElement) => {\n activate(table, cell, false);\n getTarget(cell, getWidgets(cell, true), true).focus();\n },\n [activate, getTarget, getWidgets],\n );\n\n const onKeyDown = React.useCallback<React.KeyboardEventHandler<HTMLTableElement>>(\n (event) => {\n const table = event.currentTarget;\n if (event.defaultPrevented) return;\n const cell = getCell(table, event.target);\n if (!cell) return;\n const widgets = getWidgets(cell, true);\n // A lone non-text widget is in navigation mode when focused, even an unchecked radio that\n // the radio group rule keeps from holding the tab stop.\n const widgetTarget = getTarget(cell, widgets, false);\n const onCell = event.target === cell;\n\n if (!onCell && event.target !== widgetTarget) {\n // Interaction mode: the widget keeps its keys; Escape returns to the cell.\n if (event.key === 'Escape') {\n event.preventDefault();\n focusCell(table, cell);\n }\n return;\n }\n if (event.altKey || event.metaKey) return;\n\n if ((event.key === 'Enter' || event.key === 'F2') && onCell) {\n let entry: HTMLElement | null = null;\n for (const widget of widgets) {\n entry = widget.composite ? getCompositeEntry(widget.element) : widget.element;\n if (entry) break;\n }\n if (!entry) return;\n event.preventDefault();\n activate(table, cell, true);\n entry.focus();\n return;\n }\n\n const rows = getRows(table);\n const rowIndex = rows.findIndex((row) => row === cell.parentElement);\n if (rowIndex < 0) return;\n const columnIndex = Array.from(rows[rowIndex].cells).indexOf(cell);\n const lastRow = rows.length - 1;\n const ctrl = event.ctrlKey;\n /** Left/Right, Home/End: target row and cell index in it (`Infinity`: the row's last cell). */\n let next: [row: number, column: number] | null = null;\n /** Up/Down, PageUp/PageDown: the first row to try and the direction to keep going in. */\n let vertical: [row: number, step: 1 | -1] | null = null;\n\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowRight': {\n if (ctrl) break;\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(table),\n });\n next = [rowIndex, columnIndex + (intent === 'next' ? 1 : -1)];\n break;\n }\n case 'ArrowDown':\n if (!ctrl) vertical = [rowIndex + 1, 1];\n break;\n case 'ArrowUp':\n if (!ctrl) vertical = [rowIndex - 1, -1];\n break;\n case 'Home':\n next = ctrl ? [0, 0] : [rowIndex, 0];\n break;\n case 'End':\n next = ctrl ? [lastRow, Infinity] : [rowIndex, Infinity];\n break;\n case 'PageDown':\n if (!ctrl) vertical = [Math.min(rowIndex + pageSizeRef.current, lastRow), 1];\n break;\n case 'PageUp':\n if (!ctrl) vertical = [Math.max(rowIndex - pageSizeRef.current, 0), -1];\n break;\n default:\n break;\n }\n if (!next && !vertical) return;\n // A handled key never scrolls the page or reaches the widget, even at the grid's edge.\n event.preventDefault();\n let destination: HTMLTableCellElement | null = null;\n if (vertical) {\n // Up/Down keep the visual column (spans counted), clamped to a shorter row; the rows a\n // row-spanning cell covers are skipped when moving away from it.\n const columns = getColumnMap(rows);\n const column = Math.max(columns[rowIndex].indexOf(cell), 0);\n for (let row = vertical[0]; row >= 0 && row <= lastRow; row += vertical[1]) {\n const candidate = getCellAtColumn(columns[row], column);\n if (candidate && candidate !== cell) {\n destination = candidate;\n break;\n }\n }\n } else if (next) {\n // Left/Right stop at the row's edges (no cell there).\n const [nextRow, nextColumn] = next;\n const rowCells = rows[nextRow].cells;\n destination =\n nextColumn === Infinity ? rowCells[rowCells.length - 1] : rowCells.item(nextColumn);\n }\n if (destination && destination !== cell) focusCell(table, destination);\n },\n [activate, focusCell, getTarget, getWidgets],\n );\n\n const onFocus = React.useCallback<React.FocusEventHandler<HTMLTableElement>>(\n (event) => {\n const table = event.currentTarget;\n // React types `target` as the handler's element type; it is the focused descendant.\n const target: EventTarget = event.target;\n const cell = getCell(table, target);\n if (!cell) return;\n const interaction =\n target !== cell && target !== getTarget(cell, getWidgets(cell, true), false);\n activate(table, cell, interaction);\n },\n [activate, getTarget, getWidgets],\n );\n\n const onBlur = React.useCallback<React.FocusEventHandler<HTMLTableElement>>(\n (event) => {\n const table = event.currentTarget;\n // React types `target` as the handler's element type; it is the blurred descendant.\n const left: EventTarget = event.target;\n const cells: HTMLTableCellElement[] = [];\n // A cell kept focusable while focused (see syncCell) is re-synced now that it is blurred\n // (during focusout the blurred element is no longer the active element).\n if (left instanceof Element && isCellElement(left) && retained.has(left)) cells.push(left);\n const next = event.relatedTarget;\n const interaction = interactionCellRef.current;\n if (interaction !== null && !(next instanceof Node && table.contains(next))) {\n interactionCellRef.current = null;\n cells.push(interaction);\n }\n if (cells.length > 0) sync(table, cells);\n },\n [retained, sync],\n );\n\n const gridProps = React.useMemo<GridNavigationHandlers>(\n () => ({ onKeyDown, onFocus, onBlur }),\n [onBlur, onFocus, onKeyDown],\n );\n\n return { gridRef: setGrid, gridProps };\n}\n"],"mappings":"mLA6BA,IAAMU,EAA4C,IAAI,IAAI,CACxD,WACA,QACA,SACA,SACA,QACA,QACA,OACA,OACF,CAAC,EAGKC,EAA2C,IAAI,IAAI,CACvD,UACA,YACA,WACA,aACA,QACF,CAAC,EAsBKC,EAAqB,CACzB,0BACA,GAAG,CAbH,UACA,aACA,UACA,OACA,WACA,UACA,OACA,UACA,MAKG,CAAA,CAAgB,IAAK,GAAS,UAAUC,EAAK,GAAG,CACrD,CAAC,CAAC,KAAK,IAAI,EAGLC,EAA4B,GAAGd,EAAAA,mBAAmB,IAAIY,IAMtDG,EAAsB,CAC1B,WACA,WACA,SACA,QACA,OACA,kBACA,OACA,wBACA,eACF,EAQA,SAAgBC,EAAmB,EAAsB,CACvD,IAAMC,EAAMC,EAAG,UACf,GAAID,IAAQ,YAAcA,IAAQ,SAAU,MAAO,GACnD,GAAIA,IAAQ,QAAS,MAAO,CAACP,EAAqB,IAAKQ,EAAwB,IAAI,EACnF,IAAMC,EAAWD,EAAG,aAAa,iBAAiB,EAClD,GAAIC,IAAa,MAAQA,IAAa,QAAS,MAAO,GACtD,IAAMN,EAAOK,EAAG,aAAa,MAAM,EACnC,OAAOL,IAAS,MAAQF,EAAoB,IAAIE,CAAI,CACtD,CAGA,SAASO,EAAkB,EAAsB,CAC/C,OAAOF,EAAG,QAAQN,CAAkB,CACtC,CAGA,SAASS,EAAwB,EAAe,EAAiC,CAC/E,GAAIC,IAASC,EAAM,MAAO,GAC1B,IAAK,IAAIL,EAAKI,EAAK,cAAeJ,GAAMA,IAAOK,EAAM,EAAKL,EAAG,cAC3D,GAAIE,EAAkBF,CAAE,EAAG,MAAO,GAEpC,MAAO,EACT,CAMA,SAASM,EAAkB,EAA4C,CACrE,IAAMC,EAAOC,EAAU,cAA2B,gBAAgB,EAElE,OADID,GAAQxB,EAAAA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