@skeletonlabs/skeleton 0.80.8 → 0.86.9

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 (90) hide show
  1. package/README.md +1 -1
  2. package/actions/Filters/svg-filters/Apollo.svelte.d.ts +6 -2
  3. package/actions/Filters/svg-filters/BlueNight.svelte.d.ts +6 -2
  4. package/actions/Filters/svg-filters/Emerald.svelte.d.ts +6 -2
  5. package/actions/Filters/svg-filters/GreenFall.svelte.d.ts +6 -2
  6. package/actions/Filters/svg-filters/Noir.svelte.d.ts +6 -2
  7. package/actions/Filters/svg-filters/NoirLight.svelte.d.ts +6 -2
  8. package/actions/Filters/svg-filters/Rustic.svelte.d.ts +6 -2
  9. package/actions/Filters/svg-filters/Summer84.svelte.d.ts +6 -2
  10. package/actions/Filters/svg-filters/XPro.svelte.d.ts +6 -2
  11. package/components/Accordion/AccordionGroup.svelte +1 -2
  12. package/components/Accordion/AccordionItem.svelte +1 -1
  13. package/components/Accordion/AccordionItem.svelte.d.ts +1 -0
  14. package/components/Alert/Alert.svelte +3 -3
  15. package/components/AppRail/AppRailTile.svelte +17 -18
  16. package/components/AppShell/AppShell.svelte +3 -3
  17. package/components/Breadcrumb/Crumb.svelte +3 -1
  18. package/components/Breadcrumb/Crumb.svelte.d.ts +5 -0
  19. package/components/ConicGradient/ConicGradient.svelte +1 -1
  20. package/components/ConicGradient/ConicGradient.svelte.d.ts +5 -0
  21. package/components/FileButton/FileButton.svelte +2 -2
  22. package/components/FileButton/FileButton.svelte.d.ts +3 -0
  23. package/components/FileDropzone/FileDropzone.svelte +4 -0
  24. package/components/FileDropzone/FileDropzone.svelte.d.ts +4 -0
  25. package/components/GradientHeading/GradientHeading.svelte +1 -1
  26. package/components/ListBox/ListBoxItem.svelte +3 -1
  27. package/components/ListBox/ListBoxItem.svelte.d.ts +2 -0
  28. package/components/Paginator/Paginator.svelte +21 -9
  29. package/components/Paginator/Paginator.svelte.d.ts +5 -1
  30. package/components/ProgressBar/ProgressBar.svelte +6 -4
  31. package/components/ProgressBar/ProgressBar.svelte.d.ts +1 -0
  32. package/components/ProgressRadial/ProgressRadial.svelte +1 -1
  33. package/components/Radio/RadioGroup.svelte +2 -2
  34. package/components/Radio/RadioItem.svelte +3 -1
  35. package/components/Radio/RadioItem.svelte.d.ts +2 -0
  36. package/components/RangeSlider/RangeSlider.svelte +1 -1
  37. package/components/SlideToggle/SlideToggle.svelte +8 -5
  38. package/components/SlideToggle/SlideToggle.svelte.d.ts +4 -1
  39. package/components/Stepper/Step.svelte +27 -7
  40. package/components/Stepper/Step.svelte.d.ts +6 -3
  41. package/components/Stepper/Stepper.svelte +19 -10
  42. package/components/Stepper/Stepper.svelte.d.ts +6 -3
  43. package/components/Tab/Tab.svelte +15 -3
  44. package/components/Tab/Tab.svelte.d.ts +5 -0
  45. package/components/Table/Table.svelte +3 -3
  46. package/package.json +18 -20
  47. package/styles/elements/badges.css +11 -5
  48. package/styles/elements/buttons.css +33 -9
  49. package/styles/elements/cards.css +22 -3
  50. package/styles/elements/chips.css +4 -2
  51. package/styles/elements/tables.css +1 -1
  52. package/styles/forms.css +4 -4
  53. package/styles/tokens/backgrounds.css +119 -29
  54. package/styles/tokens/borders.css +90 -22
  55. package/styles/tokens/fills.css +14 -5
  56. package/styles/tokens/rings.css +90 -22
  57. package/styles/tokens/text.css +104 -27
  58. package/styles/tokens.css +0 -3
  59. package/styles/typography.css +6 -6
  60. package/tailwind/colors.d.ts +1 -1
  61. package/tailwind/colors.js +1 -1
  62. package/tailwind/theme.cjs +4 -2
  63. package/themes/theme-crimson.css +88 -64
  64. package/themes/theme-gold-nouveau.css +108 -115
  65. package/themes/theme-hamlindigo.css +97 -74
  66. package/themes/theme-modern.css +107 -64
  67. package/themes/theme-rocket.css +96 -63
  68. package/themes/theme-sahara.css +104 -65
  69. package/themes/theme-seafoam.css +100 -66
  70. package/themes/theme-seasonal.css +111 -65
  71. package/themes/theme-skeleton.css +99 -75
  72. package/themes/theme-vintage.css +102 -63
  73. package/utilities/CodeBlock/CodeBlock.svelte +6 -1
  74. package/utilities/CodeBlock/CodeBlock.svelte.d.ts +2 -0
  75. package/utilities/DataTable/DataTable.js +3 -1
  76. package/utilities/Drawer/Drawer.svelte +11 -10
  77. package/utilities/Drawer/Drawer.svelte.d.ts +1 -2
  78. package/utilities/Drawer/stores.d.ts +1 -1
  79. package/utilities/LightSwitch/LightSwitch.svelte +9 -4
  80. package/utilities/LightSwitch/LightSwitch.svelte.d.ts +6 -1
  81. package/utilities/LocalStorageStore/LocalStorageStore.d.ts +3 -1
  82. package/utilities/LocalStorageStore/LocalStorageStore.js +9 -4
  83. package/utilities/Menu/menu.js +11 -7
  84. package/utilities/Modal/Modal.svelte +21 -9
  85. package/utilities/Modal/Modal.svelte.d.ts +2 -0
  86. package/utilities/Modal/types.d.ts +8 -0
  87. package/utilities/Toast/Toast.svelte +2 -2
  88. package/utilities/Toast/stores.js +18 -1
  89. package/utilities/Toast/types.d.ts +5 -0
  90. package/styles/tokens/misc.css +0 -22
