@kne/super-select 0.1.37 → 0.1.38

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.
@@ -1,4 +1,5 @@
1
- import React, { useState, useRef, useLayoutEffect, forwardRef, useMemo, useImperativeHandle, useEffect, useCallback } from 'react';
1
+ import React, { useState, useRef, useLayoutEffect, forwardRef, useMemo, useCallback, useImperativeHandle, useEffect } from 'react';
2
+ import { createPortal } from 'react-dom';
2
3
  import { createContext } from '@kne/global-context';
3
4
  import useResize from '@kne/use-resize';
4
5
  import useControlValue from '@kne/use-control-value';
@@ -8,10 +9,11 @@ import last from 'lodash/last';
8
9
  import { Tag, Modal, App, Dropdown, Flex, Checkbox, List, Empty, Row, Col, Button, Popover, Tree, Space, Badge, Spin } from 'antd';
9
10
  import { CloseCircleFilled, DownOutlined, CheckOutlined, RightOutlined } from '@ant-design/icons';
10
11
  import { isNotEmpty } from '@kne/is-empty';
12
+ import { useIsMobile, useResponsiveContext, usePopupContainer, useScrollElement } from '@kne/responsive-utils';
11
13
  import { createWithIntlProvider, useIntl } from '@kne/react-intl';
14
+ import 'simplebar-react/dist/simplebar.min.css';
12
15
  import get from 'lodash/get';
13
16
  import SimpleBar from 'simplebar-react';
14
- import 'simplebar-react/dist/simplebar.min.css';
15
17
  import SearchInput from '@kne/search-input';
16
18
  import { FetchScrollLoader } from '@kne/scroll-loader';
17
19
  import '@kne/scroll-loader/dist/index.css';
@@ -48,7 +50,7 @@ const {
48
50
  useContext
49
51
  } = context;
50
52
 
51
- var style$6 = {"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","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","overlay":"kne-super-select_ybN30","select-input-prefix":"kne-super-select_4Pw75","select-input-suffix":"kne-super-select_Wd4pE"};
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","is-viewport":"kne-super-select_0AE8f","is-boundary":"kne-super-select_OyJjb","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"};
52
54
 
