@skeletonlabs/skeleton 0.80.9 → 0.92.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 (122) hide show
  1. package/README.md +1 -1
  2. package/components/Accordion/AccordionGroup.svelte +1 -2
  3. package/components/Accordion/AccordionItem.svelte +6 -3
  4. package/components/Accordion/AccordionItem.svelte.d.ts +1 -0
  5. package/components/Alert/Alert.svelte +3 -3
  6. package/components/AppRail/AppRailTile.svelte +8 -6
  7. package/components/AppShell/AppShell.svelte +3 -3
  8. package/components/Breadcrumb/Crumb.svelte +3 -1
  9. package/components/Breadcrumb/Crumb.svelte.d.ts +5 -0
  10. package/components/ConicGradient/ConicGradient.svelte +2 -2
  11. package/components/ConicGradient/ConicGradient.svelte.d.ts +5 -0
  12. package/{tailwind/colors.d.ts → components/ConicGradient/settings.d.ts} +1 -1
  13. package/{tailwind/colors.js → components/ConicGradient/settings.js} +1 -1
  14. package/components/FileButton/FileButton.svelte +2 -2
  15. package/components/FileButton/FileButton.svelte.d.ts +3 -0
  16. package/components/FileDropzone/FileDropzone.svelte +5 -4
  17. package/components/FileDropzone/FileDropzone.svelte.d.ts +4 -0
  18. package/components/GradientHeading/GradientHeading.svelte +1 -1
  19. package/components/InputChip/InputChip.svelte +107 -0
  20. package/components/InputChip/InputChip.svelte.d.ts +29 -0
  21. package/components/ListBox/ListBoxItem.svelte +6 -5
  22. package/components/ListBox/ListBoxItem.svelte.d.ts +2 -0
  23. package/components/Paginator/Paginator.svelte +21 -9
  24. package/components/Paginator/Paginator.svelte.d.ts +5 -1
  25. package/components/ProgressBar/ProgressBar.svelte +6 -4
  26. package/components/ProgressBar/ProgressBar.svelte.d.ts +1 -0
  27. package/components/ProgressRadial/ProgressRadial.svelte +1 -1
  28. package/components/Radio/RadioGroup.svelte +2 -2
  29. package/components/Radio/RadioItem.svelte +3 -1
  30. package/components/Radio/RadioItem.svelte.d.ts +2 -0
  31. package/components/RangeSlider/RangeSlider.svelte +1 -1
  32. package/components/SlideToggle/SlideToggle.svelte +9 -6
  33. package/components/SlideToggle/SlideToggle.svelte.d.ts +4 -1
  34. package/components/Stepper/Step.svelte +52 -13
  35. package/components/Stepper/Step.svelte.d.ts +11 -3
  36. package/components/Stepper/Stepper.svelte +32 -10
  37. package/components/Stepper/Stepper.svelte.d.ts +8 -3
  38. package/components/SvgIcon/SvgIcon.svelte +1 -1
  39. package/components/SvgIcon/icons.js +2 -148
  40. package/components/Tab/Tab.svelte +16 -4
  41. package/components/Tab/Tab.svelte.d.ts +5 -0
  42. package/components/Table/Table.svelte +3 -3
  43. package/components/TableOfContents/TableOfContents.svelte +132 -0
  44. package/components/TableOfContents/TableOfContents.svelte.d.ts +32 -0
  45. package/index.d.ts +2 -0
  46. package/index.js +2 -0
  47. package/package.json +37 -29
  48. package/styles/all.css +0 -3
  49. package/styles/core.css +3 -0
  50. package/styles/elements/alerts.css +43 -0
  51. package/styles/elements/badges.css +12 -6
  52. package/styles/elements/breadcrumbs.css +27 -0
  53. package/styles/elements/buttons.css +34 -10
  54. package/styles/elements/cards.css +23 -4
  55. package/styles/elements/chips.css +58 -5
  56. package/styles/elements/lists.css +1 -1
  57. package/styles/elements/logo-clouds.css +1 -1
  58. package/styles/elements/menus.css +1 -1
  59. package/styles/elements/placeholders.css +1 -1
  60. package/styles/elements/tables.css +1 -1
  61. package/styles/elements/tooltips.css +1 -1
  62. package/styles/elements.css +2 -0
  63. package/styles/forms.css +59 -41
  64. package/styles/typography.css +6 -6
  65. package/tailwind/generated/allComponents.cjs +1 -0
  66. package/tailwind/generated/allComponents.d.cts +5552 -0
  67. package/tailwind/settings.cjs +20 -0
  68. package/tailwind/settings.d.cts +6 -0
  69. package/tailwind/skeleton.cjs +54 -0
  70. package/tailwind/skeleton.d.cts +5 -0
  71. package/tailwind/theme/colors.cjs +18 -0
  72. package/tailwind/theme/colors.d.cts +2 -0
  73. package/tailwind/tokens/backgrounds.cjs +40 -0
  74. package/tailwind/tokens/backgrounds.d.cts +2 -0
  75. package/tailwind/tokens/border-radius.cjs +21 -0
  76. package/tailwind/tokens/border-radius.d.cts +33 -0
  77. package/tailwind/tokens/borders.cjs +20 -0
  78. package/tailwind/tokens/borders.d.cts +6 -0
  79. package/tailwind/tokens/fills.cjs +20 -0
  80. package/tailwind/tokens/fills.d.cts +15 -0
  81. package/tailwind/tokens/rings.cjs +42 -0
  82. package/tailwind/tokens/rings.d.cts +17 -0
  83. package/tailwind/tokens/text.cjs +33 -0
  84. package/tailwind/tokens/text.d.cts +21 -0
  85. package/themes/theme-crimson.css +88 -64
  86. package/themes/theme-gold-nouveau.css +108 -115
  87. package/themes/theme-hamlindigo.css +97 -74
  88. package/themes/theme-modern.css +107 -64
  89. package/themes/theme-rocket.css +96 -63
  90. package/themes/theme-sahara.css +104 -65
  91. package/themes/theme-seafoam.css +100 -66
  92. package/themes/theme-seasonal.css +111 -65
  93. package/themes/theme-skeleton.css +99 -75
  94. package/themes/theme-vintage.css +102 -63
  95. package/utilities/CodeBlock/CodeBlock.svelte +6 -1
  96. package/utilities/CodeBlock/CodeBlock.svelte.d.ts +2 -0
  97. package/utilities/DataTable/DataTable.js +3 -1
  98. package/utilities/Drawer/Drawer.svelte +11 -10
  99. package/utilities/Drawer/Drawer.svelte.d.ts +1 -2
  100. package/utilities/Drawer/stores.d.ts +1 -1
  101. package/utilities/LightSwitch/LightSwitch.svelte +42 -14
  102. package/utilities/LightSwitch/LightSwitch.svelte.d.ts +5 -0
  103. package/utilities/LightSwitch/stores.d.ts +2 -3
  104. package/utilities/LocalStorageStore/LocalStorageStore.d.ts +3 -1
  105. package/utilities/LocalStorageStore/LocalStorageStore.js +9 -4
  106. package/utilities/Menu/menu.js +11 -7
  107. package/utilities/Modal/Modal.svelte +25 -12
  108. package/utilities/Modal/Modal.svelte.d.ts +2 -0
  109. package/utilities/Modal/types.d.ts +12 -2
  110. package/utilities/Toast/Toast.svelte +2 -2
  111. package/utilities/Toast/stores.js +17 -1
  112. package/utilities/Toast/types.d.ts +5 -0
  113. package/styles/tokens/backgrounds.css +0 -239
  114. package/styles/tokens/border-radius.css +0 -41
  115. package/styles/tokens/borders.css +0 -185
  116. package/styles/tokens/fills.css +0 -29
  117. package/styles/tokens/misc.css +0 -22
  118. package/styles/tokens/rings.css +0 -185
  119. package/styles/tokens/text.css +0 -216
  120. package/styles/tokens.css +0 -11
  121. package/tailwind/theme.cjs +0 -37
  122. package/tailwind/theme.d.cts +0 -5
