@skeletonlabs/skeleton 0.124.2 → 0.132.4
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 +1 -1
- package/components/Accordion/Accordion.svelte +4 -0
- package/components/Accordion/Accordion.svelte.d.ts +4 -0
- package/components/Accordion/AccordionItem.svelte +14 -5
- package/components/Accordion/AccordionItem.svelte.d.ts +4 -1
- package/components/ConicGradient/settings.d.ts +0 -2
- package/components/ConicGradient/settings.js +0 -1
- package/components/FileButton/FileButton.svelte +1 -1
- package/components/FileDropzone/FileDropzone.svelte +1 -1
- package/components/InputChip/InputChip.svelte +3 -3
- package/components/ListBox/ListBoxItem.svelte +3 -3
- package/components/ListBox/ListBoxItem.svelte.d.ts +2 -1
- package/components/Paginator/Paginator.svelte +3 -3
- package/components/Radio/RadioItem.svelte +2 -2
- package/components/Radio/RadioItem.svelte.d.ts +2 -1
- package/components/RangeSlider/RangeSlider.svelte.d.ts +4 -4
- package/components/Stepper/Step.svelte +3 -3
- package/components/Tab/Tab.svelte +2 -2
- package/components/Tab/Tab.svelte.d.ts +2 -1
- package/index.d.ts +3 -3
- package/index.js +9 -3
- package/package.json +10 -11
- package/styles/elements/forms.css +5 -9
- package/styles/elements/modals.css +15 -0
- package/styles/elements/popups.css +16 -0
- package/styles/elements.css +2 -2
- package/styles/typography.css +3 -3
- package/tailwind/core.cjs +1 -1
- package/tailwind/generated/intellisense-classes.cjs +1 -1
- package/tailwind/generated/intellisense-classes.d.cts +65 -208
- package/tailwind/intellisense.cjs +2 -2
- package/tailwind/skeleton.cjs +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/tailwind.d.ts +4 -0
- package/types/tailwind.js +2 -0
- package/utilities/CodeBlock/CodeBlock.svelte +12 -8
- package/utilities/CodeBlock/CodeBlock.svelte.d.ts +9 -1
- package/utilities/Drawer/Drawer.svelte +50 -37
- package/utilities/Drawer/Drawer.svelte.d.ts +8 -2
- package/utilities/Drawer/types.d.ts +8 -2
- package/utilities/LightSwitch/LightSwitch.svelte +43 -53
- package/utilities/LightSwitch/LightSwitch.svelte.d.ts +18 -4
- package/utilities/LightSwitch/lightswitch.d.ts +20 -0
- package/utilities/LightSwitch/lightswitch.js +71 -0
- package/utilities/LocalStorageStore/LocalStorageStore.js +1 -1
- package/utilities/Modal/Modal.svelte +96 -64
- package/utilities/Modal/Modal.svelte.d.ts +11 -0
- package/utilities/Modal/types.d.ts +9 -5
- package/utilities/Popup/popup.d.ts +7 -0
- package/utilities/Popup/popup.js +218 -0
- package/utilities/Popup/types.d.ts +32 -0
- package/utilities/Popup/types.js +3 -0
- package/utilities/Toast/Toast.svelte +17 -13
- package/utilities/Toast/Toast.svelte.d.ts +5 -3
- package/utilities/Toast/stores.js +9 -26
- package/utilities/Toast/types.d.ts +6 -1
- package/styles/elements/menus.css +0 -29
- package/styles/elements/tooltips.css +0 -83
- package/utilities/LightSwitch/stores.d.ts +0 -2
- package/utilities/LightSwitch/stores.js +0 -5
- package/utilities/Menu/menu.d.ts +0 -18
- package/utilities/Menu/menu.js +0 -151
- package/utilities/Modal/examples/ModalExampleEmbed.svelte +0 -17
- package/utilities/Modal/examples/ModalExampleEmbed.svelte.d.ts +0 -17
- package/utilities/Modal/examples/ModalExampleForm.svelte +0 -41
- package/utilities/Modal/examples/ModalExampleForm.svelte.d.ts +0 -17
- package/utilities/Modal/examples/ModalExampleImage.svelte +0 -19
- package/utilities/Modal/examples/ModalExampleImage.svelte.d.ts +0 -16
- package/utilities/Modal/examples/ModalExampleList.svelte +0 -26
- package/utilities/Modal/examples/ModalExampleList.svelte.d.ts +0 -17
- package/utilities/Tooltip/tooltip.d.ts +0 -35
- package/utilities/Tooltip/tooltip.js +0 -94
|
@@ -21,33 +21,11 @@ function toastService() {
|
|
|
21
21
|
/** Add a new toast to the queue. */
|
|
22
22
|
trigger: (toast) => update((tStore) => {
|
|
23
23
|
const id = randomUUID();
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
switch (toast.preset) {
|
|
28
|
-
// Success/Error
|
|
29
|
-
// IMPORTANT: use full class names here. Do not construct the classes.
|
|
30
|
-
case ('primary'):
|
|
31
|
-
classes += '!bg-primary-500 text-on-primary-token';
|
|
32
|
-
break;
|
|
33
|
-
case ('secondary'):
|
|
34
|
-
classes += '!bg-secondary-500 text-on-secondary-token';
|
|
35
|
-
break;
|
|
36
|
-
case ('tertiary'):
|
|
37
|
-
classes += '!bg-tertiary-500 text-on-tertiary-token';
|
|
38
|
-
break;
|
|
39
|
-
case ('success'):
|
|
40
|
-
classes += '!bg-success-500 text-on-success-token';
|
|
41
|
-
break;
|
|
42
|
-
case ('warning'):
|
|
43
|
-
classes += '!bg-warning-500 text-on-warning-token';
|
|
44
|
-
break;
|
|
45
|
-
case ('error'):
|
|
46
|
-
classes += '!bg-error-500 text-on-error-token';
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
24
|
+
// Trigger Callback
|
|
25
|
+
if (toast && toast.callback)
|
|
26
|
+
toast.callback({ id, status: 'queued' });
|
|
49
27
|
// Merge into store
|
|
50
|
-
const tMerged = { ...toastDefaults, ...toast, id
|
|
28
|
+
const tMerged = { ...toastDefaults, ...toast, id };
|
|
51
29
|
tStore.push(tMerged);
|
|
52
30
|
// Handle auto-hide, if needed
|
|
53
31
|
handleAutoHide(tMerged);
|
|
@@ -58,6 +36,11 @@ function toastService() {
|
|
|
58
36
|
close: (id) => update((tStore) => {
|
|
59
37
|
if (tStore.length > 0) {
|
|
60
38
|
const index = tStore.findIndex((t) => t.id === id);
|
|
39
|
+
// Trigger Callback
|
|
40
|
+
const selectedToast = tStore[index];
|
|
41
|
+
if (selectedToast && selectedToast.callback)
|
|
42
|
+
selectedToast.callback({ id, status: 'closed' });
|
|
43
|
+
// Remove
|
|
61
44
|
tStore.splice(index, 1);
|
|
62
45
|
}
|
|
63
46
|
return tStore;
|
|
@@ -5,7 +5,7 @@ export interface ToastSettings {
|
|
|
5
5
|
* Applies a canned set of styles.
|
|
6
6
|
* @type {'primary' | 'secondary' | 'tertiary' | 'warning' | 'success' | 'error'}
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
background?: string;
|
|
9
9
|
/** Enables auto-hide after the timeout duration. */
|
|
10
10
|
autohide?: boolean;
|
|
11
11
|
/** Set the auto-hide timeout duration. */
|
|
@@ -19,6 +19,11 @@ export interface ToastSettings {
|
|
|
19
19
|
};
|
|
20
20
|
/** Provide arbitrary CSS classes to style the toast. */
|
|
21
21
|
classes?: string;
|
|
22
|
+
/** Callback function that fires on trigger and close. */
|
|
23
|
+
callback?: (response: {
|
|
24
|
+
id: string;
|
|
25
|
+
status: 'queued' | 'closed';
|
|
26
|
+
}) => void;
|
|
22
27
|
}
|
|
23
28
|
export interface Toast extends ToastSettings {
|
|
24
29
|
/** A UUID will be auto-assigned on `.trigger()`. */
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/* Tailwind Elements: menus.css */
|
|
2
|
-
|
|
3
|
-
[data-menu] {
|
|
4
|
-
@apply absolute z-20 hidden;
|
|
5
|
-
}
|
|
6
|
-
[data-menu] a {
|
|
7
|
-
@apply focus-visible:bg-primary-500/10;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
:root {
|
|
11
|
-
--menu-offset: 8px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@layer components {
|
|
15
|
-
/* === Origins === */
|
|
16
|
-
|
|
17
|
-
.menu-tl {
|
|
18
|
-
@apply mt-[var(--menu-offset)] left-0 origin-top-left;
|
|
19
|
-
}
|
|
20
|
-
.menu-tr {
|
|
21
|
-
@apply mt-[var(--menu-offset)] right-0 origin-top-right;
|
|
22
|
-
}
|
|
23
|
-
.menu-bl {
|
|
24
|
-
@apply top-0 left-0 origin-bottom-left -translate-y-[calc(100%+var(--menu-offset))];
|
|
25
|
-
}
|
|
26
|
-
.menu-br {
|
|
27
|
-
@apply top-0 right-0 origin-bottom-right -translate-y-[calc(100%+var(--menu-offset))];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/* Tailwind Elements: tooltips.css */
|
|
2
|
-
|
|
3
|
-
/* FIXME: adding @layer components causes visual strobing effect bug */
|
|
4
|
-
|
|
5
|
-
:root {
|
|
6
|
-
--tooltip-offset: 8px;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.tooltip {
|
|
10
|
-
@apply text-center origin-center absolute z-[45] opacity-0 transition-opacity duration-150;
|
|
11
|
-
/* Base Design */
|
|
12
|
-
@apply bg-primary-500 w-48 p-2 shadow-xl;
|
|
13
|
-
/* Theme: Rounded */
|
|
14
|
-
@apply rounded-container-token;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/* === Positions === */
|
|
18
|
-
/* Set based on the action param 'position' */
|
|
19
|
-
|
|
20
|
-
.tooltip-top {
|
|
21
|
-
@apply top-0;
|
|
22
|
-
/* Center Horz */
|
|
23
|
-
@apply left-[50%] -translate-x-[50%];
|
|
24
|
-
/* Offset Y */
|
|
25
|
-
@apply -translate-y-[calc(100%+var(--tooltip-offset))];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.tooltip-bottom {
|
|
29
|
-
@apply bottom-0;
|
|
30
|
-
/* Center Horz */
|
|
31
|
-
@apply left-[50%] -translate-x-[50%];
|
|
32
|
-
/* Offset Y */
|
|
33
|
-
@apply translate-y-[calc(100%+var(--tooltip-offset))];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.tooltip-left {
|
|
37
|
-
@apply left-0;
|
|
38
|
-
/* Center Vert */
|
|
39
|
-
@apply top-[50%] -translate-y-[50%];
|
|
40
|
-
/* Offset X */
|
|
41
|
-
@apply -translate-x-[calc(100%+var(--tooltip-offset))];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.tooltip-right {
|
|
45
|
-
@apply right-0;
|
|
46
|
-
/* Center Vert */
|
|
47
|
-
@apply top-[50%] -translate-y-[50%];
|
|
48
|
-
/* Offset X */
|
|
49
|
-
@apply translate-x-[calc(100%+var(--tooltip-offset))];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/* === Arrow === */
|
|
53
|
-
/* Set based on the action param 'position' */
|
|
54
|
-
|
|
55
|
-
.tooltip-arrow {
|
|
56
|
-
@apply absolute h-2 w-2 -rotate-45 origin-center;
|
|
57
|
-
/* Base Design */
|
|
58
|
-
@apply bg-primary-500;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.tooltip-arrow-top {
|
|
62
|
-
@apply tooltip-arrow;
|
|
63
|
-
/* Bottom side, center horz */
|
|
64
|
-
@apply bottom-0 left-0 right-0 mx-auto translate-y-[50%];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.tooltip-arrow-bottom {
|
|
68
|
-
@apply tooltip-arrow;
|
|
69
|
-
/* Top side, centered horz */
|
|
70
|
-
@apply top-0 left-0 right-0 mx-auto translate-y-[-50%];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.tooltip-arrow-left {
|
|
74
|
-
@apply tooltip-arrow;
|
|
75
|
-
/* Right size, centered vert */
|
|
76
|
-
@apply top-0 bottom-0 right-0 my-auto translate-x-[50%];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.tooltip-arrow-right {
|
|
80
|
-
@apply tooltip-arrow;
|
|
81
|
-
/* Left size, centered vert */
|
|
82
|
-
@apply top-0 bottom-0 left-0 my-auto translate-x-[-50%];
|
|
83
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { localStorageStore } from '../LocalStorageStore/LocalStorageStore';
|
|
2
|
-
// OS Prefers Dark Scheme - TRUE: dark | FALSE: light
|
|
3
|
-
export const storePrefersDarkScheme = localStorageStore('storePrefersDarkScheme', false);
|
|
4
|
-
// User Selected Mode - TRUE: dark | FALSE: light | undefined: use system preference
|
|
5
|
-
export const storeLightSwitch = localStorageStore('storeLightSwitch', undefined);
|
package/utilities/Menu/menu.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
interface ArgsMenu {
|
|
2
|
-
/** The value of 'x' from data-menu-[x] */
|
|
3
|
-
menu: string;
|
|
4
|
-
/** Origin - TRUE: fixed | FALSE: auto */
|
|
5
|
-
fixed?: boolean;
|
|
6
|
-
/** Clicks inside body will not close window */
|
|
7
|
-
interactive?: boolean;
|
|
8
|
-
/** Provide an optional callback function to handle open/close state changes. */
|
|
9
|
-
state?: (e: {
|
|
10
|
-
menu: string;
|
|
11
|
-
state: boolean;
|
|
12
|
-
}) => void;
|
|
13
|
-
}
|
|
14
|
-
export declare function menu(node: HTMLElement, args: ArgsMenu): {
|
|
15
|
-
update: (newArgs: ArgsMenu) => void;
|
|
16
|
-
destroy: () => void;
|
|
17
|
-
} | undefined;
|
|
18
|
-
export {};
|
package/utilities/Menu/menu.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
// Action: Menu
|
|
2
|
-
// https://svelte.dev/repl/0ace7a508bd843b798ae599940a91783?version=3.16.7
|
|
3
|
-
// prettier-ignore
|
|
4
|
-
export function menu(node, args) {
|
|
5
|
-
const elemMenu = document.querySelector(`[data-menu="${args.menu}"]`);
|
|
6
|
-
if (!elemMenu)
|
|
7
|
-
return;
|
|
8
|
-
const elemWhitelist = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])';
|
|
9
|
-
let activeFocusIdx;
|
|
10
|
-
let focusableElems;
|
|
11
|
-
const onInit = () => {
|
|
12
|
-
autoUpdateOrigin();
|
|
13
|
-
// Apply a11y attributes
|
|
14
|
-
elemMenu.setAttribute('role', 'menu');
|
|
15
|
-
};
|
|
16
|
-
// Menu States ---
|
|
17
|
-
const menuOpen = (openWithFocus = false) => {
|
|
18
|
-
elemMenu.style.display = 'block';
|
|
19
|
-
stateEventHandler(true);
|
|
20
|
-
// Create array of all focusable elements, so that we can iterate through them
|
|
21
|
-
focusableElems = Array.from(elemMenu.querySelectorAll(elemWhitelist));
|
|
22
|
-
// reset the focus index
|
|
23
|
-
activeFocusIdx = -1;
|
|
24
|
-
if (openWithFocus) {
|
|
25
|
-
// Automatically focus the element if openWithFocus is true (for example if
|
|
26
|
-
// the menu was opened with Enter instead of with a click
|
|
27
|
-
activeFocusIdx = 0;
|
|
28
|
-
focusableElems[0]?.focus();
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const menuClose = () => {
|
|
32
|
-
elemMenu.style.display = 'none';
|
|
33
|
-
stateEventHandler(false);
|
|
34
|
-
};
|
|
35
|
-
const stateEventHandler = (state) => {
|
|
36
|
-
if (args.state)
|
|
37
|
-
args.state({ menu: args.menu, state });
|
|
38
|
-
};
|
|
39
|
-
// Click Handlers ---
|
|
40
|
-
const toggleMenu = () => {
|
|
41
|
-
// When the node is clicked, open the menu if it is closed, otherwise close it
|
|
42
|
-
if (elemMenu.style.display != 'block') {
|
|
43
|
-
autoUpdateOrigin();
|
|
44
|
-
menuOpen();
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
menuClose();
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
const onWindowClick = (event) => {
|
|
51
|
-
args.interactive === true ? interactiveClickHandler(event) : standardClickHandler(event);
|
|
52
|
-
};
|
|
53
|
-
// Interactive FALSE - any click closes the menu
|
|
54
|
-
const standardClickHandler = (event) => {
|
|
55
|
-
// Any click outside the node closes the menu, but a click inside the node toggles the menu.
|
|
56
|
-
const outsideNode = node && !node.contains(event.target);
|
|
57
|
-
if (outsideNode) {
|
|
58
|
-
menuClose();
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
toggleMenu();
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
// Interactive TRUE - clicks outside close menu
|
|
65
|
-
const interactiveClickHandler = (event) => {
|
|
66
|
-
const outsideNode = node && !node.contains(event.target);
|
|
67
|
-
const outsideMenu = elemMenu && !elemMenu.contains(event.target);
|
|
68
|
-
if (!outsideNode) {
|
|
69
|
-
toggleMenu();
|
|
70
|
-
}
|
|
71
|
-
else if (outsideNode && outsideMenu) {
|
|
72
|
-
menuClose();
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
// Menu - Set auto origin ---
|
|
76
|
-
const autoUpdateOrigin = () => {
|
|
77
|
-
if (!args.fixed && !elemMenu.classList.contains('hidden')) {
|
|
78
|
-
// Get the Menu's bounds
|
|
79
|
-
const elemTriggerBounds = node.getBoundingClientRect();
|
|
80
|
-
// Determine vertical and horizontal values
|
|
81
|
-
const vert = elemTriggerBounds.y < window.innerHeight / 2 ? 't' : 'b'; // top/bottom
|
|
82
|
-
const horz = elemTriggerBounds.x < window.innerWidth / 2 ? 'l' : 'r'; // left/right
|
|
83
|
-
// Strip and apply only the relevant class
|
|
84
|
-
elemMenu.classList.remove('menu-tl', 'menu-tr', 'menu-bl', 'menu-br');
|
|
85
|
-
elemMenu.classList.add(`menu-${vert}${horz}`);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
// A11y Input Handlers ---
|
|
89
|
-
const onTriggerKeyDown = (event) => {
|
|
90
|
-
const key = event.key;
|
|
91
|
-
if (key === 'Enter' || key === 'Space') {
|
|
92
|
-
event.preventDefault();
|
|
93
|
-
// Toggle menu
|
|
94
|
-
toggleMenu();
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const onWindowKeyDown = (event) => {
|
|
98
|
-
const key = event.key;
|
|
99
|
-
if (elemMenu.style.display === 'none')
|
|
100
|
-
return;
|
|
101
|
-
if (key === 'Escape' || key === 'Tab') {
|
|
102
|
-
// Close the menu
|
|
103
|
-
event.preventDefault();
|
|
104
|
-
menuClose();
|
|
105
|
-
node.focus();
|
|
106
|
-
}
|
|
107
|
-
else if (key === 'ArrowDown') {
|
|
108
|
-
event.preventDefault();
|
|
109
|
-
if (activeFocusIdx < focusableElems.length - 1) {
|
|
110
|
-
// Move down the menu
|
|
111
|
-
activeFocusIdx += 1;
|
|
112
|
-
focusableElems[activeFocusIdx]?.focus();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else if (key === 'ArrowUp') {
|
|
116
|
-
event.preventDefault();
|
|
117
|
-
if (activeFocusIdx > 0) {
|
|
118
|
-
// Move up the menu
|
|
119
|
-
activeFocusIdx -= 1;
|
|
120
|
-
focusableElems[activeFocusIdx]?.focus();
|
|
121
|
-
}
|
|
122
|
-
else if (focusableElems.length && activeFocusIdx === -1) {
|
|
123
|
-
// Start at the bottom of the menu if first key is arrow up key
|
|
124
|
-
event.preventDefault();
|
|
125
|
-
activeFocusIdx = focusableElems.length - 1;
|
|
126
|
-
focusableElems[activeFocusIdx]?.focus();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
// On Action Init
|
|
131
|
-
onInit();
|
|
132
|
-
// Window Events
|
|
133
|
-
window.addEventListener('resize', autoUpdateOrigin, true);
|
|
134
|
-
window.addEventListener('click', onWindowClick, true);
|
|
135
|
-
window.addEventListener('keydown', onWindowKeyDown, true);
|
|
136
|
-
// Trigger Node Events
|
|
137
|
-
node.addEventListener('keydown', onTriggerKeyDown);
|
|
138
|
-
node.addEventListener('change', (e) => {
|
|
139
|
-
console.log(e);
|
|
140
|
-
});
|
|
141
|
-
// Lifecycle
|
|
142
|
-
return {
|
|
143
|
-
update: (newArgs) => { args = newArgs; },
|
|
144
|
-
destroy: () => {
|
|
145
|
-
window.removeEventListener('resize', onWindowClick, true);
|
|
146
|
-
window.removeEventListener('click', onWindowClick, true);
|
|
147
|
-
window.removeEventListener('keydown', onWindowKeyDown, true);
|
|
148
|
-
node.removeEventListener('keydown', onTriggerKeyDown);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<script>export let parent;
|
|
2
|
-
const cBase = "relative";
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<!-- @component This example creates an embedded video modal. -->
|
|
6
|
-
|
|
7
|
-
<div class="modal-example-form {cBase}">
|
|
8
|
-
<button class="absolute -top-4 -right-4 z-1 btn-icon variant-filled" on:click={parent.onClose}>✕</button>
|
|
9
|
-
<iframe
|
|
10
|
-
class="w-full aspect-video rounded-container-token overflow-hidden"
|
|
11
|
-
src="https://www.youtube.com/embed/vOGhAV-84iI"
|
|
12
|
-
title="YouTube video player"
|
|
13
|
-
frameborder="0"
|
|
14
|
-
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
15
|
-
allowfullscreen
|
|
16
|
-
/>
|
|
17
|
-
</div>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
/** Exposes parent props to this component. */ parent: any;
|
|
5
|
-
};
|
|
6
|
-
events: {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
};
|
|
9
|
-
slots: {};
|
|
10
|
-
};
|
|
11
|
-
export type ModalExampleEmbedProps = typeof __propDef.props;
|
|
12
|
-
export type ModalExampleEmbedEvents = typeof __propDef.events;
|
|
13
|
-
export type ModalExampleEmbedSlots = typeof __propDef.slots;
|
|
14
|
-
/** This example creates an embedded video modal. */
|
|
15
|
-
export default class ModalExampleEmbed extends SvelteComponentTyped<ModalExampleEmbedProps, ModalExampleEmbedEvents, ModalExampleEmbedSlots> {
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<script>export let parent;
|
|
2
|
-
import { modalStore } from "../../../index.ts";
|
|
3
|
-
const formData = {
|
|
4
|
-
name: "Jane Doe",
|
|
5
|
-
tel: "214-555-1234",
|
|
6
|
-
email: "jdoe@email.com"
|
|
7
|
-
};
|
|
8
|
-
function onFormSubmit() {
|
|
9
|
-
if ($modalStore[0].response)
|
|
10
|
-
$modalStore[0].response(formData);
|
|
11
|
-
modalStore.close();
|
|
12
|
-
}
|
|
13
|
-
const cBase = "space-y-4";
|
|
14
|
-
const cForm = "border border-surface-500 p-4 space-y-4 rounded-container-token";
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<!-- @component This example creates a simple form modal. -->
|
|
18
|
-
|
|
19
|
-
<div class="modal-example-form {cBase}">
|
|
20
|
-
<!-- Enable for debugging: -->
|
|
21
|
-
<!-- <pre>{JSON.stringify(formData, null, 2)}</pre> -->
|
|
22
|
-
<form class="modal-form {cForm}">
|
|
23
|
-
<label class="label">
|
|
24
|
-
<span>Name</span>
|
|
25
|
-
<input class="input" type="text" bind:value={formData.name} placeholder="Enter name..." />
|
|
26
|
-
</label>
|
|
27
|
-
<label class="label">
|
|
28
|
-
<span>Phone Number</span>
|
|
29
|
-
<input class="input" type="tel" bind:value={formData.tel} placeholder="Enter phone..." />
|
|
30
|
-
</label>
|
|
31
|
-
<label class="label">
|
|
32
|
-
<span>Email</span>
|
|
33
|
-
<input class="input" type="email" bind:value={formData.email} placeholder="Enter email address..." />
|
|
34
|
-
</label>
|
|
35
|
-
</form>
|
|
36
|
-
<!-- prettier-ignore -->
|
|
37
|
-
<footer class="modal-footer {parent.regionFooter}">
|
|
38
|
-
<button class="btn {parent.buttonNeutral}" on:click={parent.onClose}>{parent.buttonTextCancel}</button>
|
|
39
|
-
<button class="btn {parent.buttonPositive}" on:click={onFormSubmit}>Submit Form</button>
|
|
40
|
-
</footer>
|
|
41
|
-
</div>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
/** Exposes parent props to this component. */ parent: any;
|
|
5
|
-
};
|
|
6
|
-
events: {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
};
|
|
9
|
-
slots: {};
|
|
10
|
-
};
|
|
11
|
-
export type ModalExampleFormProps = typeof __propDef.props;
|
|
12
|
-
export type ModalExampleFormEvents = typeof __propDef.events;
|
|
13
|
-
export type ModalExampleFormSlots = typeof __propDef.slots;
|
|
14
|
-
/** This example creates a simple form modal. */
|
|
15
|
-
export default class ModalExampleForm extends SvelteComponentTyped<ModalExampleFormProps, ModalExampleFormEvents, ModalExampleFormSlots> {
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<script>import { fade } from "svelte/transition";
|
|
2
|
-
import { modalStore } from "../../../index.ts";
|
|
3
|
-
export let parent;
|
|
4
|
-
const cButton = "fixed top-4 right-4 z-50 font-bold";
|
|
5
|
-
const cImage = "";
|
|
6
|
-
let showButton = false;
|
|
7
|
-
setTimeout(() => {
|
|
8
|
-
showButton = true;
|
|
9
|
-
}, 500);
|
|
10
|
-
</script>
|
|
11
|
-
|
|
12
|
-
<div>
|
|
13
|
-
<!-- Button -->
|
|
14
|
-
{#if showButton}
|
|
15
|
-
<button class="btn-icon btn-icon-lg variant-filled {cButton}" on:click={parent.onClose} transition:fade|local>×</button>
|
|
16
|
-
{/if}
|
|
17
|
-
<!-- Image -->
|
|
18
|
-
<img src={$modalStore[0]?.meta.src} class={cImage} alt="Example" />
|
|
19
|
-
</div>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
parent: any;
|
|
5
|
-
};
|
|
6
|
-
events: {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
};
|
|
9
|
-
slots: {};
|
|
10
|
-
};
|
|
11
|
-
export type ModalExampleImageProps = typeof __propDef.props;
|
|
12
|
-
export type ModalExampleImageEvents = typeof __propDef.events;
|
|
13
|
-
export type ModalExampleImageSlots = typeof __propDef.slots;
|
|
14
|
-
export default class ModalExampleImage extends SvelteComponentTyped<ModalExampleImageProps, ModalExampleImageEvents, ModalExampleImageSlots> {
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<script>import { ListBox, ListBoxItem, modalStore } from "../../../index.ts";
|
|
2
|
-
export let parent;
|
|
3
|
-
let flavor = "chocolate";
|
|
4
|
-
function onFormSubmit() {
|
|
5
|
-
if ($modalStore[0].response)
|
|
6
|
-
$modalStore[0].response(flavor);
|
|
7
|
-
modalStore.close();
|
|
8
|
-
}
|
|
9
|
-
const cBase = "space-y-4";
|
|
10
|
-
</script>
|
|
11
|
-
|
|
12
|
-
<!-- @component This example creates a simple form modal. -->
|
|
13
|
-
|
|
14
|
-
<div class="modal-example-form {cBase}">
|
|
15
|
-
<ListBox class="border border-surface-500 p-4 rounded-container-token">
|
|
16
|
-
<ListBoxItem bind:group={flavor} name="chocolate" value="chocolate">Chocolate</ListBoxItem>
|
|
17
|
-
<ListBoxItem bind:group={flavor} name="vanilla" value="vanilla">Vanilla</ListBoxItem>
|
|
18
|
-
<ListBoxItem bind:group={flavor} name="strawberry" value="strawberry">Strawberry</ListBoxItem>
|
|
19
|
-
<ListBoxItem bind:group={flavor} name="peach" value="peach">Peach</ListBoxItem>
|
|
20
|
-
</ListBox>
|
|
21
|
-
<!-- prettier-ignore -->
|
|
22
|
-
<footer class="modal-footer {parent.regionFooter}">
|
|
23
|
-
<button class="btn {parent.buttonNeutral}" on:click={parent.onClose}>{parent.buttonTextCancel}</button>
|
|
24
|
-
<button class="btn {parent.buttonPositive}" on:click={onFormSubmit}>Select Flavors</button>
|
|
25
|
-
</footer>
|
|
26
|
-
</div>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
/** Exposes parent props to this component. */ parent: any;
|
|
5
|
-
};
|
|
6
|
-
events: {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
};
|
|
9
|
-
slots: {};
|
|
10
|
-
};
|
|
11
|
-
export type ModalExampleListProps = typeof __propDef.props;
|
|
12
|
-
export type ModalExampleListEvents = typeof __propDef.events;
|
|
13
|
-
export type ModalExampleListSlots = typeof __propDef.slots;
|
|
14
|
-
/** This example creates a simple form modal. */
|
|
15
|
-
export default class ModalExampleList extends SvelteComponentTyped<ModalExampleListProps, ModalExampleListEvents, ModalExampleListSlots> {
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export interface ArgsTooltip {
|
|
2
|
-
/** The HTML content of the tooltip. */
|
|
3
|
-
content: string;
|
|
4
|
-
/** Provide a value of: top | bottom | left | right */
|
|
5
|
-
position?: string;
|
|
6
|
-
/** Sets the wrapping element to be either inline or block */
|
|
7
|
-
inline?: boolean;
|
|
8
|
-
/** Provide an optional callback function to handle open/close state changes. */
|
|
9
|
-
state?: (e: {
|
|
10
|
-
trigger: HTMLElement;
|
|
11
|
-
state: boolean;
|
|
12
|
-
}) => void;
|
|
13
|
-
/** Provide a class to set the background color. */
|
|
14
|
-
background?: string;
|
|
15
|
-
/** Provide a class to set the text color. */
|
|
16
|
-
color?: string;
|
|
17
|
-
/** Provide a class to set the width. */
|
|
18
|
-
width?: string;
|
|
19
|
-
/** Provide a class to set the padding. */
|
|
20
|
-
padding?: string;
|
|
21
|
-
/** Provide a class to set the box shadow. */
|
|
22
|
-
shadow?: string;
|
|
23
|
-
/** Provide a class to set the border radius. */
|
|
24
|
-
rounded?: string;
|
|
25
|
-
/** Provide arbitrary classes to the container element. */
|
|
26
|
-
regionContainer?: string;
|
|
27
|
-
/** Provide arbitrary classes to the tooltip element. */
|
|
28
|
-
regionTooltip?: string;
|
|
29
|
-
/** Provide arbitrary classes to the tooltip arrow element. */
|
|
30
|
-
regionArrow?: string;
|
|
31
|
-
}
|
|
32
|
-
export declare function tooltip(node: HTMLElement, args: ArgsTooltip): {
|
|
33
|
-
update(newArgs: ArgsTooltip): void;
|
|
34
|
-
destroy(): void;
|
|
35
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// Action: Tooltip
|
|
2
|
-
export function tooltip(node, args) {
|
|
3
|
-
const animDuration = 150;
|
|
4
|
-
let elemTooltip;
|
|
5
|
-
// Map the Args and provide default values
|
|
6
|
-
// prettier-ignore
|
|
7
|
-
const { content = '(tooltip)', position = 'top', inline = true,
|
|
8
|
-
// Regions
|
|
9
|
-
regionContainer = 'regionContainer', regionTooltip = 'regionTooltip', regionArrow = 'regionArrow' } = args;
|
|
10
|
-
// Create a wrapping element, set relative positioning
|
|
11
|
-
const createElemContainer = () => {
|
|
12
|
-
const elemContainer = document.createElement(inline ? 'span' : 'div');
|
|
13
|
-
elemContainer.classList.add('tooltip-container', 'relative', regionContainer);
|
|
14
|
-
node.parentNode?.insertBefore(elemContainer, node);
|
|
15
|
-
elemContainer.appendChild(node);
|
|
16
|
-
};
|
|
17
|
-
createElemContainer();
|
|
18
|
-
// Create the tooltip element
|
|
19
|
-
// prettier-ignore
|
|
20
|
-
const createElemTooltip = () => {
|
|
21
|
-
elemTooltip = document.createElement('div');
|
|
22
|
-
elemTooltip.classList.add('tooltip', `tooltip-${position}`, 'hidden', regionTooltip);
|
|
23
|
-
if (args.background) {
|
|
24
|
-
elemTooltip.classList.add(args.background);
|
|
25
|
-
}
|
|
26
|
-
if (args.color)
|
|
27
|
-
elemTooltip.classList.add(args.color);
|
|
28
|
-
if (args.width)
|
|
29
|
-
elemTooltip.classList.add(args.width);
|
|
30
|
-
if (args.padding)
|
|
31
|
-
elemTooltip.classList.add(args.padding);
|
|
32
|
-
if (args.shadow)
|
|
33
|
-
elemTooltip.classList.add(args.shadow);
|
|
34
|
-
if (args.rounded)
|
|
35
|
-
elemTooltip.classList.add(args.rounded);
|
|
36
|
-
elemTooltip.setAttribute('role', 'tooltip');
|
|
37
|
-
elemTooltip.setAttribute('data-testid', 'tooltip');
|
|
38
|
-
elemTooltip.innerHTML = content;
|
|
39
|
-
node.parentNode?.insertBefore(elemTooltip, node);
|
|
40
|
-
};
|
|
41
|
-
createElemTooltip();
|
|
42
|
-
// Create the tooltip arrow
|
|
43
|
-
// prettier-ignore
|
|
44
|
-
const createElemArrow = () => {
|
|
45
|
-
const elemArrow = document.createElement('div');
|
|
46
|
-
elemArrow.classList.add(`tooltip-arrow-${position}`, regionArrow);
|
|
47
|
-
if (args.background)
|
|
48
|
-
elemArrow.classList.add(args.background);
|
|
49
|
-
elemTooltip.append(elemArrow);
|
|
50
|
-
};
|
|
51
|
-
createElemArrow();
|
|
52
|
-
// -- State
|
|
53
|
-
// On mouse over - show the tooltip
|
|
54
|
-
const onMouseEnter = () => {
|
|
55
|
-
elemTooltip.classList.remove('hidden');
|
|
56
|
-
setTimeout(() => {
|
|
57
|
-
elemTooltip.classList.add('!opacity-100');
|
|
58
|
-
}, animDuration);
|
|
59
|
-
stateEventHandler(true);
|
|
60
|
-
};
|
|
61
|
-
// On mouse out - hide the tooltip
|
|
62
|
-
const onMouseLeave = () => {
|
|
63
|
-
elemTooltip.classList.remove('!opacity-100');
|
|
64
|
-
setTimeout(() => {
|
|
65
|
-
elemTooltip.classList.add('hidden');
|
|
66
|
-
}, animDuration);
|
|
67
|
-
stateEventHandler(false);
|
|
68
|
-
};
|
|
69
|
-
const stateEventHandler = (state) => {
|
|
70
|
-
if (args.state)
|
|
71
|
-
args.state({ trigger: node, state });
|
|
72
|
-
};
|
|
73
|
-
// Ally ---
|
|
74
|
-
// A11y Input Handler
|
|
75
|
-
const onWindowKeyDown = (event) => {
|
|
76
|
-
if (event.code === 'Escape')
|
|
77
|
-
onMouseLeave();
|
|
78
|
-
};
|
|
79
|
-
// Event Listners ---
|
|
80
|
-
node.addEventListener('mouseenter', onMouseEnter);
|
|
81
|
-
node.addEventListener('mouseleave', onMouseLeave);
|
|
82
|
-
window.addEventListener('keydown', onWindowKeyDown);
|
|
83
|
-
// Lifecycle
|
|
84
|
-
return {
|
|
85
|
-
update(newArgs) {
|
|
86
|
-
args = newArgs;
|
|
87
|
-
},
|
|
88
|
-
destroy() {
|
|
89
|
-
node.removeEventListener('mouseenter', onMouseEnter);
|
|
90
|
-
node.removeEventListener('mouseleave', onMouseLeave);
|
|
91
|
-
window.removeEventListener('keydown', onWindowKeyDown);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|