@tamagui/core 1.0.1-beta.68 → 1.0.1-beta.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants/rnw.js +2 -13
- package/dist/cjs/constants/rnw.js.map +2 -2
- package/dist/cjs/createComponent.js +29 -22
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +3 -0
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/generateAtomicStyles.js +133 -89
- package/dist/cjs/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +22 -20
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +22 -67
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/pseudos.js.map +1 -1
- package/dist/cjs/views/Text.js +2 -1
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/esm/constants/rnw.js +2 -13
- package/dist/esm/constants/rnw.js.map +2 -2
- package/dist/esm/createComponent.js +29 -22
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +3 -0
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/generateAtomicStyles.js +133 -89
- package/dist/esm/helpers/generateAtomicStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +22 -21
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +22 -67
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/pseudos.js.map +1 -1
- package/dist/esm/views/Text.js +2 -1
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/jsx/constants/rnw.js +2 -13
- package/dist/jsx/createComponent.js +29 -22
- package/dist/jsx/helpers/createPropMapper.js +3 -0
- package/dist/jsx/helpers/generateAtomicStyles.js +133 -89
- package/dist/jsx/helpers/getSplitStyles.js +22 -21
- package/dist/jsx/helpers/getStylesAtomic.js +22 -67
- package/dist/jsx/views/Text.js +2 -1
- package/package.json +6 -6
- package/reset.css +0 -1
- package/types/Pressability.d.ts +0 -0
- package/types/Pressability.d.ts.map +0 -0
- package/types/Pressability.native.d.ts +0 -0
- package/types/Pressability.native.d.ts.map +0 -0
- package/types/Tamagui.d.ts +0 -0
- package/types/Tamagui.d.ts.map +0 -0
- package/types/ThemeContext.d.ts +0 -0
- package/types/ThemeContext.d.ts.map +0 -0
- package/types/ThemeManager.d.ts +0 -0
- package/types/ThemeManager.d.ts.map +0 -0
- package/types/conf.d.ts +0 -0
- package/types/conf.d.ts.map +0 -0
- package/types/constants/constants.d.ts +0 -0
- package/types/constants/constants.d.ts.map +0 -0
- package/types/constants/platform.d.ts +0 -0
- package/types/constants/platform.d.ts.map +0 -0
- package/types/constants/rnw.d.ts +0 -0
- package/types/constants/rnw.d.ts.map +1 -1
- package/types/contexts/ButtonInsideButtonContext.d.ts +0 -0
- package/types/contexts/ButtonInsideButtonContext.d.ts.map +0 -0
- package/types/createComponent.d.ts +0 -0
- package/types/createComponent.d.ts.map +1 -1
- package/types/createFont.d.ts +0 -0
- package/types/createFont.d.ts.map +0 -0
- package/types/createShorthands.d.ts +0 -0
- package/types/createShorthands.d.ts.map +0 -0
- package/types/createTamagui.d.ts +0 -0
- package/types/createTamagui.d.ts.map +0 -0
- package/types/createTheme.d.ts +0 -0
- package/types/createTheme.d.ts.map +0 -0
- package/types/createTokens.d.ts +0 -0
- package/types/createTokens.d.ts.map +0 -0
- package/types/createVariable.d.ts +0 -0
- package/types/createVariable.d.ts.map +0 -0
- package/types/createVariables.d.ts +0 -0
- package/types/createVariables.d.ts.map +0 -0
- package/types/defaultComponentState.d.ts +0 -0
- package/types/defaultComponentState.d.ts.map +0 -0
- package/types/helpers/RNComponents.d.ts +0 -0
- package/types/helpers/RNComponents.d.ts.map +0 -0
- package/types/helpers/areEqualSets.d.ts +0 -0
- package/types/helpers/areEqualSets.d.ts.map +0 -0
- package/types/helpers/calc.d.ts +0 -0
- package/types/helpers/calc.d.ts.map +0 -0
- package/types/helpers/createMediaStyle.d.ts +0 -0
- package/types/helpers/createMediaStyle.d.ts.map +0 -0
- package/types/helpers/createPropMapper.d.ts +0 -0
- package/types/helpers/createPropMapper.d.ts.map +0 -0
- package/types/helpers/createShallowUpdate.d.ts +0 -0
- package/types/helpers/createShallowUpdate.d.ts.map +0 -0
- package/types/helpers/createTamaguiProvider.d.ts +0 -0
- package/types/helpers/createTamaguiProvider.d.ts.map +0 -0
- package/types/helpers/extendStaticConfig.d.ts +0 -0
- package/types/helpers/extendStaticConfig.d.ts.map +0 -0
- package/types/helpers/fixNativeShadow.d.ts +0 -0
- package/types/helpers/fixNativeShadow.d.ts.map +0 -0
- package/types/helpers/fixNativeShadow.native.d.ts +0 -0
- package/types/helpers/fixNativeShadow.native.d.ts.map +0 -0
- package/types/helpers/generateAtomicStyles.d.ts +3 -12
- package/types/helpers/generateAtomicStyles.d.ts.map +1 -1
- package/types/helpers/getExpandedShorthands.d.ts +0 -0
- package/types/helpers/getExpandedShorthands.d.ts.map +0 -0
- package/types/helpers/getSize.d.ts +0 -0
- package/types/helpers/getSize.d.ts.map +0 -0
- package/types/helpers/getSplitStyles.d.ts +6 -0
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStackSize.d.ts +0 -0
- package/types/helpers/getStackSize.d.ts.map +0 -0
- package/types/helpers/getStylesAtomic.d.ts +0 -5
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.native.d.ts +0 -0
- package/types/helpers/getStylesAtomic.native.d.ts.map +0 -0
- package/types/helpers/getTextSize.d.ts +0 -0
- package/types/helpers/getTextSize.d.ts.map +0 -0
- package/types/helpers/getVariantExtras.d.ts +0 -0
- package/types/helpers/getVariantExtras.d.ts.map +0 -0
- package/types/helpers/insertStyleRule.d.ts +0 -0
- package/types/helpers/insertStyleRule.d.ts.map +0 -0
- package/types/helpers/isObj.d.ts +0 -0
- package/types/helpers/isObj.d.ts.map +0 -0
- package/types/helpers/isTamaguiComponent.d.ts +0 -0
- package/types/helpers/isTamaguiComponent.d.ts.map +0 -0
- package/types/helpers/isTamaguiElement.d.ts +0 -0
- package/types/helpers/isTamaguiElement.d.ts.map +0 -0
- package/types/helpers/matchMedia.d.ts +0 -0
- package/types/helpers/matchMedia.d.ts.map +0 -0
- package/types/helpers/matchMedia.native.d.ts +0 -0
- package/types/helpers/matchMedia.native.d.ts.map +0 -0
- package/types/helpers/mergeProps.d.ts +0 -0
- package/types/helpers/mergeProps.d.ts.map +0 -0
- package/types/helpers/mergeTransform.d.ts +0 -0
- package/types/helpers/mergeTransform.d.ts.map +0 -0
- package/types/helpers/nativeGestureHandler.native.d.ts +0 -0
- package/types/helpers/nativeGestureHandler.native.d.ts.map +0 -0
- package/types/helpers/proxyThemeVariables.d.ts +0 -0
- package/types/helpers/proxyThemeVariables.d.ts.map +0 -0
- package/types/helpers/pseudos.d.ts +1 -0
- package/types/helpers/pseudos.d.ts.map +1 -1
- package/types/helpers/registerCSSVariable.d.ts +0 -0
- package/types/helpers/registerCSSVariable.d.ts.map +0 -0
- package/types/helpers/themeable.d.ts +0 -0
- package/types/helpers/themeable.d.ts.map +0 -0
- package/types/helpers/validate.d.ts +0 -0
- package/types/helpers/validate.d.ts.map +0 -0
- package/types/helpers/withStaticProperties.d.ts +0 -0
- package/types/helpers/withStaticProperties.d.ts.map +0 -0
- package/types/helpers/wrapThemeManagerContext.d.ts +0 -0
- package/types/helpers/wrapThemeManagerContext.d.ts.map +0 -0
- package/types/hooks/useConstant.d.ts +0 -0
- package/types/hooks/useConstant.d.ts.map +0 -0
- package/types/hooks/useFeatures.d.ts +0 -0
- package/types/hooks/useFeatures.d.ts.map +0 -0
- package/types/hooks/useId.d.ts +0 -0
- package/types/hooks/useId.d.ts.map +0 -0
- package/types/hooks/useIsMounted.d.ts +0 -0
- package/types/hooks/useIsMounted.d.ts.map +0 -0
- package/types/hooks/useIsTouchDevice.d.ts +0 -0
- package/types/hooks/useIsTouchDevice.d.ts.map +0 -0
- package/types/hooks/useMedia.d.ts +0 -0
- package/types/hooks/useMedia.d.ts.map +0 -0
- package/types/hooks/usePressable.d.ts +0 -0
- package/types/hooks/usePressable.d.ts.map +0 -0
- package/types/hooks/usePrevious.d.ts +0 -0
- package/types/hooks/usePrevious.d.ts.map +0 -0
- package/types/hooks/useTheme.d.ts +0 -0
- package/types/hooks/useTheme.d.ts.map +0 -0
- package/types/hooks/useUnmountEffect.d.ts +0 -0
- package/types/hooks/useUnmountEffect.d.ts.map +0 -0
- package/types/index.d.ts +0 -0
- package/types/index.d.ts.map +0 -0
- package/types/insertFont.d.ts +0 -0
- package/types/insertFont.d.ts.map +0 -0
- package/types/static.d.ts +0 -0
- package/types/static.d.ts.map +0 -0
- package/types/styled.d.ts +0 -0
- package/types/styled.d.ts.map +0 -0
- package/types/types-rnw.d.ts +0 -0
- package/types/types-rnw.d.ts.map +0 -0
- package/types/types.d.ts +0 -0
- package/types/types.d.ts.map +0 -0
- package/types/views/Slot.d.ts +0 -0
- package/types/views/Slot.d.ts.map +0 -0
- package/types/views/Stack.d.ts +0 -0
- package/types/views/Stack.d.ts.map +0 -0
- package/types/views/Text.d.ts +0 -0
- package/types/views/Text.d.ts.map +1 -1
- package/types/views/TextAncestorContext.d.ts +0 -0
- package/types/views/TextAncestorContext.d.ts.map +0 -0
- package/types/views/Theme.d.ts +0 -0
- package/types/views/Theme.d.ts.map +0 -0
- package/types/views/ThemeInverse.d.ts +0 -0
- package/types/views/ThemeInverse.d.ts.map +0 -0
- package/types/views/ThemeProvider.d.ts +0 -0
- package/types/views/ThemeProvider.d.ts.map +0 -0
- package/types/views/ThemeReset.d.ts +0 -0
- package/types/views/ThemeReset.d.ts.map +0 -0
- package/dist/cjs/helpers/nativeGestureHandler.js +0 -29
- package/dist/cjs/helpers/nativeGestureHandler.js.map +0 -7
- package/dist/cjs/helpers/prefixStyles.js +0 -192
- package/dist/cjs/helpers/prefixStyles.js.map +0 -7
- package/dist/cjs/nativeGestureHandler.native.js +0 -18
- package/dist/cjs/nativeGestureHandler.native.js.map +0 -7
- package/dist/cjs/registerCSSVariable.js +0 -41
- package/dist/cjs/registerCSSVariable.js.map +0 -7
- package/dist/esm/helpers/nativeGestureHandler.js +0 -7
- package/dist/esm/helpers/nativeGestureHandler.js.map +0 -7
- package/dist/esm/helpers/prefixStyles.js +0 -166
- package/dist/esm/helpers/prefixStyles.js.map +0 -7
- package/dist/esm/nativeGestureHandler.native.js +0 -2
- package/dist/esm/nativeGestureHandler.native.js.map +0 -7
- package/dist/esm/registerCSSVariable.js +0 -17
- package/dist/esm/registerCSSVariable.js.map +0 -7
- package/dist/jsx/helpers/nativeGestureHandler.js +0 -6
- package/dist/jsx/helpers/prefixStyles.js +0 -165
- package/dist/jsx/nativeGestureHandler.native.js +0 -1
- package/dist/jsx/registerCSSVariable.js +0 -16
- package/types/helpers/prefixStyles.d.ts +0 -5
- package/types/helpers/prefixStyles.d.ts.map +0 -1
- package/types/registerCSSVariable.d.ts +0 -5
- package/types/registerCSSVariable.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/createPropMapper.ts"],
|
|
4
|
-
"sourcesContent": ["import { getConfig } from '../conf'\nimport { isWeb } from '../constants/platform'\nimport { Variable, isVariable } from '../createVariable'\nimport {\n DebugProp,\n GenericVariantDefinitions,\n PropMapper,\n SplitStyleState,\n StaticConfig,\n TamaguiInternalConfig,\n VariantSpreadFunction,\n} from '../types'\nimport { expandStyle, expandStyles } from './generateAtomicStyles'\nimport { getVariantExtras } from './getVariantExtras'\nimport { isObj } from './isObj'\n\nexport type ResolveVariableTypes = 'auto' | 'value' | 'variable' | 'both' | 'non-color-value'\n\nexport const getReturnVariablesAs = (props: any, state: Partial<SplitStyleState>) => {\n return !!props.animation || state.resolveVariablesAs === 'value'\n ? isWeb\n ? 'non-color-value'\n : 'value'\n : 'auto'\n}\n\nexport const createPropMapper = (staticConfig: Partial<StaticConfig>) => {\n const variants = staticConfig.variants || {}\n const defaultProps = staticConfig.defaultProps || {}\n\n const mapper: PropMapper = (\n key,\n value,\n theme,\n propsIn,\n state,\n avoidDefaultProps = false,\n debug\n ) => {\n const conf = getConfig()\n if (!conf) {\n console.trace('no conf! err')\n return\n }\n\n const props = state.fallbackProps || propsIn\n const returnVariablesAs = getReturnVariablesAs(props, state)\n\n // handled here because we need to resolve this off tokens, its the only one-off like this\n const fontFamily = props.fontFamily || defaultProps.fontFamily || '$body'\n\n const variantValue = resolveVariants(\n key,\n value,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n '',\n avoidDefaultProps\n )\n if (variantValue) {\n return variantValue\n }\n\n let shouldReturn = value !== undefined && value !== null\n\n // handle shorthands\n if (conf.shorthands[key]) {\n shouldReturn = true\n key = conf.shorthands[key]\n }\n\n if (value) {\n if (value[0] === '$') {\n // prettier-ignore\n value = getToken(key, value, conf, theme, fontFamily, returnVariablesAs, debug)\n } else if (isVariable(value)) {\n value = getVariableValue(key, value, returnVariablesAs)\n }\n }\n\n if (shouldReturn) {\n return expandStyle(key, value) || [[key, value]]\n }\n }\n\n return mapper\n}\n\ntype StyleResolver = (\n key: string,\n value: any,\n props: Record<string, any>,\n defaultProps: any,\n theme: any,\n variants: GenericVariantDefinitions,\n fontFamily: string,\n conf: TamaguiInternalConfig,\n returnVariablesAs: 'auto' | 'value' | 'non-color-value',\n staticConfig: Partial<StaticConfig>,\n parentVariantKey: string,\n avoidDefaultProps?: boolean,\n debug?: DebugProp\n) => any\n\nconst resolveVariants: StyleResolver = (\n key,\n value,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n parentVariantKey,\n avoidDefaultProps = false,\n debug\n) => {\n const variant = variants && variants[key]\n if (variant && value !== undefined) {\n let variantValue = getVariantDefinition(variant, key, value)\n\n if (variantValue) {\n if (typeof variantValue === 'function') {\n const fn = variantValue as VariantSpreadFunction<any>\n variantValue = fn(value, getVariantExtras(props, theme, defaultProps, avoidDefaultProps))\n }\n\n if (isObj(variantValue)) {\n variantValue = resolveTokensAndVariants(\n key,\n variantValue,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n parentVariantKey,\n avoidDefaultProps,\n debug\n )\n }\n\n return Object.entries(expandStyles(variantValue))\n } else {\n // variant at key exists, but no matching variant value, return nothing\n if (process.env.NODE_ENV === 'development') {\n if (staticConfig.validStyles?.[key]) {\n return null\n }\n const name = staticConfig.componentName || '[UnnamedComponent]'\n console.warn(\n `No variant found: ${name} has variant \"${key}\", but no matching value \"${value}\"`\n )\n }\n return null\n }\n }\n}\n\nconst resolveTokensAndVariants: StyleResolver = (\n key, // we dont use key assume value is object instead\n value,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n parentVariantKey,\n avoidDefaultProps,\n debug\n) => {\n let res = {}\n for (const rKey in value) {\n const fKey = conf.shorthands[rKey] || rKey\n const val = value[rKey]\n if (isVariable(val)) {\n res[fKey] = !isWeb || returnVariablesAs === 'value' ? val.val : val.variable\n } else if (variants[fKey]) {\n // avoids infinite loop if variant is matching a style prop\n // eg: { variants: { flex: { true: { flex: 2 } } } }\n if (parentVariantKey === key) {\n res[fKey] = val\n } else {\n res = {\n ...res,\n ...Object.fromEntries(\n resolveVariants(\n fKey,\n val,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n key,\n avoidDefaultProps,\n debug\n )\n ),\n }\n }\n } else if (typeof val === 'string') {\n const fVal =\n val[0] === '$'\n ? getToken(fKey, val, conf, theme, fontFamily, returnVariablesAs, debug)\n : val\n res[fKey] = fVal\n } else {\n if (isObj(val)) {\n // sub-objects: media queries, pseudos, shadowOffset\n res[fKey] = resolveTokensAndVariants(\n fKey,\n val,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n key,\n avoidDefaultProps,\n debug\n )\n } else {\n // nullish values cant be tokens, need no extra parsing\n res[fKey] = value[fKey]\n }\n }\n if (process.env.NODE_ENV === 'development') {\n if (res[fKey]?.[0] === '$') {\n console.warn(`\u26A0\uFE0F Missing token in theme ${theme.name}:`, fKey, res[fKey])\n }\n }\n }\n return res\n}\n\n// goes through specificity finding best matching variant function\nfunction getVariantDefinition(variant: any, key: string, value: any) {\n if (typeof variant === 'function') {\n return variant\n }\n for (const cat in tokenCategories) {\n if (key in tokenCategories[cat]) {\n const spreadVariant = variant[`...${cat}`]\n if (spreadVariant) {\n return spreadVariant\n }\n }\n }\n let fn: any\n if (typeof value === 'number') {\n fn = variant[':number']\n } else if (typeof value === 'string') {\n fn = variant[':string']\n } else if (value === true || value === false) {\n fn = variant[':boolean']\n }\n fn = fn || variant[value]\n // fallback to size ultimately - could do token level detection\n return fn || variant['...'] || variant['...size']\n}\n\nconst fontShorthand = {\n fontSize: 'size',\n fontWeight: 'weight',\n}\n\nconst getToken = (\n key: string,\n value: string,\n { tokensParsed, fontsParsed }: TamaguiInternalConfig,\n theme: any,\n fontFamily: string | undefined = '$body',\n resolveAs?: ResolveVariableTypes,\n debug?: DebugProp\n) => {\n let valOrVar: any\n let hasSet = false\n if (theme[value]) {\n valOrVar = theme[value]\n hasSet = true\n } else {\n switch (key) {\n case 'fontFamily':\n valOrVar = fontsParsed[value]?.family || value\n hasSet = true\n break\n case 'fontSize':\n case 'lineHeight':\n case 'letterSpacing':\n case 'fontWeight':\n valOrVar = fontsParsed[fontFamily]?.[fontShorthand[key] || key]?.[value] || value\n hasSet = true\n break\n }\n for (const cat in tokenCategories) {\n if (key in tokenCategories[cat]) {\n const res = tokensParsed[cat][value]\n if (res) {\n valOrVar = res\n hasSet = true\n }\n }\n }\n if (!hasSet) {\n const spaceVar = tokensParsed.space[value]\n if (spaceVar) {\n valOrVar = spaceVar\n hasSet = true\n }\n }\n }\n if (hasSet) {\n return getVariableValue(key, valOrVar, resolveAs)\n }\n if (process.env.NODE_ENV === 'development') {\n if (value && value[0] === '$') {\n console.warn(\n `\u26A0\uFE0F You've passed the value \"${value}\" to the style property \"${key}\", but there's no theme or token with the key \"${value}\". Using theme \"${theme.name}\".\n\nSet the debug prop to true to see more detailed debug information.`\n )\n if (debug) {\n if (typeof window !== 'undefined') {\n console.log('Looked in:')\n console.log('Theme:', theme)\n console.log('Tokens:', tokensParsed)\n console.log('Fonts:', fontsParsed)\n }\n }\n return null\n }\n }\n return value\n}\n\nfunction getVariableValue(\n key: string,\n valOrVar: Variable | any,\n resolveAs: ResolveVariableTypes = 'auto'\n) {\n if (isVariable(valOrVar)) {\n if (resolveAs === 'variable') {\n return valOrVar\n }\n if (resolveAs === 'non-color-value') {\n if (isWeb) {\n if (key in tokenCategories.color) {\n return valOrVar.variable\n }\n }\n return valOrVar.val\n }\n if (!isWeb || resolveAs === 'value') {\n return valOrVar.val\n }\n return valOrVar.variable\n }\n return valOrVar\n}\n\n// just specificy the least costly, all else go to `space` (most keys - we can exclude)\nconst tokenCategories = {\n radius: {\n borderRadius: true,\n borderTopLeftRadius: true,\n borderTopRightRadius: true,\n borderBottomLeftRadius: true,\n borderBottomRightRadius: true,\n },\n size: {\n width: true,\n height: true,\n minWidth: true,\n minHeight: true,\n maxWidth: true,\n maxHeight: true,\n },\n color: {\n color: true,\n backgroundColor: true,\n borderColor: true,\n borderBottomColor: true,\n borderTopColor: true,\n borderLeftColor: true,\n borderRightColor: true,\n },\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,sBAAsB;AACtB,4BAAqC;AAUrC,kCAA0C;AAC1C,8BAAiC;AACjC,mBA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A5HL;AA6HE,QAAM,UAAU,YAAY,SAAS;AACrC,MAAI,WAAW,UAAU,QAAW;AAClC,QAAI,eAAe,qBAAqB,SAAS,KAAK,KAAK;AAE3D,QAAI,cAAc;AAChB,UAAI,OAAO,iBAAiB,YAAY;AACtC,cAAM,KAAK;AACX,uBAAe,GAAG,OAAO,8CAAiB,OAAO,OAAO,cAAc,iBAAiB,CAAC;AAAA,MAC1F;AAEA,UAAI,wBAAM,YAAY,GAAG;AACvB,uBAAe,yBACb,KACA,cACA,OACA,cACA,OACA,UACA,YACA,MACA,mBACA,cACA,kBACA,mBACA,KACF;AAAA,MACF;AAEA,aAAO,OAAO,QAAQ,8CAAa,YAAY,CAAC;AAAA,IAClD,OAAO;AAEL,UAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,YAAI,mBAAa,gBAAb,mBAA2B,MAAM;AACnC,iBAAO;AAAA,QACT;AACA,cAAM,OAAO,aAAa,iBAAiB;AAC3C,gBAAQ,KACN,qBAAqB,qBAAqB,gCAAgC,QAC5E;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF,
|
|
4
|
+
"sourcesContent": ["import { getConfig } from '../conf'\nimport { isWeb } from '../constants/platform'\nimport { Variable, isVariable } from '../createVariable'\nimport {\n DebugProp,\n GenericVariantDefinitions,\n PropMapper,\n SplitStyleState,\n StaticConfig,\n TamaguiInternalConfig,\n VariantSpreadFunction,\n} from '../types'\nimport { expandStyle, expandStyles } from './generateAtomicStyles'\nimport { getVariantExtras } from './getVariantExtras'\nimport { isObj } from './isObj'\n\nexport type ResolveVariableTypes = 'auto' | 'value' | 'variable' | 'both' | 'non-color-value'\n\nexport const getReturnVariablesAs = (props: any, state: Partial<SplitStyleState>) => {\n return !!props.animation || state.resolveVariablesAs === 'value'\n ? isWeb\n ? 'non-color-value'\n : 'value'\n : 'auto'\n}\n\nexport const createPropMapper = (staticConfig: Partial<StaticConfig>) => {\n const variants = staticConfig.variants || {}\n const defaultProps = staticConfig.defaultProps || {}\n\n const mapper: PropMapper = (\n key,\n value,\n theme,\n propsIn,\n state,\n avoidDefaultProps = false,\n debug\n ) => {\n const conf = getConfig()\n if (!conf) {\n console.trace('no conf! err')\n return\n }\n\n const props = state.fallbackProps || propsIn\n const returnVariablesAs = getReturnVariablesAs(props, state)\n\n // handled here because we need to resolve this off tokens, its the only one-off like this\n const fontFamily = props.fontFamily || defaultProps.fontFamily || '$body'\n\n const variantValue = resolveVariants(\n key,\n value,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n '',\n avoidDefaultProps\n )\n if (variantValue) {\n return variantValue\n }\n\n let shouldReturn = value !== undefined && value !== null\n\n // handle shorthands\n if (conf.shorthands[key]) {\n shouldReturn = true\n key = conf.shorthands[key]\n }\n\n if (value) {\n if (value[0] === '$') {\n // prettier-ignore\n value = getToken(key, value, conf, theme, fontFamily, returnVariablesAs, debug)\n } else if (isVariable(value)) {\n value = getVariableValue(key, value, returnVariablesAs)\n }\n }\n\n if (shouldReturn) {\n return expandStyle(key, value) || [[key, value]]\n }\n }\n\n return mapper\n}\n\ntype StyleResolver = (\n key: string,\n value: any,\n props: Record<string, any>,\n defaultProps: any,\n theme: any,\n variants: GenericVariantDefinitions,\n fontFamily: string,\n conf: TamaguiInternalConfig,\n returnVariablesAs: 'auto' | 'value' | 'non-color-value',\n staticConfig: Partial<StaticConfig>,\n parentVariantKey: string,\n avoidDefaultProps?: boolean,\n debug?: DebugProp\n) => any\n\nconst resolveVariants: StyleResolver = (\n key,\n value,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n parentVariantKey,\n avoidDefaultProps = false,\n debug\n) => {\n const variant = variants && variants[key]\n if (variant && value !== undefined) {\n let variantValue = getVariantDefinition(variant, key, value)\n\n if (variantValue) {\n if (typeof variantValue === 'function') {\n const fn = variantValue as VariantSpreadFunction<any>\n variantValue = fn(value, getVariantExtras(props, theme, defaultProps, avoidDefaultProps))\n }\n\n if (isObj(variantValue)) {\n variantValue = resolveTokensAndVariants(\n key,\n variantValue,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n parentVariantKey,\n avoidDefaultProps,\n debug\n )\n }\n\n return Object.entries(expandStyles(variantValue))\n } else {\n // variant at key exists, but no matching variant value, return nothing\n if (process.env.NODE_ENV === 'development') {\n if (staticConfig.validStyles?.[key]) {\n return null\n }\n if (value === false) {\n // don't warn on missing false values, common to only use true\n return null\n }\n const name = staticConfig.componentName || '[UnnamedComponent]'\n console.warn(\n `No variant found: ${name} has variant \"${key}\", but no matching value \"${value}\"`\n )\n }\n return null\n }\n }\n}\n\nconst resolveTokensAndVariants: StyleResolver = (\n key, // we dont use key assume value is object instead\n value,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n parentVariantKey,\n avoidDefaultProps,\n debug\n) => {\n let res = {}\n for (const rKey in value) {\n const fKey = conf.shorthands[rKey] || rKey\n const val = value[rKey]\n if (isVariable(val)) {\n res[fKey] = !isWeb || returnVariablesAs === 'value' ? val.val : val.variable\n } else if (variants[fKey]) {\n // avoids infinite loop if variant is matching a style prop\n // eg: { variants: { flex: { true: { flex: 2 } } } }\n if (parentVariantKey === key) {\n res[fKey] = val\n } else {\n res = {\n ...res,\n ...Object.fromEntries(\n resolveVariants(\n fKey,\n val,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n key,\n avoidDefaultProps,\n debug\n )\n ),\n }\n }\n } else if (typeof val === 'string') {\n const fVal =\n val[0] === '$'\n ? getToken(fKey, val, conf, theme, fontFamily, returnVariablesAs, debug)\n : val\n res[fKey] = fVal\n } else {\n if (isObj(val)) {\n // sub-objects: media queries, pseudos, shadowOffset\n res[fKey] = resolveTokensAndVariants(\n fKey,\n val,\n props,\n defaultProps,\n theme,\n variants,\n fontFamily,\n conf,\n returnVariablesAs,\n staticConfig,\n key,\n avoidDefaultProps,\n debug\n )\n } else {\n // nullish values cant be tokens, need no extra parsing\n res[fKey] = value[fKey]\n }\n }\n if (process.env.NODE_ENV === 'development') {\n if (res[fKey]?.[0] === '$') {\n console.warn(`\u26A0\uFE0F Missing token in theme ${theme.name}:`, fKey, res[fKey])\n }\n }\n }\n return res\n}\n\n// goes through specificity finding best matching variant function\nfunction getVariantDefinition(variant: any, key: string, value: any) {\n if (typeof variant === 'function') {\n return variant\n }\n for (const cat in tokenCategories) {\n if (key in tokenCategories[cat]) {\n const spreadVariant = variant[`...${cat}`]\n if (spreadVariant) {\n return spreadVariant\n }\n }\n }\n let fn: any\n if (typeof value === 'number') {\n fn = variant[':number']\n } else if (typeof value === 'string') {\n fn = variant[':string']\n } else if (value === true || value === false) {\n fn = variant[':boolean']\n }\n fn = fn || variant[value]\n // fallback to size ultimately - could do token level detection\n return fn || variant['...'] || variant['...size']\n}\n\nconst fontShorthand = {\n fontSize: 'size',\n fontWeight: 'weight',\n}\n\nconst getToken = (\n key: string,\n value: string,\n { tokensParsed, fontsParsed }: TamaguiInternalConfig,\n theme: any,\n fontFamily: string | undefined = '$body',\n resolveAs?: ResolveVariableTypes,\n debug?: DebugProp\n) => {\n let valOrVar: any\n let hasSet = false\n if (theme[value]) {\n valOrVar = theme[value]\n hasSet = true\n } else {\n switch (key) {\n case 'fontFamily':\n valOrVar = fontsParsed[value]?.family || value\n hasSet = true\n break\n case 'fontSize':\n case 'lineHeight':\n case 'letterSpacing':\n case 'fontWeight':\n valOrVar = fontsParsed[fontFamily]?.[fontShorthand[key] || key]?.[value] || value\n hasSet = true\n break\n }\n for (const cat in tokenCategories) {\n if (key in tokenCategories[cat]) {\n const res = tokensParsed[cat][value]\n if (res) {\n valOrVar = res\n hasSet = true\n }\n }\n }\n if (!hasSet) {\n const spaceVar = tokensParsed.space[value]\n if (spaceVar) {\n valOrVar = spaceVar\n hasSet = true\n }\n }\n }\n if (hasSet) {\n return getVariableValue(key, valOrVar, resolveAs)\n }\n if (process.env.NODE_ENV === 'development') {\n if (value && value[0] === '$') {\n console.warn(\n `\u26A0\uFE0F You've passed the value \"${value}\" to the style property \"${key}\", but there's no theme or token with the key \"${value}\". Using theme \"${theme.name}\".\n\nSet the debug prop to true to see more detailed debug information.`\n )\n if (debug) {\n if (typeof window !== 'undefined') {\n console.log('Looked in:')\n console.log('Theme:', theme)\n console.log('Tokens:', tokensParsed)\n console.log('Fonts:', fontsParsed)\n }\n }\n return null\n }\n }\n return value\n}\n\nfunction getVariableValue(\n key: string,\n valOrVar: Variable | any,\n resolveAs: ResolveVariableTypes = 'auto'\n) {\n if (isVariable(valOrVar)) {\n if (resolveAs === 'variable') {\n return valOrVar\n }\n if (resolveAs === 'non-color-value') {\n if (isWeb) {\n if (key in tokenCategories.color) {\n return valOrVar.variable\n }\n }\n return valOrVar.val\n }\n if (!isWeb || resolveAs === 'value') {\n return valOrVar.val\n }\n return valOrVar.variable\n }\n return valOrVar\n}\n\n// just specificy the least costly, all else go to `space` (most keys - we can exclude)\nconst tokenCategories = {\n radius: {\n borderRadius: true,\n borderTopLeftRadius: true,\n borderTopRightRadius: true,\n borderBottomLeftRadius: true,\n borderBottomRightRadius: true,\n },\n size: {\n width: true,\n height: true,\n minWidth: true,\n minHeight: true,\n maxWidth: true,\n maxHeight: true,\n },\n color: {\n color: true,\n backgroundColor: true,\n borderColor: true,\n borderBottomColor: true,\n borderTopColor: true,\n borderLeftColor: true,\n borderRightColor: true,\n },\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,sBAAsB;AACtB,4BAAqC;AAUrC,kCAA0C;AAC1C,8BAAiC;AACjC,mBAAsB;AAIf,MAAM,uBAAuB,wBAAC,OAAY,UAAoC;AACnF,SAAO,CAAC,CAAC,MAAM,aAAa,MAAM,uBAAuB,UACrD,wBACE,oBACA,U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AAS;AAAA,IAClB;AACA,QAAI,CAAC,yBAAS,cAAc,SAAS;AACnC,aAAO,SAAS;AAAA,IAClB;AACA,WAAO,SAAS;AAAA,EAClB;AACA,SAAO;AACT;AAvBS;AA0BT,MAAM,kBAAkB;AAAA,EACtB,QAAQ;AAAA,IACN,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,sBAAsB;AAAA,IACtB,wBAAwB;AAAA,IACxB,yBAAyB;AAAA,EAC3B;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,EACb;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,mBAAmB;AAAA,IACnB,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,EACpB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -43,8 +43,43 @@ module.exports = __toCommonJS(generateAtomicStyles_exports);
|
|
|
43
43
|
var import_helpers = require("@tamagui/helpers");
|
|
44
44
|
var import_hyphenate_style_name = __toESM(require("hyphenate-style-name"));
|
|
45
45
|
var import_normalize_css_color = __toESM(require("normalize-css-color"));
|
|
46
|
+
var import_conf = require("../conf");
|
|
46
47
|
var import_platform = require("../constants/platform");
|
|
48
|
+
var import_createTamagui = require("../createTamagui");
|
|
47
49
|
var import_pseudos = require("./pseudos");
|
|
50
|
+
const generateAtomicStyles = /* @__PURE__ */ __name((style, pseudo) => {
|
|
51
|
+
const res = expandStyles(style);
|
|
52
|
+
const out = [];
|
|
53
|
+
for (const key in res) {
|
|
54
|
+
const value = res[key];
|
|
55
|
+
if (value != null) {
|
|
56
|
+
const valueString = stringifyValueWithProperty(value, key);
|
|
57
|
+
const hash = (0, import_helpers.simpleHash)(key + valueString + ((pseudo == null ? void 0 : pseudo.name) || ""));
|
|
58
|
+
const cachedResult = cache.get(hash, valueString);
|
|
59
|
+
if (cachedResult != null) {
|
|
60
|
+
out.push(cachedResult);
|
|
61
|
+
} else {
|
|
62
|
+
const pseudoPrefix = pseudo ? `0${pseudo.name}-` : "";
|
|
63
|
+
const shortProp = import_createTamagui.reversedShorthands[key] || key;
|
|
64
|
+
const identifier = `_${shortProp}-${pseudoPrefix}${hash}`;
|
|
65
|
+
const rules = createAtomicRules(identifier, key, valueString, pseudo);
|
|
66
|
+
const styleObject = {
|
|
67
|
+
property: key,
|
|
68
|
+
pseudo: pseudo == null ? void 0 : pseudo.name,
|
|
69
|
+
value,
|
|
70
|
+
identifier,
|
|
71
|
+
rules
|
|
72
|
+
};
|
|
73
|
+
cache.set(hash, valueString, styleObject);
|
|
74
|
+
out.push(styleObject);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (style.borderColor === "transparent") {
|
|
79
|
+
debugger;
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}, "generateAtomicStyles");
|
|
48
83
|
const reducedStyleKeys = {
|
|
49
84
|
shadowColor: true,
|
|
50
85
|
shadowOffset: true,
|
|
@@ -54,58 +89,116 @@ const reducedStyleKeys = {
|
|
|
54
89
|
textShadowOffset: true,
|
|
55
90
|
textShadowRadius: true
|
|
56
91
|
};
|
|
92
|
+
let shorthands = null;
|
|
57
93
|
function expandStyles(style) {
|
|
58
94
|
const res = {};
|
|
59
95
|
boxShadowReducer(res, style);
|
|
60
96
|
textShadowReducer(res, style);
|
|
61
|
-
|
|
97
|
+
borderReducer(res, style);
|
|
98
|
+
for (let key in style) {
|
|
99
|
+
shorthands = shorthands || (0, import_conf.getConfig)().shorthands;
|
|
100
|
+
if (shorthands) {
|
|
101
|
+
key = shorthands[key] || key;
|
|
102
|
+
}
|
|
62
103
|
if (reducedStyleKeys[key])
|
|
63
104
|
continue;
|
|
64
105
|
if (key in import_pseudos.pseudos) {
|
|
65
106
|
res[key] = expandStyles(style[key]);
|
|
66
107
|
} else {
|
|
67
|
-
|
|
108
|
+
const val = normalizeValueWithProperty(style[key], key);
|
|
109
|
+
const out = expandStyle(key, val);
|
|
110
|
+
if (out) {
|
|
111
|
+
Object.assign(res, Object.fromEntries(out));
|
|
112
|
+
} else {
|
|
113
|
+
res[key] = val;
|
|
114
|
+
}
|
|
68
115
|
}
|
|
69
116
|
}
|
|
70
117
|
return res;
|
|
71
118
|
}
|
|
72
119
|
__name(expandStyles, "expandStyles");
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
} else {
|
|
79
|
-
style[key] = value;
|
|
120
|
+
function borderReducer(res, cur) {
|
|
121
|
+
for (const key in borderDefaults) {
|
|
122
|
+
if (key in cur) {
|
|
123
|
+
res[borderDefaults[key]] = cur[borderDefaults[key]] || "solid";
|
|
124
|
+
}
|
|
80
125
|
}
|
|
81
126
|
}
|
|
82
|
-
__name(
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
127
|
+
__name(borderReducer, "borderReducer");
|
|
128
|
+
const borderDefaults = {
|
|
129
|
+
borderWidth: "borderStyle",
|
|
130
|
+
borderBottomWidth: "borderBottomStyle",
|
|
131
|
+
borderTopWidth: "borderTopStyle",
|
|
132
|
+
borderLeftWidth: "borderLeftStyle",
|
|
133
|
+
borderRightWidth: "borderRightStyle"
|
|
134
|
+
};
|
|
135
|
+
function createDeclarationBlock(style, important = false) {
|
|
136
|
+
let declarations = "";
|
|
137
|
+
for (const key in style) {
|
|
138
|
+
const prop = (0, import_hyphenate_style_name.default)(key);
|
|
139
|
+
const value = style[key];
|
|
140
|
+
declarations += `${prop}:${value}`;
|
|
141
|
+
}
|
|
142
|
+
return `{${declarations}${important ? ` !important` : ""};}`;
|
|
143
|
+
}
|
|
144
|
+
__name(createDeclarationBlock, "createDeclarationBlock");
|
|
145
|
+
const pseudoSelectorPrefixes = (() => {
|
|
146
|
+
const res = {};
|
|
147
|
+
for (const key in import_pseudos.pseudos) {
|
|
148
|
+
const pseudo = import_pseudos.pseudos[key];
|
|
149
|
+
res[pseudo.name] = [...Array(pseudo.priority)].map(() => ":root").join("") + " ";
|
|
150
|
+
}
|
|
151
|
+
return res;
|
|
152
|
+
})();
|
|
153
|
+
function createAtomicRules(identifier, property, value, pseudo) {
|
|
154
|
+
const selector = pseudo ? `${pseudoSelectorPrefixes[pseudo.name]} .${identifier}:${pseudo.name}` : `.${identifier}`;
|
|
155
|
+
const important = !!pseudo;
|
|
156
|
+
let rules = [];
|
|
157
|
+
switch (property) {
|
|
158
|
+
case "placeholderTextColor": {
|
|
159
|
+
const block = createDeclarationBlock({ color: value, opacity: 1 }, important);
|
|
160
|
+
rules.push(`${selector}::placeholder${block}`);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case "pointerEvents": {
|
|
164
|
+
let finalValue = value;
|
|
165
|
+
if (value === "auto" || value === "box-only") {
|
|
166
|
+
finalValue = "auto!important";
|
|
167
|
+
if (value === "box-only") {
|
|
168
|
+
const block2 = createDeclarationBlock({ pointerEvents: "none" }, important);
|
|
169
|
+
rules.push(`${selector}>*${block2}`);
|
|
170
|
+
}
|
|
171
|
+
} else if (value === "none" || value === "box-none") {
|
|
172
|
+
finalValue = "none!important";
|
|
173
|
+
if (value === "box-none") {
|
|
174
|
+
const block2 = createDeclarationBlock({ pointerEvents: "auto" }, important);
|
|
175
|
+
rules.push(`${selector}>*${block2}`);
|
|
176
|
+
}
|
|
104
177
|
}
|
|
178
|
+
const block = createDeclarationBlock({ pointerEvents: finalValue }, important);
|
|
179
|
+
rules.push(`${selector}${block}`);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "scrollbarWidth": {
|
|
183
|
+
if (value === "none") {
|
|
184
|
+
rules.push(`${selector}::-webkit-scrollbar{display:none}`);
|
|
185
|
+
}
|
|
186
|
+
const block = createDeclarationBlock({ scrollbarWidth: value }, important);
|
|
187
|
+
rules.push(`${selector}${block}`);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
default: {
|
|
191
|
+
const block = createDeclarationBlock({ [property]: value }, important);
|
|
192
|
+
rules.push(`${selector}${block}`);
|
|
193
|
+
break;
|
|
105
194
|
}
|
|
106
195
|
}
|
|
107
|
-
|
|
108
|
-
}
|
|
196
|
+
if ((pseudo == null ? void 0 : pseudo.name) === "hover") {
|
|
197
|
+
rules = rules.map((r) => `@media not all and (hover: none) { ${r} }`);
|
|
198
|
+
}
|
|
199
|
+
return rules;
|
|
200
|
+
}
|
|
201
|
+
__name(createAtomicRules, "createAtomicRules");
|
|
109
202
|
function expandStyle(key, value) {
|
|
110
203
|
if (key === "flex") {
|
|
111
204
|
if (value <= -1) {
|
|
@@ -170,61 +263,6 @@ function expandStyle(key, value) {
|
|
|
170
263
|
}
|
|
171
264
|
}
|
|
172
265
|
__name(expandStyle, "expandStyle");
|
|
173
|
-
function createAtomicRules(identifier, property, value) {
|
|
174
|
-
const rules = [];
|
|
175
|
-
const selector = `.${identifier}`;
|
|
176
|
-
switch (property) {
|
|
177
|
-
case "placeholderTextColor": {
|
|
178
|
-
const block = createDeclarationBlock({ color: value, opacity: 1 });
|
|
179
|
-
rules.push(`${selector}::placeholder${block}`);
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
case "pointerEvents": {
|
|
183
|
-
let finalValue = value;
|
|
184
|
-
if (value === "auto" || value === "box-only") {
|
|
185
|
-
finalValue = "auto!important";
|
|
186
|
-
if (value === "box-only") {
|
|
187
|
-
const block2 = createDeclarationBlock({ pointerEvents: "none" });
|
|
188
|
-
rules.push(`${selector}>*${block2}`);
|
|
189
|
-
}
|
|
190
|
-
} else if (value === "none" || value === "box-none") {
|
|
191
|
-
finalValue = "none!important";
|
|
192
|
-
if (value === "box-none") {
|
|
193
|
-
const block2 = createDeclarationBlock({ pointerEvents: "auto" });
|
|
194
|
-
rules.push(`${selector}>*${block2}`);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
const block = createDeclarationBlock({ pointerEvents: finalValue });
|
|
198
|
-
rules.push(`${selector}${block}`);
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
case "scrollbarWidth": {
|
|
202
|
-
if (value === "none") {
|
|
203
|
-
rules.push(`${selector}::-webkit-scrollbar{display:none}`);
|
|
204
|
-
}
|
|
205
|
-
const block = createDeclarationBlock({ scrollbarWidth: value });
|
|
206
|
-
rules.push(`${selector}${block}`);
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
default: {
|
|
210
|
-
const block = createDeclarationBlock({ [property]: value });
|
|
211
|
-
rules.push(`${selector}${block}`);
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
return rules;
|
|
216
|
-
}
|
|
217
|
-
__name(createAtomicRules, "createAtomicRules");
|
|
218
|
-
function createDeclarationBlock(style) {
|
|
219
|
-
const domStyle = expandStyles(style);
|
|
220
|
-
const declarationsString = Object.keys(domStyle).map((property) => {
|
|
221
|
-
const value = domStyle[property];
|
|
222
|
-
const prop = (0, import_hyphenate_style_name.default)(property);
|
|
223
|
-
return `${prop}:${value}`;
|
|
224
|
-
}).sort().join(";");
|
|
225
|
-
return `{${declarationsString};}`;
|
|
226
|
-
}
|
|
227
|
-
__name(createDeclarationBlock, "createDeclarationBlock");
|
|
228
266
|
const cache = {
|
|
229
267
|
get(property, value) {
|
|
230
268
|
if (cache[property] != null && cache[property].hasOwnProperty(value) && cache[property][value] != null) {
|
|
@@ -297,7 +335,13 @@ const normalizeColor = /* @__PURE__ */ __name((color, opacity = 1) => {
|
|
|
297
335
|
}
|
|
298
336
|
return `${color}`;
|
|
299
337
|
}, "normalizeColor");
|
|
300
|
-
const
|
|
338
|
+
const webColors = {
|
|
339
|
+
currentColor: true,
|
|
340
|
+
currentcolor: true,
|
|
341
|
+
transparent: true,
|
|
342
|
+
inherit: true
|
|
343
|
+
};
|
|
344
|
+
const isWebColor = /* @__PURE__ */ __name((color) => webColors[color] || color.indexOf("var(") === 0, "isWebColor");
|
|
301
345
|
const processColor = /* @__PURE__ */ __name((color) => {
|
|
302
346
|
if (color === void 0 || color === null) {
|
|
303
347
|
return color;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/generateAtomicStyles.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Some parts adapted from react-native-web\n * Copyright (c) Nicolas Gallagher licensed under the MIT license.\n */\n\nimport { simpleHash } from '@tamagui/helpers'\nimport hyphenateStyleName from 'hyphenate-style-name'\nimport normalizeCSSColor from 'normalize-css-color'\nimport { TextStyle, ViewStyle } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { pseudos } from './pseudos'\n\ntype Value = Object | Array<any> | string | number\nexport type Style = { [key: string]: Value }\n\ntype Rule = string\ntype Rules = Array<Rule>\n\nexport type RulesData = {\n property?: string\n value?: string\n identifier: string\n rules: Rules\n}\n\ntype CompilerOutput = { [key: string]: RulesData }\n\nconst reducedStyleKeys = {\n shadowColor: true,\n shadowOffset: true,\n shadowOpacity: true,\n shadowRadius: true,\n textShadowColor: true,\n textShadowOffset: true,\n textShadowRadius: true,\n}\n\nexport function expandStyles(style: any) {\n const res = {}\n boxShadowReducer(res, style)\n textShadowReducer(res, style)\n for (const key in style) {\n if (reducedStyleKeys[key]) continue\n if (key in pseudos) {\n res[key] = expandStyles(style[key])\n } else {\n updateReactDOMStyle(res, key, style[key])\n }\n }\n return res\n}\n\nfunction updateReactDOMStyle(style: Object, key: string, value: any) {\n value = normalizeValueWithProperty(value, key)\n const out = expandStyle(key, value)\n if (out) {\n Object.assign(style, Object.fromEntries(out))\n } else {\n style[key] = value\n }\n}\n\nexport const generateAtomicStyles = (style: ViewStyle & TextStyle): CompilerOutput => {\n const res = expandStyles(style)\n\n const out = {}\n for (const key in res) {\n const value = res[key]\n if (value != null) {\n const valueString = stringifyValueWithProperty(value, key)\n const cachedResult = cache.get(key, valueString)\n if (cachedResult != null) {\n const { identifier } = cachedResult\n out[identifier] = cachedResult\n } else {\n const identifier = simpleHash(key + valueString)\n const rules = createAtomicRules(identifier, key, valueString)\n const cachedResult = cache.set(key, valueString, {\n property: key,\n value: valueString,\n identifier,\n rules,\n })\n out[identifier] = cachedResult\n }\n }\n }\n\n return out\n}\n\nexport function expandStyle(key: string, value: any) {\n if (key === 'flex') {\n // The 'flex' property value in React Native must be a positive integer,\n // 0, or -1.\n if (value <= -1) {\n return [\n ['flexGrow', 0],\n ['flexShrink', 1],\n ['flexBasis', 'auto'],\n ]\n }\n // normalizing to better align with native\n // see spec for flex shorthand https://developer.mozilla.org/en-US/docs/Web/CSS/flex\n if (value >= 0) {\n return [\n ['flexGrow', value],\n ['flexShrink', 1],\n ]\n }\n return\n }\n\n // web only\n switch (key) {\n // Ignore some React Native styles\n case 'elevation':\n case 'overlayColor':\n case 'resizeMode':\n case 'tintColor': {\n break\n }\n\n case 'aspectRatio': {\n return [[key, value.toString()]]\n }\n\n // TODO: remove once this issue is fixed\n // https://github.com/rofrischmann/inline-style-prefixer/issues/159\n case 'backgroundClip': {\n if (value === 'text') {\n return [\n ['backgroundClip', value],\n ['WebkitBackgroundClip', value],\n ]\n }\n break\n }\n\n case 'textAlignVertical': {\n return [['verticalAlign', value === 'center' ? 'middle' : value]]\n }\n\n case 'textDecorationLine': {\n return [['textDecorationLine', value]]\n }\n\n case 'transform': {\n if (Array.isArray(value)) {\n return [[key, value.map(mapTransform).join(' ')]]\n }\n break\n }\n\n case 'writingDirection': {\n return [['direction', value]]\n }\n }\n\n const longKey = STYLE_SHORT_FORM_EXPANSIONS[key]\n if (longKey) {\n return longKey.map((key) => {\n return [key, value]\n })\n } else {\n if (isWeb && Array.isArray(value)) {\n return [[key, value.join(',')]]\n }\n }\n}\n\nfunction createAtomicRules(identifier: string, property, value): Rules {\n const rules: string[] = []\n const selector = `.${identifier}`\n\n // Handle non-standard properties and object values that require multiple\n // CSS rules to be created.\n switch (property) {\n // Equivalent to using '::placeholder'\n case 'placeholderTextColor': {\n const block = createDeclarationBlock({ color: value, opacity: 1 })\n rules.push(`${selector}::placeholder${block}`)\n break\n }\n\n // Polyfill for additional 'pointer-events' values\n // See d13f78622b233a0afc0c7a200c0a0792c8ca9e58\n case 'pointerEvents': {\n let finalValue = value\n if (value === 'auto' || value === 'box-only') {\n finalValue = 'auto!important'\n if (value === 'box-only') {\n const block = createDeclarationBlock({ pointerEvents: 'none' })\n rules.push(`${selector}>*${block}`)\n }\n } else if (value === 'none' || value === 'box-none') {\n finalValue = 'none!important'\n if (value === 'box-none') {\n const block = createDeclarationBlock({ pointerEvents: 'auto' })\n rules.push(`${selector}>*${block}`)\n }\n }\n const block = createDeclarationBlock({ pointerEvents: finalValue })\n rules.push(`${selector}${block}`)\n break\n }\n\n // Polyfill for draft spec\n // https://drafts.csswg.org/css-scrollbars-1/\n case 'scrollbarWidth': {\n if (value === 'none') {\n rules.push(`${selector}::-webkit-scrollbar{display:none}`)\n }\n const block = createDeclarationBlock({ scrollbarWidth: value })\n rules.push(`${selector}${block}`)\n break\n }\n\n default: {\n const block = createDeclarationBlock({ [property]: value })\n rules.push(`${selector}${block}`)\n break\n }\n }\n\n return rules\n}\n\n/**\n * Creates a CSS declaration block from a StyleSheet object.\n */\nfunction createDeclarationBlock(style: Style) {\n const domStyle = expandStyles(style)\n const declarationsString = Object.keys(domStyle)\n .map((property) => {\n const value = domStyle[property]\n const prop = hyphenateStyleName(property)\n return `${prop}:${value}`\n })\n // Once properties are hyphenated, this will put the vendor\n // prefixed and short-form properties first in the list.\n .sort()\n .join(';')\n\n return `{${declarationsString};}`\n}\n\nconst cache = {\n get(property, value) {\n if (\n cache[property] != null &&\n cache[property].hasOwnProperty(value) &&\n cache[property][value] != null\n ) {\n return cache[property][value]\n }\n },\n set(property, value, object) {\n if (cache[property] == null) {\n cache[property] = {}\n }\n return (cache[property][value] = object)\n },\n}\n\nfunction stringifyValueWithProperty(value: Value, property?: string): string {\n // e.g., 0 => '0px', 'black' => 'rgba(0,0,0,1)'\n return normalizeValueWithProperty(value, property)\n}\n\n// { scale: 2 } => 'scale(2)'\n// { translateX: 20 } => 'translateX(20px)'\n// { matrix: [1,2,3,4,5,6] } => 'matrix(1,2,3,4,5,6)'\nconst mapTransform = (transform) => {\n const type = Object.keys(transform)[0]\n const value = transform[type]\n if (type === 'matrix' || type === 'matrix3d') {\n return `${type}(${value.join(',')})`\n } else {\n const normalizedValue = normalizeValueWithProperty(value, type)\n return `${type}(${normalizedValue})`\n }\n}\n\nconst colorProps = {\n backgroundColor: true,\n borderColor: true,\n borderTopColor: true,\n borderRightColor: true,\n borderBottomColor: true,\n borderLeftColor: true,\n color: true,\n shadowColor: true,\n textDecorationColor: true,\n textShadowColor: true,\n}\n\nfunction normalizeValueWithProperty(value: any, property?: string): any {\n if (process.env.TAMAGUI_TARGET === 'web') {\n const shouldCoerceToPx =\n typeof value === 'number' &&\n (property === undefined || property === null || !unitlessNumbers[property])\n if (shouldCoerceToPx) {\n return `${value}px`\n }\n }\n if (property && colorProps[property]) {\n return normalizeColor(value)\n }\n return value\n}\n\nconst normalizeColor = (color?: number | string, opacity = 1): void | string => {\n if (color == null || color == undefined) {\n return\n }\n if (process.env.TAMAGUI_TARGET === 'web') {\n if (typeof color === 'string' && isWebColor(color)) {\n return color\n }\n }\n const colorInt = processColor(color)\n if (colorInt != null) {\n const r = (colorInt >> 16) & 255\n const g = (colorInt >> 8) & 255\n const b = colorInt & 255\n const a = ((colorInt >> 24) & 255) / 255\n const alpha = (a * opacity).toFixed(2)\n return `rgba(${r},${g},${b},${alpha})`\n }\n return `${color}`\n}\n\nconst isWebColor = (color: string): boolean =>\n color === 'currentcolor' ||\n color === 'currentColor' ||\n color === 'inherit' ||\n color.indexOf('var(') === 0\n\nconst processColor = (color?: number | string): number | undefined | null => {\n if (color === undefined || color === null) {\n return color\n }\n let intColor = normalizeCSSColor(color)\n if (intColor === undefined || intColor === null) {\n return undefined\n }\n return ((+intColor << 24) | (+intColor >>> 8)) >>> 0\n}\n\nconst unitlessNumbers = {\n animationIterationCount: true,\n aspectRatio: true,\n borderImageOutset: true,\n borderImageSlice: true,\n borderImageWidth: true,\n boxFlex: true,\n boxFleGroup: true,\n boxOrdinalGroup: true,\n columnCount: true,\n flex: true,\n flexGrow: true,\n flexOrder: true,\n flexPositive: true,\n flexShrink: true,\n flexNegative: true,\n fontWeight: true,\n gridRow: true,\n gridRowEnd: true,\n gridRowGap: true,\n gridRowStart: true,\n gridColumn: true,\n gridColumnEnd: true,\n gridColumnGap: true,\n gridColumnStart: true,\n lineClamp: true,\n opacity: true,\n order: true,\n orphans: true,\n tabSize: true,\n widows: true,\n zIndex: true,\n zoom: true,\n fillOpacity: true,\n floodOpacity: true,\n stopOpacity: true,\n strokeDasharray: true,\n strokeDashoffset: true,\n strokeMiterlimit: true,\n strokeOpacity: true,\n strokeWidth: true,\n scale: true,\n scaleX: true,\n scaleY: true,\n scaleZ: true,\n shadowOpacity: true,\n}\n\n/**\n * Support style names that may come passed in prefixed by adding permutations\n * of vendor prefixes.\n */\n\nconst resolveShadowValue = (style: ViewStyle): void | string => {\n const { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style\n if (shadowRadius === undefined) {\n return\n }\n const { height, width } = shadowOffset || defaultOffset\n const offsetX = normalizeValueWithProperty(width)\n const offsetY = normalizeValueWithProperty(height)\n const blurRadius = normalizeValueWithProperty(shadowRadius || 0)\n const color = normalizeColor(String(shadowColor || 'black'), shadowOpacity)\n return `${offsetX} ${offsetY} ${blurRadius} ${color}`\n}\n\nfunction boxShadowReducer(resolvedStyle, style) {\n const { boxShadow } = style\n const shadow = resolveShadowValue(style)\n if (shadow != null) {\n resolvedStyle.boxShadow = boxShadow ? `${boxShadow}, ${shadow}` : shadow\n }\n}\n\nconst defaultOffset = { height: 0, width: 0 }\nfunction textShadowReducer(resolvedStyle, style) {\n const { textShadowColor, textShadowOffset, textShadowRadius } = style\n const { height, width } = textShadowOffset || defaultOffset\n const radius = textShadowRadius || 0\n const offsetX = normalizeValueWithProperty(width)\n const offsetY = normalizeValueWithProperty(height)\n const blurRadius = normalizeValueWithProperty(radius)\n const color = normalizeValueWithProperty(textShadowColor, 'textShadowColor')\n\n if (\n color &&\n (height !== 0 || width !== 0 || radius !== 0) &&\n offsetX != null &&\n offsetY != null &&\n blurRadius != null\n ) {\n resolvedStyle.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`\n }\n}\n\nconst STYLE_SHORT_FORM_EXPANSIONS = {\n borderColor: ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor'],\n borderRadius: [\n 'borderTopLeftRadius',\n 'borderTopRightRadius',\n 'borderBottomRightRadius',\n 'borderBottomLeftRadius',\n ],\n borderStyle: ['borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle'],\n borderWidth: ['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth'],\n margin: ['marginTop', 'marginRight', 'marginBottom', 'marginLeft'],\n marginHorizontal: ['marginRight', 'marginLeft'],\n marginVertical: ['marginTop', 'marginBottom'],\n overscrollBehavior: ['overscrollBehaviorX', 'overscrollBehaviorY'],\n padding: ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'],\n paddingHorizontal: ['paddingRight', 'paddingLeft'],\n paddingVertical: ['paddingTop', 'paddingBottom'],\n ...(isWeb && {\n // react-native doesn't support X / Y\n overflow: ['overflowX', 'overflowY'],\n }),\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,
|
|
4
|
+
"sourcesContent": ["/**\n * Some parts adapted from react-native-web\n * Copyright (c) Nicolas Gallagher licensed under the MIT license.\n */\n\nimport { StyleObject, simpleHash } from '@tamagui/helpers'\nimport hyphenateStyleName from 'hyphenate-style-name'\nimport normalizeCSSColor from 'normalize-css-color'\nimport { TextStyle, ViewStyle } from 'react-native'\n\nimport { getConfig } from '../conf'\nimport { isWeb } from '../constants/platform'\nimport { reversedShorthands } from '../createTamagui'\nimport { PseudoDescriptor, pseudos } from './pseudos'\n\ntype Value = Object | Array<any> | string | number\nexport type Style = { [key: string]: Value }\n\nexport const generateAtomicStyles = (\n style: ViewStyle & TextStyle,\n pseudo?: PseudoDescriptor\n): StyleObject[] => {\n const res = expandStyles(style)\n const out: StyleObject[] = []\n for (const key in res) {\n const value = res[key]\n if (value != null) {\n const valueString = stringifyValueWithProperty(value, key)\n const hash = simpleHash(key + valueString + (pseudo?.name || ''))\n const cachedResult = cache.get(hash, valueString)\n if (cachedResult != null) {\n out.push(cachedResult)\n } else {\n const pseudoPrefix = pseudo ? `0${pseudo.name}-` : ''\n const shortProp = reversedShorthands[key] || key\n const identifier = `_${shortProp}-${pseudoPrefix}${hash}`\n const rules = createAtomicRules(identifier, key, valueString, pseudo)\n const styleObject: StyleObject = {\n property: key,\n pseudo: pseudo?.name,\n value,\n identifier,\n rules,\n }\n cache.set(hash, valueString, styleObject)\n out.push(styleObject)\n }\n }\n }\n if (style.borderColor === 'transparent') {\n debugger\n }\n return out\n}\n\nconst reducedStyleKeys = {\n shadowColor: true,\n shadowOffset: true,\n shadowOpacity: true,\n shadowRadius: true,\n textShadowColor: true,\n textShadowOffset: true,\n textShadowRadius: true,\n}\n\nlet shorthands: Record<string, string> | null = null\n\n// can likely remove this and include in other loops\nexport function expandStyles(style: any) {\n const res = {}\n boxShadowReducer(res, style)\n textShadowReducer(res, style)\n borderReducer(res, style)\n for (let key in style) {\n shorthands = shorthands || getConfig().shorthands\n if (shorthands) {\n key = shorthands[key] || key\n }\n if (reducedStyleKeys[key]) continue\n if (key in pseudos) {\n res[key] = expandStyles(style[key])\n } else {\n const val = normalizeValueWithProperty(style[key], key)\n const out = expandStyle(key, val)\n if (out) {\n Object.assign(res, Object.fromEntries(out))\n } else {\n res[key] = val\n }\n }\n }\n return res\n}\n\n// why is this diff from react-native-web!? need to figure out\nfunction borderReducer(res: any, cur: any) {\n for (const key in borderDefaults) {\n if (key in cur) {\n res[borderDefaults[key]] = cur[borderDefaults[key]] || 'solid'\n }\n }\n}\n\nconst borderDefaults = {\n borderWidth: 'borderStyle',\n borderBottomWidth: 'borderBottomStyle',\n borderTopWidth: 'borderTopStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n}\n\nfunction createDeclarationBlock(style: Style, important = false) {\n let declarations = ''\n for (const key in style) {\n const prop = hyphenateStyleName(key)\n const value = style[key]\n declarations += `${prop}:${value}`\n }\n return `{${declarations}${important ? ` !important` : ''};}`\n}\n\nconst pseudoSelectorPrefixes = (() => {\n const res: Record<string, string> = {}\n for (const key in pseudos) {\n const pseudo = pseudos[key]\n res[pseudo.name] = [...Array(pseudo.priority)].map(() => ':root').join('') + ' '\n }\n return res\n})()\n\nfunction createAtomicRules(\n identifier: string,\n property: string,\n value: any,\n pseudo?: PseudoDescriptor\n): string[] {\n const selector = pseudo\n ? `${pseudoSelectorPrefixes[pseudo.name]} .${identifier}:${pseudo.name}`\n : `.${identifier}`\n const important = !!pseudo\n\n let rules: string[] = []\n\n // Handle non-standard properties and object values that require multiple\n // CSS rules to be created.\n switch (property) {\n // Equivalent to using '::placeholder'\n case 'placeholderTextColor': {\n const block = createDeclarationBlock({ color: value, opacity: 1 }, important)\n rules.push(`${selector}::placeholder${block}`)\n break\n }\n\n // Polyfill for additional 'pointer-events' values\n // See d13f78622b233a0afc0c7a200c0a0792c8ca9e58\n case 'pointerEvents': {\n let finalValue = value\n if (value === 'auto' || value === 'box-only') {\n finalValue = 'auto!important'\n if (value === 'box-only') {\n const block = createDeclarationBlock({ pointerEvents: 'none' }, important)\n rules.push(`${selector}>*${block}`)\n }\n } else if (value === 'none' || value === 'box-none') {\n finalValue = 'none!important'\n if (value === 'box-none') {\n const block = createDeclarationBlock({ pointerEvents: 'auto' }, important)\n rules.push(`${selector}>*${block}`)\n }\n }\n const block = createDeclarationBlock({ pointerEvents: finalValue }, important)\n rules.push(`${selector}${block}`)\n break\n }\n\n // Polyfill for draft spec\n // https://drafts.csswg.org/css-scrollbars-1/\n case 'scrollbarWidth': {\n if (value === 'none') {\n rules.push(`${selector}::-webkit-scrollbar{display:none}`)\n }\n const block = createDeclarationBlock({ scrollbarWidth: value }, important)\n rules.push(`${selector}${block}`)\n break\n }\n\n default: {\n const block = createDeclarationBlock({ [property]: value }, important)\n rules.push(`${selector}${block}`)\n break\n }\n }\n\n // hover styles need to be conditional\n // perhaps this can be generalized but for now lets just shortcut\n // and hardcode for hover styles, if we need to later we can\n // WEIRD SYNTAX, SEE:\n // https://stackoverflow.com/questions/40532204/media-query-for-devices-supporting-hover\n if (pseudo?.name === 'hover') {\n rules = rules.map((r) => `@media not all and (hover: none) { ${r} }`)\n }\n\n return rules\n}\n\nexport function expandStyle(key: string, value: any) {\n if (key === 'flex') {\n // The 'flex' property value in React Native must be a positive integer,\n // 0, or -1.\n if (value <= -1) {\n return [\n ['flexGrow', 0],\n ['flexShrink', 1],\n ['flexBasis', 'auto'],\n ]\n }\n // normalizing to better align with native\n // see spec for flex shorthand https://developer.mozilla.org/en-US/docs/Web/CSS/flex\n if (value >= 0) {\n return [\n ['flexGrow', value],\n ['flexShrink', 1],\n ]\n }\n return\n }\n\n // web only\n switch (key) {\n // Ignore some React Native styles\n case 'elevation':\n case 'overlayColor':\n case 'resizeMode':\n case 'tintColor': {\n break\n }\n\n case 'aspectRatio': {\n return [[key, value.toString()]]\n }\n\n // TODO: remove once this issue is fixed\n // https://github.com/rofrischmann/inline-style-prefixer/issues/159\n case 'backgroundClip': {\n if (value === 'text') {\n return [\n ['backgroundClip', value],\n ['WebkitBackgroundClip', value],\n ]\n }\n break\n }\n\n case 'textAlignVertical': {\n return [['verticalAlign', value === 'center' ? 'middle' : value]]\n }\n\n case 'textDecorationLine': {\n return [['textDecorationLine', value]]\n }\n\n case 'transform': {\n if (Array.isArray(value)) {\n return [[key, value.map(mapTransform).join(' ')]]\n }\n break\n }\n\n case 'writingDirection': {\n return [['direction', value]]\n }\n }\n\n const longKey = STYLE_SHORT_FORM_EXPANSIONS[key]\n if (longKey) {\n return longKey.map((key) => {\n return [key, value]\n })\n } else {\n if (isWeb && Array.isArray(value)) {\n return [[key, value.join(',')]]\n }\n }\n}\n\nconst cache = {\n get(property, value) {\n if (\n cache[property] != null &&\n cache[property].hasOwnProperty(value) &&\n cache[property][value] != null\n ) {\n return cache[property][value]\n }\n },\n set(property, value, object) {\n if (cache[property] == null) {\n cache[property] = {}\n }\n return (cache[property][value] = object)\n },\n}\n\nfunction stringifyValueWithProperty(value: Value, property?: string): string {\n // e.g., 0 => '0px', 'black' => 'rgba(0,0,0,1)'\n return normalizeValueWithProperty(value, property)\n}\n\n// { scale: 2 } => 'scale(2)'\n// { translateX: 20 } => 'translateX(20px)'\n// { matrix: [1,2,3,4,5,6] } => 'matrix(1,2,3,4,5,6)'\nconst mapTransform = (transform) => {\n const type = Object.keys(transform)[0]\n const value = transform[type]\n if (type === 'matrix' || type === 'matrix3d') {\n return `${type}(${value.join(',')})`\n } else {\n const normalizedValue = normalizeValueWithProperty(value, type)\n return `${type}(${normalizedValue})`\n }\n}\n\nconst colorProps = {\n backgroundColor: true,\n borderColor: true,\n borderTopColor: true,\n borderRightColor: true,\n borderBottomColor: true,\n borderLeftColor: true,\n color: true,\n shadowColor: true,\n textDecorationColor: true,\n textShadowColor: true,\n}\n\nfunction normalizeValueWithProperty(value: any, property?: string): any {\n if (process.env.TAMAGUI_TARGET === 'web') {\n const shouldCoerceToPx =\n typeof value === 'number' &&\n (property === undefined || property === null || !unitlessNumbers[property])\n if (shouldCoerceToPx) {\n return `${value}px`\n }\n }\n if (property && colorProps[property]) {\n return normalizeColor(value)\n }\n return value\n}\n\nconst normalizeColor = (color?: number | string, opacity = 1): void | string => {\n if (color == null || color == undefined) {\n return\n }\n if (process.env.TAMAGUI_TARGET === 'web') {\n if (typeof color === 'string' && isWebColor(color)) {\n return color\n }\n }\n const colorInt = processColor(color)\n if (colorInt != null) {\n const r = (colorInt >> 16) & 255\n const g = (colorInt >> 8) & 255\n const b = colorInt & 255\n const a = ((colorInt >> 24) & 255) / 255\n const alpha = (a * opacity).toFixed(2)\n return `rgba(${r},${g},${b},${alpha})`\n }\n return `${color}`\n}\n\nconst webColors = {\n currentColor: true,\n currentcolor: true,\n transparent: true,\n inherit: true,\n}\n\nconst isWebColor = (color: string): boolean => webColors[color] || color.indexOf('var(') === 0\n\nconst processColor = (color?: number | string): number | undefined | null => {\n if (color === undefined || color === null) {\n return color\n }\n let intColor = normalizeCSSColor(color)\n if (intColor === undefined || intColor === null) {\n return undefined\n }\n return ((+intColor << 24) | (+intColor >>> 8)) >>> 0\n}\n\nconst unitlessNumbers = {\n animationIterationCount: true,\n aspectRatio: true,\n borderImageOutset: true,\n borderImageSlice: true,\n borderImageWidth: true,\n boxFlex: true,\n boxFleGroup: true,\n boxOrdinalGroup: true,\n columnCount: true,\n flex: true,\n flexGrow: true,\n flexOrder: true,\n flexPositive: true,\n flexShrink: true,\n flexNegative: true,\n fontWeight: true,\n gridRow: true,\n gridRowEnd: true,\n gridRowGap: true,\n gridRowStart: true,\n gridColumn: true,\n gridColumnEnd: true,\n gridColumnGap: true,\n gridColumnStart: true,\n lineClamp: true,\n opacity: true,\n order: true,\n orphans: true,\n tabSize: true,\n widows: true,\n zIndex: true,\n zoom: true,\n fillOpacity: true,\n floodOpacity: true,\n stopOpacity: true,\n strokeDasharray: true,\n strokeDashoffset: true,\n strokeMiterlimit: true,\n strokeOpacity: true,\n strokeWidth: true,\n scale: true,\n scaleX: true,\n scaleY: true,\n scaleZ: true,\n shadowOpacity: true,\n}\n\n/**\n * Support style names that may come passed in prefixed by adding permutations\n * of vendor prefixes.\n */\n\nconst resolveShadowValue = (style: ViewStyle): void | string => {\n const { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style\n if (shadowRadius === undefined) {\n return\n }\n const { height, width } = shadowOffset || defaultOffset\n const offsetX = normalizeValueWithProperty(width)\n const offsetY = normalizeValueWithProperty(height)\n const blurRadius = normalizeValueWithProperty(shadowRadius || 0)\n const color = normalizeColor(String(shadowColor || 'black'), shadowOpacity)\n return `${offsetX} ${offsetY} ${blurRadius} ${color}`\n}\n\nfunction boxShadowReducer(resolvedStyle: any, style: any) {\n const { boxShadow } = style\n const shadow = resolveShadowValue(style)\n if (shadow != null) {\n resolvedStyle.boxShadow = boxShadow ? `${boxShadow}, ${shadow}` : shadow\n }\n}\n\nconst defaultOffset = { height: 0, width: 0 }\n\nfunction textShadowReducer(resolvedStyle: any, style: any) {\n const { textShadowColor, textShadowOffset, textShadowRadius } = style\n const { height, width } = textShadowOffset || defaultOffset\n const radius = textShadowRadius || 0\n const offsetX = normalizeValueWithProperty(width)\n const offsetY = normalizeValueWithProperty(height)\n const blurRadius = normalizeValueWithProperty(radius)\n const color = normalizeValueWithProperty(textShadowColor, 'textShadowColor')\n\n if (\n color &&\n (height !== 0 || width !== 0 || radius !== 0) &&\n offsetX != null &&\n offsetY != null &&\n blurRadius != null\n ) {\n resolvedStyle.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`\n }\n}\n\nconst STYLE_SHORT_FORM_EXPANSIONS = {\n borderColor: ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor'],\n borderRadius: [\n 'borderTopLeftRadius',\n 'borderTopRightRadius',\n 'borderBottomRightRadius',\n 'borderBottomLeftRadius',\n ],\n borderStyle: ['borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle'],\n borderWidth: ['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth'],\n margin: ['marginTop', 'marginRight', 'marginBottom', 'marginLeft'],\n marginHorizontal: ['marginRight', 'marginLeft'],\n marginVertical: ['marginTop', 'marginBottom'],\n overscrollBehavior: ['overscrollBehaviorX', 'overscrollBehaviorY'],\n padding: ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'],\n paddingHorizontal: ['paddingRight', 'paddingLeft'],\n paddingVertical: ['paddingTop', 'paddingBottom'],\n ...(isWeb && {\n // react-native doesn't support X / Y\n overflow: ['overflowX', 'overflowY'],\n }),\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,qBAAwC;AACxC,kCAA+B;AAC/B,iCAA8B;AAG9B,kBAA0B;AAC1B,sBAAsB;AACtB,2BAAmC;AACnC,qBAA0C;AAKnC,MAAM,uBAAuB,wBAClC,OACA,WACkB;AAClB,QAAM,MAAM,aAAa,KAAK;AAC9B,QAAM,MAAqB,CAAC;AAC5B,aAAW,OAAO,KAAK;AACrB,UAAM,QAAQ,IAAI;AAClB,QAAI,SAAS,MAAM;AACjB,YAAM,cAAc,2BAA2B,OAAO,GAAG;AACzD,YAAM,OAAO,+BAAW,MAAM,cAAe,mCAAQ,SAAQ,GAAG;AAChE,YAAM,eAAe,MAAM,IAAI,MAAM,WAAW;AAChD,UAAI,gBAAgB,MAAM;AACxB,YAAI,KAAK,YAAY;AAAA,MACvB,OAAO;AACL,cAAM,eAAe,SAAS,IAAI,OAAO,UAAU;AACnD,cAAM,YAAY,wCAAmB,QAAQ;AAC7C,cAAM,aAAa,IAAI,aAAa,eAAe;AACnD,cAAM,QAAQ,kBAAkB,YAAY,KAAK,aAAa,MAAM;AACpE,cAAM,cAA2B;AAAA,UAC/B,UAAU;AAAA,UACV,QAAQ,iCAAQ;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,QACF;AACA,cAAM,IAAI,MAAM,aAAa,WAAW;AACxC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AAgB,YAAY;AAAA,EACjE,kBAAkB,CAAC,eAAe,YAAY;AAAA,EAC9C,gBAAgB,CAAC,aAAa,cAAc;AAAA,EAC5C,oBAAoB,CAAC,uBAAuB,qBAAqB;AAAA,EACjE,SAAS,CAAC,cAAc,gBAAgB,iBAAiB,aAAa;AAAA,EACtE,mBAAmB,CAAC,gBAAgB,aAAa;AAAA,EACjD,iBAAiB,CAAC,cAAc,eAAe;AAAA,GAC3C,yBAAS;AAAA,EAEX,UAAU,CAAC,aAAa,WAAW;AACrC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -36,6 +36,7 @@ __export(getSplitStyles_exports, {
|
|
|
36
36
|
getSubStyle: () => getSubStyle,
|
|
37
37
|
insertSplitStyles: () => insertSplitStyles,
|
|
38
38
|
normalizeStyleObject: () => normalizeStyleObject,
|
|
39
|
+
pseudoCNInverse: () => pseudoCNInverse,
|
|
39
40
|
useSplitStyles: () => useSplitStyles
|
|
40
41
|
});
|
|
41
42
|
module.exports = __toCommonJS(getSplitStyles_exports);
|
|
@@ -69,6 +70,11 @@ const skipProps = __spreadValues({
|
|
|
69
70
|
boxShadow: true
|
|
70
71
|
});
|
|
71
72
|
let conf;
|
|
73
|
+
const pseudoCNInverse = {
|
|
74
|
+
hover: "hoverStyle",
|
|
75
|
+
focus: "focusStyle",
|
|
76
|
+
press: "pressStyle"
|
|
77
|
+
};
|
|
72
78
|
const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state, defaultClassNames, debug) => {
|
|
73
79
|
var _a, _b;
|
|
74
80
|
conf = conf || (0, import_conf.getConfig)();
|
|
@@ -78,6 +84,9 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
78
84
|
const medias = {};
|
|
79
85
|
const usedKeys = /* @__PURE__ */ new Set();
|
|
80
86
|
let style = {};
|
|
87
|
+
if (state.hasTextAncestor) {
|
|
88
|
+
style.display = "inline-flex";
|
|
89
|
+
}
|
|
81
90
|
let classNames = {};
|
|
82
91
|
let transforms = null;
|
|
83
92
|
const rulesToInsert = [];
|
|
@@ -124,6 +133,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
124
133
|
}
|
|
125
134
|
__name(mergeClassName, "mergeClassName");
|
|
126
135
|
const propKeys = Object.keys(props);
|
|
136
|
+
const shouldDoClasses = import_platform.isWeb && !state.noClassNames;
|
|
127
137
|
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
128
138
|
console.log("propKeys", propKeys);
|
|
129
139
|
}
|
|
@@ -171,10 +181,10 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
171
181
|
if (isMedia2) {
|
|
172
182
|
let mediaShortKey = mediaOrPseudo.slice(1);
|
|
173
183
|
mediaShortKey = mediaShortKey.slice(0, mediaShortKey.indexOf("_"));
|
|
174
|
-
fullKey +=
|
|
184
|
+
fullKey += `_${mediaShortKey}`;
|
|
175
185
|
} else if (isPseudo2) {
|
|
176
186
|
const pseudoShortKey = mediaOrPseudo.slice(1);
|
|
177
|
-
fullKey +=
|
|
187
|
+
fullKey += `_${pseudoShortKey}`;
|
|
178
188
|
}
|
|
179
189
|
usedKeys.add(fullKey);
|
|
180
190
|
mergeClassName(fullKey, cn, isMediaOrPseudo2);
|
|
@@ -188,7 +198,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
188
198
|
}
|
|
189
199
|
continue;
|
|
190
200
|
}
|
|
191
|
-
if (
|
|
201
|
+
if (valInit && valInit[0] === "_") {
|
|
192
202
|
usedKeys.add(keyInit);
|
|
193
203
|
mergeClassName(keyInit, valInit);
|
|
194
204
|
continue;
|
|
@@ -238,14 +248,11 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
238
248
|
}
|
|
239
249
|
pseudos[key] = pseudos[key] || {};
|
|
240
250
|
pseudos[key] = getSubStyle(val, staticConfig, theme, props, state, true);
|
|
241
|
-
if (
|
|
242
|
-
const shorthand = import_pseudos.pseudos[key].name;
|
|
243
|
-
if ((_b = props.forceStyle) == null ? void 0 : _b[shorthand]) {
|
|
244
|
-
console.warn("force");
|
|
245
|
-
}
|
|
251
|
+
if (shouldDoClasses) {
|
|
246
252
|
const pseudoStyles = (0, import_getStylesAtomic.getStylesAtomic)({ [key]: pseudos[key] });
|
|
247
253
|
for (const style2 of pseudoStyles) {
|
|
248
|
-
const
|
|
254
|
+
const postfix = ((_b = import_pseudos.pseudos[key]) == null ? void 0 : _b.name) || key;
|
|
255
|
+
const fullKey = `${style2.property}_${postfix}`;
|
|
249
256
|
if (!usedKeys.has(fullKey)) {
|
|
250
257
|
usedKeys.add(fullKey);
|
|
251
258
|
addStyle(style2.identifier, style2.rules.join(";"));
|
|
@@ -265,7 +272,6 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
265
272
|
continue;
|
|
266
273
|
}
|
|
267
274
|
const mediaStyle = getSubStyle(val, staticConfig, theme, props, state);
|
|
268
|
-
const shouldDoClasses = import_platform.isWeb && !state.noClassNames;
|
|
269
275
|
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
270
276
|
console.log(" \xBB getSplitStyles mediaStyle", { mediaKey, mediaStyle, props, shouldDoClasses });
|
|
271
277
|
}
|
|
@@ -273,7 +279,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
273
279
|
const mediaStyles = (0, import_getStylesAtomic.getStylesAtomic)(mediaStyle);
|
|
274
280
|
for (const style2 of mediaStyles) {
|
|
275
281
|
const out = (0, import_createMediaStyle.createMediaStyle)(style2, mediaKeyShort, import_useMedia.mediaQueryConfig);
|
|
276
|
-
const fullKey = `${style2.property}
|
|
282
|
+
const fullKey = `${style2.property}_${mediaKeyShort}`;
|
|
277
283
|
if (!usedKeys.has(fullKey)) {
|
|
278
284
|
usedKeys.add(fullKey);
|
|
279
285
|
addStyle(out.identifier, out.styleRule);
|
|
@@ -299,15 +305,10 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
299
305
|
usedKeys.add(key);
|
|
300
306
|
if (val && val[0] === "_") {
|
|
301
307
|
classNames[key] = val;
|
|
308
|
+
} else if (key in import_helpers.stylePropsTransform) {
|
|
309
|
+
(0, import_mergeTransform.mergeTransform)(style, key, val, true);
|
|
302
310
|
} else {
|
|
303
|
-
|
|
304
|
-
if (process.env.NODE_ENV === "development" && debug) {
|
|
305
|
-
console.log(" > mergeTransform", key, val);
|
|
306
|
-
}
|
|
307
|
-
(0, import_mergeTransform.mergeTransform)(style, key, val, true);
|
|
308
|
-
} else {
|
|
309
|
-
style[key] = val;
|
|
310
|
-
}
|
|
311
|
+
style[key] = val;
|
|
311
312
|
}
|
|
312
313
|
continue;
|
|
313
314
|
}
|
|
@@ -322,7 +323,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
322
323
|
if (defaultClassNames) {
|
|
323
324
|
classNames = __spreadValues(__spreadValues({}, defaultClassNames), classNames);
|
|
324
325
|
}
|
|
325
|
-
if (
|
|
326
|
+
if (shouldDoClasses) {
|
|
326
327
|
const atomic = (0, import_getStylesAtomic.getStylesAtomic)(style);
|
|
327
328
|
for (const atomicStyle of atomic) {
|
|
328
329
|
const key = atomicStyle.property;
|
|
@@ -411,6 +412,7 @@ __name(normalizeStyleObject, "normalizeStyleObject");
|
|
|
411
412
|
getSubStyle,
|
|
412
413
|
insertSplitStyles,
|
|
413
414
|
normalizeStyleObject,
|
|
415
|
+
pseudoCNInverse,
|
|
414
416
|
useSplitStyles
|
|
415
417
|
});
|
|
416
418
|
//# sourceMappingURL=getSplitStyles.js.map
|