@skeletonlabs/skeleton 0.78.0 → 0.80.8

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 (86) hide show
  1. package/README.md +5 -0
  2. package/actions/Filters/svg-filters/GreenFall.svelte +10 -1
  3. package/actions/Filters/svg-filters/Noir.svelte +21 -2
  4. package/actions/Filters/svg-filters/NoirLight.svelte +10 -1
  5. package/actions/FocusTrap/focusTrap.js +16 -5
  6. package/components/Accordion/AccordionGroup.svelte +1 -1
  7. package/components/Alert/Alert.svelte +4 -4
  8. package/components/AppRail/AppRail.svelte +6 -3
  9. package/components/AppRail/AppRail.svelte.d.ts +2 -1
  10. package/components/AppRail/AppRailTile.svelte +13 -6
  11. package/components/AppRail/AppRailTile.svelte.d.ts +2 -2
  12. package/components/AppShell/AppShell.svelte +1 -1
  13. package/components/Breadcrumb/Crumb.svelte +7 -1
  14. package/components/ConicGradient/ConicGradient.svelte +1 -1
  15. package/components/FileDropzone/FileDropzone.svelte +13 -2
  16. package/components/FileDropzone/FileDropzone.svelte.d.ts +1 -0
  17. package/components/GradientHeading/GradientHeading.svelte.d.ts +1 -1
  18. package/components/ListBox/ListBox.svelte +6 -3
  19. package/components/ProgressBar/ProgressBar.svelte +9 -1
  20. package/components/ProgressRadial/ProgressRadial.svelte +9 -1
  21. package/components/Radio/RadioGroup.svelte +3 -0
  22. package/components/Radio/RadioGroup.svelte.d.ts +1 -0
  23. package/components/Radio/RadioItem.svelte +23 -4
  24. package/components/Radio/RadioItem.svelte.d.ts +4 -2
  25. package/components/RangeSlider/RangeSlider.svelte +9 -3
  26. package/components/SlideToggle/SlideToggle.svelte +22 -2
  27. package/components/SvgIcon/SvgIcon.svelte +1 -1
  28. package/components/SvgIcon/icons.d.ts +1 -1
  29. package/components/SvgIcon/icons.js +1 -1
  30. package/components/Tab/Tab.svelte +5 -2
  31. package/components/Tab/TabGroup.svelte +1 -1
  32. package/components/Table/Table.svelte +2 -5
  33. package/index.d.ts +3 -1
  34. package/index.js +2 -1
  35. package/package.json +14 -6
  36. package/styles/all.css +7 -6
  37. package/styles/core.css +1 -1
  38. package/styles/elements/badges.css +22 -1
  39. package/styles/elements/buttons.css +5 -5
  40. package/styles/elements/cards.css +12 -6
  41. package/styles/elements/chips.css +18 -0
  42. package/styles/elements/lists.css +1 -1
  43. package/styles/elements/menus.css +3 -0
  44. package/styles/elements/tables.css +2 -2
  45. package/styles/elements.css +3 -2
  46. package/styles/forms.css +15 -8
  47. package/styles/tailwind.css +2 -2
  48. package/styles/tokens/backgrounds.css +239 -0
  49. package/styles/tokens/border-radius.css +41 -0
  50. package/styles/tokens/borders.css +185 -0
  51. package/styles/tokens/fills.css +29 -0
  52. package/styles/tokens/misc.css +22 -0
  53. package/styles/tokens/rings.css +185 -0
  54. package/styles/tokens/text.css +216 -0
  55. package/styles/tokens.css +9 -169
  56. package/styles/typography.css +2 -2
  57. package/tailwind/theme.cjs +10 -18
  58. package/themes/theme-crimson.css +6 -0
  59. package/themes/theme-gold-nouveau.css +12 -0
  60. package/themes/theme-hamlindigo.css +6 -0
  61. package/themes/theme-modern.css +6 -0
  62. package/themes/theme-rocket.css +6 -0
  63. package/themes/theme-sahara.css +6 -0
  64. package/themes/theme-seafoam.css +8 -2
  65. package/themes/theme-skeleton.css +7 -1
  66. package/themes/theme-vintage.css +6 -0
  67. package/utilities/DataTable/DataTable.d.ts +15 -11
  68. package/utilities/DataTable/DataTable.js +90 -53
  69. package/utilities/DataTable/types.d.ts +24 -6
  70. package/utilities/Drawer/Drawer.svelte +79 -58
  71. package/utilities/Drawer/Drawer.svelte.d.ts +1 -3
  72. package/utilities/Drawer/stores.d.ts +10 -0
  73. package/utilities/Drawer/stores.js +21 -0
  74. package/utilities/Drawer/types.d.ts +33 -0
  75. package/utilities/Drawer/types.js +2 -0
  76. package/utilities/Menu/menu.js +60 -13
  77. package/utilities/Modal/Modal.svelte +4 -4
  78. package/utilities/Modal/examples/ModalExampleForm.svelte +3 -2
  79. package/utilities/Modal/examples/ModalExampleList.svelte +3 -5
  80. package/utilities/Modal/stores.d.ts +12 -1
  81. package/utilities/Modal/stores.js +2 -0
  82. package/utilities/Modal/types.d.ts +1 -1
  83. package/utilities/Toast/Toast.svelte +1 -1
  84. package/themes/legacy/theme-skeleton.css +0 -93
  85. package/utilities/Modal/Modal.d.ts +0 -1
  86. package/utilities/Modal/Modal.js +0 -44
