sandcms 0.6.2 → 0.6.3

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 (159) hide show
  1. package/README.md +1 -1
  2. package/dist/admin/Account.svelte +284 -83
  3. package/dist/admin/ApiKeys.svelte +146 -79
  4. package/dist/admin/AssetAttachment.svelte +9 -9
  5. package/dist/admin/BlueprintFields.svelte +20 -2
  6. package/dist/admin/BlueprintFields.svelte.d.ts +2 -0
  7. package/dist/admin/Collection.svelte +111 -54
  8. package/dist/admin/Dashboard.svelte +3 -37
  9. package/dist/admin/DateField.svelte +75 -0
  10. package/dist/admin/DateField.svelte.d.ts +11 -0
  11. package/dist/admin/Editor.svelte +71 -65
  12. package/dist/admin/Fields.svelte +24 -16
  13. package/dist/admin/FocusPicker.svelte +1 -2
  14. package/dist/admin/Gallery.svelte +0 -1
  15. package/dist/admin/GlobalSearch.svelte +54 -26
  16. package/dist/admin/HoverHint.svelte +37 -0
  17. package/dist/admin/HoverHint.svelte.d.ts +8 -0
  18. package/dist/admin/Inbox.svelte +6 -11
  19. package/dist/admin/LinkField.svelte +129 -64
  20. package/dist/admin/Login.svelte +0 -1
  21. package/dist/admin/MediaLibrary.svelte +61 -50
  22. package/dist/admin/MediaPicker.svelte +57 -42
  23. package/dist/admin/NotificationSettings.svelte +35 -27
  24. package/dist/admin/RichText.svelte +2 -2
  25. package/dist/admin/RowMenu.svelte +28 -0
  26. package/dist/admin/RowMenu.svelte.d.ts +10 -0
  27. package/dist/admin/SearchList.svelte +51 -14
  28. package/dist/admin/Shell.svelte +64 -29
  29. package/dist/admin/Users.svelte +106 -50
  30. package/dist/admin/client.d.ts +2 -0
  31. package/dist/admin/client.js +18 -0
  32. package/dist/admin/components/ui/calendar/calendar-caption.svelte +76 -0
  33. package/dist/admin/components/ui/calendar/calendar-caption.svelte.d.ts +19 -0
  34. package/dist/admin/components/ui/calendar/calendar-cell.svelte +19 -0
  35. package/dist/admin/components/ui/calendar/calendar-cell.svelte.d.ts +4 -0
  36. package/dist/admin/components/ui/calendar/calendar-day.svelte +33 -0
  37. package/dist/admin/components/ui/calendar/calendar-day.svelte.d.ts +4 -0
  38. package/dist/admin/components/ui/calendar/calendar-grid-body.svelte +12 -0
  39. package/dist/admin/components/ui/calendar/calendar-grid-body.svelte.d.ts +4 -0
  40. package/dist/admin/components/ui/calendar/calendar-grid-head.svelte +12 -0
  41. package/dist/admin/components/ui/calendar/calendar-grid-head.svelte.d.ts +4 -0
  42. package/dist/admin/components/ui/calendar/calendar-grid-row.svelte +12 -0
  43. package/dist/admin/components/ui/calendar/calendar-grid-row.svelte.d.ts +4 -0
  44. package/dist/admin/components/ui/calendar/calendar-grid.svelte +16 -0
  45. package/dist/admin/components/ui/calendar/calendar-grid.svelte.d.ts +4 -0
  46. package/dist/admin/components/ui/calendar/calendar-head-cell.svelte +19 -0
  47. package/dist/admin/components/ui/calendar/calendar-head-cell.svelte.d.ts +4 -0
  48. package/dist/admin/components/ui/calendar/calendar-header.svelte +19 -0
  49. package/dist/admin/components/ui/calendar/calendar-header.svelte.d.ts +4 -0
  50. package/dist/admin/components/ui/calendar/calendar-heading.svelte +16 -0
  51. package/dist/admin/components/ui/calendar/calendar-heading.svelte.d.ts +4 -0
  52. package/dist/admin/components/ui/calendar/calendar-month-select.svelte +48 -0
  53. package/dist/admin/components/ui/calendar/calendar-month-select.svelte.d.ts +4 -0
  54. package/dist/admin/components/ui/calendar/calendar-month.svelte +15 -0
  55. package/dist/admin/components/ui/calendar/calendar-month.svelte.d.ts +5 -0
  56. package/dist/admin/components/ui/calendar/calendar-months.svelte +19 -0
  57. package/dist/admin/components/ui/calendar/calendar-months.svelte.d.ts +5 -0
  58. package/dist/admin/components/ui/calendar/calendar-nav.svelte +19 -0
  59. package/dist/admin/components/ui/calendar/calendar-nav.svelte.d.ts +5 -0
  60. package/dist/admin/components/ui/calendar/calendar-next-button.svelte +37 -0
  61. package/dist/admin/components/ui/calendar/calendar-next-button.svelte.d.ts +8 -0
  62. package/dist/admin/components/ui/calendar/calendar-prev-button.svelte +37 -0
  63. package/dist/admin/components/ui/calendar/calendar-prev-button.svelte.d.ts +8 -0
  64. package/dist/admin/components/ui/calendar/calendar-year-select.svelte +47 -0
  65. package/dist/admin/components/ui/calendar/calendar-year-select.svelte.d.ts +4 -0
  66. package/dist/admin/components/ui/calendar/calendar.svelte +115 -0
  67. package/dist/admin/components/ui/calendar/calendar.svelte.d.ts +21 -0
  68. package/dist/admin/components/ui/calendar/index.d.ts +19 -0
  69. package/dist/admin/components/ui/calendar/index.js +21 -0
  70. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-group.svelte +16 -0
  71. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-group.svelte.d.ts +4 -0
  72. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +46 -0
  73. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte.d.ts +9 -0
  74. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-content.svelte +31 -0
  75. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-content.svelte.d.ts +10 -0
  76. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte +22 -0
  77. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte.d.ts +8 -0
  78. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group.svelte +7 -0
  79. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group.svelte.d.ts +4 -0
  80. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-item.svelte +27 -0
  81. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +8 -0
  82. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-label.svelte +24 -0
  83. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-label.svelte.d.ts +8 -0
  84. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-portal.svelte +7 -0
  85. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-portal.svelte.d.ts +3 -0
  86. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte +16 -0
  87. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte.d.ts +4 -0
  88. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +36 -0
  89. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte.d.ts +4 -0
  90. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-separator.svelte +17 -0
  91. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-separator.svelte.d.ts +4 -0
  92. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte +23 -0
  93. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte.d.ts +5 -0
  94. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +31 -0
  95. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte.d.ts +10 -0
  96. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +29 -0
  97. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte.d.ts +7 -0
  98. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub.svelte +7 -0
  99. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub.svelte.d.ts +3 -0
  100. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-trigger.svelte +7 -0
  101. package/dist/admin/components/ui/dropdown-menu/dropdown-menu-trigger.svelte.d.ts +4 -0
  102. package/dist/admin/components/ui/dropdown-menu/dropdown-menu.svelte +7 -0
  103. package/dist/admin/components/ui/dropdown-menu/dropdown-menu.svelte.d.ts +3 -0
  104. package/dist/admin/components/ui/dropdown-menu/index.d.ts +18 -0
  105. package/dist/admin/components/ui/dropdown-menu/index.js +18 -0
  106. package/dist/admin/components/ui/input-otp/index.d.ts +5 -0
  107. package/dist/admin/components/ui/input-otp/index.js +5 -0
  108. package/dist/admin/components/ui/input-otp/input-otp-group.svelte +23 -0
  109. package/dist/admin/components/ui/input-otp/input-otp-group.svelte.d.ts +5 -0
  110. package/dist/admin/components/ui/input-otp/input-otp-separator.svelte +27 -0
  111. package/dist/admin/components/ui/input-otp/input-otp-separator.svelte.d.ts +5 -0
  112. package/dist/admin/components/ui/input-otp/input-otp-slot.svelte +29 -0
  113. package/dist/admin/components/ui/input-otp/input-otp-slot.svelte.d.ts +4 -0
  114. package/dist/admin/components/ui/input-otp/input-otp.svelte +24 -0
  115. package/dist/admin/components/ui/input-otp/input-otp.svelte.d.ts +4 -0
  116. package/dist/admin/components/ui/popover/index.d.ts +9 -0
  117. package/dist/admin/components/ui/popover/index.js +11 -0
  118. package/dist/admin/components/ui/popover/popover-close.svelte +7 -0
  119. package/dist/admin/components/ui/popover/popover-close.svelte.d.ts +4 -0
  120. package/dist/admin/components/ui/popover/popover-content.svelte +31 -0
  121. package/dist/admin/components/ui/popover/popover-content.svelte.d.ts +10 -0
  122. package/dist/admin/components/ui/popover/popover-description.svelte +20 -0
  123. package/dist/admin/components/ui/popover/popover-description.svelte.d.ts +5 -0
  124. package/dist/admin/components/ui/popover/popover-header.svelte +20 -0
  125. package/dist/admin/components/ui/popover/popover-header.svelte.d.ts +5 -0
  126. package/dist/admin/components/ui/popover/popover-portal.svelte +7 -0
  127. package/dist/admin/components/ui/popover/popover-portal.svelte.d.ts +3 -0
  128. package/dist/admin/components/ui/popover/popover-title.svelte +20 -0
  129. package/dist/admin/components/ui/popover/popover-title.svelte.d.ts +5 -0
  130. package/dist/admin/components/ui/popover/popover-trigger.svelte +17 -0
  131. package/dist/admin/components/ui/popover/popover-trigger.svelte.d.ts +4 -0
  132. package/dist/admin/components/ui/popover/popover.svelte +7 -0
  133. package/dist/admin/components/ui/popover/popover.svelte.d.ts +3 -0
  134. package/dist/admin/components/ui/switch/switch.svelte +2 -2
  135. package/dist/admin/components/ui/tooltip/index.d.ts +6 -0
  136. package/dist/admin/components/ui/tooltip/index.js +8 -0
  137. package/dist/admin/components/ui/tooltip/tooltip-content.svelte +48 -0
  138. package/dist/admin/components/ui/tooltip/tooltip-content.svelte.d.ts +11 -0
  139. package/dist/admin/components/ui/tooltip/tooltip-portal.svelte +7 -0
  140. package/dist/admin/components/ui/tooltip/tooltip-portal.svelte.d.ts +4 -0
  141. package/dist/admin/components/ui/tooltip/tooltip-provider.svelte +7 -0
  142. package/dist/admin/components/ui/tooltip/tooltip-provider.svelte.d.ts +4 -0
  143. package/dist/admin/components/ui/tooltip/tooltip-trigger.svelte +7 -0
  144. package/dist/admin/components/ui/tooltip/tooltip-trigger.svelte.d.ts +25 -0
  145. package/dist/admin/components/ui/tooltip/tooltip.svelte +7 -0
  146. package/dist/admin/components/ui/tooltip/tooltip.svelte.d.ts +25 -0
  147. package/dist/admin/generated/admin.css +774 -138
  148. package/dist/admin/slug.d.ts +1 -0
  149. package/dist/admin/slug.js +6 -0
  150. package/dist/cli/index.js +0 -0
  151. package/dist/server/admin-load.js +2 -2
  152. package/dist/server/api.js +6 -1
  153. package/dist/server/auth.d.ts +1 -0
  154. package/dist/server/auth.js +23 -0
  155. package/docs/api.md +1 -1
  156. package/docs/package.md +4 -4
  157. package/docs/releases.md +10 -0
  158. package/docs/upgrades.md +9 -0
  159. package/package.json +5 -3
