@flowdrop/flowdrop 2.16.0 → 2.17.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 (84) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +6 -1
  3. package/dist/components/App.svelte +212 -6
  4. package/dist/components/App.svelte.d.ts +2 -0
  5. package/dist/components/CanvasToolbar.svelte +40 -3
  6. package/dist/components/CanvasToolbar.svelte.d.ts +5 -1
  7. package/dist/components/ConnectPortPicker.svelte +8 -4
  8. package/dist/components/DoctorMenu.svelte +208 -126
  9. package/dist/components/ImpactConfirm.svelte +341 -0
  10. package/dist/components/ImpactConfirm.svelte.d.ts +12 -0
  11. package/dist/components/Navbar.svelte +42 -3
  12. package/dist/components/Navbar.svelte.d.ts +4 -0
  13. package/dist/components/NodeSidebar.svelte +36 -15
  14. package/dist/components/NodeSidebar.svelte.d.ts +2 -0
  15. package/dist/components/NodeSwapPicker.svelte +4 -14
  16. package/dist/components/RunBar.svelte +36 -1
  17. package/dist/components/RunBar.svelte.d.ts +5 -0
  18. package/dist/components/RunInputsDialog.svelte +198 -0
  19. package/dist/components/RunInputsDialog.svelte.d.ts +34 -0
  20. package/dist/components/WorkflowCompareDialog.svelte +177 -0
  21. package/dist/components/WorkflowCompareDialog.svelte.d.ts +10 -0
  22. package/dist/components/WorkflowEditor.svelte +88 -6
  23. package/dist/components/WorkflowEditor.svelte.d.ts +6 -0
  24. package/dist/components/WorkflowInterfaceEditor.svelte +14 -4
  25. package/dist/components/WorkflowInterfaceEntryCard.svelte +19 -3
  26. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +2 -0
  27. package/dist/components/nodes/NodeCard.svelte +2 -2
  28. package/dist/components/toast/DismissibleToast.svelte +25 -6
  29. package/dist/components/toast/DismissibleToast.svelte.d.ts +3 -0
  30. package/dist/config/endpoints.d.ts +7 -0
  31. package/dist/config/endpoints.js +2 -1
  32. package/dist/editor/connectCandidates.d.ts +3 -0
  33. package/dist/editor/connectCandidates.js +14 -5
  34. package/dist/editor/index.d.ts +1 -1
  35. package/dist/editor/index.js +1 -1
  36. package/dist/helpers/workflowEditorHelper.d.ts +15 -0
  37. package/dist/helpers/workflowEditorHelper.js +9 -0
  38. package/dist/index.d.ts +1 -0
  39. package/dist/messages/defaults.d.ts +100 -0
  40. package/dist/messages/defaults.js +91 -1
  41. package/dist/services/draftStorage.d.ts +24 -10
  42. package/dist/services/draftStorage.js +60 -35
  43. package/dist/services/globalSave.d.ts +28 -10
  44. package/dist/services/globalSave.js +135 -31
  45. package/dist/services/impactGate.d.ts +34 -0
  46. package/dist/services/impactGate.js +70 -0
  47. package/dist/services/impactService.d.ts +28 -0
  48. package/dist/services/impactService.js +71 -0
  49. package/dist/services/toastQueue.d.ts +9 -0
  50. package/dist/services/toastService.d.ts +4 -0
  51. package/dist/services/toastService.js +9 -3
  52. package/dist/services/workflowLaunchService.js +3 -1
  53. package/dist/settings/index.d.ts +2 -2
  54. package/dist/settings/index.js +1 -1
  55. package/dist/stores/doctorStore.svelte.d.ts +24 -1
  56. package/dist/stores/doctorStore.svelte.js +105 -2
  57. package/dist/stores/instanceContainer.svelte.d.ts +16 -0
  58. package/dist/stores/instanceContainer.svelte.js +22 -2
  59. package/dist/stores/saveConflictStore.svelte.d.ts +62 -0
  60. package/dist/stores/saveConflictStore.svelte.js +169 -0
  61. package/dist/stores/workflowStore.svelte.d.ts +7 -3
  62. package/dist/stores/workflowStore.svelte.js +14 -5
  63. package/dist/styles/toast.css +10 -1
  64. package/dist/svelte-app.d.ts +2 -0
  65. package/dist/svelte-app.js +74 -2
  66. package/dist/types/doctor.d.ts +3 -1
  67. package/dist/types/events.d.ts +20 -0
  68. package/dist/types/events.js +2 -0
  69. package/dist/types/impact.d.ts +25 -0
  70. package/dist/types/impact.js +7 -0
  71. package/dist/types/settings.d.ts +31 -0
  72. package/dist/types/settings.js +132 -0
  73. package/dist/utils/draftRestore.d.ts +27 -0
  74. package/dist/utils/draftRestore.js +36 -0
  75. package/dist/utils/interfaceTags.js +4 -1
  76. package/dist/utils/nodeSearch.d.ts +10 -0
  77. package/dist/utils/nodeSearch.js +37 -0
  78. package/dist/utils/runOffer.d.ts +21 -0
  79. package/dist/utils/runOffer.js +13 -0
  80. package/dist/utils/workflowCompare.d.ts +35 -0
  81. package/dist/utils/workflowCompare.js +84 -0
  82. package/dist/utils/workflowInterface.d.ts +26 -1
  83. package/dist/utils/workflowInterface.js +91 -11
  84. package/package.json +3 -2
