@zat-design/sisyphus-react 4.0.10 → 4.0.11

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.
@@ -75,35 +75,38 @@ 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;
80
- id?: string;
81
- prefixCls?: string;
78
+ children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
79
+ trim?: boolean;
80
+ normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
82
81
  className?: string;
82
+ prefixCls?: string;
83
83
  style?: React.CSSProperties;
84
- children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
85
- rootClassName?: string;
84
+ onReset?: () => void;
86
85
  status?: "" | "warning" | "error" | "success" | "validating";
87
- getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
88
86
  hidden?: boolean;
89
- onReset?: () => void;
90
- desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
87
+ id?: string;
91
88
  vertical?: boolean;
92
- valueType?: import("../../../render/propsType").ProFormValueType;
93
- colon?: boolean;
89
+ rootClassName?: string;
90
+ isView?: boolean;
91
+ getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
92
+ desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
94
93
  htmlFor?: string;
94
+ layout?: import("antd/es/form/Form").FormItemLayout;
95
+ help?: React.ReactNode;
96
+ preserve?: boolean;
97
+ trigger?: string;
98
+ colon?: boolean;
99
+ clearNotShow?: boolean;
95
100
  labelAlign?: import("antd/es/form/interface").FormLabelAlign;
96
101
  labelCol?: import("antd").ColProps;
97
102
  getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
98
- normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
99
103
  shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
100
- trigger?: string;
104
+ validateTrigger?: string | false | string[];
101
105
  validateDebounce?: number;
102
106
  valuePropName?: string;
103
107
  messageVariables?: Record<string, string>;
104
108
  initialValue?: any;
105
109
  onMetaChange?: (meta: import("@rc-component/form/lib/Field").MetaEvent) => void;
106
- preserve?: boolean;
107
110
  isListField?: boolean;
108
111
  isList?: boolean;
109
112
  noStyle?: boolean;
@@ -111,10 +114,9 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
111
114
  icons: import("antd/es/form/FormItem").FeedbackIcons;
112
115
  };
113
116
  validateStatus?: "" | "warning" | "error" | "success" | "validating";
114
- layout?: import("antd/es/form/Form").FormItemLayout;
115
117
  wrapperCol?: import("antd").ColProps;
116
- help?: React.ReactNode;
117
118
  fieldId?: string;
119
+ valueType?: import("../../../render/propsType").ProFormValueType;
118
120
  switchValue?: [any, any];
119
121
  viewRender?: (value: any, record: any, { form, index, namePath, }: {
120
122
  [key: string]: any;
@@ -122,11 +124,9 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
122
124
  index?: number;
123
125
  }) => string | React.ReactElement<any, any>;
124
126
  viewType?: import("../../../render/propsType").ViewType;
125
- trim?: boolean;
126
127
  upperCase?: boolean;
127
128
  toISOString?: boolean;
128
129
  toCSTString?: boolean;
129
- clearNotShow?: boolean;
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, "precision" | "format" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow">;
144
+ componentProps: import("lodash").Omit<any, "format" | "clearNotShow" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "precision">;
145
145
  formItemTransform: {
146
146
  getValueProps: any;
147
147
  normalize: any;
@@ -1,16 +1,6 @@
1
- import { FormInstance } from 'antd';
2
1
  import React from 'react';
3
2
  import { FormProviderProps } from 'antd/es/form/context';
4
- import type { ProFormType } from './propsType';
5
- import { useForm } from './utils/useForm';
6
- import useWatch from './utils/useWatch';
7
- import { useForms } from '../FormsProvider';
8
- interface IProForm<T = any> extends React.ForwardRefExoticComponent<ProFormType<T> & React.RefAttributes<FormInstance<T>>> {
9
- useForm: typeof useForm;
10
- useWatch: typeof useWatch;
11
- useFormInstances: typeof useForms;
12
- [key: string]: any;
13
- }
14
- declare const ProFormForward: IProForm;
3
+ import type { ProFormInstanceType } from './propsType';
4
+ declare const ProFormForward: ProFormInstanceType<any>;
15
5
  export declare const ProFormProvider: React.FC<FormProviderProps>;
16
6
  export default ProFormForward;
@@ -275,8 +275,6 @@ var ProForm = (props, ref) => {
275
275
  })), children]
