@redvars/peacock 3.15.0 → 3.17.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.
Files changed (157) hide show
  1. package/dist/assets/styles.css +1 -1
  2. package/dist/assets/styles.css.map +1 -1
  3. package/dist/assets/theme.js +19 -19
  4. package/dist/assets/tokens.css +1 -1
  5. package/dist/assets/tokens.css.map +1 -1
  6. package/dist/card-content.js +8 -7
  7. package/dist/card-content.js.map +1 -1
  8. package/dist/card.js +142 -98
  9. package/dist/card.js.map +1 -1
  10. package/dist/{chart-bar-D5dGFJfK.js → cartesian-chart-DgE4USyC.js} +529 -312
  11. package/dist/cartesian-chart-DgE4USyC.js.map +1 -0
  12. package/dist/chart-area.js +78 -0
  13. package/dist/chart-area.js.map +1 -0
  14. package/dist/chart-bar.js +283 -213
  15. package/dist/chart-bar.js.map +1 -1
  16. package/dist/{transform-DSwFSqzD.js → chart-base-C2qRMF48.js} +771 -102
  17. package/dist/chart-base-C2qRMF48.js.map +1 -0
  18. package/dist/chart-doughnut.js +55 -287
  19. package/dist/chart-doughnut.js.map +1 -1
  20. package/dist/chart-line.js +626 -0
  21. package/dist/chart-line.js.map +1 -0
  22. package/dist/chart-pie.js +637 -195
  23. package/dist/chart-pie.js.map +1 -1
  24. package/dist/code-editor.js +704 -131
  25. package/dist/code-editor.js.map +1 -1
  26. package/dist/code-group.js +188 -0
  27. package/dist/code-group.js.map +1 -0
  28. package/dist/code-highlighter.js +895 -257
  29. package/dist/code-highlighter.js.map +1 -1
  30. package/dist/custom-elements-jsdocs.json +2278 -677
  31. package/dist/custom-elements.json +13962 -3690
  32. package/dist/image.js +5 -1
  33. package/dist/image.js.map +1 -1
  34. package/dist/index.js +8 -7
  35. package/dist/index.js.map +1 -1
  36. package/dist/loader-full.js +1 -1
  37. package/dist/loader.js +9 -3
  38. package/dist/loader.js.map +1 -1
  39. package/dist/{is-dark-mode-DOcaw4Yq.js → observe-theme-change-DCifz1uv.js} +2 -6
  40. package/dist/observe-theme-change-DCifz1uv.js.map +1 -0
  41. package/dist/pagination.js +408 -110
  42. package/dist/pagination.js.map +1 -1
  43. package/dist/path-CJ0Arqcy.js +166 -0
  44. package/dist/path-CJ0Arqcy.js.map +1 -0
  45. package/dist/snackbar.js +89 -34
  46. package/dist/snackbar.js.map +1 -1
  47. package/dist/src/__internal/chart/cartesian-chart.d.ts +80 -0
  48. package/dist/src/__internal/chart/chart-base.d.ts +113 -0
  49. package/dist/src/__internal/chart/paths.d.ts +5 -0
  50. package/dist/src/__internal/chart/types.d.ts +42 -0
  51. package/dist/src/card/card-content.d.ts +2 -3
  52. package/dist/src/card/card.d.ts +31 -17
  53. package/dist/src/chart-area/chart-area.d.ts +54 -0
  54. package/dist/src/chart-area/index.d.ts +1 -0
  55. package/dist/src/chart-bar/chart-bar.d.ts +44 -33
  56. package/dist/src/chart-bar/index.d.ts +0 -1
  57. package/dist/src/chart-doughnut/chart-doughnut.d.ts +33 -39
  58. package/dist/src/chart-line/chart-line.d.ts +69 -0
  59. package/dist/src/chart-line/index.d.ts +1 -0
  60. package/dist/src/chart-pie/chart-pie.d.ts +63 -28
  61. package/dist/src/code-editor/code-editor.d.ts +52 -13
  62. package/dist/src/code-editor/editor-theme.d.ts +60 -0
  63. package/dist/src/code-highlighter/code-group.d.ts +52 -0
  64. package/dist/src/code-highlighter/code-highlighter.d.ts +122 -15
  65. package/dist/src/code-highlighter/index.d.ts +1 -0
  66. package/dist/src/code-highlighter/line-ranges.d.ts +24 -0
  67. package/dist/src/code-highlighter/local.d.ts +4 -1
  68. package/dist/src/code-highlighter/token-colors.d.ts +8 -0
  69. package/dist/src/index.d.ts +4 -2
  70. package/dist/src/pagination/page-items.d.ts +14 -0
  71. package/dist/src/pagination/pagination.d.ts +46 -7
  72. package/dist/src/snackbar/snackbar.d.ts +13 -1
  73. package/dist/src/table/table.d.ts +125 -27
  74. package/dist/src/toolbar/toolbar.d.ts +56 -51
  75. package/dist/table.js +1007 -338
  76. package/dist/table.js.map +1 -1
  77. package/dist/test/chart.test.d.ts +1 -0
  78. package/dist/test/code-highlighter.test.d.ts +1 -0
  79. package/dist/test/pagination.test.d.ts +1 -0
  80. package/dist/test/table.test.d.ts +1 -0
  81. package/dist/token-colors-0TFHWbcq.js +81 -0
  82. package/dist/token-colors-0TFHWbcq.js.map +1 -0
  83. package/dist/toolbar.js +195 -184
  84. package/dist/toolbar.js.map +1 -1
  85. package/dist/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +1 -2
  87. package/readme.md +7 -6
  88. package/scss/_code-block.scss +139 -0
  89. package/scss/tokens.css +24 -0
  90. package/src/__internal/chart/cartesian-chart.ts +404 -0
  91. package/src/__internal/chart/chart-base.scss +252 -0
  92. package/src/__internal/chart/chart-base.ts +474 -0
  93. package/src/__internal/chart/paths.ts +28 -0
  94. package/src/__internal/chart/types.ts +49 -0
  95. package/src/card/card-content.ts +12 -9
  96. package/src/card/card.scss +66 -54
  97. package/src/card/card.ts +109 -73
  98. package/src/chart-area/chart-area.ts +82 -0
  99. package/src/chart-area/index.ts +1 -0
  100. package/src/chart-bar/chart-bar.ts +336 -250
  101. package/src/chart-bar/index.ts +0 -1
  102. package/src/chart-doughnut/chart-doughnut.ts +62 -262
  103. package/src/chart-doughnut/demo/index.html +14 -22
  104. package/src/chart-line/chart-line.scss +25 -0
  105. package/src/chart-line/chart-line.ts +346 -0
  106. package/src/chart-line/index.ts +1 -0
  107. package/src/chart-pie/chart-pie.scss +35 -16
  108. package/src/chart-pie/chart-pie.ts +282 -188
  109. package/src/chart-pie/demo/index.html +13 -21
  110. package/src/code-editor/code-editor.scss +132 -36
  111. package/src/code-editor/code-editor.ts +308 -88
  112. package/src/code-editor/demo/index.html +39 -12
  113. package/src/code-editor/editor-theme.ts +213 -0
  114. package/src/code-highlighter/code-group.scss +34 -0
  115. package/src/code-highlighter/code-group.ts +173 -0
  116. package/src/code-highlighter/code-highlighter.scss +226 -111
  117. package/src/code-highlighter/code-highlighter.ts +554 -199
  118. package/src/code-highlighter/demo/index.html +68 -4
  119. package/src/code-highlighter/index.ts +1 -0
  120. package/src/code-highlighter/line-ranges.ts +81 -0
  121. package/src/code-highlighter/local.ts +9 -3
  122. package/src/code-highlighter/token-colors.ts +42 -0
  123. package/src/index.ts +4 -2
  124. package/src/loader.ts +8 -2
  125. package/src/pagination/page-items.ts +50 -0
  126. package/src/pagination/pagination.scss +159 -44
  127. package/src/pagination/pagination.ts +275 -74
  128. package/src/snackbar/demo/index.html +39 -4
  129. package/src/snackbar/snackbar.scss +27 -10
  130. package/src/snackbar/snackbar.ts +80 -37
  131. package/src/table/table.scss +337 -109
  132. package/src/table/table.ts +812 -272
  133. package/src/toolbar/toolbar-colors.scss +6 -7
  134. package/src/toolbar/toolbar.scss +35 -106
  135. package/src/toolbar/toolbar.ts +180 -80
  136. package/dist/array-D5vjT2Xm.js +0 -14
  137. package/dist/array-D5vjT2Xm.js.map +0 -1
  138. package/dist/chart-bar-D5dGFJfK.js.map +0 -1
  139. package/dist/chart-stacked-bar.js +0 -403
  140. package/dist/chart-stacked-bar.js.map +0 -1
  141. package/dist/copy-to-clipboard-upGx-Ueo.js +0 -39
  142. package/dist/copy-to-clipboard-upGx-Ueo.js.map +0 -1
  143. package/dist/is-dark-mode-DOcaw4Yq.js.map +0 -1
  144. package/dist/pie-Dz0IDiPt.js +0 -537
  145. package/dist/pie-Dz0IDiPt.js.map +0 -1
  146. package/dist/pierre-dark-DFWl0m-C.js +0 -4
  147. package/dist/pierre-dark-DFWl0m-C.js.map +0 -1
  148. package/dist/pierre-light-BEkAPImt.js +0 -4
  149. package/dist/pierre-light-BEkAPImt.js.map +0 -1
  150. package/dist/src/chart-bar/chart-stacked-bar.d.ts +0 -78
  151. package/dist/src/code-highlighter/constants.d.ts +0 -1
  152. package/dist/transform-DSwFSqzD.js.map +0 -1
  153. package/src/chart-bar/chart-bar.scss +0 -58
  154. package/src/chart-bar/chart-stacked-bar.ts +0 -398
  155. package/src/chart-doughnut/chart-donut.scss +0 -37
  156. package/src/code-highlighter/constants.ts +0 -117
  157. /package/dist/test/{chart-bar.test.d.ts → card.test.d.ts} +0 -0
