@antdv-next/cssinjs 0.0.3 → 1.0.0-alpha.2

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 (212) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -141
  3. package/dist/Cache.d.ts +22 -0
  4. package/dist/Cache.js +45 -0
  5. package/dist/Keyframes.d.ts +12 -0
  6. package/dist/Keyframes.js +17 -0
  7. package/dist/StyleContext.d.ts +119 -0
  8. package/dist/StyleContext.js +67 -0
  9. package/dist/cssinjs-utils/_util/hooks/useUniqueMemo.js +62 -0
  10. package/dist/cssinjs-utils/hooks/useCSP.d.ts +8 -0
  11. package/dist/cssinjs-utils/hooks/useCSP.js +8 -0
  12. package/dist/cssinjs-utils/hooks/usePrefix.d.ts +9 -0
  13. package/dist/cssinjs-utils/hooks/useToken.d.ts +25 -0
  14. package/dist/cssinjs-utils/index.d.ts +4 -0
  15. package/dist/cssinjs-utils/index.js +4 -0
  16. package/dist/cssinjs-utils/interface/components.d.ts +12 -0
  17. package/dist/cssinjs-utils/util/genStyleUtils.d.ts +127 -0
  18. package/dist/cssinjs-utils/util/genStyleUtils.js +188 -0
  19. package/dist/cssinjs-utils/util/getCompVarPrefix.js +8 -0
  20. package/dist/cssinjs-utils/util/getComponentToken.js +22 -0
  21. package/dist/cssinjs-utils/util/getDefaultComponentToken.js +11 -0
  22. package/dist/cssinjs-utils/util/maxmin.js +17 -0
  23. package/dist/cssinjs-utils/util/statistic.d.ts +15 -0
  24. package/dist/cssinjs-utils/util/statistic.js +52 -0
  25. package/dist/extractStyle.d.ts +18 -0
  26. package/dist/extractStyle.js +54 -0
  27. package/dist/hooks/useCSSVarRegister.d.ts +19 -0
  28. package/dist/hooks/useCSSVarRegister.js +86 -0
  29. package/dist/hooks/useCacheToken.d.ts +60 -0
  30. package/dist/hooks/useCacheToken.js +133 -0
  31. package/dist/hooks/useGlobalCache.d.ts +9 -0
  32. package/dist/hooks/useGlobalCache.js +68 -0
  33. package/dist/hooks/useStyleRegister.d.ts +47 -0
  34. package/dist/hooks/useStyleRegister.js +237 -0
  35. package/dist/index.d.ts +35 -0
  36. package/dist/index.js +30 -0
  37. package/dist/linters/NaNLinter.d.ts +6 -0
  38. package/dist/linters/NaNLinter.js +10 -0
  39. package/dist/linters/contentQuotesLinter.js +18 -0
  40. package/dist/linters/hashedAnimationLinter.js +12 -0
  41. package/dist/linters/index.d.ts +5 -0
  42. package/dist/linters/index.js +8 -0
  43. package/dist/linters/interface.d.ts +11 -0
  44. package/dist/linters/legacyNotSelectorLinter.d.ts +6 -0
  45. package/dist/linters/legacyNotSelectorLinter.js +20 -0
  46. package/dist/linters/logicalPropertiesLinter.d.ts +6 -0
  47. package/dist/linters/logicalPropertiesLinter.js +57 -0
  48. package/dist/linters/parentSelectorLinter.d.ts +7 -0
  49. package/dist/linters/parentSelectorLinter.js +12 -0
  50. package/dist/linters/utils.js +10 -0
  51. package/dist/ssr/styleCollector.d.ts +8 -0
  52. package/dist/ssr/styleCollector.js +11 -0
  53. package/dist/theme/Theme.d.ts +16 -0
  54. package/dist/theme/Theme.js +24 -0
  55. package/dist/theme/ThemeCache.js +79 -0
  56. package/dist/theme/calc/CSSCalculator.d.ts +19 -0
  57. package/dist/theme/calc/CSSCalculator.js +63 -0
  58. package/dist/theme/calc/NumCalculator.d.ts +14 -0
  59. package/dist/theme/calc/NumCalculator.js +37 -0
  60. package/dist/theme/calc/calculator.d.ts +32 -0
  61. package/dist/theme/calc/calculator.js +6 -0
  62. package/dist/theme/calc/index.d.ts +8 -0
  63. package/dist/theme/calc/index.js +12 -0
  64. package/dist/theme/createTheme.d.ts +11 -0
  65. package/dist/theme/createTheme.js +16 -0
  66. package/dist/theme/index.js +6 -0
  67. package/dist/theme/interface.d.ts +5 -0
  68. package/dist/transformers/autoPrefix.d.ts +6 -0
  69. package/dist/transformers/autoPrefix.js +7 -0
  70. package/dist/transformers/interface.d.ts +9 -0
  71. package/{es → dist}/transformers/legacyLogicalProperties.d.ts +6 -2
  72. package/dist/transformers/legacyLogicalProperties.js +123 -0
  73. package/dist/transformers/px2rem.d.ts +23 -0
  74. package/dist/transformers/px2rem.js +37 -0
  75. package/dist/util/cacheMapUtil.js +60 -0
  76. package/dist/util/css-variables.d.ts +7 -0
  77. package/dist/util/css-variables.js +35 -0
  78. package/dist/util/index.d.ts +8 -0
  79. package/dist/util/index.js +108 -0
  80. package/package.json +33 -64
  81. package/dist/cssinjs.umd.js +0 -3
  82. package/es/Cache.d.ts +0 -20
  83. package/es/Cache.js +0 -33
  84. package/es/Keyframes.d.ts +0 -9
  85. package/es/Keyframes.js +0 -14
  86. package/es/StyleContext.d.ts +0 -40
  87. package/es/StyleContext.js +0 -100
  88. package/es/extractStyle.d.ts +0 -12
  89. package/es/extractStyle.js +0 -43
  90. package/es/hooks/useCSSVarRegister.d.ts +0 -21
  91. package/es/hooks/useCSSVarRegister.js +0 -59
  92. package/es/hooks/useCacheToken.d.ts +0 -69
  93. package/es/hooks/useCacheToken.js +0 -106
  94. package/es/hooks/useEffectCleanupRegister.d.ts +0 -2
  95. package/es/hooks/useEffectCleanupRegister.js +0 -8
  96. package/es/hooks/useGlobalCache.d.ts +0 -7
  97. package/es/hooks/useGlobalCache.js +0 -41
  98. package/es/hooks/useHMR.d.ts +0 -3
  99. package/es/hooks/useHMR.js +0 -20
  100. package/es/hooks/useStyleRegister.d.ts +0 -81
  101. package/es/hooks/useStyleRegister.js +0 -216
  102. package/es/index.d.ts +0 -18
  103. package/es/index.js +0 -44
  104. package/es/interface.d.ts +0 -2
  105. package/es/linters/NaNLinter.d.ts +0 -3
  106. package/es/linters/NaNLinter.js +0 -7
  107. package/es/linters/contentQuotesLinter.d.ts +0 -3
  108. package/es/linters/contentQuotesLinter.js +0 -13
  109. package/es/linters/hashedAnimationLinter.d.ts +0 -3
  110. package/es/linters/hashedAnimationLinter.js +0 -10
  111. package/es/linters/index.d.ts +0 -7
  112. package/es/linters/interface.d.ts +0 -8
  113. package/es/linters/legacyNotSelectorLinter.d.ts +0 -3
  114. package/es/linters/legacyNotSelectorLinter.js +0 -14
  115. package/es/linters/logicalPropertiesLinter.d.ts +0 -3
  116. package/es/linters/logicalPropertiesLinter.js +0 -61
  117. package/es/linters/parentSelectorLinter.d.ts +0 -3
  118. package/es/linters/parentSelectorLinter.js +0 -7
  119. package/es/linters/utils.d.ts +0 -2
  120. package/es/linters/utils.js +0 -11
  121. package/es/theme/Theme.d.ts +0 -11
  122. package/es/theme/Theme.js +0 -21
  123. package/es/theme/ThemeCache.d.ts +0 -20
  124. package/es/theme/ThemeCache.js +0 -74
  125. package/es/theme/calc/CSSCalculator.d.ts +0 -15
  126. package/es/theme/calc/CSSCalculator.js +0 -40
  127. package/es/theme/calc/NumCalculator.d.ts +0 -10
  128. package/es/theme/calc/NumCalculator.js +0 -25
  129. package/es/theme/calc/calculator.d.ts +0 -30
  130. package/es/theme/calc/calculator.js +0 -5
  131. package/es/theme/calc/index.d.ts +0 -5
  132. package/es/theme/calc/index.js +0 -9
  133. package/es/theme/createTheme.d.ts +0 -6
  134. package/es/theme/createTheme.js +0 -10
  135. package/es/theme/index.d.ts +0 -6
  136. package/es/theme/interface.d.ts +0 -2
  137. package/es/transformers/interface.d.ts +0 -4
  138. package/es/transformers/legacyLogicalProperties.js +0 -108
  139. package/es/transformers/px2rem.d.ts +0 -20
  140. package/es/transformers/px2rem.js +0 -32
  141. package/es/util/cacheMapUtil.d.ts +0 -14
  142. package/es/util/cacheMapUtil.js +0 -48
  143. package/es/util/css-variables.d.ts +0 -20
  144. package/es/util/css-variables.js +0 -22
  145. package/es/util/index.d.ts +0 -15
  146. package/es/util/index.js +0 -85
  147. package/lib/Cache.d.ts +0 -20
  148. package/lib/Cache.js +0 -1
  149. package/lib/Keyframes.d.ts +0 -9
  150. package/lib/Keyframes.js +0 -1
  151. package/lib/StyleContext.d.ts +0 -40
  152. package/lib/StyleContext.js +0 -1
  153. package/lib/extractStyle.d.ts +0 -12
  154. package/lib/extractStyle.js +0 -1
  155. package/lib/hooks/useCSSVarRegister.d.ts +0 -21
  156. package/lib/hooks/useCSSVarRegister.js +0 -1
  157. package/lib/hooks/useCacheToken.d.ts +0 -69
  158. package/lib/hooks/useCacheToken.js +0 -1
  159. package/lib/hooks/useEffectCleanupRegister.d.ts +0 -2
  160. package/lib/hooks/useEffectCleanupRegister.js +0 -1
  161. package/lib/hooks/useGlobalCache.d.ts +0 -7
  162. package/lib/hooks/useGlobalCache.js +0 -1
  163. package/lib/hooks/useHMR.d.ts +0 -3
  164. package/lib/hooks/useHMR.js +0 -1
  165. package/lib/hooks/useStyleRegister.d.ts +0 -81
  166. package/lib/hooks/useStyleRegister.js +0 -3
  167. package/lib/index.d.ts +0 -18
  168. package/lib/index.js +0 -1
  169. package/lib/interface.d.ts +0 -2
  170. package/lib/linters/NaNLinter.d.ts +0 -3
  171. package/lib/linters/NaNLinter.js +0 -1
  172. package/lib/linters/contentQuotesLinter.d.ts +0 -3
  173. package/lib/linters/contentQuotesLinter.js +0 -1
  174. package/lib/linters/hashedAnimationLinter.d.ts +0 -3
  175. package/lib/linters/hashedAnimationLinter.js +0 -1
  176. package/lib/linters/index.d.ts +0 -7
  177. package/lib/linters/interface.d.ts +0 -8
  178. package/lib/linters/legacyNotSelectorLinter.d.ts +0 -3
  179. package/lib/linters/legacyNotSelectorLinter.js +0 -1
  180. package/lib/linters/logicalPropertiesLinter.d.ts +0 -3
  181. package/lib/linters/logicalPropertiesLinter.js +0 -1
  182. package/lib/linters/parentSelectorLinter.d.ts +0 -3
  183. package/lib/linters/parentSelectorLinter.js +0 -1
  184. package/lib/linters/utils.d.ts +0 -2
  185. package/lib/linters/utils.js +0 -1
  186. package/lib/theme/Theme.d.ts +0 -11
  187. package/lib/theme/Theme.js +0 -1
  188. package/lib/theme/ThemeCache.d.ts +0 -20
  189. package/lib/theme/ThemeCache.js +0 -1
  190. package/lib/theme/calc/CSSCalculator.d.ts +0 -15
  191. package/lib/theme/calc/CSSCalculator.js +0 -1
  192. package/lib/theme/calc/NumCalculator.d.ts +0 -10
  193. package/lib/theme/calc/NumCalculator.js +0 -1
  194. package/lib/theme/calc/calculator.d.ts +0 -30
  195. package/lib/theme/calc/calculator.js +0 -1
  196. package/lib/theme/calc/index.d.ts +0 -5
  197. package/lib/theme/calc/index.js +0 -1
  198. package/lib/theme/createTheme.d.ts +0 -6
  199. package/lib/theme/createTheme.js +0 -1
  200. package/lib/theme/index.d.ts +0 -6
  201. package/lib/theme/interface.d.ts +0 -2
  202. package/lib/transformers/interface.d.ts +0 -4
  203. package/lib/transformers/legacyLogicalProperties.d.ts +0 -12
  204. package/lib/transformers/legacyLogicalProperties.js +0 -1
  205. package/lib/transformers/px2rem.d.ts +0 -20
  206. package/lib/transformers/px2rem.js +0 -1
  207. package/lib/util/cacheMapUtil.d.ts +0 -14
  208. package/lib/util/cacheMapUtil.js +0 -1
  209. package/lib/util/css-variables.d.ts +0 -20
  210. package/lib/util/css-variables.js +0 -1
  211. package/lib/util/index.d.ts +0 -15
  212. package/lib/util/index.js +0 -1