276
276
  }));
277
277
  };
278
-
279
- // @ts-ignore
280
278
  var ProFormForward = /*#__PURE__*/forwardRef(ProForm);
281
279
  ProFormForward.useForm = useForm;
282
280
  ProFormForward.useWatch = useWatch;
@@ -117,6 +117,17 @@ export interface TransformType<T = any> {
117
117
  shouldUpdate?: ShouldUpdate<T>;
118
118
  }
119
119
  export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
120
+ /**
121
+ * ProForm 组件接口类型
122
+ * 用于定义 ProForm 组件及其静态方法的类型
123
+ * 注意:此接口的具体实现方法类型在组件文件中定义,这里只提供基础结构
124
+ */
125
+ export interface ProFormInstanceType<T = any> extends React.ForwardRefExoticComponent<ProFormType<T> & React.RefAttributes<FormInstance<T>>> {
126
+ useForm: any;
127
+ useWatch: any;
128
+ useFormInstances: any;
129
+ [key: string]: any;
130
+ }
120
131
  /**
121
132
  * 兼容旧命名导出
122
133
  */
@@ -1,5 +1,11 @@
1
1
  export var otherKeys = ['isView', 'viewEmpty', 'label', 'valueType', 'viewType', 'name', 'names', 'form', 'type', 'hiddenNames'];
2
2
 
3
+ /**
4
+ * ProForm 组件接口类型
5
+ * 用于定义 ProForm 组件及其静态方法的类型
6
+ * 注意:此接口的具体实现方法类型在组件文件中定义,这里只提供基础结构
7
+ */
8
+
3
9
  /**
4
10
  * 兼容旧命名导出
5
11
  */
@@ -35,6 +35,8 @@ export declare const getThemeUpdaters: () => {
35
35
  };
36
36
  interface ThemeProviderProps {
37
37
  children: ReactNode;
38
+ initialLocalConfig?: Partial<LocalThemeConfigType>;
39
+ initialAntdConfig?: AntdThemeConfigType;
38
40
  }
39
41
  export declare const ThemeProvider: React.FC<ThemeProviderProps>;
40
42
  export declare const useTheme: () => ThemeContextType;