@@ -5,75 +5,99 @@
5
5
 
6
6
  :root {
7
7
  /* =~= Theme Styles =~= */
8
- --theme-border-base: 1px;
9
- --theme-font-family-heading: 'Abril Fatface', cursive;
10
8
  --theme-font-family-base: 'Noto Sans', sans-serif;
9
+ --theme-font-family-heading: 'Abril Fatface', cursive;
11
10
  --theme-font-color-base: var(--color-primary-900);
12
11
  --theme-font-color-dark: var(--color-primary-100);
13
12
  --theme-rounded-base: 2px;
14
13
  --theme-rounded-container: 4px;
15
- /* On Colors */
16
- --on-primary: #000;
17
- --on-accent: #000;
18
- --on-tertiary: #000;
19
- --on-warning: #fff;
20
- --on-surface: #fff;
21
- /* =~= Theme Colors | Tailwind =~= */
22
- /* amber | #f59e0b */
23
- --color-primary-50: 255 251 235; /* ⬅ #fffbeb */
24
- --color-primary-100: 254 243 199; /* ⬅ #fef3c7 */
25
- --color-primary-200: 253 230 138; /* ⬅ #fde68a */
26
- --color-primary-300: 252 211 77; /* ⬅ #fcd34d */
27
- --color-primary-400: 251 191 36; /* ⬅ #fbbf24 */
28
- --color-primary-500: 245 158 11; /* ⬅ #f59e0b */
29
- --color-primary-600: 217 119 6; /* ⬅ #d97706 */
30
- --color-primary-700: 180 83 9; /* ⬅ #b45309 */
31
- --color-primary-800: 146 64 14; /* ⬅ #92400e */
32
- --color-primary-900: 120 53 15; /* ⬅ #78350f */
33
- /* green | #22c55e */
34
- --color-accent-50: 240 253 244; /* ⬅ #f0fdf4 */
35
- --color-accent-100: 220 252 231; /* ⬅ #dcfce7 */
36
- --color-accent-200: 187 247 208; /* ⬅ #bbf7d0 */
37
- --color-accent-300: 134 239 172; /* ⬅ #86efac */
38
- --color-accent-400: 74 222 128; /* ⬅ #4ade80 */
39
- --color-accent-500: 34 197 94; /* ⬅ #22c55e */
40
- --color-accent-600: 22 163 74; /* ⬅ #16a34a */
41
- --color-accent-700: 21 128 61; /* ⬅ #15803d */
42
- --color-accent-800: 22 101 52; /* ⬅ #166534 */
43
- --color-accent-900: 20 83 45; /* ⬅ #14532d */
44
- /* cyan | #06b6d4 */
45
- --color-tertiary-50: 236 254 255; /* ⬅ #ecfeff */
46
- --color-tertiary-100: 207 250 254; /* ⬅ #cffafe */
47
- --color-tertiary-200: 165 243 252; /* ⬅ #a5f3fc */
48
- --color-tertiary-300: 103 232 249; /* ⬅ #67e8f9 */
49
- --color-tertiary-400: 34 211 238; /* ⬅ #22d3ee */
14
+ --theme-border-base: 1px;
15
+ /* =~= Theme On-X Colors =~= */
16
+ --on-primary: 0 0 0;
17
+ --on-secondary: 0 0 0;
18
+ --on-tertiary: 0 0 0;
19
+ --on-success: 0 0 0;
20
+ --on-warning: 0 0 0;
21
+ --on-error: 0 0 0;
22
+ --on-surface: 255 255 255;
23
+ /* =~= Theme Colors =~= */
24
+ /* primary | #ea861a */
25
+ --color-primary-50: 252 237 221; /* ⬅ #fceddd */
26
+ --color-primary-100: 251 231 209; /* ⬅ #fbe7d1 */
27
+ --color-primary-200: 250 225 198; /* ⬅ #fae1c6 */
28
+ --color-primary-300: 247 207 163; /* ⬅ #f7cfa3 */
29
+ --color-primary-400: 240 170 95; /* ⬅ #f0aa5f */
30
+ --color-primary-500: 234 134 26; /* ⬅ #ea861a */
31
+ --color-primary-600: 211 121 23; /* ⬅ #d37917 */
32
+ --color-primary-700: 176 101 20; /* ⬅ #b06514 */
33
+ --color-primary-800: 140 80 16; /* ⬅ #8c5010 */
34
+ --color-primary-900: 115 66 13; /* ⬅ #73420d */
35
+ /* secondary | #97cea5 */
36
+ --color-secondary-50: 239 248 242; /* ⬅ #eff8f2 */
37
+ --color-secondary-100: 234 245 237; /* ⬅ #eaf5ed */
38
+ --color-secondary-200: 229 243 233; /* ⬅ #e5f3e9 */
39
+ --color-secondary-300: 213 235 219; /* ⬅ #d5ebdb */
40
+ --color-secondary-400: 182 221 192; /* ⬅ #b6ddc0 */
41
+ --color-secondary-500: 151 206 165; /* ⬅ #97cea5 */
42
+ --color-secondary-600: 136 185 149; /* ⬅ #88b995 */
43
+ --color-secondary-700: 113 155 124; /* ⬅ #719b7c */
44
+ --color-secondary-800: 91 124 99; /* ⬅ #5b7c63 */
45
+ --color-secondary-900: 74 101 81; /* ⬅ #4a6551 */
46
+ /* tertiary | #06b6d4 */
47
+ --color-tertiary-50: 218 244 249; /* ⬅ #daf4f9 */
48
+ --color-tertiary-100: 205 240 246; /* ⬅ #cdf0f6 */
49
+ --color-tertiary-200: 193 237 244; /* ⬅ #c1edf4 */
50
+ --color-tertiary-300: 155 226 238; /* ⬅ #9be2ee */
51
+ --color-tertiary-400: 81 204 225; /* ⬅ #51cce1 */
50
52
  --color-tertiary-500: 6 182 212; /* ⬅ #06b6d4 */
51
- --color-tertiary-600: 8 145 178; /* ⬅ #0891b2 */
52
- --color-tertiary-700: 14 116 144; /* ⬅ #0e7490 */
53
- --color-tertiary-800: 21 94 117; /* ⬅ #155e75 */
54
- --color-tertiary-900: 22 78 99; /* ⬅ #164e63 */
55
- /* red | #ef4444 */
56
- --color-warning-50: 254 242 242; /* ⬅ #fef2f2 */
57
- --color-warning-100: 254 226 226; /* ⬅ #fee2e2 */
58
- --color-warning-200: 254 202 202; /* ⬅ #fecaca */
59
- --color-warning-300: 252 165 165; /* ⬅ #fca5a5 */
60
- --color-warning-400: 248 113 113; /* ⬅ #f87171 */
61
- --color-warning-500: 239 68 68; /* ⬅ #ef4444 */
62
- --color-warning-600: 220 38 38; /* ⬅ #dc2626 */
63
- --color-warning-700: 185 28 28; /* ⬅ #b91c1c */
64
- --color-warning-800: 153 27 27; /* ⬅ #991b1b */
65
- --color-warning-900: 127 29 29; /* ⬅ #7f1d1d */
66
- /* stone | #78716c */
67
- --color-surface-50: 250 250 249; /* ⬅ #fafaf9 */
68
- --color-surface-100: 245 245 244; /* ⬅ #f5f5f4 */
69
- --color-surface-200: 231 229 228; /* ⬅ #e7e5e4 */
70
- --color-surface-300: 214 211 209; /* ⬅ #d6d3d1 */
71
- --color-surface-400: 168 162 158; /* ⬅ #a8a29e */
72
- --color-surface-500: 120 113 108; /* ⬅ #78716c */
73
- --color-surface-600: 87 83 78; /* ⬅ #57534e */
74
- --color-surface-700: 68 64 60; /* ⬅ #44403c */
75
- --color-surface-800: 41 37 36; /* ⬅ #292524 */
76
- --color-surface-900: 28 25 23; /* ⬅ #1c1917 */
53
+ --color-tertiary-600: 5 164 191; /* ⬅ #05a4bf */
54
+ --color-tertiary-700: 5 137 159; /* ⬅ #05899f */
55
+ --color-tertiary-800: 4 109 127; /* ⬅ #046d7f */
56
+ --color-tertiary-900: 3 89 104; /* ⬅ #035968 */
57
+ /* success | #84cb5d */
58
+ --color-success-50: 237 247 231; /* ⬅ #edf7e7 */
59
+ --color-success-100: 230 245 223; /* ⬅ #e6f5df */
60
+ --color-success-200: 224 242 215; /* ⬅ #e0f2d7 */
61
+ --color-success-300: 206 234 190; /* ⬅ #ceeabe */
62
+ --color-success-400: 169 219 142; /* ⬅ #a9db8e */
63
+ --color-success-500: 132 203 93; /* ⬅ #84cb5d */
64
+ --color-success-600: 119 183 84; /* ⬅ #77b754 */
65
+ --color-success-700: 99 152 70; /* ⬅ #639846 */
66
+ --color-success-800: 79 122 56; /* ⬅ #4f7a38 */
67
+ --color-success-900: 65 99 46; /* ⬅ #41632e */
68
+ /* warning | #f2ac23 */
69
+ --color-warning-50: 253 243 222; /* ⬅ #fdf3de */
70
+ --color-warning-100: 252 238 211; /* ⬅ #fceed3 */
71
+ --color-warning-200: 252 234 200; /* ⬅ #fceac8 */
72
+ --color-warning-300: 250 222 167; /* ⬅ #fadea7 */
73
+ --color-warning-400: 246 197 101; /* ⬅ #f6c565 */
74
+ --color-warning-500: 242 172 35; /* ⬅ #f2ac23 */
75
+ --color-warning-600: 218 155 32; /* ⬅ #da9b20 */
76
+ --color-warning-700: 182 129 26; /* ⬅ #b6811a */
77
+ --color-warning-800: 145 103 21; /* ⬅ #916715 */
78
+ --color-warning-900: 119 84 17; /* ⬅ #775411 */
79
+ /* error | #d57e78 */
80
+ --color-error-50: 249 236 235; /* ⬅ #f9eceb */
81
+ --color-error-100: 247 229 228; /* ⬅ #f7e5e4 */
82
+ --color-error-200: 245 223 221; /* ⬅ #f5dfdd */
83
+ --color-error-300: 238 203 201; /* ⬅ #eecbc9 */
84
+ --color-error-400: 226 165 161; /* ⬅ #e2a5a1 */
85
+ --color-error-500: 213 126 120; /* ⬅ #d57e78 */
86
+ --color-error-600: 192 113 108; /* ⬅ #c0716c */
87
+ --color-error-700: 160 95 90; /* ⬅ #a05f5a */
88
+ --color-error-800: 128 76 72; /* ⬅ #804c48 */
89
+ --color-error-900: 104 62 59; /* ⬅ #683e3b */
90
+ /* surface | #3f3731 */
91
+ --color-surface-50: 226 225 224; /* ⬅ #e2e1e0 */
92
+ --color-surface-100: 217 215 214; /* ⬅ #d9d7d6 */
93
+ --color-surface-200: 207 205 204; /* ⬅ #cfcdcc */
94
+ --color-surface-300: 178 175 173; /* ⬅ #b2afad */
95
+ --color-surface-400: 121 115 111; /* ⬅ #79736f */
96
+ --color-surface-500: 63 55 49; /* ⬅ #3f3731 */
97
+ --color-surface-600: 57 50 44; /* ⬅ #39322c */
98
+ --color-surface-700: 47 41 37; /* ⬅ #2f2925 */
99
+ --color-surface-800: 38 33 29; /* ⬅ #26211d */
100
+ --color-surface-900: 31 27 24; /* ⬅ #1f1b18 */
77
101
  }
