@flowdrop/flowdrop 2.0.0-beta.9 → 2.0.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 (74) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/dist/chat/batchFeedback.js +1 -1
  3. package/dist/chat/commandClassifier.d.ts +11 -0
  4. package/dist/chat/commandClassifier.js +20 -0
  5. package/dist/chat/historyBuilder.d.ts +39 -0
  6. package/dist/chat/historyBuilder.js +82 -0
  7. package/dist/chat/index.d.ts +2 -1
  8. package/dist/chat/index.js +2 -1
  9. package/dist/chat/responseParser.js +16 -12
  10. package/dist/commands/parser.d.ts +12 -0
  11. package/dist/commands/parser.js +33 -6
  12. package/dist/commands/storeIntegration.svelte.js +11 -1
  13. package/dist/components/App.svelte +56 -17
  14. package/dist/components/ConfigForm.svelte +98 -23
  15. package/dist/components/ConfigForm.svelte.d.ts +21 -2
  16. package/dist/components/ConfigModal.svelte +9 -0
  17. package/dist/components/ConfigPanel.svelte +0 -1
  18. package/dist/components/SettingsPanel.svelte +9 -0
  19. package/dist/components/WorkflowEditor.svelte +5 -2
  20. package/dist/components/chat/AIChatPanel.svelte +42 -6
  21. package/dist/components/chat/CommandPreview.svelte +10 -1
  22. package/dist/components/form/FormPorts.svelte +21 -3
  23. package/dist/components/form/FormRangeField.svelte +5 -3
  24. package/dist/components/form/FormToggle.svelte +27 -2
  25. package/dist/components/form/FormToggle.svelte.d.ts +5 -0
  26. package/dist/components/playground/ChatInput.svelte +316 -26
  27. package/dist/components/playground/ChatInput.svelte.d.ts +31 -1
  28. package/dist/components/playground/ControlPanel.svelte +22 -0
  29. package/dist/components/playground/ControlPanel.svelte.d.ts +13 -0
  30. package/dist/components/playground/Playground.svelte +217 -4
  31. package/dist/components/surfaces/SurfaceOverlay.svelte +0 -1
  32. package/dist/config/endpoints.d.ts +48 -1
  33. package/dist/config/endpoints.js +18 -5
  34. package/dist/messages/defaults.d.ts +98 -0
  35. package/dist/messages/defaults.js +58 -1
  36. package/dist/playground/commands/args.d.ts +32 -0
  37. package/dist/playground/commands/args.js +50 -0
  38. package/dist/playground/commands/dispatch.d.ts +143 -0
  39. package/dist/playground/commands/dispatch.js +162 -0
  40. package/dist/playground/commands/index.d.ts +14 -0
  41. package/dist/playground/commands/index.js +10 -0
  42. package/dist/playground/commands/parser.d.ts +38 -0
  43. package/dist/playground/commands/parser.js +163 -0
  44. package/dist/playground/commands/registry.d.ts +42 -0
  45. package/dist/playground/commands/registry.js +122 -0
  46. package/dist/playground/commands/suggest.d.ts +37 -0
  47. package/dist/playground/commands/suggest.js +46 -0
  48. package/dist/playground/commands/types.d.ts +111 -0
  49. package/dist/playground/commands/types.js +15 -0
  50. package/dist/playground/index.d.ts +19 -0
  51. package/dist/playground/index.js +25 -0
  52. package/dist/playground/runAction.d.ts +48 -0
  53. package/dist/playground/runAction.js +31 -0
  54. package/dist/services/historyService.d.ts +30 -8
  55. package/dist/services/historyService.js +51 -15
  56. package/dist/services/pipelineSignalService.d.ts +97 -0
  57. package/dist/services/pipelineSignalService.js +94 -0
  58. package/dist/services/playgroundService.d.ts +12 -0
  59. package/dist/services/playgroundService.js +22 -0
  60. package/dist/services/workflowLaunchService.d.ts +74 -0
  61. package/dist/services/workflowLaunchService.js +74 -0
  62. package/dist/stores/historyStore.svelte.d.ts +17 -3
  63. package/dist/stores/historyStore.svelte.js +30 -3
  64. package/dist/stores/instanceContainer.svelte.js +5 -0
  65. package/dist/stores/workflowStore.svelte.d.ts +41 -4
  66. package/dist/stores/workflowStore.svelte.js +103 -13
  67. package/dist/types/chat.d.ts +5 -1
  68. package/dist/types/settings.d.ts +11 -0
  69. package/dist/types/settings.js +2 -1
  70. package/dist/utils/canvasSelection.d.ts +25 -0
  71. package/dist/utils/canvasSelection.js +37 -0
  72. package/dist/utils/nodeFormSchema.d.ts +51 -0
  73. package/dist/utils/nodeFormSchema.js +87 -0
  74. package/package.json +1 -1
