@react-native-styled-system/core 0.0.5

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 (152) hide show
  1. package/bin/theme-gen.js +149 -0
  2. package/lib/commonjs/@types/SxProps.js +12 -0
  3. package/lib/commonjs/@types/SxProps.js.map +1 -0
  4. package/lib/commonjs/@types/ThemedDict.js +14 -0
  5. package/lib/commonjs/@types/ThemedDict.js.map +1 -0
  6. package/lib/commonjs/@types/ThemedTypings.js +6 -0
  7. package/lib/commonjs/@types/ThemedTypings.js.map +1 -0
  8. package/lib/commonjs/@types/Token.js +6 -0
  9. package/lib/commonjs/@types/Token.js.map +1 -0
  10. package/lib/commonjs/hook/useSx.js +82 -0
  11. package/lib/commonjs/hook/useSx.js.map +1 -0
  12. package/lib/commonjs/hook/useSxStyle.js +29 -0
  13. package/lib/commonjs/hook/useSxStyle.js.map +1 -0
  14. package/lib/commonjs/hook/useSxTokens.js +33 -0
  15. package/lib/commonjs/hook/useSxTokens.js.map +1 -0
  16. package/lib/commonjs/index.js +72 -0
  17. package/lib/commonjs/index.js.map +1 -0
  18. package/lib/commonjs/internal/TokenParser/ColorsParser.js +21 -0
  19. package/lib/commonjs/internal/TokenParser/ColorsParser.js.map +1 -0
  20. package/lib/commonjs/internal/TokenParser/RadiiParser.js +41 -0
  21. package/lib/commonjs/internal/TokenParser/RadiiParser.js.map +1 -0
  22. package/lib/commonjs/internal/TokenParser/SizesParser.js +41 -0
  23. package/lib/commonjs/internal/TokenParser/SizesParser.js.map +1 -0
  24. package/lib/commonjs/internal/TokenParser/SpaceParser.js +90 -0
  25. package/lib/commonjs/internal/TokenParser/SpaceParser.js.map +1 -0
  26. package/lib/commonjs/internal/TokenParser/TokenParser.js +23 -0
  27. package/lib/commonjs/internal/TokenParser/TokenParser.js.map +1 -0
  28. package/lib/commonjs/internal/TokenParser/TypographyParser.js +23 -0
  29. package/lib/commonjs/internal/TokenParser/TypographyParser.js.map +1 -0
  30. package/lib/commonjs/internal/useStableCallback.js +34 -0
  31. package/lib/commonjs/internal/useStableCallback.js.map +1 -0
  32. package/lib/commonjs/internal/util/fillNullishThemeKey.js +18 -0
  33. package/lib/commonjs/internal/util/fillNullishThemeKey.js.map +1 -0
  34. package/lib/commonjs/internal/util/fillStyleIfNotNullish.js +21 -0
  35. package/lib/commonjs/internal/util/fillStyleIfNotNullish.js.map +1 -0
  36. package/lib/commonjs/internal/util/parsePxSuffixNumber.js +16 -0
  37. package/lib/commonjs/internal/util/parsePxSuffixNumber.js.map +1 -0
  38. package/lib/commonjs/internal/util/printWarning.js +18 -0
  39. package/lib/commonjs/internal/util/printWarning.js.map +1 -0
  40. package/lib/commonjs/provider/StyledSystemProvider.js +25 -0
  41. package/lib/commonjs/provider/StyledSystemProvider.js.map +1 -0
  42. package/lib/commonjs/util/propsToThemedStyle.js +138 -0
  43. package/lib/commonjs/util/propsToThemedStyle.js.map +1 -0
  44. package/lib/module/@types/SxProps.js +6 -0
  45. package/lib/module/@types/SxProps.js.map +1 -0
  46. package/lib/module/@types/ThemedDict.js +8 -0
  47. package/lib/module/@types/ThemedDict.js.map +1 -0
  48. package/lib/module/@types/ThemedTypings.js +2 -0
  49. package/lib/module/@types/ThemedTypings.js.map +1 -0
  50. package/lib/module/@types/Token.js +2 -0
  51. package/lib/module/@types/Token.js.map +1 -0
  52. package/lib/module/hook/useSx.js +75 -0
  53. package/lib/module/hook/useSx.js.map +1 -0
  54. package/lib/module/hook/useSxStyle.js +22 -0
  55. package/lib/module/hook/useSxStyle.js.map +1 -0
  56. package/lib/module/hook/useSxTokens.js +26 -0
  57. package/lib/module/hook/useSxTokens.js.map +1 -0
  58. package/lib/module/index.js +7 -0
  59. package/lib/module/index.js.map +1 -0
  60. package/lib/module/internal/TokenParser/ColorsParser.js +14 -0
  61. package/lib/module/internal/TokenParser/ColorsParser.js.map +1 -0
  62. package/lib/module/internal/TokenParser/RadiiParser.js +34 -0
  63. package/lib/module/internal/TokenParser/RadiiParser.js.map +1 -0
  64. package/lib/module/internal/TokenParser/SizesParser.js +34 -0
  65. package/lib/module/internal/TokenParser/SizesParser.js.map +1 -0
  66. package/lib/module/internal/TokenParser/SpaceParser.js +82 -0
  67. package/lib/module/internal/TokenParser/SpaceParser.js.map +1 -0
  68. package/lib/module/internal/TokenParser/TokenParser.js +16 -0
  69. package/lib/module/internal/TokenParser/TokenParser.js.map +1 -0
  70. package/lib/module/internal/TokenParser/TypographyParser.js +15 -0
  71. package/lib/module/internal/TokenParser/TypographyParser.js.map +1 -0
  72. package/lib/module/internal/useStableCallback.js +27 -0
  73. package/lib/module/internal/useStableCallback.js.map +1 -0
  74. package/lib/module/internal/util/fillNullishThemeKey.js +11 -0
  75. package/lib/module/internal/util/fillNullishThemeKey.js.map +1 -0
  76. package/lib/module/internal/util/fillStyleIfNotNullish.js +14 -0
  77. package/lib/module/internal/util/fillStyleIfNotNullish.js.map +1 -0
  78. package/lib/module/internal/util/parsePxSuffixNumber.js +10 -0
  79. package/lib/module/internal/util/parsePxSuffixNumber.js.map +1 -0
  80. package/lib/module/internal/util/printWarning.js +11 -0
  81. package/lib/module/internal/util/printWarning.js.map +1 -0
  82. package/lib/module/provider/StyledSystemProvider.js +17 -0
  83. package/lib/module/provider/StyledSystemProvider.js.map +1 -0
  84. package/lib/module/util/propsToThemedStyle.js +131 -0
  85. package/lib/module/util/propsToThemedStyle.js.map +1 -0
  86. package/lib/typescript/@types/SxProps.d.ts +140 -0
  87. package/lib/typescript/@types/SxProps.d.ts.map +1 -0
  88. package/lib/typescript/@types/ThemedDict.d.ts +16 -0
  89. package/lib/typescript/@types/ThemedDict.d.ts.map +1 -0
  90. package/lib/typescript/@types/ThemedTypings.d.ts +9 -0
  91. package/lib/typescript/@types/ThemedTypings.d.ts.map +1 -0
  92. package/lib/typescript/@types/Token.d.ts +17 -0
  93. package/lib/typescript/@types/Token.d.ts.map +1 -0
  94. package/lib/typescript/hook/useSx.d.ts +307 -0
  95. package/lib/typescript/hook/useSx.d.ts.map +1 -0
  96. package/lib/typescript/hook/useSxStyle.d.ts +8 -0
  97. package/lib/typescript/hook/useSxStyle.d.ts.map +1 -0
  98. package/lib/typescript/hook/useSxTokens.d.ts +7 -0
  99. package/lib/typescript/hook/useSxTokens.d.ts.map +1 -0
  100. package/lib/typescript/index.d.ts +7 -0
  101. package/lib/typescript/index.d.ts.map +1 -0
  102. package/lib/typescript/internal/TokenParser/ColorsParser.d.ts +4 -0
  103. package/lib/typescript/internal/TokenParser/ColorsParser.d.ts.map +1 -0
  104. package/lib/typescript/internal/TokenParser/RadiiParser.d.ts +4 -0
  105. package/lib/typescript/internal/TokenParser/RadiiParser.d.ts.map +1 -0
  106. package/lib/typescript/internal/TokenParser/SizesParser.d.ts +4 -0
  107. package/lib/typescript/internal/TokenParser/SizesParser.d.ts.map +1 -0
  108. package/lib/typescript/internal/TokenParser/SpaceParser.d.ts +5 -0
  109. package/lib/typescript/internal/TokenParser/SpaceParser.d.ts.map +1 -0
  110. package/lib/typescript/internal/TokenParser/TokenParser.d.ts +10 -0
  111. package/lib/typescript/internal/TokenParser/TokenParser.d.ts.map +1 -0
  112. package/lib/typescript/internal/TokenParser/TypographyParser.d.ts +4 -0
  113. package/lib/typescript/internal/TokenParser/TypographyParser.d.ts.map +1 -0
  114. package/lib/typescript/internal/useStableCallback.d.ts +2 -0
  115. package/lib/typescript/internal/useStableCallback.d.ts.map +1 -0
  116. package/lib/typescript/internal/util/fillNullishThemeKey.d.ts +3 -0
  117. package/lib/typescript/internal/util/fillNullishThemeKey.d.ts.map +1 -0
  118. package/lib/typescript/internal/util/fillStyleIfNotNullish.d.ts +4 -0
  119. package/lib/typescript/internal/util/fillStyleIfNotNullish.d.ts.map +1 -0
  120. package/lib/typescript/internal/util/parsePxSuffixNumber.d.ts +2 -0
  121. package/lib/typescript/internal/util/parsePxSuffixNumber.d.ts.map +1 -0
  122. package/lib/typescript/internal/util/printWarning.d.ts +2 -0
  123. package/lib/typescript/internal/util/printWarning.d.ts.map +1 -0
  124. package/lib/typescript/provider/StyledSystemProvider.d.ts +13 -0
  125. package/lib/typescript/provider/StyledSystemProvider.d.ts.map +1 -0
  126. package/lib/typescript/util/propsToThemedStyle.d.ts +10 -0
  127. package/lib/typescript/util/propsToThemedStyle.d.ts.map +1 -0
  128. package/package.json +78 -0
  129. package/src/@types/SxProps.ts +255 -0
  130. package/src/@types/ThemedDict.ts +16 -0
  131. package/src/@types/ThemedTypings.ts +9 -0
  132. package/src/@types/Token.ts +21 -0
  133. package/src/hook/useSx.test.ts +348 -0
  134. package/src/hook/useSx.ts +94 -0
  135. package/src/hook/useSxStyle.test.ts +57 -0
  136. package/src/hook/useSxStyle.ts +32 -0
  137. package/src/hook/useSxTokens.test.ts +59 -0
  138. package/src/hook/useSxTokens.ts +42 -0
  139. package/src/index.ts +6 -0
  140. package/src/internal/TokenParser/ColorsParser.ts +18 -0
  141. package/src/internal/TokenParser/RadiiParser.ts +44 -0
  142. package/src/internal/TokenParser/SizesParser.ts +44 -0
  143. package/src/internal/TokenParser/SpaceParser.ts +95 -0
  144. package/src/internal/TokenParser/TokenParser.ts +18 -0
  145. package/src/internal/TokenParser/TypographyParser.ts +24 -0
  146. package/src/internal/useStableCallback.ts +29 -0
  147. package/src/internal/util/fillNullishThemeKey.ts +12 -0
  148. package/src/internal/util/fillStyleIfNotNullish.ts +26 -0
  149. package/src/internal/util/parsePxSuffixNumber.ts +10 -0
  150. package/src/internal/util/printWarning.ts +11 -0
  151. package/src/provider/StyledSystemProvider.tsx +23 -0
  152. package/src/util/propsToThemedStyle.ts +168 -0
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable max-len */
3
+ // region ZX Util
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ const filename = path.basename(__filename);
8
+ const _printTag = 'Theme Gen' || filename;
9
+
10
+ const { exec } = require('child_process');
11
+
12
+ function execa(command, ...args) {
13
+ return new Promise((resolve, reject) => {
14
+ const fullCommand = `${command} ${args.join(' ')}`;
15
+ exec(fullCommand, (error, stdout, stderr) => {
16
+ if (error) {
17
+ reject(error);
18
+ } else {
19
+ resolve(stdout.trim());
20
+ }
21
+ });
22
+ });
23
+ }
24
+
25
+ function exist(path) {
26
+ return fs.existsSync(path);
27
+ }
28
+
29
+ function read(path) {
30
+ return fs.readFileSync(path, { encoding: 'utf8' });
31
+ }
32
+
33
+ function write(p, content) {
34
+ const dir = path.dirname(p);
35
+ if (!exist(dir)) {
36
+ fs.mkdirSync(dir, { recursive: true });
37
+ }
38
+
39
+ return fs.writeFileSync(p, content);
40
+ }
41
+
42
+ function remove(path) {
43
+ if (!exist(path)) {
44
+ return;
45
+ }
46
+
47
+ if (fs.lstatSync(path).isDirectory()) {
48
+ return fs.rmSync(path, { force: true, recursive: true });
49
+ } else {
50
+ return fs.rmSync(path, { force: true });
51
+ }
52
+ }
53
+
54
+ function addLine(str, added, backward = false) {
55
+ if (backward) {
56
+ return added + '\n' + str;
57
+ } else {
58
+ return str + '\n' + added;
59
+ }
60
+ }
61
+
62
+ function print(...args) {
63
+ // eslint-disable-next-line no-console
64
+ console.log(`\x1B[35m[${_printTag}]`, ...args, '\x1B[0m');
65
+ }
66
+
67
+ function printSuccess(...args) {
68
+ // eslint-disable-next-line no-console
69
+ console.log(`\x1B[32m[${_printTag}]`, ...args);
70
+ }
71
+
72
+ function printError(...args) {
73
+ // eslint-disable-next-line no-console
74
+ console.log(`⚠️ [${_printTag}]`, ...args);
75
+ }
76
+
77
+ // endregion
78
+
79
+ const go = async () => {
80
+ const source = process.argv[2];
81
+ if (!source) {
82
+ printError('Source path is not passed');
83
+ process.exit(1);
84
+ }
85
+
86
+ print(`Generation Start, Source: ${source}`);
87
+
88
+ const tmpFile = '.tmpThemeGen.ts';
89
+ const outputFile =
90
+ process.argv[3] ||
91
+ './node_modules/@react-native-styled-system/core/lib/typescript/@types/ThemedTypings.d.ts';
92
+
93
+ try {
94
+ await execa(
95
+ 'npx',
96
+ '-y',
97
+ '@react-native-styled-system/cli',
98
+ 'generate',
99
+ '--out',
100
+ tmpFile,
101
+ source,
102
+ );
103
+
104
+ /**
105
+ * export interface ThemedTypings {
106
+ * @type {string}
107
+ */
108
+
109
+ let result = read(tmpFile);
110
+ result = result.replace(
111
+ /import.*/,
112
+ "import type { ColorsValue, RadiiValue, SizesValue, SpaceValue } from './Token';\n",
113
+ );
114
+ result = result.replace(/export.*/, 'export interface ThemedTypings {');
115
+ result = result.replace(/\/\/.*/g, '');
116
+ result = result.replace(/\|? ?\(?string & {}\)?;/g, '');
117
+ result = result.replaceAll('string & {}', '');
118
+
119
+ result = result.replace(
120
+ 'space:',
121
+ 'space: (SpaceValue & {}) | (`${number}` & {}) | (`${any}px` & {}) | ',
122
+ );
123
+
124
+ result = result.replace(
125
+ 'sizes:',
126
+ 'sizes: (SizesValue & {}) | (`${number}` & {}) | (`${any}px` & {}) | ',
127
+ );
128
+
129
+ result = result.replace(
130
+ 'radii:',
131
+ 'radii: (RadiiValue & {}) | (`${number}` & {}) | (`${any}px` & {}) | ',
132
+ );
133
+
134
+ result = result.replace('colors:', 'colors: (ColorsValue & {}) | ');
135
+ result = result.replace(/typography:\W*?\n/, 'typography: (string & {});');
136
+
137
+ result = result.replace(/\|[\s ]*\n/g, ';');
138
+
139
+ write(tmpFile, result);
140
+ fs.mkdirSync(path.dirname(outputFile), { recursive: true });
141
+ fs.renameSync(tmpFile, outputFile);
142
+ // await fixLint(outputFile);
143
+ printSuccess(`🎉 Theme Typing Generated in '${outputFile}'`);
144
+ } catch (e) {
145
+ printError(e);
146
+ remove(tmpFile);
147
+ }
148
+ };
149
+ go();
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports._viewStylePropList = exports._textStylePropList = void 0;
7
+ /**
8
+ * Always modify if you change API
9
+ */
10
+ const _viewStylePropList = exports._viewStylePropList = ['style', 'sx', 'backgroundColor', 'bg', 'borderColor', 'margin', 'm', 'marginTop', 'mt', 'marginRight', 'mr', 'marginBottom', 'mb', 'marginLeft', 'ml', 'marginX', 'mx', 'marginY', 'my', 'padding', 'p', 'paddingTop', 'pt', 'paddingRight', 'pr', 'paddingBottom', 'pb', 'paddingLeft', 'pl', 'paddingX', 'px', 'paddingY', 'py', 'top', 'right', 'bottom', 'left', 'gap', 'gapX', 'gapY', 'width', 'w', 'minW', 'minWidth', 'maxW', 'maxWidth', 'height', 'h', 'minH', 'minHeight', 'maxH', 'maxHeight', 'flex', 'alignItems', 'alignContent', 'justifyContent', 'flexWrap', 'flexDirection', 'flexGrow', 'flexShrink', 'flexBasis', 'alignSelf', 'position', 'pos', 'borderWidth', 'borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderRadius', 'radius', 'opacity', 'overflow', 'transform', 'aspectRatio', 'display', 'elevation', 'zIndex', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomLeftRadius', 'borderBottomRightRadius'];
11
+ const _textStylePropList = exports._textStylePropList = ['color', 'textDecorationColor', 'textShadowColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'weight', 'letterSpacing', 'lineHeight', 'textAlign', 'align', 'textDecorationLine', 'textDecorationStyle', 'textShadowOffset', 'textShadowRadius', 'textTransform', 'userSelect', 'includeFontPadding', 'typography', 't'];
12
+ //# sourceMappingURL=SxProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_viewStylePropList","exports","_textStylePropList"],"sourceRoot":"../../../src","sources":["@types/SxProps.ts"],"mappings":";;;;;;AAMA;AACA;AACA;AACO,MAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,CAChC,OAAO,EACP,IAAI,EACJ,iBAAiB,EACjB,IAAI,EACJ,aAAa,EACb,QAAQ,EACR,GAAG,EACH,WAAW,EACX,IAAI,EACJ,aAAa,EACb,IAAI,EACJ,cAAc,EACd,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,SAAS,EACT,GAAG,EACH,YAAY,EACZ,IAAI,EACJ,cAAc,EACd,IAAI,EACJ,eAAe,EACf,IAAI,EACJ,aAAa,EACb,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,GAAG,EACH,MAAM,EACN,UAAU,EACV,MAAM,EACN,UAAU,EACV,QAAQ,EACR,GAAG,EACH,MAAM,EACN,WAAW,EACX,MAAM,EACN,WAAW,EACX,MAAM,EACN,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,KAAK,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,SAAS,EACT,UAAU,EACV,WAAW,EACX,aAAa,EACb,SAAS,EACT,WAAW,EACX,QAAQ,EACR,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,CACU;AAC9B,MAAME,kBAAkB,GAAAD,OAAA,CAAAC,kBAAA,GAAG,CAChC,OAAO,EACP,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,WAAW,EACX,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,GAAG,CAC+D"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.emptyThemedDict = void 0;
7
+ const emptyThemedDict = exports.emptyThemedDict = {
8
+ space: {},
9
+ colors: {},
10
+ sizes: {},
11
+ radii: {},
12
+ typography: {}
13
+ };
14
+ //# sourceMappingURL=ThemedDict.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["emptyThemedDict","exports","space","colors","sizes","radii","typography"],"sourceRoot":"../../../src","sources":["@types/ThemedDict.ts"],"mappings":";;;;;;AASO,MAAMA,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG;EAC7BE,KAAK,EAAE,CAAC,CAAC;EACTC,MAAM,EAAE,CAAC,CAAC;EACVC,KAAK,EAAE,CAAC,CAAC;EACTC,KAAK,EAAE,CAAC,CAAC;EACTC,UAAU,EAAE,CAAC;AACf,CAAsB"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=ThemedTypings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["@types/ThemedTypings.ts"],"mappings":""}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=Token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["@types/Token.ts"],"mappings":""}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSx = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _jsUtil = require("@mj-studio/js-util");
10
+ var _SxProps = require("../@types/SxProps");
11
+ var _useStableCallback = require("../internal/useStableCallback");
12
+ var _printWarning = require("../internal/util/printWarning");
13
+ var _StyledSystemProvider = require("../provider/StyledSystemProvider");
14
+ var _propsToThemedStyle = require("../util/propsToThemedStyle");
15
+ const defaultUseSxOptions = {
16
+ styleType: 'ViewStyle'
17
+ };
18
+ const useSx = (props, {
19
+ theme: optionTheme,
20
+ styleType = defaultUseSxOptions.styleType,
21
+ transform = defaultUseSxOptions.transform,
22
+ fallback
23
+ } = defaultUseSxOptions) => {
24
+ const styledSystemContext = (0, _react.useContext)(_StyledSystemProvider.StyledSystemContext);
25
+ const getStyle = (0, _useStableCallback.useStableCallback)(() => {
26
+ const skip = !props && !fallback;
27
+ const theme = optionTheme ?? styledSystemContext?.theme;
28
+ if (skip) {
29
+ if (_jsUtil.is.function(transform)) {
30
+ return (0, _propsToThemedStyle.propsToThemedStyle)({
31
+ theme,
32
+ sx: transform({})
33
+ });
34
+ } else {
35
+ return;
36
+ }
37
+ }
38
+ if (!theme) {
39
+ (0, _printWarning.printWarning)('theme not found from useSx, undefined will be returned.');
40
+ return;
41
+ }
42
+
43
+ // caution: priority should be ordered correctly.
44
+ const mergedSx = {
45
+ ...fallback,
46
+ ...props,
47
+ ...props?.sx
48
+ };
49
+ const mergedSxStyle = (0, _propsToThemedStyle.propsToThemedStyle)({
50
+ theme,
51
+ sx: mergedSx,
52
+ styleType
53
+ });
54
+ const composedStyle = !mergedSxStyle ? props?.style : props?.style ? _reactNative.StyleSheet.compose(mergedSxStyle, props.style) : mergedSxStyle;
55
+ if (_jsUtil.is.function(transform)) {
56
+ const transformedSx = transform(_reactNative.StyleSheet.flatten(composedStyle));
57
+ return _reactNative.StyleSheet.compose(composedStyle, (0, _propsToThemedStyle.propsToThemedStyle)({
58
+ theme,
59
+ sx: transformedSx,
60
+ styleType
61
+ }));
62
+ } else {
63
+ return composedStyle;
64
+ }
65
+ });
66
+ const filteredProps = (0, _react.useMemo)(() => {
67
+ const ret = {
68
+ ...props
69
+ };
70
+ _SxProps._viewStylePropList.forEach(keyName => delete ret[keyName]);
71
+ if (styleType === 'TextStyle') {
72
+ _SxProps._textStylePropList.forEach(keyName => delete ret[keyName]);
73
+ }
74
+ return ret;
75
+ }, [props, styleType]);
76
+ return {
77
+ getStyle,
78
+ filteredProps
79
+ };
80
+ };
81
+ exports.useSx = useSx;
82
+ //# sourceMappingURL=useSx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_jsUtil","_SxProps","_useStableCallback","_printWarning","_StyledSystemProvider","_propsToThemedStyle","defaultUseSxOptions","styleType","useSx","props","theme","optionTheme","transform","fallback","styledSystemContext","useContext","StyledSystemContext","getStyle","useStableCallback","skip","is","function","propsToThemedStyle","sx","printWarning","mergedSx","mergedSxStyle","composedStyle","style","StyleSheet","compose","transformedSx","flatten","filteredProps","useMemo","ret","_viewStylePropList","forEach","keyName","_textStylePropList","exports"],"sourceRoot":"../../../src","sources":["hook/useSx.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAGA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AAEA,IAAAO,mBAAA,GAAAP,OAAA;AAYA,MAAMQ,mBAAiC,GAAG;EAAEC,SAAS,EAAE;AAAY,CAAC;AAC7D,MAAMC,KAAK,GAAGA,CACnBC,KAAgB,EAChB;EACEC,KAAK,EAAEC,WAAW;EAClBJ,SAAS,GAAGD,mBAAmB,CAACC,SAAS;EACzCK,SAAS,GAAGN,mBAAmB,CAACM,SAAS;EACzCC;AACY,CAAC,GAAGP,mBAAmB,KAClC;EACH,MAAMQ,mBAAmB,GAAG,IAAAC,iBAAU,EAACC,yCAAmB,CAAC;EAE3D,MAAMC,QAAQ,GAAG,IAAAC,oCAAiB,EAAC,MAAgC;IACjE,MAAMC,IAAI,GAAG,CAACV,KAAK,IAAI,CAACI,QAAQ;IAChC,MAAMH,KAAK,GAAGC,WAAW,IAAIG,mBAAmB,EAAEJ,KAAK;IAEvD,IAAIS,IAAI,EAAE;MACR,IAAIC,UAAE,CAACC,QAAQ,CAACT,SAAS,CAAC,EAAE;QAC1B,OAAO,IAAAU,sCAAkB,EAAC;UAAEZ,KAAK;UAAEa,EAAE,EAAEX,SAAS,CAAC,CAAC,CAAC;QAAE,CAAC,CAAC;MACzD,CAAC,MAAM;QACL;MACF;IACF;IAEA,IAAI,CAACF,KAAK,EAAE;MACV,IAAAc,0BAAY,EAAC,yDAAyD,CAAC;MAEvE;IACF;;IAEA;IACA,MAAMC,QAAqB,GAAG;MAAE,GAAGZ,QAAQ;MAAE,GAAGJ,KAAK;MAAE,GAAGA,KAAK,EAAEc;IAAG,CAAC;IAErE,MAAMG,aAAa,GAAG,IAAAJ,sCAAkB,EAAC;MACvCZ,KAAK;MACLa,EAAE,EAAEE,QAAQ;MACZlB;IACF,CAAC,CAAC;IAEF,MAAMoB,aAAa,GAAG,CAACD,aAAa,GAChCjB,KAAK,EAAEmB,KAAK,GACZnB,KAAK,EAAEmB,KAAK,GACVC,uBAAU,CAACC,OAAO,CAACJ,aAAa,EAAEjB,KAAK,CAACmB,KAAK,CAAC,GAC9CF,aAAa;IAEnB,IAAIN,UAAE,CAACC,QAAQ,CAACT,SAAS,CAAC,EAAE;MAC1B,MAAMmB,aAAa,GAAGnB,SAAS,CAACiB,uBAAU,CAACG,OAAO,CAACL,aAAa,CAAC,CAAC;MAElE,OAAOE,uBAAU,CAACC,OAAO,CACvBH,aAAa,EACb,IAAAL,sCAAkB,EAAC;QAAEZ,KAAK;QAAEa,EAAE,EAAEQ,aAAa;QAAExB;MAAU,CAAC,CAC5D,CAAC;IACH,CAAC,MAAM;MACL,OAAOoB,aAAa;IACtB;EACF,CAAC,CAAC;EAEF,MAAMM,aAA6C,GAAG,IAAAC,cAAO,EAAC,MAAM;IAClE,MAAMC,GAAG,GAAG;MAAE,GAAG1B;IAAM,CAAmC;IAE1D2B,2BAAkB,CAACC,OAAO,CAAEC,OAAO,IAAK,OAAOH,GAAG,CAACG,OAAO,CAAC,CAAC;IAC5D,IAAI/B,SAAS,KAAK,WAAW,EAAE;MAC7BgC,2BAAkB,CAACF,OAAO,CAAEC,OAAO,IAAK,OAAOH,GAAG,CAACG,OAAO,CAAC,CAAC;IAC9D;IAEA,OAAOH,GAAG;EACZ,CAAC,EAAE,CAAC1B,KAAK,EAAEF,SAAS,CAAC,CAAC;EAEtB,OAAO;IAAEU,QAAQ;IAAEgB;EAAc,CAAC;AACpC,CAAC;AAACO,OAAA,CAAAhC,KAAA,GAAAA,KAAA"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSxStyle = void 0;
7
+ var _react = require("react");
8
+ var _printWarning = require("../internal/util/printWarning");
9
+ var _StyledSystemProvider = require("../provider/StyledSystemProvider");
10
+ var _propsToThemedStyle = require("../util/propsToThemedStyle");
11
+ const defaultOptions = {};
12
+ const useSxStyle = ({
13
+ theme: optionTheme
14
+ } = defaultOptions) => {
15
+ const styledSystemContext = (0, _react.useContext)(_StyledSystemProvider.StyledSystemContext);
16
+ return sx => {
17
+ const theme = optionTheme ?? styledSystemContext?.theme;
18
+ if (!theme) {
19
+ (0, _printWarning.printWarning)('theme not found from useSxStyle, empty style will be returned.');
20
+ return {};
21
+ }
22
+ return (0, _propsToThemedStyle.propsToThemedStyle)({
23
+ theme,
24
+ sx
25
+ });
26
+ };
27
+ };
28
+ exports.useSxStyle = useSxStyle;
29
+ //# sourceMappingURL=useSxStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_printWarning","_StyledSystemProvider","_propsToThemedStyle","defaultOptions","useSxStyle","theme","optionTheme","styledSystemContext","useContext","StyledSystemContext","sx","printWarning","propsToThemedStyle","exports"],"sourceRoot":"../../../src","sources":["hook/useSxStyle.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAKA,MAAMI,cAAiC,GAAG,CAAC,CAAC;AAErC,MAAMC,UAAU,GAAGA,CAAC;EAAEC,KAAK,EAAEC;AAA+B,CAAC,GAAGH,cAAc,KAAK;EACxF,MAAMI,mBAAmB,GAAG,IAAAC,iBAAU,EAACC,yCAAmB,CAAC;EAE3D,OAAQC,EAAe,IAA2B;IAChD,MAAML,KAAK,GAAGC,WAAW,IAAIC,mBAAmB,EAAEF,KAAK;IAEvD,IAAI,CAACA,KAAK,EAAE;MACV,IAAAM,0BAAY,EAAC,gEAAgE,CAAC;MAE9E,OAAO,CAAC,CAAC;IACX;IAEA,OAAO,IAAAC,sCAAkB,EAAC;MACxBP,KAAK;MACLK;IACF,CAAC,CAAC;EACJ,CAAC;AACH,CAAC;AAACG,OAAA,CAAAT,UAAA,GAAAA,UAAA"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSxTokens = void 0;
7
+ var _react = require("react");
8
+ var _jsUtil = require("@mj-studio/js-util");
9
+ var _printWarning = require("../internal/util/printWarning");
10
+ var _StyledSystemProvider = require("../provider/StyledSystemProvider");
11
+ const useSxTokens = (tokenType, tokenValues, {
12
+ theme: optionTheme
13
+ } = {}) => {
14
+ const styledSystemContext = (0, _react.useContext)(_StyledSystemProvider.StyledSystemContext);
15
+ const theme = optionTheme ?? styledSystemContext?.theme;
16
+ if (!theme) {
17
+ (0, _printWarning.printWarning)('theme not found from useSxTokens, undefineds will be returned.');
18
+ return (0, _jsUtil.generateArray)(tokenValues.length).map(() => undefined);
19
+ }
20
+ const ret = [];
21
+ for (let i = 0; i < tokenValues.length; i++) {
22
+ const tokenValue = tokenValues[i];
23
+ if (!(tokenValue in theme[tokenType])) {
24
+ (0, _printWarning.printWarning)(`tokenValue ${String(tokenValue)} at index ${i} doesn't exist in tokenType ${tokenType} from useSxTokens, undefined will be returned.`);
25
+ ret.push(undefined);
26
+ } else {
27
+ ret.push(theme[tokenType][tokenValue]);
28
+ }
29
+ }
30
+ return ret;
31
+ };
32
+ exports.useSxTokens = useSxTokens;
33
+ //# sourceMappingURL=useSxTokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_jsUtil","_printWarning","_StyledSystemProvider","useSxTokens","tokenType","tokenValues","theme","optionTheme","styledSystemContext","useContext","StyledSystemContext","printWarning","generateArray","length","map","undefined","ret","i","tokenValue","String","push","exports"],"sourceRoot":"../../../src","sources":["hook/useSxTokens.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAIA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;AAKO,MAAMI,WAAW,GAAGA,CACzBC,SAAY,EACZC,WAAgD,EAChD;EAAEC,KAAK,EAAEC;AAAgC,CAAC,GAAG,CAAC,CAAC,KACD;EAC9C,MAAMC,mBAAmB,GAAG,IAAAC,iBAAU,EAACC,yCAAmB,CAAC;EAE3D,MAAMJ,KAAK,GAAGC,WAAW,IAAIC,mBAAmB,EAAEF,KAAK;EAEvD,IAAI,CAACA,KAAK,EAAE;IACV,IAAAK,0BAAY,EAAC,gEAAgE,CAAC;IAE9E,OAAO,IAAAC,qBAAa,EAACP,WAAW,CAACQ,MAAM,CAAC,CAACC,GAAG,CAAC,MAAMC,SAAS,CAAC;EAC/D;EAEA,MAAMC,GAA8C,GAAG,EAAE;EAEzD,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGZ,WAAW,CAACQ,MAAM,EAAEI,CAAC,EAAE,EAAE;IAC3C,MAAMC,UAAU,GAAGb,WAAW,CAACY,CAAC,CAAC;IACjC,IAAI,EAAEC,UAAU,IAAIZ,KAAK,CAACF,SAAS,CAAC,CAAC,EAAE;MACrC,IAAAO,0BAAY,EACT,cAAaQ,MAAM,CAACD,UAAU,CAAE,aAAYD,CAAE,+BAA8Bb,SAAU,gDACzF,CAAC;MACDY,GAAG,CAACI,IAAI,CAACL,SAAgB,CAAC;IAC5B,CAAC,MAAM;MACLC,GAAG,CAACI,IAAI,CAACd,KAAK,CAACF,SAAS,CAAC,CAACc,UAAU,CAAC,CAAC;IACxC;EACF;EAEA,OAAOF,GAAG;AACZ,CAAC;AAACK,OAAA,CAAAlB,WAAA,GAAAA,WAAA"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _StyledSystemProvider = require("./provider/StyledSystemProvider");
7
+ Object.keys(_StyledSystemProvider).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _StyledSystemProvider[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _StyledSystemProvider[key];
14
+ }
15
+ });
16
+ });
17
+ var _useSx = require("./hook/useSx");
18
+ Object.keys(_useSx).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _useSx[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _useSx[key];
25
+ }
26
+ });
27
+ });
28
+ var _ThemedDict = require("./@types/ThemedDict");
29
+ Object.keys(_ThemedDict).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _ThemedDict[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _ThemedDict[key];
36
+ }
37
+ });
38
+ });
39
+ var _SxProps = require("./@types/SxProps");
40
+ Object.keys(_SxProps).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _SxProps[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _SxProps[key];
47
+ }
48
+ });
49
+ });
50
+ var _ThemedTypings = require("./@types/ThemedTypings");
51
+ Object.keys(_ThemedTypings).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _ThemedTypings[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _ThemedTypings[key];
58
+ }
59
+ });
60
+ });
61
+ var _propsToThemedStyle = require("./util/propsToThemedStyle");
62
+ Object.keys(_propsToThemedStyle).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _propsToThemedStyle[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _propsToThemedStyle[key];
69
+ }
70
+ });
71
+ });
72
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_StyledSystemProvider","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_useSx","_ThemedDict","_SxProps","_ThemedTypings","_propsToThemedStyle"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,qBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,qBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,qBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,WAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,WAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,WAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,WAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,QAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,QAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,QAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,QAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,cAAA,GAAAZ,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAU,cAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,cAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,cAAA,CAAAR,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,mBAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,mBAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAS,mBAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAK,mBAAA,CAAAT,GAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createColorsParser = void 0;
7
+ const createColorsParser = theme => {
8
+ return token => parseColors(theme, token);
9
+ };
10
+ exports.createColorsParser = createColorsParser;
11
+ const parseColors = (theme, token) => {
12
+ if (!token) {
13
+ return;
14
+ }
15
+ if (token in theme.colors) {
16
+ return theme.colors[token];
17
+ } else {
18
+ return token;
19
+ }
20
+ };
21
+ //# sourceMappingURL=ColorsParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createColorsParser","theme","token","parseColors","exports","colors"],"sourceRoot":"../../../../src","sources":["internal/TokenParser/ColorsParser.ts"],"mappings":";;;;;;AAGO,MAAMA,kBAAkB,GAAIC,KAAiB,IAAK;EACvD,OAAQC,KAAuB,IAAKC,WAAW,CAACF,KAAK,EAAEC,KAAK,CAAC;AAC/D,CAAC;AAACE,OAAA,CAAAJ,kBAAA,GAAAA,kBAAA;AAEF,MAAMG,WAAW,GAAGA,CAACF,KAAiB,EAAEC,KAAuB,KAA8B;EAC3F,IAAI,CAACA,KAAK,EAAE;IACV;EACF;EAEA,IAAIA,KAAK,IAAID,KAAK,CAACI,MAAM,EAAE;IACzB,OAAOJ,KAAK,CAACI,MAAM,CAACH,KAAK,CAAC;EAC5B,CAAC,MAAM;IACL,OAAOA,KAAK;EACd;AACF,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createRadiiParser = void 0;
7
+ var _jsUtil = require("@mj-studio/js-util");
8
+ var _parsePxSuffixNumber = require("../util/parsePxSuffixNumber");
9
+ const createRadiiParser = theme => {
10
+ return token => parseRadii(theme, token);
11
+ };
12
+ exports.createRadiiParser = createRadiiParser;
13
+ const parseRadii = (theme, token) => {
14
+ if (_jsUtil.is.nullOrUndefined(token)) {
15
+ return;
16
+ }
17
+ const px = (0, _parsePxSuffixNumber.parsePxSuffixNumber)(token);
18
+ if (_jsUtil.is.number(px)) {
19
+ return px;
20
+ }
21
+
22
+ // end with px but not number parsed
23
+ if (_jsUtil.is.string(token) && token.endsWith('px')) {
24
+ return;
25
+ }
26
+ const radii = theme.radii;
27
+ if ((_jsUtil.is.string(token) || _jsUtil.is.number(token)) && token in radii) {
28
+ return radii[token];
29
+ }
30
+ if (_jsUtil.is.number(token)) {
31
+ const stringKey = `${token}`;
32
+ if (stringKey in radii) {
33
+ return radii[stringKey];
34
+ }
35
+ }
36
+ if (_jsUtil.is.numberString(token)) {
37
+ return Number(token);
38
+ }
39
+ return token;
40
+ };
41
+ //# sourceMappingURL=RadiiParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_jsUtil","require","_parsePxSuffixNumber","createRadiiParser","theme","token","parseRadii","exports","is","nullOrUndefined","px","parsePxSuffixNumber","number","string","endsWith","radii","stringKey","numberString","Number"],"sourceRoot":"../../../../src","sources":["internal/TokenParser/RadiiParser.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,oBAAA,GAAAD,OAAA;AAEO,MAAME,iBAAiB,GAAIC,KAAiB,IAAK;EACtD,OAAQC,KAAsB,IAAKC,UAAU,CAACF,KAAK,EAAEC,KAAK,CAAC;AAC7D,CAAC;AAACE,OAAA,CAAAJ,iBAAA,GAAAA,iBAAA;AAEF,MAAMG,UAAU,GAAGA,CAACF,KAAiB,EAAEC,KAAsB,KAA6B;EACxF,IAAIG,UAAE,CAACC,eAAe,CAACJ,KAAK,CAAC,EAAE;IAC7B;EACF;EAEA,MAAMK,EAAE,GAAG,IAAAC,wCAAmB,EAACN,KAAK,CAAC;EACrC,IAAIG,UAAE,CAACI,MAAM,CAACF,EAAE,CAAC,EAAE;IACjB,OAAOA,EAAE;EACX;;EAEA;EACA,IAAIF,UAAE,CAACK,MAAM,CAACR,KAAK,CAAC,IAAIA,KAAK,CAACS,QAAQ,CAAC,IAAI,CAAC,EAAE;IAC5C;EACF;EAEA,MAAMC,KAAK,GAAGX,KAAK,CAACW,KAAK;EAEzB,IAAI,CAACP,UAAE,CAACK,MAAM,CAACR,KAAK,CAAC,IAAIG,UAAE,CAACI,MAAM,CAACP,KAAK,CAAC,KAAKA,KAAK,IAAIU,KAAK,EAAE;IAC5D,OAAOA,KAAK,CAACV,KAAK,CAAC;EACrB;EAEA,IAAIG,UAAE,CAACI,MAAM,CAACP,KAAK,CAAC,EAAE;IACpB,MAAMW,SAAS,GAAI,GAAEX,KAAM,EAAC;IAC5B,IAAIW,SAAS,IAAID,KAAK,EAAE;MACtB,OAAOA,KAAK,CAACC,SAAS,CAAC;IACzB;EACF;EAEA,IAAIR,UAAE,CAACS,YAAY,CAACZ,KAAK,CAAC,EAAE;IAC1B,OAAOa,MAAM,CAACb,KAAK,CAAC;EACtB;EAEA,OAAOA,KAAK;AACd,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createSizesParser = void 0;
7
+ var _jsUtil = require("@mj-studio/js-util");
8
+ var _parsePxSuffixNumber = require("../util/parsePxSuffixNumber");
9
+ const createSizesParser = theme => {
10
+ return token => parseSizes(theme, token);
11
+ };
12
+ exports.createSizesParser = createSizesParser;
13
+ const parseSizes = (theme, token) => {
14
+ if (_jsUtil.is.nullOrUndefined(token)) {
15
+ return;
16
+ }
17
+ const px = (0, _parsePxSuffixNumber.parsePxSuffixNumber)(token);
18
+ if (_jsUtil.is.number(px)) {
19
+ return px;
20
+ }
21
+
22
+ // end with px but not number parsed
23
+ if (_jsUtil.is.string(token) && token.endsWith('px')) {
24
+ return;
25
+ }
26
+ const sizes = theme.sizes;
27
+ if ((_jsUtil.is.string(token) || _jsUtil.is.number(token)) && token in sizes) {
28
+ return sizes[token];
29
+ }
30
+ if (_jsUtil.is.number(token)) {
31
+ const stringKey = `${token}`;
32
+ if (stringKey in sizes) {
33
+ return sizes[stringKey];
34
+ }
35
+ }
36
+ if (_jsUtil.is.numberString(token)) {
37
+ return Number(token);
38
+ }
39
+ return token;
40
+ };
41
+ //# sourceMappingURL=SizesParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_jsUtil","require","_parsePxSuffixNumber","createSizesParser","theme","token","parseSizes","exports","is","nullOrUndefined","px","parsePxSuffixNumber","number","string","endsWith","sizes","stringKey","numberString","Number"],"sourceRoot":"../../../../src","sources":["internal/TokenParser/SizesParser.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,oBAAA,GAAAD,OAAA;AAEO,MAAME,iBAAiB,GAAIC,KAAiB,IAAK;EACtD,OAAQC,KAAsB,IAAKC,UAAU,CAACF,KAAK,EAAEC,KAAK,CAAC;AAC7D,CAAC;AAACE,OAAA,CAAAJ,iBAAA,GAAAA,iBAAA;AAEF,MAAMG,UAAU,GAAGA,CAACF,KAAiB,EAAEC,KAAsB,KAA6B;EACxF,IAAIG,UAAE,CAACC,eAAe,CAACJ,KAAK,CAAC,EAAE;IAC7B;EACF;EAEA,MAAMK,EAAE,GAAG,IAAAC,wCAAmB,EAACN,KAAK,CAAC;EACrC,IAAIG,UAAE,CAACI,MAAM,CAACF,EAAE,CAAC,EAAE;IACjB,OAAOA,EAAE;EACX;;EAEA;EACA,IAAIF,UAAE,CAACK,MAAM,CAACR,KAAK,CAAC,IAAIA,KAAK,CAACS,QAAQ,CAAC,IAAI,CAAC,EAAE;IAC5C;EACF;EAEA,MAAMC,KAAK,GAAGX,KAAK,CAACW,KAAK;EAEzB,IAAI,CAACP,UAAE,CAACK,MAAM,CAACR,KAAK,CAAC,IAAIG,UAAE,CAACI,MAAM,CAACP,KAAK,CAAC,KAAKA,KAAK,IAAIU,KAAK,EAAE;IAC5D,OAAOA,KAAK,CAACV,KAAK,CAAC;EACrB;EAEA,IAAIG,UAAE,CAACI,MAAM,CAACP,KAAK,CAAC,EAAE;IACpB,MAAMW,SAAS,GAAI,GAAEX,KAAM,EAAC;IAC5B,IAAIW,SAAS,IAAID,KAAK,EAAE;MACtB,OAAOA,KAAK,CAACC,SAAS,CAAC;IACzB;EACF;EAEA,IAAIR,UAAE,CAACS,YAAY,CAACZ,KAAK,CAAC,EAAE;IAC1B,OAAOa,MAAM,CAACb,KAAK,CAAC;EACtB;EAEA,OAAOA,KAAK;AACd,CAAC"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createSpaceParser = exports.createSpaceAsNumberOnlyParser = void 0;
7
+ var _jsUtil = require("@mj-studio/js-util");
8
+ var _parsePxSuffixNumber = require("../util/parsePxSuffixNumber");
9
+ const createSpaceParser = theme => {
10
+ return token => parseSpace(theme, token);
11
+ };
12
+ exports.createSpaceParser = createSpaceParser;
13
+ const createSpaceAsNumberOnlyParser = theme => {
14
+ return token => parseSpaceAsNumberOnly(theme, token);
15
+ };
16
+
17
+ /**
18
+ * Space should be handle negative string like '-1' as well
19
+ */
20
+ exports.createSpaceAsNumberOnlyParser = createSpaceAsNumberOnlyParser;
21
+ const parseSpace = (theme, token) => {
22
+ if (_jsUtil.is.nullOrUndefined(token)) {
23
+ return;
24
+ }
25
+ const px = (0, _parsePxSuffixNumber.parsePxSuffixNumber)(token);
26
+ if (_jsUtil.is.number(px)) {
27
+ return px;
28
+ }
29
+
30
+ // end with px but not number parsed
31
+ if (_jsUtil.is.string(token) && token.endsWith('px')) {
32
+ return;
33
+ }
34
+ const spaces = theme.space;
35
+ if ((_jsUtil.is.string(token) || _jsUtil.is.number(token)) && token in spaces) {
36
+ return spaces[token];
37
+ }
38
+
39
+ // Parse is number
40
+ if (_jsUtil.is.number(token)) {
41
+ const stringKey = `${token}`;
42
+ if (stringKey in spaces) {
43
+ return spaces[stringKey];
44
+ }
45
+ const negativeNumberKey = -token;
46
+ if (negativeNumberKey in spaces) {
47
+ const value = spaces[negativeNumberKey];
48
+ if (_jsUtil.is.number(value)) {
49
+ return -value;
50
+ }
51
+ }
52
+ const negativeStringKey = stringKey.charAt(0) === '-' ? stringKey.substring(1) : `-${stringKey}`;
53
+ if (negativeStringKey in spaces) {
54
+ const value = spaces[negativeStringKey];
55
+ if (_jsUtil.is.number(value)) {
56
+ return -value;
57
+ }
58
+ }
59
+ }
60
+
61
+ // Parse prefix minus token string
62
+ if (_jsUtil.is.string(token) && token.startsWith('-')) {
63
+ const originalToken = token.substring(1);
64
+ if (originalToken in spaces) {
65
+ const value = spaces[originalToken];
66
+ if (_jsUtil.is.number(value)) {
67
+ return -value;
68
+ }
69
+ // not invert sign percent string yet(will be supported).
70
+ }
71
+
72
+ // don't return malformed string. It is not acceptable as SpaceValue
73
+ return;
74
+ }
75
+ if (_jsUtil.is.numberString(token)) {
76
+ return Number(token);
77
+ }
78
+ return token;
79
+ };
80
+
81
+ /**
82
+ * Parse space and filter if it is number for number only prop like gap
83
+ */
84
+ const parseSpaceAsNumberOnly = (theme, token) => {
85
+ const ret = parseSpace(theme, token);
86
+ if (_jsUtil.is.number(ret)) {
87
+ return ret;
88
+ }
89
+ };
90
+ //# sourceMappingURL=SpaceParser.js.map