78
102
 
79
103
  [data-theme='vintage'] h1,
@@ -84,3 +108,18 @@
84
108
  [data-theme='vintage'] h6 {
85
109
  letter-spacing: 1px;
86
110
  }
111
+
112
+ /* Applied to body with `<body data-theme="vintage">` */
113
+ /* Created with: https://csshero.org/mesher/ */
114
+ [data-theme='vintage'] {
115
+ /* prettier-ignore */
116
+ background-image:
117
+ radial-gradient(at 100% 0%, hsla(135,34%,70%,0.20) 0px, transparent 50%),
118
+ radial-gradient(at 85% 100%, hsla(31,83%,50%,0.20) 0px, transparent 50%);
119
+ }
120
+ .dark [data-theme='vintage'] {
121
+ /* prettier-ignore */
122
+ background-image:
123
+ radial-gradient(at 100% 0%, hsla(135,34%,70%,0.14) 0px, transparent 50%),
124
+ radial-gradient(at 85% 100%, hsla(31,83%,50%,0.14) 0px, transparent 50%);
125
+ }
@@ -1,4 +1,7 @@
1
- <script>import { storeHighlightJs } from './stores';
1
+ <script>import { createEventDispatcher } from 'svelte';
2
+ // Event Handler
3
+ const dispatch = createEventDispatcher();
4
+ import { storeHighlightJs } from './stores';
2
5
  import { clipboard } from '../../actions/Clipboard/clipboard';