@@ -6,7 +6,8 @@
6
6
 
7
7
  Features:
8
8
  - Dynamic form generation from JSON Schema using modular form components
9
- - UI Extensions support for display settings (e.g., hide unconnected handles)
9
+ - Node-level settings the editor contributes for every node (port order +
10
+ exposure), rendered even when the node type declares no config schema
10
11
  - Extensible architecture for complex schema types (array, object)
11
12
  - Admin/Edit support for external configuration links and dynamic schema fetching
12
13
 
@@ -47,6 +48,7 @@
47
48
  import { logger } from '../utils/logger.js';
48
49
  import { mergeWithDefaults, cascadeClearAutocompleteDependents } from '../utils/formMerge.js';
49
50
  import { applyFetchedSchema } from '../utils/schemaMerge.js';
51
+ import { PORTS_CONFIG_KEY, withPortsControl, withPortsField } from '../utils/nodeFormSchema.js';
50
52
 
51
53
  interface Props {
52
54
  /** Optional workflow node (if provided, schema and values are derived from it) */
@@ -78,8 +80,27 @@
78
80
  workflowEdges?: WorkflowEdge[];
79
81
  /** Auth provider for API requests (used for template variable API mode) */
80
82
  authProvider?: AuthProvider;
81
- /** Callback when any field value changes (fired on blur for immediate sync) */
82
- onChange?: (config: Record<string, unknown>) => void;
83
+ /**
84
+ * How edits are committed to the parent via `onChange`:
85
+ * - `'blur'` (default): committed on focus-out. Discrete controls
86
+ * (checkbox/enum) additionally commit immediately, because WebKit doesn't
87
+ * focus them on click so no focus-out fires (see handleFieldChange).
88
+ * - `'live'`: committed on every change, with the edited `fieldKey` in the
89
+ * `onChange` meta, plus a final `{ commit: true }` on focus-out. Lets the
90
+ * parent coalesce a field-editing session into one undo step without
91
+ * depending on focus events at all.
92
+ */
93
+ commitMode?: 'blur' | 'live';
94
+ /**
95
+ * Callback when field values change.
96
+ * @param config - The current merged config values.
97
+ * @param meta - `fieldKey` names the changed field (live mode); `commit`
98
+ * marks the end-of-session flush fired on focus-out (live mode).
99
+ */
100
+ onChange?: (
101
+ config: Record<string, unknown>,
102
+ meta?: { fieldKey?: string; commit?: boolean }
103
+ ) => void;
83
104
  /** Callback when form is saved */
84
105
  onSave?: (config: Record<string, unknown>) => void;
85
106
  /** Callback when form is cancelled */
@@ -96,6 +117,7 @@
96
117
  workflowNodes = [],
97
118
  workflowEdges = [],
98
119
  authProvider,
120
+ commitMode = 'blur',
99
121
  onChange,
100
122
  onSave,
101
123
  onCancel
@@ -155,10 +177,11 @@
155
177
  });
156
178
 
157
179
  /**
158
- * Get the configuration schema from node metadata, direct prop, or fetched dynamic schema
180
+ * The node type's own configuration schema: direct prop, node metadata, or a
181
+ * dynamically fetched one layered on top.
159
182
  * Priority: fetchedDynamicSchema > direct schema prop > node metadata configSchema
160
183
  */
