@hyvor/design 0.0.15 → 0.0.16
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.
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<script>import { clickOutside } from "../../directives/clickOutside.js";
|
|
2
|
+
import { IconX } from "@hyvor/icons";
|
|
3
|
+
import IconButton from "./../IconButton/IconButton.svelte";
|
|
4
|
+
import { scale } from "svelte/transition";
|
|
5
|
+
export let show = false;
|
|
6
|
+
export let title = "";
|
|
7
|
+
export let size = "medium";
|
|
8
|
+
export let closeOnOutsideClick = true;
|
|
9
|
+
export let closeOnEscape = true;
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<svelte:window on:keyup={e => {
|
|
13
|
+
if (e.key === 'Escape' && closeOnEscape) {
|
|
14
|
+
show = false;
|
|
15
|
+
}
|
|
16
|
+
}} />
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
{#if show}
|
|
20
|
+
<div class="wrap">
|
|
21
|
+
|
|
22
|
+
<div
|
|
23
|
+
class="inner {size}"
|
|
24
|
+
use:clickOutside={{
|
|
25
|
+
enabled: closeOnOutsideClick,
|
|
26
|
+
callback: () => show = false
|
|
27
|
+
}}
|
|
28
|
+
in:scale={{duration: 100, start: 0.9, opacity: 0.9}}
|
|
29
|
+
>
|
|
30
|
+
|
|
31
|
+
<div class="header">
|
|
32
|
+
|
|
33
|
+
<div class="title">
|
|
34
|
+
{title}
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div class="close-wrap">
|
|
38
|
+
<IconButton
|
|
39
|
+
color="invisible"
|
|
40
|
+
on:click={() => show = false}
|
|
41
|
+
>
|
|
42
|
+
<IconX size={25} />
|
|
43
|
+
</IconButton>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div class="content">
|
|
49
|
+
<slot />
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<div class="footer">
|
|
53
|
+
<slot name="footer" />
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
{/if}
|
|
60
|
+
|
|
61
|
+
<style>
|
|
62
|
+
|
|
63
|
+
.wrap {
|
|
64
|
+
position: fixed;
|
|
65
|
+
top: 0;
|
|
66
|
+
left: 0;
|
|
67
|
+
z-index: 1000;
|
|
68
|
+
width: 100%;
|
|
69
|
+
height: 100%;
|
|
70
|
+
background: rgba(0,0,0,0.5);
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.inner {
|
|
77
|
+
background: var(--box-background);
|
|
78
|
+
border-radius: var(--box-radius);
|
|
79
|
+
box-shadow: var(--box-shadow);
|
|
80
|
+
width: 650px;
|
|
81
|
+
max-width: 100%;
|
|
82
|
+
max-height: 100%;
|
|
83
|
+
overflow: auto;
|
|
84
|
+
position: relative;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.inner.small {
|
|
88
|
+
width: 425px;
|
|
89
|
+
}
|
|
90
|
+
.inner.large {
|
|
91
|
+
width: 800px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.header {
|
|
95
|
+
padding: 20px 25px;
|
|
96
|
+
border-bottom: 1px solid var(--box-border);
|
|
97
|
+
font-size: 1.2em;
|
|
98
|
+
font-weight: 600;
|
|
99
|
+
display: flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.title {
|
|
104
|
+
flex: 1;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.content {
|
|
108
|
+
padding: 20px 25px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.footer {
|
|
112
|
+
padding: 20px 25px;
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
justify-content: flex-end;
|
|
116
|
+
}
|
|
117
|
+
.footer :global(button:not(:last-child)) {
|
|
118
|
+
margin-right: 2px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
show?: boolean | undefined;
|
|
5
|
+
title?: string | undefined;
|
|
6
|
+
size?: "small" | "medium" | "large" | undefined;
|
|
7
|
+
closeOnOutsideClick?: boolean | undefined;
|
|
8
|
+
closeOnEscape?: boolean | undefined;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
default: {};
|
|
15
|
+
footer: {};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type ModalProps = typeof __propDef.props;
|
|
19
|
+
export type ModalEvents = typeof __propDef.events;
|
|
20
|
+
export type ModalSlots = typeof __propDef.slots;
|
|
21
|
+
export default class Modal extends SvelteComponent<ModalProps, ModalEvents, ModalSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -21,6 +21,7 @@ export { default as Validation } from './FormControl/Validation.svelte';
|
|
|
21
21
|
export { default as IconButton } from './IconButton/IconButton.svelte';
|
|
22
22
|
export { default as Link } from './Link/Link.svelte';
|
|
23
23
|
export { default as Loader } from './Loader/Loader.svelte';
|
|
24
|
+
export { default as Modal } from './Modal/Modal.svelte';
|
|
24
25
|
export { default as NavLink } from './NavLink/NavLink.svelte';
|
|
25
26
|
export { default as Radio } from './Radio/Radio.svelte';
|
|
26
27
|
export { default as SplitControl } from './SplitControl/SplitControl.svelte';
|
package/dist/components/index.js
CHANGED
|
@@ -21,6 +21,7 @@ export { default as Validation } from './FormControl/Validation.svelte';
|
|
|
21
21
|
export { default as IconButton } from './IconButton/IconButton.svelte';
|
|
22
22
|
export { default as Link } from './Link/Link.svelte';
|
|
23
23
|
export { default as Loader } from './Loader/Loader.svelte';
|
|
24
|
+
export { default as Modal } from './Modal/Modal.svelte';
|
|
24
25
|
export { default as NavLink } from './NavLink/NavLink.svelte';
|
|
25
26
|
export { default as Radio } from './Radio/Radio.svelte';
|
|
26
27
|
export { default as SplitControl } from './SplitControl/SplitControl.svelte';
|
|
@@ -10,7 +10,9 @@ export function clickOutside(node, input) {
|
|
|
10
10
|
options.callback();
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
setTimeout(() => {
|
|
14
|
+
document.addEventListener("click", handleClick);
|
|
15
|
+
}, 0);
|
|
14
16
|
return {
|
|
15
17
|
destroy() {
|
|
16
18
|
document.removeEventListener("click", handleClick);
|