@skeletonlabs/skeleton 2.6.1-dev.a2e14d03 → 2.6.1-dev.a9b3905f

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.
@@ -6,10 +6,12 @@ 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");
10
9
  export let stepTerm = getContext("stepTerm");
11
10
  export let gap = getContext("gap");
12
11
  export let justify = getContext("justify");
12
+ export let onNext = getContext("onNext");
13
+ export let onBack = getContext("onBack");
14
+ export let onComplete = getContext("onComplete");
13
15
  export let buttonBack = getContext("buttonBack");
14
16
  export let buttonBackType = getContext("buttonBackType");
15
17
  export let buttonBackLabel = getContext("buttonBackLabel");
@@ -30,22 +32,6 @@ const cBase = "space-y-4";
30
32
  const cHeader = "text-2xl font-bold";
31
33
  const cContent = "space-y-4";
32
34
  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
- }
49
35
  $:
50
36
  classesBase = `${cBase} ${$$props.class ?? ""}`;
51
37
  $:
@@ -83,13 +69,13 @@ onDestroy(() => {
83
69
  </div>
84
70
  {:else}
85
71
  <!-- Button: Back -->
86
- <button type={buttonBackType} class="btn {buttonBack}" on:click={onBack} disabled={$state.current === 0}>
72
+ <button type={buttonBackType} class="btn {buttonBack}" on:click={() => onBack(stepIndex)} disabled={$state.current === 0}>
87
73
  {@html buttonBackLabel}
88
74
  </button>
89
75
  {/if}
90
76
  {#if stepIndex < $state.total - 1}
91
77
  <!-- Button: Next -->
92
- <button type={buttonNextType} class="btn {buttonNext}" on:click={onNext} disabled={locked}>
78
+ <button type={buttonNextType} class="btn {buttonNext}" on:click={() => onNext(locked, stepIndex)} disabled={locked}>
93
79
  {#if locked}
94
80
  <svg class="w-3 aspect-square fill-current" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
95
81
  <path
@@ -101,7 +87,7 @@ onDestroy(() => {
101
87
  </button>
102
88
  {:else}
103
89
  <!-- Button: Complete -->
104
- <button type={buttonCompleteType} class="btn {buttonComplete}" on:click={onComplete} disabled={locked}>
90
+ <button type={buttonCompleteType} class="btn {buttonComplete}" on:click={() => onComplete(stepIndex)} disabled={locked}>
105
91
  {@html buttonCompleteLabel}
106
92
  </button>
107
93
  {/if}
@@ -1,6 +1,6 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import type { Writable } from 'svelte/store';
3
- import type { StepperEventDispatcher, StepperState } from './types.js';
3
+ import type { 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,10 +13,12 @@ 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;
17
16
  stepTerm?: string | undefined;
18
17
  gap?: string | undefined;
19
18
  justify?: string | undefined;
19
+ onNext?: ((locked: boolean, stepIndex: number) => void) | undefined;
20
+ onBack?: ((stepIndex: number) => void) | undefined;
21
+ onComplete?: ((stepIndex: number) => void) | undefined;
20
22
  buttonBack?: string | undefined;
21
23
  buttonBackType?: "button" | "reset" | "submit" | undefined;
22
24
  buttonBackLabel?: string | undefined;
@@ -30,11 +30,29 @@ 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
+ }
33
49
  setContext("state", state);
34
- setContext("dispatchParent", dispatch);
35
50
  setContext("stepTerm", stepTerm);
36
51
  setContext("gap", gap);
37
52
  setContext("justify", justify);
53
+ setContext("onNext", onNext);
54
+ setContext("onBack", onBack);
55
+ setContext("onComplete", onComplete);
38
56
  setContext("buttonBack", buttonBack);
39
57
  setContext("buttonBackType", buttonBackType);
40
58
  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 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 = "bg-surface-backdrop-token";
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 p-4 overflow-y-auto flex justify-center";
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;
@@ -47,16 +47,17 @@ let modalElement;
47
47
  let windowHeight;
48
48
  let backdropOverflow = "overflow-y-hidden";
49
49
  const modalStore = getModalStore();
50
- modalStore.subscribe((modals) => {
51
- if (!modals.length)
52
- return;
50
+ $:
51
+ if ($modalStore.length)
52
+ handleModals($modalStore);
53
+ function handleModals(modals) {
53
54
  if (modals[0].type === "prompt")
54
55
  promptValue = modals[0].value;
55
56
  buttonTextCancel = modals[0].buttonTextCancel || buttonTextDefaults.buttonTextCancel;
56
57
  buttonTextConfirm = modals[0].buttonTextConfirm || buttonTextDefaults.buttonTextConfirm;
57
58
  buttonTextSubmit = modals[0].buttonTextSubmit || buttonTextDefaults.buttonTextSubmit;
58
59
  currentComponent = typeof modals[0].component === "string" ? components[modals[0].component] : modals[0].component;
59
- });
60
+ }
60
61
  function onModalHeightChange(modal) {
61
62
  let modalHeight = modal?.clientHeight;
62
63
  if (!modalHeight)
@@ -103,8 +104,12 @@ function onConfirm() {
103
104
  }
104
105
  function onPromptSubmit(event) {
105
106
  event.preventDefault();
106
- if ($modalStore[0].response)
107
- $modalStore[0].response(promptValue);
107
+ if ($modalStore[0].response) {
108
+ if ($modalStore[0].valueAttr !== void 0 && "type" in $modalStore[0].valueAttr && $modalStore[0].valueAttr.type === "number")
109
+ $modalStore[0].response(parseInt(promptValue));
110
+ else
111
+ $modalStore[0].response(promptValue);
112
+ }
108
113
  modalStore.close();
109
114
  }
110
115
  function onKeyDown(event) {
@@ -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 style the backdrop.*/
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skeletonlabs/skeleton",
3
- "version": "2.6.1-dev.a2e14d03",
3
+ "version": "2.6.1-dev.a9b3905f",
4
4
  "description": "A SvelteKit component library.",
5
5
  "author": "endigo9740 <chris@skeletonlabs.dev>",
6
6
  "repository": {