@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
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;
@@ -1,69 +0,0 @@
1
- import { ComputedRef, MaybeRef } from 'vue';
2
- import { default as Theme } from '../theme/Theme';
3
- import { ExtractStyle } from './useGlobalCache';
4
- export interface Option<DerivativeToken, DesignToken> {
5
- /**
6
- * Generate token with salt.
7
- * This is used to generate different hashId even same derivative token for different version.
8
- */
9
- salt?: string;
10
- override?: object;
11
- /**
12
- * Format token as you need. Such as:
13
- *
14
- * - rename token
15
- * - merge token
16
- * - delete token
17
- *
18
- * This should always be the same since it's one time process.
19
- * It's ok to useMemo outside but this has better cache strategy.
20
- */
21
- formatToken?: (mergedToken: any) => DerivativeToken;
22
- /**
23
- * Get final token with origin token, override token and theme.
24
- * The parameters do not contain formatToken since it's passed by user.
25
- * @param origin The original token.
26
- * @param override Extra tokens to override.
27
- * @param theme Theme instance. Could get derivative token by `theme.getDerivativeToken`
28
- */
29
- getComputedToken?: (origin: DesignToken, override: object, theme: Theme<any, any>) => DerivativeToken;
30
- /**
31
- * Transform token to css variables.
32
- */
33
- cssVar?: {
34
- /** Prefix for css variables */
35
- prefix?: string;
36
- /** Tokens that should not be appended with unit */
37
- unitless?: Record<string, boolean>;
38
- /** Tokens that should not be transformed to css variables */
39
- ignore?: Record<string, boolean>;
40
- /** Tokens that preserves origin value */
41
- preserve?: Record<string, boolean>;
42
- /** Key for current theme. Useful for customizing and should be unique */
43
- key?: string;
44
- };
45
- }
46
- export declare function getComputedToken<DerivativeToken = object, DesignToken = DerivativeToken>(originToken: DesignToken, overrideToken: object, theme: Theme<any, any>, format?: (token: DesignToken) => DerivativeToken): any;
47
- export declare const TOKEN_PREFIX = "token";
48
- type TokenCacheValue<DerivativeToken> = [
49
- token: DerivativeToken & {
50
- _tokenKey: string;
51
- _themeKey: string;
52
- },
53
- hashId: string,
54
- realToken: DerivativeToken & {
55
- _tokenKey: string;
56
- },
57
- cssVarStr: string,
58
- cssVarKey: string
59
- ];
60
- /**
61
- * Cache theme derivative token as global shared one
62
- * @param theme Theme entity
63
- * @param tokens List of tokens, used for cache. Please do not dynamic generate object directly
64
- * @param option Additional config
65
- * @returns Call Theme.getDerivativeToken(tokenObject) to get token
66
- */
67
- export default function useCacheToken<DerivativeToken = object, DesignToken = DerivativeToken>(theme: MaybeRef<Theme<any, any>>, tokens: MaybeRef<Partial<DesignToken>[]>, option?: MaybeRef<Option<DerivativeToken, DesignToken>>): ComputedRef<TokenCacheValue<DerivativeToken>>;
68
- export declare const extract: ExtractStyle<TokenCacheValue<any>>;
69
- export {};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("@emotion/hash"),N=require("@v-c/util/dist/Dom/dynamicCSS"),e=require("vue"),v=require("../StyleContext.js"),l=require("../util/index.js"),I=require("../util/css-variables.js"),x=require("./useGlobalCache.js"),A={},O=process.env.NODE_ENV!=="production"?"css-dev-only-do-not-override":"css",i=new Map;function R(t){i.set(t,(i.get(t)||0)+1)}function q(t,a){typeof document<"u"&&document.querySelectorAll(`style[${v.ATTR_TOKEN}="${t}"]`).forEach(n=>{n[v.CSS_IN_JS_INSTANCE]===a&&n.parentNode?.removeChild(n)})}const b=0;function V(t,a){i.set(t,(i.get(t)||0)-1);const r=Array.from(i.keys()),n=r.filter(u=>(i.get(u)||0)<=0);r.length-n.length>b&&n.forEach(u=>{q(u,a),i.delete(u)})}function g(t,a,r,n){let c={...r.getDerivativeToken(t),...a};return n&&(c=n(c)),c}const E="token";function D(t,a,r=e.ref({})){const n=v.useStyleContext(),u=e.computed(()=>e.unref(r).salt??""),c=e.computed(()=>e.unref(r).override??A),k=e.unref(r).formatToken,f=e.unref(r).getComputedToken,o=e.computed(()=>e.unref(r).cssVar),T=e.computed(()=>l.memoResult(()=>Object.assign({},...e.unref(a)),e.unref(a))),m=e.computed(()=>l.flattenToken(T.value)),K=e.computed(()=>l.flattenToken(c.value)),C=e.computed(()=>o.value?l.flattenToken(o.value):"");return x.default(E,e.computed(()=>[u.value,e.unref(t).id,m.value,K.value,C.value]),()=>{let s=f?f(T.value,c.value,e.unref(t)):g(T.value,c.value,e.unref(t),k);const d={...s};let y="";o.value&&([s,y]=I.transformToken(s,o.value.key,{prefix:o.value.prefix,ignore:o.value.ignore,unitless:o.value.unitless,preserve:o.value.preserve}));const S=l.token2key(s,u.value);s._tokenKey=S,d._tokenKey=l.token2key(d,u.value);const p=o.value?.key??S;s._themeKey=p,R(p);const _=`${O}-${h(S)}`;return s._hashId=_,[s,_,d,y,o.value?.key||""]},s=>{V(s[0]._themeKey,n.value.cache.instanceId)},([s,,,d])=>{if(o.value&&d){const y=N.updateCSS(d,h(`css-variables-${s._themeKey}`),{mark:v.ATTR_MARK,prepend:"queue",attachTo:n.value.container,priority:-999});y[v.CSS_IN_JS_INSTANCE]=n.value.cache.instanceId,y.setAttribute(v.ATTR_TOKEN,s._themeKey)}})}const $=(t,a,r)=>{const[,,n,u,c]=t,{plain:k}=r||{};if(!u)return null;const f=n._tokenKey,o=-999,T={"data-vc-order":"prependQueue","data-vc-priority":`${o}`},m=l.toStyleStr(u,c,f,T,k);return[o,f,m]};exports.TOKEN_PREFIX=E;exports.default=D;exports.extract=$;exports.getComputedToken=g;
@@ -1,2 +0,0 @@
1
- declare function useRun(): (fn: () => void) => void;
2
- export default useRun;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function u(){return function(e){e()}}exports.default=u;
@@ -1,7 +0,0 @@
1
- import { ComputedRef } from 'vue';
2
- import { MaybeRef } from '../interface.ts';
3
- import { KeyType } from '../Cache';
4
- export type ExtractStyle<CacheValue> = (cache: CacheValue, effectStyles: Record<string, boolean>, options?: {
5
- plain?: boolean;
6
- }) => [order: number, styleId: string, style: string] | null;
7
- export default function useGlobalCache<CacheType>(prefix: MaybeRef<string>, keyPath: MaybeRef<KeyType[]>, cacheFn: () => CacheType, onCacheRemove?: (cache: CacheType, fromHMR: boolean) => void, onCacheEffect?: (cachedValue: CacheType) => void): ComputedRef<CacheType>;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),E=require("../Cache.js"),S=require("../StyleContext.js"),_=require("./useEffectCleanupRegister.js"),G=require("./useHMR.js");function M(g,b,x,r,v){const n=S.useStyleContext(),q=e.computed(()=>[e.unref(g),...e.unref(b)]),o=e.computed(()=>E.pathKey(q.value)),y=_.default(),f=[],h=G.default(),d=l=>{n.value.cache.opUpdate(o.value,s=>{const[c=0,t]=s||[void 0,void 0];let a=t;process.env.NODE_ENV!=="production"&&t&&h&&(r?.(a,h),a=null);const C=a||x(),m=[c,C];return l?l(m):m})},u=e.shallowRef();u.value=n.value.cache.opGet(o.value),process.env.NODE_ENV!=="production"&&!u.value&&(d(),u.value=n.value.cache.opGet(o.value));const i=e.computed(()=>u.value[1]);return e.watch(o,(l,p)=>{const s=n.value.cache;v?.(i.value),d(([c,t])=>(c===0&&v?.(i.value),[c+1,t])),p&&s.opUpdate(p,c=>{const[t=0,a]=c||[];return t-1===0?(y(()=>{r?.(a,!1)}),null):[t-1,a]}),u.value=s.opGet(o.value),f.push(()=>{r?.(u.value[1],!1)})},{immediate:!0,flush:"post"}),e.onBeforeUnmount(()=>{f.map(l=>l())}),i}exports.default=M;
@@ -1,3 +0,0 @@
1
- declare function useProdHMR(): boolean;
2
- declare const _default: typeof useProdHMR;
3
- export default _default;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function u(){return!1}let t=!1;function i(){return t}const r=process.env.NODE_ENV==="production"?u:i;if(process.env.NODE_ENV!=="production"&&typeof module<"u"&&module&&module.hot&&typeof window<"u"){const e=window;if(typeof e.webpackHotUpdate=="function"){const o=e.webpackHotUpdate;e.webpackHotUpdate=(...n)=>(t=!0,setTimeout(()=>{t=!1},0),o(...n))}}exports.default=r;
@@ -1,81 +0,0 @@
1
- import { VueNode } from '@v-c/util/dist/type';
2
- import { MaybeRef } from 'vue';
3
- import { Theme, Transformer } from '..';
4
- import { default as Keyframes } from '../Keyframes';
5
- import { Linter } from '../linters';
6
- import { HashPriority } from '../StyleContext';
7
- import { ExtractStyle } from './useGlobalCache';
8
- import type * as CSS from 'csstype';
9
- declare const SKIP_CHECK = "_skip_check_";
10
- declare const MULTI_VALUE = "_multi_value_";
11
- export interface LayerConfig {
12
- name: string;
13
- dependencies?: string[];
14
- }
15
- export type CSSProperties = Omit<CSS.PropertiesFallback<number | string>, 'animationName'> & {
16
- animationName?: CSS.PropertiesFallback<number | string>['animationName'] | Keyframes;
17
- };
18
- export type CSSPropertiesWithMultiValues = {
19
- [K in keyof CSSProperties]: CSSProperties[K] | readonly Extract<CSSProperties[K], string>[] | {
20
- [SKIP_CHECK]?: boolean;
21
- [MULTI_VALUE]?: boolean;
22
- value: CSSProperties[K] | CSSProperties[K][];
23
- };
24
- };
25
- export type CSSPseudos = {
26
- [K in CSS.Pseudos]?: CSSObject;
27
- };
28
- type ArrayCSSInterpolation = readonly CSSInterpolation[];
29
- export type InterpolationPrimitive = null | undefined | boolean | number | string | CSSObject;
30
- export type CSSInterpolation = InterpolationPrimitive | ArrayCSSInterpolation | Keyframes;
31
- export type CSSOthersObject = Record<string, CSSInterpolation>;
32
- export interface CSSObject extends CSSPropertiesWithMultiValues, CSSPseudos, CSSOthersObject {
33
- }
34
- export declare function normalizeStyle(styleStr: string): string;
35
- export interface ParseConfig {
36
- hashId?: string;
37
- hashPriority?: HashPriority;
38
- layer?: LayerConfig;
39
- path?: string;
40
- transformers?: Transformer[];
41
- linters?: Linter[];
42
- }
43
- export interface ParseInfo {
44
- root?: boolean;
45
- injectHash?: boolean;
46
- parentSelectors: string[];
47
- }
48
- export declare function parseStyle(interpolation: CSSInterpolation, config?: ParseConfig, { root, injectHash, parentSelectors }?: ParseInfo): [
49
- parsedStr: string,
50
- effectStyle: Record<string, string>
51
- ];
52
- export declare function uniqueHash(path: (string | number)[], styleStr: string): string;
53
- export declare const STYLE_PREFIX = "style";
54
- type StyleCacheValue = [
55
- styleStr: string,
56
- tokenKey: string,
57
- styleId: string,
58
- effectStyle: Record<string, string>,
59
- clientOnly: boolean | undefined,
60
- order: number
61
- ];
62
- /**
63
- * Register a style to the global style sheet.
64
- */
65
- export default function useStyleRegister(info: MaybeRef<{
66
- theme: Theme<any, any>;
67
- token: any;
68
- path: string[];
69
- hashId?: string;
70
- layer?: LayerConfig;
71
- nonce?: string | (() => string);
72
- clientOnly?: boolean;
73
- /**
74
- * Tell cssinjs the insert order of style.
75
- * It's useful when you need to insert style
76
- * before other style to overwrite for the same selector priority.
77
- */
78
- order?: number;
79
- }>, styleFn: MaybeRef<() => CSSInterpolation>): (node: VueNode) => any;
80
- export declare const extract: ExtractStyle<StyleCacheValue>;
81
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),V=require("@emotion/hash"),q=require("@v-c/util/dist/Dom/dynamicCSS"),w=require("@emotion/unitless"),O=require("stylis"),F=require("../linters/contentQuotesLinter.js"),D=require("../linters/hashedAnimationLinter.js");require("@v-c/util/dist/warning");const j=require("../StyleContext.js"),P=require("../util/index.js"),k=require("../util/cacheMapUtil.js"),U=require("./useGlobalCache.js"),x="_skip_check_",M="_multi_value_";function I(e){return O.serialize(O.compile(e),O.stringify).replace(/\{%%%:[^;];\}/g,";")}function W(e){return typeof e=="object"&&e&&(x in e||M in e)}function H(e,y,E){if(!y)return e;const C=`.${y}`,T=E==="low"?`:where(${C})`:C;return e.split(",").map(u=>{const A=u.trim().split(/\s+/);let h=A[0]||"";const r=h.match(/^\w+/)?.[0]||"";return h=`${r}${T}${h.slice(r.length)}`,[h,...A.slice(1)].join(" ")}).join(",")}function R(e,y={},{root:E,injectHash:C,parentSelectors:T}={root:!0,parentSelectors:[]}){const{hashId:d,layer:u,path:A,hashPriority:h,transformers:r=[],linters:m=[]}=y;let o="",f={};function N(s){const l=s.getName(d);if(!f[l]){const[i]=R(s.style,y,{root:!1,parentSelectors:T});f[l]=`@keyframes ${s.getName(d)}${i}`}}function g(s,l=[]){return s.forEach(i=>{Array.isArray(i)?g(i,l):i&&l.push(i)}),l}return g(Array.isArray(e)?e:[e]).forEach(s=>{const l=typeof s=="string"&&!E?{}:s;if(typeof l=="string")o+=`${l}
2
- `;else if(l._keyframe)N(l);else{const i=r.reduce((a,n)=>n?.visit?.(a)||a,l);Object.keys(i).forEach(a=>{const n=i[a];if(typeof n=="object"&&n&&(a!=="animationName"||!n._keyframe)&&!W(n)){let p=!1,c=a.trim(),v=!1;(E||C)&&d?c.startsWith("@")?p=!0:c==="&"?c=H("",d,h):c=H(a,d,h):E&&!d&&(c==="&"||c==="")&&(c="",v=!0);const[_,S]=R(n,y,{root:v,injectHash:p,parentSelectors:[...T,c]});f={...f,...S},o+=`${c}${_}`}else{let p=function(v,_){process.env.NODE_ENV!=="production"&&(typeof n!="object"||!n?.[x])&&[F.default,D.default,...m].forEach(L=>L(v,_,{path:A,hashId:d,parentSelectors:T}));const S=v.replace(/[A-Z]/g,L=>`-${L.toLowerCase()}`);let b=_;!w[v]&&typeof b=="number"&&b!==0&&(b=`${b}px`),v==="animationName"&&_?._keyframe&&(N(_),b=_.getName(d)),o+=`${S}:${b};`};const c=n?.value??n;typeof n=="object"&&n?.[M]&&Array.isArray(c)?c.forEach(v=>{p(a,v)}):p(a,c)}})}}),E?u&&(o=`@layer ${u.name} {${o}}`,u.dependencies&&(f[`@layer ${u.name}`]=u.dependencies.map(s=>`@layer ${s}, ${u.name};`).join(`
3
- `))):o=`{${o}}`,[o,f]}function K(e,y){return V(`${e.join("%")}${y}`)}function Y(){return null}const z="style";function Q(e,y){const E=t.computed(()=>t.unref(e).token),C=t.computed(()=>t.unref(e).path),T=t.computed(()=>t.unref(e).hashId),d=t.computed(()=>t.unref(e).layer),u=t.computed(()=>t.unref(e).nonce),A=t.computed(()=>t.unref(e).clientOnly),h=t.computed(()=>t.unref(e).order??0),r=j.useStyleContext(),m=t.computed(()=>E.value._tokenKey),o=[m.value];r.value.layer&&o.push("layer"),o.push(...C.value);const f=r.value.mock;let N=P.isClientSide;process.env.NODE_ENV!=="production"&&f!==void 0&&(N=f==="client");const g=U.default(z,o,()=>{const $=o.join("|");if(k.existPath($)){const[p,c]=k.getStyleAndHash($);if(p)return[p,m.value,c,{},A.value,h.value]}const s=t.unref(y)(),[l,i]=R(s,{hashId:T.value,hashPriority:r.value.hashPriority,layer:r.value.layer?d.value:void 0,path:C.value.join("-"),transformers:r.value.transformers,linters:r.value.linters}),a=I(l),n=K(o,a);return[a,m.value,n,i,A.value,h.value]},([,,$],s)=>{(s||r.value.autoClear)&&P.isClientSide&&q.removeCSS($,{mark:j.ATTR_MARK})},([$,s,l,i])=>{if(N&&$!==k.CSS_FILE_STYLE){const a={mark:j.ATTR_MARK,prepend:r.value.layer?!1:"queue",attachTo:r.value.container,priority:h.value},n=typeof u.value=="function"?u.value():u.value;n&&(a.csp={nonce:n});const p=[],c=[];Object.keys(i).forEach(S=>{S.startsWith("@layer")?p.push(S):c.push(S)}),p.forEach(S=>{q.updateCSS(I(i[S]),`_layer-${S}`,{...a,prepend:!0})});const v=r.value.cache,_=q.updateCSS($,l,a);_[j.CSS_IN_JS_INSTANCE]=v.instanceId,_.setAttribute(j.ATTR_TOKEN,t.unref(m)),process.env.NODE_ENV!=="production"&&_.setAttribute(j.ATTR_CACHE_PATH,o.join("|")),c.forEach(S=>{q.updateCSS(I(i[S]),`_effect-${S}`,a)})}});return $=>{let s;const{ssrInline:l,defaultCache:i}=r.value,[a,n,p]=g.value;return!l||N||!i?s=t.createVNode(Y,null,null):s=t.createVNode("style",t.mergeProps({[j.ATTR_TOKEN]:n,[j.ATTR_MARK]:p},{innerHTML:a}),null),t.createVNode(t.Fragment,null,[s,$])}}const X=(e,y,E)=>{const[C,T,d,u,A,h]=e,{plain:r}=E||{};if(A)return null;let m=C;const o={"data-vc-order":"prependQueue","data-vc-priority":`${h}`};return m=P.toStyleStr(C,T,d,o,r),u&&Object.keys(u).forEach(f=>{if(!y[f]){y[f]=!0;const N=I(u[f]),g=P.toStyleStr(N,T,`_effect-${f}`,o,r);f.startsWith("@layer")?m=g+m:m+=g}}),[h,d,m]};exports.STYLE_PREFIX=z;exports.default=Q;exports.extract=X;exports.normalizeStyle=I;exports.parseStyle=R;exports.uniqueHash=K;
package/lib/index.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import { CSSInterpolation, CSSObject, default as useStyleRegister } from './hooks/useStyleRegister';
2
- import { Linter, legacyNotSelectorLinter, logicalPropertiesLinter, NaNLinter, parentSelectorLinter } from './linters';
3
- import { StyleProviderProps, createCache, StyleProvider } from './StyleContext';
4
- import { AbstractCalculator, DerivativeFunc, TokenType, createTheme, genCalc, Theme } from './theme';
5
- import { Transformer } from './transformers/interface';
6
- import { default as extractStyle } from './extractStyle';
7
- import { default as useCacheToken, getComputedToken } from './hooks/useCacheToken';
8
- import { default as useCSSVarRegister } from './hooks/useCSSVarRegister';
9
- import { default as Keyframes } from './Keyframes';
10
- import { default as legacyLogicalPropertiesTransformer } from './transformers/legacyLogicalProperties';
11
- import { default as px2remTransformer } from './transformers/px2rem';
12
- import { unit } from './util';
13
- import { token2CSSVar } from './util/css-variables';
14
- export { createCache, createTheme, extractStyle, genCalc, getComputedToken, Keyframes, legacyLogicalPropertiesTransformer, legacyNotSelectorLinter, logicalPropertiesLinter, NaNLinter, parentSelectorLinter, px2remTransformer, StyleProvider, Theme, token2CSSVar, unit, useCacheToken, useCSSVarRegister, useStyleRegister, };
15
- export type { AbstractCalculator, CSSInterpolation, CSSObject, DerivativeFunc, Linter, StyleProviderProps, TokenType, Transformer, };
16
- export declare const _experimental: {
17
- supportModernCSS: () => boolean;
18
- };
package/lib/index.js DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./extractStyle.js"),r=require("./hooks/useCacheToken.js"),a=require("./hooks/useCSSVarRegister.js"),i=require("./hooks/useStyleRegister.js"),u=require("./Keyframes.js");require("@v-c/util/dist/warning");const n=require("./linters/legacyNotSelectorLinter.js"),c=require("./linters/logicalPropertiesLinter.js"),s=require("./linters/NaNLinter.js"),l=require("./linters/parentSelectorLinter.js"),t=require("./StyleContext.js"),d=require("./theme/calc/index.js"),S=require("./theme/createTheme.js"),p=require("./theme/Theme.js"),f=require("./transformers/legacyLogicalProperties.js"),g=require("./transformers/px2rem.js"),e=require("./util/index.js"),q=require("./util/css-variables.js"),m={supportModernCSS:()=>e.supportWhere()&&e.supportLogicProps()};exports.extractStyle=o.default;exports.getComputedToken=r.getComputedToken;exports.useCacheToken=r.default;exports.useCSSVarRegister=a.default;exports.useStyleRegister=i.default;exports.Keyframes=u.default;exports.legacyNotSelectorLinter=n.default;exports.logicalPropertiesLinter=c.default;exports.NaNLinter=s.default;exports.parentSelectorLinter=l.default;exports.StyleProvider=t.StyleProvider;exports.createCache=t.createCache;exports.genCalc=d.default;exports.createTheme=S.default;exports.Theme=p.default;exports.legacyLogicalPropertiesTransformer=f.default;exports.px2remTransformer=g.default;exports.unit=e.unit;exports.token2CSSVar=q.token2CSSVar;exports._experimental=m;
@@ -1,2 +0,0 @@
1
- import { MaybeRef } from 'vue';
2
- export type { MaybeRef, };
@@ -1,3 +0,0 @@
1
- import { Linter } from './interface';
2
- declare const linter: Linter;
3
- export default linter;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./utils.js"),n=(t,e,i)=>{(typeof e=="string"&&/NaN/.test(e)||Number.isNaN(e))&&r.lintWarning(`Unexpected 'NaN' in property '${t}: ${e}'.`,i)};exports.default=n;
@@ -1,3 +0,0 @@
1
- import { Linter } from './interface';
2
- declare const linter: Linter;
3
- export default linter;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("./utils.js"),r=(n,t,e)=>{if(n==="content"){const o=/(attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;(typeof t!="string"||!["normal","none","initial","inherit","unset"].includes(t)&&!o.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||t.charAt(0)!=='"'&&t.charAt(0)!=="'"))&&i.lintWarning(`You seem to be using a value for 'content' without quotes, try replacing it with \`content: '"${t}"'\`.`,e)}};exports.default=r;
@@ -1,3 +0,0 @@
1
- import { Linter } from './interface';
2
- declare const linter: Linter;
3
- export default linter;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./utils.js"),a=(n,e,i)=>{n==="animation"&&i.hashId&&e!=="none"&&t.lintWarning(`You seem to be using hashed animation '${e}', in which case 'animationName' with Keyframe as value is recommended.`,i)};exports.default=a;
@@ -1,7 +0,0 @@
1
- export { default as contentQuotesLinter } from './contentQuotesLinter';
2
- export { default as hashedAnimationLinter } from './hashedAnimationLinter';
3
- export type { Linter } from './interface';
4
- export { default as legacyNotSelectorLinter } from './legacyNotSelectorLinter';
5
- export { default as logicalPropertiesLinter } from './logicalPropertiesLinter';
6
- export { default as NaNLinter } from './NaNLinter';
7
- export { default as parentSelectorLinter } from './parentSelectorLinter';
@@ -1,8 +0,0 @@
1
- export interface LinterInfo {
2
- path?: string;
3
- hashId?: string;
4
- parentSelectors: string[];
5
- }
6
- export interface Linter {
7
- (key: string, value: string | number, info: LinterInfo): void;
8
- }
@@ -1,3 +0,0 @@
1
- import { Linter } from './interface';
2
- declare const linter: Linter;
3
- export default linter;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./utils.js");function s(n){return(n.match(/:not\(([^)]*)\)/)?.[1]||"").split(/(\[[^[]*\])|(?=[.#])/).filter(o=>o).length>1}function c(n){return n.parentSelectors.reduce((e,t)=>e?t.includes("&")?t.replace(/&/g,e):`${e} ${t}`:t,"")}const i=(n,e,t)=>{const l=c(t).match(/:not\([^)]*\)/g)||[];l.length>0&&l.some(s)&&r.lintWarning("Concat ':not' selector not support in legacy browsers.",t)};exports.default=i;
@@ -1,3 +0,0 @@
1
- import { Linter } from './interface';
2
- declare const linter: Linter;
3
- export default linter;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./utils.js"),c=(t,r,o)=>{switch(t){case"marginLeft":case"marginRight":case"paddingLeft":case"paddingRight":case"left":case"right":case"borderLeft":case"borderLeftWidth":case"borderLeftStyle":case"borderLeftColor":case"borderRight":case"borderRightWidth":case"borderRightStyle":case"borderRightColor":case"borderTopLeftRadius":case"borderTopRightRadius":case"borderBottomLeftRadius":case"borderBottomRightRadius":a.lintWarning(`You seem to be using non-logical property '${t}' which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties.`,o);return;case"margin":case"padding":case"borderWidth":case"borderStyle":if(typeof r=="string"){const s=r.split(" ").map(n=>n.trim());s.length===4&&s[1]!==s[3]&&a.lintWarning(`You seem to be using '${t}' property with different left ${t} and right ${t}, which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties.`,o)}return;case"clear":case"textAlign":(r==="left"||r==="right")&&a.lintWarning(`You seem to be using non-logical value '${r}' of ${t}, which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties.`,o);return;case"borderRadius":typeof r=="string"&&r.split("/").map(i=>i.trim()).reduce((i,l)=>{if(i)return i;const e=l.split(" ").map(d=>d.trim());return e.length>=2&&e[0]!==e[1]||e.length===3&&e[1]!==e[2]||e.length===4&&e[2]!==e[3]?!0:i},!1)&&a.lintWarning(`You seem to be using non-logical value '${r}' of ${t}, which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties.`,o)}};exports.default=c;
@@ -1,3 +0,0 @@
1
- import { Linter } from './interface';
2
- declare const linter: Linter;
3
- export default linter;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./utils.js"),o=(r,n,e)=>{e.parentSelectors.some(t=>t.split(",").some(s=>s.split("&").length>2))&&l.lintWarning("Should not use more than one `&` in a selector.",e)};exports.default=o;
@@ -1,2 +0,0 @@
1
- import { LinterInfo } from './interface';
2
- export declare function lintWarning(message: string, info: LinterInfo): void;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@v-c/util/dist/warning");function o(t,r){const{path:n,parentSelectors:e}=r;i(!1,`[Ant Design CSS-in-JS] ${n?`Error in ${n}: `:""}${t}${e.length?` Selector: ${e.join(" | ")}`:""}`)}exports.lintWarning=o;
@@ -1,11 +0,0 @@
1
- import { DerivativeFunc, TokenType } from './interface';
2
- /**
3
- * Theme with algorithms to derive tokens from design tokens.
4
- * Use `createTheme` first which will help to manage the theme instance cache.
5
- */
6
- export default class Theme<DesignToken extends TokenType, DerivativeToken extends TokenType> {
7
- private derivatives;
8
- readonly id: number;
9
- constructor(derivatives: DerivativeFunc<DesignToken, DerivativeToken> | DerivativeFunc<DesignToken, DerivativeToken>[]);
10
- getDerivativeToken(token: DesignToken): DerivativeToken;
11
- }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("@v-c/util/dist/warning");let t=0;class u{derivatives;id;constructor(e){this.derivatives=Array.isArray(e)?e:[e],this.id=t,e.length===0&&n.warning(e.length>0,"[Ant Design CSS-in-JS] Theme should have at least one derivative function."),t+=1}getDerivativeToken(e){return this.derivatives.reduce((i,r)=>r(e,i),void 0)}}exports.default=u;
@@ -1,20 +0,0 @@
1
- import { DerivativeFunc } from './interface';
2
- import { default as Theme } from './Theme';
3
- type DerivativeOptions = DerivativeFunc<any, any>[];
4
- export declare function sameDerivativeOption(left: DerivativeOptions, right: DerivativeOptions): boolean;
5
- export default class ThemeCache {
6
- static MAX_CACHE_SIZE: number;
7
- static MAX_CACHE_OFFSET: number;
8
- private readonly cache;
9
- private keys;
10
- private cacheCallTimes;
11
- constructor();
12
- size(): number;
13
- private internalGet;
14
- get(derivativeOption: DerivativeOptions): Theme<any, any> | undefined;
15
- has(derivativeOption: DerivativeOptions): boolean;
16
- set(derivativeOption: DerivativeOptions, value: Theme<any, any>): void;
17
- private deleteByPath;
18
- delete(derivativeOption: DerivativeOptions): Theme<any, any> | undefined;
19
- }
20
- export {};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function n(i,e){if(i.length!==e.length)return!1;for(let s=0;s<i.length;s++)if(i[s]!==e[s])return!1;return!0}class c{static MAX_CACHE_SIZE=20;static MAX_CACHE_OFFSET=5;cache;keys;cacheCallTimes;constructor(){this.cache=new Map,this.keys=[],this.cacheCallTimes=0}size(){return this.keys.length}internalGet(e,s=!1){let t={map:this.cache};return e.forEach(l=>{t?t=t?.map?.get(l):t=void 0}),t?.value&&s&&(t.value[1]=this.cacheCallTimes++),t?.value}get(e){return this.internalGet(e,!0)?.[0]}has(e){return!!this.internalGet(e)}set(e,s){if(!this.has(e)){if(this.size()+1>c.MAX_CACHE_SIZE+c.MAX_CACHE_OFFSET){const[l]=this.keys.reduce((h,a)=>{const[,u]=h;return this.internalGet(a)[1]<u?[a,this.internalGet(a)[1]]:h},[this.keys[0],this.cacheCallTimes]);this.delete(l)}this.keys.push(e)}let t=this.cache;e.forEach((l,h)=>{if(h===e.length-1)t.set(l,{value:[s,this.cacheCallTimes++]});else{const a=t.get(l);a?a.map||(a.map=new Map):t.set(l,{map:new Map}),t=t.get(l).map}})}deleteByPath(e,s){const t=e.get(s[0]);if(s.length===1)return t.map?e.set(s[0],{map:t.map}):e.delete(s[0]),t.value?.[0];const l=this.deleteByPath(t.map,s.slice(1));return(!t.map||t.map.size===0)&&!t.value&&e.delete(s[0]),l}delete(e){if(this.has(e))return this.keys=this.keys.filter(s=>!n(s,e)),this.deleteByPath(this.cache,e)}}exports.default=c;exports.sameDerivativeOption=n;
@@ -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 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./calculator.js"),u="CALC_UNIT",f=new RegExp(u,"g");function l(r){return typeof r=="number"?`${r}${u}`:r}class e extends h.default{result="";unitlessCssVar;lowPriority;constructor(t,i){super();const s=typeof t;this.unitlessCssVar=i,t instanceof e?this.result=`(${t.result})`:s==="number"?this.result=l(t):s==="string"&&(this.result=t)}add(t){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}sub(t){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}mul(t){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}div(t){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}getResult(t){return this.lowPriority||t?`(${this.result})`:this.result}equal(t){const{unit:i}=t||{};let s=!0;return typeof i=="boolean"?s=i:Array.from(this.unitlessCssVar).some(o=>this.result.includes(o))&&(s=!1),this.result=this.result.replace(f,s?"px":""),typeof this.lowPriority<"u"?`calc(${this.result})`:this.result}}exports.default=e;
@@ -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 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./calculator.js");class t extends s.default{result=0;constructor(e){super(),e instanceof t?this.result=e.result:typeof e=="number"&&(this.result=e)}add(e){return e instanceof t?this.result+=e.result:typeof e=="number"&&(this.result+=e),this}sub(e){return e instanceof t?this.result-=e.result:typeof e=="number"&&(this.result-=e),this}mul(e){return e instanceof t?this.result*=e.result:typeof e=="number"&&(this.result*=e),this}div(e){return e instanceof t?this.result/=e.result:typeof e=="number"&&(this.result/=e),this}equal(){return this.result}}exports.default=t;
@@ -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 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class e{}exports.default=e;
@@ -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 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./CSSCalculator.js"),a=require("./NumCalculator.js");function o(e,t){const u=e==="css"?r.default:a.default;return l=>new u(l,t)}exports.default=o;
@@ -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 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./Theme.js"),a=require("./ThemeCache.js"),r=new a.default;function c(t){const e=Array.isArray(t)?t:[t];return r.has(e)||r.set(e,new u.default(e)),r.get(e)}exports.default=c;
@@ -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,12 +0,0 @@
1
- import { Transformer } from './interface';
2
- /**
3
- * Convert css logical properties to legacy properties.
4
- * Such as: `margin-block-start` to `margin-top`.
5
- * Transform list:
6
- * - inset
7
- * - margin
8
- * - padding
9
- * - border
10
- */
11
- declare const transform: Transformer;
12
- export default transform;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function s(e){if(typeof e=="number")return[[e],!1];const t=String(e).trim(),o=t.match(/(.*)(!important)/),i=(o?o[1]:t).trim().split(/\s+/);let r=[],d=0;return[i.reduce((l,n)=>{if(n.includes("(")||n.includes(")")){const a=n.split("(").length-1,p=n.split(")").length-1;d+=a-p}return d>=0&&r.push(n),d===0&&(l.push(r.join(" ")),r=[]),l},[]),!!o]}function b(e){return e.notSplit=!0,e}const c={inset:["top","right","bottom","left"],insetBlock:["top","bottom"],insetBlockStart:["top"],insetBlockEnd:["bottom"],insetInline:["left","right"],insetInlineStart:["left"],insetInlineEnd:["right"],marginBlock:["marginTop","marginBottom"],marginBlockStart:["marginTop"],marginBlockEnd:["marginBottom"],marginInline:["marginLeft","marginRight"],marginInlineStart:["marginLeft"],marginInlineEnd:["marginRight"],paddingBlock:["paddingTop","paddingBottom"],paddingBlockStart:["paddingTop"],paddingBlockEnd:["paddingBottom"],paddingInline:["paddingLeft","paddingRight"],paddingInlineStart:["paddingLeft"],paddingInlineEnd:["paddingRight"],borderBlock:b(["borderTop","borderBottom"]),borderBlockStart:b(["borderTop"]),borderBlockEnd:b(["borderBottom"]),borderInline:b(["borderLeft","borderRight"]),borderInlineStart:b(["borderLeft"]),borderInlineEnd:b(["borderRight"]),borderBlockWidth:["borderTopWidth","borderBottomWidth"],borderBlockStartWidth:["borderTopWidth"],borderBlockEndWidth:["borderBottomWidth"],borderInlineWidth:["borderLeftWidth","borderRightWidth"],borderInlineStartWidth:["borderLeftWidth"],borderInlineEndWidth:["borderRightWidth"],borderBlockStyle:["borderTopStyle","borderBottomStyle"],borderBlockStartStyle:["borderTopStyle"],borderBlockEndStyle:["borderBottomStyle"],borderInlineStyle:["borderLeftStyle","borderRightStyle"],borderInlineStartStyle:["borderLeftStyle"],borderInlineEndStyle:["borderRightStyle"],borderBlockColor:["borderTopColor","borderBottomColor"],borderBlockStartColor:["borderTopColor"],borderBlockEndColor:["borderBottomColor"],borderInlineColor:["borderLeftColor","borderRightColor"],borderInlineStartColor:["borderLeftColor"],borderInlineEndColor:["borderRightColor"],borderStartStartRadius:["borderTopLeftRadius"],borderStartEndRadius:["borderTopRightRadius"],borderEndStartRadius:["borderBottomLeftRadius"],borderEndEndRadius:["borderBottomRightRadius"]};function g(e,t){let o=e;return t&&(o=`${o} !important`),{_skip_check_:!0,value:o}}const h={visit:e=>{const t={};return Object.keys(e).forEach(o=>{const i=e[o],r=c[o];if(r&&(typeof i=="number"||typeof i=="string")){const[d,l]=s(i);r.length&&r.notSplit?r.forEach(n=>{t[n]=g(i,l)}):r.length===1?t[r[0]]=g(d[0],l):r.length===2?r.forEach((n,a)=>{t[n]=g(d[a]??d[0],l)}):r.length===4?r.forEach((n,a)=>{t[n]=g(d[a]??d[a-2]??d[0],l)}):t[o]=i}else t[o]=i}),t}};exports.default=h;