@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.
Files changed (44) hide show
  1. package/dist/index.esm.css +1 -1
  2. package/dist/less.esm.css +1 -1
  3. package/es/ProConfigProvider/index.d.ts +3 -45
  4. package/es/ProConfigProvider/index.js +23 -40
  5. package/es/ProConfigProvider/propsType.d.ts +55 -0
  6. package/es/ProConfigProvider/propsType.js +1 -0
  7. package/es/ProEnum/propsType.d.ts +0 -1
  8. package/es/ProForm/components/combination/Group/style/index.less +4 -2
  9. package/es/ProForm/components/combination/Group/utils/index.d.ts +17 -17
  10. package/es/ProForm/components/render/propsType.d.ts +2 -2
  11. package/es/ProIcon/index.js +183 -167
  12. package/es/ProLayout/components/ProFooter/index.js +1 -1
  13. package/es/ProLayout/index.js +1 -2
  14. package/es/ProStep/components/Step/index.js +1 -1
  15. package/es/ProStep/style/index.less +4 -2
  16. package/es/ProThemeTools/component/ProTools/index.js +108 -89
  17. package/es/ProThemeTools/context/ThemeContext.d.ts +10 -0
  18. package/es/ProThemeTools/context/ThemeContext.js +125 -9
  19. package/es/ProThemeTools/index.js +37 -12
  20. package/es/ProThemeTools/utils/index.d.ts +11 -1
  21. package/es/ProThemeTools/utils/index.js +120 -5
  22. package/es/index.d.ts +7 -6
  23. package/es/index.js +0 -1
  24. package/lib/ProConfigProvider/index.d.ts +3 -45
  25. package/lib/ProConfigProvider/index.js +23 -40
  26. package/lib/ProConfigProvider/propsType.d.ts +55 -0
  27. package/lib/ProConfigProvider/propsType.js +5 -0
  28. package/lib/ProEnum/propsType.d.ts +0 -1
  29. package/lib/ProForm/components/combination/Group/style/index.less +4 -2
  30. package/lib/ProForm/components/combination/Group/utils/index.d.ts +11 -11
  31. package/lib/ProForm/components/render/propsType.d.ts +2 -2
  32. package/lib/ProIcon/index.js +182 -168
  33. package/lib/ProLayout/components/ProFooter/index.js +1 -1
  34. package/lib/ProLayout/index.js +1 -2
  35. package/lib/ProStep/components/Step/index.js +1 -1
  36. package/lib/ProStep/style/index.less +4 -2
  37. package/lib/ProThemeTools/component/ProTools/index.js +108 -90
  38. package/lib/ProThemeTools/context/ThemeContext.d.ts +10 -0
  39. package/lib/ProThemeTools/context/ThemeContext.js +127 -10
  40. package/lib/ProThemeTools/index.js +35 -10
  41. package/lib/ProThemeTools/utils/index.d.ts +11 -1
  42. package/lib/ProThemeTools/utils/index.js +124 -6
  43. package/lib/index.d.ts +7 -6
  44. package/package.json +1 -1
@@ -1,8 +1,53 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  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; }
2
8
  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; }
3
9
  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; }
4
10
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
5
11
  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); }
12
+ import { getThemeUpdaters as getThemeUpdatersFromContext } from "../context/ThemeContext";
13
+ // 动态导入 getThemeUpdaters,避免循环依赖
14
+ // 保留向后兼容性,但优先使用 ThemeContext 中的 getThemeUpdaters
15
+ var getThemeUpdaters = null;
16
+
17
+ // 设置 getThemeUpdaters 函数(由 index.tsx 调用,用于向后兼容)
18
+ export var setThemeUpdatersGetter = getter => {
19
+ getThemeUpdaters = getter;
20
+ };
21
+
22
+ // 保存待应用的主题配置(用于 ThemeProvider 初始化前设置的主题)
23
+ var pendingThemes = null;
24
+
25
+ // 获取待应用的主题配置
26
+ export var getPendingThemes = () => {
27
+ return pendingThemes;
28
+ };
29
+
30
+ // 清除待应用的主题配置
31
+ export var clearPendingThemes = () => {
32
+ pendingThemes = null;
33
+ };
34
+
35
+ // 获取主题更新函数的统一入口
36
+ // 优先使用 ThemeContext 中的 getThemeUpdaters,如果不可用则使用局部变量
37
+ var getThemeUpdatersWrapper = () => {
38
+ try {
39
+ // 优先使用 ThemeContext 中的 getThemeUpdaters(不依赖 ProThemeTools 组件)
40
+ var contextUpdaters = getThemeUpdatersFromContext();
41
+ if (contextUpdaters && (contextUpdaters.updateAntdConfig || contextUpdaters.updateCssVariables || contextUpdaters.updateLocalConfig)) {
42
+ return contextUpdaters;
43
+ }
44
+ } catch (e) {
45
+ // ThemeContext 可能还未初始化,继续使用局部变量
46
+ }
47
+ // 回退到局部变量(向后兼容)
48
+ return getThemeUpdaters ? getThemeUpdaters() : null;
49
+ };
50
+
6
51
  /** antd5 主题配置 mapping */
