ui-svelte 0.2.12 → 0.2.13
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/README.md +2 -2
- package/dist/charts/ArcChart.svelte +0 -1
- package/dist/control/Fab.svelte +103 -0
- package/dist/control/Fab.svelte.d.ts +25 -0
- package/dist/control/Record.svelte +0 -3
- package/dist/control/ToggleTheme.svelte +1 -1
- package/dist/control/Video.svelte +2 -0
- package/dist/control/css/btn.css +17 -17
- package/dist/control/css/fab.css +84 -0
- package/dist/control/css/media.css +7 -7
- package/dist/control/css/toggle-group.css +1 -17
- package/dist/css/decorations.css +348 -189
- package/dist/css/utilities.css +0 -4
- package/dist/display/Accordion.svelte +3 -3
- package/dist/display/Accordion.svelte.d.ts +1 -1
- package/dist/display/Card.svelte +3 -3
- package/dist/display/Card.svelte.d.ts +1 -1
- package/dist/display/Code.svelte +1 -1
- package/dist/display/Collapsible.svelte +3 -3
- package/dist/display/Collapsible.svelte.d.ts +1 -1
- package/dist/display/Countdown.svelte +169 -0
- package/dist/display/Countdown.svelte.d.ts +21 -0
- package/dist/display/Item.svelte +12 -0
- package/dist/display/Item.svelte.d.ts +2 -0
- package/dist/display/Marquee.svelte +0 -2
- package/dist/display/Section.svelte +3 -3
- package/dist/display/Section.svelte.d.ts +1 -1
- package/dist/display/css/accordion.css +14 -14
- package/dist/display/css/alert.css +42 -15
- package/dist/display/css/avatar.css +36 -36
- package/dist/display/css/card.css +108 -36
- package/dist/display/css/chip.css +16 -16
- package/dist/display/css/collapsible.css +32 -32
- package/dist/display/css/countdown.css +206 -0
- package/dist/display/css/item.css +24 -0
- package/dist/display/css/marquee.css +0 -3
- package/dist/display/css/section.css +88 -109
- package/dist/display/css/table.css +1 -16
- package/dist/form/ColorField.svelte +60 -2
- package/dist/form/DragDrop.svelte +317 -87
- package/dist/form/DragDrop.svelte.d.ts +1 -0
- package/dist/form/Dropzone.svelte +3 -3
- package/dist/form/Dropzone.svelte.d.ts +1 -1
- package/dist/form/ImageCropper.svelte +135 -4
- package/dist/form/RadioGroup.svelte +6 -2
- package/dist/form/RadioGroup.svelte.d.ts +1 -1
- package/dist/form/Slider.svelte +6 -2
- package/dist/form/Slider.svelte.d.ts +1 -1
- package/dist/form/TextField.svelte +13 -4
- package/dist/form/TextField.svelte.d.ts +3 -2
- package/dist/form/Toggle.svelte +6 -2
- package/dist/form/Toggle.svelte.d.ts +1 -1
- package/dist/form/css/control.css +14 -14
- package/dist/form/css/csv-field.css +8 -13
- package/dist/form/css/drag-drop.css +90 -127
- package/dist/form/css/dropzone.css +8 -8
- package/dist/form/css/editor.css +14 -14
- package/dist/form/css/image-cropper.css +28 -7
- package/dist/form/css/radio-group.css +25 -0
- package/dist/form/css/slider.css +36 -0
- package/dist/form/css/textarea.css +14 -14
- package/dist/form/css/toggle.css +12 -0
- package/dist/hooks/use-chat.svelte.js +1 -1
- package/dist/hooks/use-form.svelte.js +3 -3
- package/dist/hooks/use-search.svelte.js +0 -3
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +4 -0
- package/dist/index.css +28 -48
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/layout/Provider.svelte +5 -5
- package/dist/layout/Sidebar.svelte +17 -8
- package/dist/layout/Sidebar.svelte.d.ts +2 -1
- package/dist/layout/css/app-bar.css +7 -7
- package/dist/layout/css/footer.css +7 -7
- package/dist/layout/css/sidebar.css +120 -59
- package/dist/navigation/BottomNav.svelte +23 -14
- package/dist/navigation/css/bottom-nav.css +74 -34
- package/dist/navigation/css/nav-menu.css +14 -15
- package/dist/navigation/css/side-nav.css +14 -15
- package/dist/overlay/AlertDialog.svelte +58 -0
- package/dist/overlay/AlertDialog.svelte.d.ts +14 -25
- package/dist/overlay/Command.svelte +177 -170
- package/dist/overlay/Command.svelte.d.ts +12 -3
- package/dist/overlay/Drawer.svelte +4 -4
- package/dist/overlay/Drawer.svelte.d.ts +1 -1
- package/dist/overlay/Modal.svelte +4 -4
- package/dist/overlay/Modal.svelte.d.ts +1 -1
- package/dist/overlay/Tooltip.svelte +0 -5
- package/dist/overlay/css/command.css +30 -42
- package/dist/overlay/css/drawer.css +10 -10
- package/dist/overlay/css/modal.css +70 -18
- package/dist/overlay/css/toast.css +42 -14
- package/dist/overlay/css/tooltip.css +49 -23
- package/dist/stores/theme.svelte.js +19 -12
- package/package.json +1 -1
- package/dist/utils/charts.d.ts +0 -27
- package/dist/utils/charts.js +0 -140
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { SearchState, SearchOption } from '../hooks/use-search.svelte.js';
|
|
3
3
|
import { Search24RegularIcon, DotsMoveIcon } from '../icons/index.js';
|
|
4
|
-
import { Icon, Item, type IconData } from '../index.js';
|
|
4
|
+
import { Icon, Item, Modal, TextField, type IconData } from '../index.js';
|
|
5
5
|
import { cn } from '../utils/class-names.js';
|
|
6
|
-
import { popover } from '../utils/popover.js';
|
|
7
6
|
import { tick } from 'svelte';
|
|
8
|
-
import {
|
|
7
|
+
import { afterNavigate } from '$app/navigation';
|
|
9
8
|
|
|
10
9
|
type CommandGroup = {
|
|
11
10
|
label: string;
|
|
11
|
+
icon?: IconData;
|
|
12
12
|
options: SearchOption[];
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
type
|
|
16
|
-
search: SearchState;
|
|
17
|
-
open?: boolean;
|
|
15
|
+
type CommandLabels = {
|
|
18
16
|
placeholder?: string;
|
|
19
17
|
emptyText?: string;
|
|
20
18
|
loadingText?: string;
|
|
21
19
|
loadingMoreText?: string;
|
|
20
|
+
closeText?: string;
|
|
21
|
+
navigateText?: string;
|
|
22
|
+
selectText?: string;
|
|
23
|
+
toggleText?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type Props = {
|
|
27
|
+
search: SearchState;
|
|
28
|
+
open?: boolean;
|
|
29
|
+
labels?: CommandLabels;
|
|
22
30
|
color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'warning' | 'danger';
|
|
23
31
|
disableOverlayClose?: boolean;
|
|
24
32
|
disableGlobalShortcut?: boolean;
|
|
@@ -33,10 +41,7 @@
|
|
|
33
41
|
let {
|
|
34
42
|
search,
|
|
35
43
|
open = $bindable(false),
|
|
36
|
-
|
|
37
|
-
emptyText = 'No results found',
|
|
38
|
-
loadingText = 'Loading...',
|
|
39
|
-
loadingMoreText = 'Loading more...',
|
|
44
|
+
labels = {},
|
|
40
45
|
color = 'muted',
|
|
41
46
|
disableOverlayClose = false,
|
|
42
47
|
disableGlobalShortcut = false,
|
|
@@ -48,16 +53,42 @@
|
|
|
48
53
|
class: className
|
|
49
54
|
}: Props = $props();
|
|
50
55
|
|
|
51
|
-
|
|
56
|
+
const defaultLabels: Required<CommandLabels> = {
|
|
57
|
+
placeholder: 'Search...',
|
|
58
|
+
emptyText: 'No results found',
|
|
59
|
+
loadingText: 'Loading...',
|
|
60
|
+
loadingMoreText: 'Loading more...',
|
|
61
|
+
closeText: 'to close',
|
|
62
|
+
navigateText: 'Navigate',
|
|
63
|
+
selectText: 'Select',
|
|
64
|
+
toggleText: 'Toggle'
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const t = $derived({ ...defaultLabels, ...labels });
|
|
68
|
+
|
|
52
69
|
let optionsEl = $state<HTMLElement>();
|
|
53
70
|
let searchInputEl = $state<HTMLInputElement>();
|
|
54
71
|
let focusedIndex = $state(-1);
|
|
55
72
|
let hasSearched = $state(false);
|
|
73
|
+
let modifierKey = $state('Ctrl');
|
|
74
|
+
|
|
75
|
+
const filteredGroups = $derived(() => {
|
|
76
|
+
if (!groups || groups.length === 0) return [];
|
|
77
|
+
const query = search.search?.toLowerCase() ?? '';
|
|
78
|
+
if (!query) return groups;
|
|
79
|
+
|
|
80
|
+
return groups
|
|
81
|
+
.map((group) => ({
|
|
82
|
+
...group,
|
|
83
|
+
options: group.options.filter((opt) => opt.label.toLowerCase().includes(query))
|
|
84
|
+
}))
|
|
85
|
+
.filter((group) => group.options.length > 0);
|
|
86
|
+
});
|
|
56
87
|
|
|
57
|
-
// Flatten options for keyboard navigation
|
|
58
88
|
const flatOptions = $derived(() => {
|
|
59
|
-
|
|
60
|
-
|
|
89
|
+
const filtered = filteredGroups();
|
|
90
|
+
if (filtered.length > 0) {
|
|
91
|
+
return filtered.flatMap((g) => g.options);
|
|
61
92
|
}
|
|
62
93
|
return search.options;
|
|
63
94
|
});
|
|
@@ -102,6 +133,7 @@
|
|
|
102
133
|
|
|
103
134
|
const handleGlobalKeyDown = (event: KeyboardEvent) => {
|
|
104
135
|
if (disableGlobalShortcut) return;
|
|
136
|
+
if (typeof navigator === 'undefined') return;
|
|
105
137
|
|
|
106
138
|
const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
107
139
|
const modifier = isMac ? event.metaKey : event.ctrlKey;
|
|
@@ -124,20 +156,9 @@
|
|
|
124
156
|
};
|
|
125
157
|
|
|
126
158
|
const handleSelect = (item: SearchOption) => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
} else {
|
|
131
|
-
onselect?.(item);
|
|
132
|
-
open = false;
|
|
133
|
-
search.setSearch('');
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const handleOverlayClick = () => {
|
|
138
|
-
if (!disableOverlayClose) {
|
|
139
|
-
handleClose();
|
|
140
|
-
}
|
|
159
|
+
onselect?.(item);
|
|
160
|
+
open = false;
|
|
161
|
+
search.setSearch('');
|
|
141
162
|
};
|
|
142
163
|
|
|
143
164
|
const handleClose = () => {
|
|
@@ -148,20 +169,31 @@
|
|
|
148
169
|
onclose?.();
|
|
149
170
|
};
|
|
150
171
|
|
|
172
|
+
const handleModalClose = () => {
|
|
173
|
+
handleClose();
|
|
174
|
+
};
|
|
175
|
+
|
|
151
176
|
$effect(() => {
|
|
152
177
|
if (search.search && search.search.length > 0) {
|
|
153
178
|
hasSearched = true;
|
|
154
179
|
}
|
|
155
180
|
});
|
|
156
181
|
|
|
182
|
+
$effect(() => {
|
|
183
|
+
afterNavigate(() => {
|
|
184
|
+
if (open) {
|
|
185
|
+
open = false;
|
|
186
|
+
focusedIndex = -1;
|
|
187
|
+
hasSearched = false;
|
|
188
|
+
search.setSearch('');
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
157
193
|
$effect(() => {
|
|
158
194
|
if (open) {
|
|
159
|
-
setTimeout(() => {
|
|
160
|
-
openContent = true;
|
|
161
|
-
}, 20);
|
|
162
195
|
document.addEventListener('keydown', handleKeyDown);
|
|
163
196
|
} else {
|
|
164
|
-
openContent = false;
|
|
165
197
|
document.removeEventListener('keydown', handleKeyDown);
|
|
166
198
|
}
|
|
167
199
|
|
|
@@ -171,7 +203,7 @@
|
|
|
171
203
|
});
|
|
172
204
|
|
|
173
205
|
$effect(() => {
|
|
174
|
-
if (
|
|
206
|
+
if (open && searchInputEl) {
|
|
175
207
|
tick().then(() => {
|
|
176
208
|
searchInputEl?.focus();
|
|
177
209
|
focusedIndex = -1;
|
|
@@ -181,160 +213,135 @@
|
|
|
181
213
|
});
|
|
182
214
|
|
|
183
215
|
$effect(() => {
|
|
216
|
+
if (typeof document === 'undefined') return;
|
|
217
|
+
|
|
184
218
|
if (!disableGlobalShortcut) {
|
|
185
219
|
document.addEventListener('keydown', handleGlobalKeyDown);
|
|
186
220
|
}
|
|
187
221
|
|
|
222
|
+
if (typeof navigator !== 'undefined') {
|
|
223
|
+
const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
224
|
+
modifierKey = isMac ? '⌘' : 'Ctrl';
|
|
225
|
+
}
|
|
226
|
+
|
|
188
227
|
return () => {
|
|
189
228
|
document.removeEventListener('keydown', handleGlobalKeyDown);
|
|
190
229
|
};
|
|
191
230
|
});
|
|
192
|
-
|
|
193
|
-
const isMac =
|
|
194
|
-
typeof navigator !== 'undefined' && navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
195
|
-
const modifierKey = isMac ? '⌘' : 'Ctrl';
|
|
196
231
|
</script>
|
|
197
232
|
|
|
198
|
-
{#
|
|
199
|
-
<div
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
<div in:scale={{ duration: 100 }} class={cn('command', className)}>
|
|
205
|
-
<div class="command-search">
|
|
206
|
-
<Icon icon={Search24RegularIcon} class="command-search-icon" />
|
|
207
|
-
<input
|
|
208
|
-
bind:this={searchInputEl}
|
|
209
|
-
type="text"
|
|
210
|
-
class="command-search-input"
|
|
211
|
-
{placeholder}
|
|
212
|
-
bind:value={search.search}
|
|
213
|
-
/>
|
|
214
|
-
<div class="command-kbd">
|
|
215
|
-
<kbd>Esc</kbd>
|
|
216
|
-
<span>to close</span>
|
|
217
|
-
</div>
|
|
218
|
-
</div>
|
|
233
|
+
{#snippet commandKbd()}
|
|
234
|
+
<div class="command-kbd">
|
|
235
|
+
<kbd>Esc</kbd>
|
|
236
|
+
<span>{t.closeText}</span>
|
|
237
|
+
</div>
|
|
238
|
+
{/snippet}
|
|
219
239
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
{color}
|
|
260
|
-
size="sm"
|
|
261
|
-
isCompact
|
|
262
|
-
onclick={() => handleSelect(item)}
|
|
263
|
-
/>
|
|
264
|
-
{/if}
|
|
265
|
-
{/each}
|
|
266
|
-
</div>
|
|
267
|
-
{/if}
|
|
268
|
-
{/each}
|
|
240
|
+
{#snippet renderItem(item: SearchOption, index: number)}
|
|
241
|
+
{@const hasVisualElement = !!item.icon || !!item.src}
|
|
242
|
+
<Item
|
|
243
|
+
id={item.id}
|
|
244
|
+
label={item.label}
|
|
245
|
+
icon={item.icon as IconData}
|
|
246
|
+
src={item.src}
|
|
247
|
+
description={item.description}
|
|
248
|
+
href={item.href as string | undefined}
|
|
249
|
+
isFocused={focusedIndex === index}
|
|
250
|
+
isDisabled={item.disabled}
|
|
251
|
+
hasBullet={!hasVisualElement}
|
|
252
|
+
{color}
|
|
253
|
+
size="sm"
|
|
254
|
+
isCompact
|
|
255
|
+
onclick={() => handleSelect(item)}
|
|
256
|
+
/>
|
|
257
|
+
{/snippet}
|
|
258
|
+
|
|
259
|
+
<Modal
|
|
260
|
+
bind:open
|
|
261
|
+
onclose={handleModalClose}
|
|
262
|
+
rootClass={cn(className)}
|
|
263
|
+
color="background"
|
|
264
|
+
{disableOverlayClose}
|
|
265
|
+
hideCloseButton
|
|
266
|
+
>
|
|
267
|
+
{#snippet header()}
|
|
268
|
+
<TextField
|
|
269
|
+
bind:el={searchInputEl}
|
|
270
|
+
bind:value={search.search}
|
|
271
|
+
placeholder={t.placeholder}
|
|
272
|
+
startIcon={Search24RegularIcon}
|
|
273
|
+
variant="line"
|
|
274
|
+
{color}
|
|
275
|
+
size="md"
|
|
276
|
+
endText={commandKbd}
|
|
277
|
+
/>
|
|
278
|
+
{/snippet}
|
|
269
279
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
280
|
+
<div class="command-results" bind:this={optionsEl} onscroll={handleScroll}>
|
|
281
|
+
{#if search.isLoading}
|
|
282
|
+
<div class="command-loading">
|
|
283
|
+
<Icon icon={DotsMoveIcon} class="command-loading-spinner" />
|
|
284
|
+
<span>{t.loadingText}</span>
|
|
285
|
+
</div>
|
|
286
|
+
{:else if flatOptions().length === 0 && hasSearched}
|
|
287
|
+
<div class="command-empty">{t.emptyText}</div>
|
|
288
|
+
{:else if filteredGroups().length > 0}
|
|
289
|
+
{#each filteredGroups() as group}
|
|
290
|
+
<div class="command-group">
|
|
291
|
+
<div class="command-group-label">
|
|
292
|
+
{#if group.icon}
|
|
293
|
+
<Icon icon={group.icon} class="command-group-icon" />
|
|
275
294
|
{/if}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
label={item.label}
|
|
282
|
-
icon={item.icon as IconData}
|
|
283
|
-
src={item.src}
|
|
284
|
-
description={item.description}
|
|
285
|
-
href={item.href as string}
|
|
286
|
-
isFocused={focusedIndex === index}
|
|
287
|
-
isDisabled={item.disabled}
|
|
288
|
-
{color}
|
|
289
|
-
size="sm"
|
|
290
|
-
isCompact
|
|
291
|
-
onclick={() => handleSelect(item)}
|
|
292
|
-
/>
|
|
293
|
-
{:else}
|
|
294
|
-
<Item
|
|
295
|
-
id={item.id}
|
|
296
|
-
label={item.label}
|
|
297
|
-
icon={item.icon as IconData}
|
|
298
|
-
src={item.src}
|
|
299
|
-
description={item.description}
|
|
300
|
-
isFocused={focusedIndex === index}
|
|
301
|
-
isDisabled={item.disabled}
|
|
302
|
-
{color}
|
|
303
|
-
size="sm"
|
|
304
|
-
isCompact
|
|
305
|
-
onclick={() => handleSelect(item)}
|
|
306
|
-
/>
|
|
307
|
-
{/if}
|
|
295
|
+
{group.label}
|
|
296
|
+
</div>
|
|
297
|
+
<div class="command-group-items">
|
|
298
|
+
{#each group.options as item}
|
|
299
|
+
{@render renderItem(item, flatOptions().indexOf(item))}
|
|
308
300
|
{/each}
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
{/each}
|
|
309
304
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
</div>
|
|
315
|
-
{/if}
|
|
316
|
-
{/if}
|
|
305
|
+
{#if search.isLoadingMore}
|
|
306
|
+
<div class="command-loading">
|
|
307
|
+
<Icon icon={DotsMoveIcon} class="command-loading-spinner" />
|
|
308
|
+
<span>{t.loadingMoreText}</span>
|
|
317
309
|
</div>
|
|
310
|
+
{/if}
|
|
311
|
+
{:else if search.options.length > 0}
|
|
312
|
+
<div class="command-group-items">
|
|
313
|
+
{#each search.options as item, index}
|
|
314
|
+
{@render renderItem(item, index)}
|
|
315
|
+
{/each}
|
|
316
|
+
</div>
|
|
318
317
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
</
|
|
318
|
+
{#if search.isLoadingMore}
|
|
319
|
+
<div class="command-loading">
|
|
320
|
+
<Icon icon={DotsMoveIcon} class="command-loading-spinner" />
|
|
321
|
+
<span>{t.loadingMoreText}</span>
|
|
322
|
+
</div>
|
|
323
|
+
{/if}
|
|
324
|
+
{/if}
|
|
325
|
+
</div>
|
|
326
|
+
|
|
327
|
+
{#snippet footer()}
|
|
328
|
+
{#if showFooter}
|
|
329
|
+
<div class="command-shortcuts">
|
|
330
|
+
<div class="command-shortcut">
|
|
331
|
+
<div class="command-shortcut-item">
|
|
332
|
+
<kbd>↑</kbd><kbd>↓</kbd>
|
|
333
|
+
<span>{t.navigateText}</span>
|
|
334
|
+
</div>
|
|
335
|
+
<div class="command-shortcut-item">
|
|
336
|
+
<kbd>↵</kbd>
|
|
337
|
+
<span>{t.selectText}</span>
|
|
335
338
|
</div>
|
|
336
|
-
|
|
339
|
+
</div>
|
|
340
|
+
<div class="command-shortcut-item">
|
|
341
|
+
<kbd>{modifierKey}</kbd><kbd>{shortcut.toUpperCase()}</kbd>
|
|
342
|
+
<span>{t.toggleText}</span>
|
|
343
|
+
</div>
|
|
337
344
|
</div>
|
|
338
345
|
{/if}
|
|
339
|
-
|
|
340
|
-
|
|
346
|
+
{/snippet}
|
|
347
|
+
</Modal>
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import type { SearchState, SearchOption } from '../hooks/use-search.svelte.js';
|
|
2
|
+
import { type IconData } from '../index.js';
|
|
2
3
|
type CommandGroup = {
|
|
3
4
|
label: string;
|
|
5
|
+
icon?: IconData;
|
|
4
6
|
options: SearchOption[];
|
|
5
7
|
};
|
|
6
|
-
type
|
|
7
|
-
search: SearchState;
|
|
8
|
-
open?: boolean;
|
|
8
|
+
type CommandLabels = {
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
emptyText?: string;
|
|
11
11
|
loadingText?: string;
|
|
12
12
|
loadingMoreText?: string;
|
|
13
|
+
closeText?: string;
|
|
14
|
+
navigateText?: string;
|
|
15
|
+
selectText?: string;
|
|
16
|
+
toggleText?: string;
|
|
17
|
+
};
|
|
18
|
+
type Props = {
|
|
19
|
+
search: SearchState;
|
|
20
|
+
open?: boolean;
|
|
21
|
+
labels?: CommandLabels;
|
|
13
22
|
color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'warning' | 'danger';
|
|
14
23
|
disableOverlayClose?: boolean;
|
|
15
24
|
disableGlobalShortcut?: boolean;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
| 'warning'
|
|
28
28
|
| 'danger'
|
|
29
29
|
| 'surface'
|
|
30
|
-
| '
|
|
30
|
+
| 'background';
|
|
31
31
|
variant?: 'solid' | 'soft';
|
|
32
32
|
disableOverlayClose?: boolean;
|
|
33
33
|
hideCloseButton?: boolean;
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
headerClass,
|
|
45
45
|
bodyClass,
|
|
46
46
|
footerClass,
|
|
47
|
-
color = '
|
|
47
|
+
color = 'background',
|
|
48
48
|
variant = 'solid',
|
|
49
49
|
disableOverlayClose,
|
|
50
50
|
hideCloseButton
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
danger: 'is-danger',
|
|
67
67
|
warning: 'is-warning',
|
|
68
68
|
surface: 'is-surface',
|
|
69
|
-
|
|
69
|
+
background: 'is-background'
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
const variants = {
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
warning: 'warning',
|
|
84
84
|
danger: 'danger',
|
|
85
85
|
surface: 'muted',
|
|
86
|
-
|
|
86
|
+
background: 'muted'
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
let openDrawer = $state(false);
|
|
@@ -10,7 +10,7 @@ type Props = {
|
|
|
10
10
|
headerClass?: string;
|
|
11
11
|
footerClass?: string;
|
|
12
12
|
bodyClass?: string;
|
|
13
|
-
color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'warning' | 'danger' | 'surface' | '
|
|
13
|
+
color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'warning' | 'danger' | 'surface' | 'background';
|
|
14
14
|
variant?: 'solid' | 'soft';
|
|
15
15
|
disableOverlayClose?: boolean;
|
|
16
16
|
hideCloseButton?: boolean;
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
| 'warning'
|
|
27
27
|
| 'danger'
|
|
28
28
|
| 'surface'
|
|
29
|
-
| '
|
|
29
|
+
| 'background';
|
|
30
30
|
variant?: 'solid' | 'soft';
|
|
31
31
|
disableOverlayClose?: boolean;
|
|
32
32
|
hideCloseButton?: boolean;
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
headerClass,
|
|
43
43
|
contentClass,
|
|
44
44
|
footerClass,
|
|
45
|
-
color = '
|
|
45
|
+
color = 'background',
|
|
46
46
|
variant = 'solid',
|
|
47
47
|
disableOverlayClose,
|
|
48
48
|
hideCloseButton
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
danger: 'is-danger',
|
|
60
60
|
warning: 'is-warning',
|
|
61
61
|
surface: 'is-surface',
|
|
62
|
-
|
|
62
|
+
background: 'is-background'
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
const variants = {
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
warning: 'warning',
|
|
77
77
|
danger: 'danger',
|
|
78
78
|
surface: 'muted',
|
|
79
|
-
|
|
79
|
+
background: 'muted'
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
const handleOverlayClick = () => {
|
|
@@ -9,7 +9,7 @@ type Props = {
|
|
|
9
9
|
headerClass?: string;
|
|
10
10
|
footerClass?: string;
|
|
11
11
|
contentClass?: string;
|
|
12
|
-
color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'warning' | 'danger' | 'surface' | '
|
|
12
|
+
color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'warning' | 'danger' | 'surface' | 'background';
|
|
13
13
|
variant?: 'solid' | 'soft';
|
|
14
14
|
disableOverlayClose?: boolean;
|
|
15
15
|
hideCloseButton?: boolean;
|
|
@@ -82,10 +82,6 @@
|
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
// Note: Don't add scroll offsets for position: fixed
|
|
86
|
-
// getBoundingClientRect() returns viewport-relative coordinates
|
|
87
|
-
// and position: fixed is also relative to the viewport
|
|
88
|
-
|
|
89
85
|
const padding = 8;
|
|
90
86
|
if (left < padding) left = padding;
|
|
91
87
|
if (left + tooltipRect.width > window.innerWidth - padding) {
|
|
@@ -102,7 +98,6 @@
|
|
|
102
98
|
const handleMouseEnter = () => {
|
|
103
99
|
startEventListeners();
|
|
104
100
|
isOpen = true;
|
|
105
|
-
// Use requestAnimationFrame to ensure the element is rendered before calculating position
|
|
106
101
|
requestAnimationFrame(() => {
|
|
107
102
|
updatePosition();
|
|
108
103
|
});
|