@kitcms/ui 0.0.0-stage → 0.1.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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -2
  3. package/package.json +47 -3
  4. package/src/index.ts +1 -0
  5. package/src/lib/Admin.svelte +345 -0
  6. package/src/lib/fields/ArrayField.svelte +134 -0
  7. package/src/lib/fields/BlocksField.svelte +201 -0
  8. package/src/lib/fields/CheckboxField.svelte +48 -0
  9. package/src/lib/fields/DateField.svelte +70 -0
  10. package/src/lib/fields/EmailField.svelte +39 -0
  11. package/src/lib/fields/FieldShell.svelte +70 -0
  12. package/src/lib/fields/GroupField.svelte +40 -0
  13. package/src/lib/fields/JsonField.svelte +74 -0
  14. package/src/lib/fields/NumberField.svelte +51 -0
  15. package/src/lib/fields/RelationshipField.svelte +11 -0
  16. package/src/lib/fields/RenderFields.svelte +32 -0
  17. package/src/lib/fields/RenderNodes.svelte +147 -0
  18. package/src/lib/fields/RichTextField.svelte +310 -0
  19. package/src/lib/fields/RowCard.svelte +229 -0
  20. package/src/lib/fields/SelectField.svelte +43 -0
  21. package/src/lib/fields/SlugField.svelte +85 -0
  22. package/src/lib/fields/TextField.svelte +41 -0
  23. package/src/lib/fields/TextareaField.svelte +40 -0
  24. package/src/lib/fields/UploadField.svelte +26 -0
  25. package/src/lib/fields/registry.ts +41 -0
  26. package/src/lib/fields/relation/RelationField.svelte +256 -0
  27. package/src/lib/fields/relation/RelationPicker.svelte +246 -0
  28. package/src/lib/fields/relation/api.ts +66 -0
  29. package/src/lib/fields/rowDrag.svelte.ts +41 -0
  30. package/src/lib/fields/rows.ts +70 -0
  31. package/src/lib/fields/types.ts +35 -0
  32. package/src/lib/form/context.ts +26 -0
  33. package/src/lib/format.ts +106 -0
  34. package/src/lib/index.ts +20 -0
  35. package/src/lib/links.ts +32 -0
  36. package/src/lib/media/MediaPicker.svelte +327 -0
  37. package/src/lib/media/util.ts +36 -0
  38. package/src/lib/preview/BlocksPreview.svelte +37 -0
  39. package/src/lib/preview/LazyPreview.svelte +75 -0
  40. package/src/lib/preview/PreviewPane.svelte +98 -0
  41. package/src/lib/preview/blocks.ts +39 -0
  42. package/src/lib/preview/load.ts +21 -0
  43. package/src/lib/preview/relations.ts +70 -0
  44. package/src/lib/preview/types.ts +75 -0
  45. package/src/lib/preview/useRelation.svelte.ts +58 -0
  46. package/src/lib/theme.css +193 -0
  47. package/src/lib/upload/FileUpload.svelte +216 -0
  48. package/src/lib/views/Dashboard.svelte +64 -0
  49. package/src/lib/views/Edit.svelte +557 -0
  50. package/src/lib/views/FirstUser.svelte +63 -0
  51. package/src/lib/views/List.svelte +557 -0
  52. package/src/lib/views/Login.svelte +58 -0
  53. package/src/lib/views/Panel.svelte +175 -0
  54. package/src/lib/views/Versions.svelte +144 -0
