@skeletonlabs/skeleton 0.132.5 → 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/README.md +7 -6
- package/components/Accordion/Accordion.svelte.d.ts +3 -3
- package/components/Accordion/AccordionItem.svelte +1 -1
- package/components/AppBar/AppBar.svelte +1 -1
- package/components/AppBar/AppBar.svelte.d.ts +2 -2
- package/components/AppRail/AppRailTile.svelte.d.ts +2 -2
- package/components/AppShell/AppShell.svelte +1 -1
- package/components/AppShell/AppShell.svelte.d.ts +8 -8
- 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 +6 -2
- package/components/ConicGradient/ConicGradient.svelte +2 -2
- package/components/ConicGradient/ConicGradient.svelte.d.ts +6 -6
- package/components/FileButton/FileButton.svelte +12 -5
- package/components/FileButton/FileButton.svelte.d.ts +4 -0
- package/components/FileDropzone/FileDropzone.svelte +5 -2
- package/components/FileDropzone/FileDropzone.svelte.d.ts +7 -5
- package/components/InputChip/InputChip.svelte +14 -13
- package/components/InputChip/InputChip.svelte.d.ts +3 -0
- package/components/ListBox/ListBox.svelte +1 -1
- package/components/ListBox/ListBox.svelte.d.ts +1 -0
- package/components/ProgressBar/ProgressBar.svelte +1 -1
- package/components/ProgressRadial/ProgressRadial.svelte +3 -2
- package/components/ProgressRadial/ProgressRadial.svelte.d.ts +2 -0
- package/components/Radio/RadioGroup.svelte.d.ts +1 -0
- package/components/Radio/RadioItem.svelte +3 -1
- package/components/Radio/RadioItem.svelte.d.ts +2 -0
- package/components/RangeSlider/RangeSlider.svelte +1 -1
- package/components/Stepper/Step.svelte +12 -3
- package/components/Stepper/Step.svelte.d.ts +3 -0
- package/components/Stepper/Stepper.svelte +8 -1
- package/components/Stepper/Stepper.svelte.d.ts +11 -3
- package/components/Tab/Tab.svelte +2 -1
- package/components/Tab/Tab.svelte.d.ts +2 -0
- package/components/Tab/TabGroup.svelte +4 -2
- package/components/Tab/TabGroup.svelte.d.ts +2 -0
- package/components/Table/Table.svelte +2 -0
- package/components/Table/Table.svelte.d.ts +2 -0
- package/components/TableOfContents/TableOfContents.svelte +25 -18
- 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/buttons.css +4 -0
- package/styles/elements/forms.css +4 -1
- package/styles/elements/lists.css +2 -0
- package/styles/elements/logo-clouds.css +1 -1
- package/styles/elements/tables.css +4 -3
- package/styles/tailwind.css +1 -1
- package/styles/typography.css +12 -10
- package/styles/variants.css +3 -1
- package/tailwind/generated/intellisense-classes.cjs +1 -1
- package/tailwind/generated/intellisense-classes.d.cts +316 -117
- package/tailwind/intellisense.cjs +1 -1
- package/tailwind/tokens/backgrounds.cjs +1 -1
- package/tailwind/tokens/border-radius.cjs +1 -1
- package/tailwind/tokens/borders.cjs +1 -1
- package/tailwind/tokens/fills.cjs +1 -1
- package/tailwind/tokens/rings.cjs +3 -3
- package/tailwind/tokens/text.cjs +1 -1
- package/themes/theme-gold-nouveau.css +3 -11
- package/themes/theme-hamlindigo.css +1 -3
- package/themes/theme-modern.css +0 -1
- package/themes/theme-rocket.css +6 -9
- 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 +3 -17
- package/themes/theme-vintage.css +2 -4
- package/types/tailwind.d.ts +1 -1
- package/types/tailwind.js +1 -1
- package/utilities/CodeBlock/CodeBlock.svelte.d.ts +9 -9
- package/utilities/Drawer/Drawer.svelte +3 -2
- package/utilities/Drawer/Drawer.svelte.d.ts +4 -2
- package/utilities/Drawer/types.d.ts +3 -3
- package/utilities/LightSwitch/LightSwitch.svelte +2 -2
- package/utilities/LightSwitch/lightswitch.js +3 -3
- package/utilities/Modal/Modal.svelte +5 -3
- package/utilities/Modal/Modal.svelte.d.ts +3 -1
- package/utilities/Modal/types.d.ts +5 -5
- package/utilities/Popup/popup.d.ts +1 -1
- package/utilities/Popup/popup.js +83 -28
- package/utilities/Popup/types.d.ts +1 -1
- package/utilities/Toast/Toast.svelte +3 -2
- package/utilities/Toast/Toast.svelte.d.ts +2 -0
- package/utilities/Toast/types.d.ts +1 -4
package/utilities/Popup/popup.js
CHANGED
|
@@ -1,44 +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;
|
|
16
|
+
let autoUpdateCleanup;
|
|
15
17
|
// Local A11y Variables
|
|
16
|
-
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"])';
|
|
17
19
|
let activeFocusIdx;
|
|
18
20
|
let focusableElems;
|
|
19
21
|
// On Init (floating ui)
|
|
20
22
|
function render() {
|
|
21
23
|
if (!elemPopup || !computePosition)
|
|
22
24
|
return;
|
|
23
|
-
// Construct
|
|
25
|
+
// Construct Middleware
|
|
24
26
|
// Note the order: https://floating-ui.com/docs/middleware#ordering
|
|
25
|
-
const
|
|
27
|
+
const genMiddleware = [];
|
|
26
28
|
// https://floating-ui.com/docs/offset
|
|
27
29
|
if (offset)
|
|
28
|
-
|
|
30
|
+
genMiddleware.push(offset(args.middleware?.offset ?? 8));
|
|
29
31
|
// https://floating-ui.com/docs/shift
|
|
30
32
|
if (shift)
|
|
31
|
-
|
|
33
|
+
genMiddleware.push(shift(args.middleware?.shift ?? { padding: 8 }));
|
|
32
34
|
// https://floating-ui.com/docs/flip
|
|
33
35
|
if (flip)
|
|
34
|
-
|
|
36
|
+
genMiddleware.push(flip(args.middleware?.flip));
|
|
35
37
|
// https://floating-ui.com/docs/arrow
|
|
36
38
|
if (arrow && elemArrow)
|
|
37
|
-
|
|
39
|
+
genMiddleware.push(arrow(args.middleware?.arrow ?? { element: elemArrow }));
|
|
38
40
|
// https://floating-ui.com/docs/computePosition
|
|
39
41
|
computePosition(node, elemPopup, {
|
|
40
|
-
placement: placement ?? 'bottom',
|
|
41
|
-
middleware:
|
|
42
|
+
placement: args.placement ?? 'bottom',
|
|
43
|
+
middleware: genMiddleware
|
|
42
44
|
}).then(({ x, y, placement, middlewareData }) => {
|
|
43
45
|
Object.assign(elemPopup.style, {
|
|
44
46
|
left: `${x}px`,
|
|
@@ -63,9 +65,9 @@ export function popup(node, args) {
|
|
|
63
65
|
[staticSide]: '-4px'
|
|
64
66
|
});
|
|
65
67
|
}
|
|
68
|
+
// Set Focusable State
|
|
69
|
+
setFocusableState();
|
|
66
70
|
});
|
|
67
|
-
// Set Focusable State
|
|
68
|
-
setFocusableState();
|
|
69
71
|
}
|
|
70
72
|
// Set Focusable State
|
|
71
73
|
function setFocusableState() {
|
|
@@ -78,7 +80,10 @@ export function popup(node, args) {
|
|
|
78
80
|
// Automatically focus the element if openWithFocus is true (for example if
|
|
79
81
|
// the menu was opened with Enter instead of with a click
|
|
80
82
|
activeFocusIdx = 0;
|
|
81
|
-
|
|
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
|
+
}
|
|
82
87
|
}
|
|
83
88
|
// Window Click Handler
|
|
84
89
|
const onWindowClick = (event) => {
|
|
@@ -97,7 +102,7 @@ export function popup(node, args) {
|
|
|
97
102
|
}
|
|
98
103
|
else {
|
|
99
104
|
// If click is interactive child element within popup (ex: anchor or button)
|
|
100
|
-
const interactiveMenuElems = elemPopup?.querySelectorAll(closeQuery);
|
|
105
|
+
const interactiveMenuElems = elemPopup?.querySelectorAll(args.closeQuery || '');
|
|
101
106
|
if (!interactiveMenuElems.length)
|
|
102
107
|
return;
|
|
103
108
|
interactiveMenuElems.forEach((elem) => {
|
|
@@ -118,7 +123,31 @@ export function popup(node, args) {
|
|
|
118
123
|
isVisible = false;
|
|
119
124
|
stateEventHandler(false);
|
|
120
125
|
};
|
|
121
|
-
//
|
|
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
|
|
122
151
|
function show() {
|
|
123
152
|
if (!elemPopup)
|
|
124
153
|
return;
|
|
@@ -128,6 +157,9 @@ export function popup(node, args) {
|
|
|
128
157
|
elemPopup.style.pointerEvents = 'initial';
|
|
129
158
|
isVisible = true;
|
|
130
159
|
stateEventHandler(true);
|
|
160
|
+
// Utilize autoUpdate ONLY when the popup is.
|
|
161
|
+
// https://floating-ui.com/docs/autoUpdate
|
|
162
|
+
autoUpdateCleanup = autoUpdate(node, elemPopup, render);
|
|
131
163
|
}
|
|
132
164
|
function close() {
|
|
133
165
|
if (!elemPopup)
|
|
@@ -140,11 +172,14 @@ export function popup(node, args) {
|
|
|
140
172
|
isVisible = false;
|
|
141
173
|
stateEventHandler(false);
|
|
142
174
|
}, cssTransitionDuration);
|
|
175
|
+
// Cleanup autoUpdate on close (REQUIRED)
|
|
176
|
+
if (autoUpdateCleanup)
|
|
177
|
+
autoUpdateCleanup();
|
|
143
178
|
}
|
|
144
179
|
// State Handler
|
|
145
180
|
const stateEventHandler = (value) => {
|
|
146
|
-
if (state)
|
|
147
|
-
state({ state: value });
|
|
181
|
+
if (args.state)
|
|
182
|
+
args.state({ state: value });
|
|
148
183
|
};
|
|
149
184
|
// A11y Keydown Handler
|
|
150
185
|
const onWindowKeyDown = (event) => {
|
|
@@ -184,33 +219,53 @@ export function popup(node, args) {
|
|
|
184
219
|
};
|
|
185
220
|
// On Init
|
|
186
221
|
render();
|
|
187
|
-
//
|
|
188
|
-
|
|
189
|
-
// Event Listners
|
|
190
|
-
if (event === 'click') {
|
|
222
|
+
// Event Listeners
|
|
223
|
+
if (args.event === 'click') {
|
|
191
224
|
window.addEventListener('click', onWindowClick, true);
|
|
192
|
-
// node.addEventListener('click', onNodeClick, true);
|
|
193
225
|
}
|
|
194
|
-
if (event === 'hover') {
|
|
226
|
+
if (args.event === 'hover') {
|
|
195
227
|
node.addEventListener('mouseover', show, true);
|
|
196
228
|
node.addEventListener('mouseout', close, true);
|
|
197
229
|
}
|
|
198
|
-
if (event === 'hover-click') {
|
|
230
|
+
if (args.event === 'hover-click') {
|
|
199
231
|
node.addEventListener('mouseover', show, true);
|
|
200
232
|
window.addEventListener('click', onWindowClick, true);
|
|
201
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
|
+
}
|
|
202
251
|
// A11y Event Listeners
|
|
203
252
|
window.addEventListener('keydown', onWindowKeyDown, true);
|
|
204
253
|
// Lifecycle
|
|
205
254
|
return {
|
|
206
255
|
update(newArgs) {
|
|
207
256
|
args = newArgs;
|
|
257
|
+
render();
|
|
208
258
|
},
|
|
209
259
|
destroy() {
|
|
260
|
+
// ---
|
|
210
261
|
window.removeEventListener('click', onWindowClick, true);
|
|
211
|
-
// node.removeEventListener('click', onNodeClick, true);
|
|
212
262
|
node.removeEventListener('mouseover', onMouseOver, true);
|
|
213
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);
|
|
214
269
|
// ---
|
|
215
270
|
window.removeEventListener('keydown', onWindowKeyDown, true);
|
|
216
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.*/
|
|
@@ -1,10 +1,7 @@
|
|
|
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
|
-
*/
|
|
4
|
+
/** Provide CSS classes to set the background color. */
|
|
8
5
|
background?: string;
|
|
9
6
|
/** Enables auto-hide after the timeout duration. */
|
|
10
7
|
autohide?: boolean;
|