7
52
  var antd5ConfigMapping = {
8
53
  'zaui-brand': 'colorPrimary'
@@ -31,18 +76,88 @@ export var convertToAntd5Tokens = (themes, themeMapping) => {
31
76
 
32
77
  /**
33
78
  * 设置主题变量 - antd5 兼容版本
34
- * 只设置 CSS 变量,不再使用 ConfigProvider.config
79
+ * 设置 CSS 变量,并同步更新 Context 的 antdConfig
80
+ * @param themes 主题配置对象,会自动过滤掉 antdConfig
35
81
  */
36
82
  export var setThemes = themes => {
37
83
  if (!themes || !Object.keys(themes).length) {
38
84
  return false;
39
85
  }
40
86
 
41
- // 只设置 CSS 变量,主题配置通过 Context 管理
42
- var list = Object.entries(themes);
43
- list.forEach(item => {
44
- document.documentElement.style.setProperty(`--${item[0]}`, item[1]);
87
+ // 过滤掉 antdConfig,它只用于 Ant Design ConfigProvider,不应作为 CSS 变量
88
+ var filteredThemes = Object.entries(themes).filter(_ref => {
89
+ var _ref2 = _slicedToArray(_ref, 1),
90
+ key = _ref2[0];
91
+ return key !== 'antdConfig';
45
92
  });
93
+ if (!filteredThemes.length) {
94
+ return false;
95
+ }
96
+
97
+ // 设置 CSS 变量
98
+ filteredThemes.forEach(_ref3 => {
99
+ var _ref4 = _slicedToArray(_ref3, 2),
100
+ key = _ref4[0],
101
+ value = _ref4[1];
102
+ // 确保值是字符串或数字,对象类型不应作为 CSS 变量
103
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
104
+ var cssVarName = `--${key}`;
105
+ var cssVarValue = String(value);
106
+ document.documentElement.style.setProperty(cssVarName, cssVarValue);
107
+ }
108
+ });
109
+
110
+ // 同步更新 Context(如果已注册)
111
+ // 使用统一的获取函数,优先使用 ThemeContext 中的更新函数
112
+ var updaters = getThemeUpdatersWrapper();
113
+ if (updaters) {
114
+ // 更新 CSS 变量到 Context
115
+ if (updaters.updateCssVariables) {
116
+ updaters.updateCssVariables(filteredThemes.reduce((acc, _ref5) => {
117
+ var _ref6 = _slicedToArray(_ref5, 2),
118
+ key = _ref6[0],
119
+ value = _ref6[1];
120
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
121
+ acc[key] = value;
122
+ }
123
+ return acc;
124
+ }, {}));
125
+ }
126
+
127
+ // 如果设置了 zaui-brand,同步更新 antdConfig
128
+ var zauiBrand = themes['zaui-brand'];
129
+ if (zauiBrand && typeof zauiBrand === 'string' && updaters.updateAntdConfig) {
130
+ var antdConfig = convertToAntd5Tokens({
131
+ 'zaui-brand': zauiBrand
132
+ });
133
+ updaters.updateAntdConfig(antdConfig);
134
+ }
135
+
136
+ // 更新本地配置(将 kebab-case 转换为驼峰格式)
137
+ if (updaters.updateLocalConfig) {
138
+ var localConfig = {};
139
+ filteredThemes.forEach(_ref7 => {
140
+ var _ref8 = _slicedToArray(_ref7, 2),
141
+ key = _ref8[0],
142
+ value = _ref8[1];
143
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
144
+ // 将 kebab-case 转换为驼峰格式
145
+ var camelKey = key.replace(/-(\w)/g, (_, letter) => letter.toUpperCase());
146
+ if (camelKey === 'zauiBrand') {
147
+ localConfig.zauiBrand = value;
148
+ }
149
+ }
150
+ });
151
+ if (Object.keys(localConfig).length > 0) {
152
+ updaters.updateLocalConfig(localConfig);
153
+ }
154
+ }
155
+ // 清除待应用的主题配置(因为已经应用了)
156
+ pendingThemes = null;
157
+ } else {
158
+ // 如果更新函数不可用,保存主题配置,等待 ThemeProvider 初始化后应用
159
+ pendingThemes = _objectSpread({}, themes);
160
+ }
46
161
  return true;
47
162
  };
48
163
 
package/es/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';
package/es/index.js CHANGED
@@ -39,7 +39,6 @@ export * from "./ProConfigProvider";
39
39
  export * from "./locale";
40
40
  export { default as ProBackBtn } from "./ProLayout/components/ProHeader/components/ProBackBtn";
41
41
 
42
- // TS类型导出
43
42
  // TS类型导出
44
43
 
45
44
  // token导出
@@ -1,51 +1,9 @@
1
1
  import React, { FC } from 'react';
2
- import { FormInstance } from 'antd';
3
2
  import 'dayjs/locale/zh-cn';
4
- import type { PropSelectType } from '../ProSelect/propsType';
5
- import type { ProModalSelectType } from '../ProForm/components/combination/ProModalSelect/propsType';
6
- import type { ProCascaderType } from '../ProForm/components/combination/ProCascader/propsType';
7
- import type { ProEnumConfig } from '../ProEnum/propsType';
8
- export interface ProConfigState {
9
- locale?: string;
10
- ProEnum?: Partial<ProEnumConfig>;
11
- ProSelect?: Partial<PropSelectType> & Record<string, any>;
12
- ProModalSelect?: Partial<ProModalSelectType> & Record<string, any>;
13
- ProAddressBar?: Partial<ProCascaderType> & Record<string, any>;
14
- forms: Record<string, FormInstance | undefined>;
15
- [key: string]: any;
16
- }
17
- interface ConfigContext {
18
- state: ProConfigState;
19
- dispatch: React.Dispatch<Actions>;
20
- }
3
+ import type { ProConfigProviderProps, ConfigContext } from './propsType';
21
4
  export declare const ProConfigContext: React.Context<ConfigContext>;
22
5
  export declare function useProConfig(): ConfigContext;
23
6
  export declare function useProConfig(name: keyof ConfigContext['state']): ConfigContext['state'][keyof ConfigContext['state']];
24
- type Actions = {
25
- type: 'setFormRef';
26
- name: string;
27
- value: FormInstance;
28
- } | {
29
- type: 'deleteFormRef';
30
- name: string;
31
- } | {
32
- type: 'set';
33
- payload: ProConfigState;
34
- } | {
35
- type: 'setProEnum';
36
- payload: Record<string, any>;
37
- } | {
38
- type: 'setProEnumDic';
39
- key: string;
40
- payload: any;
41
- } | {
42
- type: 'setWithLocal';
43
- payload: ProConfigState;
44
- };
45
- export declare const ProConfigProvider: FC<{
46
- value?: ProConfigState;
47
- locale?: string;
48
- onSuccess?: (data: any, params: any) => void;
49
- children?: React.ReactNode;
50
- }>;
7
+ export declare const ProConfigProvider: FC<ProConfigProviderProps>;
8
+ export type { ProConfigProviderType, ProConfigProviderProps } from './propsType';
51
9
  export default ProConfigProvider;
@@ -47,38 +47,36 @@ var initialState = {
47
47
  }]
