@primitiv-ui/react 0.1.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 +79 -0
- package/package.json +59 -0
- package/src/AccessibleIcon/AccessibleIcon.tsx +40 -0
- package/src/AccessibleIcon/README.md +42 -0
- package/src/AccessibleIcon/__tests__/AccessibleIcon.test.tsx +47 -0
- package/src/AccessibleIcon/index.ts +2 -0
- package/src/AccessibleIcon/types.ts +8 -0
- package/src/Accordion/Accordion.tsx +412 -0
- package/src/Accordion/AccordionContext.ts +12 -0
- package/src/Accordion/README.md +202 -0
- package/src/Accordion/__tests__/Accordion.asChild.test.tsx +237 -0
- package/src/Accordion/__tests__/Accordion.basic-rendering.test.tsx +333 -0
- package/src/Accordion/__tests__/Accordion.controlled-state.test.tsx +175 -0
- package/src/Accordion/__tests__/Accordion.data-attributes.test.tsx +272 -0
- package/src/Accordion/__tests__/Accordion.disabled-items.test.tsx +311 -0
- package/src/Accordion/__tests__/Accordion.error-handling.test.tsx +119 -0
- package/src/Accordion/__tests__/Accordion.forceMount.test.tsx +119 -0
- package/src/Accordion/__tests__/Accordion.keyboard-interaction.test.tsx +736 -0
- package/src/Accordion/__tests__/Accordion.mouse-interaction.test.tsx +212 -0
- package/src/Accordion/__tests__/Accordion.multiple-mode.test.tsx +90 -0
- package/src/Accordion/__tests__/Accordion.reading-direction.test.tsx +139 -0
- package/src/Accordion/__tests__/Accordion.uncontrolled-state.test.tsx +154 -0
- package/src/Accordion/hooks/index.ts +6 -0
- package/src/Accordion/hooks/useAccordionContext.ts +1 -0
- package/src/Accordion/hooks/useAccordionHeaderContext.ts +10 -0
- package/src/Accordion/hooks/useAccordionItem.ts +22 -0
- package/src/Accordion/hooks/useAccordionItemContext.ts +1 -0
- package/src/Accordion/hooks/useAccordionRoot.ts +151 -0
- package/src/Accordion/hooks/useAccordionTrigger.ts +90 -0
- package/src/Accordion/index.ts +1 -0
- package/src/Accordion/types.ts +81 -0
- package/src/Alert/Alert.tsx +43 -0
- package/src/Alert/README.md +54 -0
- package/src/Alert/__tests__/Alert.test.tsx +28 -0
- package/src/Alert/index.ts +2 -0
- package/src/Alert/types.ts +5 -0
- package/src/Avatar/Avatar.tsx +149 -0
- package/src/Avatar/AvatarContext.ts +20 -0
- package/src/Avatar/README.md +116 -0
- package/src/Avatar/__tests__/Avatar.asChild.test.tsx +53 -0
- package/src/Avatar/__tests__/Avatar.basic-rendering.test.tsx +14 -0
- package/src/Avatar/__tests__/Avatar.error-handling.test.tsx +30 -0
- package/src/Avatar/__tests__/Avatar.fallback.test.tsx +75 -0
- package/src/Avatar/__tests__/Avatar.image-loading.test.tsx +81 -0
- package/src/Avatar/hooks/index.ts +2 -0
- package/src/Avatar/hooks/useAvatarContext.ts +1 -0
- package/src/Avatar/hooks/useAvatarImage.ts +40 -0
- package/src/Avatar/index.ts +3 -0
- package/src/Avatar/types.ts +44 -0
- package/src/Breadcrumb/Breadcrumb.tsx +234 -0
- package/src/Breadcrumb/README.md +111 -0
- package/src/Breadcrumb/__tests__/Breadcrumb.asChild.test.tsx +33 -0
- package/src/Breadcrumb/__tests__/Breadcrumb.basic-rendering.test.tsx +132 -0
- package/src/Breadcrumb/index.ts +2 -0
- package/src/Breadcrumb/types.ts +22 -0
- package/src/Button/Button.tsx +95 -0
- package/src/Button/README.md +112 -0
- package/src/Button/__tests__/Button.asChild.test.tsx +91 -0
- package/src/Button/__tests__/Button.basic-rendering.test.tsx +126 -0
- package/src/Button/__tests__/Button.contract.test.tsx +72 -0
- package/src/Button/__tests__/Button.disabled.test.tsx +52 -0
- package/src/Button/__tests__/Button.icon-usage.test.tsx +57 -0
- package/src/Button/__tests__/Button.keyboard-interaction.test.tsx +70 -0
- package/src/Button/index.ts +2 -0
- package/src/Button/types.ts +8 -0
- package/src/Carousel/Carousel.tsx +708 -0
- package/src/Carousel/CarouselContext.ts +11 -0
- package/src/Carousel/README.md +848 -0
- package/src/Carousel/__tests__/Carousel.asChild.test.tsx +178 -0
- package/src/Carousel/__tests__/Carousel.auto-play.test.tsx +617 -0
- package/src/Carousel/__tests__/Carousel.basic-rendering.test.tsx +569 -0
- package/src/Carousel/__tests__/Carousel.controlled-state.test.tsx +137 -0
- package/src/Carousel/__tests__/Carousel.error-handling.test.tsx +81 -0
- package/src/Carousel/__tests__/Carousel.ids.test.tsx +111 -0
- package/src/Carousel/__tests__/Carousel.imperative-api.test.tsx +213 -0
- package/src/Carousel/__tests__/Carousel.indicators.test.tsx +560 -0
- package/src/Carousel/__tests__/Carousel.intersection-observer.test.tsx +276 -0
- package/src/Carousel/__tests__/Carousel.keyboard-navigation.test.tsx +158 -0
- package/src/Carousel/__tests__/Carousel.play-pause.test.tsx +232 -0
- package/src/Carousel/__tests__/Carousel.prev-next.test.tsx +68 -0
- package/src/Carousel/__tests__/Carousel.reduced-motion.test.tsx +49 -0
- package/src/Carousel/__tests__/Carousel.refresh-progress.test.tsx +87 -0
- package/src/Carousel/__tests__/Carousel.scroll-snap-change.test.tsx +179 -0
- package/src/Carousel/__tests__/Carousel.scroll-sync.test.tsx +109 -0
- package/src/Carousel/__tests__/Carousel.slides-per-move.test.tsx +151 -0
- package/src/Carousel/__tests__/Carousel.slides-per-page.test.tsx +183 -0
- package/src/Carousel/__tests__/Carousel.touch-interaction.test.tsx +96 -0
- package/src/Carousel/__tests__/Carousel.transition-modes.test.tsx +70 -0
- package/src/Carousel/__tests__/Carousel.translations.test.tsx +157 -0
- package/src/Carousel/__tests__/Carousel.uncontrolled-state.test.tsx +146 -0
- package/src/Carousel/hooks/index.ts +4 -0
- package/src/Carousel/hooks/useCarouselContext.ts +13 -0
- package/src/Carousel/hooks/useCarouselRoot.ts +450 -0
- package/src/Carousel/hooks/useCarouselSlide.ts +45 -0
- package/src/Carousel/hooks/useCarouselViewport.ts +290 -0
- package/src/Carousel/index.ts +3 -0
- package/src/Carousel/types.ts +400 -0
- package/src/Checkbox/Checkbox.tsx +228 -0
- package/src/Checkbox/CheckboxContext.ts +12 -0
- package/src/Checkbox/README.md +156 -0
- package/src/Checkbox/__tests__/Checkbox.asChild.test.tsx +69 -0
- package/src/Checkbox/__tests__/Checkbox.basic-rendering.test.tsx +41 -0
- package/src/Checkbox/__tests__/Checkbox.controlled-state.test.tsx +82 -0
- package/src/Checkbox/__tests__/Checkbox.disabled.test.tsx +15 -0
- package/src/Checkbox/__tests__/Checkbox.indeterminate.test.tsx +82 -0
- package/src/Checkbox/__tests__/Checkbox.indicator.test.tsx +117 -0
- package/src/Checkbox/__tests__/Checkbox.uncontrolled-state.test.tsx +89 -0
- package/src/Checkbox/hooks/index.ts +2 -0
- package/src/Checkbox/hooks/useCheckboxContext.ts +1 -0
- package/src/Checkbox/hooks/useCheckboxRoot.ts +32 -0
- package/src/Checkbox/index.ts +1 -0
- package/src/Checkbox/types.ts +33 -0
- package/src/CheckboxCard/CheckboxCard.tsx +208 -0
- package/src/CheckboxCard/CheckboxCardContext.ts +12 -0
- package/src/CheckboxCard/README.md +114 -0
- package/src/CheckboxCard/__tests__/CheckboxCard.asChild.test.tsx +54 -0
- package/src/CheckboxCard/__tests__/CheckboxCard.basic-rendering.test.tsx +58 -0
- package/src/CheckboxCard/__tests__/CheckboxCard.controlled-state.test.tsx +77 -0
- package/src/CheckboxCard/__tests__/CheckboxCard.disabled.test.tsx +55 -0
- package/src/CheckboxCard/__tests__/CheckboxCard.error-handling.test.tsx +20 -0
- package/src/CheckboxCard/__tests__/CheckboxCard.indeterminate.test.tsx +60 -0
- package/src/CheckboxCard/__tests__/CheckboxCard.indicator.test.tsx +136 -0
- package/src/CheckboxCard/__tests__/CheckboxCard.uncontrolled-state.test.tsx +73 -0
- package/src/CheckboxCard/hooks/index.ts +2 -0
- package/src/CheckboxCard/hooks/useCheckboxCardContext.ts +1 -0
- package/src/CheckboxCard/hooks/useCheckboxCardRoot.ts +30 -0
- package/src/CheckboxCard/index.ts +3 -0
- package/src/CheckboxCard/types.ts +33 -0
- package/src/Collapsible/Collapsible.tsx +316 -0
- package/src/Collapsible/CollapsibleContext.ts +7 -0
- package/src/Collapsible/README.md +174 -0
- package/src/Collapsible/__tests__/Collapsible.asChild.test.tsx +240 -0
- package/src/Collapsible/__tests__/Collapsible.basic-rendering.test.tsx +118 -0
- package/src/Collapsible/__tests__/Collapsible.controlled-state.test.tsx +134 -0
- package/src/Collapsible/__tests__/Collapsible.disabled.test.tsx +132 -0
- package/src/Collapsible/__tests__/Collapsible.error-handling.test.tsx +40 -0
- package/src/Collapsible/__tests__/Collapsible.forceMount.test.tsx +111 -0
- package/src/Collapsible/__tests__/Collapsible.triggerIcon.test.tsx +93 -0
- package/src/Collapsible/__tests__/Collapsible.uncontrolled-state.test.tsx +125 -0
- package/src/Collapsible/hooks/index.ts +2 -0
- package/src/Collapsible/hooks/useCollapsibleRoot.ts +34 -0
- package/src/Collapsible/hooks/useCollapsibleTrigger.ts +49 -0
- package/src/Collapsible/index.ts +1 -0
- package/src/Collapsible/types.ts +48 -0
- package/src/ContextMenu/ContextMenu.tsx +1004 -0
- package/src/ContextMenu/ContextMenuContentContext.ts +15 -0
- package/src/ContextMenu/ContextMenuContext.ts +21 -0
- package/src/ContextMenu/ContextMenuGroupContext.ts +8 -0
- package/src/ContextMenu/ContextMenuItemIndicatorContext.ts +8 -0
- package/src/ContextMenu/ContextMenuRadioGroupContext.ts +9 -0
- package/src/ContextMenu/ContextMenuSubContext.ts +15 -0
- package/src/ContextMenu/README.md +275 -0
- package/src/ContextMenu/__tests__/ContextMenu.asChild.test.tsx +186 -0
- package/src/ContextMenu/__tests__/ContextMenu.basic-rendering.test.tsx +39 -0
- package/src/ContextMenu/__tests__/ContextMenu.checkbox-item.test.tsx +145 -0
- package/src/ContextMenu/__tests__/ContextMenu.error-handling.test.tsx +113 -0
- package/src/ContextMenu/__tests__/ContextMenu.group-label.test.tsx +48 -0
- package/src/ContextMenu/__tests__/ContextMenu.item-indicator.test.tsx +88 -0
- package/src/ContextMenu/__tests__/ContextMenu.item.test.tsx +106 -0
- package/src/ContextMenu/__tests__/ContextMenu.keyboard-interaction.test.tsx +172 -0
- package/src/ContextMenu/__tests__/ContextMenu.mouse-interaction.test.tsx +227 -0
- package/src/ContextMenu/__tests__/ContextMenu.radio-item.test.tsx +127 -0
- package/src/ContextMenu/__tests__/ContextMenu.reading-direction.test.tsx +152 -0
- package/src/ContextMenu/__tests__/ContextMenu.separator.test.tsx +47 -0
- package/src/ContextMenu/__tests__/ContextMenu.state-modes.test.tsx +119 -0
- package/src/ContextMenu/__tests__/ContextMenu.sub.test.tsx +262 -0
- package/src/ContextMenu/__tests__/ContextMenu.typeahead.test.tsx +89 -0
- package/src/ContextMenu/constants.ts +4 -0
- package/src/ContextMenu/index.ts +1 -0
- package/src/ContextMenu/types.ts +199 -0
- package/src/DirectionProvider/DirectionContext.ts +21 -0
- package/src/DirectionProvider/DirectionProvider.tsx +31 -0
- package/src/DirectionProvider/README.md +62 -0
- package/src/DirectionProvider/__tests__/DirectionProvider.test.tsx +29 -0
- package/src/DirectionProvider/index.ts +3 -0
- package/src/DirectionProvider/types.ts +10 -0
- package/src/Divider/Divider.tsx +57 -0
- package/src/Divider/README.md +57 -0
- package/src/Divider/__tests__/Divider.test.tsx +41 -0
- package/src/Divider/index.ts +1 -0
- package/src/Divider/types.ts +5 -0
- package/src/Dropdown/Dropdown.tsx +842 -0
- package/src/Dropdown/DropdownContentContext.ts +15 -0
- package/src/Dropdown/DropdownContext.ts +17 -0
- package/src/Dropdown/DropdownGroupContext.ts +8 -0
- package/src/Dropdown/DropdownItemIndicatorContext.ts +13 -0
- package/src/Dropdown/DropdownRadioGroupContext.ts +9 -0
- package/src/Dropdown/DropdownSubContext.ts +15 -0
- package/src/Dropdown/README.md +284 -0
- package/src/Dropdown/__tests__/Dropdown.asChild.test.tsx +286 -0
- package/src/Dropdown/__tests__/Dropdown.basic-rendering.test.tsx +43 -0
- package/src/Dropdown/__tests__/Dropdown.checkbox-item.test.tsx +121 -0
- package/src/Dropdown/__tests__/Dropdown.disabled.test.tsx +143 -0
- package/src/Dropdown/__tests__/Dropdown.error-handling.test.tsx +85 -0
- package/src/Dropdown/__tests__/Dropdown.group-label.test.tsx +68 -0
- package/src/Dropdown/__tests__/Dropdown.item-indicator.test.tsx +260 -0
- package/src/Dropdown/__tests__/Dropdown.item.test.tsx +72 -0
- package/src/Dropdown/__tests__/Dropdown.keyboard-edge-cases.test.tsx +77 -0
- package/src/Dropdown/__tests__/Dropdown.keyboard-interaction.test.tsx +310 -0
- package/src/Dropdown/__tests__/Dropdown.mouse-interaction.test.tsx +347 -0
- package/src/Dropdown/__tests__/Dropdown.radio-item.test.tsx +134 -0
- package/src/Dropdown/__tests__/Dropdown.reading-direction.test.tsx +153 -0
- package/src/Dropdown/__tests__/Dropdown.separator.test.tsx +46 -0
- package/src/Dropdown/__tests__/Dropdown.state-modes.test.tsx +100 -0
- package/src/Dropdown/__tests__/Dropdown.sub.test.tsx +185 -0
- package/src/Dropdown/__tests__/Dropdown.trigger.test.tsx +110 -0
- package/src/Dropdown/__tests__/Dropdown.typeahead.test.tsx +133 -0
- package/src/Dropdown/constants.ts +4 -0
- package/src/Dropdown/hooks/index.ts +9 -0
- package/src/Dropdown/hooks/useCloseSiblingSub.ts +13 -0
- package/src/Dropdown/hooks/useDropdownContent.ts +162 -0
- package/src/Dropdown/hooks/useDropdownContext.ts +1 -0
- package/src/Dropdown/hooks/useDropdownGroup.ts +18 -0
- package/src/Dropdown/hooks/useDropdownItem.ts +49 -0
- package/src/Dropdown/hooks/useDropdownLabel.ts +15 -0
- package/src/Dropdown/hooks/useDropdownRoot.ts +57 -0
- package/src/Dropdown/hooks/useDropdownSubContext.ts +1 -0
- package/src/Dropdown/hooks/useDropdownTrigger.ts +31 -0
- package/src/Dropdown/index.ts +1 -0
- package/src/Dropdown/types.ts +200 -0
- package/src/EmptyState/EmptyState.tsx +245 -0
- package/src/EmptyState/README.md +129 -0
- package/src/EmptyState/__tests__/EmptyState.Actions.test.tsx +32 -0
- package/src/EmptyState/__tests__/EmptyState.Description.test.tsx +30 -0
- package/src/EmptyState/__tests__/EmptyState.Media.test.tsx +34 -0
- package/src/EmptyState/__tests__/EmptyState.Root.test.tsx +28 -0
- package/src/EmptyState/__tests__/EmptyState.Title.test.tsx +26 -0
- package/src/EmptyState/index.ts +2 -0
- package/src/EmptyState/types.ts +21 -0
- package/src/Field/Field.tsx +239 -0
- package/src/Field/FieldContext.ts +22 -0
- package/src/Field/README.md +167 -0
- package/src/Field/__tests__/Field.asChild.test.tsx +83 -0
- package/src/Field/__tests__/Field.basic-rendering.test.tsx +104 -0
- package/src/Field/__tests__/Field.state-cascade.test.tsx +75 -0
- package/src/Field/hooks/index.ts +2 -0
- package/src/Field/hooks/useFieldContext.ts +1 -0
- package/src/Field/hooks/useFieldProps.ts +57 -0
- package/src/Field/index.ts +2 -0
- package/src/Field/types.ts +33 -0
- package/src/Fieldset/Fieldset.tsx +104 -0
- package/src/Fieldset/README.md +74 -0
- package/src/Fieldset/__tests__/Fieldset.basic-rendering.test.tsx +81 -0
- package/src/Fieldset/__tests__/Fieldset.disabled.test.tsx +41 -0
- package/src/Fieldset/index.ts +2 -0
- package/src/Fieldset/types.ts +5 -0
- package/src/Input/Input.tsx +120 -0
- package/src/Input/README.md +180 -0
- package/src/Input/__tests__/Input.asChild.test.tsx +85 -0
- package/src/Input/__tests__/Input.basic-rendering.test.tsx +118 -0
- package/src/Input/__tests__/Input.disabled.test.tsx +49 -0
- package/src/Input/__tests__/Input.field-integration.test.tsx +148 -0
- package/src/Input/index.ts +2 -0
- package/src/Input/types.ts +7 -0
- package/src/InputGroup/InputGroup.tsx +228 -0
- package/src/InputGroup/README.md +178 -0
- package/src/InputGroup/__tests__/InputGroup.asChild.test.tsx +109 -0
- package/src/InputGroup/__tests__/InputGroup.basic-rendering.test.tsx +106 -0
- package/src/InputGroup/index.ts +2 -0
- package/src/InputGroup/types.ts +13 -0
- package/src/MillerColumns/MillerColumns.tsx +329 -0
- package/src/MillerColumns/MillerColumnsContext.ts +25 -0
- package/src/MillerColumns/README.md +278 -0
- package/src/MillerColumns/__tests__/MillerColumns.aria.test.tsx +82 -0
- package/src/MillerColumns/__tests__/MillerColumns.asChild.test.tsx +106 -0
- package/src/MillerColumns/__tests__/MillerColumns.auto-scroll.test.tsx +68 -0
- package/src/MillerColumns/__tests__/MillerColumns.basic-rendering.test.tsx +52 -0
- package/src/MillerColumns/__tests__/MillerColumns.column-projection.test.tsx +161 -0
- package/src/MillerColumns/__tests__/MillerColumns.controlled-state.test.tsx +90 -0
- package/src/MillerColumns/__tests__/MillerColumns.data-attributes.test.tsx +77 -0
- package/src/MillerColumns/__tests__/MillerColumns.disabled-items.test.tsx +65 -0
- package/src/MillerColumns/__tests__/MillerColumns.error-handling.test.tsx +57 -0
- package/src/MillerColumns/__tests__/MillerColumns.fixtures.ts +15 -0
- package/src/MillerColumns/__tests__/MillerColumns.item-indicator.test.tsx +57 -0
- package/src/MillerColumns/__tests__/MillerColumns.keyboard-interaction.test.tsx +181 -0
- package/src/MillerColumns/__tests__/MillerColumns.preview-panel.test.tsx +47 -0
- package/src/MillerColumns/__tests__/MillerColumns.resize.test.tsx +137 -0
- package/src/MillerColumns/__tests__/MillerColumns.roving-tabindex.test.tsx +91 -0
- package/src/MillerColumns/__tests__/MillerColumns.selection.test.tsx +54 -0
- package/src/MillerColumns/__tests__/MillerColumns.uncontrolled-state.test.tsx +70 -0
- package/src/MillerColumns/hooks/index.ts +7 -0
- package/src/MillerColumns/hooks/useMillerColumnsColumn.ts +23 -0
- package/src/MillerColumns/hooks/useMillerColumnsColumnContext.ts +1 -0
- package/src/MillerColumns/hooks/useMillerColumnsContext.ts +1 -0
- package/src/MillerColumns/hooks/useMillerColumnsItem.ts +157 -0
- package/src/MillerColumns/hooks/useMillerColumnsItemContext.ts +1 -0
- package/src/MillerColumns/hooks/useMillerColumnsResizeHandle.ts +76 -0
- package/src/MillerColumns/hooks/useMillerColumnsRoot.ts +0 -0
- package/src/MillerColumns/index.ts +3 -0
- package/src/MillerColumns/types.ts +93 -0
- package/src/MillerColumns/useMillerColumnsSelection.ts +31 -0
- package/src/MillerColumns/utils.ts +75 -0
- package/src/Modal/Modal.tsx +474 -0
- package/src/Modal/ModalContext.ts +13 -0
- package/src/Modal/README.md +207 -0
- package/src/Modal/__tests__/Modal.accessibility.test.tsx +167 -0
- package/src/Modal/__tests__/Modal.asChild.test.tsx +162 -0
- package/src/Modal/__tests__/Modal.click-outside.test.tsx +115 -0
- package/src/Modal/__tests__/Modal.content.test.tsx +193 -0
- package/src/Modal/__tests__/Modal.controlled-state.test.tsx +120 -0
- package/src/Modal/__tests__/Modal.error-handling.test.tsx +30 -0
- package/src/Modal/__tests__/Modal.escape-hatches.test.tsx +99 -0
- package/src/Modal/__tests__/Modal.imperative-api.test.tsx +119 -0
- package/src/Modal/__tests__/Modal.nested.test.tsx +106 -0
- package/src/Modal/__tests__/Modal.overlay.test.tsx +99 -0
- package/src/Modal/__tests__/Modal.portal.test.tsx +90 -0
- package/src/Modal/__tests__/Modal.presence.test.tsx +111 -0
- package/src/Modal/__tests__/Modal.trigger.test.tsx +70 -0
- package/src/Modal/__tests__/Modal.uncontrolled-state.test.tsx +72 -0
- package/src/Modal/__tests__/dialog-polyfill.ts +40 -0
- package/src/Modal/hooks/index.ts +4 -0
- package/src/Modal/hooks/useModalContent.ts +62 -0
- package/src/Modal/hooks/useModalContext.ts +1 -0
- package/src/Modal/hooks/useModalRoot.ts +81 -0
- package/src/Modal/hooks/useModalTrigger.ts +25 -0
- package/src/Modal/index.ts +3 -0
- package/src/Modal/types.ts +76 -0
- package/src/Portal/Portal.tsx +28 -0
- package/src/Portal/README.md +70 -0
- package/src/Portal/__tests__/Portal.basic-rendering.test.tsx +17 -0
- package/src/Portal/index.ts +2 -0
- package/src/Portal/types.ts +6 -0
- package/src/Progress/Progress.tsx +178 -0
- package/src/Progress/ProgressContext.ts +15 -0
- package/src/Progress/README.md +112 -0
- package/src/Progress/__tests__/Progress.asChild.test.tsx +37 -0
- package/src/Progress/__tests__/Progress.basic-rendering.test.tsx +65 -0
- package/src/Progress/__tests__/Progress.error-handling.test.tsx +40 -0
- package/src/Progress/__tests__/Progress.fixtures.ts +7 -0
- package/src/Progress/__tests__/Progress.value.test.tsx +83 -0
- package/src/Progress/hooks/index.ts +2 -0
- package/src/Progress/hooks/useProgressContext.ts +1 -0
- package/src/Progress/hooks/useProgressRoot.ts +45 -0
- package/src/Progress/index.ts +3 -0
- package/src/Progress/types.ts +43 -0
- package/src/RadioCard/README.md +133 -0
- package/src/RadioCard/RadioCard.tsx +334 -0
- package/src/RadioCard/RadioCardContext.ts +23 -0
- package/src/RadioCard/RadioCardItemContext.ts +10 -0
- package/src/RadioCard/__tests__/RadioCard.asChild.test.tsx +76 -0
- package/src/RadioCard/__tests__/RadioCard.basic-rendering.test.tsx +87 -0
- package/src/RadioCard/__tests__/RadioCard.controlled-state.test.tsx +107 -0
- package/src/RadioCard/__tests__/RadioCard.disabled-items.test.tsx +61 -0
- package/src/RadioCard/__tests__/RadioCard.error-handling.test.tsx +35 -0
- package/src/RadioCard/__tests__/RadioCard.indicator.test.tsx +119 -0
- package/src/RadioCard/__tests__/RadioCard.keyboard-interaction.test.tsx +158 -0
- package/src/RadioCard/__tests__/RadioCard.orientation.test.tsx +90 -0
- package/src/RadioCard/__tests__/RadioCard.reading-direction.test.tsx +65 -0
- package/src/RadioCard/__tests__/RadioCard.uncontrolled-state.test.tsx +108 -0
- package/src/RadioCard/hooks/index.ts +3 -0
- package/src/RadioCard/hooks/useRadioCardContext.ts +1 -0
- package/src/RadioCard/hooks/useRadioCardItemContext.ts +1 -0
- package/src/RadioCard/hooks/useRadioCardRoot.ts +77 -0
- package/src/RadioCard/index.ts +4 -0
- package/src/RadioCard/types.ts +51 -0
- package/src/RadioGroup/README.md +185 -0
- package/src/RadioGroup/RadioGroup.tsx +353 -0
- package/src/RadioGroup/RadioGroupContext.ts +23 -0
- package/src/RadioGroup/RadioGroupItemContext.ts +10 -0
- package/src/RadioGroup/__tests__/RadioGroup.asChild.test.tsx +105 -0
- package/src/RadioGroup/__tests__/RadioGroup.basic-rendering.test.tsx +72 -0
- package/src/RadioGroup/__tests__/RadioGroup.controlled-state.test.tsx +109 -0
- package/src/RadioGroup/__tests__/RadioGroup.disabled-keydown-guards.test.tsx +68 -0
- package/src/RadioGroup/__tests__/RadioGroup.disabled.test.tsx +79 -0
- package/src/RadioGroup/__tests__/RadioGroup.error-handling.test.tsx +33 -0
- package/src/RadioGroup/__tests__/RadioGroup.indicator.test.tsx +85 -0
- package/src/RadioGroup/__tests__/RadioGroup.keyboard-interaction.test.tsx +135 -0
- package/src/RadioGroup/__tests__/RadioGroup.orientation.test.tsx +90 -0
- package/src/RadioGroup/__tests__/RadioGroup.reading-direction.test.tsx +65 -0
- package/src/RadioGroup/__tests__/RadioGroup.ref-forwarding.test.tsx +45 -0
- package/src/RadioGroup/__tests__/RadioGroup.roving-tabindex.test.tsx +105 -0
- package/src/RadioGroup/__tests__/RadioGroup.uncontrolled-state.test.tsx +96 -0
- package/src/RadioGroup/hooks/index.ts +3 -0
- package/src/RadioGroup/hooks/useRadioGroupContext.ts +1 -0
- package/src/RadioGroup/hooks/useRadioGroupItemContext.ts +1 -0
- package/src/RadioGroup/hooks/useRadioGroupRoot.ts +87 -0
- package/src/RadioGroup/index.ts +1 -0
- package/src/RadioGroup/types.ts +51 -0
- package/src/Select/README.md +203 -0
- package/src/Select/Select.tsx +204 -0
- package/src/Select/__tests__/Select.asChild.test.tsx +36 -0
- package/src/Select/__tests__/Select.basic-rendering.test.tsx +17 -0
- package/src/Select/__tests__/Select.controlled-state.test.tsx +69 -0
- package/src/Select/__tests__/Select.data-attributes.test.tsx +29 -0
- package/src/Select/__tests__/Select.field-integration.test.tsx +150 -0
- package/src/Select/__tests__/Select.group.test.tsx +42 -0
- package/src/Select/__tests__/Select.placeholder.test.tsx +32 -0
- package/src/Select/index.ts +2 -0
- package/src/Select/types.ts +89 -0
- package/src/SkipNav/README.md +87 -0
- package/src/SkipNav/SkipNav.tsx +116 -0
- package/src/SkipNav/__tests__/SkipNav.basic-rendering.test.tsx +23 -0
- package/src/SkipNav/__tests__/SkipNav.ids.test.tsx +19 -0
- package/src/SkipNav/index.ts +1 -0
- package/src/SkipNav/types.ts +26 -0
- package/src/Slider/README.md +215 -0
- package/src/Slider/Slider.tsx +308 -0
- package/src/Slider/SliderContext.ts +24 -0
- package/src/Slider/__tests__/Slider.asChild.test.tsx +119 -0
- package/src/Slider/__tests__/Slider.basic-rendering.test.tsx +157 -0
- package/src/Slider/__tests__/Slider.controlled-state.test.tsx +78 -0
- package/src/Slider/__tests__/Slider.disabled.test.tsx +82 -0
- package/src/Slider/__tests__/Slider.error-handling.test.tsx +45 -0
- package/src/Slider/__tests__/Slider.fixtures.ts +53 -0
- package/src/Slider/__tests__/Slider.form.test.tsx +67 -0
- package/src/Slider/__tests__/Slider.inverted.test.tsx +112 -0
- package/src/Slider/__tests__/Slider.keyboard-interaction.test.tsx +118 -0
- package/src/Slider/__tests__/Slider.multiple-thumbs.test.tsx +84 -0
- package/src/Slider/__tests__/Slider.orientation.test.tsx +101 -0
- package/src/Slider/__tests__/Slider.pointer-interaction.test.tsx +205 -0
- package/src/Slider/__tests__/Slider.reading-direction.test.tsx +99 -0
- package/src/Slider/__tests__/Slider.uncontrolled-state.test.tsx +69 -0
- package/src/Slider/__tests__/Slider.value-commit.test.tsx +103 -0
- package/src/Slider/hooks/index.ts +3 -0
- package/src/Slider/hooks/useSliderContext.ts +1 -0
- package/src/Slider/hooks/useSliderRoot.ts +197 -0
- package/src/Slider/hooks/useSliderThumb.ts +77 -0
- package/src/Slider/index.ts +3 -0
- package/src/Slider/types.ts +48 -0
- package/src/Slider/utils.ts +155 -0
- package/src/Slot/Slot.tsx +158 -0
- package/src/Slot/__tests__/Slot.test.tsx +163 -0
- package/src/Slot/__tests__/composeEventHandlers.test.ts +74 -0
- package/src/Slot/composeEventHandlers.ts +38 -0
- package/src/Slot/index.ts +3 -0
- package/src/Slot/types.ts +5 -0
- package/src/Status/README.md +50 -0
- package/src/Status/Status.tsx +44 -0
- package/src/Status/__tests__/Status.test.tsx +28 -0
- package/src/Status/index.ts +2 -0
- package/src/Status/types.ts +5 -0
- package/src/Switch/README.md +121 -0
- package/src/Switch/Switch.tsx +167 -0
- package/src/Switch/SwitchContext.ts +10 -0
- package/src/Switch/__tests__/Switch.asChild.test.tsx +56 -0
- package/src/Switch/__tests__/Switch.basic-rendering.test.tsx +76 -0
- package/src/Switch/__tests__/Switch.contract.test.tsx +109 -0
- package/src/Switch/__tests__/Switch.controlled-state.test.tsx +79 -0
- package/src/Switch/__tests__/Switch.disabled.test.tsx +60 -0
- package/src/Switch/__tests__/Switch.error-handling.test.tsx +20 -0
- package/src/Switch/__tests__/Switch.keyboard-interaction.test.tsx +56 -0
- package/src/Switch/__tests__/Switch.thumb.test.tsx +84 -0
- package/src/Switch/__tests__/Switch.uncontrolled-state.test.tsx +83 -0
- package/src/Switch/hooks/index.ts +2 -0
- package/src/Switch/hooks/useSwitchContext.ts +1 -0
- package/src/Switch/hooks/useSwitchRoot.ts +28 -0
- package/src/Switch/index.ts +3 -0
- package/src/Switch/types.ts +37 -0
- package/src/Table/README.md +205 -0
- package/src/Table/Table.tsx +380 -0
- package/src/Table/__tests__/Table.Body.test.tsx +61 -0
- package/src/Table/__tests__/Table.Caption.test.tsx +70 -0
- package/src/Table/__tests__/Table.Cell.test.tsx +73 -0
- package/src/Table/__tests__/Table.Footer.test.tsx +61 -0
- package/src/Table/__tests__/Table.Head.test.tsx +61 -0
- package/src/Table/__tests__/Table.Header.test.tsx +73 -0
- package/src/Table/__tests__/Table.Root.test.tsx +49 -0
- package/src/Table/__tests__/Table.Row.test.tsx +67 -0
- package/src/Table/__tests__/Table.ScrollArea.test.tsx +83 -0
- package/src/Table/index.ts +1 -0
- package/src/Table/types.ts +63 -0
- package/src/Tabs/README.md +110 -0
- package/src/Tabs/Tabs.tsx +434 -0
- package/src/Tabs/TabsContext.ts +13 -0
- package/src/Tabs/__tests__/Tabs.activation-mode.test.tsx +114 -0
- package/src/Tabs/__tests__/Tabs.asChild.test.tsx +91 -0
- package/src/Tabs/__tests__/Tabs.basic-rendering.test.tsx +483 -0
- package/src/Tabs/__tests__/Tabs.change-event-callbacks.test.tsx +133 -0
- package/src/Tabs/__tests__/Tabs.controlled-state.test.tsx +152 -0
- package/src/Tabs/__tests__/Tabs.disabled-tabs.test.tsx +203 -0
- package/src/Tabs/__tests__/Tabs.error-handling.test.tsx +82 -0
- package/src/Tabs/__tests__/Tabs.fixtures.ts +171 -0
- package/src/Tabs/__tests__/Tabs.imperative-api.test.tsx +118 -0
- package/src/Tabs/__tests__/Tabs.keyboard-interaction.test.tsx +192 -0
- package/src/Tabs/__tests__/Tabs.lazy-mount.test.tsx +61 -0
- package/src/Tabs/__tests__/Tabs.mouse-interaction.test.tsx +216 -0
- package/src/Tabs/__tests__/Tabs.reading-direction.test.tsx +58 -0
- package/src/Tabs/__tests__/Tabs.uncontrolled-state.test.tsx +197 -0
- package/src/Tabs/hooks/index.ts +4 -0
- package/src/Tabs/hooks/useTabsContent.ts +27 -0
- package/src/Tabs/hooks/useTabsContext.ts +1 -0
- package/src/Tabs/hooks/useTabsRoot.ts +148 -0
- package/src/Tabs/hooks/useTabsTrigger.ts +111 -0
- package/src/Tabs/index.ts +3 -0
- package/src/Tabs/types.ts +99 -0
- package/src/Tabs/utils.ts +8 -0
- package/src/Textarea/README.md +98 -0
- package/src/Textarea/Textarea.tsx +93 -0
- package/src/Textarea/__tests__/Textarea.asChild.test.tsx +85 -0
- package/src/Textarea/__tests__/Textarea.basic-rendering.test.tsx +107 -0
- package/src/Textarea/__tests__/Textarea.disabled.test.tsx +49 -0
- package/src/Textarea/__tests__/Textarea.field-integration.test.tsx +134 -0
- package/src/Textarea/index.ts +2 -0
- package/src/Textarea/types.ts +7 -0
- package/src/Toggle/README.md +97 -0
- package/src/Toggle/Toggle.tsx +81 -0
- package/src/Toggle/__tests__/Toggle.asChild.test.tsx +42 -0
- package/src/Toggle/__tests__/Toggle.basic-rendering.test.tsx +28 -0
- package/src/Toggle/__tests__/Toggle.controlled-state.test.tsx +60 -0
- package/src/Toggle/__tests__/Toggle.disabled.test.tsx +34 -0
- package/src/Toggle/__tests__/Toggle.keyboard-interaction.test.tsx +42 -0
- package/src/Toggle/__tests__/Toggle.uncontrolled-state.test.tsx +40 -0
- package/src/Toggle/index.ts +2 -0
- package/src/Toggle/types.ts +23 -0
- package/src/ToggleGroup/README.md +137 -0
- package/src/ToggleGroup/ToggleGroup.tsx +298 -0
- package/src/ToggleGroup/ToggleGroupContext.ts +9 -0
- package/src/ToggleGroup/__tests__/ToggleGroup.asChild.test.tsx +65 -0
- package/src/ToggleGroup/__tests__/ToggleGroup.basic-rendering.test.tsx +50 -0
- package/src/ToggleGroup/__tests__/ToggleGroup.disabled.test.tsx +54 -0
- package/src/ToggleGroup/__tests__/ToggleGroup.keyboard-interaction.test.tsx +151 -0
- package/src/ToggleGroup/__tests__/ToggleGroup.multiple-mode.test.tsx +144 -0
- package/src/ToggleGroup/__tests__/ToggleGroup.reading-direction.test.tsx +28 -0
- package/src/ToggleGroup/__tests__/ToggleGroup.single-mode.test.tsx +139 -0
- package/src/ToggleGroup/hooks/index.ts +2 -0
- package/src/ToggleGroup/hooks/useToggleGroupContext.ts +1 -0
- package/src/ToggleGroup/hooks/useToggleGroupRoot.ts +110 -0
- package/src/ToggleGroup/index.ts +2 -0
- package/src/ToggleGroup/types.ts +72 -0
- package/src/Tooltip/README.md +214 -0
- package/src/Tooltip/Tooltip.tsx +260 -0
- package/src/Tooltip/TooltipContext.ts +20 -0
- package/src/Tooltip/__tests__/Tooltip.asChild.test.tsx +77 -0
- package/src/Tooltip/__tests__/Tooltip.basic-rendering.test.tsx +180 -0
- package/src/Tooltip/__tests__/Tooltip.controlled-state.test.tsx +128 -0
- package/src/Tooltip/__tests__/Tooltip.escape-hatches.test.tsx +73 -0
- package/src/Tooltip/__tests__/Tooltip.focus-interaction.test.tsx +88 -0
- package/src/Tooltip/__tests__/Tooltip.hover-interaction.test.tsx +179 -0
- package/src/Tooltip/__tests__/Tooltip.keyboard-interaction.test.tsx +85 -0
- package/src/Tooltip/__tests__/Tooltip.uncontrolled-state.test.tsx +67 -0
- package/src/Tooltip/hooks/index.ts +4 -0
- package/src/Tooltip/hooks/useTooltipContent.ts +53 -0
- package/src/Tooltip/hooks/useTooltipProvider.ts +41 -0
- package/src/Tooltip/hooks/useTooltipRoot.ts +106 -0
- package/src/Tooltip/hooks/useTooltipTrigger.ts +44 -0
- package/src/Tooltip/index.ts +1 -0
- package/src/Tooltip/types.ts +64 -0
- package/src/Tree/README.md +339 -0
- package/src/Tree/Tree.tsx +571 -0
- package/src/Tree/TreeContext.ts +24 -0
- package/src/Tree/__tests__/Tree.aria.test.tsx +53 -0
- package/src/Tree/__tests__/Tree.asChild.test.tsx +134 -0
- package/src/Tree/__tests__/Tree.basic-rendering.test.tsx +111 -0
- package/src/Tree/__tests__/Tree.branch-behaviour.test.tsx +87 -0
- package/src/Tree/__tests__/Tree.controlled-expansion.test.tsx +92 -0
- package/src/Tree/__tests__/Tree.data-attributes.test.tsx +88 -0
- package/src/Tree/__tests__/Tree.disabled-items.test.tsx +196 -0
- package/src/Tree/__tests__/Tree.error-handling.test.tsx +71 -0
- package/src/Tree/__tests__/Tree.forceMount.test.tsx +72 -0
- package/src/Tree/__tests__/Tree.keyboard-interaction.test.tsx +150 -0
- package/src/Tree/__tests__/Tree.multiple-selection.test.tsx +151 -0
- package/src/Tree/__tests__/Tree.range-selection.test.tsx +200 -0
- package/src/Tree/__tests__/Tree.recursion-depth.test.tsx +73 -0
- package/src/Tree/__tests__/Tree.roving-tabindex.test.tsx +117 -0
- package/src/Tree/__tests__/Tree.selection-path.test.tsx +404 -0
- package/src/Tree/__tests__/Tree.single-selection.test.tsx +108 -0
- package/src/Tree/__tests__/Tree.uncontrolled-expansion.test.tsx +69 -0
- package/src/Tree/hooks/index.ts +3 -0
- package/src/Tree/hooks/useTreeItemKeyboard.ts +86 -0
- package/src/Tree/hooks/useTreePath.ts +68 -0
- package/src/Tree/hooks/useTreeRoot.ts +279 -0
- package/src/Tree/index.ts +3 -0
- package/src/Tree/types.ts +224 -0
- package/src/Tree/utils.ts +59 -0
- package/src/VisuallyHidden/README.md +58 -0
- package/src/VisuallyHidden/VisuallyHidden.tsx +67 -0
- package/src/VisuallyHidden/__tests__/VisuallyHidden.test.tsx +59 -0
- package/src/VisuallyHidden/index.ts +2 -0
- package/src/VisuallyHidden/types.ts +5 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useCollection.ts +74 -0
- package/src/hooks/useControllableState.ts +81 -0
- package/src/hooks/useRovingTabindex.ts +178 -0
- package/src/index.ts +38 -0
- package/src/test/intersectionObserverPolyfill.ts +83 -0
- package/src/test/popoverPolyfill.ts +86 -0
- package/src/test/scrollPolyfill.ts +23 -0
- package/src/types.ts +13 -0
- package/src/utils/__tests__/createStrictContext.test.tsx +69 -0
- package/src/utils/__tests__/deriveId.test.ts +28 -0
- package/src/utils/__tests__/getKeyToActionMap.test.ts +106 -0
- package/src/utils/createStrictContext.ts +49 -0
- package/src/utils/deriveId.ts +31 -0
- package/src/utils/getKeyToActionMap.ts +95 -0
- package/src/utils/index.ts +3 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
|
|
4
|
+
import { MillerColumns } from "../MillerColumns";
|
|
5
|
+
import { useMillerColumnsSelection } from "../useMillerColumnsSelection";
|
|
6
|
+
|
|
7
|
+
function SelectionProbe() {
|
|
8
|
+
const { path, selectedValue } = useMillerColumnsSelection();
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div data-testid="probe" data-selected={selectedValue}>
|
|
12
|
+
{path.join("/")}
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe("MillerColumns — useMillerColumnsSelection", () => {
|
|
18
|
+
it("exposes the active path and the deepest selected value", async () => {
|
|
19
|
+
const user = userEvent.setup();
|
|
20
|
+
|
|
21
|
+
render(
|
|
22
|
+
<MillerColumns.Root>
|
|
23
|
+
<MillerColumns.Column>
|
|
24
|
+
<MillerColumns.Item value="fruit">
|
|
25
|
+
Fruit
|
|
26
|
+
<MillerColumns.Column>
|
|
27
|
+
<MillerColumns.Item value="apple">Apple</MillerColumns.Item>
|
|
28
|
+
</MillerColumns.Column>
|
|
29
|
+
</MillerColumns.Item>
|
|
30
|
+
</MillerColumns.Column>
|
|
31
|
+
<SelectionProbe />
|
|
32
|
+
</MillerColumns.Root>,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const probe = screen.getByTestId("probe");
|
|
36
|
+
|
|
37
|
+
expect(probe).toHaveTextContent("");
|
|
38
|
+
expect(probe).not.toHaveAttribute("data-selected");
|
|
39
|
+
|
|
40
|
+
await user.click(screen.getByRole("treeitem", { name: "Fruit" }));
|
|
41
|
+
|
|
42
|
+
expect(probe).toHaveTextContent("fruit");
|
|
43
|
+
expect(probe).toHaveAttribute("data-selected", "fruit");
|
|
44
|
+
|
|
45
|
+
await user.click(screen.getByRole("treeitem", { name: "Apple" }));
|
|
46
|
+
|
|
47
|
+
expect(probe).toHaveTextContent("fruit/apple");
|
|
48
|
+
expect(probe).toHaveAttribute("data-selected", "apple");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("throws when used outside Root", () => {
|
|
52
|
+
expect(() => render(<SelectionProbe />)).toThrow("<MillerColumns.Root>");
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
|
|
4
|
+
import { MillerColumns } from "../MillerColumns";
|
|
5
|
+
|
|
6
|
+
describe("MillerColumns — uncontrolled state", () => {
|
|
7
|
+
it("selects an item when it is clicked", async () => {
|
|
8
|
+
const user = userEvent.setup();
|
|
9
|
+
|
|
10
|
+
render(
|
|
11
|
+
<MillerColumns.Root>
|
|
12
|
+
<MillerColumns.Column>
|
|
13
|
+
<MillerColumns.Item value="a">A</MillerColumns.Item>
|
|
14
|
+
<MillerColumns.Item value="b">B</MillerColumns.Item>
|
|
15
|
+
</MillerColumns.Column>
|
|
16
|
+
</MillerColumns.Root>,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const itemA = screen.getByRole("treeitem", { name: "A" });
|
|
20
|
+
expect(itemA).toHaveAttribute("aria-selected", "false");
|
|
21
|
+
|
|
22
|
+
await user.click(itemA);
|
|
23
|
+
|
|
24
|
+
expect(itemA).toHaveAttribute("aria-selected", "true");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("starts with the item named by defaultValue selected", () => {
|
|
28
|
+
render(
|
|
29
|
+
<MillerColumns.Root defaultValue={["b"]}>
|
|
30
|
+
<MillerColumns.Column>
|
|
31
|
+
<MillerColumns.Item value="a">A</MillerColumns.Item>
|
|
32
|
+
<MillerColumns.Item value="b">B</MillerColumns.Item>
|
|
33
|
+
</MillerColumns.Column>
|
|
34
|
+
</MillerColumns.Root>,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
expect(screen.getByRole("treeitem", { name: "B" })).toHaveAttribute(
|
|
38
|
+
"aria-selected",
|
|
39
|
+
"true",
|
|
40
|
+
);
|
|
41
|
+
expect(screen.getByRole("treeitem", { name: "A" })).toHaveAttribute(
|
|
42
|
+
"aria-selected",
|
|
43
|
+
"false",
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("moving the selection within a column deselects the previous item", async () => {
|
|
48
|
+
const user = userEvent.setup();
|
|
49
|
+
|
|
50
|
+
render(
|
|
51
|
+
<MillerColumns.Root defaultValue={["a"]}>
|
|
52
|
+
<MillerColumns.Column>
|
|
53
|
+
<MillerColumns.Item value="a">A</MillerColumns.Item>
|
|
54
|
+
<MillerColumns.Item value="b">B</MillerColumns.Item>
|
|
55
|
+
</MillerColumns.Column>
|
|
56
|
+
</MillerColumns.Root>,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
await user.click(screen.getByRole("treeitem", { name: "B" }));
|
|
60
|
+
|
|
61
|
+
expect(screen.getByRole("treeitem", { name: "A" })).toHaveAttribute(
|
|
62
|
+
"aria-selected",
|
|
63
|
+
"false",
|
|
64
|
+
);
|
|
65
|
+
expect(screen.getByRole("treeitem", { name: "B" })).toHaveAttribute(
|
|
66
|
+
"aria-selected",
|
|
67
|
+
"true",
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { useMillerColumnsContext } from "./useMillerColumnsContext";
|
|
2
|
+
export { useMillerColumnsColumnContext } from "./useMillerColumnsColumnContext";
|
|
3
|
+
export { useMillerColumnsItemContext } from "./useMillerColumnsItemContext";
|
|
4
|
+
export { useMillerColumnsRoot } from "./useMillerColumnsRoot";
|
|
5
|
+
export { useMillerColumnsColumn } from "./useMillerColumnsColumn";
|
|
6
|
+
export { useMillerColumnsItem } from "./useMillerColumnsItem";
|
|
7
|
+
export { useMillerColumnsResizeHandle } from "./useMillerColumnsResizeHandle";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useContext, useMemo } from "react";
|
|
2
|
+
|
|
3
|
+
import { MillerColumnsColumnContext } from "../MillerColumnsContext";
|
|
4
|
+
|
|
5
|
+
import type { MillerColumnsColumnContextValue } from "../types";
|
|
6
|
+
|
|
7
|
+
import { useMillerColumnsContext } from "./useMillerColumnsContext";
|
|
8
|
+
|
|
9
|
+
export function useMillerColumnsColumn() {
|
|
10
|
+
const { slots, columnWidths } = useMillerColumnsContext();
|
|
11
|
+
const parentColumn = useContext(MillerColumnsColumnContext);
|
|
12
|
+
const depth = parentColumn ? parentColumn.depth + 1 : 0;
|
|
13
|
+
|
|
14
|
+
const slot = slots.get(depth) ?? null;
|
|
15
|
+
const width = columnWidths.get(depth);
|
|
16
|
+
|
|
17
|
+
const columnContextValue = useMemo<MillerColumnsColumnContextValue>(
|
|
18
|
+
() => ({ depth }),
|
|
19
|
+
[depth],
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return { slot, depth, width, columnContextValue };
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useMillerColumnsColumnContext } from "../MillerColumnsContext";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useMillerColumnsContext } from "../MillerColumnsContext";
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FocusEvent,
|
|
3
|
+
KeyboardEvent,
|
|
4
|
+
MouseEvent,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
} from "react";
|
|
9
|
+
|
|
10
|
+
import { useRovingTabindex } from "../../hooks";
|
|
11
|
+
import { composeRefs } from "../../Slot";
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
MillerColumnsItemContextValue,
|
|
15
|
+
MillerColumnsItemProps,
|
|
16
|
+
} from "../types";
|
|
17
|
+
|
|
18
|
+
import { useMillerColumnsContext } from "./useMillerColumnsContext";
|
|
19
|
+
import { useMillerColumnsColumnContext } from "./useMillerColumnsColumnContext";
|
|
20
|
+
|
|
21
|
+
export function useMillerColumnsItem(
|
|
22
|
+
{
|
|
23
|
+
value,
|
|
24
|
+
ref,
|
|
25
|
+
onClick,
|
|
26
|
+
onKeyDown,
|
|
27
|
+
onFocus,
|
|
28
|
+
disabled = false,
|
|
29
|
+
...rest
|
|
30
|
+
}: Omit<MillerColumnsItemProps, "children">,
|
|
31
|
+
hasChildren: boolean,
|
|
32
|
+
) {
|
|
33
|
+
const {
|
|
34
|
+
activePath,
|
|
35
|
+
select,
|
|
36
|
+
registerItem,
|
|
37
|
+
getColumnItems,
|
|
38
|
+
focusItem,
|
|
39
|
+
focusFirstInColumn,
|
|
40
|
+
requestColumnFocus,
|
|
41
|
+
activeItem,
|
|
42
|
+
setActiveItem,
|
|
43
|
+
} = useMillerColumnsContext();
|
|
44
|
+
const { depth } = useMillerColumnsColumnContext();
|
|
45
|
+
|
|
46
|
+
const selected = activePath[depth] === value;
|
|
47
|
+
|
|
48
|
+
const itemRef = useRef<HTMLDivElement>(null);
|
|
49
|
+
const composedRef = ref ? composeRefs(itemRef, ref) : itemRef;
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
registerItem(depth, value, itemRef.current, disabled);
|
|
53
|
+
return () => registerItem(depth, value, null, disabled);
|
|
54
|
+
}, [depth, value, disabled, registerItem]);
|
|
55
|
+
|
|
56
|
+
const enabledValues = getColumnItems(depth)
|
|
57
|
+
.filter((item) => !item.disabled)
|
|
58
|
+
.map((item) => item.value);
|
|
59
|
+
|
|
60
|
+
const { handleKeyDown: rovingKeyDown } = useRovingTabindex<string>({
|
|
61
|
+
orientation: "vertical",
|
|
62
|
+
navigable: enabledValues,
|
|
63
|
+
currentKey: value,
|
|
64
|
+
includeHomeEnd: true,
|
|
65
|
+
includeActivate: true,
|
|
66
|
+
onNavigate: (target, action) => {
|
|
67
|
+
if (action === "activate") {
|
|
68
|
+
if (!disabled) {
|
|
69
|
+
select(depth, value);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
focusItem(depth, target);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
function handleClick(event: MouseEvent<HTMLDivElement>) {
|
|
78
|
+
if (disabled) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
onClick?.(event);
|
|
82
|
+
select(depth, value);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function handleFocus(event: FocusEvent<HTMLDivElement>) {
|
|
86
|
+
onFocus?.(event);
|
|
87
|
+
setActiveItem({ depth, value });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Exactly one item in the whole tree is the Tab stop. It follows the
|
|
91
|
+
// last-focused item; before any focus it defaults to the deepest
|
|
92
|
+
// selected item, falling back to the first enabled root item.
|
|
93
|
+
const tabStop =
|
|
94
|
+
activeItem ??
|
|
95
|
+
(activePath.length > 0
|
|
96
|
+
? { depth: activePath.length - 1, value: activePath[activePath.length - 1] }
|
|
97
|
+
: null);
|
|
98
|
+
const isTabStop = tabStop
|
|
99
|
+
? tabStop.depth === depth && tabStop.value === value
|
|
100
|
+
: depth === 0 &&
|
|
101
|
+
getColumnItems(0).find((item) => !item.disabled)?.value === value;
|
|
102
|
+
|
|
103
|
+
function handleKeyDown(event: KeyboardEvent<HTMLDivElement>) {
|
|
104
|
+
onKeyDown?.(event);
|
|
105
|
+
|
|
106
|
+
if (event.key === "ArrowRight") {
|
|
107
|
+
if (!hasChildren || disabled) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
if (selected) {
|
|
112
|
+
focusFirstInColumn(depth + 1);
|
|
113
|
+
} else {
|
|
114
|
+
requestColumnFocus(depth + 1);
|
|
115
|
+
select(depth, value);
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (event.key === "ArrowLeft") {
|
|
121
|
+
if (depth === 0) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
// A column at depth > 0 exists only because its parent item is
|
|
126
|
+
// selected, so activePath[depth - 1] is always defined here.
|
|
127
|
+
focusItem(depth - 1, activePath[depth - 1]);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
rovingKeyDown(event);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const itemProps = {
|
|
135
|
+
ref: composedRef,
|
|
136
|
+
role: "treeitem",
|
|
137
|
+
tabIndex: isTabStop ? 0 : -1,
|
|
138
|
+
"aria-selected": selected,
|
|
139
|
+
"aria-level": depth + 1,
|
|
140
|
+
...(hasChildren ? { "aria-expanded": selected } : {}),
|
|
141
|
+
"data-state": selected ? "selected" : "unselected",
|
|
142
|
+
"data-depth": depth,
|
|
143
|
+
...(hasChildren ? { "data-has-children": "" } : {}),
|
|
144
|
+
...(disabled ? { "aria-disabled": true, "data-disabled": "" } : {}),
|
|
145
|
+
onClick: handleClick,
|
|
146
|
+
onKeyDown: handleKeyDown,
|
|
147
|
+
onFocus: handleFocus,
|
|
148
|
+
...rest,
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const itemContextValue = useMemo<MillerColumnsItemContextValue>(
|
|
152
|
+
() => ({ selected, hasChildren }),
|
|
153
|
+
[selected, hasChildren],
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
return { itemProps, selected, itemContextValue };
|
|
157
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useMillerColumnsItemContext } from "../MillerColumnsContext";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { PointerEvent, useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import type { MillerColumnsResizeHandleProps } from "../types";
|
|
4
|
+
|
|
5
|
+
import { useMillerColumnsContext } from "./useMillerColumnsContext";
|
|
6
|
+
import { useMillerColumnsColumnContext } from "./useMillerColumnsColumnContext";
|
|
7
|
+
|
|
8
|
+
type DragState = { startX: number; startWidth: number };
|
|
9
|
+
|
|
10
|
+
export function useMillerColumnsResizeHandle({
|
|
11
|
+
onPointerDown,
|
|
12
|
+
...rest
|
|
13
|
+
}: MillerColumnsResizeHandleProps) {
|
|
14
|
+
const { columnWidths, setColumnWidth } = useMillerColumnsContext();
|
|
15
|
+
const { depth } = useMillerColumnsColumnContext();
|
|
16
|
+
|
|
17
|
+
const [drag, setDrag] = useState<DragState | null>(null);
|
|
18
|
+
|
|
19
|
+
// A drag is tracked on `window`, not the handle, so the pointer can
|
|
20
|
+
// travel anywhere once it is down; the listeners live only for the
|
|
21
|
+
// lifetime of the drag.
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!drag) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const activeDrag = drag;
|
|
28
|
+
|
|
29
|
+
function handleMove(event: globalThis.PointerEvent) {
|
|
30
|
+
setColumnWidth(
|
|
31
|
+
depth,
|
|
32
|
+
Math.max(
|
|
33
|
+
0,
|
|
34
|
+
activeDrag.startWidth + event.clientX - activeDrag.startX,
|
|
35
|
+
),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function endDrag() {
|
|
40
|
+
setDrag(null);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
window.addEventListener("pointermove", handleMove);
|
|
44
|
+
window.addEventListener("pointerup", endDrag);
|
|
45
|
+
window.addEventListener("pointercancel", endDrag);
|
|
46
|
+
return () => {
|
|
47
|
+
window.removeEventListener("pointermove", handleMove);
|
|
48
|
+
window.removeEventListener("pointerup", endDrag);
|
|
49
|
+
window.removeEventListener("pointercancel", endDrag);
|
|
50
|
+
};
|
|
51
|
+
}, [drag, depth, setColumnWidth]);
|
|
52
|
+
|
|
53
|
+
function handlePointerDown(event: PointerEvent<HTMLDivElement>) {
|
|
54
|
+
onPointerDown?.(event);
|
|
55
|
+
// The handle only renders inside a Column (enforced by context), so
|
|
56
|
+
// its column ancestor is always present in the DOM. Once a column
|
|
57
|
+
// has been resized its width is known; before that, measure it.
|
|
58
|
+
const column = event.currentTarget.closest<HTMLElement>(
|
|
59
|
+
"[data-miller-columns-column]",
|
|
60
|
+
)!;
|
|
61
|
+
const startWidth =
|
|
62
|
+
columnWidths.get(depth) ?? column.getBoundingClientRect().width;
|
|
63
|
+
setDrag({ startX: event.clientX, startWidth });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
handleProps: {
|
|
68
|
+
role: "separator" as const,
|
|
69
|
+
"aria-orientation": "vertical" as const,
|
|
70
|
+
"data-miller-columns-resize-handle": "",
|
|
71
|
+
...(drag ? { "data-dragging": "" } : {}),
|
|
72
|
+
onPointerDown: handlePointerDown,
|
|
73
|
+
...rest,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode, Ref } from "react";
|
|
2
|
+
|
|
3
|
+
type MillerColumnsRootBaseProps = Omit<ComponentProps<"div">, "ref"> & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
type MillerColumnsRootUncontrolledProps = MillerColumnsRootBaseProps & {
|
|
8
|
+
defaultValue?: string[];
|
|
9
|
+
value?: never;
|
|
10
|
+
onValueChange?: never;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type MillerColumnsRootControlledProps = MillerColumnsRootBaseProps & {
|
|
14
|
+
defaultValue?: never;
|
|
15
|
+
value: string[];
|
|
16
|
+
onValueChange: (path: string[]) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type MillerColumnsRootProps =
|
|
20
|
+
| MillerColumnsRootUncontrolledProps
|
|
21
|
+
| MillerColumnsRootControlledProps;
|
|
22
|
+
|
|
23
|
+
export type MillerColumnsColumnProps = ComponentProps<"div"> & {
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type MillerColumnsItemProps<
|
|
28
|
+
T extends HTMLElement = HTMLDivElement,
|
|
29
|
+
> = Omit<ComponentProps<"div">, "ref"> & {
|
|
30
|
+
value: string;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
asChild?: boolean;
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
/** Ref to the rendered element. Defaults to `HTMLDivElement`; when using
|
|
35
|
+
* `asChild`, specify the child's element type. */
|
|
36
|
+
ref?: Ref<T>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type MillerColumnsItemIndicatorProps = ComponentProps<"span"> & {
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type MillerColumnsResizeHandleProps = ComponentProps<"div">;
|
|
44
|
+
|
|
45
|
+
export type MillerColumnsPreviewPanelProps = ComponentProps<"div"> & {
|
|
46
|
+
children?: ReactNode;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type MillerColumnsSelection = {
|
|
50
|
+
/** The full active path — selected item ids, root column first. */
|
|
51
|
+
path: string[];
|
|
52
|
+
/** The deepest selected item id, or `undefined` when nothing is selected. */
|
|
53
|
+
selectedValue: string | undefined;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type MillerColumnsItemMeta = {
|
|
57
|
+
value: string;
|
|
58
|
+
disabled: boolean;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type MillerColumnsItemAddress = {
|
|
62
|
+
depth: number;
|
|
63
|
+
value: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type MillerColumnsContextValue = {
|
|
67
|
+
slots: Map<number, HTMLElement>;
|
|
68
|
+
columnWidths: Map<number, number>;
|
|
69
|
+
setColumnWidth: (depth: number, width: number) => void;
|
|
70
|
+
activePath: string[];
|
|
71
|
+
select: (depth: number, value: string) => void;
|
|
72
|
+
registerItem: (
|
|
73
|
+
depth: number,
|
|
74
|
+
value: string,
|
|
75
|
+
element: HTMLElement | null,
|
|
76
|
+
disabled: boolean,
|
|
77
|
+
) => void;
|
|
78
|
+
getColumnItems: (depth: number) => MillerColumnsItemMeta[];
|
|
79
|
+
focusItem: (depth: number, value: string) => void;
|
|
80
|
+
focusFirstInColumn: (depth: number) => boolean;
|
|
81
|
+
requestColumnFocus: (depth: number) => void;
|
|
82
|
+
activeItem: MillerColumnsItemAddress | null;
|
|
83
|
+
setActiveItem: (item: MillerColumnsItemAddress) => void;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type MillerColumnsColumnContextValue = {
|
|
87
|
+
depth: number;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type MillerColumnsItemContextValue = {
|
|
91
|
+
selected: boolean;
|
|
92
|
+
hasChildren: boolean;
|
|
93
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useMillerColumnsContext } from "./hooks";
|
|
2
|
+
|
|
3
|
+
import type { MillerColumnsSelection } from "./types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Reads the current MillerColumns selection — the active path and the
|
|
7
|
+
* deepest selected item id.
|
|
8
|
+
*
|
|
9
|
+
* Intended for consumer content rendered inside a `MillerColumns.Root`
|
|
10
|
+
* (typically within a `MillerColumns.PreviewPanel`) that needs to know
|
|
11
|
+
* what is selected without owning the selection state itself. Works for
|
|
12
|
+
* both controlled and uncontrolled roots.
|
|
13
|
+
*
|
|
14
|
+
* Throws when called outside a `MillerColumns.Root`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* function FilePreview() {
|
|
19
|
+
* const { selectedValue } = useMillerColumnsSelection();
|
|
20
|
+
* return selectedValue ? <Preview id={selectedValue} /> : null;
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function useMillerColumnsSelection(): MillerColumnsSelection {
|
|
25
|
+
const { activePath } = useMillerColumnsContext();
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
path: activePath,
|
|
29
|
+
selectedValue: activePath.at(-1),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
cloneElement,
|
|
4
|
+
Fragment,
|
|
5
|
+
isValidElement,
|
|
6
|
+
ReactElement,
|
|
7
|
+
ReactNode,
|
|
8
|
+
} from "react";
|
|
9
|
+
|
|
10
|
+
import { MillerColumnsColumn } from "./MillerColumns";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Produces the next active path when an item at `depth` with id `value`
|
|
14
|
+
* is selected: keeps the columns shallower than `depth` untouched,
|
|
15
|
+
* appends `value`, and drops everything deeper (those columns close).
|
|
16
|
+
*/
|
|
17
|
+
export function selectAtDepth(
|
|
18
|
+
path: string[],
|
|
19
|
+
depth: number,
|
|
20
|
+
value: string,
|
|
21
|
+
): string[] {
|
|
22
|
+
return [...path.slice(0, depth), value];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Whether `node` is a `MillerColumns.Column` element — the identity
|
|
27
|
+
* check used to separate an Item's cell content from its child column.
|
|
28
|
+
*/
|
|
29
|
+
export function isColumnElement(node: ReactNode): node is ReactElement {
|
|
30
|
+
return isValidElement(node) && node.type === MillerColumnsColumn;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Splits an `Item`'s children into its cell content and its single
|
|
35
|
+
* optional nested `<MillerColumns.Column>`.
|
|
36
|
+
*
|
|
37
|
+
* The child column is matched however deeply it is wrapped in
|
|
38
|
+
* fragments, since `Children.toArray` does not descend into fragments —
|
|
39
|
+
* so `{cond ? <><Indicator/><Column/></> : null}` is partitioned the
|
|
40
|
+
* same as a bare `<Column/>`. Cell entries are re-keyed because
|
|
41
|
+
* unwrapping fragments can collide the keys `Children.toArray` assigns.
|
|
42
|
+
*/
|
|
43
|
+
export function partitionItemChildren(children: ReactNode): {
|
|
44
|
+
cell: ReactNode[];
|
|
45
|
+
column: ReactElement | null;
|
|
46
|
+
} {
|
|
47
|
+
const cell: ReactNode[] = [];
|
|
48
|
+
let column: ReactElement | null = null;
|
|
49
|
+
|
|
50
|
+
const visit = (nodes: ReactNode): void => {
|
|
51
|
+
for (const child of Children.toArray(nodes)) {
|
|
52
|
+
if (isColumnElement(child)) {
|
|
53
|
+
if (column !== null) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
"A MillerColumns.Item may contain at most one nested <MillerColumns.Column>.",
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
column = child;
|
|
59
|
+
} else if (isValidElement(child) && child.type === Fragment) {
|
|
60
|
+
visit((child.props as { children?: ReactNode }).children);
|
|
61
|
+
} else {
|
|
62
|
+
cell.push(child);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
visit(children);
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
cell: cell.map((node, index) =>
|
|
71
|
+
isValidElement(node) ? cloneElement(node, { key: `mc-${index}` }) : node,
|
|
72
|
+
),
|
|
73
|
+
column,
|
|
74
|
+
};
|
|
75
|
+
}
|