3
6
  // Props
4
7
  /** Sets a language alias for Highlight.js syntax highlighting. */
@@ -35,6 +38,8 @@ function onCopyClick() {
35
38
  copyState = true;
36
39
  // prettier-ignore
37
40
  setTimeout(() => { copyState = false; }, 2000);
41
+ /** @event {{}} copy - Fires when the Copy button is pressed. */
42
+ dispatch('copy', {});
38
43
  }
39
44
  // Trigger syntax highlighting if highlight.js is available
40
45
  $: if ($storeHighlightJs !== undefined) {
@@ -11,6 +11,8 @@ declare const __propDef: {
11
11
  buttonCopy?: string | undefined;
12
12
  };
13
13
  events: {
14
+ copy: CustomEvent<any>;
15
+ } & {
14
16
  [evt: string]: CustomEvent<any>;
15
17
  };
16
18
  slots: {};
@@ -107,7 +107,9 @@ function sortOrder(order, store) {
107
107
  return String(x[key]).localeCompare(String(y[key]));
108
108
  }
109
109
  else {
110
- return x[key] - y[key];
110
+ const a = x[key];
111
+ const b = y[key];
112
+ return (a < b) ? -1 : ((a > b) ? 1 : 0);
111
113
  }
112
114
  });
113
115
  }
