@parallelogram-js/dashboard 0.0.0-stage → 0.1.1

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 (77) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1390 -2
  4. package/dist/parallelogram-dashboard.css +9401 -0
  5. package/dist/parallelogram-dashboard.css.map +1 -0
  6. package/dist/parallelogram-dashboard.min.css +1 -0
  7. package/package.json +72 -4
  8. package/scss/_base.scss +403 -0
  9. package/scss/_datetime.scss +50 -0
  10. package/scss/_icon.scss +40 -0
  11. package/scss/_index.scss +60 -0
  12. package/scss/_mixins.scss +396 -0
  13. package/scss/_tokens.scss +340 -0
  14. package/scss/_utilities.scss +464 -0
  15. package/scss/_variables.scss +219 -0
  16. package/scss/components/_accordion.scss +297 -0
  17. package/scss/components/_actionbar.scss +333 -0
  18. package/scss/components/_alert.scss +183 -0
  19. package/scss/components/_avatar.scss +203 -0
  20. package/scss/components/_badge.scss +176 -0
  21. package/scss/components/_banner.scss +344 -0
  22. package/scss/components/_breadcrumb.scss +220 -0
  23. package/scss/components/_button.scss +264 -0
  24. package/scss/components/_card.scss +256 -0
  25. package/scss/components/_chart.scss +246 -0
  26. package/scss/components/_command.scss +267 -0
  27. package/scss/components/_dashboard.scss +681 -0
  28. package/scss/components/_data-list.scss +280 -0
  29. package/scss/components/_dropdown.scss +318 -0
  30. package/scss/components/_empty.scss +226 -0
  31. package/scss/components/_filebrowser.scss +906 -0
  32. package/scss/components/_form-layout.scss +332 -0
  33. package/scss/components/_input.scss +310 -0
  34. package/scss/components/_list.scss +130 -0
  35. package/scss/components/_media.scss +239 -0
  36. package/scss/components/_modal.scss +298 -0
  37. package/scss/components/_navbar.scss +312 -0
  38. package/scss/components/_notification.scss +59 -0
  39. package/scss/components/_pageheader.scss +99 -0
  40. package/scss/components/_pagination.scss +165 -0
  41. package/scss/components/_progress.scss +333 -0
  42. package/scss/components/_separator.scss +129 -0
  43. package/scss/components/_sheet.scss +286 -0
  44. package/scss/components/_sidebar.scss +324 -0
  45. package/scss/components/_skeleton.scss +246 -0
  46. package/scss/components/_stat.scss +218 -0
  47. package/scss/components/_table.scss +589 -0
  48. package/scss/components/_tabs.scss +266 -0
  49. package/scss/components/_timeline.scss +339 -0
  50. package/scss/components/_toast.scss +259 -0
  51. package/scss/components/_toolbar.scss +301 -0
  52. package/scss/components/_tooltip.scss +250 -0
  53. package/scss/main.scss +6 -0
  54. package/src/js/behaviours/accordion.js +58 -0
  55. package/src/js/behaviours/action-bar-list.js +406 -0
  56. package/src/js/behaviours/action-bar.js +29 -0
  57. package/src/js/behaviours/chart.js +339 -0
  58. package/src/js/behaviours/collapsible.js +34 -0
  59. package/src/js/behaviours/editable-table.js +91 -0
  60. package/src/js/behaviours/expandable.js +80 -0
  61. package/src/js/behaviours/overflow-actions.js +137 -0
  62. package/src/js/behaviours/publish-schedule.js +91 -0
  63. package/src/js/behaviours/search-clear.js +19 -0
  64. package/src/js/behaviours/segmented-control.js +43 -0
  65. package/src/js/behaviours/submenu.js +73 -0
  66. package/src/js/behaviours/table-columns.js +77 -0
  67. package/src/js/behaviours/table-paste.js +305 -0
  68. package/src/js/behaviours/table-reorder.js +252 -0
  69. package/src/js/behaviours/table-sort.js +101 -0
  70. package/src/js/behaviours/tabs.js +148 -0
  71. package/src/js/behaviours/toast-manager.js +106 -0
  72. package/src/js/behaviours/toggle.js +186 -0
  73. package/src/js/behaviours/unsaved-guard.js +88 -0
  74. package/src/js/core-loader.js +26 -0
  75. package/src/js/index.js +85 -0
  76. package/src/js/polyfills/dialog-commands.js +20 -0
  77. package/src/js/util/dom.js +39 -0
