@zat-design/sisyphus-react 3.4.5 → 3.4.6-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.
Files changed (137) hide show
  1. package/dist/index.esm.css +151 -35
  2. package/dist/less.esm.css +151 -35
  3. package/es/ProConfigProvider/index.d.ts +2 -2
  4. package/es/ProConfigProvider/index.js +0 -3
  5. package/es/ProEditTable/components/RenderField/index.js +56 -48
  6. package/es/ProEditTable/index.js +3 -3
  7. package/es/ProEditTable/style/index.less +5 -7
  8. package/es/ProEditTable/utils/tools.d.ts +12 -0
  9. package/es/ProEditTable/utils/tools.js +79 -2
  10. package/es/ProForm/components/base/RangePicker/index.js +9 -9
  11. package/es/ProForm/components/base/TextArea/index.d.ts +1 -0
  12. package/es/ProForm/components/base/TextArea/index.js +4 -2
  13. package/es/ProForm/components/combination/Container/index.js +3 -2
  14. package/es/ProForm/components/combination/Container/style/index.less +5 -1
  15. package/es/ProForm/components/combination/FormList/index.js +1 -0
  16. package/es/ProForm/components/combination/{ProAddressBar → ProCascader}/index.d.ts +2 -2
  17. package/es/ProForm/components/combination/ProCascader/index.js +256 -0
  18. package/es/ProForm/components/combination/{ProAddressBar → ProCascader}/propsType.d.ts +9 -6
  19. package/es/ProForm/components/combination/ProCascader/utils/index.d.ts +14 -0
  20. package/es/ProForm/components/combination/ProCascader/utils/index.js +26 -0
  21. package/es/ProForm/components/combination/ProModalSelect/index.js +47 -33
  22. package/es/ProForm/components/combination/ProModalSelect/style/index.less +23 -0
  23. package/es/ProForm/components/combination/ProRangeLimit/index.d.ts +2 -2
  24. package/es/ProForm/components/combination/ProRangeLimit/index.js +17 -10
  25. package/es/ProForm/components/index.d.ts +1 -2
  26. package/es/ProForm/components/index.js +1 -4
  27. package/es/ProForm/components/render/Render.js +25 -20
  28. package/es/ProForm/components/render/RenderFields.js +4 -1
  29. package/es/ProForm/components/render/propsType.d.ts +5 -8
  30. package/es/ProForm/index.js +6 -2
  31. package/es/ProForm/propsType.d.ts +3 -0
  32. package/es/ProForm/style/index.less +2 -1
  33. package/es/ProForm/utils/index.d.ts +6 -1
  34. package/es/ProForm/utils/index.js +9 -6
  35. package/es/ProForm/utils/useChanged.js +1 -2
  36. package/es/ProForm/utils/useForm.js +19 -6
  37. package/es/ProForm/utils/useListChanged.js +1 -3
  38. package/es/ProIcon/config/index.d.ts +2 -0
  39. package/es/ProIcon/config/index.js +4 -2
  40. package/es/ProIcon/index.js +148 -81
  41. package/es/ProIcon/propsTypes.d.ts +6 -1
  42. package/es/ProIcon/utils/index.d.ts +5 -0
  43. package/es/ProIcon/utils/index.js +60 -0
  44. package/es/ProLayout/components/ProCollapse/index.js +6 -3
  45. package/es/ProLayout/components/ProCollapse/style/index.less +1 -1
  46. package/es/ProSelect/index.js +15 -3
  47. package/es/ProSelect/propsType.d.ts +2 -0
  48. package/es/ProSelect/utils/index.d.ts +9 -0
  49. package/es/ProSelect/utils/index.js +60 -0
  50. package/es/ProStep/components/Step/index.js +4 -3
  51. package/es/ProStep/style/index.less +37 -0
  52. package/es/ProTable/utils.js +6 -3
  53. package/es/ProThemeTools/component/PrdTools/index.d.ts +1 -1
  54. package/es/ProThemeTools/component/PrdTools/index.js +16 -6
  55. package/es/ProThemeTools/component/PrdTools/style/index.less +56 -48
  56. package/es/ProTree/components/ProTree.js +96 -74
  57. package/es/ProTree/components/ProTreeSelect/index.js +5 -9
  58. package/es/ProTree/components/ProTreeSelect/style/index.less +6 -8
  59. package/es/ProTree/components/Tree.js +63 -41
  60. package/es/ProTree/style/index.less +38 -16
  61. package/es/ProUpload/index.js +11 -13
  62. package/es/ProUpload/propsType.d.ts +8 -3
  63. package/es/assets/view.svg +2 -2
  64. package/es/global.less +37 -28
  65. package/lib/ProConfigProvider/index.d.ts +2 -2
  66. package/lib/ProConfigProvider/index.js +0 -3
  67. package/lib/ProEditTable/components/RenderField/index.js +54 -46
  68. package/lib/ProEditTable/index.js +3 -3
  69. package/lib/ProEditTable/style/index.less +5 -7
  70. package/lib/ProEditTable/utils/tools.d.ts +12 -0
  71. package/lib/ProEditTable/utils/tools.js +80 -2
  72. package/lib/ProForm/components/base/RangePicker/index.js +9 -9
  73. package/lib/ProForm/components/base/TextArea/index.d.ts +1 -0
  74. package/lib/ProForm/components/base/TextArea/index.js +4 -2
  75. package/lib/ProForm/components/combination/Container/index.js +3 -2
  76. package/lib/ProForm/components/combination/Container/style/index.less +5 -1
  77. package/lib/ProForm/components/combination/FormList/index.js +1 -0
  78. package/lib/ProForm/components/combination/{ProAddressBar → ProCascader}/index.d.ts +2 -2
  79. package/lib/ProForm/components/combination/ProCascader/index.js +256 -0
  80. package/lib/ProForm/components/combination/{ProAddressBar → ProCascader}/propsType.d.ts +9 -6
  81. package/lib/ProForm/components/combination/ProCascader/utils/index.d.ts +14 -0
  82. package/lib/ProForm/components/combination/ProCascader/utils/index.js +33 -0
  83. package/lib/ProForm/components/combination/ProModalSelect/index.js +46 -32
  84. package/lib/ProForm/components/combination/ProModalSelect/style/index.less +23 -0
  85. package/lib/ProForm/components/combination/ProRangeLimit/index.d.ts +2 -2
  86. package/lib/ProForm/components/combination/ProRangeLimit/index.js +17 -10
  87. package/lib/ProForm/components/index.d.ts +1 -2
  88. package/lib/ProForm/components/index.js +1 -8
  89. package/lib/ProForm/components/render/Render.js +25 -20
  90. package/lib/ProForm/components/render/RenderFields.js +4 -1
  91. package/lib/ProForm/components/render/propsType.d.ts +5 -8
  92. package/lib/ProForm/index.js +5 -1
  93. package/lib/ProForm/propsType.d.ts +3 -0
  94. package/lib/ProForm/style/index.less +2 -1
  95. package/lib/ProForm/utils/index.d.ts +6 -1
  96. package/lib/ProForm/utils/index.js +9 -6
  97. package/lib/ProForm/utils/useChanged.js +1 -2
  98. package/lib/ProForm/utils/useForm.js +19 -6
  99. package/lib/ProForm/utils/useListChanged.js +1 -3
  100. package/lib/ProIcon/config/index.d.ts +2 -0
  101. package/lib/ProIcon/config/index.js +4 -2
  102. package/lib/ProIcon/index.js +144 -77
  103. package/lib/ProIcon/propsTypes.d.ts +6 -1
  104. package/lib/ProIcon/utils/index.d.ts +5 -0
  105. package/lib/ProIcon/utils/index.js +62 -1
  106. package/lib/ProLayout/components/ProCollapse/index.js +6 -3
  107. package/lib/ProLayout/components/ProCollapse/style/index.less +1 -1
  108. package/lib/ProSelect/index.js +15 -3
  109. package/lib/ProSelect/propsType.d.ts +2 -0
  110. package/lib/ProSelect/utils/index.d.ts +9 -0
  111. package/lib/ProSelect/utils/index.js +68 -0
  112. package/lib/ProStep/components/Step/index.js +4 -3
  113. package/lib/ProStep/style/index.less +37 -0
  114. package/lib/ProTable/utils.js +6 -3
  115. package/lib/ProThemeTools/component/PrdTools/index.d.ts +1 -1
  116. package/lib/ProThemeTools/component/PrdTools/index.js +16 -6
  117. package/lib/ProThemeTools/component/PrdTools/style/index.less +56 -48
  118. package/lib/ProTree/components/ProTree.js +96 -74
  119. package/lib/ProTree/components/ProTreeSelect/index.js +5 -9
  120. package/lib/ProTree/components/ProTreeSelect/style/index.less +6 -8
  121. package/lib/ProTree/components/Tree.js +63 -41
  122. package/lib/ProTree/style/index.less +38 -16
  123. package/lib/ProUpload/index.js +10 -12
  124. package/lib/ProUpload/propsType.d.ts +8 -3
  125. package/lib/assets/view.svg +2 -2
  126. package/lib/global.less +37 -28
  127. package/package.json +2 -2
  128. package/es/ProForm/components/base/ProCascader/index.d.ts +0 -14
  129. package/es/ProForm/components/base/ProCascader/index.js +0 -72
  130. package/es/ProForm/components/combination/ProAddressBar/index.js +0 -437
  131. package/lib/ProForm/components/base/ProCascader/index.d.ts +0 -14
  132. package/lib/ProForm/components/base/ProCascader/index.js +0 -78
  133. package/lib/ProForm/components/combination/ProAddressBar/index.js +0 -437
  134. /package/es/ProForm/components/combination/{ProAddressBar → ProCascader}/propsType.js +0 -0
  135. /package/es/ProForm/components/combination/{ProAddressBar → ProCascader}/style/index.less +0 -0
  136. /package/lib/ProForm/components/combination/{ProAddressBar → ProCascader}/propsType.js +0 -0
  137. /package/lib/ProForm/components/combination/{ProAddressBar → ProCascader}/style/index.less +0 -0