@@ -130,22 +130,41 @@ export var getThemeUpdaters = () => ({
130
130
  // Provider 组件
131
131
 
132
132
  export var ThemeProvider = _ref => {
133
- var children = _ref.children;
133
+ var children = _ref.children,
134
+ initialLocalConfig = _ref.initialLocalConfig,
135
+ initialAntdConfig = _ref.initialAntdConfig;
134
136
  // 使用惰性初始化,在组件渲染时检查 CSS 变量
135
137
  var _useReducer = useReducer(themeReducer, initialState, initial => {
138
+ // 合并初始配置
139
+ var finalState = _objectSpread({}, initial);
140
+
141
+ // 应用 initialLocalConfig
142
+ if (initialLocalConfig) {
143
+ finalState = _objectSpread(_objectSpread({}, finalState), {}, {
144
+ localConfig: _objectSpread(_objectSpread({}, finalState.localConfig), initialLocalConfig)
145
+ });
146
+ }
147
+
148
+ // 应用 initialAntdConfig
149
+ if (initialAntdConfig) {
150
+ finalState = _objectSpread(_objectSpread({}, finalState), {}, {
151
+ antdConfig: initialAntdConfig
152
+ });
153
+ }
154
+
136
155
  // 在初始化时检查 CSS 变量
137
156
  if (typeof window !== 'undefined') {
138
157
  try {
139
- var _document$documentEle2, _initial$antdConfig$t;
158
+ var _document$documentEle2, _finalState$antdConfi;
140
159
  var cssZauiBrand = (_document$documentEle2 = document.documentElement.style.getPropertyValue('--zaui-brand')) === null || _document$documentEle2 === void 0 ? void 0 : _document$documentEle2.trim();
141
- if (cssZauiBrand && cssZauiBrand !== ((_initial$antdConfig$t = initial.antdConfig.token) === null || _initial$antdConfig$t === void 0 ? void 0 : _initial$antdConfig$t.colorPrimary)) {
142
- return _objectSpread(_objectSpread({}, initial), {}, {
160
+ if (cssZauiBrand && cssZauiBrand !== ((_finalState$antdConfi = finalState.antdConfig.token) === null || _finalState$antdConfi === void 0 ? void 0 : _finalState$antdConfi.colorPrimary)) {
161
+ return _objectSpread(_objectSpread({}, finalState), {}, {
143
162
  antdConfig: {
144
163
  token: {
145
164
  colorPrimary: cssZauiBrand
146
165
  }
147
166
  },
148
- localConfig: _objectSpread(_objectSpread({}, initial.localConfig), {}, {
167
+ localConfig: _objectSpread(_objectSpread({}, finalState.localConfig), {}, {
149
168
  zauiBrand: cssZauiBrand
150
169
  })
151
170
  });
@@ -154,7 +173,7 @@ export var ThemeProvider = _ref => {
154
173
  // 忽略错误
155
174
  }
156
175
  }
157
- return initial;
176
+ return finalState;
158
177
  }),
159
178
  _useReducer2 = _slicedToArray(_useReducer, 2),
160
179
  state = _useReducer2[0],
@@ -230,6 +249,12 @@ export var ThemeProvider = _ref => {
230
249
  setThemes(pending);
231
250
  clearPendingThemes();
232
251
  }
252
+ }).catch(e => {
253
+ // 在测试环境中,动态导入可能失败,忽略错误
254
+ // eslint-disable-next-line no-console
255
+ if (process.env.NODE_ENV !== 'test') {
256
+ console.warn('Failed to load pending themes:', e);
257
+ }
233
258
  });
234
259
  });
235
260
  }
@@ -75,35 +75,38 @@ 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;
80
- id?: string;
81
- prefixCls?: string;
78
+ children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
79
+ trim?: boolean;
80
+ normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
82
81
  className?: string;
82
+ prefixCls?: string;
83
83
  style?: React.CSSProperties;
84
- children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
85
- rootClassName?: string;
84
+ onReset?: () => void;
86
85
  status?: "" | "warning" | "error" | "success" | "validating";
87
- getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
88
86
  hidden?: boolean;
89
- onReset?: () => void;
90
- desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
87
+ id?: string;
91
88
  vertical?: boolean;
92
- valueType?: import("../../../render/propsType").ProFormValueType;
93
- colon?: boolean;
89
+ rootClassName?: string;
90
+ isView?: boolean;
91
+ getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
92
+ desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
94
93
  htmlFor?: string;
94
+ layout?: import("antd/es/form/Form").FormItemLayout;
95
+ help?: React.ReactNode;
96
+ preserve?: boolean;
97
+ trigger?: string;
98
+ colon?: boolean;
99
+ clearNotShow?: boolean;
95
100
  labelAlign?: import("antd/es/form/interface").FormLabelAlign;
96
101
  labelCol?: import("antd").ColProps;
97
102
  getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
98
- normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
99
103
  shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
100
- trigger?: string;
104
+ validateTrigger?: string | false | string[];
101
105
  validateDebounce?: number;
102
106
  valuePropName?: string;
103
107
  messageVariables?: Record<string, string>;
104
108
  initialValue?: any;
105
109
  onMetaChange?: (meta: import("@rc-component/form/lib/Field").MetaEvent) => void;
106
- preserve?: boolean;
107
110
  isListField?: boolean;
108
111
  isList?: boolean;
109
112
  noStyle?: boolean;
@@ -111,10 +114,9 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
111
114
  icons: import("antd/es/form/FormItem").FeedbackIcons;
112
115
  };
113
116
  validateStatus?: "" | "warning" | "error" | "success" | "validating";
114
- layout?: import("antd/es/form/Form").FormItemLayout;
115
117
  wrapperCol?: import("antd").ColProps;
116
- help?: React.ReactNode;
117
118
  fieldId?: string;
119
+ valueType?: import("../../../render/propsType").ProFormValueType;
118
120
  switchValue?: [any, any];
119
121
  viewRender?: (value: any, record: any, { form, index, namePath, }: {
120
122
  [key: string]: any;
@@ -122,11 +124,9 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
122
124
  index?: number;
123
125
  }) => string | React.ReactElement<any, any>;
124
126
  viewType?: import("../../../render/propsType").ViewType;
125
- trim?: boolean;
126
127
  upperCase?: boolean;
127
128
  toISOString?: boolean;
128
129
  toCSTString?: boolean;
129
- clearNotShow?: boolean;
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, "precision" | "format" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow">;
144
+ componentProps: import("lodash").Omit<any, "format" | "clearNotShow" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "precision">;
145
145
  formItemTransform: {
146
146
  getValueProps: any;
147
147
  normalize: any;
@@ -1,16 +1,6 @@
1
- import { FormInstance } from 'antd';
2
1
  import React from 'react';
3
2
  import { FormProviderProps } from 'antd/es/form/context';
4
- import type { ProFormType } from './propsType';
5
- import { useForm } from './utils/useForm';
6
- import useWatch from './utils/useWatch';
7
- import { useForms } from '../FormsProvider';
8
- interface IProForm<T = any> extends React.ForwardRefExoticComponent<ProFormType<T> & React.RefAttributes<FormInstance<T>>> {
9
- useForm: typeof useForm;
10
- useWatch: typeof useWatch;
11
- useFormInstances: typeof useForms;
12
- [key: string]: any;
13
- }
14
- declare const ProFormForward: IProForm;
3
+ import type { ProFormInstanceType } from './propsType';
4
+ declare const ProFormForward: ProFormInstanceType<any>;
15
5
  export declare const ProFormProvider: React.FC<FormProviderProps>;
16
6
  export default ProFormForward;
@@ -283,8 +283,6 @@ var ProForm = (props, ref) => {
283
283
  })), children]
284
284
  }));
