@kne/super-select 0.1.36 → 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,6 +500,8 @@ const SelectInput = createWithIntlProvider({
286
500
  maxLength,
287
501
  overlayClassName,
288
502
  overlayStyle,
503
+ getPopupContainer: getPopupContainerProp,
504
+ zIndex,
289
505
  align,
290
506
  autoAdjustOverflow,
291
507
  transitionName,
@@ -301,8 +517,26 @@ const SelectInput = createWithIntlProvider({
301
517
  renderModal,
302
518
  labelKey,
303
519
  valueKey,
304
- size
520
+ size,
521
+ disableMobileSheet
305
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'];
535
+ const mergedOverlayStyle = useMemo(() => {
536
+ return Object.assign({}, overlayStyle, zIndex != null ? {
537
+ zIndex
538
+ } : null);
539
+ }, [overlayStyle, zIndex]);
306
540
  const transformValue = value => {
307
541
  if (single) {
308
542
  return isNotEmpty(value) ? [value] : [];
@@ -328,6 +562,7 @@ const SelectInput = createWithIntlProvider({
328
562
  const [hover, setHover] = useState(false);
329
563
  const [innerWidth, setInnerWidth] = useState(0);
330
564
  const [containerWidth, setContainerWidth] = useState(0);
565
+ const [popupMountNode, setPopupMountNode] = useState(null);
331
566
  const containerWidthChange = el => {
332
567
  if (!el) {
333
568
  return;
@@ -336,11 +571,53 @@ const SelectInput = createWithIntlProvider({
336
571
  setContainerWidth(containerWidth);
337
572
  const innerEl = el.querySelector('.select-input-inner');
338
573
  setInnerWidth(innerEl.clientWidth);
574
+ setInExamplePhoneFrame(!!findExamplePhoneMountNode(el));
339
575
  };
340
576
  const popupOverlayWidth = useMemo(() => {
341
577
  return numberToPx$1(Math.max(containerWidth, pxToNumber(overlayWidth)));
342
578
  }, [containerWidth, overlayWidth]);
343
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);
344
621
  const {
345
622
  message
346
623
  } = App.useApp();
@@ -393,6 +670,9 @@ const SelectInput = createWithIntlProvider({
393
670
  return newValue;
394
671
  });
395
672
  };
673
+ const handleOpenChange = useCallback(nextOpen => {
674
+ setOpen(nextOpen);
675
+ }, [setOpen]);
396
676
  const contextProps = {
397
677
  props,
398
678
  value: value,
@@ -406,7 +686,11 @@ const SelectInput = createWithIntlProvider({
406
686
  onSelect,
407
687
  open: !disabled && open,
408
688
  onOpenChange: setOpen,
409
- children
689
+ children,
690
+ isMobile,
691
+ useBoundaryMount,
692
+ getPopupContainer: resolveGetPopupContainer,
693
+ formatMessage
410
694
  };
411
695
  const inputInnerRender = (props = {}) => {
412
696
  if (typeof contextProps.props.inputRender === 'function') {
@@ -418,7 +702,8 @@ const SelectInput = createWithIntlProvider({
418
702
  [style$6['wrap']]: labelWrap,
419
703
  [style$6['disabled']]: disabled,
420
704
  [style$6['small']]: size === 'small',
421
- [style$6['large']]: size === 'large'
705
+ [style$6['large']]: size === 'large',
706
+ [style$6['is-mobile']]: isMobile
422
707
  }),
423
708
  justify: "space-between",
424
709
  onMouseOver: () => {
@@ -471,28 +756,72 @@ const SelectInput = createWithIntlProvider({
471
756
  if (props.renderContent && typeof props.renderContent === 'function') {
472
757
  return props.renderContent(children(contextProps));
473
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));
474
809
  return /*#__PURE__*/React.createElement(Provider, {
475
810
  value: contextProps
476
811
  }, isPopup ? /*#__PURE__*/React.createElement(Dropdown, {
477
812
  open: !disabled && open,
478
- onOpenChange: setOpen,
813
+ onOpenChange: handleOpenChange,
479
814
  placement: placement,
480
815
  arrow: false,
816
+ getPopupContainer: resolveGetPopupContainer,
481
817
  overlayClassName: classnames(style$6['overlay'], overlayClassName),
482
- overlayStyle: overlayStyle,
818
+ overlayStyle: mergedOverlayStyle,
483
819
  align: align,
484
820
  autoAdjustOverflow: autoAdjustOverflow,
485
821
  transitionName: transitionName,
486
822
  trigger: "click",
487
- popupRender: () => /*#__PURE__*/React.createElement("div", {
488
- style: {
489
- '--overlay-width': popupOverlayWidth
490
- },
491
- className: classnames(style$6['overlay-content'], 'over-content'),
492
- onClick: e => {
493
- e.stopPropagation();
494
- }
495
- }, children(contextProps))
823
+ popupRender: () => overlayContent,
824
+ dropdownRender: () => overlayContent
496
825
  }, /*#__PURE__*/React.createElement("span", null, inputInnerRender())) : /*#__PURE__*/React.createElement(React.Fragment, null, inputInnerRender({
497
826
  onClick: () => {
498
827
  setOpen(true);
@@ -594,14 +923,14 @@ const SelectedTagList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
594
923
  }))));
595
924
  });
596
925
 
597
- 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"};
598
927
 
599
- const _excluded$2 = ["children"];
928
+ const _excluded$3 = ["children"];
600
929
  const SelectList = forwardRef((_ref, ref) => {
601
930
  let {
602
931
  children
603
932
  } = _ref,
604
- p = _objectWithoutPropertiesLoose(_ref, _excluded$2);
933
+ p = _objectWithoutPropertiesLoose(_ref, _excluded$3);
605
934
  const fetchListRef = useRef(null);
606
935
  const props = Object.assign({}, {
607
936
  renderItemContent: ({
@@ -702,7 +1031,8 @@ const SelectList = forwardRef((_ref, ref) => {
702
1031
  value,
703
1032
  searchProps,
704
1033
  setSearchProps,
705
- onOpenChange
1034
+ onOpenChange,
1035
+ isMobile
706
1036
  } = targetProps;
707
1037
  const {
708
1038
  footer,
@@ -734,15 +1064,16 @@ const SelectList = forwardRef((_ref, ref) => {
734
1064
  simple: isPopup,
735
1065
  showSearchButton: !isPopup
736
1066
  }),
737
- selectedAll: /*#__PURE__*/React.createElement("div", {
1067
+ selectedAll: !single && allowSelectedAll && /*#__PURE__*/React.createElement("div", {
738
1068
  className: classnames(style$3['selected-all'], 'select-list-selected-all', {
739
1069
  'is-popup': isPopup
740
1070
  })
741
- }, !single && allowSelectedAll && /*#__PURE__*/React.createElement(SelectedAll, null)),
1071
+ }, /*#__PURE__*/React.createElement(SelectedAll, null)),
742
1072
  fetchList: /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
743
1073
  className: classnames(style$3['list'], 'select-list-scroll-list', {
744
1074
  'is-popup': isPopup
745
1075
  }),
1076
+ useSimpleBar: !isMobile,
746
1077
  searchProps: searchProps,
747
1078
  getSearchProps: getSearchProps,
748
1079
  api: Object.assign({}, options ? {
@@ -797,13 +1128,17 @@ const SelectList = forwardRef((_ref, ref) => {
797
1128
  }));
798
1129
  }
799
1130
  return /*#__PURE__*/React.createElement(Flex, {
800
- vertical: true
1131
+ vertical: true,
1132
+ className: classnames({
1133
+ [style$3['is-mobile']]: isMobile
1134
+ })
801
1135
  }, components.search, components.selectedAll, components.fetchList, components.footer, components.selectedTag);
802
1136
  });
803
1137
  });
804
1138
 
805
- 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"};
806
1140
 
1141
+ const _excluded$2 = ["renderBody"];
807
1142
  const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select')(forwardRef((p, ref) => {
808
1143
  const {
809
1144
  formatMessage
@@ -824,8 +1159,7 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
824
1159
  api,
825
1160
  getSearchProps,
826
1161
  options,
827
- getSearchCallback,
828
- labelKey
1162
+ getSearchCallback
829
1163
  } = props;
830
1164
  if (!(api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function')) {
831
1165
  return null;
@@ -866,10 +1200,10 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
866
1200
  props,
867
1201
  value,
868
1202
  setValue,
869
- onSelect,
870
1203
  onRemove,
871
1204
  onOpenChange,
872
- searchProps
1205
+ searchProps,
1206
+ isMobile
873
1207
  } = targetProps;
874
1208
  const {
875
1209
  footer,
@@ -887,7 +1221,8 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
887
1221
  searchPlaceholder,
888
1222
  allowSelectedAll,
889
1223
  labelKey,
890
- valueKey
1224
+ valueKey,
1225
+ renderMobile
891
1226
  } = props;
892
1227
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
893
1228
  const footerEl = footer && /*#__PURE__*/React.createElement("div", {
@@ -901,107 +1236,89 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
901
1236
  onOpenChange(false);
902
1237
  }
903
1238
  }) : footer);
904
- return /*#__PURE__*/React.createElement(Row, {
905
- wrap: false,
906
- ref: bodyRef
907
- }, /*#__PURE__*/React.createElement(Col, {
908
- className: classnames({
909
- [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
910
1242
  }),
911
- span: single ? 24 : 16
912
- }, /*#__PURE__*/React.createElement("div", null, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React.createElement("div", {
913
- className: classnames(style$2['table'], 'select-table')
914
- }, /*#__PURE__*/React.createElement(TableView, {
915
- columns: columns,
916
- rowKey: valueKey,
917
- rowSelection: {
918
- allowSelectedAll,
919
- isSelectedAll,
920
- onIsSelectAllChange: isSelectedAll => {
921
- setValue(isSelectedAll ? [selectedAllValue] : []);
1243
+ useSimpleBar: !isMobile,
1244
+ searchProps: searchProps,
1245
+ getSearchProps: getSearchProps,
1246
+ api: Object.assign({}, options ? {
1247
+ data: {
1248
+ options,
1249
+ searchProps
922
1250
  },
923
- type: single ? 'radio' : 'checkbox',
924
- selectedRowKeys: (value || []).map(item => item[valueKey]),
925
- onChange: (selectedRowKeys, selectedKey, {
926
- checked
1251
+ loader: ({
1252
+ data
927
1253
  }) => {
928
- setValue(value => {
929
- if (checked) {
930
- var _fetchListRef$current3;
931
- const selectedItem = (_fetchListRef$current3 = fetchListRef.current) == null ? void 0 : _fetchListRef$current3.list.find(item => item[valueKey] === selectedKey);
932
- if (selectedItem) {
933
- if (single) {
934
- return [selectedItem];
935
- }
936
- const newValue = value.slice(0);
937
- newValue.push(selectedItem);
938
- return newValue;
939
- }
940
- return value;
941
- } else {
942
- return value.filter(item => item[valueKey] !== selectedKey);
943
- }
944
- });
945
- if (isPopup && single) {
946
- 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
+ };
947
1263
  }
1264
+ return {
1265
+ pageData: options
1266
+ };
948
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] : []);
949
1289
  },
950
- render: ({
951
- renderBody
1290
+ type: single ? 'radio' : 'checkbox',
1291
+ selectedRowKeys: (value || []).map(item => item[valueKey]),
1292
+ onChange: (selectedRowKeys, selectedKey, {
1293
+ checked
952
1294
  }) => {
953
- return /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
954
- className: classnames(style$2['list'], 'select-table-list-scroll-list', {
955
- 'is-popup': isPopup
956
- }),
957
- searchProps: searchProps,
958
- getSearchProps: getSearchProps,
959
- api: Object.assign({}, options ? {
960
- data: {
961
- options,
962
- searchProps
963
- },
964
- loader: ({
965
- data
966
- }) => {
967
- const {
968
- options,
969
- searchProps
970
- } = data;
971
- if (typeof getSearchCallback === 'function') {
972
- const newOptions = options.filter(item => getSearchCallback(searchProps, item, targetProps));
973
- return {
974
- pageData: newOptions
975
- };
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];
976
1302
  }
977
- return {
978
- pageData: options
979
- };
1303
+ const newValue = value.slice(0);
1304
+ newValue.push(selectedItem);
1305
+ return newValue;
980
1306
  }
981
- } : api)
982
- }), fetchProps => {
983
- fetchListRef.current = fetchProps;
984
- const {
985
- list
986
- } = fetchProps;
987
- const contextProps = Object.assign({}, fetchProps, targetProps, {
988
- isSelectedAll
989
- });
990
- if (!(list && list.length > 0)) {
991
- return props.empty || /*#__PURE__*/React.createElement(Empty, {
992
- className: classnames(style$2['empty'])
993
- });
1307
+ return value;
1308
+ } else {
1309
+ return value.filter(item => item[valueKey] !== selectedKey);
994
1310
  }
995
- return renderBody(list, contextProps);
996
1311
  });
1312
+ if (isPopup && single) {
1313
+ onOpenChange(false);
1314
+ }
997
1315
  }
998
- })), single && footerEl || /*#__PURE__*/React.createElement("div", {
999
- className: classnames(style$2['footer'], 'select-table-footer')
1000
- })), !single && /*#__PURE__*/React.createElement(Col, {
1316
+ };
1317
+ const selectedPanel = !single && /*#__PURE__*/React.createElement("div", {
1001
1318
  className: classnames(style$2['right-options'], {
1002
- 'is-popup': isPopup
1003
- }),
1004
- span: 8
1319
+ 'is-popup': isPopup,
1320
+ [style$2['is-mobile']]: isMobile
1321
+ })
1005
1322
  }, /*#__PURE__*/React.createElement(SearchInput, {
1006
1323
  className: style$2['tags-search'],
1007
1324
  placeholder: searchPlaceholder,
@@ -1024,46 +1341,116 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
1024
1341
  }
1025
1342
  }, formatMessage({
1026
1343
  id: 'removeAll'
1027
- })))), /*#__PURE__*/React.createElement(SimpleBar, null, /*#__PURE__*/React.createElement(Flex, {
1028
- wrap: true,
1029
- gap: 8
1030
- }, value.filter(item => getTagSearchCallback(tagSearchText, item, targetProps)).map(item => {
1031
- var _fetchListRef$current4, _fetchListRef$current5;
1032
- return /*#__PURE__*/React.createElement(Tag, {
1033
- className: style$2['tag'],
1034
- key: item[valueKey],
1035
- closable: true,
1036
- bordered: false,
1037
- onClose: e => {
1038
- e.preventDefault();
1039
- onRemove(item);
1040
- }
1041
- }, /*#__PURE__*/React.createElement(Popover, {
1042
- getPopupContainer: () => bodyRef.current,
1043
- content: /*#__PURE__*/React.createElement(CentralContent, {
1044
- className: style$2['descriptions'],
1045
- columns: columns.filter(item => {
1046
- if (Object.hasOwn(item, 'previewHidden')) {
1047
- return !item.previewHidden;
1048
- }
1049
- return item.name !== 'options';
1050
- }).map(item => Object.assign({}, item, {
1051
- span: 12
1052
- })),
1053
- dataSource: Object.assign({}, item),
1054
- context: Object.assign({}, targetProps, {
1055
- fetchApi: (_fetchListRef$current4 = fetchListRef.current) == null ? void 0 : _fetchListRef$current4.fetchApi,
1056
- 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
+ })
1057
1376
  })
1058
- })
1059
- }, /*#__PURE__*/React.createElement("span", {
1060
- className: style$2['tag-inner']
1061
- }, item[labelKey])));
1062
- }))), 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));
1063
1450
  });
1064
1451
  }));
1065
1452
 
1066
- 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"};
1067
1454
 
1068
1455
  const _excluded$1 = ["children"],
1069
1456
  _excluded2 = ["data"];
@@ -1213,7 +1600,8 @@ const SelectTree = forwardRef((_ref, ref) => {
1213
1600
  const {
1214
1601
  props,
1215
1602
  value,
1216
- onOpenChange
1603
+ onOpenChange,
1604
+ isMobile
1217
1605
  } = targetProps;
1218
1606
  const {
1219
1607
  footer,
@@ -1228,11 +1616,11 @@ const SelectTree = forwardRef((_ref, ref) => {
1228
1616
  selectedAllValue
1229
1617
  } = props;
1230
1618
  const components = {
1231
- selectedAll: /*#__PURE__*/React.createElement("div", {
1619
+ selectedAll: !single && allowSelectedAll && /*#__PURE__*/React.createElement("div", {
1232
1620
  className: classnames(style$1['selected-all'], 'select-tree-selected-all', {
1233
1621
  'is-popup': isPopup
1234
1622
  })
1235
- }, !single && allowSelectedAll && /*#__PURE__*/React.createElement(SelectedAll, null)),
1623
+ }, /*#__PURE__*/React.createElement(SelectedAll, null)),
1236
1624
  treeList: /*#__PURE__*/React.createElement(Fetch, _extends({}, Object.assign({}, options ? {
1237
1625
  data: {
1238
1626
  options
@@ -1248,14 +1636,23 @@ const SelectTree = forwardRef((_ref, ref) => {
1248
1636
  } = _ref2,
1249
1637
  fetchProps = _objectWithoutPropertiesLoose(_ref2, _excluded2);
1250
1638
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
1251
- return /*#__PURE__*/React.createElement(SimpleBar, {
1252
- className: classnames(style$1['list'], 'select-tree-scroll-list', {
1253
- 'is-popup': isPopup
1254
- })
1255
- }, renderTree(Object.assign({}, fetchProps, targetProps, {
1639
+ const treeContent = renderTree(Object.assign({}, fetchProps, targetProps, {
1256
1640
  isSelectedAll,
1257
1641
  data
1258
- })));
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);
1259
1656
  }
1260
1657
  })),
1261
1658
  selectedTag: showSelectedTag && /*#__PURE__*/React.createElement("div", {
@@ -1280,7 +1677,10 @@ const SelectTree = forwardRef((_ref, ref) => {
1280
1677
  }));
1281
1678
  }
1282
1679
  return /*#__PURE__*/React.createElement(Flex, {
1283
- vertical: true
1680
+ vertical: true,
1681
+ className: classnames({
1682
+ [style$1['is-mobile']]: isMobile
1683
+ })
1284
1684
  }, components.search, components.selectedAll, components.treeList, components.footer, components.selectedTag);
1285
1685
  });
1286
1686
  });
@@ -1488,7 +1888,7 @@ const createTreeUtils = mapping => {
1488
1888
  };
1489
1889
  };
1490
1890
 
1491
- 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"};
1492
1892
 
1493
1893
  const CustomMenu = ({
1494
1894
  className,
@@ -1511,7 +1911,8 @@ const CustomMenu = ({
1511
1911
  const isSelected = selectedKeys == null ? void 0 : selectedKeys.includes(item.key);
1512
1912
  return /*#__PURE__*/React.createElement(List.Item, {
1513
1913
  className: classnames(style['custom-menu-item'], {
1514
- [style['selected']]: isSelected
1914
+ [style['selected']]: isSelected,
1915
+ selected: isSelected
1515
1916
  }),
1516
1917
  onClick: e => handleItemClick(item.key, e)
1517
1918
  }, item.label);
@@ -1542,13 +1943,16 @@ const CascaderInner = ({
1542
1943
  valueKey,
1543
1944
  labelKey,
1544
1945
  onOpenChange,
1545
- open
1946
+ open,
1947
+ isMobile
1546
1948
  }) => {
1547
1949
  const {
1548
1950
  message
1549
1951
  } = App.useApp();
1550
1952
  const [searchText, setSearchText] = useState('');
1551
1953
  const [loading, setLoading] = useState(false);
1954
+ // 移动端弹窗内不用 SimpleBar,改原生滚动
1955
+ const ScrollBox = isMobile ? 'div' : SimpleBar;
1552
1956
 
1553
1957
  // 构建 mapping
1554
1958
  const mapping = useMemo(() => {
@@ -1726,7 +2130,8 @@ const CascaderInner = ({
1726
2130
  const _currentIds3 = value.map(v => typeof v === 'object' ? v[valueKey] : v);
1727
2131
  return /*#__PURE__*/React.createElement("div", {
1728
2132
  className: classnames(style['content'], {
1729
- [style['is-popup']]: isPopup
2133
+ [style['is-popup']]: isPopup,
2134
+ [style['is-mobile']]: isMobile
1730
2135
  })
1731
2136
  }, /*#__PURE__*/React.createElement(SearchInput, {
1732
2137
  className: classnames(style['search-input'], {
@@ -1737,7 +2142,7 @@ const CascaderInner = ({
1737
2142
  onSearch: setSearchText,
1738
2143
  simple: isPopup,
1739
2144
  showSearchButton: !isPopup
1740
- }), /*#__PURE__*/React.createElement(SimpleBar, {
2145
+ }), /*#__PURE__*/React.createElement(ScrollBox, {
1741
2146
  className: style['scroll-plus-box']
1742
2147
  }, searchResults.length === 0 ? /*#__PURE__*/React.createElement(Empty, {
1743
2148
  description: "\u6682\u65E0\u6570\u636E"
@@ -1768,7 +2173,8 @@ const CascaderInner = ({
1768
2173
  return /*#__PURE__*/React.createElement("div", {
1769
2174
  className: classnames(style['content'], {
1770
2175
  [style['is-popup']]: isPopup,
1771
- [style['has-search']]: !!onSearch
2176
+ [style['has-search']]: !!onSearch,
2177
+ [style['is-mobile']]: isMobile
1772
2178
  }),
1773
2179
  style: {
1774
2180
  '--menu-item-width': numberToPx(menuItemWidth)
@@ -1782,23 +2188,65 @@ const CascaderInner = ({
1782
2188
  onSearch: setSearchText,
1783
2189
  simple: isPopup,
1784
2190
  showSearchButton: !isPopup
1785
- }), /*#__PURE__*/React.createElement(SimpleBar, {
1786
- className: style['scroller'],
2191
+ }), /*#__PURE__*/React.createElement(ScrollBox, _extends({
2192
+ className: style['scroller']
2193
+ }, isMobile ? {} : {
1787
2194
  options: {
1788
2195
  autoHide: false
1789
2196
  }
1790
- }, /*#__PURE__*/React.createElement("div", {
1791
- className: style['columns']
2197
+ }), /*#__PURE__*/React.createElement("div", {
2198
+ className: classnames(style['columns'], {
2199
+ [style['is-mobile']]: isMobile
2200
+ })
1792
2201
  }, selectedIds.map((selectedId, index) => {
1793
2202
  const selectNode = mapping.get(selectedId);
1794
2203
  const siblingNodes = treeUtils.getSiblingNode(selectedId);
1795
2204
  const isLastLevel = !isNotLastNode(selectNode == null ? void 0 : selectNode.id) && index > 0;
1796
- return /*#__PURE__*/React.createElement(SimpleBar, {
2205
+ return /*#__PURE__*/React.createElement(ScrollBox, {
1797
2206
  key: selectedId || index,
1798
2207
  className: classnames(style['content-item'], {
1799
2208
  [style['last-level-area']]: isLastLevel
1800
2209
  })
1801
- }, 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, {
1802
2250
  wrap: true,
1803
2251
  style: {
1804
2252
  padding: 12
@@ -2054,7 +2502,8 @@ const SelectCascader = _ref => {
2054
2502
  valueKey: valueKey,
2055
2503
  labelKey: labelKey,
2056
2504
  onOpenChange: contextProps.onOpenChange,
2057
- open: contextProps.open
2505
+ open: contextProps.open,
2506
+ isMobile: contextProps.isMobile
2058
2507
  });
2059
2508
  });
2060
2509
  };