@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,6 +1,6 @@
|
|
|
1
1
|
import {useEffect, useState} from 'react'
|
|
2
2
|
|
|
3
|
-
import {_elementSizeObserver, ElementSize} from '../observers/elementSizeObserver'
|
|
3
|
+
import {_elementSizeObserver, type ElementSize} from '../observers/elementSizeObserver'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Subscribe to the size of a DOM element.
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
/** @jest-environment node */
|
|
2
2
|
|
|
3
|
-
import {buildTheme} from '@sanity/ui/theme'
|
|
4
3
|
import {renderToStaticMarkup, renderToString} from 'react-dom/server'
|
|
4
|
+
import {describe, expect, it} from 'vitest'
|
|
5
5
|
|
|
6
|
-
import {ThemeProvider} from '../../_compat'
|
|
7
6
|
import {useMediaIndex} from './useMediaIndex'
|
|
8
7
|
|
|
9
|
-
const theme = buildTheme()
|
|
10
|
-
|
|
11
8
|
function Log() {
|
|
12
9
|
const mediaIndex = useMediaIndex()
|
|
13
10
|
|
|
@@ -16,21 +13,9 @@ function Log() {
|
|
|
16
13
|
|
|
17
14
|
describe('useMediaIndex', () => {
|
|
18
15
|
it(`SSR to static markup returns 0`, () => {
|
|
19
|
-
expect(
|
|
20
|
-
renderToStaticMarkup(
|
|
21
|
-
<ThemeProvider theme={theme}>
|
|
22
|
-
<Log />
|
|
23
|
-
</ThemeProvider>,
|
|
24
|
-
),
|
|
25
|
-
).toBe('mediaIndex: 0')
|
|
16
|
+
expect(renderToStaticMarkup(<Log />)).toBe('mediaIndex: 0')
|
|
26
17
|
})
|
|
27
18
|
it(`SSR to markup for hydration doesn't throw`, () => {
|
|
28
|
-
expect(
|
|
29
|
-
renderToString(
|
|
30
|
-
<ThemeProvider theme={theme}>
|
|
31
|
-
<Log />
|
|
32
|
-
</ThemeProvider>,
|
|
33
|
-
),
|
|
34
|
-
).toMatchInlineSnapshot(`"mediaIndex: <!-- -->0"`)
|
|
19
|
+
expect(renderToString(<Log />)).toMatchInlineSnapshot(`"mediaIndex: <!-- -->0"`)
|
|
35
20
|
})
|
|
36
21
|
})
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import {type Breakpoint, BREAKPOINTS} from '@sanity/ui/css'
|
|
1
2
|
import {useMemo, useSyncExternalStore} from 'react'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const media = [360, 600, 900, 1200, 1800, 2400]
|
|
4
|
+
const media = Object.values(BREAKPOINTS)
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
9
|
export interface _MediaStore {
|
|
10
10
|
subscribe: (onStoreChange: () => void) => () => void
|
|
11
|
-
getSnapshot: () =>
|
|
11
|
+
getSnapshot: () => Breakpoint
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
type MediaQueryMinWidth = `(min-width: ${number}px)`
|
|
@@ -18,14 +18,14 @@ type MediaQuery = `screen and ${MediaQueryMinWidth | MediaQueryMaxWidth | MediaQ
|
|
|
18
18
|
|
|
19
19
|
function _getMediaQuery(media: number[], index: number): MediaQuery {
|
|
20
20
|
if (index === 0) {
|
|
21
|
-
return `screen and (max-width: ${media[index] - 1}px)`
|
|
21
|
+
return `screen and (max-width: ${media[index + 1] - 1}px)`
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
if (index === media.length) {
|
|
25
|
-
return `screen and (min-width: ${media[index
|
|
24
|
+
if (index === media.length - 1) {
|
|
25
|
+
return `screen and (min-width: ${media[index]}px)`
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
return `screen and (min-width: ${media[index
|
|
28
|
+
return `screen and (min-width: ${media[index]}px) and (max-width: ${media[index + 1] - 1}px)`
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function _createMediaStore(): _MediaStore {
|
|
@@ -51,7 +51,7 @@ function _createMediaStore(): _MediaStore {
|
|
|
51
51
|
|
|
52
52
|
const getSnapshot = () => {
|
|
53
53
|
for (const {index, mq} of getSizes()) {
|
|
54
|
-
if (mq.matches) return index
|
|
54
|
+
if (mq.matches) return index as Breakpoint
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
return 0
|
|
@@ -87,7 +87,7 @@ function _createMediaStore(): _MediaStore {
|
|
|
87
87
|
*
|
|
88
88
|
* @link https://beta.reactjs.org/apis/react/useSyncExternalStore#adding-support-for-server-rendering
|
|
89
89
|
*/
|
|
90
|
-
function getServerSnapshot() {
|
|
90
|
+
function getServerSnapshot(): Breakpoint {
|
|
91
91
|
return 0
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -95,7 +95,7 @@ function getServerSnapshot() {
|
|
|
95
95
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
96
96
|
* @beta
|
|
97
97
|
*/
|
|
98
|
-
export function useMediaIndex():
|
|
98
|
+
export function useMediaIndex(): Breakpoint {
|
|
99
99
|
const store = useMemo(() => _createMediaStore(), [])
|
|
100
100
|
|
|
101
101
|
return useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/** @jest-environment jsdom */
|
|
2
1
|
/**
|
|
3
2
|
* As this hook is used for top-level theming it's likely to be called while server-rendering
|
|
4
3
|
* and that's why it's worth it to have a testing suite for hydration
|
|
5
4
|
*/
|
|
6
5
|
import {waitFor} from '@testing-library/dom'
|
|
7
6
|
import {hydrateRoot} from 'react-dom/client'
|
|
7
|
+
import {afterAll, beforeAll, describe, expect, it, vi} from 'vitest'
|
|
8
8
|
|
|
9
9
|
import {usePrefersDark} from './usePrefersDark'
|
|
10
10
|
|
|
@@ -20,8 +20,8 @@ describe('usePrefersDark SSR hydration', () => {
|
|
|
20
20
|
beforeAll(() => {
|
|
21
21
|
window.matchMedia = () =>
|
|
22
22
|
({
|
|
23
|
-
addEventListener:
|
|
24
|
-
removeEventListener:
|
|
23
|
+
addEventListener: vi.fn(),
|
|
24
|
+
removeEventListener: vi.fn(),
|
|
25
25
|
matches: true,
|
|
26
26
|
}) as any
|
|
27
27
|
})
|
|
@@ -31,7 +31,7 @@ describe('usePrefersDark SSR hydration', () => {
|
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
it(`hydrates without any warnings`, async () => {
|
|
34
|
-
const spy =
|
|
34
|
+
const spy = vi.spyOn(console, 'error') // .mockImplementation()
|
|
35
35
|
|
|
36
36
|
const node = document.createElement('div')
|
|
37
37
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/** @jest-environment jsdom */
|
|
2
1
|
/**
|
|
3
2
|
* As this hook is used for top-level theming it's likely to be called while server-rendering
|
|
4
3
|
* and that's why it's worth it to have a testing suite for hydration
|
|
5
4
|
*/
|
|
6
5
|
import {waitFor} from '@testing-library/dom'
|
|
7
6
|
import {hydrateRoot} from 'react-dom/client'
|
|
7
|
+
import {afterAll, beforeAll, describe, expect, it, vi} from 'vitest'
|
|
8
8
|
|
|
9
9
|
import {usePrefersReducedMotion} from './usePrefersReducedMotion'
|
|
10
10
|
|
|
@@ -20,8 +20,8 @@ describe('usePrefersReducedMotion SSR hydration', () => {
|
|
|
20
20
|
beforeAll(() => {
|
|
21
21
|
window.matchMedia = () =>
|
|
22
22
|
({
|
|
23
|
-
addEventListener:
|
|
24
|
-
removeEventListener:
|
|
23
|
+
addEventListener: vi.fn(),
|
|
24
|
+
removeEventListener: vi.fn(),
|
|
25
25
|
matches: true,
|
|
26
26
|
}) as any
|
|
27
27
|
})
|
|
@@ -31,7 +31,7 @@ describe('usePrefersReducedMotion SSR hydration', () => {
|
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
it(`hydrates without any warnings`, async () => {
|
|
34
|
-
const spy =
|
|
34
|
+
const spy = vi.spyOn(console, 'error') // .mockImplementation()
|
|
35
35
|
|
|
36
36
|
const node = document.createElement('div')
|
|
37
37
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_composeClassNames, _selectable, type SelectableStyleProps} from '@sanity/ui/css'
|
|
2
2
|
|
|
3
3
|
import type {ComponentType, Props, SelectableTone} from '../../types'
|
|
4
|
-
import {Box, BoxOwnProps} from '../box'
|
|
4
|
+
import {Box, type BoxOwnProps} from '../box'
|
|
5
5
|
|
|
6
6
|
/** @internal */
|
|
7
7
|
export const DEFAULT_SELECTABLE_ELEMENT = 'button'
|
|
@@ -37,7 +37,7 @@ export function Selectable<E extends SelectableElementType = typeof DEFAULT_SELE
|
|
|
37
37
|
} = props as SelectableProps<typeof DEFAULT_SELECTABLE_ELEMENT>
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
|
-
<Box {...rest} as={as} className={
|
|
40
|
+
<Box {...rest} as={as} className={_composeClassNames(className, _selectable({radius, tone}))} />
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -14,7 +14,7 @@ export default function WithinButtonStory() {
|
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<Container width={1}>
|
|
17
|
-
<Stack paddingX={4} paddingY={[5, 6, 7]}
|
|
17
|
+
<Stack gap={1} paddingX={4} paddingY={[5, 6, 7]}>
|
|
18
18
|
<Button disabled={disabled} padding={1}>
|
|
19
19
|
<Flex align="center" flex={1} gap={3} padding={2}>
|
|
20
20
|
<Box flex={1}>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
_composeClassNames,
|
|
2
3
|
avatar,
|
|
3
4
|
avatarArrow,
|
|
4
5
|
avatarImage,
|
|
5
6
|
avatarInitials,
|
|
6
|
-
|
|
7
|
-
ResponsiveProp,
|
|
7
|
+
type ResponsiveProp,
|
|
8
8
|
} from '@sanity/ui/css'
|
|
9
|
-
import {
|
|
9
|
+
import type {AvatarColor} from '@sanity/ui/theme'
|
|
10
10
|
import {useCallback, useEffect, useMemo, useState} from 'react'
|
|
11
11
|
|
|
12
12
|
import {useArrayProp} from '../../hooks'
|
|
@@ -23,7 +23,7 @@ export interface AvatarOwnProps {
|
|
|
23
23
|
__unstable_hideInnerStroke?: boolean
|
|
24
24
|
animateArrowFrom?: AvatarPosition
|
|
25
25
|
arrowPosition?: AvatarPosition
|
|
26
|
-
color?:
|
|
26
|
+
color?: AvatarColor
|
|
27
27
|
initials?: string
|
|
28
28
|
onImageLoadError?: (event: Error) => void
|
|
29
29
|
size?: ResponsiveProp<AvatarSize>
|
|
@@ -54,7 +54,7 @@ export function Avatar<E extends AvatarElementType = typeof DEFAULT_AVATAR_ELEME
|
|
|
54
54
|
__unstable_hideInnerStroke,
|
|
55
55
|
as: Element = DEFAULT_AVATAR_ELEMENT,
|
|
56
56
|
className,
|
|
57
|
-
color = '
|
|
57
|
+
color = 'magenta',
|
|
58
58
|
src,
|
|
59
59
|
title,
|
|
60
60
|
initials,
|
|
@@ -114,7 +114,7 @@ export function Avatar<E extends AvatarElementType = typeof DEFAULT_AVATAR_ELEME
|
|
|
114
114
|
data-ui="Avatar"
|
|
115
115
|
{...rest}
|
|
116
116
|
aria-label={title}
|
|
117
|
-
className={
|
|
117
|
+
className={_composeClassNames(className, avatar({color, size: sizeProp}))}
|
|
118
118
|
data-arrow-position={arrowPosition}
|
|
119
119
|
data-image-error={imageError ? '' : undefined}
|
|
120
120
|
title={title}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_composeClassNames, avatarCounter, type ResponsiveProp} from '@sanity/ui/css'
|
|
2
2
|
import type {AvatarSize, FontLabelSize} from '@sanity/ui/theme'
|
|
3
3
|
import {useMemo} from 'react'
|
|
4
4
|
|
|
5
5
|
import {useArrayProp} from '../../hooks'
|
|
6
|
-
import {ComponentType, Props} from '../../types'
|
|
6
|
+
import type {ComponentType, Props} from '../../types'
|
|
7
7
|
import {Box} from '../box'
|
|
8
8
|
import {Label} from '../label'
|
|
9
9
|
|
|
@@ -54,7 +54,7 @@ export function AvatarCounter<
|
|
|
54
54
|
{...rest}
|
|
55
55
|
align="center"
|
|
56
56
|
as={as}
|
|
57
|
-
className={
|
|
57
|
+
className={_composeClassNames(className, avatarCounter({size}))}
|
|
58
58
|
display="flex"
|
|
59
59
|
justify="center"
|
|
60
60
|
paddingX={2}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {AvatarSize} from '@sanity/ui/theme'
|
|
3
|
-
import {Children, cloneElement, isValidElement, ReactElement} from 'react'
|
|
1
|
+
import {_composeClassNames, avatarStack, type ResponsiveProp} from '@sanity/ui/css'
|
|
2
|
+
import type {AvatarSize} from '@sanity/ui/theme'
|
|
3
|
+
import {Children, cloneElement, isValidElement, type ReactElement} from 'react'
|
|
4
4
|
|
|
5
5
|
import {useArrayProp} from '../../hooks'
|
|
6
|
-
import {ComponentType, Props} from '../../types'
|
|
7
|
-
import {Box, BoxOwnProps} from '../box'
|
|
8
|
-
import {AvatarProps} from './avatar'
|
|
6
|
+
import type {ComponentType, Props} from '../../types'
|
|
7
|
+
import {Box, type BoxOwnProps} from '../box'
|
|
8
|
+
import type {AvatarProps} from './avatar'
|
|
9
9
|
import {AvatarCounter} from './avatarCounter'
|
|
10
10
|
|
|
11
11
|
/** @public */
|
|
@@ -62,7 +62,7 @@ export function AvatarStack<E extends AvatarStackElementType = typeof DEFAULT_AV
|
|
|
62
62
|
{...rest}
|
|
63
63
|
align="center"
|
|
64
64
|
as={as}
|
|
65
|
-
className={
|
|
65
|
+
className={_composeClassNames(className, avatarStack({size}))}
|
|
66
66
|
display="flex"
|
|
67
67
|
>
|
|
68
68
|
{len === 0 && (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {PaddingStyleProps, RadiusStyleProps, ResponsiveProp} from '@sanity/ui/css'
|
|
2
|
-
import {
|
|
3
|
-
import {FontTextSize} from '@sanity/ui/theme'
|
|
2
|
+
import {_composeClassNames, badge} from '@sanity/ui/css'
|
|
3
|
+
import type {FontTextSize} from '@sanity/ui/theme'
|
|
4
4
|
|
|
5
5
|
import type {BadgeTone, ComponentType, Props} from '../../types'
|
|
6
6
|
import {Box} from '../box'
|
|
@@ -46,7 +46,7 @@ export function Badge<E extends BadgeElementType = typeof DEFAULT_BADGE_ELEMENT>
|
|
|
46
46
|
data-ui="Badge"
|
|
47
47
|
{...rest}
|
|
48
48
|
as={as}
|
|
49
|
-
className={
|
|
49
|
+
className={_composeClassNames(
|
|
50
50
|
className,
|
|
51
51
|
badge({
|
|
52
52
|
radius,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {Box, Text} from '@sanity/ui'
|
|
2
|
+
import {vars} from '@sanity/ui/css'
|
|
2
3
|
|
|
3
4
|
export default function ResponsiveStory() {
|
|
4
5
|
return (
|
|
@@ -9,7 +10,7 @@ export default function ResponsiveStory() {
|
|
|
9
10
|
flex={[1, 2, 3, 4, 5, 6, 7]}
|
|
10
11
|
padding={3}
|
|
11
12
|
sizing={['content', 'border', 'content', 'border', 'content', 'border', 'content']}
|
|
12
|
-
style={{outline:
|
|
13
|
+
style={{outline: `1px solid ${vars.color.border}`}}
|
|
13
14
|
>
|
|
14
15
|
<Text align="center" muted>
|
|
15
16
|
This is a box with responsive props
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
InsetStyleProps,
|
|
5
5
|
PositionStyleProps,
|
|
6
6
|
} from '@sanity/ui/css'
|
|
7
|
-
import {
|
|
7
|
+
import {_composeClassNames, box} from '@sanity/ui/css'
|
|
8
8
|
|
|
9
9
|
import type {ComponentType, Props} from '../../types'
|
|
10
10
|
|
|
@@ -20,6 +20,7 @@ export type BoxElementType =
|
|
|
20
20
|
| 'article'
|
|
21
21
|
| 'aside'
|
|
22
22
|
| 'blockquote'
|
|
23
|
+
| 'body'
|
|
23
24
|
| 'button'
|
|
24
25
|
| 'details'
|
|
25
26
|
| 'div'
|
|
@@ -29,6 +30,7 @@ export type BoxElementType =
|
|
|
29
30
|
| 'figcaption'
|
|
30
31
|
| 'footer'
|
|
31
32
|
| 'form'
|
|
33
|
+
| 'html'
|
|
32
34
|
| 'iframe'
|
|
33
35
|
| 'kbd'
|
|
34
36
|
| 'label'
|
|
@@ -123,7 +125,7 @@ export function Box<E extends BoxElementType = typeof DEFAULT_BOX_ELEMENT>(props
|
|
|
123
125
|
<Element
|
|
124
126
|
data-ui="Box"
|
|
125
127
|
{...rest}
|
|
126
|
-
className={
|
|
128
|
+
className={_composeClassNames(
|
|
127
129
|
className,
|
|
128
130
|
box({
|
|
129
131
|
align,
|
|
@@ -4,12 +4,12 @@ import {THEME_COLOR_BUTTON_MODES, THEME_COLOR_STATE_TONES} from '@sanity/ui/them
|
|
|
4
4
|
export default function CustomStory() {
|
|
5
5
|
return (
|
|
6
6
|
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
|
|
7
|
-
<Stack
|
|
7
|
+
<Stack gap={2}>
|
|
8
8
|
{THEME_COLOR_BUTTON_MODES.map((mode) => (
|
|
9
9
|
<Grid columns={7} gap={1} key={mode}>
|
|
10
10
|
{THEME_COLOR_STATE_TONES.map((tone) => (
|
|
11
11
|
<Button key={tone} mode={mode} padding={3} tone={tone}>
|
|
12
|
-
<Stack
|
|
12
|
+
<Stack gap={2}>
|
|
13
13
|
<Text>Text</Text>
|
|
14
14
|
<Text muted>Muted</Text>
|
|
15
15
|
<Text>
|
|
@@ -4,9 +4,9 @@ import {Button, Flex, Inline} from '@sanity/ui'
|
|
|
4
4
|
export default function CustomIconsStory() {
|
|
5
5
|
return (
|
|
6
6
|
<Flex align="center" height="fill" justify="center">
|
|
7
|
-
<Inline
|
|
8
|
-
<Button fontSize={1}
|
|
9
|
-
<Button fontSize={1}
|
|
7
|
+
<Inline gap={1}>
|
|
8
|
+
<Button fontSize={1} gap={2} icon={RocketIcon} padding={2} text="Rocket" />
|
|
9
|
+
<Button fontSize={1} gap={2} icon={CustomIcon} padding={2} text="Heart" />
|
|
10
10
|
</Inline>
|
|
11
11
|
</Flex>
|
|
12
12
|
)
|
|
@@ -5,20 +5,20 @@ import {Container} from '../../container/container'
|
|
|
5
5
|
import {Grid} from '../../grid/grid'
|
|
6
6
|
import {Stack} from '../../stack/stack'
|
|
7
7
|
import {Text} from '../../text/text'
|
|
8
|
-
import {Button
|
|
8
|
+
import {Button} from '../button'
|
|
9
9
|
|
|
10
10
|
const GAP = 4
|
|
11
11
|
const COLUMNS = 3
|
|
12
12
|
|
|
13
|
-
const DEFAULT_PROPS
|
|
13
|
+
const DEFAULT_PROPS = {
|
|
14
14
|
icon: SquareIcon,
|
|
15
15
|
iconRight: SquareIcon,
|
|
16
|
-
}
|
|
16
|
+
} as const
|
|
17
17
|
|
|
18
18
|
function Layout() {
|
|
19
19
|
return (
|
|
20
20
|
<Container width={2}>
|
|
21
|
-
<Stack
|
|
21
|
+
<Stack gap={4}>
|
|
22
22
|
<Grid columns={COLUMNS} gap={GAP}>
|
|
23
23
|
<Text size={1} weight="semibold">
|
|
24
24
|
Default
|
|
@@ -31,21 +31,21 @@ function Layout() {
|
|
|
31
31
|
</Text>
|
|
32
32
|
</Grid>
|
|
33
33
|
|
|
34
|
-
<Stack
|
|
34
|
+
<Stack gap={2}>
|
|
35
35
|
<Grid columns={COLUMNS} gap={GAP}>
|
|
36
|
-
<Stack
|
|
36
|
+
<Stack gap={2}>
|
|
37
37
|
<Button {...DEFAULT_PROPS} mode="default" text="Enabled" />
|
|
38
38
|
<Button {...DEFAULT_PROPS} disabled mode="default" text="Disabled" />
|
|
39
39
|
<Button {...DEFAULT_PROPS} disabled mode="default" muted text="Disabled (muted)" />
|
|
40
40
|
</Stack>
|
|
41
41
|
|
|
42
|
-
<Stack
|
|
42
|
+
<Stack gap={2}>
|
|
43
43
|
<Button {...DEFAULT_PROPS} mode="ghost" text="Enabled" />
|
|
44
44
|
<Button {...DEFAULT_PROPS} disabled mode="ghost" text="Disabled" />
|
|
45
45
|
<Button {...DEFAULT_PROPS} disabled mode="ghost" muted text="Disabled (muted)" />
|
|
46
46
|
</Stack>
|
|
47
47
|
|
|
48
|
-
<Stack
|
|
48
|
+
<Stack gap={2}>
|
|
49
49
|
<Button {...DEFAULT_PROPS} mode="bleed" text="Enabled" />
|
|
50
50
|
<Button {...DEFAULT_PROPS} mode="bleed" disabled text="Disabled" />
|
|
51
51
|
<Button {...DEFAULT_PROPS} disabled mode="bleed" muted text="Disabled (muted)" />
|
|
@@ -60,7 +60,7 @@ function Layout() {
|
|
|
60
60
|
export default function DisabledButtonStory() {
|
|
61
61
|
return (
|
|
62
62
|
<Stack>
|
|
63
|
-
<Stack
|
|
63
|
+
<Stack gap={4}>
|
|
64
64
|
<Card padding={5} scheme="light">
|
|
65
65
|
<Layout />
|
|
66
66
|
</Card>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {icons} from '@sanity/icons'
|
|
2
2
|
import {Button, Flex} from '@sanity/ui'
|
|
3
|
-
import {FontTextSize} from '@sanity/ui/theme'
|
|
4
3
|
import {useAction, useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
5
4
|
|
|
6
5
|
import {
|
|
@@ -17,6 +16,7 @@ import {
|
|
|
17
16
|
export default function ButtonStory() {
|
|
18
17
|
const disabled = useBoolean('Disabled', false, 'Props')
|
|
19
18
|
const fontSize = useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 2, 'Props')
|
|
19
|
+
const gap = useSelect('Gap', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
20
20
|
const icon = useSelect('Icon', WORKSHOP_ICON_SYMBOL_OPTIONS, 'add-circle', 'Props')
|
|
21
21
|
const iconRight = useSelect('Icon (right)', WORKSHOP_ICON_SYMBOL_OPTIONS, '', 'Props')
|
|
22
22
|
const justify = useSelect('Justify', WORKSHOP_FLEX_JUSTIFY_OPTIONS, 'center', 'Props')
|
|
@@ -25,7 +25,6 @@ export default function ButtonStory() {
|
|
|
25
25
|
const paddingX = useSelect('Padding X', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
26
26
|
const paddingY = useSelect('Padding Y', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
27
27
|
const selected = useBoolean('Selected', false, 'Props')
|
|
28
|
-
const space = useSelect('Space', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
29
28
|
const tone = useSelect('Tone', WORKSHOP_BUTTON_TONE_OPTIONS, 'default', 'Props')
|
|
30
29
|
const textAlign =
|
|
31
30
|
useSelect('Text align', WORKSHOP_BUTTON_TEXT_ALIGN_OPTIONS, undefined, 'Props') || undefined
|
|
@@ -37,7 +36,8 @@ export default function ButtonStory() {
|
|
|
37
36
|
<Flex align="center" height="fill" justify="center">
|
|
38
37
|
<Button
|
|
39
38
|
disabled={disabled}
|
|
40
|
-
fontSize={fontSize
|
|
39
|
+
fontSize={fontSize}
|
|
40
|
+
gap={gap}
|
|
41
41
|
icon={icon && icons[icon]}
|
|
42
42
|
iconRight={iconRight && icons[iconRight]}
|
|
43
43
|
justify={justify}
|
|
@@ -47,7 +47,6 @@ export default function ButtonStory() {
|
|
|
47
47
|
paddingX={paddingX}
|
|
48
48
|
paddingY={paddingY}
|
|
49
49
|
selected={selected}
|
|
50
|
-
space={space}
|
|
51
50
|
textAlign={textAlign}
|
|
52
51
|
text={textProp}
|
|
53
52
|
textWeight={textWeight}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {icons} from '@sanity/icons'
|
|
2
2
|
import {Box, Button, Card, Container, Flex, Stack} from '@sanity/ui'
|
|
3
|
-
import {FontTextSize} from '@sanity/ui/theme'
|
|
4
3
|
import {useAction, useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
5
4
|
|
|
6
5
|
import {
|
|
@@ -16,6 +15,7 @@ export default function StackedStory() {
|
|
|
16
15
|
const tones = Object.entries(WORKSHOP_BUTTON_TONE_OPTIONS)
|
|
17
16
|
const disabled = useBoolean('Disabled', false, 'Props')
|
|
18
17
|
const fontSize = useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 2, 'Props')
|
|
18
|
+
const gap = useSelect('Gap', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
19
19
|
const icon = useSelect('Icon', WORKSHOP_ICON_SYMBOL_OPTIONS, 'add-circle', 'Props')
|
|
20
20
|
const iconRight = useSelect('Icon (right)', WORKSHOP_ICON_SYMBOL_OPTIONS, '', 'Props')
|
|
21
21
|
const justify = useSelect('Justify', WORKSHOP_FLEX_JUSTIFY_OPTIONS, 'center', 'Props')
|
|
@@ -24,18 +24,18 @@ export default function StackedStory() {
|
|
|
24
24
|
const paddingX = useSelect('Padding X', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
25
25
|
const paddingY = useSelect('Padding Y', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
26
26
|
const selected = useBoolean('Selected', false, 'Props')
|
|
27
|
-
const space = useSelect('Space', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
28
27
|
|
|
29
28
|
return (
|
|
30
29
|
<Card height="fill">
|
|
31
30
|
<Flex align="center" height="fill" justify="center">
|
|
32
31
|
<Container width={0} style={{textAlign: 'center'}}>
|
|
33
32
|
<Box padding={4}>
|
|
34
|
-
<Stack
|
|
33
|
+
<Stack gap={1}>
|
|
35
34
|
{tones.map(([title, tone]) => (
|
|
36
35
|
<Button
|
|
37
36
|
disabled={disabled}
|
|
38
|
-
fontSize={fontSize
|
|
37
|
+
fontSize={fontSize}
|
|
38
|
+
gap={gap}
|
|
39
39
|
icon={icon && icons[icon]}
|
|
40
40
|
iconRight={iconRight && icons[iconRight]}
|
|
41
41
|
justify={justify}
|
|
@@ -45,7 +45,6 @@ export default function StackedStory() {
|
|
|
45
45
|
paddingX={paddingX}
|
|
46
46
|
paddingY={paddingY}
|
|
47
47
|
selected={selected}
|
|
48
|
-
space={space}
|
|
49
48
|
text={title}
|
|
50
49
|
tone={tone}
|
|
51
50
|
/>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/** @jest-environment jsdom */
|
|
2
|
-
|
|
3
1
|
import {AddIcon} from '@sanity/icons'
|
|
4
2
|
import {screen} from '@testing-library/react'
|
|
5
|
-
import {
|
|
3
|
+
import {describe, expect, it} from 'vitest'
|
|
4
|
+
import {axe} from 'vitest-axe'
|
|
6
5
|
|
|
7
6
|
import {render} from '../../../../test'
|
|
8
7
|
import {Button} from './button'
|