@tamagui/core 1.0.1-beta.28 → 1.0.1-beta.31
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/ThemeManager.js +18 -8
- package/dist/cjs/ThemeManager.js.map +2 -2
- package/dist/cjs/constants/platform.js +6 -6
- package/dist/cjs/constants/platform.js.map +2 -2
- package/dist/cjs/constants/rnw.js.map +2 -2
- package/dist/cjs/createComponent.js +29 -24
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createTamagui.js +10 -2
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/helpers/createMediaStyle.js +1 -0
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +9 -39
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/generateAtomicStyles.js +455 -0
- package/dist/cjs/helpers/generateAtomicStyles.js.map +7 -0
- package/dist/cjs/helpers/getSplitStyles.js +69 -66
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +31 -40
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/mergeTransform.js +42 -0
- package/dist/cjs/helpers/mergeTransform.js.map +7 -0
- package/dist/cjs/helpers/prefixStyles.js +192 -0
- package/dist/cjs/helpers/prefixStyles.js.map +7 -0
- package/dist/cjs/hooks/useIsTouchDevice.js +1 -1
- package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +8 -7
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeProvider.js +1 -1
- package/dist/cjs/views/ThemeProvider.js.map +2 -2
- package/dist/cjs/views/ThemeReset.js +1 -0
- package/dist/cjs/views/ThemeReset.js.map +2 -2
- package/dist/esm/ThemeManager.js +18 -8
- package/dist/esm/ThemeManager.js.map +2 -2
- package/dist/esm/constants/platform.js +4 -4
- package/dist/esm/constants/platform.js.map +2 -2
- package/dist/esm/constants/rnw.js.map +2 -2
- package/dist/esm/createComponent.js +30 -24
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +8 -1
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +1 -0
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +9 -40
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/generateAtomicStyles.js +427 -0
- package/dist/esm/helpers/generateAtomicStyles.js.map +7 -0
- package/dist/esm/helpers/getSplitStyles.js +71 -73
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +26 -39
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/mergeTransform.js +19 -0
- package/dist/esm/helpers/mergeTransform.js.map +7 -0
- package/dist/esm/helpers/prefixStyles.js +166 -0
- package/dist/esm/helpers/prefixStyles.js.map +7 -0
- package/dist/esm/hooks/useIsTouchDevice.js +2 -2
- package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +8 -7
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeProvider.js +1 -1
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/dist/esm/views/ThemeReset.js +1 -0
- package/dist/esm/views/ThemeReset.js.map +2 -2
- package/dist/jsx/ThemeManager.js +18 -8
- package/dist/jsx/constants/platform.js +4 -4
- package/dist/jsx/createComponent.js +30 -24
- package/dist/jsx/createTamagui.js +8 -1
- package/dist/jsx/helpers/createMediaStyle.js +1 -0
- package/dist/jsx/helpers/createPropMapper.js +9 -40
- package/dist/jsx/helpers/generateAtomicStyles.js +426 -0
- package/dist/jsx/helpers/getSplitStyles.js +71 -73
- package/dist/jsx/helpers/getStylesAtomic.js +26 -39
- package/dist/jsx/helpers/mergeTransform.js +18 -0
- package/dist/jsx/helpers/prefixStyles.js +165 -0
- package/dist/jsx/hooks/useIsTouchDevice.js +2 -2
- package/dist/jsx/hooks/useTheme.js +8 -7
- package/dist/jsx/views/ThemeProvider.js +1 -1
- package/dist/jsx/views/ThemeReset.js +1 -1
- package/package.json +8 -5
- package/reset.css +2 -1
- package/types/Tamagui.d.ts +1 -1
- package/types/Tamagui.d.ts.map +1 -1
- package/types/ThemeManager.d.ts +9 -6
- package/types/ThemeManager.d.ts.map +1 -1
- package/types/constants/platform.d.ts +2 -2
- package/types/constants/platform.d.ts.map +1 -1
- package/types/constants/rnw.d.ts +1 -1
- package/types/constants/rnw.d.ts.map +1 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createTamagui.d.ts +1 -0
- package/types/createTamagui.d.ts.map +1 -1
- package/types/helpers/createMediaStyle.d.ts.map +1 -1
- package/types/helpers/createPropMapper.d.ts +2 -2
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/generateAtomicStyles.d.ts +22 -0
- package/types/helpers/generateAtomicStyles.d.ts.map +1 -0
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts +10 -10
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/mergeTransform.d.ts +7 -0
- package/types/helpers/mergeTransform.d.ts.map +1 -0
- package/types/helpers/prefixStyles.d.ts +5 -0
- package/types/helpers/prefixStyles.d.ts.map +1 -0
- package/types/hooks/useTheme.d.ts +13 -4
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/types.d.ts +29 -29
- package/types/types.d.ts.map +1 -1
- package/types/views/Theme.d.ts +1 -9
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeProvider.d.ts +1 -0
- package/types/views/ThemeProvider.d.ts.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/createMediaStyle.ts"],
|
|
4
|
-
"sourcesContent": ["import { StyleObject } from '@tamagui/helpers'\n\nimport { mediaObjectToString } from '../hooks/useMedia'\nimport { MediaQueries } from '../types'\n\n// TODO have this be used by extractMediaStyle in tamagui static\n// not synced to static/constants for now\nexport const MEDIA_SEP = '_'\n\nexport const createMediaStyle = (\n { identifier, rules }: StyleObject,\n mediaKey: string,\n mediaQueries: MediaQueries,\n negate?: boolean,\n importance?: number\n) => {\n const mediaKeys = Object.keys(mediaQueries)\n const importance_ = Math.max(\n 0,\n importance == undefined ? mediaKeys.indexOf(mediaKey) : importance || 0\n )\n const precendencePrefix = new Array(importance_ + 1).fill(':root').join('')\n const negKey = negate ? '0' : ''\n const ogPrefix = identifier.slice(0, identifier.indexOf('-') + 1)\n const nextIdentifier = `${identifier.replace(\n ogPrefix,\n `${ogPrefix}${MEDIA_SEP}${mediaKey}${negKey}${MEDIA_SEP}`\n )}`\n const screenStr = negate ? 'not all' : 'screen'\n const mediaSelector = mediaObjectToString(mediaQueries[mediaKey])\n const mediaQuery = `${screenStr} and ${mediaSelector}`\n const styleInner = rules[0].replace(identifier, nextIdentifier)\n // combines media queries if they already exist\n let styleRule = ''\n if (styleInner.includes('@media')) {\n // combine\n styleRule = styleInner.replace('{', ` and ${mediaQuery} {`)\n } else {\n styleRule = `@media ${mediaQuery} { ${precendencePrefix} ${styleInner} }`\n }\n return {\n styleRule,\n identifier: nextIdentifier,\n }\n}\n"],
|
|
5
|
-
"mappings": ";;AAEA;AAKO,MAAM,YAAY;AAElB,MAAM,mBAAmB,wBAC9B,EAAE,YAAY,SACd,UACA,cACA,QACA,eACG;AACH,QAAM,YAAY,OAAO,KAAK,YAAY;AAC1C,QAAM,cAAc,KAAK,IACvB,GACA,cAAc,SAAY,UAAU,QAAQ,QAAQ,IAAI,cAAc,CACxE;AACA,QAAM,oBAAoB,IAAI,MAAM,cAAc,CAAC,EAAE,KAAK,OAAO,EAAE,KAAK,EAAE;AAC1E,QAAM,SAAS,SAAS,MAAM;AAC9B,QAAM,WAAW,WAAW,MAAM,GAAG,WAAW,QAAQ,GAAG,IAAI,CAAC;AAChE,QAAM,iBAAiB,GAAG,WAAW,QACnC,UACA,GAAG,WAAW,YAAY,WAAW,SAAS,WAChD;AACA,QAAM,YAAY,SAAS,YAAY;AACvC,QAAM,gBAAgB,oBAAoB,aAAa,SAAS;AAChE,QAAM,aAAa,GAAG,iBAAiB;AACvC,QAAM,aAAa,MAAM,GAAG,QAAQ,YAAY,cAAc;AAE9D,MAAI,YAAY;AAChB,MAAI,WAAW,SAAS,QAAQ,GAAG;AAEjC,gBAAY,WAAW,QAAQ,KAAK,QAAQ,cAAc;AAAA,EAC5D,OAAO;AACL,gBAAY,UAAU,gBAAgB,qBAAqB;AAAA,EAC7D;AACA,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,EACd;AACF,
|
|
4
|
+
"sourcesContent": ["import { StyleObject } from '@tamagui/helpers'\n\nimport { mediaObjectToString } from '../hooks/useMedia'\nimport { MediaQueries } from '../types'\n\n// TODO have this be used by extractMediaStyle in tamagui static\n// not synced to static/constants for now\nexport const MEDIA_SEP = '_'\n\nexport const createMediaStyle = (\n { identifier, rules }: StyleObject,\n mediaKey: string,\n mediaQueries: MediaQueries,\n negate?: boolean,\n importance?: number\n) => {\n const mediaKeys = Object.keys(mediaQueries)\n const importance_ = Math.max(\n 0,\n importance == undefined ? mediaKeys.indexOf(mediaKey) : importance || 0\n )\n const precendencePrefix = new Array(importance_ + 1).fill(':root').join('')\n const negKey = negate ? '0' : ''\n const ogPrefix = identifier.slice(0, identifier.indexOf('-') + 1)\n const nextIdentifier = `${identifier.replace(\n ogPrefix,\n `${ogPrefix}${MEDIA_SEP}${mediaKey}${negKey}${MEDIA_SEP}`\n )}`\n const screenStr = negate ? 'not all' : 'screen'\n const mediaSelector = mediaObjectToString(mediaQueries[mediaKey])\n const mediaQuery = `${screenStr} and ${mediaSelector}`\n const styleInner = rules[0].replace(identifier, nextIdentifier)\n // combines media queries if they already exist\n let styleRule = ''\n if (styleInner.includes('@media')) {\n // combine\n styleRule = styleInner.replace('{', ` and ${mediaQuery} {`)\n } else {\n styleRule = `@media ${mediaQuery} { ${precendencePrefix} ${styleInner} }`\n }\n styleRule = styleRule.replace(';}', ' !important;}')\n return {\n styleRule,\n identifier: nextIdentifier,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAEA;AAKO,MAAM,YAAY;AAElB,MAAM,mBAAmB,wBAC9B,EAAE,YAAY,SACd,UACA,cACA,QACA,eACG;AACH,QAAM,YAAY,OAAO,KAAK,YAAY;AAC1C,QAAM,cAAc,KAAK,IACvB,GACA,cAAc,SAAY,UAAU,QAAQ,QAAQ,IAAI,cAAc,CACxE;AACA,QAAM,oBAAoB,IAAI,MAAM,cAAc,CAAC,EAAE,KAAK,OAAO,EAAE,KAAK,EAAE;AAC1E,QAAM,SAAS,SAAS,MAAM;AAC9B,QAAM,WAAW,WAAW,MAAM,GAAG,WAAW,QAAQ,GAAG,IAAI,CAAC;AAChE,QAAM,iBAAiB,GAAG,WAAW,QACnC,UACA,GAAG,WAAW,YAAY,WAAW,SAAS,WAChD;AACA,QAAM,YAAY,SAAS,YAAY;AACvC,QAAM,gBAAgB,oBAAoB,aAAa,SAAS;AAChE,QAAM,aAAa,GAAG,iBAAiB;AACvC,QAAM,aAAa,MAAM,GAAG,QAAQ,YAAY,cAAc;AAE9D,MAAI,YAAY;AAChB,MAAI,WAAW,SAAS,QAAQ,GAAG;AAEjC,gBAAY,WAAW,QAAQ,KAAK,QAAQ,cAAc;AAAA,EAC5D,OAAO;AACL,gBAAY,UAAU,gBAAgB,qBAAqB;AAAA,EAC7D;AACA,cAAY,UAAU,QAAQ,MAAM,eAAe;AACnD,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,EACd;AACF,GApCgC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,6 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
import { getConfig } from "../conf";
|
|
4
4
|
import { isWeb } from "../constants/platform";
|
|
5
5
|
import { isVariable } from "../createVariable";
|
|
6
|
+
import { expandStyle, expandStyles } from "./generateAtomicStyles";
|
|
6
7
|
import { getVariantExtras } from "./getVariantExtras";
|
|
7
8
|
import { isObj } from "./isObj";
|
|
8
9
|
function getVariantFunction(variant, key, value) {
|
|
@@ -32,12 +33,14 @@ __name(getVariantFunction, "getVariantFunction");
|
|
|
32
33
|
const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
33
34
|
const variants = staticConfig.variants || {};
|
|
34
35
|
const defaultProps = staticConfig.defaultProps || {};
|
|
35
|
-
|
|
36
|
+
const mapper = /* @__PURE__ */ __name((key, value, theme, propsIn, state, avoidDefaultProps = false) => {
|
|
36
37
|
const conf = getConfig();
|
|
37
38
|
if (!conf) {
|
|
38
39
|
console.trace("no conf! err");
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
42
|
+
const props = state.fallbackProps || propsIn;
|
|
43
|
+
const returnVariablesAs = state.resolveVariablesAs || !!props.animation ? "value" : "auto";
|
|
41
44
|
const fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
|
|
42
45
|
const variant = variants && variants[key];
|
|
43
46
|
if (variant && value !== void 0) {
|
|
@@ -50,16 +53,15 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
50
53
|
if (isObj(variantValue)) {
|
|
51
54
|
variantValue = resolveTokens(variantValue, conf, theme, fontFamily, returnVariablesAs);
|
|
52
55
|
}
|
|
53
|
-
return
|
|
56
|
+
return Object.entries(expandStyles(variantValue));
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
|
-
let shouldReturn =
|
|
59
|
+
let shouldReturn = value !== void 0 && value !== null;
|
|
57
60
|
if (conf.shorthands[key]) {
|
|
58
61
|
shouldReturn = true;
|
|
59
62
|
key = conf.shorthands[key];
|
|
60
63
|
}
|
|
61
64
|
if (value) {
|
|
62
|
-
shouldReturn = true;
|
|
63
65
|
if (value[0] === "$") {
|
|
64
66
|
value = getToken(key, value, conf, theme, fontFamily, returnVariablesAs);
|
|
65
67
|
} else if (isVariable(value)) {
|
|
@@ -67,11 +69,10 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
if (shouldReturn) {
|
|
70
|
-
return
|
|
71
|
-
[key]: value
|
|
72
|
-
});
|
|
72
|
+
return expandStyle(key, value) || [[key, value]];
|
|
73
73
|
}
|
|
74
|
-
};
|
|
74
|
+
}, "mapper");
|
|
75
|
+
return mapper;
|
|
75
76
|
}, "createPropMapper");
|
|
76
77
|
const resolveTokens = /* @__PURE__ */ __name((input, conf, theme, fontFamily, resolveAs) => {
|
|
77
78
|
var _a;
|
|
@@ -194,38 +195,6 @@ const tokenCategories = {
|
|
|
194
195
|
borderRightColor: true
|
|
195
196
|
}
|
|
196
197
|
};
|
|
197
|
-
const sidesX = ["Left", "Right"];
|
|
198
|
-
const sidesY = ["Top", "Bottom"];
|
|
199
|
-
const sidesXY = [...sidesX, ...sidesY];
|
|
200
|
-
const expand = {
|
|
201
|
-
padding: sidesXY.map((x) => `padding${x}`),
|
|
202
|
-
paddingHorizontal: sidesX.map((x) => `padding${x}`),
|
|
203
|
-
paddingVertical: sidesY.map((x) => `padding${x}`),
|
|
204
|
-
margin: sidesXY.map((x) => `margin${x}`),
|
|
205
|
-
marginHorizontal: sidesX.map((x) => `margin${x}`),
|
|
206
|
-
marginVertical: sidesY.map((x) => `margin${x}`),
|
|
207
|
-
borderWidth: sidesXY.map((x) => `border${x}Width`)
|
|
208
|
-
};
|
|
209
|
-
function expansions(styleObj) {
|
|
210
|
-
var _a, _b;
|
|
211
|
-
for (const key in expand) {
|
|
212
|
-
if (key in styleObj) {
|
|
213
|
-
for (const expandKey of expand[key]) {
|
|
214
|
-
styleObj[expandKey] = styleObj[key];
|
|
215
|
-
}
|
|
216
|
-
delete styleObj[key];
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
if ("flex" in styleObj) {
|
|
220
|
-
if (typeof styleObj.flex === "number") {
|
|
221
|
-
styleObj.flexGrow = (_a = styleObj.flexGrow) != null ? _a : styleObj.flex;
|
|
222
|
-
styleObj.flexShrink = (_b = styleObj.flexShrink) != null ? _b : 1;
|
|
223
|
-
delete styleObj.flex;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return styleObj;
|
|
227
|
-
}
|
|
228
|
-
__name(expansions, "expansions");
|
|
229
198
|
export {
|
|
230
199
|
createPropMapper
|
|
231
200
|
};
|
|
@@ -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 {
|
|
5
|
-
"mappings": ";;AAAA;AACA;AACA;
|
|
4
|
+
"sourcesContent": ["import { getConfig } from '../conf'\nimport { isWeb } from '../constants/platform'\nimport { Variable, isVariable } from '../createVariable'\nimport {\n PropMapper,\n SplitStyleState,\n StaticConfig,\n TamaguiInternalConfig,\n ThemeObject,\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'\n\n// goes through specificity finding best matching variant function\nfunction getVariantFunction(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\nexport const createPropMapper = (staticConfig: Partial<StaticConfig>) => {\n const variants = staticConfig.variants || {}\n const defaultProps = staticConfig.defaultProps || {}\n\n const mapper: PropMapper = (key, value, theme, propsIn, state, avoidDefaultProps = false) => {\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 = state.resolveVariablesAs || !!props.animation ? 'value' : 'auto'\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 const variant = variants && variants[key]\n\n if (variant && value !== undefined) {\n let variantValue = getVariantFunction(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 = resolveTokens(variantValue, conf, theme, fontFamily, returnVariablesAs)\n }\n\n return Object.entries(expandStyles(variantValue))\n }\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 value = getToken(key, value, conf, theme, fontFamily, returnVariablesAs)\n } else if (isVariable(value)) {\n value = getVariableValue(value, returnVariablesAs)\n }\n }\n\n if (shouldReturn) {\n return expandStyle(key, value) || [[key, value]]\n }\n }\n\n return mapper\n}\n\nconst resolveTokens = (\n input: Object,\n conf: TamaguiInternalConfig,\n theme: any,\n fontFamily: any,\n resolveAs?: ResolveVariableTypes\n) => {\n let res = {}\n for (const rKey in input) {\n const fKey = conf.shorthands[rKey] || rKey\n const val = input[rKey]\n if (isVariable(val)) {\n res[fKey] =\n resolveAs === 'variable' ? val : !isWeb || resolveAs === 'value' ? val.val : val.variable\n } else if (typeof val === 'string') {\n const fVal = val[0] === '$' ? getToken(fKey, val, conf, theme, fontFamily, resolveAs) : val\n res[fKey] = fVal\n } else {\n if (isObj(val)) {\n // for things like shadowOffset, hoverStyle which is a sub-object\n res[fKey] = resolveTokens(val, conf, theme, fontFamily, resolveAs)\n } else {\n // nullish values cant be tokens so need no exrta parsing\n res[fKey] = input[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\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) => {\n let valOrVar: any\n let hasSet = false\n if (value in theme) {\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(valOrVar, resolveAs)\n }\n if (process.env.NODE_ENV === 'development') {\n if (value && value[0] === '$') {\n console.warn(`\u26A0\uFE0F Missing token:`, key, value, fontFamily, theme, fontsParsed)\n return null\n }\n }\n return value\n}\n\nfunction getVariableValue(valOrVar: Variable | any, resolveAs: ResolveVariableTypes = 'auto') {\n if (isVariable(valOrVar)) {\n if (resolveAs === 'variable') {\n return valOrVar\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 },\n size: {\n width: true,\n height: true,\n minWidth: true,\n minHeight: true,\n maxWidth: true,\n maxHeight: true,\n padding: true,\n paddingLeft: true,\n paddingRight: true,\n paddingTop: true,\n paddingBottom: true,\n paddingVertical: true,\n paddingHorizontal: 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;AACA;AACA;AASA;AACA;AACA;AAKA,4BAA4B,SAAc,KAAa,OAAY;AACjE,MAAI,OAAO,YAAY,YAAY;AACjC,WAAO;AAAA,EACT;AACA,aAAW,OAAO,iBAAiB;AACjC,QAAI,OAAO,gBAAgB,MAAM;AAC/B,YAAM,gBAAgB,QAAQ,MAAM;AACpC,UAAI,eAAe;AACjB,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,MAAI;AACJ,MAAI,OAAO,UAAU,UAAU;AAC7B,SAAK,QAAQ;AAAA,EACf,WAAW,OAAO,UAAU,UAAU;AACpC,SAAK,QAAQ;AAAA,EACf,WAAW,UAAU,QAAQ,UAAU,OAAO;AAC5C,SAAK,QAAQ;AAAA,EACf;AACA,OAAK,MAAM,QAAQ;AAEnB,SAAO,MAAM,QAAQ,UAAU,QAAQ;AACzC;AAvBS;AAyBF,MAAM,mBAAmB,wBAAC,iBAAwC;AACvE,QAAM,WAAW,aAAa,YAAY,CAAC;AAC3C,QAAM,eAAe,aAAa,gBAAgB,CAAC;AAEnD,QAAM,SAAqB,wBAAC,KAAK,OAAO,OAAO,SAAS,OAAO,oBAAoB,UAAU;AAC3F,UAAM,OAAO,UAAU;AAC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.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { simpleHash } from "@tamagui/helpers";
|
|
4
|
+
import hyphenateStyleName from "hyphenate-style-name";
|
|
5
|
+
import normalizeCSSColor from "normalize-css-color";
|
|
6
|
+
import { isWeb } from "../constants/platform";
|
|
7
|
+
import { prefixInlineStyles, prefixStyles } from "./prefixStyles";
|
|
8
|
+
function expandStyles(style) {
|
|
9
|
+
const res = {};
|
|
10
|
+
for (const key in style) {
|
|
11
|
+
updateReactDOMStyle(res, key, style[key]);
|
|
12
|
+
}
|
|
13
|
+
return res;
|
|
14
|
+
}
|
|
15
|
+
__name(expandStyles, "expandStyles");
|
|
16
|
+
function inline(style) {
|
|
17
|
+
return prefixInlineStyles(expandStyles(style));
|
|
18
|
+
}
|
|
19
|
+
__name(inline, "inline");
|
|
20
|
+
const STYLE_SHORT_FORM_EXPANSIONS = {
|
|
21
|
+
borderColor: ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"],
|
|
22
|
+
borderRadius: [
|
|
23
|
+
"borderTopLeftRadius",
|
|
24
|
+
"borderTopRightRadius",
|
|
25
|
+
"borderBottomRightRadius",
|
|
26
|
+
"borderBottomLeftRadius"
|
|
27
|
+
],
|
|
28
|
+
borderStyle: ["borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle"],
|
|
29
|
+
borderWidth: ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"],
|
|
30
|
+
margin: ["marginTop", "marginRight", "marginBottom", "marginLeft"],
|
|
31
|
+
marginHorizontal: ["marginRight", "marginLeft"],
|
|
32
|
+
marginVertical: ["marginTop", "marginBottom"],
|
|
33
|
+
overflow: ["overflowX", "overflowY"],
|
|
34
|
+
overscrollBehavior: ["overscrollBehaviorX", "overscrollBehaviorY"],
|
|
35
|
+
padding: ["paddingTop", "paddingRight", "paddingBottom", "paddingLeft"],
|
|
36
|
+
paddingHorizontal: ["paddingRight", "paddingLeft"],
|
|
37
|
+
paddingVertical: ["paddingTop", "paddingBottom"]
|
|
38
|
+
};
|
|
39
|
+
const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
|
|
40
|
+
const res = expandStyles(style);
|
|
41
|
+
if (style.shadowColor != null || style.shadowOffset != null || style.shadowOpacity != null || style.shadowRadius != null) {
|
|
42
|
+
boxShadowReducer(res, style);
|
|
43
|
+
}
|
|
44
|
+
if (style.textShadowColor != null || style.textShadowOffset != null || style.textShadowRadius != null) {
|
|
45
|
+
textShadowReducer(res, style);
|
|
46
|
+
}
|
|
47
|
+
const out = {};
|
|
48
|
+
for (const key in res) {
|
|
49
|
+
const value = res[key];
|
|
50
|
+
if (value != null) {
|
|
51
|
+
const valueString = stringifyValueWithProperty(value, key);
|
|
52
|
+
const cachedResult = cache.get(key, valueString);
|
|
53
|
+
if (cachedResult != null) {
|
|
54
|
+
const { identifier } = cachedResult;
|
|
55
|
+
out[identifier] = cachedResult;
|
|
56
|
+
} else {
|
|
57
|
+
const identifier = createIdentifier("r", key, value);
|
|
58
|
+
const rules = createAtomicRules(identifier, key, value);
|
|
59
|
+
const cachedResult2 = cache.set(key, valueString, {
|
|
60
|
+
property: key,
|
|
61
|
+
value: stringifyValueWithProperty(value, key),
|
|
62
|
+
identifier,
|
|
63
|
+
rules
|
|
64
|
+
});
|
|
65
|
+
out[identifier] = cachedResult2;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}, "generateAtomicStyles");
|
|
71
|
+
function updateReactDOMStyle(style, key, value) {
|
|
72
|
+
value = normalizeValueWithProperty(value, key);
|
|
73
|
+
const out = expandStyle(key, value);
|
|
74
|
+
if (out) {
|
|
75
|
+
Object.assign(style, Object.fromEntries(out));
|
|
76
|
+
} else {
|
|
77
|
+
style[key] = value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
__name(updateReactDOMStyle, "updateReactDOMStyle");
|
|
81
|
+
function expandStyle(key, value) {
|
|
82
|
+
if (key === "flex") {
|
|
83
|
+
if (value <= -1) {
|
|
84
|
+
return [
|
|
85
|
+
["flexGrow", 0],
|
|
86
|
+
["flexShrink", 1],
|
|
87
|
+
["flexBasis", "auto"]
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
if (value >= 0) {
|
|
91
|
+
return [
|
|
92
|
+
["flexGrow", value],
|
|
93
|
+
["flexShrink", 1]
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (isWeb) {
|
|
99
|
+
switch (key) {
|
|
100
|
+
case "elevation":
|
|
101
|
+
case "overlayColor":
|
|
102
|
+
case "resizeMode":
|
|
103
|
+
case "tintColor": {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "aspectRatio": {
|
|
107
|
+
return [key, value.toString()];
|
|
108
|
+
}
|
|
109
|
+
case "backgroundClip": {
|
|
110
|
+
if (value === "text") {
|
|
111
|
+
return [
|
|
112
|
+
["backgroundClip", value],
|
|
113
|
+
["WebkitBackgroundClip", value]
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case "textAlignVertical": {
|
|
119
|
+
return [["verticalAlign", value === "center" ? "middle" : value]];
|
|
120
|
+
}
|
|
121
|
+
case "textDecorationLine": {
|
|
122
|
+
return ["textDecorationLine", value];
|
|
123
|
+
}
|
|
124
|
+
case "transform": {
|
|
125
|
+
if (Array.isArray(value)) {
|
|
126
|
+
return [[key, value.map(mapTransform).join(" ")]];
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case "writingDirection": {
|
|
131
|
+
return [["direction", value]];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const longKey = STYLE_SHORT_FORM_EXPANSIONS[key];
|
|
136
|
+
if (longKey) {
|
|
137
|
+
return longKey.map((key2) => {
|
|
138
|
+
return [key2, value];
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
if (isWeb && Array.isArray(value)) {
|
|
142
|
+
return [[key, value.join(",")]];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
__name(expandStyle, "expandStyle");
|
|
147
|
+
function createAtomicRules(identifier, property, value) {
|
|
148
|
+
const rules = [];
|
|
149
|
+
const selector = `.${identifier}`;
|
|
150
|
+
switch (property) {
|
|
151
|
+
case "animationKeyframes": {
|
|
152
|
+
const { animationNames, rules: keyframesRules } = processKeyframesValue(value);
|
|
153
|
+
const block = createDeclarationBlock({ animationName: animationNames.join(",") });
|
|
154
|
+
rules.push(`${selector}${block}`, ...keyframesRules);
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
case "placeholderTextColor": {
|
|
158
|
+
const block = createDeclarationBlock({ color: value, opacity: 1 });
|
|
159
|
+
rules.push(`${selector}::-webkit-input-placeholder${block}`, `${selector}::-moz-placeholder${block}`, `${selector}:-ms-input-placeholder${block}`, `${selector}::placeholder${block}`);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case "pointerEvents": {
|
|
163
|
+
let finalValue = value;
|
|
164
|
+
if (value === "auto" || value === "box-only") {
|
|
165
|
+
finalValue = "auto!important";
|
|
166
|
+
if (value === "box-only") {
|
|
167
|
+
const block2 = createDeclarationBlock({ pointerEvents: "none" });
|
|
168
|
+
rules.push(`${selector}>*${block2}`);
|
|
169
|
+
}
|
|
170
|
+
} else if (value === "none" || value === "box-none") {
|
|
171
|
+
finalValue = "none!important";
|
|
172
|
+
if (value === "box-none") {
|
|
173
|
+
const block2 = createDeclarationBlock({ pointerEvents: "auto" });
|
|
174
|
+
rules.push(`${selector}>*${block2}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const block = createDeclarationBlock({ pointerEvents: finalValue });
|
|
178
|
+
rules.push(`${selector}${block}`);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case "scrollbarWidth": {
|
|
182
|
+
if (value === "none") {
|
|
183
|
+
rules.push(`${selector}::-webkit-scrollbar{display:none}`);
|
|
184
|
+
}
|
|
185
|
+
const block = createDeclarationBlock({ scrollbarWidth: value });
|
|
186
|
+
rules.push(`${selector}${block}`);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
default: {
|
|
190
|
+
const block = createDeclarationBlock({ [property]: value });
|
|
191
|
+
rules.push(`${selector}${block}`);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return rules;
|
|
196
|
+
}
|
|
197
|
+
__name(createAtomicRules, "createAtomicRules");
|
|
198
|
+
function processKeyframesValue(keyframesValue) {
|
|
199
|
+
if (typeof keyframesValue === "number") {
|
|
200
|
+
throw new Error(`Invalid CSS keyframes type: ${typeof keyframesValue}`);
|
|
201
|
+
}
|
|
202
|
+
const animationNames = [];
|
|
203
|
+
const rules = [];
|
|
204
|
+
const value = Array.isArray(keyframesValue) ? keyframesValue : [keyframesValue];
|
|
205
|
+
for (const keyframes of value) {
|
|
206
|
+
if (typeof keyframes === "string") {
|
|
207
|
+
animationNames.push(keyframes);
|
|
208
|
+
} else {
|
|
209
|
+
const { identifier, rules: keyframesRules } = createKeyframes(keyframes);
|
|
210
|
+
animationNames.push(identifier);
|
|
211
|
+
rules.push(...keyframesRules);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { animationNames, rules };
|
|
215
|
+
}
|
|
216
|
+
__name(processKeyframesValue, "processKeyframesValue");
|
|
217
|
+
function createKeyframes(keyframes) {
|
|
218
|
+
const prefixes2 = ["-webkit-", ""];
|
|
219
|
+
const identifier = createIdentifier("r", "animation", keyframes);
|
|
220
|
+
const steps = "{" + Object.keys(keyframes).map((stepName) => {
|
|
221
|
+
const rule = keyframes[stepName];
|
|
222
|
+
const block = createDeclarationBlock(rule);
|
|
223
|
+
return `${stepName}${block}`;
|
|
224
|
+
}).join("") + "}";
|
|
225
|
+
const rules = prefixes2.map((prefix) => {
|
|
226
|
+
return `@${prefix}keyframes ${identifier}${steps}`;
|
|
227
|
+
});
|
|
228
|
+
return { identifier, rules };
|
|
229
|
+
}
|
|
230
|
+
__name(createKeyframes, "createKeyframes");
|
|
231
|
+
function createDeclarationBlock(style) {
|
|
232
|
+
const domStyle = prefixStyles(expandStyles(style));
|
|
233
|
+
const declarationsString = Object.keys(domStyle).map((property) => {
|
|
234
|
+
const value = domStyle[property];
|
|
235
|
+
const prop = hyphenateStyleName(property);
|
|
236
|
+
if (Array.isArray(value)) {
|
|
237
|
+
return value.map((v) => `${prop}:${v}`).join(";");
|
|
238
|
+
} else {
|
|
239
|
+
return `${prop}:${value}`;
|
|
240
|
+
}
|
|
241
|
+
}).sort().join(";");
|
|
242
|
+
return `{${declarationsString};}`;
|
|
243
|
+
}
|
|
244
|
+
__name(createDeclarationBlock, "createDeclarationBlock");
|
|
245
|
+
function createIdentifier(prefix, name, value) {
|
|
246
|
+
const hashedString = simpleHash(name + stringifyValueWithProperty(value, name));
|
|
247
|
+
return `${prefix}-${hashedString}`;
|
|
248
|
+
}
|
|
249
|
+
__name(createIdentifier, "createIdentifier");
|
|
250
|
+
const cache = {
|
|
251
|
+
get(property, value) {
|
|
252
|
+
if (cache[property] != null && cache[property].hasOwnProperty(value) && cache[property][value] != null) {
|
|
253
|
+
return cache[property][value];
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
set(property, value, object) {
|
|
257
|
+
if (cache[property] == null) {
|
|
258
|
+
cache[property] = {};
|
|
259
|
+
}
|
|
260
|
+
return cache[property][value] = object;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
function stringifyValueWithProperty(value, property) {
|
|
264
|
+
const normalizedValue = normalizeValueWithProperty(value, property);
|
|
265
|
+
return typeof normalizedValue !== "string" ? JSON.stringify(normalizedValue || "") : normalizedValue;
|
|
266
|
+
}
|
|
267
|
+
__name(stringifyValueWithProperty, "stringifyValueWithProperty");
|
|
268
|
+
const mapTransform = /* @__PURE__ */ __name((transform) => {
|
|
269
|
+
const type = Object.keys(transform)[0];
|
|
270
|
+
const value = transform[type];
|
|
271
|
+
if (type === "matrix" || type === "matrix3d") {
|
|
272
|
+
return `${type}(${value.join(",")})`;
|
|
273
|
+
} else {
|
|
274
|
+
const normalizedValue = normalizeValueWithProperty(value, type);
|
|
275
|
+
return `${type}(${normalizedValue})`;
|
|
276
|
+
}
|
|
277
|
+
}, "mapTransform");
|
|
278
|
+
const colorProps = {
|
|
279
|
+
backgroundColor: true,
|
|
280
|
+
borderColor: true,
|
|
281
|
+
borderTopColor: true,
|
|
282
|
+
borderRightColor: true,
|
|
283
|
+
borderBottomColor: true,
|
|
284
|
+
borderLeftColor: true,
|
|
285
|
+
color: true,
|
|
286
|
+
shadowColor: true,
|
|
287
|
+
textDecorationColor: true,
|
|
288
|
+
textShadowColor: true
|
|
289
|
+
};
|
|
290
|
+
function normalizeValueWithProperty(value, property) {
|
|
291
|
+
if (isWeb) {
|
|
292
|
+
if ((property == null || !unitlessNumbers[property]) && typeof value === "number") {
|
|
293
|
+
return `${value}px`;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (property && colorProps[property]) {
|
|
297
|
+
return normalizeColor(value);
|
|
298
|
+
}
|
|
299
|
+
return value;
|
|
300
|
+
}
|
|
301
|
+
__name(normalizeValueWithProperty, "normalizeValueWithProperty");
|
|
302
|
+
const normalizeColor = /* @__PURE__ */ __name((color, opacity = 1) => {
|
|
303
|
+
if (color == null || color == void 0) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (isWeb) {
|
|
307
|
+
if (typeof color === "string" && isWebColor(color)) {
|
|
308
|
+
return color;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
const colorInt = processColor(color);
|
|
312
|
+
if (colorInt != null) {
|
|
313
|
+
const r = colorInt >> 16 & 255;
|
|
314
|
+
const g = colorInt >> 8 & 255;
|
|
315
|
+
const b = colorInt & 255;
|
|
316
|
+
const a = (colorInt >> 24 & 255) / 255;
|
|
317
|
+
const alpha = (a * opacity).toFixed(2);
|
|
318
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
319
|
+
}
|
|
320
|
+
}, "normalizeColor");
|
|
321
|
+
const isWebColor = /* @__PURE__ */ __name((color) => color === "currentcolor" || color === "currentColor" || color === "inherit" || color.indexOf("var(") === 0, "isWebColor");
|
|
322
|
+
const processColor = /* @__PURE__ */ __name((color) => {
|
|
323
|
+
if (color === void 0 || color === null) {
|
|
324
|
+
return color;
|
|
325
|
+
}
|
|
326
|
+
let intColor = normalizeCSSColor(color);
|
|
327
|
+
if (intColor === void 0 || intColor === null) {
|
|
328
|
+
return void 0;
|
|
329
|
+
}
|
|
330
|
+
return (+intColor << 24 | +intColor >>> 8) >>> 0;
|
|
331
|
+
}, "processColor");
|
|
332
|
+
const unitlessNumbers = {
|
|
333
|
+
animationIterationCount: true,
|
|
334
|
+
aspectRatio: true,
|
|
335
|
+
borderImageOutset: true,
|
|
336
|
+
borderImageSlice: true,
|
|
337
|
+
borderImageWidth: true,
|
|
338
|
+
boxFlex: true,
|
|
339
|
+
boxFleGroup: true,
|
|
340
|
+
boxOrdinalGroup: true,
|
|
341
|
+
columnCount: true,
|
|
342
|
+
flex: true,
|
|
343
|
+
flexGrow: true,
|
|
344
|
+
flexOrder: true,
|
|
345
|
+
flexPositive: true,
|
|
346
|
+
flexShrink: true,
|
|
347
|
+
flexNegative: true,
|
|
348
|
+
fontWeight: true,
|
|
349
|
+
gridRow: true,
|
|
350
|
+
gridRowEnd: true,
|
|
351
|
+
gridRowGap: true,
|
|
352
|
+
gridRowStart: true,
|
|
353
|
+
gridColumn: true,
|
|
354
|
+
gridColumnEnd: true,
|
|
355
|
+
gridColumnGap: true,
|
|
356
|
+
gridColumnStart: true,
|
|
357
|
+
lineClamp: true,
|
|
358
|
+
opacity: true,
|
|
359
|
+
order: true,
|
|
360
|
+
orphans: true,
|
|
361
|
+
tabSize: true,
|
|
362
|
+
widows: true,
|
|
363
|
+
zIndex: true,
|
|
364
|
+
zoom: true,
|
|
365
|
+
fillOpacity: true,
|
|
366
|
+
floodOpacity: true,
|
|
367
|
+
stopOpacity: true,
|
|
368
|
+
strokeDasharray: true,
|
|
369
|
+
strokeDashoffset: true,
|
|
370
|
+
strokeMiterlimit: true,
|
|
371
|
+
strokeOpacity: true,
|
|
372
|
+
strokeWidth: true,
|
|
373
|
+
scale: true,
|
|
374
|
+
scaleX: true,
|
|
375
|
+
scaleY: true,
|
|
376
|
+
scaleZ: true,
|
|
377
|
+
shadowOpacity: true
|
|
378
|
+
};
|
|
379
|
+
const prefixes = ["ms", "Moz", "O", "Webkit"];
|
|
380
|
+
const prefixKey = /* @__PURE__ */ __name((prefix, key) => {
|
|
381
|
+
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
|
382
|
+
}, "prefixKey");
|
|
383
|
+
Object.keys(unitlessNumbers).forEach((prop) => {
|
|
384
|
+
prefixes.forEach((prefix) => {
|
|
385
|
+
unitlessNumbers[prefixKey(prefix, prop)] = unitlessNumbers[prop];
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
const resolveShadowValue = /* @__PURE__ */ __name((style) => {
|
|
389
|
+
const { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style;
|
|
390
|
+
const { height, width } = shadowOffset || defaultOffset;
|
|
391
|
+
const offsetX = normalizeValueWithProperty(width);
|
|
392
|
+
const offsetY = normalizeValueWithProperty(height);
|
|
393
|
+
const blurRadius = normalizeValueWithProperty(shadowRadius || 0);
|
|
394
|
+
const color = normalizeColor(shadowColor || "black", shadowOpacity);
|
|
395
|
+
if (color != null && offsetX != null && offsetY != null && blurRadius != null) {
|
|
396
|
+
return `${offsetX} ${offsetY} ${blurRadius} ${color}`;
|
|
397
|
+
}
|
|
398
|
+
}, "resolveShadowValue");
|
|
399
|
+
function boxShadowReducer(resolvedStyle, style) {
|
|
400
|
+
const { boxShadow } = style;
|
|
401
|
+
const shadow = resolveShadowValue(style);
|
|
402
|
+
if (shadow != null) {
|
|
403
|
+
resolvedStyle.boxShadow = boxShadow ? `${boxShadow}, ${shadow}` : shadow;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
__name(boxShadowReducer, "boxShadowReducer");
|
|
407
|
+
const defaultOffset = { height: 0, width: 0 };
|
|
408
|
+
function textShadowReducer(resolvedStyle, style) {
|
|
409
|
+
const { textShadowColor, textShadowOffset, textShadowRadius } = style;
|
|
410
|
+
const { height, width } = textShadowOffset || defaultOffset;
|
|
411
|
+
const radius = textShadowRadius || 0;
|
|
412
|
+
const offsetX = normalizeValueWithProperty(width);
|
|
413
|
+
const offsetY = normalizeValueWithProperty(height);
|
|
414
|
+
const blurRadius = normalizeValueWithProperty(radius);
|
|
415
|
+
const color = normalizeValueWithProperty(textShadowColor, "textShadowColor");
|
|
416
|
+
if (color && (height !== 0 || width !== 0 || radius !== 0) && offsetX != null && offsetY != null && blurRadius != null) {
|
|
417
|
+
resolvedStyle.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
__name(textShadowReducer, "textShadowReducer");
|
|
421
|
+
export {
|
|
422
|
+
expandStyle,
|
|
423
|
+
expandStyles,
|
|
424
|
+
generateAtomicStyles,
|
|
425
|
+
inline
|
|
426
|
+
};
|
|
427
|
+
//# sourceMappingURL=generateAtomicStyles.js.map
|