@kne/super-select 0.1.40 → 0.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -66,7 +66,7 @@ const {
66
66
  useContext
67
67
  } = context;
68
68
 
69
- 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"};
69
+ var style$6 = {"kne-responsive-boundary":"kne-super-select_mJpBa","kne-responsive-scroll":"kne-super-select_90VCi","select-input":"kne-super-select_d8lGc","disabled":"kne-super-select_3kjwO","wrap":"kne-super-select_dsTM2","select-input-inner":"kne-super-select_NQoX9","large":"kne-super-select_T8ZX8","small":"kne-super-select_1B72H","is-mobile":"kne-super-select_VoUSp","single-label":"kne-super-select_pL0tE","tag-item":"kne-super-select_lc4o7","tag-label":"kne-super-select_RJmlD","overflow-tag":"kne-super-select_aHua2","measure-layer":"kne-super-select_QoQpC","select-input-icon":"kne-super-select_g8QC-","placeholder":"kne-super-select_r3q69","overlay-content":"kne-super-select_zEqGe","mobile-sheet-body":"kne-super-select_Gmh-5","overlay":"kne-super-select_ybN30","select-input-prefix":"kne-super-select_4Pw75","select-input-suffix":"kne-super-select_Wd4pE","mobile-sheet-mask":"kne-super-select_EOKDm","mobile-sheet-mask-fade-in":"kne-super-select_tWTg9","mobile-sheet-mask-leave":"kne-super-select_UAU38","mobile-sheet-mask-fade-out":"kne-super-select_e3tK2","mobile-sheet-popup":"kne-super-select_x0gT0","mobile-sheet-portal":"kne-super-select_kuA7x","mobile-sheet-header":"kne-super-select_EqRnq","mobile-sheet-title":"kne-super-select_5DU3x","mobile-sheet-action":"kne-super-select_UMAVM","mobile-sheet-confirm":"kne-super-select_Y48cj"};
70
70
 
71
71
  const locale$1 = {
72
72
  placeholder: '请选择',
@@ -184,21 +184,12 @@ const TagOverflowInner = ({
184
184
  }, "+", hiddenCount));
185
185
  };
186
186
 
187
- const _excluded$4 = ["children"];
187
+ const _excluded$3 = ["children"];
188
188
  const MOBILE_SHEET_MAX_HEIGHT = '80%';
189
189
  const MOBILE_SHEET_MIN_HEIGHT = '30%';
190
190
  const MOBILE_MASK_Z_INDEX = 1000;
191
191
  const MOBILE_POPUP_Z_INDEX = 1050;
192
192
  const MASK_ANIMATION_DURATION = 180;
193
- // example-driver 手机预览外框(container 模式可能被外层 Global 的 viewport Provider 盖掉)
194
- const EXAMPLE_PHONE_SCROLL_SELECTOR = '.example-driver-device-scroll';
195
- const EXAMPLE_BOUNDARY_SELECTOR = '.kne-responsive-boundary';
196
- const findExamplePhoneMountNode = anchor => {
197
- if (!anchor || typeof anchor.closest !== 'function') {
198
- return null;
199
- }
200
- return anchor.closest(EXAMPLE_PHONE_SCROLL_SELECTOR) || anchor.closest(EXAMPLE_BOUNDARY_SELECTOR);
201
- };
202
193
  let parentScrollLockCount = 0;
203
194
  let parentScrollLocked = [];
