@uipath/apollo-react 6.79.0 → 7.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 (52) hide show
  1. package/dist/canvas/components/Guardrails/guardrail-builder.cjs +5 -5
  2. package/dist/canvas/components/Guardrails/guardrail-builder.d.ts.map +1 -1
  3. package/dist/canvas/components/Guardrails/guardrail-builder.js +6 -6
  4. package/dist/canvas/components/Guardrails/index.cjs +7 -7
  5. package/dist/canvas/components/Guardrails/index.d.ts +2 -2
  6. package/dist/canvas/components/Guardrails/index.d.ts.map +1 -1
  7. package/dist/canvas/components/Guardrails/index.js +2 -2
  8. package/dist/canvas/components/Guardrails/types.d.ts +1 -1
  9. package/dist/canvas/components/Guardrails/types.d.ts.map +1 -1
  10. package/dist/canvas/components/Guardrails/utils.cjs +9 -9
  11. package/dist/canvas/components/Guardrails/utils.d.ts +3 -3
  12. package/dist/canvas/components/Guardrails/utils.d.ts.map +1 -1
  13. package/dist/canvas/components/Guardrails/utils.js +4 -4
  14. package/dist/canvas/components/JsonTree/index.cjs +4 -0
  15. package/dist/canvas/components/JsonTree/index.d.ts +1 -1
  16. package/dist/canvas/components/JsonTree/index.d.ts.map +1 -1
  17. package/dist/canvas/components/JsonTree/index.js +2 -2
  18. package/dist/canvas/components/NodeIOView/NodeIOView.cjs +10 -12
  19. package/dist/canvas/components/NodeIOView/NodeIOView.d.ts +1 -1
  20. package/dist/canvas/components/NodeIOView/NodeIOView.d.ts.map +1 -1
  21. package/dist/canvas/components/NodeIOView/NodeIOView.js +12 -14
  22. package/dist/canvas/components/NodeIOView/NodeIOView.types.d.ts +2 -0
  23. package/dist/canvas/components/NodeIOView/NodeIOView.types.d.ts.map +1 -1
  24. package/dist/canvas/components/NodePropertyPanel/NodePropertyPanel.cjs +6 -6
  25. package/dist/canvas/components/NodePropertyPanel/NodePropertyPanel.d.ts.map +1 -1
  26. package/dist/canvas/components/NodePropertyPanel/NodePropertyPanel.js +6 -6
  27. package/dist/canvas/components/NodeVariablesPanel/NodeVariableEditDialog.cjs +405 -0
  28. package/dist/canvas/components/NodeVariablesPanel/NodeVariableEditDialog.d.ts +10 -0
  29. package/dist/canvas/components/NodeVariablesPanel/NodeVariableEditDialog.d.ts.map +1 -0
  30. package/dist/canvas/components/NodeVariablesPanel/NodeVariableEditDialog.js +371 -0
  31. package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.cjs +726 -0
  32. package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.d.ts +3 -0
  33. package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.d.ts.map +1 -0
  34. package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.js +692 -0
  35. package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.types.cjs +18 -0
  36. package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.types.d.ts +65 -0
  37. package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.types.d.ts.map +1 -0
  38. package/dist/canvas/components/NodeVariablesPanel/NodeVariablesPanel.types.js +0 -0
  39. package/dist/canvas/components/NodeVariablesPanel/index.cjs +36 -0
  40. package/dist/canvas/components/NodeVariablesPanel/index.d.ts +3 -0
  41. package/dist/canvas/components/NodeVariablesPanel/index.d.ts.map +1 -0
  42. package/dist/canvas/components/NodeVariablesPanel/index.js +2 -0
  43. package/dist/canvas/components/index.cjs +23 -16
  44. package/dist/canvas/components/index.d.ts +1 -0
  45. package/dist/canvas/components/index.d.ts.map +1 -1
  46. package/dist/canvas/components/index.js +1 -0
  47. package/dist/canvas/locales/en.cjs +1 -1
  48. package/dist/canvas/locales/en.d.ts.map +1 -1
  49. package/dist/canvas/locales/en.js +1 -1
  50. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  51. package/dist/chat/styles/tailwind.chat.css +1 -1
  52. package/package.json +3 -3