48
48
  }
49
49
  };
50
+ var antdLangMap = {
51
+ 'zh-CN': _zh_CN.default,
52
+ 'en-US': _en_US.default
53
+ };
50
54
  var ProConfigContext = exports.ProConfigContext = /*#__PURE__*/_react.default.createContext({
51
55
  state: initialState,
52
56
  dispatch: () => {}
53
57
  });
54
-
55
- // eslint-disable-next-line no-redeclare
56
-
57
- // eslint-disable-next-line no-redeclare
58
58
  function useProConfig(name) {
59
59
  var _useContext = (0, _react.useContext)(ProConfigContext),
60
60
  state = _useContext.state,
61
61
  dispatch = _useContext.dispatch;
62
- if (name) {
63
- return state[name];
64
- }
62
+ if (name) return state[name];
65
63
  return {
66
64
  state,
67
65
  dispatch
68
66
  };
69
67
  }
70
- var reducer = (state, action) => {
71
- var _state$ProEnum;
68
+ function reducer(state, action) {
69
+ var _state$forms, _state$forms2, _state$ProEnum$dics, _state$ProEnum;
72
70
  switch (action.type) {
73
71
  case 'setFormRef':
74
72
  return _objectSpread(_objectSpread({}, state), {}, {
75
- forms: _objectSpread(_objectSpread({}, state.forms), {}, {
73
+ forms: _objectSpread(_objectSpread({}, (_state$forms = state.forms) !== null && _state$forms !== void 0 ? _state$forms : {}), {}, {
76
74
  [action.name]: action.value
77
75
  })
78
76
  });
79
77
  case 'deleteFormRef':
80
78
  return _objectSpread(_objectSpread({}, state), {}, {
81
- forms: _objectSpread(_objectSpread({}, state.forms), {}, {
79
+ forms: _objectSpread(_objectSpread({}, (_state$forms2 = state.forms) !== null && _state$forms2 !== void 0 ? _state$forms2 : {}), {}, {
82
80
  [action.name]: undefined
83
81
  })
84
82
  });
@@ -91,19 +89,16 @@ var reducer = (state, action) => {
91
89
  case 'setProEnumDic':
92
90
  return _objectSpread(_objectSpread({}, state), {}, {
93
91
  ProEnum: _objectSpread(_objectSpread({}, state.ProEnum), {}, {
94
- dics: _objectSpread(_objectSpread({}, ((_state$ProEnum = state.ProEnum) === null || _state$ProEnum === void 0 ? void 0 : _state$ProEnum.dataSource) || {}), action.payload)
92
+ dics: _objectSpread(_objectSpread({}, (_state$ProEnum$dics = (_state$ProEnum = state.ProEnum) === null || _state$ProEnum === void 0 ? void 0 : _state$ProEnum.dics) !== null && _state$ProEnum$dics !== void 0 ? _state$ProEnum$dics : {}), action.payload)
95
93
  })
96
94
  });
97
95
  case 'setWithLocal':
98
- // 本地配置合并
99
96
  localStorage.setItem('localConfig', JSON.stringify(action.payload));
100
97
  return _objectSpread({}, state);
101
98
  default:
102
- return _objectSpread({}, state);
99
+ return state;
103
100
  }
104
- };
105
-
106
- // 内部组件,用于监听主题变化并应用到 ConfigProvider
101
+ }
107
102
  var ThemeAwareConfigProvider = _ref => {
108
103
  var locale = _ref.locale,
109
104
  children = _ref.children;
@@ -118,45 +113,33 @@ var ThemeAwareConfigProvider = _ref => {
118
113
  });
119
114
  };
120
115
  var ProConfigProvider = props => {
121
- var _props$value, _props$value2, _props$value3, _props$value4;
116
+ var _props$value, _props$value2, _props$value3, _props$value4, _ref2, _ref3, _state$locale, _antdLangMap$lang;
122
117
  var _useReducer = (0, _react.useReducer)(reducer, initialState),
123
118
  _useReducer2 = _slicedToArray(_useReducer, 2),
124
119
  state = _useReducer2[0],
125
120
  dispatch = _useReducer2[1];
126
121
  var enumRes = (0, _useEnumRequest.default)(_objectSpread(_objectSpread(_objectSpread({}, state.ProEnum), props === null || props === void 0 || (_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.ProEnum), props === null || props === void 0 || (_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.globalConfig), dispatch);
127
-
128
- // 处理频繁枚举请求
129
122
  var frequentEnumRes = (0, _useFrequentEnumRequest.default)(_objectSpread(_objectSpread(_objectSpread({}, state.ProEnum), props === null || props === void 0 || (_props$value3 = props.value) === null || _props$value3 === void 0 ? void 0 : _props$value3.ProEnum), props === null || props === void 0 || (_props$value4 = props.value) === null || _props$value4 === void 0 ? void 0 : _props$value4.globalConfig), dispatch);
123
+ var cacheLang = localStorage.getItem('locale');
124
+ var lang = (_ref2 = (_ref3 = (_state$locale = state === null || state === void 0 ? void 0 : state.locale) !== null && _state$locale !== void 0 ? _state$locale : cacheLang) !== null && _ref3 !== void 0 ? _ref3 : props === null || props === void 0 ? void 0 : props.locale) !== null && _ref2 !== void 0 ? _ref2 : 'zh-CN';
130
125
  (0, _react.useEffect)(() => {
131
- // 本地配置取出
132
- var localConfigStr = localStorage.getItem('localConfig');
133
- var localConfig = JSON.parse(localConfigStr || '{}');
126
+ var raw = localStorage.getItem('localConfig');
127
+ var localConfig = JSON.parse(raw || '{}');
134
128
  dispatch({
135
129
  type: 'set',
136
- payload: (0, _merge.default)(state, localConfig)
130
+ payload: (0, _merge.default)(initialState, localConfig)
137
131
  });
138
132
  }, []);
139
- var cacheLang = localStorage.getItem('locale');
140
- // 如果是用户切换了语言那么优先使用用户切换的,否则从缓存中取用户语言,在取默认值
141
- var lang = (state === null || state === void 0 ? void 0 : state.locale) || cacheLang || (props === null || props === void 0 ? void 0 : props.locale);
142
133
  (0, _react.useEffect)(() => {
143
134
  (0, _locale.setLanguage)(lang);
144
135
  }, [lang]);
145
136
  (0, _react.useEffect)(() => {
146
- if (enumRes !== null && enumRes !== void 0 && enumRes.data) {
147
- (props === null || props === void 0 ? void 0 : props.onSuccess) && (props === null || props === void 0 ? void 0 : props.onSuccess(enumRes === null || enumRes === void 0 ? void 0 : enumRes.data, enumRes === null || enumRes === void 0 ? void 0 : enumRes.params));
148
- }
137
+ var _props$onSuccess;
138
+ if (enumRes !== null && enumRes !== void 0 && enumRes.data) props === null || props === void 0 || (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 || _props$onSuccess.call(props, enumRes.data, enumRes.params);
149
139
  }, [enumRes === null || enumRes === void 0 ? void 0 : enumRes.loading]);
150
- var antdLangMap = {
151
- 'zh-CN': _zh_CN.default,
152
- // zh-CN 中文
153
- 'en-US': _en_US.default // en-US
154
- };
155
- // 处理频繁枚举的成功回调
156
140
  (0, _react.useEffect)(() => {
157
- if (frequentEnumRes !== null && frequentEnumRes !== void 0 && frequentEnumRes.data) {
158
- (props === null || props === void 0 ? void 0 : props.onSuccess) && (props === null || props === void 0 ? void 0 : props.onSuccess(frequentEnumRes === null || frequentEnumRes === void 0 ? void 0 : frequentEnumRes.data, frequentEnumRes === null || frequentEnumRes === void 0 ? void 0 : frequentEnumRes.params));
159
- }
141
+ var _props$onSuccess2;
142
+ if (frequentEnumRes !== null && frequentEnumRes !== void 0 && frequentEnumRes.data) props === null || props === void 0 || (_props$onSuccess2 = props.onSuccess) === null || _props$onSuccess2 === void 0 || _props$onSuccess2.call(props, frequentEnumRes.data, frequentEnumRes.params);
160
143
  }, [frequentEnumRes === null || frequentEnumRes === void 0 ? void 0 : frequentEnumRes.loading]);
161
144
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ThemeContext.ThemeProvider, {
162
145
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProConfigContext.Provider, {
@@ -165,7 +148,7 @@ var ProConfigProvider = props => {
165
148
  dispatch
166
149
  },
167
150
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeAwareConfigProvider, {
168
- locale: antdLangMap[lang],
151
+ locale: (_antdLangMap$lang = antdLangMap[lang]) !== null && _antdLangMap$lang !== void 0 ? _antdLangMap$lang : _zh_CN.default,
169
152
  children: props.children
170
153
  })
171
154
  })
@@ -0,0 +1,55 @@
1
+ import type React from 'react';
2
+ import type { FormInstance } from 'antd';
3
+ import type { PropSelectType } from '../ProSelect/propsType';
4
+ import type { ProModalSelectType } from '../ProForm/components/combination/ProModalSelect/propsType';
5
+ import type { ProCascaderType } from '../ProForm/components/combination/ProCascader/propsType';
6
+ import type { ProEnumConfigType } from '../ProEnum/propsType';
7
+ /** 对外配置项类型(value、内部 state 均为此类型,字段均可选) */
8
+ export interface ProConfigProviderType {
9
+ locale?: string;
10
+ ProEnum?: Partial<ProEnumConfigType>;
11
+ ProSelect?: Partial<PropSelectType> & Record<string, any>;
12
+ ProModalSelect?: Partial<ProModalSelectType> & Record<string, any>;
13
+ ProAddressBar?: Partial<ProCascaderType> & Record<string, any>;
14
+ forms?: Record<string, FormInstance | undefined>;
15
+ [key: string]: any;
16
+ }
17
+ /** ProConfigProvider 组件 Props(内部使用) */
18
+ export interface ProConfigProviderProps {
19
+ value?: ProConfigProviderType;
20
+ locale?: string;
21
+ onSuccess?: (data: any, params: any) => void;
22
+ children?: React.ReactNode;
23
+ }
24
+ /** Config 上下文 */
25
+ export interface ConfigContext {
26
+ state: ProConfigProviderType;
27
+ dispatch: React.Dispatch<ProConfigActions>;
28
+ }
29
+ /** ThemeAwareConfigProvider 内部组件 Props */
30
+ export interface ThemeAwareConfigProviderProps {
31
+ locale: any;
32
+ children: React.ReactNode;
33
+ }
34
+ /** Reducer Actions */
35
+ export type ProConfigActions = {
36
+ type: 'setFormRef';
37
+ name: string;
38
+ value: FormInstance;
39
+ } | {
40
+ type: 'deleteFormRef';
41
+ name: string;
42
+ } | {
43
+ type: 'set';
44
+ payload: ProConfigProviderType;
45
+ } | {
46
+ type: 'setProEnum';
47
+ payload: Record<string, any>;
48
+ } | {
49
+ type: 'setProEnumDic';
50
+ key: string;
51
+ payload: any;
52
+ } | {
53
+ type: 'setWithLocal';
54
+ payload: ProConfigProviderType;
55
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -303,7 +303,6 @@ export interface TagPropsMapType {
303
303
  */
304
304
  export type ProEnumType = Omit<ProEnumBaseType, 'type'> & (PropProSelectsMapType | PropRadioPropsMapType | CheckboxPropsMapType | TagPropsMapType);
305
305
  export type DataOption = DataOptionType;
306
- export type ProEnumConfig = ProEnumConfigType;
307
306
  export type ProEnum = ProEnumBaseType;
308
307
  export type PropProSelectsMap = PropProSelectsMapType;
309
308
  export type PropRadioPropsMap = PropRadioPropsMapType;
@@ -314,7 +314,8 @@
314
314
  .@{ant-prefix}-input,
315
315
  .@{ant-prefix}-select .@{ant-prefix}-select-selector,
316
316
  .@{ant-prefix}-input-number,
317
- .@{ant-prefix}-input-number-input {
317
+ .@{ant-prefix}-input-number-input,
318
+ .@{ant-prefix}-picker{
318
319
  // 重置z-index确保正确的层级关系
319
320
  position: relative;
320
321
  // 重置圆角
@@ -337,7 +338,8 @@
337
338
  .@{ant-prefix}-input,
338
339
  .@{ant-prefix}-select .@{ant-prefix}-select-selector,
339
340
  .@{ant-prefix}-input-number,
340
- .@{ant-prefix}-input-number-input {
341
+ .@{ant-prefix}-input-number-input,
342
+ .@{ant-prefix}-picker{
341
343
  border-top-right-radius: 6px;
342
344
  border-bottom-right-radius: 6px;
343
345
  }
@@ -75,29 +75,31 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
75
75
  confirm?: boolean | import("antd").ModalFuncProps | import("../../../render/propsType").FunctionArgs<any, boolean | import("antd").ModalFuncProps>;
76
76
  show?: boolean | ReactiveFunction<any, boolean>;
77
77
  component?: React.ReactNode | ReactiveFunction<any, React.ReactNode>;
78
+ validateTrigger?: string | false | string[];
79
+ isView?: boolean;
78
80
  id?: string;
81
+ prefixCls?: string;
79
82
  className?: string;
80
- hidden?: boolean;
81
83
  style?: React.CSSProperties;
82
84
  children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
83
- onReset?: () => void;
84
- prefixCls?: string;
85
- status?: "" | "warning" | "error" | "success" | "validating";
86
85
  rootClassName?: string;
87
- isView?: boolean;
86
+ status?: "" | "warning" | "error" | "success" | "validating";
87
+ getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
88
+ hidden?: boolean;
89
+ onReset?: () => void;
90
+ desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
91
+ vertical?: boolean;
92
+ valueType?: import("../../../render/propsType").ProFormValueType;
88
93
  colon?: boolean;
89
94
  htmlFor?: string;
90
95
  labelAlign?: import("antd/es/form/interface").FormLabelAlign;
91
96
  labelCol?: import("antd").ColProps;
92
- vertical?: boolean;
93
97
  getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
94
98
  normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
95
99
  shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
96
100
  trigger?: string;
97
- validateTrigger?: string | false | string[];
98
101
  validateDebounce?: number;
99
102
  valuePropName?: string;
100
- getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
101
103
  messageVariables?: Record<string, string>;
102
104
  initialValue?: any;
103
105
  onMetaChange?: (meta: import("@rc-component/form/lib/Field").MetaEvent) => void;
@@ -113,7 +115,6 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
113
115
  wrapperCol?: import("antd").ColProps;
114
116
  help?: React.ReactNode;
115
117
  fieldId?: string;
116
- valueType?: import("../../../render/propsType").ProFormValueType;
117
118
  switchValue?: [any, any];
118
119
  viewRender?: (value: any, record: any, { form, index, namePath, }: {
119
120
  [key: string]: any;
@@ -126,7 +127,6 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
126
127
  toISOString?: boolean;
127
128
  toCSTString?: boolean;
128
129
  clearNotShow?: boolean;
129
- desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
130
130
  name: any;
131
131
  dependencies: any[];
132
132
  tooltip: string | {
@@ -141,7 +141,7 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
141
141
  * 创建组件属性
142
142
  */
143
143
  export declare const createComponentProps: (column: FlexibleGroupColumnType, formItemProps: any) => {
144
- componentProps: import("lodash").Omit<any, "format" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow" | "precision">;
144
+ componentProps: import("lodash").Omit<any, "precision" | "format" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow">;
145
145
  formItemTransform: {
146
146
  getValueProps: any;
147
147
  normalize: any;
@@ -55,7 +55,7 @@ export type FunctionArgs<Values, R = any> = (value: any, record: any, { form, in
55
55
  namePath?: NamePath;
56
56
  [key: string]: any;
57
57
  }) => R;
58
- type TransformToFormField<T extends ControlProps, Values> = DistributiveOmit<T, 'onChange' | 'value'> & {
58
+ type TransformToFormField<T extends ControlProps, Values> = DistributiveOmit<T, 'onChange' | 'value' | 'role'> & {
59
59
  value?: T['value'];
60
60
  onChange?: (value: Parameters<T['onChange']>[0], options: Parameters<T['onChange']>[1], form: FormInstance<Values>) => void;
61
61
  onFieldChange?: FunctionArgs<Values>;
@@ -66,7 +66,7 @@ type TransformToFormField<T extends ControlProps, Values> = DistributiveOmit<T,
66
66
  type ProEnumFormType<Values> = TransformToFormField<ProEnum, Values> | TransformToFormField<ProEnum & PropProSelectsMap, Values> | TransformToFormField<ProEnum & PropRadioPropsMap, Values> | TransformToFormField<ProEnum & CheckboxPropsMap, Values>;
67
67
  type ProEnumTableType<Values> = TransformToTableField<ProEnum, Values> | TransformToTableField<ProEnum & PropProSelectsMap, Values> | TransformToTableField<ProEnum & PropRadioPropsMap, Values> | TransformToTableField<ProEnum & CheckboxPropsMap, Values>;
68
68
  type ProEnumFieldType<Values, TT> = TT extends 'ProForm' ? ProEnumFormType<Values> | ReactiveFunction<Values, ProEnumFormType<Values>> : ProEnumTableType<Values> | ((text: any, values: Values, index: number) => ProEnumTableType<Values>);
69
- type TransformToTableField<T extends ControlProps, Values> = Omit<T, 'onChange' | 'value' | 'onBlur'> & {
69
+ type TransformToTableField<T extends ControlProps, Values> = Omit<T, 'onChange' | 'value' | 'onBlur' | 'role'> & {
70
70
  value?: T['value'];
71
71
  onChange?: (value: Parameters<T['onChange']>[0], options: Parameters<T['onChange']>[1], record: any, index: number, form: FormInstance<Values>) => void;
72
72
  onFieldChange?: FunctionArgs<Values>;