@skeletonlabs/skeleton 0.92.2 → 0.124.2
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/README.md +0 -1
- package/actions/Filters/filter.js +6 -9
- package/components/Accordion/Accordion.svelte +30 -0
- package/components/Accordion/Accordion.svelte.d.ts +37 -0
- package/components/Accordion/AccordionItem.svelte +83 -63
- package/components/Accordion/AccordionItem.svelte.d.ts +20 -6
- package/components/AppBar/AppBar.svelte +48 -49
- package/components/AppBar/AppBar.svelte.d.ts +20 -1
- package/components/AppRail/AppRail.svelte +20 -40
- package/components/AppRail/AppRail.svelte.d.ts +13 -1
- package/components/AppRail/AppRailTile.svelte +32 -43
- package/components/AppRail/AppRailTile.svelte.d.ts +10 -4
- package/components/AppShell/AppShell.svelte +30 -39
- package/components/AppShell/AppShell.svelte.d.ts +11 -0
- package/components/Avatar/Avatar.svelte +18 -35
- package/components/Avatar/Avatar.svelte.d.ts +16 -5
- package/components/ConicGradient/ConicGradient.svelte +43 -49
- package/components/ConicGradient/ConicGradient.svelte.d.ts +11 -0
- package/components/ConicGradient/settings.d.ts +2 -4
- package/components/ConicGradient/settings.js +2 -2
- package/components/FileButton/FileButton.svelte +19 -14
- package/components/FileButton/FileButton.svelte.d.ts +3 -1
- package/components/FileDropzone/FileDropzone.svelte +48 -88
- package/components/FileDropzone/FileDropzone.svelte.d.ts +24 -8
- package/components/InputChip/InputChip.svelte +111 -96
- package/components/InputChip/InputChip.svelte.d.ts +28 -5
- package/components/ListBox/ListBox.svelte +18 -54
- package/components/ListBox/ListBox.svelte.d.ts +11 -10
- package/components/ListBox/ListBoxItem.svelte +69 -75
- package/components/ListBox/ListBoxItem.svelte.d.ts +11 -7
- package/components/Paginator/Paginator.svelte +27 -43
- package/components/Paginator/Paginator.svelte.d.ts +13 -2
- package/components/ProgressBar/ProgressBar.svelte +25 -44
- package/components/ProgressBar/ProgressBar.svelte.d.ts +9 -1
- package/components/ProgressRadial/ProgressRadial.svelte +20 -40
- package/components/ProgressRadial/ProgressRadial.svelte.d.ts +9 -2
- package/components/Radio/RadioGroup.svelte +22 -44
- package/components/Radio/RadioGroup.svelte.d.ts +15 -7
- package/components/Radio/RadioItem.svelte +37 -45
- package/components/Radio/RadioItem.svelte.d.ts +10 -6
- package/components/RangeSlider/RangeSlider.svelte +26 -57
- package/components/RangeSlider/RangeSlider.svelte.d.ts +11 -2
- package/components/SlideToggle/SlideToggle.svelte +43 -54
- package/components/SlideToggle/SlideToggle.svelte.d.ts +11 -3
- package/components/Stepper/Step.svelte +69 -120
- package/components/Stepper/Step.svelte.d.ts +17 -18
- package/components/Stepper/Stepper.svelte +61 -61
- package/components/Stepper/Stepper.svelte.d.ts +28 -14
- package/components/Tab/Tab.svelte +48 -61
- package/components/Tab/Tab.svelte.d.ts +19 -14
- package/components/Tab/TabGroup.svelte +35 -66
- package/components/Tab/TabGroup.svelte.d.ts +25 -9
- package/components/Table/Table.svelte +20 -36
- package/components/Table/Table.svelte.d.ts +9 -0
- package/components/TableOfContents/TableOfContents.svelte +63 -94
- package/components/TableOfContents/TableOfContents.svelte.d.ts +12 -0
- package/index.d.ts +2 -6
- package/index.js +1 -6
- package/package.json +39 -29
- package/styles/all.css +3 -3
- package/styles/core.css +11 -2
- package/styles/elements/alerts.css +2 -28
- package/styles/elements/badges.css +0 -25
- package/styles/elements/breadcrumbs.css +2 -3
- package/styles/elements/buttons.css +33 -120
- package/styles/elements/cards.css +2 -29
- package/styles/elements/chips.css +9 -58
- package/styles/elements/forms.css +269 -0
- package/styles/elements/lists.css +5 -4
- package/styles/elements/logo-clouds.css +2 -4
- package/styles/elements/tables.css +14 -10
- package/styles/elements.css +1 -0
- package/styles/tailwind.css +7 -3
- package/styles/typography.css +46 -62
- package/styles/variants.css +154 -0
- package/tailwind/core.cjs +37 -0
- package/tailwind/core.d.cts +5 -0
- package/tailwind/generated/intellisense-classes.cjs +1 -0
- package/tailwind/generated/{allComponents.d.cts → intellisense-classes.d.cts} +886 -1029
- package/tailwind/intellisense.cjs +21 -0
- package/tailwind/intellisense.d.cts +5 -0
- package/tailwind/settings.cjs +16 -16
- package/tailwind/skeleton.cjs +13 -44
- package/tailwind/skeleton.d.cts +4 -2
- package/tailwind/theme/colors.cjs +7 -7
- package/tailwind/tokens/backgrounds.cjs +28 -30
- package/tailwind/tokens/border-radius.cjs +15 -15
- package/tailwind/tokens/borders.cjs +14 -14
- package/tailwind/tokens/fills.cjs +14 -14
- package/tailwind/tokens/rings.cjs +40 -32
- package/tailwind/tokens/rings.d.cts +5 -0
- package/tailwind/tokens/text.cjs +24 -26
- package/themes/theme-skeleton.css +6 -6
- package/utilities/CodeBlock/CodeBlock.svelte +28 -40
- package/utilities/CodeBlock/CodeBlock.svelte.d.ts +8 -0
- package/utilities/DataTable/DataTable.js +1 -1
- package/utilities/Drawer/Drawer.svelte +82 -105
- package/utilities/Drawer/Drawer.svelte.d.ts +13 -0
- package/utilities/LightSwitch/LightSwitch.svelte +32 -50
- package/utilities/LightSwitch/LightSwitch.svelte.d.ts +3 -1
- package/utilities/Modal/Modal.svelte +58 -93
- package/utilities/Modal/Modal.svelte.d.ts +18 -0
- package/utilities/Modal/examples/ModalExampleEmbed.svelte +3 -6
- package/utilities/Modal/examples/ModalExampleForm.svelte +16 -22
- package/utilities/Modal/examples/ModalExampleImage.svelte +19 -0
- package/utilities/Modal/examples/ModalExampleImage.svelte.d.ts +16 -0
- package/utilities/Modal/examples/ModalExampleList.svelte +11 -15
- package/utilities/Toast/Toast.svelte +65 -87
- package/utilities/Toast/Toast.svelte.d.ts +12 -0
- package/utilities/Toast/stores.js +13 -4
- package/components/Accordion/AccordionGroup.svelte +0 -46
- package/components/Accordion/AccordionGroup.svelte.d.ts +0 -24
- package/components/Alert/Alert.svelte +0 -65
- package/components/Alert/Alert.svelte.d.ts +0 -30
- package/components/Breadcrumb/Breadcrumb.svelte +0 -24
- package/components/Breadcrumb/Breadcrumb.svelte.d.ts +0 -21
- package/components/Breadcrumb/Crumb.svelte +0 -37
- package/components/Breadcrumb/Crumb.svelte.d.ts +0 -26
- package/components/Divider/Divider.svelte +0 -21
- package/components/Divider/Divider.svelte.d.ts +0 -22
- package/components/GradientHeading/GradientHeading.svelte +0 -21
- package/components/GradientHeading/GradientHeading.svelte.d.ts +0 -22
- package/components/SvgIcon/SvgIcon.svelte +0 -45
- package/components/SvgIcon/SvgIcon.svelte.d.ts +0 -26
- package/components/SvgIcon/icons.d.ts +0 -1
- package/components/SvgIcon/icons.js +0 -25
- package/styles/forms.css +0 -178
- package/tailwind/generated/allComponents.cjs +0 -1
|
@@ -1,129 +1,106 @@
|
|
|
1
|
-
<script>import { fade, fly } from
|
|
2
|
-
import { createEventDispatcher, onMount } from
|
|
3
|
-
// Event Handler
|
|
1
|
+
<script>import { fade, fly } from "svelte/transition";
|
|
2
|
+
import { createEventDispatcher, onMount } from "svelte";
|
|
4
3
|
const dispatch = createEventDispatcher();
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
// Props
|
|
9
|
-
/** Set the anchor position.
|
|
10
|
-
* @type {'left' | 'top' | 'right' | 'bottom'}
|
|
11
|
-
*/
|
|
12
|
-
export let position = 'left';
|
|
13
|
-
/** Define the Svelte transition animation duration. */
|
|
4
|
+
import { focusTrap } from "../../actions/FocusTrap/focusTrap";
|
|
5
|
+
import { drawerStore } from "./stores";
|
|
6
|
+
export let position = "left";
|
|
14
7
|
export let duration = 150;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export let
|
|
18
|
-
|
|
19
|
-
export let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export let
|
|
23
|
-
|
|
24
|
-
export let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/** Drawer - Provide classes to override the width. */
|
|
28
|
-
export let width = '';
|
|
29
|
-
/** Drawer - Provide classes to override the height. */
|
|
30
|
-
export let height = '';
|
|
31
|
-
/** Drawer - Provide classes to set margins. */
|
|
32
|
-
export let margin = '';
|
|
33
|
-
// Props (a11y)
|
|
34
|
-
/** Provide an ID of the element labeling the drawer. */
|
|
35
|
-
export let labelledby = '';
|
|
36
|
-
/** Provide an ID of the element describing the drawer. */
|
|
37
|
-
export let describedby = '';
|
|
38
|
-
// Base Classes
|
|
39
|
-
const cBaseBackdrop = 'fixed top-0 left-0 right-0 bottom-0 z-40 flex';
|
|
40
|
-
const cBaseDrawer = 'shadow-xl overflow-y-auto';
|
|
41
|
-
// Local
|
|
8
|
+
export let bgBackdrop = "bg-surface-backdrop-token";
|
|
9
|
+
export let blur = "backdrop-blur-xs";
|
|
10
|
+
export let bgDrawer = "bg-surface-100-800-token";
|
|
11
|
+
export let border = "";
|
|
12
|
+
export let rounded = "";
|
|
13
|
+
export let width = "";
|
|
14
|
+
export let height = "";
|
|
15
|
+
export let margin = "";
|
|
16
|
+
export let labelledby = "";
|
|
17
|
+
export let describedby = "";
|
|
18
|
+
const cBaseBackdrop = "fixed top-0 left-0 right-0 bottom-0 z-40 flex";
|
|
19
|
+
const cBaseDrawer = "shadow-xl overflow-y-auto";
|
|
42
20
|
let elemBackdrop;
|
|
43
21
|
let windowSettings = { width: 1920, height: 1080 };
|
|
44
|
-
let styleSettings = { backdrop:
|
|
22
|
+
let styleSettings = { backdrop: "", width: "", height: "" };
|
|
45
23
|
let animSettings = { x: 0, y: 0 };
|
|
46
|
-
// Record a record of default props on init
|
|
47
|
-
// NOTE: these must stay in sync with the props implemented above.
|
|
48
|
-
// prettier-ignore
|
|
49
24
|
const propDefaults = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
25
|
+
position,
|
|
26
|
+
duration,
|
|
27
|
+
bgBackdrop,
|
|
28
|
+
blur,
|
|
29
|
+
bgDrawer,
|
|
30
|
+
border,
|
|
31
|
+
rounded,
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
margin,
|
|
35
|
+
labelledby,
|
|
36
|
+
describedby
|
|
54
37
|
};
|
|
55
|
-
// Listen to drawerStore updates
|
|
56
38
|
drawerStore.subscribe((settings) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
39
|
+
if (settings.open === false)
|
|
40
|
+
return;
|
|
41
|
+
applySettings(settings);
|
|
42
|
+
setPosition();
|
|
61
43
|
});
|
|
62
|
-
// Override provided props, else restore prop defaults
|
|
63
|
-
// NOTE: these must stay in sync with the props implemented above.
|
|
64
44
|
function applySettings(settings) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// A11y
|
|
78
|
-
labelledby = settings.labelledby || propDefaults.labelledby;
|
|
79
|
-
describedby = settings.describedby || propDefaults.describedby;
|
|
45
|
+
position = settings.position || propDefaults.position;
|
|
46
|
+
duration = settings.duration || propDefaults.duration;
|
|
47
|
+
bgBackdrop = settings.bgBackdrop || propDefaults.bgBackdrop;
|
|
48
|
+
blur = settings.blur || propDefaults.blur;
|
|
49
|
+
bgDrawer = settings.bgDrawer || propDefaults.bgDrawer;
|
|
50
|
+
border = settings.border || propDefaults.border;
|
|
51
|
+
rounded = settings.rounded || propDefaults.rounded;
|
|
52
|
+
width = settings.width || propDefaults.width;
|
|
53
|
+
height = settings.height || propDefaults.height;
|
|
54
|
+
margin = settings.margin || propDefaults.margin;
|
|
55
|
+
labelledby = settings.labelledby || propDefaults.labelledby;
|
|
56
|
+
describedby = settings.describedby || propDefaults.describedby;
|
|
80
57
|
}
|
|
81
58
|
function setPosition() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
59
|
+
switch (position) {
|
|
60
|
+
case "top":
|
|
61
|
+
styleSettings = { backdrop: "flex-col justify-start", width: "w-full", height: "h-[40%]" };
|
|
62
|
+
animSettings = { x: 0, y: -percentage(40, windowSettings.height) };
|
|
63
|
+
break;
|
|
64
|
+
case "bottom":
|
|
65
|
+
styleSettings = { backdrop: "flex-col justify-end", width: "w-full", height: "h-[40%]" };
|
|
66
|
+
animSettings = { x: 0, y: percentage(40, windowSettings.height) };
|
|
67
|
+
break;
|
|
68
|
+
case "right":
|
|
69
|
+
styleSettings = { backdrop: "justify-end", width: "w-[90%]", height: "h-full" };
|
|
70
|
+
animSettings = { x: percentage(90, windowSettings.width), y: 0 };
|
|
71
|
+
break;
|
|
72
|
+
default:
|
|
73
|
+
styleSettings = { backdrop: "justify-start", width: "w-[90%]", height: "h-full" };
|
|
74
|
+
animSettings = { x: -percentage(90, windowSettings.width), y: 0 };
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
100
77
|
}
|
|
101
78
|
function percentage(percent, amount) {
|
|
102
|
-
|
|
79
|
+
return amount / 100 * percent;
|
|
103
80
|
}
|
|
104
|
-
// Input Handlers
|
|
105
81
|
function onBackdropInteraction(event) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
dispatch('backdrop', event);
|
|
82
|
+
if (event.target === elemBackdrop)
|
|
83
|
+
drawerStore.close();
|
|
84
|
+
dispatch("backdrop", event);
|
|
110
85
|
}
|
|
111
86
|
function onKeydownWindow(event) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
87
|
+
if (!$drawerStore)
|
|
88
|
+
return;
|
|
89
|
+
if (event.code === "Escape")
|
|
90
|
+
drawerStore.close();
|
|
116
91
|
}
|
|
117
|
-
// Lifecycle
|
|
118
92
|
onMount(() => {
|
|
119
|
-
|
|
120
|
-
|
|
93
|
+
windowSettings.width = window.innerWidth;
|
|
94
|
+
windowSettings.height = window.innerHeight;
|
|
121
95
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
$:
|
|
125
|
-
|
|
126
|
-
$:
|
|
96
|
+
$:
|
|
97
|
+
classesWidth = width ? width : styleSettings.width;
|
|
98
|
+
$:
|
|
99
|
+
classesHeight = height ? height : styleSettings.height;
|
|
100
|
+
$:
|
|
101
|
+
classesBackdrop = `${cBaseBackdrop} ${styleSettings.backdrop} ${bgBackdrop} ${blur} ${$$props.class ?? ""}`;
|
|
102
|
+
$:
|
|
103
|
+
classesDrawer = `${cBaseDrawer} ${classesWidth} ${classesHeight} ${bgDrawer} ${border} ${margin} ${rounded}`;
|
|
127
104
|
</script>
|
|
128
105
|
|
|
129
106
|
<svelte:window on:keydown={onKeydownWindow} />
|
|
@@ -2,21 +2,34 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
/** Set the anchor position.*/
|
|
5
6
|
position?: "left" | "top" | "right" | "bottom" | undefined;
|
|
7
|
+
/** Define the Svelte transition animation duration.*/
|
|
6
8
|
duration?: number | undefined;
|
|
9
|
+
/** Backdrop - Provide classes to set the backdrop background color*/
|
|
7
10
|
bgBackdrop?: string | undefined;
|
|
11
|
+
/** Backdrop - Provide classes to set the blur style.*/
|
|
8
12
|
blur?: string | undefined;
|
|
13
|
+
/** Drawer - Provide classes to set the drawer background color.*/
|
|
9
14
|
bgDrawer?: string | undefined;
|
|
15
|
+
/** Drawer - Provide classes to set border color.*/
|
|
10
16
|
border?: string | undefined;
|
|
17
|
+
/** Drawer - Provide classes to set border radius.*/
|
|
11
18
|
rounded?: string | undefined;
|
|
19
|
+
/** Drawer - Provide classes to override the width.*/
|
|
12
20
|
width?: string | undefined;
|
|
21
|
+
/** Drawer - Provide classes to override the height.*/
|
|
13
22
|
height?: string | undefined;
|
|
23
|
+
/** Drawer - Provide classes to set margins.*/
|
|
14
24
|
margin?: string | undefined;
|
|
25
|
+
/** Provide an ID of the element labeling the drawer.*/
|
|
15
26
|
labelledby?: string | undefined;
|
|
27
|
+
/** Provide an ID of the element describing the drawer.*/
|
|
16
28
|
describedby?: string | undefined;
|
|
17
29
|
};
|
|
18
30
|
events: {
|
|
19
31
|
keypress: KeyboardEvent;
|
|
32
|
+
/** {{ event }} backdrop - Fires on backdrop interaction.*/
|
|
20
33
|
backdrop: CustomEvent<any>;
|
|
21
34
|
} & {
|
|
22
35
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,67 +1,49 @@
|
|
|
1
1
|
<!-- https://tailwindcss.com/docs/dark-mode -->
|
|
2
|
-
<script>import { createEventDispatcher, onMount } from
|
|
3
|
-
// Event Handler
|
|
2
|
+
<script>import { createEventDispatcher, onMount } from "svelte";
|
|
4
3
|
const dispatch = createEventDispatcher();
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const cThumb = 'bg-white dark:bg-black fill-white dark:fill-black w-6 h-6 flex justify-center items-center rounded-full shadow-lg transition-all duration-[100ms] scale-90';
|
|
10
|
-
const cIcon = 'block w-4 h-4';
|
|
11
|
-
// Set the users system prefers for light/dark mode
|
|
4
|
+
import { storePrefersDarkScheme, storeLightSwitch } from "./stores";
|
|
5
|
+
const cTrack = "inline-block bg-surface-200-700-token ring-[1px] ring-surface-300-600-token ring-inset w-12 h-6 rounded-full cursor-pointer transition-all duration-[100ms]";
|
|
6
|
+
const cThumb = "bg-white dark:bg-black fill-white dark:fill-black w-6 h-6 flex justify-center items-center rounded-full shadow-lg transition-all duration-[100ms] scale-90";
|
|
7
|
+
const cIcon = "block w-4 h-4";
|
|
12
8
|
function setPrefersDarkScheme() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
9
|
+
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
10
|
+
storePrefersDarkScheme.set(prefersDark);
|
|
11
|
+
if ($storeLightSwitch === void 0) {
|
|
12
|
+
$storeLightSwitch = $storePrefersDarkScheme;
|
|
13
|
+
}
|
|
19
14
|
}
|
|
20
|
-
// Toggles a 'dark' class on the <html> element
|
|
21
15
|
function setElemHtmlClass() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
$storeLightSwitch ? elemHtmlClassList.add('dark') : elemHtmlClassList.remove('dark');
|
|
16
|
+
const elemHtmlClassList = document.documentElement.classList;
|
|
17
|
+
$storeLightSwitch ? elemHtmlClassList.add("dark") : elemHtmlClassList.remove("dark");
|
|
25
18
|
}
|
|
26
|
-
// Sets the color scheme based on localStorage or OS preference in
|
|
27
|
-
// the <head> of the document.
|
|
28
19
|
function setColorScheme() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
document.documentElement.classList.remove('dark');
|
|
35
|
-
}
|
|
20
|
+
if (localStorage.getItem("storeLightSwitch") === "true" || !("storeLightSwitch" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
21
|
+
document.documentElement.classList.add("dark");
|
|
22
|
+
} else {
|
|
23
|
+
document.documentElement.classList.remove("dark");
|
|
24
|
+
}
|
|
36
25
|
}
|
|
37
|
-
// On Click Handler
|
|
38
26
|
function onClick(event) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
setElemHtmlClass();
|
|
43
|
-
/** @event {{ event }} click - Fires when the component is clicked. */
|
|
44
|
-
dispatch('click', event);
|
|
27
|
+
storeLightSwitch.set($storeLightSwitch = !$storeLightSwitch);
|
|
28
|
+
setElemHtmlClass();
|
|
29
|
+
dispatch("click", event);
|
|
45
30
|
}
|
|
46
|
-
// A11y Input Handlers
|
|
47
31
|
function onKeyDown(event) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/** @event {{ event }} keydown - Fires when the component has keydown event. */
|
|
54
|
-
dispatch('keydown', event);
|
|
32
|
+
if (["Enter", "Space"].includes(event.code)) {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
event.currentTarget.click();
|
|
35
|
+
}
|
|
36
|
+
dispatch("keydown", event);
|
|
55
37
|
}
|
|
56
|
-
// Lifecycle
|
|
57
38
|
onMount(() => {
|
|
58
|
-
|
|
59
|
-
setPrefersDarkScheme();
|
|
39
|
+
setPrefersDarkScheme();
|
|
60
40
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
$:
|
|
64
|
-
|
|
41
|
+
$:
|
|
42
|
+
classesPosition = $storeLightSwitch ? "translate-x-full" : "translate-x-0";
|
|
43
|
+
$:
|
|
44
|
+
classesBase = `${cTrack} ${$$props.class ?? ""}`;
|
|
45
|
+
$:
|
|
46
|
+
classesThumb = `${cThumb} ${classesPosition}`;
|
|
65
47
|
</script>
|
|
66
48
|
|
|
67
49
|
<svelte:head>
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
-
[x: string]:
|
|
4
|
+
[x: string]: any;
|
|
5
5
|
};
|
|
6
6
|
events: {
|
|
7
7
|
keyup: KeyboardEvent;
|
|
8
8
|
keypress: KeyboardEvent;
|
|
9
|
+
/** {{ event }} click - Fires when the component is clicked.*/
|
|
9
10
|
click: CustomEvent<any>;
|
|
11
|
+
/** {{ event }} keydown - Fires when the component has keydown event.*/
|
|
10
12
|
keydown: CustomEvent<any>;
|
|
11
13
|
} & {
|
|
12
14
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,108 +1,76 @@
|
|
|
1
|
-
<script>import { createEventDispatcher } from
|
|
2
|
-
import { fade, fly } from
|
|
3
|
-
// Event Handler
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { fade, fly } from "svelte/transition";
|
|
4
3
|
const dispatch = createEventDispatcher();
|
|
5
|
-
import { focusTrap } from
|
|
6
|
-
import { modalStore } from
|
|
7
|
-
// Props
|
|
8
|
-
/** The open/close animation duration. Set '0' (zero) to disable. */
|
|
4
|
+
import { focusTrap } from "../../actions/FocusTrap/focusTrap";
|
|
5
|
+
import { modalStore } from "./stores";
|
|
9
6
|
export let duration = 150;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export let
|
|
13
|
-
|
|
14
|
-
export let
|
|
15
|
-
|
|
16
|
-
export let
|
|
17
|
-
|
|
18
|
-
export let
|
|
19
|
-
|
|
20
|
-
export let
|
|
21
|
-
|
|
22
|
-
export let
|
|
23
|
-
|
|
24
|
-
export let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export let buttonPositive = 'btn-filled-primary';
|
|
30
|
-
/** Override the text for the Cancel button. */
|
|
31
|
-
export let buttonTextCancel = 'Cancel';
|
|
32
|
-
/** Override the text for the Confirm button. */
|
|
33
|
-
export let buttonTextConfirm = 'Confirm';
|
|
34
|
-
/** Override the text for the Submit button. */
|
|
35
|
-
export let buttonTextSubmit = 'Submit';
|
|
36
|
-
// Props (regions)
|
|
37
|
-
/** Provide classes to style the backdrop. */
|
|
38
|
-
export let regionBackdrop = 'bg-surface-backdrop-token';
|
|
39
|
-
/** Provide arbitrary classes to modal header region. */
|
|
40
|
-
export let regionHeader = 'text-2xl font-bold';
|
|
41
|
-
/** Provide arbitrary classes to modal body region. */
|
|
42
|
-
export let regionBody = 'max-h-[200px] overflow-hidden';
|
|
43
|
-
/** Provide arbitrary classes to modal footer region. */
|
|
44
|
-
export let regionFooter = 'flex justify-end space-x-2';
|
|
45
|
-
// Base Styles
|
|
46
|
-
const cBackdrop = 'fixed top-0 left-0 right-0 bottom-0 z-[999] flex justify-center items-center p-4';
|
|
47
|
-
const cModal = 'max-h-full overflow-y-auto overflow-x-hidden';
|
|
48
|
-
const cModalImage = 'w-full h-auto';
|
|
49
|
-
// Local
|
|
7
|
+
export let background = "bg-surface-100-800-token";
|
|
8
|
+
export let width = "w-full max-w-[640px]";
|
|
9
|
+
export let height = "h-auto";
|
|
10
|
+
export let padding = "p-4";
|
|
11
|
+
export let spacing = "space-y-4";
|
|
12
|
+
export let rounded = "rounded-container-token";
|
|
13
|
+
export let shadow = "shadow-xl";
|
|
14
|
+
export let buttonNeutral = "variant-ghost-surface";
|
|
15
|
+
export let buttonPositive = "variant-filled-primary";
|
|
16
|
+
export let buttonTextCancel = "Cancel";
|
|
17
|
+
export let buttonTextConfirm = "Confirm";
|
|
18
|
+
export let buttonTextSubmit = "Submit";
|
|
19
|
+
export let regionBackdrop = "bg-surface-backdrop-token";
|
|
20
|
+
export let regionHeader = "text-2xl font-bold";
|
|
21
|
+
export let regionBody = "max-h-[200px] overflow-hidden";
|
|
22
|
+
export let regionFooter = "flex justify-end space-x-2";
|
|
23
|
+
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0 z-[999] flex justify-center items-center p-4";
|
|
24
|
+
const cModal = "max-h-full overflow-y-auto overflow-x-hidden";
|
|
25
|
+
const cModalImage = "w-full h-auto";
|
|
50
26
|
let promptValue;
|
|
51
27
|
const buttonTextDefaults = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
28
|
+
buttonTextCancel,
|
|
29
|
+
buttonTextConfirm,
|
|
30
|
+
buttonTextSubmit
|
|
55
31
|
};
|
|
56
|
-
// Modal Store Subscription
|
|
57
32
|
modalStore.subscribe((dArr) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
buttonTextConfirm = dArr[0].buttonTextConfirm || buttonTextDefaults.buttonTextConfirm;
|
|
65
|
-
buttonTextSubmit = dArr[0].buttonTextSubmit || buttonTextDefaults.buttonTextSubmit;
|
|
33
|
+
if (!dArr.length)
|
|
34
|
+
return;
|
|
35
|
+
promptValue = dArr[0].value;
|
|
36
|
+
buttonTextCancel = dArr[0].buttonTextCancel || buttonTextDefaults.buttonTextCancel;
|
|
37
|
+
buttonTextConfirm = dArr[0].buttonTextConfirm || buttonTextDefaults.buttonTextConfirm;
|
|
38
|
+
buttonTextSubmit = dArr[0].buttonTextSubmit || buttonTextDefaults.buttonTextSubmit;
|
|
66
39
|
});
|
|
67
|
-
// Event Handlers ---
|
|
68
40
|
function onBackdropInteraction(event) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
dispatch('backdrop', event);
|
|
41
|
+
if (!(event.target instanceof Element))
|
|
42
|
+
return;
|
|
43
|
+
if (event.target.classList.contains("modal-backdrop"))
|
|
44
|
+
onClose();
|
|
45
|
+
dispatch("backdrop", event);
|
|
75
46
|
}
|
|
76
47
|
function onClose() {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
48
|
+
if ($modalStore[0].response)
|
|
49
|
+
$modalStore[0].response(false);
|
|
50
|
+
modalStore.close();
|
|
80
51
|
}
|
|
81
52
|
function onConfirm() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
53
|
+
if ($modalStore[0].response)
|
|
54
|
+
$modalStore[0].response(true);
|
|
55
|
+
modalStore.close();
|
|
85
56
|
}
|
|
86
57
|
function onPromptSubmit() {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
58
|
+
if ($modalStore[0].response)
|
|
59
|
+
$modalStore[0].response(promptValue);
|
|
60
|
+
modalStore.close();
|
|
90
61
|
}
|
|
91
|
-
// A11y ---
|
|
92
62
|
function onKeyDown(event) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
63
|
+
if (!$modalStore.length)
|
|
64
|
+
return;
|
|
65
|
+
if (event.code === "Escape")
|
|
66
|
+
onClose();
|
|
97
67
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
$:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// Source: https://discord.com/channels/457912077277855764/1037768846855118909
|
|
105
|
-
$: parent = {
|
|
68
|
+
$:
|
|
69
|
+
classesBackdrop = `${cBackdrop} ${regionBackdrop} ${$$props.class || ""}`;
|
|
70
|
+
$:
|
|
71
|
+
classesModal = `${cModal} ${background} ${width} ${height} ${padding} ${spacing} ${rounded} ${shadow}`;
|
|
72
|
+
$:
|
|
73
|
+
parent = {
|
|
106
74
|
background,
|
|
107
75
|
width,
|
|
108
76
|
height,
|
|
@@ -110,20 +78,17 @@ $: parent = {
|
|
|
110
78
|
spacing,
|
|
111
79
|
rounded,
|
|
112
80
|
shadow,
|
|
113
|
-
// ---
|
|
114
81
|
buttonNeutral,
|
|
115
82
|
buttonPositive,
|
|
116
83
|
buttonTextCancel,
|
|
117
84
|
buttonTextConfirm,
|
|
118
85
|
buttonTextSubmit,
|
|
119
|
-
// ---
|
|
120
86
|
regionBackdrop,
|
|
121
87
|
regionHeader,
|
|
122
88
|
regionBody,
|
|
123
89
|
regionFooter,
|
|
124
|
-
// ---
|
|
125
90
|
onClose
|
|
126
|
-
};
|
|
91
|
+
};
|
|
127
92
|
</script>
|
|
128
93
|
|
|
129
94
|
<svelte:window on:keydown={onKeyDown} />
|
|
@@ -176,7 +141,7 @@ $: parent = {
|
|
|
176
141
|
</footer>
|
|
177
142
|
{:else if $modalStore[0].type === 'prompt'}
|
|
178
143
|
<!-- Template: Prompt -->
|
|
179
|
-
<input class="modal-prompt-input" type="text" bind:value={promptValue} />
|
|
144
|
+
<input class="modal-prompt-input input" type="text" bind:value={promptValue} />
|
|
180
145
|
<!-- prettier-ignore -->
|
|
181
146
|
<footer class="modal-footer {regionFooter}">
|
|
182
147
|
<button class="btn {buttonNeutral}" on:click={onClose}>{buttonTextCancel}</button>
|
|
@@ -2,25 +2,43 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
/** The open/close animation duration. Set '0' (zero) to disable.*/
|
|
5
6
|
duration?: number | undefined;
|
|
7
|
+
/** Provide classes to style the modal background.*/
|
|
6
8
|
background?: string | undefined;
|
|
9
|
+
/** Provide classes to style the modal width.*/
|
|
7
10
|
width?: string | undefined;
|
|
11
|
+
/** Provide classes to style the modal.*/
|
|
8
12
|
height?: string | undefined;
|
|
13
|
+
/** Provide classes to style the modal padding.*/
|
|
9
14
|
padding?: string | undefined;
|
|
15
|
+
/** Provide classes to style the modal spacing.*/
|
|
10
16
|
spacing?: string | undefined;
|
|
17
|
+
/** Provide classes to style the modal border radius.*/
|
|
11
18
|
rounded?: string | undefined;
|
|
19
|
+
/** Provide classes to style modal box shadow.*/
|
|
12
20
|
shadow?: string | undefined;
|
|
21
|
+
/** Provide classes for neutral buttons, such as Cancel.*/
|
|
13
22
|
buttonNeutral?: string | undefined;
|
|
23
|
+
/** Provide classes for positive actions, such as Confirm or Submit.*/
|
|
14
24
|
buttonPositive?: string | undefined;
|
|
25
|
+
/** Override the text for the Cancel button.*/
|
|
15
26
|
buttonTextCancel?: string | undefined;
|
|
27
|
+
/** Override the text for the Confirm button.*/
|
|
16
28
|
buttonTextConfirm?: string | undefined;
|
|
29
|
+
/** Override the text for the Submit button.*/
|
|
17
30
|
buttonTextSubmit?: string | undefined;
|
|
31
|
+
/** Provide classes to style the backdrop.*/
|
|
18
32
|
regionBackdrop?: string | undefined;
|
|
33
|
+
/** Provide arbitrary classes to modal header region.*/
|
|
19
34
|
regionHeader?: string | undefined;
|
|
35
|
+
/** Provide arbitrary classes to modal body region.*/
|
|
20
36
|
regionBody?: string | undefined;
|
|
37
|
+
/** Provide arbitrary classes to modal footer region.*/
|
|
21
38
|
regionFooter?: string | undefined;
|
|
22
39
|
};
|
|
23
40
|
events: {
|
|
41
|
+
/** {{ event }} backdrop - Fires on backdrop interaction.*/
|
|
24
42
|
backdrop: CustomEvent<any>;
|
|
25
43
|
} & {
|
|
26
44
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
export let parent;
|
|
4
|
-
// Base Classes
|
|
5
|
-
const cBase = 'relative';
|
|
1
|
+
<script>export let parent;
|
|
2
|
+
const cBase = "relative";
|
|
6
3
|
</script>
|
|
7
4
|
|
|
8
5
|
<!-- @component This example creates an embedded video modal. -->
|
|
9
6
|
|
|
10
7
|
<div class="modal-example-form {cBase}">
|
|
11
|
-
<button class="absolute -top-4 -right-4 z-1 btn-icon
|
|
8
|
+
<button class="absolute -top-4 -right-4 z-1 btn-icon variant-filled" on:click={parent.onClose}>✕</button>
|
|
12
9
|
<iframe
|
|
13
10
|
class="w-full aspect-video rounded-container-token overflow-hidden"
|
|
14
11
|
src="https://www.youtube.com/embed/vOGhAV-84iI"
|