@kne/super-select 0.1.46 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -2
- package/dist/index.css +34 -10
- package/dist/index.css.map +1 -1
- package/dist/index.js +601 -527
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +108 -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,88 @@ 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
|
-
dataType,
|
|
1366
|
-
valueKey,
|
|
1367
|
-
parentKey,
|
|
1368
|
-
childrenKey
|
|
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 tablePageFetchConfig = options ? {
|
|
1399
|
+
data: {
|
|
1400
|
+
options,
|
|
1401
|
+
searchProps
|
|
1402
|
+
},
|
|
1403
|
+
loader: _ref3 => {
|
|
1404
|
+
let {
|
|
1405
|
+
data
|
|
1406
|
+
} = _ref3;
|
|
1407
|
+
const {
|
|
1408
|
+
options: nextOptions,
|
|
1409
|
+
searchProps: nextSearchProps
|
|
1410
|
+
} = data;
|
|
1411
|
+
const pageData = filterTreeOptions(nextOptions, nextSearchProps, getSearchCallback, targetProps, {
|
|
1412
|
+
dataType,
|
|
1413
|
+
valueKey,
|
|
1414
|
+
parentKey,
|
|
1415
|
+
childrenKey
|
|
1382
1416
|
});
|
|
1417
|
+
return {
|
|
1418
|
+
pageData,
|
|
1419
|
+
totalCount: pageData.length
|
|
1420
|
+
};
|
|
1383
1421
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1422
|
+
} : merge__default["default"]({}, api, typeof getSearchProps === 'function' && isEmpty.isNotEmpty(searchProps) ? {
|
|
1423
|
+
data: getSearchProps(searchProps) || {}
|
|
1424
|
+
} : {});
|
|
1425
|
+
const allColumnsHaveWidth = Array.isArray(columns) && columns.length > 0 && columns.every(TablePage.hasColumnWidth);
|
|
1386
1426
|
const tableSelection = {
|
|
1387
1427
|
allowSelectedAll,
|
|
1388
1428
|
isSelectedAll,
|
|
@@ -1394,9 +1434,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1394
1434
|
checkRelation,
|
|
1395
1435
|
onChange: selectedRowKeys => {
|
|
1396
1436
|
setValue(prev => {
|
|
1397
|
-
var _fetchListRef$current3;
|
|
1398
1437
|
const prevMap = new Map((prev || []).map(item => [item[valueKey], item]));
|
|
1399
|
-
const listMap = new Map(flattenSelectList((
|
|
1438
|
+
const listMap = new Map(flattenSelectList(getListFromPageData(tablePageRef.current?.data), {
|
|
1400
1439
|
dataType,
|
|
1401
1440
|
rowKey: valueKey,
|
|
1402
1441
|
parentKey,
|
|
@@ -1428,7 +1467,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1428
1467
|
align: 'middle'
|
|
1429
1468
|
}, /*#__PURE__*/React__default["default"].createElement(antd.Col, null, formatMessage({
|
|
1430
1469
|
id: 'selected'
|
|
1431
|
-
}), value.length > 0 &&
|
|
1470
|
+
}), value.length > 0 && `(${value.length}${Number.isInteger(maxLength) ? `/${maxLength}` : ''})`, ":"), /*#__PURE__*/React__default["default"].createElement(antd.Col, null, /*#__PURE__*/React__default["default"].createElement(antd.Button, {
|
|
1432
1471
|
className: style$2['no-padding-btn'],
|
|
1433
1472
|
type: "link",
|
|
1434
1473
|
onClick: () => {
|
|
@@ -1441,7 +1480,6 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1441
1480
|
wrap: true,
|
|
1442
1481
|
gap: 8
|
|
1443
1482
|
}, value.filter(item => getTagSearchCallback(tagSearchText, item, targetProps)).map(item => {
|
|
1444
|
-
var _fetchListRef$current4, _fetchListRef$current5;
|
|
1445
1483
|
return /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
1446
1484
|
className: style$2['tag'],
|
|
1447
1485
|
key: item[valueKey],
|
|
@@ -1465,8 +1503,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1465
1503
|
})),
|
|
1466
1504
|
dataSource: Object.assign({}, item),
|
|
1467
1505
|
context: Object.assign({}, targetProps, {
|
|
1468
|
-
fetchApi:
|
|
1469
|
-
list: (
|
|
1506
|
+
fetchApi: tablePageRef.current,
|
|
1507
|
+
list: getListFromPageData(tablePageRef.current?.data)
|
|
1470
1508
|
})
|
|
1471
1509
|
})
|
|
1472
1510
|
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -1491,50 +1529,67 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1491
1529
|
className: style$2['filter-wrap']
|
|
1492
1530
|
}, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1493
1531
|
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
|
-
|
|
1532
|
+
}, open ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1533
|
+
ref: listScrollRef,
|
|
1534
|
+
className: classnames__default["default"](style$2['list'], 'select-table-list-scroll-list', {
|
|
1535
|
+
'is-popup': isPopup,
|
|
1536
|
+
[style$2['is-fit-columns']]: !allColumnsHaveWidth
|
|
1537
|
+
})
|
|
1538
|
+
}, /*#__PURE__*/React__default["default"].createElement(TablePage__default["default"], _extends({}, tablePageFetchConfig, {
|
|
1539
|
+
ref: tablePageRef
|
|
1540
|
+
}, dataFormat ? {
|
|
1541
|
+
dataFormat
|
|
1542
|
+
} : null, {
|
|
1543
|
+
pagination: Object.assign({
|
|
1544
|
+
open: false,
|
|
1545
|
+
showSizeChanger: false,
|
|
1546
|
+
showQuickJumper: false,
|
|
1547
|
+
hideOnSinglePage: true
|
|
1548
|
+
}, paginationProp),
|
|
1549
|
+
scroll: isMobile ? undefined : Object.assign({
|
|
1550
|
+
y: (isPopup ? TABLE_LIST_MAX_HEIGHT_POPUP : TABLE_LIST_MAX_HEIGHT_EMBED) - TABLE_HEADER_HEIGHT
|
|
1551
|
+
}, allColumnsHaveWidth ? null : {
|
|
1552
|
+
x: undefined
|
|
1553
|
+
}),
|
|
1554
|
+
controllerOpen: false,
|
|
1555
|
+
columns: columns,
|
|
1556
|
+
rowKey: valueKey,
|
|
1557
|
+
rowSelection: tableSelection,
|
|
1558
|
+
columnRenderProps: Object.assign({}, targetProps, {
|
|
1559
|
+
isSelectedAll
|
|
1560
|
+
}),
|
|
1561
|
+
empty: props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, {
|
|
1562
|
+
className: classnames__default["default"](style$2['empty'])
|
|
1563
|
+
}),
|
|
1564
|
+
dataType: dataType,
|
|
1565
|
+
parentKey: parentKey,
|
|
1566
|
+
childrenKey: childrenKey,
|
|
1567
|
+
hasChildrenKey: hasChildrenKey,
|
|
1568
|
+
treeTitleKey: resolvedTreeTitleKey,
|
|
1569
|
+
renderMobile: renderMobile === false ? false : typeof renderMobile === 'function' ? mobileProps => renderMobile({
|
|
1570
|
+
...mobileProps,
|
|
1571
|
+
...targetProps,
|
|
1572
|
+
isSelectedAll,
|
|
1573
|
+
list: mobileProps.displayDataSource || mobileProps.dataSource,
|
|
1574
|
+
dataSource: mobileProps.dataSource,
|
|
1575
|
+
renderBody: function (nextList, nextContext) {
|
|
1576
|
+
if (nextList === void 0) {
|
|
1577
|
+
nextList = mobileProps.displayDataSource || mobileProps.dataSource;
|
|
1517
1578
|
}
|
|
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", {
|
|
1579
|
+
return mobileProps.renderBody(nextList, nextContext);
|
|
1580
|
+
}
|
|
1581
|
+
}) : true
|
|
1582
|
+
}, typeof onLoadChildren === 'function' ? {
|
|
1583
|
+
onLoadChildren
|
|
1584
|
+
} : null, typeof onExpandedKeysChange === 'function' ? {
|
|
1585
|
+
onExpandedKeysChange
|
|
1586
|
+
} : null, indentSize != null ? {
|
|
1587
|
+
indentSize
|
|
1588
|
+
} : null, Object.prototype.hasOwnProperty.call(p, 'expandedKeys') ? {
|
|
1589
|
+
expandedKeys
|
|
1590
|
+
} : null, Object.prototype.hasOwnProperty.call(p, 'defaultExpandedKeys') ? {
|
|
1591
|
+
defaultExpandedKeys
|
|
1592
|
+
} : null))) : null), single && footerEl || !isMobile && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1538
1593
|
className: classnames__default["default"](style$2['footer'], 'select-table-footer')
|
|
1539
1594
|
}));
|
|
1540
1595
|
|
|
@@ -1567,15 +1622,15 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1567
1622
|
|
|
1568
1623
|
var style$1 = {"kne-responsive-boundary":"kne-super-select_YFHhC","kne-responsive-scroll":"kne-super-select_yjaz7","list":"kne-super-select_YTqxA","default-list":"kne-super-select_IZN7r","is-selected-all":"kne-super-select_GCIMn","default-list-item":"kne-super-select_AYi0i","is-selected":"kne-super-select_eovZv","single-checked":"kne-super-select_Tr-bO","is-disabled":"kne-super-select_T-hri","selected-all":"kne-super-select_4XFtm","selected-tag":"kne-super-select_Whlzr","select-search":"kne-super-select_7zuBL","select-tree-item-description":"kne-super-select_R-Sye","footer":"kne-super-select_PjlnR","is-mobile":"kne-super-select_yTb5p"};
|
|
1569
1624
|
|
|
1570
|
-
const _excluded$1 = ["children"],
|
|
1571
|
-
_excluded2 = ["data"];
|
|
1572
1625
|
const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
1573
1626
|
if (data === void 0) {
|
|
1574
1627
|
data = [];
|
|
1575
1628
|
}
|
|
1576
|
-
let
|
|
1577
|
-
|
|
1578
|
-
|
|
1629
|
+
let {
|
|
1630
|
+
parentKey,
|
|
1631
|
+
valueKey,
|
|
1632
|
+
childrenKey
|
|
1633
|
+
} = _ref;
|
|
1579
1634
|
const parseTree = output => {
|
|
1580
1635
|
return output.map(node => {
|
|
1581
1636
|
const children = data.filter(item => {
|
|
@@ -1592,35 +1647,43 @@ const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
|
1592
1647
|
};
|
|
1593
1648
|
});
|
|
1594
1649
|
const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
1595
|
-
let
|
|
1596
|
-
|
|
1650
|
+
let {
|
|
1651
|
+
children,
|
|
1652
|
+
...p
|
|
1653
|
+
} = _ref2;
|
|
1597
1654
|
const fetchListRef = React.useRef(null);
|
|
1598
|
-
const
|
|
1599
|
-
expandedKeys = _useState[0],
|
|
1600
|
-
setExpandedKeys = _useState[1];
|
|
1655
|
+
const [expandedKeys, setExpandedKeys] = React.useState([]);
|
|
1601
1656
|
const props = Object.assign({}, {
|
|
1602
1657
|
parentKey: 'parentId',
|
|
1603
1658
|
childrenKey: 'children',
|
|
1604
1659
|
renderItemContent: _ref3 => {
|
|
1605
|
-
let
|
|
1606
|
-
|
|
1607
|
-
|
|
1660
|
+
let {
|
|
1661
|
+
item,
|
|
1662
|
+
props
|
|
1663
|
+
} = _ref3;
|
|
1664
|
+
const {
|
|
1665
|
+
labelKey
|
|
1666
|
+
} = props;
|
|
1608
1667
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1609
1668
|
className: 'select-tree-item-label'
|
|
1610
1669
|
}, item[labelKey]));
|
|
1611
1670
|
},
|
|
1612
1671
|
renderItem: contextProps => {
|
|
1613
|
-
const
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1672
|
+
const {
|
|
1673
|
+
item,
|
|
1674
|
+
props,
|
|
1675
|
+
isSelectedAll,
|
|
1676
|
+
value,
|
|
1677
|
+
onSelect,
|
|
1678
|
+
setValue,
|
|
1679
|
+
onOpenChange
|
|
1680
|
+
} = contextProps;
|
|
1681
|
+
const {
|
|
1682
|
+
single,
|
|
1683
|
+
isPopup,
|
|
1684
|
+
renderItemContent,
|
|
1685
|
+
valueKey
|
|
1686
|
+
} = props;
|
|
1624
1687
|
const isChecked = value.some(target => target[valueKey] === item[valueKey]);
|
|
1625
1688
|
return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
|
|
1626
1689
|
className: classnames__default["default"](style$1['default-list-item'], 'select-tree-item', {
|
|
@@ -1658,20 +1721,26 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1658
1721
|
}, isChecked && /*#__PURE__*/React__default["default"].createElement(icons.CheckOutlined, null)));
|
|
1659
1722
|
},
|
|
1660
1723
|
renderTree: contextProps => {
|
|
1661
|
-
const
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
treeData
|
|
1724
|
+
const {
|
|
1725
|
+
props,
|
|
1726
|
+
isSelectedAll,
|
|
1727
|
+
data
|
|
1728
|
+
} = contextProps;
|
|
1729
|
+
const {
|
|
1730
|
+
renderItem,
|
|
1731
|
+
valueKey,
|
|
1732
|
+
labelKey,
|
|
1733
|
+
childrenKey,
|
|
1734
|
+
parentKey
|
|
1735
|
+
} = props;
|
|
1736
|
+
const {
|
|
1737
|
+
treeData,
|
|
1738
|
+
ids
|
|
1739
|
+
} = parseTreeData(data, {
|
|
1740
|
+
valueKey,
|
|
1741
|
+
parentKey,
|
|
1742
|
+
childrenKey
|
|
1743
|
+
});
|
|
1675
1744
|
if (!(treeData && treeData.length > 0)) {
|
|
1676
1745
|
return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, null);
|
|
1677
1746
|
}
|
|
@@ -1702,21 +1771,25 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1702
1771
|
return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
|
|
1703
1772
|
ref: ref
|
|
1704
1773
|
}), targetProps => {
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1774
|
+
const {
|
|
1775
|
+
props,
|
|
1776
|
+
value,
|
|
1777
|
+
onOpenChange,
|
|
1778
|
+
isMobile,
|
|
1779
|
+
open
|
|
1780
|
+
} = targetProps;
|
|
1781
|
+
const {
|
|
1782
|
+
footer,
|
|
1783
|
+
isPopup,
|
|
1784
|
+
valueKey,
|
|
1785
|
+
single,
|
|
1786
|
+
allowSelectedAll,
|
|
1787
|
+
showSelectedTag,
|
|
1788
|
+
api,
|
|
1789
|
+
options,
|
|
1790
|
+
renderTree,
|
|
1791
|
+
selectedAllValue
|
|
1792
|
+
} = props;
|
|
1720
1793
|
const components = {
|
|
1721
1794
|
selectedAll: !single && allowSelectedAll && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1722
1795
|
className: classnames__default["default"](style$1['selected-all'], 'select-tree-selected-all', {
|
|
@@ -1728,14 +1801,18 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1728
1801
|
options
|
|
1729
1802
|
},
|
|
1730
1803
|
loader: _ref4 => {
|
|
1731
|
-
let
|
|
1804
|
+
let {
|
|
1805
|
+
data
|
|
1806
|
+
} = _ref4;
|
|
1732
1807
|
return data.options;
|
|
1733
1808
|
}
|
|
1734
1809
|
} : api), {
|
|
1735
1810
|
ref: fetchListRef,
|
|
1736
1811
|
render: _ref5 => {
|
|
1737
|
-
let
|
|
1738
|
-
|
|
1812
|
+
let {
|
|
1813
|
+
data,
|
|
1814
|
+
...fetchProps
|
|
1815
|
+
} = _ref5;
|
|
1739
1816
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
1740
1817
|
const treeContent = renderTree(Object.assign({}, fetchProps, targetProps, {
|
|
1741
1818
|
isSelectedAll,
|
|
@@ -2021,39 +2098,37 @@ const CustomMenu = ({
|
|
|
2021
2098
|
});
|
|
2022
2099
|
};
|
|
2023
2100
|
|
|
2024
|
-
const _excluded = ["options", "value", "onChange", "defaultValue", "maxLength", "single", "onlyAllowLastLevel", "openLoadData", "onLoadMore", "parentIdKey", "menuItemWidth", "isPopup", "searchPlaceholder", "onSearch", "valueKey", "labelKey", "placeholder", "disabled", "size", "overlayWidth"];
|
|
2025
2101
|
const numberToPx = val => {
|
|
2026
|
-
return typeof val === 'number' ? val
|
|
2102
|
+
return typeof val === 'number' ? `${val}px` : val;
|
|
2027
2103
|
};
|
|
2028
2104
|
|
|
2029
2105
|
// 级联选择内容组件
|
|
2030
2106
|
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];
|
|
2107
|
+
let {
|
|
2108
|
+
options,
|
|
2109
|
+
value,
|
|
2110
|
+
setValue,
|
|
2111
|
+
maxLength,
|
|
2112
|
+
single,
|
|
2113
|
+
onlyAllowLastLevel,
|
|
2114
|
+
openLoadData,
|
|
2115
|
+
onLoadMore,
|
|
2116
|
+
parentIdKey,
|
|
2117
|
+
menuItemWidth,
|
|
2118
|
+
isPopup,
|
|
2119
|
+
searchPlaceholder,
|
|
2120
|
+
onSearch,
|
|
2121
|
+
valueKey,
|
|
2122
|
+
labelKey,
|
|
2123
|
+
onOpenChange,
|
|
2124
|
+
open,
|
|
2125
|
+
isMobile
|
|
2126
|
+
} = _ref;
|
|
2127
|
+
const {
|
|
2128
|
+
message
|
|
2129
|
+
} = antd.App.useApp();
|
|
2130
|
+
const [searchText, setSearchText] = React.useState('');
|
|
2131
|
+
const [loading, setLoading] = React.useState(false);
|
|
2057
2132
|
// 移动端弹窗内不用 SimpleBar,改原生滚动
|
|
2058
2133
|
const ScrollBox = isMobile ? 'div' : SimpleBar__default["default"];
|
|
2059
2134
|
|
|
@@ -2065,13 +2140,15 @@ const CascaderInner = _ref => {
|
|
|
2065
2140
|
parentId = null;
|
|
2066
2141
|
}
|
|
2067
2142
|
items.forEach(item => {
|
|
2068
|
-
const node =
|
|
2143
|
+
const node = {
|
|
2144
|
+
...item,
|
|
2069
2145
|
id: item[valueKey],
|
|
2070
2146
|
label: item[labelKey],
|
|
2071
2147
|
parentId
|
|
2072
|
-
}
|
|
2148
|
+
};
|
|
2073
2149
|
if (item.children && item.children.length > 0) {
|
|
2074
|
-
node.children = item.children.map(child =>
|
|
2150
|
+
node.children = item.children.map(child => ({
|
|
2151
|
+
...child,
|
|
2075
2152
|
id: child[valueKey],
|
|
2076
2153
|
label: child[labelKey],
|
|
2077
2154
|
parentId: node.id
|
|
@@ -2091,25 +2168,23 @@ const CascaderInner = _ref => {
|
|
|
2091
2168
|
}, [mapping]);
|
|
2092
2169
|
|
|
2093
2170
|
// 当前选中的列
|
|
2094
|
-
const
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2171
|
+
const [selectedIds, setSelectedIds] = React.useState(() => {
|
|
2172
|
+
const initValue = value.find(item => {
|
|
2173
|
+
const id = typeof item === 'object' ? item[valueKey] : item;
|
|
2174
|
+
return !!mapping.get(id);
|
|
2175
|
+
});
|
|
2176
|
+
if (initValue) {
|
|
2177
|
+
const id = typeof initValue === 'object' ? initValue[valueKey] : initValue;
|
|
2178
|
+
return treeUtils.getSelectedQueue(id);
|
|
2179
|
+
}
|
|
2103
2180
|
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
selectedIds = _useState3[0],
|
|
2112
|
-
setSelectedIds = _useState3[1];
|
|
2181
|
+
// 默认选中第一列
|
|
2182
|
+
const firstNode = Array.from(mapping.values()).find(item => isNil__default["default"](item.parentId));
|
|
2183
|
+
if (firstNode) {
|
|
2184
|
+
return treeUtils.getSelectedQueue(firstNode.id);
|
|
2185
|
+
}
|
|
2186
|
+
return [];
|
|
2187
|
+
});
|
|
2113
2188
|
|
|
2114
2189
|
// 当 Modal 打开时,根据 value 重新初始化 selectedIds
|
|
2115
2190
|
const prevOpenRef = React.useRef(open);
|
|
@@ -2191,7 +2266,7 @@ const CascaderInner = _ref => {
|
|
|
2191
2266
|
return checked ? treeUtils.setNodeChecked(id, currentIds) : treeUtils.setNodeUnchecked(id, currentIds);
|
|
2192
2267
|
})();
|
|
2193
2268
|
if (newValue.length > maxLength) {
|
|
2194
|
-
message.error(
|
|
2269
|
+
message.error(`最多只能选择 ${maxLength} 项`);
|
|
2195
2270
|
return;
|
|
2196
2271
|
}
|
|
2197
2272
|
|
|
@@ -2199,10 +2274,11 @@ const CascaderInner = _ref => {
|
|
|
2199
2274
|
const newValues = newValue.map(id => {
|
|
2200
2275
|
const node = mapping.get(id);
|
|
2201
2276
|
// 返回完整的节点数据,保留所有原始字段
|
|
2202
|
-
return node ?
|
|
2277
|
+
return node ? {
|
|
2278
|
+
...node,
|
|
2203
2279
|
[valueKey]: node.id,
|
|
2204
2280
|
[labelKey]: node.label
|
|
2205
|
-
}
|
|
2281
|
+
} : null;
|
|
2206
2282
|
}).filter(Boolean);
|
|
2207
2283
|
const finalValue = single && newValues.length > 0 ? [last__default["default"](newValues)] : newValues;
|
|
2208
2284
|
setValue(finalValue);
|
|
@@ -2309,7 +2385,7 @@ const CascaderInner = _ref => {
|
|
|
2309
2385
|
}, selectedIds.map((selectedId, index) => {
|
|
2310
2386
|
const selectNode = mapping.get(selectedId);
|
|
2311
2387
|
const siblingNodes = treeUtils.getSiblingNode(selectedId);
|
|
2312
|
-
const isLastLevel = !isNotLastNode(selectNode
|
|
2388
|
+
const isLastLevel = !isNotLastNode(selectNode?.id) && index > 0;
|
|
2313
2389
|
return /*#__PURE__*/React__default["default"].createElement(ScrollBox, {
|
|
2314
2390
|
key: selectedId || index,
|
|
2315
2391
|
className: classnames__default["default"](style['content-item'], {
|
|
@@ -2319,17 +2395,21 @@ const CascaderInner = _ref => {
|
|
|
2319
2395
|
className: style['menu'],
|
|
2320
2396
|
selectedKeys: currentIds,
|
|
2321
2397
|
onSelect: _ref2 => {
|
|
2322
|
-
let
|
|
2398
|
+
let {
|
|
2399
|
+
key
|
|
2400
|
+
} = _ref2;
|
|
2323
2401
|
const node = mapping.get(key);
|
|
2324
2402
|
if (!node) return;
|
|
2325
|
-
const
|
|
2326
|
-
checked
|
|
2403
|
+
const {
|
|
2404
|
+
checked
|
|
2405
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2327
2406
|
onCheckedChange(!checked, node.id);
|
|
2328
2407
|
},
|
|
2329
2408
|
items: siblingNodes.map(node => {
|
|
2330
|
-
const
|
|
2331
|
-
checked
|
|
2332
|
-
indeterminate
|
|
2409
|
+
const {
|
|
2410
|
+
checked,
|
|
2411
|
+
indeterminate
|
|
2412
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2333
2413
|
return {
|
|
2334
2414
|
key: node.id,
|
|
2335
2415
|
label: /*#__PURE__*/React__default["default"].createElement(antd.Space, {
|
|
@@ -2360,9 +2440,10 @@ const CascaderInner = _ref => {
|
|
|
2360
2440
|
[style['single-mode']]: single
|
|
2361
2441
|
})
|
|
2362
2442
|
}, siblingNodes.map(node => {
|
|
2363
|
-
const
|
|
2364
|
-
checked
|
|
2365
|
-
indeterminate
|
|
2443
|
+
const {
|
|
2444
|
+
checked,
|
|
2445
|
+
indeterminate
|
|
2446
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2366
2447
|
return /*#__PURE__*/React__default["default"].createElement(antd.Checkbox, {
|
|
2367
2448
|
key: node.id,
|
|
2368
2449
|
checked: checked,
|
|
@@ -2373,21 +2454,25 @@ const CascaderInner = _ref => {
|
|
|
2373
2454
|
className: style['menu'],
|
|
2374
2455
|
selectedKeys: index === selectedIds.length - 1 ? [] : selectedIds,
|
|
2375
2456
|
onSelect: _ref3 => {
|
|
2376
|
-
let
|
|
2457
|
+
let {
|
|
2458
|
+
key
|
|
2459
|
+
} = _ref3;
|
|
2377
2460
|
const node = mapping.get(key);
|
|
2378
2461
|
if (!node) return;
|
|
2379
2462
|
if (isNotLastNode(node.id)) {
|
|
2380
2463
|
setSelectedIds(treeUtils.getSelectedQueue(node.id));
|
|
2381
2464
|
} else {
|
|
2382
|
-
const
|
|
2383
|
-
checked
|
|
2465
|
+
const {
|
|
2466
|
+
checked
|
|
2467
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2384
2468
|
onCheckedChange(!checked, node.id);
|
|
2385
2469
|
}
|
|
2386
2470
|
},
|
|
2387
2471
|
items: siblingNodes.map(node => {
|
|
2388
|
-
const
|
|
2389
|
-
checked
|
|
2390
|
-
indeterminate
|
|
2472
|
+
const {
|
|
2473
|
+
checked,
|
|
2474
|
+
indeterminate
|
|
2475
|
+
} = treeUtils.computedCheckboxStatus(node.id, currentIds);
|
|
2391
2476
|
const hasChildren = isNotLastNode(node.id);
|
|
2392
2477
|
|
|
2393
2478
|
// 计算子级选中数量
|
|
@@ -2431,45 +2516,32 @@ const CascaderInner = _ref => {
|
|
|
2431
2516
|
|
|
2432
2517
|
// 主组件
|
|
2433
2518
|
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);
|
|
2519
|
+
let {
|
|
2520
|
+
options = [],
|
|
2521
|
+
value,
|
|
2522
|
+
onChange,
|
|
2523
|
+
defaultValue,
|
|
2524
|
+
maxLength = Number.MAX_VALUE,
|
|
2525
|
+
single = false,
|
|
2526
|
+
onlyAllowLastLevel = false,
|
|
2527
|
+
openLoadData = false,
|
|
2528
|
+
onLoadMore,
|
|
2529
|
+
parentIdKey = 'id',
|
|
2530
|
+
menuItemWidth = 180,
|
|
2531
|
+
isPopup = true,
|
|
2532
|
+
searchPlaceholder,
|
|
2533
|
+
onSearch,
|
|
2534
|
+
valueKey = 'id',
|
|
2535
|
+
labelKey = 'label',
|
|
2536
|
+
placeholder = '请选择',
|
|
2537
|
+
disabled = false,
|
|
2538
|
+
size = 'default',
|
|
2539
|
+
overlayWidth,
|
|
2540
|
+
...props
|
|
2541
|
+
} = _ref4;
|
|
2468
2542
|
// 内部始终使用数组格式处理
|
|
2469
2543
|
// SelectInput 会处理 single 模式的 value 和 onChange 转换
|
|
2470
|
-
const
|
|
2471
|
-
innerValue = _useState4[0],
|
|
2472
|
-
setInnerValue = _useState4[1];
|
|
2544
|
+
const [innerValue, setInnerValue] = React.useState(Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : []);
|
|
2473
2545
|
|
|
2474
2546
|
// currentValue 用于内部处理,始终是数组
|
|
2475
2547
|
const currentValue = React.useMemo(() => {
|
|
@@ -2499,10 +2571,10 @@ const SelectCascader = _ref4 => {
|
|
|
2499
2571
|
// 根据单选/多选模式转换输出格式
|
|
2500
2572
|
if (single) {
|
|
2501
2573
|
// 单选:返回单个对象或 null
|
|
2502
|
-
onChange
|
|
2574
|
+
onChange?.(normalizedValue.length > 0 ? normalizedValue[0] : null);
|
|
2503
2575
|
} else {
|
|
2504
2576
|
// 多选:返回数组
|
|
2505
|
-
onChange
|
|
2577
|
+
onChange?.(normalizedValue);
|
|
2506
2578
|
}
|
|
2507
2579
|
}, [value, onChange, single]);
|
|
2508
2580
|
|
|
@@ -2524,10 +2596,11 @@ const SelectCascader = _ref4 => {
|
|
|
2524
2596
|
if (typeof item === 'object') {
|
|
2525
2597
|
// 优先使用 item[labelKey],然后是 item.label,最后是 item.name
|
|
2526
2598
|
const label = item[labelKey] || item.label || item.name || String(item[valueKey] || '');
|
|
2527
|
-
return
|
|
2599
|
+
return {
|
|
2600
|
+
...item,
|
|
2528
2601
|
[valueKey]: item[valueKey] || item.id,
|
|
2529
2602
|
[labelKey]: label
|
|
2530
|
-
}
|
|
2603
|
+
};
|
|
2531
2604
|
}
|
|
2532
2605
|
// 如果是值,从 options 中查找
|
|
2533
2606
|
const findLabel = items => {
|
|
@@ -2573,10 +2646,11 @@ const SelectCascader = _ref4 => {
|
|
|
2573
2646
|
// 如果已经是对象,确保有标准化的字段
|
|
2574
2647
|
if (typeof item === 'object') {
|
|
2575
2648
|
const label = item[labelKey] || item.label || item.name || String(item[valueKey] || '');
|
|
2576
|
-
return
|
|
2649
|
+
return {
|
|
2650
|
+
...item,
|
|
2577
2651
|
[valueKey]: item[valueKey] || item.id,
|
|
2578
2652
|
[labelKey]: label
|
|
2579
|
-
}
|
|
2653
|
+
};
|
|
2580
2654
|
}
|
|
2581
2655
|
// 如果是值,从 options 中查找
|
|
2582
2656
|
const findLabel = items => {
|
|
@@ -2624,7 +2698,7 @@ const SelectCascader = _ref4 => {
|
|
|
2624
2698
|
|
|
2625
2699
|
Object.defineProperty(exports, 'mergeTreeChildren', {
|
|
2626
2700
|
enumerable: true,
|
|
2627
|
-
get: function () { return
|
|
2701
|
+
get: function () { return TablePage.mergeTreeChildren; }
|
|
2628
2702
|
});
|
|
2629
2703
|
exports.SelectCascader = SelectCascader;
|
|
2630
2704
|
exports.SelectInput = SelectInput;
|