@@ -0,0 +1,589 @@
1
+ // ==========================================================================
2
+ // Table Component
3
+ // ==========================================================================
4
+
5
+ @use "../variables" as *;
6
+ @use "../mixins" as *;
7
+
8
+ // --------------------------------------------------------------------------
9
+ // Table Wrapper (for horizontal scroll)
10
+ // --------------------------------------------------------------------------
11
+
12
+ .table__wrapper {
13
+ // Contains anything absolutely positioned inside the table (such as .sr-only labels), so it
14
+ // scrolls with the table instead of stretching the page
15
+ position: relative;
16
+ width: 100%;
17
+ overflow-x: auto;
18
+ border: 1px solid var(--border);
19
+ border-radius: $radius;
20
+ @include scrollbar-thin;
21
+
22
+ &--borderless {
23
+ border: none;
24
+ border-radius: 0;
25
+ }
26
+ }
27
+
28
+ // --------------------------------------------------------------------------
29
+ // Base Table
30
+ // --------------------------------------------------------------------------
31
+
32
+ .table {
33
+ width: 100%;
34
+ caption-side: bottom;
35
+ font-size: $font-size-sm;
36
+ text-align: left;
37
+
38
+ // --------------------------------------------------------------------------
39
+ // Elements
40
+ // --------------------------------------------------------------------------
41
+
42
+ &__header {
43
+ border-bottom: 1px solid var(--border);
44
+ }
45
+
46
+ &__body {
47
+ // Rows alternate striping handled by modifier
48
+ }
49
+
50
+ &__footer {
51
+ border-top: 1px solid var(--border);
52
+ font-weight: $font-weight-medium;
53
+ }
54
+
55
+ &__row {
56
+ border-bottom: 1px solid var(--border);
57
+ @include transition-colors;
58
+
59
+ &:last-child {
60
+ border-bottom: none;
61
+ }
62
+
63
+ // Edited but not saved, in an editable table
64
+ &--changed > .table__cell:first-child {
65
+ box-shadow: inset 3px 0 0 var(--warning);
66
+ }
67
+
68
+ // Added but not saved, in an editable table
69
+ &--new > .table__cell:first-child {
70
+ box-shadow: inset 3px 0 0 var(--success);
71
+ }
72
+ }
73
+
74
+ &__head {
75
+ height: $spacing-3xl;
76
+ padding: 0 $spacing-sm;
77
+ font-weight: $font-weight-medium;
78
+ color: var(--fg-muted);
79
+ vertical-align: middle;
80
+ white-space: nowrap;
81
+
82
+ &--sortable {
83
+ cursor: pointer;
84
+ user-select: none;
85
+
86
+ &:hover {
87
+ color: var(--fg);
88
+ }
89
+
90
+ &:focus-visible {
91
+ @include focus-ring;
92
+ outline-offset: -2px;
93
+ }
94
+ }
95
+
96
+ &[aria-sort="ascending"],
97
+ &[aria-sort="descending"],
98
+ &--sorted {
99
+ color: var(--fg);
100
+ }
101
+ }
102
+
103
+ &__cell {
104
+ padding: $spacing-sm;
105
+ vertical-align: middle;
106
+ }
107
+
108
+ &__caption {
109
+ margin-top: $spacing-sm;
110
+ font-size: $font-size-sm;
111
+ color: var(--fg-muted);
112
+ text-align: center;
113
+ }
114
+
115
+ // Empty state
116
+ &__empty {
117
+ padding: $spacing-xl $spacing-sm;
118
+ text-align: center;
119
+ color: var(--fg-muted);
120
+ }
121
+
122
+ // --------------------------------------------------------------------------
123
+ // Variants
124
+ // --------------------------------------------------------------------------
125
+
126
+ // Striped rows
127
+ &--striped {
128
+ .table__body .table__row:nth-child(even) {
129
+ background-color: var(--bg-muted);
130
+ }
131
+ }
132
+
133
+ // Hoverable rows
134
+ &--hoverable {
135
+ .table__body .table__row {
136
+ &:hover {
137
+ background-color: var(--bg-muted);
138
+ }
139
+ }
140
+ }
141
+
142
+ // Bordered (all cells have borders)
143
+ &--bordered {
144
+ .table__head,
145
+ .table__cell {
146
+ border: 1px solid var(--border);
147
+ }
148
+ }
149
+
150
+ // Compact
151
+ &--compact {
152
+ .table__head {
153
+ height: $spacing-xl;
154
+ padding: 0 $spacing-2xs;
155
+ }
156
+
157
+ .table__cell {
158
+ padding: $spacing-2xs;
159
+ }
160
+ }
161
+
162
+ // Fixed layout
163
+ &--fixed {
164
+ table-layout: fixed;
165
+ }
166
+
167
+ // Card-compatible padding (matches card__header/footer spacing)
168
+ &--card {
169
+ .table__head {
170
+ padding: 0 $spacing-sm;
171
+ }
172
+
173
+ .table__cell {
174
+ padding: $spacing-xs $spacing-sm;
175
+ }
176
+ }
177
+
178
+ // Cells hold .table__control inputs, so rows edit like a spreadsheet
179
+ &--editable {
180
+ .table__head,
181
+ .table__cell {
182
+ padding-left: $spacing-3xs;
183
+ padding-right: $spacing-3xs;
184
+ }
185
+
186
+ .table__cell {
187
+ padding-top: $spacing-3xs;
188
+ padding-bottom: $spacing-3xs;
189
+ }
190
+
191
+ // Line header text up with the text inside .table__control (cell padding + border + control padding)
192
+ .table__head:not(.table__checkbox, .table__actions) {
193
+ padding-left: calc(#{$spacing-3xs} + 1px + #{$spacing-2xs});
194
+ padding-right: calc(#{$spacing-3xs} + 1px + #{$spacing-2xs});
195
+ }
196
+ }
197
+
198
+ // An input or select that sits flush in its cell until hovered or focused
199
+ &__control {
200
+ width: 100%;
201
+ min-width: 5.5rem;
202
+ height: 2rem;
203
+ padding: 0 $spacing-2xs;
204
+ font: inherit;
205
+ color: var(--fg);
206
+ background-color: transparent;
207
+ border: 1px solid transparent;
208
+ border-radius: $radius-md;
209
+ @include transition-colors;
210
+
211
+ &:hover {
212
+ border-color: var(--border);
213
+ }
214
+
215
+ &:focus {
216
+ @include focus-ring;
217
+ border-color: var(--ring);
218
+ background-color: var(--bg);
219
+ }
220
+
221
+ &--number {
222
+ min-width: 4.5rem;
223
+ text-align: right;
224
+ font-variant-numeric: tabular-nums;
225
+ }
226
+
227
+ // For longer values such as codes and SKUs; the table scrolls rather than squeezing them
228
+ &--wide {
229
+ min-width: 8rem;
230
+ }
231
+
232
+ // Safari and Firefox keep their native select styling unless it's switched off
233
+ @at-root select#{&} {
234
+ appearance: none;
235
+ padding-right: 1.75rem;
236
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
237
+ background-repeat: no-repeat;
238
+ background-position: right $spacing-3xs center;
239
+ background-size: 1rem;
240
+ }
241
+ }
242
+
243
+ // While rows are selected, row actions step aside for the bulk actions; they keep their space
244
+ &:has(.table__body .table__checkbox :checked) .table__body .table__actions > * {
245
+ visibility: hidden;
246
+ }
247
+
248
+ // The actions column stays pinned to the right edge while the table scrolls sideways
249
+ &--sticky-actions {
250
+ .table__actions {
251
+ position: sticky;
252
+ right: 0;
253
+ z-index: 1;
254
+ background-color: var(--card);
255
+ }
256
+
257
+ // A shadow shows only while columns are scrolled underneath the pinned actions
258
+ @supports (animation-timeline: scroll()) {
259
+ .table__actions {
260
+ animation: table-sticky-edge linear both;
261
+ animation-timeline: --table-scroll;
262
+ }
263
+ }
264
+ }
265
+ }
266
+
267
+ .table__wrapper:has(> .table--sticky-actions, > .table--sticky-start) {
268
+ scroll-timeline: --table-scroll inline;
269
+ }
270
+
271
+ /**
272
+ * Sticky header and leading columns
273
+ *
274
+ * .table--sticky-header keeps the header row in view while the table's wrapper scrolls (such as in a
275
+ * full-screen card). .table--sticky-start pins the selection column and the first column after it
276
+ * (or just the first column) while the table scrolls sideways, with a shadow once columns are
277
+ * scrolled under them.
278
+ */
279
+ .table--sticky-header .table__header .table__head {
280
+ position: sticky;
281
+ top: 0;
282
+ z-index: 2;
283
+ background-color: var(--card);
284
+ box-shadow: inset 0 -1px 0 var(--border);
285
+ }
286
+
287
+ .table--sticky-start {
288
+ $pinned: ".table__handle, .table__checkbox, .table__handle + :is(.table__head, .table__cell), .table__checkbox + :is(.table__head, .table__cell), .table__row > :is(.table__head, .table__cell):first-child";
289
+ // The last pinned cell in each row: the one after the handle and checkbox columns, or the first
290
+ $edge: ".table__handle + :is(.table__head, .table__cell):not(.table__checkbox), .table__checkbox + :is(.table__head, .table__cell), .table__row > :is(.table__head, .table__cell):first-child:not(.table__handle, .table__checkbox)";
291
+
292
+ #{$pinned} {
293
+ position: sticky;
294
+ left: 0;
295
+ z-index: 1;
296
+ background-color: var(--card);
297
+ }
298
+
299
+ // Offsets assume the handle and checkbox columns are exactly $spacing-xl wide, whatever the
300
+ // table's cell padding; a cell's width alone is only a hint, so the checkbox sets a minimum
301
+ .table__checkbox:is(.table__head, .table__cell) {
302
+ padding-left: 0;
303
+ padding-right: 0;
304
+
305
+ .checkbox {
306
+ min-width: $spacing-xl;
307
+ }
308
+ }
309
+
310
+ .table__handle + :is(.table__head, .table__cell),
311
+ .table__checkbox + :is(.table__head, .table__cell) {
312
+ left: $spacing-xl;
313
+ }
314
+
315
+ .table__handle + .table__checkbox + :is(.table__head, .table__cell) {
316
+ left: $spacing-xl * 2;
317
+ }
318
+
319
+ // Corners where the sticky header meets the sticky columns sit above both
320
+ .table__header :is(#{$pinned}) {
321
+ z-index: 3;
322
+ }
323
+
324
+ @supports (animation-timeline: scroll()) {
325
+ #{$edge} {
326
+ animation: table-sticky-start-edge linear both;
327
+ animation-timeline: --table-scroll;
328
+ }
329
+ }
330
+ }
331
+
332
+ @keyframes table-sticky-start-edge {
333
+ from {
334
+ box-shadow: none;
335
+ }
336
+
337
+ 2%,
338
+ to {
339
+ box-shadow: 8px 0 8px -8px rgb(0 0 0 / 0.2);
340
+ }
341
+ }
342
+
343
+ @keyframes table-sticky-edge {
344
+ from {
345
+ box-shadow: -8px 0 8px -8px rgb(0 0 0 / 0.2);
346
+ }
347
+
348
+ to {
349
+ box-shadow: none;
350
+ }
351
+ }
352
+
353
+ // --------------------------------------------------------------------------
354
+ // Sortable Header Icon
355
+ // --------------------------------------------------------------------------
356
+
357
+ .table__sort-icon {
358
+ display: inline-flex;
359
+ align-items: center;
360
+ margin-left: $spacing-3xs;
361
+ width: $icon-size-sm;
362
+ height: $icon-size-sm;
363
+ // Sits on the baseline by default, which rides high; this centres the arrows on the capitals
364
+ vertical-align: -0.2em;
365
+ color: var(--fg-subtle);
366
+
367
+ [aria-sort="ascending"] &,
368
+ [aria-sort="descending"] &,
369
+ &--asc,
370
+ &--desc {
371
+ color: var(--fg);
372
+ }
373
+
374
+ // Before the label, for right-aligned columns, so the label lines up with the figures
375
+ &--start {
376
+ margin-left: 0;
377
+ margin-right: $spacing-3xs;
378
+ }
379
+
380
+ // An icon holding both arrows (data-sort="ascending" and "descending" paths) fades the one not in use
381
+ [aria-sort="ascending"] & [data-sort="descending"],
382
+ [aria-sort="descending"] & [data-sort="ascending"] {
383
+ opacity: 0.3;
384
+ }
385
+ }
386
+
387
+ // --------------------------------------------------------------------------
388
+ // Checkbox Column
389
+ // --------------------------------------------------------------------------
390
+
391
+ .table__checkbox {
392
+ width: $spacing-xl;
393
+ text-align: center;
394
+
395
+ // A label with no text sits on the baseline and rides high; centre it in the cell instead
396
+ .checkbox {
397
+ display: flex;
398
+ justify-content: center;
399
+ }
400
+ }
401
+
402
+ /**
403
+ * Row save state
404
+ *
405
+ * Set data-row-state="saving", "saved" or "error" on a .table__row and its .table__checkbox
406
+ * cell shows a spinner, a tick or a warning in place of the checkbox, which keeps its space.
407
+ */
408
+ .table__row[data-row-state] > .table__checkbox {
409
+ position: relative;
410
+
411
+ .checkbox {
412
+ visibility: hidden;
413
+ }
414
+
415
+ &::after {
416
+ content: "";
417
+ position: absolute;
418
+ inset: 0;
419
+ width: 1rem;
420
+ height: 1rem;
421
+ margin: auto;
422
+ }
423
+ }
424
+
425
+ .table__row[data-row-state="saving"] > .table__checkbox::after {
426
+ border: 2px solid var(--border);
427
+ border-top-color: var(--fg-muted);
428
+ border-radius: $radius-full;
429
+ animation: spin 0.7s linear infinite;
430
+ }
431
+
432
+ .table__row[data-row-state="saved"] > .table__checkbox::after,
433
+ .table__row[data-row-state="error"] > .table__checkbox::after {
434
+ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5l10 -10'/%3E%3C/svg%3E") center / contain no-repeat;
435
+ background-color: var(--success);
436
+ }
437
+
438
+ .table__row[data-row-state="error"] > .table__checkbox {
439
+ cursor: pointer;
440
+
441
+ &::after {
442
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z'/%3E%3Cpath d='M12 16h.01'/%3E%3C/svg%3E");
443
+ background-color: var(--destructive);
444
+ }
445
+ }
446
+
447
+ @media (prefers-reduced-motion: reduce) {
448
+ .table__row[data-row-state="saving"] > .table__checkbox::after {
449
+ animation-duration: 2s;
450
+ }
451
+ }
452
+
453
+ /**
454
+ * Reorder handle column
455
+ *
456
+ * In a table with data-table-reorder, the first cell of each row holds a handle button for
457
+ * dragging the row (see TableReorder). The handle stays faint until its row is hovered or the
458
+ * handle is focused; the row being moved carries data-dragging and lifts above the others.
459
+ */
460
+ .table__handle {
461
+ width: $spacing-xl;
462
+ text-align: center;
463
+
464
+ // Doubled up to outweigh the cell padding of .table--editable and friends
465
+ &.table__head,
466
+ &.table__cell {
467
+ padding-left: 0;
468
+ padding-right: 0;
469
+ }
470
+
471
+ .btn {
472
+ color: var(--fg-subtle);
473
+ cursor: grab;
474
+ touch-action: none;
475
+ opacity: 0.4;
476
+ @include transition-colors;
477
+
478
+ &:active,
479
+ &[aria-pressed="true"] {
480
+ color: var(--primary);
481
+ cursor: grabbing;
482
+ }
483
+
484
+ // The button fills its column, so a ring drawn outside it would be clipped by the
485
+ // table's scroll area and covered by the next cell
486
+ &:focus-visible {
487
+ outline-offset: calc(var(--framework-focus-width) * -1);
488
+ }
489
+ }
490
+ }
491
+
492
+ .table__row:hover > .table__handle .btn,
493
+ .table__handle .btn:focus-visible,
494
+ .table__handle .btn[aria-pressed="true"] {
495
+ opacity: 1;
496
+ }
497
+
498
+ .table__row[data-dragging] {
499
+ position: relative;
500
+ z-index: 4;
501
+ // Rows in a collapsed table don't paint box-shadow; a filter does
502
+ filter: drop-shadow(0 8px 10px rgb(0 0 0 / 0.12)) drop-shadow(0 2px 3px rgb(0 0 0 / 0.08));
503
+ cursor: grabbing;
504
+
505
+ > .table__cell {
506
+ background-color: var(--card);
507
+ }
508
+
509
+ > .table__handle .btn {
510
+ opacity: 1;
511
+ }
512
+ }
513
+
514
+ /**
515
+ * Paste preview
516
+ *
517
+ * In the dialog TablePaste opens, a pasted value its column can't take (no matching option, or
518
+ * text in a number column) is marked data-paste-invalid and skipped, and values in a column set
519
+ * to "Skip" are marked data-paste-skipped.
520
+ */
521
+ .table__cell[data-paste-invalid] {
522
+ color: var(--destructive);
523
+ text-decoration: line-through wavy;
524
+ text-decoration-thickness: 1px;
525
+ cursor: help;
526
+ }
527
+
528
+ .table__cell[data-paste-skipped] {
529
+ color: var(--fg-subtle);
530
+ text-decoration: line-through;
531
+ }
532
+
533
+ // --------------------------------------------------------------------------
534
+ // Actions Column
535
+ // --------------------------------------------------------------------------
536
+
537
+ .table__actions {
538
+ width: auto;
539
+ text-align: right;
540
+ white-space: nowrap;
541
+
542
+ .btn + .btn {
543
+ margin-left: $spacing-3xs;
544
+ }
545
+ }
546
+
547
+ // --------------------------------------------------------------------------
548
+ // Responsive: Card layout on mobile
549
+ // --------------------------------------------------------------------------
550
+
551
+ @include max-md {
552
+ .table--responsive {
553
+ .table__header {
554
+ @include sr-only;
555
+ }
556
+
557
+ .table__body {
558
+ display: flex;
559
+ flex-direction: column;
560
+ gap: $spacing-sm;
561
+ }
562
+
563
+ .table__row {
564
+ display: flex;
565
+ flex-direction: column;
566
+ padding: $spacing-sm;
567
+ border: 1px solid var(--border);
568
+ border-radius: $radius;
569
+ }
570
+
571
+ .table__cell {
572
+ display: flex;
573
+ justify-content: space-between;
574
+ padding: $spacing-2xs 0;
575
+ border-bottom: 1px solid var(--border-muted);
576
+
577
+ &:last-child {
578
+ border-bottom: none;
579
+ }
580
+
581
+ &::before {
582
+ content: attr(data-label);
583
+ font-weight: $font-weight-medium;
584
+ color: var(--fg-muted);
585
+ margin-right: $spacing-sm;
586
+ }
587
+ }
588
+ }
589
+ }