@kne/super-select 0.1.50 → 0.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +0 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +40 -26
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +41 -27
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/dist/index.modern.js
CHANGED
|
@@ -7,9 +7,10 @@ import classnames from 'classnames';
|
|
|
7
7
|
import isEqual from 'lodash/isEqual';
|
|
8
8
|
import last from 'lodash/last';
|
|
9
9
|
import { Tag, Modal, App, Dropdown, Flex, Checkbox, List, Empty, Pagination, Row, Col, Button, Popover, Tree, Space, Badge, Spin } from 'antd';
|
|
10
|
+
import { useZIndex } from 'antd/es/_util/hooks';
|
|
10
11
|
import { CloseCircleFilled, DownOutlined, CheckOutlined, RightOutlined } from '@ant-design/icons';
|
|
11
12
|
import { isNotEmpty } from '@kne/is-empty';
|
|
12
|
-
import {
|
|
13
|
+
import { useScrollElement, usePopupMount, MOBILE_POPUP_MODE } from '@kne/responsive-utils';
|
|
13
14
|
import { createWithIntlProvider, useIntl } from '@kne/react-intl';
|
|
14
15
|
import { useOverflowItems } from '@kne/overflow-items';
|
|
15
16
|
import 'simplebar-react/dist/simplebar.min.css';
|
|
@@ -187,6 +188,20 @@ const MOBILE_SHEET_MIN_HEIGHT = '30%';
|
|
|
187
188
|
const MOBILE_MASK_Z_INDEX = 1000;
|
|
188
189
|
const MOBILE_POPUP_Z_INDEX = 1050;
|
|
189
190
|
const MASK_ANIMATION_DURATION = 180;
|
|
191
|
+
|
|
192
|
+
/** Modal 内半屏 sheet 对齐 antd Dropdown:消费 zIndexContext,保留移动端 UX */
|
|
193
|
+
const resolveMobileSheetZIndex = popupZIndex => {
|
|
194
|
+
if (popupZIndex == null) {
|
|
195
|
+
return {
|
|
196
|
+
maskZIndex: MOBILE_MASK_Z_INDEX,
|
|
197
|
+
panelZIndex: MOBILE_POPUP_Z_INDEX
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
maskZIndex: popupZIndex - 1,
|
|
202
|
+
panelZIndex: popupZIndex
|
|
203
|
+
};
|
|
204
|
+
};
|
|
190
205
|
let parentScrollLockCount = 0;
|
|
191
206
|
let parentScrollLocked = [];
|
|
192
207
|
const lockParentScroll = getScrollElements => {
|
|
@@ -294,7 +309,8 @@ const MobileSheetMask = ({
|
|
|
294
309
|
open,
|
|
295
310
|
mountNode,
|
|
296
311
|
fixedModeClass,
|
|
297
|
-
onClose
|
|
312
|
+
onClose,
|
|
313
|
+
zIndex: _zIndex = MOBILE_MASK_Z_INDEX
|
|
298
314
|
}) => {
|
|
299
315
|
const [renderMask, setRenderMask] = useState(false);
|
|
300
316
|
const [maskClosing, setMaskClosing] = useState(false);
|
|
@@ -320,7 +336,7 @@ const MobileSheetMask = ({
|
|
|
320
336
|
return createPortal(/*#__PURE__*/React.createElement("div", {
|
|
321
337
|
className: classnames(style$6['mobile-sheet-mask'], maskClosing && style$6['mobile-sheet-mask-leave'], fixedModeClass),
|
|
322
338
|
style: {
|
|
323
|
-
zIndex:
|
|
339
|
+
zIndex: _zIndex
|
|
324
340
|
},
|
|
325
341
|
onClick: onClose,
|
|
326
342
|
onTouchMove: e => {
|
|
@@ -360,7 +376,8 @@ const MobileSheetPanel = ({
|
|
|
360
376
|
confirmText,
|
|
361
377
|
onCancel,
|
|
362
378
|
onConfirm,
|
|
363
|
-
children
|
|
379
|
+
children,
|
|
380
|
+
zIndex: _zIndex2 = MOBILE_POPUP_Z_INDEX
|
|
364
381
|
}) => {
|
|
365
382
|
if (!open || !mountNode) {
|
|
366
383
|
return null;
|
|
@@ -368,7 +385,7 @@ const MobileSheetPanel = ({
|
|
|
368
385
|
return createPortal(/*#__PURE__*/React.createElement("div", {
|
|
369
386
|
className: classnames(style$6['mobile-sheet-popup'], style$6['mobile-sheet-portal'], fixedModeClass, overlayClassName),
|
|
370
387
|
style: {
|
|
371
|
-
zIndex:
|
|
388
|
+
zIndex: _zIndex2,
|
|
372
389
|
maxHeight: MOBILE_SHEET_MAX_HEIGHT,
|
|
373
390
|
minHeight: MOBILE_SHEET_MIN_HEIGHT
|
|
374
391
|
},
|
|
@@ -447,7 +464,8 @@ const SelectInput = createWithIntlProvider({
|
|
|
447
464
|
isMobile,
|
|
448
465
|
getPopupContainer,
|
|
449
466
|
formatMessage,
|
|
450
|
-
fixedModeClass
|
|
467
|
+
fixedModeClass,
|
|
468
|
+
mobileSheetZIndex
|
|
451
469
|
} = contextProps;
|
|
452
470
|
const {
|
|
453
471
|
placeholder,
|
|
@@ -458,11 +476,16 @@ const SelectInput = createWithIntlProvider({
|
|
|
458
476
|
if (isMobile && !disableMobileSheet) {
|
|
459
477
|
const mountNode = typeof getPopupContainer === 'function' ? getPopupContainer() : null;
|
|
460
478
|
const closeWithoutCommit = () => onOpenChange(false);
|
|
479
|
+
const {
|
|
480
|
+
maskZIndex,
|
|
481
|
+
panelZIndex
|
|
482
|
+
} = mobileSheetZIndex || resolveMobileSheetZIndex();
|
|
461
483
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MobileSheetMask, {
|
|
462
484
|
open: open,
|
|
463
485
|
mountNode: mountNode,
|
|
464
486
|
fixedModeClass: fixedModeClass,
|
|
465
|
-
onClose: closeWithoutCommit
|
|
487
|
+
onClose: closeWithoutCommit,
|
|
488
|
+
zIndex: maskZIndex
|
|
466
489
|
}), /*#__PURE__*/React.createElement(MobileSheetPanel, {
|
|
467
490
|
open: open,
|
|
468
491
|
mountNode: mountNode,
|
|
@@ -479,7 +502,8 @@ const SelectInput = createWithIntlProvider({
|
|
|
479
502
|
onConfirm: () => {
|
|
480
503
|
onComplete();
|
|
481
504
|
onOpenChange(false);
|
|
482
|
-
}
|
|
505
|
+
},
|
|
506
|
+
zIndex: panelZIndex
|
|
483
507
|
}, open ? children(contextProps) : null));
|
|
484
508
|
}
|
|
485
509
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
@@ -531,7 +555,6 @@ const SelectInput = createWithIntlProvider({
|
|
|
531
555
|
size,
|
|
532
556
|
disableMobileSheet
|
|
533
557
|
} = props;
|
|
534
|
-
const getPopupContainerDefault = usePopupContainer();
|
|
535
558
|
const getScrollElement = useScrollElement();
|
|
536
559
|
const wrapCustomGetPopupContainer = useMemo(() => {
|
|
537
560
|
if (typeof getPopupContainerProp === 'function') {
|
|
@@ -545,12 +568,14 @@ const SelectInput = createWithIntlProvider({
|
|
|
545
568
|
const {
|
|
546
569
|
isMobile,
|
|
547
570
|
fixedModeClass,
|
|
548
|
-
getPopupContainer:
|
|
571
|
+
getPopupContainer: resolveGetPopupContainer,
|
|
549
572
|
anchorRef
|
|
550
|
-
} =
|
|
573
|
+
} = usePopupMount({
|
|
551
574
|
cover: 'viewport',
|
|
552
575
|
getPopupContainer: wrapCustomGetPopupContainer
|
|
553
576
|
});
|
|
577
|
+
const [antdPopupZIndex] = useZIndex('Dropdown');
|
|
578
|
+
const mobileSheetZIndex = useMemo(() => resolveMobileSheetZIndex(antdPopupZIndex), [antdPopupZIndex]);
|
|
554
579
|
const useMobileSheet = isMobile && !disableMobileSheet;
|
|
555
580
|
const useBoundaryMount = !!(isMobile && fixedModeClass === MOBILE_POPUP_MODE.boundary);
|
|
556
581
|
const transformValue = value => {
|
|
@@ -607,20 +632,6 @@ const SelectInput = createWithIntlProvider({
|
|
|
607
632
|
resizeRef.current = node;
|
|
608
633
|
anchorRef(node);
|
|
609
634
|
}, [anchorRef, resizeRef]);
|
|
610
|
-
const resolveGetPopupContainer = useCallback(triggerNode => {
|
|
611
|
-
if (typeof getPopupContainerProp === 'function') {
|
|
612
|
-
const customContainer = getPopupContainerProp(triggerNode);
|
|
613
|
-
if (customContainer) {
|
|
614
|
-
return customContainer;
|
|
615
|
-
}
|
|
616
|
-
} else if (getPopupContainerProp) {
|
|
617
|
-
return getPopupContainerProp;
|
|
618
|
-
}
|
|
619
|
-
if (useMobileSheet) {
|
|
620
|
-
return getSheetPopupContainer(triggerNode);
|
|
621
|
-
}
|
|
622
|
-
return getPopupContainerDefault(triggerNode);
|
|
623
|
-
}, [getPopupContainerDefault, getPopupContainerProp, getSheetPopupContainer, useMobileSheet]);
|
|
624
635
|
|
|
625
636
|
// 打开时再取挂载节点,避免落到错误容器
|
|
626
637
|
useLayoutEffect(() => {
|
|
@@ -722,6 +733,7 @@ const SelectInput = createWithIntlProvider({
|
|
|
722
733
|
children,
|
|
723
734
|
isMobile,
|
|
724
735
|
useBoundaryMount,
|
|
736
|
+
mobileSheetZIndex,
|
|
725
737
|
fixedModeClass,
|
|
726
738
|
getPopupContainer: resolveGetPopupContainer,
|
|
727
739
|
formatMessage
|
|
@@ -815,7 +827,8 @@ const SelectInput = createWithIntlProvider({
|
|
|
815
827
|
open: sheetOpen,
|
|
816
828
|
mountNode: popupMountNode,
|
|
817
829
|
fixedModeClass: fixedModeClass,
|
|
818
|
-
onClose: closeWithoutCommit
|
|
830
|
+
onClose: closeWithoutCommit,
|
|
831
|
+
zIndex: mobileSheetZIndex.maskZIndex
|
|
819
832
|
}), /*#__PURE__*/React.createElement(MobileSheetPanel, {
|
|
820
833
|
open: sheetOpen,
|
|
821
834
|
mountNode: popupMountNode,
|
|
@@ -832,7 +845,8 @@ const SelectInput = createWithIntlProvider({
|
|
|
832
845
|
onConfirm: () => {
|
|
833
846
|
onComplete();
|
|
834
847
|
setOpen(false);
|
|
835
|
-
}
|
|
848
|
+
},
|
|
849
|
+
zIndex: mobileSheetZIndex.panelZIndex
|
|
836
850
|
}, sheetOpen ? children(sheetContextProps) : null));
|
|
837
851
|
}));
|
|
838
852
|
}
|