@majoo-ui/react 1.61.0-rc.4 → 1.61.0-rc.5
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/components/table/Table.d.ts +16 -2
- package/index.esm.js +13 -3
- package/index.umd.js +52 -41
- package/package.json +1 -1
|
@@ -1285,10 +1285,24 @@ export interface TableProps {
|
|
|
1285
1285
|
* Additional id which is not clickable and has no context menu
|
|
1286
1286
|
*/
|
|
1287
1287
|
additionalExceptionIds?: string[];
|
|
1288
|
+
/**
|
|
1289
|
+
* Additional props for set manual expanded row column
|
|
1290
|
+
* Example:<br/>
|
|
1291
|
+
* {
|
|
1292
|
+
* '8192389219289': true,
|
|
1293
|
+
* '2130912039281': true,
|
|
1294
|
+
* '2130912039382': true
|
|
1295
|
+
* }
|
|
1296
|
+
*/
|
|
1297
|
+
expanded?: object;
|
|
1288
1298
|
/**
|
|
1289
1299
|
* Callback fired when the expanded rows are updated.
|
|
1290
1300
|
*/
|
|
1291
|
-
|
|
1301
|
+
onExpandedChange?: (expanded: object) => void;
|
|
1302
|
+
/**
|
|
1303
|
+
* Additional props for autoResetExpanded
|
|
1304
|
+
*/
|
|
1305
|
+
autoResetExpanded?: boolean;
|
|
1292
1306
|
/**
|
|
1293
1307
|
* Additional id table for unique identifier each table <br />
|
|
1294
1308
|
* if id exist, column in the header can be customize to show in table <br />
|
|
@@ -1313,7 +1327,7 @@ export interface TableProps {
|
|
|
1313
1327
|
*/
|
|
1314
1328
|
autoResetExpanded?: boolean;
|
|
1315
1329
|
}
|
|
1316
|
-
export declare function Table({ columns, data: rawData, keyId, pageIndex: controlledPageIndex, totalPage, totalData, fetchData, hideDataInfo, rowsPerPageOptions, emptyDataMessage, customEmptyDataProps: emptyDataProps, isLoading, css, headerCss, hideHeader, onSelectedChange, isInfiniteScroll, hasMoreItems, rowLimit, cellAlign, selectedIds, rowGroup, decoration, hiddenColumns, columnOrder, customRowsStyle, isMobileLayout, showDuplicatedData, onRowClick, hidePagination, searchQuery, additionalExceptionIds,
|
|
1330
|
+
export declare function Table({ columns, data: rawData, keyId, pageIndex: controlledPageIndex, totalPage, totalData, fetchData, hideDataInfo, rowsPerPageOptions, emptyDataMessage, customEmptyDataProps: emptyDataProps, isLoading, css, headerCss, hideHeader, onSelectedChange, isInfiniteScroll, hasMoreItems, rowLimit, cellAlign, selectedIds, rowGroup, decoration, hiddenColumns, columnOrder, customRowsStyle, isMobileLayout, showDuplicatedData, onRowClick, hidePagination, searchQuery, additionalExceptionIds, expanded: controlledExpanded, onExpandedChange, id, onColumnChange, virtualized, withoutLimit, additionalHeader, outerContainerCss, autoResetExpanded, }: TableProps): JSX.Element;
|
|
1317
1331
|
export interface TableColumnProps {
|
|
1318
1332
|
/**
|
|
1319
1333
|
* Required if accessor is a function<br/>
|
package/index.esm.js
CHANGED
|
@@ -23888,7 +23888,8 @@ function Table({
|
|
|
23888
23888
|
hidePagination = false,
|
|
23889
23889
|
searchQuery,
|
|
23890
23890
|
additionalExceptionIds = [],
|
|
23891
|
-
|
|
23891
|
+
expanded: controlledExpanded = {},
|
|
23892
|
+
onExpandedChange,
|
|
23892
23893
|
id = null,
|
|
23893
23894
|
onColumnChange,
|
|
23894
23895
|
virtualized = true,
|
|
@@ -23923,18 +23924,27 @@ function Table({
|
|
|
23923
23924
|
selectedRowIds: selectedIds
|
|
23924
23925
|
});
|
|
23925
23926
|
}
|
|
23927
|
+
if (controlledExpanded) {
|
|
23928
|
+
Object.assign(initialState, {
|
|
23929
|
+
expanded: controlledExpanded
|
|
23930
|
+
});
|
|
23931
|
+
}
|
|
23926
23932
|
return Object.keys(initialState).length > 0 ? initialState : undefined;
|
|
23927
23933
|
};
|
|
23928
23934
|
const instance = useTable({
|
|
23929
23935
|
columns,
|
|
23930
23936
|
data: useMemo(() => formattingData(rawData, rowGroup), [rawData, rowGroup]),
|
|
23931
23937
|
initialState: getInitialState(),
|
|
23938
|
+
state: {
|
|
23939
|
+
expanded: controlledExpanded
|
|
23940
|
+
},
|
|
23932
23941
|
manualPagination: !!fetchData,
|
|
23933
23942
|
manualSortBy: !!fetchData,
|
|
23934
23943
|
defaultCanSort: true,
|
|
23935
23944
|
pageCount: totalPage || Math.ceil(totalData / limit),
|
|
23936
23945
|
autoResetSortBy: false,
|
|
23937
23946
|
autoResetExpanded,
|
|
23947
|
+
onExpandedChange,
|
|
23938
23948
|
autoResetPage: false,
|
|
23939
23949
|
autoResetSelectedRows: false,
|
|
23940
23950
|
getRowId: showDuplicatedData ? undefined : row => row[keyId] || JSON.stringify(row)
|
|
@@ -24179,8 +24189,8 @@ function Table({
|
|
|
24179
24189
|
firstUpdate.current = false;
|
|
24180
24190
|
return;
|
|
24181
24191
|
}
|
|
24182
|
-
|
|
24183
|
-
}, [expanded,
|
|
24192
|
+
onExpandedChange === null || onExpandedChange === void 0 ? void 0 : onExpandedChange(expanded);
|
|
24193
|
+
}, [expanded, onExpandedChange]);
|
|
24184
24194
|
useEffect(() => {
|
|
24185
24195
|
if (hiddenColumns) setHiddenColumns(hiddenColumns);
|
|
24186
24196
|
}, [hiddenColumns]);
|
package/index.umd.js
CHANGED
|
@@ -24260,42 +24260,44 @@
|
|
|
24260
24260
|
searchQuery = _a.searchQuery,
|
|
24261
24261
|
_t = _a.additionalExceptionIds,
|
|
24262
24262
|
additionalExceptionIds = _t === void 0 ? [] : _t,
|
|
24263
|
-
|
|
24264
|
-
|
|
24265
|
-
|
|
24263
|
+
_u = _a.expanded,
|
|
24264
|
+
controlledExpanded = _u === void 0 ? {} : _u,
|
|
24265
|
+
onExpandedChange = _a.onExpandedChange,
|
|
24266
|
+
_v = _a.id,
|
|
24267
|
+
id = _v === void 0 ? null : _v,
|
|
24266
24268
|
onColumnChange = _a.onColumnChange,
|
|
24267
|
-
|
|
24268
|
-
virtualized =
|
|
24269
|
-
|
|
24270
|
-
withoutLimit =
|
|
24269
|
+
_w = _a.virtualized,
|
|
24270
|
+
virtualized = _w === void 0 ? true : _w,
|
|
24271
|
+
_x = _a.withoutLimit,
|
|
24272
|
+
withoutLimit = _x === void 0 ? false : _x,
|
|
24271
24273
|
additionalHeader = _a.additionalHeader,
|
|
24272
24274
|
outerContainerCss = _a.outerContainerCss,
|
|
24273
|
-
|
|
24274
|
-
autoResetExpanded =
|
|
24275
|
-
var
|
|
24276
|
-
openMenu =
|
|
24277
|
-
setOpen =
|
|
24278
|
-
var
|
|
24279
|
-
limit =
|
|
24280
|
-
setLimit =
|
|
24281
|
-
var
|
|
24282
|
-
dataRow =
|
|
24283
|
-
setDataRow =
|
|
24284
|
-
var
|
|
24285
|
-
tableScrollPosition =
|
|
24286
|
-
setTableScrollPosition =
|
|
24287
|
-
var
|
|
24288
|
-
scrollAreaWidth =
|
|
24289
|
-
setScrollAreaWidth =
|
|
24290
|
-
var
|
|
24291
|
-
stateSelectedRowIds =
|
|
24292
|
-
setStateSelectedRowIds =
|
|
24293
|
-
var
|
|
24294
|
-
filterHeader =
|
|
24295
|
-
setFilterHeader =
|
|
24296
|
-
var
|
|
24297
|
-
filteredHeader =
|
|
24298
|
-
setFilteredHeader =
|
|
24275
|
+
_y = _a.autoResetExpanded,
|
|
24276
|
+
autoResetExpanded = _y === void 0 ? true : _y;
|
|
24277
|
+
var _z = React.useState(false),
|
|
24278
|
+
openMenu = _z[0],
|
|
24279
|
+
setOpen = _z[1];
|
|
24280
|
+
var _0 = React.useState(rowLimit),
|
|
24281
|
+
limit = _0[0],
|
|
24282
|
+
setLimit = _0[1];
|
|
24283
|
+
var _1 = React.useState({}),
|
|
24284
|
+
dataRow = _1[0],
|
|
24285
|
+
setDataRow = _1[1];
|
|
24286
|
+
var _2 = React.useState('start'),
|
|
24287
|
+
tableScrollPosition = _2[0],
|
|
24288
|
+
setTableScrollPosition = _2[1];
|
|
24289
|
+
var _3 = React.useState(0),
|
|
24290
|
+
scrollAreaWidth = _3[0],
|
|
24291
|
+
setScrollAreaWidth = _3[1];
|
|
24292
|
+
var _4 = React.useState(selectedIds ? Object.keys(selectedIds) : []),
|
|
24293
|
+
stateSelectedRowIds = _4[0],
|
|
24294
|
+
setStateSelectedRowIds = _4[1];
|
|
24295
|
+
var _5 = useLocalStorageState("menu:".concat(id), []),
|
|
24296
|
+
filterHeader = _5[0],
|
|
24297
|
+
setFilterHeader = _5[1];
|
|
24298
|
+
var _6 = React.useState([]),
|
|
24299
|
+
filteredHeader = _6[0],
|
|
24300
|
+
setFilteredHeader = _6[1];
|
|
24299
24301
|
var t = reactI18next.useTranslation('MajooUI/table').t;
|
|
24300
24302
|
var isMobile = useMediaQuery(isMobileLayout === undefined ? '(max-width: 1024px)' : isMobileLayout ? '(max-width: 8000px)' : '(max-width: 0px)');
|
|
24301
24303
|
var customEmptyDataProps = searchQuery ? defaultEmptySearchProps(t, isMobile, searchQuery) : emptyDataProps || defaultEmptyDataProps(t, isMobile);
|
|
@@ -24311,6 +24313,11 @@
|
|
|
24311
24313
|
selectedRowIds: selectedIds
|
|
24312
24314
|
});
|
|
24313
24315
|
}
|
|
24316
|
+
if (controlledExpanded) {
|
|
24317
|
+
Object.assign(initialState, {
|
|
24318
|
+
expanded: controlledExpanded
|
|
24319
|
+
});
|
|
24320
|
+
}
|
|
24314
24321
|
return Object.keys(initialState).length > 0 ? initialState : undefined;
|
|
24315
24322
|
};
|
|
24316
24323
|
var instance = reactTable.useTable({
|
|
@@ -24319,12 +24326,16 @@
|
|
|
24319
24326
|
return formattingData(rawData, rowGroup);
|
|
24320
24327
|
}, [rawData, rowGroup]),
|
|
24321
24328
|
initialState: getInitialState(),
|
|
24329
|
+
state: {
|
|
24330
|
+
expanded: controlledExpanded
|
|
24331
|
+
},
|
|
24322
24332
|
manualPagination: !!fetchData,
|
|
24323
24333
|
manualSortBy: !!fetchData,
|
|
24324
24334
|
defaultCanSort: true,
|
|
24325
24335
|
pageCount: totalPage || Math.ceil(totalData / limit),
|
|
24326
24336
|
autoResetSortBy: false,
|
|
24327
24337
|
autoResetExpanded: autoResetExpanded,
|
|
24338
|
+
onExpandedChange: onExpandedChange,
|
|
24328
24339
|
autoResetPage: false,
|
|
24329
24340
|
autoResetSelectedRows: false,
|
|
24330
24341
|
getRowId: showDuplicatedData ? undefined : function (row) {
|
|
@@ -24341,12 +24352,12 @@
|
|
|
24341
24352
|
setPageSize = instance.setPageSize,
|
|
24342
24353
|
toggleRowSelected = instance.toggleRowSelected,
|
|
24343
24354
|
toggleAllRowsSelected = instance.toggleAllRowsSelected,
|
|
24344
|
-
|
|
24345
|
-
pageIndex =
|
|
24346
|
-
pageSize =
|
|
24347
|
-
sortBy =
|
|
24348
|
-
selectedRowIds =
|
|
24349
|
-
expanded =
|
|
24355
|
+
_7 = instance.state,
|
|
24356
|
+
pageIndex = _7.pageIndex,
|
|
24357
|
+
pageSize = _7.pageSize,
|
|
24358
|
+
sortBy = _7.sortBy,
|
|
24359
|
+
selectedRowIds = _7.selectedRowIds,
|
|
24360
|
+
expanded = _7.expanded,
|
|
24350
24361
|
setHiddenColumns = instance.setHiddenColumns,
|
|
24351
24362
|
setColumnOrder = instance.setColumnOrder;
|
|
24352
24363
|
var scrollerRef = React.useRef(null);
|
|
@@ -24592,8 +24603,8 @@
|
|
|
24592
24603
|
firstUpdate.current = false;
|
|
24593
24604
|
return;
|
|
24594
24605
|
}
|
|
24595
|
-
|
|
24596
|
-
}, [expanded,
|
|
24606
|
+
onExpandedChange === null || onExpandedChange === void 0 ? void 0 : onExpandedChange(expanded);
|
|
24607
|
+
}, [expanded, onExpandedChange]);
|
|
24597
24608
|
React.useEffect(function () {
|
|
24598
24609
|
if (hiddenColumns) setHiddenColumns(hiddenColumns);
|
|
24599
24610
|
}, [hiddenColumns]);
|