beautiful-grid 1.0.11 → 1.0.13

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.
@@ -0,0 +1,174 @@
1
+ import { getCellValueByRowKey } from './getCellValue';
2
+ function flatFallback(data, diagnostics) {
3
+ const sourceIndexByVisibleIndex = data.map((_, index) => index);
4
+ return {
5
+ valid: false,
6
+ data,
7
+ sourceIndexByVisibleIndex,
8
+ visibleIndexBySourceIndex: new Map(sourceIndexByVisibleIndex.map(index => [index, index])),
9
+ metaByRowKey: new Map(),
10
+ metaBySourceIndex: new Map(),
11
+ diagnostics: Array.from(new Set(diagnostics)),
12
+ };
13
+ }
14
+ /** Projects flat parent-key data into visible pre-order rows without mutating the input. */
15
+ export function projectTreeData(params) {
16
+ const { data, rowKey, parentRowKey, expandedRowKeys, includedSourceIndexes, orderedSourceIndexes } = params;
17
+ if (data.length === 0) {
18
+ return {
19
+ valid: true,
20
+ data: [],
21
+ sourceIndexByVisibleIndex: [],
22
+ visibleIndexBySourceIndex: new Map(),
23
+ metaByRowKey: new Map(),
24
+ metaBySourceIndex: new Map(),
25
+ diagnostics: [],
26
+ };
27
+ }
28
+ const diagnostics = [];
29
+ const keys = new Array(data.length);
30
+ const indexByKey = new Map();
31
+ data.forEach((item, sourceIndex) => {
32
+ const key = getCellValueByRowKey(rowKey, item.values);
33
+ if (key === undefined || key === null) {
34
+ diagnostics.push('missingRowKey');
35
+ return;
36
+ }
37
+ keys[sourceIndex] = key;
38
+ if (indexByKey.has(key))
39
+ diagnostics.push('duplicateRowKey');
40
+ else
41
+ indexByKey.set(key, sourceIndex);
42
+ });
43
+ if (diagnostics.length > 0)
44
+ return flatFallback(data, diagnostics);
45
+ const parentIndexes = new Array(data.length);
46
+ const childrenByParentIndex = new Map();
47
+ const roots = [];
48
+ data.forEach((item, sourceIndex) => {
49
+ const parentKey = getCellValueByRowKey(parentRowKey, item.values);
50
+ const parentIndex = parentKey === undefined || parentKey === null ? undefined : indexByKey.get(parentKey);
51
+ if (parentIndex === undefined) {
52
+ roots.push(sourceIndex);
53
+ return;
54
+ }
55
+ parentIndexes[sourceIndex] = parentIndex;
56
+ const children = childrenByParentIndex.get(parentIndex) ?? [];
57
+ children.push(sourceIndex);
58
+ childrenByParentIndex.set(parentIndex, children);
59
+ });
60
+ // Every node has at most one parent, so iterative parent walking detects all cycles in O(N).
61
+ const visitState = new Uint8Array(data.length);
62
+ for (let start = 0; start < data.length; start++) {
63
+ if (visitState[start] !== 0)
64
+ continue;
65
+ const path = [];
66
+ let current = start;
67
+ while (current !== undefined && visitState[current] === 0) {
68
+ visitState[current] = 1;
69
+ path.push(current);
70
+ current = parentIndexes[current];
71
+ }
72
+ if (current !== undefined && visitState[current] === 1)
73
+ diagnostics.push('cycle');
74
+ path.forEach(index => {
75
+ visitState[index] = 2;
76
+ });
77
+ }
78
+ if (diagnostics.length > 0)
79
+ return flatFallback(data, diagnostics);
80
+ const orderRank = new Map();
81
+ orderedSourceIndexes?.forEach((sourceIndex, rank) => orderRank.set(sourceIndex, rank));
82
+ const compareSourceOrder = (left, right) => (orderRank.get(left) ?? Number.MAX_SAFE_INTEGER) - (orderRank.get(right) ?? Number.MAX_SAFE_INTEGER) ||
83
+ left - right;
84
+ roots.sort(compareSourceOrder);
85
+ childrenByParentIndex.forEach(children => children.sort(compareSourceOrder));
86
+ const included = includedSourceIndexes ? new Set(includedSourceIndexes) : undefined;
87
+ const forcedExpanded = new Set();
88
+ if (included) {
89
+ for (const matchedIndex of includedSourceIndexes ?? []) {
90
+ let current = parentIndexes[matchedIndex];
91
+ while (current !== undefined) {
92
+ included.add(current);
93
+ forcedExpanded.add(current);
94
+ current = parentIndexes[current];
95
+ }
96
+ }
97
+ }
98
+ const expanded = new Set(expandedRowKeys);
99
+ const visibleData = [];
100
+ const sourceIndexByVisibleIndex = [];
101
+ const visibleIndexBySourceIndex = new Map();
102
+ const metaByRowKey = new Map();
103
+ const metaBySourceIndex = new Map();
104
+ const stack = roots
105
+ .slice()
106
+ .reverse()
107
+ .map((sourceIndex, reverseIndex) => ({
108
+ sourceIndex,
109
+ depth: 0,
110
+ visible: true,
111
+ siblingIndex: roots.length - reverseIndex - 1,
112
+ siblingCount: roots.length,
113
+ }));
114
+ while (stack.length > 0) {
115
+ const entry = stack.pop();
116
+ const { sourceIndex, depth } = entry;
117
+ const key = keys[sourceIndex];
118
+ const parentSourceIndex = parentIndexes[sourceIndex];
119
+ const children = childrenByParentIndex.get(sourceIndex) ?? [];
120
+ const isIncluded = !included || included.has(sourceIndex);
121
+ const isExpanded = expanded.has(key);
122
+ const effectiveExpanded = isExpanded || forcedExpanded.has(sourceIndex);
123
+ const meta = {
124
+ rowKey: key,
125
+ parentRowKey: parentSourceIndex === undefined ? undefined : keys[parentSourceIndex],
126
+ depth,
127
+ hasChildren: children.length > 0,
128
+ expanded: isExpanded,
129
+ sourceIndex,
130
+ parentSourceIndex,
131
+ siblingIndex: entry.siblingIndex,
132
+ siblingCount: entry.siblingCount,
133
+ };
134
+ metaByRowKey.set(key, meta);
135
+ metaBySourceIndex.set(sourceIndex, meta);
136
+ const visible = entry.visible && isIncluded;
137
+ if (visible) {
138
+ visibleIndexBySourceIndex.set(sourceIndex, visibleData.length);
139
+ visibleData.push(data[sourceIndex]);
140
+ sourceIndexByVisibleIndex.push(sourceIndex);
141
+ }
142
+ // Collapsed subtrees do not need row metadata until they become visible. Skipping
143
+ // them keeps folding work proportional to the visible hierarchy, not all input rows.
144
+ if (!visible || !effectiveExpanded)
145
+ continue;
146
+ for (let childIndex = children.length - 1; childIndex >= 0; childIndex--) {
147
+ stack.push({
148
+ sourceIndex: children[childIndex],
149
+ depth: depth + 1,
150
+ visible: true,
151
+ siblingIndex: childIndex,
152
+ siblingCount: children.length,
153
+ });
154
+ }
155
+ }
156
+ return {
157
+ valid: true,
158
+ data: visibleData,
159
+ sourceIndexByVisibleIndex,
160
+ visibleIndexBySourceIndex,
161
+ metaByRowKey,
162
+ metaBySourceIndex,
163
+ diagnostics: [],
164
+ };
165
+ }
166
+ export function getTreeRowPath(metaBySourceIndex, sourceIndex) {
167
+ const path = [];
168
+ let current = metaBySourceIndex.get(sourceIndex);
169
+ while (current) {
170
+ path.push(current.rowKey);
171
+ current = current.parentSourceIndex === undefined ? undefined : metaBySourceIndex.get(current.parentSourceIndex);
172
+ }
173
+ return path.reverse();
174
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beautiful-grid",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "A beautiful, powerful, open-source React Data Grid.",
5
5
  "homepage": "https://bgrid.axisj.com",
6
6
  "bugs": {
package/style.css CHANGED
@@ -1,4 +1,4 @@
1
- [role='grid'],
1
+ :is([role='grid'], [role='treegrid']),
2
2
  .bgrid-floating-portal-root,
3
3
  .bgrid-editor-portal-root,
4
4
  .bgrid-toolbox-popover {
@@ -141,10 +141,10 @@
141
141
  Ensures the grid is self-contained and unaffected by external global CSS.
142
142
  ========================================================================== */
143
143
 
144
- [role='grid'],
145
- [role='grid'] *,
146
- [role='grid'] *::before,
147
- [role='grid'] *::after,
144
+ :is([role='grid'], [role='treegrid']),
145
+ :is([role='grid'], [role='treegrid']) *,
146
+ :is([role='grid'], [role='treegrid']) *::before,
147
+ :is([role='grid'], [role='treegrid']) *::after,
148
148
  .bgrid-floating-portal-root,
149
149
  .bgrid-floating-portal-root *,
150
150
  .bgrid-floating-portal-root *::before,
@@ -156,7 +156,7 @@
156
156
  box-sizing: border-box;
157
157
  }
158
158
 
159
- [role='grid'],
159
+ :is([role='grid'], [role='treegrid']),
160
160
  .bgrid-floating-portal-root,
161
161
  .bgrid-toolbox-popover {
162
162
  font-family: var(
@@ -488,12 +488,12 @@
488
488
  background-color: var(--bgrid-border-color-base);
489
489
  }
490
490
 
491
- [role='grid'][data-bgrid-frozen-columns='true'] .bgrid-frozen-column-boundary::after {
491
+ :is([role='grid'], [role='treegrid'])[data-bgrid-frozen-columns='true'] .bgrid-frozen-column-boundary::after {
492
492
  width: var(--bgrid-frozen-boundary-width);
493
493
  background-color: var(--bgrid-frozen-boundary-color);
494
494
  }
495
495
 
496
- [role='grid'][data-bgrid-frozen-columns='true'] .bgrid-frozen-column-boundary {
496
+ :is([role='grid'], [role='treegrid'])[data-bgrid-frozen-columns='true'] .bgrid-frozen-column-boundary {
497
497
  box-shadow: var(--bgrid-frozen-boundary-shadow);
498
498
  }
499
499
 
@@ -513,11 +513,11 @@
513
513
  box-shadow: inset 0 0 0 1px var(--bgrid-cell-value-changed-border-color);
514
514
  }
515
515
 
516
- [role='grid'] .bgrid-body-table > tbody > tr > td.bgrid-cell-search-match {
516
+ :is([role='grid'], [role='treegrid']) .bgrid-body-table > tbody > tr > td.bgrid-cell-search-match {
517
517
  position: relative;
518
518
  }
519
519
 
520
- [role='grid'] .bgrid-body-table > tbody > tr > td.bgrid-cell-search-match::before {
520
+ :is([role='grid'], [role='treegrid']) .bgrid-body-table > tbody > tr > td.bgrid-cell-search-match::before {
521
521
  position: absolute;
522
522
  inset: 1px;
523
523
  z-index: 0;
@@ -527,17 +527,26 @@
527
527
  box-shadow: inset 0 0 0 1px var(--bgrid-search-match-border-color);
528
528
  }
529
529
 
530
- [role='grid'] .bgrid-body-table > tbody > tr > td.bgrid-cell-search-current::before {
530
+ :is([role='grid'], [role='treegrid']) .bgrid-body-table > tbody > tr > td.bgrid-cell-search-current::before {
531
531
  background: var(--bgrid-search-current-bg);
532
532
  box-shadow: inset 0 0 0 2px var(--bgrid-search-current-border-color);
533
533
  }
534
534
 
535
- [role='grid'] .bgrid-body-table > tbody > tr > td.bgrid-cell-search-match > .bgrid-cell-content {
535
+ :is([role='grid'], [role='treegrid'])
536
+ .bgrid-body-table
537
+ > tbody
538
+ > tr
539
+ > td.bgrid-cell-search-match
540
+ > .bgrid-cell-content {
536
541
  position: relative;
537
542
  z-index: 3;
538
543
  }
539
544
 
540
- [role='grid'] .bgrid-body-table > tbody > tr > td.bgrid-cell-editing.bgrid-cell-search-match::before {
545
+ :is([role='grid'], [role='treegrid'])
546
+ .bgrid-body-table
547
+ > tbody
548
+ > tr
549
+ > td.bgrid-cell-editing.bgrid-cell-search-match::before {
541
550
  background: transparent;
542
551
  }
543
552
 
@@ -647,7 +656,7 @@
647
656
  background-color: var(--bgrid-body-active-bg) !important;
648
657
  }
649
658
 
650
- [role='grid'][data-bgrid-row-reordering='true'] .bgrid-body-table > tbody > tr > td {
659
+ :is([role='grid'], [role='treegrid'])[data-bgrid-row-reordering='true'] .bgrid-body-table > tbody > tr > td {
651
660
  position: relative;
652
661
  z-index: 1;
653
662
  transform: translateY(0);
@@ -655,12 +664,12 @@
655
664
  will-change: transform;
656
665
  }
657
666
 
658
- [role='grid'][data-bgrid-row-reordering='true']
667
+ :is([role='grid'], [role='treegrid'])[data-bgrid-row-reordering='true']
659
668
  .bgrid-body-table
660
669
  > tbody
661
670
  > tr[data-bgrid-row-reorder-role='shift']
662
671
  > td,
663
- [role='grid'][data-bgrid-row-reordering='true']
672
+ :is([role='grid'], [role='treegrid'])[data-bgrid-row-reordering='true']
664
673
  .bgrid-body-table
665
674
  > tbody
666
675
  > tr[data-bgrid-row-reorder-role='target']
@@ -668,7 +677,7 @@
668
677
  transform: translateY(var(--bgrid-row-reorder-offset-y, 0));
669
678
  }
670
679
 
671
- [role='grid'][data-bgrid-row-reordering='true']
680
+ :is([role='grid'], [role='treegrid'])[data-bgrid-row-reordering='true']
672
681
  .bgrid-body-table
673
682
  > tbody
674
683
  > tr[data-bgrid-row-reorder-role='source']
@@ -679,7 +688,7 @@
679
688
  box-shadow: var(--bgrid-row-reorder-preview-shadow);
680
689
  }
681
690
 
682
- [role='grid'][data-bgrid-row-reorder-phase='dragging']
691
+ :is([role='grid'], [role='treegrid'])[data-bgrid-row-reorder-phase='dragging']
683
692
  .bgrid-body-table
684
693
  > tbody
685
694
  > tr[data-bgrid-row-reorder-role='source']
@@ -687,7 +696,7 @@
687
696
  transition: none;
688
697
  }
689
698
 
690
- [role='grid'][data-bgrid-row-reordering='true']
699
+ :is([role='grid'], [role='treegrid'])[data-bgrid-row-reordering='true']
691
700
  .bgrid-body-table
692
701
  > tbody
693
702
  > tr[data-bgrid-row-reorder-role='target'][data-bgrid-row-reorder-direction='down']
@@ -695,7 +704,7 @@
695
704
  box-shadow: inset 0 -2px var(--bgrid-row-reorder-guide-color);
696
705
  }
697
706
 
698
- [role='grid'][data-bgrid-row-reordering='true']
707
+ :is([role='grid'], [role='treegrid'])[data-bgrid-row-reordering='true']
699
708
  .bgrid-body-table
700
709
  > tbody
701
710
  > tr[data-bgrid-row-reorder-role='target'][data-bgrid-row-reorder-direction='up']
@@ -705,11 +714,15 @@
705
714
 
706
715
  /* A moving rowspan cannot be split safely. Keep the table geometry fixed and
707
716
  animate the lightweight preview while retaining the insertion guide. */
708
- [role='grid'][data-bgrid-row-reorder-fallback='true'] .bgrid-body-table > tbody > tr[data-bgrid-row-reorder-role] > td {
717
+ :is([role='grid'], [role='treegrid'])[data-bgrid-row-reorder-fallback='true']
718
+ .bgrid-body-table
719
+ > tbody
720
+ > tr[data-bgrid-row-reorder-role]
721
+ > td {
709
722
  transform: none;
710
723
  }
711
724
 
712
- [role='grid'][data-bgrid-row-reorder-fallback='true']
725
+ :is([role='grid'], [role='treegrid'])[data-bgrid-row-reorder-fallback='true']
713
726
  .bgrid-body-table
714
727
  > tbody
715
728
  > tr[data-bgrid-row-reorder-role='source']
@@ -739,7 +752,7 @@
739
752
  text-overflow: ellipsis;
740
753
  }
741
754
 
742
- [role='grid'][data-bgrid-row-reorder-phase='dragging'] .bgrid-row-reorder-preview {
755
+ :is([role='grid'], [role='treegrid'])[data-bgrid-row-reorder-phase='dragging'] .bgrid-row-reorder-preview {
743
756
  transition: none;
744
757
  }
745
758
 
@@ -1021,7 +1034,7 @@
1021
1034
  background: var(--bgrid-context-menu-border-color);
1022
1035
  }
1023
1036
 
1024
- [role='grid'] .bgrid-search-popover {
1037
+ :is([role='grid'], [role='treegrid']) .bgrid-search-popover {
1025
1038
  position: absolute;
1026
1039
  top: 0;
1027
1040
  right: 0;
@@ -1039,7 +1052,7 @@
1039
1052
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
1040
1053
  }
1041
1054
 
1042
- [role='grid'] .bgrid-search-leading-icon {
1055
+ :is([role='grid'], [role='treegrid']) .bgrid-search-leading-icon {
1043
1056
  display: inline-flex;
1044
1057
  flex: none;
1045
1058
  align-items: center;
@@ -1047,7 +1060,7 @@
1047
1060
  width: 20px;
1048
1061
  }
1049
1062
 
1050
- [role='grid'] .bgrid-search-input {
1063
+ :is([role='grid'], [role='treegrid']) .bgrid-search-input {
1051
1064
  min-width: 0;
1052
1065
  height: 28px;
1053
1066
  flex: 1 1 160px;
@@ -1060,12 +1073,12 @@
1060
1073
  outline: none;
1061
1074
  }
1062
1075
 
1063
- [role='grid'] .bgrid-search-input:focus {
1076
+ :is([role='grid'], [role='treegrid']) .bgrid-search-input:focus {
1064
1077
  border-color: var(--bgrid-search-focus-ring-color);
1065
1078
  box-shadow: 0 0 0 1px var(--bgrid-search-focus-ring-color);
1066
1079
  }
1067
1080
 
1068
- [role='grid'] .bgrid-search-result-status {
1081
+ :is([role='grid'], [role='treegrid']) .bgrid-search-result-status {
1069
1082
  min-width: 72px;
1070
1083
  flex: none;
1071
1084
  color: var(--bgrid-search-muted-color);
@@ -1074,7 +1087,7 @@
1074
1087
  white-space: nowrap;
1075
1088
  }
1076
1089
 
1077
- [role='grid'] .bgrid-search-button {
1090
+ :is([role='grid'], [role='treegrid']) .bgrid-search-button {
1078
1091
  display: inline-flex;
1079
1092
  width: 28px;
1080
1093
  height: 28px;
@@ -1092,13 +1105,13 @@
1092
1105
  border-radius: 4px;
1093
1106
  }
1094
1107
 
1095
- [role='grid'] .bgrid-search-button:hover:not(:disabled),
1096
- [role='grid'] .bgrid-search-button:focus-visible {
1108
+ :is([role='grid'], [role='treegrid']) .bgrid-search-button:hover:not(:disabled),
1109
+ :is([role='grid'], [role='treegrid']) .bgrid-search-button:focus-visible {
1097
1110
  background: var(--bgrid-search-button-hover-bg);
1098
1111
  outline: 1px solid var(--bgrid-search-focus-ring-color);
1099
1112
  }
1100
1113
 
1101
- [role='grid'] .bgrid-search-button:disabled {
1114
+ :is([role='grid'], [role='treegrid']) .bgrid-search-button:disabled {
1102
1115
  cursor: default;
1103
1116
  opacity: 0.35;
1104
1117
  }
@@ -1755,8 +1768,10 @@
1755
1768
  cursor: pointer;
1756
1769
  }
1757
1770
 
1758
- [role='grid'][data-bgrid-cell-selection-enabled='true'] [data-header-cell-type][data-bgrid-axis-selectable='true'],
1759
- [role='grid'][data-bgrid-cell-selection-enabled='true'] .bgrid-line-number-cell[data-bgrid-axis-selectable='true'] {
1771
+ :is([role='grid'], [role='treegrid'])[data-bgrid-cell-selection-enabled='true']
1772
+ [data-header-cell-type][data-bgrid-axis-selectable='true'],
1773
+ :is([role='grid'], [role='treegrid'])[data-bgrid-cell-selection-enabled='true']
1774
+ .bgrid-line-number-cell[data-bgrid-axis-selectable='true'] {
1760
1775
  cursor: pointer;
1761
1776
  user-select: none;
1762
1777
  }
@@ -2363,6 +2378,73 @@
2363
2378
  text-overflow: ellipsis;
2364
2379
  }
2365
2380
 
2381
+ .bgrid-tree-cell {
2382
+ display: inline-flex;
2383
+ align-items: center;
2384
+ box-sizing: border-box;
2385
+ width: 100%;
2386
+ min-width: 0;
2387
+ padding-inline-start: calc(var(--bgrid-tree-depth, 0) * var(--bgrid-tree-indent-size, 16px));
2388
+ }
2389
+
2390
+ .bgrid-tree-toggle,
2391
+ .bgrid-tree-toggle-spacer {
2392
+ display: inline-flex;
2393
+ flex: 0 0 var(--bgrid-tree-toggle-size, 18px);
2394
+ align-items: center;
2395
+ justify-content: center;
2396
+ box-sizing: border-box;
2397
+ width: var(--bgrid-tree-toggle-size, 18px);
2398
+ height: var(--bgrid-tree-toggle-size, 18px);
2399
+ margin: 0 2px 0 0;
2400
+ }
2401
+
2402
+ .bgrid-tree-icon {
2403
+ display: inline-flex;
2404
+ align-items: center;
2405
+ justify-content: center;
2406
+ width: 100%;
2407
+ height: 100%;
2408
+ line-height: 1;
2409
+ }
2410
+
2411
+ .bgrid-tree-icon > svg {
2412
+ display: block;
2413
+ }
2414
+
2415
+ .bgrid-tree-toggle {
2416
+ padding: 0;
2417
+ color: inherit;
2418
+ font: inherit;
2419
+ line-height: 1;
2420
+ cursor: pointer;
2421
+ background: transparent;
2422
+ border: 0;
2423
+ border-radius: 2px;
2424
+ }
2425
+
2426
+ .bgrid-tree-toggle:hover:not(:disabled) {
2427
+ background: var(--bgrid-body-hover-bg);
2428
+ }
2429
+
2430
+ .bgrid-tree-toggle:focus-visible {
2431
+ outline: 2px solid var(--bgrid-active-cell-ring-color);
2432
+ outline-offset: -1px;
2433
+ }
2434
+
2435
+ .bgrid-tree-toggle:disabled {
2436
+ cursor: default;
2437
+ opacity: 0.5;
2438
+ }
2439
+
2440
+ .bgrid-tree-cell-content {
2441
+ flex: 1 1 auto;
2442
+ min-width: 0;
2443
+ overflow: hidden;
2444
+ text-overflow: ellipsis;
2445
+ white-space: nowrap;
2446
+ }
2447
+
2366
2448
  .bgrid-editor-icon {
2367
2449
  position: relative;
2368
2450
  z-index: 31;
@@ -2619,32 +2701,32 @@
2619
2701
  }
2620
2702
 
2621
2703
  @media (max-width: 480px) {
2622
- [role='grid'] .bgrid-search-result-status {
2704
+ :is([role='grid'], [role='treegrid']) .bgrid-search-result-status {
2623
2705
  min-width: 58px;
2624
2706
  }
2625
2707
  }
2626
2708
 
2627
2709
  @media (max-width: 360px) {
2628
- [role='grid'] .bgrid-search-popover {
2710
+ :is([role='grid'], [role='treegrid']) .bgrid-search-popover {
2629
2711
  gap: 2px;
2630
2712
  padding: 4px;
2631
2713
  }
2632
2714
 
2633
- [role='grid'] .bgrid-search-leading-icon {
2715
+ :is([role='grid'], [role='treegrid']) .bgrid-search-leading-icon {
2634
2716
  display: none;
2635
2717
  }
2636
2718
 
2637
- [role='grid'] .bgrid-search-input {
2719
+ :is([role='grid'], [role='treegrid']) .bgrid-search-input {
2638
2720
  flex-basis: 96px;
2639
2721
  padding-inline: 6px;
2640
2722
  }
2641
2723
 
2642
- [role='grid'] .bgrid-search-result-status {
2724
+ :is([role='grid'], [role='treegrid']) .bgrid-search-result-status {
2643
2725
  min-width: 40px;
2644
2726
  font-size: 11px;
2645
2727
  }
2646
2728
 
2647
- [role='grid'] .bgrid-search-button {
2729
+ :is([role='grid'], [role='treegrid']) .bgrid-search-button {
2648
2730
  width: 24px;
2649
2731
  }
2650
2732
  }
@@ -2655,7 +2737,7 @@
2655
2737
  animation: none;
2656
2738
  }
2657
2739
 
2658
- [role='grid'][data-bgrid-row-reordering='true'] .bgrid-body-table > tbody > tr > td,
2740
+ :is([role='grid'], [role='treegrid'])[data-bgrid-row-reordering='true'] .bgrid-body-table > tbody > tr > td,
2659
2741
  .bgrid-row-reorder-preview,
2660
2742
  .bgrid-row-reorder-handle {
2661
2743
  transition-duration: 0ms;
@@ -2663,12 +2745,12 @@
2663
2745
  }
2664
2746
 
2665
2747
  @media (forced-colors: active) {
2666
- [role='grid'] .bgrid-body-table > tbody > tr > td.bgrid-cell-search-match::before {
2748
+ :is([role='grid'], [role='treegrid']) .bgrid-body-table > tbody > tr > td.bgrid-cell-search-match::before {
2667
2749
  background: transparent;
2668
2750
  outline: 1px solid Highlight;
2669
2751
  }
2670
2752
 
2671
- [role='grid'] .bgrid-body-table > tbody > tr > td.bgrid-cell-search-current::before {
2753
+ :is([role='grid'], [role='treegrid']) .bgrid-body-table > tbody > tr > td.bgrid-cell-search-current::before {
2672
2754
  outline-width: 2px;
2673
2755
  }
2674
2756
  }
package/types/BGrid.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import * as React from 'react';
2
2
  import { BGridProps } from './types';
3
- export declare function BGrid<T = Record<string, any>>({ ref, width, height, headerHeight, footerHeight, summaryHeight, itemHeight, itemPadding, getRowHeight, columns, columnsGroup, columnGroups, onChangeColumns, frozenColumnIndex, frozenRowCount, data, page, scrollbar, status, pagination, bottomBarHeight, scrollTop, scrollLeft, className, style, rowChecked, sort, onClick, loading, spinning, disabled, rowKey, selectedRowKey, editable, onChangeData, showLineNumber, msg, getRowClassName, editTrigger, cellMergeOptions, cellSelectionOptions, cellNavigationOptions, variant, summary, columnSortable, reorder, pivot, dataControl, icons, columnVisibility, searchOptions, contextMenuOptions, }: BGridProps<T>): React.JSX.Element;
3
+ export declare function BGrid<T = Record<string, any>>({ ref, width, height, headerHeight, footerHeight, summaryHeight, itemHeight, itemPadding, getRowHeight, columns, columnsGroup, columnGroups, onChangeColumns, frozenColumnIndex, frozenRowCount, data, page, scrollbar, status, pagination, bottomBarHeight, scrollTop, scrollLeft, className, style, rowChecked, sort, onClick, loading, spinning, disabled, rowKey, selectedRowKey, editable, onChangeData, showLineNumber, msg, getRowClassName, editTrigger, cellMergeOptions, cellSelectionOptions, cellNavigationOptions, variant, summary, columnSortable, reorder, pivot, dataControl, icons, columnVisibility, searchOptions, contextMenuOptions, tree, }: BGridProps<T>): React.JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { Key } from 'react';
3
- import { BGridCellNavigationOptions, AppModelColumn, BGridColumnGroup, BGridColumnGroupNode, BGridColumnVisibilityState, BGridDataControl, BGridDataItem, BGridDataQuery, BGridPage, BGridProps, BGridRowChecked, BGridSortInfo, BGridSortParam, BGridResolvedScrollbarOptions, BGridResolvedStatusOptions, BGridResolvedPaginationViewOptions } from '../types';
3
+ import { BGridCellNavigationOptions, BGridColumn, AppModelColumn, BGridColumnGroup, BGridColumnGroupNode, BGridColumnVisibilityState, BGridDataControl, BGridDataItem, BGridDataQuery, BGridPage, BGridProps, BGridRowChecked, BGridSortInfo, BGridSortParam, BGridResolvedScrollbarOptions, BGridResolvedStatusOptions, BGridResolvedPaginationViewOptions } from '../types';
4
4
  import { type BGridRowHeightMetrics } from '../utils';
5
5
  interface Props<T> {
6
6
  ref?: BGridProps<T>['ref'];
@@ -19,6 +19,7 @@ interface Props<T> {
19
19
  frozenColumnIndex?: number;
20
20
  frozenRowCount?: number;
21
21
  columns: AppModelColumn<T>[];
22
+ sourceColumns?: BGridColumn<T>[];
22
23
  columnsGroup: BGridColumnGroup[];
23
24
  columnGroups: BGridColumnGroupNode[];
24
25
  onChangeColumns?: BGridProps<T>['onChangeColumns'];
@@ -61,6 +62,7 @@ interface Props<T> {
61
62
  reorder?: BGridProps<T>['reorder'];
62
63
  className?: BGridProps<T>['className'];
63
64
  style?: BGridProps<T>['style'];
65
+ treeEnabled?: boolean;
64
66
  }
65
67
  declare function Table<T>(props: Props<T>): React.JSX.Element;
66
68
  export default Table;
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
- import { BGridCellEditSession, BGridColumn, BGridDataItem, MoveDirection } from '../types';
2
+ import { AppModelColumn, BGridCellEditSession, BGridDataItem, MoveDirection } from '../types';
3
3
  interface Props<T> {
4
4
  index: number;
5
5
  hostIndex?: number;
6
6
  columnIndex: number;
7
- column: BGridColumn<T>;
7
+ column: AppModelColumn<T>;
8
8
  item: BGridDataItem<any>;
9
9
  valueByRowKey: any;
10
10
  handleSave?: (value: any, columnDirection?: MoveDirection, rowDirection?: MoveDirection) => void;
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import type { BGridColumn, BGridDataItem } from '../types';
3
+ interface Props<T> {
4
+ column: BGridColumn<T>;
5
+ item: BGridDataItem<T>;
6
+ children: React.ReactNode;
7
+ }
8
+ export declare function TreeCell<T>({ column, item, children }: Props<T>): React.JSX.Element;
9
+ export {};
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import type { BGridTreeIcons, BGridTreeRowMeta } from '../types';
3
+ export interface BGridTreeContextValue {
4
+ treeColumnId: string;
5
+ indentSize: number;
6
+ icons?: BGridTreeIcons;
7
+ expandAriaLabel: string;
8
+ collapseAriaLabel: string;
9
+ disabled: boolean;
10
+ metaByRowKey: ReadonlyMap<React.Key, BGridTreeRowMeta>;
11
+ metaBySourceIndex: ReadonlyMap<number, BGridTreeRowMeta>;
12
+ getRowKey: (values: unknown) => React.Key | undefined;
13
+ toggle: (meta: BGridTreeRowMeta) => void;
14
+ }
15
+ export declare const TreeContext: React.Context<BGridTreeContextValue | undefined>;
16
+ export declare function useTreeContext(): BGridTreeContextValue | undefined;