@skeletonlabs/skeleton 1.11.0 → 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Accordion/Accordion.svelte +15 -3
- package/dist/components/Accordion/Accordion.svelte.d.ts +17 -23
- package/dist/components/Accordion/AccordionItem.svelte +8 -3
- package/dist/components/Accordion/AccordionItem.svelte.d.ts +15 -25
- package/dist/components/AppRail/AppRailTile.svelte +1 -1
- package/dist/components/Autocomplete/Autocomplete.svelte +24 -15
- package/dist/components/Autocomplete/Autocomplete.svelte.d.ts +17 -27
- package/dist/components/Avatar/Avatar.svelte +1 -1
- package/dist/components/ConicGradient/ConicGradient.svelte +1 -1
- package/dist/components/InputChip/InputChip.svelte +25 -10
- package/dist/components/InputChip/InputChip.svelte.d.ts +22 -27
- package/dist/components/Paginator/Paginator.svelte +18 -16
- package/dist/components/Paginator/Paginator.svelte.d.ts +2 -2
- package/dist/components/Paginator/types.d.ts +2 -2
- package/dist/components/Radio/RadioGroup.svelte +2 -0
- package/dist/components/Radio/RadioGroup.svelte.d.ts +2 -0
- package/dist/components/Radio/RadioItem.svelte +8 -4
- package/dist/components/Radio/RadioItem.svelte.d.ts +1 -0
- package/dist/components/Ratings/Ratings.svelte +1 -1
- package/dist/components/Stepper/Step.svelte +11 -2
- package/dist/components/Stepper/Step.svelte.d.ts +15 -12
- package/dist/components/Stepper/Stepper.svelte +21 -3
- package/dist/components/Stepper/Stepper.svelte.d.ts +17 -27
- package/dist/components/Tab/TabGroup.svelte +1 -1
- package/dist/components/Table/Table.svelte +1 -1
- package/dist/components/TreeView/TreeView.svelte +71 -2
- package/dist/components/TreeView/TreeView.svelte.d.ts +19 -0
- package/dist/components/TreeView/TreeViewDataDrivenItem.svelte +70 -0
- package/dist/components/TreeView/TreeViewDataDrivenItem.svelte.d.ts +25 -0
- package/dist/components/TreeView/TreeViewItem.svelte +198 -10
- package/dist/components/TreeView/TreeViewItem.svelte.d.ts +90 -2
- package/dist/components/TreeView/types.d.ts +18 -0
- package/dist/components/TreeView/types.js +1 -0
- package/dist/index.d.ts +12 -9
- package/dist/index.js +11 -12
- package/dist/internal/transitions.d.ts +10 -0
- package/dist/internal/transitions.js +11 -0
- package/dist/transitions/crossfade.d.ts +1 -0
- package/dist/transitions/crossfade.js +21 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.js +1 -0
- package/dist/utilities/Drawer/Drawer.svelte +33 -12
- package/dist/utilities/Drawer/Drawer.svelte.d.ts +4 -2
- package/dist/utilities/Drawer/stores.d.ts +20 -1
- package/dist/utilities/Drawer/stores.js +27 -2
- package/dist/utilities/Drawer/types.d.ts +2 -0
- package/dist/utilities/Modal/Modal.svelte +21 -23
- package/dist/utilities/Modal/Modal.svelte.d.ts +17 -37
- package/dist/utilities/Modal/stores.d.ts +20 -1
- package/dist/utilities/Modal/stores.js +27 -1
- package/dist/utilities/PrefersReducedMotion/PrefersReducedMotion.d.ts +7 -0
- package/dist/utilities/PrefersReducedMotion/PrefersReducedMotion.js +26 -0
- package/dist/utilities/TableOfContents/TableOfContents.svelte +56 -0
- package/dist/utilities/TableOfContents/TableOfContents.svelte.d.ts +34 -0
- package/dist/utilities/TableOfContents/crawler.d.ts +14 -0
- package/dist/utilities/TableOfContents/crawler.js +76 -0
- package/dist/utilities/TableOfContents/stores.d.ts +6 -0
- package/dist/utilities/TableOfContents/stores.js +5 -0
- package/dist/utilities/TableOfContents/types.d.ts +5 -0
- package/dist/utilities/TableOfContents/types.js +2 -0
- package/dist/utilities/Toast/Toast.svelte +24 -23
- package/dist/utilities/Toast/Toast.svelte.d.ts +17 -24
- package/dist/utilities/Toast/stores.d.ts +23 -5
- package/dist/utilities/Toast/stores.js +56 -29
- package/dist/utilities/index.d.ts +18 -0
- package/dist/utilities/index.js +25 -0
- package/package.json +3 -16
- package/dist/components/TableOfContents/TableOfContents.svelte +0 -111
- package/dist/components/TableOfContents/TableOfContents.svelte.d.ts +0 -44
- package/dist/styles/all.css +0 -30
- package/dist/styles/elements/alerts.css +0 -17
- package/dist/styles/elements/badges.css +0 -31
- package/dist/styles/elements/breadcrumbs.css +0 -36
- package/dist/styles/elements/buttons.css +0 -109
- package/dist/styles/elements/cards.css +0 -32
- package/dist/styles/elements/chips.css +0 -22
- package/dist/styles/elements/codeblocks.css +0 -16
- package/dist/styles/elements/forms.css +0 -283
- package/dist/styles/elements/lists.css +0 -51
- package/dist/styles/elements/logo-clouds.css +0 -29
- package/dist/styles/elements/modals.css +0 -15
- package/dist/styles/elements/placeholders.css +0 -17
- package/dist/styles/elements/popups.css +0 -16
- package/dist/styles/elements/tables.css +0 -102
- package/dist/styles/partials/core.css +0 -66
- package/dist/styles/partials/elements.css +0 -20
- package/dist/styles/partials/tailwind.css +0 -16
- package/dist/styles/partials/typography-next.css +0 -99
- package/dist/styles/partials/typography-prose.css +0 -49
- package/dist/styles/partials/typography.css +0 -99
- package/dist/styles/partials/variants.css +0 -204
- package/dist/styles/skeleton-minimal.css +0 -30
- package/dist/styles/skeleton.css +0 -30
- package/dist/tailwind/core.cjs +0 -37
- package/dist/tailwind/core.d.cts +0 -5
- package/dist/tailwind/generated/intellisense-classes.cjs +0 -1
- package/dist/tailwind/generated/intellisense-classes.d.cts +0 -2729
- package/dist/tailwind/intellisense.cjs +0 -21
- package/dist/tailwind/intellisense.d.cts +0 -5
- package/dist/tailwind/settings.cjs +0 -20
- package/dist/tailwind/settings.d.cts +0 -6
- package/dist/tailwind/skeleton.cjs +0 -19
- package/dist/tailwind/skeleton.d.cts +0 -7
- package/dist/tailwind/theme/colors.cjs +0 -18
- package/dist/tailwind/theme/colors.d.cts +0 -2
- package/dist/tailwind/tokens/backgrounds.cjs +0 -39
- package/dist/tailwind/tokens/backgrounds.d.cts +0 -2
- package/dist/tailwind/tokens/border-radius.cjs +0 -21
- package/dist/tailwind/tokens/border-radius.d.cts +0 -33
- package/dist/tailwind/tokens/borders.cjs +0 -20
- package/dist/tailwind/tokens/borders.d.cts +0 -6
- package/dist/tailwind/tokens/fills.cjs +0 -20
- package/dist/tailwind/tokens/fills.d.cts +0 -15
- package/dist/tailwind/tokens/rings.cjs +0 -50
- package/dist/tailwind/tokens/rings.d.cts +0 -22
- package/dist/tailwind/tokens/text.cjs +0 -31
- package/dist/tailwind/tokens/text.d.cts +0 -21
- package/dist/themes/theme-crimson.css +0 -100
- package/dist/themes/theme-gold-nouveau.css +0 -143
- package/dist/themes/theme-hamlindigo.css +0 -109
- package/dist/themes/theme-modern.css +0 -134
- package/dist/themes/theme-rocket.css +0 -120
- package/dist/themes/theme-sahara.css +0 -133
- package/dist/themes/theme-seafoam.css +0 -128
- package/dist/themes/theme-seasonal.css +0 -114
- package/dist/themes/theme-skeleton.css +0 -119
- package/dist/themes/theme-test.css +0 -96
- package/dist/themes/theme-vintage.css +0 -131
- package/dist/utilities/DataTable/DataTable.d.ts +0 -19
- package/dist/utilities/DataTable/DataTable.js +0 -137
- package/dist/utilities/DataTable/types.d.ts +0 -33
- package/dist/utilities/DataTable/types.js +0 -2
- /package/dist/{utilities/DataTable → components/Table}/actions.d.ts +0 -0
- /package/dist/{utilities/DataTable → components/Table}/actions.js +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { createEventDispatcher } from "svelte";
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
3
2
|
import { BROWSER } from "esm-env";
|
|
4
3
|
const dispatch = createEventDispatcher();
|
|
4
|
+
import { prefersReducedMotionStore } from "../../index.js";
|
|
5
5
|
import { focusTrap } from "../../actions/FocusTrap/focusTrap.js";
|
|
6
|
-
import {
|
|
6
|
+
import { getDrawerStore } from "./stores.js";
|
|
7
|
+
import { fade, fly } from "svelte/transition";
|
|
8
|
+
import { dynamicTransition } from "../../internal/transitions.js";
|
|
7
9
|
export let position = "left";
|
|
8
|
-
export let duration = 150;
|
|
9
10
|
export let bgBackdrop = "bg-surface-backdrop-token";
|
|
10
11
|
export let blur = "";
|
|
11
12
|
export let padding = "";
|
|
@@ -20,20 +21,22 @@ export let regionBackdrop = "";
|
|
|
20
21
|
export let regionDrawer = "";
|
|
21
22
|
export let labelledby = "";
|
|
22
23
|
export let describedby = "";
|
|
24
|
+
export let transitions = !$prefersReducedMotionStore;
|
|
25
|
+
export let opacityTransition = true;
|
|
23
26
|
const presets = {
|
|
24
27
|
top: { alignment: "items-start", width: "w-full", height: "h-[50%]", rounded: "rounded-bl-container-token rounded-br-container-token" },
|
|
25
28
|
bottom: { alignment: "items-end", width: "w-full", height: " h-[50%]", rounded: "rounded-tl-container-token rounded-tr-container-token" },
|
|
26
29
|
left: { alignment: "justify-start", width: "w-[90%]", height: "h-full", rounded: "rounded-tr-container-token rounded-br-container-token" },
|
|
27
30
|
right: { alignment: "justify-end", width: "w-[90%]", height: "h-full", rounded: "rounded-tl-container-token rounded-bl-container-token" }
|
|
28
31
|
};
|
|
29
|
-
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0 flex";
|
|
30
|
-
const cDrawer = "overflow-y-auto transition-transform";
|
|
31
32
|
let elemBackdrop;
|
|
32
33
|
let elemDrawer;
|
|
33
34
|
let anim = { x: 0, y: 0 };
|
|
35
|
+
const drawerStore = getDrawerStore();
|
|
36
|
+
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0 flex";
|
|
37
|
+
const cDrawer = "overflow-y-auto transition-transform";
|
|
34
38
|
const propDefaults = {
|
|
35
39
|
position,
|
|
36
|
-
duration,
|
|
37
40
|
bgBackdrop,
|
|
38
41
|
blur,
|
|
39
42
|
padding,
|
|
@@ -43,6 +46,7 @@ const propDefaults = {
|
|
|
43
46
|
shadow,
|
|
44
47
|
width,
|
|
45
48
|
height,
|
|
49
|
+
opacityTransition,
|
|
46
50
|
labelledby,
|
|
47
51
|
describedby,
|
|
48
52
|
regionBackdrop,
|
|
@@ -50,7 +54,6 @@ const propDefaults = {
|
|
|
50
54
|
};
|
|
51
55
|
function applyPropSettings(settings) {
|
|
52
56
|
position = settings.position || propDefaults.position;
|
|
53
|
-
duration = settings.duration || propDefaults.duration;
|
|
54
57
|
bgBackdrop = settings.bgBackdrop || propDefaults.bgBackdrop;
|
|
55
58
|
blur = settings.blur || propDefaults.blur;
|
|
56
59
|
padding = settings.padding || propDefaults.padding;
|
|
@@ -60,6 +63,7 @@ function applyPropSettings(settings) {
|
|
|
60
63
|
shadow = settings.shadow || propDefaults.shadow;
|
|
61
64
|
width = settings.width || propDefaults.width;
|
|
62
65
|
height = settings.height || propDefaults.height;
|
|
66
|
+
opacityTransition = settings.opacityTransition || propDefaults.opacityTransition;
|
|
63
67
|
regionBackdrop = settings.regionBackdrop || propDefaults.regionBackdrop;
|
|
64
68
|
regionDrawer = settings.regionDrawer || propDefaults.regionDrawer;
|
|
65
69
|
labelledby = settings.labelledby || propDefaults.labelledby;
|
|
@@ -124,7 +128,7 @@ $:
|
|
|
124
128
|
|
|
125
129
|
{#if $drawerStore.open === true}
|
|
126
130
|
<!-- Backdrop -->
|
|
127
|
-
<!--
|
|
131
|
+
<!-- FIXME: resolve a11y warnings -->
|
|
128
132
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
129
133
|
<div
|
|
130
134
|
bind:this={elemBackdrop}
|
|
@@ -134,7 +138,16 @@ $:
|
|
|
134
138
|
on:touchstart
|
|
135
139
|
on:touchend
|
|
136
140
|
on:keypress
|
|
137
|
-
|
|
141
|
+
in:dynamicTransition|local={{
|
|
142
|
+
transition: fade,
|
|
143
|
+
params: { duration: 150 },
|
|
144
|
+
enabled: transitions && opacityTransition
|
|
145
|
+
}}
|
|
146
|
+
out:dynamicTransition|local={{
|
|
147
|
+
transition: fade,
|
|
148
|
+
params: { duration: 150 },
|
|
149
|
+
enabled: transitions && opacityTransition
|
|
150
|
+
}}
|
|
138
151
|
use:focusTrap={true}
|
|
139
152
|
>
|
|
140
153
|
<!-- Drawer -->
|
|
@@ -147,8 +160,16 @@ $:
|
|
|
147
160
|
aria-modal="true"
|
|
148
161
|
aria-labelledby={labelledby}
|
|
149
162
|
aria-describedby={describedby}
|
|
150
|
-
in:
|
|
151
|
-
|
|
163
|
+
in:dynamicTransition|local={{
|
|
164
|
+
transition: fly,
|
|
165
|
+
params: { x: anim.x, y: anim.y, duration: 150, opacity: opacityTransition ? undefined : 1 },
|
|
166
|
+
enabled: transitions
|
|
167
|
+
}}
|
|
168
|
+
out:dynamicTransition|local={{
|
|
169
|
+
transition: fly,
|
|
170
|
+
params: { x: anim.x, y: anim.y, duration: 150, opacity: opacityTransition ? undefined : 1 },
|
|
171
|
+
enabled: transitions
|
|
172
|
+
}}
|
|
152
173
|
>
|
|
153
174
|
<!-- Slot: Default -->
|
|
154
175
|
<slot />
|
|
@@ -4,8 +4,6 @@ declare const __propDef: {
|
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
/** Set the anchor position.*/
|
|
6
6
|
position?: "left" | "top" | "right" | "bottom" | undefined;
|
|
7
|
-
/** Define the Svelte transition animation duration.*/
|
|
8
|
-
duration?: number | undefined;
|
|
9
7
|
/** Backdrop - Provide classes to set the backdrop background color*/
|
|
10
8
|
bgBackdrop?: string | undefined;
|
|
11
9
|
/** Backdrop - Provide classes to set the blur style.*/
|
|
@@ -34,6 +32,10 @@ declare const __propDef: {
|
|
|
34
32
|
labelledby?: string | undefined;
|
|
35
33
|
/** Provide an ID of the element describing the drawer.*/
|
|
36
34
|
describedby?: string | undefined;
|
|
35
|
+
/** Enable/Disable transitions*/
|
|
36
|
+
transitions?: boolean | undefined;
|
|
37
|
+
/** Drawer - Enable/Disable opacity transition*/
|
|
38
|
+
opacityTransition?: boolean | undefined;
|
|
37
39
|
};
|
|
38
40
|
events: {
|
|
39
41
|
touchstart: TouchEvent;
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
/// <reference types="svelte" />
|
|
2
2
|
import type { DrawerSettings } from './types.js';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the `drawerStore`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { getDrawerStore } from "@skeletonlabs/skeleton";
|
|
9
|
+
*
|
|
10
|
+
* const drawerStore = getDrawerStore();
|
|
11
|
+
*
|
|
12
|
+
* drawerStore.open();
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function getDrawerStore(): DrawerStore;
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the `drawerStore`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function initializeDrawerStore(): DrawerStore;
|
|
20
|
+
type DrawerStore = ReturnType<typeof drawerService>;
|
|
21
|
+
declare function drawerService(): {
|
|
4
22
|
subscribe: (this: void, run: import("svelte/store").Subscriber<DrawerSettings>, invalidate?: import("svelte/store").Invalidator<DrawerSettings> | undefined) => import("svelte/store").Unsubscriber;
|
|
5
23
|
set: (this: void, value: DrawerSettings) => void;
|
|
6
24
|
update: (this: void, updater: import("svelte/store").Updater<DrawerSettings>) => void;
|
|
@@ -9,3 +27,4 @@ export declare const drawerStore: {
|
|
|
9
27
|
/** Close the drawer. */
|
|
10
28
|
close: () => void;
|
|
11
29
|
};
|
|
30
|
+
export {};
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
// Drawer Stores
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
|
+
import { getContext, setContext } from 'svelte';
|
|
4
|
+
const DRAWER_STORE_KEY = 'drawerStore';
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves the `drawerStore`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { getDrawerStore } from "@skeletonlabs/skeleton";
|
|
11
|
+
*
|
|
12
|
+
* const drawerStore = getDrawerStore();
|
|
13
|
+
*
|
|
14
|
+
* drawerStore.open();
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function getDrawerStore() {
|
|
18
|
+
const drawerStore = getContext(DRAWER_STORE_KEY);
|
|
19
|
+
if (!drawerStore)
|
|
20
|
+
throw new Error('drawerStore is not initialized. Please ensure that `initializeStores()` is invoked in the root layout file of this app!');
|
|
21
|
+
return drawerStore;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Initializes the `drawerStore`.
|
|
25
|
+
*/
|
|
26
|
+
export function initializeDrawerStore() {
|
|
27
|
+
const drawerStore = drawerService();
|
|
28
|
+
return setContext(DRAWER_STORE_KEY, drawerStore);
|
|
29
|
+
}
|
|
3
30
|
function drawerService() {
|
|
4
31
|
const { subscribe, set, update } = writable({});
|
|
5
32
|
return {
|
|
@@ -17,5 +44,3 @@ function drawerService() {
|
|
|
17
44
|
})
|
|
18
45
|
};
|
|
19
46
|
}
|
|
20
|
-
// Exports
|
|
21
|
-
export const drawerStore = drawerService();
|
|
@@ -28,6 +28,8 @@ export interface DrawerSettings {
|
|
|
28
28
|
width?: string;
|
|
29
29
|
/** Drawer - Provide classes to override the height.*/
|
|
30
30
|
height?: string;
|
|
31
|
+
/** Drawer - Enable/Disable opacity transition */
|
|
32
|
+
opacityTransition?: boolean;
|
|
31
33
|
/** Provide arbitrary classes to the backdrop region. */
|
|
32
34
|
regionBackdrop?: string;
|
|
33
35
|
/** Provide arbitrary classes to the drawer region. */
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import {
|
|
1
|
+
<script context="module">import { fly, fade } from "svelte/transition";
|
|
2
|
+
import { prefersReducedMotionStore } from "../../index.js";
|
|
3
|
+
import { dynamicTransition } from "../../internal/transitions.js";
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<script generics="TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition">import { createEventDispatcher } from "svelte";
|
|
3
7
|
const dispatch = createEventDispatcher();
|
|
4
|
-
import { modalStore } from "./stores.js";
|
|
5
8
|
import { focusTrap } from "../../actions/FocusTrap/focusTrap.js";
|
|
9
|
+
import { getModalStore } from "./stores.js";
|
|
6
10
|
export let position = "items-center";
|
|
7
11
|
export let components = {};
|
|
8
|
-
export let duration = 150;
|
|
9
|
-
export let flyOpacity = 0;
|
|
10
|
-
export let flyX = 0;
|
|
11
|
-
export let flyY = 100;
|
|
12
12
|
export let background = "bg-surface-100-800-token";
|
|
13
13
|
export let width = "w-modal";
|
|
14
14
|
export let height = "h-auto";
|
|
@@ -26,6 +26,11 @@ export let regionBackdrop = "bg-surface-backdrop-token";
|
|
|
26
26
|
export let regionHeader = "text-2xl font-bold";
|
|
27
27
|
export let regionBody = "max-h-[200px] overflow-hidden";
|
|
28
28
|
export let regionFooter = "flex justify-end space-x-2";
|
|
29
|
+
export let transitions = !$prefersReducedMotionStore;
|
|
30
|
+
export let transitionIn = fly;
|
|
31
|
+
export let transitionInParams = { duration: 150, opacity: 0, x: 0, y: 100 };
|
|
32
|
+
export let transitionOut = fly;
|
|
33
|
+
export let transitionOutParams = { duration: 150, opacity: 0, x: 0, y: 100 };
|
|
29
34
|
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0 overflow-y-auto";
|
|
30
35
|
const cTransitionLayer = "w-full h-fit min-h-full p-4 overflow-y-auto flex justify-center";
|
|
31
36
|
const cModal = "block overflow-y-auto";
|
|
@@ -38,6 +43,7 @@ const buttonTextDefaults = {
|
|
|
38
43
|
};
|
|
39
44
|
let currentComponent;
|
|
40
45
|
let registeredInteractionWithBackdrop = false;
|
|
46
|
+
const modalStore = getModalStore();
|
|
41
47
|
modalStore.subscribe((modals) => {
|
|
42
48
|
if (!modals.length)
|
|
43
49
|
return;
|
|
@@ -102,11 +108,6 @@ $:
|
|
|
102
108
|
parent = {
|
|
103
109
|
position,
|
|
104
110
|
// ---
|
|
105
|
-
duration,
|
|
106
|
-
flyOpacity,
|
|
107
|
-
flyX,
|
|
108
|
-
flyY,
|
|
109
|
-
// ---
|
|
110
111
|
background,
|
|
111
112
|
width,
|
|
112
113
|
height,
|
|
@@ -135,7 +136,7 @@ $:
|
|
|
135
136
|
{#if $modalStore.length > 0}
|
|
136
137
|
{#key $modalStore}
|
|
137
138
|
<!-- Backdrop -->
|
|
138
|
-
<!--
|
|
139
|
+
<!-- FIXME: resolve a11y warnings -->
|
|
139
140
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
140
141
|
<div
|
|
141
142
|
class="modal-backdrop {classesBackdrop}"
|
|
@@ -144,21 +145,18 @@ $:
|
|
|
144
145
|
on:mouseup={onBackdropInteractionEnd}
|
|
145
146
|
on:touchstart|passive
|
|
146
147
|
on:touchend|passive
|
|
147
|
-
transition:
|
|
148
|
+
transition:dynamicTransition|global={{ transition: fade, params: { duration: 150 }, enabled: transitions }}
|
|
148
149
|
use:focusTrap={true}
|
|
149
150
|
>
|
|
150
151
|
<!-- Transition Layer -->
|
|
151
|
-
<div
|
|
152
|
+
<div
|
|
153
|
+
class="modal-transition {classesTransitionLayer}"
|
|
154
|
+
in:dynamicTransition|global={{ transition: transitionIn, params: transitionInParams, enabled: transitions }}
|
|
155
|
+
out:dynamicTransition|global={{ transition: transitionOut, params: transitionOutParams, enabled: transitions }}
|
|
156
|
+
>
|
|
152
157
|
{#if $modalStore[0].type !== 'component'}
|
|
153
158
|
<!-- Modal: Presets -->
|
|
154
|
-
<div
|
|
155
|
-
class="modal {classesModal}"
|
|
156
|
-
data-testid="modal"
|
|
157
|
-
role="dialog"
|
|
158
|
-
aria-modal="true"
|
|
159
|
-
aria-label={$modalStore[0].title ?? ''}
|
|
160
|
-
transition:fly|global={{ duration, opacity: 0, y: 100 }}
|
|
161
|
-
>
|
|
159
|
+
<div class="modal {classesModal}" data-testid="modal" role="dialog" aria-modal="true" aria-label={$modalStore[0].title ?? ''}>
|
|
162
160
|
<!-- Header -->
|
|
163
161
|
{#if $modalStore[0]?.title}
|
|
164
162
|
<header class="modal-header {regionHeader}">{@html $modalStore[0].title}</header>
|
|
@@ -1,68 +1,48 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { fly } from 'svelte/transition';
|
|
3
|
+
import { type Transition, type TransitionParams } from '../../index.js';
|
|
4
|
+
type FlyTransition = typeof fly;
|
|
2
5
|
import type { ModalComponent } from './types.js';
|
|
3
|
-
declare
|
|
4
|
-
props: {
|
|
6
|
+
declare class __sveltets_Render<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> {
|
|
7
|
+
props(): {
|
|
5
8
|
[x: string]: any;
|
|
6
|
-
/** Set the modal position within the backdrop container*/
|
|
7
9
|
position?: string | undefined;
|
|
8
|
-
/** Register a list of reusable component modals.*/
|
|
9
10
|
components?: Record<string, ModalComponent> | undefined;
|
|
10
|
-
/** The open/close animation duration. Set '0' (zero) to disable.*/
|
|
11
|
-
duration?: number | undefined;
|
|
12
|
-
/** Set the fly transition opacity.*/
|
|
13
|
-
flyOpacity?: number | undefined;
|
|
14
|
-
/** Set the fly transition X axis value.*/
|
|
15
|
-
flyX?: number | undefined;
|
|
16
|
-
/** Set the fly transition Y axis value.*/
|
|
17
|
-
flyY?: number | undefined;
|
|
18
|
-
/** Provide classes to style the modal background.*/
|
|
19
11
|
background?: string | undefined;
|
|
20
|
-
/** Provide classes to style the modal width.*/
|
|
21
12
|
width?: string | undefined;
|
|
22
|
-
/** Provide classes to style the modal height.*/
|
|
23
13
|
height?: string | undefined;
|
|
24
|
-
/** Provide classes to style the modal padding.*/
|
|
25
14
|
padding?: string | undefined;
|
|
26
|
-
/** Provide classes to style the modal spacing.*/
|
|
27
15
|
spacing?: string | undefined;
|
|
28
|
-
/** Provide classes to style the modal border radius.*/
|
|
29
16
|
rounded?: string | undefined;
|
|
30
|
-
/** Provide classes to style modal box shadow.*/
|
|
31
17
|
shadow?: string | undefined;
|
|
32
|
-
/** Provide a class to override the z-index*/
|
|
33
18
|
zIndex?: string | undefined;
|
|
34
|
-
/** Provide classes for neutral buttons, such as Cancel.*/
|
|
35
19
|
buttonNeutral?: string | undefined;
|
|
36
|
-
/** Provide classes for positive actions, such as Confirm or Submit.*/
|
|
37
20
|
buttonPositive?: string | undefined;
|
|
38
|
-
/** Override the text for the Cancel button.*/
|
|
39
21
|
buttonTextCancel?: string | undefined;
|
|
40
|
-
/** Override the text for the Confirm button.*/
|
|
41
22
|
buttonTextConfirm?: string | undefined;
|
|
42
|
-
/** Override the text for the Submit button.*/
|
|
43
23
|
buttonTextSubmit?: string | undefined;
|
|
44
|
-
/** Provide classes to style the backdrop.*/
|
|
45
24
|
regionBackdrop?: string | undefined;
|
|
46
|
-
/** Provide arbitrary classes to modal header region.*/
|
|
47
25
|
regionHeader?: string | undefined;
|
|
48
|
-
/** Provide arbitrary classes to modal body region.*/
|
|
49
26
|
regionBody?: string | undefined;
|
|
50
|
-
/** Provide arbitrary classes to modal footer region.*/
|
|
51
27
|
regionFooter?: string | undefined;
|
|
28
|
+
transitions?: boolean | undefined;
|
|
29
|
+
transitionIn?: TransitionIn | undefined;
|
|
30
|
+
transitionInParams?: TransitionParams<TransitionIn> | undefined;
|
|
31
|
+
transitionOut?: TransitionOut | undefined;
|
|
32
|
+
transitionOutParams?: TransitionParams<TransitionOut> | undefined;
|
|
52
33
|
};
|
|
53
|
-
events: {
|
|
34
|
+
events(): {
|
|
54
35
|
touchstart: TouchEvent;
|
|
55
36
|
touchend: TouchEvent;
|
|
56
|
-
/** {{ event }} backdrop - Fires on backdrop interaction.*/
|
|
57
37
|
backdrop: CustomEvent<MouseEvent>;
|
|
58
38
|
} & {
|
|
59
39
|
[evt: string]: CustomEvent<any>;
|
|
60
40
|
};
|
|
61
|
-
slots: {};
|
|
62
|
-
}
|
|
63
|
-
export type ModalProps =
|
|
64
|
-
export type ModalEvents =
|
|
65
|
-
export type ModalSlots =
|
|
66
|
-
export default class Modal extends SvelteComponentTyped<ModalProps, ModalEvents, ModalSlots
|
|
41
|
+
slots(): {};
|
|
42
|
+
}
|
|
43
|
+
export type ModalProps<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['props']>;
|
|
44
|
+
export type ModalEvents<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['events']>;
|
|
45
|
+
export type ModalSlots<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['slots']>;
|
|
46
|
+
export default class Modal<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> extends SvelteComponentTyped<ModalProps<TransitionIn, TransitionOut>, ModalEvents<TransitionIn, TransitionOut>, ModalSlots<TransitionIn, TransitionOut>> {
|
|
67
47
|
}
|
|
68
48
|
export {};
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
/// <reference types="svelte" />
|
|
2
2
|
import type { ModalSettings } from './types.js';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the `modalStore`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { getmodalStore } from "@skeletonlabs/skeleton";
|
|
9
|
+
*
|
|
10
|
+
* const modalStore = getModalStore();
|
|
11
|
+
*
|
|
12
|
+
* modalStore.trigger({ type: "alert", title: "Welcome!" });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function getModalStore(): ModalStore;
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the `modalStore`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function initializeModalStore(): ModalStore;
|
|
20
|
+
type ModalStore = ReturnType<typeof modalService>;
|
|
21
|
+
declare function modalService(): {
|
|
4
22
|
subscribe: (this: void, run: import("svelte/store").Subscriber<ModalSettings[]>, invalidate?: import("svelte/store").Invalidator<ModalSettings[]> | undefined) => import("svelte/store").Unsubscriber;
|
|
5
23
|
set: (this: void, value: ModalSettings[]) => void;
|
|
6
24
|
update: (this: void, updater: import("svelte/store").Updater<ModalSettings[]>) => void;
|
|
@@ -11,3 +29,4 @@ export declare const modalStore: {
|
|
|
11
29
|
/** Remove all items from queue. */
|
|
12
30
|
clear: () => void;
|
|
13
31
|
};
|
|
32
|
+
export {};
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
// Modal Store Queue
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
|
+
import { getContext, setContext } from 'svelte';
|
|
4
|
+
const MODAL_STORE_KEY = 'modalStore';
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves the `modalStore`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { getmodalStore } from "@skeletonlabs/skeleton";
|
|
11
|
+
*
|
|
12
|
+
* const modalStore = getModalStore();
|
|
13
|
+
*
|
|
14
|
+
* modalStore.trigger({ type: "alert", title: "Welcome!" });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function getModalStore() {
|
|
18
|
+
const modalStore = getContext(MODAL_STORE_KEY);
|
|
19
|
+
if (!modalStore)
|
|
20
|
+
throw new Error('modalStore is not initialized. Please ensure that `initializeStores()` is invoked in the root layout file of this app!');
|
|
21
|
+
return modalStore;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Initializes the `modalStore`.
|
|
25
|
+
*/
|
|
26
|
+
export function initializeModalStore() {
|
|
27
|
+
const modalStore = modalService();
|
|
28
|
+
return setContext(MODAL_STORE_KEY, modalStore);
|
|
29
|
+
}
|
|
3
30
|
function modalService() {
|
|
4
31
|
const { subscribe, set, update } = writable([]);
|
|
5
32
|
return {
|
|
@@ -21,4 +48,3 @@ function modalService() {
|
|
|
21
48
|
clear: () => set([])
|
|
22
49
|
};
|
|
23
50
|
}
|
|
24
|
-
export const modalStore = modalService();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
/**
|
|
3
|
+
* Indicates that the user has enabled reduced motion on their device.
|
|
4
|
+
*
|
|
5
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
|
|
6
|
+
*/
|
|
7
|
+
export declare const prefersReducedMotionStore: import("svelte/store").Readable<boolean>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readable } from 'svelte/store';
|
|
2
|
+
import { BROWSER } from 'esm-env';
|
|
3
|
+
/** Prefers reduced motion */
|
|
4
|
+
const reducedMotionQuery = '(prefers-reduced-motion: reduce)';
|
|
5
|
+
function prefersReducedMotion() {
|
|
6
|
+
if (!BROWSER)
|
|
7
|
+
return false;
|
|
8
|
+
return window.matchMedia(reducedMotionQuery).matches;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Indicates that the user has enabled reduced motion on their device.
|
|
12
|
+
*
|
|
13
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
|
|
14
|
+
*/
|
|
15
|
+
export const prefersReducedMotionStore = readable(prefersReducedMotion(), (set) => {
|
|
16
|
+
if (BROWSER) {
|
|
17
|
+
const setReducedMotion = (event) => {
|
|
18
|
+
set(event.matches);
|
|
19
|
+
};
|
|
20
|
+
const mediaQueryList = window.matchMedia(reducedMotionQuery);
|
|
21
|
+
mediaQueryList.addEventListener('change', setReducedMotion);
|
|
22
|
+
return () => {
|
|
23
|
+
mediaQueryList.removeEventListener('change', setReducedMotion);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script>import { fade } from "svelte/transition";
|
|
2
|
+
import { tocStore, tocActiveId } from "./stores.js";
|
|
3
|
+
export let inactive = "opacity-60 hover:opacity-100";
|
|
4
|
+
export let active = "text-primary-500";
|
|
5
|
+
export let activeId = "";
|
|
6
|
+
export let indentStyles = {
|
|
7
|
+
h2: "",
|
|
8
|
+
h3: "ml-4",
|
|
9
|
+
h4: "ml-8",
|
|
10
|
+
h5: "ml-12",
|
|
11
|
+
h6: "ml-16"
|
|
12
|
+
};
|
|
13
|
+
export let regionLead = "font-bold";
|
|
14
|
+
export let regionList = "";
|
|
15
|
+
export let regionListItem = "";
|
|
16
|
+
export let regionAnchor = "";
|
|
17
|
+
const cBase = "space-y-4";
|
|
18
|
+
const cList = "space-y-2";
|
|
19
|
+
const cListItem = "block";
|
|
20
|
+
const cAnchor = "";
|
|
21
|
+
$:
|
|
22
|
+
reactiveActiveId = $tocActiveId ? $tocActiveId : activeId.replace("#", "");
|
|
23
|
+
$:
|
|
24
|
+
classesBase = `${cBase} ${$$props.class ?? ""}`;
|
|
25
|
+
$:
|
|
26
|
+
classesList = `${cList} ${regionList}`;
|
|
27
|
+
$:
|
|
28
|
+
classesListItem = `${cListItem} ${regionListItem}`;
|
|
29
|
+
$:
|
|
30
|
+
classesAnchor = `${cAnchor} ${regionAnchor}`;
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
{#if $tocStore.length}
|
|
34
|
+
<nav class="toc {classesBase}" data-testid="toc" transition:fade|local={{ duration: 100 }}>
|
|
35
|
+
<!-- Slot: Default (title) -->
|
|
36
|
+
<div class={regionLead}>
|
|
37
|
+
<slot>Table of Contents</slot>
|
|
38
|
+
</div>
|
|
39
|
+
<!-- List -->
|
|
40
|
+
<ul class="toc-list {classesList}">
|
|
41
|
+
{#each $tocStore as tocHeading}
|
|
42
|
+
<li class="toc-list-item {classesListItem} {indentStyles[tocHeading.element]}">
|
|
43
|
+
<a
|
|
44
|
+
href="#{tocHeading.id}"
|
|
45
|
+
class="toc-anchor {classesAnchor} {tocHeading.id === reactiveActiveId ? active : inactive}"
|
|
46
|
+
on:click={() => {
|
|
47
|
+
reactiveActiveId = tocHeading.id;
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
{tocHeading.text}
|
|
51
|
+
</a>
|
|
52
|
+
</li>
|
|
53
|
+
{/each}
|
|
54
|
+
</ul>
|
|
55
|
+
</nav>
|
|
56
|
+
{/if}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
/** Provide classes to set the inactive anchor styles.*/
|
|
6
|
+
inactive?: string | undefined;
|
|
7
|
+
/** Provide classes to set the active anchor styles.*/
|
|
8
|
+
active?: string | undefined;
|
|
9
|
+
/** Set the active permalink ID on load.*/
|
|
10
|
+
activeId?: string | undefined;
|
|
11
|
+
/** Set indentation per each queried element.*/
|
|
12
|
+
indentStyles?: Record<string, string> | undefined;
|
|
13
|
+
/** Provide arbitrary classes to the lead regions, used for titles.*/
|
|
14
|
+
regionLead?: string | undefined;
|
|
15
|
+
/** Provide arbitrary classes to style the list element.*/
|
|
16
|
+
regionList?: string | undefined;
|
|
17
|
+
/** Provide arbitrary classes to style the list item elements.*/
|
|
18
|
+
regionListItem?: string | undefined;
|
|
19
|
+
/** Provide arbitrary classes to style the anchor elements.*/
|
|
20
|
+
regionAnchor?: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
events: {
|
|
23
|
+
[evt: string]: CustomEvent<any>;
|
|
24
|
+
};
|
|
25
|
+
slots: {
|
|
26
|
+
default: {};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export type TableOfContentsProps = typeof __propDef.props;
|
|
30
|
+
export type TableOfContentsEvents = typeof __propDef.events;
|
|
31
|
+
export type TableOfContentsSlots = typeof __propDef.slots;
|
|
32
|
+
export default class TableOfContents extends SvelteComponentTyped<TableOfContentsProps, TableOfContentsEvents, TableOfContentsSlots> {
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface TOCCrawlerArgs {
|
|
2
|
+
/** Set generate mode to automatically set heading IDs. */
|
|
3
|
+
mode?: 'generate' | undefined;
|
|
4
|
+
/** Provide query list of elements. Defaults h2-h6. */
|
|
5
|
+
queryElements?: string;
|
|
6
|
+
scrollTarget?: string;
|
|
7
|
+
/** Reload the action when this key value changes. */
|
|
8
|
+
key?: unknown;
|
|
9
|
+
}
|
|
10
|
+
export declare function tocCrawler(node: HTMLElement, args?: TOCCrawlerArgs): {
|
|
11
|
+
update(newArgs: TOCCrawlerArgs): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
};
|
|
14
|
+
export {};
|