@bifrostui/utils 2.0.0-alpha.5 → 2.0.0-alpha.6
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.
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { CssVarToValueOptions } from './index.types';
|
|
2
|
+
/**
|
|
3
|
+
* 设置全局默认主题变量
|
|
4
|
+
* 建议在小程序入口文件(app.ts)中调用,设置后所有组件都会使用该主题
|
|
5
|
+
* 支持主题继承:如果设置的主题中某个变量不存在,会自动从 defaultLight 继承
|
|
6
|
+
* @param themeVars 主题CSS变量对象
|
|
7
|
+
* @example
|
|
8
|
+
* import { setDefaultThemeVars } from '@bifrostui/utils';
|
|
9
|
+
* import { pioneerLight } from '@bifrostui/styles/registry';
|
|
10
|
+
* setDefaultThemeVars(pioneerLight.cssVars);
|
|
11
|
+
*/
|
|
12
|
+
export declare const setDefaultThemeVars: (themeVars: Record<string, string> | undefined) => void;
|
|
13
|
+
/**
|
|
14
|
+
* 获取当前全局默认主题变量
|
|
15
|
+
* 返回合并后的主题变量(自定义主题 + defaultLight 基础主题)
|
|
16
|
+
*/
|
|
17
|
+
export declare const getDefaultThemeVars: () => Record<string, string> | undefined;
|
|
2
18
|
/**
|
|
3
19
|
* css变量转值
|
|
4
20
|
*/
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
5
19
|
var __export = (target, all) => {
|
|
6
20
|
for (var name in all)
|
|
7
21
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,15 +31,27 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
32
|
var cssVarToValue_exports = {};
|
|
19
33
|
__export(cssVarToValue_exports, {
|
|
20
|
-
cssVarToValue: () => cssVarToValue
|
|
34
|
+
cssVarToValue: () => cssVarToValue,
|
|
35
|
+
getDefaultThemeVars: () => getDefaultThemeVars,
|
|
36
|
+
setDefaultThemeVars: () => setDefaultThemeVars
|
|
21
37
|
});
|
|
22
38
|
module.exports = __toCommonJS(cssVarToValue_exports);
|
|
23
39
|
var import_registry = require("@bifrostui/styles/registry");
|
|
40
|
+
let globalDefaultThemeVars;
|
|
41
|
+
const setDefaultThemeVars = (themeVars) => {
|
|
42
|
+
globalDefaultThemeVars = themeVars;
|
|
43
|
+
};
|
|
44
|
+
const getDefaultThemeVars = () => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
if (!globalDefaultThemeVars) {
|
|
47
|
+
return (_a = import_registry.defaultLight) == null ? void 0 : _a.cssVars;
|
|
48
|
+
}
|
|
49
|
+
return __spreadValues(__spreadValues({}, (_b = import_registry.defaultLight) == null ? void 0 : _b.cssVars), globalDefaultThemeVars);
|
|
50
|
+
};
|
|
24
51
|
const cssVarToValue = (options) => {
|
|
25
|
-
var _a;
|
|
26
52
|
const {
|
|
27
53
|
cssVar,
|
|
28
|
-
themeVars = (
|
|
54
|
+
themeVars = getDefaultThemeVars(),
|
|
29
55
|
_visitedKeys = /* @__PURE__ */ new Set()
|
|
30
56
|
} = options || {};
|
|
31
57
|
if (!cssVar)
|
|
@@ -48,5 +74,7 @@ const cssVarToValue = (options) => {
|
|
|
48
74
|
};
|
|
49
75
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
76
|
0 && (module.exports = {
|
|
51
|
-
cssVarToValue
|
|
77
|
+
cssVarToValue,
|
|
78
|
+
getDefaultThemeVars,
|
|
79
|
+
setDefaultThemeVars
|
|
52
80
|
});
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { CssVarToValueOptions } from './index.types';
|
|
2
|
+
/**
|
|
3
|
+
* 设置全局默认主题变量
|
|
4
|
+
* 建议在小程序入口文件(app.ts)中调用,设置后所有组件都会使用该主题
|
|
5
|
+
* 支持主题继承:如果设置的主题中某个变量不存在,会自动从 defaultLight 继承
|
|
6
|
+
* @param themeVars 主题CSS变量对象
|
|
7
|
+
* @example
|
|
8
|
+
* import { setDefaultThemeVars } from '@bifrostui/utils';
|
|
9
|
+
* import { pioneerLight } from '@bifrostui/styles/registry';
|
|
10
|
+
* setDefaultThemeVars(pioneerLight.cssVars);
|
|
11
|
+
*/
|
|
12
|
+
export declare const setDefaultThemeVars: (themeVars: Record<string, string> | undefined) => void;
|
|
13
|
+
/**
|
|
14
|
+
* 获取当前全局默认主题变量
|
|
15
|
+
* 返回合并后的主题变量(自定义主题 + defaultLight 基础主题)
|
|
16
|
+
*/
|
|
17
|
+
export declare const getDefaultThemeVars: () => Record<string, string> | undefined;
|
|
2
18
|
/**
|
|
3
19
|
* css变量转值
|
|
4
20
|
*/
|
|
@@ -1,9 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
1
17
|
import { defaultLight } from "@bifrostui/styles/registry";
|
|
18
|
+
let globalDefaultThemeVars;
|
|
19
|
+
const setDefaultThemeVars = (themeVars) => {
|
|
20
|
+
globalDefaultThemeVars = themeVars;
|
|
21
|
+
};
|
|
22
|
+
const getDefaultThemeVars = () => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
if (!globalDefaultThemeVars) {
|
|
25
|
+
return (_a = defaultLight) == null ? void 0 : _a.cssVars;
|
|
26
|
+
}
|
|
27
|
+
return __spreadValues(__spreadValues({}, (_b = defaultLight) == null ? void 0 : _b.cssVars), globalDefaultThemeVars);
|
|
28
|
+
};
|
|
2
29
|
const cssVarToValue = (options) => {
|
|
3
|
-
var _a;
|
|
4
30
|
const {
|
|
5
31
|
cssVar,
|
|
6
|
-
themeVars = (
|
|
32
|
+
themeVars = getDefaultThemeVars(),
|
|
7
33
|
_visitedKeys = /* @__PURE__ */ new Set()
|
|
8
34
|
} = options || {};
|
|
9
35
|
if (!cssVar)
|
|
@@ -25,5 +51,7 @@ const cssVarToValue = (options) => {
|
|
|
25
51
|
return variableValue;
|
|
26
52
|
};
|
|
27
53
|
export {
|
|
28
|
-
cssVarToValue
|
|
54
|
+
cssVarToValue,
|
|
55
|
+
getDefaultThemeVars,
|
|
56
|
+
setDefaultThemeVars
|
|
29
57
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bifrostui/utils",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.6",
|
|
4
4
|
"description": "BUI React utilities for building components.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"react-is": "^18.0.0",
|
|
20
|
-
"@bifrostui/styles": "2.0.0-alpha.
|
|
20
|
+
"@bifrostui/styles": "2.0.0-alpha.6"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@tarojs/runtime": "^3.0.0",
|