@@ -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,7 +1,7 @@
1
1
  <!-- https://tailwindcss.com/docs/dark-mode -->
2
- <script>import { onMount } from 'svelte';
3
- // Components
4
- import SvgIcon from '../../components/SvgIcon/SvgIcon.svelte';
2
+ <script>import { createEventDispatcher, onMount } from 'svelte';
3
+ // Event Handler
4
+ const dispatch = createEventDispatcher();
5
5
  // Stores
6
6
  import { storePrefersDarkScheme, storeLightSwitch } from './stores';
7
7
  // Base Classes
@@ -12,38 +12,51 @@ const cIcon = 'block w-4 h-4';
12
12
  function setPrefersDarkScheme() {
13
13
  const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
14
14
  storePrefersDarkScheme.set(prefersDark);
15
- }
16
- // Toggles a 'dark' class on the <html> element
17
- function setElemHtmlClass() {
18
- const elemHtmlClassList = document.documentElement.classList;
19
15
  // If $storeLightSwitch not set, match the OS preference
20
16
  if ($storeLightSwitch === undefined) {
21
17
  $storeLightSwitch = $storePrefersDarkScheme;
22
18
  }
19
+ }
20
+ // Toggles a 'dark' class on the <html> element
21
+ function setElemHtmlClass() {
22
+ const elemHtmlClassList = document.documentElement.classList;
23
23
  // Update HTML element class
24
- $storeLightSwitch === true ? elemHtmlClassList.add('dark') : elemHtmlClassList.remove('dark');
24
+ $storeLightSwitch ? elemHtmlClassList.add('dark') : elemHtmlClassList.remove('dark');
25
+ }
26
+ // Sets the color scheme based on localStorage or OS preference in
27
+ // the <head> of the document.
28
+ function setColorScheme() {
29
+ if (localStorage.getItem('storeLightSwitch') === 'true' ||
30
+ (!('storeLightSwitch' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
31
+ document.documentElement.classList.add('dark');
32
+ }
33
+ else {
34
+ document.documentElement.classList.remove('dark');
35
+ }
25
36
  }
26
37
  // On Click Handler
27
- function onClick() {
38
+ function onClick(event) {
28
39
  // Set the Store Value
29
40
  storeLightSwitch.set(($storeLightSwitch = !$storeLightSwitch));
30
41
  // Apply to <html> Element
31
42
  setElemHtmlClass();
43
+ /** @event {{ event }} click - Fires when the component is clicked. */
44
+ dispatch('click', event);
32
45
  }
33
46
  // A11y Input Handlers
34
47
  function onKeyDown(event) {
35
48
  // Enter/Space triggers selecton event
36
49
  if (['Enter', 'Space'].includes(event.code)) {
37
50
  event.preventDefault();
38
- event.target.click();
51
+ event.currentTarget.click();
39
52
  }
53
+ /** @event {{ event }} keydown - Fires when the component has keydown event. */
54
+ dispatch('keydown', event);
40
55
  }
41
56
  // Lifecycle
42
57
  onMount(() => {
43
58
  // Determine OS Preference
44
59
  setPrefersDarkScheme();
45
- // Finally, update HTML element class as needed
46
- setElemHtmlClass();
47
60
  });
48
61
  // Reactive Classses
49
62
  $: classesPosition = $storeLightSwitch ? 'translate-x-full' : 'translate-x-0';
@@ -51,11 +64,17 @@ $: classesBase = `${cTrack} ${$$props.class ?? ''}`;
51
64
  $: classesThumb = `${cThumb} ${classesPosition}`;
52
65
  </script>
53
66
 
67
+ <svelte:head>
68
+ {@html `<script>${setColorScheme.toString()} setColorScheme();</script>`}
69
+ </svelte:head>
70
+
54
71
  <!-- prettier-ignore -->
55
72
  <div
56
73
  class="lightswitch {classesBase}"
57
74
  on:click={onClick}
58
75
  on:keydown={onKeyDown}
76
+ on:keyup
77
+ on:keypress
59
78
  role="switch"
60
79
  aria-label="Light Switch"
61
80
  aria-checked={$storeLightSwitch}
@@ -64,7 +83,16 @@ $: classesThumb = `${cThumb} ${classesPosition}`;
64
83
  >
65
84
  <!-- Thumb -->
66
85
  <div class="lightswitch-thumb {classesThumb}">
67
- <!-- SVG Icon -->
68
- <SvgIcon name={$storeLightSwitch === false ? 'sun' : 'moon'} class="lightswitch-icon {cIcon}" />
86
+ {#if $storeLightSwitch === false}
87
+ <!-- Icon Light -->
88
+ <svg class="lightswitch-icon fill-black {cIcon}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
89
+ <path d="M361.5 1.2c5 2.1 8.6 6.6 9.6 11.9L391 121l107.9 19.8c5.3 1 9.8 4.6 11.9 9.6s1.5 10.7-1.6 15.2L446.9 256l62.3 90.3c3.1 4.5 3.7 10.2 1.6 15.2s-6.6 8.6-11.9 9.6L391 391 371.1 498.9c-1 5.3-4.6 9.8-9.6 11.9s-10.7 1.5-15.2-1.6L256 446.9l-90.3 62.3c-4.5 3.1-10.2 3.7-15.2 1.6s-8.6-6.6-9.6-11.9L121 391 13.1 371.1c-5.3-1-9.8-4.6-11.9-9.6s-1.5-10.7 1.6-15.2L65.1 256 2.8 165.7c-3.1-4.5-3.7-10.2-1.6-15.2s6.6-8.6 11.9-9.6L121 121 140.9 13.1c1-5.3 4.6-9.8 9.6-11.9s10.7-1.5 15.2 1.6L256 65.1 346.3 2.8c4.5-3.1 10.2-3.7 15.2-1.6zM352 256c0 53-43 96-96 96s-96-43-96-96s43-96 96-96s96 43 96 96zm32 0c0-70.7-57.3-128-128-128s-128 57.3-128 128s57.3 128 128 128s128-57.3 128-128z"/>
90
+ </svg>
91
+ {:else}
92
+ <!-- Icon Dark -->
93
+ <svg class="lightswitch-icon fill-white {cIcon}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512">
94
+ <path d="M223.5 32C100 32 0 132.3 0 256S100 480 223.5 480c60.6 0 115.5-24.2 155.8-63.4c5-4.9 6.3-12.5 3.1-18.7s-10.1-9.7-17-8.5c-9.8 1.7-19.8 2.6-30.1 2.6c-96.9 0-175.5-78.8-175.5-176c0-65.8 36-123.1 89.3-153.3c6.1-3.5 9.2-10.5 7.7-17.3s-7.3-11.9-14.3-12.5c-6.3-.5-12.6-.8-19-.8z"/>
95
+ </svg>
96
+ {/if}
69
97
  </div>
70
98
  </div>
@@ -4,6 +4,11 @@ declare const __propDef: {
4
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: {};
@@ -1,3 +1,2 @@
1
- import type { Writable } from 'svelte/store';
2
- export declare const storePrefersDarkScheme: Writable<boolean>;
3
- export declare const storeLightSwitch: Writable<boolean | undefined>;
1
+ export declare const storePrefersDarkScheme: import("svelte/store").Writable<boolean>;
2
+ export declare const storeLightSwitch: import("svelte/store").Writable<boolean | undefined>;
@@ -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. */
@@ -43,22 +44,34 @@ export let regionBody = 'max-h-[200px] overflow-hidden';
43
44
  export let regionFooter = 'flex justify-end space-x-2';
44
45
  // Base Styles
45
46
  const cBackdrop = 'fixed top-0 left-0 right-0 bottom-0 z-[999] flex justify-center items-center p-4';
47
+ const cModal = 'max-h-full overflow-y-auto overflow-x-hidden';
46
48
  const cModalImage = 'w-full h-auto';
47
49
  // Local
48
50
  let promptValue;
51
+ const buttonTextDefaults = {
52
+ buttonTextCancel,
53
+ buttonTextConfirm,
54
+ buttonTextSubmit
55
+ };
49
56
  // Modal Store Subscription
50
57
  modalStore.subscribe((dArr) => {
51
58
  if (!dArr.length)
52
59
  return;
53
- // Set the local modal value (for prompt)
60
+ // Set Prompt input value and type
54
61
  promptValue = dArr[0].value;
62
+ // Override button text per instance, if available
63
+ buttonTextCancel = dArr[0].buttonTextCancel || buttonTextDefaults.buttonTextCancel;
64
+ buttonTextConfirm = dArr[0].buttonTextConfirm || buttonTextDefaults.buttonTextConfirm;
65
+ buttonTextSubmit = dArr[0].buttonTextSubmit || buttonTextDefaults.buttonTextSubmit;
55
66
  });
56
67
  // Event Handlers ---
57
- function onBackdropInteraction(e) {
58
- if (!(e.target instanceof Element))
68
+ function onBackdropInteraction(event) {
69
+ if (!(event.target instanceof Element))
59
70
  return;
60
- if (e.target.classList.contains('modal-backdrop'))
71
+ if (event.target.classList.contains('modal-backdrop'))
61
72
  onClose();
73
+ /** @event {{ event }} backdrop - Fires on backdrop interaction. */
74
+ dispatch('backdrop', event);
62
75
  }
63
76
  function onClose() {
64
77
  if ($modalStore[0].response)
@@ -84,7 +97,7 @@ function onKeyDown(event) {
84
97
  }
85
98
  // Reactive
86
99
  $: classesBackdrop = `${cBackdrop} ${regionBackdrop} ${$$props.class || ''}`;
87
- $: classesModal = `${background} ${width} ${height} ${padding} ${spacing} ${rounded} ${shadow}`;
100
+ $: classesModal = `${cModal} ${background} ${width} ${height} ${padding} ${spacing} ${rounded} ${shadow}`;
88
101
  // IMPORTANT: add values to pass to the children templates.
89
102
  // There is a way to self-reference component values, but it involes svelte-internal and is not yet stable.
90
103
  // REPL: https://svelte.dev/repl/badd0f11aa99450ca69dca6690d4d5a4?version=3.52.0
@@ -119,7 +132,7 @@ $: parent = {
119
132
  {#key $modalStore}
120
133
  <!-- Backdrop -->
121
134
  <div
122
- class="modal-backdrop {classesBackdrop}"
135
+ class="modal-backdrop {classesBackdrop} {$modalStore[0].backdropClasses}"
123
136
  on:mousedown={onBackdropInteraction}
124
137
  on:touchstart={onBackdropInteraction}
125
138
  transition:fade={{ duration }}
@@ -127,7 +140,7 @@ $: parent = {
127
140
  >
128
141
  <!-- Modal -->
129
142
  <div
130
- class="modal {classesModal} {$modalStore[0].classes}"
143
+ class="modal {classesModal} {$modalStore[0].modalClasses}"
131
144
  transition:fly={{ duration, opacity: 0, y: 100 }}
132
145
  use:focusTrap={true}
133
146
  data-testid="modal"
@@ -163,11 +176,11 @@ $: parent = {
163
176
  </footer>
164
177
  {:else if $modalStore[0].type === 'prompt'}
165
178
  <!-- Template: Prompt -->
166
- <input class="modal-prompt-input" type="text" bind:value={promptValue} required />
179
+ <input class="modal-prompt-input" type="text" bind:value={promptValue} />
167
180
  <!-- prettier-ignore -->
168
181
  <footer class="modal-footer {regionFooter}">
169
182
  <button class="btn {buttonNeutral}" on:click={onClose}>{buttonTextCancel}</button>
170
- <button class="btn {buttonPositive}" on:click={onPromptSubmit}>{buttonTextSubmit}</button>
183
+ <button class="btn {buttonPositive}" on:click={onPromptSubmit} disabled={!promptValue}>{buttonTextSubmit}</button>
171
184
  </footer>
172
185
  {:else if $modalStore[0].type === 'component'}
173
186
  <!-- 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: {};
@@ -21,6 +21,16 @@ export interface ModalSettings {
21
21
  component?: ModalComponent;
22
22
  /** Provide a function. Returns the repsonse value. */
23
23
  response?: (r: any) => void;
24
- /** Provide abritrary classes to apply to the Modal element. Use `!` for important. */
25
- classes?: string;
24
+ /** Provide abitrary classes to the backdrop. */
25
+ backdropClasses?: string;
26
+ /** Provide abitrary classes to the modal window. */
27
+ modalClasses?: string;
28
+ /** Override the Cancel button label. */
29
+ buttonTextCancel?: string;
30
+ /** Override the Confirm button label. */
31
+ buttonTextConfirm?: string;
32
+ /** Override the Submit button label. */
33
+ buttonTextSubmit?: string;
34
+ /** Pass abitrary data per modal instance. */
35
+ meta?: any;
26
36
  }