@zat-design/sisyphus-react 4.1.2-beta.1 → 4.1.2-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claudeignore +40 -0
- package/dist/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/ProEditTable/components/RcTable/BaseTable.js +12 -16
- package/es/ProEditTable/components/RcTable/DraggableTable.js +11 -16
- package/es/ProEditTable/components/RenderField/index.js +292 -97
- package/es/ProEditTable/index.js +14 -4
- package/es/ProEditTable/propsType.d.ts +6 -1
- package/es/ProEditTable/style/index.less +8 -0
- package/es/ProEditTable/utils/index.js +66 -24
- package/es/ProEditTable/utils/useShouldUpdateForTable.d.ts +1 -0
- package/es/ProEditTable/utils/useShouldUpdateForTable.js +37 -10
- package/es/ProForm/components/base/DatePicker/index.js +1 -7
- package/es/ProForm/components/base/RangePicker/index.js +62 -8
- package/es/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
- package/es/ProForm/components/combination/Group/component/ComRender.js +15 -11
- package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
- package/es/ProForm/components/combination/Group/style/index.less +26 -1
- package/es/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
- package/es/ProForm/propsType.d.ts +3 -3
- package/es/ProForm/utils/transformValue.d.ts +1 -1
- package/es/ProForm/utils/useForm.d.ts +1 -1
- package/es/ProForm/utils/useWatch.d.ts +2 -1
- package/es/ProForm/utils/useWatch.js +3 -1
- package/es/ProSelect/index.js +117 -62
- package/es/ProUpload/propsType.d.ts +1 -1
- package/es/ProUpload/style/index.less +3 -3
- package/lib/ProEditTable/components/RcTable/BaseTable.js +11 -15
- package/lib/ProEditTable/components/RcTable/DraggableTable.js +11 -16
- package/lib/ProEditTable/components/RenderField/index.js +292 -97
- package/lib/ProEditTable/index.js +14 -4
- package/lib/ProEditTable/propsType.d.ts +6 -1
- package/lib/ProEditTable/style/index.less +8 -0
- package/lib/ProEditTable/utils/index.js +67 -23
- package/lib/ProEditTable/utils/useShouldUpdateForTable.d.ts +1 -0
- package/lib/ProEditTable/utils/useShouldUpdateForTable.js +37 -10
- package/lib/ProForm/components/base/DatePicker/index.js +1 -7
- package/lib/ProForm/components/base/RangePicker/index.js +62 -8
- package/lib/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
- package/lib/ProForm/components/combination/Group/component/ComRender.js +15 -11
- package/lib/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
- package/lib/ProForm/components/combination/Group/style/index.less +26 -1
- package/lib/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
- package/lib/ProForm/propsType.d.ts +3 -3
- package/lib/ProForm/utils/transformValue.d.ts +1 -1
- package/lib/ProForm/utils/useForm.d.ts +1 -1
- package/lib/ProForm/utils/useWatch.d.ts +2 -1
- package/lib/ProForm/utils/useWatch.js +3 -1
- package/lib/ProSelect/index.js +115 -61
- package/lib/ProUpload/propsType.d.ts +1 -1
- package/lib/ProUpload/style/index.less +3 -3
- package/package.json +4 -2
|
@@ -127,16 +127,16 @@ var FlexibleGroupRender = props => {
|
|
|
127
127
|
var childDisabled = typeof child.disabled === 'function' ? false : child.disabled;
|
|
128
128
|
var finalDisabled = groupDisabled || childDisabled;
|
|
129
129
|
|
|
130
|
-
// 构建 formItemProps
|
|
130
|
+
// 构建 formItemProps - 在非编辑态时移除校验规则
|
|
131
131
|
var formItemProps = {
|
|
132
132
|
name: fullName,
|
|
133
133
|
label: child.label,
|
|
134
|
-
rules: child.rules,
|
|
134
|
+
rules: isView ? undefined : child.rules,
|
|
135
135
|
dependencies: processedDependencies,
|
|
136
136
|
extra: child.extra,
|
|
137
137
|
before: child.before,
|
|
138
138
|
after: child.after,
|
|
139
|
-
required: child.required,
|
|
139
|
+
required: isView ? undefined : child.required,
|
|
140
140
|
disabled: finalDisabled,
|
|
141
141
|
validateFirst: child.validateFirst
|
|
142
142
|
};
|
|
@@ -157,13 +157,40 @@ var FlexibleGroupRender = props => {
|
|
|
157
157
|
formItemProps.tooltip = child.tooltip;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
// 在ProEditTable场景下,如果同组其他字段有值,则当前字段空值不显示 -
|
|
161
|
+
var childViewEmpty = otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewEmpty;
|
|
162
|
+
if (isView && (otherProps === null || otherProps === void 0 ? void 0 : otherProps.source) === 'ProEditTable' && form && children.length > 1) {
|
|
163
|
+
// 检查同组其他字段是否有值
|
|
164
|
+
var hasOtherValues = children.some(otherChild => {
|
|
165
|
+
if (otherChild === child) return false; // 跳过当前字段
|
|
166
|
+
|
|
167
|
+
var otherChildNamePath = otherChild.namePath || contextProps.namePath;
|
|
168
|
+
var otherFullName = (() => {
|
|
169
|
+
if (otherChildNamePath && Array.isArray(otherChild.name) && otherChild.name.length > 1) {
|
|
170
|
+
return [...otherChildNamePath, ...otherChild.name];
|
|
171
|
+
}
|
|
172
|
+
if (otherChildNamePath) {
|
|
173
|
+
return [...otherChildNamePath, otherChild.name];
|
|
174
|
+
}
|
|
175
|
+
return otherChild.name;
|
|
176
|
+
})();
|
|
177
|
+
var value = form.getFieldValue(otherFullName);
|
|
178
|
+
return value !== undefined && value !== null && value !== '';
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// 如果有其他字段有值,当前字段空值显示为空字符串
|
|
182
|
+
if (hasOtherValues) {
|
|
183
|
+
childViewEmpty = '';
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
160
187
|
// 构建 otherProps
|
|
161
188
|
var renderOtherProps = {
|
|
162
189
|
label: child.label,
|
|
163
190
|
name: fullName,
|
|
164
191
|
disabled: finalDisabled,
|
|
165
192
|
isView,
|
|
166
|
-
viewEmpty:
|
|
193
|
+
viewEmpty: childViewEmpty,
|
|
167
194
|
valueType: child.valueType,
|
|
168
195
|
form,
|
|
169
196
|
type,
|
|
@@ -277,12 +304,16 @@ var FlexibleGroupRender = props => {
|
|
|
277
304
|
elements.push(formElement);
|
|
278
305
|
|
|
279
306
|
// 添加分隔符
|
|
280
|
-
|
|
307
|
+
// 查看模式下,如果没有配置separator,使用默认的 finalSeparator
|
|
308
|
+
var separatorToUse = isView ? (space === null || space === void 0 ? void 0 : space.separator) || finalSeparator : space === null || space === void 0 ? void 0 : space.separator;
|
|
309
|
+
if (index < visibleChildren.length - 1 && separatorToUse) {
|
|
281
310
|
var shouldAddSeparator = space.separatorIndex ? Array.isArray(space.separatorIndex) ? space.separatorIndex.includes(originalIndex) : space.separatorIndex === originalIndex : true;
|
|
282
311
|
if (shouldAddSeparator) {
|
|
312
|
+
// 查看模式下使用不同的className,避免显示边框
|
|
313
|
+
var separatorClassName = isView ? 'pro-group-separator-compact pro-group-separator-view' : 'pro-group-separator-compact';
|
|
283
314
|
elements.push( /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
284
|
-
className:
|
|
285
|
-
children:
|
|
315
|
+
className: separatorClassName,
|
|
316
|
+
children: separatorToUse
|
|
286
317
|
}, child.name ? `separator-${child.name}` : `separator-${originalIndex}`));
|
|
287
318
|
}
|
|
288
319
|
}
|
|
@@ -312,6 +343,29 @@ var FlexibleGroupRender = props => {
|
|
|
312
343
|
return (otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewEmpty) || '-';
|
|
313
344
|
}
|
|
314
345
|
|
|
346
|
+
// 查看模式下,检查所有children的值是否都为空
|
|
347
|
+
if (isView && form && children.length > 0) {
|
|
348
|
+
var allValuesEmpty = children.every(child => {
|
|
349
|
+
var childNamePath = child.namePath || contextProps.namePath;
|
|
350
|
+
var fullName = (() => {
|
|
351
|
+
if (childNamePath && Array.isArray(child.name) && child.name.length > 1) {
|
|
352
|
+
return [...childNamePath, ...child.name];
|
|
353
|
+
}
|
|
354
|
+
if (childNamePath) {
|
|
355
|
+
return [...childNamePath, child.name];
|
|
356
|
+
}
|
|
357
|
+
return child.name;
|
|
358
|
+
})();
|
|
359
|
+
var value = form.getFieldValue(fullName);
|
|
360
|
+
return value === undefined || value === null || value === '';
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// 如果所有值都为空,显示一个 -
|
|
364
|
+
if (allValuesEmpty) {
|
|
365
|
+
return (otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewEmpty) || '-';
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
315
369
|
// 渲染内容
|
|
316
370
|
var renderContent = () => {
|
|
317
371
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
display: flex;
|
|
5
5
|
width: unset !important;
|
|
6
6
|
|
|
7
|
+
&.pro-group-view {
|
|
8
|
+
.pro-group-form-item {
|
|
9
|
+
flex: 0 0 auto !important;
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
.@{ant-prefix}-space-compact .pro-group-separator-compact{
|
|
13
|
+
color: #333 !important;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
7
16
|
|
|
8
17
|
|
|
9
18
|
&.pro-group-view {
|
|
@@ -385,6 +394,13 @@
|
|
|
385
394
|
// margin: 0 !important;
|
|
386
395
|
}
|
|
387
396
|
|
|
397
|
+
// 查看模式下,Form.Item不平分空间,而是根据内容自适应
|
|
398
|
+
&.pro-group-view {
|
|
399
|
+
.pro-group-form-item {
|
|
400
|
+
flex: 0 0 auto;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
388
404
|
// 当有自定义宽度时,只有设置了宽度的 Form.Item 不使用 flex:1
|
|
389
405
|
&.pro-group-diy-width {
|
|
390
406
|
// 覆盖 Space.Compact 内设置了宽度的 Form.Item
|
|
@@ -430,7 +446,7 @@
|
|
|
430
446
|
}
|
|
431
447
|
|
|
432
448
|
.@{ant-prefix}-input-number-input {
|
|
433
|
-
border-left:
|
|
449
|
+
border-left: 0 !important;
|
|
434
450
|
}
|
|
435
451
|
}
|
|
436
452
|
|
|
@@ -467,6 +483,15 @@
|
|
|
467
483
|
margin-left: -1px;
|
|
468
484
|
}
|
|
469
485
|
|
|
486
|
+
// 查看模式下的分隔符样式 - 移除边框,使用简洁样式
|
|
487
|
+
.pro-group-separator-view {
|
|
488
|
+
border: none !important;
|
|
489
|
+
background: transparent !important;
|
|
490
|
+
padding: 0 2px !important;
|
|
491
|
+
margin-inline-start: 0 !important;
|
|
492
|
+
color: #999 !important;
|
|
493
|
+
}
|
|
494
|
+
|
|
470
495
|
|
|
471
496
|
/* 1. 处理第一个子元素:左上、左下圆角 */
|
|
472
497
|
> .pro-group-form-item:first-child{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { DefaultOptionType } from 'rc-select/
|
|
2
|
+
import { DefaultOptionType } from '@rc-component/select/es/Select';
|
|
3
3
|
import { Service, Options } from 'ahooks/lib/useRequest/src/types';
|
|
4
4
|
export interface FieldNamesType {
|
|
5
5
|
label: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
1
2
|
import { ButtonProps, ColProps, RowProps } from 'antd';
|
|
2
3
|
import { FormProps, FormInstance } from 'antd/es/form/Form';
|
|
3
4
|
import { NamePath } from 'antd/es/form/interface';
|
|
4
|
-
import { StoreValue, Store } from 'rc-
|
|
5
|
-
import { ShouldUpdate } from 'rc-
|
|
6
|
-
import React, { ReactNode } from 'react';
|
|
5
|
+
import type { StoreValue, Store } from '@rc-component/form/es/interface';
|
|
6
|
+
import type { ShouldUpdate } from '@rc-component/form/es/Field';
|
|
7
7
|
import type { ProFormColumnType, ViewType } from './components/render/propsType';
|
|
8
8
|
import type { ProFormComponentType } from './components';
|
|
9
9
|
export interface ButtonType extends ButtonProps {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormInstance, FormItemProps } from 'antd';
|
|
2
2
|
import { NamePath } from 'antd/es/form/interface';
|
|
3
|
-
import { StoreValue, Store } from 'rc-
|
|
3
|
+
import type { StoreValue, Store } from '@rc-component/form/es/interface';
|
|
4
4
|
import type { TransformType } from '../propsType';
|
|
5
5
|
export declare const transformValue: (names: NamePath[], form: FormInstance, fieldName: NamePath, normalize?: (value: StoreValue, prevValue: StoreValue, allValues: Store) => StoreValue, getValueProps?: FormItemProps['getValueProps']) => TransformType;
|
|
6
6
|
export default transformValue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormInstance } from 'antd';
|
|
2
2
|
import { NamePath } from 'antd/es/form/interface';
|
|
3
|
-
import { ValuedNotifyInfo } from 'rc-
|
|
3
|
+
import type { ValuedNotifyInfo } from '@rc-component/form/es/interface';
|
|
4
4
|
export type ModifiedFormInstanceType<T> = FormInstance<T> & {
|
|
5
5
|
isModified?: boolean;
|
|
6
6
|
/** 默认清空设置值的报错状态 */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FormInstance
|
|
1
|
+
import { FormInstance } from 'antd/es/form/Form';
|
|
2
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
2
3
|
export declare function toArray<T>(value?: T | T[] | null): T[];
|
|
3
4
|
/**
|
|
4
5
|
* ProForm的useWatch hook,用于监听表单字段变化
|
package/lib/ProSelect/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var _locale = _interopRequireDefault(require("../locale"));
|
|
|
16
16
|
var _utils = require("./utils");
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
18
|
var _excluded = ["dataSource", "useRequest", "fieldNames", "tooltip", "otherProps", "labelInValue", "filterInList", "scrollFollowParent", "defaultOne", "onSearch", "optionRender", "onChange", "transformResponse", "getValueProps", "getChangeValue", "viewportReady", "isView"];
|
|
19
|
+
/** 将 selectList(扁平或分组)转为扁平选项列表,用于查找、回显、defaultOne */
|
|
19
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
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); }
|
|
21
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; }
|
|
@@ -32,10 +33,6 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
32
33
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
33
34
|
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; }
|
|
34
35
|
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; }
|
|
35
|
-
var Option = _antd.Select.Option,
|
|
36
|
-
OptGroup = _antd.Select.OptGroup;
|
|
37
|
-
|
|
38
|
-
/** 将 selectList(扁平或分组)转为扁平选项列表,用于查找、回显、defaultOne */
|
|
39
36
|
function flattenOptions(list) {
|
|
40
37
|
if (!Array.isArray(list) || !list.length) return [];
|
|
41
38
|
var out = [];
|
|
@@ -49,7 +46,7 @@ function flattenOptions(list) {
|
|
|
49
46
|
return out;
|
|
50
47
|
}
|
|
51
48
|
var ProSelect = (props, ref) => {
|
|
52
|
-
var _selectProps$showCode, _useRequest$options3, _locale$ProSelect;
|
|
49
|
+
var _selectProps$showCode, _ProForm$useFieldProp, _useRequest$options3, _locale$ProSelect;
|
|
53
50
|
var _ref = (0, _ProConfigProvider.useProConfig)('ProSelect') || {},
|
|
54
51
|
_ref$fieldNames = _ref.fieldNames,
|
|
55
52
|
proSelectFieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames,
|
|
@@ -84,7 +81,7 @@ var ProSelect = (props, ref) => {
|
|
|
84
81
|
selectProps = _objectWithoutProperties(props, _excluded);
|
|
85
82
|
selectProps.showCodeName = (_selectProps$showCode = selectProps.showCodeName) !== null && _selectProps$showCode !== void 0 ? _selectProps$showCode : showCodeName;
|
|
86
83
|
var value = getValueProps && props.value ? getValueProps(props.value) : props.value;
|
|
87
|
-
var _ref2 = _.ProForm.useFieldProps() || {},
|
|
84
|
+
var _ref2 = (_.ProForm === null || _.ProForm === void 0 || (_ProForm$useFieldProp = _.ProForm.useFieldProps) === null || _ProForm$useFieldProp === void 0 ? void 0 : _ProForm$useFieldProp.call(_.ProForm)) || {},
|
|
88
85
|
isViewCon = _ref2.isView,
|
|
89
86
|
viewEmpty = _ref2.viewEmpty;
|
|
90
87
|
var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
|
|
@@ -146,6 +143,10 @@ var ProSelect = (props, ref) => {
|
|
|
146
143
|
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);
|
|
147
144
|
}
|
|
148
145
|
}));
|
|
146
|
+
var fetchFunctionRef = (0, _react.useRef)(fetchFunction);
|
|
147
|
+
(0, _react.useEffect)(() => {
|
|
148
|
+
fetchFunctionRef.current = fetchFunction;
|
|
149
|
+
}, [fetchFunction]);
|
|
149
150
|
var cacheList = useRequest !== null && useRequest !== void 0 && (_useRequest$options3 = useRequest.options) !== null && _useRequest$options3 !== void 0 && _useRequest$options3.cacheKey ? successTransformDataHandle(fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data) : [];
|
|
150
151
|
var flatOptions = flattenOptions(selectList);
|
|
151
152
|
var getValueObject = input => {
|
|
@@ -323,16 +324,99 @@ var ProSelect = (props, ref) => {
|
|
|
323
324
|
return props.children;
|
|
324
325
|
};
|
|
325
326
|
var isReactElement = element => /*#__PURE__*/(0, _react.isValidElement)(element);
|
|
327
|
+
var getInnerRecord = option => {
|
|
328
|
+
var _option$data;
|
|
329
|
+
if (!option) return undefined;
|
|
330
|
+
if (option.record) return option.record;
|
|
331
|
+
if ((_option$data = option.data) !== null && _option$data !== void 0 && _option$data.record) return option.data.record;
|
|
332
|
+
return undefined;
|
|
333
|
+
};
|
|
334
|
+
var getOptionText = item => {
|
|
335
|
+
if (OptionRender) {
|
|
336
|
+
var _item$label;
|
|
337
|
+
var rendered = OptionRender(item);
|
|
338
|
+
return (0, _lodash.isString)(rendered) ? rendered : String((_item$label = item[label]) !== null && _item$label !== void 0 ? _item$label : '');
|
|
339
|
+
}
|
|
340
|
+
var text = selectProps.showCodeName ? `${item[code]}-${item[label]}` : item[label];
|
|
341
|
+
return (0, _lodash.isString)(text) ? text : String(text !== null && text !== void 0 ? text : '');
|
|
342
|
+
};
|
|
343
|
+
var buildOptionItem = (item, index) => {
|
|
344
|
+
var text = getOptionText(item);
|
|
345
|
+
return {
|
|
346
|
+
key: item[code] != null ? `${item[code]}-${index}` : `option-${index}`,
|
|
347
|
+
label: text,
|
|
348
|
+
value: item[code] != null ? item[code] : undefined,
|
|
349
|
+
disabled: !!item.disabled,
|
|
350
|
+
title: text,
|
|
351
|
+
searchText: text,
|
|
352
|
+
record: item
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
var selectOptionRender = option => {
|
|
356
|
+
var _option$data2, _ref5, _ref6, _option$data$searchTe, _option$data3, _option$data4;
|
|
357
|
+
var currentRecord = (option === null || option === void 0 || (_option$data2 = option.data) === null || _option$data2 === void 0 ? void 0 : _option$data2.record) || (option === null || option === void 0 ? void 0 : option.record);
|
|
358
|
+
var text = (_ref5 = (_ref6 = (_option$data$searchTe = option === null || option === void 0 || (_option$data3 = option.data) === null || _option$data3 === void 0 ? void 0 : _option$data3.searchText) !== null && _option$data$searchTe !== void 0 ? _option$data$searchTe : option === null || option === void 0 || (_option$data4 = option.data) === null || _option$data4 === void 0 ? void 0 : _option$data4.title) !== null && _ref6 !== void 0 ? _ref6 : option === null || option === void 0 ? void 0 : option.label) !== null && _ref5 !== void 0 ? _ref5 : '';
|
|
359
|
+
if (!currentRecord) {
|
|
360
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TooltipOption, {
|
|
361
|
+
title: String(text),
|
|
362
|
+
children: String(text)
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TooltipOption, {
|
|
366
|
+
title: String(text),
|
|
367
|
+
children: OptionRender ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
368
|
+
children: OptionRender(currentRecord)
|
|
369
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
370
|
+
children: String(text)
|
|
371
|
+
})
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
var defaultFilterOption = (0, _react.useCallback)((input, option) => {
|
|
375
|
+
var _ref7, _option$searchText;
|
|
376
|
+
if ((option === null || option === void 0 ? void 0 : option.value) == null) return false;
|
|
377
|
+
var optionLabel = (_ref7 = (_option$searchText = option === null || option === void 0 ? void 0 : option.searchText) !== null && _option$searchText !== void 0 ? _option$searchText : option === null || option === void 0 ? void 0 : option.title) !== null && _ref7 !== void 0 ? _ref7 : option === null || option === void 0 ? void 0 : option.label;
|
|
378
|
+
return String(optionLabel !== null && optionLabel !== void 0 ? optionLabel : '').toLowerCase().includes(input.toLowerCase());
|
|
379
|
+
}, []);
|
|
380
|
+
var mergedShowSearch = (0, _react.useMemo)(() => {
|
|
381
|
+
var defaultConfig = {
|
|
382
|
+
enabled: true,
|
|
383
|
+
filterOption: (0, _lodash.isFunction)(_onSearch) ? false : defaultFilterOption,
|
|
384
|
+
onSearch: searchValue => {
|
|
385
|
+
_onSearch === null || _onSearch === void 0 || _onSearch(searchValue, _objectSpread({}, fetchFunctionRef.current));
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
var customShowSearch = selectProps.showSearch;
|
|
389
|
+
if (customShowSearch === false) {
|
|
390
|
+
return _objectSpread(_objectSpread({}, defaultConfig), {}, {
|
|
391
|
+
enabled: false
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
if (customShowSearch === true || customShowSearch == null) {
|
|
395
|
+
return defaultConfig;
|
|
396
|
+
}
|
|
397
|
+
if ((0, _lodash.isObject)(customShowSearch)) {
|
|
398
|
+
var _customShowSearch$fil, _customShowSearch$onS;
|
|
399
|
+
return _objectSpread(_objectSpread(_objectSpread({}, defaultConfig), customShowSearch), {}, {
|
|
400
|
+
enabled: true,
|
|
401
|
+
filterOption: (_customShowSearch$fil = customShowSearch.filterOption) !== null && _customShowSearch$fil !== void 0 ? _customShowSearch$fil : defaultConfig.filterOption,
|
|
402
|
+
onSearch: (_customShowSearch$onS = customShowSearch.onSearch) !== null && _customShowSearch$onS !== void 0 ? _customShowSearch$onS : defaultConfig.onSearch
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
return defaultConfig;
|
|
406
|
+
}, [_onSearch, defaultFilterOption, selectProps.showSearch]);
|
|
326
407
|
var handleChange = (value, _option) => {
|
|
327
408
|
// option/其第一层子节点是react节点且是labelInValue就拿record
|
|
328
409
|
var option = _option;
|
|
329
410
|
if (labelInValue && (isReactElement(_option) || isReactElement(_option === null || _option === void 0 ? void 0 : _option.children))) {
|
|
330
|
-
option = _option
|
|
411
|
+
option = getInnerRecord(_option);
|
|
331
412
|
}
|
|
332
413
|
if (selectProps.mode && selectProps.mode === 'multiple') {
|
|
333
414
|
if (Array.isArray(option)) {
|
|
334
415
|
option.forEach(item => {
|
|
335
|
-
|
|
416
|
+
var currentRecord = getInnerRecord(item);
|
|
417
|
+
if (currentRecord) {
|
|
418
|
+
Object.assign(item, currentRecord);
|
|
419
|
+
}
|
|
336
420
|
delete item.record;
|
|
337
421
|
delete item.children;
|
|
338
422
|
});
|
|
@@ -345,7 +429,7 @@ var ProSelect = (props, ref) => {
|
|
|
345
429
|
} else if (!selectProps.mode && labelInValue) {
|
|
346
430
|
onChange(getChangeValue ? getChangeValue(getValueObject(value)) : getValueObject(value), option);
|
|
347
431
|
} else {
|
|
348
|
-
onChange === null || onChange === void 0 || onChange(getChangeValue ? getChangeValue(value) : value, _option
|
|
432
|
+
onChange === null || onChange === void 0 || onChange(getChangeValue ? getChangeValue(value) : value, getInnerRecord(_option));
|
|
349
433
|
}
|
|
350
434
|
};
|
|
351
435
|
|
|
@@ -396,71 +480,41 @@ var ProSelect = (props, ref) => {
|
|
|
396
480
|
mode: selectProps.mode
|
|
397
481
|
});
|
|
398
482
|
}
|
|
483
|
+
var selectOptions = Array.isArray(newSelectList) ? newSelectList.map((item, index) => {
|
|
484
|
+
var groupOptions = item.options;
|
|
485
|
+
if (Array.isArray(groupOptions)) {
|
|
486
|
+
var _item$label2;
|
|
487
|
+
return {
|
|
488
|
+
key: (_item$label2 = item[label]) !== null && _item$label2 !== void 0 ? _item$label2 : `group-${index}`,
|
|
489
|
+
label: item[label],
|
|
490
|
+
options: groupOptions.map((opt, optIndex) => buildOptionItem(opt, optIndex))
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
return buildOptionItem(item, index);
|
|
494
|
+
}) : [];
|
|
495
|
+
var selectSearchProps = {
|
|
496
|
+
filterOption: mergedShowSearch.filterOption,
|
|
497
|
+
onSearch: mergedShowSearch.onSearch
|
|
498
|
+
};
|
|
399
499
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
400
500
|
style: props.style,
|
|
401
501
|
className: "pro-select",
|
|
402
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Select, _objectSpread(_objectSpread({
|
|
502
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Select, _objectSpread(_objectSpread(_objectSpread({
|
|
403
503
|
placeholder: _locale.default === null || _locale.default === void 0 || (_locale$ProSelect = _locale.default.ProSelect) === null || _locale$ProSelect === void 0 ? void 0 : _locale$ProSelect.select,
|
|
404
504
|
allowClear: true,
|
|
405
505
|
loading: fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.loading,
|
|
406
506
|
onChange: handleChange,
|
|
407
|
-
showSearch:
|
|
408
|
-
|
|
409
|
-
var _option$children;
|
|
410
|
-
if ((option === null || option === void 0 ? void 0 : option.value) == null) return false;
|
|
411
|
-
var value = (0, _lodash.isString)(option === null || option === void 0 ? void 0 : option.children) ? option === null || option === void 0 ? void 0 : option.children : option === null || option === void 0 || (_option$children = option.children) === null || _option$children === void 0 || (_option$children = _option$children.props) === null || _option$children === void 0 ? void 0 : _option$children.title;
|
|
412
|
-
return value.toLowerCase().includes(input.toLowerCase());
|
|
413
|
-
},
|
|
414
|
-
onSearch: value => {
|
|
415
|
-
_onSearch && _onSearch(value, _objectSpread({}, fetchFunction));
|
|
416
|
-
},
|
|
507
|
+
showSearch: mergedShowSearch.enabled
|
|
508
|
+
}, selectSearchProps), {}, {
|
|
417
509
|
getPopupContainer: trigger => {
|
|
418
510
|
return scrollFollowParent ? trigger.parentElement : document.body;
|
|
419
511
|
}
|
|
420
|
-
}, (0, _lodash.omit)(_objectSpread({}, selectProps), ['isView', 'showCodeName', 'form', 'name', 'style', 'onFieldChange', 'getChangeValue', 'viewportReady'])), {}, {
|
|
512
|
+
}, (0, _lodash.omit)(_objectSpread({}, selectProps), ['isView', 'showCodeName', 'form', 'name', 'style', 'onFieldChange', 'getChangeValue', 'viewportReady', 'showSearch'])), {}, {
|
|
421
513
|
// 如果是多选模式且用户没有自定义maxTagPlaceholder,使用我们的hover版本
|
|
422
514
|
maxTagPlaceholder: selectProps.mode === 'multiple' && !selectProps.maxTagPlaceholder ? maxTagPlaceholder : selectProps.maxTagPlaceholder,
|
|
515
|
+
optionRender: selectOptionRender,
|
|
423
516
|
value: transformValue(),
|
|
424
|
-
|
|
425
|
-
var itemValue = item[code];
|
|
426
|
-
var itemKey = itemValue != null ? `${itemValue}-${index}` : `option-${index}`;
|
|
427
|
-
var optionValue = itemValue != null ? itemValue : undefined;
|
|
428
|
-
var groupOpts = item.options;
|
|
429
|
-
if (Array.isArray(groupOpts)) {
|
|
430
|
-
var _item$label;
|
|
431
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(OptGroup, {
|
|
432
|
-
label: item[label],
|
|
433
|
-
children: groupOpts.map(opt => /*#__PURE__*/(0, _jsxRuntime.jsx)(Option, {
|
|
434
|
-
label: selectProps.showCodeName ? `${opt[code]}-${opt[label]}` : opt[label],
|
|
435
|
-
value: opt[code],
|
|
436
|
-
record: opt,
|
|
437
|
-
disabled: !!opt.disabled,
|
|
438
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(TooltipOption, {
|
|
439
|
-
title: OptionRender ? OptionRender(opt) : selectProps.showCodeName ? `${opt[code]}-${opt[label]}` : opt[label],
|
|
440
|
-
children: OptionRender ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
441
|
-
children: OptionRender(opt)
|
|
442
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
443
|
-
children: selectProps.showCodeName ? `${opt[code]}-${opt[label]}` : opt[label]
|
|
444
|
-
})
|
|
445
|
-
})
|
|
446
|
-
}, opt[code]))
|
|
447
|
-
}, (_item$label = item[label]) !== null && _item$label !== void 0 ? _item$label : `group-${index}`);
|
|
448
|
-
}
|
|
449
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Option, {
|
|
450
|
-
label: selectProps.showCodeName ? `${item[code]}-${item[label]}` : item[label],
|
|
451
|
-
value: optionValue,
|
|
452
|
-
record: item,
|
|
453
|
-
disabled: !!item.disabled,
|
|
454
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(TooltipOption, {
|
|
455
|
-
title: OptionRender ? OptionRender(item) : selectProps.showCodeName ? `${item[code]}-${item[label]}` : item[label],
|
|
456
|
-
children: OptionRender ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
457
|
-
children: OptionRender(item)
|
|
458
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
459
|
-
children: selectProps.showCodeName ? `${item[code]}-${item[label]}` : item[label]
|
|
460
|
-
})
|
|
461
|
-
})
|
|
462
|
-
}, itemKey);
|
|
463
|
-
})
|
|
517
|
+
options: selectOptions
|
|
464
518
|
}))
|
|
465
519
|
});
|
|
466
520
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UploadFile } from 'antd/es/upload/interface';
|
|
3
|
-
import { UploadRequestOption } from 'rc-upload/
|
|
3
|
+
import type { UploadRequestOption } from '@rc-component/upload/es/interface';
|
|
4
4
|
export type UploadType = 'drag' | 'button' | 'image';
|
|
5
5
|
export interface UploadFileResType {
|
|
6
6
|
/**
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
.file-name {
|
|
87
|
-
display:
|
|
87
|
+
display: flex;
|
|
88
88
|
overflow: hidden;
|
|
89
89
|
word-break: break-all;
|
|
90
90
|
line-clamp: 1;
|
|
@@ -362,7 +362,7 @@
|
|
|
362
362
|
position: absolute;
|
|
363
363
|
}
|
|
364
364
|
.file-name {
|
|
365
|
-
display:
|
|
365
|
+
display: flex;
|
|
366
366
|
padding-left: var(--zaui-space-size-lg, 32px);
|
|
367
367
|
overflow: hidden;
|
|
368
368
|
line-clamp: 1;
|
|
@@ -429,7 +429,7 @@
|
|
|
429
429
|
position: absolute;
|
|
430
430
|
}
|
|
431
431
|
.file-name {
|
|
432
|
-
display:
|
|
432
|
+
display: flex;
|
|
433
433
|
padding-left: var(--zaui-space-size-sm, 8px);
|
|
434
434
|
overflow: hidden;
|
|
435
435
|
line-clamp: 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zat-design/sisyphus-react",
|
|
3
|
-
"version": "4.1.2-beta.
|
|
3
|
+
"version": "4.1.2-beta.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -44,6 +44,8 @@
|
|
|
44
44
|
"lint": "npm run lint:js && npm run lint:style && npm run lint:prettier",
|
|
45
45
|
"lint-staged": "lint-staged",
|
|
46
46
|
"lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx --ignore-pattern '**/__tests__/**' --ignore-pattern '**/*.test.*' --ignore-pattern '**/*.spec.*'",
|
|
47
|
+
"code-standards:check": "node ./scripts/code-standards-check.mjs",
|
|
48
|
+
"git:pull:dev_4": "git pull --tags --no-rebase origin dev_4",
|
|
47
49
|
"lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
|
|
48
50
|
"lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
|
|
49
51
|
"lint:prettier": "prettier --check \"**/*\" --end-of-line auto",
|
|
@@ -62,7 +64,7 @@
|
|
|
62
64
|
"husky": {
|
|
63
65
|
"hooks": {
|
|
64
66
|
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
|
|
65
|
-
"pre-commit": "npm run lint-staged"
|
|
67
|
+
"pre-commit": "npm run lint-staged && npm run code-standards:check"
|
|
66
68
|
}
|
|
67
69
|
},
|
|
68
70
|
"lint-staged": {
|