trotl-table 1.0.80 → 1.0.81

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/dist/Table.cjs.js CHANGED
@@ -9677,6 +9677,8 @@ function TableInner({
9677
9677
  enableMouseRightClick = null,
9678
9678
  customColumns = [],
9679
9679
  groupDefaultOpen = false,
9680
+ groupExpanded = null,
9681
+ onExpandedGroupsChange = () => {},
9680
9682
  showIcons = true,
9681
9683
  timeoutLoading = 5,
9682
9684
  t
@@ -10311,12 +10313,24 @@ function TableInner({
10311
10313
  rows: sortRows(g.rows || [])
10312
10314
  }));
10313
10315
  }, [normalizedGroups, sorting, filterRows, getAccessorValue]);
10316
+ const emitExpandedChange = React.useCallback((nextState, toggledGroupId) => {
10317
+ if (typeof onExpandedGroupsChange === "function") {
10318
+ onExpandedGroupsChange(nextState, toggledGroupId);
10319
+ }
10320
+ if (typeof groupExpanded === "function") {
10321
+ groupExpanded(nextState, toggledGroupId);
10322
+ }
10323
+ }, [onExpandedGroupsChange, groupExpanded]);
10314
10324
  const [expandedGroups, setExpandedGroups] = React.useState({});
10315
10325
  const toggleGroup = gid => {
10316
- setExpandedGroups(prev => ({
10317
- ...prev,
10318
- [gid]: !prev[gid]
10319
- }));
10326
+ setExpandedGroups(prev => {
10327
+ const next = {
10328
+ ...prev,
10329
+ [gid]: !prev[gid]
10330
+ };
10331
+ emitExpandedChange(next, gid);
10332
+ return next;
10333
+ });
10320
10334
  };
10321
10335
  React.useEffect(() => {
10322
10336
  // Pre-populate expansion state for all groups
@@ -10331,6 +10345,11 @@ function TableInner({
10331
10345
  return next;
10332
10346
  });
10333
10347
  }, [normalizedGroups, groupKey, groupDefaultOpen]);
10348
+ React.useEffect(() => {
10349
+ if (groupExpanded && typeof groupExpanded === "object") {
10350
+ setExpandedGroups(groupExpanded);
10351
+ }
10352
+ }, [groupExpanded]);
10334
10353
  const groupRowsById = React.useMemo(() => {
10335
10354
  const map = {};
10336
10355
  for (const g of sortedGroupedData) {