@kne/super-select 0.1.46 → 0.1.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -2
- package/dist/index.css +34 -10
- package/dist/index.css.map +1 -1
- package/dist/index.js +603 -527
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +110 -91
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -18,8 +18,9 @@ var SimpleBar = require('simplebar-react');
|
|
|
18
18
|
var SearchInput = require('@kne/search-input');
|
|
19
19
|
var scrollLoader = require('@kne/scroll-loader');
|
|
20
20
|
require('@kne/scroll-loader/dist/index.css');
|
|
21
|
-
var
|
|
22
|
-
require('@kne/table-
|
|
21
|
+
var merge = require('lodash/merge');
|
|
22
|
+
var TablePage = require('@kne/table-page');
|
|
23
|
+
require('@kne/table-page/dist/index.css');
|
|
23
24
|
var infoPage = require('@kne/info-page');
|
|
24
25
|
require('@kne/info-page/dist/index.css');
|
|
25
26
|
var memoize = require('lodash/memoize');
|
|
@@ -37,7 +38,8 @@ var last__default = /*#__PURE__*/_interopDefaultLegacy(last);
|
|
|
37
38
|
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
38
39
|
var SimpleBar__default = /*#__PURE__*/_interopDefaultLegacy(SimpleBar);
|
|
39
40
|
var SearchInput__default = /*#__PURE__*/_interopDefaultLegacy(SearchInput);
|
|
40
|
-
var
|
|
41
|
+
var merge__default = /*#__PURE__*/_interopDefaultLegacy(merge);
|
|
42
|
+
var TablePage__default = /*#__PURE__*/_interopDefaultLegacy(TablePage);
|
|
41
43
|
var memoize__default = /*#__PURE__*/_interopDefaultLegacy(memoize);
|
|
42
44
|
var isNil__default = /*#__PURE__*/_interopDefaultLegacy(isNil);
|
|
43
45
|
var Fetch__default = /*#__PURE__*/_interopDefaultLegacy(Fetch);
|
|
@@ -51,15 +53,6 @@ function _extends() {
|
|
|
51
53
|
return n;
|
|
52
54
|
}, _extends.apply(null, arguments);
|
|
53
55
|
}
|
|
54
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
55
|
-
if (null == r) return {};
|
|
56
|
-
var t = {};
|
|
57
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
58
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
59
|
-
t[n] = r[n];
|
|
60
|
-
}
|
|
61
|
-
return t;
|
|
62
|
-
}
|
|
63
56
|
|
|
64
57
|
const context = globalContext.createContext();
|
|
65
58
|
const {
|
|
@@ -195,7 +188,6 @@ const TagOverflowInner = ({
|
|
|
195
188
|
}, "+", hiddenCount) : null));
|
|
196
189
|
};
|
|
197
190
|
|
|
198
|
-
const _excluded$3 = ["children"];
|
|
199
191
|
const MOBILE_SHEET_MAX_HEIGHT = '80%';
|
|
200
192
|
const MOBILE_SHEET_MIN_HEIGHT = '30%';
|
|
201
193
|
const MOBILE_MASK_Z_INDEX = 1000;
|
|
@@ -235,8 +227,10 @@ const lockParentScroll = getScrollElements => {
|
|
|
235
227
|
parentScrollLockCount = Math.max(0, parentScrollLockCount - 1);
|
|
236
228
|
if (parentScrollLockCount === 0) {
|
|
237
229
|
parentScrollLocked.forEach(_ref => {
|
|
238
|
-
let
|
|
239
|
-
|
|
230
|
+
let {
|
|
231
|
+
el,
|
|
232
|
+
prev
|
|
233
|
+
} = _ref;
|
|
240
234
|
el.style.overflow = prev.overflow;
|
|
241
235
|
el.style.overscrollBehavior = prev.overscrollBehavior;
|
|
242
236
|
});
|
|
@@ -253,7 +247,7 @@ const useLockParentScroll = (enabled, getScrollElements) => {
|
|
|
253
247
|
}, [enabled, getScrollElements]);
|
|
254
248
|
};
|
|
255
249
|
const numberToPx$1 = val => {
|
|
256
|
-
return typeof val === 'number' ? val
|
|
250
|
+
return typeof val === 'number' ? `${val}px` : val;
|
|
257
251
|
};
|
|
258
252
|
const pxToNumber = value => {
|
|
259
253
|
if (!value) return 0;
|
|
@@ -269,13 +263,15 @@ const DEFAULT_OVERLAY_MIN_WIDTH = 300;
|
|
|
269
263
|
|
|
270
264
|
// 与 Modal 模式一致:面板内用临时 value,确认后才写回
|
|
271
265
|
const ModalContent = _ref2 => {
|
|
272
|
-
let
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
266
|
+
let {
|
|
267
|
+
children: renderContent,
|
|
268
|
+
...others
|
|
269
|
+
} = _ref2;
|
|
270
|
+
const {
|
|
271
|
+
open,
|
|
272
|
+
value: propsValue
|
|
273
|
+
} = others;
|
|
274
|
+
const [value, setValue] = React.useState(propsValue);
|
|
279
275
|
React.useEffect(() => {
|
|
280
276
|
if (open && !isEqual__default["default"](value, propsValue)) {
|
|
281
277
|
setValue(propsValue);
|
|
@@ -291,8 +287,7 @@ const ModalContent = _ref2 => {
|
|
|
291
287
|
onSelect: item => others.onSelect(item, setValue),
|
|
292
288
|
onRemove: item => others.onRemove(item, setValue),
|
|
293
289
|
onOpenChange: nextOpen => {
|
|
294
|
-
|
|
295
|
-
if (nextOpen || ((_others$props = others.props) == null ? void 0 : _others$props.isPopup) === false) {
|
|
290
|
+
if (nextOpen || others.props?.isPopup === false) {
|
|
296
291
|
others.onOpenChange && others.onOpenChange(!!nextOpen);
|
|
297
292
|
}
|
|
298
293
|
}
|
|
@@ -302,16 +297,14 @@ const ModalContent = _ref2 => {
|
|
|
302
297
|
}, renderContent(contextProps));
|
|
303
298
|
};
|
|
304
299
|
const MobileSheetMask = _ref3 => {
|
|
305
|
-
let
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const
|
|
313
|
-
maskClosing = _useState3[0],
|
|
314
|
-
setMaskClosing = _useState3[1];
|
|
300
|
+
let {
|
|
301
|
+
open,
|
|
302
|
+
mountNode,
|
|
303
|
+
fixedModeClass,
|
|
304
|
+
onClose
|
|
305
|
+
} = _ref3;
|
|
306
|
+
const [renderMask, setRenderMask] = React.useState(false);
|
|
307
|
+
const [maskClosing, setMaskClosing] = React.useState(false);
|
|
315
308
|
React.useEffect(() => {
|
|
316
309
|
if (open) {
|
|
317
310
|
setRenderMask(true);
|
|
@@ -343,11 +336,13 @@ const MobileSheetMask = _ref3 => {
|
|
|
343
336
|
}), mountNode);
|
|
344
337
|
};
|
|
345
338
|
const MobileSheetHeader = _ref4 => {
|
|
346
|
-
let
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
339
|
+
let {
|
|
340
|
+
title,
|
|
341
|
+
cancelText,
|
|
342
|
+
confirmText,
|
|
343
|
+
onCancel,
|
|
344
|
+
onConfirm
|
|
345
|
+
} = _ref4;
|
|
351
346
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
352
347
|
className: style$6['mobile-sheet-header']
|
|
353
348
|
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
@@ -364,16 +359,18 @@ const MobileSheetHeader = _ref4 => {
|
|
|
364
359
|
}, confirmText));
|
|
365
360
|
};
|
|
366
361
|
const MobileSheetPanel = _ref5 => {
|
|
367
|
-
let
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
362
|
+
let {
|
|
363
|
+
open,
|
|
364
|
+
mountNode,
|
|
365
|
+
fixedModeClass,
|
|
366
|
+
overlayClassName,
|
|
367
|
+
title,
|
|
368
|
+
cancelText,
|
|
369
|
+
confirmText,
|
|
370
|
+
onCancel,
|
|
371
|
+
onConfirm,
|
|
372
|
+
children
|
|
373
|
+
} = _ref5;
|
|
377
374
|
if (!open || !mountNode) {
|
|
378
375
|
return null;
|
|
379
376
|
}
|
|
@@ -413,7 +410,9 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
413
410
|
}
|
|
414
411
|
})(React.forwardRef((p, ref) => {
|
|
415
412
|
const intl = reactIntl.useIntl();
|
|
416
|
-
const
|
|
413
|
+
const {
|
|
414
|
+
formatMessage
|
|
415
|
+
} = intl;
|
|
417
416
|
const props = Object.assign({}, {
|
|
418
417
|
children: () => formatMessage({
|
|
419
418
|
id: 'defaultChildren'
|
|
@@ -449,18 +448,22 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
449
448
|
size: 'default',
|
|
450
449
|
disableMobileSheet: false,
|
|
451
450
|
renderModal: contextProps => {
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
451
|
+
const {
|
|
452
|
+
props,
|
|
453
|
+
open,
|
|
454
|
+
onComplete,
|
|
455
|
+
onOpenChange,
|
|
456
|
+
isMobile,
|
|
457
|
+
getPopupContainer,
|
|
458
|
+
formatMessage,
|
|
459
|
+
fixedModeClass
|
|
460
|
+
} = contextProps;
|
|
461
|
+
const {
|
|
462
|
+
placeholder,
|
|
463
|
+
children,
|
|
464
|
+
overlayClassName,
|
|
465
|
+
disableMobileSheet
|
|
466
|
+
} = props;
|
|
464
467
|
if (isMobile && !disableMobileSheet) {
|
|
465
468
|
const mountNode = typeof getPopupContainer === 'function' ? getPopupContainer() : null;
|
|
466
469
|
const closeWithoutCommit = () => onOpenChange(false);
|
|
@@ -509,32 +512,34 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
509
512
|
[props.valueKey]: props.selectedAllValue.value,
|
|
510
513
|
[props.labelKey]: props.selectedAllValue.label
|
|
511
514
|
};
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
515
|
+
const {
|
|
516
|
+
children,
|
|
517
|
+
prefix,
|
|
518
|
+
suffix,
|
|
519
|
+
className,
|
|
520
|
+
maxLength,
|
|
521
|
+
overlayClassName,
|
|
522
|
+
overlayStyle,
|
|
523
|
+
getPopupContainer: getPopupContainerProp,
|
|
524
|
+
zIndex,
|
|
525
|
+
align,
|
|
526
|
+
autoAdjustOverflow,
|
|
527
|
+
transitionName,
|
|
528
|
+
single,
|
|
529
|
+
labelWrap,
|
|
530
|
+
isPopup,
|
|
531
|
+
allowClear,
|
|
532
|
+
disabled,
|
|
533
|
+
placeholder,
|
|
534
|
+
selectedAllValue,
|
|
535
|
+
overlayWidth,
|
|
536
|
+
placement,
|
|
537
|
+
renderModal,
|
|
538
|
+
labelKey,
|
|
539
|
+
valueKey,
|
|
540
|
+
size,
|
|
541
|
+
disableMobileSheet
|
|
542
|
+
} = props;
|
|
538
543
|
const getPopupContainerDefault = responsiveUtils.usePopupContainer();
|
|
539
544
|
const getScrollElement = responsiveUtils.useScrollElement();
|
|
540
545
|
const wrapCustomGetPopupContainer = React.useMemo(() => {
|
|
@@ -546,14 +551,15 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
546
551
|
}
|
|
547
552
|
return undefined;
|
|
548
553
|
}, [getPopupContainerProp]);
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
554
|
+
const {
|
|
555
|
+
isMobile,
|
|
556
|
+
fixedModeClass,
|
|
557
|
+
getPopupContainer: getSheetPopupContainer,
|
|
558
|
+
anchorRef
|
|
559
|
+
} = responsiveUtils.useMobilePopupMount({
|
|
560
|
+
cover: 'viewport',
|
|
561
|
+
getPopupContainer: wrapCustomGetPopupContainer
|
|
562
|
+
});
|
|
557
563
|
const useMobileSheet = isMobile && !disableMobileSheet;
|
|
558
564
|
const useBoundaryMount = !!(isMobile && fixedModeClass === responsiveUtils.MOBILE_POPUP_MODE.boundary);
|
|
559
565
|
const transformValue = value => {
|
|
@@ -563,39 +569,25 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
563
569
|
return Array.isArray(value) ? value : [];
|
|
564
570
|
}
|
|
565
571
|
};
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
open = _useControlValue2[0],
|
|
586
|
-
setOpen = _useControlValue2[1];
|
|
587
|
-
const _useState5 = React.useState(false),
|
|
588
|
-
hover = _useState5[0],
|
|
589
|
-
setHover = _useState5[1];
|
|
590
|
-
const _useState6 = React.useState(0),
|
|
591
|
-
innerWidth = _useState6[0],
|
|
592
|
-
setInnerWidth = _useState6[1];
|
|
593
|
-
const _useState7 = React.useState(0),
|
|
594
|
-
containerWidth = _useState7[0],
|
|
595
|
-
setContainerWidth = _useState7[1];
|
|
596
|
-
const _useState8 = React.useState(null),
|
|
597
|
-
popupMountNode = _useState8[0],
|
|
598
|
-
setPopupMountNode = _useState8[1];
|
|
572
|
+
const [value, setValue] = useControlValue__default["default"](Object.assign({}, props, {
|
|
573
|
+
onChange: value => {
|
|
574
|
+
props.onChange && props.onChange(props.single ? last__default["default"](value) : value);
|
|
575
|
+
}
|
|
576
|
+
}, 'value' in props ? {
|
|
577
|
+
value: transformValue(props.value)
|
|
578
|
+
} : {
|
|
579
|
+
defaultValue: transformValue(props.defaultValue)
|
|
580
|
+
}));
|
|
581
|
+
const [searchProps, setSearchProps] = React.useState({});
|
|
582
|
+
const [open, setOpen] = useControlValue__default["default"](props, {
|
|
583
|
+
defaultValue: 'defaultOpen',
|
|
584
|
+
value: 'open',
|
|
585
|
+
onChange: 'onOpenChange'
|
|
586
|
+
});
|
|
587
|
+
const [hover, setHover] = React.useState(false);
|
|
588
|
+
const [innerWidth, setInnerWidth] = React.useState(0);
|
|
589
|
+
const [containerWidth, setContainerWidth] = React.useState(0);
|
|
590
|
+
const [popupMountNode, setPopupMountNode] = React.useState(null);
|
|
599
591
|
const containerWidthChange = el => {
|
|
600
592
|
if (!el) {
|
|
601
593
|
return;
|
|
@@ -661,8 +653,9 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
661
653
|
}, [getScrollElement, popupMountNode]);
|
|
662
654
|
const sheetOpen = !disabled && open;
|
|
663
655
|
useLockParentScroll(useMobileSheet && sheetOpen, getLockScrollTargets);
|
|
664
|
-
const
|
|
665
|
-
message
|
|
656
|
+
const {
|
|
657
|
+
message
|
|
658
|
+
} = antd.App.useApp();
|
|
666
659
|
const checkMaxLength = (value, maxLength) => {
|
|
667
660
|
if (Number.isInteger(maxLength) && maxLength > 0 && value.length >= maxLength) {
|
|
668
661
|
message.error(formatMessage({
|
|
@@ -827,7 +820,9 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
827
820
|
}
|
|
828
821
|
}
|
|
829
822
|
}), /*#__PURE__*/React__default["default"].createElement(ModalContent, contextProps, sheetContextProps => {
|
|
830
|
-
const
|
|
823
|
+
const {
|
|
824
|
+
onComplete
|
|
825
|
+
} = sheetContextProps;
|
|
831
826
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(MobileSheetMask, {
|
|
832
827
|
open: sheetOpen,
|
|
833
828
|
mountNode: popupMountNode,
|
|
@@ -890,22 +885,25 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
890
885
|
var style$5 = {"selected-all":"kne-super-select_prlgN"};
|
|
891
886
|
|
|
892
887
|
const SelectedAll = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
|
|
893
|
-
const
|
|
894
|
-
formatMessage
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
unit
|
|
907
|
-
|
|
908
|
-
|
|
888
|
+
const {
|
|
889
|
+
formatMessage
|
|
890
|
+
} = reactIntl.useIntl();
|
|
891
|
+
const {
|
|
892
|
+
props,
|
|
893
|
+
value,
|
|
894
|
+
setValue
|
|
895
|
+
} = useContext();
|
|
896
|
+
const {
|
|
897
|
+
unit,
|
|
898
|
+
selectedAllValue,
|
|
899
|
+
valueKey
|
|
900
|
+
} = Object.assign({}, {
|
|
901
|
+
unit: number => formatMessage({
|
|
902
|
+
id: 'numberOf'
|
|
903
|
+
}, {
|
|
904
|
+
number
|
|
905
|
+
})
|
|
906
|
+
}, props);
|
|
909
907
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
910
908
|
return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
911
909
|
justify: "space-between",
|
|
@@ -932,23 +930,26 @@ const computedIsSelectAll = function (value, selectedAllValue, valueKey) {
|
|
|
932
930
|
if (valueKey === void 0) {
|
|
933
931
|
valueKey = 'value';
|
|
934
932
|
}
|
|
935
|
-
return
|
|
933
|
+
return value?.length === 1 && get__default["default"](value, `[0][${valueKey}]`) === selectedAllValue[valueKey];
|
|
936
934
|
};
|
|
937
935
|
|
|
938
936
|
var style$4 = {"label":"kne-super-select_l3KoW","tag-list":"kne-super-select_CCPzb","tag-container":"kne-super-select_dKZHi","tag-container-inner":"kne-super-select_oijCI","tag":"kne-super-select_WmnnS","tag-inner":"kne-super-select_TMcFl"};
|
|
939
937
|
|
|
940
938
|
const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
|
|
941
|
-
const
|
|
942
|
-
formatMessage
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
939
|
+
const {
|
|
940
|
+
formatMessage
|
|
941
|
+
} = reactIntl.useIntl();
|
|
942
|
+
const {
|
|
943
|
+
props,
|
|
944
|
+
value,
|
|
945
|
+
onRemove
|
|
946
|
+
} = useContext();
|
|
947
|
+
const {
|
|
948
|
+
single,
|
|
949
|
+
maxLength,
|
|
950
|
+
labelKey,
|
|
951
|
+
valueKey
|
|
952
|
+
} = Object.assign({}, props);
|
|
952
953
|
return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
953
954
|
className: classnames__default["default"](style$4['tag-list'], 'selected-tag-list'),
|
|
954
955
|
gap: 8
|
|
@@ -956,7 +957,7 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
956
957
|
className: style$4['label']
|
|
957
958
|
}, formatMessage({
|
|
958
959
|
id: 'selected'
|
|
959
|
-
}), !single && value.length > 0 &&
|
|
960
|
+
}), !single && value.length > 0 && `(${value.length}${Number.isInteger(maxLength) ? `/${maxLength}` : ''})`, ":"), /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
|
|
960
961
|
className: style$4['tag-container']
|
|
961
962
|
}, /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
962
963
|
gap: 8,
|
|
@@ -980,16 +981,21 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
980
981
|
|
|
981
982
|
var style$3 = {"kne-responsive-boundary":"kne-super-select_Nc-y4","kne-responsive-scroll":"kne-super-select_RlrDm","list":"kne-super-select_IsXdU","empty":"kne-super-select_SQZ8k","default-list":"kne-super-select_QD1Mz","is-selected-all":"kne-super-select_M-mOy","default-list-item":"kne-super-select_KtOsz","is-selected":"kne-super-select_TQhBB","single-checked":"kne-super-select_2rUrh","is-disabled":"kne-super-select_NbwX5","selected-all":"kne-super-select_vN2Fx","selected-tag":"kne-super-select_6oITk","select-search":"kne-super-select_iAH9D","select-list-item-description":"kne-super-select_TCkeJ","footer":"kne-super-select_v3f23","is-mobile":"kne-super-select_w-WB8"};
|
|
982
983
|
|
|
983
|
-
const _excluded$2 = ["children"];
|
|
984
984
|
const SelectList = React.forwardRef((_ref, ref) => {
|
|
985
|
-
let
|
|
986
|
-
|
|
985
|
+
let {
|
|
986
|
+
children,
|
|
987
|
+
...p
|
|
988
|
+
} = _ref;
|
|
987
989
|
const fetchListRef = React.useRef(null);
|
|
988
990
|
const props = Object.assign({}, {
|
|
989
991
|
renderItemContent: _ref2 => {
|
|
990
|
-
let
|
|
991
|
-
|
|
992
|
-
|
|
992
|
+
let {
|
|
993
|
+
item,
|
|
994
|
+
props
|
|
995
|
+
} = _ref2;
|
|
996
|
+
const {
|
|
997
|
+
labelKey
|
|
998
|
+
} = props;
|
|
993
999
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
994
1000
|
className: 'select-list-item-label'
|
|
995
1001
|
}, item[labelKey]), item.description && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -997,17 +1003,21 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
997
1003
|
}, item.description));
|
|
998
1004
|
},
|
|
999
1005
|
renderItem: contextProps => {
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1006
|
+
const {
|
|
1007
|
+
item,
|
|
1008
|
+
props,
|
|
1009
|
+
isSelectedAll,
|
|
1010
|
+
value,
|
|
1011
|
+
onSelect,
|
|
1012
|
+
setValue,
|
|
1013
|
+
onOpenChange
|
|
1014
|
+
} = contextProps;
|
|
1015
|
+
const {
|
|
1016
|
+
single,
|
|
1017
|
+
isPopup,
|
|
1018
|
+
renderItemContent,
|
|
1019
|
+
valueKey
|
|
1020
|
+
} = props;
|
|
1011
1021
|
const isChecked = value.some(target => target[valueKey] === item[valueKey]);
|
|
1012
1022
|
return /*#__PURE__*/React__default["default"].createElement(antd.List.Item, {
|
|
1013
1023
|
className: classnames__default["default"](style$3['default-list-item'], 'select-list-item', {
|
|
@@ -1045,10 +1055,14 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1045
1055
|
}, isChecked && /*#__PURE__*/React__default["default"].createElement(icons.CheckOutlined, null)));
|
|
1046
1056
|
},
|
|
1047
1057
|
renderList: contextProps => {
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1058
|
+
const {
|
|
1059
|
+
props,
|
|
1060
|
+
isSelectedAll,
|
|
1061
|
+
list
|
|
1062
|
+
} = contextProps;
|
|
1063
|
+
const {
|
|
1064
|
+
renderItem
|
|
1065
|
+
} = props;
|
|
1052
1066
|
if (!(list && list.length > 0)) {
|
|
1053
1067
|
return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, {
|
|
1054
1068
|
className: style$3['empty']
|
|
@@ -1069,26 +1083,30 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1069
1083
|
return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
|
|
1070
1084
|
ref: ref
|
|
1071
1085
|
}), targetProps => {
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1086
|
+
const {
|
|
1087
|
+
props,
|
|
1088
|
+
value,
|
|
1089
|
+
searchProps,
|
|
1090
|
+
setSearchProps,
|
|
1091
|
+
onOpenChange,
|
|
1092
|
+
isMobile,
|
|
1093
|
+
open
|
|
1094
|
+
} = targetProps;
|
|
1095
|
+
const {
|
|
1096
|
+
footer,
|
|
1097
|
+
isPopup,
|
|
1098
|
+
getSearchProps,
|
|
1099
|
+
getSearchCallback,
|
|
1100
|
+
searchPlaceholder,
|
|
1101
|
+
valueKey,
|
|
1102
|
+
single,
|
|
1103
|
+
allowSelectedAll,
|
|
1104
|
+
showSelectedTag,
|
|
1105
|
+
api,
|
|
1106
|
+
options,
|
|
1107
|
+
renderList,
|
|
1108
|
+
selectedAllValue
|
|
1109
|
+
} = props;
|
|
1092
1110
|
const components = {
|
|
1093
1111
|
search: (api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function') && /*#__PURE__*/React__default["default"].createElement(SearchInput__default["default"], {
|
|
1094
1112
|
className: classnames__default["default"](style$3['select-search'], 'select-list-search', {
|
|
@@ -1122,9 +1140,13 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1122
1140
|
searchProps
|
|
1123
1141
|
},
|
|
1124
1142
|
loader: _ref3 => {
|
|
1125
|
-
let
|
|
1126
|
-
|
|
1127
|
-
|
|
1143
|
+
let {
|
|
1144
|
+
data
|
|
1145
|
+
} = _ref3;
|
|
1146
|
+
const {
|
|
1147
|
+
options,
|
|
1148
|
+
searchProps
|
|
1149
|
+
} = data;
|
|
1128
1150
|
if (typeof getSearchCallback === 'function') {
|
|
1129
1151
|
const newOptions = options.filter(item => getSearchCallback(searchProps, item));
|
|
1130
1152
|
return {
|
|
@@ -1173,33 +1195,37 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1173
1195
|
});
|
|
1174
1196
|
});
|
|
1175
1197
|
|
|
1176
|
-
var style$2 = {"body":"kne-super-select_704J1","is-mobile":"kne-super-select_HYGUN","table-panel-wrap":"kne-super-select_Boo1a","selected-panel-wrap":"kne-super-select_q-BjK","table-panel":"kne-super-select_UAejp","filter-wrap":"kne-super-select_gmlBv","table":"kne-super-select_zE-14","list":"kne-super-select_DrEYJ","is-
|
|
1198
|
+
var style$2 = {"body":"kne-super-select_704J1","is-mobile":"kne-super-select_HYGUN","table-panel-wrap":"kne-super-select_Boo1a","selected-panel-wrap":"kne-super-select_q-BjK","table-panel":"kne-super-select_UAejp","filter-wrap":"kne-super-select_gmlBv","table":"kne-super-select_zE-14","list":"kne-super-select_DrEYJ","is-fit-columns":"kne-super-select_QqZxW","empty":"kne-super-select_5Tyrt","right-options-col":"kne-super-select_sNBrJ","right-options":"kne-super-select_UXi-g","no-padding-btn":"kne-super-select_iaCir","selected-tags-scroll":"kne-super-select_b-3Xk","tag":"kne-super-select_JkYqS","tag-inner":"kne-super-select_VZlBL","single-checked":"kne-super-select_Eiz-u","select-search":"kne-super-select_temy6","tags-search":"kne-super-select_7phL2","descriptions":"kne-super-select_ttNK9","footer":"kne-super-select_lISfA"};
|
|
1177
1199
|
|
|
1178
1200
|
const isEmptyParentKey = value => value == null || value === '';
|
|
1179
1201
|
const flattenSelectList = (list, _ref) => {
|
|
1180
|
-
let
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1202
|
+
let {
|
|
1203
|
+
dataType,
|
|
1204
|
+
rowKey,
|
|
1205
|
+
parentKey,
|
|
1206
|
+
childrenKey
|
|
1207
|
+
} = _ref;
|
|
1208
|
+
if (!list || !TablePage.isTreeDataType(dataType)) {
|
|
1185
1209
|
return list || [];
|
|
1186
1210
|
}
|
|
1187
|
-
const tree =
|
|
1211
|
+
const tree = TablePage.normalizeTreeData(list, {
|
|
1188
1212
|
dataType,
|
|
1189
1213
|
rowKey,
|
|
1190
1214
|
parentKey,
|
|
1191
1215
|
childrenKey
|
|
1192
1216
|
});
|
|
1193
|
-
return
|
|
1217
|
+
return TablePage.flattenAllTree(tree, {
|
|
1194
1218
|
rowKey,
|
|
1195
1219
|
childrenKey
|
|
1196
1220
|
}).map(row => row.item);
|
|
1197
1221
|
};
|
|
1198
1222
|
const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps, _ref2) => {
|
|
1199
|
-
let
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1223
|
+
let {
|
|
1224
|
+
dataType,
|
|
1225
|
+
valueKey,
|
|
1226
|
+
parentKey,
|
|
1227
|
+
childrenKey
|
|
1228
|
+
} = _ref2;
|
|
1203
1229
|
if (typeof getSearchCallback !== 'function') {
|
|
1204
1230
|
return options;
|
|
1205
1231
|
}
|
|
@@ -1241,13 +1267,25 @@ const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps,
|
|
|
1241
1267
|
}
|
|
1242
1268
|
return options.filter(item => getSearchCallback(searchProps, item, targetProps));
|
|
1243
1269
|
};
|
|
1270
|
+
const getListFromPageData = data => {
|
|
1271
|
+
if (Array.isArray(data?.pageData)) {
|
|
1272
|
+
return data.pageData;
|
|
1273
|
+
}
|
|
1274
|
+
if (Array.isArray(data?.list)) {
|
|
1275
|
+
return data.list;
|
|
1276
|
+
}
|
|
1277
|
+
return [];
|
|
1278
|
+
};
|
|
1279
|
+
const TABLE_LIST_MAX_HEIGHT_POPUP = 300;
|
|
1280
|
+
const TABLE_LIST_MAX_HEIGHT_EMBED = 400;
|
|
1281
|
+
const TABLE_HEADER_HEIGHT = 48;
|
|
1244
1282
|
const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(React.forwardRef((p, ref) => {
|
|
1245
|
-
const
|
|
1246
|
-
formatMessage
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
const
|
|
1283
|
+
const {
|
|
1284
|
+
formatMessage
|
|
1285
|
+
} = reactIntl.useIntl();
|
|
1286
|
+
const [tagSearchText, setTagSearchText] = React.useState('');
|
|
1287
|
+
const tablePageRef = React.useRef();
|
|
1288
|
+
const listScrollRef = React.useRef();
|
|
1251
1289
|
const props = Object.assign({}, {
|
|
1252
1290
|
overlayWidth: '600px',
|
|
1253
1291
|
dataType: 'list',
|
|
@@ -1255,15 +1293,19 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1255
1293
|
childrenKey: 'children',
|
|
1256
1294
|
hasChildrenKey: 'hasChildren',
|
|
1257
1295
|
filterRender: contextProps => {
|
|
1258
|
-
const
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1296
|
+
const {
|
|
1297
|
+
props,
|
|
1298
|
+
searchProps,
|
|
1299
|
+
setSearchProps
|
|
1300
|
+
} = contextProps;
|
|
1301
|
+
const {
|
|
1302
|
+
isPopup,
|
|
1303
|
+
searchPlaceholder,
|
|
1304
|
+
api,
|
|
1305
|
+
getSearchProps,
|
|
1306
|
+
options,
|
|
1307
|
+
getSearchCallback
|
|
1308
|
+
} = props;
|
|
1267
1309
|
if (!(api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function')) {
|
|
1268
1310
|
return null;
|
|
1269
1311
|
}
|
|
@@ -1283,8 +1325,12 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1283
1325
|
});
|
|
1284
1326
|
},
|
|
1285
1327
|
getTagSearchCallback: (tagSearchText, item, contextProps) => {
|
|
1286
|
-
const
|
|
1287
|
-
|
|
1328
|
+
const {
|
|
1329
|
+
props
|
|
1330
|
+
} = contextProps;
|
|
1331
|
+
const {
|
|
1332
|
+
labelKey
|
|
1333
|
+
} = props;
|
|
1288
1334
|
if (!tagSearchText) {
|
|
1289
1335
|
return true;
|
|
1290
1336
|
}
|
|
@@ -1295,94 +1341,90 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1295
1341
|
return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
|
|
1296
1342
|
ref: ref
|
|
1297
1343
|
}), targetProps => {
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1344
|
+
const {
|
|
1345
|
+
props,
|
|
1346
|
+
value,
|
|
1347
|
+
setValue,
|
|
1348
|
+
onRemove,
|
|
1349
|
+
onOpenChange,
|
|
1350
|
+
searchProps,
|
|
1351
|
+
isMobile,
|
|
1352
|
+
open
|
|
1353
|
+
} = targetProps;
|
|
1354
|
+
const {
|
|
1355
|
+
footer,
|
|
1356
|
+
filterRender,
|
|
1357
|
+
columns,
|
|
1358
|
+
options,
|
|
1359
|
+
getSearchProps,
|
|
1360
|
+
getSearchCallback,
|
|
1361
|
+
getTagSearchCallback,
|
|
1362
|
+
api,
|
|
1363
|
+
selectedAllValue,
|
|
1364
|
+
isPopup,
|
|
1365
|
+
single,
|
|
1366
|
+
maxLength,
|
|
1367
|
+
searchPlaceholder,
|
|
1368
|
+
allowSelectedAll,
|
|
1369
|
+
labelKey,
|
|
1370
|
+
valueKey,
|
|
1371
|
+
renderMobile,
|
|
1372
|
+
dataType,
|
|
1373
|
+
parentKey,
|
|
1374
|
+
childrenKey,
|
|
1375
|
+
hasChildrenKey,
|
|
1376
|
+
treeTitleKey,
|
|
1377
|
+
onLoadChildren,
|
|
1378
|
+
expandedKeys,
|
|
1379
|
+
defaultExpandedKeys,
|
|
1380
|
+
onExpandedKeysChange,
|
|
1381
|
+
indentSize,
|
|
1382
|
+
checkRelation,
|
|
1383
|
+
pagination: paginationProp,
|
|
1384
|
+
dataFormat
|
|
1385
|
+
} = props;
|
|
1334
1386
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
1335
1387
|
const resolvedTreeTitleKey = treeTitleKey || labelKey;
|
|
1336
1388
|
const footerEl = footer && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1337
1389
|
className: classnames__default["default"](style$2['footer'], 'select-table-footer')
|
|
1338
1390
|
}, typeof footer === 'function' ? footer({
|
|
1339
1391
|
reload: () => {
|
|
1340
|
-
|
|
1341
|
-
((_fetchListRef$current = fetchListRef.current) == null ? void 0 : _fetchListRef$current.fetchApi) && ((_fetchListRef$current2 = fetchListRef.current) == null ? void 0 : _fetchListRef$current2.fetchApi.reload());
|
|
1392
|
+
tablePageRef.current?.reload();
|
|
1342
1393
|
},
|
|
1343
1394
|
close: () => {
|
|
1344
1395
|
onOpenChange(false);
|
|
1345
1396
|
}
|
|
1346
1397
|
}) : footer);
|
|
1347
|
-
const
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
})
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
|
-
} : api)
|
|
1373
|
-
}), fetchProps => {
|
|
1374
|
-
fetchListRef.current = fetchProps;
|
|
1375
|
-
const list = fetchProps.list;
|
|
1376
|
-
const contextProps = Object.assign({}, fetchProps, targetProps, {
|
|
1377
|
-
isSelectedAll
|
|
1378
|
-
});
|
|
1379
|
-
if (!(list && list.length > 0)) {
|
|
1380
|
-
return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, {
|
|
1381
|
-
className: classnames__default["default"](style$2['empty'])
|
|
1398
|
+
const paginationParamsType = paginationProp?.paramsType || 'data';
|
|
1399
|
+
const searchRequestProps = typeof getSearchProps === 'function' && isEmpty.isNotEmpty(searchProps) ? {
|
|
1400
|
+
[paginationParamsType]: getSearchProps(searchProps) || {}
|
|
1401
|
+
} : {};
|
|
1402
|
+
const tablePageFetchConfig = options ? {
|
|
1403
|
+
data: {
|
|
1404
|
+
options,
|
|
1405
|
+
searchProps
|
|
1406
|
+
},
|
|
1407
|
+
loader: _ref3 => {
|
|
1408
|
+
let {
|
|
1409
|
+
data
|
|
1410
|
+
} = _ref3;
|
|
1411
|
+
const {
|
|
1412
|
+
options: nextOptions,
|
|
1413
|
+
searchProps: nextSearchProps
|
|
1414
|
+
} = data;
|
|
1415
|
+
const pageData = filterTreeOptions(nextOptions, nextSearchProps, getSearchCallback, targetProps, {
|
|
1416
|
+
dataType,
|
|
1417
|
+
valueKey,
|
|
1418
|
+
parentKey,
|
|
1419
|
+
childrenKey
|
|
1382
1420
|
});
|
|
1421
|
+
return {
|
|
1422
|
+
pageData,
|
|
1423
|
+
totalCount: pageData.length
|
|
1424
|
+
};
|
|
1383
1425
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1426
|
+
} : merge__default["default"]({}, api, searchRequestProps);
|
|
1427
|
+
const allColumnsHaveWidth = Array.isArray(columns) && columns.length > 0 && columns.every(TablePage.hasColumnWidth);
|
|
1386
1428
|
const tableSelection = {
|
|
1387
1429
|
allowSelectedAll,
|
|
1388
1430
|
isSelectedAll,
|
|
@@ -1394,9 +1436,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1394
1436
|
checkRelation,
|
|
1395
1437
|
onChange: selectedRowKeys => {
|
|
1396
1438
|
setValue(prev => {
|
|
1397
|
-
var _fetchListRef$current3;
|
|
1398
1439
|
const prevMap = new Map((prev || []).map(item => [item[valueKey], item]));
|
|
1399
|
-
const listMap = new Map(flattenSelectList((
|
|
1440
|
+
const listMap = new Map(flattenSelectList(getListFromPageData(tablePageRef.current?.data), {
|
|
1400
1441
|
dataType,
|
|
1401
1442
|
rowKey: valueKey,
|
|
1402
1443
|
parentKey,
|
|
@@ -1428,7 +1469,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1428
1469
|
align: 'middle'
|
|
1429
1470
|
}, /*#__PURE__*/React__default["default"].createElement(antd.Col, null, formatMessage({
|
|
1430
1471
|
id: 'selected'
|
|
1431
|
-
}), value.length > 0 &&
|
|
1472
|
+
}), value.length > 0 && `(${value.length}${Number.isInteger(maxLength) ? `/${maxLength}` : ''})`, ":"), /*#__PURE__*/React__default["default"].createElement(antd.Col, null, /*#__PURE__*/React__default["default"].createElement(antd.Button, {
|
|
1432
1473
|
className: style$2['no-padding-btn'],
|
|
1433
1474
|
type: "link",
|
|
1434
1475
|
onClick: () => {
|
|
@@ -1441,7 +1482,6 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1441
1482
|
wrap: true,
|
|
1442
1483
|
gap: 8
|
|
1443
1484
|
}, value.filter(item => getTagSearchCallback(tagSearchText, item, targetProps)).map(item => {
|
|
1444
|
-
var _fetchListRef$current4, _fetchListRef$current5;
|
|
1445
1485
|
return /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
1446
1486
|
className: style$2['tag'],
|
|
1447
1487
|
key: item[valueKey],
|
|
@@ -1465,8 +1505,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1465
1505
|
})),
|
|
1466
1506
|
dataSource: Object.assign({}, item),
|
|
1467
1507
|
context: Object.assign({}, targetProps, {
|
|
1468
|
-
fetchApi:
|
|
1469
|
-
list: (
|
|
1508
|
+
fetchApi: tablePageRef.current,
|
|
1509
|
+
list: getListFromPageData(tablePageRef.current?.data)
|
|
1470
1510
|
})
|
|
1471
1511
|
})
|
|
1472
1512
|
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -1491,50 +1531,67 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1491
1531
|
className: style$2['filter-wrap']
|
|
1492
1532
|
}, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1493
1533
|
className: classnames__default["default"](style$2['table'], 'select-table')
|
|
1494
|
-
},
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1534
|
+
}, open ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1535
|
+
ref: listScrollRef,
|
|
1536
|
+
className: classnames__default["default"](style$2['list'], 'select-table-list-scroll-list', {
|
|
1537
|
+
'is-popup': isPopup,
|
|
1538
|
+
[style$2['is-fit-columns']]: !allColumnsHaveWidth
|
|
1539
|
+
})
|
|
1540
|
+
}, /*#__PURE__*/React__default["default"].createElement(TablePage__default["default"], _extends({}, tablePageFetchConfig, {
|
|
1541
|
+
ref: tablePageRef
|
|
1542
|
+
}, dataFormat ? {
|
|
1543
|
+
dataFormat
|
|
1544
|
+
} : null, {
|
|
1545
|
+
pagination: Object.assign({
|
|
1546
|
+
open: false,
|
|
1547
|
+
showSizeChanger: false,
|
|
1548
|
+
showQuickJumper: false,
|
|
1549
|
+
hideOnSinglePage: true
|
|
1550
|
+
}, paginationProp),
|
|
1551
|
+
scroll: isMobile ? undefined : Object.assign({
|
|
1552
|
+
y: (isPopup ? TABLE_LIST_MAX_HEIGHT_POPUP : TABLE_LIST_MAX_HEIGHT_EMBED) - TABLE_HEADER_HEIGHT
|
|
1553
|
+
}, allColumnsHaveWidth ? null : {
|
|
1554
|
+
x: undefined
|
|
1555
|
+
}),
|
|
1556
|
+
controllerOpen: false,
|
|
1557
|
+
columns: columns,
|
|
1558
|
+
rowKey: valueKey,
|
|
1559
|
+
rowSelection: tableSelection,
|
|
1560
|
+
columnRenderProps: Object.assign({}, targetProps, {
|
|
1561
|
+
isSelectedAll
|
|
1562
|
+
}),
|
|
1563
|
+
empty: props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, {
|
|
1564
|
+
className: classnames__default["default"](style$2['empty'])
|
|
1565
|
+
}),
|
|
1566
|
+
dataType: dataType,
|
|
1567
|
+
parentKey: parentKey,
|
|
1568
|
+
childrenKey: childrenKey,
|
|
1569
|
+
hasChildrenKey: hasChildrenKey,
|
|
1570
|
+
treeTitleKey: resolvedTreeTitleKey,
|
|
1571
|
+
renderMobile: renderMobile === false ? false : typeof renderMobile === 'function' ? mobileProps => renderMobile({
|
|
1572
|
+
...mobileProps,
|
|
1573
|
+
...targetProps,
|
|
1574
|
+
isSelectedAll,
|
|
1575
|
+
list: mobileProps.displayDataSource || mobileProps.dataSource,
|
|
1576
|
+
dataSource: mobileProps.dataSource,
|
|
1577
|
+
renderBody: function (nextList, nextContext) {
|
|
1578
|
+
if (nextList === void 0) {
|
|
1579
|
+
nextList = mobileProps.displayDataSource || mobileProps.dataSource;
|
|
1517
1580
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
}
|
|
1533
|
-
if (Object.prototype.hasOwnProperty.call(p, 'defaultExpandedKeys')) {
|
|
1534
|
-
tableViewProps.defaultExpandedKeys = defaultExpandedKeys;
|
|
1535
|
-
}
|
|
1536
|
-
return /*#__PURE__*/React__default["default"].createElement(TableView__default["default"], tableViewProps);
|
|
1537
|
-
})), single && footerEl || !isMobile && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1581
|
+
return mobileProps.renderBody(nextList, nextContext);
|
|
1582
|
+
}
|
|
1583
|
+
}) : true
|
|
1584
|
+
}, typeof onLoadChildren === 'function' ? {
|
|
1585
|
+
onLoadChildren
|
|
1586
|
+
} : null, typeof onExpandedKeysChange === 'function' ? {
|
|
1587
|
+
onExpandedKeysChange
|
|
1588
|
+
} : null, indentSize != null ? {
|
|
1589
|
+
indentSize
|
|
1590
|
+
} : null, Object.prototype.hasOwnProperty.call(p, 'expandedKeys') ? {
|
|
1591
|
+
expandedKeys
|
|
1592
|
+
} : null, Object.prototype.hasOwnProperty.call(p, 'defaultExpandedKeys') ? {
|
|
1593
|
+
defaultExpandedKeys
|
|
1594
|
+
} : null))) : null), single && footerEl || !isMobile && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1538
1595
|
className: classnames__default["default"](style$2['footer'], 'select-table-footer')
|
|
1539
1596
|
}));
|
|
1540
1597
|
|
|
@@ -1567,15 +1624,15 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1567
1624
|
|
|
1568
1625
|
var style$1 = {"kne-responsive-boundary":"kne-super-select_YFHhC","kne-responsive-scroll":"kne-super-select_yjaz7","list":"kne-super-select_YTqxA","default-list":"kne-super-select_IZN7r","is-selected-all":"kne-super-select_GCIMn","default-list-item":"kne-super-select_AYi0i","is-selected":"kne-super-select_eovZv","single-checked":"kne-super-select_Tr-bO","is-disabled":"kne-super-select_T-hri","selected-all":"kne-super-select_4XFtm","selected-tag":"kne-super-select_Whlzr","select-search":"kne-super-select_7zuBL","select-tree-item-description":"kne-super-select_R-Sye","footer":"kne-super-select_PjlnR","is-mobile":"kne-super-select_yTb5p"};
|
|
1569
1626
|
|
|
1570
|
-
const _excluded$1 = ["children"],
|
|
1571
|
-
_excluded2 = ["data"];
|
|
1572
1627
|
const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
1573
1628
|
if (data === void 0) {
|
|
1574
1629
|
data = [];
|
|
1575
1630
|
}
|
|
1576
|
-
let
|
|
1577
|
-
|
|
1578
|
-
|
|
1631
|
+
let {
|
|
1632
|
+
parentKey,
|
|
1633
|
+
valueKey,
|
|
1634
|
+
childrenKey
|
|
1635
|
+
} = _ref;
|
|
1579
1636
|
const parseTree = output => {
|
|
1580
1637
|
return output.map(node => {
|
|
1581
1638
|
const children = data.filter(item => {
|
|
@@ -1592,35 +1649,43 @@ const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
|
1592
1649
|
};
|
|
1593
1650
|
});
|
|
1594
1651
|
const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
1595
|
-
let
|
|
1596
|
-
|
|
1652
|
+
let {
|
|
1653
|
+
children,
|
|
1654
|
+
...p
|
|
1655
|
+
} = _ref2;
|
|
1597
1656
|
const fetchListRef = React.useRef(null);
|
|
1598
|
-
const
|
|
1599
|
-
expandedKeys = _useState[0],
|
|
1600
|
-
setExpandedKeys = _useState[1];
|
|
1657
|
+
const [expandedKeys, setExpandedKeys] = React.useState([]);
|
|
1601
1658
|
const props = Object.assign({}, {
|
|
1602
1659
|
parentKey: 'parentId',
|
|
1603
1660
|
childrenKey: 'children',
|
|
1604
1661
|
renderItemContent: _ref3 => {
|
|
1605
|
-
let
|
|
1606
|
-
|
|
1607
|
-
|
|
1662
|
+
let {
|
|
1663
|
+
item,
|
|
1664
|
+
props
|
|
1665
|
+
} = _ref3;
|
|
1666
|
+
const {
|
|
1667
|
+
labelKey
|
|
1668
|
+
} = props;
|
|
1608
1669
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1609
1670
|
className: 'select-tree-item-label'
|
|
1610
1671
|
}, item[labelKey]));
|
|
1611
1672
|
},
|
|
1612
1673
|
renderItem: contextProps => {
|
|
1613
|
-
const
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1674
|
+
const {
|
|
1675
|
+
item,
|
|
1676
|
+
props,
|
|
1677
|
+
isSelectedAll,
|
|
1678
|
+
value,
|
|
1679
|
+
onSelect,
|
|
1680
|
+
setValue,
|
|
1681
|
+
onOpenChange
|
|
1682
|
+
} = contextProps;
|
|
1683
|
+
const {
|
|
1684
|
+
single,
|
|
1685
|
+
isPopup,
|
|
1686
|
+
renderItemContent,
|
|
1687
|
+
valueKey
|
|
1688
|
+
} = props;
|
|
1624
1689
|
const isChecked = value.some(target => target[valueKey] === item[valueKey]);
|
|
1625
1690
|
return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
1626
1691
|
className: classnames__default["default"](style$1['default-list-item'], 'select-tree-item', {
|
|
@@ -1658,20 +1723,26 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1658
1723
|
}, isChecked && /*#__PURE__*/React__default["default"].createElement(icons.CheckOutlined, null)));
|
|
1659
1724
|
},
|
|
1660
1725
|
renderTree: contextProps => {
|
|
1661
|
-
const
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
treeData
|
|
1726
|
+
const {
|
|
1727
|
+
props,
|
|
1728
|
+
isSelectedAll,
|
|
1729
|
+
data
|
|
1730
|
+
} = contextProps;
|
|
1731
|
+
const {
|
|
1732
|
+
renderItem,
|
|
1733
|
+
valueKey,
|
|
1734
|
+
labelKey,
|
|
1735
|
+
childrenKey,
|
|
1736
|
+
parentKey
|
|
1737
|
+
} = props;
|
|
1738
|
+
const {
|
|
1739
|
+
treeData,
|
|
1740
|
+
ids
|
|
1741
|
+
} = parseTreeData(data, {
|
|
1742
|
+
valueKey,
|
|
1743
|
+
parentKey,
|
|
1744
|
+
childrenKey
|
|
1745
|
+
});
|
|
1675
1746
|
if (!(treeData && treeData.length > 0)) {
|
|
1676
1747
|
return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, null);
|
|
1677
1748
|
}
|
|
@@ -1702,21 +1773,25 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1702
1773
|
return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
|
|
1703
1774
|
ref: ref
|
|
1704
1775
|
}), targetProps => {
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1776
|
+
const {
|
|
1777
|
+
props,
|
|
1778
|
+
value,
|
|
1779
|
+
onOpenChange,
|
|
1780
|
+
isMobile,
|
|
1781
|
+
open
|
|
1782
|
+
} = targetProps;
|
|
1783
|
+
const {
|
|
1784
|
+
footer,
|
|
1785
|
+
isPopup,
|
|
1786
|
+
valueKey,
|
|
1787
|
+
single,
|
|
1788
|
+
allowSelectedAll,
|
|
1789
|
+
showSelectedTag,
|
|
1790
|
+
api,
|
|
1791
|
+
options,
|
|
1792
|
+
renderTree,
|
|
1793
|
+
selectedAllValue
|
|
1794
|
+
} = props;
|
|
1720
1795
|
const components = {
|
|
1721
1796
|
selectedAll: !single && allowSelectedAll && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1722
1797
|
className: classnames__default["default"](style$1['selected-all'], 'select-tree-selected-all', {
|
|
@@ -1728,14 +1803,18 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1728
1803
|
options
|
|
1729
1804
|
},
|
|
1730
1805
|
loader: _ref4 => {
|
|
1731
|
-
let
|
|
1806
|
+
let {
|
|
1807
|
+
data
|
|
1808
|
+
} = _ref4;
|
|
1732
1809
|
return data.options;
|
|
1733
1810
|
}
|
|
1734
1811
|
} : api), {
|
|
1735
1812
|
ref: fetchListRef,
|
|
1736
1813
|
render: _ref5 => {
|
|
1737
|
-
let
|
|
1738
|
-
|
|
1814
|
+
let {
|
|
1815
|
+
data,
|
|
1816
|
+
...fetchProps
|
|
1817
|
+
} = _ref5;
|
|
1739
1818
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
1740
1819
|
const treeContent = renderTree(Object.assign({}, fetchProps, targetProps, {
|
|
1741
1820
|
isSelectedAll,
|
|
@@ -2021,39 +2100,37 @@ const CustomMenu = ({
|
|
|
2021
2100
|
});
|
|
2022
2101
|
};
|
|
2023
2102
|
|
|
2024
|
-
const _excluded = ["options", "value", "onChange", "defaultValue", "maxLength", "single", "onlyAllowLastLevel", "openLoadData", "onLoadMore", "parentIdKey", "menuItemWidth", "isPopup", "searchPlaceholder", "onSearch", "valueKey", "labelKey", "placeholder", "disabled", "size", "overlayWidth"];
|
|
2025
2103
|
const numberToPx = val => {
|
|
2026
|
-
return typeof val === 'number' ? val
|
|
2104
|
+
return typeof val === 'number' ? `${val}px` : val;
|
|
2027
2105
|
};
|
|
2028
2106
|
|
|
2029
2107
|
// 级联选择内容组件
|
|
2030
2108
|
const CascaderInner = _ref => {
|
|
2031
|
-
let
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
const
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
const
|
|
2055
|
-
|
|
2056
|
-
setLoading = _useState2[1];
|
|
2109
|
+
let {
|
|
2110
|
+
options,
|
|
2111
|
+
value,
|
|
2112
|
+
setValue,
|
|
2113
|
+
maxLength,
|
|
2114
|
+
single,
|
|
2115
|
+
onlyAllowLastLevel,
|
|
2116
|
+
openLoadData,
|
|
2117
|
+
onLoadMore,
|
|
2118
|
+
parentIdKey,
|
|
2119
|
+
menuItemWidth,
|
|
2120
|
+
isPopup,
|
|
2121
|
+
searchPlaceholder,
|
|
2122
|
+
onSearch,
|
|
2123
|
+
valueKey,
|
|
2124
|
+
labelKey,
|
|
2125
|
+
onOpenChange,
|
|
2126
|
+
open,
|
|
2127
|
+
isMobile
|
|
2128
|
+
} = _ref;
|
|
2129
|
+
const {
|
|
2130
|
+
message
|
|
2131
|
+
} = antd.App.useApp();
|
|
2132
|
+
const [searchText, setSearchText] = React.useState('');
|
|
2133
|
+
const [loading, setLoading] = React.useState(false);
|
|
2057
2134
|
// 移动端弹窗内不用 SimpleBar,改原生滚动
|
|
2058
2135
|
const ScrollBox = isMobile ? 'div' : SimpleBar__default["default"];
|
|
2059
2136
|
|
|
@@ -2065,13 +2142,15 @@ const CascaderInner = _ref => {
|
|
|
2065
2142
|
parentId = null;
|
|
2066
2143
|
}
|
|
2067
2144
|
items.forEach(item => {
|
|
2068
|
-
const node =
|
|
2145
|
+
const node = {
|
|
2146
|
+
...item,
|
|
2069
2147
|
id: item[valueKey],
|
|
2070
2148
|
label: item[labelKey],
|
|
2071
2149
|
parentId
|
|
2072
|
-
}
|
|
2150
|
+
};
|
|
2073
2151
|
if (item.children && item.children.length > 0) {
|
|
2074
|
-
node.children = item.children.map(child =>
|
|
2152
|
+
node.children = item.children.map(child => ({
|
|
2153
|
+
...child,
|
|
2075
2154
|
id: child[valueKey],
|
|
2076
2155
|
label: child[labelKey],
|
|
2077
2156
|
parentId: node.id
|
|
@@ -2091,25 +2170,23 @@ const CascaderInner = _ref => {
|
|
|
2091
2170
|
}, [mapping]);
|
|
2092
2171
|
|
|
2093
2172
|
// 当前选中的列
|
|
2094
|
-
const
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2173
|
+
const [selectedIds, setSelectedIds] = React.useState(() => {
|
|
2174
|
+
const initValue = value.find(item => {
|
|
2175
|
+
const id = typeof item === 'object' ? item[valueKey] : item;
|
|
2176
|
+
return !!mapping.get(id);
|
|
2177
|
+
});
|
|
2178
|
+
if (initValue) {
|
|
2179
|
+
const id = typeof initValue === 'object' ? initValue[valueKey] : initValue;
|
|
2180
|
+
return treeUtils.getSelectedQueue(id);
|
|
2181
|
+
}
|
|
2103
2182
|
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
selectedIds = _useState3[0],
|
|
2112
|
-
setSelectedIds = _useState3[1];
|
|
2183
|
+
// 默认选中第一列
|
|
2184
|
+
const firstNode = Array.from(mapping.values()).find(item => isNil__default["default"](item.parentId));
|
|
2185
|
+
if (firstNode) {
|
|
2186
|
+
return treeUtils.getSelectedQueue(firstNode.id);
|
|
2187
|
+
}
|
|
2188
|
+
return [];
|
|
2189
|
+
});
|
|
2113
2190
|
|
|
2114
2191
|
// 当 Modal 打开时,根据 value 重新初始化 selectedIds
|
|
2115
2192
|
const prevOpenRef = React.useRef(open);
|
|
@@ -2191,7 +2268,7 @@ const CascaderInner = _ref => {
|
|
|
2191
2268
|
return checked ? treeUtils.setNodeChecked(id, currentIds) : treeUtils.setNodeUnchecked(id, currentIds);
|
|
2192
2269
|
})();
|
|
2193
2270
|
if (newValue.length > maxLength) {
|
|
2194
|
-
message.error(
|
|
2271
|
+
message.error(`最多只能选择 ${maxLength} 项`);
|
|
2195
2272
|
return;
|
|
2196
2273
|
}
|
|
2197
2274
|
|
|
@@ -2199,10 +2276,11 @@ const CascaderInner = _ref => {
|
|
|
2199
2276
|
const newValues = newValue.map(id => {
|
|
2200
2277
|
const node = mapping.get(id);
|
|
2201
2278
|
// 返回完整的节点数据,保留所有原始字段
|
|
2202
|
-
return node ?
|
|
2279
|
+
return node ? {
|
|
2280
|
+
...node,
|
|
2203
2281
|
[valueKey]: node.id,
|
|
2204
2282
|
[labelKey]: node.label
|
|
2205
|
-
}
|
|
2283
|
+
} : null;
|
|
2206
2284
|
}).filter(Boolean);
|
|
2207
2285
|
const finalValue = single && newValues.length > 0 ? [last__default["default"](newValues)] : newValues;
|
|
2208
2286
|
setValue(finalValue);
|
|
@@ -2309,7 +2387,7 @@ const CascaderInner = _ref => {
|
|
|
2309
2387
|
}, selectedIds.map((selectedId, index) => {
|
|
2310
2388
|
const selectNode = mapping.get(selectedId);
|
|
2311
2389
|
const siblingNodes = treeUtils.getSiblingNode(selectedId);
|
|
2312
|
-
const isLastLevel = !isNotLastNode(selectNode
|
|
2390
|
+
const isLastLevel = !isNotLastNode(selectNode?.id) && index > 0;
|
|
2313
2391
|
return /*#__PURE__*/React__default["default"].createElement(ScrollBox, {
|
|
2314
2392
|
key: selectedId || index,
|
|
2315
2393
|
className: classnames__default["default"](style['content-item'], {
|
|
@@ -2319,17 +2397,21 @@ const CascaderInner = _ref => {
|
|
|
2319
2397
|
className: style['menu'],
|
|
2320
2398
|
selectedKeys: currentIds,
|
|
2321
2399
|
onSelect: _ref2 => {
|
|
2322
|
-
let
|
|
2400
|
+
let {
|
|
2401
|
+
key
|
|
2402
|
+
} = _ref2;
|
|
2323
2403
|
const node = mapping.get(key);
|
|
2324
2404
|
if (!node) return;
|
|
2325
|
-
const
|
|
2326
|
-
checked
|
|
2405
|
+
const {
|
|
2406
|
+
checked
|
|
2407
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2327
2408
|
onCheckedChange(!checked, node.id);
|
|
2328
2409
|
},
|
|
2329
2410
|
items: siblingNodes.map(node => {
|
|
2330
|
-
const
|
|
2331
|
-
checked
|
|
2332
|
-
indeterminate
|
|
2411
|
+
const {
|
|
2412
|
+
checked,
|
|
2413
|
+
indeterminate
|
|
2414
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2333
2415
|
return {
|
|
2334
2416
|
key: node.id,
|
|
2335
2417
|
label: /*#__PURE__*/React__default["default"].createElement(antd.Space, {
|
|
@@ -2360,9 +2442,10 @@ const CascaderInner = _ref => {
|
|
|
2360
2442
|
[style['single-mode']]: single
|
|
2361
2443
|
})
|
|
2362
2444
|
}, siblingNodes.map(node => {
|
|
2363
|
-
const
|
|
2364
|
-
checked
|
|
2365
|
-
indeterminate
|
|
2445
|
+
const {
|
|
2446
|
+
checked,
|
|
2447
|
+
indeterminate
|
|
2448
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2366
2449
|
return /*#__PURE__*/React__default["default"].createElement(antd.Checkbox, {
|
|
2367
2450
|
key: node.id,
|
|
2368
2451
|
checked: checked,
|
|
@@ -2373,21 +2456,25 @@ const CascaderInner = _ref => {
|
|
|
2373
2456
|
className: style['menu'],
|
|
2374
2457
|
selectedKeys: index === selectedIds.length - 1 ? [] : selectedIds,
|
|
2375
2458
|
onSelect: _ref3 => {
|
|
2376
|
-
let
|
|
2459
|
+
let {
|
|
2460
|
+
key
|
|
2461
|
+
} = _ref3;
|
|
2377
2462
|
const node = mapping.get(key);
|
|
2378
2463
|
if (!node) return;
|
|
2379
2464
|
if (isNotLastNode(node.id)) {
|
|
2380
2465
|
setSelectedIds(treeUtils.getSelectedQueue(node.id));
|
|
2381
2466
|
} else {
|
|
2382
|
-
const
|
|
2383
|
-
checked
|
|
2467
|
+
const {
|
|
2468
|
+
checked
|
|
2469
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2384
2470
|
onCheckedChange(!checked, node.id);
|
|
2385
2471
|
}
|
|
2386
2472
|
},
|
|
2387
2473
|
items: siblingNodes.map(node => {
|
|
2388
|
-
const
|
|
2389
|
-
checked
|
|
2390
|
-
indeterminate
|
|
2474
|
+
const {
|
|
2475
|
+
checked,
|
|
2476
|
+
indeterminate
|
|
2477
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2391
2478
|
const hasChildren = isNotLastNode(node.id);
|
|
2392
2479
|
|
|
2393
2480
|
// 计算子级选中数量
|
|
@@ -2431,45 +2518,32 @@ const CascaderInner = _ref => {
|
|
|
2431
2518
|
|
|
2432
2519
|
// 主组件
|
|
2433
2520
|
const SelectCascader = _ref4 => {
|
|
2434
|
-
let
|
|
2435
|
-
options =
|
|
2436
|
-
value
|
|
2437
|
-
onChange
|
|
2438
|
-
defaultValue
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
valueKey = _ref4$valueKey === void 0 ? 'id' : _ref4$valueKey,
|
|
2458
|
-
_ref4$labelKey = _ref4.labelKey,
|
|
2459
|
-
labelKey = _ref4$labelKey === void 0 ? 'label' : _ref4$labelKey,
|
|
2460
|
-
_ref4$placeholder = _ref4.placeholder,
|
|
2461
|
-
placeholder = _ref4$placeholder === void 0 ? '请选择' : _ref4$placeholder,
|
|
2462
|
-
_ref4$disabled = _ref4.disabled,
|
|
2463
|
-
disabled = _ref4$disabled === void 0 ? false : _ref4$disabled,
|
|
2464
|
-
_ref4$size = _ref4.size,
|
|
2465
|
-
size = _ref4$size === void 0 ? 'default' : _ref4$size,
|
|
2466
|
-
overlayWidth = _ref4.overlayWidth,
|
|
2467
|
-
props = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
2521
|
+
let {
|
|
2522
|
+
options = [],
|
|
2523
|
+
value,
|
|
2524
|
+
onChange,
|
|
2525
|
+
defaultValue,
|
|
2526
|
+
maxLength = Number.MAX_VALUE,
|
|
2527
|
+
single = false,
|
|
2528
|
+
onlyAllowLastLevel = false,
|
|
2529
|
+
openLoadData = false,
|
|
2530
|
+
onLoadMore,
|
|
2531
|
+
parentIdKey = 'id',
|
|
2532
|
+
menuItemWidth = 180,
|
|
2533
|
+
isPopup = true,
|
|
2534
|
+
searchPlaceholder,
|
|
2535
|
+
onSearch,
|
|
2536
|
+
valueKey = 'id',
|
|
2537
|
+
labelKey = 'label',
|
|
2538
|
+
placeholder = '请选择',
|
|
2539
|
+
disabled = false,
|
|
2540
|
+
size = 'default',
|
|
2541
|
+
overlayWidth,
|
|
2542
|
+
...props
|
|
2543
|
+
} = _ref4;
|
|
2468
2544
|
// 内部始终使用数组格式处理
|
|
2469
2545
|
// SelectInput 会处理 single 模式的 value 和 onChange 转换
|
|
2470
|
-
const
|
|
2471
|
-
innerValue = _useState4[0],
|
|
2472
|
-
setInnerValue = _useState4[1];
|
|
2546
|
+
const [innerValue, setInnerValue] = React.useState(Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : []);
|
|
2473
2547
|
|
|
2474
2548
|
// currentValue 用于内部处理,始终是数组
|
|
2475
2549
|
const currentValue = React.useMemo(() => {
|
|
@@ -2499,10 +2573,10 @@ const SelectCascader = _ref4 => {
|
|
|
2499
2573
|
// 根据单选/多选模式转换输出格式
|
|
2500
2574
|
if (single) {
|
|
2501
2575
|
// 单选:返回单个对象或 null
|
|
2502
|
-
onChange
|
|
2576
|
+
onChange?.(normalizedValue.length > 0 ? normalizedValue[0] : null);
|
|
2503
2577
|
} else {
|
|
2504
2578
|
// 多选:返回数组
|
|
2505
|
-
onChange
|
|
2579
|
+
onChange?.(normalizedValue);
|
|
2506
2580
|
}
|
|
2507
2581
|
}, [value, onChange, single]);
|
|
2508
2582
|
|
|
@@ -2524,10 +2598,11 @@ const SelectCascader = _ref4 => {
|
|
|
2524
2598
|
if (typeof item === 'object') {
|
|
2525
2599
|
// 优先使用 item[labelKey],然后是 item.label,最后是 item.name
|
|
2526
2600
|
const label = item[labelKey] || item.label || item.name || String(item[valueKey] || '');
|
|
2527
|
-
return
|
|
2601
|
+
return {
|
|
2602
|
+
...item,
|
|
2528
2603
|
[valueKey]: item[valueKey] || item.id,
|
|
2529
2604
|
[labelKey]: label
|
|
2530
|
-
}
|
|
2605
|
+
};
|
|
2531
2606
|
}
|
|
2532
2607
|
// 如果是值,从 options 中查找
|
|
2533
2608
|
const findLabel = items => {
|
|
@@ -2573,10 +2648,11 @@ const SelectCascader = _ref4 => {
|
|
|
2573
2648
|
// 如果已经是对象,确保有标准化的字段
|
|
2574
2649
|
if (typeof item === 'object') {
|
|
2575
2650
|
const label = item[labelKey] || item.label || item.name || String(item[valueKey] || '');
|
|
2576
|
-
return
|
|
2651
|
+
return {
|
|
2652
|
+
...item,
|
|
2577
2653
|
[valueKey]: item[valueKey] || item.id,
|
|
2578
2654
|
[labelKey]: label
|
|
2579
|
-
}
|
|
2655
|
+
};
|
|
2580
2656
|
}
|
|
2581
2657
|
// 如果是值,从 options 中查找
|
|
2582
2658
|
const findLabel = items => {
|
|
@@ -2624,7 +2700,7 @@ const SelectCascader = _ref4 => {
|
|
|
2624
2700
|
|
|
2625
2701
|
Object.defineProperty(exports, 'mergeTreeChildren', {
|
|
2626
2702
|
enumerable: true,
|
|
2627
|
-
get: function () { return
|
|
2703
|
+
get: function () { return TablePage.mergeTreeChildren; }
|
|
2628
2704
|
});
|
|
2629
2705
|
exports.SelectCascader = SelectCascader;
|
|
2630
2706
|
exports.SelectInput = SelectInput;
|