161
- const configSchema = $derived.by<ConfigSchema | undefined>(() => {
184
+ const typeConfigSchema = $derived.by<ConfigSchema | undefined>(() => {
162
185
  const staticSchema = schema ?? (node?.data.metadata?.configSchema as ConfigSchema | undefined);
163
186
  // A fetched dynamic schema is layered onto the static one per the endpoint's
164
187
  // mergeStrategy/target (default 'replace' → fetched wins wholesale). With no
@@ -172,6 +195,22 @@
172
195
  return staticSchema;
173
196
  });
174
197
 
198
+ /**
199
+ * The schema the form actually renders: the node type's, plus the node-level
200
+ * fields the editor contributes for every node (the reserved `ports` widget).
201
+ *
202
+ * The injection is what keeps a node type that declares no `configSchema` from
203
+ * falling through to the empty state and losing its node-level settings with
204
+ * it (#34) — it now has a schema of exactly those settings. Purely a display
205
+ * concern: nothing is written to the node until the user edits a field.
206
+ */
207
+ const configSchema = $derived(withPortsField(typeConfigSchema, node));
208
+
209
+ /** Whether the ports field above was contributed by us rather than authored. */
210
+ const portsFieldInjected = $derived(
211
+ configSchema !== typeConfigSchema && configSchema?.properties?.[PORTS_CONFIG_KEY] !== undefined
212
+ );
213
+
175
214
  /**
176
215
  * Get the UI schema for the active configSchema.
177
216
  * Priority: direct uiSchema prop > fetched dynamic uiSchema > node metadata.
@@ -184,9 +223,14 @@
184
223
  * uiSchema describing the schema it served.
185
224
  */
186
225
  const configUISchema = $derived.by<UISchemaElement | undefined>(() => {
187
- if (uiSchema) return uiSchema;
188
- if (fetchedDynamicSchema && fetchedDynamicUiSchema) return fetchedDynamicUiSchema;
189
- return node?.data.metadata?.uiSchema as UISchemaElement | undefined;
226
+ const authored = uiSchema
227
+ ? uiSchema
228
+ : fetchedDynamicSchema && fetchedDynamicUiSchema
229
+ ? fetchedDynamicUiSchema
230
+ : (node?.data.metadata?.uiSchema as UISchemaElement | undefined);
231
+ // An authored tree lists only the author's own controls, so the injected
232
+ // ports field needs a control of its own or it would never render.
233
+ return withPortsControl(authored, portsFieldInjected);
190
234
  });
191
235
 
192
236
  /**
@@ -388,26 +432,57 @@
388
432
  for (const [depKey, depValue] of Object.entries(dependents)) {
389
433
  edits[depKey] = depValue;
390
434
  }
435
+
436
+ if (commitMode === 'live') {
437
+ // Commit every change, tagging the field so the parent can coalesce a
438
+ // whole field-editing session into one undo step. Nothing depends on a
439
+ // focus event, so WebKit not focusing checkboxes/selects on click (#38)
440
+ // is a non-issue. Keep the edits buffer until the session ends (blur) so
441
+ // fast typing never briefly reverts on the parent's value round-trip.
442
+ commitEdits({ fieldKey: key }, false);
443
+ return;
444
+ }
445
+
446
+ // Blur mode: text/number fields commit on focus-out (one store write per
447
+ // field, not per keystroke). Discrete controls (checkbox/toggle, enum)
448
+ // commit immediately — WebKit doesn't focus them on click, so no focus-out
449
+ // ever fires and the edit would otherwise be lost on save (#38).
450
+ const prop = configSchema?.properties?.[key];
451
+ if (prop && (prop.type === 'boolean' || Array.isArray(prop.enum))) {
452
+ commitEdits();
453
+ }
391
454
  }
392
455
 
393
456
  /**
394
- * Handle form field blur - sync changes to workflow immediately
395
- * Uses focusout which bubbles from child elements
396
- * This enables auto-save behavior without requiring explicit Save button clicks
457
+ * Emit the current merged config to the parent.
458
+ *
459
+ * @param meta - Passed through to `onChange` (live mode: `fieldKey` /
460
+ * `commit`).
461
+ * @param clearBuffer - Discharge the local `edits` buffer after emitting, so
462
+ * subsequent prop changes (parent absorbing the commit, undo/redo,
463
+ * collaboration) flow through `initialConfig` cleanly instead of being
464
+ * shadowed by a stale local edit. Done at every commit boundary in blur
465
+ * mode, but only at session end (blur) in live mode.
466
+ */
467
+ function commitEdits(meta?: { fieldKey?: string; commit?: boolean }, clearBuffer = true): void {
468
+ if (!onChange) return;
469
+ // Spread `initialConfig` first so config keys the active schema doesn't own
470
+ // (e.g. after a dynamic schema narrows the field set) pass through untouched
471
+ // instead of being silently dropped; `configValues` then wins for every
472
+ // field the schema actually renders.
473
+ onChange({ ...initialConfig, ...configValues }, meta);
474
+ if (clearBuffer) edits = {};
475
+ }
476
+
477
+ /**
478
+ * Focus-out handler (bubbles from child fields).
479
+ *
480
+ * Blur mode: the primary commit. Live mode: edits are already committed per
481
+ * change, so this just signals end-of-session (`commit: true`) so the parent
482
+ * can finalize the coalesced undo step, and discharges the edits buffer.
397
483
  */
398
484
  function handleFormBlur(): void {
399
- if (onChange) {
400
- // Spread `initialConfig` first so config keys the active schema doesn't
401
- // own (e.g. after a dynamic schema narrows the field set) pass through
402
- // untouched instead of being silently dropped; `configValues` then wins
403
- // for every field the schema actually renders.
404
- onChange({ ...initialConfig, ...configValues });
405
- // Discharge the edits buffer at the commit boundary. Subsequent prop
406
- // changes (parent absorbing the commit, undo/redo, collaboration) then
407
- // flow through `initialConfig` cleanly instead of being shadowed by a
408
- // stale local edit.
409
- edits = {};
410
- }
485
+ commitEdits(commitMode === 'live' ? { commit: true } : undefined);
411
486
  }
412
487
 
413
488
  /**
@@ -30,8 +30,27 @@ interface Props {
30
30
  workflowEdges?: WorkflowEdge[];
31
31
  /** Auth provider for API requests (used for template variable API mode) */
32
32
  authProvider?: AuthProvider;
33
- /** Callback when any field value changes (fired on blur for immediate sync) */
34
- onChange?: (config: Record<string, unknown>) => void;
33
+ /**
34
+ * How edits are committed to the parent via `onChange`:
35
+ * - `'blur'` (default): committed on focus-out. Discrete controls
36
+ * (checkbox/enum) additionally commit immediately, because WebKit doesn't
37
+ * focus them on click so no focus-out fires (see handleFieldChange).
38
+ * - `'live'`: committed on every change, with the edited `fieldKey` in the
39
+ * `onChange` meta, plus a final `{ commit: true }` on focus-out. Lets the
40
+ * parent coalesce a field-editing session into one undo step without
41
+ * depending on focus events at all.
42
+ */
43
+ commitMode?: 'blur' | 'live';
44
+ /**
45
+ * Callback when field values change.
46
+ * @param config - The current merged config values.
47
+ * @param meta - `fieldKey` names the changed field (live mode); `commit`
48
+ * marks the end-of-session flush fired on focus-out (live mode).
49
+ */
50
+ onChange?: (config: Record<string, unknown>, meta?: {
51
+ fieldKey?: string;
52
+ commit?: boolean;
53
+ }) => void;
35
54
  /** Callback when form is saved */
36
55
  onSave?: (config: Record<string, unknown>) => void;
37
56
  /** Callback when form is cancelled */
@@ -94,6 +94,15 @@
94
94
  left: 0;
95
95
  right: 0;
96
96
  bottom: 0;
97
+ /*
98
+ This modal is exported (@flowdrop/flowdrop/editor) and embedders like fddo
99
+ mount it standalone, outside the editor container that carries the app
100
+ font. The library's text/inputs use `font-family: inherit`, so without
101
+ this they'd fall back to the host page's default (e.g. serif on a bare
102
+ Drupal page). Re-establish the font here, mirroring SurfaceOverlay /
103
+ ConfigPanel.
104
+ */
105
+ font-family: var(--fd-font-family, system-ui, -apple-system, sans-serif);
97
106
  background-color: rgba(0, 0, 0, 0.5);
98
107
  display: flex;
99
108
  align-items: center;
@@ -167,7 +167,6 @@
167
167
  </div>
168
168
 
169
169
  {#if expanded}
170
- <!-- svelte-ignore a11y_click_events_have_key_events -->
171
170
  <!-- svelte-ignore a11y_no_static_element_interactions -->
172
171
  <div
173
172
  class="config-panel-modal__backdrop"
@@ -273,6 +273,15 @@
273
273
  title: 'AI Assistant Auto-retry',
274
274
  description: 'Automatically ask the AI to self-correct when commands fail',
275
275
  default: true
276
+ },
277
+ chatAllowLayoutChanges: {
278
+ type: 'boolean',
279
+ title: 'AI Assistant Layout Changes',
280
+ description:
281
+ 'Let the AI assistant re-arrange node positions (layout auto / layout beautify). ' +
282
+ 'Turn off to keep a hand-crafted layout — those commands are then skipped and ' +
283
+ 'the rest of the batch still applies.',
284
+ default: true
276
285
  }
277
286
  }
278
287
  },
