@tamagui/helpers 1.0.0-alpha.0
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/allRules.js +9 -0
- package/dist/allRules.js.map +7 -0
- package/dist/concatClassName.js +70 -0
- package/dist/concatClassName.js.map +7 -0
- package/dist/getNiceKey.js +16 -0
- package/dist/getNiceKey.js.map +7 -0
- package/dist/getStylesAtomic.js +96 -0
- package/dist/getStylesAtomic.js.map +7 -0
- package/dist/getStylesAtomic.native.js +11 -0
- package/dist/getStylesAtomic.native.js.map +7 -0
- package/dist/index.cjs +241 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/dist/simpleHash.js +15 -0
- package/dist/simpleHash.js.map +7 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +7 -0
- package/dist/uniqueStyleKeys.js +33 -0
- package/dist/uniqueStyleKeys.js.map +7 -0
- package/dist/validStyleProps.js +150 -0
- package/dist/validStyleProps.js.map +7 -0
- package/package.json +26 -0
- package/src/AllRules.ts +5 -0
- package/src/concatClassName.ts +77 -0
- package/src/index.ts +4 -0
- package/src/simpleHash.ts +9 -0
- package/src/types.ts +7 -0
- package/src/validStyleProps.ts +152 -0
package/dist/allRules.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const AllRules = new Set();
|
|
4
|
+
const getStyleRules = /* @__PURE__ */ __name(() => AllRules, "getStyleRules");
|
|
5
|
+
export {
|
|
6
|
+
AllRules,
|
|
7
|
+
getStyleRules
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=AllRules.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
function concatClassName(...classNamesOrPropObjects) {
|
|
4
|
+
const usedPrefixes = [];
|
|
5
|
+
let final = "";
|
|
6
|
+
const len = classNamesOrPropObjects.length;
|
|
7
|
+
let propObjects = null;
|
|
8
|
+
for (let x = len; x >= 0; x--) {
|
|
9
|
+
const cns = classNamesOrPropObjects[x];
|
|
10
|
+
if (!cns)
|
|
11
|
+
continue;
|
|
12
|
+
if (!Array.isArray(cns) && typeof cns !== "string") {
|
|
13
|
+
propObjects = propObjects || [];
|
|
14
|
+
propObjects.push(cns);
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const names = Array.isArray(cns) ? cns : cns.split(" ");
|
|
18
|
+
for (let i = names.length - 1; i >= 0; i--) {
|
|
19
|
+
const name = names[i];
|
|
20
|
+
if (!name || name === " ")
|
|
21
|
+
continue;
|
|
22
|
+
if (name[0] !== "_") {
|
|
23
|
+
final = name + " " + final;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const splitIndex = name.indexOf("-");
|
|
27
|
+
if (splitIndex < 1) {
|
|
28
|
+
final = name + " " + final;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const nextChar = name[splitIndex + 1];
|
|
32
|
+
const isMediaQuery = nextChar === "_";
|
|
33
|
+
const isPsuedoQuery = nextChar === "-";
|
|
34
|
+
const styleKey = name.slice(1, splitIndex);
|
|
35
|
+
const mediaKey = isMediaQuery || isPsuedoQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null;
|
|
36
|
+
const uid = mediaKey ? styleKey + mediaKey : styleKey;
|
|
37
|
+
if (!isMediaQuery && !isPsuedoQuery) {
|
|
38
|
+
if (usedPrefixes.indexOf(uid) > -1) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
usedPrefixes.push(uid);
|
|
42
|
+
}
|
|
43
|
+
const propName = styleKey;
|
|
44
|
+
if (propName && propObjects) {
|
|
45
|
+
if (propObjects.some((po) => {
|
|
46
|
+
if (mediaKey) {
|
|
47
|
+
const propKey = pseudoInvert[mediaKey];
|
|
48
|
+
return po && po[propKey] && propName in po[propKey] && po[propKey] !== null;
|
|
49
|
+
}
|
|
50
|
+
const res = po && propName in po && po[propName] !== null;
|
|
51
|
+
return res;
|
|
52
|
+
})) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
final = name + " " + final;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return final;
|
|
60
|
+
}
|
|
61
|
+
__name(concatClassName, "concatClassName");
|
|
62
|
+
const pseudoInvert = {
|
|
63
|
+
hover: "hoverStyle",
|
|
64
|
+
focus: "focusStyle",
|
|
65
|
+
press: "pressStyle"
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
concatClassName
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=concatClassName.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/concatClassName.ts"],
|
|
4
|
+
"sourcesContent": ["export function concatClassName(...classNamesOrPropObjects: string[]) {\n const usedPrefixes: string[] = []\n let final = ''\n\n const len = classNamesOrPropObjects.length\n let propObjects: any = null\n for (let x = len; x >= 0; x--) {\n const cns = classNamesOrPropObjects[x]\n if (!cns) continue\n if (!Array.isArray(cns) && typeof cns !== 'string') {\n // is prop object\n propObjects = propObjects || []\n propObjects.push(cns)\n continue\n }\n const names = Array.isArray(cns) ? cns : cns.split(' ')\n for (let i = names.length - 1; i >= 0; i--) {\n const name = names[i]\n if (!name || name === ' ') continue\n if (name[0] !== '_') {\n // not snack style (todo slightly stronger heuristic)\n final = name + ' ' + final\n continue\n }\n const splitIndex = name.indexOf('-')\n if (splitIndex < 1) {\n final = name + ' ' + final\n continue\n }\n const nextChar = name[splitIndex + 1]\n // synced to static-ui constants\n // MEDIA_SEP\n const isMediaQuery = nextChar === '_'\n // PSEUDO_SEP\n const isPsuedoQuery = nextChar === '-'\n const styleKey = name.slice(1, splitIndex)\n const mediaKey =\n isMediaQuery || isPsuedoQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null\n const uid = mediaKey ? styleKey + mediaKey : styleKey\n if (!isMediaQuery && !isPsuedoQuery) {\n if (usedPrefixes.indexOf(uid) > -1) {\n continue\n }\n usedPrefixes.push(uid)\n }\n\n // overrides for full safety\n const propName = styleKey\n // shouldLog && console.log('propName', propName)\n if (propName && propObjects) {\n if (\n propObjects.some((po) => {\n if (mediaKey) {\n const propKey = pseudoInvert[mediaKey]\n return po && po[propKey] && propName in po[propKey] && po[propKey] !== null\n }\n const res = po && propName in po && po[propName] !== null\n return res\n })\n ) {\n // shouldLog && console.log('SKIP PROP')\n continue\n }\n }\n\n final = name + ' ' + final\n }\n }\n\n return final\n}\n\nconst pseudoInvert = {\n hover: 'hoverStyle',\n focus: 'focusStyle',\n press: 'pressStyle',\n}\n"],
|
|
5
|
+
"mappings": ";;AAAO,4BAA4B,yBAAmC;AACpE,QAAM,eAAyB;AAC/B,MAAI,QAAQ;AAEZ,QAAM,MAAM,wBAAwB;AACpC,MAAI,cAAmB;AACvB,WAAS,IAAI,KAAK,KAAK,GAAG,KAAK;AAC7B,UAAM,MAAM,wBAAwB;AACpC,QAAI,CAAC;AAAK;AACV,QAAI,CAAC,MAAM,QAAQ,QAAQ,OAAO,QAAQ,UAAU;AAElD,oBAAc,eAAe;AAC7B,kBAAY,KAAK;AACjB;AAAA;AAEF,UAAM,QAAQ,MAAM,QAAQ,OAAO,MAAM,IAAI,MAAM;AACnD,aAAS,IAAI,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK;AAC1C,YAAM,OAAO,MAAM;AACnB,UAAI,CAAC,QAAQ,SAAS;AAAK;AAC3B,UAAI,KAAK,OAAO,KAAK;AAEnB,gBAAQ,OAAO,MAAM;AACrB;AAAA;AAEF,YAAM,aAAa,KAAK,QAAQ;AAChC,UAAI,aAAa,GAAG;AAClB,gBAAQ,OAAO,MAAM;AACrB;AAAA;AAEF,YAAM,WAAW,KAAK,aAAa;AAGnC,YAAM,eAAe,aAAa;AAElC,YAAM,gBAAgB,aAAa;AACnC,YAAM,WAAW,KAAK,MAAM,GAAG;AAC/B,YAAM,WACJ,gBAAgB,gBAAgB,KAAK,MAAM,aAAa,GAAG,aAAa,KAAK;AAC/E,YAAM,MAAM,WAAW,WAAW,WAAW;AAC7C,UAAI,CAAC,gBAAgB,CAAC,eAAe;AACnC,YAAI,aAAa,QAAQ,OAAO,IAAI;AAClC;AAAA;AAEF,qBAAa,KAAK;AAAA;AAIpB,YAAM,WAAW;AAEjB,UAAI,YAAY,aAAa;AAC3B,YACE,YAAY,KAAK,CAAC,OAAO;AACvB,cAAI,UAAU;AACZ,kBAAM,UAAU,aAAa;AAC7B,mBAAO,MAAM,GAAG,YAAY,YAAY,GAAG,YAAY,GAAG,aAAa;AAAA;AAEzE,gBAAM,MAAM,MAAM,YAAY,MAAM,GAAG,cAAc;AACrD,iBAAO;AAAA,YAET;AAEA;AAAA;AAAA;AAIJ,cAAQ,OAAO,MAAM;AAAA;AAAA;AAIzB,SAAO;AAAA;AArEO;AAwEhB,MAAM,eAAe;AAAA,EACnB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
function getNiceKey(name, len = 2) {
|
|
4
|
+
let key = "";
|
|
5
|
+
for (const [index, char] of name.split("").entries()) {
|
|
6
|
+
if (index === 0 || char.toUpperCase() === char) {
|
|
7
|
+
key += name.slice(index, index + len);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return key;
|
|
11
|
+
}
|
|
12
|
+
__name(getNiceKey, "getNiceKey");
|
|
13
|
+
export {
|
|
14
|
+
getNiceKey
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=getNiceKey.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/getNiceKey.ts"],
|
|
4
|
+
"sourcesContent": ["export function getNiceKey(name: string, len = 2) {\n let key = ''\n for (const [index, char] of name.split('').entries()) {\n if (index === 0 || char.toUpperCase() === char) {\n key += name.slice(index, index + len)\n }\n }\n return key\n}\n"],
|
|
5
|
+
"mappings": ";;AAAO,oBAAoB,MAAc,MAAM,GAAG;AAChD,MAAI,MAAM;AACV,aAAW,CAAC,OAAO,SAAS,KAAK,MAAM,IAAI,WAAW;AACpD,QAAI,UAAU,KAAK,KAAK,kBAAkB,MAAM;AAC9C,aAAO,KAAK,MAAM,OAAO,QAAQ;AAAA;AAAA;AAGrC,SAAO;AAAA;AAPO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { atomic } from "react-native-web/dist/cjs/exports/StyleSheet/compile";
|
|
4
|
+
import createCompileableStyle from "react-native-web/dist/cjs/exports/StyleSheet/createCompileableStyle";
|
|
5
|
+
import createReactDOMStyle from "react-native-web/dist/cjs/exports/StyleSheet/createReactDOMStyle";
|
|
6
|
+
import i18Style from "react-native-web/dist/cjs/exports/StyleSheet/i18nStyle";
|
|
7
|
+
import { AllRules } from "./AllRules";
|
|
8
|
+
const pseudos = {
|
|
9
|
+
focusStyle: {
|
|
10
|
+
name: "focus",
|
|
11
|
+
priority: 3
|
|
12
|
+
},
|
|
13
|
+
pressStyle: {
|
|
14
|
+
name: "active",
|
|
15
|
+
priority: 2
|
|
16
|
+
},
|
|
17
|
+
hoverStyle: {
|
|
18
|
+
name: "hover",
|
|
19
|
+
priority: 1
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const borderDefaults = {
|
|
23
|
+
borderWidth: "borderStyle",
|
|
24
|
+
borderBottomWidth: "borderBottomStyle",
|
|
25
|
+
borderTopWidth: "borderTopStyle",
|
|
26
|
+
borderLeftWidth: "borderLeftStyle",
|
|
27
|
+
borderRightWidth: "borderRightStyle"
|
|
28
|
+
};
|
|
29
|
+
function getStylesAtomic(style, avoidCollection = false) {
|
|
30
|
+
const styles = {
|
|
31
|
+
base: {}
|
|
32
|
+
};
|
|
33
|
+
for (const key in style) {
|
|
34
|
+
if (!!pseudos[key]) {
|
|
35
|
+
styles[key] = style[key];
|
|
36
|
+
} else {
|
|
37
|
+
styles.base[key] = style[key];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return Object.keys(styles).map((key) => {
|
|
41
|
+
return getAtomicStyle(styles[key], pseudos[key], avoidCollection);
|
|
42
|
+
}).flat();
|
|
43
|
+
}
|
|
44
|
+
__name(getStylesAtomic, "getStylesAtomic");
|
|
45
|
+
const importantRegex = /\!important*/g;
|
|
46
|
+
function getAtomicStyle(style, pseudo, avoidCollection) {
|
|
47
|
+
if (style == null || typeof style !== "object") {
|
|
48
|
+
throw new Error(`Wrong style type: "${typeof style}": ${style}`);
|
|
49
|
+
}
|
|
50
|
+
for (const key in borderDefaults) {
|
|
51
|
+
if (key in style) {
|
|
52
|
+
style[borderDefaults[key]] = style[borderDefaults[key]] ?? "solid";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const all = {
|
|
56
|
+
...atomic(createCompileableStyle(createReactDOMStyle(i18Style(style))))
|
|
57
|
+
};
|
|
58
|
+
return Object.keys(all).map((key) => {
|
|
59
|
+
const val = all[key];
|
|
60
|
+
const hash = val.identifier.slice(`${val.identifier}`.lastIndexOf("-") + 1);
|
|
61
|
+
const psuedoPrefix = pseudo ? `-${pseudo.name}-` : "";
|
|
62
|
+
const identifier = `_${val.property}-${psuedoPrefix}${hash}`;
|
|
63
|
+
const className = `.${identifier}`;
|
|
64
|
+
const rules = val.rules.map((rule) => {
|
|
65
|
+
if (pseudo) {
|
|
66
|
+
const psuedoPrefixSelect = [...Array(pseudo.priority)].map(() => ":root").join("") + " ";
|
|
67
|
+
let res = rule.replace(`.${val.identifier}`, `${psuedoPrefixSelect} ${className}`).replace("{", `:${pseudo.name}{`);
|
|
68
|
+
if (pseudo.name === "hover") {
|
|
69
|
+
res = `@media not all and (hover: none) { ${res} }`;
|
|
70
|
+
}
|
|
71
|
+
return res;
|
|
72
|
+
}
|
|
73
|
+
return rule.replace(`.${val.identifier}`, className).replace(importantRegex, "");
|
|
74
|
+
});
|
|
75
|
+
if (!avoidCollection) {
|
|
76
|
+
if (rules.length > 1) {
|
|
77
|
+
console.warn("have never seen more than one, verifying");
|
|
78
|
+
}
|
|
79
|
+
AllRules.add(rules[0]);
|
|
80
|
+
}
|
|
81
|
+
const result = {
|
|
82
|
+
property: val.property,
|
|
83
|
+
value: val.value,
|
|
84
|
+
identifier,
|
|
85
|
+
className,
|
|
86
|
+
rules
|
|
87
|
+
};
|
|
88
|
+
return result;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
__name(getAtomicStyle, "getAtomicStyle");
|
|
92
|
+
export {
|
|
93
|
+
getStylesAtomic,
|
|
94
|
+
pseudos
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=getStylesAtomic.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/getStylesAtomic.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ViewStyle } from 'react-native'\nimport { atomic } from 'react-native-web/dist/cjs/exports/StyleSheet/compile'\nimport createCompileableStyle from 'react-native-web/dist/cjs/exports/StyleSheet/createCompileableStyle'\nimport createReactDOMStyle from 'react-native-web/dist/cjs/exports/StyleSheet/createReactDOMStyle'\nimport i18Style from 'react-native-web/dist/cjs/exports/StyleSheet/i18nStyle'\n\nimport { AllRules } from './AllRules'\nimport { StyleObject } from './types'\n\nexport const pseudos = {\n focusStyle: {\n name: 'focus',\n priority: 3,\n },\n pressStyle: {\n name: 'active',\n priority: 2,\n },\n hoverStyle: {\n name: 'hover',\n priority: 1,\n },\n}\n\nconst borderDefaults = {\n borderWidth: 'borderStyle',\n borderBottomWidth: 'borderBottomStyle',\n borderTopWidth: 'borderTopStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n}\n\nexport function getStylesAtomic(style: any, avoidCollection = false) {\n const styles: { [key: string]: ViewStyle } = {\n base: {},\n }\n // split pseudos\n for (const key in style) {\n if (!!pseudos[key]) {\n styles[key] = style[key]\n } else {\n styles.base[key] = style[key]\n }\n }\n return Object.keys(styles)\n .map((key) => {\n return getAtomicStyle(styles[key], pseudos[key], avoidCollection)\n })\n .flat()\n}\n\nconst importantRegex = /\\!important*/g\n\nfunction getAtomicStyle(\n style: ViewStyle,\n pseudo?: { name: string; priority: number },\n avoidCollection?: boolean\n): StyleObject[] {\n if (style == null || typeof style !== 'object') {\n throw new Error(`Wrong style type: \"${typeof style}\": ${style}`)\n }\n\n // why is this diff from react-native-web!? need to figure out\n for (const key in borderDefaults) {\n if (key in style) {\n style[borderDefaults[key]] = style[borderDefaults[key]] ?? 'solid'\n }\n }\n\n const all = {\n // TODO man, rnw has a ton of function calls etc here\n ...atomic(createCompileableStyle(createReactDOMStyle(i18Style(style)))),\n }\n\n return Object.keys(all).map((key) => {\n const val = all[key]\n const hash = val.identifier.slice(`${val.identifier}`.lastIndexOf('-') + 1)\n // pseudos have a `--` to be easier to find with concatClassNames\n const psuedoPrefix = pseudo ? `-${pseudo.name}-` : ''\n const identifier = `_${val.property}-${psuedoPrefix}${hash}`\n const className = `.${identifier}`\n const rules = val.rules.map((rule) => {\n if (pseudo) {\n const psuedoPrefixSelect = [...Array(pseudo.priority)].map(() => ':root').join('') + ' '\n let res = rule\n .replace(`.${val.identifier}`, `${psuedoPrefixSelect} ${className}`)\n .replace('{', `:${pseudo.name}{`)\n\n if (pseudo.name === 'hover') {\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 res = `@media not all and (hover: none) { ${res} }`\n }\n return res\n }\n return rule.replace(`.${val.identifier}`, className).replace(importantRegex, '')\n })\n\n if (!avoidCollection) {\n if (rules.length > 1) {\n console.warn('have never seen more than one, verifying')\n }\n AllRules.add(rules[0])\n }\n\n const result: StyleObject = {\n property: val.property,\n value: val.value,\n identifier,\n className,\n rules,\n }\n return result\n })\n}\n"],
|
|
5
|
+
"mappings": ";;AACA;AACA;AACA;AACA;AAEA;AAGO,MAAM,UAAU;AAAA,EACrB,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA;AAAA,EAEZ,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA;AAAA,EAEZ,YAAY;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;AAId,MAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA;AAGb,yBAAyB,OAAY,kBAAkB,OAAO;AACnE,QAAM,SAAuC;AAAA,IAC3C,MAAM;AAAA;AAGR,aAAW,OAAO,OAAO;AACvB,QAAI,CAAC,CAAC,QAAQ,MAAM;AAClB,aAAO,OAAO,MAAM;AAAA,WACf;AACL,aAAO,KAAK,OAAO,MAAM;AAAA;AAAA;AAG7B,SAAO,OAAO,KAAK,QAChB,IAAI,CAAC,QAAQ;AACZ,WAAO,eAAe,OAAO,MAAM,QAAQ,MAAM;AAAA,KAElD;AAAA;AAhBW;AAmBhB,MAAM,iBAAiB;AAEvB,wBACE,OACA,QACA,iBACe;AACf,MAAI,SAAS,QAAQ,OAAO,UAAU,UAAU;AAC9C,UAAM,IAAI,MAAM,sBAAsB,OAAO,WAAW;AAAA;AAI1D,aAAW,OAAO,gBAAgB;AAChC,QAAI,OAAO,OAAO;AAChB,YAAM,eAAe,QAAQ,MAAM,eAAe,SAAS;AAAA;AAAA;AAI/D,QAAM,MAAM;AAAA,OAEP,OAAO,uBAAuB,oBAAoB,SAAS;AAAA;AAGhE,SAAO,OAAO,KAAK,KAAK,IAAI,CAAC,QAAQ;AACnC,UAAM,MAAM,IAAI;AAChB,UAAM,OAAO,IAAI,WAAW,MAAM,GAAG,IAAI,aAAa,YAAY,OAAO;AAEzE,UAAM,eAAe,SAAS,IAAI,OAAO,UAAU;AACnD,UAAM,aAAa,IAAI,IAAI,YAAY,eAAe;AACtD,UAAM,YAAY,IAAI;AACtB,UAAM,QAAQ,IAAI,MAAM,IAAI,CAAC,SAAS;AACpC,UAAI,QAAQ;AACV,cAAM,qBAAqB,CAAC,GAAG,MAAM,OAAO,WAAW,IAAI,MAAM,SAAS,KAAK,MAAM;AACrF,YAAI,MAAM,KACP,QAAQ,IAAI,IAAI,cAAc,GAAG,sBAAsB,aACvD,QAAQ,KAAK,IAAI,OAAO;AAE3B,YAAI,OAAO,SAAS,SAAS;AAM3B,gBAAM,sCAAsC;AAAA;AAE9C,eAAO;AAAA;AAET,aAAO,KAAK,QAAQ,IAAI,IAAI,cAAc,WAAW,QAAQ,gBAAgB;AAAA;AAG/E,QAAI,CAAC,iBAAiB;AACpB,UAAI,MAAM,SAAS,GAAG;AACpB,gBAAQ,KAAK;AAAA;AAEf,eAAS,IAAI,MAAM;AAAA;AAGrB,UAAM,SAAsB;AAAA,MAC1B,UAAU,IAAI;AAAA,MACd,OAAO,IAAI;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA;AAEF,WAAO;AAAA;AAAA;AA9DF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
console.log("is this importing");
|
|
4
|
+
function getStylesAtomic() {
|
|
5
|
+
console.warn("no-op native");
|
|
6
|
+
}
|
|
7
|
+
__name(getStylesAtomic, "getStylesAtomic");
|
|
8
|
+
export {
|
|
9
|
+
getStylesAtomic
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=getStylesAtomic.native.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/getStylesAtomic.native.ts"],
|
|
4
|
+
"sourcesContent": ["console.log('is this importing')\n\nexport function getStylesAtomic() {\n console.warn('no-op native')\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,QAAQ,IAAI;AAEL,2BAA2B;AAChC,UAAQ,KAAK;AAAA;AADC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
18
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
__markAsModule(target);
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/index.ts
|
|
26
|
+
__export(exports, {
|
|
27
|
+
AllRules: () => AllRules,
|
|
28
|
+
concatClassName: () => concatClassName,
|
|
29
|
+
getStyleRules: () => getStyleRules,
|
|
30
|
+
stylePropsAll: () => stylePropsAll,
|
|
31
|
+
stylePropsText: () => stylePropsText,
|
|
32
|
+
stylePropsTextOnly: () => stylePropsTextOnly,
|
|
33
|
+
stylePropsTransform: () => stylePropsTransform,
|
|
34
|
+
stylePropsView: () => stylePropsView,
|
|
35
|
+
validStyles: () => validStyles,
|
|
36
|
+
validStylesPseudo: () => validStylesPseudo
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// src/concatClassName.ts
|
|
40
|
+
function concatClassName(...classNamesOrPropObjects) {
|
|
41
|
+
const usedPrefixes = [];
|
|
42
|
+
let final = "";
|
|
43
|
+
const len = classNamesOrPropObjects.length;
|
|
44
|
+
let propObjects = null;
|
|
45
|
+
for (let x = len; x >= 0; x--) {
|
|
46
|
+
const cns = classNamesOrPropObjects[x];
|
|
47
|
+
if (!cns)
|
|
48
|
+
continue;
|
|
49
|
+
if (!Array.isArray(cns) && typeof cns !== "string") {
|
|
50
|
+
propObjects = propObjects || [];
|
|
51
|
+
propObjects.push(cns);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const names = Array.isArray(cns) ? cns : cns.split(" ");
|
|
55
|
+
for (let i = names.length - 1; i >= 0; i--) {
|
|
56
|
+
const name = names[i];
|
|
57
|
+
if (!name || name === " ")
|
|
58
|
+
continue;
|
|
59
|
+
if (name[0] !== "_") {
|
|
60
|
+
final = name + " " + final;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const splitIndex = name.indexOf("-");
|
|
64
|
+
if (splitIndex < 1) {
|
|
65
|
+
final = name + " " + final;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const nextChar = name[splitIndex + 1];
|
|
69
|
+
const isMediaQuery = nextChar === "_";
|
|
70
|
+
const isPsuedoQuery = nextChar === "-";
|
|
71
|
+
const styleKey = name.slice(1, splitIndex);
|
|
72
|
+
const mediaKey = isMediaQuery || isPsuedoQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null;
|
|
73
|
+
const uid = mediaKey ? styleKey + mediaKey : styleKey;
|
|
74
|
+
if (!isMediaQuery && !isPsuedoQuery) {
|
|
75
|
+
if (usedPrefixes.indexOf(uid) > -1) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
usedPrefixes.push(uid);
|
|
79
|
+
}
|
|
80
|
+
const propName = styleKey;
|
|
81
|
+
if (propName && propObjects) {
|
|
82
|
+
if (propObjects.some((po) => {
|
|
83
|
+
if (mediaKey) {
|
|
84
|
+
const propKey = pseudoInvert[mediaKey];
|
|
85
|
+
return po && po[propKey] && propName in po[propKey] && po[propKey] !== null;
|
|
86
|
+
}
|
|
87
|
+
const res = po && propName in po && po[propName] !== null;
|
|
88
|
+
return res;
|
|
89
|
+
})) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
final = name + " " + final;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return final;
|
|
97
|
+
}
|
|
98
|
+
__name(concatClassName, "concatClassName");
|
|
99
|
+
var pseudoInvert = {
|
|
100
|
+
hover: "hoverStyle",
|
|
101
|
+
focus: "focusStyle",
|
|
102
|
+
press: "pressStyle"
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/validStyleProps.ts
|
|
106
|
+
var stylePropsTransform = {
|
|
107
|
+
x: true,
|
|
108
|
+
y: true,
|
|
109
|
+
scale: true,
|
|
110
|
+
perspective: true,
|
|
111
|
+
scaleX: true,
|
|
112
|
+
scaleY: true,
|
|
113
|
+
skewX: true,
|
|
114
|
+
skewY: true,
|
|
115
|
+
matrix: true,
|
|
116
|
+
rotate: true,
|
|
117
|
+
rotateY: true,
|
|
118
|
+
rotateX: true,
|
|
119
|
+
rotateZ: true
|
|
120
|
+
};
|
|
121
|
+
var stylePropsView = Object.freeze(__spreadValues(__spreadValues({
|
|
122
|
+
backfaceVisibility: true,
|
|
123
|
+
backgroundColor: true,
|
|
124
|
+
borderBottomColor: true,
|
|
125
|
+
borderBottomEndRadius: true,
|
|
126
|
+
borderBottomLeftRadius: true,
|
|
127
|
+
borderBottomRightRadius: true,
|
|
128
|
+
borderBottomStartRadius: true,
|
|
129
|
+
borderBottomWidth: true,
|
|
130
|
+
borderColor: true,
|
|
131
|
+
borderEndColor: true,
|
|
132
|
+
borderLeftColor: true,
|
|
133
|
+
borderLeftWidth: true,
|
|
134
|
+
borderRadius: true,
|
|
135
|
+
borderRightColor: true,
|
|
136
|
+
borderRightWidth: true,
|
|
137
|
+
borderStartColor: true,
|
|
138
|
+
borderStyle: true,
|
|
139
|
+
borderTopColor: true,
|
|
140
|
+
borderTopEndRadius: true,
|
|
141
|
+
borderTopLeftRadius: true,
|
|
142
|
+
borderTopRightRadius: true,
|
|
143
|
+
borderTopStartRadius: true,
|
|
144
|
+
borderTopWidth: true,
|
|
145
|
+
borderWidth: true,
|
|
146
|
+
opacity: true,
|
|
147
|
+
transform: true,
|
|
148
|
+
alignContent: true,
|
|
149
|
+
alignItems: true,
|
|
150
|
+
alignSelf: true,
|
|
151
|
+
aspectRatio: true,
|
|
152
|
+
borderEndWidth: true,
|
|
153
|
+
borderStartWidth: true,
|
|
154
|
+
bottom: true,
|
|
155
|
+
display: true,
|
|
156
|
+
end: true,
|
|
157
|
+
flex: true,
|
|
158
|
+
flexBasis: true,
|
|
159
|
+
flexDirection: true,
|
|
160
|
+
flexGrow: true,
|
|
161
|
+
flexShrink: true,
|
|
162
|
+
flexWrap: true,
|
|
163
|
+
height: true,
|
|
164
|
+
justifyContent: true,
|
|
165
|
+
left: true,
|
|
166
|
+
margin: true,
|
|
167
|
+
marginBottom: true,
|
|
168
|
+
marginEnd: true,
|
|
169
|
+
marginHorizontal: true,
|
|
170
|
+
marginLeft: true,
|
|
171
|
+
marginRight: true,
|
|
172
|
+
marginStart: true,
|
|
173
|
+
marginTop: true,
|
|
174
|
+
marginVertical: true,
|
|
175
|
+
maxHeight: true,
|
|
176
|
+
maxWidth: true,
|
|
177
|
+
minHeight: true,
|
|
178
|
+
minWidth: true,
|
|
179
|
+
overflow: true,
|
|
180
|
+
padding: true,
|
|
181
|
+
paddingBottom: true,
|
|
182
|
+
paddingEnd: true,
|
|
183
|
+
paddingHorizontal: true,
|
|
184
|
+
paddingLeft: true,
|
|
185
|
+
paddingRight: true,
|
|
186
|
+
paddingStart: true,
|
|
187
|
+
paddingTop: true,
|
|
188
|
+
paddingVertical: true,
|
|
189
|
+
position: true,
|
|
190
|
+
right: true,
|
|
191
|
+
start: true,
|
|
192
|
+
top: true,
|
|
193
|
+
width: true,
|
|
194
|
+
zIndex: true,
|
|
195
|
+
direction: true,
|
|
196
|
+
shadowColor: true,
|
|
197
|
+
shadowOffset: true,
|
|
198
|
+
shadowOpacity: true,
|
|
199
|
+
shadowRadius: true
|
|
200
|
+
}, stylePropsTransform), process.env.TAMAGUI_TARGET === "web" && {
|
|
201
|
+
userSelect: true,
|
|
202
|
+
cursor: true,
|
|
203
|
+
contain: true,
|
|
204
|
+
pointerEvents: true,
|
|
205
|
+
boxSizing: true
|
|
206
|
+
}));
|
|
207
|
+
var stylePropsTextOnly = Object.freeze(__spreadValues({
|
|
208
|
+
color: true,
|
|
209
|
+
fontFamily: true,
|
|
210
|
+
fontSize: true,
|
|
211
|
+
fontStyle: true,
|
|
212
|
+
fontWeight: true,
|
|
213
|
+
letterSpacing: true,
|
|
214
|
+
lineHeight: true,
|
|
215
|
+
textAlign: true,
|
|
216
|
+
textDecorationLine: true,
|
|
217
|
+
textDecorationStyle: true,
|
|
218
|
+
textDecorationColor: true,
|
|
219
|
+
textShadowColor: true,
|
|
220
|
+
textShadowOffset: true,
|
|
221
|
+
textShadowRadius: true,
|
|
222
|
+
textTransform: true
|
|
223
|
+
}, process.env.TAMAGUI_TARGET === "web" && {
|
|
224
|
+
whiteSpace: true,
|
|
225
|
+
wordWrap: true,
|
|
226
|
+
textOverflow: true,
|
|
227
|
+
textDecorationDistance: true
|
|
228
|
+
}));
|
|
229
|
+
var stylePropsText = Object.freeze(__spreadValues(__spreadValues({}, stylePropsView), stylePropsTextOnly));
|
|
230
|
+
var stylePropsAll = stylePropsText;
|
|
231
|
+
var validStylesPseudo = {
|
|
232
|
+
hoverStyle: true,
|
|
233
|
+
pressStyle: true,
|
|
234
|
+
focusStyle: true
|
|
235
|
+
};
|
|
236
|
+
var validStyles = __spreadValues(__spreadValues({}, validStylesPseudo), stylePropsView);
|
|
237
|
+
|
|
238
|
+
// src/AllRules.ts
|
|
239
|
+
var AllRules = new Set();
|
|
240
|
+
var getStyleRules = /* @__PURE__ */ __name(() => AllRules, "getStyleRules");
|
|
241
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/concatClassName.ts", "../src/validStyleProps.ts", "../src/AllRules.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './concatClassName'\nexport * from './validStyleProps'\nexport * from './types'\nexport * from './AllRules'\n", "export function concatClassName(...classNamesOrPropObjects: string[]) {\n const usedPrefixes: string[] = []\n let final = ''\n\n const len = classNamesOrPropObjects.length\n let propObjects: any = null\n for (let x = len; x >= 0; x--) {\n const cns = classNamesOrPropObjects[x]\n if (!cns) continue\n if (!Array.isArray(cns) && typeof cns !== 'string') {\n // is prop object\n propObjects = propObjects || []\n propObjects.push(cns)\n continue\n }\n const names = Array.isArray(cns) ? cns : cns.split(' ')\n for (let i = names.length - 1; i >= 0; i--) {\n const name = names[i]\n if (!name || name === ' ') continue\n if (name[0] !== '_') {\n // not snack style (todo slightly stronger heuristic)\n final = name + ' ' + final\n continue\n }\n const splitIndex = name.indexOf('-')\n if (splitIndex < 1) {\n final = name + ' ' + final\n continue\n }\n const nextChar = name[splitIndex + 1]\n // synced to static-ui constants\n // MEDIA_SEP\n const isMediaQuery = nextChar === '_'\n // PSEUDO_SEP\n const isPsuedoQuery = nextChar === '-'\n const styleKey = name.slice(1, splitIndex)\n const mediaKey =\n isMediaQuery || isPsuedoQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null\n const uid = mediaKey ? styleKey + mediaKey : styleKey\n if (!isMediaQuery && !isPsuedoQuery) {\n if (usedPrefixes.indexOf(uid) > -1) {\n continue\n }\n usedPrefixes.push(uid)\n }\n\n // overrides for full safety\n const propName = styleKey\n // shouldLog && console.log('propName', propName)\n if (propName && propObjects) {\n if (\n propObjects.some((po) => {\n if (mediaKey) {\n const propKey = pseudoInvert[mediaKey]\n return po && po[propKey] && propName in po[propKey] && po[propKey] !== null\n }\n const res = po && propName in po && po[propName] !== null\n return res\n })\n ) {\n // shouldLog && console.log('SKIP PROP')\n continue\n }\n }\n\n final = name + ' ' + final\n }\n }\n\n return final\n}\n\nconst pseudoInvert = {\n hover: 'hoverStyle',\n focus: 'focusStyle',\n press: 'pressStyle',\n}\n", "// flat transform props\nexport const stylePropsTransform = {\n x: true,\n y: true,\n scale: true,\n perspective: true,\n scaleX: true,\n scaleY: true,\n skewX: true,\n skewY: true,\n matrix: true,\n rotate: true,\n rotateY: true,\n rotateX: true,\n rotateZ: true,\n}\n\nexport const stylePropsView = Object.freeze({\n backfaceVisibility: true,\n backgroundColor: true,\n borderBottomColor: true,\n borderBottomEndRadius: true,\n borderBottomLeftRadius: true,\n borderBottomRightRadius: true,\n borderBottomStartRadius: true,\n borderBottomWidth: true,\n borderColor: true,\n borderEndColor: true,\n borderLeftColor: true,\n borderLeftWidth: true,\n borderRadius: true,\n borderRightColor: true,\n borderRightWidth: true,\n borderStartColor: true,\n borderStyle: true,\n borderTopColor: true,\n borderTopEndRadius: true,\n borderTopLeftRadius: true,\n borderTopRightRadius: true,\n borderTopStartRadius: true,\n borderTopWidth: true,\n borderWidth: true,\n opacity: true,\n transform: true,\n alignContent: true,\n alignItems: true,\n alignSelf: true,\n aspectRatio: true,\n borderEndWidth: true,\n borderStartWidth: true,\n bottom: true,\n display: true,\n end: true,\n flex: true,\n flexBasis: true,\n flexDirection: true,\n flexGrow: true,\n flexShrink: true,\n flexWrap: true,\n height: true,\n justifyContent: true,\n left: true,\n margin: true,\n marginBottom: true,\n marginEnd: true,\n marginHorizontal: true,\n marginLeft: true,\n marginRight: true,\n marginStart: true,\n marginTop: true,\n marginVertical: true,\n maxHeight: true,\n maxWidth: true,\n minHeight: true,\n minWidth: true,\n overflow: true,\n padding: true,\n paddingBottom: true,\n paddingEnd: true,\n paddingHorizontal: true,\n paddingLeft: true,\n paddingRight: true,\n paddingStart: true,\n paddingTop: true,\n paddingVertical: true,\n position: true,\n right: true,\n start: true,\n top: true,\n width: true,\n zIndex: true,\n direction: true,\n shadowColor: true,\n shadowOffset: true,\n shadowOpacity: true,\n shadowRadius: true,\n ...stylePropsTransform,\n\n // allow a few web only ones\n ...(process.env.TAMAGUI_TARGET === 'web' && {\n userSelect: true,\n cursor: true,\n contain: true,\n pointerEvents: true,\n boxSizing: true,\n }),\n})\n\nexport const stylePropsTextOnly = Object.freeze({\n color: true,\n fontFamily: true,\n fontSize: true,\n fontStyle: true,\n fontWeight: true,\n letterSpacing: true,\n lineHeight: true,\n textAlign: true,\n textDecorationLine: true,\n textDecorationStyle: true,\n textDecorationColor: true,\n textShadowColor: true,\n textShadowOffset: true,\n textShadowRadius: true,\n textTransform: true,\n\n // allow a few web only ones\n // TODO\n ...(process.env.TAMAGUI_TARGET === 'web' && {\n whiteSpace: true,\n wordWrap: true,\n textOverflow: true,\n textDecorationDistance: true,\n }),\n})\n\nexport const stylePropsText = Object.freeze({\n ...stylePropsView,\n ...stylePropsTextOnly,\n})\n\nexport const stylePropsAll = stylePropsText\n\nexport const validStylesPseudo = {\n hoverStyle: true,\n pressStyle: true,\n focusStyle: true,\n}\n\nexport const validStyles = {\n ...validStylesPseudo,\n ...stylePropsView,\n}\n", "// ssr only\n\nexport const AllRules = new Set()\n\nexport const getStyleRules = () => AllRules\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const simpleHash = /* @__PURE__ */ __name((str) => {
|
|
4
|
+
let hash = 0;
|
|
5
|
+
for (let i = 0; i < str.length; i++) {
|
|
6
|
+
const char = str.charCodeAt(i);
|
|
7
|
+
hash = (hash << 5) - hash + char;
|
|
8
|
+
hash &= hash;
|
|
9
|
+
}
|
|
10
|
+
return new Uint32Array([hash])[0].toString(36);
|
|
11
|
+
}, "simpleHash");
|
|
12
|
+
export {
|
|
13
|
+
simpleHash
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=simpleHash.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/simpleHash.ts"],
|
|
4
|
+
"sourcesContent": ["export const simpleHash = (str: string) => {\n let hash = 0\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i)\n hash = (hash << 5) - hash + char\n hash &= hash // Convert to 32bit integer\n }\n return new Uint32Array([hash])[0].toString(36)\n}\n"],
|
|
5
|
+
"mappings": ";;AAAO,MAAM,aAAa,wBAAC,QAAgB;AACzC,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACnC,UAAM,OAAO,IAAI,WAAW;AAC5B,WAAQ,SAAQ,KAAK,OAAO;AAC5B,YAAQ;AAAA;AAEV,SAAO,IAAI,YAAY,CAAC,OAAO,GAAG,SAAS;AAAA,GAPnB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { getNiceKey } from "./getNiceKey";
|
|
4
|
+
import { stylePropsAll } from "./validStyleProps";
|
|
5
|
+
const existing = new Set();
|
|
6
|
+
const uniqueStyleKeys = {};
|
|
7
|
+
const uniqueKeyToStyleName = {};
|
|
8
|
+
for (const name in stylePropsAll) {
|
|
9
|
+
addStylePrefix(name);
|
|
10
|
+
}
|
|
11
|
+
function getOrCreateStylePrefix(name) {
|
|
12
|
+
return uniqueStyleKeys[name] ?? addStylePrefix(name);
|
|
13
|
+
}
|
|
14
|
+
__name(getOrCreateStylePrefix, "getOrCreateStylePrefix");
|
|
15
|
+
function addStylePrefix(name) {
|
|
16
|
+
let len = 1;
|
|
17
|
+
let key = getNiceKey(name);
|
|
18
|
+
while (existing.has(key)) {
|
|
19
|
+
len++;
|
|
20
|
+
key = getNiceKey(name, len);
|
|
21
|
+
}
|
|
22
|
+
existing.add(key);
|
|
23
|
+
uniqueStyleKeys[name] = key;
|
|
24
|
+
uniqueKeyToStyleName[key] = name;
|
|
25
|
+
return key;
|
|
26
|
+
}
|
|
27
|
+
__name(addStylePrefix, "addStylePrefix");
|
|
28
|
+
export {
|
|
29
|
+
getOrCreateStylePrefix,
|
|
30
|
+
uniqueKeyToStyleName,
|
|
31
|
+
uniqueStyleKeys
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=uniqueStyleKeys.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/uniqueStyleKeys.ts"],
|
|
4
|
+
"sourcesContent": ["import { getNiceKey } from './getNiceKey'\nimport { stylePropsAll } from './validStyleProps'\n\nconst existing = new Set<string>()\n\n// unique shortkey for each style key\n// for atomic styles prefixing and collision dedupe\nexport const uniqueStyleKeys: { [key: string]: string } = {}\nexport const uniqueKeyToStyleName: { [key: string]: string } = {}\n\nfor (const name in stylePropsAll) {\n addStylePrefix(name)\n}\n\nexport function getOrCreateStylePrefix(name: string) {\n return uniqueStyleKeys[name] ?? addStylePrefix(name)\n}\n\nfunction addStylePrefix(name: string) {\n let len = 1\n let key = getNiceKey(name)\n while (existing.has(key)) {\n len++\n key = getNiceKey(name, len)\n }\n existing.add(key)\n uniqueStyleKeys[name] = key\n uniqueKeyToStyleName[key] = name\n return key\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AACA;AAEA,MAAM,WAAW,IAAI;AAId,MAAM,kBAA6C;AACnD,MAAM,uBAAkD;AAE/D,WAAW,QAAQ,eAAe;AAChC,iBAAe;AAAA;AAGV,gCAAgC,MAAc;AACnD,SAAO,gBAAgB,SAAS,eAAe;AAAA;AADjC;AAIhB,wBAAwB,MAAc;AACpC,MAAI,MAAM;AACV,MAAI,MAAM,WAAW;AACrB,SAAO,SAAS,IAAI,MAAM;AACxB;AACA,UAAM,WAAW,MAAM;AAAA;AAEzB,WAAS,IAAI;AACb,kBAAgB,QAAQ;AACxB,uBAAqB,OAAO;AAC5B,SAAO;AAAA;AAVA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
const stylePropsTransform = {
|
|
2
|
+
x: true,
|
|
3
|
+
y: true,
|
|
4
|
+
scale: true,
|
|
5
|
+
perspective: true,
|
|
6
|
+
scaleX: true,
|
|
7
|
+
scaleY: true,
|
|
8
|
+
skewX: true,
|
|
9
|
+
skewY: true,
|
|
10
|
+
matrix: true,
|
|
11
|
+
rotate: true,
|
|
12
|
+
rotateY: true,
|
|
13
|
+
rotateX: true,
|
|
14
|
+
rotateZ: true
|
|
15
|
+
};
|
|
16
|
+
const stylePropsView = Object.freeze({
|
|
17
|
+
backfaceVisibility: true,
|
|
18
|
+
backgroundColor: true,
|
|
19
|
+
borderBottomColor: true,
|
|
20
|
+
borderBottomEndRadius: true,
|
|
21
|
+
borderBottomLeftRadius: true,
|
|
22
|
+
borderBottomRightRadius: true,
|
|
23
|
+
borderBottomStartRadius: true,
|
|
24
|
+
borderBottomWidth: true,
|
|
25
|
+
borderColor: true,
|
|
26
|
+
borderEndColor: true,
|
|
27
|
+
borderLeftColor: true,
|
|
28
|
+
borderLeftWidth: true,
|
|
29
|
+
borderRadius: true,
|
|
30
|
+
borderRightColor: true,
|
|
31
|
+
borderRightWidth: true,
|
|
32
|
+
borderStartColor: true,
|
|
33
|
+
borderStyle: true,
|
|
34
|
+
borderTopColor: true,
|
|
35
|
+
borderTopEndRadius: true,
|
|
36
|
+
borderTopLeftRadius: true,
|
|
37
|
+
borderTopRightRadius: true,
|
|
38
|
+
borderTopStartRadius: true,
|
|
39
|
+
borderTopWidth: true,
|
|
40
|
+
borderWidth: true,
|
|
41
|
+
opacity: true,
|
|
42
|
+
transform: true,
|
|
43
|
+
alignContent: true,
|
|
44
|
+
alignItems: true,
|
|
45
|
+
alignSelf: true,
|
|
46
|
+
aspectRatio: true,
|
|
47
|
+
borderEndWidth: true,
|
|
48
|
+
borderStartWidth: true,
|
|
49
|
+
bottom: true,
|
|
50
|
+
display: true,
|
|
51
|
+
end: true,
|
|
52
|
+
flex: true,
|
|
53
|
+
flexBasis: true,
|
|
54
|
+
flexDirection: true,
|
|
55
|
+
flexGrow: true,
|
|
56
|
+
flexShrink: true,
|
|
57
|
+
flexWrap: true,
|
|
58
|
+
height: true,
|
|
59
|
+
justifyContent: true,
|
|
60
|
+
left: true,
|
|
61
|
+
margin: true,
|
|
62
|
+
marginBottom: true,
|
|
63
|
+
marginEnd: true,
|
|
64
|
+
marginHorizontal: true,
|
|
65
|
+
marginLeft: true,
|
|
66
|
+
marginRight: true,
|
|
67
|
+
marginStart: true,
|
|
68
|
+
marginTop: true,
|
|
69
|
+
marginVertical: true,
|
|
70
|
+
maxHeight: true,
|
|
71
|
+
maxWidth: true,
|
|
72
|
+
minHeight: true,
|
|
73
|
+
minWidth: true,
|
|
74
|
+
overflow: true,
|
|
75
|
+
padding: true,
|
|
76
|
+
paddingBottom: true,
|
|
77
|
+
paddingEnd: true,
|
|
78
|
+
paddingHorizontal: true,
|
|
79
|
+
paddingLeft: true,
|
|
80
|
+
paddingRight: true,
|
|
81
|
+
paddingStart: true,
|
|
82
|
+
paddingTop: true,
|
|
83
|
+
paddingVertical: true,
|
|
84
|
+
position: true,
|
|
85
|
+
right: true,
|
|
86
|
+
start: true,
|
|
87
|
+
top: true,
|
|
88
|
+
width: true,
|
|
89
|
+
zIndex: true,
|
|
90
|
+
direction: true,
|
|
91
|
+
shadowColor: true,
|
|
92
|
+
shadowOffset: true,
|
|
93
|
+
shadowOpacity: true,
|
|
94
|
+
shadowRadius: true,
|
|
95
|
+
...stylePropsTransform,
|
|
96
|
+
...process.env.TAMAGUI_TARGET === "web" && {
|
|
97
|
+
userSelect: true,
|
|
98
|
+
cursor: true,
|
|
99
|
+
contain: true,
|
|
100
|
+
pointerEvents: true,
|
|
101
|
+
boxSizing: true
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const stylePropsTextOnly = Object.freeze({
|
|
105
|
+
color: true,
|
|
106
|
+
fontFamily: true,
|
|
107
|
+
fontSize: true,
|
|
108
|
+
fontStyle: true,
|
|
109
|
+
fontWeight: true,
|
|
110
|
+
letterSpacing: true,
|
|
111
|
+
lineHeight: true,
|
|
112
|
+
textAlign: true,
|
|
113
|
+
textDecorationLine: true,
|
|
114
|
+
textDecorationStyle: true,
|
|
115
|
+
textDecorationColor: true,
|
|
116
|
+
textShadowColor: true,
|
|
117
|
+
textShadowOffset: true,
|
|
118
|
+
textShadowRadius: true,
|
|
119
|
+
textTransform: true,
|
|
120
|
+
...process.env.TAMAGUI_TARGET === "web" && {
|
|
121
|
+
whiteSpace: true,
|
|
122
|
+
wordWrap: true,
|
|
123
|
+
textOverflow: true,
|
|
124
|
+
textDecorationDistance: true
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
const stylePropsText = Object.freeze({
|
|
128
|
+
...stylePropsView,
|
|
129
|
+
...stylePropsTextOnly
|
|
130
|
+
});
|
|
131
|
+
const stylePropsAll = stylePropsText;
|
|
132
|
+
const validStylesPseudo = {
|
|
133
|
+
hoverStyle: true,
|
|
134
|
+
pressStyle: true,
|
|
135
|
+
focusStyle: true
|
|
136
|
+
};
|
|
137
|
+
const validStyles = {
|
|
138
|
+
...validStylesPseudo,
|
|
139
|
+
...stylePropsView
|
|
140
|
+
};
|
|
141
|
+
export {
|
|
142
|
+
stylePropsAll,
|
|
143
|
+
stylePropsText,
|
|
144
|
+
stylePropsTextOnly,
|
|
145
|
+
stylePropsTransform,
|
|
146
|
+
stylePropsView,
|
|
147
|
+
validStyles,
|
|
148
|
+
validStylesPseudo
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=validStyleProps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/validStyleProps.ts"],
|
|
4
|
+
"sourcesContent": ["// flat transform props\nexport const stylePropsTransform = {\n x: true,\n y: true,\n scale: true,\n perspective: true,\n scaleX: true,\n scaleY: true,\n skewX: true,\n skewY: true,\n matrix: true,\n rotate: true,\n rotateY: true,\n rotateX: true,\n rotateZ: true,\n}\n\nexport const stylePropsView = Object.freeze({\n backfaceVisibility: true,\n backgroundColor: true,\n borderBottomColor: true,\n borderBottomEndRadius: true,\n borderBottomLeftRadius: true,\n borderBottomRightRadius: true,\n borderBottomStartRadius: true,\n borderBottomWidth: true,\n borderColor: true,\n borderEndColor: true,\n borderLeftColor: true,\n borderLeftWidth: true,\n borderRadius: true,\n borderRightColor: true,\n borderRightWidth: true,\n borderStartColor: true,\n borderStyle: true,\n borderTopColor: true,\n borderTopEndRadius: true,\n borderTopLeftRadius: true,\n borderTopRightRadius: true,\n borderTopStartRadius: true,\n borderTopWidth: true,\n borderWidth: true,\n opacity: true,\n transform: true,\n alignContent: true,\n alignItems: true,\n alignSelf: true,\n aspectRatio: true,\n borderEndWidth: true,\n borderStartWidth: true,\n bottom: true,\n display: true,\n end: true,\n flex: true,\n flexBasis: true,\n flexDirection: true,\n flexGrow: true,\n flexShrink: true,\n flexWrap: true,\n height: true,\n justifyContent: true,\n left: true,\n margin: true,\n marginBottom: true,\n marginEnd: true,\n marginHorizontal: true,\n marginLeft: true,\n marginRight: true,\n marginStart: true,\n marginTop: true,\n marginVertical: true,\n maxHeight: true,\n maxWidth: true,\n minHeight: true,\n minWidth: true,\n overflow: true,\n padding: true,\n paddingBottom: true,\n paddingEnd: true,\n paddingHorizontal: true,\n paddingLeft: true,\n paddingRight: true,\n paddingStart: true,\n paddingTop: true,\n paddingVertical: true,\n position: true,\n right: true,\n start: true,\n top: true,\n width: true,\n zIndex: true,\n direction: true,\n shadowColor: true,\n shadowOffset: true,\n shadowOpacity: true,\n shadowRadius: true,\n ...stylePropsTransform,\n\n // allow a few web only ones\n ...(process.env.TAMAGUI_TARGET === 'web' && {\n userSelect: true,\n cursor: true,\n contain: true,\n pointerEvents: true,\n boxSizing: true,\n }),\n})\n\nexport const stylePropsTextOnly = Object.freeze({\n color: true,\n fontFamily: true,\n fontSize: true,\n fontStyle: true,\n fontWeight: true,\n letterSpacing: true,\n lineHeight: true,\n textAlign: true,\n textDecorationLine: true,\n textDecorationStyle: true,\n textDecorationColor: true,\n textShadowColor: true,\n textShadowOffset: true,\n textShadowRadius: true,\n textTransform: true,\n\n // allow a few web only ones\n // TODO\n ...(process.env.TAMAGUI_TARGET === 'web' && {\n whiteSpace: true,\n wordWrap: true,\n textOverflow: true,\n textDecorationDistance: true,\n }),\n})\n\nexport const stylePropsText = Object.freeze({\n ...stylePropsView,\n ...stylePropsTextOnly,\n})\n\nexport const stylePropsAll = stylePropsText\n\nexport const validStylesPseudo = {\n hoverStyle: true,\n pressStyle: true,\n focusStyle: true,\n}\n\nexport const validStyles = {\n ...validStylesPseudo,\n ...stylePropsView,\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tamagui/helpers",
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
|
+
"source": "src/index.ts",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"typings": "types.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tamagui-build",
|
|
14
|
+
"watch": "tamagui-build --watch"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@tamagui/build": "^1.0.0-alpha.0"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"react-native": "*"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"gitHead": "a41c5a5b08be5518d138515137122c248e3f7c71"
|
|
26
|
+
}
|
package/src/AllRules.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export function concatClassName(...classNamesOrPropObjects: string[]) {
|
|
2
|
+
const usedPrefixes: string[] = []
|
|
3
|
+
let final = ''
|
|
4
|
+
|
|
5
|
+
const len = classNamesOrPropObjects.length
|
|
6
|
+
let propObjects: any = null
|
|
7
|
+
for (let x = len; x >= 0; x--) {
|
|
8
|
+
const cns = classNamesOrPropObjects[x]
|
|
9
|
+
if (!cns) continue
|
|
10
|
+
if (!Array.isArray(cns) && typeof cns !== 'string') {
|
|
11
|
+
// is prop object
|
|
12
|
+
propObjects = propObjects || []
|
|
13
|
+
propObjects.push(cns)
|
|
14
|
+
continue
|
|
15
|
+
}
|
|
16
|
+
const names = Array.isArray(cns) ? cns : cns.split(' ')
|
|
17
|
+
for (let i = names.length - 1; i >= 0; i--) {
|
|
18
|
+
const name = names[i]
|
|
19
|
+
if (!name || name === ' ') continue
|
|
20
|
+
if (name[0] !== '_') {
|
|
21
|
+
// not snack style (todo slightly stronger heuristic)
|
|
22
|
+
final = name + ' ' + final
|
|
23
|
+
continue
|
|
24
|
+
}
|
|
25
|
+
const splitIndex = name.indexOf('-')
|
|
26
|
+
if (splitIndex < 1) {
|
|
27
|
+
final = name + ' ' + final
|
|
28
|
+
continue
|
|
29
|
+
}
|
|
30
|
+
const nextChar = name[splitIndex + 1]
|
|
31
|
+
// synced to static-ui constants
|
|
32
|
+
// MEDIA_SEP
|
|
33
|
+
const isMediaQuery = nextChar === '_'
|
|
34
|
+
// PSEUDO_SEP
|
|
35
|
+
const isPsuedoQuery = nextChar === '-'
|
|
36
|
+
const styleKey = name.slice(1, splitIndex)
|
|
37
|
+
const mediaKey =
|
|
38
|
+
isMediaQuery || isPsuedoQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null
|
|
39
|
+
const uid = mediaKey ? styleKey + mediaKey : styleKey
|
|
40
|
+
if (!isMediaQuery && !isPsuedoQuery) {
|
|
41
|
+
if (usedPrefixes.indexOf(uid) > -1) {
|
|
42
|
+
continue
|
|
43
|
+
}
|
|
44
|
+
usedPrefixes.push(uid)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// overrides for full safety
|
|
48
|
+
const propName = styleKey
|
|
49
|
+
// shouldLog && console.log('propName', propName)
|
|
50
|
+
if (propName && propObjects) {
|
|
51
|
+
if (
|
|
52
|
+
propObjects.some((po) => {
|
|
53
|
+
if (mediaKey) {
|
|
54
|
+
const propKey = pseudoInvert[mediaKey]
|
|
55
|
+
return po && po[propKey] && propName in po[propKey] && po[propKey] !== null
|
|
56
|
+
}
|
|
57
|
+
const res = po && propName in po && po[propName] !== null
|
|
58
|
+
return res
|
|
59
|
+
})
|
|
60
|
+
) {
|
|
61
|
+
// shouldLog && console.log('SKIP PROP')
|
|
62
|
+
continue
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
final = name + ' ' + final
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return final
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const pseudoInvert = {
|
|
74
|
+
hover: 'hoverStyle',
|
|
75
|
+
focus: 'focusStyle',
|
|
76
|
+
press: 'pressStyle',
|
|
77
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const simpleHash = (str: string) => {
|
|
2
|
+
let hash = 0
|
|
3
|
+
for (let i = 0; i < str.length; i++) {
|
|
4
|
+
const char = str.charCodeAt(i)
|
|
5
|
+
hash = (hash << 5) - hash + char
|
|
6
|
+
hash &= hash // Convert to 32bit integer
|
|
7
|
+
}
|
|
8
|
+
return new Uint32Array([hash])[0].toString(36)
|
|
9
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// flat transform props
|
|
2
|
+
export const stylePropsTransform = {
|
|
3
|
+
x: true,
|
|
4
|
+
y: true,
|
|
5
|
+
scale: true,
|
|
6
|
+
perspective: true,
|
|
7
|
+
scaleX: true,
|
|
8
|
+
scaleY: true,
|
|
9
|
+
skewX: true,
|
|
10
|
+
skewY: true,
|
|
11
|
+
matrix: true,
|
|
12
|
+
rotate: true,
|
|
13
|
+
rotateY: true,
|
|
14
|
+
rotateX: true,
|
|
15
|
+
rotateZ: true,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const stylePropsView = Object.freeze({
|
|
19
|
+
backfaceVisibility: true,
|
|
20
|
+
backgroundColor: true,
|
|
21
|
+
borderBottomColor: true,
|
|
22
|
+
borderBottomEndRadius: true,
|
|
23
|
+
borderBottomLeftRadius: true,
|
|
24
|
+
borderBottomRightRadius: true,
|
|
25
|
+
borderBottomStartRadius: true,
|
|
26
|
+
borderBottomWidth: true,
|
|
27
|
+
borderColor: true,
|
|
28
|
+
borderEndColor: true,
|
|
29
|
+
borderLeftColor: true,
|
|
30
|
+
borderLeftWidth: true,
|
|
31
|
+
borderRadius: true,
|
|
32
|
+
borderRightColor: true,
|
|
33
|
+
borderRightWidth: true,
|
|
34
|
+
borderStartColor: true,
|
|
35
|
+
borderStyle: true,
|
|
36
|
+
borderTopColor: true,
|
|
37
|
+
borderTopEndRadius: true,
|
|
38
|
+
borderTopLeftRadius: true,
|
|
39
|
+
borderTopRightRadius: true,
|
|
40
|
+
borderTopStartRadius: true,
|
|
41
|
+
borderTopWidth: true,
|
|
42
|
+
borderWidth: true,
|
|
43
|
+
opacity: true,
|
|
44
|
+
transform: true,
|
|
45
|
+
alignContent: true,
|
|
46
|
+
alignItems: true,
|
|
47
|
+
alignSelf: true,
|
|
48
|
+
aspectRatio: true,
|
|
49
|
+
borderEndWidth: true,
|
|
50
|
+
borderStartWidth: true,
|
|
51
|
+
bottom: true,
|
|
52
|
+
display: true,
|
|
53
|
+
end: true,
|
|
54
|
+
flex: true,
|
|
55
|
+
flexBasis: true,
|
|
56
|
+
flexDirection: true,
|
|
57
|
+
flexGrow: true,
|
|
58
|
+
flexShrink: true,
|
|
59
|
+
flexWrap: true,
|
|
60
|
+
height: true,
|
|
61
|
+
justifyContent: true,
|
|
62
|
+
left: true,
|
|
63
|
+
margin: true,
|
|
64
|
+
marginBottom: true,
|
|
65
|
+
marginEnd: true,
|
|
66
|
+
marginHorizontal: true,
|
|
67
|
+
marginLeft: true,
|
|
68
|
+
marginRight: true,
|
|
69
|
+
marginStart: true,
|
|
70
|
+
marginTop: true,
|
|
71
|
+
marginVertical: true,
|
|
72
|
+
maxHeight: true,
|
|
73
|
+
maxWidth: true,
|
|
74
|
+
minHeight: true,
|
|
75
|
+
minWidth: true,
|
|
76
|
+
overflow: true,
|
|
77
|
+
padding: true,
|
|
78
|
+
paddingBottom: true,
|
|
79
|
+
paddingEnd: true,
|
|
80
|
+
paddingHorizontal: true,
|
|
81
|
+
paddingLeft: true,
|
|
82
|
+
paddingRight: true,
|
|
83
|
+
paddingStart: true,
|
|
84
|
+
paddingTop: true,
|
|
85
|
+
paddingVertical: true,
|
|
86
|
+
position: true,
|
|
87
|
+
right: true,
|
|
88
|
+
start: true,
|
|
89
|
+
top: true,
|
|
90
|
+
width: true,
|
|
91
|
+
zIndex: true,
|
|
92
|
+
direction: true,
|
|
93
|
+
shadowColor: true,
|
|
94
|
+
shadowOffset: true,
|
|
95
|
+
shadowOpacity: true,
|
|
96
|
+
shadowRadius: true,
|
|
97
|
+
...stylePropsTransform,
|
|
98
|
+
|
|
99
|
+
// allow a few web only ones
|
|
100
|
+
...(process.env.TAMAGUI_TARGET === 'web' && {
|
|
101
|
+
userSelect: true,
|
|
102
|
+
cursor: true,
|
|
103
|
+
contain: true,
|
|
104
|
+
pointerEvents: true,
|
|
105
|
+
boxSizing: true,
|
|
106
|
+
}),
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
export const stylePropsTextOnly = Object.freeze({
|
|
110
|
+
color: true,
|
|
111
|
+
fontFamily: true,
|
|
112
|
+
fontSize: true,
|
|
113
|
+
fontStyle: true,
|
|
114
|
+
fontWeight: true,
|
|
115
|
+
letterSpacing: true,
|
|
116
|
+
lineHeight: true,
|
|
117
|
+
textAlign: true,
|
|
118
|
+
textDecorationLine: true,
|
|
119
|
+
textDecorationStyle: true,
|
|
120
|
+
textDecorationColor: true,
|
|
121
|
+
textShadowColor: true,
|
|
122
|
+
textShadowOffset: true,
|
|
123
|
+
textShadowRadius: true,
|
|
124
|
+
textTransform: true,
|
|
125
|
+
|
|
126
|
+
// allow a few web only ones
|
|
127
|
+
// TODO
|
|
128
|
+
...(process.env.TAMAGUI_TARGET === 'web' && {
|
|
129
|
+
whiteSpace: true,
|
|
130
|
+
wordWrap: true,
|
|
131
|
+
textOverflow: true,
|
|
132
|
+
textDecorationDistance: true,
|
|
133
|
+
}),
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
export const stylePropsText = Object.freeze({
|
|
137
|
+
...stylePropsView,
|
|
138
|
+
...stylePropsTextOnly,
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
export const stylePropsAll = stylePropsText
|
|
142
|
+
|
|
143
|
+
export const validStylesPseudo = {
|
|
144
|
+
hoverStyle: true,
|
|
145
|
+
pressStyle: true,
|
|
146
|
+
focusStyle: true,
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export const validStyles = {
|
|
150
|
+
...validStylesPseudo,
|
|
151
|
+
...stylePropsView,
|
|
152
|
+
}
|