@skeletonlabs/skeleton 2.9.2 → 3.0.0-next.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.
Files changed (177) hide show
  1. package/dist/core/index.d.ts +2 -0
  2. package/dist/core/index.js +1 -0
  3. package/dist/core/index.js.map +1 -0
  4. package/dist/plugin/index.cjs +419 -0
  5. package/dist/plugin/index.cjs.map +1 -0
  6. package/dist/plugin/index.d.ts +270 -0
  7. package/dist/themes/index.d.ts +1117 -0
  8. package/dist/themes/index.js +935 -0
  9. package/dist/themes/index.js.map +1 -0
  10. package/package.json +31 -50
  11. package/README.md +0 -38
  12. package/dist/actions/Clipboard/clipboard.d.ts +0 -11
  13. package/dist/actions/Clipboard/clipboard.js +0 -64
  14. package/dist/actions/Filters/filter.d.ts +0 -6
  15. package/dist/actions/Filters/filter.js +0 -16
  16. package/dist/actions/Filters/svg-filters/Apollo.svelte +0 -13
  17. package/dist/actions/Filters/svg-filters/Apollo.svelte.d.ts +0 -23
  18. package/dist/actions/Filters/svg-filters/BlueNight.svelte +0 -12
  19. package/dist/actions/Filters/svg-filters/BlueNight.svelte.d.ts +0 -23
  20. package/dist/actions/Filters/svg-filters/Emerald.svelte +0 -23
  21. package/dist/actions/Filters/svg-filters/Emerald.svelte.d.ts +0 -23
  22. package/dist/actions/Filters/svg-filters/GreenFall.svelte +0 -27
  23. package/dist/actions/Filters/svg-filters/GreenFall.svelte.d.ts +0 -23
  24. package/dist/actions/Filters/svg-filters/Noir.svelte +0 -17
  25. package/dist/actions/Filters/svg-filters/Noir.svelte.d.ts +0 -23
  26. package/dist/actions/Filters/svg-filters/NoirLight.svelte +0 -19
  27. package/dist/actions/Filters/svg-filters/NoirLight.svelte.d.ts +0 -23
  28. package/dist/actions/Filters/svg-filters/Rustic.svelte +0 -14
  29. package/dist/actions/Filters/svg-filters/Rustic.svelte.d.ts +0 -23
  30. package/dist/actions/Filters/svg-filters/Summer84.svelte +0 -12
  31. package/dist/actions/Filters/svg-filters/Summer84.svelte.d.ts +0 -23
  32. package/dist/actions/Filters/svg-filters/XPro.svelte +0 -12
  33. package/dist/actions/Filters/svg-filters/XPro.svelte.d.ts +0 -23
  34. package/dist/actions/FocusTrap/focusTrap.d.ts +0 -4
  35. package/dist/actions/FocusTrap/focusTrap.js +0 -89
  36. package/dist/components/Accordion/Accordion.svelte +0 -49
  37. package/dist/components/Accordion/Accordion.svelte.d.ts +0 -56
  38. package/dist/components/Accordion/AccordionItem.svelte +0 -126
  39. package/dist/components/Accordion/AccordionItem.svelte.d.ts +0 -73
  40. package/dist/components/AppBar/AppBar.svelte +0 -53
  41. package/dist/components/AppBar/AppBar.svelte.d.ts +0 -49
  42. package/dist/components/AppRail/AppRail.svelte +0 -41
  43. package/dist/components/AppRail/AppRail.svelte.d.ts +0 -45
  44. package/dist/components/AppRail/AppRailAnchor.svelte +0 -46
  45. package/dist/components/AppRail/AppRailAnchor.svelte.d.ts +0 -38
  46. package/dist/components/AppRail/AppRailTile.svelte +0 -60
  47. package/dist/components/AppRail/AppRailTile.svelte.d.ts +0 -45
  48. package/dist/components/AppShell/AppShell.svelte +0 -72
  49. package/dist/components/AppShell/AppShell.svelte.d.ts +0 -50
  50. package/dist/components/Autocomplete/Autocomplete.svelte +0 -98
  51. package/dist/components/Autocomplete/Autocomplete.svelte.d.ts +0 -58
  52. package/dist/components/Autocomplete/types.d.ts +0 -10
  53. package/dist/components/Autocomplete/types.js +0 -2
  54. package/dist/components/Avatar/Avatar.svelte +0 -54
  55. package/dist/components/Avatar/Avatar.svelte.d.ts +0 -50
  56. package/dist/components/ConicGradient/ConicGradient.svelte +0 -77
  57. package/dist/components/ConicGradient/ConicGradient.svelte.d.ts +0 -42
  58. package/dist/components/ConicGradient/settings.d.ts +0 -9
  59. package/dist/components/ConicGradient/settings.js +0 -334
  60. package/dist/components/ConicGradient/types.d.ts +0 -10
  61. package/dist/components/ConicGradient/types.js +0 -2
  62. package/dist/components/FileButton/FileButton.svelte +0 -37
  63. package/dist/components/FileButton/FileButton.svelte.d.ts +0 -33
  64. package/dist/components/FileDropzone/FileDropzone.svelte +0 -63
  65. package/dist/components/FileDropzone/FileDropzone.svelte.d.ts +0 -55
  66. package/dist/components/InputChip/InputChip.svelte +0 -203
  67. package/dist/components/InputChip/InputChip.svelte.d.ts +0 -114
  68. package/dist/components/ListBox/ListBox.svelte +0 -29
  69. package/dist/components/ListBox/ListBox.svelte.d.ts +0 -40
  70. package/dist/components/ListBox/ListBoxItem.svelte +0 -117
  71. package/dist/components/ListBox/ListBoxItem.svelte.d.ts +0 -41
  72. package/dist/components/Paginator/Paginator.svelte +0 -190
  73. package/dist/components/Paginator/Paginator.svelte.d.ts +0 -68
  74. package/dist/components/Paginator/icons.d.ts +0 -4
  75. package/dist/components/Paginator/icons.js +0 -4
  76. package/dist/components/Paginator/types.d.ts +0 -10
  77. package/dist/components/Paginator/types.js +0 -2
  78. package/dist/components/ProgressBar/ProgressBar.svelte +0 -50
  79. package/dist/components/ProgressBar/ProgressBar.svelte.d.ts +0 -36
  80. package/dist/components/ProgressRadial/ProgressRadial.svelte +0 -73
  81. package/dist/components/ProgressRadial/ProgressRadial.svelte.d.ts +0 -38
  82. package/dist/components/Radio/RadioGroup.svelte +0 -29
  83. package/dist/components/Radio/RadioGroup.svelte.d.ts +0 -44
  84. package/dist/components/Radio/RadioItem.svelte +0 -61
  85. package/dist/components/Radio/RadioItem.svelte.d.ts +0 -41
  86. package/dist/components/RangeSlider/RangeSlider.svelte +0 -72
  87. package/dist/components/RangeSlider/RangeSlider.svelte.d.ts +0 -41
  88. package/dist/components/Ratings/Ratings.svelte +0 -52
  89. package/dist/components/Ratings/Ratings.svelte.d.ts +0 -41
  90. package/dist/components/SlideToggle/SlideToggle.svelte +0 -91
  91. package/dist/components/SlideToggle/SlideToggle.svelte.d.ts +0 -44
  92. package/dist/components/Stepper/Step.svelte +0 -97
  93. package/dist/components/Stepper/Step.svelte.d.ts +0 -56
  94. package/dist/components/Stepper/Stepper.svelte +0 -107
  95. package/dist/components/Stepper/Stepper.svelte.d.ts +0 -85
  96. package/dist/components/Stepper/types.d.ts +0 -25
  97. package/dist/components/Stepper/types.js +0 -1
  98. package/dist/components/Tab/Tab.svelte +0 -95
  99. package/dist/components/Tab/Tab.svelte.d.ts +0 -49
  100. package/dist/components/Tab/TabAnchor.svelte +0 -44
  101. package/dist/components/Tab/TabAnchor.svelte.d.ts +0 -44
  102. package/dist/components/Tab/TabGroup.svelte +0 -44
  103. package/dist/components/Tab/TabGroup.svelte.d.ts +0 -48
  104. package/dist/components/Table/Table.svelte +0 -86
  105. package/dist/components/Table/Table.svelte.d.ts +0 -42
  106. package/dist/components/Table/actions.d.ts +0 -8
  107. package/dist/components/Table/actions.js +0 -114
  108. package/dist/components/Table/types.d.ts +0 -10
  109. package/dist/components/Table/types.js +0 -1
  110. package/dist/components/Table/utils.d.ts +0 -7
  111. package/dist/components/Table/utils.js +0 -33
  112. package/dist/components/TreeView/RecursiveTreeView.svelte +0 -64
  113. package/dist/components/TreeView/RecursiveTreeView.svelte.d.ts +0 -63
  114. package/dist/components/TreeView/RecursiveTreeViewItem.svelte +0 -141
  115. package/dist/components/TreeView/RecursiveTreeViewItem.svelte.d.ts +0 -38
  116. package/dist/components/TreeView/TreeView.svelte +0 -68
  117. package/dist/components/TreeView/TreeView.svelte.d.ts +0 -55
  118. package/dist/components/TreeView/TreeViewItem.svelte +0 -319
  119. package/dist/components/TreeView/TreeViewItem.svelte.d.ts +0 -145
  120. package/dist/components/TreeView/types.d.ts +0 -17
  121. package/dist/components/TreeView/types.js +0 -1
  122. package/dist/index.d.ts +0 -75
  123. package/dist/index.js +0 -79
  124. package/dist/internal/transitions.d.ts +0 -10
  125. package/dist/internal/transitions.js +0 -11
  126. package/dist/transitions/crossfade.d.ts +0 -1
  127. package/dist/transitions/crossfade.js +0 -21
  128. package/dist/types.d.ts +0 -8
  129. package/dist/types.js +0 -1
  130. package/dist/utilities/CodeBlock/CodeBlock.svelte +0 -70
  131. package/dist/utilities/CodeBlock/CodeBlock.svelte.d.ts +0 -43
  132. package/dist/utilities/CodeBlock/stores.d.ts +0 -2
  133. package/dist/utilities/CodeBlock/stores.js +0 -3
  134. package/dist/utilities/Drawer/Drawer.svelte +0 -182
  135. package/dist/utilities/Drawer/Drawer.svelte.d.ts +0 -62
  136. package/dist/utilities/Drawer/stores.d.ts +0 -34
  137. package/dist/utilities/Drawer/stores.js +0 -50
  138. package/dist/utilities/Drawer/types.d.ts +0 -42
  139. package/dist/utilities/Drawer/types.js +0 -2
  140. package/dist/utilities/LightSwitch/LightSwitch.svelte +0 -78
  141. package/dist/utilities/LightSwitch/LightSwitch.svelte.d.ts +0 -39
  142. package/dist/utilities/LightSwitch/lightswitch.d.ts +0 -21
  143. package/dist/utilities/LightSwitch/lightswitch.js +0 -72
  144. package/dist/utilities/LocalStorageStore/LocalStorageStore.d.ts +0 -12
  145. package/dist/utilities/LocalStorageStore/LocalStorageStore.js +0 -49
  146. package/dist/utilities/Modal/Modal.svelte +0 -247
  147. package/dist/utilities/Modal/Modal.svelte.d.ts +0 -72
  148. package/dist/utilities/Modal/ModalTest.svelte +0 -8
  149. package/dist/utilities/Modal/ModalTest.svelte.d.ts +0 -17
  150. package/dist/utilities/Modal/stores.d.ts +0 -36
  151. package/dist/utilities/Modal/stores.js +0 -54
  152. package/dist/utilities/Modal/types.d.ts +0 -41
  153. package/dist/utilities/Modal/types.js +0 -2
  154. package/dist/utilities/Popup/popup.d.ts +0 -7
  155. package/dist/utilities/Popup/popup.js +0 -240
  156. package/dist/utilities/Popup/types.d.ts +0 -40
  157. package/dist/utilities/Popup/types.js +0 -2
  158. package/dist/utilities/PrefersReducedMotion/PrefersReducedMotion.d.ts +0 -7
  159. package/dist/utilities/PrefersReducedMotion/PrefersReducedMotion.js +0 -26
  160. package/dist/utilities/TableOfContents/TableOfContents.svelte +0 -56
  161. package/dist/utilities/TableOfContents/TableOfContents.svelte.d.ts +0 -34
  162. package/dist/utilities/TableOfContents/crawler.d.ts +0 -16
  163. package/dist/utilities/TableOfContents/crawler.js +0 -78
  164. package/dist/utilities/TableOfContents/stores.d.ts +0 -6
  165. package/dist/utilities/TableOfContents/stores.js +0 -5
  166. package/dist/utilities/TableOfContents/types.d.ts +0 -5
  167. package/dist/utilities/TableOfContents/types.js +0 -2
  168. package/dist/utilities/Toast/Toast.svelte +0 -150
  169. package/dist/utilities/Toast/Toast.svelte.d.ts +0 -55
  170. package/dist/utilities/Toast/ToastTest.svelte +0 -16
  171. package/dist/utilities/Toast/ToastTest.svelte.d.ts +0 -20
  172. package/dist/utilities/Toast/stores.d.ts +0 -37
  173. package/dist/utilities/Toast/stores.js +0 -107
  174. package/dist/utilities/Toast/types.d.ts +0 -35
  175. package/dist/utilities/Toast/types.js +0 -2
  176. package/dist/utilities/index.d.ts +0 -18
  177. package/dist/utilities/index.js +0 -25