@@ -0,0 +1,371 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Button, Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, FormField, FormFieldDescription, FormFieldLabel, Input, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Textarea } from "@uipath/apollo-wind";
3
+ import { Database, Pencil } from "lucide-react";
4
+ import { useId, useRef, useState } from "react";
5
+ import { useSafeLingui } from "../../../i18n/index.js";
6
+ const VARIABLE_TYPES = [
7
+ 'string',
8
+ 'number',
9
+ 'boolean',
10
+ 'object',
11
+ 'array'
12
+ ];
13
+ const IDENTIFIER_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
14
+ function draftFor(type, value) {
15
+ if (null == value) return '';
16
+ if ('object' === type || 'array' === type) return JSON.stringify(value, null, 2);
17
+ return String(value);
18
+ }
19
+ function parseDefault(type, draft, checked) {
20
+ if ('boolean' === type) return {
21
+ value: checked
22
+ };
23
+ const text = draft.trim();
24
+ if (!text) return {
25
+ value: void 0
26
+ };
27
+ if ('string' === type) return {
28
+ value: draft
29
+ };
30
+ if ('number' === type) {
31
+ const value = Number(text);
32
+ return Number.isFinite(value) ? {
33
+ value
34
+ } : {
35
+ error: true
36
+ };
37
+ }
38
+ try {
39
+ const value = JSON.parse(text);
40
+ const isArray = Array.isArray(value);
41
+ const isObject = 'object' == typeof value && null !== value && !isArray;
42
+ return ('array' === type ? isArray : isObject) ? {
43
+ value
44
+ } : {
45
+ error: true
46
+ };
47
+ } catch {
48
+ return {
49
+ error: true
50
+ };
51
+ }
52
+ }
53
+ function NodeVariableEditDialog({ variable, takenNames, referenceFor, onSave, onClose }) {
54
+ const { _ } = useSafeLingui();
55
+ const fieldId = useId();
56
+ const idInputRef = useRef(null);
57
+ const [id, setId] = useState(variable.id);
58
+ const [editingId, setEditingId] = useState(()=>!IDENTIFIER_PATTERN.test(variable.id));
59
+ const [type, setType] = useState(variable.type);
60
+ const [description, setDescription] = useState(variable.description ?? '');
61
+ const [draft, setDraftState] = useState(()=>draftFor(variable.type, variable.defaultValue));
62
+ const [checked, setCheckedState] = useState('boolean' == typeof variable.defaultValue ? variable.defaultValue : void 0);
63
+ const [defaultEdited, setDefaultEdited] = useState(false);
64
+ const setDraft = (next)=>{
65
+ setDraftState(next);
66
+ setDefaultEdited(true);
67
+ };
68
+ const setChecked = (next)=>{
69
+ setCheckedState(next);
70
+ setDefaultEdited(true);
71
+ };
72
+ const nullPlaceholder = null !== variable.defaultValue || defaultEdited ? void 0 : 'null';
73
+ const trimmedId = id.trim();
74
+ const idError = IDENTIFIER_PATTERN.test(trimmedId) ? trimmedId !== variable.id && takenNames.has(trimmedId) ? _({
75
+ id: 'canvas.node_variables_panel.edit_id_taken_error',
76
+ message: 'A variable named {name} already exists.',
77
+ values: {
78
+ name: trimmedId
79
+ }
80
+ }) : void 0 : _({
81
+ id: 'canvas.node_variables_panel.edit_id_pattern_error',
82
+ message: 'Use a letter or underscore first, then letters, numbers, or underscores.'
83
+ });
84
+ const parsed = parseDefault(type, draft, checked);
85
+ const defaultError = 'error' in parsed ? ({
86
+ number: _({
87
+ id: 'canvas.node_variables_panel.edit_default_number_error',
88
+ message: 'Enter a number.'
89
+ }),
90
+ object: _({
91
+ id: 'canvas.node_variables_panel.edit_default_object_error',
92
+ message: 'Enter a valid JSON object.'
93
+ }),
94
+ array: _({
95
+ id: 'canvas.node_variables_panel.edit_default_array_error',
96
+ message: 'Enter a valid JSON array.'
97
+ })
98
+ })[type] : void 0;
99
+ const changeType = (next)=>{
100
+ setType(next);
101
+ setDraft('');
102
+ setChecked(void 0);
103
+ };
104
+ const submit = (event)=>{
105
+ event.preventDefault();
106
+ if (idError || 'error' in parsed) return;
107
+ const untouched = !defaultEdited;
108
+ onSave({
109
+ id: trimmedId,
110
+ type,
111
+ description: description.trim() || void 0,
112
+ defaultValue: untouched ? variable.defaultValue : parsed.value
113
+ });
114
+ };
115
+ const typeLabel = {
116
+ string: _({
117
+ id: 'canvas.node_variables_panel.type_string',
118
+ message: 'String'
119
+ }),
120
+ number: _({
121
+ id: 'canvas.node_variables_panel.type_number',
122
+ message: 'Number'
123
+ }),
124
+ boolean: _({
125
+ id: 'canvas.node_variables_panel.type_boolean',
126
+ message: 'Boolean'
127
+ }),
128
+ object: _({
129
+ id: 'canvas.node_variables_panel.type_object',
130
+ message: 'Object'
131
+ }),
132
+ array: _({
133
+ id: 'canvas.node_variables_panel.type_array',
134
+ message: 'Array'
135
+ })
136
+ };
137
+ const defaultLabel = _({
138
+ id: 'canvas.node_variables_panel.edit_default_label',
139
+ message: 'Default value'
140
+ });
141
+ const reference = referenceFor(IDENTIFIER_PATTERN.test(trimmedId) ? trimmedId : variable.id);
142
+ return /*#__PURE__*/ jsx(Dialog, {
143
+ open: true,
144
+ onOpenChange: (open)=>!open && onClose(),
145
+ children: /*#__PURE__*/ jsx(DialogContent, {
146
+ "aria-describedby": void 0,
147
+ onKeyDown: (event)=>event.stopPropagation(),
148
+ children: /*#__PURE__*/ jsxs("form", {
149
+ onSubmit: submit,
150
+ noValidate: true,
151
+ className: "grid gap-4",
152
+ children: [
153
+ /*#__PURE__*/ jsx(DialogHeader, {
154
+ children: /*#__PURE__*/ jsxs(DialogTitle, {
155
+ className: "flex items-center gap-2",
156
+ children: [
157
+ /*#__PURE__*/ jsx(Database, {
158
+ size: 16,
159
+ "aria-hidden": "true",
160
+ className: "text-foreground-muted"
161
+ }),
162
+ _({
163
+ id: 'canvas.node_variables_panel.edit_title',
164
+ message: 'Edit variable'
165
+ })
166
+ ]
167
+ })
168
+ }),
169
+ /*#__PURE__*/ jsxs(FormField, {
170
+ children: [
171
+ /*#__PURE__*/ jsx(FormFieldLabel, {
172
+ htmlFor: `${fieldId}-id`,
173
+ children: _({
174
+ id: 'canvas.node_variables_panel.edit_id_label',
175
+ message: 'ID'
176
+ })
177
+ }),
178
+ /*#__PURE__*/ jsxs("div", {
179
+ className: "flex items-start gap-2",
180
+ children: [
181
+ /*#__PURE__*/ jsx(Input, {
182
+ ref: idInputRef,
183
+ id: `${fieldId}-id`,
184
+ value: id,
185
+ disabled: !editingId,
186
+ onChange: (event)=>setId(event.target.value),
187
+ error: editingId ? idError : void 0,
188
+ "aria-describedby": `${fieldId}-id-hint`,
189
+ autoComplete: "off",
190
+ spellCheck: false,
191
+ className: "flex-1 font-mono"
192
+ }),
193
+ !editingId && /*#__PURE__*/ jsx(Button, {
194
+ type: "button",
195
+ variant: "outline",
196
+ size: "icon",
197
+ "aria-label": _({
198
+ id: 'canvas.node_variables_panel.edit_id_action',
199
+ message: 'Edit ID'
200
+ }),
201
+ onClick: ()=>{
202
+ setEditingId(true);
203
+ requestAnimationFrame(()=>idInputRef.current?.select());
204
+ },
205
+ className: "shrink-0",
206
+ children: /*#__PURE__*/ jsx(Pencil, {})
207
+ })
208
+ ]
209
+ }),
210
+ /*#__PURE__*/ jsxs(FormFieldDescription, {
211
+ id: `${fieldId}-id-hint`,
212
+ children: [
213
+ _({
214
+ id: 'canvas.node_variables_panel.edit_id_hint',
215
+ message: 'Used in expressions as'
216
+ }),
217
+ ' ',
218
+ /*#__PURE__*/ jsx("code", {
219
+ className: "break-all rounded bg-surface-overlay px-1 py-0.5 font-mono text-xs",
220
+ children: reference
221
+ })
222
+ ]
223
+ })
224
+ ]
225
+ }),
226
+ /*#__PURE__*/ jsxs(FormField, {
227
+ children: [
228
+ /*#__PURE__*/ jsx(FormFieldLabel, {
229
+ htmlFor: `${fieldId}-type`,
230
+ children: _({
231
+ id: 'canvas.node_variables_panel.edit_type_label',
232
+ message: 'Data type'
233
+ })
234
+ }),
235
+ /*#__PURE__*/ jsxs(Select, {
236
+ value: type,
237
+ onValueChange: (next)=>changeType(next),
238
+ children: [
239
+ /*#__PURE__*/ jsx(SelectTrigger, {
240
+ id: `${fieldId}-type`,
241
+ children: /*#__PURE__*/ jsx(SelectValue, {})
242
+ }),
243
+ /*#__PURE__*/ jsx(SelectContent, {
244
+ children: VARIABLE_TYPES.map((option)=>/*#__PURE__*/ jsx(SelectItem, {
245
+ value: option,
246
+ children: typeLabel[option]
247
+ }, option))
248
+ })
249
+ ]
250
+ })
251
+ ]
252
+ }),
253
+ /*#__PURE__*/ jsxs(FormField, {
254
+ children: [
255
+ /*#__PURE__*/ jsx(FormFieldLabel, {
256
+ htmlFor: `${fieldId}-description`,
257
+ children: _({
258
+ id: "canvas.node_variables_panel.edit_description_label",
259
+ message: "Description"
260
+ })
261
+ }),
262
+ /*#__PURE__*/ jsx(Textarea, {
263
+ id: `${fieldId}-description`,
264
+ value: description,
265
+ onChange: (event)=>setDescription(event.target.value),
266
+ placeholder: _({
267
+ id: "canvas.node_variables_panel.edit_description_placeholder",
268
+ message: "Helpful description of what this variable represents"
269
+ }),
270
+ rows: 2
271
+ })
272
+ ]
273
+ }),
274
+ 'boolean' === type ? /*#__PURE__*/ jsxs(FormField, {
275
+ children: [
276
+ /*#__PURE__*/ jsx(FormFieldLabel, {
277
+ htmlFor: `${fieldId}-default`,
278
+ children: defaultLabel
279
+ }),
280
+ /*#__PURE__*/ jsxs("div", {
281
+ className: "flex items-center gap-2",
282
+ children: [
283
+ /*#__PURE__*/ jsx(Switch, {
284
+ id: `${fieldId}-default`,
285
+ checked: checked ?? false,
286
+ onCheckedChange: setChecked,
287
+ "aria-describedby": `${fieldId}-default-hint`
288
+ }),
289
+ void 0 !== checked && /*#__PURE__*/ jsx(Button, {
290
+ type: "button",
291
+ variant: "ghost",
292
+ size: "2xs",
293
+ onClick: ()=>setChecked(void 0),
294
+ "aria-label": _({
295
+ id: 'canvas.node_variables_panel.edit_default_clear_label',
296
+ message: 'Clear default value'
297
+ }),
298
+ children: _({
299
+ id: 'canvas.node_variables_panel.edit_default_clear',
300
+ message: 'Clear'
301
+ })
302
+ })
303
+ ]
304
+ }),
305
+ /*#__PURE__*/ jsx(FormFieldDescription, {
306
+ id: `${fieldId}-default-hint`,
307
+ children: void 0 === checked ? _({
308
+ id: 'canvas.node_variables_panel.edit_default_boolean_unset_hint',
309
+ message: 'No default. Toggle on for true, off for false'
310
+ }) : _({
311
+ id: 'canvas.node_variables_panel.edit_default_boolean_hint',
312
+ message: 'Toggle on for true, off for false'
313
+ })
314
+ })
315
+ ]
316
+ }) : /*#__PURE__*/ jsxs(FormField, {
317
+ children: [
318
+ /*#__PURE__*/ jsx(FormFieldLabel, {
319
+ htmlFor: `${fieldId}-default`,
320
+ children: defaultLabel
321
+ }),
322
+ 'object' === type || 'array' === type ? /*#__PURE__*/ jsx(Textarea, {
323
+ id: `${fieldId}-default`,
324
+ value: draft,
325
+ onChange: (event)=>setDraft(event.target.value),
326
+ placeholder: nullPlaceholder ?? ('object' === type ? '{"key": "value"}' : '[1, 2, 3]'),
327
+ error: defaultError,
328
+ rows: 4,
329
+ spellCheck: false,
330
+ className: "font-mono"
331
+ }) : /*#__PURE__*/ jsx(Input, {
332
+ id: `${fieldId}-default`,
333
+ value: draft,
334
+ onChange: (event)=>setDraft(event.target.value),
335
+ inputMode: 'number' === type ? 'decimal' : void 0,
336
+ placeholder: nullPlaceholder ?? ('number' === type ? '0' : _({
337
+ id: 'canvas.node_variables_panel.edit_default_string_placeholder',
338
+ message: 'Enter text value'
339
+ })),
340
+ error: defaultError,
341
+ autoComplete: "off"
342
+ })
343
+ ]
344
+ }),
345
+ /*#__PURE__*/ jsxs(DialogFooter, {
346
+ children: [
347
+ /*#__PURE__*/ jsx(Button, {
348
+ type: "button",
349
+ variant: "outline",
350
+ onClick: onClose,
351
+ children: _({
352
+ id: 'canvas.node_variables_panel.edit_cancel',
353
+ message: 'Cancel'
354
+ })
355
+ }),
356
+ /*#__PURE__*/ jsx(Button, {
357
+ type: "submit",
358
+ disabled: !!idError || !!defaultError,
359
+ children: _({
360
+ id: 'canvas.node_variables_panel.edit_save',
361
+ message: 'Save'
362
+ })
363
+ })
364
+ ]
365
+ })
366
+ ]
367
+ })
368
+ })
369
+ });
370
+ }
371
+ export { NodeVariableEditDialog };