@sanity/ui 3.3.0 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/_visual-editing.d.mts +2 -1126
- package/dist/_visual-editing.d.ts +2 -1126
- package/dist/_visual-editing.js +3 -31
- package/dist/_visual-editing.mjs +2 -31
- package/dist/index.d.mts +555 -2769
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +555 -2769
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2982 -1934
- package/dist/index.mjs +2950 -1903
- package/dist/index.mjs.map +1 -1
- package/dist/refractor.js +16 -0
- package/dist/refractor.mjs +21 -0
- package/dist/refractor.mjs.map +1 -0
- package/dist/tabList.js +3804 -0
- package/dist/tabList.mjs +3355 -0
- package/dist/tabList.mjs.map +1 -0
- package/dist/theme.d.mts +927 -1227
- package/dist/theme.d.mts.map +1 -0
- package/dist/theme.d.ts +927 -1227
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +3 -4127
- package/dist/theme.mjs +2 -4127
- package/dist/theme2.d.mts +2 -0
- package/dist/theme2.d.ts +2 -0
- package/dist/theme2.js +4104 -0
- package/dist/theme2.mjs +3851 -0
- package/dist/theme2.mjs.map +1 -0
- package/dist/useTheme.d.mts +1451 -0
- package/dist/useTheme.d.mts.map +1 -0
- package/dist/useTheme.d.ts +1451 -0
- package/dist/useTheme.d.ts.map +1 -0
- package/exports/_visual-editing.ts +1 -0
- package/package.json +52 -168
- package/src/core/_compat.ts +30 -0
- package/src/core/components/autocomplete/autocomplete.tsx +8 -0
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -0
- package/src/core/components/breadcrumbs/breadcrumbs.test.tsx +8 -5
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +3 -0
- package/src/core/components/dialog/dialog.tsx +5 -2
- package/src/core/components/hotkeys/hotkeys.test.tsx +10 -5
- package/src/core/components/hotkeys/hotkeys.tsx +2 -0
- package/src/core/components/menu/menu.spacing.test.tsx +12 -7
- package/src/core/components/menu/menu.test.tsx +9 -6
- package/src/core/components/menu/menu.tsx +4 -2
- package/src/core/components/menu/menuButton.tsx +8 -0
- package/src/core/components/menu/menuDivider.ts +1 -0
- package/src/core/components/menu/menuGroup.spacing.test.tsx +9 -6
- package/src/core/components/menu/menuGroup.tsx +6 -2
- package/src/core/components/menu/menuItem.spacing.test.tsx +8 -5
- package/src/core/components/menu/menuItem.tsx +4 -0
- package/src/core/components/menu/useMenuController.ts +2 -0
- package/src/core/components/skeleton/skeleton.tsx +1 -0
- package/src/core/components/tab/tab.tsx +1 -0
- package/src/core/components/tab/tabList.test.tsx +7 -5
- package/src/core/components/tab/tabList.tsx +1 -0
- package/src/core/components/toast/toast.test.tsx +9 -4
- package/src/core/components/toast/toast.tsx +1 -0
- package/src/core/components/toast/toastLayer.tsx +1 -0
- package/src/core/components/tree/tree.test.tsx +10 -5
- package/src/core/components/tree/tree.tsx +2 -0
- package/src/core/components/tree/treeGroup.tsx +1 -0
- package/src/core/components/tree/treeItem.test.tsx +10 -5
- package/src/core/components/tree/treeItem.tsx +1 -0
- package/src/core/hooks/index.ts +1 -0
- package/src/core/hooks/useClickOutside.test.tsx +43 -15
- package/src/core/hooks/useClickOutside.ts +1 -1
- package/src/core/hooks/useClickOutsideEvent.test.tsx +8 -4
- package/src/core/hooks/useDelayed.test.ts +9 -8
- package/src/core/hooks/useElementRect/useElementRect.ts +1 -0
- package/src/core/hooks/useForwardedRef.ts +1 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +2 -1
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +7 -5
- package/src/core/hooks/usePrefersDark.test.tsx +3 -1
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +7 -5
- package/src/core/hooks/usePrefersReducedMotion.test.tsx +3 -1
- package/src/core/lib/createGlobalScopedContext.ts +1 -0
- package/src/core/lib/globalScope.ts +1 -0
- package/src/core/observers/elementSizeObserver.ts +1 -0
- package/src/core/primitives/avatar/avatar.tsx +2 -2
- package/src/core/primitives/avatar/avatarStack.tsx +1 -0
- package/src/core/primitives/badge/badge.test.tsx +3 -2
- package/src/core/primitives/badge/badge.tsx +3 -1
- package/src/core/primitives/box/box.test.tsx +18 -5
- package/src/core/primitives/box/box.tsx +9 -1
- package/src/core/primitives/button/button.test.tsx +10 -6
- package/src/core/primitives/button/button.tsx +4 -0
- package/src/core/primitives/button/styles.ts +1 -0
- package/src/core/primitives/card/card.tsx +2 -5
- package/src/core/primitives/card/types.ts +1 -0
- package/src/core/primitives/code/code.tsx +1 -0
- package/src/core/primitives/code/refractor.tsx +2 -0
- package/src/core/primitives/container/container.tsx +1 -0
- package/src/core/primitives/flex/flex.tsx +2 -3
- package/src/core/primitives/grid/grid.test.tsx +11 -5
- package/src/core/primitives/grid/grid.tsx +3 -0
- package/src/core/primitives/heading/heading.tsx +1 -0
- package/src/core/primitives/inline/inline.test.tsx +9 -5
- package/src/core/primitives/inline/inline.tsx +3 -0
- package/src/core/primitives/kbd/kbd.tsx +5 -1
- package/src/core/primitives/label/label.tsx +1 -0
- package/src/core/primitives/popover/popover.tsx +5 -4
- package/src/core/primitives/popover/popoverCard.tsx +1 -0
- package/src/core/primitives/popover/types.ts +0 -1
- package/src/core/primitives/select/select.test.tsx +9 -5
- package/src/core/primitives/select/select.tsx +1 -0
- package/src/core/primitives/stack/stack.test.tsx +9 -5
- package/src/core/primitives/stack/stack.tsx +2 -0
- package/src/core/primitives/stack/styles.ts +1 -0
- package/src/core/primitives/text/text.tsx +1 -0
- package/src/core/primitives/textInput/textInput.test.tsx +9 -5
- package/src/core/primitives/textInput/textInput.tsx +3 -0
- package/src/core/primitives/tooltip/tooltip.test.tsx +82 -49
- package/src/core/primitives/tooltip/tooltip.tsx +3 -1
- package/src/core/primitives/tooltip/tooltipCard.tsx +1 -0
- package/src/core/primitives/tooltip/tooltipDelayGroup/types.ts +2 -0
- package/src/core/styles/flex/types.ts +0 -1
- package/src/core/styles/font/responsiveFont.ts +0 -3
- package/src/core/styles/font/types.ts +1 -3
- package/src/core/styles/grid/gridStyle.ts +1 -0
- package/src/core/styles/margin/marginStyle.ts +1 -0
- package/src/core/styles/margin/marginsStyle.test.ts +2 -1
- package/src/core/styles/padding/paddingStyle.test.ts +2 -1
- package/src/core/styles/padding/paddingStyle.ts +1 -0
- package/src/core/theme/theme.test.tsx +7 -3
- package/src/core/theme/useRootTheme.ts +1 -0
- package/src/core/theme/useTheme.ts +2 -0
- package/src/core/utils/arrow/arrow.tsx +1 -0
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +9 -4
- package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +1 -0
- package/src/core/utils/getElementRef.ts +5 -0
- package/src/core/utils/layer/getLayerContext.test.ts +2 -0
- package/src/core/utils/layer/layer.test.tsx +9 -4
- package/src/core/utils/layer/layer.tsx +1 -0
- package/src/core/utils/layer/useLayer.ts +2 -0
- package/src/core/utils/portal/portal.test.tsx +9 -4
- package/src/core/utils/portal/portalProvider.tsx +1 -0
- package/src/core/utils/virtualList/virtualList.tsx +2 -1
- package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +10 -0
- package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +4 -0
- package/src/theme/build/_deprecated/color/button/createButtonModes.ts +5 -0
- package/src/theme/build/_deprecated/color/button/createButtonTones.ts +5 -0
- package/src/theme/build/_deprecated/color/card/createCardStates.ts +6 -0
- package/src/theme/build/_deprecated/color/color.test.ts +5 -1
- package/src/theme/build/_deprecated/color/defaults.ts +1 -0
- package/src/theme/build/_deprecated/color/factory.ts +36 -0
- package/src/theme/build/_deprecated/color/input/createInputModes.ts +5 -0
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +4 -0
- package/src/theme/build/_deprecated/color/spot/createSpot.ts +3 -0
- package/src/theme/build/buildColorTheme.test.ts +2 -0
- package/src/theme/build/buildColorTheme.ts +8 -0
- package/src/theme/build/buildTheme.test.ts +2 -0
- package/src/theme/build/lib/color-fns/color-fns.test.ts +3 -1
- package/src/theme/build/merge.ts +5 -0
- package/src/theme/build/mixThemeColor.test.ts +2 -0
- package/src/theme/build/renderColorTheme.ts +6 -0
- package/src/theme/build/renderColorValue.ts +0 -2
- package/src/theme/build/resolveColorTokens.ts +6 -0
- package/src/theme/build/theme.test.ts +2 -0
- package/src/theme/config/helpers.ts +5 -0
- package/src/theme/config/system.ts +2 -0
- package/src/theme/config/tokens/color/types.ts +6 -4
- package/src/theme/config/tokens/parseTokenKey.test.ts +2 -0
- package/src/theme/config/tokens/parseTokenValue.test.ts +2 -0
- package/src/theme/config/tokens/parseTokenValue.ts +1 -0
- package/src/theme/getScopedTheme.ts +6 -1
- package/src/theme/system/color/_helpers.ts +4 -0
- package/src/theme/system/theme.ts +4 -0
- package/src/theme/system/v0/color/_system.ts +1 -0
- package/src/theme/system/v0/color/button.ts +14 -0
- package/src/theme/system/v0/color/card.ts +6 -0
- package/src/theme/system/v0/color/color.ts +11 -0
- package/src/theme/system/v0/color/input.ts +6 -0
- package/src/theme/system/v0/color/muted.ts +11 -0
- package/src/theme/system/v0/color/selectable.ts +11 -0
- package/src/theme/system/v0/color/solid.ts +11 -0
- package/src/theme/system/v0/color/spot.ts +1 -0
- package/src/theme/versioning/getTheme_v2.ts +15 -0
- package/src/theme/versioning/themeColor_v0_v2.ts +7 -0
- package/src/theme/versioning/themeColor_v2_v2_9.ts +1 -0
- package/src/theme/versioning/v0_v2.ts +13 -1
- package/src/theme/versioning/v2_v0.ts +18 -0
- package/dist/_chunks-cjs/_visual-editing.js +0 -5899
- package/dist/_chunks-cjs/_visual-editing.js.map +0 -1
- package/dist/_chunks-cjs/refractor.js +0 -23
- package/dist/_chunks-cjs/refractor.js.map +0 -1
- package/dist/_chunks-es/_visual-editing.mjs +0 -5905
- package/dist/_chunks-es/_visual-editing.mjs.map +0 -1
- package/dist/_chunks-es/refractor.mjs +0 -26
- package/dist/_chunks-es/refractor.mjs.map +0 -1
- package/dist/_visual-editing.js.map +0 -1
- package/dist/_visual-editing.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/theme.js.map +0 -1
- package/dist/theme.mjs.map +0 -1
- package/src/core/__workshop__/constants.ts +0 -293
- package/src/core/components/autocomplete/__mocks__/apiStore.ts +0 -49
- package/src/core/components/autocomplete/__mocks__/countries.ts +0 -245
- package/src/core/components/autocomplete/__workshop__/async.tsx +0 -156
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +0 -137
- package/src/core/components/autocomplete/__workshop__/custom.tsx +0 -89
- package/src/core/components/autocomplete/__workshop__/example.tsx +0 -79
- package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +0 -36
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +0 -294
- package/src/core/components/autocomplete/__workshop__/index.ts +0 -39
- package/src/core/components/autocomplete/__workshop__/types.ts +0 -4
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +0 -62
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -14
- package/src/core/components/dialog/__workshop__/activate.tsx +0 -134
- package/src/core/components/dialog/__workshop__/autoFocus.tsx +0 -29
- package/src/core/components/dialog/__workshop__/index.ts +0 -19
- package/src/core/components/dialog/__workshop__/layering.tsx +0 -41
- package/src/core/components/dialog/__workshop__/nested.tsx +0 -72
- package/src/core/components/dialog/__workshop__/onScroll.tsx +0 -39
- package/src/core/components/dialog/__workshop__/panes.tsx +0 -82
- package/src/core/components/dialog/__workshop__/position.tsx +0 -30
- package/src/core/components/dialog/__workshop__/props.tsx +0 -75
- package/src/core/components/dialog/__workshop__/provider.tsx +0 -11
- package/src/core/components/dialog/__workshop__/wrapped.tsx +0 -76
- package/src/core/components/hotkeys/__workshop__/index.ts +0 -14
- package/src/core/components/hotkeys/__workshop__/plain.tsx +0 -9
- package/src/core/components/menu/__workshop__/asComponent.tsx +0 -45
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +0 -51
- package/src/core/components/menu/__workshop__/closableMenuButton.tsx +0 -46
- package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +0 -134
- package/src/core/components/menu/__workshop__/customMenuItem.tsx +0 -45
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +0 -39
- package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +0 -40
- package/src/core/components/menu/__workshop__/groups.tsx +0 -156
- package/src/core/components/menu/__workshop__/index.ts +0 -89
- package/src/core/components/menu/__workshop__/menuButton.tsx +0 -80
- package/src/core/components/menu/__workshop__/menuGroupRight.tsx +0 -65
- package/src/core/components/menu/__workshop__/nestedMenu.tsx +0 -22
- package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +0 -41
- package/src/core/components/menu/__workshop__/selectedItem.tsx +0 -69
- package/src/core/components/menu/__workshop__/shouldFocus.tsx +0 -47
- package/src/core/components/menu/__workshop__/tones.tsx +0 -25
- package/src/core/components/menu/__workshop__/withoutArrow.tsx +0 -32
- package/src/core/components/skeleton/__workshop__/delay.tsx +0 -70
- package/src/core/components/skeleton/__workshop__/index.ts +0 -11
- package/src/core/components/skeleton/__workshop__/skeleton.tsx +0 -64
- package/src/core/components/tab/__workshop__/example.tsx +0 -79
- package/src/core/components/tab/__workshop__/index.ts +0 -14
- package/src/core/components/toast/__workshop__/hook.tsx +0 -71
- package/src/core/components/toast/__workshop__/index.ts +0 -19
- package/src/core/components/toast/__workshop__/toast.tsx +0 -26
- package/src/core/components/tree/__workshop__/basic.perf.ts +0 -19
- package/src/core/components/tree/__workshop__/basic.tsx +0 -105
- package/src/core/components/tree/__workshop__/index.ts +0 -21
- package/src/core/components/tree/__workshop__/tabFromElement.tsx +0 -84
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +0 -32
- package/src/core/hooks/useElementRect/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/index.ts +0 -29
- package/src/core/primitives/avatar/__workshop__/stack.tsx +0 -25
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +0 -63
- package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +0 -70
- package/src/core/primitives/badge/__workshop__/index.ts +0 -19
- package/src/core/primitives/badge/__workshop__/props.tsx +0 -30
- package/src/core/primitives/badge/__workshop__/tones.tsx +0 -21
- package/src/core/primitives/box/__workshop__/asComponent.tsx +0 -31
- package/src/core/primitives/box/__workshop__/index.ts +0 -24
- package/src/core/primitives/box/__workshop__/props.tsx +0 -20
- package/src/core/primitives/box/__workshop__/responsive.tsx +0 -20
- package/src/core/primitives/button/__workshop__/custom.tsx +0 -51
- package/src/core/primitives/button/__workshop__/customIcons.tsx +0 -30
- package/src/core/primitives/button/__workshop__/disabled.tsx +0 -74
- package/src/core/primitives/button/__workshop__/index.ts +0 -59
- package/src/core/primitives/button/__workshop__/mixedChildren.tsx +0 -12
- package/src/core/primitives/button/__workshop__/props.tsx +0 -55
- package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +0 -36
- package/src/core/primitives/button/__workshop__/stacked.tsx +0 -58
- package/src/core/primitives/button/__workshop__/styled1.tsx +0 -17
- package/src/core/primitives/button/__workshop__/styled2.tsx +0 -19
- package/src/core/primitives/button/__workshop__/uploadButton.tsx +0 -28
- package/src/core/primitives/card/__workshop__/allTones.tsx +0 -25
- package/src/core/primitives/card/__workshop__/asButton.tsx +0 -107
- package/src/core/primitives/card/__workshop__/asComponent.tsx +0 -27
- package/src/core/primitives/card/__workshop__/checkered.tsx +0 -26
- package/src/core/primitives/card/__workshop__/index.ts +0 -18
- package/src/core/primitives/card/__workshop__/interactive.tsx +0 -30
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +0 -80
- package/src/core/primitives/card/__workshop__/props.tsx +0 -53
- package/src/core/primitives/card/__workshop__/selected.tsx +0 -94
- package/src/core/primitives/card/__workshop__/styled.tsx +0 -14
- package/src/core/primitives/checkbox/__workshop__/example.tsx +0 -25
- package/src/core/primitives/checkbox/__workshop__/index.ts +0 -13
- package/src/core/primitives/checkbox/__workshop__/props.tsx +0 -33
- package/src/core/primitives/checkbox/__workshop__/readOnly.tsx +0 -16
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +0 -28
- package/src/core/primitives/code/__workshop__/index.ts +0 -19
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/code/__workshop__/props.tsx +0 -21
- package/src/core/primitives/container/__workshop__/example.tsx +0 -20
- package/src/core/primitives/container/__workshop__/index.ts +0 -8
- package/src/core/primitives/flex/__workshop__/example.tsx +0 -34
- package/src/core/primitives/flex/__workshop__/gap.tsx +0 -25
- package/src/core/primitives/flex/__workshop__/index.ts +0 -11
- package/src/core/primitives/grid/__workshop__/index.ts +0 -10
- package/src/core/primitives/grid/__workshop__/responsive.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/index.ts +0 -19
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/inline/__workshop__/index.ts +0 -8
- package/src/core/primitives/inline/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/kbd/__workshop__/index.ts +0 -8
- package/src/core/primitives/kbd/__workshop__/plain.tsx +0 -9
- package/src/core/primitives/label/__workshop__/index.ts +0 -19
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/label/__workshop__/plain.tsx +0 -24
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +0 -77
- package/src/core/primitives/popover/__workshop__/MarginsStory.tsx +0 -31
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +0 -32
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +0 -11
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +0 -89
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +0 -97
- package/src/core/primitives/popover/__workshop__/index.ts +0 -49
- package/src/core/primitives/radio/__workshop__/example.tsx +0 -63
- package/src/core/primitives/radio/__workshop__/index.ts +0 -11
- package/src/core/primitives/radio/__workshop__/plain.tsx +0 -28
- package/src/core/primitives/select/__workshop__/index.ts +0 -11
- package/src/core/primitives/select/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/select/__workshop__/readOnly.tsx +0 -23
- package/src/core/primitives/spinner/__workshop__/Props.tsx +0 -15
- package/src/core/primitives/spinner/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/switch/__workshop__/example.tsx +0 -23
- package/src/core/primitives/switch/__workshop__/index.ts +0 -11
- package/src/core/primitives/switch/__workshop__/props.tsx +0 -21
- package/src/core/primitives/text/__workshop__/colored.tsx +0 -30
- package/src/core/primitives/text/__workshop__/example.tsx +0 -39
- package/src/core/primitives/text/__workshop__/index.ts +0 -24
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/textArea/__workshop__/index.ts +0 -14
- package/src/core/primitives/textArea/__workshop__/plain.tsx +0 -50
- package/src/core/primitives/textInput/__workshop__/clearButton.tsx +0 -30
- package/src/core/primitives/textInput/__workshop__/customValidity.tsx +0 -17
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -44
- package/src/core/primitives/textInput/__workshop__/plain.tsx +0 -98
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +0 -9
- package/src/core/primitives/textInput/__workshop__/states.tsx +0 -53
- package/src/core/primitives/textInput/__workshop__/tones.tsx +0 -277
- package/src/core/primitives/textInput/__workshop__/typed.tsx +0 -23
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +0 -102
- package/src/core/primitives/tooltip/__workshop__/index.ts +0 -29
- package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +0 -74
- package/src/core/primitives/tooltip/__workshop__/props.tsx +0 -107
- package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +0 -86
- package/src/core/theme/__workshop__/build/Root.tsx +0 -367
- package/src/core/theme/__workshop__/build/helpers.ts +0 -46
- package/src/core/theme/__workshop__/build/story.tsx +0 -465
- package/src/core/theme/__workshop__/canvas.tsx +0 -352
- package/src/core/theme/__workshop__/color.tsx +0 -62
- package/src/core/theme/__workshop__/debug/story.tsx +0 -408
- package/src/core/theme/__workshop__/index.ts +0 -39
- package/src/core/theme/__workshop__/layer.tsx +0 -78
- package/src/core/theme/__workshop__/nestedProvider.tsx +0 -15
- package/src/core/utils/boundaryElement/__workshop__/index.ts +0 -14
- package/src/core/utils/boundaryElement/__workshop__/plain.tsx +0 -19
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +0 -30
- package/src/core/utils/elementQuery/__workshop__/index.ts +0 -14
- package/src/core/utils/layer/__workshop__/_debug.tsx +0 -17
- package/src/core/utils/layer/__workshop__/index.ts +0 -24
- package/src/core/utils/layer/__workshop__/multipleRoots.tsx +0 -49
- package/src/core/utils/layer/__workshop__/nested.tsx +0 -98
- package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +0 -13
- package/src/core/utils/portal/__workshop__/index.ts +0 -14
- package/src/core/utils/portal/__workshop__/named.tsx +0 -63
- package/src/core/utils/virtualList/__workshop__/changingProps.tsx +0 -36
- package/src/core/utils/virtualList/__workshop__/elementScroll.tsx +0 -24
- package/src/core/utils/virtualList/__workshop__/index.ts +0 -29
- package/src/core/utils/virtualList/__workshop__/infiniteList.tsx +0 -48
- package/src/core/utils/virtualList/__workshop__/windowScrolll.tsx +0 -22
package/dist/theme2.js
ADDED
|
@@ -0,0 +1,4104 @@
|
|
|
1
|
+
let _sanity_color = require("@sanity/color");
|
|
2
|
+
function createSelectableTones(opts, base, dark, solid, muted) {
|
|
3
|
+
return {
|
|
4
|
+
default: _createSelectableStates(opts, base, dark, solid, muted, "default"),
|
|
5
|
+
primary: _createSelectableStates(opts, base, dark, solid, muted, "primary"),
|
|
6
|
+
positive: _createSelectableStates(opts, base, dark, solid, muted, "positive"),
|
|
7
|
+
caution: _createSelectableStates(opts, base, dark, solid, muted, "caution"),
|
|
8
|
+
critical: _createSelectableStates(opts, base, dark, solid, muted, "critical")
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function _createSelectableStates(opts, base, dark, solid, muted, tone) {
|
|
12
|
+
return {
|
|
13
|
+
enabled: opts.selectable({
|
|
14
|
+
base,
|
|
15
|
+
dark,
|
|
16
|
+
solid,
|
|
17
|
+
muted,
|
|
18
|
+
state: "enabled",
|
|
19
|
+
tone
|
|
20
|
+
}),
|
|
21
|
+
hovered: opts.selectable({
|
|
22
|
+
base,
|
|
23
|
+
dark,
|
|
24
|
+
solid,
|
|
25
|
+
muted,
|
|
26
|
+
state: "hovered",
|
|
27
|
+
tone
|
|
28
|
+
}),
|
|
29
|
+
pressed: opts.selectable({
|
|
30
|
+
base,
|
|
31
|
+
dark,
|
|
32
|
+
solid,
|
|
33
|
+
muted,
|
|
34
|
+
state: "pressed",
|
|
35
|
+
tone
|
|
36
|
+
}),
|
|
37
|
+
selected: opts.selectable({
|
|
38
|
+
base,
|
|
39
|
+
dark,
|
|
40
|
+
solid,
|
|
41
|
+
muted,
|
|
42
|
+
state: "selected",
|
|
43
|
+
tone
|
|
44
|
+
}),
|
|
45
|
+
disabled: opts.selectable({
|
|
46
|
+
base,
|
|
47
|
+
dark,
|
|
48
|
+
solid,
|
|
49
|
+
muted,
|
|
50
|
+
state: "disabled",
|
|
51
|
+
tone
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function createSolidTones(opts, base, dark, name) {
|
|
56
|
+
return {
|
|
57
|
+
default: {
|
|
58
|
+
enabled: opts.solid({
|
|
59
|
+
base,
|
|
60
|
+
dark,
|
|
61
|
+
tone: "default",
|
|
62
|
+
name,
|
|
63
|
+
state: "enabled"
|
|
64
|
+
}),
|
|
65
|
+
disabled: opts.solid({
|
|
66
|
+
base,
|
|
67
|
+
dark,
|
|
68
|
+
tone: "default",
|
|
69
|
+
name,
|
|
70
|
+
state: "disabled"
|
|
71
|
+
}),
|
|
72
|
+
hovered: opts.solid({
|
|
73
|
+
base,
|
|
74
|
+
dark,
|
|
75
|
+
tone: "default",
|
|
76
|
+
name,
|
|
77
|
+
state: "hovered"
|
|
78
|
+
}),
|
|
79
|
+
pressed: opts.solid({
|
|
80
|
+
base,
|
|
81
|
+
dark,
|
|
82
|
+
tone: "default",
|
|
83
|
+
name,
|
|
84
|
+
state: "pressed"
|
|
85
|
+
}),
|
|
86
|
+
selected: opts.solid({
|
|
87
|
+
base,
|
|
88
|
+
dark,
|
|
89
|
+
tone: "default",
|
|
90
|
+
name,
|
|
91
|
+
state: "selected"
|
|
92
|
+
})
|
|
93
|
+
},
|
|
94
|
+
transparent: {
|
|
95
|
+
enabled: opts.solid({
|
|
96
|
+
base,
|
|
97
|
+
dark,
|
|
98
|
+
tone: "transparent",
|
|
99
|
+
name,
|
|
100
|
+
state: "enabled"
|
|
101
|
+
}),
|
|
102
|
+
disabled: opts.solid({
|
|
103
|
+
base,
|
|
104
|
+
dark,
|
|
105
|
+
tone: "transparent",
|
|
106
|
+
name,
|
|
107
|
+
state: "disabled"
|
|
108
|
+
}),
|
|
109
|
+
hovered: opts.solid({
|
|
110
|
+
base,
|
|
111
|
+
dark,
|
|
112
|
+
tone: "transparent",
|
|
113
|
+
name,
|
|
114
|
+
state: "hovered"
|
|
115
|
+
}),
|
|
116
|
+
pressed: opts.solid({
|
|
117
|
+
base,
|
|
118
|
+
dark,
|
|
119
|
+
tone: "transparent",
|
|
120
|
+
name,
|
|
121
|
+
state: "pressed"
|
|
122
|
+
}),
|
|
123
|
+
selected: opts.solid({
|
|
124
|
+
base,
|
|
125
|
+
dark,
|
|
126
|
+
tone: "transparent",
|
|
127
|
+
name,
|
|
128
|
+
state: "selected"
|
|
129
|
+
})
|
|
130
|
+
},
|
|
131
|
+
primary: {
|
|
132
|
+
enabled: opts.solid({
|
|
133
|
+
base,
|
|
134
|
+
dark,
|
|
135
|
+
tone: "primary",
|
|
136
|
+
name,
|
|
137
|
+
state: "enabled"
|
|
138
|
+
}),
|
|
139
|
+
disabled: opts.solid({
|
|
140
|
+
base,
|
|
141
|
+
dark,
|
|
142
|
+
tone: "primary",
|
|
143
|
+
name,
|
|
144
|
+
state: "disabled"
|
|
145
|
+
}),
|
|
146
|
+
hovered: opts.solid({
|
|
147
|
+
base,
|
|
148
|
+
dark,
|
|
149
|
+
tone: "primary",
|
|
150
|
+
name,
|
|
151
|
+
state: "hovered"
|
|
152
|
+
}),
|
|
153
|
+
pressed: opts.solid({
|
|
154
|
+
base,
|
|
155
|
+
dark,
|
|
156
|
+
tone: "primary",
|
|
157
|
+
name,
|
|
158
|
+
state: "pressed"
|
|
159
|
+
}),
|
|
160
|
+
selected: opts.solid({
|
|
161
|
+
base,
|
|
162
|
+
dark,
|
|
163
|
+
tone: "primary",
|
|
164
|
+
name,
|
|
165
|
+
state: "selected"
|
|
166
|
+
})
|
|
167
|
+
},
|
|
168
|
+
positive: {
|
|
169
|
+
enabled: opts.solid({
|
|
170
|
+
base,
|
|
171
|
+
dark,
|
|
172
|
+
tone: "positive",
|
|
173
|
+
name,
|
|
174
|
+
state: "enabled"
|
|
175
|
+
}),
|
|
176
|
+
disabled: opts.solid({
|
|
177
|
+
base,
|
|
178
|
+
dark,
|
|
179
|
+
tone: "positive",
|
|
180
|
+
name,
|
|
181
|
+
state: "disabled"
|
|
182
|
+
}),
|
|
183
|
+
hovered: opts.solid({
|
|
184
|
+
base,
|
|
185
|
+
dark,
|
|
186
|
+
tone: "positive",
|
|
187
|
+
name,
|
|
188
|
+
state: "hovered"
|
|
189
|
+
}),
|
|
190
|
+
pressed: opts.solid({
|
|
191
|
+
base,
|
|
192
|
+
dark,
|
|
193
|
+
tone: "positive",
|
|
194
|
+
name,
|
|
195
|
+
state: "pressed"
|
|
196
|
+
}),
|
|
197
|
+
selected: opts.solid({
|
|
198
|
+
base,
|
|
199
|
+
dark,
|
|
200
|
+
tone: "positive",
|
|
201
|
+
name,
|
|
202
|
+
state: "selected"
|
|
203
|
+
})
|
|
204
|
+
},
|
|
205
|
+
caution: {
|
|
206
|
+
enabled: opts.solid({
|
|
207
|
+
base,
|
|
208
|
+
dark,
|
|
209
|
+
tone: "caution",
|
|
210
|
+
name,
|
|
211
|
+
state: "enabled"
|
|
212
|
+
}),
|
|
213
|
+
disabled: opts.solid({
|
|
214
|
+
base,
|
|
215
|
+
dark,
|
|
216
|
+
tone: "caution",
|
|
217
|
+
name,
|
|
218
|
+
state: "disabled"
|
|
219
|
+
}),
|
|
220
|
+
hovered: opts.solid({
|
|
221
|
+
base,
|
|
222
|
+
dark,
|
|
223
|
+
tone: "caution",
|
|
224
|
+
name,
|
|
225
|
+
state: "hovered"
|
|
226
|
+
}),
|
|
227
|
+
pressed: opts.solid({
|
|
228
|
+
base,
|
|
229
|
+
dark,
|
|
230
|
+
tone: "caution",
|
|
231
|
+
name,
|
|
232
|
+
state: "pressed"
|
|
233
|
+
}),
|
|
234
|
+
selected: opts.solid({
|
|
235
|
+
base,
|
|
236
|
+
dark,
|
|
237
|
+
tone: "caution",
|
|
238
|
+
name,
|
|
239
|
+
state: "selected"
|
|
240
|
+
})
|
|
241
|
+
},
|
|
242
|
+
critical: {
|
|
243
|
+
enabled: opts.solid({
|
|
244
|
+
base,
|
|
245
|
+
dark,
|
|
246
|
+
tone: "critical",
|
|
247
|
+
name,
|
|
248
|
+
state: "enabled"
|
|
249
|
+
}),
|
|
250
|
+
disabled: opts.solid({
|
|
251
|
+
base,
|
|
252
|
+
dark,
|
|
253
|
+
tone: "critical",
|
|
254
|
+
name,
|
|
255
|
+
state: "disabled"
|
|
256
|
+
}),
|
|
257
|
+
hovered: opts.solid({
|
|
258
|
+
base,
|
|
259
|
+
dark,
|
|
260
|
+
tone: "critical",
|
|
261
|
+
name,
|
|
262
|
+
state: "hovered"
|
|
263
|
+
}),
|
|
264
|
+
pressed: opts.solid({
|
|
265
|
+
base,
|
|
266
|
+
dark,
|
|
267
|
+
tone: "critical",
|
|
268
|
+
name,
|
|
269
|
+
state: "pressed"
|
|
270
|
+
}),
|
|
271
|
+
selected: opts.solid({
|
|
272
|
+
base,
|
|
273
|
+
dark,
|
|
274
|
+
tone: "critical",
|
|
275
|
+
name,
|
|
276
|
+
state: "selected"
|
|
277
|
+
})
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function createButtonTones(opts, base, dark, solid, muted, mode) {
|
|
282
|
+
return {
|
|
283
|
+
default: opts.button({
|
|
284
|
+
base,
|
|
285
|
+
dark,
|
|
286
|
+
solid: solid.default,
|
|
287
|
+
muted: muted.default,
|
|
288
|
+
mode
|
|
289
|
+
}),
|
|
290
|
+
primary: opts.button({
|
|
291
|
+
base,
|
|
292
|
+
dark,
|
|
293
|
+
solid: solid.primary,
|
|
294
|
+
muted: muted.primary,
|
|
295
|
+
mode
|
|
296
|
+
}),
|
|
297
|
+
positive: opts.button({
|
|
298
|
+
base,
|
|
299
|
+
dark,
|
|
300
|
+
solid: solid.positive,
|
|
301
|
+
muted: muted.positive,
|
|
302
|
+
mode
|
|
303
|
+
}),
|
|
304
|
+
caution: opts.button({
|
|
305
|
+
base,
|
|
306
|
+
dark,
|
|
307
|
+
solid: solid.caution,
|
|
308
|
+
muted: muted.caution,
|
|
309
|
+
mode
|
|
310
|
+
}),
|
|
311
|
+
critical: opts.button({
|
|
312
|
+
base,
|
|
313
|
+
dark,
|
|
314
|
+
solid: solid.critical,
|
|
315
|
+
muted: muted.critical,
|
|
316
|
+
mode
|
|
317
|
+
})
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function createButtonModes(opts, base, dark, solid, muted) {
|
|
321
|
+
return {
|
|
322
|
+
default: createButtonTones(opts, base, dark, solid, muted, "default"),
|
|
323
|
+
ghost: createButtonTones(opts, base, dark, solid, muted, "ghost"),
|
|
324
|
+
bleed: createButtonTones(opts, base, dark, solid, muted, "bleed")
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function createCardStates(opts, base, dark, name, solid, muted) {
|
|
328
|
+
return {
|
|
329
|
+
enabled: opts.card({
|
|
330
|
+
base,
|
|
331
|
+
dark,
|
|
332
|
+
name,
|
|
333
|
+
state: "enabled",
|
|
334
|
+
solid,
|
|
335
|
+
muted
|
|
336
|
+
}),
|
|
337
|
+
disabled: opts.card({
|
|
338
|
+
base,
|
|
339
|
+
dark,
|
|
340
|
+
name,
|
|
341
|
+
state: "disabled",
|
|
342
|
+
solid,
|
|
343
|
+
muted
|
|
344
|
+
}),
|
|
345
|
+
hovered: opts.card({
|
|
346
|
+
base,
|
|
347
|
+
dark,
|
|
348
|
+
name,
|
|
349
|
+
state: "hovered",
|
|
350
|
+
solid,
|
|
351
|
+
muted
|
|
352
|
+
}),
|
|
353
|
+
pressed: opts.card({
|
|
354
|
+
base,
|
|
355
|
+
dark,
|
|
356
|
+
name,
|
|
357
|
+
state: "pressed",
|
|
358
|
+
solid,
|
|
359
|
+
muted
|
|
360
|
+
}),
|
|
361
|
+
selected: opts.card({
|
|
362
|
+
base,
|
|
363
|
+
dark,
|
|
364
|
+
name,
|
|
365
|
+
state: "selected",
|
|
366
|
+
solid,
|
|
367
|
+
muted
|
|
368
|
+
})
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
|
|
372
|
+
default: {
|
|
373
|
+
lightest: "hsl(0, 0%, 95%)",
|
|
374
|
+
lighter: "hsl(0, 0%, 70%)",
|
|
375
|
+
light: "hsl(0, 0%, 65%)",
|
|
376
|
+
base: "hsl(0, 0%, 50%)",
|
|
377
|
+
dark: "hsl(0, 0%, 35%)",
|
|
378
|
+
darker: "hsl(0, 0%, 20%)",
|
|
379
|
+
darkest: "hsl(0, 0%, 5%)"
|
|
380
|
+
},
|
|
381
|
+
transparent: {
|
|
382
|
+
lightest: "hsl(240, 100%, 95%)",
|
|
383
|
+
lighter: "hsl(240, 100%, 70%)",
|
|
384
|
+
light: "hsl(240, 100%, 65%)",
|
|
385
|
+
base: "hsl(240, 100%, 50%)",
|
|
386
|
+
dark: "hsl(240, 100%, 35%)",
|
|
387
|
+
darker: "hsl(240, 100%, 20%)",
|
|
388
|
+
darkest: "hsl(240, 100%, 5%)"
|
|
389
|
+
},
|
|
390
|
+
primary: {
|
|
391
|
+
lightest: "hsl(240, 100%, 95%)",
|
|
392
|
+
lighter: "hsl(240, 100%, 70%)",
|
|
393
|
+
light: "hsl(240, 100%, 65%)",
|
|
394
|
+
base: "hsl(240, 100%, 50%)",
|
|
395
|
+
dark: "hsl(240, 100%, 35%)",
|
|
396
|
+
darker: "hsl(240, 100%, 20%)",
|
|
397
|
+
darkest: "hsl(240, 100%, 5%)"
|
|
398
|
+
},
|
|
399
|
+
positive: {
|
|
400
|
+
lightest: "hsl(120, 100%, 95%)",
|
|
401
|
+
lighter: "hsl(120, 100%, 70%)",
|
|
402
|
+
light: "hsl(120, 100%, 65%)",
|
|
403
|
+
base: "hsl(120, 100%, 50%)",
|
|
404
|
+
dark: "hsl(120, 100%, 35%)",
|
|
405
|
+
darker: "hsl(120, 100%, 20%)",
|
|
406
|
+
darkest: "hsl(120, 100%, 5%)"
|
|
407
|
+
},
|
|
408
|
+
caution: {
|
|
409
|
+
lightest: "hsl(60, 100%, 95%)",
|
|
410
|
+
lighter: "hsl(60, 100%, 70%)",
|
|
411
|
+
light: "hsl(60, 100%, 65%)",
|
|
412
|
+
base: "hsl(60, 100%, 50%)",
|
|
413
|
+
dark: "hsl(60, 100%, 35%)",
|
|
414
|
+
darker: "hsl(60, 100%, 20%)",
|
|
415
|
+
darkest: "hsl(60, 100%, 5%)"
|
|
416
|
+
},
|
|
417
|
+
critical: {
|
|
418
|
+
lightest: "hsl(0, 100%, 95%)",
|
|
419
|
+
lighter: "hsl(0, 100%, 70%)",
|
|
420
|
+
light: "hsl(0, 100%, 65%)",
|
|
421
|
+
base: "hsl(0, 100%, 50%)",
|
|
422
|
+
dark: "hsl(0, 100%, 35%)",
|
|
423
|
+
darker: "hsl(0, 100%, 20%)",
|
|
424
|
+
darkest: "hsl(0, 100%, 5%)"
|
|
425
|
+
}
|
|
426
|
+
}, spots = {
|
|
427
|
+
gray: "hsl(0, 0%, 50%)",
|
|
428
|
+
red: "hsl(0, 100%, 50%)",
|
|
429
|
+
orange: "hsl(30, 100%, 50%)",
|
|
430
|
+
yellow: "hsl(60, 100%, 50%)",
|
|
431
|
+
green: "hsl(120, 100%, 50%)",
|
|
432
|
+
cyan: "hsl(180, 100%, 50%)",
|
|
433
|
+
blue: "hsl(240, 100%, 50%)",
|
|
434
|
+
purple: "hsl(270, 100%, 50%)",
|
|
435
|
+
magenta: "hsl(300, 100%, 50%)"
|
|
436
|
+
}, tones = {
|
|
437
|
+
transparent: {
|
|
438
|
+
bg: [colors.transparent.darkest, colors.transparent.lightest],
|
|
439
|
+
fg: [colors.transparent.lightest, colors.transparent.darkest],
|
|
440
|
+
border: [colors.transparent.darker, colors.transparent.lighter],
|
|
441
|
+
focusRing: [colors.transparent.base, colors.transparent.base]
|
|
442
|
+
},
|
|
443
|
+
primary: {
|
|
444
|
+
bg: [colors.primary.darkest, colors.primary.lightest],
|
|
445
|
+
fg: [colors.primary.lightest, colors.primary.darkest],
|
|
446
|
+
border: [colors.primary.darker, colors.primary.lighter],
|
|
447
|
+
focusRing: [colors.primary.base, colors.primary.base]
|
|
448
|
+
},
|
|
449
|
+
positive: {
|
|
450
|
+
bg: [colors.positive.darkest, colors.positive.lightest],
|
|
451
|
+
fg: [colors.positive.lightest, colors.positive.darkest],
|
|
452
|
+
border: [colors.positive.darker, colors.positive.lighter],
|
|
453
|
+
focusRing: [colors.positive.base, colors.positive.base]
|
|
454
|
+
},
|
|
455
|
+
caution: {
|
|
456
|
+
bg: [colors.caution.darkest, colors.caution.lightest],
|
|
457
|
+
fg: [colors.caution.lightest, colors.caution.darkest],
|
|
458
|
+
border: [colors.caution.darker, colors.caution.lighter],
|
|
459
|
+
focusRing: [colors.caution.base, colors.caution.base]
|
|
460
|
+
},
|
|
461
|
+
critical: {
|
|
462
|
+
bg: [colors.critical.darkest, colors.critical.lightest],
|
|
463
|
+
fg: [colors.critical.lightest, colors.critical.darkest],
|
|
464
|
+
border: [colors.critical.darker, colors.critical.lighter],
|
|
465
|
+
focusRing: [colors.critical.base, colors.critical.base]
|
|
466
|
+
}
|
|
467
|
+
}, defaultOpts = {
|
|
468
|
+
base: ({ dark, name }) => name === "default" ? {
|
|
469
|
+
bg: dark ? black : white,
|
|
470
|
+
fg: dark ? white : black,
|
|
471
|
+
border: dark ? colors.default.darkest : colors.default.lightest,
|
|
472
|
+
focusRing: colors.primary.base,
|
|
473
|
+
shadow: {
|
|
474
|
+
outline: black,
|
|
475
|
+
umbra: black,
|
|
476
|
+
penumbra: black,
|
|
477
|
+
ambient: black
|
|
478
|
+
},
|
|
479
|
+
skeleton: {
|
|
480
|
+
from: dark ? white : black,
|
|
481
|
+
to: dark ? white : black
|
|
482
|
+
}
|
|
483
|
+
} : {
|
|
484
|
+
bg: tones[name].bg[+!dark],
|
|
485
|
+
fg: tones[name].fg[+!dark],
|
|
486
|
+
border: tones[name].border[+!dark],
|
|
487
|
+
focusRing: tones[name].focusRing[+!dark],
|
|
488
|
+
shadow: {
|
|
489
|
+
outline: black,
|
|
490
|
+
umbra: black,
|
|
491
|
+
penumbra: black,
|
|
492
|
+
ambient: black
|
|
493
|
+
},
|
|
494
|
+
skeleton: {
|
|
495
|
+
from: dark ? white : black,
|
|
496
|
+
to: dark ? white : black
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
solid: ({ base, dark, state, tone }) => {
|
|
500
|
+
let color = colors[tone];
|
|
501
|
+
return state === "hovered" ? {
|
|
502
|
+
bg: dark ? color.light : color.dark,
|
|
503
|
+
bg2: dark ? color.light : color.dark,
|
|
504
|
+
border: dark ? color.lighter : color.darker,
|
|
505
|
+
fg: dark ? color.darkest : color.lightest,
|
|
506
|
+
icon: dark ? color.darkest : color.lightest,
|
|
507
|
+
muted: { fg: black },
|
|
508
|
+
accent: { fg: black },
|
|
509
|
+
link: { fg: black },
|
|
510
|
+
code: {
|
|
511
|
+
bg: black,
|
|
512
|
+
fg: black
|
|
513
|
+
},
|
|
514
|
+
skeleton: base.skeleton
|
|
515
|
+
} : {
|
|
516
|
+
bg: color.base,
|
|
517
|
+
bg2: color.base,
|
|
518
|
+
border: dark ? color.light : color.dark,
|
|
519
|
+
fg: dark ? color.darkest : color.lightest,
|
|
520
|
+
icon: dark ? color.darkest : color.lightest,
|
|
521
|
+
muted: { fg: black },
|
|
522
|
+
accent: { fg: black },
|
|
523
|
+
link: { fg: black },
|
|
524
|
+
code: {
|
|
525
|
+
bg: black,
|
|
526
|
+
fg: black
|
|
527
|
+
},
|
|
528
|
+
skeleton: base.skeleton
|
|
529
|
+
};
|
|
530
|
+
},
|
|
531
|
+
muted: ({ base, dark, state, tone }) => {
|
|
532
|
+
let color = colors[tone];
|
|
533
|
+
return state === "hovered" ? {
|
|
534
|
+
bg: dark ? color.darker : color.lighter,
|
|
535
|
+
bg2: dark ? color.darker : color.lighter,
|
|
536
|
+
border: dark ? color.lighter : color.darker,
|
|
537
|
+
fg: dark ? color.lightest : color.darkest,
|
|
538
|
+
icon: dark ? color.lightest : color.darkest,
|
|
539
|
+
muted: { fg: black },
|
|
540
|
+
accent: { fg: black },
|
|
541
|
+
link: { fg: black },
|
|
542
|
+
code: {
|
|
543
|
+
bg: black,
|
|
544
|
+
fg: black
|
|
545
|
+
},
|
|
546
|
+
skeleton: base.skeleton
|
|
547
|
+
} : {
|
|
548
|
+
bg: dark ? color.darkest : color.lightest,
|
|
549
|
+
bg2: dark ? color.darkest : color.lightest,
|
|
550
|
+
border: dark ? color.darker : color.lighter,
|
|
551
|
+
fg: dark ? color.lighter : color.darker,
|
|
552
|
+
icon: dark ? color.lighter : color.darker,
|
|
553
|
+
muted: { fg: black },
|
|
554
|
+
accent: { fg: black },
|
|
555
|
+
link: { fg: black },
|
|
556
|
+
code: {
|
|
557
|
+
bg: black,
|
|
558
|
+
fg: black
|
|
559
|
+
},
|
|
560
|
+
skeleton: base.skeleton
|
|
561
|
+
};
|
|
562
|
+
},
|
|
563
|
+
button: ({ base, mode, muted, solid }) => mode === "bleed" ? {
|
|
564
|
+
...muted,
|
|
565
|
+
enabled: {
|
|
566
|
+
bg: "transparent",
|
|
567
|
+
bg2: "transparent",
|
|
568
|
+
fg: muted.enabled.fg,
|
|
569
|
+
icon: muted.enabled.fg,
|
|
570
|
+
border: "transparent",
|
|
571
|
+
muted: { fg: black },
|
|
572
|
+
accent: { fg: black },
|
|
573
|
+
link: { fg: black },
|
|
574
|
+
code: {
|
|
575
|
+
bg: black,
|
|
576
|
+
fg: black
|
|
577
|
+
},
|
|
578
|
+
skeleton: base.skeleton
|
|
579
|
+
},
|
|
580
|
+
hovered: {
|
|
581
|
+
bg: muted.enabled.bg,
|
|
582
|
+
bg2: muted.enabled.bg,
|
|
583
|
+
fg: muted.hovered.fg,
|
|
584
|
+
icon: muted.hovered.fg,
|
|
585
|
+
border: "transparent",
|
|
586
|
+
muted: { fg: black },
|
|
587
|
+
accent: { fg: black },
|
|
588
|
+
link: { fg: black },
|
|
589
|
+
code: {
|
|
590
|
+
bg: black,
|
|
591
|
+
fg: black
|
|
592
|
+
},
|
|
593
|
+
skeleton: base.skeleton
|
|
594
|
+
}
|
|
595
|
+
} : mode === "ghost" ? {
|
|
596
|
+
...solid,
|
|
597
|
+
enabled: muted.enabled
|
|
598
|
+
} : solid,
|
|
599
|
+
card: ({ base }) => ({
|
|
600
|
+
bg: black,
|
|
601
|
+
bg2: black,
|
|
602
|
+
fg: black,
|
|
603
|
+
icon: black,
|
|
604
|
+
border: black,
|
|
605
|
+
muted: { fg: black },
|
|
606
|
+
accent: { fg: black },
|
|
607
|
+
link: { fg: black },
|
|
608
|
+
code: {
|
|
609
|
+
bg: black,
|
|
610
|
+
fg: black
|
|
611
|
+
},
|
|
612
|
+
skeleton: base.skeleton
|
|
613
|
+
}),
|
|
614
|
+
input: () => ({
|
|
615
|
+
bg: black,
|
|
616
|
+
bg2: black,
|
|
617
|
+
fg: black,
|
|
618
|
+
border: black,
|
|
619
|
+
placeholder: black
|
|
620
|
+
}),
|
|
621
|
+
selectable: ({ muted, state, tone }) => muted[tone][state],
|
|
622
|
+
spot: ({ key }) => spots[key],
|
|
623
|
+
syntax: () => ({
|
|
624
|
+
atrule: black,
|
|
625
|
+
attrName: black,
|
|
626
|
+
attrValue: black,
|
|
627
|
+
attribute: black,
|
|
628
|
+
boolean: black,
|
|
629
|
+
builtin: black,
|
|
630
|
+
cdata: black,
|
|
631
|
+
char: black,
|
|
632
|
+
class: black,
|
|
633
|
+
className: black,
|
|
634
|
+
comment: black,
|
|
635
|
+
constant: black,
|
|
636
|
+
deleted: black,
|
|
637
|
+
doctype: black,
|
|
638
|
+
entity: black,
|
|
639
|
+
function: black,
|
|
640
|
+
hexcode: black,
|
|
641
|
+
id: black,
|
|
642
|
+
important: black,
|
|
643
|
+
inserted: black,
|
|
644
|
+
keyword: black,
|
|
645
|
+
number: black,
|
|
646
|
+
operator: black,
|
|
647
|
+
prolog: black,
|
|
648
|
+
property: black,
|
|
649
|
+
pseudoClass: black,
|
|
650
|
+
pseudoElement: black,
|
|
651
|
+
punctuation: black,
|
|
652
|
+
regex: black,
|
|
653
|
+
selector: black,
|
|
654
|
+
string: black,
|
|
655
|
+
symbol: black,
|
|
656
|
+
tag: black,
|
|
657
|
+
unit: black,
|
|
658
|
+
url: black,
|
|
659
|
+
variable: black
|
|
660
|
+
})
|
|
661
|
+
};
|
|
662
|
+
function createInputModes(opts, base, dark, solid, muted) {
|
|
663
|
+
return {
|
|
664
|
+
default: {
|
|
665
|
+
enabled: opts.input({
|
|
666
|
+
base,
|
|
667
|
+
dark,
|
|
668
|
+
mode: "default",
|
|
669
|
+
state: "enabled",
|
|
670
|
+
solid: solid.default,
|
|
671
|
+
muted: muted.default
|
|
672
|
+
}),
|
|
673
|
+
disabled: opts.input({
|
|
674
|
+
base,
|
|
675
|
+
dark,
|
|
676
|
+
mode: "default",
|
|
677
|
+
state: "disabled",
|
|
678
|
+
solid: solid.default,
|
|
679
|
+
muted: muted.default
|
|
680
|
+
}),
|
|
681
|
+
hovered: opts.input({
|
|
682
|
+
base,
|
|
683
|
+
dark,
|
|
684
|
+
mode: "default",
|
|
685
|
+
state: "hovered",
|
|
686
|
+
solid: solid.default,
|
|
687
|
+
muted: muted.default
|
|
688
|
+
}),
|
|
689
|
+
readOnly: opts.input({
|
|
690
|
+
base,
|
|
691
|
+
dark,
|
|
692
|
+
mode: "default",
|
|
693
|
+
state: "readOnly",
|
|
694
|
+
solid: solid.default,
|
|
695
|
+
muted: muted.default
|
|
696
|
+
})
|
|
697
|
+
},
|
|
698
|
+
invalid: {
|
|
699
|
+
enabled: opts.input({
|
|
700
|
+
base,
|
|
701
|
+
dark,
|
|
702
|
+
mode: "invalid",
|
|
703
|
+
state: "enabled",
|
|
704
|
+
solid: solid.default,
|
|
705
|
+
muted: muted.default
|
|
706
|
+
}),
|
|
707
|
+
disabled: opts.input({
|
|
708
|
+
base,
|
|
709
|
+
dark,
|
|
710
|
+
mode: "invalid",
|
|
711
|
+
state: "disabled",
|
|
712
|
+
solid: solid.default,
|
|
713
|
+
muted: muted.default
|
|
714
|
+
}),
|
|
715
|
+
hovered: opts.input({
|
|
716
|
+
base,
|
|
717
|
+
dark,
|
|
718
|
+
mode: "invalid",
|
|
719
|
+
state: "hovered",
|
|
720
|
+
solid: solid.default,
|
|
721
|
+
muted: muted.default
|
|
722
|
+
}),
|
|
723
|
+
readOnly: opts.input({
|
|
724
|
+
base,
|
|
725
|
+
dark,
|
|
726
|
+
mode: "invalid",
|
|
727
|
+
state: "readOnly",
|
|
728
|
+
solid: solid.default,
|
|
729
|
+
muted: muted.default
|
|
730
|
+
})
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
function createMutedTones(opts, base, dark, name) {
|
|
735
|
+
return {
|
|
736
|
+
default: {
|
|
737
|
+
enabled: opts.muted({
|
|
738
|
+
base,
|
|
739
|
+
dark,
|
|
740
|
+
tone: "default",
|
|
741
|
+
name,
|
|
742
|
+
state: "enabled"
|
|
743
|
+
}),
|
|
744
|
+
disabled: opts.muted({
|
|
745
|
+
base,
|
|
746
|
+
dark,
|
|
747
|
+
tone: "default",
|
|
748
|
+
name,
|
|
749
|
+
state: "disabled"
|
|
750
|
+
}),
|
|
751
|
+
hovered: opts.muted({
|
|
752
|
+
base,
|
|
753
|
+
dark,
|
|
754
|
+
tone: "default",
|
|
755
|
+
name,
|
|
756
|
+
state: "hovered"
|
|
757
|
+
}),
|
|
758
|
+
pressed: opts.muted({
|
|
759
|
+
base,
|
|
760
|
+
dark,
|
|
761
|
+
tone: "default",
|
|
762
|
+
name,
|
|
763
|
+
state: "pressed"
|
|
764
|
+
}),
|
|
765
|
+
selected: opts.muted({
|
|
766
|
+
base,
|
|
767
|
+
dark,
|
|
768
|
+
tone: "default",
|
|
769
|
+
name,
|
|
770
|
+
state: "selected"
|
|
771
|
+
})
|
|
772
|
+
},
|
|
773
|
+
transparent: {
|
|
774
|
+
enabled: opts.muted({
|
|
775
|
+
base,
|
|
776
|
+
dark,
|
|
777
|
+
tone: "transparent",
|
|
778
|
+
name,
|
|
779
|
+
state: "enabled"
|
|
780
|
+
}),
|
|
781
|
+
disabled: opts.muted({
|
|
782
|
+
base,
|
|
783
|
+
dark,
|
|
784
|
+
tone: "transparent",
|
|
785
|
+
name,
|
|
786
|
+
state: "disabled"
|
|
787
|
+
}),
|
|
788
|
+
hovered: opts.muted({
|
|
789
|
+
base,
|
|
790
|
+
dark,
|
|
791
|
+
tone: "transparent",
|
|
792
|
+
name,
|
|
793
|
+
state: "hovered"
|
|
794
|
+
}),
|
|
795
|
+
pressed: opts.muted({
|
|
796
|
+
base,
|
|
797
|
+
dark,
|
|
798
|
+
tone: "transparent",
|
|
799
|
+
name,
|
|
800
|
+
state: "pressed"
|
|
801
|
+
}),
|
|
802
|
+
selected: opts.muted({
|
|
803
|
+
base,
|
|
804
|
+
dark,
|
|
805
|
+
tone: "transparent",
|
|
806
|
+
name,
|
|
807
|
+
state: "selected"
|
|
808
|
+
})
|
|
809
|
+
},
|
|
810
|
+
primary: {
|
|
811
|
+
enabled: opts.muted({
|
|
812
|
+
base,
|
|
813
|
+
dark,
|
|
814
|
+
tone: "primary",
|
|
815
|
+
name,
|
|
816
|
+
state: "enabled"
|
|
817
|
+
}),
|
|
818
|
+
disabled: opts.muted({
|
|
819
|
+
base,
|
|
820
|
+
dark,
|
|
821
|
+
tone: "primary",
|
|
822
|
+
name,
|
|
823
|
+
state: "disabled"
|
|
824
|
+
}),
|
|
825
|
+
hovered: opts.muted({
|
|
826
|
+
base,
|
|
827
|
+
dark,
|
|
828
|
+
tone: "primary",
|
|
829
|
+
name,
|
|
830
|
+
state: "hovered"
|
|
831
|
+
}),
|
|
832
|
+
pressed: opts.muted({
|
|
833
|
+
base,
|
|
834
|
+
dark,
|
|
835
|
+
tone: "primary",
|
|
836
|
+
name,
|
|
837
|
+
state: "pressed"
|
|
838
|
+
}),
|
|
839
|
+
selected: opts.muted({
|
|
840
|
+
base,
|
|
841
|
+
dark,
|
|
842
|
+
tone: "primary",
|
|
843
|
+
name,
|
|
844
|
+
state: "selected"
|
|
845
|
+
})
|
|
846
|
+
},
|
|
847
|
+
positive: {
|
|
848
|
+
enabled: opts.muted({
|
|
849
|
+
base,
|
|
850
|
+
dark,
|
|
851
|
+
tone: "positive",
|
|
852
|
+
name,
|
|
853
|
+
state: "enabled"
|
|
854
|
+
}),
|
|
855
|
+
disabled: opts.muted({
|
|
856
|
+
base,
|
|
857
|
+
dark,
|
|
858
|
+
tone: "positive",
|
|
859
|
+
name,
|
|
860
|
+
state: "disabled"
|
|
861
|
+
}),
|
|
862
|
+
hovered: opts.muted({
|
|
863
|
+
base,
|
|
864
|
+
dark,
|
|
865
|
+
tone: "positive",
|
|
866
|
+
name,
|
|
867
|
+
state: "hovered"
|
|
868
|
+
}),
|
|
869
|
+
pressed: opts.muted({
|
|
870
|
+
base,
|
|
871
|
+
dark,
|
|
872
|
+
tone: "positive",
|
|
873
|
+
name,
|
|
874
|
+
state: "pressed"
|
|
875
|
+
}),
|
|
876
|
+
selected: opts.muted({
|
|
877
|
+
base,
|
|
878
|
+
dark,
|
|
879
|
+
tone: "positive",
|
|
880
|
+
name,
|
|
881
|
+
state: "selected"
|
|
882
|
+
})
|
|
883
|
+
},
|
|
884
|
+
caution: {
|
|
885
|
+
enabled: opts.muted({
|
|
886
|
+
base,
|
|
887
|
+
dark,
|
|
888
|
+
tone: "caution",
|
|
889
|
+
name,
|
|
890
|
+
state: "enabled"
|
|
891
|
+
}),
|
|
892
|
+
disabled: opts.muted({
|
|
893
|
+
base,
|
|
894
|
+
dark,
|
|
895
|
+
tone: "caution",
|
|
896
|
+
name,
|
|
897
|
+
state: "disabled"
|
|
898
|
+
}),
|
|
899
|
+
hovered: opts.muted({
|
|
900
|
+
base,
|
|
901
|
+
dark,
|
|
902
|
+
tone: "caution",
|
|
903
|
+
name,
|
|
904
|
+
state: "hovered"
|
|
905
|
+
}),
|
|
906
|
+
pressed: opts.muted({
|
|
907
|
+
base,
|
|
908
|
+
dark,
|
|
909
|
+
tone: "caution",
|
|
910
|
+
name,
|
|
911
|
+
state: "pressed"
|
|
912
|
+
}),
|
|
913
|
+
selected: opts.muted({
|
|
914
|
+
base,
|
|
915
|
+
dark,
|
|
916
|
+
tone: "caution",
|
|
917
|
+
name,
|
|
918
|
+
state: "selected"
|
|
919
|
+
})
|
|
920
|
+
},
|
|
921
|
+
critical: {
|
|
922
|
+
enabled: opts.muted({
|
|
923
|
+
base,
|
|
924
|
+
dark,
|
|
925
|
+
tone: "critical",
|
|
926
|
+
name,
|
|
927
|
+
state: "enabled"
|
|
928
|
+
}),
|
|
929
|
+
disabled: opts.muted({
|
|
930
|
+
base,
|
|
931
|
+
dark,
|
|
932
|
+
tone: "critical",
|
|
933
|
+
name,
|
|
934
|
+
state: "disabled"
|
|
935
|
+
}),
|
|
936
|
+
hovered: opts.muted({
|
|
937
|
+
base,
|
|
938
|
+
dark,
|
|
939
|
+
tone: "critical",
|
|
940
|
+
name,
|
|
941
|
+
state: "hovered"
|
|
942
|
+
}),
|
|
943
|
+
pressed: opts.muted({
|
|
944
|
+
base,
|
|
945
|
+
dark,
|
|
946
|
+
tone: "critical",
|
|
947
|
+
name,
|
|
948
|
+
state: "pressed"
|
|
949
|
+
}),
|
|
950
|
+
selected: opts.muted({
|
|
951
|
+
base,
|
|
952
|
+
dark,
|
|
953
|
+
tone: "critical",
|
|
954
|
+
name,
|
|
955
|
+
state: "selected"
|
|
956
|
+
})
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
function createSpot(opts, base, dark) {
|
|
961
|
+
return {
|
|
962
|
+
gray: opts.spot({
|
|
963
|
+
base,
|
|
964
|
+
dark,
|
|
965
|
+
key: "gray"
|
|
966
|
+
}),
|
|
967
|
+
blue: opts.spot({
|
|
968
|
+
base,
|
|
969
|
+
dark,
|
|
970
|
+
key: "blue"
|
|
971
|
+
}),
|
|
972
|
+
purple: opts.spot({
|
|
973
|
+
base,
|
|
974
|
+
dark,
|
|
975
|
+
key: "purple"
|
|
976
|
+
}),
|
|
977
|
+
magenta: opts.spot({
|
|
978
|
+
base,
|
|
979
|
+
dark,
|
|
980
|
+
key: "magenta"
|
|
981
|
+
}),
|
|
982
|
+
red: opts.spot({
|
|
983
|
+
base,
|
|
984
|
+
dark,
|
|
985
|
+
key: "red"
|
|
986
|
+
}),
|
|
987
|
+
orange: opts.spot({
|
|
988
|
+
base,
|
|
989
|
+
dark,
|
|
990
|
+
key: "orange"
|
|
991
|
+
}),
|
|
992
|
+
yellow: opts.spot({
|
|
993
|
+
base,
|
|
994
|
+
dark,
|
|
995
|
+
key: "yellow"
|
|
996
|
+
}),
|
|
997
|
+
green: opts.spot({
|
|
998
|
+
base,
|
|
999
|
+
dark,
|
|
1000
|
+
key: "green"
|
|
1001
|
+
}),
|
|
1002
|
+
cyan: opts.spot({
|
|
1003
|
+
base,
|
|
1004
|
+
dark,
|
|
1005
|
+
key: "cyan"
|
|
1006
|
+
})
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* @public
|
|
1011
|
+
* @deprecated Use `buildColorTheme` instead.
|
|
1012
|
+
*/
|
|
1013
|
+
function createColorTheme(partialOpts = {}) {
|
|
1014
|
+
let builders = {
|
|
1015
|
+
...defaultOpts,
|
|
1016
|
+
...partialOpts
|
|
1017
|
+
};
|
|
1018
|
+
return {
|
|
1019
|
+
light: _createColorScheme(builders, !1),
|
|
1020
|
+
dark: _createColorScheme(builders, !0)
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* @internal
|
|
1025
|
+
*/
|
|
1026
|
+
function _createColorScheme(opts, dark) {
|
|
1027
|
+
return {
|
|
1028
|
+
default: _createColor(opts, dark, "default"),
|
|
1029
|
+
transparent: _createColor(opts, dark, "transparent"),
|
|
1030
|
+
primary: _createColor(opts, dark, "primary"),
|
|
1031
|
+
positive: _createColor(opts, dark, "positive"),
|
|
1032
|
+
caution: _createColor(opts, dark, "caution"),
|
|
1033
|
+
critical: _createColor(opts, dark, "critical")
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* @internal
|
|
1038
|
+
*/
|
|
1039
|
+
function _createColor(opts, dark, name) {
|
|
1040
|
+
let base = opts.base({
|
|
1041
|
+
dark,
|
|
1042
|
+
name
|
|
1043
|
+
}), solid = createSolidTones(opts, base, dark, name), muted = createMutedTones(opts, base, dark, name);
|
|
1044
|
+
return {
|
|
1045
|
+
base,
|
|
1046
|
+
button: createButtonModes(opts, base, dark, solid, muted),
|
|
1047
|
+
card: createCardStates(opts, base, dark, name, solid, muted),
|
|
1048
|
+
dark,
|
|
1049
|
+
input: createInputModes(opts, base, dark, solid, muted),
|
|
1050
|
+
selectable: createSelectableTones(opts, base, dark, solid, muted),
|
|
1051
|
+
spot: createSpot(opts, base, dark),
|
|
1052
|
+
syntax: opts.syntax({
|
|
1053
|
+
base,
|
|
1054
|
+
dark
|
|
1055
|
+
}),
|
|
1056
|
+
solid,
|
|
1057
|
+
muted
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
const defaultThemeConfig = {
|
|
1061
|
+
_version: 2,
|
|
1062
|
+
avatar: {
|
|
1063
|
+
sizes: [
|
|
1064
|
+
{
|
|
1065
|
+
distance: -4,
|
|
1066
|
+
size: 19
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
distance: -4,
|
|
1070
|
+
size: 25
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
distance: -8,
|
|
1074
|
+
size: 33
|
|
1075
|
+
},
|
|
1076
|
+
{
|
|
1077
|
+
distance: -12,
|
|
1078
|
+
size: 49
|
|
1079
|
+
}
|
|
1080
|
+
],
|
|
1081
|
+
focusRing: {
|
|
1082
|
+
offset: 1,
|
|
1083
|
+
width: 1
|
|
1084
|
+
}
|
|
1085
|
+
},
|
|
1086
|
+
button: {
|
|
1087
|
+
textWeight: "medium",
|
|
1088
|
+
border: { width: 1 },
|
|
1089
|
+
focusRing: {
|
|
1090
|
+
offset: -1,
|
|
1091
|
+
width: 1
|
|
1092
|
+
}
|
|
1093
|
+
},
|
|
1094
|
+
card: {
|
|
1095
|
+
border: { width: 1 },
|
|
1096
|
+
focusRing: {
|
|
1097
|
+
offset: -1,
|
|
1098
|
+
width: 1
|
|
1099
|
+
},
|
|
1100
|
+
shadow: { outline: .5 }
|
|
1101
|
+
},
|
|
1102
|
+
container: [
|
|
1103
|
+
320,
|
|
1104
|
+
640,
|
|
1105
|
+
960,
|
|
1106
|
+
1280,
|
|
1107
|
+
1600,
|
|
1108
|
+
1920
|
|
1109
|
+
],
|
|
1110
|
+
media: [
|
|
1111
|
+
360,
|
|
1112
|
+
600,
|
|
1113
|
+
900,
|
|
1114
|
+
1200,
|
|
1115
|
+
1800,
|
|
1116
|
+
2400
|
|
1117
|
+
],
|
|
1118
|
+
layer: {
|
|
1119
|
+
dialog: { zOffset: 600 },
|
|
1120
|
+
popover: { zOffset: 400 },
|
|
1121
|
+
tooltip: { zOffset: 200 }
|
|
1122
|
+
},
|
|
1123
|
+
radius: [
|
|
1124
|
+
0,
|
|
1125
|
+
1,
|
|
1126
|
+
3,
|
|
1127
|
+
6,
|
|
1128
|
+
9,
|
|
1129
|
+
12,
|
|
1130
|
+
21
|
|
1131
|
+
],
|
|
1132
|
+
shadow: [
|
|
1133
|
+
null,
|
|
1134
|
+
{
|
|
1135
|
+
umbra: [
|
|
1136
|
+
0,
|
|
1137
|
+
0,
|
|
1138
|
+
0,
|
|
1139
|
+
0
|
|
1140
|
+
],
|
|
1141
|
+
penumbra: [
|
|
1142
|
+
0,
|
|
1143
|
+
0,
|
|
1144
|
+
0,
|
|
1145
|
+
0
|
|
1146
|
+
],
|
|
1147
|
+
ambient: [
|
|
1148
|
+
0,
|
|
1149
|
+
0,
|
|
1150
|
+
0,
|
|
1151
|
+
0
|
|
1152
|
+
]
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
umbra: [
|
|
1156
|
+
0,
|
|
1157
|
+
3,
|
|
1158
|
+
5,
|
|
1159
|
+
-2
|
|
1160
|
+
],
|
|
1161
|
+
penumbra: [
|
|
1162
|
+
0,
|
|
1163
|
+
6,
|
|
1164
|
+
10,
|
|
1165
|
+
0
|
|
1166
|
+
],
|
|
1167
|
+
ambient: [
|
|
1168
|
+
0,
|
|
1169
|
+
1,
|
|
1170
|
+
18,
|
|
1171
|
+
1
|
|
1172
|
+
]
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
umbra: [
|
|
1176
|
+
0,
|
|
1177
|
+
7,
|
|
1178
|
+
8,
|
|
1179
|
+
-4
|
|
1180
|
+
],
|
|
1181
|
+
penumbra: [
|
|
1182
|
+
0,
|
|
1183
|
+
12,
|
|
1184
|
+
17,
|
|
1185
|
+
2
|
|
1186
|
+
],
|
|
1187
|
+
ambient: [
|
|
1188
|
+
0,
|
|
1189
|
+
5,
|
|
1190
|
+
22,
|
|
1191
|
+
4
|
|
1192
|
+
]
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
umbra: [
|
|
1196
|
+
0,
|
|
1197
|
+
9,
|
|
1198
|
+
11,
|
|
1199
|
+
-5
|
|
1200
|
+
],
|
|
1201
|
+
penumbra: [
|
|
1202
|
+
0,
|
|
1203
|
+
18,
|
|
1204
|
+
28,
|
|
1205
|
+
2
|
|
1206
|
+
],
|
|
1207
|
+
ambient: [
|
|
1208
|
+
0,
|
|
1209
|
+
7,
|
|
1210
|
+
34,
|
|
1211
|
+
6
|
|
1212
|
+
]
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
umbra: [
|
|
1216
|
+
0,
|
|
1217
|
+
11,
|
|
1218
|
+
15,
|
|
1219
|
+
-7
|
|
1220
|
+
],
|
|
1221
|
+
penumbra: [
|
|
1222
|
+
0,
|
|
1223
|
+
24,
|
|
1224
|
+
38,
|
|
1225
|
+
3
|
|
1226
|
+
],
|
|
1227
|
+
ambient: [
|
|
1228
|
+
0,
|
|
1229
|
+
9,
|
|
1230
|
+
46,
|
|
1231
|
+
8
|
|
1232
|
+
]
|
|
1233
|
+
}
|
|
1234
|
+
],
|
|
1235
|
+
space: [
|
|
1236
|
+
0,
|
|
1237
|
+
4,
|
|
1238
|
+
8,
|
|
1239
|
+
12,
|
|
1240
|
+
20,
|
|
1241
|
+
32,
|
|
1242
|
+
52,
|
|
1243
|
+
84,
|
|
1244
|
+
136,
|
|
1245
|
+
220
|
|
1246
|
+
],
|
|
1247
|
+
input: {
|
|
1248
|
+
border: { width: 1 },
|
|
1249
|
+
checkbox: {
|
|
1250
|
+
size: 17,
|
|
1251
|
+
focusRing: {
|
|
1252
|
+
offset: -1,
|
|
1253
|
+
width: 1
|
|
1254
|
+
}
|
|
1255
|
+
},
|
|
1256
|
+
radio: {
|
|
1257
|
+
size: 17,
|
|
1258
|
+
markSize: 9,
|
|
1259
|
+
focusRing: {
|
|
1260
|
+
offset: -1,
|
|
1261
|
+
width: 1
|
|
1262
|
+
}
|
|
1263
|
+
},
|
|
1264
|
+
switch: {
|
|
1265
|
+
width: 25,
|
|
1266
|
+
height: 17,
|
|
1267
|
+
padding: 5,
|
|
1268
|
+
transitionDurationMs: 150,
|
|
1269
|
+
transitionTimingFunction: "ease-out",
|
|
1270
|
+
focusRing: {
|
|
1271
|
+
offset: 1,
|
|
1272
|
+
width: 1
|
|
1273
|
+
}
|
|
1274
|
+
},
|
|
1275
|
+
select: { focusRing: {
|
|
1276
|
+
offset: -1,
|
|
1277
|
+
width: 1
|
|
1278
|
+
} },
|
|
1279
|
+
text: { focusRing: {
|
|
1280
|
+
offset: -1,
|
|
1281
|
+
width: 1
|
|
1282
|
+
} }
|
|
1283
|
+
},
|
|
1284
|
+
style: { button: { root: { transition: "background-color 100ms,border-color 100ms,color 100ms" } } }
|
|
1285
|
+
}, defaultThemeFonts = {
|
|
1286
|
+
code: {
|
|
1287
|
+
family: "ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace",
|
|
1288
|
+
weights: {
|
|
1289
|
+
regular: 400,
|
|
1290
|
+
medium: 500,
|
|
1291
|
+
semibold: 600,
|
|
1292
|
+
bold: 700
|
|
1293
|
+
},
|
|
1294
|
+
sizes: [
|
|
1295
|
+
{
|
|
1296
|
+
ascenderHeight: 4,
|
|
1297
|
+
descenderHeight: 4,
|
|
1298
|
+
fontSize: 10,
|
|
1299
|
+
iconSize: 17,
|
|
1300
|
+
lineHeight: 15,
|
|
1301
|
+
letterSpacing: 0
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
ascenderHeight: 5,
|
|
1305
|
+
descenderHeight: 5,
|
|
1306
|
+
fontSize: 13,
|
|
1307
|
+
iconSize: 21,
|
|
1308
|
+
lineHeight: 19,
|
|
1309
|
+
letterSpacing: 0
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
ascenderHeight: 6,
|
|
1313
|
+
descenderHeight: 6,
|
|
1314
|
+
fontSize: 16,
|
|
1315
|
+
iconSize: 25,
|
|
1316
|
+
lineHeight: 23,
|
|
1317
|
+
letterSpacing: 0
|
|
1318
|
+
},
|
|
1319
|
+
{
|
|
1320
|
+
ascenderHeight: 7,
|
|
1321
|
+
descenderHeight: 7,
|
|
1322
|
+
fontSize: 19,
|
|
1323
|
+
iconSize: 29,
|
|
1324
|
+
lineHeight: 27,
|
|
1325
|
+
letterSpacing: 0
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
ascenderHeight: 8,
|
|
1329
|
+
descenderHeight: 8,
|
|
1330
|
+
fontSize: 22,
|
|
1331
|
+
iconSize: 33,
|
|
1332
|
+
lineHeight: 31,
|
|
1333
|
+
letterSpacing: 0
|
|
1334
|
+
}
|
|
1335
|
+
]
|
|
1336
|
+
},
|
|
1337
|
+
heading: {
|
|
1338
|
+
family: "Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Liberation Sans\", Helvetica, Arial, system-ui, sans-serif",
|
|
1339
|
+
weights: {
|
|
1340
|
+
regular: 700,
|
|
1341
|
+
medium: 800,
|
|
1342
|
+
semibold: 900,
|
|
1343
|
+
bold: 900
|
|
1344
|
+
},
|
|
1345
|
+
sizes: [
|
|
1346
|
+
{
|
|
1347
|
+
ascenderHeight: 5,
|
|
1348
|
+
descenderHeight: 5,
|
|
1349
|
+
fontSize: 13,
|
|
1350
|
+
iconSize: 17,
|
|
1351
|
+
lineHeight: 19,
|
|
1352
|
+
letterSpacing: 0
|
|
1353
|
+
},
|
|
1354
|
+
{
|
|
1355
|
+
ascenderHeight: 6,
|
|
1356
|
+
descenderHeight: 6,
|
|
1357
|
+
fontSize: 16,
|
|
1358
|
+
iconSize: 25,
|
|
1359
|
+
lineHeight: 23,
|
|
1360
|
+
letterSpacing: 0
|
|
1361
|
+
},
|
|
1362
|
+
{
|
|
1363
|
+
ascenderHeight: 7,
|
|
1364
|
+
descenderHeight: 7,
|
|
1365
|
+
fontSize: 21,
|
|
1366
|
+
iconSize: 33,
|
|
1367
|
+
lineHeight: 29,
|
|
1368
|
+
letterSpacing: 0
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
ascenderHeight: 8,
|
|
1372
|
+
descenderHeight: 8,
|
|
1373
|
+
fontSize: 27,
|
|
1374
|
+
iconSize: 41,
|
|
1375
|
+
lineHeight: 35,
|
|
1376
|
+
letterSpacing: 0
|
|
1377
|
+
},
|
|
1378
|
+
{
|
|
1379
|
+
ascenderHeight: 9.5,
|
|
1380
|
+
descenderHeight: 8.5,
|
|
1381
|
+
fontSize: 33,
|
|
1382
|
+
iconSize: 49,
|
|
1383
|
+
lineHeight: 41,
|
|
1384
|
+
letterSpacing: 0
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
ascenderHeight: 10.5,
|
|
1388
|
+
descenderHeight: 9.5,
|
|
1389
|
+
fontSize: 38,
|
|
1390
|
+
iconSize: 53,
|
|
1391
|
+
lineHeight: 47,
|
|
1392
|
+
letterSpacing: 0
|
|
1393
|
+
}
|
|
1394
|
+
]
|
|
1395
|
+
},
|
|
1396
|
+
label: {
|
|
1397
|
+
family: "Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Liberation Sans\", system-ui, sans-serif",
|
|
1398
|
+
weights: {
|
|
1399
|
+
regular: 600,
|
|
1400
|
+
medium: 700,
|
|
1401
|
+
semibold: 800,
|
|
1402
|
+
bold: 900
|
|
1403
|
+
},
|
|
1404
|
+
sizes: [
|
|
1405
|
+
{
|
|
1406
|
+
ascenderHeight: 2,
|
|
1407
|
+
descenderHeight: 2,
|
|
1408
|
+
fontSize: 8.1,
|
|
1409
|
+
iconSize: 13,
|
|
1410
|
+
lineHeight: 10,
|
|
1411
|
+
letterSpacing: .5
|
|
1412
|
+
},
|
|
1413
|
+
{
|
|
1414
|
+
ascenderHeight: 2,
|
|
1415
|
+
descenderHeight: 2,
|
|
1416
|
+
fontSize: 9.5,
|
|
1417
|
+
iconSize: 15,
|
|
1418
|
+
lineHeight: 11,
|
|
1419
|
+
letterSpacing: .5
|
|
1420
|
+
},
|
|
1421
|
+
{
|
|
1422
|
+
ascenderHeight: 2,
|
|
1423
|
+
descenderHeight: 2,
|
|
1424
|
+
fontSize: 10.8,
|
|
1425
|
+
iconSize: 17,
|
|
1426
|
+
lineHeight: 12,
|
|
1427
|
+
letterSpacing: .5
|
|
1428
|
+
},
|
|
1429
|
+
{
|
|
1430
|
+
ascenderHeight: 2,
|
|
1431
|
+
descenderHeight: 2,
|
|
1432
|
+
fontSize: 12.25,
|
|
1433
|
+
iconSize: 19,
|
|
1434
|
+
lineHeight: 13,
|
|
1435
|
+
letterSpacing: .5
|
|
1436
|
+
},
|
|
1437
|
+
{
|
|
1438
|
+
ascenderHeight: 2,
|
|
1439
|
+
descenderHeight: 2,
|
|
1440
|
+
fontSize: 13.6,
|
|
1441
|
+
iconSize: 21,
|
|
1442
|
+
lineHeight: 14,
|
|
1443
|
+
letterSpacing: .5
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
ascenderHeight: 2,
|
|
1447
|
+
descenderHeight: 2,
|
|
1448
|
+
fontSize: 15,
|
|
1449
|
+
iconSize: 23,
|
|
1450
|
+
lineHeight: 15,
|
|
1451
|
+
letterSpacing: .5
|
|
1452
|
+
}
|
|
1453
|
+
]
|
|
1454
|
+
},
|
|
1455
|
+
text: {
|
|
1456
|
+
family: "Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Liberation Sans\", Helvetica, Arial, system-ui, sans-serif",
|
|
1457
|
+
weights: {
|
|
1458
|
+
regular: 400,
|
|
1459
|
+
medium: 500,
|
|
1460
|
+
semibold: 600,
|
|
1461
|
+
bold: 700
|
|
1462
|
+
},
|
|
1463
|
+
sizes: [
|
|
1464
|
+
{
|
|
1465
|
+
ascenderHeight: 4,
|
|
1466
|
+
descenderHeight: 4,
|
|
1467
|
+
fontSize: 10,
|
|
1468
|
+
iconSize: 17,
|
|
1469
|
+
lineHeight: 15,
|
|
1470
|
+
letterSpacing: 0
|
|
1471
|
+
},
|
|
1472
|
+
{
|
|
1473
|
+
ascenderHeight: 5,
|
|
1474
|
+
descenderHeight: 5,
|
|
1475
|
+
fontSize: 13,
|
|
1476
|
+
iconSize: 21,
|
|
1477
|
+
lineHeight: 19,
|
|
1478
|
+
letterSpacing: 0
|
|
1479
|
+
},
|
|
1480
|
+
{
|
|
1481
|
+
ascenderHeight: 6,
|
|
1482
|
+
descenderHeight: 6,
|
|
1483
|
+
fontSize: 15,
|
|
1484
|
+
iconSize: 25,
|
|
1485
|
+
lineHeight: 23,
|
|
1486
|
+
letterSpacing: 0
|
|
1487
|
+
},
|
|
1488
|
+
{
|
|
1489
|
+
ascenderHeight: 7,
|
|
1490
|
+
descenderHeight: 7,
|
|
1491
|
+
fontSize: 18,
|
|
1492
|
+
iconSize: 29,
|
|
1493
|
+
lineHeight: 27,
|
|
1494
|
+
letterSpacing: 0
|
|
1495
|
+
},
|
|
1496
|
+
{
|
|
1497
|
+
ascenderHeight: 8,
|
|
1498
|
+
descenderHeight: 8,
|
|
1499
|
+
fontSize: 21,
|
|
1500
|
+
iconSize: 33,
|
|
1501
|
+
lineHeight: 31,
|
|
1502
|
+
letterSpacing: 0
|
|
1503
|
+
}
|
|
1504
|
+
]
|
|
1505
|
+
}
|
|
1506
|
+
}, cache$4 = /* @__PURE__ */ new WeakMap();
|
|
1507
|
+
/** @internal */
|
|
1508
|
+
function themeColor_v0_v2(color_v0) {
|
|
1509
|
+
let cached_v2 = cache$4.get(color_v0);
|
|
1510
|
+
if (cached_v2) return cached_v2;
|
|
1511
|
+
let base = stateThemeColor_v0_v2(color_v0, color_v0.card.enabled), color_v2 = {
|
|
1512
|
+
_blend: color_v0._blend || (color_v0.dark ? "screen" : "multiply"),
|
|
1513
|
+
_dark: color_v0.dark,
|
|
1514
|
+
accent: base.accent,
|
|
1515
|
+
avatar: base.avatar,
|
|
1516
|
+
backdrop: color_v0.base.shadow.ambient,
|
|
1517
|
+
badge: base.badge,
|
|
1518
|
+
bg: color_v0.base.bg,
|
|
1519
|
+
border: color_v0.base.border,
|
|
1520
|
+
button: {
|
|
1521
|
+
default: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.default),
|
|
1522
|
+
ghost: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.ghost),
|
|
1523
|
+
bleed: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.bleed)
|
|
1524
|
+
},
|
|
1525
|
+
code: base.code,
|
|
1526
|
+
fg: color_v0.base.fg,
|
|
1527
|
+
focusRing: color_v0.base.focusRing,
|
|
1528
|
+
icon: base.muted.fg,
|
|
1529
|
+
input: {
|
|
1530
|
+
default: inputStatesThemeColor_v0_v2(color_v0.input.default),
|
|
1531
|
+
invalid: inputStatesThemeColor_v0_v2(color_v0.input.invalid)
|
|
1532
|
+
},
|
|
1533
|
+
kbd: base.kbd,
|
|
1534
|
+
link: base.link,
|
|
1535
|
+
muted: {
|
|
1536
|
+
...base.muted,
|
|
1537
|
+
bg: color_v0.selectable?.default.enabled.bg2 || color_v0.base.bg
|
|
1538
|
+
},
|
|
1539
|
+
selectable: stateTonesThemeColor_v0_v2(color_v0, color_v0.selectable || color_v0.muted),
|
|
1540
|
+
shadow: color_v0.base.shadow,
|
|
1541
|
+
skeleton: {
|
|
1542
|
+
from: color_v0.skeleton?.from || color_v0.base.border,
|
|
1543
|
+
to: color_v0.skeleton?.to || color_v0.base.border
|
|
1544
|
+
},
|
|
1545
|
+
syntax: color_v0.syntax
|
|
1546
|
+
};
|
|
1547
|
+
return cache$4.set(color_v0, color_v2), color_v2;
|
|
1548
|
+
}
|
|
1549
|
+
function stateTonesThemeColor_v0_v2(v0, t) {
|
|
1550
|
+
return {
|
|
1551
|
+
default: {
|
|
1552
|
+
enabled: stateThemeColor_v0_v2(v0, t.default.enabled),
|
|
1553
|
+
hovered: stateThemeColor_v0_v2(v0, t.default.hovered),
|
|
1554
|
+
pressed: stateThemeColor_v0_v2(v0, t.default.pressed),
|
|
1555
|
+
selected: stateThemeColor_v0_v2(v0, t.default.selected),
|
|
1556
|
+
disabled: stateThemeColor_v0_v2(v0, t.default.disabled)
|
|
1557
|
+
},
|
|
1558
|
+
neutral: {
|
|
1559
|
+
enabled: stateThemeColor_v0_v2(v0, t.default.enabled),
|
|
1560
|
+
hovered: stateThemeColor_v0_v2(v0, t.default.hovered),
|
|
1561
|
+
pressed: stateThemeColor_v0_v2(v0, t.default.pressed),
|
|
1562
|
+
selected: stateThemeColor_v0_v2(v0, t.default.selected),
|
|
1563
|
+
disabled: stateThemeColor_v0_v2(v0, t.default.disabled)
|
|
1564
|
+
},
|
|
1565
|
+
primary: {
|
|
1566
|
+
enabled: stateThemeColor_v0_v2(v0, t.primary.enabled),
|
|
1567
|
+
hovered: stateThemeColor_v0_v2(v0, t.primary.hovered),
|
|
1568
|
+
pressed: stateThemeColor_v0_v2(v0, t.primary.pressed),
|
|
1569
|
+
selected: stateThemeColor_v0_v2(v0, t.primary.selected),
|
|
1570
|
+
disabled: stateThemeColor_v0_v2(v0, t.primary.disabled)
|
|
1571
|
+
},
|
|
1572
|
+
suggest: {
|
|
1573
|
+
enabled: stateThemeColor_v0_v2(v0, t.primary.enabled),
|
|
1574
|
+
hovered: stateThemeColor_v0_v2(v0, t.primary.hovered),
|
|
1575
|
+
pressed: stateThemeColor_v0_v2(v0, t.primary.pressed),
|
|
1576
|
+
selected: stateThemeColor_v0_v2(v0, t.primary.selected),
|
|
1577
|
+
disabled: stateThemeColor_v0_v2(v0, t.primary.disabled)
|
|
1578
|
+
},
|
|
1579
|
+
positive: {
|
|
1580
|
+
enabled: stateThemeColor_v0_v2(v0, t.positive.enabled),
|
|
1581
|
+
hovered: stateThemeColor_v0_v2(v0, t.positive.hovered),
|
|
1582
|
+
pressed: stateThemeColor_v0_v2(v0, t.positive.pressed),
|
|
1583
|
+
selected: stateThemeColor_v0_v2(v0, t.positive.selected),
|
|
1584
|
+
disabled: stateThemeColor_v0_v2(v0, t.positive.disabled)
|
|
1585
|
+
},
|
|
1586
|
+
caution: {
|
|
1587
|
+
enabled: stateThemeColor_v0_v2(v0, t.caution.enabled),
|
|
1588
|
+
hovered: stateThemeColor_v0_v2(v0, t.caution.hovered),
|
|
1589
|
+
pressed: stateThemeColor_v0_v2(v0, t.caution.pressed),
|
|
1590
|
+
selected: stateThemeColor_v0_v2(v0, t.caution.selected),
|
|
1591
|
+
disabled: stateThemeColor_v0_v2(v0, t.caution.disabled)
|
|
1592
|
+
},
|
|
1593
|
+
critical: {
|
|
1594
|
+
enabled: stateThemeColor_v0_v2(v0, t.critical.enabled),
|
|
1595
|
+
hovered: stateThemeColor_v0_v2(v0, t.critical.hovered),
|
|
1596
|
+
pressed: stateThemeColor_v0_v2(v0, t.critical.pressed),
|
|
1597
|
+
selected: stateThemeColor_v0_v2(v0, t.critical.selected),
|
|
1598
|
+
disabled: stateThemeColor_v0_v2(v0, t.critical.disabled)
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
function stateThemeColor_v0_v2(v0, state) {
|
|
1603
|
+
return {
|
|
1604
|
+
...state,
|
|
1605
|
+
avatar: {
|
|
1606
|
+
gray: {
|
|
1607
|
+
bg: v0.spot.gray,
|
|
1608
|
+
fg: v0.base.bg
|
|
1609
|
+
},
|
|
1610
|
+
blue: {
|
|
1611
|
+
bg: v0.spot.blue,
|
|
1612
|
+
fg: v0.base.bg
|
|
1613
|
+
},
|
|
1614
|
+
purple: {
|
|
1615
|
+
bg: v0.spot.purple,
|
|
1616
|
+
fg: v0.base.bg
|
|
1617
|
+
},
|
|
1618
|
+
magenta: {
|
|
1619
|
+
bg: v0.spot.magenta,
|
|
1620
|
+
fg: v0.base.bg
|
|
1621
|
+
},
|
|
1622
|
+
red: {
|
|
1623
|
+
bg: v0.spot.red,
|
|
1624
|
+
fg: v0.base.bg
|
|
1625
|
+
},
|
|
1626
|
+
orange: {
|
|
1627
|
+
bg: v0.spot.orange,
|
|
1628
|
+
fg: v0.base.bg
|
|
1629
|
+
},
|
|
1630
|
+
yellow: {
|
|
1631
|
+
bg: v0.spot.yellow,
|
|
1632
|
+
fg: v0.base.bg
|
|
1633
|
+
},
|
|
1634
|
+
green: {
|
|
1635
|
+
bg: v0.spot.green,
|
|
1636
|
+
fg: v0.base.bg
|
|
1637
|
+
},
|
|
1638
|
+
cyan: {
|
|
1639
|
+
bg: v0.spot.cyan,
|
|
1640
|
+
fg: v0.base.bg
|
|
1641
|
+
}
|
|
1642
|
+
},
|
|
1643
|
+
badge: {
|
|
1644
|
+
default: {
|
|
1645
|
+
bg: v0.muted.default.enabled.bg,
|
|
1646
|
+
fg: v0.muted.default.enabled.fg,
|
|
1647
|
+
dot: v0.muted.default.enabled.muted.fg,
|
|
1648
|
+
icon: v0.muted.default.enabled.muted.fg
|
|
1649
|
+
},
|
|
1650
|
+
neutral: {
|
|
1651
|
+
bg: v0.muted.transparent.enabled.bg,
|
|
1652
|
+
fg: v0.muted.transparent.enabled.fg,
|
|
1653
|
+
dot: v0.muted.transparent.enabled.muted.fg,
|
|
1654
|
+
icon: v0.muted.transparent.enabled.muted.fg
|
|
1655
|
+
},
|
|
1656
|
+
primary: {
|
|
1657
|
+
bg: v0.muted.primary.enabled.bg,
|
|
1658
|
+
fg: v0.muted.primary.enabled.fg,
|
|
1659
|
+
dot: v0.muted.primary.enabled.muted.fg,
|
|
1660
|
+
icon: v0.muted.primary.enabled.muted.fg
|
|
1661
|
+
},
|
|
1662
|
+
suggest: {
|
|
1663
|
+
bg: v0.muted.primary.enabled.bg,
|
|
1664
|
+
fg: v0.muted.primary.enabled.fg,
|
|
1665
|
+
dot: v0.muted.primary.enabled.muted.fg,
|
|
1666
|
+
icon: v0.muted.primary.enabled.muted.fg
|
|
1667
|
+
},
|
|
1668
|
+
positive: {
|
|
1669
|
+
bg: v0.muted.positive.enabled.bg,
|
|
1670
|
+
fg: v0.muted.positive.enabled.fg,
|
|
1671
|
+
dot: v0.muted.positive.enabled.muted.fg,
|
|
1672
|
+
icon: v0.muted.positive.enabled.muted.fg
|
|
1673
|
+
},
|
|
1674
|
+
caution: {
|
|
1675
|
+
bg: v0.muted.caution.enabled.bg,
|
|
1676
|
+
fg: v0.muted.caution.enabled.fg,
|
|
1677
|
+
dot: v0.muted.caution.enabled.muted.fg,
|
|
1678
|
+
icon: v0.muted.caution.enabled.muted.fg
|
|
1679
|
+
},
|
|
1680
|
+
critical: {
|
|
1681
|
+
bg: v0.muted.critical.enabled.bg,
|
|
1682
|
+
fg: v0.muted.critical.enabled.fg,
|
|
1683
|
+
dot: v0.muted.critical.enabled.muted.fg,
|
|
1684
|
+
icon: v0.muted.critical.enabled.muted.fg
|
|
1685
|
+
}
|
|
1686
|
+
},
|
|
1687
|
+
kbd: {
|
|
1688
|
+
bg: v0.muted.default.enabled.bg,
|
|
1689
|
+
fg: v0.muted.default.enabled.fg,
|
|
1690
|
+
border: v0.muted.default.enabled.border
|
|
1691
|
+
},
|
|
1692
|
+
muted: {
|
|
1693
|
+
...v0.muted.default.enabled.muted,
|
|
1694
|
+
bg: state.bg2 || state.bg
|
|
1695
|
+
},
|
|
1696
|
+
skeleton: {
|
|
1697
|
+
from: state.skeleton?.from || state.border,
|
|
1698
|
+
to: state.skeleton?.to || state.border
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1702
|
+
function inputStatesThemeColor_v0_v2(states) {
|
|
1703
|
+
return {
|
|
1704
|
+
enabled: inputStateThemeColor_v0_v2(states.enabled),
|
|
1705
|
+
disabled: inputStateThemeColor_v0_v2(states.disabled),
|
|
1706
|
+
readOnly: inputStateThemeColor_v0_v2(states.readOnly),
|
|
1707
|
+
hovered: inputStateThemeColor_v0_v2(states.hovered)
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
function inputStateThemeColor_v0_v2(state) {
|
|
1711
|
+
return {
|
|
1712
|
+
bg: state.bg,
|
|
1713
|
+
border: state.border,
|
|
1714
|
+
fg: state.fg,
|
|
1715
|
+
muted: { bg: state.bg2 },
|
|
1716
|
+
placeholder: state.placeholder
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
const cache$3 = /* @__PURE__ */ new WeakMap();
|
|
1720
|
+
/** @public */
|
|
1721
|
+
function getTheme_v2(theme) {
|
|
1722
|
+
if (theme.sanity.v2?._resolved) return theme.sanity.v2;
|
|
1723
|
+
let cached_v2 = cache$3.get(theme);
|
|
1724
|
+
if (cached_v2) return cached_v2;
|
|
1725
|
+
let v2 = {
|
|
1726
|
+
_version: 2,
|
|
1727
|
+
_resolved: !0,
|
|
1728
|
+
avatar: {
|
|
1729
|
+
...defaultThemeConfig.avatar,
|
|
1730
|
+
...theme.sanity.avatar
|
|
1731
|
+
},
|
|
1732
|
+
button: {
|
|
1733
|
+
...defaultThemeConfig.button,
|
|
1734
|
+
...theme.sanity.button
|
|
1735
|
+
},
|
|
1736
|
+
card: defaultThemeConfig.card,
|
|
1737
|
+
color: themeColor_v0_v2(theme.sanity.color),
|
|
1738
|
+
container: theme.sanity.container,
|
|
1739
|
+
font: theme.sanity.fonts,
|
|
1740
|
+
input: {
|
|
1741
|
+
...defaultThemeConfig.input,
|
|
1742
|
+
...theme.sanity.input,
|
|
1743
|
+
checkbox: {
|
|
1744
|
+
...defaultThemeConfig.input.checkbox,
|
|
1745
|
+
...theme.sanity.input.checkbox
|
|
1746
|
+
},
|
|
1747
|
+
radio: {
|
|
1748
|
+
...defaultThemeConfig.input.radio,
|
|
1749
|
+
...theme.sanity.input.radio
|
|
1750
|
+
},
|
|
1751
|
+
switch: {
|
|
1752
|
+
...defaultThemeConfig.input.switch,
|
|
1753
|
+
...theme.sanity.input.switch
|
|
1754
|
+
}
|
|
1755
|
+
},
|
|
1756
|
+
layer: theme.sanity.layer ?? defaultThemeConfig.layer,
|
|
1757
|
+
media: theme.sanity.media,
|
|
1758
|
+
radius: theme.sanity.radius,
|
|
1759
|
+
shadow: theme.sanity.shadows,
|
|
1760
|
+
space: theme.sanity.space,
|
|
1761
|
+
style: theme.sanity.styles
|
|
1762
|
+
};
|
|
1763
|
+
return cache$3.set(theme, v2), v2;
|
|
1764
|
+
}
|
|
1765
|
+
/** @internal */
|
|
1766
|
+
function is_v0(themeProp) {
|
|
1767
|
+
return themeProp._version === 0;
|
|
1768
|
+
}
|
|
1769
|
+
/** @internal */
|
|
1770
|
+
function is_v2(themeProp) {
|
|
1771
|
+
return themeProp._version === 2;
|
|
1772
|
+
}
|
|
1773
|
+
const cache$2 = /* @__PURE__ */ new WeakMap();
|
|
1774
|
+
/** @internal */
|
|
1775
|
+
function v0_v2(v0) {
|
|
1776
|
+
if (v0.v2) return v0.v2;
|
|
1777
|
+
let cached_v2 = cache$2.get(v0);
|
|
1778
|
+
if (cached_v2) return cached_v2;
|
|
1779
|
+
let { avatar, button, color, container, focusRing: _unused_focusRing, fonts: font, input, layer, media, radius, shadows: shadow, space, styles: style } = v0, v2 = {
|
|
1780
|
+
_version: 2,
|
|
1781
|
+
avatar: {
|
|
1782
|
+
...defaultThemeConfig.avatar,
|
|
1783
|
+
...avatar
|
|
1784
|
+
},
|
|
1785
|
+
button: {
|
|
1786
|
+
...defaultThemeConfig.button,
|
|
1787
|
+
...button
|
|
1788
|
+
},
|
|
1789
|
+
card: defaultThemeConfig.card,
|
|
1790
|
+
color: {
|
|
1791
|
+
light: {
|
|
1792
|
+
transparent: themeColor_v0_v2(color.light.transparent),
|
|
1793
|
+
default: themeColor_v0_v2(color.light.default),
|
|
1794
|
+
neutral: themeColor_v0_v2(color.light.transparent),
|
|
1795
|
+
primary: themeColor_v0_v2(color.light.primary),
|
|
1796
|
+
suggest: themeColor_v0_v2(color.light.primary),
|
|
1797
|
+
positive: themeColor_v0_v2(color.light.positive),
|
|
1798
|
+
caution: themeColor_v0_v2(color.light.caution),
|
|
1799
|
+
critical: themeColor_v0_v2(color.light.critical)
|
|
1800
|
+
},
|
|
1801
|
+
dark: {
|
|
1802
|
+
transparent: themeColor_v0_v2(color.dark.transparent),
|
|
1803
|
+
default: themeColor_v0_v2(color.dark.default),
|
|
1804
|
+
neutral: themeColor_v0_v2(color.dark.transparent),
|
|
1805
|
+
primary: themeColor_v0_v2(color.dark.primary),
|
|
1806
|
+
suggest: themeColor_v0_v2(color.dark.primary),
|
|
1807
|
+
positive: themeColor_v0_v2(color.dark.positive),
|
|
1808
|
+
caution: themeColor_v0_v2(color.dark.caution),
|
|
1809
|
+
critical: themeColor_v0_v2(color.dark.critical)
|
|
1810
|
+
}
|
|
1811
|
+
},
|
|
1812
|
+
container,
|
|
1813
|
+
font,
|
|
1814
|
+
input: {
|
|
1815
|
+
...defaultThemeConfig.input,
|
|
1816
|
+
...input,
|
|
1817
|
+
checkbox: {
|
|
1818
|
+
...defaultThemeConfig.input.checkbox,
|
|
1819
|
+
...input.checkbox
|
|
1820
|
+
},
|
|
1821
|
+
radio: {
|
|
1822
|
+
...defaultThemeConfig.input.radio,
|
|
1823
|
+
...input.radio
|
|
1824
|
+
},
|
|
1825
|
+
switch: {
|
|
1826
|
+
...defaultThemeConfig.input.switch,
|
|
1827
|
+
...input.switch
|
|
1828
|
+
}
|
|
1829
|
+
},
|
|
1830
|
+
layer: layer ?? defaultThemeConfig.layer,
|
|
1831
|
+
media,
|
|
1832
|
+
radius,
|
|
1833
|
+
shadow,
|
|
1834
|
+
space,
|
|
1835
|
+
style
|
|
1836
|
+
};
|
|
1837
|
+
return cache$2.set(v0, v2), v2;
|
|
1838
|
+
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Defines a lazy, self-replacing property on `obj`.
|
|
1841
|
+
*
|
|
1842
|
+
* On first access the `factory` is called and the getter is replaced with the
|
|
1843
|
+
* computed plain value — subsequent reads have zero overhead.
|
|
1844
|
+
*
|
|
1845
|
+
* The property is enumerable (visible in `Object.keys` / spread) in both states.
|
|
1846
|
+
*
|
|
1847
|
+
* @internal
|
|
1848
|
+
*/
|
|
1849
|
+
function defineLazyProperty(obj, key, factory) {
|
|
1850
|
+
Object.defineProperty(obj, key, {
|
|
1851
|
+
get() {
|
|
1852
|
+
let value = factory();
|
|
1853
|
+
return Object.defineProperty(obj, key, {
|
|
1854
|
+
value,
|
|
1855
|
+
enumerable: !0,
|
|
1856
|
+
writable: !1,
|
|
1857
|
+
configurable: !1
|
|
1858
|
+
}), value;
|
|
1859
|
+
},
|
|
1860
|
+
enumerable: !0,
|
|
1861
|
+
configurable: !0
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
const cache$1 = /* @__PURE__ */ new WeakMap(), V0_TONES = [
|
|
1865
|
+
"transparent",
|
|
1866
|
+
"default",
|
|
1867
|
+
"primary",
|
|
1868
|
+
"positive",
|
|
1869
|
+
"caution",
|
|
1870
|
+
"critical"
|
|
1871
|
+
];
|
|
1872
|
+
function lazyV0Scheme(schemeKey, color) {
|
|
1873
|
+
let scheme = {};
|
|
1874
|
+
for (let tone of V0_TONES) defineLazyProperty(scheme, tone, () => themeColor_v2_v0(color[schemeKey][tone]));
|
|
1875
|
+
return scheme;
|
|
1876
|
+
}
|
|
1877
|
+
/** @internal */
|
|
1878
|
+
function v2_v0(v2) {
|
|
1879
|
+
let cachedTheme = cache$1.get(v2);
|
|
1880
|
+
if (cachedTheme) return cachedTheme;
|
|
1881
|
+
let { avatar, button, color, container, font: fonts, input, media, radius, shadow: shadows, space, style: styles } = v2, v0Color = {};
|
|
1882
|
+
defineLazyProperty(v0Color, "light", () => lazyV0Scheme("light", color)), defineLazyProperty(v0Color, "dark", () => lazyV0Scheme("dark", color));
|
|
1883
|
+
let theme = {
|
|
1884
|
+
_version: 0,
|
|
1885
|
+
avatar,
|
|
1886
|
+
button,
|
|
1887
|
+
container,
|
|
1888
|
+
color: v0Color,
|
|
1889
|
+
focusRing: input.text.focusRing,
|
|
1890
|
+
fonts,
|
|
1891
|
+
input,
|
|
1892
|
+
media,
|
|
1893
|
+
radius,
|
|
1894
|
+
shadows,
|
|
1895
|
+
space,
|
|
1896
|
+
styles,
|
|
1897
|
+
v2
|
|
1898
|
+
};
|
|
1899
|
+
return cache$1.set(v2, theme), theme;
|
|
1900
|
+
}
|
|
1901
|
+
function themeColor_v2_v0(color_v2) {
|
|
1902
|
+
return {
|
|
1903
|
+
base: {
|
|
1904
|
+
bg: color_v2.bg,
|
|
1905
|
+
fg: color_v2.fg,
|
|
1906
|
+
border: color_v2.border,
|
|
1907
|
+
focusRing: color_v2.focusRing,
|
|
1908
|
+
shadow: color_v2.shadow
|
|
1909
|
+
},
|
|
1910
|
+
button: color_v2.button,
|
|
1911
|
+
card: color_v2.selectable.default,
|
|
1912
|
+
dark: color_v2._dark,
|
|
1913
|
+
input: {
|
|
1914
|
+
default: inputStatesThemeColor_v2_v0(color_v2.input.default),
|
|
1915
|
+
invalid: inputStatesThemeColor_v2_v0(color_v2.input.invalid)
|
|
1916
|
+
},
|
|
1917
|
+
muted: {
|
|
1918
|
+
...color_v2.button.ghost,
|
|
1919
|
+
transparent: color_v2.button.ghost.default
|
|
1920
|
+
},
|
|
1921
|
+
solid: {
|
|
1922
|
+
...color_v2.button.default,
|
|
1923
|
+
transparent: color_v2.button.default.default
|
|
1924
|
+
},
|
|
1925
|
+
selectable: color_v2.selectable,
|
|
1926
|
+
spot: {
|
|
1927
|
+
gray: color_v2.avatar.gray.bg,
|
|
1928
|
+
blue: color_v2.avatar.blue.bg,
|
|
1929
|
+
purple: color_v2.avatar.purple.bg,
|
|
1930
|
+
magenta: color_v2.avatar.magenta.bg,
|
|
1931
|
+
red: color_v2.avatar.red.bg,
|
|
1932
|
+
orange: color_v2.avatar.orange.bg,
|
|
1933
|
+
yellow: color_v2.avatar.yellow.bg,
|
|
1934
|
+
green: color_v2.avatar.green.bg,
|
|
1935
|
+
cyan: color_v2.avatar.cyan.bg
|
|
1936
|
+
},
|
|
1937
|
+
syntax: color_v2.syntax
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
function inputStatesThemeColor_v2_v0(t) {
|
|
1941
|
+
return {
|
|
1942
|
+
enabled: inputStateThemeColor_v2_v0(t.enabled),
|
|
1943
|
+
disabled: inputStateThemeColor_v2_v0(t.disabled),
|
|
1944
|
+
readOnly: inputStateThemeColor_v2_v0(t.readOnly),
|
|
1945
|
+
hovered: inputStateThemeColor_v2_v0(t.hovered)
|
|
1946
|
+
};
|
|
1947
|
+
}
|
|
1948
|
+
function inputStateThemeColor_v2_v0(t) {
|
|
1949
|
+
return {
|
|
1950
|
+
bg: t.bg,
|
|
1951
|
+
bg2: t.muted.bg,
|
|
1952
|
+
border: t.border,
|
|
1953
|
+
fg: t.fg,
|
|
1954
|
+
placeholder: t.placeholder
|
|
1955
|
+
};
|
|
1956
|
+
}
|
|
1957
|
+
/** @public */
|
|
1958
|
+
const THEME_COLOR_SCHEMES = ["light", "dark"], THEME_COLOR_BLEND_MODES = ["multiply", "screen"], THEME_COLOR_CARD_TONES = [
|
|
1959
|
+
"transparent",
|
|
1960
|
+
"default",
|
|
1961
|
+
"neutral",
|
|
1962
|
+
"primary",
|
|
1963
|
+
"suggest",
|
|
1964
|
+
"positive",
|
|
1965
|
+
"caution",
|
|
1966
|
+
"critical"
|
|
1967
|
+
], THEME_COLOR_STATE_TONES = [
|
|
1968
|
+
"default",
|
|
1969
|
+
"neutral",
|
|
1970
|
+
"primary",
|
|
1971
|
+
"suggest",
|
|
1972
|
+
"positive",
|
|
1973
|
+
"caution",
|
|
1974
|
+
"critical"
|
|
1975
|
+
], THEME_COLOR_STATES = [
|
|
1976
|
+
"enabled",
|
|
1977
|
+
"hovered",
|
|
1978
|
+
"pressed",
|
|
1979
|
+
"selected",
|
|
1980
|
+
"disabled"
|
|
1981
|
+
], THEME_COLOR_BUTTON_MODES = [
|
|
1982
|
+
"default",
|
|
1983
|
+
"ghost",
|
|
1984
|
+
"bleed"
|
|
1985
|
+
], THEME_COLOR_INPUT_MODES = ["default", "invalid"], THEME_COLOR_INPUT_STATES = [
|
|
1986
|
+
"enabled",
|
|
1987
|
+
"hovered",
|
|
1988
|
+
"readOnly",
|
|
1989
|
+
"disabled"
|
|
1990
|
+
], THEME_COLOR_AVATAR_COLORS = _sanity_color.COLOR_HUES;
|
|
1991
|
+
/** @internal */
|
|
1992
|
+
function isColorBlendModeValue(str) {
|
|
1993
|
+
return THEME_COLOR_BLEND_MODES.includes(str);
|
|
1994
|
+
}
|
|
1995
|
+
/** @internal */
|
|
1996
|
+
function isColorHueKey(str) {
|
|
1997
|
+
return _sanity_color.COLOR_HUES.includes(str);
|
|
1998
|
+
}
|
|
1999
|
+
/** @internal */
|
|
2000
|
+
function isColorTintKey(str) {
|
|
2001
|
+
return _sanity_color.COLOR_TINTS.includes(str);
|
|
2002
|
+
}
|
|
2003
|
+
/** @internal */
|
|
2004
|
+
function isColorButtonMode(str) {
|
|
2005
|
+
return THEME_COLOR_BUTTON_MODES.includes(str);
|
|
2006
|
+
}
|
|
2007
|
+
/** @public */
|
|
2008
|
+
const COLOR_CONFIG_STATE_KEYS = [
|
|
2009
|
+
"_hue",
|
|
2010
|
+
"bg",
|
|
2011
|
+
"fg",
|
|
2012
|
+
"border",
|
|
2013
|
+
"focusRing",
|
|
2014
|
+
"muted/fg",
|
|
2015
|
+
"accent/fg",
|
|
2016
|
+
"link/fg",
|
|
2017
|
+
"code/bg",
|
|
2018
|
+
"code/fg",
|
|
2019
|
+
"skeleton/from",
|
|
2020
|
+
"skeleton/to",
|
|
2021
|
+
"status/dot",
|
|
2022
|
+
"status/icon"
|
|
2023
|
+
], COLOR_CONFIG_CARD_KEYS = [
|
|
2024
|
+
...COLOR_CONFIG_STATE_KEYS,
|
|
2025
|
+
"_hue",
|
|
2026
|
+
"bg",
|
|
2027
|
+
"fg",
|
|
2028
|
+
"border",
|
|
2029
|
+
"focusRing",
|
|
2030
|
+
"shadow/outline",
|
|
2031
|
+
"shadow/umbra",
|
|
2032
|
+
"shadow/penumbra",
|
|
2033
|
+
"shadow/ambient"
|
|
2034
|
+
], COLOR_CONFIG_BLEND_KEYS = ["_blend"], COLOR_CONFIG_AVATAR_COLORS = ["*", ...THEME_COLOR_AVATAR_COLORS], COLOR_CONFIG_CARD_TONES = ["*", ...THEME_COLOR_CARD_TONES], COLOR_CONFIG_STATE_TONES = ["*", ...THEME_COLOR_STATE_TONES], COLOR_CONFIG_STATES = ["*", ...THEME_COLOR_STATES], COLOR_CONFIG_INPUT_MODES = ["*", ...THEME_COLOR_INPUT_MODES], COLOR_CONFIG_INPUT_STATES = ["*", ...THEME_COLOR_INPUT_STATES];
|
|
2035
|
+
/** @internal */
|
|
2036
|
+
function parseTokenKey(str) {
|
|
2037
|
+
let segments = str.split("/"), segment0 = segments.shift() || "";
|
|
2038
|
+
if (isColorConfigBaseTone(segment0)) {
|
|
2039
|
+
let key = segments.join("/");
|
|
2040
|
+
if (isColorConfigBaseKey(key) || isColorConfigBlendKey(key)) return {
|
|
2041
|
+
type: "base",
|
|
2042
|
+
tone: segment0,
|
|
2043
|
+
key
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
2046
|
+
if (segment0 === "button") {
|
|
2047
|
+
let segment1 = segments.shift() || "";
|
|
2048
|
+
if (isColorConfigStateTone(segment1)) {
|
|
2049
|
+
let segment2 = segments.shift() || "";
|
|
2050
|
+
if (isColorButtonMode(segment2)) {
|
|
2051
|
+
let key = segments.join("/");
|
|
2052
|
+
if (isColorConfigStateKey(key) || isColorConfigBlendKey(key)) return {
|
|
2053
|
+
type: "button",
|
|
2054
|
+
tone: segment1,
|
|
2055
|
+
mode: segment2,
|
|
2056
|
+
key
|
|
2057
|
+
};
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
function isColorMixPercentValue(str) {
|
|
2063
|
+
return /^\d+%$/.test(str);
|
|
2064
|
+
}
|
|
2065
|
+
/** @internal */
|
|
2066
|
+
function parseTokenValue(str) {
|
|
2067
|
+
let segments = str.split("/"), nextSegment = segments.shift() || "", [segment0, segment0mix] = nextSegment.split(" ");
|
|
2068
|
+
if (isColorTintKey(segment0)) {
|
|
2069
|
+
let tint = segment0, segment1 = segments.shift() || "";
|
|
2070
|
+
return isColorMixPercentValue(segment0mix) ? {
|
|
2071
|
+
type: "color",
|
|
2072
|
+
tint,
|
|
2073
|
+
mix: Number(segment0mix.slice(0, -1)) / 100
|
|
2074
|
+
} : isColorOpacityValue(segment1) ? {
|
|
2075
|
+
type: "color",
|
|
2076
|
+
tint,
|
|
2077
|
+
opacity: Number(segment1)
|
|
2078
|
+
} : {
|
|
2079
|
+
type: "color",
|
|
2080
|
+
tint
|
|
2081
|
+
};
|
|
2082
|
+
}
|
|
2083
|
+
if (isColorValue(segment0)) {
|
|
2084
|
+
let key = segment0, segment1 = segments.shift() || "";
|
|
2085
|
+
return isColorMixPercentValue(segment0mix) ? {
|
|
2086
|
+
type: "color",
|
|
2087
|
+
key,
|
|
2088
|
+
mix: Number(segment0mix.slice(0, -1)) / 100
|
|
2089
|
+
} : isColorOpacityValue(segment1) ? {
|
|
2090
|
+
type: "color",
|
|
2091
|
+
key,
|
|
2092
|
+
opacity: Number(segment1)
|
|
2093
|
+
} : {
|
|
2094
|
+
type: "color",
|
|
2095
|
+
key
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
if (isColorHueKey(segment0)) {
|
|
2099
|
+
let hue = segment0;
|
|
2100
|
+
nextSegment = segments.shift() || "";
|
|
2101
|
+
let [segment1, segment1mix] = nextSegment.split(" ");
|
|
2102
|
+
if (isColorTintKey(segment1)) {
|
|
2103
|
+
let tint = segment1, segment2 = segments.shift() || "";
|
|
2104
|
+
return isColorMixPercentValue(segment1mix) ? {
|
|
2105
|
+
type: "color",
|
|
2106
|
+
hue,
|
|
2107
|
+
tint,
|
|
2108
|
+
mix: Number(segment1mix.slice(0, -1)) / 100
|
|
2109
|
+
} : isColorOpacityValue(segment2) ? {
|
|
2110
|
+
type: "color",
|
|
2111
|
+
hue,
|
|
2112
|
+
tint,
|
|
2113
|
+
opacity: Number(segment2)
|
|
2114
|
+
} : {
|
|
2115
|
+
type: "color",
|
|
2116
|
+
hue,
|
|
2117
|
+
tint
|
|
2118
|
+
};
|
|
2119
|
+
}
|
|
2120
|
+
return {
|
|
2121
|
+
type: "hue",
|
|
2122
|
+
value: hue
|
|
2123
|
+
};
|
|
2124
|
+
}
|
|
2125
|
+
if (isColorBlendModeValue(segment0)) return {
|
|
2126
|
+
type: "blendMode",
|
|
2127
|
+
value: segment0
|
|
2128
|
+
};
|
|
2129
|
+
}
|
|
2130
|
+
/** @internal */
|
|
2131
|
+
function isColorConfigBaseTone(str) {
|
|
2132
|
+
return COLOR_CONFIG_CARD_TONES.includes(str);
|
|
2133
|
+
}
|
|
2134
|
+
/** @internal */
|
|
2135
|
+
function isColorConfigBaseKey(str) {
|
|
2136
|
+
return COLOR_CONFIG_CARD_KEYS.includes(str);
|
|
2137
|
+
}
|
|
2138
|
+
/** @internal */
|
|
2139
|
+
function isColorConfigStateKey(str) {
|
|
2140
|
+
return COLOR_CONFIG_STATE_KEYS.includes(str);
|
|
2141
|
+
}
|
|
2142
|
+
/** @internal */
|
|
2143
|
+
function isColorConfigStateTone(str) {
|
|
2144
|
+
return COLOR_CONFIG_STATE_TONES.includes(str);
|
|
2145
|
+
}
|
|
2146
|
+
/** @internal */
|
|
2147
|
+
function isColorConfigBlendKey(str) {
|
|
2148
|
+
return COLOR_CONFIG_BLEND_KEYS.includes(str);
|
|
2149
|
+
}
|
|
2150
|
+
/** @internal */
|
|
2151
|
+
function isColorTokenValue(str) {
|
|
2152
|
+
return parseTokenValue(str)?.type === "color" || parseTokenValue(str)?.type === "hue";
|
|
2153
|
+
}
|
|
2154
|
+
/** @internal */
|
|
2155
|
+
function isColorValue(str) {
|
|
2156
|
+
return str === "black" || str === "white";
|
|
2157
|
+
}
|
|
2158
|
+
/** @internal */
|
|
2159
|
+
function isColorOpacityValue(str) {
|
|
2160
|
+
return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
|
|
2161
|
+
}
|
|
2162
|
+
function compileColorTokenValue(node) {
|
|
2163
|
+
let key = "";
|
|
2164
|
+
return key = node.key === "black" || node.key === "white" ? node.key : `${node.hue}/${node.tint}`, node.mix === void 0 ? (node.opacity !== void 0 && (key += `/${node.opacity}`), key) : `${key} ${node.mix * 100}%`;
|
|
2165
|
+
}
|
|
2166
|
+
const DEFAULT_COLOR_TOKEN_VALUE = ["500", "500"];
|
|
2167
|
+
function resolveColorTokenValue(context, value = DEFAULT_COLOR_TOKEN_VALUE) {
|
|
2168
|
+
let { hue, scheme } = context, node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
|
|
2169
|
+
if (!node || node.type !== "color") throw Error(`Invalid color token: ${value[0]}`);
|
|
2170
|
+
return compileColorTokenValue({
|
|
2171
|
+
...node,
|
|
2172
|
+
hue: node.hue || hue
|
|
2173
|
+
});
|
|
2174
|
+
}
|
|
2175
|
+
const defaultColorTokens = {
|
|
2176
|
+
base: {
|
|
2177
|
+
"*": {
|
|
2178
|
+
_blend: ["multiply", "screen"],
|
|
2179
|
+
accent: { fg: ["purple/600", "purple/400"] },
|
|
2180
|
+
avatar: { "*": {
|
|
2181
|
+
_blend: ["screen", "multiply"],
|
|
2182
|
+
bg: ["500", "400"],
|
|
2183
|
+
fg: ["white", "black"]
|
|
2184
|
+
} },
|
|
2185
|
+
backdrop: ["gray/200/0.5", "black/0.5"],
|
|
2186
|
+
badge: {
|
|
2187
|
+
"*": {
|
|
2188
|
+
bg: ["100", "900"],
|
|
2189
|
+
fg: ["600", "400"],
|
|
2190
|
+
icon: ["500", "500"],
|
|
2191
|
+
dot: ["500", "500"]
|
|
2192
|
+
},
|
|
2193
|
+
positive: {
|
|
2194
|
+
bg: ["200 50%", "900"],
|
|
2195
|
+
fg: ["600", "500"]
|
|
2196
|
+
},
|
|
2197
|
+
caution: {
|
|
2198
|
+
bg: ["200 50%", "900"],
|
|
2199
|
+
fg: ["600", "500"]
|
|
2200
|
+
}
|
|
2201
|
+
},
|
|
2202
|
+
bg: ["50", "950"],
|
|
2203
|
+
border: ["200", "800"],
|
|
2204
|
+
code: {
|
|
2205
|
+
bg: ["50", "950"],
|
|
2206
|
+
fg: ["600", "400"]
|
|
2207
|
+
},
|
|
2208
|
+
fg: ["800", "200"],
|
|
2209
|
+
focusRing: ["blue/500", "blue/500"],
|
|
2210
|
+
icon: ["600", "400"],
|
|
2211
|
+
kbd: {
|
|
2212
|
+
bg: ["white", "black"],
|
|
2213
|
+
fg: ["600", "400"],
|
|
2214
|
+
border: ["200", "800"]
|
|
2215
|
+
},
|
|
2216
|
+
link: { fg: ["blue/600", "blue/300"] },
|
|
2217
|
+
muted: {
|
|
2218
|
+
bg: ["50", "950"],
|
|
2219
|
+
fg: ["700 75%", "300 75%"]
|
|
2220
|
+
},
|
|
2221
|
+
shadow: {
|
|
2222
|
+
outline: ["500/0.3", "500/0.4"],
|
|
2223
|
+
umbra: ["gray/500/0.1", "black/0.2"],
|
|
2224
|
+
penumbra: ["gray/500/0.07", "black/0.14"],
|
|
2225
|
+
ambient: ["gray/500/0.06", "black/0.12"]
|
|
2226
|
+
},
|
|
2227
|
+
skeleton: {
|
|
2228
|
+
from: ["100", "900"],
|
|
2229
|
+
to: ["100 50%", "900 50%"]
|
|
2230
|
+
}
|
|
2231
|
+
},
|
|
2232
|
+
transparent: { bg: ["50", "black"] },
|
|
2233
|
+
default: {
|
|
2234
|
+
bg: ["white", "950"],
|
|
2235
|
+
fg: ["800", "200"],
|
|
2236
|
+
muted: { fg: ["600", "400"] }
|
|
2237
|
+
},
|
|
2238
|
+
primary: { _hue: "blue" },
|
|
2239
|
+
suggest: { _hue: "purple" },
|
|
2240
|
+
positive: {
|
|
2241
|
+
_hue: "green",
|
|
2242
|
+
shadow: { outline: ["500/0.4", "500/0.4"] }
|
|
2243
|
+
},
|
|
2244
|
+
caution: {
|
|
2245
|
+
_hue: "yellow",
|
|
2246
|
+
shadow: { outline: ["600/0.3", "500/0.4"] }
|
|
2247
|
+
},
|
|
2248
|
+
critical: { _hue: "red" }
|
|
2249
|
+
},
|
|
2250
|
+
button: {
|
|
2251
|
+
default: {
|
|
2252
|
+
"*": {
|
|
2253
|
+
"*": {
|
|
2254
|
+
_blend: ["screen", "multiply"],
|
|
2255
|
+
accent: { fg: ["purple/300", "purple/700"] },
|
|
2256
|
+
avatar: { "*": {
|
|
2257
|
+
_blend: ["screen", "multiply"],
|
|
2258
|
+
bg: ["500", "400"],
|
|
2259
|
+
fg: ["white", "black"]
|
|
2260
|
+
} },
|
|
2261
|
+
badge: { "*": {
|
|
2262
|
+
bg: ["900", "100"],
|
|
2263
|
+
fg: ["400", "600"],
|
|
2264
|
+
dot: ["500", "500"],
|
|
2265
|
+
icon: ["500", "500"]
|
|
2266
|
+
} },
|
|
2267
|
+
bg: ["500", "400"],
|
|
2268
|
+
border: ["500/0", "400/0"],
|
|
2269
|
+
code: {
|
|
2270
|
+
bg: ["500 20%", "400 20%"],
|
|
2271
|
+
fg: ["200", "600"]
|
|
2272
|
+
},
|
|
2273
|
+
fg: ["white", "black"],
|
|
2274
|
+
icon: ["100 70%", "900 70%"],
|
|
2275
|
+
kbd: {
|
|
2276
|
+
bg: ["black", "white"],
|
|
2277
|
+
fg: ["200", "600"],
|
|
2278
|
+
border: ["800", "200"]
|
|
2279
|
+
},
|
|
2280
|
+
link: { fg: ["blue/200", "blue/600"] },
|
|
2281
|
+
muted: {
|
|
2282
|
+
bg: ["950", "50"],
|
|
2283
|
+
fg: ["100 70%", "900 70%"]
|
|
2284
|
+
},
|
|
2285
|
+
skeleton: {
|
|
2286
|
+
from: ["900", "100"],
|
|
2287
|
+
to: ["900 50%", "100 50%"]
|
|
2288
|
+
}
|
|
2289
|
+
},
|
|
2290
|
+
hovered: {
|
|
2291
|
+
bg: ["600", "300"],
|
|
2292
|
+
border: ["700/0", "300/0"]
|
|
2293
|
+
},
|
|
2294
|
+
pressed: { bg: ["700", "300"] },
|
|
2295
|
+
selected: { bg: ["700", "300"] },
|
|
2296
|
+
disabled: {
|
|
2297
|
+
_hue: "gray",
|
|
2298
|
+
accent: { fg: ["100 70%", "900 70%"] },
|
|
2299
|
+
avatar: { "*": {
|
|
2300
|
+
_blend: ["screen", "multiply"],
|
|
2301
|
+
bg: ["gray/500", "gray/400"],
|
|
2302
|
+
fg: ["white", "black"]
|
|
2303
|
+
} },
|
|
2304
|
+
badge: { "*": {
|
|
2305
|
+
bg: ["gray/700", "gray/300"],
|
|
2306
|
+
fg: ["white", "black"],
|
|
2307
|
+
dot: ["white", "black"],
|
|
2308
|
+
icon: ["white", "black"]
|
|
2309
|
+
} },
|
|
2310
|
+
bg: ["300", "600"],
|
|
2311
|
+
code: {
|
|
2312
|
+
bg: ["950", "50"],
|
|
2313
|
+
fg: ["300", "600"]
|
|
2314
|
+
},
|
|
2315
|
+
fg: ["300", "600"],
|
|
2316
|
+
muted: {
|
|
2317
|
+
bg: ["950", "50"],
|
|
2318
|
+
fg: ["300", "600"]
|
|
2319
|
+
},
|
|
2320
|
+
kbd: {
|
|
2321
|
+
bg: ["black", "white"],
|
|
2322
|
+
fg: ["white", "black"],
|
|
2323
|
+
border: ["700", "300"]
|
|
2324
|
+
},
|
|
2325
|
+
link: { fg: ["100 70%", "900 70%"] }
|
|
2326
|
+
}
|
|
2327
|
+
},
|
|
2328
|
+
default: {
|
|
2329
|
+
"*": {
|
|
2330
|
+
avatar: { "*": {
|
|
2331
|
+
_blend: ["screen", "multiply"],
|
|
2332
|
+
bg: ["500", "400"],
|
|
2333
|
+
fg: ["white", "black"]
|
|
2334
|
+
} },
|
|
2335
|
+
bg: ["800", "200"],
|
|
2336
|
+
muted: {
|
|
2337
|
+
bg: ["950", "50"],
|
|
2338
|
+
fg: ["400", "600"]
|
|
2339
|
+
}
|
|
2340
|
+
},
|
|
2341
|
+
hovered: { bg: ["900", "100"] },
|
|
2342
|
+
pressed: { bg: ["black", "white"] },
|
|
2343
|
+
selected: { bg: ["black", "white"] }
|
|
2344
|
+
}
|
|
2345
|
+
},
|
|
2346
|
+
ghost: {
|
|
2347
|
+
"*": {
|
|
2348
|
+
"*": {
|
|
2349
|
+
_blend: ["multiply", "screen"],
|
|
2350
|
+
accent: { fg: ["purple/700 60%", "purple/300 70%"] },
|
|
2351
|
+
avatar: { "*": {
|
|
2352
|
+
_blend: ["screen", "multiply"],
|
|
2353
|
+
bg: ["500", "400"],
|
|
2354
|
+
fg: ["white", "black"]
|
|
2355
|
+
} },
|
|
2356
|
+
badge: { "*": {
|
|
2357
|
+
bg: ["100", "900"],
|
|
2358
|
+
fg: ["600", "400"],
|
|
2359
|
+
dot: ["500", "500"],
|
|
2360
|
+
icon: ["500", "500"]
|
|
2361
|
+
} },
|
|
2362
|
+
bg: ["50", "950"],
|
|
2363
|
+
border: ["100", "900"],
|
|
2364
|
+
code: {
|
|
2365
|
+
bg: ["500 10%", "400 10%"],
|
|
2366
|
+
fg: ["700 60%", "400 60%"]
|
|
2367
|
+
},
|
|
2368
|
+
fg: ["600", "400"],
|
|
2369
|
+
icon: ["700 60%", "300 60%"],
|
|
2370
|
+
kbd: {
|
|
2371
|
+
bg: ["white", "black"],
|
|
2372
|
+
fg: ["600", "400"],
|
|
2373
|
+
border: ["200", "800"]
|
|
2374
|
+
},
|
|
2375
|
+
link: { fg: ["blue/700 60%", "blue/300 60%"] },
|
|
2376
|
+
muted: {
|
|
2377
|
+
bg: ["100", "950"],
|
|
2378
|
+
fg: ["700 60%", "300 60%"]
|
|
2379
|
+
},
|
|
2380
|
+
skeleton: {
|
|
2381
|
+
from: ["100", "900"],
|
|
2382
|
+
to: ["100 50%", "900 50%"]
|
|
2383
|
+
}
|
|
2384
|
+
},
|
|
2385
|
+
hovered: {
|
|
2386
|
+
bg: ["100", "900"],
|
|
2387
|
+
fg: ["700", "300"]
|
|
2388
|
+
},
|
|
2389
|
+
pressed: {
|
|
2390
|
+
bg: ["200", "800"],
|
|
2391
|
+
fg: ["800", "200"]
|
|
2392
|
+
},
|
|
2393
|
+
selected: {
|
|
2394
|
+
bg: ["200", "800"],
|
|
2395
|
+
fg: ["800", "200"]
|
|
2396
|
+
},
|
|
2397
|
+
disabled: {
|
|
2398
|
+
_hue: "gray",
|
|
2399
|
+
accent: { fg: ["200", "800"] },
|
|
2400
|
+
avatar: { "*": {
|
|
2401
|
+
_blend: ["screen", "multiply"],
|
|
2402
|
+
bg: ["gray/100", "gray/900"],
|
|
2403
|
+
fg: ["white", "black"]
|
|
2404
|
+
} },
|
|
2405
|
+
badge: { "*": {
|
|
2406
|
+
_hue: "gray",
|
|
2407
|
+
bg: ["50", "950"],
|
|
2408
|
+
fg: ["gray/200", "gray/800"],
|
|
2409
|
+
dot: ["gray/200", "gray/800"],
|
|
2410
|
+
icon: ["gray/200", "gray/800"]
|
|
2411
|
+
} },
|
|
2412
|
+
border: ["100", "900"],
|
|
2413
|
+
code: {
|
|
2414
|
+
bg: ["50", "950"],
|
|
2415
|
+
fg: ["200", "800"]
|
|
2416
|
+
},
|
|
2417
|
+
fg: ["400", "600"],
|
|
2418
|
+
icon: ["300", "700"],
|
|
2419
|
+
muted: { fg: ["300", "700"] },
|
|
2420
|
+
kbd: {
|
|
2421
|
+
bg: ["white", "black"],
|
|
2422
|
+
fg: ["200", "800"],
|
|
2423
|
+
border: ["100", "900"]
|
|
2424
|
+
},
|
|
2425
|
+
link: { fg: ["200", "800"] }
|
|
2426
|
+
}
|
|
2427
|
+
},
|
|
2428
|
+
positive: { "*": { border: ["600 20%", "800"] } },
|
|
2429
|
+
caution: { "*": { border: ["600 20%", "800"] } }
|
|
2430
|
+
},
|
|
2431
|
+
bleed: { "*": {
|
|
2432
|
+
"*": {
|
|
2433
|
+
_blend: ["multiply", "screen"],
|
|
2434
|
+
accent: { fg: ["purple/700 70%", "purple/300 70%"] },
|
|
2435
|
+
avatar: { "*": {
|
|
2436
|
+
_blend: ["screen", "multiply"],
|
|
2437
|
+
bg: ["500", "400"],
|
|
2438
|
+
fg: ["white", "black"]
|
|
2439
|
+
} },
|
|
2440
|
+
badge: { "*": {
|
|
2441
|
+
bg: ["100", "900"],
|
|
2442
|
+
fg: ["600", "400"],
|
|
2443
|
+
dot: ["500", "500"],
|
|
2444
|
+
icon: ["500", "500"]
|
|
2445
|
+
} },
|
|
2446
|
+
bg: ["white", "black"],
|
|
2447
|
+
border: ["white/0", "black/0"],
|
|
2448
|
+
code: {
|
|
2449
|
+
bg: ["50", "950"],
|
|
2450
|
+
fg: ["700 75%", "300 75%"]
|
|
2451
|
+
},
|
|
2452
|
+
fg: ["700", "300"],
|
|
2453
|
+
icon: ["700 75%", "300 75%"],
|
|
2454
|
+
kbd: {
|
|
2455
|
+
bg: ["white", "black"],
|
|
2456
|
+
fg: ["700", "300"],
|
|
2457
|
+
border: ["200", "800"]
|
|
2458
|
+
},
|
|
2459
|
+
link: { fg: ["blue/700 70%", "blue/300 70%"] },
|
|
2460
|
+
muted: {
|
|
2461
|
+
bg: ["100", "950"],
|
|
2462
|
+
fg: ["700 75%", "300 75%"]
|
|
2463
|
+
},
|
|
2464
|
+
skeleton: {
|
|
2465
|
+
from: ["100", "900"],
|
|
2466
|
+
to: ["100 50%", "900 50%"]
|
|
2467
|
+
}
|
|
2468
|
+
},
|
|
2469
|
+
hovered: {
|
|
2470
|
+
bg: ["50", "900"],
|
|
2471
|
+
fg: ["800", "200"],
|
|
2472
|
+
icon: ["800 70%", "300 70%"]
|
|
2473
|
+
},
|
|
2474
|
+
pressed: {
|
|
2475
|
+
bg: ["100", "800"],
|
|
2476
|
+
fg: ["800", "200"],
|
|
2477
|
+
icon: ["800 70%", "200 70%"]
|
|
2478
|
+
},
|
|
2479
|
+
selected: {
|
|
2480
|
+
bg: ["100", "900"],
|
|
2481
|
+
fg: ["800", "200"],
|
|
2482
|
+
icon: ["800 60%", "200 60%"]
|
|
2483
|
+
},
|
|
2484
|
+
disabled: {
|
|
2485
|
+
_hue: "gray",
|
|
2486
|
+
accent: { fg: ["200", "800"] },
|
|
2487
|
+
avatar: { "*": {
|
|
2488
|
+
_blend: ["screen", "multiply"],
|
|
2489
|
+
bg: ["gray/100", "gray/900"],
|
|
2490
|
+
fg: ["white", "black"]
|
|
2491
|
+
} },
|
|
2492
|
+
badge: { "*": {
|
|
2493
|
+
_hue: "gray",
|
|
2494
|
+
bg: ["50", "950"],
|
|
2495
|
+
fg: ["gray/200", "gray/800"],
|
|
2496
|
+
dot: ["gray/200", "gray/800"],
|
|
2497
|
+
icon: ["gray/200", "gray/800"]
|
|
2498
|
+
} },
|
|
2499
|
+
code: {
|
|
2500
|
+
bg: ["50", "950"],
|
|
2501
|
+
fg: ["200", "800"]
|
|
2502
|
+
},
|
|
2503
|
+
fg: ["400", "600"],
|
|
2504
|
+
icon: ["300", "700"],
|
|
2505
|
+
muted: { fg: ["400", "600"] },
|
|
2506
|
+
kbd: {
|
|
2507
|
+
bg: ["white", "black"],
|
|
2508
|
+
fg: ["200", "800"],
|
|
2509
|
+
border: ["100", "900"]
|
|
2510
|
+
},
|
|
2511
|
+
link: { fg: ["200", "800"] }
|
|
2512
|
+
}
|
|
2513
|
+
} }
|
|
2514
|
+
},
|
|
2515
|
+
input: {
|
|
2516
|
+
"*": {
|
|
2517
|
+
"*": {
|
|
2518
|
+
_blend: ["multiply", "screen"],
|
|
2519
|
+
bg: ["white", "black"],
|
|
2520
|
+
border: ["200", "700"],
|
|
2521
|
+
fg: ["black", "200"],
|
|
2522
|
+
muted: { bg: ["50", "950"] },
|
|
2523
|
+
placeholder: ["400", "600"]
|
|
2524
|
+
},
|
|
2525
|
+
hovered: { border: ["300", "700"] },
|
|
2526
|
+
readOnly: {
|
|
2527
|
+
bg: ["50", "950"],
|
|
2528
|
+
border: ["200", "800"],
|
|
2529
|
+
fg: ["800", "200"]
|
|
2530
|
+
},
|
|
2531
|
+
disabled: {
|
|
2532
|
+
bg: ["50", "950"],
|
|
2533
|
+
fg: ["400", "600"],
|
|
2534
|
+
border: ["100", "900"],
|
|
2535
|
+
placeholder: ["200", "800 50%"]
|
|
2536
|
+
}
|
|
2537
|
+
},
|
|
2538
|
+
invalid: { "*": {
|
|
2539
|
+
_hue: "red",
|
|
2540
|
+
bg: ["100", "950"]
|
|
2541
|
+
} }
|
|
2542
|
+
},
|
|
2543
|
+
selectable: {
|
|
2544
|
+
"*": {
|
|
2545
|
+
"*": {
|
|
2546
|
+
_blend: ["multiply", "screen"],
|
|
2547
|
+
accent: { fg: ["purple/700 70%", "purple/300 70%"] },
|
|
2548
|
+
avatar: { "*": {
|
|
2549
|
+
_blend: ["screen", "multiply"],
|
|
2550
|
+
bg: ["500", "400"],
|
|
2551
|
+
fg: ["white", "black"]
|
|
2552
|
+
} },
|
|
2553
|
+
badge: { "*": {
|
|
2554
|
+
bg: ["100", "900"],
|
|
2555
|
+
fg: ["600", "400"],
|
|
2556
|
+
dot: ["500", "500"],
|
|
2557
|
+
icon: ["500", "500"]
|
|
2558
|
+
} },
|
|
2559
|
+
bg: ["white", "black"],
|
|
2560
|
+
border: ["200", "800"],
|
|
2561
|
+
code: {
|
|
2562
|
+
bg: ["50", "950"],
|
|
2563
|
+
fg: ["600", "400"]
|
|
2564
|
+
},
|
|
2565
|
+
fg: ["700", "300"],
|
|
2566
|
+
icon: ["700 75%", "300 75%"],
|
|
2567
|
+
kbd: {
|
|
2568
|
+
bg: ["white", "black"],
|
|
2569
|
+
fg: ["600", "400"],
|
|
2570
|
+
border: ["200", "800"]
|
|
2571
|
+
},
|
|
2572
|
+
link: { fg: ["blue/700 70%", "blue/300 70%"] },
|
|
2573
|
+
muted: {
|
|
2574
|
+
bg: ["50", "950"],
|
|
2575
|
+
fg: ["700 75%", "300 75%"]
|
|
2576
|
+
},
|
|
2577
|
+
skeleton: {
|
|
2578
|
+
from: ["100", "900"],
|
|
2579
|
+
to: ["100 50%", "900 50%"]
|
|
2580
|
+
}
|
|
2581
|
+
},
|
|
2582
|
+
hovered: { bg: ["50", "950"] },
|
|
2583
|
+
pressed: { bg: ["100", "900"] },
|
|
2584
|
+
selected: {
|
|
2585
|
+
_blend: ["screen", "multiply"],
|
|
2586
|
+
accent: { fg: ["purple/300", "purple/700"] },
|
|
2587
|
+
avatar: { "*": {
|
|
2588
|
+
_blend: ["multiply", "screen"],
|
|
2589
|
+
bg: ["white", "black"],
|
|
2590
|
+
fg: ["black", "white"]
|
|
2591
|
+
} },
|
|
2592
|
+
badge: { "*": {
|
|
2593
|
+
bg: ["900", "100"],
|
|
2594
|
+
fg: ["400", "600"],
|
|
2595
|
+
dot: ["500", "500"],
|
|
2596
|
+
icon: ["500", "500"]
|
|
2597
|
+
} },
|
|
2598
|
+
bg: ["500", "400"],
|
|
2599
|
+
border: ["500 20%", "400 20%"],
|
|
2600
|
+
code: {
|
|
2601
|
+
bg: ["500 20%", "400 20%"],
|
|
2602
|
+
fg: ["200", "600"]
|
|
2603
|
+
},
|
|
2604
|
+
fg: ["white", "black"],
|
|
2605
|
+
icon: ["100 70%", "900 70%"],
|
|
2606
|
+
kbd: {
|
|
2607
|
+
bg: ["black", "white"],
|
|
2608
|
+
fg: ["200", "600"],
|
|
2609
|
+
border: ["800", "200"]
|
|
2610
|
+
},
|
|
2611
|
+
link: { fg: ["blue/200", "blue/600"] },
|
|
2612
|
+
muted: {
|
|
2613
|
+
bg: ["500 10%", "400 10%"],
|
|
2614
|
+
fg: ["100 70%", "900 70%"]
|
|
2615
|
+
},
|
|
2616
|
+
skeleton: {
|
|
2617
|
+
from: ["900", "100"],
|
|
2618
|
+
to: ["900 50%", "100 50%"]
|
|
2619
|
+
}
|
|
2620
|
+
},
|
|
2621
|
+
disabled: {
|
|
2622
|
+
_hue: "gray",
|
|
2623
|
+
accent: { fg: ["200", "800"] },
|
|
2624
|
+
avatar: { "*": {
|
|
2625
|
+
_blend: ["screen", "multiply"],
|
|
2626
|
+
bg: ["gray/100", "gray/900"],
|
|
2627
|
+
fg: ["white", "black"]
|
|
2628
|
+
} },
|
|
2629
|
+
badge: { "*": {
|
|
2630
|
+
_hue: "gray",
|
|
2631
|
+
bg: ["50", "950"],
|
|
2632
|
+
fg: ["gray/200", "gray/800"],
|
|
2633
|
+
dot: ["gray/200", "gray/800"],
|
|
2634
|
+
icon: ["gray/200", "gray/800"]
|
|
2635
|
+
} },
|
|
2636
|
+
border: ["100", "900"],
|
|
2637
|
+
code: {
|
|
2638
|
+
bg: ["50", "950"],
|
|
2639
|
+
fg: ["200", "800"]
|
|
2640
|
+
},
|
|
2641
|
+
fg: ["200", "800"],
|
|
2642
|
+
icon: ["200", "800"],
|
|
2643
|
+
kbd: {
|
|
2644
|
+
bg: ["white", "black"],
|
|
2645
|
+
fg: ["200", "800"],
|
|
2646
|
+
border: ["100", "900"]
|
|
2647
|
+
},
|
|
2648
|
+
link: { fg: ["200", "800"] },
|
|
2649
|
+
muted: {
|
|
2650
|
+
bg: ["50 50%", "950 50%"],
|
|
2651
|
+
fg: ["200", "800"]
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
},
|
|
2655
|
+
default: { selected: { _hue: "blue" } },
|
|
2656
|
+
critical: { disabled: { bg: ["50 50%", "950 50%"] } }
|
|
2657
|
+
},
|
|
2658
|
+
syntax: {
|
|
2659
|
+
atrule: ["purple/600", "purple/400"],
|
|
2660
|
+
attrName: ["green/600", "green/400"],
|
|
2661
|
+
attrValue: ["yellow/600", "yellow/400"],
|
|
2662
|
+
attribute: ["yellow/600", "yellow/400"],
|
|
2663
|
+
boolean: ["purple/600", "purple/400"],
|
|
2664
|
+
builtin: ["purple/600", "purple/400"],
|
|
2665
|
+
cdata: ["yellow/600", "yellow/400"],
|
|
2666
|
+
char: ["yellow/600", "yellow/400"],
|
|
2667
|
+
class: ["orange/600", "orange/400"],
|
|
2668
|
+
className: ["cyan/600", "cyan/400"],
|
|
2669
|
+
comment: ["gray/400", "gray/600"],
|
|
2670
|
+
constant: ["purple/600", "purple/400"],
|
|
2671
|
+
deleted: ["red/600", "red/400"],
|
|
2672
|
+
entity: ["red/600", "red/400"],
|
|
2673
|
+
function: ["green/600", "green/400"],
|
|
2674
|
+
hexcode: ["blue/600", "blue/400"],
|
|
2675
|
+
id: ["purple/600", "purple/400"],
|
|
2676
|
+
important: ["purple/600", "purple/400"],
|
|
2677
|
+
inserted: ["yellow/600", "yellow/400"],
|
|
2678
|
+
keyword: ["magenta/600", "magenta/400"],
|
|
2679
|
+
number: ["purple/600", "purple/400"],
|
|
2680
|
+
operator: ["magenta/600", "magenta/400"],
|
|
2681
|
+
property: ["blue/600", "blue/400"],
|
|
2682
|
+
pseudoClass: ["yellow/600", "yellow/400"],
|
|
2683
|
+
pseudoElement: ["yellow/600", "yellow/400"],
|
|
2684
|
+
punctuation: ["gray/600", "gray/400"],
|
|
2685
|
+
regex: ["blue/600", "blue/400"],
|
|
2686
|
+
selector: ["red/600", "red/400"],
|
|
2687
|
+
string: ["yellow/600", "yellow/400"],
|
|
2688
|
+
symbol: ["purple/600", "purple/400"],
|
|
2689
|
+
tag: ["red/600", "red/400"],
|
|
2690
|
+
unit: ["orange/600", "orange/400"],
|
|
2691
|
+
url: ["red/600", "red/400"],
|
|
2692
|
+
variable: ["red/600", "red/400"]
|
|
2693
|
+
}
|
|
2694
|
+
};
|
|
2695
|
+
function isRecord(value) {
|
|
2696
|
+
return !!(value && typeof value == "object" && !Array.isArray(value));
|
|
2697
|
+
}
|
|
2698
|
+
function merge(...records) {
|
|
2699
|
+
let _records = records.filter(Boolean);
|
|
2700
|
+
return _records.length === 0 ? {} : _records.reduce(_merge, {});
|
|
2701
|
+
}
|
|
2702
|
+
function _merge(acc, source) {
|
|
2703
|
+
for (let key of Object.keys(source)) {
|
|
2704
|
+
let prevValue = acc[key], nextValue = source[key];
|
|
2705
|
+
isRecord(prevValue) && isRecord(nextValue) ? acc[key] = merge(prevValue, nextValue) : acc[key] = nextValue;
|
|
2706
|
+
}
|
|
2707
|
+
return acc;
|
|
2708
|
+
}
|
|
2709
|
+
/**
|
|
2710
|
+
* Convert a tree of color tokens from a sparse format to a dense format.
|
|
2711
|
+
*/
|
|
2712
|
+
function resolveColorTokens(inputTokens) {
|
|
2713
|
+
let tokens = merge(defaultColorTokens, inputTokens);
|
|
2714
|
+
return {
|
|
2715
|
+
base: resolveBaseColorTokens(tokens),
|
|
2716
|
+
button: resolveButtonColorTokens(tokens),
|
|
2717
|
+
input: resolveInputColorTokens(tokens),
|
|
2718
|
+
selectable: resolveSelectableColorTokens(tokens),
|
|
2719
|
+
syntax: tokens.syntax
|
|
2720
|
+
};
|
|
2721
|
+
}
|
|
2722
|
+
function resolveBaseColorTokens(sparseTokens) {
|
|
2723
|
+
let tokens = {};
|
|
2724
|
+
for (let tone of THEME_COLOR_CARD_TONES) tokens[tone] = resolveBaseColorTones(sparseTokens, tone);
|
|
2725
|
+
return tokens;
|
|
2726
|
+
}
|
|
2727
|
+
function resolveBaseColorTones(inputTokens, tone) {
|
|
2728
|
+
let spec = merge(inputTokens?.base?.["*"], inputTokens?.base?.[tone]), hue = spec._hue || inputTokens?.base?.[tone]?._hue || "gray";
|
|
2729
|
+
return {
|
|
2730
|
+
...spec,
|
|
2731
|
+
_hue: hue,
|
|
2732
|
+
avatar: _sanity_color.COLOR_HUES.reduce((acc, hue) => ({
|
|
2733
|
+
...acc,
|
|
2734
|
+
[hue]: merge({ _hue: hue }, spec.avatar?.["*"], spec.avatar?.[hue])
|
|
2735
|
+
}), {}),
|
|
2736
|
+
badge: THEME_COLOR_STATE_TONES.reduce((acc, tone) => ({
|
|
2737
|
+
...acc,
|
|
2738
|
+
[tone]: {
|
|
2739
|
+
_hue: inputTokens?.base?.[tone]?._hue || hue,
|
|
2740
|
+
...spec.badge?.["*"],
|
|
2741
|
+
...spec.badge?.[tone]
|
|
2742
|
+
}
|
|
2743
|
+
}), {})
|
|
2744
|
+
};
|
|
2745
|
+
}
|
|
2746
|
+
function resolveButtonColorTokens(inputTokens) {
|
|
2747
|
+
let tokens = {};
|
|
2748
|
+
for (let mode of THEME_COLOR_BUTTON_MODES) tokens[mode] = resolveButtonToneColorTokens(inputTokens, mode);
|
|
2749
|
+
return tokens;
|
|
2750
|
+
}
|
|
2751
|
+
function resolveButtonToneColorTokens(inputTokens, mode) {
|
|
2752
|
+
let tokens = {};
|
|
2753
|
+
for (let tone of THEME_COLOR_STATE_TONES) tokens[tone] = resolveButtonModeColorTokens(inputTokens, mode, tone);
|
|
2754
|
+
return tokens;
|
|
2755
|
+
}
|
|
2756
|
+
function resolveButtonModeColorTokens(inputTokens, mode, tone) {
|
|
2757
|
+
let tokens = {};
|
|
2758
|
+
for (let state of THEME_COLOR_STATES) tokens[state] = resolveButtonStateColorTokens(inputTokens, tone, mode, state);
|
|
2759
|
+
return tokens;
|
|
2760
|
+
}
|
|
2761
|
+
function resolveButtonStateColorTokens(inputTokens, tone, mode, state) {
|
|
2762
|
+
let spec = merge(inputTokens?.button?.[mode]?.["*"]?.["*"], inputTokens?.button?.[mode]?.[tone]?.["*"], inputTokens?.button?.[mode]?.["*"]?.[state], inputTokens?.button?.[mode]?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
|
|
2763
|
+
return {
|
|
2764
|
+
...spec,
|
|
2765
|
+
_hue: hue,
|
|
2766
|
+
avatar: _sanity_color.COLOR_HUES.reduce((acc, hue) => ({
|
|
2767
|
+
...acc,
|
|
2768
|
+
[hue]: merge({ _hue: hue }, spec.avatar?.["*"], spec.avatar?.[hue])
|
|
2769
|
+
}), {}),
|
|
2770
|
+
badge: THEME_COLOR_STATE_TONES.reduce((acc, tone) => ({
|
|
2771
|
+
...acc,
|
|
2772
|
+
[tone]: {
|
|
2773
|
+
_hue: inputTokens?.base?.[tone]?._hue || hue,
|
|
2774
|
+
...spec.badge?.["*"],
|
|
2775
|
+
...spec.badge?.[tone]
|
|
2776
|
+
}
|
|
2777
|
+
}), {})
|
|
2778
|
+
};
|
|
2779
|
+
}
|
|
2780
|
+
function resolveInputColorTokens(inputTokens) {
|
|
2781
|
+
let tokens = {};
|
|
2782
|
+
for (let mode of THEME_COLOR_INPUT_MODES) tokens[mode] = resolveInputModeColorTokens(inputTokens, mode);
|
|
2783
|
+
return tokens;
|
|
2784
|
+
}
|
|
2785
|
+
function resolveInputModeColorTokens(inputTokens, mode) {
|
|
2786
|
+
let states = {};
|
|
2787
|
+
for (let state of THEME_COLOR_INPUT_STATES) states[state] = resolveInputStateColorTokens(inputTokens, mode, state);
|
|
2788
|
+
return states;
|
|
2789
|
+
}
|
|
2790
|
+
function resolveInputStateColorTokens(inputTokens, mode, state) {
|
|
2791
|
+
let spec = merge(inputTokens?.input?.["*"]?.["*"], inputTokens?.input?.[mode]?.["*"], inputTokens?.input?.["*"]?.[state], inputTokens?.input?.[mode]?.[state]), hue = spec._hue || inputTokens?.input?.[mode]?._hue;
|
|
2792
|
+
return {
|
|
2793
|
+
...spec,
|
|
2794
|
+
_hue: hue
|
|
2795
|
+
};
|
|
2796
|
+
}
|
|
2797
|
+
function resolveSelectableColorTokens(inputTokens) {
|
|
2798
|
+
let tokens = {};
|
|
2799
|
+
for (let tone of THEME_COLOR_STATE_TONES) tokens[tone] = resolveSelectableToneColorTokens(inputTokens, tone);
|
|
2800
|
+
return tokens;
|
|
2801
|
+
}
|
|
2802
|
+
function resolveSelectableToneColorTokens(inputTokens, tone) {
|
|
2803
|
+
let states = { _hue: inputTokens?.selectable?.[tone]?._hue || inputTokens?.base?.[tone]?._hue };
|
|
2804
|
+
for (let state of THEME_COLOR_STATES) states[state] = resolveSelectableStateColorTokens(inputTokens, tone, state);
|
|
2805
|
+
return states;
|
|
2806
|
+
}
|
|
2807
|
+
function resolveSelectableStateColorTokens(inputTokens, tone, state) {
|
|
2808
|
+
let spec = merge(inputTokens?.selectable?.["*"]?.["*"], inputTokens?.selectable?.[tone]?.["*"], inputTokens?.selectable?.["*"]?.[state], inputTokens?.selectable?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
|
|
2809
|
+
return {
|
|
2810
|
+
...spec,
|
|
2811
|
+
_hue: hue,
|
|
2812
|
+
avatar: _sanity_color.COLOR_HUES.reduce((acc, hue) => ({
|
|
2813
|
+
...acc,
|
|
2814
|
+
[hue]: merge({ _hue: hue }, spec.avatar?.["*"], spec.avatar?.[hue])
|
|
2815
|
+
}), {}),
|
|
2816
|
+
badge: THEME_COLOR_STATE_TONES.reduce((acc, tone) => ({
|
|
2817
|
+
...acc,
|
|
2818
|
+
[tone]: {
|
|
2819
|
+
_hue: inputTokens?.base?.[tone]?._hue || hue,
|
|
2820
|
+
...spec.badge?.["*"],
|
|
2821
|
+
...spec.badge?.[tone]
|
|
2822
|
+
}
|
|
2823
|
+
}), {})
|
|
2824
|
+
};
|
|
2825
|
+
}
|
|
2826
|
+
function buildColorTheme(config) {
|
|
2827
|
+
let resolvedConfig = {
|
|
2828
|
+
...config,
|
|
2829
|
+
color: resolveColorTokens(config?.color)
|
|
2830
|
+
}, schemes = {};
|
|
2831
|
+
return defineLazyProperty(schemes, "light", () => buildColorScheme({ scheme: "light" }, resolvedConfig)), defineLazyProperty(schemes, "dark", () => buildColorScheme({ scheme: "dark" }, resolvedConfig)), schemes;
|
|
2832
|
+
}
|
|
2833
|
+
function buildColorScheme(options, config) {
|
|
2834
|
+
let { scheme } = options, colorScheme = {};
|
|
2835
|
+
for (let tone of THEME_COLOR_CARD_TONES) defineLazyProperty(colorScheme, tone, () => buildCardColorTheme({
|
|
2836
|
+
scheme,
|
|
2837
|
+
tone
|
|
2838
|
+
}, config));
|
|
2839
|
+
return colorScheme;
|
|
2840
|
+
}
|
|
2841
|
+
function buildCardColorTheme(options, config) {
|
|
2842
|
+
let { scheme, tone } = options, tokens = config?.color?.base?.[tone], context = {
|
|
2843
|
+
hue: tokens?._hue || "gray",
|
|
2844
|
+
scheme
|
|
2845
|
+
};
|
|
2846
|
+
return {
|
|
2847
|
+
_blend: (tokens?._blend || ["multiply", "screen"])[scheme === "light" ? 0 : 1],
|
|
2848
|
+
_dark: scheme === "dark",
|
|
2849
|
+
accent: { fg: resolveColorTokenValue(context, tokens?.accent?.fg) },
|
|
2850
|
+
avatar: buildAvatarColorTheme({ scheme }, tokens),
|
|
2851
|
+
backdrop: resolveColorTokenValue(context, tokens?.backdrop),
|
|
2852
|
+
badge: buildBadgeColorTheme(tokens?.badge, { scheme }, config),
|
|
2853
|
+
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
2854
|
+
border: resolveColorTokenValue(context, tokens?.border),
|
|
2855
|
+
button: buildButtonColorTheme({
|
|
2856
|
+
scheme,
|
|
2857
|
+
tone
|
|
2858
|
+
}, config),
|
|
2859
|
+
code: {
|
|
2860
|
+
bg: resolveColorTokenValue(context, tokens?.code?.bg),
|
|
2861
|
+
fg: resolveColorTokenValue(context, tokens?.code?.fg)
|
|
2862
|
+
},
|
|
2863
|
+
fg: resolveColorTokenValue(context, tokens?.fg),
|
|
2864
|
+
focusRing: resolveColorTokenValue(context, tokens?.focusRing),
|
|
2865
|
+
icon: resolveColorTokenValue(context, tokens?.icon),
|
|
2866
|
+
input: buildInputColorTheme({
|
|
2867
|
+
scheme,
|
|
2868
|
+
tone
|
|
2869
|
+
}, config),
|
|
2870
|
+
kbd: {
|
|
2871
|
+
bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
|
|
2872
|
+
fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
|
|
2873
|
+
border: resolveColorTokenValue(context, tokens?.kbd?.border)
|
|
2874
|
+
},
|
|
2875
|
+
link: { fg: resolveColorTokenValue(context, tokens?.link?.fg) },
|
|
2876
|
+
muted: {
|
|
2877
|
+
bg: resolveColorTokenValue(context, tokens?.muted?.bg),
|
|
2878
|
+
fg: resolveColorTokenValue(context, tokens?.muted?.fg)
|
|
2879
|
+
},
|
|
2880
|
+
selectable: buildSelectableColorTheme({
|
|
2881
|
+
scheme,
|
|
2882
|
+
tone
|
|
2883
|
+
}, config),
|
|
2884
|
+
shadow: buildShadowColorTheme({
|
|
2885
|
+
scheme,
|
|
2886
|
+
tone
|
|
2887
|
+
}, config),
|
|
2888
|
+
skeleton: {
|
|
2889
|
+
from: resolveColorTokenValue(context, tokens?.skeleton?.from),
|
|
2890
|
+
to: resolveColorTokenValue(context, tokens?.skeleton?.to)
|
|
2891
|
+
},
|
|
2892
|
+
syntax: buildSyntaxColorTheme({ scheme }, config)
|
|
2893
|
+
};
|
|
2894
|
+
}
|
|
2895
|
+
function buildShadowColorTheme(options, config) {
|
|
2896
|
+
let { scheme, tone } = options, tokens = config?.color?.base?.[tone], context = {
|
|
2897
|
+
hue: tokens?._hue || "gray",
|
|
2898
|
+
scheme
|
|
2899
|
+
};
|
|
2900
|
+
return {
|
|
2901
|
+
outline: resolveColorTokenValue(context, tokens?.shadow?.outline),
|
|
2902
|
+
umbra: resolveColorTokenValue(context, tokens?.shadow?.umbra),
|
|
2903
|
+
penumbra: resolveColorTokenValue(context, tokens?.shadow?.penumbra),
|
|
2904
|
+
ambient: resolveColorTokenValue(context, tokens?.shadow?.ambient)
|
|
2905
|
+
};
|
|
2906
|
+
}
|
|
2907
|
+
function buildAvatarColorTheme(options, stateTokens) {
|
|
2908
|
+
let { scheme } = options;
|
|
2909
|
+
return {
|
|
2910
|
+
gray: _buildAvatarColorTheme({
|
|
2911
|
+
color: "gray",
|
|
2912
|
+
scheme
|
|
2913
|
+
}, stateTokens),
|
|
2914
|
+
blue: _buildAvatarColorTheme({
|
|
2915
|
+
color: "blue",
|
|
2916
|
+
scheme
|
|
2917
|
+
}, stateTokens),
|
|
2918
|
+
purple: _buildAvatarColorTheme({
|
|
2919
|
+
color: "purple",
|
|
2920
|
+
scheme
|
|
2921
|
+
}, stateTokens),
|
|
2922
|
+
magenta: _buildAvatarColorTheme({
|
|
2923
|
+
color: "magenta",
|
|
2924
|
+
scheme
|
|
2925
|
+
}, stateTokens),
|
|
2926
|
+
red: _buildAvatarColorTheme({
|
|
2927
|
+
color: "red",
|
|
2928
|
+
scheme
|
|
2929
|
+
}, stateTokens),
|
|
2930
|
+
orange: _buildAvatarColorTheme({
|
|
2931
|
+
color: "orange",
|
|
2932
|
+
scheme
|
|
2933
|
+
}, stateTokens),
|
|
2934
|
+
yellow: _buildAvatarColorTheme({
|
|
2935
|
+
color: "yellow",
|
|
2936
|
+
scheme
|
|
2937
|
+
}, stateTokens),
|
|
2938
|
+
green: _buildAvatarColorTheme({
|
|
2939
|
+
color: "green",
|
|
2940
|
+
scheme
|
|
2941
|
+
}, stateTokens),
|
|
2942
|
+
cyan: _buildAvatarColorTheme({
|
|
2943
|
+
color: "cyan",
|
|
2944
|
+
scheme
|
|
2945
|
+
}, stateTokens)
|
|
2946
|
+
};
|
|
2947
|
+
}
|
|
2948
|
+
function _buildAvatarColorTheme(options, stateTokens) {
|
|
2949
|
+
let { color, scheme } = options, tokens = stateTokens?.avatar?.[color], context = {
|
|
2950
|
+
hue: tokens?._hue || "gray",
|
|
2951
|
+
scheme
|
|
2952
|
+
};
|
|
2953
|
+
return {
|
|
2954
|
+
_blend: (tokens?._blend || ["screen", "multiply"])[scheme === "light" ? 0 : 1],
|
|
2955
|
+
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
2956
|
+
fg: resolveColorTokenValue(context, tokens?.fg)
|
|
2957
|
+
};
|
|
2958
|
+
}
|
|
2959
|
+
function buildBadgeColorTheme(tokens, options, config) {
|
|
2960
|
+
let { scheme } = options, colorBadge = {};
|
|
2961
|
+
for (let tone of THEME_COLOR_STATE_TONES) colorBadge[tone] = _buildBadgeColorTheme(tokens, {
|
|
2962
|
+
scheme,
|
|
2963
|
+
tone
|
|
2964
|
+
}, config);
|
|
2965
|
+
return colorBadge;
|
|
2966
|
+
}
|
|
2967
|
+
function _buildBadgeColorTheme(parentTokens, options, config) {
|
|
2968
|
+
let { scheme, tone } = options, tokens = parentTokens?.[tone], context = {
|
|
2969
|
+
hue: tokens?._hue || config?.color?.base?.[tone]?._hue || "gray",
|
|
2970
|
+
scheme
|
|
2971
|
+
};
|
|
2972
|
+
return {
|
|
2973
|
+
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
2974
|
+
fg: resolveColorTokenValue(context, tokens?.fg),
|
|
2975
|
+
dot: resolveColorTokenValue(context, tokens?.dot),
|
|
2976
|
+
icon: resolveColorTokenValue(context, tokens?.icon)
|
|
2977
|
+
};
|
|
2978
|
+
}
|
|
2979
|
+
function buildButtonColorTheme(options, config) {
|
|
2980
|
+
let { scheme, tone: cardTone } = options, modes = {};
|
|
2981
|
+
for (let mode of THEME_COLOR_BUTTON_MODES) modes[mode] = buildButtonTonesColorTheme({
|
|
2982
|
+
cardTone,
|
|
2983
|
+
scheme,
|
|
2984
|
+
mode
|
|
2985
|
+
}, config);
|
|
2986
|
+
return modes;
|
|
2987
|
+
}
|
|
2988
|
+
function buildButtonTonesColorTheme(options, config) {
|
|
2989
|
+
let { cardTone, mode, scheme } = options, tones = {};
|
|
2990
|
+
for (let tone of THEME_COLOR_STATE_TONES) tones[tone] = buildButtonStatesColorTheme({
|
|
2991
|
+
cardTone,
|
|
2992
|
+
mode,
|
|
2993
|
+
scheme,
|
|
2994
|
+
tone
|
|
2995
|
+
}, config);
|
|
2996
|
+
return tones;
|
|
2997
|
+
}
|
|
2998
|
+
function buildButtonStatesColorTheme(options, config) {
|
|
2999
|
+
let { cardTone, mode, scheme, tone } = options, states = {};
|
|
3000
|
+
for (let state of THEME_COLOR_STATES) states[state] = buildButtonStateColorTheme({
|
|
3001
|
+
cardTone,
|
|
3002
|
+
mode,
|
|
3003
|
+
tone,
|
|
3004
|
+
scheme,
|
|
3005
|
+
state
|
|
3006
|
+
}, config);
|
|
3007
|
+
return states;
|
|
3008
|
+
}
|
|
3009
|
+
function buildButtonStateColorTheme(options, config) {
|
|
3010
|
+
let { cardTone, mode, tone, scheme, state } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.button?.[mode]?.[tone]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
|
|
3011
|
+
hue,
|
|
3012
|
+
scheme
|
|
3013
|
+
};
|
|
3014
|
+
return {
|
|
3015
|
+
_blend: blendMode[scheme === "light" ? 0 : 1],
|
|
3016
|
+
accent: { fg: resolveColorTokenValue(context, tokens?.accent?.fg) },
|
|
3017
|
+
avatar: buildAvatarColorTheme({ scheme }, tokens),
|
|
3018
|
+
badge: buildBadgeColorTheme(tokens?.badge, { scheme }, config),
|
|
3019
|
+
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
3020
|
+
border: resolveColorTokenValue(context, tokens?.border),
|
|
3021
|
+
code: {
|
|
3022
|
+
bg: resolveColorTokenValue(context, tokens?.code?.bg),
|
|
3023
|
+
fg: resolveColorTokenValue(context, tokens?.code?.fg)
|
|
3024
|
+
},
|
|
3025
|
+
fg: resolveColorTokenValue(context, tokens?.fg),
|
|
3026
|
+
icon: resolveColorTokenValue(context, tokens?.icon),
|
|
3027
|
+
muted: {
|
|
3028
|
+
bg: resolveColorTokenValue(context, tokens?.muted?.bg),
|
|
3029
|
+
fg: resolveColorTokenValue(context, tokens?.muted?.fg)
|
|
3030
|
+
},
|
|
3031
|
+
kbd: {
|
|
3032
|
+
bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
|
|
3033
|
+
fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
|
|
3034
|
+
border: resolveColorTokenValue(context, tokens?.kbd?.border)
|
|
3035
|
+
},
|
|
3036
|
+
link: { fg: resolveColorTokenValue(context, tokens?.link?.fg) },
|
|
3037
|
+
skeleton: {
|
|
3038
|
+
from: resolveColorTokenValue(context, tokens?.skeleton?.from),
|
|
3039
|
+
to: resolveColorTokenValue(context, tokens?.skeleton?.to)
|
|
3040
|
+
}
|
|
3041
|
+
};
|
|
3042
|
+
}
|
|
3043
|
+
function buildInputColorTheme(options, config) {
|
|
3044
|
+
let { scheme, tone } = options;
|
|
3045
|
+
return {
|
|
3046
|
+
default: buildInputStatesColorTheme({
|
|
3047
|
+
mode: "default",
|
|
3048
|
+
scheme,
|
|
3049
|
+
tone
|
|
3050
|
+
}, config),
|
|
3051
|
+
invalid: buildInputStatesColorTheme({
|
|
3052
|
+
mode: "invalid",
|
|
3053
|
+
scheme,
|
|
3054
|
+
tone
|
|
3055
|
+
}, config)
|
|
3056
|
+
};
|
|
3057
|
+
}
|
|
3058
|
+
function buildInputStatesColorTheme(options, config) {
|
|
3059
|
+
let { mode, scheme, tone } = options;
|
|
3060
|
+
return {
|
|
3061
|
+
enabled: buildInputStateColorTheme({
|
|
3062
|
+
mode,
|
|
3063
|
+
scheme,
|
|
3064
|
+
state: "enabled",
|
|
3065
|
+
cardTone: tone
|
|
3066
|
+
}, config),
|
|
3067
|
+
hovered: buildInputStateColorTheme({
|
|
3068
|
+
mode,
|
|
3069
|
+
scheme,
|
|
3070
|
+
state: "hovered",
|
|
3071
|
+
cardTone: tone
|
|
3072
|
+
}, config),
|
|
3073
|
+
readOnly: buildInputStateColorTheme({
|
|
3074
|
+
mode,
|
|
3075
|
+
scheme,
|
|
3076
|
+
state: "readOnly",
|
|
3077
|
+
cardTone: tone
|
|
3078
|
+
}, config),
|
|
3079
|
+
disabled: buildInputStateColorTheme({
|
|
3080
|
+
mode,
|
|
3081
|
+
scheme,
|
|
3082
|
+
state: "disabled",
|
|
3083
|
+
cardTone: tone
|
|
3084
|
+
}, config)
|
|
3085
|
+
};
|
|
3086
|
+
}
|
|
3087
|
+
function buildInputStateColorTheme(options, config) {
|
|
3088
|
+
let { cardTone, mode, scheme, state } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.input?.[mode]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
|
|
3089
|
+
hue,
|
|
3090
|
+
scheme
|
|
3091
|
+
};
|
|
3092
|
+
return {
|
|
3093
|
+
_blend: blendMode[scheme === "light" ? 0 : 1],
|
|
3094
|
+
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
3095
|
+
border: resolveColorTokenValue(context, tokens?.border),
|
|
3096
|
+
fg: resolveColorTokenValue(context, tokens?.fg),
|
|
3097
|
+
muted: { bg: resolveColorTokenValue(context, tokens?.muted?.bg) },
|
|
3098
|
+
placeholder: resolveColorTokenValue(context, tokens?.placeholder)
|
|
3099
|
+
};
|
|
3100
|
+
}
|
|
3101
|
+
function buildSelectableColorTheme(options, config) {
|
|
3102
|
+
let { scheme, tone: cardTone } = options, tones = {};
|
|
3103
|
+
for (let tone of THEME_COLOR_STATE_TONES) tones[tone] = buildSelectableStatesColorTheme({
|
|
3104
|
+
cardTone,
|
|
3105
|
+
scheme,
|
|
3106
|
+
tone
|
|
3107
|
+
}, config);
|
|
3108
|
+
return tones;
|
|
3109
|
+
}
|
|
3110
|
+
function buildSelectableStatesColorTheme(options, config) {
|
|
3111
|
+
let { cardTone, scheme, tone } = options, states = {};
|
|
3112
|
+
for (let state of THEME_COLOR_STATES) states[state] = buildSelectableStateColorTheme({
|
|
3113
|
+
cardTone,
|
|
3114
|
+
tone,
|
|
3115
|
+
scheme,
|
|
3116
|
+
state
|
|
3117
|
+
}, config);
|
|
3118
|
+
return states;
|
|
3119
|
+
}
|
|
3120
|
+
function buildSelectableStateColorTheme(options, config) {
|
|
3121
|
+
let { cardTone, scheme, state, tone } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.selectable?.[tone]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
|
|
3122
|
+
hue,
|
|
3123
|
+
scheme
|
|
3124
|
+
};
|
|
3125
|
+
return {
|
|
3126
|
+
_blend: blendMode[scheme === "light" ? 0 : 1],
|
|
3127
|
+
accent: { fg: resolveColorTokenValue(context, tokens?.accent?.fg) },
|
|
3128
|
+
avatar: buildAvatarColorTheme({ scheme }, tokens),
|
|
3129
|
+
badge: buildBadgeColorTheme(tokens?.badge, { scheme }, config),
|
|
3130
|
+
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
3131
|
+
border: resolveColorTokenValue(context, tokens?.border),
|
|
3132
|
+
code: {
|
|
3133
|
+
bg: resolveColorTokenValue(context, tokens?.code?.bg),
|
|
3134
|
+
fg: resolveColorTokenValue(context, tokens?.code?.fg)
|
|
3135
|
+
},
|
|
3136
|
+
fg: resolveColorTokenValue(context, tokens?.fg),
|
|
3137
|
+
icon: resolveColorTokenValue(context, tokens?.icon),
|
|
3138
|
+
muted: {
|
|
3139
|
+
bg: resolveColorTokenValue(context, tokens?.muted?.bg),
|
|
3140
|
+
fg: resolveColorTokenValue(context, tokens?.muted?.fg)
|
|
3141
|
+
},
|
|
3142
|
+
kbd: {
|
|
3143
|
+
bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
|
|
3144
|
+
fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
|
|
3145
|
+
border: resolveColorTokenValue(context, tokens?.kbd?.border)
|
|
3146
|
+
},
|
|
3147
|
+
link: { fg: resolveColorTokenValue(context, tokens?.link?.fg) },
|
|
3148
|
+
skeleton: {
|
|
3149
|
+
from: resolveColorTokenValue(context, tokens?.skeleton?.from),
|
|
3150
|
+
to: resolveColorTokenValue(context, tokens?.skeleton?.to)
|
|
3151
|
+
}
|
|
3152
|
+
};
|
|
3153
|
+
}
|
|
3154
|
+
function buildSyntaxColorTheme(options, config) {
|
|
3155
|
+
let { scheme } = options, tokens = config?.color?.syntax, context = {
|
|
3156
|
+
hue: "gray",
|
|
3157
|
+
scheme
|
|
3158
|
+
};
|
|
3159
|
+
return {
|
|
3160
|
+
atrule: resolveColorTokenValue(context, tokens?.atrule),
|
|
3161
|
+
attrName: resolveColorTokenValue(context, tokens?.attrName),
|
|
3162
|
+
attrValue: resolveColorTokenValue(context, tokens?.attrValue),
|
|
3163
|
+
attribute: resolveColorTokenValue(context, tokens?.attribute),
|
|
3164
|
+
boolean: resolveColorTokenValue(context, tokens?.boolean),
|
|
3165
|
+
builtin: resolveColorTokenValue(context, tokens?.builtin),
|
|
3166
|
+
cdata: resolveColorTokenValue(context, tokens?.cdata),
|
|
3167
|
+
char: resolveColorTokenValue(context, tokens?.char),
|
|
3168
|
+
class: resolveColorTokenValue(context, tokens?.class),
|
|
3169
|
+
className: resolveColorTokenValue(context, tokens?.className),
|
|
3170
|
+
comment: resolveColorTokenValue(context, tokens?.comment),
|
|
3171
|
+
constant: resolveColorTokenValue(context, tokens?.constant),
|
|
3172
|
+
deleted: resolveColorTokenValue(context, tokens?.deleted),
|
|
3173
|
+
doctype: resolveColorTokenValue(context, tokens?.doctype),
|
|
3174
|
+
entity: resolveColorTokenValue(context, tokens?.entity),
|
|
3175
|
+
function: resolveColorTokenValue(context, tokens?.function),
|
|
3176
|
+
hexcode: resolveColorTokenValue(context, tokens?.hexcode),
|
|
3177
|
+
id: resolveColorTokenValue(context, tokens?.id),
|
|
3178
|
+
important: resolveColorTokenValue(context, tokens?.important),
|
|
3179
|
+
inserted: resolveColorTokenValue(context, tokens?.inserted),
|
|
3180
|
+
keyword: resolveColorTokenValue(context, tokens?.keyword),
|
|
3181
|
+
number: resolveColorTokenValue(context, tokens?.number),
|
|
3182
|
+
operator: resolveColorTokenValue(context, tokens?.operator),
|
|
3183
|
+
prolog: resolveColorTokenValue(context, tokens?.prolog),
|
|
3184
|
+
property: resolveColorTokenValue(context, tokens?.property),
|
|
3185
|
+
pseudoClass: resolveColorTokenValue(context, tokens?.pseudoClass),
|
|
3186
|
+
pseudoElement: resolveColorTokenValue(context, tokens?.pseudoElement),
|
|
3187
|
+
punctuation: resolveColorTokenValue(context, tokens?.punctuation),
|
|
3188
|
+
regex: resolveColorTokenValue(context, tokens?.regex),
|
|
3189
|
+
selector: resolveColorTokenValue(context, tokens?.selector),
|
|
3190
|
+
string: resolveColorTokenValue(context, tokens?.string),
|
|
3191
|
+
symbol: resolveColorTokenValue(context, tokens?.symbol),
|
|
3192
|
+
tag: resolveColorTokenValue(context, tokens?.tag),
|
|
3193
|
+
unit: resolveColorTokenValue(context, tokens?.unit),
|
|
3194
|
+
url: resolveColorTokenValue(context, tokens?.url),
|
|
3195
|
+
variable: resolveColorTokenValue(context, tokens?.variable)
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
3198
|
+
const defaultColorPalette = _sanity_color.color;
|
|
3199
|
+
function mixChannel(b, s, weight) {
|
|
3200
|
+
return b + (s - b) * weight;
|
|
3201
|
+
}
|
|
3202
|
+
/**
|
|
3203
|
+
* Apply the \`mix\` blend mode
|
|
3204
|
+
* @internal
|
|
3205
|
+
*/
|
|
3206
|
+
function mix(b, s, weight) {
|
|
3207
|
+
return {
|
|
3208
|
+
r: mixChannel(b.r, s.r, weight),
|
|
3209
|
+
g: mixChannel(b.g, s.g, weight),
|
|
3210
|
+
b: mixChannel(b.b, s.b, weight)
|
|
3211
|
+
};
|
|
3212
|
+
}
|
|
3213
|
+
function multiplyChannel(b, s) {
|
|
3214
|
+
return b * s;
|
|
3215
|
+
}
|
|
3216
|
+
/**
|
|
3217
|
+
* Apply the \`multiply\` blend mode
|
|
3218
|
+
* Source: https://www.w3.org/TR/compositing-1/#blendingmultiply
|
|
3219
|
+
* @internal
|
|
3220
|
+
*/
|
|
3221
|
+
function multiply(b, s) {
|
|
3222
|
+
return {
|
|
3223
|
+
r: multiplyChannel(b.r / 255, s.r / 255) * 255,
|
|
3224
|
+
g: multiplyChannel(b.g / 255, s.g / 255) * 255,
|
|
3225
|
+
b: multiplyChannel(b.b / 255, s.b / 255) * 255
|
|
3226
|
+
};
|
|
3227
|
+
}
|
|
3228
|
+
function screenChannel(b, s) {
|
|
3229
|
+
return b + s - b * s;
|
|
3230
|
+
}
|
|
3231
|
+
/**
|
|
3232
|
+
* Apply the \`screen\` blend mode
|
|
3233
|
+
* Source: https://www.w3.org/TR/compositing-1/#blendingscreen
|
|
3234
|
+
* @internal
|
|
3235
|
+
*/
|
|
3236
|
+
function screen(b, s) {
|
|
3237
|
+
return {
|
|
3238
|
+
r: screenChannel(b.r / 255, s.r / 255) * 255,
|
|
3239
|
+
g: screenChannel(b.g / 255, s.g / 255) * 255,
|
|
3240
|
+
b: screenChannel(b.b / 255, s.b / 255) * 255
|
|
3241
|
+
};
|
|
3242
|
+
}
|
|
3243
|
+
function lerp(x, y, a) {
|
|
3244
|
+
return x * (1 - a) + y * a;
|
|
3245
|
+
}
|
|
3246
|
+
function invlerp(x, y, a) {
|
|
3247
|
+
return clamp((a - x) / (y - x));
|
|
3248
|
+
}
|
|
3249
|
+
function clamp(a, min = 0, max = 1) {
|
|
3250
|
+
return Math.min(max, Math.max(min, a));
|
|
3251
|
+
}
|
|
3252
|
+
function range(x1, y1, x2, y2, a) {
|
|
3253
|
+
return lerp(x2, y2, invlerp(x1, y1, a));
|
|
3254
|
+
}
|
|
3255
|
+
function round(value) {
|
|
3256
|
+
return Math.round(value);
|
|
3257
|
+
}
|
|
3258
|
+
/**
|
|
3259
|
+
* @internal
|
|
3260
|
+
*/
|
|
3261
|
+
function hexToRgb(hex) {
|
|
3262
|
+
if (hex.length === 4) {
|
|
3263
|
+
let hexR = hex.slice(1, 2), hexG = hex.slice(2, 3), hexB = hex.slice(3, 4);
|
|
3264
|
+
return {
|
|
3265
|
+
r: parseInt(hexR + hexR, 16),
|
|
3266
|
+
g: parseInt(hexG + hexG, 16),
|
|
3267
|
+
b: parseInt(hexB + hexB, 16)
|
|
3268
|
+
};
|
|
3269
|
+
}
|
|
3270
|
+
return {
|
|
3271
|
+
r: parseInt(hex.slice(1, 3), 16),
|
|
3272
|
+
g: parseInt(hex.slice(3, 5), 16),
|
|
3273
|
+
b: parseInt(hex.slice(5, 7), 16)
|
|
3274
|
+
};
|
|
3275
|
+
}
|
|
3276
|
+
/**
|
|
3277
|
+
* @internal
|
|
3278
|
+
*/
|
|
3279
|
+
function rgbaToRGBA(rgba) {
|
|
3280
|
+
let values = rgba.replace(/rgba\(|\)/g, "").split(",");
|
|
3281
|
+
return {
|
|
3282
|
+
r: parseInt(values[0]),
|
|
3283
|
+
g: parseInt(values[1]),
|
|
3284
|
+
b: parseInt(values[2]),
|
|
3285
|
+
a: parseFloat(values[3])
|
|
3286
|
+
};
|
|
3287
|
+
}
|
|
3288
|
+
/**
|
|
3289
|
+
* @internal
|
|
3290
|
+
*/
|
|
3291
|
+
function rgbToHex(color) {
|
|
3292
|
+
let r = round(clamp(Math.round(color.r), 0, 255)), g = round(clamp(Math.round(color.g), 0, 255)), b = round(clamp(Math.round(color.b), 0, 255));
|
|
3293
|
+
return "a" in color ? `rgba(${r},${g},${b},${color.a})` : "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
3294
|
+
}
|
|
3295
|
+
/**
|
|
3296
|
+
* @internal
|
|
3297
|
+
* @see https://css-tricks.com/converting-color-spaces-in-javascript/
|
|
3298
|
+
*/
|
|
3299
|
+
function rgbToHsl({ r, g, b }) {
|
|
3300
|
+
r /= 255, g /= 255, b /= 255;
|
|
3301
|
+
let cmin = Math.min(r, g, b), cmax = Math.max(r, g, b), delta = cmax - cmin, h = 0, s = 0, l = 0;
|
|
3302
|
+
return h = delta == 0 ? 0 : cmax == r ? (g - b) / delta % 6 : cmax == g ? (b - r) / delta + 2 : (r - g) / delta + 4, h = Math.round(h * 60), h < 0 && (h += 360), l = (cmax + cmin) / 2, s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1)), s = +(s * 100).toFixed(1), l = +(l * 100).toFixed(1), {
|
|
3303
|
+
h,
|
|
3304
|
+
s,
|
|
3305
|
+
l
|
|
3306
|
+
};
|
|
3307
|
+
}
|
|
3308
|
+
/**
|
|
3309
|
+
* @internal
|
|
3310
|
+
*/
|
|
3311
|
+
function hslToRgb(hsl) {
|
|
3312
|
+
let s = hsl.s / 100, l = hsl.l / 100, c = (1 - Math.abs(2 * l - 1)) * s, x = c * (1 - Math.abs(hsl.h / 60 % 2 - 1)), m = l - c / 2, r = 0, g = 0, b = 0;
|
|
3313
|
+
return 0 <= hsl.h && hsl.h < 60 ? (r = c, g = x, b = 0) : 60 <= hsl.h && hsl.h < 120 ? (r = x, g = c, b = 0) : 120 <= hsl.h && hsl.h < 180 ? (r = 0, g = c, b = x) : 180 <= hsl.h && hsl.h < 240 ? (r = 0, g = x, b = c) : 240 <= hsl.h && hsl.h < 300 ? (r = x, g = 0, b = c) : 300 <= hsl.h && hsl.h < 360 && (r = c, g = 0, b = x), {
|
|
3314
|
+
r: Math.round((r + m) * 255),
|
|
3315
|
+
g: Math.round((g + m) * 255),
|
|
3316
|
+
b: Math.round((b + m) * 255)
|
|
3317
|
+
};
|
|
3318
|
+
}
|
|
3319
|
+
const HSL_RE = /hsl\(\s*(\d+)\s*,\s*((\d+(?:\.\d+)?)%)\s*,\s*((\d+(?:\.\d+)?)%)\s*\)/i;
|
|
3320
|
+
function isHexChars(str) {
|
|
3321
|
+
for (let c of str) if ("0123456789ABCDEFabcdef".indexOf(c) === -1) return !1;
|
|
3322
|
+
return !0;
|
|
3323
|
+
}
|
|
3324
|
+
function isHex(str) {
|
|
3325
|
+
return str[0] !== "#" || !(str.length === 4 || str.length === 7) ? !1 : isHexChars(str.slice(1));
|
|
3326
|
+
}
|
|
3327
|
+
function parseHsl(str) {
|
|
3328
|
+
let res = HSL_RE.exec(str);
|
|
3329
|
+
if (!res) throw Error(`parseHsl: string is not a HSL color: "${str}"`);
|
|
3330
|
+
return {
|
|
3331
|
+
h: parseInt(res[1]),
|
|
3332
|
+
s: parseFloat(res[3]),
|
|
3333
|
+
l: parseFloat(res[5])
|
|
3334
|
+
};
|
|
3335
|
+
}
|
|
3336
|
+
/**
|
|
3337
|
+
* @internal
|
|
3338
|
+
*/
|
|
3339
|
+
function parseColor(color) {
|
|
3340
|
+
if (!color) return {
|
|
3341
|
+
r: 0,
|
|
3342
|
+
g: 0,
|
|
3343
|
+
b: 0
|
|
3344
|
+
};
|
|
3345
|
+
if (typeof color != "string") throw Error("parseColor: expected a string");
|
|
3346
|
+
if (isHex(color)) return hexToRgb(color);
|
|
3347
|
+
if (color.startsWith("hsl(")) return hslToRgb(parseHsl(color));
|
|
3348
|
+
if (color.startsWith("rgba(")) return rgbaToRGBA(color);
|
|
3349
|
+
throw Error(`parseColor: unexpected color format: "${color}"`);
|
|
3350
|
+
}
|
|
3351
|
+
/** @internal */
|
|
3352
|
+
function getContrastRatio(bg, fg) {
|
|
3353
|
+
let rgb1 = parseColor(bg), rgb2 = parseColor(fg), c1 = rgb_lrgb(rgb1), c2 = rgb_lrgb(rgb2), l1 = lrgb_luminance(c1), l2 = lrgb_luminance(c2);
|
|
3354
|
+
return (Math.max(l1, l2) + .05) / (Math.min(l1, l2) + .05);
|
|
3355
|
+
}
|
|
3356
|
+
function rgb_lrgb({ r, g, b }) {
|
|
3357
|
+
return [
|
|
3358
|
+
rgb_lrgb1(r / 255),
|
|
3359
|
+
rgb_lrgb1(g / 255),
|
|
3360
|
+
rgb_lrgb1(b / 255)
|
|
3361
|
+
];
|
|
3362
|
+
}
|
|
3363
|
+
function rgb_lrgb1(v) {
|
|
3364
|
+
return v <= .04045 ? v / 12.92 : ((v + .055) / 1.055) ** 2.4;
|
|
3365
|
+
}
|
|
3366
|
+
function lrgb_luminance([r, g, b]) {
|
|
3367
|
+
return .2126 * r + .7152 * g + .0722 * b;
|
|
3368
|
+
}
|
|
3369
|
+
/**
|
|
3370
|
+
* @internal
|
|
3371
|
+
*/
|
|
3372
|
+
function rgba(color, a) {
|
|
3373
|
+
let rgb = parseColor(color);
|
|
3374
|
+
return `rgba(${rgb.r},${rgb.g},${rgb.b},${a})`;
|
|
3375
|
+
}
|
|
3376
|
+
const RGB_RANGE = [0, 255];
|
|
3377
|
+
function mixThemeColor(value, options) {
|
|
3378
|
+
let { blendMode } = options, color = parseColor(value), black = parseColor(options.black), white = parseColor(options.white), bg = options.bg ? parseColor(options.bg) : blendMode === "multiply" ? white : black, paletteRange = {
|
|
3379
|
+
r: [black.r, white.r],
|
|
3380
|
+
g: [black.g, white.g],
|
|
3381
|
+
b: [black.b, white.b]
|
|
3382
|
+
}, convertedBgColor = {
|
|
3383
|
+
r: clamp(range(...paletteRange.r, ...RGB_RANGE, bg.r), ...RGB_RANGE),
|
|
3384
|
+
g: clamp(range(...paletteRange.g, ...RGB_RANGE, bg.g), ...RGB_RANGE),
|
|
3385
|
+
b: clamp(range(...paletteRange.b, ...RGB_RANGE, bg.b), ...RGB_RANGE)
|
|
3386
|
+
}, convertedColor = {
|
|
3387
|
+
r: clamp(range(...paletteRange.r, ...RGB_RANGE, color.r), ...RGB_RANGE),
|
|
3388
|
+
g: clamp(range(...paletteRange.g, ...RGB_RANGE, color.g), ...RGB_RANGE),
|
|
3389
|
+
b: clamp(range(...paletteRange.b, ...RGB_RANGE, color.b), ...RGB_RANGE)
|
|
3390
|
+
}, resultColor = blendMode === "multiply" ? multiply(convertedBgColor, convertedColor) : screen(convertedBgColor, convertedColor);
|
|
3391
|
+
return rgbToHex({
|
|
3392
|
+
r: clamp(range(...RGB_RANGE, ...paletteRange.r, resultColor.r), ...paletteRange.r),
|
|
3393
|
+
g: clamp(range(...RGB_RANGE, ...paletteRange.g, resultColor.g), ...paletteRange.g),
|
|
3394
|
+
b: clamp(range(...RGB_RANGE, ...paletteRange.b, resultColor.b), ...paletteRange.b)
|
|
3395
|
+
});
|
|
3396
|
+
}
|
|
3397
|
+
function renderColorValue(str, options) {
|
|
3398
|
+
let { bg, blendMode, colorPalette } = options;
|
|
3399
|
+
if (bg === "white") throw Error("Cannot blend with white background");
|
|
3400
|
+
let node = parseTokenValue(str);
|
|
3401
|
+
if (!node || node.type !== "color") throw Error(`Invalid color token value: ${str}`);
|
|
3402
|
+
let hex = "";
|
|
3403
|
+
if (node.key === "black" && (hex = renderColorHex(colorPalette.black)), node.key === "white" && (hex = renderColorHex(colorPalette.white)), node.hue && node.tint && (hex = renderColorHex(colorPalette[node.hue][node.tint])), !hex) throw Error(`Invalid color token value: ${str}`);
|
|
3404
|
+
let hexBeforeMix = hex, mixOptions = {
|
|
3405
|
+
blendMode,
|
|
3406
|
+
bg,
|
|
3407
|
+
black: renderColorHex(colorPalette.black),
|
|
3408
|
+
white: renderColorHex(colorPalette.white)
|
|
3409
|
+
};
|
|
3410
|
+
try {
|
|
3411
|
+
hex = mixThemeColor(hex, mixOptions), bg && node.mix !== void 0 && (hex = rgbToHex(mix(hexToRgb(bg), hexToRgb(hex), node.mix)));
|
|
3412
|
+
} catch (err) {
|
|
3413
|
+
throw console.warn("could not blend", hex, mixOptions), err;
|
|
3414
|
+
}
|
|
3415
|
+
return hex === "#aN" && (console.warn(`invalid color token value: ${str}`), hex = hexBeforeMix), node.opacity !== void 0 && (hex = rgba(hex, node.opacity)), hex;
|
|
3416
|
+
}
|
|
3417
|
+
function renderColorHex(color) {
|
|
3418
|
+
return typeof color == "string" ? color : color.hex;
|
|
3419
|
+
}
|
|
3420
|
+
function renderThemeColorSchemes(value, config) {
|
|
3421
|
+
let colorPalette = config?.palette ?? defaultColorPalette, schemes = {};
|
|
3422
|
+
return defineLazyProperty(schemes, "light", () => renderThemeColorScheme(colorPalette, value.light)), defineLazyProperty(schemes, "dark", () => renderThemeColorScheme(colorPalette, value.dark)), schemes;
|
|
3423
|
+
}
|
|
3424
|
+
function renderThemeColorScheme(colorPalette, value) {
|
|
3425
|
+
let renderedDefaultTone = renderThemeColor(value.default, { colorPalette }), bg = renderedDefaultTone.bg;
|
|
3426
|
+
if (bg === "white") throw Error("Cannot blend with white background");
|
|
3427
|
+
let scheme = { default: renderedDefaultTone };
|
|
3428
|
+
for (let tone of THEME_COLOR_CARD_TONES) {
|
|
3429
|
+
if (tone === "default") continue;
|
|
3430
|
+
let opts = tone === "transparent" ? { colorPalette } : {
|
|
3431
|
+
bg,
|
|
3432
|
+
colorPalette
|
|
3433
|
+
};
|
|
3434
|
+
defineLazyProperty(scheme, tone, () => renderThemeColor(value[tone], opts));
|
|
3435
|
+
}
|
|
3436
|
+
return scheme;
|
|
3437
|
+
}
|
|
3438
|
+
function renderThemeColor(value, options) {
|
|
3439
|
+
let { colorPalette, bg } = options, blendMode = value._blend || "multiply", baseBg = renderColorValue(value.bg, {
|
|
3440
|
+
colorPalette,
|
|
3441
|
+
bg,
|
|
3442
|
+
blendMode
|
|
3443
|
+
}), colorOptions = {
|
|
3444
|
+
colorPalette,
|
|
3445
|
+
bg: baseBg,
|
|
3446
|
+
blendMode
|
|
3447
|
+
}, button = renderThemeColorButton(value.button, {
|
|
3448
|
+
baseBg,
|
|
3449
|
+
blendMode,
|
|
3450
|
+
colorPalette
|
|
3451
|
+
}), selectable = renderThemeColorSelectable(value.selectable, {
|
|
3452
|
+
colorPalette,
|
|
3453
|
+
baseBg,
|
|
3454
|
+
blendMode
|
|
3455
|
+
}), shadow = {
|
|
3456
|
+
outline: renderColorValue(value.shadow.outline, colorOptions),
|
|
3457
|
+
umbra: renderColorValue(value.shadow.umbra, {
|
|
3458
|
+
...colorOptions,
|
|
3459
|
+
bg: void 0,
|
|
3460
|
+
colorPalette: {
|
|
3461
|
+
...colorPalette,
|
|
3462
|
+
black: "#000000"
|
|
3463
|
+
}
|
|
3464
|
+
}),
|
|
3465
|
+
penumbra: renderColorValue(value.shadow.penumbra, {
|
|
3466
|
+
...colorOptions,
|
|
3467
|
+
bg: void 0,
|
|
3468
|
+
colorPalette: {
|
|
3469
|
+
...colorPalette,
|
|
3470
|
+
black: "#000000"
|
|
3471
|
+
}
|
|
3472
|
+
}),
|
|
3473
|
+
ambient: renderColorValue(value.shadow.ambient, {
|
|
3474
|
+
...colorOptions,
|
|
3475
|
+
bg: void 0,
|
|
3476
|
+
colorPalette: {
|
|
3477
|
+
...colorPalette,
|
|
3478
|
+
black: "#000000"
|
|
3479
|
+
}
|
|
3480
|
+
})
|
|
3481
|
+
};
|
|
3482
|
+
return {
|
|
3483
|
+
_blend: blendMode,
|
|
3484
|
+
_dark: value._dark,
|
|
3485
|
+
accent: { fg: renderColorValue(value.accent.fg, colorOptions) },
|
|
3486
|
+
avatar: renderThemeColorAvatar(value.avatar, {
|
|
3487
|
+
baseBg,
|
|
3488
|
+
colorPalette,
|
|
3489
|
+
blendMode
|
|
3490
|
+
}),
|
|
3491
|
+
backdrop: renderColorValue(value.backdrop, colorOptions),
|
|
3492
|
+
badge: renderThemeColorBadge(value.badge, {
|
|
3493
|
+
baseBg,
|
|
3494
|
+
colorPalette,
|
|
3495
|
+
blendMode
|
|
3496
|
+
}),
|
|
3497
|
+
bg: baseBg,
|
|
3498
|
+
border: renderColorValue(value.border, colorOptions),
|
|
3499
|
+
button,
|
|
3500
|
+
code: {
|
|
3501
|
+
bg: renderColorValue(value.code.bg, colorOptions),
|
|
3502
|
+
fg: renderColorValue(value.code.fg, colorOptions)
|
|
3503
|
+
},
|
|
3504
|
+
fg: renderColorValue(value.fg, colorOptions),
|
|
3505
|
+
focusRing: renderColorValue(value.focusRing, colorOptions),
|
|
3506
|
+
icon: renderColorValue(value.icon, colorOptions),
|
|
3507
|
+
input: renderThemeColorInput(value.input, {
|
|
3508
|
+
baseBg,
|
|
3509
|
+
colorPalette,
|
|
3510
|
+
blendMode
|
|
3511
|
+
}),
|
|
3512
|
+
kbd: renderThemeColorKBD(value.kbd, {
|
|
3513
|
+
baseBg,
|
|
3514
|
+
colorPalette,
|
|
3515
|
+
blendMode
|
|
3516
|
+
}),
|
|
3517
|
+
link: { fg: renderColorValue(value.link.fg, colorOptions) },
|
|
3518
|
+
muted: {
|
|
3519
|
+
bg: renderColorValue(value.muted.bg, colorOptions),
|
|
3520
|
+
fg: renderColorValue(value.muted.fg, colorOptions)
|
|
3521
|
+
},
|
|
3522
|
+
shadow,
|
|
3523
|
+
skeleton: {
|
|
3524
|
+
from: renderColorValue(value.skeleton.from, colorOptions),
|
|
3525
|
+
to: renderColorValue(value.skeleton.to, colorOptions)
|
|
3526
|
+
},
|
|
3527
|
+
syntax: renderSyntaxColorTheme(value.syntax, {
|
|
3528
|
+
baseBg,
|
|
3529
|
+
colorPalette,
|
|
3530
|
+
blendMode
|
|
3531
|
+
}),
|
|
3532
|
+
selectable
|
|
3533
|
+
};
|
|
3534
|
+
}
|
|
3535
|
+
function renderThemeColorKBD(value, options) {
|
|
3536
|
+
let { baseBg, blendMode, colorPalette } = options, rootOptions = {
|
|
3537
|
+
bg: baseBg,
|
|
3538
|
+
blendMode,
|
|
3539
|
+
colorPalette
|
|
3540
|
+
}, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
|
|
3541
|
+
bg,
|
|
3542
|
+
blendMode,
|
|
3543
|
+
colorPalette
|
|
3544
|
+
};
|
|
3545
|
+
return {
|
|
3546
|
+
bg,
|
|
3547
|
+
fg: renderColorValue(value.fg, colorOptions),
|
|
3548
|
+
border: renderColorValue(value.border, colorOptions)
|
|
3549
|
+
};
|
|
3550
|
+
}
|
|
3551
|
+
function renderThemeColorAvatar(value, options) {
|
|
3552
|
+
let colorAvatar = {};
|
|
3553
|
+
for (let hue of _sanity_color.COLOR_HUES) colorAvatar[hue] = renderThemeColorAvatarColor(value[hue], options);
|
|
3554
|
+
return colorAvatar;
|
|
3555
|
+
}
|
|
3556
|
+
function renderThemeColorAvatarColor(value, options) {
|
|
3557
|
+
let { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = value._blend || "multiply", rootOptions = {
|
|
3558
|
+
bg: baseBg,
|
|
3559
|
+
blendMode: rootBlendMode,
|
|
3560
|
+
colorPalette
|
|
3561
|
+
}, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
|
|
3562
|
+
bg,
|
|
3563
|
+
blendMode,
|
|
3564
|
+
colorPalette
|
|
3565
|
+
};
|
|
3566
|
+
return {
|
|
3567
|
+
_blend: blendMode,
|
|
3568
|
+
bg,
|
|
3569
|
+
fg: renderColorValue(value.fg, colorOptions)
|
|
3570
|
+
};
|
|
3571
|
+
}
|
|
3572
|
+
function renderThemeColorBadge(value, options) {
|
|
3573
|
+
let colorBadge = {};
|
|
3574
|
+
for (let tone of THEME_COLOR_STATE_TONES) colorBadge[tone] = renderThemeColorBadgeColor(value[tone], options);
|
|
3575
|
+
return colorBadge;
|
|
3576
|
+
}
|
|
3577
|
+
function renderThemeColorBadgeColor(value, options) {
|
|
3578
|
+
let { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = rootBlendMode, rootOptions = {
|
|
3579
|
+
bg: baseBg,
|
|
3580
|
+
blendMode: rootBlendMode,
|
|
3581
|
+
colorPalette
|
|
3582
|
+
}, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
|
|
3583
|
+
bg,
|
|
3584
|
+
blendMode,
|
|
3585
|
+
colorPalette
|
|
3586
|
+
};
|
|
3587
|
+
return {
|
|
3588
|
+
bg,
|
|
3589
|
+
dot: renderColorValue(value.dot, colorOptions),
|
|
3590
|
+
fg: renderColorValue(value.fg, colorOptions),
|
|
3591
|
+
icon: renderColorValue(value.icon, colorOptions)
|
|
3592
|
+
};
|
|
3593
|
+
}
|
|
3594
|
+
function renderThemeColorButton(value, options) {
|
|
3595
|
+
return {
|
|
3596
|
+
default: renderThemeColorButtonTones(value.default, options),
|
|
3597
|
+
ghost: renderThemeColorButtonTones(value.ghost, options),
|
|
3598
|
+
bleed: renderThemeColorButtonTones(value.bleed, options)
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
function renderThemeColorButtonTones(value, options) {
|
|
3602
|
+
let colorButtonMode = {};
|
|
3603
|
+
for (let tone of THEME_COLOR_STATE_TONES) colorButtonMode[tone] = renderThemeColorButtonStates(value[tone], options);
|
|
3604
|
+
return colorButtonMode;
|
|
3605
|
+
}
|
|
3606
|
+
function renderThemeColorButtonStates(value, options) {
|
|
3607
|
+
return {
|
|
3608
|
+
enabled: renderThemeColorState(value.enabled, options),
|
|
3609
|
+
hovered: renderThemeColorState(value.hovered, options),
|
|
3610
|
+
pressed: renderThemeColorState(value.pressed, options),
|
|
3611
|
+
selected: renderThemeColorState(value.selected, options),
|
|
3612
|
+
disabled: renderThemeColorState(value.disabled, options)
|
|
3613
|
+
};
|
|
3614
|
+
}
|
|
3615
|
+
function renderThemeColorState(value, options) {
|
|
3616
|
+
let { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = value._blend || "multiply", rootOptions = {
|
|
3617
|
+
bg: baseBg,
|
|
3618
|
+
blendMode: rootBlendMode,
|
|
3619
|
+
colorPalette
|
|
3620
|
+
}, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
|
|
3621
|
+
bg,
|
|
3622
|
+
blendMode,
|
|
3623
|
+
colorPalette
|
|
3624
|
+
};
|
|
3625
|
+
return {
|
|
3626
|
+
_blend: blendMode,
|
|
3627
|
+
accent: { fg: renderColorValue(value.accent.fg, colorOptions) },
|
|
3628
|
+
avatar: renderThemeColorAvatar(value.avatar, {
|
|
3629
|
+
baseBg: bg,
|
|
3630
|
+
colorPalette,
|
|
3631
|
+
blendMode
|
|
3632
|
+
}),
|
|
3633
|
+
badge: renderThemeColorBadge(value.badge, {
|
|
3634
|
+
baseBg: bg,
|
|
3635
|
+
colorPalette,
|
|
3636
|
+
blendMode
|
|
3637
|
+
}),
|
|
3638
|
+
bg,
|
|
3639
|
+
border: renderColorValue(value.border, colorOptions),
|
|
3640
|
+
code: {
|
|
3641
|
+
bg: renderColorValue(value.code.bg, colorOptions),
|
|
3642
|
+
fg: renderColorValue(value.code.fg, colorOptions)
|
|
3643
|
+
},
|
|
3644
|
+
fg: renderColorValue(value.fg, colorOptions),
|
|
3645
|
+
icon: renderColorValue(value.icon, colorOptions),
|
|
3646
|
+
link: { fg: renderColorValue(value.link.fg, colorOptions) },
|
|
3647
|
+
muted: {
|
|
3648
|
+
bg: renderColorValue(value.muted.bg, colorOptions),
|
|
3649
|
+
fg: renderColorValue(value.muted.fg, colorOptions)
|
|
3650
|
+
},
|
|
3651
|
+
kbd: {
|
|
3652
|
+
bg: renderColorValue(value.kbd.bg, colorOptions),
|
|
3653
|
+
fg: renderColorValue(value.kbd.fg, colorOptions),
|
|
3654
|
+
border: renderColorValue(value.kbd.border, colorOptions)
|
|
3655
|
+
},
|
|
3656
|
+
skeleton: {
|
|
3657
|
+
from: renderColorValue(value.skeleton?.from, colorOptions),
|
|
3658
|
+
to: renderColorValue(value.skeleton?.to, colorOptions)
|
|
3659
|
+
}
|
|
3660
|
+
};
|
|
3661
|
+
}
|
|
3662
|
+
function renderThemeColorInput(value, options) {
|
|
3663
|
+
return {
|
|
3664
|
+
default: renderInputStatesColorTheme(value.default, options),
|
|
3665
|
+
invalid: renderInputStatesColorTheme(value.invalid, options)
|
|
3666
|
+
};
|
|
3667
|
+
}
|
|
3668
|
+
function renderInputStatesColorTheme(value, options) {
|
|
3669
|
+
return {
|
|
3670
|
+
enabled: renderInputStateColorTheme(value.enabled, options),
|
|
3671
|
+
hovered: renderInputStateColorTheme(value.hovered, options),
|
|
3672
|
+
readOnly: renderInputStateColorTheme(value.readOnly, options),
|
|
3673
|
+
disabled: renderInputStateColorTheme(value.disabled, options)
|
|
3674
|
+
};
|
|
3675
|
+
}
|
|
3676
|
+
function renderInputStateColorTheme(value, options) {
|
|
3677
|
+
let { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = value._blend || "multiply", rootOptions = {
|
|
3678
|
+
colorPalette,
|
|
3679
|
+
bg: baseBg,
|
|
3680
|
+
blendMode: rootBlendMode
|
|
3681
|
+
}, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
|
|
3682
|
+
colorPalette,
|
|
3683
|
+
bg,
|
|
3684
|
+
blendMode
|
|
3685
|
+
};
|
|
3686
|
+
return {
|
|
3687
|
+
_blend: blendMode,
|
|
3688
|
+
bg,
|
|
3689
|
+
border: renderColorValue(value.border, colorOptions),
|
|
3690
|
+
fg: renderColorValue(value.fg, colorOptions),
|
|
3691
|
+
muted: { bg: renderColorValue(value.muted.bg, colorOptions) },
|
|
3692
|
+
placeholder: renderColorValue(value.placeholder, colorOptions)
|
|
3693
|
+
};
|
|
3694
|
+
}
|
|
3695
|
+
function renderThemeColorSelectable(value, options) {
|
|
3696
|
+
let colorSelectable = {};
|
|
3697
|
+
for (let tone of THEME_COLOR_STATE_TONES) colorSelectable[tone] = renderThemeColorSelectableStates(value[tone], options);
|
|
3698
|
+
return colorSelectable;
|
|
3699
|
+
}
|
|
3700
|
+
function renderThemeColorSelectableStates(value, options) {
|
|
3701
|
+
return {
|
|
3702
|
+
enabled: renderThemeColorState(value.enabled, options),
|
|
3703
|
+
hovered: renderThemeColorState(value.hovered, options),
|
|
3704
|
+
pressed: renderThemeColorState(value.pressed, options),
|
|
3705
|
+
selected: renderThemeColorState(value.selected, options),
|
|
3706
|
+
disabled: renderThemeColorState(value.disabled, options)
|
|
3707
|
+
};
|
|
3708
|
+
}
|
|
3709
|
+
function renderSyntaxColorTheme(value, options) {
|
|
3710
|
+
let { colorPalette, baseBg, blendMode } = options, colorOptions = {
|
|
3711
|
+
colorPalette,
|
|
3712
|
+
bg: baseBg,
|
|
3713
|
+
blendMode
|
|
3714
|
+
};
|
|
3715
|
+
return {
|
|
3716
|
+
atrule: renderColorValue(value.atrule, colorOptions),
|
|
3717
|
+
attrName: renderColorValue(value.attrName, colorOptions),
|
|
3718
|
+
attrValue: renderColorValue(value.attrValue, colorOptions),
|
|
3719
|
+
attribute: renderColorValue(value.attribute, colorOptions),
|
|
3720
|
+
boolean: renderColorValue(value.boolean, colorOptions),
|
|
3721
|
+
builtin: renderColorValue(value.builtin, colorOptions),
|
|
3722
|
+
cdata: renderColorValue(value.cdata, colorOptions),
|
|
3723
|
+
char: renderColorValue(value.char, colorOptions),
|
|
3724
|
+
class: renderColorValue(value.class, colorOptions),
|
|
3725
|
+
className: renderColorValue(value.className, colorOptions),
|
|
3726
|
+
comment: renderColorValue(value.comment, colorOptions),
|
|
3727
|
+
constant: renderColorValue(value.constant, colorOptions),
|
|
3728
|
+
deleted: renderColorValue(value.deleted, colorOptions),
|
|
3729
|
+
doctype: renderColorValue(value.doctype, colorOptions),
|
|
3730
|
+
entity: renderColorValue(value.entity, colorOptions),
|
|
3731
|
+
function: renderColorValue(value.function, colorOptions),
|
|
3732
|
+
hexcode: renderColorValue(value.hexcode, colorOptions),
|
|
3733
|
+
id: renderColorValue(value.id, colorOptions),
|
|
3734
|
+
important: renderColorValue(value.important, colorOptions),
|
|
3735
|
+
inserted: renderColorValue(value.inserted, colorOptions),
|
|
3736
|
+
keyword: renderColorValue(value.keyword, colorOptions),
|
|
3737
|
+
number: renderColorValue(value.number, colorOptions),
|
|
3738
|
+
operator: renderColorValue(value.operator, colorOptions),
|
|
3739
|
+
prolog: renderColorValue(value.prolog, colorOptions),
|
|
3740
|
+
property: renderColorValue(value.property, colorOptions),
|
|
3741
|
+
pseudoClass: renderColorValue(value.pseudoClass, colorOptions),
|
|
3742
|
+
pseudoElement: renderColorValue(value.pseudoElement, colorOptions),
|
|
3743
|
+
punctuation: renderColorValue(value.punctuation, colorOptions),
|
|
3744
|
+
regex: renderColorValue(value.regex, colorOptions),
|
|
3745
|
+
selector: renderColorValue(value.selector, colorOptions),
|
|
3746
|
+
string: renderColorValue(value.string, colorOptions),
|
|
3747
|
+
symbol: renderColorValue(value.symbol, colorOptions),
|
|
3748
|
+
tag: renderColorValue(value.tag, colorOptions),
|
|
3749
|
+
unit: renderColorValue(value.unit, colorOptions),
|
|
3750
|
+
url: renderColorValue(value.url, colorOptions),
|
|
3751
|
+
variable: renderColorValue(value.variable, colorOptions)
|
|
3752
|
+
};
|
|
3753
|
+
}
|
|
3754
|
+
/** @internal */
|
|
3755
|
+
function buildTheme(config) {
|
|
3756
|
+
let colorTheme = buildColorTheme(config);
|
|
3757
|
+
return v2_v0({
|
|
3758
|
+
_version: 2,
|
|
3759
|
+
avatar: config?.avatar ?? defaultThemeConfig.avatar,
|
|
3760
|
+
button: config?.button ?? defaultThemeConfig.button,
|
|
3761
|
+
card: config?.card ?? defaultThemeConfig.card,
|
|
3762
|
+
color: renderThemeColorSchemes(colorTheme, config),
|
|
3763
|
+
container: config?.container ?? defaultThemeConfig.container,
|
|
3764
|
+
font: config?.font ?? defaultThemeFonts,
|
|
3765
|
+
input: config?.input ?? defaultThemeConfig.input,
|
|
3766
|
+
layer: config?.layer ?? defaultThemeConfig.layer,
|
|
3767
|
+
media: config?.media ?? defaultThemeConfig.media,
|
|
3768
|
+
radius: config?.radius ?? defaultThemeConfig.radius,
|
|
3769
|
+
shadow: config?.shadow ?? defaultThemeConfig.shadow,
|
|
3770
|
+
space: config?.space ?? defaultThemeConfig.space,
|
|
3771
|
+
style: config?.style ?? defaultThemeConfig.style
|
|
3772
|
+
});
|
|
3773
|
+
}
|
|
3774
|
+
/**
|
|
3775
|
+
* Apply `neutral` and `suggest` if they're not already part of the color object,
|
|
3776
|
+
* as this was introduced in v2.9, but is not compatible with v2.0.
|
|
3777
|
+
*
|
|
3778
|
+
* @param color - The color object to upgrade
|
|
3779
|
+
* @returns The upgraded color object. Returns as-is if already upgraded.
|
|
3780
|
+
* @internal
|
|
3781
|
+
*/
|
|
3782
|
+
function themeColor_v0_v2_9(color) {
|
|
3783
|
+
if ("neutral" in color.badge) return color;
|
|
3784
|
+
let colors = color;
|
|
3785
|
+
return {
|
|
3786
|
+
...colors,
|
|
3787
|
+
badge: {
|
|
3788
|
+
...colors.badge,
|
|
3789
|
+
neutral: colors.badge.default,
|
|
3790
|
+
suggest: colors.badge.primary
|
|
3791
|
+
},
|
|
3792
|
+
button: {
|
|
3793
|
+
bleed: {
|
|
3794
|
+
...colors.button.bleed,
|
|
3795
|
+
neutral: colors.button.bleed.default,
|
|
3796
|
+
suggest: colors.button.bleed.primary
|
|
3797
|
+
},
|
|
3798
|
+
default: {
|
|
3799
|
+
...colors.button.default,
|
|
3800
|
+
neutral: colors.button.default.default,
|
|
3801
|
+
suggest: colors.button.default.primary
|
|
3802
|
+
},
|
|
3803
|
+
ghost: {
|
|
3804
|
+
...colors.button.ghost,
|
|
3805
|
+
neutral: colors.button.ghost.default,
|
|
3806
|
+
suggest: colors.button.ghost.primary
|
|
3807
|
+
}
|
|
3808
|
+
},
|
|
3809
|
+
selectable: {
|
|
3810
|
+
...colors.selectable,
|
|
3811
|
+
neutral: colors.selectable.default,
|
|
3812
|
+
suggest: colors.selectable.primary
|
|
3813
|
+
}
|
|
3814
|
+
};
|
|
3815
|
+
}
|
|
3816
|
+
const cache = /* @__PURE__ */ new Map();
|
|
3817
|
+
/** @internal */
|
|
3818
|
+
function getScopedTheme(themeProp, scheme, tone) {
|
|
3819
|
+
let cachedTheme = _getCachedTheme(themeProp, scheme, tone);
|
|
3820
|
+
if (cachedTheme) return cachedTheme;
|
|
3821
|
+
let v0 = is_v2(themeProp) ? v2_v0(themeProp) : themeProp, v2 = is_v2(themeProp) ? themeProp : v0_v2(themeProp), layer_v0 = v0.layer || defaultThemeConfig.layer, colorScheme_v2 = v2.color[scheme] || v2.color.light, color_v2_9 = themeColor_v0_v2_9(colorScheme_v2[tone] || colorScheme_v2.default), layer_v2 = v2.layer || defaultThemeConfig.layer, { color: _v0Color, ...v0Rest } = v0, sanity = {
|
|
3822
|
+
...v0Rest,
|
|
3823
|
+
layer: layer_v0,
|
|
3824
|
+
v2: {
|
|
3825
|
+
...v2,
|
|
3826
|
+
_resolved: !0,
|
|
3827
|
+
color: color_v2_9,
|
|
3828
|
+
layer: layer_v2
|
|
3829
|
+
}
|
|
3830
|
+
};
|
|
3831
|
+
defineLazyProperty(sanity, "color", () => {
|
|
3832
|
+
let colorScheme_v0 = v0.color[scheme] || v0.color.light;
|
|
3833
|
+
return colorScheme_v0[tone] || colorScheme_v0.default;
|
|
3834
|
+
});
|
|
3835
|
+
let theme = { sanity };
|
|
3836
|
+
return _setCachedTheme(themeProp, scheme, tone, theme), theme;
|
|
3837
|
+
}
|
|
3838
|
+
function _getCachedTheme(rootTheme, scheme, tone) {
|
|
3839
|
+
let schemeCache = cache.get(scheme);
|
|
3840
|
+
if (!schemeCache) return;
|
|
3841
|
+
let toneCache = schemeCache.get(tone);
|
|
3842
|
+
if (toneCache) return toneCache.get(rootTheme);
|
|
3843
|
+
}
|
|
3844
|
+
function _setCachedTheme(rootTheme, scheme, tone, theme) {
|
|
3845
|
+
cache.has(scheme) || cache.set(scheme, /* @__PURE__ */ new Map());
|
|
3846
|
+
let schemeCache = cache.get(scheme);
|
|
3847
|
+
schemeCache.has(tone) || schemeCache.set(tone, /* @__PURE__ */ new WeakMap()), schemeCache.get(tone).set(rootTheme, theme);
|
|
3848
|
+
}
|
|
3849
|
+
Object.defineProperty(exports, "A", {
|
|
3850
|
+
enumerable: !0,
|
|
3851
|
+
get: function() {
|
|
3852
|
+
return COLOR_CONFIG_STATES;
|
|
3853
|
+
}
|
|
3854
|
+
}), Object.defineProperty(exports, "B", {
|
|
3855
|
+
enumerable: !0,
|
|
3856
|
+
get: function() {
|
|
3857
|
+
return THEME_COLOR_CARD_TONES;
|
|
3858
|
+
}
|
|
3859
|
+
}), Object.defineProperty(exports, "C", {
|
|
3860
|
+
enumerable: !0,
|
|
3861
|
+
get: function() {
|
|
3862
|
+
return parseTokenKey;
|
|
3863
|
+
}
|
|
3864
|
+
}), Object.defineProperty(exports, "D", {
|
|
3865
|
+
enumerable: !0,
|
|
3866
|
+
get: function() {
|
|
3867
|
+
return COLOR_CONFIG_CARD_TONES;
|
|
3868
|
+
}
|
|
3869
|
+
}), Object.defineProperty(exports, "E", {
|
|
3870
|
+
enumerable: !0,
|
|
3871
|
+
get: function() {
|
|
3872
|
+
return COLOR_CONFIG_CARD_KEYS;
|
|
3873
|
+
}
|
|
3874
|
+
}), Object.defineProperty(exports, "F", {
|
|
3875
|
+
enumerable: !0,
|
|
3876
|
+
get: function() {
|
|
3877
|
+
return isColorHueKey;
|
|
3878
|
+
}
|
|
3879
|
+
}), Object.defineProperty(exports, "G", {
|
|
3880
|
+
enumerable: !0,
|
|
3881
|
+
get: function() {
|
|
3882
|
+
return THEME_COLOR_STATE_TONES;
|
|
3883
|
+
}
|
|
3884
|
+
}), Object.defineProperty(exports, "H", {
|
|
3885
|
+
enumerable: !0,
|
|
3886
|
+
get: function() {
|
|
3887
|
+
return THEME_COLOR_INPUT_STATES;
|
|
3888
|
+
}
|
|
3889
|
+
}), Object.defineProperty(exports, "I", {
|
|
3890
|
+
enumerable: !0,
|
|
3891
|
+
get: function() {
|
|
3892
|
+
return isColorTintKey;
|
|
3893
|
+
}
|
|
3894
|
+
}), Object.defineProperty(exports, "J", {
|
|
3895
|
+
enumerable: !0,
|
|
3896
|
+
get: function() {
|
|
3897
|
+
return is_v2;
|
|
3898
|
+
}
|
|
3899
|
+
}), Object.defineProperty(exports, "K", {
|
|
3900
|
+
enumerable: !0,
|
|
3901
|
+
get: function() {
|
|
3902
|
+
return v2_v0;
|
|
3903
|
+
}
|
|
3904
|
+
}), Object.defineProperty(exports, "L", {
|
|
3905
|
+
enumerable: !0,
|
|
3906
|
+
get: function() {
|
|
3907
|
+
return THEME_COLOR_AVATAR_COLORS;
|
|
3908
|
+
}
|
|
3909
|
+
}), Object.defineProperty(exports, "M", {
|
|
3910
|
+
enumerable: !0,
|
|
3911
|
+
get: function() {
|
|
3912
|
+
return COLOR_CONFIG_STATE_TONES;
|
|
3913
|
+
}
|
|
3914
|
+
}), Object.defineProperty(exports, "N", {
|
|
3915
|
+
enumerable: !0,
|
|
3916
|
+
get: function() {
|
|
3917
|
+
return isColorBlendModeValue;
|
|
3918
|
+
}
|
|
3919
|
+
}), Object.defineProperty(exports, "O", {
|
|
3920
|
+
enumerable: !0,
|
|
3921
|
+
get: function() {
|
|
3922
|
+
return COLOR_CONFIG_INPUT_MODES;
|
|
3923
|
+
}
|
|
3924
|
+
}), Object.defineProperty(exports, "P", {
|
|
3925
|
+
enumerable: !0,
|
|
3926
|
+
get: function() {
|
|
3927
|
+
return isColorButtonMode;
|
|
3928
|
+
}
|
|
3929
|
+
}), Object.defineProperty(exports, "R", {
|
|
3930
|
+
enumerable: !0,
|
|
3931
|
+
get: function() {
|
|
3932
|
+
return THEME_COLOR_BLEND_MODES;
|
|
3933
|
+
}
|
|
3934
|
+
}), Object.defineProperty(exports, "S", {
|
|
3935
|
+
enumerable: !0,
|
|
3936
|
+
get: function() {
|
|
3937
|
+
return parseTokenValue;
|
|
3938
|
+
}
|
|
3939
|
+
}), Object.defineProperty(exports, "T", {
|
|
3940
|
+
enumerable: !0,
|
|
3941
|
+
get: function() {
|
|
3942
|
+
return COLOR_CONFIG_BLEND_KEYS;
|
|
3943
|
+
}
|
|
3944
|
+
}), Object.defineProperty(exports, "U", {
|
|
3945
|
+
enumerable: !0,
|
|
3946
|
+
get: function() {
|
|
3947
|
+
return THEME_COLOR_SCHEMES;
|
|
3948
|
+
}
|
|
3949
|
+
}), Object.defineProperty(exports, "V", {
|
|
3950
|
+
enumerable: !0,
|
|
3951
|
+
get: function() {
|
|
3952
|
+
return THEME_COLOR_INPUT_MODES;
|
|
3953
|
+
}
|
|
3954
|
+
}), Object.defineProperty(exports, "W", {
|
|
3955
|
+
enumerable: !0,
|
|
3956
|
+
get: function() {
|
|
3957
|
+
return THEME_COLOR_STATES;
|
|
3958
|
+
}
|
|
3959
|
+
}), Object.defineProperty(exports, "X", {
|
|
3960
|
+
enumerable: !0,
|
|
3961
|
+
get: function() {
|
|
3962
|
+
return getTheme_v2;
|
|
3963
|
+
}
|
|
3964
|
+
}), Object.defineProperty(exports, "Y", {
|
|
3965
|
+
enumerable: !0,
|
|
3966
|
+
get: function() {
|
|
3967
|
+
return is_v0;
|
|
3968
|
+
}
|
|
3969
|
+
}), Object.defineProperty(exports, "Z", {
|
|
3970
|
+
enumerable: !0,
|
|
3971
|
+
get: function() {
|
|
3972
|
+
return createColorTheme;
|
|
3973
|
+
}
|
|
3974
|
+
}), Object.defineProperty(exports, "_", {
|
|
3975
|
+
enumerable: !0,
|
|
3976
|
+
get: function() {
|
|
3977
|
+
return isColorConfigStateKey;
|
|
3978
|
+
}
|
|
3979
|
+
}), Object.defineProperty(exports, "a", {
|
|
3980
|
+
enumerable: !0,
|
|
3981
|
+
get: function() {
|
|
3982
|
+
return parseColor;
|
|
3983
|
+
}
|
|
3984
|
+
}), Object.defineProperty(exports, "b", {
|
|
3985
|
+
enumerable: !0,
|
|
3986
|
+
get: function() {
|
|
3987
|
+
return isColorTokenValue;
|
|
3988
|
+
}
|
|
3989
|
+
}), Object.defineProperty(exports, "c", {
|
|
3990
|
+
enumerable: !0,
|
|
3991
|
+
get: function() {
|
|
3992
|
+
return rgbToHex;
|
|
3993
|
+
}
|
|
3994
|
+
}), Object.defineProperty(exports, "d", {
|
|
3995
|
+
enumerable: !0,
|
|
3996
|
+
get: function() {
|
|
3997
|
+
return screen;
|
|
3998
|
+
}
|
|
3999
|
+
}), Object.defineProperty(exports, "f", {
|
|
4000
|
+
enumerable: !0,
|
|
4001
|
+
get: function() {
|
|
4002
|
+
return multiply;
|
|
4003
|
+
}
|
|
4004
|
+
}), Object.defineProperty(exports, "g", {
|
|
4005
|
+
enumerable: !0,
|
|
4006
|
+
get: function() {
|
|
4007
|
+
return isColorConfigBlendKey;
|
|
4008
|
+
}
|
|
4009
|
+
}), Object.defineProperty(exports, "h", {
|
|
4010
|
+
enumerable: !0,
|
|
4011
|
+
get: function() {
|
|
4012
|
+
return isColorConfigBaseTone;
|
|
4013
|
+
}
|
|
4014
|
+
}), Object.defineProperty(exports, "i", {
|
|
4015
|
+
enumerable: !0,
|
|
4016
|
+
get: function() {
|
|
4017
|
+
return getContrastRatio;
|
|
4018
|
+
}
|
|
4019
|
+
}), Object.defineProperty(exports, "j", {
|
|
4020
|
+
enumerable: !0,
|
|
4021
|
+
get: function() {
|
|
4022
|
+
return COLOR_CONFIG_STATE_KEYS;
|
|
4023
|
+
}
|
|
4024
|
+
}), Object.defineProperty(exports, "k", {
|
|
4025
|
+
enumerable: !0,
|
|
4026
|
+
get: function() {
|
|
4027
|
+
return COLOR_CONFIG_INPUT_STATES;
|
|
4028
|
+
}
|
|
4029
|
+
}), Object.defineProperty(exports, "l", {
|
|
4030
|
+
enumerable: !0,
|
|
4031
|
+
get: function() {
|
|
4032
|
+
return rgbToHsl;
|
|
4033
|
+
}
|
|
4034
|
+
}), Object.defineProperty(exports, "m", {
|
|
4035
|
+
enumerable: !0,
|
|
4036
|
+
get: function() {
|
|
4037
|
+
return isColorConfigBaseKey;
|
|
4038
|
+
}
|
|
4039
|
+
}), Object.defineProperty(exports, "n", {
|
|
4040
|
+
enumerable: !0,
|
|
4041
|
+
get: function() {
|
|
4042
|
+
return buildTheme;
|
|
4043
|
+
}
|
|
4044
|
+
}), Object.defineProperty(exports, "o", {
|
|
4045
|
+
enumerable: !0,
|
|
4046
|
+
get: function() {
|
|
4047
|
+
return hexToRgb;
|
|
4048
|
+
}
|
|
4049
|
+
}), Object.defineProperty(exports, "p", {
|
|
4050
|
+
enumerable: !0,
|
|
4051
|
+
get: function() {
|
|
4052
|
+
return mix;
|
|
4053
|
+
}
|
|
4054
|
+
}), Object.defineProperty(exports, "q", {
|
|
4055
|
+
enumerable: !0,
|
|
4056
|
+
get: function() {
|
|
4057
|
+
return v0_v2;
|
|
4058
|
+
}
|
|
4059
|
+
}), Object.defineProperty(exports, "r", {
|
|
4060
|
+
enumerable: !0,
|
|
4061
|
+
get: function() {
|
|
4062
|
+
return rgba;
|
|
4063
|
+
}
|
|
4064
|
+
}), Object.defineProperty(exports, "s", {
|
|
4065
|
+
enumerable: !0,
|
|
4066
|
+
get: function() {
|
|
4067
|
+
return hslToRgb;
|
|
4068
|
+
}
|
|
4069
|
+
}), Object.defineProperty(exports, "t", {
|
|
4070
|
+
enumerable: !0,
|
|
4071
|
+
get: function() {
|
|
4072
|
+
return getScopedTheme;
|
|
4073
|
+
}
|
|
4074
|
+
}), Object.defineProperty(exports, "u", {
|
|
4075
|
+
enumerable: !0,
|
|
4076
|
+
get: function() {
|
|
4077
|
+
return rgbaToRGBA;
|
|
4078
|
+
}
|
|
4079
|
+
}), Object.defineProperty(exports, "v", {
|
|
4080
|
+
enumerable: !0,
|
|
4081
|
+
get: function() {
|
|
4082
|
+
return isColorConfigStateTone;
|
|
4083
|
+
}
|
|
4084
|
+
}), Object.defineProperty(exports, "w", {
|
|
4085
|
+
enumerable: !0,
|
|
4086
|
+
get: function() {
|
|
4087
|
+
return COLOR_CONFIG_AVATAR_COLORS;
|
|
4088
|
+
}
|
|
4089
|
+
}), Object.defineProperty(exports, "x", {
|
|
4090
|
+
enumerable: !0,
|
|
4091
|
+
get: function() {
|
|
4092
|
+
return isColorValue;
|
|
4093
|
+
}
|
|
4094
|
+
}), Object.defineProperty(exports, "y", {
|
|
4095
|
+
enumerable: !0,
|
|
4096
|
+
get: function() {
|
|
4097
|
+
return isColorOpacityValue;
|
|
4098
|
+
}
|
|
4099
|
+
}), Object.defineProperty(exports, "z", {
|
|
4100
|
+
enumerable: !0,
|
|
4101
|
+
get: function() {
|
|
4102
|
+
return THEME_COLOR_BUTTON_MODES;
|
|
4103
|
+
}
|
|
4104
|
+
});
|