@functionalcms/svelte-components 2.33.2 → 2.34.2

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 (103) hide show
  1. package/dist/components/Link.svelte +290 -290
  2. package/dist/components/agnostic/Alert/Alert.svelte +310 -0
  3. package/dist/components/agnostic/Alert/Alert.svelte.d.ts +31 -0
  4. package/dist/components/agnostic/Avatar/Avatar.svelte +123 -0
  5. package/dist/components/agnostic/Avatar/Avatar.svelte.d.ts +26 -0
  6. package/dist/components/agnostic/Avatar/AvatarGroup.svelte +106 -0
  7. package/dist/components/agnostic/Avatar/AvatarGroup.svelte.d.ts +29 -0
  8. package/dist/components/agnostic/Breadcrumb/Breadcrumb.svelte +56 -0
  9. package/dist/components/agnostic/Breadcrumb/Breadcrumb.svelte.d.ts +20 -0
  10. package/dist/components/agnostic/Breadcrumb/api.d.ts +4 -0
  11. package/dist/components/agnostic/Breadcrumb/api.js +1 -0
  12. package/dist/components/agnostic/Button/Button.svelte +345 -0
  13. package/dist/components/agnostic/Button/Button.svelte.d.ts +43 -0
  14. package/dist/components/agnostic/Button/ButtonGroup.svelte +20 -0
  15. package/dist/components/agnostic/Button/ButtonGroup.svelte.d.ts +23 -0
  16. package/dist/components/agnostic/Button/button-base.css +12 -0
  17. package/dist/components/agnostic/Button/button-core.css +237 -0
  18. package/dist/components/agnostic/Button/button-empty.css +31 -0
  19. package/dist/components/agnostic/Button/button-group.css +8 -0
  20. package/dist/components/agnostic/Card/Card.svelte +133 -0
  21. package/dist/components/agnostic/Card/Card.svelte.d.ts +31 -0
  22. package/dist/components/agnostic/ChoiceInput/ChoiceInput.svelte +337 -0
  23. package/dist/components/agnostic/ChoiceInput/ChoiceInput.svelte.d.ts +37 -0
  24. package/dist/components/agnostic/ChoiceInput/api.d.ts +7 -0
  25. package/dist/components/agnostic/ChoiceInput/api.js +1 -0
  26. package/dist/components/agnostic/Close/Close.svelte +120 -0
  27. package/dist/components/agnostic/Close/Close.svelte.d.ts +23 -0
  28. package/dist/components/agnostic/Close/api.d.ts +1 -0
  29. package/dist/components/agnostic/Close/api.js +1 -0
  30. package/dist/components/agnostic/Dialog/Dialog.svelte +265 -0
  31. package/dist/components/agnostic/Dialog/Dialog.svelte.d.ts +39 -0
  32. package/dist/components/agnostic/Dialog/SvelteA11yDialog.svelte +103 -0
  33. package/dist/components/agnostic/Dialog/SvelteA11yDialog.svelte.d.ts +30 -0
  34. package/dist/components/agnostic/Dialog/a11y-dialog.d.ts +56 -0
  35. package/dist/components/agnostic/Dialog/a11y-dialog.js +216 -0
  36. package/dist/components/agnostic/Dialog/dom-utils.d.ts +26 -0
  37. package/dist/components/agnostic/Dialog/dom-utils.js +206 -0
  38. package/dist/components/agnostic/Disclose/Disclose.svelte +102 -0
  39. package/dist/components/agnostic/Disclose/Disclose.svelte.d.ts +23 -0
  40. package/dist/components/agnostic/Divider/Divider.svelte +139 -0
  41. package/dist/components/agnostic/Divider/Divider.svelte.d.ts +25 -0
  42. package/dist/components/agnostic/Divider/api.d.ts +3 -0
  43. package/dist/components/agnostic/Divider/api.js +1 -0
  44. package/dist/components/agnostic/Drawer/Drawer.svelte +30 -0
  45. package/dist/components/agnostic/Drawer/Drawer.svelte.d.ts +28 -0
  46. package/dist/components/agnostic/Drawer/api.d.ts +1 -0
  47. package/dist/components/agnostic/Drawer/api.js +1 -0
  48. package/dist/components/agnostic/EmptyState/EmptyState.svelte +46 -0
  49. package/dist/components/agnostic/EmptyState/EmptyState.svelte.d.ts +23 -0
  50. package/dist/components/agnostic/Header/Header.svelte +104 -0
  51. package/dist/components/agnostic/Header/Header.svelte.d.ts +26 -0
  52. package/dist/components/agnostic/Header/HeaderNav.svelte +28 -0
  53. package/dist/components/agnostic/Header/HeaderNav.svelte.d.ts +20 -0
  54. package/dist/components/agnostic/Header/HeaderNavItem.svelte +30 -0
  55. package/dist/components/agnostic/Header/HeaderNavItem.svelte.d.ts +20 -0
  56. package/dist/components/agnostic/Icon/Icon.svelte +180 -0
  57. package/dist/components/agnostic/Icon/Icon.svelte.d.ts +23 -0
  58. package/dist/components/agnostic/Icon/api.d.ts +2 -0
  59. package/dist/components/agnostic/Icon/api.js +1 -0
  60. package/dist/components/agnostic/Input/Input.svelte +415 -0
  61. package/dist/components/agnostic/Input/Input.svelte.d.ts +45 -0
  62. package/dist/components/agnostic/Input/InputAddonItem.svelte +42 -0
  63. package/dist/components/agnostic/Input/InputAddonItem.svelte.d.ts +33 -0
  64. package/dist/components/agnostic/Loader/Loader.svelte +113 -0
  65. package/dist/components/agnostic/Loader/Loader.svelte.d.ts +20 -0
  66. package/dist/components/agnostic/Menu/Menu.svelte +466 -0
  67. package/dist/components/agnostic/Menu/Menu.svelte.d.ts +31 -0
  68. package/dist/components/agnostic/Menu/MenuItem.svelte +117 -0
  69. package/dist/components/agnostic/Menu/MenuItem.svelte.d.ts +29 -0
  70. package/dist/components/agnostic/Progress/Progress.svelte +50 -0
  71. package/dist/components/agnostic/Progress/Progress.svelte.d.ts +20 -0
  72. package/dist/components/agnostic/Select/Select.svelte +141 -0
  73. package/dist/components/agnostic/Select/Select.svelte.d.ts +32 -0
  74. package/dist/components/agnostic/Spinner/Spinner.svelte +105 -0
  75. package/dist/components/agnostic/Spinner/Spinner.svelte.d.ts +19 -0
  76. package/dist/components/agnostic/Switch/Switch.svelte +275 -0
  77. package/dist/components/agnostic/Switch/Switch.svelte.d.ts +45 -0
  78. package/dist/components/agnostic/Table/Table.svelte +508 -0
  79. package/dist/components/agnostic/Table/Table.svelte.d.ts +36 -0
  80. package/dist/components/agnostic/Table/TableCustomRenderComponent.svelte +13 -0
  81. package/dist/components/agnostic/Table/TableCustomRenderComponent.svelte.d.ts +25 -0
  82. package/dist/components/agnostic/Tabs/TabButtonCustom.svelte +65 -0
  83. package/dist/components/agnostic/Tabs/TabButtonCustom.svelte.d.ts +35 -0
  84. package/dist/components/agnostic/Tabs/Tabs.svelte +330 -0
  85. package/dist/components/agnostic/Tabs/Tabs.svelte.d.ts +34 -0
  86. package/dist/components/agnostic/Tabs/api.d.ts +10 -0
  87. package/dist/components/agnostic/Tabs/api.js +1 -0
  88. package/dist/components/agnostic/Tag/Tag.svelte +74 -0
  89. package/dist/components/agnostic/Tag/Tag.svelte.d.ts +23 -0
  90. package/dist/components/agnostic/Tag/TagSlots.svelte +51 -0
  91. package/dist/components/agnostic/Tag/TagSlots.svelte.d.ts +16 -0
  92. package/dist/components/agnostic/Toasts/Toasts.svelte +46 -0
  93. package/dist/components/agnostic/Toasts/Toasts.svelte.d.ts +22 -0
  94. package/dist/components/agnostic/Tooltip/Tooltip.svelte +103 -0
  95. package/dist/components/agnostic/Tooltip/Tooltip.svelte.d.ts +23 -0
  96. package/dist/components/agnostic/Tooltip/TooltipSlots.svelte +81 -0
  97. package/dist/components/agnostic/Tooltip/TooltipSlots.svelte.d.ts +16 -0
  98. package/dist/components/agnostic/Tooltip/api.d.ts +1 -0
  99. package/dist/components/agnostic/Tooltip/api.js +1 -0
  100. package/dist/components/agnostic/animation.css +37 -0
  101. package/dist/index.d.ts +30 -1
  102. package/dist/index.js +30 -1
  103. package/package.json +1 -4
