@tamagui/helpers 1.0.0-alpha.38 → 1.0.0-alpha.39

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.
Files changed (50) hide show
  1. package/dist/cjs/allRules.js +15 -0
  2. package/dist/cjs/allRules.js.map +7 -0
  3. package/dist/cjs/concatClassName.js +78 -0
  4. package/dist/cjs/concatClassName.js.map +7 -0
  5. package/dist/cjs/index.js +24 -0
  6. package/dist/cjs/index.js.map +7 -0
  7. package/dist/cjs/simpleHash.js +21 -0
  8. package/dist/cjs/simpleHash.js.map +7 -0
  9. package/dist/cjs/types.js +4 -0
  10. package/dist/cjs/types.js.map +7 -0
  11. package/dist/cjs/validStyleProps.js +163 -0
  12. package/dist/cjs/validStyleProps.js.map +7 -0
  13. package/dist/esm/allRules.js +9 -0
  14. package/dist/esm/allRules.js.map +7 -0
  15. package/dist/esm/concatClassName.js +72 -0
  16. package/dist/esm/concatClassName.js.map +7 -0
  17. package/dist/{index.js → esm/index.js} +1 -3
  18. package/dist/esm/index.js.map +7 -0
  19. package/dist/{simpleHash.js → esm/simpleHash.js} +0 -0
  20. package/dist/{simpleHash.js.map → esm/simpleHash.js.map} +1 -1
  21. package/dist/{types.js → esm/types.js} +0 -0
  22. package/dist/{types.js.map → esm/types.js.map} +0 -0
  23. package/dist/{validStyleProps.js → esm/validStyleProps.js} +26 -14
  24. package/dist/esm/validStyleProps.js.map +7 -0
  25. package/dist/jsx/allRules.js +8 -0
  26. package/dist/jsx/concatClassName.js +71 -0
  27. package/dist/jsx/index.js +4 -0
  28. package/dist/jsx/simpleHash.js +14 -0
  29. package/dist/jsx/types.js +0 -0
  30. package/dist/jsx/validStyleProps.js +149 -0
  31. package/package.json +3 -3
  32. package/types/allRules.d.ts.map +1 -0
  33. package/types/concatClassName.d.ts.map +1 -0
  34. package/types/index.d.ts.map +1 -0
  35. package/types/simpleHash.d.ts.map +1 -0
  36. package/types/types.d.ts.map +1 -0
  37. package/types/validStyleProps.d.ts.map +1 -0
  38. package/dist/.buildinfo +0 -1
  39. package/dist/concatClassName.js +0 -60
  40. package/dist/concatClassName.js.map +0 -7
  41. package/dist/getNiceKey.js +0 -16
  42. package/dist/getNiceKey.js.map +0 -7
  43. package/dist/getStylesAtomic.js +0 -101
  44. package/dist/getStylesAtomic.js.map +0 -7
  45. package/dist/index.cjs +0 -379
  46. package/dist/index.cjs.map +0 -7
  47. package/dist/index.js.map +0 -7
  48. package/dist/uniqueStyleKeys.js +0 -33
  49. package/dist/uniqueStyleKeys.js.map +0 -7
  50. package/dist/validStyleProps.js.map +0 -7
