@choco-vanille/theme 0.0.0-stage → 0.1.0-dev.1
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/LICENSE +21 -0
- package/README.md +216 -2
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2743 -0
- package/dist/index.d.ts +2743 -0
- package/dist/index.js +18 -0
- package/dist/styles.css +2 -0
- package/dist/theme/constants/index.cjs +2 -0
- package/dist/theme/constants/index.cjs.map +1 -0
- package/dist/theme/constants/index.js +9 -0
- package/dist/theme/constants/index.js.map +1 -0
- package/dist/theme/flavors/contrast/constants/index.cjs +2 -0
- package/dist/theme/flavors/contrast/constants/index.cjs.map +1 -0
- package/dist/theme/flavors/contrast/constants/index.js +58 -0
- package/dist/theme/flavors/contrast/constants/index.js.map +1 -0
- package/dist/theme/flavors/contrast/contrastFlavor.const.cjs +2 -0
- package/dist/theme/flavors/contrast/contrastFlavor.const.cjs.map +1 -0
- package/dist/theme/flavors/contrast/contrastFlavor.const.js +149 -0
- package/dist/theme/flavors/contrast/contrastFlavor.const.js.map +1 -0
- package/dist/theme/flavors/contrast/utils/createContrastIntents.utils.cjs +2 -0
- package/dist/theme/flavors/contrast/utils/createContrastIntents.utils.cjs.map +1 -0
- package/dist/theme/flavors/contrast/utils/createContrastIntents.utils.js +20 -0
- package/dist/theme/flavors/contrast/utils/createContrastIntents.utils.js.map +1 -0
- package/dist/theme/flavors/default/constants/index.cjs +2 -0
- package/dist/theme/flavors/default/constants/index.cjs.map +1 -0
- package/dist/theme/flavors/default/constants/index.js +58 -0
- package/dist/theme/flavors/default/constants/index.js.map +1 -0
- package/dist/theme/flavors/default/defaultDarkTheme.const.cjs +2 -0
- package/dist/theme/flavors/default/defaultDarkTheme.const.cjs.map +1 -0
- package/dist/theme/flavors/default/defaultDarkTheme.const.js +93 -0
- package/dist/theme/flavors/default/defaultDarkTheme.const.js.map +1 -0
- package/dist/theme/flavors/default/defaultFlavor.const.cjs +2 -0
- package/dist/theme/flavors/default/defaultFlavor.const.cjs.map +1 -0
- package/dist/theme/flavors/default/defaultFlavor.const.js +12 -0
- package/dist/theme/flavors/default/defaultFlavor.const.js.map +1 -0
- package/dist/theme/flavors/default/defaultLightTheme.const.cjs +2 -0
- package/dist/theme/flavors/default/defaultLightTheme.const.cjs.map +1 -0
- package/dist/theme/flavors/default/defaultLightTheme.const.js +93 -0
- package/dist/theme/flavors/default/defaultLightTheme.const.js.map +1 -0
- package/dist/theme/flavors/neutral/neutralFlavor.const.cjs +2 -0
- package/dist/theme/flavors/neutral/neutralFlavor.const.cjs.map +1 -0
- package/dist/theme/flavors/neutral/neutralFlavor.const.js +32 -0
- package/dist/theme/flavors/neutral/neutralFlavor.const.js.map +1 -0
- package/dist/theme/hooks/viewport/use-breakpoint/useBreakpoint.hook.cjs +2 -0
- package/dist/theme/hooks/viewport/use-breakpoint/useBreakpoint.hook.cjs.map +1 -0
- package/dist/theme/hooks/viewport/use-breakpoint/useBreakpoint.hook.js +11 -0
- package/dist/theme/hooks/viewport/use-breakpoint/useBreakpoint.hook.js.map +1 -0
- package/dist/theme/hooks/viewport/use-breakpoint/utils/mediaQueryStore.utils.cjs +2 -0
- package/dist/theme/hooks/viewport/use-breakpoint/utils/mediaQueryStore.utils.cjs.map +1 -0
- package/dist/theme/hooks/viewport/use-breakpoint/utils/mediaQueryStore.utils.js +20 -0
- package/dist/theme/hooks/viewport/use-breakpoint/utils/mediaQueryStore.utils.js.map +1 -0
- package/dist/theme/styles/themes.css.cjs +1 -0
- package/dist/theme/styles/themes.css.js +1 -0
- package/dist/theme/styles/vars.css.cjs +2 -0
- package/dist/theme/styles/vars.css.cjs.map +1 -0
- package/dist/theme/styles/vars.css.js +366 -0
- package/dist/theme/styles/vars.css.js.map +1 -0
- package/dist/theme/theme-provider/ThemeProvider.cjs +2 -0
- package/dist/theme/theme-provider/ThemeProvider.cjs.map +1 -0
- package/dist/theme/theme-provider/ThemeProvider.css.cjs +2 -0
- package/dist/theme/theme-provider/ThemeProvider.css.cjs.map +1 -0
- package/dist/theme/theme-provider/ThemeProvider.css.js +6 -0
- package/dist/theme/theme-provider/ThemeProvider.css.js.map +1 -0
- package/dist/theme/theme-provider/ThemeProvider.js +45 -0
- package/dist/theme/theme-provider/ThemeProvider.js.map +1 -0
- package/dist/theme/theme-provider/constants/index.cjs +2 -0
- package/dist/theme/theme-provider/constants/index.cjs.map +1 -0
- package/dist/theme/theme-provider/constants/index.js +13 -0
- package/dist/theme/theme-provider/constants/index.js.map +1 -0
- package/dist/theme/theme-provider/contexts/FlavorRegistryContext.cjs +2 -0
- package/dist/theme/theme-provider/contexts/FlavorRegistryContext.cjs.map +1 -0
- package/dist/theme/theme-provider/contexts/FlavorRegistryContext.js +6 -0
- package/dist/theme/theme-provider/contexts/FlavorRegistryContext.js.map +1 -0
- package/dist/theme/theme-provider/contexts/ThemeContext.cjs +2 -0
- package/dist/theme/theme-provider/contexts/ThemeContext.cjs.map +1 -0
- package/dist/theme/theme-provider/contexts/ThemeContext.js +6 -0
- package/dist/theme/theme-provider/contexts/ThemeContext.js.map +1 -0
- package/dist/theme/theme-provider/contexts/ThemeSetterContext.cjs +2 -0
- package/dist/theme/theme-provider/contexts/ThemeSetterContext.cjs.map +1 -0
- package/dist/theme/theme-provider/contexts/ThemeSetterContext.js +6 -0
- package/dist/theme/theme-provider/contexts/ThemeSetterContext.js.map +1 -0
- package/dist/theme/theme-provider/hooks/use-controllable-selection/useControllableSelection.hook.cjs +2 -0
- package/dist/theme/theme-provider/hooks/use-controllable-selection/useControllableSelection.hook.cjs.map +1 -0
- package/dist/theme/theme-provider/hooks/use-controllable-selection/useControllableSelection.hook.js +41 -0
- package/dist/theme/theme-provider/hooks/use-controllable-selection/useControllableSelection.hook.js.map +1 -0
- package/dist/theme/theme-provider/hooks/use-document-scope/useDocumentScope.hook.cjs +2 -0
- package/dist/theme/theme-provider/hooks/use-document-scope/useDocumentScope.hook.cjs.map +1 -0
- package/dist/theme/theme-provider/hooks/use-document-scope/useDocumentScope.hook.js +30 -0
- package/dist/theme/theme-provider/hooks/use-document-scope/useDocumentScope.hook.js.map +1 -0
- package/dist/theme/theme-provider/hooks/use-flavor-registry/useFlavorRegistry.hook.cjs +2 -0
- package/dist/theme/theme-provider/hooks/use-flavor-registry/useFlavorRegistry.hook.cjs.map +1 -0
- package/dist/theme/theme-provider/hooks/use-flavor-registry/useFlavorRegistry.hook.js +30 -0
- package/dist/theme/theme-provider/hooks/use-flavor-registry/useFlavorRegistry.hook.js.map +1 -0
- package/dist/theme/theme-provider/hooks/use-flavor-registry/utils/areFlavorListsEqual.utils.cjs +2 -0
- package/dist/theme/theme-provider/hooks/use-flavor-registry/utils/areFlavorListsEqual.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/hooks/use-flavor-registry/utils/areFlavorListsEqual.utils.js +5 -0
- package/dist/theme/theme-provider/hooks/use-flavor-registry/utils/areFlavorListsEqual.utils.js.map +1 -0
- package/dist/theme/theme-provider/hooks/use-theme-provider/useThemeProvider.hook.cjs +2 -0
- package/dist/theme/theme-provider/hooks/use-theme-provider/useThemeProvider.hook.cjs.map +1 -0
- package/dist/theme/theme-provider/hooks/use-theme-provider/useThemeProvider.hook.js +80 -0
- package/dist/theme/theme-provider/hooks/use-theme-provider/useThemeProvider.hook.js.map +1 -0
- package/dist/theme/theme-provider/hooks/use-token-styles/useTokenStyles.hook.cjs +2 -0
- package/dist/theme/theme-provider/hooks/use-token-styles/useTokenStyles.hook.cjs.map +1 -0
- package/dist/theme/theme-provider/hooks/use-token-styles/useTokenStyles.hook.js +11 -0
- package/dist/theme/theme-provider/hooks/use-token-styles/useTokenStyles.hook.js.map +1 -0
- package/dist/theme/theme-provider/hooks/use-token-styles/utils/areTokenStylesEqual.utils.cjs +2 -0
- package/dist/theme/theme-provider/hooks/use-token-styles/utils/areTokenStylesEqual.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/hooks/use-token-styles/utils/areTokenStylesEqual.utils.js +8 -0
- package/dist/theme/theme-provider/hooks/use-token-styles/utils/areTokenStylesEqual.utils.js.map +1 -0
- package/dist/theme/theme-provider/hooks/useResolvedTheme.hook.cjs +2 -0
- package/dist/theme/theme-provider/hooks/useResolvedTheme.hook.cjs.map +1 -0
- package/dist/theme/theme-provider/hooks/useResolvedTheme.hook.js +13 -0
- package/dist/theme/theme-provider/hooks/useResolvedTheme.hook.js.map +1 -0
- package/dist/theme/theme-provider/hooks/useSetTheme.hook.cjs +2 -0
- package/dist/theme/theme-provider/hooks/useSetTheme.hook.cjs.map +1 -0
- package/dist/theme/theme-provider/hooks/useSetTheme.hook.js +11 -0
- package/dist/theme/theme-provider/hooks/useSetTheme.hook.js.map +1 -0
- package/dist/theme/theme-provider/hooks/useTheme.hook.cjs +2 -0
- package/dist/theme/theme-provider/hooks/useTheme.hook.cjs.map +1 -0
- package/dist/theme/theme-provider/hooks/useTheme.hook.js +11 -0
- package/dist/theme/theme-provider/hooks/useTheme.hook.js.map +1 -0
- package/dist/theme/theme-provider/utils/createFlavorValidator.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/createFlavorValidator.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/createFlavorValidator.utils.js +11 -0
- package/dist/theme/theme-provider/utils/createFlavorValidator.utils.js.map +1 -0
- package/dist/theme/theme-provider/utils/get-flavor-stylesheet/getFlavorStylesheet.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/get-flavor-stylesheet/getFlavorStylesheet.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/get-flavor-stylesheet/getFlavorStylesheet.utils.js +15 -0
- package/dist/theme/theme-provider/utils/get-flavor-stylesheet/getFlavorStylesheet.utils.js.map +1 -0
- package/dist/theme/theme-provider/utils/get-flavor-stylesheet/utils/hashString.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/get-flavor-stylesheet/utils/hashString.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/get-flavor-stylesheet/utils/hashString.utils.js +9 -0
- package/dist/theme/theme-provider/utils/get-flavor-stylesheet/utils/hashString.utils.js.map +1 -0
- package/dist/theme/theme-provider/utils/getReferencedFlavors.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/getReferencedFlavors.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/getReferencedFlavors.utils.js +6 -0
- package/dist/theme/theme-provider/utils/getReferencedFlavors.utils.js.map +1 -0
- package/dist/theme/theme-provider/utils/getServerSystemTheme.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/getServerSystemTheme.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/getServerSystemTheme.utils.js +5 -0
- package/dist/theme/theme-provider/utils/getServerSystemTheme.utils.js.map +1 -0
- package/dist/theme/theme-provider/utils/getSystemTheme.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/getSystemTheme.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/getSystemTheme.utils.js +6 -0
- package/dist/theme/theme-provider/utils/getSystemTheme.utils.js.map +1 -0
- package/dist/theme/theme-provider/utils/register-document-scope/registerDocumentScope.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/register-document-scope/registerDocumentScope.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/register-document-scope/registerDocumentScope.utils.js +33 -0
- package/dist/theme/theme-provider/utils/register-document-scope/registerDocumentScope.utils.js.map +1 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/applyDocumentScope.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/applyDocumentScope.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/applyDocumentScope.utils.js +16 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/applyDocumentScope.utils.js.map +1 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/syncAttribute.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/syncAttribute.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/syncAttribute.utils.js +7 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/syncAttribute.utils.js.map +1 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/syncProperty.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/syncProperty.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/syncProperty.utils.js +7 -0
- package/dist/theme/theme-provider/utils/register-document-scope/utils/syncProperty.utils.js.map +1 -0
- package/dist/theme/theme-provider/utils/subscribeToNothing.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/subscribeToNothing.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/subscribeToNothing.utils.js +5 -0
- package/dist/theme/theme-provider/utils/subscribeToNothing.utils.js.map +1 -0
- package/dist/theme/theme-provider/utils/subscribeToSystemTheme.utils.cjs +2 -0
- package/dist/theme/theme-provider/utils/subscribeToSystemTheme.utils.cjs.map +1 -0
- package/dist/theme/theme-provider/utils/subscribeToSystemTheme.utils.js +10 -0
- package/dist/theme/theme-provider/utils/subscribeToSystemTheme.utils.js.map +1 -0
- package/dist/theme/tokens/primitives/breakpoints.const.cjs +2 -0
- package/dist/theme/tokens/primitives/breakpoints.const.cjs.map +1 -0
- package/dist/theme/tokens/primitives/breakpoints.const.js +19 -0
- package/dist/theme/tokens/primitives/breakpoints.const.js.map +1 -0
- package/dist/theme/tokens/primitives/palette.const.cjs +2 -0
- package/dist/theme/tokens/primitives/palette.const.cjs.map +1 -0
- package/dist/theme/tokens/primitives/palette.const.js +602 -0
- package/dist/theme/tokens/primitives/palette.const.js.map +1 -0
- package/dist/theme/tokens/primitives/scales.const.cjs +2 -0
- package/dist/theme/tokens/primitives/scales.const.cjs.map +1 -0
- package/dist/theme/tokens/primitives/scales.const.js +125 -0
- package/dist/theme/tokens/primitives/scales.const.js.map +1 -0
- package/dist/theme/tokens/shared/sharedThemeTokens.const.cjs +2 -0
- package/dist/theme/tokens/shared/sharedThemeTokens.const.cjs.map +1 -0
- package/dist/theme/tokens/shared/sharedThemeTokens.const.js +21 -0
- package/dist/theme/tokens/shared/sharedThemeTokens.const.js.map +1 -0
- package/dist/theme/utils/colors/create-accent/constants/index.cjs +2 -0
- package/dist/theme/utils/colors/create-accent/constants/index.cjs.map +1 -0
- package/dist/theme/utils/colors/create-accent/constants/index.js +9 -0
- package/dist/theme/utils/colors/create-accent/constants/index.js.map +1 -0
- package/dist/theme/utils/colors/create-accent/createAccent.utils.cjs +2 -0
- package/dist/theme/utils/colors/create-accent/createAccent.utils.cjs.map +1 -0
- package/dist/theme/utils/colors/create-accent/createAccent.utils.js +23 -0
- package/dist/theme/utils/colors/create-accent/createAccent.utils.js.map +1 -0
- package/dist/theme/utils/colors/mixColors.utils.cjs +2 -0
- package/dist/theme/utils/colors/mixColors.utils.cjs.map +1 -0
- package/dist/theme/utils/colors/mixColors.utils.js +12 -0
- package/dist/theme/utils/colors/mixColors.utils.js.map +1 -0
- package/dist/theme/utils/flavors/collect-flavor-styles/collectFlavorStyles.utils.cjs +2 -0
- package/dist/theme/utils/flavors/collect-flavor-styles/collectFlavorStyles.utils.cjs.map +1 -0
- package/dist/theme/utils/flavors/collect-flavor-styles/collectFlavorStyles.utils.js +24 -0
- package/dist/theme/utils/flavors/collect-flavor-styles/collectFlavorStyles.utils.js.map +1 -0
- package/dist/theme/utils/flavors/constants/index.cjs +2 -0
- package/dist/theme/utils/flavors/constants/index.cjs.map +1 -0
- package/dist/theme/utils/flavors/constants/index.js +6 -0
- package/dist/theme/utils/flavors/constants/index.js.map +1 -0
- package/dist/theme/utils/flavors/createFlavor.utils.cjs +2 -0
- package/dist/theme/utils/flavors/createFlavor.utils.cjs.map +1 -0
- package/dist/theme/utils/flavors/createFlavor.utils.js +20 -0
- package/dist/theme/utils/flavors/createFlavor.utils.js.map +1 -0
- package/dist/theme/utils/flavors/get-flavor-css/getFlavorCss.utils.cjs +3 -0
- package/dist/theme/utils/flavors/get-flavor-css/getFlavorCss.utils.cjs.map +1 -0
- package/dist/theme/utils/flavors/get-flavor-css/getFlavorCss.utils.js +19 -0
- package/dist/theme/utils/flavors/get-flavor-css/getFlavorCss.utils.js.map +1 -0
- package/dist/theme/utils/flavors/get-flavor-css/utils/get-flavor-selectors/getFlavorSelectors.utils.cjs +2 -0
- package/dist/theme/utils/flavors/get-flavor-css/utils/get-flavor-selectors/getFlavorSelectors.utils.cjs.map +1 -0
- package/dist/theme/utils/flavors/get-flavor-css/utils/get-flavor-selectors/getFlavorSelectors.utils.js +13 -0
- package/dist/theme/utils/flavors/get-flavor-css/utils/get-flavor-selectors/getFlavorSelectors.utils.js.map +1 -0
- package/dist/theme/utils/flavors/get-flavor-css/utils/serializeDeclarations.utils.cjs +2 -0
- package/dist/theme/utils/flavors/get-flavor-css/utils/serializeDeclarations.utils.cjs.map +1 -0
- package/dist/theme/utils/flavors/get-flavor-css/utils/serializeDeclarations.utils.js +5 -0
- package/dist/theme/utils/flavors/get-flavor-css/utils/serializeDeclarations.utils.js.map +1 -0
- package/dist/theme/utils/flavors/getFlavorReferenceName.utils.cjs +2 -0
- package/dist/theme/utils/flavors/getFlavorReferenceName.utils.cjs.map +1 -0
- package/dist/theme/utils/flavors/getFlavorReferenceName.utils.js +6 -0
- package/dist/theme/utils/flavors/getFlavorReferenceName.utils.js.map +1 -0
- package/dist/theme/utils/guards/isRecord.utils.cjs +2 -0
- package/dist/theme/utils/guards/isRecord.utils.cjs.map +1 -0
- package/dist/theme/utils/guards/isRecord.utils.js +5 -0
- package/dist/theme/utils/guards/isRecord.utils.js.map +1 -0
- package/dist/theme/utils/server-rendering/get-theme-root-props/getThemeRootProps.utils.cjs +2 -0
- package/dist/theme/utils/server-rendering/get-theme-root-props/getThemeRootProps.utils.cjs.map +1 -0
- package/dist/theme/utils/server-rendering/get-theme-root-props/getThemeRootProps.utils.js +14 -0
- package/dist/theme/utils/server-rendering/get-theme-root-props/getThemeRootProps.utils.js.map +1 -0
- package/dist/theme/utils/tokens/assertCompleteTheme.utils.cjs +2 -0
- package/dist/theme/utils/tokens/assertCompleteTheme.utils.cjs.map +1 -0
- package/dist/theme/utils/tokens/assertCompleteTheme.utils.js +9 -0
- package/dist/theme/utils/tokens/assertCompleteTheme.utils.js.map +1 -0
- package/dist/theme/utils/tokens/collect-token-styles/collectTokenStyles.utils.cjs +2 -0
- package/dist/theme/utils/tokens/collect-token-styles/collectTokenStyles.utils.cjs.map +1 -0
- package/dist/theme/utils/tokens/collect-token-styles/collectTokenStyles.utils.js +25 -0
- package/dist/theme/utils/tokens/collect-token-styles/collectTokenStyles.utils.js.map +1 -0
- package/dist/theme/utils/tokens/create-theme-tokens/createThemeTokens.utils.cjs +2 -0
- package/dist/theme/utils/tokens/create-theme-tokens/createThemeTokens.utils.cjs.map +1 -0
- package/dist/theme/utils/tokens/create-theme-tokens/createThemeTokens.utils.js +12 -0
- package/dist/theme/utils/tokens/create-theme-tokens/createThemeTokens.utils.js.map +1 -0
- package/dist/theme/utils/tokens/create-theme-tokens/utils/mergeTokens.utils.cjs +2 -0
- package/dist/theme/utils/tokens/create-theme-tokens/utils/mergeTokens.utils.cjs.map +1 -0
- package/dist/theme/utils/tokens/create-theme-tokens/utils/mergeTokens.utils.js +9 -0
- package/dist/theme/utils/tokens/create-theme-tokens/utils/mergeTokens.utils.js.map +1 -0
- package/dist/theme/utils/tokens/getSharedTokenStyles.utils.cjs +2 -0
- package/dist/theme/utils/tokens/getSharedTokenStyles.utils.cjs.map +1 -0
- package/dist/theme/utils/tokens/getSharedTokenStyles.utils.js +12 -0
- package/dist/theme/utils/tokens/getSharedTokenStyles.utils.js.map +1 -0
- package/dist/theme/utils/tokens/getThemeTokenStyles.utils.cjs +2 -0
- package/dist/theme/utils/tokens/getThemeTokenStyles.utils.cjs.map +1 -0
- package/dist/theme/utils/tokens/getThemeTokenStyles.utils.js +12 -0
- package/dist/theme/utils/tokens/getThemeTokenStyles.utils.js.map +1 -0
- package/dist/theme/utils/validation/assertFlavorName.utils.cjs +2 -0
- package/dist/theme/utils/validation/assertFlavorName.utils.cjs.map +1 -0
- package/dist/theme/utils/validation/assertFlavorName.utils.js +10 -0
- package/dist/theme/utils/validation/assertFlavorName.utils.js.map +1 -0
- package/dist/theme/utils/validation/assertThemeName.utils.cjs +2 -0
- package/dist/theme/utils/validation/assertThemeName.utils.cjs.map +1 -0
- package/dist/theme/utils/validation/assertThemeName.utils.js +9 -0
- package/dist/theme/utils/validation/assertThemeName.utils.js.map +1 -0
- package/package.json +83 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useControllableSelection.hook.js","names":["useControllableSelection","isControlled","controlledValue","inheritedSelection","defaultValue","parent","initialProps","useState","propNames","internalValue","setInternalValue","validate","fallbackValue","ownValue","value","snapshot","latest","useRef","setValue","useCallback","current","nextValue","requestedValue"],"sources":["../../../../../src/theme/theme-provider/hooks/use-controllable-selection/useControllableSelection.hook.ts"],"sourcesContent":["import { useCallback, useLayoutEffect, useRef, useState } from 'react';\n\nimport type {\n UseControllableSelectionOptions,\n UseControllableSelectionResult,\n} from '@theme/theme-provider/hooks/use-controllable-selection/types';\nimport type { ThemeSetter } from '@theme/theme-provider/types';\n\n/**\n * Selects a value of the provider, its theme or its flavor: the parent's\n * when neither the controlled nor the default prop is given, otherwise the\n * controlled prop or the internal state seeded by the default prop. Like\n * React inputs, a provider picks its mode once, at mount.\n *\n * @param options Props of the selection and its parent.\n * @param options.controlledValue Controlled prop.\n * @param options.defaultValue Uncontrolled prop.\n * @param options.fallbackValue Value of a root provider without props.\n * @param options.parent Selection of the closest parent provider.\n * @param options.onChange Listener of accepted or requested changes.\n * @param options.validate Validator of every received value.\n * @param options.propNames Names of the props, quoted in error messages.\n * @returns The value, its origin and a setter whose identity never changes.\n * @throws {TypeError} When `validate` rejects a value, including in the\n * setter.\n * @throws {Error} When the provider switches between controlled and\n * uncontrolled, or when the default prop changes after mount.\n */\nexport const useControllableSelection = ({\n controlledValue,\n defaultValue,\n fallbackValue,\n parent,\n onChange,\n validate,\n propNames,\n}: UseControllableSelectionOptions): UseControllableSelectionResult => {\n const isControlled = controlledValue !== undefined;\n const inheritedSelection =\n controlledValue === undefined && defaultValue === undefined\n ? parent\n : undefined;\n const [initialProps] = useState({ isControlled, defaultValue });\n if (isControlled !== initialProps.isControlled) {\n throw new Error(\n `A ThemeProvider cannot switch between controlled and uncontrolled: keep \\`${propNames.value}\\` always defined or always undefined.`,\n );\n }\n if (!isControlled && defaultValue !== initialProps.defaultValue) {\n throw new Error(\n `\\`${propNames.defaultValue}\\` cannot change after mount: it only seeds the initial value. Use \\`${propNames.value}\\` to change it from outside.`,\n );\n }\n\n const [internalValue, setInternalValue] = useState(() =>\n validate(defaultValue ?? fallbackValue, propNames.defaultValue),\n );\n const ownValue =\n controlledValue === undefined\n ? internalValue\n : validate(controlledValue, propNames.value);\n const value = inheritedSelection?.value ?? ownValue;\n\n const snapshot = {\n value,\n isControlled,\n onChange,\n validate,\n parentSetValue: inheritedSelection?.setValue,\n };\n const latest = useRef(snapshot);\n useLayoutEffect(() => {\n latest.current = snapshot;\n });\n\n const setValue = useCallback<ThemeSetter>(\n (requestedValue) => {\n const current = latest.current;\n const nextValue = current.validate(\n requestedValue,\n propNames.setter,\n );\n if (current.parentSetValue) {\n // The parent owns the value: it compares against its latest one,\n // and nothing here would reset a change it does not commit.\n if (!current.parentSetValue(nextValue)) {\n return false;\n }\n } else {\n if (nextValue === current.value) {\n return false;\n }\n if (!current.isControlled) {\n setInternalValue(nextValue);\n // The change only commits after the event: later calls in the\n // same event must compare against it, not the rendered value.\n latest.current = { ...current, value: nextValue };\n }\n }\n current.onChange?.(nextValue);\n return true;\n },\n [propNames.setter],\n );\n\n return {\n value,\n isInherited: inheritedSelection !== undefined,\n setValue,\n };\n};\n"],"mappings":";;AA4BA,IAAaA,KAA4B,EACrC,oBACA,iBACA,kBACA,WACA,aACA,aACA,mBACmE;CACnE,IAAMC,IAAeC,MAAoB,KAAA,GACnCC,IACFD,MAAoB,KAAA,KAAaE,MAAiB,KAAA,IAC5CC,IACA,KAAA,GACJ,CAACC,KAAgBC,EAAS;EAAE;EAAc;CAAa,CAAC;CAC9D,IAAIN,MAAiBK,EAAa,cAC9B,MAAU,MACN,6EAA6EE,EAAU,MAAM,uCACjG;CAEJ,IAAI,CAACP,KAAgBG,MAAiBE,EAAa,cAC/C,MAAU,MACN,KAAKE,EAAU,aAAa,uEAAuEA,EAAU,MAAM,8BACvH;CAGJ,IAAM,CAACC,GAAeC,KAAoBH,QACtCI,EAASP,KAAgBQ,GAAeJ,EAAU,YAAY,CAClE,GACMK,IACFX,MAAoB,KAAA,IACdO,IACAE,EAAST,GAAiBM,EAAU,KAAK,GAC7CM,IAAQX,GAAoB,SAASU,GAErCE,IAAW;EACb;EACA;EACA;EACA;EACA,gBAAgBZ,GAAoB;CACxC,GACMa,IAASC,EAAOF,CAAQ;CAC9B,QAAsB;EAClB,EAAO,UAAUA;CACrB,CAAC;CAED,IAAMG,IAAWC,GACZ,MAAmB;EAChB,IAAMC,IAAUJ,EAAO,SACjBK,IAAYD,EAAQ,SACtBE,GACAd,EAAU,MACd;EACA,IAAIY,EAAQ,gBAGJ;OAAA,CAACA,EAAQ,eAAeC,CAAS,GACjC,OAAO;EAAA,OAER;GACH,IAAIA,MAAcD,EAAQ,OACtB,OAAO;GAEX,AAAKA,EAAQ,iBACTV,EAAiBW,CAAS,GAG1B,EAAO,UAAU;IAAE,GAAGD;IAAS,OAAOC;GAAU;EAExD;EAEA,OADAD,EAAQ,WAAWC,CAAS,GACrB;CACX,GACA,CAACb,EAAU,MAAM,CACrB;CAEA,OAAO;EACH;EACA,aAAaL,MAAuB,KAAA;EACpC;CACJ;AACJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../utils/register-document-scope/registerDocumentScope.utils.cjs");let t=require("react");var n=({isEnabled:n,theme:r,flavor:i,styles:a})=>{let o=(0,t.useRef)(null);(0,t.useLayoutEffect)(()=>{if(!n)return;let t=e.registerDocumentScope(document.documentElement);return o.current=t,()=>{o.current=null,t.release()}},[n]),(0,t.useLayoutEffect)(()=>{if(n){if(o.current===null)throw Error(`The document scope must be registered before updates.`);o.current.update({theme:r,flavor:i,styles:a})}},[n,r,i,a])};exports.useDocumentScope=n;
|
|
2
|
+
//# sourceMappingURL=useDocumentScope.hook.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDocumentScope.hook.cjs","names":["useRef","registerDocumentScope","require_registerDocumentScope_utils","react","useDocumentScope","registration","isEnabled","current","theme","flavor","styles"],"sources":["../../../../../src/theme/theme-provider/hooks/use-document-scope/useDocumentScope.hook.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react';\n\nimport type { UseDocumentScopeOptions } from '@theme/theme-provider/hooks/use-document-scope/types';\nimport { registerDocumentScope } from '@theme/theme-provider/utils/register-document-scope/registerDocumentScope.utils';\nimport type { DocumentScopeRegistration } from '@theme/theme-provider/utils/register-document-scope/types';\n\n/**\n * Mirrors the provider's theme, flavor and custom properties on `<html>`\n * while enabled. The registration is released on cleanup, which restores the\n * state found before the provider, or the state of the providers mounted\n * before it.\n *\n * @param options Document state of the provider.\n * @param options.isEnabled Whether the provider themes the document.\n * @param options.theme Theme name written to `<html>`.\n * @param options.flavor Flavor name written to `<html>`.\n * @param options.styles Custom properties written to `<html>`.\n * @throws {Error} When an update runs without a registration.\n */\nexport const useDocumentScope = ({\n isEnabled,\n theme,\n flavor,\n styles,\n}: UseDocumentScopeOptions): void => {\n const registration = useRef<DocumentScopeRegistration | null>(null);\n\n useLayoutEffect(() => {\n if (!isEnabled) {\n return;\n }\n const current = registerDocumentScope(document.documentElement);\n registration.current = current;\n return () => {\n registration.current = null;\n current.release();\n };\n }, [isEnabled]);\n\n useLayoutEffect(() => {\n if (!isEnabled) {\n return;\n }\n if (registration.current === null) {\n throw new Error(\n 'The document scope must be registered before updates.',\n );\n }\n registration.current.update({ theme, flavor, styles });\n }, [isEnabled, theme, flavor, styles]);\n};\n"],"mappings":"A,8GAmBA,IAAaI,GAAoB,CAC7B,YACA,QACA,SACA,YACiC,CACjC,IAAMC,GAAA,EAAeL,EAAAA,OAAAA,CAAyC,IAAI,GAElE,EAAAG,EAAA,gBAAA,KAAsB,CAClB,GAAI,CAACG,EACD,OAEJ,IAAMC,EAAUN,EAAAA,sBAAsB,SAAS,eAAe,EAE9D,MADA,GAAa,QAAUM,MACV,CACT,EAAa,QAAU,KACvBA,EAAQ,QAAQ,CACpB,CACJ,EAAG,CAACD,CAAS,CAAC,GAEd,EAAAH,EAAA,gBAAA,KAAsB,CAClB,GAAKG,EAGL,IAAID,EAAa,UAAY,KACzB,MAAU,MACN,uDACJ,EAEJA,EAAa,QAAQ,OAAO,CAAE,QAAO,SAAQ,QAAO,CAAC,CAFjD,CAGR,EAAG,CAACC,EAAWE,EAAOC,EAAQC,CAAM,CAAC,CACzC,E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { registerDocumentScope as e } from "../../utils/register-document-scope/registerDocumentScope.utils.js";
|
|
2
|
+
import { useLayoutEffect as t, useRef as n } from "react";
|
|
3
|
+
// src/theme/theme-provider/hooks/use-document-scope/useDocumentScope.hook.ts
|
|
4
|
+
var r = ({ isEnabled: r, theme: i, flavor: a, styles: o }) => {
|
|
5
|
+
let s = n(null);
|
|
6
|
+
t(() => {
|
|
7
|
+
if (!r) return;
|
|
8
|
+
let t = e(document.documentElement);
|
|
9
|
+
return s.current = t, () => {
|
|
10
|
+
s.current = null, t.release();
|
|
11
|
+
};
|
|
12
|
+
}, [r]), t(() => {
|
|
13
|
+
if (r) {
|
|
14
|
+
if (s.current === null) throw Error("The document scope must be registered before updates.");
|
|
15
|
+
s.current.update({
|
|
16
|
+
theme: i,
|
|
17
|
+
flavor: a,
|
|
18
|
+
styles: o
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}, [
|
|
22
|
+
r,
|
|
23
|
+
i,
|
|
24
|
+
a,
|
|
25
|
+
o
|
|
26
|
+
]);
|
|
27
|
+
};
|
|
28
|
+
export { r as useDocumentScope };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=useDocumentScope.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDocumentScope.hook.js","names":["useDocumentScope","registration","useRef","useLayoutEffect","isEnabled","current","registerDocumentScope","theme","flavor","styles"],"sources":["../../../../../src/theme/theme-provider/hooks/use-document-scope/useDocumentScope.hook.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react';\n\nimport type { UseDocumentScopeOptions } from '@theme/theme-provider/hooks/use-document-scope/types';\nimport { registerDocumentScope } from '@theme/theme-provider/utils/register-document-scope/registerDocumentScope.utils';\nimport type { DocumentScopeRegistration } from '@theme/theme-provider/utils/register-document-scope/types';\n\n/**\n * Mirrors the provider's theme, flavor and custom properties on `<html>`\n * while enabled. The registration is released on cleanup, which restores the\n * state found before the provider, or the state of the providers mounted\n * before it.\n *\n * @param options Document state of the provider.\n * @param options.isEnabled Whether the provider themes the document.\n * @param options.theme Theme name written to `<html>`.\n * @param options.flavor Flavor name written to `<html>`.\n * @param options.styles Custom properties written to `<html>`.\n * @throws {Error} When an update runs without a registration.\n */\nexport const useDocumentScope = ({\n isEnabled,\n theme,\n flavor,\n styles,\n}: UseDocumentScopeOptions): void => {\n const registration = useRef<DocumentScopeRegistration | null>(null);\n\n useLayoutEffect(() => {\n if (!isEnabled) {\n return;\n }\n const current = registerDocumentScope(document.documentElement);\n registration.current = current;\n return () => {\n registration.current = null;\n current.release();\n };\n }, [isEnabled]);\n\n useLayoutEffect(() => {\n if (!isEnabled) {\n return;\n }\n if (registration.current === null) {\n throw new Error(\n 'The document scope must be registered before updates.',\n );\n }\n registration.current.update({ theme, flavor, styles });\n }, [isEnabled, theme, flavor, styles]);\n};\n"],"mappings":";;;AAmBA,IAAaA,KAAoB,EAC7B,cACA,UACA,WACA,gBACiC;CACjC,IAAMC,IAAeC,EAAyC,IAAI;CAclE,AAZAC,QAAsB;EAClB,IAAI,CAACC,GACD;EAEJ,IAAMC,IAAUC,EAAsB,SAAS,eAAe;EAE9D,OADA,EAAa,UAAUD,SACV;GAET,AADA,EAAa,UAAU,MACvBA,EAAQ,QAAQ;EACpB;CACJ,GAAG,CAACD,CAAS,CAAC,GAEdD,QAAsB;EAClB,IAAKC,GAGL;OAAIH,EAAa,YAAY,MACzB,MAAU,MACN,uDACJ;GAEJ,EAAa,QAAQ,OAAO;IAAE;IAAO;IAAQ;GAAO,CAAC;EAFjD;CAGR,GAAG;EAACG;EAAWG;EAAOC;EAAQC;CAAM,CAAC;AACzC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../../constants/index.cjs"),t=require("../../constants/index.cjs"),n=require("./utils/areFlavorListsEqual.utils.cjs"),r=require("../../utils/get-flavor-stylesheet/getFlavorStylesheet.utils.cjs");let i=require("react");var a=(a,o=t.noFlavors)=>{let[s,c]=(0,i.useState)(o),l=!n.areFlavorListsEqual(s,o);l&&c(o);let u=l?o:s;return(0,i.useMemo)(()=>{let t=new Map(a),n=[];for(let e of u){let i=r.getFlavorStylesheet(e),o=t.get(e.name);if(o!==e){if(e.name==="default"&&a!==void 0)throw TypeError(`Only a root ThemeProvider can replace the default flavor: select the default flavor by name in nested providers.`);if(o!==void 0)throw TypeError(`Two different flavors are named "${e.name}": give each flavor a unique name.`);t.set(e.name,e),n.push(i)}}return{registry:t,names:[e.defaultFlavorName,...[...t.keys()].filter(t=>t!==e.defaultFlavorName)],stylesheets:n}},[a,u])};exports.useFlavorRegistry=a;
|
|
2
|
+
//# sourceMappingURL=useFlavorRegistry.hook.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFlavorRegistry.hook.cjs","names":["noFlavors","useState","areFlavorListsEqual","useMemo","getFlavorStylesheet","defaultFlavorName","require_index","require_index$1","require_areFlavorListsEqual_utils","require_getFlavorStylesheet_utils","react","useFlavorRegistry","stableFlavors","setStableFlavors","flavors","hasChanged","ownFlavors","registry","parentRegistry","stylesheets","flavor","stylesheet","registered","name"],"sources":["../../../../../src/theme/theme-provider/hooks/use-flavor-registry/useFlavorRegistry.hook.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\n\nimport { defaultFlavorName } from '@theme/constants';\nimport { noFlavors } from '@theme/theme-provider/constants';\nimport type { UseFlavorRegistryResult } from '@theme/theme-provider/hooks/use-flavor-registry/types';\nimport { areFlavorListsEqual } from '@theme/theme-provider/hooks/use-flavor-registry/utils/areFlavorListsEqual.utils';\nimport type { FlavorRegistry } from '@theme/theme-provider/types';\nimport { getFlavorStylesheet } from '@theme/theme-provider/utils/get-flavor-stylesheet/getFlavorStylesheet.utils';\nimport type { FlavorStylesheet } from '@theme/theme-provider/utils/get-flavor-stylesheet/types';\nimport type { Flavor } from '@theme/types';\n\n/**\n * Adds the flavors of a provider to those of its ancestors. The result only\n * changes with the flavor objects, so inline `flavors={[…]}` arrays don't\n * re-render the consumers. A flavor already registered by an ancestor is\n * not styled again.\n *\n * @param parentRegistry Flavors of the parent providers; `undefined` at the\n * root.\n * @param flavors `flavors` prop; none when `undefined`.\n * @returns The registry, the selectable names and the stylesheets to render.\n * @throws {TypeError} When a flavor is malformed, two different flavors\n * share a name, or a nested provider replaces the default flavor.\n */\nexport const useFlavorRegistry = (\n parentRegistry: FlavorRegistry | undefined,\n flavors: readonly Flavor[] = noFlavors,\n): UseFlavorRegistryResult => {\n const [stableFlavors, setStableFlavors] = useState(flavors);\n const hasChanged = !areFlavorListsEqual(stableFlavors, flavors);\n\n if (hasChanged) {\n setStableFlavors(flavors);\n }\n\n const ownFlavors = hasChanged ? flavors : stableFlavors;\n\n return useMemo(() => {\n const registry = new Map(parentRegistry);\n const stylesheets: FlavorStylesheet[] = [];\n\n for (const flavor of ownFlavors) {\n const stylesheet = getFlavorStylesheet(flavor);\n const registered = registry.get(flavor.name);\n\n if (registered === flavor) {\n continue;\n }\n\n // Flavor stylesheets apply to the whole document: a nested\n // replacement of the default flavor would leak out of its subtree.\n if (\n flavor.name === defaultFlavorName &&\n parentRegistry !== undefined\n ) {\n throw new TypeError(\n 'Only a root ThemeProvider can replace the default flavor: select the default flavor by name in nested providers.',\n );\n }\n\n if (registered !== undefined) {\n throw new TypeError(\n `Two different flavors are named \"${flavor.name}\": give each flavor a unique name.`,\n );\n }\n\n registry.set(flavor.name, flavor);\n stylesheets.push(stylesheet);\n }\n\n const names = [\n defaultFlavorName,\n ...[...registry.keys()].filter(\n (name) => name !== defaultFlavorName,\n ),\n ];\n\n return { registry, names, stylesheets };\n }, [parentRegistry, ownFlavors]);\n};\n"],"mappings":"A,8OAwBA,IAAaW,GACT,EACA,EAA6BX,EAAAA,YACH,CAC1B,GAAM,CAACY,EAAeC,IAAA,EAAoBZ,EAAAA,SAAAA,CAASa,CAAO,EACpDC,EAAa,CAACb,EAAAA,oBAAoBU,EAAeE,CAAO,EAE1DC,GACAF,EAAiBC,CAAO,EAG5B,IAAME,EAAaD,EAAaD,EAAUF,EAE1C,OAAA,EAAOT,EAAAA,QAAAA,KAAc,CACjB,IAAMc,EAAW,IAAI,IAAIC,CAAc,EACjCC,EAAkC,CAAC,EAEzC,IAAK,IAAMC,KAAUJ,EAAY,CAC7B,IAAMK,EAAajB,EAAAA,oBAAoBgB,CAAM,EACvCE,EAAaL,EAAS,IAAIG,EAAO,IAAI,EAE3C,GAAIE,IAAeF,EAMnB,IACIA,EAAO,OAAA,WACPF,IAAmB,IAAA,GAEnB,MAAU,UACN,kHACJ,EAGJ,GAAII,IAAe,IAAA,GACf,MAAU,UACN,oCAAoCF,EAAO,KAAK,mCACpD,EAGJH,EAAS,IAAIG,EAAO,KAAMA,CAAM,EAChCD,EAAY,KAAKE,CAAU,CAVvB,CAWR,CASA,MAAO,CAAE,WAAU,MAAA,CANfhB,EAAAA,kBACA,GAAG,CAAC,GAAGY,EAAS,KAAK,CAAC,CAAC,CAAC,OACnB,GAASM,IAASlB,EAAAA,iBACvB,CAGe,EAAO,aAAY,CAC1C,EAAG,CAACa,EAAgBF,CAAU,CAAC,CACnC,E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defaultFlavorName as e } from "../../../constants/index.js";
|
|
2
|
+
import { noFlavors as t } from "../../constants/index.js";
|
|
3
|
+
import { areFlavorListsEqual as n } from "./utils/areFlavorListsEqual.utils.js";
|
|
4
|
+
import { getFlavorStylesheet as r } from "../../utils/get-flavor-stylesheet/getFlavorStylesheet.utils.js";
|
|
5
|
+
import { useMemo as i, useState as a } from "react";
|
|
6
|
+
// src/theme/theme-provider/hooks/use-flavor-registry/useFlavorRegistry.hook.ts
|
|
7
|
+
var o = (o, s = t) => {
|
|
8
|
+
let [c, l] = a(s), u = !n(c, s);
|
|
9
|
+
u && l(s);
|
|
10
|
+
let d = u ? s : c;
|
|
11
|
+
return i(() => {
|
|
12
|
+
let t = new Map(o), n = [];
|
|
13
|
+
for (let e of d) {
|
|
14
|
+
let i = r(e), a = t.get(e.name);
|
|
15
|
+
if (a !== e) {
|
|
16
|
+
if (e.name === "default" && o !== void 0) throw TypeError("Only a root ThemeProvider can replace the default flavor: select the default flavor by name in nested providers.");
|
|
17
|
+
if (a !== void 0) throw TypeError(`Two different flavors are named "${e.name}": give each flavor a unique name.`);
|
|
18
|
+
t.set(e.name, e), n.push(i);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
registry: t,
|
|
23
|
+
names: [e, ...[...t.keys()].filter((t) => t !== e)],
|
|
24
|
+
stylesheets: n
|
|
25
|
+
};
|
|
26
|
+
}, [o, d]);
|
|
27
|
+
};
|
|
28
|
+
export { o as useFlavorRegistry };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=useFlavorRegistry.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFlavorRegistry.hook.js","names":["useFlavorRegistry","noFlavors","stableFlavors","setStableFlavors","useState","flavors","hasChanged","areFlavorListsEqual","ownFlavors","useMemo","registry","parentRegistry","stylesheets","flavor","stylesheet","getFlavorStylesheet","registered","defaultFlavorName","name"],"sources":["../../../../../src/theme/theme-provider/hooks/use-flavor-registry/useFlavorRegistry.hook.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\n\nimport { defaultFlavorName } from '@theme/constants';\nimport { noFlavors } from '@theme/theme-provider/constants';\nimport type { UseFlavorRegistryResult } from '@theme/theme-provider/hooks/use-flavor-registry/types';\nimport { areFlavorListsEqual } from '@theme/theme-provider/hooks/use-flavor-registry/utils/areFlavorListsEqual.utils';\nimport type { FlavorRegistry } from '@theme/theme-provider/types';\nimport { getFlavorStylesheet } from '@theme/theme-provider/utils/get-flavor-stylesheet/getFlavorStylesheet.utils';\nimport type { FlavorStylesheet } from '@theme/theme-provider/utils/get-flavor-stylesheet/types';\nimport type { Flavor } from '@theme/types';\n\n/**\n * Adds the flavors of a provider to those of its ancestors. The result only\n * changes with the flavor objects, so inline `flavors={[…]}` arrays don't\n * re-render the consumers. A flavor already registered by an ancestor is\n * not styled again.\n *\n * @param parentRegistry Flavors of the parent providers; `undefined` at the\n * root.\n * @param flavors `flavors` prop; none when `undefined`.\n * @returns The registry, the selectable names and the stylesheets to render.\n * @throws {TypeError} When a flavor is malformed, two different flavors\n * share a name, or a nested provider replaces the default flavor.\n */\nexport const useFlavorRegistry = (\n parentRegistry: FlavorRegistry | undefined,\n flavors: readonly Flavor[] = noFlavors,\n): UseFlavorRegistryResult => {\n const [stableFlavors, setStableFlavors] = useState(flavors);\n const hasChanged = !areFlavorListsEqual(stableFlavors, flavors);\n\n if (hasChanged) {\n setStableFlavors(flavors);\n }\n\n const ownFlavors = hasChanged ? flavors : stableFlavors;\n\n return useMemo(() => {\n const registry = new Map(parentRegistry);\n const stylesheets: FlavorStylesheet[] = [];\n\n for (const flavor of ownFlavors) {\n const stylesheet = getFlavorStylesheet(flavor);\n const registered = registry.get(flavor.name);\n\n if (registered === flavor) {\n continue;\n }\n\n // Flavor stylesheets apply to the whole document: a nested\n // replacement of the default flavor would leak out of its subtree.\n if (\n flavor.name === defaultFlavorName &&\n parentRegistry !== undefined\n ) {\n throw new TypeError(\n 'Only a root ThemeProvider can replace the default flavor: select the default flavor by name in nested providers.',\n );\n }\n\n if (registered !== undefined) {\n throw new TypeError(\n `Two different flavors are named \"${flavor.name}\": give each flavor a unique name.`,\n );\n }\n\n registry.set(flavor.name, flavor);\n stylesheets.push(stylesheet);\n }\n\n const names = [\n defaultFlavorName,\n ...[...registry.keys()].filter(\n (name) => name !== defaultFlavorName,\n ),\n ];\n\n return { registry, names, stylesheets };\n }, [parentRegistry, ownFlavors]);\n};\n"],"mappings":";;;;;;AAwBA,IAAaA,KACT,GACA,IAA6BC,MACH;CAC1B,IAAM,CAACC,GAAeC,KAAoBC,EAASC,CAAO,GACpDC,IAAa,CAACC,EAAoBL,GAAeG,CAAO;CAE9D,AAAIC,KACAH,EAAiBE,CAAO;CAG5B,IAAMG,IAAaF,IAAaD,IAAUH;CAE1C,OAAOO,QAAc;EACjB,IAAMC,IAAW,IAAI,IAAIC,CAAc,GACjCC,IAAkC,CAAC;EAEzC,KAAK,IAAMC,KAAUL,GAAY;GAC7B,IAAMM,IAAaC,EAAoBF,CAAM,GACvCG,IAAaN,EAAS,IAAIG,EAAO,IAAI;GAE3C,IAAIG,MAAeH,GAMnB;QACIA,EAAO,SAAA,aACPF,MAAmB,KAAA,GAEnB,MAAU,UACN,kHACJ;IAGJ,IAAIK,MAAe,KAAA,GACf,MAAU,UACN,oCAAoCH,EAAO,KAAK,mCACpD;IAIJ,AADAH,EAAS,IAAIG,EAAO,MAAMA,CAAM,GAChCD,EAAY,KAAKE,CAAU;GAVvB;EAWR;EASA,OAAO;GAAE;GAAU,OAAA,CANfG,GACA,GAAG,CAAC,GAAGP,EAAS,KAAK,CAAC,CAAC,CAAC,QACnB,MAASQ,MAASD,CACvB,CAGe;GAAO;EAAY;CAC1C,GAAG,CAACN,GAAgBH,CAAU,CAAC;AACnC"}
|
package/dist/theme/theme-provider/hooks/use-flavor-registry/utils/areFlavorListsEqual.utils.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areFlavorListsEqual.utils.cjs","names":["areFlavorListsEqual","first","second","flavor","index"],"sources":["../../../../../../src/theme/theme-provider/hooks/use-flavor-registry/utils/areFlavorListsEqual.utils.ts"],"sourcesContent":["import type { Flavor } from '@theme/types';\n\n/**\n * Compares two flavor lists by the identity of their items.\n *\n * @param first Flavors to compare.\n * @param second Flavors to compare with.\n * @returns Whether both hold the same flavor objects in the same order.\n */\nexport const areFlavorListsEqual = (\n first: readonly Flavor[],\n second: readonly Flavor[],\n): boolean =>\n first.length === second.length &&\n first.every((flavor, index) => flavor === second[index]);\n"],"mappings":"AASA,IAAaA,GACT,EACA,IAEAC,EAAM,SAAWC,EAAO,QACxBD,EAAM,OAAO,EAAQ,IAAUE,IAAWD,EAAOE,EAAM,E"}
|
package/dist/theme/theme-provider/hooks/use-flavor-registry/utils/areFlavorListsEqual.utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areFlavorListsEqual.utils.js","names":["areFlavorListsEqual","first","second","flavor","index"],"sources":["../../../../../../src/theme/theme-provider/hooks/use-flavor-registry/utils/areFlavorListsEqual.utils.ts"],"sourcesContent":["import type { Flavor } from '@theme/types';\n\n/**\n * Compares two flavor lists by the identity of their items.\n *\n * @param first Flavors to compare.\n * @param second Flavors to compare with.\n * @returns Whether both hold the same flavor objects in the same order.\n */\nexport const areFlavorListsEqual = (\n first: readonly Flavor[],\n second: readonly Flavor[],\n): boolean =>\n first.length === second.length &&\n first.every((flavor, index) => flavor === second[index]);\n"],"mappings":";AASA,IAAaA,KACT,GACA,MAEAC,EAAM,WAAWC,EAAO,UACxBD,EAAM,OAAO,GAAQ,MAAUE,MAAWD,EAAOE,EAAM"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../../constants/index.cjs"),t=require("../../constants/index.cjs"),n=require("../../contexts/FlavorRegistryContext.cjs"),r=require("../../contexts/ThemeContext.cjs"),i=require("../use-controllable-selection/useControllableSelection.hook.cjs"),a=require("../use-document-scope/useDocumentScope.hook.cjs"),o=require("../use-flavor-registry/useFlavorRegistry.hook.cjs"),s=require("../use-token-styles/useTokenStyles.hook.cjs"),c=require("../useResolvedTheme.hook.cjs"),l=require("../../ThemeProvider.css.cjs"),u=require("../../utils/createFlavorValidator.utils.cjs"),d=require("../../utils/getReferencedFlavors.utils.cjs"),f=require("../../../utils/flavors/getFlavorReferenceName.utils.cjs"),p=require("../../../utils/validation/assertThemeName.utils.cjs");let m=require("react");var h=({controlledTheme:h,defaultTheme:g,controlledFlavor:_,defaultFlavor:v,flavors:y,scope:b,tokens:x,onThemeChange:S,onFlavorChange:C,className:w,style:T})=>{let E=(0,m.useContext)(r.ThemeContext),D=(0,m.useContext)(n.FlavorRegistryContext),O=(b??(E?`subtree`:`document`))===`document`,{registry:k,names:A,stylesheets:j}=o.useFlavorRegistry(D,d.getReferencedFlavors(y,[_,v])),M=(0,m.useMemo)(()=>u.createFlavorValidator(k),[k]),N=i.useControllableSelection({controlledValue:h,defaultValue:g,fallbackValue:e.defaultThemeName,parent:E&&{value:E.theme,setValue:E.setTheme},onChange:S,validate:p.assertThemeName,propNames:t.themePropNames}),P=i.useControllableSelection({controlledValue:f.getFlavorReferenceName(_),defaultValue:f.getFlavorReferenceName(v),fallbackValue:e.defaultFlavorName,parent:E&&{value:E.flavor,setValue:E.setFlavor},onChange:C,validate:M,propNames:t.flavorPropNames}),{value:F,setValue:I}=N,{value:L,setValue:R}=P,z=N.isInherited&&P.isInherited,B=c.useResolvedTheme(F),V=s.useTokenStyles(x);a.useDocumentScope({isEnabled:O,theme:F,flavor:L,styles:V});let H=(0,m.useMemo)(()=>({theme:F,resolvedTheme:B,setTheme:I,flavor:L,flavors:A,setFlavor:R}),[F,B,I,L,A,R]),U=[O?l.themeProviderStyles.documentWrapper:void 0,w].filter(e=>e!==void 0&&e!==``).join(` `)||void 0;return{context:H,setTheme:I,flavorRegistry:k,flavorStylesheets:j,rootAttributes:{[e.themeAttribute]:z?void 0:F,[e.flavorAttribute]:z?void 0:L},rootClassName:U,rootStyle:{...V,...T}}};exports.useThemeProvider=h;
|
|
2
|
+
//# sourceMappingURL=useThemeProvider.hook.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemeProvider.hook.cjs","names":["useContext","ThemeContext","FlavorRegistryContext","useFlavorRegistry","getReferencedFlavors","useMemo","createFlavorValidator","useControllableSelection","defaultThemeName","assertThemeName","themePropNames","getFlavorReferenceName","defaultFlavorName","flavorPropNames","useResolvedTheme","useTokenStyles","themeProviderStyles","themeAttribute","flavorAttribute","require_index","require_index$1","require_FlavorRegistryContext","require_ThemeContext","require_useControllableSelection_hook","require_useDocumentScope_hook","require_useFlavorRegistry_hook","require_useTokenStyles_hook","require_useResolvedTheme_hook","require_ThemeProvider_css","require_createFlavorValidator_utils","require_getReferencedFlavors_utils","require_getFlavorReferenceName_utils","require_assertThemeName_utils","react","useThemeProvider","requestedScope","parent","parentRegistry","isDocumentScope","flavorRegistry","flavorNames","flavorStylesheets","flavors","controlledFlavor","defaultFlavor","validateFlavor","themeSelection","controlledTheme","defaultTheme","onThemeChange","flavorSelection","onFlavorChange","theme","setTheme","flavor","setFlavor","isInherited","resolvedTheme","tokenStyles","tokens","context","rootClassName","className","name","style"],"sources":["../../../../../src/theme/theme-provider/hooks/use-theme-provider/useThemeProvider.hook.ts"],"sourcesContent":["import { useContext, useMemo } from 'react';\n\nimport {\n defaultFlavorName,\n defaultThemeName,\n flavorAttribute,\n themeAttribute,\n} from '@theme/constants';\nimport {\n flavorPropNames,\n themePropNames,\n} from '@theme/theme-provider/constants';\nimport { FlavorRegistryContext } from '@theme/theme-provider/contexts/FlavorRegistryContext';\nimport { ThemeContext } from '@theme/theme-provider/contexts/ThemeContext';\nimport { useControllableSelection } from '@theme/theme-provider/hooks/use-controllable-selection/useControllableSelection.hook';\nimport { useDocumentScope } from '@theme/theme-provider/hooks/use-document-scope/useDocumentScope.hook';\nimport { useFlavorRegistry } from '@theme/theme-provider/hooks/use-flavor-registry/useFlavorRegistry.hook';\nimport type {\n UseThemeProviderOptions,\n UseThemeProviderResult,\n} from '@theme/theme-provider/hooks/use-theme-provider/types';\nimport { useTokenStyles } from '@theme/theme-provider/hooks/use-token-styles/useTokenStyles.hook';\nimport { useResolvedTheme } from '@theme/theme-provider/hooks/useResolvedTheme.hook';\nimport { themeProviderStyles } from '@theme/theme-provider/ThemeProvider.css';\nimport { createFlavorValidator } from '@theme/theme-provider/utils/createFlavorValidator.utils';\nimport { getReferencedFlavors } from '@theme/theme-provider/utils/getReferencedFlavors.utils';\nimport { getFlavorReferenceName } from '@theme/utils/flavors/getFlavorReferenceName.utils';\nimport { assertThemeName } from '@theme/utils/validation/assertThemeName.utils';\n\n/**\n * Orchestrates a provider: registers its flavors, selects and resolves its\n * theme and flavor, converts its token overrides and, for the document\n * scope, mirrors everything on `<html>`. A root provider themes the document\n * by default, a nested one its subtree.\n *\n * @param options Props of the provider.\n * @param options.controlledTheme `theme` prop.\n * @param options.defaultTheme `defaultTheme` prop.\n * @param options.controlledFlavor `flavor` prop, a name or a flavor object\n * registered by this provider.\n * @param options.defaultFlavor `defaultFlavor` prop, a name or a flavor\n * object registered by this provider.\n * @param options.flavors `flavors` prop.\n * @param options.scope `scope` prop.\n * @param options.tokens `tokens` prop.\n * @param options.onThemeChange `onThemeChange` prop.\n * @param options.onFlavorChange `onFlavorChange` prop.\n * @param options.className Class of the consumer.\n * @param options.style Inline style of the consumer.\n * @returns The context values, the flavor stylesheets and the wrapper\n * attributes, class and style.\n * @throws {TypeError} When a theme name is empty, a flavor is malformed or\n * not registered, or a token is a color or space, unknown or malformed.\n * @throws {Error} When the provider changes mode after mount.\n */\nexport const useThemeProvider = ({\n controlledTheme,\n defaultTheme,\n controlledFlavor,\n defaultFlavor,\n flavors,\n scope: requestedScope,\n tokens,\n onThemeChange,\n onFlavorChange,\n className,\n style,\n}: UseThemeProviderOptions): UseThemeProviderResult => {\n const parent = useContext(ThemeContext);\n const parentRegistry = useContext(FlavorRegistryContext);\n const scope = requestedScope ?? (parent ? 'subtree' : 'document');\n const isDocumentScope = scope === 'document';\n const {\n registry: flavorRegistry,\n names: flavorNames,\n stylesheets: flavorStylesheets,\n } = useFlavorRegistry(\n parentRegistry,\n getReferencedFlavors(flavors, [controlledFlavor, defaultFlavor]),\n );\n const validateFlavor = useMemo(\n () => createFlavorValidator(flavorRegistry),\n [flavorRegistry],\n );\n const themeSelection = useControllableSelection({\n controlledValue: controlledTheme,\n defaultValue: defaultTheme,\n fallbackValue: defaultThemeName,\n parent: parent && { value: parent.theme, setValue: parent.setTheme },\n onChange: onThemeChange,\n validate: assertThemeName,\n propNames: themePropNames,\n });\n const flavorSelection = useControllableSelection({\n controlledValue: getFlavorReferenceName(controlledFlavor),\n defaultValue: getFlavorReferenceName(defaultFlavor),\n fallbackValue: defaultFlavorName,\n parent: parent && { value: parent.flavor, setValue: parent.setFlavor },\n onChange: onFlavorChange,\n validate: validateFlavor,\n propNames: flavorPropNames,\n });\n const { value: theme, setValue: setTheme } = themeSelection;\n const { value: flavor, setValue: setFlavor } = flavorSelection;\n // Inheriting both keeps the parent's themed variables and token overrides;\n // otherwise flavor and mode must share an element for flavor rules to match.\n const isInherited =\n themeSelection.isInherited && flavorSelection.isInherited;\n const resolvedTheme = useResolvedTheme(theme);\n const tokenStyles = useTokenStyles(tokens);\n\n useDocumentScope({\n isEnabled: isDocumentScope,\n theme,\n flavor,\n styles: tokenStyles,\n });\n\n const context = useMemo(\n () => ({\n theme,\n resolvedTheme,\n setTheme,\n flavor,\n flavors: flavorNames,\n setFlavor,\n }),\n [theme, resolvedTheme, setTheme, flavor, flavorNames, setFlavor],\n );\n\n const rootClassName =\n [\n isDocumentScope ? themeProviderStyles.documentWrapper : undefined,\n className,\n ]\n .filter((name) => name !== undefined && name !== '')\n .join(' ') || undefined;\n\n return {\n context,\n setTheme,\n flavorRegistry,\n flavorStylesheets,\n rootAttributes: {\n [themeAttribute]: isInherited ? undefined : theme,\n [flavorAttribute]: isInherited ? undefined : flavor,\n },\n rootClassName,\n rootStyle: { ...tokenStyles, ...style },\n };\n};\n"],"mappings":"A,6xBAuDA,IAAakC,GAAoB,CAC7B,kBACA,eACA,mBACA,gBACA,UACA,MAAOC,EACP,SACA,gBACA,iBACA,YACA,WACmD,CACnD,IAAMC,GAAA,EAASpC,EAAAA,WAAAA,CAAWC,EAAAA,YAAY,EAChCoC,GAAA,EAAiBrC,EAAAA,WAAAA,CAAWE,EAAAA,qBAAqB,EAEjDoC,GADQH,IAAmBC,EAAS,UAAY,eACpB,WAC5B,CACF,SAAUG,EACV,MAAOC,EACP,YAAaC,GACbtC,EAAAA,kBACAkC,EACAjC,EAAAA,qBAAqBsC,EAAS,CAACC,EAAkBC,CAAa,CAAC,CACnE,EACMC,GAAA,EAAiBxC,EAAAA,QAAAA,KACbC,EAAAA,sBAAsBiC,CAAc,EAC1C,CAACA,CAAc,CACnB,EACMO,EAAiBvC,EAAAA,yBAAyB,CAC5C,gBAAiBwC,EACjB,aAAcC,EACd,cAAexC,EAAAA,iBACf,OAAQ4B,GAAU,CAAE,MAAOA,EAAO,MAAO,SAAUA,EAAO,QAAS,EACnE,SAAUa,EACV,SAAUxC,EAAAA,gBACV,UAAWC,EAAAA,cACf,CAAC,EACKwC,EAAkB3C,EAAAA,yBAAyB,CAC7C,gBAAiBI,EAAAA,uBAAuBgC,CAAgB,EACxD,aAAchC,EAAAA,uBAAuBiC,CAAa,EAClD,cAAehC,EAAAA,kBACf,OAAQwB,GAAU,CAAE,MAAOA,EAAO,OAAQ,SAAUA,EAAO,SAAU,EACrE,SAAUe,EACV,SAAUN,EACV,UAAWhC,EAAAA,eACf,CAAC,EACK,CAAE,MAAOuC,EAAO,SAAUC,GAAaP,EACvC,CAAE,MAAOQ,EAAQ,SAAUC,GAAcL,EAGzCM,EACFV,EAAe,aAAeI,EAAgB,YAC5CO,EAAgB3C,EAAAA,iBAAiBsC,CAAK,EACtCM,EAAc3C,EAAAA,eAAe4C,CAAM,EAEzCnC,EAAA,iBAAiB,CACb,UAAWc,EACX,QACA,SACA,OAAQoB,CACZ,CAAC,EAED,IAAME,GAAA,EAAUvD,EAAAA,QAAAA,MACL,CACH,QACA,gBACA,WACA,SACA,QAASmC,EACT,WACJ,GACA,CAACY,EAAOK,EAAeJ,EAAUC,EAAQd,EAAae,CAAS,CACnE,EAEMM,EACF,CACIvB,EAAkBtB,EAAAA,oBAAoB,gBAAkB,IAAA,GACxD8C,CACJ,CAAC,CACI,OAAQ,GAASC,IAAS,IAAA,IAAaA,IAAS,EAAE,CAAC,CACnD,KAAK,GAAG,GAAK,IAAA,GAEtB,MAAO,CACH,UACA,WACA,iBACA,oBACA,eAAgB,EACX9C,EAAAA,gBAAiBuC,EAAc,IAAA,GAAYJ,GAC3ClC,EAAAA,iBAAkBsC,EAAc,IAAA,GAAYF,CACjD,EACA,gBACA,UAAW,CAAE,GAAGI,EAAa,GAAGM,CAAM,CAC1C,CACJ,E"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { defaultFlavorName as e, defaultThemeName as t, flavorAttribute as n, themeAttribute as r } from "../../../constants/index.js";
|
|
2
|
+
import { flavorPropNames as i, themePropNames as a } from "../../constants/index.js";
|
|
3
|
+
import { FlavorRegistryContext as o } from "../../contexts/FlavorRegistryContext.js";
|
|
4
|
+
import { ThemeContext as s } from "../../contexts/ThemeContext.js";
|
|
5
|
+
import { useControllableSelection as c } from "../use-controllable-selection/useControllableSelection.hook.js";
|
|
6
|
+
import { useDocumentScope as l } from "../use-document-scope/useDocumentScope.hook.js";
|
|
7
|
+
import { useFlavorRegistry as u } from "../use-flavor-registry/useFlavorRegistry.hook.js";
|
|
8
|
+
import { useTokenStyles as d } from "../use-token-styles/useTokenStyles.hook.js";
|
|
9
|
+
import { useResolvedTheme as f } from "../useResolvedTheme.hook.js";
|
|
10
|
+
import { themeProviderStyles as p } from "../../ThemeProvider.css.js";
|
|
11
|
+
import { createFlavorValidator as m } from "../../utils/createFlavorValidator.utils.js";
|
|
12
|
+
import { getReferencedFlavors as h } from "../../utils/getReferencedFlavors.utils.js";
|
|
13
|
+
import { getFlavorReferenceName as g } from "../../../utils/flavors/getFlavorReferenceName.utils.js";
|
|
14
|
+
import { assertThemeName as _ } from "../../../utils/validation/assertThemeName.utils.js";
|
|
15
|
+
import { useContext as v, useMemo as y } from "react";
|
|
16
|
+
// src/theme/theme-provider/hooks/use-theme-provider/useThemeProvider.hook.ts
|
|
17
|
+
var b = ({ controlledTheme: b, defaultTheme: x, controlledFlavor: S, defaultFlavor: C, flavors: w, scope: T, tokens: E, onThemeChange: D, onFlavorChange: O, className: k, style: A }) => {
|
|
18
|
+
let j = v(s), M = v(o), N = (T ?? (j ? "subtree" : "document")) === "document", { registry: P, names: F, stylesheets: I } = u(M, h(w, [S, C])), L = y(() => m(P), [P]), R = c({
|
|
19
|
+
controlledValue: b,
|
|
20
|
+
defaultValue: x,
|
|
21
|
+
fallbackValue: t,
|
|
22
|
+
parent: j && {
|
|
23
|
+
value: j.theme,
|
|
24
|
+
setValue: j.setTheme
|
|
25
|
+
},
|
|
26
|
+
onChange: D,
|
|
27
|
+
validate: _,
|
|
28
|
+
propNames: a
|
|
29
|
+
}), z = c({
|
|
30
|
+
controlledValue: g(S),
|
|
31
|
+
defaultValue: g(C),
|
|
32
|
+
fallbackValue: e,
|
|
33
|
+
parent: j && {
|
|
34
|
+
value: j.flavor,
|
|
35
|
+
setValue: j.setFlavor
|
|
36
|
+
},
|
|
37
|
+
onChange: O,
|
|
38
|
+
validate: L,
|
|
39
|
+
propNames: i
|
|
40
|
+
}), { value: B, setValue: V } = R, { value: H, setValue: U } = z, W = R.isInherited && z.isInherited, G = f(B), K = d(E);
|
|
41
|
+
l({
|
|
42
|
+
isEnabled: N,
|
|
43
|
+
theme: B,
|
|
44
|
+
flavor: H,
|
|
45
|
+
styles: K
|
|
46
|
+
});
|
|
47
|
+
let q = y(() => ({
|
|
48
|
+
theme: B,
|
|
49
|
+
resolvedTheme: G,
|
|
50
|
+
setTheme: V,
|
|
51
|
+
flavor: H,
|
|
52
|
+
flavors: F,
|
|
53
|
+
setFlavor: U
|
|
54
|
+
}), [
|
|
55
|
+
B,
|
|
56
|
+
G,
|
|
57
|
+
V,
|
|
58
|
+
H,
|
|
59
|
+
F,
|
|
60
|
+
U
|
|
61
|
+
]), J = [N ? p.documentWrapper : void 0, k].filter((e) => e !== void 0 && e !== "").join(" ") || void 0;
|
|
62
|
+
return {
|
|
63
|
+
context: q,
|
|
64
|
+
setTheme: V,
|
|
65
|
+
flavorRegistry: P,
|
|
66
|
+
flavorStylesheets: I,
|
|
67
|
+
rootAttributes: {
|
|
68
|
+
[r]: W ? void 0 : B,
|
|
69
|
+
[n]: W ? void 0 : H
|
|
70
|
+
},
|
|
71
|
+
rootClassName: J,
|
|
72
|
+
rootStyle: {
|
|
73
|
+
...K,
|
|
74
|
+
...A
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export { b as useThemeProvider };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=useThemeProvider.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemeProvider.hook.js","names":["useThemeProvider","requestedScope","parent","useContext","ThemeContext","parentRegistry","FlavorRegistryContext","isDocumentScope","flavorRegistry","flavorNames","flavorStylesheets","useFlavorRegistry","getReferencedFlavors","flavors","controlledFlavor","defaultFlavor","validateFlavor","useMemo","createFlavorValidator","themeSelection","useControllableSelection","controlledTheme","defaultTheme","defaultThemeName","onThemeChange","assertThemeName","themePropNames","flavorSelection","getFlavorReferenceName","defaultFlavorName","onFlavorChange","flavorPropNames","theme","setTheme","flavor","setFlavor","isInherited","resolvedTheme","useResolvedTheme","tokenStyles","useTokenStyles","tokens","context","rootClassName","themeProviderStyles","className","name","themeAttribute","flavorAttribute","style"],"sources":["../../../../../src/theme/theme-provider/hooks/use-theme-provider/useThemeProvider.hook.ts"],"sourcesContent":["import { useContext, useMemo } from 'react';\n\nimport {\n defaultFlavorName,\n defaultThemeName,\n flavorAttribute,\n themeAttribute,\n} from '@theme/constants';\nimport {\n flavorPropNames,\n themePropNames,\n} from '@theme/theme-provider/constants';\nimport { FlavorRegistryContext } from '@theme/theme-provider/contexts/FlavorRegistryContext';\nimport { ThemeContext } from '@theme/theme-provider/contexts/ThemeContext';\nimport { useControllableSelection } from '@theme/theme-provider/hooks/use-controllable-selection/useControllableSelection.hook';\nimport { useDocumentScope } from '@theme/theme-provider/hooks/use-document-scope/useDocumentScope.hook';\nimport { useFlavorRegistry } from '@theme/theme-provider/hooks/use-flavor-registry/useFlavorRegistry.hook';\nimport type {\n UseThemeProviderOptions,\n UseThemeProviderResult,\n} from '@theme/theme-provider/hooks/use-theme-provider/types';\nimport { useTokenStyles } from '@theme/theme-provider/hooks/use-token-styles/useTokenStyles.hook';\nimport { useResolvedTheme } from '@theme/theme-provider/hooks/useResolvedTheme.hook';\nimport { themeProviderStyles } from '@theme/theme-provider/ThemeProvider.css';\nimport { createFlavorValidator } from '@theme/theme-provider/utils/createFlavorValidator.utils';\nimport { getReferencedFlavors } from '@theme/theme-provider/utils/getReferencedFlavors.utils';\nimport { getFlavorReferenceName } from '@theme/utils/flavors/getFlavorReferenceName.utils';\nimport { assertThemeName } from '@theme/utils/validation/assertThemeName.utils';\n\n/**\n * Orchestrates a provider: registers its flavors, selects and resolves its\n * theme and flavor, converts its token overrides and, for the document\n * scope, mirrors everything on `<html>`. A root provider themes the document\n * by default, a nested one its subtree.\n *\n * @param options Props of the provider.\n * @param options.controlledTheme `theme` prop.\n * @param options.defaultTheme `defaultTheme` prop.\n * @param options.controlledFlavor `flavor` prop, a name or a flavor object\n * registered by this provider.\n * @param options.defaultFlavor `defaultFlavor` prop, a name or a flavor\n * object registered by this provider.\n * @param options.flavors `flavors` prop.\n * @param options.scope `scope` prop.\n * @param options.tokens `tokens` prop.\n * @param options.onThemeChange `onThemeChange` prop.\n * @param options.onFlavorChange `onFlavorChange` prop.\n * @param options.className Class of the consumer.\n * @param options.style Inline style of the consumer.\n * @returns The context values, the flavor stylesheets and the wrapper\n * attributes, class and style.\n * @throws {TypeError} When a theme name is empty, a flavor is malformed or\n * not registered, or a token is a color or space, unknown or malformed.\n * @throws {Error} When the provider changes mode after mount.\n */\nexport const useThemeProvider = ({\n controlledTheme,\n defaultTheme,\n controlledFlavor,\n defaultFlavor,\n flavors,\n scope: requestedScope,\n tokens,\n onThemeChange,\n onFlavorChange,\n className,\n style,\n}: UseThemeProviderOptions): UseThemeProviderResult => {\n const parent = useContext(ThemeContext);\n const parentRegistry = useContext(FlavorRegistryContext);\n const scope = requestedScope ?? (parent ? 'subtree' : 'document');\n const isDocumentScope = scope === 'document';\n const {\n registry: flavorRegistry,\n names: flavorNames,\n stylesheets: flavorStylesheets,\n } = useFlavorRegistry(\n parentRegistry,\n getReferencedFlavors(flavors, [controlledFlavor, defaultFlavor]),\n );\n const validateFlavor = useMemo(\n () => createFlavorValidator(flavorRegistry),\n [flavorRegistry],\n );\n const themeSelection = useControllableSelection({\n controlledValue: controlledTheme,\n defaultValue: defaultTheme,\n fallbackValue: defaultThemeName,\n parent: parent && { value: parent.theme, setValue: parent.setTheme },\n onChange: onThemeChange,\n validate: assertThemeName,\n propNames: themePropNames,\n });\n const flavorSelection = useControllableSelection({\n controlledValue: getFlavorReferenceName(controlledFlavor),\n defaultValue: getFlavorReferenceName(defaultFlavor),\n fallbackValue: defaultFlavorName,\n parent: parent && { value: parent.flavor, setValue: parent.setFlavor },\n onChange: onFlavorChange,\n validate: validateFlavor,\n propNames: flavorPropNames,\n });\n const { value: theme, setValue: setTheme } = themeSelection;\n const { value: flavor, setValue: setFlavor } = flavorSelection;\n // Inheriting both keeps the parent's themed variables and token overrides;\n // otherwise flavor and mode must share an element for flavor rules to match.\n const isInherited =\n themeSelection.isInherited && flavorSelection.isInherited;\n const resolvedTheme = useResolvedTheme(theme);\n const tokenStyles = useTokenStyles(tokens);\n\n useDocumentScope({\n isEnabled: isDocumentScope,\n theme,\n flavor,\n styles: tokenStyles,\n });\n\n const context = useMemo(\n () => ({\n theme,\n resolvedTheme,\n setTheme,\n flavor,\n flavors: flavorNames,\n setFlavor,\n }),\n [theme, resolvedTheme, setTheme, flavor, flavorNames, setFlavor],\n );\n\n const rootClassName =\n [\n isDocumentScope ? themeProviderStyles.documentWrapper : undefined,\n className,\n ]\n .filter((name) => name !== undefined && name !== '')\n .join(' ') || undefined;\n\n return {\n context,\n setTheme,\n flavorRegistry,\n flavorStylesheets,\n rootAttributes: {\n [themeAttribute]: isInherited ? undefined : theme,\n [flavorAttribute]: isInherited ? undefined : flavor,\n },\n rootClassName,\n rootStyle: { ...tokenStyles, ...style },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAuDA,IAAaA,KAAoB,EAC7B,oBACA,iBACA,qBACA,kBACA,YACA,OAAOC,GACP,WACA,kBACA,mBACA,cACA,eACmD;CACnD,IAAMC,IAASC,EAAWC,CAAY,GAChCC,IAAiBF,EAAWG,CAAqB,GAEjDC,KADQN,MAAmBC,IAAS,YAAY,iBACpB,YAC5B,EACF,UAAUM,GACV,OAAOC,GACP,aAAaC,MACbC,EACAN,GACAO,EAAqBC,GAAS,CAACC,GAAkBC,CAAa,CAAC,CACnE,GACMC,IAAiBC,QACbC,EAAsBV,CAAc,GAC1C,CAACA,CAAc,CACnB,GACMW,IAAiBC,EAAyB;EAC5C,iBAAiBC;EACjB,cAAcC;EACd,eAAeC;EACf,QAAQrB,KAAU;GAAE,OAAOA,EAAO;GAAO,UAAUA,EAAO;EAAS;EACnE,UAAUsB;EACV,UAAUC;EACV,WAAWC;CACf,CAAC,GACKC,IAAkBP,EAAyB;EAC7C,iBAAiBQ,EAAuBd,CAAgB;EACxD,cAAcc,EAAuBb,CAAa;EAClD,eAAec;EACf,QAAQ3B,KAAU;GAAE,OAAOA,EAAO;GAAQ,UAAUA,EAAO;EAAU;EACrE,UAAU4B;EACV,UAAUd;EACV,WAAWe;CACf,CAAC,GACK,EAAE,OAAOC,GAAO,UAAUC,MAAad,GACvC,EAAE,OAAOe,GAAQ,UAAUC,MAAcR,GAGzCS,IACFjB,EAAe,eAAeQ,EAAgB,aAC5CU,IAAgBC,EAAiBN,CAAK,GACtCO,IAAcC,EAAeC,CAAM;CAEzC,EAAiB;EACb,WAAWlC;EACX;EACA;EACA,QAAQgC;CACZ,CAAC;CAED,IAAMG,IAAUzB,SACL;EACH;EACA;EACA;EACA;EACA,SAASR;EACT;CACJ,IACA;EAACuB;EAAOK;EAAeJ;EAAUC;EAAQzB;EAAa0B;CAAS,CACnE,GAEMQ,IACF,CACIpC,IAAkBqC,EAAoB,kBAAkB,KAAA,GACxDC,CACJ,CAAC,CACI,QAAQ,MAASC,MAAS,KAAA,KAAaA,MAAS,EAAE,CAAC,CACnD,KAAK,GAAG,KAAK,KAAA;CAEtB,OAAO;EACH;EACA;EACA;EACA;EACA,gBAAgB;IACXC,IAAiBX,IAAc,KAAA,IAAYJ;IAC3CgB,IAAkBZ,IAAc,KAAA,IAAYF;EACjD;EACA;EACA,WAAW;GAAE,GAAGK;GAAa,GAAGU;EAAM;CAC1C;AACJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./utils/areTokenStylesEqual.utils.cjs"),t=require("../../../utils/tokens/getSharedTokenStyles.utils.cjs");let n=require("react");var r=r=>{let i=(0,n.useMemo)(()=>t.getSharedTokenStyles(r),[r]),[a,o]=(0,n.useState)(i),s=!e.areTokenStylesEqual(a,i);return s&&o(i),s?i:a};exports.useTokenStyles=r;
|
|
2
|
+
//# sourceMappingURL=useTokenStyles.hook.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTokenStyles.hook.cjs","names":["useMemo","getSharedTokenStyles","useState","areTokenStylesEqual","require_areTokenStylesEqual_utils","require_getSharedTokenStyles_utils","react","useTokenStyles","styles","tokens","stableStyles","setStableStyles","hasChanged"],"sources":["../../../../../src/theme/theme-provider/hooks/use-token-styles/useTokenStyles.hook.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\n\nimport { areTokenStylesEqual } from '@theme/theme-provider/hooks/use-token-styles/utils/areTokenStylesEqual.utils';\nimport type { SharedTokenOverrides, TokenStyles } from '@theme/types';\nimport { getSharedTokenStyles } from '@theme/utils/tokens/getSharedTokenStyles.utils';\n\n/**\n * Converts mode-independent token overrides into custom properties whose\n * identity only changes with their content, so inline `tokens={{ … }}`\n * objects don't trigger DOM writes on every render.\n *\n * @param tokens Token overrides of the provider; none when `undefined`.\n * @returns The custom properties of the overrides.\n * @throws {TypeError} When a token is a color or space, unknown or\n * malformed.\n */\nexport const useTokenStyles = (\n tokens: SharedTokenOverrides | undefined,\n): TokenStyles => {\n const styles = useMemo(() => getSharedTokenStyles(tokens), [tokens]);\n const [stableStyles, setStableStyles] = useState(styles);\n const hasChanged = !areTokenStylesEqual(stableStyles, styles);\n if (hasChanged) {\n setStableStyles(styles);\n }\n return hasChanged ? styles : stableStyles;\n};\n"],"mappings":"A,kJAgBA,IAAaO,EACT,GACc,CACd,IAAMC,GAAA,EAASR,EAAAA,QAAAA,KAAcC,EAAAA,qBAAqBQ,CAAM,EAAG,CAACA,CAAM,CAAC,EAC7D,CAACC,EAAcC,IAAA,EAAmBT,EAAAA,SAAAA,CAASM,CAAM,EACjDI,EAAa,CAACT,EAAAA,oBAAoBO,EAAcF,CAAM,EAI5D,OAHII,GACAD,EAAgBH,CAAM,EAEnBI,EAAaJ,EAASE,CACjC,E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { areTokenStylesEqual as e } from "./utils/areTokenStylesEqual.utils.js";
|
|
2
|
+
import { getSharedTokenStyles as t } from "../../../utils/tokens/getSharedTokenStyles.utils.js";
|
|
3
|
+
import { useMemo as n, useState as r } from "react";
|
|
4
|
+
// src/theme/theme-provider/hooks/use-token-styles/useTokenStyles.hook.ts
|
|
5
|
+
var i = (i) => {
|
|
6
|
+
let a = n(() => t(i), [i]), [o, s] = r(a), c = !e(o, a);
|
|
7
|
+
return c && s(a), c ? a : o;
|
|
8
|
+
};
|
|
9
|
+
export { i as useTokenStyles };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=useTokenStyles.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTokenStyles.hook.js","names":["useTokenStyles","styles","useMemo","getSharedTokenStyles","tokens","stableStyles","setStableStyles","useState","hasChanged","areTokenStylesEqual"],"sources":["../../../../../src/theme/theme-provider/hooks/use-token-styles/useTokenStyles.hook.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\n\nimport { areTokenStylesEqual } from '@theme/theme-provider/hooks/use-token-styles/utils/areTokenStylesEqual.utils';\nimport type { SharedTokenOverrides, TokenStyles } from '@theme/types';\nimport { getSharedTokenStyles } from '@theme/utils/tokens/getSharedTokenStyles.utils';\n\n/**\n * Converts mode-independent token overrides into custom properties whose\n * identity only changes with their content, so inline `tokens={{ … }}`\n * objects don't trigger DOM writes on every render.\n *\n * @param tokens Token overrides of the provider; none when `undefined`.\n * @returns The custom properties of the overrides.\n * @throws {TypeError} When a token is a color or space, unknown or\n * malformed.\n */\nexport const useTokenStyles = (\n tokens: SharedTokenOverrides | undefined,\n): TokenStyles => {\n const styles = useMemo(() => getSharedTokenStyles(tokens), [tokens]);\n const [stableStyles, setStableStyles] = useState(styles);\n const hasChanged = !areTokenStylesEqual(stableStyles, styles);\n if (hasChanged) {\n setStableStyles(styles);\n }\n return hasChanged ? styles : stableStyles;\n};\n"],"mappings":";;;;AAgBA,IAAaA,KACT,MACc;CACd,IAAMC,IAASC,QAAcC,EAAqBC,CAAM,GAAG,CAACA,CAAM,CAAC,GAC7D,CAACC,GAAcC,KAAmBC,EAASN,CAAM,GACjDO,IAAa,CAACC,EAAoBJ,GAAcJ,CAAM;CAI5D,OAHIO,KACAF,EAAgBL,CAAM,GAEnBO,IAAaP,IAASI;AACjC"}
|
package/dist/theme/theme-provider/hooks/use-token-styles/utils/areTokenStylesEqual.utils.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areTokenStylesEqual.utils.cjs","names":["areTokenStylesEqual","firstEntries","first","second","name","value"],"sources":["../../../../../../src/theme/theme-provider/hooks/use-token-styles/utils/areTokenStylesEqual.utils.ts"],"sourcesContent":["import type { TokenStyles } from '@theme/types';\n\n/**\n * Compares two sets of custom properties by content.\n *\n * @param first Custom properties to compare.\n * @param second Custom properties to compare with.\n * @returns Whether both declare the same properties with the same values.\n */\nexport const areTokenStylesEqual = (\n first: TokenStyles,\n second: TokenStyles,\n): boolean => {\n const firstEntries = Object.entries(first);\n return (\n firstEntries.length === Object.keys(second).length &&\n firstEntries.every(\n ([name, value]) =>\n Object.hasOwn(second, name) && second[name] === value,\n )\n );\n};\n"],"mappings":"AASA,IAAaA,GACT,EACA,IACU,CACV,IAAMC,EAAe,OAAO,QAAQC,CAAK,EACzC,OACID,EAAa,SAAW,OAAO,KAAKE,CAAM,CAAC,CAAC,QAC5CF,EAAa,OACR,CAACG,EAAMC,KACJ,OAAO,OAAOF,EAAQC,CAAI,GAAKD,EAAOC,KAAUC,CACxD,CAER,E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// src/theme/theme-provider/hooks/use-token-styles/utils/areTokenStylesEqual.utils.ts
|
|
2
|
+
var e = (e, t) => {
|
|
3
|
+
let n = Object.entries(e);
|
|
4
|
+
return n.length === Object.keys(t).length && n.every(([e, n]) => Object.hasOwn(t, e) && t[e] === n);
|
|
5
|
+
};
|
|
6
|
+
export { e as areTokenStylesEqual };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=areTokenStylesEqual.utils.js.map
|
package/dist/theme/theme-provider/hooks/use-token-styles/utils/areTokenStylesEqual.utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areTokenStylesEqual.utils.js","names":["areTokenStylesEqual","firstEntries","first","second","name","value"],"sources":["../../../../../../src/theme/theme-provider/hooks/use-token-styles/utils/areTokenStylesEqual.utils.ts"],"sourcesContent":["import type { TokenStyles } from '@theme/types';\n\n/**\n * Compares two sets of custom properties by content.\n *\n * @param first Custom properties to compare.\n * @param second Custom properties to compare with.\n * @returns Whether both declare the same properties with the same values.\n */\nexport const areTokenStylesEqual = (\n first: TokenStyles,\n second: TokenStyles,\n): boolean => {\n const firstEntries = Object.entries(first);\n return (\n firstEntries.length === Object.keys(second).length &&\n firstEntries.every(\n ([name, value]) =>\n Object.hasOwn(second, name) && second[name] === value,\n )\n );\n};\n"],"mappings":";AASA,IAAaA,KACT,GACA,MACU;CACV,IAAMC,IAAe,OAAO,QAAQC,CAAK;CACzC,OACID,EAAa,WAAW,OAAO,KAAKE,CAAM,CAAC,CAAC,UAC5CF,EAAa,OACR,CAACG,GAAMC,OACJ,OAAO,OAAOF,GAAQC,CAAI,KAAKD,EAAOC,OAAUC,CACxD;AAER"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../utils/getServerSystemTheme.utils.cjs"),t=require("../utils/getSystemTheme.utils.cjs"),n=require("../utils/subscribeToNothing.utils.cjs"),r=require("../utils/subscribeToSystemTheme.utils.cjs");let i=require("react");var a=a=>{let o=a===`system`,s=(0,i.useSyncExternalStore)(o?r.subscribeToSystemTheme:n.subscribeToNothing,o?t.getSystemTheme:e.getServerSystemTheme,e.getServerSystemTheme);return o?s:a};exports.useResolvedTheme=a;
|
|
2
|
+
//# sourceMappingURL=useResolvedTheme.hook.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolvedTheme.hook.cjs","names":["useSyncExternalStore","subscribeToSystemTheme","subscribeToNothing","getSystemTheme","getServerSystemTheme","require_getServerSystemTheme_utils","require_getSystemTheme_utils","require_subscribeToNothing_utils","require_subscribeToSystemTheme_utils","react","useResolvedTheme","isFollowingSystem","theme","systemTheme"],"sources":["../../../../src/theme/theme-provider/hooks/useResolvedTheme.hook.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nimport { getServerSystemTheme } from '@theme/theme-provider/utils/getServerSystemTheme.utils';\nimport { getSystemTheme } from '@theme/theme-provider/utils/getSystemTheme.utils';\nimport { subscribeToNothing } from '@theme/theme-provider/utils/subscribeToNothing.utils';\nimport { subscribeToSystemTheme } from '@theme/theme-provider/utils/subscribeToSystemTheme.utils';\nimport type { ThemeName } from '@theme/types';\n\n/**\n * Resolves `system` to the OS preference and follows its changes; other\n * themes are returned as-is without subscribing. Server and hydration\n * renders resolve `system` to `light`.\n *\n * @param theme Selected theme.\n * @returns The effective theme.\n */\nexport const useResolvedTheme = (theme: ThemeName): ThemeName => {\n const isFollowingSystem = theme === 'system';\n const systemTheme = useSyncExternalStore(\n isFollowingSystem ? subscribeToSystemTheme : subscribeToNothing,\n isFollowingSystem ? getSystemTheme : getServerSystemTheme,\n getServerSystemTheme,\n );\n return isFollowingSystem ? systemTheme : theme;\n};\n"],"mappings":"A,2OAgBA,IAAaU,EAAoB,GAAgC,CAC7D,IAAMC,EAAoBC,IAAU,SAC9BC,GAAA,EAAcb,EAAAA,qBAAAA,CAChBW,EAAoBV,EAAAA,uBAAyBC,EAAAA,mBAC7CS,EAAoBR,EAAAA,eAAiBC,EAAAA,qBACrCA,EAAAA,oBACJ,EACA,OAAOO,EAAoBE,EAAcD,CAC7C,E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getServerSystemTheme as e } from "../utils/getServerSystemTheme.utils.js";
|
|
2
|
+
import { getSystemTheme as t } from "../utils/getSystemTheme.utils.js";
|
|
3
|
+
import { subscribeToNothing as n } from "../utils/subscribeToNothing.utils.js";
|
|
4
|
+
import { subscribeToSystemTheme as r } from "../utils/subscribeToSystemTheme.utils.js";
|
|
5
|
+
import { useSyncExternalStore as i } from "react";
|
|
6
|
+
// src/theme/theme-provider/hooks/useResolvedTheme.hook.ts
|
|
7
|
+
var a = (a) => {
|
|
8
|
+
let o = a === "system", s = i(o ? r : n, o ? t : e, e);
|
|
9
|
+
return o ? s : a;
|
|
10
|
+
};
|
|
11
|
+
export { a as useResolvedTheme };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=useResolvedTheme.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolvedTheme.hook.js","names":["useResolvedTheme","isFollowingSystem","theme","systemTheme","useSyncExternalStore","subscribeToSystemTheme","subscribeToNothing","getSystemTheme","getServerSystemTheme"],"sources":["../../../../src/theme/theme-provider/hooks/useResolvedTheme.hook.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nimport { getServerSystemTheme } from '@theme/theme-provider/utils/getServerSystemTheme.utils';\nimport { getSystemTheme } from '@theme/theme-provider/utils/getSystemTheme.utils';\nimport { subscribeToNothing } from '@theme/theme-provider/utils/subscribeToNothing.utils';\nimport { subscribeToSystemTheme } from '@theme/theme-provider/utils/subscribeToSystemTheme.utils';\nimport type { ThemeName } from '@theme/types';\n\n/**\n * Resolves `system` to the OS preference and follows its changes; other\n * themes are returned as-is without subscribing. Server and hydration\n * renders resolve `system` to `light`.\n *\n * @param theme Selected theme.\n * @returns The effective theme.\n */\nexport const useResolvedTheme = (theme: ThemeName): ThemeName => {\n const isFollowingSystem = theme === 'system';\n const systemTheme = useSyncExternalStore(\n isFollowingSystem ? subscribeToSystemTheme : subscribeToNothing,\n isFollowingSystem ? getSystemTheme : getServerSystemTheme,\n getServerSystemTheme,\n );\n return isFollowingSystem ? systemTheme : theme;\n};\n"],"mappings":";;;;;;AAgBA,IAAaA,KAAoB,MAAgC;CAC7D,IAAMC,IAAoBC,MAAU,UAC9BC,IAAcC,EAChBH,IAAoBI,IAAyBC,GAC7CL,IAAoBM,IAAiBC,GACrCA,CACJ;CACA,OAAOP,IAAoBE,IAAcD;AAC7C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../contexts/ThemeSetterContext.cjs");let t=require("react");var n=()=>{let n=(0,t.useContext)(e.ThemeSetterContext);if(!n)throw Error(`useSetTheme must be used within a ThemeProvider.`);return n};exports.useSetTheme=n;
|
|
2
|
+
//# sourceMappingURL=useSetTheme.hook.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSetTheme.hook.cjs","names":["useContext","ThemeSetterContext","require_ThemeSetterContext","react","useSetTheme","setTheme"],"sources":["../../../../src/theme/theme-provider/hooks/useSetTheme.hook.ts"],"sourcesContent":["import { useContext } from 'react';\n\nimport { ThemeSetterContext } from '@theme/theme-provider/contexts/ThemeSetterContext';\nimport type { ThemeContextValue } from '@theme/theme-provider/types';\n\n/**\n * Reads only the stable `setTheme` of the closest `ThemeProvider`; the\n * calling component does not re-render when the theme changes.\n *\n * @returns The theme setter, whose identity never changes.\n * @throws {Error} When called outside a `ThemeProvider`.\n */\nexport const useSetTheme = (): ThemeContextValue['setTheme'] => {\n const setTheme = useContext(ThemeSetterContext);\n if (!setTheme) {\n throw new Error('useSetTheme must be used within a ThemeProvider.');\n }\n return setTheme;\n};\n"],"mappings":"A,6EAYA,IAAaI,MAAmD,CAC5D,IAAMC,GAAA,EAAWL,EAAAA,WAAAA,CAAWC,EAAAA,kBAAkB,EAC9C,GAAI,CAACI,EACD,MAAU,MAAM,kDAAkD,EAEtE,OAAOA,CACX,E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ThemeSetterContext as e } from "../contexts/ThemeSetterContext.js";
|
|
2
|
+
import { useContext as t } from "react";
|
|
3
|
+
// src/theme/theme-provider/hooks/useSetTheme.hook.ts
|
|
4
|
+
var n = () => {
|
|
5
|
+
let n = t(e);
|
|
6
|
+
if (!n) throw Error("useSetTheme must be used within a ThemeProvider.");
|
|
7
|
+
return n;
|
|
8
|
+
};
|
|
9
|
+
export { n as useSetTheme };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=useSetTheme.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSetTheme.hook.js","names":["useSetTheme","setTheme","useContext","ThemeSetterContext"],"sources":["../../../../src/theme/theme-provider/hooks/useSetTheme.hook.ts"],"sourcesContent":["import { useContext } from 'react';\n\nimport { ThemeSetterContext } from '@theme/theme-provider/contexts/ThemeSetterContext';\nimport type { ThemeContextValue } from '@theme/theme-provider/types';\n\n/**\n * Reads only the stable `setTheme` of the closest `ThemeProvider`; the\n * calling component does not re-render when the theme changes.\n *\n * @returns The theme setter, whose identity never changes.\n * @throws {Error} When called outside a `ThemeProvider`.\n */\nexport const useSetTheme = (): ThemeContextValue['setTheme'] => {\n const setTheme = useContext(ThemeSetterContext);\n if (!setTheme) {\n throw new Error('useSetTheme must be used within a ThemeProvider.');\n }\n return setTheme;\n};\n"],"mappings":";;;AAYA,IAAaA,UAAmD;CAC5D,IAAMC,IAAWC,EAAWC,CAAkB;CAC9C,IAAI,CAACF,GACD,MAAU,MAAM,kDAAkD;CAEtE,OAAOA;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.hook.cjs","names":["useContext","ThemeContext","require_ThemeContext","react","useTheme","context"],"sources":["../../../../src/theme/theme-provider/hooks/useTheme.hook.ts"],"sourcesContent":["import { useContext } from 'react';\n\nimport { ThemeContext } from '@theme/theme-provider/contexts/ThemeContext';\nimport type { ThemeContextValue } from '@theme/theme-provider/types';\n\n/**\n * Reads the theme of the closest `ThemeProvider`.\n *\n * @returns The selected theme, its resolved name and its setter.\n * @throws {Error} When called outside a `ThemeProvider`.\n */\nexport const useTheme = (): ThemeContextValue => {\n const context = useContext(ThemeContext);\n if (!context) {\n throw new Error('useTheme must be used within a ThemeProvider.');\n }\n return context;\n};\n"],"mappings":"A,uEAWA,IAAaI,MAAoC,CAC7C,IAAMC,GAAA,EAAUL,EAAAA,WAAAA,CAAWC,EAAAA,YAAY,EACvC,GAAI,CAACI,EACD,MAAU,MAAM,+CAA+C,EAEnE,OAAOA,CACX,E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ThemeContext as e } from "../contexts/ThemeContext.js";
|
|
2
|
+
import { useContext as t } from "react";
|
|
3
|
+
// src/theme/theme-provider/hooks/useTheme.hook.ts
|
|
4
|
+
var n = () => {
|
|
5
|
+
let n = t(e);
|
|
6
|
+
if (!n) throw Error("useTheme must be used within a ThemeProvider.");
|
|
7
|
+
return n;
|
|
8
|
+
};
|
|
9
|
+
export { n as useTheme };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=useTheme.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.hook.js","names":["useTheme","context","useContext","ThemeContext"],"sources":["../../../../src/theme/theme-provider/hooks/useTheme.hook.ts"],"sourcesContent":["import { useContext } from 'react';\n\nimport { ThemeContext } from '@theme/theme-provider/contexts/ThemeContext';\nimport type { ThemeContextValue } from '@theme/theme-provider/types';\n\n/**\n * Reads the theme of the closest `ThemeProvider`.\n *\n * @returns The selected theme, its resolved name and its setter.\n * @throws {Error} When called outside a `ThemeProvider`.\n */\nexport const useTheme = (): ThemeContextValue => {\n const context = useContext(ThemeContext);\n if (!context) {\n throw new Error('useTheme must be used within a ThemeProvider.');\n }\n return context;\n};\n"],"mappings":";;;AAWA,IAAaA,UAAoC;CAC7C,IAAMC,IAAUC,EAAWC,CAAY;CACvC,IAAI,CAACF,GACD,MAAU,MAAM,+CAA+C;CAEnE,OAAOA;AACX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require("../../constants/index.cjs");const e=require("../../utils/validation/assertFlavorName.utils.cjs");var t=t=>(n,r)=>{let i=e.assertFlavorName(n,r);if(i!=="default"&&!t.has(i))throw TypeError(`${r} received "${i}", which is not a registered flavor: pass it to the \`flavors\` of this ThemeProvider or of a parent one.`);return i};exports.createFlavorValidator=t;
|
|
2
|
+
//# sourceMappingURL=createFlavorValidator.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFlavorValidator.utils.cjs","names":["assertFlavorName","require_assertFlavorName_utils","createFlavorValidator","name","flavor","source","registry"],"sources":["../../../../src/theme/theme-provider/utils/createFlavorValidator.utils.ts"],"sourcesContent":["import { defaultFlavorName } from '@theme/constants';\nimport type { SelectionValidator } from '@theme/theme-provider/hooks/use-controllable-selection/types';\nimport type { FlavorRegistry } from '@theme/theme-provider/types';\nimport { assertFlavorName } from '@theme/utils/validation/assertFlavorName.utils';\n\n/**\n * Creates the validator of the flavors a provider can select: `default` and\n * the registered ones.\n *\n * @param registry Flavors registered by the provider and its ancestors.\n * @returns The validator, returning the flavor name unchanged.\n */\nexport const createFlavorValidator = (\n registry: FlavorRegistry,\n): SelectionValidator => {\n return (flavor, source) => {\n const name = assertFlavorName(flavor, source);\n\n if (name !== defaultFlavorName && !registry.has(name)) {\n throw new TypeError(\n `${source} received \"${name}\", which is not a registered flavor: pass it to the \\`flavors\\` of this ThemeProvider or of a parent one.`,\n );\n }\n\n return name;\n };\n};\n"],"mappings":"A,0GAYA,IAAaE,EACT,IAEQ,EAAQ,IAAW,CACvB,IAAMC,EAAOH,EAAAA,iBAAiBI,EAAQC,CAAM,EAE5C,GAAIF,IAAA,WAA8B,CAACG,EAAS,IAAIH,CAAI,EAChD,MAAU,UACN,GAAGE,EAAO,aAAaF,EAAK,0GAChC,EAGJ,OAAOA,CACX,E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "../../constants/index.js";
|
|
2
|
+
import { assertFlavorName as e } from "../../utils/validation/assertFlavorName.utils.js";
|
|
3
|
+
// src/theme/theme-provider/utils/createFlavorValidator.utils.ts
|
|
4
|
+
var t = (t) => (n, r) => {
|
|
5
|
+
let i = e(n, r);
|
|
6
|
+
if (i !== "default" && !t.has(i)) throw TypeError(`${r} received "${i}", which is not a registered flavor: pass it to the \`flavors\` of this ThemeProvider or of a parent one.`);
|
|
7
|
+
return i;
|
|
8
|
+
};
|
|
9
|
+
export { t as createFlavorValidator };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=createFlavorValidator.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFlavorValidator.utils.js","names":["createFlavorValidator","name","assertFlavorName","flavor","source","registry"],"sources":["../../../../src/theme/theme-provider/utils/createFlavorValidator.utils.ts"],"sourcesContent":["import { defaultFlavorName } from '@theme/constants';\nimport type { SelectionValidator } from '@theme/theme-provider/hooks/use-controllable-selection/types';\nimport type { FlavorRegistry } from '@theme/theme-provider/types';\nimport { assertFlavorName } from '@theme/utils/validation/assertFlavorName.utils';\n\n/**\n * Creates the validator of the flavors a provider can select: `default` and\n * the registered ones.\n *\n * @param registry Flavors registered by the provider and its ancestors.\n * @returns The validator, returning the flavor name unchanged.\n */\nexport const createFlavorValidator = (\n registry: FlavorRegistry,\n): SelectionValidator => {\n return (flavor, source) => {\n const name = assertFlavorName(flavor, source);\n\n if (name !== defaultFlavorName && !registry.has(name)) {\n throw new TypeError(\n `${source} received \"${name}\", which is not a registered flavor: pass it to the \\`flavors\\` of this ThemeProvider or of a parent one.`,\n );\n }\n\n return name;\n };\n};\n"],"mappings":";;;AAYA,IAAaA,KACT,OAEQ,GAAQ,MAAW;CACvB,IAAMC,IAAOC,EAAiBC,GAAQC,CAAM;CAE5C,IAAIH,MAAA,aAA8B,CAACI,EAAS,IAAIJ,CAAI,GAChD,MAAU,UACN,GAAGG,EAAO,aAAaH,EAAK,0GAChC;CAGJ,OAAOA;AACX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./utils/hashString.utils.cjs"),t=require("../../../utils/flavors/get-flavor-css/getFlavorCss.utils.cjs");var n=new WeakMap,r=r=>{let i=n.get(r);if(i!==void 0)return i;let a=t.getFlavorCss(r),o={href:`cv-flavor-${r.name}-${e.hashString(a)}`,css:a};return n.set(r,o),o};exports.getFlavorStylesheet=r;
|
|
2
|
+
//# sourceMappingURL=getFlavorStylesheet.utils.cjs.map
|
package/dist/theme/theme-provider/utils/get-flavor-stylesheet/getFlavorStylesheet.utils.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFlavorStylesheet.utils.cjs","names":["getFlavorCss","hashString","require_hashString_utils","require_getFlavorCss_utils","stylesheets","getFlavorStylesheet","cached","flavor","css","stylesheet"],"sources":["../../../../../src/theme/theme-provider/utils/get-flavor-stylesheet/getFlavorStylesheet.utils.ts"],"sourcesContent":["import type { FlavorStylesheet } from '@theme/theme-provider/utils/get-flavor-stylesheet/types';\nimport { hashString } from '@theme/theme-provider/utils/get-flavor-stylesheet/utils/hashString.utils';\nimport type { Flavor } from '@theme/types';\nimport { getFlavorCss } from '@theme/utils/flavors/get-flavor-css/getFlavorCss.utils';\n\nconst stylesheets = new WeakMap<Flavor, FlavorStylesheet>();\n\n/**\n * Generates the stylesheet of a flavor once per flavor object. Its `href`\n * includes a hash of the CSS, so React never keeps the stylesheet of an\n * earlier flavor sharing the same name.\n *\n * @param flavor Flavor to style.\n * @returns The stylesheet of the flavor.\n * @throws {TypeError} When the flavor is malformed.\n */\nexport const getFlavorStylesheet = (flavor: Flavor): FlavorStylesheet => {\n const cached = stylesheets.get(flavor);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const css = getFlavorCss(flavor);\n const stylesheet = {\n href: `cv-flavor-${flavor.name}-${hashString(css)}`,\n css,\n };\n\n stylesheets.set(flavor, stylesheet);\n\n return stylesheet;\n};\n"],"mappings":"A,0HAKA,IAAMI,EAAc,IAAI,QAWXC,EAAuB,GAAqC,CACrE,IAAMC,EAASF,EAAY,IAAIG,CAAM,EAErC,GAAID,IAAW,IAAA,GACX,OAAOA,EAGX,IAAME,EAAMR,EAAAA,aAAaO,CAAM,EACzBE,EAAa,CACf,KAAM,aAAaF,EAAO,KAAK,GAAGN,EAAAA,WAAWO,CAAG,IAChD,KACJ,EAIA,OAFAJ,EAAY,IAAIG,EAAQE,CAAU,EAE3BA,CACX,E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { hashString as e } from "./utils/hashString.utils.js";
|
|
2
|
+
import { getFlavorCss as t } from "../../../utils/flavors/get-flavor-css/getFlavorCss.utils.js";
|
|
3
|
+
// src/theme/theme-provider/utils/get-flavor-stylesheet/getFlavorStylesheet.utils.ts
|
|
4
|
+
var n = /* @__PURE__ */ new WeakMap(), r = (r) => {
|
|
5
|
+
let i = n.get(r);
|
|
6
|
+
if (i !== void 0) return i;
|
|
7
|
+
let a = t(r), o = {
|
|
8
|
+
href: `cv-flavor-${r.name}-${e(a)}`,
|
|
9
|
+
css: a
|
|
10
|
+
};
|
|
11
|
+
return n.set(r, o), o;
|
|
12
|
+
};
|
|
13
|
+
export { r as getFlavorStylesheet };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=getFlavorStylesheet.utils.js.map
|
package/dist/theme/theme-provider/utils/get-flavor-stylesheet/getFlavorStylesheet.utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFlavorStylesheet.utils.js","names":["stylesheets","getFlavorStylesheet","cached","flavor","css","getFlavorCss","stylesheet","hashString"],"sources":["../../../../../src/theme/theme-provider/utils/get-flavor-stylesheet/getFlavorStylesheet.utils.ts"],"sourcesContent":["import type { FlavorStylesheet } from '@theme/theme-provider/utils/get-flavor-stylesheet/types';\nimport { hashString } from '@theme/theme-provider/utils/get-flavor-stylesheet/utils/hashString.utils';\nimport type { Flavor } from '@theme/types';\nimport { getFlavorCss } from '@theme/utils/flavors/get-flavor-css/getFlavorCss.utils';\n\nconst stylesheets = new WeakMap<Flavor, FlavorStylesheet>();\n\n/**\n * Generates the stylesheet of a flavor once per flavor object. Its `href`\n * includes a hash of the CSS, so React never keeps the stylesheet of an\n * earlier flavor sharing the same name.\n *\n * @param flavor Flavor to style.\n * @returns The stylesheet of the flavor.\n * @throws {TypeError} When the flavor is malformed.\n */\nexport const getFlavorStylesheet = (flavor: Flavor): FlavorStylesheet => {\n const cached = stylesheets.get(flavor);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const css = getFlavorCss(flavor);\n const stylesheet = {\n href: `cv-flavor-${flavor.name}-${hashString(css)}`,\n css,\n };\n\n stylesheets.set(flavor, stylesheet);\n\n return stylesheet;\n};\n"],"mappings":";;;AAKA,IAAMA,oBAAc,IAAI,QAAkC,GAW7CC,KAAuB,MAAqC;CACrE,IAAMC,IAASF,EAAY,IAAIG,CAAM;CAErC,IAAID,MAAW,KAAA,GACX,OAAOA;CAGX,IAAME,IAAMC,EAAaF,CAAM,GACzBG,IAAa;EACf,MAAM,aAAaH,EAAO,KAAK,GAAGI,EAAWH,CAAG;EAChD;CACJ;CAIA,OAFAJ,EAAY,IAAIG,GAAQG,CAAU,GAE3BA;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashString.utils.cjs","names":["hashString","hash","index","value"],"sources":["../../../../../../src/theme/theme-provider/utils/get-flavor-stylesheet/utils/hashString.utils.ts"],"sourcesContent":["/**\n * Hashes a string with 32-bit FNV-1a, to tell contents apart in identifiers;\n * not suited to security.\n *\n * @param value String to hash.\n * @returns The hash, in base 36.\n */\nexport const hashString = (value: string): string => {\n let hash = 0x811c9dc5;\n\n for (let index = 0; index < value.length; index += 1) {\n hash ^= value.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193);\n }\n\n return (hash >>> 0).toString(36);\n};\n"],"mappings":"AAOA,IAAaA,EAAc,GAA0B,CACjD,IAAIC,EAAO,WAEX,IAAK,IAAIC,EAAQ,EAAGA,EAAQC,EAAM,OAAQ,GAAS,EAC/C,GAAQA,EAAM,WAAWD,CAAK,EAC9B,EAAO,KAAK,KAAKD,EAAM,QAAU,EAGrC,OAAQA,IAAS,EAAA,CAAG,SAAS,EAAE,CACnC,E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/theme/theme-provider/utils/get-flavor-stylesheet/utils/hashString.utils.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let t = 2166136261;
|
|
4
|
+
for (let n = 0; n < e.length; n += 1) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
5
|
+
return (t >>> 0).toString(36);
|
|
6
|
+
};
|
|
7
|
+
export { e as hashString };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=hashString.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashString.utils.js","names":["hashString","hash","index","value"],"sources":["../../../../../../src/theme/theme-provider/utils/get-flavor-stylesheet/utils/hashString.utils.ts"],"sourcesContent":["/**\n * Hashes a string with 32-bit FNV-1a, to tell contents apart in identifiers;\n * not suited to security.\n *\n * @param value String to hash.\n * @returns The hash, in base 36.\n */\nexport const hashString = (value: string): string => {\n let hash = 0x811c9dc5;\n\n for (let index = 0; index < value.length; index += 1) {\n hash ^= value.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193);\n }\n\n return (hash >>> 0).toString(36);\n};\n"],"mappings":";AAOA,IAAaA,KAAc,MAA0B;CACjD,IAAIC,IAAO;CAEX,KAAK,IAAIC,IAAQ,GAAGA,IAAQC,EAAM,QAAQ,KAAS,GAE/C,AADA,KAAQA,EAAM,WAAWD,CAAK,GAC9B,IAAO,KAAK,KAAKD,GAAM,QAAU;CAGrC,QAAQA,MAAS,EAAA,CAAG,SAAS,EAAE;AACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getReferencedFlavors.utils.cjs","names":["isRecord","require_isRecord_utils","getReferencedFlavors","references","reference","flavors"],"sources":["../../../../src/theme/theme-provider/utils/getReferencedFlavors.utils.ts"],"sourcesContent":["import type { Flavor, FlavorReference } from '@theme/types';\nimport { isRecord } from '@theme/utils/guards/isRecord.utils';\n\n/**\n * Lists the flavor objects a provider registers: those given as objects to\n * select a flavor, then those of its `flavors` prop.\n *\n * @param flavors `flavors` prop; none when `undefined`.\n * @param references Flavors given to `flavor` and `defaultFlavor`.\n * @returns The flavor objects, possibly repeated.\n */\nexport const getReferencedFlavors = (\n flavors: readonly Flavor[] | undefined,\n references: readonly (FlavorReference | undefined)[],\n): readonly Flavor[] => [\n ...references.filter((reference): reference is Flavor =>\n isRecord(reference),\n ),\n ...(flavors ?? []),\n];\n"],"mappings":"A,yDAWA,IAAaE,GACT,EACA,IACoB,CACpB,GAAGC,EAAW,OAAQ,GAClBH,EAAAA,SAASI,CAAS,CACtB,EACA,GAAIC,GAAW,CAAC,CACpB,E"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { isRecord as e } from "../../utils/guards/isRecord.utils.js";
|
|
2
|
+
// src/theme/theme-provider/utils/getReferencedFlavors.utils.ts
|
|
3
|
+
var t = (t, n) => [...n.filter((t) => e(t)), ...t ?? []];
|
|
4
|
+
export { t as getReferencedFlavors };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=getReferencedFlavors.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getReferencedFlavors.utils.js","names":["getReferencedFlavors","references","isRecord","reference","flavors"],"sources":["../../../../src/theme/theme-provider/utils/getReferencedFlavors.utils.ts"],"sourcesContent":["import type { Flavor, FlavorReference } from '@theme/types';\nimport { isRecord } from '@theme/utils/guards/isRecord.utils';\n\n/**\n * Lists the flavor objects a provider registers: those given as objects to\n * select a flavor, then those of its `flavors` prop.\n *\n * @param flavors `flavors` prop; none when `undefined`.\n * @param references Flavors given to `flavor` and `defaultFlavor`.\n * @returns The flavor objects, possibly repeated.\n */\nexport const getReferencedFlavors = (\n flavors: readonly Flavor[] | undefined,\n references: readonly (FlavorReference | undefined)[],\n): readonly Flavor[] => [\n ...references.filter((reference): reference is Flavor =>\n isRecord(reference),\n ),\n ...(flavors ?? []),\n];\n"],"mappings":";;AAWA,IAAaA,KACT,GACA,MACoB,CACpB,GAAGC,EAAW,QAAQ,MAClBC,EAASC,CAAS,CACtB,GACA,GAAIC,KAAW,CAAC,CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getServerSystemTheme.utils.cjs","names":["getServerSystemTheme"],"sources":["../../../../src/theme/theme-provider/utils/getServerSystemTheme.utils.ts"],"sourcesContent":["import type { SystemTheme } from '@theme/types';\n\n/**\n * Snapshot of the OS preference during server and hydration renders, which\n * cannot know it: CSS follows the real preference until hydration ends.\n *\n * @returns Always `light`.\n */\nexport const getServerSystemTheme = (): SystemTheme => 'light';\n"],"mappings":"AAQA,IAAaA,MAA0C,Q"}
|