@kne/super-select 0.1.50 → 0.1.54
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 +32 -0
- package/dist/index.css +121 -26
- package/dist/index.css.map +1 -1
- package/dist/index.js +219 -213
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +90 -45
- package/dist/index.modern.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var classnames = require('classnames');
|
|
|
7
7
|
var isEqual = require('lodash/isEqual');
|
|
8
8
|
var last = require('lodash/last');
|
|
9
9
|
var antd = require('antd');
|
|
10
|
+
var hooks = require('antd/es/_util/hooks');
|
|
10
11
|
var icons = require('@ant-design/icons');
|
|
11
12
|
var isEmpty = require('@kne/is-empty');
|
|
12
13
|
var responsiveUtils = require('@kne/responsive-utils');
|
|
@@ -146,7 +147,7 @@ const TagOverflowInner = ({
|
|
|
146
147
|
"data-tag-measure": true
|
|
147
148
|
}, /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
148
149
|
closable: true,
|
|
149
|
-
|
|
150
|
+
variant: "filled",
|
|
150
151
|
className: style$6['tag-item'],
|
|
151
152
|
style: {
|
|
152
153
|
'--max-tag-width': `${maxTagWidth}px`,
|
|
@@ -169,7 +170,7 @@ const TagOverflowInner = ({
|
|
|
169
170
|
}, displayTags.map(item => /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
170
171
|
key: item[valueKey],
|
|
171
172
|
closable: true,
|
|
172
|
-
|
|
173
|
+
variant: "filled",
|
|
173
174
|
className: style$6['tag-item'],
|
|
174
175
|
style: {
|
|
175
176
|
'--max-tag-width': `${maxTagWidth}px`,
|
|
@@ -192,6 +193,20 @@ const MOBILE_SHEET_MIN_HEIGHT = '30%';
|
|
|
192
193
|
const MOBILE_MASK_Z_INDEX = 1000;
|
|
193
194
|
const MOBILE_POPUP_Z_INDEX = 1050;
|
|
194
195
|
const MASK_ANIMATION_DURATION = 180;
|
|
196
|
+
|
|
197
|
+
/** Modal 内半屏 sheet 对齐 antd Dropdown:消费 zIndexContext,保留移动端 UX */
|
|
198
|
+
const resolveMobileSheetZIndex = popupZIndex => {
|
|
199
|
+
if (popupZIndex == null) {
|
|
200
|
+
return {
|
|
201
|
+
maskZIndex: MOBILE_MASK_Z_INDEX,
|
|
202
|
+
panelZIndex: MOBILE_POPUP_Z_INDEX
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
maskZIndex: popupZIndex - 1,
|
|
207
|
+
panelZIndex: popupZIndex
|
|
208
|
+
};
|
|
209
|
+
};
|
|
195
210
|
let parentScrollLockCount = 0;
|
|
196
211
|
let parentScrollLocked = [];
|
|
197
212
|
const lockParentScroll = getScrollElements => {
|
|
@@ -225,11 +240,10 @@ const lockParentScroll = getScrollElements => {
|
|
|
225
240
|
return () => {
|
|
226
241
|
parentScrollLockCount = Math.max(0, parentScrollLockCount - 1);
|
|
227
242
|
if (parentScrollLockCount === 0) {
|
|
228
|
-
parentScrollLocked.forEach(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
} = _ref;
|
|
243
|
+
parentScrollLocked.forEach(({
|
|
244
|
+
el,
|
|
245
|
+
prev
|
|
246
|
+
}) => {
|
|
233
247
|
el.style.overflow = prev.overflow;
|
|
234
248
|
el.style.overscrollBehavior = prev.overscrollBehavior;
|
|
235
249
|
});
|
|
@@ -261,11 +275,10 @@ const pxToNumber = value => {
|
|
|
261
275
|
const DEFAULT_OVERLAY_MIN_WIDTH = 300;
|
|
262
276
|
|
|
263
277
|
// 与 Modal 模式一致:面板内用临时 value,确认后才写回
|
|
264
|
-
const ModalContent =
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
} = _ref2;
|
|
278
|
+
const ModalContent = ({
|
|
279
|
+
children: renderContent,
|
|
280
|
+
...others
|
|
281
|
+
}) => {
|
|
269
282
|
const {
|
|
270
283
|
open,
|
|
271
284
|
value: propsValue
|
|
@@ -295,13 +308,13 @@ const ModalContent = _ref2 => {
|
|
|
295
308
|
value: contextProps
|
|
296
309
|
}, renderContent(contextProps));
|
|
297
310
|
};
|
|
298
|
-
const MobileSheetMask =
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
311
|
+
const MobileSheetMask = ({
|
|
312
|
+
open,
|
|
313
|
+
mountNode,
|
|
314
|
+
fixedModeClass,
|
|
315
|
+
onClose,
|
|
316
|
+
zIndex = MOBILE_MASK_Z_INDEX
|
|
317
|
+
}) => {
|
|
305
318
|
const [renderMask, setRenderMask] = React.useState(false);
|
|
306
319
|
const [maskClosing, setMaskClosing] = React.useState(false);
|
|
307
320
|
React.useEffect(() => {
|
|
@@ -324,9 +337,9 @@ const MobileSheetMask = _ref3 => {
|
|
|
324
337
|
return null;
|
|
325
338
|
}
|
|
326
339
|
return reactDom.createPortal(/*#__PURE__*/React__default["default"].createElement("div", {
|
|
327
|
-
className: classnames__default["default"](style$6['mobile-sheet-mask'], maskClosing && style$6['mobile-sheet-mask-leave'], fixedModeClass),
|
|
340
|
+
className: classnames__default["default"](style$6['mobile-sheet-mask'], 'select-mobile-sheet-mask', maskClosing && style$6['mobile-sheet-mask-leave'], fixedModeClass),
|
|
328
341
|
style: {
|
|
329
|
-
zIndex
|
|
342
|
+
zIndex
|
|
330
343
|
},
|
|
331
344
|
onClick: onClose,
|
|
332
345
|
onTouchMove: e => {
|
|
@@ -334,49 +347,48 @@ const MobileSheetMask = _ref3 => {
|
|
|
334
347
|
}
|
|
335
348
|
}), mountNode);
|
|
336
349
|
};
|
|
337
|
-
const MobileSheetHeader =
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
} = _ref4;
|
|
350
|
+
const MobileSheetHeader = ({
|
|
351
|
+
title,
|
|
352
|
+
cancelText,
|
|
353
|
+
confirmText,
|
|
354
|
+
onCancel,
|
|
355
|
+
onConfirm
|
|
356
|
+
}) => {
|
|
345
357
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
346
|
-
className: style$6['mobile-sheet-header']
|
|
358
|
+
className: classnames__default["default"](style$6['mobile-sheet-header'], 'select-mobile-sheet-header')
|
|
347
359
|
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
348
360
|
type: "button",
|
|
349
|
-
className: style$6['mobile-sheet-action'],
|
|
361
|
+
className: classnames__default["default"](style$6['mobile-sheet-action'], 'select-mobile-sheet-cancel'),
|
|
350
362
|
onClick: onCancel
|
|
351
363
|
}, cancelText), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
352
|
-
className: style$6['mobile-sheet-title'],
|
|
364
|
+
className: classnames__default["default"](style$6['mobile-sheet-title'], 'select-mobile-sheet-title'),
|
|
353
365
|
title: title
|
|
354
366
|
}, title), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
355
367
|
type: "button",
|
|
356
|
-
className: classnames__default["default"](style$6['mobile-sheet-action'], style$6['mobile-sheet-confirm']),
|
|
368
|
+
className: classnames__default["default"](style$6['mobile-sheet-action'], style$6['mobile-sheet-confirm'], 'select-mobile-sheet-confirm'),
|
|
357
369
|
onClick: onConfirm
|
|
358
370
|
}, confirmText));
|
|
359
371
|
};
|
|
360
|
-
const MobileSheetPanel =
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
372
|
+
const MobileSheetPanel = ({
|
|
373
|
+
open,
|
|
374
|
+
mountNode,
|
|
375
|
+
fixedModeClass,
|
|
376
|
+
overlayClassName,
|
|
377
|
+
title,
|
|
378
|
+
cancelText,
|
|
379
|
+
confirmText,
|
|
380
|
+
onCancel,
|
|
381
|
+
onConfirm,
|
|
382
|
+
children,
|
|
383
|
+
zIndex = MOBILE_POPUP_Z_INDEX
|
|
384
|
+
}) => {
|
|
373
385
|
if (!open || !mountNode) {
|
|
374
386
|
return null;
|
|
375
387
|
}
|
|
376
388
|
return reactDom.createPortal(/*#__PURE__*/React__default["default"].createElement("div", {
|
|
377
|
-
className: classnames__default["default"](style$6['mobile-sheet-popup'], style$6['mobile-sheet-portal'], fixedModeClass, overlayClassName),
|
|
389
|
+
className: classnames__default["default"](style$6['mobile-sheet-popup'], style$6['mobile-sheet-portal'], 'select-mobile-sheet', fixedModeClass, overlayClassName),
|
|
378
390
|
style: {
|
|
379
|
-
zIndex
|
|
391
|
+
zIndex,
|
|
380
392
|
maxHeight: MOBILE_SHEET_MAX_HEIGHT,
|
|
381
393
|
minHeight: MOBILE_SHEET_MIN_HEIGHT
|
|
382
394
|
},
|
|
@@ -455,7 +467,8 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
455
467
|
isMobile,
|
|
456
468
|
getPopupContainer,
|
|
457
469
|
formatMessage,
|
|
458
|
-
fixedModeClass
|
|
470
|
+
fixedModeClass,
|
|
471
|
+
mobileSheetZIndex
|
|
459
472
|
} = contextProps;
|
|
460
473
|
const {
|
|
461
474
|
placeholder,
|
|
@@ -466,11 +479,16 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
466
479
|
if (isMobile && !disableMobileSheet) {
|
|
467
480
|
const mountNode = typeof getPopupContainer === 'function' ? getPopupContainer() : null;
|
|
468
481
|
const closeWithoutCommit = () => onOpenChange(false);
|
|
482
|
+
const {
|
|
483
|
+
maskZIndex,
|
|
484
|
+
panelZIndex
|
|
485
|
+
} = mobileSheetZIndex || resolveMobileSheetZIndex();
|
|
469
486
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(MobileSheetMask, {
|
|
470
487
|
open: open,
|
|
471
488
|
mountNode: mountNode,
|
|
472
489
|
fixedModeClass: fixedModeClass,
|
|
473
|
-
onClose: closeWithoutCommit
|
|
490
|
+
onClose: closeWithoutCommit,
|
|
491
|
+
zIndex: maskZIndex
|
|
474
492
|
}), /*#__PURE__*/React__default["default"].createElement(MobileSheetPanel, {
|
|
475
493
|
open: open,
|
|
476
494
|
mountNode: mountNode,
|
|
@@ -487,14 +505,14 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
487
505
|
onConfirm: () => {
|
|
488
506
|
onComplete();
|
|
489
507
|
onOpenChange(false);
|
|
490
|
-
}
|
|
508
|
+
},
|
|
509
|
+
zIndex: panelZIndex
|
|
491
510
|
}, open ? children(contextProps) : null));
|
|
492
511
|
}
|
|
493
512
|
return /*#__PURE__*/React__default["default"].createElement(antd.Modal, {
|
|
494
513
|
className: overlayClassName,
|
|
495
514
|
width: 1000,
|
|
496
515
|
open: open,
|
|
497
|
-
destroyOnClose: true,
|
|
498
516
|
destroyOnHidden: true,
|
|
499
517
|
title: placeholder,
|
|
500
518
|
onCancel: () => {
|
|
@@ -539,7 +557,6 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
539
557
|
size,
|
|
540
558
|
disableMobileSheet
|
|
541
559
|
} = props;
|
|
542
|
-
const getPopupContainerDefault = responsiveUtils.usePopupContainer();
|
|
543
560
|
const getScrollElement = responsiveUtils.useScrollElement();
|
|
544
561
|
const wrapCustomGetPopupContainer = React.useMemo(() => {
|
|
545
562
|
if (typeof getPopupContainerProp === 'function') {
|
|
@@ -553,12 +570,14 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
553
570
|
const {
|
|
554
571
|
isMobile,
|
|
555
572
|
fixedModeClass,
|
|
556
|
-
getPopupContainer:
|
|
573
|
+
getPopupContainer: resolveGetPopupContainer,
|
|
557
574
|
anchorRef
|
|
558
|
-
} = responsiveUtils.
|
|
575
|
+
} = responsiveUtils.usePopupMount({
|
|
559
576
|
cover: 'viewport',
|
|
560
577
|
getPopupContainer: wrapCustomGetPopupContainer
|
|
561
578
|
});
|
|
579
|
+
const [antdPopupZIndex] = hooks.useZIndex('Dropdown');
|
|
580
|
+
const mobileSheetZIndex = React.useMemo(() => resolveMobileSheetZIndex(antdPopupZIndex), [antdPopupZIndex]);
|
|
562
581
|
const useMobileSheet = isMobile && !disableMobileSheet;
|
|
563
582
|
const useBoundaryMount = !!(isMobile && fixedModeClass === responsiveUtils.MOBILE_POPUP_MODE.boundary);
|
|
564
583
|
const transformValue = value => {
|
|
@@ -615,20 +634,6 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
615
634
|
resizeRef.current = node;
|
|
616
635
|
anchorRef(node);
|
|
617
636
|
}, [anchorRef, resizeRef]);
|
|
618
|
-
const resolveGetPopupContainer = React.useCallback(triggerNode => {
|
|
619
|
-
if (typeof getPopupContainerProp === 'function') {
|
|
620
|
-
const customContainer = getPopupContainerProp(triggerNode);
|
|
621
|
-
if (customContainer) {
|
|
622
|
-
return customContainer;
|
|
623
|
-
}
|
|
624
|
-
} else if (getPopupContainerProp) {
|
|
625
|
-
return getPopupContainerProp;
|
|
626
|
-
}
|
|
627
|
-
if (useMobileSheet) {
|
|
628
|
-
return getSheetPopupContainer(triggerNode);
|
|
629
|
-
}
|
|
630
|
-
return getPopupContainerDefault(triggerNode);
|
|
631
|
-
}, [getPopupContainerDefault, getPopupContainerProp, getSheetPopupContainer, useMobileSheet]);
|
|
632
637
|
|
|
633
638
|
// 打开时再取挂载节点,避免落到错误容器
|
|
634
639
|
React.useLayoutEffect(() => {
|
|
@@ -730,14 +735,12 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
730
735
|
children,
|
|
731
736
|
isMobile,
|
|
732
737
|
useBoundaryMount,
|
|
738
|
+
mobileSheetZIndex,
|
|
733
739
|
fixedModeClass,
|
|
734
740
|
getPopupContainer: resolveGetPopupContainer,
|
|
735
741
|
formatMessage
|
|
736
742
|
};
|
|
737
|
-
const inputInnerRender =
|
|
738
|
-
if (props === void 0) {
|
|
739
|
-
props = {};
|
|
740
|
-
}
|
|
743
|
+
const inputInnerRender = (props = {}) => {
|
|
741
744
|
if (typeof contextProps.props.inputRender === 'function') {
|
|
742
745
|
return contextProps.props.inputRender(props, contextProps);
|
|
743
746
|
}
|
|
@@ -826,7 +829,8 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
826
829
|
open: sheetOpen,
|
|
827
830
|
mountNode: popupMountNode,
|
|
828
831
|
fixedModeClass: fixedModeClass,
|
|
829
|
-
onClose: closeWithoutCommit
|
|
832
|
+
onClose: closeWithoutCommit,
|
|
833
|
+
zIndex: mobileSheetZIndex.maskZIndex
|
|
830
834
|
}), /*#__PURE__*/React__default["default"].createElement(MobileSheetPanel, {
|
|
831
835
|
open: sheetOpen,
|
|
832
836
|
mountNode: popupMountNode,
|
|
@@ -843,7 +847,8 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
843
847
|
onConfirm: () => {
|
|
844
848
|
onComplete();
|
|
845
849
|
setOpen(false);
|
|
846
|
-
}
|
|
850
|
+
},
|
|
851
|
+
zIndex: mobileSheetZIndex.panelZIndex
|
|
847
852
|
}, sheetOpen ? children(sheetContextProps) : null));
|
|
848
853
|
}));
|
|
849
854
|
}
|
|
@@ -864,16 +869,18 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
864
869
|
placement: placement,
|
|
865
870
|
arrow: false,
|
|
866
871
|
getPopupContainer: resolveGetPopupContainer,
|
|
867
|
-
|
|
868
|
-
|
|
872
|
+
classNames: {
|
|
873
|
+
root: classnames__default["default"](style$6['overlay'], overlayClassName)
|
|
874
|
+
},
|
|
875
|
+
styles: {
|
|
876
|
+
root: mergedOverlayStyle
|
|
877
|
+
},
|
|
869
878
|
align: align,
|
|
870
879
|
autoAdjustOverflow: autoAdjustOverflow,
|
|
871
880
|
transitionName: transitionName,
|
|
872
881
|
trigger: "click",
|
|
873
|
-
destroyPopupOnHide: true,
|
|
874
882
|
destroyOnHidden: true,
|
|
875
|
-
popupRender: () => overlayContent
|
|
876
|
-
dropdownRender: () => overlayContent
|
|
883
|
+
popupRender: () => overlayContent
|
|
877
884
|
}, /*#__PURE__*/React__default["default"].createElement("span", null, inputInnerRender())) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, inputInnerRender({
|
|
878
885
|
onClick: () => {
|
|
879
886
|
setOpen(true);
|
|
@@ -925,10 +932,7 @@ const SelectedAll = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-s
|
|
|
925
932
|
id: 'selectAll'
|
|
926
933
|
}))));
|
|
927
934
|
});
|
|
928
|
-
const computedIsSelectAll =
|
|
929
|
-
if (valueKey === void 0) {
|
|
930
|
-
valueKey = 'value';
|
|
931
|
-
}
|
|
935
|
+
const computedIsSelectAll = (value, selectedAllValue, valueKey = 'value') => {
|
|
932
936
|
return value?.length === 1 && get__default["default"](value, `[0][${valueKey}]`) === selectedAllValue[valueKey];
|
|
933
937
|
};
|
|
934
938
|
|
|
@@ -967,7 +971,7 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
967
971
|
className: style$4['tag'],
|
|
968
972
|
key: item[valueKey],
|
|
969
973
|
closable: true,
|
|
970
|
-
|
|
974
|
+
variant: "filled",
|
|
971
975
|
onClose: e => {
|
|
972
976
|
e.preventDefault();
|
|
973
977
|
onRemove(item);
|
|
@@ -980,18 +984,16 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
980
984
|
|
|
981
985
|
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
986
|
|
|
983
|
-
const SelectList = React.forwardRef((
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
} = _ref;
|
|
987
|
+
const SelectList = React.forwardRef(({
|
|
988
|
+
children,
|
|
989
|
+
...p
|
|
990
|
+
}, ref) => {
|
|
988
991
|
const fetchListRef = React.useRef(null);
|
|
989
992
|
const props = Object.assign({}, {
|
|
990
|
-
renderItemContent:
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
} = _ref2;
|
|
993
|
+
renderItemContent: ({
|
|
994
|
+
item,
|
|
995
|
+
props
|
|
996
|
+
}) => {
|
|
995
997
|
const {
|
|
996
998
|
labelKey
|
|
997
999
|
} = props;
|
|
@@ -1138,10 +1140,9 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1138
1140
|
options,
|
|
1139
1141
|
searchProps
|
|
1140
1142
|
},
|
|
1141
|
-
loader:
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
} = _ref3;
|
|
1143
|
+
loader: ({
|
|
1144
|
+
data
|
|
1145
|
+
}) => {
|
|
1145
1146
|
const {
|
|
1146
1147
|
options,
|
|
1147
1148
|
searchProps
|
|
@@ -1354,13 +1355,12 @@ const FetchTableContent = ({
|
|
|
1354
1355
|
const FetchTable = Fetch.withFetch(FetchTableContent);
|
|
1355
1356
|
|
|
1356
1357
|
const isEmptyParentKey = value => value == null || value === '';
|
|
1357
|
-
const flattenSelectList = (list,
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
} = _ref;
|
|
1358
|
+
const flattenSelectList = (list, {
|
|
1359
|
+
dataType,
|
|
1360
|
+
rowKey,
|
|
1361
|
+
parentKey,
|
|
1362
|
+
childrenKey
|
|
1363
|
+
}) => {
|
|
1364
1364
|
if (!list || !tableView.isTreeDataType(dataType)) {
|
|
1365
1365
|
return list || [];
|
|
1366
1366
|
}
|
|
@@ -1375,13 +1375,12 @@ const flattenSelectList = (list, _ref) => {
|
|
|
1375
1375
|
childrenKey
|
|
1376
1376
|
}).map(row => row.item);
|
|
1377
1377
|
};
|
|
1378
|
-
const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps,
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
} = _ref2;
|
|
1378
|
+
const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps, {
|
|
1379
|
+
dataType,
|
|
1380
|
+
valueKey,
|
|
1381
|
+
parentKey,
|
|
1382
|
+
childrenKey
|
|
1383
|
+
}) => {
|
|
1385
1384
|
if (typeof getSearchCallback !== 'function') {
|
|
1386
1385
|
return options;
|
|
1387
1386
|
}
|
|
@@ -1560,10 +1559,9 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1560
1559
|
options,
|
|
1561
1560
|
searchProps
|
|
1562
1561
|
},
|
|
1563
|
-
loader:
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
} = _ref3;
|
|
1562
|
+
loader: ({
|
|
1563
|
+
data
|
|
1564
|
+
}) => {
|
|
1567
1565
|
const {
|
|
1568
1566
|
options: nextOptions,
|
|
1569
1567
|
searchProps: nextSearchProps
|
|
@@ -1642,7 +1640,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1642
1640
|
className: style$2['tag'],
|
|
1643
1641
|
key: item[valueKey],
|
|
1644
1642
|
closable: true,
|
|
1645
|
-
|
|
1643
|
+
variant: "filled",
|
|
1646
1644
|
onClose: e => {
|
|
1647
1645
|
e.preventDefault();
|
|
1648
1646
|
onRemove(item);
|
|
@@ -1730,12 +1728,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1730
1728
|
isSelectedAll,
|
|
1731
1729
|
list: mobileProps.displayDataSource || mobileProps.dataSource,
|
|
1732
1730
|
dataSource: mobileProps.dataSource,
|
|
1733
|
-
renderBody:
|
|
1734
|
-
if (nextList === void 0) {
|
|
1735
|
-
nextList = mobileProps.displayDataSource || mobileProps.dataSource;
|
|
1736
|
-
}
|
|
1737
|
-
return mobileProps.renderBody(nextList, nextContext);
|
|
1738
|
-
}
|
|
1731
|
+
renderBody: (nextList = mobileProps.displayDataSource || mobileProps.dataSource, nextContext) => mobileProps.renderBody(nextList, nextContext)
|
|
1739
1732
|
}) : true
|
|
1740
1733
|
}, typeof onLoadChildren === 'function' ? {
|
|
1741
1734
|
onLoadChildren
|
|
@@ -1780,15 +1773,11 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1780
1773
|
|
|
1781
1774
|
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"};
|
|
1782
1775
|
|
|
1783
|
-
const parseTreeData = memoize__default["default"](
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
parentKey,
|
|
1789
|
-
valueKey,
|
|
1790
|
-
childrenKey
|
|
1791
|
-
} = _ref;
|
|
1776
|
+
const parseTreeData = memoize__default["default"]((data = [], {
|
|
1777
|
+
parentKey,
|
|
1778
|
+
valueKey,
|
|
1779
|
+
childrenKey
|
|
1780
|
+
}) => {
|
|
1792
1781
|
const parseTree = output => {
|
|
1793
1782
|
return output.map(node => {
|
|
1794
1783
|
const children = data.filter(item => {
|
|
@@ -1804,21 +1793,19 @@ const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
|
1804
1793
|
ids: data.map(item => item.id)
|
|
1805
1794
|
};
|
|
1806
1795
|
});
|
|
1807
|
-
const SelectTree = React.forwardRef((
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
} = _ref2;
|
|
1796
|
+
const SelectTree = React.forwardRef(({
|
|
1797
|
+
children,
|
|
1798
|
+
...p
|
|
1799
|
+
}, ref) => {
|
|
1812
1800
|
const fetchListRef = React.useRef(null);
|
|
1813
1801
|
const [expandedKeys, setExpandedKeys] = React.useState([]);
|
|
1814
1802
|
const props = Object.assign({}, {
|
|
1815
1803
|
parentKey: 'parentId',
|
|
1816
1804
|
childrenKey: 'children',
|
|
1817
|
-
renderItemContent:
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
} = _ref3;
|
|
1805
|
+
renderItemContent: ({
|
|
1806
|
+
item,
|
|
1807
|
+
props
|
|
1808
|
+
}) => {
|
|
1822
1809
|
const {
|
|
1823
1810
|
labelKey
|
|
1824
1811
|
} = props;
|
|
@@ -1958,19 +1945,15 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1958
1945
|
data: {
|
|
1959
1946
|
options
|
|
1960
1947
|
},
|
|
1961
|
-
loader:
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
} = _ref4;
|
|
1965
|
-
return data.options;
|
|
1966
|
-
}
|
|
1948
|
+
loader: ({
|
|
1949
|
+
data
|
|
1950
|
+
}) => data.options
|
|
1967
1951
|
} : api), {
|
|
1968
1952
|
ref: fetchListRef,
|
|
1969
|
-
render:
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
} = _ref5;
|
|
1953
|
+
render: ({
|
|
1954
|
+
data,
|
|
1955
|
+
...fetchProps
|
|
1956
|
+
}) => {
|
|
1974
1957
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
1975
1958
|
const treeContent = renderTree(Object.assign({}, fetchProps, targetProps, {
|
|
1976
1959
|
isSelectedAll,
|
|
@@ -2224,7 +2207,7 @@ const createTreeUtils = mapping => {
|
|
|
2224
2207
|
};
|
|
2225
2208
|
};
|
|
2226
2209
|
|
|
2227
|
-
var style = {"kne-responsive-boundary":"kne-super-select_5gTKr","kne-responsive-scroll":"kne-super-select_fhAr5","content":"kne-super-select_fHNBt","columns":"kne-super-select_VgpIp","content-item":"kne-super-select_kSkN1","last-level-area":"kne-super-select_1QV-l","is-popup":"kne-super-select_zFwDF","menu":"kne-super-select_s-ON4","scroll-plus-box":"kne-super-select_rIix2","menu-label":"kne-super-select_XAs20","menu-label-text":"kne-super-select_Y8AoQ","menu-item":"kne-super-select_ZwakZ","checkbox-hidden":"kne-super-select_0FUoe","single-mode":"kne-super-select_dahnB","menu-item-icon":"kne-super-select_AZZvN","menu-item-placeholder":"kne-super-select_TudTj","loading":"kne-super-select_ljvZk","search-input":"kne-super-select_FVxuS","scroller":"kne-super-select_vnHAM","is-mobile":"kne-super-select_HjXMw","
|
|
2210
|
+
var style = {"kne-responsive-boundary":"kne-super-select_5gTKr","kne-responsive-scroll":"kne-super-select_fhAr5","content":"kne-super-select_fHNBt","columns":"kne-super-select_VgpIp","content-item":"kne-super-select_kSkN1","last-level-area":"kne-super-select_1QV-l","is-popup":"kne-super-select_zFwDF","menu":"kne-super-select_s-ON4","scroll-plus-box":"kne-super-select_rIix2","menu-label":"kne-super-select_XAs20","menu-label-text":"kne-super-select_Y8AoQ","menu-item":"kne-super-select_ZwakZ","checkbox-hidden":"kne-super-select_0FUoe","single-mode":"kne-super-select_dahnB","menu-item-icon":"kne-super-select_AZZvN","menu-item-placeholder":"kne-super-select_TudTj","loading":"kne-super-select_ljvZk","search-input":"kne-super-select_FVxuS","scroller":"kne-super-select_vnHAM","is-mobile":"kne-super-select_HjXMw","custom-menu":"kne-super-select_OerpL","list":"kne-super-select_iUhv7","is-selected":"kne-super-select_tx4-l","selected":"kne-super-select_OUkpN"};
|
|
2228
2211
|
|
|
2229
2212
|
const CustomMenu = ({
|
|
2230
2213
|
className,
|
|
@@ -2261,27 +2244,26 @@ const numberToPx = val => {
|
|
|
2261
2244
|
};
|
|
2262
2245
|
|
|
2263
2246
|
// 级联选择内容组件
|
|
2264
|
-
const CascaderInner =
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
} = _ref;
|
|
2247
|
+
const CascaderInner = ({
|
|
2248
|
+
options,
|
|
2249
|
+
value,
|
|
2250
|
+
setValue,
|
|
2251
|
+
maxLength,
|
|
2252
|
+
single,
|
|
2253
|
+
onlyAllowLastLevel,
|
|
2254
|
+
openLoadData,
|
|
2255
|
+
onLoadMore,
|
|
2256
|
+
parentIdKey,
|
|
2257
|
+
menuItemWidth,
|
|
2258
|
+
isPopup,
|
|
2259
|
+
searchPlaceholder,
|
|
2260
|
+
onSearch,
|
|
2261
|
+
valueKey,
|
|
2262
|
+
labelKey,
|
|
2263
|
+
onOpenChange,
|
|
2264
|
+
open,
|
|
2265
|
+
isMobile
|
|
2266
|
+
}) => {
|
|
2285
2267
|
const {
|
|
2286
2268
|
message
|
|
2287
2269
|
} = antd.App.useApp();
|
|
@@ -2293,10 +2275,7 @@ const CascaderInner = _ref => {
|
|
|
2293
2275
|
// 构建 mapping
|
|
2294
2276
|
const mapping = React.useMemo(() => {
|
|
2295
2277
|
const map = new Map();
|
|
2296
|
-
const processData =
|
|
2297
|
-
if (parentId === void 0) {
|
|
2298
|
-
parentId = null;
|
|
2299
|
-
}
|
|
2278
|
+
const processData = (items, parentId = null) => {
|
|
2300
2279
|
items.forEach(item => {
|
|
2301
2280
|
const node = {
|
|
2302
2281
|
...item,
|
|
@@ -2367,6 +2346,32 @@ const CascaderInner = _ref => {
|
|
|
2367
2346
|
prevOpenRef.current = open;
|
|
2368
2347
|
}, [open, value, mapping, treeUtils, valueKey, isPopup]);
|
|
2369
2348
|
|
|
2349
|
+
// 移动端多列竖直堆叠:切换后子级列若完全不在可视区,滚动到子级列
|
|
2350
|
+
const scrollerRef = React.useRef(null);
|
|
2351
|
+
const columnsRef = React.useRef(null);
|
|
2352
|
+
const scrollToLevelRef = React.useRef(null);
|
|
2353
|
+
React.useEffect(() => {
|
|
2354
|
+
const level = scrollToLevelRef.current;
|
|
2355
|
+
const scroller = scrollerRef.current;
|
|
2356
|
+
if (!isMobile || level === null || !scroller || !columnsRef.current) {
|
|
2357
|
+
return;
|
|
2358
|
+
}
|
|
2359
|
+
const column = columnsRef.current.children[level];
|
|
2360
|
+
// 懒加载时子级列在数据返回后才渲染
|
|
2361
|
+
if (!column) {
|
|
2362
|
+
return;
|
|
2363
|
+
}
|
|
2364
|
+
scrollToLevelRef.current = null;
|
|
2365
|
+
const scrollerRect = scroller.getBoundingClientRect();
|
|
2366
|
+
const columnRect = column.getBoundingClientRect();
|
|
2367
|
+
if (columnRect.top >= scrollerRect.bottom || columnRect.bottom <= scrollerRect.top) {
|
|
2368
|
+
scroller.scrollTo({
|
|
2369
|
+
top: scroller.scrollTop + columnRect.top - scrollerRect.top,
|
|
2370
|
+
behavior: 'smooth'
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
}, [selectedIds, mapping, isMobile]);
|
|
2374
|
+
|
|
2370
2375
|
// 懒加载支持
|
|
2371
2376
|
const loadMorePropsRef = React.useRef({});
|
|
2372
2377
|
loadMorePropsRef.current = {
|
|
@@ -2532,11 +2537,14 @@ const CascaderInner = _ref => {
|
|
|
2532
2537
|
showSearchButton: !isPopup
|
|
2533
2538
|
}), /*#__PURE__*/React__default["default"].createElement(ScrollBox, _extends({
|
|
2534
2539
|
className: classnames__default["default"](style['scroller'], 'select-cascader-scroller')
|
|
2535
|
-
}, isMobile ? {
|
|
2540
|
+
}, isMobile ? {
|
|
2541
|
+
ref: scrollerRef
|
|
2542
|
+
} : {
|
|
2536
2543
|
options: {
|
|
2537
2544
|
autoHide: false
|
|
2538
2545
|
}
|
|
2539
2546
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2547
|
+
ref: columnsRef,
|
|
2540
2548
|
className: classnames__default["default"](style['columns'], {
|
|
2541
2549
|
[style['is-mobile']]: isMobile
|
|
2542
2550
|
})
|
|
@@ -2552,10 +2560,9 @@ const CascaderInner = _ref => {
|
|
|
2552
2560
|
}, isLastLevel ? isMobile ? /*#__PURE__*/React__default["default"].createElement(CustomMenu, {
|
|
2553
2561
|
className: style['menu'],
|
|
2554
2562
|
selectedKeys: currentIds,
|
|
2555
|
-
onSelect:
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
} = _ref2;
|
|
2563
|
+
onSelect: ({
|
|
2564
|
+
key
|
|
2565
|
+
}) => {
|
|
2559
2566
|
const node = mapping.get(key);
|
|
2560
2567
|
if (!node) return;
|
|
2561
2568
|
const {
|
|
@@ -2611,13 +2618,13 @@ const CascaderInner = _ref => {
|
|
|
2611
2618
|
})) : /*#__PURE__*/React__default["default"].createElement(CustomMenu, {
|
|
2612
2619
|
className: style['menu'],
|
|
2613
2620
|
selectedKeys: index === selectedIds.length - 1 ? [] : selectedIds,
|
|
2614
|
-
onSelect:
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
} = _ref3;
|
|
2621
|
+
onSelect: ({
|
|
2622
|
+
key
|
|
2623
|
+
}) => {
|
|
2618
2624
|
const node = mapping.get(key);
|
|
2619
2625
|
if (!node) return;
|
|
2620
2626
|
if (isNotLastNode(node.id)) {
|
|
2627
|
+
scrollToLevelRef.current = index + 1;
|
|
2621
2628
|
setSelectedIds(treeUtils.getSelectedQueue(node.id));
|
|
2622
2629
|
} else {
|
|
2623
2630
|
const {
|
|
@@ -2673,30 +2680,29 @@ const CascaderInner = _ref => {
|
|
|
2673
2680
|
};
|
|
2674
2681
|
|
|
2675
2682
|
// 主组件
|
|
2676
|
-
const SelectCascader =
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
} = _ref4;
|
|
2683
|
+
const SelectCascader = ({
|
|
2684
|
+
options = [],
|
|
2685
|
+
value,
|
|
2686
|
+
onChange,
|
|
2687
|
+
defaultValue,
|
|
2688
|
+
maxLength = Number.MAX_VALUE,
|
|
2689
|
+
single = false,
|
|
2690
|
+
onlyAllowLastLevel = false,
|
|
2691
|
+
openLoadData = false,
|
|
2692
|
+
onLoadMore,
|
|
2693
|
+
parentIdKey = 'id',
|
|
2694
|
+
menuItemWidth = 180,
|
|
2695
|
+
isPopup = true,
|
|
2696
|
+
searchPlaceholder,
|
|
2697
|
+
onSearch,
|
|
2698
|
+
valueKey = 'id',
|
|
2699
|
+
labelKey = 'label',
|
|
2700
|
+
placeholder = '请选择',
|
|
2701
|
+
disabled = false,
|
|
2702
|
+
size = 'default',
|
|
2703
|
+
overlayWidth,
|
|
2704
|
+
...props
|
|
2705
|
+
}) => {
|
|
2700
2706
|
// 内部始终使用数组格式处理
|
|
2701
2707
|
// SelectInput 会处理 single 模式的 value 和 onChange 转换
|
|
2702
2708
|
const [innerValue, setInnerValue] = React.useState(Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : []);
|