@kne/super-select 0.1.45 → 0.1.47
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/README.md +65 -2
- package/dist/index.css +59 -16
- package/dist/index.css.map +1 -1
- package/dist/index.js +667 -582
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +175 -147
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -11,14 +11,16 @@ var icons = require('@ant-design/icons');
|
|
|
11
11
|
var isEmpty = require('@kne/is-empty');
|
|
12
12
|
var responsiveUtils = require('@kne/responsive-utils');
|
|
13
13
|
var reactIntl = require('@kne/react-intl');
|
|
14
|
+
var overflowItems = require('@kne/overflow-items');
|
|
14
15
|
require('simplebar-react/dist/simplebar.min.css');
|
|
15
16
|
var get = require('lodash/get');
|
|
16
17
|
var SimpleBar = require('simplebar-react');
|
|
17
18
|
var SearchInput = require('@kne/search-input');
|
|
18
19
|
var scrollLoader = require('@kne/scroll-loader');
|
|
19
20
|
require('@kne/scroll-loader/dist/index.css');
|
|
20
|
-
var
|
|
21
|
-
require('@kne/table-
|
|
21
|
+
var merge = require('lodash/merge');
|
|
22
|
+
var TablePage = require('@kne/table-page');
|
|
23
|
+
require('@kne/table-page/dist/index.css');
|
|
22
24
|
var infoPage = require('@kne/info-page');
|
|
23
25
|
require('@kne/info-page/dist/index.css');
|
|
24
26
|
var memoize = require('lodash/memoize');
|
|
@@ -36,7 +38,8 @@ var last__default = /*#__PURE__*/_interopDefaultLegacy(last);
|
|
|
36
38
|
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
37
39
|
var SimpleBar__default = /*#__PURE__*/_interopDefaultLegacy(SimpleBar);
|
|
38
40
|
var SearchInput__default = /*#__PURE__*/_interopDefaultLegacy(SearchInput);
|
|
39
|
-
var
|
|
41
|
+
var merge__default = /*#__PURE__*/_interopDefaultLegacy(merge);
|
|
42
|
+
var TablePage__default = /*#__PURE__*/_interopDefaultLegacy(TablePage);
|
|
40
43
|
var memoize__default = /*#__PURE__*/_interopDefaultLegacy(memoize);
|
|
41
44
|
var isNil__default = /*#__PURE__*/_interopDefaultLegacy(isNil);
|
|
42
45
|
var Fetch__default = /*#__PURE__*/_interopDefaultLegacy(Fetch);
|
|
@@ -50,15 +53,6 @@ function _extends() {
|
|
|
50
53
|
return n;
|
|
51
54
|
}, _extends.apply(null, arguments);
|
|
52
55
|
}
|
|
53
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
54
|
-
if (null == r) return {};
|
|
55
|
-
var t = {};
|
|
56
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
57
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
58
|
-
t[n] = r[n];
|
|
59
|
-
}
|
|
60
|
-
return t;
|
|
61
|
-
}
|
|
62
56
|
|
|
63
57
|
const context = globalContext.createContext();
|
|
64
58
|
const {
|
|
@@ -66,7 +60,7 @@ const {
|
|
|
66
60
|
useContext
|
|
67
61
|
} = context;
|
|
68
62
|
|
|
69
|
-
var style$6 = {"kne-responsive-boundary":"kne-super-select_mJpBa","kne-responsive-scroll":"kne-super-select_90VCi","select-input":"kne-super-select_d8lGc","disabled":"kne-super-select_3kjwO","wrap":"kne-super-select_dsTM2","select-input-inner":"kne-super-select_NQoX9","large":"kne-super-select_T8ZX8","small":"kne-super-select_1B72H","is-mobile":"kne-super-select_VoUSp","single-label":"kne-super-select_pL0tE","tag-item":"kne-super-select_lc4o7","tag-label":"kne-super-select_RJmlD","overflow-tag":"kne-super-select_aHua2","measure-layer":"kne-super-select_QoQpC","select-input-icon":"kne-super-select_g8QC-","placeholder":"kne-super-select_r3q69","overlay-content":"kne-super-select_zEqGe","mobile-sheet-body":"kne-super-select_Gmh-5","overlay":"kne-super-select_ybN30","select-input-prefix":"kne-super-select_4Pw75","select-input-suffix":"kne-super-select_Wd4pE","mobile-sheet-mask":"kne-super-select_EOKDm","mobile-sheet-mask-fade-in":"kne-super-select_tWTg9","mobile-sheet-mask-leave":"kne-super-select_UAU38","mobile-sheet-mask-fade-out":"kne-super-select_e3tK2","mobile-sheet-popup":"kne-super-select_x0gT0","mobile-sheet-portal":"kne-super-select_kuA7x","mobile-sheet-header":"kne-super-select_EqRnq","mobile-sheet-title":"kne-super-select_5DU3x","mobile-sheet-action":"kne-super-select_UMAVM","mobile-sheet-confirm":"kne-super-select_Y48cj"};
|
|
63
|
+
var style$6 = {"kne-responsive-boundary":"kne-super-select_mJpBa","kne-responsive-scroll":"kne-super-select_90VCi","select-input":"kne-super-select_d8lGc","disabled":"kne-super-select_3kjwO","wrap":"kne-super-select_dsTM2","select-input-inner":"kne-super-select_NQoX9","large":"kne-super-select_T8ZX8","small":"kne-super-select_1B72H","is-mobile":"kne-super-select_VoUSp","single-label":"kne-super-select_pL0tE","tag-item":"kne-super-select_lc4o7","tag-label":"kne-super-select_RJmlD","overflow-tag":"kne-super-select_aHua2","tag-overflow":"kne-super-select_as9W0","tag-overflow-content":"kne-super-select_-JRYS","measure-layer":"kne-super-select_QoQpC","select-input-icon":"kne-super-select_g8QC-","placeholder":"kne-super-select_r3q69","overlay-content":"kne-super-select_zEqGe","mobile-sheet-body":"kne-super-select_Gmh-5","overlay":"kne-super-select_ybN30","select-input-prefix":"kne-super-select_4Pw75","select-input-suffix":"kne-super-select_Wd4pE","mobile-sheet-mask":"kne-super-select_EOKDm","mobile-sheet-mask-fade-in":"kne-super-select_tWTg9","mobile-sheet-mask-leave":"kne-super-select_UAU38","mobile-sheet-mask-fade-out":"kne-super-select_e3tK2","mobile-sheet-popup":"kne-super-select_x0gT0","mobile-sheet-portal":"kne-super-select_kuA7x","mobile-sheet-header":"kne-super-select_EqRnq","mobile-sheet-title":"kne-super-select_5DU3x","mobile-sheet-action":"kne-super-select_UMAVM","mobile-sheet-confirm":"kne-super-select_Y48cj"};
|
|
70
64
|
|
|
71
65
|
const locale$1 = {
|
|
72
66
|
placeholder: '请选择',
|
|
@@ -94,9 +88,10 @@ const locale = {
|
|
|
94
88
|
confirm: 'OK'
|
|
95
89
|
};
|
|
96
90
|
|
|
91
|
+
const TAG_GAP = 8;
|
|
92
|
+
|
|
97
93
|
/**
|
|
98
|
-
*
|
|
99
|
-
* 根据 innerWidth 计算标签显示数量
|
|
94
|
+
* 标签溢出:用 @kne/overflow-items 按容器宽度计算可见数量,预留 +N。
|
|
100
95
|
*/
|
|
101
96
|
const TagOverflowInner = ({
|
|
102
97
|
value,
|
|
@@ -104,73 +99,82 @@ const TagOverflowInner = ({
|
|
|
104
99
|
labelKey,
|
|
105
100
|
valueKey,
|
|
106
101
|
onRemove,
|
|
107
|
-
overflowTagWidth = 45,
|
|
108
102
|
iconSpace = 20
|
|
109
103
|
}) => {
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
104
|
+
const list = Array.isArray(value) ? value : [];
|
|
105
|
+
const availableWidth = Math.max((innerWidth || 0) - iconSpace, 0);
|
|
106
|
+
const maxTagWidth = innerWidth > 0 ? Math.min(150, Math.max(60, innerWidth - 60)) : 150;
|
|
107
|
+
const shareItems = React.useMemo(() => list.map(item => ({
|
|
108
|
+
key: item?.[valueKey],
|
|
109
|
+
label: item?.[labelKey]
|
|
110
|
+
})), [list, labelKey, valueKey]);
|
|
111
|
+
const {
|
|
112
|
+
setContainerRef,
|
|
113
|
+
setMeasureRef,
|
|
114
|
+
setMoreMeasureRef,
|
|
115
|
+
visibleCount,
|
|
116
|
+
ready,
|
|
117
|
+
hiddenCount,
|
|
118
|
+
shouldMeasure
|
|
119
|
+
} = overflowItems.useOverflowItems({
|
|
120
|
+
itemCount: list.length,
|
|
121
|
+
items: shareItems,
|
|
122
|
+
enabled: list.length > 0 && availableWidth > 0,
|
|
123
|
+
gap: TAG_GAP,
|
|
124
|
+
beforeReady: 'all',
|
|
125
|
+
debounce: 0,
|
|
126
|
+
itemSelector: '[data-tag-measure]'
|
|
127
|
+
});
|
|
128
|
+
const displayCount = ready ? visibleCount : list.length;
|
|
129
|
+
const displayTags = list.slice(0, displayCount);
|
|
130
|
+
const showOverflow = ready && hiddenCount > 0;
|
|
131
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
132
|
+
ref: setContainerRef,
|
|
133
|
+
className: style$6['tag-overflow'],
|
|
134
|
+
style: {
|
|
135
|
+
width: availableWidth || '100%',
|
|
136
|
+
maxWidth: '100%'
|
|
119
137
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const marginLeft = parseFloat(style.marginLeft) || 0;
|
|
127
|
-
const marginRight = parseFloat(style.marginRight) || 0;
|
|
128
|
-
return el.offsetWidth + marginLeft + marginRight;
|
|
129
|
-
});
|
|
130
|
-
const availableWidth = innerWidth - iconSpace;
|
|
131
|
-
let totalWidth = 0;
|
|
132
|
-
let count = 0;
|
|
133
|
-
for (let i = 0; i < tagWidths.length; i++) {
|
|
134
|
-
// 如果不是最后一个,需要预留 +N 标签空间
|
|
135
|
-
const needOverflowSpace = i < tagWidths.length - 1;
|
|
136
|
-
const requiredWidth = tagWidths[i] + (needOverflowSpace ? overflowTagWidth : 0);
|
|
137
|
-
if (totalWidth + requiredWidth <= availableWidth) {
|
|
138
|
-
totalWidth += tagWidths[i];
|
|
139
|
-
count++;
|
|
140
|
-
} else {
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
138
|
+
}, shouldMeasure ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
139
|
+
ref: setMeasureRef,
|
|
140
|
+
className: style$6['measure-layer'],
|
|
141
|
+
"aria-hidden": true,
|
|
142
|
+
style: {
|
|
143
|
+
gap: TAG_GAP
|
|
143
144
|
}
|
|
144
|
-
|
|
145
|
-
// 确保至少显示一个标签
|
|
146
|
-
setVisibleCount(Math.max(1, count));
|
|
147
|
-
}, [value, innerWidth, overflowTagWidth, iconSpace]);
|
|
148
|
-
|
|
149
|
-
// 计算单个标签最大宽度:min(150px, innerWidth - 60),初始状态默认 150px
|
|
150
|
-
const maxTagWidth = innerWidth > 0 ? Math.min(150, Math.max(60, innerWidth - 60)) : 150;
|
|
151
|
-
const displayTags = value.slice(0, visibleCount);
|
|
152
|
-
const hiddenCount = value.length - visibleCount;
|
|
153
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
154
|
-
ref: measureRef,
|
|
155
|
-
className: style$6['measure-layer']
|
|
156
|
-
}, value.map(item => /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
145
|
+
}, list.map(item => /*#__PURE__*/React__default["default"].createElement("div", {
|
|
157
146
|
key: item[valueKey],
|
|
158
|
-
"data-tag-measure": true
|
|
147
|
+
"data-tag-measure": true
|
|
148
|
+
}, /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
159
149
|
closable: true,
|
|
160
150
|
bordered: false,
|
|
161
151
|
className: style$6['tag-item'],
|
|
162
152
|
style: {
|
|
163
|
-
'--max-tag-width': `${maxTagWidth}px
|
|
153
|
+
'--max-tag-width': `${maxTagWidth}px`,
|
|
154
|
+
margin: 0
|
|
164
155
|
}
|
|
165
156
|
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
166
157
|
className: style$6['tag-label']
|
|
167
|
-
}, item[labelKey])))),
|
|
158
|
+
}, item[labelKey])))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
159
|
+
ref: setMoreMeasureRef
|
|
160
|
+
}, /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
161
|
+
className: style$6['overflow-tag'],
|
|
162
|
+
style: {
|
|
163
|
+
margin: 0
|
|
164
|
+
}
|
|
165
|
+
}, "+99"))) : null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
166
|
+
className: style$6['tag-overflow-content'],
|
|
167
|
+
style: {
|
|
168
|
+
gap: TAG_GAP
|
|
169
|
+
}
|
|
170
|
+
}, displayTags.map(item => /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
168
171
|
key: item[valueKey],
|
|
169
172
|
closable: true,
|
|
170
173
|
bordered: false,
|
|
171
174
|
className: style$6['tag-item'],
|
|
172
175
|
style: {
|
|
173
|
-
'--max-tag-width': `${maxTagWidth}px
|
|
176
|
+
'--max-tag-width': `${maxTagWidth}px`,
|
|
177
|
+
margin: 0
|
|
174
178
|
},
|
|
175
179
|
onClose: e => {
|
|
176
180
|
e.preventDefault();
|
|
@@ -179,12 +183,11 @@ const TagOverflowInner = ({
|
|
|
179
183
|
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
180
184
|
className: style$6['tag-label'],
|
|
181
185
|
title: item[labelKey]
|
|
182
|
-
}, item[labelKey]))),
|
|
186
|
+
}, item[labelKey]))), showOverflow ? /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
183
187
|
className: style$6['overflow-tag']
|
|
184
|
-
}, "+", hiddenCount));
|
|
188
|
+
}, "+", hiddenCount) : null));
|
|
185
189
|
};
|
|
186
190
|
|
|
187
|
-
const _excluded$3 = ["children"];
|
|
188
191
|
const MOBILE_SHEET_MAX_HEIGHT = '80%';
|
|
189
192
|
const MOBILE_SHEET_MIN_HEIGHT = '30%';
|
|
190
193
|
const MOBILE_MASK_Z_INDEX = 1000;
|
|
@@ -224,8 +227,10 @@ const lockParentScroll = getScrollElements => {
|
|
|
224
227
|
parentScrollLockCount = Math.max(0, parentScrollLockCount - 1);
|
|
225
228
|
if (parentScrollLockCount === 0) {
|
|
226
229
|
parentScrollLocked.forEach(_ref => {
|
|
227
|
-
let
|
|
228
|
-
|
|
230
|
+
let {
|
|
231
|
+
el,
|
|
232
|
+
prev
|
|
233
|
+
} = _ref;
|
|
229
234
|
el.style.overflow = prev.overflow;
|
|
230
235
|
el.style.overscrollBehavior = prev.overscrollBehavior;
|
|
231
236
|
});
|
|
@@ -242,7 +247,7 @@ const useLockParentScroll = (enabled, getScrollElements) => {
|
|
|
242
247
|
}, [enabled, getScrollElements]);
|
|
243
248
|
};
|
|
244
249
|
const numberToPx$1 = val => {
|
|
245
|
-
return typeof val === 'number' ? val
|
|
250
|
+
return typeof val === 'number' ? `${val}px` : val;
|
|
246
251
|
};
|
|
247
252
|
const pxToNumber = value => {
|
|
248
253
|
if (!value) return 0;
|
|
@@ -258,13 +263,15 @@ const DEFAULT_OVERLAY_MIN_WIDTH = 300;
|
|
|
258
263
|
|
|
259
264
|
// 与 Modal 模式一致:面板内用临时 value,确认后才写回
|
|
260
265
|
const ModalContent = _ref2 => {
|
|
261
|
-
let
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
let {
|
|
267
|
+
children: renderContent,
|
|
268
|
+
...others
|
|
269
|
+
} = _ref2;
|
|
270
|
+
const {
|
|
271
|
+
open,
|
|
272
|
+
value: propsValue
|
|
273
|
+
} = others;
|
|
274
|
+
const [value, setValue] = React.useState(propsValue);
|
|
268
275
|
React.useEffect(() => {
|
|
269
276
|
if (open && !isEqual__default["default"](value, propsValue)) {
|
|
270
277
|
setValue(propsValue);
|
|
@@ -280,8 +287,7 @@ const ModalContent = _ref2 => {
|
|
|
280
287
|
onSelect: item => others.onSelect(item, setValue),
|
|
281
288
|
onRemove: item => others.onRemove(item, setValue),
|
|
282
289
|
onOpenChange: nextOpen => {
|
|
283
|
-
|
|
284
|
-
if (nextOpen || ((_others$props = others.props) == null ? void 0 : _others$props.isPopup) === false) {
|
|
290
|
+
if (nextOpen || others.props?.isPopup === false) {
|
|
285
291
|
others.onOpenChange && others.onOpenChange(!!nextOpen);
|
|
286
292
|
}
|
|
287
293
|
}
|
|
@@ -291,16 +297,14 @@ const ModalContent = _ref2 => {
|
|
|
291
297
|
}, renderContent(contextProps));
|
|
292
298
|
};
|
|
293
299
|
const MobileSheetMask = _ref3 => {
|
|
294
|
-
let
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
maskClosing = _useState3[0],
|
|
303
|
-
setMaskClosing = _useState3[1];
|
|
300
|
+
let {
|
|
301
|
+
open,
|
|
302
|
+
mountNode,
|
|
303
|
+
fixedModeClass,
|
|
304
|
+
onClose
|
|
305
|
+
} = _ref3;
|
|
306
|
+
const [renderMask, setRenderMask] = React.useState(false);
|
|
307
|
+
const [maskClosing, setMaskClosing] = React.useState(false);
|
|
304
308
|
React.useEffect(() => {
|
|
305
309
|
if (open) {
|
|
306
310
|
setRenderMask(true);
|
|
@@ -332,11 +336,13 @@ const MobileSheetMask = _ref3 => {
|
|
|
332
336
|
}), mountNode);
|
|
333
337
|
};
|
|
334
338
|
const MobileSheetHeader = _ref4 => {
|
|
335
|
-
let
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
339
|
+
let {
|
|
340
|
+
title,
|
|
341
|
+
cancelText,
|
|
342
|
+
confirmText,
|
|
343
|
+
onCancel,
|
|
344
|
+
onConfirm
|
|
345
|
+
} = _ref4;
|
|
340
346
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
341
347
|
className: style$6['mobile-sheet-header']
|
|
342
348
|
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
@@ -353,16 +359,18 @@ const MobileSheetHeader = _ref4 => {
|
|
|
353
359
|
}, confirmText));
|
|
354
360
|
};
|
|
355
361
|
const MobileSheetPanel = _ref5 => {
|
|
356
|
-
let
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
362
|
+
let {
|
|
363
|
+
open,
|
|
364
|
+
mountNode,
|
|
365
|
+
fixedModeClass,
|
|
366
|
+
overlayClassName,
|
|
367
|
+
title,
|
|
368
|
+
cancelText,
|
|
369
|
+
confirmText,
|
|
370
|
+
onCancel,
|
|
371
|
+
onConfirm,
|
|
372
|
+
children
|
|
373
|
+
} = _ref5;
|
|
366
374
|
if (!open || !mountNode) {
|
|
367
375
|
return null;
|
|
368
376
|
}
|
|
@@ -402,7 +410,9 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
402
410
|
}
|
|
403
411
|
})(React.forwardRef((p, ref) => {
|
|
404
412
|
const intl = reactIntl.useIntl();
|
|
405
|
-
const
|
|
413
|
+
const {
|
|
414
|
+
formatMessage
|
|
415
|
+
} = intl;
|
|
406
416
|
const props = Object.assign({}, {
|
|
407
417
|
children: () => formatMessage({
|
|
408
418
|
id: 'defaultChildren'
|
|
@@ -438,18 +448,22 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
438
448
|
size: 'default',
|
|
439
449
|
disableMobileSheet: false,
|
|
440
450
|
renderModal: contextProps => {
|
|
441
|
-
const
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
451
|
+
const {
|
|
452
|
+
props,
|
|
453
|
+
open,
|
|
454
|
+
onComplete,
|
|
455
|
+
onOpenChange,
|
|
456
|
+
isMobile,
|
|
457
|
+
getPopupContainer,
|
|
458
|
+
formatMessage,
|
|
459
|
+
fixedModeClass
|
|
460
|
+
} = contextProps;
|
|
461
|
+
const {
|
|
462
|
+
placeholder,
|
|
463
|
+
children,
|
|
464
|
+
overlayClassName,
|
|
465
|
+
disableMobileSheet
|
|
466
|
+
} = props;
|
|
453
467
|
if (isMobile && !disableMobileSheet) {
|
|
454
468
|
const mountNode = typeof getPopupContainer === 'function' ? getPopupContainer() : null;
|
|
455
469
|
const closeWithoutCommit = () => onOpenChange(false);
|
|
@@ -498,32 +512,34 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
498
512
|
[props.valueKey]: props.selectedAllValue.value,
|
|
499
513
|
[props.labelKey]: props.selectedAllValue.label
|
|
500
514
|
};
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
515
|
+
const {
|
|
516
|
+
children,
|
|
517
|
+
prefix,
|
|
518
|
+
suffix,
|
|
519
|
+
className,
|
|
520
|
+
maxLength,
|
|
521
|
+
overlayClassName,
|
|
522
|
+
overlayStyle,
|
|
523
|
+
getPopupContainer: getPopupContainerProp,
|
|
524
|
+
zIndex,
|
|
525
|
+
align,
|
|
526
|
+
autoAdjustOverflow,
|
|
527
|
+
transitionName,
|
|
528
|
+
single,
|
|
529
|
+
labelWrap,
|
|
530
|
+
isPopup,
|
|
531
|
+
allowClear,
|
|
532
|
+
disabled,
|
|
533
|
+
placeholder,
|
|
534
|
+
selectedAllValue,
|
|
535
|
+
overlayWidth,
|
|
536
|
+
placement,
|
|
537
|
+
renderModal,
|
|
538
|
+
labelKey,
|
|
539
|
+
valueKey,
|
|
540
|
+
size,
|
|
541
|
+
disableMobileSheet
|
|
542
|
+
} = props;
|
|
527
543
|
const getPopupContainerDefault = responsiveUtils.usePopupContainer();
|
|
528
544
|
const getScrollElement = responsiveUtils.useScrollElement();
|
|
529
545
|
const wrapCustomGetPopupContainer = React.useMemo(() => {
|
|
@@ -535,14 +551,15 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
535
551
|
}
|
|
536
552
|
return undefined;
|
|
537
553
|
}, [getPopupContainerProp]);
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
554
|
+
const {
|
|
555
|
+
isMobile,
|
|
556
|
+
fixedModeClass,
|
|
557
|
+
getPopupContainer: getSheetPopupContainer,
|
|
558
|
+
anchorRef
|
|
559
|
+
} = responsiveUtils.useMobilePopupMount({
|
|
560
|
+
cover: 'viewport',
|
|
561
|
+
getPopupContainer: wrapCustomGetPopupContainer
|
|
562
|
+
});
|
|
546
563
|
const useMobileSheet = isMobile && !disableMobileSheet;
|
|
547
564
|
const useBoundaryMount = !!(isMobile && fixedModeClass === responsiveUtils.MOBILE_POPUP_MODE.boundary);
|
|
548
565
|
const transformValue = value => {
|
|
@@ -552,39 +569,25 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
552
569
|
return Array.isArray(value) ? value : [];
|
|
553
570
|
}
|
|
554
571
|
};
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
open = _useControlValue2[0],
|
|
575
|
-
setOpen = _useControlValue2[1];
|
|
576
|
-
const _useState5 = React.useState(false),
|
|
577
|
-
hover = _useState5[0],
|
|
578
|
-
setHover = _useState5[1];
|
|
579
|
-
const _useState6 = React.useState(0),
|
|
580
|
-
innerWidth = _useState6[0],
|
|
581
|
-
setInnerWidth = _useState6[1];
|
|
582
|
-
const _useState7 = React.useState(0),
|
|
583
|
-
containerWidth = _useState7[0],
|
|
584
|
-
setContainerWidth = _useState7[1];
|
|
585
|
-
const _useState8 = React.useState(null),
|
|
586
|
-
popupMountNode = _useState8[0],
|
|
587
|
-
setPopupMountNode = _useState8[1];
|
|
572
|
+
const [value, setValue] = useControlValue__default["default"](Object.assign({}, props, {
|
|
573
|
+
onChange: value => {
|
|
574
|
+
props.onChange && props.onChange(props.single ? last__default["default"](value) : value);
|
|
575
|
+
}
|
|
576
|
+
}, 'value' in props ? {
|
|
577
|
+
value: transformValue(props.value)
|
|
578
|
+
} : {
|
|
579
|
+
defaultValue: transformValue(props.defaultValue)
|
|
580
|
+
}));
|
|
581
|
+
const [searchProps, setSearchProps] = React.useState({});
|
|
582
|
+
const [open, setOpen] = useControlValue__default["default"](props, {
|
|
583
|
+
defaultValue: 'defaultOpen',
|
|
584
|
+
value: 'open',
|
|
585
|
+
onChange: 'onOpenChange'
|
|
586
|
+
});
|
|
587
|
+
const [hover, setHover] = React.useState(false);
|
|
588
|
+
const [innerWidth, setInnerWidth] = React.useState(0);
|
|
589
|
+
const [containerWidth, setContainerWidth] = React.useState(0);
|
|
590
|
+
const [popupMountNode, setPopupMountNode] = React.useState(null);
|
|
588
591
|
const containerWidthChange = el => {
|
|
589
592
|
if (!el) {
|
|
590
593
|
return;
|
|
@@ -650,8 +653,9 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
650
653
|
}, [getScrollElement, popupMountNode]);
|
|
651
654
|
const sheetOpen = !disabled && open;
|
|
652
655
|
useLockParentScroll(useMobileSheet && sheetOpen, getLockScrollTargets);
|
|
653
|
-
const
|
|
654
|
-
message
|
|
656
|
+
const {
|
|
657
|
+
message
|
|
658
|
+
} = antd.App.useApp();
|
|
655
659
|
const checkMaxLength = (value, maxLength) => {
|
|
656
660
|
if (Number.isInteger(maxLength) && maxLength > 0 && value.length >= maxLength) {
|
|
657
661
|
message.error(formatMessage({
|
|
@@ -816,7 +820,9 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
816
820
|
}
|
|
817
821
|
}
|
|
818
822
|
}), /*#__PURE__*/React__default["default"].createElement(ModalContent, contextProps, sheetContextProps => {
|
|
819
|
-
const
|
|
823
|
+
const {
|
|
824
|
+
onComplete
|
|
825
|
+
} = sheetContextProps;
|
|
820
826
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(MobileSheetMask, {
|
|
821
827
|
open: sheetOpen,
|
|
822
828
|
mountNode: popupMountNode,
|
|
@@ -879,22 +885,25 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
879
885
|
var style$5 = {"selected-all":"kne-super-select_prlgN"};
|
|
880
886
|
|
|
881
887
|
const SelectedAll = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
|
|
882
|
-
const
|
|
883
|
-
formatMessage
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
unit
|
|
896
|
-
|
|
897
|
-
|
|
888
|
+
const {
|
|
889
|
+
formatMessage
|
|
890
|
+
} = reactIntl.useIntl();
|
|
891
|
+
const {
|
|
892
|
+
props,
|
|
893
|
+
value,
|
|
894
|
+
setValue
|
|
895
|
+
} = useContext();
|
|
896
|
+
const {
|
|
897
|
+
unit,
|
|
898
|
+
selectedAllValue,
|
|
899
|
+
valueKey
|
|
900
|
+
} = Object.assign({}, {
|
|
901
|
+
unit: number => formatMessage({
|
|
902
|
+
id: 'numberOf'
|
|
903
|
+
}, {
|
|
904
|
+
number
|
|
905
|
+
})
|
|
906
|
+
}, props);
|
|
898
907
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
899
908
|
return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
900
909
|
justify: "space-between",
|
|
@@ -921,23 +930,26 @@ const computedIsSelectAll = function (value, selectedAllValue, valueKey) {
|
|
|
921
930
|
if (valueKey === void 0) {
|
|
922
931
|
valueKey = 'value';
|
|
923
932
|
}
|
|
924
|
-
return
|
|
933
|
+
return value?.length === 1 && get__default["default"](value, `[0][${valueKey}]`) === selectedAllValue[valueKey];
|
|
925
934
|
};
|
|
926
935
|
|
|
927
936
|
var style$4 = {"label":"kne-super-select_l3KoW","tag-list":"kne-super-select_CCPzb","tag-container":"kne-super-select_dKZHi","tag-container-inner":"kne-super-select_oijCI","tag":"kne-super-select_WmnnS","tag-inner":"kne-super-select_TMcFl"};
|
|
928
937
|
|
|
929
938
|
const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
|
|
930
|
-
const
|
|
931
|
-
formatMessage
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
939
|
+
const {
|
|
940
|
+
formatMessage
|
|
941
|
+
} = reactIntl.useIntl();
|
|
942
|
+
const {
|
|
943
|
+
props,
|
|
944
|
+
value,
|
|
945
|
+
onRemove
|
|
946
|
+
} = useContext();
|
|
947
|
+
const {
|
|
948
|
+
single,
|
|
949
|
+
maxLength,
|
|
950
|
+
labelKey,
|
|
951
|
+
valueKey
|
|
952
|
+
} = Object.assign({}, props);
|
|
941
953
|
return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
942
954
|
className: classnames__default["default"](style$4['tag-list'], 'selected-tag-list'),
|
|
943
955
|
gap: 8
|
|
@@ -945,7 +957,7 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
945
957
|
className: style$4['label']
|
|
946
958
|
}, formatMessage({
|
|
947
959
|
id: 'selected'
|
|
948
|
-
}), !single && value.length > 0 &&
|
|
960
|
+
}), !single && value.length > 0 && `(${value.length}${Number.isInteger(maxLength) ? `/${maxLength}` : ''})`, ":"), /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
|
|
949
961
|
className: style$4['tag-container']
|
|
950
962
|
}, /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
951
963
|
gap: 8,
|
|
@@ -969,16 +981,21 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
969
981
|
|
|
970
982
|
var style$3 = {"kne-responsive-boundary":"kne-super-select_Nc-y4","kne-responsive-scroll":"kne-super-select_RlrDm","list":"kne-super-select_IsXdU","empty":"kne-super-select_SQZ8k","default-list":"kne-super-select_QD1Mz","is-selected-all":"kne-super-select_M-mOy","default-list-item":"kne-super-select_KtOsz","is-selected":"kne-super-select_TQhBB","single-checked":"kne-super-select_2rUrh","is-disabled":"kne-super-select_NbwX5","selected-all":"kne-super-select_vN2Fx","selected-tag":"kne-super-select_6oITk","select-search":"kne-super-select_iAH9D","select-list-item-description":"kne-super-select_TCkeJ","footer":"kne-super-select_v3f23","is-mobile":"kne-super-select_w-WB8"};
|
|
971
983
|
|
|
972
|
-
const _excluded$2 = ["children"];
|
|
973
984
|
const SelectList = React.forwardRef((_ref, ref) => {
|
|
974
|
-
let
|
|
975
|
-
|
|
985
|
+
let {
|
|
986
|
+
children,
|
|
987
|
+
...p
|
|
988
|
+
} = _ref;
|
|
976
989
|
const fetchListRef = React.useRef(null);
|
|
977
990
|
const props = Object.assign({}, {
|
|
978
991
|
renderItemContent: _ref2 => {
|
|
979
|
-
let
|
|
980
|
-
|
|
981
|
-
|
|
992
|
+
let {
|
|
993
|
+
item,
|
|
994
|
+
props
|
|
995
|
+
} = _ref2;
|
|
996
|
+
const {
|
|
997
|
+
labelKey
|
|
998
|
+
} = props;
|
|
982
999
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
983
1000
|
className: 'select-list-item-label'
|
|
984
1001
|
}, item[labelKey]), item.description && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -986,17 +1003,21 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
986
1003
|
}, item.description));
|
|
987
1004
|
},
|
|
988
1005
|
renderItem: contextProps => {
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1006
|
+
const {
|
|
1007
|
+
item,
|
|
1008
|
+
props,
|
|
1009
|
+
isSelectedAll,
|
|
1010
|
+
value,
|
|
1011
|
+
onSelect,
|
|
1012
|
+
setValue,
|
|
1013
|
+
onOpenChange
|
|
1014
|
+
} = contextProps;
|
|
1015
|
+
const {
|
|
1016
|
+
single,
|
|
1017
|
+
isPopup,
|
|
1018
|
+
renderItemContent,
|
|
1019
|
+
valueKey
|
|
1020
|
+
} = props;
|
|
1000
1021
|
const isChecked = value.some(target => target[valueKey] === item[valueKey]);
|
|
1001
1022
|
return /*#__PURE__*/React__default["default"].createElement(antd.List.Item, {
|
|
1002
1023
|
className: classnames__default["default"](style$3['default-list-item'], 'select-list-item', {
|
|
@@ -1034,10 +1055,14 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1034
1055
|
}, isChecked && /*#__PURE__*/React__default["default"].createElement(icons.CheckOutlined, null)));
|
|
1035
1056
|
},
|
|
1036
1057
|
renderList: contextProps => {
|
|
1037
|
-
const
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1058
|
+
const {
|
|
1059
|
+
props,
|
|
1060
|
+
isSelectedAll,
|
|
1061
|
+
list
|
|
1062
|
+
} = contextProps;
|
|
1063
|
+
const {
|
|
1064
|
+
renderItem
|
|
1065
|
+
} = props;
|
|
1041
1066
|
if (!(list && list.length > 0)) {
|
|
1042
1067
|
return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, {
|
|
1043
1068
|
className: style$3['empty']
|
|
@@ -1058,26 +1083,30 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1058
1083
|
return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
|
|
1059
1084
|
ref: ref
|
|
1060
1085
|
}), targetProps => {
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1086
|
+
const {
|
|
1087
|
+
props,
|
|
1088
|
+
value,
|
|
1089
|
+
searchProps,
|
|
1090
|
+
setSearchProps,
|
|
1091
|
+
onOpenChange,
|
|
1092
|
+
isMobile,
|
|
1093
|
+
open
|
|
1094
|
+
} = targetProps;
|
|
1095
|
+
const {
|
|
1096
|
+
footer,
|
|
1097
|
+
isPopup,
|
|
1098
|
+
getSearchProps,
|
|
1099
|
+
getSearchCallback,
|
|
1100
|
+
searchPlaceholder,
|
|
1101
|
+
valueKey,
|
|
1102
|
+
single,
|
|
1103
|
+
allowSelectedAll,
|
|
1104
|
+
showSelectedTag,
|
|
1105
|
+
api,
|
|
1106
|
+
options,
|
|
1107
|
+
renderList,
|
|
1108
|
+
selectedAllValue
|
|
1109
|
+
} = props;
|
|
1081
1110
|
const components = {
|
|
1082
1111
|
search: (api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function') && /*#__PURE__*/React__default["default"].createElement(SearchInput__default["default"], {
|
|
1083
1112
|
className: classnames__default["default"](style$3['select-search'], 'select-list-search', {
|
|
@@ -1111,9 +1140,13 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1111
1140
|
searchProps
|
|
1112
1141
|
},
|
|
1113
1142
|
loader: _ref3 => {
|
|
1114
|
-
let
|
|
1115
|
-
|
|
1116
|
-
|
|
1143
|
+
let {
|
|
1144
|
+
data
|
|
1145
|
+
} = _ref3;
|
|
1146
|
+
const {
|
|
1147
|
+
options,
|
|
1148
|
+
searchProps
|
|
1149
|
+
} = data;
|
|
1117
1150
|
if (typeof getSearchCallback === 'function') {
|
|
1118
1151
|
const newOptions = options.filter(item => getSearchCallback(searchProps, item));
|
|
1119
1152
|
return {
|
|
@@ -1162,33 +1195,37 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1162
1195
|
});
|
|
1163
1196
|
});
|
|
1164
1197
|
|
|
1165
|
-
var style$2 = {"body":"kne-super-select_704J1","is-mobile":"kne-super-select_HYGUN","table-panel-wrap":"kne-super-select_Boo1a","selected-panel-wrap":"kne-super-select_q-BjK","table-panel":"kne-super-select_UAejp","filter-wrap":"kne-super-select_gmlBv","table":"kne-super-select_zE-14","list":"kne-super-select_DrEYJ","is-
|
|
1198
|
+
var style$2 = {"body":"kne-super-select_704J1","is-mobile":"kne-super-select_HYGUN","table-panel-wrap":"kne-super-select_Boo1a","selected-panel-wrap":"kne-super-select_q-BjK","table-panel":"kne-super-select_UAejp","filter-wrap":"kne-super-select_gmlBv","table":"kne-super-select_zE-14","list":"kne-super-select_DrEYJ","is-fit-columns":"kne-super-select_QqZxW","empty":"kne-super-select_5Tyrt","right-options-col":"kne-super-select_sNBrJ","right-options":"kne-super-select_UXi-g","no-padding-btn":"kne-super-select_iaCir","selected-tags-scroll":"kne-super-select_b-3Xk","tag":"kne-super-select_JkYqS","tag-inner":"kne-super-select_VZlBL","single-checked":"kne-super-select_Eiz-u","select-search":"kne-super-select_temy6","tags-search":"kne-super-select_7phL2","descriptions":"kne-super-select_ttNK9","footer":"kne-super-select_lISfA"};
|
|
1166
1199
|
|
|
1167
1200
|
const isEmptyParentKey = value => value == null || value === '';
|
|
1168
1201
|
const flattenSelectList = (list, _ref) => {
|
|
1169
|
-
let
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1202
|
+
let {
|
|
1203
|
+
dataType,
|
|
1204
|
+
rowKey,
|
|
1205
|
+
parentKey,
|
|
1206
|
+
childrenKey
|
|
1207
|
+
} = _ref;
|
|
1208
|
+
if (!list || !TablePage.isTreeDataType(dataType)) {
|
|
1174
1209
|
return list || [];
|
|
1175
1210
|
}
|
|
1176
|
-
const tree =
|
|
1211
|
+
const tree = TablePage.normalizeTreeData(list, {
|
|
1177
1212
|
dataType,
|
|
1178
1213
|
rowKey,
|
|
1179
1214
|
parentKey,
|
|
1180
1215
|
childrenKey
|
|
1181
1216
|
});
|
|
1182
|
-
return
|
|
1217
|
+
return TablePage.flattenAllTree(tree, {
|
|
1183
1218
|
rowKey,
|
|
1184
1219
|
childrenKey
|
|
1185
1220
|
}).map(row => row.item);
|
|
1186
1221
|
};
|
|
1187
1222
|
const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps, _ref2) => {
|
|
1188
|
-
let
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1223
|
+
let {
|
|
1224
|
+
dataType,
|
|
1225
|
+
valueKey,
|
|
1226
|
+
parentKey,
|
|
1227
|
+
childrenKey
|
|
1228
|
+
} = _ref2;
|
|
1192
1229
|
if (typeof getSearchCallback !== 'function') {
|
|
1193
1230
|
return options;
|
|
1194
1231
|
}
|
|
@@ -1230,13 +1267,25 @@ const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps,
|
|
|
1230
1267
|
}
|
|
1231
1268
|
return options.filter(item => getSearchCallback(searchProps, item, targetProps));
|
|
1232
1269
|
};
|
|
1270
|
+
const getListFromPageData = data => {
|
|
1271
|
+
if (Array.isArray(data?.pageData)) {
|
|
1272
|
+
return data.pageData;
|
|
1273
|
+
}
|
|
1274
|
+
if (Array.isArray(data?.list)) {
|
|
1275
|
+
return data.list;
|
|
1276
|
+
}
|
|
1277
|
+
return [];
|
|
1278
|
+
};
|
|
1279
|
+
const TABLE_LIST_MAX_HEIGHT_POPUP = 300;
|
|
1280
|
+
const TABLE_LIST_MAX_HEIGHT_EMBED = 400;
|
|
1281
|
+
const TABLE_HEADER_HEIGHT = 48;
|
|
1233
1282
|
const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(React.forwardRef((p, ref) => {
|
|
1234
|
-
const
|
|
1235
|
-
formatMessage
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
const
|
|
1283
|
+
const {
|
|
1284
|
+
formatMessage
|
|
1285
|
+
} = reactIntl.useIntl();
|
|
1286
|
+
const [tagSearchText, setTagSearchText] = React.useState('');
|
|
1287
|
+
const tablePageRef = React.useRef();
|
|
1288
|
+
const listScrollRef = React.useRef();
|
|
1240
1289
|
const props = Object.assign({}, {
|
|
1241
1290
|
overlayWidth: '600px',
|
|
1242
1291
|
dataType: 'list',
|
|
@@ -1244,15 +1293,19 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1244
1293
|
childrenKey: 'children',
|
|
1245
1294
|
hasChildrenKey: 'hasChildren',
|
|
1246
1295
|
filterRender: contextProps => {
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1296
|
+
const {
|
|
1297
|
+
props,
|
|
1298
|
+
searchProps,
|
|
1299
|
+
setSearchProps
|
|
1300
|
+
} = contextProps;
|
|
1301
|
+
const {
|
|
1302
|
+
isPopup,
|
|
1303
|
+
searchPlaceholder,
|
|
1304
|
+
api,
|
|
1305
|
+
getSearchProps,
|
|
1306
|
+
options,
|
|
1307
|
+
getSearchCallback
|
|
1308
|
+
} = props;
|
|
1256
1309
|
if (!(api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function')) {
|
|
1257
1310
|
return null;
|
|
1258
1311
|
}
|
|
@@ -1272,8 +1325,12 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1272
1325
|
});
|
|
1273
1326
|
},
|
|
1274
1327
|
getTagSearchCallback: (tagSearchText, item, contextProps) => {
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1328
|
+
const {
|
|
1329
|
+
props
|
|
1330
|
+
} = contextProps;
|
|
1331
|
+
const {
|
|
1332
|
+
labelKey
|
|
1333
|
+
} = props;
|
|
1277
1334
|
if (!tagSearchText) {
|
|
1278
1335
|
return true;
|
|
1279
1336
|
}
|
|
@@ -1284,94 +1341,88 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1284
1341
|
return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
|
|
1285
1342
|
ref: ref
|
|
1286
1343
|
}), targetProps => {
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1344
|
+
const {
|
|
1345
|
+
props,
|
|
1346
|
+
value,
|
|
1347
|
+
setValue,
|
|
1348
|
+
onRemove,
|
|
1349
|
+
onOpenChange,
|
|
1350
|
+
searchProps,
|
|
1351
|
+
isMobile,
|
|
1352
|
+
open
|
|
1353
|
+
} = targetProps;
|
|
1354
|
+
const {
|
|
1355
|
+
footer,
|
|
1356
|
+
filterRender,
|
|
1357
|
+
columns,
|
|
1358
|
+
options,
|
|
1359
|
+
getSearchProps,
|
|
1360
|
+
getSearchCallback,
|
|
1361
|
+
getTagSearchCallback,
|
|
1362
|
+
api,
|
|
1363
|
+
selectedAllValue,
|
|
1364
|
+
isPopup,
|
|
1365
|
+
single,
|
|
1366
|
+
maxLength,
|
|
1367
|
+
searchPlaceholder,
|
|
1368
|
+
allowSelectedAll,
|
|
1369
|
+
labelKey,
|
|
1370
|
+
valueKey,
|
|
1371
|
+
renderMobile,
|
|
1372
|
+
dataType,
|
|
1373
|
+
parentKey,
|
|
1374
|
+
childrenKey,
|
|
1375
|
+
hasChildrenKey,
|
|
1376
|
+
treeTitleKey,
|
|
1377
|
+
onLoadChildren,
|
|
1378
|
+
expandedKeys,
|
|
1379
|
+
defaultExpandedKeys,
|
|
1380
|
+
onExpandedKeysChange,
|
|
1381
|
+
indentSize,
|
|
1382
|
+
checkRelation,
|
|
1383
|
+
pagination: paginationProp,
|
|
1384
|
+
dataFormat
|
|
1385
|
+
} = props;
|
|
1323
1386
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
1324
1387
|
const resolvedTreeTitleKey = treeTitleKey || labelKey;
|
|
1325
1388
|
const footerEl = footer && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1326
1389
|
className: classnames__default["default"](style$2['footer'], 'select-table-footer')
|
|
1327
1390
|
}, typeof footer === 'function' ? footer({
|
|
1328
1391
|
reload: () => {
|
|
1329
|
-
|
|
1330
|
-
((_fetchListRef$current = fetchListRef.current) == null ? void 0 : _fetchListRef$current.fetchApi) && ((_fetchListRef$current2 = fetchListRef.current) == null ? void 0 : _fetchListRef$current2.fetchApi.reload());
|
|
1392
|
+
tablePageRef.current?.reload();
|
|
1331
1393
|
},
|
|
1332
1394
|
close: () => {
|
|
1333
1395
|
onOpenChange(false);
|
|
1334
1396
|
}
|
|
1335
1397
|
}) : footer);
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
dataType,
|
|
1355
|
-
valueKey,
|
|
1356
|
-
parentKey,
|
|
1357
|
-
childrenKey
|
|
1358
|
-
})
|
|
1359
|
-
};
|
|
1360
|
-
}
|
|
1361
|
-
} : api)
|
|
1362
|
-
}), fetchProps => {
|
|
1363
|
-
fetchListRef.current = fetchProps;
|
|
1364
|
-
const list = fetchProps.list;
|
|
1365
|
-
const contextProps = Object.assign({}, fetchProps, targetProps, {
|
|
1366
|
-
isSelectedAll
|
|
1367
|
-
});
|
|
1368
|
-
if (!(list && list.length > 0)) {
|
|
1369
|
-
return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, {
|
|
1370
|
-
className: classnames__default["default"](style$2['empty'])
|
|
1398
|
+
const tablePageFetchConfig = options ? {
|
|
1399
|
+
data: {
|
|
1400
|
+
options,
|
|
1401
|
+
searchProps
|
|
1402
|
+
},
|
|
1403
|
+
loader: _ref3 => {
|
|
1404
|
+
let {
|
|
1405
|
+
data
|
|
1406
|
+
} = _ref3;
|
|
1407
|
+
const {
|
|
1408
|
+
options: nextOptions,
|
|
1409
|
+
searchProps: nextSearchProps
|
|
1410
|
+
} = data;
|
|
1411
|
+
const pageData = filterTreeOptions(nextOptions, nextSearchProps, getSearchCallback, targetProps, {
|
|
1412
|
+
dataType,
|
|
1413
|
+
valueKey,
|
|
1414
|
+
parentKey,
|
|
1415
|
+
childrenKey
|
|
1371
1416
|
});
|
|
1417
|
+
return {
|
|
1418
|
+
pageData,
|
|
1419
|
+
totalCount: pageData.length
|
|
1420
|
+
};
|
|
1372
1421
|
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1422
|
+
} : merge__default["default"]({}, api, typeof getSearchProps === 'function' && isEmpty.isNotEmpty(searchProps) ? {
|
|
1423
|
+
data: getSearchProps(searchProps) || {}
|
|
1424
|
+
} : {});
|
|
1425
|
+
const allColumnsHaveWidth = Array.isArray(columns) && columns.length > 0 && columns.every(TablePage.hasColumnWidth);
|
|
1375
1426
|
const tableSelection = {
|
|
1376
1427
|
allowSelectedAll,
|
|
1377
1428
|
isSelectedAll,
|
|
@@ -1383,9 +1434,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1383
1434
|
checkRelation,
|
|
1384
1435
|
onChange: selectedRowKeys => {
|
|
1385
1436
|
setValue(prev => {
|
|
1386
|
-
var _fetchListRef$current3;
|
|
1387
1437
|
const prevMap = new Map((prev || []).map(item => [item[valueKey], item]));
|
|
1388
|
-
const listMap = new Map(flattenSelectList((
|
|
1438
|
+
const listMap = new Map(flattenSelectList(getListFromPageData(tablePageRef.current?.data), {
|
|
1389
1439
|
dataType,
|
|
1390
1440
|
rowKey: valueKey,
|
|
1391
1441
|
parentKey,
|
|
@@ -1417,7 +1467,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1417
1467
|
align: 'middle'
|
|
1418
1468
|
}, /*#__PURE__*/React__default["default"].createElement(antd.Col, null, formatMessage({
|
|
1419
1469
|
id: 'selected'
|
|
1420
|
-
}), value.length > 0 &&
|
|
1470
|
+
}), value.length > 0 && `(${value.length}${Number.isInteger(maxLength) ? `/${maxLength}` : ''})`, ":"), /*#__PURE__*/React__default["default"].createElement(antd.Col, null, /*#__PURE__*/React__default["default"].createElement(antd.Button, {
|
|
1421
1471
|
className: style$2['no-padding-btn'],
|
|
1422
1472
|
type: "link",
|
|
1423
1473
|
onClick: () => {
|
|
@@ -1430,7 +1480,6 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1430
1480
|
wrap: true,
|
|
1431
1481
|
gap: 8
|
|
1432
1482
|
}, value.filter(item => getTagSearchCallback(tagSearchText, item, targetProps)).map(item => {
|
|
1433
|
-
var _fetchListRef$current4, _fetchListRef$current5;
|
|
1434
1483
|
return /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
1435
1484
|
className: style$2['tag'],
|
|
1436
1485
|
key: item[valueKey],
|
|
@@ -1454,8 +1503,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1454
1503
|
})),
|
|
1455
1504
|
dataSource: Object.assign({}, item),
|
|
1456
1505
|
context: Object.assign({}, targetProps, {
|
|
1457
|
-
fetchApi:
|
|
1458
|
-
list: (
|
|
1506
|
+
fetchApi: tablePageRef.current,
|
|
1507
|
+
list: getListFromPageData(tablePageRef.current?.data)
|
|
1459
1508
|
})
|
|
1460
1509
|
})
|
|
1461
1510
|
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -1480,50 +1529,67 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1480
1529
|
className: style$2['filter-wrap']
|
|
1481
1530
|
}, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1482
1531
|
className: classnames__default["default"](style$2['table'], 'select-table')
|
|
1483
|
-
},
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1532
|
+
}, open ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1533
|
+
ref: listScrollRef,
|
|
1534
|
+
className: classnames__default["default"](style$2['list'], 'select-table-list-scroll-list', {
|
|
1535
|
+
'is-popup': isPopup,
|
|
1536
|
+
[style$2['is-fit-columns']]: !allColumnsHaveWidth
|
|
1537
|
+
})
|
|
1538
|
+
}, /*#__PURE__*/React__default["default"].createElement(TablePage__default["default"], _extends({}, tablePageFetchConfig, {
|
|
1539
|
+
ref: tablePageRef
|
|
1540
|
+
}, dataFormat ? {
|
|
1541
|
+
dataFormat
|
|
1542
|
+
} : null, {
|
|
1543
|
+
pagination: Object.assign({
|
|
1544
|
+
open: false,
|
|
1545
|
+
showSizeChanger: false,
|
|
1546
|
+
showQuickJumper: false,
|
|
1547
|
+
hideOnSinglePage: true
|
|
1548
|
+
}, paginationProp),
|
|
1549
|
+
scroll: isMobile ? undefined : Object.assign({
|
|
1550
|
+
y: (isPopup ? TABLE_LIST_MAX_HEIGHT_POPUP : TABLE_LIST_MAX_HEIGHT_EMBED) - TABLE_HEADER_HEIGHT
|
|
1551
|
+
}, allColumnsHaveWidth ? null : {
|
|
1552
|
+
x: undefined
|
|
1553
|
+
}),
|
|
1554
|
+
controllerOpen: false,
|
|
1555
|
+
columns: columns,
|
|
1556
|
+
rowKey: valueKey,
|
|
1557
|
+
rowSelection: tableSelection,
|
|
1558
|
+
columnRenderProps: Object.assign({}, targetProps, {
|
|
1559
|
+
isSelectedAll
|
|
1560
|
+
}),
|
|
1561
|
+
empty: props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, {
|
|
1562
|
+
className: classnames__default["default"](style$2['empty'])
|
|
1563
|
+
}),
|
|
1564
|
+
dataType: dataType,
|
|
1565
|
+
parentKey: parentKey,
|
|
1566
|
+
childrenKey: childrenKey,
|
|
1567
|
+
hasChildrenKey: hasChildrenKey,
|
|
1568
|
+
treeTitleKey: resolvedTreeTitleKey,
|
|
1569
|
+
renderMobile: renderMobile === false ? false : typeof renderMobile === 'function' ? mobileProps => renderMobile({
|
|
1570
|
+
...mobileProps,
|
|
1571
|
+
...targetProps,
|
|
1572
|
+
isSelectedAll,
|
|
1573
|
+
list: mobileProps.displayDataSource || mobileProps.dataSource,
|
|
1574
|
+
dataSource: mobileProps.dataSource,
|
|
1575
|
+
renderBody: function (nextList, nextContext) {
|
|
1576
|
+
if (nextList === void 0) {
|
|
1577
|
+
nextList = mobileProps.displayDataSource || mobileProps.dataSource;
|
|
1506
1578
|
}
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
}
|
|
1522
|
-
if (Object.prototype.hasOwnProperty.call(p, 'defaultExpandedKeys')) {
|
|
1523
|
-
tableViewProps.defaultExpandedKeys = defaultExpandedKeys;
|
|
1524
|
-
}
|
|
1525
|
-
return /*#__PURE__*/React__default["default"].createElement(TableView__default["default"], tableViewProps);
|
|
1526
|
-
})), single && footerEl || !isMobile && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1579
|
+
return mobileProps.renderBody(nextList, nextContext);
|
|
1580
|
+
}
|
|
1581
|
+
}) : true
|
|
1582
|
+
}, typeof onLoadChildren === 'function' ? {
|
|
1583
|
+
onLoadChildren
|
|
1584
|
+
} : null, typeof onExpandedKeysChange === 'function' ? {
|
|
1585
|
+
onExpandedKeysChange
|
|
1586
|
+
} : null, indentSize != null ? {
|
|
1587
|
+
indentSize
|
|
1588
|
+
} : null, Object.prototype.hasOwnProperty.call(p, 'expandedKeys') ? {
|
|
1589
|
+
expandedKeys
|
|
1590
|
+
} : null, Object.prototype.hasOwnProperty.call(p, 'defaultExpandedKeys') ? {
|
|
1591
|
+
defaultExpandedKeys
|
|
1592
|
+
} : null))) : null), single && footerEl || !isMobile && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1527
1593
|
className: classnames__default["default"](style$2['footer'], 'select-table-footer')
|
|
1528
1594
|
}));
|
|
1529
1595
|
|
|
@@ -1556,15 +1622,15 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1556
1622
|
|
|
1557
1623
|
var style$1 = {"kne-responsive-boundary":"kne-super-select_YFHhC","kne-responsive-scroll":"kne-super-select_yjaz7","list":"kne-super-select_YTqxA","default-list":"kne-super-select_IZN7r","is-selected-all":"kne-super-select_GCIMn","default-list-item":"kne-super-select_AYi0i","is-selected":"kne-super-select_eovZv","single-checked":"kne-super-select_Tr-bO","is-disabled":"kne-super-select_T-hri","selected-all":"kne-super-select_4XFtm","selected-tag":"kne-super-select_Whlzr","select-search":"kne-super-select_7zuBL","select-tree-item-description":"kne-super-select_R-Sye","footer":"kne-super-select_PjlnR","is-mobile":"kne-super-select_yTb5p"};
|
|
1558
1624
|
|
|
1559
|
-
const _excluded$1 = ["children"],
|
|
1560
|
-
_excluded2 = ["data"];
|
|
1561
1625
|
const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
1562
1626
|
if (data === void 0) {
|
|
1563
1627
|
data = [];
|
|
1564
1628
|
}
|
|
1565
|
-
let
|
|
1566
|
-
|
|
1567
|
-
|
|
1629
|
+
let {
|
|
1630
|
+
parentKey,
|
|
1631
|
+
valueKey,
|
|
1632
|
+
childrenKey
|
|
1633
|
+
} = _ref;
|
|
1568
1634
|
const parseTree = output => {
|
|
1569
1635
|
return output.map(node => {
|
|
1570
1636
|
const children = data.filter(item => {
|
|
@@ -1581,35 +1647,43 @@ const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
|
1581
1647
|
};
|
|
1582
1648
|
});
|
|
1583
1649
|
const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
1584
|
-
let
|
|
1585
|
-
|
|
1650
|
+
let {
|
|
1651
|
+
children,
|
|
1652
|
+
...p
|
|
1653
|
+
} = _ref2;
|
|
1586
1654
|
const fetchListRef = React.useRef(null);
|
|
1587
|
-
const
|
|
1588
|
-
expandedKeys = _useState[0],
|
|
1589
|
-
setExpandedKeys = _useState[1];
|
|
1655
|
+
const [expandedKeys, setExpandedKeys] = React.useState([]);
|
|
1590
1656
|
const props = Object.assign({}, {
|
|
1591
1657
|
parentKey: 'parentId',
|
|
1592
1658
|
childrenKey: 'children',
|
|
1593
1659
|
renderItemContent: _ref3 => {
|
|
1594
|
-
let
|
|
1595
|
-
|
|
1596
|
-
|
|
1660
|
+
let {
|
|
1661
|
+
item,
|
|
1662
|
+
props
|
|
1663
|
+
} = _ref3;
|
|
1664
|
+
const {
|
|
1665
|
+
labelKey
|
|
1666
|
+
} = props;
|
|
1597
1667
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1598
1668
|
className: 'select-tree-item-label'
|
|
1599
1669
|
}, item[labelKey]));
|
|
1600
1670
|
},
|
|
1601
1671
|
renderItem: contextProps => {
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1672
|
+
const {
|
|
1673
|
+
item,
|
|
1674
|
+
props,
|
|
1675
|
+
isSelectedAll,
|
|
1676
|
+
value,
|
|
1677
|
+
onSelect,
|
|
1678
|
+
setValue,
|
|
1679
|
+
onOpenChange
|
|
1680
|
+
} = contextProps;
|
|
1681
|
+
const {
|
|
1682
|
+
single,
|
|
1683
|
+
isPopup,
|
|
1684
|
+
renderItemContent,
|
|
1685
|
+
valueKey
|
|
1686
|
+
} = props;
|
|
1613
1687
|
const isChecked = value.some(target => target[valueKey] === item[valueKey]);
|
|
1614
1688
|
return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
1615
1689
|
className: classnames__default["default"](style$1['default-list-item'], 'select-tree-item', {
|
|
@@ -1647,20 +1721,26 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1647
1721
|
}, isChecked && /*#__PURE__*/React__default["default"].createElement(icons.CheckOutlined, null)));
|
|
1648
1722
|
},
|
|
1649
1723
|
renderTree: contextProps => {
|
|
1650
|
-
const
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
treeData
|
|
1724
|
+
const {
|
|
1725
|
+
props,
|
|
1726
|
+
isSelectedAll,
|
|
1727
|
+
data
|
|
1728
|
+
} = contextProps;
|
|
1729
|
+
const {
|
|
1730
|
+
renderItem,
|
|
1731
|
+
valueKey,
|
|
1732
|
+
labelKey,
|
|
1733
|
+
childrenKey,
|
|
1734
|
+
parentKey
|
|
1735
|
+
} = props;
|
|
1736
|
+
const {
|
|
1737
|
+
treeData,
|
|
1738
|
+
ids
|
|
1739
|
+
} = parseTreeData(data, {
|
|
1740
|
+
valueKey,
|
|
1741
|
+
parentKey,
|
|
1742
|
+
childrenKey
|
|
1743
|
+
});
|
|
1664
1744
|
if (!(treeData && treeData.length > 0)) {
|
|
1665
1745
|
return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, null);
|
|
1666
1746
|
}
|
|
@@ -1691,21 +1771,25 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1691
1771
|
return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
|
|
1692
1772
|
ref: ref
|
|
1693
1773
|
}), targetProps => {
|
|
1694
|
-
const
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1774
|
+
const {
|
|
1775
|
+
props,
|
|
1776
|
+
value,
|
|
1777
|
+
onOpenChange,
|
|
1778
|
+
isMobile,
|
|
1779
|
+
open
|
|
1780
|
+
} = targetProps;
|
|
1781
|
+
const {
|
|
1782
|
+
footer,
|
|
1783
|
+
isPopup,
|
|
1784
|
+
valueKey,
|
|
1785
|
+
single,
|
|
1786
|
+
allowSelectedAll,
|
|
1787
|
+
showSelectedTag,
|
|
1788
|
+
api,
|
|
1789
|
+
options,
|
|
1790
|
+
renderTree,
|
|
1791
|
+
selectedAllValue
|
|
1792
|
+
} = props;
|
|
1709
1793
|
const components = {
|
|
1710
1794
|
selectedAll: !single && allowSelectedAll && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1711
1795
|
className: classnames__default["default"](style$1['selected-all'], 'select-tree-selected-all', {
|
|
@@ -1717,14 +1801,18 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1717
1801
|
options
|
|
1718
1802
|
},
|
|
1719
1803
|
loader: _ref4 => {
|
|
1720
|
-
let
|
|
1804
|
+
let {
|
|
1805
|
+
data
|
|
1806
|
+
} = _ref4;
|
|
1721
1807
|
return data.options;
|
|
1722
1808
|
}
|
|
1723
1809
|
} : api), {
|
|
1724
1810
|
ref: fetchListRef,
|
|
1725
1811
|
render: _ref5 => {
|
|
1726
|
-
let
|
|
1727
|
-
|
|
1812
|
+
let {
|
|
1813
|
+
data,
|
|
1814
|
+
...fetchProps
|
|
1815
|
+
} = _ref5;
|
|
1728
1816
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
1729
1817
|
const treeContent = renderTree(Object.assign({}, fetchProps, targetProps, {
|
|
1730
1818
|
isSelectedAll,
|
|
@@ -2010,39 +2098,37 @@ const CustomMenu = ({
|
|
|
2010
2098
|
});
|
|
2011
2099
|
};
|
|
2012
2100
|
|
|
2013
|
-
const _excluded = ["options", "value", "onChange", "defaultValue", "maxLength", "single", "onlyAllowLastLevel", "openLoadData", "onLoadMore", "parentIdKey", "menuItemWidth", "isPopup", "searchPlaceholder", "onSearch", "valueKey", "labelKey", "placeholder", "disabled", "size", "overlayWidth"];
|
|
2014
2101
|
const numberToPx = val => {
|
|
2015
|
-
return typeof val === 'number' ? val
|
|
2102
|
+
return typeof val === 'number' ? `${val}px` : val;
|
|
2016
2103
|
};
|
|
2017
2104
|
|
|
2018
2105
|
// 级联选择内容组件
|
|
2019
2106
|
const CascaderInner = _ref => {
|
|
2020
|
-
let
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
const
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
const
|
|
2044
|
-
|
|
2045
|
-
setLoading = _useState2[1];
|
|
2107
|
+
let {
|
|
2108
|
+
options,
|
|
2109
|
+
value,
|
|
2110
|
+
setValue,
|
|
2111
|
+
maxLength,
|
|
2112
|
+
single,
|
|
2113
|
+
onlyAllowLastLevel,
|
|
2114
|
+
openLoadData,
|
|
2115
|
+
onLoadMore,
|
|
2116
|
+
parentIdKey,
|
|
2117
|
+
menuItemWidth,
|
|
2118
|
+
isPopup,
|
|
2119
|
+
searchPlaceholder,
|
|
2120
|
+
onSearch,
|
|
2121
|
+
valueKey,
|
|
2122
|
+
labelKey,
|
|
2123
|
+
onOpenChange,
|
|
2124
|
+
open,
|
|
2125
|
+
isMobile
|
|
2126
|
+
} = _ref;
|
|
2127
|
+
const {
|
|
2128
|
+
message
|
|
2129
|
+
} = antd.App.useApp();
|
|
2130
|
+
const [searchText, setSearchText] = React.useState('');
|
|
2131
|
+
const [loading, setLoading] = React.useState(false);
|
|
2046
2132
|
// 移动端弹窗内不用 SimpleBar,改原生滚动
|
|
2047
2133
|
const ScrollBox = isMobile ? 'div' : SimpleBar__default["default"];
|
|
2048
2134
|
|
|
@@ -2054,13 +2140,15 @@ const CascaderInner = _ref => {
|
|
|
2054
2140
|
parentId = null;
|
|
2055
2141
|
}
|
|
2056
2142
|
items.forEach(item => {
|
|
2057
|
-
const node =
|
|
2143
|
+
const node = {
|
|
2144
|
+
...item,
|
|
2058
2145
|
id: item[valueKey],
|
|
2059
2146
|
label: item[labelKey],
|
|
2060
2147
|
parentId
|
|
2061
|
-
}
|
|
2148
|
+
};
|
|
2062
2149
|
if (item.children && item.children.length > 0) {
|
|
2063
|
-
node.children = item.children.map(child =>
|
|
2150
|
+
node.children = item.children.map(child => ({
|
|
2151
|
+
...child,
|
|
2064
2152
|
id: child[valueKey],
|
|
2065
2153
|
label: child[labelKey],
|
|
2066
2154
|
parentId: node.id
|
|
@@ -2080,25 +2168,23 @@ const CascaderInner = _ref => {
|
|
|
2080
2168
|
}, [mapping]);
|
|
2081
2169
|
|
|
2082
2170
|
// 当前选中的列
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2171
|
+
const [selectedIds, setSelectedIds] = React.useState(() => {
|
|
2172
|
+
const initValue = value.find(item => {
|
|
2173
|
+
const id = typeof item === 'object' ? item[valueKey] : item;
|
|
2174
|
+
return !!mapping.get(id);
|
|
2175
|
+
});
|
|
2176
|
+
if (initValue) {
|
|
2177
|
+
const id = typeof initValue === 'object' ? initValue[valueKey] : initValue;
|
|
2178
|
+
return treeUtils.getSelectedQueue(id);
|
|
2179
|
+
}
|
|
2092
2180
|
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
selectedIds = _useState3[0],
|
|
2101
|
-
setSelectedIds = _useState3[1];
|
|
2181
|
+
// 默认选中第一列
|
|
2182
|
+
const firstNode = Array.from(mapping.values()).find(item => isNil__default["default"](item.parentId));
|
|
2183
|
+
if (firstNode) {
|
|
2184
|
+
return treeUtils.getSelectedQueue(firstNode.id);
|
|
2185
|
+
}
|
|
2186
|
+
return [];
|
|
2187
|
+
});
|
|
2102
2188
|
|
|
2103
2189
|
// 当 Modal 打开时,根据 value 重新初始化 selectedIds
|
|
2104
2190
|
const prevOpenRef = React.useRef(open);
|
|
@@ -2180,7 +2266,7 @@ const CascaderInner = _ref => {
|
|
|
2180
2266
|
return checked ? treeUtils.setNodeChecked(id, currentIds) : treeUtils.setNodeUnchecked(id, currentIds);
|
|
2181
2267
|
})();
|
|
2182
2268
|
if (newValue.length > maxLength) {
|
|
2183
|
-
message.error(
|
|
2269
|
+
message.error(`最多只能选择 ${maxLength} 项`);
|
|
2184
2270
|
return;
|
|
2185
2271
|
}
|
|
2186
2272
|
|
|
@@ -2188,10 +2274,11 @@ const CascaderInner = _ref => {
|
|
|
2188
2274
|
const newValues = newValue.map(id => {
|
|
2189
2275
|
const node = mapping.get(id);
|
|
2190
2276
|
// 返回完整的节点数据,保留所有原始字段
|
|
2191
|
-
return node ?
|
|
2277
|
+
return node ? {
|
|
2278
|
+
...node,
|
|
2192
2279
|
[valueKey]: node.id,
|
|
2193
2280
|
[labelKey]: node.label
|
|
2194
|
-
}
|
|
2281
|
+
} : null;
|
|
2195
2282
|
}).filter(Boolean);
|
|
2196
2283
|
const finalValue = single && newValues.length > 0 ? [last__default["default"](newValues)] : newValues;
|
|
2197
2284
|
setValue(finalValue);
|
|
@@ -2298,7 +2385,7 @@ const CascaderInner = _ref => {
|
|
|
2298
2385
|
}, selectedIds.map((selectedId, index) => {
|
|
2299
2386
|
const selectNode = mapping.get(selectedId);
|
|
2300
2387
|
const siblingNodes = treeUtils.getSiblingNode(selectedId);
|
|
2301
|
-
const isLastLevel = !isNotLastNode(selectNode
|
|
2388
|
+
const isLastLevel = !isNotLastNode(selectNode?.id) && index > 0;
|
|
2302
2389
|
return /*#__PURE__*/React__default["default"].createElement(ScrollBox, {
|
|
2303
2390
|
key: selectedId || index,
|
|
2304
2391
|
className: classnames__default["default"](style['content-item'], {
|
|
@@ -2308,17 +2395,21 @@ const CascaderInner = _ref => {
|
|
|
2308
2395
|
className: style['menu'],
|
|
2309
2396
|
selectedKeys: currentIds,
|
|
2310
2397
|
onSelect: _ref2 => {
|
|
2311
|
-
let
|
|
2398
|
+
let {
|
|
2399
|
+
key
|
|
2400
|
+
} = _ref2;
|
|
2312
2401
|
const node = mapping.get(key);
|
|
2313
2402
|
if (!node) return;
|
|
2314
|
-
const
|
|
2315
|
-
checked
|
|
2403
|
+
const {
|
|
2404
|
+
checked
|
|
2405
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2316
2406
|
onCheckedChange(!checked, node.id);
|
|
2317
2407
|
},
|
|
2318
2408
|
items: siblingNodes.map(node => {
|
|
2319
|
-
const
|
|
2320
|
-
checked
|
|
2321
|
-
indeterminate
|
|
2409
|
+
const {
|
|
2410
|
+
checked,
|
|
2411
|
+
indeterminate
|
|
2412
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2322
2413
|
return {
|
|
2323
2414
|
key: node.id,
|
|
2324
2415
|
label: /*#__PURE__*/React__default["default"].createElement(antd.Space, {
|
|
@@ -2349,9 +2440,10 @@ const CascaderInner = _ref => {
|
|
|
2349
2440
|
[style['single-mode']]: single
|
|
2350
2441
|
})
|
|
2351
2442
|
}, siblingNodes.map(node => {
|
|
2352
|
-
const
|
|
2353
|
-
checked
|
|
2354
|
-
indeterminate
|
|
2443
|
+
const {
|
|
2444
|
+
checked,
|
|
2445
|
+
indeterminate
|
|
2446
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2355
2447
|
return /*#__PURE__*/React__default["default"].createElement(antd.Checkbox, {
|
|
2356
2448
|
key: node.id,
|
|
2357
2449
|
checked: checked,
|
|
@@ -2362,21 +2454,25 @@ const CascaderInner = _ref => {
|
|
|
2362
2454
|
className: style['menu'],
|
|
2363
2455
|
selectedKeys: index === selectedIds.length - 1 ? [] : selectedIds,
|
|
2364
2456
|
onSelect: _ref3 => {
|
|
2365
|
-
let
|
|
2457
|
+
let {
|
|
2458
|
+
key
|
|
2459
|
+
} = _ref3;
|
|
2366
2460
|
const node = mapping.get(key);
|
|
2367
2461
|
if (!node) return;
|
|
2368
2462
|
if (isNotLastNode(node.id)) {
|
|
2369
2463
|
setSelectedIds(treeUtils.getSelectedQueue(node.id));
|
|
2370
2464
|
} else {
|
|
2371
|
-
const
|
|
2372
|
-
checked
|
|
2465
|
+
const {
|
|
2466
|
+
checked
|
|
2467
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2373
2468
|
onCheckedChange(!checked, node.id);
|
|
2374
2469
|
}
|
|
2375
2470
|
},
|
|
2376
2471
|
items: siblingNodes.map(node => {
|
|
2377
|
-
const
|
|
2378
|
-
checked
|
|
2379
|
-
indeterminate
|
|
2472
|
+
const {
|
|
2473
|
+
checked,
|
|
2474
|
+
indeterminate
|
|
2475
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2380
2476
|
const hasChildren = isNotLastNode(node.id);
|
|
2381
2477
|
|
|
2382
2478
|
// 计算子级选中数量
|
|
@@ -2420,45 +2516,32 @@ const CascaderInner = _ref => {
|
|
|
2420
2516
|
|
|
2421
2517
|
// 主组件
|
|
2422
2518
|
const SelectCascader = _ref4 => {
|
|
2423
|
-
let
|
|
2424
|
-
options =
|
|
2425
|
-
value
|
|
2426
|
-
onChange
|
|
2427
|
-
defaultValue
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
valueKey = _ref4$valueKey === void 0 ? 'id' : _ref4$valueKey,
|
|
2447
|
-
_ref4$labelKey = _ref4.labelKey,
|
|
2448
|
-
labelKey = _ref4$labelKey === void 0 ? 'label' : _ref4$labelKey,
|
|
2449
|
-
_ref4$placeholder = _ref4.placeholder,
|
|
2450
|
-
placeholder = _ref4$placeholder === void 0 ? '请选择' : _ref4$placeholder,
|
|
2451
|
-
_ref4$disabled = _ref4.disabled,
|
|
2452
|
-
disabled = _ref4$disabled === void 0 ? false : _ref4$disabled,
|
|
2453
|
-
_ref4$size = _ref4.size,
|
|
2454
|
-
size = _ref4$size === void 0 ? 'default' : _ref4$size,
|
|
2455
|
-
overlayWidth = _ref4.overlayWidth,
|
|
2456
|
-
props = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
2519
|
+
let {
|
|
2520
|
+
options = [],
|
|
2521
|
+
value,
|
|
2522
|
+
onChange,
|
|
2523
|
+
defaultValue,
|
|
2524
|
+
maxLength = Number.MAX_VALUE,
|
|
2525
|
+
single = false,
|
|
2526
|
+
onlyAllowLastLevel = false,
|
|
2527
|
+
openLoadData = false,
|
|
2528
|
+
onLoadMore,
|
|
2529
|
+
parentIdKey = 'id',
|
|
2530
|
+
menuItemWidth = 180,
|
|
2531
|
+
isPopup = true,
|
|
2532
|
+
searchPlaceholder,
|
|
2533
|
+
onSearch,
|
|
2534
|
+
valueKey = 'id',
|
|
2535
|
+
labelKey = 'label',
|
|
2536
|
+
placeholder = '请选择',
|
|
2537
|
+
disabled = false,
|
|
2538
|
+
size = 'default',
|
|
2539
|
+
overlayWidth,
|
|
2540
|
+
...props
|
|
2541
|
+
} = _ref4;
|
|
2457
2542
|
// 内部始终使用数组格式处理
|
|
2458
2543
|
// SelectInput 会处理 single 模式的 value 和 onChange 转换
|
|
2459
|
-
const
|
|
2460
|
-
innerValue = _useState4[0],
|
|
2461
|
-
setInnerValue = _useState4[1];
|
|
2544
|
+
const [innerValue, setInnerValue] = React.useState(Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : []);
|
|
2462
2545
|
|
|
2463
2546
|
// currentValue 用于内部处理,始终是数组
|
|
2464
2547
|
const currentValue = React.useMemo(() => {
|
|
@@ -2488,10 +2571,10 @@ const SelectCascader = _ref4 => {
|
|
|
2488
2571
|
// 根据单选/多选模式转换输出格式
|
|
2489
2572
|
if (single) {
|
|
2490
2573
|
// 单选:返回单个对象或 null
|
|
2491
|
-
onChange
|
|
2574
|
+
onChange?.(normalizedValue.length > 0 ? normalizedValue[0] : null);
|
|
2492
2575
|
} else {
|
|
2493
2576
|
// 多选:返回数组
|
|
2494
|
-
onChange
|
|
2577
|
+
onChange?.(normalizedValue);
|
|
2495
2578
|
}
|
|
2496
2579
|
}, [value, onChange, single]);
|
|
2497
2580
|
|
|
@@ -2513,10 +2596,11 @@ const SelectCascader = _ref4 => {
|
|
|
2513
2596
|
if (typeof item === 'object') {
|
|
2514
2597
|
// 优先使用 item[labelKey],然后是 item.label,最后是 item.name
|
|
2515
2598
|
const label = item[labelKey] || item.label || item.name || String(item[valueKey] || '');
|
|
2516
|
-
return
|
|
2599
|
+
return {
|
|
2600
|
+
...item,
|
|
2517
2601
|
[valueKey]: item[valueKey] || item.id,
|
|
2518
2602
|
[labelKey]: label
|
|
2519
|
-
}
|
|
2603
|
+
};
|
|
2520
2604
|
}
|
|
2521
2605
|
// 如果是值,从 options 中查找
|
|
2522
2606
|
const findLabel = items => {
|
|
@@ -2562,10 +2646,11 @@ const SelectCascader = _ref4 => {
|
|
|
2562
2646
|
// 如果已经是对象,确保有标准化的字段
|
|
2563
2647
|
if (typeof item === 'object') {
|
|
2564
2648
|
const label = item[labelKey] || item.label || item.name || String(item[valueKey] || '');
|
|
2565
|
-
return
|
|
2649
|
+
return {
|
|
2650
|
+
...item,
|
|
2566
2651
|
[valueKey]: item[valueKey] || item.id,
|
|
2567
2652
|
[labelKey]: label
|
|
2568
|
-
}
|
|
2653
|
+
};
|
|
2569
2654
|
}
|
|
2570
2655
|
// 如果是值,从 options 中查找
|
|
2571
2656
|
const findLabel = items => {
|
|
@@ -2613,7 +2698,7 @@ const SelectCascader = _ref4 => {
|
|
|
2613
2698
|
|
|
2614
2699
|
Object.defineProperty(exports, 'mergeTreeChildren', {
|
|
2615
2700
|
enumerable: true,
|
|
2616
|
-
get: function () { return
|
|
2701
|
+
get: function () { return TablePage.mergeTreeChildren; }
|
|
2617
2702
|
});
|
|
2618
2703
|
exports.SelectCascader = SelectCascader;
|
|
2619
2704
|
exports.SelectInput = SelectInput;
|