@sanity/ui 3.0.0-static.17 → 3.0.0-static.19
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/_chunks-cjs/_visual-editing.cjs +138 -137
- package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
- package/dist/_chunks-cjs/buildCommand.cjs +21 -22
- package/dist/_chunks-cjs/buildCommand.cjs.map +1 -1
- package/dist/_chunks-es/_visual-editing.js +139 -138
- package/dist/_chunks-es/_visual-editing.js.map +1 -1
- package/dist/_visual-editing.d.cts +12 -22
- package/dist/_visual-editing.d.ts +12 -22
- package/dist/cli.cjs +1 -1
- package/dist/css.cjs +1589 -2016
- package/dist/css.cjs.map +1 -1
- package/dist/css.d.cts +9427 -874
- package/dist/css.d.ts +9427 -874
- package/dist/css.js +1591 -2018
- package/dist/css.js.map +1 -1
- package/dist/index.cjs +28 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -23
- package/dist/index.d.ts +26 -23
- package/dist/index.js +30 -42
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs +2749 -2756
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.d.cts +242 -161
- package/dist/theme.d.ts +242 -161
- package/dist/theme.js +2750 -2757
- package/dist/theme.js.map +1 -1
- package/dist/ui-system.css +15719 -16097
- package/dist/ui-system.min.css +1 -1
- package/dist/ui-theme.css +850 -4568
- package/dist/ui-theme.min.css +1 -1
- package/dist/ui.css +16569 -20772
- package/dist/ui.min.css +1 -1
- package/package.json +10 -15
- package/src/cli/buildCommand.ts +13 -30
- package/src/core/StyleTags.tsx +4 -12
- package/src/core/_compat/styles/_responsive.ts +1 -1
- package/src/core/_compat/theme/theme.test.tsx +4 -5
- package/src/core/_compat/theme/themeColorProvider.tsx +2 -2
- package/src/core/_compat/theme/themeContext.ts +2 -2
- package/src/core/_compat/theme/themeProvider.tsx +2 -2
- package/src/core/_compat/theme/types.ts +1 -1
- package/src/core/_compat/theme/useRootTheme.ts +1 -1
- package/src/core/_compat/theme/useTheme.ts +1 -1
- package/src/core/components/autocomplete/__workshop__/async.tsx +2 -2
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
- package/src/core/components/autocomplete/__workshop__/custom.tsx +11 -11
- package/src/core/components/autocomplete/__workshop__/example.tsx +6 -7
- package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +2 -2
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +1 -1
- package/src/core/components/autocomplete/autocomplete.tsx +5 -5
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -1
- package/src/core/components/autocomplete/autocompleteReducer.ts +1 -1
- package/src/core/components/autocomplete/constants.ts +1 -1
- package/src/core/components/autocomplete/types.ts +1 -1
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +1 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +7 -7
- package/src/core/components/dialog/__workshop__/activate.tsx +4 -4
- package/src/core/components/dialog/__workshop__/position.tsx +1 -1
- package/src/core/components/dialog/__workshop__/props.tsx +1 -1
- package/src/core/components/dialog/__workshop__/wrapped.tsx +2 -2
- package/src/core/components/dialog/dialog.tsx +15 -8
- package/src/core/components/dialog/dialogCard.tsx +18 -3
- package/src/core/components/dialog/dialogContext.ts +1 -1
- package/src/core/components/dialog/dialogProvider.tsx +3 -3
- package/src/core/components/dialog/useDialog.ts +1 -1
- package/src/core/components/hotkeys/hotkeys.tsx +4 -4
- package/src/core/components/menu/__workshop__/closableMenuButton.tsx +5 -4
- package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +2 -2
- package/src/core/components/menu/__workshop__/customMenuItem.tsx +3 -3
- package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +1 -1
- package/src/core/components/menu/__workshop__/groups.tsx +2 -2
- package/src/core/components/menu/__workshop__/menuButton.tsx +1 -1
- package/src/core/components/menu/__workshop__/menuGroupRight.tsx +1 -1
- package/src/core/components/menu/__workshop__/nestedMenu.tsx +1 -1
- package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +13 -4
- package/src/core/components/menu/__workshop__/selectedItem.tsx +2 -2
- package/src/core/components/menu/__workshop__/withoutArrow.tsx +1 -1
- package/src/core/components/menu/menu.test.tsx +6 -7
- package/src/core/components/menu/menu.tsx +2 -2
- package/src/core/components/menu/menuButton.tsx +9 -9
- package/src/core/components/menu/menuContext.ts +1 -1
- package/src/core/components/menu/menuDivider.tsx +3 -3
- package/src/core/components/menu/menuGroup.tsx +9 -9
- package/src/core/components/menu/menuItem.tsx +9 -6
- package/src/core/components/menu/useMenu.ts +1 -1
- package/src/core/components/menu/useMenuController.ts +4 -4
- package/src/core/components/skeleton/__workshop__/delay.tsx +1 -1
- package/src/core/components/skeleton/__workshop__/skeleton.tsx +2 -2
- package/src/core/components/skeleton/codeSkeleton.tsx +5 -5
- package/src/core/components/skeleton/headingSkeleton.tsx +5 -5
- package/src/core/components/skeleton/labelSkeleton.tsx +5 -5
- package/src/core/components/skeleton/skeleton.tsx +4 -4
- package/src/core/components/skeleton/textSkeleton.tsx +5 -5
- package/src/core/components/tab/__workshop__/example.tsx +1 -1
- package/src/core/components/tab/tab.tsx +7 -7
- package/src/core/components/tab/tabList.tsx +14 -7
- package/src/core/components/tab/tabPanel.tsx +10 -7
- package/src/core/components/toast/__workshop__/hook.tsx +1 -1
- package/src/core/components/toast/toast.test.tsx +5 -5
- package/src/core/components/toast/toast.tsx +6 -7
- package/src/core/components/toast/toastContext.ts +1 -1
- package/src/core/components/toast/toastLayer.tsx +2 -2
- package/src/core/components/toast/toastProvider.tsx +1 -1
- package/src/core/components/toast/types.ts +1 -1
- package/src/core/components/toast/useToast.ts +1 -1
- package/src/core/components/tree/__workshop__/basic.perf.ts +1 -1
- package/src/core/components/tree/__workshop__/basic.tsx +1 -1
- package/src/core/components/tree/__workshop__/tabFromElement.tsx +1 -1
- package/src/core/components/tree/helpers.ts +1 -1
- package/src/core/components/tree/tree.tsx +6 -6
- package/src/core/components/tree/treeContext.ts +1 -1
- package/src/core/components/tree/treeGroup.tsx +2 -2
- package/src/core/components/tree/treeItem.tsx +15 -15
- package/src/core/components/tree/types.ts +2 -2
- package/src/core/components/tree/useTree.ts +1 -1
- package/src/core/hooks/useClickOutside.test.tsx +15 -16
- package/src/core/hooks/useClickOutsideEvent.test.tsx +4 -5
- package/src/core/hooks/useDelayed.test.ts +6 -7
- package/src/core/hooks/useDelayedState.ts +1 -1
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +1 -1
- package/src/core/hooks/useElementSize.ts +1 -1
- package/src/core/hooks/useForwardedRef.ts +1 -1
- package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +1 -1
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +3 -18
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +10 -10
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +4 -4
- package/src/core/hooks/usePrefersDark.test.tsx +1 -0
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +4 -4
- package/src/core/hooks/usePrefersReducedMotion.test.tsx +1 -0
- package/src/core/middleware/origin.ts +1 -1
- package/src/core/primitives/_selectable/selectable.tsx +3 -3
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +1 -1
- package/src/core/primitives/avatar/avatar.tsx +6 -6
- package/src/core/primitives/avatar/avatarCounter.tsx +3 -3
- package/src/core/primitives/avatar/avatarStack.tsx +7 -7
- package/src/core/primitives/avatar/types.ts +1 -3
- package/src/core/primitives/badge/badge.test.tsx +2 -3
- package/src/core/primitives/badge/badge.tsx +3 -3
- package/src/core/primitives/box/__workshop__/responsive.tsx +2 -1
- package/src/core/primitives/box/box.tsx +4 -2
- package/src/core/primitives/button/__workshop__/custom.tsx +2 -2
- package/src/core/primitives/button/__workshop__/customIcons.tsx +3 -3
- package/src/core/primitives/button/__workshop__/disabled.tsx +9 -9
- package/src/core/primitives/button/__workshop__/props.tsx +3 -4
- package/src/core/primitives/button/__workshop__/stacked.tsx +4 -5
- package/src/core/primitives/button/button.test.tsx +2 -3
- package/src/core/primitives/button/button.tsx +11 -6
- package/src/core/primitives/card/__workshop__/asButton.tsx +16 -7
- package/src/core/primitives/card/__workshop__/checkered.tsx +1 -1
- package/src/core/primitives/card/__workshop__/index.ts +1 -1
- package/src/core/primitives/card/__workshop__/interactive.tsx +1 -1
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +3 -3
- package/src/core/primitives/card/__workshop__/props.tsx +3 -3
- package/src/core/primitives/card/__workshop__/selected.tsx +2 -2
- package/src/core/primitives/card/__workshop__/{allTones.tsx → tones.tsx} +3 -3
- package/src/core/primitives/card/card.tsx +4 -4
- package/src/core/primitives/card/cardContext.ts +2 -2
- package/src/core/primitives/card/cardProvider.tsx +3 -3
- package/src/core/primitives/card/types.ts +2 -2
- package/src/core/primitives/card/useCard.ts +2 -1
- package/src/core/primitives/checkbox/__workshop__/props.tsx +2 -0
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +11 -20
- package/src/core/primitives/checkbox/checkbox.tsx +5 -7
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +1 -1
- package/src/core/primitives/code/code.tsx +3 -3
- package/src/core/primitives/container/container.tsx +4 -4
- package/src/core/primitives/flex/flex.tsx +2 -2
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +1 -1
- package/src/core/primitives/heading/heading.tsx +2 -2
- package/src/core/primitives/inline/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/inline/inline.tsx +2 -2
- package/src/core/primitives/inline/types.ts +1 -0
- package/src/core/primitives/kbd/kbd.tsx +5 -5
- package/src/core/primitives/label/label.tsx +5 -5
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +2 -2
- package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +3 -4
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +4 -4
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +2 -3
- package/src/core/primitives/popover/constants.ts +1 -1
- package/src/core/primitives/popover/floating-ui/size.ts +2 -2
- package/src/core/primitives/popover/helpers.ts +1 -1
- package/src/core/primitives/popover/popover.tsx +1 -1
- package/src/core/primitives/popover/popoverLayer.tsx +4 -4
- package/src/core/primitives/popover/types.ts +3 -2
- package/src/core/primitives/radio/__workshop__/example.tsx +1 -1
- package/src/core/primitives/radio/radio.tsx +5 -5
- package/src/core/primitives/select/__workshop__/plain.tsx +15 -3
- package/src/core/primitives/select/__workshop__/readOnly.tsx +1 -1
- package/src/core/primitives/select/select.tsx +4 -10
- package/src/core/primitives/spinner/__workshop__/Props.tsx +1 -2
- package/src/core/primitives/spinner/animatedSpinnerIcon.tsx +3 -3
- package/src/core/primitives/spinner/spinner.tsx +3 -3
- package/src/core/primitives/stack/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/stack/stack.tsx +5 -5
- package/src/core/primitives/switch/switch.tsx +3 -3
- package/src/core/primitives/text/__workshop__/colored.tsx +5 -5
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +1 -1
- package/src/core/primitives/text/text.tsx +6 -6
- package/src/core/primitives/textArea/__workshop__/plain.tsx +35 -23
- package/src/core/primitives/textArea/textArea.tsx +14 -5
- package/src/core/primitives/textInput/__workshop__/customValidity.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/plain.tsx +9 -15
- package/src/core/primitives/textInput/__workshop__/states.tsx +4 -4
- package/src/core/primitives/textInput/__workshop__/tones.tsx +2 -2
- package/src/core/primitives/textInput/textInput.tsx +13 -11
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +2 -2
- package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +1 -1
- package/src/core/primitives/tooltip/__workshop__/props.tsx +5 -4
- package/src/core/primitives/tooltip/constants.ts +1 -1
- package/src/core/primitives/tooltip/tooltip.test.tsx +61 -60
- package/src/core/primitives/tooltip/tooltip.tsx +11 -6
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx +1 -1
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +3 -3
- package/src/core/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts +1 -1
- package/src/core/primitives/tooltip/tooltipLayer.tsx +4 -4
- package/src/core/primitives/types.ts +15 -24
- package/src/core/types/badge.ts +1 -1
- package/src/core/types/button.ts +1 -1
- package/src/core/types/card.ts +1 -1
- package/src/core/types/selectable.ts +1 -1
- package/src/core/utils/arrow/arrow.tsx +5 -14
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +5 -5
- package/src/core/utils/boundaryElement/boundaryElementContext.ts +1 -1
- package/src/core/utils/boundaryElement/boundaryElementProvider.tsx +2 -2
- package/src/core/utils/boundaryElement/useBoundaryElement.ts +1 -1
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +15 -8
- package/src/core/utils/elementQuery/elementQuery.tsx +1 -1
- package/src/core/utils/errorBoundary.tsx +4 -4
- package/src/core/utils/layer/__workshop__/multipleRoots.tsx +5 -5
- package/src/core/utils/layer/__workshop__/nested.tsx +3 -3
- package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +9 -5
- package/src/core/utils/layer/getLayerContext.test.ts +3 -1
- package/src/core/utils/layer/getLayerContext.ts +1 -1
- package/src/core/utils/layer/layer.test.tsx +5 -5
- package/src/core/utils/layer/layer.tsx +2 -2
- package/src/core/utils/layer/layerCard.tsx +3 -3
- package/src/core/utils/layer/layerContext.ts +1 -1
- package/src/core/utils/layer/layerProvider.tsx +10 -2
- package/src/core/utils/layer/useLayer.ts +1 -1
- package/src/core/utils/portal/__workshop__/named.tsx +3 -3
- package/src/core/utils/portal/portal.test.tsx +5 -5
- package/src/core/utils/portal/portal.tsx +3 -2
- package/src/core/utils/portal/portalContext.ts +1 -1
- package/src/core/utils/portal/portalProvider.tsx +2 -2
- package/src/core/utils/portal/usePortal.ts +1 -1
- package/src/core/utils/srOnly/srOnly.tsx +3 -3
- package/src/core/utils/virtualList/__workshop__/infiniteList.tsx +1 -1
- package/src/core/utils/virtualList/virtualList.tsx +3 -3
- package/src/css/_assign.ts +3 -0
- package/src/css/_compileStyle.ts +12 -4
- package/src/css/_compileTheme.ts +10 -13
- package/src/css/_composeClassNames.ts +12 -0
- package/src/css/_fromEntries.ts +3 -0
- package/src/css/_getClassNames.ts +9 -0
- package/src/css/_hash.ts +9 -0
- package/src/css/_mergeStyles.ts +1 -1
- package/src/css/_resp.ts +6 -12
- package/src/css/_scopeClassName.ts +9 -0
- package/src/css/_scopeClassNames.ts +12 -0
- package/src/css/_system.style.ts +2 -0
- package/src/css/aspects/border/border.style.ts +2 -2
- package/src/css/aspects/border/border.ts +3 -3
- package/src/css/aspects/border/types.ts +1 -1
- package/src/css/aspects/boxSizing/boxSizing.style.ts +10 -0
- package/src/css/aspects/boxSizing/boxSizing.ts +8 -0
- package/src/css/aspects/boxSizing/index.ts +2 -0
- package/src/css/aspects/boxSizing/types.ts +9 -0
- package/src/css/aspects/display/display.style.ts +8 -8
- package/src/css/aspects/display/display.ts +3 -3
- package/src/css/aspects/display/types.ts +1 -1
- package/src/css/aspects/flex/flex.ts +3 -3
- package/src/css/aspects/flex/types.ts +1 -1
- package/src/css/aspects/flexItem/flex.style.ts +1 -1
- package/src/css/aspects/flexItem/flexItem.ts +3 -3
- package/src/css/aspects/flexItem/types.ts +1 -1
- package/src/css/aspects/font/font.style.ts +33 -22
- package/src/css/aspects/font/font.ts +3 -3
- package/src/css/aspects/font/types.ts +1 -1
- package/src/css/aspects/gap/gap.style.ts +2 -2
- package/src/css/aspects/gap/gap.ts +3 -3
- package/src/css/aspects/gap/types.ts +2 -2
- package/src/css/aspects/grid/grid.ts +3 -3
- package/src/css/aspects/grid/types.ts +1 -1
- package/src/css/aspects/gridItem/gridItem.ts +3 -3
- package/src/css/aspects/gridItem/types.ts +1 -1
- package/src/css/aspects/height/height.ts +3 -3
- package/src/css/aspects/index.ts +1 -0
- package/src/css/aspects/inset/inset.ts +3 -3
- package/src/css/aspects/inset/types.ts +1 -1
- package/src/css/aspects/margin/margin.style.ts +10 -10
- package/src/css/aspects/margin/margin.ts +3 -3
- package/src/css/aspects/margin/types.ts +1 -1
- package/src/css/aspects/maxWidth/maxWidth.style.ts +1 -1
- package/src/css/aspects/maxWidth/maxWidth.ts +4 -3
- package/src/css/aspects/maxWidth/types.ts +2 -2
- package/src/css/aspects/minWidth/minWidth.ts +4 -3
- package/src/css/aspects/minWidth/types.ts +1 -1
- package/src/css/aspects/overflow/overflow.ts +3 -3
- package/src/css/aspects/overflow/types.ts +1 -1
- package/src/css/aspects/padding/padding.style.ts +2 -5
- package/src/css/aspects/padding/padding.ts +3 -3
- package/src/css/aspects/padding/types.ts +2 -2
- package/src/css/aspects/pointerEvents/pointerEvents.ts +3 -3
- package/src/css/aspects/position/position.ts +3 -3
- package/src/css/aspects/position/types.ts +1 -1
- package/src/css/aspects/radius/radius.style.ts +1 -1
- package/src/css/aspects/radius/radius.ts +3 -3
- package/src/css/aspects/radius/types.ts +2 -2
- package/src/css/aspects/shadow/shadow.style.ts +7 -7
- package/src/css/aspects/shadow/shadow.ts +3 -3
- package/src/css/aspects/shadow/types.ts +2 -2
- package/src/css/aspects/textAlign/textAlign.style.ts +1 -1
- package/src/css/aspects/textAlign/textAlign.ts +3 -3
- package/src/css/aspects/textOverflow/textOverflow.ts +3 -3
- package/src/css/aspects/width/types.ts +2 -2
- package/src/css/aspects/width/width.style.ts +1 -1
- package/src/css/aspects/width/width.ts +4 -3
- package/src/css/components/breadcrumbs/breadcrumbs.style.ts +1 -1
- package/src/css/components/breadcrumbs/breadcrumbs.ts +2 -2
- package/src/css/components/dialog/dialog.style.ts +14 -16
- package/src/css/components/dialog/dialog.ts +9 -8
- package/src/css/components/menu/menu.style.ts +2 -2
- package/src/css/components/menu/menu.ts +3 -3
- package/src/css/components/skeleton/skeleton.style.ts +24 -17
- package/src/css/components/skeleton/skeleton.ts +8 -7
- package/src/css/components/skeleton/types.ts +4 -6
- package/src/css/components/toast/toast.style.ts +1 -1
- package/src/css/components/toast/toast.ts +6 -6
- package/src/css/components/tree/tree.style.ts +7 -23
- package/src/css/components/tree/tree.ts +2 -2
- package/src/css/constants.ts +1 -3
- package/src/css/index.ts +3 -5
- package/src/css/prefix/constants.ts +6 -0
- package/src/css/prefix/types.ts +1 -0
- package/src/css/primitives/_arrow/_arrow.style.ts +11 -13
- package/src/css/primitives/_arrow/_arrow.ts +5 -5
- package/src/css/primitives/_input/_input.style.ts +171 -75
- package/src/css/primitives/_input/input.ts +13 -10
- package/src/css/primitives/_input/types.ts +3 -3
- package/src/css/primitives/_selectable/_selectable.style.ts +5 -6
- package/src/css/primitives/_selectable/selectable.ts +4 -3
- package/src/css/primitives/_selectable/types.ts +2 -2
- package/src/css/primitives/avatar/avatar.style.ts +38 -39
- package/src/css/primitives/avatar/avatar.ts +8 -8
- package/src/css/primitives/avatar/types.ts +3 -3
- package/src/css/primitives/badge/badge.style.ts +2 -3
- package/src/css/primitives/badge/badge.ts +7 -3
- package/src/css/primitives/badge/types.ts +2 -2
- package/src/css/primitives/box/box.style.ts +5 -15
- package/src/css/primitives/box/box.ts +7 -9
- package/src/css/primitives/box/types.ts +3 -6
- package/src/css/primitives/button/button.style.ts +189 -162
- package/src/css/primitives/button/button.ts +11 -4
- package/src/css/primitives/button/types.ts +1 -1
- package/src/css/primitives/card/card.style.ts +102 -68
- package/src/css/primitives/card/card.ts +5 -7
- package/src/css/primitives/card/types.ts +2 -2
- package/src/css/primitives/checkbox/checkbox.style.ts +125 -101
- package/src/css/primitives/checkbox/checkbox.ts +3 -3
- package/src/css/primitives/code/code.style.ts +24 -26
- package/src/css/primitives/code/code.ts +7 -3
- package/src/css/primitives/code/types.ts +2 -2
- package/src/css/primitives/container/container.style.ts +1 -1
- package/src/css/primitives/container/container.ts +4 -3
- package/src/css/primitives/container/types.ts +2 -2
- package/src/css/primitives/heading/heading.style.ts +31 -23
- package/src/css/primitives/heading/heading.ts +10 -8
- package/src/css/primitives/heading/types.ts +3 -2
- package/src/css/primitives/kbd/kbd.style.ts +7 -7
- package/src/css/primitives/kbd/kbd.ts +4 -3
- package/src/css/primitives/kbd/types.ts +1 -1
- package/src/css/primitives/label/label.style.ts +27 -24
- package/src/css/primitives/label/label.ts +5 -8
- package/src/css/primitives/label/types.ts +4 -3
- package/src/css/primitives/popover/popover.style.ts +6 -2
- package/src/css/primitives/popover/popover.ts +3 -3
- package/src/css/primitives/radio/radio.style.ts +37 -76
- package/src/css/primitives/radio/radio.ts +2 -2
- package/src/css/primitives/select/select.style.ts +3 -3
- package/src/css/primitives/select/select.ts +5 -5
- package/src/css/primitives/select/types.ts +1 -1
- package/src/css/primitives/spinner/spinner.style.ts +1 -1
- package/src/css/primitives/spinner/spinner.ts +3 -3
- package/src/css/primitives/stack/stack.style.ts +6 -2
- package/src/css/primitives/stack/stack.ts +2 -2
- package/src/css/primitives/switch/switch.style.ts +47 -39
- package/src/css/primitives/switch/switch.ts +6 -6
- package/src/css/primitives/text/text.style.ts +28 -23
- package/src/css/primitives/text/text.ts +5 -8
- package/src/css/primitives/text/types.ts +2 -2
- package/src/css/primitives/textArea/textArea.style.ts +6 -2
- package/src/css/primitives/textArea/textArea.ts +4 -4
- package/src/css/primitives/textArea/types.ts +1 -1
- package/src/css/primitives/textInput/textInput.style.ts +23 -17
- package/src/css/primitives/textInput/textInput.ts +4 -4
- package/src/css/primitives/textInput/types.ts +2 -8
- package/src/css/primitives/token/token.style.ts +4 -4
- package/src/css/primitives/tooltip/tooltip.style.ts +5 -4
- package/src/css/primitives/tooltip/tooltip.ts +3 -3
- package/src/css/renderColor.ts +31 -0
- package/src/css/theme/index.ts +14 -0
- package/src/css/theme/lib/contract/buildVarContract.ts +76 -0
- package/src/css/theme/lib/contract/index.ts +2 -0
- package/src/css/theme/lib/contract/types.ts +15 -0
- package/src/css/theme/resolveTheme.ts +852 -0
- package/src/css/types.ts +26 -910
- package/src/css/utils/srOnly/srOnly.style.ts +1 -1
- package/src/css/utils/srOnly/srOnly.ts +3 -3
- package/src/theme/getScopedTheme.ts +4 -4
- package/src/theme/index.ts +0 -5
- package/src/theme/types.ts +4 -4
- package/src/theme/v0/color/_generic.ts +1 -1
- package/src/theme/v0/color/button.ts +1 -1
- package/src/theme/v0/color/card.ts +1 -1
- package/src/theme/v0/color/color.ts +11 -11
- package/src/theme/v0/color/input.ts +1 -1
- package/src/theme/v0/color/muted.ts +1 -1
- package/src/theme/v0/color/selectable.ts +1 -1
- package/src/theme/v0/color/solid.ts +1 -1
- package/src/theme/v0/color/spot.ts +1 -1
- package/src/theme/v0/styles.ts +1 -1
- package/src/theme/v0/theme.ts +7 -7
- package/src/theme/v2/avatar.ts +1 -1
- package/src/theme/{build → v2/build}/_deprecated/color/_selectable/createSelectableTones.ts +3 -3
- package/src/theme/{build → v2/build}/_deprecated/color/_solid/createSolidTones.ts +2 -2
- package/src/theme/{build → v2/build}/_deprecated/color/button/createButtonModes.ts +7 -2
- package/src/theme/{build → v2/build}/_deprecated/color/button/createButtonTones.ts +4 -4
- package/src/theme/{build → v2/build}/_deprecated/color/card/createCardStates.ts +3 -3
- package/src/theme/{build → v2/build}/_deprecated/color/color.test.ts +1 -1
- package/src/theme/{build → v2/build}/_deprecated/color/defaults.ts +1 -1
- package/src/theme/{build → v2/build}/_deprecated/color/factory.ts +3 -3
- package/src/theme/{build → v2/build}/_deprecated/color/input/createInputModes.ts +7 -2
- package/src/theme/{build → v2/build}/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/{build → v2/build}/_deprecated/color/spot/createSpot.ts +2 -2
- package/src/theme/{build → v2/build}/buildColorTheme.test.ts +3 -1
- package/src/theme/{build → v2/build}/buildColorTheme.ts +24 -24
- package/src/theme/{build → v2/build}/buildTheme.test.ts +10 -8
- package/src/theme/{build → v2/build}/buildTheme.ts +4 -4
- package/src/theme/{build → v2/build}/colorToken/colorToken.ts +2 -2
- package/src/theme/{build → v2/build}/colorToken/compileColorToken.ts +1 -1
- package/src/theme/{build → v2/build}/colorToken/types.ts +2 -2
- package/src/theme/{build → v2/build}/lib/color-fns/blend/mix.ts +1 -1
- package/src/theme/{build → v2/build}/lib/color-fns/blend/multiply.ts +1 -1
- package/src/theme/{build → v2/build}/lib/color-fns/blend/screen.ts +1 -1
- package/src/theme/{build → v2/build}/lib/color-fns/color-fns.test.ts +1 -1
- package/src/theme/{build → v2/build}/lib/color-fns/contrastRatio.ts +5 -2
- package/src/theme/{build → v2/build}/lib/color-fns/convert.ts +1 -1
- package/src/theme/{build → v2/build}/lib/color-fns/parse.ts +1 -1
- package/src/theme/{build → v2/build}/mixThemeColor.test.ts +2 -0
- package/src/theme/{build → v2/build}/mixThemeColor.ts +1 -1
- package/src/theme/{build → v2/build}/renderColorTheme.ts +27 -27
- package/src/theme/{build → v2/build}/renderColorValue.ts +3 -3
- package/src/theme/{build → v2/build}/resolveColorTokens.ts +13 -13
- package/src/theme/v2/color/_helpers.ts +2 -2
- package/src/theme/v2/color/_system.ts +1 -1
- package/src/theme/v2/color/avatar.ts +1 -1
- package/src/theme/v2/color/badge.ts +1 -1
- package/src/theme/v2/color/button.ts +2 -2
- package/src/theme/v2/color/color.ts +7 -7
- package/src/theme/v2/color/input.ts +5 -1
- package/src/theme/v2/color/selectable.ts +2 -2
- package/src/theme/v2/color/state.ts +4 -4
- package/src/theme/{config → v2/config}/helpers.ts +6 -13
- package/src/theme/{config → v2/config}/system.ts +11 -12
- package/src/theme/{config → v2/config}/tokens/color/types.ts +14 -10
- package/src/theme/{config → v2/config}/tokens/index.ts +0 -1
- package/src/theme/{config → v2/config}/tokens/parseTokenValue.test.ts +2 -0
- package/src/theme/{config → v2/config}/tokens/parseTokenValue.ts +2 -2
- package/src/theme/{config → v2/config}/tokens/types.ts +3 -3
- package/src/theme/{config → v2/config}/types.ts +8 -6
- package/src/theme/{defaults → v2/defaults}/colorPalette.ts +1 -1
- package/src/theme/{defaults → v2/defaults}/colorTokens.ts +1 -1
- package/src/theme/{defaults → v2/defaults}/config.ts +1 -1
- package/src/theme/{defaults → v2/defaults}/fonts.ts +1 -1
- package/src/theme/v2/index.ts +2 -0
- package/src/theme/v2/input.ts +1 -1
- package/src/theme/v2/theme.ts +8 -8
- package/src/theme/{_constants.ts → v3/_constants.ts} +6 -3
- package/src/theme/v3/_parseColorToken.ts +185 -0
- package/src/theme/v3/buildTheme_v3.ts +11 -7
- package/src/theme/v3/color/_constants.ts +15 -0
- package/src/theme/v3/color/avatar.ts +14 -0
- package/src/theme/v3/color/card.ts +53 -53
- package/src/theme/v3/color/color.ts +66 -68
- package/src/theme/v3/color/element.ts +8 -8
- package/src/theme/v3/color/index.ts +2 -2
- package/src/theme/v3/color/token.ts +18 -4
- package/src/theme/v3/color/tokens.ts +2 -2
- package/src/theme/v3/defaultTokens.ts +73 -85
- package/src/theme/v3/index.ts +3 -0
- package/src/theme/v3/palette/index.ts +2 -0
- package/src/theme/v3/resolveTokens.ts +65 -65
- package/src/theme/v3/tokens.ts +2 -2
- package/src/theme/v3/types.ts +61 -7
- package/src/theme/versioning/getTheme_v2.ts +3 -3
- package/src/theme/versioning/is_v0.ts +2 -2
- package/src/theme/versioning/is_v2.ts +2 -2
- package/src/theme/versioning/themeColor_v0_v2.ts +2 -2
- package/src/theme/versioning/themeColor_v2_v2_9.ts +1 -1
- package/src/theme/versioning/themeColor_v3_v2.ts +229 -52
- package/src/theme/versioning/v0_v2.ts +3 -3
- package/src/theme/versioning/v2_v0.ts +4 -4
- package/src/theme/versioning/v3_v2.ts +38 -38
- package/dist/ui-palette.css +0 -105
- package/dist/ui-palette.min.css +0 -1
- package/src/css/_comp.test.ts +0 -7
- package/src/css/_comp.ts +0 -11
- package/src/css/_compilePalette.ts +0 -32
- package/src/css/_compileTheme_v3.ts +0 -440
- package/src/css/aspects/flex/flex.style.ts +0 -30
- package/src/css/composeClassNames.ts +0 -19
- package/src/css/primitives/_selectable/__style.ts +0 -117
- package/src/css/primitives/checkbox/__styles.ts +0 -129
- package/src/css/scopeClassName.ts +0 -7
- package/src/css/varNames.ts +0 -607
- package/src/css/vars.ts +0 -520
- package/src/theme/_types.ts +0 -41
- package/src/theme/build/theme.test.ts +0 -27
- package/src/theme/config/tokens/parseTokenKey.test.ts +0 -64
- package/src/theme/config/tokens/parseTokenKey.ts +0 -67
- package/src/theme/v3/buildTheme_v3.test.ts +0 -40
- package/src/theme/v3/color/buildColor_v3.ts +0 -226
- package/src/theme/v3/color/parseColor.test.ts +0 -79
- package/src/theme/v3/color/parseColor.ts +0 -167
- package/src/theme/v3/color/renderColor.test.ts +0 -20
- package/src/theme/v3/color/renderColor.ts +0 -43
- /package/src/{theme/palette → css/prefix}/index.ts +0 -0
- /package/src/theme/{build → v2/build}/_deprecated/color/index.ts +0 -0
- /package/src/theme/{build → v2/build}/colorToken/index.ts +0 -0
- /package/src/theme/{build → v2/build}/index.ts +0 -0
- /package/src/theme/{build → v2/build}/lib/color-fns/blend/index.ts +0 -0
- /package/src/theme/{build → v2/build}/lib/color-fns/index.ts +0 -0
- /package/src/theme/{build → v2/build}/lib/color-fns/rgba.ts +0 -0
- /package/src/theme/{build → v2/build}/lib/color-fns/types.ts +0 -0
- /package/src/theme/{build → v2/build}/lib/isRecord.ts +0 -0
- /package/src/theme/{build → v2/build}/lib/utils.ts +0 -0
- /package/src/theme/{build → v2/build}/merge.ts +0 -0
- /package/src/theme/{config → v2/config}/index.ts +0 -0
- /package/src/theme/{config → v2/config}/tokens/color/index.ts +0 -0
- /package/src/theme/{palette → v3/palette}/constants.ts +0 -0
- /package/src/theme/{palette → v3/palette}/types.ts +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {CloseIcon} from '@sanity/icons'
|
|
2
2
|
import {
|
|
3
|
+
_composeClassNames,
|
|
3
4
|
_inputElement,
|
|
4
5
|
_inputPresentation,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ResponsiveProp,
|
|
6
|
+
type InputStyleProps,
|
|
7
|
+
type ResponsiveProp,
|
|
8
8
|
textInput,
|
|
9
9
|
} from '@sanity/ui/css'
|
|
10
|
-
import {Space, ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
10
|
+
import type {Space, ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
11
11
|
import {
|
|
12
|
-
CSSProperties,
|
|
13
|
-
ElementType,
|
|
12
|
+
type CSSProperties,
|
|
13
|
+
type ElementType,
|
|
14
14
|
isValidElement,
|
|
15
|
-
MouseEvent,
|
|
16
|
-
ReactNode,
|
|
15
|
+
type MouseEvent,
|
|
16
|
+
type ReactNode,
|
|
17
17
|
useCallback,
|
|
18
18
|
useImperativeHandle,
|
|
19
19
|
useMemo,
|
|
@@ -24,9 +24,9 @@ import {isValidElementType} from 'react-is'
|
|
|
24
24
|
import {EMPTY_RECORD} from '../../constants'
|
|
25
25
|
import {useArrayProp, useCustomValidity} from '../../hooks'
|
|
26
26
|
import {isRecord} from '../../lib/isRecord'
|
|
27
|
-
import {ComponentType, Props} from '../../types'
|
|
27
|
+
import type {ComponentType, Props} from '../../types'
|
|
28
28
|
import {Box} from '../box'
|
|
29
|
-
import {Button, ButtonProps} from '../button'
|
|
29
|
+
import {Button, type ButtonProps} from '../button'
|
|
30
30
|
import {Text} from '../text'
|
|
31
31
|
|
|
32
32
|
/** @public */
|
|
@@ -177,7 +177,7 @@ export function TextInput<E extends TextInputElementType = typeof DEFAULT_TEXT_I
|
|
|
177
177
|
<Box
|
|
178
178
|
align="center"
|
|
179
179
|
as="span"
|
|
180
|
-
className={
|
|
180
|
+
className={_composeClassNames(
|
|
181
181
|
className,
|
|
182
182
|
textInput({
|
|
183
183
|
border,
|
|
@@ -190,7 +190,9 @@ export function TextInput<E extends TextInputElementType = typeof DEFAULT_TEXT_I
|
|
|
190
190
|
)}
|
|
191
191
|
data-icon-left={IconComponent ? '' : undefined}
|
|
192
192
|
data-icon-right={IconRightComponent ? '' : undefined}
|
|
193
|
+
data-invalid={customValidity ? '' : undefined}
|
|
193
194
|
data-prefix={prefix ? '' : undefined}
|
|
195
|
+
data-read-only={!disabled && readOnly ? '' : undefined}
|
|
194
196
|
data-suffix={suffix ? '' : undefined}
|
|
195
197
|
data-ui="TextInput"
|
|
196
198
|
display="flex"
|
|
@@ -55,7 +55,7 @@ export default function CustomPortalStory() {
|
|
|
55
55
|
<Text>Boundary element</Text>
|
|
56
56
|
<Flex align="center" height="fill" justify="center">
|
|
57
57
|
<Flex justify="center">
|
|
58
|
-
<Stack
|
|
58
|
+
<Stack gap={2}>
|
|
59
59
|
<Tooltip
|
|
60
60
|
boundaryElement={useBoundaryElement ? boundaryElement : null}
|
|
61
61
|
content={<Text size={1}>{content}</Text>}
|
|
@@ -87,7 +87,7 @@ export default function CustomPortalStory() {
|
|
|
87
87
|
/>
|
|
88
88
|
|
|
89
89
|
<Portal __unstable_name="portal1">
|
|
90
|
-
<Stack
|
|
90
|
+
<Stack gap={4}>
|
|
91
91
|
<Text size={1} weight="medium">
|
|
92
92
|
Portal 1 content
|
|
93
93
|
</Text>
|
|
@@ -40,7 +40,7 @@ export default function OverflowingBoundaryStory() {
|
|
|
40
40
|
>
|
|
41
41
|
<Flex align="center" height="fill" justify="center">
|
|
42
42
|
<Flex justify="center">
|
|
43
|
-
<Stack
|
|
43
|
+
<Stack gap={2}>
|
|
44
44
|
<Code size={1}>Placement: {placement}</Code>
|
|
45
45
|
<Button
|
|
46
46
|
disabled={buttonsVisible}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {Button, Card, Flex, Stack, Text, Tooltip, TooltipDelayGroupProvider} from '@sanity/ui'
|
|
2
|
+
import {vars} from '@sanity/ui/css'
|
|
2
3
|
import {useBoolean, useNumber, useSelect, useText} from '@sanity/ui-workshop'
|
|
3
4
|
|
|
4
5
|
import {
|
|
@@ -29,9 +30,9 @@ export default function PropsStory() {
|
|
|
29
30
|
gap={4}
|
|
30
31
|
>
|
|
31
32
|
<Stack
|
|
33
|
+
gap={4}
|
|
32
34
|
padding={4}
|
|
33
|
-
style={{outline:
|
|
34
|
-
space={4}
|
|
35
|
+
style={{outline: `1px solid ${vars.color.border}`, width: '100%', maxWidth: '640px'}}
|
|
35
36
|
>
|
|
36
37
|
<Text align="center" size={3}>
|
|
37
38
|
Standalone tooltip
|
|
@@ -54,9 +55,9 @@ export default function PropsStory() {
|
|
|
54
55
|
</Flex>
|
|
55
56
|
</Stack>
|
|
56
57
|
<Stack
|
|
58
|
+
gap={4}
|
|
57
59
|
padding={4}
|
|
58
|
-
style={{outline:
|
|
59
|
-
space={4}
|
|
60
|
+
style={{outline: `1px solid ${vars.color.border}`, width: '100%', maxWidth: '640px'}}
|
|
60
61
|
>
|
|
61
62
|
<Text align="center" size={3}>
|
|
62
63
|
Grouped tooltips
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
/** @jest-environment jsdom */
|
|
2
|
-
|
|
3
1
|
import '../../../../test/mocks/resizeObserver.mock'
|
|
4
2
|
import '../../../../test/mocks/matchMedia.mock'
|
|
5
3
|
|
|
6
4
|
import {act, fireEvent, screen} from '@testing-library/react'
|
|
5
|
+
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'
|
|
7
6
|
|
|
8
7
|
import {render} from '../../../../test'
|
|
9
|
-
import {Button
|
|
10
|
-
import {
|
|
8
|
+
import {Button} from '../button'
|
|
9
|
+
import {Text} from '../text'
|
|
10
|
+
import {Tooltip} from './tooltip'
|
|
11
|
+
import {TooltipDelayGroupProvider} from './tooltipDelayGroup'
|
|
11
12
|
|
|
12
|
-
// Fake timers
|
|
13
|
+
// Fake timers
|
|
13
14
|
beforeEach(() => {
|
|
14
|
-
|
|
15
|
+
vi.useFakeTimers()
|
|
15
16
|
})
|
|
16
17
|
|
|
17
|
-
// Running all pending timers and switching to real timers
|
|
18
|
+
// Running all pending timers and switching to real timers
|
|
18
19
|
afterEach(() => {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
vi.runOnlyPendingTimers()
|
|
21
|
+
vi.useRealTimers()
|
|
21
22
|
})
|
|
22
23
|
|
|
23
24
|
describe('Tooltip', () => {
|
|
@@ -44,7 +45,7 @@ describe('Tooltip', () => {
|
|
|
44
45
|
expect(screen.queryByText('Tooltip content')).not.toBeInTheDocument()
|
|
45
46
|
})
|
|
46
47
|
it('should support delays to show and hide the tooltip.', () => {
|
|
47
|
-
|
|
48
|
+
vi.useFakeTimers()
|
|
48
49
|
const delay = 200
|
|
49
50
|
|
|
50
51
|
render(
|
|
@@ -64,10 +65,10 @@ describe('Tooltip', () => {
|
|
|
64
65
|
|
|
65
66
|
fireEvent.mouseEnter(button)
|
|
66
67
|
|
|
67
|
-
act(() =>
|
|
68
|
+
act(() => vi.advanceTimersByTime(delay / 2))
|
|
68
69
|
// Content should not be rendered yet
|
|
69
70
|
expect(screen.queryByText('Tooltip content')).not.toBeInTheDocument()
|
|
70
|
-
act(() =>
|
|
71
|
+
act(() => vi.advanceTimersByTime(delay / 2))
|
|
71
72
|
|
|
72
73
|
// Validate tooltip content is rendered
|
|
73
74
|
screen.getByText('Tooltip content')
|
|
@@ -75,12 +76,12 @@ describe('Tooltip', () => {
|
|
|
75
76
|
fireEvent.mouseOut(button)
|
|
76
77
|
// Validate tooltip content is still showing.
|
|
77
78
|
screen.getByText('Tooltip content')
|
|
78
|
-
act(() =>
|
|
79
|
+
act(() => vi.advanceTimersByTime(delay))
|
|
79
80
|
// Validate tooltip content is not rendered anymore
|
|
80
81
|
expect(screen.queryByText('Tooltip content')).not.toBeInTheDocument()
|
|
81
82
|
})
|
|
82
83
|
it('should support different open and close delays to show and hide the tooltip.', () => {
|
|
83
|
-
|
|
84
|
+
vi.useFakeTimers()
|
|
84
85
|
const openDelay = 200
|
|
85
86
|
const closeDelay = 150
|
|
86
87
|
|
|
@@ -104,10 +105,10 @@ describe('Tooltip', () => {
|
|
|
104
105
|
|
|
105
106
|
fireEvent.mouseEnter(button)
|
|
106
107
|
|
|
107
|
-
act(() =>
|
|
108
|
+
act(() => vi.advanceTimersByTime(openDelay / 2))
|
|
108
109
|
// Content should not be rendered yet
|
|
109
110
|
expect(screen.queryByText('Tooltip content')).not.toBeInTheDocument()
|
|
110
|
-
act(() =>
|
|
111
|
+
act(() => vi.advanceTimersByTime(openDelay / 2))
|
|
111
112
|
|
|
112
113
|
// Validate tooltip content is rendered
|
|
113
114
|
screen.getByText('Tooltip content')
|
|
@@ -115,7 +116,7 @@ describe('Tooltip', () => {
|
|
|
115
116
|
fireEvent.mouseOut(button)
|
|
116
117
|
// Validate tooltip content is still showing.
|
|
117
118
|
screen.getByText('Tooltip content')
|
|
118
|
-
act(() =>
|
|
119
|
+
act(() => vi.advanceTimersByTime(closeDelay))
|
|
119
120
|
// Validate tooltip content is not rendered anymore
|
|
120
121
|
expect(screen.queryByText('Tooltip content')).not.toBeInTheDocument()
|
|
121
122
|
})
|
|
@@ -125,7 +126,7 @@ describe('Tooltip', () => {
|
|
|
125
126
|
it('should support groups with the same delay to open and close.', () => {
|
|
126
127
|
const delay = 150
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
vi.useFakeTimers()
|
|
129
130
|
render(
|
|
130
131
|
<TooltipDelayGroupProvider delay={delay}>
|
|
131
132
|
<Tooltip content={<Text size={1}>{'Tooltip 1'}</Text>} placement={'top'} delay={400}>
|
|
@@ -150,11 +151,11 @@ describe('Tooltip', () => {
|
|
|
150
151
|
|
|
151
152
|
// Hovers on first button, it should show first tooltip only
|
|
152
153
|
fireEvent.mouseEnter(button1)
|
|
153
|
-
act(() =>
|
|
154
|
+
act(() => vi.advanceTimersByTime(delay / 2))
|
|
154
155
|
// Content should not be rendered yet, we have a delay of 150ms
|
|
155
156
|
expect(screen.queryByText('Tooltip 1')).not.toBeInTheDocument()
|
|
156
157
|
expect(screen.queryByText('Tooltip 2')).not.toBeInTheDocument()
|
|
157
|
-
act(() =>
|
|
158
|
+
act(() => vi.advanceTimersByTime(delay / 2))
|
|
158
159
|
|
|
159
160
|
// Validate Tooltip 1 is rendered
|
|
160
161
|
screen.getByText('Tooltip 1')
|
|
@@ -165,38 +166,38 @@ describe('Tooltip', () => {
|
|
|
165
166
|
fireEvent.mouseEnter(button2)
|
|
166
167
|
|
|
167
168
|
// Validate Tooltip 1 is not rendered, now tooltip 2 is open.
|
|
168
|
-
act(() =>
|
|
169
|
+
act(() => vi.advanceTimersByTime(1))
|
|
169
170
|
expect(screen.queryByText('Tooltip 1')).not.toBeInTheDocument()
|
|
170
171
|
screen.getByText('Tooltip 2')
|
|
171
172
|
|
|
172
173
|
// Validate tooltip content is not rendered anymore
|
|
173
174
|
fireEvent.mouseOut(button2)
|
|
174
|
-
act(() =>
|
|
175
|
+
act(() => vi.advanceTimersByTime(delay + 1))
|
|
175
176
|
expect(screen.queryByText('Tooltip 2')).not.toBeInTheDocument()
|
|
176
177
|
|
|
177
178
|
// Hovering again, should trigger the tooltip to show immediately, as the group is not deactivated yet
|
|
178
179
|
fireEvent.mouseEnter(button2)
|
|
179
|
-
act(() =>
|
|
180
|
+
act(() => vi.advanceTimersByTime(1))
|
|
180
181
|
screen.getByText('Tooltip 2')
|
|
181
182
|
|
|
182
183
|
// Validate tooltip content is not rendered anymore
|
|
183
184
|
fireEvent.mouseOut(button2)
|
|
184
|
-
act(() =>
|
|
185
|
+
act(() => vi.advanceTimersByTime(delay + 1))
|
|
185
186
|
expect(screen.queryByText('Tooltip 2')).not.toBeInTheDocument()
|
|
186
187
|
|
|
187
188
|
// Wait 200ms, the group is deactivated, hovering again should trigger the delay
|
|
188
|
-
act(() =>
|
|
189
|
+
act(() => vi.advanceTimersByTime(200))
|
|
189
190
|
fireEvent.mouseEnter(button2)
|
|
190
|
-
act(() =>
|
|
191
|
+
act(() => vi.advanceTimersByTime(delay / 2))
|
|
191
192
|
expect(screen.queryByText('Tooltip 2')).not.toBeInTheDocument()
|
|
192
|
-
act(() =>
|
|
193
|
+
act(() => vi.advanceTimersByTime(delay / 2))
|
|
193
194
|
screen.getByText('Tooltip 2')
|
|
194
195
|
})
|
|
195
196
|
it('should support groups with different open and close delay.', () => {
|
|
196
197
|
const openDelay = 250
|
|
197
198
|
const closeDelay = 150
|
|
198
199
|
|
|
199
|
-
|
|
200
|
+
vi.useFakeTimers()
|
|
200
201
|
render(
|
|
201
202
|
<TooltipDelayGroupProvider
|
|
202
203
|
delay={{
|
|
@@ -226,11 +227,11 @@ describe('Tooltip', () => {
|
|
|
226
227
|
|
|
227
228
|
// Hovers on first button, it should show first tooltip only
|
|
228
229
|
fireEvent.mouseEnter(button1)
|
|
229
|
-
act(() =>
|
|
230
|
+
act(() => vi.advanceTimersByTime(openDelay / 2))
|
|
230
231
|
// Content should not be rendered yet, we have a delay of2150ms
|
|
231
232
|
expect(screen.queryByText('Tooltip 1')).not.toBeInTheDocument()
|
|
232
233
|
expect(screen.queryByText('Tooltip 2')).not.toBeInTheDocument()
|
|
233
|
-
act(() =>
|
|
234
|
+
act(() => vi.advanceTimersByTime(openDelay / 2))
|
|
234
235
|
|
|
235
236
|
// Validate Tooltip 1 is rendered
|
|
236
237
|
screen.getByText('Tooltip 1')
|
|
@@ -241,31 +242,31 @@ describe('Tooltip', () => {
|
|
|
241
242
|
fireEvent.mouseEnter(button2)
|
|
242
243
|
|
|
243
244
|
// Validate Tooltip 1 is not rendered, now tooltip 2 is open.
|
|
244
|
-
act(() =>
|
|
245
|
+
act(() => vi.advanceTimersByTime(1))
|
|
245
246
|
expect(screen.queryByText('Tooltip 1')).not.toBeInTheDocument()
|
|
246
247
|
screen.getByText('Tooltip 2')
|
|
247
248
|
|
|
248
249
|
// Validate tooltip content is not rendered anymore
|
|
249
250
|
fireEvent.mouseOut(button2)
|
|
250
|
-
act(() =>
|
|
251
|
+
act(() => vi.advanceTimersByTime(closeDelay + 1))
|
|
251
252
|
expect(screen.queryByText('Tooltip 2')).not.toBeInTheDocument()
|
|
252
253
|
|
|
253
254
|
// Hovering again, should trigger the tooltip to show immediately, as the group is not deactivated yet
|
|
254
255
|
fireEvent.mouseEnter(button2)
|
|
255
|
-
act(() =>
|
|
256
|
+
act(() => vi.advanceTimersByTime(1))
|
|
256
257
|
screen.getByText('Tooltip 2')
|
|
257
258
|
|
|
258
259
|
// Validate tooltip content is not rendered anymore
|
|
259
260
|
fireEvent.mouseOut(button2)
|
|
260
|
-
act(() =>
|
|
261
|
+
act(() => vi.advanceTimersByTime(closeDelay + 1))
|
|
261
262
|
expect(screen.queryByText('Tooltip 2')).not.toBeInTheDocument()
|
|
262
263
|
|
|
263
264
|
// Wait 200ms, the group is deactivated, hovering again should trigger the delay
|
|
264
|
-
act(() =>
|
|
265
|
+
act(() => vi.advanceTimersByTime(200))
|
|
265
266
|
fireEvent.mouseEnter(button2)
|
|
266
|
-
act(() =>
|
|
267
|
+
act(() => vi.advanceTimersByTime(openDelay / 2))
|
|
267
268
|
expect(screen.queryByText('Tooltip 2')).not.toBeInTheDocument()
|
|
268
|
-
act(() =>
|
|
269
|
+
act(() => vi.advanceTimersByTime(openDelay / 2))
|
|
269
270
|
screen.getByText('Tooltip 2')
|
|
270
271
|
})
|
|
271
272
|
})
|
|
@@ -274,7 +275,7 @@ describe('Tooltip', () => {
|
|
|
274
275
|
it('Standalone tooltip closes immediately with Escape key', () => {
|
|
275
276
|
const delay = 150
|
|
276
277
|
|
|
277
|
-
|
|
278
|
+
vi.useFakeTimers()
|
|
278
279
|
|
|
279
280
|
render(
|
|
280
281
|
<Tooltip
|
|
@@ -290,8 +291,8 @@ describe('Tooltip', () => {
|
|
|
290
291
|
|
|
291
292
|
// Validate tooltip content is not rendered
|
|
292
293
|
expect(screen.queryByText('Tooltip content')).not.toBeInTheDocument()
|
|
293
|
-
fireEvent.focus(button)
|
|
294
|
-
act(() =>
|
|
294
|
+
act(() => fireEvent.focus(button))
|
|
295
|
+
act(() => vi.advanceTimersByTime(delay))
|
|
295
296
|
|
|
296
297
|
// Validate tooltip content is rendered
|
|
297
298
|
screen.getByText('Tooltip content')
|
|
@@ -305,7 +306,7 @@ describe('Tooltip', () => {
|
|
|
305
306
|
it('With <TooltipDelayGroupProvider /> closes immediately with Escape key', () => {
|
|
306
307
|
const delay = 150
|
|
307
308
|
|
|
308
|
-
|
|
309
|
+
vi.useFakeTimers()
|
|
309
310
|
|
|
310
311
|
render(
|
|
311
312
|
<TooltipDelayGroupProvider delay={{close: delay}}>
|
|
@@ -323,9 +324,9 @@ describe('Tooltip', () => {
|
|
|
323
324
|
|
|
324
325
|
// Validate tooltip content is not rendered
|
|
325
326
|
expect(screen.queryByText('Tooltip content')).not.toBeInTheDocument()
|
|
326
|
-
fireEvent.focus(button)
|
|
327
|
+
act(() => fireEvent.focus(button))
|
|
327
328
|
|
|
328
|
-
act(() =>
|
|
329
|
+
act(() => vi.advanceTimersByTime(delay))
|
|
329
330
|
|
|
330
331
|
// Validate tooltip content is rendered
|
|
331
332
|
screen.getByText('Tooltip content')
|
|
@@ -352,9 +353,9 @@ describe('Tooltip', () => {
|
|
|
352
353
|
|
|
353
354
|
// Assertion: tooltip does not exist in the document
|
|
354
355
|
expect(screen.queryByText('Tooltip content')).not.toBeInTheDocument()
|
|
355
|
-
fireEvent.focus(button)
|
|
356
|
+
act(() => fireEvent.focus(button))
|
|
356
357
|
|
|
357
|
-
act(() =>
|
|
358
|
+
act(() => vi.advanceTimersByTime(delay))
|
|
358
359
|
|
|
359
360
|
// Assertion: the tooltip is not visible
|
|
360
361
|
expect(screen.queryByText('Tooltip content')).toBeVisible()
|
|
@@ -378,9 +379,9 @@ describe('Tooltip', () => {
|
|
|
378
379
|
|
|
379
380
|
// Assertion: tooltip does not exist in the document
|
|
380
381
|
expect(screen.queryByText('Tooltip content')).not.toBeInTheDocument()
|
|
381
|
-
fireEvent.focus(button)
|
|
382
|
+
act(() => fireEvent.focus(button))
|
|
382
383
|
|
|
383
|
-
act(() =>
|
|
384
|
+
act(() => vi.advanceTimersByTime(delay))
|
|
384
385
|
|
|
385
386
|
// Assertion: the tooltip is not visible
|
|
386
387
|
expect(screen.queryByText('Tooltip content')).toBeVisible()
|
|
@@ -393,12 +394,12 @@ describe('Tooltip', () => {
|
|
|
393
394
|
})
|
|
394
395
|
|
|
395
396
|
describe('Used defined events on <Tooltip /> child should fire correctly', () => {
|
|
396
|
-
const handleBlur =
|
|
397
|
-
const handleClick =
|
|
398
|
-
const handleContextMenu =
|
|
399
|
-
const handleFocus =
|
|
400
|
-
const handleMouseEnter =
|
|
401
|
-
const handleMouseLeave =
|
|
397
|
+
const handleBlur = vi.fn()
|
|
398
|
+
const handleClick = vi.fn()
|
|
399
|
+
const handleContextMenu = vi.fn()
|
|
400
|
+
const handleFocus = vi.fn()
|
|
401
|
+
const handleMouseEnter = vi.fn()
|
|
402
|
+
const handleMouseLeave = vi.fn()
|
|
402
403
|
|
|
403
404
|
beforeEach(() => {
|
|
404
405
|
render(
|
|
@@ -418,35 +419,35 @@ describe('Tooltip', () => {
|
|
|
418
419
|
)
|
|
419
420
|
})
|
|
420
421
|
|
|
421
|
-
afterEach(() =>
|
|
422
|
+
afterEach(() => vi.clearAllMocks())
|
|
422
423
|
|
|
423
424
|
it('should fire the onBlur event', () => {
|
|
424
|
-
fireEvent.blur(screen.getByTestId('btn'))
|
|
425
|
+
act(() => fireEvent.blur(screen.getByTestId('btn')))
|
|
425
426
|
expect(handleBlur).toHaveBeenCalledTimes(1)
|
|
426
427
|
})
|
|
427
428
|
|
|
428
429
|
it('should fire the onClick event', () => {
|
|
429
|
-
fireEvent.click(screen.getByTestId('btn'))
|
|
430
|
+
act(() => fireEvent.click(screen.getByTestId('btn')))
|
|
430
431
|
expect(handleClick).toHaveBeenCalledTimes(1)
|
|
431
432
|
})
|
|
432
433
|
|
|
433
434
|
it('should fire the onContextMenu event', () => {
|
|
434
|
-
fireEvent.contextMenu(screen.getByTestId('btn'))
|
|
435
|
+
act(() => fireEvent.contextMenu(screen.getByTestId('btn')))
|
|
435
436
|
expect(handleContextMenu).toHaveBeenCalledTimes(1)
|
|
436
437
|
})
|
|
437
438
|
|
|
438
439
|
it('should fire the onFocus event', () => {
|
|
439
|
-
fireEvent.focus(screen.getByTestId('btn'))
|
|
440
|
+
act(() => fireEvent.focus(screen.getByTestId('btn')))
|
|
440
441
|
expect(handleFocus).toHaveBeenCalledTimes(1)
|
|
441
442
|
})
|
|
442
443
|
|
|
443
444
|
it('should fire the onMouseEnter event', () => {
|
|
444
|
-
fireEvent.mouseEnter(screen.getByTestId('btn'))
|
|
445
|
+
act(() => fireEvent.mouseEnter(screen.getByTestId('btn')))
|
|
445
446
|
expect(handleMouseEnter).toHaveBeenCalledTimes(1)
|
|
446
447
|
})
|
|
447
448
|
|
|
448
449
|
it('should fire the onMouseLeave event', () => {
|
|
449
|
-
fireEvent.mouseLeave(screen.getByTestId('btn'))
|
|
450
|
+
act(() => fireEvent.mouseLeave(screen.getByTestId('btn')))
|
|
450
451
|
expect(handleMouseLeave).toHaveBeenCalledTimes(1)
|
|
451
452
|
})
|
|
452
453
|
})
|
|
@@ -8,17 +8,22 @@ import {
|
|
|
8
8
|
shift,
|
|
9
9
|
useFloating,
|
|
10
10
|
} from '@floating-ui/react-dom'
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
_composeClassNames,
|
|
13
|
+
type RadiusStyleProps,
|
|
14
|
+
type ShadowStyleProps,
|
|
15
|
+
tooltip,
|
|
16
|
+
} from '@sanity/ui/css'
|
|
12
17
|
import type {ThemeColorCardToneKey, ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
13
18
|
import {AnimatePresence} from 'framer-motion'
|
|
14
19
|
import {
|
|
15
20
|
cloneElement,
|
|
16
21
|
type FocusEvent,
|
|
17
|
-
HTMLAttributes,
|
|
22
|
+
type HTMLAttributes,
|
|
18
23
|
type MouseEvent as ReactMouseEvent,
|
|
19
24
|
type ReactElement,
|
|
20
25
|
type ReactNode,
|
|
21
|
-
RefAttributes,
|
|
26
|
+
type RefAttributes,
|
|
22
27
|
useCallback,
|
|
23
28
|
useEffect,
|
|
24
29
|
useId,
|
|
@@ -38,7 +43,7 @@ import type {ComponentType, Placement, Props} from '../../types'
|
|
|
38
43
|
import {type LayerOwnProps, Portal, useBoundaryElement, usePortal} from '../../utils'
|
|
39
44
|
import {getElementRef} from '../../utils/getElementRef'
|
|
40
45
|
import {CardProvider, useCard} from '../card'
|
|
41
|
-
import {Delay} from '../types'
|
|
46
|
+
import type {Delay} from '../types'
|
|
42
47
|
import {
|
|
43
48
|
DEFAULT_FALLBACK_PLACEMENTS,
|
|
44
49
|
DEFAULT_TOOLTIP_DISTANCE,
|
|
@@ -107,7 +112,7 @@ export function Tooltip<E extends TooltipElementType = typeof DEFAULT_TOOLTIP_EL
|
|
|
107
112
|
const boundaryElementContext = useBoundaryElement()
|
|
108
113
|
|
|
109
114
|
const {
|
|
110
|
-
animate: _animate =
|
|
115
|
+
animate: _animate = false,
|
|
111
116
|
arrow: arrowProp = false,
|
|
112
117
|
as = DEFAULT_TOOLTIP_ELEMENT,
|
|
113
118
|
boundaryElement = boundaryElementContext?.element,
|
|
@@ -391,7 +396,7 @@ export function Tooltip<E extends TooltipElementType = typeof DEFAULT_TOOLTIP_EL
|
|
|
391
396
|
arrowX={arrowX}
|
|
392
397
|
arrowY={arrowY}
|
|
393
398
|
as={as}
|
|
394
|
-
className={
|
|
399
|
+
className={_composeClassNames(className, tooltip())}
|
|
395
400
|
originX={originX}
|
|
396
401
|
originY={originY}
|
|
397
402
|
padding={padding}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {ReactElement, ReactNode, useMemo} from 'react'
|
|
1
|
+
import {type ReactElement, type ReactNode, useMemo} from 'react'
|
|
2
2
|
|
|
3
3
|
import {useDelayedState} from '../../../hooks/useDelayedState'
|
|
4
|
-
import {Delay} from '../../types'
|
|
4
|
+
import type {Delay} from '../../types'
|
|
5
5
|
import {TooltipDelayGroupContext} from './tooltipDelayGroupContext'
|
|
6
|
-
import {TooltipDelayGroupContextValue} from './types'
|
|
6
|
+
import type {TooltipDelayGroupContextValue} from './types'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @public
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {tooltipCard} from '@sanity/ui/css'
|
|
2
|
-
import {motion, MotionStyle} from 'framer-motion'
|
|
3
|
-
import {type CSSProperties, ForwardedRef, useMemo} from 'react'
|
|
2
|
+
import {motion, type MotionStyle} from 'framer-motion'
|
|
3
|
+
import {type CSSProperties, type ForwardedRef, useMemo} from 'react'
|
|
4
4
|
|
|
5
5
|
import {POPOVER_MOTION_PROPS} from '../../constants'
|
|
6
|
-
import {Placement} from '../../types'
|
|
7
|
-
import {Arrow, Layer, LayerOwnProps, LayerProps} from '../../utils'
|
|
6
|
+
import type {Placement} from '../../types'
|
|
7
|
+
import {Arrow, Layer, type LayerOwnProps, type LayerProps} from '../../utils'
|
|
8
8
|
import {
|
|
9
9
|
DEFAULT_TOOLTIP_ARROW_HEIGHT,
|
|
10
10
|
DEFAULT_TOOLTIP_ARROW_RADIUS,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type {
|
|
2
|
+
FlexAlign,
|
|
3
|
+
FlexDirection,
|
|
4
|
+
FlexJustify,
|
|
5
|
+
FlexValue,
|
|
6
|
+
FlexWrap,
|
|
7
7
|
GridItemColumn,
|
|
8
8
|
GridItemColumnEnd,
|
|
9
9
|
GridItemColumnStart,
|
|
@@ -12,21 +12,15 @@ import {
|
|
|
12
12
|
GridItemRowStart,
|
|
13
13
|
} from '@sanity/ui/css'
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// type GridItemColumnEnd,
|
|
25
|
-
// type GridItemColumnStart,
|
|
26
|
-
// type GridItemRow,
|
|
27
|
-
// type GridItemRowEnd,
|
|
28
|
-
// type GridItemRowStart,
|
|
29
|
-
type Radius,
|
|
15
|
+
import type {
|
|
16
|
+
BoxDisplay,
|
|
17
|
+
BoxHeight,
|
|
18
|
+
BoxOverflow,
|
|
19
|
+
BoxSizing,
|
|
20
|
+
GridAutoCols,
|
|
21
|
+
GridAutoFlow,
|
|
22
|
+
GridAutoRows,
|
|
23
|
+
Radius,
|
|
30
24
|
} from '../types'
|
|
31
25
|
|
|
32
26
|
/**
|
|
@@ -81,9 +75,6 @@ export interface ResponsiveGridProps {
|
|
|
81
75
|
autoCols?: GridAutoCols | GridAutoCols[]
|
|
82
76
|
autoFlow?: GridAutoFlow | GridAutoFlow[]
|
|
83
77
|
columns?: number | number[]
|
|
84
|
-
// gap?: number | number[]
|
|
85
|
-
// gapX?: number | number[]
|
|
86
|
-
// gapY?: number | number[]
|
|
87
78
|
rows?: number | number[]
|
|
88
79
|
}
|
|
89
80
|
|
package/src/core/types/badge.ts
CHANGED
package/src/core/types/button.ts
CHANGED
package/src/core/types/card.ts
CHANGED