@@ -0,0 +1,341 @@
1
+ <!--
2
+ ImpactConfirm
3
+
4
+ The dialog shown before a workflow save that breaks or changes what uses the
5
+ workflow: lists the affected things by severity and asks the person at the
6
+ keyboard. Mounted imperatively by `services/impactGate.ts` into the host's
7
+ container (default `document.body`), one at a time per editor.
8
+
9
+ A native modal `<dialog>`: the page behind it is inert, Tab stays inside, and
10
+ the item links are part of the Tab order. Focus starts on Cancel, so Enter
11
+ never saves a breaking change by reflex.
12
+ -->
13
+
14
+ <script lang="ts">
15
+ import { onMount } from 'svelte';
16
+ import { m } from '../messages/index.js';
17
+ import Button from './primitives/Button.svelte';
18
+ import type { ImpactItem, ImpactReport, ImpactSeverity } from '../types/impact.js';
19
+
20
+ interface Props {
21
+ /** What the check found. `null` when the check itself failed (see `error`). */
22
+ report: ImpactReport | null;
23
+ /** The reason the check failed; shown as one line instead of the list. */
24
+ error?: string;
25
+ /** Called exactly once: `true` to save, `false` to cancel. */
26
+ onResolve: (save: boolean) => void;
27
+ }
28
+
29
+ let { report, error, onResolve }: Props = $props();
30
+
31
+ // Unique per instance so two dialogs on one page do not share a DOM id.
32
+ const uid = $props.id();
33
+ const titleId = `${uid}-impact-title`;
34
+ const bodyId = `${uid}-impact-body`;
35
+
36
+ const severities: ImpactSeverity[] = ['breaks', 'changes', 'info'];
37
+
38
+ const groups = $derived(
39
+ severities
40
+ .map((severity) => ({
41
+ severity,
42
+ items: (report?.items ?? []).filter((item: ImpactItem) => item.severity === severity)
43
+ }))
44
+ .filter((group) => group.items.length > 0)
45
+ );
46
+
47
+ let dialogRef = $state<HTMLDialogElement | null>(null);
48
+ let cancelWrap = $state<HTMLElement | null>(null);
49
+ let opener: HTMLElement | null = null;
50
+ let resolved = false;
51
+
52
+ onMount(() => {
53
+ opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
54
+ if (dialogRef && !dialogRef.open) dialogRef.showModal();
55
+ // showModal focuses the first control (a link); the safe answer comes first.
56
+ cancelWrap?.querySelector('button')?.focus();
57
+ });
58
+
59
+ function resolve(save: boolean): void {
60
+ if (resolved) return;
61
+ resolved = true;
62
+ if (dialogRef?.open) dialogRef.close();
63
+ if (opener?.isConnected) opener.focus();
64
+ onResolve(save);
65
+ }
66
+
67
+ // Escape: the native cancel event. Resolve here and keep the browser from
68
+ // closing the dialog a second time.
69
+ function handleCancel(event: Event): void {
70
+ event.preventDefault();
71
+ resolve(false);
72
+ }
73
+ </script>
74
+
75
+ <dialog
76
+ bind:this={dialogRef}
77
+ class="flowdrop-portal fd-impact-confirm"
78
+ data-testid="flowdrop-impact-confirm"
79
+ role="alertdialog"
80
+ aria-labelledby={titleId}
81
+ aria-describedby={bodyId}
82
+ oncancel={handleCancel}
83
+ >
84
+ <div class="fd-impact-confirm__dialog">
85
+ <header class="fd-impact-confirm__header">
86
+ <h2 id={titleId} class="fd-impact-confirm__title">
87
+ {m().impact.title}
88
+ </h2>
89
+ </header>
90
+ <div id={bodyId} class="fd-impact-confirm__body">
91
+ {#if error}
92
+ <p class="fd-impact-confirm__error" data-testid="flowdrop-impact-error">
93
+ {m().impact.failed({ message: error })}
94
+ </p>
95
+ {/if}
96
+ {#each groups as group (group.severity)}
97
+ <section class="fd-impact-confirm__group" data-severity={group.severity}>
98
+ <h3 class="fd-impact-confirm__group-title">{m().impact[group.severity]}</h3>
99
+ <ul class="fd-impact-confirm__list" role="list">
100
+ {#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>
119
+ {/each}
120
+ </ul>
121
+ </section>
122
+ {/each}
123
+ </div>
124
+ <footer class="fd-impact-confirm__actions">
125
+ <span class="fd-impact-confirm__cancel" bind:this={cancelWrap}>
126
+ <Button data-testid="flowdrop-impact-cancel" onclick={() => resolve(false)}>
127
+ {m().impact.cancel}
128
+ </Button>
129
+ </span>
130
+ <Button variant="primary" data-testid="flowdrop-impact-save" onclick={() => resolve(true)}>
131
+ {m().impact.save}
132
+ </Button>
133
+ </footer>
134
+ </div>
135
+ </dialog>
136
+
137
+ <style>
138
+ /* Mounted on document.body, outside the editor tree. Tokens come from :root
139
+ (tokens.css) and, for a skinned editor, from the editor's scope, which the
140
+ helper copies onto the host element; the dark palette follows
141
+ [data-theme='dark'] on the host element; the buttons are the Button primitive.
142
+ Everything else is set here, because the host page's own element
143
+ rules (h2, h3, p, ul, li, a) reach a dialog on <body>: every element below
144
+ states its margin, padding, font and list style. */
145
+ .fd-impact-confirm {
146
+ position: fixed;
147
+ inset: 0;
148
+ z-index: 10000;
149
+ width: 100%;
150
+ height: 100%;
151
+ max-width: none;
152
+ max-height: none;
153
+ box-sizing: border-box;
154
+ margin: 0;
155
+ border: 0;
156
+ color: inherit;
157
+ align-items: center;
158
+ justify-content: center;
159
+ padding: var(--fd-space-xl, 1rem);
160
+ background: color-mix(in srgb, var(--fd-foreground) 50%, transparent);
161
+ backdrop-filter: blur(4px);
162
+ font-family: var(--fd-font-sans, system-ui, sans-serif);
163
+ font-size: var(--fd-text-sm, 0.875rem);
164
+ font-weight: 400;
165
+ line-height: var(--fd-leading-normal, 1.5);
166
+ letter-spacing: normal;
167
+ text-align: left;
168
+ text-transform: none;
169
+ }
170
+
171
+ .fd-impact-confirm:not([open]) {
172
+ display: none;
173
+ }
174
+
175
+ .fd-impact-confirm[open] {
176
+ display: flex;
177
+ }
178
+
179
+ .fd-impact-confirm::backdrop {
180
+ background: transparent;
181
+ }
182
+
183
+ .fd-impact-confirm__cancel {
184
+ display: contents;
185
+ }
186
+
187
+ .fd-impact-confirm__dialog {
188
+ display: flex;
189
+ flex-direction: column;
190
+ width: 100%;
191
+ max-width: 36rem;
192
+ max-height: calc(100vh - 2 * var(--fd-space-xl, 1rem));
193
+ overflow: hidden;
194
+ border: 1px solid var(--fd-border);
195
+ border-radius: var(--fd-radius-lg, 0.5rem);
196
+ background: var(--fd-background);
197
+ color: var(--fd-foreground);
198
+ box-shadow: var(--fd-shadow-xl);
199
+ animation: fd-impact-confirm-enter 0.2s ease-out;
200
+ }
201
+
202
+ @keyframes fd-impact-confirm-enter {
203
+ from {
204
+ opacity: 0;
205
+ transform: scale(0.95) translateY(-10px);
206
+ }
207
+ to {
208
+ opacity: 1;
209
+ transform: scale(1) translateY(0);
210
+ }
211
+ }
212
+
213
+ .fd-impact-confirm__header {
214
+ flex-shrink: 0;
215
+ padding: var(--fd-space-xl, 1rem) var(--fd-space-xl, 1rem) var(--fd-space-lg, 0.875rem);
216
+ border-bottom: 1px solid var(--fd-border);
217
+ }
218
+
219
+ .fd-impact-confirm__title {
220
+ margin: 0;
221
+ padding: 0;
222
+ font-family: inherit;
223
+ font-size: var(--fd-text-lg, 1.125rem);
224
+ letter-spacing: normal;
225
+ text-transform: none;
226
+ font-weight: 600;
227
+ line-height: var(--fd-leading-tight, 1.3);
228
+ color: var(--fd-foreground);
229
+ overflow-wrap: anywhere;
230
+ }
231
+
232
+ .fd-impact-confirm__body {
233
+ flex: 1;
234
+ min-height: 0;
235
+ overflow: auto;
236
+ padding: var(--fd-space-xl, 1rem);
237
+ }
238
+
239
+ .fd-impact-confirm__error {
240
+ margin: 0;
241
+ padding: 0;
242
+ font-size: var(--fd-text-sm, 0.875rem);
243
+ color: var(--fd-foreground);
244
+ overflow-wrap: anywhere;
245
+ }
246
+
247
+ .fd-impact-confirm__group + .fd-impact-confirm__group {
248
+ margin-top: var(--fd-space-lg, 0.875rem);
249
+ }
250
+
251
+ .fd-impact-confirm__group-title {
252
+ margin: 0 0 var(--fd-space-xs, 0.5rem);
253
+ padding: 0;
254
+ font-family: inherit;
255
+ font-size: var(--fd-text-sm, 0.875rem);
256
+ font-weight: 600;
257
+ letter-spacing: normal;
258
+ text-transform: none;
259
+ line-height: var(--fd-leading-tight, 1.3);
260
+ color: var(--fd-foreground);
261
+ }
262
+
263
+ .fd-impact-confirm__list {
264
+ display: grid;
265
+ margin: 0;
266
+ padding: 0;
267
+ list-style: none;
268
+ border: 1px solid var(--fd-border);
269
+ border-radius: var(--fd-radius-md, 0.375rem);
270
+ background: var(--fd-muted);
271
+ overflow: hidden;
272
+ }
273
+
274
+ .fd-impact-confirm__item {
275
+ display: flex;
276
+ align-items: baseline;
277
+ gap: var(--fd-space-sm, 0.625rem);
278
+ margin: 0;
279
+ padding: var(--fd-space-xs, 0.5rem) var(--fd-space-md, 0.75rem);
280
+ list-style: none;
281
+ }
282
+
283
+ .fd-impact-confirm__item + .fd-impact-confirm__item {
284
+ border-top: 1px solid var(--fd-border-muted);
285
+ }
286
+
287
+ .fd-impact-confirm__severity {
288
+ flex-shrink: 0;
289
+ font-size: var(--fd-text-xs, 0.8125rem);
290
+ font-weight: 600;
291
+ text-transform: none;
292
+ color: var(--fd-muted-foreground);
293
+ }
294
+
295
+ .fd-impact-confirm__text {
296
+ min-width: 0;
297
+ line-height: var(--fd-leading-normal, 1.5);
298
+ overflow-wrap: anywhere;
299
+ }
300
+
301
+ .fd-impact-confirm__label {
302
+ font-weight: 600;
303
+ color: var(--fd-foreground);
304
+ }
305
+
306
+ a.fd-impact-confirm__label {
307
+ color: var(--fd-primary);
308
+ text-decoration: underline;
309
+ }
310
+
311
+ .fd-impact-confirm__message {
312
+ color: var(--fd-muted-foreground);
313
+ }
314
+
315
+ .fd-impact-confirm__actions {
316
+ flex-shrink: 0;
317
+ display: flex;
318
+ justify-content: flex-end;
319
+ gap: var(--fd-space-sm, 0.625rem);
320
+ padding: var(--fd-space-lg, 0.875rem) var(--fd-space-xl, 1rem);
321
+ border-top: 1px solid var(--fd-border);
322
+ background: var(--fd-muted);
323
+ }
324
+
325
+ @media (max-width: 640px) {
326
+ .fd-impact-confirm {
327
+ padding: 0;
328
+ align-items: flex-end;
329
+ }
330
+
331
+ .fd-impact-confirm__dialog {
332
+ max-width: 100%;
333
+ max-height: 100vh;
334
+ border-radius: var(--fd-radius-lg, 0.5rem) var(--fd-radius-lg, 0.5rem) 0 0;
335
+ }
336
+
337
+ .fd-impact-confirm__actions {
338
+ flex-direction: column-reverse;
339
+ }
340
+ }
341
+ </style>
@@ -0,0 +1,12 @@
1
+ import type { ImpactReport } from '../types/impact.js';
2
+ interface Props {
3
+ /** What the check found. `null` when the check itself failed (see `error`). */
4
+ report: ImpactReport | null;
5
+ /** The reason the check failed; shown as one line instead of the list. */
6
+ error?: string;
7
+ /** Called exactly once: `true` to save, `false` to cancel. */
8
+ onResolve: (save: boolean) => void;
9
+ }
10
+ declare const ImpactConfirm: import("svelte").Component<Props, {}, "">;
11
+ type ImpactConfirm = ReturnType<typeof ImpactConfirm>;
12
+ export default ImpactConfirm;
@@ -45,6 +45,8 @@
45
45
  showStatus?: boolean;
46
46
  /** Page title */
47
47
  title?: string;
48
+ /** Heading level of the title: 1 makes it the page's H1 */
49
+ titleLevel?: 1 | 2;
48
50
  /** Breadcrumb navigation items */
49
51
  breadcrumbs?: BreadcrumbItem[];
50
52
  /** Show settings gear icon */
@@ -76,12 +78,15 @@
76
78
  * Renders nothing of its own, so an empty snippet leaves no gap.
77
79
  */
78
80
  status?: Snippet;
81
+ /** The workflow has changes that are not saved: the first action (Save) shows a dot. */
82
+ dirty?: boolean;
79
83
  }
80
84
 
81
85
  let {
82
86
  primaryActions = [],
83
87
  showStatus = true,
84
88
  title,
89
+ titleLevel = 2,
85
90
  breadcrumbs = [],
86
91
  showSettings = true,
87
92
  settingsCategories,
@@ -92,7 +97,8 @@
92
97
  onWorkflowSettings,
93
98
  workflowSettingsOpen = false,
94
99
  saveShortcut = false,
95
- status
100
+ status,
101
+ dirty = false
96
102
  }: Props = $props();
97
103
 
98
104
  // Settings modal state
@@ -323,7 +329,10 @@
323
329
  {:else if title}
324
330
  <div class="flowdrop-navbar__title-container">
325
331
  <div class="flowdrop-navbar__title">
326
- <h2 class="flowdrop-navbar__title-text">{title}</h2>
332
+ <svelte:element
333
+ this={titleLevel === 1 ? 'h1' : 'h2'}
334
+ class="flowdrop-navbar__title-text">{title}</svelte:element
335
+ >
327
336
  </div>
328
337
  </div>
329
338
  {/if}
@@ -348,10 +357,13 @@
348
357
  {#if taskActions.length > 0}
349
358
  <!-- Split mode: all actions as individual side-by-side buttons -->
350
359
  <div class="flowdrop-navbar__split-actions">
351
- {#each taskActions as action (action.label)}
360
+ {#each taskActions as action, index (action.label)}
361
+ {@const unsaved = dirty && index === 0}
352
362
  <a
353
363
  href={action.href}
354
364
  class="flowdrop-navbar__action flowdrop-navbar__action--{action.variant || 'primary'}"
365
+ data-dirty={unsaved ? 'true' : undefined}
366
+ title={unsaved ? `${action.label}, ${nav.unsavedChanges}` : undefined}
355
367
  onclick={action.onclick}
356
368
  target={action.external ? '_blank' : undefined}
357
369
  rel={action.external ? 'noopener noreferrer' : undefined}
@@ -362,6 +374,10 @@
362
374
  </span>
363
375
  {/if}
364
376
  <span class="flowdrop-navbar__action-label">{action.label}</span>
377
+ {#if unsaved}
378
+ <span class="flowdrop-navbar__dirty-dot" aria-hidden="true"></span>
379
+ <span class="flowdrop-navbar__visually-hidden">, {nav.unsavedChanges}</span>
380
+ {/if}
365
381
  </a>
366
382
  {/each}
367
383
  </div>
@@ -374,6 +390,8 @@
374
390
  href={primaryAction.href}
375
391
  class="flowdrop-navbar__primary-action flowdrop-navbar__action--{primaryAction.variant ||
376
392
  'primary'}"
393
+ data-dirty={dirty ? 'true' : undefined}
394
+ title={dirty ? `${primaryAction.label}, ${nav.unsavedChanges}` : undefined}
377
395
  onclick={primaryAction.onclick}
378
396
  target={primaryAction.external ? '_blank' : undefined}
379
397
  rel={primaryAction.external ? 'noopener noreferrer' : undefined}
@@ -384,6 +402,10 @@
384
402
  </span>
385
403
  {/if}
386
404
  <span class="flowdrop-navbar__action-label">{primaryAction.label}</span>
405
+ {#if dirty}
406
+ <span class="flowdrop-navbar__dirty-dot" aria-hidden="true"></span>
407
+ <span class="flowdrop-navbar__visually-hidden">, {nav.unsavedChanges}</span>
408
+ {/if}
387
409
  </a>
388
410
  {/if}
389
411
 
@@ -1072,6 +1094,23 @@
1072
1094
  font-weight: 500;
1073
1095
  }
1074
1096
 
1097
+ .flowdrop-navbar__dirty-dot {
1098
+ width: 6px;
1099
+ height: 6px;
1100
+ border-radius: var(--fd-radius-full);
1101
+ background: var(--fd-warning);
1102
+ flex-shrink: 0;
1103
+ }
1104
+
1105
+ .flowdrop-navbar__visually-hidden {
1106
+ position: absolute;
1107
+ width: 1px;
1108
+ height: 1px;
1109
+ overflow: hidden;
1110
+ clip-path: inset(50%);
1111
+ white-space: nowrap;
1112
+ }
1113
+
1075
1114
  .flowdrop-navbar__end {
1076
1115
  display: flex;
1077
1116
  align-items: center;
@@ -13,6 +13,8 @@ interface Props {
13
13
  showStatus?: boolean;
14
14
  /** Page title */
15
15
  title?: string;
16
+ /** Heading level of the title: 1 makes it the page's H1 */
17
+ titleLevel?: 1 | 2;
16
18
  /** Breadcrumb navigation items */
17
19
  breadcrumbs?: BreadcrumbItem[];
18
20
  /** Show settings gear icon */
@@ -44,6 +46,8 @@ interface Props {
44
46
  * Renders nothing of its own, so an empty snippet leaves no gap.
45
47
  */
46
48
  status?: Snippet;
49
+ /** The workflow has changes that are not saved: the first action (Save) shows a dot. */
50
+ dirty?: boolean;
47
51
  }
48
52
  /**
49
53
  * The bar along the top of the editor: logo and breadcrumbs on the left, actions in the middle,
@@ -20,6 +20,7 @@
20
20
  import { getInstance } from '../stores/getInstance.svelte.js';
21
21
  import { getUiSettings } from '../stores/settingsStore.svelte.js';
22
22
  import { extractConfigDefaults } from '../utils/nodeIds.js';
23
+ import { searchNodeTypes } from '../utils/nodeSearch.js';
23
24
  import { m } from '../messages/index.js';
24
25
 
25
26
  interface Props {
@@ -41,6 +42,8 @@
41
42
  * flat 32px category rows (no card, no border) with a filled search field.
42
43
  */
43
44
  listStyle?: 'cards' | 'flat' | 'rows';
45
+ /** Called when a palette item is clicked or activated with Enter or Space. */
46
+ onadd?: (nodeType: NodeMetadata) => void;
44
47
  }
45
48
 
46
49
  let props: Props = $props();
@@ -103,7 +106,7 @@
103
106
 
104
107
  /**
105
108
  * Filter node types based on search query and selected category
106
- * Preserves the API order - no client-side sorting applied
109
+ * Without a query the API order is preserved; a query ranks matches
107
110
  */
108
111
  function getFilteredNodes(): NodeMetadata[] {
109
112
  // Start with format-compatible nodes
@@ -114,21 +117,25 @@
114
117
  filtered = filtered.filter((node) => node.category === selectedCategory);
115
118
  }
116
119
 
117
- // Filter by search query
118
- if (searchInput.trim()) {
119
- const query = searchInput.toLowerCase();
120
- filtered = filtered.filter(
121
- (node) =>
122
- node.name.toLowerCase().includes(query) ||
123
- node.description.toLowerCase().includes(query) ||
124
- node.tags?.some((tag) => tag.toLowerCase().includes(query))
125
- );
126
- }
120
+ // Search ranks exact matches first; blank query keeps API order
121
+ filtered = searchNodeTypes(filtered, searchInput);
127
122
 
128
123
  // Return filtered results preserving API order
129
124
  return filtered;
130
125
  }
131
126
 
127
+ /**
128
+ * Add a node from the keyboard. Enter acts on keydown, Space on keyup (like a
129
+ * button); a held key adds once.
130
+ */
131
+ function handleItemKey(event: KeyboardEvent, nodeType: NodeMetadata): void {
132
+ if (event.key !== 'Enter' && event.key !== ' ') return;
133
+ event.preventDefault();
134
+ if (event.repeat) return;
135
+ if (event.key === 'Enter' && event.type === 'keydown') props.onadd?.(nodeType);
136
+ if (event.key === ' ' && event.type === 'keyup') props.onadd?.(nodeType);
137
+ }
138
+
132
139
  /**
133
140
  * Handle node type drag start - creates a new node instance
134
141
  */
@@ -276,8 +283,12 @@
276
283
  class="flowdrop-card flowdrop-card--compact flowdrop-node-item"
277
284
  draggable="true"
278
285
  ondragstart={(e) => handleNodeDragStart(e, nodeType)}
286
+ onclick={() => props.onadd?.(nodeType)}
287
+ onkeydown={(e) => handleItemKey(e, nodeType)}
288
+ onkeyup={(e) => handleItemKey(e, nodeType)}
279
289
  role="button"
280
290
  tabindex="0"
291
+ aria-label={m().layout.addNode({ name: nodeType.name })}
281
292
  title={nodeType.description}
282
293
  >
283
294
  <div class="flowdrop-card__body flowdrop-p--1 flowdrop-py--1">
@@ -324,13 +335,18 @@
324
335
  <div class="fd-sidebar-flat-category">
325
336
  {getCategoryDisplayName(category).toUpperCase()}
326
337
  </div>
327
- <div class="fd-sidebar-flat-list" role="list">
338
+ <div class="fd-sidebar-flat-list">
328
339
  {#each categoryNodes as nodeType (nodeType.node_type_id)}
329
340
  <div
330
341
  class="fd-sidebar-flat-item"
331
- role="listitem"
342
+ role="button"
343
+ tabindex="0"
344
+ aria-label={m().layout.addNode({ name: nodeType.name })}
332
345
  draggable="true"
333
346
  ondragstart={(e) => handleNodeDragStart(e, nodeType)}
347
+ onclick={() => props.onadd?.(nodeType)}
348
+ onkeydown={(e) => handleItemKey(e, nodeType)}
349
+ onkeyup={(e) => handleItemKey(e, nodeType)}
334
350
  >
335
351
  <span
336
352
  class="fd-sidebar-flat-dot"
@@ -369,13 +385,18 @@
369
385
  </div>
370
386
  </summary>
371
387
  <div class="flowdrop-details__content">
372
- <div class="flowdrop-node-list" role="list">
388
+ <div class="flowdrop-node-list">
373
389
  {#each categoryNodes as nodeType (nodeType.node_type_id)}
374
390
  <div
375
391
  class="flowdrop-card flowdrop-card--compact flowdrop-node-item"
376
- role="listitem"
392
+ role="button"
393
+ tabindex="0"
394
+ aria-label={m().layout.addNode({ name: nodeType.name })}
377
395
  draggable="true"
378
396
  ondragstart={(e) => handleNodeDragStart(e, nodeType)}
397
+ onclick={() => props.onadd?.(nodeType)}
398
+ onkeydown={(e) => handleItemKey(e, nodeType)}
399
+ onkeyup={(e) => handleItemKey(e, nodeType)}
379
400
  title={nodeType.description}
380
401
  >
381
402
  <div class="flowdrop-card__body flowdrop-p--1 flowdrop-py--1">
@@ -18,6 +18,8 @@ interface Props {
18
18
  * flat 32px category rows (no card, no border) with a filled search field.
19
19
  */
20
20
  listStyle?: 'cards' | 'flat' | 'rows';
21
+ /** Called when a palette item is clicked or activated with Enter or Space. */
22
+ onadd?: (nodeType: NodeMetadata) => void;
21
23
  }
22
24
  /**
23
25
  * The node palette: every node type the editor knows, grouped by category in accordions, with a search field.
@@ -14,6 +14,8 @@
14
14
  import { m } from '../messages/index.js';
15
15
  import { getInstance } from '../stores/getInstance.svelte.js';
16
16
  import { getVersionUpgrade } from '../utils/nodeSwap.js';
17
+ import { nodeCanvasLabel } from '../utils/workflowInterface.js';
18
+ import { searchNodeTypes } from '../utils/nodeSearch.js';
17
19
 
18
20
  interface Props {
19
21
  /** The node being swapped */
@@ -48,19 +50,7 @@
48
50
  let formatCompatibleNodes = $derived(availableNodes.filter((n) => isNodeCompatibleWithFormat(n)));
49
51
 
50
52
  /** Apply search filter */
51
- let filteredNodes = $derived.by(() => {
52
- let nodes = formatCompatibleNodes;
53
- if (searchInput.trim()) {
54
- const query = searchInput.toLowerCase();
55
- nodes = nodes.filter(
56
- (node) =>
57
- node.name.toLowerCase().includes(query) ||
58
- node.description.toLowerCase().includes(query) ||
59
- node.tags?.some((tag) => tag.toLowerCase().includes(query))
60
- );
61
- }
62
- return nodes;
63
- });
53
+ let filteredNodes = $derived(searchNodeTypes(formatCompatibleNodes, searchInput));
64
54
 
65
55
  /** Get unique categories preserving API order */
66
56
  let categories = $derived.by(() => {
@@ -97,7 +87,7 @@
97
87
  <!-- Current node info -->
98
88
  <div class="swap-picker__current">
99
89
  <span class="swap-picker__current-label">Current:</span>
100
- <span class="swap-picker__current-name">{currentNode.data.label}</span>
90
+ <span class="swap-picker__current-name">{nodeCanvasLabel(currentNode)}</span>
101
91
  </div>
102
92
 
103
93
  <!-- Version upgrade banner -->