@functionalcms/svelte-components 3.0.6 → 3.0.8
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.
- package/dist/components/Banner.svelte +5 -3
- package/dist/components/Link.svelte +54 -44
- package/dist/components/Logo.svelte +15 -3
- package/dist/components/Spacer.svelte +10 -7
- package/dist/components/Well.svelte +15 -12
- package/dist/components/agnostic/Alert/Alert.svelte +64 -57
- package/dist/components/agnostic/Avatar/Avatar.svelte +19 -15
- package/dist/components/agnostic/Breadcrumb/Breadcrumb.svelte +19 -10
- package/dist/components/agnostic/Button/Button.svelte +60 -35
- package/dist/components/agnostic/Button/ButtonGroup.svelte +4 -3
- package/dist/components/agnostic/Card/Card.svelte +22 -18
- package/dist/components/agnostic/ChoiceInput/ChoiceInput.svelte +87 -59
- package/dist/components/agnostic/Close/Close.svelte +11 -7
- package/dist/components/agnostic/Dialog/Dialog.svelte +64 -42
- package/dist/components/agnostic/Dialog/SvelteA11yDialog.svelte +76 -51
- package/dist/components/agnostic/Disclose/Disclose.svelte +15 -9
- package/dist/components/agnostic/Divider/Divider.svelte +21 -11
- package/dist/components/agnostic/Drawer/Drawer.svelte +20 -16
- package/dist/components/agnostic/EmptyState/EmptyState.svelte +10 -7
- package/dist/components/agnostic/Header/Header.svelte +22 -15
- package/dist/components/agnostic/Header/HeaderNav.svelte +4 -3
- package/dist/components/agnostic/Header/HeaderNavItem.svelte +3 -2
- package/dist/components/agnostic/Icon/Icon.svelte +28 -20
- package/dist/components/agnostic/Loader/Loader.svelte +6 -3
- package/dist/components/agnostic/Progress/Progress.svelte +5 -4
- package/dist/components/agnostic/Spinner/Spinner.svelte +6 -3
- package/dist/components/agnostic/Table/Table.svelte +191 -134
- package/dist/components/agnostic/Tabs/TabButtonCustom.svelte +24 -12
- package/dist/components/agnostic/Tabs/Tabs.svelte +173 -104
- package/dist/components/agnostic/Tag/Tag.svelte +14 -10
- package/dist/components/agnostic/Tag/TagSlots.svelte +2 -1
- package/dist/components/agnostic/Toasts/Toasts.svelte +29 -19
- package/dist/components/agnostic/Tooltip/Tooltip.svelte +85 -68
- package/dist/components/agnostic/Tooltip/TooltipSlots.svelte +2 -1
- package/dist/components/blog/BlogDescription.svelte +6 -4
- package/dist/components/blog/BlogTitle.svelte +8 -6
- package/dist/components/form/Input.svelte +81 -52
- package/dist/components/form/Input.svelte.d.ts +2 -2
- package/dist/components/form/Select.svelte +40 -24
- package/dist/components/layouts/DefaultLayout.svelte +8 -5
- package/dist/components/layouts/Meta.svelte +7 -6
- package/dist/components/layouts/SimpleFooter.svelte +13 -3
- package/dist/components/layouts/Tracker.svelte +2 -1
- package/dist/components/layouts/TwoColumnsLayout.svelte +3 -2
- package/dist/components/markdown/markdown-parser.d.ts +1 -0
- package/dist/components/menu/CollapsibleMenu.svelte +18 -13
- package/dist/components/menu/DynamicMenu.svelte +16 -10
- package/dist/components/menu/HamburgerMenu.svelte +24 -18
- package/dist/components/menu/Menu.svelte +279 -219
- package/dist/components/menu/MenuItem.svelte +14 -10
- package/dist/components/menu/NavigationItems.svelte +18 -12
- package/dist/components/presentation/Carusel.svelte +77 -72
- package/dist/components/presentation/Gallery.svelte +14 -8
- package/package.json +10 -10
|
@@ -153,26 +153,34 @@
|
|
|
153
153
|
}
|
|
154
154
|
</style>
|
|
155
155
|
|
|
156
|
-
<script
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
export let
|
|
160
|
-
let
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
156
|
+
<script lang="ts">
|
|
157
|
+
import { onMount } from 'svelte';
|
|
158
|
+
import type { IconSize, IconType } from './api';
|
|
159
|
+
export let type: IconType = '';
|
|
160
|
+
export let size: IconSize = 14;
|
|
161
|
+
export let isSkinned = true;
|
|
162
|
+
let spanRef;
|
|
163
|
+
|
|
164
|
+
const iconClasses = [
|
|
165
|
+
"screenreader-only",
|
|
166
|
+
isSkinned ? "icon" : "icon-base",
|
|
167
|
+
type ? `icon-${type}` : "",
|
|
168
|
+
size ? `icon-${size}` : "",
|
|
169
|
+
]
|
|
170
|
+
.filter((cls) => cls)
|
|
171
|
+
.join(" ");
|
|
172
|
+
|
|
173
|
+
onMount(() => {
|
|
174
|
+
const svg = spanRef.querySelector("svg");
|
|
175
|
+
svg.classList.add("icon-svg");
|
|
176
|
+
if (svg) {
|
|
177
|
+
if (size) svg.classList.add(`icon-svg-${size}`);
|
|
178
|
+
if (type) svg.classList.add(`icon-svg-${type}`);
|
|
179
|
+
|
|
180
|
+
// Now that we've setup our SVG classes we can visually unhide the icon
|
|
181
|
+
spanRef.classList.remove("screenreader-only");
|
|
182
|
+
}
|
|
183
|
+
});
|
|
176
184
|
</script>
|
|
177
185
|
|
|
178
186
|
<span bind:this={spanRef} class={iconClasses}>
|
|
@@ -103,9 +103,12 @@
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
</style>
|
|
106
|
-
<script
|
|
107
|
-
export let
|
|
108
|
-
export let
|
|
106
|
+
<script lang="ts">
|
|
107
|
+
export let ariaLabel = "Loading…";
|
|
108
|
+
export let size: "small" | "large" | "" = "";
|
|
109
|
+
export let loaderClasses: string = ["loader", size ? `loader-${size}` : ""]
|
|
110
|
+
.filter((c) => c)
|
|
111
|
+
.join(" ");
|
|
109
112
|
</script>
|
|
110
113
|
|
|
111
114
|
<div class={loaderClasses} role="status" aria-live="polite" aria-busy="true">
|
|
@@ -41,10 +41,11 @@
|
|
|
41
41
|
|
|
42
42
|
</style>
|
|
43
43
|
|
|
44
|
-
<script
|
|
45
|
-
export let
|
|
46
|
-
export let
|
|
47
|
-
let
|
|
44
|
+
<script lang="ts">
|
|
45
|
+
export let value = 0;
|
|
46
|
+
export let max;
|
|
47
|
+
export let css = "";
|
|
48
|
+
let klasses: string = ["progress", css ? `${css}` : ""].filter(cl => cl && cl.length).join(' ');
|
|
48
49
|
</script>
|
|
49
50
|
|
|
50
51
|
<progress class={klasses} value={value} max={max}></progress>
|
|
@@ -95,9 +95,12 @@
|
|
|
95
95
|
|
|
96
96
|
</style>
|
|
97
97
|
|
|
98
|
-
<script
|
|
99
|
-
export let
|
|
100
|
-
|
|
98
|
+
<script lang="ts">
|
|
99
|
+
export let ariaLabel = "Loading…";
|
|
100
|
+
export let size: "small" | "large" | "xlarge" | "" = "";
|
|
101
|
+
$: spinnerClasses = ["spinner", size ? `spinner-${size}` : ""]
|
|
102
|
+
.filter((c) => c)
|
|
103
|
+
.join(" ");
|
|
101
104
|
</script>
|
|
102
105
|
|
|
103
106
|
<div class={spinnerClasses} role="status" aria-live="polite" aria-busy="true">
|
|
@@ -255,140 +255,197 @@
|
|
|
255
255
|
|
|
256
256
|
</style>
|
|
257
257
|
|
|
258
|
-
<script
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return rv
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
export let
|
|
277
|
-
|
|
278
|
-
export let
|
|
279
|
-
export let
|
|
280
|
-
export let
|
|
281
|
-
export let
|
|
282
|
-
export let
|
|
283
|
-
export let
|
|
284
|
-
let
|
|
285
|
-
let
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
return
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
);
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
|
|
258
|
+
<script lang="ts">
|
|
259
|
+
import { createEventDispatcher } from "svelte";
|
|
260
|
+
|
|
261
|
+
// Hack: Preserves way it was done in agnostic-svelte but ugly :(
|
|
262
|
+
interface ArrayMonkeyPatched extends Array<any> {
|
|
263
|
+
labelByKey(): any[];
|
|
264
|
+
}
|
|
265
|
+
export let headers: ArrayMonkeyPatched = [] as ArrayMonkeyPatched;
|
|
266
|
+
headers.labelByKey = function () {
|
|
267
|
+
return this.reduce(function (rv, x) {
|
|
268
|
+
if (!("key" in x))
|
|
269
|
+
throw new Error(
|
|
270
|
+
"Header must have key value with `sortByKey` set to `true`"
|
|
271
|
+
);
|
|
272
|
+
rv[x.key] = x;
|
|
273
|
+
return rv;
|
|
274
|
+
}, {});
|
|
275
|
+
};
|
|
276
|
+
export let rows = [];
|
|
277
|
+
|
|
278
|
+
export let caption = "";
|
|
279
|
+
export let captionPosition = "hidden";
|
|
280
|
+
export let tableSize = "";
|
|
281
|
+
export let responsiveSize = "";
|
|
282
|
+
export let isUppercasedHeaders = false;
|
|
283
|
+
export let isBordered = false;
|
|
284
|
+
export let isBorderless = false;
|
|
285
|
+
export let isStriped = false;
|
|
286
|
+
export let isHoverable = false;
|
|
287
|
+
export let isStacked = false;
|
|
288
|
+
export let filterByKey = false;
|
|
289
|
+
export let offset = 0;
|
|
290
|
+
export let limit = 0;
|
|
291
|
+
|
|
292
|
+
// State
|
|
293
|
+
let direction = "none";
|
|
294
|
+
let sortingKey = "";
|
|
295
|
+
|
|
296
|
+
// Trigger event on sort
|
|
297
|
+
const dispatch = createEventDispatcher();
|
|
298
|
+
$: dispatch("sort", {
|
|
299
|
+
direction,
|
|
300
|
+
sortingKey,
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
const pluckColumnToSort = (rowLeft, rowRight) => {
|
|
304
|
+
const colLeft =
|
|
305
|
+
rowLeft[sortingKey] === null || rowLeft[sortingKey] === undefined
|
|
306
|
+
? -Infinity
|
|
307
|
+
: rowLeft[sortingKey];
|
|
308
|
+
const colRight =
|
|
309
|
+
rowRight[sortingKey] === null || rowRight[sortingKey] === undefined
|
|
310
|
+
? -Infinity
|
|
311
|
+
: rowRight[sortingKey];
|
|
312
|
+
return {
|
|
313
|
+
colLeft,
|
|
314
|
+
colRight,
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
const internalSort = (rowLeft, rowRight) => {
|
|
319
|
+
let { colLeft, colRight } = pluckColumnToSort(rowLeft, rowRight);
|
|
320
|
+
|
|
321
|
+
const headerWithCustomSortFunction = headers.find(
|
|
322
|
+
(h) => h.key === sortingKey && !!h.sortFn
|
|
323
|
+
);
|
|
324
|
+
if (headerWithCustomSortFunction && headerWithCustomSortFunction.sortFn) {
|
|
325
|
+
return headerWithCustomSortFunction.sortFn(colLeft, colRight);
|
|
326
|
+
}
|
|
327
|
+
// No custom sort method for the header cell, so we continue with our own.
|
|
328
|
+
// Strings converted to lowercase; dollar currency etc. stripped (not yet i18n safe!)
|
|
329
|
+
colLeft =
|
|
330
|
+
typeof colLeft === "string"
|
|
331
|
+
? colLeft.toLowerCase().replace(/(^\$|,)/g, "")
|
|
332
|
+
: colLeft;
|
|
333
|
+
colRight =
|
|
334
|
+
typeof colRight === "string"
|
|
335
|
+
? colRight.toLowerCase().replace(/(^\$|,)/g, "")
|
|
336
|
+
: colRight;
|
|
337
|
+
// If raw value represents a number explicitly set to Number
|
|
338
|
+
colLeft = !Number.isNaN(Number(colLeft)) ? Number(colLeft) : colLeft;
|
|
339
|
+
colRight = !Number.isNaN(Number(colRight)) ? Number(colRight) : colRight;
|
|
340
|
+
if (colLeft > colRight) {
|
|
341
|
+
return 1;
|
|
342
|
+
}
|
|
343
|
+
if (colLeft < colRight) {
|
|
344
|
+
return -1;
|
|
345
|
+
}
|
|
346
|
+
return 0;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
// Simply flips the sign of results of the ascending sort
|
|
350
|
+
const descendingSort = (row1, row2) => internalSort(row1, row2) * -1;
|
|
351
|
+
|
|
352
|
+
$: columns = filterByKey ? headers.labelByKey() : { ...headers };
|
|
353
|
+
// Reactive declaration: ...state needs to be computed from other parts; so
|
|
354
|
+
// direction is a dependency and when it changes, sortableItems gets recomputed
|
|
355
|
+
$: sortableItems =
|
|
356
|
+
direction === "ascending"
|
|
357
|
+
? rows.sort(internalSort)
|
|
358
|
+
: direction === "descending"
|
|
359
|
+
? rows.sort(descendingSort)
|
|
360
|
+
: (sortableItems = [...rows]);
|
|
361
|
+
|
|
362
|
+
$: visibleItems = sortableItems.slice(
|
|
363
|
+
offset ? offset : 0,
|
|
364
|
+
limit ? offset + limit : undefined
|
|
365
|
+
);
|
|
366
|
+
|
|
367
|
+
const handleSortClicked = (headerKey: string) => {
|
|
368
|
+
if (sortingKey !== headerKey) {
|
|
369
|
+
direction = "none";
|
|
370
|
+
sortingKey = headerKey;
|
|
371
|
+
}
|
|
372
|
+
switch (direction) {
|
|
373
|
+
case "ascending":
|
|
374
|
+
direction = "descending";
|
|
375
|
+
break;
|
|
376
|
+
case "descending":
|
|
377
|
+
direction = "none";
|
|
378
|
+
break;
|
|
379
|
+
case "none":
|
|
380
|
+
direction = "ascending";
|
|
381
|
+
break;
|
|
382
|
+
default:
|
|
383
|
+
console.warn(
|
|
384
|
+
"Table sorting only supports directions: ascending | descending | none"
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
const getSortingClassesFor = (headerKey, direction, sortingKey) => {
|
|
390
|
+
if (sortingKey === headerKey) {
|
|
391
|
+
return [
|
|
392
|
+
"icon-sort",
|
|
393
|
+
direction && direction !== "none" ? `icon-sort-${direction}` : "",
|
|
394
|
+
]
|
|
395
|
+
.filter((klass) => klass.length)
|
|
396
|
+
.join(" ");
|
|
397
|
+
}
|
|
398
|
+
return "icon-sort";
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
const getSortDirectionFor = (headerKey, direction, sortingKey) => {
|
|
402
|
+
if (sortingKey !== headerKey) {
|
|
403
|
+
return "none";
|
|
404
|
+
} else {
|
|
405
|
+
return direction;
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
const tableResponsiveClasses = () => {
|
|
410
|
+
return [
|
|
411
|
+
!responsiveSize ? "table-responsive" : "",
|
|
412
|
+
responsiveSize ? `table-responsive-${responsiveSize}` : "",
|
|
413
|
+
]
|
|
414
|
+
.filter((klass) => klass.length)
|
|
415
|
+
.join(" ");
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
const tableClasses = () => {
|
|
419
|
+
return [
|
|
420
|
+
"table",
|
|
421
|
+
tableSize ? `table-${tableSize}` : "",
|
|
422
|
+
isUppercasedHeaders ? "table-caps" : "",
|
|
423
|
+
isBordered ? "table-bordered" : "",
|
|
424
|
+
isBorderless ? "table-borderless" : "",
|
|
425
|
+
isStriped ? "table-striped" : "",
|
|
426
|
+
isHoverable ? "table-hoverable" : "",
|
|
427
|
+
isStacked ? "table-stacked" : "",
|
|
428
|
+
]
|
|
429
|
+
.filter((klass) => klass.length)
|
|
430
|
+
.join(" ");
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
const captionClasses = () => {
|
|
434
|
+
return [
|
|
435
|
+
// .screenreader-only is expected to be globally available via common.min.css
|
|
436
|
+
captionPosition === "hidden" ? "screenreader-only" : "",
|
|
437
|
+
captionPosition !== "hidden" ? `caption-${captionPosition}` : "",
|
|
438
|
+
]
|
|
439
|
+
.filter((klass) => klass.length)
|
|
440
|
+
.join(" ");
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
const getKeys = (row) => {
|
|
444
|
+
const filteredKeys = filterByKey
|
|
445
|
+
? Object.keys(columns).map((key) => [key, key])
|
|
446
|
+
: Object.keys(row).map((key, index) => [key, index]);
|
|
447
|
+
return filteredKeys;
|
|
448
|
+
};
|
|
392
449
|
</script>
|
|
393
450
|
<div class="{tableResponsiveClasses()}">
|
|
394
451
|
<table class="{tableClasses()}">
|
|
@@ -27,18 +27,30 @@
|
|
|
27
27
|
}
|
|
28
28
|
</style>
|
|
29
29
|
|
|
30
|
-
<script
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
<script lang="ts">
|
|
31
|
+
// You can leverage all the prebuilt AgnosticUI buttons
|
|
32
|
+
import Button from '../Button/Button.svelte';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* You must expose this prop for your tab buttons to get proper
|
|
36
|
+
* aria-selected and to show an affordance of the selected tab.
|
|
37
|
+
* See the .active class -- we're using an outline but you can
|
|
38
|
+
* set that affordance up however you'd like.
|
|
39
|
+
*/
|
|
40
|
+
export let isActive = false;
|
|
41
|
+
export let ariaControls = '';
|
|
42
|
+
export let disabled = false;
|
|
43
|
+
export let role = 'tab';
|
|
44
|
+
|
|
45
|
+
// This is a component reference which we need to control the keyboard navigation
|
|
46
|
+
// in our tabs implementation. See: https://svelte.dev/tutorial/component-this
|
|
47
|
+
let btn;
|
|
48
|
+
export function focus() {
|
|
49
|
+
return btn.focus();
|
|
50
|
+
}
|
|
51
|
+
export function isDisabled() {
|
|
52
|
+
return btn.disabled;
|
|
53
|
+
}
|
|
42
54
|
</script>
|
|
43
55
|
|
|
44
56
|
<div class="buttonWrap {isActive ? 'active' : ''}">
|