@flowdrop/flowdrop 2.17.0 → 2.18.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 (77) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/api/enhanced-client.d.ts +3 -1
  3. package/dist/api/enhanced-client.js +4 -2
  4. package/dist/commands/executor.js +9 -0
  5. package/dist/commands/storeIntegration.svelte.js +6 -0
  6. package/dist/commands/types.d.ts +8 -0
  7. package/dist/components/App.svelte +209 -106
  8. package/dist/components/App.svelte.d.ts +29 -0
  9. package/dist/components/FlowDropZone.svelte +7 -1
  10. package/dist/components/FlowDropZone.svelte.d.ts +5 -0
  11. package/dist/components/ImpactConfirm.svelte +246 -33
  12. package/dist/components/ImpactConfirm.svelte.d.ts +13 -3
  13. package/dist/components/Input.svelte +8 -2
  14. package/dist/components/LockBanner.svelte +76 -0
  15. package/dist/components/LockBanner.svelte.d.ts +14 -0
  16. package/dist/components/LockFence.svelte +33 -0
  17. package/dist/components/LockFence.svelte.d.ts +19 -0
  18. package/dist/components/Navbar.svelte +35 -6
  19. package/dist/components/Navbar.svelte.d.ts +6 -0
  20. package/dist/components/RunBar.svelte +16 -4
  21. package/dist/components/Textarea.svelte +7 -1
  22. package/dist/components/WorkflowEditor.svelte +32 -9
  23. package/dist/components/WorkflowInterfaceEditor.svelte +3 -0
  24. package/dist/components/WorkflowInterfaceEntryCard.svelte +21 -4
  25. package/dist/components/WorkflowPlaygroundSettings.svelte +9 -1
  26. package/dist/components/form/FieldFactory.svelte +13 -6
  27. package/dist/components/form/FormArray.svelte +0 -1
  28. package/dist/components/form/FormArrayRows.svelte +4 -4
  29. package/dist/components/form/FormCodeEditor.svelte +18 -2
  30. package/dist/components/form/FormMarkdownEditor.svelte +22 -8
  31. package/dist/components/form/FormTemplateEditor.svelte +17 -1
  32. package/dist/components/form/readOnly.d.ts +13 -0
  33. package/dist/components/form/readOnly.js +18 -0
  34. package/dist/components/nodes/CaptionNode.svelte +1 -0
  35. package/dist/components/primitives/Checkbox.svelte +5 -1
  36. package/dist/components/primitives/Select.svelte +6 -1
  37. package/dist/components/primitives/Switch.svelte +5 -1
  38. package/dist/editor/index.d.ts +1 -0
  39. package/dist/index.d.ts +2 -1
  40. package/dist/messages/defaults.d.ts +45 -0
  41. package/dist/messages/defaults.js +51 -3
  42. package/dist/openapi/v1/openapi.yaml +492 -0
  43. package/dist/registry/nodeComponentRegistry.d.ts +5 -0
  44. package/dist/schemas/v1/workflow.schema.json +2 -0
  45. package/dist/services/globalSave.d.ts +17 -0
  46. package/dist/services/globalSave.js +166 -6
  47. package/dist/services/impactGate.d.ts +7 -3
  48. package/dist/services/impactGate.js +9 -7
  49. package/dist/services/impactService.d.ts +18 -1
  50. package/dist/services/impactService.js +93 -7
  51. package/dist/services/runsService.d.ts +9 -0
  52. package/dist/services/runsService.js +13 -0
  53. package/dist/services/workflowLaunchService.d.ts +6 -0
  54. package/dist/services/workflowLaunchService.js +2 -0
  55. package/dist/stores/historyStore.svelte.d.ts +12 -2
  56. package/dist/stores/historyStore.svelte.js +25 -2
  57. package/dist/stores/instanceContainer.svelte.d.ts +7 -0
  58. package/dist/stores/instanceContainer.svelte.js +10 -0
  59. package/dist/stores/lockStore.svelte.d.ts +39 -0
  60. package/dist/stores/lockStore.svelte.js +109 -0
  61. package/dist/stores/runController.svelte.d.ts +2 -0
  62. package/dist/stores/runController.svelte.js +27 -11
  63. package/dist/stores/workflowStore.svelte.d.ts +7 -1
  64. package/dist/stores/workflowStore.svelte.js +41 -13
  65. package/dist/styles/base.css +6 -0
  66. package/dist/svelte-app.d.ts +31 -0
  67. package/dist/svelte-app.js +110 -26
  68. package/dist/types/events.d.ts +17 -0
  69. package/dist/types/impact.d.ts +52 -0
  70. package/dist/types/lock.d.ts +35 -0
  71. package/dist/types/lock.js +13 -0
  72. package/dist/types/navbar.d.ts +6 -0
  73. package/dist/utils/links.d.ts +29 -0
  74. package/dist/utils/links.js +63 -0
  75. package/dist/webmcp/runtime.js +16 -3
  76. package/dist/webmcp/types.d.ts +11 -1
  77. package/package.json +1 -1
