lapikit 0.0.0-insiders.dcdfb82 → 0.0.0-insiders.dd024f5

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 (210) hide show
  1. package/LICENSE +21 -0
  2. package/bin/configuration.js +304 -0
  3. package/bin/helper.js +64 -32
  4. package/bin/index.js +41 -0
  5. package/bin/lapikit.js +42 -10
  6. package/bin/legacy.js +34 -0
  7. package/bin/modules/adapter.js +5 -5
  8. package/bin/modules/plugin.js +223 -0
  9. package/bin/presets.js +26 -0
  10. package/bin/prompts.js +100 -0
  11. package/dist/actions/index.d.ts +1 -0
  12. package/dist/actions/index.js +1 -0
  13. package/dist/assets/icons/arrow-down.svelte +12 -0
  14. package/dist/assets/icons/arrow-down.svelte.d.ts +18 -0
  15. package/dist/assets/icons/arrow-up.svelte +12 -0
  16. package/dist/assets/icons/arrow-up.svelte.d.ts +18 -0
  17. package/dist/assets/icons/close-fill.svelte +12 -0
  18. package/dist/assets/icons/close-fill.svelte.d.ts +18 -0
  19. package/dist/assets/icons/loading-fill.svelte +31 -0
  20. package/dist/assets/icons/loading-fill.svelte.d.ts +18 -0
  21. package/dist/colors.css +0 -0
  22. package/dist/components/accordion/accordion.css +113 -0
  23. package/dist/components/accordion/accordion.svelte +155 -0
  24. package/dist/components/accordion/accordion.svelte.d.ts +4 -0
  25. package/dist/components/accordion/accordion.svelte.js +24 -0
  26. package/dist/components/accordion/modules/accordion-item.svelte +94 -0
  27. package/dist/components/accordion/modules/accordion-item.svelte.d.ts +4 -0
  28. package/dist/components/accordion/types.d.ts +33 -0
  29. package/dist/components/accordion/types.js +1 -0
  30. package/dist/components/alert/alert.css +137 -0
  31. package/dist/components/alert/alert.svelte +211 -0
  32. package/dist/components/alert/alert.svelte.d.ts +4 -0
  33. package/dist/components/alert/types.d.ts +28 -0
  34. package/dist/components/alert/types.js +1 -0
  35. package/dist/components/app/app.css +16 -0
  36. package/dist/components/app/app.svelte +66 -0
  37. package/dist/components/app/app.svelte.d.ts +7 -0
  38. package/dist/components/app/types.d.ts +4 -0
  39. package/dist/components/app/types.js +1 -0
  40. package/dist/components/appbar/appbar.css +48 -0
  41. package/dist/components/appbar/appbar.svelte +85 -0
  42. package/dist/components/appbar/appbar.svelte.d.ts +4 -0
  43. package/dist/components/appbar/types.d.ts +15 -0
  44. package/dist/components/appbar/types.js +1 -0
  45. package/dist/components/aspect-ratio/aspect-ratio.css +19 -0
  46. package/dist/components/aspect-ratio/aspect-ratio.svelte +66 -0
  47. package/dist/components/aspect-ratio/aspect-ratio.svelte.d.ts +4 -0
  48. package/dist/components/aspect-ratio/types.d.ts +5 -0
  49. package/dist/components/aspect-ratio/types.js +1 -0
  50. package/dist/components/avatar/avatar.css +109 -0
  51. package/dist/components/avatar/avatar.svelte +160 -0
  52. package/dist/components/avatar/avatar.svelte.d.ts +4 -0
  53. package/dist/components/avatar/types.d.ts +22 -0
  54. package/dist/components/avatar/types.js +1 -0
  55. package/dist/components/button/button.css +247 -0
  56. package/dist/components/button/button.svelte +332 -0
  57. package/dist/components/button/button.svelte.d.ts +4 -0
  58. package/dist/components/button/types.d.ts +29 -0
  59. package/dist/components/button/types.js +1 -0
  60. package/dist/components/card/card.css +115 -0
  61. package/dist/components/card/card.svelte +171 -0
  62. package/dist/components/card/card.svelte.d.ts +4 -0
  63. package/dist/components/card/types.d.ts +18 -0
  64. package/dist/components/card/types.js +1 -0
  65. package/dist/components/chip/chip.css +231 -0
  66. package/dist/components/chip/chip.svelte +342 -0
  67. package/dist/components/chip/chip.svelte.d.ts +4 -0
  68. package/dist/components/chip/types.d.ts +32 -0
  69. package/dist/components/chip/types.js +1 -0
  70. package/dist/components/dialog/dialog.css +136 -0
  71. package/dist/components/dialog/dialog.svelte +211 -0
  72. package/dist/components/dialog/dialog.svelte.d.ts +4 -0
  73. package/dist/components/dialog/types.d.ts +24 -0
  74. package/dist/components/dialog/types.js +1 -0
  75. package/dist/components/dropdown/dropdown.css +22 -0
  76. package/dist/components/dropdown/dropdown.svelte +140 -0
  77. package/dist/components/dropdown/dropdown.svelte.d.ts +4 -0
  78. package/dist/components/dropdown/dropdown.svelte.js +148 -0
  79. package/dist/components/dropdown/types.d.ts +26 -0
  80. package/dist/components/dropdown/types.js +1 -0
  81. package/dist/components/icon/icon.css +81 -0
  82. package/dist/components/icon/icon.svelte +138 -0
  83. package/dist/components/icon/icon.svelte.d.ts +4 -0
  84. package/dist/components/icon/types.d.ts +16 -0
  85. package/dist/components/icon/types.js +1 -0
  86. package/dist/components/index.d.ts +22 -0
  87. package/dist/components/index.js +23 -0
  88. package/dist/components/list/list.css +221 -0
  89. package/dist/components/list/list.svelte +243 -0
  90. package/dist/components/list/list.svelte.d.ts +4 -0
  91. package/dist/components/list/modules/list-item.svelte +275 -0
  92. package/dist/components/list/modules/list-item.svelte.d.ts +4 -0
  93. package/dist/components/list/types.d.ts +33 -0
  94. package/dist/components/list/types.js +1 -0
  95. package/dist/components/modal/modal.css +145 -0
  96. package/dist/components/modal/modal.svelte +248 -0
  97. package/dist/components/modal/modal.svelte.d.ts +4 -0
  98. package/dist/components/modal/types.d.ts +26 -0
  99. package/dist/components/modal/types.js +1 -0
  100. package/dist/components/popover/popover.css +22 -0
  101. package/dist/components/popover/popover.svelte +97 -0
  102. package/dist/components/popover/popover.svelte.d.ts +4 -0
  103. package/dist/components/popover/popover.svelte.js +134 -0
  104. package/dist/components/popover/types.d.ts +20 -0
  105. package/dist/components/popover/types.js +1 -0
  106. package/dist/components/separator/separator.css +46 -0
  107. package/dist/components/separator/separator.svelte +85 -0
  108. package/dist/components/separator/separator.svelte.d.ts +4 -0
  109. package/dist/components/separator/types.d.ts +11 -0
  110. package/dist/components/separator/types.js +1 -0
  111. package/dist/components/spacer/spacer.css +3 -0
  112. package/dist/components/spacer/spacer.svelte +12 -0
  113. package/dist/components/spacer/spacer.svelte.d.ts +4 -0
  114. package/dist/components/spacer/types.d.ts +4 -0
  115. package/dist/components/spacer/types.js +1 -0
  116. package/dist/components/textfield/textfield.css +305 -0
  117. package/dist/components/textfield/textfield.svelte +463 -0
  118. package/dist/components/textfield/textfield.svelte.d.ts +4 -0
  119. package/dist/components/textfield/types.d.ts +37 -0
  120. package/dist/components/textfield/types.js +1 -0
  121. package/dist/components/toolbar/toolbar.css +129 -0
  122. package/dist/components/toolbar/toolbar.svelte +182 -0
  123. package/dist/components/toolbar/toolbar.svelte.d.ts +4 -0
  124. package/dist/components/toolbar/types.d.ts +27 -0
  125. package/dist/components/toolbar/types.js +1 -0
  126. package/dist/components/tooltip/tooltip.css +124 -0
  127. package/dist/components/tooltip/tooltip.svelte +240 -0
  128. package/dist/components/tooltip/tooltip.svelte.d.ts +4 -0
  129. package/dist/components/tooltip/tooltip.svelte.js +131 -0
  130. package/dist/components/tooltip/types.d.ts +23 -0
  131. package/dist/components/tooltip/types.js +1 -0
  132. package/dist/index.d.ts +27 -1
  133. package/dist/index.js +27 -3
  134. package/dist/internal/assets.svelte.d.ts +8 -0
  135. package/dist/internal/assets.svelte.js +54 -0
  136. package/dist/internal/clickOutside.d.ts +9 -0
  137. package/dist/internal/clickOutside.js +34 -0
  138. package/dist/internal/config/presets.d.ts +136 -0
  139. package/dist/internal/config/presets.js +121 -0
  140. package/dist/internal/config/variables.d.ts +20 -0
  141. package/dist/internal/config/variables.js +20 -0
  142. package/dist/internal/core/formatter/component.d.ts +5 -0
  143. package/dist/internal/core/formatter/component.js +63 -0
  144. package/dist/internal/core/formatter/index.d.ts +6 -0
  145. package/dist/internal/core/formatter/index.js +30 -0
  146. package/dist/internal/core/formatter/styles.d.ts +4 -0
  147. package/dist/internal/core/formatter/styles.js +16 -0
  148. package/dist/internal/core/formatter/theme.d.ts +5 -0
  149. package/dist/internal/core/formatter/theme.js +20 -0
  150. package/dist/internal/core/formatter/typography.d.ts +5 -0
  151. package/dist/internal/core/formatter/typography.js +12 -0
  152. package/dist/internal/deepMerge.d.ts +44 -0
  153. package/dist/internal/deepMerge.js +80 -0
  154. package/dist/internal/helpers/parser.d.ts +10 -0
  155. package/dist/internal/helpers/parser.js +92 -0
  156. package/dist/internal/index.d.ts +2 -0
  157. package/dist/internal/index.js +2 -0
  158. package/dist/internal/plugins/vite.d.ts +8 -0
  159. package/dist/internal/plugins/vite.js +25 -0
  160. package/dist/internal/ripple.d.ts +12 -0
  161. package/dist/internal/ripple.js +93 -0
  162. package/dist/internal/scroll.d.ts +1 -0
  163. package/dist/internal/scroll.js +6 -0
  164. package/dist/internal/types/configuration.d.ts +40 -0
  165. package/dist/internal/types/configuration.js +1 -0
  166. package/dist/internal/types/index.d.ts +1 -0
  167. package/dist/internal/types/index.js +1 -0
  168. package/dist/internal/types.d.ts +13 -0
  169. package/dist/internal/unit.d.ts +1 -0
  170. package/dist/internal/unit.js +11 -0
  171. package/dist/labs/index.d.ts +4 -0
  172. package/dist/labs/index.js +5 -0
  173. package/dist/labs/my-component-style-global.svelte +6 -0
  174. package/dist/labs/my-component-style-global.svelte.d.ts +18 -0
  175. package/dist/labs/my-component-style-import.svelte +15 -0
  176. package/dist/labs/my-component-style-import.svelte.d.ts +18 -0
  177. package/dist/labs/my-component-style-mixed.svelte +23 -0
  178. package/dist/labs/my-component-style-mixed.svelte.d.ts +18 -0
  179. package/dist/labs/my-component.svelte +16 -0
  180. package/dist/labs/my-component.svelte.d.ts +18 -0
  181. package/dist/labs/style-mixed.css +7 -0
  182. package/dist/labs/style.css +7 -0
  183. package/dist/labs.css +25 -0
  184. package/dist/plugin/css.d.ts +1 -0
  185. package/dist/plugin/css.js +73 -0
  186. package/dist/plugin/preset-v2.d.ts +108 -0
  187. package/dist/plugin/preset-v2.js +126 -0
  188. package/dist/plugin/vitejs.d.ts +5 -1
  189. package/dist/plugin/vitejs.js +32 -3
  190. package/dist/preset.js +16 -4
  191. package/dist/stores/breakpoints.d.ts +6 -0
  192. package/dist/stores/breakpoints.js +14 -0
  193. package/dist/stores/components.d.ts +8 -0
  194. package/dist/stores/components.js +26 -0
  195. package/dist/stores/devices.d.ts +6 -0
  196. package/dist/stores/devices.js +9 -0
  197. package/dist/stores/index.d.ts +4 -0
  198. package/dist/stores/index.js +4 -0
  199. package/dist/stores/themes.d.ts +8 -0
  200. package/dist/stores/themes.js +34 -0
  201. package/dist/style/animation.css +62 -0
  202. package/dist/style/css.js +6 -3
  203. package/dist/style/normalize.css +2 -0
  204. package/dist/style/parser/color.js +15 -4
  205. package/dist/style/parser/device.js +31 -19
  206. package/dist/style/variable.css +12 -0
  207. package/dist/utils/convert.d.ts +1 -0
  208. package/dist/utils/convert.js +17 -0
  209. package/dist/utils/x11.d.ts +1 -1
  210. package/package.json +29 -4
