@ni/nimble-components 21.5.1 → 21.5.2
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/all-components-bundle.js +51 -30
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +571 -569
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/table/models/expansion-manager.d.ts +3 -2
- package/dist/esm/table/models/expansion-manager.js +50 -29
- package/dist/esm/table/models/expansion-manager.js.map +1 -1
- package/package.json +1 -1
|
@@ -16301,7 +16301,7 @@
|
|
|
16301
16301
|
|
|
16302
16302
|
/**
|
|
16303
16303
|
* Do not edit directly
|
|
16304
|
-
* Generated on
|
|
16304
|
+
* Generated on Mon, 19 Feb 2024 18:58:25 GMT
|
|
16305
16305
|
*/
|
|
16306
16306
|
|
|
16307
16307
|
const Information100DarkUi = "#a46eff";
|
|
@@ -65953,79 +65953,94 @@ img.ProseMirror-separator {
|
|
|
65953
65953
|
class ExpansionManager {
|
|
65954
65954
|
constructor(tanStackTable) {
|
|
65955
65955
|
this.tanStackTable = tanStackTable;
|
|
65956
|
-
|
|
65957
|
-
// state or not. Note that the default expanded state for a particular row type (group vs parent) can
|
|
65958
|
-
// potentially be different (e.g. expanded for groups and collapsed for parent rows).
|
|
65959
|
-
this.isInDefaultState = true;
|
|
65960
|
-
this.collapsedRows = new Set();
|
|
65956
|
+
this.explicitExpansionStates = new Map();
|
|
65961
65957
|
this.hierarchyOptions = new Map();
|
|
65962
65958
|
this.isHierarchyEnabled = false;
|
|
65959
|
+
this.parentRowsWithChildren = new Set();
|
|
65963
65960
|
}
|
|
65964
65961
|
isRowExpanded(row) {
|
|
65965
65962
|
if (!this.isRowExpandable(row)) {
|
|
65966
65963
|
return false;
|
|
65967
65964
|
}
|
|
65968
|
-
|
|
65969
|
-
|
|
65970
|
-
}
|
|
65971
|
-
return this.isInDefaultState || !this.collapsedRows.has(row.id);
|
|
65965
|
+
const expansionState = this.explicitExpansionStates.get(row.id);
|
|
65966
|
+
return expansionState ?? this.getDefaultExpansionState(row);
|
|
65972
65967
|
}
|
|
65973
65968
|
toggleRowExpansion(row) {
|
|
65974
65969
|
if (!this.isRowExpandable(row)) {
|
|
65975
65970
|
return;
|
|
65976
65971
|
}
|
|
65977
65972
|
const wasExpanded = this.isRowExpanded(row);
|
|
65978
|
-
this.
|
|
65979
|
-
if (wasExpanded) {
|
|
65980
|
-
this.collapsedRows.add(row.id);
|
|
65981
|
-
}
|
|
65982
|
-
else {
|
|
65983
|
-
this.collapsedRows.delete(row.id);
|
|
65984
|
-
}
|
|
65973
|
+
this.explicitExpansionStates.set(row.id, !wasExpanded);
|
|
65985
65974
|
row.toggleExpanded();
|
|
65986
65975
|
}
|
|
65987
65976
|
collapseAll() {
|
|
65988
65977
|
this.resetExpansionState();
|
|
65989
|
-
this.isInDefaultState = false;
|
|
65990
65978
|
const rows = this.tanStackTable.getRowModel().flatRows;
|
|
65991
65979
|
for (const row of rows) {
|
|
65992
65980
|
if (this.isRowExpandable(row)) {
|
|
65993
|
-
this.
|
|
65981
|
+
this.explicitExpansionStates.set(row.id, false);
|
|
65994
65982
|
}
|
|
65995
65983
|
}
|
|
65996
65984
|
this.tanStackTable.toggleAllRowsExpanded(false);
|
|
65997
65985
|
}
|
|
65998
65986
|
resetExpansionState() {
|
|
65999
|
-
this.
|
|
66000
|
-
this.isInDefaultState = true;
|
|
65987
|
+
this.explicitExpansionStates.clear();
|
|
66001
65988
|
}
|
|
66002
65989
|
resetHierarchyOptions() {
|
|
66003
65990
|
this.hierarchyOptions.clear();
|
|
66004
65991
|
}
|
|
66005
65992
|
processDataUpdate(rows) {
|
|
66006
|
-
if (this.
|
|
65993
|
+
if (this.explicitExpansionStates.size === 0
|
|
65994
|
+
&& this.hierarchyOptions.size === 0) {
|
|
66007
65995
|
return;
|
|
66008
65996
|
}
|
|
66009
|
-
const
|
|
65997
|
+
const updatedExplicitExpansionStates = new Map();
|
|
66010
65998
|
const updatedHierarchyOptions = new Map();
|
|
65999
|
+
const updatedParentRowsWithChildren = new Set();
|
|
66011
66000
|
for (const row of rows) {
|
|
66012
66001
|
const rowId = row.id;
|
|
66013
|
-
|
|
66014
|
-
updatedCollapsedRows.add(rowId);
|
|
66015
|
-
}
|
|
66002
|
+
const isGroupRow = row.getIsGrouped();
|
|
66016
66003
|
const rowHierarchyOptions = this.hierarchyOptions.get(rowId);
|
|
66017
|
-
if (!
|
|
66004
|
+
if (!isGroupRow && rowHierarchyOptions) {
|
|
66018
66005
|
updatedHierarchyOptions.set(rowId, rowHierarchyOptions);
|
|
66019
66006
|
}
|
|
66007
|
+
if (this.isRowExpandable(row)) {
|
|
66008
|
+
const expansionState = this.explicitExpansionStates.get(rowId);
|
|
66009
|
+
if (expansionState !== undefined) {
|
|
66010
|
+
updatedExplicitExpansionStates.set(rowId, expansionState);
|
|
66011
|
+
}
|
|
66012
|
+
if (!isGroupRow) {
|
|
66013
|
+
const hasChildRows = row.subRows.length !== 0;
|
|
66014
|
+
if (hasChildRows) {
|
|
66015
|
+
updatedParentRowsWithChildren.add(rowId);
|
|
66016
|
+
}
|
|
66017
|
+
else if (this.parentRowsWithChildren.has(rowId)) {
|
|
66018
|
+
// The row used to have children, but now it does not. Therefore,
|
|
66019
|
+
// collapse the row.
|
|
66020
|
+
updatedExplicitExpansionStates.set(rowId, false);
|
|
66021
|
+
}
|
|
66022
|
+
}
|
|
66023
|
+
}
|
|
66020
66024
|
}
|
|
66021
|
-
this.
|
|
66025
|
+
this.explicitExpansionStates = updatedExplicitExpansionStates;
|
|
66022
66026
|
this.hierarchyOptions = updatedHierarchyOptions;
|
|
66027
|
+
this.parentRowsWithChildren = updatedParentRowsWithChildren;
|
|
66023
66028
|
}
|
|
66024
66029
|
setHierarchyOptions(hierarchyOptions) {
|
|
66025
|
-
|
|
66030
|
+
const updatedHierarchyOptions = new Map();
|
|
66026
66031
|
for (const { recordId, options } of hierarchyOptions) {
|
|
66027
|
-
|
|
66032
|
+
updatedHierarchyOptions.set(recordId, options);
|
|
66033
|
+
const oldState = this.hierarchyOptions.get(recordId)?.delayedHierarchyState;
|
|
66034
|
+
const newState = options.delayedHierarchyState;
|
|
66035
|
+
if (oldState === TableRecordDelayedHierarchyState.loadingChildren
|
|
66036
|
+
&& newState === TableRecordDelayedHierarchyState.canLoadChildren
|
|
66037
|
+
&& !this.parentRowsWithChildren.has(recordId)) {
|
|
66038
|
+
// If a row without children transitions from loadingChildren to canLoadChildren,
|
|
66039
|
+
// put it back in its default state of collapsed.
|
|
66040
|
+
this.explicitExpansionStates.delete(recordId);
|
|
66041
|
+
}
|
|
66028
66042
|
}
|
|
66043
|
+
this.hierarchyOptions = updatedHierarchyOptions;
|
|
66029
66044
|
}
|
|
66030
66045
|
isRowExpandable(row) {
|
|
66031
66046
|
return row.subRows.length > 0 || this.canLoadDelayedChildren(row.id);
|
|
@@ -66047,6 +66062,12 @@ img.ProseMirror-separator {
|
|
|
66047
66062
|
const delayedHierarchyState = this.hierarchyOptions.get(id)?.delayedHierarchyState;
|
|
66048
66063
|
return delayedHierarchyState !== TableRecordDelayedHierarchyState.none;
|
|
66049
66064
|
}
|
|
66065
|
+
getDefaultExpansionState(row) {
|
|
66066
|
+
// Rows with children (group rows and parent rows with populated children)
|
|
66067
|
+
// default to expanded. Other rows (parent rows with lazy-loaded children)
|
|
66068
|
+
// default to collapsed.
|
|
66069
|
+
return row.subRows.length !== 0;
|
|
66070
|
+
}
|
|
66050
66071
|
}
|
|
66051
66072
|
|
|
66052
66073
|
/**
|