@velastack/patterns 0.0.21 → 0.0.23

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