@@ -0,0 +1,211 @@
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>
68
+
69
+ <style>.kit-dialog {
70
+ border: 0;
71
+ padding: 0;
72
+ margin: auto;
73
+ width: 100%;
74
+ max-width: none;
75
+ background-color: transparent;
76
+ color: inherit;
77
+ }
78
+
79
+ .kit-dialog[open] {
80
+ pointer-events: auto;
81
+ visibility: visible;
82
+ opacity: 1;
83
+ }
84
+
85
+ .kit-dialog::backdrop {
86
+ background-color: color-mix(in oklab, var(--kit-shadow) 30%, transparent);
87
+ animation: fade 0.2s ease-out;
88
+ }
89
+
90
+ .kit-dialog[open]::backdrop {
91
+ animation: fade 0.2s ease-out;
92
+ }
93
+
94
+ .kit-dialog .kit-dialog-container {
95
+ --dialog-color: var(--on, var(--kit-on-surface));
96
+ --dialog-background: var(--base, var(--kit-surface));
97
+ --dialog-radius: var(--shape, var(--kit-radius-md));
98
+
99
+ border-radius: var(--dialog-radius);
100
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
101
+ transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
102
+ transition-duration: 0.2s;
103
+ padding-top: var(--dialog-spacing-x);
104
+ padding-bottom: var(--dialog-spacing-x);
105
+ padding-right: var(--dialog-spacing-y);
106
+ padding-left: var(--dialog-spacing-y);
107
+
108
+ /* theme */
109
+ color: var(--dialog-color);
110
+ background-color: var(--dialog-background);
111
+ border-color: var(--dialog-background);
112
+ }
113
+
114
+ .kit-dialog .close-dialog {
115
+ opacity: 0;
116
+ position: fixed;
117
+ top: 0;
118
+ z-index: -1;
119
+ }
120
+
121
+ .kit-dialog[breakpoint]kit-dialog--position-bottom {
122
+ margin-bottom: 0;
123
+ margin-top: auto;
124
+ }
125
+
126
+ .kit-dialog[breakpoint]kit-dialog--position-top {
127
+ margin-top: 0;
128
+ margin-bottom: auto;
129
+ }
130
+
131
+ .kit-dialog[breakpoint]kit-dialog--position-center {
132
+ /* margin: auto; */
133
+ margin-top: auto;
134
+ margin-bottom: auto;
135
+ }
136
+
137
+ .kit-dialog[breakpoint]kit-dialog--size-xs {
138
+ max-width: var(--kit-dialog-size-xs);
139
+ }
140
+
141
+ .kit-dialog[breakpoint]kit-dialog--size-sm {
142
+ max-width: var(--kit-dialog-size-sm);
143
+ height: fit-content;
144
+ }
145
+
146
+ .kit-dialog[breakpoint]kit-dialog--size-md {
147
+ max-width: var(--kit-dialog-size-md);
148
+ height: fit-content;
149
+ }
150
+
151
+ .kit-dialog[breakpoint]kit-dialog--size-lg {
152
+ max-width: var(--kit-dialog-size-lg);
153
+ height: fit-content;
154
+ }
155
+
156
+ .kit-dialog[breakpoint]kit-dialog--size-xl {
157
+ max-width: var(--kit-dialog-size-xl);
158
+ height: fit-content;
159
+ }
160
+
161
+ .kit-dialog[breakpoint]kit-dialog--size-xs .kit-dialog-container {
162
+ max-height: calc(100% - 3rem);
163
+ margin: 0 auto;
164
+ }
165
+
166
+ .kit-dialog[breakpoint]kit-dialog--size-sm .kit-dialog-container {
167
+ max-height: calc(100% - 3rem);
168
+ margin: 0 auto;
169
+ }
170
+
171
+ .kit-dialog[breakpoint]kit-dialog--size-md .kit-dialog-container {
172
+ max-height: calc(100% - 3rem);
173
+ margin: 0 auto;
174
+ }
175
+
176
+ .kit-dialog[breakpoint]kit-dialog--size-lg .kit-dialog-container {
177
+ max-height: calc(100% - 3rem);
178
+ margin: 0 auto;
179
+ }
180
+
181
+ .kit-dialog[breakpoint]kit-dialog--size-xl .kit-dialog-container {
182
+ max-height: calc(100% - 3rem);
183
+ margin: 0 auto;
184
+ }
185
+
186
+ /* density */
187
+
188
+ .kit-dialog .kit-dialog-container[breakpoint]kit-dialog-container--density-default {
189
+ --dialog-spacing-x: 0.5rem;
190
+ --dialog-spacing-y: 0.5rem;
191
+ }
192
+
193
+ .kit-dialog .kit-dialog-container[breakpoint]kit-dialog-container--density-compact {
194
+ --dialog-spacing-x: 0.25rem;
195
+ --dialog-spacing-y: 0.25rem;
196
+ }
197
+
198
+ .kit-dialog .kit-dialog-container[breakpoint]kit-dialog-container--density-comfortable {
199
+ --dialog-spacing-x: 0.75rem;
200
+ --dialog-spacing-y: 0.75rem;
201
+ }
202
+
203
+ @keyframes fade {
204
+ from {
205
+ opacity: 0;
206
+ }
207
+ to {
208
+ opacity: 1;
209
+ }
210
+ }
211
+ </style>
@@ -0,0 +1,4 @@
1
+ import type { DialogProps } from './types.js';
2
+ declare const Dialog: import("svelte").Component<DialogProps, {}, "ref" | "open">;
3
+ type Dialog = ReturnType<typeof Dialog>;
4
+ export default 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 {};
@@ -0,0 +1,22 @@
1
+ .kit-dropdown-content {
2
+ --dropdown-color: var(--on, var(--kit-on-surface));
3
+ --dropdown-background: var(--base, var(--kit-surface));
4
+ --dropdown-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(--dropdown-background);
20
+ color: var(--dropdown-color);
21
+ border-radius: var(--dropdown-radius);
22
+ }
@@ -0,0 +1,140 @@
1
+ <script lang="ts">
2
+ import { getAssets } from '../../internal/assets.svelte.js';
3
+ import { clickOutside } from '../../internal/clickOutside.js';
4
+ import { getPositions } from './dropdown.svelte.js';
5
+ import type { DropdownProps, ModelDropdownProps } from './types.js';
6
+
7
+ let {
8
+ children,
9
+ activator,
10
+ dark,
11
+ light,
12
+ rounded,
13
+ position,
14
+ closeOnClick,
15
+ openOnHover,
16
+ color,
17
+ background,
18
+ ...rest
19
+ }: DropdownProps = $props();
20
+
21
+ const positionAxis = getPositions();
22
+ const assets = getAssets();
23
+
24
+ let ref: HTMLElement | null = $state(null);
25
+ let refActivator: HTMLElement | PointerEvent | null = $state(null);
26
+ let open = $state(false);
27
+ let axis = $state({ x: 0, y: 0 });
28
+ let innerHeight = $state(0);
29
+ let innerWidth = $state(0);
30
+ let scrollX = $state(0);
31
+ let scrollY = $state(0);
32
+ let timeoutId: ReturnType<typeof setTimeout> | null = $state(null);
33
+
34
+ axis = positionAxis?.values;
35
+
36
+ let model: ModelDropdownProps = {
37
+ get open() {
38
+ return open;
39
+ },
40
+ close: () => (open = false),
41
+ toggle: (element) => handleToggle(element)
42
+ };
43
+
44
+ const handleToggle = (element: HTMLElement | PointerEvent | null) => {
45
+ if (element === null) return;
46
+ refActivator = element;
47
+ open = !open;
48
+ };
49
+
50
+ const handleClose = () => {
51
+ if (closeOnClick && open) open = false;
52
+ };
53
+
54
+ const handleMouseEvent = (
55
+ state: 'open' | 'close',
56
+ element: HTMLElement | PointerEvent | null
57
+ ) => {
58
+ console.log();
59
+ if (openOnHover && state === 'open') {
60
+ if (timeoutId) {
61
+ clearTimeout(timeoutId);
62
+ timeoutId = null;
63
+ }
64
+ refActivator = element;
65
+ open = true;
66
+ }
67
+
68
+ if (openOnHover && state === 'close') {
69
+ timeoutId = setTimeout(() => {
70
+ open = false;
71
+ timeoutId = null;
72
+ }, 150);
73
+ }
74
+ };
75
+
76
+ $effect(() => {
77
+ if (
78
+ open &&
79
+ ref &&
80
+ refActivator &&
81
+ (scrollX > 0 || scrollY > 0 || innerHeight > 0 || innerWidth > 0)
82
+ ) {
83
+ positionAxis.update(refActivator, ref, position);
84
+ }
85
+ });
86
+
87
+ $effect(() => {
88
+ if (scrollX || scrollY) open = false;
89
+ });
90
+ </script>
91
+
92
+ <svelte:window bind:innerHeight bind:innerWidth bind:scrollX bind:scrollY />
93
+
94
+ {@render activator?.(model, (state, element) => handleMouseEvent(state, element))}
95
+
96
+ {#if open}
97
+ <div
98
+ bind:this={ref}
99
+ {...rest}
100
+ role="menu"
101
+ class={['kit-dropdown-content', light && 'light', dark && 'dark', rest.class]}
102
+ style={`transform: translate(${axis.x}px, ${axis.y}px);`}
103
+ onmouseover={() => handleMouseEvent('open', refActivator)}
104
+ onmouseleave={() => handleMouseEvent('close', refActivator)}
105
+ onclick={(e) => {
106
+ e.stopPropagation();
107
+ handleClose();
108
+ }}
109
+ style:--base={assets.color(background)}
110
+ style:--on={assets.color(color)}
111
+ style:--shape={assets.shape(rounded)}
112
+ use:clickOutside={{ exclude: [ref, refActivator], onClose: () => (open = false) }}
113
+ >
114
+ {@render children?.()}
115
+ </div>
116
+ {/if}
117
+
118
+ <style>.kit-dropdown-content {
119
+ --dropdown-color: var(--on, var(--kit-on-surface));
120
+ --dropdown-background: var(--base, var(--kit-surface));
121
+ --dropdown-radius: var(--shape, var(--kit-radius-md));
122
+
123
+ inset: 0px auto auto 0px;
124
+ margin: 0px;
125
+ position: fixed;
126
+ z-index: 9999;
127
+ display: inline-block;
128
+ width: auto;
129
+ opacity: 1;
130
+ transition-property: opacity, transform;
131
+ /* transition:
132
+ color 0.5s,
133
+ background-color 0.5s; */
134
+
135
+ /* theme */
136
+ background-color: var(--dropdown-background);
137
+ color: var(--dropdown-color);
138
+ border-radius: var(--dropdown-radius);
139
+ }
140
+ </style>
@@ -0,0 +1,4 @@
1
+ import type { DropdownProps } from './types.js';
2
+ declare const Dropdown: import("svelte").Component<DropdownProps, {}, "">;
3
+ type Dropdown = ReturnType<typeof Dropdown>;
4
+ export default Dropdown;
@@ -0,0 +1,148 @@
1
+ import { innerWidth, innerHeight } from 'svelte/reactivity/window';
2
+ export function getPositions() {
3
+ // state
4
+ const axis = $state({
5
+ x: 0,
6
+ y: 0,
7
+ location: null
8
+ });
9
+ return {
10
+ get values() {
11
+ return axis;
12
+ },
13
+ update(activator, element, location, centered, avoidCollisions) {
14
+ if (!activator || !element)
15
+ return;
16
+ const elementRect = element.getBoundingClientRect();
17
+ if (!(activator instanceof HTMLElement)) {
18
+ if (activator.clientX + elementRect.width > innerWidth.current) {
19
+ axis.x = activator.clientX - elementRect.width;
20
+ }
21
+ else {
22
+ axis.x = activator.clientX;
23
+ }
24
+ if (activator.clientY + elementRect.height > innerHeight.current) {
25
+ axis.y = activator.clientY - elementRect.height;
26
+ }
27
+ else {
28
+ axis.y = activator.clientY;
29
+ }
30
+ }
31
+ else if (activator instanceof HTMLElement) {
32
+ const activatorRect = activator.getBoundingClientRect();
33
+ const spacing = 0;
34
+ const _activator = activatorRect.y + activatorRect.height;
35
+ const _element = elementRect.height + spacing;
36
+ if (location === 'top' || location === 'bottom') {
37
+ if (avoidCollisions) {
38
+ if (location === 'top') {
39
+ if (activatorRect.y - _element < 0) {
40
+ axis.y = activatorRect.bottom + spacing;
41
+ axis.location = 'bottom';
42
+ }
43
+ else {
44
+ axis.y = activatorRect.top - _element;
45
+ axis.location = 'top';
46
+ }
47
+ }
48
+ else {
49
+ if (_activator + _element > innerHeight.current) {
50
+ axis.y = activatorRect.top - _element;
51
+ axis.location = 'top';
52
+ }
53
+ else {
54
+ axis.y = activatorRect.bottom + spacing;
55
+ axis.location = 'bottom';
56
+ }
57
+ }
58
+ }
59
+ else {
60
+ if (location === 'top') {
61
+ axis.y = activatorRect.top - _element;
62
+ axis.location = 'top';
63
+ }
64
+ else {
65
+ axis.y = activatorRect.bottom + spacing;
66
+ axis.location = 'bottom';
67
+ }
68
+ }
69
+ if (centered &&
70
+ activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
71
+ activatorRect.left + elementRect.width < innerWidth.current) {
72
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
73
+ }
74
+ else if (activatorRect.left + elementRect.width > innerWidth.current) {
75
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
76
+ }
77
+ else {
78
+ axis.x = activatorRect.left;
79
+ }
80
+ }
81
+ else if (location === 'left' || location === 'right') {
82
+ if (avoidCollisions) {
83
+ if (location === 'left' && !(activatorRect.left - elementRect.width < 0)) {
84
+ axis.x = activatorRect.left - (elementRect.width + spacing);
85
+ axis.location = 'left';
86
+ }
87
+ else {
88
+ if (activatorRect.left + activatorRect.width + elementRect.width + spacing >
89
+ innerWidth.current) {
90
+ axis.x = activatorRect.left - (elementRect.width + spacing);
91
+ axis.location = 'left';
92
+ }
93
+ else {
94
+ axis.x = activatorRect.left + activatorRect.width + spacing;
95
+ axis.location = 'right';
96
+ }
97
+ }
98
+ }
99
+ else {
100
+ if (location === 'left') {
101
+ axis.x = activatorRect.left - (elementRect.width + spacing);
102
+ axis.location = 'left';
103
+ }
104
+ else {
105
+ axis.x = activatorRect.left + activatorRect.width + spacing;
106
+ axis.location = 'right';
107
+ }
108
+ }
109
+ if (centered &&
110
+ activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
111
+ activatorRect.top + elementRect.height < innerHeight.current) {
112
+ axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
113
+ }
114
+ else if (activatorRect.y + elementRect.height > innerHeight.current) {
115
+ axis.y = activatorRect.y - elementRect.height + activatorRect.height;
116
+ }
117
+ else {
118
+ axis.y = activatorRect.y;
119
+ }
120
+ }
121
+ else {
122
+ if (centered &&
123
+ activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
124
+ activatorRect.left + elementRect.width < innerWidth.current) {
125
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
126
+ }
127
+ else if (activatorRect.left + elementRect.width > innerWidth.current) {
128
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
129
+ }
130
+ else {
131
+ axis.x = activatorRect.left;
132
+ }
133
+ if (centered &&
134
+ activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
135
+ activatorRect.top + elementRect.height < innerHeight.current) {
136
+ axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
137
+ }
138
+ else if (activatorRect.bottom + elementRect.height > innerHeight.current) {
139
+ axis.y = activatorRect.top - elementRect.height;
140
+ }
141
+ else {
142
+ axis.y = activatorRect.bottom;
143
+ }
144
+ }
145
+ }
146
+ }
147
+ };
148
+ }
@@ -0,0 +1,26 @@
1
+ import type { Component } from '../../internal/types.js';
2
+ import type { Snippet } from 'svelte';
3
+ export type PositionElement = {
4
+ x: number;
5
+ y: number;
6
+ location: string | null;
7
+ };
8
+ export interface DropdownProps extends Component {
9
+ dark?: boolean;
10
+ light?: boolean;
11
+ rounded?: string;
12
+ position?: 'top' | 'bottom' | 'left' | 'right';
13
+ openOnHover?: boolean;
14
+ closeOnClick?: boolean;
15
+ color?: string;
16
+ background?: string;
17
+ activator?: Snippet<[
18
+ ModelDropdownProps,
19
+ (state: 'open' | 'close', element: HTMLElement | PointerEvent | null) => void
20
+ ]>;
21
+ }
22
+ export type ModelDropdownProps = {
23
+ open: boolean;
24
+ close: () => void;
25
+ toggle: (element: HTMLElement | PointerEvent | null) => void;
26
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,81 @@
1
+ .kit-icon {
2
+ --icon-color: var(--base, var(--base-parent, var(--kit-on-neutral)));
3
+
4
+ display: inline-flex;
5
+ align-items: center;
6
+ justify-content: center;
7
+ /* transition: color 0.5s; */
8
+ text-indent: 0;
9
+ font-size: calc(
10
+ var(--icon-multiplier-parent-size, var(--icon-multiplier-size)) * var(--prism-spacing)
11
+ );
12
+ }
13
+
14
+ .kit-icon:before {
15
+ color: var(--icon-color);
16
+ }
17
+
18
+ .kit-icon svg {
19
+ color: var(--icon-color);
20
+ }
21
+
22
+ .kit-icon svg,
23
+ .kit-icon img {
24
+ width: calc(
25
+ var(--icon-multiplier-parent-size, var(--icon-multiplier-size)) * var(--prism-spacing)
26
+ );
27
+ height: calc(
28
+ var(--icon-multiplier-parent-size, var(--icon-multiplier-size)) * var(--prism-spacing)
29
+ );
30
+ }
31
+
32
+ /* size */
33
+ .kit-icon[breakpoint]kit-icon--size-xs {
34
+ --icon-multiplier-size: 7;
35
+ }
36
+
37
+ .kit-icon[breakpoint]kit-icon--size-sm {
38
+ --icon-multiplier-size: 8;
39
+ }
40
+
41
+ .kit-icon[breakpoint]kit-icon--size-md {
42
+ --icon-multiplier-size: 9;
43
+ }
44
+
45
+ .kit-icon[breakpoint]kit-icon--size-lg {
46
+ --icon-multiplier-size: 10;
47
+ }
48
+
49
+ .kit-icon[breakpoint]kit-icon--size-xl {
50
+ --icon-multiplier-size: 11;
51
+ }
52
+
53
+ /* state */
54
+ .kit-icon.kit-icon--info {
55
+ --base: var(--kit-info);
56
+ }
57
+ .kit-icon.kit-icon--success {
58
+ --base: var(--kit-success);
59
+ }
60
+ .kit-icon.kit-icon--warning {
61
+ --base: var(--kit-warning);
62
+ }
63
+ .kit-icon.kit-icon--error {
64
+ --base: var(--kit-error);
65
+ }
66
+
67
+ /* disabled */
68
+ .kit-icon.kit-icon--disabled {
69
+ -webkit-user-select: none;
70
+ user-select: none;
71
+ pointer-events: none;
72
+ }
73
+
74
+ .kit-icon.kit-icon--disabled img {
75
+ opacity: 0.38;
76
+ }
77
+
78
+ .kit-icon.kit-icon--disabled svg,
79
+ .kit-icon.kit-icon--disabled:before {
80
+ color: color-mix(in oklab, var(--icon-color) 40%, transparent) !important;
81
+ }