@solidxai/core-ui 0.1.13-beta.6 → 0.1.14-beta.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 (147) hide show
  1. package/dist/components/common/SolidPopupContainer.d.ts.map +1 -1
  2. package/dist/components/common/SolidPopupContainer.js +68 -5
  3. package/dist/components/common/SolidPopupContainer.js.map +1 -1
  4. package/dist/components/common/SolidPopupContainer.tsx +50 -4
  5. package/dist/components/core/card/SolidCardViewConfigure.d.ts.map +1 -1
  6. package/dist/components/core/card/SolidCardViewConfigure.js +1 -1
  7. package/dist/components/core/card/SolidCardViewConfigure.js.map +1 -1
  8. package/dist/components/core/card/SolidCardViewConfigure.tsx +3 -1
  9. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.d.ts +2 -0
  10. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.d.ts.map +1 -0
  11. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.js +4 -0
  12. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.js.map +1 -0
  13. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.ts +3 -0
  14. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.d.ts +8 -0
  15. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.d.ts.map +1 -0
  16. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.js +9 -0
  17. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.js.map +1 -0
  18. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.ts +17 -0
  19. package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
  20. package/dist/components/core/form/SolidFormView.js +52 -22
  21. package/dist/components/core/form/SolidFormView.js.map +1 -1
  22. package/dist/components/core/form/SolidFormView.tsx +49 -9
  23. package/dist/components/core/kanban/SolidKanbanViewConfigure.d.ts.map +1 -1
  24. package/dist/components/core/kanban/SolidKanbanViewConfigure.js +1 -1
  25. package/dist/components/core/kanban/SolidKanbanViewConfigure.js.map +1 -1
  26. package/dist/components/core/kanban/SolidKanbanViewConfigure.tsx +3 -1
  27. package/dist/components/core/list/SolidCustomListViewColumn.d.ts +2 -1
  28. package/dist/components/core/list/SolidCustomListViewColumn.d.ts.map +1 -1
  29. package/dist/components/core/list/SolidCustomListViewColumn.js +3 -2
  30. package/dist/components/core/list/SolidCustomListViewColumn.js.map +1 -1
  31. package/dist/components/core/list/SolidCustomListViewColumn.tsx +4 -1
  32. package/dist/components/core/list/SolidListView.d.ts.map +1 -1
  33. package/dist/components/core/list/SolidListView.js +75 -71
  34. package/dist/components/core/list/SolidListView.js.map +1 -1
  35. package/dist/components/core/list/SolidListView.tsx +25 -10
  36. package/dist/components/core/list/SolidListViewColumn.d.ts +3 -1
  37. package/dist/components/core/list/SolidListViewColumn.d.ts.map +1 -1
  38. package/dist/components/core/list/SolidListViewColumn.js +81 -42
  39. package/dist/components/core/list/SolidListViewColumn.js.map +1 -1
  40. package/dist/components/core/list/SolidListViewColumn.tsx +93 -44
  41. package/dist/components/core/list/SolidListViewConfigure.d.ts.map +1 -1
  42. package/dist/components/core/list/SolidListViewConfigure.js +2 -2
  43. package/dist/components/core/list/SolidListViewConfigure.js.map +1 -1
  44. package/dist/components/core/list/SolidListViewConfigure.tsx +4 -2
  45. package/dist/components/core/list/widgets/PillWidget.d.ts +3 -0
  46. package/dist/components/core/list/widgets/PillWidget.d.ts.map +1 -0
  47. package/dist/components/core/list/widgets/PillWidget.js +95 -0
  48. package/dist/components/core/list/widgets/PillWidget.js.map +1 -0
  49. package/dist/components/core/list/widgets/PillWidget.tsx +127 -0
  50. package/dist/components/shad-cn-ui/SolidDialog.js +1 -1
  51. package/dist/components/shad-cn-ui/SolidDialog.js.map +1 -1
  52. package/dist/components/shad-cn-ui/SolidDialog.tsx +1 -1
  53. package/dist/components/shad-cn-ui/SolidDropdownMenu.d.ts +3 -1
  54. package/dist/components/shad-cn-ui/SolidDropdownMenu.d.ts.map +1 -1
  55. package/dist/components/shad-cn-ui/SolidDropdownMenu.js +2 -2
  56. package/dist/components/shad-cn-ui/SolidDropdownMenu.js.map +1 -1
  57. package/dist/components/shad-cn-ui/SolidDropdownMenu.tsx +11 -5
  58. package/dist/components/shad-cn-ui/SolidIcon.d.ts +2 -1
  59. package/dist/components/shad-cn-ui/SolidIcon.d.ts.map +1 -1
  60. package/dist/components/shad-cn-ui/SolidIcon.js +2 -1
  61. package/dist/components/shad-cn-ui/SolidIcon.js.map +1 -1
  62. package/dist/components/shad-cn-ui/SolidIcon.tsx +2 -0
  63. package/dist/components/workflow/WorkflowFlowCanvas.css +454 -0
  64. package/dist/components/workflow/WorkflowFlowCanvas.d.ts +40 -0
  65. package/dist/components/workflow/WorkflowFlowCanvas.d.ts.map +1 -0
  66. package/dist/components/workflow/WorkflowFlowCanvas.js +861 -0
  67. package/dist/components/workflow/WorkflowFlowCanvas.js.map +1 -0
  68. package/dist/components/workflow/WorkflowFlowCanvas.tsx +1522 -0
  69. package/dist/components/workflow/WorkflowNodeDocsPanel.css +247 -0
  70. package/dist/components/workflow/WorkflowNodeDocsPanel.d.ts +22 -0
  71. package/dist/components/workflow/WorkflowNodeDocsPanel.d.ts.map +1 -0
  72. package/dist/components/workflow/WorkflowNodeDocsPanel.js +97 -0
  73. package/dist/components/workflow/WorkflowNodeDocsPanel.js.map +1 -0
  74. package/dist/components/workflow/WorkflowNodeDocsPanel.tsx +363 -0
  75. package/dist/components/workflow/WorkflowNodeSchemaEditor.css +802 -0
  76. package/dist/components/workflow/WorkflowNodeSchemaEditor.d.ts +72 -0
  77. package/dist/components/workflow/WorkflowNodeSchemaEditor.d.ts.map +1 -0
  78. package/dist/components/workflow/WorkflowNodeSchemaEditor.js +1107 -0
  79. package/dist/components/workflow/WorkflowNodeSchemaEditor.js.map +1 -0
  80. package/dist/components/workflow/WorkflowNodeSchemaEditor.tsx +2347 -0
  81. package/dist/helpers/registry.d.ts.map +1 -1
  82. package/dist/helpers/registry.js +7 -0
  83. package/dist/helpers/registry.js.map +1 -1
  84. package/dist/helpers/registry.ts +8 -0
  85. package/dist/index.d.ts +6 -0
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +5 -0
  88. package/dist/index.js.map +1 -1
  89. package/dist/index.ts +37 -0
  90. package/dist/redux/api/workflowDefinitionEditorApi.d.ts +17 -0
  91. package/dist/redux/api/workflowDefinitionEditorApi.d.ts.map +1 -0
  92. package/dist/redux/api/workflowDefinitionEditorApi.js +38 -0
  93. package/dist/redux/api/workflowDefinitionEditorApi.js.map +1 -0
  94. package/dist/redux/api/workflowDefinitionEditorApi.ts +40 -0
  95. package/dist/redux/api/workflowNodeApi.d.ts +6 -0
  96. package/dist/redux/api/workflowNodeApi.d.ts.map +1 -0
  97. package/dist/redux/api/workflowNodeApi.js +14 -0
  98. package/dist/redux/api/workflowNodeApi.js.map +1 -0
  99. package/dist/redux/api/workflowNodeApi.ts +18 -0
  100. package/dist/redux/features/popupSlice.d.ts +17 -2
  101. package/dist/redux/features/popupSlice.d.ts.map +1 -1
  102. package/dist/redux/features/popupSlice.js.map +1 -1
  103. package/dist/redux/features/popupSlice.ts +19 -3
  104. package/dist/redux/store/defaultStoreConfig.d.ts +13 -0
  105. package/dist/redux/store/defaultStoreConfig.d.ts.map +1 -1
  106. package/dist/redux/store/defaultStoreConfig.js +4 -0
  107. package/dist/redux/store/defaultStoreConfig.js.map +1 -1
  108. package/dist/redux/store/defaultStoreConfig.ts +4 -0
  109. package/dist/redux/store/solidEntityApiPool.d.ts.map +1 -1
  110. package/dist/redux/store/solidEntityApiPool.js +1 -0
  111. package/dist/redux/store/solidEntityApiPool.js.map +1 -1
  112. package/dist/redux/store/solidEntityApiPool.ts +1 -0
  113. package/dist/resources/solid-custom.css +16 -0
  114. package/dist/resources/solid-tailwind-generated.css +1 -1
  115. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.css +3194 -0
  116. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.d.ts +3 -0
  117. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.d.ts.map +1 -0
  118. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.js +3371 -0
  119. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.js.map +1 -0
  120. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.tsx +6215 -0
  121. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.css +217 -0
  122. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.d.ts +3 -0
  123. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.d.ts.map +1 -0
  124. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.js +268 -0
  125. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.js.map +1 -0
  126. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.tsx +510 -0
  127. package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.d.ts +3 -0
  128. package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.d.ts.map +1 -0
  129. package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.js +618 -0
  130. package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.js.map +1 -0
  131. package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.tsx +1322 -0
  132. package/dist/routes/solidRoutes.d.ts.map +1 -1
  133. package/dist/routes/solidRoutes.js +6 -0
  134. package/dist/routes/solidRoutes.js.map +1 -1
  135. package/dist/routes/solidRoutes.tsx +6 -0
  136. package/dist/types/extension-registry.d.ts +4 -0
  137. package/dist/types/extension-registry.d.ts.map +1 -1
  138. package/dist/types/extension-registry.js +5 -1
  139. package/dist/types/extension-registry.js.map +1 -1
  140. package/dist/types/extension-registry.ts +5 -1
  141. package/dist/types/solid-core.d.ts +32 -0
  142. package/dist/types/workflow-node.d.ts +142 -0
  143. package/dist/types/workflow-node.d.ts.map +1 -0
  144. package/dist/types/workflow-node.js +2 -0
  145. package/dist/types/workflow-node.js.map +1 -0
  146. package/dist/types/workflow-node.ts +179 -0
  147. package/package.json +3 -1
