@kne/super-select 0.1.41 → 0.1.43
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/README.md +475 -278
- package/dist/index.css +26 -17
- package/dist/index.css.map +1 -1
- package/dist/index.js +193 -83
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +185 -78
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/dist/index.modern.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useRef, useLayoutEffect, forwardRef, useMemo, useCallback,
|
|
1
|
+
import React, { useState, useRef, useLayoutEffect, forwardRef, useMemo, useCallback, useEffect, useImperativeHandle } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { createContext } from '@kne/global-context';
|
|
4
4
|
import useResize from '@kne/use-resize';
|
|
@@ -17,7 +17,8 @@ import SimpleBar from 'simplebar-react';
|
|
|
17
17
|
import SearchInput from '@kne/search-input';
|
|
18
18
|
import { FetchScrollLoader } from '@kne/scroll-loader';
|
|
19
19
|
import '@kne/scroll-loader/dist/index.css';
|
|
20
|
-
import TableView from '@kne/table-view';
|
|
20
|
+
import TableView, { isTreeDataType, normalizeTreeData, flattenAllTree } from '@kne/table-view';
|
|
21
|
+
export { mergeTreeChildren } from '@kne/table-view';
|
|
21
22
|
import '@kne/table-view/dist/index.css';
|
|
22
23
|
import { CentralContent } from '@kne/info-page';
|
|
23
24
|
import '@kne/info-page/dist/index.css';
|
|
@@ -168,7 +169,7 @@ const TagOverflowInner = ({
|
|
|
168
169
|
}, "+", hiddenCount));
|
|
169
170
|
};
|
|
170
171
|
|
|
171
|
-
const _excluded$
|
|
172
|
+
const _excluded$3 = ["children"];
|
|
172
173
|
const MOBILE_SHEET_MAX_HEIGHT = '80%';
|
|
173
174
|
const MOBILE_SHEET_MIN_HEIGHT = '30%';
|
|
174
175
|
const MOBILE_MASK_Z_INDEX = 1000;
|
|
@@ -243,7 +244,7 @@ const ModalContent = _ref => {
|
|
|
243
244
|
let {
|
|
244
245
|
children: renderContent
|
|
245
246
|
} = _ref,
|
|
246
|
-
others = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
247
|
+
others = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
247
248
|
const {
|
|
248
249
|
open,
|
|
249
250
|
value: propsValue
|
|
@@ -464,12 +465,14 @@ const SelectInput = createWithIntlProvider({
|
|
|
464
465
|
onComplete();
|
|
465
466
|
onOpenChange(false);
|
|
466
467
|
}
|
|
467
|
-
}, children(contextProps)));
|
|
468
|
+
}, open ? children(contextProps) : null));
|
|
468
469
|
}
|
|
469
470
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
470
471
|
className: overlayClassName,
|
|
471
472
|
width: 1000,
|
|
472
473
|
open: open,
|
|
474
|
+
destroyOnClose: true,
|
|
475
|
+
destroyOnHidden: true,
|
|
473
476
|
title: placeholder,
|
|
474
477
|
onCancel: () => {
|
|
475
478
|
onOpenChange(false);
|
|
@@ -478,7 +481,7 @@ const SelectInput = createWithIntlProvider({
|
|
|
478
481
|
onComplete();
|
|
479
482
|
onOpenChange(false);
|
|
480
483
|
}
|
|
481
|
-
}, children(contextProps));
|
|
484
|
+
}, open ? children(contextProps) : null);
|
|
482
485
|
}
|
|
483
486
|
}, p);
|
|
484
487
|
props.selectedAllValue = {
|
|
@@ -675,6 +678,13 @@ const SelectInput = createWithIntlProvider({
|
|
|
675
678
|
const handleOpenChange = useCallback(nextOpen => {
|
|
676
679
|
setOpen(nextOpen);
|
|
677
680
|
}, [setOpen]);
|
|
681
|
+
|
|
682
|
+
// 关闭时清空搜索,保证下次展开重新请求且从初始搜索态开始
|
|
683
|
+
useEffect(() => {
|
|
684
|
+
if (!open) {
|
|
685
|
+
setSearchProps({});
|
|
686
|
+
}
|
|
687
|
+
}, [open]);
|
|
678
688
|
const contextProps = {
|
|
679
689
|
props,
|
|
680
690
|
value: value,
|
|
@@ -756,9 +766,14 @@ const SelectInput = createWithIntlProvider({
|
|
|
756
766
|
useImperativeHandle(ref, () => {
|
|
757
767
|
return contextProps;
|
|
758
768
|
});
|
|
769
|
+
|
|
770
|
+
// 嵌入模式内容常显,视为已展开,保证会发起请求
|
|
759
771
|
if (props.renderContent && typeof props.renderContent === 'function') {
|
|
760
|
-
return props.renderContent(children(contextProps
|
|
772
|
+
return props.renderContent(children(Object.assign({}, contextProps, {
|
|
773
|
+
open: true
|
|
774
|
+
})));
|
|
761
775
|
}
|
|
776
|
+
const isOverlayOpen = !disabled && open;
|
|
762
777
|
|
|
763
778
|
// 移动端半屏:与 Modal 一致,临时选中 + 取消/确认
|
|
764
779
|
if (useMobileSheet) {
|
|
@@ -797,7 +812,7 @@ const SelectInput = createWithIntlProvider({
|
|
|
797
812
|
onComplete();
|
|
798
813
|
setOpen(false);
|
|
799
814
|
}
|
|
800
|
-
}, children(sheetContextProps)));
|
|
815
|
+
}, sheetOpen ? children(sheetContextProps) : null));
|
|
801
816
|
}));
|
|
802
817
|
}
|
|
803
818
|
const overlayContent = /*#__PURE__*/React.createElement("div", {
|
|
@@ -808,11 +823,11 @@ const SelectInput = createWithIntlProvider({
|
|
|
808
823
|
onClick: e => {
|
|
809
824
|
e.stopPropagation();
|
|
810
825
|
}
|
|
811
|
-
}, children(contextProps));
|
|
826
|
+
}, isOverlayOpen ? children(contextProps) : null);
|
|
812
827
|
return /*#__PURE__*/React.createElement(Provider, {
|
|
813
828
|
value: contextProps
|
|
814
829
|
}, isPopup ? /*#__PURE__*/React.createElement(Dropdown, {
|
|
815
|
-
open:
|
|
830
|
+
open: isOverlayOpen,
|
|
816
831
|
onOpenChange: handleOpenChange,
|
|
817
832
|
placement: placement,
|
|
818
833
|
arrow: false,
|
|
@@ -823,6 +838,8 @@ const SelectInput = createWithIntlProvider({
|
|
|
823
838
|
autoAdjustOverflow: autoAdjustOverflow,
|
|
824
839
|
transitionName: transitionName,
|
|
825
840
|
trigger: "click",
|
|
841
|
+
destroyPopupOnHide: true,
|
|
842
|
+
destroyOnHidden: true,
|
|
826
843
|
popupRender: () => overlayContent,
|
|
827
844
|
dropdownRender: () => overlayContent
|
|
828
845
|
}, /*#__PURE__*/React.createElement("span", null, inputInnerRender())) : /*#__PURE__*/React.createElement(React.Fragment, null, inputInnerRender({
|
|
@@ -928,12 +945,12 @@ const SelectedTagList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
928
945
|
|
|
929
946
|
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"};
|
|
930
947
|
|
|
931
|
-
const _excluded$
|
|
948
|
+
const _excluded$2 = ["children"];
|
|
932
949
|
const SelectList = forwardRef((_ref, ref) => {
|
|
933
950
|
let {
|
|
934
951
|
children
|
|
935
952
|
} = _ref,
|
|
936
|
-
p = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
953
|
+
p = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
937
954
|
const fetchListRef = useRef(null);
|
|
938
955
|
const props = Object.assign({}, {
|
|
939
956
|
renderItemContent: ({
|
|
@@ -1035,7 +1052,8 @@ const SelectList = forwardRef((_ref, ref) => {
|
|
|
1035
1052
|
searchProps,
|
|
1036
1053
|
setSearchProps,
|
|
1037
1054
|
onOpenChange,
|
|
1038
|
-
isMobile
|
|
1055
|
+
isMobile,
|
|
1056
|
+
open
|
|
1039
1057
|
} = targetProps;
|
|
1040
1058
|
const {
|
|
1041
1059
|
footer,
|
|
@@ -1072,7 +1090,7 @@ const SelectList = forwardRef((_ref, ref) => {
|
|
|
1072
1090
|
'is-popup': isPopup
|
|
1073
1091
|
})
|
|
1074
1092
|
}, /*#__PURE__*/React.createElement(SelectedAll, null)),
|
|
1075
|
-
fetchList: /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
|
|
1093
|
+
fetchList: open ? /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
|
|
1076
1094
|
className: classnames(style$3['list'], 'select-list-scroll-list', {
|
|
1077
1095
|
'is-popup': isPopup
|
|
1078
1096
|
}),
|
|
@@ -1108,7 +1126,7 @@ const SelectList = forwardRef((_ref, ref) => {
|
|
|
1108
1126
|
return renderList(Object.assign({}, fetchProps, targetProps, {
|
|
1109
1127
|
isSelectedAll
|
|
1110
1128
|
}));
|
|
1111
|
-
}),
|
|
1129
|
+
}) : null,
|
|
1112
1130
|
selectedTag: showSelectedTag && /*#__PURE__*/React.createElement("div", {
|
|
1113
1131
|
className: classnames(style$3['selected-tag'], 'select-list-selected-tag', {
|
|
1114
1132
|
'is-popup': isPopup
|
|
@@ -1141,7 +1159,74 @@ const SelectList = forwardRef((_ref, ref) => {
|
|
|
1141
1159
|
|
|
1142
1160
|
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"};
|
|
1143
1161
|
|
|
1144
|
-
const
|
|
1162
|
+
const isEmptyParentKey = value => value == null || value === '';
|
|
1163
|
+
const flattenSelectList = (list, {
|
|
1164
|
+
dataType,
|
|
1165
|
+
rowKey,
|
|
1166
|
+
parentKey,
|
|
1167
|
+
childrenKey
|
|
1168
|
+
}) => {
|
|
1169
|
+
if (!list || !isTreeDataType(dataType)) {
|
|
1170
|
+
return list || [];
|
|
1171
|
+
}
|
|
1172
|
+
const tree = normalizeTreeData(list, {
|
|
1173
|
+
dataType,
|
|
1174
|
+
rowKey,
|
|
1175
|
+
parentKey,
|
|
1176
|
+
childrenKey
|
|
1177
|
+
});
|
|
1178
|
+
return flattenAllTree(tree, {
|
|
1179
|
+
rowKey,
|
|
1180
|
+
childrenKey
|
|
1181
|
+
}).map(row => row.item);
|
|
1182
|
+
};
|
|
1183
|
+
const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps, {
|
|
1184
|
+
dataType,
|
|
1185
|
+
valueKey,
|
|
1186
|
+
parentKey,
|
|
1187
|
+
childrenKey
|
|
1188
|
+
}) => {
|
|
1189
|
+
if (typeof getSearchCallback !== 'function') {
|
|
1190
|
+
return options;
|
|
1191
|
+
}
|
|
1192
|
+
if (dataType === 'tree') {
|
|
1193
|
+
const filterNodes = nodes => (nodes || []).reduce((acc, item) => {
|
|
1194
|
+
const rawChildren = Array.isArray(item[childrenKey]) ? item[childrenKey] : [];
|
|
1195
|
+
const filteredChildren = filterNodes(rawChildren);
|
|
1196
|
+
const selfMatch = getSearchCallback(searchProps, item, targetProps);
|
|
1197
|
+
if (selfMatch) {
|
|
1198
|
+
acc.push(item);
|
|
1199
|
+
} else if (filteredChildren.length > 0) {
|
|
1200
|
+
acc.push(Object.assign({}, item, {
|
|
1201
|
+
[childrenKey]: filteredChildren
|
|
1202
|
+
}));
|
|
1203
|
+
}
|
|
1204
|
+
return acc;
|
|
1205
|
+
}, []);
|
|
1206
|
+
return filterNodes(options);
|
|
1207
|
+
}
|
|
1208
|
+
if (dataType === 'treeList') {
|
|
1209
|
+
const matched = options.filter(item => getSearchCallback(searchProps, item, targetProps));
|
|
1210
|
+
if (matched.length === 0) {
|
|
1211
|
+
return [];
|
|
1212
|
+
}
|
|
1213
|
+
const idSet = new Set(matched.map(item => item[valueKey]));
|
|
1214
|
+
const map = new Map(options.map(item => [item[valueKey], item]));
|
|
1215
|
+
matched.forEach(item => {
|
|
1216
|
+
let parentId = item[parentKey];
|
|
1217
|
+
while (!isEmptyParentKey(parentId) && !idSet.has(parentId)) {
|
|
1218
|
+
idSet.add(parentId);
|
|
1219
|
+
const parent = map.get(parentId);
|
|
1220
|
+
if (!parent) {
|
|
1221
|
+
break;
|
|
1222
|
+
}
|
|
1223
|
+
parentId = parent[parentKey];
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
return options.filter(item => idSet.has(item[valueKey]));
|
|
1227
|
+
}
|
|
1228
|
+
return options.filter(item => getSearchCallback(searchProps, item, targetProps));
|
|
1229
|
+
};
|
|
1145
1230
|
const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select')(forwardRef((p, ref) => {
|
|
1146
1231
|
const {
|
|
1147
1232
|
formatMessage
|
|
@@ -1150,6 +1235,10 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1150
1235
|
const fetchListRef = useRef();
|
|
1151
1236
|
const props = Object.assign({}, {
|
|
1152
1237
|
overlayWidth: '600px',
|
|
1238
|
+
dataType: 'list',
|
|
1239
|
+
parentKey: 'parentId',
|
|
1240
|
+
childrenKey: 'children',
|
|
1241
|
+
hasChildrenKey: 'hasChildren',
|
|
1153
1242
|
filterRender: contextProps => {
|
|
1154
1243
|
const {
|
|
1155
1244
|
props,
|
|
@@ -1206,7 +1295,8 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1206
1295
|
onRemove,
|
|
1207
1296
|
onOpenChange,
|
|
1208
1297
|
searchProps,
|
|
1209
|
-
isMobile
|
|
1298
|
+
isMobile,
|
|
1299
|
+
open
|
|
1210
1300
|
} = targetProps;
|
|
1211
1301
|
const {
|
|
1212
1302
|
footer,
|
|
@@ -1225,9 +1315,21 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1225
1315
|
allowSelectedAll,
|
|
1226
1316
|
labelKey,
|
|
1227
1317
|
valueKey,
|
|
1228
|
-
renderMobile
|
|
1318
|
+
renderMobile,
|
|
1319
|
+
dataType,
|
|
1320
|
+
parentKey,
|
|
1321
|
+
childrenKey,
|
|
1322
|
+
hasChildrenKey,
|
|
1323
|
+
treeTitleKey,
|
|
1324
|
+
onLoadChildren,
|
|
1325
|
+
expandedKeys,
|
|
1326
|
+
defaultExpandedKeys,
|
|
1327
|
+
onExpandedKeysChange,
|
|
1328
|
+
indentSize,
|
|
1329
|
+
checkRelation
|
|
1229
1330
|
} = props;
|
|
1230
1331
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
1332
|
+
const resolvedTreeTitleKey = treeTitleKey || labelKey;
|
|
1231
1333
|
const footerEl = footer && /*#__PURE__*/React.createElement("div", {
|
|
1232
1334
|
className: classnames(style$2['footer'], 'select-table-footer')
|
|
1233
1335
|
}, typeof footer === 'function' ? footer({
|
|
@@ -1239,7 +1341,7 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1239
1341
|
onOpenChange(false);
|
|
1240
1342
|
}
|
|
1241
1343
|
}) : footer);
|
|
1242
|
-
const renderScrollList =
|
|
1344
|
+
const renderScrollList = renderContent => open ? /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
|
|
1243
1345
|
className: classnames(style$2['list'], 'select-table-list-scroll-list', {
|
|
1244
1346
|
'is-popup': isPopup
|
|
1245
1347
|
}),
|
|
@@ -1258,14 +1360,13 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1258
1360
|
options,
|
|
1259
1361
|
searchProps
|
|
1260
1362
|
} = data;
|
|
1261
|
-
if (typeof getSearchCallback === 'function') {
|
|
1262
|
-
const newOptions = options.filter(item => getSearchCallback(searchProps, item, targetProps));
|
|
1263
|
-
return {
|
|
1264
|
-
pageData: newOptions
|
|
1265
|
-
};
|
|
1266
|
-
}
|
|
1267
1363
|
return {
|
|
1268
|
-
pageData: options
|
|
1364
|
+
pageData: filterTreeOptions(options, searchProps, getSearchCallback, targetProps, {
|
|
1365
|
+
dataType,
|
|
1366
|
+
valueKey,
|
|
1367
|
+
parentKey,
|
|
1368
|
+
childrenKey
|
|
1369
|
+
})
|
|
1269
1370
|
};
|
|
1270
1371
|
}
|
|
1271
1372
|
} : api)
|
|
@@ -1282,8 +1383,8 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1282
1383
|
className: classnames(style$2['empty'])
|
|
1283
1384
|
});
|
|
1284
1385
|
}
|
|
1285
|
-
return
|
|
1286
|
-
});
|
|
1386
|
+
return renderContent(list, contextProps);
|
|
1387
|
+
}) : null;
|
|
1287
1388
|
const tableSelection = {
|
|
1288
1389
|
allowSelectedAll,
|
|
1289
1390
|
isSelectedAll,
|
|
@@ -1292,27 +1393,20 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1292
1393
|
},
|
|
1293
1394
|
type: single ? 'radio' : 'checkbox',
|
|
1294
1395
|
selectedRowKeys: (value || []).map(item => item[valueKey]),
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
newValue.push(selectedItem);
|
|
1308
|
-
return newValue;
|
|
1309
|
-
}
|
|
1310
|
-
return value;
|
|
1311
|
-
} else {
|
|
1312
|
-
return value.filter(item => item[valueKey] !== selectedKey);
|
|
1313
|
-
}
|
|
1396
|
+
checkRelation,
|
|
1397
|
+
onChange: selectedRowKeys => {
|
|
1398
|
+
setValue(prev => {
|
|
1399
|
+
var _fetchListRef$current3;
|
|
1400
|
+
const prevMap = new Map((prev || []).map(item => [item[valueKey], item]));
|
|
1401
|
+
const listMap = new Map(flattenSelectList((_fetchListRef$current3 = fetchListRef.current) == null ? void 0 : _fetchListRef$current3.list, {
|
|
1402
|
+
dataType,
|
|
1403
|
+
rowKey: valueKey,
|
|
1404
|
+
parentKey,
|
|
1405
|
+
childrenKey
|
|
1406
|
+
}).map(item => [item[valueKey], item]));
|
|
1407
|
+
return (selectedRowKeys || []).map(key => prevMap.get(key) || listMap.get(key)).filter(Boolean);
|
|
1314
1408
|
});
|
|
1315
|
-
if (isPopup && single) {
|
|
1409
|
+
if (isPopup && single && selectedRowKeys && selectedRowKeys.length > 0) {
|
|
1316
1410
|
onOpenChange(false);
|
|
1317
1411
|
}
|
|
1318
1412
|
}
|
|
@@ -1391,21 +1485,6 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1391
1485
|
className: style$2['selected-tags-scroll']
|
|
1392
1486
|
}, selectedTags);
|
|
1393
1487
|
})(), footerEl);
|
|
1394
|
-
const tableMobileRender = _ref => {
|
|
1395
|
-
let {
|
|
1396
|
-
renderBody
|
|
1397
|
-
} = _ref,
|
|
1398
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
1399
|
-
return renderScrollList((list, contextProps) => {
|
|
1400
|
-
if (typeof renderMobile === 'function') {
|
|
1401
|
-
return renderMobile(_extends({}, rest, contextProps, {
|
|
1402
|
-
list,
|
|
1403
|
-
renderBody: (nextList = list, nextContext = contextProps) => renderBody(nextList, nextContext)
|
|
1404
|
-
}));
|
|
1405
|
-
}
|
|
1406
|
-
return renderBody(list, contextProps);
|
|
1407
|
-
});
|
|
1408
|
-
};
|
|
1409
1488
|
const tablePanel = /*#__PURE__*/React.createElement("div", {
|
|
1410
1489
|
className: classnames(style$2['table-panel'], {
|
|
1411
1490
|
[style$2['single-body']]: single
|
|
@@ -1414,14 +1493,41 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1414
1493
|
className: style$2['filter-wrap']
|
|
1415
1494
|
}, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React.createElement("div", {
|
|
1416
1495
|
className: classnames(style$2['table'], 'select-table')
|
|
1417
|
-
},
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1496
|
+
}, renderScrollList((list, contextProps) => {
|
|
1497
|
+
const tableViewProps = {
|
|
1498
|
+
dataSource: list,
|
|
1499
|
+
columns,
|
|
1500
|
+
rowKey: valueKey,
|
|
1501
|
+
rowSelection: tableSelection,
|
|
1502
|
+
context: contextProps,
|
|
1503
|
+
dataType,
|
|
1504
|
+
parentKey,
|
|
1505
|
+
childrenKey,
|
|
1506
|
+
hasChildrenKey,
|
|
1507
|
+
treeTitleKey: resolvedTreeTitleKey,
|
|
1508
|
+
renderMobile: renderMobile === false ? false : typeof renderMobile === 'function' ? mobileProps => renderMobile(_extends({}, mobileProps, contextProps, {
|
|
1509
|
+
list: mobileProps.displayDataSource || list,
|
|
1510
|
+
dataSource: list,
|
|
1511
|
+
renderBody: (nextList = mobileProps.displayDataSource || list, nextContext = contextProps) => mobileProps.renderBody(nextList, nextContext)
|
|
1512
|
+
})) : true
|
|
1513
|
+
};
|
|
1514
|
+
// 可选树形 props:仅在有值 / 用户显式传入时透传,避免 undefined 覆盖 TableView 默认值
|
|
1515
|
+
if (typeof onLoadChildren === 'function') {
|
|
1516
|
+
tableViewProps.onLoadChildren = onLoadChildren;
|
|
1517
|
+
}
|
|
1518
|
+
if (typeof onExpandedKeysChange === 'function') {
|
|
1519
|
+
tableViewProps.onExpandedKeysChange = onExpandedKeysChange;
|
|
1520
|
+
}
|
|
1521
|
+
if (indentSize != null) {
|
|
1522
|
+
tableViewProps.indentSize = indentSize;
|
|
1523
|
+
}
|
|
1524
|
+
if (Object.prototype.hasOwnProperty.call(p, 'expandedKeys')) {
|
|
1525
|
+
tableViewProps.expandedKeys = expandedKeys;
|
|
1526
|
+
}
|
|
1527
|
+
if (Object.prototype.hasOwnProperty.call(p, 'defaultExpandedKeys')) {
|
|
1528
|
+
tableViewProps.defaultExpandedKeys = defaultExpandedKeys;
|
|
1529
|
+
}
|
|
1530
|
+
return /*#__PURE__*/React.createElement(TableView, tableViewProps);
|
|
1425
1531
|
})), single && footerEl || !isMobile && /*#__PURE__*/React.createElement("div", {
|
|
1426
1532
|
className: classnames(style$2['footer'], 'select-table-footer')
|
|
1427
1533
|
}));
|
|
@@ -1604,7 +1710,8 @@ const SelectTree = forwardRef((_ref, ref) => {
|
|
|
1604
1710
|
props,
|
|
1605
1711
|
value,
|
|
1606
1712
|
onOpenChange,
|
|
1607
|
-
isMobile
|
|
1713
|
+
isMobile,
|
|
1714
|
+
open
|
|
1608
1715
|
} = targetProps;
|
|
1609
1716
|
const {
|
|
1610
1717
|
footer,
|
|
@@ -1624,7 +1731,7 @@ const SelectTree = forwardRef((_ref, ref) => {
|
|
|
1624
1731
|
'is-popup': isPopup
|
|
1625
1732
|
})
|
|
1626
1733
|
}, /*#__PURE__*/React.createElement(SelectedAll, null)),
|
|
1627
|
-
treeList: /*#__PURE__*/React.createElement(Fetch, _extends({}, Object.assign({}, options ? {
|
|
1734
|
+
treeList: open ? /*#__PURE__*/React.createElement(Fetch, _extends({}, Object.assign({}, options ? {
|
|
1628
1735
|
data: {
|
|
1629
1736
|
options
|
|
1630
1737
|
},
|
|
@@ -1657,7 +1764,7 @@ const SelectTree = forwardRef((_ref, ref) => {
|
|
|
1657
1764
|
autoHide: false
|
|
1658
1765
|
}, treeContent);
|
|
1659
1766
|
}
|
|
1660
|
-
})),
|
|
1767
|
+
})) : null,
|
|
1661
1768
|
selectedTag: showSelectedTag && /*#__PURE__*/React.createElement("div", {
|
|
1662
1769
|
className: classnames(style$1['selected-tag'], 'select-tree-selected-tag', {
|
|
1663
1770
|
'is-popup': isPopup
|
|
@@ -2038,7 +2145,7 @@ const CascaderInner = ({
|
|
|
2038
2145
|
treeUtils
|
|
2039
2146
|
};
|
|
2040
2147
|
useEffect(() => {
|
|
2041
|
-
if (!openLoadData || !onLoadMore) {
|
|
2148
|
+
if (!open || !openLoadData || !onLoadMore) {
|
|
2042
2149
|
return;
|
|
2043
2150
|
}
|
|
2044
2151
|
const lastNode = mapping.get(last(selectedIds));
|
|
@@ -2058,7 +2165,7 @@ const CascaderInner = ({
|
|
|
2058
2165
|
}).catch(() => {
|
|
2059
2166
|
setLoading(false);
|
|
2060
2167
|
});
|
|
2061
|
-
}, [selectedIds, mapping, openLoadData, onLoadMore, parentIdKey]);
|
|
2168
|
+
}, [open, selectedIds, mapping, openLoadData, onLoadMore, parentIdKey]);
|
|
2062
2169
|
|
|
2063
2170
|
// 检查是否为非叶子节点
|
|
2064
2171
|
const isNotLastNode = useCallback(id => {
|
|
@@ -2488,7 +2595,7 @@ const SelectCascader = _ref => {
|
|
|
2488
2595
|
[labelKey]: String(item)
|
|
2489
2596
|
};
|
|
2490
2597
|
}).filter(Boolean);
|
|
2491
|
-
return /*#__PURE__*/React.createElement(CascaderInner, {
|
|
2598
|
+
return contextProps.open ? /*#__PURE__*/React.createElement(CascaderInner, {
|
|
2492
2599
|
options: options,
|
|
2493
2600
|
value: currentDisplayValue,
|
|
2494
2601
|
setValue: contextSetValue,
|
|
@@ -2507,7 +2614,7 @@ const SelectCascader = _ref => {
|
|
|
2507
2614
|
onOpenChange: contextProps.onOpenChange,
|
|
2508
2615
|
open: contextProps.open,
|
|
2509
2616
|
isMobile: contextProps.isMobile
|
|
2510
|
-
});
|
|
2617
|
+
}) : null;
|
|
2511
2618
|
});
|
|
2512
2619
|
};
|
|
2513
2620
|
|