@@ -19,6 +19,11 @@
19
19
  * ignored.
20
20
  */
21
21
  toFlowPosition: (point: { x: number; y: number }) => { x: number; y: number } | null;
22
+ /**
23
+ * Whether a drop may change the workflow. When false, drops are swallowed
24
+ * (so the browser does not open a dropped file) and nothing is reported.
25
+ */
26
+ editable?: boolean;
22
27
  children: Snippet;
23
28
  }
24
29
 
@@ -30,7 +35,7 @@
30
35
  function handleDragOver(e: DragEvent): void {
31
36
  e.preventDefault();
32
37
  if (e.dataTransfer) {
33
- e.dataTransfer.dropEffect = 'copy';
38
+ e.dataTransfer.dropEffect = props.editable === false ? 'none' : 'copy';
34
39
  }
35
40
  }
36
41
 
@@ -43,6 +48,7 @@
43
48
  */
44
49
  function handleDrop(e: DragEvent): void {
45
50
  e.preventDefault();
51
+ if (props.editable === false) return;
46
52
 
47
53
  // Check if the drop contains files (e.g. a workflow JSON file from the OS)
48
54
  const files = e.dataTransfer?.files;
@@ -18,6 +18,11 @@ interface Props {
18
18
  x: number;
19
19
  y: number;
20
20
  } | null;
21
+ /**
22
+ * Whether a drop may change the workflow. When false, drops are swallowed
23
+ * (so the browser does not open a dropped file) and nothing is reported.
24
+ */
25
+ editable?: boolean;
21
26
  children: Snippet;
22
27
  }
23
28
  declare const FlowDropZone: import("svelte").Component<Props, {}, "">;
@@ -12,21 +12,56 @@
12
12
  -->
13
13
 
14
14
  <script lang="ts">
15
- import { onMount } from 'svelte';
16
- import { m } from '../messages/index.js';
15
+ import { onMount, tick } from 'svelte';
16
+ import { getMessages } from '../messages/context.js';
17
+ import type { Messages } from '../messages/types.js';
17
18
  import Button from './primitives/Button.svelte';
18
- import type { ImpactItem, ImpactReport, ImpactSeverity } from '../types/impact.js';
19
+ import Checkbox from './primitives/Checkbox.svelte';
20
+ import { safeLinkUrl } from '../utils/links.js';
21
+ import type {
22
+ ImpactAnswer,
23
+ ImpactItem,
24
+ ImpactRenamePlace,
25
+ ImpactReport,
26
+ ImpactSeverity,
27
+ SavedCopy
28
+ } from '../types/impact.js';
19
29
 
