@kne/super-select 0.1.39 → 0.1.41
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 +86 -6
- package/dist/index.css.map +1 -1
- package/dist/index.js +63 -62
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +51 -48
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -3
package/dist/index.modern.js
CHANGED
|
@@ -9,7 +9,7 @@ import last from 'lodash/last';
|
|
|
9
9
|
import { Tag, Modal, App, Dropdown, Flex, Checkbox, List, Empty, Row, Col, Button, Popover, Tree, Space, Badge, Spin } from 'antd';
|
|
10
10
|
import { CloseCircleFilled, DownOutlined, CheckOutlined, RightOutlined } from '@ant-design/icons';
|
|
11
11
|
import { isNotEmpty } from '@kne/is-empty';
|
|
12
|
-
import {
|
|
12
|
+
import { usePopupContainer, useScrollElement, useMobilePopupMount, MOBILE_POPUP_MODE } from '@kne/responsive-utils';
|
|
13
13
|
import { createWithIntlProvider, useIntl } from '@kne/react-intl';
|
|
14
14
|
import 'simplebar-react/dist/simplebar.min.css';
|
|
15
15
|
import get from 'lodash/get';
|
|
@@ -50,7 +50,7 @@ const {
|
|
|
50
50
|
useContext
|
|
51
51
|
} = context;
|
|
52
52
|
|
|
53
|
-
var style$6 = {"kne-responsive-boundary":"kne-super-select_mJpBa","kne-responsive-scroll":"kne-super-select_90VCi","select-input":"kne-super-select_d8lGc","disabled":"kne-super-select_3kjwO","wrap":"kne-super-select_dsTM2","select-input-inner":"kne-super-select_NQoX9","large":"kne-super-select_T8ZX8","small":"kne-super-select_1B72H","is-mobile":"kne-super-select_VoUSp","single-label":"kne-super-select_pL0tE","tag-item":"kne-super-select_lc4o7","tag-label":"kne-super-select_RJmlD","overflow-tag":"kne-super-select_aHua2","measure-layer":"kne-super-select_QoQpC","select-input-icon":"kne-super-select_g8QC-","placeholder":"kne-super-select_r3q69","overlay-content":"kne-super-select_zEqGe","mobile-sheet-body":"kne-super-select_Gmh-5","overlay":"kne-super-select_ybN30","select-input-prefix":"kne-super-select_4Pw75","select-input-suffix":"kne-super-select_Wd4pE","mobile-sheet-mask":"kne-super-select_EOKDm","mobile-sheet-mask-fade-in":"kne-super-select_tWTg9","
|
|
53
|
+
var style$6 = {"kne-responsive-boundary":"kne-super-select_mJpBa","kne-responsive-scroll":"kne-super-select_90VCi","select-input":"kne-super-select_d8lGc","disabled":"kne-super-select_3kjwO","wrap":"kne-super-select_dsTM2","select-input-inner":"kne-super-select_NQoX9","large":"kne-super-select_T8ZX8","small":"kne-super-select_1B72H","is-mobile":"kne-super-select_VoUSp","single-label":"kne-super-select_pL0tE","tag-item":"kne-super-select_lc4o7","tag-label":"kne-super-select_RJmlD","overflow-tag":"kne-super-select_aHua2","measure-layer":"kne-super-select_QoQpC","select-input-icon":"kne-super-select_g8QC-","placeholder":"kne-super-select_r3q69","overlay-content":"kne-super-select_zEqGe","mobile-sheet-body":"kne-super-select_Gmh-5","overlay":"kne-super-select_ybN30","select-input-prefix":"kne-super-select_4Pw75","select-input-suffix":"kne-super-select_Wd4pE","mobile-sheet-mask":"kne-super-select_EOKDm","mobile-sheet-mask-fade-in":"kne-super-select_tWTg9","mobile-sheet-mask-leave":"kne-super-select_UAU38","mobile-sheet-mask-fade-out":"kne-super-select_e3tK2","mobile-sheet-popup":"kne-super-select_x0gT0","mobile-sheet-portal":"kne-super-select_kuA7x","mobile-sheet-header":"kne-super-select_EqRnq","mobile-sheet-title":"kne-super-select_5DU3x","mobile-sheet-action":"kne-super-select_UMAVM","mobile-sheet-confirm":"kne-super-select_Y48cj"};
|
|
54
54
|
|
|
55
55
|
const locale$1 = {
|
|
56
56
|
placeholder: '请选择',
|
|
@@ -170,18 +170,10 @@ const TagOverflowInner = ({
|
|
|
170
170
|
|
|
171
171
|
const _excluded$4 = ["children"];
|
|
172
172
|
const MOBILE_SHEET_MAX_HEIGHT = '80%';
|
|
173
|
+
const MOBILE_SHEET_MIN_HEIGHT = '30%';
|
|
173
174
|
const MOBILE_MASK_Z_INDEX = 1000;
|
|
174
175
|
const MOBILE_POPUP_Z_INDEX = 1050;
|
|
175
176
|
const MASK_ANIMATION_DURATION = 180;
|
|
176
|
-
// example-driver 手机预览外框(container 模式可能被外层 Global 的 viewport Provider 盖掉)
|
|
177
|
-
const EXAMPLE_PHONE_SCROLL_SELECTOR = '.example-driver-device-scroll';
|
|
178
|
-
const EXAMPLE_BOUNDARY_SELECTOR = '.kne-responsive-boundary';
|
|
179
|
-
const findExamplePhoneMountNode = anchor => {
|
|
180
|
-
if (!anchor || typeof anchor.closest !== 'function') {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
return anchor.closest(EXAMPLE_PHONE_SCROLL_SELECTOR) || anchor.closest(EXAMPLE_BOUNDARY_SELECTOR);
|
|
184
|
-
};
|
|
185
177
|
let parentScrollLockCount = 0;
|
|
186
178
|
let parentScrollLocked = [];
|
|
187
179
|
const lockParentScroll = getScrollElements => {
|
|
@@ -262,8 +254,8 @@ const ModalContent = _ref => {
|
|
|
262
254
|
setValue(propsValue);
|
|
263
255
|
}
|
|
264
256
|
}, [open]);
|
|
265
|
-
//
|
|
266
|
-
//
|
|
257
|
+
// 半屏(isPopup=true)拦截内容区 onOpenChange(false),避免单选自动关(由取消/确认关);
|
|
258
|
+
// Modal 模式(isPopup=false)必须放行关闭,否则取消/右上角关不掉
|
|
267
259
|
const contextProps = Object.assign({}, others, {
|
|
268
260
|
value,
|
|
269
261
|
setValue,
|
|
@@ -272,8 +264,9 @@ const ModalContent = _ref => {
|
|
|
272
264
|
onSelect: item => others.onSelect(item, setValue),
|
|
273
265
|
onRemove: item => others.onRemove(item, setValue),
|
|
274
266
|
onOpenChange: nextOpen => {
|
|
275
|
-
|
|
276
|
-
|
|
267
|
+
var _others$props;
|
|
268
|
+
if (nextOpen || ((_others$props = others.props) == null ? void 0 : _others$props.isPopup) === false) {
|
|
269
|
+
others.onOpenChange && others.onOpenChange(!!nextOpen);
|
|
277
270
|
}
|
|
278
271
|
}
|
|
279
272
|
});
|
|
@@ -360,7 +353,8 @@ const MobileSheetPanel = ({
|
|
|
360
353
|
className: classnames(style$6['mobile-sheet-popup'], style$6['mobile-sheet-portal'], fixedModeClass, overlayClassName),
|
|
361
354
|
style: {
|
|
362
355
|
zIndex: MOBILE_POPUP_Z_INDEX,
|
|
363
|
-
maxHeight: MOBILE_SHEET_MAX_HEIGHT
|
|
356
|
+
maxHeight: MOBILE_SHEET_MAX_HEIGHT,
|
|
357
|
+
minHeight: MOBILE_SHEET_MIN_HEIGHT
|
|
364
358
|
},
|
|
365
359
|
onTouchMove: e => {
|
|
366
360
|
// 仅非列表区域阻止穿透;列表滚动容器内允许原生滚动
|
|
@@ -437,7 +431,7 @@ const SelectInput = createWithIntlProvider({
|
|
|
437
431
|
isMobile,
|
|
438
432
|
getPopupContainer,
|
|
439
433
|
formatMessage,
|
|
440
|
-
|
|
434
|
+
fixedModeClass
|
|
441
435
|
} = contextProps;
|
|
442
436
|
const {
|
|
443
437
|
placeholder,
|
|
@@ -446,7 +440,6 @@ const SelectInput = createWithIntlProvider({
|
|
|
446
440
|
disableMobileSheet
|
|
447
441
|
} = props;
|
|
448
442
|
if (isMobile && !disableMobileSheet) {
|
|
449
|
-
const fixedModeClass = useBoundaryMount ? style$6['is-boundary'] : style$6['is-viewport'];
|
|
450
443
|
const mountNode = typeof getPopupContainer === 'function' ? getPopupContainer() : null;
|
|
451
444
|
const closeWithoutCommit = () => onOpenChange(false);
|
|
452
445
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MobileSheetMask, {
|
|
@@ -520,18 +513,28 @@ const SelectInput = createWithIntlProvider({
|
|
|
520
513
|
size,
|
|
521
514
|
disableMobileSheet
|
|
522
515
|
} = props;
|
|
523
|
-
const isMobileContext = useIsMobile();
|
|
524
|
-
const {
|
|
525
|
-
mode
|
|
526
|
-
} = useResponsiveContext();
|
|
527
516
|
const getPopupContainerDefault = usePopupContainer();
|
|
528
517
|
const getScrollElement = useScrollElement();
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
518
|
+
const wrapCustomGetPopupContainer = useMemo(() => {
|
|
519
|
+
if (typeof getPopupContainerProp === 'function') {
|
|
520
|
+
return triggerNode => getPopupContainerProp(triggerNode) || null;
|
|
521
|
+
}
|
|
522
|
+
if (getPopupContainerProp) {
|
|
523
|
+
return () => getPopupContainerProp;
|
|
524
|
+
}
|
|
525
|
+
return undefined;
|
|
526
|
+
}, [getPopupContainerProp]);
|
|
527
|
+
const {
|
|
528
|
+
isMobile,
|
|
529
|
+
fixedModeClass,
|
|
530
|
+
getPopupContainer: getSheetPopupContainer,
|
|
531
|
+
anchorRef
|
|
532
|
+
} = useMobilePopupMount({
|
|
533
|
+
cover: 'viewport',
|
|
534
|
+
getPopupContainer: wrapCustomGetPopupContainer
|
|
535
|
+
});
|
|
532
536
|
const useMobileSheet = isMobile && !disableMobileSheet;
|
|
533
|
-
const useBoundaryMount =
|
|
534
|
-
const fixedModeClass = useBoundaryMount ? style$6['is-boundary'] : style$6['is-viewport'];
|
|
537
|
+
const useBoundaryMount = !!(isMobile && fixedModeClass === MOBILE_POPUP_MODE.boundary);
|
|
535
538
|
const mergedOverlayStyle = useMemo(() => {
|
|
536
539
|
return Object.assign({}, overlayStyle, zIndex != null ? {
|
|
537
540
|
zIndex
|
|
@@ -571,51 +574,50 @@ const SelectInput = createWithIntlProvider({
|
|
|
571
574
|
setContainerWidth(containerWidth);
|
|
572
575
|
const innerEl = el.querySelector('.select-input-inner');
|
|
573
576
|
setInnerWidth(innerEl.clientWidth);
|
|
574
|
-
setInExamplePhoneFrame(!!findExamplePhoneMountNode(el));
|
|
575
577
|
};
|
|
576
578
|
const popupOverlayWidth = useMemo(() => {
|
|
577
579
|
return numberToPx$1(Math.max(containerWidth, pxToNumber(overlayWidth)));
|
|
578
580
|
}, [containerWidth, overlayWidth]);
|
|
579
|
-
const
|
|
581
|
+
const resizeRef = useResize(containerWidthChange);
|
|
582
|
+
const setContainerRef = useCallback(node => {
|
|
583
|
+
resizeRef.current = node;
|
|
584
|
+
anchorRef(node);
|
|
585
|
+
}, [anchorRef, resizeRef]);
|
|
580
586
|
const resolveGetPopupContainer = useCallback(triggerNode => {
|
|
581
587
|
if (typeof getPopupContainerProp === 'function') {
|
|
582
588
|
const customContainer = getPopupContainerProp(triggerNode);
|
|
583
589
|
if (customContainer) {
|
|
584
590
|
return customContainer;
|
|
585
591
|
}
|
|
592
|
+
} else if (getPopupContainerProp) {
|
|
593
|
+
return getPopupContainerProp;
|
|
586
594
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
return exampleMount;
|
|
590
|
-
}
|
|
591
|
-
if (useMobileSheet && !useBoundaryMount && typeof document !== 'undefined') {
|
|
592
|
-
return document.body;
|
|
595
|
+
if (useMobileSheet) {
|
|
596
|
+
return getSheetPopupContainer(triggerNode);
|
|
593
597
|
}
|
|
594
598
|
return getPopupContainerDefault(triggerNode);
|
|
595
|
-
}, [getPopupContainerDefault, getPopupContainerProp,
|
|
599
|
+
}, [getPopupContainerDefault, getPopupContainerProp, getSheetPopupContainer, useMobileSheet]);
|
|
596
600
|
|
|
597
|
-
//
|
|
601
|
+
// 打开时再取挂载节点,避免落到错误容器
|
|
598
602
|
useLayoutEffect(() => {
|
|
599
|
-
const exampleMount = findExamplePhoneMountNode(containerRef.current);
|
|
600
|
-
setInExamplePhoneFrame(!!exampleMount);
|
|
601
603
|
if (!useMobileSheet) {
|
|
602
604
|
setPopupMountNode(null);
|
|
603
605
|
return;
|
|
604
606
|
}
|
|
605
|
-
setPopupMountNode(resolveGetPopupContainer(
|
|
606
|
-
}, [useMobileSheet, resolveGetPopupContainer, open,
|
|
607
|
+
setPopupMountNode(resolveGetPopupContainer(resizeRef.current) || (typeof document !== 'undefined' ? document.body : null));
|
|
608
|
+
}, [useMobileSheet, resolveGetPopupContainer, open, resizeRef]);
|
|
607
609
|
const getLockScrollTargets = useCallback(() => {
|
|
608
610
|
const targets = [];
|
|
609
611
|
const scrollEl = typeof getScrollElement === 'function' ? getScrollElement() : null;
|
|
610
612
|
if (scrollEl) {
|
|
611
613
|
targets.push(scrollEl);
|
|
612
614
|
}
|
|
613
|
-
const mountNode = popupMountNode
|
|
615
|
+
const mountNode = popupMountNode;
|
|
614
616
|
if (mountNode && mountNode !== document.body) {
|
|
615
617
|
targets.push(mountNode);
|
|
616
618
|
}
|
|
617
619
|
return targets;
|
|
618
|
-
}, [getScrollElement, popupMountNode
|
|
620
|
+
}, [getScrollElement, popupMountNode]);
|
|
619
621
|
const sheetOpen = !disabled && open;
|
|
620
622
|
useLockParentScroll(useMobileSheet && sheetOpen, getLockScrollTargets);
|
|
621
623
|
const {
|
|
@@ -689,6 +691,7 @@ const SelectInput = createWithIntlProvider({
|
|
|
689
691
|
children,
|
|
690
692
|
isMobile,
|
|
691
693
|
useBoundaryMount,
|
|
694
|
+
fixedModeClass,
|
|
692
695
|
getPopupContainer: resolveGetPopupContainer,
|
|
693
696
|
formatMessage
|
|
694
697
|
};
|
|
@@ -697,7 +700,7 @@ const SelectInput = createWithIntlProvider({
|
|
|
697
700
|
return contextProps.props.inputRender(props, contextProps);
|
|
698
701
|
}
|
|
699
702
|
return /*#__PURE__*/React.createElement(Flex, _extends({}, props, {
|
|
700
|
-
ref:
|
|
703
|
+
ref: setContainerRef,
|
|
701
704
|
className: classnames(className, style$6['select-input'], 'select-input', {
|
|
702
705
|
[style$6['wrap']]: labelWrap,
|
|
703
706
|
[style$6['disabled']]: disabled,
|
|
@@ -1888,7 +1891,7 @@ const createTreeUtils = mapping => {
|
|
|
1888
1891
|
};
|
|
1889
1892
|
};
|
|
1890
1893
|
|
|
1891
|
-
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","list":"kne-super-select_iUhv7","is-selected":"kne-super-select_tx4-l","custom-menu":"kne-super-select_OerpL","selected":"kne-super-select_OUkpN"
|
|
1894
|
+
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","list":"kne-super-select_iUhv7","is-selected":"kne-super-select_tx4-l","custom-menu":"kne-super-select_OerpL","selected":"kne-super-select_OUkpN"};
|
|
1892
1895
|
|
|
1893
1896
|
const CustomMenu = ({
|
|
1894
1897
|
className,
|
|
@@ -2129,7 +2132,7 @@ const CascaderInner = ({
|
|
|
2129
2132
|
if (searchText && searchResults) {
|
|
2130
2133
|
const _currentIds3 = value.map(v => typeof v === 'object' ? v[valueKey] : v);
|
|
2131
2134
|
return /*#__PURE__*/React.createElement("div", {
|
|
2132
|
-
className: classnames(style['content'], {
|
|
2135
|
+
className: classnames(style['content'], 'select-cascader-content', {
|
|
2133
2136
|
[style['is-popup']]: isPopup,
|
|
2134
2137
|
[style['is-mobile']]: isMobile
|
|
2135
2138
|
})
|
|
@@ -2171,7 +2174,7 @@ const CascaderInner = ({
|
|
|
2171
2174
|
// 渲染级联列
|
|
2172
2175
|
const currentIds = value.map(v => typeof v === 'object' ? v[valueKey] : v);
|
|
2173
2176
|
return /*#__PURE__*/React.createElement("div", {
|
|
2174
|
-
className: classnames(style['content'], {
|
|
2177
|
+
className: classnames(style['content'], 'select-cascader-content', {
|
|
2175
2178
|
[style['is-popup']]: isPopup,
|
|
2176
2179
|
[style['has-search']]: !!onSearch,
|
|
2177
2180
|
[style['is-mobile']]: isMobile
|
|
@@ -2189,7 +2192,7 @@ const CascaderInner = ({
|
|
|
2189
2192
|
simple: isPopup,
|
|
2190
2193
|
showSearchButton: !isPopup
|
|
2191
2194
|
}), /*#__PURE__*/React.createElement(ScrollBox, _extends({
|
|
2192
|
-
className: style['scroller']
|
|
2195
|
+
className: classnames(style['scroller'], 'select-cascader-scroller')
|
|
2193
2196
|
}, isMobile ? {} : {
|
|
2194
2197
|
options: {
|
|
2195
2198
|
autoHide: false
|