@uipath/apollo-wind 2.46.0 → 2.47.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 (93) hide show
  1. package/dist/components/ui/avatar.d.ts +1 -1
  2. package/dist/components/ui/badge.d.ts +1 -1
  3. package/dist/components/ui/button.d.ts +2 -2
  4. package/dist/components/ui/command.d.ts +13 -13
  5. package/dist/components/ui/index.cjs +30 -30
  6. package/dist/components/ui/prompt-editor/components/EditorToolbar.cjs +101 -68
  7. package/dist/components/ui/prompt-editor/components/EditorToolbar.d.ts +16 -2
  8. package/dist/components/ui/prompt-editor/components/EditorToolbar.js +101 -68
  9. package/dist/components/ui/prompt-editor/components/MarkdownPreview.cjs +13 -8
  10. package/dist/components/ui/prompt-editor/components/MarkdownPreview.d.ts +13 -1
  11. package/dist/components/ui/prompt-editor/components/MarkdownPreview.js +13 -8
  12. package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.cjs +22 -11
  13. package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.js +23 -12
  14. package/dist/components/ui/prompt-editor/components/TokenPill.cjs +4 -2
  15. package/dist/components/ui/prompt-editor/components/TokenPill.js +4 -2
  16. package/dist/components/ui/prompt-editor/components/TokenPillSlot.cjs +58 -0
  17. package/dist/components/ui/prompt-editor/components/TokenPillSlot.d.ts +7 -0
  18. package/dist/components/ui/prompt-editor/components/TokenPillSlot.js +24 -0
  19. package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.cjs +8 -9
  20. package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.js +8 -9
  21. package/dist/components/ui/prompt-editor/index.cjs +152 -9
  22. package/dist/components/ui/prompt-editor/index.d.ts +13 -1
  23. package/dist/components/ui/prompt-editor/index.js +11 -1
  24. package/dist/components/ui/prompt-editor/nodes/InputTokenNode.cjs +2 -2
  25. package/dist/components/ui/prompt-editor/nodes/InputTokenNode.d.ts +1 -1
  26. package/dist/components/ui/prompt-editor/nodes/InputTokenNode.js +2 -2
  27. package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.cjs +2 -2
  28. package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.d.ts +1 -1
  29. package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.js +2 -2
  30. package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.cjs +2 -2
  31. package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.d.ts +1 -1
  32. package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.js +2 -2
  33. package/dist/components/ui/prompt-editor/nodes/StateTokenNode.cjs +2 -2
  34. package/dist/components/ui/prompt-editor/nodes/StateTokenNode.d.ts +1 -1
  35. package/dist/components/ui/prompt-editor/nodes/StateTokenNode.js +2 -2
  36. package/dist/components/ui/prompt-editor/nodes/index.cjs +1 -1
  37. package/dist/components/ui/prompt-editor/nodes/index.d.ts +5 -5
  38. package/dist/components/ui/prompt-editor/nodes/index.js +1 -1
  39. package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.cjs +11 -5
  40. package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.d.ts +8 -1
  41. package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.js +12 -6
  42. package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.cjs +1 -1
  43. package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.js +1 -1
  44. package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.cjs +1 -1
  45. package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.js +1 -1
  46. package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.cjs +1 -1
  47. package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.js +1 -1
  48. package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.cjs +12 -6
  49. package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.js +13 -7
  50. package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.cjs +64 -3
  51. package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.d.ts +6 -2
  52. package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.js +65 -4
  53. package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.cjs +4 -9
  54. package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.js +4 -9
  55. package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.cjs +10 -5
  56. package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.d.ts +3 -1
  57. package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.js +10 -5
  58. package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.cjs +1 -1
  59. package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.js +2 -2
  60. package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.cjs +10 -1
  61. package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.d.ts +4 -1
  62. package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.js +8 -2
  63. package/dist/components/ui/prompt-editor/prompt-editor-config.cjs +69 -0
  64. package/dist/components/ui/prompt-editor/prompt-editor-config.d.ts +70 -0
  65. package/dist/components/ui/prompt-editor/prompt-editor-config.js +29 -0
  66. package/dist/components/ui/prompt-editor/prompt-editor.cjs +198 -88
  67. package/dist/components/ui/prompt-editor/prompt-editor.d.ts +46 -1
  68. package/dist/components/ui/prompt-editor/prompt-editor.js +199 -89
  69. package/dist/components/ui/prompt-editor/types.cjs +5 -5
  70. package/dist/components/ui/prompt-editor/types.d.ts +18 -2
  71. package/dist/components/ui/prompt-editor/types.js +5 -5
  72. package/dist/components/ui/prompt-editor/utils/autocomplete-segments.cjs +10 -5
  73. package/dist/components/ui/prompt-editor/utils/autocomplete-segments.d.ts +13 -0
  74. package/dist/components/ui/prompt-editor/utils/autocomplete-segments.js +8 -6
  75. package/dist/components/ui/prompt-editor/utils/index.cjs +1 -1
  76. package/dist/components/ui/prompt-editor/utils/index.d.ts +1 -1
  77. package/dist/components/ui/prompt-editor/utils/index.js +1 -1
  78. package/dist/components/ui/prompt-editor/utils/insert-token.d.ts +1 -1
  79. package/dist/components/ui/prompt-editor/utils/rich-serialization.cjs +186 -0
  80. package/dist/components/ui/prompt-editor/utils/rich-serialization.d.ts +38 -0
  81. package/dist/components/ui/prompt-editor/utils/rich-serialization.js +140 -0
  82. package/dist/components/ui/prompt-editor/utils/serialization.cjs +13 -5
  83. package/dist/components/ui/prompt-editor/utils/serialization.js +14 -6
  84. package/dist/components/ui/sheet.d.ts +1 -1
  85. package/dist/components/ui/spinner.d.ts +1 -1
  86. package/dist/components/ui/switch.d.ts +2 -2
  87. package/dist/components/ui/toggle-group.d.ts +2 -2
  88. package/dist/components/ui/toggle.d.ts +2 -2
  89. package/dist/index.cjs +136 -61
  90. package/dist/index.d.ts +89 -89
  91. package/dist/index.js +61 -61
  92. package/dist/styles.css +15 -0
  93. package/package.json +3 -1