@@ -5,7 +5,15 @@
5
5
  import { Input } from './components/ui/input/index.js';
6
6
  import { Label } from './components/ui/label/index.js';
7
7
  import { Button } from './components/ui/button/index.js';
8
- import { Switch } from './components/ui/switch/index.js';
8
+ import { Checkbox } from './components/ui/checkbox/index.js';
9
+ import * as Dialog from './components/ui/dialog/index.js';
10
+ import Link2 from '@lucide/svelte/icons/link-2';
11
+ import FileText from '@lucide/svelte/icons/file-text';
12
+ import Paperclip from '@lucide/svelte/icons/paperclip';
13
+ import Mail from '@lucide/svelte/icons/mail';
14
+ import Phone from '@lucide/svelte/icons/phone';
15
+ import Plus from '@lucide/svelte/icons/plus';
16
+ import X from '@lucide/svelte/icons/x';
9
17
  import SelectField from './SelectField.svelte';
10
18
  import MediaPicker from './MediaPicker.svelte';
11
19
  let {
@@ -47,70 +55,127 @@
47
55
  }))
48
56
  )
49
57
  );
50
- function set(updates: Partial<LinkValue>) {
51
- onchange({ ...link, ...updates });
58
+ const destinations: Record<LinkType, string> = {
59
+ url: 'Address',
60
+ entry: 'Entry',
61
+ file: 'File',
62
+ email: 'Email address',
63
+ phone: 'Phone number'
64
+ };
65
+ const icons = { url: Link2, entry: FileText, file: Paperclip, email: Mail, phone: Phone };
66
+ let open = $state(false),
67
+ draft = $state<LinkValue>({ type: 'url', value: '' });
68
+ function edit() {
69
+ draft = { ...link };
70
+ open = true;
52
71
  }
72
+ const target = (l: LinkValue) =>
73
+ l.type === 'entry'
74
+ ? (entries.find((e) => e.value === l.value)?.label ?? '')
75
+ : l.type === 'file'
76
+ ? (assets.find((a) => a.id === l.value)?.filename ?? '')
77
+ : l.value;
53
78
  </script>
54
79
 
55
- <div class="cms-stack">
56
- <div class="cms-field">
57
- <Label for={id + '-type'}>Link type</Label>
58
- <SelectField
59
- id={id + '-type'}
60
- value={link.type}
61
- clearable={false}
62
- options={linkTypes.map((type) => ({ value: type, label: titles[type] }))}
63
- onchange={(type) => set({ type: type as LinkType, value: '' })}
64
- />
65
- </div>
66
- {#if link.type === 'entry'}
67
- <SelectField
68
- {id}
69
- value={link.value}
70
- options={entries}
71
- {invalid}
72
- placeholder="Choose an entry"
73
- onchange={(value) => set({ value })}
74
- />
75
- {:else if link.type === 'file'}
76
- <MediaPicker
77
- {id}
78
- value={link.value || null}
79
- {assets}
80
- {workerUrl}
81
- fileBlueprint={fileBlueprints.find((b) => b.id === field.fileBlueprint)}
82
- onchange={(value) => set({ value: typeof value === 'string' ? value : '' })}
83
- />
84
- {:else}
85
- <Input
86
- {id}
87
- value={link.value}
88
- aria-invalid={invalid}
89
- type={link.type === 'email' ? 'email' : link.type === 'phone' ? 'tel' : 'text'}
90
- placeholder={link.type === 'email'
91
- ? 'hello@example.com'
92
- : link.type === 'phone'
93
- ? '+15551234567'
94
- : 'https://example.com or /path'}
95
- oninput={(event) => set({ value: event.currentTarget.value })}
96
- />
97
- {/if}
98
- <div class="cms-field">
99
- <Label for={id + '-label'}>Link text</Label>
100
- <Input
101
- id={id + '-label'}
102
- value={link.label ?? ''}
103
- placeholder="Optional"
104
- oninput={(event) => set({ label: event.currentTarget.value })}
105
- />
106
- </div>
107
- <div class="cms-checkbox">
108
- <Switch
109
- id={id + '-new-tab'}
110
- checked={link.newTab ?? false}
111
- onCheckedChange={(newTab) => set({ newTab })}
112
- />
113
- <Label for={id + '-new-tab'}>Open in new tab</Label>
114
- </div>
115
- {#if value}<Button variant="outline" onclick={() => onchange(null)}>Clear link</Button>{/if}
80
+ <div class="cms-link">
81
+ {#if value}
82
+ {@const Icon = icons[link.type]}
83
+ <div class="cms-link-summary">
84
+ <Icon size={16} />
85
+ <span class="cms-link-text">
86
+ <strong>{link.label || target(link) || 'Untitled link'}</strong>
87
+ <span class="cms-muted"
88
+ >{titles[link.type]}{link.label && target(link) ? ' · ' + target(link) : ''}{link.newTab
89
+ ? ' · New tab'
90
+ : ''}</span
91
+ >
92
+ </span>
93
+ </div>
94
+ <Button {id} variant="outline" size="sm" aria-invalid={invalid} onclick={edit}>Edit</Button>
95
+ <Button variant="ghost" size="icon-sm" aria-label="Remove link" onclick={() => onchange(null)}
96
+ ><X /></Button
97
+ >
98
+ {:else}<Button {id} variant="outline" class="cms-link-add" aria-invalid={invalid} onclick={edit}
99
+ ><Plus /> Add link</Button
100
+ >{/if}
116
101
  </div>
102
+ <Dialog.Root bind:open>
103
+ <Dialog.Content portalProps={{ disabled: true }}>
104
+ <Dialog.Header><Dialog.Title>{value ? 'Edit link' : 'Add link'}</Dialog.Title></Dialog.Header>
105
+ <form
106
+ class="cms-stack"
107
+ onsubmit={(event) => {
108
+ event.preventDefault();
109
+ onchange(draft);
110
+ open = false;
111
+ }}
112
+ >
113
+ <div class="cms-field">
114
+ <Label for={id + '-type'}>Link type</Label>
115
+ <SelectField
116
+ id={id + '-type'}
117
+ value={draft.type}
118
+ clearable={false}
119
+ options={linkTypes.map((type) => ({ value: type, label: titles[type] }))}
120
+ onchange={(type) => (draft = { ...draft, type: type as LinkType, value: '' })}
121
+ />
122
+ </div>
123
+ <div class="cms-field">
124
+ <Label for={id + '-value'}>{destinations[draft.type]}</Label>
125
+ {#if draft.type === 'entry'}
126
+ <SelectField
127
+ id={id + '-value'}
128
+ value={draft.value}
129
+ options={entries}
130
+ placeholder="Choose an entry"
131
+ onchange={(value) => (draft = { ...draft, value })}
132
+ />
133
+ {:else if draft.type === 'file'}
134
+ <MediaPicker
135
+ id={id + '-value'}
136
+ value={draft.value || null}
137
+ {assets}
138
+ {workerUrl}
139
+ fileBlueprint={fileBlueprints.find((b) => b.id === field.fileBlueprint)}
140
+ onchange={(value) =>
141
+ (draft = { ...draft, value: typeof value === 'string' ? value : '' })}
142
+ />
143
+ {:else}
144
+ <Input
145
+ id={id + '-value'}
146
+ value={draft.value}
147
+ type={draft.type === 'email' ? 'email' : draft.type === 'phone' ? 'tel' : 'text'}
148
+ placeholder={draft.type === 'email'
149
+ ? 'hello@example.com'
150
+ : draft.type === 'phone'
151
+ ? '+15551234567'
152
+ : 'https://example.com or /path'}
153
+ oninput={(event) => (draft = { ...draft, value: event.currentTarget.value })}
154
+ />
155
+ {/if}
156
+ </div>
157
+ <div class="cms-field">
158
+ <Label for={id + '-label'}>Link text</Label>
159
+ <Input
160
+ id={id + '-label'}
161
+ value={draft.label ?? ''}
162
+ placeholder="Optional"
163
+ oninput={(event) => (draft = { ...draft, label: event.currentTarget.value })}
164
+ />
165
+ </div>
166
+ <div class="cms-checkbox">
167
+ <Checkbox
168
+ id={id + '-new-tab'}
169
+ checked={draft.newTab ?? false}
170
+ onCheckedChange={(newTab) => (draft = { ...draft, newTab })}
171
+ />
172
+ <Label for={id + '-new-tab'}>Open in new tab</Label>
173
+ </div>
174
+ <Dialog.Footer
175
+ ><Button variant="outline" onclick={() => (open = false)}>Cancel</Button><Button
176
+ type="submit">Done</Button
177
+ ></Dialog.Footer
178
+ >
179
+ </form>
180
+ </Dialog.Content>
181
+ </Dialog.Root>
@@ -45,7 +45,6 @@
45
45
  <div class="cms-login">
46
46
  <a href="/" class="cms-wordmark"><Layers size={24} /> SandCMS</a>
47
47
  <Card.Root class="cms-login-card gap-0">
48
- <div class="cms-eyebrow">YOUR WEBSITE, IN GOOD HANDS</div>
49
48
  <h1>{twoFactor ? 'Verify your sign-in' : 'Welcome back'}</h1>
50
49
  <p class="cms-muted">
51
50
  {twoFactor
@@ -9,6 +9,7 @@
9
9
  import { api, assetUrl, message } from './client.js';
10
10
  import { Button } from './components/ui/button/index.js';
11
11
  import { Label } from './components/ui/label/index.js';
12
+ import { Badge } from './components/ui/badge/index.js';
12
13
  import * as Dialog from './components/ui/dialog/index.js';
13
14
  import Image from '@lucide/svelte/icons/image';
14
15
  import SelectField from './SelectField.svelte';
@@ -37,15 +38,33 @@
37
38
  batchBlueprint = $state<string | undefined>(),
38
39
  confirmDelete = $state(false);
39
40
  let openedLink = $state('');
40
- afterNavigate(() => openedLink = '');
41
+ afterNavigate(() => (openedLink = ''));
41
42
  $effect(() => {
42
43
  const id = page.url.searchParams.get('asset');
43
- if (!id) { openedLink = ''; return; }
44
+ if (!id) {
45
+ openedLink = '';
46
+ return;
47
+ }
44
48
  const asset = data.assets?.find((asset) => asset.id === id);
45
49
  if (asset && openedLink !== id) {
46
- openedLink = id; active = asset; metadata = structuredClone(asset.metadata); confirmDelete = false;
50
+ openedLink = id;
51
+ active = asset;
52
+ metadata = structuredClone(asset.metadata);
53
+ confirmDelete = false;
47
54
  }
48
55
  });
56
+ const usedIn = $derived.by(() => {
57
+ const grouped = new Map<
58
+ string,
59
+ { blueprint: string; documentId: string; snapshots: string[] }
60
+ >();
61
+ for (const usage of (active && data.usages?.[active.id]) || []) {
62
+ const item = grouped.get(usage.documentId) ?? { ...usage, snapshots: [] };
63
+ item.snapshots.push(usage.snapshot);
64
+ grouped.set(usage.documentId, item);
65
+ }
66
+ return [...grouped.values()];
67
+ });
49
68
  const isPublic = (id: string) =>
50
69
  data.usages?.[id]?.some((usage) => usage.snapshot === 'published') ?? false;
51
70
  onMount(() => {
@@ -117,11 +136,7 @@
117
136
  </script>
118
137
 
119
138
  <div class="cms-page-heading">
120
- <div>
121
- <div class="cms-eyebrow">YOUR SHARED LIBRARY</div>
122
- <h1>Media library</h1>
123
- <p class="cms-muted">Upload once. Use it wherever your story takes you.</p>
124
- </div>
139
+ <h1>Media library</h1>
125
140
  <div class="cms-stack">
126
141
  {#if uploadChoices.length > 1}<Label for="upload-blueprint">Upload as</Label><SelectField
127
142
  id="upload-blueprint"
@@ -147,34 +162,37 @@
147
162
  {/if}
148
163
  {#if progress}<p role="status">{progress}</p>{/if}
149
164
  {#if error}<Notice error>{error}</Notice>{/if}
150
- <div class="cms-section-heading">
165
+ <div class="cms-list-meta">
151
166
  <span class="cms-muted">{data.assets?.length ?? 0} assets</span><span class="cms-muted"
152
167
  >Up to {(data.uploadLimit ?? 0) / 1_000_000} MB per image · SVG up to 1 MB</span
153
168
  >
154
169
  </div>
155
- <SearchList path="media/list" initial={data.assets ?? []} label="Search media" refreshKey={JSON.stringify(data.assets)}>
156
- {#snippet children(assets)}
157
- {#if assets.length}<div class="cms-media-grid">
158
- {#each assets as asset (asset.id)}
159
- <AssetAttachment
160
- {asset}
161
- workerUrl={data.workerUrl!}
162
- class="cms-media-card"
163
- visibility={isPublic(asset.id) ? 'Public' : 'Private'}
164
- onopen={() => {
165
- active = asset;
166
- metadata = structuredClone(asset.metadata);
167
- confirmDelete = false;
168
- }}
169
- />
170
- {/each}
171
- </div>{:else if !data.assets?.length}<Card.Root class="cms-empty">
172
- <Image size={36} />
173
- <h2>A home for your images</h2>
174
- <p>Upload your first image to start building your library.</p>
175
- <p class="cms-muted">Images are prepared for your website automatically.</p>
176
- </Card.Root>{/if}
177
- {/snippet}
170
+ <SearchList
171
+ path="media/list"
172
+ initial={data.assets ?? []}
173
+ label="Search media"
174
+ refreshKey={JSON.stringify(data.assets)}
175
+ >
176
+ {#snippet children(assets)}
177
+ {#if assets.length}<div class="cms-media-grid">
178
+ {#each assets as asset (asset.id)}
179
+ <AssetAttachment
180
+ {asset}
181
+ workerUrl={data.workerUrl!}
182
+ class="cms-media-card"
183
+ visibility={isPublic(asset.id) ? 'Public' : 'Private'}
184
+ onopen={() => {
185
+ active = asset;
186
+ metadata = structuredClone(asset.metadata);
187
+ confirmDelete = false;
188
+ }}
189
+ />
190
+ {/each}
191
+ </div>{:else if !data.assets?.length}<Card.Root class="cms-empty">
192
+ <Image size={36} />
193
+ <h2>No images yet</h2>
194
+ </Card.Root>{/if}
195
+ {/snippet}
178
196
  </SearchList>
179
197
  <Dialog.Root
180
198
  open={!!active}
@@ -183,9 +201,9 @@
183
201
  }}
184
202
  ><Dialog.Content portalProps={{ disabled: true }} class="cms-asset-dialog"
185
203
  ><Dialog.Header
186
- ><Dialog.Title>{active?.filename}</Dialog.Title><Dialog.Description
187
- >Default details for every use of this asset. Gallery overrides apply only to that gallery.</Dialog.Description
188
- ></Dialog.Header
204
+ ><Dialog.Title>{active?.filename}</Dialog.Title>{#if active}<Badge variant="outline"
205
+ >{isPublic(active.id) ? 'Public' : 'Private'}</Badge
206
+ >{/if}</Dialog.Header
189
207
  >{#if active}{@const blueprint = data.fileBlueprints?.find((b) => b.id === active!.blueprint)}
190
208
  <div class="cms-stack">
191
209
  {#if !Object.values(blueprint?.fields ?? {}).some((field) => field.type === 'focus') && assetUrl(active, data.workerUrl!)}<img
@@ -193,13 +211,7 @@
193
211
  src={assetUrl(active, data.workerUrl!)}
194
212
  alt={String(active.metadata.alt ?? '')}
195
213
  />{/if}
196
- <p class="cms-muted">
197
- {isPublic(active.id)
198
- ? 'Used in published content. Website variants are public; the original stays private.'
199
- : 'Private. Only signed-in editors can view this image until it is used in published content.'}
200
- </p>
201
- {#if blueprint}<p class="cms-muted">{blueprint.label}</p>
202
- <Fields
214
+ {#if blueprint}<Fields
203
215
  imageUrl={active.variants.some(
204
216
  (v) => v.preset === 'sandcms-preview' || v.format === 'svg'
205
217
  )
@@ -227,14 +239,13 @@
227
239
  onclick={() => action('media/retry', { id: active!.id })}>Retry processing</Button
228
240
  >{/if}
229
241
  {/if}
230
- <div>
231
- <h3>Used in {(data.usages?.[active.id] ?? []).length} content references</h3>
232
- {#each data.usages?.[active.id] ?? [] as usage}<a
233
- class="cms-usage"
234
- href={'/admin/content/' + usage.blueprint + '/' + usage.documentId}
235
- >{usage.blueprint} · {usage.snapshot}</a
236
- >{/each}
237
- </div>
242
+ {#if usedIn.length}<p class="cms-usages">
243
+ Used in {#each usedIn as usage, i}{i ? ', ' : ''}<a
244
+ href={'/admin/content/' + usage.blueprint + '/' + usage.documentId}
245
+ >{usage.blueprint}</a
246
+ >
247
+ <span class="cms-muted">({usage.snapshots.join(', ')})</span>{/each}
248
+ </p>{/if}
238
249
  {#if confirmDelete}<div class="cms-alert">
239
250
  <p>
240
251
  Delete this image? Its references will be cleared from drafts and published content.
@@ -221,11 +221,9 @@
221
221
  : 'Choose an image'}
222
222
  </Button>{/snippet}</Dialog.Trigger
223
223
  ><Dialog.Content portalProps={{ disabled: true }} class="cms-media-dialog"
224
- ><Dialog.Header
225
- ><Dialog.Title>Media library</Dialog.Title><Dialog.Description
226
- >Select images from the library or upload new ones.</Dialog.Description
227
- ></Dialog.Header
228
- ><UploadQueue items={uploads} />
224
+ ><Dialog.Header><Dialog.Title>Media library</Dialog.Title></Dialog.Header><UploadQueue
225
+ items={uploads}
226
+ />
229
227
  {#if failures.length}
230
228
  <Button
231
229
  variant="outline"
@@ -239,43 +237,60 @@
239
237
  {error}
240
238
  </p>{/if}
241
239
  {#if open}<SearchList
242
- path={'media/list' + (fileBlueprint ? '?' + new URLSearchParams([['blueprint', fileBlueprint.id], ...fileBlueprint.accept.map((mime): [string, string] => ['mime', mime])]).toString() : '')}
243
- initial={all.filter((a) => !fileBlueprint || (a.blueprint === fileBlueprint.id && fileBlueprint.accept.includes(a.mime)))}
244
- label="Search media" refreshKey={JSON.stringify(all)}>
245
- {#snippet children(matches)}
246
- <div class="cms-picker-drop-area" bind:this={dropArea}>
247
- <div class="cms-picker-grid">
248
- <UploadButton tile {busy} {multiple} accept={accept.join(',')} onchange={upload} />
249
- {#each matches.filter((a) => a.status !== 'deleting') as asset (asset.id)}
250
- <AssetAttachment
251
- {asset}
252
- {workerUrl}
253
- class="cms-picker-item"
254
- selected={selected.some((a) => a.id === asset.id)}
255
- onopen={() => {
256
- if (!all.some((a) => a.id === asset.id)) { extra = [...extra, asset]; onasset?.(asset); }
257
- select(asset.id);
258
- }}
259
- />
260
- {/each}
261
- </div>
262
- <div class="cms-picker-drop-overlay" data-active={dragging} aria-hidden={!dragging}>
263
- <Upload size={32} />
264
- <strong
265
- >{busy
266
- ? 'Upload in progress'
267
- : multiple
268
- ? 'Drop images here'
269
- : 'Drop an image here'}</strong
270
- >
271
- <span
272
- >{busy
273
- ? 'Wait for your current upload to finish.'
274
- : 'Release to upload to your library'}</span
275
- >
276
- </div>
277
- </div>
278
- {/snippet}</SearchList>{/if}
240
+ path={'media/list' +
241
+ (fileBlueprint
242
+ ? '?' +
243
+ new URLSearchParams([
244
+ ['blueprint', fileBlueprint.id],
245
+ ...fileBlueprint.accept.map((mime): [string, string] => ['mime', mime])
246
+ ]).toString()
247
+ : '')}
248
+ initial={all.filter(
249
+ (a) =>
250
+ !fileBlueprint ||
251
+ (a.blueprint === fileBlueprint.id && fileBlueprint.accept.includes(a.mime))
252
+ )}
253
+ label="Search media"
254
+ refreshKey={JSON.stringify(all)}
255
+ >
256
+ {#snippet children(matches)}
257
+ <div class="cms-picker-drop-area" bind:this={dropArea}>
258
+ <div class="cms-picker-grid">
259
+ <UploadButton tile {busy} {multiple} accept={accept.join(',')} onchange={upload} />
260
+ {#each matches.filter((a) => a.status !== 'deleting') as asset (asset.id)}
261
+ <AssetAttachment
262
+ {asset}
263
+ {workerUrl}
264
+ class="cms-picker-item"
265
+ selected={selected.some((a) => a.id === asset.id)}
266
+ onopen={() => {
267
+ if (!all.some((a) => a.id === asset.id)) {
268
+ extra = [...extra, asset];
269
+ onasset?.(asset);
270
+ }
271
+ select(asset.id);
272
+ }}
273
+ />
274
+ {/each}
275
+ </div>
276
+ <div class="cms-picker-drop-overlay" data-active={dragging} aria-hidden={!dragging}>
277
+ <Upload size={32} />
278
+ <strong
279
+ >{busy
280
+ ? 'Upload in progress'
281
+ : multiple
282
+ ? 'Drop images here'
283
+ : 'Drop an image here'}</strong
284
+ >
285
+ <span
286
+ >{busy
287
+ ? 'Wait for your current upload to finish.'
288
+ : 'Release to upload to your library'}</span
289
+ >
290
+ </div>
291
+ </div>
292
+ {/snippet}</SearchList
293
+ >{/if}
279
294
  {#if multiple}<div class="flex justify-end">
280
295
  <Button onclick={() => (open = false)}>Done</Button>
281
296
  </div>{/if}</Dialog.Content
@@ -6,6 +6,7 @@
6
6
  import { Button } from './components/ui/button/index.js';
7
7
  import { Input } from './components/ui/input/index.js';
8
8
  import { Label } from './components/ui/label/index.js';
9
+ import { Checkbox } from './components/ui/checkbox/index.js';
9
10
  import * as Dialog from './components/ui/dialog/index.js';
10
11
  import SelectField from './SelectField.svelte';
11
12
  let { data }: { data: AdminData } = $props();
@@ -19,6 +20,8 @@
19
20
  busy = $state(false),
20
21
  error = $state(''),
21
22
  removed = $state(false);
23
+ const toggle = (list: string[], item: string, on: boolean) =>
24
+ on ? [...new Set([...list, item])] : list.filter((value) => value !== item);
22
25
  const available = $derived(notificationFields(data.blueprint?.fields ?? {}));
23
26
  function show() {
24
27
  const settings = data.notificationSettings;
@@ -73,12 +76,7 @@
73
76
  <Button variant="outline" onclick={show}>Notifications</Button>
74
77
  <Dialog.Root bind:open
75
78
  ><Dialog.Content portalProps={{ disabled: true }} class="max-h-[85vh] overflow-y-auto">
76
- <Dialog.Header
77
- ><Dialog.Title>Email notifications</Dialog.Title><Dialog.Description
78
- >Choose who receives new {data.blueprint?.label} submissions. Changes apply to future sends, including
79
- manual resends.</Dialog.Description
80
- ></Dialog.Header
81
- >
79
+ <Dialog.Header><Dialog.Title>Email notifications</Dialog.Title></Dialog.Header>
82
80
  <form
83
81
  class="cms-stack"
84
82
  onsubmit={(e) => {
@@ -93,18 +91,26 @@
93
91
  Email is not configured. Ask your operator to configure SMTP before enabling
94
92
  notifications.
95
93
  </p>{/if}
96
- <label class="flex gap-2"
97
- ><input
98
- type="checkbox"
94
+ <div class="cms-checkbox">
95
+ <Checkbox
96
+ id="notifications-enabled"
99
97
  bind:checked={enabled}
100
98
  disabled={!data.emailEnabled && !enabled}
101
- />Email notifications enabled</label
102
- >
103
- <fieldset class="cms-stack">
104
- <legend>CMS recipients</legend>
105
- {#each data.notificationUsers ?? [] as person}<label class="flex gap-2"
106
- ><input type="checkbox" bind:group={userIds} value={person.id} />{person.name} ({person.email})</label
107
- >{/each}
99
+ /><Label for="notifications-enabled">Email notifications enabled</Label>
100
+ </div>
101
+ <fieldset class="cms-field">
102
+ <legend class="cms-legend">CMS recipients</legend>
103
+ <div class="cms-checkboxes">
104
+ {#each data.notificationUsers ?? [] as person}<div class="cms-checkbox">
105
+ <Checkbox
106
+ id={'notify-' + person.id}
107
+ checked={userIds.includes(person.id)}
108
+ onCheckedChange={(on) => (userIds = toggle(userIds, person.id, on))}
109
+ /><Label for={'notify-' + person.id}
110
+ >{person.name} <span class="cms-muted">{person.email}</span></Label
111
+ >
112
+ </div>{/each}
113
+ </div>
108
114
  </fieldset>
109
115
  <div class="cms-field">
110
116
  <Label for="notification-addresses">Additional email addresses</Label><Input
@@ -112,7 +118,7 @@
112
118
  bind:value={addresses}
113
119
  placeholder="enquiries@example.com, team@example.com"
114
120
  />
115
- <p class="cms-muted">Separate addresses with commas. Up to 20 recipients in total.</p>
121
+ <p class="cms-muted">Comma-separated, up to 20 recipients in total.</p>
116
122
  </div>
117
123
  <div class="cms-field">
118
124
  <Label for="notification-content">Email content</Label><SelectField
@@ -125,15 +131,18 @@
125
131
  ]}
126
132
  />
127
133
  </div>
128
- {#if content === 'fields'}<fieldset class="cms-stack">
129
- <legend>Included fields</legend>
130
- {#each available as field}<label class="flex gap-2"
131
- ><input type="checkbox" bind:group={fields} value={field.value} />{field.label}</label
132
- >{/each}
133
- <p class="cms-muted">
134
- Only selected answers are included. Files, rich text, and repeated groups are not
135
- available.
136
- </p>
134
+ {#if content === 'fields'}<fieldset class="cms-field">
135
+ <legend class="cms-legend">Included fields</legend>
136
+ <div class="cms-checkboxes">
137
+ {#each available as field}<div class="cms-checkbox">
138
+ <Checkbox
139
+ id={'notify-field-' + field.value}
140
+ checked={fields.includes(field.value)}
141
+ onCheckedChange={(on) => (fields = toggle(fields, field.value, on))}
142
+ /><Label for={'notify-field-' + field.value}>{field.label}</Label>
143
+ </div>{/each}
144
+ </div>
145
+ <p class="cms-muted">Files, rich text, and repeated groups can’t be included.</p>
137
146
  </fieldset>{/if}
138
147
  <div class="cms-field">
139
148
  <Label for="notification-reply">Reply-to field</Label><SelectField
@@ -144,7 +153,6 @@
144
153
  .map((f) => ({ value: f.value, label: f.label }))}
145
154
  placeholder="Use configured default"
146
155
  />
147
- <p class="cms-muted">Used only when the submitted answer is a valid email address.</p>
148
156
  </div>
149
157
  {#if error}<p class="cms-error" role="alert">{error}</p>{/if}
150
158
  <Button type="submit" disabled={busy}>{busy ? 'Saving…' : 'Save notifications'}</Button>
@@ -69,7 +69,7 @@
69
69
  pressed={active.italic}
70
70
  onPressedChange={() => editor?.chain().focus().toggleItalic().run()}><i>I</i></Toggle
71
71
  >
72
- <Separator orientation="vertical" class="mx-1 h-6 self-center" />
72
+ <Separator orientation="vertical" class="h-auto self-stretch" />
73
73
  <Toggle
74
74
  pressed={active.paragraph}
75
75
  onPressedChange={() => editor?.chain().focus().setParagraph().run()}>Text</Toggle
@@ -84,7 +84,7 @@
84
84
  pressed={active.h3}
85
85
  onPressedChange={() => editor?.chain().focus().toggleHeading({ level: 3 }).run()}>H3</Toggle
86
86
  >
87
- <Separator orientation="vertical" class="mx-1 h-6 self-center" />
87
+ <Separator orientation="vertical" class="h-auto self-stretch" />
88
88
  <RichTextLink {editor} />
89
89
  <Toggle
90
90
  pressed={active.bulletList}