@@ -0,0 +1,2347 @@
1
+ import React from "react";
2
+ import { createPortal } from "react-dom";
3
+ import YAML from "yaml";
4
+ import {
5
+ ArrowLeft,
6
+ CircleHelp,
7
+ Filter,
8
+ GitBranch,
9
+ Plus,
10
+ Search,
11
+ Trash2,
12
+ Workflow,
13
+ X,
14
+ Zap,
15
+ } from "lucide-react";
16
+ import { getExtensionComponent } from "../../helpers/registry";
17
+ import type {
18
+ WorkflowNodeChildSlotDefinition,
19
+ WorkflowNodeConfigurationFieldDefinition,
20
+ WorkflowNodeMetadataResponse,
21
+ } from "../../types/workflow-node";
22
+ import {
23
+ SolidButton,
24
+ SolidCodeEditor,
25
+ SolidDialog,
26
+ SolidDialogBody,
27
+ SolidDialogFooter,
28
+ SolidInput,
29
+ SolidNumberInput,
30
+ SolidSelect,
31
+ SolidSwitch,
32
+ SolidTabGroup,
33
+ SolidTag,
34
+ SolidTextarea,
35
+ SolidTooltip,
36
+ SolidTooltipContent,
37
+ SolidTooltipTrigger,
38
+ SolidIcon,
39
+ normalizeSolidIconName,
40
+ } from "../shad-cn-ui";
41
+ import "./WorkflowNodeSchemaEditor.css";
42
+
43
+ type WorkflowNodeSchemaEditorProps = {
44
+ nodeType: WorkflowNodeMetadataResponse;
45
+ value?: Record<string, any>;
46
+ onChange?: (value: Record<string, any>) => void;
47
+ onSubmit?: (value: Record<string, any>) => void;
48
+ expressionSuggestions?: WorkflowExpressionSuggestion[];
49
+ readOnly?: boolean;
50
+ className?: string;
51
+ };
52
+
53
+ type WorkflowNodeEditorValue = {
54
+ [key: string]: any;
55
+ id: string;
56
+ name?: string;
57
+ description?: string;
58
+ kind: string;
59
+ type: string;
60
+ disabled?: boolean;
61
+ timeoutMs?: number;
62
+ retryPolicy?: Record<string, any>;
63
+ onError?: "fail" | "continue";
64
+ configuration?: Record<string, any>;
65
+ tasks?: WorkflowNodeEditorValue[];
66
+ then?: WorkflowNodeEditorValue[];
67
+ else?: WorkflowNodeEditorValue[];
68
+ defaults?: WorkflowNodeEditorValue[];
69
+ cases?: Record<string, WorkflowNodeEditorValue[]>;
70
+ };
71
+
72
+ type WorkflowNodeEditorDialogProps = WorkflowNodeSchemaEditorProps & {
73
+ open: boolean;
74
+ onOpenChange: (open: boolean) => void;
75
+ title?: string;
76
+ nodeValue?: WorkflowNodeEditorValue;
77
+ onNodeChange?: (value: WorkflowNodeEditorValue) => void;
78
+ onNodeSubmit?: (value: WorkflowNodeEditorValue) => void;
79
+ };
80
+
81
+ type WorkflowNodePaletteProps = {
82
+ nodeTypes: WorkflowNodeMetadataResponse[];
83
+ value?: string;
84
+ onSelect?: (nodeType: WorkflowNodeMetadataResponse) => void;
85
+ className?: string;
86
+ };
87
+
88
+ type WorkflowAddNodeDialogProps = {
89
+ open: boolean;
90
+ nodeTypes: WorkflowNodeMetadataResponse[];
91
+ onOpenChange: (open: boolean) => void;
92
+ createNodeValue: (nodeType: WorkflowNodeMetadataResponse) => WorkflowNodeEditorValue;
93
+ onSubmit: (nodeValue: WorkflowNodeEditorValue) => void;
94
+ };
95
+
96
+ type FieldEditorProps = {
97
+ nodeType: WorkflowNodeMetadataResponse;
98
+ field: WorkflowNodeConfigurationFieldDefinition;
99
+ value: any;
100
+ expressionSuggestions?: WorkflowExpressionSuggestion[];
101
+ readOnly?: boolean;
102
+ onChange: (value: any) => void;
103
+ };
104
+
105
+ export type WorkflowExpressionSuggestionGroup = "Inputs" | "Variables" | "Secrets" | "Outputs";
106
+
107
+ export type WorkflowExpressionSuggestion = {
108
+ group: WorkflowExpressionSuggestionGroup;
109
+ label: string;
110
+ insertText: string;
111
+ detail?: string;
112
+ description?: string;
113
+ };
114
+
115
+ type WorkflowExpressionAutocompletePosition = {
116
+ left: number;
117
+ top: number;
118
+ width: number;
119
+ maxHeight: number;
120
+ };
121
+
122
+ const EMPTY_YAML_OBJECT = {};
123
+ const EMPTY_YAML_ARRAY: any[] = [];
124
+
125
+ function normalizeFieldValue(
126
+ field: WorkflowNodeConfigurationFieldDefinition,
127
+ currentValue: any,
128
+ ) {
129
+ if (currentValue !== undefined) {
130
+ return currentValue;
131
+ }
132
+
133
+ return field.defaultValue;
134
+ }
135
+
136
+ function stringifyYamlEditorValue(value: any, emptyValue: any) {
137
+ if (typeof value === "string") {
138
+ return value;
139
+ }
140
+
141
+ return YAML.stringify(value ?? emptyValue);
142
+ }
143
+
144
+ function stringifyJsonEditorValue(value: any, emptyValue: any) {
145
+ if (typeof value === "string") {
146
+ return value;
147
+ }
148
+
149
+ return JSON.stringify(value ?? emptyValue, null, 2);
150
+ }
151
+
152
+ function getYamlValueSignature(value: any) {
153
+ try {
154
+ return JSON.stringify(value);
155
+ } catch {
156
+ return String(value);
157
+ }
158
+ }
159
+
160
+ function getPathValue(value: Record<string, any>, pathOrKey: string) {
161
+ return pathOrKey
162
+ .split(".")
163
+ .reduce<any>((current, part) => current?.[part], value);
164
+ }
165
+
166
+ function setPathValue(value: Record<string, any>, pathOrKey: string, nextValue: any) {
167
+ const parts = pathOrKey.split(".");
168
+ if (parts.length === 1) {
169
+ return {
170
+ ...value,
171
+ [pathOrKey]: nextValue,
172
+ };
173
+ }
174
+
175
+ const nextRoot = { ...value };
176
+ let cursor: Record<string, any> = nextRoot;
177
+ parts.forEach((part, index) => {
178
+ if (index === parts.length - 1) {
179
+ cursor[part] = nextValue;
180
+ return;
181
+ }
182
+
183
+ const existing = cursor[part];
184
+ cursor[part] =
185
+ existing && typeof existing === "object" && !Array.isArray(existing)
186
+ ? { ...existing }
187
+ : {};
188
+ cursor = cursor[part];
189
+ });
190
+
191
+ return nextRoot;
192
+ }
193
+
194
+ function getSlotCount(node: WorkflowNodeEditorValue, slot: WorkflowNodeChildSlotDefinition) {
195
+ if (slot.kind === "case-collection") {
196
+ return Object.keys(node.cases ?? {}).length;
197
+ }
198
+
199
+ const value = node[slot.key];
200
+ return Array.isArray(value) ? value.length : 0;
201
+ }
202
+
203
+ function hasRuntimeFields(nodeType: WorkflowNodeMetadataResponse) {
204
+ const authoring = nodeType.authoring;
205
+ return Boolean(
206
+ authoring?.supportsDisableToggle ||
207
+ authoring?.supportsTimeoutMs ||
208
+ authoring?.supportsOnError ||
209
+ authoring?.supportsRetryPolicy,
210
+ );
211
+ }
212
+
213
+ function getNodeTypeIconName(nodeType: WorkflowNodeMetadataResponse) {
214
+ return nodeType.ui?.icon ?? nodeType.icon;
215
+ }
216
+
217
+ function WorkflowNodeTypeIcon({
218
+ nodeType,
219
+ size = 18,
220
+ }: {
221
+ nodeType: WorkflowNodeMetadataResponse;
222
+ size?: number;
223
+ }) {
224
+ const iconName = getNodeTypeIconName(nodeType);
225
+ const normalizedIconName = normalizeSolidIconName(iconName);
226
+
227
+ if (normalizedIconName) {
228
+ return <SolidIcon name={normalizedIconName} size={size} aria-hidden />;
229
+ }
230
+
231
+ if (nodeType.kind === "control") {
232
+ return <GitBranch size={size} strokeWidth={1.9} />;
233
+ }
234
+
235
+ if (nodeType.kind === "subflow") {
236
+ return <Workflow size={size} strokeWidth={1.9} />;
237
+ }
238
+
239
+ return <Zap size={size} strokeWidth={1.9} />;
240
+ }
241
+
242
+ function getWorkflowNodeIconStyle(
243
+ nodeType: WorkflowNodeMetadataResponse,
244
+ ): React.CSSProperties | undefined {
245
+ const backgroundColor = nodeType.ui?.iconBackgroundColor;
246
+ const color = nodeType.ui?.iconColor;
247
+ const borderColor = nodeType.ui?.iconBorderColor;
248
+
249
+ if (!backgroundColor && !color && !borderColor) {
250
+ return undefined;
251
+ }
252
+
253
+ return {
254
+ ...(backgroundColor ? { backgroundColor } : null),
255
+ ...(color ? { color } : null),
256
+ ...(borderColor ? { borderColor } : null),
257
+ };
258
+ }
259
+
260
+ function normalizeGroupLabel(value: string | undefined, fallback: string) {
261
+ const trimmed = value?.trim();
262
+ return trimmed || fallback;
263
+ }
264
+
265
+ function getNodeTypeSearchText(nodeType: WorkflowNodeMetadataResponse) {
266
+ return [
267
+ nodeType.type,
268
+ nodeType.kind,
269
+ nodeType.label,
270
+ nodeType.description,
271
+ nodeType.category,
272
+ nodeType.subcategory,
273
+ ...(nodeType.tags ?? []),
274
+ ...(nodeType.authoring?.searchableText ?? []),
275
+ ]
276
+ .filter(Boolean)
277
+ .join(" ")
278
+ .toLowerCase();
279
+ }
280
+
281
+ function createSelectOptions(values: string[], allLabel: string) {
282
+ return [
283
+ { label: allLabel, value: "" },
284
+ ...values
285
+ .filter(Boolean)
286
+ .sort((a, b) => a.localeCompare(b))
287
+ .map((value) => ({ label: value, value })),
288
+ ];
289
+ }
290
+
291
+ function isConfigurationFieldVisible(
292
+ field: WorkflowNodeConfigurationFieldDefinition,
293
+ draft: Record<string, any>,
294
+ ) {
295
+ const visibleWhen = field.uiSchema?.visibleWhen as
296
+ | {
297
+ field?: string;
298
+ path?: string;
299
+ equals?: any;
300
+ notEquals?: any;
301
+ includes?: any[];
302
+ }
303
+ | undefined;
304
+
305
+ if (!visibleWhen) {
306
+ return true;
307
+ }
308
+
309
+ const dependencyPath = visibleWhen.path ?? visibleWhen.field;
310
+ if (!dependencyPath) {
311
+ return true;
312
+ }
313
+
314
+ const dependencyValue = getPathValue(draft, dependencyPath);
315
+
316
+ if ("equals" in visibleWhen) {
317
+ return dependencyValue === visibleWhen.equals;
318
+ }
319
+
320
+ if ("notEquals" in visibleWhen) {
321
+ return dependencyValue !== visibleWhen.notEquals;
322
+ }
323
+
324
+ if (Array.isArray(visibleWhen.includes)) {
325
+ return visibleWhen.includes.includes(dependencyValue);
326
+ }
327
+
328
+ return true;
329
+ }
330
+
331
+ function getConfigurationFieldWidth(field: WorkflowNodeConfigurationFieldDefinition) {
332
+ const width = field.uiSchema?.layout?.width;
333
+ return width === "full" || width === "field" ? width : "half";
334
+ }
335
+
336
+ function normalizeCssLength(value: unknown) {
337
+ if (typeof value === "number" && Number.isFinite(value)) {
338
+ return `${value}px`;
339
+ }
340
+
341
+ if (typeof value === "string" && value.trim()) {
342
+ return value;
343
+ }
344
+
345
+ return undefined;
346
+ }
347
+
348
+ function getConfigurationFieldEditorHeight(
349
+ field: WorkflowNodeConfigurationFieldDefinition,
350
+ fallback = "220px",
351
+ ) {
352
+ return (
353
+ normalizeCssLength(field.uiSchema?.editor?.height) ??
354
+ normalizeCssLength(field.uiSchema?.layout?.height) ??
355
+ normalizeCssLength(field.uiSchema?.layout?.minHeight) ??
356
+ fallback
357
+ );
358
+ }
359
+
360
+ function getWorkflowNodeEditorDialogStyle(
361
+ nodeType: WorkflowNodeMetadataResponse,
362
+ ): React.CSSProperties {
363
+ const modalSize = nodeType.ui?.modalSize ?? "lg";
364
+
365
+ if (modalSize === "full") {
366
+ return {
367
+ width: "96vw",
368
+ maxWidth: "96vw",
369
+ height: "92vh",
370
+ maxHeight: "92vh",
371
+ };
372
+ }
373
+
374
+ if (modalSize === "xl") {
375
+ return {
376
+ width: "min(1240px, 94vw)",
377
+ maxWidth: "94vw",
378
+ height: "min(880px, 90vh)",
379
+ maxHeight: "90vh",
380
+ };
381
+ }
382
+
383
+ return {
384
+ width: "min(780px, 92vw)",
385
+ maxWidth: "92vw",
386
+ maxHeight: "90vh",
387
+ };
388
+ }
389
+
390
+ function getFieldHintItems(field: WorkflowNodeConfigurationFieldDefinition) {
391
+ return [
392
+ field.valueType ? { key: "valueType", label: field.valueType } : null,
393
+ field.required ? { key: "required", label: "required", tone: "warn" as const } : null,
394
+ field.expressionAllowed ? { key: "expressions", label: "expressions" } : null,
395
+ field.secretAllowed ? { key: "secret", label: "secret", tone: "success" as const } : null,
396
+ ].filter(Boolean) as Array<{
397
+ key: string;
398
+ label: string;
399
+ tone?: "warn" | "success";
400
+ }>;
401
+ }
402
+
403
+ function WorkflowFieldHelp({ field }: { field: WorkflowNodeConfigurationFieldDefinition }) {
404
+ const hintItems = getFieldHintItems(field);
405
+
406
+ if (!field.description && !hintItems.length) {
407
+ return null;
408
+ }
409
+
410
+ return (
411
+ <SolidTooltip delayDuration={120}>
412
+ <SolidTooltipTrigger asChild>
413
+ <button
414
+ type="button"
415
+ className="workflow-node-editor-help-trigger"
416
+ aria-label={`${field.label ?? field.key} help`}
417
+ >
418
+ <CircleHelp size={13} />
419
+ </button>
420
+ </SolidTooltipTrigger>
421
+ <SolidTooltipContent
422
+ side="top"
423
+ align="end"
424
+ className="workflow-node-editor-help-tooltip"
425
+ >
426
+ {field.description ? (
427
+ <div className="workflow-node-editor-help-section">
428
+ <div className="workflow-node-editor-help-title">Help</div>
429
+ <div className="workflow-node-editor-help-copy">{field.description}</div>
430
+ </div>
431
+ ) : null}
432
+ {hintItems.length ? (
433
+ <div className="workflow-node-editor-help-section">
434
+ <div className="workflow-node-editor-help-title">Allowed</div>
435
+ <div className="workflow-node-editor-help-pills">
436
+ {hintItems.map((item) => (
437
+ <SolidTag key={item.key} tone={item.tone}>
438
+ {item.label}
439
+ </SolidTag>
440
+ ))}
441
+ </div>
442
+ </div>
443
+ ) : null}
444
+ </SolidTooltipContent>
445
+ </SolidTooltip>
446
+ );
447
+ }
448
+
449
+ function normalizeKeyValueRows(value: any) {
450
+ if (Array.isArray(value)) {
451
+ return value.map((item) => ({
452
+ key: String(item?.key ?? item?.name ?? ""),
453
+ value: item?.value ?? "",
454
+ }));
455
+ }
456
+
457
+ if (value && typeof value === "object") {
458
+ return Object.entries(value).map(([key, rowValue]) => ({
459
+ key,
460
+ value:
461
+ rowValue === undefined || rowValue === null
462
+ ? ""
463
+ : typeof rowValue === "string"
464
+ ? rowValue
465
+ : YAML.stringify(rowValue).trim(),
466
+ }));
467
+ }
468
+
469
+ return [];
470
+ }
471
+
472
+ function rowsToKeyValueObject(rows: Array<{ key: string; value: any }>) {
473
+ return rows.reduce<Record<string, any>>((acc, row) => {
474
+ const key = row.key.trim();
475
+ if (!key) {
476
+ return acc;
477
+ }
478
+ acc[key] = row.value;
479
+ return acc;
480
+ }, {});
481
+ }
482
+
483
+ function keyValueRowsSignature(rows: Array<{ key: string; value: any }>) {
484
+ return JSON.stringify(rowsToKeyValueObject(rows));
485
+ }
486
+
487
+ function WorkflowKeyValueEditor({
488
+ value,
489
+ readOnly,
490
+ onChange,
491
+ }: {
492
+ value: any;
493
+ readOnly?: boolean;
494
+ onChange: (value: Record<string, any>) => void;
495
+ }) {
496
+ const normalizedRows = normalizeKeyValueRows(value);
497
+ const [rows, setRows] = React.useState<Array<{ key: string; value: any }>>(
498
+ normalizedRows.length ? normalizedRows : [{ key: "", value: "" }],
499
+ );
500
+ const lastEmittedSignatureRef = React.useRef(keyValueRowsSignature(normalizedRows));
501
+
502
+ React.useEffect(() => {
503
+ const nextRows = normalizeKeyValueRows(value);
504
+ const nextSignature = keyValueRowsSignature(nextRows);
505
+ if (nextSignature === lastEmittedSignatureRef.current) {
506
+ return;
507
+ }
508
+
509
+ setRows(nextRows.length ? nextRows : [{ key: "", value: "" }]);
510
+ lastEmittedSignatureRef.current = nextSignature;
511
+ }, [value]);
512
+
513
+ const emitRows = (nextRows: Array<{ key: string; value: any }>) => {
514
+ const nextValue = rowsToKeyValueObject(nextRows);
515
+ lastEmittedSignatureRef.current = JSON.stringify(nextValue);
516
+ onChange(nextValue);
517
+ };
518
+
519
+ const updateRow = (
520
+ index: number,
521
+ patch: Partial<{ key: string; value: any }>,
522
+ ) => {
523
+ const nextRows = rows.map((row, rowIndex) =>
524
+ rowIndex === index ? { ...row, ...patch } : row,
525
+ );
526
+ setRows(nextRows);
527
+ emitRows(nextRows);
528
+ };
529
+
530
+ const removeRow = (index: number) => {
531
+ const nextRows = rows.filter((_, rowIndex) => rowIndex !== index);
532
+ const displayRows = nextRows.length ? nextRows : [{ key: "", value: "" }];
533
+ setRows(displayRows);
534
+ emitRows(displayRows);
535
+ };
536
+
537
+ const addRow = () => {
538
+ setRows([...rows, { key: "", value: "" }]);
539
+ };
540
+
541
+ return (
542
+ <div className="workflow-node-key-value-editor">
543
+ <div className="workflow-node-key-value-header">
544
+ <span>Key</span>
545
+ <span>Value</span>
546
+ <span />
547
+ </div>
548
+ {rows.map((row, index) => (
549
+ <div
550
+ className="workflow-node-key-value-row"
551
+ key={`${row.key || "row"}-${index}`}
552
+ >
553
+ <SolidInput
554
+ value={row.key}
555
+ disabled={readOnly}
556
+ placeholder="key"
557
+ onChange={(event) => updateRow(index, { key: event.target.value })}
558
+ />
559
+ <SolidInput
560
+ value={row.value ?? ""}
561
+ disabled={readOnly}
562
+ placeholder="value"
563
+ onChange={(event) => updateRow(index, { value: event.target.value })}
564
+ />
565
+ <button
566
+ type="button"
567
+ className="workflow-node-key-value-action"
568
+ disabled={readOnly || rows.length === 1}
569
+ aria-label="Remove row"
570
+ onClick={() => removeRow(index)}
571
+ >
572
+ <Trash2 size={14} />
573
+ </button>
574
+ </div>
575
+ ))}
576
+ <button
577
+ type="button"
578
+ className="workflow-node-key-value-add"
579
+ disabled={readOnly}
580
+ onClick={addRow}
581
+ >
582
+ <Plus size={14} />
583
+ Add row
584
+ </button>
585
+ </div>
586
+ );
587
+ }
588
+
589
+ function WorkflowYamlFieldEditor({
590
+ value,
591
+ readOnly,
592
+ onChange,
593
+ emptyValue = {},
594
+ format = "yaml",
595
+ height = "220px",
596
+ }: {
597
+ value: any;
598
+ readOnly?: boolean;
599
+ onChange: (value: any) => void;
600
+ emptyValue?: any;
601
+ format?: "json" | "yaml";
602
+ height?: string;
603
+ }) {
604
+ const stringifyValue = React.useCallback(
605
+ (nextValue: any, nextEmptyValue: any) =>
606
+ format === "json"
607
+ ? stringifyJsonEditorValue(nextValue, nextEmptyValue)
608
+ : stringifyYamlEditorValue(nextValue, nextEmptyValue),
609
+ [format],
610
+ );
611
+ const [textValue, setTextValue] = React.useState(() =>
612
+ stringifyValue(value, emptyValue),
613
+ );
614
+ const [parseError, setParseError] = React.useState<string | null>(null);
615
+ const lastEmittedSignatureRef = React.useRef(getYamlValueSignature(value ?? emptyValue));
616
+
617
+ React.useEffect(() => {
618
+ const nextSignature = getYamlValueSignature(value ?? emptyValue);
619
+ if (nextSignature === lastEmittedSignatureRef.current) {
620
+ return;
621
+ }
622
+
623
+ setTextValue(stringifyValue(value, emptyValue));
624
+ setParseError(null);
625
+ lastEmittedSignatureRef.current = nextSignature;
626
+ }, [emptyValue, stringifyValue, value]);
627
+
628
+ const handleEditorChange = (nextText: string | undefined) => {
629
+ const safeText = nextText ?? "";
630
+ setTextValue(safeText);
631
+
632
+ try {
633
+ const parsedValue = safeText.trim()
634
+ ? format === "json"
635
+ ? JSON.parse(safeText)
636
+ : YAML.parse(safeText)
637
+ : emptyValue;
638
+ setParseError(null);
639
+ lastEmittedSignatureRef.current = getYamlValueSignature(parsedValue);
640
+ onChange(parsedValue);
641
+ } catch (error: any) {
642
+ setParseError(error?.message ?? `${format.toUpperCase()} is invalid.`);
643
+ }
644
+ };
645
+
646
+ return (
647
+ <div className="workflow-node-yaml-field-editor">
648
+ <SolidCodeEditor
649
+ language={format}
650
+ height={height}
651
+ fontSize={12}
652
+ readOnly={readOnly}
653
+ value={textValue}
654
+ onChange={handleEditorChange}
655
+ />
656
+ {parseError ? (
657
+ <div className="workflow-node-yaml-field-error">{parseError}</div>
658
+ ) : null}
659
+ </div>
660
+ );
661
+ }
662
+
663
+ function stringifyRecipientListValue(value: any) {
664
+ if (Array.isArray(value)) {
665
+ return value.join(", ");
666
+ }
667
+
668
+ if (value === undefined || value === null) {
669
+ return "";
670
+ }
671
+
672
+ return String(value);
673
+ }
674
+
675
+ function parseRecipientListValue(value: string) {
676
+ const trimmedValue = value.trim();
677
+ if (!trimmedValue) {
678
+ return [];
679
+ }
680
+
681
+ if (/^\{\{[\s\S]*\}\}$/.test(trimmedValue)) {
682
+ return trimmedValue;
683
+ }
684
+
685
+ const recipients = trimmedValue
686
+ .split(",")
687
+ .map((recipient) => recipient.trim())
688
+ .filter(Boolean);
689
+
690
+ return recipients.length <= 1 ? trimmedValue : recipients;
691
+ }
692
+
693
+ function WorkflowRecipientListFieldEditor({
694
+ value,
695
+ readOnly,
696
+ placeholder,
697
+ expressionSuggestions,
698
+ onChange,
699
+ }: {
700
+ value: any;
701
+ readOnly?: boolean;
702
+ placeholder?: string;
703
+ expressionSuggestions?: WorkflowExpressionSuggestion[];
704
+ onChange: (value: any) => void;
705
+ }) {
706
+ const [textValue, setTextValue] = React.useState(() =>
707
+ stringifyRecipientListValue(value),
708
+ );
709
+ const lastValueSignatureRef = React.useRef(getYamlValueSignature(value));
710
+
711
+ React.useEffect(() => {
712
+ const nextSignature = getYamlValueSignature(value);
713
+ if (nextSignature === lastValueSignatureRef.current) {
714
+ return;
715
+ }
716
+
717
+ setTextValue(stringifyRecipientListValue(value));
718
+ lastValueSignatureRef.current = nextSignature;
719
+ }, [value]);
720
+
721
+ const emitChange = (nextValue: string) => {
722
+ setTextValue(nextValue);
723
+ const parsedValue = parseRecipientListValue(nextValue);
724
+ lastValueSignatureRef.current = getYamlValueSignature(parsedValue);
725
+ onChange(parsedValue);
726
+ };
727
+
728
+ return (
729
+ <WorkflowExpressionAutocompleteField
730
+ value={textValue}
731
+ readOnly={readOnly}
732
+ placeholder={placeholder ?? "{{ item.email }}"}
733
+ suggestions={expressionSuggestions}
734
+ onChange={emitChange}
735
+ />
736
+ );
737
+ }
738
+
739
+ function getExpressionSearchTerm(value: string, caretIndex: number) {
740
+ const prefix = value.slice(0, caretIndex);
741
+ const expressionStart = prefix.lastIndexOf("{{");
742
+ if (expressionStart >= 0 && prefix.lastIndexOf("}}") < expressionStart) {
743
+ return prefix.slice(expressionStart + 2).trim();
744
+ }
745
+
746
+ const wordMatch = prefix.match(/[A-Za-z0-9_.-]*$/);
747
+ return wordMatch?.[0] ?? "";
748
+ }
749
+
750
+ function insertExpressionAtCaret(
751
+ value: string,
752
+ caretIndex: number,
753
+ insertText: string,
754
+ ) {
755
+ const prefix = value.slice(0, caretIndex);
756
+ const suffix = value.slice(caretIndex);
757
+ const expressionStart = prefix.lastIndexOf("{{");
758
+ const expressionEndInSuffix = suffix.indexOf("}}");
759
+
760
+ if (expressionStart >= 0 && prefix.lastIndexOf("}}") < expressionStart) {
761
+ const endIndex =
762
+ expressionEndInSuffix >= 0
763
+ ? caretIndex + expressionEndInSuffix + 2
764
+ : caretIndex;
765
+ return {
766
+ value: `${value.slice(0, expressionStart)}${insertText}${value.slice(endIndex)}`,
767
+ caretIndex: expressionStart + insertText.length,
768
+ };
769
+ }
770
+
771
+ const wordMatch = prefix.match(/[A-Za-z0-9_.-]*$/);
772
+ const replaceStart = wordMatch ? caretIndex - wordMatch[0].length : caretIndex;
773
+ const spacerBefore =
774
+ replaceStart > 0 && !/\s/.test(value.charAt(replaceStart - 1)) ? " " : "";
775
+ const spacerAfter =
776
+ suffix && !/^\s/.test(suffix) ? " " : "";
777
+ const replacement = `${spacerBefore}${insertText}${spacerAfter}`;
778
+
779
+ return {
780
+ value: `${value.slice(0, replaceStart)}${replacement}${suffix}`,
781
+ caretIndex: replaceStart + spacerBefore.length + insertText.length,
782
+ };
783
+ }
784
+
785
+ function getWorkflowAutocompletePortalPosition(
786
+ anchor: HTMLElement | null,
787
+ ): WorkflowExpressionAutocompletePosition | null {
788
+ if (!anchor || typeof window === "undefined") {
789
+ return null;
790
+ }
791
+
792
+ const rect = anchor.getBoundingClientRect();
793
+ const viewportWidth = window.innerWidth;
794
+ const viewportHeight = window.innerHeight;
795
+ const gutter = 12;
796
+ const offset = 6;
797
+ const preferredWidth = Math.max(rect.width, 420);
798
+ const width = Math.min(preferredWidth, viewportWidth - gutter * 2);
799
+ const left = Math.min(
800
+ Math.max(rect.left, gutter),
801
+ Math.max(viewportWidth - width - gutter, gutter),
802
+ );
803
+ const spaceBelow = viewportHeight - rect.bottom - gutter;
804
+ const spaceAbove = rect.top - gutter;
805
+ const renderAbove = spaceBelow < 220 && spaceAbove > spaceBelow;
806
+ const availableHeight = Math.max(
807
+ 160,
808
+ Math.min(320, renderAbove ? spaceAbove - offset : spaceBelow - offset),
809
+ );
810
+
811
+ return {
812
+ left,
813
+ top: renderAbove
814
+ ? Math.max(gutter, rect.top - offset - availableHeight)
815
+ : Math.min(viewportHeight - gutter - availableHeight, rect.bottom + offset),
816
+ width,
817
+ maxHeight: availableHeight,
818
+ };
819
+ }
820
+
821
+ export function WorkflowExpressionAutocompleteField({
822
+ value,
823
+ readOnly,
824
+ multiline,
825
+ placeholder,
826
+ suggestions = [],
827
+ onChange,
828
+ }: {
829
+ value: string;
830
+ readOnly?: boolean;
831
+ multiline?: boolean;
832
+ placeholder?: string;
833
+ suggestions?: WorkflowExpressionSuggestion[];
834
+ onChange: (value: string) => void;
835
+ }) {
836
+ const inputRef = React.useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);
837
+ const [open, setOpen] = React.useState(false);
838
+ const [query, setQuery] = React.useState("");
839
+ const [activeIndex, setActiveIndex] = React.useState(0);
840
+ const [portalPosition, setPortalPosition] =
841
+ React.useState<WorkflowExpressionAutocompletePosition | null>(null);
842
+
843
+ const filteredSuggestions = React.useMemo(() => {
844
+ const normalizedQuery = query.trim().toLowerCase();
845
+ if (!normalizedQuery) {
846
+ return suggestions;
847
+ }
848
+
849
+ return suggestions.filter((suggestion) =>
850
+ [
851
+ suggestion.group,
852
+ suggestion.label,
853
+ suggestion.insertText,
854
+ suggestion.detail,
855
+ suggestion.description,
856
+ ]
857
+ .filter(Boolean)
858
+ .some((entry) => String(entry).toLowerCase().includes(normalizedQuery)),
859
+ );
860
+ }, [query, suggestions]);
861
+
862
+ React.useEffect(() => {
863
+ setActiveIndex(0);
864
+ }, [query]);
865
+
866
+ const updatePortalPosition = React.useCallback(() => {
867
+ setPortalPosition(getWorkflowAutocompletePortalPosition(inputRef.current));
868
+ }, []);
869
+
870
+ React.useLayoutEffect(() => {
871
+ if (!open) {
872
+ setPortalPosition(null);
873
+ return;
874
+ }
875
+
876
+ updatePortalPosition();
877
+ }, [open, updatePortalPosition, value, filteredSuggestions.length]);
878
+
879
+ React.useEffect(() => {
880
+ if (!open || typeof window === "undefined") {
881
+ return;
882
+ }
883
+
884
+ window.addEventListener("resize", updatePortalPosition);
885
+ window.addEventListener("scroll", updatePortalPosition, true);
886
+
887
+ return () => {
888
+ window.removeEventListener("resize", updatePortalPosition);
889
+ window.removeEventListener("scroll", updatePortalPosition, true);
890
+ };
891
+ }, [open, updatePortalPosition]);
892
+
893
+ const openPicker = () => {
894
+ const input = inputRef.current;
895
+ const caretIndex = input?.selectionStart ?? value.length;
896
+ setQuery(getExpressionSearchTerm(value, caretIndex));
897
+ setPortalPosition(getWorkflowAutocompletePortalPosition(input));
898
+ setOpen(true);
899
+ };
900
+
901
+ const closePicker = () => {
902
+ setOpen(false);
903
+ setQuery("");
904
+ setActiveIndex(0);
905
+ setPortalPosition(null);
906
+ };
907
+
908
+ const selectSuggestion = (suggestion: WorkflowExpressionSuggestion) => {
909
+ const input = inputRef.current;
910
+ const caretIndex = input?.selectionStart ?? value.length;
911
+ const next = insertExpressionAtCaret(value, caretIndex, suggestion.insertText);
912
+ onChange(next.value);
913
+ closePicker();
914
+
915
+ window.requestAnimationFrame(() => {
916
+ input?.focus();
917
+ input?.setSelectionRange(next.caretIndex, next.caretIndex);
918
+ });
919
+ };
920
+
921
+ const handleKeyDown = (
922
+ event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>,
923
+ ) => {
924
+ if (event.ctrlKey && event.code === "Space") {
925
+ event.preventDefault();
926
+ if (!readOnly) {
927
+ openPicker();
928
+ }
929
+ return;
930
+ }
931
+
932
+ if (!open) {
933
+ return;
934
+ }
935
+
936
+ if (event.key === "Escape") {
937
+ event.preventDefault();
938
+ closePicker();
939
+ return;
940
+ }
941
+
942
+ if (event.key === "ArrowDown") {
943
+ event.preventDefault();
944
+ setActiveIndex((current) =>
945
+ Math.min(current + 1, Math.max(filteredSuggestions.length - 1, 0)),
946
+ );
947
+ return;
948
+ }
949
+
950
+ if (event.key === "ArrowUp") {
951
+ event.preventDefault();
952
+ setActiveIndex((current) => Math.max(current - 1, 0));
953
+ return;
954
+ }
955
+
956
+ if (event.key === "Enter" && filteredSuggestions[activeIndex]) {
957
+ event.preventDefault();
958
+ selectSuggestion(filteredSuggestions[activeIndex]);
959
+ }
960
+ };
961
+
962
+ const handleChange = (
963
+ event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
964
+ ) => {
965
+ const nextValue = event.target.value;
966
+ onChange(nextValue);
967
+
968
+ if (open) {
969
+ setQuery(getExpressionSearchTerm(nextValue, event.target.selectionStart ?? nextValue.length));
970
+ }
971
+ };
972
+
973
+ const groupedSuggestions = filteredSuggestions.reduce<Record<string, WorkflowExpressionSuggestion[]>>(
974
+ (acc, suggestion) => {
975
+ acc[suggestion.group] = acc[suggestion.group] ?? [];
976
+ acc[suggestion.group].push(suggestion);
977
+ return acc;
978
+ },
979
+ {},
980
+ );
981
+
982
+ const inputProps = {
983
+ ref: inputRef as any,
984
+ value,
985
+ disabled: readOnly,
986
+ placeholder,
987
+ onChange: handleChange,
988
+ onKeyDown: handleKeyDown,
989
+ onBlur: () => window.setTimeout(() => setOpen(false), 120),
990
+ };
991
+
992
+ const handleMenuWheel = (event: React.WheelEvent<HTMLDivElement>) => {
993
+ const menuElement = event.currentTarget;
994
+ const canScrollVertically =
995
+ menuElement.scrollHeight > menuElement.clientHeight;
996
+ const canScrollHorizontally =
997
+ menuElement.scrollWidth > menuElement.clientWidth;
998
+
999
+ if (!canScrollVertically && !canScrollHorizontally) {
1000
+ return;
1001
+ }
1002
+
1003
+ event.preventDefault();
1004
+ event.stopPropagation();
1005
+
1006
+ if (canScrollVertically) {
1007
+ menuElement.scrollTop += event.deltaY;
1008
+ }
1009
+
1010
+ if (event.shiftKey && canScrollHorizontally) {
1011
+ menuElement.scrollLeft += event.deltaY || event.deltaX;
1012
+ } else if (canScrollHorizontally && Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
1013
+ menuElement.scrollLeft += event.deltaX;
1014
+ }
1015
+ };
1016
+
1017
+ const menu = open && portalPosition && typeof document !== "undefined" ? (
1018
+ <div
1019
+ className="workflow-expression-autocomplete-menu"
1020
+ data-solid-dialog-outside-safe="true"
1021
+ style={{
1022
+ left: portalPosition.left,
1023
+ top: portalPosition.top,
1024
+ width: portalPosition.width,
1025
+ maxHeight: portalPosition.maxHeight,
1026
+ }}
1027
+ onMouseDown={(event) => event.preventDefault()}
1028
+ onWheelCapture={handleMenuWheel}
1029
+ >
1030
+ <div className="workflow-expression-autocomplete-help">
1031
+ Start typing to choose from available variables, inputs, secrets, or outputs.
1032
+ </div>
1033
+ {filteredSuggestions.length ? (
1034
+ Object.entries(groupedSuggestions).map(([group, groupSuggestions]) => (
1035
+ <div key={group} className="workflow-expression-autocomplete-group">
1036
+ <div className="workflow-expression-autocomplete-group-title">{group}</div>
1037
+ {groupSuggestions.map((suggestion) => {
1038
+ const absoluteIndex = filteredSuggestions.indexOf(suggestion);
1039
+ const isActive = absoluteIndex === activeIndex;
1040
+
1041
+ return (
1042
+ <button
1043
+ key={`${suggestion.group}-${suggestion.insertText}`}
1044
+ type="button"
1045
+ className={`workflow-expression-autocomplete-option ${isActive ? "is-active" : ""}`}
1046
+ onMouseDown={(event) => {
1047
+ event.preventDefault();
1048
+ selectSuggestion(suggestion);
1049
+ }}
1050
+ >
1051
+ <span className="workflow-expression-autocomplete-option-main">
1052
+ <span className="workflow-expression-autocomplete-option-label">
1053
+ {suggestion.label}
1054
+ </span>
1055
+ {suggestion.detail ? (
1056
+ <span className="workflow-expression-autocomplete-option-detail">
1057
+ {suggestion.detail}
1058
+ </span>
1059
+ ) : null}
1060
+ </span>
1061
+ {suggestion.description ? (
1062
+ <span className="workflow-expression-autocomplete-option-description">
1063
+ {suggestion.description}
1064
+ </span>
1065
+ ) : null}
1066
+ </button>
1067
+ );
1068
+ })}
1069
+ </div>
1070
+ ))
1071
+ ) : (
1072
+ <div className="workflow-expression-autocomplete-empty">
1073
+ No matching expression references.
1074
+ </div>
1075
+ )}
1076
+ </div>
1077
+ ) : null;
1078
+
1079
+ return (
1080
+ <div className="workflow-expression-autocomplete">
1081
+ {multiline ? (
1082
+ <SolidTextarea {...inputProps} />
1083
+ ) : (
1084
+ <SolidInput {...inputProps} />
1085
+ )}
1086
+ {menu ? createPortal(menu, document.body) : null}
1087
+ </div>
1088
+ );
1089
+ }
1090
+
1091
+ function WorkflowNodeFieldEditor({
1092
+ nodeType,
1093
+ field,
1094
+ value,
1095
+ expressionSuggestions,
1096
+ readOnly,
1097
+ onChange,
1098
+ }: FieldEditorProps) {
1099
+ const extensionKey =
1100
+ field.extensionComponentKey ?? nodeType.ui?.fieldComponentKeys?.[field.key];
1101
+ const ExtensionComponent = extensionKey ? getExtensionComponent(extensionKey) : null;
1102
+
1103
+ const normalizedValue = normalizeFieldValue(field, value);
1104
+
1105
+ if (ExtensionComponent) {
1106
+ return (
1107
+ <ExtensionComponent
1108
+ nodeType={nodeType}
1109
+ field={field}
1110
+ value={normalizedValue}
1111
+ onChange={onChange}
1112
+ readOnly={readOnly}
1113
+ />
1114
+ );
1115
+ }
1116
+
1117
+ if (field.enumValues?.length) {
1118
+ return (
1119
+ <SolidSelect
1120
+ value={normalizedValue}
1121
+ disabled={readOnly}
1122
+ options={field.enumValues.map((item) => ({
1123
+ label: String(item),
1124
+ value: item,
1125
+ }))}
1126
+ onChange={(event) => onChange(event.value)}
1127
+ />
1128
+ );
1129
+ }
1130
+
1131
+ if (field.widgetHint === "key-value-editor") {
1132
+ return (
1133
+ <WorkflowKeyValueEditor
1134
+ value={normalizedValue}
1135
+ readOnly={readOnly}
1136
+ onChange={onChange}
1137
+ />
1138
+ );
1139
+ }
1140
+
1141
+ if (field.valueType === "boolean") {
1142
+ return (
1143
+ <SolidSwitch
1144
+ checked={!!normalizedValue}
1145
+ disabled={readOnly}
1146
+ onChange={(checked) => onChange(checked)}
1147
+ />
1148
+ );
1149
+ }
1150
+
1151
+ if (field.valueType === "number" || field.valueType === "integer") {
1152
+ return (
1153
+ <SolidNumberInput
1154
+ value={normalizedValue}
1155
+ disabled={readOnly}
1156
+ onChange={(event) => onChange(event.value)}
1157
+ />
1158
+ );
1159
+ }
1160
+
1161
+ if (field.widgetHint === "raw-editor") {
1162
+ const stringValue =
1163
+ typeof normalizedValue === "string"
1164
+ ? normalizedValue
1165
+ : normalizedValue === undefined || normalizedValue === null
1166
+ ? ""
1167
+ : JSON.stringify(normalizedValue, null, 2);
1168
+ const editorLanguage = field.uiSchema?.editor?.language ?? "json";
1169
+
1170
+ return (
1171
+ <SolidCodeEditor
1172
+ language={editorLanguage}
1173
+ height={getConfigurationFieldEditorHeight(field)}
1174
+ fontSize={12}
1175
+ readOnly={readOnly}
1176
+ value={stringValue}
1177
+ onChange={(next) => onChange(next ?? "")}
1178
+ />
1179
+ );
1180
+ }
1181
+
1182
+ if (field.widgetHint === "recipient-list") {
1183
+ return (
1184
+ <WorkflowRecipientListFieldEditor
1185
+ value={normalizedValue}
1186
+ readOnly={readOnly}
1187
+ placeholder={field.uiSchema?.placeholder}
1188
+ expressionSuggestions={expressionSuggestions}
1189
+ onChange={onChange}
1190
+ />
1191
+ );
1192
+ }
1193
+
1194
+ if (
1195
+ field.valueType === "object" ||
1196
+ field.valueType === "array" ||
1197
+ field.valueType === "json" ||
1198
+ field.widgetHint === "json-editor" ||
1199
+ field.widgetHint === "yaml-editor"
1200
+ ) {
1201
+ return (
1202
+ <WorkflowYamlFieldEditor
1203
+ value={normalizedValue}
1204
+ readOnly={readOnly}
1205
+ onChange={onChange}
1206
+ emptyValue={field.valueType === "array" ? EMPTY_YAML_ARRAY : EMPTY_YAML_OBJECT}
1207
+ format={field.widgetHint === "yaml-editor" ? "yaml" : "json"}
1208
+ height={getConfigurationFieldEditorHeight(field)}
1209
+ />
1210
+ );
1211
+ }
1212
+
1213
+ if (field.valueType === "any") {
1214
+ return (
1215
+ <WorkflowYamlFieldEditor
1216
+ value={normalizedValue}
1217
+ readOnly={readOnly}
1218
+ onChange={onChange}
1219
+ emptyValue={null}
1220
+ format="yaml"
1221
+ height={getConfigurationFieldEditorHeight(field)}
1222
+ />
1223
+ );
1224
+ }
1225
+
1226
+ if (field.widgetHint === "textarea") {
1227
+ if (field.expressionAllowed) {
1228
+ return (
1229
+ <WorkflowExpressionAutocompleteField
1230
+ value={normalizedValue ?? ""}
1231
+ readOnly={readOnly}
1232
+ multiline
1233
+ suggestions={expressionSuggestions}
1234
+ onChange={onChange}
1235
+ />
1236
+ );
1237
+ }
1238
+
1239
+ return (
1240
+ <SolidTextarea
1241
+ value={normalizedValue ?? ""}
1242
+ disabled={readOnly}
1243
+ onChange={(event) => onChange(event.target.value)}
1244
+ />
1245
+ );
1246
+ }
1247
+
1248
+ if (field.expressionAllowed) {
1249
+ return (
1250
+ <WorkflowExpressionAutocompleteField
1251
+ value={normalizedValue ?? ""}
1252
+ readOnly={readOnly}
1253
+ suggestions={expressionSuggestions}
1254
+ onChange={onChange}
1255
+ />
1256
+ );
1257
+ }
1258
+
1259
+ return (
1260
+ <SolidInput
1261
+ value={normalizedValue ?? ""}
1262
+ disabled={readOnly}
1263
+ onChange={(event) => onChange(event.target.value)}
1264
+ />
1265
+ );
1266
+ }
1267
+
1268
+ type WorkflowConfigurationSection = {
1269
+ key: string;
1270
+ label: string;
1271
+ fields: WorkflowNodeConfigurationFieldDefinition[];
1272
+ };
1273
+
1274
+ type WorkflowConfigurationTab = {
1275
+ key: string;
1276
+ label: string;
1277
+ sections: WorkflowConfigurationSection[];
1278
+ };
1279
+
1280
+ function orderGroupLabels(groupLabels: string[], groupOrder: string[]) {
1281
+ return [...groupLabels].sort((left, right) => {
1282
+ const leftIndex = groupOrder.indexOf(left);
1283
+ const rightIndex = groupOrder.indexOf(right);
1284
+ if (leftIndex >= 0 && rightIndex >= 0) {
1285
+ return leftIndex - rightIndex;
1286
+ }
1287
+ if (leftIndex >= 0) {
1288
+ return -1;
1289
+ }
1290
+ if (rightIndex >= 0) {
1291
+ return 1;
1292
+ }
1293
+ return left.localeCompare(right);
1294
+ });
1295
+ }
1296
+
1297
+ function buildConfigurationSections(
1298
+ fields: WorkflowNodeConfigurationFieldDefinition[],
1299
+ groupOrder: string[],
1300
+ ) {
1301
+ const groupedFields = fields.reduce<Record<string, WorkflowNodeConfigurationFieldDefinition[]>>(
1302
+ (acc, field) => {
1303
+ const group = field.group ?? "General";
1304
+ acc[group] = acc[group] ?? [];
1305
+ acc[group].push(field);
1306
+ return acc;
1307
+ },
1308
+ {},
1309
+ );
1310
+
1311
+ return orderGroupLabels(Object.keys(groupedFields), groupOrder).map((group) => ({
1312
+ key: group,
1313
+ label: group,
1314
+ fields: groupedFields[group],
1315
+ }));
1316
+ }
1317
+
1318
+ function getFieldLayoutKeys(field: WorkflowNodeConfigurationFieldDefinition) {
1319
+ return [field.key, field.path].filter(Boolean) as string[];
1320
+ }
1321
+
1322
+ function buildConfigurationTabs(
1323
+ fields: WorkflowNodeConfigurationFieldDefinition[],
1324
+ groupOrder: string[],
1325
+ layout: NonNullable<WorkflowNodeMetadataResponse["authoring"]>["configurationLayout"] | undefined,
1326
+ ): WorkflowConfigurationTab[] {
1327
+ if (layout?.type !== "tabs" || !Array.isArray(layout.tabs) || !layout.tabs.length) {
1328
+ return [];
1329
+ }
1330
+
1331
+ const assignedFieldKeys = new Set<string>();
1332
+ const tabs = layout.tabs
1333
+ .map((tab) => {
1334
+ const tabFieldKeys = new Set(tab.fields ?? []);
1335
+ const tabGroupLabels = new Set(tab.groups ?? []);
1336
+ const tabFields = fields.filter((field) => {
1337
+ const isFieldMatch = getFieldLayoutKeys(field).some((key) => tabFieldKeys.has(key));
1338
+ const isGroupMatch = tabGroupLabels.has(field.group ?? "General");
1339
+
1340
+ if (isFieldMatch || isGroupMatch) {
1341
+ getFieldLayoutKeys(field).forEach((key) => assignedFieldKeys.add(key));
1342
+ return true;
1343
+ }
1344
+
1345
+ return false;
1346
+ });
1347
+
1348
+ return {
1349
+ key: tab.key,
1350
+ label: tab.label,
1351
+ sections: buildConfigurationSections(tabFields, groupOrder),
1352
+ };
1353
+ })
1354
+ .filter((tab) => tab.sections.some((section) => section.fields.length));
1355
+
1356
+ const unassignedFields = fields.filter(
1357
+ (field) => !getFieldLayoutKeys(field).some((key) => assignedFieldKeys.has(key)),
1358
+ );
1359
+
1360
+ if (unassignedFields.length) {
1361
+ tabs.push({
1362
+ key: "other",
1363
+ label: "Other",
1364
+ sections: buildConfigurationSections(unassignedFields, groupOrder),
1365
+ });
1366
+ }
1367
+
1368
+ return tabs;
1369
+ }
1370
+
1371
+ function WorkflowConfigurationSections({
1372
+ sections,
1373
+ nodeType,
1374
+ draft,
1375
+ expressionSuggestions,
1376
+ readOnly,
1377
+ updateField,
1378
+ }: {
1379
+ sections: WorkflowConfigurationSection[];
1380
+ nodeType: WorkflowNodeMetadataResponse;
1381
+ draft: Record<string, any>;
1382
+ expressionSuggestions?: WorkflowExpressionSuggestion[];
1383
+ readOnly?: boolean;
1384
+ updateField: (field: WorkflowNodeConfigurationFieldDefinition, nextValue: any) => void;
1385
+ }) {
1386
+ return (
1387
+ <>
1388
+ {sections.map((section) => (
1389
+ <section key={section.key} className="workflow-node-editor-section">
1390
+ {sections.length > 1 || section.label !== "General" ? (
1391
+ <div className="workflow-node-editor-section-heading">{section.label}</div>
1392
+ ) : null}
1393
+ <div className="workflow-node-editor-form-grid">
1394
+ {section.fields.map((field) => {
1395
+ const fieldWidth = getConfigurationFieldWidth(field);
1396
+ return (
1397
+ <div
1398
+ key={field.key}
1399
+ className={`workflow-node-editor-field workflow-node-editor-field--${fieldWidth}`}
1400
+ >
1401
+ <div className="workflow-node-editor-field-heading">
1402
+ <div className="workflow-node-editor-label-row">
1403
+ <label className="workflow-node-editor-label">
1404
+ {field.label ?? field.key}
1405
+ </label>
1406
+ <WorkflowFieldHelp field={field} />
1407
+ </div>
1408
+ </div>
1409
+ <WorkflowNodeFieldEditor
1410
+ nodeType={nodeType}
1411
+ field={field}
1412
+ value={getPathValue(draft, field.path ?? field.key)}
1413
+ expressionSuggestions={expressionSuggestions}
1414
+ readOnly={readOnly}
1415
+ onChange={(nextValue) => updateField(field, nextValue)}
1416
+ />
1417
+ </div>
1418
+ );
1419
+ })}
1420
+ </div>
1421
+ </section>
1422
+ ))}
1423
+ </>
1424
+ );
1425
+ }
1426
+
1427
+ export function WorkflowNodeSchemaEditor({
1428
+ nodeType,
1429
+ value,
1430
+ onChange,
1431
+ onSubmit,
1432
+ expressionSuggestions,
1433
+ readOnly,
1434
+ className,
1435
+ }: WorkflowNodeSchemaEditorProps) {
1436
+ const [draft, setDraft] = React.useState<Record<string, any>>(
1437
+ value ?? nodeType.authoring?.defaultConfiguration ?? {},
1438
+ );
1439
+ const [activeConfigurationTab, setActiveConfigurationTab] = React.useState("");
1440
+
1441
+ React.useEffect(() => {
1442
+ setDraft(value ?? nodeType.authoring?.defaultConfiguration ?? {});
1443
+ }, [nodeType, value]);
1444
+
1445
+ const fields = nodeType.authoring?.configurationFields ?? [];
1446
+ const groupOrder = nodeType.ui?.layoutHints?.groupOrder ?? [];
1447
+ const visibleFields = fields.filter((field) =>
1448
+ isConfigurationFieldVisible(field, draft),
1449
+ );
1450
+ const configurationSections = buildConfigurationSections(visibleFields, groupOrder);
1451
+ const configurationTabs = buildConfigurationTabs(
1452
+ visibleFields,
1453
+ groupOrder,
1454
+ nodeType.authoring?.configurationLayout,
1455
+ );
1456
+ const activeConfigurationTabValue =
1457
+ activeConfigurationTab || configurationTabs[0]?.key || "";
1458
+
1459
+ const updateField = (field: WorkflowNodeConfigurationFieldDefinition, nextValue: any) => {
1460
+ const nextDraft = setPathValue(draft, field.path ?? field.key, nextValue);
1461
+ setDraft(nextDraft);
1462
+ onChange?.(nextDraft);
1463
+ };
1464
+
1465
+ React.useEffect(() => {
1466
+ if (
1467
+ configurationTabs.length &&
1468
+ !configurationTabs.some((tab) => tab.key === activeConfigurationTab)
1469
+ ) {
1470
+ setActiveConfigurationTab(configurationTabs[0].key);
1471
+ }
1472
+ }, [activeConfigurationTab, configurationTabs]);
1473
+
1474
+ if (!configurationSections.length) {
1475
+ return (
1476
+ <div className={`workflow-node-editor-empty ${className ?? ""}`}>
1477
+ This node does not expose configuration fields yet.
1478
+ </div>
1479
+ );
1480
+ }
1481
+
1482
+ return (
1483
+ <div className={`workflow-node-editor-config ${className ?? ""}`}>
1484
+ {configurationTabs.length > 1 ? (
1485
+ <SolidTabGroup
1486
+ tabs={configurationTabs.map((tab) => ({
1487
+ value: tab.key,
1488
+ label: tab.label,
1489
+ content: (
1490
+ <WorkflowConfigurationSections
1491
+ sections={tab.sections}
1492
+ nodeType={nodeType}
1493
+ draft={draft}
1494
+ expressionSuggestions={expressionSuggestions}
1495
+ readOnly={readOnly}
1496
+ updateField={updateField}
1497
+ />
1498
+ ),
1499
+ }))}
1500
+ value={activeConfigurationTabValue}
1501
+ onValueChange={setActiveConfigurationTab}
1502
+ className="workflow-node-editor-config-tabs"
1503
+ panelClassName="workflow-node-editor-config-tab-panel"
1504
+ />
1505
+ ) : (
1506
+ <WorkflowConfigurationSections
1507
+ sections={configurationTabs[0]?.sections ?? configurationSections}
1508
+ nodeType={nodeType}
1509
+ draft={draft}
1510
+ expressionSuggestions={expressionSuggestions}
1511
+ readOnly={readOnly}
1512
+ updateField={updateField}
1513
+ />
1514
+ )}
1515
+
1516
+ {!readOnly && onSubmit ? (
1517
+ <div className="workflow-node-editor-inline-actions">
1518
+ <SolidButton onClick={() => onSubmit(draft)}>Save</SolidButton>
1519
+ </div>
1520
+ ) : null}
1521
+ </div>
1522
+ );
1523
+ }
1524
+
1525
+ function WorkflowNodeTags({ nodeType }: { nodeType: WorkflowNodeMetadataResponse }) {
1526
+ return (
1527
+ <div className="workflow-node-editor-tags">
1528
+ <SolidTag>{nodeType.kind}</SolidTag>
1529
+ {nodeType.category ? <SolidTag>{nodeType.category}</SolidTag> : null}
1530
+ {nodeType.ui?.defaultEditorMode ? <SolidTag>{nodeType.ui.defaultEditorMode}</SolidTag> : null}
1531
+ </div>
1532
+ );
1533
+ }
1534
+
1535
+ function WorkflowNodeHeaderMeta({ nodeType }: { nodeType: WorkflowNodeMetadataResponse }) {
1536
+ return (
1537
+ <div className="workflow-node-editor-dialog-meta">
1538
+ <span
1539
+ className="workflow-node-editor-dialog-icon"
1540
+ style={getWorkflowNodeIconStyle(nodeType)}
1541
+ >
1542
+ <WorkflowNodeTypeIcon nodeType={nodeType} size={15} />
1543
+ </span>
1544
+ <SolidTag>{nodeType.kind}</SolidTag>
1545
+ <SolidTag>{nodeType.type}</SolidTag>
1546
+ {nodeType.category ? <SolidTag>{nodeType.category}</SolidTag> : null}
1547
+ {nodeType.subcategory ? <SolidTag>{nodeType.subcategory}</SolidTag> : null}
1548
+ </div>
1549
+ );
1550
+ }
1551
+
1552
+ function WorkflowNodeCommonFields({
1553
+ nodeType,
1554
+ draft,
1555
+ readOnly,
1556
+ onChange,
1557
+ }: {
1558
+ nodeType: WorkflowNodeMetadataResponse;
1559
+ draft: WorkflowNodeEditorValue;
1560
+ readOnly?: boolean;
1561
+ onChange: (value: WorkflowNodeEditorValue) => void;
1562
+ }) {
1563
+ const authoring = nodeType.authoring;
1564
+ const update = (patch: Partial<WorkflowNodeEditorValue>) => {
1565
+ onChange({ ...draft, ...patch });
1566
+ };
1567
+
1568
+ return (
1569
+ <section className="workflow-node-editor-section">
1570
+ <div className="workflow-node-editor-form-grid">
1571
+ <div className="workflow-node-editor-field">
1572
+ <label className="workflow-node-editor-label">Id</label>
1573
+ <SolidInput
1574
+ value={draft.id ?? ""}
1575
+ disabled={readOnly}
1576
+ onChange={(event) => update({ id: event.target.value })}
1577
+ />
1578
+ </div>
1579
+ <div className="workflow-node-editor-field">
1580
+ <label className="workflow-node-editor-label">Type</label>
1581
+ <SolidInput value={draft.type ?? nodeType.type} disabled />
1582
+ </div>
1583
+
1584
+ {authoring?.supportsName !== false ? (
1585
+ <div className="workflow-node-editor-field">
1586
+ <label className="workflow-node-editor-label">Name</label>
1587
+ <SolidInput
1588
+ value={draft.name ?? ""}
1589
+ disabled={readOnly}
1590
+ onChange={(event) => update({ name: event.target.value })}
1591
+ />
1592
+ </div>
1593
+ ) : null}
1594
+
1595
+ <div className="workflow-node-editor-field">
1596
+ <label className="workflow-node-editor-label">Kind</label>
1597
+ <WorkflowNodeTags nodeType={nodeType} />
1598
+ </div>
1599
+
1600
+ {authoring?.supportsDescription ? (
1601
+ <div className="workflow-node-editor-field workflow-node-editor-field--wide">
1602
+ <label className="workflow-node-editor-label">Description</label>
1603
+ <SolidTextarea
1604
+ className="workflow-node-editor-description-input"
1605
+ value={draft.description ?? ""}
1606
+ disabled={readOnly}
1607
+ onChange={(event) => update({ description: event.target.value })}
1608
+ />
1609
+ </div>
1610
+ ) : null}
1611
+ </div>
1612
+ </section>
1613
+ );
1614
+ }
1615
+
1616
+ function WorkflowNodeRuntimeFields({
1617
+ nodeType,
1618
+ draft,
1619
+ readOnly,
1620
+ onChange,
1621
+ }: {
1622
+ nodeType: WorkflowNodeMetadataResponse;
1623
+ draft: WorkflowNodeEditorValue;
1624
+ readOnly?: boolean;
1625
+ onChange: (value: WorkflowNodeEditorValue) => void;
1626
+ }) {
1627
+ const authoring = nodeType.authoring;
1628
+
1629
+ if (!hasRuntimeFields(nodeType)) {
1630
+ return null;
1631
+ }
1632
+
1633
+ const update = (patch: Partial<WorkflowNodeEditorValue>) => {
1634
+ onChange({ ...draft, ...patch });
1635
+ };
1636
+
1637
+ return (
1638
+ <section className="workflow-node-editor-section">
1639
+ {authoring?.supportsDisableToggle ? (
1640
+ <div className="workflow-node-editor-toggle-row">
1641
+ <div>
1642
+ <div className="workflow-node-editor-toggle-title">Disabled</div>
1643
+ <div className="workflow-node-editor-description">
1644
+ Skip this node during execution.
1645
+ </div>
1646
+ </div>
1647
+ <SolidSwitch
1648
+ checked={!!draft.disabled}
1649
+ disabled={readOnly}
1650
+ onChange={(checked) => update({ disabled: checked || undefined })}
1651
+ />
1652
+ </div>
1653
+ ) : null}
1654
+
1655
+ <div className="workflow-node-editor-form-grid">
1656
+ {authoring?.supportsTimeoutMs ? (
1657
+ <div className="workflow-node-editor-field">
1658
+ <label className="workflow-node-editor-label">Timeout (ms)</label>
1659
+ <SolidNumberInput
1660
+ value={draft.timeoutMs}
1661
+ disabled={readOnly}
1662
+ onChange={(event) => update({ timeoutMs: event.value ?? undefined })}
1663
+ />
1664
+ </div>
1665
+ ) : null}
1666
+
1667
+ {authoring?.supportsOnError ? (
1668
+ <div className="workflow-node-editor-field">
1669
+ <label className="workflow-node-editor-label">On error</label>
1670
+ <SolidSelect
1671
+ value={draft.onError ?? "fail"}
1672
+ disabled={readOnly}
1673
+ options={[
1674
+ { label: "Fail workflow", value: "fail" },
1675
+ { label: "Continue", value: "continue" },
1676
+ ]}
1677
+ onChange={(event) => update({ onError: event.value })}
1678
+ />
1679
+ </div>
1680
+ ) : null}
1681
+
1682
+ {authoring?.supportsRetryPolicy ? (
1683
+ <>
1684
+ <div className="workflow-node-editor-field">
1685
+ <label className="workflow-node-editor-label">Max retries</label>
1686
+ <SolidNumberInput
1687
+ value={draft.retryPolicy?.maxRetries}
1688
+ disabled={readOnly}
1689
+ onChange={(event) =>
1690
+ update({
1691
+ retryPolicy: {
1692
+ ...(draft.retryPolicy ?? {}),
1693
+ maxRetries: event.value ?? undefined,
1694
+ },
1695
+ })
1696
+ }
1697
+ />
1698
+ </div>
1699
+ <div className="workflow-node-editor-field">
1700
+ <label className="workflow-node-editor-label">Retry delay (ms)</label>
1701
+ <SolidNumberInput
1702
+ value={draft.retryPolicy?.delayMs}
1703
+ disabled={readOnly}
1704
+ onChange={(event) =>
1705
+ update({
1706
+ retryPolicy: {
1707
+ ...(draft.retryPolicy ?? {}),
1708
+ delayMs: event.value ?? undefined,
1709
+ },
1710
+ })
1711
+ }
1712
+ />
1713
+ </div>
1714
+ </>
1715
+ ) : null}
1716
+ </div>
1717
+ </section>
1718
+ );
1719
+ }
1720
+
1721
+ function WorkflowNodeChildSlotsSummary({
1722
+ nodeType,
1723
+ draft,
1724
+ }: {
1725
+ nodeType: WorkflowNodeMetadataResponse;
1726
+ draft: WorkflowNodeEditorValue;
1727
+ }) {
1728
+ const childSlots = nodeType.authoring?.childSlots ?? [];
1729
+ if (!childSlots.length) {
1730
+ return null;
1731
+ }
1732
+
1733
+ return (
1734
+ <section className="workflow-node-editor-section">
1735
+ <div className="workflow-node-editor-slot-list">
1736
+ {childSlots.map((slot) => (
1737
+ <div key={slot.key} className="workflow-node-editor-slot-row">
1738
+ <div className="workflow-node-editor-slot-copy">
1739
+ <div className="workflow-node-editor-slot-title">{slot.label ?? slot.key}</div>
1740
+ <div className="workflow-node-editor-description">
1741
+ {slot.description ??
1742
+ "Use the topology canvas to add, reorder, or remove child nodes."}
1743
+ </div>
1744
+ </div>
1745
+ <SolidTag>{getSlotCount(draft, slot)}</SolidTag>
1746
+ </div>
1747
+ ))}
1748
+ </div>
1749
+ <div className="workflow-node-editor-note">
1750
+ Child node membership is edited from the topology canvas. This dialog edits the
1751
+ control node itself.
1752
+ </div>
1753
+ </section>
1754
+ );
1755
+ }
1756
+
1757
+ function WorkflowNodeFullEditor({
1758
+ nodeType,
1759
+ value,
1760
+ onChange,
1761
+ expressionSuggestions,
1762
+ readOnly,
1763
+ }: {
1764
+ nodeType: WorkflowNodeMetadataResponse;
1765
+ value: WorkflowNodeEditorValue;
1766
+ onChange: (value: WorkflowNodeEditorValue) => void;
1767
+ expressionSuggestions?: WorkflowExpressionSuggestion[];
1768
+ readOnly?: boolean;
1769
+ }) {
1770
+ const configuration = value.configuration ?? {};
1771
+ const [activeTab, setActiveTab] = React.useState("basic");
1772
+ const hasConfiguration = Boolean(nodeType.authoring?.configurationFields?.length);
1773
+ const childSlots = nodeType.authoring?.childSlots ?? [];
1774
+
1775
+ const tabs = [
1776
+ {
1777
+ value: "basic",
1778
+ label: "Basic Info",
1779
+ content: (
1780
+ <WorkflowNodeCommonFields
1781
+ nodeType={nodeType}
1782
+ draft={value}
1783
+ readOnly={readOnly}
1784
+ onChange={onChange}
1785
+ />
1786
+ ),
1787
+ },
1788
+ hasConfiguration
1789
+ ? {
1790
+ value: "configuration",
1791
+ label: "Configuration",
1792
+ content: (
1793
+ <WorkflowNodeSchemaEditor
1794
+ nodeType={nodeType}
1795
+ value={configuration}
1796
+ expressionSuggestions={expressionSuggestions}
1797
+ readOnly={readOnly}
1798
+ onChange={(nextConfiguration) =>
1799
+ onChange({
1800
+ ...value,
1801
+ configuration: nextConfiguration,
1802
+ })
1803
+ }
1804
+ />
1805
+ ),
1806
+ }
1807
+ : null,
1808
+ hasRuntimeFields(nodeType)
1809
+ ? {
1810
+ value: "runtime",
1811
+ label: "Runtime",
1812
+ content: (
1813
+ <WorkflowNodeRuntimeFields
1814
+ nodeType={nodeType}
1815
+ draft={value}
1816
+ readOnly={readOnly}
1817
+ onChange={onChange}
1818
+ />
1819
+ ),
1820
+ }
1821
+ : null,
1822
+ childSlots.length
1823
+ ? {
1824
+ value: "topology",
1825
+ label: "Topology",
1826
+ content: <WorkflowNodeChildSlotsSummary nodeType={nodeType} draft={value} />,
1827
+ }
1828
+ : null,
1829
+ ].filter(Boolean) as Array<{ value: string; label: string; content: React.ReactNode }>;
1830
+
1831
+ React.useEffect(() => {
1832
+ if (!tabs.some((tab) => tab.value === activeTab)) {
1833
+ setActiveTab(tabs[0]?.value ?? "basic");
1834
+ }
1835
+ }, [activeTab, tabs]);
1836
+
1837
+ return (
1838
+ <SolidTabGroup
1839
+ tabs={tabs}
1840
+ value={activeTab}
1841
+ onValueChange={setActiveTab}
1842
+ className="workflow-node-editor-tabs"
1843
+ panelClassName="workflow-node-editor-tab-panel"
1844
+ />
1845
+ );
1846
+ }
1847
+
1848
+ export function WorkflowNodeEditorDialog({
1849
+ open,
1850
+ onOpenChange,
1851
+ title,
1852
+ nodeType,
1853
+ value,
1854
+ onChange,
1855
+ onSubmit,
1856
+ expressionSuggestions,
1857
+ readOnly,
1858
+ nodeValue,
1859
+ onNodeChange,
1860
+ onNodeSubmit,
1861
+ }: WorkflowNodeEditorDialogProps) {
1862
+ const [draft, setDraft] = React.useState<Record<string, any>>(
1863
+ value ?? nodeValue?.configuration ?? nodeType.authoring?.defaultConfiguration ?? {},
1864
+ );
1865
+ const [nodeDraft, setNodeDraft] = React.useState<WorkflowNodeEditorValue>(
1866
+ nodeValue ?? {
1867
+ id: "",
1868
+ type: nodeType.type,
1869
+ kind: nodeType.kind,
1870
+ configuration: value ?? nodeType.authoring?.defaultConfiguration ?? {},
1871
+ },
1872
+ );
1873
+
1874
+ React.useEffect(() => {
1875
+ setDraft(value ?? nodeValue?.configuration ?? nodeType.authoring?.defaultConfiguration ?? {});
1876
+ setNodeDraft(
1877
+ nodeValue ?? {
1878
+ id: "",
1879
+ type: nodeType.type,
1880
+ kind: nodeType.kind,
1881
+ configuration: value ?? nodeType.authoring?.defaultConfiguration ?? {},
1882
+ },
1883
+ );
1884
+ }, [nodeType, nodeValue, value, open]);
1885
+
1886
+ const editorComponentKey = nodeType.ui?.editorComponentKey;
1887
+ const CustomEditor = editorComponentKey ? getExtensionComponent(editorComponentKey) : null;
1888
+ const useCustomEditor = !!CustomEditor && nodeType.ui?.defaultEditorMode === "custom";
1889
+ const isFullNodeMode = !!nodeValue || !!onNodeSubmit || !!onNodeChange;
1890
+ const dialogTitle = title ?? nodeType.label ?? nodeType.type;
1891
+ const dialogSubtitle = isFullNodeMode
1892
+ ? "Review the node details and configuration for this workflow step."
1893
+ : "Review the configuration fields for this workflow node.";
1894
+
1895
+ const handleNodeChange = (nextValue: WorkflowNodeEditorValue) => {
1896
+ setNodeDraft(nextValue);
1897
+ setDraft(nextValue.configuration ?? {});
1898
+ onNodeChange?.(nextValue);
1899
+ };
1900
+
1901
+ return (
1902
+ <SolidDialog
1903
+ open={open}
1904
+ onOpenChange={onOpenChange}
1905
+ header={
1906
+ <div className="workflow-node-editor-dialog-heading">
1907
+ <div className="workflow-node-editor-dialog-title">{dialogTitle}</div>
1908
+ <div className="workflow-node-editor-dialog-subtitle">{dialogSubtitle}</div>
1909
+ <WorkflowNodeHeaderMeta nodeType={nodeType} />
1910
+ </div>
1911
+ }
1912
+ className={`solid-workflow-node-editor-dialog solid-workflow-node-editor-dialog--${nodeType.ui?.modalSize ?? "lg"}`}
1913
+ style={getWorkflowNodeEditorDialogStyle(nodeType)}
1914
+ >
1915
+ <SolidDialogBody className="workflow-node-editor-dialog-body">
1916
+ {useCustomEditor ? (
1917
+ <CustomEditor
1918
+ nodeType={nodeType}
1919
+ value={isFullNodeMode ? nodeDraft : draft}
1920
+ nodeValue={nodeDraft}
1921
+ configuration={draft}
1922
+ onChange={isFullNodeMode ? handleNodeChange : setDraft}
1923
+ readOnly={readOnly}
1924
+ />
1925
+ ) : isFullNodeMode ? (
1926
+ <WorkflowNodeFullEditor
1927
+ nodeType={nodeType}
1928
+ value={nodeDraft}
1929
+ onChange={handleNodeChange}
1930
+ expressionSuggestions={expressionSuggestions}
1931
+ readOnly={readOnly}
1932
+ />
1933
+ ) : (
1934
+ <WorkflowNodeSchemaEditor
1935
+ className="workflow-node-editor-standalone-config"
1936
+ nodeType={nodeType}
1937
+ value={draft}
1938
+ expressionSuggestions={expressionSuggestions}
1939
+ onChange={(nextValue) => {
1940
+ setDraft(nextValue);
1941
+ onChange?.(nextValue);
1942
+ }}
1943
+ onSubmit={(nextValue) => {
1944
+ setDraft(nextValue);
1945
+ onSubmit?.(nextValue);
1946
+ }}
1947
+ readOnly={readOnly}
1948
+ />
1949
+ )}
1950
+ </SolidDialogBody>
1951
+ {!readOnly && (onSubmit || onNodeSubmit) ? (
1952
+ <SolidDialogFooter className="workflow-node-editor-dialog-footer">
1953
+ <SolidButton variant="secondary" onClick={() => onOpenChange(false)}>
1954
+ Cancel
1955
+ </SolidButton>
1956
+ <SolidButton
1957
+ onClick={() => {
1958
+ if (isFullNodeMode) {
1959
+ onNodeSubmit?.(nodeDraft);
1960
+ } else {
1961
+ onSubmit?.(draft);
1962
+ }
1963
+ }}
1964
+ >
1965
+ Save
1966
+ </SolidButton>
1967
+ </SolidDialogFooter>
1968
+ ) : null}
1969
+ </SolidDialog>
1970
+ );
1971
+ }
1972
+
1973
+ export function WorkflowAddNodeDialog({
1974
+ open,
1975
+ nodeTypes,
1976
+ onOpenChange,
1977
+ createNodeValue,
1978
+ onSubmit,
1979
+ }: WorkflowAddNodeDialogProps) {
1980
+ const [step, setStep] = React.useState<"select" | "configure">("select");
1981
+ const [query, setQuery] = React.useState("");
1982
+ const [categoryFilter, setCategoryFilter] = React.useState("");
1983
+ const [subcategoryFilter, setSubcategoryFilter] = React.useState("");
1984
+ const [kindFilter, setKindFilter] = React.useState("");
1985
+ const [filtersOpen, setFiltersOpen] = React.useState(false);
1986
+ const [selectedType, setSelectedType] = React.useState("");
1987
+ const [nodeDraft, setNodeDraft] = React.useState<WorkflowNodeEditorValue | null>(null);
1988
+
1989
+ React.useEffect(() => {
1990
+ if (!open) {
1991
+ setStep("select");
1992
+ setQuery("");
1993
+ setCategoryFilter("");
1994
+ setSubcategoryFilter("");
1995
+ setKindFilter("");
1996
+ setFiltersOpen(false);
1997
+ setSelectedType("");
1998
+ setNodeDraft(null);
1999
+ }
2000
+ }, [open]);
2001
+
2002
+ const selectedNodeType = React.useMemo(
2003
+ () => nodeTypes.find((nodeType) => nodeType.type === selectedType),
2004
+ [nodeTypes, selectedType],
2005
+ );
2006
+
2007
+ const categoryOptions = React.useMemo(
2008
+ () =>
2009
+ createSelectOptions(
2010
+ Array.from(
2011
+ new Set(nodeTypes.map((nodeType) => nodeType.category ?? "").filter(Boolean)),
2012
+ ),
2013
+ "All categories",
2014
+ ),
2015
+ [nodeTypes],
2016
+ );
2017
+
2018
+ const subcategoryOptions = React.useMemo(() => {
2019
+ const source = categoryFilter
2020
+ ? nodeTypes.filter((nodeType) => nodeType.category === categoryFilter)
2021
+ : nodeTypes;
2022
+ return createSelectOptions(
2023
+ Array.from(
2024
+ new Set(source.map((nodeType) => nodeType.subcategory ?? "").filter(Boolean)),
2025
+ ),
2026
+ "All subcategories",
2027
+ );
2028
+ }, [categoryFilter, nodeTypes]);
2029
+
2030
+ const kindOptions = React.useMemo(
2031
+ () =>
2032
+ createSelectOptions(
2033
+ Array.from(new Set(nodeTypes.map((nodeType) => nodeType.kind).filter(Boolean))),
2034
+ "All kinds",
2035
+ ),
2036
+ [nodeTypes],
2037
+ );
2038
+
2039
+ React.useEffect(() => {
2040
+ if (
2041
+ subcategoryFilter &&
2042
+ !subcategoryOptions.some((option) => option.value === subcategoryFilter)
2043
+ ) {
2044
+ setSubcategoryFilter("");
2045
+ }
2046
+ }, [subcategoryFilter, subcategoryOptions]);
2047
+
2048
+ const filteredNodeTypes = React.useMemo(() => {
2049
+ const normalizedQuery = query.trim().toLowerCase();
2050
+ return nodeTypes.filter((nodeType) => {
2051
+ if (categoryFilter && nodeType.category !== categoryFilter) {
2052
+ return false;
2053
+ }
2054
+ if (subcategoryFilter && nodeType.subcategory !== subcategoryFilter) {
2055
+ return false;
2056
+ }
2057
+ if (kindFilter && nodeType.kind !== kindFilter) {
2058
+ return false;
2059
+ }
2060
+ if (!normalizedQuery) {
2061
+ return true;
2062
+ }
2063
+ return getNodeTypeSearchText(nodeType).includes(normalizedQuery);
2064
+ });
2065
+ }, [
2066
+ categoryFilter,
2067
+ kindFilter,
2068
+ nodeTypes,
2069
+ query,
2070
+ subcategoryFilter,
2071
+ ]);
2072
+
2073
+ const groupedNodeTypes = React.useMemo(() => {
2074
+ const grouped = new Map<
2075
+ string,
2076
+ Map<string, WorkflowNodeMetadataResponse[]>
2077
+ >();
2078
+
2079
+ filteredNodeTypes.forEach((nodeType) => {
2080
+ const category = normalizeGroupLabel(nodeType.category, "Uncategorized");
2081
+ const subcategory = normalizeGroupLabel(nodeType.subcategory, "General");
2082
+ const categoryGroup = grouped.get(category) ?? new Map();
2083
+ const subcategoryGroup = categoryGroup.get(subcategory) ?? [];
2084
+ subcategoryGroup.push(nodeType);
2085
+ categoryGroup.set(subcategory, subcategoryGroup);
2086
+ grouped.set(category, categoryGroup);
2087
+ });
2088
+
2089
+ return Array.from(grouped.entries())
2090
+ .sort(([left], [right]) => left.localeCompare(right))
2091
+ .map(([category, subcategories]) => ({
2092
+ category,
2093
+ subcategories: Array.from(subcategories.entries())
2094
+ .sort(([left], [right]) => left.localeCompare(right))
2095
+ .map(([subcategory, nodes]) => ({
2096
+ subcategory,
2097
+ nodes: nodes.sort((left, right) =>
2098
+ (left.label ?? left.type).localeCompare(right.label ?? right.type),
2099
+ ),
2100
+ })),
2101
+ }));
2102
+ }, [filteredNodeTypes]);
2103
+
2104
+ const goToConfigureStep = (nodeType = selectedNodeType) => {
2105
+ if (!nodeType) {
2106
+ return;
2107
+ }
2108
+
2109
+ setSelectedType(nodeType.type);
2110
+ setNodeDraft(createNodeValue(nodeType));
2111
+ setStep("configure");
2112
+ };
2113
+
2114
+ const handleSubmit = () => {
2115
+ if (!nodeDraft) {
2116
+ return;
2117
+ }
2118
+
2119
+ onSubmit(nodeDraft);
2120
+ onOpenChange(false);
2121
+ };
2122
+
2123
+ const header = (
2124
+ <div className="workflow-node-editor-dialog-heading">
2125
+ <div className="workflow-node-editor-dialog-title">
2126
+ {step === "select" ? "Add Node" : `Configure ${selectedNodeType?.label ?? selectedNodeType?.type ?? "Node"}`}
2127
+ </div>
2128
+ <div className="workflow-node-editor-dialog-subtitle">
2129
+ {step === "select"
2130
+ ? "Choose the workflow node type to insert at this point in the flow."
2131
+ : "Review the node details and configuration before adding it to the workflow."}
2132
+ </div>
2133
+ {selectedNodeType ? <WorkflowNodeHeaderMeta nodeType={selectedNodeType} /> : null}
2134
+ </div>
2135
+ );
2136
+
2137
+ return (
2138
+ <SolidDialog
2139
+ open={open}
2140
+ onOpenChange={onOpenChange}
2141
+ header={header}
2142
+ className="solid-workflow-node-editor-dialog solid-workflow-add-node-dialog"
2143
+ style={{ width: "min(1040px, 94vw)", maxWidth: "96vw" }}
2144
+ >
2145
+ <SolidDialogBody className="workflow-node-editor-dialog-body workflow-add-node-dialog-body">
2146
+ {step === "select" ? (
2147
+ <div className="workflow-add-node-picker">
2148
+ <div className="workflow-add-node-search-row">
2149
+ <div className="workflow-add-node-search">
2150
+ <Search size={15} />
2151
+ <SolidInput
2152
+ value={query}
2153
+ onChange={(event) => setQuery(event.target.value)}
2154
+ placeholder="Search node types"
2155
+ />
2156
+ <button
2157
+ type="button"
2158
+ className={`workflow-add-node-search-action ${filtersOpen ? "is-active" : ""}`}
2159
+ aria-label={filtersOpen ? "Hide filters" : "Show filters"}
2160
+ title={filtersOpen ? "Hide filters" : "Show filters"}
2161
+ onClick={() => setFiltersOpen((current) => !current)}
2162
+ >
2163
+ <Filter size={14} />
2164
+ </button>
2165
+ <button
2166
+ type="button"
2167
+ className="workflow-add-node-search-action"
2168
+ aria-label="Clear search"
2169
+ title="Clear search"
2170
+ disabled={!query}
2171
+ onClick={() => setQuery("")}
2172
+ >
2173
+ <X size={14} />
2174
+ </button>
2175
+ </div>
2176
+ {filtersOpen ? (
2177
+ <div className="workflow-add-node-filters">
2178
+ <SolidSelect
2179
+ value={categoryFilter}
2180
+ options={categoryOptions}
2181
+ onChange={(event) => setCategoryFilter(event.value ?? "")}
2182
+ />
2183
+ <SolidSelect
2184
+ value={subcategoryFilter}
2185
+ options={subcategoryOptions}
2186
+ onChange={(event) => setSubcategoryFilter(event.value ?? "")}
2187
+ />
2188
+ <SolidSelect
2189
+ value={kindFilter}
2190
+ options={kindOptions}
2191
+ onChange={(event) => setKindFilter(event.value ?? "")}
2192
+ />
2193
+ </div>
2194
+ ) : null}
2195
+ </div>
2196
+
2197
+ <div className="workflow-add-node-results">
2198
+ {groupedNodeTypes.length ? (
2199
+ groupedNodeTypes.map((categoryGroup) => (
2200
+ <section
2201
+ key={categoryGroup.category}
2202
+ className="workflow-add-node-category"
2203
+ >
2204
+ <div className="workflow-add-node-category-title">
2205
+ {categoryGroup.category}
2206
+ </div>
2207
+ <div className="workflow-add-node-subcategory-list">
2208
+ {categoryGroup.subcategories.map((subcategoryGroup) => (
2209
+ <div
2210
+ key={`${categoryGroup.category}-${subcategoryGroup.subcategory}`}
2211
+ className="workflow-add-node-subcategory"
2212
+ >
2213
+ <div className="workflow-add-node-subcategory-title">
2214
+ {subcategoryGroup.subcategory}
2215
+ </div>
2216
+ <div className="workflow-add-node-grid">
2217
+ {subcategoryGroup.nodes.map((nodeType) => (
2218
+ <button
2219
+ key={nodeType.type}
2220
+ type="button"
2221
+ className={`workflow-add-node-card ${selectedType === nodeType.type ? "is-active" : ""}`}
2222
+ onClick={() => goToConfigureStep(nodeType)}
2223
+ >
2224
+ <span
2225
+ className={`workflow-add-node-card-icon workflow-add-node-card-icon--${nodeType.kind}`}
2226
+ style={getWorkflowNodeIconStyle(nodeType)}
2227
+ >
2228
+ <WorkflowNodeTypeIcon nodeType={nodeType} />
2229
+ </span>
2230
+ <span className="workflow-add-node-card-copy">
2231
+ <span className="workflow-add-node-card-title">
2232
+ {nodeType.label ?? nodeType.type}
2233
+ </span>
2234
+ <span className="workflow-add-node-card-description">
2235
+ {nodeType.description ?? nodeType.type}
2236
+ </span>
2237
+ </span>
2238
+ </button>
2239
+ ))}
2240
+ </div>
2241
+ </div>
2242
+ ))}
2243
+ </div>
2244
+ </section>
2245
+ ))
2246
+ ) : (
2247
+ <div className="workflow-node-editor-empty">
2248
+ No node types match the current search and filters.
2249
+ </div>
2250
+ )}
2251
+ </div>
2252
+ </div>
2253
+ ) : selectedNodeType && nodeDraft ? (
2254
+ <WorkflowNodeFullEditor
2255
+ nodeType={selectedNodeType}
2256
+ value={nodeDraft}
2257
+ onChange={setNodeDraft}
2258
+ />
2259
+ ) : null}
2260
+ </SolidDialogBody>
2261
+ <SolidDialogFooter className="workflow-node-editor-dialog-footer">
2262
+ {step === "select" ? (
2263
+ <SolidButton variant="secondary" onClick={() => onOpenChange(false)}>
2264
+ Cancel
2265
+ </SolidButton>
2266
+ ) : (
2267
+ <>
2268
+ <SolidButton
2269
+ variant="secondary"
2270
+ leftIcon={<ArrowLeft size={14} />}
2271
+ onClick={() => setStep("select")}
2272
+ >
2273
+ Back
2274
+ </SolidButton>
2275
+ <SolidButton onClick={handleSubmit}>Add Node</SolidButton>
2276
+ </>
2277
+ )}
2278
+ </SolidDialogFooter>
2279
+ </SolidDialog>
2280
+ );
2281
+ }
2282
+
2283
+ export function WorkflowNodePalette({
2284
+ nodeTypes,
2285
+ value,
2286
+ onSelect,
2287
+ className,
2288
+ }: WorkflowNodePaletteProps) {
2289
+ const [query, setQuery] = React.useState("");
2290
+
2291
+ const filteredNodeTypes = nodeTypes.filter((nodeType) => {
2292
+ const haystack = [
2293
+ nodeType.type,
2294
+ nodeType.label,
2295
+ nodeType.description,
2296
+ nodeType.category,
2297
+ nodeType.subcategory,
2298
+ ...(nodeType.tags ?? []),
2299
+ ...(nodeType.authoring?.searchableText ?? []),
2300
+ ]
2301
+ .filter(Boolean)
2302
+ .join(" ")
2303
+ .toLowerCase();
2304
+
2305
+ return haystack.includes(query.trim().toLowerCase());
2306
+ });
2307
+
2308
+ return (
2309
+ <div className={className} style={{ display: "grid", gap: "1rem" }}>
2310
+ <SolidInput
2311
+ value={query}
2312
+ onChange={(event) => setQuery(event.target.value)}
2313
+ placeholder="Search node types"
2314
+ />
2315
+ <div style={{ display: "grid", gap: "0.75rem" }}>
2316
+ {filteredNodeTypes.map((nodeType) => (
2317
+ <button
2318
+ key={nodeType.type}
2319
+ type="button"
2320
+ onClick={() => onSelect?.(nodeType)}
2321
+ style={{
2322
+ textAlign: "left",
2323
+ border: value === nodeType.type
2324
+ ? "1px solid var(--primary-color, #2563eb)"
2325
+ : "1px solid var(--surface-border, #e5e7eb)",
2326
+ borderRadius: "0.75rem",
2327
+ padding: "0.9rem 1rem",
2328
+ background: "var(--surface-card, #fff)",
2329
+ display: "grid",
2330
+ gap: "0.5rem",
2331
+ cursor: "pointer",
2332
+ }}
2333
+ >
2334
+ <div style={{ display: "flex", gap: "0.5rem", alignItems: "center", flexWrap: "wrap" }}>
2335
+ <strong>{nodeType.label ?? nodeType.type}</strong>
2336
+ {nodeType.category ? <SolidTag>{nodeType.category}</SolidTag> : null}
2337
+ <SolidTag>{nodeType.kind}</SolidTag>
2338
+ </div>
2339
+ {nodeType.description ? (
2340
+ <div style={{ opacity: 0.8 }}>{nodeType.description}</div>
2341
+ ) : null}
2342
+ </button>
2343
+ ))}
2344
+ </div>
2345
+ </div>
2346
+ );
2347
+ }