package/dist/table.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import { i, _ as __decorate, I as IndividualComponent, a as i$1, b, A } from './IndividualComponent-Bdwyrvd6.js';
2
2
  import { n } from './property-B49QQ8pS.js';
3
3
  import { r } from './state-DkTK9EGF.js';
4
- import { e } from './class-map-DG7CA1et.js';
4
+ import { e } from './query-CHb9Ft_d.js';
5
+ import { e as e$1 } from './class-map-DG7CA1et.js';
6
+ import { o as o$1 } from './style-map-BQD5Et1D.js';
5
7
  import { o } from './unsafe-html-Ct0N2_UU.js';
6
- import { t as throttle } from './throttle-C7ZAPqtu.js';
8
+ import './base-Cl6v8-BZ.js';
7
9
  import './directive-ZPhl09Yt.js';
8
10
 
9
11
  var css_248z = i`* {
@@ -22,168 +24,404 @@ var css_248z = i`* {
22
24
  :host {
23
25
  display: block;
24
26
  height: 100%;
25
- min-height: 20em;
27
+ min-width: 0;
28
+ --table-row-height: 3rem;
26
29
  --table-border-color: var(--color-outline-variant);
27
- --table-border: 1px solid var(--table-border-color);
28
- --table-col-content-padding: var(--spacing-150, 0.75rem)
29
- var(--spacing-200, 1rem);
30
+ --table-cell-padding-inline: var(--spacing-200, 1rem);
31
+ --table-header-background: var(--color-surface, #fff);
32
+ --table-background: var(--color-surface, #fff);
33
+ --_table-checkbox-width: 3rem;
34
+ --_table-edge-shadow: color-mix(in srgb, var(--color-shadow) 14%, transparent);
35
+ }
36
+
37
+ :host([density=compact]) {
38
+ --table-row-height: 2.25rem;
39
+ --table-cell-padding-inline: var(--spacing-150, 0.75rem);
40
+ }
41
+
42
+ :host([density=comfortable]) {
43
+ --table-row-height: 3.5rem;
30
44
  }
31
45
 
32
46
  .table {
47
+ position: relative;
33
48
  height: 100%;
34
49
  display: flex;
35
50
  flex-direction: column;
36
- background: var(--color-surface, #fff);
51
+ background: var(--table-background);
52
+ color: var(--color-on-surface);
37
53
  font-family: var(--typography-body-medium-font-family);
38
54
  font-size: var(--typography-body-medium-font-size);
39
55
  font-weight: var(--typography-body-medium-font-weight);
40
56
  line-height: var(--typography-body-medium-line-height);
41
57
  letter-spacing: var(--typography-body-medium-letter-spacing);
42
58
  }
43
- .table .table-scroll-container {
59
+
60
+ .table-scroll-container {
61
+ contain: inline-size;
44
62
  position: relative;
63
+ flex: 1 1 auto;
64
+ min-height: 0;
45
65
  overflow: auto;
46
- height: 100%;
66
+ outline: none;
47
67
  }
48
- .table .empty-table {
49
- height: 80%;
68
+
69
+ .row {
70
+ --_cell-background: var(--table-background);
50
71
  display: flex;
51
- align-items: center;
52
- justify-content: center;
72
+ width: max-content;
73
+ min-width: max(100%, var(--_row-min-width, 0rem));
53
74
  }
54
- .table .empty-table .empty-state {
55
- width: 10rem;
75
+
76
+ .columns {
77
+ display: flex;
56
78
  }
57
- .table wc-pagination {
58
- border-top: 1px solid var(--table-border-color);
79
+
80
+ .scroll-group {
81
+ flex: 1 0 auto;
82
+ isolation: isolate;
59
83
  }
60
- .table.horizontal-scrolled .fixed-columns::after {
61
- box-shadow: 10px 0 20px -20px var(--color-outline) inset;
62
- content: " ";
63
- height: 100%;
64
- position: absolute;
65
- top: 0;
66
- right: -20px;
67
- width: 20px;
84
+ .scroll-group > .cell:last-child {
85
+ flex-grow: 1;
68
86
  }
69
87
 
70
- .row {
71
- display: flex;
72
- box-sizing: border-box;
73
- width: max-content;
74
- min-width: 100%;
88
+ .pinned-group {
89
+ position: sticky;
90
+ z-index: 1;
91
+ flex: none;
75
92
  }
76
- .row .columns-container {
77
- display: flex;
93
+
94
+ .pinned-group-start {
95
+ inset-inline-start: 0;
78
96
  }
79
- .row .col {
80
- margin: 0;
81
- color: var(--color-on-surface);
97
+
98
+ .pinned-group-end {
99
+ inset-inline-end: 0;
100
+ }
101
+
102
+ .cell {
103
+ position: relative;
104
+ display: flex;
105
+ align-items: center;
82
106
  flex-shrink: 0;
107
+ min-width: 0;
108
+ min-height: var(--table-row-height);
109
+ padding-inline: var(--table-cell-padding-inline);
110
+ background: var(--_cell-background);
111
+ border-bottom: 1px solid var(--table-border-color);
112
+ }
113
+ .cell:focus-visible {
114
+ outline: 2px solid var(--color-primary);
115
+ outline-offset: -2px;
83
116
  }
84
- .row .col .col-content {
117
+ .cell.align-start {
118
+ justify-content: flex-start;
119
+ text-align: start;
120
+ }
121
+ .cell.align-center {
122
+ justify-content: center;
123
+ text-align: center;
124
+ }
125
+ .cell.align-end {
126
+ justify-content: flex-end;
127
+ text-align: end;
128
+ }
129
+ .cell.numeric {
130
+ font-variant-numeric: tabular-nums;
131
+ }
132
+ .cell.cell-checkbox {
133
+ width: var(--_table-checkbox-width);
134
+ padding-inline: 0;
135
+ }
136
+
137
+ .cell-text {
138
+ min-width: 0;
139
+ overflow: hidden;
140
+ white-space: nowrap;
141
+ text-overflow: ellipsis;
142
+ }
143
+ .wrap .cell-text {
144
+ padding-block: var(--spacing-100, 0.5rem);
145
+ white-space: normal;
146
+ overflow-wrap: anywhere;
147
+ }
148
+
149
+ .cell-template {
85
150
  display: flex;
86
151
  align-items: center;
87
- height: 100%;
152
+ min-width: 0;
153
+ max-width: 100%;
88
154
  }
89
- .row .col .col-content .col-text {
90
- padding: var(--table-col-content-padding);
91
- flex: 1;
155
+
156
+ .header {
157
+ position: sticky;
158
+ top: 0;
159
+ z-index: 3;
160
+ }
161
+ .header .row {
162
+ --_cell-background: var(--table-header-background);
163
+ }
164
+ .header .cell {
165
+ color: var(--color-on-surface-variant);
166
+ font-family: var(--typography-label-large-font-family);
167
+ font-size: var(--typography-label-large-font-size);
168
+ font-weight: var(--typography-label-large-font-weight);
169
+ line-height: var(--typography-label-large-line-height);
170
+ letter-spacing: var(--typography-label-large-letter-spacing);
171
+ }
172
+ .header .cell.sortable {
173
+ padding-inline: 0;
174
+ }
175
+ .header .cell.sorted {
176
+ color: var(--color-on-surface);
177
+ }
178
+ .header .header-label {
179
+ min-width: 0;
92
180
  overflow: hidden;
93
181
  white-space: nowrap;
94
182
  text-overflow: ellipsis;
95
183
  }
96
- .row .col .col-content .col-template {
184
+
185
+ .sort-button {
186
+ background: transparent;
187
+ border: none;
188
+ appearance: none;
189
+ margin: 0;
190
+ outline: none;
191
+ padding: 0;
192
+ display: flex;
193
+ align-items: center;
194
+ justify-content: inherit;
195
+ gap: var(--spacing-050, 0.25rem);
196
+ align-self: stretch;
97
197
  width: 100%;
198
+ min-width: 0;
199
+ padding-inline: var(--table-cell-padding-inline);
200
+ color: inherit;
201
+ font: inherit;
202
+ letter-spacing: inherit;
203
+ text-align: inherit;
204
+ cursor: pointer;
98
205
  }
99
- .row .col .col-content .col-action {
100
- --button-container-shape: 0;
206
+ .align-end .sort-button {
207
+ flex-direction: row-reverse;
101
208
  }
102
- .row .col .col-content .checkbox {
103
- padding: 0 var(--spacing-100, 0.5rem);
209
+ .sort-button:hover {
210
+ background: color-mix(in srgb, var(--color-on-surface) 6%, transparent);
104
211
  }
105
- .row .col.center .col-content {
106
- justify-content: center;
212
+ .sort-button:focus-visible {
213
+ outline: 2px solid var(--color-primary);
214
+ outline-offset: -2px;
107
215
  }
108
- .row .col:last-child {
109
- flex: 1;
216
+
217
+ .sort-icon {
218
+ flex: none;
219
+ --icon-size: 1.125rem;
220
+ font-size: 1.125rem;
221
+ opacity: 0;
222
+ transition: opacity var(--duration-short2, 100ms) ease;
110
223
  }
111
- .row .fixed-columns {
112
- position: sticky;
113
- left: 0;
224
+ .sort-button:hover .sort-icon, .sort-button:focus-visible .sort-icon {
225
+ opacity: 0.6;
114
226
  }
115
- .row .scrollable-columns {
116
- flex: 0 0 auto;
227
+ .sorted .sort-icon {
228
+ opacity: 1;
117
229
  }
118
230
 
119
- .header {
120
- position: sticky;
231
+ .loading-bar {
232
+ position: absolute;
233
+ inset-inline: 0;
234
+ bottom: 0;
235
+ --progress-height: 2px;
236
+ }
237
+
238
+ .body .cell {
239
+ cursor: pointer;
240
+ }
241
+ .body .cell.cell-checkbox {
242
+ cursor: default;
243
+ }
244
+ .body .row:hover {
245
+ --_cell-background: var(--color-surface-container-low);
246
+ }
247
+ .body .row.selected {
248
+ --_cell-background: color-mix(
249
+ in srgb,
250
+ var(--color-secondary-container) 55%,
251
+ var(--table-background)
252
+ );
253
+ }
254
+ .body .row.selected > .columns:first-child > .cell:first-child {
255
+ box-shadow: inset 2px 0 0 var(--color-primary);
256
+ }
257
+ .body .row.selected:hover {
258
+ --_cell-background: var(--color-secondary-container);
259
+ }
260
+ .body .skeleton-row .cell {
261
+ cursor: default;
262
+ }
263
+
264
+ .has-footer .body .row:last-child .cell {
265
+ border-bottom-color: transparent;
266
+ }
267
+
268
+ :host([striped]) .body .row:nth-child(even):not(.selected) {
269
+ --_cell-background: color-mix(
270
+ in srgb,
271
+ var(--color-surface-container) 45%,
272
+ var(--table-background)
273
+ );
274
+ }
275
+ :host([striped]) .body .row:nth-child(even):not(.selected):hover {
276
+ --_cell-background: var(--color-surface-container-low);
277
+ }
278
+
279
+ .skeleton-bar {
280
+ block-size: 0.75rem;
281
+ max-inline-size: 100%;
282
+ --skeleton-container-shape: var(--shape-corner-extra-small);
283
+ }
284
+ .cell-checkbox .skeleton-bar {
285
+ inline-size: 1.125rem;
286
+ block-size: 1.125rem;
287
+ }
288
+
289
+ .checkbox {
290
+ display: flex;
291
+ }
292
+
293
+ .pinned-group-start::after,
294
+ .pinned-group-end::before {
295
+ content: "";
296
+ position: absolute;
121
297
  top: 0;
122
- font-family: var(--typography-label-medium-font-family);
123
- font-size: var(--typography-label-medium-font-size);
124
- font-weight: var(--typography-label-medium-font-weight);
125
- line-height: var(--typography-label-medium-line-height);
126
- letter-spacing: var(--typography-label-medium-letter-spacing);
298
+ bottom: 0;
299
+ width: 0.75rem;
300
+ pointer-events: none;
301
+ opacity: 0;
302
+ transition: opacity var(--duration-short4, 200ms) ease;
127
303
  }
128
- .header .col {
129
- background: var(--color-surface-variant, #f4f4f4);
304
+
305
+ .pinned-group-start::after {
306
+ inset-inline-end: -0.75rem;
307
+ background: linear-gradient(to right, var(--_table-edge-shadow), transparent);
130
308
  }
131
- .header .col.sort {
132
- background: var(--color-secondary-container, #e8eaf6);
309
+
310
+ .pinned-group-end::before {
311
+ inset-inline-start: -0.75rem;
312
+ background: linear-gradient(to left, var(--_table-edge-shadow), transparent);
133
313
  }
134
314
 
135
- .body .row .col {
136
- cursor: pointer;
137
- background: var(--color-surface, #fff);
138
- border-bottom: 1px solid var(--color-surface-variant, #f4f4f4);
315
+ .scrolled-from-start .pinned-group-start::after,
316
+ .scrolled-from-end .pinned-group-end::before {
317
+ opacity: 1;
139
318
  }
140
- .body .row .col.col-checkbox .col-content {
141
- border: 0;
319
+
320
+ .bulk-bar {
321
+ position: absolute;
322
+ top: 0;
323
+ inset-inline: var(--_table-checkbox-width) 0;
324
+ z-index: 4;
325
+ display: flex;
326
+ align-items: center;
327
+ gap: var(--spacing-100, 0.5rem);
328
+ height: var(--table-row-height);
329
+ padding-inline: var(--spacing-100, 0.5rem) var(--spacing-100, 0.5rem);
330
+ background: var(--color-secondary-container);
331
+ color: var(--color-on-secondary-container);
332
+ border-bottom: 1px solid var(--table-border-color);
333
+ overflow-x: auto;
334
+ scrollbar-width: none;
335
+ white-space: nowrap;
336
+ font-family: var(--typography-label-large-font-family);
337
+ font-size: var(--typography-label-large-font-size);
338
+ font-weight: var(--typography-label-large-font-weight);
339
+ line-height: var(--typography-label-large-line-height);
340
+ letter-spacing: var(--typography-label-large-letter-spacing);
142
341
  }
143
- .body .row .col .col-content {
144
- border: 2px solid transparent;
145
- border-bottom: 1px solid transparent;
342
+ .bulk-bar > *,
343
+ .bulk-bar ::slotted(*) {
344
+ flex: none;
146
345
  }
147
- .body .row .col .col-content .col-text {
148
- text-wrap: wrap;
346
+
347
+ .bulk-count {
348
+ padding-inline-start: var(--spacing-050, 0.25rem);
349
+ white-space: nowrap;
350
+ font-variant-numeric: tabular-nums;
149
351
  }
150
- .body .row .col:focus {
151
- outline: none;
152
- border-bottom-color: var(--color-primary);
352
+
353
+ .bulk-spacer {
354
+ flex: 1;
355
+ }
356
+
357
+ ::slotted([slot=bulk-actions]) {
358
+ display: inline-flex;
359
+ align-items: center;
360
+ gap: var(--spacing-050, 0.25rem);
361
+ }
362
+
363
+ .empty-table {
364
+ position: sticky;
365
+ inset-inline-start: 0;
366
+ display: flex;
367
+ align-items: center;
368
+ justify-content: center;
369
+ min-height: 16rem;
370
+ padding: var(--spacing-400, 2rem) var(--spacing-200, 1rem);
153
371
  }
154
- .body .row .col:focus .col-content {
155
- border-color: var(--color-primary);
372
+ .empty-table .empty-state {
373
+ max-width: 24rem;
156
374
  }
157
- .body .row:hover .col {
158
- background-color: var(--color-surface-container-low, #f8f8f8);
375
+
376
+ .table-footer {
377
+ flex: none;
378
+ border-top: 1px solid var(--table-border-color);
159
379
  }`;
160
380
 
381
+ var Table_1;
161
382
  const DEFAULT_CELL_WIDTH = 16; // in rem
383
+ const CHECKBOX_CELL_WIDTH = 3; // in rem
384
+ const SKELETON_ROWS = 5;
385
+ const collator = new Intl.Collator(undefined, {
386
+ numeric: true,
387
+ sensitivity: 'base',
388
+ });
162
389
  /**
163
390
  * @label Table
164
391
  * @tag wc-table
165
392
  * @rawTag table
166
393
  * @summary A configurable component for displaying tabular data.
167
394
  * @overview
168
- * <p>The table component displays rows of data with support for sorting, pagination, row selection, and fixed columns.</p>
395
+ * <p>The table displays rows of data with sorting, pagination, row selection, sticky header and sticky start or end columns.</p>
396
+ * <p>It follows the grid keyboard pattern: the table is one tab stop and the arrow keys move between cells. <kbd>Space</kbd> selects the focused row, <kbd>Enter</kbd> activates the focused cell, and <kbd>Ctrl</kbd>+<kbd>C</kbd> copies its text.</p>
397
+ * <p>When rows are selected, a bar over the header shows the count and the actions placed in the <code>bulk-actions</code> slot.</p>
398
+ *
399
+ * @fires {CustomEvent} cell-click - Dispatched when a cell is clicked or activated with Enter. Detail: `{ record, column, altKey, ctrlKey, metaKey, shiftKey }`.
400
+ * @fires {CustomEvent} row-click - Dispatched when a row is clicked or activated with Enter. Detail: `{ record }`.
401
+ * @fires {CustomEvent} selection-change - Dispatched when the row selection changes. Detail: `{ value, isSelectAll, allPages }`.
402
+ * @fires {CustomEvent} sort - Dispatched when the table is sorted. Detail: `{ sortBy, sortOrder }`.
403
+ * @fires {CustomEvent} page - Dispatched when the page or page size changes. Detail: `{ page, pageSize }`.
169
404
  *
170
- * @fires {CustomEvent} cell-click - Dispatched when a table cell is clicked.
171
- * @fires {CustomEvent} selection-change - Dispatched when the row selection changes.
172
- * @fires {CustomEvent} sort - Dispatched when the table is sorted.
173
- * @fires {CustomEvent} page - Dispatched when the page or page size changes.
405
+ * @slot bulk-actions - Actions shown in the selection bar while rows are selected.
406
+ *
407
+ * @cssprop --table-row-height - Minimum height of a row. Set by `density`.
408
+ * @cssprop --table-border-color - Color of the row dividers.
409
+ * @cssprop --table-cell-padding-inline - Horizontal padding of a cell.
174
410
  *
175
411
  * @example
176
412
  * ```html
177
- * <wc-table columns="[{'name': 'name','label': 'Name','width': 16},{'name': 'age','label': 'Age','width': 7}]" data="[{'name': 'John','age': 30},{'name': 'Jane','age': 25}]"></wc-table>
413
+ * <wc-table columns="[{'name': 'name','label': 'Name','width': 16},{'name': 'age','label': 'Age','width': 7,'type': 'number'}]" data="[{'name': 'John','age': 30},{'name': 'Jane','age': 25}]"></wc-table>
178
414
  * ```
179
415
  * @tags display, data
180
416
  */
181
- let Table = class Table extends i$1 {
417
+ let Table = Table_1 = class Table extends i$1 {
182
418
  constructor() {
419
+ // ── Static ───────────────────────────────────────────────────────────────
183
420
  super(...arguments);
421
+ // ── Properties ───────────────────────────────────────────────────────────
184
422
  /**
185
423
  * Grid columns configuration.
186
- * Each column can have: name, label, width (px), fixed (boolean), template (function).
424
+ * Each column can have: name, label, width (rem), fixed, align, type, sortable, wrap, template.
187
425
  */
188
426
  this.columns = [];
189
427
  /**
@@ -215,7 +453,7 @@ let Table = class Table extends i$1 {
215
453
  */
216
454
  this.sortOrder = 'asc';
217
455
  /**
218
- * If true, pagination is enabled. Defaults to `true`.
456
+ * If true, pagination is enabled. Defaults to `false`.
219
457
  */
220
458
  this.paginate = false;
221
459
  /**
@@ -226,6 +464,31 @@ let Table = class Table extends i$1 {
226
464
  * The number of rows per page. Defaults to `10`.
227
465
  */
228
466
  this.pageSize = 10;
467
+ /**
468
+ * Whether another page exists after this one, in managed mode with an unknown total.
469
+ */
470
+ this.hasNext = false;
471
+ /**
472
+ * Pagination variant: `full` (page numbers), `compact` or `simple`. Defaults to `full`.
473
+ */
474
+ this.paginationVariant = 'full';
475
+ /**
476
+ * Row height: `compact`, `default` or `comfortable`. Defaults to `default`.
477
+ */
478
+ this.density = 'default';
479
+ /**
480
+ * Shades every other row.
481
+ */
482
+ this.striped = false;
483
+ /**
484
+ * Shows a loading state: skeleton rows while there is no data, otherwise a progress bar
485
+ * under the header so the current rows stay readable.
486
+ */
487
+ this.loading = false;
488
+ /**
489
+ * Accessible name of the table.
490
+ */
491
+ this.label = '';
229
492
  /**
230
493
  * Headline text shown when the table has no data.
231
494
  */
@@ -234,92 +497,220 @@ let Table = class Table extends i$1 {
234
497
  * Description text shown when the table has no data.
235
498
  */
236
499
  this.emptyStateDescription = 'There are no items to display';
237
- /** Tracks the currently hovered row and column for hover-highlight CSS. */
238
- this.hoveredCell = {};
239
- /** True when all rows on the current page are selected. */
240
- this.isSelectAll = false;
241
- /** True when some (but not all) rows on the current page are selected. */
242
- this.isSelectAllIntermediate = false;
243
- /** True when the scroll container has been scrolled horizontally. */
244
- this.isHorizontallyScrolled = false;
245
- // ── Private fields ────────────────────────────────────────────────────────
246
- /** Throttled version of the cell-mouseover handler to avoid excessive state updates. */
247
- this.onCellMouseOverThrottled = throttle((row, column) => {
248
- this.hoveredCell = { row, column };
249
- }, 30);
250
- this.onSelectAllClick = () => {
251
- this.isSelectAll = !this.isSelectAll;
252
- let selectedRowKeys = [];
253
- if (this.isSelectAll) {
254
- selectedRowKeys = this.data
255
- .slice((this.page - 1) * this.pageSize, this.page * this.pageSize)
256
- .map(row => row[this.keyField]);
257
- }
258
- this.onSelectChange(selectedRowKeys);
500
+ // ── States ───────────────────────────────────────────────────────────────
501
+ /** True when every item across all pages is selected, not only the current page. */
502
+ this.allPagesSelected = false;
503
+ /** True when content is scrolled under the start-pinned columns. */
504
+ this.scrolledFromStart = false;
505
+ /** True when more content waits past the end-pinned columns. */
506
+ this.scrolledFromEnd = false;
507
+ /** The cell that holds the grid's single tab stop. Row 0 is the header. */
508
+ this.activeCell = { row: 0, col: 0 };
509
+ // ── Private fields ───────────────────────────────────────────────────────
510
+ /** Set when a keyboard move must focus the active cell after the next render. */
511
+ this.pendingFocus = false;
512
+ this.onScrollContainer = () => {
513
+ this.updateScrollEdges();
259
514
  };
260
- this.onRowSelectClick = (row) => {
261
- let selectedRowKeys = [...this.selectedRowKeys];
262
- if (selectedRowKeys.includes(row[this.keyField])) {
263
- this.isSelectAll = false;
264
- selectedRowKeys = selectedRowKeys.filter(rowId => rowId !== row[this.keyField]);
265
- }
266
- else {
267
- selectedRowKeys.push(row[this.keyField]);
515
+ this.onGridFocusIn = (event) => {
516
+ const cell = event.target.closest('[data-cell]');
517
+ if (!cell)
518
+ return;
519
+ const row = Number(cell.dataset.row);
520
+ const col = Number(cell.dataset.col);
521
+ if (row !== this.activeCell.row || col !== this.activeCell.col) {
522
+ this.activeCell = { row, col };
268
523
  }
269
- this.onSelectChange(selectedRowKeys);
270
524
  };
271
- this.onScrollContainer = (event) => {
525
+ this.onGridKeydown = (event) => {
272
526
  const target = event.target;
273
- this.isHorizontallyScrolled = !!target.scrollLeft;
527
+ const cell = target.closest('[data-cell]');
528
+ // Leave keys alone while focus is on interactive content inside a cell.
529
+ if (!cell || (target !== cell && !target.hasAttribute('data-focus-target')))
530
+ return;
531
+ const row = Number(cell.dataset.row);
532
+ const col = Number(cell.dataset.col);
533
+ const lastRow = this.getPageRows().length;
534
+ const lastCol = this.getGridColumns().length - 1;
535
+ let next;
536
+ switch (event.key) {
537
+ case 'ArrowRight':
538
+ next = { row, col: Math.min(col + 1, lastCol) };
539
+ break;
540
+ case 'ArrowLeft':
541
+ next = { row, col: Math.max(col - 1, 0) };
542
+ break;
543
+ case 'ArrowDown':
544
+ next = { row: Math.min(row + 1, lastRow), col };
545
+ break;
546
+ case 'ArrowUp':
547
+ next = { row: Math.max(row - 1, 0), col };
548
+ break;
549
+ case 'Home':
550
+ next = { row: event.ctrlKey ? 0 : row, col: 0 };
551
+ break;
552
+ case 'End':
553
+ next = { row: event.ctrlKey ? lastRow : row, col: lastCol };
554
+ break;
555
+ case ' ':
556
+ if (row > 0 && this.selectionType === 'checkbox') {
557
+ event.preventDefault();
558
+ const pageRows = this.getPageRows();
559
+ this.onRowSelectClick(pageRows[row - 1], pageRows);
560
+ }
561
+ return;
562
+ case 'Enter':
563
+ if (row > 0) {
564
+ const pageRows = this.getPageRows();
565
+ const column = this.getGridColumns()[col]?.column;
566
+ if (column)
567
+ this.dispatchCellEvents(pageRows[row - 1], column, event);
568
+ }
569
+ return;
570
+ case 'c':
571
+ case 'C':
572
+ if ((event.ctrlKey || event.metaKey) && row > 0) {
573
+ window.navigator.clipboard?.writeText(cell.innerText).catch(() => { });
574
+ }
575
+ return;
576
+ default:
577
+ return;
578
+ }
579
+ event.preventDefault();
580
+ this.activeCell = next;
581
+ this.pendingFocus = true;
582
+ // The cell may already be active (an edge was reached): focus it anyway.
583
+ if (next.row === row && next.col === col) {
584
+ this.pendingFocus = false;
585
+ }
274
586
  };
275
587
  }
276
- onSelectChange(selectedRowKeys) {
277
- this.selectedRowKeys = selectedRowKeys;
278
- this.dispatchEvent(new CustomEvent('selection-change', {
279
- detail: {
280
- value: this.selectedRowKeys,
281
- isSelectAll: this.isSelectAll,
282
- },
283
- bubbles: true,
284
- composed: true,
285
- }));
588
+ // ── Lifecycle ────────────────────────────────────────────────────────────
589
+ disconnectedCallback() {
590
+ super.disconnectedCallback();
591
+ this.resizeObserver?.disconnect();
286
592
  }
287
- onCellClick(row, col, evt) {
288
- this.dispatchEvent(new CustomEvent('cell-click', {
289
- detail: {
290
- record: row,
291
- column: col,
292
- altKey: evt.altKey,
293
- ctrlKey: evt.ctrlKey,
294
- metaKey: evt.metaKey,
295
- shiftKey: evt.shiftKey,
296
- },
297
- bubbles: true,
298
- composed: true,
299
- }));
593
+ firstUpdated() {
594
+ if (typeof ResizeObserver !== 'undefined' && this.scrollContainer) {
595
+ this.resizeObserver = new ResizeObserver(() => this.updateScrollEdges());
596
+ this.resizeObserver.observe(this.scrollContainer);
597
+ }
598
+ this.updateScrollEdges();
300
599
  }
301
- get totalColumnsWidth() {
302
- let total = 0;
600
+ willUpdate(changed) {
601
+ if (!Number.isFinite(this.page) || this.page < 1) {
602
+ this.page = 1;
603
+ }
604
+ // Filtering the data can leave the current page past the end.
605
+ // An empty data set (for example before the first load) keeps the requested page.
606
+ if (this.paginate &&
607
+ !this.managed &&
608
+ changed.has('data') &&
609
+ this.data?.length) {
610
+ const lastPage = Math.max(1, Math.ceil((this.data?.length ?? 0) / this.pageSize));
611
+ if (this.page > lastPage)
612
+ this.page = lastPage;
613
+ }
614
+ if (changed.has('data') && !this.managed) {
615
+ this.allPagesSelected = false;
616
+ }
617
+ const rowCount = this.getPageRows().length;
618
+ const colCount = this.getGridColumns().length;
619
+ const row = Math.min(this.activeCell.row, rowCount);
620
+ const col = Math.min(this.activeCell.col, Math.max(0, colCount - 1));
621
+ if (row !== this.activeCell.row || col !== this.activeCell.col) {
622
+ this.activeCell = { row, col };
623
+ }
624
+ }
625
+ updated(changed) {
626
+ if (changed.has('columns') || changed.has('data')) {
627
+ this.updateScrollEdges();
628
+ }
629
+ if (this.pendingFocus) {
630
+ this.pendingFocus = false;
631
+ this.getFocusTarget(this.activeCell.row, this.activeCell.col)?.focus();
632
+ }
633
+ }
634
+ // ── Private methods ──────────────────────────────────────────────────────
635
+ /** Columns in visual order: checkbox, start-pinned, scrolling, end-pinned. */
636
+ getGridColumns() {
637
+ const start = [];
638
+ const scroll = [];
639
+ const end = [];
303
640
  if (this.selectionType === 'checkbox') {
304
- total += 3; // approximate checkbox column width in rem
641
+ start.push({ placement: 'start' });
305
642
  }
306
- this.columns.forEach(col => {
307
- total += col.width ?? DEFAULT_CELL_WIDTH;
643
+ (this.columns ?? []).forEach(column => {
644
+ const placement = Table_1.getPlacement(column);
645
+ const entry = { column, placement };
646
+ if (placement === 'start')
647
+ start.push(entry);
648
+ else if (placement === 'end')
649
+ end.push(entry);
650
+ else
651
+ scroll.push(entry);
652
+ });
653
+ return [...start, ...scroll, ...end];
654
+ }
655
+ static getPlacement(column) {
656
+ if (column.fixed === true || column.fixed === 'start')
657
+ return 'start';
658
+ if (column.fixed === 'end')
659
+ return 'end';
660
+ return 'scroll';
661
+ }
662
+ static getAlign(column) {
663
+ return column.align ?? (column.type === 'number' ? 'end' : 'start');
664
+ }
665
+ static getWidth(column) {
666
+ const width = Number.parseFloat(String(column.width ?? ''));
667
+ return Number.isFinite(width) && width > 0 ? width : DEFAULT_CELL_WIDTH;
668
+ }
669
+ get totalColumnsWidth() {
670
+ let total = this.selectionType === 'checkbox' ? CHECKBOX_CELL_WIDTH : 0;
671
+ (this.columns ?? []).forEach(col => {
672
+ total += Table_1.getWidth(col);
308
673
  });
309
674
  return total;
310
675
  }
676
+ isColumnSortable(column) {
677
+ return this.sortable && column.sortable !== false;
678
+ }
679
+ /** Total item count across pages, or `undefined` when it is unknown. */
311
680
  getTotalItems() {
312
- if (this.paginate && !this.managed && this.data)
313
- return this.data.length;
314
- return this.totalItems ?? 0;
681
+ if (!this.managed)
682
+ return this.data?.length ?? 0;
683
+ return this.totalItems ?? undefined;
315
684
  }
316
- getSortIcon(col) {
317
- if (this.sortBy === col.name) {
318
- return this.sortOrder === 'asc'
319
- ? 'keyboard_arrow_up'
320
- : 'keyboard_arrow_down';
685
+ /** Rows shown on the current page, sorted and sliced unless the table is managed. */
686
+ getPageRows() {
687
+ let rows = [...(this.data ?? [])];
688
+ if (this.managed)
689
+ return rows;
690
+ if (this.sortable && this.sortBy) {
691
+ const direction = this.sortOrder === 'desc' ? -1 : 1;
692
+ const key = this.sortBy;
693
+ rows = rows.sort((a, b) => Table_1.compare(a?.[key], b?.[key]) * direction);
694
+ }
695
+ if (this.paginate) {
696
+ rows = rows.slice((this.page - 1) * this.pageSize, this.page * this.pageSize);
321
697
  }
322
- return 'unfold_more';
698
+ return rows;
699
+ }
700
+ /** Compares numbers by value and everything else as text with natural number order. */
701
+ static compare(a, b) {
702
+ if (a === b)
703
+ return 0;
704
+ if (a === undefined || a === null || a === '')
705
+ return 1;
706
+ if (b === undefined || b === null || b === '')
707
+ return -1;
708
+ if (typeof a === 'number' && typeof b === 'number')
709
+ return a - b;
710
+ return collator.compare(String(a), String(b));
711
+ }
712
+ getRowKey(row) {
713
+ return row?.[this.keyField];
323
714
  }
324
715
  onSortClick(col) {
325
716
  if (this.sortBy === col.name) {
@@ -328,6 +719,7 @@ let Table = class Table extends i$1 {
328
719
  }
329
720
  else {
330
721
  this.sortBy = '';
722
+ this.sortOrder = 'asc';
331
723
  }
332
724
  }
333
725
  else {
@@ -340,212 +732,465 @@ let Table = class Table extends i$1 {
340
732
  composed: true,
341
733
  }));
342
734
  }
343
- renderHeader() {
344
- const fixedCols = [];
345
- const scrollCols = [];
346
- if (this.selectionType === 'checkbox') {
347
- fixedCols.push(b `
348
- <div class="col col-checkbox center">
349
- <div class="col-content">
350
- <wc-checkbox
351
- class="checkbox"
352
- .value=${this.isSelectAll}
353
- .indeterminate=${this.isSelectAllIntermediate}
354
- @change=${this.onSelectAllClick}
355
- ></wc-checkbox>
356
- </div>
357
- </div>
358
- `);
735
+ onSelectAllClick(pageRows) {
736
+ const pageKeys = pageRows.map(row => this.getRowKey(row));
737
+ const allSelected = pageKeys.length > 0 &&
738
+ pageKeys.every(key => this.selectedRowKeys.includes(key));
739
+ const next = allSelected
740
+ ? this.selectedRowKeys.filter(key => !pageKeys.includes(key))
741
+ : [...new Set([...this.selectedRowKeys, ...pageKeys])];
742
+ this.allPagesSelected = false;
743
+ this.onSelectChange(next, pageRows);
744
+ }
745
+ onRowSelectClick(row, pageRows) {
746
+ const key = this.getRowKey(row);
747
+ const next = this.selectedRowKeys.includes(key)
748
+ ? this.selectedRowKeys.filter(rowKey => rowKey !== key)
749
+ : [...this.selectedRowKeys, key];
750
+ this.allPagesSelected = false;
751
+ this.onSelectChange(next, pageRows);
752
+ }
753
+ selectAllPages(pageRows) {
754
+ // Without the full data set (managed mode), the flag tells the owner to act on every item.
755
+ const keys = this.managed
756
+ ? [
757
+ ...new Set([
758
+ ...this.selectedRowKeys,
759
+ ...pageRows.map(row => this.getRowKey(row)),
760
+ ]),
761
+ ]
762
+ : (this.data ?? []).map(row => this.getRowKey(row));
763
+ this.allPagesSelected = true;
764
+ this.onSelectChange(keys, pageRows);
765
+ }
766
+ clearSelection() {
767
+ this.allPagesSelected = false;
768
+ this.onSelectChange([], this.getPageRows());
769
+ }
770
+ onSelectChange(selectedRowKeys, pageRows) {
771
+ this.selectedRowKeys = selectedRowKeys;
772
+ const isSelectAll = pageRows.length > 0 &&
773
+ pageRows.every(row => selectedRowKeys.includes(this.getRowKey(row)));
774
+ this.dispatchEvent(new CustomEvent('selection-change', {
775
+ detail: {
776
+ value: this.selectedRowKeys,
777
+ isSelectAll,
778
+ allPages: this.allPagesSelected,
779
+ },
780
+ bubbles: true,
781
+ composed: true,
782
+ }));
783
+ }
784
+ onCellClick(row, col, evt) {
785
+ const selection = window.getSelection();
786
+ if (selection?.type === 'Range')
787
+ return;
788
+ this.dispatchCellEvents(row, col, evt);
789
+ }
790
+ dispatchCellEvents(row, col, evt) {
791
+ this.dispatchEvent(new CustomEvent('cell-click', {
792
+ detail: {
793
+ record: row,
794
+ column: col,
795
+ altKey: evt.altKey,
796
+ ctrlKey: evt.ctrlKey,
797
+ metaKey: evt.metaKey,
798
+ shiftKey: evt.shiftKey,
799
+ },
800
+ bubbles: true,
801
+ composed: true,
802
+ }));
803
+ this.dispatchEvent(new CustomEvent('row-click', {
804
+ detail: { record: row },
805
+ bubbles: true,
806
+ composed: true,
807
+ }));
808
+ }
809
+ onPage(event) {
810
+ event.stopPropagation();
811
+ this.page = event.detail.page;
812
+ this.pageSize = event.detail.pageSize;
813
+ this.dispatchEvent(new CustomEvent('page', {
814
+ detail: { page: this.page, pageSize: this.pageSize },
815
+ bubbles: true,
816
+ composed: true,
817
+ }));
818
+ }
819
+ updateScrollEdges() {
820
+ const el = this.scrollContainer;
821
+ if (!el)
822
+ return;
823
+ // scrollLeft is negative in right-to-left layouts; the magnitude is what matters.
824
+ const scrolled = Math.abs(el.scrollLeft);
825
+ this.scrolledFromStart = scrolled > 0;
826
+ this.scrolledFromEnd = scrolled + el.clientWidth < el.scrollWidth - 1;
827
+ }
828
+ getCell(row, col) {
829
+ return (this.renderRoot.querySelector(`[data-cell][data-row="${row}"][data-col="${col}"]`) ?? null);
830
+ }
831
+ /** The element that takes focus for a cell: its sort button, or the cell itself. */
832
+ getFocusTarget(row, col) {
833
+ const cell = this.getCell(row, col);
834
+ return cell?.querySelector('[data-focus-target]') ?? cell;
835
+ }
836
+ tabIndexFor(row, col) {
837
+ return this.activeCell.row === row && this.activeCell.col === col
838
+ ? '0'
839
+ : '-1';
840
+ }
841
+ // ── Render helpers ───────────────────────────────────────────────────────
842
+ renderCellContent(row, column) {
843
+ if (column.template) {
844
+ const content = column.template(row, column);
845
+ return b `<div class="cell-template">
846
+ ${typeof content === 'string' ? o(content) : content}
847
+ </div>`;
359
848
  }
360
- this.columns.forEach(col => {
361
- const colWidth = col.width
362
- ? parseInt(String(col.width), 10)
363
- : DEFAULT_CELL_WIDTH;
364
- const colEl = b `
849
+ const value = row?.[column.name];
850
+ return b `<div class="cell-text" title=${value ?? ''}>${value}</div>`;
851
+ }
852
+ cellClasses(entry, extra = {}) {
853
+ const { column } = entry;
854
+ return e$1({
855
+ cell: true,
856
+ 'cell-checkbox': !column,
857
+ [`align-${column ? Table_1.getAlign(column) : 'center'}`]: true,
858
+ numeric: column?.type === 'number',
859
+ wrap: !!column?.wrap,
860
+ ...extra,
861
+ });
862
+ }
863
+ cellStyle(entry) {
864
+ const width = entry.column
865
+ ? Table_1.getWidth(entry.column)
866
+ : CHECKBOX_CELL_WIDTH;
867
+ return o$1({ width: `${width}rem` });
868
+ }
869
+ /** Splits a row's cells into the start-pinned, scrolling and end-pinned groups. */
870
+ renderRowGroups(columns, renderCell) {
871
+ const groups = {
872
+ start: [],
873
+ scroll: [],
874
+ end: [],
875
+ };
876
+ columns.forEach((entry, index) => {
877
+ groups[entry.placement].push(renderCell(entry, index));
878
+ });
879
+ return b `
880
+ ${groups.start.length
881
+ ? b `<div class="columns pinned-group pinned-group-start" role="none">
882
+ ${groups.start}
883
+ </div>`
884
+ : A}
885
+ <div class="columns scroll-group" role="none">${groups.scroll}</div>
886
+ ${groups.end.length
887
+ ? b `<div class="columns pinned-group pinned-group-end" role="none">
888
+ ${groups.end}
889
+ </div>`
890
+ : A}
891
+ `;
892
+ }
893
+ renderHeader(columns, pageRows) {
894
+ const pageKeys = pageRows.map(row => this.getRowKey(row));
895
+ const selectedOnPage = pageKeys.filter(key => this.selectedRowKeys.includes(key)).length;
896
+ const allOnPage = pageKeys.length > 0 && selectedOnPage === pageKeys.length;
897
+ return b `
898
+ <div class="header" role="rowgroup">
365
899
  <div
366
- class=${e({ col: true, sort: this.sortBy === col.name })}
367
- style="width: ${colWidth}rem"
900
+ class="row"
901
+ role="row"
902
+ aria-rowindex="1"
903
+ style="--_row-min-width: ${this.totalColumnsWidth}rem"
368
904
  >
369
- <div class="col-content">
370
- <div class="col-text">${col.label}</div>
371
- <div class="col-actions">
372
- ${this.sortable
373
- ? b `
374
- <wc-button
375
- class="col-action"
376
- color="secondary"
377
- variant="text"
378
- @click=${() => this.onSortClick(col)}
379
- >
380
- <wc-icon
381
- slot="icon"
382
- name=${this.getSortIcon(col)}
383
- ></wc-icon>
384
- </wc-button>
385
- `
386
- : A}
387
- </div>
388
- </div>
389
- </div>
390
- `;
391
- if (col.fixed) {
392
- fixedCols.push(colEl);
905
+ ${this.renderRowGroups(columns, (entry, index) => {
906
+ const { column } = entry;
907
+ if (!column) {
908
+ return b `
909
+ <div
910
+ class=${this.cellClasses(entry)}
911
+ style=${this.cellStyle(entry)}
912
+ role="columnheader"
913
+ data-cell
914
+ data-row="0"
915
+ data-col=${index}
916
+ tabindex=${this.tabIndexFor(0, index)}
917
+ aria-label="Select all rows on this page"
918
+ @keydown=${(event) => {
919
+ if (event.key === ' ' || event.key === 'Enter') {
920
+ event.preventDefault();
921
+ this.onSelectAllClick(pageRows);
922
+ }
923
+ }}
924
+ >
925
+ <wc-checkbox
926
+ class="checkbox"
927
+ tabindex="-1"
928
+ aria-label="Select all rows on this page"
929
+ .checked=${allOnPage}
930
+ .indeterminate=${selectedOnPage > 0 && !allOnPage}
931
+ ?disabled=${pageKeys.length === 0}
932
+ @change=${() => this.onSelectAllClick(pageRows)}
933
+ ></wc-checkbox>
934
+ </div>
935
+ `;
393
936
  }
394
- else {
395
- scrollCols.push(colEl);
937
+ const sortable = this.isColumnSortable(column);
938
+ const sorted = this.sortBy === column.name;
939
+ let ariaSort;
940
+ if (sortable) {
941
+ if (!sorted)
942
+ ariaSort = 'none';
943
+ else
944
+ ariaSort =
945
+ this.sortOrder === 'asc' ? 'ascending' : 'descending';
396
946
  }
397
- });
398
- return b `
399
- <div class="header">
400
- <div class="row" style="min-width: ${this.totalColumnsWidth}rem">
401
- <div class="fixed-columns columns-container">${fixedCols}</div>
402
- <div class="scrollable-columns columns-container">${scrollCols}</div>
947
+ return b `
948
+ <div
949
+ class=${this.cellClasses(entry, { sorted, sortable })}
950
+ style=${this.cellStyle(entry)}
951
+ role="columnheader"
952
+ aria-sort=${ariaSort ?? A}
953
+ data-cell
954
+ data-row="0"
955
+ data-col=${index}
956
+ tabindex=${sortable ? A : this.tabIndexFor(0, index)}
957
+ >
958
+ ${sortable
959
+ ? b `
960
+ <button
961
+ type="button"
962
+ class="sort-button"
963
+ data-focus-target
964
+ tabindex=${this.tabIndexFor(0, index)}
965
+ @click=${() => this.onSortClick(column)}
966
+ >
967
+ <span class="header-label">${column.label}</span>
968
+ <wc-icon
969
+ class="sort-icon"
970
+ aria-hidden="true"
971
+ name=${sorted && this.sortOrder === 'desc'
972
+ ? 'arrow_downward'
973
+ : 'arrow_upward'}
974
+ ></wc-icon>
975
+ </button>
976
+ `
977
+ : b `<span class="header-label">${column.label}</span>`}
978
+ </div>
979
+ `;
980
+ })}
403
981
  </div>
982
+ ${this.loading && pageRows.length
983
+ ? b `<wc-linear-progress
984
+ class="loading-bar"
985
+ indeterminate
986
+ aria-label="Loading"
987
+ ></wc-linear-progress>`
988
+ : A}
404
989
  </div>
405
990
  `;
406
991
  }
407
- renderBody() {
408
- let data = [...this.data];
409
- if (!this.managed) {
410
- if (this.sortable && this.sortBy) {
411
- data = data.sort((a, b) => {
412
- if (a[this.sortBy] < b[this.sortBy])
413
- return this.sortOrder === 'asc' ? -1 : 1;
414
- if (a[this.sortBy] > b[this.sortBy])
415
- return this.sortOrder === 'asc' ? 1 : -1;
416
- return 0;
417
- });
418
- }
419
- if (this.paginate) {
420
- data = data.slice((this.page - 1) * this.pageSize, this.page * this.pageSize);
421
- }
422
- }
423
- const rows = data.map(row => {
424
- const fixedCols = [];
425
- const scrollCols = [];
426
- if (this.selectionType === 'checkbox') {
427
- fixedCols.push(b `
428
- <div class="col center col-checkbox">
429
- <div class="col-content">
430
- <wc-checkbox
431
- class="checkbox"
432
- .value=${this.selectedRowKeys.includes(row[this.keyField])}
433
- @change=${() => this.onRowSelectClick(row)}
434
- ></wc-checkbox>
435
- </div>
436
- </div>
437
- `);
438
- }
439
- this.columns.forEach(column => {
440
- const colWidth = column.width
441
- ? parseInt(String(column.width), 10)
442
- : DEFAULT_CELL_WIDTH;
443
- const colEl = b `
444
- <div
445
- tabindex="0"
446
- class=${e({
447
- col: true,
448
- 'col-hover': this.hoveredCell.row === row &&
449
- this.hoveredCell.column === column,
450
- })}
451
- style="width: ${colWidth}rem"
452
- @mouseover=${() => this.onCellMouseOverThrottled(row, column)}
453
- @focus=${() => this.onCellMouseOverThrottled(row, column)}
454
- @keydown=${(event) => {
455
- if ((event.ctrlKey || event.metaKey) && event.key === 'c') {
456
- const elem = event.target;
457
- window.navigator.clipboard
458
- .writeText(elem.innerText)
459
- .catch(() => { });
460
- }
461
- }}
462
- @click=${(evt) => {
463
- const selection = window.getSelection();
464
- if (selection?.type !== 'Range') {
465
- this.onCellClick(row, column, evt);
466
- }
467
- }}
468
- >
469
- <div class="col-content">
470
- ${column.template
471
- ? b `<div class="col-template">
472
- ${o(column.template(row, column))}
473
- </div>`
474
- : b `<div class="col-text" title=${row?.[column.name] ?? ''}>
475
- ${row?.[column.name]}
476
- </div>`}
477
- </div>
478
- </div>
479
- `;
480
- if (column.fixed) {
481
- fixedCols.push(colEl);
482
- }
483
- else {
484
- scrollCols.push(colEl);
485
- }
486
- });
992
+ renderBody(columns, pageRows) {
993
+ const rowOffset = this.paginate ? (this.page - 1) * this.pageSize : 0;
994
+ const selectable = this.selectionType === 'checkbox';
995
+ const rows = pageRows.map((row, rowIndex) => {
996
+ const gridRow = rowIndex + 1;
997
+ const selected = selectable && this.selectedRowKeys.includes(this.getRowKey(row));
487
998
  return b `
488
999
  <div
489
- class=${e({
490
- row: true,
491
- 'row-hover': this.hoveredCell.row === row,
492
- })}
493
- style="min-width: ${this.totalColumnsWidth}rem"
1000
+ class=${e$1({ row: true, selected })}
1001
+ role="row"
1002
+ aria-rowindex=${rowOffset + rowIndex + 2}
1003
+ aria-selected=${selectable ? String(selected) : A}
1004
+ style="--_row-min-width: ${this.totalColumnsWidth}rem"
494
1005
  >
495
- <div class="fixed-columns columns-container">${fixedCols}</div>
496
- <div class="scrollable-columns columns-container">${scrollCols}</div>
1006
+ ${this.renderRowGroups(columns, (entry, index) => {
1007
+ const { column } = entry;
1008
+ if (!column) {
1009
+ return b `
1010
+ <div
1011
+ class=${this.cellClasses(entry)}
1012
+ style=${this.cellStyle(entry)}
1013
+ role="gridcell"
1014
+ data-cell
1015
+ data-row=${gridRow}
1016
+ data-col=${index}
1017
+ tabindex=${this.tabIndexFor(gridRow, index)}
1018
+ >
1019
+ <wc-checkbox
1020
+ class="checkbox"
1021
+ tabindex="-1"
1022
+ aria-label="Select row"
1023
+ .checked=${selected}
1024
+ @change=${() => this.onRowSelectClick(row, pageRows)}
1025
+ ></wc-checkbox>
1026
+ </div>
1027
+ `;
1028
+ }
1029
+ // Enter on a cell is handled by the grid's keydown listener.
1030
+ /* eslint-disable lit-a11y/click-events-have-key-events */
1031
+ return b `
1032
+ <div
1033
+ class=${this.cellClasses(entry)}
1034
+ style=${this.cellStyle(entry)}
1035
+ role="gridcell"
1036
+ data-cell
1037
+ data-row=${gridRow}
1038
+ data-col=${index}
1039
+ tabindex=${this.tabIndexFor(gridRow, index)}
1040
+ @click=${(evt) => this.onCellClick(row, column, evt)}
1041
+ >
1042
+ ${this.renderCellContent(row, column)}
1043
+ </div>
1044
+ `;
1045
+ /* eslint-enable lit-a11y/click-events-have-key-events */
1046
+ })}
497
1047
  </div>
498
1048
  `;
499
1049
  });
500
- return b `<div class="body">${rows}</div>`;
1050
+ return b `<div class="body" role="rowgroup">${rows}</div>`;
1051
+ }
1052
+ renderSkeletonBody(columns) {
1053
+ const count = this.paginate ? Math.min(this.pageSize, 10) : SKELETON_ROWS;
1054
+ return b `
1055
+ <div class="body" role="rowgroup">
1056
+ ${Array.from({ length: count }, (_, rowIndex) => b `
1057
+ <div
1058
+ class="row skeleton-row"
1059
+ role="row"
1060
+ style="--_row-min-width: ${this.totalColumnsWidth}rem"
1061
+ >
1062
+ ${this.renderRowGroups(columns, (entry, index) => b `
1063
+ <div
1064
+ class=${this.cellClasses(entry)}
1065
+ style=${this.cellStyle(entry)}
1066
+ role="gridcell"
1067
+ >
1068
+ <wc-skeleton
1069
+ class="skeleton-bar"
1070
+ visible
1071
+ style=${entry.column
1072
+ ? `inline-size: ${40 + ((rowIndex * 7 + index * 13) % 45)}%`
1073
+ : A}
1074
+ ></wc-skeleton>
1075
+ </div>
1076
+ `)}
1077
+ </div>
1078
+ `)}
1079
+ </div>
1080
+ `;
501
1081
  }
502
1082
  renderEmptyState() {
503
1083
  return b `
504
1084
  <div class="empty-table">
505
1085
  <wc-empty-state
506
- class="empty-state content-center"
1086
+ class="empty-state"
507
1087
  headline=${this.emptyStateHeadline}
508
1088
  description=${this.emptyStateDescription}
509
1089
  ></wc-empty-state>
510
1090
  </div>
511
1091
  `;
512
1092
  }
1093
+ renderBulkBar(pageRows) {
1094
+ if (this.selectionType !== 'checkbox')
1095
+ return A;
1096
+ const count = this.selectedRowKeys.length;
1097
+ if (count === 0)
1098
+ return A;
1099
+ const total = this.getTotalItems();
1100
+ const shownCount = this.allPagesSelected && total !== undefined ? total : count;
1101
+ const pageFullySelected = pageRows.length > 0 &&
1102
+ pageRows.every(row => this.selectedRowKeys.includes(this.getRowKey(row)));
1103
+ const canSelectAllPages = this.paginate &&
1104
+ !this.allPagesSelected &&
1105
+ pageFullySelected &&
1106
+ total !== undefined &&
1107
+ total > count;
1108
+ return b `
1109
+ <div class="bulk-bar" role="region" aria-label="Selection">
1110
+ <span class="bulk-count" aria-live="polite"
1111
+ >${shownCount} selected</span
1112
+ >
1113
+ ${canSelectAllPages
1114
+ ? b `<wc-button
1115
+ class="bulk-select-all"
1116
+ variant="text"
1117
+ size="sm"
1118
+ @click=${() => this.selectAllPages(pageRows)}
1119
+ >Select all ${total}</wc-button
1120
+ >`
1121
+ : A}
1122
+ <span class="bulk-spacer"></span>
1123
+ <slot name="bulk-actions"></slot>
1124
+ <wc-button
1125
+ class="bulk-clear"
1126
+ variant="text"
1127
+ size="sm"
1128
+ @click=${this.clearSelection}
1129
+ >Clear</wc-button
1130
+ >
1131
+ </div>
1132
+ `;
1133
+ }
513
1134
  renderPagination() {
514
1135
  if (!this.paginate)
515
1136
  return A;
516
1137
  return b `
517
- <wc-pagination
518
- .page=${this.page}
519
- .pageSize=${this.pageSize}
520
- .totalItems=${this.getTotalItems()}
521
- @page=${(e) => {
522
- this.page = e.detail.page;
523
- this.pageSize = e.detail.pageSize;
524
- this.dispatchEvent(new CustomEvent('page', {
525
- detail: { page: this.page, pageSize: this.pageSize },
526
- bubbles: true,
527
- composed: true,
528
- }));
529
- }}
530
- ></wc-pagination>
1138
+ <div class="table-footer">
1139
+ <wc-pagination
1140
+ .page=${this.page}
1141
+ .pageSize=${this.pageSize}
1142
+ .totalItems=${this.getTotalItems()}
1143
+ .hasNext=${this.hasNext}
1144
+ .variant=${this.paginationVariant}
1145
+ .pageSizes=${this.pageSizes ?? [10, 25, 50, 100]}
1146
+ @page=${this.onPage}
1147
+ ></wc-pagination>
1148
+ </div>
531
1149
  `;
532
1150
  }
1151
+ // ── Render ───────────────────────────────────────────────────────────────
533
1152
  render() {
534
- const tableClasses = {
535
- table: true,
536
- sortable: this.sortable,
537
- paginate: this.paginate,
538
- 'horizontal-scrolled': this.isHorizontallyScrolled,
539
- };
1153
+ const columns = this.getGridColumns();
1154
+ const pageRows = this.getPageRows();
1155
+ const total = this.getTotalItems();
1156
+ const hasRows = pageRows.length > 0;
1157
+ let body;
1158
+ if (hasRows)
1159
+ body = this.renderBody(columns, pageRows);
1160
+ else if (this.loading)
1161
+ body = this.renderSkeletonBody(columns);
1162
+ else
1163
+ body = this.renderEmptyState();
540
1164
  return b `
541
- <div class=${e(tableClasses)}>
542
- <div class="table-scroll-container" @scroll=${this.onScrollContainer}>
543
- ${this.renderHeader()}
544
- ${this.data && this.data.length
545
- ? this.renderBody()
546
- : this.renderEmptyState()}
1165
+ <div
1166
+ class=${e$1({
1167
+ table: true,
1168
+ 'scrolled-from-start': this.scrolledFromStart,
1169
+ 'scrolled-from-end': this.scrolledFromEnd,
1170
+ 'has-selection': this.selectedRowKeys.length > 0,
1171
+ 'has-footer': this.paginate,
1172
+ })}
1173
+ >
1174
+ ${this.renderBulkBar(pageRows)}
1175
+ <div
1176
+ class="table-scroll-container"
1177
+ role="grid"
1178
+ aria-label=${this.label || A}
1179
+ aria-busy=${this.loading ? 'true' : A}
1180
+ aria-multiselectable=${this.selectionType === 'checkbox'
1181
+ ? 'true'
1182
+ : A}
1183
+ aria-rowcount=${this.paginate && total !== undefined
1184
+ ? total + 1
1185
+ : A}
1186
+ aria-colcount=${columns.length}
1187
+ @scroll=${this.onScrollContainer}
1188
+ @focusin=${this.onGridFocusIn}
1189
+ @keydown=${this.onGridKeydown}
1190
+ >
1191
+ ${this.renderHeader(columns, pageRows)} ${body}
547
1192
  </div>
548
- <div class="table-footer">${this.renderPagination()}</div>
1193
+ ${this.renderPagination()}
549
1194
  </div>
550
1195
  `;
551
1196
  }
@@ -587,9 +1232,30 @@ __decorate([
587
1232
  __decorate([
588
1233
  n({ type: Number, attribute: 'page-size' })
589
1234
  ], Table.prototype, "pageSize", void 0);
1235
+ __decorate([
1236
+ n({ type: Array, attribute: 'page-sizes' })
1237
+ ], Table.prototype, "pageSizes", void 0);
590
1238
  __decorate([
591
1239
  n({ type: Number, attribute: 'total-items' })
592
1240
  ], Table.prototype, "totalItems", void 0);
1241
+ __decorate([
1242
+ n({ type: Boolean, attribute: 'has-next' })
1243
+ ], Table.prototype, "hasNext", void 0);
1244
+ __decorate([
1245
+ n({ type: String, attribute: 'pagination-variant' })
1246
+ ], Table.prototype, "paginationVariant", void 0);
1247
+ __decorate([
1248
+ n({ type: String, reflect: true })
1249
+ ], Table.prototype, "density", void 0);
1250
+ __decorate([
1251
+ n({ type: Boolean, reflect: true })
1252
+ ], Table.prototype, "striped", void 0);
1253
+ __decorate([
1254
+ n({ type: Boolean, reflect: true })
1255
+ ], Table.prototype, "loading", void 0);
1256
+ __decorate([
1257
+ n({ type: String })
1258
+ ], Table.prototype, "label", void 0);
593
1259
  __decorate([
594
1260
  n({ type: String, attribute: 'empty-state-headline' })
595
1261
  ], Table.prototype, "emptyStateHeadline", void 0);
@@ -598,17 +1264,20 @@ __decorate([
598
1264
  ], Table.prototype, "emptyStateDescription", void 0);
599
1265
  __decorate([
600
1266
  r()
601
- ], Table.prototype, "hoveredCell", void 0);
1267
+ ], Table.prototype, "allPagesSelected", void 0);
602
1268
  __decorate([
603
1269
  r()
604
- ], Table.prototype, "isSelectAll", void 0);
1270
+ ], Table.prototype, "scrolledFromStart", void 0);
605
1271
  __decorate([
606
1272
  r()
607
- ], Table.prototype, "isSelectAllIntermediate", void 0);
1273
+ ], Table.prototype, "scrolledFromEnd", void 0);
608
1274
  __decorate([
609
1275
  r()
610
- ], Table.prototype, "isHorizontallyScrolled", void 0);
611
- Table = __decorate([
1276
+ ], Table.prototype, "activeCell", void 0);
1277
+ __decorate([
1278
+ e('.table-scroll-container')
1279
+ ], Table.prototype, "scrollContainer", void 0);
1280
+ Table = Table_1 = __decorate([
612
1281
  IndividualComponent
613
1282
  ], Table);
614
1283