@redvars/peacock 3.15.0 → 3.16.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.
@@ -5,164 +5,386 @@
5
5
  :host {
6
6
  display: block;
7
7
  height: 100%;
8
- min-height: 20em;
8
+ min-width: 0;
9
+ --table-row-height: 3rem;
9
10
  --table-border-color: var(--color-outline-variant);
10
- --table-border: 1px solid var(--table-border-color);
11
- --table-col-content-padding: var(--spacing-150, 0.75rem)
12
- var(--spacing-200, 1rem);
11
+ --table-cell-padding-inline: var(--spacing-200, 1rem);
12
+ --table-header-background: var(--color-surface, #fff);
13
+ --table-background: var(--color-surface, #fff);
14
+ --_table-checkbox-width: 3rem;
15
+ --_table-edge-shadow: color-mix(in srgb, var(--color-shadow) 14%, transparent);
16
+ }
17
+
18
+ :host([density='compact']) {
19
+ --table-row-height: 2.25rem;
20
+ --table-cell-padding-inline: var(--spacing-150, 0.75rem);
21
+ }
22
+
23
+ :host([density='comfortable']) {
24
+ --table-row-height: 3.5rem;
13
25
  }
14
26
 
15
27
  .table {
28
+ position: relative;
16
29
  height: 100%;
17
30
  display: flex;
18
31
  flex-direction: column;
19
- background: var(--color-surface, #fff);
32
+ background: var(--table-background);
33
+ color: var(--color-on-surface);
20
34
 
21
35
  @include mixin.get-typography-not-important('body-medium');
36
+ }
37
+
38
+ .table-scroll-container {
39
+ // Wide rows scroll inside the table instead of widening the page around it.
40
+ contain: inline-size;
41
+ position: relative;
42
+ flex: 1 1 auto;
43
+ min-height: 0;
44
+ overflow: auto;
45
+ outline: none;
46
+ }
47
+
48
+ // ── Rows and cells ──────────────────────────────────────────────────────────
49
+
50
+ .row {
51
+ --_cell-background: var(--table-background);
52
+
53
+ display: flex;
54
+ width: max-content;
55
+ min-width: 100%;
56
+ }
22
57
 
23
- .table-scroll-container {
24
- position: relative;
25
- overflow: auto;
26
- height: 100%;
58
+ .columns {
59
+ display: flex;
60
+ }
61
+
62
+ .scroll-group {
63
+ flex: 1 0 auto;
64
+ // Keeps positioned cell content (tags, buttons) below the pinned columns.
65
+ isolation: isolate;
66
+
67
+ > .cell:last-child {
68
+ flex-grow: 1;
27
69
  }
70
+ }
71
+
72
+ .pinned-group {
73
+ position: sticky;
74
+ z-index: 1;
75
+ flex: none;
76
+ }
77
+
78
+ .pinned-group-start {
79
+ inset-inline-start: 0;
80
+ }
28
81
 
29
- .empty-table {
30
- height: 80%;
31
- display: flex;
32
- align-items: center;
82
+ .pinned-group-end {
83
+ inset-inline-end: 0;
84
+ }
85
+
86
+ .cell {
87
+ position: relative;
88
+ display: flex;
89
+ align-items: center;
90
+ flex-shrink: 0;
91
+ min-width: 0;
92
+ min-height: var(--table-row-height);
93
+ padding-inline: var(--table-cell-padding-inline);
94
+ background: var(--_cell-background);
95
+ border-bottom: 1px solid var(--table-border-color);
96
+
97
+ &:focus-visible {
98
+ outline: 2px solid var(--color-primary);
99
+ outline-offset: -2px;
100
+ }
101
+
102
+ &.align-start {
103
+ justify-content: flex-start;
104
+ text-align: start;
105
+ }
106
+
107
+ &.align-center {
33
108
  justify-content: center;
109
+ text-align: center;
110
+ }
34
111
 
35
- .empty-state {
36
- width: 10rem;
37
- }
112
+ &.align-end {
113
+ justify-content: flex-end;
114
+ text-align: end;
115
+ }
116
+
117
+ &.numeric {
118
+ font-variant-numeric: tabular-nums;
38
119
  }
39
120
 
40
- wc-pagination {
41
- border-top: 1px solid var(--table-border-color);
121
+ &.cell-checkbox {
122
+ width: var(--_table-checkbox-width);
123
+ padding-inline: 0;
124
+ }
125
+ }
126
+
127
+ .cell-text {
128
+ min-width: 0;
129
+ overflow: hidden;
130
+ white-space: nowrap;
131
+ text-overflow: ellipsis;
132
+
133
+ .wrap & {
134
+ padding-block: var(--spacing-100, 0.5rem);
135
+ white-space: normal;
136
+ overflow-wrap: anywhere;
137
+ }
138
+ }
139
+
140
+ .cell-template {
141
+ display: flex;
142
+ align-items: center;
143
+ min-width: 0;
144
+ max-width: 100%;
145
+ }
146
+
147
+ // ── Header ──────────────────────────────────────────────────────────────────
148
+
149
+ .header {
150
+ position: sticky;
151
+ top: 0;
152
+ z-index: 3;
153
+
154
+ .row {
155
+ --_cell-background: var(--table-header-background);
42
156
  }
43
157
 
44
- &.horizontal-scrolled {
45
- .fixed-columns::after {
46
- box-shadow: 10px 0 20px -20px var(--color-outline) inset;
47
- content: ' ';
48
- height: 100%;
49
- position: absolute;
50
- top: 0;
51
- right: -20px;
52
- width: 20px;
158
+ .cell {
159
+ color: var(--color-on-surface-variant);
160
+
161
+ @include mixin.get-typography-not-important('label-large');
162
+
163
+ &.sortable {
164
+ padding-inline: 0;
53
165
  }
166
+
167
+ &.sorted {
168
+ color: var(--color-on-surface);
169
+ }
170
+ }
171
+
172
+ .header-label {
173
+ min-width: 0;
174
+ overflow: hidden;
175
+ white-space: nowrap;
176
+ text-overflow: ellipsis;
54
177
  }
55
178
  }
56
179
 
57
- .row {
180
+ .sort-button {
181
+ @include mixin.reset-button-styles;
182
+
58
183
  display: flex;
59
- box-sizing: border-box;
60
- width: max-content;
61
- min-width: 100%;
184
+ align-items: center;
185
+ justify-content: inherit;
186
+ gap: var(--spacing-050, 0.25rem);
187
+ align-self: stretch;
188
+ width: 100%;
189
+ min-width: 0;
190
+ padding-inline: var(--table-cell-padding-inline);
191
+ color: inherit;
192
+ font: inherit;
193
+ letter-spacing: inherit;
194
+ text-align: inherit;
195
+ cursor: pointer;
196
+
197
+ .align-end & {
198
+ flex-direction: row-reverse;
199
+ }
62
200
 
63
- .columns-container {
64
- display: flex;
201
+ &:hover {
202
+ background: color-mix(in srgb, var(--color-on-surface) 6%, transparent);
65
203
  }
66
204
 
67
- .col {
68
- margin: 0;
69
- color: var(--color-on-surface);
70
- flex-shrink: 0;
205
+ &:focus-visible {
206
+ outline: 2px solid var(--color-primary);
207
+ outline-offset: -2px;
208
+ }
209
+ }
71
210
 
72
- .col-content {
73
- display: flex;
74
- align-items: center;
75
- height: 100%;
211
+ .sort-icon {
212
+ flex: none;
213
+ --icon-size: 1.125rem;
214
+ font-size: 1.125rem;
215
+ opacity: 0;
216
+ transition: opacity var(--duration-short2, 100ms) ease;
76
217
 
77
- .col-text {
78
- padding: var(--table-col-content-padding);
79
- flex: 1;
80
- overflow: hidden;
81
- white-space: nowrap;
82
- text-overflow: ellipsis;
83
- }
218
+ .sort-button:hover &,
219
+ .sort-button:focus-visible & {
220
+ opacity: 0.6;
221
+ }
84
222
 
85
- .col-template {
86
- width: 100%;
87
- }
223
+ .sorted & {
224
+ opacity: 1;
225
+ }
226
+ }
88
227
 
89
- .col-action {
90
- --button-container-shape: 0;
91
- }
228
+ .loading-bar {
229
+ position: absolute;
230
+ inset-inline: 0;
231
+ bottom: 0;
232
+ --progress-height: 2px;
233
+ }
92
234
 
93
- .checkbox {
94
- padding: 0 var(--spacing-100, 0.5rem);
95
- }
96
- }
235
+ // ── Body ────────────────────────────────────────────────────────────────────
236
+
237
+ .body {
238
+ .cell {
239
+ cursor: pointer;
97
240
 
98
- &.center .col-content {
99
- justify-content: center;
241
+ &.cell-checkbox {
242
+ cursor: default;
100
243
  }
244
+ }
245
+
246
+ .row:hover {
247
+ --_cell-background: var(--color-surface-container-low);
248
+ }
249
+
250
+ .row.selected {
251
+ --_cell-background: color-mix(
252
+ in srgb,
253
+ var(--color-secondary-container) 55%,
254
+ var(--table-background)
255
+ );
101
256
 
102
- &:last-child {
103
- flex: 1;
257
+ > .columns:first-child > .cell:first-child {
258
+ box-shadow: inset 2px 0 0 var(--color-primary);
104
259
  }
105
260
  }
106
261
 
107
- .fixed-columns {
108
- position: sticky;
109
- left: 0;
262
+ .row.selected:hover {
263
+ --_cell-background: var(--color-secondary-container);
110
264
  }
111
265
 
112
- .scrollable-columns {
113
- flex: 0 0 auto;
266
+ .skeleton-row .cell {
267
+ cursor: default;
114
268
  }
115
269
  }
116
270
 
117
- .header {
118
- position: sticky;
271
+ :host([striped]) .body .row:nth-child(even):not(.selected) {
272
+ --_cell-background: color-mix(
273
+ in srgb,
274
+ var(--color-surface-container) 45%,
275
+ var(--table-background)
276
+ );
277
+
278
+ &:hover {
279
+ --_cell-background: var(--color-surface-container-low);
280
+ }
281
+ }
282
+
283
+ .skeleton-bar {
284
+ block-size: 0.75rem;
285
+ max-inline-size: 100%;
286
+ --skeleton-container-shape: var(--shape-corner-extra-small);
287
+
288
+ .cell-checkbox & {
289
+ inline-size: 1.125rem;
290
+ block-size: 1.125rem;
291
+ }
292
+ }
293
+
294
+ .checkbox {
295
+ display: flex;
296
+ }
297
+
298
+ // ── Edge shadows on pinned columns ──────────────────────────────────────────
299
+
300
+ .pinned-group-start::after,
301
+ .pinned-group-end::before {
302
+ content: '';
303
+ position: absolute;
119
304
  top: 0;
305
+ bottom: 0;
306
+ width: 0.75rem;
307
+ pointer-events: none;
308
+ opacity: 0;
309
+ transition: opacity var(--duration-short4, 200ms) ease;
310
+ }
311
+
312
+ .pinned-group-start::after {
313
+ inset-inline-end: -0.75rem;
314
+ background: linear-gradient(to right, var(--_table-edge-shadow), transparent);
315
+ }
120
316
 
121
- @include mixin.get-typography-not-important('label-medium');
317
+ .pinned-group-end::before {
318
+ inset-inline-start: -0.75rem;
319
+ background: linear-gradient(to left, var(--_table-edge-shadow), transparent);
320
+ }
321
+
322
+ .scrolled-from-start .pinned-group-start::after,
323
+ .scrolled-from-end .pinned-group-end::before {
324
+ opacity: 1;
325
+ }
122
326
 
123
- .col {
124
- background: var(--color-surface-variant, #f4f4f4);
327
+ // ── Selection bar ───────────────────────────────────────────────────────────
125
328
 
126
- &.sort {
127
- background: var(--color-secondary-container, #e8eaf6);
128
- }
329
+ .bulk-bar {
330
+ position: absolute;
331
+ top: 0;
332
+ inset-inline: var(--_table-checkbox-width) 0;
333
+ z-index: 4;
334
+ display: flex;
335
+ align-items: center;
336
+ gap: var(--spacing-100, 0.5rem);
337
+ height: var(--table-row-height);
338
+ padding-inline: var(--spacing-100, 0.5rem) var(--spacing-100, 0.5rem);
339
+ background: var(--color-secondary-container);
340
+ color: var(--color-on-secondary-container);
341
+ border-bottom: 1px solid var(--table-border-color);
342
+ // One line at any width: on a narrow table the actions scroll instead of wrapping.
343
+ overflow-x: auto;
344
+ scrollbar-width: none;
345
+ white-space: nowrap;
346
+
347
+ @include mixin.get-typography-not-important('label-large');
348
+
349
+ > *,
350
+ ::slotted(*) {
351
+ flex: none;
129
352
  }
130
353
  }
131
354
 
132
- .body {
133
- .row {
134
- .col {
135
- cursor: pointer;
136
- background: var(--color-surface, #fff);
137
- border-bottom: 1px solid var(--color-surface-variant, #f4f4f4);
138
-
139
- &.col-checkbox .col-content {
140
- border: 0;
141
- }
142
-
143
- .col-content {
144
- border: 2px solid transparent;
145
- border-bottom: 1px solid transparent;
146
-
147
- .col-text {
148
- text-wrap: wrap;
149
- }
150
- }
151
-
152
- &:focus {
153
- outline: none;
154
- border-bottom-color: var(--color-primary);
155
-
156
- .col-content {
157
- border-color: var(--color-primary);
158
- }
159
- }
160
- }
355
+ .bulk-count {
356
+ padding-inline-start: var(--spacing-050, 0.25rem);
357
+ white-space: nowrap;
358
+ font-variant-numeric: tabular-nums;
359
+ }
161
360
 
162
- &:hover {
163
- .col {
164
- background-color: var(--color-surface-container-low, #f8f8f8);
165
- }
166
- }
361
+ .bulk-spacer {
362
+ flex: 1;
363
+ }
364
+
365
+ ::slotted([slot='bulk-actions']) {
366
+ display: inline-flex;
367
+ align-items: center;
368
+ gap: var(--spacing-050, 0.25rem);
369
+ }
370
+
371
+ // ── Empty state and footer ──────────────────────────────────────────────────
372
+
373
+ .empty-table {
374
+ position: sticky;
375
+ inset-inline-start: 0;
376
+ display: flex;
377
+ align-items: center;
378
+ justify-content: center;
379
+ min-height: 16rem;
380
+ padding: var(--spacing-400, 2rem) var(--spacing-200, 1rem);
381
+
382
+ .empty-state {
383
+ max-width: 24rem;
167
384
  }
168
385
  }
386
+
387
+ .table-footer {
388
+ flex: none;
389
+ border-top: 1px solid var(--table-border-color);
390
+ }