@kne/table-page 0.1.15 → 0.1.17
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 +2 -2
- package/dist/index.css +2 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +38 -17
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +44 -22
- package/dist/index.modern.js.map +1 -1
- package/package.json +4 -3
package/dist/index.modern.js
CHANGED
|
@@ -25,6 +25,7 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
25
25
|
import { createWithIntlProvider, useIntl } from '@kne/react-intl';
|
|
26
26
|
import filterZhCN from '@kne/react-filter/dist/locale/zh-CN';
|
|
27
27
|
import filterEnUS from '@kne/react-filter/dist/locale/en-US';
|
|
28
|
+
import useControlValue from '@kne/use-control-value';
|
|
28
29
|
import { createPortal } from 'react-dom';
|
|
29
30
|
import '@kne/button-group/dist/index.css';
|
|
30
31
|
import '@kne/react-filter/dist/index.css';
|
|
@@ -1156,7 +1157,7 @@ const TreeExpandContent = ({
|
|
|
1156
1157
|
|
|
1157
1158
|
const _excluded$3 = ["className", "dataSource", "columns", "rowKey", "rowSelection", "valueIsEmpty", "emptyIsPlaceholder", "placeholder", "empty", "onRowSelect", "render", "renderMobile", "context", "sticky", "scrollTopInset", "stickyOffset", "getStickyContainer", "headerStyle", "pagination", "sortRender", "mobileSortToolbar", "name", "controllerOpen", "tableServerApis", "scroll", "summary", "size", "dataType", "parentKey", "childrenKey", "hasChildrenKey", "treeTitleKey", "onLoadChildren", "expandedKeys", "defaultExpandedKeys", "onExpandedKeysChange", "indentSize"],
|
|
1158
1159
|
_excluded2$2 = ["y"],
|
|
1159
|
-
_excluded3 = ["getContainer"];
|
|
1160
|
+
_excluded3$1 = ["getContainer"];
|
|
1160
1161
|
const mapJustifyToAlign = justify => {
|
|
1161
1162
|
if (justify === 'center') {
|
|
1162
1163
|
return 'center';
|
|
@@ -1870,7 +1871,7 @@ const Table = p => {
|
|
|
1870
1871
|
}
|
|
1871
1872
|
const config = typeof sticky === 'object' ? Object.assign({}, sticky) : {};
|
|
1872
1873
|
if (hasScrollY) {
|
|
1873
|
-
const scrollSticky = _objectWithoutPropertiesLoose(config, _excluded3);
|
|
1874
|
+
const scrollSticky = _objectWithoutPropertiesLoose(config, _excluded3$1);
|
|
1874
1875
|
return Object.assign({
|
|
1875
1876
|
offsetHeader: 0
|
|
1876
1877
|
}, scrollSticky);
|
|
@@ -2324,8 +2325,9 @@ const resolveToolbarButtonGroupProps = (buttonGroup, getPopupContainer) => {
|
|
|
2324
2325
|
|
|
2325
2326
|
var style = {"kne-responsive-boundary":"kne-table-page_u90lj","kne-responsive-scroll":"kne-table-page_bSj1H","table-toolbar-section":"kne-table-page_I21Xn","has-value-display":"kne-table-page_COnMY","table-toolbar":"kne-table-page_x6mv7","table-toolbar-value-display":"kne-table-page_vbwMg","table-toolbar-batch":"kne-table-page_k8-Ku","table-toolbar-batch-btn":"kne-table-page_gZtbT","table-toolbar-batch-clear-btn":"kne-table-page_o6Oml","table-toolbar-actions":"kne-table-page_t3-57","table-toolbar-button-group":"kne-table-page_2sdSC","table-toolbar-search":"kne-table-page_pB5en","table-page-tabs":"kne-table-page_UTy3R","is-mobile-render":"kne-table-page_J-AEV","is-mobile":"kne-table-page_n9eAS","table-toolbar-mobile-actions":"kne-table-page_I--A1","table-toolbar-mobile-filter-row":"kne-table-page_Qo5Zl","table-toolbar-filter":"kne-table-page_Jyfm7","has-mobile-search":"kne-table-page_14SJt","table-toolbar-search-row":"kne-table-page_zuGJv","has-mobile-search-only":"kne-table-page_Y5IR1","has-tabs":"kne-table-page_EImBh","table-toolbar-search-input":"kne-table-page_t60hK","table-toolbar-divider":"kne-table-page_z--2N","table-toolbar-filter-outer":"kne-table-page_PiWGM","table-toolbar-filter-inner":"kne-table-page_AX3aK"};
|
|
2326
2327
|
|
|
2327
|
-
const _excluded$1 = ["
|
|
2328
|
-
_excluded2$1 = ["
|
|
2328
|
+
const _excluded$1 = ["getPopupContainer"],
|
|
2329
|
+
_excluded2$1 = ["list", "displayLine", "extraExpand", "className"],
|
|
2330
|
+
_excluded3 = ["className", "style"];
|
|
2329
2331
|
const TAB_ALL_KEY = '__all__';
|
|
2330
2332
|
const getTabActiveKey = (filterValue, tabName) => {
|
|
2331
2333
|
var _entry$value;
|
|
@@ -2347,7 +2349,13 @@ const TablePageTabs = ({
|
|
|
2347
2349
|
const {
|
|
2348
2350
|
formatMessage
|
|
2349
2351
|
} = useIntl();
|
|
2352
|
+
const getPopupContainer = usePopupContainer();
|
|
2350
2353
|
const showTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
|
|
2354
|
+
const _ref = tabProps || {},
|
|
2355
|
+
{
|
|
2356
|
+
getPopupContainer: userGetPopupContainer
|
|
2357
|
+
} = _ref,
|
|
2358
|
+
restTabProps = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
2351
2359
|
const tabItems = useMemo(() => {
|
|
2352
2360
|
if (!showTab) {
|
|
2353
2361
|
return [];
|
|
@@ -2388,7 +2396,8 @@ const TablePageTabs = ({
|
|
|
2388
2396
|
}),
|
|
2389
2397
|
children: /*#__PURE__*/jsx(Tabs, _extends({
|
|
2390
2398
|
size: "small"
|
|
2391
|
-
},
|
|
2399
|
+
}, restTabProps, {
|
|
2400
|
+
getPopupContainer: userGetPopupContainer != null ? userGetPopupContainer : getPopupContainer,
|
|
2392
2401
|
activeKey: getTabActiveKey(filterValue, tab.name),
|
|
2393
2402
|
onChange: handleTabChange,
|
|
2394
2403
|
items: tabItems
|
|
@@ -2518,20 +2527,20 @@ const TableToolbar = ({
|
|
|
2518
2527
|
if (!showBatchInToolbar && !showFilter && !showSearch && !showTab && !showButtonGroup && !showCardModeToggle) {
|
|
2519
2528
|
return null;
|
|
2520
2529
|
}
|
|
2521
|
-
const
|
|
2530
|
+
const _ref2 = filter || {},
|
|
2522
2531
|
{
|
|
2523
2532
|
list: filterList,
|
|
2524
2533
|
displayLine = 1,
|
|
2525
2534
|
extraExpand,
|
|
2526
2535
|
className: filterClassName
|
|
2527
|
-
} =
|
|
2528
|
-
filterRest = _objectWithoutPropertiesLoose(
|
|
2529
|
-
const
|
|
2536
|
+
} = _ref2,
|
|
2537
|
+
filterRest = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
|
|
2538
|
+
const _ref3 = search || {},
|
|
2530
2539
|
{
|
|
2531
2540
|
className: searchClassName,
|
|
2532
2541
|
style: searchStyle
|
|
2533
|
-
} =
|
|
2534
|
-
searchRest = _objectWithoutPropertiesLoose(
|
|
2542
|
+
} = _ref3,
|
|
2543
|
+
searchRest = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
2535
2544
|
|
|
2536
2545
|
// tab 已有选中态展示,已选筛选标签中不再重复显示 tab 的值
|
|
2537
2546
|
const displayFilterValue = hasTab ? (filterValue || []).filter(item => (item == null ? void 0 : item.name) !== tab.name) : filterValue || [];
|
|
@@ -2651,6 +2660,17 @@ const defaultMergeList = (data, newData) => {
|
|
|
2651
2660
|
pageData: [...((data == null ? void 0 : data.pageData) || []), ...((newData == null ? void 0 : newData.pageData) || [])]
|
|
2652
2661
|
});
|
|
2653
2662
|
};
|
|
2663
|
+
|
|
2664
|
+
/** 与 use-control-value 一致:有 value key 为受控,否则用 defaultValue */
|
|
2665
|
+
const resolveInitialFilterValue = filter => {
|
|
2666
|
+
if (!filter) {
|
|
2667
|
+
return [];
|
|
2668
|
+
}
|
|
2669
|
+
if ('value' in filter) {
|
|
2670
|
+
return filter.value || [];
|
|
2671
|
+
}
|
|
2672
|
+
return filter.defaultValue || [];
|
|
2673
|
+
};
|
|
2654
2674
|
const readPageSize = key => {
|
|
2655
2675
|
try {
|
|
2656
2676
|
const value = localStorage.getItem(key);
|
|
@@ -2794,9 +2814,9 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2794
2814
|
const tableContentRef = useRef(null);
|
|
2795
2815
|
const pendingScrollRef = useRef(false);
|
|
2796
2816
|
const handlerDataFormat = useRefCallback(dataFormat);
|
|
2797
|
-
const
|
|
2798
|
-
|
|
2799
|
-
|
|
2817
|
+
const [filterValue, setFilterValue] = useControlValue(Object.assign({
|
|
2818
|
+
defaultValue: []
|
|
2819
|
+
}, filter));
|
|
2800
2820
|
const mapFilterValue = (filter == null ? void 0 : filter.mapFilterValue) || getFilterValue;
|
|
2801
2821
|
const getFilterParams = useRefCallback(value => {
|
|
2802
2822
|
return mapFilterValue(value || []);
|
|
@@ -2843,10 +2863,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2843
2863
|
});
|
|
2844
2864
|
});
|
|
2845
2865
|
const handleFilterChange = useRefCallback(value => {
|
|
2846
|
-
|
|
2847
|
-
setInternalFilterValue(value);
|
|
2848
|
-
}
|
|
2849
|
-
filter == null || filter.onChange == null || filter.onChange(value);
|
|
2866
|
+
setFilterValue(value);
|
|
2850
2867
|
reload({
|
|
2851
2868
|
[pagination.paramsType]: buildRequestParamsWithFilter(value, {
|
|
2852
2869
|
[pagination.currentName]: 1
|
|
@@ -3107,12 +3124,17 @@ const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
3107
3124
|
});
|
|
3108
3125
|
const params = props[pagination.paramsType];
|
|
3109
3126
|
const filterDefaultParams = useMemo(() => {
|
|
3110
|
-
|
|
3111
|
-
if (!
|
|
3127
|
+
const filter = props.filter;
|
|
3128
|
+
if (!filter) {
|
|
3129
|
+
return {};
|
|
3130
|
+
}
|
|
3131
|
+
const initialValue = resolveInitialFilterValue(filter);
|
|
3132
|
+
const mapFilterValue = filter.mapFilterValue || getFilterValue;
|
|
3133
|
+
// 有 mapFilterValue 时即使 initialValue 为空也要跑(注入 namespace 等)
|
|
3134
|
+
if (!initialValue.length && !filter.mapFilterValue) {
|
|
3112
3135
|
return {};
|
|
3113
3136
|
}
|
|
3114
|
-
|
|
3115
|
-
return mapFilterValue(props.filter.defaultValue);
|
|
3137
|
+
return mapFilterValue(initialValue);
|
|
3116
3138
|
}, [props.filter]);
|
|
3117
3139
|
const fetchParams = useMemo(() => {
|
|
3118
3140
|
return {
|