@uipath/apollo-wind 2.68.0 → 2.69.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/ui/code-block.cjs +375 -0
- package/dist/components/ui/code-block.d.ts +38 -0
- package/dist/components/ui/code-block.js +307 -0
- package/dist/components/ui/index.cjs +254 -188
- package/dist/components/ui/index.d.ts +6 -0
- package/dist/components/ui/index.js +6 -0
- package/dist/components/ui/json-tree-view/JsonTree.cjs +2 -2
- package/dist/components/ui/json-tree-view/JsonTree.js +1 -1
- package/dist/components/ui/json-tree-view/index.cjs +26 -23
- package/dist/components/ui/json-tree-view/index.d.ts +2 -2
- package/dist/components/ui/json-tree-view/index.js +2 -2
- package/dist/components/ui/live-region.cjs +106 -0
- package/dist/components/ui/live-region.d.ts +31 -0
- package/dist/components/ui/live-region.js +72 -0
- package/dist/components/ui/loading-dots.cjs +95 -0
- package/dist/components/ui/loading-dots.d.ts +21 -0
- package/dist/components/ui/loading-dots.js +55 -0
- package/dist/components/ui/markdown.cjs +428 -0
- package/dist/components/ui/markdown.d.ts +55 -0
- package/dist/components/ui/markdown.js +378 -0
- package/dist/components/ui/thinking-indicator.cjs +146 -0
- package/dist/components/ui/thinking-indicator.d.ts +38 -0
- package/dist/components/ui/thinking-indicator.js +106 -0
- package/dist/components/ui/tool-call.cjs +359 -0
- package/dist/components/ui/tool-call.d.ts +75 -0
- package/dist/components/ui/tool-call.js +301 -0
- package/dist/index.cjs +321 -252
- package/dist/index.d.ts +12 -0
- package/dist/index.js +7 -1
- package/dist/styles.css +206 -0
- package/dist/tailwind.utilities.css +21 -0
- package/package.json +7 -1
- /package/dist/{components/ui/json-tree-view → lib}/clipboard.cjs +0 -0
- /package/dist/{components/ui/json-tree-view → lib}/clipboard.d.ts +0 -0
- /package/dist/{components/ui/json-tree-view → lib}/clipboard.js +0 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check, Copy } from "lucide-react";
|
|
3
|
+
import { forwardRef, memo, useEffect, useRef, useState } from "react";
|
|
4
|
+
import bash from "react-syntax-highlighter/dist/esm/languages/prism/bash.js";
|
|
5
|
+
import csharp from "react-syntax-highlighter/dist/esm/languages/prism/csharp.js";
|
|
6
|
+
import css from "react-syntax-highlighter/dist/esm/languages/prism/css.js";
|
|
7
|
+
import diff from "react-syntax-highlighter/dist/esm/languages/prism/diff.js";
|
|
8
|
+
import go from "react-syntax-highlighter/dist/esm/languages/prism/go.js";
|
|
9
|
+
import java from "react-syntax-highlighter/dist/esm/languages/prism/java.js";
|
|
10
|
+
import javascript from "react-syntax-highlighter/dist/esm/languages/prism/javascript.js";
|
|
11
|
+
import json from "react-syntax-highlighter/dist/esm/languages/prism/json.js";
|
|
12
|
+
import prism_jsx from "react-syntax-highlighter/dist/esm/languages/prism/jsx.js";
|
|
13
|
+
import markdown from "react-syntax-highlighter/dist/esm/languages/prism/markdown.js";
|
|
14
|
+
import markup from "react-syntax-highlighter/dist/esm/languages/prism/markup.js";
|
|
15
|
+
import powershell from "react-syntax-highlighter/dist/esm/languages/prism/powershell.js";
|
|
16
|
+
import python from "react-syntax-highlighter/dist/esm/languages/prism/python.js";
|
|
17
|
+
import sql from "react-syntax-highlighter/dist/esm/languages/prism/sql.js";
|
|
18
|
+
import tsx from "react-syntax-highlighter/dist/esm/languages/prism/tsx.js";
|
|
19
|
+
import typescript from "react-syntax-highlighter/dist/esm/languages/prism/typescript.js";
|
|
20
|
+
import vbnet from "react-syntax-highlighter/dist/esm/languages/prism/vbnet.js";
|
|
21
|
+
import yaml from "react-syntax-highlighter/dist/esm/languages/prism/yaml.js";
|
|
22
|
+
import prism_light from "react-syntax-highlighter/dist/esm/prism-light.js";
|
|
23
|
+
import { Button } from "./button.js";
|
|
24
|
+
import { cn } from "../../lib/index.js";
|
|
25
|
+
import { copyTextToClipboard } from "../../lib/clipboard.js";
|
|
26
|
+
const LANGUAGES = {
|
|
27
|
+
bash: bash,
|
|
28
|
+
csharp: csharp,
|
|
29
|
+
css: css,
|
|
30
|
+
diff: diff,
|
|
31
|
+
go: go,
|
|
32
|
+
java: java,
|
|
33
|
+
javascript: javascript,
|
|
34
|
+
json: json,
|
|
35
|
+
jsx: prism_jsx,
|
|
36
|
+
markdown: markdown,
|
|
37
|
+
markup: markup,
|
|
38
|
+
powershell: powershell,
|
|
39
|
+
python: python,
|
|
40
|
+
sql: sql,
|
|
41
|
+
tsx: tsx,
|
|
42
|
+
typescript: typescript,
|
|
43
|
+
vbnet: vbnet,
|
|
44
|
+
yaml: yaml
|
|
45
|
+
};
|
|
46
|
+
for (const [name, grammar] of Object.entries(LANGUAGES))prism_light.registerLanguage(name, grammar);
|
|
47
|
+
const LANGUAGE_ALIASES = {
|
|
48
|
+
'c#': 'csharp',
|
|
49
|
+
cjs: "javascript",
|
|
50
|
+
cs: 'csharp',
|
|
51
|
+
golang: 'go',
|
|
52
|
+
htm: 'markup',
|
|
53
|
+
html: 'markup',
|
|
54
|
+
js: "javascript",
|
|
55
|
+
md: 'markdown',
|
|
56
|
+
mjs: "javascript",
|
|
57
|
+
patch: 'diff',
|
|
58
|
+
ps: 'powershell',
|
|
59
|
+
ps1: 'powershell',
|
|
60
|
+
pwsh: 'powershell',
|
|
61
|
+
py: 'python',
|
|
62
|
+
sh: 'bash',
|
|
63
|
+
shell: 'bash',
|
|
64
|
+
svg: 'markup',
|
|
65
|
+
ts: "typescript",
|
|
66
|
+
vb: 'vbnet',
|
|
67
|
+
'vb.net': 'vbnet',
|
|
68
|
+
xml: 'markup',
|
|
69
|
+
yml: 'yaml',
|
|
70
|
+
zsh: 'bash'
|
|
71
|
+
};
|
|
72
|
+
function resolveLanguage(language) {
|
|
73
|
+
const key = language?.trim().toLowerCase();
|
|
74
|
+
if (!key) return;
|
|
75
|
+
const name = LANGUAGE_ALIASES[key] ?? key;
|
|
76
|
+
return name in LANGUAGES ? name : void 0;
|
|
77
|
+
}
|
|
78
|
+
const token = (name)=>`var(--code-${name}, var(--foreground))`;
|
|
79
|
+
const codeBlockTheme = {
|
|
80
|
+
'code[class*="language-"]': {
|
|
81
|
+
color: token('rest'),
|
|
82
|
+
background: 'none',
|
|
83
|
+
fontFamily: 'var(--font-mono)',
|
|
84
|
+
textAlign: 'left',
|
|
85
|
+
wordSpacing: 'normal',
|
|
86
|
+
wordBreak: 'normal',
|
|
87
|
+
tabSize: 2,
|
|
88
|
+
hyphens: 'none'
|
|
89
|
+
},
|
|
90
|
+
'pre[class*="language-"]': {
|
|
91
|
+
color: token('rest'),
|
|
92
|
+
background: 'none',
|
|
93
|
+
fontFamily: 'var(--font-mono)',
|
|
94
|
+
fontSize: '0.8125rem',
|
|
95
|
+
lineHeight: 1.6,
|
|
96
|
+
margin: 0,
|
|
97
|
+
padding: '0.75rem 1rem',
|
|
98
|
+
overflow: 'auto',
|
|
99
|
+
tabSize: 2
|
|
100
|
+
},
|
|
101
|
+
comment: {
|
|
102
|
+
color: 'var(--foreground-muted)',
|
|
103
|
+
fontStyle: 'italic'
|
|
104
|
+
},
|
|
105
|
+
prolog: {
|
|
106
|
+
color: 'var(--foreground-muted)',
|
|
107
|
+
fontStyle: 'italic'
|
|
108
|
+
},
|
|
109
|
+
doctype: {
|
|
110
|
+
color: 'var(--foreground-muted)'
|
|
111
|
+
},
|
|
112
|
+
cdata: {
|
|
113
|
+
color: 'var(--foreground-muted)'
|
|
114
|
+
},
|
|
115
|
+
punctuation: {
|
|
116
|
+
color: token('punctuation')
|
|
117
|
+
},
|
|
118
|
+
operator: {
|
|
119
|
+
color: token('key')
|
|
120
|
+
},
|
|
121
|
+
keyword: {
|
|
122
|
+
color: token('key')
|
|
123
|
+
},
|
|
124
|
+
atrule: {
|
|
125
|
+
color: token('key')
|
|
126
|
+
},
|
|
127
|
+
tag: {
|
|
128
|
+
color: token('key')
|
|
129
|
+
},
|
|
130
|
+
property: {
|
|
131
|
+
color: token('key')
|
|
132
|
+
},
|
|
133
|
+
'attr-name': {
|
|
134
|
+
color: token('key')
|
|
135
|
+
},
|
|
136
|
+
selector: {
|
|
137
|
+
color: token('key')
|
|
138
|
+
},
|
|
139
|
+
string: {
|
|
140
|
+
color: token('string')
|
|
141
|
+
},
|
|
142
|
+
char: {
|
|
143
|
+
color: token('string')
|
|
144
|
+
},
|
|
145
|
+
'attr-value': {
|
|
146
|
+
color: token('string')
|
|
147
|
+
},
|
|
148
|
+
'template-string': {
|
|
149
|
+
color: token('string')
|
|
150
|
+
},
|
|
151
|
+
regex: {
|
|
152
|
+
color: token('string')
|
|
153
|
+
},
|
|
154
|
+
url: {
|
|
155
|
+
color: token('string')
|
|
156
|
+
},
|
|
157
|
+
inserted: {
|
|
158
|
+
color: token('string')
|
|
159
|
+
},
|
|
160
|
+
number: {
|
|
161
|
+
color: token('number')
|
|
162
|
+
},
|
|
163
|
+
unit: {
|
|
164
|
+
color: token('number')
|
|
165
|
+
},
|
|
166
|
+
boolean: {
|
|
167
|
+
color: token('literal')
|
|
168
|
+
},
|
|
169
|
+
constant: {
|
|
170
|
+
color: token('literal')
|
|
171
|
+
},
|
|
172
|
+
symbol: {
|
|
173
|
+
color: token('literal')
|
|
174
|
+
},
|
|
175
|
+
builtin: {
|
|
176
|
+
color: token('literal')
|
|
177
|
+
},
|
|
178
|
+
'class-name': {
|
|
179
|
+
color: token('literal')
|
|
180
|
+
},
|
|
181
|
+
function: {
|
|
182
|
+
color: token('literal')
|
|
183
|
+
},
|
|
184
|
+
entity: {
|
|
185
|
+
color: token('literal')
|
|
186
|
+
},
|
|
187
|
+
deleted: {
|
|
188
|
+
color: 'var(--error, var(--destructive))'
|
|
189
|
+
},
|
|
190
|
+
important: {
|
|
191
|
+
fontWeight: 600
|
|
192
|
+
},
|
|
193
|
+
bold: {
|
|
194
|
+
fontWeight: 600
|
|
195
|
+
},
|
|
196
|
+
italic: {
|
|
197
|
+
fontStyle: 'italic'
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const lineNumberStyle = {
|
|
201
|
+
minWidth: '2.25em',
|
|
202
|
+
paddingRight: '1em',
|
|
203
|
+
color: 'var(--foreground-subtle)',
|
|
204
|
+
textAlign: 'right',
|
|
205
|
+
userSelect: 'none'
|
|
206
|
+
};
|
|
207
|
+
const DEFAULT_CODE_BLOCK_STRINGS = {
|
|
208
|
+
copy: 'Copy code',
|
|
209
|
+
copied: 'Copied',
|
|
210
|
+
plainText: 'Text'
|
|
211
|
+
};
|
|
212
|
+
const COPIED_RESET_MS = 2000;
|
|
213
|
+
const CodeBlockHeader = /*#__PURE__*/ forwardRef(({ code, language, strings, className, children, ...props }, ref)=>{
|
|
214
|
+
const text = {
|
|
215
|
+
...DEFAULT_CODE_BLOCK_STRINGS,
|
|
216
|
+
...strings
|
|
217
|
+
};
|
|
218
|
+
const [copied, setCopied] = useState(false);
|
|
219
|
+
const timer = useRef(void 0);
|
|
220
|
+
useEffect(()=>()=>clearTimeout(timer.current), []);
|
|
221
|
+
const handleCopy = async ()=>{
|
|
222
|
+
if (!await copyTextToClipboard(code)) return;
|
|
223
|
+
setCopied(true);
|
|
224
|
+
clearTimeout(timer.current);
|
|
225
|
+
timer.current = setTimeout(()=>setCopied(false), COPIED_RESET_MS);
|
|
226
|
+
};
|
|
227
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
228
|
+
ref: ref,
|
|
229
|
+
"data-slot": "code-block-header",
|
|
230
|
+
className: cn('flex items-center justify-between gap-2 border-b border-border-subtle py-1 pr-1 pl-4', className),
|
|
231
|
+
...props,
|
|
232
|
+
children: [
|
|
233
|
+
/*#__PURE__*/ jsx("span", {
|
|
234
|
+
"data-slot": "code-block-language",
|
|
235
|
+
className: "min-w-0 truncate text-xs font-medium text-muted-foreground",
|
|
236
|
+
children: language?.trim() || text.plainText
|
|
237
|
+
}),
|
|
238
|
+
/*#__PURE__*/ jsxs("div", {
|
|
239
|
+
className: "flex shrink-0 items-center gap-1",
|
|
240
|
+
children: [
|
|
241
|
+
children,
|
|
242
|
+
/*#__PURE__*/ jsx(Button, {
|
|
243
|
+
"data-slot": "code-block-copy",
|
|
244
|
+
"data-copied": copied || void 0,
|
|
245
|
+
variant: "ghost",
|
|
246
|
+
size: "2xs",
|
|
247
|
+
icon: true,
|
|
248
|
+
"aria-label": text.copy,
|
|
249
|
+
title: copied ? text.copied : text.copy,
|
|
250
|
+
onClick: handleCopy,
|
|
251
|
+
children: copied ? /*#__PURE__*/ jsx(Check, {
|
|
252
|
+
"aria-hidden": true
|
|
253
|
+
}) : /*#__PURE__*/ jsx(Copy, {
|
|
254
|
+
"aria-hidden": true
|
|
255
|
+
})
|
|
256
|
+
}),
|
|
257
|
+
/*#__PURE__*/ jsx("output", {
|
|
258
|
+
className: "sr-only",
|
|
259
|
+
children: copied ? text.copied : ''
|
|
260
|
+
})
|
|
261
|
+
]
|
|
262
|
+
})
|
|
263
|
+
]
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
CodeBlockHeader.displayName = 'CodeBlockHeader';
|
|
267
|
+
const code_block_CodeBlockBody = /*#__PURE__*/ memo(function({ code, language, wrap, showLineNumbers }) {
|
|
268
|
+
return /*#__PURE__*/ jsx(prism_light, {
|
|
269
|
+
language: language ?? 'text',
|
|
270
|
+
style: codeBlockTheme,
|
|
271
|
+
wrapLongLines: wrap,
|
|
272
|
+
showLineNumbers: showLineNumbers,
|
|
273
|
+
lineNumberStyle: lineNumberStyle,
|
|
274
|
+
"data-slot": "code-block-body",
|
|
275
|
+
"data-wrap": wrap,
|
|
276
|
+
tabIndex: wrap ? void 0 : 0,
|
|
277
|
+
className: "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
|
|
278
|
+
children: code
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
const CodeBlock = /*#__PURE__*/ forwardRef(({ code, language, wrap = false, showLineNumbers = false, hideHeader = false, actions, strings, className, ...props }, ref)=>{
|
|
282
|
+
const source = code.replace(/\n$/, '');
|
|
283
|
+
const resolved = resolveLanguage(language);
|
|
284
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
285
|
+
ref: ref,
|
|
286
|
+
"data-slot": "code-block",
|
|
287
|
+
"data-language": resolved ?? 'text',
|
|
288
|
+
className: cn('min-w-0 overflow-hidden rounded-lg border border-border-subtle bg-surface-overlay text-foreground', className),
|
|
289
|
+
...props,
|
|
290
|
+
children: [
|
|
291
|
+
!hideHeader && /*#__PURE__*/ jsx(CodeBlockHeader, {
|
|
292
|
+
code: source,
|
|
293
|
+
language: language,
|
|
294
|
+
strings: strings,
|
|
295
|
+
children: actions
|
|
296
|
+
}),
|
|
297
|
+
/*#__PURE__*/ jsx(code_block_CodeBlockBody, {
|
|
298
|
+
code: source,
|
|
299
|
+
language: resolved,
|
|
300
|
+
wrap: wrap,
|
|
301
|
+
showLineNumbers: showLineNumbers
|
|
302
|
+
})
|
|
303
|
+
]
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
CodeBlock.displayName = 'CodeBlock';
|
|
307
|
+
export { CodeBlock, CodeBlockHeader, DEFAULT_CODE_BLOCK_STRINGS };
|