@@ -1,5 +1,7 @@
1
1
  <script>import { fade, fly } from 'svelte/transition';
2
- import { onMount } from 'svelte';
2
+ import { createEventDispatcher, onMount } from 'svelte';
3
+ // Event Handler
4
+ const dispatch = createEventDispatcher();
3
5
  // Actions
4
6
  import { focusTrap } from '../../actions/FocusTrap/focusTrap';
5
7
  import { drawerStore } from './stores';
@@ -100,14 +102,16 @@ function percentage(percent, amount) {
100
102
  return (amount / 100) * percent;
101
103
  }
102
104
  // Input Handlers
103
- function onClickBackdrop(e) {
104
- if (e.target === elemBackdrop)
105
+ function onBackdropInteraction(event) {
106
+ if (event.target === elemBackdrop)
105
107
  drawerStore.close();
108
+ /** @event {{ event }} backdrop - Fires on backdrop interaction. */
109
+ dispatch('backdrop', event);
106
110
  }
107
- function onKeydownWindow(e) {
111
+ function onKeydownWindow(event) {
108
112
  if (!$drawerStore)
109
113
  return;
110
- if (e.code === 'Escape')
114
+ if (event.code === 'Escape')
111
115
  drawerStore.close();
112
116
  }
113
117
  // Lifecycle
@@ -131,11 +135,8 @@ $: classesDrawer = `${cBaseDrawer} ${classesWidth} ${classesHeight} ${bgDrawer}
131
135
  class="drawer-backdrop {classesBackdrop}"
132
136
  data-testid="drawer-backdrop"
133
137
  transition:fade|local={{ duration }}
134
- on:click={(e) => {
135
- onClickBackdrop(e);
136
- }}
137
- on:keydown
138
- on:keyup
138
+ on:mousedown={onBackdropInteraction}
139
+ on:touchstart={onBackdropInteraction}
139
140
  on:keypress
140
141
  use:focusTrap={true}
141
142
  >
@@ -16,9 +16,8 @@ declare const __propDef: {
16
16
  describedby?: string | undefined;
17
17
  };
18
18
  events: {
19
- keydown: KeyboardEvent;
20
- keyup: KeyboardEvent;
21
19
  keypress: KeyboardEvent;
20
+ backdrop: CustomEvent<any>;
22
21
  } & {
23
22
  [evt: string]: CustomEvent<any>;
24
23
  };
@@ -4,7 +4,7 @@ export declare const drawerStore: {
4
4
  set: (this: void, value: DrawerSettings) => void;
5
5
  update: (this: void, updater: import("svelte/store").Updater<DrawerSettings>) => void;
6
6
  /** Open the drawer. */
7
- open: (newSettings: DrawerSettings) => void;
7
+ open: (newSettings?: DrawerSettings) => void;
8
8
  /** Close the drawer. */
9
9
  close: () => void;
10
10
  };
@@ -1,5 +1,7 @@
1
1
  <!-- https://tailwindcss.com/docs/dark-mode -->
2
- <script>import { onMount } from 'svelte';
2
+ <script>import { createEventDispatcher, onMount } from 'svelte';
3
+ // Event Handler
4
+ const dispatch = createEventDispatcher();
3
5
  // Components
4
6
  import SvgIcon from '../../components/SvgIcon/SvgIcon.svelte';
5
7
  // Stores
@@ -24,11 +26,13 @@ function setElemHtmlClass() {
24
26
  $storeLightSwitch === true ? elemHtmlClassList.add('dark') : elemHtmlClassList.remove('dark');
25
27
  }
26
28
  // On Click Handler
27
- function onClick() {
29
+ function onClick(event) {
28
30
  // Set the Store Value
29
31
  storeLightSwitch.set(($storeLightSwitch = !$storeLightSwitch));
30
32
  // Apply to <html> Element
31
33
  setElemHtmlClass();
34
+ /** @event {{ event }} click - Fires when the component is clicked. */
35
+ dispatch('click', event);
32
36
  }
33
37
  // A11y Input Handlers
34
38
  function onKeyDown(event) {
@@ -37,6 +41,8 @@ function onKeyDown(event) {
37
41
  event.preventDefault();
38
42
  event.target.click();
39
43
  }
44
+ /** @event {{ event }} keydown - Fires when the component has keydown event. */
45
+ dispatch('keydown', event);
40
46
  }
41
47
  // Lifecycle
42
48
  onMount(() => {
@@ -54,8 +60,7 @@ $: classesThumb = `${cThumb} ${classesPosition}`;
54
60
  <!-- prettier-ignore -->
55
61
  <div
56
62
  class="lightswitch {classesBase}"
57
- on:click={onClick}
58
- on:keydown={onKeyDown}
63
+ on:click={onClick} on:keydown={onKeyDown} on:keyup on:keypress
59
64
  role="switch"
60
65
  aria-label="Light Switch"
61
66
  aria-checked={$storeLightSwitch}
@@ -1,9 +1,14 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- [x: string]: any;
4
+ [x: string]: never;
5
5
  };
6
6
  events: {
7
+ keyup: KeyboardEvent;
8
+ keypress: KeyboardEvent;
9
+ click: CustomEvent<any>;
10
+ keydown: CustomEvent<any>;
11
+ } & {
7
12
  [evt: string]: CustomEvent<any>;
8
13
  };
9
14
  slots: {};
@@ -3,8 +3,10 @@ interface Serializer<T> {
3
3
  parse(text: string): T;
4
4
  stringify(object: T): string;
5
5
  }
6
+ type StorageType = 'local' | 'session';
6
7
  interface Options<T> {
7
- serializer: Serializer<T>;
8
+ serializer?: Serializer<T>;
9
+ storage?: StorageType;
8
10
  }
9
11
  export declare function localStorageStore<T>(key: string, initialValue: T, options?: Options<T>): Writable<T>;
10
12
  export {};
@@ -2,18 +2,23 @@
2
2
  // https://github.com/joshnuss/svelte-local-storage-store/blob/master/index.ts
3
3
  // Represents version v0.3.1 (2022-08-21)
4
4
  import { writable as internal, get } from 'svelte/store';
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
5
6
  const stores = {};
7
+ function getStorage(type) {
8
+ return type === 'local' ? localStorage : sessionStorage;
9
+ }
6
10
  export function localStorageStore(key, initialValue, options) {
7
- const browser = typeof localStorage != 'undefined' && typeof window != 'undefined';
8
- const serializer = options?.serializer || JSON;
11
+ const serializer = options?.serializer ?? JSON;
12
+ const storageType = options?.storage ?? 'local';
13
+ const browser = typeof window !== 'undefined' && typeof document !== 'undefined';
9
14
  function updateStorage(key, value) {
10
15
  if (!browser)
11
16
  return;
12
- localStorage.setItem(key, serializer.stringify(value));
17
+ getStorage(storageType).setItem(key, serializer.stringify(value));
13
18
  }
14
19
  if (!stores[key]) {
15
20
  const store = internal(initialValue, (set) => {
16
- const json = browser ? localStorage.getItem(key) : null;
21
+ const json = browser ? getStorage(storageType).getItem(key) : null;
17
22
  if (json) {
18
23
  set(serializer.parse(json));
19
24
  }
@@ -37,9 +37,9 @@ export function menu(node, args) {
37
37
  args.state({ menu: args.menu, state });
38
38
  };
39
39
  // Click Handlers ---
40
- const onTriggerClick = () => {
40
+ const toggleMenu = () => {
41
41
  // When the node is clicked, open the menu if it is closed, otherwise close it
42
- if (elemMenu.style.display === 'none') {
42
+ if (elemMenu.style.display != 'block') {
43
43
  autoUpdateOrigin();
44
44
  menuOpen();
45
45
  }
@@ -52,17 +52,23 @@ export function menu(node, args) {
52
52
  };
53
53
  // Interactive FALSE - any click closes the menu
54
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.
55
+ // Any click outside the node closes the menu, but a click inside the node toggles the menu.
56
56
  const outsideNode = node && !node.contains(event.target);
57
57
  if (outsideNode) {
58
58
  menuClose();
59
59
  }
60
+ else {
61
+ toggleMenu();
62
+ }
60
63
  };
61
64
  // Interactive TRUE - clicks outside close menu
62
65
  const interactiveClickHandler = (event) => {
63
66
  const outsideNode = node && !node.contains(event.target);
64
67
  const outsideMenu = elemMenu && !elemMenu.contains(event.target);
65
- if (outsideNode && outsideMenu) {
68
+ if (!outsideNode) {
69
+ toggleMenu();
70
+ }
71
+ else if (outsideNode && outsideMenu) {
66
72
  menuClose();
67
73
  }
68
74
  };
@@ -85,7 +91,7 @@ export function menu(node, args) {
85
91
  if (key === 'Enter' || key === 'Space') {
86
92
  event.preventDefault();
87
93
  // Toggle menu
88
- onTriggerClick();
94
+ toggleMenu();
89
95
  }
90
96
  };
91
97
  const onWindowKeyDown = (event) => {
@@ -128,7 +134,6 @@ export function menu(node, args) {
128
134
  window.addEventListener('click', onWindowClick, true);
129
135
  window.addEventListener('keydown', onWindowKeyDown, true);
130
136
  // Trigger Node Events
131
- node.addEventListener('click', onTriggerClick);
132
137
  node.addEventListener('keydown', onTriggerKeyDown);
133
138
  node.addEventListener('change', (e) => {
134
139
  console.log(e);
@@ -140,7 +145,6 @@ export function menu(node, args) {
140
145
  window.removeEventListener('resize', onWindowClick, true);
141
146
  window.removeEventListener('click', onWindowClick, true);
142
147
  window.removeEventListener('keydown', onWindowKeyDown, true);
143
- node.removeEventListener('click', onTriggerClick);
144
148
  node.removeEventListener('keydown', onTriggerKeyDown);
145
149
  }
146
150
  };
@@ -1,7 +1,8 @@
1
- <script>import { fade, fly } from 'svelte/transition';
2
- // Actions
1
+ <script>import { createEventDispatcher } from 'svelte';
2
+ import { fade, fly } from 'svelte/transition';
3
+ // Event Handler
4
+ const dispatch = createEventDispatcher();
3
5
  import { focusTrap } from '../../actions/FocusTrap/focusTrap';
4
- // Stores
5
6
  import { modalStore } from './stores';
6
7
  // Props
7
8
  /** The open/close animation duration. Set '0' (zero) to disable. */
@@ -46,19 +47,30 @@ const cBackdrop = 'fixed top-0 left-0 right-0 bottom-0 z-[999] flex justify-cent
46
47
  const cModalImage = 'w-full h-auto';
47
48
  // Local
48
49
  let promptValue;
50
+ const buttonTextDefaults = {
51
+ buttonTextCancel,
52
+ buttonTextConfirm,
53
+ buttonTextSubmit
54
+ };
49
55
  // Modal Store Subscription
50
56
  modalStore.subscribe((dArr) => {
51
57
  if (!dArr.length)
52
58
  return;
53
- // Set the local modal value (for prompt)
59
+ // Set Prompt input value and type
54
60
  promptValue = dArr[0].value;
61
+ // Override button text per instance, if available
62
+ buttonTextCancel = dArr[0].buttonTextCancel || buttonTextDefaults.buttonTextCancel;
63
+ buttonTextConfirm = dArr[0].buttonTextConfirm || buttonTextDefaults.buttonTextConfirm;
64
+ buttonTextSubmit = dArr[0].buttonTextSubmit || buttonTextDefaults.buttonTextSubmit;
55
65
  });
56
66
  // Event Handlers ---
57
- function onBackdropInteraction(e) {
58
- if (!(e.target instanceof Element))
67
+ function onBackdropInteraction(event) {
68
+ if (!(event.target instanceof Element))
59
69
  return;
60
- if (e.target.classList.contains('modal-backdrop'))
70
+ if (event.target.classList.contains('modal-backdrop'))
61
71
  onClose();
72
+ /** @event {{ event }} backdrop - Fires on backdrop interaction. */
73
+ dispatch('backdrop', event);
62
74
  }
63
75
  function onClose() {
64
76
  if ($modalStore[0].response)
@@ -163,11 +175,11 @@ $: parent = {
163
175
  </footer>
164
176
  {:else if $modalStore[0].type === 'prompt'}
165
177
  <!-- Template: Prompt -->
166
- <input class="modal-prompt-input" type="text" bind:value={promptValue} required />
178
+ <input class="modal-prompt-input" type="text" bind:value={promptValue} />
167
179
  <!-- prettier-ignore -->
168
180
  <footer class="modal-footer {regionFooter}">
169
181
  <button class="btn {buttonNeutral}" on:click={onClose}>{buttonTextCancel}</button>
170
- <button class="btn {buttonPositive}" on:click={onPromptSubmit}>{buttonTextSubmit}</button>
182
+ <button class="btn {buttonPositive}" on:click={onPromptSubmit} disabled={!promptValue}>{buttonTextSubmit}</button>
171
183
  </footer>
172
184
  {:else if $modalStore[0].type === 'component'}
173
185
  <!-- Template: Component -->
@@ -21,6 +21,8 @@ declare const __propDef: {
21
21
  regionFooter?: string | undefined;
22
22
  };
23
23
  events: {
24
+ backdrop: CustomEvent<any>;
25
+ } & {
24
26
  [evt: string]: CustomEvent<any>;
25
27
  };
26
28
  slots: {};
@@ -23,4 +23,12 @@ export interface ModalSettings {
23
23
  response?: (r: any) => void;
24
24
  /** Provide abritrary classes to apply to the Modal element. Use `!` for important. */
25
25
  classes?: string;
26
+ /** Override the Cancel button label. */
27
+ buttonTextCancel?: string;
28
+ /** Override the Confirm button label. */
29
+ buttonTextConfirm?: string;
30
+ /** Override the Submit button label. */
31
+ buttonTextSubmit?: string;
32
+ /** Pass abitrary data per modal instance. */
33
+ meta?: any;
26
34
  }
@@ -12,11 +12,11 @@ export let max = 3;
12
12
  export let duration = 150;
13
13
  // Props (styles)
14
14
  /** Provide classes to set the background color. */
15
- export let background = 'bg-accent-500';
15
+ export let background = 'bg-secondary-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-on-accent-token';
19
+ export let color = 'text-on-secondary-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. */
@@ -21,8 +21,25 @@ function toastService() {
21
21
  /** Add a new toast to the queue. */
22
22
  trigger: (toast) => update((tStore) => {
23
23
  const id = randomUUID();
24
+ // Apply Preset Color Styles
25
+ let classes = toast.classes ?? '';
26
+ // prettier-ignore
27
+ switch (toast.preset) {
28
+ // Success/Error
29
+ case ('success'):
30
+ classes += '!bg-success-500 text-on-success-token';
31
+ break;
32
+ case ('error'):
33
+ classes += '!bg-error-500 text-on-error-token';
34
+ break;
35
+ // Theme
36
+ default:
37
+ classes += `!bg-${toast.preset}-500 text-on-${toast.preset}-token`;
38
+ break;
39
+ }
24
40
  // Merge into store
25
- const tMerged = { ...toastDefaults, ...toast, id };
41
+ const tMerged = { ...toastDefaults, ...toast, id, classes };
42
+ console.log(tMerged);
26
43
  tStore.push(tMerged);
27
44
  // Handle auto-hide, if needed
28
45
  handleAutoHide(tMerged);
@@ -1,6 +1,11 @@
1
1
  export interface ToastSettings {
2
2
  /** Provide the toast message. Supports HTML. */
3
3
  message: string;
4
+ /**
5
+ * Applies a canned set of styles.
6
+ * @type {'primary' | 'secondary' | 'tertiary' | 'warning' | 'success' | 'error'}
7
+ */
8
+ preset?: 'primary' | 'secondary' | 'tertiary' | 'warning' | 'success' | 'error';
4
9
  /** Enables auto-hide after the timeout duration. */
5
10
  autohide?: boolean;
6
11
  /** Set the auto-hide timeout duration. */
@@ -1,22 +0,0 @@
1
- /* Design Tokens: Misc */
2
-
3
- @layer utilities {
4
- /* === Input Accent Color === */
5
- /* https://developer.mozilla.org/en-US/docs/Web/CSS/accent-color */
6
-
7
- .accent-primary-token {
8
- @apply accent-accent-500;
9
- }
10
- .accent-accent-token {
11
- @apply accent-accent-500;
12
- }
13
- .accent-tertiary-token {
14
- @apply accent-accent-500;
15
- }
16
- .accent-warning-token {
17
- @apply accent-accent-500;
18
- }
19
- .accent-surface-token {
20
- @apply accent-accent-500;
21
- }
22
- }