@skeletonlabs/skeleton 2.6.0-dev.f67521b0 → 2.6.1-dev.04dfa822
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/dist/actions/FocusTrap/focusTrap.js +28 -4
- package/dist/components/Accordion/AccordionItem.svelte +23 -12
- package/dist/components/Accordion/AccordionItem.svelte.d.ts +3 -1
- package/dist/components/Avatar/Avatar.svelte +1 -1
- package/dist/components/Radio/RadioGroup.svelte +3 -4
- package/dist/components/Radio/RadioGroup.svelte.d.ts +5 -3
- package/dist/utilities/Modal/Modal.svelte +37 -11
- package/dist/utilities/Modal/Modal.svelte.d.ts +3 -3
- package/package.json +1 -1
|
@@ -17,18 +17,42 @@ export function focusTrap(node, enabled) {
|
|
|
17
17
|
elemFirst.focus();
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
+
// Sort focusable elements by tabindex, positive first, then 0
|
|
21
|
+
const sortByTabIndex = (focusableElems) => {
|
|
22
|
+
return focusableElems
|
|
23
|
+
.filter((elem) => elem.tabIndex >= 0)
|
|
24
|
+
.sort((a, b) => {
|
|
25
|
+
if (a.tabIndex === 0 && b.tabIndex > 0)
|
|
26
|
+
return 1; // Move 0 to end of array
|
|
27
|
+
else if (a.tabIndex > 0 && b.tabIndex === 0)
|
|
28
|
+
return -1; // Move 0 to end of array
|
|
29
|
+
else
|
|
30
|
+
return a.tabIndex - b.tabIndex; // Sort non-zero values in ascending order
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
// Get element with smallest focusindex value, or first focusable element
|
|
34
|
+
const getFocusTrapTarget = (elemFirst) => {
|
|
35
|
+
// Get elements with data-focusindex attribute
|
|
36
|
+
const focusindexElements = [...node.querySelectorAll('[data-focusindex]')];
|
|
37
|
+
if (!focusindexElements || focusindexElements.length === 0)
|
|
38
|
+
return elemFirst;
|
|
39
|
+
// return smallest focusindex element or elemFirst
|
|
40
|
+
return (focusindexElements.sort((a, b) => {
|
|
41
|
+
return +a.dataset.focusindex - +b.dataset.focusindex;
|
|
42
|
+
})[0] || elemFirst);
|
|
43
|
+
};
|
|
20
44
|
const onScanElements = (fromObserver) => {
|
|
21
45
|
if (enabled === false)
|
|
22
46
|
return;
|
|
23
|
-
// Gather all focusable elements
|
|
24
|
-
const focusableElems = Array.from(node.querySelectorAll(elemWhitelist));
|
|
47
|
+
// Gather all focusable elements, sorted according to tabindex
|
|
48
|
+
const focusableElems = sortByTabIndex(Array.from(node.querySelectorAll(elemWhitelist)));
|
|
25
49
|
if (focusableElems.length) {
|
|
26
50
|
// Set first/last focusable elements
|
|
27
51
|
elemFirst = focusableElems[0];
|
|
28
52
|
elemLast = focusableElems[focusableElems.length - 1];
|
|
29
|
-
// Auto-focus first focusable element only when not called from observer
|
|
53
|
+
// Auto-focus focusTrapTarget or first focusable element only when not called from observer
|
|
30
54
|
if (!fromObserver)
|
|
31
|
-
elemFirst.focus();
|
|
55
|
+
getFocusTrapTarget(elemFirst).focus();
|
|
32
56
|
// Listen for keydown on first & last element
|
|
33
57
|
elemFirst.addEventListener('keydown', onFirstElemKeydown);
|
|
34
58
|
elemLast.addEventListener('keydown', onLastElemKeydown);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
<script>import { getContext } from "svelte";
|
|
2
|
-
import { createEventDispatcher } from "svelte";
|
|
1
|
+
<script>import { createEventDispatcher, getContext } from "svelte";
|
|
3
2
|
import { dynamicTransition } from "../../internal/transitions.js";
|
|
4
3
|
const dispatch = createEventDispatcher();
|
|
5
4
|
export let open = false;
|
|
6
5
|
export let id = String(Math.random());
|
|
7
6
|
const cBase = "";
|
|
8
7
|
const cControl = "text-start w-full flex items-center space-x-4";
|
|
9
|
-
const
|
|
8
|
+
const cControlIcons = "fill-current w-3 transition-transform duration-[200ms]";
|
|
10
9
|
const cPanel = "";
|
|
11
10
|
export let autocollapse = getContext("autocollapse");
|
|
12
11
|
export let active = getContext("active");
|
|
@@ -24,6 +23,10 @@ export let transitionIn = getContext("transitionIn");
|
|
|
24
23
|
export let transitionInParams = getContext("transitionInParams");
|
|
25
24
|
export let transitionOut = getContext("transitionOut");
|
|
26
25
|
export let transitionOutParams = getContext("transitionOutParams");
|
|
26
|
+
const svgCaretIcon = `
|
|
27
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class={classesControlCaret}>
|
|
28
|
+
<path d="M201.4 374.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 306.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z" />
|
|
29
|
+
</svg>`;
|
|
27
30
|
function setActive(event) {
|
|
28
31
|
if (autocollapse === true) {
|
|
29
32
|
active.set(id);
|
|
@@ -56,7 +59,9 @@ $:
|
|
|
56
59
|
$:
|
|
57
60
|
classesCaretState = openState ? caretOpen : caretClosed;
|
|
58
61
|
$:
|
|
59
|
-
classesControlCaret = `${
|
|
62
|
+
classesControlCaret = `${cControlIcons} ${regionCaret} ${classesCaretState}`;
|
|
63
|
+
$:
|
|
64
|
+
classesControlIcons = `${cControlIcons} ${regionCaret}`;
|
|
60
65
|
$:
|
|
61
66
|
classesPanel = `${cPanel} ${padding} ${rounded} ${regionPanel}`;
|
|
62
67
|
</script>
|
|
@@ -88,15 +93,21 @@ $:
|
|
|
88
93
|
<div class="accordion-summary flex-1">
|
|
89
94
|
<slot name="summary">(summary)</slot>
|
|
90
95
|
</div>
|
|
91
|
-
<!--
|
|
92
|
-
|
|
96
|
+
<!-- Icons -->
|
|
97
|
+
{#if $$slots.iconClosed || $$slots.iconOpen}
|
|
98
|
+
<!-- Custom -->
|
|
99
|
+
<!-- If a custom icon is provided, do not use rotation -->
|
|
100
|
+
<div class="accordion-summary-icons {classesControlIcons}">
|
|
101
|
+
{#if openState}
|
|
102
|
+
<slot name="iconClosed">{@html svgCaretIcon}</slot>
|
|
103
|
+
{:else}
|
|
104
|
+
<slot name="iconOpen">{@html svgCaretIcon}</slot>
|
|
105
|
+
{/if}
|
|
106
|
+
</div>
|
|
107
|
+
{:else}
|
|
93
108
|
<!-- SVG Caret -->
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
d="M201.4 374.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 306.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z"
|
|
97
|
-
/>
|
|
98
|
-
</svg>
|
|
99
|
-
</div>
|
|
109
|
+
<div class="accordion-summary-caret {classesControlCaret}">{@html svgCaretIcon}</div>
|
|
110
|
+
{/if}
|
|
100
111
|
</button>
|
|
101
112
|
<!-- Panel -->
|
|
102
113
|
{#if openState}
|
|
@@ -28,7 +28,7 @@ declare class __sveltets_Render<TransitionIn extends Transition, TransitionOut e
|
|
|
28
28
|
regionControl?: string | undefined;
|
|
29
29
|
/** Provide arbitrary classes to content panel region.*/
|
|
30
30
|
regionPanel?: string | undefined;
|
|
31
|
-
/** Provide arbitrary classes
|
|
31
|
+
/** Provide arbitrary classes default region.*/
|
|
32
32
|
regionCaret?: string | undefined;
|
|
33
33
|
/** Enable/Disable transitions*/
|
|
34
34
|
transitions?: boolean | undefined;
|
|
@@ -59,6 +59,8 @@ declare class __sveltets_Render<TransitionIn extends Transition, TransitionOut e
|
|
|
59
59
|
slots(): {
|
|
60
60
|
lead: {};
|
|
61
61
|
summary: {};
|
|
62
|
+
iconClosed: {};
|
|
63
|
+
iconOpen: {};
|
|
62
64
|
content: {};
|
|
63
65
|
};
|
|
64
66
|
}
|
|
@@ -13,7 +13,7 @@ export let rounded = "rounded-full";
|
|
|
13
13
|
export let shadow = "";
|
|
14
14
|
export let cursor = "";
|
|
15
15
|
let cBase = "flex aspect-square text-surface-50 font-semibold justify-center items-center overflow-hidden isolate";
|
|
16
|
-
let cImage = "w-full
|
|
16
|
+
let cImage = "w-full object-cover";
|
|
17
17
|
$:
|
|
18
18
|
classesBase = `${cBase} ${background} ${width} ${border} ${rounded} ${shadow} ${cursor} ${$$props.class ?? ""}`;
|
|
19
19
|
function prunedRestProps() {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script>import { setContext } from "svelte";
|
|
2
2
|
export let display = "inline-flex";
|
|
3
|
+
export let flexDirection = "flex-row";
|
|
4
|
+
export let gap = "gap-1";
|
|
3
5
|
export let background = "bg-surface-200-700-token";
|
|
4
6
|
export let border = "border-token border-surface-400-500-token";
|
|
5
|
-
export let spacing = "";
|
|
6
7
|
export let rounded = "rounded-token";
|
|
7
8
|
export let padding = "px-4 py-1";
|
|
8
9
|
export let active = "variant-filled";
|
|
@@ -20,9 +21,7 @@ setContext("fill", fill);
|
|
|
20
21
|
setContext("regionLabel", regionLabel);
|
|
21
22
|
const cBase = "p-1";
|
|
22
23
|
$:
|
|
23
|
-
|
|
24
|
-
$:
|
|
25
|
-
classesBase = `${cBase} ${display} ${background} ${border} ${spacing} ${rounded} ${$$props.class ?? ""}`;
|
|
24
|
+
classesBase = `${cBase} ${display} ${flexDirection} ${gap} ${background} ${border} ${rounded} ${$$props.class ?? ""}`;
|
|
26
25
|
</script>
|
|
27
26
|
|
|
28
27
|
<div class="radio-group {classesBase}" data-testid="radio-group" role="radiogroup" aria-labelledby={labelledby}>
|
|
@@ -2,14 +2,16 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
-
/** Provide display classes.
|
|
5
|
+
/** Provide display classes. Use `flex` to stretch full width.*/
|
|
6
6
|
display?: string | undefined;
|
|
7
|
+
/** Provide classes to set flex-direction. Use `flex-col` for vertical layout.*/
|
|
8
|
+
flexDirection?: string | undefined;
|
|
9
|
+
/** Provide classes to set gap spacing between items.*/
|
|
10
|
+
gap?: string | undefined;
|
|
7
11
|
/** Provide classes to set the base background color.*/
|
|
8
12
|
background?: string | undefined;
|
|
9
13
|
/** Provide classes to set the border styles.*/
|
|
10
14
|
border?: string | undefined;
|
|
11
|
-
/** Provide classes horizontal spacing between items.*/
|
|
12
|
-
spacing?: string | undefined;
|
|
13
15
|
/** Provide classes to set the border radius.*/
|
|
14
16
|
rounded?: string | undefined;
|
|
15
17
|
/** Provide classes to set the RadioItem padding.*/
|
|
@@ -7,8 +7,8 @@ import { dynamicTransition } from "../../internal/transitions.js";
|
|
|
7
7
|
const dispatch = createEventDispatcher();
|
|
8
8
|
import { focusTrap } from "../../actions/FocusTrap/focusTrap.js";
|
|
9
9
|
import { getModalStore } from "./stores.js";
|
|
10
|
-
export let position = "items-center";
|
|
11
10
|
export let components = {};
|
|
11
|
+
export let position = "items-center";
|
|
12
12
|
export let background = "bg-surface-100-800-token";
|
|
13
13
|
export let width = "w-modal";
|
|
14
14
|
export let height = "h-auto";
|
|
@@ -22,7 +22,7 @@ export let buttonPositive = "variant-filled";
|
|
|
22
22
|
export let buttonTextCancel = "Cancel";
|
|
23
23
|
export let buttonTextConfirm = "Confirm";
|
|
24
24
|
export let buttonTextSubmit = "Submit";
|
|
25
|
-
export let regionBackdrop = "
|
|
25
|
+
export let regionBackdrop = "";
|
|
26
26
|
export let regionHeader = "text-2xl font-bold";
|
|
27
27
|
export let regionBody = "max-h-[200px] overflow-hidden";
|
|
28
28
|
export let regionFooter = "flex justify-end space-x-2";
|
|
@@ -31,8 +31,8 @@ export let transitionIn = fly;
|
|
|
31
31
|
export let transitionInParams = { duration: 150, opacity: 0, x: 0, y: 100 };
|
|
32
32
|
export let transitionOut = fly;
|
|
33
33
|
export let transitionOutParams = { duration: 150, opacity: 0, x: 0, y: 100 };
|
|
34
|
-
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0
|
|
35
|
-
const cTransitionLayer = "w-full h-fit min-h-full
|
|
34
|
+
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0 bg-surface-backdrop-token p-4";
|
|
35
|
+
const cTransitionLayer = "w-full h-fit min-h-full overflow-y-auto flex justify-center";
|
|
36
36
|
const cModal = "block overflow-y-auto";
|
|
37
37
|
const cModalImage = "w-full h-auto";
|
|
38
38
|
let promptValue;
|
|
@@ -43,17 +43,35 @@ const buttonTextDefaults = {
|
|
|
43
43
|
};
|
|
44
44
|
let currentComponent;
|
|
45
45
|
let registeredInteractionWithBackdrop = false;
|
|
46
|
+
let modalElement;
|
|
47
|
+
let windowHeight;
|
|
48
|
+
let backdropOverflow = "overflow-y-hidden";
|
|
46
49
|
const modalStore = getModalStore();
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
+
$:
|
|
51
|
+
if ($modalStore.length)
|
|
52
|
+
handleModals($modalStore);
|
|
53
|
+
function handleModals(modals) {
|
|
50
54
|
if (modals[0].type === "prompt")
|
|
51
55
|
promptValue = modals[0].value;
|
|
52
56
|
buttonTextCancel = modals[0].buttonTextCancel || buttonTextDefaults.buttonTextCancel;
|
|
53
57
|
buttonTextConfirm = modals[0].buttonTextConfirm || buttonTextDefaults.buttonTextConfirm;
|
|
54
58
|
buttonTextSubmit = modals[0].buttonTextSubmit || buttonTextDefaults.buttonTextSubmit;
|
|
55
59
|
currentComponent = typeof modals[0].component === "string" ? components[modals[0].component] : modals[0].component;
|
|
56
|
-
}
|
|
60
|
+
}
|
|
61
|
+
function onModalHeightChange(modal) {
|
|
62
|
+
let modalHeight = modal?.clientHeight;
|
|
63
|
+
if (!modalHeight)
|
|
64
|
+
modalHeight = modal?.firstChild?.clientHeight;
|
|
65
|
+
if (!modalHeight)
|
|
66
|
+
return;
|
|
67
|
+
if (modalHeight > windowHeight) {
|
|
68
|
+
backdropOverflow = "overflow-y-auto";
|
|
69
|
+
} else {
|
|
70
|
+
backdropOverflow = "overflow-y-hidden";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
$:
|
|
74
|
+
onModalHeightChange(modalElement);
|
|
57
75
|
function onBackdropInteractionBegin(event) {
|
|
58
76
|
if (!(event.target instanceof Element))
|
|
59
77
|
return;
|
|
@@ -131,7 +149,7 @@ $:
|
|
|
131
149
|
};
|
|
132
150
|
</script>
|
|
133
151
|
|
|
134
|
-
<svelte:window on:keydown={onKeyDown} />
|
|
152
|
+
<svelte:window bind:innerHeight={windowHeight} on:keydown={onKeyDown} />
|
|
135
153
|
|
|
136
154
|
{#if $modalStore.length > 0}
|
|
137
155
|
{#key $modalStore}
|
|
@@ -139,7 +157,7 @@ $:
|
|
|
139
157
|
<!-- FIXME: resolve a11y warnings -->
|
|
140
158
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
141
159
|
<div
|
|
142
|
-
class="modal-backdrop {classesBackdrop}"
|
|
160
|
+
class="modal-backdrop {classesBackdrop} {backdropOverflow}"
|
|
143
161
|
data-testid="modal-backdrop"
|
|
144
162
|
on:mousedown={onBackdropInteractionBegin}
|
|
145
163
|
on:mouseup={onBackdropInteractionEnd}
|
|
@@ -156,7 +174,14 @@ $:
|
|
|
156
174
|
>
|
|
157
175
|
{#if $modalStore[0].type !== 'component'}
|
|
158
176
|
<!-- Modal: Presets -->
|
|
159
|
-
<div
|
|
177
|
+
<div
|
|
178
|
+
class="modal {classesModal}"
|
|
179
|
+
bind:this={modalElement}
|
|
180
|
+
data-testid="modal"
|
|
181
|
+
role="dialog"
|
|
182
|
+
aria-modal="true"
|
|
183
|
+
aria-label={$modalStore[0].title ?? ''}
|
|
184
|
+
>
|
|
160
185
|
<!-- Header -->
|
|
161
186
|
{#if $modalStore[0]?.title}
|
|
162
187
|
<header class="modal-header {regionHeader}">{@html $modalStore[0].title}</header>
|
|
@@ -196,6 +221,7 @@ $:
|
|
|
196
221
|
<!-- Modal: Components -->
|
|
197
222
|
<!-- Note: keep `contents` class to allow widths from children -->
|
|
198
223
|
<div
|
|
224
|
+
bind:this={modalElement}
|
|
199
225
|
class="modal contents {$modalStore[0]?.modalClasses ?? ''}"
|
|
200
226
|
data-testid="modal-component"
|
|
201
227
|
role="dialog"
|
|
@@ -6,10 +6,10 @@ import type { ModalComponent } from './types.js';
|
|
|
6
6
|
declare class __sveltets_Render<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> {
|
|
7
7
|
props(): {
|
|
8
8
|
[x: string]: any;
|
|
9
|
-
/** Set the modal position within the backdrop container*/
|
|
10
|
-
position?: string | undefined;
|
|
11
9
|
/** Register a list of reusable component modals.*/
|
|
12
10
|
components?: Record<string, ModalComponent> | undefined;
|
|
11
|
+
/** Set the modal position within the backdrop container*/
|
|
12
|
+
position?: string | undefined;
|
|
13
13
|
/** Provide classes to style the modal background.*/
|
|
14
14
|
background?: string | undefined;
|
|
15
15
|
/** Provide classes to style the modal width.*/
|
|
@@ -36,7 +36,7 @@ declare class __sveltets_Render<TransitionIn extends Transition = FlyTransition,
|
|
|
36
36
|
buttonTextConfirm?: string | undefined;
|
|
37
37
|
/** Override the text for the Submit button.*/
|
|
38
38
|
buttonTextSubmit?: string | undefined;
|
|
39
|
-
/** Provide classes to
|
|
39
|
+
/** Provide arbitrary classes to the backdrop region.*/
|
|
40
40
|
regionBackdrop?: string | undefined;
|
|
41
41
|
/** Provide arbitrary classes to modal header region.*/
|
|
42
42
|
regionHeader?: string | undefined;
|