@onsvisual/svelte-components 0.0.8 → 0.0.9
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/@types/inputs/Checkbox/Checkbox.svelte.d.ts +41 -0
- package/dist/@types/inputs/Checkboxes/Checkboxes.svelte.d.ts +37 -0
- package/dist/@types/inputs/ErrorPanel/ErrorPanel.svelte.d.ts +27 -0
- package/dist/@types/inputs/ErrorSummary/ErrorSummary.svelte.d.ts +2 -0
- package/dist/@types/inputs/Radios/Radio.svelte.d.ts +37 -0
- package/dist/@types/inputs/Radios/Radios.svelte.d.ts +39 -0
- package/dist/inputs/Checkbox/Checkbox.svelte +133 -0
- package/dist/inputs/Checkboxes/Checkboxes.svelte +33 -0
- package/dist/inputs/ErrorPanel/ErrorPanel.svelte +35 -0
- package/dist/inputs/ErrorSummary/ErrorSummary.svelte +19 -0
- package/dist/inputs/Radios/Radio.svelte +108 -0
- package/dist/inputs/Radios/Radios.svelte +46 -0
- package/package.json +6 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} CheckboxProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} CheckboxEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} CheckboxSlots */
|
|
4
|
+
export default class Checkbox extends SvelteComponentTyped<{
|
|
5
|
+
label: string;
|
|
6
|
+
id: string;
|
|
7
|
+
compact?: boolean;
|
|
8
|
+
variant?: "default" | "ghost";
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
description?: string;
|
|
11
|
+
group?: boolean;
|
|
12
|
+
checked?: boolean;
|
|
13
|
+
}, {
|
|
14
|
+
change: CustomEvent<any>;
|
|
15
|
+
} & {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}> {
|
|
18
|
+
}
|
|
19
|
+
export type CheckboxProps = typeof __propDef.props;
|
|
20
|
+
export type CheckboxEvents = typeof __propDef.events;
|
|
21
|
+
export type CheckboxSlots = typeof __propDef.slots;
|
|
22
|
+
import { SvelteComponentTyped } from "svelte";
|
|
23
|
+
declare const __propDef: {
|
|
24
|
+
props: {
|
|
25
|
+
label: string;
|
|
26
|
+
id: string;
|
|
27
|
+
compact?: boolean;
|
|
28
|
+
variant?: "default" | "ghost";
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
description?: string;
|
|
31
|
+
group?: boolean;
|
|
32
|
+
checked?: boolean;
|
|
33
|
+
};
|
|
34
|
+
events: {
|
|
35
|
+
change: CustomEvent<any>;
|
|
36
|
+
} & {
|
|
37
|
+
[evt: string]: CustomEvent<any>;
|
|
38
|
+
};
|
|
39
|
+
slots: {};
|
|
40
|
+
};
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} CheckboxesProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} CheckboxesEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} CheckboxesSlots */
|
|
4
|
+
export default class Checkboxes extends SvelteComponentTyped<{
|
|
5
|
+
label?: string;
|
|
6
|
+
compact?: boolean;
|
|
7
|
+
value?: any[];
|
|
8
|
+
items?: any[];
|
|
9
|
+
}, {
|
|
10
|
+
change: CustomEvent<any>;
|
|
11
|
+
} & {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {
|
|
14
|
+
default: {};
|
|
15
|
+
}> {
|
|
16
|
+
}
|
|
17
|
+
export type CheckboxesProps = typeof __propDef.props;
|
|
18
|
+
export type CheckboxesEvents = typeof __propDef.events;
|
|
19
|
+
export type CheckboxesSlots = typeof __propDef.slots;
|
|
20
|
+
import { SvelteComponentTyped } from "svelte";
|
|
21
|
+
declare const __propDef: {
|
|
22
|
+
props: {
|
|
23
|
+
label?: string;
|
|
24
|
+
compact?: boolean;
|
|
25
|
+
value?: any[];
|
|
26
|
+
items?: any[];
|
|
27
|
+
};
|
|
28
|
+
events: {
|
|
29
|
+
change: CustomEvent<any>;
|
|
30
|
+
} & {
|
|
31
|
+
[evt: string]: CustomEvent<any>;
|
|
32
|
+
};
|
|
33
|
+
slots: {
|
|
34
|
+
default: {};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} ErrorPanelProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} ErrorPanelEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} ErrorPanelSlots */
|
|
4
|
+
export default class ErrorPanel extends SvelteComponentTyped<{
|
|
5
|
+
message?: string;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {
|
|
9
|
+
default: {};
|
|
10
|
+
}> {
|
|
11
|
+
}
|
|
12
|
+
export type ErrorPanelProps = typeof __propDef.props;
|
|
13
|
+
export type ErrorPanelEvents = typeof __propDef.events;
|
|
14
|
+
export type ErrorPanelSlots = typeof __propDef.slots;
|
|
15
|
+
import { SvelteComponentTyped } from "svelte";
|
|
16
|
+
declare const __propDef: {
|
|
17
|
+
props: {
|
|
18
|
+
message?: string;
|
|
19
|
+
};
|
|
20
|
+
events: {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
};
|
|
23
|
+
slots: {
|
|
24
|
+
default: {};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/** @typedef {typeof __propDef.slots} ErrorSummarySlots */
|
|
4
4
|
export default class ErrorSummary extends SvelteComponentTyped<{
|
|
5
5
|
title?: string;
|
|
6
|
+
items?: any[];
|
|
6
7
|
}, {
|
|
7
8
|
[evt: string]: CustomEvent<any>;
|
|
8
9
|
}, {
|
|
@@ -16,6 +17,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
16
17
|
declare const __propDef: {
|
|
17
18
|
props: {
|
|
18
19
|
title?: string;
|
|
20
|
+
items?: any[];
|
|
19
21
|
};
|
|
20
22
|
events: {
|
|
21
23
|
[evt: string]: CustomEvent<any>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} RadioProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} RadioEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} RadioSlots */
|
|
4
|
+
export default class Radio extends SvelteComponentTyped<{
|
|
5
|
+
label: string;
|
|
6
|
+
id: string;
|
|
7
|
+
groupId: string;
|
|
8
|
+
compact?: boolean;
|
|
9
|
+
value?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
}, {
|
|
12
|
+
change: CustomEvent<any>;
|
|
13
|
+
} & {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
}, {}> {
|
|
16
|
+
}
|
|
17
|
+
export type RadioProps = typeof __propDef.props;
|
|
18
|
+
export type RadioEvents = typeof __propDef.events;
|
|
19
|
+
export type RadioSlots = typeof __propDef.slots;
|
|
20
|
+
import { SvelteComponentTyped } from "svelte";
|
|
21
|
+
declare const __propDef: {
|
|
22
|
+
props: {
|
|
23
|
+
label: string;
|
|
24
|
+
id: string;
|
|
25
|
+
groupId: string;
|
|
26
|
+
compact?: boolean;
|
|
27
|
+
value?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
};
|
|
30
|
+
events: {
|
|
31
|
+
change: CustomEvent<any>;
|
|
32
|
+
} & {
|
|
33
|
+
[evt: string]: CustomEvent<any>;
|
|
34
|
+
};
|
|
35
|
+
slots: {};
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} RadiosProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} RadiosEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} RadiosSlots */
|
|
4
|
+
export default class Radios extends SvelteComponentTyped<{
|
|
5
|
+
label?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
compact?: boolean;
|
|
8
|
+
value?: string;
|
|
9
|
+
items?: any[];
|
|
10
|
+
}, {
|
|
11
|
+
change: CustomEvent<any>;
|
|
12
|
+
} & {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
}, {
|
|
15
|
+
default: {};
|
|
16
|
+
}> {
|
|
17
|
+
}
|
|
18
|
+
export type RadiosProps = typeof __propDef.props;
|
|
19
|
+
export type RadiosEvents = typeof __propDef.events;
|
|
20
|
+
export type RadiosSlots = typeof __propDef.slots;
|
|
21
|
+
import { SvelteComponentTyped } from "svelte";
|
|
22
|
+
declare const __propDef: {
|
|
23
|
+
props: {
|
|
24
|
+
label?: string;
|
|
25
|
+
id?: string;
|
|
26
|
+
compact?: boolean;
|
|
27
|
+
value?: string;
|
|
28
|
+
items?: any[];
|
|
29
|
+
};
|
|
30
|
+
events: {
|
|
31
|
+
change: CustomEvent<any>;
|
|
32
|
+
} & {
|
|
33
|
+
[evt: string]: CustomEvent<any>;
|
|
34
|
+
};
|
|
35
|
+
slots: {
|
|
36
|
+
default: {};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ID for input element
|
|
8
|
+
* @type {string}
|
|
9
|
+
*/
|
|
10
|
+
export let id;
|
|
11
|
+
/**
|
|
12
|
+
* Label for input
|
|
13
|
+
* @type {string}
|
|
14
|
+
*/
|
|
15
|
+
export let label;
|
|
16
|
+
/**
|
|
17
|
+
* Binding for checked state of input
|
|
18
|
+
* @type {boolean}
|
|
19
|
+
*/
|
|
20
|
+
export let checked = false;
|
|
21
|
+
/**
|
|
22
|
+
* Binding for checked state of input
|
|
23
|
+
* @type {boolean}
|
|
24
|
+
*/
|
|
25
|
+
export let group = null;
|
|
26
|
+
/**
|
|
27
|
+
* (Optional) Extended description for element
|
|
28
|
+
* @type {string}
|
|
29
|
+
*/
|
|
30
|
+
export let description = null;
|
|
31
|
+
/**
|
|
32
|
+
* Set display mode of checkbox
|
|
33
|
+
* @type {"default"|"ghost"}
|
|
34
|
+
*/
|
|
35
|
+
export let variant = "default";
|
|
36
|
+
/**
|
|
37
|
+
* Option to disable input
|
|
38
|
+
* @type {boolean}
|
|
39
|
+
*/
|
|
40
|
+
export let disabled = false;
|
|
41
|
+
/**
|
|
42
|
+
* Compact mode (no border)
|
|
43
|
+
* @type {boolean}
|
|
44
|
+
*/
|
|
45
|
+
export let compact = false;
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<span
|
|
49
|
+
class="ons-checkboxes__item"
|
|
50
|
+
class:ons-checkboxes__item--ghost="{variant === 'ghost'}"
|
|
51
|
+
class:ons-checkboxes__item--no-border="{compact}"
|
|
52
|
+
>
|
|
53
|
+
<span class="ons-checkbox" class:ons-checkbox--no-border="{compact}">
|
|
54
|
+
{#if Array.isArray(group)}
|
|
55
|
+
<input
|
|
56
|
+
type="checkbox"
|
|
57
|
+
id="{id}"
|
|
58
|
+
value="{id}"
|
|
59
|
+
bind:group="{group}"
|
|
60
|
+
class="ons-checkbox__input ons-js-checkbox"
|
|
61
|
+
disabled="{disabled}"
|
|
62
|
+
aria-disabled="{disabled}"
|
|
63
|
+
on:change="{(e) => dispatch('change', e)}"
|
|
64
|
+
/>
|
|
65
|
+
{:else}
|
|
66
|
+
<input
|
|
67
|
+
type="checkbox"
|
|
68
|
+
id="{id}"
|
|
69
|
+
value="{id}"
|
|
70
|
+
bind:checked="{checked}"
|
|
71
|
+
class="ons-checkbox__input ons-js-checkbox"
|
|
72
|
+
disabled="{disabled}"
|
|
73
|
+
aria-disabled="{disabled}"
|
|
74
|
+
on:change="{(e) => dispatch('change', e)}"
|
|
75
|
+
/>
|
|
76
|
+
{/if}
|
|
77
|
+
<label
|
|
78
|
+
class="ons-checkbox__label"
|
|
79
|
+
class:ons-label--with-description="{description}"
|
|
80
|
+
for="{id}"
|
|
81
|
+
id="{id}-label"
|
|
82
|
+
aria-describedby="{description ? `${id}-label-description-hint` : null}"
|
|
83
|
+
>
|
|
84
|
+
{label}
|
|
85
|
+
{#if description}
|
|
86
|
+
<span class="ons-label__aria-hidden-description" aria-hidden="true"
|
|
87
|
+
><span class="ons-label__description ons-radio__label--with-description">
|
|
88
|
+
{description}
|
|
89
|
+
</span></span
|
|
90
|
+
>
|
|
91
|
+
{/if}
|
|
92
|
+
</label>
|
|
93
|
+
{#if description}
|
|
94
|
+
<span
|
|
95
|
+
class="ons-label__visually-hidden-description ons-u-vh"
|
|
96
|
+
id="{id}-label-description-hint"
|
|
97
|
+
>
|
|
98
|
+
{description}
|
|
99
|
+
</span>
|
|
100
|
+
{/if}
|
|
101
|
+
</span>
|
|
102
|
+
</span>
|
|
103
|
+
|
|
104
|
+
<style>
|
|
105
|
+
.ons-checkboxes__item {
|
|
106
|
+
display: table;
|
|
107
|
+
}
|
|
108
|
+
.ons-checkbox__input:disabled {
|
|
109
|
+
border: 2px solid var(--ons-color-border-disabled);
|
|
110
|
+
}
|
|
111
|
+
.ons-checkboxes__item label::before {
|
|
112
|
+
background: none;
|
|
113
|
+
border-color: currentColor;
|
|
114
|
+
box-shadow: 0 0 0 1px currentColor;
|
|
115
|
+
}
|
|
116
|
+
.ons-checkboxes__item--ghost label::before {
|
|
117
|
+
opacity: 60%;
|
|
118
|
+
}
|
|
119
|
+
.ons-checkboxes__item .ons-checkbox__input:focus + .ons-checkbox__label::before {
|
|
120
|
+
box-shadow: 0 0 0 1px currentColor, 0 0 0 4px #fbc900;
|
|
121
|
+
opacity: 100%;
|
|
122
|
+
}
|
|
123
|
+
.ons-checkboxes__item input {
|
|
124
|
+
background: none;
|
|
125
|
+
border-color: currentColor;
|
|
126
|
+
}
|
|
127
|
+
.ons-checkboxes__item input::after {
|
|
128
|
+
border-color: currentColor;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.ons-checkboxes__item--no-border .ons-checkbox__input:focus {
|
|
132
|
+
box-shadow: 0 0 0 1px currentColor, 0 0 0 4px #fbc900;
|
|
133
|
+
}</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Checkbox from "../Checkbox/Checkbox.svelte";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Label for grouped inputs
|
|
6
|
+
* @type {string}
|
|
7
|
+
*/
|
|
8
|
+
export let label = "";
|
|
9
|
+
/** (Optional) Define the checkboxes as an array of {id, label, checked, description?}
|
|
10
|
+
* @type {array}
|
|
11
|
+
*/
|
|
12
|
+
export let items = null;
|
|
13
|
+
/** Compact mode (no borders)
|
|
14
|
+
* @type {boolean}
|
|
15
|
+
*/
|
|
16
|
+
export let compact = false;
|
|
17
|
+
/** Binding for selected checkboxes (if checkboxes are defined as "items")
|
|
18
|
+
* @type {array}
|
|
19
|
+
*/
|
|
20
|
+
export let value = [];
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
{#if label}
|
|
24
|
+
<p class="ons-checkboxes__label">{label}</p>
|
|
25
|
+
{/if}
|
|
26
|
+
<div class="ons-checkboxes__items">
|
|
27
|
+
<slot />
|
|
28
|
+
{#if items}
|
|
29
|
+
{#each items as item, i}
|
|
30
|
+
<Checkbox {...item} group="{value}" compact="{compact}" on:change />
|
|
31
|
+
{/each}
|
|
32
|
+
{/if}
|
|
33
|
+
</div>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/**
|
|
3
|
+
* Set an error message
|
|
4
|
+
* @type {string}
|
|
5
|
+
*/
|
|
6
|
+
export let message = "";
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<div class="ons-panel ons-panel--error ons-panel--no-title" id="number-of-employees-error">
|
|
10
|
+
<span class="ons-panel__assistive-text ons-u-vh">Error: </span>
|
|
11
|
+
<div class="ons-panel__body">
|
|
12
|
+
{#if message}
|
|
13
|
+
<p class="ons-panel__error">
|
|
14
|
+
<strong>{message}</strong>
|
|
15
|
+
</p>
|
|
16
|
+
{/if}
|
|
17
|
+
<slot />
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<style>
|
|
22
|
+
.ons-panel {
|
|
23
|
+
color: rgb(34, 34, 34);
|
|
24
|
+
}
|
|
25
|
+
:global(.ons-panel__body a) {
|
|
26
|
+
color: #206095 !important;
|
|
27
|
+
}
|
|
28
|
+
:global(.ons-panel__body a:hover) {
|
|
29
|
+
color: rgb(0, 60, 87) !important;
|
|
30
|
+
-webkit-text-decoration: underline solid rgb(0, 60, 87) 2px !important;
|
|
31
|
+
text-decoration: underline solid rgb(0, 60, 87) 2px !important;
|
|
32
|
+
}
|
|
33
|
+
:global(.ons-panel__body .ons-input) {
|
|
34
|
+
background: white !important;
|
|
35
|
+
}</style>
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import List from "../../layout/List/List.svelte";
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* Defines the title of the error
|
|
4
6
|
* @type {string}
|
|
5
7
|
*/
|
|
6
8
|
export let title = "";
|
|
9
|
+
/**
|
|
10
|
+
* Define an array of errors/issues in the format {label, href?}
|
|
11
|
+
*/
|
|
12
|
+
export let items = [];
|
|
7
13
|
</script>
|
|
8
14
|
|
|
9
15
|
<div aria-labelledby="alert" role="alert" tabindex="-1" class="ons-panel ons-panel--error">
|
|
@@ -11,6 +17,19 @@
|
|
|
11
17
|
<h2 id="alert" data-qa="error-header" class="ons-panel__title ons-u-fs-r--b">{title}</h2>
|
|
12
18
|
</div>
|
|
13
19
|
<div class="ons-panel__body">
|
|
20
|
+
{#if Array.isArray(items)}
|
|
21
|
+
<List mode="number">
|
|
22
|
+
{#each items as item}
|
|
23
|
+
<li>
|
|
24
|
+
{#if item.href}
|
|
25
|
+
<a href="{item.href}">{item.label}</a>
|
|
26
|
+
{:else}
|
|
27
|
+
{item.label}
|
|
28
|
+
{/if}
|
|
29
|
+
</li>
|
|
30
|
+
{/each}
|
|
31
|
+
</List>
|
|
32
|
+
{/if}
|
|
14
33
|
<slot />
|
|
15
34
|
</div>
|
|
16
35
|
</div>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Unique ID input
|
|
8
|
+
* @type {string}
|
|
9
|
+
*/
|
|
10
|
+
export let id;
|
|
11
|
+
/**
|
|
12
|
+
* ID for radio group (required)
|
|
13
|
+
* @type {string}
|
|
14
|
+
*/
|
|
15
|
+
export let groupId;
|
|
16
|
+
/**
|
|
17
|
+
* Label for input
|
|
18
|
+
* @type {string}
|
|
19
|
+
*/
|
|
20
|
+
export let label;
|
|
21
|
+
/**
|
|
22
|
+
* Binding for ID of selected option
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
25
|
+
export let value = null;
|
|
26
|
+
/**
|
|
27
|
+
* (Optional) Extended description for element
|
|
28
|
+
* @type {string}
|
|
29
|
+
*/
|
|
30
|
+
export let description = null;
|
|
31
|
+
/**
|
|
32
|
+
* Compact mode (no border)
|
|
33
|
+
* @type {boolean}
|
|
34
|
+
*/
|
|
35
|
+
export let compact = false;
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<span class="ons-radios__item" class:ons-radios__item--no-border="{compact}">
|
|
39
|
+
<span class="ons-radio" class:ons-radio--no-border="{compact}">
|
|
40
|
+
<input
|
|
41
|
+
type="radio"
|
|
42
|
+
id="{id}"
|
|
43
|
+
bind:group="{value}"
|
|
44
|
+
value="{id}"
|
|
45
|
+
name="{groupId}"
|
|
46
|
+
class="ons-radio__input ons-js-radio"
|
|
47
|
+
on:change="{(e) => dispatch('change', e)}"
|
|
48
|
+
/>
|
|
49
|
+
<label
|
|
50
|
+
class="ons-radio__label"
|
|
51
|
+
class:ons-label--with-description="{description}"
|
|
52
|
+
for="{id}"
|
|
53
|
+
id="{id}-label"
|
|
54
|
+
aria-describedby="{description ? `${id}-label-description-hint` : null}"
|
|
55
|
+
>
|
|
56
|
+
{label}
|
|
57
|
+
{#if description}
|
|
58
|
+
<span class="ons-label__aria-hidden-description" aria-hidden="true"
|
|
59
|
+
><span class="ons-label__description ons-radio__label--with-description">
|
|
60
|
+
{description}
|
|
61
|
+
</span></span
|
|
62
|
+
>
|
|
63
|
+
{/if}
|
|
64
|
+
</label>
|
|
65
|
+
{#if description}
|
|
66
|
+
<span
|
|
67
|
+
class="ons-label__visually-hidden-description ons-u-vh"
|
|
68
|
+
id="{id}-label-description-hint"
|
|
69
|
+
>
|
|
70
|
+
{description}
|
|
71
|
+
</span>
|
|
72
|
+
{/if}
|
|
73
|
+
</span>
|
|
74
|
+
</span>
|
|
75
|
+
|
|
76
|
+
<style>
|
|
77
|
+
.ons-radios__item {
|
|
78
|
+
display: table;
|
|
79
|
+
}
|
|
80
|
+
.ons-radio__input {
|
|
81
|
+
border-color: currentColor !important;
|
|
82
|
+
background: none !important;
|
|
83
|
+
box-shadow: none !important;
|
|
84
|
+
}
|
|
85
|
+
.ons-radio--no-border .ons-radio__input:focus {
|
|
86
|
+
box-shadow: 0 0 0 1px currentColor, 0 0 0 4px #fbc900 !important;
|
|
87
|
+
}
|
|
88
|
+
.ons-radio__input:checked::after {
|
|
89
|
+
border-color: currentColor;
|
|
90
|
+
}
|
|
91
|
+
.ons-radio__input::after {
|
|
92
|
+
left: 50% !important;
|
|
93
|
+
top: 50% !important;
|
|
94
|
+
margin-left: -6px !important;
|
|
95
|
+
margin-top: -6px !important;
|
|
96
|
+
/* background-color: currentColor !important;
|
|
97
|
+
border-color: currentColor !important; */
|
|
98
|
+
}
|
|
99
|
+
.ons-radio__label::before {
|
|
100
|
+
background: none;
|
|
101
|
+
border-color: currentColor;
|
|
102
|
+
}
|
|
103
|
+
.ons-radio__input:checked + .ons-radio__label::before {
|
|
104
|
+
background: var(--pale, #f5f5f6);
|
|
105
|
+
}
|
|
106
|
+
.ons-radio__input:focus + .ons-radio__label::before {
|
|
107
|
+
box-shadow: 0 0 0 1px currentColor, 0 0 0 4px #fbc900;
|
|
108
|
+
}</style>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Radio from "./Radio.svelte";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unique ID for radio group (required)
|
|
6
|
+
* @type {string}
|
|
7
|
+
*/
|
|
8
|
+
export let id = "name";
|
|
9
|
+
/**
|
|
10
|
+
* Label for grouped inputs
|
|
11
|
+
* @type {string}
|
|
12
|
+
*/
|
|
13
|
+
export let label = "";
|
|
14
|
+
/**
|
|
15
|
+
* Binding for ID of selected option
|
|
16
|
+
* @type {string}
|
|
17
|
+
*/
|
|
18
|
+
export let value = null;
|
|
19
|
+
/** (Optional) Define the radios as an array of {id, label, description?}
|
|
20
|
+
* @type {array}
|
|
21
|
+
*/
|
|
22
|
+
export let items = [];
|
|
23
|
+
/**
|
|
24
|
+
* Compact mode (no border)
|
|
25
|
+
* @type {boolean}
|
|
26
|
+
*/
|
|
27
|
+
export let compact = false;
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
{#if label}
|
|
31
|
+
<p class="ons-radios__label">{label}</p>
|
|
32
|
+
{/if}
|
|
33
|
+
<div class="ons-radios__items">
|
|
34
|
+
<slot />
|
|
35
|
+
{#each items as item, i}
|
|
36
|
+
<Radio
|
|
37
|
+
id="{item.id}"
|
|
38
|
+
label="{item.label}"
|
|
39
|
+
description="{item.description}"
|
|
40
|
+
groupId="{id}"
|
|
41
|
+
compact="{compact}"
|
|
42
|
+
bind:value="{value}"
|
|
43
|
+
on:change
|
|
44
|
+
/>
|
|
45
|
+
{/each}
|
|
46
|
+
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onsvisual/svelte-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://onsvisual.github.io/svelte-components",
|
|
@@ -125,9 +125,14 @@
|
|
|
125
125
|
"./globals.d.ts": "./dist/globals.d.ts",
|
|
126
126
|
"./inputs/Button/Button.svelte": "./dist/inputs/Button/Button.svelte",
|
|
127
127
|
"./inputs/Button/Icon.svelte": "./dist/inputs/Button/Icon.svelte",
|
|
128
|
+
"./inputs/Checkbox/Checkbox.svelte": "./dist/inputs/Checkbox/Checkbox.svelte",
|
|
129
|
+
"./inputs/Checkboxes/Checkboxes.svelte": "./dist/inputs/Checkboxes/Checkboxes.svelte",
|
|
128
130
|
"./inputs/Dropdown/Dropdown.svelte": "./dist/inputs/Dropdown/Dropdown.svelte",
|
|
131
|
+
"./inputs/ErrorPanel/ErrorPanel.svelte": "./dist/inputs/ErrorPanel/ErrorPanel.svelte",
|
|
129
132
|
"./inputs/ErrorSummary/ErrorSummary.svelte": "./dist/inputs/ErrorSummary/ErrorSummary.svelte",
|
|
130
133
|
"./inputs/Input/Input.svelte": "./dist/inputs/Input/Input.svelte",
|
|
134
|
+
"./inputs/Radios/Radio.svelte": "./dist/inputs/Radios/Radio.svelte",
|
|
135
|
+
"./inputs/Radios/Radios.svelte": "./dist/inputs/Radios/Radios.svelte",
|
|
131
136
|
"./inputs/Select/Select.svelte": "./dist/inputs/Select/Select.svelte",
|
|
132
137
|
"./inputs/Textarea/Textarea.svelte": "./dist/inputs/Textarea/Textarea.svelte",
|
|
133
138
|
"./js/docsPage": "./dist/js/docsPage.js",
|