@functionalcms/svelte-components 3.5.15 → 3.5.18
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/components/Banner.svelte +1 -1
- package/dist/components/Banner.svelte.d.ts +8 -13
- package/dist/components/Link.svelte.d.ts +45 -34
- package/dist/components/Logo.svelte.d.ts +26 -22
- package/dist/components/Markdown.svelte.d.ts +5 -14
- package/dist/components/Spacer.svelte.d.ts +6 -14
- package/dist/components/Well.svelte.d.ts +11 -13
- package/dist/components/agnostic/Button/Button.svelte +333 -332
- package/dist/components/agnostic/Button/Button.svelte.d.ts +50 -39
- package/dist/components/agnostic/Button/ButtonGroup.svelte.d.ts +30 -19
- package/dist/components/agnostic/Close/Close.svelte.d.ts +22 -18
- package/dist/components/agnostic/Disclose/Disclose.svelte.d.ts +10 -13
- package/dist/components/agnostic/Divider/Divider.svelte.d.ts +21 -17
- package/dist/components/agnostic/Loader/Loader.svelte.d.ts +20 -16
- package/dist/components/blog/BlogDescription.svelte.d.ts +21 -17
- package/dist/components/blog/BlogTitle.svelte.d.ts +21 -17
- package/dist/components/form/DateTimePicker.svelte.d.ts +16 -12
- package/dist/components/form/Input.svelte +1 -1
- package/dist/components/form/Input.svelte.d.ts +46 -20
- package/dist/components/form/InputAddonItem.svelte +34 -34
- package/dist/components/form/InputAddonItem.svelte.d.ts +27 -27
- package/dist/components/form/Select.svelte.d.ts +32 -28
- package/dist/components/{agnostic/Switch → form}/Switch.svelte +1 -1
- package/dist/components/form/Switch.svelte.d.ts +30 -0
- package/dist/components/layouts/DefaultLayout.svelte.d.ts +11 -13
- package/dist/components/layouts/Meta.svelte.d.ts +10 -13
- package/dist/components/layouts/SimpleFooter.svelte.d.ts +7 -13
- package/dist/components/layouts/Tracker.svelte.d.ts +5 -13
- package/dist/components/layouts/TwoColumnsLayout.svelte.d.ts +9 -13
- package/dist/components/menu/CollapsibleMenu.svelte.d.ts +27 -23
- package/dist/components/menu/DynamicMenu.svelte.d.ts +27 -23
- package/dist/components/menu/HamburgerMenu.svelte +3 -3
- package/dist/components/menu/HamburgerMenu.svelte.d.ts +25 -21
- package/dist/components/menu/Menu.svelte.d.ts +31 -27
- package/dist/components/menu/MenuItem.svelte.d.ts +37 -25
- package/dist/components/menu/NavigationItems.svelte +9 -4
- package/dist/components/menu/NavigationItems.svelte.d.ts +27 -23
- package/dist/components/presentation/Card.svelte.d.ts +17 -13
- package/dist/components/presentation/Carousel/carousel-content.svelte +35 -0
- package/dist/components/presentation/Carousel/carousel-content.svelte.d.ts +28 -0
- package/dist/components/presentation/Carousel/carousel-item.svelte +25 -0
- package/dist/components/presentation/Carousel/carousel-item.svelte.d.ts +28 -0
- package/dist/components/presentation/Carousel/carousel-next.svelte +39 -0
- package/dist/components/presentation/Carousel/carousel-next.svelte.d.ts +18 -0
- package/dist/components/presentation/Carousel/carousel-previous.svelte +40 -0
- package/dist/components/presentation/Carousel/carousel-previous.svelte.d.ts +18 -0
- package/dist/components/presentation/Carousel/carousel.svelte +99 -0
- package/dist/components/presentation/Carousel/carousel.svelte.d.ts +31 -0
- package/dist/components/presentation/Carousel/context.d.ts +32 -0
- package/dist/components/presentation/Carousel/context.js +12 -0
- package/dist/components/presentation/Carousel.svelte +4 -0
- package/dist/components/presentation/Carousel.svelte.d.ts +18 -0
- package/dist/components/presentation/Carusele.d.ts +1 -1
- package/dist/components/presentation/Carusele.js +1 -1
- package/dist/components/presentation/Gallery.svelte.d.ts +14 -13
- package/dist/components/presentation/ImageCompare.svelte +15 -12
- package/dist/components/presentation/ImageCompare.svelte.d.ts +24 -38
- package/dist/index.d.ts +5 -4
- package/dist/index.js +12 -7
- package/package.json +24 -24
- package/dist/components/agnostic/Alert/Alert.svelte +0 -317
- package/dist/components/agnostic/Alert/Alert.svelte.d.ts +0 -29
- package/dist/components/agnostic/Avatar/Avatar.svelte +0 -127
- package/dist/components/agnostic/Avatar/Avatar.svelte.d.ts +0 -24
- package/dist/components/agnostic/Avatar/AvatarGroup.svelte +0 -106
- package/dist/components/agnostic/Avatar/AvatarGroup.svelte.d.ts +0 -27
- package/dist/components/agnostic/Breadcrumb/Breadcrumb.svelte +0 -65
- package/dist/components/agnostic/Breadcrumb/Breadcrumb.svelte.d.ts +0 -18
- package/dist/components/agnostic/Breadcrumb/api.d.ts +0 -4
- package/dist/components/agnostic/Breadcrumb/api.js +0 -1
- package/dist/components/agnostic/ChoiceInput/ChoiceInput.svelte +0 -365
- package/dist/components/agnostic/ChoiceInput/ChoiceInput.svelte.d.ts +0 -35
- package/dist/components/agnostic/ChoiceInput/api.d.ts +0 -7
- package/dist/components/agnostic/ChoiceInput/api.js +0 -1
- package/dist/components/agnostic/Dialog/Dialog.svelte +0 -278
- package/dist/components/agnostic/Dialog/Dialog.svelte.d.ts +0 -37
- package/dist/components/agnostic/Dialog/SvelteA11yDialog.svelte +0 -128
- package/dist/components/agnostic/Dialog/SvelteA11yDialog.svelte.d.ts +0 -28
- package/dist/components/agnostic/Dialog/a11y-dialog.d.ts +0 -56
- package/dist/components/agnostic/Dialog/a11y-dialog.js +0 -216
- package/dist/components/agnostic/Dialog/dom-utils.d.ts +0 -26
- package/dist/components/agnostic/Dialog/dom-utils.js +0 -206
- package/dist/components/agnostic/Drawer/Drawer.svelte +0 -34
- package/dist/components/agnostic/Drawer/Drawer.svelte.d.ts +0 -26
- package/dist/components/agnostic/Drawer/api.d.ts +0 -1
- package/dist/components/agnostic/Drawer/api.js +0 -1
- package/dist/components/agnostic/EmptyState/EmptyState.svelte +0 -49
- package/dist/components/agnostic/EmptyState/EmptyState.svelte.d.ts +0 -21
- package/dist/components/agnostic/Header/Header.svelte +0 -111
- package/dist/components/agnostic/Header/Header.svelte.d.ts +0 -24
- package/dist/components/agnostic/Header/HeaderNav.svelte +0 -29
- package/dist/components/agnostic/Header/HeaderNav.svelte.d.ts +0 -18
- package/dist/components/agnostic/Header/HeaderNavItem.svelte +0 -31
- package/dist/components/agnostic/Header/HeaderNavItem.svelte.d.ts +0 -18
- package/dist/components/agnostic/Icon/Icon.svelte +0 -188
- package/dist/components/agnostic/Icon/Icon.svelte.d.ts +0 -21
- package/dist/components/agnostic/Icon/api.d.ts +0 -2
- package/dist/components/agnostic/Icon/api.js +0 -1
- package/dist/components/agnostic/Progress/Progress.svelte +0 -51
- package/dist/components/agnostic/Progress/Progress.svelte.d.ts +0 -18
- package/dist/components/agnostic/Spinner/Spinner.svelte +0 -108
- package/dist/components/agnostic/Spinner/Spinner.svelte.d.ts +0 -17
- package/dist/components/agnostic/Switch/Switch.svelte.d.ts +0 -43
- package/dist/components/agnostic/Table/Table.svelte +0 -521
- package/dist/components/agnostic/Table/Table.svelte.d.ts +0 -34
- package/dist/components/agnostic/Table/TableCustomRenderComponent.svelte +0 -13
- package/dist/components/agnostic/Table/TableCustomRenderComponent.svelte.d.ts +0 -23
- package/dist/components/agnostic/Tabs/TabButtonCustom.svelte +0 -77
- package/dist/components/agnostic/Tabs/TabButtonCustom.svelte.d.ts +0 -33
- package/dist/components/agnostic/Tabs/Tabs.svelte +0 -399
- package/dist/components/agnostic/Tabs/Tabs.svelte.d.ts +0 -32
- package/dist/components/agnostic/Tabs/api.d.ts +0 -10
- package/dist/components/agnostic/Tabs/api.js +0 -1
- package/dist/components/agnostic/Tag/Tag.svelte +0 -78
- package/dist/components/agnostic/Tag/Tag.svelte.d.ts +0 -21
- package/dist/components/agnostic/Tag/TagSlots.svelte +0 -52
- package/dist/components/agnostic/Tag/TagSlots.svelte.d.ts +0 -14
- package/dist/components/agnostic/Toasts/Toasts.svelte +0 -56
- package/dist/components/agnostic/Toasts/Toasts.svelte.d.ts +0 -20
- package/dist/components/agnostic/Tooltip/Tooltip.svelte +0 -120
- package/dist/components/agnostic/Tooltip/Tooltip.svelte.d.ts +0 -21
- package/dist/components/agnostic/Tooltip/TooltipSlots.svelte +0 -82
- package/dist/components/agnostic/Tooltip/TooltipSlots.svelte.d.ts +0 -14
- package/dist/components/agnostic/Tooltip/api.d.ts +0 -1
- package/dist/components/agnostic/Tooltip/api.js +0 -1
- package/dist/components/presentation/Carusel.svelte +0 -109
- package/dist/components/presentation/Carusel.svelte.d.ts +0 -56
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import Close from '../Close/Close.svelte';
|
|
3
|
-
import SvelteA11yDialog from './SvelteA11yDialog.svelte';
|
|
4
|
-
import { createEventDispatcher } from 'svelte';
|
|
5
|
-
const dispatch = createEventDispatcher();
|
|
6
|
-
|
|
7
|
-
export let id;
|
|
8
|
-
export let title;
|
|
9
|
-
export let dialogRoot;
|
|
10
|
-
export let role: 'dialog' | 'alertdialog' = 'dialog';
|
|
11
|
-
export let titleId = '';
|
|
12
|
-
export let closeButtonLabel = 'Close button';
|
|
13
|
-
export let closeButtonPosition: 'first' | 'last' | 'none' = 'first';
|
|
14
|
-
export let drawerPlacement = '';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Animates the dialog content by fading in. Set to false to disable.
|
|
18
|
-
*/
|
|
19
|
-
export let isAnimationFadeIn = false;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Animates the dialog content by sliding up. Set to false to disable.
|
|
23
|
-
*/
|
|
24
|
-
export let isAnimationSlideUp = false;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Handles a11y-dialog instantiation and assigning of dialog instance
|
|
28
|
-
*/
|
|
29
|
-
let dialogInstance;
|
|
30
|
-
const assignDialogInstance = (ev) => {
|
|
31
|
-
dialogInstance = ev.detail.instance;
|
|
32
|
-
dispatch('instance', {
|
|
33
|
-
instance: dialogInstance
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export let classNames = {};
|
|
38
|
-
const documentClasses = [
|
|
39
|
-
'dialog-content',
|
|
40
|
-
isAnimationFadeIn && isAnimationSlideUp ? 'dialog-slide-up-fade-in' : '',
|
|
41
|
-
!isAnimationFadeIn && isAnimationSlideUp ? 'dialog-slide-up' : '',
|
|
42
|
-
isAnimationFadeIn && !isAnimationSlideUp ? 'dialog-fade-in' : '',
|
|
43
|
-
drawerPlacement.length ? 'drawer-content' : ''
|
|
44
|
-
]
|
|
45
|
-
.filter((c) => c)
|
|
46
|
-
.join(' ');
|
|
47
|
-
|
|
48
|
-
const containerClasses = ['dialog', drawerPlacement ? `drawer-${drawerPlacement}` : '']
|
|
49
|
-
.filter((c) => c)
|
|
50
|
-
.join(' ');
|
|
51
|
-
|
|
52
|
-
const defaultClassNames = {
|
|
53
|
-
container: containerClasses,
|
|
54
|
-
document: documentClasses,
|
|
55
|
-
overlay: 'dialog-overlay',
|
|
56
|
-
title: 'h4 mbe16',
|
|
57
|
-
// Borrows .close-button (from close.css) as it gives us the transparent
|
|
58
|
-
// style plus the a11y focus ring we want applied to dialog's close button
|
|
59
|
-
closeButton: 'dialog-close dialog-close-button'
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
$: getClassNames = () => {
|
|
63
|
-
return { ...defaultClassNames, ...classNames };
|
|
64
|
-
};
|
|
65
|
-
</script>
|
|
66
|
-
|
|
67
|
-
<SvelteA11yDialog
|
|
68
|
-
{id}
|
|
69
|
-
{dialogRoot}
|
|
70
|
-
{closeButtonLabel}
|
|
71
|
-
{closeButtonPosition}
|
|
72
|
-
{title}
|
|
73
|
-
{titleId}
|
|
74
|
-
{role}
|
|
75
|
-
classNames={getClassNames()}
|
|
76
|
-
on:instance={assignDialogInstance}
|
|
77
|
-
>
|
|
78
|
-
<slot name="closeButtonContent" slot="closeButtonContent">
|
|
79
|
-
<Close isFaux size="large" />
|
|
80
|
-
</slot>
|
|
81
|
-
<slot />
|
|
82
|
-
</SvelteA11yDialog>
|
|
83
|
-
|
|
84
|
-
<style>
|
|
85
|
-
/* ---------- GLOBAL STYLES ---------- */
|
|
86
|
-
/* Note this component requires global styles and doesn't get copied over from copystyles.js
|
|
87
|
-
and is "locked down". Svelte no longer appears to support <style global> and CSS Modules support
|
|
88
|
-
isn't built in. So, not ideal, but this is what we'll have to do for this component. */
|
|
89
|
-
|
|
90
|
-
/* These are styles for the case where classNames.closeButton property was NOT
|
|
91
|
-
passed in and so we're generating the default close 'X' button on the upper right. */
|
|
92
|
-
:global(.dialog-close-button) {
|
|
93
|
-
display: inline-flex;
|
|
94
|
-
align-items: center;
|
|
95
|
-
justify-content: center;
|
|
96
|
-
background-color: transparent;
|
|
97
|
-
border: 0;
|
|
98
|
-
border-radius: 0;
|
|
99
|
-
box-shadow: none;
|
|
100
|
-
width: var(--fluid-32);
|
|
101
|
-
height: var(--fluid-32);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
:global(.dialog-close-button:hover, .dialog-close-button:active, .dialog-close-button:focus) {
|
|
105
|
-
background: none;
|
|
106
|
-
|
|
107
|
-
/* Needed for High Contrast mode */
|
|
108
|
-
outline: var(--functional-focus-ring-outline-width) var(--functional-focus-ring-outline-style)
|
|
109
|
-
var(--functional-focus-ring-outline-color);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
:global(.dialog-close-button:focus) {
|
|
113
|
-
box-shadow: 0 0 0 3px var(--functional-focus-ring-color);
|
|
114
|
-
transition: box-shadow var(--functional-timing-fast) ease-out;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
@media (prefers-reduced-motion), (update: slow) {
|
|
118
|
-
:global(.dialog-close-button:focus) {
|
|
119
|
-
transition-duration: 0.001ms !important;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
:global(.close-button-large > .close) {
|
|
124
|
-
width: var(--fluid-16);
|
|
125
|
-
height: var(--fluid-16);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
:global(.dialog-close-button:hover .close) {
|
|
129
|
-
opacity: 100%;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
:global(.dialog),
|
|
133
|
-
:global(.dialog-overlay) {
|
|
134
|
-
position: fixed;
|
|
135
|
-
top: 0;
|
|
136
|
-
right: 0;
|
|
137
|
-
bottom: 0;
|
|
138
|
-
left: 0;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
:global(.dialog) {
|
|
142
|
-
z-index: 1001;
|
|
143
|
-
display: flex;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
:global(.dialog[aria-hidden='true']) {
|
|
147
|
-
display: none;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
:global(.dialog-overlay) {
|
|
151
|
-
background-color: rgb(50 50 50 / 60%);
|
|
152
|
-
animation: fade-in var(--functional-timing-fast) both;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
:global(.dialog-content) {
|
|
156
|
-
background-color: var(--functional-light);
|
|
157
|
-
margin: auto;
|
|
158
|
-
z-index: 1001;
|
|
159
|
-
position: relative;
|
|
160
|
-
padding: var(--fluid-16);
|
|
161
|
-
max-width: 90%;
|
|
162
|
-
width: 600px;
|
|
163
|
-
border-radius: var(--functional-radius);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
:global(.dialog-fade-in) {
|
|
167
|
-
animation: fade-in var(--functional-timing-fast) both;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
:global(.dialog-slide-up) {
|
|
171
|
-
animation: slide-up var(--functional-timing-slow) var(--functional-timing-fast) both;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Cannot use two separate CSS classes with animation: foo, bar
|
|
176
|
-
* as the later class will overwrite the first (so this combines)
|
|
177
|
-
*/
|
|
178
|
-
:global(.dialog-slide-up-fade-in) {
|
|
179
|
-
animation:
|
|
180
|
-
fade-in var(--functional-timing-fast) both,
|
|
181
|
-
slide-up var(--functional-timing-slow) var(--functional-timing-fast) both;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
@media screen and (min-width: 700px) {
|
|
185
|
-
:global(.dialog-content) {
|
|
186
|
-
padding: var(--fluid-32);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
@keyframes -global-fade-in {
|
|
191
|
-
from {
|
|
192
|
-
opacity: 0%;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
@keyframes -global-slide-up {
|
|
197
|
-
from {
|
|
198
|
-
transform: translateY(10%);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/* Shared with AgnosticUI close buton so only need positioning and transition */
|
|
203
|
-
:global(.dialog-close) {
|
|
204
|
-
position: absolute;
|
|
205
|
-
top: var(--fluid-8);
|
|
206
|
-
right: var(--fluid-8);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
@media (prefers-reduced-motion), (update: slow) {
|
|
210
|
-
:global(.dialog-slide-up-fade-in, .dialog-fade-in, .dialog-slide-up, .dialog-content) {
|
|
211
|
-
transition-duration: 0.001ms !important;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
@media only screen and (min-width: 576px) {
|
|
216
|
-
:global(.dialog-close) {
|
|
217
|
-
top: var(--fluid-12);
|
|
218
|
-
right: var(--fluid-12);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
@media screen and (min-width: 768px) {
|
|
223
|
-
:global(.dialog-close) {
|
|
224
|
-
top: var(--fluid-16);
|
|
225
|
-
right: var(--fluid-16);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/* We use div.drawer-* for specificity battle :( */
|
|
230
|
-
:global(div.drawer-start) {
|
|
231
|
-
right: initial;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
:global(div.drawer-start[aria-hidden]) {
|
|
235
|
-
transform: none;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
:global(div.drawer-end) {
|
|
239
|
-
left: initial;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
:global(div.drawer-end[aria-hidden]) {
|
|
243
|
-
transform: none;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
:global(div.drawer-top) {
|
|
247
|
-
bottom: initial;
|
|
248
|
-
transform: none;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
:global(div.drawer-top[aria-hidden]) {
|
|
252
|
-
transform: none;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
:global(div.drawer-bottom) {
|
|
256
|
-
top: initial;
|
|
257
|
-
transform: none;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
:global(div.drawer-bottom[aria-hidden]) {
|
|
261
|
-
transform: none;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
:global(div.drawer-content) {
|
|
265
|
-
margin: initial;
|
|
266
|
-
max-width: initial;
|
|
267
|
-
border-radius: initial;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
:global(div.drawer-start div.drawer-content, div.drawer-end div.drawer-content) {
|
|
271
|
-
width: 25rem;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
:global(div.drawer-top div.drawer-content, div.drawer-bottom div.drawer-content) {
|
|
275
|
-
height: 25vh;
|
|
276
|
-
width: 100%;
|
|
277
|
-
}
|
|
278
|
-
</style>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
id: any;
|
|
5
|
-
title: any;
|
|
6
|
-
dialogRoot: any;
|
|
7
|
-
role?: "dialog" | "alertdialog";
|
|
8
|
-
titleId?: string;
|
|
9
|
-
closeButtonLabel?: string;
|
|
10
|
-
closeButtonPosition?: "first" | "last" | "none";
|
|
11
|
-
drawerPlacement?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Animates the dialog content by fading in. Set to false to disable.
|
|
14
|
-
*/ isAnimationFadeIn?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Animates the dialog content by sliding up. Set to false to disable.
|
|
17
|
-
*/ isAnimationSlideUp?: boolean;
|
|
18
|
-
classNames?: {};
|
|
19
|
-
};
|
|
20
|
-
events: {
|
|
21
|
-
instance: CustomEvent<any>;
|
|
22
|
-
} & {
|
|
23
|
-
[evt: string]: CustomEvent<any>;
|
|
24
|
-
};
|
|
25
|
-
slots: {
|
|
26
|
-
closeButtonContent: {
|
|
27
|
-
slot: string;
|
|
28
|
-
};
|
|
29
|
-
default: {};
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
export type DialogProps = typeof __propDef.props;
|
|
33
|
-
export type DialogEvents = typeof __propDef.events;
|
|
34
|
-
export type DialogSlots = typeof __propDef.slots;
|
|
35
|
-
export default class Dialog extends SvelteComponentTyped<DialogProps, DialogEvents, DialogSlots> {
|
|
36
|
-
}
|
|
37
|
-
export {};
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { createEventDispatcher, onMount, onDestroy, tick } from "svelte";
|
|
3
|
-
import A11yDialog from './a11y-dialog.js';
|
|
4
|
-
|
|
5
|
-
const dispatch = createEventDispatcher();
|
|
6
|
-
|
|
7
|
-
export let id: string;
|
|
8
|
-
export let titleId = '';
|
|
9
|
-
export let role: 'dialog' | 'alertdialog' = 'dialog';
|
|
10
|
-
export let dialogRoot: string;
|
|
11
|
-
export let title: string;
|
|
12
|
-
export let closeButtonLabel = 'Close this dialog window';
|
|
13
|
-
export let closeButtonPosition: 'first' | 'last' | 'none' = 'first';
|
|
14
|
-
export let classNames = {}
|
|
15
|
-
const defaultClassNames = {
|
|
16
|
-
container: 'dialog-container',
|
|
17
|
-
document: 'dialog-content',
|
|
18
|
-
overlay: 'dialog-overlay',
|
|
19
|
-
element: 'dialog-element',
|
|
20
|
-
title: 'dialog-title h4',
|
|
21
|
-
closeButton: 'dialog-close',
|
|
22
|
-
};
|
|
23
|
-
const classes = {...defaultClassNames, ...classNames};
|
|
24
|
-
|
|
25
|
-
// The dialog instance
|
|
26
|
-
let dialog;
|
|
27
|
-
|
|
28
|
-
// Dialog element's binding
|
|
29
|
-
let rootElement;
|
|
30
|
-
|
|
31
|
-
const portalTarget: string = dialogRoot || "document.body";
|
|
32
|
-
|
|
33
|
-
const fullTitleId = titleId || `${id}-title`;
|
|
34
|
-
|
|
35
|
-
const roleAttribute = ['dialog', 'alertdialog'].includes(role)
|
|
36
|
-
? role
|
|
37
|
-
: 'dialog';
|
|
38
|
-
|
|
39
|
-
// In case of SSR we don't render element until hydration is complete
|
|
40
|
-
let mounted = false;
|
|
41
|
-
onMount(() => mounted = true);
|
|
42
|
-
|
|
43
|
-
onDestroy(() => {
|
|
44
|
-
if (dialog) {
|
|
45
|
-
dialog.destroy();
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const instantiateDialog = async () => {
|
|
50
|
-
await tick();
|
|
51
|
-
dialog = new A11yDialog(rootElement, portalTarget);
|
|
52
|
-
dispatch("instance", {
|
|
53
|
-
"instance": dialog
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const teleportNode = async (node) => {
|
|
58
|
-
const destination = document.querySelector(portalTarget);
|
|
59
|
-
destination.appendChild(node);
|
|
60
|
-
// We don't render the template until mounted. So we need
|
|
61
|
-
// wait one more "tick" before instantiating the dialog
|
|
62
|
-
instantiateDialog();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Svelte actions don't want to be async so this is a hack
|
|
67
|
-
* to get around that by delegating to teleportNode
|
|
68
|
-
*/
|
|
69
|
-
const teleport = (node) => {
|
|
70
|
-
teleportNode(node);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const close = () => {
|
|
74
|
-
dialog.hide();
|
|
75
|
-
}
|
|
76
|
-
</script>
|
|
77
|
-
|
|
78
|
-
{#if mounted}
|
|
79
|
-
<div
|
|
80
|
-
id={id}
|
|
81
|
-
bind:this={rootElement}
|
|
82
|
-
class={classes.container}
|
|
83
|
-
role={roleAttribute}
|
|
84
|
-
aria-hidden="true"
|
|
85
|
-
aria-labelledby={fullTitleId}
|
|
86
|
-
use:teleport
|
|
87
|
-
>
|
|
88
|
-
<div
|
|
89
|
-
data-a11y-dialog-hide
|
|
90
|
-
tabindex="-1"
|
|
91
|
-
class={classes.overlay}
|
|
92
|
-
on:click|preventDefault={role === 'alertdialog' ? undefined : close}
|
|
93
|
-
></div>
|
|
94
|
-
<div role="document" class={classes.document}>
|
|
95
|
-
{#if closeButtonPosition === 'first'}
|
|
96
|
-
<button
|
|
97
|
-
data-a11y-dialog-hide
|
|
98
|
-
type="button"
|
|
99
|
-
class={classes.closeButton}
|
|
100
|
-
aria-label={closeButtonLabel}
|
|
101
|
-
on:click={close}
|
|
102
|
-
>
|
|
103
|
-
<slot name="closeButtonContent">
|
|
104
|
-
{ '\u00D7' }
|
|
105
|
-
</slot>
|
|
106
|
-
</button>
|
|
107
|
-
{/if}
|
|
108
|
-
<p id={fullTitleId} class={classes.title}>
|
|
109
|
-
{title}
|
|
110
|
-
</p>
|
|
111
|
-
<slot />
|
|
112
|
-
{#if closeButtonPosition === 'last'}
|
|
113
|
-
<button
|
|
114
|
-
data-a11y-dialog-hide
|
|
115
|
-
type="button"
|
|
116
|
-
class={classes.closeButton}
|
|
117
|
-
aria-label={closeButtonLabel}
|
|
118
|
-
on:click={close}
|
|
119
|
-
>
|
|
120
|
-
<slot name="closeButtonContent">
|
|
121
|
-
{ '\u00D7' }
|
|
122
|
-
</slot>
|
|
123
|
-
</button>
|
|
124
|
-
{/if}
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
{/if}
|
|
128
|
-
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
id: string;
|
|
5
|
-
titleId?: string;
|
|
6
|
-
role?: "dialog" | "alertdialog";
|
|
7
|
-
dialogRoot: string;
|
|
8
|
-
title: string;
|
|
9
|
-
closeButtonLabel?: string;
|
|
10
|
-
closeButtonPosition?: "first" | "last" | "none";
|
|
11
|
-
classNames?: {};
|
|
12
|
-
};
|
|
13
|
-
events: {
|
|
14
|
-
instance: CustomEvent<any>;
|
|
15
|
-
} & {
|
|
16
|
-
[evt: string]: CustomEvent<any>;
|
|
17
|
-
};
|
|
18
|
-
slots: {
|
|
19
|
-
closeButtonContent: {};
|
|
20
|
-
default: {};
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
export type SvelteA11yDialogProps = typeof __propDef.props;
|
|
24
|
-
export type SvelteA11yDialogEvents = typeof __propDef.events;
|
|
25
|
-
export type SvelteA11yDialogSlots = typeof __propDef.slots;
|
|
26
|
-
export default class SvelteA11yDialog extends SvelteComponentTyped<SvelteA11yDialogProps, SvelteA11yDialogEvents, SvelteA11yDialogSlots> {
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export type A11yDialogEvent = 'show' | 'hide' | 'destroy';
|
|
2
|
-
export type A11yDialogInstance = InstanceType<typeof A11yDialog>;
|
|
3
|
-
export default class A11yDialog {
|
|
4
|
-
private $el;
|
|
5
|
-
private id;
|
|
6
|
-
private previouslyFocused;
|
|
7
|
-
shown: boolean;
|
|
8
|
-
constructor(element: HTMLElement);
|
|
9
|
-
/**
|
|
10
|
-
* Destroy the current instance (after making sure the dialog has been hidden)
|
|
11
|
-
* and remove all associated listeners from dialog openers and closers
|
|
12
|
-
*/
|
|
13
|
-
destroy(): this;
|
|
14
|
-
/**
|
|
15
|
-
* Show the dialog element, trap the current focus within it, listen for some
|
|
16
|
-
* specific key presses and fire all registered callbacks for `show` event
|
|
17
|
-
*/
|
|
18
|
-
show(event?: Event): this;
|
|
19
|
-
/**
|
|
20
|
-
* Hide the dialog element, restore the focus to the previously active
|
|
21
|
-
* element, stop listening for some specific key presses and fire all
|
|
22
|
-
* registered callbacks for `hide` event
|
|
23
|
-
*/
|
|
24
|
-
hide(event?: Event): this;
|
|
25
|
-
/**
|
|
26
|
-
* Register a new callback for the given event type
|
|
27
|
-
*/
|
|
28
|
-
on(type: A11yDialogEvent, handler: EventListener, options?: AddEventListenerOptions): this;
|
|
29
|
-
/**
|
|
30
|
-
* Unregister an existing callback for the given event type
|
|
31
|
-
*/
|
|
32
|
-
off(type: A11yDialogEvent, handler: EventListener, options?: AddEventListenerOptions): this;
|
|
33
|
-
/**
|
|
34
|
-
* Dispatch and return a custom event from the DOM element associated with
|
|
35
|
-
* this dialog; this allows authors to listen for and respond to the events
|
|
36
|
-
* in their own code
|
|
37
|
-
*/
|
|
38
|
-
private fire;
|
|
39
|
-
/**
|
|
40
|
-
* Add a delegated event listener for when elememts that open or close the
|
|
41
|
-
* dialog are clicked, and call `show` or `hide`, respectively
|
|
42
|
-
*/
|
|
43
|
-
private handleTriggerClicks;
|
|
44
|
-
/**
|
|
45
|
-
* Private event handler used when listening to some specific key presses
|
|
46
|
-
* (namely ESC and TAB)
|
|
47
|
-
*/
|
|
48
|
-
private bindKeypress;
|
|
49
|
-
/**
|
|
50
|
-
* If the dialog is shown and the focus is not within a dialog element (either
|
|
51
|
-
* this one or another one in case of nested dialogs) or attribute, move it
|
|
52
|
-
* back to the dialog container
|
|
53
|
-
* See: https://github.com/KittyGiraudel/a11y-dialog/issues/177
|
|
54
|
-
*/
|
|
55
|
-
private maintainFocus;
|
|
56
|
-
}
|