@velastack/patterns 0.0.1
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 +81 -0
- package/dist/chunks/collections-BRabBN4M.js +38 -0
- package/dist/chunks/collections-BRabBN4M.js.map +1 -0
- package/dist/chunks/env.preview-HlXZOEL4.js +17 -0
- package/dist/chunks/env.preview-HlXZOEL4.js.map +1 -0
- package/dist/chunks/env.runtime-_7lT2q35.js +36 -0
- package/dist/chunks/env.runtime-_7lT2q35.js.map +1 -0
- package/dist/chunks/generate.runtime-BR_qnQ-6.js +419 -0
- package/dist/chunks/generate.runtime-BR_qnQ-6.js.map +1 -0
- package/dist/chunks/index-D5FMXkZu.js +5916 -0
- package/dist/chunks/index-D5FMXkZu.js.map +1 -0
- package/dist/chunks/pocketbase-D612ARa5.js +135 -0
- package/dist/chunks/pocketbase-D612ARa5.js.map +1 -0
- package/dist/chunks/write-result-DG5OAbe1.js +1541 -0
- package/dist/chunks/write-result-DG5OAbe1.js.map +1 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,1541 @@
|
|
|
1
|
+
import { mkdirSync as f, writeFileSync as _, existsSync as v, rmSync as $, readFileSync as P } from "node:fs";
|
|
2
|
+
import r from "node:path";
|
|
3
|
+
import { detect as T } from "package-manager-detector";
|
|
4
|
+
import { resolveCommand as L } from "package-manager-detector/commands";
|
|
5
|
+
import I from "cross-spawn";
|
|
6
|
+
const M = `<script lang="ts">
|
|
7
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
8
|
+
import { cn } from '$lib/utils';
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
value,
|
|
12
|
+
class: className,
|
|
13
|
+
...restProps
|
|
14
|
+
}: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();
|
|
15
|
+
<\/script>
|
|
16
|
+
|
|
17
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
18
|
+
{#if value}
|
|
19
|
+
{new Date(value).toLocaleDateString()}
|
|
20
|
+
{/if}
|
|
21
|
+
</div>
|
|
22
|
+
`, D = `<script lang="ts">
|
|
23
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
24
|
+
import { cn } from '$lib/utils';
|
|
25
|
+
|
|
26
|
+
let {
|
|
27
|
+
value,
|
|
28
|
+
class: className,
|
|
29
|
+
...restProps
|
|
30
|
+
}: { value: boolean | undefined } & HTMLAttributes<HTMLDivElement> = $props();
|
|
31
|
+
<\/script>
|
|
32
|
+
|
|
33
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
34
|
+
{value ? 'Yes' : 'No'}
|
|
35
|
+
</div>
|
|
36
|
+
`, S = `<script lang="ts">
|
|
37
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
38
|
+
import { cn } from '$lib/utils';
|
|
39
|
+
|
|
40
|
+
let {
|
|
41
|
+
value,
|
|
42
|
+
class: className,
|
|
43
|
+
...restProps
|
|
44
|
+
}: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();
|
|
45
|
+
<\/script>
|
|
46
|
+
|
|
47
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
48
|
+
{#if value}
|
|
49
|
+
{new Date(value).toLocaleDateString()}
|
|
50
|
+
{/if}
|
|
51
|
+
</div>
|
|
52
|
+
`, k = `<script lang="ts">
|
|
53
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
54
|
+
import { cn } from '$lib/utils';
|
|
55
|
+
|
|
56
|
+
let {
|
|
57
|
+
value,
|
|
58
|
+
class: className,
|
|
59
|
+
...restProps
|
|
60
|
+
}: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();
|
|
61
|
+
<\/script>
|
|
62
|
+
|
|
63
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
64
|
+
{value}
|
|
65
|
+
</div>
|
|
66
|
+
`, F = `<script lang="ts">
|
|
67
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
68
|
+
import { cn } from '$lib/utils';
|
|
69
|
+
|
|
70
|
+
let {
|
|
71
|
+
value,
|
|
72
|
+
class: className,
|
|
73
|
+
...restProps
|
|
74
|
+
}: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();
|
|
75
|
+
<\/script>
|
|
76
|
+
|
|
77
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
78
|
+
{value}
|
|
79
|
+
</div>
|
|
80
|
+
`, N = `<script lang="ts">
|
|
81
|
+
import FileIcon from '@lucide/svelte/icons/file';
|
|
82
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
83
|
+
import { cn } from '$lib/utils';
|
|
84
|
+
|
|
85
|
+
let {
|
|
86
|
+
value,
|
|
87
|
+
collectionId,
|
|
88
|
+
id,
|
|
89
|
+
class: className,
|
|
90
|
+
...restProps
|
|
91
|
+
}: {
|
|
92
|
+
value: string[] | string | undefined;
|
|
93
|
+
collectionId: string;
|
|
94
|
+
id: string;
|
|
95
|
+
} & HTMLAttributes<HTMLDivElement> = $props();
|
|
96
|
+
<\/script>
|
|
97
|
+
|
|
98
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
99
|
+
{#if value}
|
|
100
|
+
{#if Array.isArray(value)}
|
|
101
|
+
{#each value.slice(0, 2) as filename}
|
|
102
|
+
{#if ['.jpg', '.png', '.jpeg', '.webp', '.gif'].some((ext) => filename.endsWith(ext))}
|
|
103
|
+
<img
|
|
104
|
+
src="/api/files/{collectionId}/{id}/{filename}"
|
|
105
|
+
class="w-8 h-8 rounded-sm object-cover inline-block mr-2"
|
|
106
|
+
alt={filename}
|
|
107
|
+
title={filename}
|
|
108
|
+
/>
|
|
109
|
+
{:else}
|
|
110
|
+
<div
|
|
111
|
+
class="inline-flex items-center justify-center w-8 h-8 bg-muted rounded-sm mr-2"
|
|
112
|
+
title={filename}
|
|
113
|
+
>
|
|
114
|
+
<FileIcon class="w-4 h-4" />
|
|
115
|
+
</div>
|
|
116
|
+
{/if}
|
|
117
|
+
{/each}
|
|
118
|
+
{#if value.length > 2}
|
|
119
|
+
and {value.length - 2} more files
|
|
120
|
+
{/if}
|
|
121
|
+
{:else if ['.jpg', '.png', '.jpeg', '.webp', '.gif'].some((ext) => value.endsWith(ext))}
|
|
122
|
+
<img
|
|
123
|
+
src="/api/files/{collectionId}/{id}/{value}"
|
|
124
|
+
class="w-8 h-8 rounded-sm object-cover"
|
|
125
|
+
alt={value}
|
|
126
|
+
title={value}
|
|
127
|
+
/>
|
|
128
|
+
{:else}
|
|
129
|
+
<div
|
|
130
|
+
class="inline-flex items-center justify-center w-8 h-8 bg-muted rounded-sm"
|
|
131
|
+
title={value}
|
|
132
|
+
>
|
|
133
|
+
<FileIcon class="w-4 h-4" />
|
|
134
|
+
</div>
|
|
135
|
+
{/if}
|
|
136
|
+
{/if}
|
|
137
|
+
</div>
|
|
138
|
+
`, A = `<script lang="ts">
|
|
139
|
+
import MapPinIcon from '@lucide/svelte/icons/map-pin';
|
|
140
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
141
|
+
import { cn } from '$lib/utils';
|
|
142
|
+
|
|
143
|
+
let {
|
|
144
|
+
value,
|
|
145
|
+
class: className,
|
|
146
|
+
...restProps
|
|
147
|
+
}: {
|
|
148
|
+
value: { lat: number; lon: number } | undefined;
|
|
149
|
+
} & HTMLAttributes<HTMLDivElement> = $props();
|
|
150
|
+
<\/script>
|
|
151
|
+
|
|
152
|
+
<div class={cn('flex items-center space-x-1', className)} {...restProps}>
|
|
153
|
+
{#if value}
|
|
154
|
+
<MapPinIcon class="inline-block w-4 h-4 text-muted-foreground" />
|
|
155
|
+
<span>{value.lat.toFixed(6)}, {value.lon.toFixed(6)}</span>
|
|
156
|
+
{/if}
|
|
157
|
+
</div>
|
|
158
|
+
`, H = `export { default as AutodateCell } from './autodate.svelte';
|
|
159
|
+
export { default as BoolCell } from './bool.svelte';
|
|
160
|
+
export { default as DateCell } from './date.svelte';
|
|
161
|
+
export { default as EditorCell } from './editor.svelte';
|
|
162
|
+
export { default as EmailCell } from './email.svelte';
|
|
163
|
+
export { default as FileCell } from './file.svelte';
|
|
164
|
+
export { default as GeoPointCell } from './geoPoint.svelte';
|
|
165
|
+
export { default as JsonCell } from './json.svelte';
|
|
166
|
+
export { default as NumberCell } from './number.svelte';
|
|
167
|
+
export { default as PasswordCell } from './password.svelte';
|
|
168
|
+
export { default as RelationCell } from './relation.svelte';
|
|
169
|
+
export { default as SelectCell } from './select.svelte';
|
|
170
|
+
export { default as TextCell } from './text.svelte';
|
|
171
|
+
export { default as UrlCell } from './url.svelte';
|
|
172
|
+
`, B = `<script lang="ts">
|
|
173
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
174
|
+
import { cn } from '$lib/utils';
|
|
175
|
+
|
|
176
|
+
let {
|
|
177
|
+
value,
|
|
178
|
+
class: className,
|
|
179
|
+
...restProps
|
|
180
|
+
}: { value: any } & HTMLAttributes<HTMLDivElement> = $props();
|
|
181
|
+
<\/script>
|
|
182
|
+
|
|
183
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
184
|
+
{#if value !== undefined}
|
|
185
|
+
{JSON.stringify(value)}
|
|
186
|
+
{/if}
|
|
187
|
+
</div>
|
|
188
|
+
`, j = `<script lang="ts">
|
|
189
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
190
|
+
import { cn } from '$lib/utils';
|
|
191
|
+
|
|
192
|
+
let {
|
|
193
|
+
value,
|
|
194
|
+
class: className,
|
|
195
|
+
...restProps
|
|
196
|
+
}: { value: number | undefined } & HTMLAttributes<HTMLDivElement> = $props();
|
|
197
|
+
<\/script>
|
|
198
|
+
|
|
199
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
200
|
+
{value}
|
|
201
|
+
</div>
|
|
202
|
+
`, R = `<script lang="ts">
|
|
203
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
204
|
+
import { cn } from '$lib/utils';
|
|
205
|
+
|
|
206
|
+
let {
|
|
207
|
+
value,
|
|
208
|
+
class: className,
|
|
209
|
+
...restProps
|
|
210
|
+
}: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();
|
|
211
|
+
<\/script>
|
|
212
|
+
|
|
213
|
+
<div class={cn('flex items-center', className)} {...restProps}>********</div>
|
|
214
|
+
`, E = `<script lang="ts">
|
|
215
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
216
|
+
import { Badge } from '$lib/components/ui/badge';
|
|
217
|
+
import { cn } from '$lib/utils';
|
|
218
|
+
|
|
219
|
+
let {
|
|
220
|
+
value,
|
|
221
|
+
expanded,
|
|
222
|
+
displayField = 'id',
|
|
223
|
+
class: className,
|
|
224
|
+
...restProps
|
|
225
|
+
}: {
|
|
226
|
+
value: string[] | string | undefined;
|
|
227
|
+
expanded: any;
|
|
228
|
+
displayField?: string;
|
|
229
|
+
} & HTMLAttributes<HTMLDivElement> = $props();
|
|
230
|
+
<\/script>
|
|
231
|
+
|
|
232
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
233
|
+
{#if expanded}
|
|
234
|
+
{#if Array.isArray(expanded)}
|
|
235
|
+
{#each expanded.slice(0, 2) as item}
|
|
236
|
+
<Badge variant="outline" class="mr-1">
|
|
237
|
+
{item[displayField]}
|
|
238
|
+
</Badge>
|
|
239
|
+
{/each}
|
|
240
|
+
{#if expanded.length > 2}
|
|
241
|
+
<Badge variant="secondary" class="mr-1">
|
|
242
|
+
+{expanded.length - 2}
|
|
243
|
+
</Badge>
|
|
244
|
+
{/if}
|
|
245
|
+
{:else}
|
|
246
|
+
<Badge variant="outline" class="mr-1">
|
|
247
|
+
{expanded[displayField]}
|
|
248
|
+
</Badge>
|
|
249
|
+
{/if}
|
|
250
|
+
{/if}
|
|
251
|
+
</div>
|
|
252
|
+
`, U = `<script lang="ts">
|
|
253
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
254
|
+
import { Badge } from '$lib/components/ui/badge';
|
|
255
|
+
import { cn } from '$lib/utils';
|
|
256
|
+
|
|
257
|
+
let {
|
|
258
|
+
value,
|
|
259
|
+
options,
|
|
260
|
+
class: className,
|
|
261
|
+
...restProps
|
|
262
|
+
}: {
|
|
263
|
+
value: string[] | string | undefined;
|
|
264
|
+
options: Record<string, { label: string; value: string }>;
|
|
265
|
+
} & HTMLAttributes<HTMLDivElement> = $props();
|
|
266
|
+
<\/script>
|
|
267
|
+
|
|
268
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
269
|
+
{#if value}
|
|
270
|
+
{#if Array.isArray(value)}
|
|
271
|
+
{#each value.slice(0, 2) as item}
|
|
272
|
+
<Badge variant="outline" class="mr-1">
|
|
273
|
+
{options[item].label}
|
|
274
|
+
</Badge>
|
|
275
|
+
{/each}
|
|
276
|
+
{:else}
|
|
277
|
+
{options[value].label}
|
|
278
|
+
{/if}
|
|
279
|
+
{/if}
|
|
280
|
+
</div>
|
|
281
|
+
`, z = `<script lang="ts">
|
|
282
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
283
|
+
import { cn } from '$lib/utils';
|
|
284
|
+
|
|
285
|
+
let {
|
|
286
|
+
value,
|
|
287
|
+
class: className,
|
|
288
|
+
...restProps
|
|
289
|
+
}: { value: string | undefined } & HTMLAttributes<HTMLDivElement> = $props();
|
|
290
|
+
<\/script>
|
|
291
|
+
|
|
292
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
293
|
+
{value}
|
|
294
|
+
</div>
|
|
295
|
+
`, V = `<script lang="ts">
|
|
296
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
297
|
+
import { cn } from '$lib/utils';
|
|
298
|
+
|
|
299
|
+
let {
|
|
300
|
+
value,
|
|
301
|
+
class: className,
|
|
302
|
+
target = '_blank',
|
|
303
|
+
rel = 'noopener noreferrer',
|
|
304
|
+
...restProps
|
|
305
|
+
}: {
|
|
306
|
+
value: string | undefined;
|
|
307
|
+
target?: string;
|
|
308
|
+
rel?: string;
|
|
309
|
+
} & HTMLAttributes<HTMLDivElement> = $props();
|
|
310
|
+
<\/script>
|
|
311
|
+
|
|
312
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
313
|
+
{#if value}
|
|
314
|
+
<a href={value} {target} {rel}>{value}</a>
|
|
315
|
+
{/if}
|
|
316
|
+
</div>
|
|
317
|
+
`, O = `<script lang="ts">
|
|
318
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
319
|
+
import type { Column } from '@tanstack/table-core';
|
|
320
|
+
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
|
|
321
|
+
import { Button } from '$lib/components/ui/button';
|
|
322
|
+
import ArrowUpIcon from '@lucide/svelte/icons/arrow-up';
|
|
323
|
+
import ArrowDownIcon from '@lucide/svelte/icons/arrow-down';
|
|
324
|
+
import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';
|
|
325
|
+
import { cn } from '$lib/utils';
|
|
326
|
+
|
|
327
|
+
let {
|
|
328
|
+
column,
|
|
329
|
+
title,
|
|
330
|
+
class: className,
|
|
331
|
+
...restProps
|
|
332
|
+
}: { column: Column<any>; title: string } & HTMLAttributes<HTMLDivElement> = $props();
|
|
333
|
+
<\/script>
|
|
334
|
+
|
|
335
|
+
{#if !column?.getCanSort()}
|
|
336
|
+
<div class={className} {...restProps}>
|
|
337
|
+
{title}
|
|
338
|
+
</div>
|
|
339
|
+
{:else}
|
|
340
|
+
<div class={cn('flex items-center', className)} {...restProps}>
|
|
341
|
+
<DropdownMenu.Root>
|
|
342
|
+
<DropdownMenu.Trigger>
|
|
343
|
+
{#snippet child({ props })}
|
|
344
|
+
<Button
|
|
345
|
+
{...props}
|
|
346
|
+
variant="ghost"
|
|
347
|
+
size="sm"
|
|
348
|
+
class="data-[state=open]:bg-accent -ml-3 h-8"
|
|
349
|
+
>
|
|
350
|
+
<span>
|
|
351
|
+
{title}
|
|
352
|
+
</span>
|
|
353
|
+
{#if column.getIsSorted() === 'desc'}
|
|
354
|
+
<ArrowDownIcon />
|
|
355
|
+
{:else if column.getIsSorted() === 'asc'}
|
|
356
|
+
<ArrowUpIcon />
|
|
357
|
+
{:else}
|
|
358
|
+
<ChevronsUpDownIcon />
|
|
359
|
+
{/if}
|
|
360
|
+
</Button>
|
|
361
|
+
{/snippet}
|
|
362
|
+
</DropdownMenu.Trigger>
|
|
363
|
+
<DropdownMenu.Content align="start">
|
|
364
|
+
<DropdownMenu.Item onclick={() => column.toggleSorting(false)}>
|
|
365
|
+
<ArrowUpIcon class="text-muted-foreground/70 mr-2 size-3.5" />
|
|
366
|
+
Asc
|
|
367
|
+
</DropdownMenu.Item>
|
|
368
|
+
<DropdownMenu.Item onclick={() => column.toggleSorting(true)}>
|
|
369
|
+
<ArrowDownIcon class="text-muted-foreground/70 mr-2 size-3.5" />
|
|
370
|
+
Desc
|
|
371
|
+
</DropdownMenu.Item>
|
|
372
|
+
</DropdownMenu.Content>
|
|
373
|
+
</DropdownMenu.Root>
|
|
374
|
+
</div>
|
|
375
|
+
{/if}
|
|
376
|
+
`, W = `export { default as ColumnHeader } from './column-header.svelte';
|
|
377
|
+
`, G = `<script lang="ts" generics="TData, TValue">
|
|
378
|
+
import type { Component } from 'svelte';
|
|
379
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
380
|
+
import type { Column } from '@tanstack/table-core';
|
|
381
|
+
import CirclePlusIcon from '@lucide/svelte/icons/circle-plus';
|
|
382
|
+
import CheckIcon from '@lucide/svelte/icons/check';
|
|
383
|
+
import * as Command from '$lib/components/ui/command';
|
|
384
|
+
import * as Popover from '$lib/components/ui/popover';
|
|
385
|
+
import { Button } from '$lib/components/ui/button';
|
|
386
|
+
import { Separator } from '$lib/components/ui/separator';
|
|
387
|
+
import { Badge } from '$lib/components/ui/badge';
|
|
388
|
+
import { cn } from '$lib/utils';
|
|
389
|
+
|
|
390
|
+
let {
|
|
391
|
+
column,
|
|
392
|
+
title,
|
|
393
|
+
options
|
|
394
|
+
}: {
|
|
395
|
+
column: Column<TData, TValue>;
|
|
396
|
+
title: string;
|
|
397
|
+
options: {
|
|
398
|
+
label: string;
|
|
399
|
+
value: string;
|
|
400
|
+
icon?: Component;
|
|
401
|
+
}[];
|
|
402
|
+
} = $props();
|
|
403
|
+
|
|
404
|
+
const facets = $derived(column?.getFacetedUniqueValues());
|
|
405
|
+
const selectedValues = $derived(new SvelteSet(column?.getFilterValue() as string[]));
|
|
406
|
+
<\/script>
|
|
407
|
+
|
|
408
|
+
<Popover.Root>
|
|
409
|
+
<Popover.Trigger>
|
|
410
|
+
{#snippet child({ props })}
|
|
411
|
+
<Button {...props} variant="outline" size="sm" class="h-8 border-dashed">
|
|
412
|
+
<CirclePlusIcon />
|
|
413
|
+
{title}
|
|
414
|
+
{#if selectedValues.size > 0}
|
|
415
|
+
<Separator orientation="vertical" class="mx-2 h-4" />
|
|
416
|
+
<Badge variant="secondary" class="rounded-sm px-1 font-normal lg:hidden">
|
|
417
|
+
{selectedValues.size}
|
|
418
|
+
</Badge>
|
|
419
|
+
<div class="hidden space-x-1 lg:flex">
|
|
420
|
+
{#if selectedValues.size > 2}
|
|
421
|
+
<Badge variant="secondary" class="rounded-sm px-1 font-normal">
|
|
422
|
+
{selectedValues.size} selected
|
|
423
|
+
</Badge>
|
|
424
|
+
{:else}
|
|
425
|
+
{#each options.filter((opt) => selectedValues.has(opt.value)) as option (option)}
|
|
426
|
+
<Badge variant="secondary" class="rounded-sm px-1 font-normal">
|
|
427
|
+
{option.label}
|
|
428
|
+
</Badge>
|
|
429
|
+
{/each}
|
|
430
|
+
{/if}
|
|
431
|
+
</div>
|
|
432
|
+
{/if}
|
|
433
|
+
</Button>
|
|
434
|
+
{/snippet}
|
|
435
|
+
</Popover.Trigger>
|
|
436
|
+
<Popover.Content class="w-[200px] p-0" align="start">
|
|
437
|
+
<Command.Root>
|
|
438
|
+
<Command.Input placeholder={title} />
|
|
439
|
+
<Command.List>
|
|
440
|
+
<Command.Empty>No results found.</Command.Empty>
|
|
441
|
+
<Command.Group>
|
|
442
|
+
{#each options as option (option)}
|
|
443
|
+
{@const isSelected = selectedValues.has(option.value)}
|
|
444
|
+
<Command.Item
|
|
445
|
+
onSelect={() => {
|
|
446
|
+
if (isSelected) {
|
|
447
|
+
selectedValues.delete(option.value);
|
|
448
|
+
} else {
|
|
449
|
+
selectedValues.add(option.value);
|
|
450
|
+
}
|
|
451
|
+
const filterValues = Array.from(selectedValues);
|
|
452
|
+
column?.setFilterValue(filterValues.length ? filterValues : undefined);
|
|
453
|
+
}}
|
|
454
|
+
>
|
|
455
|
+
<div
|
|
456
|
+
class={cn(
|
|
457
|
+
'border-primary mr-2 flex size-4 items-center justify-center rounded-sm border',
|
|
458
|
+
isSelected ? 'bg-primary text-primary-foreground' : 'opacity-50 [&_svg]:invisible'
|
|
459
|
+
)}
|
|
460
|
+
>
|
|
461
|
+
<CheckIcon class="size-4" />
|
|
462
|
+
</div>
|
|
463
|
+
{#if option.icon}
|
|
464
|
+
{@const Icon = option.icon}
|
|
465
|
+
<Icon class="text-muted-foreground" />
|
|
466
|
+
{/if}
|
|
467
|
+
|
|
468
|
+
<span>{option.label}</span>
|
|
469
|
+
{#if facets?.get(option.value)}
|
|
470
|
+
<span class="ml-auto flex size-4 items-center justify-center font-mono text-xs">
|
|
471
|
+
{facets.get(option.value)}
|
|
472
|
+
</span>
|
|
473
|
+
{/if}
|
|
474
|
+
</Command.Item>
|
|
475
|
+
{/each}
|
|
476
|
+
</Command.Group>
|
|
477
|
+
{#if selectedValues.size > 0}
|
|
478
|
+
<Command.Separator />
|
|
479
|
+
<Command.Group>
|
|
480
|
+
<Command.Item
|
|
481
|
+
onSelect={() => column?.setFilterValue(undefined)}
|
|
482
|
+
class="justify-center text-center"
|
|
483
|
+
>
|
|
484
|
+
Clear filters
|
|
485
|
+
</Command.Item>
|
|
486
|
+
</Command.Group>
|
|
487
|
+
{/if}
|
|
488
|
+
</Command.List>
|
|
489
|
+
</Command.Root>
|
|
490
|
+
</Popover.Content>
|
|
491
|
+
</Popover.Root>
|
|
492
|
+
`, J = `export { default as FacetedFilter } from './faceted-filter.svelte';
|
|
493
|
+
`, Z = `<script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>">
|
|
494
|
+
import * as FormPrimitive from 'formsnap';
|
|
495
|
+
import type { FormPath } from 'sveltekit-superforms';
|
|
496
|
+
import { cn, type WithElementRef, type WithoutChildren } from '$lib/utils';
|
|
497
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
498
|
+
import { setContext } from 'svelte';
|
|
499
|
+
|
|
500
|
+
let {
|
|
501
|
+
ref = $bindable(null),
|
|
502
|
+
class: className,
|
|
503
|
+
form,
|
|
504
|
+
name,
|
|
505
|
+
children: childrenProp,
|
|
506
|
+
...restProps
|
|
507
|
+
}: FormPrimitive.FieldProps<T, U> &
|
|
508
|
+
WithoutChildren<WithElementRef<HTMLAttributes<HTMLDivElement>>> = $props();
|
|
509
|
+
|
|
510
|
+
setContext('file-field', {
|
|
511
|
+
form,
|
|
512
|
+
name
|
|
513
|
+
});
|
|
514
|
+
<\/script>
|
|
515
|
+
|
|
516
|
+
<FormPrimitive.Field {form} {name}>
|
|
517
|
+
{#snippet children({ constraints, errors, tainted, value })}
|
|
518
|
+
<div bind:this={ref} data-slot="form-item" class={cn('space-y-2', className)} {...restProps}>
|
|
519
|
+
{@render childrenProp?.({ constraints, errors, tainted, value: value as T[U] })}
|
|
520
|
+
</div>
|
|
521
|
+
{/snippet}
|
|
522
|
+
</FormPrimitive.Field>
|
|
523
|
+
`, q = `<script lang="ts">
|
|
524
|
+
import { getContext } from 'svelte';
|
|
525
|
+
import { fileProxy, filesProxy, type SuperForm } from 'sveltekit-superforms';
|
|
526
|
+
import { Input } from '$lib/components/ui/input';
|
|
527
|
+
|
|
528
|
+
const { form, name } = getContext<{ form: SuperForm<any, any>; name: string }>('file-field');
|
|
529
|
+
const { multiple } = getContext<{ multiple: boolean }>('file-field-multiple');
|
|
530
|
+
|
|
531
|
+
const files = multiple ? filesProxy(form, \`\${name}+\`) : fileProxy(form, name);
|
|
532
|
+
const { form: formData, reset } = form;
|
|
533
|
+
|
|
534
|
+
const { ...props } = $props();
|
|
535
|
+
|
|
536
|
+
const onchange = () => {
|
|
537
|
+
reset({
|
|
538
|
+
data: $formData
|
|
539
|
+
});
|
|
540
|
+
};
|
|
541
|
+
<\/script>
|
|
542
|
+
|
|
543
|
+
{#if !multiple}
|
|
544
|
+
{#if $formData[name]}
|
|
545
|
+
{#if typeof $formData[name] === 'string'}
|
|
546
|
+
<input type="text" {name} value={$formData[name]} class="hidden" />
|
|
547
|
+
{:else}
|
|
548
|
+
<input type="file" {name} files={$files} class="hidden" />
|
|
549
|
+
{/if}
|
|
550
|
+
{:else}
|
|
551
|
+
<input type="text" {name} value="" class="hidden" />
|
|
552
|
+
{/if}
|
|
553
|
+
{/if}
|
|
554
|
+
|
|
555
|
+
<Input
|
|
556
|
+
type="file"
|
|
557
|
+
bind:files={$files}
|
|
558
|
+
{multiple}
|
|
559
|
+
{onchange}
|
|
560
|
+
{...props}
|
|
561
|
+
name={multiple ? \`\${name}+\` : ''}
|
|
562
|
+
/>
|
|
563
|
+
`, Y = `<script lang="ts">
|
|
564
|
+
import { setContext, getContext } from 'svelte';
|
|
565
|
+
import { type SuperForm } from 'sveltekit-superforms';
|
|
566
|
+
import { getName } from './shared';
|
|
567
|
+
|
|
568
|
+
const { form, name } = getContext<{ form: SuperForm<any, any>; name: string }>('file-field');
|
|
569
|
+
const {
|
|
570
|
+
display,
|
|
571
|
+
input
|
|
572
|
+
}: {
|
|
573
|
+
display: (props: {
|
|
574
|
+
file: File | string;
|
|
575
|
+
filename: string;
|
|
576
|
+
onremove: (file: File | string) => void;
|
|
577
|
+
}) => any;
|
|
578
|
+
input: () => any;
|
|
579
|
+
} = $props();
|
|
580
|
+
|
|
581
|
+
setContext('file-field-multiple', { multiple: true });
|
|
582
|
+
|
|
583
|
+
const { form: formData, reset } = form;
|
|
584
|
+
|
|
585
|
+
let removed = $state<string[]>([]);
|
|
586
|
+
|
|
587
|
+
const onremove = (file: File | string) => {
|
|
588
|
+
if (typeof file === 'string') {
|
|
589
|
+
removed.push(file);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
reset({
|
|
593
|
+
data: {
|
|
594
|
+
...$formData,
|
|
595
|
+
[name]: $formData[name].filter((f: File | string) => f !== file) as File[] | undefined
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
const initialFiles = $formData[name] || [];
|
|
601
|
+
<\/script>
|
|
602
|
+
|
|
603
|
+
{#if initialFiles}
|
|
604
|
+
{#each initialFiles as file}
|
|
605
|
+
{#if !removed.includes(file)}
|
|
606
|
+
{@render display({ file, filename: getName(file), onremove })}
|
|
607
|
+
{/if}
|
|
608
|
+
{/each}
|
|
609
|
+
{/if}
|
|
610
|
+
|
|
611
|
+
{#each $formData[\`\${name}+\`] as file}
|
|
612
|
+
{#if file && typeof file !== 'string'}
|
|
613
|
+
{@render display({ file, filename: getName(file), onremove })}
|
|
614
|
+
{/if}
|
|
615
|
+
{/each}
|
|
616
|
+
|
|
617
|
+
{#each removed as removedFile}
|
|
618
|
+
<input type="text" name={\`\${name}-\`} value={removedFile} class="hidden" />
|
|
619
|
+
{/each}
|
|
620
|
+
|
|
621
|
+
{@render input()}
|
|
622
|
+
`, K = `<script lang="ts">
|
|
623
|
+
import { setContext, getContext } from 'svelte';
|
|
624
|
+
import { type SuperForm } from 'sveltekit-superforms';
|
|
625
|
+
import { getName } from './shared';
|
|
626
|
+
|
|
627
|
+
const { form, name } = getContext<{ form: SuperForm<any, any>; name: string }>('file-field');
|
|
628
|
+
const {
|
|
629
|
+
display,
|
|
630
|
+
input
|
|
631
|
+
}: {
|
|
632
|
+
display: (props: {
|
|
633
|
+
file: File | string;
|
|
634
|
+
filename: string;
|
|
635
|
+
onremove: (file: File | string) => void;
|
|
636
|
+
}) => any;
|
|
637
|
+
input: () => any;
|
|
638
|
+
} = $props();
|
|
639
|
+
|
|
640
|
+
const { form: formData, reset } = form;
|
|
641
|
+
|
|
642
|
+
setContext('file-field-multiple', { multiple: false });
|
|
643
|
+
|
|
644
|
+
const onremove = () => {
|
|
645
|
+
reset({
|
|
646
|
+
data: {
|
|
647
|
+
...$formData,
|
|
648
|
+
[name]: ''
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
};
|
|
652
|
+
<\/script>
|
|
653
|
+
|
|
654
|
+
{#if $formData[name]}
|
|
655
|
+
{@render display({ file: $formData[name], filename: getName($formData[name]), onremove })}
|
|
656
|
+
{/if}
|
|
657
|
+
|
|
658
|
+
{@render input()}
|
|
659
|
+
`, Q = `<script lang="ts">
|
|
660
|
+
import { getContext } from 'svelte';
|
|
661
|
+
import { type SuperForm } from 'sveltekit-superforms';
|
|
662
|
+
import FileIcon from '@lucide/svelte/icons/file';
|
|
663
|
+
import ImageIcon from '@lucide/svelte/icons/image';
|
|
664
|
+
import { cn } from '$lib/utils';
|
|
665
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
666
|
+
|
|
667
|
+
const { form } = getContext<{ form: SuperForm<any, any>; name: string }>('file-field');
|
|
668
|
+
const { form: formData } = form;
|
|
669
|
+
|
|
670
|
+
const {
|
|
671
|
+
file,
|
|
672
|
+
filename,
|
|
673
|
+
collectionId,
|
|
674
|
+
id,
|
|
675
|
+
thumb = '50x50',
|
|
676
|
+
class: className,
|
|
677
|
+
type = 'image',
|
|
678
|
+
...props
|
|
679
|
+
}: {
|
|
680
|
+
file: File | string;
|
|
681
|
+
filename: string;
|
|
682
|
+
collectionId?: string;
|
|
683
|
+
id?: string;
|
|
684
|
+
thumb?: string;
|
|
685
|
+
class?: string;
|
|
686
|
+
type?: 'image' | 'file';
|
|
687
|
+
} & HTMLAttributes<HTMLImageElement> = $props();
|
|
688
|
+
|
|
689
|
+
const isImage = $derived(
|
|
690
|
+
type === 'image' ||
|
|
691
|
+
filename.toLowerCase().endsWith('.png') ||
|
|
692
|
+
filename.toLowerCase().endsWith('.jpg') ||
|
|
693
|
+
filename.toLowerCase().endsWith('.jpeg') ||
|
|
694
|
+
filename.toLowerCase().endsWith('.gif') ||
|
|
695
|
+
filename.toLowerCase().endsWith('.webp')
|
|
696
|
+
);
|
|
697
|
+
|
|
698
|
+
function getUrl(file: string) {
|
|
699
|
+
return \`/api/files/\${collectionId ?? $formData.collectionId}/\${id ?? $formData.id}/\${file}?thumb=\${thumb}\`;
|
|
700
|
+
}
|
|
701
|
+
<\/script>
|
|
702
|
+
|
|
703
|
+
{#if typeof file === 'string'}
|
|
704
|
+
{#if (id ?? $formData.collectionId) && (id ?? $formData.id) && isImage}
|
|
705
|
+
<img src={getUrl(file)} alt={filename} class={className} {...props} />
|
|
706
|
+
{:else}
|
|
707
|
+
<div
|
|
708
|
+
class={cn('flex items-center justify-center w-full h-full bg-muted rounded-md', className)}
|
|
709
|
+
{...props as HTMLAttributes<HTMLDivElement>}
|
|
710
|
+
>
|
|
711
|
+
{#if isImage}
|
|
712
|
+
<ImageIcon class="w-4 h-4" />
|
|
713
|
+
{:else}
|
|
714
|
+
<FileIcon class="w-4 h-4" />
|
|
715
|
+
{/if}
|
|
716
|
+
</div>
|
|
717
|
+
{/if}
|
|
718
|
+
{:else if isImage}
|
|
719
|
+
<img src={URL.createObjectURL(file)} alt={filename} class={className} {...props} />
|
|
720
|
+
{:else}
|
|
721
|
+
<div
|
|
722
|
+
class={cn('flex items-center justify-center w-full h-full bg-muted rounded-md', className)}
|
|
723
|
+
{...props as HTMLAttributes<HTMLDivElement>}
|
|
724
|
+
>
|
|
725
|
+
<FileIcon class="w-4 h-4" />
|
|
726
|
+
</div>
|
|
727
|
+
{/if}
|
|
728
|
+
`, X = `export { default as Field } from './file-field.svelte';
|
|
729
|
+
export { default as Single } from './file-single.svelte';
|
|
730
|
+
export { default as Multiple } from './file-multiple.svelte';
|
|
731
|
+
export { default as Input } from './file-input.svelte';
|
|
732
|
+
export { default as Thumb } from './file-thumb.svelte';
|
|
733
|
+
`, tt = `export function getUrl(file: File | string, collectionId: string, recordId: string, thumb: string) {
|
|
734
|
+
return typeof file === 'string'
|
|
735
|
+
? \`/api/files/\${collectionId}/\${recordId}/\${file}?thumb=\${thumb}\`
|
|
736
|
+
: URL.createObjectURL(file);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
export function getName(file: File | string) {
|
|
740
|
+
return typeof file === 'string' ? (file.split('/').pop() ?? '') : file.name;
|
|
741
|
+
}
|
|
742
|
+
`, et = `<script lang="ts">
|
|
743
|
+
import { cn } from '$lib/utils';
|
|
744
|
+
|
|
745
|
+
let {
|
|
746
|
+
value = $bindable(),
|
|
747
|
+
id,
|
|
748
|
+
label,
|
|
749
|
+
shortLabel,
|
|
750
|
+
mapOpen
|
|
751
|
+
}: {
|
|
752
|
+
value: number;
|
|
753
|
+
id: string;
|
|
754
|
+
label: string;
|
|
755
|
+
shortLabel: string;
|
|
756
|
+
mapOpen: boolean;
|
|
757
|
+
} = $props();
|
|
758
|
+
<\/script>
|
|
759
|
+
|
|
760
|
+
<div
|
|
761
|
+
class={cn(
|
|
762
|
+
'border-input bg-background selection:bg-primary dark:bg-input/30 selection:text-primary-foreground ring-offset-background placeholder:text-muted-foreground shadow-xs flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base outline-none transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
|
|
763
|
+
'focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]',
|
|
764
|
+
'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
|
|
765
|
+
'pr-0 flex items-center',
|
|
766
|
+
label === 'Latitude' && 'rounded-r-none',
|
|
767
|
+
label === 'Longitude' && 'rounded-none -ml-px',
|
|
768
|
+
mapOpen && 'rounded-b-none'
|
|
769
|
+
)}
|
|
770
|
+
>
|
|
771
|
+
<label for={id} class="text-muted-foreground mr-2">
|
|
772
|
+
<span class="hidden md:block">{label}</span>
|
|
773
|
+
<span class="block md:hidden">{shortLabel}</span>
|
|
774
|
+
</label>
|
|
775
|
+
|
|
776
|
+
<input
|
|
777
|
+
bind:value
|
|
778
|
+
type="number"
|
|
779
|
+
class="border-none outline-none min-w-0 w-full pr-2"
|
|
780
|
+
{id}
|
|
781
|
+
step="0.000001"
|
|
782
|
+
/>
|
|
783
|
+
</div>
|
|
784
|
+
`, nt = `export { default as GeopointInput } from './input.svelte';
|
|
785
|
+
`, ot = `<script lang="ts">
|
|
786
|
+
import { setContext } from 'svelte';
|
|
787
|
+
import ToggleMap from './toggle-map.svelte';
|
|
788
|
+
import Coordinate from './coordinate.svelte';
|
|
789
|
+
|
|
790
|
+
let {
|
|
791
|
+
name,
|
|
792
|
+
value = $bindable()
|
|
793
|
+
}: {
|
|
794
|
+
name: string;
|
|
795
|
+
value: string | undefined;
|
|
796
|
+
} = $props();
|
|
797
|
+
|
|
798
|
+
const geopoint = $state(value ? JSON.parse(value) : { lat: 0, lon: 0 });
|
|
799
|
+
const map = $state({ open: false });
|
|
800
|
+
|
|
801
|
+
setContext('geopoint', {
|
|
802
|
+
geopoint,
|
|
803
|
+
map
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
$effect(() => {
|
|
807
|
+
if (value) {
|
|
808
|
+
const parsed = JSON.parse(value);
|
|
809
|
+
|
|
810
|
+
if (typeof parsed === 'object' && parsed !== null && 'lat' in parsed && 'lon' in parsed) {
|
|
811
|
+
geopoint.lat = parsed.lat.toFixed(6);
|
|
812
|
+
geopoint.lon = parsed.lon.toFixed(6);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
const stringValue = $derived(
|
|
818
|
+
JSON.stringify({ lat: parseFloat(geopoint.lat), lon: parseFloat(geopoint.lon) })
|
|
819
|
+
);
|
|
820
|
+
<\/script>
|
|
821
|
+
|
|
822
|
+
<input type="hidden" {name} value={stringValue} />
|
|
823
|
+
|
|
824
|
+
<div class="w-full">
|
|
825
|
+
<div class="w-full flex">
|
|
826
|
+
<Coordinate
|
|
827
|
+
id="latitude"
|
|
828
|
+
label="Latitude"
|
|
829
|
+
shortLabel="Lat"
|
|
830
|
+
bind:value={geopoint.lat}
|
|
831
|
+
mapOpen={map.open}
|
|
832
|
+
/>
|
|
833
|
+
<Coordinate
|
|
834
|
+
id="longitude"
|
|
835
|
+
label="Longitude"
|
|
836
|
+
shortLabel="Lon"
|
|
837
|
+
bind:value={geopoint.lon}
|
|
838
|
+
mapOpen={map.open}
|
|
839
|
+
/>
|
|
840
|
+
<ToggleMap />
|
|
841
|
+
</div>
|
|
842
|
+
|
|
843
|
+
{#if map.open}
|
|
844
|
+
{#await import('$lib/components/ui/leaflet/leaflet.svelte')}
|
|
845
|
+
<div class="h-[225px] w-full bg-input rounded-b-md"></div>
|
|
846
|
+
{:then { default: Leaflet }}
|
|
847
|
+
<Leaflet height={225} point={geopoint} class="rounded-b-md overflow-hidden" />
|
|
848
|
+
{/await}
|
|
849
|
+
{/if}
|
|
850
|
+
</div>
|
|
851
|
+
`, it = `<script>
|
|
852
|
+
import { Button } from '$lib/components/ui/button';
|
|
853
|
+
import MapIcon from '@lucide/svelte/icons/map';
|
|
854
|
+
import { getContext } from 'svelte';
|
|
855
|
+
import { cn } from '$lib/utils';
|
|
856
|
+
|
|
857
|
+
let { map } = getContext('geopoint');
|
|
858
|
+
<\/script>
|
|
859
|
+
|
|
860
|
+
<Button
|
|
861
|
+
variant="outline"
|
|
862
|
+
size="icon"
|
|
863
|
+
class={cn('w-10 rounded-none rounded-r-md border-l-0', map.open && 'rounded-b-none')}
|
|
864
|
+
onclick={() => (map.open = !map.open)}
|
|
865
|
+
>
|
|
866
|
+
<MapIcon class="w-4 h-4" />
|
|
867
|
+
</Button>
|
|
868
|
+
`, st = `export { default as Leaflet } from './leaflet.svelte';
|
|
869
|
+
`, lt = `<script lang="ts">
|
|
870
|
+
import { onMount } from 'svelte';
|
|
871
|
+
import L from 'leaflet';
|
|
872
|
+
import 'leaflet/dist/leaflet.css';
|
|
873
|
+
|
|
874
|
+
// manually load the markers so that they can be embedded in the prod bundle
|
|
875
|
+
import markerIconUrl from 'leaflet/dist/images/marker-icon.png';
|
|
876
|
+
import markerIconRetinaUrl from 'leaflet/dist/images/marker-icon-2x.png';
|
|
877
|
+
import markerShadowUrl from 'leaflet/dist/images/marker-shadow.png';
|
|
878
|
+
|
|
879
|
+
let { height = 225, point = $bindable(), readonly = false, ...props } = $props();
|
|
880
|
+
|
|
881
|
+
let map: L.Map;
|
|
882
|
+
let mapEl: HTMLElement;
|
|
883
|
+
let marker: L.Marker;
|
|
884
|
+
let panTimeoutId: ReturnType<typeof setTimeout>;
|
|
885
|
+
|
|
886
|
+
const defaultZoomLevel = 8;
|
|
887
|
+
|
|
888
|
+
$effect(() => {
|
|
889
|
+
if (point.lat && point.lon) {
|
|
890
|
+
panInside();
|
|
891
|
+
}
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
function normalizeCoordinate(coord: any) {
|
|
895
|
+
return +(+coord).toFixed(6);
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
function panInside(debounce = 200) {
|
|
899
|
+
clearTimeout(panTimeoutId);
|
|
900
|
+
panTimeoutId = setTimeout(() => {
|
|
901
|
+
marker?.setLatLng([point.lat, point.lon]);
|
|
902
|
+
map?.panInside([point.lat, point.lon], { padding: [20, 40] });
|
|
903
|
+
}, debounce);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
function initMap() {
|
|
907
|
+
const latlon = [
|
|
908
|
+
normalizeCoordinate(point.lat),
|
|
909
|
+
normalizeCoordinate(point.lon)
|
|
910
|
+
] as L.LatLngTuple;
|
|
911
|
+
|
|
912
|
+
map = L.map(mapEl, {
|
|
913
|
+
zoomControl: false,
|
|
914
|
+
maxBounds: [
|
|
915
|
+
[-90, -180],
|
|
916
|
+
[90, 180]
|
|
917
|
+
],
|
|
918
|
+
minZoom: 2
|
|
919
|
+
}).setView(latlon, defaultZoomLevel);
|
|
920
|
+
|
|
921
|
+
if (readonly) {
|
|
922
|
+
map.dragging.disable();
|
|
923
|
+
map.touchZoom.disable();
|
|
924
|
+
map.doubleClickZoom.disable();
|
|
925
|
+
map.scrollWheelZoom.disable();
|
|
926
|
+
map.boxZoom.disable();
|
|
927
|
+
map.keyboard.disable();
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
931
|
+
attribution: '© <a href="https://www.openstreetmap.org/copyright">OSM</a>',
|
|
932
|
+
noWrap: true
|
|
933
|
+
}).addTo(map);
|
|
934
|
+
|
|
935
|
+
map.attributionControl.setPrefix('');
|
|
936
|
+
|
|
937
|
+
// reassign the default marker images with the loaded ones
|
|
938
|
+
// (https://leafletjs.com/reference.html#icon-default-option)
|
|
939
|
+
L.Icon.Default.prototype.options.iconUrl = markerIconUrl;
|
|
940
|
+
L.Icon.Default.prototype.options.iconRetinaUrl = markerIconRetinaUrl;
|
|
941
|
+
L.Icon.Default.prototype.options.shadowUrl = markerShadowUrl;
|
|
942
|
+
L.Icon.Default.imagePath = '';
|
|
943
|
+
|
|
944
|
+
marker = L.marker(latlon, {
|
|
945
|
+
draggable: true,
|
|
946
|
+
autoPan: true
|
|
947
|
+
}).addTo(map);
|
|
948
|
+
|
|
949
|
+
marker.bindTooltip('drag or right click anywhere on the map to move');
|
|
950
|
+
|
|
951
|
+
marker.on('moveend', (e) => {
|
|
952
|
+
if (e.sourceTarget?._latlng) {
|
|
953
|
+
select(e.sourceTarget._latlng.lat, e.sourceTarget._latlng.lng, false);
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
map.on('contextmenu', (e) => {
|
|
958
|
+
select(e.latlng.lat, e.latlng.lng, false);
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
function destroyMap() {
|
|
963
|
+
marker?.remove();
|
|
964
|
+
map?.remove();
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
function select(lat: number, lon: number, centerMap = true) {
|
|
968
|
+
point.lat = normalizeCoordinate(lat);
|
|
969
|
+
point.lon = normalizeCoordinate(lon);
|
|
970
|
+
|
|
971
|
+
// center the map
|
|
972
|
+
if (centerMap) {
|
|
973
|
+
marker?.setLatLng([point.lat, point.lon]); // optimistic marker update
|
|
974
|
+
map?.panTo([point.lat, point.lon], { animate: false });
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
onMount(() => {
|
|
979
|
+
initMap();
|
|
980
|
+
|
|
981
|
+
return () => {
|
|
982
|
+
destroyMap();
|
|
983
|
+
};
|
|
984
|
+
});
|
|
985
|
+
<\/script>
|
|
986
|
+
|
|
987
|
+
<div class="map-wrapper" style="{height ? \`height:\${height}px\` : null};" {...props}>
|
|
988
|
+
<div bind:this={mapEl} class="map-box"></div>
|
|
989
|
+
</div>
|
|
990
|
+
|
|
991
|
+
<style>
|
|
992
|
+
.map-wrapper {
|
|
993
|
+
position: relative;
|
|
994
|
+
display: block;
|
|
995
|
+
height: 100%;
|
|
996
|
+
width: 100%;
|
|
997
|
+
}
|
|
998
|
+
.map-box {
|
|
999
|
+
z-index: 1;
|
|
1000
|
+
height: 100%;
|
|
1001
|
+
width: 100%;
|
|
1002
|
+
}
|
|
1003
|
+
</style>
|
|
1004
|
+
`, rt = `<script lang="ts">
|
|
1005
|
+
import type { Snippet } from 'svelte';
|
|
1006
|
+
import { cn } from '$lib/utils';
|
|
1007
|
+
|
|
1008
|
+
let { children, class: className }: { children: Snippet; class?: string } = $props();
|
|
1009
|
+
<\/script>
|
|
1010
|
+
|
|
1011
|
+
<span class={cn('bg-secondary text-secondary-foreground px-2 py-1 rounded-sm text-sm', className)}>
|
|
1012
|
+
{@render children?.()}
|
|
1013
|
+
</span>
|
|
1014
|
+
`, at = `<script lang="ts">
|
|
1015
|
+
import { Popover as PopoverPrimitive } from 'bits-ui';
|
|
1016
|
+
import * as Popover from '$lib/components/ui/popover';
|
|
1017
|
+
|
|
1018
|
+
let {
|
|
1019
|
+
children,
|
|
1020
|
+
...props
|
|
1021
|
+
}: PopoverPrimitive.ContentProps & {
|
|
1022
|
+
portalProps?: PopoverPrimitive.PortalProps;
|
|
1023
|
+
} = $props();
|
|
1024
|
+
<\/script>
|
|
1025
|
+
|
|
1026
|
+
<Popover.Content {...props}>
|
|
1027
|
+
{@render children?.()}
|
|
1028
|
+
</Popover.Content>
|
|
1029
|
+
`, pt = `<script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>">
|
|
1030
|
+
import * as FormPrimitive from 'formsnap';
|
|
1031
|
+
import type { FormPath } from 'sveltekit-superforms';
|
|
1032
|
+
import { cn, type WithElementRef, type WithoutChildren } from '$lib/utils';
|
|
1033
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
1034
|
+
import { setContext } from 'svelte';
|
|
1035
|
+
import * as Popover from '$lib/components/ui/popover';
|
|
1036
|
+
|
|
1037
|
+
let {
|
|
1038
|
+
ref = $bindable(null),
|
|
1039
|
+
class: className,
|
|
1040
|
+
type,
|
|
1041
|
+
form,
|
|
1042
|
+
name,
|
|
1043
|
+
required,
|
|
1044
|
+
children: childrenProp,
|
|
1045
|
+
...restProps
|
|
1046
|
+
}: FormPrimitive.FieldProps<T, U> & {
|
|
1047
|
+
type: 'multiple' | 'single';
|
|
1048
|
+
required?: boolean;
|
|
1049
|
+
} & WithoutChildren<WithElementRef<HTMLAttributes<HTMLDivElement>>> = $props();
|
|
1050
|
+
|
|
1051
|
+
const { form: formData } = form;
|
|
1052
|
+
|
|
1053
|
+
const toggleSelected = (value: string) => {
|
|
1054
|
+
if (type === 'single') {
|
|
1055
|
+
if (!required && $formData[name] === value) {
|
|
1056
|
+
$formData[name] = undefined as T[U];
|
|
1057
|
+
} else {
|
|
1058
|
+
$formData[name] = value as T[U];
|
|
1059
|
+
}
|
|
1060
|
+
} else if (type === 'multiple') {
|
|
1061
|
+
if (!$formData[name]) {
|
|
1062
|
+
$formData[name] = [] as T[U];
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
const currentValue = $formData[name] as string[];
|
|
1066
|
+
const index = currentValue.indexOf(value);
|
|
1067
|
+
|
|
1068
|
+
if (index > -1) {
|
|
1069
|
+
$formData[name] = currentValue.filter((id) => id !== value) as T[U];
|
|
1070
|
+
} else {
|
|
1071
|
+
$formData[name] = [...currentValue, value] as T[U];
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
const isSelected = (value: string) => {
|
|
1077
|
+
if (type === 'single') {
|
|
1078
|
+
return $formData[name] === value;
|
|
1079
|
+
} else if (type === 'multiple') {
|
|
1080
|
+
return ($formData[name] as string[])?.includes(value) ?? false;
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
setContext('multiselect-field', {
|
|
1085
|
+
form,
|
|
1086
|
+
name,
|
|
1087
|
+
type,
|
|
1088
|
+
toggleSelected,
|
|
1089
|
+
isSelected
|
|
1090
|
+
});
|
|
1091
|
+
<\/script>
|
|
1092
|
+
|
|
1093
|
+
<Popover.Root>
|
|
1094
|
+
<FormPrimitive.Field {form} {name}>
|
|
1095
|
+
{#snippet children({ constraints, errors, tainted, value })}
|
|
1096
|
+
<div bind:this={ref} data-slot="form-item" class={cn('space-y-2', className)} {...restProps}>
|
|
1097
|
+
{@render childrenProp?.({ constraints, errors, tainted, value: value as T[U] })}
|
|
1098
|
+
</div>
|
|
1099
|
+
{/snippet}
|
|
1100
|
+
</FormPrimitive.Field>
|
|
1101
|
+
</Popover.Root>
|
|
1102
|
+
`, mt = `export { default as Field } from './field.svelte';
|
|
1103
|
+
export { default as Trigger } from './trigger.svelte';
|
|
1104
|
+
export { default as Input } from './input.svelte';
|
|
1105
|
+
export { default as Content } from './content.svelte';
|
|
1106
|
+
export { default as Item } from './item.svelte';
|
|
1107
|
+
export { default as Chip } from './chip.svelte';
|
|
1108
|
+
`, ct = `<script lang="ts" generics="T extends string">
|
|
1109
|
+
import type { SuperForm } from 'sveltekit-superforms';
|
|
1110
|
+
import { getContext, type Snippet } from 'svelte';
|
|
1111
|
+
|
|
1112
|
+
const { form, type } = getContext<{ form: SuperForm<any, any>; type: 'single' | 'multiple' }>(
|
|
1113
|
+
'multiselect-field'
|
|
1114
|
+
);
|
|
1115
|
+
const { form: formData } = form;
|
|
1116
|
+
|
|
1117
|
+
let {
|
|
1118
|
+
children,
|
|
1119
|
+
placeholder,
|
|
1120
|
+
name,
|
|
1121
|
+
value = $bindable()
|
|
1122
|
+
}: {
|
|
1123
|
+
children: Snippet<[{ selected: T[] }]>;
|
|
1124
|
+
placeholder?: string;
|
|
1125
|
+
name: string;
|
|
1126
|
+
value: T[] | T | undefined;
|
|
1127
|
+
} = $props();
|
|
1128
|
+
<\/script>
|
|
1129
|
+
|
|
1130
|
+
{#if value && value.length > 0}
|
|
1131
|
+
{@render children?.({ selected: type === 'single' ? [$formData[name]] : $formData[name] })}
|
|
1132
|
+
{#if type === 'multiple'}
|
|
1133
|
+
{#each value as v}
|
|
1134
|
+
<input type="hidden" {name} value={v} />
|
|
1135
|
+
{/each}
|
|
1136
|
+
{:else}
|
|
1137
|
+
<input type="hidden" {name} {value} />
|
|
1138
|
+
{/if}
|
|
1139
|
+
{:else}
|
|
1140
|
+
{placeholder}
|
|
1141
|
+
{/if}
|
|
1142
|
+
`, dt = `<script lang="ts">
|
|
1143
|
+
import { getContext, type Snippet } from 'svelte';
|
|
1144
|
+
import { cn } from '$lib/utils';
|
|
1145
|
+
import { Command as CommandPrimitive } from 'bits-ui';
|
|
1146
|
+
import * as Command from '$lib/components/ui/command';
|
|
1147
|
+
import CheckIcon from '@lucide/svelte/icons/check';
|
|
1148
|
+
|
|
1149
|
+
let {
|
|
1150
|
+
children,
|
|
1151
|
+
value,
|
|
1152
|
+
label,
|
|
1153
|
+
class: className,
|
|
1154
|
+
...props
|
|
1155
|
+
}: CommandPrimitive.ItemProps & {
|
|
1156
|
+
value: string;
|
|
1157
|
+
label: string | undefined;
|
|
1158
|
+
children?: Snippet;
|
|
1159
|
+
class?: string;
|
|
1160
|
+
} = $props();
|
|
1161
|
+
|
|
1162
|
+
const { toggleSelected, isSelected } = getContext<{
|
|
1163
|
+
toggleSelected: (value: string) => void;
|
|
1164
|
+
isSelected: (value: string) => boolean;
|
|
1165
|
+
}>('multiselect-field');
|
|
1166
|
+
|
|
1167
|
+
const handleSelect = () => {
|
|
1168
|
+
toggleSelected(value);
|
|
1169
|
+
};
|
|
1170
|
+
<\/script>
|
|
1171
|
+
|
|
1172
|
+
<Command.Item
|
|
1173
|
+
class={cn('cursor-pointer', className)}
|
|
1174
|
+
{...props}
|
|
1175
|
+
value={label}
|
|
1176
|
+
onSelect={handleSelect}
|
|
1177
|
+
>
|
|
1178
|
+
{label}
|
|
1179
|
+
<CheckIcon class={cn('ml-auto', !isSelected(value) && 'text-transparent')} />
|
|
1180
|
+
</Command.Item>
|
|
1181
|
+
`, ut = `<script lang="ts">
|
|
1182
|
+
import * as Popover from '$lib/components/ui/popover';
|
|
1183
|
+
import { Popover as PopoverPrimitive } from 'bits-ui';
|
|
1184
|
+
import { cn } from '$lib/utils';
|
|
1185
|
+
import { buttonVariants } from '$lib/components/ui/button';
|
|
1186
|
+
import ChevronDownIcon from '@lucide/svelte/icons/chevron-down';
|
|
1187
|
+
|
|
1188
|
+
let { children, class: className, ...props }: PopoverPrimitive.TriggerProps = $props();
|
|
1189
|
+
<\/script>
|
|
1190
|
+
|
|
1191
|
+
<Popover.Trigger
|
|
1192
|
+
class={cn(buttonVariants({ variant: 'outline' }), className)}
|
|
1193
|
+
role="combobox"
|
|
1194
|
+
{...props}
|
|
1195
|
+
>
|
|
1196
|
+
{@render children?.()}
|
|
1197
|
+
<ChevronDownIcon class="size-4 opacity-50" />
|
|
1198
|
+
</Popover.Trigger>
|
|
1199
|
+
`, ft = `export { default as Pagination } from './pagination.svelte';
|
|
1200
|
+
`, vt = `<script lang="ts">
|
|
1201
|
+
import * as Select from '$lib/components/ui/select';
|
|
1202
|
+
import { Button } from '$lib/components/ui/button';
|
|
1203
|
+
import ChevronsLeftIcon from '@lucide/svelte/icons/chevrons-left';
|
|
1204
|
+
import ChevronLeftIcon from '@lucide/svelte/icons/chevron-left';
|
|
1205
|
+
import ChevronRightIcon from '@lucide/svelte/icons/chevron-right';
|
|
1206
|
+
import ChevronsRightIcon from '@lucide/svelte/icons/chevrons-right';
|
|
1207
|
+
import type { Table as TableType } from '@tanstack/table-core';
|
|
1208
|
+
|
|
1209
|
+
let { table }: { table: TableType<any> } = $props();
|
|
1210
|
+
<\/script>
|
|
1211
|
+
|
|
1212
|
+
<div class="flex items-center justify-between px-2">
|
|
1213
|
+
<div class="text-muted-foreground flex-1 text-sm">
|
|
1214
|
+
{table.getFilteredSelectedRowModel().rows.length} of
|
|
1215
|
+
{table.getFilteredRowModel().rows.length} row(s) selected.
|
|
1216
|
+
</div>
|
|
1217
|
+
<div class="flex items-center space-x-6 lg:space-x-8">
|
|
1218
|
+
<div class="flex items-center space-x-2">
|
|
1219
|
+
<p class="text-sm font-medium">Rows per page</p>
|
|
1220
|
+
<Select.Root
|
|
1221
|
+
allowDeselect={false}
|
|
1222
|
+
type="single"
|
|
1223
|
+
value={\`\${table.getState().pagination.pageSize}\`}
|
|
1224
|
+
onValueChange={(value) => {
|
|
1225
|
+
table.setPageSize(Number(value));
|
|
1226
|
+
}}
|
|
1227
|
+
>
|
|
1228
|
+
<Select.Trigger class="h-8 w-[70px]">
|
|
1229
|
+
{String(table.getState().pagination.pageSize)}
|
|
1230
|
+
</Select.Trigger>
|
|
1231
|
+
<Select.Content side="top">
|
|
1232
|
+
{#each [10, 20, 30, 40, 50] as pageSize (pageSize)}
|
|
1233
|
+
<Select.Item value={\`\${pageSize}\`}>
|
|
1234
|
+
{pageSize}
|
|
1235
|
+
</Select.Item>
|
|
1236
|
+
{/each}
|
|
1237
|
+
</Select.Content>
|
|
1238
|
+
</Select.Root>
|
|
1239
|
+
</div>
|
|
1240
|
+
<div class="flex w-[100px] items-center justify-center text-sm font-medium">
|
|
1241
|
+
Page {table.getState().pagination.pageIndex + 1} of
|
|
1242
|
+
{table.getPageCount()}
|
|
1243
|
+
</div>
|
|
1244
|
+
<div class="flex items-center space-x-2">
|
|
1245
|
+
<Button
|
|
1246
|
+
variant="outline"
|
|
1247
|
+
class="hidden size-8 p-0 lg:flex"
|
|
1248
|
+
onclick={() => table.setPageIndex(0)}
|
|
1249
|
+
disabled={!table.getCanPreviousPage()}
|
|
1250
|
+
>
|
|
1251
|
+
<span class="sr-only">Go to first page</span>
|
|
1252
|
+
<ChevronsLeftIcon />
|
|
1253
|
+
</Button>
|
|
1254
|
+
<Button
|
|
1255
|
+
variant="outline"
|
|
1256
|
+
class="size-8 p-0"
|
|
1257
|
+
onclick={() => table.previousPage()}
|
|
1258
|
+
disabled={!table.getCanPreviousPage()}
|
|
1259
|
+
>
|
|
1260
|
+
<span class="sr-only">Go to previous page</span>
|
|
1261
|
+
<ChevronLeftIcon />
|
|
1262
|
+
</Button>
|
|
1263
|
+
<Button
|
|
1264
|
+
variant="outline"
|
|
1265
|
+
class="size-8 p-0"
|
|
1266
|
+
onclick={() => table.nextPage()}
|
|
1267
|
+
disabled={!table.getCanNextPage()}
|
|
1268
|
+
>
|
|
1269
|
+
<span class="sr-only">Go to next page</span>
|
|
1270
|
+
<ChevronRightIcon />
|
|
1271
|
+
</Button>
|
|
1272
|
+
<Button
|
|
1273
|
+
variant="outline"
|
|
1274
|
+
class="hidden size-8 p-0 lg:flex"
|
|
1275
|
+
onclick={() => table.setPageIndex(table.getPageCount() - 1)}
|
|
1276
|
+
disabled={!table.getCanNextPage()}
|
|
1277
|
+
>
|
|
1278
|
+
<span class="sr-only">Go to last page</span>
|
|
1279
|
+
<ChevronsRightIcon />
|
|
1280
|
+
</Button>
|
|
1281
|
+
</div>
|
|
1282
|
+
</div>
|
|
1283
|
+
</div>
|
|
1284
|
+
`, gt = `export { default as RowActions } from './row-actions.svelte';
|
|
1285
|
+
`, bt = `<script lang="ts">
|
|
1286
|
+
import { goto } from '$app/navigation';
|
|
1287
|
+
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
|
|
1288
|
+
import { Button } from '$lib/components/ui/button';
|
|
1289
|
+
import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
|
|
1290
|
+
|
|
1291
|
+
let {
|
|
1292
|
+
viewPath,
|
|
1293
|
+
editPath,
|
|
1294
|
+
deletePath
|
|
1295
|
+
}: {
|
|
1296
|
+
viewPath: string;
|
|
1297
|
+
editPath: string;
|
|
1298
|
+
deletePath: string;
|
|
1299
|
+
} = $props();
|
|
1300
|
+
<\/script>
|
|
1301
|
+
|
|
1302
|
+
<DropdownMenu.Root>
|
|
1303
|
+
<DropdownMenu.Trigger>
|
|
1304
|
+
{#snippet child({ props })}
|
|
1305
|
+
<Button {...props} variant="ghost" class="data-[state=open]:bg-muted flex h-8 w-8 p-0">
|
|
1306
|
+
<EllipsisIcon />
|
|
1307
|
+
<span class="sr-only">Open Menu</span>
|
|
1308
|
+
</Button>
|
|
1309
|
+
{/snippet}
|
|
1310
|
+
</DropdownMenu.Trigger>
|
|
1311
|
+
<DropdownMenu.Content class="w-[160px]" align="end">
|
|
1312
|
+
<DropdownMenu.Item onclick={() => goto(viewPath)}>View</DropdownMenu.Item>
|
|
1313
|
+
<DropdownMenu.Item onclick={() => goto(editPath)}>Edit</DropdownMenu.Item>
|
|
1314
|
+
<DropdownMenu.Item>
|
|
1315
|
+
<form method="POST" action={deletePath}>
|
|
1316
|
+
<button type="submit" class="contents">Delete</button>
|
|
1317
|
+
</form>
|
|
1318
|
+
</DropdownMenu.Item>
|
|
1319
|
+
</DropdownMenu.Content>
|
|
1320
|
+
</DropdownMenu.Root>
|
|
1321
|
+
`, ht = {
|
|
1322
|
+
"file-form": ["input", "form"],
|
|
1323
|
+
multiselect: ["command", "popover", "button", "badge"],
|
|
1324
|
+
geopoint: ["button", "leaflet"],
|
|
1325
|
+
cells: [],
|
|
1326
|
+
"column-header": ["dropdown-menu", "button"],
|
|
1327
|
+
"faceted-filter": ["command", "popover", "button", "separator", "badge"],
|
|
1328
|
+
pagination: ["button", "select"],
|
|
1329
|
+
"row-actions": ["dropdown-menu", "button"],
|
|
1330
|
+
leaflet: []
|
|
1331
|
+
}, _t = {
|
|
1332
|
+
"file-form": [],
|
|
1333
|
+
multiselect: [],
|
|
1334
|
+
geopoint: [],
|
|
1335
|
+
cells: [],
|
|
1336
|
+
"column-header": ["@tanstack/table-core"],
|
|
1337
|
+
"faceted-filter": ["@tanstack/table-core"],
|
|
1338
|
+
pagination: ["@tanstack/table-core"],
|
|
1339
|
+
"row-actions": [],
|
|
1340
|
+
leaflet: ["leaflet", "@types/leaflet"]
|
|
1341
|
+
}, x = /* @__PURE__ */ Object.assign({
|
|
1342
|
+
"../ui/components/cells/autodate.svelte": M,
|
|
1343
|
+
"../ui/components/cells/bool.svelte": D,
|
|
1344
|
+
"../ui/components/cells/date.svelte": S,
|
|
1345
|
+
"../ui/components/cells/editor.svelte": k,
|
|
1346
|
+
"../ui/components/cells/email.svelte": F,
|
|
1347
|
+
"../ui/components/cells/file.svelte": N,
|
|
1348
|
+
"../ui/components/cells/geoPoint.svelte": A,
|
|
1349
|
+
"../ui/components/cells/index.ts": H,
|
|
1350
|
+
"../ui/components/cells/json.svelte": B,
|
|
1351
|
+
"../ui/components/cells/number.svelte": j,
|
|
1352
|
+
"../ui/components/cells/password.svelte": R,
|
|
1353
|
+
"../ui/components/cells/relation.svelte": E,
|
|
1354
|
+
"../ui/components/cells/select.svelte": U,
|
|
1355
|
+
"../ui/components/cells/text.svelte": z,
|
|
1356
|
+
"../ui/components/cells/url.svelte": V,
|
|
1357
|
+
"../ui/components/column-header/column-header.svelte": O,
|
|
1358
|
+
"../ui/components/column-header/index.ts": W,
|
|
1359
|
+
"../ui/components/faceted-filter/faceted-filter.svelte": G,
|
|
1360
|
+
"../ui/components/faceted-filter/index.ts": J,
|
|
1361
|
+
"../ui/components/file-form/file-field.svelte": Z,
|
|
1362
|
+
"../ui/components/file-form/file-input.svelte": q,
|
|
1363
|
+
"../ui/components/file-form/file-multiple.svelte": Y,
|
|
1364
|
+
"../ui/components/file-form/file-single.svelte": K,
|
|
1365
|
+
"../ui/components/file-form/file-thumb.svelte": Q,
|
|
1366
|
+
"../ui/components/file-form/index.ts": X,
|
|
1367
|
+
"../ui/components/file-form/shared.ts": tt,
|
|
1368
|
+
"../ui/components/geopoint/coordinate.svelte": et,
|
|
1369
|
+
"../ui/components/geopoint/index.ts": nt,
|
|
1370
|
+
"../ui/components/geopoint/input.svelte": ot,
|
|
1371
|
+
"../ui/components/geopoint/toggle-map.svelte": it,
|
|
1372
|
+
"../ui/components/leaflet/index.ts": st,
|
|
1373
|
+
"../ui/components/leaflet/leaflet.svelte": lt,
|
|
1374
|
+
"../ui/components/multiselect/chip.svelte": rt,
|
|
1375
|
+
"../ui/components/multiselect/content.svelte": at,
|
|
1376
|
+
"../ui/components/multiselect/field.svelte": pt,
|
|
1377
|
+
"../ui/components/multiselect/index.ts": mt,
|
|
1378
|
+
"../ui/components/multiselect/input.svelte": ct,
|
|
1379
|
+
"../ui/components/multiselect/item.svelte": dt,
|
|
1380
|
+
"../ui/components/multiselect/trigger.svelte": ut,
|
|
1381
|
+
"../ui/components/pagination/index.ts": ft,
|
|
1382
|
+
"../ui/components/pagination/pagination.svelte": vt,
|
|
1383
|
+
"../ui/components/row-actions/index.ts": gt,
|
|
1384
|
+
"../ui/components/row-actions/row-actions.svelte": bt
|
|
1385
|
+
});
|
|
1386
|
+
function xt() {
|
|
1387
|
+
return [
|
|
1388
|
+
...new Set(
|
|
1389
|
+
Object.keys(x).map(y)
|
|
1390
|
+
)
|
|
1391
|
+
].filter(Boolean).sort();
|
|
1392
|
+
}
|
|
1393
|
+
function y(t) {
|
|
1394
|
+
const e = t.split("/"), n = e.indexOf("components");
|
|
1395
|
+
return e[n + 1] ?? "";
|
|
1396
|
+
}
|
|
1397
|
+
function yt(t) {
|
|
1398
|
+
const e = t.split("/"), n = e.indexOf("components");
|
|
1399
|
+
return e.slice(n + 2).join("/");
|
|
1400
|
+
}
|
|
1401
|
+
function g(t, e) {
|
|
1402
|
+
return r.isAbsolute(e) ? e : r.join(t, e);
|
|
1403
|
+
}
|
|
1404
|
+
function h(t, e) {
|
|
1405
|
+
f(r.dirname(t), { recursive: !0 }), _(t, e, "utf8");
|
|
1406
|
+
}
|
|
1407
|
+
function wt(t) {
|
|
1408
|
+
v(t) && $(t, { force: !0, recursive: !0 });
|
|
1409
|
+
}
|
|
1410
|
+
async function Ct(t, e, n) {
|
|
1411
|
+
var l;
|
|
1412
|
+
const o = ((l = await T({ cwd: t })) == null ? void 0 : l.name) ?? "npm", s = L(o, e, n);
|
|
1413
|
+
if (!s)
|
|
1414
|
+
throw new Error(
|
|
1415
|
+
`Unable to resolve ${e} command for ${o}`
|
|
1416
|
+
);
|
|
1417
|
+
const i = [...s.args];
|
|
1418
|
+
o === "npm" && i.unshift("--yes"), await new Promise((c, p) => {
|
|
1419
|
+
const d = I(s.command, i, {
|
|
1420
|
+
cwd: t,
|
|
1421
|
+
stdio: "inherit"
|
|
1422
|
+
});
|
|
1423
|
+
d.on("error", p), d.on("exit", (m) => {
|
|
1424
|
+
if (m === 0) {
|
|
1425
|
+
c();
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
p(
|
|
1429
|
+
new Error(`${s.command} exited with code ${m ?? "unknown"}`)
|
|
1430
|
+
);
|
|
1431
|
+
});
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
async function w(t, e, n, o) {
|
|
1435
|
+
if (o != null && o.executeCommand) {
|
|
1436
|
+
await o.executeCommand(t, e, n);
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
await Ct(t, e, n);
|
|
1440
|
+
}
|
|
1441
|
+
function $t(t) {
|
|
1442
|
+
const e = r.join(t, "package.json");
|
|
1443
|
+
if (!v(e))
|
|
1444
|
+
return /* @__PURE__ */ new Set();
|
|
1445
|
+
const n = JSON.parse(P(e, "utf8"));
|
|
1446
|
+
return /* @__PURE__ */ new Set([
|
|
1447
|
+
...Object.keys(n.dependencies ?? {}),
|
|
1448
|
+
...Object.keys(n.devDependencies ?? {}),
|
|
1449
|
+
...Object.keys(n.optionalDependencies ?? {}),
|
|
1450
|
+
...Object.keys(n.peerDependencies ?? {})
|
|
1451
|
+
]);
|
|
1452
|
+
}
|
|
1453
|
+
async function C(t, e, n) {
|
|
1454
|
+
if (e.length === 0)
|
|
1455
|
+
return [];
|
|
1456
|
+
const o = $t(t), s = [...new Set(e)].filter((i) => !o.has(i));
|
|
1457
|
+
return s.length === 0 ? [] : (await w(t, "install", s, n), s);
|
|
1458
|
+
}
|
|
1459
|
+
function b(t) {
|
|
1460
|
+
return xt().includes(t);
|
|
1461
|
+
}
|
|
1462
|
+
function Pt(t) {
|
|
1463
|
+
return [
|
|
1464
|
+
...new Set(
|
|
1465
|
+
t.flatMap((e) => _t[e] ?? [])
|
|
1466
|
+
)
|
|
1467
|
+
];
|
|
1468
|
+
}
|
|
1469
|
+
function Tt(t, e) {
|
|
1470
|
+
const n = r.join(e, t);
|
|
1471
|
+
f(n, { recursive: !0 });
|
|
1472
|
+
for (const [o, s] of Object.entries(x)) {
|
|
1473
|
+
if (y(o) !== t)
|
|
1474
|
+
continue;
|
|
1475
|
+
const i = yt(o);
|
|
1476
|
+
if (!i)
|
|
1477
|
+
continue;
|
|
1478
|
+
const l = r.join(n, i);
|
|
1479
|
+
f(r.dirname(l), { recursive: !0 }), _(l, s, "utf8");
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
async function Lt(t, e, n) {
|
|
1483
|
+
if (e.length === 0)
|
|
1484
|
+
return { components: [], packages: [] };
|
|
1485
|
+
const o = r.join(t, "src", "lib", "components", "ui");
|
|
1486
|
+
f(o, { recursive: !0 });
|
|
1487
|
+
const i = [...new Set(e)].filter(
|
|
1488
|
+
(a) => !v(r.join(o, a))
|
|
1489
|
+
);
|
|
1490
|
+
if (i.length === 0)
|
|
1491
|
+
return { components: [], packages: [] };
|
|
1492
|
+
const l = new Set(i.filter(b)), c = new Set(
|
|
1493
|
+
i.filter((a) => !b(a))
|
|
1494
|
+
);
|
|
1495
|
+
for (const a of [...l])
|
|
1496
|
+
for (const u of ht[a] ?? [])
|
|
1497
|
+
v(r.join(o, u)) || (b(u) ? l.add(u) : c.add(u));
|
|
1498
|
+
const p = [];
|
|
1499
|
+
for (const a of [...l].sort())
|
|
1500
|
+
Tt(a, o), p.push(a), c.delete(a);
|
|
1501
|
+
const d = await C(
|
|
1502
|
+
t,
|
|
1503
|
+
Pt([...l]),
|
|
1504
|
+
n
|
|
1505
|
+
), m = [...c].sort();
|
|
1506
|
+
return m.length > 0 && (await w(
|
|
1507
|
+
t,
|
|
1508
|
+
"execute",
|
|
1509
|
+
["shadcn-svelte", "add", "--yes", "--overwrite", ...m],
|
|
1510
|
+
n
|
|
1511
|
+
), p.push(...m)), {
|
|
1512
|
+
components: [...new Set(p)],
|
|
1513
|
+
packages: d
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
async function Ft(t, e, n) {
|
|
1517
|
+
for (const i of t.creates)
|
|
1518
|
+
h(g(e.root, i.path), i.content);
|
|
1519
|
+
for (const i of t.modifies)
|
|
1520
|
+
h(g(e.root, i.path), i.content);
|
|
1521
|
+
for (const i of t.deletes)
|
|
1522
|
+
wt(g(e.root, i.path));
|
|
1523
|
+
const o = await C(
|
|
1524
|
+
e.root,
|
|
1525
|
+
t.packages,
|
|
1526
|
+
n
|
|
1527
|
+
), s = await Lt(
|
|
1528
|
+
e.root,
|
|
1529
|
+
t.components,
|
|
1530
|
+
n
|
|
1531
|
+
);
|
|
1532
|
+
return {
|
|
1533
|
+
...t,
|
|
1534
|
+
components: s.components,
|
|
1535
|
+
packages: [.../* @__PURE__ */ new Set([...o, ...s.packages])]
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
export {
|
|
1539
|
+
Ft as writeResult
|
|
1540
|
+
};
|
|
1541
|
+
//# sourceMappingURL=write-result-DG5OAbe1.js.map
|