@@ -1,10 +1,13 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { LexicalComposer } from "@lexical/react/LexicalComposer";
3
3
  import { ContentEditable } from "@lexical/react/LexicalContentEditable";
4
4
  import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
5
5
  import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
6
+ import { ListPlugin } from "@lexical/react/LexicalListPlugin";
7
+ import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
6
8
  import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
7
9
  import { PlainTextPlugin } from "@lexical/react/LexicalPlainTextPlugin";
10
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
8
11
  import { $getSelection, $isRangeSelection } from "lexical";
9
12
  import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
10
13
  import { FormFieldError } from "../form-field.js";
@@ -22,15 +25,19 @@ import { ToolbarActionsPlugin } from "./plugins/ToolbarActionsPlugin.js";
22
25
  import { ValidateTokensPlugin } from "./plugins/ValidateTokensPlugin.js";
23
26
  import { ValueSyncPlugin } from "./plugins/ValueSyncPlugin.js";
24
27
  import { VariableDropPlugin } from "./plugins/VariableDropPlugin.js";
28
+ import { DEFAULT_PROMPT_EDITOR_STRINGS, PromptEditorConfigProvider } from "./prompt-editor-config.js";
25
29
  import { $getEditorTokensInternal, $insertTokenAtCursor, $setEditorTokensInternal, areTokensEqual } from "./utils/index.js";
30
+ import { $getRichEditorTokensInternal, $setRichEditorTokensInternal, PROMPT_EDITOR_RICH_TRANSFORMERS, RICH_EDITOR_EXTRA_NODES } from "./utils/rich-serialization.js";
26
31
  const DEFAULT_MIN_ROWS = 4;
27
32
  const DEFAULT_MAX_ROWS = 20;
28
33
  const LINE_HEIGHT = 20;
29
34
  const EMPTY_AUTOCOMPLETE_OPTIONS = [];
30
35
  const EMPTY_TOKENS = [];
31
36
  const toTokenArray = (v)=>void 0 === v ? void 0 : Array.isArray(v) ? v : EMPTY_TOKENS;