285
285
  };
286
-
287
- // @ts-ignore
288
286
  var ProFormForward = /*#__PURE__*/(0, _react.forwardRef)(ProForm);
289
287
  ProFormForward.useForm = _useForm3.useForm;
290
288
  ProFormForward.useWatch = _useWatch.default;
@@ -117,6 +117,17 @@ export interface TransformType<T = any> {
117
117
  shouldUpdate?: ShouldUpdate<T>;
118
118
  }
119
119
  export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
120
+ /**
121
+ * ProForm 组件接口类型
122
+ * 用于定义 ProForm 组件及其静态方法的类型
123
+ * 注意:此接口的具体实现方法类型在组件文件中定义,这里只提供基础结构
124
+ */
125
+ export interface ProFormInstanceType<T = any> extends React.ForwardRefExoticComponent<ProFormType<T> & React.RefAttributes<FormInstance<T>>> {
126
+ useForm: any;
127
+ useWatch: any;
128
+ useFormInstances: any;
129
+ [key: string]: any;
130
+ }
120
131
  /**
121
132
  * 兼容旧命名导出
122
133
  */
@@ -6,6 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.otherKeys = void 0;
7
7
  var otherKeys = exports.otherKeys = ['isView', 'viewEmpty', 'label', 'valueType', 'viewType', 'name', 'names', 'form', 'type', 'hiddenNames'];
8
8
 
9
+ /**
10
+ * ProForm 组件接口类型
11
+ * 用于定义 ProForm 组件及其静态方法的类型
12
+ * 注意:此接口的具体实现方法类型在组件文件中定义,这里只提供基础结构
13
+ */
14
+
9
15
  /**
10
16
  * 兼容旧命名导出
11
17
  */
@@ -35,6 +35,8 @@ export declare const getThemeUpdaters: () => {
35
35
  };