20
30
  interface Props {
21
31
  /** What the check found. `null` when the check itself failed (see `error`). */
22
32
  report: ImpactReport | null;
23
33
  /** The reason the check failed; shown as one line instead of the list. */
24
34
  error?: string;
25
- /** Called exactly once: `true` to save, `false` to cancel. */
26
- onResolve: (save: boolean) => void;
35
+ /** Called exactly once with what the person decided. */
36
+ onResolve: (answer: ImpactAnswer) => void;
37
+ /**
38
+ * Saves the draft as a new workflow (the refused state's "Save as a copy").
39
+ * Rejects with the reason when it fails; the dialog then stays open.
40
+ */
41
+ onSaveAsCopy?: () => Promise<SavedCopy>;
42
+ /**
43
+ * Throws away every unsaved edit and loads the saved version (the refused
44
+ * state's "Discard my changes").
45
+ */
46
+ onDiscard?: () => Promise<void>;
27
47
  }
28
48
 
29
- let { report, error, onResolve }: Props = $props();
49
+ let { report, error, onResolve, onSaveAsCopy, onDiscard }: Props = $props();
50
+
51
+ // The getter is read at initialisation: the context is gone after an await.
52
+ const readMessages = getMessages();
53
+ const m = (): Messages => readMessages();
54
+
55
+ const refused = $derived(report?.refused === true);
56
+ const renames = $derived(report?.renames ?? []);
57
+ const renamedPlaces = $derived(renames.reduce((n, r) => n + r.places.length, 0));
58
+ const breakingCount = $derived(
59
+ (report?.items ?? []).filter((item) => item.severity === 'breaks').length
60
+ );
61
+ // Opt-in: nothing a rename touches elsewhere changes unless the person asks.
62
+ let followRenames = $state(false);
63
+ let busy = $state<'copy' | 'discard' | null>(null);
64
+ let actionError = $state('');
30
65
 
31
66
  // Unique per instance so two dialogs on one page do not share a DOM id.
32
67
  const uid = $props.id();
@@ -56,22 +91,119 @@
56
91
  cancelWrap?.querySelector('button')?.focus();
57
92
  });
58
93
 
