@zat-design/sisyphus-react 4.3.5-beta.1 → 4.3.5

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.
@@ -64,13 +64,14 @@ const useEnumRequest = (props, dispatch) => {
64
64
  // 缓存命中时跳过 transformResponse 和重复处理,直接 dispatch
65
65
  if (fromCacheRef.current) {
66
66
  const cachedData = fromCacheRef.current;
67
+ const mergedPayload = {
68
+ ...dics,
69
+ ...cachedData,
70
+ ...dataSource
71
+ };
67
72
  dispatch({
68
73
  type: 'setProEnumDic',
69
- payload: {
70
- ...dics,
71
- ...dataSource,
72
- ...cachedData
73
- }
74
+ payload: mergedPayload
74
75
  });
75
76
  if (main) {
76
77
  setTimeout(() => {
@@ -132,13 +133,14 @@ const useEnumRequest = (props, dispatch) => {
132
133
  await Promise.resolve(setEnumData(storage, cacheKey, res));
133
134
 
134
135
  // 同步数据到全局
136
+ const mergedPayload = {
137
+ ...dics,
138
+ ...res.data,
139
+ ...dataSource
140
+ };
135
141
  dispatch({
136
142
  type: 'setProEnumDic',
137
- payload: {
138
- ...dics,
139
- ...dataSource,
140
- ...res.data
141
- }
143
+ payload: mergedPayload
142
144
  });
143
145
  if (main) {
144
146
  setTimeout(() => {
@@ -157,13 +159,14 @@ const useEnumRequest = (props, dispatch) => {
157
159
  const res = getEnumData(storage, cacheKey) || {
158
160
  data: {}
159
161
  };
162
+ const mergedPayload = {
163
+ ...dics,
164
+ ...res?.data,
165
+ ...dataSource
166
+ };
160
167
  dispatch({
161
168
  type: 'setProEnumDic',
162
- payload: {
163
- ...dics,
164
- ...dataSource,
165
- ...res?.data
166
- }
169
+ payload: mergedPayload
167
170
  });
168
171
  if (main) {
169
172
  setTimeout(() => {
@@ -229,18 +232,25 @@ const useEnumRequest = (props, dispatch) => {
229
232
  type: 'setProEnumDic',
230
233
  payload: {
231
234
  ...dics,
232
- ...dataSource,
233
- ...cacheData.data
235
+ ...cacheData.data,
236
+ ...dataSource
234
237
  }
235
238
  });
236
239
  } else if (dataSource && Object.keys(dataSource).length > 0) {
237
- // 子系统也可能会有 dataSource
240
+ // 子系统也可能会有 dataSource,并需要同步写入缓存
241
+ const mergedPayload = {
242
+ ...dics,
243
+ ...cacheData.data,
244
+ ...dataSource
245
+ };
246
+ await Promise.resolve(setEnumData(storage, cacheKey, {
247
+ ...cacheData,
248
+ data: mergedPayload,
249
+ time: Date.now()
250
+ }));
238
251
  dispatch({
239
252
  type: 'setProEnumDic',
240
- payload: {
241
- ...dics,
242
- ...dataSource
243
- }
253
+ payload: mergedPayload
244
254
  });
245
255
  }
246
256
  }
@@ -266,12 +276,18 @@ const useEnumRequest = (props, dispatch) => {
266
276
  const res = await Promise.resolve(getEnumData(storage, cacheKey) || {
267
277
  data: {}
268
278
  });
279
+ const mergedData = {
280
+ ...res?.data,
281
+ ...dataSource
282
+ };
283
+ await Promise.resolve(setEnumData(storage, cacheKey, {
284
+ ...res,
285
+ data: mergedData,
286
+ time: Date.now()
287
+ }));
269
288
  dispatch({
270
289
  type: 'setProEnumDic',
271
- payload: {
272
- ...dataSource,
273
- ...res?.data
274
- }
290
+ payload: mergedData
275
291
  });
276
292
  } else {
277
293
  const res = await Promise.resolve(getEnumData(storage, cacheKey) || {
@@ -1,4 +1,3 @@
1
- import _isNumber from "lodash/isNumber";
2
1
  import _omit from "lodash/omit";
3
2
  import _isArray from "lodash/isArray";
4
3
  import _isString from "lodash/isString";
@@ -36,7 +35,7 @@ const ProEnum = props => {
36
35
  const {
37
36
  viewEmpty
38
37
  } = otherProps || {};
39
- const _defalutValue = props?.defaultValue;
38
+ const _defaultValue = props?.defaultValue;
40
39
  const {
41
40
  isView: configIsView
42
41
  } = useFieldProps() || {};
@@ -68,8 +67,8 @@ const ProEnum = props => {
68
67
  fieldValue = 'value';
69
68
  }
70
69
 
71
- // 这种时候优先级最高、完全走自定义
72
- if (useRequest?.service && props.fieldNames) {
70
+ // 组件显式传入 fieldNames 时优先级最高,必须覆盖 clear 默认映射
71
+ if (props.fieldNames && Object.keys(props.fieldNames).length) {
73
72
  if (props.fieldNames?.label) label = props.fieldNames.label;
74
73
  if (props.fieldNames?.value) fieldValue = props.fieldNames.value;
75
74
  }
@@ -264,7 +263,7 @@ const ProEnum = props => {
264
263
  return _isFunction(props.optionRender) && record.length ? _optionRender() : labelList?.join(',');
265
264
  };
266
265
  if (_isView) {
267
- const __value = value || _defalutValue;
266
+ const __value = value ?? _defaultValue;
268
267
  if (Array.isArray(__value)) {
269
268
  return /*#__PURE__*/_jsx(Container, {
270
269
  tooltip: true,
@@ -274,7 +273,7 @@ const ProEnum = props => {
274
273
  }
275
274
  return /*#__PURE__*/_jsx(Container, {
276
275
  viewEmpty: viewEmpty,
277
- children: __value || _isNumber(__value) ? transToLabel([__value]) : null
276
+ children: __value != null ? transToLabel([__value]) : null
278
277
  });
279
278
  }
280
279
  return /*#__PURE__*/_jsx(_Fragment, {
@@ -148,7 +148,7 @@ const InputNumber = props => {
148
148
  }
149
149
  }
150
150
  }
151
- return [_min ?? min ?? valueProps?.min, _max ?? max ?? valueProps?.max];
151
+ return [_min ?? min ?? valueProps?.min ?? initialConfig?.min, _max ?? max ?? valueProps?.max ?? initialConfig?.max];
152
152
  }, [range, min, max, rest.precision]);
153
153
  const _className = classNames({
154
154
  'full-form-item': true,
@@ -75,38 +75,33 @@ 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
- children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
79
- status?: "" | "warning" | "error" | "success" | "validating";
80
- isView?: boolean;
81
78
  id?: string;
82
- prefixCls?: string;
83
79
  className?: string;
80
+ hidden?: boolean;
84
81
  style?: React.CSSProperties;
82
+ children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
83
+ onReset?: () => void;
84
+ prefixCls?: string;
85
85
  rootClassName?: string;
86
- getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
87
- trim?: boolean;
88
- normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
86
+ status?: "" | "warning" | "error" | "success" | "validating";
89
87
  vertical?: boolean;
90
- trigger?: string;
91
- hidden?: boolean;
92
- onReset?: () => void;
93
- desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
94
- validateTrigger?: string | false | string[];
95
- preserve?: boolean;
96
- clearNotShow?: boolean;
97
- labelAlign?: import("antd/es/form/interface").FormLabelAlign;
88
+ isView?: boolean;
98
89
  colon?: boolean;
99
- layout?: import("antd/es/form/Form").FormItemLayout;
100
- labelCol?: import("antd").ColProps;
101
- wrapperCol?: import("antd").ColProps;
102
90
  htmlFor?: string;
91
+ labelAlign?: import("antd/es/form/interface").FormLabelAlign;
92
+ labelCol?: import("antd").ColProps;
103
93
  getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
94
+ normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
104
95
  shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
96
+ trigger?: string;
97
+ validateTrigger?: string | false | string[];
105
98
  validateDebounce?: number;
106
99
  valuePropName?: string;
100
+ getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
107
101
  messageVariables?: Record<string, string>;
108
102
  initialValue?: any;
109
103
  onMetaChange?: (meta: import("@rc-component/form/lib/Field").MetaEvent) => void;
104
+ preserve?: boolean;
110
105
  isListField?: boolean;
111
106
  isList?: boolean;
112
107
  noStyle?: boolean;
@@ -114,6 +109,8 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
114
109
  icons: import("antd/es/form/FormItem").FeedbackIcons;
115
110
  };
116
111
  validateStatus?: "" | "warning" | "error" | "success" | "validating";
112
+ layout?: import("antd/es/form/Form").FormItemLayout;
113
+ wrapperCol?: import("antd").ColProps;
117
114
  help?: React.ReactNode;
118
115
  fieldId?: string;
119
116
  valueType?: import("../../../render/propsType").ProFormValueType;
@@ -124,9 +121,12 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
124
121
  index?: number;
125
122
  }) => string | React.ReactElement<any, any>;
126
123
  viewType?: import("../../../render/propsType").ViewType;
124
+ trim?: boolean;
127
125
  upperCase?: boolean;
128
126
  toISOString?: boolean;
129
127
  toCSTString?: boolean;
128
+ 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" | "clearNotShow" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "precision">;
144
+ componentProps: import("lodash").Omit<any, "format" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow" | "precision">;
145
145
  formItemTransform: {
146
146
  getValueProps: any;
147
147
  normalize: any;
@@ -22,7 +22,7 @@ const ConfirmWrapper = props => {
22
22
  name,
23
23
  index,
24
24
  listName
25
- } = ProForm.useFieldProps();
25
+ } = ProForm.useFieldProps() || {};
26
26
  const handleChange = async (value, ...other) => {
27
27
  const _value = value?.target ? value.target.value : value;
28
28
  const confirmProps = _isFunction(confirm) ? await confirm(value, form.getFieldsValue(), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "4.3.5-beta.1",
3
+ "version": "4.3.5",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "es",