lapikit 0.1.3 → 0.1.5
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/app/app.css +16 -0
- package/dist/components/app/app.svelte +12 -1
- package/dist/components/button/button.svelte +1 -1
- package/dist/components/dialog/dialog.css +134 -0
- package/dist/components/dialog/dialog.svelte +67 -0
- package/dist/components/dialog/dialog.svelte.d.ts +4 -0
- package/dist/components/dialog/types.d.ts +24 -0
- package/dist/components/dialog/types.js +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/components/modal/modal.css +140 -0
- package/dist/components/modal/modal.svelte +112 -0
- package/dist/components/modal/modal.svelte.d.ts +4 -0
- package/dist/components/modal/types.d.ts +26 -0
- package/dist/components/modal/types.js +1 -0
- package/dist/components/separator/separator.css +46 -0
- package/dist/components/separator/separator.svelte +37 -0
- package/dist/components/separator/separator.svelte.d.ts +4 -0
- package/dist/components/separator/types.d.ts +11 -0
- package/dist/components/separator/types.js +1 -0
- package/dist/internal/assets.svelte.d.ts +1 -0
- package/dist/internal/assets.svelte.js +11 -0
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.js +1 -0
- package/dist/internal/scroll.d.ts +1 -0
- package/dist/internal/scroll.js +6 -0
- package/dist/stores/index.d.ts +5 -0
- package/dist/stores/index.js +21 -2
- package/dist/style/css.js +3 -0
- package/dist/style/variable.css +12 -0
- package/package.json +3 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.kit-overlay {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
height: 100%;
|
|
6
|
+
width: 100%;
|
|
7
|
+
background-color: color-mix(in oklab, var(--kit-shadow) 45%, transparent);
|
|
8
|
+
z-index: 9000;
|
|
9
|
+
cursor: default;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.kit-overlay.kit-overlay--persistent {
|
|
13
|
+
/* pointer-events: none; */
|
|
14
|
+
user-select: none;
|
|
15
|
+
cursor: default;
|
|
16
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { BROWSER } from 'esm-env';
|
|
3
|
-
import { updateThemeStore } from '../../stores/index.js';
|
|
3
|
+
import { modalOpen, setOpenModal, updateThemeStore } from '../../stores/index.js';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
let { children }: { children: Snippet } = $props();
|
|
6
6
|
|
|
@@ -11,4 +11,15 @@
|
|
|
11
11
|
});
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
|
+
{$modalOpen ? ($modalOpen === 'persistent' ? 'persistent' : 'true') : 'false'}
|
|
15
|
+
|
|
14
16
|
{@render children?.()}
|
|
17
|
+
|
|
18
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
19
|
+
{#if $modalOpen}
|
|
20
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
21
|
+
<div
|
|
22
|
+
class={['kit-overlay', $modalOpen === 'persistent' && 'kit-overlay--persistent']}
|
|
23
|
+
onclick={() => $modalOpen !== 'persistent' && setOpenModal(false)}
|
|
24
|
+
></div>
|
|
25
|
+
{/if}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
.kit-dialog {
|
|
2
|
+
border: 0;
|
|
3
|
+
padding: 0;
|
|
4
|
+
margin: auto;
|
|
5
|
+
width: 100%;
|
|
6
|
+
max-width: none;
|
|
7
|
+
background-color: transparent;
|
|
8
|
+
color: inherit;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.kit-dialog[open] {
|
|
12
|
+
pointer-events: auto;
|
|
13
|
+
visibility: visible;
|
|
14
|
+
opacity: 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.kit-dialog::backdrop {
|
|
18
|
+
background-color: color-mix(in oklab, var(--kit-shadow) 30%, transparent);
|
|
19
|
+
animation: fade 0.2s ease-out;
|
|
20
|
+
}
|
|
21
|
+
.kit-dialog[open]::backdrop {
|
|
22
|
+
animation: fade 0.2s ease-out;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.kit-dialog .kit-dialog-container {
|
|
26
|
+
--dialog-color: var(--on, var(--kit-on-neutral));
|
|
27
|
+
--dialog-background: var(--base, var(--kit-neutral));
|
|
28
|
+
--dialog-radius: var(--shape, var(--kit-radius-md));
|
|
29
|
+
|
|
30
|
+
border-radius: var(--dialog-radius);
|
|
31
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
32
|
+
transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
|
|
33
|
+
transition-duration: 0.2s;
|
|
34
|
+
padding-top: var(--dialog-spacing-x);
|
|
35
|
+
padding-bottom: var(--dialog-spacing-x);
|
|
36
|
+
padding-right: var(--dialog-spacing-y);
|
|
37
|
+
padding-left: var(--dialog-spacing-y);
|
|
38
|
+
|
|
39
|
+
/* theme */
|
|
40
|
+
color: var(--dialog-color);
|
|
41
|
+
background-color: var(--dialog-background);
|
|
42
|
+
border-color: var(--dialog-background);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.kit-dialog .close-dialog {
|
|
46
|
+
opacity: 0;
|
|
47
|
+
position: fixed;
|
|
48
|
+
top: 0;
|
|
49
|
+
z-index: -1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.kit-dialog[breakpoint]kit-dialog--position-bottom {
|
|
53
|
+
margin-bottom: 0;
|
|
54
|
+
margin-top: auto;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.kit-dialog[breakpoint]kit-dialog--position-top {
|
|
58
|
+
margin-top: 0;
|
|
59
|
+
margin-bottom: auto;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.kit-dialog[breakpoint]kit-dialog--position-center {
|
|
63
|
+
margin: auto;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.kit-dialog[breakpoint]kit-dialog--size-xs {
|
|
67
|
+
max-width: var(--kit-dialog-size-xs);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.kit-dialog[breakpoint]kit-dialog--size-sm {
|
|
71
|
+
max-width: var(--kit-dialog-size-sm);
|
|
72
|
+
height: fit-content;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.kit-dialog[breakpoint]kit-dialog--size-md {
|
|
76
|
+
max-width: var(--kit-dialog-size-md);
|
|
77
|
+
height: fit-content;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.kit-dialog[breakpoint]kit-dialog--size-lg {
|
|
81
|
+
max-width: var(--kit-dialog-size-lg);
|
|
82
|
+
height: fit-content;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.kit-dialog[breakpoint]kit-dialog--size-xl {
|
|
86
|
+
max-width: var(--kit-dialog-size-xl);
|
|
87
|
+
height: fit-content;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.kit-dialog[breakpoint]kit-dialog--size-xs .kit-dialog-container {
|
|
91
|
+
max-height: calc(100% - 3rem);
|
|
92
|
+
margin: 0 auto;
|
|
93
|
+
}
|
|
94
|
+
.kit-dialog[breakpoint]kit-dialog--size-sm .kit-dialog-container {
|
|
95
|
+
max-height: calc(100% - 3rem);
|
|
96
|
+
margin: 0 auto;
|
|
97
|
+
}
|
|
98
|
+
.kit-dialog[breakpoint]kit-dialog--size-md .kit-dialog-container {
|
|
99
|
+
max-height: calc(100% - 3rem);
|
|
100
|
+
margin: 0 auto;
|
|
101
|
+
}
|
|
102
|
+
.kit-dialog[breakpoint]kit-dialog--size-lg .kit-dialog-container {
|
|
103
|
+
max-height: calc(100% - 3rem);
|
|
104
|
+
margin: 0 auto;
|
|
105
|
+
}
|
|
106
|
+
.kit-dialog[breakpoint]kit-dialog--size-xl .kit-dialog-container {
|
|
107
|
+
max-height: calc(100% - 3rem);
|
|
108
|
+
margin: 0 auto;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* density */
|
|
112
|
+
.kit-dialog .kit-dialog-container[breakpoint]kit-dialog-container--density-default {
|
|
113
|
+
--dialog-spacing-x: 0.5rem;
|
|
114
|
+
--dialog-spacing-y: 0.5rem;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.kit-dialog .kit-dialog-container[breakpoint]kit-dialog-container--density-compact {
|
|
118
|
+
--dialog-spacing-x: 0.25rem;
|
|
119
|
+
--dialog-spacing-y: 0.25rem;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.kit-dialog .kit-dialog-container[breakpoint]kit-dialog-container--density-comfortable {
|
|
123
|
+
--dialog-spacing-x: 0.75rem;
|
|
124
|
+
--dialog-spacing-y: 0.75rem;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@keyframes fade {
|
|
128
|
+
from {
|
|
129
|
+
opacity: 0;
|
|
130
|
+
}
|
|
131
|
+
to {
|
|
132
|
+
opacity: 1;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { disabledScroll } from '../../internal/index.js';
|
|
3
|
+
import { getAssets } from '../../internal/index.js';
|
|
4
|
+
import type { DialogProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
ref = $bindable(),
|
|
9
|
+
open = $bindable(),
|
|
10
|
+
dark,
|
|
11
|
+
light,
|
|
12
|
+
classContent,
|
|
13
|
+
color,
|
|
14
|
+
background,
|
|
15
|
+
size = 'md',
|
|
16
|
+
persistent,
|
|
17
|
+
position = 'center',
|
|
18
|
+
rounded,
|
|
19
|
+
density = 'default',
|
|
20
|
+
...rest
|
|
21
|
+
}: DialogProps = $props();
|
|
22
|
+
|
|
23
|
+
const assets = getAssets();
|
|
24
|
+
|
|
25
|
+
$effect(() => {
|
|
26
|
+
if (ref && open) ref.showModal();
|
|
27
|
+
if (ref && !open) ref.close();
|
|
28
|
+
disabledScroll(open ? true : false);
|
|
29
|
+
});
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<dialog
|
|
33
|
+
bind:this={ref}
|
|
34
|
+
class={[
|
|
35
|
+
'kit-dialog',
|
|
36
|
+
persistent && 'kit-dialog--persistent',
|
|
37
|
+
size && assets.className('dialog', 'size', size),
|
|
38
|
+
position && assets.className('dialog', 'position', position),
|
|
39
|
+
rest.class
|
|
40
|
+
]}
|
|
41
|
+
onclose={() => (!persistent ? (open = false) : null)}
|
|
42
|
+
onclick={(event: MouseEvent) => {
|
|
43
|
+
if (event.target === ref) {
|
|
44
|
+
if (!persistent) ref.close();
|
|
45
|
+
}
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<!-- surcharge-dialog autofocus-action-element -->
|
|
49
|
+
<button type="button" class="close-dialog">close</button>
|
|
50
|
+
<div
|
|
51
|
+
{...rest}
|
|
52
|
+
class={[
|
|
53
|
+
'kit-dialog-container',
|
|
54
|
+
light && 'light',
|
|
55
|
+
dark && 'dark',
|
|
56
|
+
classContent,
|
|
57
|
+
density && assets.className('dialog-container', 'density', density),
|
|
58
|
+
rest.class
|
|
59
|
+
]}
|
|
60
|
+
onclick={(event: MouseEvent) => event.stopPropagation()}
|
|
61
|
+
style:--base={assets.color(background)}
|
|
62
|
+
style:--on={assets.color(color)}
|
|
63
|
+
style:--shape={assets.shape(rounded)}
|
|
64
|
+
>
|
|
65
|
+
{@render children?.()}
|
|
66
|
+
</div>
|
|
67
|
+
</dialog>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Component } from '../../internal/types.js';
|
|
2
|
+
type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
3
|
+
type DialogPosition = 'bottom' | 'center' | 'top';
|
|
4
|
+
type DialogDensity = 'compact' | 'comfortable' | 'default';
|
|
5
|
+
export interface DialogProps extends Component {
|
|
6
|
+
ref?: HTMLDialogElement;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
classContent?: string | string[] | undefined;
|
|
9
|
+
size?: DialogSize | {
|
|
10
|
+
[key: string]: DialogSize;
|
|
11
|
+
};
|
|
12
|
+
persistent?: boolean;
|
|
13
|
+
position?: DialogPosition | {
|
|
14
|
+
[key: string]: DialogPosition;
|
|
15
|
+
};
|
|
16
|
+
dark?: boolean;
|
|
17
|
+
light?: boolean;
|
|
18
|
+
color?: string;
|
|
19
|
+
background?: string;
|
|
20
|
+
density?: DialogDensity | {
|
|
21
|
+
[key: string]: DialogDensity;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,3 +4,6 @@ export { default as Icon } from './icon/icon.svelte';
|
|
|
4
4
|
export { default as Dropdown } from './dropdown/dropdown.svelte';
|
|
5
5
|
export { default as Popover } from './popover/popover.svelte';
|
|
6
6
|
export { default as Tooltip } from './tooltip/tooltip.svelte';
|
|
7
|
+
export { default as Dialog } from './dialog/dialog.svelte';
|
|
8
|
+
export { default as Separator } from './separator/separator.svelte';
|
|
9
|
+
export { default as Modal } from './modal/modal.svelte';
|
package/dist/components/index.js
CHANGED
|
@@ -5,3 +5,6 @@ export { default as Icon } from './icon/icon.svelte';
|
|
|
5
5
|
export { default as Dropdown } from './dropdown/dropdown.svelte';
|
|
6
6
|
export { default as Popover } from './popover/popover.svelte';
|
|
7
7
|
export { default as Tooltip } from './tooltip/tooltip.svelte';
|
|
8
|
+
export { default as Dialog } from './dialog/dialog.svelte';
|
|
9
|
+
export { default as Separator } from './separator/separator.svelte';
|
|
10
|
+
export { default as Modal } from './modal/modal.svelte';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
.kit-modal {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.kit-modal-container {
|
|
7
|
+
--modal-color: var(--on, var(--kit-on-neutral));
|
|
8
|
+
--modal-background: var(--base, var(--kit-neutral));
|
|
9
|
+
--modal-radius: var(--shape, var(--kit-radius-md));
|
|
10
|
+
--modal-translate-x: -50%;
|
|
11
|
+
--modal-translate-y: -50%;
|
|
12
|
+
|
|
13
|
+
position: fixed;
|
|
14
|
+
|
|
15
|
+
z-index: 9100;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
padding-top: var(--modal-spacing-x);
|
|
19
|
+
padding-bottom: var(--modal-spacing-x);
|
|
20
|
+
padding-right: var(--modal-spacing-y);
|
|
21
|
+
padding-left: var(--modal-spacing-y);
|
|
22
|
+
|
|
23
|
+
/* theme */
|
|
24
|
+
color: var(--modal-color);
|
|
25
|
+
background-color: var(--modal-background);
|
|
26
|
+
border-color: var(--modal-background);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.kit-modal.kit-modal--contain {
|
|
30
|
+
position: absolute;
|
|
31
|
+
top: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.kit-modal.kit-modal--contain .kit-overlay {
|
|
35
|
+
position: absolute;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.kit-modal.kit-modal--contain .kit-modal-container {
|
|
39
|
+
position: absolute;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* size */
|
|
43
|
+
.kit-modal [breakpoint]kit-modal-container--size-xs {
|
|
44
|
+
max-width: var(--kit-modal-size-xs);
|
|
45
|
+
max-height: calc(100% - 3rem);
|
|
46
|
+
height: fit-content;
|
|
47
|
+
margin: 0 auto;
|
|
48
|
+
top: 50%;
|
|
49
|
+
left: 50%;
|
|
50
|
+
bottom: initial;
|
|
51
|
+
translate: var(--modal-translate-x) var(--modal-translate-y);
|
|
52
|
+
border-radius: var(--modal-radius);
|
|
53
|
+
}
|
|
54
|
+
.kit-modal [breakpoint]kit-modal-container--size-sm {
|
|
55
|
+
max-width: var(--kit-modal-size-sm);
|
|
56
|
+
max-height: calc(100% - 3rem);
|
|
57
|
+
height: fit-content;
|
|
58
|
+
margin: 0 auto;
|
|
59
|
+
top: 50%;
|
|
60
|
+
left: 50%;
|
|
61
|
+
bottom: initial;
|
|
62
|
+
translate: var(--modal-translate-x) var(--modal-translate-y);
|
|
63
|
+
border-radius: var(--modal-radius);
|
|
64
|
+
}
|
|
65
|
+
.kit-modal [breakpoint]kit-modal-container--size-md {
|
|
66
|
+
max-width: var(--kit-modal-size-md);
|
|
67
|
+
max-height: calc(100% - 3rem);
|
|
68
|
+
height: fit-content;
|
|
69
|
+
margin: 0 auto;
|
|
70
|
+
top: 50%;
|
|
71
|
+
left: 50%;
|
|
72
|
+
bottom: initial;
|
|
73
|
+
translate: var(--modal-translate-x) var(--modal-translate-y);
|
|
74
|
+
border-radius: var(--modal-radius);
|
|
75
|
+
}
|
|
76
|
+
.kit-modal [breakpoint]kit-modal-container--size-lg {
|
|
77
|
+
max-width: var(--kit-modal-size-lg);
|
|
78
|
+
max-height: calc(100% - 3rem);
|
|
79
|
+
height: fit-content;
|
|
80
|
+
margin: 0 auto;
|
|
81
|
+
top: 50%;
|
|
82
|
+
left: 50%;
|
|
83
|
+
bottom: initial;
|
|
84
|
+
translate: var(--modal-translate-x) var(--modal-translate-y);
|
|
85
|
+
border-radius: var(--modal-radius);
|
|
86
|
+
}
|
|
87
|
+
.kit-modal [breakpoint]kit-modal-container--size-xl {
|
|
88
|
+
max-width: var(--kit-modal-size-xl);
|
|
89
|
+
max-height: calc(100% - 3rem);
|
|
90
|
+
height: fit-content;
|
|
91
|
+
margin: 0 auto;
|
|
92
|
+
top: 50%;
|
|
93
|
+
left: 50%;
|
|
94
|
+
bottom: initial;
|
|
95
|
+
translate: var(--modal-translate-x) var(--modal-translate-y);
|
|
96
|
+
border-radius: var(--modal-radius);
|
|
97
|
+
}
|
|
98
|
+
.kit-modal [breakpoint]kit-modal-container--size-full {
|
|
99
|
+
max-width: 100%;
|
|
100
|
+
max-height: calc(100% - 3rem);
|
|
101
|
+
margin: 0 auto;
|
|
102
|
+
bottom: 0;
|
|
103
|
+
translate: 0 0;
|
|
104
|
+
left: 0;
|
|
105
|
+
top: initial;
|
|
106
|
+
height: 100%;
|
|
107
|
+
border-radius: var(--modal-radius) var(--modal-radius) 0 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* density */
|
|
111
|
+
.kit-modal [breakpoint]kit-modal-container--density-default {
|
|
112
|
+
--modal-spacing-x: 0.5rem;
|
|
113
|
+
--modal-spacing-y: 0.5rem;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.kit-modal [breakpoint]kit-modal-container--density-compact {
|
|
117
|
+
--modal-spacing-x: 0.25rem;
|
|
118
|
+
--modal-spacing-y: 0.25rem;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.kit-modal [breakpoint]kit-modal-container--density-comfortable {
|
|
122
|
+
--modal-spacing-x: 0.75rem;
|
|
123
|
+
--modal-spacing-y: 0.75rem;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* position */
|
|
127
|
+
.kit-modal [breakpoint]kit-modal-container--position-bottom {
|
|
128
|
+
--modal-translate-y: 0;
|
|
129
|
+
bottom: 0;
|
|
130
|
+
top: initial;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.kit-modal [breakpoint]kit-modal-container--position-top {
|
|
134
|
+
--modal-translate-y: 0;
|
|
135
|
+
top: 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.kit-modal [breakpoint]kit-modal-container--position-center {
|
|
139
|
+
margin: auto;
|
|
140
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// import { disabledScroll } from '../../internal/index.js';
|
|
3
|
+
import { getAssets } from '../../internal/index.js';
|
|
4
|
+
import { modalOpen, modalStack, popModal, pushModal, setOpenModal } from '../../stores/index.js';
|
|
5
|
+
import { onDestroy } from 'svelte';
|
|
6
|
+
import type { ModalProps } from './types.js';
|
|
7
|
+
import { get } from 'svelte/store';
|
|
8
|
+
|
|
9
|
+
const modalId = crypto.randomUUID();
|
|
10
|
+
let wasPushed = $state(false);
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
children,
|
|
14
|
+
ref = $bindable(),
|
|
15
|
+
open = $bindable(),
|
|
16
|
+
contain,
|
|
17
|
+
size = 'md',
|
|
18
|
+
persistent,
|
|
19
|
+
dark,
|
|
20
|
+
light,
|
|
21
|
+
classContent,
|
|
22
|
+
color,
|
|
23
|
+
background,
|
|
24
|
+
position = 'center',
|
|
25
|
+
rounded,
|
|
26
|
+
density = 'default',
|
|
27
|
+
closeWithEsc,
|
|
28
|
+
...rest
|
|
29
|
+
}: ModalProps = $props();
|
|
30
|
+
|
|
31
|
+
const assets = getAssets();
|
|
32
|
+
|
|
33
|
+
$effect(() => {
|
|
34
|
+
if (open && !wasPushed) {
|
|
35
|
+
pushModal(modalId);
|
|
36
|
+
wasPushed = true;
|
|
37
|
+
} else if (!open && wasPushed) {
|
|
38
|
+
popModal(modalId);
|
|
39
|
+
wasPushed = false;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
onDestroy(() => {
|
|
44
|
+
if (wasPushed) popModal(modalId);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
$effect(() => {
|
|
48
|
+
if (open !== undefined && !contain)
|
|
49
|
+
setOpenModal(open ? (persistent ? 'persistent' : open) : open);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
$effect(() => {
|
|
53
|
+
if ($modalOpen === false && !contain) open = false;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
$effect(() => {
|
|
57
|
+
if (!closeWithEsc || persistent || !open) return;
|
|
58
|
+
|
|
59
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
60
|
+
const stack = get(modalStack);
|
|
61
|
+
const isTop = stack[stack.length - 1] === modalId;
|
|
62
|
+
|
|
63
|
+
if (event.key === 'Escape' && isTop) {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
open = false;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
document.addEventListener('keydown', onKeyDown);
|
|
70
|
+
return () => {
|
|
71
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const handleClose = () => {
|
|
76
|
+
if (!persistent) open = false;
|
|
77
|
+
};
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
{#if open}
|
|
81
|
+
<div
|
|
82
|
+
bind:this={ref}
|
|
83
|
+
class={['kit-modal', contain && 'kit-modal--contain', rest.class]}
|
|
84
|
+
role="dialog"
|
|
85
|
+
>
|
|
86
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
87
|
+
{#if contain}
|
|
88
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
89
|
+
<div
|
|
90
|
+
class={['kit-overlay', persistent && 'kit-overlay--persistent']}
|
|
91
|
+
onclick={() => handleClose()}
|
|
92
|
+
></div>
|
|
93
|
+
{/if}
|
|
94
|
+
|
|
95
|
+
<div
|
|
96
|
+
class={[
|
|
97
|
+
'kit-modal-container',
|
|
98
|
+
classContent,
|
|
99
|
+
light && 'light',
|
|
100
|
+
dark && 'dark',
|
|
101
|
+
size && assets.className('modal-container', 'size', size),
|
|
102
|
+
density && assets.className('modal-container', 'density', density),
|
|
103
|
+
position && assets.className('modal-container', 'position', position)
|
|
104
|
+
]}
|
|
105
|
+
style:--base={assets.color(background)}
|
|
106
|
+
style:--on={assets.color(color)}
|
|
107
|
+
style:--shape={assets.shape(rounded)}
|
|
108
|
+
>
|
|
109
|
+
{@render children?.()}
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
{/if}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Component } from '../../internal/types.js';
|
|
2
|
+
type ModalSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
3
|
+
type ModalPosition = 'bottom' | 'center' | 'top';
|
|
4
|
+
type ModalDensity = 'compact' | 'comfortable' | 'default';
|
|
5
|
+
export interface ModalProps extends Component {
|
|
6
|
+
ref?: HTMLDivElement;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
classContent?: string | string[] | undefined;
|
|
9
|
+
size?: ModalSize | {
|
|
10
|
+
[key: string]: ModalSize;
|
|
11
|
+
};
|
|
12
|
+
persistent?: boolean;
|
|
13
|
+
position?: ModalPosition | {
|
|
14
|
+
[key: string]: ModalPosition;
|
|
15
|
+
};
|
|
16
|
+
dark?: boolean;
|
|
17
|
+
light?: boolean;
|
|
18
|
+
color?: string;
|
|
19
|
+
background?: string;
|
|
20
|
+
density?: ModalDensity | {
|
|
21
|
+
[key: string]: ModalDensity;
|
|
22
|
+
};
|
|
23
|
+
contain?: boolean;
|
|
24
|
+
closeWithEsc?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.kit-separator {
|
|
2
|
+
--separator-opacity: var(--opacity, 0.12);
|
|
3
|
+
--separator-color: var(--base, var(--kit-scrim));
|
|
4
|
+
|
|
5
|
+
display: block;
|
|
6
|
+
flex: 1 1 100%;
|
|
7
|
+
height: 0px;
|
|
8
|
+
max-height: 0px;
|
|
9
|
+
opacity: var(--separator-opacity);
|
|
10
|
+
transition: inherit;
|
|
11
|
+
border-color: var(--separator-color);
|
|
12
|
+
transition: border-color 0.5s;
|
|
13
|
+
border-style: solid;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.kit-separator:not(.kit-separator--orientation-vertical) {
|
|
17
|
+
border-width: var(--border-top-width, thin) 0 0 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.kit-separator--orientation-vertical {
|
|
21
|
+
align-self: stretch;
|
|
22
|
+
border-width: 0 thin 0 0;
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
height: auto;
|
|
25
|
+
margin-left: 0px;
|
|
26
|
+
max-height: 100%;
|
|
27
|
+
max-width: 0px;
|
|
28
|
+
vertical-align: text-bottom;
|
|
29
|
+
width: 0px;
|
|
30
|
+
border-width: 0 var(--border-right-width, thin) 0 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.kit-separator--inset:not(.kit-separator--orientation-vertical) {
|
|
34
|
+
max-width: calc(100% - 4.5rem);
|
|
35
|
+
margin-inline-start: 4.5rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.kit-separator--inset.kit-separator--orientation-vertical {
|
|
39
|
+
margin-bottom: 0.5rem;
|
|
40
|
+
margin-top: 0.5rem;
|
|
41
|
+
max-height: calc(100% - 1rem);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.kit-separator:not(.kit-separator--orientation-vertical) {
|
|
45
|
+
width: 100%;
|
|
46
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getAssets } from '../../internal/index.js';
|
|
3
|
+
import type { SeparatorProps } from './types.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
is = 'hr',
|
|
7
|
+
light,
|
|
8
|
+
dark,
|
|
9
|
+
inset,
|
|
10
|
+
thickness,
|
|
11
|
+
orientation = 'horizontal',
|
|
12
|
+
opacity,
|
|
13
|
+
color,
|
|
14
|
+
...rest
|
|
15
|
+
}: SeparatorProps = $props();
|
|
16
|
+
|
|
17
|
+
const assets = getAssets();
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<svelte:element
|
|
21
|
+
this={is}
|
|
22
|
+
{...rest}
|
|
23
|
+
class={[
|
|
24
|
+
'kit-separator',
|
|
25
|
+
light && 'light',
|
|
26
|
+
dark && 'dark',
|
|
27
|
+
inset && 'kit-separator--inset',
|
|
28
|
+
orientation && assets.className('separator', 'orientation', orientation),
|
|
29
|
+
rest.class
|
|
30
|
+
]}
|
|
31
|
+
aria-orientation={orientation}
|
|
32
|
+
role="separator"
|
|
33
|
+
style:--base={assets.color(color)}
|
|
34
|
+
style:--opacity={opacity}
|
|
35
|
+
style:--border-top-width={orientation === 'horizontal' ? assets.unit(thickness) : undefined}
|
|
36
|
+
style:--border-right-width={orientation === 'vertical' ? assets.unit(thickness) : undefined}
|
|
37
|
+
/>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Base } from '../../internal/types.js';
|
|
2
|
+
export interface SeparatorProps extends Base {
|
|
3
|
+
is?: 'div' | 'hr';
|
|
4
|
+
light?: boolean;
|
|
5
|
+
dark?: boolean;
|
|
6
|
+
inset?: boolean;
|
|
7
|
+
thickness?: string;
|
|
8
|
+
opacity?: string | number;
|
|
9
|
+
color?: string;
|
|
10
|
+
orientation?: 'horizontal' | 'vertical';
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -36,6 +36,17 @@ export function getAssets() {
|
|
|
36
36
|
return color;
|
|
37
37
|
return `var(--kit-${color})`;
|
|
38
38
|
}
|
|
39
|
+
},
|
|
40
|
+
unit(value) {
|
|
41
|
+
if (typeof value === 'number')
|
|
42
|
+
return `${value}px`;
|
|
43
|
+
if (typeof value === 'string') {
|
|
44
|
+
const cleaned = value.trim();
|
|
45
|
+
const isOnlyNumericLike = /^[\d.,]+$/.test(cleaned);
|
|
46
|
+
if (isOnlyNumericLike)
|
|
47
|
+
return `${value}px`;
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
39
50
|
}
|
|
40
51
|
};
|
|
41
52
|
}
|
package/dist/internal/index.d.ts
CHANGED
package/dist/internal/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function disabledScroll(state: boolean): void;
|
package/dist/stores/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { type Writable } from 'svelte/store';
|
|
2
2
|
export declare const colorScheme: Writable<'auto' | 'dark' | 'light'>;
|
|
3
|
+
export declare const modalOpen: Writable<boolean | 'persistent'>;
|
|
4
|
+
export declare const modalStack: Writable<string[]>;
|
|
3
5
|
export declare function updateThemeStore(update: 'auto' | 'dark' | 'light'): void;
|
|
4
6
|
export declare function setColorScheme(scheme: 'auto' | 'dark' | 'light'): void;
|
|
7
|
+
export declare function setOpenModal(state: boolean | 'persistent'): void;
|
|
8
|
+
export declare const pushModal: (id: string) => void;
|
|
9
|
+
export declare const popModal: (id: string) => void;
|
package/dist/stores/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { writable } from 'svelte/store';
|
|
2
2
|
// states
|
|
3
|
-
const
|
|
3
|
+
const colorScheme_default = 'light';
|
|
4
|
+
const modalOpen_default = false;
|
|
4
5
|
const isBrowser = typeof window !== 'undefined';
|
|
5
|
-
export const colorScheme = writable(
|
|
6
|
+
export const colorScheme = writable(colorScheme_default);
|
|
7
|
+
export const modalOpen = writable(modalOpen_default);
|
|
8
|
+
export const modalStack = writable([]);
|
|
6
9
|
export function updateThemeStore(update) {
|
|
7
10
|
colorScheme.update(() => {
|
|
8
11
|
if (isBrowser) {
|
|
@@ -21,3 +24,19 @@ export function updateThemeStore(update) {
|
|
|
21
24
|
export function setColorScheme(scheme) {
|
|
22
25
|
updateThemeStore(scheme);
|
|
23
26
|
}
|
|
27
|
+
export function setOpenModal(state) {
|
|
28
|
+
modalOpen.set(state);
|
|
29
|
+
}
|
|
30
|
+
export const pushModal = (id) => {
|
|
31
|
+
modalStack.update((stack) => {
|
|
32
|
+
if (!stack.includes(id))
|
|
33
|
+
return [...stack, id];
|
|
34
|
+
return stack;
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export const popModal = (id) => {
|
|
38
|
+
modalStack.update((stack) => {
|
|
39
|
+
const newStack = stack.filter((m) => m !== id);
|
|
40
|
+
return newStack.length === 0 ? [] : newStack;
|
|
41
|
+
});
|
|
42
|
+
};
|
package/dist/style/css.js
CHANGED
|
@@ -11,6 +11,7 @@ const __dirname = dirname(__filename);
|
|
|
11
11
|
export const processCSS = async (config) => {
|
|
12
12
|
const _normalize = fs.readFileSync(path.resolve(__dirname, './normalize.css'), 'utf-8');
|
|
13
13
|
const _animation = fs.readFileSync(path.resolve(__dirname, './animation.css'), 'utf-8');
|
|
14
|
+
const _variables = fs.readFileSync(path.resolve(__dirname, './variable.css'), 'utf-8');
|
|
14
15
|
let styles = ``;
|
|
15
16
|
if (config.options.normalize)
|
|
16
17
|
styles += `${_normalize}\n`;
|
|
@@ -19,6 +20,8 @@ export const processCSS = async (config) => {
|
|
|
19
20
|
const variablesStyles = variables(config);
|
|
20
21
|
styles += `${colorScheme.root}\n`;
|
|
21
22
|
styles += `${variablesStyles}\n`;
|
|
23
|
+
styles += `${variablesStyles}\n`;
|
|
24
|
+
styles += `${_variables}\n`;
|
|
22
25
|
styles += `${colorScheme.className}\n`;
|
|
23
26
|
styles += `${deviceDisplay}\n`;
|
|
24
27
|
styles += component(config);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--kit-dialog-size-xs: 18.75rem;
|
|
3
|
+
--kit-dialog-size-sm: 25rem;
|
|
4
|
+
--kit-dialog-size-md: 37.5rem;
|
|
5
|
+
--kit-dialog-size-lg: 53.125rem;
|
|
6
|
+
--kit-dialog-size-xl: 75rem;
|
|
7
|
+
--kit-modal-size-xs: 18.75rem;
|
|
8
|
+
--kit-modal-size-sm: 25rem;
|
|
9
|
+
--kit-modal-size-md: 37.5rem;
|
|
10
|
+
--kit-modal-size-lg: 53.125rem;
|
|
11
|
+
--kit-modal-size-xl: 75rem;
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lapikit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"type": "module",
|
|
43
43
|
"exports": {
|
|
44
44
|
".": {
|
|
45
|
-
"types": "./dist/index.d.ts"
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"svelte": "./dist/index.js"
|
|
46
47
|
},
|
|
47
48
|
"./components": {
|
|
48
49
|
"svelte": "./dist/components/index.js",
|