@skeletonlabs/skeleton 2.6.1-dev.a9b3905f → 2.6.1-dev.ea10993e
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/components/Avatar/Avatar.svelte +1 -1
- package/dist/components/Stepper/Step.svelte +20 -6
- package/dist/components/Stepper/Step.svelte.d.ts +2 -4
- package/dist/components/Stepper/Stepper.svelte +1 -19
- package/dist/utilities/Modal/Modal.svelte +13 -43
- package/dist/utilities/Modal/Modal.svelte.d.ts +3 -3
- package/package.json +1 -1
|
@@ -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 object-cover";
|
|
16
|
+
let cImage = "w-full h-full object-cover";
|
|
17
17
|
$:
|
|
18
18
|
classesBase = `${cBase} ${background} ${width} ${border} ${rounded} ${shadow} ${cursor} ${$$props.class ?? ""}`;
|
|
19
19
|
function prunedRestProps() {
|
|
@@ -6,12 +6,10 @@ export let regionHeader = "";
|
|
|
6
6
|
export let regionContent = "";
|
|
7
7
|
export let regionNavigation = "";
|
|
8
8
|
export let state = getContext("state");
|
|
9
|
+
export let dispatchParent = getContext("dispatchParent");
|
|
9
10
|
export let stepTerm = getContext("stepTerm");
|
|
10
11
|
export let gap = getContext("gap");
|
|
11
12
|
export let justify = getContext("justify");
|
|
12
|
-
export let onNext = getContext("onNext");
|
|
13
|
-
export let onBack = getContext("onBack");
|
|
14
|
-
export let onComplete = getContext("onComplete");
|
|
15
13
|
export let buttonBack = getContext("buttonBack");
|
|
16
14
|
export let buttonBackType = getContext("buttonBackType");
|
|
17
15
|
export let buttonBackLabel = getContext("buttonBackLabel");
|
|
@@ -32,6 +30,22 @@ const cBase = "space-y-4";
|
|
|
32
30
|
const cHeader = "text-2xl font-bold";
|
|
33
31
|
const cContent = "space-y-4";
|
|
34
32
|
const cNavigation = "flex";
|
|
33
|
+
async function onNext() {
|
|
34
|
+
await new Promise((resolve) => setTimeout(resolve));
|
|
35
|
+
if (locked)
|
|
36
|
+
return;
|
|
37
|
+
$state.current++;
|
|
38
|
+
dispatchParent("next", { step: stepIndex, state: $state });
|
|
39
|
+
dispatchParent("step", { step: stepIndex, state: $state });
|
|
40
|
+
}
|
|
41
|
+
function onBack() {
|
|
42
|
+
$state.current--;
|
|
43
|
+
dispatchParent("back", { step: stepIndex, state: $state });
|
|
44
|
+
dispatchParent("step", { step: stepIndex, state: $state });
|
|
45
|
+
}
|
|
46
|
+
function onComplete() {
|
|
47
|
+
dispatchParent("complete", { step: stepIndex, state: $state });
|
|
48
|
+
}
|
|
35
49
|
$:
|
|
36
50
|
classesBase = `${cBase} ${$$props.class ?? ""}`;
|
|
37
51
|
$:
|
|
@@ -69,13 +83,13 @@ onDestroy(() => {
|
|
|
69
83
|
</div>
|
|
70
84
|
{:else}
|
|
71
85
|
<!-- Button: Back -->
|
|
72
|
-
<button type={buttonBackType} class="btn {buttonBack}" on:click={
|
|
86
|
+
<button type={buttonBackType} class="btn {buttonBack}" on:click={onBack} disabled={$state.current === 0}>
|
|
73
87
|
{@html buttonBackLabel}
|
|
74
88
|
</button>
|
|
75
89
|
{/if}
|
|
76
90
|
{#if stepIndex < $state.total - 1}
|
|
77
91
|
<!-- Button: Next -->
|
|
78
|
-
<button type={buttonNextType} class="btn {buttonNext}" on:click={
|
|
92
|
+
<button type={buttonNextType} class="btn {buttonNext}" on:click={onNext} disabled={locked}>
|
|
79
93
|
{#if locked}
|
|
80
94
|
<svg class="w-3 aspect-square fill-current" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
|
|
81
95
|
<path
|
|
@@ -87,7 +101,7 @@ onDestroy(() => {
|
|
|
87
101
|
</button>
|
|
88
102
|
{:else}
|
|
89
103
|
<!-- Button: Complete -->
|
|
90
|
-
<button type={buttonCompleteType} class="btn {buttonComplete}" on:click={
|
|
104
|
+
<button type={buttonCompleteType} class="btn {buttonComplete}" on:click={onComplete} disabled={locked}>
|
|
91
105
|
{@html buttonCompleteLabel}
|
|
92
106
|
</button>
|
|
93
107
|
{/if}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { Writable } from 'svelte/store';
|
|
3
|
-
import type { StepperState } from './types.js';
|
|
3
|
+
import type { StepperEventDispatcher, StepperState } from './types.js';
|
|
4
4
|
import type { Transition, TransitionParams } from '../../index.js';
|
|
5
5
|
declare class __sveltets_Render<TransitionIn extends Transition, TransitionOut extends Transition> {
|
|
6
6
|
props(): {
|
|
@@ -13,12 +13,10 @@ declare class __sveltets_Render<TransitionIn extends Transition, TransitionOut e
|
|
|
13
13
|
/** Provide arbitrary classes to the step navigation region.*/
|
|
14
14
|
regionNavigation?: string | undefined;
|
|
15
15
|
state?: Writable<StepperState> | undefined;
|
|
16
|
+
dispatchParent?: StepperEventDispatcher | undefined;
|
|
16
17
|
stepTerm?: string | undefined;
|
|
17
18
|
gap?: string | undefined;
|
|
18
19
|
justify?: string | undefined;
|
|
19
|
-
onNext?: ((locked: boolean, stepIndex: number) => void) | undefined;
|
|
20
|
-
onBack?: ((stepIndex: number) => void) | undefined;
|
|
21
|
-
onComplete?: ((stepIndex: number) => void) | undefined;
|
|
22
20
|
buttonBack?: string | undefined;
|
|
23
21
|
buttonBackType?: "button" | "reset" | "submit" | undefined;
|
|
24
22
|
buttonBackLabel?: string | undefined;
|
|
@@ -30,29 +30,11 @@ export let transitionInParams = { duration: 100 };
|
|
|
30
30
|
export let transitionOut = fade;
|
|
31
31
|
export let transitionOutParams = { duration: 100 };
|
|
32
32
|
let state = writable({ current: start, total: 0 });
|
|
33
|
-
async function onNext(locked, stepIndex) {
|
|
34
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
35
|
-
if (locked)
|
|
36
|
-
return;
|
|
37
|
-
$state.current++;
|
|
38
|
-
dispatch("next", { step: stepIndex, state: $state });
|
|
39
|
-
dispatch("step", { step: stepIndex, state: $state });
|
|
40
|
-
}
|
|
41
|
-
function onBack(stepIndex) {
|
|
42
|
-
$state.current--;
|
|
43
|
-
dispatch("back", { step: stepIndex, state: $state });
|
|
44
|
-
dispatch("step", { step: stepIndex, state: $state });
|
|
45
|
-
}
|
|
46
|
-
function onComplete(stepIndex) {
|
|
47
|
-
dispatch("complete", { step: stepIndex, state: $state });
|
|
48
|
-
}
|
|
49
33
|
setContext("state", state);
|
|
34
|
+
setContext("dispatchParent", dispatch);
|
|
50
35
|
setContext("stepTerm", stepTerm);
|
|
51
36
|
setContext("gap", gap);
|
|
52
37
|
setContext("justify", justify);
|
|
53
|
-
setContext("onNext", onNext);
|
|
54
|
-
setContext("onBack", onBack);
|
|
55
|
-
setContext("onComplete", onComplete);
|
|
56
38
|
setContext("buttonBack", buttonBack);
|
|
57
39
|
setContext("buttonBackType", buttonBackType);
|
|
58
40
|
setContext("buttonBackLabel", buttonBackLabel);
|
|
@@ -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 components = {};
|
|
11
10
|
export let position = "items-center";
|
|
11
|
+
export let components = {};
|
|
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 = "bg-surface-backdrop-token";
|
|
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 overflow-y-auto flex justify-center";
|
|
34
|
+
const cBackdrop = "fixed top-0 left-0 right-0 bottom-0 overflow-y-auto";
|
|
35
|
+
const cTransitionLayer = "w-full h-fit min-h-full p-4 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,35 +43,17 @@ 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";
|
|
49
46
|
const modalStore = getModalStore();
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
function handleModals(modals) {
|
|
47
|
+
modalStore.subscribe((modals) => {
|
|
48
|
+
if (!modals.length)
|
|
49
|
+
return;
|
|
54
50
|
if (modals[0].type === "prompt")
|
|
55
51
|
promptValue = modals[0].value;
|
|
56
52
|
buttonTextCancel = modals[0].buttonTextCancel || buttonTextDefaults.buttonTextCancel;
|
|
57
53
|
buttonTextConfirm = modals[0].buttonTextConfirm || buttonTextDefaults.buttonTextConfirm;
|
|
58
54
|
buttonTextSubmit = modals[0].buttonTextSubmit || buttonTextDefaults.buttonTextSubmit;
|
|
59
55
|
currentComponent = typeof modals[0].component === "string" ? components[modals[0].component] : modals[0].component;
|
|
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);
|
|
56
|
+
});
|
|
75
57
|
function onBackdropInteractionBegin(event) {
|
|
76
58
|
if (!(event.target instanceof Element))
|
|
77
59
|
return;
|
|
@@ -104,12 +86,8 @@ function onConfirm() {
|
|
|
104
86
|
}
|
|
105
87
|
function onPromptSubmit(event) {
|
|
106
88
|
event.preventDefault();
|
|
107
|
-
if ($modalStore[0].response)
|
|
108
|
-
|
|
109
|
-
$modalStore[0].response(parseInt(promptValue));
|
|
110
|
-
else
|
|
111
|
-
$modalStore[0].response(promptValue);
|
|
112
|
-
}
|
|
89
|
+
if ($modalStore[0].response)
|
|
90
|
+
$modalStore[0].response(promptValue);
|
|
113
91
|
modalStore.close();
|
|
114
92
|
}
|
|
115
93
|
function onKeyDown(event) {
|
|
@@ -153,7 +131,7 @@ $:
|
|
|
153
131
|
};
|
|
154
132
|
</script>
|
|
155
133
|
|
|
156
|
-
<svelte:window
|
|
134
|
+
<svelte:window on:keydown={onKeyDown} />
|
|
157
135
|
|
|
158
136
|
{#if $modalStore.length > 0}
|
|
159
137
|
{#key $modalStore}
|
|
@@ -161,7 +139,7 @@ $:
|
|
|
161
139
|
<!-- FIXME: resolve a11y warnings -->
|
|
162
140
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
163
141
|
<div
|
|
164
|
-
class="modal-backdrop {classesBackdrop}
|
|
142
|
+
class="modal-backdrop {classesBackdrop}"
|
|
165
143
|
data-testid="modal-backdrop"
|
|
166
144
|
on:mousedown={onBackdropInteractionBegin}
|
|
167
145
|
on:mouseup={onBackdropInteractionEnd}
|
|
@@ -178,14 +156,7 @@ $:
|
|
|
178
156
|
>
|
|
179
157
|
{#if $modalStore[0].type !== 'component'}
|
|
180
158
|
<!-- Modal: Presets -->
|
|
181
|
-
<div
|
|
182
|
-
class="modal {classesModal}"
|
|
183
|
-
bind:this={modalElement}
|
|
184
|
-
data-testid="modal"
|
|
185
|
-
role="dialog"
|
|
186
|
-
aria-modal="true"
|
|
187
|
-
aria-label={$modalStore[0].title ?? ''}
|
|
188
|
-
>
|
|
159
|
+
<div class="modal {classesModal}" data-testid="modal" role="dialog" aria-modal="true" aria-label={$modalStore[0].title ?? ''}>
|
|
189
160
|
<!-- Header -->
|
|
190
161
|
{#if $modalStore[0]?.title}
|
|
191
162
|
<header class="modal-header {regionHeader}">{@html $modalStore[0].title}</header>
|
|
@@ -225,7 +196,6 @@ $:
|
|
|
225
196
|
<!-- Modal: Components -->
|
|
226
197
|
<!-- Note: keep `contents` class to allow widths from children -->
|
|
227
198
|
<div
|
|
228
|
-
bind:this={modalElement}
|
|
229
199
|
class="modal contents {$modalStore[0]?.modalClasses ?? ''}"
|
|
230
200
|
data-testid="modal-component"
|
|
231
201
|
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
|
-
/** Register a list of reusable component modals.*/
|
|
10
|
-
components?: Record<string, ModalComponent> | undefined;
|
|
11
9
|
/** Set the modal position within the backdrop container*/
|
|
12
10
|
position?: string | undefined;
|
|
11
|
+
/** Register a list of reusable component modals.*/
|
|
12
|
+
components?: Record<string, ModalComponent> | 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
|
|
39
|
+
/** Provide classes to style the backdrop.*/
|
|
40
40
|
regionBackdrop?: string | undefined;
|
|
41
41
|
/** Provide arbitrary classes to modal header region.*/
|
|
42
42
|
regionHeader?: string | undefined;
|