@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,402 @@
|
|
|
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
|
+
PromptEditor: ()=>PromptEditor
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const LexicalComposer_namespaceObject = require("@lexical/react/LexicalComposer");
|
|
31
|
+
const LexicalContentEditable_namespaceObject = require("@lexical/react/LexicalContentEditable");
|
|
32
|
+
const LexicalErrorBoundary_namespaceObject = require("@lexical/react/LexicalErrorBoundary");
|
|
33
|
+
const LexicalHistoryPlugin_namespaceObject = require("@lexical/react/LexicalHistoryPlugin");
|
|
34
|
+
const LexicalOnChangePlugin_namespaceObject = require("@lexical/react/LexicalOnChangePlugin");
|
|
35
|
+
const LexicalPlainTextPlugin_namespaceObject = require("@lexical/react/LexicalPlainTextPlugin");
|
|
36
|
+
const external_lexical_namespaceObject = require("lexical");
|
|
37
|
+
const external_react_namespaceObject = require("react");
|
|
38
|
+
const external_tooltip_cjs_namespaceObject = require("../tooltip.cjs");
|
|
39
|
+
const EditorToolbar_cjs_namespaceObject = require("./components/EditorToolbar.cjs");
|
|
40
|
+
const MarkdownPreview_cjs_namespaceObject = require("./components/MarkdownPreview.cjs");
|
|
41
|
+
const index_cjs_namespaceObject = require("./nodes/index.cjs");
|
|
42
|
+
const AutocompletePlugin_cjs_namespaceObject = require("./plugins/AutocompletePlugin.cjs");
|
|
43
|
+
const CopyPastePlugin_cjs_namespaceObject = require("./plugins/CopyPastePlugin.cjs");
|
|
44
|
+
const EditorRefPlugin_cjs_namespaceObject = require("./plugins/EditorRefPlugin.cjs");
|
|
45
|
+
const MultilinePlugin_cjs_namespaceObject = require("./plugins/MultilinePlugin.cjs");
|
|
46
|
+
const NodeSelectionFixPlugin_cjs_namespaceObject = require("./plugins/NodeSelectionFixPlugin.cjs");
|
|
47
|
+
const RenameTokensPlugin_cjs_namespaceObject = require("./plugins/RenameTokensPlugin.cjs");
|
|
48
|
+
const ToolbarActionsPlugin_cjs_namespaceObject = require("./plugins/ToolbarActionsPlugin.cjs");
|
|
49
|
+
const ValidateTokensPlugin_cjs_namespaceObject = require("./plugins/ValidateTokensPlugin.cjs");
|
|
50
|
+
const ValueSyncPlugin_cjs_namespaceObject = require("./plugins/ValueSyncPlugin.cjs");
|
|
51
|
+
const VariableDropPlugin_cjs_namespaceObject = require("./plugins/VariableDropPlugin.cjs");
|
|
52
|
+
const external_utils_index_cjs_namespaceObject = require("./utils/index.cjs");
|
|
53
|
+
const DEFAULT_MIN_ROWS = 4;
|
|
54
|
+
const DEFAULT_MAX_ROWS = 20;
|
|
55
|
+
const LINE_HEIGHT = 20;
|
|
56
|
+
const EMPTY_AUTOCOMPLETE_OPTIONS = [];
|
|
57
|
+
const EMPTY_TOKENS = [];
|
|
58
|
+
const toTokenArray = (v)=>void 0 === v ? void 0 : Array.isArray(v) ? v : EMPTY_TOKENS;
|
|
59
|
+
const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.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)=>{
|
|
60
|
+
const editorRef = (0, external_react_namespaceObject.useRef)(null);
|
|
61
|
+
const [isEmpty, setIsEmpty] = (0, external_react_namespaceObject.useState)(()=>{
|
|
62
|
+
const seed = initialValue ?? value;
|
|
63
|
+
return !seed || 0 === seed.length;
|
|
64
|
+
});
|
|
65
|
+
const initializedRef = (0, external_react_namespaceObject.useRef)(false);
|
|
66
|
+
const onChangeRef = (0, external_react_namespaceObject.useRef)(onChange);
|
|
67
|
+
const isEmptyRef = (0, external_react_namespaceObject.useRef)(isEmpty);
|
|
68
|
+
const debounceTimerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
69
|
+
const pendingTokensRef = (0, external_react_namespaceObject.useRef)(null);
|
|
70
|
+
const lastEmittedValueRef = (0, external_react_namespaceObject.useRef)(null);
|
|
71
|
+
const isMountedRef = (0, external_react_namespaceObject.useRef)(true);
|
|
72
|
+
const isSyncingRef = (0, external_react_namespaceObject.useRef)(false);
|
|
73
|
+
onChangeRef.current = onChange;
|
|
74
|
+
isEmptyRef.current = isEmpty;
|
|
75
|
+
(0, external_react_namespaceObject.useImperativeHandle)(ref, ()=>({
|
|
76
|
+
setTokens: (tokens)=>{
|
|
77
|
+
if (editorRef.current) editorRef.current.update(()=>{
|
|
78
|
+
(0, external_utils_index_cjs_namespaceObject.$setEditorTokensInternal)(tokens);
|
|
79
|
+
});
|
|
80
|
+
else onChangeRef.current?.(tokens);
|
|
81
|
+
},
|
|
82
|
+
insertAutocompleteTrigger: ()=>{
|
|
83
|
+
const editor = editorRef.current;
|
|
84
|
+
if (!editor) return;
|
|
85
|
+
editor.focus();
|
|
86
|
+
editor.update(()=>{
|
|
87
|
+
const selection = (0, external_lexical_namespaceObject.$getSelection)();
|
|
88
|
+
if ((0, external_lexical_namespaceObject.$isRangeSelection)(selection)) selection.insertRawText('$');
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
insertVariableToken: (option)=>{
|
|
92
|
+
const editor = editorRef.current;
|
|
93
|
+
if (!editor) return;
|
|
94
|
+
editor.focus();
|
|
95
|
+
editor.update(()=>{
|
|
96
|
+
(0, external_utils_index_cjs_namespaceObject.$insertTokenAtCursor)(option);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}), []);
|
|
100
|
+
const contentEditableStyle = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
101
|
+
const verticalPadding = 8;
|
|
102
|
+
const textColor = borderless ? 'inherit' : 'var(--color-foreground)';
|
|
103
|
+
const base = {
|
|
104
|
+
width: '100%',
|
|
105
|
+
outline: 'none',
|
|
106
|
+
userSelect: 'text',
|
|
107
|
+
boxSizing: 'border-box',
|
|
108
|
+
padding: '8px 12px',
|
|
109
|
+
fontFamily: "'Noto Sans', sans-serif",
|
|
110
|
+
fontSize: '14px',
|
|
111
|
+
lineHeight: `${LINE_HEIGHT}px`,
|
|
112
|
+
color: textColor
|
|
113
|
+
};
|
|
114
|
+
if (!multiline) return {
|
|
115
|
+
...base,
|
|
116
|
+
height: '36px',
|
|
117
|
+
maxHeight: '36px',
|
|
118
|
+
overflowX: 'auto',
|
|
119
|
+
overflowY: 'hidden',
|
|
120
|
+
whiteSpace: 'nowrap'
|
|
121
|
+
};
|
|
122
|
+
const effectiveMinRows = Math.min(minRows, maxRows);
|
|
123
|
+
const minHeight = effectiveMinRows * LINE_HEIGHT + 2 * verticalPadding;
|
|
124
|
+
const maxHeight = maxRows * LINE_HEIGHT + 2 * verticalPadding;
|
|
125
|
+
return {
|
|
126
|
+
...base,
|
|
127
|
+
minHeight: `${minHeight}px`,
|
|
128
|
+
...fillHeight ? {
|
|
129
|
+
flex: 1
|
|
130
|
+
} : {
|
|
131
|
+
maxHeight: `${maxHeight}px`
|
|
132
|
+
},
|
|
133
|
+
overflowY: 'auto'
|
|
134
|
+
};
|
|
135
|
+
}, [
|
|
136
|
+
multiline,
|
|
137
|
+
minRows,
|
|
138
|
+
maxRows,
|
|
139
|
+
fillHeight,
|
|
140
|
+
borderless
|
|
141
|
+
]);
|
|
142
|
+
const handleEditorRef = (0, external_react_namespaceObject.useCallback)((editor)=>{
|
|
143
|
+
editorRef.current = editor;
|
|
144
|
+
}, []);
|
|
145
|
+
const handleChange = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
146
|
+
if (!editorRef.current) return;
|
|
147
|
+
editorRef.current.getEditorState().read(()=>{
|
|
148
|
+
const tokens = (0, external_utils_index_cjs_namespaceObject.$getEditorTokensInternal)();
|
|
149
|
+
const newIsEmpty = 0 === tokens.length || 1 === tokens.length && 'text' === tokens[0].type && '' === tokens[0].value;
|
|
150
|
+
if (newIsEmpty !== isEmptyRef.current) setIsEmpty(newIsEmpty);
|
|
151
|
+
if (!isSyncingRef.current) pendingTokensRef.current = tokens;
|
|
152
|
+
});
|
|
153
|
+
if (isSyncingRef.current || !onChangeRef.current) return;
|
|
154
|
+
if (debounceTimerRef.current) clearTimeout(debounceTimerRef.current);
|
|
155
|
+
debounceTimerRef.current = setTimeout(()=>{
|
|
156
|
+
if (!isMountedRef.current || !pendingTokensRef.current || !onChangeRef.current || !editorRef.current || isSyncingRef.current) return;
|
|
157
|
+
lastEmittedValueRef.current = pendingTokensRef.current;
|
|
158
|
+
onChangeRef.current(pendingTokensRef.current);
|
|
159
|
+
pendingTokensRef.current = null;
|
|
160
|
+
}, 0);
|
|
161
|
+
}, []);
|
|
162
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
163
|
+
if (value && lastEmittedValueRef.current && !(0, external_utils_index_cjs_namespaceObject.areTokensEqual)(value, lastEmittedValueRef.current)) lastEmittedValueRef.current = null;
|
|
164
|
+
}, [
|
|
165
|
+
value
|
|
166
|
+
]);
|
|
167
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
168
|
+
isMountedRef.current = true;
|
|
169
|
+
return ()=>{
|
|
170
|
+
isMountedRef.current = false;
|
|
171
|
+
if (debounceTimerRef.current) {
|
|
172
|
+
clearTimeout(debounceTimerRef.current);
|
|
173
|
+
debounceTimerRef.current = null;
|
|
174
|
+
}
|
|
175
|
+
pendingTokensRef.current = null;
|
|
176
|
+
};
|
|
177
|
+
}, []);
|
|
178
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
179
|
+
const seed = initialValue ?? value;
|
|
180
|
+
if (!editorRef.current || !seed || initializedRef.current) return;
|
|
181
|
+
const valueToSet = seed;
|
|
182
|
+
queueMicrotask(()=>{
|
|
183
|
+
if (!editorRef.current || initializedRef.current) return;
|
|
184
|
+
editorRef.current.update(()=>{
|
|
185
|
+
(0, external_utils_index_cjs_namespaceObject.$setEditorTokensInternal)(valueToSet);
|
|
186
|
+
setIsEmpty(0 === valueToSet.length);
|
|
187
|
+
initializedRef.current = true;
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}, []);
|
|
191
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
192
|
+
if (!editorRef.current) return;
|
|
193
|
+
editorRef.current.setEditable(!disabled);
|
|
194
|
+
}, [
|
|
195
|
+
disabled
|
|
196
|
+
]);
|
|
197
|
+
const options = Array.isArray(autoCompleteOptions) ? autoCompleteOptions : EMPTY_AUTOCOMPLETE_OPTIONS;
|
|
198
|
+
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'}`;
|
|
199
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
200
|
+
className: wrapperClassName,
|
|
201
|
+
style: {
|
|
202
|
+
fontFamily: "'Noto Sans', sans-serif",
|
|
203
|
+
fontSize: '14px',
|
|
204
|
+
lineHeight: '20px',
|
|
205
|
+
...fillHeight ? {
|
|
206
|
+
flex: 1,
|
|
207
|
+
minHeight: 0
|
|
208
|
+
} : {}
|
|
209
|
+
},
|
|
210
|
+
children: [
|
|
211
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("style", {
|
|
212
|
+
children: `
|
|
213
|
+
.prompt-editor-paragraph { padding: 0; margin: 0; }
|
|
214
|
+
${borderless ? '' : '.prompt-editor-shell:focus-within { border-color: var(--color-ring); box-shadow: 0 0 0 1px var(--color-ring); }'}
|
|
215
|
+
.prompt-editor-root *::selection { background-color: color-mix(in srgb, var(--color-primary) 30%, transparent); }
|
|
216
|
+
`
|
|
217
|
+
}),
|
|
218
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
219
|
+
className: "prompt-editor-root",
|
|
220
|
+
style: {
|
|
221
|
+
position: 'relative',
|
|
222
|
+
...fillHeight ? {
|
|
223
|
+
flex: 1,
|
|
224
|
+
display: 'flex',
|
|
225
|
+
flexDirection: 'column',
|
|
226
|
+
minHeight: 0
|
|
227
|
+
} : {}
|
|
228
|
+
},
|
|
229
|
+
children: [
|
|
230
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalPlainTextPlugin_namespaceObject.PlainTextPlugin, {
|
|
231
|
+
contentEditable: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalContentEditable_namespaceObject.ContentEditable, {
|
|
232
|
+
style: contentEditableStyle,
|
|
233
|
+
ariaLabel: ariaLabel
|
|
234
|
+
}),
|
|
235
|
+
placeholder: null,
|
|
236
|
+
ErrorBoundary: LexicalErrorBoundary_namespaceObject.LexicalErrorBoundary
|
|
237
|
+
}),
|
|
238
|
+
placeholder && isEmpty && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
239
|
+
style: {
|
|
240
|
+
position: 'absolute',
|
|
241
|
+
top: '8px',
|
|
242
|
+
left: '12px',
|
|
243
|
+
right: '12px',
|
|
244
|
+
pointerEvents: 'none',
|
|
245
|
+
userSelect: 'none',
|
|
246
|
+
fontFamily: "'Noto Sans', sans-serif",
|
|
247
|
+
fontSize: '14px',
|
|
248
|
+
lineHeight: '20px',
|
|
249
|
+
...multiline ? {} : {
|
|
250
|
+
whiteSpace: 'nowrap',
|
|
251
|
+
overflow: 'hidden',
|
|
252
|
+
textOverflow: 'ellipsis'
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
className: "text-muted-foreground/60",
|
|
256
|
+
children: placeholder
|
|
257
|
+
})
|
|
258
|
+
]
|
|
259
|
+
}),
|
|
260
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalHistoryPlugin_namespaceObject.HistoryPlugin, {}),
|
|
261
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(NodeSelectionFixPlugin_cjs_namespaceObject.NodeSelectionFixPlugin, {}),
|
|
262
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CopyPastePlugin_cjs_namespaceObject.CopyPastePlugin, {}),
|
|
263
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EditorRefPlugin_cjs_namespaceObject.EditorRefPlugin, {
|
|
264
|
+
onRef: handleEditorRef
|
|
265
|
+
}),
|
|
266
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ValueSyncPlugin_cjs_namespaceObject.ValueSyncPlugin, {
|
|
267
|
+
value: value,
|
|
268
|
+
editorRef: editorRef,
|
|
269
|
+
lastEmittedValueRef: lastEmittedValueRef,
|
|
270
|
+
isSyncingRef: isSyncingRef
|
|
271
|
+
}),
|
|
272
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MultilinePlugin_cjs_namespaceObject.MultilinePlugin, {
|
|
273
|
+
multiline: multiline
|
|
274
|
+
}),
|
|
275
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalOnChangePlugin_namespaceObject.OnChangePlugin, {
|
|
276
|
+
ignoreSelectionChange: true,
|
|
277
|
+
onChange: handleChange
|
|
278
|
+
}),
|
|
279
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ToolbarActionsPlugin_cjs_namespaceObject.ToolbarActionsPlugin, {
|
|
280
|
+
actionsRef: toolbarActionsRef
|
|
281
|
+
}),
|
|
282
|
+
options.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(AutocompletePlugin_cjs_namespaceObject.AutocompletePlugin, {
|
|
283
|
+
options: options
|
|
284
|
+
}),
|
|
285
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ValidateTokensPlugin_cjs_namespaceObject.ValidateTokensPlugin, {
|
|
286
|
+
options: options
|
|
287
|
+
}),
|
|
288
|
+
options.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RenameTokensPlugin_cjs_namespaceObject.RenameTokensPlugin, {
|
|
289
|
+
options: options,
|
|
290
|
+
onChange: onChange
|
|
291
|
+
}),
|
|
292
|
+
mapVarDropToToken && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(VariableDropPlugin_cjs_namespaceObject.VariableDropPlugin, {
|
|
293
|
+
mapVarDropToToken: mapVarDropToToken,
|
|
294
|
+
disabled: disabled
|
|
295
|
+
})
|
|
296
|
+
]
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
EditorInner.displayName = 'PromptEditorInner';
|
|
300
|
+
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 })=>{
|
|
301
|
+
const value = toTokenArray(rawValue);
|
|
302
|
+
const initialValue = toTokenArray(rawInitialValue);
|
|
303
|
+
const [internalMode, setInternalMode] = (0, external_react_namespaceObject.useState)('edit');
|
|
304
|
+
const mode = controlledMode ?? internalMode;
|
|
305
|
+
const toolbarActionsRef = (0, external_react_namespaceObject.useRef)(null);
|
|
306
|
+
const [uncontrolledPreviewTokens, setUncontrolledPreviewTokens] = (0, external_react_namespaceObject.useState)(initialValue ?? []);
|
|
307
|
+
const handleModeChange = (0, external_react_namespaceObject.useCallback)((newMode)=>{
|
|
308
|
+
if (onModeChange) onModeChange(newMode);
|
|
309
|
+
else setInternalMode(newMode);
|
|
310
|
+
}, [
|
|
311
|
+
onModeChange
|
|
312
|
+
]);
|
|
313
|
+
const initialConfig = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
314
|
+
namespace: 'PromptEditor',
|
|
315
|
+
theme: {
|
|
316
|
+
paragraph: 'prompt-editor-paragraph'
|
|
317
|
+
},
|
|
318
|
+
onError: (error)=>console.error('PromptEditor error:', error),
|
|
319
|
+
nodes: [
|
|
320
|
+
index_cjs_namespaceObject.InputTokenNode,
|
|
321
|
+
index_cjs_namespaceObject.OutputTokenNode,
|
|
322
|
+
index_cjs_namespaceObject.StateTokenNode,
|
|
323
|
+
index_cjs_namespaceObject.ResourceTokenNode
|
|
324
|
+
]
|
|
325
|
+
}), []);
|
|
326
|
+
const isControlled = void 0 !== value;
|
|
327
|
+
const previewTokens = isControlled ? value : uncontrolledPreviewTokens;
|
|
328
|
+
const handleEditorChange = (0, external_react_namespaceObject.useCallback)((tokens)=>{
|
|
329
|
+
if (!isControlled) setUncontrolledPreviewTokens(tokens);
|
|
330
|
+
onChange?.(tokens);
|
|
331
|
+
}, [
|
|
332
|
+
isControlled,
|
|
333
|
+
onChange
|
|
334
|
+
]);
|
|
335
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipProvider, {
|
|
336
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
337
|
+
style: {
|
|
338
|
+
display: 'flex',
|
|
339
|
+
flexDirection: 'column',
|
|
340
|
+
width: '100%',
|
|
341
|
+
...fillHeight ? {
|
|
342
|
+
flex: 1,
|
|
343
|
+
minHeight: 0
|
|
344
|
+
} : {}
|
|
345
|
+
},
|
|
346
|
+
children: [
|
|
347
|
+
showToolbar && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EditorToolbar_cjs_namespaceObject.EditorToolbar, {
|
|
348
|
+
mode: mode,
|
|
349
|
+
disabled: disabled,
|
|
350
|
+
actionsRef: toolbarActionsRef,
|
|
351
|
+
onModeChange: handleModeChange,
|
|
352
|
+
onFullscreen: onFullscreen
|
|
353
|
+
}),
|
|
354
|
+
'preview' === mode && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
355
|
+
className: borderless ? void 0 : `border bg-background ${showToolbar ? 'border-t-0 rounded-b-md' : 'rounded-md'}`,
|
|
356
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MarkdownPreview_cjs_namespaceObject.MarkdownPreview, {
|
|
357
|
+
tokens: previewTokens,
|
|
358
|
+
minRows: minRows
|
|
359
|
+
})
|
|
360
|
+
}),
|
|
361
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
362
|
+
style: {
|
|
363
|
+
display: 'preview' === mode ? 'none' : 'flex',
|
|
364
|
+
flexDirection: 'column',
|
|
365
|
+
...fillHeight ? {
|
|
366
|
+
flex: 1,
|
|
367
|
+
minHeight: 0
|
|
368
|
+
} : {}
|
|
369
|
+
},
|
|
370
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalComposer_namespaceObject.LexicalComposer, {
|
|
371
|
+
initialConfig: initialConfig,
|
|
372
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EditorInner, {
|
|
373
|
+
ref: editorRef,
|
|
374
|
+
autoCompleteOptions: autoCompleteOptions,
|
|
375
|
+
disabled: disabled,
|
|
376
|
+
ariaLabel: ariaLabel,
|
|
377
|
+
initialValue: initialValue,
|
|
378
|
+
maxRows: maxRows,
|
|
379
|
+
minRows: minRows,
|
|
380
|
+
multiline: multiline,
|
|
381
|
+
placeholder: placeholder,
|
|
382
|
+
fillHeight: fillHeight,
|
|
383
|
+
borderless: borderless,
|
|
384
|
+
mapVarDropToToken: mapVarDropToToken,
|
|
385
|
+
showToolbar: showToolbar,
|
|
386
|
+
toolbarActionsRef: toolbarActionsRef,
|
|
387
|
+
value: value,
|
|
388
|
+
onChange: handleEditorChange
|
|
389
|
+
})
|
|
390
|
+
})
|
|
391
|
+
})
|
|
392
|
+
]
|
|
393
|
+
})
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
exports.PromptEditor = __webpack_exports__.PromptEditor;
|
|
397
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
398
|
+
"PromptEditor"
|
|
399
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
400
|
+
Object.defineProperty(exports, '__esModule', {
|
|
401
|
+
value: true
|
|
402
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { PromptEditorAutoCompleteOption, PromptEditorMode, PromptEditorToken } from './types';
|
|
2
|
+
export interface PromptEditorRef {
|
|
3
|
+
setTokens: (tokens: PromptEditorToken[]) => void;
|
|
4
|
+
/** Focus the editor and insert the `$` trigger character to open the autocomplete menu. */
|
|
5
|
+
insertAutocompleteTrigger: () => void;
|
|
6
|
+
/** Focus the editor and insert a variable token pill at the current cursor position. */
|
|
7
|
+
insertVariableToken: (option: PromptEditorAutoCompleteOption) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface PromptEditorProps {
|
|
10
|
+
value?: PromptEditorToken[];
|
|
11
|
+
initialValue?: PromptEditorToken[];
|
|
12
|
+
onChange?: (value: PromptEditorToken[]) => void;
|
|
13
|
+
autoCompleteOptions?: PromptEditorAutoCompleteOption[];
|
|
14
|
+
multiline?: boolean;
|
|
15
|
+
minRows?: number;
|
|
16
|
+
maxRows?: number;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
ariaLabel?: string;
|
|
20
|
+
showToolbar?: boolean;
|
|
21
|
+
mode?: PromptEditorMode;
|
|
22
|
+
onModeChange?: (mode: PromptEditorMode) => void;
|
|
23
|
+
onFullscreen?: () => void;
|
|
24
|
+
editorRef?: React.RefObject<PromptEditorRef | null>;
|
|
25
|
+
fillHeight?: boolean;
|
|
26
|
+
/** Drop the editor's own border/background/rounding so a parent can provide the field chrome. */
|
|
27
|
+
borderless?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Enable variable drag-drop: map a path dropped onto the editor (see `VARIABLE_DRAG_MIME`) to the
|
|
30
|
+
* token to insert at the drop point. The drag *source* is the consumer's (it sets the path on
|
|
31
|
+
* `dataTransfer`); omit this prop to disable drop handling entirely.
|
|
32
|
+
*/
|
|
33
|
+
mapVarDropToToken?: (insertPath: string) => PromptEditorAutoCompleteOption;
|
|
34
|
+
}
|
|
35
|
+
export declare const PromptEditor: ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline, minRows, maxRows, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, mapVarDropToToken, }: PromptEditorProps) => import("react/jsx-runtime").JSX.Element;
|