sveltacular 0.0.36 → 0.0.37
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/forms/button/button.svelte +10 -1
- package/dist/helpers/subscribable.d.ts +6 -0
- package/dist/helpers/subscribable.js +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/navigation/wizard/wizard-context.d.ts +10 -0
- package/dist/navigation/wizard/wizard-context.js +1 -0
- package/dist/navigation/wizard/wizard-step.svelte +20 -0
- package/dist/navigation/wizard/wizard-step.svelte.d.ts +19 -0
- package/dist/navigation/wizard/wizard.svelte +95 -0
- package/dist/navigation/wizard/wizard.svelte.d.ts +25 -0
- package/package.json +29 -2
|
@@ -8,7 +8,12 @@ export let block = false;
|
|
|
8
8
|
export let flex = false;
|
|
9
9
|
export let disabled = false;
|
|
10
10
|
const dispatch = createEventDispatcher();
|
|
11
|
-
const click = () => {
|
|
11
|
+
const click = (e) => {
|
|
12
|
+
if (disabled) {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
e.stopPropagation();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
12
17
|
dispatch("click");
|
|
13
18
|
if (href) {
|
|
14
19
|
navigateTo(href);
|
|
@@ -44,6 +49,10 @@ const click = () => {
|
|
|
44
49
|
font-family: var(--base-font-family, sans-serif);
|
|
45
50
|
text-shadow: 0 0 0.125rem rgba(0, 0, 0, 0.5);
|
|
46
51
|
}
|
|
52
|
+
button[disabled] {
|
|
53
|
+
opacity: 0.5;
|
|
54
|
+
cursor: not-allowed;
|
|
55
|
+
}
|
|
47
56
|
button.flex {
|
|
48
57
|
flex-grow: 1;
|
|
49
58
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { Writable } from 'svelte/store';
|
|
3
|
+
export declare const subscribable: <T>(subject: Writable<T>) => {
|
|
4
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<T>, invalidate?: import("svelte/store").Invalidator<T> | undefined) => import("svelte/store").Unsubscriber;
|
|
5
|
+
};
|
|
6
|
+
export type Subscribable<T> = ReturnType<typeof subscribable<T>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,8 @@ export { default as AppLogo } from './navigation/app-bar/app-logo.svelte';
|
|
|
56
56
|
export { default as AppNav } from './navigation/app-bar/app-nav.svelte';
|
|
57
57
|
export { default as AppNavItem } from './navigation/app-bar/app-nav-item.svelte';
|
|
58
58
|
export { default as AppBranding } from './navigation/app-bar/app-branding.svelte';
|
|
59
|
+
export { default as Wizard } from './navigation/wizard/wizard.svelte';
|
|
60
|
+
export { default as WizardStep } from './navigation/wizard/wizard-step.svelte';
|
|
59
61
|
export { default as DataGrid } from './tables/data-grid.svelte';
|
|
60
62
|
export { default as Table } from './tables/table.svelte';
|
|
61
63
|
export { default as TableBody } from './tables/table-body.svelte';
|
|
@@ -83,4 +85,5 @@ export * from './helpers/date.js';
|
|
|
83
85
|
export * from './helpers/navigate-to.js';
|
|
84
86
|
export * from './helpers/round-to-decimals.js';
|
|
85
87
|
export * from './helpers/unique-id.js';
|
|
88
|
+
export * from './helpers/subscribable.js';
|
|
86
89
|
export * as Data from './data/index.js';
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,8 @@ export { default as AppLogo } from './navigation/app-bar/app-logo.svelte';
|
|
|
61
61
|
export { default as AppNav } from './navigation/app-bar/app-nav.svelte';
|
|
62
62
|
export { default as AppNavItem } from './navigation/app-bar/app-nav-item.svelte';
|
|
63
63
|
export { default as AppBranding } from './navigation/app-bar/app-branding.svelte';
|
|
64
|
+
export { default as Wizard } from './navigation/wizard/wizard.svelte';
|
|
65
|
+
export { default as WizardStep } from './navigation/wizard/wizard-step.svelte';
|
|
64
66
|
// Tables
|
|
65
67
|
export { default as DataGrid } from './tables/data-grid.svelte';
|
|
66
68
|
export { default as Table } from './tables/table.svelte';
|
|
@@ -94,5 +96,6 @@ export * from './helpers/date.js';
|
|
|
94
96
|
export * from './helpers/navigate-to.js';
|
|
95
97
|
export * from './helpers/round-to-decimals.js';
|
|
96
98
|
export * from './helpers/unique-id.js';
|
|
99
|
+
export * from './helpers/subscribable.js';
|
|
97
100
|
// Data
|
|
98
101
|
export * as Data from './data/index.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Subscribable } from '../../helpers/subscribable.js';
|
|
2
|
+
export type WizardState = {
|
|
3
|
+
currentStep: number;
|
|
4
|
+
totalSteps: number;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
};
|
|
7
|
+
export interface WizardContext {
|
|
8
|
+
state: Subscribable<WizardState>;
|
|
9
|
+
register: (step: number, title: string) => void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script>import { getContext, onDestroy } from "svelte";
|
|
2
|
+
const wizard = getContext("wizard");
|
|
3
|
+
const state = wizard.state;
|
|
4
|
+
export let step;
|
|
5
|
+
export let subtitle;
|
|
6
|
+
wizard.register(step, subtitle);
|
|
7
|
+
$:
|
|
8
|
+
isCurrentStep = $state.currentStep === step;
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class="step {isCurrentStep ? 'current' : ''}">
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<style>.step {
|
|
16
|
+
display: none;
|
|
17
|
+
}
|
|
18
|
+
.step.current {
|
|
19
|
+
display: block;
|
|
20
|
+
}</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
step: number;
|
|
5
|
+
subtitle: string;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type WizardStepProps = typeof __propDef.props;
|
|
15
|
+
export type WizardStepEvents = typeof __propDef.events;
|
|
16
|
+
export type WizardStepSlots = typeof __propDef.slots;
|
|
17
|
+
export default class WizardStep extends SvelteComponent<WizardStepProps, WizardStepEvents, WizardStepSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script>import { createEventDispatcher, setContext } from "svelte";
|
|
2
|
+
import { writable } from "svelte/store";
|
|
3
|
+
import { subscribable } from "../../helpers/subscribable.js";
|
|
4
|
+
import Section from "../../generic/section/section.svelte";
|
|
5
|
+
import Header from "../../generic/header/header.svelte";
|
|
6
|
+
import Button from "../../forms/button/button.svelte";
|
|
7
|
+
export let title;
|
|
8
|
+
export let level = 3;
|
|
9
|
+
export let disabled = false;
|
|
10
|
+
let currentStep = 0;
|
|
11
|
+
const dispatch = createEventDispatcher();
|
|
12
|
+
const steps = {};
|
|
13
|
+
const wizardStore = writable({
|
|
14
|
+
currentStep,
|
|
15
|
+
totalSteps: 0,
|
|
16
|
+
disabled
|
|
17
|
+
});
|
|
18
|
+
const publish = () => {
|
|
19
|
+
wizardStore.set({
|
|
20
|
+
currentStep,
|
|
21
|
+
totalSteps: Object.values(steps).length,
|
|
22
|
+
disabled
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const register = (stepNumber, subtitle2) => {
|
|
26
|
+
steps[stepNumber] = subtitle2;
|
|
27
|
+
publish();
|
|
28
|
+
};
|
|
29
|
+
const next = () => {
|
|
30
|
+
if (currentStep >= Object.values(steps).length || disabled)
|
|
31
|
+
return;
|
|
32
|
+
currentStep++;
|
|
33
|
+
dispatch("next", currentStep);
|
|
34
|
+
publish();
|
|
35
|
+
};
|
|
36
|
+
const previous = () => {
|
|
37
|
+
if (currentStep <= 1 || disabled)
|
|
38
|
+
return;
|
|
39
|
+
currentStep--;
|
|
40
|
+
dispatch("previous", currentStep);
|
|
41
|
+
publish();
|
|
42
|
+
};
|
|
43
|
+
const done = () => {
|
|
44
|
+
disabled = true;
|
|
45
|
+
dispatch("submit");
|
|
46
|
+
};
|
|
47
|
+
setContext("wizard", {
|
|
48
|
+
state: subscribable(wizardStore),
|
|
49
|
+
register
|
|
50
|
+
});
|
|
51
|
+
setTimeout(next, 100);
|
|
52
|
+
$:
|
|
53
|
+
isFirstStep = currentStep <= 1;
|
|
54
|
+
$:
|
|
55
|
+
isLastStep = currentStep >= Object.values(steps).length;
|
|
56
|
+
$:
|
|
57
|
+
subtitle = steps[currentStep - 1];
|
|
58
|
+
$:
|
|
59
|
+
total = Object.values(steps).length;
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<section class:disabled>
|
|
63
|
+
<Header {title} {subtitle} {level} />
|
|
64
|
+
<div class="content">
|
|
65
|
+
<slot />
|
|
66
|
+
</div>
|
|
67
|
+
<footer>
|
|
68
|
+
<div>
|
|
69
|
+
{#if !isFirstStep}
|
|
70
|
+
<Button type="button" style="secondary" on:click={previous} {disabled}>Previous</Button>
|
|
71
|
+
{/if}
|
|
72
|
+
</div>
|
|
73
|
+
<div>
|
|
74
|
+
<div>Step {currentStep} of {total}</div>
|
|
75
|
+
</div>
|
|
76
|
+
<div>
|
|
77
|
+
{#if isLastStep}
|
|
78
|
+
<Button type="submit" style="primary" on:click={done} {disabled}>Done</Button>
|
|
79
|
+
{:else}
|
|
80
|
+
<Button type="button" style="primary" on:click={next} {disabled}>Next</Button>
|
|
81
|
+
{/if}
|
|
82
|
+
</div>
|
|
83
|
+
</footer>
|
|
84
|
+
</section>
|
|
85
|
+
|
|
86
|
+
<style>section.disabled {
|
|
87
|
+
opacity: 0.5;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
footer {
|
|
91
|
+
margin-top: 1rem;
|
|
92
|
+
display: flex;
|
|
93
|
+
justify-content: space-between;
|
|
94
|
+
align-items: center;
|
|
95
|
+
}</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { SectionLevel } from '../../types/generic.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
title: string;
|
|
6
|
+
level?: SectionLevel | undefined;
|
|
7
|
+
disabled?: boolean | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
submit: CustomEvent<void>;
|
|
11
|
+
next: CustomEvent<number>;
|
|
12
|
+
previous: CustomEvent<number>;
|
|
13
|
+
} & {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {
|
|
17
|
+
default: {};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type WizardProps = typeof __propDef.props;
|
|
21
|
+
export type WizardEvents = typeof __propDef.events;
|
|
22
|
+
export type WizardSlots = typeof __propDef.slots;
|
|
23
|
+
export default class Wizard extends SvelteComponent<WizardProps, WizardEvents, WizardSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sveltacular",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
|
+
"description": "A Svelte component library",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/jasonbyrne/sveltacular.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/jasonbyrne/sveltacular/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/jasonbyrne/sveltacular#readme",
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"author": "Jason Byrne <jasonbyrne662@gmail.com>",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"svelte",
|
|
20
|
+
"sveltekit",
|
|
21
|
+
"component",
|
|
22
|
+
"library",
|
|
23
|
+
"ui",
|
|
24
|
+
"kit",
|
|
25
|
+
"storybook",
|
|
26
|
+
"vite",
|
|
27
|
+
"typescript",
|
|
28
|
+
"css",
|
|
29
|
+
"scss",
|
|
30
|
+
"helpers"
|
|
31
|
+
],
|
|
4
32
|
"scripts": {
|
|
5
33
|
"watch": "npm run dev -- --open",
|
|
6
34
|
"dev": "vite dev",
|
|
@@ -69,6 +97,5 @@
|
|
|
69
97
|
"vitest": "^0.34.0"
|
|
70
98
|
},
|
|
71
99
|
"svelte": "./dist/index.js",
|
|
72
|
-
"types": "./dist/index.d.ts",
|
|
73
100
|
"type": "module"
|
|
74
101
|
}
|