@skeletonlabs/skeleton 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/AppBar/AppBar.svelte +1 -1
- package/components/AppRail/AppRailTile.svelte +1 -1
- package/components/AppRail/AppRailTile.svelte.d.ts +2 -2
- package/components/Autocomplete/Autocomplete.svelte +79 -0
- package/components/Autocomplete/Autocomplete.svelte.d.ts +44 -0
- package/components/Autocomplete/types.d.ts +10 -0
- package/components/Autocomplete/types.js +2 -0
- package/components/Avatar/Avatar.svelte +5 -1
- package/components/FileButton/FileButton.svelte +3 -2
- package/components/FileButton/FileButton.svelte.d.ts +2 -0
- package/components/InputChip/InputChip.svelte +13 -13
- package/components/InputChip/InputChip.svelte.d.ts +3 -0
- package/components/Stepper/Step.svelte +3 -1
- package/components/TableOfContents/TableOfContents.svelte +3 -3
- package/fonts/quicksand/Quicksand-VariableFont_wght.ttf +0 -0
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/package.json +5 -1
- package/styles/elements/lists.css +2 -0
- package/tailwind/generated/intellisense-classes.cjs +1 -1
- package/tailwind/generated/intellisense-classes.d.cts +90 -0
- package/tailwind/intellisense.cjs +1 -1
- package/tailwind/tokens/rings.cjs +2 -2
- package/themes/theme-gold-nouveau.css +0 -1
- package/themes/theme-hamlindigo.css +1 -3
- package/themes/theme-modern.css +0 -1
- package/themes/theme-rocket.css +1 -4
- package/themes/theme-sahara.css +4 -7
- package/themes/theme-seafoam.css +1 -2
- package/themes/theme-seasonal.css +0 -1
- package/themes/theme-skeleton.css +0 -3
- package/themes/theme-vintage.css +2 -4
- package/utilities/Drawer/Drawer.svelte +3 -2
- package/utilities/Drawer/Drawer.svelte.d.ts +2 -0
- package/utilities/LightSwitch/lightswitch.js +3 -3
- package/utilities/Modal/Modal.svelte +5 -3
- package/utilities/Modal/Modal.svelte.d.ts +2 -0
- package/utilities/Popup/popup.d.ts +1 -1
- package/utilities/Popup/popup.js +73 -22
- package/utilities/Popup/types.d.ts +1 -1
- package/utilities/Toast/Toast.svelte +3 -2
- package/utilities/Toast/Toast.svelte.d.ts +2 -0
|
@@ -45,6 +45,19 @@ declare const _exports: {
|
|
|
45
45
|
borderWidth: string;
|
|
46
46
|
borderColor: string;
|
|
47
47
|
};
|
|
48
|
+
".\\!input": {
|
|
49
|
+
width: string;
|
|
50
|
+
transitionProperty: string;
|
|
51
|
+
transitionTimingFunction: string;
|
|
52
|
+
transitionDuration: string;
|
|
53
|
+
backgroundColor: string;
|
|
54
|
+
"--tw-ring-offset-shadow": string;
|
|
55
|
+
"--tw-ring-shadow": string;
|
|
56
|
+
boxShadow: string;
|
|
57
|
+
borderWidth: string;
|
|
58
|
+
borderColor: string;
|
|
59
|
+
borderRadius: string;
|
|
60
|
+
};
|
|
48
61
|
".dark .input,.dark \n\t.textarea,.dark \n\t.select,.dark \n\t.input-group": {
|
|
49
62
|
backgroundColor: string;
|
|
50
63
|
borderColor: string;
|
|
@@ -57,10 +70,26 @@ declare const _exports: {
|
|
|
57
70
|
"--tw-brightness": string;
|
|
58
71
|
filter: string;
|
|
59
72
|
};
|
|
73
|
+
".dark .\\!input": {
|
|
74
|
+
backgroundColor: string;
|
|
75
|
+
borderColor: string;
|
|
76
|
+
};
|
|
77
|
+
".\\!input:hover": {
|
|
78
|
+
"--tw-brightness": string;
|
|
79
|
+
filter: string;
|
|
80
|
+
};
|
|
81
|
+
".\\!input:focus": {
|
|
82
|
+
"--tw-brightness": string;
|
|
83
|
+
filter: string;
|
|
84
|
+
};
|
|
60
85
|
".input:focus-within,\n\t.textarea:focus-within,\n\t.select:focus-within,\n\t.input-group:focus-within": {
|
|
61
86
|
"--tw-border-opacity": string;
|
|
62
87
|
borderColor: string;
|
|
63
88
|
};
|
|
89
|
+
".\\!input:focus-within": {
|
|
90
|
+
"--tw-border-opacity": string;
|
|
91
|
+
borderColor: string;
|
|
92
|
+
};
|
|
64
93
|
".input,\n\t.input-group": {
|
|
65
94
|
borderRadius: string;
|
|
66
95
|
};
|
|
@@ -160,6 +189,9 @@ declare const _exports: {
|
|
|
160
189
|
".input[type='file']": {
|
|
161
190
|
padding: string;
|
|
162
191
|
};
|
|
192
|
+
".\\!input[type='file']": {
|
|
193
|
+
padding: string;
|
|
194
|
+
};
|
|
163
195
|
".input[type='color']": {
|
|
164
196
|
height: string;
|
|
165
197
|
width: string;
|
|
@@ -169,9 +201,21 @@ declare const _exports: {
|
|
|
169
201
|
borderRadius: string;
|
|
170
202
|
WebkitAppearance: string;
|
|
171
203
|
};
|
|
204
|
+
".\\!input[type='color']": {
|
|
205
|
+
height: string;
|
|
206
|
+
width: string;
|
|
207
|
+
cursor: string;
|
|
208
|
+
overflow: string;
|
|
209
|
+
borderStyle: string;
|
|
210
|
+
borderRadius: string;
|
|
211
|
+
WebkitAppearance: string;
|
|
212
|
+
};
|
|
172
213
|
".input[type='color']::-webkit-color-swatch-wrapper": {
|
|
173
214
|
padding: string;
|
|
174
215
|
};
|
|
216
|
+
".\\!input[type='color']::-webkit-color-swatch-wrapper": {
|
|
217
|
+
padding: string;
|
|
218
|
+
};
|
|
175
219
|
".input[type='color']::-webkit-color-swatch": {
|
|
176
220
|
borderStyle: string;
|
|
177
221
|
};
|
|
@@ -179,9 +223,19 @@ declare const _exports: {
|
|
|
179
223
|
"--tw-brightness": string;
|
|
180
224
|
filter: string;
|
|
181
225
|
};
|
|
226
|
+
".\\!input[type='color']::-webkit-color-swatch": {
|
|
227
|
+
borderStyle: string;
|
|
228
|
+
};
|
|
229
|
+
".\\!input[type='color']::-webkit-color-swatch:hover": {
|
|
230
|
+
"--tw-brightness": string;
|
|
231
|
+
filter: string;
|
|
232
|
+
};
|
|
182
233
|
".input[type='color']::-moz-color-swatch": {
|
|
183
234
|
borderStyle: string;
|
|
184
235
|
};
|
|
236
|
+
".\\!input[type='color']::-moz-color-swatch": {
|
|
237
|
+
borderStyle: string;
|
|
238
|
+
};
|
|
185
239
|
".input:disabled,\n\t.textarea:disabled,\n\t.select:disabled": {
|
|
186
240
|
cursor: string;
|
|
187
241
|
opacity: string;
|
|
@@ -190,6 +244,14 @@ declare const _exports: {
|
|
|
190
244
|
"--tw-brightness": string;
|
|
191
245
|
filter: string;
|
|
192
246
|
};
|
|
247
|
+
".\\!input:disabled": {
|
|
248
|
+
cursor: string;
|
|
249
|
+
opacity: string;
|
|
250
|
+
};
|
|
251
|
+
".\\!input:disabled:hover": {
|
|
252
|
+
"--tw-brightness": string;
|
|
253
|
+
filter: string;
|
|
254
|
+
};
|
|
193
255
|
".input[readonly],\n\t.textarea[readonly],\n\t.select[readonly]": {
|
|
194
256
|
cursor: string;
|
|
195
257
|
borderWidth: string;
|
|
@@ -198,6 +260,14 @@ declare const _exports: {
|
|
|
198
260
|
"--tw-brightness": string;
|
|
199
261
|
filter: string;
|
|
200
262
|
};
|
|
263
|
+
".\\!input[readonly]": {
|
|
264
|
+
cursor: string;
|
|
265
|
+
borderWidth: string;
|
|
266
|
+
};
|
|
267
|
+
".\\!input[readonly]:hover": {
|
|
268
|
+
"--tw-brightness": string;
|
|
269
|
+
filter: string;
|
|
270
|
+
};
|
|
201
271
|
".input-group": {
|
|
202
272
|
display: string;
|
|
203
273
|
overflow: string;
|
|
@@ -770,6 +840,8 @@ declare const _exports: {
|
|
|
770
840
|
paddingRight: string;
|
|
771
841
|
paddingTop: string;
|
|
772
842
|
paddingBottom: string;
|
|
843
|
+
outline: string;
|
|
844
|
+
outlineOffset: string;
|
|
773
845
|
cursor: string;
|
|
774
846
|
borderRadius: string;
|
|
775
847
|
};
|
|
@@ -781,6 +853,16 @@ declare const _exports: {
|
|
|
781
853
|
".list-nav a:hover,\n\t.list-nav button:hover,\n\t.list-option:hover": {
|
|
782
854
|
backgroundColor: string;
|
|
783
855
|
};
|
|
856
|
+
".list-nav a:focus,\n\t.list-nav button:focus,\n\t.list-option:focus": {
|
|
857
|
+
"--tw-bg-opacity": string;
|
|
858
|
+
backgroundColor: string;
|
|
859
|
+
color: string;
|
|
860
|
+
};
|
|
861
|
+
".dark .list-nav a:focus,.dark \n\t.list-nav button:focus,.dark \n\t.list-option:focus": {
|
|
862
|
+
"--tw-bg-opacity": string;
|
|
863
|
+
backgroundColor: string;
|
|
864
|
+
color: string;
|
|
865
|
+
};
|
|
784
866
|
".logo-cloud": {
|
|
785
867
|
display: string;
|
|
786
868
|
overflow: string;
|
|
@@ -1453,6 +1535,9 @@ declare const _exports: {
|
|
|
1453
1535
|
".h-\\[280px\\]": {
|
|
1454
1536
|
height: string;
|
|
1455
1537
|
};
|
|
1538
|
+
".max-h-\\[180px\\]": {
|
|
1539
|
+
maxHeight: string;
|
|
1540
|
+
};
|
|
1456
1541
|
".max-h-\\[480px\\]": {
|
|
1457
1542
|
maxHeight: string;
|
|
1458
1543
|
};
|
|
@@ -1827,6 +1912,11 @@ declare const _exports: {
|
|
|
1827
1912
|
".duration-\\[200ms\\]": {
|
|
1828
1913
|
transitionDuration: string;
|
|
1829
1914
|
};
|
|
1915
|
+
".hover\\:scale-105:hover": {
|
|
1916
|
+
"--tw-scale-x": string;
|
|
1917
|
+
"--tw-scale-y": string;
|
|
1918
|
+
transform: string;
|
|
1919
|
+
};
|
|
1830
1920
|
".hover\\:card:hover": {
|
|
1831
1921
|
backgroundColor: string;
|
|
1832
1922
|
"--tw-ring-offset-shadow": string;
|
|
@@ -7,7 +7,7 @@ const settings = require('../settings.cjs');
|
|
|
7
7
|
const ringTokenTheme = {
|
|
8
8
|
'--tw-ring-offset-shadow': `var(--tw-ring-inset) 0 0 0 var(--theme-border-base) var(--tw-ring-offset-color)`,
|
|
9
9
|
'--tw-ring-shadow': `var(--tw-ring-inset) 0 0 0 calc(2px + var(--theme-border-base)) var(--tw-ring-color)`,
|
|
10
|
-
'box-shadow': `var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000)
|
|
10
|
+
'box-shadow': `var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000)`
|
|
11
11
|
};
|
|
12
12
|
const ringOutlineShared = {
|
|
13
13
|
// .ring-[1px]
|
|
@@ -21,7 +21,7 @@ const ringOutlineShared = {
|
|
|
21
21
|
module.exports = () => {
|
|
22
22
|
const classes = {
|
|
23
23
|
'.ring-token': {
|
|
24
|
-
...ringTokenTheme
|
|
24
|
+
...ringTokenTheme
|
|
25
25
|
},
|
|
26
26
|
// Ring Outline (for cards)
|
|
27
27
|
// Example: .ring-outline-token
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/* https://github.com/skeletonlabs/skeleton/discussions/401 */
|
|
3
3
|
|
|
4
4
|
/* https://fonts.google.com/specimen/Quicksand?query=Quicksand */
|
|
5
|
-
@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap');
|
|
6
5
|
|
|
7
6
|
/* =~= Gold Nouveau =~= */
|
|
8
7
|
:root {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/* =~= Hamlindigo Theme - made by GitHub user @rcgy for the Skeleton community. Go watch Better Call Saul. =~= */
|
|
2
2
|
/* https://github.com/skeletonlabs/skeleton/discussions/401 */
|
|
3
3
|
|
|
4
|
-
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,500;1,600;1,700;1,800&display=swap');
|
|
5
|
-
|
|
6
4
|
:root {
|
|
7
5
|
/* =~= Hamlindigo Theme | Custom =~= */
|
|
8
6
|
--theme-font-family-base: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
|
|
9
7
|
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
|
10
|
-
--theme-font-family-heading:
|
|
8
|
+
--theme-font-family-heading: serif;
|
|
11
9
|
--theme-font-color-base: 0 0 0;
|
|
12
10
|
--theme-font-color-dark: 255 255 255;
|
|
13
11
|
--theme-rounded-base: 2px;
|
package/themes/theme-modern.css
CHANGED
package/themes/theme-rocket.css
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/* https://fonts.google.com/specimen/Space+Grotesk */
|
|
2
|
-
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
|
|
3
|
-
/* https://fonts.google.com/specimen/Roboto?query=roboto */
|
|
4
|
-
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
|
|
5
2
|
|
|
6
3
|
:root {
|
|
7
4
|
/* =~= Theme Properties =~= */
|
|
8
|
-
--theme-font-family-base:
|
|
5
|
+
--theme-font-family-base: system-ui;
|
|
9
6
|
--theme-font-family-heading: 'Space Grotesk', sans-serif;
|
|
10
7
|
--theme-font-color-base: var(--color-primary-900);
|
|
11
8
|
--theme-font-color-dark: var(--color-primary-100);
|
package/themes/theme-sahara.css
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
/* https://fonts.google.com/specimen/Raleway */
|
|
2
|
-
@import url('https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
|
|
3
|
-
/* https://fonts.google.com/specimen/Lato?query=lato¬o.query=Abril */
|
|
4
|
-
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap');
|
|
5
|
-
|
|
6
1
|
:root {
|
|
7
2
|
/* =~= Theme Styles =~= */
|
|
8
|
-
--theme-font-family-base:
|
|
9
|
-
|
|
3
|
+
--theme-font-family-base: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
|
|
4
|
+
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
|
5
|
+
--theme-font-family-heading: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
|
|
6
|
+
Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
|
10
7
|
--theme-font-color-base: var(--color-secondary-900);
|
|
11
8
|
--theme-font-color-dark: var(--color-primary-100);
|
|
12
9
|
--theme-rounded-base: 9999px;
|
package/themes/theme-seafoam.css
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/* https://fonts.google.com/specimen/Playfair+Display?query=playfair
|
|
2
|
-
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
|
|
1
|
+
/* https://fonts.google.com/specimen/Playfair+Display?query=playfair */
|
|
3
2
|
|
|
4
3
|
:root {
|
|
5
4
|
/* =~= Theme Styles =~= */
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/* https://fonts.google.com/specimen/Lato?query=lato¬o.query=Abril */
|
|
2
|
-
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap');
|
|
3
|
-
|
|
4
1
|
:root {
|
|
5
2
|
/* =~= Theme Properties =~= */
|
|
6
3
|
--theme-font-family-base: system-ui;
|
package/themes/theme-vintage.css
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/* https://fonts.google.com/specimen/Abril+Fatface?query=Abril+Fatface¬o.query=Abril */
|
|
2
|
-
@import url('https://fonts.googleapis.com/css2?family=Abril+Fatface&display=swap');
|
|
3
|
-
/* https://fonts.google.com/noto/specimen/Noto+Sans?query=sans */
|
|
4
|
-
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100;0,200;0,300;0,400;1,100;1,200;1,300&display=swap');
|
|
5
2
|
|
|
6
3
|
:root {
|
|
7
4
|
/* =~= Theme Styles =~= */
|
|
8
|
-
--theme-font-family-base: '
|
|
5
|
+
--theme-font-family-base: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
|
|
6
|
+
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
|
9
7
|
--theme-font-family-heading: 'Abril Fatface', cursive;
|
|
10
8
|
--theme-font-color-base: var(--color-primary-900);
|
|
11
9
|
--theme-font-color-dark: var(--color-primary-100);
|
|
@@ -14,6 +14,7 @@ export let rounded = "";
|
|
|
14
14
|
export let shadow = "shadow-xl";
|
|
15
15
|
export let width = "";
|
|
16
16
|
export let height = "";
|
|
17
|
+
export let zIndex = "z-40";
|
|
17
18
|
export let regionBackdrop = "";
|
|
18
19
|
export let regionDrawer = "";
|
|
19
20
|
export let labelledby = "";
|
|
@@ -24,7 +25,7 @@ const presets = {
|
|
|
24
25
|
left: { alignment: "justify-start", width: "w-[90%]", height: "h-full", rounded: "rounded-tr-container-token rounded-br-container-token" },
|
|
25
26
|
right: { alignment: "justify-end", width: "w-[90%]", height: "h-full", rounded: "rounded-tl-container-token rounded-bl-container-token" }
|
|
26
27
|
};
|
|
27
|
-
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0
|
|
28
|
+
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0 flex";
|
|
28
29
|
const cDrawer = "ox-border overflow-y-auto transition-transform";
|
|
29
30
|
let elemBackdrop;
|
|
30
31
|
let elemDrawer;
|
|
@@ -110,7 +111,7 @@ $:
|
|
|
110
111
|
$:
|
|
111
112
|
classesRounded = rounded ? rounded : presets[position].rounded;
|
|
112
113
|
$:
|
|
113
|
-
classesBackdrop = `${cBackdrop} ${bgBackdrop} ${padding} ${blur} ${classesPosition} ${regionBackdrop} ${$$props.class ?? ""}`;
|
|
114
|
+
classesBackdrop = `${cBackdrop} ${bgBackdrop} ${padding} ${blur} ${classesPosition} ${regionBackdrop} ${zIndex} ${$$props.class ?? ""}`;
|
|
114
115
|
$:
|
|
115
116
|
classesDrawer = `${cDrawer} ${bgDrawer} ${border} ${rounded} ${shadow} ${classesWidth} ${classesHeight} ${classesRounded} ${regionDrawer}`;
|
|
116
117
|
</script>
|
|
@@ -24,6 +24,8 @@ declare const __propDef: {
|
|
|
24
24
|
width?: string | undefined;
|
|
25
25
|
/** Drawer - Provide classes to override the height.*/
|
|
26
26
|
height?: string | undefined;
|
|
27
|
+
/** Provide a class to override the z-index*/
|
|
28
|
+
zIndex?: string | undefined;
|
|
27
29
|
/** Provide arbitrary classes to the backdrop region.*/
|
|
28
30
|
regionBackdrop?: string | undefined;
|
|
29
31
|
/** Provide arbitrary classes to the drawer region.*/
|
|
@@ -44,11 +44,11 @@ export function setModeCurrent(value) {
|
|
|
44
44
|
export function setInitialClassState() {
|
|
45
45
|
const elemHtmlClasses = document.documentElement.classList;
|
|
46
46
|
// Conditions
|
|
47
|
-
const
|
|
48
|
-
const
|
|
47
|
+
const condLocalStorageUserPrefs = localStorage.getItem('modeUserPrefers') === 'false';
|
|
48
|
+
const condLocalStorageUserPrefsExists = !('modeUserPrefers' in localStorage);
|
|
49
49
|
const condMatchMedia = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
50
50
|
// Add/remove `.dark` class to HTML element
|
|
51
|
-
if (
|
|
51
|
+
if (condLocalStorageUserPrefs || (condLocalStorageUserPrefsExists && condMatchMedia)) {
|
|
52
52
|
elemHtmlClasses.add('dark');
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
@@ -16,6 +16,7 @@ export let padding = "p-4";
|
|
|
16
16
|
export let spacing = "space-y-4";
|
|
17
17
|
export let rounded = "rounded-container-token";
|
|
18
18
|
export let shadow = "shadow-xl";
|
|
19
|
+
export let zIndex = "z-[999]";
|
|
19
20
|
export let buttonNeutral = "variant-ghost-surface";
|
|
20
21
|
export let buttonPositive = "variant-filled";
|
|
21
22
|
export let buttonTextCancel = "Cancel";
|
|
@@ -25,7 +26,7 @@ export let regionBackdrop = "bg-surface-backdrop-token";
|
|
|
25
26
|
export let regionHeader = "text-2xl font-bold";
|
|
26
27
|
export let regionBody = "max-h-[200px] overflow-hidden";
|
|
27
28
|
export let regionFooter = "flex justify-end space-x-2";
|
|
28
|
-
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0
|
|
29
|
+
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0";
|
|
29
30
|
const cTransitionLayer = "w-full h-full p-4 overflow-y-auto flex justify-center";
|
|
30
31
|
const cModal = "block";
|
|
31
32
|
const cModalImage = "w-full h-auto";
|
|
@@ -65,7 +66,8 @@ function onConfirm() {
|
|
|
65
66
|
$modalStore[0].response(true);
|
|
66
67
|
modalStore.close();
|
|
67
68
|
}
|
|
68
|
-
function onPromptSubmit() {
|
|
69
|
+
function onPromptSubmit(event) {
|
|
70
|
+
event.preventDefault();
|
|
69
71
|
if ($modalStore[0].response)
|
|
70
72
|
$modalStore[0].response(promptValue);
|
|
71
73
|
modalStore.close();
|
|
@@ -79,7 +81,7 @@ function onKeyDown(event) {
|
|
|
79
81
|
$:
|
|
80
82
|
cPosition = $modalStore[0]?.position ?? position;
|
|
81
83
|
$:
|
|
82
|
-
classesBackdrop = `${cBackdrop} ${regionBackdrop} ${$$props.class ?? ""} ${$modalStore[0]?.backdropClasses ?? ""}`;
|
|
84
|
+
classesBackdrop = `${cBackdrop} ${regionBackdrop} ${zIndex} ${$$props.class ?? ""} ${$modalStore[0]?.backdropClasses ?? ""}`;
|
|
83
85
|
$:
|
|
84
86
|
classesTransitionLayer = `${cTransitionLayer} ${cPosition ?? ""}`;
|
|
85
87
|
$:
|
|
@@ -29,6 +29,8 @@ declare const __propDef: {
|
|
|
29
29
|
rounded?: string | undefined;
|
|
30
30
|
/** Provide classes to style modal box shadow.*/
|
|
31
31
|
shadow?: string | undefined;
|
|
32
|
+
/** Provide a class to override the z-index*/
|
|
33
|
+
zIndex?: string | undefined;
|
|
32
34
|
/** Provide classes for neutral buttons, such as Cancel.*/
|
|
33
35
|
buttonNeutral?: string | undefined;
|
|
34
36
|
/** Provide classes for positive actions, such as Confirm or Submit.*/
|
|
@@ -2,6 +2,6 @@ import { type Writable } from 'svelte/store';
|
|
|
2
2
|
import type { PopupSettings } from './types';
|
|
3
3
|
export declare const storePopup: Writable<any>;
|
|
4
4
|
export declare function popup(node: HTMLElement, args: PopupSettings): {
|
|
5
|
-
update(newArgs:
|
|
5
|
+
update(newArgs: PopupSettings): void;
|
|
6
6
|
destroy(): void;
|
|
7
7
|
} | undefined;
|
package/utilities/Popup/popup.js
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
import { get, writable } from 'svelte/store';
|
|
2
2
|
// Store
|
|
3
3
|
export const storePopup = writable(undefined);
|
|
4
|
+
function isNode(node) {
|
|
5
|
+
return node instanceof Node;
|
|
6
|
+
}
|
|
4
7
|
// Action
|
|
5
8
|
export function popup(node, args) {
|
|
6
|
-
|
|
7
|
-
const { event = 'click', target, placement, closeQuery = 'a[href], button', middleware, state } = args;
|
|
8
|
-
if (!event || !target)
|
|
9
|
+
if (!args.event || !args.target)
|
|
9
10
|
return;
|
|
10
11
|
// Local
|
|
11
12
|
const { computePosition, autoUpdate, flip, shift, offset, arrow } = get(storePopup);
|
|
12
|
-
const elemPopup = document.querySelector(`[data-popup="${target}"]`);
|
|
13
|
+
const elemPopup = document.querySelector(`[data-popup="${args.target}"]`);
|
|
13
14
|
const elemArrow = elemPopup?.querySelector(`.arrow`) ?? null;
|
|
14
15
|
let isVisible = false;
|
|
15
16
|
let autoUpdateCleanup;
|
|
16
17
|
// Local A11y Variables
|
|
17
|
-
const elemWhitelist = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])';
|
|
18
|
+
const elemWhitelist = ':is(a[href], button, input, textarea, select, details, [tabindex]):not([tabindex="-1"])';
|
|
18
19
|
let activeFocusIdx;
|
|
19
20
|
let focusableElems;
|
|
20
21
|
// On Init (floating ui)
|
|
21
22
|
function render() {
|
|
22
23
|
if (!elemPopup || !computePosition)
|
|
23
24
|
return;
|
|
24
|
-
// Construct
|
|
25
|
+
// Construct Middleware
|
|
25
26
|
// Note the order: https://floating-ui.com/docs/middleware#ordering
|
|
26
|
-
const
|
|
27
|
+
const genMiddleware = [];
|
|
27
28
|
// https://floating-ui.com/docs/offset
|
|
28
29
|
if (offset)
|
|
29
|
-
|
|
30
|
+
genMiddleware.push(offset(args.middleware?.offset ?? 8));
|
|
30
31
|
// https://floating-ui.com/docs/shift
|
|
31
32
|
if (shift)
|
|
32
|
-
|
|
33
|
+
genMiddleware.push(shift(args.middleware?.shift ?? { padding: 8 }));
|
|
33
34
|
// https://floating-ui.com/docs/flip
|
|
34
35
|
if (flip)
|
|
35
|
-
|
|
36
|
+
genMiddleware.push(flip(args.middleware?.flip));
|
|
36
37
|
// https://floating-ui.com/docs/arrow
|
|
37
38
|
if (arrow && elemArrow)
|
|
38
|
-
|
|
39
|
+
genMiddleware.push(arrow(args.middleware?.arrow ?? { element: elemArrow }));
|
|
39
40
|
// https://floating-ui.com/docs/computePosition
|
|
40
41
|
computePosition(node, elemPopup, {
|
|
41
|
-
placement: placement ?? 'bottom',
|
|
42
|
-
middleware:
|
|
42
|
+
placement: args.placement ?? 'bottom',
|
|
43
|
+
middleware: genMiddleware
|
|
43
44
|
}).then(({ x, y, placement, middlewareData }) => {
|
|
44
45
|
Object.assign(elemPopup.style, {
|
|
45
46
|
left: `${x}px`,
|
|
@@ -79,7 +80,10 @@ export function popup(node, args) {
|
|
|
79
80
|
// Automatically focus the element if openWithFocus is true (for example if
|
|
80
81
|
// the menu was opened with Enter instead of with a click
|
|
81
82
|
activeFocusIdx = 0;
|
|
82
|
-
|
|
83
|
+
// if the popup was triggered via focus, we don't want to move that focus
|
|
84
|
+
if (args.event !== 'focus' && args.event !== 'focus-click') {
|
|
85
|
+
focusableElems[0]?.focus();
|
|
86
|
+
}
|
|
83
87
|
}
|
|
84
88
|
// Window Click Handler
|
|
85
89
|
const onWindowClick = (event) => {
|
|
@@ -98,7 +102,7 @@ export function popup(node, args) {
|
|
|
98
102
|
}
|
|
99
103
|
else {
|
|
100
104
|
// If click is interactive child element within popup (ex: anchor or button)
|
|
101
|
-
const interactiveMenuElems = elemPopup?.querySelectorAll(closeQuery);
|
|
105
|
+
const interactiveMenuElems = elemPopup?.querySelectorAll(args.closeQuery || '');
|
|
102
106
|
if (!interactiveMenuElems.length)
|
|
103
107
|
return;
|
|
104
108
|
interactiveMenuElems.forEach((elem) => {
|
|
@@ -119,7 +123,31 @@ export function popup(node, args) {
|
|
|
119
123
|
isVisible = false;
|
|
120
124
|
stateEventHandler(false);
|
|
121
125
|
};
|
|
122
|
-
//
|
|
126
|
+
// Focus Handlers
|
|
127
|
+
function onFocusIn() {
|
|
128
|
+
if (!isVisible)
|
|
129
|
+
node.focus();
|
|
130
|
+
}
|
|
131
|
+
function onFocusOut(e) {
|
|
132
|
+
// if the focus is within the popup, or on the trigger node, do nothing
|
|
133
|
+
if (e.relatedTarget instanceof Element && (elemPopup?.contains(e.relatedTarget) || node.isSameNode(e.relatedTarget)))
|
|
134
|
+
return;
|
|
135
|
+
close();
|
|
136
|
+
}
|
|
137
|
+
function onMouseDown(e) {
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
if (isNode(document.activeElement)) {
|
|
140
|
+
if (!node.isSameNode(document.activeElement)) {
|
|
141
|
+
node.focus();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (isVisible)
|
|
145
|
+
close();
|
|
146
|
+
else
|
|
147
|
+
show();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Visibility
|
|
123
151
|
function show() {
|
|
124
152
|
if (!elemPopup)
|
|
125
153
|
return;
|
|
@@ -150,8 +178,8 @@ export function popup(node, args) {
|
|
|
150
178
|
}
|
|
151
179
|
// State Handler
|
|
152
180
|
const stateEventHandler = (value) => {
|
|
153
|
-
if (state)
|
|
154
|
-
state({ state: value });
|
|
181
|
+
if (args.state)
|
|
182
|
+
args.state({ state: value });
|
|
155
183
|
};
|
|
156
184
|
// A11y Keydown Handler
|
|
157
185
|
const onWindowKeyDown = (event) => {
|
|
@@ -191,30 +219,53 @@ export function popup(node, args) {
|
|
|
191
219
|
};
|
|
192
220
|
// On Init
|
|
193
221
|
render();
|
|
194
|
-
// Event
|
|
195
|
-
if (event === 'click') {
|
|
222
|
+
// Event Listeners
|
|
223
|
+
if (args.event === 'click') {
|
|
196
224
|
window.addEventListener('click', onWindowClick, true);
|
|
197
225
|
}
|
|
198
|
-
if (event === 'hover') {
|
|
226
|
+
if (args.event === 'hover') {
|
|
199
227
|
node.addEventListener('mouseover', show, true);
|
|
200
228
|
node.addEventListener('mouseout', close, true);
|
|
201
229
|
}
|
|
202
|
-
if (event === 'hover-click') {
|
|
230
|
+
if (args.event === 'hover-click') {
|
|
203
231
|
node.addEventListener('mouseover', show, true);
|
|
204
232
|
window.addEventListener('click', onWindowClick, true);
|
|
205
233
|
}
|
|
234
|
+
if (args.event === 'focus' || args.event === 'focus-click') {
|
|
235
|
+
if (!elemPopup)
|
|
236
|
+
return;
|
|
237
|
+
node.addEventListener('focusin', show, true);
|
|
238
|
+
node.addEventListener('focusout', onFocusOut, true);
|
|
239
|
+
// if we tab into a closed popup, we will tab into the last element of any focusable element in elemPopup
|
|
240
|
+
// so we add an event listener to move the focus back to the node the `use:popup` directive is on
|
|
241
|
+
elemPopup.addEventListener('focusin', onFocusIn, true);
|
|
242
|
+
// when we focus off the end of the list, close the popup
|
|
243
|
+
elemPopup.addEventListener('focusout', onFocusOut, true);
|
|
244
|
+
}
|
|
245
|
+
if (args.event === 'focus-click') {
|
|
246
|
+
// we must use mousedown instead of click because click fires after focusin, meaning isVisible would always be true
|
|
247
|
+
// if the active element (one with current focus) is the same as the node (the element with the use:popup directive),
|
|
248
|
+
// then the user clicked on the node, so we should toggle the state of the popup
|
|
249
|
+
node.addEventListener('mousedown', onMouseDown, true);
|
|
250
|
+
}
|
|
206
251
|
// A11y Event Listeners
|
|
207
252
|
window.addEventListener('keydown', onWindowKeyDown, true);
|
|
208
253
|
// Lifecycle
|
|
209
254
|
return {
|
|
210
255
|
update(newArgs) {
|
|
211
256
|
args = newArgs;
|
|
257
|
+
render();
|
|
212
258
|
},
|
|
213
259
|
destroy() {
|
|
214
260
|
// ---
|
|
215
261
|
window.removeEventListener('click', onWindowClick, true);
|
|
216
262
|
node.removeEventListener('mouseover', onMouseOver, true);
|
|
217
263
|
node.removeEventListener('mouseout', onMouseOut, true);
|
|
264
|
+
node.removeEventListener('focusin', show, true);
|
|
265
|
+
node.removeEventListener('focusout', onFocusOut, true);
|
|
266
|
+
node.removeEventListener('mousedown', onMouseDown, true);
|
|
267
|
+
elemPopup?.removeEventListener('focusin', onFocusIn, true);
|
|
268
|
+
elemPopup?.removeEventListener('focusout', onFocusOut, true);
|
|
218
269
|
// ---
|
|
219
270
|
window.removeEventListener('keydown', onWindowKeyDown, true);
|
|
220
271
|
}
|
|
@@ -15,7 +15,7 @@ interface Middlware {
|
|
|
15
15
|
}
|
|
16
16
|
export interface PopupSettings {
|
|
17
17
|
/** Provide the event type. */
|
|
18
|
-
event: 'click' | 'hover' | 'hover-click';
|
|
18
|
+
event: 'click' | 'hover' | 'hover-click' | 'focus' | 'focus-click';
|
|
19
19
|
/** Match the popup data value `[data-popup]="targetNameHere"` */
|
|
20
20
|
target: string;
|
|
21
21
|
/** Set the placement position. Defaults 'bottom'. */
|
|
@@ -11,10 +11,11 @@ export let padding = "p-4";
|
|
|
11
11
|
export let spacing = "space-x-4";
|
|
12
12
|
export let rounded = "rounded-container-token";
|
|
13
13
|
export let shadow = "shadow-lg";
|
|
14
|
+
export let zIndex = "z-[888]";
|
|
14
15
|
export let buttonAction = "btn variant-filled";
|
|
15
16
|
export let buttonDismiss = "btn-icon btn-icon-sm variant-filled";
|
|
16
17
|
export let buttonDismissLabel = "\u2715";
|
|
17
|
-
const cWrapper = "flex fixed top-0 left-0 right-0 bottom-0
|
|
18
|
+
const cWrapper = "flex fixed top-0 left-0 right-0 bottom-0 pointer-events-none";
|
|
18
19
|
const cSnackbar = "flex flex-col space-y-2";
|
|
19
20
|
const cToast = "flex justify-between items-center pointer-events-auto";
|
|
20
21
|
const cToastActions = "flex items-center space-x-2";
|
|
@@ -68,7 +69,7 @@ function onAction(index) {
|
|
|
68
69
|
toastStore.close($toastStore[index].id);
|
|
69
70
|
}
|
|
70
71
|
$:
|
|
71
|
-
classesWrapper = `${cWrapper} ${cPosition} ${$$props.class || ""}`;
|
|
72
|
+
classesWrapper = `${cWrapper} ${cPosition} ${zIndex} ${$$props.class || ""}`;
|
|
72
73
|
$:
|
|
73
74
|
classesSnackbar = `${cSnackbar} ${cAlign} ${padding}`;
|
|
74
75
|
$:
|
|
@@ -22,6 +22,8 @@ declare const __propDef: {
|
|
|
22
22
|
rounded?: string | undefined;
|
|
23
23
|
/** Provide classes to set the border box shadow.*/
|
|
24
24
|
shadow?: string | undefined;
|
|
25
|
+
/** Provide a class to override the z-index*/
|
|
26
|
+
zIndex?: string | undefined;
|
|
25
27
|
/** Provide styles for the action button.*/
|
|
26
28
|
buttonAction?: string | undefined;
|
|
27
29
|
/** Provide styles for the dismiss button.*/
|