lapikit 0.0.0-insiders.b2fe678 → 0.0.0-insiders.cee8a41

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.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/dist/assets/icons/loading-fill.svelte +29 -0
  3. package/dist/assets/icons/loading-fill.svelte.d.ts +26 -0
  4. package/dist/components/app/app.css +16 -0
  5. package/dist/components/app/app.svelte +25 -0
  6. package/dist/components/app/app.svelte.d.ts +7 -0
  7. package/dist/components/app/types.d.ts +4 -0
  8. package/dist/components/app/types.js +1 -0
  9. package/dist/components/button/button.css +276 -0
  10. package/dist/components/button/button.svelte +94 -0
  11. package/dist/components/button/button.svelte.d.ts +4 -0
  12. package/dist/components/button/types.d.ts +27 -0
  13. package/dist/components/button/types.js +1 -0
  14. package/dist/components/dialog/dialog.css +134 -0
  15. package/dist/components/dialog/dialog.svelte +67 -0
  16. package/dist/components/dialog/dialog.svelte.d.ts +4 -0
  17. package/dist/components/dialog/types.d.ts +24 -0
  18. package/dist/components/dialog/types.js +1 -0
  19. package/dist/components/dropdown/dropdown.css +22 -0
  20. package/dist/components/dropdown/dropdown.svelte +116 -0
  21. package/dist/components/dropdown/dropdown.svelte.d.ts +4 -0
  22. package/dist/components/dropdown/dropdown.svelte.js +148 -0
  23. package/dist/components/dropdown/types.d.ts +26 -0
  24. package/dist/components/dropdown/types.js +1 -0
  25. package/dist/components/icon/icon.css +76 -0
  26. package/dist/components/icon/icon.svelte +49 -0
  27. package/dist/components/icon/icon.svelte.d.ts +4 -0
  28. package/dist/components/icon/types.d.ts +16 -0
  29. package/dist/components/icon/types.js +1 -0
  30. package/dist/components/index.d.ts +11 -0
  31. package/dist/components/index.js +12 -0
  32. package/dist/components/list/list.css +193 -0
  33. package/dist/components/list/list.svelte +46 -0
  34. package/dist/components/list/list.svelte.d.ts +4 -0
  35. package/dist/components/list/modules/list-item.svelte +68 -0
  36. package/dist/components/list/modules/list-item.svelte.d.ts +4 -0
  37. package/dist/components/list/types.d.ts +36 -0
  38. package/dist/components/list/types.js +1 -0
  39. package/dist/components/modal/modal.css +140 -0
  40. package/dist/components/modal/modal.svelte +112 -0
  41. package/dist/components/modal/modal.svelte.d.ts +4 -0
  42. package/dist/components/modal/types.d.ts +26 -0
  43. package/dist/components/modal/types.js +1 -0
  44. package/dist/components/popover/popover.css +22 -0
  45. package/dist/components/popover/popover.svelte +73 -0
  46. package/dist/components/popover/popover.svelte.d.ts +4 -0
  47. package/dist/components/popover/popover.svelte.js +134 -0
  48. package/dist/components/popover/types.d.ts +20 -0
  49. package/dist/components/popover/types.js +1 -0
  50. package/dist/components/separator/separator.css +46 -0
  51. package/dist/components/separator/separator.svelte +37 -0
  52. package/dist/components/separator/separator.svelte.d.ts +4 -0
  53. package/dist/components/separator/types.d.ts +11 -0
  54. package/dist/components/separator/types.js +1 -0
  55. package/dist/components/tooltip/tooltip.css +124 -0
  56. package/dist/components/tooltip/tooltip.svelte +113 -0
  57. package/dist/components/tooltip/tooltip.svelte.d.ts +4 -0
  58. package/dist/components/tooltip/tooltip.svelte.js +131 -0
  59. package/dist/components/tooltip/types.d.ts +23 -0
  60. package/dist/components/tooltip/types.js +1 -0
  61. package/dist/internal/assets.svelte.d.ts +8 -0
  62. package/dist/internal/assets.svelte.js +52 -0
  63. package/dist/internal/clickOutside.d.ts +9 -0
  64. package/dist/internal/clickOutside.js +34 -0
  65. package/dist/internal/index.d.ts +2 -0
  66. package/dist/internal/index.js +2 -0
  67. package/dist/internal/scroll.d.ts +1 -0
  68. package/dist/internal/scroll.js +6 -0
  69. package/dist/internal/types.d.ts +13 -0
  70. package/dist/preset.js +14 -2
  71. package/dist/stores/index.d.ts +9 -0
  72. package/dist/stores/index.js +42 -0
  73. package/dist/style/animation.css +20 -0
  74. package/dist/style/css.js +6 -3
  75. package/dist/style/parser/color.js +13 -2
  76. package/dist/style/variable.css +12 -0
  77. package/dist/utils/x11.d.ts +1 -1
  78. package/package.json +11 -1
