@lavalogic/scoria 0.39.2 → 0.40.0

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 (141) hide show
  1. package/README.md +58 -58
  2. package/dist/Components/AccordionGroup.svelte +46 -46
  3. package/dist/Components/AccordionGroupButton.svelte +76 -76
  4. package/dist/Components/Action.svelte +136 -136
  5. package/dist/Components/AlertModal.svelte +195 -195
  6. package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +729 -729
  7. package/dist/Components/Base/BaseModal.svelte +125 -125
  8. package/dist/Components/Base/ContextWrapper.svelte +72 -72
  9. package/dist/Components/Base/Pagination.svelte +198 -198
  10. package/dist/Components/Base/Snippets.svelte +36 -36
  11. package/dist/Components/BigRadioSet.svelte +38 -38
  12. package/dist/Components/Bubble.svelte +101 -101
  13. package/dist/Components/Button.svelte +209 -209
  14. package/dist/Components/Checkbox.svelte +86 -86
  15. package/dist/Components/CollapsibleCard.svelte +78 -78
  16. package/dist/Components/ConditionBuilder/ConditionBuilder.svelte +212 -0
  17. package/dist/Components/ConditionBuilder/ConditionBuilder.svelte.d.ts +25 -0
  18. package/dist/Components/ConditionBuilder/ConditionBuilderProps.d.ts +45 -0
  19. package/dist/Components/ConditionBuilder/ConditionBuilderProps.js +1 -0
  20. package/dist/Components/ConditionBuilder/ConditionTree.d.ts +27 -0
  21. package/dist/Components/ConditionBuilder/ConditionTree.js +9 -0
  22. package/dist/Components/Contexts/ContextMenu.svelte +164 -164
  23. package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
  24. package/dist/Components/Contexts/ContextMenuOption.svelte +60 -60
  25. package/dist/Components/Contexts/Toast.svelte +86 -86
  26. package/dist/Components/Contexts/ToastContainer.svelte +65 -65
  27. package/dist/Components/Contexts/Tooltip.svelte +37 -37
  28. package/dist/Components/DataMatrixIcon.svelte +112 -112
  29. package/dist/Components/DateInput.svelte +148 -148
  30. package/dist/Components/DatePicker.svelte +300 -300
  31. package/dist/Components/DesktopModal.svelte +90 -90
  32. package/dist/Components/Dial.svelte +204 -204
  33. package/dist/Components/DimensionInput.svelte +170 -170
  34. package/dist/Components/DragMenu/DragMenuHolder.svelte +119 -119
  35. package/dist/Components/DragMenu/DraggableCard.svelte +77 -77
  36. package/dist/Components/FileCard.svelte +24 -24
  37. package/dist/Components/FileUpload.svelte +236 -236
  38. package/dist/Components/GridInput.svelte +196 -196
  39. package/dist/Components/GridInputSet.svelte +29 -29
  40. package/dist/Components/HorizontalTabGroup.svelte +82 -82
  41. package/dist/Components/HorizontalTabGroupButton.svelte +44 -44
  42. package/dist/Components/Icon.svelte +128 -128
  43. package/dist/Components/Icons.js +357 -357
  44. package/dist/Components/InfoAlert.svelte +35 -35
  45. package/dist/Components/LoadingAnimation.svelte +29 -29
  46. package/dist/Components/LoadingModal.svelte +45 -45
  47. package/dist/Components/LoadingOverlay.svelte +25 -25
  48. package/dist/Components/Modal.svelte +258 -258
  49. package/dist/Components/MultiSelect.svelte +220 -220
  50. package/dist/Components/Nav/Nav.svelte +110 -110
  51. package/dist/Components/Nav/NavServiceMenuList.svelte +43 -43
  52. package/dist/Components/Nav/NavTab.svelte +62 -62
  53. package/dist/Components/Nav/ServiceMenuItem.svelte +112 -112
  54. package/dist/Components/Nav/ServicesNav.svelte +80 -80
  55. package/dist/Components/NumberInput.svelte +157 -157
  56. package/dist/Components/PageHeading.svelte +25 -25
  57. package/dist/Components/PasswordInput.svelte +88 -88
  58. package/dist/Components/Portal.svelte +36 -36
  59. package/dist/Components/ProgressBubble.svelte +107 -107
  60. package/dist/Components/QuerySelect.svelte +366 -366
  61. package/dist/Components/SingleSelect.svelte +250 -250
  62. package/dist/Components/StepButton.svelte +70 -70
  63. package/dist/Components/StepForm.svelte +140 -140
  64. package/dist/Components/Switch.svelte +69 -69
  65. package/dist/Components/Table/ARCHITECTURE.md +298 -298
  66. package/dist/Components/Table/Body/QuickSearchCell.svelte +679 -679
  67. package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +51 -51
  68. package/dist/Components/Table/Body/Rows/ColumnList.svelte +59 -59
  69. package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +454 -454
  70. package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +79 -79
  71. package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +185 -185
  72. package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +124 -124
  73. package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +120 -120
  74. package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +234 -234
  75. package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +105 -105
  76. package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +87 -87
  77. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +126 -126
  78. package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +159 -159
  79. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +246 -246
  80. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +216 -216
  81. package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +252 -252
  82. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +179 -179
  83. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +221 -221
  84. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +197 -197
  85. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +190 -190
  86. package/dist/Components/Table/Body/Rows/TableRow.svelte +290 -290
  87. package/dist/Components/Table/Body/TableBody.svelte +155 -155
  88. package/dist/Components/Table/Headers/HighlightAllHeader.svelte +41 -41
  89. package/dist/Components/Table/Headers/SelectAllHeader.svelte +30 -30
  90. package/dist/Components/Table/Headers/TableHead.svelte +415 -415
  91. package/dist/Components/Table/Misc/ColumnPanel.svelte +39 -39
  92. package/dist/Components/Table/Misc/ColumnPanelModal.svelte +39 -39
  93. package/dist/Components/Table/Misc/FilterInput.svelte +641 -641
  94. package/dist/Components/Table/Misc/FilterPanel.svelte +190 -190
  95. package/dist/Components/Table/Misc/FilterPanelModal.svelte +31 -31
  96. package/dist/Components/Table/Misc/ShareViewModal.svelte +291 -291
  97. package/dist/Components/Table/Misc/SidePanel.svelte +35 -35
  98. package/dist/Components/Table/Misc/TableConfigurationModal.svelte +644 -644
  99. package/dist/Components/Table/Misc/TableFooter.svelte +340 -340
  100. package/dist/Components/Table/Misc/TableHorizontalBar.svelte +140 -140
  101. package/dist/Components/Table/Misc/TableSidebar.svelte +200 -200
  102. package/dist/Components/Table/Misc/TableViewDropdown.svelte +105 -105
  103. package/dist/Components/Table/Misc/ToolboxPanel.svelte +100 -100
  104. package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +107 -107
  105. package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +192 -192
  106. package/dist/Components/Table/NestedTable.svelte +130 -130
  107. package/dist/Components/Table/Table.svelte +692 -692
  108. package/dist/Components/Test/TestContextConsumer.svelte +13 -13
  109. package/dist/Components/TextArea.svelte +130 -130
  110. package/dist/Components/TextInput.svelte +176 -176
  111. package/dist/Components/ThreeStateRadio.svelte +131 -131
  112. package/dist/Components/Touch/BoolCard.svelte +45 -45
  113. package/dist/Components/Touch/DateModal.svelte +209 -209
  114. package/dist/Components/Touch/EditCard.svelte +59 -59
  115. package/dist/Components/Touch/InfoCard.svelte +31 -31
  116. package/dist/Components/Touch/InfoTextCard.svelte +28 -28
  117. package/dist/Components/Touch/ModalExplanation.svelte +17 -17
  118. package/dist/Components/Touch/NumberKeyboard.svelte +225 -225
  119. package/dist/Components/Touch/NumberModal.svelte +79 -79
  120. package/dist/Components/Touch/PlusMinusCard.svelte +46 -46
  121. package/dist/Components/Touch/SelectModal.svelte +127 -127
  122. package/dist/Components/Touch/SummaryCard.svelte +93 -93
  123. package/dist/Components/Touch/TextAreaModal.svelte +95 -95
  124. package/dist/Components/Touch/TextModal.svelte +106 -106
  125. package/dist/Components/Touch/TouchCard.svelte +33 -33
  126. package/dist/Components/Touch/TouchModal.svelte +274 -274
  127. package/dist/Components/Touch/UtilityButton.svelte +109 -109
  128. package/dist/Components/VerticalTabGroup.svelte +79 -79
  129. package/dist/Components/VerticalTabGroupButton.svelte +58 -58
  130. package/dist/Helpers/Datamatrix.d.ts +19 -19
  131. package/dist/Helpers/Datamatrix.js +291 -291
  132. package/dist/Types/Examples/ExampleModal.svelte +35 -35
  133. package/dist/index.d.ts +3 -0
  134. package/dist/index.js +2 -0
  135. package/dist/scss/_basics.scss +12 -12
  136. package/dist/scss/_colours.scss +134 -134
  137. package/dist/scss/_mixins.scss +3392 -3392
  138. package/dist/scss/_motion.scss +57 -57
  139. package/dist/scss/_sizing.scss +85 -85
  140. package/dist/scss/_transitions.scss +8 -8
  141. package/package.json +1 -1
