@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.
@@ -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
- onExpand?: (expanded: object) => void;
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, onExpand, id, onColumnChange, virtualized, withoutLimit, additionalHeader, outerContainerCss, autoResetExpanded, }: TableProps): JSX.Element;
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
- onExpand,
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
- onExpand === null || onExpand === void 0 ? void 0 : onExpand(expanded);
24183
- }, [expanded, onExpand]);
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
- onExpand = _a.onExpand,
24264
- _u = _a.id,
24265
- id = _u === void 0 ? null : _u,
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
- _v = _a.virtualized,
24268
- virtualized = _v === void 0 ? true : _v,
24269
- _w = _a.withoutLimit,
24270
- withoutLimit = _w === void 0 ? false : _w,
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
- _x = _a.autoResetExpanded,
24274
- autoResetExpanded = _x === void 0 ? true : _x;
24275
- var _y = React.useState(false),
24276
- openMenu = _y[0],
24277
- setOpen = _y[1];
24278
- var _z = React.useState(rowLimit),
24279
- limit = _z[0],
24280
- setLimit = _z[1];
24281
- var _0 = React.useState({}),
24282
- dataRow = _0[0],
24283
- setDataRow = _0[1];
24284
- var _1 = React.useState('start'),
24285
- tableScrollPosition = _1[0],
24286
- setTableScrollPosition = _1[1];
24287
- var _2 = React.useState(0),
24288
- scrollAreaWidth = _2[0],
24289
- setScrollAreaWidth = _2[1];
24290
- var _3 = React.useState(selectedIds ? Object.keys(selectedIds) : []),
24291
- stateSelectedRowIds = _3[0],
24292
- setStateSelectedRowIds = _3[1];
24293
- var _4 = useLocalStorageState("menu:".concat(id), []),
24294
- filterHeader = _4[0],
24295
- setFilterHeader = _4[1];
24296
- var _5 = React.useState([]),
24297
- filteredHeader = _5[0],
24298
- setFilteredHeader = _5[1];
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
- _6 = instance.state,
24345
- pageIndex = _6.pageIndex,
24346
- pageSize = _6.pageSize,
24347
- sortBy = _6.sortBy,
24348
- selectedRowIds = _6.selectedRowIds,
24349
- expanded = _6.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
- onExpand === null || onExpand === void 0 ? void 0 : onExpand(expanded);
24596
- }, [expanded, onExpand]);
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]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@majoo-ui/react",
3
- "version": "1.61.0-rc.4",
3
+ "version": "1.61.0-rc.5",
4
4
  "dependencies": {
5
5
  "@majoo-ui/core": "^1.31.3",
6
6
  "@majoo-ui/helpers": "^1.30.5",