@@ -1,72 +0,0 @@
1
- // Lightswitch Service
2
- import { get } from 'svelte/store';
3
- // DO NOT replace this ⬇ import, it has to be imported directly
4
- import { localStorageStore } from '../LocalStorageStore/LocalStorageStore.js';
5
- // Stores ---
6
- // TRUE: light, FALSE: dark
7
- /** Store: OS Preference Mode */
8
- export const modeOsPrefers = localStorageStore('modeOsPrefers', false);
9
- /** Store: User Preference Mode */
10
- export const modeUserPrefers = localStorageStore('modeUserPrefers', undefined);
11
- /** Store: Current Mode State */
12
- export const modeCurrent = localStorageStore('modeCurrent', false);
13
- // Get ---
14
- /** Get the OS Preference for light/dark mode */
15
- export function getModeOsPrefers() {
16
- const prefersLightMode = window.matchMedia('(prefers-color-scheme: light)').matches;
17
- modeOsPrefers.set(prefersLightMode);
18
- return prefersLightMode;
19
- }
20
- /** Get the User for light/dark mode */
21
- export function getModeUserPrefers() {
22
- return get(modeUserPrefers);
23
- }
24
- /** Get the Automatic Preference light/dark mode */
25
- export function getModeAutoPrefers() {
26
- const os = getModeOsPrefers();
27
- const user = getModeUserPrefers();
28
- const modeValue = user !== undefined ? user : os;
29
- return modeValue;
30
- }
31
- // Set ---
32
- /** Set the User Preference for light/dark mode */
33
- export function setModeUserPrefers(value) {
34
- modeUserPrefers.set(value);
35
- }
36
- /** Set the the current light/dark mode */
37
- export function setModeCurrent(value) {
38
- const elemHtmlClasses = document.documentElement.classList;
39
- const classDark = `dark`;
40
- value === true ? elemHtmlClasses.remove(classDark) : elemHtmlClasses.add(classDark);
41
- modeCurrent.set(value);
42
- }
43
- // Lightswitch Utility
44
- /** Set the visible light/dark mode on page load. */
45
- export function setInitialClassState() {
46
- const elemHtmlClasses = document.documentElement.classList;
47
- // Conditions
48
- const condLocalStorageUserPrefs = localStorage.getItem('modeUserPrefers') === 'false';
49
- const condLocalStorageUserPrefsExists = !('modeUserPrefers' in localStorage);
50
- const condMatchMedia = window.matchMedia('(prefers-color-scheme: dark)').matches;
51
- // Add/remove `.dark` class to HTML element
52
- if (condLocalStorageUserPrefs || (condLocalStorageUserPrefsExists && condMatchMedia)) {
53
- elemHtmlClasses.add('dark');
54
- }
55
- else {
56
- elemHtmlClasses.remove('dark');
57
- }
58
- }
59
- // Auto-Switch Utility
60
- /** Automatically set the visible light/dark, updates on change. */
61
- export function autoModeWatcher() {
62
- const mql = window.matchMedia('(prefers-color-scheme: light)');
63
- function setMode(value) {
64
- const elemHtmlClasses = document.documentElement.classList;
65
- const classDark = `dark`;
66
- value === true ? elemHtmlClasses.remove(classDark) : elemHtmlClasses.add(classDark);
67
- }
68
- setMode(mql.matches);
69
- mql.onchange = () => {
70
- setMode(mql.matches);
71
- };
72
- }
@@ -1,12 +0,0 @@
1
- import { type Writable } from 'svelte/store';
2
- interface Serializer<T> {
3
- parse(text: string): T;
4
- stringify(object: T): string;
5
- }
6
- type StorageType = 'local' | 'session';
7
- interface Options<T> {
8
- serializer?: Serializer<T>;
9
- storage?: StorageType;
10
- }
11
- export declare function localStorageStore<T>(key: string, initialValue: T, options?: Options<T>): Writable<T>;
12
- export {};
@@ -1,49 +0,0 @@
1
- // Source: https://github.com/joshnuss/svelte-local-storage-store
2
- // https://github.com/joshnuss/svelte-local-storage-store/blob/master/index.ts
3
- // Represents version v0.4.0 (2023-01-18)
4
- import { BROWSER } from 'esm-env';
5
- import { writable as internal, get } from 'svelte/store';
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- const stores = {};
8
- function getStorage(type) {
9
- return type === 'local' ? localStorage : sessionStorage;
10
- }
11
- export function localStorageStore(key, initialValue, options) {
12
- const serializer = options?.serializer ?? JSON;
13
- const storageType = options?.storage ?? 'local';
14
- function updateStorage(key, value) {
15
- if (!BROWSER)
16
- return;
17
- getStorage(storageType).setItem(key, serializer.stringify(value));
18
- }
19
- if (!stores[key]) {
20
- const store = internal(initialValue, (set) => {
21
- const json = BROWSER ? getStorage(storageType).getItem(key) : null;
22
- if (json) {
23
- set(serializer.parse(json));
24
- }
25
- if (BROWSER) {
26
- const handleStorage = (event) => {
27
- if (event.key === key)
28
- set(event.newValue ? serializer.parse(event.newValue) : null);
29
- };
30
- window.addEventListener('storage', handleStorage);
31
- return () => window.removeEventListener('storage', handleStorage);
32
- }
33
- });
34
- const { subscribe, set } = store;
35
- stores[key] = {
36
- set(value) {
37
- updateStorage(key, value);
38
- set(value);
39
- },
40
- update(updater) {
41
- const value = updater(get(store));
42
- updateStorage(key, value);
43
- set(value);
44
- },
45
- subscribe
46
- };
47
- }
48
- return stores[key];
49
- }
@@ -1,247 +0,0 @@
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";
7
- const dispatch = createEventDispatcher();
8
- import { focusTrap } from "../../actions/FocusTrap/focusTrap.js";
9
- import { getModalStore } from "./stores.js";
10
- export let components = {};
11
- export let position = "items-center";
12
- export let background = "bg-surface-100-800-token";
13
- export let width = "w-modal";
14
- export let height = "h-auto";
15
- export let padding = "p-4";
16
- export let spacing = "space-y-4";
17
- export let rounded = "rounded-container-token";
18
- export let shadow = "shadow-xl";
19
- export let zIndex = "z-[999]";
20
- export let buttonNeutral = "variant-ghost-surface";
21
- export let buttonPositive = "variant-filled";
22
- export let buttonTextCancel = "Cancel";
23
- export let buttonTextConfirm = "Confirm";
24
- export let buttonTextSubmit = "Submit";
25
- export let regionBackdrop = "";
26
- export let regionHeader = "text-2xl font-bold";
27
- export let regionBody = "max-h-[200px] overflow-hidden";
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 };
34
- const cBackdrop = "fixed top-0 left-0 right-0 bottom-0 bg-surface-backdrop-token p-4";
35
- const cTransitionLayer = "w-full h-fit min-h-full overflow-y-auto flex justify-center";
36
- const cModal = "block overflow-y-auto";
37
- const cModalImage = "w-full h-auto";
38
- let promptValue;
39
- const buttonTextDefaults = {
40
- buttonTextCancel,
41
- buttonTextConfirm,
42
- buttonTextSubmit
43
- };
44
- let currentComponent;
45
- let registeredInteractionWithBackdrop = false;
46
- let modalElement;
47
- let windowHeight;
48
- let backdropOverflow = "overflow-y-hidden";
49
- const modalStore = getModalStore();
50
- $:
51
- if ($modalStore.length)
52
- handleModals($modalStore);
53
- function handleModals(modals) {
54
- if (modals[0].type === "prompt")
55
- promptValue = modals[0].value;
56
- buttonTextCancel = modals[0].buttonTextCancel || buttonTextDefaults.buttonTextCancel;
57
- buttonTextConfirm = modals[0].buttonTextConfirm || buttonTextDefaults.buttonTextConfirm;
58
- buttonTextSubmit = modals[0].buttonTextSubmit || buttonTextDefaults.buttonTextSubmit;
59
- currentComponent = typeof modals[0].component === "string" ? components[modals[0].component] : modals[0].component;
60
- }
61
- function onModalHeightChange(modal) {
62
- let modalHeight = modal?.clientHeight;
63
- if (!modalHeight)
64
- modalHeight = modal?.firstChild?.clientHeight;
65
- if (!modalHeight)
66
- return;
67
- if (modalHeight > windowHeight) {
68
- backdropOverflow = "overflow-y-auto";
69
- } else {
70
- backdropOverflow = "overflow-y-hidden";
71
- }
72
- }
73
- $:
74
- onModalHeightChange(modalElement);
75
- function onBackdropInteractionBegin(event) {
76
- if (!(event.target instanceof Element))
77
- return;
78
- const classList = event.target.classList;
79
- if (classList.contains("modal-backdrop") || classList.contains("modal-transition")) {
80
- registeredInteractionWithBackdrop = true;
81
- }
82
- }
83
- function onBackdropInteractionEnd(event) {
84
- if (!(event.target instanceof Element))
85
- return;
86
- const classList = event.target.classList;
87
- if ((classList.contains("modal-backdrop") || classList.contains("modal-transition")) && registeredInteractionWithBackdrop) {
88
- if ($modalStore[0].response)
89
- $modalStore[0].response(void 0);
90
- modalStore.close();
91
- dispatch("backdrop", event);
92
- }
93
- registeredInteractionWithBackdrop = false;
94
- }
95
- function onClose() {
96
- if ($modalStore[0].response)
97
- $modalStore[0].response(false);
98
- modalStore.close();
99
- }
100
- function onConfirm() {
101
- if ($modalStore[0].response)
102
- $modalStore[0].response(true);
103
- modalStore.close();
104
- }
105
- function onPromptSubmit(event) {
106
- event.preventDefault();
107
- if ($modalStore[0].response) {
108
- if ($modalStore[0].valueAttr !== void 0 && "type" in $modalStore[0].valueAttr && $modalStore[0].valueAttr.type === "number")
109
- $modalStore[0].response(parseInt(promptValue));
110
- else
111
- $modalStore[0].response(promptValue);
112
- }
113
- modalStore.close();
114
- }
115
- function onKeyDown(event) {
116
- if (!$modalStore.length)
117
- return;
118
- if (event.code === "Escape")
119
- onClose();
120
- }
121
- $:
122
- cPosition = $modalStore[0]?.position ?? position;
123
- $:
124
- classesBackdrop = `${cBackdrop} ${regionBackdrop} ${zIndex} ${$$props.class ?? ""} ${$modalStore[0]?.backdropClasses ?? ""}`;
125
- $:
126
- classesTransitionLayer = `${cTransitionLayer} ${cPosition ?? ""}`;
127
- $:
128
- classesModal = `${cModal} ${background} ${width} ${height} ${padding} ${spacing} ${rounded} ${shadow} ${$modalStore[0]?.modalClasses ?? ""}`;
129
- $:
130
- parent = {
131
- position,
132
- // ---
133
- background,
134
- width,
135
- height,
136
- padding,
137
- spacing,
138
- rounded,
139
- shadow,
140
- // ---
141
- buttonNeutral,
142
- buttonPositive,
143
- buttonTextCancel,
144
- buttonTextConfirm,
145
- buttonTextSubmit,
146
- // ---
147
- regionBackdrop,
148
- regionHeader,
149
- regionBody,
150
- regionFooter,
151
- // ---
152
- onClose
153
- };
154
- </script>
155
-
156
- <svelte:window bind:innerHeight={windowHeight} on:keydown={onKeyDown} />
157
-
158
- {#if $modalStore.length > 0}
159
- {#key $modalStore}
160
- <!-- Backdrop -->
161
- <!-- FIXME: resolve a11y warnings -->
162
- <!-- svelte-ignore a11y-no-static-element-interactions -->
163
- <div
164
- class="modal-backdrop {classesBackdrop} {backdropOverflow}"
165
- data-testid="modal-backdrop"
166
- on:mousedown={onBackdropInteractionBegin}
167
- on:mouseup={onBackdropInteractionEnd}
168
- on:touchstart|passive
169
- on:touchend|passive
170
- transition:dynamicTransition|global={{ transition: fade, params: { duration: 150 }, enabled: transitions }}
171
- use:focusTrap={true}
172
- >
173
- <!-- Transition Layer -->
174
- <div
175
- class="modal-transition {classesTransitionLayer}"
176
- in:dynamicTransition|global={{ transition: transitionIn, params: transitionInParams, enabled: transitions }}
177
- out:dynamicTransition|global={{ transition: transitionOut, params: transitionOutParams, enabled: transitions }}
178
- >
179
- {#if $modalStore[0].type !== 'component'}
180
- <!-- Modal: Presets -->
181
- <div
182
- class="modal {classesModal}"
183
- bind:this={modalElement}
184
- data-testid="modal"
185
- role="dialog"
186
- aria-modal="true"
187
- aria-label={$modalStore[0].title ?? ''}
188
- >
189
- <!-- Header -->
190
- {#if $modalStore[0]?.title}
191
- <header class="modal-header {regionHeader}">{@html $modalStore[0].title}</header>
192
- {/if}
193
- <!-- Body -->
194
- {#if $modalStore[0]?.body}
195
- <article class="modal-body {regionBody}">{@html $modalStore[0].body}</article>
196
- {/if}
197
- <!-- Image -->
198
- {#if $modalStore[0]?.image && typeof $modalStore[0]?.image === 'string'}
199
- <img class="modal-image {cModalImage}" src={$modalStore[0]?.image} alt="Modal" />
200
- {/if}
201
- <!-- Type -->
202
- {#if $modalStore[0].type === 'alert'}
203
- <!-- Template: Alert -->
204
- <footer class="modal-footer {regionFooter}">
205
- <button type="button" class="btn {buttonNeutral}" on:click={onClose}>{buttonTextCancel}</button>
206
- </footer>
207
- {:else if $modalStore[0].type === 'confirm'}
208
- <!-- Template: Confirm -->
209
- <footer class="modal-footer {regionFooter}">
210
- <button type="button" class="btn {buttonNeutral}" on:click={onClose}>{buttonTextCancel}</button>
211
- <button type="button" class="btn {buttonPositive}" on:click={onConfirm}>{buttonTextConfirm}</button>
212
- </footer>
213
- {:else if $modalStore[0].type === 'prompt'}
214
- <!-- Template: Prompt -->
215
- <form class="space-y-4" on:submit={onPromptSubmit}>
216
- <input class="modal-prompt-input input" name="prompt" type="text" bind:value={promptValue} {...$modalStore[0].valueAttr} />
217
- <footer class="modal-footer {regionFooter}">
218
- <button type="button" class="btn {buttonNeutral}" on:click={onClose}>{buttonTextCancel}</button>
219
- <button type="submit" class="btn {buttonPositive}">{buttonTextSubmit}</button>
220
- </footer>
221
- </form>
222
- {/if}
223
- </div>
224
- {:else}
225
- <!-- Modal: Components -->
226
- <!-- Note: keep `contents` class to allow widths from children -->
227
- <div
228
- bind:this={modalElement}
229
- class="modal contents {$modalStore[0]?.modalClasses ?? ''}"
230
- data-testid="modal-component"
231
- role="dialog"
232
- aria-modal="true"
233
- aria-label={$modalStore[0].title ?? ''}
234
- >
235
- {#if currentComponent?.slot}
236
- <svelte:component this={currentComponent?.ref} {...currentComponent?.props} {parent}>
237
- {@html currentComponent?.slot}
238
- </svelte:component>
239
- {:else}
240
- <svelte:component this={currentComponent?.ref} {...currentComponent?.props} {parent} />
241
- {/if}
242
- </div>
243
- {/if}
244
- </div>
245
- </div>
246
- {/key}
247
- {/if}
@@ -1,72 +0,0 @@
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;
5
- import type { ModalComponent } from './types.js';
6
- declare class __sveltets_Render<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> {
7
- props(): {
8
- [x: string]: any;
9
- /** Register a list of reusable component modals.*/
10
- components?: Record<string, ModalComponent> | undefined;
11
- /** Set the modal position within the backdrop container*/
12
- position?: string | undefined;
13
- /** Provide classes to style the modal background.*/
14
- background?: string | undefined;
15
- /** Provide classes to style the modal width.*/
16
- width?: string | undefined;
17
- /** Provide classes to style the modal height.*/
18
- height?: string | undefined;
19
- /** Provide classes to style the modal padding.*/
20
- padding?: string | undefined;
21
- /** Provide classes to style the modal spacing.*/
22
- spacing?: string | undefined;
23
- /** Provide classes to style the modal border radius.*/
24
- rounded?: string | undefined;
25
- /** Provide classes to style modal box shadow.*/
26
- shadow?: string | undefined;
27
- /** Provide a class to override the z-index*/
28
- zIndex?: string | undefined;
29
- /** Provide classes for neutral buttons, such as Cancel.*/
30
- buttonNeutral?: string | undefined;
31
- /** Provide classes for positive actions, such as Confirm or Submit.*/
32
- buttonPositive?: string | undefined;
33
- /** Override the text for the Cancel button.*/
34
- buttonTextCancel?: string | undefined;
35
- /** Override the text for the Confirm button.*/
36
- buttonTextConfirm?: string | undefined;
37
- /** Override the text for the Submit button.*/
38
- buttonTextSubmit?: string | undefined;
39
- /** Provide arbitrary classes to the backdrop region.*/
40
- regionBackdrop?: string | undefined;
41
- /** Provide arbitrary classes to modal header region.*/
42
- regionHeader?: string | undefined;
43
- /** Provide arbitrary classes to modal body region.*/
44
- regionBody?: string | undefined;
45
- /** Provide arbitrary classes to modal footer region.*/
46
- regionFooter?: string | undefined;
47
- /** Enable/Disable transitions*/
48
- transitions?: boolean | undefined;
49
- /** Provide the transition used on entry.*/
50
- transitionIn?: TransitionIn | undefined;
51
- /** Transition params provided to `TransitionIn`.*/
52
- transitionInParams?: TransitionParams<TransitionIn> | undefined;
53
- /** Provide the transition used on exit.*/
54
- transitionOut?: TransitionOut | undefined;
55
- /** Transition params provided to `TransitionOut`.*/
56
- transitionOutParams?: TransitionParams<TransitionOut> | undefined;
57
- };
58
- events(): {
59
- touchstart: TouchEvent;
60
- touchend: TouchEvent;
61
- backdrop: CustomEvent<MouseEvent>;
62
- } & {
63
- [evt: string]: CustomEvent<any>;
64
- };
65
- slots(): {};
66
- }
67
- export type ModalProps<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['props']>;
68
- export type ModalEvents<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['events']>;
69
- export type ModalSlots<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['slots']>;
70
- export default class Modal<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> extends SvelteComponentTyped<ModalProps<TransitionIn, TransitionOut>, ModalEvents<TransitionIn, TransitionOut>, ModalSlots<TransitionIn, TransitionOut>> {
71
- }
72
- export {};
@@ -1,8 +0,0 @@
1
- <script>import { initializeModalStore, getModalStore } from "./stores.js";
2
- import Modal from "./Modal.svelte";
3
- export let modalSetting;
4
- initializeModalStore();
5
- getModalStore().trigger(modalSetting);
6
- </script>
7
-
8
- <Modal />
@@ -1,17 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- import type { ModalSettings } from './types.js';
3
- declare const __propDef: {
4
- props: {
5
- modalSetting: ModalSettings;
6
- };
7
- events: {
8
- [evt: string]: CustomEvent<any>;
9
- };
10
- slots: {};
11
- };
12
- export type ModalTestProps = typeof __propDef.props;
13
- export type ModalTestEvents = typeof __propDef.events;
14
- export type ModalTestSlots = typeof __propDef.slots;
15
- export default class ModalTest extends SvelteComponentTyped<ModalTestProps, ModalTestEvents, ModalTestSlots> {
16
- }
17
- export {};
@@ -1,36 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { ModalSettings } from './types.js';
3
- /**
4
- * Retrieves the `modalStore`.
5
- *
6
- * This can *ONLY* be called from the **top level** of components!
7
- *
8
- * @example
9
- * ```svelte
10
- * <script>
11
- * import { getModalStore } from "@skeletonlabs/skeleton";
12
- *
13
- * const modalStore = getModalStore();
14
- *
15
- * modalStore.trigger({ type: "alert", title: "Welcome!" });
16
- * </script>
17
- * ```
18
- */
19
- export declare function getModalStore(): ModalStore;
20
- /**
21
- * Initializes the `modalStore`.
22
- */
23
- export declare function initializeModalStore(): ModalStore;
24
- export type ModalStore = ReturnType<typeof modalService>;
25
- declare function modalService(): {
26
- subscribe: (this: void, run: import("svelte/store").Subscriber<ModalSettings[]>, invalidate?: import("svelte/store").Invalidator<ModalSettings[]> | undefined) => import("svelte/store").Unsubscriber;
27
- set: (this: void, value: ModalSettings[]) => void;
28
- update: (this: void, updater: import("svelte/store").Updater<ModalSettings[]>) => void;
29
- /** Append to end of queue. */
30
- trigger: (modal: ModalSettings) => void;
31
- /** Remove first item in queue. */
32
- close: () => void;
33
- /** Remove all items from queue. */
34
- clear: () => void;
35
- };
36
- export {};
@@ -1,54 +0,0 @@
1
- // Modal Store Queue
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
- * This can *ONLY* be called from the **top level** of components!
9
- *
10
- * @example
11
- * ```svelte
12
- * <script>
13
- * import { getModalStore } from "@skeletonlabs/skeleton";
14
- *
15
- * const modalStore = getModalStore();
16
- *
17
- * modalStore.trigger({ type: "alert", title: "Welcome!" });
18
- * </script>
19
- * ```
20
- */
21
- export function getModalStore() {
22
- const modalStore = getContext(MODAL_STORE_KEY);
23
- if (!modalStore)
24
- throw new Error('modalStore is not initialized. Please ensure that `initializeStores()` is invoked in the root layout file of this app!');
25
- return modalStore;
26
- }
27
- /**
28
- * Initializes the `modalStore`.
29
- */
30
- export function initializeModalStore() {
31
- const modalStore = modalService();
32
- return setContext(MODAL_STORE_KEY, modalStore);
33
- }
34
- function modalService() {
35
- const { subscribe, set, update } = writable([]);
36
- return {
37
- subscribe,
38
- set,
39
- update,
40
- /** Append to end of queue. */
41
- trigger: (modal) => update((mStore) => {
42
- mStore.push(modal);
43
- return mStore;
44
- }),
45
- /** Remove first item in queue. */
46
- close: () => update((mStore) => {
47
- if (mStore.length > 0)
48
- mStore.shift();
49
- return mStore;
50
- }),
51
- /** Remove all items from queue. */
52
- clear: () => set([])
53
- };
54
- }
@@ -1,41 +0,0 @@
1
- export type { ModalStore } from './stores.js';
2
- export interface ModalComponent {
3
- /** Import and provide your component reference. */
4
- ref: any;
5
- /** Provide component props as key/value pairs. */
6
- props?: Record<string, unknown>;
7
- /** Provide an HTML template literal for the default slot. */
8
- slot?: string;
9
- }
10
- export interface ModalSettings {
11
- /** Designate what type of component will display. */
12
- type: 'alert' | 'confirm' | 'prompt' | 'component';
13
- /** Set the modal position within the backdrop container. */
14
- position?: string;
15
- /** Provide the modal header content. Accepts HTML. */
16
- title?: string;
17
- /** Provide the modal body content. Accepts HTML. */
18
- body?: string;
19
- /** Provide a URL to display an image within the modal. */
20
- image?: string;
21
- /** By default, used to provide a prompt value. */
22
- value?: any;
23
- /** Provide input attributes as key/value pairs. */
24
- valueAttr?: object;
25
- /** Provide your component reference key or object. */
26
- component?: ModalComponent | string;
27
- /** Provide a function. Returns the response value. */
28
- response?: (r: any) => void;
29
- /** Provide arbitrary classes to the backdrop. */
30
- backdropClasses?: string;
31
- /** Provide arbitrary classes to the modal window. */
32
- modalClasses?: string;
33
- /** Override the Cancel button label. */
34
- buttonTextCancel?: string;
35
- /** Override the Confirm button label. */
36
- buttonTextConfirm?: string;
37
- /** Override the Submit button label. */
38
- buttonTextSubmit?: string;
39
- /** Pass arbitrary data per modal instance. */
40
- meta?: any;
41
- }
@@ -1,2 +0,0 @@
1
- // Modal Types
2
- export {};
@@ -1,7 +0,0 @@
1
- import { type Writable } from 'svelte/store';
2
- import type { PopupSettings } from './types.js';
3
- export declare const storePopup: Writable<any>;
4
- export declare function popup(triggerNode: HTMLElement, args: PopupSettings): {
5
- update(newArgs: PopupSettings): void;
6
- destroy(): void;
7
- };