204
195
  const lockParentScroll = getScrollElements => {
@@ -265,7 +256,7 @@ const pxToNumber = value => {
265
256
  // 与 Modal 模式一致:面板内用临时 value,确认后才写回
266
257
  const ModalContent = _ref2 => {
267
258
  let renderContent = _ref2.children,
268
- others = _objectWithoutPropertiesLoose(_ref2, _excluded$4);
259
+ others = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
269
260
  const open = others.open,
270
261
  propsValue = others.value;
271
262
  const _useState = React.useState(propsValue),
@@ -451,13 +442,12 @@ const SelectInput = reactIntl.createWithIntlProvider({
451
442
  isMobile = contextProps.isMobile,
452
443
  getPopupContainer = contextProps.getPopupContainer,
453
444
  formatMessage = contextProps.formatMessage,
454
- useBoundaryMount = contextProps.useBoundaryMount;
445
+ fixedModeClass = contextProps.fixedModeClass;
455
446
  const placeholder = props.placeholder,
456
447
  children = props.children,
457
448
  overlayClassName = props.overlayClassName,
458
449
  disableMobileSheet = props.disableMobileSheet;
459
450
  if (isMobile && !disableMobileSheet) {
460
- const fixedModeClass = useBoundaryMount ? style$6['is-boundary'] : style$6['is-viewport'];
461
451
  const mountNode = typeof getPopupContainer === 'function' ? getPopupContainer() : null;
462
452
  const closeWithoutCommit = () => onOpenChange(false);
463
453
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(MobileSheetMask, {
@@ -529,19 +519,27 @@ const SelectInput = reactIntl.createWithIntlProvider({
529
519
  valueKey = props.valueKey,
530
520
  size = props.size,
531
521
  disableMobileSheet = props.disableMobileSheet;
532
- const isMobileContext = responsiveUtils.useIsMobile();
533
- const _useResponsiveContext = responsiveUtils.useResponsiveContext(),
534
- mode = _useResponsiveContext.mode;
535
522
  const getPopupContainerDefault = responsiveUtils.usePopupContainer();
536
523
  const getScrollElement = responsiveUtils.useScrollElement();
537
- // example 手机框:外层 Global(viewport) 可能盖掉 container 的 useIsMobile,需 DOM 兜底
538
- const _useState4 = React.useState(false),
539
- inExamplePhoneFrame = _useState4[0],
540
- setInExamplePhoneFrame = _useState4[1];
541
- const isMobile = isMobileContext || inExamplePhoneFrame;
524
+ const wrapCustomGetPopupContainer = React.useMemo(() => {
525
+ if (typeof getPopupContainerProp === 'function') {
526
+ return triggerNode => getPopupContainerProp(triggerNode) || null;
527
+ }
528
+ if (getPopupContainerProp) {
529
+ return () => getPopupContainerProp;
530
+ }
531
+ return undefined;
532
+ }, [getPopupContainerProp]);
533
+ const _useMobilePopupMount = responsiveUtils.useMobilePopupMount({
534
+ cover: 'viewport',
535
+ getPopupContainer: wrapCustomGetPopupContainer
536
+ }),
537
+ isMobile = _useMobilePopupMount.isMobile,
538
+ fixedModeClass = _useMobilePopupMount.fixedModeClass,
539
+ getSheetPopupContainer = _useMobilePopupMount.getPopupContainer,
540
+ anchorRef = _useMobilePopupMount.anchorRef;
542
541
  const useMobileSheet = isMobile && !disableMobileSheet;
543
- const useBoundaryMount = useMobileSheet && (mode === 'container' || inExamplePhoneFrame);
544
- const fixedModeClass = useBoundaryMount ? style$6['is-boundary'] : style$6['is-viewport'];
542
+ const useBoundaryMount = !!(isMobile && fixedModeClass === responsiveUtils.MOBILE_POPUP_MODE.boundary);
545
543
  const mergedOverlayStyle = React.useMemo(() => {
546
544
  return Object.assign({}, overlayStyle, zIndex != null ? {
547
545
  zIndex
@@ -565,9 +563,9 @@ const SelectInput = reactIntl.createWithIntlProvider({
565
563
  })),
566
564
  value = _useControlValue[0],
567
565
  setValue = _useControlValue[1];
568
- const _useState5 = React.useState({}),
569
- searchProps = _useState5[0],
570
- setSearchProps = _useState5[1];
566
+ const _useState4 = React.useState({}),
567
+ searchProps = _useState4[0],
568
+ setSearchProps = _useState4[1];
571
569
  const _useControlValue2 = useControlValue__default["default"](props, {
572
570
  defaultValue: 'defaultOpen',
573
571
  value: 'open',
@@ -575,18 +573,18 @@ const SelectInput = reactIntl.createWithIntlProvider({
575
573
  }),
576
574
  open = _useControlValue2[0],
577
575
  setOpen = _useControlValue2[1];
578
- const _useState6 = React.useState(false),
579
- hover = _useState6[0],
580
- setHover = _useState6[1];
576
+ const _useState5 = React.useState(false),
577
+ hover = _useState5[0],
578
+ setHover = _useState5[1];
579
+ const _useState6 = React.useState(0),
580
+ innerWidth = _useState6[0],
581
+ setInnerWidth = _useState6[1];
581
582
  const _useState7 = React.useState(0),
582
- innerWidth = _useState7[0],
583
- setInnerWidth = _useState7[1];
584
- const _useState8 = React.useState(0),
585
- containerWidth = _useState8[0],
586
- setContainerWidth = _useState8[1];
587
- const _useState9 = React.useState(null),
588
- popupMountNode = _useState9[0],
589
- setPopupMountNode = _useState9[1];
583
+ containerWidth = _useState7[0],
584
+ setContainerWidth = _useState7[1];
585
+ const _useState8 = React.useState(null),
586
+ popupMountNode = _useState8[0],
587
+ setPopupMountNode = _useState8[1];
590
588
  const containerWidthChange = el => {
591
589
  if (!el) {
592
590
  return;
@@ -595,51 +593,50 @@ const SelectInput = reactIntl.createWithIntlProvider({
595
593
  setContainerWidth(containerWidth);
596
594
  const innerEl = el.querySelector('.select-input-inner');
597
595
  setInnerWidth(innerEl.clientWidth);
598
- setInExamplePhoneFrame(!!findExamplePhoneMountNode(el));
599
596
  };
600
597
  const popupOverlayWidth = React.useMemo(() => {
601
598
  return numberToPx$1(Math.max(containerWidth, pxToNumber(overlayWidth)));
602
599
  }, [containerWidth, overlayWidth]);
603
- const containerRef = useResize__default["default"](containerWidthChange);
600
+ const resizeRef = useResize__default["default"](containerWidthChange);
601
+ const setContainerRef = React.useCallback(node => {
602
+ resizeRef.current = node;
603
+ anchorRef(node);
604
+ }, [anchorRef, resizeRef]);
604
605
  const resolveGetPopupContainer = React.useCallback(triggerNode => {
605
606
  if (typeof getPopupContainerProp === 'function') {
606
607
  const customContainer = getPopupContainerProp(triggerNode);
607
608
  if (customContainer) {
608
609
  return customContainer;
609
610
  }
611
+ } else if (getPopupContainerProp) {
612
+ return getPopupContainerProp;
610
613
  }
611
- const exampleMount = findExamplePhoneMountNode(triggerNode || containerRef.current);
612
- if (exampleMount) {
613
- return exampleMount;
614
- }
615
- if (useMobileSheet && !useBoundaryMount && typeof document !== 'undefined') {
616
- return document.body;
614
+ if (useMobileSheet) {
615
+ return getSheetPopupContainer(triggerNode);
617
616
  }
618
617
  return getPopupContainerDefault(triggerNode);
619
- }, [getPopupContainerDefault, getPopupContainerProp, useBoundaryMount, useMobileSheet, containerRef]);
618
+ }, [getPopupContainerDefault, getPopupContainerProp, getSheetPopupContainer, useMobileSheet]);
620
619
 
621
- // 打开时再取挂载节点,避免落到 body 导致 absolute 半屏跑出手机预览框
620
+ // 打开时再取挂载节点,避免落到错误容器
622
621
  React.useLayoutEffect(() => {
623
- const exampleMount = findExamplePhoneMountNode(containerRef.current);
624
- setInExamplePhoneFrame(!!exampleMount);
625
622
  if (!useMobileSheet) {
626
623
  setPopupMountNode(null);
627
624
  return;
628
625
  }
629
- setPopupMountNode(resolveGetPopupContainer(containerRef.current) || (typeof document !== 'undefined' ? document.body : null));
630
- }, [useMobileSheet, resolveGetPopupContainer, open, containerRef]);
626
+ setPopupMountNode(resolveGetPopupContainer(resizeRef.current) || (typeof document !== 'undefined' ? document.body : null));
627
+ }, [useMobileSheet, resolveGetPopupContainer, open, resizeRef]);
631
628
  const getLockScrollTargets = React.useCallback(() => {
632
629
  const targets = [];
633
630
  const scrollEl = typeof getScrollElement === 'function' ? getScrollElement() : null;
634
631
  if (scrollEl) {
635
632
  targets.push(scrollEl);
636
633
  }
637
- const mountNode = popupMountNode || findExamplePhoneMountNode(containerRef.current);
634
+ const mountNode = popupMountNode;
638
635
  if (mountNode && mountNode !== document.body) {
639
636
  targets.push(mountNode);
640
637
  }
641
638
  return targets;
642
- }, [getScrollElement, popupMountNode, containerRef]);
639
+ }, [getScrollElement, popupMountNode]);
643
640
  const sheetOpen = !disabled && open;
644
641
  useLockParentScroll(useMobileSheet && sheetOpen, getLockScrollTargets);
645
642
  const _App$useApp = antd.App.useApp(),
@@ -712,6 +709,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
712
709
  children,
713
710
  isMobile,
714
711
  useBoundaryMount,
712
+ fixedModeClass,
715
713
  getPopupContainer: resolveGetPopupContainer,
716
714
  formatMessage
717
715
  };
@@ -723,7 +721,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
723
721
  return contextProps.props.inputRender(props, contextProps);
724
722
  }
725
723
  return /*#__PURE__*/React__default["default"].createElement(antd.Flex, _extends({}, props, {
726
- ref: containerRef,
724
+ ref: setContainerRef,
727
725
  className: classnames__default["default"](className, style$6['select-input'], 'select-input', {
728
726
  [style$6['wrap']]: labelWrap,
729
727
  [style$6['disabled']]: disabled,
@@ -946,10 +944,10 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
946
944
 
947
945
  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"};
948
946
 
949
- const _excluded$3 = ["children"];
947
+ const _excluded$2 = ["children"];
950
948
  const SelectList = React.forwardRef((_ref, ref) => {
951
949
  let children = _ref.children,
952
- p = _objectWithoutPropertiesLoose(_ref, _excluded$3);
950
+ p = _objectWithoutPropertiesLoose(_ref, _excluded$2);
953
951
  const fetchListRef = React.useRef(null);
954
952
  const props = Object.assign({}, {
955
953
  renderItemContent: _ref2 => {
@@ -1139,7 +1137,72 @@ const SelectList = React.forwardRef((_ref, ref) => {
1139
1137
 
1140
1138
  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"};
1141
1139
 
1142
- const _excluded$2 = ["renderBody"];
1140
+ const isEmptyParentKey = value => value == null || value === '';
1141
+ const flattenSelectList = (list, _ref) => {
1142
+ let dataType = _ref.dataType,
1143
+ rowKey = _ref.rowKey,
1144
+ parentKey = _ref.parentKey,
1145
+ childrenKey = _ref.childrenKey;
1146
+ if (!list || !TableView.isTreeDataType(dataType)) {
1147
+ return list || [];
1148
+ }
1149
+ const tree = TableView.normalizeTreeData(list, {
1150
+ dataType,
1151
+ rowKey,
1152
+ parentKey,
1153
+ childrenKey
1154
+ });
1155
+ return TableView.flattenAllTree(tree, {
1156
+ rowKey,
1157
+ childrenKey
1158
+ }).map(row => row.item);
1159
+ };
1160
+ const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps, _ref2) => {
1161
+ let dataType = _ref2.dataType,
1162
+ valueKey = _ref2.valueKey,
1163
+ parentKey = _ref2.parentKey,
1164
+ childrenKey = _ref2.childrenKey;
1165
+ if (typeof getSearchCallback !== 'function') {
1166
+ return options;
1167
+ }
1168
+ if (dataType === 'tree') {
1169
+ const filterNodes = nodes => (nodes || []).reduce((acc, item) => {
1170
+ const rawChildren = Array.isArray(item[childrenKey]) ? item[childrenKey] : [];
1171
+ const filteredChildren = filterNodes(rawChildren);
1172
+ const selfMatch = getSearchCallback(searchProps, item, targetProps);
1173
+ if (selfMatch) {
1174
+ acc.push(item);
1175
+ } else if (filteredChildren.length > 0) {
1176
+ acc.push(Object.assign({}, item, {
1177
+ [childrenKey]: filteredChildren
1178
+ }));
1179
+ }
1180
+ return acc;
1181
+ }, []);
1182
+ return filterNodes(options);
1183
+ }
1184
+ if (dataType === 'treeList') {
1185
+ const matched = options.filter(item => getSearchCallback(searchProps, item, targetProps));
1186
+ if (matched.length === 0) {
1187
+ return [];
1188
+ }
1189
+ const idSet = new Set(matched.map(item => item[valueKey]));
1190
+ const map = new Map(options.map(item => [item[valueKey], item]));
1191
+ matched.forEach(item => {
1192
+ let parentId = item[parentKey];
1193
+ while (!isEmptyParentKey(parentId) && !idSet.has(parentId)) {
1194
+ idSet.add(parentId);
1195
+ const parent = map.get(parentId);
1196
+ if (!parent) {
1197
+ break;
1198
+ }
1199
+ parentId = parent[parentKey];
1200
+ }
1201
+ });
1202
+ return options.filter(item => idSet.has(item[valueKey]));
1203
+ }
1204
+ return options.filter(item => getSearchCallback(searchProps, item, targetProps));
1205
+ };
1143
1206
  const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(React.forwardRef((p, ref) => {
1144
1207
  const _useIntl = reactIntl.useIntl(),
1145
1208
  formatMessage = _useIntl.formatMessage;
@@ -1149,6 +1212,10 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
1149
1212
  const fetchListRef = React.useRef();
1150
1213
  const props = Object.assign({}, {
1151
1214
  overlayWidth: '600px',
1215
+ dataType: 'list',
1216
+ parentKey: 'parentId',
1217
+ childrenKey: 'children',
1218
+ hasChildrenKey: 'hasChildren',
1152
1219
  filterRender: contextProps => {
1153
1220
  const props = contextProps.props,
1154
1221
  searchProps = contextProps.searchProps,
@@ -1213,8 +1280,20 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
1213
1280
  allowSelectedAll = props.allowSelectedAll,
1214
1281
  labelKey = props.labelKey,
1215
1282
  valueKey = props.valueKey,
1216
- renderMobile = props.renderMobile;
1283
+ renderMobile = props.renderMobile,
1284
+ dataType = props.dataType,
1285
+ parentKey = props.parentKey,
1286
+ childrenKey = props.childrenKey,
1287
+ hasChildrenKey = props.hasChildrenKey,
1288
+ treeTitleKey = props.treeTitleKey,
1289
+ onLoadChildren = props.onLoadChildren,
1290
+ expandedKeys = props.expandedKeys,
1291
+ defaultExpandedKeys = props.defaultExpandedKeys,
1292
+ onExpandedKeysChange = props.onExpandedKeysChange,
1293
+ indentSize = props.indentSize,
1294
+ checkRelation = props.checkRelation;
1217
1295
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
1296
+ const resolvedTreeTitleKey = treeTitleKey || labelKey;
1218
1297
  const footerEl = footer && /*#__PURE__*/React__default["default"].createElement("div", {
1219
1298
  className: classnames__default["default"](style$2['footer'], 'select-table-footer')
1220
1299
  }, typeof footer === 'function' ? footer({
@@ -1226,7 +1305,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
1226
1305
  onOpenChange(false);
1227
1306
  }
1228
1307
  }) : footer);
1229
- const renderScrollList = renderBody => /*#__PURE__*/React__default["default"].createElement(scrollLoader.FetchScrollLoader, _extends({}, props, {
1308
+ const renderScrollList = renderContent => /*#__PURE__*/React__default["default"].createElement(scrollLoader.FetchScrollLoader, _extends({}, props, {
1230
1309
  className: classnames__default["default"](style$2['list'], 'select-table-list-scroll-list', {
1231
1310
  'is-popup': isPopup
1232
1311
  }),
@@ -1238,18 +1317,17 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
1238
1317
  options,
1239
1318
  searchProps
1240
1319
  },
1241
- loader: _ref => {
1242
- let data = _ref.data;
1320
+ loader: _ref3 => {
1321
+ let data = _ref3.data;
1243
1322
  const options = data.options,
1244
1323
  searchProps = data.searchProps;
1245
- if (typeof getSearchCallback === 'function') {
1246
- const newOptions = options.filter(item => getSearchCallback(searchProps, item, targetProps));
1247
- return {
1248
- pageData: newOptions
1249
- };
1250
- }
1251
1324
  return {
1252
- pageData: options
1325
+ pageData: filterTreeOptions(options, searchProps, getSearchCallback, targetProps, {
1326
+ dataType,
1327
+ valueKey,
1328
+ parentKey,
1329
+ childrenKey
1330
+ })
1253
1331
  };
1254
1332
  }
1255
1333
  } : api)
@@ -1264,7 +1342,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
1264
1342
  className: classnames__default["default"](style$2['empty'])
1265
1343
  });
1266
1344
  }
1267
- return renderBody(list, contextProps);
1345
+ return renderContent(list, contextProps);
1268
1346
  });
1269
1347
  const tableSelection = {
1270
1348
  allowSelectedAll,
@@ -1274,26 +1352,20 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
1274
1352
  },
1275
1353
  type: single ? 'radio' : 'checkbox',
1276
1354
  selectedRowKeys: (value || []).map(item => item[valueKey]),
1277
- onChange: (selectedRowKeys, selectedKey, _ref2) => {
1278
- let checked = _ref2.checked;
1279
- setValue(value => {
1280
- if (checked) {
1281
- var _fetchListRef$current3;
1282
- const selectedItem = (_fetchListRef$current3 = fetchListRef.current) == null ? void 0 : _fetchListRef$current3.list.find(item => item[valueKey] === selectedKey);
1283
- if (selectedItem) {
1284
- if (single) {
1285
- return [selectedItem];
1286
- }
1287
- const newValue = value.slice(0);
1288
- newValue.push(selectedItem);
1289
- return newValue;
1290
- }
1291
- return value;
1292
- } else {
1293
- return value.filter(item => item[valueKey] !== selectedKey);
1294
- }
1355
+ checkRelation,
1356
+ onChange: selectedRowKeys => {
1357
+ setValue(prev => {
1358
+ var _fetchListRef$current3;
1359
+ const prevMap = new Map((prev || []).map(item => [item[valueKey], item]));
1360
+ const listMap = new Map(flattenSelectList((_fetchListRef$current3 = fetchListRef.current) == null ? void 0 : _fetchListRef$current3.list, {
1361
+ dataType,
1362
+ rowKey: valueKey,
1363
+ parentKey,
1364
+ childrenKey
1365
+ }).map(item => [item[valueKey], item]));
1366
+ return (selectedRowKeys || []).map(key => prevMap.get(key) || listMap.get(key)).filter(Boolean);
1295
1367
  });
1296
- if (isPopup && single) {
1368
+ if (isPopup && single && selectedRowKeys && selectedRowKeys.length > 0) {
1297
1369
  onOpenChange(false);
1298
1370
  }
1299
1371
  }
@@ -1372,27 +1444,6 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
1372
1444
  className: style$2['selected-tags-scroll']
1373
1445
  }, selectedTags);
1374
1446
  })(), footerEl);
1375
- const tableMobileRender = _ref3 => {
1376
- let renderBody = _ref3.renderBody,
1377
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded$2);
1378
- return renderScrollList((list, contextProps) => {
1379
- if (typeof renderMobile === 'function') {
1380
- return renderMobile(_extends({}, rest, contextProps, {
1381
- list,
1382
- renderBody: function (nextList, nextContext) {
1383
- if (nextList === void 0) {
1384
- nextList = list;
1385
- }
1386
- if (nextContext === void 0) {
1387
- nextContext = contextProps;
1388
- }
1389
- return renderBody(nextList, nextContext);
1390
- }
1391
- }));
1392
- }
1393
- return renderBody(list, contextProps);
1394
- });
1395
- };
1396
1447
  const tablePanel = /*#__PURE__*/React__default["default"].createElement("div", {
1397
1448
  className: classnames__default["default"](style$2['table-panel'], {
1398
1449
  [style$2['single-body']]: single
@@ -1401,15 +1452,49 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
1401
1452
  className: style$2['filter-wrap']
1402
1453
  }, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React__default["default"].createElement("div", {
1403
1454
  className: classnames__default["default"](style$2['table'], 'select-table')
1404
- }, /*#__PURE__*/React__default["default"].createElement(TableView__default["default"], {
1405
- columns: columns,
1406
- rowKey: valueKey,
1407
- rowSelection: tableSelection,
1408
- renderMobile: renderMobile === false ? undefined : tableMobileRender,
1409
- render: _ref4 => {
1410
- let renderBody = _ref4.renderBody;
1411
- return renderScrollList(renderBody);
1455
+ }, renderScrollList((list, contextProps) => {
1456
+ const tableViewProps = {
1457
+ dataSource: list,
1458
+ columns,
1459
+ rowKey: valueKey,
1460
+ rowSelection: tableSelection,
1461
+ context: contextProps,
1462
+ dataType,
1463
+ parentKey,
1464
+ childrenKey,
1465
+ hasChildrenKey,
1466
+ treeTitleKey: resolvedTreeTitleKey,
1467
+ renderMobile: renderMobile === false ? false : typeof renderMobile === 'function' ? mobileProps => renderMobile(_extends({}, mobileProps, contextProps, {
1468
+ list: mobileProps.displayDataSource || list,
1469
+ dataSource: list,
1470
+ renderBody: function (nextList, nextContext) {
1471
+ if (nextList === void 0) {
1472
+ nextList = mobileProps.displayDataSource || list;
1473
+ }
1474
+ if (nextContext === void 0) {
1475
+ nextContext = contextProps;
1476
+ }
1477
+ return mobileProps.renderBody(nextList, nextContext);
1478
+ }
1479
+ })) : true
1480
+ };
1481
+ // 可选树形 props:仅在有值 / 用户显式传入时透传,避免 undefined 覆盖 TableView 默认值
1482
+ if (typeof onLoadChildren === 'function') {
1483
+ tableViewProps.onLoadChildren = onLoadChildren;
1484
+ }
1485
+ if (typeof onExpandedKeysChange === 'function') {
1486
+ tableViewProps.onExpandedKeysChange = onExpandedKeysChange;
1487
+ }
1488
+ if (indentSize != null) {
1489
+ tableViewProps.indentSize = indentSize;
1412
1490
  }
1491
+ if (Object.prototype.hasOwnProperty.call(p, 'expandedKeys')) {
1492
+ tableViewProps.expandedKeys = expandedKeys;
1493
+ }
1494
+ if (Object.prototype.hasOwnProperty.call(p, 'defaultExpandedKeys')) {
1495
+ tableViewProps.defaultExpandedKeys = defaultExpandedKeys;
1496
+ }
1497
+ return /*#__PURE__*/React__default["default"].createElement(TableView__default["default"], tableViewProps);
1413
1498
  })), single && footerEl || !isMobile && /*#__PURE__*/React__default["default"].createElement("div", {
1414
1499
  className: classnames__default["default"](style$2['footer'], 'select-table-footer')
1415
1500
  }));
@@ -2496,6 +2581,10 @@ const SelectCascader = _ref4 => {
2496
2581
  });
2497
2582
  };
2498
2583
 
2584
+ Object.defineProperty(exports, 'mergeTreeChildren', {
2585
+ enumerable: true,
2586
+ get: function () { return TableView.mergeTreeChildren; }
2587
+ });
2499
2588
  exports.SelectCascader = SelectCascader;
2500
2589
  exports.SelectInput = SelectInput;
2501
2590
  exports.SelectTableList = SelectTableList;