@@ -0,0 +1,256 @@
1
+ import "antd/es/input/style";
2
+ import _Input from "antd/es/input";
3
+ import "antd/es/cascader/style";
4
+ import _Cascader from "antd/es/cascader";
5
+ import "antd/es/tooltip/style";
6
+ import _Tooltip from "antd/es/tooltip";
7
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
8
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
9
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
10
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
11
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
12
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
13
+ import "antd/es/typography/style";
14
+ import _Typography from "antd/es/typography";
15
+ var _excluded = ["className", "hasDetail", "detailMaxLength", "fieldNames", "value", "disabled", "dataSource", "onChange", "useRequest", "transformResponse", "level", "isView", "enumCode", "code", "tooltip", "separator"];
16
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
+ import { useEffect, useState, memo, useMemo } from 'react';
18
+ import { isEqual, omit } from 'lodash';
19
+ import { transformDataName } from './utils/index';
20
+ import { useProConfig } from '../../../../ProConfigProvider';
21
+ import useEnum from '../../../../ProEnum/hooks/useEnum';
22
+ import locale from '../../../../locale';
23
+ import ProForm from '../../..';
24
+ var Text = _Typography.Text;
25
+ var filterDataSource = function filterDataSource(dataSource, level) {
26
+ return dataSource === null || dataSource === void 0 ? void 0 : dataSource.map(function (item) {
27
+ return _objectSpread(_objectSpread({}, item), {}, {
28
+ children: level === 1 ? [] : filterDataSource(item === null || item === void 0 ? void 0 : item.children, level - 1)
29
+ });
30
+ });
31
+ };
32
+ var getViewLabel = function getViewLabel(_ref) {
33
+ var dataSource = _ref.dataSource,
34
+ value = _ref.value;
35
+ var viewLabel = [];
36
+ // 根据dataSource得到label数组,查看模式展示需要
37
+ value === null || value === void 0 ? void 0 : value.forEach(function (value, index) {
38
+ var _dataSource;
39
+ var temp = (_dataSource = dataSource) === null || _dataSource === void 0 ? void 0 : _dataSource.find(function (item) {
40
+ return (item === null || item === void 0 ? void 0 : item.value) === value;
41
+ });
42
+ dataSource = (temp === null || temp === void 0 ? void 0 : temp.children) || [];
43
+ viewLabel[index] = temp === null || temp === void 0 ? void 0 : temp.label;
44
+ });
45
+ return viewLabel;
46
+ };
47
+ var defaultFieldNames = {
48
+ label: 'name',
49
+ value: 'code',
50
+ children: 'children'
51
+ };
52
+ var ProCascader = function ProCascader(props) {
53
+ var _value$slice, _ref7, _ref7$filter, _defaultLabel$filter, _locale$ProAddressBar, _locale$ProAddressBar2;
54
+ var _ref2 = useProConfig('ProAddressBar') || {},
55
+ configDetailMaxLength = _ref2.detailMaxLength,
56
+ configEnumCode = _ref2.enumCode,
57
+ configCode = _ref2.code;
58
+ var isAddressMode = (props === null || props === void 0 ? void 0 : props.mode) === 'address';
59
+ var _props$className = props.className,
60
+ className = _props$className === void 0 ? '' : _props$className,
61
+ _props$hasDetail = props.hasDetail,
62
+ hasDetail = _props$hasDetail === void 0 ? isAddressMode ? true : undefined : _props$hasDetail,
63
+ _props$detailMaxLengt = props.detailMaxLength,
64
+ detailMaxLength = _props$detailMaxLengt === void 0 ? isAddressMode ? configDetailMaxLength || 100 : 100 : _props$detailMaxLengt,
65
+ _props$fieldNames = props.fieldNames,
66
+ fieldNames = _props$fieldNames === void 0 ? defaultFieldNames : _props$fieldNames,
67
+ value = props.value,
68
+ disabled = props.disabled,
69
+ dataSource = props.dataSource,
70
+ onChange = props.onChange,
71
+ useRequest = props.useRequest,
72
+ transformResponse = props.transformResponse,
73
+ _props$level = props.level,
74
+ level = _props$level === void 0 ? isAddressMode ? 3 : undefined : _props$level,
75
+ isView = props.isView,
76
+ _props$enumCode = props.enumCode,
77
+ enumCode = _props$enumCode === void 0 ? configEnumCode : _props$enumCode,
78
+ _props$code = props.code,
79
+ code = _props$code === void 0 ? configCode : _props$code,
80
+ tooltip = props.tooltip,
81
+ _props$separator = props.separator,
82
+ separator = _props$separator === void 0 ? '' : _props$separator,
83
+ otherProps = _objectWithoutProperties(props, _excluded);
84
+ var _ref3 = ProForm.useFieldProps() || {},
85
+ isViewCon = _ref3.isView;
86
+ var addressCode = code || enumCode;
87
+ var realIsView = typeof isView === 'boolean' ? isView : isViewCon;
88
+ var realLevel = Math.max(2, level);
89
+ var detail = value === null || value === void 0 ? void 0 : value[realLevel];
90
+ var enumData = useEnum(addressCode);
91
+ var _ref4 = Array.isArray(enumData) ? enumData : [],
92
+ _ref5 = _slicedToArray(_ref4, 1),
93
+ _ref5$ = _ref5[0],
94
+ enumDataSource = _ref5$ === void 0 ? [] : _ref5$;
95
+ var realDataSource = useMemo(function () {
96
+ var innerDataSource = dataSource || (addressCode ? enumDataSource : []);
97
+ var result = isAddressMode && realLevel === 2 ? filterDataSource(innerDataSource, level) : innerDataSource;
98
+ return isEqual(fieldNames, defaultFieldNames) ? result : transformDataName(result, fieldNames);
99
+ }, [isAddressMode, addressCode, realLevel, dataSource, enumDataSource === null || enumDataSource === void 0 ? void 0 : enumDataSource.length]);
100
+ var _useRequest = _objectSpread({}, useRequest),
101
+ service = _useRequest.service,
102
+ _useRequest$defaultPa = _useRequest.defaultParams,
103
+ defaultParams = _useRequest$defaultPa === void 0 ? {} : _useRequest$defaultPa;
104
+ var _useState = useState([]),
105
+ _useState2 = _slicedToArray(_useState, 2),
106
+ serviceData = _useState2[0],
107
+ setServiceData = _useState2[1];
108
+ var _useState3 = useState([]),
109
+ _useState4 = _slicedToArray(_useState3, 2),
110
+ defaultLabel = _useState4[0],
111
+ setDefaultLabel = _useState4[1];
112
+ var getFirstLevelOptions = /*#__PURE__*/function () {
113
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
114
+ var _yield$service, data, newData, transFormData, serviceData;
115
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
116
+ while (1) switch (_context.prev = _context.next) {
117
+ case 0:
118
+ _context.next = 2;
119
+ return service(defaultParams);
120
+ case 2:
121
+ _yield$service = _context.sent;
122
+ data = _yield$service.data;
123
+ newData = data;
124
+ if (transformResponse) {
125
+ newData = transformResponse(data);
126
+ }
127
+ transFormData = transformDataName(newData, {
128
+ label: fieldNames.label,
129
+ value: fieldNames.value,
130
+ children: (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'
131
+ });
132
+ serviceData = isAddressMode && realLevel === 2 ? filterDataSource(transFormData, level) : transFormData;
133
+ setServiceData(serviceData);
134
+ case 9:
135
+ case "end":
136
+ return _context.stop();
137
+ }
138
+ }, _callee);
139
+ }));
140
+ return function getFirstLevelOptions() {
141
+ return _ref6.apply(this, arguments);
142
+ };
143
+ }();
144
+ useEffect(function () {
145
+ if (service) {
146
+ // 传入useRequest时,初次加载级联第一级数据源
147
+ getFirstLevelOptions();
148
+ }
149
+ }, [service]);
150
+ useEffect(function () {
151
+ if (realIsView && value) {
152
+ // 传入dataSource + 查看时初始化展示
153
+ if (service) {
154
+ setDefaultLabel(getViewLabel({
155
+ dataSource: serviceData,
156
+ value: isAddressMode && hasDetail ? value === null || value === void 0 ? void 0 : value.slice(0, realLevel) : value
157
+ }));
158
+ } else if ((realDataSource === null || realDataSource === void 0 ? void 0 : realDataSource.length) > 0) {
159
+ setDefaultLabel(getViewLabel({
160
+ dataSource: realDataSource,
161
+ value: isAddressMode && hasDetail ? value === null || value === void 0 ? void 0 : value.slice(0, realLevel) : value
162
+ }));
163
+ }
164
+ }
165
+ }, [realIsView, value, realDataSource, serviceData]);
166
+ var handleChange = function handleChange(changeValue, selectedOptions) {
167
+ if (onChange) {
168
+ if (isAddressMode && hasDetail && detail) {
169
+ // 有详情地址
170
+ var realValue = changeValue || [];
171
+ realValue[realLevel] = detail;
172
+ onChange(realValue, selectedOptions);
173
+ } else {
174
+ onChange(changeValue, selectedOptions);
175
+ }
176
+ }
177
+ };
178
+ // showSearch中的筛选函数
179
+ var handlefilter = function handlefilter(inputValue, path) {
180
+ return path.some(function (option) {
181
+ return option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1;
182
+ });
183
+ };
184
+ var handleAddressChange = function handleAddressChange(e) {
185
+ var cascaderValue = value === null || value === void 0 ? void 0 : value.slice(0, realLevel);
186
+ if (onChange) {
187
+ if (!e.target.value && (cascaderValue === null || cascaderValue === void 0 ? void 0 : cascaderValue.every(function (item) {
188
+ return !item;
189
+ }))) {
190
+ onChange(undefined);
191
+ } else {
192
+ var realValue = value ? _toConsumableArray(value) : [];
193
+ realValue[realLevel] = e.target.value;
194
+ onChange(realValue);
195
+ }
196
+ }
197
+ };
198
+ var displayRender = function displayRender(label) {
199
+ return label === null || label === void 0 ? void 0 : label.filter(function (item) {
200
+ return !!item;
201
+ }).join('/');
202
+ };
203
+ var addressValue = isAddressMode ? value && ((_value$slice = value.slice(0, realLevel)) === null || _value$slice === void 0 ? void 0 : _value$slice.some(function (item) {
204
+ return !!item;
205
+ })) ? value.slice(0, realLevel) : undefined : value;
206
+ var viewValue = isAddressMode ? ((_ref7 = [].concat(_toConsumableArray(defaultLabel), [value === null || value === void 0 ? void 0 : value[realLevel]])) === null || _ref7 === void 0 ? void 0 : (_ref7$filter = _ref7.filter(function (item) {
207
+ return !!item;
208
+ })) === null || _ref7$filter === void 0 ? void 0 : _ref7$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
209
+ return !!item;
210
+ })) === null || _defaultLabel$filter === void 0 ? void 0 : _defaultLabel$filter.join(separator)) || '-';
211
+ return realIsView ? tooltip ? _jsx(_Tooltip, {
212
+ className: className,
213
+ title: tooltip === true ? viewValue : tooltip,
214
+ children: _jsx(Text, {
215
+ ellipsis: {
216
+ tooltip: false
217
+ },
218
+ children: viewValue
219
+ })
220
+ }) : _jsx("span", {
221
+ className: className,
222
+ children: viewValue
223
+ }) : _jsxs("div", {
224
+ className: "pro-address ".concat(className),
225
+ children: [_jsx(_Cascader, _objectSpread({
226
+ className: hasDetail ? '' : 'no-detail',
227
+ placeholder: locale === null || locale === void 0 ? void 0 : (_locale$ProAddressBar = locale.ProAddressBar) === null || _locale$ProAddressBar === void 0 ? void 0 : _locale$ProAddressBar.placeholder,
228
+ value: addressValue,
229
+ options: service ? serviceData : realDataSource,
230
+ disabled: disabled,
231
+ displayRender: displayRender,
232
+ showSearch: {
233
+ filter: handlefilter
234
+ },
235
+ onChange: handleChange
236
+ }, omit(otherProps, 'otherProps'))), hasDetail && (tooltip && disabled && detail ? _jsx(_Tooltip, {
237
+ title: detail,
238
+ children: _jsx("span", {
239
+ className: "pro-address-detail",
240
+ children: _jsx(_Input, {
241
+ disabled: disabled,
242
+ value: detail
243
+ })
244
+ })
245
+ }) : _jsx(_Input, {
246
+ allowClear: true,
247
+ autoComplete: "off",
248
+ disabled: disabled,
249
+ value: detail,
250
+ maxLength: detailMaxLength,
251
+ placeholder: locale === null || locale === void 0 ? void 0 : (_locale$ProAddressBar2 = locale.ProAddressBar) === null || _locale$ProAddressBar2 === void 0 ? void 0 : _locale$ProAddressBar2.detailPlaceholder,
252
+ onChange: handleAddressChange
253
+ }))]
254
+ });
255
+ };
256
+ export default /*#__PURE__*/memo(ProCascader);
@@ -1,19 +1,22 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { DefaultOptionType } from 'rc-select/lib/Select';
3
3
  import { Service } from 'ahooks/lib/useRequest/src/types';