36
36
  interface ThemeProviderProps {
37
37
  children: ReactNode;
38
+ initialLocalConfig?: Partial<LocalThemeConfigType>;
39
+ initialAntdConfig?: AntdThemeConfigType;
38
40
  }
39
41
  export declare const ThemeProvider: React.FC<ThemeProviderProps>;
40
42
  export declare const useTheme: () => ThemeContextType;
@@ -134,22 +134,41 @@ var getThemeUpdaters = () => ({
134
134
  // Provider 组件
135
135
  exports.getThemeUpdaters = getThemeUpdaters;
136
136
  var ThemeProvider = _ref => {
137
- var children = _ref.children;
137
+ var children = _ref.children,
138
+ initialLocalConfig = _ref.initialLocalConfig,
139
+ initialAntdConfig = _ref.initialAntdConfig;
138
140
  // 使用惰性初始化,在组件渲染时检查 CSS 变量
139
141
  var _useReducer = (0, _react.useReducer)(themeReducer, initialState, initial => {
142
+ // 合并初始配置
143
+ var finalState = _objectSpread({}, initial);
144
+
145
+ // 应用 initialLocalConfig
146
+ if (initialLocalConfig) {
147
+ finalState = _objectSpread(_objectSpread({}, finalState), {}, {
148
+ localConfig: _objectSpread(_objectSpread({}, finalState.localConfig), initialLocalConfig)
149
+ });
150
+ }
151
+
152
+ // 应用 initialAntdConfig
153
+ if (initialAntdConfig) {
154
+ finalState = _objectSpread(_objectSpread({}, finalState), {}, {
155
+ antdConfig: initialAntdConfig
156
+ });
157
+ }
158
+
140
159
  // 在初始化时检查 CSS 变量
141
160
  if (typeof window !== 'undefined') {
142
161
  try {
143
- var _document$documentEle2, _initial$antdConfig$t;
162
+ var _document$documentEle2, _finalState$antdConfi;
144
163
  var cssZauiBrand = (_document$documentEle2 = document.documentElement.style.getPropertyValue('--zaui-brand')) === null || _document$documentEle2 === void 0 ? void 0 : _document$documentEle2.trim();
145
- if (cssZauiBrand && cssZauiBrand !== ((_initial$antdConfig$t = initial.antdConfig.token) === null || _initial$antdConfig$t === void 0 ? void 0 : _initial$antdConfig$t.colorPrimary)) {
146
- return _objectSpread(_objectSpread({}, initial), {}, {
164
+ if (cssZauiBrand && cssZauiBrand !== ((_finalState$antdConfi = finalState.antdConfig.token) === null || _finalState$antdConfi === void 0 ? void 0 : _finalState$antdConfi.colorPrimary)) {
165
+ return _objectSpread(_objectSpread({}, finalState), {}, {
147
166
  antdConfig: {
148
167
  token: {
149
168
  colorPrimary: cssZauiBrand
150
169
  }
151
170
  },
152
- localConfig: _objectSpread(_objectSpread({}, initial.localConfig), {}, {
171
+ localConfig: _objectSpread(_objectSpread({}, finalState.localConfig), {}, {
153
172
  zauiBrand: cssZauiBrand
154
173
  })
155
174
  });
@@ -158,7 +177,7 @@ var ThemeProvider = _ref => {
158
177
  // 忽略错误
159
178
  }
160
179
  }
161
- return initial;
180
+ return finalState;
162
181
  }),
163
182
  _useReducer2 = _slicedToArray(_useReducer, 2),
164
183
  state = _useReducer2[0],
@@ -234,6 +253,12 @@ var ThemeProvider = _ref => {
234
253
  setThemes(pending);
235
254
  clearPendingThemes();
236
255
  }
256
+ }).catch(e => {
257
+ // 在测试环境中,动态导入可能失败,忽略错误
258
+ // eslint-disable-next-line no-console
259
+ if (process.env.NODE_ENV !== 'test') {
260
+ console.warn('Failed to load pending themes:', e);
261
+ }
237
262
  });
238
263
  });
239
264
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "4.0.10",
3
+ "version": "4.0.11",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",