59
- function resolve(save: boolean): void {
94
+ /**
95
+ * The safe answer takes focus. While an action runs every button is
96
+ * disabled and cannot hold focus, so this runs when the action has failed
97
+ * and the buttons are enabled again (the dialog may have been reopened).
98
+ */
99
+ async function focusCancel(): Promise<void> {
100
+ await tick();
101
+ cancelWrap?.querySelector('button')?.focus();
102
+ }
103
+
104
+ function resolve(answer: ImpactAnswer): void {
60
105
  if (resolved) return;
61
106
  resolved = true;
62
107
  if (dialogRef?.open) dialogRef.close();
63
108
  if (opener?.isConnected) opener.focus();
64
- onResolve(save);
109
+ onResolve(answer);
110
+ }
111
+
112
+ function save(): void {
113
+ // Only a box the person saw is an answer.
114
+ resolve(renamedPlaces > 0 ? { action: 'save', followRenames } : { action: 'save' });
115
+ }
116
+
117
+ async function saveCopy(): Promise<void> {
118
+ if (!onSaveAsCopy || busy) return;
119
+ busy = 'copy';
120
+ actionError = '';
121
+ try {
122
+ const copy = await onSaveAsCopy();
123
+ resolve({ action: 'copied', copy });
124
+ } catch (e) {
125
+ actionError = m().impact.refused.copyFailed({
126
+ message: e instanceof Error ? e.message : String(e)
127
+ });
128
+ busy = null;
129
+ void focusCancel();
130
+ }
131
+ }
132
+
133
+ async function discard(): Promise<void> {
134
+ if (!onDiscard || busy) return;
135
+ busy = 'discard';
136
+ actionError = '';
137
+ try {
138
+ await onDiscard();
139
+ resolve({ action: 'discarded' });
140
+ } catch (e) {
141
+ actionError = m().impact.refused.discardFailed({
142
+ message: e instanceof Error ? e.message : String(e)
143
+ });
144
+ busy = null;
145
+ void focusCancel();
146
+ }
65
147
  }
66
148
 
67
149
  // Escape: the native cancel event. Resolve here and keep the browser from
68
150
  // closing the dialog a second time.
69
151
  function handleCancel(event: Event): void {
70
152
  event.preventDefault();
71
- resolve(false);
153
+ if (busy) return;
154
+ resolve({ action: 'cancel' });
155
+ }
156
+
157
+ // The browser can close the dialog without a cancel event (a second Escape
158
+ // under close-request handling). An action in flight must not be cut off:
159
+ // its answer ('copied', 'discarded') or its error is what the person needs,
160
+ // so the dialog opens again. Otherwise whoever waits still gets an answer.
161
+ // `resolve` ignores this when the dialog was closed by an answer.
162
+ function handleClose(): void {
163
+ if (resolved) return;
164
+ if (busy) {
165
+ if (dialogRef && !dialogRef.open) {
166
+ dialogRef.showModal();
167
+ }
168
+ return;
169
+ }
170
+ resolve({ action: 'cancel' });
72
171
  }
73
172
  </script>
74
173
 
174
+ {#snippet label(text: string, url: string | null)}
175
+ {@const href = safeLinkUrl(url)}
176
+ {#if href}
177
+ <a class="fd-impact-confirm__label" {href} target="_blank" rel="noopener">{text}</a>
178
+ {:else}
179
+ <span class="fd-impact-confirm__label">{text}</span>
180
+ {/if}
181
+ {/snippet}
182
+
183
+ {#snippet itemRow(item: ImpactItem, severity: ImpactSeverity)}
184
+ <li class="fd-impact-confirm__item">
185
+ <span class="fd-impact-confirm__severity">{m().impact.severity[severity]}</span>
186
+ <span class="fd-impact-confirm__text">
187
+ {@render label(item.label, item.url)}
188
+ <span class="fd-impact-confirm__message">{item.message}</span>
189
+ </span>
190
+ </li>
191
+ {/snippet}
192
+
193
+ {#snippet placeRow(place: ImpactRenamePlace)}
194
+ <li class="fd-impact-confirm__item fd-impact-confirm__item--place">
195
+ <span class="fd-impact-confirm__text">
196
+ {@render label(place.label, place.url)}
197
+ {#if place.enabled === false}
198
+ <span class="fd-impact-confirm__message">{m().impact.renames.disabledPlace}</span>
199
+ {/if}
200
+ {#if place.message}
201
+ <span class="fd-impact-confirm__message">{place.message}</span>
202
+ {/if}
203
+ </span>
204
+ </li>
205
+ {/snippet}
206
+
75
207
  <dialog
76
208
  bind:this={dialogRef}
77
209
  class="flowdrop-portal fd-impact-confirm"
@@ -80,14 +212,26 @@
80
212
  aria-labelledby={titleId}
81
213
  aria-describedby={bodyId}
82
214
  oncancel={handleCancel}
215
+ onclose={handleClose}
216
+ closedby={busy ? 'none' : 'closerequest'}
83
217
  >
84
218
  <div class="fd-impact-confirm__dialog">
85
219
  <header class="fd-impact-confirm__header">
86
220
  <h2 id={titleId} class="fd-impact-confirm__title">
87
- {m().impact.title}
221
+ {refused ? m().impact.refused.title : m().impact.title}
88
222
  </h2>
89
223
  </header>
90
224
  <div id={bodyId} class="fd-impact-confirm__body">
225
+ {#if refused}
226
+ <p class="fd-impact-confirm__refused" data-testid="flowdrop-impact-refused">
227
+ {m().impact.refused.body({ count: breakingCount })}
228
+ </p>
229
+ {#if report?.refusedMessage}
230
+ <p class="fd-impact-confirm__message fd-impact-confirm__refused-message">
231
+ {report.refusedMessage}
232
+ </p>
233
+ {/if}
234
+ {/if}
91
235
  {#if error}
92
236
  <p class="fd-impact-confirm__error" data-testid="flowdrop-impact-error">
93
237
  {m().impact.failed({ message: error })}
@@ -98,38 +242,81 @@
98
242
  <h3 class="fd-impact-confirm__group-title">{m().impact[group.severity]}</h3>
99
243
  <ul class="fd-impact-confirm__list" role="list">
100
244
  {#each group.items as item (item)}
101
- <li class="fd-impact-confirm__item">
102
- <span class="fd-impact-confirm__severity"
103
- >{m().impact.severity[group.severity]}</span
104
- >
105
- <span class="fd-impact-confirm__text">
106
- {#if item.url}
107
- <a
108
- class="fd-impact-confirm__label"
109
- href={item.url}
110
- target="_blank"
111
- rel="noopener">{item.label}</a
112
- >
113
- {:else}
114
- <span class="fd-impact-confirm__label">{item.label}</span>
115
- {/if}
116
- <span class="fd-impact-confirm__message">{item.message}</span>
117
- </span>
118
- </li>
245
+ {@render itemRow(item, group.severity)}
119
246
  {/each}
120
247
  </ul>
121
248
  </section>
122
249
  {/each}
250
+ {#if !refused && renames.length > 0}
251
+ <section class="fd-impact-confirm__group" data-testid="flowdrop-impact-renames">
252
+ <h3 class="fd-impact-confirm__group-title">{m().impact.renames.heading}</h3>
253
+ {#each renames as rename (rename.direction + rename.from)}
254
+ <p class="fd-impact-confirm__rename-title">
255
+ {m().impact.renames.title({
256
+ kind: m().impact.renames[rename.direction],
257
+ from: rename.from,
258
+ to: rename.to
259
+ })}
260
+ </p>
261
+ {#if rename.places.length > 0}
262
+ <ul class="fd-impact-confirm__list" role="list">
263
+ {#each rename.places as place (place)}
264
+ {@render placeRow(place)}
265
+ {/each}
266
+ </ul>
267
+ {:else}
268
+ <p class="fd-impact-confirm__message">{m().impact.renames.noPlaces}</p>
269
+ {/if}
270
+ {/each}
271
+ {#if renamedPlaces > 0}
272
+ <div class="fd-impact-confirm__follow">
273
+ <Checkbox
274
+ data-testid="flowdrop-impact-follow-renames"
275
+ checked={followRenames}
276
+ onchange={(checked) => (followRenames = checked)}
277
+ label={m().impact.renames.follow({ count: renamedPlaces })}
278
+ />
279
+ </div>
280
+ {/if}
281
+ </section>
282
+ {/if}
283
+ {#if actionError}
284
+ <p class="fd-impact-confirm__error" role="alert" data-testid="flowdrop-impact-action-error">
285
+ {actionError}
286
+ </p>
287
+ {/if}
123
288
  </div>
124
289
  <footer class="fd-impact-confirm__actions">
125
290
  <span class="fd-impact-confirm__cancel" bind:this={cancelWrap}>
126
- <Button data-testid="flowdrop-impact-cancel" onclick={() => resolve(false)}>
127
- {m().impact.cancel}
291
+ <Button
292
+ data-testid="flowdrop-impact-cancel"
293
+ disabled={busy !== null}
294
+ onclick={() => resolve({ action: 'cancel' })}
295
+ >
296
+ {refused ? m().impact.refused.keepEditing : m().impact.cancel}
128
297
  </Button>
129
298
  </span>
130
- <Button variant="primary" data-testid="flowdrop-impact-save" onclick={() => resolve(true)}>
131
- {m().impact.save}
132
- </Button>
299
+ {#if refused}
300
+ {#if onDiscard}
301
+ <Button data-testid="flowdrop-impact-discard" disabled={busy !== null} onclick={discard}>
302
+ {busy === 'discard' ? m().impact.refused.discarding : m().impact.refused.discard}
303
+ </Button>
304
+ {/if}
305
+ {#if onSaveAsCopy && report?.copyUrl}
306
+ <Button
307
+ variant="primary"
308
+ data-testid="flowdrop-impact-copy"
309
+ disabled={busy !== null}
310
+ onclick={saveCopy}
311
+ >
312
+ {busy === 'copy' ? m().impact.refused.copying : m().impact.refused.copy}
313
+ </Button>
314
+ {/if}
315
+ {:else}
316
+ <Button variant="primary" data-testid="flowdrop-impact-save" onclick={save}>
317
+ {renamedPlaces > 0 && !report?.confirm ? m().impact.saveRenames : m().impact.save}
318
+ </Button>
319
+ {/if}
133
320
  </footer>
134
321
  </div>
135
322
  </dialog>
@@ -244,6 +431,32 @@
244
431
  overflow-wrap: anywhere;
245
432
  }
246
433
 
434
+ .fd-impact-confirm__refused,
435
+ .fd-impact-confirm__refused-message,
436
+ .fd-impact-confirm__rename-title {
437
+ margin: 0 0 var(--fd-space-xs, 0.5rem);
438
+ padding: 0;
439
+ overflow-wrap: anywhere;
440
+ }
441
+
442
+ .fd-impact-confirm__refused {
443
+ font-weight: 600;
444
+ }
445
+
446
+ .fd-impact-confirm__rename-title {
447
+ margin-top: var(--fd-space-sm, 0.625rem);
448
+ }
449
+
450
+ .fd-impact-confirm__follow {
451
+ margin-top: var(--fd-space-md, 0.75rem);
452
+ }
453
+
454
+ .fd-impact-confirm__error + .fd-impact-confirm__group,
455
+ .fd-impact-confirm__refused-message + .fd-impact-confirm__group,
456
+ .fd-impact-confirm__refused + .fd-impact-confirm__group {
457
+ margin-top: var(--fd-space-lg, 0.875rem);
458
+ }
459
+
247
460
  .fd-impact-confirm__group + .fd-impact-confirm__group {
248
461
  margin-top: var(--fd-space-lg, 0.875rem);
249
462
  }
@@ -1,11 +1,21 @@
1
- import type { ImpactReport } from '../types/impact.js';
1
+ import type { ImpactAnswer, ImpactReport, SavedCopy } from '../types/impact.js';
2
2
  interface Props {
3
3
  /** What the check found. `null` when the check itself failed (see `error`). */
4
4
  report: ImpactReport | null;
5
5
  /** The reason the check failed; shown as one line instead of the list. */
6
6
  error?: string;
7
- /** Called exactly once: `true` to save, `false` to cancel. */
8
- onResolve: (save: boolean) => void;
7
+ /** Called exactly once with what the person decided. */
8
+ onResolve: (answer: ImpactAnswer) => void;
9
+ /**
10
+ * Saves the draft as a new workflow (the refused state's "Save as a copy").
11
+ * Rejects with the reason when it fails; the dialog then stays open.
12
+ */
13
+ onSaveAsCopy?: () => Promise<SavedCopy>;
14
+ /**
15
+ * Throws away every unsaved edit and loads the saved version (the refused
16
+ * state's "Discard my changes").
17
+ */
18
+ onDiscard?: () => Promise<void>;
9
19
  }
10
20
  declare const ImpactConfirm: import("svelte").Component<Props, {}, "">;
11
21
  type ImpactConfirm = ReturnType<typeof ImpactConfirm>;
@@ -17,6 +17,7 @@
17
17
  <script lang="ts">
18
18
  import type { Snippet } from 'svelte';
19
19
  import type { HTMLInputAttributes } from 'svelte/elements';
20
+ import { useFormReadOnly } from './form/readOnly.js';
20
21
 
21
22
  // Omit native numeric `size` so our design-token size (matching Button) wins.
22
23
  interface Props extends Omit<HTMLInputAttributes, 'size'> {
@@ -41,6 +42,11 @@
41
42
  ...rest
42
43
  }: Props = $props();
43
44
 
45
+ const formReadOnly = useFormReadOnly();
46
+ // A read-only form (a locked editor) keeps the value readable: it can be
47
+ // focused, selected and copied, just not changed. Hence readonly, not disabled.
48
+ const isReadOnly = $derived(Boolean(rest.readonly) || formReadOnly());
49
+
44
50
  const inputClass = $derived(
45
51
  [
46
52
  'flowdrop-input',
@@ -62,7 +68,7 @@
62
68
  {@render leading()}
63
69
  </span>
64
70
  {/if}
65
- <input class={inputClass} {...rest} />
71
+ <input class={inputClass} {...rest} readonly={isReadOnly} />
66
72
  {#if trailing}
67
73
  <span class="flowdrop-input-wrap__icon flowdrop-input-wrap__icon--trailing">
68
74
  {@render trailing()}
@@ -70,5 +76,5 @@
70
76
  {/if}
71
77
  </div>
72
78
  {:else}
73
- <input class={inputClass} {...rest} />
79
+ <input class={inputClass} {...rest} readonly={isReadOnly} />
74
80
  {/if}
@@ -0,0 +1,76 @@
1
+ <!--
2
+ @component
3
+ LockBanner: the strip above the canvas that says why the workflow is read-only
4
+ and offers the actions the host chose (for example "Edit anyway").
5
+
6
+ It draws nothing while the editor is not locked. Reasons are plain text, each
7
+ with an optional "Learn more" link; the buttons report their id to the host
8
+ through `fd.lock` (`onLockAction`).
9
+
10
+ **Use it for** the one place the editor explains a lock.
11
+ **Not for** other messages; use `Notice`.
12
+ -->
13
+
14
+ <script lang="ts">
15
+ import { getInstance } from '../stores/getInstance.svelte.js';
16
+ import Notice from './primitives/Notice.svelte';
17
+ import Button from './primitives/Button.svelte';
18
+ import { m } from '../messages/index.js';
19
+ import { safeLinkUrl } from '../utils/links.js';
20
+
21
+ const fd = getInstance();
22
+ const lock = $derived(fd.lock.current);
23
+ const lockMessages = $derived(m().lock);
24
+
25
+ /** Only http(s) and site-relative links are made clickable. */
26
+ const safeUrl = safeLinkUrl;
27
+ </script>
28
+
29
+ {#if lock}
30
+ <div class="flowdrop-lock-banner" data-testid="lock-banner">
31
+ <Notice tone="info" title={lockMessages.title} role="status">
32
+ {#each lock.reasons as reason, index (index)}
33
+ <p class="flowdrop-lock-banner__reason" data-kind={reason.kind}>
34
+ {reason.message}
35
+ {#if safeUrl(reason.url)}
36
+ <a href={safeUrl(reason.url)} target="_blank" rel="noopener noreferrer"
37
+ >{lockMessages.learnMore}</a
38
+ >
39
+ {/if}
40
+ </p>
41
+ {/each}
42
+ {#snippet actions()}
43
+ {#each lock.actions as action (action.id)}
44
+ <Button
45
+ size="sm"
46
+ variant={action.primary ? 'primary' : 'secondary'}
47
+ data-testid="lock-action-{action.id}"
48
+ onclick={() => fd.lock.fire(action.id)}
49
+ >
50
+ {action.label}
51
+ </Button>
52
+ {/each}
53
+ {/snippet}
54
+ </Notice>
55
+ </div>
56
+ {/if}
57
+
58
+ <style>
59
+ .flowdrop-lock-banner {
60
+ flex: none;
61
+ padding: var(--fd-space-xs) var(--fd-space-md) 0;
62
+ }
63
+
64
+ .flowdrop-lock-banner__reason {
65
+ margin: 0;
66
+ }
67
+
68
+ .flowdrop-lock-banner__reason + .flowdrop-lock-banner__reason {
69
+ margin-top: var(--fd-space-3xs);
70
+ }
71
+
72
+ .flowdrop-lock-banner__reason a {
73
+ color: var(--fd-primary);
74
+ white-space: nowrap;
75
+ }
76
+ </style>
@@ -0,0 +1,14 @@
1
+ /**
2
+ * LockBanner: the strip above the canvas that says why the workflow is read-only
3
+ * and offers the actions the host chose (for example "Edit anyway").
4
+ *
5
+ * It draws nothing while the editor is not locked. Reasons are plain text, each
6
+ * with an optional "Learn more" link; the buttons report their id to the host
7
+ * through `fd.lock` (`onLockAction`).
8
+ *
9
+ * **Use it for** the one place the editor explains a lock.
10
+ * **Not for** other messages; use `Notice`.
11
+ */
12
+ declare const LockBanner: import("svelte").Component<Record<string, never>, {}, "">;
13
+ type LockBanner = ReturnType<typeof LockBanner>;
14
+ export default LockBanner;
@@ -0,0 +1,33 @@
1
+ <!--
2
+ @component
3
+ LockFence: makes the form controls inside it read-only while the editor is locked.
4
+
5
+ It tells every form field below it, through the form read-only context, that the
6
+ form is read-only. Inputs, selects, switches, code editors and the buttons that
7
+ add, move or remove things then stop answering, while text stays selectable and
8
+ the buttons that only open, close or refresh something keep working. The workflow
9
+ store refuses edits as well; this is what the person sees.
10
+
11
+ **Use it for** wrapping a config form or panel body that edits the workflow.
12
+ **Not for** navigation inside a panel (tabs stay usable on a locked workflow).
13
+ -->
14
+
15
+ <script lang="ts">
16
+ import type { Snippet } from 'svelte';
17
+ import { getInstance } from '../stores/getInstance.svelte.js';
18
+ import { provideFormReadOnly } from './form/readOnly.js';
19
+
20
+ let { children }: { children: Snippet } = $props();
21
+ const fd = getInstance();
22
+ provideFormReadOnly(() => fd.lock.isLocked);
23
+ </script>
24
+
25
+ <div class="flowdrop-lock-fence" data-locked={fd.lock.isLocked ? '' : undefined}>
26
+ {@render children()}
27
+ </div>
28
+
29
+ <style>
30
+ .flowdrop-lock-fence {
31
+ display: contents;
32
+ }
33
+ </style>
@@ -0,0 +1,19 @@
1
+ import type { Snippet } from 'svelte';
2
+ type $$ComponentProps = {
3
+ children: Snippet;
4
+ };
5
+ /**
6
+ * LockFence: makes the form controls inside it read-only while the editor is locked.
7
+ *
8
+ * It tells every form field below it, through the form read-only context, that the
9
+ * form is read-only. Inputs, selects, switches, code editors and the buttons that
10
+ * add, move or remove things then stop answering, while text stays selectable and
11
+ * the buttons that only open, close or refresh something keep working. The workflow
12
+ * store refuses edits as well; this is what the person sees.
13
+ *
14
+ * **Use it for** wrapping a config form or panel body that edits the workflow.
15
+ * **Not for** navigation inside a panel (tabs stay usable on a locked workflow).
16
+ */
17
+ declare const LockFence: import("svelte").Component<$$ComponentProps, {}, "">;
18
+ type LockFence = ReturnType<typeof LockFence>;
19
+ export default LockFence;