@kne/super-select 0.1.46 → 0.1.48
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 +120 -2
- package/dist/index.css +34 -10
- package/dist/index.css.map +1 -1
- package/dist/index.js +603 -527
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +110 -91
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/dist/index.modern.js
CHANGED
|
@@ -18,9 +18,10 @@ import SimpleBar from 'simplebar-react';
|
|
|
18
18
|
import SearchInput from '@kne/search-input';
|
|
19
19
|
import { FetchScrollLoader } from '@kne/scroll-loader';
|
|
20
20
|
import '@kne/scroll-loader/dist/index.css';
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
import merge from 'lodash/merge';
|
|
22
|
+
import TablePage, { hasColumnWidth, isTreeDataType, normalizeTreeData, flattenAllTree } from '@kne/table-page';
|
|
23
|
+
export { mergeTreeChildren } from '@kne/table-page';
|
|
24
|
+
import '@kne/table-page/dist/index.css';
|
|
24
25
|
import { CentralContent } from '@kne/info-page';
|
|
25
26
|
import '@kne/info-page/dist/index.css';
|
|
26
27
|
import memoize from 'lodash/memoize';
|
|
@@ -1178,7 +1179,7 @@ const SelectList = forwardRef((_ref, ref) => {
|
|
|
1178
1179
|
});
|
|
1179
1180
|
});
|
|
1180
1181
|
|
|
1181
|
-
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-
|
|
1182
|
+
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-fit-columns":"kne-super-select_QqZxW","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"};
|
|
1182
1183
|
|
|
1183
1184
|
const isEmptyParentKey = value => value == null || value === '';
|
|
1184
1185
|
const flattenSelectList = (list, {
|
|
@@ -1248,12 +1249,25 @@ const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps,
|
|
|
1248
1249
|
}
|
|
1249
1250
|
return options.filter(item => getSearchCallback(searchProps, item, targetProps));
|
|
1250
1251
|
};
|
|
1252
|
+
const getListFromPageData = data => {
|
|
1253
|
+
if (Array.isArray(data == null ? void 0 : data.pageData)) {
|
|
1254
|
+
return data.pageData;
|
|
1255
|
+
}
|
|
1256
|
+
if (Array.isArray(data == null ? void 0 : data.list)) {
|
|
1257
|
+
return data.list;
|
|
1258
|
+
}
|
|
1259
|
+
return [];
|
|
1260
|
+
};
|
|
1261
|
+
const TABLE_LIST_MAX_HEIGHT_POPUP = 300;
|
|
1262
|
+
const TABLE_LIST_MAX_HEIGHT_EMBED = 400;
|
|
1263
|
+
const TABLE_HEADER_HEIGHT = 48;
|
|
1251
1264
|
const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select')(forwardRef((p, ref) => {
|
|
1252
1265
|
const {
|
|
1253
1266
|
formatMessage
|
|
1254
1267
|
} = useIntl();
|
|
1255
1268
|
const [tagSearchText, setTagSearchText] = useState('');
|
|
1256
|
-
const
|
|
1269
|
+
const tablePageRef = useRef();
|
|
1270
|
+
const listScrollRef = useRef();
|
|
1257
1271
|
const props = Object.assign({}, {
|
|
1258
1272
|
overlayWidth: '600px',
|
|
1259
1273
|
dataType: 'list',
|
|
@@ -1347,7 +1361,9 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1347
1361
|
defaultExpandedKeys,
|
|
1348
1362
|
onExpandedKeysChange,
|
|
1349
1363
|
indentSize,
|
|
1350
|
-
checkRelation
|
|
1364
|
+
checkRelation,
|
|
1365
|
+
pagination: paginationProp,
|
|
1366
|
+
dataFormat
|
|
1351
1367
|
} = props;
|
|
1352
1368
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
1353
1369
|
const resolvedTreeTitleKey = treeTitleKey || labelKey;
|
|
@@ -1355,57 +1371,42 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1355
1371
|
className: classnames(style$2['footer'], 'select-table-footer')
|
|
1356
1372
|
}, typeof footer === 'function' ? footer({
|
|
1357
1373
|
reload: () => {
|
|
1358
|
-
var
|
|
1359
|
-
(
|
|
1374
|
+
var _tablePageRef$current;
|
|
1375
|
+
(_tablePageRef$current = tablePageRef.current) == null || _tablePageRef$current.reload();
|
|
1360
1376
|
},
|
|
1361
1377
|
close: () => {
|
|
1362
1378
|
onOpenChange(false);
|
|
1363
1379
|
}
|
|
1364
1380
|
}) : footer);
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
dataType,
|
|
1387
|
-
valueKey,
|
|
1388
|
-
parentKey,
|
|
1389
|
-
childrenKey
|
|
1390
|
-
})
|
|
1391
|
-
};
|
|
1392
|
-
}
|
|
1393
|
-
} : api)
|
|
1394
|
-
}), fetchProps => {
|
|
1395
|
-
fetchListRef.current = fetchProps;
|
|
1396
|
-
const {
|
|
1397
|
-
list
|
|
1398
|
-
} = fetchProps;
|
|
1399
|
-
const contextProps = Object.assign({}, fetchProps, targetProps, {
|
|
1400
|
-
isSelectedAll
|
|
1401
|
-
});
|
|
1402
|
-
if (!(list && list.length > 0)) {
|
|
1403
|
-
return props.empty || /*#__PURE__*/React.createElement(Empty, {
|
|
1404
|
-
className: classnames(style$2['empty'])
|
|
1381
|
+
const paginationParamsType = (paginationProp == null ? void 0 : paginationProp.paramsType) || 'data';
|
|
1382
|
+
const searchRequestProps = typeof getSearchProps === 'function' && isNotEmpty(searchProps) ? {
|
|
1383
|
+
[paginationParamsType]: getSearchProps(searchProps) || {}
|
|
1384
|
+
} : {};
|
|
1385
|
+
const tablePageFetchConfig = options ? {
|
|
1386
|
+
data: {
|
|
1387
|
+
options,
|
|
1388
|
+
searchProps
|
|
1389
|
+
},
|
|
1390
|
+
loader: ({
|
|
1391
|
+
data
|
|
1392
|
+
}) => {
|
|
1393
|
+
const {
|
|
1394
|
+
options: nextOptions,
|
|
1395
|
+
searchProps: nextSearchProps
|
|
1396
|
+
} = data;
|
|
1397
|
+
const pageData = filterTreeOptions(nextOptions, nextSearchProps, getSearchCallback, targetProps, {
|
|
1398
|
+
dataType,
|
|
1399
|
+
valueKey,
|
|
1400
|
+
parentKey,
|
|
1401
|
+
childrenKey
|
|
1405
1402
|
});
|
|
1403
|
+
return {
|
|
1404
|
+
pageData,
|
|
1405
|
+
totalCount: pageData.length
|
|
1406
|
+
};
|
|
1406
1407
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1408
|
+
} : merge({}, api, searchRequestProps);
|
|
1409
|
+
const allColumnsHaveWidth = Array.isArray(columns) && columns.length > 0 && columns.every(hasColumnWidth);
|
|
1409
1410
|
const tableSelection = {
|
|
1410
1411
|
allowSelectedAll,
|
|
1411
1412
|
isSelectedAll,
|
|
@@ -1417,9 +1418,9 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1417
1418
|
checkRelation,
|
|
1418
1419
|
onChange: selectedRowKeys => {
|
|
1419
1420
|
setValue(prev => {
|
|
1420
|
-
var
|
|
1421
|
+
var _tablePageRef$current2;
|
|
1421
1422
|
const prevMap = new Map((prev || []).map(item => [item[valueKey], item]));
|
|
1422
|
-
const listMap = new Map(flattenSelectList((
|
|
1423
|
+
const listMap = new Map(flattenSelectList(getListFromPageData((_tablePageRef$current2 = tablePageRef.current) == null ? void 0 : _tablePageRef$current2.data), {
|
|
1423
1424
|
dataType,
|
|
1424
1425
|
rowKey: valueKey,
|
|
1425
1426
|
parentKey,
|
|
@@ -1464,7 +1465,7 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1464
1465
|
wrap: true,
|
|
1465
1466
|
gap: 8
|
|
1466
1467
|
}, value.filter(item => getTagSearchCallback(tagSearchText, item, targetProps)).map(item => {
|
|
1467
|
-
var
|
|
1468
|
+
var _tablePageRef$current3;
|
|
1468
1469
|
return /*#__PURE__*/React.createElement(Tag, {
|
|
1469
1470
|
className: style$2['tag'],
|
|
1470
1471
|
key: item[valueKey],
|
|
@@ -1488,8 +1489,8 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1488
1489
|
})),
|
|
1489
1490
|
dataSource: Object.assign({}, item),
|
|
1490
1491
|
context: Object.assign({}, targetProps, {
|
|
1491
|
-
fetchApi:
|
|
1492
|
-
list: (
|
|
1492
|
+
fetchApi: tablePageRef.current,
|
|
1493
|
+
list: getListFromPageData((_tablePageRef$current3 = tablePageRef.current) == null ? void 0 : _tablePageRef$current3.data)
|
|
1493
1494
|
})
|
|
1494
1495
|
})
|
|
1495
1496
|
}, /*#__PURE__*/React.createElement("span", {
|
|
@@ -1514,42 +1515,60 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
|
|
|
1514
1515
|
className: style$2['filter-wrap']
|
|
1515
1516
|
}, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React.createElement("div", {
|
|
1516
1517
|
className: classnames(style$2['table'], 'select-table')
|
|
1517
|
-
},
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1518
|
+
}, open ? /*#__PURE__*/React.createElement("div", {
|
|
1519
|
+
ref: listScrollRef,
|
|
1520
|
+
className: classnames(style$2['list'], 'select-table-list-scroll-list', {
|
|
1521
|
+
'is-popup': isPopup,
|
|
1522
|
+
[style$2['is-fit-columns']]: !allColumnsHaveWidth
|
|
1523
|
+
})
|
|
1524
|
+
}, /*#__PURE__*/React.createElement(TablePage, _extends({}, tablePageFetchConfig, {
|
|
1525
|
+
ref: tablePageRef
|
|
1526
|
+
}, dataFormat ? {
|
|
1527
|
+
dataFormat
|
|
1528
|
+
} : null, {
|
|
1529
|
+
pagination: Object.assign({
|
|
1530
|
+
open: false,
|
|
1531
|
+
showSizeChanger: false,
|
|
1532
|
+
showQuickJumper: false,
|
|
1533
|
+
hideOnSinglePage: true
|
|
1534
|
+
}, paginationProp),
|
|
1535
|
+
scroll: isMobile ? undefined : Object.assign({
|
|
1536
|
+
y: (isPopup ? TABLE_LIST_MAX_HEIGHT_POPUP : TABLE_LIST_MAX_HEIGHT_EMBED) - TABLE_HEADER_HEIGHT
|
|
1537
|
+
}, allColumnsHaveWidth ? null : {
|
|
1538
|
+
x: undefined
|
|
1539
|
+
}),
|
|
1540
|
+
controllerOpen: false,
|
|
1541
|
+
columns: columns,
|
|
1542
|
+
rowKey: valueKey,
|
|
1543
|
+
rowSelection: tableSelection,
|
|
1544
|
+
columnRenderProps: Object.assign({}, targetProps, {
|
|
1545
|
+
isSelectedAll
|
|
1546
|
+
}),
|
|
1547
|
+
empty: props.empty || /*#__PURE__*/React.createElement(Empty, {
|
|
1548
|
+
className: classnames(style$2['empty'])
|
|
1549
|
+
}),
|
|
1550
|
+
dataType: dataType,
|
|
1551
|
+
parentKey: parentKey,
|
|
1552
|
+
childrenKey: childrenKey,
|
|
1553
|
+
hasChildrenKey: hasChildrenKey,
|
|
1554
|
+
treeTitleKey: resolvedTreeTitleKey,
|
|
1555
|
+
renderMobile: renderMobile === false ? false : typeof renderMobile === 'function' ? mobileProps => renderMobile(_extends({}, mobileProps, targetProps, {
|
|
1556
|
+
isSelectedAll,
|
|
1557
|
+
list: mobileProps.displayDataSource || mobileProps.dataSource,
|
|
1558
|
+
dataSource: mobileProps.dataSource,
|
|
1559
|
+
renderBody: (nextList = mobileProps.displayDataSource || mobileProps.dataSource, nextContext) => mobileProps.renderBody(nextList, nextContext)
|
|
1560
|
+
})) : true
|
|
1561
|
+
}, typeof onLoadChildren === 'function' ? {
|
|
1562
|
+
onLoadChildren
|
|
1563
|
+
} : null, typeof onExpandedKeysChange === 'function' ? {
|
|
1564
|
+
onExpandedKeysChange
|
|
1565
|
+
} : null, indentSize != null ? {
|
|
1566
|
+
indentSize
|
|
1567
|
+
} : null, Object.prototype.hasOwnProperty.call(p, 'expandedKeys') ? {
|
|
1568
|
+
expandedKeys
|
|
1569
|
+
} : null, Object.prototype.hasOwnProperty.call(p, 'defaultExpandedKeys') ? {
|
|
1570
|
+
defaultExpandedKeys
|
|
1571
|
+
} : null))) : null), single && footerEl || !isMobile && /*#__PURE__*/React.createElement("div", {
|
|
1553
1572
|
className: classnames(style$2['footer'], 'select-table-footer')
|
|
1554
1573
|
}));
|
|
1555
1574
|
|