@functionalcms/svelte-components 3.5.20 → 4.0.0-pre
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/css/functional.css +1 -1
- package/css/functional.css.map +1 -1
- package/dist/auth/authenticationHandle.js +0 -4
- package/dist/auth/redisSessionProvider.js +1 -2
- package/dist/auth/sessionIdGenerator.d.ts +1 -1
- package/dist/components/form/Button.svelte +379 -0
- package/dist/components/form/Button.svelte.d.ts +27 -0
- package/dist/components/form/Input.d.ts +21 -0
- package/dist/components/form/Input.js +23 -0
- package/dist/components/form/Input.svelte +142 -177
- package/dist/components/form/Input.svelte.d.ts +24 -46
- package/dist/components/{Banner.svelte → layouts/Banner.svelte} +5 -5
- package/dist/components/layouts/DefaultLayout.svelte +5 -5
- package/dist/components/layouts/DefaultLayout.svelte.d.ts +4 -4
- package/dist/components/layouts/SimpleFooter.svelte +4 -4
- package/dist/components/layouts/SimpleFooter.svelte.d.ts +3 -3
- package/dist/components/layouts/Well.svelte +46 -0
- package/dist/components/layouts/Well.svelte.d.ts +12 -0
- package/dist/components/menu/CollapsibleMenu.svelte +2 -2
- package/dist/components/menu/CollapsibleMenu.svelte.d.ts +3 -16
- package/dist/components/menu/DynamicMenu.svelte +25 -13
- package/dist/components/menu/DynamicMenu.svelte.d.ts +10 -28
- package/dist/components/menu/HamburgerMenu.svelte +29 -21
- package/dist/components/menu/HamburgerMenu.svelte.d.ts +11 -24
- package/dist/components/menu/ListMenu.svelte +53 -0
- package/dist/components/menu/ListMenu.svelte.d.ts +17 -0
- package/dist/components/menu/{Menu.d.ts → types.d.ts} +2 -0
- package/dist/components/menu/{Menu.js → types.js} +5 -0
- package/dist/components/presentation/Card.svelte +77 -92
- package/dist/components/presentation/Card.svelte.d.ts +10 -13
- package/dist/components/presentation/{Carusele.d.ts → Carousel.d.ts} +1 -1
- package/dist/components/presentation/Carousel.svelte +98 -1
- package/dist/components/presentation/Carousel.svelte.d.ts +14 -15
- package/dist/components/presentation/Drawer.svelte +131 -0
- package/dist/components/presentation/Drawer.svelte.d.ts +13 -0
- package/dist/components/presentation/Gallery.svelte +7 -7
- package/dist/components/presentation/Gallery.svelte.d.ts +3 -3
- package/dist/components/presentation/ImageCompare.svelte +39 -46
- package/dist/components/presentation/ImageCompare.svelte.d.ts +8 -26
- package/dist/components/presentation/Link.svelte +362 -0
- package/dist/components/presentation/Link.svelte.d.ts +27 -0
- package/dist/components/presentation/Logo.svelte +36 -0
- package/dist/components/presentation/Logo.svelte.d.ts +8 -0
- package/dist/components/presentation/ShowItem.d.ts +7 -7
- package/dist/components/presentation/ShowItem.js +1 -8
- package/dist/index-server.d.ts +0 -1
- package/dist/index-server.js +0 -3
- package/dist/index.d.ts +16 -22
- package/dist/index.js +39 -57
- package/dist/server-side/getServices.d.ts +1 -1
- package/dist/server-side/types.d.ts +1 -2
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +54 -0
- package/package.json +27 -24
- package/dist/components/CssHelper.d.ts +0 -1
- package/dist/components/CssHelper.js +0 -3
- package/dist/components/Link.svelte +0 -349
- package/dist/components/Link.svelte.d.ts +0 -48
- package/dist/components/Logo.svelte +0 -38
- package/dist/components/Logo.svelte.d.ts +0 -28
- package/dist/components/Spacer.svelte +0 -22
- package/dist/components/Spacer.svelte.d.ts +0 -6
- package/dist/components/Well.svelte +0 -40
- package/dist/components/Well.svelte.d.ts +0 -12
- package/dist/components/agnostic/Button/Button.svelte +0 -371
- package/dist/components/agnostic/Button/Button.svelte.d.ts +0 -52
- package/dist/components/agnostic/Button/ButtonGroup.svelte +0 -21
- package/dist/components/agnostic/Button/ButtonGroup.svelte.d.ts +0 -32
- package/dist/components/agnostic/Button/button-base.css +0 -12
- package/dist/components/agnostic/Button/button-core.css +0 -237
- package/dist/components/agnostic/Button/button-empty.css +0 -31
- package/dist/components/agnostic/Button/button-group.css +0 -8
- package/dist/components/agnostic/Close/Close.svelte +0 -124
- package/dist/components/agnostic/Close/Close.svelte.d.ts +0 -25
- package/dist/components/agnostic/Close/api.d.ts +0 -1
- package/dist/components/agnostic/Disclose/Disclose.svelte +0 -116
- package/dist/components/agnostic/Disclose/Disclose.svelte.d.ts +0 -11
- package/dist/components/agnostic/Divider/Divider.svelte +0 -141
- package/dist/components/agnostic/Divider/Divider.svelte.d.ts +0 -24
- package/dist/components/agnostic/Divider/api.d.ts +0 -3
- package/dist/components/agnostic/Divider/api.js +0 -1
- package/dist/components/agnostic/Loader/Loader.svelte +0 -116
- package/dist/components/agnostic/Loader/Loader.svelte.d.ts +0 -22
- package/dist/components/agnostic/animation.css +0 -37
- package/dist/components/blog/BlogDescription.svelte +0 -9
- package/dist/components/blog/BlogDescription.svelte.d.ts +0 -23
- package/dist/components/blog/BlogPost.d.ts +0 -13
- package/dist/components/blog/BlogPost.js +0 -1
- package/dist/components/blog/BlogTitle.svelte +0 -19
- package/dist/components/blog/BlogTitle.svelte.d.ts +0 -23
- package/dist/components/blog/blog.d.ts +0 -8
- package/dist/components/blog/blog.js +0 -29
- package/dist/components/converters/ShowItemToNavigationItems.d.ts +0 -3
- package/dist/components/converters/ShowItemToNavigationItems.js +0 -10
- package/dist/components/form/DateTimePicker.svelte +0 -59
- package/dist/components/form/DateTimePicker.svelte.d.ts +0 -18
- package/dist/components/form/InputAddonItem.svelte +0 -42
- package/dist/components/form/InputAddonItem.svelte.d.ts +0 -31
- package/dist/components/form/InputTypes.d.ts +0 -9
- package/dist/components/form/InputTypes.js +0 -10
- package/dist/components/form/Select.svelte +0 -157
- package/dist/components/form/Select.svelte.d.ts +0 -34
- package/dist/components/form/Switch.svelte +0 -275
- package/dist/components/form/Switch.svelte.d.ts +0 -30
- package/dist/components/menu/Menu.svelte +0 -526
- package/dist/components/menu/Menu.svelte.d.ts +0 -33
- package/dist/components/menu/MenuItem.svelte +0 -121
- package/dist/components/menu/MenuItem.svelte.d.ts +0 -39
- package/dist/components/menu/NavigationItems.svelte +0 -44
- package/dist/components/menu/NavigationItems.svelte.d.ts +0 -32
- package/dist/components/menu/authentication.d.ts +0 -1
- package/dist/components/menu/authentication.js +0 -6
- package/dist/components/presentation/Carousel/carousel-content.svelte +0 -35
- package/dist/components/presentation/Carousel/carousel-content.svelte.d.ts +0 -28
- package/dist/components/presentation/Carousel/carousel-item.svelte +0 -25
- package/dist/components/presentation/Carousel/carousel-item.svelte.d.ts +0 -28
- package/dist/components/presentation/Carousel/carousel-next.svelte +0 -39
- package/dist/components/presentation/Carousel/carousel-next.svelte.d.ts +0 -18
- package/dist/components/presentation/Carousel/carousel-previous.svelte +0 -40
- package/dist/components/presentation/Carousel/carousel-previous.svelte.d.ts +0 -18
- package/dist/components/presentation/Carousel/carousel.svelte +0 -99
- package/dist/components/presentation/Carousel/carousel.svelte.d.ts +0 -31
- package/dist/components/presentation/Carousel/context.d.ts +0 -32
- package/dist/components/presentation/Carousel/context.js +0 -12
- package/dist/components/presentation/Carusele.js +0 -5
- /package/dist/components/{Markdown.svelte → content/Markdown.svelte} +0 -0
- /package/dist/components/{Markdown.svelte.d.ts → content/Markdown.svelte.d.ts} +0 -0
- /package/dist/components/{Banner.svelte.d.ts → layouts/Banner.svelte.d.ts} +0 -0
- /package/dist/components/{agnostic/Close/api.js → presentation/Carousel.js} +0 -0
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
<style>
|
|
2
|
-
.select,
|
|
3
|
-
.select-base {
|
|
4
|
-
display: block;
|
|
5
|
-
width: 100%;
|
|
6
|
-
/* stylelint-disable-next-line property-no-vendor-prefix */
|
|
7
|
-
-webkit-appearance: none;
|
|
8
|
-
/* stylelint-disable-next-line property-no-vendor-prefix */
|
|
9
|
-
-moz-appearance: none;
|
|
10
|
-
appearance: none;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.select,
|
|
14
|
-
.select-skin {
|
|
15
|
-
padding: var(--fluid-6) var(--fluid-32) var(--fluid-6) var(--fluid-12);
|
|
16
|
-
-moz-padding-start: calc(var(--fluid-12) - 3px);
|
|
17
|
-
font-size: var(--fluid-16);
|
|
18
|
-
font-weight: 400;
|
|
19
|
-
line-height: 1.5;
|
|
20
|
-
color: var(--functional-dark);
|
|
21
|
-
border: 1px solid var(--functional-select-border-color, var(--functional-gray-light));
|
|
22
|
-
border-radius: var(--functional-radius);
|
|
23
|
-
transition:
|
|
24
|
-
border-color var(--functional-timing-fast) ease-in-out,
|
|
25
|
-
box-shadow var(--functional-timing-fast) ease-in-out;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* Only shows the down arrow SVG if in single mode */
|
|
29
|
-
.select:not([multiple]) {
|
|
30
|
-
background-color: inherit;
|
|
31
|
-
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23333330' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
|
|
32
|
-
background-repeat: no-repeat;
|
|
33
|
-
background-position: right var(--fluid-12) center;
|
|
34
|
-
background-size: var(--fluid-16) var(--fluid-12);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.select:focus {
|
|
38
|
-
border-color: var(--functional-focus-ring-color);
|
|
39
|
-
box-shadow: 0 0 0 var(--functional-focus-ring-outline-width) var(--functional-focus-ring-color);
|
|
40
|
-
|
|
41
|
-
/* Needed for High Contrast mode */
|
|
42
|
-
outline:
|
|
43
|
-
var(--functional-focus-ring-outline-width) var(--functional-focus-ring-outline-style)
|
|
44
|
-
var(--functional-focus-ring-outline-color);
|
|
45
|
-
transition: box-shadow var(--functional-timing-fast) ease-out;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.select-base,
|
|
49
|
-
.select:disabled {
|
|
50
|
-
background-color: var(--functional-disabled-bg);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.select-base,
|
|
54
|
-
.select:-moz-focusring {
|
|
55
|
-
color: transparent;
|
|
56
|
-
text-shadow: 0 0 0 var(--functional-dark);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@media (prefers-reduced-motion), (update: slow) {
|
|
60
|
-
.select,
|
|
61
|
-
.select-base,
|
|
62
|
-
.select:focus {
|
|
63
|
-
transition: none;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.select-small {
|
|
68
|
-
padding-top: var(--fluid-4);
|
|
69
|
-
padding-bottom: var(--fluid-4);
|
|
70
|
-
padding-left: var(--fluid-8);
|
|
71
|
-
font-size: var(--fluid-14);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.select-large {
|
|
75
|
-
padding-top: var(--fluid-8);
|
|
76
|
-
padding-bottom: var(--fluid-8);
|
|
77
|
-
padding-left: var(--fluid-16);
|
|
78
|
-
font-size: var(--fluid-18);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
</style>
|
|
82
|
-
|
|
83
|
-
<script lang="ts">
|
|
84
|
-
import { createEventDispatcher } from "svelte";
|
|
85
|
-
|
|
86
|
-
export let uniqueId = "";
|
|
87
|
-
export let name = "";
|
|
88
|
-
export let labelCopy = "";
|
|
89
|
-
export let options = [];
|
|
90
|
-
export let size: "small" | "large" | "" = "";
|
|
91
|
-
export let multipleSize = 1;
|
|
92
|
-
export let isMultiple = false;
|
|
93
|
-
export let defaultOptionLabel = "Please select an option";
|
|
94
|
-
export let isDisabled = false;
|
|
95
|
-
export let isSkinned = true;
|
|
96
|
-
export let css = "";
|
|
97
|
-
|
|
98
|
-
// singleSelected can be used for two-way bindings
|
|
99
|
-
export let singleSelected = "";
|
|
100
|
-
|
|
101
|
-
// If we don't make it seems Svelte gets confused:
|
|
102
|
-
// https://github.com/sveltejs/svelte/issues/5644
|
|
103
|
-
// And so we cannot share singleSelected above :(
|
|
104
|
-
export let multiSelected = [];
|
|
105
|
-
|
|
106
|
-
const dispatch = createEventDispatcher();
|
|
107
|
-
// This will emit an event object that has a event.detail prop
|
|
108
|
-
// This will contain the value of the selected option value. See
|
|
109
|
-
// https://svelte.dev/docs#createEventDispatcher
|
|
110
|
-
const changeHandler = () => {
|
|
111
|
-
dispatch("selected", isMultiple ? multiSelected : singleSelected);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
$: disable = isDisabled;
|
|
115
|
-
$: classes = [
|
|
116
|
-
isSkinned ? "select" : "select-base",
|
|
117
|
-
size ? `select-${size}` : "",
|
|
118
|
-
css ? `${css}` : "",
|
|
119
|
-
]
|
|
120
|
-
.filter((cl) => cl)
|
|
121
|
-
.join(" ");
|
|
122
|
-
|
|
123
|
-
</script>
|
|
124
|
-
|
|
125
|
-
<label class="screenreader-only" for={uniqueId}> {labelCopy} </label>
|
|
126
|
-
{#if isMultiple}
|
|
127
|
-
<select
|
|
128
|
-
id={uniqueId}
|
|
129
|
-
class={classes}
|
|
130
|
-
name={name}
|
|
131
|
-
disabled={disable}
|
|
132
|
-
multiple
|
|
133
|
-
size={multipleSize}
|
|
134
|
-
bind:value={multiSelected}
|
|
135
|
-
on:change={changeHandler}
|
|
136
|
-
>
|
|
137
|
-
{#each options as { value, label }}
|
|
138
|
-
<option value={value}>{label}</option>
|
|
139
|
-
{/each}
|
|
140
|
-
</select>
|
|
141
|
-
{:else}
|
|
142
|
-
<select
|
|
143
|
-
id={uniqueId}
|
|
144
|
-
class={classes}
|
|
145
|
-
name={name}
|
|
146
|
-
disabled={disable}
|
|
147
|
-
bind:value={singleSelected}
|
|
148
|
-
on:change={changeHandler}
|
|
149
|
-
>
|
|
150
|
-
<option value="" disabled selected>
|
|
151
|
-
{defaultOptionLabel}
|
|
152
|
-
</option>
|
|
153
|
-
{#each options as { value, label }}
|
|
154
|
-
<option value={value}>{label}</option>
|
|
155
|
-
{/each}
|
|
156
|
-
</select>
|
|
157
|
-
{/if}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const Select: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
-
uniqueId?: string;
|
|
16
|
-
name?: string;
|
|
17
|
-
labelCopy?: string;
|
|
18
|
-
options?: any[];
|
|
19
|
-
size?: "small" | "large" | "";
|
|
20
|
-
multipleSize?: number;
|
|
21
|
-
isMultiple?: boolean;
|
|
22
|
-
defaultOptionLabel?: string;
|
|
23
|
-
isDisabled?: boolean;
|
|
24
|
-
isSkinned?: boolean;
|
|
25
|
-
css?: string;
|
|
26
|
-
singleSelected?: string;
|
|
27
|
-
multiSelected?: any[];
|
|
28
|
-
}, {
|
|
29
|
-
selected: CustomEvent<any>;
|
|
30
|
-
} & {
|
|
31
|
-
[evt: string]: CustomEvent<any>;
|
|
32
|
-
}, {}, {}, string>;
|
|
33
|
-
type Select = InstanceType<typeof Select>;
|
|
34
|
-
export default Select;
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
<style>
|
|
2
|
-
/**
|
|
3
|
-
* Switch
|
|
4
|
-
*
|
|
5
|
-
* This switch is inspired by Scott Ohara's checkbox switch:
|
|
6
|
-
* https://scottaohara.github.io/a11y_styled_form_controls/src/checkbox--switch/
|
|
7
|
-
*/
|
|
8
|
-
.switch-container {
|
|
9
|
-
display: block;
|
|
10
|
-
|
|
11
|
-
/* TODO: Hopefully this doesn't become a problem but since we use absolute
|
|
12
|
-
positioning extensively, we need some way to have adjacent spaced lines */
|
|
13
|
-
min-height: 2.25rem;
|
|
14
|
-
width: 100%;
|
|
15
|
-
padding: 0.5rem;
|
|
16
|
-
position: relative;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.switch-container:hover {
|
|
20
|
-
cursor: pointer;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/* using the before/after pseudo elements of the span to create the "switch" */
|
|
24
|
-
.switch::before,
|
|
25
|
-
.switch::after {
|
|
26
|
-
border: 1px solid var(--functional-gray-mid-dark);
|
|
27
|
-
content: "";
|
|
28
|
-
position: absolute;
|
|
29
|
-
top: 50%;
|
|
30
|
-
transform: translateY(-50%);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/* styling specific to the knob of the switch */
|
|
34
|
-
.switch::after {
|
|
35
|
-
background: #fff;
|
|
36
|
-
border-radius: 100%;
|
|
37
|
-
width: 1.4rem;
|
|
38
|
-
height: 1.4rem;
|
|
39
|
-
right: 1.4rem;
|
|
40
|
-
transition: right var(--functional-timing-fast) ease-in-out;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/* styling specific to the knob "container" */
|
|
44
|
-
.switch::before {
|
|
45
|
-
background: #eee;
|
|
46
|
-
border-radius: 1.75rem;
|
|
47
|
-
width: 2.75rem;
|
|
48
|
-
height: 1.75rem;
|
|
49
|
-
right: 0.25rem;
|
|
50
|
-
transition: background var(--functional-timing-medium) ease-in-out;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* Sizes */
|
|
54
|
-
.switch-small::after {
|
|
55
|
-
width: 1.25rem;
|
|
56
|
-
height: 1.25rem;
|
|
57
|
-
right: 1.125rem;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.switch-small::before {
|
|
61
|
-
width: 2.25rem;
|
|
62
|
-
height: 1.5rem;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.switch-large::after {
|
|
66
|
-
width: 1.65rem;
|
|
67
|
-
height: 1.65rem;
|
|
68
|
-
right: 1.65rem;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.switch-large::before {
|
|
72
|
-
width: 3.25rem;
|
|
73
|
-
height: 2rem;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.switch-border::before {
|
|
77
|
-
border: 1px solid var(--functional-primary);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.switch-action.switch-border::before {
|
|
81
|
-
border: 1px solid var(--functional-action);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/* Switch label on right */
|
|
85
|
-
|
|
86
|
-
/* We have to flip the positioning when the label is on the right of switch */
|
|
87
|
-
.switch-right .switch::before {
|
|
88
|
-
right: initial;
|
|
89
|
-
left: 0.25rem;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.switch-right .switch::after {
|
|
93
|
-
right: initial;
|
|
94
|
-
left: 1.4rem;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/* Switch sizes w/label on right -- I expect SMACSS so .switch .switch-small
|
|
98
|
-
classes should both exist so the right: initial was taken care of above :) */
|
|
99
|
-
.switch-right .switch-small::after {
|
|
100
|
-
left: 1.125rem;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.switch-right .switch-large::after {
|
|
104
|
-
left: 1.65rem;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/* ---- CHECKED STATE ----- */
|
|
108
|
-
|
|
109
|
-
/* change the position of the knob to indicate it has been checked */
|
|
110
|
-
|
|
111
|
-
.switch-input:checked + .switch-small::after {
|
|
112
|
-
right: 0.425rem;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.switch-input:checked + .switch::after {
|
|
116
|
-
right: 0.5em;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.switch-right .switch-label {
|
|
120
|
-
position: absolute;
|
|
121
|
-
right: 0;
|
|
122
|
-
|
|
123
|
-
/* Flips transition target to left to preserve our smooth transitions */
|
|
124
|
-
transition: left var(--functional-timing-fast) ease-in-out;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.switch-right .switch-input:checked + .switch::after {
|
|
128
|
-
right: initial;
|
|
129
|
-
left: 0.5em;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.switch-right .switch-input:checked + .switch-small::after {
|
|
133
|
-
right: initial;
|
|
134
|
-
left: 0.425rem;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/* From: https://scottaohara.github.io/a11y_styled_form_controls/src/checkbox--switch/
|
|
138
|
-
hide the actual checkbox from view, but not from keyboards or ATs.
|
|
139
|
-
Instead of standard visually hidden styling, instead set opacity to
|
|
140
|
-
almost 0 (not zero for ChomeVox legacy bug), pointer-events none, and
|
|
141
|
-
then set to full height/width of container element so that VO focus
|
|
142
|
-
ring outlines the component, instead of a tiny box within the component
|
|
143
|
-
*/
|
|
144
|
-
.switch-input {
|
|
145
|
-
margin: 0;
|
|
146
|
-
opacity: 0.01%;
|
|
147
|
-
position: absolute;
|
|
148
|
-
left: 0;
|
|
149
|
-
top: 0;
|
|
150
|
-
width: 100%;
|
|
151
|
-
height: 100%;
|
|
152
|
-
pointer-events: none;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.switch-input:focus + .switch::before {
|
|
156
|
-
box-shadow: 0 0 0 var(--functional-focus-ring-outline-width) var(--functional-focus-ring-color);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/* update the color of the "container" to further visually indicate state */
|
|
160
|
-
.switch-input:checked + .switch:not(.switch-border)::before {
|
|
161
|
-
background: var(--functional-primary);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.switch-input:checked + .switch-action:not(.switch-border)::before {
|
|
165
|
-
background: var(--functional-action);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/* Border switch on checked the thumb gets primary or action bg respectively */
|
|
169
|
-
.switch-input:checked + .switch-border::after {
|
|
170
|
-
background: var(--functional-primary);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
.switch-input:checked + .switch-action.switch-border::after {
|
|
174
|
-
background: var(--functional-action);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/* Disabled aka :disabled is not actually supported for <label>
|
|
178
|
-
element so we use attribute selector for that:
|
|
179
|
-
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled#:~:text=The%20disabled%20attribute%20is%20supported,control%20or%20its%20descendant%20controls.
|
|
180
|
-
*/
|
|
181
|
-
.switch-input[disabled] + .switch,
|
|
182
|
-
.switch-input[disabled] + .switch-label,
|
|
183
|
-
.switch-container.disabled {
|
|
184
|
-
color: var(--functional-input-disabled-color, var(--functional-disabled-color)) !important;
|
|
185
|
-
appearance: none !important;
|
|
186
|
-
box-shadow: none !important;
|
|
187
|
-
cursor: not-allowed !important;
|
|
188
|
-
opacity: 80% !important;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
@media screen and (-ms-high-contrast: active) {
|
|
192
|
-
.switch::after {
|
|
193
|
-
background-color: windowText;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/* High contrast mode outline hacks */
|
|
197
|
-
.switch-input[disabled] + .switch-label,
|
|
198
|
-
.switch-container.disabled {
|
|
199
|
-
outline: 2px solid transparent;
|
|
200
|
-
outline-offset: -2px;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
@media (prefers-reduced-motion), (update: slow) {
|
|
205
|
-
.switch::after,
|
|
206
|
-
.switch::before {
|
|
207
|
-
transition-duration: 0.001ms !important;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
</style>
|
|
212
|
-
|
|
213
|
-
<script lang="ts">
|
|
214
|
-
export let id = "";
|
|
215
|
-
export let label = "";
|
|
216
|
-
export let css = "";
|
|
217
|
-
export let labelPosition = "left";
|
|
218
|
-
export let size = "";
|
|
219
|
-
export let isChecked = false;
|
|
220
|
-
export let isBordered = false;
|
|
221
|
-
export let isAction = false;
|
|
222
|
-
export let isDisabled = false;
|
|
223
|
-
|
|
224
|
-
$: switchContainer = [
|
|
225
|
-
"switch-container",
|
|
226
|
-
labelPosition === "right" ? "switch-right" : "",
|
|
227
|
-
css ? css : "",
|
|
228
|
-
isDisabled ? "disabled" : "",
|
|
229
|
-
].filter(c => c).join(" ");
|
|
230
|
-
|
|
231
|
-
const switchSpan = () => {
|
|
232
|
-
let klasses = [
|
|
233
|
-
"switch",
|
|
234
|
-
isBordered ? "switch-border" : "",
|
|
235
|
-
isAction ? "switch-action" : "",
|
|
236
|
-
size ? `switch-${size}` : "",
|
|
237
|
-
];
|
|
238
|
-
klasses = klasses.filter((klass) => klass.length);
|
|
239
|
-
return klasses.join(" ");
|
|
240
|
-
};
|
|
241
|
-
const handleClick = (evt) => {
|
|
242
|
-
const el = evt.target;
|
|
243
|
-
if (el.getAttribute("aria-checked") == "true") {
|
|
244
|
-
el.setAttribute("aria-checked", "false");
|
|
245
|
-
} else {
|
|
246
|
-
el.setAttribute("aria-checked", "true");
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
const handleKeypress = (evt) => {
|
|
250
|
-
const keyCode = evt.keyCode || evt.which;
|
|
251
|
-
switch (keyCode) {
|
|
252
|
-
case 13:
|
|
253
|
-
evt.preventDefault();
|
|
254
|
-
evt.target.click();
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
</script>
|
|
259
|
-
|
|
260
|
-
<label class={switchContainer} for={id}>
|
|
261
|
-
{#if labelPosition === "left"}<span class="switch-label">{label}</span>{/if}
|
|
262
|
-
<input
|
|
263
|
-
type="checkbox"
|
|
264
|
-
class="switch-input"
|
|
265
|
-
id={id}
|
|
266
|
-
bind:checked={isChecked}
|
|
267
|
-
disabled={isDisabled}
|
|
268
|
-
on:change
|
|
269
|
-
on:click={handleClick}
|
|
270
|
-
on:keypress={handleKeypress}
|
|
271
|
-
role="switch"
|
|
272
|
-
/>
|
|
273
|
-
<span class={switchSpan()} aria-hidden="true"></span>
|
|
274
|
-
{#if labelPosition === "right"}<span class="switch-label">{label}</span>{/if}
|
|
275
|
-
</label>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const Switch: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
-
id?: string;
|
|
16
|
-
label?: string;
|
|
17
|
-
css?: string;
|
|
18
|
-
labelPosition?: string;
|
|
19
|
-
size?: string;
|
|
20
|
-
isChecked?: boolean;
|
|
21
|
-
isBordered?: boolean;
|
|
22
|
-
isAction?: boolean;
|
|
23
|
-
isDisabled?: boolean;
|
|
24
|
-
}, {
|
|
25
|
-
change: Event;
|
|
26
|
-
} & {
|
|
27
|
-
[evt: string]: CustomEvent<any>;
|
|
28
|
-
}, {}, {}, string>;
|
|
29
|
-
type Switch = InstanceType<typeof Switch>;
|
|
30
|
-
export default Switch;
|