32
- const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, autoCompleteOptions = EMPTY_AUTOCOMPLETE_OPTIONS, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, fillHeight, borderless, error, errorId, ariaDescribedBy, mapVarDropToToken, toolbarActionsRef, showToolbar }, ref)=>{
37
+ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, autoCompleteOptions = EMPTY_AUTOCOMPLETE_OPTIONS, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, fillHeight, borderless, error, errorId, ariaDescribedBy, mapVarDropToToken, validationOptions, renderAutocompleteMenu, toolbarActionsRef, showToolbar, children, richText, onActiveFormatsChange }, ref)=>{
33
38
  const editorRef = useRef(null);
39
+ const $getTokens = richText ? $getRichEditorTokensInternal : $getEditorTokensInternal;
40
+ const $setTokens = richText ? $setRichEditorTokensInternal : $setEditorTokensInternal;
34
41
  const [isEmpty, setIsEmpty] = useState(()=>{
35
42
  const seed = initialValue ?? value;
36
43
  return !seed || 0 === seed.length;
@@ -48,7 +55,7 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
48
55
  useImperativeHandle(ref, ()=>({
49
56
  setTokens: (tokens)=>{
50
57
  if (editorRef.current) editorRef.current.update(()=>{
51
- $setEditorTokensInternal(tokens);
58
+ $setTokens(tokens);
52
59
  });
53
60
  else onChangeRef.current?.(tokens);
54
61
  },
@@ -69,7 +76,9 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
69
76
  $insertTokenAtCursor(option);
70
77
  });
71
78
  }
72
- }), []);
79
+ }), [
80
+ $setTokens
81
+ ]);
73
82
  const contentEditableStyle = useMemo(()=>{
74
83
  const verticalPadding = 8;
75
84
  const textColor = borderless ? 'inherit' : 'var(--color-foreground)';
@@ -118,7 +127,7 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
118
127
  const handleChange = useCallback(()=>{
119
128
  if (!editorRef.current) return;
120
129
  editorRef.current.getEditorState().read(()=>{
121
- const tokens = $getEditorTokensInternal();
130
+ const tokens = $getTokens();
122
131
  const newIsEmpty = 0 === tokens.length || 1 === tokens.length && 'text' === tokens[0].type && '' === tokens[0].value;
123
132
  if (newIsEmpty !== isEmptyRef.current) setIsEmpty(newIsEmpty);
124
133
  if (!isSyncingRef.current) pendingTokensRef.current = tokens;
@@ -155,7 +164,7 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
155
164
  queueMicrotask(()=>{
156
165
  if (!editorRef.current || initializedRef.current) return;
157
166
  editorRef.current.update(()=>{
158
- $setEditorTokensInternal(valueToSet);
167
+ $setTokens(valueToSet);
159
168
  setIsEmpty(0 === valueToSet.length);
160
169
  initializedRef.current = true;
161
170
  });
@@ -168,7 +177,8 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
168
177
  disabled
169
178
  ]);
170
179
  const options = Array.isArray(autoCompleteOptions) ? autoCompleteOptions : EMPTY_AUTOCOMPLETE_OPTIONS;
171
- const wrapperClassName = borderless ? 'flex flex-col w-full relative' : `prompt-editor-shell flex flex-col w-full relative border bg-background future:border-0 future:bg-surface-overlay ${showToolbar ? 'border-t-0 rounded-b-md future:rounded-b-xl' : 'rounded-md future:rounded-xl'} ${error ? 'border-error ring-1 ring-error/20 future:ring-error/40' : ''}`;
180
+ const shellFocusClasses = showToolbar ? '' : ' focus-within:ring-2 focus-within:ring-ring future:focus-within:ring-offset-2 future:focus-within:ring-offset-background';
181
+ const wrapperClassName = borderless ? 'flex flex-col w-full relative' : `prompt-editor-shell flex flex-col w-full relative border bg-background future:border-0 future:bg-surface-overlay ${showToolbar ? 'border-t-0 rounded-b-md future:rounded-b-xl' : 'rounded-md future:rounded-xl'} ${error ? 'border-error ring-1 ring-error/20 future:ring-error/40' : ''}${shellFocusClasses}`;
172
182
  return /*#__PURE__*/ jsxs("div", {
173
183
  className: wrapperClassName,
174
184
  "data-invalid": error ? 'true' : void 0,
@@ -185,8 +195,18 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
185
195
  /*#__PURE__*/ jsx("style", {
186
196
  children: `
187
197
  .prompt-editor-paragraph { padding: 0; margin: 0; }
188
- ${borderless ? '' : '.prompt-editor-shell:not([data-invalid="true"]):focus-within { border-color: var(--color-ring); box-shadow: 0 0 0 1px var(--color-ring); } .future .prompt-editor-shell:not([data-invalid="true"]):focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-ring) 35%, transparent); }'}
189
198
  .prompt-editor-root *::selection { background-color: color-mix(in srgb, var(--color-primary) 30%, transparent); }
199
+ ${richText ? `
200
+ /* Rich-mode formatting — metrics mirror MarkdownPreview so editing matches rendering. */
201
+ .prompt-editor-text-bold { font-weight: 700; }
202
+ .prompt-editor-text-italic { font-style: italic; }
203
+ .prompt-editor-text-strikethrough { text-decoration: line-through; }
204
+ .prompt-editor-list-ul, .prompt-editor-list-ol { margin: 0.25em 0; padding-left: 1.5em; }
205
+ .prompt-editor-list-ul { list-style-type: disc; }
206
+ .prompt-editor-list-ol { list-style-type: decimal; }
207
+ .prompt-editor-list-item { margin: 0.125em 0; }
208
+ .prompt-editor-list-item-nested { list-style-type: none; }
209
+ ` : ''}
190
210
  `
191
211
  }),
192
212
  /*#__PURE__*/ jsxs("div", {
@@ -201,7 +221,17 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
201
221
  } : {}
202
222
  },
203
223
  children: [
204
- /*#__PURE__*/ jsx(PlainTextPlugin, {
224
+ richText ? /*#__PURE__*/ jsx(RichTextPlugin, {
225
+ contentEditable: /*#__PURE__*/ jsx(ContentEditable, {
226
+ style: contentEditableStyle,
227
+ ariaLabel: ariaLabel,
228
+ "aria-invalid": error ? true : void 0,
229
+ "aria-describedby": ariaDescribedBy,
230
+ "aria-errormessage": error ? errorId : void 0
231
+ }),
232
+ placeholder: null,
233
+ ErrorBoundary: LexicalErrorBoundary
234
+ }) : /*#__PURE__*/ jsx(PlainTextPlugin, {
205
235
  contentEditable: /*#__PURE__*/ jsx(ContentEditable, {
206
236
  style: contentEditableStyle,
207
237
  ariaLabel: ariaLabel,
@@ -244,23 +274,35 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
244
274
  value: value,
245
275
  editorRef: editorRef,
246
276
  lastEmittedValueRef: lastEmittedValueRef,
247
- isSyncingRef: isSyncingRef
277
+ isSyncingRef: isSyncingRef,
278
+ richText: richText
248
279
  }),
249
- /*#__PURE__*/ jsx(MultilinePlugin, {
280
+ !richText && /*#__PURE__*/ jsx(MultilinePlugin, {
250
281
  multiline: multiline
251
282
  }),
283
+ richText && /*#__PURE__*/ jsxs(Fragment, {
284
+ children: [
285
+ /*#__PURE__*/ jsx(ListPlugin, {}),
286
+ /*#__PURE__*/ jsx(MarkdownShortcutPlugin, {
287
+ transformers: PROMPT_EDITOR_RICH_TRANSFORMERS
288
+ })
289
+ ]
290
+ }),
252
291
  /*#__PURE__*/ jsx(OnChangePlugin, {
253
292
  ignoreSelectionChange: true,
254
293
  onChange: handleChange
255
294
  }),
256
295
  /*#__PURE__*/ jsx(ToolbarActionsPlugin, {
257
- actionsRef: toolbarActionsRef
296
+ actionsRef: toolbarActionsRef,
297
+ richText: richText,
298
+ onActiveFormatsChange: onActiveFormatsChange
258
299
  }),
259
- options.length > 0 && /*#__PURE__*/ jsx(AutocompletePlugin, {
260
- options: options
300
+ (options.length > 0 || renderAutocompleteMenu) && /*#__PURE__*/ jsx(AutocompletePlugin, {
301
+ options: options,
302
+ renderMenu: renderAutocompleteMenu
261
303
  }),
262
304
  /*#__PURE__*/ jsx(ValidateTokensPlugin, {
263
- options: options
305
+ options: Array.isArray(validationOptions) ? validationOptions : options
264
306
  }),
265
307
  options.length > 0 && /*#__PURE__*/ jsx(RenameTokensPlugin, {
266
308
  options: options,
@@ -269,17 +311,27 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
269
311
  mapVarDropToToken && /*#__PURE__*/ jsx(VariableDropPlugin, {
270
312
  mapVarDropToToken: mapVarDropToToken,
271
313
  disabled: disabled
272
- })
314
+ }),
315
+ children
273
316
  ]
274
317
  });
275
318
  });
276
319
  EditorInner.displayName = 'PromptEditorInner';
277
- const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar = false, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, error, errorId: providedErrorId, 'aria-describedby': nativeAriaDescribedBy, ariaDescribedBy: legacyAriaDescribedBy, mapVarDropToToken })=>{
320
+ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar = false, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, error, errorId: providedErrorId, 'aria-describedby': nativeAriaDescribedBy, ariaDescribedBy: legacyAriaDescribedBy, mapVarDropToToken, validationOptions, renderAutocompleteMenu, renderTokenPill, strings: partialStrings, showModeToggle = true, toolbarTrailing, children, richText: richTextProp, previewToken })=>{
278
321
  const value = toTokenArray(rawValue);
279
322
  const initialValue = toTokenArray(rawInitialValue);
323
+ const [richText] = useState(()=>{
324
+ if (richTextProp && !multiline) {
325
+ console.warn('PromptEditor: richText requires multiline — falling back to the plain editor.');
326
+ return false;
327
+ }
328
+ return !!richTextProp;
329
+ });
280
330
  const [internalMode, setInternalMode] = useState('edit');
281
- const mode = controlledMode ?? internalMode;
331
+ const modeLocked = richText || showToolbar && !showModeToggle;
332
+ const mode = modeLocked ? 'edit' : controlledMode ?? internalMode;
282
333
  const toolbarActionsRef = useRef(null);
334
+ const [activeFormats, setActiveFormats] = useState(void 0);
283
335
  const [uncontrolledPreviewTokens, setUncontrolledPreviewTokens] = useState(initialValue ?? []);
284
336
  const handleModeChange = useCallback((newMode)=>{
285
337
  if (onModeChange) onModeChange(newMode);
@@ -290,16 +342,34 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
290
342
  const initialConfig = useMemo(()=>({
291
343
  namespace: 'PromptEditor',
292
344
  theme: {
293
- paragraph: 'prompt-editor-paragraph'
345
+ paragraph: 'prompt-editor-paragraph',
346
+ ...richText ? {
347
+ text: {
348
+ bold: 'prompt-editor-text-bold',
349
+ italic: 'prompt-editor-text-italic',
350
+ strikethrough: 'prompt-editor-text-strikethrough'
351
+ },
352
+ list: {
353
+ ul: 'prompt-editor-list-ul',
354
+ ol: 'prompt-editor-list-ol',
355
+ listitem: 'prompt-editor-list-item',
356
+ nested: {
357
+ listitem: 'prompt-editor-list-item-nested'
358
+ }
359
+ }
360
+ } : {}
294
361
  },
295
362
  onError: (error)=>console.error('PromptEditor error:', error),
296
363
  nodes: [
297
364
  InputTokenNode,
298
365
  OutputTokenNode,
299
366
  StateTokenNode,
300
- ResourceTokenNode
367
+ ResourceTokenNode,
368
+ ...richText ? RICH_EDITOR_EXTRA_NODES : []
301
369
  ]
302
- }), []);
370
+ }), [
371
+ richText
372
+ ]);
303
373
  const isControlled = void 0 !== value;
304
374
  const previewTokens = isControlled ? value : uncontrolledPreviewTokens;
305
375
  const generatedErrorId = useId();
@@ -316,75 +386,115 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
316
386
  isControlled,
317
387
  onChange
318
388
  ]);
319
- return /*#__PURE__*/ jsx(TooltipProvider, {
320
- children: /*#__PURE__*/ jsxs("div", {
321
- style: {
322
- display: 'flex',
323
- flexDirection: 'column',
324
- width: '100%',
325
- ...fillHeight ? {
326
- flex: 1,
327
- minHeight: 0
328
- } : {}
329
- },
330
- children: [
331
- showToolbar && /*#__PURE__*/ jsx(EditorToolbar, {
332
- mode: mode,
333
- disabled: disabled,
334
- error: Boolean(error),
335
- actionsRef: toolbarActionsRef,
336
- onModeChange: handleModeChange,
337
- onFullscreen: onFullscreen
338
- }),
339
- 'preview' === mode && /*#__PURE__*/ jsx("div", {
340
- "data-invalid": error ? 'true' : void 0,
341
- className: borderless ? void 0 : `border bg-background future:border-0 future:bg-surface-overlay ${showToolbar ? 'border-t-0 rounded-b-md future:rounded-b-xl' : 'rounded-md future:rounded-xl'} ${error ? 'border-error ring-1 ring-error/20 future:ring-error/40' : ''}`,
342
- children: /*#__PURE__*/ jsx(MarkdownPreview, {
343
- tokens: previewTokens,
344
- minRows: minRows
345
- })
346
- }),
347
- /*#__PURE__*/ jsx("div", {
348
- style: {
349
- display: 'preview' === mode ? 'none' : 'flex',
350
- flexDirection: 'column',
351
- ...fillHeight ? {
352
- flex: 1,
353
- minHeight: 0
354
- } : {}
355
- },
356
- children: /*#__PURE__*/ jsx(LexicalComposer, {
357
- initialConfig: initialConfig,
358
- children: /*#__PURE__*/ jsx(EditorInner, {
359
- ref: editorRef,
360
- autoCompleteOptions: autoCompleteOptions,
361
- disabled: disabled,
362
- ariaLabel: ariaLabel,
363
- error: error,
364
- errorId: error ? errorId : void 0,
365
- ariaDescribedBy: describedBy || void 0,
366
- initialValue: initialValue,
367
- maxRows: maxRows,
368
- minRows: minRows,
369
- multiline: multiline,
370
- placeholder: placeholder,
371
- fillHeight: fillHeight,
372
- borderless: borderless,
373
- mapVarDropToToken: mapVarDropToToken,
374
- showToolbar: showToolbar,
375
- toolbarActionsRef: toolbarActionsRef,
376
- value: value,
377
- onChange: handleEditorChange
378
- })
389
+ const strings = useMemo(()=>({
390
+ ...DEFAULT_PROMPT_EDITOR_STRINGS,
391
+ ...partialStrings
392
+ }), [
393
+ partialStrings
394
+ ]);
395
+ const editorConfig = useMemo(()=>({
396
+ renderTokenPill,
397
+ strings
398
+ }), [
399
+ renderTokenPill,
400
+ strings
401
+ ]);
402
+ return /*#__PURE__*/ jsx(PromptEditorConfigProvider, {
403
+ value: editorConfig,
404
+ children: /*#__PURE__*/ jsx(TooltipProvider, {
405
+ children: /*#__PURE__*/ jsxs("div", {
406
+ style: {
407
+ display: 'flex',
408
+ flexDirection: 'column',
409
+ width: '100%',
410
+ ...fillHeight ? {
411
+ flex: 1,
412
+ minHeight: 0
413
+ } : {}
414
+ },
415
+ children: [
416
+ /*#__PURE__*/ jsxs("div", {
417
+ className: showToolbar && !borderless ? 'prompt-editor-frame rounded-md future:rounded-xl focus-within:ring-2 focus-within:ring-ring future:focus-within:ring-offset-2 future:focus-within:ring-offset-background' : void 0,
418
+ style: {
419
+ display: 'flex',
420
+ flexDirection: 'column',
421
+ width: '100%',
422
+ ...fillHeight ? {
423
+ flex: 1,
424
+ minHeight: 0
425
+ } : {}
426
+ },
427
+ children: [
428
+ showToolbar && /*#__PURE__*/ jsx(EditorToolbar, {
429
+ mode: mode,
430
+ disabled: disabled,
431
+ error: Boolean(error),
432
+ actionsRef: toolbarActionsRef,
433
+ onModeChange: handleModeChange,
434
+ onFullscreen: onFullscreen,
435
+ showModeToggle: showModeToggle && !richText,
436
+ trailing: toolbarTrailing,
437
+ strings: strings,
438
+ activeFormats: richText ? activeFormats : void 0
439
+ }),
440
+ 'preview' === mode && /*#__PURE__*/ jsx("div", {
441
+ "data-invalid": error ? 'true' : void 0,
442
+ className: borderless ? void 0 : `border bg-background future:border-0 future:bg-surface-overlay ${showToolbar ? 'border-t-0 rounded-b-md future:rounded-b-xl' : 'rounded-md future:rounded-xl'} ${error ? 'border-error ring-1 ring-error/20 future:ring-error/40' : ''}`,
443
+ children: /*#__PURE__*/ jsx(MarkdownPreview, {
444
+ tokens: previewTokens,
445
+ minRows: minRows,
446
+ previewToken: previewToken
447
+ })
448
+ }),
449
+ /*#__PURE__*/ jsx("div", {
450
+ style: {
451
+ display: 'preview' === mode ? 'none' : 'flex',
452
+ flexDirection: 'column',
453
+ ...fillHeight ? {
454
+ flex: 1,
455
+ minHeight: 0
456
+ } : {}
457
+ },
458
+ children: /*#__PURE__*/ jsx(LexicalComposer, {
459
+ initialConfig: initialConfig,
460
+ children: /*#__PURE__*/ jsx(EditorInner, {
461
+ ref: editorRef,
462
+ autoCompleteOptions: autoCompleteOptions,
463
+ disabled: disabled,
464
+ ariaLabel: ariaLabel,
465
+ error: error,
466
+ errorId: error ? errorId : void 0,
467
+ ariaDescribedBy: describedBy || void 0,
468
+ initialValue: initialValue,
469
+ maxRows: maxRows,
470
+ minRows: minRows,
471
+ multiline: multiline,
472
+ placeholder: placeholder,
473
+ fillHeight: fillHeight,
474
+ borderless: borderless,
475
+ mapVarDropToToken: mapVarDropToToken,
476
+ validationOptions: validationOptions,
477
+ renderAutocompleteMenu: renderAutocompleteMenu,
478
+ showToolbar: showToolbar,
479
+ toolbarActionsRef: toolbarActionsRef,
480
+ value: value,
481
+ onChange: handleEditorChange,
482
+ richText: richText,
483
+ onActiveFormatsChange: richText ? setActiveFormats : void 0,
484
+ children: children
485
+ })
486
+ })
487
+ })
488
+ ]
489
+ }),
490
+ /*#__PURE__*/ jsx(FormFieldError, {
491
+ id: errorId,
492
+ "data-slot": "prompt-editor-error",
493
+ className: "mt-1",
494
+ children: error
379
495
  })
380
- }),
381
- /*#__PURE__*/ jsx(FormFieldError, {
382
- id: errorId,
383
- "data-slot": "prompt-editor-error",
384
- className: "mt-1",
385
- children: error
386
- })
387
- ]
496
+ ]
497
+ })
388
498
  })
389
499
  });
390
500
  };
@@ -43,16 +43,16 @@ const getPromptEditorTokenColors = ()=>({
43
43
  icon: 'var(--color-error-icon)'
44
44
  }
45
45
  });
46
- const getPromptEditorTokenTypeLabel = (type)=>{
46
+ const getPromptEditorTokenTypeLabel = (type, labels)=>{
47
47
  switch(type){
48
48
  case 'input':
49
- return 'Input variable';
49
+ return labels?.tokenTypeInput ?? 'Input variable';
50
50
  case 'output':
51
- return 'Output variable';
51
+ return labels?.tokenTypeOutput ?? 'Output variable';
52
52
  case 'state':
53
- return 'State variable';
53
+ return labels?.tokenTypeState ?? 'State variable';
54
54
  case 'resource':
55
- return 'Resource';
55
+ return labels?.tokenTypeResource ?? 'Resource';
56
56
  default:
57
57
  return 'Text';
58
58
  }
@@ -31,6 +31,14 @@ export interface PromptEditorAutoCompleteOption {
31
31
  value: string;
32
32
  }
33
33
  export type PromptEditorMode = 'edit' | 'preview';
34
+ /** Which formats are active at the selection (rich mode) — drives the toolbar's pressed states. */
35
+ export interface PromptEditorToolbarActiveFormats {
36
+ bold: boolean;
37
+ italic: boolean;
38
+ strikethrough: boolean;
39
+ orderedList: boolean;
40
+ bulletedList: boolean;
41
+ }
34
42
  export interface PromptEditorToolbarActionsRef {
35
43
  formatBold: () => void;
36
44
  formatItalic: () => void;
@@ -50,8 +58,16 @@ export interface PromptEditorTokenColorConfig {
50
58
  * which already resolve per light/dark theme via CSS — no JS theme detection needed.
51
59
  */
52
60
  export declare const getPromptEditorTokenColors: () => Record<"valid" | "invalid", PromptEditorTokenColorConfig>;
53
- /** Human-readable label for a token type, used in the chip's hover tooltip. */
54
- export declare const getPromptEditorTokenTypeLabel: (type: PromptEditorTokenType) => string;
61
+ /** The token-type label subset of `PromptEditorStrings` (structural, to avoid a config↔types cycle). */
62
+ export interface PromptEditorTokenTypeLabels {
63
+ tokenTypeInput: string;
64
+ tokenTypeOutput: string;
65
+ tokenTypeState: string;
66
+ tokenTypeResource: string;
67
+ }
68
+ /** Human-readable label for a token type, used in the chip's hover tooltip. Pass the editor's
69
+ * `strings` to localize; the English defaults apply otherwise. */
70
+ export declare const getPromptEditorTokenTypeLabel: (type: PromptEditorTokenType, labels?: PromptEditorTokenTypeLabels) => string;
55
71
  export type PromptEditorDiffType = 'added' | 'removed';
56
72
  export declare const isPromptEditorTextToken: (token: PromptEditorToken) => token is PromptEditorTextToken;
57
73
  export declare const isPromptEditorNonTextToken: (token: PromptEditorToken) => token is Exclude<PromptEditorToken, PromptEditorTextToken>;
@@ -12,16 +12,16 @@ const getPromptEditorTokenColors = ()=>({
12
12
  icon: 'var(--color-error-icon)'
13
13
  }
14
14
  });
15
- const getPromptEditorTokenTypeLabel = (type)=>{
15
+ const getPromptEditorTokenTypeLabel = (type, labels)=>{
16
16
  switch(type){
17
17
  case 'input':
18
- return 'Input variable';
18
+ return labels?.tokenTypeInput ?? 'Input variable';
19
19
  case 'output':
20
- return 'Output variable';
20
+ return labels?.tokenTypeOutput ?? 'Output variable';
21
21
  case 'state':
22
- return 'State variable';
22
+ return labels?.tokenTypeState ?? 'State variable';
23
23
  case 'resource':
24
- return 'Resource';
24
+ return labels?.tokenTypeResource ?? 'Resource';
25
25
  default:
26
26
  return 'Text';
27
27
  }
@@ -26,33 +26,38 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  VARIABLE_PATH_REGEX: ()=>VARIABLE_PATH_REGEX,
28
28
  inferTokenTypeFromPath: ()=>inferTokenTypeFromPath,
29
+ normalizeVariablePath: ()=>normalizeVariablePath,
29
30
  shouldSuppressOpenForDismissed: ()=>shouldSuppressOpenForDismissed
30
31
  });
32
+ const normalizeVariablePath = (path)=>path.replace(/\[\d+\]/g, '[]');
31
33
  const NAMESPACE_TOKEN_TYPE = {
32
34
  state: 'state',
33
35
  resource: 'resource'
34
36
  };
35
37
  const inferTokenTypeFromPath = (path, options)=>{
36
- for (const opt of options)if (opt.value === path) return opt.type;
37
- const segments = path.split('.');
38
+ const target = normalizeVariablePath(path);
39
+ for (const opt of options)if (normalizeVariablePath(opt.value) === target) return opt.type;
40
+ const segments = target.split('.');
38
41
  while(segments.length > 1){
39
42
  segments.pop();
40
43
  const prefix = segments.join('.');
41
- for (const opt of options)if (opt.value === prefix) return opt.type;
44
+ for (const opt of options)if (normalizeVariablePath(opt.value) === prefix) return opt.type;
42
45
  }
43
- return NAMESPACE_TOKEN_TYPE[path.split('.')[0]] ?? 'input';
46
+ return NAMESPACE_TOKEN_TYPE[target.split('.')[0]] ?? 'input';
44
47
  };
45
- const VARIABLE_PATH_REGEX = /^(?:vars|metadata|agent|state|resource)\.[a-zA-Z_][a-zA-Z0-9_.]*$/;
48
+ const VARIABLE_PATH_REGEX = /^(?:vars|metadata|agent|state|resource)(?:\.[a-zA-Z_][a-zA-Z0-9_]*(?:\[\d+\])*)+$/;
46
49
  function shouldSuppressOpenForDismissed(trigger, dismissed) {
47
50
  if (!dismissed) return false;
48
51
  return dismissed.nodeKey === trigger.nodeKey && dismissed.triggerIndex === trigger.triggerIndex;
49
52
  }
50
53
  exports.VARIABLE_PATH_REGEX = __webpack_exports__.VARIABLE_PATH_REGEX;
51
54
  exports.inferTokenTypeFromPath = __webpack_exports__.inferTokenTypeFromPath;
55
+ exports.normalizeVariablePath = __webpack_exports__.normalizeVariablePath;
52
56
  exports.shouldSuppressOpenForDismissed = __webpack_exports__.shouldSuppressOpenForDismissed;
53
57
  for(var __rspack_i in __webpack_exports__)if (-1 === [
54
58
  "VARIABLE_PATH_REGEX",
55
59
  "inferTokenTypeFromPath",
60
+ "normalizeVariablePath",
56
61
  "shouldSuppressOpenForDismissed"
57
62
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
58
63
  Object.defineProperty(exports, '__esModule', {
@@ -1,4 +1,17 @@
1
1
  import type { PromptEditorAutoCompleteOption, PromptEditorTokenType } from '../types';
2
+ /**
3
+ * Helpers for the prompt editor's `$`-trigger flow that survived after the bespoke segment-aware
4
+ * drill-in menu was replaced by `<VariablePickerAutocompleteMenu>`. The picker itself owns search,
5
+ * keyboard nav, and visual rendering — these helpers cover the parts of the trigger flow that live
6
+ * in `AutocompletePlugin`: free-form Enter commit (when the typed `$prefix.path` doesn't match any
7
+ * scope entry) and the dismissal sentinel that suppresses re-opening on cursor returns.
8
+ */
9
+ /**
10
+ * Normalize array indices in an expression-ready path (`items[0]` → `items[]`) for lookup, so an
11
+ * option advertised with the schema's example index (`records[0].id`) also validates user-entered
12
+ * indices such as `records[1].id`.
13
+ */
14
+ export declare const normalizeVariablePath: (path: string) => string;
2
15
  /**
3
16
  * Infer the token type for a typed-but-unmatched path by walking up parent prefixes in the option set.
4
17
  * Mirrors `findVariableForPath`'s ancestor-fallback shape so a free-form chip inherits the closest
@@ -1,20 +1,22 @@
1
+ const normalizeVariablePath = (path)=>path.replace(/\[\d+\]/g, '[]');
1
2
  const NAMESPACE_TOKEN_TYPE = {
2
3
  state: 'state',
3
4
  resource: 'resource'
4
5
  };
5
6
  const inferTokenTypeFromPath = (path, options)=>{
6
- for (const opt of options)if (opt.value === path) return opt.type;
7
- const segments = path.split('.');
7
+ const target = normalizeVariablePath(path);
8
+ for (const opt of options)if (normalizeVariablePath(opt.value) === target) return opt.type;
9
+ const segments = target.split('.');
8
10
  while(segments.length > 1){
9
11
  segments.pop();
10
12
  const prefix = segments.join('.');
11
- for (const opt of options)if (opt.value === prefix) return opt.type;
13
+ for (const opt of options)if (normalizeVariablePath(opt.value) === prefix) return opt.type;
12
14
  }
13
- return NAMESPACE_TOKEN_TYPE[path.split('.')[0]] ?? 'input';
15
+ return NAMESPACE_TOKEN_TYPE[target.split('.')[0]] ?? 'input';
14
16
  };
15
- const VARIABLE_PATH_REGEX = /^(?:vars|metadata|agent|state|resource)\.[a-zA-Z_][a-zA-Z0-9_.]*$/;
17
+ const VARIABLE_PATH_REGEX = /^(?:vars|metadata|agent|state|resource)(?:\.[a-zA-Z_][a-zA-Z0-9_]*(?:\[\d+\])*)+$/;
16
18
  function shouldSuppressOpenForDismissed(trigger, dismissed) {
17
19
  if (!dismissed) return false;
18
20
  return dismissed.nodeKey === trigger.nodeKey && dismissed.triggerIndex === trigger.triggerIndex;
19
21
  }
20
- export { VARIABLE_PATH_REGEX, inferTokenTypeFromPath, shouldSuppressOpenForDismissed };
22
+ export { VARIABLE_PATH_REGEX, inferTokenTypeFromPath, normalizeVariablePath, shouldSuppressOpenForDismissed };
@@ -36,9 +36,9 @@ __webpack_require__.d(__webpack_exports__, {
36
36
  WORD_JOINER: ()=>external_serialization_cjs_namespaceObject.WORD_JOINER,
37
37
  setEditorTokens: ()=>external_serialization_cjs_namespaceObject.setEditorTokens
38
38
  });
39
- const external_serialization_cjs_namespaceObject = require("./serialization.cjs");
40
39
  const external_comparison_cjs_namespaceObject = require("./comparison.cjs");
41
40
  const external_insert_token_cjs_namespaceObject = require("./insert-token.cjs");
41
+ const external_serialization_cjs_namespaceObject = require("./serialization.cjs");
42
42
  exports.$getEditorTokensInternal = __webpack_exports__.$getEditorTokensInternal;
43
43
  exports.$insertTokenAtCursor = __webpack_exports__.$insertTokenAtCursor;
44
44
  exports.$setEditorTokensInternal = __webpack_exports__.$setEditorTokensInternal;
@@ -1,3 +1,3 @@
1
- export { $getEditorTokensInternal, $setEditorTokensInternal, getEditorTokens, setEditorTokens, tokensToClipboardString, clipboardStringToTokens, getEditorTokensFromSelection, WORD_JOINER, } from './serialization';
2
1
  export { areTokensEqual } from './comparison';
3
2
  export { $insertTokenAtCursor, createTokenNodeForOption } from './insert-token';
3
+ export { $getEditorTokensInternal, $setEditorTokensInternal, clipboardStringToTokens, getEditorTokens, getEditorTokensFromSelection, setEditorTokens, tokensToClipboardString, WORD_JOINER, } from './serialization';
@@ -1,4 +1,4 @@
1
- import { $getEditorTokensInternal, $setEditorTokensInternal, WORD_JOINER, clipboardStringToTokens, getEditorTokens, getEditorTokensFromSelection, setEditorTokens, tokensToClipboardString } from "./serialization.js";
2
1
  import { areTokensEqual } from "./comparison.js";
3
2
  import { $insertTokenAtCursor, createTokenNodeForOption } from "./insert-token.js";
3
+ import { $getEditorTokensInternal, $setEditorTokensInternal, WORD_JOINER, clipboardStringToTokens, getEditorTokens, getEditorTokensFromSelection, setEditorTokens, tokensToClipboardString } from "./serialization.js";
4
4
  export { $getEditorTokensInternal, $insertTokenAtCursor, $setEditorTokensInternal, WORD_JOINER, areTokensEqual, clipboardStringToTokens, createTokenNodeForOption, getEditorTokens, getEditorTokensFromSelection, setEditorTokens, tokensToClipboardString };
@@ -1,6 +1,6 @@
1
1
  import type { PromptEditorAutoCompleteOption } from '../types';
2
2
  /** Create the correct Lexical token decorator node for an autocomplete option. */
3
- export declare const createTokenNodeForOption: (option: PromptEditorAutoCompleteOption) => import("../nodes").InputTokenNode | import("../nodes").OutputTokenNode | import("../nodes").StateTokenNode | import("../nodes").ResourceTokenNode;
3
+ export declare const createTokenNodeForOption: (option: PromptEditorAutoCompleteOption) => import("..").InputTokenNode | import("..").OutputTokenNode | import("..").ResourceTokenNode | import("..").StateTokenNode;
4
4
  /**
5
5
  * Insert a token pill at the current cursor position. Must be called inside an
6
6
  * `editor.update(() => ...)` block.