@@ -1,108 +1,130 @@
1
1
  <script>import { fade, fly } from 'svelte/transition';
2
- import { writable } from 'svelte/store';
2
+ import { onMount } from 'svelte';
3
+ // Actions
3
4
  import { focusTrap } from '../../actions/FocusTrap/focusTrap';
5
+ import { drawerStore } from './stores';
4
6
  // Props
5
- /** Provide a store to manage visible state.
6
- * @type {Writable(boolean)}
7
- */
8
- export let open = writable(false);
9
7
  /** Set the anchor position.
10
8
  * @type {'left' | 'top' | 'right' | 'bottom'}
11
9
  */
12
10
  export let position = 'left';
13
- /** Define the Svelte transition animation duration.*/
11
+ /** Define the Svelte transition animation duration. */
14
12
  export let duration = 150;
15
13
  // Props (backdrop)
16
- /** Backdrop - Provide classes to set the backdrop background color*/
17
- export let bgBackdrop = 'bg-backdrop-token';
18
- /** Backdrop - Provide classes to set the blur style.*/
14
+ /** Backdrop - Provide classes to set the backdrop background color */
15
+ export let bgBackdrop = 'bg-surface-backdrop-token';
16
+ /** Backdrop - Provide classes to set the blur style. */
19
17
  export let blur = 'backdrop-blur-xs';
20
18
  // Props (drawer)
21
- /** Drawer - Provide classes to set the drawer background color.*/
19
+ /** Drawer - Provide classes to set the drawer background color. */
22
20
  export let bgDrawer = 'bg-surface-100-800-token';
23
- /** Drawer - Provide classes to set border color.*/
21
+ /** Drawer - Provide classes to set border color. */
24
22
  export let border = '';
25
- /** Drawer - Provide classes to set border radius.*/
23
+ /** Drawer - Provide classes to set border radius. */
26
24
  export let rounded = '';
27
- /** Drawer - Provide classes to override the width.*/
25
+ /** Drawer - Provide classes to override the width. */
28
26
  export let width = '';
29
- /** Drawer - Provide classes to override the height.*/
27
+ /** Drawer - Provide classes to override the height. */
30
28
  export let height = '';
31
- /** Drawer - Provide classes to set margins.*/
29
+ /** Drawer - Provide classes to set margins. */
32
30
  export let margin = '';
33
31
  // Props (a11y)
34
- /** Provide an ID of the element labeling the drawer.*/
32
+ /** Provide an ID of the element labeling the drawer. */
35
33
  export let labelledby = '';
36
- /** Provide an ID of the element describing the drawer.*/
34
+ /** Provide an ID of the element describing the drawer. */
37
35
  export let describedby = '';
38
36
  // Base Classes
39
37
  const cBaseBackdrop = 'fixed top-0 left-0 right-0 bottom-0 z-40 flex';
40
38
  const cBaseDrawer = 'shadow-xl overflow-y-auto';
41
39
  // Local
42
40
  let elemBackdrop;