4
- export interface AddressProps {
5
- getPopupContainer?: () => ReactNode;
4
+ export interface fieldNamesProps {
5
+ label: string;
6
+ value: string;
7
+ children?: string;
8
+ [key: string]: string;
9
+ }
10
+ export interface ProCascaderProps {
6
11
  className?: string;
12
+ mode?: 'address' | 'default';
7
13
  isView?: boolean;
8
14
  value?: string[];
9
15
  disabled?: boolean;
10
16
  hasDetail?: boolean;
11
17
  tooltip?: boolean | ReactNode;
12
18
  detailMaxLength?: number;
13
- fieldNames?: {
14
- label: string;
15
- value: string;
16
- };
19
+ fieldNames?: fieldNamesProps;
17
20
  dataSource?: DefaultOptionType[];
18
21
  useRequest?: {
19
22
  loadData?: boolean;
@@ -0,0 +1,14 @@
1
+ interface DataNode {
2
+ label: string;
3
+ value: string;
4
+ children?: DataNode[];
5
+ [key: string]: any;
6
+ }
7
+ interface FieldNames {
8
+ label: string;
9
+ value: string;
10
+ children?: string;
11
+ [key: string]: string;
12
+ }
13
+ export declare const transformDataName: (dataSource: any[], fieldNames: FieldNames) => DataNode[];
14
+ export {};
@@ -0,0 +1,26 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ var _excluded = ["label", "value", "children"];
3
+ export var transformDataName = function transformDataName(dataSource, fieldNames) {
4
+ var label = fieldNames.label,
5
+ value = fieldNames.value,
6
+ children = fieldNames.children,
7
+ extraFields = _objectWithoutProperties(fieldNames, _excluded);
8
+ function transformNode(node) {
9
+ var newNode = {
10
+ label: node[label],
11
+ value: node[value]
12
+ };
13
+ // 处理额外的字段
14
+ Object.keys(extraFields).forEach(function (key) {
15
+ newNode[key] = node[extraFields[key]];
16
+ });
17
+ if (children && Array.isArray(node[children])) {
18
+ newNode.children = node[children].map(transformNode);
19
+ }
20
+ return newNode;
21
+ }
22
+ function transformData(data) {
23
+ return data.map(transformNode);
24
+ }
25
+ return transformData(dataSource);
26
+ };
@@ -21,7 +21,7 @@ var _excluded = ["value", "onChange", "disabled", "labelInValue", "fieldNames",
21
21
  _excluded3 = ["rowKey", "columns", "rowSelection"];
22
22
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
23
23
  import { SearchOutlined } from '@ant-design/icons';
24
- import { useMount, useSetState } from 'ahooks';
24
+ import { useDeepCompareEffect, useMount, useSetState } from 'ahooks';
25
25
  import { cloneDeep, debounce, isArray, isEqual, isFunction, omit } from 'lodash';
26
26
  import { ReactSVG } from 'react-svg';
27
27
  import React, { forwardRef, useEffect, useImperativeHandle, useMemo } from 'react';
@@ -295,58 +295,64 @@ var ProModalSelect = function ProModalSelect(props, ref) {
295
295
  };
296
296
  var handleFinish = /*#__PURE__*/function () {
297
297
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
298
- var _data, flag, res;
298
+ var _nextSelectedRows, _nextSelectedRows2, nextSelectedRows, record, flag, res;
299
299
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
300
300
  while (1) switch (_context2.prev = _context2.next) {
301
301
  case 0:
302
302
  _context2.prev = 0;
303
- if (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) {
303
+ if (selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.length) {
304
304
  _context2.next = 4;
305
305
  break;
306
306
  }
307
307
  _message.error(locale.ProModalSelect.checkMsg);
308
308
  return _context2.abrupt("return", false);
309
309
  case 4:
310
- _data = isMultiple ? selectedRows : selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows[0];
310
+ nextSelectedRows = selectedRows;
311
+ if (!((_nextSelectedRows = nextSelectedRows) === null || _nextSelectedRows === void 0 ? void 0 : _nextSelectedRows[0])) {
312
+ nextSelectedRows = data.filter(function (item) {
313
+ return selectedRowKeys.includes(item[valueKey]);
314
+ });
315
+ }
316
+ record = isMultiple ? nextSelectedRows : (_nextSelectedRows2 = nextSelectedRows) === null || _nextSelectedRows2 === void 0 ? void 0 : _nextSelectedRows2[0];
311
317
  if (!isMultiple) {
312
318
  // @ts-ignore
313
- _data.value = _data[valueKey];
319
+ record.value = record[valueKey];
314
320
  // @ts-ignore
315
- _data.label = _data[labelKey];
321
+ record.label = record[labelKey];
316
322
  }
317
323
  flag = true;
318
324
  if (!onOk) {
319
- _context2.next = 12;
325
+ _context2.next = 14;
320
326
  break;
321
327
  }
322
- _context2.next = 10;
323
- return onOk(_data);
324
- case 10:
328
+ _context2.next = 12;
329
+ return onOk(record);
330
+ case 12:
325
331
  res = _context2.sent;
326
332
  if (res !== null && res !== undefined) {
327
333
  // @ts-ignore
328
334
  flag = res;
329
335
  }
330
- case 12:
336
+ case 14:
331
337
  if (flag) {
332
- onChange === null || onChange === void 0 ? void 0 : onChange(labelInValue ? _data : getNextValues(_data), _data);
338
+ onChange === null || onChange === void 0 ? void 0 : onChange(labelInValue ? record : getNextValues(record), record);
333
339
  // 更新内部展示值
334
340
  setState({
335
- _value: _data,
336
- options: isArray(_data) ? _data : [_data]
341
+ _value: record,
342
+ options: isArray(record) ? record : [record]
337
343
  });
338
344
  handleClose();
339
345
  }
340
346
  return _context2.abrupt("return", flag);
341
- case 16:
342
- _context2.prev = 16;
347
+ case 18:
348
+ _context2.prev = 18;
343
349
  _context2.t0 = _context2["catch"](0);
344
- console.log('error', _context2.t0);
345
- case 19:
350
+ console.warn('error', _context2.t0);
351
+ case 21:
346
352
  case "end":
347
353
  return _context2.stop();
348
354
  }
349
- }, _callee2, null, [[0, 16]]);
355
+ }, _callee2, null, [[0, 18]]);
350
356
  }));
