lapikit 0.1.4 → 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 +0 -9
- package/dist/components/dialog/dialog.svelte +1 -2
- package/dist/components/dialog/dialog.svelte.d.ts +1 -1
- package/dist/components/dialog/types.d.ts +6 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -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/stores/index.d.ts +5 -0
- package/dist/stores/index.js +21 -2
- package/dist/style/variable.css +5 -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}
|
|
@@ -42,10 +42,6 @@
|
|
|
42
42
|
border-color: var(--dialog-background);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
.kit-dialog[class*='kit-dialog--size-full'] .kit-dialog-container {
|
|
46
|
-
height: 100%;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
45
|
.kit-dialog .close-dialog {
|
|
50
46
|
opacity: 0;
|
|
51
47
|
position: fixed;
|
|
@@ -91,11 +87,6 @@
|
|
|
91
87
|
height: fit-content;
|
|
92
88
|
}
|
|
93
89
|
|
|
94
|
-
.kit-dialog[breakpoint]kit-dialog--size-full {
|
|
95
|
-
height: 100%;
|
|
96
|
-
max-height: 100%;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
90
|
.kit-dialog[breakpoint]kit-dialog--size-xs .kit-dialog-container {
|
|
100
91
|
max-height: calc(100% - 3rem);
|
|
101
92
|
margin: 0 auto;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
let {
|
|
7
7
|
children,
|
|
8
|
+
ref = $bindable(),
|
|
8
9
|
open = $bindable(),
|
|
9
10
|
dark,
|
|
10
11
|
light,
|
|
@@ -21,8 +22,6 @@
|
|
|
21
22
|
|
|
22
23
|
const assets = getAssets();
|
|
23
24
|
|
|
24
|
-
let ref: HTMLDialogElement;
|
|
25
|
-
|
|
26
25
|
$effect(() => {
|
|
27
26
|
if (ref && open) ref.showModal();
|
|
28
27
|
if (ref && !open) ref.close();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DialogProps } from './types.js';
|
|
2
|
-
declare const Dialog: import("svelte").Component<DialogProps, {}, "open">;
|
|
2
|
+
declare const Dialog: import("svelte").Component<DialogProps, {}, "ref" | "open">;
|
|
3
3
|
type Dialog = ReturnType<typeof Dialog>;
|
|
4
4
|
export default Dialog;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Component } from '../../internal/types.js';
|
|
2
|
-
type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
2
|
+
type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
3
3
|
type DialogPosition = 'bottom' | 'center' | 'top';
|
|
4
|
+
type DialogDensity = 'compact' | 'comfortable' | 'default';
|
|
4
5
|
export interface DialogProps extends Component {
|
|
6
|
+
ref?: HTMLDialogElement;
|
|
5
7
|
open?: boolean;
|
|
6
8
|
classContent?: string | string[] | undefined;
|
|
7
9
|
size?: DialogSize | {
|
|
@@ -15,6 +17,8 @@ export interface DialogProps extends Component {
|
|
|
15
17
|
light?: boolean;
|
|
16
18
|
color?: string;
|
|
17
19
|
background?: string;
|
|
18
|
-
density?:
|
|
20
|
+
density?: DialogDensity | {
|
|
21
|
+
[key: string]: DialogDensity;
|
|
22
|
+
};
|
|
19
23
|
}
|
|
20
24
|
export {};
|
|
@@ -5,3 +5,5 @@ 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
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
|
@@ -6,3 +6,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
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/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/variable.css
CHANGED
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",
|