@@ -56,6 +56,7 @@
56
56
  import PortCoordinateTracker from './PortCoordinateTracker.svelte';
57
57
  import { logger } from '../utils/logger.js';
58
58
  import { validateWorkflowData } from '../utils/validation.js';
59
+ import { suppressPortDragSelection } from '../utils/canvasSelection.js';
59
60
  import { createEditorStateMachine } from '../stores/editorStateMachine.svelte.js';
60
61
  import CanvasIconButton from './CanvasIconButton.svelte';
61
62
  import CommandLineIcon from './icons/CommandLineIcon.svelte';
@@ -887,8 +888,10 @@
887
888
  <div class="flowdrop-workflow-editor">
888
889
  <!-- Main Editor Area -->
889
890
  <div class="flowdrop-workflow-editor__main">
890
- <!-- Flow Canvas -->
891
- <div class="flowdrop-canvas">
891
+ <!-- Flow Canvas.
892
+ Capture-phase mousedown so dragging from a port never turns into a
893
+ WebKit text-selection drag — see suppressPortDragSelection. -->
894
+ <div class="flowdrop-canvas" onmousedowncapture={suppressPortDragSelection}>
892
895
  <FlowDropZone ondrop={handleNodeDrop} onfiledrop={handleWorkflowFileDrop}>
