@zat-design/sisyphus-react 4.0.1 → 4.0.2
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/ProEditTable/components/RenderField/index.js +77 -13
- package/es/ProEditTable/style/index.less +2 -2
- package/es/ProEditTable/utils/index.js +5 -4
- package/es/ProForm/components/combination/Group/style/index.less +13 -12
- package/es/ProForm/components/combination/Group/utils/index.d.ts +21 -21
- package/es/ProForm/style/index.less +2 -2
- package/es/ProSelect/index.d.ts +1 -1
- package/es/ProSelect/index.js +33 -32
- package/es/ProSelect/propsType.d.ts +0 -12
- package/es/ProTreeModal/style/index.less +1 -1
- package/es/style/theme/antd.less +1 -1
- package/lib/ProEditTable/components/RenderField/index.js +76 -12
- package/lib/ProEditTable/style/index.less +2 -2
- package/lib/ProEditTable/utils/index.js +5 -4
- package/lib/ProForm/components/combination/Group/style/index.less +13 -12
- package/lib/ProForm/components/combination/Group/utils/index.d.ts +21 -21
- package/lib/ProForm/style/index.less +2 -2
- package/lib/ProSelect/index.d.ts +1 -1
- package/lib/ProSelect/index.js +31 -30
- package/lib/ProSelect/propsType.d.ts +0 -12
- package/lib/ProTreeModal/style/index.less +1 -1
- package/lib/style/theme/antd.less +1 -1
- package/package.json +5 -8
- /package/es/ProSelect/{index.less → style/index.less} +0 -0
- /package/lib/ProSelect/{index.less → style/index.less} +0 -0
|
@@ -41,7 +41,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
41
41
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
42
42
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
43
43
|
var RenderField = _ref => {
|
|
44
|
-
var _type, _type$replace, _fieldProps2, _fieldProps4, _names, _TargetComponent5,
|
|
44
|
+
var _type, _type$replace, _fieldProps2, _fieldProps4, _names, _TargetComponent5, _componentProps;
|
|
45
45
|
var value = _ref.text,
|
|
46
46
|
record = _ref.record,
|
|
47
47
|
index = _ref.index,
|
|
@@ -101,6 +101,7 @@ var RenderField = _ref => {
|
|
|
101
101
|
// editRender弃用使用component同ProForm
|
|
102
102
|
var _editRender = component || editRender;
|
|
103
103
|
var isCell = mode === 'cell';
|
|
104
|
+
var isSingleMode = mode === 'single';
|
|
104
105
|
if (isCell) {
|
|
105
106
|
record['is-view'] = !(0, _lodash.isEqual)(cellNamePath, cellName);
|
|
106
107
|
}
|
|
@@ -234,6 +235,32 @@ var RenderField = _ref => {
|
|
|
234
235
|
var _formItemProps = (0, _react.useMemo)(() => _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultProps), resetProps), internalRule), {}, {
|
|
235
236
|
validateTrigger
|
|
236
237
|
}), [defaultProps, resetProps, internalRule, validateTrigger]);
|
|
238
|
+
|
|
239
|
+
// 只在 single 模式下,当这些函数类型存在时,自动添加 shouldUpdate
|
|
240
|
+
// 因为这些函数依赖行数据,当行数据变化时需要重新计算
|
|
241
|
+
var hasFunctionDependency = (0, _lodash.isFunction)(column === null || column === void 0 ? void 0 : column.disabled) ||
|
|
242
|
+
// disabled 是函数
|
|
243
|
+
(0, _lodash.isFunction)(fieldProps) ||
|
|
244
|
+
// fieldProps 是函数
|
|
245
|
+
(0, _lodash.isFunction)(required) ||
|
|
246
|
+
// required 是函数
|
|
247
|
+
(0, _lodash.isFunction)(rules) ||
|
|
248
|
+
// rules 是函数
|
|
249
|
+
(0, _lodash.isFunction)(isEditable) ||
|
|
250
|
+
// isEditable 是函数
|
|
251
|
+
(0, _lodash.isFunction)(_editRender) ||
|
|
252
|
+
// component/editRender 是函数
|
|
253
|
+
(0, _lodash.isFunction)(viewRender); // viewRender 是函数
|
|
254
|
+
|
|
255
|
+
if (isSingleMode && hasFunctionDependency && !(column !== null && column !== void 0 && column.dependencies)) {
|
|
256
|
+
// 使用 shouldUpdate 监听同一行的数据变化
|
|
257
|
+
_formItemProps.shouldUpdate = (prevValues, currentValues) => {
|
|
258
|
+
var prevRow = (0, _lodash.get)(prevValues, [...namePath, index]);
|
|
259
|
+
var currentRow = (0, _lodash.get)(currentValues, [...namePath, index]);
|
|
260
|
+
// 如果行数据发生变化,则重新渲染
|
|
261
|
+
return !(0, _lodash.isEqual)(prevRow, currentRow);
|
|
262
|
+
};
|
|
263
|
+
}
|
|
237
264
|
if (['Switch', 'SwitchCheckbox'].includes(type)) {
|
|
238
265
|
_formItemProps.valuePropName = 'checked';
|
|
239
266
|
_valueType = 'switch';
|
|
@@ -660,10 +687,47 @@ var RenderField = _ref => {
|
|
|
660
687
|
}), [className]);
|
|
661
688
|
|
|
662
689
|
// 使用useCallback优化getFieldItem函数
|
|
663
|
-
var getFieldItem =
|
|
664
|
-
var
|
|
690
|
+
var getFieldItem = function getFieldItem() {
|
|
691
|
+
var _finalComponentProps;
|
|
692
|
+
var shouldUpdateMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
693
|
+
// 如果处于 shouldUpdate 模式,需要重新获取最新的行数据并重新计算依赖值
|
|
694
|
+
var finalComponentProps = componentProps;
|
|
695
|
+
if (shouldUpdateMode) {
|
|
696
|
+
// 重新获取最新的行数据
|
|
697
|
+
var latestRowData = form.getFieldValue([...namePath, index]) || record || {};
|
|
698
|
+
var latestOptions = {
|
|
699
|
+
index,
|
|
700
|
+
form,
|
|
701
|
+
name: column === null || column === void 0 ? void 0 : column.name,
|
|
702
|
+
namePath: [...namePath, index]
|
|
703
|
+
};
|
|
704
|
+
var latestRowParams = [latestRowData, latestOptions];
|
|
705
|
+
|
|
706
|
+
// 重新计算 fieldProps
|
|
707
|
+
var latestFieldProps = fieldProps || formItemProps || {};
|
|
708
|
+
if ((0, _lodash.isFunction)(fieldProps)) {
|
|
709
|
+
latestFieldProps = fieldProps(...latestRowParams);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// 重新计算 disabled
|
|
713
|
+
var latestDisabled = (0, _tools.getDisabled)({
|
|
714
|
+
globalControl: otherProps === null || otherProps === void 0 ? void 0 : otherProps.globalControl,
|
|
715
|
+
formDisabled: otherProps === null || otherProps === void 0 ? void 0 : otherProps.formDisabled,
|
|
716
|
+
column,
|
|
717
|
+
tabledDisabled: config === null || config === void 0 ? void 0 : config.disabled,
|
|
718
|
+
columnFieldProps: latestFieldProps,
|
|
719
|
+
params: latestRowParams
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
// 更新 componentProps 中的 disabled 和 fieldProps
|
|
723
|
+
finalComponentProps = _objectSpread(_objectSpread({}, componentProps), {}, {
|
|
724
|
+
disabled: latestDisabled
|
|
725
|
+
}, latestFieldProps);
|
|
726
|
+
}
|
|
665
727
|
var FormItem = null;
|
|
666
|
-
|
|
728
|
+
// 当 viewRender 存在时,需要排除 finalComponentProps 中的 children,避免覆盖 Container 的 children
|
|
729
|
+
var propsForTarget = isView && typeof viewRender === 'function' ? (0, _lodash.omit)(finalComponentProps, ['children']) : finalComponentProps;
|
|
730
|
+
var FieldComponent = /*#__PURE__*/_react.default.isValidElement(TargetComponent) ? ( /*#__PURE__*/_react.default.cloneElement(TargetComponent, propsForTarget)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(TargetComponent, _objectSpread({}, propsForTarget));
|
|
667
731
|
if (originalValues && !getIsNew(record)) {
|
|
668
732
|
FieldComponent = /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListChangedWrapper.default, {
|
|
669
733
|
name: cellName,
|
|
@@ -687,15 +751,15 @@ var RenderField = _ref => {
|
|
|
687
751
|
children: FieldComponent
|
|
688
752
|
});
|
|
689
753
|
}
|
|
690
|
-
if ((
|
|
691
|
-
FieldComponent = /*#__PURE__*/(0, _jsxRuntime.jsx)(_ConfirmWrapper.default, _objectSpread(_objectSpread({},
|
|
754
|
+
if ((_finalComponentProps = finalComponentProps) !== null && _finalComponentProps !== void 0 && _finalComponentProps.confirm) {
|
|
755
|
+
FieldComponent = /*#__PURE__*/(0, _jsxRuntime.jsx)(_ConfirmWrapper.default, _objectSpread(_objectSpread({}, finalComponentProps), {}, {
|
|
692
756
|
children: FieldComponent
|
|
693
757
|
}));
|
|
694
758
|
}
|
|
695
759
|
FormItem = TargetComponent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Form.Item, _objectSpread(_objectSpread({
|
|
696
760
|
validateFirst: true
|
|
697
|
-
}, (0, _lodash.omit)(finalFormItemProps, ['render', 'key', 'width', 'hiddenNames', 'name', 'onCell',
|
|
698
|
-
//
|
|
761
|
+
}, (0, _lodash.omit)(finalFormItemProps, ['render', 'key', 'width', 'hiddenNames', 'name', 'onCell', _formItemProps.shouldUpdate ? 'shouldUpdate' : null])), {}, {
|
|
762
|
+
// 移除非必要字段,但保留 dependencies
|
|
699
763
|
className: _className,
|
|
700
764
|
name: formNamePath ? cellName.slice((formNamePath === null || formNamePath === void 0 ? void 0 : formNamePath.length) - 1) : cellName,
|
|
701
765
|
children: FieldComponent
|
|
@@ -706,7 +770,7 @@ var RenderField = _ref => {
|
|
|
706
770
|
FormItem = /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Form.List, _objectSpread(_objectSpread({
|
|
707
771
|
name: formNamePath ? cellName.slice((formNamePath === null || formNamePath === void 0 ? void 0 : formNamePath.length) - 1) : cellName
|
|
708
772
|
}, (0, _lodash.omit)(finalFormItemProps, ['render', 'key', 'width', 'hiddenNames', 'name'])), {}, {
|
|
709
|
-
children: (fields, operation, meta) => /*#__PURE__*/(0, _jsxRuntime.jsx)(TargetComponent, _objectSpread(_objectSpread({},
|
|
773
|
+
children: (fields, operation, meta) => /*#__PURE__*/(0, _jsxRuntime.jsx)(TargetComponent, _objectSpread(_objectSpread({}, finalComponentProps), {}, {
|
|
710
774
|
otherProps: otherProps,
|
|
711
775
|
fields: fields,
|
|
712
776
|
operation: operation,
|
|
@@ -715,13 +779,13 @@ var RenderField = _ref => {
|
|
|
715
779
|
}));
|
|
716
780
|
}
|
|
717
781
|
return FormItem;
|
|
718
|
-
}
|
|
782
|
+
};
|
|
719
783
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_useFieldProps.FieldProvider, {
|
|
720
|
-
value: ((
|
|
784
|
+
value: ((_componentProps = componentProps) === null || _componentProps === void 0 ? void 0 : _componentProps.otherProps) || {},
|
|
721
785
|
children: finalFormItemProps.shouldUpdate ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Form.Item, {
|
|
722
786
|
noStyle: true,
|
|
723
787
|
shouldUpdate: finalFormItemProps.shouldUpdate,
|
|
724
|
-
children: () => getFieldItem()
|
|
788
|
+
children: () => getFieldItem(true)
|
|
725
789
|
}) : getFieldItem()
|
|
726
790
|
});
|
|
727
791
|
};
|
|
@@ -174,11 +174,11 @@
|
|
|
174
174
|
padding: 8px 16px;
|
|
175
175
|
&:first-child{
|
|
176
176
|
// 左下角圆角8px
|
|
177
|
-
border-bottom-left-radius:
|
|
177
|
+
border-bottom-left-radius: 6px;
|
|
178
178
|
}
|
|
179
179
|
&:last-child{
|
|
180
180
|
// 右下角圆角8px
|
|
181
|
-
border-bottom-right-radius:
|
|
181
|
+
border-bottom-right-radius: 6px;
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
.@{ant-prefix}-table-cell-fix-left,
|
|
@@ -12,6 +12,7 @@ var _utils = require("@zat-design/utils");
|
|
|
12
12
|
var _icons = require("@ant-design/icons");
|
|
13
13
|
var _config = require("./config");
|
|
14
14
|
var _tools = require("./tools");
|
|
15
|
+
var _utils2 = require("../../ProForm/utils");
|
|
15
16
|
var _ProTooltip = _interopRequireDefault(require("../../ProTooltip"));
|
|
16
17
|
var _components = require("../components");
|
|
17
18
|
var _locale = _interopRequireDefault(require("../../locale"));
|
|
@@ -91,7 +92,7 @@ var getActionColumn = config => {
|
|
|
91
92
|
action.onEvent = /*#__PURE__*/function () {
|
|
92
93
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(record, _ref) {
|
|
93
94
|
var _form$getFieldValue;
|
|
94
|
-
var index, form, name, namePath, tableLength, selectedRows, rowName,
|
|
95
|
+
var index, form, name, namePath, tableLength, selectedRows, rowName, lastRecord, onEvent, result, actionHandler;
|
|
95
96
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
96
97
|
while (1) switch (_context.prev = _context.next) {
|
|
97
98
|
case 0:
|
|
@@ -115,7 +116,7 @@ var getActionColumn = config => {
|
|
|
115
116
|
return _context.abrupt("return", Promise.reject(_context.t0));
|
|
116
117
|
case 13:
|
|
117
118
|
// 编辑状态使用自定义form值,非编辑状态直接使用行数据
|
|
118
|
-
|
|
119
|
+
lastRecord = (0, _utils2.filterInternalFields)((_form$getFieldValue = form.getFieldValue(rowName)) !== null && _form$getFieldValue !== void 0 ? _form$getFieldValue : record); // 新增事件可以设置初始默认值,当做函数的出参导出
|
|
119
120
|
onEvent = onClick || onHandle;
|
|
120
121
|
if (onEvent) {
|
|
121
122
|
_context.next = 19;
|
|
@@ -126,7 +127,7 @@ var getActionColumn = config => {
|
|
|
126
127
|
break;
|
|
127
128
|
case 19:
|
|
128
129
|
_context.next = 21;
|
|
129
|
-
return onEvent === null || onEvent === void 0 ? void 0 : onEvent(
|
|
130
|
+
return onEvent === null || onEvent === void 0 ? void 0 : onEvent(lastRecord, {
|
|
130
131
|
form,
|
|
131
132
|
index,
|
|
132
133
|
tableLength,
|
|
@@ -142,7 +143,7 @@ var getActionColumn = config => {
|
|
|
142
143
|
actionHandler(_objectSpread(_objectSpread({}, config), {}, {
|
|
143
144
|
rowName: [...name, index],
|
|
144
145
|
virtualRowName: rowName,
|
|
145
|
-
record,
|
|
146
|
+
record: lastRecord,
|
|
146
147
|
result,
|
|
147
148
|
validateKeys
|
|
148
149
|
}));
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
&.pro-group-view {
|
|
8
8
|
.@{ant-prefix}-space {
|
|
9
|
+
gap: 0 !important;
|
|
9
10
|
.@{ant-prefix}-space-item {
|
|
10
11
|
width: auto;
|
|
11
12
|
}
|
|
@@ -121,8 +122,8 @@
|
|
|
121
122
|
.@{ant-prefix}-select .@{ant-prefix}-select-selector,
|
|
122
123
|
.@{ant-prefix}-input-number,
|
|
123
124
|
.@{ant-prefix}-input-number-input {
|
|
124
|
-
border-top-left-radius:
|
|
125
|
-
border-bottom-left-radius:
|
|
125
|
+
border-top-left-radius: 6px;
|
|
126
|
+
border-bottom-left-radius: 6px;
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
|
|
@@ -132,8 +133,8 @@
|
|
|
132
133
|
.@{ant-prefix}-select .@{ant-prefix}-select-selector,
|
|
133
134
|
.@{ant-prefix}-input-number,
|
|
134
135
|
.@{ant-prefix}-input-number-input {
|
|
135
|
-
border-top-right-radius:
|
|
136
|
-
border-bottom-right-radius:
|
|
136
|
+
border-top-right-radius: 6px;
|
|
137
|
+
border-bottom-right-radius: 6px;
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -324,8 +325,8 @@
|
|
|
324
325
|
.@{ant-prefix}-select .@{ant-prefix}-select-selector,
|
|
325
326
|
.@{ant-prefix}-input-number,
|
|
326
327
|
.@{ant-prefix}-input-number-input {
|
|
327
|
-
border-top-left-radius:
|
|
328
|
-
border-bottom-left-radius:
|
|
328
|
+
border-top-left-radius: 6px;
|
|
329
|
+
border-bottom-left-radius: 6px;
|
|
329
330
|
}
|
|
330
331
|
}
|
|
331
332
|
|
|
@@ -335,8 +336,8 @@
|
|
|
335
336
|
.@{ant-prefix}-select .@{ant-prefix}-select-selector,
|
|
336
337
|
.@{ant-prefix}-input-number,
|
|
337
338
|
.@{ant-prefix}-input-number-input {
|
|
338
|
-
border-top-right-radius:
|
|
339
|
-
border-bottom-right-radius:
|
|
339
|
+
border-top-right-radius: 6px;
|
|
340
|
+
border-bottom-right-radius: 6px;
|
|
340
341
|
}
|
|
341
342
|
}
|
|
342
343
|
|
|
@@ -468,8 +469,8 @@
|
|
|
468
469
|
.pro-select .@{ant-prefix}-select,
|
|
469
470
|
.@{ant-prefix}-select,
|
|
470
471
|
.@{ant-prefix}-input-number {
|
|
471
|
-
border-top-left-radius:
|
|
472
|
-
border-bottom-left-radius:
|
|
472
|
+
border-top-left-radius: 6px;
|
|
473
|
+
border-bottom-left-radius: 6px;
|
|
473
474
|
}
|
|
474
475
|
}
|
|
475
476
|
|
|
@@ -478,8 +479,8 @@
|
|
|
478
479
|
.pro-select .@{ant-prefix}-select,
|
|
479
480
|
.@{ant-prefix}-select,
|
|
480
481
|
.@{ant-prefix}-input-number {
|
|
481
|
-
border-top-right-radius:
|
|
482
|
-
border-bottom-right-radius:
|
|
482
|
+
border-top-right-radius: 6px;
|
|
483
|
+
border-bottom-right-radius: 6px;
|
|
483
484
|
}
|
|
484
485
|
}
|
|
485
486
|
}
|
|
@@ -75,34 +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
|
-
children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
|
|
79
|
-
style?: React.CSSProperties;
|
|
80
|
-
normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
|
|
81
|
-
getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
|
|
82
|
-
valuePropName?: string;
|
|
83
|
-
viewRender?: (value: any, record: any, { form, index, namePath, }: {
|
|
84
|
-
[key: string]: any;
|
|
85
|
-
form: FormInstance<any>;
|
|
86
|
-
index?: number;
|
|
87
|
-
}) => string | React.ReactElement<any, any>;
|
|
88
|
-
isView?: boolean;
|
|
89
78
|
trim?: boolean;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
id?: string;
|
|
79
|
+
normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
|
|
80
|
+
children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
|
|
93
81
|
vertical?: boolean;
|
|
82
|
+
id?: string;
|
|
94
83
|
className?: string;
|
|
95
84
|
hidden?: boolean;
|
|
96
|
-
|
|
85
|
+
style?: React.CSSProperties;
|
|
97
86
|
onReset?: () => void;
|
|
87
|
+
prefixCls?: string;
|
|
98
88
|
rootClassName?: string;
|
|
99
|
-
|
|
89
|
+
status?: "" | "success" | "error" | "warning" | "validating";
|
|
90
|
+
trigger?: string;
|
|
100
91
|
colon?: boolean;
|
|
92
|
+
isView?: boolean;
|
|
93
|
+
desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
|
|
94
|
+
getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
|
|
95
|
+
htmlFor?: string;
|
|
101
96
|
labelAlign?: import("antd/es/form/interface").FormLabelAlign;
|
|
102
97
|
labelCol?: import("antd").ColProps;
|
|
103
98
|
getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
|
|
104
99
|
shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
|
|
100
|
+
validateTrigger?: string | false | string[];
|
|
105
101
|
validateDebounce?: number;
|
|
102
|
+
valuePropName?: string;
|
|
106
103
|
messageVariables?: Record<string, string>;
|
|
107
104
|
initialValue?: any;
|
|
108
105
|
onMetaChange?: (meta: import("@rc-component/form/lib/Field").MetaEvent) => void;
|
|
@@ -113,20 +110,23 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
113
110
|
hasFeedback?: boolean | {
|
|
114
111
|
icons: import("antd/es/form/FormItem").FeedbackIcons;
|
|
115
112
|
};
|
|
116
|
-
validateStatus?: "" | "
|
|
113
|
+
validateStatus?: "" | "success" | "error" | "warning" | "validating";
|
|
117
114
|
layout?: import("antd/es/form/Form").FormItemLayout;
|
|
118
115
|
wrapperCol?: import("antd").ColProps;
|
|
119
|
-
status?: "" | "error" | "warning" | "success" | "validating";
|
|
120
116
|
help?: React.ReactNode;
|
|
121
117
|
fieldId?: string;
|
|
122
|
-
clearNotShow?: boolean;
|
|
123
118
|
valueType?: import("../../../render/propsType").ProFormValueType;
|
|
124
119
|
switchValue?: [any, any];
|
|
120
|
+
viewRender?: (value: any, record: any, { form, index, namePath, }: {
|
|
121
|
+
[key: string]: any;
|
|
122
|
+
form: FormInstance<any>;
|
|
123
|
+
index?: number;
|
|
124
|
+
}) => string | React.ReactElement<any, any>;
|
|
125
125
|
viewType?: import("../../../render/propsType").ViewType;
|
|
126
126
|
upperCase?: boolean;
|
|
127
127
|
toISOString?: boolean;
|
|
128
128
|
toCSTString?: boolean;
|
|
129
|
-
|
|
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, "
|
|
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;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
.pro-form {
|
|
13
13
|
.@{ant-prefix}-input-disabled {
|
|
14
|
-
border-radius:
|
|
14
|
+
border-radius: 6px !important;
|
|
15
15
|
}
|
|
16
16
|
&.@{ant-prefix}-form-vertical {
|
|
17
17
|
.@{ant-prefix}-form-item .@{ant-prefix}-form-item-label {
|
|
@@ -338,7 +338,7 @@
|
|
|
338
338
|
|
|
339
339
|
.@{ant-prefix}-input, .@{ant-prefix}-select {
|
|
340
340
|
background: @zaui-contract-bg !important;
|
|
341
|
-
border-radius:
|
|
341
|
+
border-radius: 6px;
|
|
342
342
|
}
|
|
343
343
|
.@{ant-prefix}-select.@{ant-prefix}-select-disabled .@{ant-prefix}-select-selector{
|
|
344
344
|
background: @zaui-contract-bg !important;
|
package/lib/ProSelect/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PropSelectType, ProSelectActionType } from './propsType';
|
|
3
|
-
import './index.less';
|
|
3
|
+
import './style/index.less';
|
|
4
4
|
export declare const ProSelect: (props: PropSelectType, ref: React.Ref<ProSelectActionType> | undefined) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
declare const _default: React.ForwardRefExoticComponent<PropSelectType & React.RefAttributes<ProSelectActionType>>;
|
|
6
6
|
export default _default;
|
package/lib/ProSelect/index.js
CHANGED
|
@@ -14,9 +14,9 @@ var _AdaptiveTooltip = _interopRequireDefault(require("./components/AdaptiveTool
|
|
|
14
14
|
var _ = require("..");
|
|
15
15
|
var _locale = _interopRequireDefault(require("../locale"));
|
|
16
16
|
var _utils = require("./utils");
|
|
17
|
-
require("./index.less");
|
|
17
|
+
require("./style/index.less");
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
var _excluded = ["dataSource", "
|
|
19
|
+
var _excluded = ["dataSource", "useRequest", "fieldNames", "tooltip", "otherProps", "labelInValue", "filterInList", "scrollFollowParent", "defaultOne", "onSearch", "optionRender", "onChange", "transformResponse", "getValueProps", "getChangeValue", "viewportReady", "isView"];
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -48,7 +48,6 @@ var ProSelect = (props, ref) => {
|
|
|
48
48
|
}
|
|
49
49
|
var _props$dataSource = props.dataSource,
|
|
50
50
|
dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
|
|
51
|
-
defaultDisableValue = props.defaultDisableValue,
|
|
52
51
|
useRequest = props.useRequest,
|
|
53
52
|
fieldNames = props.fieldNames,
|
|
54
53
|
_props$tooltip = props.tooltip,
|
|
@@ -63,9 +62,10 @@ var ProSelect = (props, ref) => {
|
|
|
63
62
|
_onSearch = props.onSearch,
|
|
64
63
|
optionRender = props.optionRender,
|
|
65
64
|
onChange = props.onChange,
|
|
66
|
-
updateDataSource = props.updateDataSource,
|
|
67
65
|
transformResponse = props.transformResponse,
|
|
68
66
|
getValueProps = props.getValueProps,
|
|
67
|
+
getChangeValue = props.getChangeValue,
|
|
68
|
+
viewportReady = props.viewportReady,
|
|
69
69
|
isViewPro = props.isView,
|
|
70
70
|
selectProps = _objectWithoutProperties(props, _excluded);
|
|
71
71
|
selectProps.showCodeName = (_selectProps$showCode = selectProps.showCodeName) !== null && _selectProps$showCode !== void 0 ? _selectProps$showCode : showCodeName;
|
|
@@ -126,8 +126,7 @@ var ProSelect = (props, ref) => {
|
|
|
126
126
|
var responseData = transformResponse(data);
|
|
127
127
|
setSelectList(responseData);
|
|
128
128
|
} else {
|
|
129
|
-
|
|
130
|
-
updateDataSource ? updateDataSource(data, setSelectList) : defaultOnSuccessFun(data);
|
|
129
|
+
defaultOnSuccessFun(data);
|
|
131
130
|
}
|
|
132
131
|
// 执行传入onSuccess
|
|
133
132
|
useRequest === null || useRequest === void 0 || (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 || (_useRequest$options$o = _useRequest$options.onSuccess) === null || _useRequest$options$o === void 0 || _useRequest$options$o.call(_useRequest$options, data, useRequest === null || useRequest === void 0 || (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.defaultParams);
|
|
@@ -162,8 +161,7 @@ var ProSelect = (props, ref) => {
|
|
|
162
161
|
}
|
|
163
162
|
}, [fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data]);
|
|
164
163
|
(0, _ahooks.useDeepCompareEffect)(() => {
|
|
165
|
-
|
|
166
|
-
if (defaultDisableValue || !useRequest) {
|
|
164
|
+
if (!useRequest) {
|
|
167
165
|
return;
|
|
168
166
|
}
|
|
169
167
|
var _ref4 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
|
|
@@ -174,19 +172,21 @@ var ProSelect = (props, ref) => {
|
|
|
174
172
|
}
|
|
175
173
|
var params = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
|
|
176
174
|
fetchFunction.run(params);
|
|
177
|
-
}, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.options
|
|
175
|
+
}, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.options]);
|
|
178
176
|
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
177
|
+
// 处理 defaultOne 逻辑:当 dataSource 只有一个值且没有 value 时,自动设置默认值
|
|
178
|
+
(0, _react.useEffect)(() => {
|
|
179
|
+
if (defaultOne && !value && !isDefaultOne && (selectList === null || selectList === void 0 ? void 0 : selectList.length) === 1) {
|
|
180
|
+
var option = selectList === null || selectList === void 0 ? void 0 : selectList[0];
|
|
181
|
+
if (option && option[code] !== undefined && option[code] !== null) {
|
|
182
|
+
setIsDefaultOne(true);
|
|
183
|
+
// 使用 setTimeout 确保在下一个事件循环中调用,避免在渲染过程中更新状态
|
|
184
|
+
setTimeout(() => {
|
|
185
|
+
onChange === null || onChange === void 0 || onChange(option[code], option);
|
|
186
|
+
}, 0);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}, [defaultOne, value, isDefaultOne, selectList, code, onChange]);
|
|
190
190
|
var transToLabel = value => {
|
|
191
191
|
if (!Array.isArray(selectList) || !selectList.length) {
|
|
192
192
|
return viewEmpty;
|
|
@@ -259,7 +259,6 @@ var ProSelect = (props, ref) => {
|
|
|
259
259
|
if (labelInValue && (isReactElement(_option) || isReactElement(_option === null || _option === void 0 ? void 0 : _option.children))) {
|
|
260
260
|
option = _option === null || _option === void 0 ? void 0 : _option.record;
|
|
261
261
|
}
|
|
262
|
-
var getChangeValue = selectProps.getChangeValue;
|
|
263
262
|
if (selectProps.mode && selectProps.mode === 'multiple') {
|
|
264
263
|
if (Array.isArray(option)) {
|
|
265
264
|
option.forEach(item => {
|
|
@@ -302,18 +301,17 @@ var ProSelect = (props, ref) => {
|
|
|
302
301
|
if (selectProps.mode && value === null) {
|
|
303
302
|
return undefined;
|
|
304
303
|
}
|
|
305
|
-
|
|
304
|
+
// 只有当 dataSource 只有一个值时才默认回填(只返回值,不进行状态更新)
|
|
305
|
+
if (defaultOne && !value && !isDefaultOne && (selectList === null || selectList === void 0 ? void 0 : selectList.length) === 1) {
|
|
306
306
|
var option = selectList === null || selectList === void 0 ? void 0 : selectList[0];
|
|
307
307
|
// selectList 可能是异步回来的值
|
|
308
308
|
if (option) {
|
|
309
|
-
setIsDefaultOne(true);
|
|
310
|
-
onChange === null || onChange === void 0 || onChange(option === null || option === void 0 ? void 0 : option[code], option);
|
|
311
309
|
return option === null || option === void 0 ? void 0 : option[code];
|
|
312
310
|
}
|
|
313
311
|
}
|
|
314
312
|
// 修复空字符placeholder不显示
|
|
315
313
|
if (value === '') {
|
|
316
|
-
return
|
|
314
|
+
return undefined;
|
|
317
315
|
}
|
|
318
316
|
return value;
|
|
319
317
|
};
|
|
@@ -348,12 +346,15 @@ var ProSelect = (props, ref) => {
|
|
|
348
346
|
getPopupContainer: trigger => {
|
|
349
347
|
return scrollFollowParent ? trigger.parentElement : document.body;
|
|
350
348
|
}
|
|
351
|
-
}, (0, _lodash.omit)(_objectSpread({}, selectProps), ['isView', 'showCodeName', 'form', 'name', 'style', 'onFieldChange'])), {}, {
|
|
349
|
+
}, (0, _lodash.omit)(_objectSpread({}, selectProps), ['isView', 'showCodeName', 'form', 'name', 'style', 'onFieldChange', 'getChangeValue', 'viewportReady'])), {}, {
|
|
352
350
|
value: transformValue(),
|
|
353
|
-
children: Array.isArray(newSelectList) && newSelectList.map(item => {
|
|
351
|
+
children: Array.isArray(newSelectList) && newSelectList.map((item, index) => {
|
|
352
|
+
var itemValue = item[code];
|
|
353
|
+
var itemKey = itemValue != null ? `${itemValue}-${index}` : `option-${index}`;
|
|
354
|
+
var optionValue = itemValue != null ? itemValue : undefined;
|
|
354
355
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Option, {
|
|
355
356
|
label: item[label],
|
|
356
|
-
value:
|
|
357
|
+
value: optionValue,
|
|
357
358
|
record: item,
|
|
358
359
|
disabled: !!item.disabled,
|
|
359
360
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(TooltipOption, {
|
|
@@ -363,8 +364,8 @@ var ProSelect = (props, ref) => {
|
|
|
363
364
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
364
365
|
children: selectProps.showCodeName ? `${item[code]}-${item[label]}` : item[label]
|
|
365
366
|
})
|
|
366
|
-
}
|
|
367
|
-
},
|
|
367
|
+
})
|
|
368
|
+
}, itemKey);
|
|
368
369
|
})
|
|
369
370
|
}))
|
|
370
371
|
});
|
|
@@ -50,11 +50,6 @@ export interface PropSelectType extends Omit<SelectProps, 'onSearch'> {
|
|
|
50
50
|
* @default false
|
|
51
51
|
*/
|
|
52
52
|
filterInList?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* @deprecated 兼容 2.0 版本、3.0 使用view 模式
|
|
55
|
-
* @default -
|
|
56
|
-
*/
|
|
57
|
-
defaultDisableValue?: string;
|
|
58
53
|
/**
|
|
59
54
|
* @description 是否展示 tooltip、当 label 特别长的时候使用
|
|
60
55
|
* @default false
|
|
@@ -89,13 +84,6 @@ export interface PropSelectType extends Omit<SelectProps, 'onSearch'> {
|
|
|
89
84
|
*/
|
|
90
85
|
options?: Options<any, any>;
|
|
91
86
|
};
|
|
92
|
-
/**
|
|
93
|
-
* @deprecated 兼容 2.0 版本、3.0 使用 transformResponse
|
|
94
|
-
* @param data 数据
|
|
95
|
-
* @param setSelectList 设置选择列表的函数
|
|
96
|
-
* @returns
|
|
97
|
-
*/
|
|
98
|
-
updateDataSource?: (data: any, setSelectList: any) => void;
|
|
99
87
|
/**
|
|
100
88
|
* @description 格式化数据
|
|
101
89
|
* @param data 后台返回的数据
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zat-design/sisyphus-react",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -57,10 +57,7 @@
|
|
|
57
57
|
"browserslist": [
|
|
58
58
|
"last 2 versions",
|
|
59
59
|
"Firefox ESR",
|
|
60
|
-
"> 1%"
|
|
61
|
-
"ie >= 11",
|
|
62
|
-
"iOS >= 7",
|
|
63
|
-
"Android >= 4"
|
|
60
|
+
"> 1%"
|
|
64
61
|
],
|
|
65
62
|
"overrides": {
|
|
66
63
|
"react-resizable": {
|
|
@@ -90,9 +87,9 @@
|
|
|
90
87
|
"react-svg": "^15.1.7"
|
|
91
88
|
},
|
|
92
89
|
"peerDependencies": {
|
|
93
|
-
"antd": "^6.0.0",
|
|
94
|
-
"react": "^18.3.0",
|
|
95
|
-
"react-dom": "^18.3.0",
|
|
90
|
+
"antd": "^6.0.0",
|
|
91
|
+
"react": "^18.3.0 || ^19.0.0",
|
|
92
|
+
"react-dom": "^18.3.0 || ^19.0.0",
|
|
96
93
|
"react-router-dom": "^6.0.0"
|
|
97
94
|
},
|
|
98
95
|
"devDependencies": {
|
|
File without changes
|
|
File without changes
|