@@ -1,74 +0,0 @@
1
- function u(c, e) {
2
- if (c.length !== e.length)
3
- return !1;
4
- for (let s = 0; s < c.length; s++)
5
- if (c[s] !== e[s])
6
- return !1;
7
- return !0;
8
- }
9
- class n {
10
- static MAX_CACHE_SIZE = 20;
11
- static MAX_CACHE_OFFSET = 5;
12
- cache;
13
- keys;
14
- cacheCallTimes;
15
- constructor() {
16
- this.cache = /* @__PURE__ */ new Map(), this.keys = [], this.cacheCallTimes = 0;
17
- }
18
- size() {
19
- return this.keys.length;
20
- }
21
- internalGet(e, s = !1) {
22
- let t = { map: this.cache };
23
- return e.forEach((a) => {
24
- t ? t = t?.map?.get(a) : t = void 0;
25
- }), t?.value && s && (t.value[1] = this.cacheCallTimes++), t?.value;
26
- }
27
- get(e) {
28
- return this.internalGet(e, !0)?.[0];
29
- }
30
- has(e) {
31
- return !!this.internalGet(e);
32
- }
33
- set(e, s) {
34
- if (!this.has(e)) {
35
- if (this.size() + 1 > n.MAX_CACHE_SIZE + n.MAX_CACHE_OFFSET) {
36
- const [a] = this.keys.reduce(
37
- (h, l) => {
38
- const [, i] = h;
39
- return this.internalGet(l)[1] < i ? [l, this.internalGet(l)[1]] : h;
40
- },
41
- [this.keys[0], this.cacheCallTimes]
42
- );
43
- this.delete(a);
44
- }
45
- this.keys.push(e);
46
- }
47
- let t = this.cache;
48
- e.forEach((a, h) => {
49
- if (h === e.length - 1)
50
- t.set(a, { value: [s, this.cacheCallTimes++] });
51
- else {
52
- const l = t.get(a);
53
- l ? l.map || (l.map = /* @__PURE__ */ new Map()) : t.set(a, { map: /* @__PURE__ */ new Map() }), t = t.get(a).map;
54
- }
55
- });
56
- }
57
- deleteByPath(e, s) {
58
- const t = e.get(s[0]);
59
- if (s.length === 1)
60
- return t.map ? e.set(s[0], { map: t.map }) : e.delete(s[0]), t.value?.[0];
61
- const a = this.deleteByPath(t.map, s.slice(1));
62
- return (!t.map || t.map.size === 0) && !t.value && e.delete(s[0]), a;
63
- }
64
- delete(e) {
65
- if (this.has(e))
66
- return this.keys = this.keys.filter(
67
- (s) => !u(s, e)
68
- ), this.deleteByPath(this.cache, e);
69
- }
70
- }
71
- export {
72
- n as default,
73
- u as sameDerivativeOption
74
- };
@@ -1,15 +0,0 @@
1
- import { default as AbstractCalculator } from './calculator';
2
- export default class CSSCalculator extends AbstractCalculator {
3
- result: string;
4
- unitlessCssVar: Set<string>;
5
- lowPriority?: boolean;
6
- constructor(num: number | string | AbstractCalculator, unitlessCssVar: Set<string>);
7
- add(num: number | string | AbstractCalculator): this;
8
- sub(num: number | string | AbstractCalculator): this;
9
- mul(num: number | string | AbstractCalculator): this;
10
- div(num: number | string | AbstractCalculator): this;
11
- getResult(force?: boolean): string;
12
- equal(options?: {
13
- unit?: boolean;
14
- }): string;
15
- }
@@ -1,40 +0,0 @@
1
- import h from "./calculator.js";
2
- const u = "CALC_UNIT", f = new RegExp(u, "g");
3
- function l(r) {
4
- return typeof r == "number" ? `${r}${u}` : r;
5
- }
6
- class e extends h {
7
- result = "";
8
- unitlessCssVar;
9
- lowPriority;
10
- constructor(t, i) {
11
- super();
12
- const s = typeof t;
13
- this.unitlessCssVar = i, t instanceof e ? this.result = `(${t.result})` : s === "number" ? this.result = l(t) : s === "string" && (this.result = t);
14
- }
15
- add(t) {
16
- return t instanceof e ? this.result = `${this.result} + ${t.getResult()}` : (typeof t == "number" || typeof t == "string") && (this.result = `${this.result} + ${l(t)}`), this.lowPriority = !0, this;
17
- }
18
- sub(t) {
19
- return t instanceof e ? this.result = `${this.result} - ${t.getResult()}` : (typeof t == "number" || typeof t == "string") && (this.result = `${this.result} - ${l(t)}`), this.lowPriority = !0, this;
20
- }
21
- mul(t) {
22
- return this.lowPriority && (this.result = `(${this.result})`), t instanceof e ? this.result = `${this.result} * ${t.getResult(!0)}` : (typeof t == "number" || typeof t == "string") && (this.result = `${this.result} * ${t}`), this.lowPriority = !1, this;
23
- }
24
- div(t) {
25
- return this.lowPriority && (this.result = `(${this.result})`), t instanceof e ? this.result = `${this.result} / ${t.getResult(!0)}` : (typeof t == "number" || typeof t == "string") && (this.result = `${this.result} / ${t}`), this.lowPriority = !1, this;
26
- }
27
- getResult(t) {
28
- return this.lowPriority || t ? `(${this.result})` : this.result;
29
- }
30
- equal(t) {
31
- const { unit: i } = t || {};
32
- let s = !0;
33
- return typeof i == "boolean" ? s = i : Array.from(this.unitlessCssVar).some(
34
- (o) => this.result.includes(o)
35
- ) && (s = !1), this.result = this.result.replace(f, s ? "px" : ""), typeof this.lowPriority < "u" ? `calc(${this.result})` : this.result;
36
- }
37
- }
38
- export {
39
- e as default
40
- };
@@ -1,10 +0,0 @@
1
- import { default as AbstractCalculator } from './calculator';
2
- export default class NumCalculator extends AbstractCalculator {
3
- result: number;
4
- constructor(num: number | string | AbstractCalculator);
5
- add(num: number | string | AbstractCalculator): this;
6
- sub(num: number | string | AbstractCalculator): this;
7
- mul(num: number | string | AbstractCalculator): this;
8
- div(num: number | string | AbstractCalculator): this;
9
- equal(): number;
10
- }
@@ -1,25 +0,0 @@
1
- import s from "./calculator.js";
2
- class t extends s {
3
- result = 0;
4
- constructor(e) {
5
- super(), e instanceof t ? this.result = e.result : typeof e == "number" && (this.result = e);
6
- }
7
- add(e) {
8
- return e instanceof t ? this.result += e.result : typeof e == "number" && (this.result += e), this;
9
- }
10
- sub(e) {
11
- return e instanceof t ? this.result -= e.result : typeof e == "number" && (this.result -= e), this;
12
- }
13
- mul(e) {
14
- return e instanceof t ? this.result *= e.result : typeof e == "number" && (this.result *= e), this;
15
- }
16
- div(e) {
17
- return e instanceof t ? this.result /= e.result : typeof e == "number" && (this.result /= e), this;
18
- }
19
- equal() {
20
- return this.result;
21
- }
22
- }
23
- export {
24
- t as default
25
- };
@@ -1,30 +0,0 @@
1
- declare abstract class AbstractCalculator {
2
- /**
3
- * @descCN 计算两数的和,例如:1 + 2
4
- * @descEN Calculate the sum of two numbers, e.g. 1 + 2
5
- */
6
- abstract add(num: number | string | AbstractCalculator): this;
7
- /**
8
- * @descCN 计算两数的差,例如:1 - 2
9
- * @descEN Calculate the difference between two numbers, e.g. 1 - 2
10
- */
11
- abstract sub(num: number | string | AbstractCalculator): this;
12
- /**
13
- * @descCN 计算两数的积,例如:1 * 2
14
- * @descEN Calculate the product of two numbers, e.g. 1 * 2
15
- */
16
- abstract mul(num: number | string | AbstractCalculator): this;
17
- /**
18
- * @descCN 计算两数的商,例如:1 / 2
19
- * @descEN Calculate the quotient of two numbers, e.g. 1 / 2
20
- */
21
- abstract div(num: number | string | AbstractCalculator): this;
22
- /**
23
- * @descCN 获取计算结果
24
- * @descEN Get the calculation result
25
- */
26
- abstract equal(options?: {
27
- unit?: boolean;
28
- }): string | number;
29
- }
30
- export default AbstractCalculator;
@@ -1,5 +0,0 @@
1
- class t {
2
- }
3
- export {
4
- t as default
5
- };
@@ -1,5 +0,0 @@
1
- import { default as AbstractCalculator } from './calculator';
2
- import { default as CSSCalculator } from './CSSCalculator';
3
- import { default as NumCalculator } from './NumCalculator';
4
- declare function genCalc(type: 'css' | 'js', unitlessCssVar: Set<string>): (num: number | string | AbstractCalculator) => CSSCalculator | NumCalculator;
5
- export default genCalc;
@@ -1,9 +0,0 @@
1
- import l from "./CSSCalculator.js";
2
- import c from "./NumCalculator.js";
3
- function e(o, r) {
4
- const t = o === "css" ? l : c;
5
- return (a) => new t(a, r);
6
- }
7
- export {
8
- e as default
9
- };
@@ -1,6 +0,0 @@
1
- import { DerivativeFunc, TokenType } from './interface';
2
- import { default as Theme } from './Theme';
3
- /**
4
- * Same as new Theme, but will always return same one if `derivative` not changed.
5
- */
6
- export default function createTheme<DesignToken extends TokenType, DerivativeToken extends TokenType>(derivatives: DerivativeFunc<DesignToken, DerivativeToken>[] | DerivativeFunc<DesignToken, DerivativeToken>): Theme<any, any>;
@@ -1,10 +0,0 @@
1
- import m from "./Theme.js";
2
- import o from "./ThemeCache.js";
3
- const t = new o();
4
- function h(r) {
5
- const e = Array.isArray(r) ? r : [r];
6
- return t.has(e) || t.set(e, new m(e)), t.get(e);
7
- }
8
- export {
9
- h as default
10
- };
@@ -1,6 +0,0 @@
1
- export { default as genCalc } from './calc';
2
- export type { default as AbstractCalculator } from './calc/calculator';
3
- export { default as createTheme } from './createTheme';
4
- export type { DerivativeFunc, TokenType } from './interface';
5
- export { default as Theme } from './Theme';
6
- export { default as ThemeCache } from './ThemeCache';
@@ -1,2 +0,0 @@
1
- export type TokenType = object;
2
- export type DerivativeFunc<DesignToken extends TokenType, DerivativeToken extends TokenType> = (designToken: DesignToken, derivativeToken?: DerivativeToken) => DerivativeToken;
@@ -1,4 +0,0 @@
1
- import { CSSObject } from '..';
2
- export interface Transformer {
3
- visit?: (cssObj: CSSObject) => CSSObject;
4
- }
@@ -1,108 +0,0 @@
1
- function c(e) {
2
- if (typeof e == "number")
3
- return [[e], !1];
4
- const t = String(e).trim(), o = t.match(/(.*)(!important)/), i = (o ? o[1] : t).trim().split(/\s+/);
5
- let r = [], d = 0;
6
- return [
7
- i.reduce((l, n) => {
8
- if (n.includes("(") || n.includes(")")) {
9
- const a = n.split("(").length - 1, g = n.split(")").length - 1;
10
- d += a - g;
11
- }
12
- return d >= 0 && r.push(n), d === 0 && (l.push(r.join(" ")), r = []), l;
13
- }, []),
14
- !!o
15
- ];
16
- }
17
- function b(e) {
18
- return e.notSplit = !0, e;
19
- }
20
- const s = {
21
- // Inset
22
- inset: ["top", "right", "bottom", "left"],
23
- insetBlock: ["top", "bottom"],
24
- insetBlockStart: ["top"],
25
- insetBlockEnd: ["bottom"],
26
- insetInline: ["left", "right"],
27
- insetInlineStart: ["left"],
28
- insetInlineEnd: ["right"],
29
- // Margin
30
- marginBlock: ["marginTop", "marginBottom"],
31
- marginBlockStart: ["marginTop"],
32
- marginBlockEnd: ["marginBottom"],
33
- marginInline: ["marginLeft", "marginRight"],
34
- marginInlineStart: ["marginLeft"],
35
- marginInlineEnd: ["marginRight"],
36
- // Padding
37
- paddingBlock: ["paddingTop", "paddingBottom"],
38
- paddingBlockStart: ["paddingTop"],
39
- paddingBlockEnd: ["paddingBottom"],
40
- paddingInline: ["paddingLeft", "paddingRight"],
41
- paddingInlineStart: ["paddingLeft"],
42
- paddingInlineEnd: ["paddingRight"],
43
- // Border
44
- borderBlock: b(["borderTop", "borderBottom"]),
45
- borderBlockStart: b(["borderTop"]),
46
- borderBlockEnd: b(["borderBottom"]),
47
- borderInline: b(["borderLeft", "borderRight"]),
48
- borderInlineStart: b(["borderLeft"]),
49
- borderInlineEnd: b(["borderRight"]),
50
- // Border width
51
- borderBlockWidth: ["borderTopWidth", "borderBottomWidth"],
52
- borderBlockStartWidth: ["borderTopWidth"],
53
- borderBlockEndWidth: ["borderBottomWidth"],
54
- borderInlineWidth: ["borderLeftWidth", "borderRightWidth"],
55
- borderInlineStartWidth: ["borderLeftWidth"],
56
- borderInlineEndWidth: ["borderRightWidth"],
57
- // Border style
58
- borderBlockStyle: ["borderTopStyle", "borderBottomStyle"],
59
- borderBlockStartStyle: ["borderTopStyle"],
60
- borderBlockEndStyle: ["borderBottomStyle"],
61
- borderInlineStyle: ["borderLeftStyle", "borderRightStyle"],
62
- borderInlineStartStyle: ["borderLeftStyle"],
63
- borderInlineEndStyle: ["borderRightStyle"],
64
- // Border color
65
- borderBlockColor: ["borderTopColor", "borderBottomColor"],
66
- borderBlockStartColor: ["borderTopColor"],
67
- borderBlockEndColor: ["borderBottomColor"],
68
- borderInlineColor: ["borderLeftColor", "borderRightColor"],
69
- borderInlineStartColor: ["borderLeftColor"],
70
- borderInlineEndColor: ["borderRightColor"],
71
- // Border radius
72
- borderStartStartRadius: ["borderTopLeftRadius"],
73
- borderStartEndRadius: ["borderTopRightRadius"],
74
- borderEndStartRadius: ["borderBottomLeftRadius"],
75
- borderEndEndRadius: ["borderBottomRightRadius"]
76
- };
77
- function p(e, t) {
78
- let o = e;
79
- return t && (o = `${o} !important`), { _skip_check_: !0, value: o };
80
- }
81
- const h = {
82
- visit: (e) => {
83
- const t = {};
84
- return Object.keys(e).forEach((o) => {
85
- const i = e[o], r = s[o];
86
- if (r && (typeof i == "number" || typeof i == "string")) {
87
- const [d, l] = c(i);
88
- r.length && r.notSplit ? r.forEach((n) => {
89
- t[n] = p(i, l);
90
- }) : r.length === 1 ? t[r[0]] = p(d[0], l) : r.length === 2 ? r.forEach((n, a) => {
91
- t[n] = p(
92
- d[a] ?? d[0],
93
- l
94
- );
95
- }) : r.length === 4 ? r.forEach((n, a) => {
96
- t[n] = p(
97
- d[a] ?? d[a - 2] ?? d[0],
98
- l
99
- );
100
- }) : t[o] = i;
101
- } else
102
- t[o] = i;
103
- }), t;
104
- }
105
- };
106
- export {
107
- h as default
108
- };
@@ -1,20 +0,0 @@
1
- import { Transformer } from './interface';
2
- interface Options {
3
- /**
4
- * The root font size.
5
- * @default 16
6
- */
7
- rootValue?: number;
8
- /**
9
- * The decimal numbers to allow the REM units to grow to.
10
- * @default 5
11
- */
12
- precision?: number;
13
- /**
14
- * Whether to allow px to be converted in media queries.
15
- * @default false
16
- */
17
- mediaQuery?: boolean;
18
- }
19
- declare function transform(options?: Options): Transformer;
20
- export default transform;
@@ -1,32 +0,0 @@
1
- import a from "@emotion/unitless";
2
- const l = /url\([^)]+\)|var\([^)]+\)|(\d+(?:\.\d+)?|\.\d+)px/g;
3
- function d(i, s) {
4
- const o = 10 ** (s + 1), c = Math.floor(i * o);
5
- return Math.round(c / 10) * 10 / o;
6
- }
7
- function h(i = {}) {
8
- const { rootValue: s = 16, precision: o = 5, mediaQuery: c = !1 } = i, p = (n, e) => {
9
- if (!e)
10
- return n;
11
- const t = Number.parseFloat(e);
12
- return t <= 1 ? n : `${d(t / s, o)}rem`;
13
- };
14
- return { visit: (n) => {
15
- const e = { ...n };
16
- return Object.entries(n).forEach(([t, r]) => {
17
- if (typeof r == "string" && r.includes("px")) {
18
- const f = r.replace(l, p);
19
- e[t] = f;
20
- }
21
- !a[t] && typeof r == "number" && r !== 0 && (e[t] = `${r}px`.replace(l, p));
22
- const u = t.trim();
23
- if (u.startsWith("@") && u.includes("px") && c) {
24
- const f = t.replace(l, p);
25
- e[f] = e[t], delete e[t];
26
- }
27
- }), e;
28
- } };
29
- }
30
- export {
31
- h as default
32
- };
@@ -1,14 +0,0 @@
1
- export declare const ATTR_CACHE_MAP = "data-ant-cssinjs-cache-path";
2
- /**
3
- * This marks style from the css file.
4
- * Which means not exist in `<style />` tag.
5
- */
6
- export declare const CSS_FILE_STYLE = "_FILE_STYLE__";
7
- export declare function serialize(cachePathMap: Record<string, string>): string;
8
- /**
9
- * @private
10
- */
11
- export declare function reset(mockCache?: Record<string, string>, fromFile?: boolean): void;
12
- export declare function prepare(): void;
13
- export declare function existPath(path: string): boolean;
14
- export declare function getStyleAndHash(path: string): [style: string | null, hash: string];
@@ -1,48 +0,0 @@
1
- import s from "@v-c/util/dist/Dom/canUseDom";
2
- import { ATTR_MARK as d } from "../StyleContext.js";
3
- const l = "data-ant-cssinjs-cache-path", u = "_FILE_STYLE__";
4
- function y(e) {
5
- return Object.keys(e).map((t) => {
6
- const n = e[t];
7
- return `${t}:${n}`;
8
- }).join(";");
9
- }
10
- let o, c = !0;
11
- function m() {
12
- if (!o && (o = {}, s())) {
13
- const e = document.createElement("div");
14
- e.className = l, e.style.position = "fixed", e.style.visibility = "hidden", e.style.top = "-9999px", document.body.appendChild(e);
15
- let t = getComputedStyle(e).content || "";
16
- t = t.replace(/^"/, "").replace(/"$/, ""), t.split(";").forEach((i) => {
17
- const [r, a] = i.split(":");
18
- o[r] = a;
19
- });
20
- const n = document.querySelector(`style[${l}]`);
21
- n && (c = !1, n.parentNode?.removeChild(n)), document.body.removeChild(e);
22
- }
23
- }
24
- function h(e) {
25
- return m(), !!o[e];
26
- }
27
- function S(e) {
28
- const t = o[e];
29
- let n = null;
30
- if (t && s())
31
- if (c)
32
- n = u;
33
- else {
34
- const i = document.querySelector(
35
- `style[${d}="${o[e]}"]`
36
- );
37
- i ? n = i.innerHTML : delete o[e];
38
- }
39
- return [n, t];
40
- }
41
- export {
42
- l as ATTR_CACHE_MAP,
43
- u as CSS_FILE_STYLE,
44
- h as existPath,
45
- S as getStyleAndHash,
46
- m as prepare,
47
- y as serialize
48
- };
@@ -1,20 +0,0 @@
1
- export declare function token2CSSVar(token: string, prefix?: string): string;
2
- export declare function serializeCSSVar<T extends Record<string, any>>(cssVars: T, hashId: string, options?: {
3
- scope?: string;
4
- }): string;
5
- export type TokenWithCSSVar<V, T extends Record<string, V> = Record<string, V>> = {
6
- [key in keyof T]?: string | V;
7
- };
8
- export declare function transformToken<V, T extends Record<string, V> = Record<string, V>>(token: T, themeKey: string, config?: {
9
- prefix?: string;
10
- ignore?: {
11
- [key in keyof T]?: boolean;
12
- };
13
- unitless?: {
14
- [key in keyof T]?: boolean;
15
- };
16
- preserve?: {
17
- [key in keyof T]?: boolean;
18
- };
19
- scope?: string;
20
- }): [TokenWithCSSVar<V, T>, string];
@@ -1,22 +0,0 @@
1
- function p(r, t = "") {
2
- return `--${t ? `${t}-` : ""}${r}`.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, "$1-$2").replace(/([a-z])([A-Z0-9])/g, "$1-$2").toLowerCase();
3
- }
4
- function a(r, t, e) {
5
- return Object.keys(r).length ? `.${t}${e?.scope ? `.${e.scope}` : ""}{${Object.entries(r).map(([o, $]) => `${o}:${$};`).join("")}}` : "";
6
- }
7
- function i(r, t, e) {
8
- const o = {}, $ = {};
9
- return Object.entries(r).forEach(([n, s]) => {
10
- if (e?.preserve?.[n])
11
- $[n] = s;
12
- else if ((typeof s == "string" || typeof s == "number") && !e?.ignore?.[n]) {
13
- const c = p(n, e?.prefix);
14
- o[c] = typeof s == "number" && !e?.unitless?.[n] ? `${s}px` : String(s), $[n] = `var(${c})`;
15
- }
16
- }), [$, a(o, t, { scope: e?.scope })];
17
- }
18
- export {
19
- a as serializeCSSVar,
20
- p as token2CSSVar,
21
- i as transformToken
22
- };
@@ -1,15 +0,0 @@
1
- export declare function memoResult<T extends object, R>(callback: () => R, deps: T[]): R;
2
- /**
3
- * Flatten token to string, this will auto cache the result when token not change
4
- */
5
- export declare function flattenToken(token: any, hashed?: boolean): string;
6
- /**
7
- * Convert derivative token to key string
8
- */
9
- export declare function token2key(token: any, salt: string): string;
10
- export declare function supportLayer(): boolean;
11
- export declare function supportWhere(): boolean;
12
- export declare function supportLogicProps(): boolean;
13
- export declare const isClientSide: boolean;
14
- export declare function unit(num: string | number): string;
15
- export declare function toStyleStr(style: string, tokenKey?: string, styleId?: string, customizeAttrs?: Record<string, string>, plain?: boolean): string;
package/es/util/index.js DELETED
@@ -1,85 +0,0 @@
1
- import m from "@emotion/hash";
2
- import d from "@v-c/util/dist/Dom/canUseDom";
3
- import { updateCSS as $, removeCSS as T } from "@v-c/util/dist/Dom/dynamicCSS";
4
- import { ATTR_MARK as g, ATTR_TOKEN as C } from "../StyleContext.js";
5
- import b from "../theme/Theme.js";
6
- const v = /* @__PURE__ */ new WeakMap(), c = {};
7
- function w(e, r) {
8
- let t = v;
9
- for (let n = 0; n < r.length; n += 1) {
10
- const o = r[n];
11
- t.has(o) || t.set(o, /* @__PURE__ */ new WeakMap()), t = t.get(o);
12
- }
13
- return t.has(c) || t.set(c, e()), t.get(c);
14
- }
15
- const p = /* @__PURE__ */ new WeakMap();
16
- function y(e, r = !1) {
17
- let t = p.get(e) || "";
18
- return t || (Object.keys(e).forEach((n) => {
19
- const o = e[n];
20
- t += n, o instanceof b ? t += o.id : o && typeof o == "object" ? t += y(o, r) : t += o;
21
- }), r && (t = m(t)), p.set(e, t)), t;
22
- }
23
- function A(e, r) {
24
- return m(`${r}_${y(e, !0)}`);
25
- }
26
- const i = `random-${Date.now()}-${Math.random()}`.replace(
27
- /\./g,
28
- ""
29
- ), S = "_bAmBoO_";
30
- function h(e, r, t) {
31
- if (d()) {
32
- $(e, i);
33
- const n = document.createElement("div");
34
- n.style.position = "fixed", n.style.left = "0", n.style.top = "0", r?.(n), document.body.appendChild(n), process.env.NODE_ENV !== "production" && (n.innerHTML = "Test", n.style.zIndex = "9999999");
35
- const o = t ? t(n) : getComputedStyle(n).content?.includes(S);
36
- return n.parentNode?.removeChild(n), T(i), o;
37
- }
38
- return !1;
39
- }
40
- let a;
41
- function L() {
42
- return a === void 0 && (a = h(
43
- `:where(.${i}) { content: "${S}"!important; }`,
44
- (e) => {
45
- e.className = i;
46
- }
47
- )), a;
48
- }
49
- let l;
50
- function O() {
51
- return l === void 0 && (l = h(
52
- `.${i} { inset-block: 93px !important; }`,
53
- (e) => {
54
- e.className = i;
55
- },
56
- (e) => getComputedStyle(e).bottom === "93px"
57
- )), l;
58
- }
59
- const R = d();
60
- function W(e) {
61
- return typeof e == "number" ? `${e}px` : e;
62
- }
63
- function j(e, r, t, n = {}, o = !1) {
64
- if (o)
65
- return e;
66
- const f = {
67
- ...n,
68
- [C]: r,
69
- [g]: t
70
- };
71
- return `<style ${Object.keys(f).map((s) => {
72
- const u = f[s];
73
- return u ? `${s}="${u}"` : null;
74
- }).filter((s) => s).join(" ")}>${e}</style>`;
75
- }
76
- export {
77
- y as flattenToken,
78
- R as isClientSide,
79
- w as memoResult,
80
- O as supportLogicProps,
81
- L as supportWhere,
82
- j as toStyleStr,
83
- A as token2key,
84
- W as unit
85
- };
package/lib/Cache.d.ts DELETED
@@ -1,20 +0,0 @@
1
- export type KeyType = string | number;
2
- type ValueType = [number, any];
3
- /** Connect key with `SPLIT` */
4
- export declare function pathKey(keys: KeyType[]): string;
5
- declare class Entity {
6
- instanceId: string;
7
- constructor(instanceId: string);
8
- /**
9
- * @private
10
- * Internal cache map. Do not access this directly
11
- */
12
- cache: Map<string, ValueType>;
13
- get(keys: KeyType[]): ValueType | null;
14
- /** A fast get cache with `get` concat. */
15
- opGet(keyPathStr: string): ValueType | null;
16
- update(keys: KeyType[], valueFn: (origin: ValueType | null) => ValueType | null): void;
17
- /** A fast get cache with `get` concat. */
18
- opUpdate(keyPathStr: string, valueFn: (origin: ValueType | null) => ValueType | null): void;
19
- }
20
- export default Entity;
package/lib/Cache.js DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u="%";function n(c){return c.join(u)}class i{instanceId;constructor(e){this.instanceId=e}cache=new Map;get(e){return this.opGet(n(e))}opGet(e){return this.cache.get(e)||null}update(e,t){return this.opUpdate(n(e),t)}opUpdate(e,t){const a=this.cache.get(e),s=t(a);s===null?this.cache.delete(e):this.cache.set(e,s)}}exports.default=i;exports.pathKey=n;
@@ -1,9 +0,0 @@
1
- import { CSSInterpolation } from './hooks/useStyleRegister';
2
- declare class Keyframe {
3
- private readonly name;
4
- style: CSSInterpolation;
5
- constructor(name: string, style: CSSInterpolation);
6
- getName(hashId?: string): string;
7
- _keyframe: boolean;
8
- }
9
- export default Keyframe;