@@ -0,0 +1,193 @@
1
+ .kit-list {
2
+ --list-color: var(--on, var(--kit-on-neutral));
3
+ --list-background: var(--base, var(--kit-neutral));
4
+ --list-radius: var(--shape, var(--kit-radius-md));
5
+
6
+ display: flex;
7
+ width: 100%;
8
+ }
9
+
10
+ .kit-list--nav {
11
+ padding: 8px;
12
+ }
13
+
14
+ /* orientation */
15
+ .kit-list[breakpoint]kit-list--orientation-vertical {
16
+ flex-direction: column;
17
+ }
18
+ .kit-list[breakpoint]kit-list--orientation-horizontal {
19
+ flex-direction: row;
20
+ }
21
+ .kit-list[breakpoint]kit-list--orientation-horizontal .kit-list-item {
22
+ justify-content: center;
23
+ }
24
+
25
+ /* size */
26
+ .kit-list[breakpoint]kit-list--size-xs {
27
+ --list-height: 1.75rem;
28
+ --list-multiplier-y: 2;
29
+ --list-gap: 0.25rem;
30
+ font-size: 0.75rem;
31
+ }
32
+
33
+ .kit-list[breakpoint]kit-list--size-sm {
34
+ --list-height: 2rem;
35
+ --list-multiplier-y: 3;
36
+ --list-gap: 0.5rem;
37
+ font-size: 0.875rem;
38
+ }
39
+
40
+ .kit-list[breakpoint]kit-list--size-md {
41
+ --list-height: 2.25rem;
42
+ --list-multiplier-y: 4;
43
+ --list-gap: 0.5rem;
44
+ font-size: 0.875rem;
45
+ }
46
+
47
+ .kit-list[breakpoint]kit-list--size-lg {
48
+ --list-height: 2.5rem;
49
+ --list-multiplier-y: 5;
50
+ --list-gap: 0.5rem;
51
+ font-size: 1rem;
52
+ }
53
+
54
+ .kit-list[breakpoint]kit-list--size-xl {
55
+ --list-height: 2.75rem;
56
+ --list-multiplier-y: 6;
57
+ --list-gap: 0.675rem;
58
+ font-size: 1.125rem;
59
+ }
60
+
61
+ /* density */
62
+ .kit-list[breakpoint]kit-list--density-default .kit-list-item {
63
+ height: calc(var(--list-height));
64
+ min-width: calc(var(--list-height));
65
+ --list-spacing-x: 0;
66
+ --list-spacing-y: calc(var(--kit-spacing) * var(--list-multiplier-y));
67
+ }
68
+
69
+ .kit-list[breakpoint]kit-list--density-compact .kit-list-item {
70
+ height: calc(var(--list-height) - 0.25rem);
71
+ min-width: calc(var(--list-height - 0.25rem));
72
+ --list-spacing-x: 0;
73
+ --list-spacing-y: calc(var(--list-spacing) * var(--list-multiplier-y) - 0.25rem);
74
+ }
75
+
76
+ .kit-list[breakpoint]kit-list--density-comfortable .kit-list-item {
77
+ height: calc(var(--list-height) + 0.25rem);
78
+ min-width: calc(var(--list-height + 0.25rem));
79
+ --list-spacing-x: 0;
80
+ --list-spacing-y: calc(var(--kit-spacing) * var(--list-multiplier-y) + 0.25rem);
81
+ }
82
+
83
+ /* variant */
84
+ .kit-list[breakpoint]kit-list--variant-outline .kit-list-item {
85
+ --list-item-color: var(--base, var(--list-background, var(--kit-neutral)));
86
+ background-color: transparent;
87
+ border: 1px solid currentColor;
88
+ }
89
+
90
+ .kit-list[breakpoint]kit-list--variant-text .kit-list-item {
91
+ --list-item-color: var(--base, var(--list-background, var(--kit-neutral)));
92
+ background-color: transparent;
93
+ border-color: transparent;
94
+ }
95
+
96
+ .kit-list[breakpoint]kit-list--variant-dash .kit-list-item {
97
+ --list-item-color: var(--base, var(--list-background, var(--kit-neutral)));
98
+ background-color: transparent;
99
+ border: 1px dashed currentColor;
100
+ }
101
+
102
+ .kit-list[breakpoint]kit-list--variant-link .kit-list-item {
103
+ --list-item-color: var(--base, var(--list-background, var(--kit-neutral)));
104
+ background-color: transparent;
105
+ border-color: transparent;
106
+ }
107
+
108
+ /* events */
109
+ .kit-list:not([class*='list--variant-']) .kit-list-item.kit-list-item--active {
110
+ background-color: color-mix(in oklab, var(--list-item-background) 90%, var(--kit-scrim));
111
+ border-color: color-mix(in oklab, var(--list-item-background) 90%, var(--kit-scrim));
112
+ }
113
+ .kit-list[class*='list--variant-'] .kit-list-item.kit-list-item--active {
114
+ background-color: color-mix(in oklab, currentColor 15%, transparent);
115
+ border-color: color-mix(in oklab, currentColor 15%, transparent);
116
+ }
117
+
118
+ .kit-list:not([class*='list--variant-']) .kit-list-item:not(div):hover {
119
+ background-color: color-mix(in oklab, var(--list-item-background) 85%, var(--kit-scrim));
120
+ border-color: color-mix(in oklab, var(--list-item-background) 85%, var(--kit-scrim));
121
+ }
122
+ .kit-list[class*='list--variant-'] .kit-list-item:not(div):hover {
123
+ background-color: color-mix(in oklab, currentColor 25%, transparent);
124
+ }
125
+
126
+ /* disabled */
127
+ .kit-list .kit-list-item.kit-list-item--disabled,
128
+ .kit-list .kit-list-item[disabled],
129
+ .kit-list.kit-list--disabled .kit-list-item {
130
+ pointer-events: none;
131
+ user-select: none;
132
+ cursor: default;
133
+ }
134
+ .kit-list:not([class*='list--variant-']) .kit-list-item.kit-list-item--disabled {
135
+ color: color-mix(in oklab, var(--list-item-color) 40%, transparent) !important;
136
+ background-color: color-mix(in oklab, var(--list-item-background) 70%, transparent) !important;
137
+ border-color: color-mix(in oklab, var(--list-item-background) 70%, transparent) !important;
138
+ }
139
+ .kit-list:not([class*='list--variant-']) .kit-list-item.kit-list-item--disabled i:before {
140
+ color: color-mix(in oklab, var(--list-item-color) 40%, transparent) !important;
141
+ }
142
+ .kit-list[class*='list--variant-'] .kit-list-item.kit-list-item--disabled,
143
+ .kit-list[class*='list--variant-'] .kit-list-item.kit-list-item--disabled i:before {
144
+ color: color-mix(in oklab, var(--list-item-background) 40%, transparent) !important;
145
+ }
146
+
147
+ /* list item */
148
+ .kit-list .kit-list-item {
149
+ --list-item-color: var(--on, var(--list-color, var(--kit-on-neutral)));
150
+ --list-item-background: var(--base, var(--list-background, var(--kit-neutral)));
151
+ --list-item-radius: var(--shape, var(--list-radius, var(--kit-radius-md)));
152
+
153
+ display: inline-flex;
154
+ padding-top: var(--list-spacing-x);
155
+ padding-bottom: var(--list-spacing-x);
156
+ padding-right: var(--list-spacing-y);
157
+ padding-left: var(--list-spacing-y);
158
+ align-items: center;
159
+ white-space: nowrap;
160
+ gap: var(--list-gap);
161
+
162
+ border-width: 1px;
163
+ border-style: solid;
164
+ border-radius: var(--list-item-radius);
165
+
166
+ /* theme */
167
+ color: var(--list-item-color);
168
+ background-color: var(--list-item-background);
169
+ border-color: var(--list-item-background);
170
+ }
171
+
172
+ .kit-list .kit-list-item:not(div) {
173
+ cursor: pointer;
174
+ }
175
+
176
+ .kit-list .kit-list-item > .kit-list-item-content {
177
+ display: flex;
178
+ }
179
+
180
+ .kit-list .kit-list-item.kit-list-item--append:not(.kit-list-item--prepend) {
181
+ display: grid;
182
+ grid-template-columns: auto 1fr;
183
+ }
184
+
185
+ .kit-list .kit-list-item.kit-list-item--prepend:not(.kit-list-item--append) {
186
+ display: grid;
187
+ grid-template-columns: 1fr auto;
188
+ }
189
+
190
+ .kit-list .kit-list-item.kit-list-item--prepend.kit-list-item--append {
191
+ display: grid;
192
+ grid-template-columns: auto 1fr auto;
193
+ }
@@ -0,0 +1,46 @@
1
+ <script lang="ts">
2
+ import { getAssets } from '../../internal/index.js';
3
+ import type { ListProps } from './types.js';
4
+
5
+ let {
6
+ children,
7
+ ref = $bindable(),
8
+ is = 'div',
9
+ dark,
10
+ light,
11
+ orientation = 'vertical',
12
+ background,
13
+ color,
14
+ rounded,
15
+ size = 'md',
16
+ density = 'default',
17
+ variant,
18
+ nav,
19
+ ...rest
20
+ }: ListProps = $props();
21
+
22
+ const assets = getAssets();
23
+ </script>
24
+
25
+ <svelte:element
26
+ this={is}
27
+ bind:this={ref}
28
+ {...rest}
29
+ class={[
30
+ 'kit-list',
31
+ light && 'light',
32
+ dark && 'dark',
33
+ orientation && assets.className('list', 'orientation', orientation),
34
+ size && assets.className('list', 'size', size),
35
+ variant && assets.className('list', 'variant', variant),
36
+ density && assets.className('list', 'density', density),
37
+ nav && 'kit-list--nav',
38
+ rest.class
39
+ ]}
40
+ role="listbox"
41
+ style:--base={assets.color(background)}
42
+ style:--on={assets.color(color)}
43
+ style:--shape={assets.shape(rounded)}
44
+ >
45
+ {@render children?.()}
46
+ </svelte:element>
@@ -0,0 +1,4 @@
1
+ import type { ListProps } from './types.js';
2
+ declare const List: import("svelte").Component<ListProps, {}, "ref">;
3
+ type List = ReturnType<typeof List>;
4
+ export default List;
@@ -0,0 +1,68 @@
1
+ <script lang="ts">
2
+ import { getAssets } from '../../../internal/index.js';
3
+ import type { ListItemProps } from '../types.js';
4
+
5
+ let {
6
+ children,
7
+ append,
8
+ prepend,
9
+ ref = $bindable(),
10
+ is = 'div',
11
+ dark,
12
+ light,
13
+ background,
14
+ color,
15
+ rounded,
16
+ disabled,
17
+ active,
18
+ href,
19
+ ...rest
20
+ }: ListItemProps = $props();
21
+
22
+ const assets = getAssets();
23
+
24
+ $effect(() => {
25
+ const refProps = { ...rest };
26
+ if (refProps?.onclick) is = 'button';
27
+ });
28
+ </script>
29
+
30
+ <svelte:element
31
+ this={href ? 'a' : is}
32
+ bind:this={ref}
33
+ {...rest}
34
+ href={href && !disabled ? href : undefined}
35
+ class={[
36
+ 'kit-list-item',
37
+ light && 'light',
38
+ dark && 'dark',
39
+ append && 'kit-list-item--append',
40
+ prepend && 'kit-list-item--prepend',
41
+ active && 'kit-list-item--active',
42
+ disabled && 'kit-list-item--disabled',
43
+ rest.class
44
+ ]}
45
+ role={is === 'button' ? 'listitem' : undefined}
46
+ tabindex={href && disabled ? -2 : 0}
47
+ aria-disabled={href ? disabled : undefined}
48
+ disabled={href ? undefined : disabled}
49
+ style:--base={assets.color(background)}
50
+ style:--on={assets.color(color)}
51
+ style:--shape={assets.shape(rounded)}
52
+ >
53
+ {#if append}
54
+ <div class="kit-list-item-content--append">
55
+ {@render append?.()}
56
+ </div>
57
+ {/if}
58
+
59
+ <div class="kit-list-item-content">
60
+ {@render children?.()}
61
+ </div>
62
+
63
+ {#if prepend}
64
+ <div class="kit-list-item-content--prepend">
65
+ {@render prepend?.()}
66
+ </div>
67
+ {/if}
68
+ </svelte:element>
@@ -0,0 +1,4 @@
1
+ import type { ListItemProps } from '../types.js';
2
+ declare const ListItem: import("svelte").Component<ListItemProps, {}, "ref">;
3
+ type ListItem = ReturnType<typeof ListItem>;
4
+ export default ListItem;
@@ -0,0 +1,36 @@
1
+ import type { Component } from '../../internal/types.js';
2
+ import type { Snippet } from 'svelte';
3
+ type ListOrientation = 'vertical' | 'horizontal';
4
+ type ListSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
5
+ type ListDensity = 'compact' | 'comfortable' | 'default';
6
+ export interface ListProps extends Component {
7
+ ref?: HTMLElement | null;
8
+ is?: 'div' | 'nav';
9
+ dark?: boolean;
10
+ light?: boolean;
11
+ size?: ListSize | {
12
+ [key: string]: ListSize;
13
+ };
14
+ variant?: 'outline' | 'text' | 'dash' | 'link';
15
+ density?: ListDensity | {
16
+ [key: string]: ListDensity;
17
+ };
18
+ nav?: boolean;
19
+ orientation?: ListOrientation | {
20
+ [key: string]: ListOrientation;
21
+ };
22
+ }
23
+ export interface ListItemProps extends Component {
24
+ ref?: HTMLElement | null;
25
+ is?: 'div' | 'a' | 'button';
26
+ href?: string;
27
+ dark?: boolean;
28
+ light?: boolean;
29
+ append?: Snippet;
30
+ prepend?: Snippet;
31
+ color?: string;
32
+ background?: string;
33
+ active?: boolean;
34
+ disabled?: boolean;
35
+ }
36
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -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,4 @@
1
+ import type { ModalProps } from './types.js';
2
+ declare const Modal: import("svelte").Component<ModalProps, {}, "ref" | "open">;
3
+ type Modal = ReturnType<typeof Modal>;
4
+ export default Modal;
@@ -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,22 @@
1
+ .kit-popover-content {
2
+ --popover-color: var(--on, var(--kit-on-neutral));
3
+ --popover-background: var(--base, var(--kit-neutral));
4
+ --popover-radius: var(--shape, var(--kit-radius-md));
5
+
6
+ inset: 0px auto auto 0px;
7
+ margin: 0px;
8
+ position: fixed;
9
+ z-index: 9999;
10
+ display: inline-block;
11
+ width: auto;
12
+ opacity: 1;
13
+ transition-property: opacity, transform;
14
+ transition:
15
+ color 0.5s,
16
+ background-color 0.5s;
17
+
18
+ /* theme */
19
+ background-color: var(--popover-background);
20
+ color: var(--popover-color);
21
+ border-radius: var(--popover-radius);
22
+ }