53
55
  const locale$1 = {
54
56
  placeholder: '请选择',
@@ -58,7 +60,9 @@ const locale$1 = {
58
60
  numberOf: '{number}个',
59
61
  maxLengthError: '最大数量不能超过{maxLength}',
60
62
  defaultChildren: '下拉内容,需要调用方实现',
61
- removeAll: '移除全部'
63
+ removeAll: '移除全部',
64
+ cancel: '取消',
65
+ confirm: '确定'
62
66
  };
63
67
 
64
68
  const locale = {
@@ -69,7 +73,9 @@ const locale = {
69
73
  numberOf: '{number} items',
70
74
  maxLengthError: 'The maximum number cannot exceed {maxLength}',
71
75
  defaultChildren: 'Dropdown content, to be implemented by the caller',
72
- removeAll: 'Remove All'
76
+ removeAll: 'Remove All',
77
+ cancel: 'Cancel',
78
+ confirm: 'OK'
73
79
  };
74
80
 
75
81
  /**
@@ -162,7 +168,72 @@ const TagOverflowInner = ({
162
168
  }, "+", hiddenCount));
163
169
  };
164
170
 
165
- const _excluded$3 = ["children"];
171
+ const _excluded$4 = ["children"];
172
+ const MOBILE_SHEET_MAX_HEIGHT = '80%';
173
+ const MOBILE_MASK_Z_INDEX = 1000;
174
+ const MOBILE_POPUP_Z_INDEX = 1050;
175
+ 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
+ let parentScrollLockCount = 0;
186
+ let parentScrollLocked = [];
187
+ const lockParentScroll = getScrollElements => {
188
+ parentScrollLockCount += 1;
189
+ if (parentScrollLockCount === 1) {
190
+ const targets = [];
191
+ if (typeof document !== 'undefined') {
192
+ targets.push(document.body);
193
+ if (document.documentElement) {
194
+ targets.push(document.documentElement);
195
+ }
196
+ }
197
+ (typeof getScrollElements === 'function' ? getScrollElements() : []).forEach(el => {
198
+ if (el && !targets.includes(el)) {
199
+ targets.push(el);
200
+ }
201
+ });
202
+ parentScrollLocked = targets.map(el => {
203
+ const prev = {
204
+ overflow: el.style.overflow,
205
+ overscrollBehavior: el.style.overscrollBehavior
206
+ };
207
+ el.style.overflow = 'hidden';
208
+ el.style.overscrollBehavior = 'none';
209
+ return {
210
+ el,
211
+ prev
212
+ };
213
+ });
214
+ }
215
+ return () => {
216
+ parentScrollLockCount = Math.max(0, parentScrollLockCount - 1);
217
+ if (parentScrollLockCount === 0) {
218
+ parentScrollLocked.forEach(({
219
+ el,
220
+ prev
221
+ }) => {
222
+ el.style.overflow = prev.overflow;
223
+ el.style.overscrollBehavior = prev.overscrollBehavior;
224
+ });
225
+ parentScrollLocked = [];
226
+ }
227
+ };
228
+ };
229
+ const useLockParentScroll = (enabled, getScrollElements) => {
230
+ useEffect(() => {
231
+ if (!enabled) {
232
+ return undefined;
233
+ }
234
+ return lockParentScroll(getScrollElements);
235
+ }, [enabled, getScrollElements]);
236
+ };
166
237
  const numberToPx$1 = val => {
167
238
  return typeof val === 'number' ? `${val}px` : val;
168
239
  };
@@ -174,11 +245,13 @@ const pxToNumber = value => {
174
245
  const match = value.toString().match(/^\d*(\.\d*)?/);
175
246
  return match ? Number(match[0]) : 0;
176
247
  };
248
+
249
+ // 与 Modal 模式一致:面板内用临时 value,确认后才写回
177
250
  const ModalContent = _ref => {
178
251
  let {
179
- children
252
+ children: renderContent
180
253
  } = _ref,
181
- others = _objectWithoutPropertiesLoose(_ref, _excluded$3);
254
+ others = _objectWithoutPropertiesLoose(_ref, _excluded$4);
182
255
  const {
183
256
  open,
184
257
  value: propsValue
@@ -189,6 +262,8 @@ const ModalContent = _ref => {
189
262
  setValue(propsValue);
190
263
  }
191
264
  }, [open]);
265
+ // 保留 isPopup 以沿用弹层内搜索等 padding 样式;
266
+ // 拦截内容区 onOpenChange(false),避免单选自动关闭(由取消/确认关)
192
267
  const contextProps = Object.assign({}, others, {
193
268
  value,
194
269
  setValue,
@@ -196,11 +271,116 @@ const ModalContent = _ref => {
196
271
  onAdd: item => others.onAdd(item, setValue),
197
272
  onSelect: item => others.onSelect(item, setValue),
198
273
  onRemove: item => others.onRemove(item, setValue),
199
- children
274
+ onOpenChange: nextOpen => {
275
+ if (nextOpen) {
276
+ others.onOpenChange && others.onOpenChange(true);
277
+ }
278
+ }
200
279
  });
201
280
  return /*#__PURE__*/React.createElement(Provider, {
202
281
  value: contextProps
203
- }, children(contextProps));
282
+ }, renderContent(contextProps));
283
+ };
284
+ const MobileSheetMask = ({
285
+ open,
286
+ mountNode,
287
+ fixedModeClass,
288
+ onClose
289
+ }) => {
290
+ const [renderMask, setRenderMask] = useState(false);
291
+ const [maskClosing, setMaskClosing] = useState(false);
292
+ useEffect(() => {
293
+ if (open) {
294
+ setRenderMask(true);
295
+ setMaskClosing(false);
296
+ return;
297
+ }
298
+ if (!renderMask) return;
299
+ setMaskClosing(true);
300
+ const timer = setTimeout(() => {
301
+ setRenderMask(false);
302
+ setMaskClosing(false);
303
+ }, MASK_ANIMATION_DURATION);
304
+ return () => {
305
+ clearTimeout(timer);
306
+ };
307
+ }, [open, renderMask]);
308
+ if (!renderMask || !mountNode) {
309
+ return null;
310
+ }
311
+ return createPortal(/*#__PURE__*/React.createElement("div", {
312
+ className: classnames(style$6['mobile-sheet-mask'], maskClosing && style$6['mobile-sheet-mask-leave'], fixedModeClass),
313
+ style: {
314
+ zIndex: MOBILE_MASK_Z_INDEX
315
+ },
316
+ onClick: onClose,
317
+ onTouchMove: e => {
318
+ e.preventDefault();
319
+ }
320
+ }), mountNode);
321
+ };
322
+ const MobileSheetHeader = ({
323
+ title,
324
+ cancelText,
325
+ confirmText,
326
+ onCancel,
327
+ onConfirm
328
+ }) => {
329
+ return /*#__PURE__*/React.createElement("div", {
330
+ className: style$6['mobile-sheet-header']
331
+ }, /*#__PURE__*/React.createElement("button", {
332
+ type: "button",
333
+ className: style$6['mobile-sheet-action'],
334
+ onClick: onCancel
335
+ }, cancelText), /*#__PURE__*/React.createElement("div", {
336
+ className: style$6['mobile-sheet-title'],
337
+ title: title
338
+ }, title), /*#__PURE__*/React.createElement("button", {
339
+ type: "button",
340
+ className: classnames(style$6['mobile-sheet-action'], style$6['mobile-sheet-confirm']),
341
+ onClick: onConfirm
342
+ }, confirmText));
343
+ };
344
+ const MobileSheetPanel = ({
345
+ open,
346
+ mountNode,
347
+ fixedModeClass,
348
+ overlayClassName,
349
+ title,
350
+ cancelText,
351
+ confirmText,
352
+ onCancel,
353
+ onConfirm,
354
+ children
355
+ }) => {
356
+ if (!open || !mountNode) {
357
+ return null;
358
+ }
359
+ return createPortal(/*#__PURE__*/React.createElement("div", {
360
+ className: classnames(style$6['mobile-sheet-popup'], style$6['mobile-sheet-portal'], fixedModeClass, overlayClassName),
361
+ style: {
362
+ zIndex: MOBILE_POPUP_Z_INDEX,
363
+ maxHeight: MOBILE_SHEET_MAX_HEIGHT
364
+ },
365
+ onTouchMove: e => {
366
+ // 仅非列表区域阻止穿透;列表滚动容器内允许原生滚动
367
+ const scrollable = e.target.closest('.simplebar-content-wrapper, .simplebar-content, .select-list-scroll-list, .select-table-list-scroll-list, .select-tree-scroll-list, .load-container, .info-page-table-mobile-card-list');
368
+ if (!scrollable) {
369
+ e.preventDefault();
370
+ }
371
+ }
372
+ }, /*#__PURE__*/React.createElement(MobileSheetHeader, {
373
+ title: title,
374
+ cancelText: cancelText,
375
+ confirmText: confirmText,
376
+ onCancel: onCancel,
377
+ onConfirm: onConfirm
378
+ }), /*#__PURE__*/React.createElement("div", {
379
+ className: classnames(style$6['mobile-sheet-body'], style$6['overlay-content'], 'over-content'),
380
+ onClick: e => {
381
+ e.stopPropagation();
382
+ }
383
+ }, children)), mountNode);
204
384
  };
