@uipath/apollo-wind 2.22.0 → 2.24.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.
- package/dist/components/forms/metadata-form.cjs +2 -2
- package/dist/components/forms/metadata-form.js +2 -2
- package/dist/components/ui/index.cjs +92 -82
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/components/ui/prompt-editor/components/EditorToolbar.cjs +156 -0
- package/dist/components/ui/prompt-editor/components/EditorToolbar.d.ts +9 -0
- package/dist/components/ui/prompt-editor/components/EditorToolbar.js +122 -0
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.cjs +205 -0
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.d.ts +14 -0
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.js +161 -0
- package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.cjs +194 -0
- package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.d.ts +28 -0
- package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.js +160 -0
- package/dist/components/ui/prompt-editor/components/TokenPill.cjs +119 -0
- package/dist/components/ui/prompt-editor/components/TokenPill.d.ts +15 -0
- package/dist/components/ui/prompt-editor/components/TokenPill.js +85 -0
- package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.cjs +138 -0
- package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.d.ts +13 -0
- package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.js +104 -0
- package/dist/components/ui/prompt-editor/components/token-icon-markup.cjs +138 -0
- package/dist/components/ui/prompt-editor/components/token-icon-markup.d.ts +16 -0
- package/dist/components/ui/prompt-editor/components/token-icon-markup.js +104 -0
- package/dist/components/ui/prompt-editor/index.cjs +40 -0
- package/dist/components/ui/prompt-editor/index.d.ts +4 -0
- package/dist/components/ui/prompt-editor/index.js +3 -0
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.cjs +145 -0
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.d.ts +30 -0
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.js +105 -0
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.cjs +145 -0
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.d.ts +30 -0
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.js +105 -0
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.cjs +145 -0
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.d.ts +30 -0
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.js +105 -0
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.cjs +145 -0
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.d.ts +30 -0
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.js +105 -0
- package/dist/components/ui/prompt-editor/nodes/index.cjs +72 -0
- package/dist/components/ui/prompt-editor/nodes/index.d.ts +8 -0
- package/dist/components/ui/prompt-editor/nodes/index.js +5 -0
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.cjs +242 -0
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.d.ts +15 -0
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.js +208 -0
- package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.cjs +164 -0
- package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.d.ts +1 -0
- package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.js +130 -0
- package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.cjs +50 -0
- package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.d.ts +4 -0
- package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.js +16 -0
- package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.cjs +108 -0
- package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.d.ts +3 -0
- package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.js +74 -0
- package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.cjs +313 -0
- package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.d.ts +7 -0
- package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.js +276 -0
- package/dist/components/ui/prompt-editor/plugins/RenameTokensPlugin.cjs +186 -0
- package/dist/components/ui/prompt-editor/plugins/RenameTokensPlugin.d.ts +7 -0
- package/dist/components/ui/prompt-editor/plugins/RenameTokensPlugin.js +152 -0
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.cjs +132 -0
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.d.ts +7 -0
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.js +98 -0
- package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.cjs +85 -0
- package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.d.ts +4 -0
- package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.js +51 -0
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.cjs +98 -0
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.d.ts +8 -0
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.js +64 -0
- package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.cjs +137 -0
- package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.d.ts +19 -0
- package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.js +100 -0
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.cjs +49 -0
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.d.ts +8 -0
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.js +12 -0
- package/dist/components/ui/prompt-editor/prompt-editor.cjs +402 -0
- package/dist/components/ui/prompt-editor/prompt-editor.d.ts +35 -0
- package/dist/components/ui/prompt-editor/prompt-editor.js +368 -0
- package/dist/components/ui/prompt-editor/types.cjs +74 -0
- package/dist/components/ui/prompt-editor/types.d.ts +58 -0
- package/dist/components/ui/prompt-editor/types.js +31 -0
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.cjs +60 -0
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.d.ts +29 -0
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.js +20 -0
- package/dist/components/ui/prompt-editor/utils/comparison.cjs +39 -0
- package/dist/components/ui/prompt-editor/utils/comparison.d.ts +3 -0
- package/dist/components/ui/prompt-editor/utils/comparison.js +5 -0
- package/dist/components/ui/prompt-editor/utils/index.cjs +68 -0
- package/dist/components/ui/prompt-editor/utils/index.d.ts +3 -0
- package/dist/components/ui/prompt-editor/utils/index.js +4 -0
- package/dist/components/ui/prompt-editor/utils/insert-token.cjs +103 -0
- package/dist/components/ui/prompt-editor/utils/insert-token.d.ts +12 -0
- package/dist/components/ui/prompt-editor/utils/insert-token.js +66 -0
- package/dist/components/ui/prompt-editor/utils/serialization.cjs +255 -0
- package/dist/components/ui/prompt-editor/utils/serialization.d.ts +16 -0
- package/dist/components/ui/prompt-editor/utils/serialization.js +200 -0
- package/dist/editor-themes/monaco.cjs +2 -2
- package/dist/editor-themes/monaco.js +2 -2
- package/dist/index.cjs +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/styles.css +44 -16
- package/dist/tailwind.utilities.css +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
3
|
+
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
4
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
5
|
+
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
6
|
+
import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
|
|
7
|
+
import { PlainTextPlugin } from "@lexical/react/LexicalPlainTextPlugin";
|
|
8
|
+
import { $getSelection, $isRangeSelection } from "lexical";
|
|
9
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
10
|
+
import { TooltipProvider } from "../tooltip.js";
|
|
11
|
+
import { EditorToolbar } from "./components/EditorToolbar.js";
|
|
12
|
+
import { MarkdownPreview } from "./components/MarkdownPreview.js";
|
|
13
|
+
import { InputTokenNode, OutputTokenNode, ResourceTokenNode, StateTokenNode } from "./nodes/index.js";
|
|
14
|
+
import { AutocompletePlugin } from "./plugins/AutocompletePlugin.js";
|
|
15
|
+
import { CopyPastePlugin } from "./plugins/CopyPastePlugin.js";
|
|
16
|
+
import { EditorRefPlugin } from "./plugins/EditorRefPlugin.js";
|
|
17
|
+
import { MultilinePlugin } from "./plugins/MultilinePlugin.js";
|
|
18
|
+
import { NodeSelectionFixPlugin } from "./plugins/NodeSelectionFixPlugin.js";
|
|
19
|
+
import { RenameTokensPlugin } from "./plugins/RenameTokensPlugin.js";
|
|
20
|
+
import { ToolbarActionsPlugin } from "./plugins/ToolbarActionsPlugin.js";
|
|
21
|
+
import { ValidateTokensPlugin } from "./plugins/ValidateTokensPlugin.js";
|
|
22
|
+
import { ValueSyncPlugin } from "./plugins/ValueSyncPlugin.js";
|
|
23
|
+
import { VariableDropPlugin } from "./plugins/VariableDropPlugin.js";
|
|
24
|
+
import { $getEditorTokensInternal, $insertTokenAtCursor, $setEditorTokensInternal, areTokensEqual } from "./utils/index.js";
|
|
25
|
+
const DEFAULT_MIN_ROWS = 4;
|
|
26
|
+
const DEFAULT_MAX_ROWS = 20;
|
|
27
|
+
const LINE_HEIGHT = 20;
|
|
28
|
+
const EMPTY_AUTOCOMPLETE_OPTIONS = [];
|
|
29
|
+
const EMPTY_TOKENS = [];
|
|
30
|
+
const toTokenArray = (v)=>void 0 === v ? void 0 : Array.isArray(v) ? v : EMPTY_TOKENS;
|
|
31
|
+
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, mapVarDropToToken, toolbarActionsRef, showToolbar }, ref)=>{
|
|
32
|
+
const editorRef = useRef(null);
|
|
33
|
+
const [isEmpty, setIsEmpty] = useState(()=>{
|
|
34
|
+
const seed = initialValue ?? value;
|
|
35
|
+
return !seed || 0 === seed.length;
|
|
36
|
+
});
|
|
37
|
+
const initializedRef = useRef(false);
|
|
38
|
+
const onChangeRef = useRef(onChange);
|
|
39
|
+
const isEmptyRef = useRef(isEmpty);
|
|
40
|
+
const debounceTimerRef = useRef(null);
|
|
41
|
+
const pendingTokensRef = useRef(null);
|
|
42
|
+
const lastEmittedValueRef = useRef(null);
|
|
43
|
+
const isMountedRef = useRef(true);
|
|
44
|
+
const isSyncingRef = useRef(false);
|
|
45
|
+
onChangeRef.current = onChange;
|
|
46
|
+
isEmptyRef.current = isEmpty;
|
|
47
|
+
useImperativeHandle(ref, ()=>({
|
|
48
|
+
setTokens: (tokens)=>{
|
|
49
|
+
if (editorRef.current) editorRef.current.update(()=>{
|
|
50
|
+
$setEditorTokensInternal(tokens);
|
|
51
|
+
});
|
|
52
|
+
else onChangeRef.current?.(tokens);
|
|
53
|
+
},
|
|
54
|
+
insertAutocompleteTrigger: ()=>{
|
|
55
|
+
const editor = editorRef.current;
|
|
56
|
+
if (!editor) return;
|
|
57
|
+
editor.focus();
|
|
58
|
+
editor.update(()=>{
|
|
59
|
+
const selection = $getSelection();
|
|
60
|
+
if ($isRangeSelection(selection)) selection.insertRawText('$');
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
insertVariableToken: (option)=>{
|
|
64
|
+
const editor = editorRef.current;
|
|
65
|
+
if (!editor) return;
|
|
66
|
+
editor.focus();
|
|
67
|
+
editor.update(()=>{
|
|
68
|
+
$insertTokenAtCursor(option);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}), []);
|
|
72
|
+
const contentEditableStyle = useMemo(()=>{
|
|
73
|
+
const verticalPadding = 8;
|
|
74
|
+
const textColor = borderless ? 'inherit' : 'var(--color-foreground)';
|
|
75
|
+
const base = {
|
|
76
|
+
width: '100%',
|
|
77
|
+
outline: 'none',
|
|
78
|
+
userSelect: 'text',
|
|
79
|
+
boxSizing: 'border-box',
|
|
80
|
+
padding: '8px 12px',
|
|
81
|
+
fontFamily: "'Noto Sans', sans-serif",
|
|
82
|
+
fontSize: '14px',
|
|
83
|
+
lineHeight: `${LINE_HEIGHT}px`,
|
|
84
|
+
color: textColor
|
|
85
|
+
};
|
|
86
|
+
if (!multiline) return {
|
|
87
|
+
...base,
|
|
88
|
+
height: '36px',
|
|
89
|
+
maxHeight: '36px',
|
|
90
|
+
overflowX: 'auto',
|
|
91
|
+
overflowY: 'hidden',
|
|
92
|
+
whiteSpace: 'nowrap'
|
|
93
|
+
};
|
|
94
|
+
const effectiveMinRows = Math.min(minRows, maxRows);
|
|
95
|
+
const minHeight = effectiveMinRows * LINE_HEIGHT + 2 * verticalPadding;
|
|
96
|
+
const maxHeight = maxRows * LINE_HEIGHT + 2 * verticalPadding;
|
|
97
|
+
return {
|
|
98
|
+
...base,
|
|
99
|
+
minHeight: `${minHeight}px`,
|
|
100
|
+
...fillHeight ? {
|
|
101
|
+
flex: 1
|
|
102
|
+
} : {
|
|
103
|
+
maxHeight: `${maxHeight}px`
|
|
104
|
+
},
|
|
105
|
+
overflowY: 'auto'
|
|
106
|
+
};
|
|
107
|
+
}, [
|
|
108
|
+
multiline,
|
|
109
|
+
minRows,
|
|
110
|
+
maxRows,
|
|
111
|
+
fillHeight,
|
|
112
|
+
borderless
|
|
113
|
+
]);
|
|
114
|
+
const handleEditorRef = useCallback((editor)=>{
|
|
115
|
+
editorRef.current = editor;
|
|
116
|
+
}, []);
|
|
117
|
+
const handleChange = useCallback(()=>{
|
|
118
|
+
if (!editorRef.current) return;
|
|
119
|
+
editorRef.current.getEditorState().read(()=>{
|
|
120
|
+
const tokens = $getEditorTokensInternal();
|
|
121
|
+
const newIsEmpty = 0 === tokens.length || 1 === tokens.length && 'text' === tokens[0].type && '' === tokens[0].value;
|
|
122
|
+
if (newIsEmpty !== isEmptyRef.current) setIsEmpty(newIsEmpty);
|
|
123
|
+
if (!isSyncingRef.current) pendingTokensRef.current = tokens;
|
|
124
|
+
});
|
|
125
|
+
if (isSyncingRef.current || !onChangeRef.current) return;
|
|
126
|
+
if (debounceTimerRef.current) clearTimeout(debounceTimerRef.current);
|
|
127
|
+
debounceTimerRef.current = setTimeout(()=>{
|
|
128
|
+
if (!isMountedRef.current || !pendingTokensRef.current || !onChangeRef.current || !editorRef.current || isSyncingRef.current) return;
|
|
129
|
+
lastEmittedValueRef.current = pendingTokensRef.current;
|
|
130
|
+
onChangeRef.current(pendingTokensRef.current);
|
|
131
|
+
pendingTokensRef.current = null;
|
|
132
|
+
}, 0);
|
|
133
|
+
}, []);
|
|
134
|
+
useEffect(()=>{
|
|
135
|
+
if (value && lastEmittedValueRef.current && !areTokensEqual(value, lastEmittedValueRef.current)) lastEmittedValueRef.current = null;
|
|
136
|
+
}, [
|
|
137
|
+
value
|
|
138
|
+
]);
|
|
139
|
+
useEffect(()=>{
|
|
140
|
+
isMountedRef.current = true;
|
|
141
|
+
return ()=>{
|
|
142
|
+
isMountedRef.current = false;
|
|
143
|
+
if (debounceTimerRef.current) {
|
|
144
|
+
clearTimeout(debounceTimerRef.current);
|
|
145
|
+
debounceTimerRef.current = null;
|
|
146
|
+
}
|
|
147
|
+
pendingTokensRef.current = null;
|
|
148
|
+
};
|
|
149
|
+
}, []);
|
|
150
|
+
useEffect(()=>{
|
|
151
|
+
const seed = initialValue ?? value;
|
|
152
|
+
if (!editorRef.current || !seed || initializedRef.current) return;
|
|
153
|
+
const valueToSet = seed;
|
|
154
|
+
queueMicrotask(()=>{
|
|
155
|
+
if (!editorRef.current || initializedRef.current) return;
|
|
156
|
+
editorRef.current.update(()=>{
|
|
157
|
+
$setEditorTokensInternal(valueToSet);
|
|
158
|
+
setIsEmpty(0 === valueToSet.length);
|
|
159
|
+
initializedRef.current = true;
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}, []);
|
|
163
|
+
useEffect(()=>{
|
|
164
|
+
if (!editorRef.current) return;
|
|
165
|
+
editorRef.current.setEditable(!disabled);
|
|
166
|
+
}, [
|
|
167
|
+
disabled
|
|
168
|
+
]);
|
|
169
|
+
const options = Array.isArray(autoCompleteOptions) ? autoCompleteOptions : EMPTY_AUTOCOMPLETE_OPTIONS;
|
|
170
|
+
const wrapperClassName = borderless ? 'flex flex-col w-full relative' : `prompt-editor-shell flex flex-col w-full relative border bg-background ${showToolbar ? 'border-t-0 rounded-b-md' : 'rounded-md'}`;
|
|
171
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
172
|
+
className: wrapperClassName,
|
|
173
|
+
style: {
|
|
174
|
+
fontFamily: "'Noto Sans', sans-serif",
|
|
175
|
+
fontSize: '14px',
|
|
176
|
+
lineHeight: '20px',
|
|
177
|
+
...fillHeight ? {
|
|
178
|
+
flex: 1,
|
|
179
|
+
minHeight: 0
|
|
180
|
+
} : {}
|
|
181
|
+
},
|
|
182
|
+
children: [
|
|
183
|
+
/*#__PURE__*/ jsx("style", {
|
|
184
|
+
children: `
|
|
185
|
+
.prompt-editor-paragraph { padding: 0; margin: 0; }
|
|
186
|
+
${borderless ? '' : '.prompt-editor-shell:focus-within { border-color: var(--color-ring); box-shadow: 0 0 0 1px var(--color-ring); }'}
|
|
187
|
+
.prompt-editor-root *::selection { background-color: color-mix(in srgb, var(--color-primary) 30%, transparent); }
|
|
188
|
+
`
|
|
189
|
+
}),
|
|
190
|
+
/*#__PURE__*/ jsxs("div", {
|
|
191
|
+
className: "prompt-editor-root",
|
|
192
|
+
style: {
|
|
193
|
+
position: 'relative',
|
|
194
|
+
...fillHeight ? {
|
|
195
|
+
flex: 1,
|
|
196
|
+
display: 'flex',
|
|
197
|
+
flexDirection: 'column',
|
|
198
|
+
minHeight: 0
|
|
199
|
+
} : {}
|
|
200
|
+
},
|
|
201
|
+
children: [
|
|
202
|
+
/*#__PURE__*/ jsx(PlainTextPlugin, {
|
|
203
|
+
contentEditable: /*#__PURE__*/ jsx(ContentEditable, {
|
|
204
|
+
style: contentEditableStyle,
|
|
205
|
+
ariaLabel: ariaLabel
|
|
206
|
+
}),
|
|
207
|
+
placeholder: null,
|
|
208
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
209
|
+
}),
|
|
210
|
+
placeholder && isEmpty && /*#__PURE__*/ jsx("div", {
|
|
211
|
+
style: {
|
|
212
|
+
position: 'absolute',
|
|
213
|
+
top: '8px',
|
|
214
|
+
left: '12px',
|
|
215
|
+
right: '12px',
|
|
216
|
+
pointerEvents: 'none',
|
|
217
|
+
userSelect: 'none',
|
|
218
|
+
fontFamily: "'Noto Sans', sans-serif",
|
|
219
|
+
fontSize: '14px',
|
|
220
|
+
lineHeight: '20px',
|
|
221
|
+
...multiline ? {} : {
|
|
222
|
+
whiteSpace: 'nowrap',
|
|
223
|
+
overflow: 'hidden',
|
|
224
|
+
textOverflow: 'ellipsis'
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
className: "text-muted-foreground/60",
|
|
228
|
+
children: placeholder
|
|
229
|
+
})
|
|
230
|
+
]
|
|
231
|
+
}),
|
|
232
|
+
/*#__PURE__*/ jsx(HistoryPlugin, {}),
|
|
233
|
+
/*#__PURE__*/ jsx(NodeSelectionFixPlugin, {}),
|
|
234
|
+
/*#__PURE__*/ jsx(CopyPastePlugin, {}),
|
|
235
|
+
/*#__PURE__*/ jsx(EditorRefPlugin, {
|
|
236
|
+
onRef: handleEditorRef
|
|
237
|
+
}),
|
|
238
|
+
/*#__PURE__*/ jsx(ValueSyncPlugin, {
|
|
239
|
+
value: value,
|
|
240
|
+
editorRef: editorRef,
|
|
241
|
+
lastEmittedValueRef: lastEmittedValueRef,
|
|
242
|
+
isSyncingRef: isSyncingRef
|
|
243
|
+
}),
|
|
244
|
+
/*#__PURE__*/ jsx(MultilinePlugin, {
|
|
245
|
+
multiline: multiline
|
|
246
|
+
}),
|
|
247
|
+
/*#__PURE__*/ jsx(OnChangePlugin, {
|
|
248
|
+
ignoreSelectionChange: true,
|
|
249
|
+
onChange: handleChange
|
|
250
|
+
}),
|
|
251
|
+
/*#__PURE__*/ jsx(ToolbarActionsPlugin, {
|
|
252
|
+
actionsRef: toolbarActionsRef
|
|
253
|
+
}),
|
|
254
|
+
options.length > 0 && /*#__PURE__*/ jsx(AutocompletePlugin, {
|
|
255
|
+
options: options
|
|
256
|
+
}),
|
|
257
|
+
/*#__PURE__*/ jsx(ValidateTokensPlugin, {
|
|
258
|
+
options: options
|
|
259
|
+
}),
|
|
260
|
+
options.length > 0 && /*#__PURE__*/ jsx(RenameTokensPlugin, {
|
|
261
|
+
options: options,
|
|
262
|
+
onChange: onChange
|
|
263
|
+
}),
|
|
264
|
+
mapVarDropToToken && /*#__PURE__*/ jsx(VariableDropPlugin, {
|
|
265
|
+
mapVarDropToToken: mapVarDropToToken,
|
|
266
|
+
disabled: disabled
|
|
267
|
+
})
|
|
268
|
+
]
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
EditorInner.displayName = 'PromptEditorInner';
|
|
272
|
+
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, mapVarDropToToken })=>{
|
|
273
|
+
const value = toTokenArray(rawValue);
|
|
274
|
+
const initialValue = toTokenArray(rawInitialValue);
|
|
275
|
+
const [internalMode, setInternalMode] = useState('edit');
|
|
276
|
+
const mode = controlledMode ?? internalMode;
|
|
277
|
+
const toolbarActionsRef = useRef(null);
|
|
278
|
+
const [uncontrolledPreviewTokens, setUncontrolledPreviewTokens] = useState(initialValue ?? []);
|
|
279
|
+
const handleModeChange = useCallback((newMode)=>{
|
|
280
|
+
if (onModeChange) onModeChange(newMode);
|
|
281
|
+
else setInternalMode(newMode);
|
|
282
|
+
}, [
|
|
283
|
+
onModeChange
|
|
284
|
+
]);
|
|
285
|
+
const initialConfig = useMemo(()=>({
|
|
286
|
+
namespace: 'PromptEditor',
|
|
287
|
+
theme: {
|
|
288
|
+
paragraph: 'prompt-editor-paragraph'
|
|
289
|
+
},
|
|
290
|
+
onError: (error)=>console.error('PromptEditor error:', error),
|
|
291
|
+
nodes: [
|
|
292
|
+
InputTokenNode,
|
|
293
|
+
OutputTokenNode,
|
|
294
|
+
StateTokenNode,
|
|
295
|
+
ResourceTokenNode
|
|
296
|
+
]
|
|
297
|
+
}), []);
|
|
298
|
+
const isControlled = void 0 !== value;
|
|
299
|
+
const previewTokens = isControlled ? value : uncontrolledPreviewTokens;
|
|
300
|
+
const handleEditorChange = useCallback((tokens)=>{
|
|
301
|
+
if (!isControlled) setUncontrolledPreviewTokens(tokens);
|
|
302
|
+
onChange?.(tokens);
|
|
303
|
+
}, [
|
|
304
|
+
isControlled,
|
|
305
|
+
onChange
|
|
306
|
+
]);
|
|
307
|
+
return /*#__PURE__*/ jsx(TooltipProvider, {
|
|
308
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
309
|
+
style: {
|
|
310
|
+
display: 'flex',
|
|
311
|
+
flexDirection: 'column',
|
|
312
|
+
width: '100%',
|
|
313
|
+
...fillHeight ? {
|
|
314
|
+
flex: 1,
|
|
315
|
+
minHeight: 0
|
|
316
|
+
} : {}
|
|
317
|
+
},
|
|
318
|
+
children: [
|
|
319
|
+
showToolbar && /*#__PURE__*/ jsx(EditorToolbar, {
|
|
320
|
+
mode: mode,
|
|
321
|
+
disabled: disabled,
|
|
322
|
+
actionsRef: toolbarActionsRef,
|
|
323
|
+
onModeChange: handleModeChange,
|
|
324
|
+
onFullscreen: onFullscreen
|
|
325
|
+
}),
|
|
326
|
+
'preview' === mode && /*#__PURE__*/ jsx("div", {
|
|
327
|
+
className: borderless ? void 0 : `border bg-background ${showToolbar ? 'border-t-0 rounded-b-md' : 'rounded-md'}`,
|
|
328
|
+
children: /*#__PURE__*/ jsx(MarkdownPreview, {
|
|
329
|
+
tokens: previewTokens,
|
|
330
|
+
minRows: minRows
|
|
331
|
+
})
|
|
332
|
+
}),
|
|
333
|
+
/*#__PURE__*/ jsx("div", {
|
|
334
|
+
style: {
|
|
335
|
+
display: 'preview' === mode ? 'none' : 'flex',
|
|
336
|
+
flexDirection: 'column',
|
|
337
|
+
...fillHeight ? {
|
|
338
|
+
flex: 1,
|
|
339
|
+
minHeight: 0
|
|
340
|
+
} : {}
|
|
341
|
+
},
|
|
342
|
+
children: /*#__PURE__*/ jsx(LexicalComposer, {
|
|
343
|
+
initialConfig: initialConfig,
|
|
344
|
+
children: /*#__PURE__*/ jsx(EditorInner, {
|
|
345
|
+
ref: editorRef,
|
|
346
|
+
autoCompleteOptions: autoCompleteOptions,
|
|
347
|
+
disabled: disabled,
|
|
348
|
+
ariaLabel: ariaLabel,
|
|
349
|
+
initialValue: initialValue,
|
|
350
|
+
maxRows: maxRows,
|
|
351
|
+
minRows: minRows,
|
|
352
|
+
multiline: multiline,
|
|
353
|
+
placeholder: placeholder,
|
|
354
|
+
fillHeight: fillHeight,
|
|
355
|
+
borderless: borderless,
|
|
356
|
+
mapVarDropToToken: mapVarDropToToken,
|
|
357
|
+
showToolbar: showToolbar,
|
|
358
|
+
toolbarActionsRef: toolbarActionsRef,
|
|
359
|
+
value: value,
|
|
360
|
+
onChange: handleEditorChange
|
|
361
|
+
})
|
|
362
|
+
})
|
|
363
|
+
})
|
|
364
|
+
]
|
|
365
|
+
})
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
export { PromptEditor };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
getPromptEditorTokenColors: ()=>getPromptEditorTokenColors,
|
|
28
|
+
getPromptEditorTokenTypeLabel: ()=>getPromptEditorTokenTypeLabel,
|
|
29
|
+
isPromptEditorNonTextToken: ()=>isPromptEditorNonTextToken,
|
|
30
|
+
isPromptEditorTextToken: ()=>isPromptEditorTextToken
|
|
31
|
+
});
|
|
32
|
+
const getPromptEditorTokenColors = ()=>({
|
|
33
|
+
valid: {
|
|
34
|
+
background: 'var(--color-primary-lighter)',
|
|
35
|
+
border: 'var(--color-primary)',
|
|
36
|
+
text: 'var(--color-foreground)',
|
|
37
|
+
icon: 'var(--color-primary)'
|
|
38
|
+
},
|
|
39
|
+
invalid: {
|
|
40
|
+
background: 'var(--color-error-background)',
|
|
41
|
+
border: 'var(--color-error)',
|
|
42
|
+
text: 'var(--color-error-text)',
|
|
43
|
+
icon: 'var(--color-error-icon)'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const getPromptEditorTokenTypeLabel = (type)=>{
|
|
47
|
+
switch(type){
|
|
48
|
+
case 'input':
|
|
49
|
+
return 'Input variable';
|
|
50
|
+
case 'output':
|
|
51
|
+
return 'Output variable';
|
|
52
|
+
case 'state':
|
|
53
|
+
return 'State variable';
|
|
54
|
+
case 'resource':
|
|
55
|
+
return 'Resource';
|
|
56
|
+
default:
|
|
57
|
+
return 'Text';
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const isPromptEditorTextToken = (token)=>'text' === token.type;
|
|
61
|
+
const isPromptEditorNonTextToken = (token)=>'text' !== token.type;
|
|
62
|
+
exports.getPromptEditorTokenColors = __webpack_exports__.getPromptEditorTokenColors;
|
|
63
|
+
exports.getPromptEditorTokenTypeLabel = __webpack_exports__.getPromptEditorTokenTypeLabel;
|
|
64
|
+
exports.isPromptEditorNonTextToken = __webpack_exports__.isPromptEditorNonTextToken;
|
|
65
|
+
exports.isPromptEditorTextToken = __webpack_exports__.isPromptEditorTextToken;
|
|
66
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
67
|
+
"getPromptEditorTokenColors",
|
|
68
|
+
"getPromptEditorTokenTypeLabel",
|
|
69
|
+
"isPromptEditorNonTextToken",
|
|
70
|
+
"isPromptEditorTextToken"
|
|
71
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
72
|
+
Object.defineProperty(exports, '__esModule', {
|
|
73
|
+
value: true
|
|
74
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type PromptEditorTokenType = 'input' | 'output' | 'state' | 'resource' | 'text';
|
|
2
|
+
interface BaseToken {
|
|
3
|
+
type: PromptEditorTokenType;
|
|
4
|
+
/**
|
|
5
|
+
* Variable path **without** a leading `$` — e.g. `vars.firstName`, `state.retryCount`. apollo-wind
|
|
6
|
+
* owns this no-`$` convention (unlike flow-workbench's `$vars.firstName`). Serialization and
|
|
7
|
+
* `ValidateTokensPlugin` compare these by exact string equality against
|
|
8
|
+
* {@link PromptEditorAutoCompleteOption.value}, so the two must use the same `$`-less form.
|
|
9
|
+
*/
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PromptEditorTextToken extends BaseToken {
|
|
13
|
+
type: 'text';
|
|
14
|
+
}
|
|
15
|
+
export interface PromptEditorInputToken extends BaseToken {
|
|
16
|
+
type: 'input';
|
|
17
|
+
}
|
|
18
|
+
export interface PromptEditorOutputToken extends BaseToken {
|
|
19
|
+
type: 'output';
|
|
20
|
+
}
|
|
21
|
+
export interface PromptEditorStateToken extends BaseToken {
|
|
22
|
+
type: 'state';
|
|
23
|
+
}
|
|
24
|
+
export interface PromptEditorResourceToken extends BaseToken {
|
|
25
|
+
type: 'resource';
|
|
26
|
+
}
|
|
27
|
+
export type PromptEditorToken = PromptEditorInputToken | PromptEditorOutputToken | PromptEditorStateToken | PromptEditorResourceToken | PromptEditorTextToken;
|
|
28
|
+
export interface PromptEditorAutoCompleteOption {
|
|
29
|
+
type: Exclude<PromptEditorTokenType, 'text'>;
|
|
30
|
+
/** Variable path without a leading `$` (e.g. `vars.firstName`). See {@link PromptEditorToken} value. */
|
|
31
|
+
value: string;
|
|
32
|
+
}
|
|
33
|
+
export type PromptEditorMode = 'edit' | 'preview';
|
|
34
|
+
export interface PromptEditorToolbarActionsRef {
|
|
35
|
+
formatBold: () => void;
|
|
36
|
+
formatItalic: () => void;
|
|
37
|
+
formatStrikethrough: () => void;
|
|
38
|
+
formatNumberedList: () => void;
|
|
39
|
+
formatBulletedList: () => void;
|
|
40
|
+
}
|
|
41
|
+
export type PromptEditorToolbarFormatAction = 'bold' | 'bulletedList' | 'italic' | 'numberedList' | 'strikethrough';
|
|
42
|
+
export interface PromptEditorTokenColorConfig {
|
|
43
|
+
background: string;
|
|
44
|
+
border: string;
|
|
45
|
+
text: string;
|
|
46
|
+
icon: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Two-state palette: invalid = red, valid = blue. Backed by apollo-wind's semantic design tokens,
|
|
50
|
+
* which already resolve per light/dark theme via CSS — no JS theme detection needed.
|
|
51
|
+
*/
|
|
52
|
+
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;
|
|
55
|
+
export type PromptEditorDiffType = 'added' | 'removed';
|
|
56
|
+
export declare const isPromptEditorTextToken: (token: PromptEditorToken) => token is PromptEditorTextToken;
|
|
57
|
+
export declare const isPromptEditorNonTextToken: (token: PromptEditorToken) => token is Exclude<PromptEditorToken, PromptEditorTextToken>;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const getPromptEditorTokenColors = ()=>({
|
|
2
|
+
valid: {
|
|
3
|
+
background: 'var(--color-primary-lighter)',
|
|
4
|
+
border: 'var(--color-primary)',
|
|
5
|
+
text: 'var(--color-foreground)',
|
|
6
|
+
icon: 'var(--color-primary)'
|
|
7
|
+
},
|
|
8
|
+
invalid: {
|
|
9
|
+
background: 'var(--color-error-background)',
|
|
10
|
+
border: 'var(--color-error)',
|
|
11
|
+
text: 'var(--color-error-text)',
|
|
12
|
+
icon: 'var(--color-error-icon)'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const getPromptEditorTokenTypeLabel = (type)=>{
|
|
16
|
+
switch(type){
|
|
17
|
+
case 'input':
|
|
18
|
+
return 'Input variable';
|
|
19
|
+
case 'output':
|
|
20
|
+
return 'Output variable';
|
|
21
|
+
case 'state':
|
|
22
|
+
return 'State variable';
|
|
23
|
+
case 'resource':
|
|
24
|
+
return 'Resource';
|
|
25
|
+
default:
|
|
26
|
+
return 'Text';
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const isPromptEditorTextToken = (token)=>'text' === token.type;
|
|
30
|
+
const isPromptEditorNonTextToken = (token)=>'text' !== token.type;
|
|
31
|
+
export { getPromptEditorTokenColors, getPromptEditorTokenTypeLabel, isPromptEditorNonTextToken, isPromptEditorTextToken };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
VARIABLE_PATH_REGEX: ()=>VARIABLE_PATH_REGEX,
|
|
28
|
+
inferTokenTypeFromPath: ()=>inferTokenTypeFromPath,
|
|
29
|
+
shouldSuppressOpenForDismissed: ()=>shouldSuppressOpenForDismissed
|
|
30
|
+
});
|
|
31
|
+
const NAMESPACE_TOKEN_TYPE = {
|
|
32
|
+
state: 'state',
|
|
33
|
+
resource: 'resource'
|
|
34
|
+
};
|
|
35
|
+
const inferTokenTypeFromPath = (path, options)=>{
|
|
36
|
+
for (const opt of options)if (opt.value === path) return opt.type;
|
|
37
|
+
const segments = path.split('.');
|
|
38
|
+
while(segments.length > 1){
|
|
39
|
+
segments.pop();
|
|
40
|
+
const prefix = segments.join('.');
|
|
41
|
+
for (const opt of options)if (opt.value === prefix) return opt.type;
|
|
42
|
+
}
|
|
43
|
+
return NAMESPACE_TOKEN_TYPE[path.split('.')[0]] ?? 'input';
|
|
44
|
+
};
|
|
45
|
+
const VARIABLE_PATH_REGEX = /^(?:vars|metadata|agent|state|resource)\.[a-zA-Z_][a-zA-Z0-9_.]*$/;
|
|
46
|
+
function shouldSuppressOpenForDismissed(trigger, dismissed) {
|
|
47
|
+
if (!dismissed) return false;
|
|
48
|
+
return dismissed.nodeKey === trigger.nodeKey && dismissed.triggerIndex === trigger.triggerIndex;
|
|
49
|
+
}
|
|
50
|
+
exports.VARIABLE_PATH_REGEX = __webpack_exports__.VARIABLE_PATH_REGEX;
|
|
51
|
+
exports.inferTokenTypeFromPath = __webpack_exports__.inferTokenTypeFromPath;
|
|
52
|
+
exports.shouldSuppressOpenForDismissed = __webpack_exports__.shouldSuppressOpenForDismissed;
|
|
53
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
54
|
+
"VARIABLE_PATH_REGEX",
|
|
55
|
+
"inferTokenTypeFromPath",
|
|
56
|
+
"shouldSuppressOpenForDismissed"
|
|
57
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
58
|
+
Object.defineProperty(exports, '__esModule', {
|
|
59
|
+
value: true
|
|
60
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PromptEditorAutoCompleteOption, PromptEditorTokenType } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Infer the token type for a typed-but-unmatched path by walking up parent prefixes in the option set.
|
|
4
|
+
* Mirrors `findVariableForPath`'s ancestor-fallback shape so a free-form chip inherits the closest
|
|
5
|
+
* known parent's type. With no matching ancestor, falls back to the leading namespace (`state.*` →
|
|
6
|
+
* `state`, `resource.*` → `resource`) so those chips get the right node type even before a matching
|
|
7
|
+
* option exists; everything else (`vars.*`, `metadata.*`, `agent.*`) defaults to `'input'`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const inferTokenTypeFromPath: (path: string, options: PromptEditorAutoCompleteOption[]) => Exclude<PromptEditorTokenType, "text">;
|
|
10
|
+
/**
|
|
11
|
+
* Recognised free-form path syntax for committing typed-but-unmatched paths as chips. Covers the
|
|
12
|
+
* namespaces apollo-wind's public token types/options use — `vars`/`metadata`/`agent` plus `state`
|
|
13
|
+
* and `resource` (the `state.*` / `resource.*` examples in the stories), so free-form state/resource
|
|
14
|
+
* paths can be committed the same as input/output ones.
|
|
15
|
+
*/
|
|
16
|
+
export declare const VARIABLE_PATH_REGEX: RegExp;
|
|
17
|
+
/** Identifier for the `$` position the picker was last dismissed for. */
|
|
18
|
+
export interface TriggerKey {
|
|
19
|
+
triggerIndex: number;
|
|
20
|
+
nodeKey: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Decide whether the autocomplete should suppress reopening. After the user dismisses the picker
|
|
24
|
+
* (Escape, click-outside), we remember the dismissed `$` position and don't reopen for it on a
|
|
25
|
+
* cursor-only return — gives the user a window to Backspace the `$` without the picker grabbing
|
|
26
|
+
* focus again. Once the editor's text changes (any new typing), the dismissal sentinel is cleared
|
|
27
|
+
* and the next valid trigger opens the picker fresh.
|
|
28
|
+
*/
|
|
29
|
+
export declare function shouldSuppressOpenForDismissed(trigger: TriggerKey, dismissed: TriggerKey | null): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const NAMESPACE_TOKEN_TYPE = {
|
|
2
|
+
state: 'state',
|
|
3
|
+
resource: 'resource'
|
|
4
|
+
};
|
|
5
|
+
const inferTokenTypeFromPath = (path, options)=>{
|
|
6
|
+
for (const opt of options)if (opt.value === path) return opt.type;
|
|
7
|
+
const segments = path.split('.');
|
|
8
|
+
while(segments.length > 1){
|
|
9
|
+
segments.pop();
|
|
10
|
+
const prefix = segments.join('.');
|
|
11
|
+
for (const opt of options)if (opt.value === prefix) return opt.type;
|
|
12
|
+
}
|
|
13
|
+
return NAMESPACE_TOKEN_TYPE[path.split('.')[0]] ?? 'input';
|
|
14
|
+
};
|
|
15
|
+
const VARIABLE_PATH_REGEX = /^(?:vars|metadata|agent|state|resource)\.[a-zA-Z_][a-zA-Z0-9_.]*$/;
|
|
16
|
+
function shouldSuppressOpenForDismissed(trigger, dismissed) {
|
|
17
|
+
if (!dismissed) return false;
|
|
18
|
+
return dismissed.nodeKey === trigger.nodeKey && dismissed.triggerIndex === trigger.triggerIndex;
|
|
19
|
+
}
|
|
20
|
+
export { VARIABLE_PATH_REGEX, inferTokenTypeFromPath, shouldSuppressOpenForDismissed };
|