43
- let elemDrawer;
44
- function percentage(percent, amount) {
45
- return (amount / 100) * percent;
41
+ let windowSettings = { width: 1920, height: 1080 };
42
+ let styleSettings = { backdrop: '', width: '', height: '' };
43
+ let animSettings = { x: 0, y: 0 };
44
+ // Record a record of default props on init
45
+ // NOTE: these must stay in sync with the props implemented above.
46
+ // prettier-ignore
47
+ const propDefaults = {
48
+ position, duration,
49
+ bgBackdrop, blur,
50
+ bgDrawer, border, rounded, width, height, margin,
51
+ labelledby, describedby
52
+ };
53
+ // Listen to drawerStore updates
54
+ drawerStore.subscribe((settings) => {
55
+ if (settings.open === false)
56
+ return;
57
+ applySettings(settings);
58
+ setPosition();
59
+ });
60
+ // Override provided props, else restore prop defaults
61
+ // NOTE: these must stay in sync with the props implemented above.
62
+ function applySettings(settings) {
63
+ position = settings.position || propDefaults.position;
64
+ duration = settings.duration || propDefaults.duration;
65
+ // Backdrop
66
+ bgBackdrop = settings.bgBackdrop || propDefaults.bgBackdrop;
67
+ blur = settings.blur || propDefaults.blur;
68
+ // Drawer
69
+ bgDrawer = settings.bgDrawer || propDefaults.bgDrawer;
70
+ border = settings.border || propDefaults.border;
71
+ rounded = settings.rounded || propDefaults.rounded;
72
+ width = settings.width || propDefaults.width;
73
+ height = settings.height || propDefaults.height;
74
+ margin = settings.margin || propDefaults.margin;
75
+ // A11y
76
+ labelledby = settings.labelledby || propDefaults.labelledby;
77
+ describedby = settings.describedby || propDefaults.describedby;
46
78
  }
47
- // Set Animation Values
48
- let animParams = { backdrop: '', width: '', height: '', x: 0, y: 0 };
49
- function setAnimParams() {
79
+ function setPosition() {
50
80
  switch (position) {
51
81
  case 'top':
52
- animParams = {
53
- backdrop: 'flex-col justify-start',
54
- width: 'w-full',
55
- height: 'h-[40%]',
56
- x: 0,
57
- y: -percentage(40, window.innerHeight)
58
- };
82
+ styleSettings = { backdrop: 'flex-col justify-start', width: 'w-full', height: 'h-[40%]' };
83
+ animSettings = { x: 0, y: -percentage(40, windowSettings.height) };
59
84
  break;
60
85
  case 'bottom':
61
- animParams = { backdrop: 'flex-col justify-end', width: 'w-full', height: 'h-[40%]', x: 0, y: percentage(40, window.innerHeight) };
86
+ styleSettings = { backdrop: 'flex-col justify-end', width: 'w-full', height: 'h-[40%]' };
87
+ animSettings = { x: 0, y: percentage(40, windowSettings.height) };
62
88
  break;
63
89
  case 'right':
64
- animParams = { backdrop: 'justify-end', width: 'w-[90%]', height: 'h-full', x: percentage(80, window.innerWidth), y: 0 };
90
+ styleSettings = { backdrop: 'justify-end', width: 'w-[90%]', height: 'h-full' };
91
+ animSettings = { x: percentage(90, windowSettings.width), y: 0 };
65
92
  break;
66
- // Default: Left
67
- default:
68
- animParams = { backdrop: 'justify-start', width: 'w-[90%]', height: 'h-full', x: -percentage(80, window.innerWidth), y: 0 };
93
+ default: // left
94
+ styleSettings = { backdrop: 'justify-start', width: 'w-[90%]', height: 'h-full' };
95
+ animSettings = { x: -percentage(90, windowSettings.width), y: 0 };
69
96
  break;
70
97
  }
71
98
  }
99
+ function percentage(percent, amount) {
100
+ return (amount / 100) * percent;
101
+ }
72
102
  // Input Handlers
73
103
  function onClickBackdrop(e) {
74
- // Limit to only backdrop element
75
- if (e.target === elemBackdrop) {
76
- close();
77
- }
104
+ if (e.target === elemBackdrop)
105
+ drawerStore.close();
78
106
  }
79
107
  function onKeydownWindow(e) {
80
- if (!$open)
108
+ if (!$drawerStore)
81
109
  return;
82
- if (e.code === 'Escape') {
83
- close();
84
- }
85
- }
86
- // Close
87
- function close() {
88
- open.set(false);
110
+ if (e.code === 'Escape')
111
+ drawerStore.close();
89
112
  }
90
- // Subscribe to $open prop
91
- open.subscribe((o) => {
92
- if (o === true) {
93
- setAnimParams();
94
- }
113
+ // Lifecycle
114
+ onMount(() => {
115
+ windowSettings.width = window.innerWidth;
116
+ windowSettings.height = window.innerHeight;
95
117
  });
96
118
  // Reactive
97
- $: classesWidth = width ? width : animParams.width;
98
- $: classesHeight = height ? height : animParams.height;
99
- $: classesBackdrop = `${cBaseBackdrop} ${animParams.backdrop} ${bgBackdrop} ${blur} ${$$props.class ?? ''}`;
119
+ $: classesWidth = width ? width : styleSettings.width;
120
+ $: classesHeight = height ? height : styleSettings.height;
121
+ $: classesBackdrop = `${cBaseBackdrop} ${styleSettings.backdrop} ${bgBackdrop} ${blur} ${$$props.class ?? ''}`;
100
122
  $: classesDrawer = `${cBaseDrawer} ${classesWidth} ${classesHeight} ${bgDrawer} ${border} ${margin} ${rounded}`;
101
123
  </script>
102
124
 
103
125
  <svelte:window on:keydown={onKeydownWindow} />
104
126
 
105
- {#if $open}
127
+ {#if $drawerStore.open === true}
106
128
  <!-- Backdrop -->
107
129
  <div
108
130
  bind:this={elemBackdrop}
@@ -119,10 +141,9 @@ $: classesDrawer = `${cBaseDrawer} ${classesWidth} ${classesHeight} ${bgDrawer}
119
141
  >
120
142
  <!-- Drawer -->
121
143
  <div
122
- bind:this={elemDrawer}
123
144
  class="drawer {classesDrawer}"
124
145
  data-testid="drawer"
125
- transition:fly|local={{ x: animParams.x, y: animParams.y, duration }}
146
+ transition:fly|local={{ x: animSettings.x, y: animSettings.y, duration }}
126
147
  role="dialog"
127
148
  aria-modal="true"
128
149
  aria-labelledby={labelledby}
@@ -1,10 +1,8 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import { type Writable } from 'svelte/store';
3
2
  declare const __propDef: {
4
3
  props: {
5
4
  [x: string]: any;
6
- open?: Writable<boolean> | undefined;
7
- position?: string | undefined;
5
+ position?: "left" | "top" | "right" | "bottom" | undefined;
8
6
  duration?: number | undefined;
9
7
  bgBackdrop?: string | undefined;
10
8
  blur?: string | undefined;
@@ -0,0 +1,10 @@
1
+ import type { DrawerSettings } from './types';
2
+ export declare const drawerStore: {
3
+ subscribe: (this: void, run: import("svelte/store").Subscriber<DrawerSettings>, invalidate?: ((value?: DrawerSettings | undefined) => void) | undefined) => import("svelte/store").Unsubscriber;
4
+ set: (this: void, value: DrawerSettings) => void;
5
+ update: (this: void, updater: import("svelte/store").Updater<DrawerSettings>) => void;
6
+ /** Open the drawer. */
7
+ open: (newSettings: DrawerSettings) => void;
8
+ /** Close the drawer. */
9
+ close: () => void;
10
+ };
@@ -0,0 +1,21 @@
1
+ // Drawer Stores
2
+ import { writable } from 'svelte/store';
3
+ function drawerService() {
4
+ const { subscribe, set, update } = writable({});
5
+ return {
6
+ subscribe,
7
+ set,
8
+ update,
9
+ /** Open the drawer. */
10
+ open: (newSettings) => update(() => {
11
+ return { open: true, ...newSettings };
12
+ }),
13
+ /** Close the drawer. */
14
+ close: () => update((d) => {
15
+ d.open = false;
16
+ return d;
17
+ })
18
+ };
19
+ }
20
+ // Exports
21
+ export const drawerStore = drawerService();
@@ -0,0 +1,33 @@
1
+ export interface DrawerSettings {
2
+ open?: boolean;
3
+ /** A unique identifier, useful for setting contents. */
4
+ id?: string;
5
+ /** Pass abitrary information for your own persona use. */
6
+ meta?: any;
7
+ /** Set the anchor position.
8
+ * @type {'left' | 'top' | 'right' | 'bottom'}
9
+ */
10
+ position?: 'left' | 'top' | 'right' | 'bottom';
11
+ /** Define the Svelte transition animation duration.*/
12
+ duration?: number;
13
+ /** Backdrop - Provide classes to set the backdrop background color*/
14
+ bgBackdrop?: string;
15
+ /** Backdrop - Provide classes to set the blur style.*/
16
+ blur?: string;
17
+ /** Drawer - Provide classes to set the drawer background color.*/
18
+ bgDrawer?: string;
19
+ /** Drawer - Provide classes to set border color.*/
20
+ border?: string;
21
+ /** Drawer - Provide classes to set border radius.*/
22
+ rounded?: string;
23
+ /** Drawer - Provide classes to override the width.*/
24
+ width?: string;
25
+ /** Drawer - Provide classes to override the height.*/
26
+ height?: string;
27
+ /** Drawer - Provide classes to set margins.*/
28
+ margin?: string;
29
+ /** Provide an ID of the element labeling the drawer.*/
30
+ labelledby?: string;
31
+ /** Provide an ID of the element describing the drawer.*/
32
+ describedby?: string;
33
+ }
@@ -0,0 +1,2 @@
1
+ // Drawer Types
2
+ export {};
@@ -5,15 +5,28 @@ export function menu(node, args) {
5
5
  const elemMenu = document.querySelector(`[data-menu="${args.menu}"]`);
6
6
  if (!elemMenu)
7
7
  return;
8
+ const elemWhitelist = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])';
9
+ let activeFocusIdx;
10
+ let focusableElems;
8
11
  const onInit = () => {
9
12
  autoUpdateOrigin();
10
13
  // Apply a11y attributes
11
14
  elemMenu.setAttribute('role', 'menu');
12
15
  };
13
16
  // Menu States ---
14
- const menuOpen = () => {
17
+ const menuOpen = (openWithFocus = false) => {
15
18
  elemMenu.style.display = 'block';
16
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
+ }
17
30
  };
18
31
  const menuClose = () => {
19
32
  elemMenu.style.display = 'none';
@@ -25,15 +38,25 @@ export function menu(node, args) {
25
38
  };
26
39
  // Click Handlers ---
27
40
  const onTriggerClick = () => {
28
- autoUpdateOrigin();
29
- menuOpen();
41
+ // When the node is clicked, open the menu if it is closed, otherwise close it
42
+ if (elemMenu.style.display === 'none') {
43
+ autoUpdateOrigin();
44
+ menuOpen();
45
+ }
46
+ else {
47
+ menuClose();
48
+ }
30
49
  };
31
50
  const onWindowClick = (event) => {
32
- args.interactive === true ? interactiveClickHandler(event) : standardClickHandler();
51
+ args.interactive === true ? interactiveClickHandler(event) : standardClickHandler(event);
33
52
  };
34
53
  // Interactive FALSE - any click closes the menu
35
- const standardClickHandler = () => {
36
- menuClose();
54
+ const standardClickHandler = (event) => {
55
+ // Any click closes the menu, except for when the node is clicked, since onTriggerClick() will take care of closing it in this case. If we don't include this check this function would close the menu when the node is clicked and onTriggerClick reopens it again because display will be 'none' again.
56
+ const outsideNode = node && !node.contains(event.target);
57
+ if (outsideNode) {
58
+ menuClose();
59
+ }
37
60
  };
38
61
  // Interactive TRUE - clicks outside close menu
39
62
  const interactiveClickHandler = (event) => {
@@ -58,20 +81,44 @@ export function menu(node, args) {
58
81
  };
59
82
  // A11y Input Handlers ---
60
83
  const onTriggerKeyDown = (event) => {
61
- if (['Enter', 'Space'].includes(event.code)) {
84
+ const key = event.key;
85
+ if (key === 'Enter' || key === 'Space') {
62
86
  event.preventDefault();
63
- // Trigger Menu
87
+ // Toggle menu
64
88
  onTriggerClick();
65
- // If menu open, set focus
66
- if (elemMenu.style.display === 'block') {
67
- elemMenu.focus();
68
- }
69
89
  }
70
90
  };
71
91
  const onWindowKeyDown = (event) => {
72
- if (['Escape'].includes(event.code)) {
92
+ const key = event.key;
93
+ if (elemMenu.style.display === 'none')
94
+ return;
95
+ if (key === 'Escape' || key === 'Tab') {
96
+ // Close the menu
73
97
  event.preventDefault();
74
98
  menuClose();
99
+ node.focus();
100
+ }
101
+ else if (key === 'ArrowDown') {
102
+ event.preventDefault();
103
+ if (activeFocusIdx < focusableElems.length - 1) {
104
+ // Move down the menu
105
+ activeFocusIdx += 1;
106
+ focusableElems[activeFocusIdx]?.focus();
107
+ }
108
+ }
109
+ else if (key === 'ArrowUp') {
110
+ event.preventDefault();
111
+ if (activeFocusIdx > 0) {
112
+ // Move up the menu
113
+ activeFocusIdx -= 1;
114
+ focusableElems[activeFocusIdx]?.focus();
115
+ }
116
+ else if (focusableElems.length && activeFocusIdx === -1) {
117
+ // Start at the bottom of the menu if first key is arrow up key
118
+ event.preventDefault();
119
+ activeFocusIdx = focusableElems.length - 1;
120
+ focusableElems[activeFocusIdx]?.focus();
121
+ }
75
122
  }
76
123
  };
77
124
  // On Action Init
@@ -34,7 +34,7 @@ export let buttonTextConfirm = 'Confirm';
34
34
  export let buttonTextSubmit = 'Submit';
35
35
  // Props (regions)
36
36
  /** Provide classes to style the backdrop. */
37
- export let regionBackdrop = 'bg-backdrop-token';
37
+ export let regionBackdrop = 'bg-surface-backdrop-token';
38
38
  /** Provide arbitrary classes to modal header region. */
39
39
  export let regionHeader = 'text-2xl font-bold';
40
40
  /** Provide arbitrary classes to modal body region. */
@@ -144,7 +144,7 @@ $: parent = {
144
144
  <article class="modal-body {regionBody}">{@html $modalStore[0].body}</article>
145
145
  {/if}
146
146
  <!-- Image -->
147
- {#if $modalStore[0]?.image}
147
+ {#if $modalStore[0]?.image && typeof $modalStore[0]?.image === 'string'}
148
148
  <img class="modal-image {cModalImage}" src={$modalStore[0]?.image} alt="Modal" />
149
149
  {/if}
150
150
  <!-- Type -->
@@ -172,8 +172,8 @@ $: parent = {
172
172
  {:else if $modalStore[0].type === 'component'}
173
173
  <!-- Template: Component -->
174
174
  <!-- NOTE: users are repsonsible for handling all UI, including cancel/submit buttons -->
175
- <svelte:component this={$modalStore[0].component.ref} {...$modalStore[0].component.props} {parent}>
176
- {@html $modalStore[0].component.slot}
175
+ <svelte:component this={$modalStore[0].component?.ref} {...$modalStore[0].component?.props} {parent}>
176
+ {@html $modalStore[0].component?.slot}
177
177
  </svelte:component>
178
178
  {/if}
179
179
  </div>
@@ -2,7 +2,7 @@
2
2
  /** Exposes parent props to this component. */
3
3
  export let parent;
4
4
  // Stores
5
- import { modalStore } from '../stores';
5
+ import { modalStore } from '../../../index.ts';
6
6
  // Form Data
7
7
  const formData = {
8
8
  name: 'Jane Doe',
@@ -11,7 +11,8 @@ const formData = {
11
11
  };
12
12
  // We've created a custom submit function to pass the response and close the modal.
13
13
  function onFormSubmit() {
14
- $modalStore[0].response(formData);
14
+ if ($modalStore[0].response)
15
+ $modalStore[0].response(formData);
15
16
  modalStore.close();
16
17
  }
17
18
  // Base Classes
@@ -1,14 +1,12 @@
1
1
  <script>import { writable } from 'svelte/store';
2
- import ListBox from '../../../components/ListBox/ListBox.svelte';
3
- import ListBoxItem from '../../../components/ListBox/ListBoxItem.svelte';
2
+ import { ListBox, ListBoxItem, modalStore } from '../../../index.ts';
4
3
  // Props
5
4
  /** Exposes parent props to this component. */
6
5
  export let parent;
7
- // Stores
8
- import { modalStore } from '../stores';
9
6
  const storeFlavor = writable('chocolate');
10
7
  function onFormSubmit() {
11
- $modalStore[0].response($storeFlavor);
8
+ if ($modalStore[0].response)
9
+ $modalStore[0].response($storeFlavor);
12
10
  modalStore.close();
13
11
  }
14
12
  // Base Classes
@@ -1 +1,12 @@
1
- export declare const modalStore: any;
1
+ import type { ModalSettings } from './types';
2
+ export declare const modalStore: {
3
+ subscribe: (this: void, run: import("svelte/store").Subscriber<ModalSettings[]>, invalidate?: ((value?: ModalSettings[] | undefined) => void) | undefined) => import("svelte/store").Unsubscriber;
4
+ set: (this: void, value: ModalSettings[]) => void;
5
+ update: (this: void, updater: import("svelte/store").Updater<ModalSettings[]>) => void;
6
+ /** Append to end of queue. */
7
+ trigger: (modal: ModalSettings) => void;
8
+ /** Remove first item in queue. */
9
+ close: () => void;
10
+ /** Remove all items from queue. */
11
+ clear: () => void;
12
+ };
@@ -4,6 +4,8 @@ function modalService() {
4
4
  const { subscribe, set, update } = writable([]);
5
5
  return {
6
6
  subscribe,
7
+ set,
8
+ update,
7
9
  /** Append to end of queue. */
8
10
  trigger: (modal) => update((mStore) => {
9
11
  mStore.push(modal);
@@ -2,7 +2,7 @@ export interface ModalComponent {
2
2
  /** Import and provide your component reference. */
3
3
  ref: any;
4
4
  /** Provide a key/value pairs of component props. */
5
- props?: Record<string, string>;
5
+ props?: Record<string, unknown>;
6
6
  /** Provide an HTML template literal for the default slot. */
7
7
  slot?: string;
8
8
  }
@@ -16,7 +16,7 @@ export let background = 'bg-accent-500';
16
16
  /** Provide classes to set width styles. */
17
17
  export let width = 'max-w-[640px]';
18
18
  /** Provide classes to set the text color. */
19
- export let color = 'text-white';
19
+ export let color = 'text-on-accent-token';
20
20
  /** Provide classes to set the padding. */
21
21
  export let padding = 'p-4';
22
22
  /** Provide classes to set the horizontal spacing. */
@@ -1,93 +0,0 @@
1
- /* prettier-ignore */
2
- :root {
3
- /* =~= Theme Styles =~= */
4
- --theme-border-base: 1px;
5
- --theme-font-family-heading: system-ui;
6
- --theme-font-family-base: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
7
- --theme-font-color-base: var(--color-surface-900);
8
- --theme-font-color-dark: var(--color-surface-50);
9
- --theme-rounded-base: 4px;
10
- --theme-rounded-container: 8px;
11
- /* =~= Theme Colors | Tailwind =~= */
12
- /* emerald | #10b981 */
13
- --color-primary-50: 236 253 245; /* ⬅ #ecfdf5 */
14
- --color-primary-100: 209 250 229; /* ⬅ #d1fae5 */
15
- --color-primary-200: 167 243 208; /* ⬅ #a7f3d0 */
16
- --color-primary-300: 110 231 183; /* ⬅ #6ee7b7 */
17
- --color-primary-400: 52 211 153; /* ⬅ #34d399 */
18
- --color-primary-500: 16 185 129; /* ⬅ #10b981 */
19
- --color-primary-600: 5 150 105; /* ⬅ #059669 */
20
- --color-primary-700: 4 120 87; /* ⬅ #047857 */
21
- --color-primary-800: 6 95 70; /* ⬅ #065f46 */
22
- --color-primary-900: 6 78 59; /* ⬅ #064e3b */
23
- /* indigo | #6366f1 */
24
- --color-accent-50: 238 242 255; /* ⬅ #eef2ff */
25
- --color-accent-100: 224 231 255; /* ⬅ #e0e7ff */
26
- --color-accent-200: 199 210 254; /* ⬅ #c7d2fe */
27
- --color-accent-300: 165 180 252; /* ⬅ #a5b4fc */
28
- --color-accent-400: 129 140 248; /* ⬅ #818cf8 */
29
- --color-accent-500: 99 102 241; /* ⬅ #6366f1 */
30
- --color-accent-600: 79 70 229; /* ⬅ #4f46e5 */
31
- --color-accent-700: 67 56 202; /* ⬅ #4338ca */
32
- --color-accent-800: 55 48 163; /* ⬅ #3730a3 */
33
- --color-accent-900: 49 46 129; /* ⬅ #312e81 */
34
- /* yellow | #eab308 */
35
- --color-tertiary-50: 254 252 232; /* ⬅ #fefce8 */
36
- --color-tertiary-100: 254 249 195; /* ⬅ #fef9c3 */
37
- --color-tertiary-200: 254 240 138; /* ⬅ #fef08a */
38
- --color-tertiary-300: 253 224 71; /* ⬅ #fde047 */
39
- --color-tertiary-400: 250 204 21; /* ⬅ #facc15 */
40
- --color-tertiary-500: 234 179 8; /* ⬅ #eab308 */
41
- --color-tertiary-600: 202 138 4; /* ⬅ #ca8a04 */
42
- --color-tertiary-700: 161 98 7; /* ⬅ #a16207 */
43
- --color-tertiary-800: 133 77 14; /* ⬅ #854d0e */
44
- --color-tertiary-900: 113 63 18; /* ⬅ #713f12 */
45
- /* rose | #f43f5e */
46
- --color-warning-50: 255 241 242; /* ⬅ #fff1f2 */
47
- --color-warning-100: 255 228 230; /* ⬅ #ffe4e6 */
48
- --color-warning-200: 254 205 211; /* ⬅ #fecdd3 */
49
- --color-warning-300: 253 164 175; /* ⬅ #fda4af */
50
- --color-warning-400: 251 113 133; /* ⬅ #fb7185 */
51
- --color-warning-500: 244 63 94; /* ⬅ #f43f5e */
52
- --color-warning-600: 225 29 72; /* ⬅ #e11d48 */
53
- --color-warning-700: 190 18 60; /* ⬅ #be123c */
54
- --color-warning-800: 159 18 57; /* ⬅ #9f1239 */
55
- --color-warning-900: 136 19 55; /* ⬅ #881337 */
56
- /* gray | #6b7280 */
57
- --color-surface-50: 249 250 251; /* ⬅ #f9fafb */
58
- --color-surface-100: 243 244 246; /* ⬅ #f3f4f6 */
59
- --color-surface-200: 229 231 235; /* ⬅ #e5e7eb */
60
- --color-surface-300: 209 213 219; /* ⬅ #d1d5db */
61
- --color-surface-400: 156 163 175; /* ⬅ #9ca3af */
62
- --color-surface-500: 107 114 128; /* ⬅ #6b7280 */
63
- --color-surface-600: 75 85 99; /* ⬅ #4b5563 */
64
- --color-surface-700: 55 65 81; /* ⬅ #374151 */
65
- --color-surface-800: 31 41 55; /* ⬅ #1f2937 */
66
- --color-surface-900: 17 24 39; /* ⬅ #111827 */
67
- }
68
-
69
- [data-theme='skeleton'] h1,
70
- [data-theme='skeleton'] h2,
71
- [data-theme='skeleton'] h3,
72
- [data-theme='skeleton'] h4,
73
- [data-theme='skeleton'] h5,
74
- [data-theme='skeleton'] h6 {
75
- font-weight: bold;
76
- }
77
-
78
- /* Applied to body with `<body data-theme="skeleton">` */
79
- /* Created with: https://csshero.org/mesher/ */
80
- [data-theme='skeleton'] {
81
- /* prettier-ignore */
82
- background-image:
83
- radial-gradient(at 35% 35%, hsla(160,84%,39%,0.14) 0px, transparent 35%),
84
- radial-gradient(at 61% 60%, hsla(238,83%,66%,0.18) 0px, transparent 35%);
85
- background-size: cover;
86
- background-attachment: fixed;
87
- }
88
- .dark [data-theme='skeleton'] {
89
- /* prettier-ignore */
90
- background-image:
91
- radial-gradient(at 35% 35%, hsla(160,84%,39%,0.18) 0px, transparent 50%),
92
- radial-gradient(at 61% 60%, hsla(238,83%,66%,0.18) 0px, transparent 50%);
93
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,44 +0,0 @@
1
- import { render } from '@testing-library/svelte';
2
- import { describe, it, expect } from 'vitest';
3
- import { modalStore } from './stores';
4
- // @ts-ignore
5
- import Modal from './Modal.svelte';
6
- // Modal Payloads
7
- const modalAlert = {
8
- type: 'alert',
9
- title: 'Welcome to Skeleton.',
10
- body: 'This is a standard alert modal.'
11
- };
12
- const modalConfirm = {
13
- type: 'confirm',
14
- title: 'Please Confirm',
15
- body: 'Are you sure you wish to proceed?',
16
- response: (r) => console.log(r)
17
- };
18
- const modalPrompt = {
19
- type: 'prompt',
20
- title: 'Enter Name',
21
- body: 'Provide your first name in the field below.',
22
- value: 'foobar',
23
- response: (r) => console.log(r)
24
- };
25
- describe('Modal.svelte', () => {
26
- it('Renders modal alert', async () => {
27
- modalStore.trigger(modalAlert);
28
- const { getByTestId } = render(Modal);
29
- expect(getByTestId('modal-backdrop')).toBeTruthy();
30
- expect(getByTestId('modal')).toBeTruthy();
31
- });
32
- it('Renders modal confirm', async () => {
33
- modalStore.trigger(modalConfirm);
34
- const { getByTestId } = render(Modal);
35
- expect(getByTestId('modal-backdrop')).toBeTruthy();
36
- expect(getByTestId('modal')).toBeTruthy();
37
- });
38
- it('Renders modal prompt', async () => {
39
- modalStore.trigger(modalPrompt);
40
- const { getByTestId } = render(Modal);
41
- expect(getByTestId('modal-backdrop')).toBeTruthy();
42
- expect(getByTestId('modal')).toBeTruthy();
43
- });
44
- });