205
385
  const SelectInput = createWithIntlProvider({
206
386
  defaultLocale: 'zh-CN',
@@ -247,18 +427,52 @@ const SelectInput = createWithIntlProvider({
247
427
  suffix: null,
248
428
  extra: null,
249
429
  size: 'default',
430
+ disableMobileSheet: false,
250
431
  renderModal: contextProps => {
251
432
  const {
252
433
  props,
253
434
  open,
254
435
  onComplete,
255
- onOpenChange
436
+ onOpenChange,
437
+ isMobile,
438
+ getPopupContainer,
439
+ formatMessage,
440
+ useBoundaryMount
256
441
  } = contextProps;
257
442
  const {
258
443
  placeholder,
259
444
  children,
260
- overlayClassName
445
+ overlayClassName,
446
+ disableMobileSheet
261
447
  } = props;
448
+ if (isMobile && !disableMobileSheet) {
449
+ const fixedModeClass = useBoundaryMount ? style$6['is-boundary'] : style$6['is-viewport'];
450
+ const mountNode = typeof getPopupContainer === 'function' ? getPopupContainer() : null;
451
+ const closeWithoutCommit = () => onOpenChange(false);
452
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MobileSheetMask, {
453
+ open: open,
454
+ mountNode: mountNode,
455
+ fixedModeClass: fixedModeClass,
456
+ onClose: closeWithoutCommit
457
+ }), /*#__PURE__*/React.createElement(MobileSheetPanel, {
458
+ open: open,
459
+ mountNode: mountNode,
460
+ fixedModeClass: fixedModeClass,
461
+ overlayClassName: overlayClassName,
462
+ title: placeholder,
463
+ cancelText: formatMessage({
464
+ id: 'cancel'
465
+ }),
466
+ confirmText: formatMessage({
467
+ id: 'confirm'
468
+ }),
469
+ onCancel: closeWithoutCommit,
470
+ onConfirm: () => {
471
+ onComplete();
472
+ onOpenChange(false);
473
+ }
474
+ }, children(contextProps)));
475
+ }
262
476
  return /*#__PURE__*/React.createElement(Modal, {
263
477
  className: overlayClassName,
264
478
  width: 1000,
@@ -286,7 +500,7 @@ const SelectInput = createWithIntlProvider({
286
500
  maxLength,
287
501
  overlayClassName,
288
502
  overlayStyle,
289
- getPopupContainer,
503
+ getPopupContainer: getPopupContainerProp,
290
504
  zIndex,
291
505
  align,
292
506
  autoAdjustOverflow,
@@ -303,8 +517,21 @@ const SelectInput = createWithIntlProvider({
303
517
  renderModal,
304
518
  labelKey,
305
519
  valueKey,
306
- size
520
+ size,
521
+ disableMobileSheet
307
522
  } = props;
523
+ const isMobileContext = useIsMobile();
524
+ const {
525
+ mode
526
+ } = useResponsiveContext();
527
+ const getPopupContainerDefault = usePopupContainer();
528
+ const getScrollElement = useScrollElement();
529
+ // example 手机框:外层 Global(viewport) 可能盖掉 container 的 useIsMobile,需 DOM 兜底
530
+ const [inExamplePhoneFrame, setInExamplePhoneFrame] = useState(false);
531
+ const isMobile = isMobileContext || inExamplePhoneFrame;
532
+ const useMobileSheet = isMobile && !disableMobileSheet;
533
+ const useBoundaryMount = useMobileSheet && (mode === 'container' || inExamplePhoneFrame);
534
+ const fixedModeClass = useBoundaryMount ? style$6['is-boundary'] : style$6['is-viewport'];
308
535
  const mergedOverlayStyle = useMemo(() => {
309
536
  return Object.assign({}, overlayStyle, zIndex != null ? {
310
537
  zIndex
@@ -335,6 +562,7 @@ const SelectInput = createWithIntlProvider({
335
562
  const [hover, setHover] = useState(false);
336
563
  const [innerWidth, setInnerWidth] = useState(0);
337
564
  const [containerWidth, setContainerWidth] = useState(0);
565
+ const [popupMountNode, setPopupMountNode] = useState(null);
338
566
  const containerWidthChange = el => {
339
567
  if (!el) {
340
568
  return;
@@ -343,11 +571,53 @@ const SelectInput = createWithIntlProvider({
343
571
  setContainerWidth(containerWidth);
344
572
  const innerEl = el.querySelector('.select-input-inner');
345
573
  setInnerWidth(innerEl.clientWidth);
574
+ setInExamplePhoneFrame(!!findExamplePhoneMountNode(el));
346
575
  };
347
576
  const popupOverlayWidth = useMemo(() => {
348
577
  return numberToPx$1(Math.max(containerWidth, pxToNumber(overlayWidth)));
349
578
  }, [containerWidth, overlayWidth]);
350
579
  const containerRef = useResize(containerWidthChange);
580
+ const resolveGetPopupContainer = useCallback(triggerNode => {
581
+ if (typeof getPopupContainerProp === 'function') {
582
+ const customContainer = getPopupContainerProp(triggerNode);
583
+ if (customContainer) {
584
+ return customContainer;
585
+ }
586
+ }
587
+ const exampleMount = findExamplePhoneMountNode(triggerNode || containerRef.current);
588
+ if (exampleMount) {
589
+ return exampleMount;
590
+ }
591
+ if (useMobileSheet && !useBoundaryMount && typeof document !== 'undefined') {
592
+ return document.body;
593
+ }
594
+ return getPopupContainerDefault(triggerNode);
595
+ }, [getPopupContainerDefault, getPopupContainerProp, useBoundaryMount, useMobileSheet, containerRef]);
596
+
597
+ // 打开时再取挂载节点,避免落到 body 导致 absolute 半屏跑出手机预览框
598
+ useLayoutEffect(() => {
599
+ const exampleMount = findExamplePhoneMountNode(containerRef.current);
600
+ setInExamplePhoneFrame(!!exampleMount);
601
+ if (!useMobileSheet) {
602
+ setPopupMountNode(null);
603
+ return;
604
+ }
605
+ setPopupMountNode(resolveGetPopupContainer(containerRef.current) || (typeof document !== 'undefined' ? document.body : null));
606
+ }, [useMobileSheet, resolveGetPopupContainer, open, containerRef]);
607
+ const getLockScrollTargets = useCallback(() => {
608
+ const targets = [];
609
+ const scrollEl = typeof getScrollElement === 'function' ? getScrollElement() : null;
610
+ if (scrollEl) {
611
+ targets.push(scrollEl);
612
+ }
613
+ const mountNode = popupMountNode || findExamplePhoneMountNode(containerRef.current);
614
+ if (mountNode && mountNode !== document.body) {
615
+ targets.push(mountNode);
616
+ }
617
+ return targets;
618
+ }, [getScrollElement, popupMountNode, containerRef]);
619
+ const sheetOpen = !disabled && open;
620
+ useLockParentScroll(useMobileSheet && sheetOpen, getLockScrollTargets);
351
621
  const {
352
622
  message
353
623
  } = App.useApp();
@@ -400,6 +670,9 @@ const SelectInput = createWithIntlProvider({
400
670
  return newValue;
401
671
  });
402
672
  };
673
+ const handleOpenChange = useCallback(nextOpen => {
674
+ setOpen(nextOpen);
675
+ }, [setOpen]);
403
676
  const contextProps = {
404
677
  props,
405
678
  value: value,
@@ -413,7 +686,11 @@ const SelectInput = createWithIntlProvider({
413
686
  onSelect,
414
687
  open: !disabled && open,
415
688
  onOpenChange: setOpen,
416
- children
689
+ children,
690
+ isMobile,
691
+ useBoundaryMount,
692
+ getPopupContainer: resolveGetPopupContainer,
693
+ formatMessage
417
694
  };
418
695
  const inputInnerRender = (props = {}) => {
419
696
  if (typeof contextProps.props.inputRender === 'function') {
@@ -425,7 +702,8 @@ const SelectInput = createWithIntlProvider({
425
702
  [style$6['wrap']]: labelWrap,
426
703
  [style$6['disabled']]: disabled,
427
704
  [style$6['small']]: size === 'small',
428
- [style$6['large']]: size === 'large'
705
+ [style$6['large']]: size === 'large',
706
+ [style$6['is-mobile']]: isMobile
429
707
  }),
430
708
  justify: "space-between",
431
709
  onMouseOver: () => {
@@ -478,29 +756,72 @@ const SelectInput = createWithIntlProvider({
478
756
  if (props.renderContent && typeof props.renderContent === 'function') {
479
757
  return props.renderContent(children(contextProps));
480
758
  }
759
+
760
+ // 移动端半屏:与 Modal 一致,临时选中 + 取消/确认
761
+ if (useMobileSheet) {
762
+ const closeWithoutCommit = () => setOpen(false);
763
+ return /*#__PURE__*/React.createElement(Provider, {
764
+ value: contextProps
765
+ }, inputInnerRender({
766
+ onClick: () => {
767
+ if (!disabled) {
768
+ setOpen(true);
769
+ }
770
+ }
771
+ }), /*#__PURE__*/React.createElement(ModalContent, contextProps, sheetContextProps => {
772
+ const {
773
+ onComplete
774
+ } = sheetContextProps;
775
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MobileSheetMask, {
776
+ open: sheetOpen,
777
+ mountNode: popupMountNode,
778
+ fixedModeClass: fixedModeClass,
779
+ onClose: closeWithoutCommit
780
+ }), /*#__PURE__*/React.createElement(MobileSheetPanel, {
781
+ open: sheetOpen,
782
+ mountNode: popupMountNode,
783
+ fixedModeClass: fixedModeClass,
784
+ overlayClassName: overlayClassName,
785
+ title: placeholder,
786
+ cancelText: formatMessage({
787
+ id: 'cancel'
788
+ }),
789
+ confirmText: formatMessage({
790
+ id: 'confirm'
791
+ }),
792
+ onCancel: closeWithoutCommit,
793
+ onConfirm: () => {
794
+ onComplete();
795
+ setOpen(false);
796
+ }
797
+ }, children(sheetContextProps)));
798
+ }));
799
+ }
800
+ const overlayContent = /*#__PURE__*/React.createElement("div", {
801
+ style: {
802
+ '--overlay-width': popupOverlayWidth
803
+ },
804
+ className: classnames(style$6['overlay-content'], 'over-content'),
805
+ onClick: e => {
806
+ e.stopPropagation();
807
+ }
808
+ }, children(contextProps));
481
809
  return /*#__PURE__*/React.createElement(Provider, {
482
810
  value: contextProps
483
811
  }, isPopup ? /*#__PURE__*/React.createElement(Dropdown, {
484
812
  open: !disabled && open,
485
- onOpenChange: setOpen,
813
+ onOpenChange: handleOpenChange,
486
814
  placement: placement,
487
815
  arrow: false,
488
- getPopupContainer: getPopupContainer,
816
+ getPopupContainer: resolveGetPopupContainer,
489
817
  overlayClassName: classnames(style$6['overlay'], overlayClassName),
490
818
  overlayStyle: mergedOverlayStyle,
491
819
  align: align,
492
820
  autoAdjustOverflow: autoAdjustOverflow,
493
821
  transitionName: transitionName,
494
822
  trigger: "click",
495
- popupRender: () => /*#__PURE__*/React.createElement("div", {
496
- style: {
497
- '--overlay-width': popupOverlayWidth
498
- },
499
- className: classnames(style$6['overlay-content'], 'over-content'),
500
- onClick: e => {
501
- e.stopPropagation();
502
- }
503
- }, children(contextProps))
823
+ popupRender: () => overlayContent,
824
+ dropdownRender: () => overlayContent
504
825
  }, /*#__PURE__*/React.createElement("span", null, inputInnerRender())) : /*#__PURE__*/React.createElement(React.Fragment, null, inputInnerRender({
505
826
  onClick: () => {
506
827
  setOpen(true);
@@ -602,14 +923,14 @@ const SelectedTagList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
602
923
  }))));
603
924
  });
604
925
 
605
- var style$3 = {"list":"kne-super-select_IsXdU","is-popup":"kne-super-select_-dvpa","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"};
926
+ 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"};
606
927
 
607
- const _excluded$2 = ["children"];
928
+ const _excluded$3 = ["children"];
608
929
  const SelectList = forwardRef((_ref, ref) => {
609
930
  let {
610
931
  children
611
932
  } = _ref,
612
- p = _objectWithoutPropertiesLoose(_ref, _excluded$2);
933
+ p = _objectWithoutPropertiesLoose(_ref, _excluded$3);
613
934
  const fetchListRef = useRef(null);
614
935
  const props = Object.assign({}, {
615
936
  renderItemContent: ({
@@ -710,7 +1031,8 @@ const SelectList = forwardRef((_ref, ref) => {
710
1031
  value,
711
1032
  searchProps,
712
1033
  setSearchProps,
713
- onOpenChange
1034
+ onOpenChange,
1035
+ isMobile
714
1036
  } = targetProps;
715
1037
  const {
716
1038
  footer,
@@ -742,15 +1064,16 @@ const SelectList = forwardRef((_ref, ref) => {
742
1064
  simple: isPopup,
743
1065
  showSearchButton: !isPopup
744
1066
  }),
745
- selectedAll: /*#__PURE__*/React.createElement("div", {
1067
+ selectedAll: !single && allowSelectedAll && /*#__PURE__*/React.createElement("div", {
746
1068
  className: classnames(style$3['selected-all'], 'select-list-selected-all', {
747
1069
  'is-popup': isPopup
748
1070
  })
749
- }, !single && allowSelectedAll && /*#__PURE__*/React.createElement(SelectedAll, null)),
1071
+ }, /*#__PURE__*/React.createElement(SelectedAll, null)),
750
1072
  fetchList: /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
751
1073
  className: classnames(style$3['list'], 'select-list-scroll-list', {
752
1074
  'is-popup': isPopup
753
1075
  }),
1076
+ useSimpleBar: !isMobile,
754
1077
  searchProps: searchProps,
755
1078
  getSearchProps: getSearchProps,
756
1079
  api: Object.assign({}, options ? {
@@ -805,13 +1128,17 @@ const SelectList = forwardRef((_ref, ref) => {
805
1128
  }));
806
1129
  }
807
1130
  return /*#__PURE__*/React.createElement(Flex, {
808
- vertical: true
1131
+ vertical: true,
1132
+ className: classnames({
1133
+ [style$3['is-mobile']]: isMobile
1134
+ })
809
1135
  }, components.search, components.selectedAll, components.fetchList, components.footer, components.selectedTag);
810
1136
  });
811
1137
  });
812
1138
 
813
- var style$2 = {"table":"kne-super-select_zE-14","list":"kne-super-select_DrEYJ","is-popup":"kne-super-select_KgWTX","empty":"kne-super-select_5Tyrt","right-options":"kne-super-select_UXi-g","no-padding-btn":"kne-super-select_iaCir","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"};
1139
+ 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-popup":"kne-super-select_KgWTX","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"};
814
1140
 
1141
+ const _excluded$2 = ["renderBody"];
815
1142
  const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select')(forwardRef((p, ref) => {
816
1143
  const {
817
1144
  formatMessage
@@ -832,8 +1159,7 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
832
1159
  api,
833
1160
  getSearchProps,
834
1161
  options,
835
- getSearchCallback,
836
- labelKey
1162
+ getSearchCallback
837
1163
  } = props;
838
1164
  if (!(api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function')) {
839
1165
  return null;
@@ -874,10 +1200,10 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
874
1200
  props,
875
1201
  value,
876
1202
  setValue,
877
- onSelect,
878
1203
  onRemove,
879
1204
  onOpenChange,
880
- searchProps
1205
+ searchProps,
1206
+ isMobile
881
1207
  } = targetProps;
882
1208
  const {
883
1209
  footer,
@@ -895,7 +1221,8 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
895
1221
  searchPlaceholder,
896
1222
  allowSelectedAll,
897
1223
  labelKey,
898
- valueKey
1224
+ valueKey,
1225
+ renderMobile
899
1226
  } = props;
900
1227
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
901
1228
  const footerEl = footer && /*#__PURE__*/React.createElement("div", {
@@ -909,107 +1236,89 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
909
1236
  onOpenChange(false);
910
1237
  }
911
1238
  }) : footer);
912
- return /*#__PURE__*/React.createElement(Row, {
913
- wrap: false,
914
- ref: bodyRef
915
- }, /*#__PURE__*/React.createElement(Col, {
916
- className: classnames({
917
- [style$2['single-body']]: single
1239
+ const renderScrollList = renderBody => /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
1240
+ className: classnames(style$2['list'], 'select-table-list-scroll-list', {
1241
+ 'is-popup': isPopup
918
1242
  }),
919
- span: single ? 24 : 16
920
- }, /*#__PURE__*/React.createElement("div", null, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React.createElement("div", {
921
- className: classnames(style$2['table'], 'select-table')
922
- }, /*#__PURE__*/React.createElement(TableView, {
923
- columns: columns,
924
- rowKey: valueKey,
925
- rowSelection: {
926
- allowSelectedAll,
927
- isSelectedAll,
928
- onIsSelectAllChange: isSelectedAll => {
929
- setValue(isSelectedAll ? [selectedAllValue] : []);
1243
+ useSimpleBar: !isMobile,
1244
+ searchProps: searchProps,
1245
+ getSearchProps: getSearchProps,
1246
+ api: Object.assign({}, options ? {
1247
+ data: {
1248
+ options,
1249
+ searchProps
930
1250
  },
931
- type: single ? 'radio' : 'checkbox',
932
- selectedRowKeys: (value || []).map(item => item[valueKey]),
933
- onChange: (selectedRowKeys, selectedKey, {
934
- checked
1251
+ loader: ({
1252
+ data
935
1253
  }) => {
936
- setValue(value => {
937
- if (checked) {
938
- var _fetchListRef$current3;
939
- const selectedItem = (_fetchListRef$current3 = fetchListRef.current) == null ? void 0 : _fetchListRef$current3.list.find(item => item[valueKey] === selectedKey);
940
- if (selectedItem) {
941
- if (single) {
942
- return [selectedItem];
943
- }
944
- const newValue = value.slice(0);
945
- newValue.push(selectedItem);
946
- return newValue;
947
- }
948
- return value;
949
- } else {
950
- return value.filter(item => item[valueKey] !== selectedKey);
951
- }
952
- });
953
- if (isPopup && single) {
954
- onOpenChange(false);
1254
+ const {
1255
+ options,
1256
+ searchProps
1257
+ } = data;
1258
+ if (typeof getSearchCallback === 'function') {
1259
+ const newOptions = options.filter(item => getSearchCallback(searchProps, item, targetProps));
1260
+ return {
1261
+ pageData: newOptions
1262
+ };
955
1263
  }
1264
+ return {
1265
+ pageData: options
1266
+ };
956
1267
  }
1268
+ } : api)
1269
+ }), fetchProps => {
1270
+ fetchListRef.current = fetchProps;
1271
+ const {
1272
+ list
1273
+ } = fetchProps;
1274
+ const contextProps = Object.assign({}, fetchProps, targetProps, {
1275
+ isSelectedAll
1276
+ });
1277
+ if (!(list && list.length > 0)) {
1278
+ return props.empty || /*#__PURE__*/React.createElement(Empty, {
1279
+ className: classnames(style$2['empty'])
1280
+ });
1281
+ }
1282
+ return renderBody(list, contextProps);
1283
+ });
1284
+ const tableSelection = {
1285
+ allowSelectedAll,
1286
+ isSelectedAll,
1287
+ onIsSelectAllChange: isSelectedAll => {
1288
+ setValue(isSelectedAll ? [selectedAllValue] : []);
957
1289
  },
958
- render: ({
959
- renderBody
1290
+ type: single ? 'radio' : 'checkbox',
1291
+ selectedRowKeys: (value || []).map(item => item[valueKey]),
1292
+ onChange: (selectedRowKeys, selectedKey, {
1293
+ checked
960
1294
  }) => {
961
- return /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
962
- className: classnames(style$2['list'], 'select-table-list-scroll-list', {
963
- 'is-popup': isPopup
964
- }),
965
- searchProps: searchProps,
966
- getSearchProps: getSearchProps,
967
- api: Object.assign({}, options ? {
968
- data: {
969
- options,
970
- searchProps
971
- },
972
- loader: ({
973
- data
974
- }) => {
975
- const {
976
- options,
977
- searchProps
978
- } = data;
979
- if (typeof getSearchCallback === 'function') {
980
- const newOptions = options.filter(item => getSearchCallback(searchProps, item, targetProps));
981
- return {
982
- pageData: newOptions
983
- };
1295
+ setValue(value => {
1296
+ if (checked) {
1297
+ var _fetchListRef$current3;
1298
+ const selectedItem = (_fetchListRef$current3 = fetchListRef.current) == null ? void 0 : _fetchListRef$current3.list.find(item => item[valueKey] === selectedKey);
1299
+ if (selectedItem) {
1300
+ if (single) {
1301
+ return [selectedItem];
984
1302
  }
985
- return {
986
- pageData: options
987
- };
1303
+ const newValue = value.slice(0);
1304
+ newValue.push(selectedItem);
1305
+ return newValue;
988
1306
  }
989
- } : api)
990
- }), fetchProps => {
991
- fetchListRef.current = fetchProps;
992
- const {
993
- list
994
- } = fetchProps;
995
- const contextProps = Object.assign({}, fetchProps, targetProps, {
996
- isSelectedAll
997
- });
998
- if (!(list && list.length > 0)) {
999
- return props.empty || /*#__PURE__*/React.createElement(Empty, {
1000
- className: classnames(style$2['empty'])
1001
- });
1307
+ return value;
1308
+ } else {
1309
+ return value.filter(item => item[valueKey] !== selectedKey);
1002
1310
  }
1003
- return renderBody(list, contextProps);
1004
1311
  });
1312
+ if (isPopup && single) {
1313
+ onOpenChange(false);
1314
+ }
1005
1315
  }
1006
- })), single && footerEl || /*#__PURE__*/React.createElement("div", {
1007
- className: classnames(style$2['footer'], 'select-table-footer')
1008
- })), !single && /*#__PURE__*/React.createElement(Col, {
1316
+ };
1317
+ const selectedPanel = !single && /*#__PURE__*/React.createElement("div", {
1009
1318
  className: classnames(style$2['right-options'], {
1010
- 'is-popup': isPopup
1011
- }),
1012
- span: 8
1319
+ 'is-popup': isPopup,
1320
+ [style$2['is-mobile']]: isMobile
1321
+ })
1013
1322
  }, /*#__PURE__*/React.createElement(SearchInput, {
1014
1323
  className: style$2['tags-search'],
1015
1324
  placeholder: searchPlaceholder,
@@ -1032,46 +1341,116 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
1032
1341
  }
1033
1342
  }, formatMessage({
1034
1343
  id: 'removeAll'
1035
- })))), /*#__PURE__*/React.createElement(SimpleBar, null, /*#__PURE__*/React.createElement(Flex, {
1036
- wrap: true,
1037
- gap: 8
1038
- }, value.filter(item => getTagSearchCallback(tagSearchText, item, targetProps)).map(item => {
1039
- var _fetchListRef$current4, _fetchListRef$current5;
1040
- return /*#__PURE__*/React.createElement(Tag, {
1041
- className: style$2['tag'],
1042
- key: item[valueKey],
1043
- closable: true,
1044
- bordered: false,
1045
- onClose: e => {
1046
- e.preventDefault();
1047
- onRemove(item);
1048
- }
1049
- }, /*#__PURE__*/React.createElement(Popover, {
1050
- getPopupContainer: () => bodyRef.current,
1051
- content: /*#__PURE__*/React.createElement(CentralContent, {
1052
- className: style$2['descriptions'],
1053
- columns: columns.filter(item => {
1054
- if (Object.hasOwn(item, 'previewHidden')) {
1055
- return !item.previewHidden;
1056
- }
1057
- return item.name !== 'options';
1058
- }).map(item => Object.assign({}, item, {
1059
- span: 12
1060
- })),
1061
- dataSource: Object.assign({}, item),
1062
- context: Object.assign({}, targetProps, {
1063
- fetchApi: (_fetchListRef$current4 = fetchListRef.current) == null ? void 0 : _fetchListRef$current4.fetchApi,
1064
- list: (_fetchListRef$current5 = fetchListRef.current) == null ? void 0 : _fetchListRef$current5.list
1344
+ })))), (() => {
1345
+ const selectedTags = /*#__PURE__*/React.createElement(Flex, {
1346
+ wrap: true,
1347
+ gap: 8
1348
+ }, value.filter(item => getTagSearchCallback(tagSearchText, item, targetProps)).map(item => {
1349
+ var _fetchListRef$current4, _fetchListRef$current5;
1350
+ return /*#__PURE__*/React.createElement(Tag, {
1351
+ className: style$2['tag'],
1352
+ key: item[valueKey],
1353
+ closable: true,
1354
+ bordered: false,
1355
+ onClose: e => {
1356
+ e.preventDefault();
1357
+ onRemove(item);
1358
+ }
1359
+ }, /*#__PURE__*/React.createElement(Popover, {
1360
+ getPopupContainer: () => bodyRef.current,
1361
+ content: /*#__PURE__*/React.createElement(CentralContent, {
1362
+ className: style$2['descriptions'],
1363
+ columns: columns.filter(item => {
1364
+ if (Object.hasOwn(item, 'previewHidden')) {
1365
+ return !item.previewHidden;
1366
+ }
1367
+ return item.name !== 'options';
1368
+ }).map(item => Object.assign({}, item, {
1369
+ span: 12
1370
+ })),
1371
+ dataSource: Object.assign({}, item),
1372
+ context: Object.assign({}, targetProps, {
1373
+ fetchApi: (_fetchListRef$current4 = fetchListRef.current) == null ? void 0 : _fetchListRef$current4.fetchApi,
1374
+ list: (_fetchListRef$current5 = fetchListRef.current) == null ? void 0 : _fetchListRef$current5.list
1375
+ })
1065
1376
  })
1066
- })
1067
- }, /*#__PURE__*/React.createElement("span", {
1068
- className: style$2['tag-inner']
1069
- }, item[labelKey])));
1070
- }))), footerEl));
1377
+ }, /*#__PURE__*/React.createElement("span", {
1378
+ className: style$2['tag-inner']
1379
+ }, item[labelKey])));
1380
+ }));
1381
+ // 移动端弹窗内不用 SimpleBar,改原生滚动
1382
+ if (isMobile) {
1383
+ return /*#__PURE__*/React.createElement("div", {
1384
+ className: style$2['selected-tags-scroll']
1385
+ }, selectedTags);
1386
+ }
1387
+ return /*#__PURE__*/React.createElement(SimpleBar, {
1388
+ className: style$2['selected-tags-scroll']
1389
+ }, selectedTags);
1390
+ })(), footerEl);
1391
+ const tableMobileRender = _ref => {
1392
+ let {
1393
+ renderBody
1394
+ } = _ref,
1395
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
1396
+ return renderScrollList((list, contextProps) => {
1397
+ if (typeof renderMobile === 'function') {
1398
+ return renderMobile(_extends({}, rest, contextProps, {
1399
+ list,
1400
+ renderBody: (nextList = list, nextContext = contextProps) => renderBody(nextList, nextContext)
1401
+ }));
1402
+ }
1403
+ return renderBody(list, contextProps);
1404
+ });
1405
+ };
1406
+ const tablePanel = /*#__PURE__*/React.createElement("div", {
1407
+ className: classnames(style$2['table-panel'], {
1408
+ [style$2['single-body']]: single
1409
+ })
1410
+ }, /*#__PURE__*/React.createElement("div", {
1411
+ className: style$2['filter-wrap']
1412
+ }, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React.createElement("div", {
1413
+ className: classnames(style$2['table'], 'select-table')
1414
+ }, /*#__PURE__*/React.createElement(TableView, {
1415
+ columns: columns,
1416
+ rowKey: valueKey,
1417
+ rowSelection: tableSelection,
1418
+ renderMobile: renderMobile === false ? undefined : tableMobileRender,
1419
+ render: ({
1420
+ renderBody
1421
+ }) => renderScrollList(renderBody)
1422
+ })), single && footerEl || !isMobile && /*#__PURE__*/React.createElement("div", {
1423
+ className: classnames(style$2['footer'], 'select-table-footer')
1424
+ }));
1425
+
1426
+ // 移动端:表格在上、已选在下(上下布局)
1427
+ if (isMobile) {
1428
+ return /*#__PURE__*/React.createElement("div", {
1429
+ ref: bodyRef,
1430
+ className: classnames(style$2['body'], style$2['is-mobile'], 'select-table-list-body')
1431
+ }, /*#__PURE__*/React.createElement("div", {
1432
+ className: style$2['table-panel-wrap']
1433
+ }, tablePanel), selectedPanel ? /*#__PURE__*/React.createElement("div", {
1434
+ className: style$2['selected-panel-wrap']
1435
+ }, selectedPanel) : null);
1436
+ }
1437
+ return /*#__PURE__*/React.createElement(Row, {
1438
+ wrap: false,
1439
+ ref: bodyRef,
1440
+ className: classnames(style$2['body'], 'select-table-list-body')
1441
+ }, /*#__PURE__*/React.createElement(Col, {
1442
+ className: classnames({
1443
+ [style$2['single-body']]: single
1444
+ }),
1445
+ span: single ? 24 : 16
1446
+ }, tablePanel), !single && /*#__PURE__*/React.createElement(Col, {
1447
+ span: 8,
1448
+ className: style$2['right-options-col']
1449
+ }, selectedPanel));
1071
1450
  });
1072
1451
  }));
1073
1452
 
1074
- var style$1 = {"list":"kne-super-select_YTqxA","is-popup":"kne-super-select_TR-1a","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"};
1453
+ 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"};
1075
1454
 
1076
1455
  const _excluded$1 = ["children"],
1077
1456
  _excluded2 = ["data"];
@@ -1221,7 +1600,8 @@ const SelectTree = forwardRef((_ref, ref) => {
1221
1600
  const {
1222
1601
  props,
1223
1602
  value,
1224
- onOpenChange
1603
+ onOpenChange,
1604
+ isMobile
1225
1605
  } = targetProps;
1226
1606
  const {
1227
1607
  footer,
@@ -1236,11 +1616,11 @@ const SelectTree = forwardRef((_ref, ref) => {
1236
1616
  selectedAllValue
1237
1617
  } = props;
1238
1618
  const components = {
1239
- selectedAll: /*#__PURE__*/React.createElement("div", {
1619
+ selectedAll: !single && allowSelectedAll && /*#__PURE__*/React.createElement("div", {
1240
1620
  className: classnames(style$1['selected-all'], 'select-tree-selected-all', {
1241
1621
  'is-popup': isPopup
1242
1622
  })
1243
- }, !single && allowSelectedAll && /*#__PURE__*/React.createElement(SelectedAll, null)),
1623
+ }, /*#__PURE__*/React.createElement(SelectedAll, null)),
1244
1624
  treeList: /*#__PURE__*/React.createElement(Fetch, _extends({}, Object.assign({}, options ? {
1245
1625
  data: {
1246
1626
  options
@@ -1256,14 +1636,23 @@ const SelectTree = forwardRef((_ref, ref) => {
1256
1636
  } = _ref2,
1257
1637
  fetchProps = _objectWithoutPropertiesLoose(_ref2, _excluded2);
1258
1638
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
1259
- return /*#__PURE__*/React.createElement(SimpleBar, {
1260
- className: classnames(style$1['list'], 'select-tree-scroll-list', {
1261
- 'is-popup': isPopup
1262
- })
1263
- }, renderTree(Object.assign({}, fetchProps, targetProps, {
1639
+ const treeContent = renderTree(Object.assign({}, fetchProps, targetProps, {
1264
1640
  isSelectedAll,
1265
1641
  data
1266
- })));
1642
+ }));
1643
+ const scrollClassName = classnames(style$1['list'], 'select-tree-scroll-list', {
1644
+ 'is-popup': isPopup
1645
+ });
1646
+ // 移动端弹窗内不用 SimpleBar,改原生滚动
1647
+ if (isMobile) {
1648
+ return /*#__PURE__*/React.createElement("div", {
1649
+ className: scrollClassName
1650
+ }, treeContent);
1651
+ }
1652
+ return /*#__PURE__*/React.createElement(SimpleBar, {
1653
+ className: scrollClassName,
1654
+ autoHide: false
1655
+ }, treeContent);
1267
1656
  }
1268
1657
  })),
1269
1658
  selectedTag: showSelectedTag && /*#__PURE__*/React.createElement("div", {
@@ -1288,7 +1677,10 @@ const SelectTree = forwardRef((_ref, ref) => {
1288
1677
  }));
1289
1678
  }
1290
1679
  return /*#__PURE__*/React.createElement(Flex, {
1291
- vertical: true
1680
+ vertical: true,
1681
+ className: classnames({
1682
+ [style$1['is-mobile']]: isMobile
1683
+ })
1292
1684
  }, components.search, components.selectedAll, components.treeList, components.footer, components.selectedTag);
1293
1685
  });
1294
1686
  });
@@ -1496,7 +1888,7 @@ const createTreeUtils = mapping => {
1496
1888
  };
1497
1889
  };
1498
1890
 
1499
- var style = {"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","list":"kne-super-select_iUhv7","is-selected":"kne-super-select_tx4-l","custom-menu":"kne-super-select_OerpL","selected":"kne-super-select_OUkpN"};
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","is-mobile":"kne-super-select_HjXMw"};
1500
1892
 
1501
1893
  const CustomMenu = ({
1502
1894
  className,
@@ -1519,7 +1911,8 @@ const CustomMenu = ({
1519
1911
  const isSelected = selectedKeys == null ? void 0 : selectedKeys.includes(item.key);
1520
1912
  return /*#__PURE__*/React.createElement(List.Item, {
1521
1913
  className: classnames(style['custom-menu-item'], {
1522
- [style['selected']]: isSelected
1914
+ [style['selected']]: isSelected,
1915
+ selected: isSelected
1523
1916
  }),
1524
1917
  onClick: e => handleItemClick(item.key, e)
1525
1918
  }, item.label);
@@ -1550,13 +1943,16 @@ const CascaderInner = ({
1550
1943
  valueKey,
1551
1944
  labelKey,
1552
1945
  onOpenChange,
1553
- open
1946
+ open,
1947
+ isMobile
1554
1948
  }) => {
1555
1949
  const {
1556
1950
  message
1557
1951
  } = App.useApp();
1558
1952
  const [searchText, setSearchText] = useState('');
1559
1953
  const [loading, setLoading] = useState(false);
1954
+ // 移动端弹窗内不用 SimpleBar,改原生滚动
1955
+ const ScrollBox = isMobile ? 'div' : SimpleBar;
1560
1956
 
1561
1957
  // 构建 mapping
1562
1958
  const mapping = useMemo(() => {
@@ -1734,7 +2130,8 @@ const CascaderInner = ({
1734
2130
  const _currentIds3 = value.map(v => typeof v === 'object' ? v[valueKey] : v);
1735
2131
  return /*#__PURE__*/React.createElement("div", {
1736
2132
  className: classnames(style['content'], {
1737
- [style['is-popup']]: isPopup
2133
+ [style['is-popup']]: isPopup,
2134
+ [style['is-mobile']]: isMobile
1738
2135
  })
1739
2136
  }, /*#__PURE__*/React.createElement(SearchInput, {
1740
2137
  className: classnames(style['search-input'], {
@@ -1745,7 +2142,7 @@ const CascaderInner = ({
1745
2142
  onSearch: setSearchText,
1746
2143
  simple: isPopup,
1747
2144
  showSearchButton: !isPopup
1748
- }), /*#__PURE__*/React.createElement(SimpleBar, {
2145
+ }), /*#__PURE__*/React.createElement(ScrollBox, {
1749
2146
  className: style['scroll-plus-box']
1750
2147
  }, searchResults.length === 0 ? /*#__PURE__*/React.createElement(Empty, {
1751
2148
  description: "\u6682\u65E0\u6570\u636E"
@@ -1776,7 +2173,8 @@ const CascaderInner = ({
1776
2173
  return /*#__PURE__*/React.createElement("div", {
1777
2174
  className: classnames(style['content'], {
1778
2175
  [style['is-popup']]: isPopup,
1779
- [style['has-search']]: !!onSearch
2176
+ [style['has-search']]: !!onSearch,
2177
+ [style['is-mobile']]: isMobile
1780
2178
  }),
1781
2179
  style: {
1782
2180
  '--menu-item-width': numberToPx(menuItemWidth)
@@ -1790,23 +2188,65 @@ const CascaderInner = ({
1790
2188
  onSearch: setSearchText,
1791
2189
  simple: isPopup,
1792
2190
  showSearchButton: !isPopup
1793
- }), /*#__PURE__*/React.createElement(SimpleBar, {
1794
- className: style['scroller'],
2191
+ }), /*#__PURE__*/React.createElement(ScrollBox, _extends({
2192
+ className: style['scroller']
2193
+ }, isMobile ? {} : {
1795
2194
  options: {
1796
2195
  autoHide: false
1797
2196
  }
1798
- }, /*#__PURE__*/React.createElement("div", {
1799
- className: style['columns']
2197
+ }), /*#__PURE__*/React.createElement("div", {
2198
+ className: classnames(style['columns'], {
2199
+ [style['is-mobile']]: isMobile
2200
+ })
1800
2201
  }, selectedIds.map((selectedId, index) => {
1801
2202
  const selectNode = mapping.get(selectedId);
1802
2203
  const siblingNodes = treeUtils.getSiblingNode(selectedId);
1803
2204
  const isLastLevel = !isNotLastNode(selectNode == null ? void 0 : selectNode.id) && index > 0;
1804
- return /*#__PURE__*/React.createElement(SimpleBar, {
2205
+ return /*#__PURE__*/React.createElement(ScrollBox, {
1805
2206
  key: selectedId || index,
1806
2207
  className: classnames(style['content-item'], {
1807
2208
  [style['last-level-area']]: isLastLevel
1808
2209
  })
1809
- }, isLastLevel ? /*#__PURE__*/React.createElement(Space, {
2210
+ }, isLastLevel ? isMobile ? /*#__PURE__*/React.createElement(CustomMenu, {
2211
+ className: style['menu'],
2212
+ selectedKeys: currentIds,
2213
+ onSelect: ({
2214
+ key
2215
+ }) => {
2216
+ const node = mapping.get(key);
2217
+ if (!node) return;
2218
+ const {
2219
+ checked
2220
+ } = treeUtils.computedCheckboxStatus(node.id, currentIds);
2221
+ onCheckedChange(!checked, node.id);
2222
+ },
2223
+ items: siblingNodes.map(node => {
2224
+ const {
2225
+ checked,
2226
+ indeterminate
2227
+ } = treeUtils.computedCheckboxStatus(node.id, currentIds);
2228
+ return {
2229
+ key: node.id,
2230
+ label: /*#__PURE__*/React.createElement(Space, {
2231
+ className: classnames(style['menu-item'], {
2232
+ [style['single-mode']]: single
2233
+ })
2234
+ }, /*#__PURE__*/React.createElement(Checkbox, {
2235
+ checked: checked,
2236
+ indeterminate: indeterminate,
2237
+ onClick: e => e.stopPropagation(),
2238
+ onChange: e => {
2239
+ e.stopPropagation();
2240
+ onCheckedChange(e.target.checked, node.id);
2241
+ }
2242
+ }), /*#__PURE__*/React.createElement("div", {
2243
+ className: style['menu-label']
2244
+ }, /*#__PURE__*/React.createElement("span", {
2245
+ className: style['menu-label-text']
2246
+ }, node.label)))
2247
+ };
2248
+ })
2249
+ }) : /*#__PURE__*/React.createElement(Space, {
1810
2250
  wrap: true,
1811
2251
  style: {
1812
2252
  padding: 12
@@ -2062,7 +2502,8 @@ const SelectCascader = _ref => {
2062
2502
  valueKey: valueKey,
2063
2503
  labelKey: labelKey,
2064
2504
  onOpenChange: contextProps.onOpenChange,
2065
- open: contextProps.open
2505
+ open: contextProps.open,
2506
+ isMobile: contextProps.isMobile
2066
2507
  });
2067
2508
  });
2068
2509
  };