@@ -0,0 +1,508 @@
1
+ <style>
2
+ .table {
3
+ --table-bg: transparent;
4
+ --table-accent-bg: transparent;
5
+ --table-striped-color: var(--functional-dark);
6
+ --table-striped-bg: rgb(0 0 0 / 2.5%);
7
+ --table-active-color: var(--functional-dark);
8
+ --table-active-bg: rgb(0 0 0 / 1.5%);
9
+ --table-hoverable-color: var(--functional-dark);
10
+ --table-hoverable-bg: var(--functional-table-hover-bg, #f1faff);
11
+
12
+ width: 100%;
13
+ margin-bottom: var(--fluid-16);
14
+ color: var(--functional-dark);
15
+ vertical-align: top;
16
+ border-color: var(--functional-table-border-color, var(--functional-gray-light));
17
+ }
18
+
19
+ .table > :not(caption) > * > * {
20
+ padding: var(--fluid-8) var(--fluid-8);
21
+ background-color: var(--table-bg);
22
+ border-bottom-width: 1px;
23
+
24
+ /* 4th is spread --table-accent-bg will gets reset for active, hover, striped */
25
+ box-shadow: inset 0 0 0 9999px var(--table-accent-bg);
26
+ }
27
+
28
+ .table > tbody {
29
+ vertical-align: inherit;
30
+ }
31
+
32
+ .table > thead {
33
+ vertical-align: bottom;
34
+ }
35
+
36
+ .table thead th {
37
+ font-weight: 600;
38
+ }
39
+
40
+ .table-caps thead th {
41
+ font-size: var(--fluid-12);
42
+ text-transform: uppercase;
43
+ }
44
+
45
+ .table tbody td,
46
+ .table tbody th {
47
+ font-weight: 400;
48
+ }
49
+
50
+ .table > :not(thead):not(caption) {
51
+ border-top: var(--fluid-2) solid var(--functional-gray-light);
52
+ }
53
+
54
+ .caption-top {
55
+ caption-side: top;
56
+ }
57
+
58
+ .caption-bottom {
59
+ caption-side: bottom;
60
+ }
61
+
62
+ .caption-bottom,
63
+ .caption-top {
64
+ padding-block-start: var(--fluid-12);
65
+ padding-block-end: var(--fluid-12);
66
+
67
+ /* Takes writing mode into account -- (mdn) same as left if direction is left-to-right
68
+ and right if direction is right-to-left */
69
+ text-align: start;
70
+ }
71
+
72
+ .caption-end {
73
+ text-align: end;
74
+ }
75
+
76
+ .table-small > :not(caption) > * > * {
77
+ padding: var(--fluid-4) var(--fluid-4);
78
+ }
79
+
80
+ .table-large > :not(caption) > * > * {
81
+ padding: var(--fluid-12) var(--fluid-12);
82
+ }
83
+
84
+ .table-xlarge > :not(caption) > * > * {
85
+ padding: var(--fluid-18) var(--fluid-18);
86
+ }
87
+
88
+ .table-bordered > :not(caption) > * {
89
+ border-width: 1px 0;
90
+ }
91
+
92
+ .table-bordered > :not(caption) > * > * {
93
+ border-width: 0 1px;
94
+ }
95
+
96
+ .table-borderless > :not(caption) > * > * {
97
+ border-bottom-width: 0;
98
+ }
99
+
100
+ .table-borderless > :not(:first-child) {
101
+ border-top-width: 0;
102
+ }
103
+
104
+ .table-striped > tbody > tr:nth-of-type(odd) > * {
105
+ --table-accent-bg: var(--table-striped-bg);
106
+
107
+ color: var(--table-striped-color);
108
+ }
109
+
110
+ .table-active {
111
+ --table-accent-bg: var(--table-active-bg);
112
+
113
+ color: var(--table-active-color);
114
+ }
115
+
116
+ .table-hoverable > tbody > tr:hover > * {
117
+ --table-accent-bg: var(--table-hoverable-bg);
118
+
119
+ color: var(--table-hoverable-color);
120
+ }
121
+
122
+ /* Stacked tables */
123
+ .table-stacked thead {
124
+ display: none;
125
+ }
126
+
127
+ .table-stacked tr,
128
+ .table-stacked tbody th,
129
+ .table-stacked tbody td {
130
+ display: block;
131
+ width: 100%;
132
+ }
133
+
134
+ .table-stacked tbody th,
135
+ .table-stacked tbody td {
136
+ border-bottom-width: 0;
137
+ }
138
+
139
+ .table-stacked td[data-label] {
140
+ padding-bottom: var(--fluid-12);
141
+ }
142
+
143
+ .table-stacked tr {
144
+ border-bottom: var(--fluid-2) solid var(--functional-gray-light);
145
+ border-top-width: 0;
146
+ }
147
+
148
+ .table-stacked th[data-label]::before,
149
+ .table-stacked td[data-label]::before {
150
+ content: attr(data-label);
151
+ display: block;
152
+ font-weight: 600;
153
+ margin: -0.5rem -1rem 0;
154
+ padding: var(--fluid-12) var(--fluid-16) var(--fluid-6);
155
+ }
156
+
157
+ .table-stacked tr th:first-child,
158
+ .table-stacked tr td:first-child {
159
+ border-top-width: 0;
160
+ }
161
+
162
+ .table-stacked tr:nth-child(odd) td,
163
+ .table-stacked tr:nth-child(odd) th {
164
+ background-color: inherit;
165
+ }
166
+
167
+ .table-stacked tr:first-child th:first-child,
168
+ .table-stacked tr:first-child td:first-child {
169
+ border-top: var(--fluid-2) solid var(--functional-gray-light);
170
+ }
171
+
172
+ .table-stacked th[data-label],
173
+ .table-stacked td[data-label] {
174
+ padding-bottom: var(--fluid-12);
175
+ }
176
+
177
+ /* As soon as there's not enough width, it will kick in horizontal scrolling */
178
+ .table-responsive {
179
+ overflow-x: auto;
180
+ -webkit-overflow-scrolling: touch;
181
+ }
182
+
183
+ /* Table is responsive only "up to" the breakpoint. Above it will not scroll */
184
+ @media (max-width: 576px) {
185
+ .table-responsive-small {
186
+ overflow-x: auto;
187
+ -webkit-overflow-scrolling: touch;
188
+ }
189
+ }
190
+
191
+ @media (max-width: 768px) {
192
+ .table-responsive-medium {
193
+ overflow-x: auto;
194
+ -webkit-overflow-scrolling: touch;
195
+ }
196
+ }
197
+
198
+ @media (max-width: 992px) {
199
+ .table-responsive-large {
200
+ overflow-x: auto;
201
+ -webkit-overflow-scrolling: touch;
202
+ }
203
+ }
204
+
205
+ @media (max-width: 1200px) {
206
+ .table-responsive-xlarge {
207
+ overflow-x: auto;
208
+ -webkit-overflow-scrolling: touch;
209
+ }
210
+ }
211
+
212
+ .table-header-container {
213
+ display: flex;
214
+ align-items: center;
215
+ }
216
+
217
+ .table-sort-label {
218
+ flex: 1;
219
+ padding-inline-end: 0.5rem;
220
+ text-align: left;
221
+ }
222
+
223
+ .table-sort {
224
+ flex: 0 1 var(--fluid-48);
225
+ background-color: transparent;
226
+ border-color: transparent;
227
+ border-width: 0;
228
+ cursor: pointer;
229
+ display: flex;
230
+ justify-content: center;
231
+ padding-block-start: var(--fluid-2);
232
+ padding-block-end: var(--fluid-2);
233
+ }
234
+
235
+ .icon-sort {
236
+ width: 1.125rem;
237
+ height: 1.125rem;
238
+ }
239
+
240
+ .table-sort:focus {
241
+ box-shadow: 0 0 0 var(--functional-focus-ring-outline-width) var(--functional-focus-ring-color);
242
+
243
+ /* Needed for High Contrast mode */
244
+ outline:
245
+ var(--functional-focus-ring-outline-width) var(--functional-focus-ring-outline-style)
246
+ var(--functional-focus-ring-outline-color);
247
+ transition: box-shadow var(--functional-timing-fast) ease-out;
248
+ }
249
+
250
+ @media (prefers-reduced-motion), (update: slow) {
251
+ .table-sort:focus {
252
+ transition-duration: 0.001ms !important;
253
+ }
254
+ }
255
+
256
+ </style>
257
+
258
+ <script>import { createEventDispatcher } from "svelte";
259
+ export let headers = [];
260
+ headers.labelByKey = function() {
261
+ return this.reduce(function(rv, x) {
262
+ if (!("key" in x))
263
+ throw new Error(
264
+ "Header must have key value with `sortByKey` set to `true`"
265
+ );
266
+ rv[x.key] = x;
267
+ return rv;
268
+ }, {});
269
+ };
270
+ export let rows = [];
271
+ export let caption = "";
272
+ export let captionPosition = "hidden";
273
+ export let tableSize = "";
274
+ export let responsiveSize = "";
275
+ export let isUppercasedHeaders = false;
276
+ export let isBordered = false;
277
+ export let isBorderless = false;
278
+ export let isStriped = false;
279
+ export let isHoverable = false;
280
+ export let isStacked = false;
281
+ export let filterByKey = false;
282
+ export let offset = 0;
283
+ export let limit = 0;
284
+ let direction = "none";
285
+ let sortingKey = "";
286
+ const dispatch = createEventDispatcher();
287
+ $: dispatch("sort", {
288
+ direction,
289
+ sortingKey
290
+ });
291
+ const pluckColumnToSort = (rowLeft, rowRight) => {
292
+ const colLeft = rowLeft[sortingKey] === null || rowLeft[sortingKey] === void 0 ? -Infinity : rowLeft[sortingKey];
293
+ const colRight = rowRight[sortingKey] === null || rowRight[sortingKey] === void 0 ? -Infinity : rowRight[sortingKey];
294
+ return {
295
+ colLeft,
296
+ colRight
297
+ };
298
+ };
299
+ const internalSort = (rowLeft, rowRight) => {
300
+ let { colLeft, colRight } = pluckColumnToSort(rowLeft, rowRight);
301
+ const headerWithCustomSortFunction = headers.find(
302
+ (h) => h.key === sortingKey && !!h.sortFn
303
+ );
304
+ if (headerWithCustomSortFunction && headerWithCustomSortFunction.sortFn) {
305
+ return headerWithCustomSortFunction.sortFn(colLeft, colRight);
306
+ }
307
+ colLeft = typeof colLeft === "string" ? colLeft.toLowerCase().replace(/(^\$|,)/g, "") : colLeft;
308
+ colRight = typeof colRight === "string" ? colRight.toLowerCase().replace(/(^\$|,)/g, "") : colRight;
309
+ colLeft = !Number.isNaN(Number(colLeft)) ? Number(colLeft) : colLeft;
310
+ colRight = !Number.isNaN(Number(colRight)) ? Number(colRight) : colRight;
311
+ if (colLeft > colRight) {
312
+ return 1;
313
+ }
314
+ if (colLeft < colRight) {
315
+ return -1;
316
+ }
317
+ return 0;
318
+ };
319
+ const descendingSort = (row1, row2) => internalSort(row1, row2) * -1;
320
+ $: columns = filterByKey ? headers.labelByKey() : { ...headers };
321
+ $: sortableItems = direction === "ascending" ? rows.sort(internalSort) : direction === "descending" ? rows.sort(descendingSort) : sortableItems = [...rows];
322
+ $: visibleItems = sortableItems.slice(
323
+ offset ? offset : 0,
324
+ limit ? offset + limit : void 0
325
+ );
326
+ const handleSortClicked = (headerKey) => {
327
+ if (sortingKey !== headerKey) {
328
+ direction = "none";
329
+ sortingKey = headerKey;
330
+ }
331
+ switch (direction) {
332
+ case "ascending":
333
+ direction = "descending";
334
+ break;
335
+ case "descending":
336
+ direction = "none";
337
+ break;
338
+ case "none":
339
+ direction = "ascending";
340
+ break;
341
+ default:
342
+ console.warn(
343
+ "Table sorting only supports directions: ascending | descending | none"
344
+ );
345
+ }
346
+ };
347
+ const getSortingClassesFor = (headerKey, direction2, sortingKey2) => {
348
+ if (sortingKey2 === headerKey) {
349
+ return [
350
+ "icon-sort",
351
+ direction2 && direction2 !== "none" ? `icon-sort-${direction2}` : ""
352
+ ].filter((klass) => klass.length).join(" ");
353
+ }
354
+ return "icon-sort";
355
+ };
356
+ const getSortDirectionFor = (headerKey, direction2, sortingKey2) => {
357
+ if (sortingKey2 !== headerKey) {
358
+ return "none";
359
+ } else {
360
+ return direction2;
361
+ }
362
+ };
363
+ const tableResponsiveClasses = () => {
364
+ return [
365
+ !responsiveSize ? "table-responsive" : "",
366
+ responsiveSize ? `table-responsive-${responsiveSize}` : ""
367
+ ].filter((klass) => klass.length).join(" ");
368
+ };
369
+ const tableClasses = () => {
370
+ return [
371
+ "table",
372
+ tableSize ? `table-${tableSize}` : "",
373
+ isUppercasedHeaders ? "table-caps" : "",
374
+ isBordered ? "table-bordered" : "",
375
+ isBorderless ? "table-borderless" : "",
376
+ isStriped ? "table-striped" : "",
377
+ isHoverable ? "table-hoverable" : "",
378
+ isStacked ? "table-stacked" : ""
379
+ ].filter((klass) => klass.length).join(" ");
380
+ };
381
+ const captionClasses = () => {
382
+ return [
383
+ // .screenreader-only is expected to be globally available via common.min.css
384
+ captionPosition === "hidden" ? "screenreader-only" : "",
385
+ captionPosition !== "hidden" ? `caption-${captionPosition}` : ""
386
+ ].filter((klass) => klass.length).join(" ");
387
+ };
388
+ const getKeys = (row) => {
389
+ const filteredKeys = filterByKey ? Object.keys(columns).map((key) => [key, key]) : Object.keys(row).map((key, index) => [key, index]);
390
+ return filteredKeys;
391
+ };
392
+ </script>
393
+ <div class="{tableResponsiveClasses()}">
394
+ <table class="{tableClasses()}">
395
+ <caption class="{captionClasses()}">{caption}</caption>
396
+ <thead>
397
+ <tr>
398
+ {#each headers as headerCol}
399
+ <th
400
+ aria-sort="{getSortDirectionFor(
401
+ headerCol.key,
402
+ direction,
403
+ sortingKey
404
+ )}"
405
+ scope="col"
406
+ style="{headerCol.width
407
+ ? `width: ${headerCol.width}`
408
+ : 'width: auto'}"
409
+ >
410
+ {#if headerCol.sortable}
411
+ <div class="table-header-container">
412
+ <span class="table-sort-label">{headerCol.label}</span>
413
+ <button
414
+ type="button"
415
+ class="table-sort"
416
+ on:click={() => handleSortClicked(headerCol.key)}
417
+ >
418
+ <span class="screenreader-only">{headerCol.label}</span>
419
+ <span
420
+ class="{getSortingClassesFor(
421
+ headerCol.key,
422
+ direction,
423
+ sortingKey
424
+ )}">
425
+ {#if getSortDirectionFor(headerCol.key, direction, sortingKey) === 'none'}
426
+ <svg
427
+ xmlns="http://www.w3.org/2000/svg"
428
+ class="{getSortingClassesFor(
429
+ headerCol.key,
430
+ direction,
431
+ sortingKey
432
+ )}"
433
+ fill="none"
434
+ viewBox="0 0 20 20"
435
+ width="20"
436
+ height="20"
437
+ >
438
+ <path
439
+ d="m15 13-5 5-5-5M5 7l5-5 5 5"
440
+ stroke="currentColor"
441
+ stroke-width="2"
442
+ stroke-linecap="round"
443
+ stroke-linejoin="round"
444
+ />
445
+ </svg>
446
+ {:else if getSortDirectionFor(headerCol.key, direction, sortingKey) === 'descending'}
447
+ <svg
448
+ xmlns="http://www.w3.org/2000/svg"
449
+ class="{getSortingClassesFor(
450
+ headerCol.key,
451
+ direction,
452
+ sortingKey
453
+ )}"
454
+ viewBox="0 0 20 20"
455
+ width="20"
456
+ height="20"
457
+ >
458
+ <path
459
+ d="m10.778 13.635 4.964-5.86c.586-.693.11-1.775-.78-1.775H5.037a1.01 1.01 0 0 0-.561.17c-.168.111-.3.27-.382.457a1.102 1.102 0 0 0 .164 1.147l4.963 5.86a1.006 1.006 0 0 0 1.559 0v.001Z"
460
+ fill="currentColor"
461
+ />
462
+ </svg>
463
+ {:else}
464
+ <svg
465
+ xmlns="http://www.w3.org/2000/svg"
466
+ class="{getSortingClassesFor(
467
+ headerCol.key,
468
+ direction,
469
+ sortingKey
470
+ )}"
471
+ viewBox="0 0 20 20"
472
+ width="20"
473
+ height="20"
474
+ >
475
+ <path
476
+ d="m9.221 6.365-4.963 5.86c-.586.693-.11 1.775.78 1.775h9.926c.2 0 .394-.059.561-.17.168-.111.3-.27.383-.457a1.102 1.102 0 0 0-.165-1.147l-4.963-5.86a1.04 1.04 0 0 0-.351-.27 1.007 1.007 0 0 0-1.208.27v-.001Z"
477
+ fill="currentColor"
478
+ />
479
+ </svg>
480
+ {/if}
481
+ </span>
482
+ </button>
483
+ </div>
484
+ {:else}{headerCol.label}{/if}
485
+ </th>
486
+ {/each}
487
+ </tr>
488
+ </thead>
489
+ <tbody>
490
+ {#each visibleItems as row}
491
+ <tr>
492
+ {#each getKeys(row) as [key, id]}
493
+ <td>
494
+ {#if columns[id].renderComponent}
495
+ <svelte:component
496
+ this="{columns[id].renderComponent()}"
497
+ cellValue="{row[key]}"
498
+ />
499
+ {:else}
500
+ {row[key]}
501
+ {/if}
502
+ </td>
503
+ {/each}
504
+ </tr>
505
+ {/each}
506
+ </tbody>
507
+ </table>
508
+ </div>
@@ -0,0 +1,36 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ headers?: any[] & {
5
+ labelByKey(): any[];
6
+ };
7
+ rows?: any[];
8
+ caption?: string;
9
+ captionPosition?: string;
10
+ tableSize?: string;
11
+ responsiveSize?: string;
12
+ isUppercasedHeaders?: boolean;
13
+ isBordered?: boolean;
14
+ isBorderless?: boolean;
15
+ isStriped?: boolean;
16
+ isHoverable?: boolean;
17
+ isStacked?: boolean;
18
+ filterByKey?: boolean;
19
+ offset?: number;
20
+ limit?: number;
21
+ };
22
+ events: {
23
+ sort: CustomEvent<any>;
24
+ } & {
25
+ [evt: string]: CustomEvent<any>;
26
+ };
27
+ slots: {};
28
+ exports?: {} | undefined;
29
+ bindings?: string | undefined;
30
+ };
31
+ export type TableProps = typeof __propDef.props;
32
+ export type TableEvents = typeof __propDef.events;
33
+ export type TableSlots = typeof __propDef.slots;
34
+ export default class Table extends SvelteComponent<TableProps, TableEvents, TableSlots> {
35
+ }
36
+ export {};
@@ -0,0 +1,13 @@
1
+ <script>
2
+ /**
3
+ * This is just an example that is used within the `renderComponent` in ./Table.stories.js
4
+ * `headers` like: { renderComponent: () => TableCustomRenderComponent },
5
+ *
6
+ * Also, it would have been nice to be able to generate this component "inline" but it seems
7
+ * there's an RFC for a long time but hasn't materialized:
8
+ * https://github.com/sveltejs/rfcs/blob/inline-components/text/0000-inline-components.md
9
+ */
10
+ export let cellValue;
11
+ </script>
12
+
13
+ <td>{cellValue}<span class="mis6">🏆</span></td>
@@ -0,0 +1,25 @@
1
+ /** @typedef {typeof __propDef.props} TableCustomRenderComponentProps */
2
+ /** @typedef {typeof __propDef.events} TableCustomRenderComponentEvents */
3
+ /** @typedef {typeof __propDef.slots} TableCustomRenderComponentSlots */
4
+ export default class TableCustomRenderComponent extends SvelteComponent<{
5
+ cellValue: any;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {}> {
9
+ }
10
+ export type TableCustomRenderComponentProps = typeof __propDef.props;
11
+ export type TableCustomRenderComponentEvents = typeof __propDef.events;
12
+ export type TableCustomRenderComponentSlots = typeof __propDef.slots;
13
+ import { SvelteComponent } from "svelte";
14
+ declare const __propDef: {
15
+ props: {
16
+ cellValue: any;
17
+ };
18
+ events: {
19
+ [evt: string]: CustomEvent<any>;
20
+ };
21
+ slots: {};
22
+ exports?: undefined;
23
+ bindings?: undefined;
24
+ };
25
+ export {};
@@ -0,0 +1,65 @@
1
+ <style>
2
+ .buttonWrap {
3
+ opacity: 1;
4
+ transition: opacity 0.2s;
5
+ margin: 0;
6
+ }
7
+ .buttonWrap:not(:first-of-type) {
8
+ /* So we don't get a "double border" between tab buttons */
9
+ margin-inline-start: -1px;
10
+ }
11
+ .buttonWrap:hover {
12
+ opacity: 0.7;
13
+ }
14
+ .buttonWrap:hover:focus {
15
+ opacity: 1;
16
+ }
17
+ .tabButton:focus {
18
+ box-shadow: 0 0 0 var(--functional-focus-ring-outline-width)
19
+ var(--functional-focus-ring-color);
20
+ outline: var(--functional-focus-ring-outline-width)
21
+ var(--functional-focus-ring-outline-style)
22
+ var(--functional-focus-ring-outline-color);
23
+ transition: box-shadow var(--functional-timing-fast) ease-out;
24
+ }
25
+ .active .tabButton {
26
+ outline: 1px solid var(--functional-primary-hover);
27
+ }
28
+ </style>
29
+
30
+ <script>import Button from "../Button/Button.svelte";
31
+ export let isActive = false;
32
+ export let ariaControls = "";
33
+ export let disabled = false;
34
+ export let role = "tab";
35
+ let btn;
36
+ export function focus() {
37
+ return btn.focus();
38
+ }
39
+ export function isDisabled() {
40
+ return btn.disabled;
41
+ }
42
+ </script>
43
+
44
+ <div class="buttonWrap {isActive ? 'active' : ''}">
45
+ <!-- We're using our own button to manage aria et al and then use the Button of
46
+ type "faux" to get back a <div> styled like a button. We need to do this because
47
+ we need to bind:this={btn} so the Tabs library can call ref.focus() and
48
+ ref.isDisabled() from the a11y keyboard navigation code. -->
49
+ <button
50
+ style="background: transparent; border: none; padding: 0;"
51
+ on:click
52
+ on:keydown
53
+ bind:this="{btn}"
54
+ disabled="{disabled}"
55
+ role="{role}"
56
+ class="tabButton"
57
+ tabindex="{isActive ? 0 : -1}"
58
+ aria-controls="{ariaControls ? ariaControls : null}"
59
+ aria-selected="{isActive}"
60
+ >
61
+ <Button type="faux" isBordered mode="primary">
62
+ <slot />
63
+ </Button>
64
+ </button>
65
+ </div>
@@ -0,0 +1,35 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ /**
5
+ * You must expose this prop for your tab buttons to get proper
6
+ * aria-selected and to show an affordance of the selected tab.
7
+ * See the .active class -- we're using an outline but you can
8
+ * set that affordance up however you'd like.
9
+ */ isActive?: boolean;
10
+ ariaControls?: string;
11
+ disabled?: boolean;
12
+ role?: string;
13
+ focus?: () => any;
14
+ isDisabled?: () => any;
15
+ };
16
+ events: {
17
+ click: MouseEvent;
18
+ keydown: KeyboardEvent;
19
+ } & {
20
+ [evt: string]: CustomEvent<any>;
21
+ };
22
+ slots: {
23
+ default: {};
24
+ };
25
+ exports?: {} | undefined;
26
+ bindings?: string | undefined;
27
+ };
28
+ export type TabButtonCustomProps = typeof __propDef.props;
29
+ export type TabButtonCustomEvents = typeof __propDef.events;
30
+ export type TabButtonCustomSlots = typeof __propDef.slots;
31
+ export default class TabButtonCustom extends SvelteComponent<TabButtonCustomProps, TabButtonCustomEvents, TabButtonCustomSlots> {
32
+ get focus(): () => any;
33
+ get isDisabled(): () => any;
34
+ }
35
+ export {};