@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.js
CHANGED
|
@@ -184,7 +184,7 @@ const TagOverflowInner = ({
|
|
|
184
184
|
}, "+", hiddenCount));
|
|
185
185
|
};
|
|
186
186
|
|
|
187
|
-
const _excluded$
|
|
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;
|
|
@@ -256,7 +256,7 @@ const pxToNumber = value => {
|
|
|
256
256
|
// 与 Modal 模式一致:面板内用临时 value,确认后才写回
|
|
257
257
|
const ModalContent = _ref2 => {
|
|
258
258
|
let renderContent = _ref2.children,
|
|
259
|
-
others = _objectWithoutPropertiesLoose(_ref2, _excluded$
|
|
259
|
+
others = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
|
|
260
260
|
const open = others.open,
|
|
261
261
|
propsValue = others.value;
|
|
262
262
|
const _useState = React.useState(propsValue),
|
|
@@ -472,12 +472,14 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
472
472
|
onComplete();
|
|
473
473
|
onOpenChange(false);
|
|
474
474
|
}
|
|
475
|
-
}, children(contextProps)));
|
|
475
|
+
}, open ? children(contextProps) : null));
|
|
476
476
|
}
|
|
477
477
|
return /*#__PURE__*/React__default["default"].createElement(antd.Modal, {
|
|
478
478
|
className: overlayClassName,
|
|
479
479
|
width: 1000,
|
|
480
480
|
open: open,
|
|
481
|
+
destroyOnClose: true,
|
|
482
|
+
destroyOnHidden: true,
|
|
481
483
|
title: placeholder,
|
|
482
484
|
onCancel: () => {
|
|
483
485
|
onOpenChange(false);
|
|
@@ -486,7 +488,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
486
488
|
onComplete();
|
|
487
489
|
onOpenChange(false);
|
|
488
490
|
}
|
|
489
|
-
}, children(contextProps));
|
|
491
|
+
}, open ? children(contextProps) : null);
|
|
490
492
|
}
|
|
491
493
|
}, p);
|
|
492
494
|
props.selectedAllValue = {
|
|
@@ -693,6 +695,13 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
693
695
|
const handleOpenChange = React.useCallback(nextOpen => {
|
|
694
696
|
setOpen(nextOpen);
|
|
695
697
|
}, [setOpen]);
|
|
698
|
+
|
|
699
|
+
// 关闭时清空搜索,保证下次展开重新请求且从初始搜索态开始
|
|
700
|
+
React.useEffect(() => {
|
|
701
|
+
if (!open) {
|
|
702
|
+
setSearchProps({});
|
|
703
|
+
}
|
|
704
|
+
}, [open]);
|
|
696
705
|
const contextProps = {
|
|
697
706
|
props,
|
|
698
707
|
value: value,
|
|
@@ -777,9 +786,14 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
777
786
|
React.useImperativeHandle(ref, () => {
|
|
778
787
|
return contextProps;
|
|
779
788
|
});
|
|
789
|
+
|
|
790
|
+
// 嵌入模式内容常显,视为已展开,保证会发起请求
|
|
780
791
|
if (props.renderContent && typeof props.renderContent === 'function') {
|
|
781
|
-
return props.renderContent(children(contextProps
|
|
792
|
+
return props.renderContent(children(Object.assign({}, contextProps, {
|
|
793
|
+
open: true
|
|
794
|
+
})));
|
|
782
795
|
}
|
|
796
|
+
const isOverlayOpen = !disabled && open;
|
|
783
797
|
|
|
784
798
|
// 移动端半屏:与 Modal 一致,临时选中 + 取消/确认
|
|
785
799
|
if (useMobileSheet) {
|
|
@@ -816,7 +830,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
816
830
|
onComplete();
|
|
817
831
|
setOpen(false);
|
|
818
832
|
}
|
|
819
|
-
}, children(sheetContextProps)));
|
|
833
|
+
}, sheetOpen ? children(sheetContextProps) : null));
|
|
820
834
|
}));
|
|
821
835
|
}
|
|
822
836
|
const overlayContent = /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -827,11 +841,11 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
827
841
|
onClick: e => {
|
|
828
842
|
e.stopPropagation();
|
|
829
843
|
}
|
|
830
|
-
}, children(contextProps));
|
|
844
|
+
}, isOverlayOpen ? children(contextProps) : null);
|
|
831
845
|
return /*#__PURE__*/React__default["default"].createElement(Provider, {
|
|
832
846
|
value: contextProps
|
|
833
847
|
}, isPopup ? /*#__PURE__*/React__default["default"].createElement(antd.Dropdown, {
|
|
834
|
-
open:
|
|
848
|
+
open: isOverlayOpen,
|
|
835
849
|
onOpenChange: handleOpenChange,
|
|
836
850
|
placement: placement,
|
|
837
851
|
arrow: false,
|
|
@@ -842,6 +856,8 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
842
856
|
autoAdjustOverflow: autoAdjustOverflow,
|
|
843
857
|
transitionName: transitionName,
|
|
844
858
|
trigger: "click",
|
|
859
|
+
destroyPopupOnHide: true,
|
|
860
|
+
destroyOnHidden: true,
|
|
845
861
|
popupRender: () => overlayContent,
|
|
846
862
|
dropdownRender: () => overlayContent
|
|
847
863
|
}, /*#__PURE__*/React__default["default"].createElement("span", null, inputInnerRender())) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, inputInnerRender({
|
|
@@ -944,10 +960,10 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
944
960
|
|
|
945
961
|
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"};
|
|
946
962
|
|
|
947
|
-
const _excluded$
|
|
963
|
+
const _excluded$2 = ["children"];
|
|
948
964
|
const SelectList = React.forwardRef((_ref, ref) => {
|
|
949
965
|
let children = _ref.children,
|
|
950
|
-
p = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
966
|
+
p = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
951
967
|
const fetchListRef = React.useRef(null);
|
|
952
968
|
const props = Object.assign({}, {
|
|
953
969
|
renderItemContent: _ref2 => {
|
|
@@ -1037,7 +1053,8 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1037
1053
|
searchProps = targetProps.searchProps,
|
|
1038
1054
|
setSearchProps = targetProps.setSearchProps,
|
|
1039
1055
|
onOpenChange = targetProps.onOpenChange,
|
|
1040
|
-
isMobile = targetProps.isMobile
|
|
1056
|
+
isMobile = targetProps.isMobile,
|
|
1057
|
+
open = targetProps.open;
|
|
1041
1058
|
const footer = props.footer,
|
|
1042
1059
|
isPopup = props.isPopup,
|
|
1043
1060
|
getSearchProps = props.getSearchProps,
|
|
@@ -1071,7 +1088,7 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1071
1088
|
'is-popup': isPopup
|
|
1072
1089
|
})
|
|
1073
1090
|
}, /*#__PURE__*/React__default["default"].createElement(SelectedAll, null)),
|
|
1074
|
-
fetchList: /*#__PURE__*/React__default["default"].createElement(scrollLoader.FetchScrollLoader, _extends({}, props, {
|
|
1091
|
+
fetchList: open ? /*#__PURE__*/React__default["default"].createElement(scrollLoader.FetchScrollLoader, _extends({}, props, {
|
|
1075
1092
|
className: classnames__default["default"](style$3['list'], 'select-list-scroll-list', {
|
|
1076
1093
|
'is-popup': isPopup
|
|
1077
1094
|
}),
|
|
@@ -1104,7 +1121,7 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1104
1121
|
return renderList(Object.assign({}, fetchProps, targetProps, {
|
|
1105
1122
|
isSelectedAll
|
|
1106
1123
|
}));
|
|
1107
|
-
}),
|
|
1124
|
+
}) : null,
|
|
1108
1125
|
selectedTag: showSelectedTag && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1109
1126
|
className: classnames__default["default"](style$3['selected-tag'], 'select-list-selected-tag', {
|
|
1110
1127
|
'is-popup': isPopup
|
|
@@ -1137,7 +1154,72 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1137
1154
|
|
|
1138
1155
|
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"};
|
|
1139
1156
|
|
|
1140
|
-
const
|
|
1157
|
+
const isEmptyParentKey = value => value == null || value === '';
|
|
1158
|
+
const flattenSelectList = (list, _ref) => {
|
|
1159
|
+
let dataType = _ref.dataType,
|
|
1160
|
+
rowKey = _ref.rowKey,
|
|
1161
|
+
parentKey = _ref.parentKey,
|
|
1162
|
+
childrenKey = _ref.childrenKey;
|
|
1163
|
+
if (!list || !TableView.isTreeDataType(dataType)) {
|
|
1164
|
+
return list || [];
|
|
1165
|
+
}
|
|
1166
|
+
const tree = TableView.normalizeTreeData(list, {
|
|
1167
|
+
dataType,
|
|
1168
|
+
rowKey,
|
|
1169
|
+
parentKey,
|
|
1170
|
+
childrenKey
|
|
1171
|
+
});
|
|
1172
|
+
return TableView.flattenAllTree(tree, {
|
|
1173
|
+
rowKey,
|
|
1174
|
+
childrenKey
|
|
1175
|
+
}).map(row => row.item);
|
|
1176
|
+
};
|
|
1177
|
+
const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps, _ref2) => {
|
|
1178
|
+
let dataType = _ref2.dataType,
|
|
1179
|
+
valueKey = _ref2.valueKey,
|
|
1180
|
+
parentKey = _ref2.parentKey,
|
|
1181
|
+
childrenKey = _ref2.childrenKey;
|
|
1182
|
+
if (typeof getSearchCallback !== 'function') {
|
|
1183
|
+
return options;
|
|
1184
|
+
}
|
|
1185
|
+
if (dataType === 'tree') {
|
|
1186
|
+
const filterNodes = nodes => (nodes || []).reduce((acc, item) => {
|
|
1187
|
+
const rawChildren = Array.isArray(item[childrenKey]) ? item[childrenKey] : [];
|
|
1188
|
+
const filteredChildren = filterNodes(rawChildren);
|
|
1189
|
+
const selfMatch = getSearchCallback(searchProps, item, targetProps);
|
|
1190
|
+
if (selfMatch) {
|
|
1191
|
+
acc.push(item);
|
|
1192
|
+
} else if (filteredChildren.length > 0) {
|
|
1193
|
+
acc.push(Object.assign({}, item, {
|
|
1194
|
+
[childrenKey]: filteredChildren
|
|
1195
|
+
}));
|
|
1196
|
+
}
|
|
1197
|
+
return acc;
|
|
1198
|
+
}, []);
|
|
1199
|
+
return filterNodes(options);
|
|
1200
|
+
}
|
|
1201
|
+
if (dataType === 'treeList') {
|
|
1202
|
+
const matched = options.filter(item => getSearchCallback(searchProps, item, targetProps));
|
|
1203
|
+
if (matched.length === 0) {
|
|
1204
|
+
return [];
|
|
1205
|
+
}
|
|
1206
|
+
const idSet = new Set(matched.map(item => item[valueKey]));
|
|
1207
|
+
const map = new Map(options.map(item => [item[valueKey], item]));
|
|
1208
|
+
matched.forEach(item => {
|
|
1209
|
+
let parentId = item[parentKey];
|
|
1210
|
+
while (!isEmptyParentKey(parentId) && !idSet.has(parentId)) {
|
|
1211
|
+
idSet.add(parentId);
|
|
1212
|
+
const parent = map.get(parentId);
|
|
1213
|
+
if (!parent) {
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
parentId = parent[parentKey];
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
return options.filter(item => idSet.has(item[valueKey]));
|
|
1220
|
+
}
|
|
1221
|
+
return options.filter(item => getSearchCallback(searchProps, item, targetProps));
|
|
1222
|
+
};
|
|
1141
1223
|
const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(React.forwardRef((p, ref) => {
|
|
1142
1224
|
const _useIntl = reactIntl.useIntl(),
|
|
1143
1225
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -1147,6 +1229,10 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1147
1229
|
const fetchListRef = React.useRef();
|
|
1148
1230
|
const props = Object.assign({}, {
|
|
1149
1231
|
overlayWidth: '600px',
|
|
1232
|
+
dataType: 'list',
|
|
1233
|
+
parentKey: 'parentId',
|
|
1234
|
+
childrenKey: 'children',
|
|
1235
|
+
hasChildrenKey: 'hasChildren',
|
|
1150
1236
|
filterRender: contextProps => {
|
|
1151
1237
|
const props = contextProps.props,
|
|
1152
1238
|
searchProps = contextProps.searchProps,
|
|
@@ -1194,7 +1280,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1194
1280
|
onRemove = targetProps.onRemove,
|
|
1195
1281
|
onOpenChange = targetProps.onOpenChange,
|
|
1196
1282
|
searchProps = targetProps.searchProps,
|
|
1197
|
-
isMobile = targetProps.isMobile
|
|
1283
|
+
isMobile = targetProps.isMobile,
|
|
1284
|
+
open = targetProps.open;
|
|
1198
1285
|
const footer = props.footer,
|
|
1199
1286
|
filterRender = props.filterRender,
|
|
1200
1287
|
columns = props.columns,
|
|
@@ -1211,8 +1298,20 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1211
1298
|
allowSelectedAll = props.allowSelectedAll,
|
|
1212
1299
|
labelKey = props.labelKey,
|
|
1213
1300
|
valueKey = props.valueKey,
|
|
1214
|
-
renderMobile = props.renderMobile
|
|
1301
|
+
renderMobile = props.renderMobile,
|
|
1302
|
+
dataType = props.dataType,
|
|
1303
|
+
parentKey = props.parentKey,
|
|
1304
|
+
childrenKey = props.childrenKey,
|
|
1305
|
+
hasChildrenKey = props.hasChildrenKey,
|
|
1306
|
+
treeTitleKey = props.treeTitleKey,
|
|
1307
|
+
onLoadChildren = props.onLoadChildren,
|
|
1308
|
+
expandedKeys = props.expandedKeys,
|
|
1309
|
+
defaultExpandedKeys = props.defaultExpandedKeys,
|
|
1310
|
+
onExpandedKeysChange = props.onExpandedKeysChange,
|
|
1311
|
+
indentSize = props.indentSize,
|
|
1312
|
+
checkRelation = props.checkRelation;
|
|
1215
1313
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
1314
|
+
const resolvedTreeTitleKey = treeTitleKey || labelKey;
|
|
1216
1315
|
const footerEl = footer && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1217
1316
|
className: classnames__default["default"](style$2['footer'], 'select-table-footer')
|
|
1218
1317
|
}, typeof footer === 'function' ? footer({
|
|
@@ -1224,7 +1323,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1224
1323
|
onOpenChange(false);
|
|
1225
1324
|
}
|
|
1226
1325
|
}) : footer);
|
|
1227
|
-
const renderScrollList =
|
|
1326
|
+
const renderScrollList = renderContent => open ? /*#__PURE__*/React__default["default"].createElement(scrollLoader.FetchScrollLoader, _extends({}, props, {
|
|
1228
1327
|
className: classnames__default["default"](style$2['list'], 'select-table-list-scroll-list', {
|
|
1229
1328
|
'is-popup': isPopup
|
|
1230
1329
|
}),
|
|
@@ -1236,18 +1335,17 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1236
1335
|
options,
|
|
1237
1336
|
searchProps
|
|
1238
1337
|
},
|
|
1239
|
-
loader:
|
|
1240
|
-
let data =
|
|
1338
|
+
loader: _ref3 => {
|
|
1339
|
+
let data = _ref3.data;
|
|
1241
1340
|
const options = data.options,
|
|
1242
1341
|
searchProps = data.searchProps;
|
|
1243
|
-
if (typeof getSearchCallback === 'function') {
|
|
1244
|
-
const newOptions = options.filter(item => getSearchCallback(searchProps, item, targetProps));
|
|
1245
|
-
return {
|
|
1246
|
-
pageData: newOptions
|
|
1247
|
-
};
|
|
1248
|
-
}
|
|
1249
1342
|
return {
|
|
1250
|
-
pageData: options
|
|
1343
|
+
pageData: filterTreeOptions(options, searchProps, getSearchCallback, targetProps, {
|
|
1344
|
+
dataType,
|
|
1345
|
+
valueKey,
|
|
1346
|
+
parentKey,
|
|
1347
|
+
childrenKey
|
|
1348
|
+
})
|
|
1251
1349
|
};
|
|
1252
1350
|
}
|
|
1253
1351
|
} : api)
|
|
@@ -1262,8 +1360,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1262
1360
|
className: classnames__default["default"](style$2['empty'])
|
|
1263
1361
|
});
|
|
1264
1362
|
}
|
|
1265
|
-
return
|
|
1266
|
-
});
|
|
1363
|
+
return renderContent(list, contextProps);
|
|
1364
|
+
}) : null;
|
|
1267
1365
|
const tableSelection = {
|
|
1268
1366
|
allowSelectedAll,
|
|
1269
1367
|
isSelectedAll,
|
|
@@ -1272,26 +1370,20 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1272
1370
|
},
|
|
1273
1371
|
type: single ? 'radio' : 'checkbox',
|
|
1274
1372
|
selectedRowKeys: (value || []).map(item => item[valueKey]),
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
setValue(
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
return newValue;
|
|
1288
|
-
}
|
|
1289
|
-
return value;
|
|
1290
|
-
} else {
|
|
1291
|
-
return value.filter(item => item[valueKey] !== selectedKey);
|
|
1292
|
-
}
|
|
1373
|
+
checkRelation,
|
|
1374
|
+
onChange: selectedRowKeys => {
|
|
1375
|
+
setValue(prev => {
|
|
1376
|
+
var _fetchListRef$current3;
|
|
1377
|
+
const prevMap = new Map((prev || []).map(item => [item[valueKey], item]));
|
|
1378
|
+
const listMap = new Map(flattenSelectList((_fetchListRef$current3 = fetchListRef.current) == null ? void 0 : _fetchListRef$current3.list, {
|
|
1379
|
+
dataType,
|
|
1380
|
+
rowKey: valueKey,
|
|
1381
|
+
parentKey,
|
|
1382
|
+
childrenKey
|
|
1383
|
+
}).map(item => [item[valueKey], item]));
|
|
1384
|
+
return (selectedRowKeys || []).map(key => prevMap.get(key) || listMap.get(key)).filter(Boolean);
|
|
1293
1385
|
});
|
|
1294
|
-
if (isPopup && single) {
|
|
1386
|
+
if (isPopup && single && selectedRowKeys && selectedRowKeys.length > 0) {
|
|
1295
1387
|
onOpenChange(false);
|
|
1296
1388
|
}
|
|
1297
1389
|
}
|
|
@@ -1370,27 +1462,6 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1370
1462
|
className: style$2['selected-tags-scroll']
|
|
1371
1463
|
}, selectedTags);
|
|
1372
1464
|
})(), footerEl);
|
|
1373
|
-
const tableMobileRender = _ref3 => {
|
|
1374
|
-
let renderBody = _ref3.renderBody,
|
|
1375
|
-
rest = _objectWithoutPropertiesLoose(_ref3, _excluded$2);
|
|
1376
|
-
return renderScrollList((list, contextProps) => {
|
|
1377
|
-
if (typeof renderMobile === 'function') {
|
|
1378
|
-
return renderMobile(_extends({}, rest, contextProps, {
|
|
1379
|
-
list,
|
|
1380
|
-
renderBody: function (nextList, nextContext) {
|
|
1381
|
-
if (nextList === void 0) {
|
|
1382
|
-
nextList = list;
|
|
1383
|
-
}
|
|
1384
|
-
if (nextContext === void 0) {
|
|
1385
|
-
nextContext = contextProps;
|
|
1386
|
-
}
|
|
1387
|
-
return renderBody(nextList, nextContext);
|
|
1388
|
-
}
|
|
1389
|
-
}));
|
|
1390
|
-
}
|
|
1391
|
-
return renderBody(list, contextProps);
|
|
1392
|
-
});
|
|
1393
|
-
};
|
|
1394
1465
|
const tablePanel = /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1395
1466
|
className: classnames__default["default"](style$2['table-panel'], {
|
|
1396
1467
|
[style$2['single-body']]: single
|
|
@@ -1399,15 +1470,49 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1399
1470
|
className: style$2['filter-wrap']
|
|
1400
1471
|
}, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1401
1472
|
className: classnames__default["default"](style$2['table'], 'select-table')
|
|
1402
|
-
},
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1473
|
+
}, renderScrollList((list, contextProps) => {
|
|
1474
|
+
const tableViewProps = {
|
|
1475
|
+
dataSource: list,
|
|
1476
|
+
columns,
|
|
1477
|
+
rowKey: valueKey,
|
|
1478
|
+
rowSelection: tableSelection,
|
|
1479
|
+
context: contextProps,
|
|
1480
|
+
dataType,
|
|
1481
|
+
parentKey,
|
|
1482
|
+
childrenKey,
|
|
1483
|
+
hasChildrenKey,
|
|
1484
|
+
treeTitleKey: resolvedTreeTitleKey,
|
|
1485
|
+
renderMobile: renderMobile === false ? false : typeof renderMobile === 'function' ? mobileProps => renderMobile(_extends({}, mobileProps, contextProps, {
|
|
1486
|
+
list: mobileProps.displayDataSource || list,
|
|
1487
|
+
dataSource: list,
|
|
1488
|
+
renderBody: function (nextList, nextContext) {
|
|
1489
|
+
if (nextList === void 0) {
|
|
1490
|
+
nextList = mobileProps.displayDataSource || list;
|
|
1491
|
+
}
|
|
1492
|
+
if (nextContext === void 0) {
|
|
1493
|
+
nextContext = contextProps;
|
|
1494
|
+
}
|
|
1495
|
+
return mobileProps.renderBody(nextList, nextContext);
|
|
1496
|
+
}
|
|
1497
|
+
})) : true
|
|
1498
|
+
};
|
|
1499
|
+
// 可选树形 props:仅在有值 / 用户显式传入时透传,避免 undefined 覆盖 TableView 默认值
|
|
1500
|
+
if (typeof onLoadChildren === 'function') {
|
|
1501
|
+
tableViewProps.onLoadChildren = onLoadChildren;
|
|
1410
1502
|
}
|
|
1503
|
+
if (typeof onExpandedKeysChange === 'function') {
|
|
1504
|
+
tableViewProps.onExpandedKeysChange = onExpandedKeysChange;
|
|
1505
|
+
}
|
|
1506
|
+
if (indentSize != null) {
|
|
1507
|
+
tableViewProps.indentSize = indentSize;
|
|
1508
|
+
}
|
|
1509
|
+
if (Object.prototype.hasOwnProperty.call(p, 'expandedKeys')) {
|
|
1510
|
+
tableViewProps.expandedKeys = expandedKeys;
|
|
1511
|
+
}
|
|
1512
|
+
if (Object.prototype.hasOwnProperty.call(p, 'defaultExpandedKeys')) {
|
|
1513
|
+
tableViewProps.defaultExpandedKeys = defaultExpandedKeys;
|
|
1514
|
+
}
|
|
1515
|
+
return /*#__PURE__*/React__default["default"].createElement(TableView__default["default"], tableViewProps);
|
|
1411
1516
|
})), single && footerEl || !isMobile && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1412
1517
|
className: classnames__default["default"](style$2['footer'], 'select-table-footer')
|
|
1413
1518
|
}));
|
|
@@ -1578,7 +1683,8 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1578
1683
|
const props = targetProps.props,
|
|
1579
1684
|
value = targetProps.value,
|
|
1580
1685
|
onOpenChange = targetProps.onOpenChange,
|
|
1581
|
-
isMobile = targetProps.isMobile
|
|
1686
|
+
isMobile = targetProps.isMobile,
|
|
1687
|
+
open = targetProps.open;
|
|
1582
1688
|
const footer = props.footer,
|
|
1583
1689
|
isPopup = props.isPopup,
|
|
1584
1690
|
valueKey = props.valueKey,
|
|
@@ -1595,7 +1701,7 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1595
1701
|
'is-popup': isPopup
|
|
1596
1702
|
})
|
|
1597
1703
|
}, /*#__PURE__*/React__default["default"].createElement(SelectedAll, null)),
|
|
1598
|
-
treeList: /*#__PURE__*/React__default["default"].createElement(Fetch__default["default"], _extends({}, Object.assign({}, options ? {
|
|
1704
|
+
treeList: open ? /*#__PURE__*/React__default["default"].createElement(Fetch__default["default"], _extends({}, Object.assign({}, options ? {
|
|
1599
1705
|
data: {
|
|
1600
1706
|
options
|
|
1601
1707
|
},
|
|
@@ -1627,7 +1733,7 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1627
1733
|
autoHide: false
|
|
1628
1734
|
}, treeContent);
|
|
1629
1735
|
}
|
|
1630
|
-
})),
|
|
1736
|
+
})) : null,
|
|
1631
1737
|
selectedTag: showSelectedTag && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1632
1738
|
className: classnames__default["default"](style$1['selected-tag'], 'select-tree-selected-tag', {
|
|
1633
1739
|
'is-popup': isPopup
|
|
@@ -2015,7 +2121,7 @@ const CascaderInner = _ref => {
|
|
|
2015
2121
|
treeUtils
|
|
2016
2122
|
};
|
|
2017
2123
|
React.useEffect(() => {
|
|
2018
|
-
if (!openLoadData || !onLoadMore) {
|
|
2124
|
+
if (!open || !openLoadData || !onLoadMore) {
|
|
2019
2125
|
return;
|
|
2020
2126
|
}
|
|
2021
2127
|
const lastNode = mapping.get(last__default["default"](selectedIds));
|
|
@@ -2035,7 +2141,7 @@ const CascaderInner = _ref => {
|
|
|
2035
2141
|
}).catch(() => {
|
|
2036
2142
|
setLoading(false);
|
|
2037
2143
|
});
|
|
2038
|
-
}, [selectedIds, mapping, openLoadData, onLoadMore, parentIdKey]);
|
|
2144
|
+
}, [open, selectedIds, mapping, openLoadData, onLoadMore, parentIdKey]);
|
|
2039
2145
|
|
|
2040
2146
|
// 检查是否为非叶子节点
|
|
2041
2147
|
const isNotLastNode = React.useCallback(id => {
|
|
@@ -2471,7 +2577,7 @@ const SelectCascader = _ref4 => {
|
|
|
2471
2577
|
[labelKey]: String(item)
|
|
2472
2578
|
};
|
|
2473
2579
|
}).filter(Boolean);
|
|
2474
|
-
return /*#__PURE__*/React__default["default"].createElement(CascaderInner, {
|
|
2580
|
+
return contextProps.open ? /*#__PURE__*/React__default["default"].createElement(CascaderInner, {
|
|
2475
2581
|
options: options,
|
|
2476
2582
|
value: currentDisplayValue,
|
|
2477
2583
|
setValue: contextSetValue,
|
|
@@ -2490,10 +2596,14 @@ const SelectCascader = _ref4 => {
|
|
|
2490
2596
|
onOpenChange: contextProps.onOpenChange,
|
|
2491
2597
|
open: contextProps.open,
|
|
2492
2598
|
isMobile: contextProps.isMobile
|
|
2493
|
-
});
|
|
2599
|
+
}) : null;
|
|
2494
2600
|
});
|
|
2495
2601
|
};
|
|
2496
2602
|
|
|
2603
|
+
Object.defineProperty(exports, 'mergeTreeChildren', {
|
|
2604
|
+
enumerable: true,
|
|
2605
|
+
get: function () { return TableView.mergeTreeChildren; }
|
|
2606
|
+
});
|
|
2497
2607
|
exports.SelectCascader = SelectCascader;
|
|
2498
2608
|
exports.SelectInput = SelectInput;
|
|
2499
2609
|
exports.SelectTableList = SelectTableList;
|