@@ -1,293 +1,293 @@
1
- <svelte:options runes />
2
-
3
- <script
4
- lang="ts"
5
- generics="T extends object, IdType extends Primitive"
6
- >
7
- import Button from '../../Button.svelte';
8
- import DesktopModal from '../../DesktopModal.svelte';
9
- import Icon from '../../Icon.svelte';
10
- import InfoAlert from '../../InfoAlert.svelte';
11
- import MultiSelect from '../../MultiSelect.svelte';
12
- import { cssLength } from '../../../Helpers/Helpers.svelte.js';
13
- import { ColourSet } from '../../../scss/colours.js';
14
- import { Size } from '../../../Types/Internal/Size.js';
15
- import { Variant } from '../../../Types/Internal/Variant.js';
16
- import { getContext, onMount } from 'svelte';
17
- import { TableContext } from '../Types/Context/TableContext.svelte.js';
18
- import type { Primitive } from '../Types/Context/TableInitOptions.js';
19
- import type { DatatableViewUser } from '../Types/Persistence/RemoteTableLayoutAdapter.js';
20
- import type { ShareViewModalProps } from './ShareViewModalProps.js';
21
-
22
- const { view, onclose, onsaved }: ShareViewModalProps = $props();
23
-
24
- const tableContext = getContext<TableContext<T, IdType>>(TableContext.identifier);
25
-
26
- // All users the current user is allowed to share with. `null` until the
27
- // boot-time `listUsers` fetch resolves; an array (possibly empty) once
28
- // the call lands. Bound to the `MultiSelect` options below.
29
- let allUsers = $state<ReadonlyArray<DatatableViewUser> | null>(null);
30
-
31
- // User-visible error banner. Adapter rejections are routed here so the
32
- // modal never throws into the host UI.
33
- let errorMessage = $state<string | null>(null);
34
-
35
- // In-flight flags for the two adapter call sites. `loadingUsers` blanks
36
- // the picker while `listUsers` is in flight; `saving` disables the
37
- // footer buttons while the subscribe / unsubscribe deltas land.
38
- let loadingUsers = $state(false);
39
- let saving = $state(false);
40
-
41
- /**
42
- * Current picker selection. Each entry is a `DatatableViewUser`. The
43
- * initial value is seeded from `view.subscribers` (the existing
44
- * roster) inside `onMount` so opening the modal shows "who is already
45
- * shared with", and Save can diff against the originals.
46
- *
47
- * `displayName` falls back to the opaque `userId` when the subscriber
48
- * record carries no label, matching the rest of the Configuration
49
- * modal's fallback behaviour.
50
- */
51
- let selected = $state<Array<DatatableViewUser>>([]);
52
-
53
- /**
54
- * Snapshot of the subscriber ids the view started with. The Save diff
55
- * reads it to compute which subscribers were added (POST subscribe)
56
- * vs removed (POST unsubscribe). Seeded in `onMount` from
57
- * `view.subscribers` so the snapshot stays a true *initial* roster
58
- * regardless of any concurrent edits to `view`.
59
- *
60
- * Typed as a plain `Set` (not `ReadonlySet`) only because it is
61
- * reassigned once in `onMount`; reads downstream still treat it as
62
- * read-only. Not reactive - the modal owns this snapshot for its
63
- * lifetime and never re-derives it.
64
- */
65
- let initialIds: Set<string> = new Set();
66
-
67
- // Whether anything in the picker differs from the initial roster.
68
- // Drives the Save button's disabled state so a no-op Save never hits
69
- // the network.
70
- const dirty = $derived.by(() => {
71
- const currentIds = new Set(selected.map((s) => s.id));
72
- if (currentIds.size !== initialIds.size) {
73
- return true;
74
- }
75
- for (const id of currentIds) {
76
- if (!initialIds.has(id)) {
77
- return true;
78
- }
79
- }
80
- return false;
81
- });
82
-
83
- onMount(() => {
84
- // Snapshot the initial subscriber roster once on mount so the
85
- // Save diff has a stable starting point. Done inside `onMount`
86
- // (rather than at `$state` init) so Svelte's reactivity lint does
87
- // not flag the read as "captures the initial value of `view`" -
88
- // the modal owns this snapshot for its lifetime intentionally.
89
- const initial = (view.subscribers ?? []).map((s) => ({
90
- id: s.userId,
91
- displayName: s.displayName?.trim() ? s.displayName : s.userId,
92
- }));
93
- selected = initial;
94
- initialIds = new Set(initial.map((u) => u.id));
95
-
96
- const adapter = tableContext.remoteLayouts;
97
- if (!adapter) {
98
- errorMessage = 'Sharing is unavailable: no remote layouts adapter is configured.';
99
- return;
100
- }
101
- loadingUsers = true;
102
- adapter
103
- .listUsers()
104
- .then((users) => {
105
- // Exclude the view's owner from the picker - sharing a view
106
- // with its own owner is nonsensical and the backend would
107
- // reject the subscribe anyway.
108
- allUsers = users.filter((u) => u.id !== view.ownerUserId);
109
- })
110
- .catch((e: unknown) => {
111
- console.error('[ShareViewModal] listUsers failed:', e);
112
- errorMessage =
113
- e instanceof Error
114
- ? `Could not load the user list. (${e.message})`
115
- : 'Could not load the user list.';
116
- })
117
- .finally(() => {
118
- loadingUsers = false;
119
- });
120
- });
121
-
122
- /** Remove a user from the current selection. */
123
- function removeFromSelection(userId: string): void {
124
- selected = selected.filter((s) => s.id !== userId);
125
- }
126
-
127
- /** Apply the picker selection by issuing the required deltas. */
128
- async function save(): Promise<void> {
129
- const adapter = tableContext.remoteLayouts;
130
- if (!adapter) {
131
- errorMessage = 'Sharing is unavailable: no remote layouts adapter is configured.';
132
- return;
133
- }
134
- if (!dirty) {
135
- onclose();
136
- return;
137
- }
138
-
139
- const currentIds = new Set(selected.map((s) => s.id));
140
- const toAdd: Array<string> = [];
141
- const toRemove: Array<string> = [];
142
-
143
- // Added: in the new selection but not the original roster.
144
- for (const id of currentIds) {
145
- if (!initialIds.has(id)) {
146
- toAdd.push(id);
147
- }
148
- }
149
- // Removed: in the original roster but not the new selection.
150
- for (const id of initialIds) {
151
- if (!currentIds.has(id)) {
152
- toRemove.push(id);
153
- }
154
- }
155
-
156
- errorMessage = null;
157
- saving = true;
158
- try {
159
- // Run sequentially so a partial failure surfaces a useful error
160
- // and leaves the already-applied deltas committed (an aborted
161
- // `Promise.all` is much harder to reason about).
162
- for (const userId of toAdd) {
163
- await adapter.addSubscriber(view.id, userId);
164
- }
165
- for (const userId of toRemove) {
166
- await adapter.removeSubscriber(view.id, userId);
167
- }
168
- if (onsaved) {
169
- await onsaved();
170
- }
171
- onclose();
172
- } catch (e: unknown) {
173
- console.error('[ShareViewModal] save failed:', e);
174
- errorMessage =
175
- e instanceof Error
176
- ? `Could not update sharing. Some changes may have been applied. (${e.message})`
177
- : 'Could not update sharing. Some changes may have been applied.';
178
- } finally {
179
- saving = false;
180
- }
181
- }
182
- </script>
183
-
184
- <DesktopModal
185
- headerLabel={`Share "${view.name}"`}
186
- headerSubtitle={`Choose who can access this ${view.kind === 'filter' ? 'filter' : 'layout'}.`}
187
- onclose={() => {
188
- if (!saving) {
189
- onclose();
190
- }
191
- }}
192
- width={cssLength('40vw')}
193
- minWidth={cssLength('32rem')}
194
- buttons={[
195
- {
196
- label: 'Cancel',
197
- callback: () => {
198
- if (!saving) {
199
- onclose();
200
- }
201
- },
202
- disabled: saving,
203
- },
204
- {
205
- label: saving ? 'Saving…' : 'Save',
206
- callback: () => {
207
- void save();
208
- },
209
- colourSet: ColourSet.Primary,
210
- disabled: saving || !dirty || allUsers === null,
211
- },
212
- ]}
213
- >
214
- <div class="share-body">
215
- {#if errorMessage}
216
- <div
217
- class="error-banner"
218
- role="alert"
219
- >
220
- <Icon
221
- name="circle-exclamation"
222
- size={Size.Small}
223
- />
224
- <span>{errorMessage}</span>
225
- </div>
226
- {/if}
227
-
228
- <div class="picker">
229
- {#if loadingUsers && allUsers === null}
230
- <InfoAlert>Loading users…</InfoAlert>
231
- {:else if allUsers !== null}
232
- <MultiSelect
233
- label="Users"
234
- name="User"
235
- options={allUsers as Array<DatatableViewUser>}
236
- labelProp="displayName"
237
- valueProp="id"
238
- valueAsObject={true}
239
- selectedValues={selected}
240
- onchange={(values) => {
241
- selected = values;
242
- }}
243
- />
244
- {/if}
245
- </div>
246
-
247
- {#if selected.length === 0}
248
- <InfoAlert>
249
- No users selected. Use the picker above to share this {view.kind === 'filter'
250
- ? 'filter'
251
- : 'layout'} with one or more users.
252
- </InfoAlert>
253
- {:else}
254
- <ul class="user-card-list">
255
- {#each selected as user (user.id)}
256
- <li class="user-card">
257
- <div class="user-info">
258
- <Icon
259
- name="user-3"
260
- size={Size.Medium}
261
- />
262
- <span class="user-name">{user.displayName}</span>
263
- </div>
264
- <div class="user-meta">
265
- <!--
266
- v1 sharing exposes a single role - subscriber - so
267
- the "permission" surface is informational only. The
268
- backend's `editor` / `systemOwned` flags are
269
- reserved no-ops in v1 (see `DatatableView` DTO
270
- JSDoc); scoria never sets them.
271
- -->
272
- <span class="permission-pill">Subscriber</span>
273
- <Button
274
- variant={Variant.Secondary}
275
- size={Size.MediumSmall}
276
- nowrap
277
- iconLeft={{ name: 'circle-cross', size: Size.Small }}
278
- disabled={saving}
279
- onclick={() => {
280
- removeFromSelection(user.id);
281
- }}>Remove</Button
282
- >
283
- </div>
284
- </li>
285
- {/each}
286
- </ul>
287
- {/if}
288
- </div>
289
- </DesktopModal>
290
-
1
+ <svelte:options runes />
2
+
3
+ <script
4
+ lang="ts"
5
+ generics="T extends object, IdType extends Primitive"
6
+ >
7
+ import Button from '../../Button.svelte';
8
+ import DesktopModal from '../../DesktopModal.svelte';
9
+ import Icon from '../../Icon.svelte';
10
+ import InfoAlert from '../../InfoAlert.svelte';
11
+ import MultiSelect from '../../MultiSelect.svelte';
12
+ import { cssLength } from '../../../Helpers/Helpers.svelte.js';
13
+ import { ColourSet } from '../../../scss/colours.js';
14
+ import { Size } from '../../../Types/Internal/Size.js';
15
+ import { Variant } from '../../../Types/Internal/Variant.js';
16
+ import { getContext, onMount } from 'svelte';
17
+ import { TableContext } from '../Types/Context/TableContext.svelte.js';
18
+ import type { Primitive } from '../Types/Context/TableInitOptions.js';
19
+ import type { DatatableViewUser } from '../Types/Persistence/RemoteTableLayoutAdapter.js';
20
+ import type { ShareViewModalProps } from './ShareViewModalProps.js';
21
+
22
+ const { view, onclose, onsaved }: ShareViewModalProps = $props();
23
+
24
+ const tableContext = getContext<TableContext<T, IdType>>(TableContext.identifier);
25
+
26
+ // All users the current user is allowed to share with. `null` until the
27
+ // boot-time `listUsers` fetch resolves; an array (possibly empty) once
28
+ // the call lands. Bound to the `MultiSelect` options below.
29
+ let allUsers = $state<ReadonlyArray<DatatableViewUser> | null>(null);
30
+
31
+ // User-visible error banner. Adapter rejections are routed here so the
32
+ // modal never throws into the host UI.
33
+ let errorMessage = $state<string | null>(null);
34
+
35
+ // In-flight flags for the two adapter call sites. `loadingUsers` blanks
36
+ // the picker while `listUsers` is in flight; `saving` disables the
37
+ // footer buttons while the subscribe / unsubscribe deltas land.
38
+ let loadingUsers = $state(false);
39
+ let saving = $state(false);
40
+
41
+ /**
42
+ * Current picker selection. Each entry is a `DatatableViewUser`. The
43
+ * initial value is seeded from `view.subscribers` (the existing
44
+ * roster) inside `onMount` so opening the modal shows "who is already
45
+ * shared with", and Save can diff against the originals.
46
+ *
47
+ * `displayName` falls back to the opaque `userId` when the subscriber
48
+ * record carries no label, matching the rest of the Configuration
49
+ * modal's fallback behaviour.
50
+ */
51
+ let selected = $state<Array<DatatableViewUser>>([]);
52
+
53
+ /**
54
+ * Snapshot of the subscriber ids the view started with. The Save diff
55
+ * reads it to compute which subscribers were added (POST subscribe)
56
+ * vs removed (POST unsubscribe). Seeded in `onMount` from
57
+ * `view.subscribers` so the snapshot stays a true *initial* roster
58
+ * regardless of any concurrent edits to `view`.
59
+ *
60
+ * Typed as a plain `Set` (not `ReadonlySet`) only because it is
61
+ * reassigned once in `onMount`; reads downstream still treat it as
62
+ * read-only. Not reactive - the modal owns this snapshot for its
63
+ * lifetime and never re-derives it.
64
+ */
65
+ let initialIds: Set<string> = new Set();
66
+
67
+ // Whether anything in the picker differs from the initial roster.
68
+ // Drives the Save button's disabled state so a no-op Save never hits
69
+ // the network.
70
+ const dirty = $derived.by(() => {
71
+ const currentIds = new Set(selected.map((s) => s.id));
72
+ if (currentIds.size !== initialIds.size) {
73
+ return true;
74
+ }
75
+ for (const id of currentIds) {
76
+ if (!initialIds.has(id)) {
77
+ return true;
78
+ }
79
+ }
80
+ return false;
81
+ });
82
+
83
+ onMount(() => {
84
+ // Snapshot the initial subscriber roster once on mount so the
85
+ // Save diff has a stable starting point. Done inside `onMount`
86
+ // (rather than at `$state` init) so Svelte's reactivity lint does
87
+ // not flag the read as "captures the initial value of `view`" -
88
+ // the modal owns this snapshot for its lifetime intentionally.
89
+ const initial = (view.subscribers ?? []).map((s) => ({
90
+ id: s.userId,
91
+ displayName: s.displayName?.trim() ? s.displayName : s.userId,
92
+ }));
93
+ selected = initial;
94
+ initialIds = new Set(initial.map((u) => u.id));
95
+
96
+ const adapter = tableContext.remoteLayouts;
97
+ if (!adapter) {
98
+ errorMessage = 'Sharing is unavailable: no remote layouts adapter is configured.';
99
+ return;
100
+ }
101
+ loadingUsers = true;
102
+ adapter
103
+ .listUsers()
104
+ .then((users) => {
105
+ // Exclude the view's owner from the picker - sharing a view
106
+ // with its own owner is nonsensical and the backend would
107
+ // reject the subscribe anyway.
108
+ allUsers = users.filter((u) => u.id !== view.ownerUserId);
109
+ })
110
+ .catch((e: unknown) => {
111
+ console.error('[ShareViewModal] listUsers failed:', e);
112
+ errorMessage =
113
+ e instanceof Error
114
+ ? `Could not load the user list. (${e.message})`
115
+ : 'Could not load the user list.';
116
+ })
117
+ .finally(() => {
118
+ loadingUsers = false;
119
+ });
120
+ });
121
+
122
+ /** Remove a user from the current selection. */
123
+ function removeFromSelection(userId: string): void {
124
+ selected = selected.filter((s) => s.id !== userId);
125
+ }
126
+
127
+ /** Apply the picker selection by issuing the required deltas. */
128
+ async function save(): Promise<void> {
129
+ const adapter = tableContext.remoteLayouts;
130
+ if (!adapter) {
131
+ errorMessage = 'Sharing is unavailable: no remote layouts adapter is configured.';
132
+ return;
133
+ }
134
+ if (!dirty) {
135
+ onclose();
136
+ return;
137
+ }
138
+
139
+ const currentIds = new Set(selected.map((s) => s.id));
140
+ const toAdd: Array<string> = [];
141
+ const toRemove: Array<string> = [];
142
+
143
+ // Added: in the new selection but not the original roster.
144
+ for (const id of currentIds) {
145
+ if (!initialIds.has(id)) {
146
+ toAdd.push(id);
147
+ }
148
+ }
149
+ // Removed: in the original roster but not the new selection.
150
+ for (const id of initialIds) {
151
+ if (!currentIds.has(id)) {
152
+ toRemove.push(id);
153
+ }
154
+ }
155
+
156
+ errorMessage = null;
157
+ saving = true;
158
+ try {
159
+ // Run sequentially so a partial failure surfaces a useful error
160
+ // and leaves the already-applied deltas committed (an aborted
161
+ // `Promise.all` is much harder to reason about).
162
+ for (const userId of toAdd) {
163
+ await adapter.addSubscriber(view.id, userId);
164
+ }
165
+ for (const userId of toRemove) {
166
+ await adapter.removeSubscriber(view.id, userId);
167
+ }
168
+ if (onsaved) {
169
+ await onsaved();
170
+ }
171
+ onclose();
172
+ } catch (e: unknown) {
173
+ console.error('[ShareViewModal] save failed:', e);
174
+ errorMessage =
175
+ e instanceof Error
176
+ ? `Could not update sharing. Some changes may have been applied. (${e.message})`
177
+ : 'Could not update sharing. Some changes may have been applied.';
178
+ } finally {
179
+ saving = false;
180
+ }
181
+ }
182
+ </script>
183
+
184
+ <DesktopModal
185
+ headerLabel={`Share "${view.name}"`}
186
+ headerSubtitle={`Choose who can access this ${view.kind === 'filter' ? 'filter' : 'layout'}.`}
187
+ onclose={() => {
188
+ if (!saving) {
189
+ onclose();
190
+ }
191
+ }}
192
+ width={cssLength('40vw')}
193
+ minWidth={cssLength('32rem')}
194
+ buttons={[
195
+ {
196
+ label: 'Cancel',
197
+ callback: () => {
198
+ if (!saving) {
199
+ onclose();
200
+ }
201
+ },
202
+ disabled: saving,
203
+ },
204
+ {
205
+ label: saving ? 'Saving…' : 'Save',
206
+ callback: () => {
207
+ void save();
208
+ },
209
+ colourSet: ColourSet.Primary,
210
+ disabled: saving || !dirty || allUsers === null,
211
+ },
212
+ ]}
213
+ >
214
+ <div class="share-body">
215
+ {#if errorMessage}
216
+ <div
217
+ class="error-banner"
218
+ role="alert"
219
+ >
220
+ <Icon
221
+ name="circle-exclamation"
222
+ size={Size.Small}
223
+ />
224
+ <span>{errorMessage}</span>
225
+ </div>
226
+ {/if}
227
+
228
+ <div class="picker">
229
+ {#if loadingUsers && allUsers === null}
230
+ <InfoAlert>Loading users…</InfoAlert>
231
+ {:else if allUsers !== null}
232
+ <MultiSelect
233
+ label="Users"
234
+ name="User"
235
+ options={allUsers as Array<DatatableViewUser>}
236
+ labelProp="displayName"
237
+ valueProp="id"
238
+ valueAsObject={true}
239
+ selectedValues={selected}
240
+ onchange={(values) => {
241
+ selected = values;
242
+ }}
243
+ />
244
+ {/if}
245
+ </div>
246
+
247
+ {#if selected.length === 0}
248
+ <InfoAlert>
249
+ No users selected. Use the picker above to share this {view.kind === 'filter'
250
+ ? 'filter'
251
+ : 'layout'} with one or more users.
252
+ </InfoAlert>
253
+ {:else}
254
+ <ul class="user-card-list">
255
+ {#each selected as user (user.id)}
256
+ <li class="user-card">
257
+ <div class="user-info">
258
+ <Icon
259
+ name="user-3"
260
+ size={Size.Medium}
261
+ />
262
+ <span class="user-name">{user.displayName}</span>
263
+ </div>
264
+ <div class="user-meta">
265
+ <!--
266
+ v1 sharing exposes a single role - subscriber - so
267
+ the "permission" surface is informational only. The
268
+ backend's `editor` / `systemOwned` flags are
269
+ reserved no-ops in v1 (see `DatatableView` DTO
270
+ JSDoc); scoria never sets them.
271
+ -->
272
+ <span class="permission-pill">Subscriber</span>
273
+ <Button
274
+ variant={Variant.Secondary}
275
+ size={Size.MediumSmall}
276
+ nowrap
277
+ iconLeft={{ name: 'circle-cross', size: Size.Small }}
278
+ disabled={saving}
279
+ onclick={() => {
280
+ removeFromSelection(user.id);
281
+ }}>Remove</Button
282
+ >
283
+ </div>
284
+ </li>
285
+ {/each}
286
+ </ul>
287
+ {/if}
288
+ </div>
289
+ </DesktopModal>
290
+
291
291
  <style>.share-body {
292
292
  display: flex;
293
293
  flex-flow: column nowrap;
@@ -370,4 +370,4 @@
370
370
  border-radius: 999px;
371
371
  background-color: #e9ecf1;
372
372
  color: #3a4952;
373
- }</style>
373
+ }</style>
@@ -1,37 +1,37 @@
1
- <svelte:options runes />
2
-
3
- <script
4
- lang="ts"
5
- module
6
- >
7
- import { quintOut } from 'svelte/easing';
8
- import { slide } from 'svelte/transition';
9
- import { Delay } from '../../../Delay/Delay.js';
10
- import { usePrefersReducedMotion } from '../../../Helpers/prefersReducedMotion.svelte.js';
11
- import { ToolbarPosition } from '../Types/Toolbar/ToolbarPosition.js';
12
- import type { SidePanelProps } from './SidePanelProps.js';
13
- </script>
14
-
15
- <script lang="ts">
16
- const { toolbarPosition, onkeydown, ariaLabel, children }: SidePanelProps = $props();
17
- const reducedMotion = usePrefersReducedMotion();
18
- const slideDuration = $derived(reducedMotion.matches ? 0 : Delay.Default);
19
- </script>
20
-
21
- <!-- svelte-ignore a11y_no_static_element_interactions -->
22
- <div
23
- class="side-panel"
24
- class:left={toolbarPosition === ToolbarPosition.Left}
25
- class:right={toolbarPosition === ToolbarPosition.Right}
26
- aria-label={ariaLabel}
27
- {onkeydown}
28
- transition:slide={{ duration: slideDuration, easing: quintOut, axis: 'x' }}
29
- >
30
- <div class="side-content">
31
- {#if children}{@render children()}{/if}
32
- </div>
33
- </div>
34
-
1
+ <svelte:options runes />
2
+
3
+ <script
4
+ lang="ts"
5
+ module
6
+ >
7
+ import { quintOut } from 'svelte/easing';
8
+ import { slide } from 'svelte/transition';
9
+ import { Delay } from '../../../Delay/Delay.js';
10
+ import { usePrefersReducedMotion } from '../../../Helpers/prefersReducedMotion.svelte.js';
11
+ import { ToolbarPosition } from '../Types/Toolbar/ToolbarPosition.js';
12
+ import type { SidePanelProps } from './SidePanelProps.js';
13
+ </script>
14
+
15
+ <script lang="ts">
16
+ const { toolbarPosition, onkeydown, ariaLabel, children }: SidePanelProps = $props();
17
+ const reducedMotion = usePrefersReducedMotion();
18
+ const slideDuration = $derived(reducedMotion.matches ? 0 : Delay.Default);
19
+ </script>
20
+
21
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
22
+ <div
23
+ class="side-panel"
24
+ class:left={toolbarPosition === ToolbarPosition.Left}
25
+ class:right={toolbarPosition === ToolbarPosition.Right}
26
+ aria-label={ariaLabel}
27
+ {onkeydown}
28
+ transition:slide={{ duration: slideDuration, easing: quintOut, axis: 'x' }}
29
+ >
30
+ <div class="side-content">
31
+ {#if children}{@render children()}{/if}
32
+ </div>
33
+ </div>
34
+
35
35
  <style>.side-panel {
36
36
  display: flex;
37
37
  flex-shrink: 0;
@@ -51,4 +51,4 @@
51
51
  flex-flow: column nowrap;
52
52
  flex: 1;
53
53
  width: 400px;
54
- }</style>
54
+ }</style>