@ni/nimble-components 20.18.0 → 21.0.0
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 +484 -240
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +508 -482
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/label-provider/table/index.d.ts +3 -3
- package/dist/esm/label-provider/table/index.js +4 -4
- package/dist/esm/label-provider/table/index.js.map +1 -1
- package/dist/esm/label-provider/table/label-token-defaults.js +1 -1
- package/dist/esm/label-provider/table/label-token-defaults.js.map +1 -1
- package/dist/esm/label-provider/table/label-tokens.d.ts +1 -1
- package/dist/esm/label-provider/table/label-tokens.js +3 -3
- package/dist/esm/label-provider/table/label-tokens.js.map +1 -1
- package/dist/esm/table/components/group-row/index.d.ts +1 -1
- package/dist/esm/table/components/group-row/index.js +1 -1
- package/dist/esm/table/components/group-row/index.js.map +1 -1
- package/dist/esm/table/components/group-row/template.js +1 -1
- package/dist/esm/table/components/group-row/template.js.map +1 -1
- package/dist/esm/table/components/row/index.d.ts +1 -0
- package/dist/esm/table/components/row/index.js +6 -0
- package/dist/esm/table/components/row/index.js.map +1 -1
- package/dist/esm/table/components/row/template.js +1 -1
- package/dist/esm/table/components/row/template.js.map +1 -1
- package/dist/esm/table/index.d.ts +14 -4
- package/dist/esm/table/index.js +105 -77
- package/dist/esm/table/index.js.map +1 -1
- package/dist/esm/table/models/array-to-tree.d.ts +17 -0
- package/dist/esm/table/models/array-to-tree.js +83 -0
- package/dist/esm/table/models/array-to-tree.js.map +1 -0
- package/dist/esm/table/models/data-hierarchy-manager.d.ts +15 -0
- package/dist/esm/table/models/data-hierarchy-manager.js +64 -0
- package/dist/esm/table/models/data-hierarchy-manager.js.map +1 -0
- package/dist/esm/table/models/expansion-manager.d.ts +25 -0
- package/dist/esm/table/models/expansion-manager.js +73 -0
- package/dist/esm/table/models/expansion-manager.js.map +1 -0
- package/dist/esm/table/models/interactive-selection-manager.d.ts +1 -0
- package/dist/esm/table/models/interactive-selection-manager.js +13 -0
- package/dist/esm/table/models/interactive-selection-manager.js.map +1 -1
- package/dist/esm/table/models/selection-managers/selection-manager-base.js +6 -4
- package/dist/esm/table/models/selection-managers/selection-manager-base.js.map +1 -1
- package/dist/esm/table/models/table-update-tracker.d.ts +3 -1
- package/dist/esm/table/models/table-update-tracker.js +12 -1
- package/dist/esm/table/models/table-update-tracker.js.map +1 -1
- package/dist/esm/table/models/table-validator.d.ts +5 -3
- package/dist/esm/table/models/table-validator.js +14 -7
- package/dist/esm/table/models/table-validator.js.map +1 -1
- package/dist/esm/table/template.js +12 -8
- package/dist/esm/table/template.js.map +1 -1
- package/dist/esm/table/testing/table.pageobject.d.ts +4 -0
- package/dist/esm/table/testing/table.pageobject.js +24 -0
- package/dist/esm/table/testing/table.pageobject.js.map +1 -1
- package/dist/esm/table/types.d.ts +6 -3
- package/dist/esm/table/types.js.map +1 -1
- package/dist/esm/table-column/number-text/index.d.ts +1 -1
- package/dist/esm/unit/base/unit.d.ts +1 -1
- package/dist/esm/unit/byte/index.js +1 -1
- package/dist/esm/unit/byte/index.js.map +1 -1
- package/dist/esm/unit/volt/index.js +1 -1
- package/dist/esm/unit/volt/index.js.map +1 -1
- package/dist/esm/utilities/unit-format/decimal-unit-format.d.ts +2 -2
- package/dist/esm/utilities/unit-format/decimal-unit-format.js +1 -1
- package/dist/esm/utilities/unit-format/decimal-unit-format.js.map +1 -1
- package/dist/esm/utilities/unit-format/default-unit-format.d.ts +1 -1
- package/dist/esm/utilities/unit-format/default-unit-format.js +1 -1
- package/dist/esm/utilities/unit-format/default-unit-format.js.map +1 -1
- package/dist/esm/utilities/unit-format/{unit-scale/base → scaled-unit}/scaled-unit.d.ts +1 -1
- package/dist/esm/utilities/unit-format/scaled-unit/scaled-unit.js.map +1 -0
- package/dist/esm/utilities/unit-format/scaled-unit-format/intl-number-format-scaled-unit-format.d.ts +11 -0
- package/dist/esm/utilities/unit-format/{unit-scale/base → scaled-unit-format}/intl-number-format-scaled-unit-format.js +2 -2
- package/dist/esm/utilities/unit-format/scaled-unit-format/intl-number-format-scaled-unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/scaled-unit-format/manually-translated-scaled-unit-format.d.ts +43 -0
- package/dist/esm/utilities/unit-format/{manually-translated-unit-scale/base → scaled-unit-format}/manually-translated-scaled-unit-format.js +27 -14
- package/dist/esm/utilities/unit-format/scaled-unit-format/manually-translated-scaled-unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/{unit-scale/base → scaled-unit-format}/scaled-unit-format.d.ts +1 -1
- package/dist/esm/utilities/unit-format/{unit-scale/base → scaled-unit-format}/scaled-unit-format.js.map +1 -1
- package/dist/esm/utilities/unit-format/{base/unit-format.d.ts → unit-format.d.ts} +1 -1
- package/dist/esm/utilities/unit-format/unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/byte-1024-unit-scale.d.ts +9 -0
- package/dist/esm/utilities/unit-format/unit-scale/byte-1024-unit-scale.js +31 -0
- package/dist/esm/utilities/unit-format/unit-scale/byte-1024-unit-scale.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/byte-unit-scale.d.ts +1 -1
- package/dist/esm/utilities/unit-format/unit-scale/byte-unit-scale.js +16 -35
- package/dist/esm/utilities/unit-format/unit-scale/byte-unit-scale.js.map +1 -1
- package/dist/esm/utilities/unit-format/unit-scale/passthrough-unit-scale.d.ts +1 -1
- package/dist/esm/utilities/unit-format/unit-scale/passthrough-unit-scale.js +4 -4
- package/dist/esm/utilities/unit-format/unit-scale/passthrough-unit-scale.js.map +1 -1
- package/dist/esm/utilities/unit-format/unit-scale/{base/unit-scale.d.ts → unit-scale.d.ts} +1 -1
- package/dist/esm/utilities/unit-format/unit-scale/unit-scale.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/utilities/metrix-prefixes.d.ts +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/utilities/metrix-prefixes.js +17 -0
- package/dist/esm/utilities/unit-format/unit-scale/utilities/metrix-prefixes.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/volt-unit-scale.d.ts +9 -0
- package/dist/esm/utilities/unit-format/unit-scale/volt-unit-scale.js +24 -0
- package/dist/esm/utilities/unit-format/unit-scale/volt-unit-scale.js.map +1 -0
- package/package.json +1 -1
- package/dist/esm/utilities/unit-format/base/unit-format.js.map +0 -1
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-scaled-unit-format.d.ts +0 -18
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-scaled-unit-format.js.map +0 -1
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-unit-scale.d.ts +0 -10
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-unit-scale.js +0 -19
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-unit-scale.js.map +0 -1
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefix.d.ts +0 -10
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefix.js +0 -17
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefix.js.map +0 -1
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.d.ts +0 -5
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.js +0 -21
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.js.map +0 -1
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.d.ts +0 -9
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.js +0 -11
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.js.map +0 -1
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.d.ts +0 -9
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.js +0 -26
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.js.map +0 -1
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/volt-unit-scale.d.ts +0 -9
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/volt-unit-scale.js +0 -19
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/volt-unit-scale.js.map +0 -1
- package/dist/esm/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.d.ts +0 -11
- package/dist/esm/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.js.map +0 -1
- package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit.js.map +0 -1
- package/dist/esm/utilities/unit-format/unit-scale/base/unit-scale.js.map +0 -1
- /package/dist/esm/utilities/unit-format/{unit-scale/base → scaled-unit}/scaled-unit.js +0 -0
- /package/dist/esm/utilities/unit-format/{unit-scale/base → scaled-unit-format}/scaled-unit-format.js +0 -0
- /package/dist/esm/utilities/unit-format/{base/unit-format.js → unit-format.js} +0 -0
- /package/dist/esm/utilities/unit-format/unit-scale/{base/unit-scale.js → unit-scale.js} +0 -0
|
@@ -16301,7 +16301,7 @@
|
|
|
16301
16301
|
|
|
16302
16302
|
/**
|
|
16303
16303
|
* Do not edit directly
|
|
16304
|
-
* Generated on
|
|
16304
|
+
* Generated on Fri, 19 Jan 2024 22:07:28 GMT
|
|
16305
16305
|
*/
|
|
16306
16306
|
|
|
16307
16307
|
const Information100DarkUi = "#a46eff";
|
|
@@ -23897,7 +23897,7 @@
|
|
|
23897
23897
|
tableGroupExpandLabel: 'Expand group',
|
|
23898
23898
|
tableRowCollapseLabel: 'Collapse row',
|
|
23899
23899
|
tableRowExpandLabel: 'Expand row',
|
|
23900
|
-
|
|
23900
|
+
tableCollapseAllLabel: 'Collapse all',
|
|
23901
23901
|
tableCellActionMenuLabel: 'Options',
|
|
23902
23902
|
tableColumnHeaderGroupedLabel: 'Grouped',
|
|
23903
23903
|
tableColumnHeaderSortedAscendingLabel: 'Sorted ascending',
|
|
@@ -23924,10 +23924,10 @@
|
|
|
23924
23924
|
name: 'table-row-expand-label',
|
|
23925
23925
|
cssCustomPropertyName: null
|
|
23926
23926
|
}).withDefault(tableLabelDefaults.tableRowExpandLabel);
|
|
23927
|
-
const
|
|
23928
|
-
name: 'table-
|
|
23927
|
+
const tableCollapseAllLabel = DesignToken.create({
|
|
23928
|
+
name: 'table-collapse-all-label',
|
|
23929
23929
|
cssCustomPropertyName: null
|
|
23930
|
-
}).withDefault(tableLabelDefaults.
|
|
23930
|
+
}).withDefault(tableLabelDefaults.tableCollapseAllLabel);
|
|
23931
23931
|
const tableCellActionMenuLabel = DesignToken.create({
|
|
23932
23932
|
name: 'table-cell-action-menu-label',
|
|
23933
23933
|
cssCustomPropertyName: null
|
|
@@ -23966,7 +23966,7 @@
|
|
|
23966
23966
|
groupExpand: tableGroupExpandLabel,
|
|
23967
23967
|
rowCollapse: tableRowCollapseLabel,
|
|
23968
23968
|
rowExpand: tableRowExpandLabel,
|
|
23969
|
-
|
|
23969
|
+
collapseAll: tableCollapseAllLabel,
|
|
23970
23970
|
cellActionMenu: tableCellActionMenuLabel,
|
|
23971
23971
|
columnHeaderGrouped: tableColumnHeaderGroupedLabel,
|
|
23972
23972
|
columnHeaderSortedAscending: tableColumnHeaderSortedAscendingLabel,
|
|
@@ -23998,8 +23998,8 @@
|
|
|
23998
23998
|
attr({ attribute: 'row-expand' })
|
|
23999
23999
|
], LabelProviderTable.prototype, "rowExpand", void 0);
|
|
24000
24000
|
__decorate$1([
|
|
24001
|
-
attr({ attribute: '
|
|
24002
|
-
], LabelProviderTable.prototype, "
|
|
24001
|
+
attr({ attribute: 'collapse-all' })
|
|
24002
|
+
], LabelProviderTable.prototype, "collapseAll", void 0);
|
|
24003
24003
|
__decorate$1([
|
|
24004
24004
|
attr({ attribute: 'cell-action-menu' })
|
|
24005
24005
|
], LabelProviderTable.prototype, "cellActionMenu", void 0);
|
|
@@ -61480,6 +61480,7 @@ img.ProseMirror-separator {
|
|
|
61480
61480
|
this.duplicateGroupIndex = false;
|
|
61481
61481
|
this.idFieldNameNotConfigured = false;
|
|
61482
61482
|
this.invalidColumnConfiguration = false;
|
|
61483
|
+
this.invalidParentIdConfiguration = false;
|
|
61483
61484
|
this.recordIds = new Set();
|
|
61484
61485
|
}
|
|
61485
61486
|
getValidity() {
|
|
@@ -61492,7 +61493,8 @@ img.ProseMirror-separator {
|
|
|
61492
61493
|
duplicateSortIndex: this.duplicateSortIndex,
|
|
61493
61494
|
duplicateGroupIndex: this.duplicateGroupIndex,
|
|
61494
61495
|
idFieldNameNotConfigured: this.idFieldNameNotConfigured,
|
|
61495
|
-
invalidColumnConfiguration: this.invalidColumnConfiguration
|
|
61496
|
+
invalidColumnConfiguration: this.invalidColumnConfiguration,
|
|
61497
|
+
invalidParentIdConfiguration: this.invalidParentIdConfiguration
|
|
61496
61498
|
};
|
|
61497
61499
|
}
|
|
61498
61500
|
isValid() {
|
|
@@ -61504,12 +61506,14 @@ img.ProseMirror-separator {
|
|
|
61504
61506
|
&& !validity.missingRecordId
|
|
61505
61507
|
&& !validity.invalidRecordId);
|
|
61506
61508
|
}
|
|
61507
|
-
|
|
61508
|
-
|
|
61509
|
-
|
|
61509
|
+
validateIdFieldConfiguration(selectionMode, idFieldName, parentIdFieldName) {
|
|
61510
|
+
const idFieldNameRequired = selectionMode !== TableRowSelectionMode.none
|
|
61511
|
+
|| typeof parentIdFieldName === 'string';
|
|
61512
|
+
if (idFieldNameRequired) {
|
|
61513
|
+
this.idFieldNameNotConfigured = typeof idFieldName !== 'string';
|
|
61510
61514
|
}
|
|
61511
61515
|
else {
|
|
61512
|
-
this.idFieldNameNotConfigured =
|
|
61516
|
+
this.idFieldNameNotConfigured = false;
|
|
61513
61517
|
}
|
|
61514
61518
|
return !this.idFieldNameNotConfigured;
|
|
61515
61519
|
}
|
|
@@ -61523,11 +61527,11 @@ img.ProseMirror-separator {
|
|
|
61523
61527
|
return true;
|
|
61524
61528
|
}
|
|
61525
61529
|
for (const record of data) {
|
|
61526
|
-
if (!Object.prototype.hasOwnProperty.call(record
|
|
61530
|
+
if (!Object.prototype.hasOwnProperty.call(record, idFieldName)) {
|
|
61527
61531
|
this.missingRecordId = true;
|
|
61528
61532
|
continue;
|
|
61529
61533
|
}
|
|
61530
|
-
const id = record
|
|
61534
|
+
const id = record[idFieldName];
|
|
61531
61535
|
if (typeof id !== 'string') {
|
|
61532
61536
|
this.invalidRecordId = true;
|
|
61533
61537
|
continue;
|
|
@@ -61576,6 +61580,9 @@ img.ProseMirror-separator {
|
|
|
61576
61580
|
getPresentRecordIds(requestedRecordIds) {
|
|
61577
61581
|
return requestedRecordIds.filter(id => this.recordIds.has(id));
|
|
61578
61582
|
}
|
|
61583
|
+
setParentIdConfigurationValidity(valid) {
|
|
61584
|
+
this.invalidParentIdConfiguration = !valid;
|
|
61585
|
+
}
|
|
61579
61586
|
validateIndicesAreUnique(indices) {
|
|
61580
61587
|
const numberSet = new Set(indices);
|
|
61581
61588
|
return numberSet.size === indices.length;
|
|
@@ -62131,7 +62138,7 @@ img.ProseMirror-separator {
|
|
|
62131
62138
|
`)}
|
|
62132
62139
|
</span>
|
|
62133
62140
|
`)}
|
|
62134
|
-
<span class="row-front-spacer ${x => (x.
|
|
62141
|
+
<span class="row-front-spacer ${x => (x.isTopLevelParentRow ? 'top-level-parent' : '')}"></span>
|
|
62135
62142
|
${when(x => x.isParentRow, html `
|
|
62136
62143
|
<${buttonTag}
|
|
62137
62144
|
appearance="${ButtonAppearance.ghost}"
|
|
@@ -62224,6 +62231,9 @@ img.ProseMirror-separator {
|
|
|
62224
62231
|
this.expandIcon?.removeEventListener('transitionend', this.removeAnimatingClass);
|
|
62225
62232
|
};
|
|
62226
62233
|
}
|
|
62234
|
+
get isTopLevelParentRow() {
|
|
62235
|
+
return this.isParentRow && this.nestingLevel === 0;
|
|
62236
|
+
}
|
|
62227
62237
|
get ariaSelected() {
|
|
62228
62238
|
if (this.selectable) {
|
|
62229
62239
|
return this.selected ? 'true' : 'false';
|
|
@@ -62411,6 +62421,9 @@ img.ProseMirror-separator {
|
|
|
62411
62421
|
__decorate$1([
|
|
62412
62422
|
observable
|
|
62413
62423
|
], TableRow.prototype, "animationClass", void 0);
|
|
62424
|
+
__decorate$1([
|
|
62425
|
+
volatile
|
|
62426
|
+
], TableRow.prototype, "isTopLevelParentRow", null);
|
|
62414
62427
|
__decorate$1([
|
|
62415
62428
|
volatile
|
|
62416
62429
|
], TableRow.prototype, "ariaSelected", null);
|
|
@@ -62547,7 +62560,7 @@ img.ProseMirror-separator {
|
|
|
62547
62560
|
|
|
62548
62561
|
<div class="group-row-header-content">
|
|
62549
62562
|
${x => x.groupColumn?.columnInternals.groupHeaderViewTemplate}
|
|
62550
|
-
<span class="group-row-child-count">(${x => x.
|
|
62563
|
+
<span class="group-row-child-count">(${x => x.immediateChildCount})</span>
|
|
62551
62564
|
</div>
|
|
62552
62565
|
</template>
|
|
62553
62566
|
`;
|
|
@@ -62628,7 +62641,7 @@ img.ProseMirror-separator {
|
|
|
62628
62641
|
], TableGroupRow.prototype, "nestingLevel", void 0);
|
|
62629
62642
|
__decorate$1([
|
|
62630
62643
|
observable
|
|
62631
|
-
], TableGroupRow.prototype, "
|
|
62644
|
+
], TableGroupRow.prototype, "immediateChildCount", void 0);
|
|
62632
62645
|
__decorate$1([
|
|
62633
62646
|
observable
|
|
62634
62647
|
], TableGroupRow.prototype, "groupColumn", void 0);
|
|
@@ -62658,7 +62671,7 @@ img.ProseMirror-separator {
|
|
|
62658
62671
|
// prettier-ignore
|
|
62659
62672
|
const template$e = html `
|
|
62660
62673
|
<template
|
|
62661
|
-
role="
|
|
62674
|
+
role="treegrid"
|
|
62662
62675
|
aria-multiselectable="${x => x.ariaMultiSelectable}"
|
|
62663
62676
|
${children$1({ property: 'childItems', filter: elements() })}
|
|
62664
62677
|
>
|
|
@@ -62698,11 +62711,11 @@ img.ProseMirror-separator {
|
|
|
62698
62711
|
class="collapse-all-button ${x => `${x.showCollapseAll ? 'visible' : ''}`}"
|
|
62699
62712
|
content-hidden
|
|
62700
62713
|
appearance="${ButtonAppearance.ghost}"
|
|
62701
|
-
title="${x =>
|
|
62702
|
-
@click="${x => x.
|
|
62714
|
+
title="${x => tableCollapseAllLabel.getValueFor(x)}"
|
|
62715
|
+
@click="${x => x.handleCollapseAllRows()}"
|
|
62703
62716
|
>
|
|
62704
62717
|
<${iconTriangleTwoLinesHorizontalTag} slot="start"></${iconTriangleTwoLinesHorizontalTag}>
|
|
62705
|
-
${x =>
|
|
62718
|
+
${x => tableCollapseAllLabel.getValueFor(x)}
|
|
62706
62719
|
</${buttonTag}>
|
|
62707
62720
|
</span>
|
|
62708
62721
|
<span class="column-headers-container" ${ref('columnHeadersContainer')}>
|
|
@@ -62739,13 +62752,13 @@ img.ProseMirror-separator {
|
|
|
62739
62752
|
role="rowgroup">
|
|
62740
62753
|
${when(x => x.columns.length > 0 && x.canRenderRows, html `
|
|
62741
62754
|
${repeat(x => x.virtualizer.visibleItems, html `
|
|
62742
|
-
${when((x, c) => c.parent.tableData[x.index]?.
|
|
62755
|
+
${when((x, c) => c.parent.tableData[x.index]?.isGroupRow, html `
|
|
62743
62756
|
<${tableGroupRowTag}
|
|
62744
62757
|
class="group-row"
|
|
62745
62758
|
:groupRowValue="${(x, c) => c.parent.tableData[x.index]?.groupRowValue}"
|
|
62746
62759
|
?expanded="${(x, c) => c.parent.tableData[x.index]?.isExpanded}"
|
|
62747
62760
|
:nestingLevel="${(x, c) => c.parent.tableData[x.index]?.nestingLevel}"
|
|
62748
|
-
:
|
|
62761
|
+
:immediateChildCount="${(x, c) => c.parent.tableData[x.index]?.immediateChildCount}"
|
|
62749
62762
|
:groupColumn="${(x, c) => c.parent.tableData[x.index]?.groupColumn}"
|
|
62750
62763
|
?selectable="${(_, c) => c.parent.selectionMode === TableRowSelectionMode.multiple}"
|
|
62751
62764
|
selection-state="${(x, c) => c.parent.tableData[x.index]?.selectionState}"
|
|
@@ -62754,21 +62767,25 @@ img.ProseMirror-separator {
|
|
|
62754
62767
|
>
|
|
62755
62768
|
</${tableGroupRowTag}>
|
|
62756
62769
|
`)}
|
|
62757
|
-
${when((x, c) => !c.parent.tableData[x.index]?.
|
|
62770
|
+
${when((x, c) => !c.parent.tableData[x.index]?.isGroupRow, html `
|
|
62758
62771
|
<${tableRowTag}
|
|
62759
62772
|
class="row"
|
|
62760
62773
|
record-id="${(x, c) => c.parent.tableData[x.index]?.id}"
|
|
62761
62774
|
?selectable="${(_, c) => c.parent.selectionMode !== TableRowSelectionMode.none}"
|
|
62762
62775
|
?selected="${(x, c) => c.parent.tableData[x.index]?.selectionState === TableRowSelectionState.selected}"
|
|
62776
|
+
?expanded="${(x, c) => c.parent.tableData[x.index]?.isExpanded}"
|
|
62763
62777
|
?hide-selection="${(_, c) => c.parent.selectionMode !== TableRowSelectionMode.multiple}"
|
|
62764
62778
|
:dataRecord="${(x, c) => c.parent.tableData[x.index]?.record}"
|
|
62765
62779
|
:columns="${(_, c) => c.parent.columns}"
|
|
62780
|
+
:isParentRow="${(x, c) => c.parent.tableData[x.index]?.isParentRow}"
|
|
62766
62781
|
:nestingLevel="${(x, c) => c.parent.tableData[x.index]?.nestingLevel}"
|
|
62767
62782
|
?row-operation-grid-cell-hidden="${(_, c) => !c.parent.showRowOperationColumn}"
|
|
62768
62783
|
@click="${(x, c) => c.parent.onRowClick(x.index, c.event)}"
|
|
62769
62784
|
@row-selection-toggle="${(x, c) => c.parent.onRowSelectionToggle(x.index, c.event)}"
|
|
62770
62785
|
@row-action-menu-beforetoggle="${(x, c) => c.parent.onRowActionMenuBeforeToggle(x.index, c.event)}"
|
|
62771
62786
|
@row-action-menu-toggle="${(_, c) => c.parent.onRowActionMenuToggle(c.event)}"
|
|
62787
|
+
@row-expand-toggle="${(x, c) => c.parent.handleRowExpanded(x.index)}"
|
|
62788
|
+
:dataIndex="${x => x.index}"
|
|
62772
62789
|
>
|
|
62773
62790
|
${when((x, c) => c.parent.openActionMenuRecordId === c.parent.tableData[x.index]?.id, html `
|
|
62774
62791
|
${repeat((_, c) => c.parent.actionMenuSlots, html `
|
|
@@ -63892,6 +63909,7 @@ img.ProseMirror-separator {
|
|
|
63892
63909
|
};
|
|
63893
63910
|
const trackedItems$1 = [
|
|
63894
63911
|
'rowIds',
|
|
63912
|
+
'rowParentIds',
|
|
63895
63913
|
'groupRows',
|
|
63896
63914
|
'columnIds',
|
|
63897
63915
|
'columnSort',
|
|
@@ -63913,6 +63931,9 @@ img.ProseMirror-separator {
|
|
|
63913
63931
|
get updateRowIds() {
|
|
63914
63932
|
return this.isTracked('rowIds');
|
|
63915
63933
|
}
|
|
63934
|
+
get updateRowParentIds() {
|
|
63935
|
+
return this.isTracked('rowParentIds');
|
|
63936
|
+
}
|
|
63916
63937
|
get updateGroupRows() {
|
|
63917
63938
|
return this.isTracked('groupRows');
|
|
63918
63939
|
}
|
|
@@ -63936,13 +63957,16 @@ img.ProseMirror-separator {
|
|
|
63936
63957
|
}
|
|
63937
63958
|
get requiresTanStackUpdate() {
|
|
63938
63959
|
return (this.isTracked('rowIds')
|
|
63960
|
+
|| this.isTracked('rowParentIds')
|
|
63939
63961
|
|| this.isTracked('columnSort')
|
|
63940
63962
|
|| this.isTracked('columnDefinition')
|
|
63941
63963
|
|| this.isTracked('groupRows')
|
|
63942
63964
|
|| this.isTracked('selectionMode'));
|
|
63943
63965
|
}
|
|
63944
63966
|
get requiresTanStackDataReset() {
|
|
63945
|
-
return this.isTracked('rowIds')
|
|
63967
|
+
return (this.isTracked('rowIds')
|
|
63968
|
+
|| this.isTracked('columnDefinition')
|
|
63969
|
+
|| this.isTracked('rowParentIds'));
|
|
63946
63970
|
}
|
|
63947
63971
|
trackAllStateChanged() {
|
|
63948
63972
|
this.trackAll();
|
|
@@ -63987,6 +64011,10 @@ img.ProseMirror-separator {
|
|
|
63987
64011
|
this.track('rowIds');
|
|
63988
64012
|
this.queueUpdate();
|
|
63989
64013
|
}
|
|
64014
|
+
trackParentIdFieldNameChanged() {
|
|
64015
|
+
this.track('rowParentIds');
|
|
64016
|
+
this.queueUpdate();
|
|
64017
|
+
}
|
|
63990
64018
|
trackSelectionModeChanged() {
|
|
63991
64019
|
this.track('selectionMode');
|
|
63992
64020
|
this.queueUpdate();
|
|
@@ -64015,18 +64043,20 @@ img.ProseMirror-separator {
|
|
|
64015
64043
|
}
|
|
64016
64044
|
reset() { }
|
|
64017
64045
|
toggleIsRowSelected(rowState, isSelecting) {
|
|
64018
|
-
if (rowState.
|
|
64046
|
+
if (rowState.isGroupRow
|
|
64019
64047
|
&& rowState.selectionState === TableRowSelectionState.selected) {
|
|
64020
64048
|
// Work around for https://github.com/TanStack/table/issues/4759
|
|
64021
64049
|
// Manually deselect all leaf rows when a fully selected group is being deselected.
|
|
64022
64050
|
this.deselectAllLeafRows(rowState.id);
|
|
64023
64051
|
}
|
|
64024
64052
|
else {
|
|
64025
|
-
this.tanStackTable.getRow(rowState.id).toggleSelected(isSelecting
|
|
64053
|
+
this.tanStackTable.getRow(rowState.id).toggleSelected(isSelecting, {
|
|
64054
|
+
selectChildren: rowState.isGroupRow
|
|
64055
|
+
});
|
|
64026
64056
|
}
|
|
64027
64057
|
}
|
|
64028
64058
|
selectSingleRow(rowState) {
|
|
64029
|
-
if (rowState.
|
|
64059
|
+
if (rowState.isGroupRow) {
|
|
64030
64060
|
throw new Error('function not intended to select grouped rows');
|
|
64031
64061
|
}
|
|
64032
64062
|
const currentSelection = this.tanStackTable.getState().rowSelection;
|
|
@@ -64064,7 +64094,7 @@ img.ProseMirror-separator {
|
|
|
64064
64094
|
}
|
|
64065
64095
|
return row
|
|
64066
64096
|
.getLeafRows()
|
|
64067
|
-
.filter(leafRow => leafRow.
|
|
64097
|
+
.filter(leafRow => !leafRow.getIsGrouped())
|
|
64068
64098
|
.map(leafRow => leafRow.id);
|
|
64069
64099
|
}
|
|
64070
64100
|
getAllOrderedRows() {
|
|
@@ -64251,6 +64281,19 @@ img.ProseMirror-separator {
|
|
|
64251
64281
|
handleSelectionReset() {
|
|
64252
64282
|
this.selectionManager.reset();
|
|
64253
64283
|
}
|
|
64284
|
+
getCurrentSelectedRecordIds() {
|
|
64285
|
+
const tanStackSelectionState = this.tanStackTable.options.state.rowSelection;
|
|
64286
|
+
if (!tanStackSelectionState) {
|
|
64287
|
+
return [];
|
|
64288
|
+
}
|
|
64289
|
+
const selectedRecordIds = [];
|
|
64290
|
+
Object.entries(tanStackSelectionState).forEach(([recordId, isSelected]) => {
|
|
64291
|
+
if (isSelected) {
|
|
64292
|
+
selectedRecordIds.push(recordId);
|
|
64293
|
+
}
|
|
64294
|
+
});
|
|
64295
|
+
return selectedRecordIds;
|
|
64296
|
+
}
|
|
64254
64297
|
createSelectionManager(selectionMode) {
|
|
64255
64298
|
switch (selectionMode) {
|
|
64256
64299
|
case TableRowSelectionMode.multiple:
|
|
@@ -64265,6 +64308,225 @@ img.ProseMirror-separator {
|
|
|
64265
64308
|
}
|
|
64266
64309
|
}
|
|
64267
64310
|
|
|
64311
|
+
// Modified from https://github.com/philipstanislaus/performant-array-to-tree/blob/v1.11.0/src/arrayToTree.ts
|
|
64312
|
+
// Copyright (c) 2022 philipstanislaus
|
|
64313
|
+
// SPDX-License-Identifier: MIT
|
|
64314
|
+
/**
|
|
64315
|
+
* Unflattens an array to a tree with runtime O(n)
|
|
64316
|
+
*/
|
|
64317
|
+
function arrayToTree(items, config) {
|
|
64318
|
+
const conf = config;
|
|
64319
|
+
// the resulting unflattened tree
|
|
64320
|
+
const rootItems = [];
|
|
64321
|
+
// stores all already processed items with their ids as key so we can easily look them up
|
|
64322
|
+
const lookup = {};
|
|
64323
|
+
// stores all item ids that have not been added to the resulting unflattened tree yet
|
|
64324
|
+
// this is an opt-in property, since it has a slight runtime overhead
|
|
64325
|
+
const orphanIds = new Set();
|
|
64326
|
+
// idea of this loop:
|
|
64327
|
+
// whenever an item has a parent, but the parent is not yet in the lookup object, we store a preliminary parent
|
|
64328
|
+
// in the lookup object and fill it with the data of the parent later
|
|
64329
|
+
// if an item has no parentId, add it as a root element to rootItems
|
|
64330
|
+
// Convert to a for-loop to have access to the item's index in the flat list
|
|
64331
|
+
for (let i = 0; i < items.length; i++) {
|
|
64332
|
+
const item = items[i];
|
|
64333
|
+
const itemId = item[conf.id];
|
|
64334
|
+
const parentId = item[conf.parentId];
|
|
64335
|
+
// look whether item already exists in the lookup table
|
|
64336
|
+
if (!Object.prototype.hasOwnProperty.call(lookup, itemId)) {
|
|
64337
|
+
// item is not yet there, so add a preliminary item (its data will be added later)
|
|
64338
|
+
lookup[itemId] = {
|
|
64339
|
+
subRows: [],
|
|
64340
|
+
clientRecord: undefined,
|
|
64341
|
+
originalIndex: undefined
|
|
64342
|
+
};
|
|
64343
|
+
}
|
|
64344
|
+
// if we track orphans, delete this item from the orphan set if it is in it
|
|
64345
|
+
if (orphanIds) {
|
|
64346
|
+
orphanIds.delete(itemId);
|
|
64347
|
+
}
|
|
64348
|
+
// add the current item's data to the item in the lookup table
|
|
64349
|
+
lookup[itemId].clientRecord = item;
|
|
64350
|
+
const treeItem = lookup[itemId];
|
|
64351
|
+
// Add the index to the item
|
|
64352
|
+
treeItem.originalIndex = i;
|
|
64353
|
+
if (parentId === null || parentId === undefined) {
|
|
64354
|
+
// is a root item
|
|
64355
|
+
rootItems.push(treeItem);
|
|
64356
|
+
}
|
|
64357
|
+
else {
|
|
64358
|
+
// has a parent
|
|
64359
|
+
// look whether the parent already exists in the lookup table
|
|
64360
|
+
if (!Object.prototype.hasOwnProperty.call(lookup, parentId)) {
|
|
64361
|
+
// parent is not yet there, so add a preliminary parent (its data will be added later)
|
|
64362
|
+
lookup[parentId] = {
|
|
64363
|
+
subRows: [],
|
|
64364
|
+
clientRecord: undefined,
|
|
64365
|
+
originalIndex: undefined
|
|
64366
|
+
};
|
|
64367
|
+
// if we track orphans, add the generated parent to the orphan list
|
|
64368
|
+
if (orphanIds) {
|
|
64369
|
+
orphanIds.add(parentId);
|
|
64370
|
+
}
|
|
64371
|
+
}
|
|
64372
|
+
// add the current item to the parent
|
|
64373
|
+
lookup[parentId].subRows.push(treeItem);
|
|
64374
|
+
}
|
|
64375
|
+
}
|
|
64376
|
+
if (orphanIds?.size) {
|
|
64377
|
+
const orphans = Array.from(orphanIds.values()).join(',');
|
|
64378
|
+
throw new Error(`The items array contains orphans that point to the following parentIds: [${orphans}]. These parentIds do not exist in the items array.`);
|
|
64379
|
+
}
|
|
64380
|
+
if (countNodes(rootItems) < Object.keys(lookup).length) {
|
|
64381
|
+
throw new Error('The items array contains nodes with a circular parent/child relationship.');
|
|
64382
|
+
}
|
|
64383
|
+
return rootItems;
|
|
64384
|
+
}
|
|
64385
|
+
/**
|
|
64386
|
+
* Returns the number of nodes in a tree in a recursive way
|
|
64387
|
+
* @param tree An array of nodes (tree items), each having a field `childrenField` that contains an array of nodes
|
|
64388
|
+
* @returns Number of nodes in the tree
|
|
64389
|
+
*/
|
|
64390
|
+
function countNodes(tree) {
|
|
64391
|
+
return tree.reduce((sum, n) => sum + 1 + (n.subRows && countNodes(n.subRows)), 0);
|
|
64392
|
+
}
|
|
64393
|
+
|
|
64394
|
+
/**
|
|
64395
|
+
* Manages data hierarchy within the table, including converting between a flat list of
|
|
64396
|
+
* data and hierarchical data.
|
|
64397
|
+
*/
|
|
64398
|
+
class DataHierarchyManager {
|
|
64399
|
+
constructor(records, idFieldName, parentIdFieldName) {
|
|
64400
|
+
this.isDataFlat = false;
|
|
64401
|
+
if (typeof idFieldName === 'string'
|
|
64402
|
+
&& typeof parentIdFieldName === 'string') {
|
|
64403
|
+
try {
|
|
64404
|
+
this._hierarchicalData = arrayToTree(records, {
|
|
64405
|
+
id: idFieldName,
|
|
64406
|
+
parentId: parentIdFieldName
|
|
64407
|
+
});
|
|
64408
|
+
this.isDataFlat = false;
|
|
64409
|
+
this._parentIdConfigurationValid = true;
|
|
64410
|
+
}
|
|
64411
|
+
catch {
|
|
64412
|
+
this.isDataFlat = true;
|
|
64413
|
+
this._hierarchicalData = records.map((record, index) => ({
|
|
64414
|
+
clientRecord: { ...record },
|
|
64415
|
+
originalIndex: index
|
|
64416
|
+
}));
|
|
64417
|
+
this._parentIdConfigurationValid = false;
|
|
64418
|
+
}
|
|
64419
|
+
}
|
|
64420
|
+
else {
|
|
64421
|
+
this.isDataFlat = true;
|
|
64422
|
+
this._hierarchicalData = records.map((record, index) => ({
|
|
64423
|
+
clientRecord: { ...record },
|
|
64424
|
+
originalIndex: index
|
|
64425
|
+
}));
|
|
64426
|
+
this._parentIdConfigurationValid = true;
|
|
64427
|
+
}
|
|
64428
|
+
}
|
|
64429
|
+
get hierarchicalData() {
|
|
64430
|
+
return this._hierarchicalData;
|
|
64431
|
+
}
|
|
64432
|
+
get parentIdConfigurationValid() {
|
|
64433
|
+
return this._parentIdConfigurationValid;
|
|
64434
|
+
}
|
|
64435
|
+
getAllRecords(sort = false) {
|
|
64436
|
+
const allNodes = [];
|
|
64437
|
+
this.getAllNodes(this._hierarchicalData, allNodes);
|
|
64438
|
+
if (this.isDataFlat || !sort) {
|
|
64439
|
+
// If the data is flat, then it was never reordered to support hierarchy.
|
|
64440
|
+
// Therefore, there is no need to sort the nodes.
|
|
64441
|
+
return allNodes.map(x => x.clientRecord);
|
|
64442
|
+
}
|
|
64443
|
+
return allNodes
|
|
64444
|
+
.sort((a, b) => a.originalIndex - b.originalIndex)
|
|
64445
|
+
.map(x => x.clientRecord);
|
|
64446
|
+
}
|
|
64447
|
+
getAllNodes(parentNodes, allNodes) {
|
|
64448
|
+
for (const parentNode of parentNodes) {
|
|
64449
|
+
allNodes.push(parentNode);
|
|
64450
|
+
if (parentNode.subRows) {
|
|
64451
|
+
this.getAllNodes(parentNode.subRows, allNodes);
|
|
64452
|
+
}
|
|
64453
|
+
}
|
|
64454
|
+
}
|
|
64455
|
+
}
|
|
64456
|
+
|
|
64457
|
+
/**
|
|
64458
|
+
* Manages the expanded/collapsed state of rows in the table.
|
|
64459
|
+
*
|
|
64460
|
+
* We must track the expansion state separately from TanStack because:
|
|
64461
|
+
* 1. TanStack does not support having a different initial expansion state per row unless explicitly
|
|
64462
|
+
* specified for each row by ID. This causes problems in the nimble-table because we could have
|
|
64463
|
+
* a different initial expansion state for group rows, parent rows, and parent rows with lazy
|
|
64464
|
+
* loaded children.
|
|
64465
|
+
* 2. TanStack does not remove entries from its expanded state when those rows are no longer present
|
|
64466
|
+
* in the data. This is not ideal because the object maintaining the expansion state can grow unbounded.
|
|
64467
|
+
*/
|
|
64468
|
+
class ExpansionManager {
|
|
64469
|
+
constructor(tanStackTable) {
|
|
64470
|
+
this.tanStackTable = tanStackTable;
|
|
64471
|
+
// This field represents whether or not the expanded state of **all** rows is in the default expanded
|
|
64472
|
+
// state or not. Note that the default expanded state for a particular row type (group vs parent) can
|
|
64473
|
+
// potentially be different (e.g. expanded for groups and collapsed for parent rows).
|
|
64474
|
+
this.isInDefaultState = true;
|
|
64475
|
+
this.collapsedRows = new Set();
|
|
64476
|
+
}
|
|
64477
|
+
isRowExpanded(row) {
|
|
64478
|
+
if (!this.isRowExpandable(row)) {
|
|
64479
|
+
return false;
|
|
64480
|
+
}
|
|
64481
|
+
return this.isInDefaultState || !this.collapsedRows.has(row.id);
|
|
64482
|
+
}
|
|
64483
|
+
toggleRowExpansion(row) {
|
|
64484
|
+
if (!this.isRowExpandable(row)) {
|
|
64485
|
+
return;
|
|
64486
|
+
}
|
|
64487
|
+
const wasExpanded = this.isRowExpanded(row);
|
|
64488
|
+
this.isInDefaultState = false;
|
|
64489
|
+
if (wasExpanded) {
|
|
64490
|
+
this.collapsedRows.add(row.id);
|
|
64491
|
+
}
|
|
64492
|
+
else {
|
|
64493
|
+
this.collapsedRows.delete(row.id);
|
|
64494
|
+
}
|
|
64495
|
+
row.toggleExpanded();
|
|
64496
|
+
}
|
|
64497
|
+
collapseAll() {
|
|
64498
|
+
this.reset();
|
|
64499
|
+
this.isInDefaultState = false;
|
|
64500
|
+
const rows = this.tanStackTable.getRowModel().flatRows;
|
|
64501
|
+
for (const row of rows) {
|
|
64502
|
+
if (this.isRowExpandable(row)) {
|
|
64503
|
+
this.collapsedRows.add(row.id);
|
|
64504
|
+
}
|
|
64505
|
+
}
|
|
64506
|
+
this.tanStackTable.toggleAllRowsExpanded(false);
|
|
64507
|
+
}
|
|
64508
|
+
reset() {
|
|
64509
|
+
this.collapsedRows.clear();
|
|
64510
|
+
this.isInDefaultState = true;
|
|
64511
|
+
}
|
|
64512
|
+
processDataUpdate(rows) {
|
|
64513
|
+
if (this.isInDefaultState) {
|
|
64514
|
+
return;
|
|
64515
|
+
}
|
|
64516
|
+
const updatedCollapsedRows = new Set();
|
|
64517
|
+
for (const row of rows) {
|
|
64518
|
+
const rowId = row.id;
|
|
64519
|
+
if (this.collapsedRows.has(rowId)) {
|
|
64520
|
+
updatedCollapsedRows.add(rowId);
|
|
64521
|
+
}
|
|
64522
|
+
}
|
|
64523
|
+
this.collapsedRows = updatedCollapsedRows;
|
|
64524
|
+
}
|
|
64525
|
+
isRowExpandable(row) {
|
|
64526
|
+
return row.getIsGrouped() || row.subRows.length > 0;
|
|
64527
|
+
}
|
|
64528
|
+
}
|
|
64529
|
+
|
|
64268
64530
|
/**
|
|
64269
64531
|
* A nimble-styled table.
|
|
64270
64532
|
*/
|
|
@@ -64323,7 +64585,6 @@ img.ProseMirror-separator {
|
|
|
64323
64585
|
this.tableUpdateTracker = new TableUpdateTracker(this);
|
|
64324
64586
|
this.columnNotifiers = [];
|
|
64325
64587
|
this.isInitialized = false;
|
|
64326
|
-
this.collapsedRows = new Set();
|
|
64327
64588
|
// Programmatically updating the selection state of a checkbox fires the 'change' event.
|
|
64328
64589
|
// Therefore, selection change events that occur due to programmatically updating
|
|
64329
64590
|
// the selection checkbox 'checked' value should be ingored.
|
|
@@ -64343,17 +64604,7 @@ img.ProseMirror-separator {
|
|
|
64343
64604
|
}
|
|
64344
64605
|
};
|
|
64345
64606
|
this.getIsRowExpanded = (row) => {
|
|
64346
|
-
|
|
64347
|
-
return false;
|
|
64348
|
-
}
|
|
64349
|
-
const expandedState = this.table.options.state.expanded;
|
|
64350
|
-
if (expandedState === true) {
|
|
64351
|
-
return true;
|
|
64352
|
-
}
|
|
64353
|
-
if (Object.keys(expandedState ?? {}).includes(row.id)) {
|
|
64354
|
-
return expandedState[row.id];
|
|
64355
|
-
}
|
|
64356
|
-
return !this.collapsedRows.has(row.id);
|
|
64607
|
+
return this.expansionManager.isRowExpanded(row);
|
|
64357
64608
|
};
|
|
64358
64609
|
this.handleRowSelectionChange = (updaterOrValue) => {
|
|
64359
64610
|
const rowSelectionState = updaterOrValue instanceof Function
|
|
@@ -64385,6 +64636,7 @@ img.ProseMirror-separator {
|
|
|
64385
64636
|
getGroupedRowModel: getGroupedRowModel(),
|
|
64386
64637
|
getExpandedRowModel: getExpandedRowModel(),
|
|
64387
64638
|
getIsRowExpanded: this.getIsRowExpanded,
|
|
64639
|
+
getSubRows: r => r.subRows,
|
|
64388
64640
|
columns: [],
|
|
64389
64641
|
state: {
|
|
64390
64642
|
rowSelection: {},
|
|
@@ -64405,6 +64657,7 @@ img.ProseMirror-separator {
|
|
|
64405
64657
|
this.layoutManagerNotifier = Observable.getNotifier(this.layoutManager);
|
|
64406
64658
|
this.layoutManagerNotifier.subscribe(this, 'isColumnBeingSized');
|
|
64407
64659
|
this.selectionManager = new InteractiveSelectionManager(this.table, this.selectionMode);
|
|
64660
|
+
this.expansionManager = new ExpansionManager(this.table);
|
|
64408
64661
|
}
|
|
64409
64662
|
get validity() {
|
|
64410
64663
|
return this.tableValidator.getValidity();
|
|
@@ -64418,36 +64671,12 @@ img.ProseMirror-separator {
|
|
|
64418
64671
|
}
|
|
64419
64672
|
async setData(newData) {
|
|
64420
64673
|
await this.processPendingUpdates();
|
|
64421
|
-
const
|
|
64422
|
-
|
|
64423
|
-
});
|
|
64424
|
-
const tanStackUpdates = {
|
|
64425
|
-
data
|
|
64426
|
-
};
|
|
64427
|
-
this.validateWithData(data);
|
|
64428
|
-
if (this.tableValidator.areRecordIdsValid()) {
|
|
64429
|
-
// Update the selection state to remove previously selected records that no longer exist in the
|
|
64430
|
-
// data set while maintaining the selection state of records that still exist in the data set.
|
|
64431
|
-
const previousSelection = await this.getSelectedRecordIds();
|
|
64432
|
-
tanStackUpdates.state = {
|
|
64433
|
-
rowSelection: this.calculateTanStackSelectionState(previousSelection)
|
|
64434
|
-
};
|
|
64435
|
-
}
|
|
64436
|
-
this.updateTableOptions(tanStackUpdates);
|
|
64674
|
+
const tanstackUpdates = this.calculateTanStackData(newData);
|
|
64675
|
+
this.updateTableOptions(tanstackUpdates);
|
|
64437
64676
|
}
|
|
64438
64677
|
async getSelectedRecordIds() {
|
|
64439
64678
|
await this.processPendingUpdates();
|
|
64440
|
-
|
|
64441
|
-
if (!tanStackSelectionState) {
|
|
64442
|
-
return [];
|
|
64443
|
-
}
|
|
64444
|
-
const selectedRecordIds = [];
|
|
64445
|
-
Object.entries(tanStackSelectionState).forEach(([recordId, isSelected]) => {
|
|
64446
|
-
if (isSelected) {
|
|
64447
|
-
selectedRecordIds.push(recordId);
|
|
64448
|
-
}
|
|
64449
|
-
});
|
|
64450
|
-
return selectedRecordIds;
|
|
64679
|
+
return this.selectionManager.getCurrentSelectedRecordIds();
|
|
64451
64680
|
}
|
|
64452
64681
|
async setSelectedRecordIds(recordIds) {
|
|
64453
64682
|
await this.processPendingUpdates();
|
|
@@ -64542,13 +64771,8 @@ img.ProseMirror-separator {
|
|
|
64542
64771
|
void this.handleRowActionMenuToggleEvent(event);
|
|
64543
64772
|
}
|
|
64544
64773
|
/** @internal */
|
|
64545
|
-
|
|
64546
|
-
this.
|
|
64547
|
-
this.table
|
|
64548
|
-
.getRowModel()
|
|
64549
|
-
.flatRows.filter(row => row.getIsGrouped())
|
|
64550
|
-
.forEach(row => this.collapsedRows.add(row.id));
|
|
64551
|
-
this.table.toggleAllRowsExpanded(false);
|
|
64774
|
+
handleCollapseAllRows() {
|
|
64775
|
+
this.expansionManager.collapseAll();
|
|
64552
64776
|
}
|
|
64553
64777
|
/** @internal */
|
|
64554
64778
|
onRightDividerMouseDown(event, columnIndex) {
|
|
@@ -64564,9 +64788,13 @@ img.ProseMirror-separator {
|
|
|
64564
64788
|
}
|
|
64565
64789
|
/** @internal */
|
|
64566
64790
|
handleGroupRowExpanded(rowIndex, event) {
|
|
64567
|
-
this.
|
|
64791
|
+
this.toggleRowExpanded(rowIndex);
|
|
64568
64792
|
event.stopPropagation();
|
|
64569
64793
|
}
|
|
64794
|
+
/** @internal */
|
|
64795
|
+
handleRowExpanded(rowIndex) {
|
|
64796
|
+
this.toggleRowExpanded(rowIndex);
|
|
64797
|
+
}
|
|
64570
64798
|
/**
|
|
64571
64799
|
* @internal
|
|
64572
64800
|
*/
|
|
@@ -64624,9 +64852,6 @@ img.ProseMirror-separator {
|
|
|
64624
64852
|
this.rowGridColumns = this.layoutManager.getGridTemplateColumns();
|
|
64625
64853
|
this.visibleColumns = this.columns.filter(column => !column.columnHidden);
|
|
64626
64854
|
}
|
|
64627
|
-
if (this.tableUpdateTracker.updateGroupRows) {
|
|
64628
|
-
this.showCollapseAll = this.getColumnsParticipatingInGrouping().length > 0;
|
|
64629
|
-
}
|
|
64630
64855
|
}
|
|
64631
64856
|
get ariaMultiSelectable() {
|
|
64632
64857
|
switch (this.selectionMode) {
|
|
@@ -64644,6 +64869,31 @@ img.ProseMirror-separator {
|
|
|
64644
64869
|
getHeaderContainerElements() {
|
|
64645
64870
|
return this.columnHeadersContainer.querySelectorAll('.header-container');
|
|
64646
64871
|
}
|
|
64872
|
+
/**
|
|
64873
|
+
* @internal
|
|
64874
|
+
*/
|
|
64875
|
+
calculateTanStackData(data) {
|
|
64876
|
+
this.dataHierarchyManager = new DataHierarchyManager(data, this.idFieldName, this.parentIdFieldName);
|
|
64877
|
+
const tableNodes = this.dataHierarchyManager.hierarchicalData;
|
|
64878
|
+
this.tableValidator.setParentIdConfigurationValidity(this.dataHierarchyManager.parentIdConfigurationValid);
|
|
64879
|
+
const tanStackUpdates = {
|
|
64880
|
+
data: tableNodes
|
|
64881
|
+
};
|
|
64882
|
+
this.validateWithData(data);
|
|
64883
|
+
if (this.tableValidator.areRecordIdsValid()) {
|
|
64884
|
+
// Update the selection state to remove previously selected records that no longer exist in the
|
|
64885
|
+
// data set while maintaining the selection state of records that still exist in the data set.
|
|
64886
|
+
const previousSelection = this.selectionManager.getCurrentSelectedRecordIds();
|
|
64887
|
+
tanStackUpdates.state = {
|
|
64888
|
+
rowSelection: this.calculateTanStackSelectionState(previousSelection),
|
|
64889
|
+
// Reset the TanStack expanded state to "true" to clear TanStack's cache of expanded state that may include
|
|
64890
|
+
// rows that no longer exist in the table. The nimble table's expansion manager tracks the expanded
|
|
64891
|
+
// state of each row, so no state is lost by resetting TanStack.
|
|
64892
|
+
expanded: true
|
|
64893
|
+
};
|
|
64894
|
+
}
|
|
64895
|
+
return tanStackUpdates;
|
|
64896
|
+
}
|
|
64647
64897
|
selectionModeChanged(_prev, _next) {
|
|
64648
64898
|
if (!this.$fastController.isConnected) {
|
|
64649
64899
|
return;
|
|
@@ -64656,6 +64906,12 @@ img.ProseMirror-separator {
|
|
|
64656
64906
|
}
|
|
64657
64907
|
this.tableUpdateTracker.trackIdFieldNameChanged();
|
|
64658
64908
|
}
|
|
64909
|
+
parentIdFieldNameChanged(_prev, _next) {
|
|
64910
|
+
if (!this.$fastController.isConnected) {
|
|
64911
|
+
return;
|
|
64912
|
+
}
|
|
64913
|
+
this.tableUpdateTracker.trackParentIdFieldNameChanged();
|
|
64914
|
+
}
|
|
64659
64915
|
columnsChanged(_prev, _next) {
|
|
64660
64916
|
if (!this.$fastController.isConnected) {
|
|
64661
64917
|
return;
|
|
@@ -64760,14 +65016,30 @@ img.ProseMirror-separator {
|
|
|
64760
65016
|
updatedOptions.state.rowSelection = {};
|
|
64761
65017
|
this.selectionManager.handleSelectionModeChanged(this.selectionMode);
|
|
64762
65018
|
}
|
|
64763
|
-
if (this.
|
|
64764
|
-
|
|
64765
|
-
|
|
65019
|
+
if (this.dataHierarchyManager
|
|
65020
|
+
&& this.tableUpdateTracker.requiresTanStackDataReset) {
|
|
65021
|
+
if (!this.parentIdFieldName
|
|
65022
|
+
&& !this.tableUpdateTracker.updateRowParentIds) {
|
|
65023
|
+
// Perform a shallow copy of the data to trigger tanstack to regenerate the row models and columns.
|
|
65024
|
+
updatedOptions.data = [...this.table.options.data];
|
|
65025
|
+
}
|
|
65026
|
+
else {
|
|
65027
|
+
const orderedRecords = this.dataHierarchyManager.getAllRecords(true);
|
|
65028
|
+
const tanstackUpdates = this.calculateTanStackData(orderedRecords);
|
|
65029
|
+
if (tanstackUpdates.state) {
|
|
65030
|
+
updatedOptions.state.rowSelection = tanstackUpdates.state.rowSelection;
|
|
65031
|
+
}
|
|
65032
|
+
updatedOptions.data = tanstackUpdates.data;
|
|
65033
|
+
}
|
|
64766
65034
|
}
|
|
64767
65035
|
if (this.tableUpdateTracker.updateGroupRows) {
|
|
64768
65036
|
updatedOptions.state.grouping = this.calculateTanStackGroupingState();
|
|
65037
|
+
}
|
|
65038
|
+
if (this.tableUpdateTracker.updateRowIds
|
|
65039
|
+
|| this.tableUpdateTracker.updateRowParentIds
|
|
65040
|
+
|| this.tableUpdateTracker.updateGroupRows) {
|
|
64769
65041
|
updatedOptions.state.expanded = true;
|
|
64770
|
-
this.
|
|
65042
|
+
this.expansionManager.reset();
|
|
64771
65043
|
}
|
|
64772
65044
|
this.updateTableOptions(updatedOptions);
|
|
64773
65045
|
}
|
|
@@ -64781,12 +65053,14 @@ img.ProseMirror-separator {
|
|
|
64781
65053
|
this.actionMenuSlots = Array.from(slots);
|
|
64782
65054
|
}
|
|
64783
65055
|
validate() {
|
|
64784
|
-
this.tableValidator.
|
|
65056
|
+
this.tableValidator.validateIdFieldConfiguration(this.selectionMode, this.idFieldName, this.parentIdFieldName);
|
|
64785
65057
|
this.tableValidator.validateColumnIds(this.columns.map(x => x.columnId));
|
|
64786
65058
|
this.tableValidator.validateColumnSortIndices(this.getColumnsParticipatingInSorting().map(x => x.columnInternals.currentSortIndex));
|
|
64787
65059
|
this.tableValidator.validateColumnGroupIndices(this.getColumnsParticipatingInGrouping().map(x => x.columnInternals.groupIndex));
|
|
64788
65060
|
this.tableValidator.validateColumnConfigurations(this.columns);
|
|
64789
|
-
|
|
65061
|
+
if (this.dataHierarchyManager) {
|
|
65062
|
+
this.validateWithData(this.dataHierarchyManager.getAllRecords());
|
|
65063
|
+
}
|
|
64790
65064
|
}
|
|
64791
65065
|
validateWithData(data) {
|
|
64792
65066
|
this.tableValidator.validateRecordIds(data, this.idFieldName);
|
|
@@ -64829,27 +65103,41 @@ img.ProseMirror-separator {
|
|
|
64829
65103
|
}
|
|
64830
65104
|
refreshRows() {
|
|
64831
65105
|
this.selectionState = this.getTableSelectionState();
|
|
65106
|
+
let hasDataHierarchy = false;
|
|
64832
65107
|
const rows = this.table.getRowModel().rows;
|
|
64833
65108
|
this.tableData = rows.map(row => {
|
|
64834
|
-
const
|
|
65109
|
+
const isGroupRow = row.getIsGrouped();
|
|
65110
|
+
const hasParentRow = isGroupRow ? false : row.getParentRow();
|
|
65111
|
+
// we check row.original.subRows below because row.subRows is populated for group rows
|
|
65112
|
+
// which we don't want to include
|
|
65113
|
+
const isParent = row.original.subRows !== undefined
|
|
65114
|
+
&& row.original.subRows.length > 0;
|
|
65115
|
+
const isChildOfGroupRowWithNoHierarchy = !isGroupRow
|
|
65116
|
+
&& !isParent
|
|
65117
|
+
&& !hasParentRow
|
|
65118
|
+
&& row.depth > 0
|
|
65119
|
+
&& !this.parentIdFieldName;
|
|
64835
65120
|
const rowState = {
|
|
64836
65121
|
record: row.original.clientRecord,
|
|
64837
65122
|
id: row.id,
|
|
64838
65123
|
selectionState: this.getRowSelectionState(row),
|
|
64839
|
-
|
|
65124
|
+
isGroupRow,
|
|
64840
65125
|
isExpanded: row.getIsExpanded(),
|
|
64841
|
-
groupRowValue:
|
|
65126
|
+
groupRowValue: isGroupRow
|
|
64842
65127
|
? row.getValue(row.groupingColumnId)
|
|
64843
65128
|
: undefined,
|
|
64844
|
-
nestingLevel:
|
|
64845
|
-
|
|
64846
|
-
.
|
|
64847
|
-
|
|
64848
|
-
|
|
65129
|
+
nestingLevel: isChildOfGroupRowWithNoHierarchy
|
|
65130
|
+
? row.depth - 1
|
|
65131
|
+
: row.depth,
|
|
65132
|
+
isParentRow: isParent,
|
|
65133
|
+
immediateChildCount: row.subRows.length,
|
|
64849
65134
|
groupColumn: this.getGroupRowColumn(row)
|
|
64850
65135
|
};
|
|
65136
|
+
hasDataHierarchy = hasDataHierarchy || isParent;
|
|
64851
65137
|
return rowState;
|
|
64852
65138
|
});
|
|
65139
|
+
this.showCollapseAll = hasDataHierarchy
|
|
65140
|
+
|| this.getColumnsParticipatingInGrouping().length > 0;
|
|
64853
65141
|
this.virtualizer.dataChanged();
|
|
64854
65142
|
}
|
|
64855
65143
|
getTableSelectionState() {
|
|
@@ -64870,10 +65158,10 @@ img.ProseMirror-separator {
|
|
|
64870
65158
|
: TableRowSelectionState.notSelected;
|
|
64871
65159
|
}
|
|
64872
65160
|
getGroupedRowSelectionState(groupedRow) {
|
|
64873
|
-
const
|
|
65161
|
+
const leafRows = groupedRow.getLeafRows() ?? [];
|
|
64874
65162
|
let foundSelectedRow = false;
|
|
64875
65163
|
let foundNotSelectedRow = false;
|
|
64876
|
-
for (const row of
|
|
65164
|
+
for (const row of leafRows) {
|
|
64877
65165
|
if (row.getIsGrouped()) {
|
|
64878
65166
|
const subGroupRowSelectionState = this.getGroupedRowSelectionState(row);
|
|
64879
65167
|
switch (subGroupRowSelectionState) {
|
|
@@ -64915,19 +65203,16 @@ img.ProseMirror-separator {
|
|
|
64915
65203
|
state: { ...this.options.state, ...updatedOptions.state }
|
|
64916
65204
|
};
|
|
64917
65205
|
this.table.setOptions(this.options);
|
|
65206
|
+
if (updatedOptions.data) {
|
|
65207
|
+
const rows = this.table.getRowModel().flatRows;
|
|
65208
|
+
this.expansionManager.processDataUpdate(rows);
|
|
65209
|
+
}
|
|
64918
65210
|
this.refreshRows();
|
|
64919
65211
|
}
|
|
64920
|
-
|
|
64921
|
-
const
|
|
64922
|
-
const
|
|
64923
|
-
|
|
64924
|
-
if (wasExpanded) {
|
|
64925
|
-
this.collapsedRows.add(row.id);
|
|
64926
|
-
}
|
|
64927
|
-
else {
|
|
64928
|
-
this.collapsedRows.delete(row.id);
|
|
64929
|
-
}
|
|
64930
|
-
row.toggleExpanded();
|
|
65212
|
+
toggleRowExpanded(rowIndex) {
|
|
65213
|
+
const rows = this.table.getRowModel().rows;
|
|
65214
|
+
const row = rows[rowIndex];
|
|
65215
|
+
this.expansionManager.toggleRowExpansion(row);
|
|
64931
65216
|
}
|
|
64932
65217
|
calculateTanStackSortState() {
|
|
64933
65218
|
const sortedColumns = this.getColumnsParticipatingInSorting().sort((x, y) => x.columnInternals.currentSortIndex
|
|
@@ -64987,6 +65272,9 @@ img.ProseMirror-separator {
|
|
|
64987
65272
|
__decorate$1([
|
|
64988
65273
|
attr({ attribute: 'id-field-name' })
|
|
64989
65274
|
], Table.prototype, "idFieldName", void 0);
|
|
65275
|
+
__decorate$1([
|
|
65276
|
+
attr({ attribute: 'parent-id-field-name' })
|
|
65277
|
+
], Table.prototype, "parentIdFieldName", void 0);
|
|
64990
65278
|
__decorate$1([
|
|
64991
65279
|
attr({ attribute: 'selection-mode' })
|
|
64992
65280
|
], Table.prototype, "selectionMode", void 0);
|
|
@@ -66460,7 +66748,7 @@ img.ProseMirror-separator {
|
|
|
66460
66748
|
* A formatter for units that can be formatted/translated by Intl.NumberFormat
|
|
66461
66749
|
*/
|
|
66462
66750
|
class IntlNumberFormatScaledUnitFormat extends ScaledUnitFormat {
|
|
66463
|
-
constructor(scaledUnitFormatFactoryOptions, unitSpecificIntlNumberFormatOptions
|
|
66751
|
+
constructor(scaledUnitFormatFactoryOptions, unitSpecificIntlNumberFormatOptions) {
|
|
66464
66752
|
super(scaledUnitFormatFactoryOptions);
|
|
66465
66753
|
this.formatter = new Intl.NumberFormat(this.locale, {
|
|
66466
66754
|
...unitSpecificIntlNumberFormatOptions,
|
|
@@ -66468,7 +66756,7 @@ img.ProseMirror-separator {
|
|
|
66468
66756
|
...this.intlNumberFormatOptions
|
|
66469
66757
|
});
|
|
66470
66758
|
}
|
|
66471
|
-
static createFactory(unitSpecificIntlNumberFormatOptions
|
|
66759
|
+
static createFactory(unitSpecificIntlNumberFormatOptions) {
|
|
66472
66760
|
return (scaledUnitFormatFactoryOptions) => new IntlNumberFormatScaledUnitFormat(scaledUnitFormatFactoryOptions, unitSpecificIntlNumberFormatOptions);
|
|
66473
66761
|
}
|
|
66474
66762
|
format(value) {
|
|
@@ -66544,7 +66832,7 @@ img.ProseMirror-separator {
|
|
|
66544
66832
|
class PassthroughUnitScale extends UnitScale {
|
|
66545
66833
|
constructor() {
|
|
66546
66834
|
super([
|
|
66547
|
-
new ScaledUnit(10 ** 0, IntlNumberFormatScaledUnitFormat.createFactory())
|
|
66835
|
+
new ScaledUnit(10 ** 0, IntlNumberFormatScaledUnitFormat.createFactory({}))
|
|
66548
66836
|
]);
|
|
66549
66837
|
}
|
|
66550
66838
|
}
|
|
@@ -68527,25 +68815,38 @@ img.ProseMirror-separator {
|
|
|
68527
68815
|
|
|
68528
68816
|
const template$1 = html `<template slot="unit"></template>`;
|
|
68529
68817
|
|
|
68818
|
+
/**
|
|
68819
|
+
* Representations of a unit in a particular language
|
|
68820
|
+
*/
|
|
68821
|
+
class UnitTranslation {
|
|
68822
|
+
constructor(singular, plural, symbol) {
|
|
68823
|
+
this.singular = singular;
|
|
68824
|
+
this.plural = plural;
|
|
68825
|
+
this.symbol = symbol;
|
|
68826
|
+
}
|
|
68827
|
+
}
|
|
68530
68828
|
/**
|
|
68531
68829
|
* A formatter for units that are not supported by Intl.NumberFormat
|
|
68532
68830
|
*/
|
|
68533
68831
|
class ManuallyTranslatedScaledUnitFormat extends ScaledUnitFormat {
|
|
68534
|
-
constructor(scaledUnitFormatFactoryOptions, unitTranslations,
|
|
68832
|
+
constructor(scaledUnitFormatFactoryOptions, { unitTranslations, scaledPrefixText }) {
|
|
68535
68833
|
super(scaledUnitFormatFactoryOptions);
|
|
68536
|
-
|
|
68537
|
-
|
|
68834
|
+
if (!unitTranslations.get('en')) {
|
|
68835
|
+
throw new Error('English translations must exist with locale string "en"');
|
|
68836
|
+
}
|
|
68538
68837
|
this.pluralRules = new Intl.PluralRules(this.locale);
|
|
68539
68838
|
this.formatter = new Intl.NumberFormat(this.locale, this.intlNumberFormatOptions);
|
|
68540
|
-
this.unitTranslation = this.getTranslationToUse(this.locale);
|
|
68839
|
+
this.unitTranslation = this.getTranslationToUse(unitTranslations, this.locale);
|
|
68840
|
+
this.scaledPrefixText = scaledPrefixText;
|
|
68541
68841
|
}
|
|
68542
|
-
static createFactory(
|
|
68543
|
-
return (scaledUnitFormatFactoryOptions) => new ManuallyTranslatedScaledUnitFormat(scaledUnitFormatFactoryOptions,
|
|
68842
|
+
static createFactory(manuallyTranslatedScaledUnitFormatOptions) {
|
|
68843
|
+
return (scaledUnitFormatFactoryOptions) => new ManuallyTranslatedScaledUnitFormat(scaledUnitFormatFactoryOptions, manuallyTranslatedScaledUnitFormatOptions);
|
|
68544
68844
|
}
|
|
68545
68845
|
format(value) {
|
|
68546
68846
|
const formatted = this.formatter.format(value);
|
|
68547
|
-
|
|
68548
|
-
|
|
68847
|
+
// For non-base units (which are a scaled prefix text of empty string)
|
|
68848
|
+
if (this.scaledPrefixText !== '') {
|
|
68849
|
+
return `${formatted} ${this.scaledPrefixText}${this.unitTranslation.symbol}`;
|
|
68549
68850
|
}
|
|
68550
68851
|
// Some languages have more than two forms (singular/plural) of cardinal
|
|
68551
68852
|
// numbers, but we are treating anything other than the 'one' form as plural.
|
|
@@ -68562,123 +68863,65 @@ img.ProseMirror-separator {
|
|
|
68562
68863
|
: this.unitTranslation.plural;
|
|
68563
68864
|
return `${formatted} ${unitLabel}`;
|
|
68564
68865
|
}
|
|
68565
|
-
getTranslationToUse(locale) {
|
|
68866
|
+
getTranslationToUse(unitTranslations, locale) {
|
|
68566
68867
|
const localeObject = new Intl.Locale(locale ?? 'en');
|
|
68567
68868
|
const language = localeObject.language;
|
|
68568
68869
|
const region = localeObject.region;
|
|
68569
68870
|
const regionSpecificMatchedTranslations = region
|
|
68570
|
-
?
|
|
68571
|
-
:
|
|
68871
|
+
? unitTranslations.get(`${language}-${region}`)
|
|
68872
|
+
: undefined;
|
|
68572
68873
|
return (regionSpecificMatchedTranslations
|
|
68573
|
-
??
|
|
68574
|
-
??
|
|
68575
|
-
}
|
|
68576
|
-
}
|
|
68577
|
-
|
|
68578
|
-
/**
|
|
68579
|
-
* A unit scale that is not supported by Intl.NumberFormat and has manually provided translation strings
|
|
68580
|
-
*/
|
|
68581
|
-
class ManuallyTranslatedUnitScale extends UnitScale {
|
|
68582
|
-
constructor(unitTranslations, supportedUnitPrefixes) {
|
|
68583
|
-
super(ManuallyTranslatedUnitScale.createSupportedScaledUnits(unitTranslations, supportedUnitPrefixes));
|
|
68584
|
-
}
|
|
68585
|
-
static createSupportedScaledUnits(unitTranslations, supportedUnitPrefixes) {
|
|
68586
|
-
if (!unitTranslations.get('en')) {
|
|
68587
|
-
throw new Error('English translations must exist');
|
|
68588
|
-
}
|
|
68589
|
-
const supportedUnits = supportedUnitPrefixes.map(unitPrefix => new ScaledUnit(unitPrefix.scaleFactor, ManuallyTranslatedScaledUnitFormat.createFactory(unitTranslations, unitPrefix)));
|
|
68590
|
-
return supportedUnits;
|
|
68591
|
-
}
|
|
68592
|
-
}
|
|
68593
|
-
|
|
68594
|
-
/**
|
|
68595
|
-
* A prefix that represents a scaling factor when applied to a base unit.
|
|
68596
|
-
* A base unit is represented as scale factor 1 and empty text.
|
|
68597
|
-
*/
|
|
68598
|
-
class UnitPrefix {
|
|
68599
|
-
constructor(scaleFactor, text) {
|
|
68600
|
-
this.scaleFactor = scaleFactor;
|
|
68601
|
-
this.text = text;
|
|
68602
|
-
if (scaleFactor === 1 && text !== '') {
|
|
68603
|
-
throw new Error('Base scale factor of 1 has unused text and should be empty string');
|
|
68604
|
-
}
|
|
68605
|
-
}
|
|
68606
|
-
isBase() {
|
|
68607
|
-
return this.scaleFactor === 1;
|
|
68608
|
-
}
|
|
68609
|
-
}
|
|
68610
|
-
|
|
68611
|
-
/**
|
|
68612
|
-
* Representations of a base unit in a particular language
|
|
68613
|
-
*/
|
|
68614
|
-
class UnitTranslation {
|
|
68615
|
-
constructor(singular, plural, symbol) {
|
|
68616
|
-
this.singular = singular;
|
|
68617
|
-
this.plural = plural;
|
|
68618
|
-
this.symbol = symbol;
|
|
68874
|
+
?? unitTranslations.get(language)
|
|
68875
|
+
?? unitTranslations.get('en'));
|
|
68619
68876
|
}
|
|
68620
68877
|
}
|
|
68621
68878
|
|
|
68879
|
+
const unitTranslations$1 = new Map([
|
|
68880
|
+
['en', new UnitTranslation('byte', 'bytes', 'B')],
|
|
68881
|
+
['fr', new UnitTranslation('octet', 'octets', 'o')],
|
|
68882
|
+
['de', new UnitTranslation('Byte', 'Byte', 'B')],
|
|
68883
|
+
['ja', new UnitTranslation('バイト', 'バイト', 'B')],
|
|
68884
|
+
['zh', new UnitTranslation('字节', '字节', 'B')]
|
|
68885
|
+
]);
|
|
68886
|
+
const byte1024Prefixes = [
|
|
68887
|
+
[1024 ** 0, ''],
|
|
68888
|
+
[1024 ** 1, 'Ki'],
|
|
68889
|
+
[1024 ** 2, 'Mi'],
|
|
68890
|
+
[1024 ** 3, 'Gi'],
|
|
68891
|
+
[1024 ** 4, 'Ti'],
|
|
68892
|
+
[1024 ** 5, 'Pi']
|
|
68893
|
+
];
|
|
68622
68894
|
/**
|
|
68623
68895
|
* Byte units (1024-based)
|
|
68624
68896
|
*/
|
|
68625
|
-
class Byte1024UnitScale extends
|
|
68897
|
+
class Byte1024UnitScale extends UnitScale {
|
|
68626
68898
|
constructor() {
|
|
68627
|
-
super(new
|
|
68628
|
-
|
|
68629
|
-
|
|
68630
|
-
|
|
68631
|
-
['ja', new UnitTranslation('バイト', 'バイト', 'B')],
|
|
68632
|
-
['zh', new UnitTranslation('字节', '字节', 'B')]
|
|
68633
|
-
]), [
|
|
68634
|
-
new UnitPrefix(1024 ** 0, ''),
|
|
68635
|
-
new UnitPrefix(1024 ** 1, 'Ki'),
|
|
68636
|
-
new UnitPrefix(1024 ** 2, 'Mi'),
|
|
68637
|
-
new UnitPrefix(1024 ** 3, 'Gi'),
|
|
68638
|
-
new UnitPrefix(1024 ** 4, 'Ti'),
|
|
68639
|
-
new UnitPrefix(1024 ** 5, 'Pi')
|
|
68640
|
-
]);
|
|
68899
|
+
super(byte1024Prefixes.map(([scaleFactor, scaledPrefixText]) => new ScaledUnit(scaleFactor, ManuallyTranslatedScaledUnitFormat.createFactory({
|
|
68900
|
+
unitTranslations: unitTranslations$1,
|
|
68901
|
+
scaledPrefixText
|
|
68902
|
+
}))));
|
|
68641
68903
|
}
|
|
68642
68904
|
}
|
|
68643
68905
|
const byte1024UnitScale = new Byte1024UnitScale();
|
|
68644
68906
|
|
|
68907
|
+
const byteUnitScaleOptions = [
|
|
68908
|
+
[1000 ** 0, 'byte', 'long'],
|
|
68909
|
+
[1000 ** 1, 'kilobyte', 'short'],
|
|
68910
|
+
[1000 ** 2, 'megabyte', 'short'],
|
|
68911
|
+
[1000 ** 3, 'gigabyte', 'short'],
|
|
68912
|
+
[1000 ** 4, 'terabyte', 'short'],
|
|
68913
|
+
[1000 ** 5, 'petabyte', 'short']
|
|
68914
|
+
];
|
|
68645
68915
|
/**
|
|
68646
68916
|
* Byte units (1000-based)
|
|
68647
68917
|
*/
|
|
68648
68918
|
class ByteUnitScale extends UnitScale {
|
|
68649
68919
|
constructor() {
|
|
68650
|
-
super([
|
|
68651
|
-
|
|
68652
|
-
|
|
68653
|
-
|
|
68654
|
-
|
|
68655
|
-
})),
|
|
68656
|
-
new ScaledUnit(10 ** 3, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
68657
|
-
style: 'unit',
|
|
68658
|
-
unit: 'kilobyte',
|
|
68659
|
-
unitDisplay: 'short'
|
|
68660
|
-
})),
|
|
68661
|
-
new ScaledUnit(10 ** 6, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
68662
|
-
style: 'unit',
|
|
68663
|
-
unit: 'megabyte',
|
|
68664
|
-
unitDisplay: 'short'
|
|
68665
|
-
})),
|
|
68666
|
-
new ScaledUnit(10 ** 9, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
68667
|
-
style: 'unit',
|
|
68668
|
-
unit: 'gigabyte',
|
|
68669
|
-
unitDisplay: 'short'
|
|
68670
|
-
})),
|
|
68671
|
-
new ScaledUnit(10 ** 12, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
68672
|
-
style: 'unit',
|
|
68673
|
-
unit: 'terabyte',
|
|
68674
|
-
unitDisplay: 'short'
|
|
68675
|
-
})),
|
|
68676
|
-
new ScaledUnit(10 ** 15, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
68677
|
-
style: 'unit',
|
|
68678
|
-
unit: 'petabyte',
|
|
68679
|
-
unitDisplay: 'short'
|
|
68680
|
-
}))
|
|
68681
|
-
]);
|
|
68920
|
+
super(byteUnitScaleOptions.map(([scaleFactor, unit, unitDisplay]) => new ScaledUnit(scaleFactor, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
68921
|
+
style: 'unit',
|
|
68922
|
+
unit,
|
|
68923
|
+
unitDisplay
|
|
68924
|
+
}))));
|
|
68682
68925
|
}
|
|
68683
68926
|
}
|
|
68684
68927
|
const byteUnitScale = new ByteUnitScale();
|
|
@@ -68711,38 +68954,39 @@ img.ProseMirror-separator {
|
|
|
68711
68954
|
});
|
|
68712
68955
|
DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleUnitByte());
|
|
68713
68956
|
|
|
68714
|
-
|
|
68715
|
-
|
|
68716
|
-
|
|
68717
|
-
|
|
68718
|
-
|
|
68719
|
-
|
|
68720
|
-
|
|
68721
|
-
|
|
68722
|
-
|
|
68723
|
-
|
|
68724
|
-
|
|
68725
|
-
|
|
68726
|
-
|
|
68727
|
-
|
|
68728
|
-
|
|
68729
|
-
new UnitPrefix(10 ** 12, 'T'),
|
|
68730
|
-
new UnitPrefix(10 ** 15, 'P'),
|
|
68731
|
-
new UnitPrefix(10 ** 18, 'E')
|
|
68957
|
+
const metricPrefixes = [
|
|
68958
|
+
[10 ** -15, 'f'],
|
|
68959
|
+
[10 ** -12, 'p'],
|
|
68960
|
+
[10 ** -9, 'n'],
|
|
68961
|
+
[10 ** -6, 'μ'],
|
|
68962
|
+
[10 ** -3, 'm'],
|
|
68963
|
+
[10 ** -2, 'c'],
|
|
68964
|
+
[10 ** -1, 'd'],
|
|
68965
|
+
[10 ** 0, ''],
|
|
68966
|
+
[10 ** 3, 'k'],
|
|
68967
|
+
[10 ** 6, 'M'],
|
|
68968
|
+
[10 ** 9, 'G'],
|
|
68969
|
+
[10 ** 12, 'T'],
|
|
68970
|
+
[10 ** 15, 'P'],
|
|
68971
|
+
[10 ** 18, 'E']
|
|
68732
68972
|
];
|
|
68733
68973
|
|
|
68974
|
+
const unitTranslations = new Map([
|
|
68975
|
+
['en', new UnitTranslation('volt', 'volts', 'V')],
|
|
68976
|
+
['fr', new UnitTranslation('volt', 'volts', 'V')],
|
|
68977
|
+
['de', new UnitTranslation('Volt', 'Volt', 'V')],
|
|
68978
|
+
['ja', new UnitTranslation('ボルト', 'ボルト', 'V')],
|
|
68979
|
+
['zh', new UnitTranslation('伏特', '伏特', 'V')]
|
|
68980
|
+
]);
|
|
68734
68981
|
/**
|
|
68735
68982
|
* Voltage unit scale
|
|
68736
68983
|
*/
|
|
68737
|
-
class VoltUnitScale extends
|
|
68984
|
+
class VoltUnitScale extends UnitScale {
|
|
68738
68985
|
constructor() {
|
|
68739
|
-
super(new
|
|
68740
|
-
|
|
68741
|
-
|
|
68742
|
-
|
|
68743
|
-
['ja', new UnitTranslation('ボルト', 'ボルト', 'V')],
|
|
68744
|
-
['zh', new UnitTranslation('伏特', '伏特', 'V')]
|
|
68745
|
-
]), unitPrefixesMetric);
|
|
68986
|
+
super(metricPrefixes.map(([scaleFactor, scaledPrefixText]) => new ScaledUnit(scaleFactor, ManuallyTranslatedScaledUnitFormat.createFactory({
|
|
68987
|
+
unitTranslations,
|
|
68988
|
+
scaledPrefixText
|
|
68989
|
+
}))));
|
|
68746
68990
|
}
|
|
68747
68991
|
}
|
|
68748
68992
|
const voltUnitScale = new VoltUnitScale();
|