@sanity/ui 3.0.0-static.18 → 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 +137 -136
- 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 +138 -137
- 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 -2017
- package/dist/css.cjs.map +1 -1
- package/dist/css.d.cts +9423 -874
- package/dist/css.d.ts +9423 -874
- package/dist/css.js +1591 -2019
- 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 +23 -21
- package/dist/index.d.ts +23 -21
- 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 +1 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +2 -2
- 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 +0 -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 +25 -914
- 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,67 +0,0 @@
|
|
|
1
|
-
import {isColorButtonMode} from '../../v2'
|
|
2
|
-
import {
|
|
3
|
-
isColorConfigBaseKey,
|
|
4
|
-
isColorConfigBaseTone,
|
|
5
|
-
isColorConfigBlendKey,
|
|
6
|
-
isColorConfigStateKey,
|
|
7
|
-
isColorConfigStateTone,
|
|
8
|
-
} from '../helpers'
|
|
9
|
-
import {TokenKeyNode} from './types'
|
|
10
|
-
|
|
11
|
-
/** @internal */
|
|
12
|
-
export function parseTokenKey(str: string): TokenKeyNode | undefined {
|
|
13
|
-
const segments = str.split('/')
|
|
14
|
-
const segment0 = segments.shift() || ''
|
|
15
|
-
|
|
16
|
-
if (isColorConfigBaseTone(segment0)) {
|
|
17
|
-
const key = segments.join('/')
|
|
18
|
-
|
|
19
|
-
if (isColorConfigBaseKey(key)) {
|
|
20
|
-
return {
|
|
21
|
-
type: 'base',
|
|
22
|
-
tone: segment0,
|
|
23
|
-
key,
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (isColorConfigBlendKey(key)) {
|
|
28
|
-
return {
|
|
29
|
-
type: 'base',
|
|
30
|
-
tone: segment0,
|
|
31
|
-
key,
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (segment0 === 'button') {
|
|
37
|
-
const segment1 = segments.shift() || ''
|
|
38
|
-
|
|
39
|
-
if (isColorConfigStateTone(segment1)) {
|
|
40
|
-
const segment2 = segments.shift() || ''
|
|
41
|
-
|
|
42
|
-
if (isColorButtonMode(segment2)) {
|
|
43
|
-
const key = segments.join('/')
|
|
44
|
-
|
|
45
|
-
if (isColorConfigStateKey(key)) {
|
|
46
|
-
return {
|
|
47
|
-
type: 'button',
|
|
48
|
-
tone: segment1,
|
|
49
|
-
mode: segment2,
|
|
50
|
-
key,
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (isColorConfigBlendKey(key)) {
|
|
55
|
-
return {
|
|
56
|
-
type: 'button',
|
|
57
|
-
tone: segment1,
|
|
58
|
-
mode: segment2,
|
|
59
|
-
key,
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return undefined
|
|
67
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {buildTheme_v3} from './buildTheme_v3'
|
|
2
|
-
|
|
3
|
-
it('should build theme', () => {
|
|
4
|
-
const theme = buildTheme_v3({
|
|
5
|
-
tokens: {
|
|
6
|
-
color: {
|
|
7
|
-
'*': {
|
|
8
|
-
variant: {
|
|
9
|
-
tinted: {
|
|
10
|
-
'*': {
|
|
11
|
-
bg: {
|
|
12
|
-
0: ['50', '950'],
|
|
13
|
-
},
|
|
14
|
-
fg: {
|
|
15
|
-
0: ['900 50%', '100 50%'],
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
'primary': {
|
|
22
|
-
_hue: 'purple',
|
|
23
|
-
},
|
|
24
|
-
'positive': {
|
|
25
|
-
_hue: 'green',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// eslint-disable-next-line no-console
|
|
32
|
-
console.log('default', theme.color.light.card.default)
|
|
33
|
-
// eslint-disable-next-line no-console
|
|
34
|
-
console.log('primary', theme.color.light.card.primary)
|
|
35
|
-
// eslint-disable-next-line no-console
|
|
36
|
-
console.log(
|
|
37
|
-
'primary.variant.tinted.positive',
|
|
38
|
-
theme.color.light.card.primary.variant.tinted.positive,
|
|
39
|
-
)
|
|
40
|
-
})
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
THEME_COLOR_AVATAR_COLORS,
|
|
3
|
-
THEME_COLOR_CARD_TONES,
|
|
4
|
-
THEME_COLOR_STATE_TONES,
|
|
5
|
-
ThemeColorAvatar_v2,
|
|
6
|
-
ThemeColorCardToneKey,
|
|
7
|
-
ThemeColorSchemeKey,
|
|
8
|
-
ThemeColorStateToneKey,
|
|
9
|
-
} from '../../v2'
|
|
10
|
-
import {CardColorTokens} from './card'
|
|
11
|
-
import {
|
|
12
|
-
ThemeColor_v3,
|
|
13
|
-
ThemeColorCard_v3,
|
|
14
|
-
ThemeColorElement,
|
|
15
|
-
ThemeColorScheme_v3,
|
|
16
|
-
ThemeColorVariant,
|
|
17
|
-
} from './color'
|
|
18
|
-
import {ElementColorTokens} from './element'
|
|
19
|
-
import {renderColor, RenderColorContext} from './renderColor'
|
|
20
|
-
import {ColorTokens} from './tokens'
|
|
21
|
-
|
|
22
|
-
const debug = false
|
|
23
|
-
|
|
24
|
-
let nodeLen = 0
|
|
25
|
-
|
|
26
|
-
/** @internal */
|
|
27
|
-
export function buildColor_v3(tokens: ColorTokens): ThemeColor_v3 {
|
|
28
|
-
return {
|
|
29
|
-
dark: buildColorScheme_v3(tokens, {scheme: 'dark'}),
|
|
30
|
-
light: buildColorScheme_v3(tokens, {scheme: 'light'}),
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function buildColorScheme_v3(
|
|
35
|
-
tokens: ColorTokens,
|
|
36
|
-
options: {scheme: ThemeColorSchemeKey},
|
|
37
|
-
): ThemeColorScheme_v3 {
|
|
38
|
-
const {scheme} = options
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
card: THEME_COLOR_CARD_TONES.reduce(
|
|
42
|
-
(acc, tone) => {
|
|
43
|
-
acc[tone] = buildColorCard_v3(tokens[tone], {cardTone: tone, scheme})
|
|
44
|
-
|
|
45
|
-
return acc
|
|
46
|
-
},
|
|
47
|
-
{} as Record<ThemeColorCardToneKey, ThemeColorCard_v3>,
|
|
48
|
-
),
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function buildColorCard_v3(
|
|
53
|
-
tokens: CardColorTokens,
|
|
54
|
-
options: {
|
|
55
|
-
cardTone: ThemeColorCardToneKey
|
|
56
|
-
scheme: ThemeColorSchemeKey
|
|
57
|
-
},
|
|
58
|
-
): ThemeColorCard_v3 {
|
|
59
|
-
const {cardTone, scheme} = options
|
|
60
|
-
const context: RenderColorContext = {
|
|
61
|
-
bgVar: `--color-bg`,
|
|
62
|
-
bgValue: 'transparent',
|
|
63
|
-
hue: tokens._hue,
|
|
64
|
-
scheme,
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const tintedDefaultVariant = buildColorElement_v3(tokens.variant.tinted.default, {
|
|
68
|
-
bgValue: 'transparent',
|
|
69
|
-
cardTone,
|
|
70
|
-
debugId: 'tinted',
|
|
71
|
-
scheme,
|
|
72
|
-
tone: 'default',
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
const bgValue = tintedDefaultVariant.bg[0]
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
_hue: tokens._hue ?? 'gray',
|
|
79
|
-
avatar: THEME_COLOR_AVATAR_COLORS.reduce<ThemeColorAvatar_v2>((acc, hue) => {
|
|
80
|
-
const avatarTokens = tokens.avatar[hue]
|
|
81
|
-
|
|
82
|
-
acc[hue] = {
|
|
83
|
-
bg: renderColor(avatarTokens.bg, {
|
|
84
|
-
bgValue,
|
|
85
|
-
bgVar: `--color-bg-1`,
|
|
86
|
-
hue: avatarTokens._hue,
|
|
87
|
-
scheme,
|
|
88
|
-
}),
|
|
89
|
-
fg: renderColor(avatarTokens.fg, {
|
|
90
|
-
bgValue,
|
|
91
|
-
bgVar: `--color-bg-1`,
|
|
92
|
-
hue: avatarTokens._hue,
|
|
93
|
-
scheme,
|
|
94
|
-
}),
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return acc
|
|
98
|
-
}, {} as ThemeColorAvatar_v2),
|
|
99
|
-
backdrop: renderColor(tokens.backdrop, context),
|
|
100
|
-
code: {
|
|
101
|
-
bg: renderColor(tokens.code.bg, context),
|
|
102
|
-
fg: renderColor(tokens.code.fg, context),
|
|
103
|
-
token: {
|
|
104
|
-
atrule: renderColor(tokens.code.token.atrule, context),
|
|
105
|
-
attrName: renderColor(tokens.code.token.attrName, context),
|
|
106
|
-
attrValue: renderColor(tokens.code.token.attrValue, context),
|
|
107
|
-
attribute: renderColor(tokens.code.token.attribute, context),
|
|
108
|
-
boolean: renderColor(tokens.code.token.boolean, context),
|
|
109
|
-
builtin: renderColor(tokens.code.token.builtin, context),
|
|
110
|
-
cdata: renderColor(tokens.code.token.cdata, context),
|
|
111
|
-
char: renderColor(tokens.code.token.char, context),
|
|
112
|
-
class: renderColor(tokens.code.token.class, context),
|
|
113
|
-
className: renderColor(tokens.code.token.className, context),
|
|
114
|
-
comment: renderColor(tokens.code.token.comment, context),
|
|
115
|
-
constant: renderColor(tokens.code.token.constant, context),
|
|
116
|
-
deleted: renderColor(tokens.code.token.deleted, context),
|
|
117
|
-
doctype: renderColor(tokens.code.token.doctype, context),
|
|
118
|
-
entity: renderColor(tokens.code.token.entity, context),
|
|
119
|
-
function: renderColor(tokens.code.token.function, context),
|
|
120
|
-
hexcode: renderColor(tokens.code.token.hexcode, context),
|
|
121
|
-
id: renderColor(tokens.code.token.id, context),
|
|
122
|
-
important: renderColor(tokens.code.token.important, context),
|
|
123
|
-
inserted: renderColor(tokens.code.token.inserted, context),
|
|
124
|
-
keyword: renderColor(tokens.code.token.keyword, context),
|
|
125
|
-
number: renderColor(tokens.code.token.number, context),
|
|
126
|
-
operator: renderColor(tokens.code.token.operator, context),
|
|
127
|
-
prolog: renderColor(tokens.code.token.prolog, context),
|
|
128
|
-
property: renderColor(tokens.code.token.property, context),
|
|
129
|
-
pseudoClass: renderColor(tokens.code.token.pseudoClass, context),
|
|
130
|
-
pseudoElement: renderColor(tokens.code.token.pseudoElement, context),
|
|
131
|
-
punctuation: renderColor(tokens.code.token.punctuation, context),
|
|
132
|
-
regex: renderColor(tokens.code.token.regex, context),
|
|
133
|
-
selector: renderColor(tokens.code.token.selector, context),
|
|
134
|
-
string: renderColor(tokens.code.token.string, context),
|
|
135
|
-
symbol: renderColor(tokens.code.token.symbol, context),
|
|
136
|
-
tag: renderColor(tokens.code.token.tag, context),
|
|
137
|
-
unit: renderColor(tokens.code.token.unit, context),
|
|
138
|
-
url: renderColor(tokens.code.token.url, context),
|
|
139
|
-
variable: renderColor(tokens.code.token.variable, context),
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
focusRing: renderColor(tokens.focusRing, context),
|
|
143
|
-
shadow: {
|
|
144
|
-
outline: renderColor(tokens.shadow.outline, context),
|
|
145
|
-
umbra: renderColor(tokens.shadow.umbra, context),
|
|
146
|
-
penumbra: renderColor(tokens.shadow.penumbra, context),
|
|
147
|
-
ambient: renderColor(tokens.shadow.ambient, context),
|
|
148
|
-
},
|
|
149
|
-
skeleton: {
|
|
150
|
-
from: renderColor(tokens.skeleton.from, context),
|
|
151
|
-
to: renderColor(tokens.skeleton.to, context),
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
variant: {
|
|
155
|
-
solid: {
|
|
156
|
-
...THEME_COLOR_STATE_TONES.reduce((acc, tone) => {
|
|
157
|
-
acc[tone] = buildColorElement_v3(tokens.variant.solid[tone], {
|
|
158
|
-
bgValue,
|
|
159
|
-
cardTone,
|
|
160
|
-
debugId: `solid`,
|
|
161
|
-
scheme,
|
|
162
|
-
tone,
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
return acc
|
|
166
|
-
}, {} as ThemeColorVariant),
|
|
167
|
-
},
|
|
168
|
-
tinted: {
|
|
169
|
-
...THEME_COLOR_STATE_TONES.reduce((acc, tone) => {
|
|
170
|
-
if (tone === 'default') {
|
|
171
|
-
acc[tone] = tintedDefaultVariant
|
|
172
|
-
} else {
|
|
173
|
-
acc[tone] = buildColorElement_v3(tokens.variant.tinted[tone], {
|
|
174
|
-
bgValue,
|
|
175
|
-
cardTone,
|
|
176
|
-
debugId: `tinted`,
|
|
177
|
-
scheme,
|
|
178
|
-
tone,
|
|
179
|
-
})
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return acc
|
|
183
|
-
}, {} as ThemeColorVariant),
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function buildColorElement_v3(
|
|
190
|
-
tokens: ElementColorTokens,
|
|
191
|
-
options: {
|
|
192
|
-
bgValue: string
|
|
193
|
-
cardTone: ThemeColorCardToneKey
|
|
194
|
-
debugId?: string
|
|
195
|
-
scheme: ThemeColorSchemeKey
|
|
196
|
-
tone?: ThemeColorStateToneKey
|
|
197
|
-
},
|
|
198
|
-
): ThemeColorElement {
|
|
199
|
-
const {bgValue, cardTone, debugId, scheme, tone} = options
|
|
200
|
-
|
|
201
|
-
const path = [scheme, cardTone, debugId, tone].filter(Boolean).join('/')
|
|
202
|
-
|
|
203
|
-
if (debug) {
|
|
204
|
-
// eslint-disable-next-line no-console
|
|
205
|
-
console.log(nodeLen, path)
|
|
206
|
-
nodeLen += 1
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const context: RenderColorContext = {bgValue, bgVar: `--color-bg`, hue: tokens._hue, scheme}
|
|
210
|
-
|
|
211
|
-
return {
|
|
212
|
-
_hue: tokens._hue ?? 'gray',
|
|
213
|
-
bg: {
|
|
214
|
-
0: renderColor(tokens.bg[0], context),
|
|
215
|
-
4: renderColor(tokens.bg[4], context),
|
|
216
|
-
},
|
|
217
|
-
border: {
|
|
218
|
-
0: renderColor(tokens.border[0], context),
|
|
219
|
-
4: renderColor(tokens.border[4], context),
|
|
220
|
-
},
|
|
221
|
-
fg: {
|
|
222
|
-
0: renderColor(tokens.fg[0], context),
|
|
223
|
-
4: renderColor(tokens.fg[4], context),
|
|
224
|
-
},
|
|
225
|
-
}
|
|
226
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import {parseColor} from './parseColor'
|
|
2
|
-
|
|
3
|
-
it('should parse color', () => {
|
|
4
|
-
expect(parseColor('black/0.5')).toEqual({
|
|
5
|
-
color: {
|
|
6
|
-
type: 'black',
|
|
7
|
-
},
|
|
8
|
-
opacity: 0.5,
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
expect(parseColor('black')).toEqual({
|
|
12
|
-
color: {
|
|
13
|
-
type: 'black',
|
|
14
|
-
},
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
expect(parseColor('white')).toEqual({
|
|
18
|
-
color: {
|
|
19
|
-
type: 'white',
|
|
20
|
-
},
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
expect(parseColor('white/1')).toEqual({
|
|
24
|
-
color: {
|
|
25
|
-
type: 'white',
|
|
26
|
-
},
|
|
27
|
-
opacity: 1,
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
expect(parseColor('50')).toEqual({
|
|
31
|
-
color: {
|
|
32
|
-
type: 'hue',
|
|
33
|
-
tint: '50',
|
|
34
|
-
},
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
expect(parseColor('50/0.5')).toEqual({
|
|
38
|
-
color: {
|
|
39
|
-
type: 'hue',
|
|
40
|
-
tint: '50',
|
|
41
|
-
},
|
|
42
|
-
opacity: 0.5,
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
expect(parseColor('500/0.5')).toEqual({
|
|
46
|
-
color: {
|
|
47
|
-
type: 'hue',
|
|
48
|
-
tint: '500',
|
|
49
|
-
},
|
|
50
|
-
opacity: 0.5,
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
expect(parseColor('red/50')).toEqual({
|
|
54
|
-
color: {
|
|
55
|
-
type: 'hue',
|
|
56
|
-
hue: 'red',
|
|
57
|
-
tint: '50',
|
|
58
|
-
},
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
expect(parseColor('red/200/0.5 5%')).toEqual({
|
|
62
|
-
color: {
|
|
63
|
-
type: 'hue',
|
|
64
|
-
hue: 'red',
|
|
65
|
-
tint: '200',
|
|
66
|
-
},
|
|
67
|
-
opacity: 0.5,
|
|
68
|
-
mix: 5,
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
expect(parseColor('red/50 50%')).toEqual({
|
|
72
|
-
color: {
|
|
73
|
-
type: 'hue',
|
|
74
|
-
hue: 'red',
|
|
75
|
-
tint: '50',
|
|
76
|
-
},
|
|
77
|
-
mix: 50,
|
|
78
|
-
})
|
|
79
|
-
})
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import {Hue, HUES, Tint, TINTS} from '../../palette'
|
|
2
|
-
|
|
3
|
-
const RE_PERCENTAGE = /^([0-9]+)%/
|
|
4
|
-
const RE_OPACITY = /^(1|0\.[0-9]+)?/
|
|
5
|
-
|
|
6
|
-
export interface TokenizeColorResult {
|
|
7
|
-
color: {type: 'black' | 'white'} | {type: 'hue'; hue: Hue | undefined; tint: Tint | undefined}
|
|
8
|
-
opacity: number | undefined
|
|
9
|
-
mix: number | undefined
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function parseColor(str: string): TokenizeColorResult {
|
|
13
|
-
let cursor = 0
|
|
14
|
-
|
|
15
|
-
const color = getColor()
|
|
16
|
-
|
|
17
|
-
if (!color) {
|
|
18
|
-
throw new Error(`Invalid color: ${str}`)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const opacity = getOpacity()
|
|
22
|
-
const mix = getMixPercentage()
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
color,
|
|
26
|
-
mix,
|
|
27
|
-
opacity,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function _consume(s: string) {
|
|
31
|
-
if (str.startsWith(s, cursor)) {
|
|
32
|
-
cursor += s.length
|
|
33
|
-
|
|
34
|
-
return s
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return undefined
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _peek() {
|
|
41
|
-
return str[cursor]
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getColor(): TokenizeColorResult['color'] | undefined {
|
|
45
|
-
ignoreWhitespace()
|
|
46
|
-
|
|
47
|
-
let v = _consume('black') || _consume('white')
|
|
48
|
-
|
|
49
|
-
if (v) {
|
|
50
|
-
return {
|
|
51
|
-
type: v as 'black' | 'white',
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
for (const hue of HUES) {
|
|
56
|
-
v = _consume(String(hue))
|
|
57
|
-
|
|
58
|
-
if (v) {
|
|
59
|
-
if (_peek() !== '/') {
|
|
60
|
-
throw new Error(`Expected slash after hue`)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
cursor += 1
|
|
64
|
-
|
|
65
|
-
const tint = getTint()
|
|
66
|
-
|
|
67
|
-
if (!tint) {
|
|
68
|
-
throw new Error(`Expected tint after hue`)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
type: 'hue',
|
|
73
|
-
hue,
|
|
74
|
-
tint,
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const tint = getTint()
|
|
80
|
-
|
|
81
|
-
if (tint) {
|
|
82
|
-
return {
|
|
83
|
-
type: 'hue',
|
|
84
|
-
hue: undefined,
|
|
85
|
-
tint,
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return undefined
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function getTint() {
|
|
93
|
-
ignoreWhitespace()
|
|
94
|
-
|
|
95
|
-
// if (_peek() === '/') {
|
|
96
|
-
// cursor += 1
|
|
97
|
-
|
|
98
|
-
let v = Number(str.slice(cursor, cursor + 3)) as Tint
|
|
99
|
-
|
|
100
|
-
if (TINTS.includes(v)) {
|
|
101
|
-
cursor += 3
|
|
102
|
-
|
|
103
|
-
return v
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
v = Number(str.slice(cursor, cursor + 2)) as Tint
|
|
107
|
-
|
|
108
|
-
if (TINTS.includes(v)) {
|
|
109
|
-
cursor += 2
|
|
110
|
-
|
|
111
|
-
return v
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// for (const tint of COLOR_TINTS) {
|
|
115
|
-
// const v = _consume(String(tint))
|
|
116
|
-
|
|
117
|
-
// if (v) {
|
|
118
|
-
// return tint
|
|
119
|
-
// }
|
|
120
|
-
// }
|
|
121
|
-
|
|
122
|
-
// cursor -= 1
|
|
123
|
-
// }
|
|
124
|
-
|
|
125
|
-
return undefined
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function getMixPercentage() {
|
|
129
|
-
ignoreWhitespace()
|
|
130
|
-
|
|
131
|
-
const match = RE_PERCENTAGE.exec(str.slice(cursor))
|
|
132
|
-
|
|
133
|
-
if (match) {
|
|
134
|
-
cursor += match[0].length
|
|
135
|
-
|
|
136
|
-
return parseFloat(match[1])
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return undefined
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getOpacity() {
|
|
143
|
-
ignoreWhitespace()
|
|
144
|
-
|
|
145
|
-
if (_peek() === '/') {
|
|
146
|
-
cursor += 1
|
|
147
|
-
|
|
148
|
-
const match = RE_OPACITY.exec(str.slice(cursor))
|
|
149
|
-
|
|
150
|
-
if (match) {
|
|
151
|
-
cursor += match[0].length
|
|
152
|
-
|
|
153
|
-
return parseFloat(match[1])
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
cursor -= 1
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return undefined
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function ignoreWhitespace() {
|
|
163
|
-
while (_peek() === ' ') {
|
|
164
|
-
cursor++
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {renderColor, RenderColorContext} from './renderColor'
|
|
2
|
-
|
|
3
|
-
it('should render color', () => {
|
|
4
|
-
const context: RenderColorContext = {
|
|
5
|
-
bgValue: 'transparent',
|
|
6
|
-
bgVar: '--bg',
|
|
7
|
-
hue: 'gray',
|
|
8
|
-
scheme: 'light',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
expect(renderColor(['500/0.2', '500/0.2'], context)).toBe(
|
|
12
|
-
`color-mix(in srgb, transparent, var(--gray-500) 20%)`,
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
expect(renderColor(['500', '500'], context)).toBe(`var(--gray-500)`)
|
|
16
|
-
|
|
17
|
-
expect(renderColor(['50 20%', '50 20%'], context)).toBe(
|
|
18
|
-
`color-mix(in srgb, var(--bg), var(--gray-50) 20%)`,
|
|
19
|
-
)
|
|
20
|
-
})
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {Hue} from '../../palette'
|
|
2
|
-
import {ThemeColorSchemeKey} from '../../v2'
|
|
3
|
-
import {parseColor} from './parseColor'
|
|
4
|
-
import {ColorToken} from './token'
|
|
5
|
-
|
|
6
|
-
/** @public */
|
|
7
|
-
export type CSSVariableKey = `--${string}`
|
|
8
|
-
|
|
9
|
-
/** @public */
|
|
10
|
-
export interface RenderColorContext {
|
|
11
|
-
bgVar: CSSVariableKey
|
|
12
|
-
bgValue: string
|
|
13
|
-
hue: Hue
|
|
14
|
-
scheme: ThemeColorSchemeKey
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** @public */
|
|
18
|
-
export function renderColor(token: [ColorToken, ColorToken], context: RenderColorContext): string {
|
|
19
|
-
const {bgValue, bgVar, hue, scheme} = context
|
|
20
|
-
|
|
21
|
-
const t = token[scheme === 'dark' ? 0 : 1]
|
|
22
|
-
|
|
23
|
-
if (t === 'inherit') {
|
|
24
|
-
return bgValue
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const result = parseColor(t)
|
|
28
|
-
|
|
29
|
-
const colorVar =
|
|
30
|
-
result.color.type === 'hue'
|
|
31
|
-
? `--${result.color.hue ?? hue}-${result.color.tint}`
|
|
32
|
-
: `--${result.color.type}`
|
|
33
|
-
|
|
34
|
-
if (result.mix !== undefined) {
|
|
35
|
-
return `color-mix(in srgb, var(${bgVar}), var(${colorVar}) ${result.mix}%)`
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (result.opacity !== undefined) {
|
|
39
|
-
return `color-mix(in srgb, transparent, var(${colorVar}) ${result.opacity * 100}%)`
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return `var(${colorVar})`
|
|
43
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|