@hyvor/design 0.0.40 → 0.0.42
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/Button/Button.svelte.d.ts +1 -1
- package/dist/components/IconButton/IconButton.svelte.d.ts +1 -1
- package/dist/components/Loader/LoadButton.svelte.d.ts +2 -2
- package/dist/components/Loader/Loader.svelte.d.ts +1 -1
- package/dist/components/Modal/Modal.svelte +48 -7
- package/dist/components/Modal/Modal.svelte.d.ts +6 -0
- package/dist/components/Modal/ModalFooter.svelte +36 -0
- package/dist/components/Modal/ModalFooter.svelte.d.ts +21 -0
- package/dist/components/Modal/modal-types.d.ts +18 -0
- package/dist/components/Modal/modal-types.js +1 -0
- package/dist/components/Textarea/Textarea.svelte +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ declare const __propDef: {
|
|
|
6
6
|
size?: "small" | "medium" | "large" | "x-small" | undefined;
|
|
7
7
|
color?: "input" | "accent" | "gray" | "green" | "red" | "blue" | "orange" | undefined;
|
|
8
8
|
block?: boolean | undefined;
|
|
9
|
-
variant?: "fill" | "fill-light" | "outline" | "
|
|
9
|
+
variant?: "fill" | "fill-light" | "outline" | "invisible" | "outline-fill" | undefined;
|
|
10
10
|
align?: "start" | "center" | undefined;
|
|
11
11
|
button?: HTMLButtonElement | HTMLAnchorElement | undefined;
|
|
12
12
|
};
|
|
@@ -4,7 +4,7 @@ declare const __propDef: {
|
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
size?: number | "small" | "medium" | "large" | undefined;
|
|
6
6
|
color?: "accent" | "gray" | "green" | "red" | "blue" | "orange" | undefined;
|
|
7
|
-
variant?: "fill" | "fill-light" | "outline" | "
|
|
7
|
+
variant?: "fill" | "fill-light" | "outline" | "invisible" | "outline-fill" | undefined;
|
|
8
8
|
as?: "button" | "a" | undefined;
|
|
9
9
|
};
|
|
10
10
|
events: {
|
|
@@ -12,7 +12,7 @@ declare const __propDef: {
|
|
|
12
12
|
full?: boolean | undefined;
|
|
13
13
|
padding?: number | "none" | "small" | "medium" | "large" | undefined;
|
|
14
14
|
size?: number | "small" | "medium" | "large" | undefined;
|
|
15
|
-
state?: "none" | "error" | "
|
|
15
|
+
state?: "none" | "error" | "loading" | "success" | undefined;
|
|
16
16
|
duration?: number | null | undefined;
|
|
17
17
|
color?: string | undefined;
|
|
18
18
|
colorTrack?: string | undefined;
|
|
@@ -24,7 +24,7 @@ declare const __propDef: {
|
|
|
24
24
|
size?: "small" | "medium" | "large" | "x-small" | undefined;
|
|
25
25
|
color?: "input" | "accent" | "gray" | "green" | "red" | "blue" | "orange" | undefined;
|
|
26
26
|
block?: boolean | undefined;
|
|
27
|
-
variant?: "fill" | "fill-light" | "outline" | "
|
|
27
|
+
variant?: "fill" | "fill-light" | "outline" | "invisible" | "outline-fill" | undefined;
|
|
28
28
|
align?: "start" | "center" | undefined;
|
|
29
29
|
button?: HTMLButtonElement | HTMLAnchorElement | undefined;
|
|
30
30
|
} | undefined;
|
|
@@ -6,7 +6,7 @@ declare const __propDef: {
|
|
|
6
6
|
full?: boolean | undefined;
|
|
7
7
|
padding?: number | "none" | "small" | "medium" | "large" | undefined;
|
|
8
8
|
size?: number | "small" | "medium" | "large" | undefined;
|
|
9
|
-
state?: "none" | "error" | "
|
|
9
|
+
state?: "none" | "error" | "loading" | "success" | undefined;
|
|
10
10
|
duration?: number | null | undefined;
|
|
11
11
|
color?: string | undefined;
|
|
12
12
|
colorTrack?: string | undefined;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
<script>import
|
|
1
|
+
<script>import ModalFooter from "./ModalFooter.svelte";
|
|
2
|
+
import { clickOutside } from "../../directives/clickOutside.js";
|
|
2
3
|
import { IconX } from "@hyvor/icons";
|
|
3
4
|
import IconButton from "./../IconButton/IconButton.svelte";
|
|
4
|
-
import { scale } from "svelte/transition";
|
|
5
|
+
import { fade, scale } from "svelte/transition";
|
|
5
6
|
import { onMount, tick } from "svelte";
|
|
7
|
+
import Loader from "../Loader/Loader.svelte";
|
|
6
8
|
export let show = false;
|
|
7
9
|
export let title = "";
|
|
8
10
|
export let size = "medium";
|
|
9
11
|
export let closeOnOutsideClick = true;
|
|
10
12
|
export let closeOnEscape = true;
|
|
13
|
+
export let loading = false;
|
|
14
|
+
export let footer = null;
|
|
11
15
|
let wrapEl;
|
|
12
16
|
let innerEl;
|
|
13
17
|
async function setFlex() {
|
|
@@ -26,7 +30,7 @@ $:
|
|
|
26
30
|
</script>
|
|
27
31
|
|
|
28
32
|
<svelte:window on:keyup={e => {
|
|
29
|
-
if (e.key === 'Escape' && closeOnEscape) {
|
|
33
|
+
if (e.key === 'Escape' && closeOnEscape && !loading) {
|
|
30
34
|
show = false;
|
|
31
35
|
}
|
|
32
36
|
}} />
|
|
@@ -36,15 +40,18 @@ $:
|
|
|
36
40
|
<div
|
|
37
41
|
class="wrap"
|
|
38
42
|
bind:this={wrapEl}
|
|
43
|
+
in:fade={{duration: 100}}
|
|
44
|
+
out:fade={{duration: 100}}
|
|
39
45
|
>
|
|
40
46
|
|
|
41
|
-
<div
|
|
47
|
+
<div
|
|
42
48
|
class="inner {size}"
|
|
43
49
|
use:clickOutside={{
|
|
44
50
|
enabled: closeOnOutsideClick,
|
|
45
|
-
callback: () => show = false
|
|
51
|
+
callback: () => !loading ? show = false : null
|
|
46
52
|
}}
|
|
47
53
|
in:scale={{duration: 100, start: 0.9, opacity: 0.9}}
|
|
54
|
+
out:scale={{duration: 100, start: 0.9, opacity: 0.9}}
|
|
48
55
|
bind:this={innerEl}
|
|
49
56
|
>
|
|
50
57
|
|
|
@@ -73,9 +80,31 @@ $:
|
|
|
73
80
|
<slot />
|
|
74
81
|
</div>
|
|
75
82
|
|
|
76
|
-
{#if $$slots.footer}
|
|
83
|
+
{#if $$slots.footer || footer}
|
|
77
84
|
<div class="footer">
|
|
78
|
-
|
|
85
|
+
{#if $$slots.footer}
|
|
86
|
+
<slot name="footer" />
|
|
87
|
+
{:else if footer}
|
|
88
|
+
<ModalFooter
|
|
89
|
+
{footer}
|
|
90
|
+
bind:show={show}
|
|
91
|
+
on:cancel
|
|
92
|
+
on:confirm
|
|
93
|
+
/>
|
|
94
|
+
{/if}
|
|
95
|
+
</div>
|
|
96
|
+
{/if}
|
|
97
|
+
|
|
98
|
+
{#if loading}
|
|
99
|
+
<div
|
|
100
|
+
class="loading"
|
|
101
|
+
in:fade={{duration: 100}}
|
|
102
|
+
>
|
|
103
|
+
<Loader full>
|
|
104
|
+
{#if typeof loading === "string"}
|
|
105
|
+
{loading}
|
|
106
|
+
{/if}
|
|
107
|
+
</Loader>
|
|
79
108
|
</div>
|
|
80
109
|
{/if}
|
|
81
110
|
|
|
@@ -86,6 +115,18 @@ $:
|
|
|
86
115
|
|
|
87
116
|
<style>
|
|
88
117
|
|
|
118
|
+
.loading {
|
|
119
|
+
position: absolute;
|
|
120
|
+
top: 0;
|
|
121
|
+
left: 0;
|
|
122
|
+
z-index: 1;
|
|
123
|
+
width: 100%;
|
|
124
|
+
height: 100%;
|
|
125
|
+
background-color: var(--box-background);
|
|
126
|
+
border-radius: var(--box-radius);
|
|
127
|
+
box-shadow: var(--box-shadow);
|
|
128
|
+
}
|
|
129
|
+
|
|
89
130
|
.wrap {
|
|
90
131
|
position: fixed;
|
|
91
132
|
top: 0;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Footer } from './modal-types.js';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
show?: boolean | undefined;
|
|
@@ -6,8 +7,13 @@ declare const __propDef: {
|
|
|
6
7
|
size?: "small" | "medium" | "large" | undefined;
|
|
7
8
|
closeOnOutsideClick?: boolean | undefined;
|
|
8
9
|
closeOnEscape?: boolean | undefined;
|
|
10
|
+
loading?: string | boolean | undefined;
|
|
11
|
+
footer?: Footer | null | undefined;
|
|
9
12
|
};
|
|
10
13
|
events: {
|
|
14
|
+
cancel: CustomEvent<any>;
|
|
15
|
+
confirm: CustomEvent<any>;
|
|
16
|
+
} & {
|
|
11
17
|
[evt: string]: CustomEvent<any>;
|
|
12
18
|
};
|
|
13
19
|
slots: {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import Button from "../Button/Button.svelte";
|
|
3
|
+
import ButtonGroup from "../Button/ButtonGroup.svelte";
|
|
4
|
+
export let show;
|
|
5
|
+
export let footer;
|
|
6
|
+
const dispatch = createEventDispatcher();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
<ButtonGroup>
|
|
11
|
+
|
|
12
|
+
{#if footer.cancel !== false}
|
|
13
|
+
<Button
|
|
14
|
+
variant="invisible"
|
|
15
|
+
on:click={() => {
|
|
16
|
+
show = false;
|
|
17
|
+
dispatch("cancel");
|
|
18
|
+
}}
|
|
19
|
+
{...footer.cancel?.props}
|
|
20
|
+
>
|
|
21
|
+
{footer.cancel?.text || "Cancel"}
|
|
22
|
+
</Button>
|
|
23
|
+
{/if}
|
|
24
|
+
|
|
25
|
+
{#if footer.confirm !== false}
|
|
26
|
+
<Button
|
|
27
|
+
variant="fill"
|
|
28
|
+
color={footer.confirm?.danger ? "red" : "accent"}
|
|
29
|
+
on:click={() => dispatch("confirm")}
|
|
30
|
+
{...footer.confirm?.props}
|
|
31
|
+
>
|
|
32
|
+
{footer.confirm?.text || "Confirm"}
|
|
33
|
+
</Button>
|
|
34
|
+
{/if}
|
|
35
|
+
|
|
36
|
+
</ButtonGroup>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Footer } from './modal-types.ts';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
show: boolean;
|
|
6
|
+
footer: Footer;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
cancel: CustomEvent<any>;
|
|
10
|
+
confirm: CustomEvent<any>;
|
|
11
|
+
} & {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {};
|
|
15
|
+
};
|
|
16
|
+
export type ModalFooterProps = typeof __propDef.props;
|
|
17
|
+
export type ModalFooterEvents = typeof __propDef.events;
|
|
18
|
+
export type ModalFooterSlots = typeof __propDef.slots;
|
|
19
|
+
export default class ModalFooter extends SvelteComponent<ModalFooterProps, ModalFooterEvents, ModalFooterSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentProps } from "svelte";
|
|
2
|
+
import type Button from "../Button/Button.svelte";
|
|
3
|
+
export interface Footer {
|
|
4
|
+
/**
|
|
5
|
+
* undefined: default cancel button
|
|
6
|
+
* false: no cancel button
|
|
7
|
+
* obj: custom cancel button
|
|
8
|
+
*/
|
|
9
|
+
cancel?: false | {
|
|
10
|
+
text?: string;
|
|
11
|
+
props?: ComponentProps<Button>;
|
|
12
|
+
};
|
|
13
|
+
confirm?: false | {
|
|
14
|
+
danger?: boolean;
|
|
15
|
+
text?: string;
|
|
16
|
+
props?: ComponentProps<Button>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|