351
357
  return function handleFinish() {
352
358
  return _ref7.apply(this, arguments);
@@ -427,7 +433,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
427
433
  // 初始化回显,当传入initParams时,前端用来回险
428
434
  var getInitValues = /*#__PURE__*/function () {
429
435
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
430
- var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _list, list, _res$data2, _data2, nextSelectRowKeys;
436
+ var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _list, list, _res$data2, _data, nextSelectRowKeys;
431
437
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
432
438
  while (1) switch (_context4.prev = _context4.next) {
433
439
  case 0:
@@ -458,15 +464,15 @@ var ProModalSelect = function ProModalSelect(props, ref) {
458
464
  } else {
459
465
  list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.list : res === null || res === void 0 ? void 0 : res.data;
460
466
  }
461
- _data2 = isMultiple ? list : (_list = list) === null || _list === void 0 ? void 0 : _list[0];
462
- if (_data2) {
467
+ _data = isMultiple ? list : (_list = list) === null || _list === void 0 ? void 0 : _list[0];
468
+ if (_data) {
463
469
  nextSelectRowKeys = isMultiple ? value : [value];
464
470
  if (labelInValue) {
465
- onChange(_data2);
471
+ onChange(_data);
466
472
  }
467
473
  // 更新内部展示值
468
474
  setState({
469
- _value: _data2,
475
+ _value: _data,
470
476
  isInit: false,
471
477
  selectedRows: list,
472
478
  selectedRowKeys: nextSelectRowKeys
@@ -493,7 +499,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
493
499
  var getDefaultOneValues = /*#__PURE__*/function () {
494
500
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
495
501
  var _useRequest$options4, _useRequest$options5;
496
- var queryBean, page, params, res, _list2, list, _res$data3, _data3, nextSelectRowKeys;
502
+ var queryBean, page, params, res, _list2, list, _res$data3, _data2, nextSelectRowKeys;
497
503
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
498
504
  while (1) switch (_context5.prev = _context5.next) {
499
505
  case 0:
@@ -517,18 +523,18 @@ var ProModalSelect = function ProModalSelect(props, ref) {
517
523
  } else {
518
524
  list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.list : res === null || res === void 0 ? void 0 : res.data;
519
525
  }
520
- _data3 = isMultiple ? list : (_list2 = list) === null || _list2 === void 0 ? void 0 : _list2[0];
526
+ _data2 = isMultiple ? list : (_list2 = list) === null || _list2 === void 0 ? void 0 : _list2[0];
521
527
  nextSelectRowKeys = isMultiple ? value : [value];
522
528
  if (labelInValue) {
523
- onChange(_data3);
529
+ onChange(_data2);
524
530
  } else {
525
- onChange(isMultiple ? _data3.map(function (item) {
531
+ onChange(isMultiple ? _data2.map(function (item) {
526
532
  return item[valueKey];
527
- }) : _data3[valueKey]);
533
+ }) : _data2[valueKey]);
528
534
  }
529
535
  // 更新内部展示值
530
536
  setState({
531
- _value: _data3,
537
+ _value: _data2,
532
538
  isInit: false,
533
539
  selectedRows: list,
534
540
  selectedRowKeys: nextSelectRowKeys
@@ -596,6 +602,9 @@ var ProModalSelect = function ProModalSelect(props, ref) {
596
602
  });
597
603
  nextState.selectedRows = value;
598
604
  }
605
+ } else if (value) {
606
+ console.log('value', value);
607
+ nextState.selectedRowKeys = [value];
599
608
  }
600
609
  setState(nextState);
601
610
  }
@@ -670,9 +679,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
670
679
  labelInValue: labelInValue,
671
680
  dataSource: options,
672
681
  scrollFollowParent: false,
673
- onClick: function onClick() {
674
- // 没有值的时候,初始化点击默认查询前五十条
675
- if (!value && isInit || !(options === null || options === void 0 ? void 0 : options.length)) {
682
+ onFocus: function onFocus() {
683
+ if (useRequest) {
676
684
  var _useRequest$options9;
677
685
  var queryBean = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options9 = useRequest.options) === null || _useRequest$options9 === void 0 ? void 0 : _useRequest$options9.defaultParams) || {};
678
686
  var params = withPagination ? {
@@ -755,6 +763,11 @@ var ProModalSelect = function ProModalSelect(props, ref) {
755
763
  };
756
764
  }
757
765
  }, [value, isTooltip]);
766
+ useDeepCompareEffect(function () {
767
+ setState({
768
+ options: tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource
769
+ });
770
+ }, [tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource]);
758
771
  // 当搜索条件只有一个时,且为输入框,默认设置suffix
759
772
  if ((formColumns === null || formColumns === void 0 ? void 0 : formColumns.length) === 1 && (formColumns === null || formColumns === void 0 ? void 0 : (_formColumns$ = formColumns[0]) === null || _formColumns$ === void 0 ? void 0 : _formColumns$.type) === 'Input') {
760
773
  var _formColumns$2, _formColumns$3, _formColumns$3$fieldP;
@@ -800,6 +813,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
800
813
  form: form,
801
814
  columns: formColumns,
802
815
  onFinish: handleSearch,
816
+ confirmLoading: loading,
803
817
  footer: (formColumns === null || formColumns === void 0 ? void 0 : formColumns.length) > 1
804
818
  }), _jsx(ProTable, _objectSpread({
805
819
  onRow: function onRow(record) {
@@ -53,6 +53,20 @@
53
53
  }
54
54
  }
55
55
 
56
+ // 新加适用于 readonly false
57
+ .@{ant-prefix}-input-affix-wrapper {
58
+ border-top-right-radius: 0;
59
+ border-bottom-right-radius: 0;
60
+ &.ant-input-affix-wrapper-status-error{
61
+ & + .@{ant-prefix}-btn{
62
+ border: 1px solid var(--ant-error-color);
63
+ >.viewSvg{
64
+ color: var(--ant-error-color);
65
+ }
66
+ }
67
+ }
68
+ }
69
+
56
70
  .pro-tree-modal-input-appoint {
57
71
  .@{ant-prefix}-input {
58
72
  border-top-left-radius: 0;
@@ -93,6 +107,15 @@
93
107
  fill: #c5c7cd;
94
108
  }
95
109
 
110
+ .@{ant-prefix}-select-status-error {
111
+ & + .@{ant-prefix}-btn{
112
+ border: 1px solid var(--ant-error-color);
113
+ >.viewSvg{
114
+ color: var(--ant-error-color);
115
+ }
116
+ }
117
+ }
118
+
96
119
  .@{ant-prefix}-input-group-addon {
97
120
  padding: 0px var(--zaui-space-size-sm, 8px);
98
121
  background-color: var(--zaui-base-bg, #ffffff);
@@ -12,8 +12,8 @@ export type Props = Omit<RangePickerProps, 'value' | 'onChange' | 'format' | 'se
12
12
  separator?: any;
13
13
  isView?: boolean;
14
14
  };
15
- type Value = [Moment?, Moment?, boolean?];
16
- type ValueStr = [string?, string?, string?];
15
+ type Value = [Moment?, Moment?, boolean?] | null;
16
+ type ValueStr = [string?, string?, string?] | null;
17
17
  type HandleChange = (value: ValueStr | null, valueStr: Value | null) => void;
18
18
  declare const ProRangeLimit: React.FC<Props>;
19
19
  export default ProRangeLimit;
@@ -27,12 +27,16 @@ var useControlled = function useControlled(props) {
27
27
  var _props$value, _props$value2;
28
28
  var internalValue = [((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value[0]) && moment(props.value[0], props.format), ((_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2[1]) && moment(props.value[1], props.format)];
29
29
  var handleChange = function handleChange(value, other) {
30
- var _value = _slicedToArray(value, 2),
31
- start = _value[0],
32
- end = _value[1];
33
- if (props === null || props === void 0 ? void 0 : props.onChange) {
34
- var valueStr = [start === null || start === void 0 ? void 0 : start.format(props.format), end === null || end === void 0 ? void 0 : end.format(props.format)];
35
- props === null || props === void 0 ? void 0 : props.onChange(valueStr, value);
30
+ if (!value) {
31
+ props === null || props === void 0 ? void 0 : props.onChange(value, other);
32
+ } else {
33
+ var _value = _slicedToArray(value, 2),
34
+ start = _value[0],
35
+ end = _value[1];
36
+ if (props === null || props === void 0 ? void 0 : props.onChange) {
37
+ var valueStr = [start === null || start === void 0 ? void 0 : start.format(props.format), end === null || end === void 0 ? void 0 : end.format(props.format)];
38
+ props === null || props === void 0 ? void 0 : props.onChange(valueStr, value);
39
+ }
36
40
  }
37
41
  };
38
42
  return [internalValue, handleChange];
@@ -96,6 +100,10 @@ var ProRangeLimit = function ProRangeLimit(props) {
96
100
  }
97
101
  // 时间范围change
98
102
  var handleRangeChange = function handleRangeChange(date, dateStr) {
103
+ if (!date) {
104
+ onChange(date, dateStr);
105
+ return;
106
+ }
99
107
  var _ref4 = date || [],
100
108
  _ref5 = _slicedToArray(_ref4, 2),
101
109
  start = _ref5[0],
@@ -108,20 +116,19 @@ var ProRangeLimit = function ProRangeLimit(props) {
108
116
  };
109
117
  // 长期选择框change
110
118
  var handleForeverChange = function handleForeverChange(e) {
111
- var _start, _end;
112
119
  var foreverStr = e.target.checked ? 'Y' : 'N';
113
120
  var _ref8 = value || [],
114
121
  _ref9 = _slicedToArray(_ref8, 2),
115
122
  start = _ref9[0],
116
123
  end = _ref9[1];
117
124
  if (e.target.checked) {
125
+ var _start, _end;
118
126
  start = start || moment().startOf('day');
119
127
  end = foreverMoment;
128
+ onChange([start, end, e.target.checked], [(_start = start) === null || _start === void 0 ? void 0 : _start.format(format), (_end = end) === null || _end === void 0 ? void 0 : _end.format(format), foreverStr]);
120
129
  } else {
121
- start = undefined;
122
- end = undefined;
130
+ onChange(null);
123
131
  }
124
- onChange([start, end, e.target.checked], [(_start = start) === null || _start === void 0 ? void 0 : _start.format(format), (_end = end) === null || _end === void 0 ? void 0 : _end.format(format), foreverStr]);
125
132
  };
126
133
  return _jsxs(_Input.Group, {
127
134
  compact: true,
@@ -11,8 +11,7 @@ export { default as SwitchCheckbox } from './base/SwitchCheckbox';
11
11
  export { default as TimePicker } from './base/TimePicker';
12
12
  export { default as FormList } from './combination/FormList';
13
13
  export { default as ProEditTable } from '../../ProEditTable';
14
- export { default as ProCascader } from './base/ProCascader';
15
- export { default as ProAddressBar } from './combination/ProAddressBar';
14
+ export { default as ProCascader } from './combination/ProCascader';
16
15
  export { default as ProCombination } from './combination/ProCombination';
17
16
  export { default as ProNumberRange } from './combination/ProNumberRange';
18
17
  export { default as ProModalSelect } from './combination/ProModalSelect';
@@ -12,22 +12,19 @@ export { default as SwitchCheckbox } from './base/SwitchCheckbox';
12
12
  export { default as TimePicker } from './base/TimePicker';
13
13
  export { default as FormList } from './combination/FormList';
14
14
  export { default as ProEditTable } from '../../ProEditTable';
15
- export { default as ProCascader } from './base/ProCascader';
16
15
  // combination 组合组件
17
- export { default as ProAddressBar } from './combination/ProAddressBar';
16
+ export { default as ProCascader } from './combination/ProCascader';
18
17
  export { default as ProCombination } from './combination/ProCombination';
19
18
  export { default as ProNumberRange } from './combination/ProNumberRange';
20
19
  export { default as ProModalSelect } from './combination/ProModalSelect';
21
20
  export { default as ProTimeLimit } from './combination/ProTimeLimit';
22
21
  export { default as ProRangeLimit } from './combination/ProRangeLimit';
23
22
  export { default as Group } from './combination/Group';
24
- // export { default as GroupCopy } from './combination/GroupCopy';
25
23
  export { default as ProCollapse } from './combination/Container';
26
24
  export { default as Container } from './combination/Container';
27
25
  export { default as ProEnum } from '../../ProEnum';
28
26
  export { default as ProSelect } from '../../ProSelect';
29
27
  export { default as ProUpload } from '../../ProUpload';
30
- // export { default as ProTreeSelect } from '../../ProTreeSelect';
31
28
  export { default as ProTreeModal } from '../../ProTreeModal';
32
29
  export { default as ProTree } from '../../ProTree';
33
30
  // footer组件