@antdv-next/cssinjs 1.0.0-alpha.2 → 1.0.0-beta.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.
- package/dist/StyleContext.d.ts +3 -3
- package/dist/StyleContext.js +12 -2
- package/dist/cssinjs-utils/util/genStyleUtils.d.ts +5 -5
- package/dist/hooks/useCacheToken.js +1 -1
- package/dist/hooks/useGlobalCache.js +1 -2
- package/dist/hooks/useStyleRegister.js +7 -5
- package/dist/index.js +1 -1
- package/dist/transformers/autoPrefix.js +1 -1
- package/dist/util/index.js +4 -1
- package/package.json +2 -2
package/dist/StyleContext.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Linter } from "./linters/interface.js";
|
|
2
2
|
import "./linters/index.js";
|
|
3
3
|
import { Entity, KeyType } from "./Cache.js";
|
|
4
|
-
import * as
|
|
4
|
+
import * as vue0 from "vue";
|
|
5
5
|
import { App, Ref } from "vue";
|
|
6
6
|
|
|
7
7
|
//#region src/StyleContext.d.ts
|
|
8
8
|
|
|
9
|
-
declare function createCache():
|
|
9
|
+
declare function createCache(): vue0.Raw<Entity>;
|
|
10
10
|
declare function useStyleContextProvide(props: Ref<StyleContextProps>): void;
|
|
11
11
|
declare function provideStyleContext(app: App, props: Ref<StyleContextProps>): void;
|
|
12
12
|
declare function useStyleContext(): Ref<{
|
|
@@ -114,6 +114,6 @@ interface StyleContextProps {
|
|
|
114
114
|
autoPrefix?: boolean;
|
|
115
115
|
}
|
|
116
116
|
type StyleProviderProps = StyleContextProps;
|
|
117
|
-
declare const StyleProvider:
|
|
117
|
+
declare const StyleProvider: vue0.DefineSetupFnComponent<Partial<StyleContextProps>, {}, {}, Partial<StyleContextProps> & {}, vue0.PublicProps>;
|
|
118
118
|
//#endregion
|
|
119
119
|
export { StyleProvider, StyleProviderProps, createCache, provideStyleContext, useStyleContext, useStyleContextProvide };
|
package/dist/StyleContext.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Cache_default from "./Cache.js";
|
|
2
|
+
import { AUTO_PREFIX } from "./transformers/autoPrefix.js";
|
|
2
3
|
import { computed, defineComponent, inject, markRaw, provide, ref } from "vue";
|
|
3
|
-
import defu from "defu";
|
|
4
4
|
|
|
5
5
|
//#region src/StyleContext.ts
|
|
6
6
|
const ATTR_TOKEN = "data-token-hash";
|
|
@@ -45,7 +45,17 @@ function useStyleContext() {
|
|
|
45
45
|
const StyleProvider = defineComponent((props, { slots }) => {
|
|
46
46
|
const parentContext = useStyleContext();
|
|
47
47
|
useStyleContextProvide(computed(() => {
|
|
48
|
-
|
|
48
|
+
const restProps = props;
|
|
49
|
+
const mergedContext = { ...parentContext.value };
|
|
50
|
+
Object.keys(restProps).forEach((key) => {
|
|
51
|
+
const value = restProps[key];
|
|
52
|
+
if (restProps[key] !== void 0) mergedContext[key] = value;
|
|
53
|
+
});
|
|
54
|
+
const { cache, transformers = [] } = restProps;
|
|
55
|
+
mergedContext.cache = mergedContext.cache || createCache();
|
|
56
|
+
mergedContext.defaultCache = !cache && parentContext.value?.defaultCache;
|
|
57
|
+
if (transformers.includes(AUTO_PREFIX)) mergedContext.autoPrefix = true;
|
|
58
|
+
return mergedContext;
|
|
49
59
|
}));
|
|
50
60
|
return () => {
|
|
51
61
|
return slots?.default?.();
|
|
@@ -6,7 +6,7 @@ import "../../index.js";
|
|
|
6
6
|
import { UseCSP } from "../hooks/useCSP.js";
|
|
7
7
|
import { UsePrefix } from "../hooks/usePrefix.js";
|
|
8
8
|
import { UseToken } from "../hooks/useToken.js";
|
|
9
|
-
import * as
|
|
9
|
+
import * as vue2 from "vue";
|
|
10
10
|
import { Ref, UnwrapRef } from "vue";
|
|
11
11
|
|
|
12
12
|
//#region src/cssinjs-utils/util/genStyleUtils.d.ts
|
|
@@ -85,7 +85,7 @@ declare function genStyleUtils<CompTokenMap extends TokenMap, AliasToken extends
|
|
|
85
85
|
* @default true
|
|
86
86
|
*/
|
|
87
87
|
injectStyle?: boolean;
|
|
88
|
-
}) => (prefixCls: Ref<string>, rootCls?: Ref<string | undefined>) => readonly [Ref<string, string>,
|
|
88
|
+
}) => (prefixCls: Ref<string>, rootCls?: Ref<string | undefined>) => readonly [Ref<string, string>, vue2.ComputedRef<string | undefined>];
|
|
89
89
|
genSubStyleComponent: <C extends TokenMapKey<CompTokenMap>>(componentName: C | [C, string], styleFn: GenStyleFn<CompTokenMap, AliasToken, C>, getDefaultToken?: GetDefaultToken<CompTokenMap, AliasToken, C>, options?: {
|
|
90
90
|
resetStyle?: boolean;
|
|
91
91
|
resetFont?: boolean;
|
|
@@ -100,13 +100,13 @@ declare function genStyleUtils<CompTokenMap extends TokenMap, AliasToken extends
|
|
|
100
100
|
order?: number;
|
|
101
101
|
injectStyle?: boolean;
|
|
102
102
|
unitless?: Partial<Record<ComponentTokenKey<CompTokenMap, AliasToken, C>, boolean>>;
|
|
103
|
-
}) =>
|
|
103
|
+
}) => vue2.DefineComponent<vue2.ExtractPropTypes<{
|
|
104
104
|
prefixCls: StringConstructor;
|
|
105
105
|
rootCls: StringConstructor;
|
|
106
|
-
}>, () => null, {}, {}, {},
|
|
106
|
+
}>, () => null, {}, {}, {}, vue2.ComponentOptionsMixin, vue2.ComponentOptionsMixin, {}, string, vue2.PublicProps, Readonly<vue2.ExtractPropTypes<{
|
|
107
107
|
prefixCls: StringConstructor;
|
|
108
108
|
rootCls: StringConstructor;
|
|
109
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string,
|
|
109
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue2.ComponentProvideOptions, true, {}, any>;
|
|
110
110
|
genComponentStyleHook: <C extends TokenMapKey<CompTokenMap>>(componentName: C | [C, string], styleFn: GenStyleFn<CompTokenMap, AliasToken, C>, getDefaultToken?: GetDefaultToken<CompTokenMap, AliasToken, C>, options?: {
|
|
111
111
|
resetStyle?: boolean;
|
|
112
112
|
resetFont?: boolean;
|
|
@@ -86,7 +86,7 @@ function useCacheToken(theme, tokens, option) {
|
|
|
86
86
|
const actualToken = { ...mergedDerivativeToken };
|
|
87
87
|
const mergedSalt = `${salt.value}_${cssVar.value.prefix || ""}`;
|
|
88
88
|
const hashId = hash(mergedSalt);
|
|
89
|
-
const hashCls = `${hashPrefix}-${
|
|
89
|
+
const hashCls = `${hashPrefix}-${hashId}`;
|
|
90
90
|
actualToken._tokenKey = token2key(actualToken, mergedSalt);
|
|
91
91
|
const [tokenWithCssVar, cssVarsStr] = transformToken(mergedDerivativeToken, cssVar.value.key, {
|
|
92
92
|
prefix: cssVar.value.prefix,
|
|
@@ -3,7 +3,6 @@ import { useStyleContext } from "../StyleContext.js";
|
|
|
3
3
|
import { computed, watch } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/useGlobalCache.ts
|
|
6
|
-
const isDev = process.env.NODE_ENV !== "production";
|
|
7
6
|
const effectMap = /* @__PURE__ */ new Map();
|
|
8
7
|
/**
|
|
9
8
|
* Global cache for CSS-in-JS styles
|
|
@@ -32,7 +31,7 @@ function useGlobalCache(prefix, keyPath, cacheFn, onCacheRemove, onCacheEffect)
|
|
|
32
31
|
buildCache();
|
|
33
32
|
const cacheContent = computed(() => {
|
|
34
33
|
let entity = styleContext.value.cache.opGet(fullPathStr.value);
|
|
35
|
-
if (
|
|
34
|
+
if (!entity) {
|
|
36
35
|
buildCache();
|
|
37
36
|
entity = getCacheEntity();
|
|
38
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ATTR_CACHE_PATH, ATTR_MARK, CSS_IN_JS_INSTANCE, useStyleContext } from "../StyleContext.js";
|
|
2
|
-
import { isClientSide, toStyleStr } from "../util/index.js";
|
|
2
|
+
import { isClientSide, isNonNullable, toStyleStr, where } from "../util/index.js";
|
|
3
3
|
import { useGlobalCache } from "./useGlobalCache.js";
|
|
4
4
|
import contentQuotesLinter_default from "../linters/contentQuotesLinter.js";
|
|
5
5
|
import hashedAnimationLinter_default from "../linters/hashedAnimationLinter.js";
|
|
@@ -21,10 +21,12 @@ function normalizeStyle(styleStr, autoPrefix) {
|
|
|
21
21
|
function isCompoundCSSProperty(value) {
|
|
22
22
|
return typeof value === "object" && value && (SKIP_CHECK in value || MULTI_VALUE in value);
|
|
23
23
|
}
|
|
24
|
-
function injectSelectorHash(key, hashId, hashPriority) {
|
|
24
|
+
function injectSelectorHash(key, hashId, hashPriority = "high") {
|
|
25
25
|
if (!hashId) return key;
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const hashSelector = where({
|
|
27
|
+
hashCls: hashId,
|
|
28
|
+
hashPriority
|
|
29
|
+
});
|
|
28
30
|
return key.split(",").map((k) => {
|
|
29
31
|
const fullPath = k.trim().split(/\s+/);
|
|
30
32
|
let firstPath = fullPath[0] || "";
|
|
@@ -110,7 +112,7 @@ function parseStyle(interpolation, config = {}, { root, injectHash, parentSelect
|
|
|
110
112
|
if (typeof value === "object" && value?.[MULTI_VALUE] && Array.isArray(actualValue)) actualValue.forEach((item) => {
|
|
111
113
|
appendStyle(key, item);
|
|
112
114
|
});
|
|
113
|
-
else appendStyle(key, actualValue);
|
|
115
|
+
else if (isNonNullable(actualValue)) appendStyle(key, actualValue);
|
|
114
116
|
}
|
|
115
117
|
});
|
|
116
118
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { collectStyleText, setStyleCollector } from "./ssr/styleCollector.js";
|
|
2
|
+
import autoPrefix_default from "./transformers/autoPrefix.js";
|
|
2
3
|
import { StyleProvider, createCache, provideStyleContext, useStyleContext, useStyleContextProvide } from "./StyleContext.js";
|
|
3
4
|
import calc_default from "./theme/calc/index.js";
|
|
4
5
|
import Theme from "./theme/Theme.js";
|
|
@@ -16,7 +17,6 @@ import useStyleRegister from "./hooks/useStyleRegister.js";
|
|
|
16
17
|
import useCSSVarRegister from "./hooks/useCSSVarRegister.js";
|
|
17
18
|
import extractStyle from "./extractStyle.js";
|
|
18
19
|
import Keyframes_default from "./Keyframes.js";
|
|
19
|
-
import autoPrefix_default from "./transformers/autoPrefix.js";
|
|
20
20
|
import legacyLogicalProperties_default from "./transformers/legacyLogicalProperties.js";
|
|
21
21
|
import px2rem_default from "./transformers/px2rem.js";
|
|
22
22
|
import statistic_default, { merge, statistic } from "./cssinjs-utils/util/statistic.js";
|
package/dist/util/index.js
CHANGED
|
@@ -103,6 +103,9 @@ function where(options) {
|
|
|
103
103
|
const hashSelector = `.${hashCls}`;
|
|
104
104
|
return hashPriority === "low" ? `:where(${hashSelector})` : hashSelector;
|
|
105
105
|
}
|
|
106
|
+
function isNonNullable(val) {
|
|
107
|
+
return val !== void 0 && val !== null;
|
|
108
|
+
}
|
|
106
109
|
|
|
107
110
|
//#endregion
|
|
108
|
-
export { flattenToken, isClientSide, memoResult, supportLogicProps, supportWhere, toStyleStr, token2key, unit, where };
|
|
111
|
+
export { flattenToken, isClientSide, isNonNullable, memoResult, supportLogicProps, supportWhere, toStyleStr, token2key, unit, where };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antdv-next/cssinjs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-
|
|
4
|
+
"version": "1.0.0-beta.1",
|
|
5
5
|
"description": "cssinjs solution for ant-design-vue",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@emotion/hash": "^0.8.0",
|
|
32
32
|
"@emotion/unitless": "^0.7.5",
|
|
33
|
-
"@v-c/util": "^1.0.
|
|
33
|
+
"@v-c/util": "^1.0.8",
|
|
34
34
|
"csstype": "^3.2.3",
|
|
35
35
|
"defu": "^6.1.4",
|
|
36
36
|
"stylis": "^4.3.6"
|