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

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 (210) 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 +118 -0
  8. package/dist/StyleContext.js +64 -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 +74 -0
  29. package/dist/hooks/useCacheToken.d.ts +60 -0
  30. package/dist/hooks/useCacheToken.js +120 -0
  31. package/dist/hooks/useGlobalCache.d.ts +9 -0
  32. package/dist/hooks/useGlobalCache.js +70 -0
  33. package/dist/hooks/useStyleRegister.d.ts +47 -0
  34. package/dist/hooks/useStyleRegister.js +237 -0
  35. package/dist/index.d.ts +34 -0
  36. package/dist/index.js +29 -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/theme/Theme.d.ts +16 -0
  52. package/dist/theme/Theme.js +24 -0
  53. package/dist/theme/ThemeCache.js +79 -0
  54. package/dist/theme/calc/CSSCalculator.d.ts +19 -0
  55. package/dist/theme/calc/CSSCalculator.js +63 -0
  56. package/dist/theme/calc/NumCalculator.d.ts +14 -0
  57. package/dist/theme/calc/NumCalculator.js +37 -0
  58. package/dist/theme/calc/calculator.d.ts +32 -0
  59. package/dist/theme/calc/calculator.js +6 -0
  60. package/dist/theme/calc/index.d.ts +8 -0
  61. package/dist/theme/calc/index.js +12 -0
  62. package/dist/theme/createTheme.d.ts +11 -0
  63. package/dist/theme/createTheme.js +16 -0
  64. package/dist/theme/index.js +6 -0
  65. package/dist/theme/interface.d.ts +5 -0
  66. package/dist/transformers/autoPrefix.d.ts +6 -0
  67. package/dist/transformers/autoPrefix.js +7 -0
  68. package/dist/transformers/interface.d.ts +9 -0
  69. package/{es → dist}/transformers/legacyLogicalProperties.d.ts +6 -2
  70. package/dist/transformers/legacyLogicalProperties.js +123 -0
  71. package/dist/transformers/px2rem.d.ts +23 -0
  72. package/dist/transformers/px2rem.js +37 -0
  73. package/dist/util/cacheMapUtil.js +60 -0
  74. package/dist/util/css-variables.d.ts +7 -0
  75. package/dist/util/css-variables.js +35 -0
  76. package/dist/util/index.d.ts +8 -0
  77. package/dist/util/index.js +108 -0
  78. package/package.json +33 -64
  79. package/dist/cssinjs.umd.js +0 -3
  80. package/es/Cache.d.ts +0 -20
  81. package/es/Cache.js +0 -33
  82. package/es/Keyframes.d.ts +0 -9
  83. package/es/Keyframes.js +0 -14
  84. package/es/StyleContext.d.ts +0 -40
  85. package/es/StyleContext.js +0 -100
  86. package/es/extractStyle.d.ts +0 -12
  87. package/es/extractStyle.js +0 -43
  88. package/es/hooks/useCSSVarRegister.d.ts +0 -21
  89. package/es/hooks/useCSSVarRegister.js +0 -59
  90. package/es/hooks/useCacheToken.d.ts +0 -69
  91. package/es/hooks/useCacheToken.js +0 -106
  92. package/es/hooks/useEffectCleanupRegister.d.ts +0 -2
  93. package/es/hooks/useEffectCleanupRegister.js +0 -8
  94. package/es/hooks/useGlobalCache.d.ts +0 -7
  95. package/es/hooks/useGlobalCache.js +0 -41
  96. package/es/hooks/useHMR.d.ts +0 -3
  97. package/es/hooks/useHMR.js +0 -20
  98. package/es/hooks/useStyleRegister.d.ts +0 -81
  99. package/es/hooks/useStyleRegister.js +0 -216
  100. package/es/index.d.ts +0 -18
  101. package/es/index.js +0 -44
  102. package/es/interface.d.ts +0 -2
  103. package/es/linters/NaNLinter.d.ts +0 -3
  104. package/es/linters/NaNLinter.js +0 -7
  105. package/es/linters/contentQuotesLinter.d.ts +0 -3
  106. package/es/linters/contentQuotesLinter.js +0 -13
  107. package/es/linters/hashedAnimationLinter.d.ts +0 -3
  108. package/es/linters/hashedAnimationLinter.js +0 -10
  109. package/es/linters/index.d.ts +0 -7
  110. package/es/linters/interface.d.ts +0 -8
  111. package/es/linters/legacyNotSelectorLinter.d.ts +0 -3
  112. package/es/linters/legacyNotSelectorLinter.js +0 -14
  113. package/es/linters/logicalPropertiesLinter.d.ts +0 -3
  114. package/es/linters/logicalPropertiesLinter.js +0 -61
  115. package/es/linters/parentSelectorLinter.d.ts +0 -3
  116. package/es/linters/parentSelectorLinter.js +0 -7
  117. package/es/linters/utils.d.ts +0 -2
  118. package/es/linters/utils.js +0 -11
  119. package/es/theme/Theme.d.ts +0 -11
  120. package/es/theme/Theme.js +0 -21
  121. package/es/theme/ThemeCache.d.ts +0 -20
  122. package/es/theme/ThemeCache.js +0 -74
  123. package/es/theme/calc/CSSCalculator.d.ts +0 -15
  124. package/es/theme/calc/CSSCalculator.js +0 -40
  125. package/es/theme/calc/NumCalculator.d.ts +0 -10
  126. package/es/theme/calc/NumCalculator.js +0 -25
  127. package/es/theme/calc/calculator.d.ts +0 -30
  128. package/es/theme/calc/calculator.js +0 -5
  129. package/es/theme/calc/index.d.ts +0 -5
  130. package/es/theme/calc/index.js +0 -9
  131. package/es/theme/createTheme.d.ts +0 -6
  132. package/es/theme/createTheme.js +0 -10
  133. package/es/theme/index.d.ts +0 -6
  134. package/es/theme/interface.d.ts +0 -2
  135. package/es/transformers/interface.d.ts +0 -4
  136. package/es/transformers/legacyLogicalProperties.js +0 -108
  137. package/es/transformers/px2rem.d.ts +0 -20
  138. package/es/transformers/px2rem.js +0 -32
  139. package/es/util/cacheMapUtil.d.ts +0 -14
  140. package/es/util/cacheMapUtil.js +0 -48
  141. package/es/util/css-variables.d.ts +0 -20
  142. package/es/util/css-variables.js +0 -22
  143. package/es/util/index.d.ts +0 -15
  144. package/es/util/index.js +0 -85
  145. package/lib/Cache.d.ts +0 -20
  146. package/lib/Cache.js +0 -1
  147. package/lib/Keyframes.d.ts +0 -9
  148. package/lib/Keyframes.js +0 -1
  149. package/lib/StyleContext.d.ts +0 -40
  150. package/lib/StyleContext.js +0 -1
  151. package/lib/extractStyle.d.ts +0 -12
  152. package/lib/extractStyle.js +0 -1
  153. package/lib/hooks/useCSSVarRegister.d.ts +0 -21
  154. package/lib/hooks/useCSSVarRegister.js +0 -1
  155. package/lib/hooks/useCacheToken.d.ts +0 -69
  156. package/lib/hooks/useCacheToken.js +0 -1
  157. package/lib/hooks/useEffectCleanupRegister.d.ts +0 -2
  158. package/lib/hooks/useEffectCleanupRegister.js +0 -1
  159. package/lib/hooks/useGlobalCache.d.ts +0 -7
  160. package/lib/hooks/useGlobalCache.js +0 -1
  161. package/lib/hooks/useHMR.d.ts +0 -3
  162. package/lib/hooks/useHMR.js +0 -1
  163. package/lib/hooks/useStyleRegister.d.ts +0 -81
  164. package/lib/hooks/useStyleRegister.js +0 -3
  165. package/lib/index.d.ts +0 -18
  166. package/lib/index.js +0 -1
  167. package/lib/interface.d.ts +0 -2
  168. package/lib/linters/NaNLinter.d.ts +0 -3
  169. package/lib/linters/NaNLinter.js +0 -1
  170. package/lib/linters/contentQuotesLinter.d.ts +0 -3
  171. package/lib/linters/contentQuotesLinter.js +0 -1
  172. package/lib/linters/hashedAnimationLinter.d.ts +0 -3
  173. package/lib/linters/hashedAnimationLinter.js +0 -1
  174. package/lib/linters/index.d.ts +0 -7
  175. package/lib/linters/interface.d.ts +0 -8
  176. package/lib/linters/legacyNotSelectorLinter.d.ts +0 -3
  177. package/lib/linters/legacyNotSelectorLinter.js +0 -1
  178. package/lib/linters/logicalPropertiesLinter.d.ts +0 -3
  179. package/lib/linters/logicalPropertiesLinter.js +0 -1
  180. package/lib/linters/parentSelectorLinter.d.ts +0 -3
  181. package/lib/linters/parentSelectorLinter.js +0 -1
  182. package/lib/linters/utils.d.ts +0 -2
  183. package/lib/linters/utils.js +0 -1
  184. package/lib/theme/Theme.d.ts +0 -11
  185. package/lib/theme/Theme.js +0 -1
  186. package/lib/theme/ThemeCache.d.ts +0 -20
  187. package/lib/theme/ThemeCache.js +0 -1
  188. package/lib/theme/calc/CSSCalculator.d.ts +0 -15
  189. package/lib/theme/calc/CSSCalculator.js +0 -1
  190. package/lib/theme/calc/NumCalculator.d.ts +0 -10
  191. package/lib/theme/calc/NumCalculator.js +0 -1
  192. package/lib/theme/calc/calculator.d.ts +0 -30
  193. package/lib/theme/calc/calculator.js +0 -1
  194. package/lib/theme/calc/index.d.ts +0 -5
  195. package/lib/theme/calc/index.js +0 -1
  196. package/lib/theme/createTheme.d.ts +0 -6
  197. package/lib/theme/createTheme.js +0 -1
  198. package/lib/theme/index.d.ts +0 -6
  199. package/lib/theme/interface.d.ts +0 -2
  200. package/lib/transformers/interface.d.ts +0 -4
  201. package/lib/transformers/legacyLogicalProperties.d.ts +0 -12
  202. package/lib/transformers/legacyLogicalProperties.js +0 -1
  203. package/lib/transformers/px2rem.d.ts +0 -20
  204. package/lib/transformers/px2rem.js +0 -1
  205. package/lib/util/cacheMapUtil.d.ts +0 -14
  206. package/lib/util/cacheMapUtil.js +0 -1
  207. package/lib/util/css-variables.d.ts +0 -20
  208. package/lib/util/css-variables.js +0 -1
  209. package/lib/util/index.d.ts +0 -15
  210. package/lib/util/index.js +0 -1