@@ -0,0 +1,43 @@
1
+ <script lang="ts">
2
+ // Single choice from `field.options`. Same structure as TextField (the reference); see ./types.ts.
3
+ // The empty option stands for "no value" (stored null) unless the field is required and set.
4
+ import type { FieldOf } from '@kitcms/core/client';
5
+ import { getFormContext } from '../form/context';
6
+ import FieldShell from './FieldShell.svelte';
7
+ import { fieldId, type FieldProps } from './types';
8
+
9
+ let { field, path, value = $bindable() }: FieldProps<FieldOf<'select', 'client'>> = $props();
10
+
11
+ const ctx = getFormContext();
12
+ const id = $derived(fieldId(path));
13
+ const readOnly = $derived(Boolean(field.admin.readOnly) || ctx.readOnly);
14
+ const describedBy = $derived(
15
+ [field.admin.description && `${id}-desc`, ctx.errors[path] && `${id}-err`].filter(Boolean).join(' ') ||
16
+ undefined,
17
+ );
18
+ const showEmpty = $derived(!(field.required && typeof value === 'string' && value !== ''));
19
+
20
+ // The form state may hold null; the select works with strings (function binding, Svelte ≥ 5.9).
21
+ const get = () => (typeof value === 'string' ? value : '');
22
+ const set = (v: string) => {
23
+ value = v === '' ? null : v;
24
+ };
25
+ </script>
26
+
27
+ <FieldShell {field} {path}>
28
+ <select
29
+ {id}
30
+ class="kc-input"
31
+ name={path}
32
+ bind:value={get, set}
33
+ required={field.required}
34
+ disabled={readOnly}
35
+ aria-invalid={ctx.errors[path] ? 'true' : undefined}
36
+ aria-describedby={describedBy}
37
+ >
38
+ {#if showEmpty}<option value="">—</option>{/if}
39
+ {#each field.options as option (option.value)}
40
+ <option value={option.value}>{option.label}</option>
41
+ {/each}
42
+ </select>
43
+ </FieldShell>
@@ -0,0 +1,85 @@
1
+ <script lang="ts">
2
+ // URL slug. Same structure as TextField (the reference); see ./types.ts for the contract.
3
+ // "Generate" normalizes the current text with `slugify`. The server fills an empty slug from
4
+ // the `from` field, so an empty value is valid.
5
+ import type { FieldOf } from '@kitcms/core/client';
6
+ import { slugify } from '@kitcms/core/client';
7
+ import { getFormContext } from '../form/context';
8
+ import FieldShell from './FieldShell.svelte';
9
+ import { fieldId, type FieldProps } from './types';
10
+
11
+ let { field, path, value = $bindable() }: FieldProps<FieldOf<'slug', 'client'>> = $props();
12
+
13
+ const ctx = getFormContext();
14
+ const id = $derived(fieldId(path));
15
+ const readOnly = $derived(Boolean(field.admin.readOnly) || ctx.readOnly);
16
+ const hintId = $derived(`${id}-hint`);
17
+ const showHint = $derived(Boolean(field.from) && (typeof value !== 'string' || value === ''));
18
+ const describedBy = $derived(
19
+ [field.admin.description && `${id}-desc`, showHint && hintId, ctx.errors[path] && `${id}-err`]
20
+ .filter(Boolean)
21
+ .join(' ') || undefined,
22
+ );
23
+
24
+ // The form state may hold null; the input works with strings (function binding, Svelte ≥ 5.9).
25
+ const get = () => (typeof value === 'string' ? value : '');
26
+ const set = (v: string) => {
27
+ value = v === '' ? null : v;
28
+ };
29
+
30
+ const normalize = () => {
31
+ const slug = slugify(typeof value === 'string' ? value : '');
32
+ value = slug === '' ? null : slug;
33
+ };
34
+ </script>
35
+
36
+ <FieldShell {field} {path}>
37
+ <div class="kc-slug">
38
+ <input
39
+ {id}
40
+ class="kc-input"
41
+ type="text"
42
+ name={path}
43
+ bind:value={get, set}
44
+ required={field.required}
45
+ placeholder={field.admin.placeholder}
46
+ disabled={readOnly}
47
+ aria-invalid={ctx.errors[path] ? 'true' : undefined}
48
+ aria-describedby={describedBy}
49
+ />
50
+ {#if !readOnly}
51
+ <button type="button" class="kc-slug__generate" onclick={normalize}>Generate</button>
52
+ {/if}
53
+ </div>
54
+ {#if showHint}
55
+ <p class="kc-slug__hint" id={hintId}>Leave empty to generate from {field.from}</p>
56
+ {/if}
57
+ </FieldShell>
58
+
59
+ <style>
60
+ .kc-slug {
61
+ display: flex;
62
+ gap: 0.5rem;
63
+ align-items: center;
64
+ }
65
+ .kc-slug .kc-input {
66
+ flex: 1;
67
+ min-width: 0;
68
+ }
69
+ .kc-slug__generate {
70
+ flex: none;
71
+ font: inherit;
72
+ font-size: 0.875rem;
73
+ padding: 0.375rem 0.75rem;
74
+ border: 1px solid var(--kc-border, currentColor);
75
+ border-radius: 0.375rem;
76
+ background: transparent;
77
+ color: var(--kc-text);
78
+ cursor: pointer;
79
+ }
80
+ .kc-slug__hint {
81
+ margin: 0;
82
+ font-size: 0.8125rem;
83
+ color: var(--kc-muted);
84
+ }
85
+ </style>
@@ -0,0 +1,41 @@
1
+ <script lang="ts">
2
+ // THE REFERENCE FIELD COMPONENT. Simple field components (textarea, number, email, slug, date,
3
+ // select, checkbox) follow this file's structure. See ./types.ts for the contract.
4
+ import type { FieldOf } from '@kitcms/core/client';
5
+ import { getFormContext } from '../form/context';
6
+ import FieldShell from './FieldShell.svelte';
7
+ import { fieldId, type FieldProps } from './types';
8
+
9
+ let { field, path, value = $bindable() }: FieldProps<FieldOf<'text', 'client'>> = $props();
10
+
11
+ const ctx = getFormContext();
12
+ const id = $derived(fieldId(path));
13
+ const readOnly = $derived(Boolean(field.admin.readOnly) || ctx.readOnly);
14
+ const describedBy = $derived(
15
+ [field.admin.description && `${id}-desc`, ctx.errors[path] && `${id}-err`].filter(Boolean).join(' ') ||
16
+ undefined,
17
+ );
18
+
19
+ // The form state may hold null; the input works with strings (function binding, Svelte ≥ 5.9).
20
+ const get = () => (typeof value === 'string' ? value : '');
21
+ const set = (v: string) => {
22
+ value = v === '' ? null : v;
23
+ };
24
+ </script>
25
+
26
+ <FieldShell {field} {path}>
27
+ <input
28
+ {id}
29
+ class="kc-input"
30
+ type="text"
31
+ name={path}
32
+ bind:value={get, set}
33
+ required={field.required}
34
+ minlength={field.minLength}
35
+ maxlength={field.maxLength}
36
+ placeholder={field.admin.placeholder}
37
+ disabled={readOnly}
38
+ aria-invalid={ctx.errors[path] ? 'true' : undefined}
39
+ aria-describedby={describedBy}
40
+ />
41
+ </FieldShell>
@@ -0,0 +1,40 @@
1
+ <script lang="ts">
2
+ // Multi-line text. Same structure as TextField (the reference); see ./types.ts for the contract.
3
+ import type { FieldOf } from '@kitcms/core/client';
4
+ import { getFormContext } from '../form/context';
5
+ import FieldShell from './FieldShell.svelte';
6
+ import { fieldId, type FieldProps } from './types';
7
+
8
+ let { field, path, value = $bindable() }: FieldProps<FieldOf<'textarea', 'client'>> = $props();
9
+
10
+ const ctx = getFormContext();
11
+ const id = $derived(fieldId(path));
12
+ const readOnly = $derived(Boolean(field.admin.readOnly) || ctx.readOnly);
13
+ const describedBy = $derived(
14
+ [field.admin.description && `${id}-desc`, ctx.errors[path] && `${id}-err`].filter(Boolean).join(' ') ||
15
+ undefined,
16
+ );
17
+
18
+ // The form state may hold null; the input works with strings (function binding, Svelte ≥ 5.9).
19
+ const get = () => (typeof value === 'string' ? value : '');
20
+ const set = (v: string) => {
21
+ value = v === '' ? null : v;
22
+ };
23
+ </script>
24
+
25
+ <FieldShell {field} {path}>
26
+ <textarea
27
+ {id}
28
+ class="kc-input"
29
+ name={path}
30
+ rows={field.admin.rows ?? 4}
31
+ bind:value={get, set}
32
+ required={field.required}
33
+ minlength={field.minLength}
34
+ maxlength={field.maxLength}
35
+ placeholder={field.admin.placeholder}
36
+ disabled={readOnly}
37
+ aria-invalid={ctx.errors[path] ? 'true' : undefined}
38
+ aria-describedby={describedBy}
39
+ ></textarea>
40
+ </FieldShell>
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ // Upload: a reference (or ordered list) to documents of an upload collection, shown with thumbnails.
3
+ // Besides the search combobox, "Browse library" opens the media picker modal.
4
+ import type { FieldOf } from '@kitcms/core/client';
5
+ import MediaPicker from '../media/MediaPicker.svelte';
6
+ import RelationField from './relation/RelationField.svelte';
7
+ import type { FieldProps } from './types';
8
+
9
+ let { field, path, value = $bindable() }: FieldProps<FieldOf<'relationship' | 'upload', 'client'>> = $props();
10
+
11
+ let open = $state(false);
12
+ </script>
13
+
14
+ <RelationField {field} {path} bind:value kind="upload">
15
+ {#snippet browse({ select, disabled, selectedIds })}
16
+ <button type="button" class="kc-btn" {disabled} onclick={() => (open = true)}>Browse library</button>
17
+ <MediaPicker
18
+ bind:open
19
+ collection={field.relationTo}
20
+ multiple={field.hasMany}
21
+ max={field.hasMany ? field.maxRows : undefined}
22
+ {selectedIds}
23
+ onselect={(picked) => picked.forEach(select)}
24
+ />
25
+ {/snippet}
26
+ </RelationField>
@@ -0,0 +1,41 @@
1
+ // Field type → component. Every data field type must have an entry before the admin ships.
2
+ import type { Component } from 'svelte';
3
+ import type { ClientField } from '@kitcms/core/client';
4
+ import JsonField from './JsonField.svelte';
5
+ import TextField from './TextField.svelte';
6
+ import TextareaField from './TextareaField.svelte';
7
+ import EmailField from './EmailField.svelte';
8
+ import NumberField from './NumberField.svelte';
9
+ import CheckboxField from './CheckboxField.svelte';
10
+ import SelectField from './SelectField.svelte';
11
+ import DateField from './DateField.svelte';
12
+ import SlugField from './SlugField.svelte';
13
+ import GroupField from './GroupField.svelte';
14
+ import ArrayField from './ArrayField.svelte';
15
+ import BlocksField from './BlocksField.svelte';
16
+ import RelationshipField from './RelationshipField.svelte';
17
+ import UploadField from './UploadField.svelte';
18
+ import RichTextField from './RichTextField.svelte';
19
+ import type { FieldProps } from './types';
20
+
21
+ // Components are typed per field type; the renderer only ever passes the matching field.
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ type AnyFieldComponent = Component<FieldProps<any>, object, 'value'>;
24
+
25
+ export const fieldComponents: Partial<Record<ClientField['type'], AnyFieldComponent>> = {
26
+ text: TextField,
27
+ json: JsonField,
28
+ textarea: TextareaField,
29
+ email: EmailField,
30
+ number: NumberField,
31
+ checkbox: CheckboxField,
32
+ select: SelectField,
33
+ date: DateField,
34
+ slug: SlugField,
35
+ group: GroupField,
36
+ array: ArrayField,
37
+ blocks: BlocksField,
38
+ relationship: RelationshipField,
39
+ upload: UploadField,
40
+ richText: RichTextField,
41
+ };
@@ -0,0 +1,256 @@
1
+ <script lang="ts">
2
+ // Shared implementation of relationship and upload fields (see ../RelationshipField.svelte and
3
+ // ../UploadField.svelte). Values are document ids: a string|null, or string[] when hasMany.
4
+ // Hidden inputs are SSR-rendered, so existing values survive a no-JS submit; titles and
5
+ // thumbnails are resolved in the browser through the lookup endpoint (SSR shows the id).
6
+ import { tick, untrack, type Snippet } from 'svelte';
7
+ import type { FieldOf } from '@kitcms/core/client';
8
+ import { FORM } from '@kitcms/core/client';
9
+ import { getFormContext } from '../../form/context';
10
+ import { docHref } from '../../links';
11
+ import FieldShell from '../FieldShell.svelte';
12
+ import { RowDrag } from '../rowDrag.svelte';
13
+ import { idOf, moveItem } from '../rows';
14
+ import { fieldId } from '../types';
15
+ import { isImage, lookupDocs, type PickerDoc } from './api';
16
+ import RelationPicker from './RelationPicker.svelte';
17
+
18
+ let {
19
+ field,
20
+ path,
21
+ value = $bindable(),
22
+ kind,
23
+ browse,
24
+ }: {
25
+ field: FieldOf<'relationship' | 'upload', 'client'>;
26
+ path: string;
27
+ value: unknown;
28
+ kind: 'relationship' | 'upload';
29
+ /**
30
+ * EXTENSION POINT (task "Media library grid + <MediaPicker>"): rendered next to the search
31
+ * box. Call `select(doc)` to pick a document, e.g. from a media-library modal or after an
32
+ * upload finishes.
33
+ */
34
+ browse?: Snippet<[{ select: (doc: PickerDoc) => void; disabled: boolean; selectedIds: string[] }]>;
35
+ } = $props();
36
+
37
+ const ctx = getFormContext();
38
+ const id = $derived(fieldId(path));
39
+ const readOnly = $derived(Boolean(field.admin.readOnly) || ctx.readOnly);
40
+ const describedBy = $derived(
41
+ [field.admin.description && `${id}-desc`, ctx.errors[path] && `${id}-err`].filter(Boolean).join(' ') ||
42
+ undefined,
43
+ );
44
+
45
+ const many = $derived(field.hasMany);
46
+ const ids = $derived.by((): string[] => {
47
+ if (many) return Array.isArray(value) ? value.map(idOf).filter((v): v is string => v !== null) : [];
48
+ const one = idOf(value);
49
+ return one ? [one] : [];
50
+ });
51
+ const full = $derived(many && field.maxRows !== undefined && ids.length >= field.maxRows);
52
+ const atMin = $derived(many && field.minRows !== undefined && ids.length <= field.minRows);
53
+
54
+ // Resolved documents by id. Starts empty (SSR shows ids); filled by lookups and picks.
55
+ let docs = $state<Record<string, PickerDoc>>({});
56
+ // Plain (non-reactive) bookkeeping, deliberately not a SvelteSet.
57
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity
58
+ const requested = new Set<string>();
59
+
60
+ $effect(() => {
61
+ const missing = ids.filter((i) => !requested.has(i));
62
+ if (missing.length === 0) return;
63
+ for (const i of missing) requested.add(i);
64
+ const controller = new AbortController();
65
+ lookupDocs(field.relationTo, missing, controller.signal)
66
+ .then((found) => {
67
+ untrack(() => {
68
+ for (const d of found) docs[d.id] = d;
69
+ });
70
+ })
71
+ .catch(() => {
72
+ // Offline or no access: keep showing ids. Allow a retry on the next change.
73
+ for (const i of missing) requested.delete(i);
74
+ });
75
+ return () => controller.abort();
76
+ });
77
+
78
+ function setIds(next: string[]) {
79
+ value = many ? next : (next[0] ?? null);
80
+ }
81
+ function select(doc: PickerDoc) {
82
+ if (readOnly) return;
83
+ docs[doc.id] = doc;
84
+ requested.add(doc.id);
85
+ if (many) {
86
+ if (!ids.includes(doc.id) && !full) setIds([...ids, doc.id]);
87
+ } else setIds([doc.id]);
88
+ }
89
+ let searchEl: HTMLElement | undefined = $state();
90
+ async function remove(i: number) {
91
+ if (atMin) return;
92
+ setIds(ids.filter((_, j) => j !== i));
93
+ await tick();
94
+ searchEl?.querySelector<HTMLElement>('input[role="combobox"]')?.focus();
95
+ }
96
+ const move = (from: number, to: number) => setIds(moveItem(ids, from, to));
97
+ const drag = new RowDrag(move);
98
+
99
+ const noun = $derived(kind === 'upload' ? 'file' : field.relationTo);
100
+ </script>
101
+
102
+ <!-- eslint-disable svelte/no-navigation-without-resolve -- hrefs come from ../../links, which calls resolve() -->
103
+ {#snippet entry(docId: string, i: number)}
104
+ {@const doc = docs[docId]}
105
+ <span class="kc-rel__item-main">
106
+ {#if kind === 'upload'}
107
+ {#if isImage(doc)}
108
+ <img class="kc-rel__thumb" src={doc.url} alt="" />
109
+ {:else}
110
+ <span class="kc-rel__thumb kc-rel__file" aria-hidden="true">&#128196;</span>
111
+ {/if}
112
+ <span class="kc-rel__title">{doc?.filename ?? doc?.title ?? docId}</span>
113
+ {:else}
114
+ <span class="kc-rel__title">{doc?.title ?? docId}</span>
115
+ {/if}
116
+ </span>
117
+ <a class="kc-btn kc-btn--ghost" href={docHref(field.relationTo, docId)} target="_blank" rel="noreferrer"
118
+ aria-label="Open {doc?.title ?? docId} in a new tab">Open</a
119
+ >
120
+ {#if !readOnly}
121
+ {#if many}
122
+ <button type="button" class="kc-btn kc-btn--ghost" aria-label="Move {doc?.title ?? docId} up" disabled={i === 0}
123
+ onclick={() => move(i, i - 1)}>&uarr;</button
124
+ >
125
+ <button type="button" class="kc-btn kc-btn--ghost" aria-label="Move {doc?.title ?? docId} down"
126
+ disabled={i === ids.length - 1} onclick={() => move(i, i + 1)}>&darr;</button
127
+ >
128
+ {/if}
129
+ <button type="button" class="kc-btn kc-btn--ghost kc-btn--danger" aria-label="{many ? 'Remove' : 'Clear'} {doc?.title ?? docId}"
130
+ disabled={atMin} onclick={() => remove(i)}>{many ? 'Remove' : 'Clear'}</button
131
+ >
132
+ {/if}
133
+ {/snippet}
134
+
135
+ <FieldShell {field} {path} as={many ? 'fieldset' : 'div'}>
136
+ {#if many}
137
+ <input type="hidden" name={FORM.marker(path)} value="1" disabled={readOnly} />
138
+ {#each ids as docId (docId)}
139
+ <input type="hidden" name={path} value={docId} disabled={readOnly} />
140
+ {/each}
141
+ {:else}
142
+ <input type="hidden" name={path} value={ids[0] ?? ''} disabled={readOnly} />
143
+ {/if}
144
+
145
+ {#if many && (field.minRows !== undefined || field.maxRows !== undefined)}
146
+ <p class="kc-muted kc-rel__hint">
147
+ {ids.length} selected{#if field.minRows !== undefined}, min {field.minRows}{/if}{#if field.maxRows !== undefined},
148
+ max {field.maxRows}{/if}
149
+ </p>
150
+ {/if}
151
+
152
+ {#if ids.length > 0}
153
+ <ul class="kc-rel__list" aria-label="Selected {noun}">
154
+ {#each ids as docId, i (docId)}
155
+ <li
156
+ class="kc-card kc-rel__item"
157
+ class:kc-rel__item--dragging={drag.from === i}
158
+ class:kc-rel__item--drop={drag.over === i && drag.from !== i}
159
+ ondragover={(e) => drag.dragover(i, e)}
160
+ ondrop={(e) => drag.drop(i, e)}
161
+ >
162
+ {#if many && !readOnly}
163
+ <button type="button" class="kc-btn kc-btn--ghost kc-rel__handle" draggable="true"
164
+ aria-label="Drag to reorder {docs[docId]?.title ?? docId}"
165
+ ondragstart={(e) => drag.start(i, e, (e.currentTarget as HTMLElement).closest('li'))}
166
+ ondragend={drag.end}>&#8942;&#8942;</button
167
+ >
168
+ {/if}
169
+ {@render entry(docId, i)}
170
+ </li>
171
+ {/each}
172
+ </ul>
173
+ {/if}
174
+
175
+ {#if !readOnly && !full}
176
+ <div class="kc-rel__search" bind:this={searchEl}>
177
+ <RelationPicker
178
+ {id}
179
+ collection={field.relationTo}
180
+ {kind}
181
+ exclude={many ? ids : []}
182
+ placeholder={many || ids.length === 0 ? `Search ${noun}...` : `Search to replace...`}
183
+ {describedBy}
184
+ invalid={Boolean(ctx.errors[path])}
185
+ onselect={select}
186
+ />
187
+ {#if browse}{@render browse({ select, disabled: readOnly || full, selectedIds: ids })}{/if}
188
+ </div>
189
+ {:else if ids.length === 0}
190
+ <p class="kc-muted">Nothing selected.</p>
191
+ {/if}
192
+ </FieldShell>
193
+
194
+ <style>
195
+ .kc-rel__hint {
196
+ margin: 0;
197
+ font-size: 0.8125rem;
198
+ }
199
+ .kc-rel__list {
200
+ list-style: none;
201
+ margin: 0;
202
+ padding: 0;
203
+ display: grid;
204
+ gap: 0.375rem;
205
+ }
206
+ .kc-rel__item {
207
+ display: flex;
208
+ align-items: center;
209
+ gap: 0.25rem;
210
+ padding: 0.375rem 0.5rem;
211
+ }
212
+ .kc-rel__item--dragging {
213
+ opacity: 0.5;
214
+ }
215
+ .kc-rel__item--drop {
216
+ border-color: var(--kc-accent);
217
+ }
218
+ .kc-rel__item-main {
219
+ flex: 1;
220
+ min-width: 0;
221
+ display: flex;
222
+ align-items: center;
223
+ gap: 0.5rem;
224
+ }
225
+ .kc-rel__title {
226
+ overflow: hidden;
227
+ text-overflow: ellipsis;
228
+ white-space: nowrap;
229
+ }
230
+ .kc-rel__thumb {
231
+ width: 2.5rem;
232
+ height: 2.5rem;
233
+ flex: none;
234
+ object-fit: cover;
235
+ border-radius: calc(var(--kc-radius) - 2px);
236
+ background: var(--kc-bg);
237
+ }
238
+ .kc-rel__file {
239
+ display: grid;
240
+ place-items: center;
241
+ font-size: 1.25rem;
242
+ }
243
+ .kc-rel__handle {
244
+ cursor: grab;
245
+ padding-inline: 0.375rem;
246
+ letter-spacing: -0.2em;
247
+ }
248
+ .kc-rel__search {
249
+ display: flex;
250
+ gap: 0.5rem;
251
+ align-items: start;
252
+ }
253
+ .kc-rel__search > :global(:first-child) {
254
+ flex: 1;
255
+ }
256
+ </style>