@zat-design/sisyphus-react 4.0.8 → 4.0.10
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/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/ProConfigProvider/index.d.ts +3 -45
- package/es/ProConfigProvider/index.js +23 -40
- package/es/ProConfigProvider/propsType.d.ts +55 -0
- package/es/ProConfigProvider/propsType.js +1 -0
- package/es/ProEnum/propsType.d.ts +0 -1
- package/es/ProForm/components/combination/Group/style/index.less +4 -2
- package/es/ProForm/components/combination/Group/utils/index.d.ts +17 -17
- package/es/ProForm/components/render/propsType.d.ts +2 -2
- package/es/ProIcon/index.js +183 -167
- package/es/ProLayout/components/ProFooter/index.js +1 -1
- package/es/ProLayout/index.js +1 -2
- package/es/ProStep/components/Step/index.js +1 -1
- package/es/ProStep/style/index.less +4 -2
- package/es/ProThemeTools/component/ProTools/index.js +108 -89
- package/es/ProThemeTools/context/ThemeContext.d.ts +10 -0
- package/es/ProThemeTools/context/ThemeContext.js +125 -9
- package/es/ProThemeTools/index.js +37 -12
- package/es/ProThemeTools/utils/index.d.ts +11 -1
- package/es/ProThemeTools/utils/index.js +120 -5
- package/es/index.d.ts +7 -6
- package/es/index.js +0 -1
- package/lib/ProConfigProvider/index.d.ts +3 -45
- package/lib/ProConfigProvider/index.js +23 -40
- package/lib/ProConfigProvider/propsType.d.ts +55 -0
- package/lib/ProConfigProvider/propsType.js +5 -0
- package/lib/ProEnum/propsType.d.ts +0 -1
- package/lib/ProForm/components/combination/Group/style/index.less +4 -2
- package/lib/ProForm/components/combination/Group/utils/index.d.ts +11 -11
- package/lib/ProForm/components/render/propsType.d.ts +2 -2
- package/lib/ProIcon/index.js +182 -168
- package/lib/ProLayout/components/ProFooter/index.js +1 -1
- package/lib/ProLayout/index.js +1 -2
- package/lib/ProStep/components/Step/index.js +1 -1
- package/lib/ProStep/style/index.less +4 -2
- package/lib/ProThemeTools/component/ProTools/index.js +108 -90
- package/lib/ProThemeTools/context/ThemeContext.d.ts +10 -0
- package/lib/ProThemeTools/context/ThemeContext.js +127 -10
- package/lib/ProThemeTools/index.js +35 -10
- package/lib/ProThemeTools/utils/index.d.ts +11 -1
- package/lib/ProThemeTools/utils/index.js +124 -6
- package/lib/index.d.ts +7 -6
- package/package.json +1 -1
|
@@ -3,12 +3,60 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setThemes = exports.setTableNoStripe = exports.setTableBorder = exports.getMapKebabCase = exports.getMapHumpCase = exports.getKebabCase = exports.getAntd5ThemeConfig = exports.convertToAntd5Tokens = void 0;
|
|
6
|
+
exports.setThemes = exports.setThemeUpdatersGetter = exports.setTableNoStripe = exports.setTableBorder = exports.getPendingThemes = exports.getMapKebabCase = exports.getMapHumpCase = exports.getKebabCase = exports.getAntd5ThemeConfig = exports.convertToAntd5Tokens = exports.clearPendingThemes = void 0;
|
|
7
|
+
var _ThemeContext = require("../context/ThemeContext");
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
16
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
11
18
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
+
// 动态导入 getThemeUpdaters,避免循环依赖
|
|
20
|
+
// 保留向后兼容性,但优先使用 ThemeContext 中的 getThemeUpdaters
|
|
21
|
+
var getThemeUpdaters = null;
|
|
22
|
+
|
|
23
|
+
// 设置 getThemeUpdaters 函数(由 index.tsx 调用,用于向后兼容)
|
|
24
|
+
var setThemeUpdatersGetter = getter => {
|
|
25
|
+
getThemeUpdaters = getter;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// 保存待应用的主题配置(用于 ThemeProvider 初始化前设置的主题)
|
|
29
|
+
exports.setThemeUpdatersGetter = setThemeUpdatersGetter;
|
|
30
|
+
var pendingThemes = null;
|
|
31
|
+
|
|
32
|
+
// 获取待应用的主题配置
|
|
33
|
+
var getPendingThemes = () => {
|
|
34
|
+
return pendingThemes;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// 清除待应用的主题配置
|
|
38
|
+
exports.getPendingThemes = getPendingThemes;
|
|
39
|
+
var clearPendingThemes = () => {
|
|
40
|
+
pendingThemes = null;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// 获取主题更新函数的统一入口
|
|
44
|
+
// 优先使用 ThemeContext 中的 getThemeUpdaters,如果不可用则使用局部变量
|
|
45
|
+
exports.clearPendingThemes = clearPendingThemes;
|
|
46
|
+
var getThemeUpdatersWrapper = () => {
|
|
47
|
+
try {
|
|
48
|
+
// 优先使用 ThemeContext 中的 getThemeUpdaters(不依赖 ProThemeTools 组件)
|
|
49
|
+
var contextUpdaters = (0, _ThemeContext.getThemeUpdaters)();
|
|
50
|
+
if (contextUpdaters && (contextUpdaters.updateAntdConfig || contextUpdaters.updateCssVariables || contextUpdaters.updateLocalConfig)) {
|
|
51
|
+
return contextUpdaters;
|
|
52
|
+
}
|
|
53
|
+
} catch (e) {
|
|
54
|
+
// ThemeContext 可能还未初始化,继续使用局部变量
|
|
55
|
+
}
|
|
56
|
+
// 回退到局部变量(向后兼容)
|
|
57
|
+
return getThemeUpdaters ? getThemeUpdaters() : null;
|
|
58
|
+
};
|
|
59
|
+
|
|
12
60
|
/** antd5 主题配置 mapping */
|
|
13
61
|
var antd5ConfigMapping = {
|
|
14
62
|
'zaui-brand': 'colorPrimary'
|
|
@@ -37,7 +85,8 @@ var convertToAntd5Tokens = (themes, themeMapping) => {
|
|
|
37
85
|
|
|
38
86
|
/**
|
|
39
87
|
* 设置主题变量 - antd5 兼容版本
|
|
40
|
-
*
|
|
88
|
+
* 设置 CSS 变量,并同步更新 Context 的 antdConfig
|
|
89
|
+
* @param themes 主题配置对象,会自动过滤掉 antdConfig
|
|
41
90
|
*/
|
|
42
91
|
exports.convertToAntd5Tokens = convertToAntd5Tokens;
|
|
43
92
|
var setThemes = themes => {
|
|
@@ -45,11 +94,80 @@ var setThemes = themes => {
|
|
|
45
94
|
return false;
|
|
46
95
|
}
|
|
47
96
|
|
|
48
|
-
//
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
97
|
+
// 过滤掉 antdConfig,它只用于 Ant Design ConfigProvider,不应作为 CSS 变量
|
|
98
|
+
var filteredThemes = Object.entries(themes).filter(_ref => {
|
|
99
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
100
|
+
key = _ref2[0];
|
|
101
|
+
return key !== 'antdConfig';
|
|
52
102
|
});
|
|
103
|
+
if (!filteredThemes.length) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 设置 CSS 变量
|
|
108
|
+
filteredThemes.forEach(_ref3 => {
|
|
109
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
110
|
+
key = _ref4[0],
|
|
111
|
+
value = _ref4[1];
|
|
112
|
+
// 确保值是字符串或数字,对象类型不应作为 CSS 变量
|
|
113
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
114
|
+
var cssVarName = `--${key}`;
|
|
115
|
+
var cssVarValue = String(value);
|
|
116
|
+
document.documentElement.style.setProperty(cssVarName, cssVarValue);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// 同步更新 Context(如果已注册)
|
|
121
|
+
// 使用统一的获取函数,优先使用 ThemeContext 中的更新函数
|
|
122
|
+
var updaters = getThemeUpdatersWrapper();
|
|
123
|
+
if (updaters) {
|
|
124
|
+
// 更新 CSS 变量到 Context
|
|
125
|
+
if (updaters.updateCssVariables) {
|
|
126
|
+
updaters.updateCssVariables(filteredThemes.reduce((acc, _ref5) => {
|
|
127
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
128
|
+
key = _ref6[0],
|
|
129
|
+
value = _ref6[1];
|
|
130
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
131
|
+
acc[key] = value;
|
|
132
|
+
}
|
|
133
|
+
return acc;
|
|
134
|
+
}, {}));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 如果设置了 zaui-brand,同步更新 antdConfig
|
|
138
|
+
var zauiBrand = themes['zaui-brand'];
|
|
139
|
+
if (zauiBrand && typeof zauiBrand === 'string' && updaters.updateAntdConfig) {
|
|
140
|
+
var antdConfig = convertToAntd5Tokens({
|
|
141
|
+
'zaui-brand': zauiBrand
|
|
142
|
+
});
|
|
143
|
+
updaters.updateAntdConfig(antdConfig);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 更新本地配置(将 kebab-case 转换为驼峰格式)
|
|
147
|
+
if (updaters.updateLocalConfig) {
|
|
148
|
+
var localConfig = {};
|
|
149
|
+
filteredThemes.forEach(_ref7 => {
|
|
150
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
151
|
+
key = _ref8[0],
|
|
152
|
+
value = _ref8[1];
|
|
153
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
154
|
+
// 将 kebab-case 转换为驼峰格式
|
|
155
|
+
var camelKey = key.replace(/-(\w)/g, (_, letter) => letter.toUpperCase());
|
|
156
|
+
if (camelKey === 'zauiBrand') {
|
|
157
|
+
localConfig.zauiBrand = value;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
if (Object.keys(localConfig).length > 0) {
|
|
162
|
+
updaters.updateLocalConfig(localConfig);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// 清除待应用的主题配置(因为已经应用了)
|
|
166
|
+
pendingThemes = null;
|
|
167
|
+
} else {
|
|
168
|
+
// 如果更新函数不可用,保存主题配置,等待 ThemeProvider 初始化后应用
|
|
169
|
+
pendingThemes = _objectSpread({}, themes);
|
|
170
|
+
}
|
|
53
171
|
return true;
|
|
54
172
|
};
|
|
55
173
|
|
package/lib/index.d.ts
CHANGED
|
@@ -27,20 +27,21 @@ export { default as ProAction } from './ProAction';
|
|
|
27
27
|
export * from './ProConfigProvider';
|
|
28
28
|
export * from './locale';
|
|
29
29
|
export { default as ProBackBtn } from './ProLayout/components/ProHeader/components/ProBackBtn';
|
|
30
|
+
export type { ProConfigProviderType } from './ProConfigProvider';
|
|
30
31
|
export type { ProFormType, ProColumnProps, ProFormColumnType } from './ProForm/propsType';
|
|
31
32
|
export type { ProFormComponentType } from './ProForm/components';
|
|
32
|
-
export type { ProTableType, ProTableColumnType, ProTableSummaryType, ProTableUseAntdTableType, ProTableProps, ProTableSummaryProps, ProTableColumn, UseAntdTableState } from './ProTable/propsType';
|
|
33
|
+
export type { ProTableType, ProTableColumnType, ProTableSummaryType, ProTableUseAntdTableType, ProTableProps, ProTableSummaryProps, ProTableColumn, UseAntdTableState, } from './ProTable/propsType';
|
|
33
34
|
export type { ProUploadType, ProUploadProps } from './ProUpload/propsType';
|
|
34
35
|
export type { ProTabsType, ProTabsItemType, ProTabsProps, ProTabsItemsProps } from './ProTabs/propType';
|
|
35
|
-
export type { BreadcrumbColumnType, SubDescribeColumnType, DescribeColumnType, ProHeaderType, ProHeaderProps, BreadcrumbColumnsProps, SubDescribeColumnsProps, DescribeColumnsProps } from './ProLayout/components/ProHeader/PropTypes';
|
|
36
|
+
export type { BreadcrumbColumnType, SubDescribeColumnType, DescribeColumnType, ProHeaderType, ProHeaderProps, BreadcrumbColumnsProps, SubDescribeColumnsProps, DescribeColumnsProps, } from './ProLayout/components/ProHeader/PropTypes';
|
|
36
37
|
export type { ProLayoutTabsInstance, AddTabParams, AddTabOptions } from './ProLayout/propTypes';
|
|
37
38
|
export type { ProTooltipType, ProTooltipProps } from './ProTooltip/propsType';
|
|
38
39
|
export type { ProIconType, ProIconProps } from './ProIcon/propsTypes';
|
|
39
40
|
export type { ProTreeType, ProTreeSelectType, ProTreeProps, PropTreeSelectProps } from './ProTree/propsType';
|
|
40
|
-
export type { ProTreeModalType, ProTreeModalActionType, ProTreeModalProps, ProTreeModalAction } from './ProTreeModal/propsType';
|
|
41
|
-
export type { ProEditTableType, ProEditTableColumnType, ProEditTableSummaryColumnType, ProEditTableSummaryConfigType, ProEditTableActionType, ProEditTableProps, ProEditTableColumnsProps, SummaryProps, SummaryColumnProps, BaseActionProps } from './ProEditTable/propsType';
|
|
42
|
-
export type { ProStepType, ProStepContextType, ProStepItemType, ProStepPropsType, ProStepItemPropsType } from './ProStep/propsType';
|
|
41
|
+
export type { ProTreeModalType, ProTreeModalActionType, ProTreeModalProps, ProTreeModalAction, } from './ProTreeModal/propsType';
|
|
42
|
+
export type { ProEditTableType, ProEditTableColumnType, ProEditTableSummaryColumnType, ProEditTableSummaryConfigType, ProEditTableActionType, ProEditTableProps, ProEditTableColumnsProps, SummaryProps, SummaryColumnProps, BaseActionProps, } from './ProEditTable/propsType';
|
|
43
|
+
export type { ProStepType, ProStepContextType, ProStepItemType, ProStepPropsType, ProStepItemPropsType, } from './ProStep/propsType';
|
|
43
44
|
export type { ProDrawerFormType, ProDrawerFormPropsType } from './ProDrawerForm/propsType';
|
|
44
|
-
export type { ProModalSelectType, ProModalSelectConfigType, ProModalSelectPropsType } from './ProForm/components/combination/ProModalSelect/propsType';
|
|
45
|
+
export type { ProModalSelectType, ProModalSelectConfigType, ProModalSelectPropsType, } from './ProForm/components/combination/ProModalSelect/propsType';
|
|
45
46
|
export type { ProStepTabType, ProStepTabResultType } from './ProStepTab/propsType';
|
|
46
47
|
export * from './tokens';
|