@@ -0,0 +1,71 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ function concatClassName(_cn) {
4
+ const classNamesOrPropObjects = arguments;
5
+ const usedPrefixes = [];
6
+ let final = "";
7
+ const len = classNamesOrPropObjects.length;
8
+ let propObjects = null;
9
+ for (let x = len; x >= 0; x--) {
10
+ const cns = classNamesOrPropObjects[x];
11
+ if (!cns)
12
+ continue;
13
+ if (!Array.isArray(cns) && typeof cns !== "string") {
14
+ propObjects = propObjects || [];
15
+ propObjects.push(cns);
16
+ continue;
17
+ }
18
+ const names = Array.isArray(cns) ? cns : cns.split(" ");
19
+ const numNames = names.length;
20
+ for (let i = numNames - 1; i >= 0; i--) {
21
+ const name = names[i];
22
+ if (!name || name === " ")
23
+ continue;
24
+ if (name[0] !== "_") {
25
+ final = name + " " + final;
26
+ continue;
27
+ }
28
+ const splitIndex = name.indexOf("-");
29
+ if (splitIndex < 1) {
30
+ final = name + " " + final;
31
+ continue;
32
+ }
33
+ const nextChar = name[splitIndex + 1];
34
+ const isMediaQuery = nextChar === "_";
35
+ const isPsuedoQuery = nextChar === "-";
36
+ const styleKey = name.slice(1, splitIndex);
37
+ const mediaKey = isMediaQuery || isPsuedoQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null;
38
+ const uid = mediaKey ? styleKey + mediaKey : styleKey;
39
+ if (!isMediaQuery && !isPsuedoQuery) {
40
+ if (usedPrefixes.indexOf(uid) > -1) {
41
+ continue;
42
+ }
43
+ usedPrefixes.push(uid);
44
+ }
45
+ const propName = styleKey;
46
+ if (propName && propObjects) {
47
+ if (propObjects.some((po) => {
48
+ if (mediaKey) {
49
+ const propKey = pseudoInvert[mediaKey];
50
+ return po && po[propKey] && propName in po[propKey] && po[propKey] !== null;
51
+ }
52
+ const res = po && propName in po && po[propName] !== null;
53
+ return res;
54
+ })) {
55
+ continue;
56
+ }
57
+ }
58
+ final = name + " " + final;
59
+ }
60
+ }
61
+ return final;
62
+ }
63
+ __name(concatClassName, "concatClassName");
64
+ const pseudoInvert = {
65
+ hover: "hoverStyle",
66
+ focus: "focusStyle",
67
+ press: "pressStyle"
68
+ };
69
+ export {
70
+ concatClassName
71
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./concatClassName";
2
+ export * from "./validStyleProps";
3
+ export * from "./types";
4
+ export * from "./allRules";
@@ -0,0 +1,14 @@
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
+ };
File without changes
@@ -0,0 +1,149 @@
1
+ const stylePropsTransform = Object.freeze({
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 = Object.freeze({
133
+ hoverStyle: true,
134
+ pressStyle: true,
135
+ focusStyle: true
136
+ });
137
+ const validStyles = Object.freeze({
138
+ ...validStylesPseudo,
139
+ ...stylePropsView
140
+ });
141
+ export {
142
+ stylePropsAll,
143
+ stylePropsText,
144
+ stylePropsTextOnly,
145
+ stylePropsTransform,
146
+ stylePropsView,
147
+ validStyles,
148
+ validStylesPseudo
149
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/helpers",
3
- "version": "1.0.0-alpha.38",
3
+ "version": "1.0.0-alpha.39",
4
4
  "source": "src/index.ts",
5
5
  "typings": "types",
6
6
  "main": "dist/cjs",
@@ -15,7 +15,7 @@
15
15
  "watch": "tamagui-build --watch"
16
16
  },
17
17
  "devDependencies": {
18
- "@tamagui/build": "^1.0.0-alpha.38",
18
+ "@tamagui/build": "^1.0.0-alpha.39",
19
19
  "react-native": "*"
20
20
  },
21
21
  "peerDependencies": {
@@ -24,5 +24,5 @@
24
24
  "publishConfig": {
25
25
  "access": "public"
26
26
  },
27
- "gitHead": "155f989a05a70b2a9181cf820363f170a293f78b"
27
+ "gitHead": "20b8c3487cae35a29bf878191fdc0381020b5304"
28
28
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allRules.d.ts","sourceRoot":"","sources":["../src/allRules.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,cAAY,CAAA;AAEjC,eAAO,MAAM,aAAa,oBAAiB,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concatClassName.d.ts","sourceRoot":"","sources":["../src/concatClassName.ts"],"names":[],"mappings":"AAUA,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,UAoFvC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simpleHash.d.ts","sourceRoot":"","sources":["../src/simpleHash.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,QAAS,MAAM,WAQrC,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validStyleProps.d.ts","sourceRoot":"","sources":["../src/validStyleProps.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;EAc9B,CAAA;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyFzB,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;EAyB7B,CAAA;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGzB,CAAA;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAiB,CAAA;AAE3C,eAAO,MAAM,iBAAiB;;;;EAI5B,CAAA;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGtB,CAAA"}
package/dist/.buildinfo DELETED
@@ -1 +0,0 @@
1
- {"at":1636517189907}
@@ -1,60 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { uniqueKeyToStyleName } from "./uniqueStyleKeys";
4
- const pseudoInvert = {
5
- hover: "hoverStyle",
6
- focus: "focusStyle",
7
- press: "pressStyle"
8
- };
9
- function concatClassName(className, ...propObjects) {
10
- const usedPrefixes = new Set();
11
- const final = [];
12
- const names = className.split(" ");
13
- const hasPropObjects = propObjects.length;
14
- for (let i = names.length - 1; i >= 0; i--) {
15
- const name = names[i];
16
- if (!name || name === " ")
17
- continue;
18
- if (name[0] !== "_") {
19
- final.push(name);
20
- continue;
21
- }
22
- const splitIndex = name.indexOf("-");
23
- if (splitIndex < 1) {
24
- final.push(name);
25
- continue;
26
- }
27
- const nextChar = name[splitIndex + 1];
28
- const isMediaQuery = nextChar === "_";
29
- const isPsuedoQuery = nextChar === "-";
30
- const styleKey = name.slice(1, splitIndex);
31
- const mediaKey = isMediaQuery || isPsuedoQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null;
32
- const uid = mediaKey ? styleKey + mediaKey : styleKey;
33
- if (!isMediaQuery && !isPsuedoQuery) {
34
- if (usedPrefixes.has(uid)) {
35
- continue;
36
- }
37
- usedPrefixes.add(uid);
38
- }
39
- const propName = uniqueKeyToStyleName[styleKey];
40
- if (propName && hasPropObjects) {
41
- if (propObjects.some((po) => {
42
- if (mediaKey) {
43
- const propKey = pseudoInvert[mediaKey];
44
- return po && po[propKey] && propName in po[propKey] && po[propKey] !== null;
45
- }
46
- const res = po && propName in po && po[propName] !== null;
47
- return res;
48
- })) {
49
- continue;
50
- }
51
- }
52
- final.push(name);
53
- }
54
- return final.join(" ");
55
- }
56
- __name(concatClassName, "concatClassName");
57
- export {
58
- concatClassName
59
- };
60
- //# sourceMappingURL=concatClassName.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/concatClassName.ts"],
4
- "sourcesContent": ["import { uniqueKeyToStyleName } from './uniqueStyleKeys'\n\nconst pseudoInvert = {\n hover: 'hoverStyle',\n focus: 'focusStyle',\n press: 'pressStyle',\n}\n\nexport function concatClassName(className: string, ...propObjects: any[]) {\n const usedPrefixes = new Set<string>()\n const final: string[] = []\n const names = className.split(' ')\n const hasPropObjects = propObjects.length\n // const shouldLog = className.includes('_col-varzzzcolor3z')\n // shouldLog && console.log('>>>>>>>>>>', className)\n\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.push(name)\n continue\n }\n const splitIndex = name.indexOf('-')\n if (splitIndex < 1) {\n final.push(name)\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 // shouldLog && console.log('uid', uid)\n if (!isMediaQuery && !isPsuedoQuery) {\n if (usedPrefixes.has(uid)) {\n // shouldLog && console.log('used', uid)\n continue\n }\n usedPrefixes.add(uid)\n }\n const propName = uniqueKeyToStyleName[styleKey]\n // shouldLog && console.log('propName', propName)\n if (propName && hasPropObjects) {\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 // shouldLog && res && console.log('SKIP BECAUSE', propName, po)\n return res\n })\n ) {\n // shouldLog && console.log('SKIP PROP')\n continue\n }\n }\n // shouldLog && console.log('push', name)\n final.push(name)\n }\n\n // shouldLog && console.log(' in:', className, 'out:', final)\n\n return final.join(' ')\n}\n"],
5
- "mappings": ";;AAAA;AAEA,MAAM,eAAe;AAAA,EACnB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA;AAGF,yBAAyB,cAAsB,aAAoB;AACxE,QAAM,eAAe,IAAI;AACzB,QAAM,QAAkB;AACxB,QAAM,QAAQ,UAAU,MAAM;AAC9B,QAAM,iBAAiB,YAAY;AAInC,WAAS,IAAI,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK;AAC1C,UAAM,OAAO,MAAM;AACnB,QAAI,CAAC,QAAQ,SAAS;AAAK;AAC3B,QAAI,KAAK,OAAO,KAAK;AAEnB,YAAM,KAAK;AACX;AAAA;AAEF,UAAM,aAAa,KAAK,QAAQ;AAChC,QAAI,aAAa,GAAG;AAClB,YAAM,KAAK;AACX;AAAA;AAEF,UAAM,WAAW,KAAK,aAAa;AAGnC,UAAM,eAAe,aAAa;AAElC,UAAM,gBAAgB,aAAa;AACnC,UAAM,WAAW,KAAK,MAAM,GAAG;AAC/B,UAAM,WACJ,gBAAgB,gBAAgB,KAAK,MAAM,aAAa,GAAG,aAAa,KAAK;AAC/E,UAAM,MAAM,WAAW,WAAW,WAAW;AAE7C,QAAI,CAAC,gBAAgB,CAAC,eAAe;AACnC,UAAI,aAAa,IAAI,MAAM;AAEzB;AAAA;AAEF,mBAAa,IAAI;AAAA;AAEnB,UAAM,WAAW,qBAAqB;AAEtC,QAAI,YAAY,gBAAgB;AAC9B,UACE,YAAY,KAAK,CAAC,OAAO;AACvB,YAAI,UAAU;AACZ,gBAAM,UAAU,aAAa;AAC7B,iBAAO,MAAM,GAAG,YAAY,YAAY,GAAG,YAAY,GAAG,aAAa;AAAA;AAEzE,cAAM,MAAM,MAAM,YAAY,MAAM,GAAG,cAAc;AAErD,eAAO;AAAA,UAET;AAEA;AAAA;AAAA;AAIJ,UAAM,KAAK;AAAA;AAKb,SAAO,MAAM,KAAK;AAAA;AA/DJ;",
6
- "names": []
7
- }
@@ -1,16 +0,0 @@
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
@@ -1,7 +0,0 @@
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
- }
@@ -1,101 +0,0 @@
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 { simpleHash } from "./simpleHash";
8
- import { getOrCreateStylePrefix } from "./uniqueStyleKeys";
9
- const pseudos = {
10
- focusWithinStyle: {
11
- name: "focus-within",
12
- priority: 4
13
- },
14
- focusStyle: {
15
- name: "focus",
16
- priority: 3
17
- },
18
- pressStyle: {
19
- name: "active",
20
- priority: 2
21
- },
22
- hoverStyle: {
23
- name: "hover",
24
- priority: 1
25
- }
26
- };
27
- const borderDefaults = {
28
- borderWidth: "borderStyle",
29
- borderBottomWidth: "borderBottomStyle",
30
- borderTopWidth: "borderTopStyle",
31
- borderLeftWidth: "borderLeftStyle",
32
- borderRightWidth: "borderRightStyle"
33
- };
34
- function getStylesAtomic(style) {
35
- const styles = {
36
- base: {}
37
- };
38
- for (const key in style) {
39
- if (!!pseudos[key]) {
40
- styles[key] = style[key];
41
- } else {
42
- styles.base[key] = style[key];
43
- }
44
- }
45
- return Object.keys(styles).map((key) => {
46
- return getAtomicStyle(styles[key], pseudos[key]);
47
- }).flat();
48
- }
49
- __name(getStylesAtomic, "getStylesAtomic");
50
- const importantRegex = /\!important*/g;
51
- function getAtomicStyle(style, pseudo) {
52
- if (style == null || typeof style !== "object") {
53
- throw new Error(`Wrong style type: "${typeof style}": ${style}`);
54
- }
55
- for (const key in borderDefaults) {
56
- if (key in style) {
57
- style[borderDefaults[key]] = style[borderDefaults[key]] ?? "solid";
58
- }
59
- }
60
- const all = {
61
- ...atomic(createCompileableStyle(createReactDOMStyle(i18Style(style))))
62
- };
63
- return Object.keys(all).map((key) => {
64
- const val = all[key];
65
- const prefix = `_${getOrCreateStylePrefix(val.property)}`;
66
- const hash = (() => {
67
- let s = `${val.value}`.replace(/[%]/g, "pct").replace(/[^a-z0-9]/gi, "z").replace(/\s/, "-");
68
- if (s.length < 16)
69
- return s;
70
- return simpleHash(val.identifier);
71
- })();
72
- const psuedoPrefix = pseudo ? `-${pseudo.name}-` : "";
73
- const identifier = `${prefix}-${psuedoPrefix}${hash}`;
74
- const className = `.${identifier}`;
75
- const rules = val.rules.map((rule) => {
76
- if (pseudo) {
77
- const psuedoPrefixSelect = [...Array(pseudo.priority)].map(() => ":root").join("") + " ";
78
- let res = rule.replace(`.${val.identifier}`, `${psuedoPrefixSelect} ${className}`).replace("{", `:${pseudo.name}{`);
79
- if (pseudo.name === "hover") {
80
- res = `@media not all and (hover: none) { ${res} }`;
81
- }
82
- return res;
83
- }
84
- return rule.replace(`.${val.identifier}`, className).replace(importantRegex, "");
85
- });
86
- const result = {
87
- property: val.property,
88
- value: val.value,
89
- identifier,
90
- className,
91
- rules
92
- };
93
- return result;
94
- });
95
- }
96
- __name(getAtomicStyle, "getAtomicStyle");
97
- export {
98
- getStylesAtomic,
99
- pseudos
100
- };
101
- //# sourceMappingURL=getStylesAtomic.js.map
@@ -1,7 +0,0 @@
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 { simpleHash } from './simpleHash'\nimport { StyleObject } from './types'\nimport { getOrCreateStylePrefix } from './uniqueStyleKeys'\n\nexport const pseudos = {\n focusWithinStyle: {\n name: 'focus-within',\n priority: 4,\n },\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) {\n const styles: { [key: string]: ViewStyle } = {\n base: {},\n }\n // split psuedos\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])\n })\n .flat()\n}\n\nconst importantRegex = /\\!important*/g\n\nfunction getAtomicStyle(style: ViewStyle, pseudo?: { name: string; priority: number }): 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 ...atomic(createCompileableStyle(createReactDOMStyle(i18Style(style)))),\n }\n\n return Object.keys(all).map((key) => {\n const val = all[key]\n const prefix = `_${getOrCreateStylePrefix(val.property)}`\n const hash = (() => {\n let s = `${val.value}`\n .replace(/[%]/g, 'pct')\n .replace(/[^a-z0-9]/gi, 'z')\n .replace(/\\s/, '-')\n if (s.length < 16) return s\n return simpleHash(val.identifier)\n })()\n\n // pseudos have a `--` to be easier to find with concatClassNames\n const psuedoPrefix = pseudo ? `-${pseudo.name}-` : ''\n const identifier = `${prefix}-${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 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;AAEA;AAEO,MAAM,UAAU;AAAA,EACrB,kBAAkB;AAAA,IAChB,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,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;AAC1C,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;AAAA,KAE5C;AAAA;AAhBW;AAmBhB,MAAM,iBAAiB;AAEvB,wBAAwB,OAAkB,QAA4D;AACpG,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,OACP,OAAO,uBAAuB,oBAAoB,SAAS;AAAA;AAGhE,SAAO,OAAO,KAAK,KAAK,IAAI,CAAC,QAAQ;AACnC,UAAM,MAAM,IAAI;AAChB,UAAM,SAAS,IAAI,uBAAuB,IAAI;AAC9C,UAAM,OAAQ,OAAM;AAClB,UAAI,IAAI,GAAG,IAAI,QACZ,QAAQ,QAAQ,OAChB,QAAQ,eAAe,KACvB,QAAQ,MAAM;AACjB,UAAI,EAAE,SAAS;AAAI,eAAO;AAC1B,aAAO,WAAW,IAAI;AAAA;AAIxB,UAAM,eAAe,SAAS,IAAI,OAAO,UAAU;AACnD,UAAM,aAAa,GAAG,UAAU,eAAe;AAC/C,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;AAE/E,UAAM,SAAsB;AAAA,MAC1B,UAAU,IAAI;AAAA,MACd,OAAO,IAAI;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA;AAEF,WAAO;AAAA;AAAA;AA1DF;",
6
- "names": []
7
- }