@sanity/ui 3.3.1 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_visual-editing.d.mts +2 -1126
- package/dist/_visual-editing.d.ts +2 -1126
- package/dist/_visual-editing.js +3 -31
- package/dist/_visual-editing.mjs +2 -31
- package/dist/index.d.mts +555 -2769
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +555 -2769
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2982 -1934
- package/dist/index.mjs +2950 -1903
- package/dist/index.mjs.map +1 -1
- package/dist/refractor.js +16 -0
- package/dist/refractor.mjs +21 -0
- package/dist/refractor.mjs.map +1 -0
- package/dist/tabList.js +3804 -0
- package/dist/tabList.mjs +3355 -0
- package/dist/tabList.mjs.map +1 -0
- package/dist/theme.d.mts +927 -1227
- package/dist/theme.d.mts.map +1 -0
- package/dist/theme.d.ts +927 -1227
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +3 -4127
- package/dist/theme.mjs +2 -4127
- package/dist/theme2.d.mts +2 -0
- package/dist/theme2.d.ts +2 -0
- package/dist/theme2.js +4104 -0
- package/dist/theme2.mjs +3851 -0
- package/dist/theme2.mjs.map +1 -0
- package/dist/useTheme.d.mts +1451 -0
- package/dist/useTheme.d.mts.map +1 -0
- package/dist/useTheme.d.ts +1451 -0
- package/dist/useTheme.d.ts.map +1 -0
- package/exports/_visual-editing.ts +1 -0
- package/package.json +49 -102
- package/src/core/_compat.ts +30 -0
- package/src/core/components/autocomplete/autocomplete.tsx +8 -0
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -0
- package/src/core/components/breadcrumbs/breadcrumbs.test.tsx +8 -5
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +3 -0
- package/src/core/components/dialog/dialog.tsx +5 -2
- package/src/core/components/hotkeys/hotkeys.test.tsx +10 -5
- package/src/core/components/hotkeys/hotkeys.tsx +2 -0
- package/src/core/components/menu/menu.spacing.test.tsx +12 -7
- package/src/core/components/menu/menu.test.tsx +9 -6
- package/src/core/components/menu/menu.tsx +4 -2
- package/src/core/components/menu/menuButton.tsx +8 -0
- package/src/core/components/menu/menuDivider.ts +1 -0
- package/src/core/components/menu/menuGroup.spacing.test.tsx +9 -6
- package/src/core/components/menu/menuGroup.tsx +6 -2
- package/src/core/components/menu/menuItem.spacing.test.tsx +8 -5
- package/src/core/components/menu/menuItem.tsx +4 -0
- package/src/core/components/menu/useMenuController.ts +2 -0
- package/src/core/components/skeleton/skeleton.tsx +1 -0
- package/src/core/components/tab/tab.tsx +1 -0
- package/src/core/components/tab/tabList.test.tsx +7 -5
- package/src/core/components/tab/tabList.tsx +1 -0
- package/src/core/components/toast/toast.test.tsx +9 -4
- package/src/core/components/toast/toast.tsx +1 -0
- package/src/core/components/toast/toastLayer.tsx +1 -0
- package/src/core/components/tree/tree.test.tsx +10 -5
- package/src/core/components/tree/tree.tsx +2 -0
- package/src/core/components/tree/treeGroup.tsx +1 -0
- package/src/core/components/tree/treeItem.test.tsx +10 -5
- package/src/core/components/tree/treeItem.tsx +1 -0
- package/src/core/hooks/index.ts +1 -0
- package/src/core/hooks/useClickOutside.test.tsx +43 -15
- package/src/core/hooks/useClickOutside.ts +1 -1
- package/src/core/hooks/useClickOutsideEvent.test.tsx +8 -4
- package/src/core/hooks/useDelayed.test.ts +9 -8
- package/src/core/hooks/useElementRect/useElementRect.ts +1 -0
- package/src/core/hooks/useForwardedRef.ts +1 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +2 -1
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +7 -5
- package/src/core/hooks/usePrefersDark.test.tsx +3 -1
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +7 -5
- package/src/core/hooks/usePrefersReducedMotion.test.tsx +3 -1
- package/src/core/lib/createGlobalScopedContext.ts +1 -0
- package/src/core/lib/globalScope.ts +1 -0
- package/src/core/observers/elementSizeObserver.ts +1 -0
- package/src/core/primitives/avatar/avatar.tsx +2 -2
- package/src/core/primitives/avatar/avatarStack.tsx +1 -0
- package/src/core/primitives/badge/badge.test.tsx +3 -2
- package/src/core/primitives/badge/badge.tsx +3 -1
- package/src/core/primitives/box/box.test.tsx +18 -5
- package/src/core/primitives/box/box.tsx +9 -1
- package/src/core/primitives/button/button.test.tsx +10 -6
- package/src/core/primitives/button/button.tsx +4 -0
- package/src/core/primitives/button/styles.ts +1 -0
- package/src/core/primitives/card/card.tsx +2 -5
- package/src/core/primitives/card/types.ts +1 -0
- package/src/core/primitives/code/code.tsx +1 -0
- package/src/core/primitives/code/refractor.tsx +2 -0
- package/src/core/primitives/container/container.tsx +1 -0
- package/src/core/primitives/flex/flex.tsx +2 -3
- package/src/core/primitives/grid/grid.test.tsx +11 -5
- package/src/core/primitives/grid/grid.tsx +3 -0
- package/src/core/primitives/heading/heading.tsx +1 -0
- package/src/core/primitives/inline/inline.test.tsx +9 -5
- package/src/core/primitives/inline/inline.tsx +3 -0
- package/src/core/primitives/kbd/kbd.tsx +5 -1
- package/src/core/primitives/label/label.tsx +1 -0
- package/src/core/primitives/popover/popover.tsx +5 -4
- package/src/core/primitives/popover/popoverCard.tsx +1 -0
- package/src/core/primitives/popover/types.ts +0 -1
- package/src/core/primitives/select/select.test.tsx +9 -5
- package/src/core/primitives/select/select.tsx +1 -0
- package/src/core/primitives/stack/stack.test.tsx +9 -5
- package/src/core/primitives/stack/stack.tsx +2 -0
- package/src/core/primitives/stack/styles.ts +1 -0
- package/src/core/primitives/text/text.tsx +1 -0
- package/src/core/primitives/textInput/textInput.test.tsx +9 -5
- package/src/core/primitives/textInput/textInput.tsx +3 -0
- package/src/core/primitives/tooltip/tooltip.test.tsx +82 -49
- package/src/core/primitives/tooltip/tooltip.tsx +3 -1
- package/src/core/primitives/tooltip/tooltipCard.tsx +1 -0
- package/src/core/primitives/tooltip/tooltipDelayGroup/types.ts +2 -0
- package/src/core/styles/flex/types.ts +0 -1
- package/src/core/styles/font/responsiveFont.ts +0 -3
- package/src/core/styles/font/types.ts +1 -3
- package/src/core/styles/grid/gridStyle.ts +1 -0
- package/src/core/styles/margin/marginStyle.ts +1 -0
- package/src/core/styles/margin/marginsStyle.test.ts +2 -1
- package/src/core/styles/padding/paddingStyle.test.ts +2 -1
- package/src/core/styles/padding/paddingStyle.ts +1 -0
- package/src/core/theme/theme.test.tsx +7 -3
- package/src/core/theme/useRootTheme.ts +1 -0
- package/src/core/theme/useTheme.ts +2 -0
- package/src/core/utils/arrow/arrow.tsx +1 -0
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +9 -4
- package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +1 -0
- package/src/core/utils/getElementRef.ts +5 -0
- package/src/core/utils/layer/getLayerContext.test.ts +2 -0
- package/src/core/utils/layer/layer.test.tsx +9 -4
- package/src/core/utils/layer/layer.tsx +1 -0
- package/src/core/utils/layer/useLayer.ts +2 -0
- package/src/core/utils/portal/portal.test.tsx +9 -4
- package/src/core/utils/portal/portalProvider.tsx +1 -0
- package/src/core/utils/virtualList/virtualList.tsx +2 -1
- package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +10 -0
- package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +4 -0
- package/src/theme/build/_deprecated/color/button/createButtonModes.ts +5 -0
- package/src/theme/build/_deprecated/color/button/createButtonTones.ts +5 -0
- package/src/theme/build/_deprecated/color/card/createCardStates.ts +6 -0
- package/src/theme/build/_deprecated/color/color.test.ts +5 -1
- package/src/theme/build/_deprecated/color/defaults.ts +1 -0
- package/src/theme/build/_deprecated/color/factory.ts +36 -0
- package/src/theme/build/_deprecated/color/input/createInputModes.ts +5 -0
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +4 -0
- package/src/theme/build/_deprecated/color/spot/createSpot.ts +3 -0
- package/src/theme/build/buildColorTheme.test.ts +2 -0
- package/src/theme/build/buildColorTheme.ts +8 -0
- package/src/theme/build/buildTheme.test.ts +2 -0
- package/src/theme/build/lib/color-fns/color-fns.test.ts +3 -1
- package/src/theme/build/merge.ts +5 -0
- package/src/theme/build/mixThemeColor.test.ts +2 -0
- package/src/theme/build/renderColorTheme.ts +6 -0
- package/src/theme/build/renderColorValue.ts +0 -2
- package/src/theme/build/resolveColorTokens.ts +6 -0
- package/src/theme/build/theme.test.ts +2 -0
- package/src/theme/config/helpers.ts +5 -0
- package/src/theme/config/system.ts +2 -0
- package/src/theme/config/tokens/color/types.ts +6 -4
- package/src/theme/config/tokens/parseTokenKey.test.ts +2 -0
- package/src/theme/config/tokens/parseTokenValue.test.ts +2 -0
- package/src/theme/config/tokens/parseTokenValue.ts +1 -0
- package/src/theme/getScopedTheme.ts +6 -1
- package/src/theme/system/color/_helpers.ts +4 -0
- package/src/theme/system/theme.ts +4 -0
- package/src/theme/system/v0/color/_system.ts +1 -0
- package/src/theme/system/v0/color/button.ts +14 -0
- package/src/theme/system/v0/color/card.ts +6 -0
- package/src/theme/system/v0/color/color.ts +11 -0
- package/src/theme/system/v0/color/input.ts +6 -0
- package/src/theme/system/v0/color/muted.ts +11 -0
- package/src/theme/system/v0/color/selectable.ts +11 -0
- package/src/theme/system/v0/color/solid.ts +11 -0
- package/src/theme/system/v0/color/spot.ts +1 -0
- package/src/theme/versioning/getTheme_v2.ts +15 -0
- package/src/theme/versioning/themeColor_v0_v2.ts +7 -0
- package/src/theme/versioning/themeColor_v2_v2_9.ts +1 -0
- package/src/theme/versioning/v0_v2.ts +13 -1
- package/src/theme/versioning/v2_v0.ts +18 -0
- package/dist/_chunks-cjs/_visual-editing.js +0 -5899
- package/dist/_chunks-cjs/_visual-editing.js.map +0 -1
- package/dist/_chunks-cjs/refractor.js +0 -23
- package/dist/_chunks-cjs/refractor.js.map +0 -1
- package/dist/_chunks-es/_visual-editing.mjs +0 -5905
- package/dist/_chunks-es/_visual-editing.mjs.map +0 -1
- package/dist/_chunks-es/refractor.mjs +0 -26
- package/dist/_chunks-es/refractor.mjs.map +0 -1
- package/dist/_visual-editing.js.map +0 -1
- package/dist/_visual-editing.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/theme.js.map +0 -1
- package/dist/theme.mjs.map +0 -1
- package/src/core/__workshop__/constants.ts +0 -293
- package/src/core/components/autocomplete/__mocks__/apiStore.ts +0 -49
- package/src/core/components/autocomplete/__mocks__/countries.ts +0 -245
- package/src/core/components/autocomplete/__workshop__/async.tsx +0 -156
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +0 -137
- package/src/core/components/autocomplete/__workshop__/custom.tsx +0 -89
- package/src/core/components/autocomplete/__workshop__/example.tsx +0 -79
- package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +0 -36
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +0 -294
- package/src/core/components/autocomplete/__workshop__/index.ts +0 -39
- package/src/core/components/autocomplete/__workshop__/types.ts +0 -4
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +0 -62
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -14
- package/src/core/components/dialog/__workshop__/activate.tsx +0 -134
- package/src/core/components/dialog/__workshop__/autoFocus.tsx +0 -29
- package/src/core/components/dialog/__workshop__/index.ts +0 -19
- package/src/core/components/dialog/__workshop__/layering.tsx +0 -41
- package/src/core/components/dialog/__workshop__/nested.tsx +0 -72
- package/src/core/components/dialog/__workshop__/onScroll.tsx +0 -39
- package/src/core/components/dialog/__workshop__/panes.tsx +0 -82
- package/src/core/components/dialog/__workshop__/position.tsx +0 -30
- package/src/core/components/dialog/__workshop__/props.tsx +0 -75
- package/src/core/components/dialog/__workshop__/provider.tsx +0 -11
- package/src/core/components/dialog/__workshop__/wrapped.tsx +0 -76
- package/src/core/components/hotkeys/__workshop__/index.ts +0 -14
- package/src/core/components/hotkeys/__workshop__/plain.tsx +0 -9
- package/src/core/components/menu/__workshop__/asComponent.tsx +0 -45
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +0 -51
- package/src/core/components/menu/__workshop__/closableMenuButton.tsx +0 -46
- package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +0 -134
- package/src/core/components/menu/__workshop__/customMenuItem.tsx +0 -45
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +0 -39
- package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +0 -40
- package/src/core/components/menu/__workshop__/groups.tsx +0 -156
- package/src/core/components/menu/__workshop__/index.ts +0 -89
- package/src/core/components/menu/__workshop__/menuButton.tsx +0 -80
- package/src/core/components/menu/__workshop__/menuGroupRight.tsx +0 -65
- package/src/core/components/menu/__workshop__/nestedMenu.tsx +0 -22
- package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +0 -41
- package/src/core/components/menu/__workshop__/selectedItem.tsx +0 -69
- package/src/core/components/menu/__workshop__/shouldFocus.tsx +0 -47
- package/src/core/components/menu/__workshop__/tones.tsx +0 -25
- package/src/core/components/menu/__workshop__/withoutArrow.tsx +0 -32
- package/src/core/components/skeleton/__workshop__/delay.tsx +0 -70
- package/src/core/components/skeleton/__workshop__/index.ts +0 -11
- package/src/core/components/skeleton/__workshop__/skeleton.tsx +0 -64
- package/src/core/components/tab/__workshop__/example.tsx +0 -79
- package/src/core/components/tab/__workshop__/index.ts +0 -14
- package/src/core/components/toast/__workshop__/hook.tsx +0 -71
- package/src/core/components/toast/__workshop__/index.ts +0 -19
- package/src/core/components/toast/__workshop__/toast.tsx +0 -26
- package/src/core/components/tree/__workshop__/basic.perf.ts +0 -19
- package/src/core/components/tree/__workshop__/basic.tsx +0 -105
- package/src/core/components/tree/__workshop__/index.ts +0 -21
- package/src/core/components/tree/__workshop__/tabFromElement.tsx +0 -84
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +0 -32
- package/src/core/hooks/useElementRect/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/index.ts +0 -29
- package/src/core/primitives/avatar/__workshop__/stack.tsx +0 -25
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +0 -63
- package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +0 -70
- package/src/core/primitives/badge/__workshop__/index.ts +0 -19
- package/src/core/primitives/badge/__workshop__/props.tsx +0 -30
- package/src/core/primitives/badge/__workshop__/tones.tsx +0 -21
- package/src/core/primitives/box/__workshop__/asComponent.tsx +0 -31
- package/src/core/primitives/box/__workshop__/index.ts +0 -24
- package/src/core/primitives/box/__workshop__/props.tsx +0 -20
- package/src/core/primitives/box/__workshop__/responsive.tsx +0 -20
- package/src/core/primitives/button/__workshop__/custom.tsx +0 -51
- package/src/core/primitives/button/__workshop__/customIcons.tsx +0 -30
- package/src/core/primitives/button/__workshop__/disabled.tsx +0 -74
- package/src/core/primitives/button/__workshop__/index.ts +0 -59
- package/src/core/primitives/button/__workshop__/mixedChildren.tsx +0 -12
- package/src/core/primitives/button/__workshop__/props.tsx +0 -55
- package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +0 -36
- package/src/core/primitives/button/__workshop__/stacked.tsx +0 -58
- package/src/core/primitives/button/__workshop__/styled1.tsx +0 -17
- package/src/core/primitives/button/__workshop__/styled2.tsx +0 -19
- package/src/core/primitives/button/__workshop__/uploadButton.tsx +0 -28
- package/src/core/primitives/card/__workshop__/allTones.tsx +0 -25
- package/src/core/primitives/card/__workshop__/asButton.tsx +0 -107
- package/src/core/primitives/card/__workshop__/asComponent.tsx +0 -27
- package/src/core/primitives/card/__workshop__/checkered.tsx +0 -26
- package/src/core/primitives/card/__workshop__/index.ts +0 -18
- package/src/core/primitives/card/__workshop__/interactive.tsx +0 -30
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +0 -80
- package/src/core/primitives/card/__workshop__/props.tsx +0 -53
- package/src/core/primitives/card/__workshop__/selected.tsx +0 -94
- package/src/core/primitives/card/__workshop__/styled.tsx +0 -14
- package/src/core/primitives/checkbox/__workshop__/example.tsx +0 -25
- package/src/core/primitives/checkbox/__workshop__/index.ts +0 -13
- package/src/core/primitives/checkbox/__workshop__/props.tsx +0 -33
- package/src/core/primitives/checkbox/__workshop__/readOnly.tsx +0 -16
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +0 -28
- package/src/core/primitives/code/__workshop__/index.ts +0 -19
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/code/__workshop__/props.tsx +0 -21
- package/src/core/primitives/container/__workshop__/example.tsx +0 -20
- package/src/core/primitives/container/__workshop__/index.ts +0 -8
- package/src/core/primitives/flex/__workshop__/example.tsx +0 -34
- package/src/core/primitives/flex/__workshop__/gap.tsx +0 -25
- package/src/core/primitives/flex/__workshop__/index.ts +0 -11
- package/src/core/primitives/grid/__workshop__/index.ts +0 -10
- package/src/core/primitives/grid/__workshop__/responsive.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/index.ts +0 -19
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/inline/__workshop__/index.ts +0 -8
- package/src/core/primitives/inline/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/kbd/__workshop__/index.ts +0 -8
- package/src/core/primitives/kbd/__workshop__/plain.tsx +0 -9
- package/src/core/primitives/label/__workshop__/index.ts +0 -19
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/label/__workshop__/plain.tsx +0 -24
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +0 -77
- package/src/core/primitives/popover/__workshop__/MarginsStory.tsx +0 -31
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +0 -32
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +0 -11
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +0 -89
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +0 -97
- package/src/core/primitives/popover/__workshop__/index.ts +0 -49
- package/src/core/primitives/radio/__workshop__/example.tsx +0 -63
- package/src/core/primitives/radio/__workshop__/index.ts +0 -11
- package/src/core/primitives/radio/__workshop__/plain.tsx +0 -28
- package/src/core/primitives/select/__workshop__/index.ts +0 -11
- package/src/core/primitives/select/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/select/__workshop__/readOnly.tsx +0 -23
- package/src/core/primitives/spinner/__workshop__/Props.tsx +0 -15
- package/src/core/primitives/spinner/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/switch/__workshop__/example.tsx +0 -23
- package/src/core/primitives/switch/__workshop__/index.ts +0 -11
- package/src/core/primitives/switch/__workshop__/props.tsx +0 -21
- package/src/core/primitives/text/__workshop__/colored.tsx +0 -30
- package/src/core/primitives/text/__workshop__/example.tsx +0 -39
- package/src/core/primitives/text/__workshop__/index.ts +0 -24
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/textArea/__workshop__/index.ts +0 -14
- package/src/core/primitives/textArea/__workshop__/plain.tsx +0 -50
- package/src/core/primitives/textInput/__workshop__/clearButton.tsx +0 -30
- package/src/core/primitives/textInput/__workshop__/customValidity.tsx +0 -17
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -44
- package/src/core/primitives/textInput/__workshop__/plain.tsx +0 -98
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +0 -9
- package/src/core/primitives/textInput/__workshop__/states.tsx +0 -53
- package/src/core/primitives/textInput/__workshop__/tones.tsx +0 -277
- package/src/core/primitives/textInput/__workshop__/typed.tsx +0 -23
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +0 -102
- package/src/core/primitives/tooltip/__workshop__/index.ts +0 -29
- package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +0 -74
- package/src/core/primitives/tooltip/__workshop__/props.tsx +0 -107
- package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +0 -86
- package/src/core/theme/__workshop__/build/Root.tsx +0 -367
- package/src/core/theme/__workshop__/build/helpers.ts +0 -46
- package/src/core/theme/__workshop__/build/story.tsx +0 -465
- package/src/core/theme/__workshop__/canvas.tsx +0 -352
- package/src/core/theme/__workshop__/color.tsx +0 -62
- package/src/core/theme/__workshop__/debug/story.tsx +0 -408
- package/src/core/theme/__workshop__/index.ts +0 -39
- package/src/core/theme/__workshop__/layer.tsx +0 -78
- package/src/core/theme/__workshop__/nestedProvider.tsx +0 -15
- package/src/core/utils/boundaryElement/__workshop__/index.ts +0 -14
- package/src/core/utils/boundaryElement/__workshop__/plain.tsx +0 -19
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +0 -30
- package/src/core/utils/elementQuery/__workshop__/index.ts +0 -14
- package/src/core/utils/layer/__workshop__/_debug.tsx +0 -17
- package/src/core/utils/layer/__workshop__/index.ts +0 -24
- package/src/core/utils/layer/__workshop__/multipleRoots.tsx +0 -49
- package/src/core/utils/layer/__workshop__/nested.tsx +0 -98
- package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +0 -13
- package/src/core/utils/portal/__workshop__/index.ts +0 -14
- package/src/core/utils/portal/__workshop__/named.tsx +0 -63
- package/src/core/utils/virtualList/__workshop__/changingProps.tsx +0 -36
- package/src/core/utils/virtualList/__workshop__/elementScroll.tsx +0 -24
- package/src/core/utils/virtualList/__workshop__/index.ts +0 -29
- package/src/core/utils/virtualList/__workshop__/infiniteList.tsx +0 -48
- package/src/core/utils/virtualList/__workshop__/windowScrolll.tsx +0 -22
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/** @
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-console */
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
4
2
|
|
|
5
3
|
import React, {useCallback, useMemo} from 'react'
|
|
4
|
+
import {describe, expect, it, vi} from 'vitest'
|
|
6
5
|
|
|
7
6
|
import {render} from '../../../../test'
|
|
8
7
|
import {MenuContext, MenuContextValue} from './menuContext'
|
|
@@ -11,7 +10,7 @@ import {useMenu} from './useMenu'
|
|
|
11
10
|
describe('components/menu', () => {
|
|
12
11
|
describe('useMenu', () => {
|
|
13
12
|
it('should get context value', async () => {
|
|
14
|
-
const log =
|
|
13
|
+
const log = vi.fn()
|
|
15
14
|
|
|
16
15
|
function Debug() {
|
|
17
16
|
const rootMenu = useMenu()
|
|
@@ -23,11 +22,13 @@ describe('components/menu', () => {
|
|
|
23
22
|
|
|
24
23
|
function Root() {
|
|
25
24
|
const handleItemMouseEnter = useCallback(
|
|
25
|
+
// oxlint-disable-next-line no-console
|
|
26
26
|
(event: React.MouseEvent<HTMLElement>) => console.log(event),
|
|
27
27
|
[],
|
|
28
28
|
)
|
|
29
29
|
|
|
30
30
|
const handleItemMouseLeave = useCallback(
|
|
31
|
+
// oxlint-disable-next-line no-console
|
|
31
32
|
(event: React.MouseEvent<HTMLElement>) => console.log(event),
|
|
32
33
|
[],
|
|
33
34
|
)
|
|
@@ -37,6 +38,7 @@ describe('components/menu', () => {
|
|
|
37
38
|
({
|
|
38
39
|
version: 2,
|
|
39
40
|
activeElement: null,
|
|
41
|
+
// oxlint-disable-next-line no-console
|
|
40
42
|
mount: (element: HTMLElement | null) => () => console.log(element),
|
|
41
43
|
onItemClick: () => undefined,
|
|
42
44
|
onItemMouseEnter: handleItemMouseEnter,
|
|
@@ -64,7 +66,7 @@ describe('components/menu', () => {
|
|
|
64
66
|
})
|
|
65
67
|
|
|
66
68
|
it('should fail when no context value is provided', async () => {
|
|
67
|
-
const log =
|
|
69
|
+
const log = vi.fn()
|
|
68
70
|
|
|
69
71
|
function Debug() {
|
|
70
72
|
try {
|
|
@@ -92,7 +94,7 @@ describe('components/menu', () => {
|
|
|
92
94
|
})
|
|
93
95
|
|
|
94
96
|
it('should fail when context value is not compatible', async () => {
|
|
95
|
-
const log =
|
|
97
|
+
const log = vi.fn()
|
|
96
98
|
|
|
97
99
|
function Debug() {
|
|
98
100
|
try {
|
|
@@ -111,6 +113,7 @@ describe('components/menu', () => {
|
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
return (
|
|
116
|
+
// oxlint-disable-next-line jsx-no-constructed-context-values
|
|
114
117
|
<MenuContext.Provider value={value}>
|
|
115
118
|
<Debug />
|
|
116
119
|
</MenuContext.Provider>
|
|
@@ -52,9 +52,9 @@ export const Menu = forwardRef(function Menu(
|
|
|
52
52
|
) {
|
|
53
53
|
const {
|
|
54
54
|
children,
|
|
55
|
-
//
|
|
55
|
+
// oxlint-disable-next-line no-deprecated, no-unused-vars
|
|
56
56
|
focusFirst,
|
|
57
|
-
//
|
|
57
|
+
// oxlint-disable-next-line no-deprecated, no-unused-vars
|
|
58
58
|
focusLast,
|
|
59
59
|
onClickOutside,
|
|
60
60
|
onEscape,
|
|
@@ -66,11 +66,13 @@ export const Menu = forwardRef(function Menu(
|
|
|
66
66
|
registerElement,
|
|
67
67
|
shouldFocus: _shouldFocus,
|
|
68
68
|
gap,
|
|
69
|
+
// oxlint-disable-next-line no-deprecated
|
|
69
70
|
space: deprecated_space = 1,
|
|
70
71
|
...restProps
|
|
71
72
|
} = props
|
|
72
73
|
const spacing = gap === undefined ? deprecated_space : gap
|
|
73
74
|
const shouldFocus =
|
|
75
|
+
// oxlint-disable-next-line no-deprecated
|
|
74
76
|
_shouldFocus ?? ((props.focusFirst && 'first') || (props.focusLast && 'last') || null)
|
|
75
77
|
|
|
76
78
|
const ref = useRef<HTMLDivElement | null>(null)
|
|
@@ -66,17 +66,23 @@ export const MenuButton = forwardRef(function MenuButton(
|
|
|
66
66
|
) {
|
|
67
67
|
const {
|
|
68
68
|
__unstable_disableRestoreFocusOnClose: disableRestoreFocusOnClose = false,
|
|
69
|
+
// oxlint-disable-next-line no-deprecated
|
|
69
70
|
boundaryElement: deprecated_boundaryElement,
|
|
70
71
|
button: buttonProp,
|
|
71
72
|
id,
|
|
72
73
|
menu: menuProp,
|
|
73
74
|
onClose,
|
|
74
75
|
onOpen,
|
|
76
|
+
// oxlint-disable-next-line no-deprecated
|
|
75
77
|
placement: deprecated_placement,
|
|
78
|
+
// oxlint-disable-next-line no-deprecated
|
|
76
79
|
popoverScheme: deprecated_popoverScheme,
|
|
80
|
+
// oxlint-disable-next-line no-deprecated
|
|
77
81
|
portal: deprecated_portal = true,
|
|
78
82
|
popover,
|
|
83
|
+
// oxlint-disable-next-line no-deprecated
|
|
79
84
|
popoverRadius: deprecated_popoverRadius,
|
|
85
|
+
// oxlint-disable-next-line no-deprecated
|
|
80
86
|
preventOverflow: deprecated_preventOverflow,
|
|
81
87
|
} = props
|
|
82
88
|
const [open, setOpen] = useState(false)
|
|
@@ -239,6 +245,7 @@ export const MenuButton = forwardRef(function MenuButton(
|
|
|
239
245
|
|
|
240
246
|
const popoverProps: MenuButtonProps['popover'] = useMemo(
|
|
241
247
|
() => ({
|
|
248
|
+
// oxlint-disable-next-line no-deprecated
|
|
242
249
|
boundaryElement: deprecated_boundaryElement,
|
|
243
250
|
overflow: 'auto',
|
|
244
251
|
placement: deprecated_placement,
|
|
@@ -246,6 +253,7 @@ export const MenuButton = forwardRef(function MenuButton(
|
|
|
246
253
|
preventOverflow: deprecated_preventOverflow,
|
|
247
254
|
radius: deprecated_popoverRadius,
|
|
248
255
|
scheme: deprecated_popoverScheme,
|
|
256
|
+
// oxlint-disable-next-line no-useless-fallback-in-spread
|
|
249
257
|
...(popover || {}),
|
|
250
258
|
}),
|
|
251
259
|
[
|
|
@@ -18,6 +18,7 @@ export type MenuDividerProps<E extends ElementType = 'hr'> = Props<EmptyProps, E
|
|
|
18
18
|
/**
|
|
19
19
|
* @public
|
|
20
20
|
*/
|
|
21
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
21
22
|
export const MenuDivider = StyledMenuDivider as unknown as <E extends ElementType = 'hr'>(
|
|
22
23
|
props: MenuDividerProps<E>,
|
|
23
24
|
) => React.JSX.Element
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
/** @
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import {beforeEach, describe, expect, it, vi} from 'vitest'
|
|
2
4
|
|
|
3
5
|
import {render} from '../../../../test'
|
|
4
6
|
import {Flex} from '../../primitives'
|
|
@@ -6,13 +8,14 @@ import {MenuContext, MenuContextValue} from './menuContext'
|
|
|
6
8
|
import {MenuGroup} from './menuGroup'
|
|
7
9
|
import {MenuItem} from './menuItem'
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
const actual =
|
|
11
|
+
vi.mock('../../primitives', async (importOriginal) => {
|
|
12
|
+
const actual = await importOriginal<typeof import('../../primitives')>()
|
|
11
13
|
|
|
12
14
|
return {
|
|
13
15
|
...actual,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
17
|
+
Flex: vi.fn((props: Record<string, unknown>) => (actual.Flex as any).render(props, null)),
|
|
18
|
+
Popover: vi.fn(({children}: {children?: React.ReactNode}) => children),
|
|
16
19
|
}
|
|
17
20
|
})
|
|
18
21
|
|
|
@@ -35,7 +38,7 @@ function renderMenuGroup(props: Partial<React.ComponentProps<typeof MenuGroup>>
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
describe('components/menuGroup spacing', () => {
|
|
38
|
-
const mockedFlex =
|
|
41
|
+
const mockedFlex = vi.mocked(Flex)
|
|
39
42
|
|
|
40
43
|
beforeEach(() => {
|
|
41
44
|
mockedFlex.mockClear()
|
|
@@ -15,6 +15,7 @@ import {useMenu} from './useMenu'
|
|
|
15
15
|
*/
|
|
16
16
|
export interface MenuGroupOwnProps {
|
|
17
17
|
fontSize?: number | number[]
|
|
18
|
+
// oxlint-disable-next-line no-redundant-type-constituents
|
|
18
19
|
icon?: React.ElementType | React.ReactNode
|
|
19
20
|
menu?: Omit<
|
|
20
21
|
MenuProps,
|
|
@@ -59,6 +60,7 @@ function MenuGroupComponent(
|
|
|
59
60
|
popover,
|
|
60
61
|
radius = 2,
|
|
61
62
|
gap,
|
|
63
|
+
// oxlint-disable-next-line no-deprecated
|
|
62
64
|
space: deprecated_space = 3,
|
|
63
65
|
text,
|
|
64
66
|
tone = 'default',
|
|
@@ -129,13 +131,13 @@ function MenuGroupComponent(
|
|
|
129
131
|
|
|
130
132
|
// Close child menu when a sibling item becomes active
|
|
131
133
|
useEffect(() => {
|
|
132
|
-
//
|
|
134
|
+
// oxlint-disable-next-line react-compiler
|
|
133
135
|
if (!active) setOpen(false)
|
|
134
136
|
}, [active])
|
|
135
137
|
|
|
136
138
|
// Update state when child menu is no longer open
|
|
137
139
|
useEffect(() => {
|
|
138
|
-
//
|
|
140
|
+
// oxlint-disable-next-line react-compiler
|
|
139
141
|
if (!open) setWithinMenu(false)
|
|
140
142
|
}, [open])
|
|
141
143
|
|
|
@@ -146,6 +148,7 @@ function MenuGroupComponent(
|
|
|
146
148
|
// By doing the same here, we ensure that the reset is processed after the focus change.
|
|
147
149
|
const rafId = requestAnimationFrame(() => setShouldFocus(null))
|
|
148
150
|
|
|
151
|
+
// oxlint-disable-next-line consistent-return
|
|
149
152
|
return () => cancelAnimationFrame(rafId)
|
|
150
153
|
}, [shouldFocus])
|
|
151
154
|
|
|
@@ -228,6 +231,7 @@ MenuGroupComponent.displayName = 'MenuGroup'
|
|
|
228
231
|
/**
|
|
229
232
|
* @public
|
|
230
233
|
*/
|
|
234
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
231
235
|
export const MenuGroup = MenuGroupComponent as unknown as <E extends ElementType = 'button'>(
|
|
232
236
|
props: MenuGroupProps<E>,
|
|
233
237
|
) => React.JSX.Element
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
/** @
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import {beforeEach, describe, expect, it, vi} from 'vitest'
|
|
2
4
|
|
|
3
5
|
import {render} from '../../../../test'
|
|
4
6
|
import {Flex} from '../../primitives'
|
|
5
7
|
import {MenuContext, MenuContextValue} from './menuContext'
|
|
6
8
|
import {MenuItem} from './menuItem'
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
const actual =
|
|
10
|
+
vi.mock('../../primitives', async (importOriginal) => {
|
|
11
|
+
const actual = await importOriginal<typeof import('../../primitives')>()
|
|
10
12
|
|
|
11
13
|
return {
|
|
12
14
|
...actual,
|
|
13
|
-
|
|
15
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
16
|
+
Flex: vi.fn((props: Record<string, unknown>) => (actual.Flex as any).render(props, null)),
|
|
14
17
|
}
|
|
15
18
|
})
|
|
16
19
|
|
|
@@ -31,7 +34,7 @@ function renderMenuItem(props: Partial<React.ComponentProps<typeof MenuItem>> =
|
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
describe('components/menuItem spacing', () => {
|
|
34
|
-
const mockedFlex =
|
|
37
|
+
const mockedFlex = vi.mocked(Flex)
|
|
35
38
|
|
|
36
39
|
beforeEach(() => {
|
|
37
40
|
mockedFlex.mockClear()
|
|
@@ -26,7 +26,9 @@ import {useMenu} from './useMenu'
|
|
|
26
26
|
export interface MenuItemOwnProps extends ResponsivePaddingProps, ResponsiveRadiusProps {
|
|
27
27
|
fontSize?: number | number[]
|
|
28
28
|
hotkeys?: string[]
|
|
29
|
+
// oxlint-disable-next-line no-redundant-type-constituents
|
|
29
30
|
icon?: React.ElementType | React.ReactNode
|
|
31
|
+
// oxlint-disable-next-line no-redundant-type-constituents
|
|
30
32
|
iconRight?: React.ElementType | React.ReactNode
|
|
31
33
|
pressed?: boolean
|
|
32
34
|
selected?: boolean
|
|
@@ -71,6 +73,7 @@ const MenuItemComponent = forwardRef(function MenuItem(
|
|
|
71
73
|
radius = 2,
|
|
72
74
|
selected: selectedProp,
|
|
73
75
|
gap,
|
|
76
|
+
// oxlint-disable-next-line no-deprecated
|
|
74
77
|
space: deprecated_space = 3,
|
|
75
78
|
text,
|
|
76
79
|
tone = 'default',
|
|
@@ -192,6 +195,7 @@ MenuItemComponent.displayName = 'ForwardRef(MenuItem)'
|
|
|
192
195
|
/**
|
|
193
196
|
* @public
|
|
194
197
|
*/
|
|
198
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
195
199
|
export const MenuItem = MenuItemComponent as unknown as <E extends ElementType = 'button'>(
|
|
196
200
|
props: MenuItemProps<E>,
|
|
197
201
|
) => React.JSX.Element
|
|
@@ -23,6 +23,7 @@ export function useMenuController(props: {
|
|
|
23
23
|
onKeyDown?: React.KeyboardEventHandler
|
|
24
24
|
originElement?: HTMLElement | null
|
|
25
25
|
shouldFocus: 'first' | 'last' | null
|
|
26
|
+
// oxlint-disable-next-line no-deprecated
|
|
26
27
|
rootElementRef: React.MutableRefObject<HTMLDivElement | null>
|
|
27
28
|
}): MenuController {
|
|
28
29
|
const {onKeyDown, originElement, shouldFocus, rootElementRef} = props
|
|
@@ -217,6 +218,7 @@ export function useMenuController(props: {
|
|
|
217
218
|
element?.focus()
|
|
218
219
|
})
|
|
219
220
|
|
|
221
|
+
// oxlint-disable-next-line consistent-return
|
|
220
222
|
return () => cancelAnimationFrame(rafId)
|
|
221
223
|
}, [activeIndex, rootElementRef, setActiveIndex, shouldFocus])
|
|
222
224
|
|
|
@@ -28,6 +28,7 @@ export const Skeleton = forwardRef(function Skeleton(
|
|
|
28
28
|
ref: React.Ref<HTMLDivElement>,
|
|
29
29
|
) {
|
|
30
30
|
const {animated = false, delay, radius, ...restProps} = props
|
|
31
|
+
// oxlint-disable-next-line no-unneeded-ternary
|
|
31
32
|
const [visible, setVisible] = useState<boolean>(delay ? false : true)
|
|
32
33
|
|
|
33
34
|
useEffect(() => {
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
/** @
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import {beforeEach, describe, expect, it, vi} from 'vitest'
|
|
2
4
|
|
|
3
5
|
import {render} from '../../../../test'
|
|
4
6
|
import {inlineSpaceStyle} from '../../primitives/inline/styles'
|
|
5
7
|
import {Tab} from './tab'
|
|
6
8
|
import {TabList} from './tabList'
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
const actual =
|
|
10
|
+
vi.mock('../../primitives/inline/styles', async (importOriginal) => {
|
|
11
|
+
const actual = await importOriginal<typeof import('../../primitives/inline/styles')>()
|
|
10
12
|
|
|
11
13
|
return {
|
|
12
14
|
...actual,
|
|
13
|
-
inlineSpaceStyle:
|
|
15
|
+
inlineSpaceStyle: vi.fn(actual.inlineSpaceStyle),
|
|
14
16
|
}
|
|
15
17
|
})
|
|
16
18
|
|
|
17
19
|
describe('components/tabList', () => {
|
|
18
|
-
const mockedInlineSpaceStyle =
|
|
20
|
+
const mockedInlineSpaceStyle = vi.mocked(inlineSpaceStyle)
|
|
19
21
|
|
|
20
22
|
beforeEach(() => {
|
|
21
23
|
mockedInlineSpaceStyle.mockClear()
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
/** @
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import {describe, expect, it, vi} from 'vitest'
|
|
2
4
|
|
|
3
5
|
import {render} from '../../../../test'
|
|
4
6
|
import {ToastContext} from './toastContext'
|
|
@@ -8,7 +10,7 @@ import {useToast} from './useToast'
|
|
|
8
10
|
describe('components/toast', () => {
|
|
9
11
|
describe('useToast', () => {
|
|
10
12
|
it('should get context value', async () => {
|
|
11
|
-
const log =
|
|
13
|
+
const log = vi.fn()
|
|
12
14
|
|
|
13
15
|
function Debug() {
|
|
14
16
|
const rootToast = useToast()
|
|
@@ -25,6 +27,7 @@ describe('components/toast', () => {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
return (
|
|
30
|
+
// oxlint-disable-next-line jsx-no-constructed-context-values
|
|
28
31
|
<ToastContext.Provider value={value}>
|
|
29
32
|
<Debug />
|
|
30
33
|
</ToastContext.Provider>
|
|
@@ -38,7 +41,7 @@ describe('components/toast', () => {
|
|
|
38
41
|
})
|
|
39
42
|
|
|
40
43
|
it('should fail when no context value is provided', async () => {
|
|
41
|
-
const log =
|
|
44
|
+
const log = vi.fn()
|
|
42
45
|
|
|
43
46
|
function Debug() {
|
|
44
47
|
try {
|
|
@@ -54,6 +57,7 @@ describe('components/toast', () => {
|
|
|
54
57
|
const value = undefined
|
|
55
58
|
|
|
56
59
|
return (
|
|
60
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
57
61
|
<ToastContext.Provider value={value as any}>
|
|
58
62
|
<Debug />
|
|
59
63
|
</ToastContext.Provider>
|
|
@@ -66,7 +70,7 @@ describe('components/toast', () => {
|
|
|
66
70
|
})
|
|
67
71
|
|
|
68
72
|
it('should fail when context value is not compatible', async () => {
|
|
69
|
-
const log =
|
|
73
|
+
const log = vi.fn()
|
|
70
74
|
|
|
71
75
|
function Debug() {
|
|
72
76
|
try {
|
|
@@ -85,6 +89,7 @@ describe('components/toast', () => {
|
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
return (
|
|
92
|
+
// oxlint-disable-next-line jsx-no-constructed-context-values, no-unsafe-type-assertion
|
|
88
93
|
<ToastContext.Provider value={value as any}>
|
|
89
94
|
<Debug />
|
|
90
95
|
</ToastContext.Provider>
|
|
@@ -106,6 +106,7 @@ export function Toast(
|
|
|
106
106
|
>
|
|
107
107
|
<MotionFlex align="flex-start" variants={content} transition={transition}>
|
|
108
108
|
<TextBox flex={1} padding={3}>
|
|
109
|
+
{/* oxlint-disable-next-line no-deprecated */}
|
|
109
110
|
<Stack space={3}>
|
|
110
111
|
{title && (
|
|
111
112
|
<Text size={1} weight="medium">
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
/** @
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import {beforeEach, describe, expect, it, vi} from 'vitest'
|
|
2
4
|
|
|
3
5
|
import {render} from '../../../../test'
|
|
4
6
|
import {Stack} from '../../primitives'
|
|
5
7
|
import {Tree} from './tree'
|
|
6
8
|
import {TreeItem} from './treeItem'
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
const actual =
|
|
10
|
+
vi.mock('../../primitives', async (importOriginal) => {
|
|
11
|
+
const actual = await importOriginal<typeof import('../../primitives')>()
|
|
10
12
|
|
|
11
13
|
return {
|
|
12
14
|
...actual,
|
|
13
|
-
|
|
15
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
16
|
+
Stack: vi.fn((props: Record<string, unknown>) => (actual.Stack as any).render(props, null)),
|
|
14
17
|
}
|
|
15
18
|
})
|
|
16
19
|
|
|
17
20
|
describe('components/tree spacing', () => {
|
|
18
|
-
const mockedStack =
|
|
21
|
+
const mockedStack = vi.mocked(Stack)
|
|
19
22
|
|
|
20
23
|
beforeEach(() => {
|
|
21
24
|
mockedStack.mockClear()
|
|
@@ -23,6 +26,7 @@ describe('components/tree spacing', () => {
|
|
|
23
26
|
|
|
24
27
|
it('should support `space` and `gap` with the same behavior', () => {
|
|
25
28
|
render(
|
|
29
|
+
// oxlint-disable-next-line no-deprecated
|
|
26
30
|
<Tree space={2}>
|
|
27
31
|
<TreeItem text="Item 1" />
|
|
28
32
|
</Tree>,
|
|
@@ -44,6 +48,7 @@ describe('components/tree spacing', () => {
|
|
|
44
48
|
|
|
45
49
|
it('should prefer `gap` over `space` when both are provided', () => {
|
|
46
50
|
render(
|
|
51
|
+
// oxlint-disable-next-line no-deprecated
|
|
47
52
|
<Tree gap={3} space={1}>
|
|
48
53
|
<TreeItem text="Item 1" />
|
|
49
54
|
</Tree>,
|
|
@@ -34,6 +34,7 @@ export const Tree = forwardRef(function Tree(
|
|
|
34
34
|
Omit<React.HTMLProps<HTMLUListElement>, 'align' | 'as' | 'height' | 'ref' | 'role' | 'wrap'>,
|
|
35
35
|
forwardedRef: React.ForwardedRef<HTMLUListElement>,
|
|
36
36
|
): React.JSX.Element {
|
|
37
|
+
// oxlint-disable-next-line no-deprecated
|
|
37
38
|
const {children, gap, space: deprecated_space = 1, onFocus, ...restProps} = props
|
|
38
39
|
const spacing = gap === undefined ? deprecated_space : gap
|
|
39
40
|
const ref = useRef<HTMLUListElement | null>(null)
|
|
@@ -222,6 +223,7 @@ export const Tree = forwardRef(function Tree(
|
|
|
222
223
|
|
|
223
224
|
return (
|
|
224
225
|
<TreeContext.Provider value={contextValue}>
|
|
226
|
+
{/* oxlint-disable-next-line interactive-supports-focus */}
|
|
225
227
|
<Stack
|
|
226
228
|
as="ul"
|
|
227
229
|
data-ui="Tree"
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
/** @
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import {beforeEach, describe, expect, it, vi} from 'vitest'
|
|
2
4
|
|
|
3
5
|
import {render} from '../../../../test'
|
|
4
6
|
import {Box} from '../../primitives'
|
|
@@ -6,12 +8,13 @@ import {TreeContext} from './treeContext'
|
|
|
6
8
|
import {TreeItem} from './treeItem'
|
|
7
9
|
import {TreeContextValue, TreeState} from './types'
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
const actual =
|
|
11
|
+
vi.mock('../../primitives', async (importOriginal) => {
|
|
12
|
+
const actual = await importOriginal<typeof import('../../primitives')>()
|
|
11
13
|
|
|
12
14
|
return {
|
|
13
15
|
...actual,
|
|
14
|
-
|
|
16
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
17
|
+
Box: vi.fn((props: Record<string, unknown>) => (actual.Box as any).render(props, null)),
|
|
15
18
|
}
|
|
16
19
|
})
|
|
17
20
|
|
|
@@ -24,7 +27,9 @@ const treeContextValue: TreeContextValue = {
|
|
|
24
27
|
registerItem: () => () => undefined,
|
|
25
28
|
setExpanded: () => undefined,
|
|
26
29
|
setFocusedElement: () => undefined,
|
|
30
|
+
// oxlint-disable-next-line no-deprecated
|
|
27
31
|
space: 1,
|
|
32
|
+
// oxlint-disable-next-line no-unnecessary-type-assertion
|
|
28
33
|
state: {} as TreeState,
|
|
29
34
|
}
|
|
30
35
|
|
|
@@ -37,7 +42,7 @@ function renderTreeItem(props: Partial<React.ComponentProps<typeof TreeItem>> =
|
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
describe('components/treeItem spacing', () => {
|
|
40
|
-
const mockedBox =
|
|
45
|
+
const mockedBox = vi.mocked(Box)
|
|
41
46
|
|
|
42
47
|
beforeEach(() => {
|
|
43
48
|
mockedBox.mockClear()
|
package/src/core/hooks/index.ts
CHANGED