@onsvisual/svelte-components 1.0.0-next.4 → 1.0.0-next.6
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/datavis/DataTile/DataTile.stories.svelte +28 -0
- package/dist/datavis/DataTile/DataTile.stories.svelte.d.ts +23 -0
- package/dist/datavis/DataTile/DataTile.svelte +56 -0
- package/dist/datavis/DataTile/DataTile.svelte.d.ts +37 -0
- package/dist/datavis/DataTile/docs/component.md +17 -0
- package/dist/datavis/Table/Table.svelte +6 -0
- package/dist/datavis/Table/Table.svelte.d.ts +2 -0
- package/dist/decorators/Divider/Divider.svelte +8 -3
- package/dist/decorators/Divider/Divider.svelte.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/inputs/Button/Button.svelte +7 -2
- package/dist/inputs/Button/Button.svelte.d.ts +2 -0
- package/dist/inputs/Checkbox/Checkbox.svelte +48 -39
- package/dist/inputs/Checkbox/Checkbox.svelte.d.ts +8 -6
- package/dist/inputs/Checkboxes/Checkboxes.stories.svelte +7 -15
- package/dist/inputs/Checkboxes/Checkboxes.svelte +35 -11
- package/dist/inputs/Checkboxes/Checkboxes.svelte.d.ts +6 -0
- package/dist/inputs/Checkboxes/docs/component.md +1 -1
- package/dist/inputs/Dropdown/Dropdown.svelte +6 -1
- package/dist/inputs/Dropdown/Dropdown.svelte.d.ts +2 -0
- package/dist/inputs/ErrorPanel/ErrorPanel.svelte +6 -1
- package/dist/inputs/ErrorPanel/ErrorPanel.svelte.d.ts +2 -0
- package/dist/inputs/ErrorSummary/ErrorSummary.svelte +6 -1
- package/dist/inputs/ErrorSummary/ErrorSummary.svelte.d.ts +2 -0
- package/dist/inputs/Input/Input.svelte +6 -1
- package/dist/inputs/Input/Input.svelte.d.ts +2 -0
- package/dist/inputs/Radios/Radio.svelte +31 -22
- package/dist/inputs/Radios/Radio.svelte.d.ts +8 -6
- package/dist/inputs/Radios/Radios.svelte +35 -19
- package/dist/inputs/Radios/Radios.svelte.d.ts +8 -2
- package/dist/inputs/Radios/docs/component.md +2 -2
- package/dist/inputs/Select/Select.svelte +6 -1
- package/dist/inputs/Select/Select.svelte.d.ts +2 -0
- package/dist/inputs/Textarea/Textarea.svelte +6 -1
- package/dist/inputs/Textarea/Textarea.svelte.d.ts +2 -0
- package/dist/intro.mdx +9 -2
- package/dist/layout/Accordion/Accordion.svelte +1 -1
- package/dist/layout/Accordion/Accordion.svelte.d.ts +2 -2
- package/dist/layout/Breadcrumb/Breadcrumb.svelte +11 -1
- package/dist/layout/Breadcrumb/Breadcrumb.svelte.d.ts +4 -0
- package/dist/layout/Card/Card.svelte +1 -1
- package/dist/layout/Card/Card.svelte.d.ts +2 -2
- package/dist/layout/Contents/Contents.svelte +6 -1
- package/dist/layout/Contents/Contents.svelte.d.ts +2 -0
- package/dist/layout/DescriptionList/DescriptionList.svelte +6 -1
- package/dist/layout/DescriptionList/DescriptionList.svelte.d.ts +2 -0
- package/dist/layout/Details/Details.svelte +6 -1
- package/dist/layout/Details/Details.svelte.d.ts +2 -0
- package/dist/layout/DocumentList/DocumentList.svelte +6 -1
- package/dist/layout/DocumentList/DocumentList.svelte.d.ts +2 -0
- package/dist/layout/Footer/Footer.svelte +1 -1
- package/dist/layout/Footer/Footer.svelte.d.ts +4 -4
- package/dist/layout/Grid/Grid.svelte +3 -3
- package/dist/layout/Grid/Grid.svelte.d.ts +2 -2
- package/dist/layout/Header/Header.svelte +1 -1
- package/dist/layout/Header/Header.svelte.d.ts +4 -4
- package/dist/layout/Hero/Hero.stories.svelte +2 -1
- package/dist/layout/Hero/Hero.svelte +9 -8
- package/dist/layout/Hero/Hero.svelte.d.ts +8 -6
- package/dist/layout/Highlight/Highlight.svelte +15 -22
- package/dist/layout/Highlight/Highlight.svelte.d.ts +6 -6
- package/dist/layout/Image/Image.svelte +6 -1
- package/dist/layout/Image/Image.svelte.d.ts +2 -0
- package/dist/layout/List/List.svelte +6 -1
- package/dist/layout/List/List.svelte.d.ts +2 -0
- package/dist/layout/NavSections/NavSection.svelte +1 -1
- package/dist/layout/NavSections/NavSection.svelte.d.ts +2 -2
- package/dist/layout/NavSections/NavSections.svelte +3 -3
- package/dist/layout/NavSections/NavSections.svelte.d.ts +2 -2
- package/dist/layout/Notice/Notice.svelte +6 -1
- package/dist/layout/Notice/Notice.svelte.d.ts +2 -0
- package/dist/layout/PhaseBanner/PhaseBanner.svelte +6 -1
- package/dist/layout/PhaseBanner/PhaseBanner.svelte.d.ts +2 -0
- package/dist/layout/RelatedContent/RelatedContent.svelte +6 -1
- package/dist/layout/RelatedContent/RelatedContent.svelte.d.ts +2 -0
- package/dist/layout/Scroller/Scroller.svelte +6 -1
- package/dist/layout/Scroller/Scroller.svelte.d.ts +2 -0
- package/dist/layout/Scroller/ScrollerSection.svelte +6 -1
- package/dist/layout/Scroller/ScrollerSection.svelte.d.ts +2 -0
- package/dist/layout/Section/Section.svelte +3 -3
- package/dist/layout/Section/Section.svelte.d.ts +2 -2
- package/dist/layout/ShareButtons/ShareButtons.svelte +8 -3
- package/dist/layout/ShareButtons/ShareButtons.svelte.d.ts +2 -0
- package/dist/layout/Summary/Summary.svelte +6 -1
- package/dist/layout/Summary/Summary.svelte.d.ts +2 -0
- package/dist/layout/Tabs/Tabs.svelte +6 -1
- package/dist/layout/Tabs/Tabs.svelte.d.ts +2 -0
- package/dist/templates/intro.mdx +1 -1
- package/dist/wrappers/Container/Container.svelte +41 -28
- package/dist/wrappers/Container/Container.svelte.d.ts +8 -4
- package/dist/wrappers/Container/docs/component.md +4 -2
- package/dist/wrappers/Theme/Theme.svelte +4 -4
- package/dist/wrappers/Theme/Theme.svelte.d.ts +6 -6
- package/dist/wrappers/Theme/docs/component.md +1 -1
- package/dist/wrappers/Theme/themes.d.ts +28 -0
- package/dist/wrappers/Theme/themes.js +2 -1
- package/package.json +1 -1
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
* @type {string}
|
|
5
5
|
*/
|
|
6
6
|
export let message = "";
|
|
7
|
+
/**
|
|
8
|
+
* Optional: Set an additional CSS class for the component
|
|
9
|
+
* @type {string}
|
|
10
|
+
*/
|
|
11
|
+
export let cls = "";
|
|
7
12
|
</script>
|
|
8
13
|
|
|
9
|
-
<div class="ons-panel ons-panel--error ons-panel--no-title" id="number-of-employees-error">
|
|
14
|
+
<div class="ons-panel ons-panel--error ons-panel--no-title {cls}" id="number-of-employees-error">
|
|
10
15
|
<span class="ons-panel__assistive-text ons-u-vh">Error: </span>
|
|
11
16
|
<div class="ons-panel__body">
|
|
12
17
|
{#if message}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} ErrorPanelEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} ErrorPanelSlots */
|
|
4
4
|
export default class ErrorPanel extends SvelteComponentTyped<{
|
|
5
|
+
cls?: string | undefined;
|
|
5
6
|
message?: string | undefined;
|
|
6
7
|
}, {
|
|
7
8
|
[evt: string]: CustomEvent<any>;
|
|
@@ -15,6 +16,7 @@ export type ErrorPanelSlots = typeof __propDef.slots;
|
|
|
15
16
|
import { SvelteComponentTyped } from "svelte";
|
|
16
17
|
declare const __propDef: {
|
|
17
18
|
props: {
|
|
19
|
+
cls?: string | undefined;
|
|
18
20
|
message?: string | undefined;
|
|
19
21
|
};
|
|
20
22
|
events: {
|
|
@@ -11,9 +11,14 @@
|
|
|
11
11
|
* @type {object[]}
|
|
12
12
|
*/
|
|
13
13
|
export let items = [];
|
|
14
|
+
/**
|
|
15
|
+
* Optional: Set an additional CSS class for the component
|
|
16
|
+
* @type {string}
|
|
17
|
+
*/
|
|
18
|
+
export let cls = "";
|
|
14
19
|
</script>
|
|
15
20
|
|
|
16
|
-
<div aria-labelledby="alert" role="alert" tabindex="-1" class="ons-panel ons-panel--error">
|
|
21
|
+
<div aria-labelledby="alert" role="alert" tabindex="-1" class="ons-panel ons-panel--error {cls}">
|
|
17
22
|
<div class="ons-panel__header">
|
|
18
23
|
<h2 id="alert" data-qa="error-header" class="ons-panel__title ons-u-fs-r--b">{title}</h2>
|
|
19
24
|
</div>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} ErrorSummaryEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} ErrorSummarySlots */
|
|
4
4
|
export default class ErrorSummary extends SvelteComponentTyped<{
|
|
5
|
+
cls?: string | undefined;
|
|
5
6
|
title?: string | undefined;
|
|
6
7
|
items?: object[] | undefined;
|
|
7
8
|
}, {
|
|
@@ -16,6 +17,7 @@ export type ErrorSummarySlots = typeof __propDef.slots;
|
|
|
16
17
|
import { SvelteComponentTyped } from "svelte";
|
|
17
18
|
declare const __propDef: {
|
|
18
19
|
props: {
|
|
20
|
+
cls?: string | undefined;
|
|
19
21
|
title?: string | undefined;
|
|
20
22
|
items?: object[] | undefined;
|
|
21
23
|
};
|
|
@@ -68,9 +68,14 @@
|
|
|
68
68
|
* @type {boolean}
|
|
69
69
|
*/
|
|
70
70
|
export let error = false;
|
|
71
|
+
/**
|
|
72
|
+
* Optional: Set an additional CSS class for the component
|
|
73
|
+
* @type {string}
|
|
74
|
+
*/
|
|
75
|
+
export let cls = "";
|
|
71
76
|
</script>
|
|
72
77
|
|
|
73
|
-
<div class="ons-field">
|
|
78
|
+
<div class="ons-field {cls}">
|
|
74
79
|
{#if label}
|
|
75
80
|
<label
|
|
76
81
|
class="ons-label"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} InputEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} InputSlots */
|
|
4
4
|
export default class Input extends SvelteComponentTyped<{
|
|
5
|
+
cls?: string | undefined;
|
|
5
6
|
id?: string | undefined;
|
|
6
7
|
width?: number | undefined;
|
|
7
8
|
label?: string | undefined;
|
|
@@ -27,6 +28,7 @@ export type InputSlots = typeof __propDef.slots;
|
|
|
27
28
|
import { SvelteComponentTyped } from "svelte";
|
|
28
29
|
declare const __propDef: {
|
|
29
30
|
props: {
|
|
31
|
+
cls?: string | undefined;
|
|
30
32
|
id?: string | undefined;
|
|
31
33
|
width?: number | undefined;
|
|
32
34
|
label?: string | undefined;
|
|
@@ -7,27 +7,32 @@
|
|
|
7
7
|
* Unique ID input
|
|
8
8
|
* @type {string}
|
|
9
9
|
*/
|
|
10
|
-
export let id;
|
|
10
|
+
export let id = "";
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Label for input
|
|
13
13
|
* @type {string}
|
|
14
14
|
*/
|
|
15
|
-
export let
|
|
15
|
+
export let label = "";
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Optional: Extended description for element
|
|
18
18
|
* @type {string}
|
|
19
19
|
*/
|
|
20
|
-
export let
|
|
20
|
+
export let description = "";
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @type {
|
|
22
|
+
* Optional: Define the item as an object in the form {id, label, description?}
|
|
23
|
+
* @type {object}
|
|
24
24
|
*/
|
|
25
|
-
export let
|
|
25
|
+
export let item = { id, label, description };
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* ID for radio group (required)
|
|
28
28
|
* @type {string}
|
|
29
29
|
*/
|
|
30
|
-
export let
|
|
30
|
+
export let groupId;
|
|
31
|
+
/**
|
|
32
|
+
* Binding selected option
|
|
33
|
+
* @type {object|null}
|
|
34
|
+
*/
|
|
35
|
+
export let value = null;
|
|
31
36
|
/**
|
|
32
37
|
* Compact mode (no border)
|
|
33
38
|
* @type {boolean}
|
|
@@ -39,35 +44,39 @@
|
|
|
39
44
|
<span class="ons-radio" class:ons-radio--no-border={compact}>
|
|
40
45
|
<input
|
|
41
46
|
type="radio"
|
|
42
|
-
{id}
|
|
43
|
-
|
|
44
|
-
value={id}
|
|
47
|
+
id={item.id}
|
|
48
|
+
value={item}
|
|
45
49
|
name={groupId}
|
|
46
50
|
class="ons-radio__input ons-js-radio"
|
|
47
|
-
on:change={(e) =>
|
|
51
|
+
on:change={(e) => {
|
|
52
|
+
if (e?.target?.checked) {
|
|
53
|
+
value = item;
|
|
54
|
+
dispatch("change", { value, e });
|
|
55
|
+
}
|
|
56
|
+
}}
|
|
48
57
|
/>
|
|
49
58
|
<label
|
|
50
59
|
class="ons-radio__label"
|
|
51
60
|
class:ons-label--with-description={description}
|
|
52
|
-
for={id}
|
|
53
|
-
id="{id}-label"
|
|
54
|
-
aria-describedby={description ? `${id}-label-description-hint` : null}
|
|
61
|
+
for={item.id}
|
|
62
|
+
id="{item.id}-label"
|
|
63
|
+
aria-describedby={item.description ? `${item.id}-label-description-hint` : null}
|
|
55
64
|
>
|
|
56
|
-
{label}
|
|
57
|
-
{#if description}
|
|
65
|
+
{item.label}
|
|
66
|
+
{#if item.description}
|
|
58
67
|
<span class="ons-label__aria-hidden-description" aria-hidden="true"
|
|
59
68
|
><span class="ons-label__description ons-radio__label--with-description">
|
|
60
|
-
{description}
|
|
69
|
+
{item.description}
|
|
61
70
|
</span></span
|
|
62
71
|
>
|
|
63
72
|
{/if}
|
|
64
73
|
</label>
|
|
65
|
-
{#if description}
|
|
74
|
+
{#if item.description}
|
|
66
75
|
<span
|
|
67
76
|
class="ons-label__visually-hidden-description ons-u-vh"
|
|
68
77
|
id="{id}-label-description-hint"
|
|
69
78
|
>
|
|
70
|
-
{description}
|
|
79
|
+
{item.description}
|
|
71
80
|
</span>
|
|
72
81
|
{/if}
|
|
73
82
|
</span>
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} RadioEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} RadioSlots */
|
|
4
4
|
export default class Radio extends SvelteComponentTyped<{
|
|
5
|
-
id: string;
|
|
6
|
-
label: string;
|
|
7
5
|
groupId: string;
|
|
6
|
+
id?: string | undefined;
|
|
7
|
+
label?: string | undefined;
|
|
8
8
|
compact?: boolean | undefined;
|
|
9
|
-
value?:
|
|
9
|
+
value?: object | null | undefined;
|
|
10
10
|
description?: string | undefined;
|
|
11
|
+
item?: object | undefined;
|
|
11
12
|
}, {
|
|
12
13
|
change: CustomEvent<any>;
|
|
13
14
|
} & {
|
|
@@ -20,12 +21,13 @@ export type RadioSlots = typeof __propDef.slots;
|
|
|
20
21
|
import { SvelteComponentTyped } from "svelte";
|
|
21
22
|
declare const __propDef: {
|
|
22
23
|
props: {
|
|
23
|
-
id: string;
|
|
24
|
-
label: string;
|
|
25
24
|
groupId: string;
|
|
25
|
+
id?: string | undefined;
|
|
26
|
+
label?: string | undefined;
|
|
26
27
|
compact?: boolean | undefined;
|
|
27
|
-
value?:
|
|
28
|
+
value?: object | null | undefined;
|
|
28
29
|
description?: string | undefined;
|
|
30
|
+
item?: object | undefined;
|
|
29
31
|
};
|
|
30
32
|
events: {
|
|
31
33
|
change: CustomEvent<any>;
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import Radio from "./Radio.svelte";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Title/legend for parent <fieldset>
|
|
6
|
+
* @type {string}
|
|
7
|
+
*/
|
|
8
|
+
export let title = "";
|
|
9
|
+
/**
|
|
10
|
+
* Visually hide the title/legend
|
|
11
|
+
* @type {boolean}
|
|
12
|
+
*/
|
|
13
|
+
export let hideTitle = false;
|
|
4
14
|
/**
|
|
5
15
|
* Unique ID for radio group (required)
|
|
6
16
|
* @type {string}
|
|
7
17
|
*/
|
|
8
18
|
export let id = "name";
|
|
9
19
|
/**
|
|
10
|
-
*
|
|
20
|
+
* Descriptive "how to" label for inputs
|
|
11
21
|
* @type {string}
|
|
12
22
|
*/
|
|
13
23
|
export let label = "";
|
|
14
24
|
/**
|
|
15
25
|
* Binding for ID of selected option
|
|
16
|
-
* @type {
|
|
26
|
+
* @type {object|null}
|
|
17
27
|
*/
|
|
18
28
|
export let value = null;
|
|
19
29
|
/** Optional: Define the radios as an array of {id, label, description?}
|
|
@@ -25,22 +35,28 @@
|
|
|
25
35
|
* @type {boolean}
|
|
26
36
|
*/
|
|
27
37
|
export let compact = false;
|
|
38
|
+
/**
|
|
39
|
+
* Optional: Set an additional CSS class for the component
|
|
40
|
+
* @type {string}
|
|
41
|
+
*/
|
|
42
|
+
export let cls = "";
|
|
28
43
|
</script>
|
|
29
44
|
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</div>
|
|
45
|
+
<fieldset class="ons-fieldset {cls}">
|
|
46
|
+
{#if title}
|
|
47
|
+
<legend class="ons-fieldset__legend ons-u-mb-no">
|
|
48
|
+
<span class="ons-fieldset__legend-title ons-u-pb-no" class:ons-u-vh={hideTitle}>{title}</span>
|
|
49
|
+
</legend>
|
|
50
|
+
{/if}
|
|
51
|
+
<div class="ons-input-items">
|
|
52
|
+
{#if label}
|
|
53
|
+
<p class="ons-radios__label">{label}</p>
|
|
54
|
+
{/if}
|
|
55
|
+
<div class="ons-radios__items">
|
|
56
|
+
<slot />
|
|
57
|
+
{#each items as item}
|
|
58
|
+
<Radio {item} groupId={id} {compact} bind:value on:change />
|
|
59
|
+
{/each}
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</fieldset>
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} RadiosEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} RadiosSlots */
|
|
4
4
|
export default class Radios extends SvelteComponentTyped<{
|
|
5
|
+
cls?: string | undefined;
|
|
5
6
|
id?: string | undefined;
|
|
6
7
|
label?: string | undefined;
|
|
8
|
+
title?: string | undefined;
|
|
7
9
|
compact?: boolean | undefined;
|
|
10
|
+
hideTitle?: boolean | undefined;
|
|
8
11
|
items?: object[] | undefined;
|
|
9
|
-
value?:
|
|
12
|
+
value?: object | null | undefined;
|
|
10
13
|
}, {
|
|
11
14
|
change: CustomEvent<any>;
|
|
12
15
|
} & {
|
|
@@ -21,11 +24,14 @@ export type RadiosSlots = typeof __propDef.slots;
|
|
|
21
24
|
import { SvelteComponentTyped } from "svelte";
|
|
22
25
|
declare const __propDef: {
|
|
23
26
|
props: {
|
|
27
|
+
cls?: string | undefined;
|
|
24
28
|
id?: string | undefined;
|
|
25
29
|
label?: string | undefined;
|
|
30
|
+
title?: string | undefined;
|
|
26
31
|
compact?: boolean | undefined;
|
|
32
|
+
hideTitle?: boolean | undefined;
|
|
27
33
|
items?: object[] | undefined;
|
|
28
|
-
value?:
|
|
34
|
+
value?: object | null | undefined;
|
|
29
35
|
};
|
|
30
36
|
events: {
|
|
31
37
|
change: CustomEvent<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
A component for defining a group of radio inputs, where the selected item id can be bound to a Svelte variable.
|
|
2
2
|
|
|
3
|
-
Based on [this ONS Design System component](https://service-manual.ons.gov.uk/design-system/components/radios).
|
|
3
|
+
Based on [this ONS Design System component](https://service-manual.ons.gov.uk/design-system/components/radios). (Note: In some use cases, it may be preferable to use raw HTML `<input type="radio">` components and style these using CSS.)
|
|
4
4
|
|
|
5
5
|
<!-- prettier-ignore -->
|
|
6
6
|
```html
|
|
@@ -17,7 +17,7 @@ Based on [this ONS Design System component](https://service-manual.ons.gov.uk/de
|
|
|
17
17
|
{ id: "mobile", label: "Caravan or other mobile or temporary structure" },
|
|
18
18
|
];
|
|
19
19
|
|
|
20
|
-
let selected; // A binding for the selected item
|
|
20
|
+
let selected; // A binding for the selected item
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
23
|
<Radios {items} bind:value={selected} label="Select one">
|
|
@@ -108,6 +108,11 @@
|
|
|
108
108
|
hideMenu = false;
|
|
109
109
|
dispatch("clear", value);
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Optional: Set an additional CSS class for the component
|
|
113
|
+
* @type {string}
|
|
114
|
+
*/
|
|
115
|
+
export let cls = "";
|
|
111
116
|
|
|
112
117
|
function inputValueTemplate(result) {
|
|
113
118
|
return result && result[labelKey];
|
|
@@ -183,7 +188,7 @@
|
|
|
183
188
|
<script src={scriptUrl} on:load={handleScriptLoad}></script>
|
|
184
189
|
</svelte:head>
|
|
185
190
|
|
|
186
|
-
<div class="ons-field">
|
|
191
|
+
<div class="ons-field {cls}">
|
|
187
192
|
{#if label}<label for={id} class="ons-label" class:ons-u-vh={hideLabel}>{label}</label>{/if}
|
|
188
193
|
<div class="ons-autocomplete-wrapper">
|
|
189
194
|
{#if scriptLoaded}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} SelectEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} SelectSlots */
|
|
4
4
|
export default class Select extends SvelteComponentTyped<{
|
|
5
|
+
cls?: string | undefined;
|
|
5
6
|
id?: string | undefined;
|
|
6
7
|
label?: string | undefined;
|
|
7
8
|
mode?: "default" | "search" | undefined;
|
|
@@ -31,6 +32,7 @@ export type SelectSlots = typeof __propDef.slots;
|
|
|
31
32
|
import { SvelteComponentTyped } from "svelte";
|
|
32
33
|
declare const __propDef: {
|
|
33
34
|
props: {
|
|
35
|
+
cls?: string | undefined;
|
|
34
36
|
id?: string | undefined;
|
|
35
37
|
label?: string | undefined;
|
|
36
38
|
mode?: "default" | "search" | undefined;
|
|
@@ -43,11 +43,16 @@
|
|
|
43
43
|
* @type {number}
|
|
44
44
|
*/
|
|
45
45
|
export let width = 30;
|
|
46
|
+
/**
|
|
47
|
+
* Optional: Set an additional CSS class for the component
|
|
48
|
+
* @type {string}
|
|
49
|
+
*/
|
|
50
|
+
export let cls = "";
|
|
46
51
|
|
|
47
52
|
$: remaining = charLimit && value.length ? charLimit - value.length : charLimit || null;
|
|
48
53
|
</script>
|
|
49
54
|
|
|
50
|
-
<div class="ons-field">
|
|
55
|
+
<div class="ons-field {cls}">
|
|
51
56
|
{#if label}
|
|
52
57
|
<label
|
|
53
58
|
class="ons-label ons-label--with-description"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} TextareaEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} TextareaSlots */
|
|
4
4
|
export default class Textarea extends SvelteComponentTyped<{
|
|
5
|
+
cls?: string | undefined;
|
|
5
6
|
id?: string | undefined;
|
|
6
7
|
width?: number | undefined;
|
|
7
8
|
label?: string | undefined;
|
|
@@ -20,6 +21,7 @@ export type TextareaSlots = typeof __propDef.slots;
|
|
|
20
21
|
import { SvelteComponentTyped } from "svelte";
|
|
21
22
|
declare const __propDef: {
|
|
22
23
|
props: {
|
|
24
|
+
cls?: string | undefined;
|
|
23
25
|
id?: string | undefined;
|
|
24
26
|
width?: number | undefined;
|
|
25
27
|
label?: string | undefined;
|
package/dist/intro.mdx
CHANGED
|
@@ -47,14 +47,21 @@ npm install @onsvisual/svelte-components --save-dev
|
|
|
47
47
|
|
|
48
48
|
## Using the components
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
When using the components, you need to import both the desired component and the global CSS styles. In a SvelteKit project it is best to import the CSS in a top-level **+layout.svelte** file in your **src/routes** folder, which will apply it to all pages/components in the project.
|
|
51
51
|
|
|
52
52
|
{/* prettier-ignore */}
|
|
53
53
|
```html
|
|
54
|
+
<!-- +layout.svelte -->
|
|
54
55
|
<script>
|
|
55
56
|
import "@onsvisual/svelte-components/css/main.css";
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<slot/>
|
|
60
|
+
|
|
61
|
+
<!-- +page.svelte / Component.svelte -->
|
|
62
|
+
<script>
|
|
56
63
|
import { Section } from "@onsvisual/svelte-components";
|
|
57
64
|
</script>
|
|
58
65
|
|
|
59
|
-
<Section title="Hello world!">
|
|
66
|
+
<Section title="Hello world!">I am using an ONS Svelte component.</Section>
|
|
60
67
|
```
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} AccordionEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} AccordionSlots */
|
|
4
4
|
export default class Accordion extends SvelteComponentTyped<{
|
|
5
|
-
id?: string | undefined;
|
|
6
5
|
cls?: string | undefined;
|
|
6
|
+
id?: string | undefined;
|
|
7
7
|
showToggle?: boolean | undefined;
|
|
8
8
|
}, {
|
|
9
9
|
[evt: string]: CustomEvent<any>;
|
|
@@ -17,8 +17,8 @@ export type AccordionSlots = typeof __propDef.slots;
|
|
|
17
17
|
import { SvelteComponentTyped } from "svelte";
|
|
18
18
|
declare const __propDef: {
|
|
19
19
|
props: {
|
|
20
|
-
id?: string | undefined;
|
|
21
20
|
cls?: string | undefined;
|
|
21
|
+
id?: string | undefined;
|
|
22
22
|
showToggle?: boolean | undefined;
|
|
23
23
|
};
|
|
24
24
|
events: {
|
|
@@ -16,9 +16,19 @@
|
|
|
16
16
|
* @type {"narrow"|"medium"|"wide"|"wider"|"full"}
|
|
17
17
|
*/
|
|
18
18
|
export let width = "wide";
|
|
19
|
+
/**
|
|
20
|
+
* Optional: Set an additional CSS class for the component
|
|
21
|
+
* @type {string}
|
|
22
|
+
*/
|
|
23
|
+
export let cls = "";
|
|
24
|
+
/**
|
|
25
|
+
* Overrides the base theme background (accepts any valid CSS background value)
|
|
26
|
+
* @type {string|null}
|
|
27
|
+
*/
|
|
28
|
+
export let background = null;
|
|
19
29
|
</script>
|
|
20
30
|
|
|
21
|
-
<Container {width}>
|
|
31
|
+
<Container {width} {background} {cls}>
|
|
22
32
|
<nav class="ons-breadcrumbs" aria-label="Breadcrumbs">
|
|
23
33
|
<ol class="ons-breadcrumbs__items ons-u-fs-s">
|
|
24
34
|
{#each backHref ? [{ label: "Back", href: backHref }] : links as link}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} BreadcrumbEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} BreadcrumbSlots */
|
|
4
4
|
export default class Breadcrumb extends SvelteComponentTyped<{
|
|
5
|
+
background?: string | null | undefined;
|
|
6
|
+
cls?: string | undefined;
|
|
5
7
|
width?: "narrow" | "medium" | "wide" | "wider" | "full" | undefined;
|
|
6
8
|
links?: object[] | undefined;
|
|
7
9
|
backHref?: string | undefined;
|
|
@@ -15,6 +17,8 @@ export type BreadcrumbSlots = typeof __propDef.slots;
|
|
|
15
17
|
import { SvelteComponentTyped } from "svelte";
|
|
16
18
|
declare const __propDef: {
|
|
17
19
|
props: {
|
|
20
|
+
background?: string | null | undefined;
|
|
21
|
+
cls?: string | undefined;
|
|
18
22
|
width?: "narrow" | "medium" | "wide" | "wider" | "full" | undefined;
|
|
19
23
|
links?: object[] | undefined;
|
|
20
24
|
backHref?: string | undefined;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} CardEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} CardSlots */
|
|
4
4
|
export default class Card extends SvelteComponentTyped<{
|
|
5
|
-
id?: string | undefined;
|
|
6
5
|
cls?: string | undefined;
|
|
6
|
+
id?: string | undefined;
|
|
7
7
|
title?: string | undefined;
|
|
8
8
|
image?: string | undefined;
|
|
9
9
|
headingTag?: "h2" | "h3" | undefined;
|
|
@@ -27,8 +27,8 @@ export type CardSlots = typeof __propDef.slots;
|
|
|
27
27
|
import { SvelteComponentTyped } from "svelte";
|
|
28
28
|
declare const __propDef: {
|
|
29
29
|
props: {
|
|
30
|
-
id?: string | undefined;
|
|
31
30
|
cls?: string | undefined;
|
|
31
|
+
id?: string | undefined;
|
|
32
32
|
title?: string | undefined;
|
|
33
33
|
image?: string | undefined;
|
|
34
34
|
headingTag?: "h2" | "h3" | undefined;
|
|
@@ -19,9 +19,14 @@
|
|
|
19
19
|
* @type {string}
|
|
20
20
|
*/
|
|
21
21
|
export let skipHref = "";
|
|
22
|
+
/**
|
|
23
|
+
* Optional: Set an additional CSS class for the component
|
|
24
|
+
* @type {string}
|
|
25
|
+
*/
|
|
26
|
+
export let cls = "";
|
|
22
27
|
</script>
|
|
23
28
|
|
|
24
|
-
<aside class="ons-table-of-contents-container" role="complementary">
|
|
29
|
+
<aside class="ons-table-of-contents-container {cls}" role="complementary">
|
|
25
30
|
{#if skipHref}
|
|
26
31
|
<a class="ons-skip-to-content" href="#0">Skip to guide content</a>
|
|
27
32
|
{/if}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} ContentsEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} ContentsSlots */
|
|
4
4
|
export default class Contents extends SvelteComponentTyped<{
|
|
5
|
+
cls?: string | undefined;
|
|
5
6
|
title?: string | undefined;
|
|
6
7
|
links?: object[] | undefined;
|
|
7
8
|
hideTitle?: boolean | undefined;
|
|
@@ -16,6 +17,7 @@ export type ContentsSlots = typeof __propDef.slots;
|
|
|
16
17
|
import { SvelteComponentTyped } from "svelte";
|
|
17
18
|
declare const __propDef: {
|
|
18
19
|
props: {
|
|
20
|
+
cls?: string | undefined;
|
|
19
21
|
title?: string | undefined;
|
|
20
22
|
links?: object[] | undefined;
|
|
21
23
|
hideTitle?: boolean | undefined;
|
|
@@ -14,10 +14,15 @@
|
|
|
14
14
|
* @type {"default"|"inline"}
|
|
15
15
|
*/
|
|
16
16
|
export let mode = "default";
|
|
17
|
+
/**
|
|
18
|
+
* Optional: Set an additional CSS class for the component
|
|
19
|
+
* @type {string}
|
|
20
|
+
*/
|
|
21
|
+
export let cls = "";
|
|
17
22
|
</script>
|
|
18
23
|
|
|
19
24
|
<dl
|
|
20
|
-
class="ons-description-list ons-description-list__items ons-grid ons-grid--gutterless ons-u-mb-no {mode ===
|
|
25
|
+
class="ons-description-list ons-description-list__items ons-grid ons-grid--gutterless ons-u-mb-no {cls} {mode ===
|
|
21
26
|
'inline'
|
|
22
27
|
? 'ons-u-mt-s ons-u-mt-l@l'
|
|
23
28
|
: 'ons-u-cf'}"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} DescriptionListEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} DescriptionListSlots */
|
|
4
4
|
export default class DescriptionList extends SvelteComponentTyped<{
|
|
5
|
+
cls?: string | undefined;
|
|
5
6
|
title?: string | undefined;
|
|
6
7
|
mode?: "default" | "inline" | undefined;
|
|
7
8
|
items?: object[] | undefined;
|
|
@@ -15,6 +16,7 @@ export type DescriptionListSlots = typeof __propDef.slots;
|
|
|
15
16
|
import { SvelteComponentTyped } from "svelte";
|
|
16
17
|
declare const __propDef: {
|
|
17
18
|
props: {
|
|
19
|
+
cls?: string | undefined;
|
|
18
20
|
title?: string | undefined;
|
|
19
21
|
mode?: "default" | "inline" | undefined;
|
|
20
22
|
items?: object[] | undefined;
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
* @type {boolean}
|
|
19
19
|
*/
|
|
20
20
|
export let open = false;
|
|
21
|
+
/**
|
|
22
|
+
* Optional: Set an additional CSS class for the component
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
25
|
+
export let cls = "";
|
|
21
26
|
|
|
22
27
|
function doToggle(e) {
|
|
23
28
|
dispatch("toggle", { open: e.newState === "open", e });
|
|
@@ -25,7 +30,7 @@
|
|
|
25
30
|
</script>
|
|
26
31
|
|
|
27
32
|
<details
|
|
28
|
-
class="ons-details ons-js-details ons-details--initialised"
|
|
33
|
+
class="ons-details ons-js-details ons-details--initialised {cls}"
|
|
29
34
|
class:ons-details--open={open}
|
|
30
35
|
bind:open
|
|
31
36
|
on:toggle={doToggle}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} DetailsEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} DetailsSlots */
|
|
4
4
|
export default class Details extends SvelteComponentTyped<{
|
|
5
|
+
cls?: string | undefined;
|
|
5
6
|
title?: string | undefined;
|
|
6
7
|
open?: boolean | undefined;
|
|
7
8
|
headingTag?: "h2" | "h3" | undefined;
|
|
@@ -19,6 +20,7 @@ export type DetailsSlots = typeof __propDef.slots;
|
|
|
19
20
|
import { SvelteComponentTyped } from "svelte";
|
|
20
21
|
declare const __propDef: {
|
|
21
22
|
props: {
|
|
23
|
+
cls?: string | undefined;
|
|
22
24
|
title?: string | undefined;
|
|
23
25
|
open?: boolean | undefined;
|
|
24
26
|
headingTag?: "h2" | "h3" | undefined;
|