@@ -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;
package/lib/Keyframes.js DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class r{name;style;constructor(e,t){this.name=e,this.style=t}getName(e=""){return e?`${e}-${this.name}`:this.name}_keyframe=!0}exports.default=r;
@@ -1,40 +0,0 @@
1
- import { ComputedRef } from 'vue';
2
- import { Linter } from './linters';
3
- import { Transformer } from './transformers/interface';
4
- import { default as CacheEntity } from './Cache';
5
- export declare const ATTR_TOKEN = "data-token-hash";
6
- export declare const ATTR_MARK = "data-css-hash";
7
- export declare const ATTR_CACHE_PATH = "data-cache-path";
8
- export declare const CSS_IN_JS_INSTANCE = "__cssinjs_instance__";
9
- export declare function createCache(): CacheEntity;
10
- export type HashPriority = 'low' | 'high';
11
- export interface StyleContextProps {
12
- autoClear?: boolean;
13
- mock?: 'server' | 'client';
14
- /**
15
- * Only set when you need ssr to extract style on you own.
16
- * If not provided, it will auto create <style /> on the end of Provider in server side.
17
- */
18
- cache: CacheEntity;
19
- /** Tell children that this context is default generated context */
20
- defaultCache: boolean;
21
- /** Use `:where` selector to reduce hashId css selector priority */
22
- hashPriority?: HashPriority;
23
- /** Tell cssinjs where to inject style in */
24
- container?: Element | ShadowRoot;
25
- /** Component wil render inline `<style />` for fallback in SSR. Not recommend. */
26
- ssrInline?: boolean;
27
- /** Transform css before inject in document. Please note that `transformers` do not support dynamic update */
28
- transformers?: Transformer[];
29
- /**
30
- * Linters to lint css before inject in document.
31
- * Styles will be linted after transforming.
32
- * Please note that `linters` do not support dynamic update.
33
- */
34
- linters?: Linter[];
35
- /** Wrap css in a layer to avoid global style conflict */
36
- layer?: boolean;
37
- }
38
- export type StyleProviderProps = Partial<StyleContextProps>;
39
- export declare const StyleProvider: import('vue').DefineSetupFnComponent<Partial<StyleContextProps>, {}, {}, Partial<StyleContextProps> & {}, import('vue').PublicProps>;
40
- export declare function useStyleContext(): ComputedRef<StyleContextProps>;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),C=require("./Cache.js"),S="data-token-hash",d="data-css-hash",p="data-cache-path",o="__cssinjs_instance__";function i(){const n=Math.random().toString(12).slice(2);if(typeof document<"u"&&document.head&&document.body){const u=document.body.querySelectorAll(`style[${d}]`)||[],{firstChild:r}=document.head;Array.from(u).forEach(e=>{e[o]=e[o]||n,e[o]===n&&document.head.insertBefore(e,r)});const c={};Array.from(document.querySelectorAll(`style[${d}]`)).forEach(e=>{const t=e.getAttribute(d);c[t]?e[o]===n&&e.parentNode?.removeChild(e):c[t]=!0})}return new C.default(n)}const l=Symbol("StyleContext"),A={hashPriority:"low",cache:i(),defaultCache:!0},m=a.defineComponent((n,{slots:u})=>{const r=f(),c=a.computed(()=>{const e=n,t={...r.value};Object.keys(e).forEach(s=>{const y=e[s];e[s]!==void 0&&(t[s]=y)});const{cache:h}=e;return t.cache=t.cache||i(),t.defaultCache=!h&&r.value.defaultCache,t});return a.provide(l,c),()=>u.default?.()},{name:"StyleProvider",name:"StyleProvider",inheritAttrs:!1,props:{autoClear:{type:Boolean,default:void 0},mock:{type:String,default:void 0},cache:{type:Object,default:void 0},defaultCache:{type:Boolean,default:void 0},hashPriority:{type:String,default:void 0},container:{type:Object,default:void 0},ssrInline:{type:Boolean,default:void 0},transformers:{type:Array,default:void 0},linters:{type:Array,default:void 0},layer:{type:Boolean,default:void 0}}});function f(){return a.inject(l,a.computed(()=>A))}exports.ATTR_CACHE_PATH=p;exports.ATTR_MARK=d;exports.ATTR_TOKEN=S;exports.CSS_IN_JS_INSTANCE=o;exports.StyleProvider=m;exports.createCache=i;exports.useStyleContext=f;
@@ -1,12 +0,0 @@
1
- import { default as Cache } from './Cache';
2
- declare const ExtractStyleFns: {
3
- style: import('./hooks/useGlobalCache').ExtractStyle<[styleStr: string, tokenKey: string, styleId: string, effectStyle: Record<string, string>, clientOnly: boolean | undefined, order: number]>;
4
- token: import('./hooks/useGlobalCache').ExtractStyle<[token: any, hashId: string, realToken: any, cssVarStr: string, cssVarKey: string]>;
5
- cssVar: import('./hooks/useGlobalCache').ExtractStyle<[cssVarToken: import('./util/css-variables').TokenWithCSSVar<any, Record<string, any>>, cssVarStr: string, styleId: string, cssVarKey: string]>;
6
- };
7
- type ExtractStyleType = keyof typeof ExtractStyleFns;
8
- export default function extractStyle(cache: Cache, options?: boolean | {
9
- plain?: boolean;
10
- types?: ExtractStyleType | ExtractStyleType[];
11
- }): string;
12
- export {};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("./hooks/useCacheToken.js"),y=require("./hooks/useCSSVarRegister.js"),S=require("./hooks/useStyleRegister.js"),d=require("./util/index.js"),r=require("./util/cacheMapUtil.js"),h={[S.STYLE_PREFIX]:S.extract,[f.TOKEN_PREFIX]:f.extract,[y.CSS_VAR_PREFIX]:y.extract};function P(t){return t!==null}function g(t,s){const{plain:o=!1,types:c=["style","token","cssVar"]}=typeof s=="boolean"?{plain:s}:s||{},a=new RegExp(`^(${(typeof c=="string"?[c]:c).join("|")})%`),p=Array.from(t.cache.keys()).filter(e=>a.test(e)),x={},i={};let n="";return p.map(e=>{const l=e.replace(a,"").replace(/%/g,"|"),[_]=e.split("%"),A=h[_],u=A(t.cache.get(e)[1],x,{plain:o});if(!u)return null;const[E,R,T]=u;return e.startsWith("style")&&(i[l]=R),[E,T]}).filter(P).sort(([e],[l])=>e-l).forEach(([,e])=>{n+=e}),n+=d.toStyleStr(`.${r.ATTR_CACHE_MAP}{content:"${r.serialize(i)}";}`,void 0,void 0,{[r.ATTR_CACHE_MAP]:r.ATTR_CACHE_MAP},o),n}exports.default=g;
@@ -1,21 +0,0 @@
1
- import { MaybeRef } from 'vue';
2
- import { TokenWithCSSVar } from '../util/css-variables';
3
- import { ExtractStyle } from './useGlobalCache';
4
- export declare const CSS_VAR_PREFIX = "cssVar";
5
- type CSSVarCacheValue<V, T extends Record<string, V> = Record<string, V>> = [
6
- cssVarToken: TokenWithCSSVar<V, T>,
7
- cssVarStr: string,
8
- styleId: string,
9
- cssVarKey: string
10
- ];
11
- declare function useCSSVarRegister<V, T extends Record<string, V>>(config: MaybeRef<{
12
- path: string[];
13
- key: string;
14
- prefix?: string;
15
- unitless?: Record<string, boolean>;
16
- ignore?: Record<string, boolean>;
17
- scope?: string;
18
- token: any;
19
- }>, fn: MaybeRef<() => T>): import('vue').ComputedRef<CSSVarCacheValue<V, T>>;
20
- export declare const extract: ExtractStyle<CSSVarCacheValue<any>>;
21
- export default useCSSVarRegister;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("@v-c/util/dist/Dom/dynamicCSS"),e=require("vue"),s=require("../StyleContext.js"),_=require("../util/index.js"),R=require("../util/css-variables.js"),h=require("./useGlobalCache.js"),x=require("./useStyleRegister.js"),C="cssVar";function A(t,v){const l=s.useStyleContext(),u=e.computed(()=>e.unref(t).path),r=e.computed(()=>e.unref(t).key),i=e.computed(()=>e.unref(t).prefix),d=e.computed(()=>e.unref(t).unitless),o=e.computed(()=>e.unref(t).ignore),c=e.computed(()=>e.unref(t).scope),p=e.computed(()=>e.unref(t).token),k=e.computed(()=>p.value._tokenKey),m=e.computed(()=>[...u.value,r.value,c.value,k.value]);return h.default(C,m,()=>{const n=e.unref(v)(),[S,a]=R.transformToken(n,r.value,{prefix:i.value,unitless:d.value,ignore:o.value,scope:c.value}),y=x.uniqueHash(m.value,a);return[S,a,y,r.value]},([,,n])=>{_.isClientSide&&T.removeCSS(n,{mark:s.ATTR_MARK})},([,n,S])=>{if(!n)return;const{container:a,cache:{instanceId:y}}=l.value,f=T.updateCSS(n,S,{mark:s.ATTR_MARK,prepend:"queue",attachTo:a,priority:-999});f[s.CSS_IN_JS_INSTANCE]=y,f.setAttribute(s.ATTR_TOKEN,r)})}const q=(t,v,l)=>{const[,u,r,i]=t,{plain:d}=l||{};if(!u)return null;const o=-999,c={"data-vc-order":"prependQueue","data-vc-priority":`${o}`},p=_.toStyleStr(u,i,r,c,d);return[o,r,p]};exports.CSS_VAR_PREFIX=C;exports.default=A;exports.extract=q;