@kne/super-select 0.1.34 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +179 -170
- package/dist/index.css.map +1 -1
- package/dist/index.js +380 -419
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +23 -12
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -15,6 +15,8 @@ require('simplebar-react/dist/simplebar.min.css');
|
|
|
15
15
|
var SearchInput = require('@kne/search-input');
|
|
16
16
|
var scrollLoader = require('@kne/scroll-loader');
|
|
17
17
|
require('@kne/scroll-loader/dist/index.css');
|
|
18
|
+
var TableView = require('@kne/table-view');
|
|
19
|
+
require('@kne/table-view/dist/index.css');
|
|
18
20
|
var infoPage = require('@kne/info-page');
|
|
19
21
|
require('@kne/info-page/dist/index.css');
|
|
20
22
|
var memoize = require('lodash/memoize');
|
|
@@ -32,6 +34,7 @@ var last__default = /*#__PURE__*/_interopDefaultLegacy(last);
|
|
|
32
34
|
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
33
35
|
var SimpleBar__default = /*#__PURE__*/_interopDefaultLegacy(SimpleBar);
|
|
34
36
|
var SearchInput__default = /*#__PURE__*/_interopDefaultLegacy(SearchInput);
|
|
37
|
+
var TableView__default = /*#__PURE__*/_interopDefaultLegacy(TableView);
|
|
35
38
|
var memoize__default = /*#__PURE__*/_interopDefaultLegacy(memoize);
|
|
36
39
|
var isNil__default = /*#__PURE__*/_interopDefaultLegacy(isNil);
|
|
37
40
|
var Fetch__default = /*#__PURE__*/_interopDefaultLegacy(Fetch);
|
|
@@ -45,6 +48,15 @@ function _extends() {
|
|
|
45
48
|
return n;
|
|
46
49
|
}, _extends.apply(null, arguments);
|
|
47
50
|
}
|
|
51
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
52
|
+
if (null == r) return {};
|
|
53
|
+
var t = {};
|
|
54
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
55
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
56
|
+
t[n] = r[n];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
}
|
|
48
60
|
|
|
49
61
|
const context = globalContext.createContext();
|
|
50
62
|
const {
|
|
@@ -52,7 +64,7 @@ const {
|
|
|
52
64
|
useContext
|
|
53
65
|
} = context;
|
|
54
66
|
|
|
55
|
-
var style$6 = {"select-input":"
|
|
67
|
+
var style$6 = {"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","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","overlay":"kne-super-select_ybN30","select-input-prefix":"kne-super-select_4Pw75","select-input-suffix":"kne-super-select_Wd4pE"};
|
|
56
68
|
|
|
57
69
|
const locale$1 = {
|
|
58
70
|
placeholder: '请选择',
|
|
@@ -166,8 +178,9 @@ const TagOverflowInner = ({
|
|
|
166
178
|
}, "+", hiddenCount));
|
|
167
179
|
};
|
|
168
180
|
|
|
181
|
+
const _excluded$3 = ["children"];
|
|
169
182
|
const numberToPx$1 = val => {
|
|
170
|
-
return typeof val === 'number' ?
|
|
183
|
+
return typeof val === 'number' ? val + "px" : val;
|
|
171
184
|
};
|
|
172
185
|
const pxToNumber = value => {
|
|
173
186
|
if (!value) return 0;
|
|
@@ -178,15 +191,13 @@ const pxToNumber = value => {
|
|
|
178
191
|
return match ? Number(match[0]) : 0;
|
|
179
192
|
};
|
|
180
193
|
const ModalContent = _ref => {
|
|
181
|
-
let
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
} = others;
|
|
189
|
-
const [value, setValue] = React.useState(propsValue);
|
|
194
|
+
let children = _ref.children,
|
|
195
|
+
others = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
196
|
+
const open = others.open,
|
|
197
|
+
propsValue = others.value;
|
|
198
|
+
const _useState = React.useState(propsValue),
|
|
199
|
+
value = _useState[0],
|
|
200
|
+
setValue = _useState[1];
|
|
190
201
|
React.useEffect(() => {
|
|
191
202
|
if (open && !isEqual__default["default"](value, propsValue)) {
|
|
192
203
|
setValue(propsValue);
|
|
@@ -214,9 +225,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
214
225
|
}
|
|
215
226
|
})(React.forwardRef((p, ref) => {
|
|
216
227
|
const intl = reactIntl.useIntl();
|
|
217
|
-
const
|
|
218
|
-
formatMessage
|
|
219
|
-
} = intl;
|
|
228
|
+
const formatMessage = intl.formatMessage;
|
|
220
229
|
const props = Object.assign({}, {
|
|
221
230
|
children: () => formatMessage({
|
|
222
231
|
id: 'defaultChildren'
|
|
@@ -251,17 +260,15 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
251
260
|
extra: null,
|
|
252
261
|
size: 'default',
|
|
253
262
|
renderModal: contextProps => {
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
placeholder,
|
|
262
|
-
children
|
|
263
|
-
} = props;
|
|
263
|
+
const props = contextProps.props,
|
|
264
|
+
open = contextProps.open,
|
|
265
|
+
onComplete = contextProps.onComplete,
|
|
266
|
+
onOpenChange = contextProps.onOpenChange;
|
|
267
|
+
const placeholder = props.placeholder,
|
|
268
|
+
children = props.children,
|
|
269
|
+
overlayClassName = props.overlayClassName;
|
|
264
270
|
return /*#__PURE__*/React__default["default"].createElement(antd.Modal, {
|
|
271
|
+
className: overlayClassName,
|
|
265
272
|
width: 1000,
|
|
266
273
|
open: open,
|
|
267
274
|
title: placeholder,
|
|
@@ -279,27 +286,29 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
279
286
|
[props.valueKey]: props.selectedAllValue.value,
|
|
280
287
|
[props.labelKey]: props.selectedAllValue.label
|
|
281
288
|
};
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
289
|
+
const children = props.children,
|
|
290
|
+
prefix = props.prefix,
|
|
291
|
+
suffix = props.suffix,
|
|
292
|
+
className = props.className,
|
|
293
|
+
maxLength = props.maxLength,
|
|
294
|
+
overlayClassName = props.overlayClassName,
|
|
295
|
+
overlayStyle = props.overlayStyle,
|
|
296
|
+
align = props.align,
|
|
297
|
+
autoAdjustOverflow = props.autoAdjustOverflow,
|
|
298
|
+
transitionName = props.transitionName,
|
|
299
|
+
single = props.single,
|
|
300
|
+
labelWrap = props.labelWrap,
|
|
301
|
+
isPopup = props.isPopup,
|
|
302
|
+
allowClear = props.allowClear,
|
|
303
|
+
disabled = props.disabled,
|
|
304
|
+
placeholder = props.placeholder,
|
|
305
|
+
selectedAllValue = props.selectedAllValue,
|
|
306
|
+
overlayWidth = props.overlayWidth,
|
|
307
|
+
placement = props.placement,
|
|
308
|
+
renderModal = props.renderModal,
|
|
309
|
+
labelKey = props.labelKey,
|
|
310
|
+
valueKey = props.valueKey,
|
|
311
|
+
size = props.size;
|
|
303
312
|
const transformValue = value => {
|
|
304
313
|
if (single) {
|
|
305
314
|
return isEmpty.isNotEmpty(value) ? [value] : [];
|
|
@@ -307,24 +316,36 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
307
316
|
return Array.isArray(value) ? value : [];
|
|
308
317
|
}
|
|
309
318
|
};
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
319
|
+
const _useControlValue = useControlValue__default["default"](Object.assign({}, props, {
|
|
320
|
+
onChange: value => {
|
|
321
|
+
props.onChange && props.onChange(props.single ? last__default["default"](value) : value);
|
|
322
|
+
}
|
|
323
|
+
}, 'value' in props ? {
|
|
324
|
+
value: transformValue(props.value)
|
|
325
|
+
} : {
|
|
326
|
+
defaultValue: transformValue(props.defaultValue)
|
|
327
|
+
})),
|
|
328
|
+
value = _useControlValue[0],
|
|
329
|
+
setValue = _useControlValue[1];
|
|
330
|
+
const _useState2 = React.useState({}),
|
|
331
|
+
searchProps = _useState2[0],
|
|
332
|
+
setSearchProps = _useState2[1];
|
|
333
|
+
const _useControlValue2 = useControlValue__default["default"](props, {
|
|
334
|
+
defaultValue: 'defaultOpen',
|
|
335
|
+
value: 'open',
|
|
336
|
+
onChange: 'onOpenChange'
|
|
337
|
+
}),
|
|
338
|
+
open = _useControlValue2[0],
|
|
339
|
+
setOpen = _useControlValue2[1];
|
|
340
|
+
const _useState3 = React.useState(false),
|
|
341
|
+
hover = _useState3[0],
|
|
342
|
+
setHover = _useState3[1];
|
|
343
|
+
const _useState4 = React.useState(0),
|
|
344
|
+
innerWidth = _useState4[0],
|
|
345
|
+
setInnerWidth = _useState4[1];
|
|
346
|
+
const _useState5 = React.useState(0),
|
|
347
|
+
containerWidth = _useState5[0],
|
|
348
|
+
setContainerWidth = _useState5[1];
|
|
328
349
|
const containerWidthChange = el => {
|
|
329
350
|
if (!el) {
|
|
330
351
|
return;
|
|
@@ -338,9 +359,8 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
338
359
|
return numberToPx$1(Math.max(containerWidth, pxToNumber(overlayWidth)));
|
|
339
360
|
}, [containerWidth, overlayWidth]);
|
|
340
361
|
const containerRef = useResize__default["default"](containerWidthChange);
|
|
341
|
-
const
|
|
342
|
-
message
|
|
343
|
-
} = antd.App.useApp();
|
|
362
|
+
const _App$useApp = antd.App.useApp(),
|
|
363
|
+
message = _App$useApp.message;
|
|
344
364
|
const checkMaxLength = (value, maxLength) => {
|
|
345
365
|
if (Number.isInteger(maxLength) && maxLength > 0 && value.length >= maxLength) {
|
|
346
366
|
message.error(formatMessage({
|
|
@@ -479,6 +499,10 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
479
499
|
placement: placement,
|
|
480
500
|
arrow: false,
|
|
481
501
|
overlayClassName: classnames__default["default"](style$6['overlay'], overlayClassName),
|
|
502
|
+
overlayStyle: overlayStyle,
|
|
503
|
+
align: align,
|
|
504
|
+
autoAdjustOverflow: autoAdjustOverflow,
|
|
505
|
+
transitionName: transitionName,
|
|
482
506
|
trigger: "click",
|
|
483
507
|
popupRender: () => /*#__PURE__*/React__default["default"].createElement("div", {
|
|
484
508
|
style: {
|
|
@@ -496,28 +520,25 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
496
520
|
}), /*#__PURE__*/React__default["default"].createElement(ModalContent, contextProps, renderModal)));
|
|
497
521
|
}));
|
|
498
522
|
|
|
499
|
-
var style$5 = {"selected-all":"
|
|
523
|
+
var style$5 = {"selected-all":"kne-super-select_prlgN"};
|
|
500
524
|
|
|
501
525
|
const SelectedAll = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
|
|
502
|
-
const
|
|
503
|
-
formatMessage
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
unit
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
number
|
|
519
|
-
})
|
|
520
|
-
}, props);
|
|
526
|
+
const _useIntl = reactIntl.useIntl(),
|
|
527
|
+
formatMessage = _useIntl.formatMessage;
|
|
528
|
+
const _useContext = useContext(),
|
|
529
|
+
props = _useContext.props,
|
|
530
|
+
value = _useContext.value,
|
|
531
|
+
setValue = _useContext.setValue;
|
|
532
|
+
const _Object$assign = Object.assign({}, {
|
|
533
|
+
unit: number => formatMessage({
|
|
534
|
+
id: 'numberOf'
|
|
535
|
+
}, {
|
|
536
|
+
number
|
|
537
|
+
})
|
|
538
|
+
}, props),
|
|
539
|
+
unit = _Object$assign.unit,
|
|
540
|
+
selectedAllValue = _Object$assign.selectedAllValue,
|
|
541
|
+
valueKey = _Object$assign.valueKey;
|
|
521
542
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
522
543
|
return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
523
544
|
justify: "space-between",
|
|
@@ -544,26 +565,23 @@ const computedIsSelectAll = function (value, selectedAllValue, valueKey) {
|
|
|
544
565
|
if (valueKey === void 0) {
|
|
545
566
|
valueKey = 'value';
|
|
546
567
|
}
|
|
547
|
-
return value
|
|
568
|
+
return (value == null ? void 0 : value.length) === 1 && get__default["default"](value, "[0][" + valueKey + "]") === selectedAllValue[valueKey];
|
|
548
569
|
};
|
|
549
570
|
|
|
550
|
-
var style$4 = {"label":"
|
|
571
|
+
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"};
|
|
551
572
|
|
|
552
573
|
const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
|
|
553
|
-
const
|
|
554
|
-
formatMessage
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
labelKey,
|
|
565
|
-
valueKey
|
|
566
|
-
} = Object.assign({}, props);
|
|
574
|
+
const _useIntl = reactIntl.useIntl(),
|
|
575
|
+
formatMessage = _useIntl.formatMessage;
|
|
576
|
+
const _useContext = useContext(),
|
|
577
|
+
props = _useContext.props,
|
|
578
|
+
value = _useContext.value,
|
|
579
|
+
onRemove = _useContext.onRemove;
|
|
580
|
+
const _Object$assign = Object.assign({}, props),
|
|
581
|
+
single = _Object$assign.single,
|
|
582
|
+
maxLength = _Object$assign.maxLength,
|
|
583
|
+
labelKey = _Object$assign.labelKey,
|
|
584
|
+
valueKey = _Object$assign.valueKey;
|
|
567
585
|
return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
568
586
|
className: classnames__default["default"](style$4['tag-list'], 'selected-tag-list'),
|
|
569
587
|
gap: 8
|
|
@@ -571,7 +589,7 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
571
589
|
className: style$4['label']
|
|
572
590
|
}, formatMessage({
|
|
573
591
|
id: 'selected'
|
|
574
|
-
}), !single && value.length > 0 &&
|
|
592
|
+
}), !single && value.length > 0 && "(" + value.length + (Number.isInteger(maxLength) ? "/" + maxLength : '') + ")", ":"), /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
|
|
575
593
|
className: style$4['tag-container']
|
|
576
594
|
}, /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
577
595
|
gap: 8,
|
|
@@ -593,23 +611,18 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
593
611
|
}))));
|
|
594
612
|
});
|
|
595
613
|
|
|
596
|
-
var style$3 = {"list":"
|
|
614
|
+
var style$3 = {"list":"kne-super-select_IsXdU","is-popup":"kne-super-select_-dvpa","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"};
|
|
597
615
|
|
|
616
|
+
const _excluded$2 = ["children"];
|
|
598
617
|
const SelectList = React.forwardRef((_ref, ref) => {
|
|
599
|
-
let
|
|
600
|
-
|
|
601
|
-
...p
|
|
602
|
-
} = _ref;
|
|
618
|
+
let children = _ref.children,
|
|
619
|
+
p = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
603
620
|
const fetchListRef = React.useRef(null);
|
|
604
621
|
const props = Object.assign({}, {
|
|
605
622
|
renderItemContent: _ref2 => {
|
|
606
|
-
let
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
} = _ref2;
|
|
610
|
-
const {
|
|
611
|
-
labelKey
|
|
612
|
-
} = props;
|
|
623
|
+
let item = _ref2.item,
|
|
624
|
+
props = _ref2.props;
|
|
625
|
+
const labelKey = props.labelKey;
|
|
613
626
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
614
627
|
className: 'select-list-item-label'
|
|
615
628
|
}, item[labelKey]), item.description && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -617,21 +630,17 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
617
630
|
}, item.description));
|
|
618
631
|
},
|
|
619
632
|
renderItem: contextProps => {
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
isPopup,
|
|
632
|
-
renderItemContent,
|
|
633
|
-
valueKey
|
|
634
|
-
} = props;
|
|
633
|
+
const item = contextProps.item,
|
|
634
|
+
props = contextProps.props,
|
|
635
|
+
isSelectedAll = contextProps.isSelectedAll,
|
|
636
|
+
value = contextProps.value,
|
|
637
|
+
onSelect = contextProps.onSelect,
|
|
638
|
+
setValue = contextProps.setValue,
|
|
639
|
+
onOpenChange = contextProps.onOpenChange;
|
|
640
|
+
const single = props.single,
|
|
641
|
+
isPopup = props.isPopup,
|
|
642
|
+
renderItemContent = props.renderItemContent,
|
|
643
|
+
valueKey = props.valueKey;
|
|
635
644
|
const isChecked = value.some(target => target[valueKey] === item[valueKey]);
|
|
636
645
|
return /*#__PURE__*/React__default["default"].createElement(antd.List.Item, {
|
|
637
646
|
className: classnames__default["default"](style$3['default-list-item'], 'select-list-item', {
|
|
@@ -668,14 +677,10 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
668
677
|
}, isChecked && /*#__PURE__*/React__default["default"].createElement(icons.CheckOutlined, null)));
|
|
669
678
|
},
|
|
670
679
|
renderList: contextProps => {
|
|
671
|
-
const
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
} = contextProps;
|
|
676
|
-
const {
|
|
677
|
-
renderItem
|
|
678
|
-
} = props;
|
|
680
|
+
const props = contextProps.props,
|
|
681
|
+
isSelectedAll = contextProps.isSelectedAll,
|
|
682
|
+
list = contextProps.list;
|
|
683
|
+
const renderItem = props.renderItem;
|
|
679
684
|
if (!(list && list.length > 0)) {
|
|
680
685
|
return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, {
|
|
681
686
|
className: style$3['empty']
|
|
@@ -696,28 +701,24 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
696
701
|
return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
|
|
697
702
|
ref: ref
|
|
698
703
|
}), targetProps => {
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
options,
|
|
718
|
-
renderList,
|
|
719
|
-
selectedAllValue
|
|
720
|
-
} = props;
|
|
704
|
+
const props = targetProps.props,
|
|
705
|
+
value = targetProps.value,
|
|
706
|
+
searchProps = targetProps.searchProps,
|
|
707
|
+
setSearchProps = targetProps.setSearchProps,
|
|
708
|
+
onOpenChange = targetProps.onOpenChange;
|
|
709
|
+
const footer = props.footer,
|
|
710
|
+
isPopup = props.isPopup,
|
|
711
|
+
getSearchProps = props.getSearchProps,
|
|
712
|
+
getSearchCallback = props.getSearchCallback,
|
|
713
|
+
searchPlaceholder = props.searchPlaceholder,
|
|
714
|
+
valueKey = props.valueKey,
|
|
715
|
+
single = props.single,
|
|
716
|
+
allowSelectedAll = props.allowSelectedAll,
|
|
717
|
+
showSelectedTag = props.showSelectedTag,
|
|
718
|
+
api = props.api,
|
|
719
|
+
options = props.options,
|
|
720
|
+
renderList = props.renderList,
|
|
721
|
+
selectedAllValue = props.selectedAllValue;
|
|
721
722
|
const components = {
|
|
722
723
|
search: (api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function') && /*#__PURE__*/React__default["default"].createElement(SearchInput__default["default"], {
|
|
723
724
|
className: classnames__default["default"](style$3['select-search'], 'select-list-search', {
|
|
@@ -750,13 +751,9 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
750
751
|
searchProps
|
|
751
752
|
},
|
|
752
753
|
loader: _ref3 => {
|
|
753
|
-
let
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
const {
|
|
757
|
-
options,
|
|
758
|
-
searchProps
|
|
759
|
-
} = data;
|
|
754
|
+
let data = _ref3.data;
|
|
755
|
+
const options = data.options,
|
|
756
|
+
searchProps = data.searchProps;
|
|
760
757
|
if (typeof getSearchCallback === 'function') {
|
|
761
758
|
const newOptions = options.filter(item => getSearchCallback(searchProps, item));
|
|
762
759
|
return {
|
|
@@ -802,31 +799,27 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
802
799
|
});
|
|
803
800
|
});
|
|
804
801
|
|
|
805
|
-
var style$2 = {"
|
|
802
|
+
var style$2 = {"table":"kne-super-select_zE-14","list":"kne-super-select_DrEYJ","is-popup":"kne-super-select_KgWTX","empty":"kne-super-select_5Tyrt","right-options":"kne-super-select_UXi-g","no-padding-btn":"kne-super-select_iaCir","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"};
|
|
806
803
|
|
|
807
804
|
const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(React.forwardRef((p, ref) => {
|
|
808
|
-
const
|
|
809
|
-
formatMessage
|
|
810
|
-
|
|
811
|
-
|
|
805
|
+
const _useIntl = reactIntl.useIntl(),
|
|
806
|
+
formatMessage = _useIntl.formatMessage;
|
|
807
|
+
const _useState = React.useState(''),
|
|
808
|
+
tagSearchText = _useState[0],
|
|
809
|
+
setTagSearchText = _useState[1];
|
|
812
810
|
const fetchListRef = React.useRef();
|
|
813
811
|
const props = Object.assign({}, {
|
|
814
812
|
overlayWidth: '600px',
|
|
815
813
|
filterRender: contextProps => {
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
getSearchProps,
|
|
826
|
-
options,
|
|
827
|
-
getSearchCallback,
|
|
828
|
-
labelKey
|
|
829
|
-
} = props;
|
|
814
|
+
const props = contextProps.props,
|
|
815
|
+
searchProps = contextProps.searchProps,
|
|
816
|
+
setSearchProps = contextProps.setSearchProps;
|
|
817
|
+
const isPopup = props.isPopup,
|
|
818
|
+
searchPlaceholder = props.searchPlaceholder,
|
|
819
|
+
api = props.api,
|
|
820
|
+
getSearchProps = props.getSearchProps,
|
|
821
|
+
options = props.options,
|
|
822
|
+
getSearchCallback = props.getSearchCallback;
|
|
830
823
|
if (!(api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function')) {
|
|
831
824
|
return null;
|
|
832
825
|
}
|
|
@@ -846,12 +839,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
846
839
|
});
|
|
847
840
|
},
|
|
848
841
|
getTagSearchCallback: (tagSearchText, item, contextProps) => {
|
|
849
|
-
const
|
|
850
|
-
|
|
851
|
-
} = contextProps;
|
|
852
|
-
const {
|
|
853
|
-
labelKey
|
|
854
|
-
} = props;
|
|
842
|
+
const props = contextProps.props;
|
|
843
|
+
const labelKey = props.labelKey;
|
|
855
844
|
if (!tagSearchText) {
|
|
856
845
|
return true;
|
|
857
846
|
}
|
|
@@ -862,39 +851,35 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
862
851
|
return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
|
|
863
852
|
ref: ref
|
|
864
853
|
}), targetProps => {
|
|
865
|
-
const
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
searchPlaceholder,
|
|
888
|
-
allowSelectedAll,
|
|
889
|
-
labelKey,
|
|
890
|
-
valueKey
|
|
891
|
-
} = props;
|
|
854
|
+
const props = targetProps.props,
|
|
855
|
+
value = targetProps.value,
|
|
856
|
+
setValue = targetProps.setValue,
|
|
857
|
+
onRemove = targetProps.onRemove,
|
|
858
|
+
onOpenChange = targetProps.onOpenChange,
|
|
859
|
+
searchProps = targetProps.searchProps;
|
|
860
|
+
const footer = props.footer,
|
|
861
|
+
filterRender = props.filterRender,
|
|
862
|
+
columns = props.columns,
|
|
863
|
+
options = props.options,
|
|
864
|
+
getSearchProps = props.getSearchProps,
|
|
865
|
+
getSearchCallback = props.getSearchCallback,
|
|
866
|
+
getTagSearchCallback = props.getTagSearchCallback,
|
|
867
|
+
api = props.api,
|
|
868
|
+
selectedAllValue = props.selectedAllValue,
|
|
869
|
+
isPopup = props.isPopup,
|
|
870
|
+
single = props.single,
|
|
871
|
+
maxLength = props.maxLength,
|
|
872
|
+
searchPlaceholder = props.searchPlaceholder,
|
|
873
|
+
allowSelectedAll = props.allowSelectedAll,
|
|
874
|
+
labelKey = props.labelKey,
|
|
875
|
+
valueKey = props.valueKey;
|
|
892
876
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
893
877
|
const footerEl = footer && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
894
878
|
className: classnames__default["default"](style$2['footer'], 'select-table-footer')
|
|
895
879
|
}, typeof footer === 'function' ? footer({
|
|
896
880
|
reload: () => {
|
|
897
|
-
|
|
881
|
+
var _fetchListRef$current, _fetchListRef$current2;
|
|
882
|
+
((_fetchListRef$current = fetchListRef.current) == null ? void 0 : _fetchListRef$current.fetchApi) && ((_fetchListRef$current2 = fetchListRef.current) == null ? void 0 : _fetchListRef$current2.fetchApi.reload());
|
|
898
883
|
},
|
|
899
884
|
close: () => {
|
|
900
885
|
onOpenChange(false);
|
|
@@ -910,7 +895,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
910
895
|
span: single ? 24 : 16
|
|
911
896
|
}, /*#__PURE__*/React__default["default"].createElement("div", null, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
912
897
|
className: classnames__default["default"](style$2['table'], 'select-table')
|
|
913
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
898
|
+
}, /*#__PURE__*/React__default["default"].createElement(TableView__default["default"], {
|
|
914
899
|
columns: columns,
|
|
915
900
|
rowKey: valueKey,
|
|
916
901
|
rowSelection: {
|
|
@@ -922,12 +907,11 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
922
907
|
type: single ? 'radio' : 'checkbox',
|
|
923
908
|
selectedRowKeys: (value || []).map(item => item[valueKey]),
|
|
924
909
|
onChange: (selectedRowKeys, selectedKey, _ref) => {
|
|
925
|
-
let
|
|
926
|
-
checked
|
|
927
|
-
} = _ref;
|
|
910
|
+
let checked = _ref.checked;
|
|
928
911
|
setValue(value => {
|
|
929
912
|
if (checked) {
|
|
930
|
-
|
|
913
|
+
var _fetchListRef$current3;
|
|
914
|
+
const selectedItem = (_fetchListRef$current3 = fetchListRef.current) == null ? void 0 : _fetchListRef$current3.list.find(item => item[valueKey] === selectedKey);
|
|
931
915
|
if (selectedItem) {
|
|
932
916
|
if (single) {
|
|
933
917
|
return [selectedItem];
|
|
@@ -947,11 +931,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
947
931
|
}
|
|
948
932
|
},
|
|
949
933
|
render: _ref2 => {
|
|
950
|
-
let
|
|
951
|
-
|
|
952
|
-
renderBody
|
|
953
|
-
} = _ref2;
|
|
954
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, header, /*#__PURE__*/React__default["default"].createElement(scrollLoader.FetchScrollLoader, _extends({}, props, {
|
|
934
|
+
let renderBody = _ref2.renderBody;
|
|
935
|
+
return /*#__PURE__*/React__default["default"].createElement(scrollLoader.FetchScrollLoader, _extends({}, props, {
|
|
955
936
|
className: classnames__default["default"](style$2['list'], 'select-table-list-scroll-list', {
|
|
956
937
|
'is-popup': isPopup
|
|
957
938
|
}),
|
|
@@ -963,13 +944,9 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
963
944
|
searchProps
|
|
964
945
|
},
|
|
965
946
|
loader: _ref3 => {
|
|
966
|
-
let
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
const {
|
|
970
|
-
options,
|
|
971
|
-
searchProps
|
|
972
|
-
} = data;
|
|
947
|
+
let data = _ref3.data;
|
|
948
|
+
const options = data.options,
|
|
949
|
+
searchProps = data.searchProps;
|
|
973
950
|
if (typeof getSearchCallback === 'function') {
|
|
974
951
|
const newOptions = options.filter(item => getSearchCallback(searchProps, item, targetProps));
|
|
975
952
|
return {
|
|
@@ -983,9 +960,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
983
960
|
} : api)
|
|
984
961
|
}), fetchProps => {
|
|
985
962
|
fetchListRef.current = fetchProps;
|
|
986
|
-
const
|
|
987
|
-
list
|
|
988
|
-
} = fetchProps;
|
|
963
|
+
const list = fetchProps.list;
|
|
989
964
|
const contextProps = Object.assign({}, fetchProps, targetProps, {
|
|
990
965
|
isSelectedAll
|
|
991
966
|
});
|
|
@@ -995,7 +970,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
995
970
|
});
|
|
996
971
|
}
|
|
997
972
|
return renderBody(list, contextProps);
|
|
998
|
-
})
|
|
973
|
+
});
|
|
999
974
|
}
|
|
1000
975
|
})), single && footerEl || /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1001
976
|
className: classnames__default["default"](style$2['footer'], 'select-table-footer')
|
|
@@ -1018,7 +993,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1018
993
|
align: 'middle'
|
|
1019
994
|
}, /*#__PURE__*/React__default["default"].createElement(antd.Col, null, formatMessage({
|
|
1020
995
|
id: 'selected'
|
|
1021
|
-
}), value.length > 0 &&
|
|
996
|
+
}), value.length > 0 && "(" + value.length + (Number.isInteger(maxLength) ? "/" + maxLength : '') + ")", ":"), /*#__PURE__*/React__default["default"].createElement(antd.Col, null, /*#__PURE__*/React__default["default"].createElement(antd.Button, {
|
|
1022
997
|
className: style$2['no-padding-btn'],
|
|
1023
998
|
type: "link",
|
|
1024
999
|
onClick: () => {
|
|
@@ -1030,6 +1005,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1030
1005
|
wrap: true,
|
|
1031
1006
|
gap: 8
|
|
1032
1007
|
}, value.filter(item => getTagSearchCallback(tagSearchText, item, targetProps)).map(item => {
|
|
1008
|
+
var _fetchListRef$current4, _fetchListRef$current5;
|
|
1033
1009
|
return /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
1034
1010
|
className: style$2['tag'],
|
|
1035
1011
|
key: item[valueKey],
|
|
@@ -1053,8 +1029,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1053
1029
|
})),
|
|
1054
1030
|
dataSource: Object.assign({}, item),
|
|
1055
1031
|
context: Object.assign({}, targetProps, {
|
|
1056
|
-
fetchApi: fetchListRef.current
|
|
1057
|
-
list: fetchListRef.current
|
|
1032
|
+
fetchApi: (_fetchListRef$current4 = fetchListRef.current) == null ? void 0 : _fetchListRef$current4.fetchApi,
|
|
1033
|
+
list: (_fetchListRef$current5 = fetchListRef.current) == null ? void 0 : _fetchListRef$current5.list
|
|
1058
1034
|
})
|
|
1059
1035
|
})
|
|
1060
1036
|
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -1064,17 +1040,17 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1064
1040
|
});
|
|
1065
1041
|
}));
|
|
1066
1042
|
|
|
1067
|
-
var style$1 = {"list":"
|
|
1043
|
+
var style$1 = {"list":"kne-super-select_YTqxA","is-popup":"kne-super-select_TR-1a","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"};
|
|
1068
1044
|
|
|
1045
|
+
const _excluded$1 = ["children"],
|
|
1046
|
+
_excluded2 = ["data"];
|
|
1069
1047
|
const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
1070
1048
|
if (data === void 0) {
|
|
1071
1049
|
data = [];
|
|
1072
1050
|
}
|
|
1073
|
-
let
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
childrenKey
|
|
1077
|
-
} = _ref;
|
|
1051
|
+
let parentKey = _ref.parentKey,
|
|
1052
|
+
valueKey = _ref.valueKey,
|
|
1053
|
+
childrenKey = _ref.childrenKey;
|
|
1078
1054
|
const parseTree = output => {
|
|
1079
1055
|
return output.map(node => {
|
|
1080
1056
|
const children = data.filter(item => {
|
|
@@ -1091,43 +1067,35 @@ const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
|
1091
1067
|
};
|
|
1092
1068
|
});
|
|
1093
1069
|
const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
1094
|
-
let
|
|
1095
|
-
|
|
1096
|
-
...p
|
|
1097
|
-
} = _ref2;
|
|
1070
|
+
let children = _ref2.children,
|
|
1071
|
+
p = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
|
|
1098
1072
|
const fetchListRef = React.useRef(null);
|
|
1099
|
-
const
|
|
1073
|
+
const _useState = React.useState([]),
|
|
1074
|
+
expandedKeys = _useState[0],
|
|
1075
|
+
setExpandedKeys = _useState[1];
|
|
1100
1076
|
const props = Object.assign({}, {
|
|
1101
1077
|
parentKey: 'parentId',
|
|
1102
1078
|
childrenKey: 'children',
|
|
1103
1079
|
renderItemContent: _ref3 => {
|
|
1104
|
-
let
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
} = _ref3;
|
|
1108
|
-
const {
|
|
1109
|
-
labelKey
|
|
1110
|
-
} = props;
|
|
1080
|
+
let item = _ref3.item,
|
|
1081
|
+
props = _ref3.props;
|
|
1082
|
+
const labelKey = props.labelKey;
|
|
1111
1083
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1112
1084
|
className: 'select-tree-item-label'
|
|
1113
1085
|
}, item[labelKey]));
|
|
1114
1086
|
},
|
|
1115
1087
|
renderItem: contextProps => {
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
isPopup,
|
|
1128
|
-
renderItemContent,
|
|
1129
|
-
valueKey
|
|
1130
|
-
} = props;
|
|
1088
|
+
const item = contextProps.item,
|
|
1089
|
+
props = contextProps.props,
|
|
1090
|
+
isSelectedAll = contextProps.isSelectedAll,
|
|
1091
|
+
value = contextProps.value,
|
|
1092
|
+
onSelect = contextProps.onSelect,
|
|
1093
|
+
setValue = contextProps.setValue,
|
|
1094
|
+
onOpenChange = contextProps.onOpenChange;
|
|
1095
|
+
const single = props.single,
|
|
1096
|
+
isPopup = props.isPopup,
|
|
1097
|
+
renderItemContent = props.renderItemContent,
|
|
1098
|
+
valueKey = props.valueKey;
|
|
1131
1099
|
const isChecked = value.some(target => target[valueKey] === item[valueKey]);
|
|
1132
1100
|
return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
1133
1101
|
className: classnames__default["default"](style$1['default-list-item'], 'select-tree-item', {
|
|
@@ -1164,26 +1132,20 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1164
1132
|
}, isChecked && /*#__PURE__*/React__default["default"].createElement(icons.CheckOutlined, null)));
|
|
1165
1133
|
},
|
|
1166
1134
|
renderTree: contextProps => {
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
treeData
|
|
1181
|
-
ids
|
|
1182
|
-
} = parseTreeData(data, {
|
|
1183
|
-
valueKey,
|
|
1184
|
-
parentKey,
|
|
1185
|
-
childrenKey
|
|
1186
|
-
});
|
|
1135
|
+
const props = contextProps.props,
|
|
1136
|
+
isSelectedAll = contextProps.isSelectedAll,
|
|
1137
|
+
data = contextProps.data;
|
|
1138
|
+
const renderItem = props.renderItem,
|
|
1139
|
+
valueKey = props.valueKey,
|
|
1140
|
+
labelKey = props.labelKey,
|
|
1141
|
+
childrenKey = props.childrenKey,
|
|
1142
|
+
parentKey = props.parentKey;
|
|
1143
|
+
const _parseTreeData = parseTreeData(data, {
|
|
1144
|
+
valueKey,
|
|
1145
|
+
parentKey,
|
|
1146
|
+
childrenKey
|
|
1147
|
+
}),
|
|
1148
|
+
treeData = _parseTreeData.treeData;
|
|
1187
1149
|
if (!(treeData && treeData.length > 0)) {
|
|
1188
1150
|
return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, null);
|
|
1189
1151
|
}
|
|
@@ -1214,23 +1176,19 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1214
1176
|
return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
|
|
1215
1177
|
ref: ref
|
|
1216
1178
|
}), targetProps => {
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
options,
|
|
1231
|
-
renderTree,
|
|
1232
|
-
selectedAllValue
|
|
1233
|
-
} = props;
|
|
1179
|
+
const props = targetProps.props,
|
|
1180
|
+
value = targetProps.value,
|
|
1181
|
+
onOpenChange = targetProps.onOpenChange;
|
|
1182
|
+
const footer = props.footer,
|
|
1183
|
+
isPopup = props.isPopup,
|
|
1184
|
+
valueKey = props.valueKey,
|
|
1185
|
+
single = props.single,
|
|
1186
|
+
allowSelectedAll = props.allowSelectedAll,
|
|
1187
|
+
showSelectedTag = props.showSelectedTag,
|
|
1188
|
+
api = props.api,
|
|
1189
|
+
options = props.options,
|
|
1190
|
+
renderTree = props.renderTree,
|
|
1191
|
+
selectedAllValue = props.selectedAllValue;
|
|
1234
1192
|
const components = {
|
|
1235
1193
|
selectedAll: /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1236
1194
|
className: classnames__default["default"](style$1['selected-all'], 'select-tree-selected-all', {
|
|
@@ -1242,18 +1200,14 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1242
1200
|
options
|
|
1243
1201
|
},
|
|
1244
1202
|
loader: _ref4 => {
|
|
1245
|
-
let
|
|
1246
|
-
data
|
|
1247
|
-
} = _ref4;
|
|
1203
|
+
let data = _ref4.data;
|
|
1248
1204
|
return data.options;
|
|
1249
1205
|
}
|
|
1250
1206
|
} : api), {
|
|
1251
1207
|
ref: fetchListRef,
|
|
1252
1208
|
render: _ref5 => {
|
|
1253
|
-
let
|
|
1254
|
-
|
|
1255
|
-
...fetchProps
|
|
1256
|
-
} = _ref5;
|
|
1209
|
+
let data = _ref5.data,
|
|
1210
|
+
fetchProps = _objectWithoutPropertiesLoose(_ref5, _excluded2);
|
|
1257
1211
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
1258
1212
|
return /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
|
|
1259
1213
|
className: classnames__default["default"](style$1['list'], 'select-tree-scroll-list', {
|
|
@@ -1495,7 +1449,7 @@ const createTreeUtils = mapping => {
|
|
|
1495
1449
|
};
|
|
1496
1450
|
};
|
|
1497
1451
|
|
|
1498
|
-
var style = {"content":"
|
|
1452
|
+
var style = {"content":"kne-super-select_fHNBt","columns":"kne-super-select_VgpIp","content-item":"kne-super-select_kSkN1","last-level-area":"kne-super-select_1QV-l","is-popup":"kne-super-select_zFwDF","menu":"kne-super-select_s-ON4","scroll-plus-box":"kne-super-select_rIix2","menu-label":"kne-super-select_XAs20","menu-label-text":"kne-super-select_Y8AoQ","menu-item":"kne-super-select_ZwakZ","checkbox-hidden":"kne-super-select_0FUoe","single-mode":"kne-super-select_dahnB","menu-item-icon":"kne-super-select_AZZvN","menu-item-placeholder":"kne-super-select_TudTj","loading":"kne-super-select_ljvZk","search-input":"kne-super-select_FVxuS","list":"kne-super-select_iUhv7","is-selected":"kne-super-select_tx4-l","custom-menu":"kne-super-select_OerpL","selected":"kne-super-select_OUkpN"};
|
|
1499
1453
|
|
|
1500
1454
|
const CustomMenu = ({
|
|
1501
1455
|
className,
|
|
@@ -1526,36 +1480,38 @@ const CustomMenu = ({
|
|
|
1526
1480
|
});
|
|
1527
1481
|
};
|
|
1528
1482
|
|
|
1483
|
+
const _excluded = ["options", "value", "onChange", "defaultValue", "maxLength", "single", "onlyAllowLastLevel", "openLoadData", "onLoadMore", "parentIdKey", "menuItemWidth", "isPopup", "searchPlaceholder", "onSearch", "valueKey", "labelKey", "placeholder", "disabled", "size", "overlayWidth"];
|
|
1529
1484
|
const numberToPx = val => {
|
|
1530
|
-
return typeof val === 'number' ?
|
|
1485
|
+
return typeof val === 'number' ? val + "px" : val;
|
|
1531
1486
|
};
|
|
1532
1487
|
|
|
1533
1488
|
// 级联选择内容组件
|
|
1534
1489
|
const CascaderInner = _ref => {
|
|
1535
|
-
let
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
const
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1490
|
+
let options = _ref.options,
|
|
1491
|
+
value = _ref.value,
|
|
1492
|
+
setValue = _ref.setValue,
|
|
1493
|
+
maxLength = _ref.maxLength,
|
|
1494
|
+
single = _ref.single,
|
|
1495
|
+
onlyAllowLastLevel = _ref.onlyAllowLastLevel,
|
|
1496
|
+
openLoadData = _ref.openLoadData,
|
|
1497
|
+
onLoadMore = _ref.onLoadMore,
|
|
1498
|
+
parentIdKey = _ref.parentIdKey,
|
|
1499
|
+
menuItemWidth = _ref.menuItemWidth,
|
|
1500
|
+
isPopup = _ref.isPopup,
|
|
1501
|
+
searchPlaceholder = _ref.searchPlaceholder,
|
|
1502
|
+
onSearch = _ref.onSearch,
|
|
1503
|
+
valueKey = _ref.valueKey,
|
|
1504
|
+
labelKey = _ref.labelKey,
|
|
1505
|
+
onOpenChange = _ref.onOpenChange,
|
|
1506
|
+
open = _ref.open;
|
|
1507
|
+
const _App$useApp = antd.App.useApp(),
|
|
1508
|
+
message = _App$useApp.message;
|
|
1509
|
+
const _useState = React.useState(''),
|
|
1510
|
+
searchText = _useState[0],
|
|
1511
|
+
setSearchText = _useState[1];
|
|
1512
|
+
const _useState2 = React.useState(false),
|
|
1513
|
+
loading = _useState2[0],
|
|
1514
|
+
setLoading = _useState2[1];
|
|
1559
1515
|
|
|
1560
1516
|
// 构建 mapping
|
|
1561
1517
|
const mapping = React.useMemo(() => {
|
|
@@ -1565,15 +1521,13 @@ const CascaderInner = _ref => {
|
|
|
1565
1521
|
parentId = null;
|
|
1566
1522
|
}
|
|
1567
1523
|
items.forEach(item => {
|
|
1568
|
-
const node = {
|
|
1569
|
-
...item,
|
|
1524
|
+
const node = _extends({}, item, {
|
|
1570
1525
|
id: item[valueKey],
|
|
1571
1526
|
label: item[labelKey],
|
|
1572
1527
|
parentId
|
|
1573
|
-
};
|
|
1528
|
+
});
|
|
1574
1529
|
if (item.children && item.children.length > 0) {
|
|
1575
|
-
node.children = item.children.map(child => ({
|
|
1576
|
-
...child,
|
|
1530
|
+
node.children = item.children.map(child => _extends({}, child, {
|
|
1577
1531
|
id: child[valueKey],
|
|
1578
1532
|
label: child[labelKey],
|
|
1579
1533
|
parentId: node.id
|
|
@@ -1593,23 +1547,25 @@ const CascaderInner = _ref => {
|
|
|
1593
1547
|
}, [mapping]);
|
|
1594
1548
|
|
|
1595
1549
|
// 当前选中的列
|
|
1596
|
-
const
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1550
|
+
const _useState3 = React.useState(() => {
|
|
1551
|
+
const initValue = value.find(item => {
|
|
1552
|
+
const id = typeof item === 'object' ? item[valueKey] : item;
|
|
1553
|
+
return !!mapping.get(id);
|
|
1554
|
+
});
|
|
1555
|
+
if (initValue) {
|
|
1556
|
+
const id = typeof initValue === 'object' ? initValue[valueKey] : initValue;
|
|
1557
|
+
return treeUtils.getSelectedQueue(id);
|
|
1558
|
+
}
|
|
1605
1559
|
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1560
|
+
// 默认选中第一列
|
|
1561
|
+
const firstNode = Array.from(mapping.values()).find(item => isNil__default["default"](item.parentId));
|
|
1562
|
+
if (firstNode) {
|
|
1563
|
+
return treeUtils.getSelectedQueue(firstNode.id);
|
|
1564
|
+
}
|
|
1565
|
+
return [];
|
|
1566
|
+
}),
|
|
1567
|
+
selectedIds = _useState3[0],
|
|
1568
|
+
setSelectedIds = _useState3[1];
|
|
1613
1569
|
|
|
1614
1570
|
// 当 Modal 打开时,根据 value 重新初始化 selectedIds
|
|
1615
1571
|
const prevOpenRef = React.useRef(open);
|
|
@@ -1691,7 +1647,7 @@ const CascaderInner = _ref => {
|
|
|
1691
1647
|
return checked ? treeUtils.setNodeChecked(id, currentIds) : treeUtils.setNodeUnchecked(id, currentIds);
|
|
1692
1648
|
})();
|
|
1693
1649
|
if (newValue.length > maxLength) {
|
|
1694
|
-
message.error(
|
|
1650
|
+
message.error("\u6700\u591A\u53EA\u80FD\u9009\u62E9 " + maxLength + " \u9879");
|
|
1695
1651
|
return;
|
|
1696
1652
|
}
|
|
1697
1653
|
|
|
@@ -1699,11 +1655,10 @@ const CascaderInner = _ref => {
|
|
|
1699
1655
|
const newValues = newValue.map(id => {
|
|
1700
1656
|
const node = mapping.get(id);
|
|
1701
1657
|
// 返回完整的节点数据,保留所有原始字段
|
|
1702
|
-
return node ? {
|
|
1703
|
-
...node,
|
|
1658
|
+
return node ? _extends({}, node, {
|
|
1704
1659
|
[valueKey]: node.id,
|
|
1705
1660
|
[labelKey]: node.label
|
|
1706
|
-
} : null;
|
|
1661
|
+
}) : null;
|
|
1707
1662
|
}).filter(Boolean);
|
|
1708
1663
|
const finalValue = single && newValues.length > 0 ? [last__default["default"](newValues)] : newValues;
|
|
1709
1664
|
setValue(finalValue);
|
|
@@ -1805,7 +1760,7 @@ const CascaderInner = _ref => {
|
|
|
1805
1760
|
}, selectedIds.map((selectedId, index) => {
|
|
1806
1761
|
const selectNode = mapping.get(selectedId);
|
|
1807
1762
|
const siblingNodes = treeUtils.getSiblingNode(selectedId);
|
|
1808
|
-
const isLastLevel = !isNotLastNode(selectNode
|
|
1763
|
+
const isLastLevel = !isNotLastNode(selectNode == null ? void 0 : selectNode.id) && index > 0;
|
|
1809
1764
|
return /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
|
|
1810
1765
|
key: selectedId || index,
|
|
1811
1766
|
className: classnames__default["default"](style['content-item'], {
|
|
@@ -1820,10 +1775,9 @@ const CascaderInner = _ref => {
|
|
|
1820
1775
|
[style['single-mode']]: single
|
|
1821
1776
|
})
|
|
1822
1777
|
}, siblingNodes.map(node => {
|
|
1823
|
-
const
|
|
1824
|
-
checked,
|
|
1825
|
-
indeterminate
|
|
1826
|
-
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
1778
|
+
const _treeUtils$computedCh = treeUtils.computedCheckboxStatus(node.id, currentIds),
|
|
1779
|
+
checked = _treeUtils$computedCh.checked,
|
|
1780
|
+
indeterminate = _treeUtils$computedCh.indeterminate;
|
|
1827
1781
|
return /*#__PURE__*/React__default["default"].createElement(antd.Checkbox, {
|
|
1828
1782
|
key: node.id,
|
|
1829
1783
|
checked: checked,
|
|
@@ -1834,25 +1788,21 @@ const CascaderInner = _ref => {
|
|
|
1834
1788
|
className: style['menu'],
|
|
1835
1789
|
selectedKeys: index === selectedIds.length - 1 ? [] : selectedIds,
|
|
1836
1790
|
onSelect: _ref2 => {
|
|
1837
|
-
let
|
|
1838
|
-
key
|
|
1839
|
-
} = _ref2;
|
|
1791
|
+
let key = _ref2.key;
|
|
1840
1792
|
const node = mapping.get(key);
|
|
1841
1793
|
if (!node) return;
|
|
1842
1794
|
if (isNotLastNode(node.id)) {
|
|
1843
1795
|
setSelectedIds(treeUtils.getSelectedQueue(node.id));
|
|
1844
1796
|
} else {
|
|
1845
|
-
const
|
|
1846
|
-
checked
|
|
1847
|
-
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
1797
|
+
const _treeUtils$computedCh2 = treeUtils.computedCheckboxStatus(node.id, currentIds),
|
|
1798
|
+
checked = _treeUtils$computedCh2.checked;
|
|
1848
1799
|
onCheckedChange(!checked, node.id);
|
|
1849
1800
|
}
|
|
1850
1801
|
},
|
|
1851
1802
|
items: siblingNodes.map(node => {
|
|
1852
|
-
const
|
|
1853
|
-
checked,
|
|
1854
|
-
indeterminate
|
|
1855
|
-
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
1803
|
+
const _treeUtils$computedCh3 = treeUtils.computedCheckboxStatus(node.id, currentIds),
|
|
1804
|
+
checked = _treeUtils$computedCh3.checked,
|
|
1805
|
+
indeterminate = _treeUtils$computedCh3.indeterminate;
|
|
1856
1806
|
const hasChildren = isNotLastNode(node.id);
|
|
1857
1807
|
|
|
1858
1808
|
// 计算子级选中数量
|
|
@@ -1896,32 +1846,45 @@ const CascaderInner = _ref => {
|
|
|
1896
1846
|
|
|
1897
1847
|
// 主组件
|
|
1898
1848
|
const SelectCascader = _ref3 => {
|
|
1899
|
-
let
|
|
1900
|
-
options = [],
|
|
1901
|
-
value,
|
|
1902
|
-
onChange,
|
|
1903
|
-
defaultValue,
|
|
1904
|
-
maxLength =
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1849
|
+
let _ref3$options = _ref3.options,
|
|
1850
|
+
options = _ref3$options === void 0 ? [] : _ref3$options,
|
|
1851
|
+
value = _ref3.value,
|
|
1852
|
+
onChange = _ref3.onChange,
|
|
1853
|
+
defaultValue = _ref3.defaultValue,
|
|
1854
|
+
_ref3$maxLength = _ref3.maxLength,
|
|
1855
|
+
maxLength = _ref3$maxLength === void 0 ? Number.MAX_VALUE : _ref3$maxLength,
|
|
1856
|
+
_ref3$single = _ref3.single,
|
|
1857
|
+
single = _ref3$single === void 0 ? false : _ref3$single,
|
|
1858
|
+
_ref3$onlyAllowLastLe = _ref3.onlyAllowLastLevel,
|
|
1859
|
+
onlyAllowLastLevel = _ref3$onlyAllowLastLe === void 0 ? false : _ref3$onlyAllowLastLe,
|
|
1860
|
+
_ref3$openLoadData = _ref3.openLoadData,
|
|
1861
|
+
openLoadData = _ref3$openLoadData === void 0 ? false : _ref3$openLoadData,
|
|
1862
|
+
onLoadMore = _ref3.onLoadMore,
|
|
1863
|
+
_ref3$parentIdKey = _ref3.parentIdKey,
|
|
1864
|
+
parentIdKey = _ref3$parentIdKey === void 0 ? 'id' : _ref3$parentIdKey,
|
|
1865
|
+
_ref3$menuItemWidth = _ref3.menuItemWidth,
|
|
1866
|
+
menuItemWidth = _ref3$menuItemWidth === void 0 ? 180 : _ref3$menuItemWidth,
|
|
1867
|
+
_ref3$isPopup = _ref3.isPopup,
|
|
1868
|
+
isPopup = _ref3$isPopup === void 0 ? true : _ref3$isPopup,
|
|
1869
|
+
searchPlaceholder = _ref3.searchPlaceholder,
|
|
1870
|
+
onSearch = _ref3.onSearch,
|
|
1871
|
+
_ref3$valueKey = _ref3.valueKey,
|
|
1872
|
+
valueKey = _ref3$valueKey === void 0 ? 'id' : _ref3$valueKey,
|
|
1873
|
+
_ref3$labelKey = _ref3.labelKey,
|
|
1874
|
+
labelKey = _ref3$labelKey === void 0 ? 'label' : _ref3$labelKey,
|
|
1875
|
+
_ref3$placeholder = _ref3.placeholder,
|
|
1876
|
+
placeholder = _ref3$placeholder === void 0 ? '请选择' : _ref3$placeholder,
|
|
1877
|
+
_ref3$disabled = _ref3.disabled,
|
|
1878
|
+
disabled = _ref3$disabled === void 0 ? false : _ref3$disabled,
|
|
1879
|
+
_ref3$size = _ref3.size,
|
|
1880
|
+
size = _ref3$size === void 0 ? 'default' : _ref3$size,
|
|
1881
|
+
overlayWidth = _ref3.overlayWidth,
|
|
1882
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
1922
1883
|
// 内部始终使用数组格式处理
|
|
1923
1884
|
// SelectInput 会处理 single 模式的 value 和 onChange 转换
|
|
1924
|
-
const
|
|
1885
|
+
const _useState4 = React.useState(Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : []),
|
|
1886
|
+
innerValue = _useState4[0],
|
|
1887
|
+
setInnerValue = _useState4[1];
|
|
1925
1888
|
|
|
1926
1889
|
// currentValue 用于内部处理,始终是数组
|
|
1927
1890
|
const currentValue = React.useMemo(() => {
|
|
@@ -1951,10 +1914,10 @@ const SelectCascader = _ref3 => {
|
|
|
1951
1914
|
// 根据单选/多选模式转换输出格式
|
|
1952
1915
|
if (single) {
|
|
1953
1916
|
// 单选:返回单个对象或 null
|
|
1954
|
-
onChange
|
|
1917
|
+
onChange == null || onChange(normalizedValue.length > 0 ? normalizedValue[0] : null);
|
|
1955
1918
|
} else {
|
|
1956
1919
|
// 多选:返回数组
|
|
1957
|
-
onChange
|
|
1920
|
+
onChange == null || onChange(normalizedValue);
|
|
1958
1921
|
}
|
|
1959
1922
|
}, [value, onChange, single]);
|
|
1960
1923
|
|
|
@@ -1976,11 +1939,10 @@ const SelectCascader = _ref3 => {
|
|
|
1976
1939
|
if (typeof item === 'object') {
|
|
1977
1940
|
// 优先使用 item[labelKey],然后是 item.label,最后是 item.name
|
|
1978
1941
|
const label = item[labelKey] || item.label || item.name || String(item[valueKey] || '');
|
|
1979
|
-
return {
|
|
1980
|
-
...item,
|
|
1942
|
+
return _extends({}, item, {
|
|
1981
1943
|
[valueKey]: item[valueKey] || item.id,
|
|
1982
1944
|
[labelKey]: label
|
|
1983
|
-
};
|
|
1945
|
+
});
|
|
1984
1946
|
}
|
|
1985
1947
|
// 如果是值,从 options 中查找
|
|
1986
1948
|
const findLabel = items => {
|
|
@@ -2026,11 +1988,10 @@ const SelectCascader = _ref3 => {
|
|
|
2026
1988
|
// 如果已经是对象,确保有标准化的字段
|
|
2027
1989
|
if (typeof item === 'object') {
|
|
2028
1990
|
const label = item[labelKey] || item.label || item.name || String(item[valueKey] || '');
|
|
2029
|
-
return {
|
|
2030
|
-
...item,
|
|
1991
|
+
return _extends({}, item, {
|
|
2031
1992
|
[valueKey]: item[valueKey] || item.id,
|
|
2032
1993
|
[labelKey]: label
|
|
2033
|
-
};
|
|
1994
|
+
});
|
|
2034
1995
|
}
|
|
2035
1996
|
// 如果是值,从 options 中查找
|
|
2036
1997
|
const findLabel = items => {
|