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