893
896
  {#key svelteFlowKey}
894
897
  <SvelteFlow
@@ -7,7 +7,8 @@
7
7
  import { getInstance } from '../../stores/getInstance.svelte.js';
8
8
  import { getBehaviorSettings } from '../../stores/settingsStore.svelte.js';
9
9
  import { extractCommands } from '../../chat/responseParser.js';
10
- import { isMutatingCommand } from '../../chat/commandClassifier.js';
10
+ import { buildApiHistory } from '../../chat/historyBuilder.js';
11
+ import { isMutatingCommand, isLayoutCommand } from '../../chat/commandClassifier.js';
11
12
  import { parseCommand } from '../../commands/parser.js';
12
13
  import { executeCommand } from '../../commands/index.js';
13
14
  import { createStoreCommandContext } from '../../commands/storeIntegration.svelte.js';
@@ -29,12 +30,20 @@
29
30
  interface DisplayMessage {
30
31
  role: 'user' | 'assistant';
31
32
  content: string;
33
+ /**
34
+ * The unmodified LLM response, kept when `content` is the explanation-only
35
+ * display text. Sent as history so the assistant sees the DSL it emitted
36
+ * (issue #35).
37
+ */
38
+ rawContent?: string;
32
39
  /** Set on auto-retry messages — renders as a muted notice, not a user bubble */
33
40
  retryAttempt?: number;
34
41
  /** Mutating commands awaiting approval */
35
42
  commandPreview?: CommandPreviewItem[];
36
43
  /** Results from auto-executed read-only commands */
37
44
  readOnlyResults?: string[];
45
+ /** Set when the user dismissed this message's command preview */
46
+ commandsDismissed?: boolean;
38
47
  }
39
48
 
40
49
  interface Props {
@@ -93,9 +102,14 @@
93
102
  // Helpers
94
103
  // =========================================================================
95
104
 
96
- /** Build conversation history from display messages for API requests */
105
+ /**
106
+ * Build conversation history from display messages for API requests.
107
+ *
108
+ * Read at send time, so each assistant entry reports the *current* status of
109
+ * the commands it emitted — applied, dismissed, failed or still pending.
110
+ */
97
111
  function getHistory(): ChatHistoryMessage[] {
98
- return displayMessages.map((m) => ({ role: m.role, content: m.content }));
112
+ return buildApiHistory(displayMessages);
99
113
  }
100
114
 
101
115
  function getWorkflowState(): unknown {
@@ -169,7 +183,8 @@
169
183
 
170
184
  const msg: DisplayMessage = {
171
185
  role: 'assistant',
172
- content: explanation || responseContent
186
+ content: explanation || responseContent,
187
+ rawContent: responseContent
173
188
  };
174
189
 
175
190
  if (readOnlyResults.length > 0) {
@@ -222,6 +237,12 @@
222
237
  command: import('../../commands/types.js').Command;
223
238
  }[] = [];
224
239
 
240
+ // Layout commands rewrite every node's position, so they wipe a hand-crafted
241
+ // arrangement. Honour the user's opt-out by skipping them instead of running
242
+ // them — a skip is not a failure, so the rest of the batch still applies and
243
+ // no retry feedback is sent (issue #36).
244
+ const allowLayoutChanges = getBehaviorSettings().chatAllowLayoutChanges;
245
+
225
246
  for (const item of pendingItems) {
226
247
  const parsed = parseCommand(item.raw);
227
248
  if (!parsed.ok) {
@@ -231,11 +252,22 @@
231
252
  parseErrors.push({ raw: item.raw, error: parsed.error });
232
253
  continue;
233
254
  }
255
+ if (!allowLayoutChanges && isLayoutCommand(parsed.command.type)) {
256
+ item.status = 'skipped';
257
+ item.result = t.commandPreview.layoutSkipped;
258
+ continue;
259
+ }
234
260
  parsedCommands.push({ item, command: parsed.command });
235
261
  }
236
262
 
237
263
  const totalCount = parsedCommands.length;
238
264
 
265
+ // Everything was intentionally skipped (layout commands with layout changes
266
+ // off) — nothing failed, so there is nothing to report or retry.
267
+ if (totalCount === 0 && parseErrors.length === 0) {
268
+ return;
269
+ }
270
+
239
271
  // Nothing parseable to run — feed the parse errors straight back so the
240
272
  // assistant can resend a corrected batch.
241
273
  if (totalCount === 0) {
@@ -338,8 +370,12 @@
338
370
  }
339
371
 
340
372
  /** Dismiss a command preview without executing — CommandPreview shows its own cancelled state */
341
- function handleCancelCommands(_messageIndex: number) {
342
- // Intentionally empty: CommandPreview owns the "Dismissed" display via resolvedAction state
373
+ function handleCancelCommands(messageIndex: number) {
374
+ // CommandPreview owns the "Dismissed" *display* via its resolvedAction state;
375
+ // the flag here is what tells the assistant, on the next turn, that these
376
+ // commands were rejected rather than still waiting (issue #35).
377
+ const msg = displayMessages[messageIndex];
378
+ if (msg) msg.commandsDismissed = true;
343
379
  }
344
380
 
345
381
  /** Append an error message to conversation history so the LLM can self-correct */
@@ -44,10 +44,12 @@
44
44
  <Icon icon="mdi:check-circle" />
45
45
  {:else if command.status === 'error'}
46
46
  <Icon icon="mdi:alert-circle" />
47
+ {:else if command.status === 'skipped'}
48
+ <Icon icon="mdi:debug-step-over" />
47
49
  {/if}
48
50
  </span>
49
51
  <pre class="command-preview__command">{command.raw}</pre>
50
- {#if command.status === 'error' && command.result}
52
+ {#if (command.status === 'error' || command.status === 'skipped') && command.result}
51
53
  <span class="command-preview__error">{command.result}</span>
52
54
  {/if}
53
55
  </div>
@@ -163,6 +165,13 @@
163
165
  color: var(--fd-error);
164
166
  }
165
167
 
168
+ /* Skipped isn't a failure — mute it instead of colouring it like an error. */
169
+ .command-preview__item--skipped .command-preview__status,
170
+ .command-preview__item--skipped .command-preview__command,
171
+ .command-preview__item--skipped .command-preview__error {
172
+ color: var(--fd-muted-foreground);
173
+ }
174
+
166
175
  .command-preview__error {
167
176
  display: block;
168
177
  font-size: var(--fd-text-xs);
@@ -135,7 +135,8 @@
135
135
  <span class="fd-ports__group-label">{group.label}</span>
136
136
  <ul class="fd-ports__list">
137
137
  {#each ordered as port, i (port.id)}
138
- <li class="fd-ports__item">
138
+ {@const exposed = isPortExposed(port, portsConfig[direction])}
139
+ <li class="fd-ports__item" class:fd-ports__item--hidden={!exposed}>
139
140
  <div class="fd-ports__reorder">
140
141
  <button
141
142
  type="button"
@@ -156,9 +157,10 @@
156
157
  <Icon icon="heroicons:chevron-down" />
157
158
  </button>
158
159
  </div>
159
- <span class="fd-ports__name">{port.name}</span>
160
+ <span class="fd-ports__name" title={port.name}>{port.name}</span>
160
161
  <span
161
162
  class="fd-ports__badge"
163
+ title={port.dataType}
162
164
  style="background-color:{getPortBackgroundColorForPort(
163
165
  checker,
164
166
  port,
@@ -172,10 +174,11 @@
172
174
  </span>
173
175
  <FormToggle
174
176
  id={`${id}-${direction}-${port.id}`}
175
- value={isPortExposed(port, portsConfig[direction])}
177
+ value={exposed}
176
178
  onLabel="Exposed"
177
179
  offLabel="Hidden"
178
180
  {disabled}
181
+ hideLabel
179
182
  onChange={(exposed) => setExposed(direction, port.id, exposed)}
180
183
  />
181
184
  </li>
@@ -225,6 +228,13 @@
225
228
  border: 1px solid var(--fd-border-muted);
226
229
  }
227
230
 
231
+ /* The switch alone carries the state now that its label is screen-reader
232
+ only, so dim the row to keep "hidden" legible at a glance. */
233
+ .fd-ports__item--hidden .fd-ports__name,
234
+ .fd-ports__item--hidden .fd-ports__badge {
235
+ opacity: 0.55;
236
+ }
237
+
228
238
  .fd-ports__reorder {
229
239
  display: flex;
230
240
  flex-direction: column;
@@ -247,10 +257,15 @@
247
257
  cursor: default;
248
258
  }
249
259
 
260
+ /* min-width:0 so a long port name ellipsizes instead of widening the row. */
250
261
  .fd-ports__name {
251
262
  flex: 1;
263
+ min-width: 0;
252
264
  font-size: var(--fd-text-xs);
253
265
  font-weight: 500;
266
+ overflow: hidden;
267
+ text-overflow: ellipsis;
268
+ white-space: nowrap;
254
269
  }
255
270
 
256
271
  .fd-ports__badge {
@@ -258,5 +273,8 @@
258
273
  padding: 0 var(--fd-space-1, 0.25rem);
259
274
  border-radius: var(--fd-radius-sm, 4px);
260
275
  white-space: nowrap;
276
+ max-width: 10ch;
277
+ overflow: hidden;
278
+ text-overflow: ellipsis;
261
279
  }
262
280
  </style>
@@ -11,6 +11,8 @@
11
11
  -->
12
12
 
13
13
  <script lang="ts">
14
+ import { untrack } from 'svelte';
15
+
14
16
  interface Props {
15
17
  /** Field identifier */
16
18
  id: string;
@@ -78,15 +80,15 @@
78
80
  * instant the user drags onto a whole number (e.g. 1.0), stranding the slider
79
81
  * on integer increments.
80
82
  */
81
- const initialNumeric = typeof value === 'number' ? value : Number(value);
82
- const inferredStep = ((): number => {
83
+ const inferredStep = untrack((): number => {
84
+ const initialNumeric = typeof value === 'number' ? value : Number(value);
83
85
  const places = Math.max(
84
86
  decimalPlaces(Number.isNaN(initialNumeric) ? min : initialNumeric),
85
87
  decimalPlaces(min),
86
88
  decimalPlaces(max)
87
89
  );
88
90
  return places > 0 ? Math.pow(10, -places) : 1;
89
- })();
91
+ });
90
92
 
91
93
  const effectiveStep = $derived(typeof step === 'number' && step > 0 ? step : inferredStep);
92
94
 
@@ -26,6 +26,11 @@
26
26
  * `messages.form.toggle.disabled`.
27
27
  */
28
28
  offLabel?: string;
29
+ /**
30
+ * Keep the state label as the switch's accessible name only, without
31
+ * rendering it. For dense rows where the switch alone carries the state.
32
+ */
33
+ hideLabel?: boolean;
29
34
  /** Whether the field is disabled (read-only) */
30
35
  disabled?: boolean;
31
36
  /** ARIA description ID */
@@ -39,6 +44,7 @@
39
44
  value = false,
40
45
  onLabel,
41
46
  offLabel,
47
+ hideLabel = false,
42
48
  disabled = false,
43
49
  ariaDescribedBy,
44
50
  onChange
@@ -56,7 +62,7 @@
56
62
  }
57
63
  </script>
58
64
 
59
- <label class="form-toggle">
65
+ <label class="form-toggle" class:form-toggle--compact={hideLabel}>
60
66
  <input
61
67
  {id}
62
68
  type="checkbox"
@@ -69,7 +75,7 @@
69
75
  <span class="form-toggle__track">
70
76
  <span class="form-toggle__thumb"></span>
71
77
  </span>
72
- <span class="form-toggle__label">
78
+ <span class="form-toggle__label" class:form-toggle__label--sr-only={hideLabel}>
73
79
  {value ? resolvedOnLabel : resolvedOffLabel}
74
80
  </span>
75
81
  </label>
@@ -130,4 +136,23 @@
130
136
  .form-toggle__input:checked ~ .form-toggle__label {
131
137
  color: var(--fd-primary-hover);
132
138
  }
139
+
140
+ /* Compact: switch only, no reserved label column and no vertical padding. */
141
+ .form-toggle--compact {
142
+ gap: 0;
143
+ padding: 0;
144
+ }
145
+
146
+ .form-toggle__label--sr-only {
147
+ position: absolute;
148
+ width: 1px;
149
+ height: 1px;
150
+ min-width: 0;
151
+ padding: 0;
152
+ margin: -1px;
153
+ overflow: hidden;
154
+ clip-path: inset(50%);
155
+ white-space: nowrap;
156
+ border: 0;
157
+ }
133
158
  </style>
@@ -13,6 +13,11 @@ interface Props {
13
13
  * `messages.form.toggle.disabled`.
14
14
  */
15
15
  offLabel?: string;
16
+ /**
17
+ * Keep the state label as the switch's accessible name only, without
18
+ * rendering it. For dense rows where the switch alone carries the state.
19
+ */
20
+ hideLabel?: boolean;
16
21
  /** Whether the field is disabled (read-only) */
17
22
  disabled?: boolean;
18
23
  /** ARIA description ID */