@uipath/apollo-wind 2.79.0 → 2.79.2

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 (48) hide show
  1. package/dist/components/forms/metadata-form.cjs +3 -2
  2. package/dist/components/forms/metadata-form.js +3 -2
  3. package/dist/components/ui/field-actions/ai-assist-action.cjs +7 -5
  4. package/dist/components/ui/field-actions/ai-assist-action.js +7 -5
  5. package/dist/components/ui/field-actions/collapse.cjs +7 -7
  6. package/dist/components/ui/field-actions/collapse.d.ts +6 -3
  7. package/dist/components/ui/field-actions/collapse.js +3 -3
  8. package/dist/components/ui/field-actions/insert-variable-action.cjs +7 -7
  9. package/dist/components/ui/field-actions/insert-variable-action.js +8 -8
  10. package/dist/components/ui/index.cjs +34 -34
  11. package/dist/components/ui/json-tree-view/EditorChrome.cjs +5 -2
  12. package/dist/components/ui/json-tree-view/EditorChrome.js +5 -2
  13. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.cjs +6 -3
  14. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.js +6 -3
  15. package/dist/components/ui/json-tree-view/JsonTree.cjs +66 -38
  16. package/dist/components/ui/json-tree-view/JsonTree.d.ts +6 -1
  17. package/dist/components/ui/json-tree-view/JsonTree.js +66 -38
  18. package/dist/components/ui/json-tree-view/JsonTree.types.d.ts +6 -1
  19. package/dist/components/ui/json-tree-view/JsonTreeRow.cjs +116 -81
  20. package/dist/components/ui/json-tree-view/JsonTreeRow.d.ts +16 -8
  21. package/dist/components/ui/json-tree-view/JsonTreeRow.js +116 -81
  22. package/dist/components/ui/json-tree-view/NodeKey.cjs +2 -2
  23. package/dist/components/ui/json-tree-view/NodeKey.js +2 -2
  24. package/dist/components/ui/json-tree-view/RowActions.cjs +6 -6
  25. package/dist/components/ui/json-tree-view/RowActions.js +6 -6
  26. package/dist/components/ui/json-tree-view/buildJsonTree.cjs +20 -1
  27. package/dist/components/ui/json-tree-view/buildJsonTree.d.ts +4 -0
  28. package/dist/components/ui/json-tree-view/buildJsonTree.js +20 -1
  29. package/dist/components/ui/json-tree-view/strings.cjs +2 -0
  30. package/dist/components/ui/json-tree-view/strings.d.ts +12 -0
  31. package/dist/components/ui/json-tree-view/strings.js +2 -0
  32. package/dist/components/ui/json-tree-view/treeGrid.cjs +306 -0
  33. package/dist/components/ui/json-tree-view/treeGrid.d.ts +36 -0
  34. package/dist/components/ui/json-tree-view/treeGrid.js +269 -0
  35. package/dist/components/ui/quick-form-field/components/field-header.cjs +14 -14
  36. package/dist/components/ui/quick-form-field/components/field-header.js +15 -15
  37. package/dist/components/ui/tool-call.cjs +2 -2
  38. package/dist/components/ui/tool-call.js +2 -2
  39. package/dist/lib/clipboard.cjs +4 -0
  40. package/dist/lib/clipboard.js +4 -0
  41. package/dist/lib/use-ancestor-density.cjs +2 -2
  42. package/dist/lib/use-ancestor-density.js +2 -2
  43. package/dist/lib/use-isomorphic-layout-effect.cjs +37 -0
  44. package/dist/lib/use-isomorphic-layout-effect.d.ts +3 -0
  45. package/dist/lib/use-isomorphic-layout-effect.js +3 -0
  46. package/dist/styles.css +18 -26
  47. package/dist/tailwind.css +2 -1
  48. package/package.json +1 -1
@@ -0,0 +1,269 @@
1
+ import { useMemo, useRef, useState } from "react";
2
+ import { useIsomorphicLayoutEffect } from "../../../lib/use-isomorphic-layout-effect.js";
3
+ import { appendPathSegment, isPathCollapsed } from "./buildJsonTree.js";
4
+ const EDITOR_ATTR = 'data-json-tree-editor';
5
+ const SKIP_ATTR = 'data-json-tree-skip';
6
+ const MANAGED_ATTR = 'data-json-tree-tabindex';
7
+ const ROW_SELECTOR = '[role="row"]';
8
+ const CONTROL_SELECTOR = 'button, a[href], input, select, textarea, [contenteditable="true"], [tabindex]:not([role="gridcell"])';
9
+ const TEXT_ENTRY_SELECTOR = `input, textarea, select, [contenteditable="true"], [${EDITOR_ATTR}]`;
10
+ const HANDLED_KEYS = new Set([
11
+ 'ArrowDown',
12
+ 'ArrowUp',
13
+ 'ArrowLeft',
14
+ 'ArrowRight',
15
+ 'PageDown',
16
+ 'PageUp',
17
+ 'Home',
18
+ 'End',
19
+ 'Enter'
20
+ ]);
21
+ const PAGE_SIZE = 10;
22
+ function isOwnRow(grid, row) {
23
+ return row.closest('[role="treegrid"]') === grid;
24
+ }
25
+ function isNavigable(element) {
26
+ return !element.hasAttribute('disabled') && !element.closest(`[${EDITOR_ATTR}], [${SKIP_ATTR}], [aria-hidden="true"]`);
27
+ }
28
+ function cellsOf(row) {
29
+ return Array.from(row.querySelectorAll('[role="gridcell"]'));
30
+ }
31
+ function stopsOf(cell) {
32
+ const controls = Array.from(cell.querySelectorAll(CONTROL_SELECTOR)).filter(isNavigable);
33
+ if (controls.length > 0) return controls;
34
+ return cell.textContent?.trim() ? [
35
+ cell
36
+ ] : [];
37
+ }
38
+ function rowStops(row) {
39
+ return cellsOf(row).flatMap(stopsOf);
40
+ }
41
+ function cellNameOf(element) {
42
+ return element.closest('[role="gridcell"]')?.dataset.cell;
43
+ }
44
+ function findRow(grid, path) {
45
+ return Array.from(grid.querySelectorAll(ROW_SELECTOR)).find((row)=>row.dataset.path === path && isOwnRow(grid, row));
46
+ }
47
+ function focusInRow(row, cell) {
48
+ const target = cell ? cellsOf(row).find((c)=>c.dataset.cell === cell) : void 0;
49
+ const stop = target ? stopsOf(target)[0] : void 0;
50
+ (stop ?? row).focus();
51
+ }
52
+ function syncRowTabOrder(row, tabbable) {
53
+ for (const control of row.querySelectorAll(CONTROL_SELECTOR)){
54
+ if (control.closest(`[${SKIP_ATTR}]`)) continue;
55
+ const saved = control.getAttribute(MANAGED_ATTR);
56
+ if (tabbable) {
57
+ if (null === saved) continue;
58
+ if ('' === saved) control.removeAttribute('tabindex');
59
+ else control.setAttribute('tabindex', saved);
60
+ control.removeAttribute(MANAGED_ATTR);
61
+ } else if (null === saved) {
62
+ control.setAttribute(MANAGED_ATTR, control.getAttribute('tabindex') ?? '');
63
+ control.setAttribute('tabindex', '-1');
64
+ }
65
+ }
66
+ }
67
+ function ancestorPaths(segments) {
68
+ const paths = [];
69
+ let path = '';
70
+ for (const segment of segments.slice(0, -1)){
71
+ path = appendPathSegment(path, segment);
72
+ paths.unshift(path);
73
+ }
74
+ return paths;
75
+ }
76
+ function isParentRow(row) {
77
+ return !!row.node.children?.length;
78
+ }
79
+ function useTreeGrid({ rows, indexByPath, collapsed, toggle }) {
80
+ const [grid, setGrid] = useState(null);
81
+ const [active, setActive] = useState(null);
82
+ const activePath = useMemo(()=>{
83
+ if (active && indexByPath.has(active.path)) return active.path;
84
+ const ancestor = active && ancestorPaths(active.segments).find((path)=>indexByPath.has(path));
85
+ return ancestor ?? rows[0]?.node.path ?? null;
86
+ }, [
87
+ active,
88
+ indexByPath,
89
+ rows
90
+ ]);
91
+ const pendingFocusRef = useRef(null);
92
+ const openEditorsRef = useRef({});
93
+ const lastFocusedRef = useRef(null);
94
+ const activePathRef = useRef(activePath);
95
+ const syncedPathRef = useRef(null);
96
+ useIsomorphicLayoutEffect(()=>{
97
+ activePathRef.current = activePath;
98
+ const previous = syncedPathRef.current;
99
+ syncedPathRef.current = activePath;
100
+ if (!grid || previous === activePath) return;
101
+ for (const path of [
102
+ previous,
103
+ activePath
104
+ ]){
105
+ const row = null === path ? void 0 : findRow(grid, path);
106
+ if (row) syncRowTabOrder(row, path === activePath);
107
+ }
108
+ }, [
109
+ grid,
110
+ activePath
111
+ ]);
112
+ useIsomorphicLayoutEffect(()=>{
113
+ if (!grid) return;
114
+ const sync = (row)=>syncRowTabOrder(row, row.dataset.path === activePathRef.current);
115
+ for (const row of grid.querySelectorAll(ROW_SELECTOR))sync(row);
116
+ const observer = new MutationObserver((mutations)=>{
117
+ const touched = new Set();
118
+ for (const mutation of mutations)for (const added of mutation.addedNodes){
119
+ if (!(added instanceof Element)) continue;
120
+ const row = added.closest(ROW_SELECTOR);
121
+ if (row) touched.add(row);
122
+ for (const inner of added.querySelectorAll(ROW_SELECTOR))touched.add(inner);
123
+ }
124
+ for (const row of touched)sync(row);
125
+ });
126
+ observer.observe(grid, {
127
+ childList: true,
128
+ subtree: true
129
+ });
130
+ return ()=>observer.disconnect();
131
+ }, [
132
+ grid
133
+ ]);
134
+ useIsomorphicLayoutEffect(()=>{
135
+ const pending = pendingFocusRef.current;
136
+ pendingFocusRef.current = null;
137
+ if (!grid) return;
138
+ const row = pending && findRow(grid, pending.path);
139
+ if (pending && row) {
140
+ const { opener } = pending;
141
+ if (opener instanceof HTMLElement && opener.isConnected && row.contains(opener)) opener.focus();
142
+ else focusInRow(row, pending.cell);
143
+ return;
144
+ }
145
+ const lost = lastFocusedRef.current;
146
+ const focusDropped = !document.activeElement || document.activeElement === document.body;
147
+ if (lost && !lost.isConnected && focusDropped && activePath) findRow(grid, activePath)?.focus();
148
+ });
149
+ const focusRow = (index, cell)=>{
150
+ const row = rows[index];
151
+ if (!row) return;
152
+ const element = grid && findRow(grid, row.node.path);
153
+ if (element) return void focusInRow(element, cell);
154
+ pendingFocusRef.current = {
155
+ path: row.node.path,
156
+ cell
157
+ };
158
+ setActive({
159
+ path: row.node.path,
160
+ segments: row.node.segments
161
+ });
162
+ };
163
+ const trackEditor = (kind, set)=>(path)=>{
164
+ if (null !== path) {
165
+ const opener = document.activeElement;
166
+ const cell = (opener && cellNameOf(opener)) ?? ('json' === kind ? 'actions' : void 0);
167
+ openEditorsRef.current[kind] = {
168
+ path,
169
+ cell,
170
+ opener
171
+ };
172
+ } else {
173
+ const open = openEditorsRef.current[kind];
174
+ openEditorsRef.current[kind] = void 0;
175
+ if (open && grid && findRow(grid, open.path)?.contains(document.activeElement)) pendingFocusRef.current = open;
176
+ }
177
+ set(path);
178
+ };
179
+ const onKeyDown = (event)=>{
180
+ if (!HANDLED_KEYS.has(event.key) || event.altKey || event.metaKey || event.shiftKey) return;
181
+ if (event.ctrlKey && 'Home' !== event.key && 'End' !== event.key) return;
182
+ const { target, currentTarget } = event;
183
+ if (!(target instanceof HTMLElement) || !currentTarget.contains(target)) return;
184
+ if (target.closest(TEXT_ENTRY_SELECTOR)) return;
185
+ const row = target.closest(ROW_SELECTOR);
186
+ if (!row || !isOwnRow(currentTarget, row)) return;
187
+ const path = row.dataset.path;
188
+ const index = void 0 === path ? void 0 : indexByPath.get(path);
189
+ const flatRow = void 0 === index ? void 0 : rows[index];
190
+ if (void 0 === path || void 0 === index || !flatRow) return;
191
+ const isParent = isParentRow(flatRow);
192
+ const expanded = isParent && !isPathCollapsed(collapsed, path);
193
+ const onRow = target === row;
194
+ const stops = onRow ? [] : rowStops(row);
195
+ const at = stops.indexOf(target);
196
+ const cell = onRow ? void 0 : cellNameOf(target);
197
+ const last = rows.length - 1;
198
+ const moveTo = (next)=>focusRow(Math.max(0, Math.min(last, next)), cell);
199
+ switch(event.key){
200
+ case 'ArrowDown':
201
+ moveTo(index + 1);
202
+ break;
203
+ case 'ArrowUp':
204
+ moveTo(index - 1);
205
+ break;
206
+ case 'PageDown':
207
+ moveTo(index + PAGE_SIZE);
208
+ break;
209
+ case 'PageUp':
210
+ moveTo(index - PAGE_SIZE);
211
+ break;
212
+ case 'Home':
213
+ if (onRow || event.ctrlKey) moveTo(0);
214
+ else stops[0]?.focus();
215
+ break;
216
+ case 'End':
217
+ if (onRow || event.ctrlKey) moveTo(last);
218
+ else stops[stops.length - 1]?.focus();
219
+ break;
220
+ case 'ArrowRight':
221
+ if (onRow) if (isParent && !expanded && toggle) toggle(path);
222
+ else rowStops(row)[0]?.focus();
223
+ else stops[at + 1]?.focus();
224
+ break;
225
+ case 'ArrowLeft':
226
+ if (onRow) if (expanded && toggle) toggle(path);
227
+ else {
228
+ const parentPath = ancestorPaths(flatRow.node.segments)[0];
229
+ const parent = void 0 === parentPath ? void 0 : indexByPath.get(parentPath);
230
+ if (void 0 !== parent) focusRow(parent, void 0);
231
+ }
232
+ else (stops[at - 1] ?? row).focus();
233
+ break;
234
+ case 'Enter':
235
+ if (!onRow || !isParent || !toggle) return;
236
+ toggle(path);
237
+ break;
238
+ }
239
+ event.preventDefault();
240
+ event.stopPropagation();
241
+ };
242
+ const onFocus = (event)=>{
243
+ const { target } = event;
244
+ if (!(target instanceof HTMLElement)) return;
245
+ lastFocusedRef.current = target;
246
+ const path = target.closest(ROW_SELECTOR)?.dataset.path;
247
+ const index = void 0 === path ? void 0 : indexByPath.get(path);
248
+ const row = void 0 === index ? void 0 : rows[index];
249
+ if (void 0 === path || !row || path === active?.path) return;
250
+ setActive({
251
+ path,
252
+ segments: row.node.segments
253
+ });
254
+ };
255
+ const onBlur = (event)=>{
256
+ if (!event.currentTarget.contains(event.relatedTarget)) lastFocusedRef.current = null;
257
+ };
258
+ return {
259
+ activePath,
260
+ gridHandlers: {
261
+ ref: setGrid,
262
+ onFocus,
263
+ onBlur,
264
+ onKeyDownCapture: onKeyDown
265
+ },
266
+ trackEditor
267
+ };
268
+ }
269
+ export { isParentRow, useTreeGrid };
@@ -29,6 +29,7 @@ __webpack_require__.d(__webpack_exports__, {
29
29
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
30
  const external_lucide_react_namespaceObject = require("lucide-react");
31
31
  const external_react_namespaceObject = require("react");
32
+ const external_button_cjs_namespaceObject = require("../../button.cjs");
32
33
  const external_dropdown_menu_cjs_namespaceObject = require("../../dropdown-menu.cjs");
33
34
  const external_form_field_cjs_namespaceObject = require("../../form-field.cjs");
34
35
  const external_popover_cjs_namespaceObject = require("../../popover.cjs");
@@ -68,8 +69,7 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
68
69
  const typeMeta = external_types_cjs_namespaceObject.FIELD_TYPE_META[fieldType];
69
70
  const typeLabel = strings.typeLabels[fieldType] ?? typeMeta.label;
70
71
  const collapsedTextClass = (0, index_cjs_namespaceObject.cn)(collapse_cjs_namespaceObject.COLLAPSED_HIDDEN, compact && '!hidden');
71
- const collapsedPaddingClass = (0, index_cjs_namespaceObject.cn)(collapse_cjs_namespaceObject.COLLAPSED_ICON_PADDING, compact && '!px-1.5');
72
- const compactOnlyClass = (0, index_cjs_namespaceObject.cn)(collapse_cjs_namespaceObject.COLLAPSED_ONLY, compact && '!block');
72
+ const compactOnlyClass = (0, index_cjs_namespaceObject.cn)(collapse_cjs_namespaceObject.COLLAPSED_ONLY, compact && '!flex');
73
73
  const hasActions = !!onFieldTypeChange || !!onRequiredChange || showFieldActions || null != headerActions;
74
74
  if (null != label && !hasActions) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
75
75
  children: label
@@ -94,22 +94,21 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
94
94
  asChild: true,
95
95
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuTrigger, {
96
96
  asChild: true,
97
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("button", {
97
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
98
98
  type: "button",
99
+ variant: "ghost",
100
+ size: "3xs",
99
101
  "aria-label": strings.fieldTypeAriaLabel,
100
102
  disabled: disabled,
101
- className: (0, index_cjs_namespaceObject.cn)('flex h-7 items-center gap-1 rounded-lg px-2 text-[11px] text-foreground-subtle transition hover:bg-surface-overlay hover:text-foreground disabled:pointer-events-none disabled:opacity-50', collapsedPaddingClass),
103
+ className: (0, index_cjs_namespaceObject.cn)('gap-1', collapse_cjs_namespaceObject.FIELD_ACTION_CLASS),
102
104
  children: [
103
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(typeMeta.icon, {
104
- size: 12
105
- }),
105
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(typeMeta.icon, {}),
106
106
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
107
107
  className: collapsedTextClass,
108
108
  children: typeLabel
109
109
  }),
110
110
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronDown, {
111
- size: 9,
112
- className: collapsedTextClass
111
+ className: (0, index_cjs_namespaceObject.cn)('!size-2.5', collapsedTextClass)
113
112
  })
114
113
  ]
115
114
  })
@@ -178,14 +177,15 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
178
177
  asChild: true,
179
178
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
180
179
  asChild: true,
181
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
180
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
182
181
  type: "button",
182
+ variant: "ghost",
183
+ size: "3xs",
184
+ icon: true,
183
185
  "aria-label": required ? strings.requiredAriaLabel : strings.optionalAriaLabel,
184
186
  disabled: disabled,
185
- className: "grid size-7 place-items-center rounded-lg text-foreground-subtle transition hover:bg-surface-overlay hover:text-foreground disabled:pointer-events-none disabled:opacity-50",
186
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Asterisk, {
187
- size: 12
188
- })
187
+ className: collapse_cjs_namespaceObject.FIELD_ACTION_CLASS,
188
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Asterisk, {})
189
189
  })
190
190
  })
191
191
  }),
@@ -1,6 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Asterisk, ChevronDown } from "lucide-react";
3
3
  import { useMemo } from "react";
4
+ import { Button } from "../../button.js";
4
5
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../../dropdown-menu.js";
5
6
  import { FormFieldHeader } from "../../form-field.js";
6
7
  import { Popover, PopoverContent, PopoverTrigger } from "../../popover.js";
@@ -8,7 +9,7 @@ import { Switch } from "../../switch.js";
8
9
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../tooltip.js";
9
10
  import { cn } from "../../../../lib/index.js";
10
11
  import { AiAssistAction } from "../../field-actions/ai-assist-action.js";
11
- import { COLLAPSED_HIDDEN, COLLAPSED_ICON_PADDING, COLLAPSED_ONLY } from "../../field-actions/collapse.js";
12
+ import { COLLAPSED_HIDDEN, COLLAPSED_ONLY, FIELD_ACTION_CLASS } from "../../field-actions/collapse.js";
12
13
  import { InsertVariableAction } from "../../field-actions/insert-variable-action.js";
13
14
  import { FIELD_TYPE_META, FIELD_TYPE_ORDER } from "../types.js";
14
15
  function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTypes = FIELD_TYPE_ORDER, onFieldTypeChange, onRequiredChange, compact, disabled, isExpression, showFieldActions, onValueChange, variables, onGenerateWithAi, onInsertVariable, strings, headerActions }) {
@@ -40,8 +41,7 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
40
41
  const typeMeta = FIELD_TYPE_META[fieldType];
41
42
  const typeLabel = strings.typeLabels[fieldType] ?? typeMeta.label;
42
43
  const collapsedTextClass = cn(COLLAPSED_HIDDEN, compact && '!hidden');
43
- const collapsedPaddingClass = cn(COLLAPSED_ICON_PADDING, compact && '!px-1.5');
44
- const compactOnlyClass = cn(COLLAPSED_ONLY, compact && '!block');
44
+ const compactOnlyClass = cn(COLLAPSED_ONLY, compact && '!flex');
45
45
  const hasActions = !!onFieldTypeChange || !!onRequiredChange || showFieldActions || null != headerActions;
46
46
  if (null != label && !hasActions) return /*#__PURE__*/ jsx(Fragment, {
47
47
  children: label
@@ -66,22 +66,21 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
66
66
  asChild: true,
67
67
  children: /*#__PURE__*/ jsx(DropdownMenuTrigger, {
68
68
  asChild: true,
69
- children: /*#__PURE__*/ jsxs("button", {
69
+ children: /*#__PURE__*/ jsxs(Button, {
70
70
  type: "button",
71
+ variant: "ghost",
72
+ size: "3xs",
71
73
  "aria-label": strings.fieldTypeAriaLabel,
72
74
  disabled: disabled,
73
- className: cn('flex h-7 items-center gap-1 rounded-lg px-2 text-[11px] text-foreground-subtle transition hover:bg-surface-overlay hover:text-foreground disabled:pointer-events-none disabled:opacity-50', collapsedPaddingClass),
75
+ className: cn('gap-1', FIELD_ACTION_CLASS),
74
76
  children: [
75
- /*#__PURE__*/ jsx(typeMeta.icon, {
76
- size: 12
77
- }),
77
+ /*#__PURE__*/ jsx(typeMeta.icon, {}),
78
78
  /*#__PURE__*/ jsx("span", {
79
79
  className: collapsedTextClass,
80
80
  children: typeLabel
81
81
  }),
82
82
  /*#__PURE__*/ jsx(ChevronDown, {
83
- size: 9,
84
- className: collapsedTextClass
83
+ className: cn('!size-2.5', collapsedTextClass)
85
84
  })
86
85
  ]
87
86
  })
@@ -150,14 +149,15 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
150
149
  asChild: true,
151
150
  children: /*#__PURE__*/ jsx(PopoverTrigger, {
152
151
  asChild: true,
153
- children: /*#__PURE__*/ jsx("button", {
152
+ children: /*#__PURE__*/ jsx(Button, {
154
153
  type: "button",
154
+ variant: "ghost",
155
+ size: "3xs",
156
+ icon: true,
155
157
  "aria-label": required ? strings.requiredAriaLabel : strings.optionalAriaLabel,
156
158
  disabled: disabled,
157
- className: "grid size-7 place-items-center rounded-lg text-foreground-subtle transition hover:bg-surface-overlay hover:text-foreground disabled:pointer-events-none disabled:opacity-50",
158
- children: /*#__PURE__*/ jsx(Asterisk, {
159
- size: 12
160
- })
159
+ className: FIELD_ACTION_CLASS,
160
+ children: /*#__PURE__*/ jsx(Asterisk, {})
161
161
  })
162
162
  })
163
163
  }),
@@ -40,6 +40,7 @@ const external_lucide_react_namespaceObject = require("lucide-react");
40
40
  const external_react_namespaceObject = require("react");
41
41
  const index_cjs_namespaceObject = require("../../lib/index.cjs");
42
42
  const disclosure_row_cjs_namespaceObject = require("../../lib/disclosure-row.cjs");
43
+ const use_isomorphic_layout_effect_cjs_namespaceObject = require("../../lib/use-isomorphic-layout-effect.cjs");
43
44
  const external_collapsible_cjs_namespaceObject = require("./collapsible.cjs");
44
45
  const external_json_tree_view_index_cjs_namespaceObject = require("./json-tree-view/index.cjs");
45
46
  const DEFAULT_TOOL_CALL_STRINGS = {
@@ -70,7 +71,6 @@ function mergeStrings(overrides) {
70
71
  }
71
72
  return merged;
72
73
  }
73
- const useIsomorphicLayoutEffect = "u" < typeof window ? external_react_namespaceObject.useEffect : external_react_namespaceObject.useLayoutEffect;
74
74
  const TOGGLE_CLASSES = `${disclosure_row_cjs_namespaceObject.disclosureRowClassName} hover:text-foreground`;
75
75
  const toolCallVariants = (0, external_class_variance_authority_namespaceObject.cva)('group/tool-call flex w-full min-w-0 flex-col text-muted-foreground', {
76
76
  variants: {
@@ -191,7 +191,7 @@ const ToolCallHeader = /*#__PURE__*/ external_react_namespaceObject.forwardRef((
191
191
  ToolCallHeader.displayName = 'ToolCallHeader';
192
192
  const ToolCallContent = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, ...props }, ref)=>{
193
193
  const { registerContent } = useToolCallContext('ToolCallContent');
194
- useIsomorphicLayoutEffect(()=>registerContent(), [
194
+ (0, use_isomorphic_layout_effect_cjs_namespaceObject.useIsomorphicLayoutEffect)(()=>registerContent(), [
195
195
  registerContent
196
196
  ]);
197
197
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_collapsible_cjs_namespaceObject.CollapsibleContent, {
@@ -1,9 +1,10 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { cva } from "class-variance-authority";
3
3
  import { ChevronDown, ChevronRight, CircleCheck, CircleX, Clock, Loader2 } from "lucide-react";
4
- import { createContext, forwardRef, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useState } from "react";
4
+ import { createContext, forwardRef, useCallback, useContext, useMemo, useState } from "react";
5
5
  import { cn } from "../../lib/index.js";
6
6
  import { disclosureRowClassName } from "../../lib/disclosure-row.js";
7
+ import { useIsomorphicLayoutEffect } from "../../lib/use-isomorphic-layout-effect.js";
7
8
  import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./collapsible.js";
8
9
  import { JsonTreeView, buildJsonTree, collectContainerPaths } from "./json-tree-view/index.js";
9
10
  const DEFAULT_TOOL_CALL_STRINGS = {
@@ -34,7 +35,6 @@ function mergeStrings(overrides) {
34
35
  }
35
36
  return merged;
36
37
  }
37
- const useIsomorphicLayoutEffect = "u" < typeof window ? useEffect : useLayoutEffect;
38
38
  const TOGGLE_CLASSES = `${disclosureRowClassName} hover:text-foreground`;
39
39
  const toolCallVariants = cva('group/tool-call flex w-full min-w-0 flex-col text-muted-foreground', {
40
40
  variants: {
@@ -37,6 +37,7 @@ async function copyTextToClipboard(text) {
37
37
  textarea.setAttribute('readonly', '');
38
38
  textarea.style.position = 'fixed';
39
39
  textarea.style.opacity = '0';
40
+ const previousFocus = document.activeElement;
40
41
  document.body.appendChild(textarea);
41
42
  const selection = document.getSelection();
42
43
  const previousRange = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : null;
@@ -48,6 +49,9 @@ async function copyTextToClipboard(text) {
48
49
  copied = false;
49
50
  }
50
51
  textarea.remove();
52
+ if (previousFocus instanceof HTMLElement) previousFocus.focus({
53
+ preventScroll: true
54
+ });
51
55
  if (previousRange && selection) {
52
56
  selection.removeAllRanges();
53
57
  selection.addRange(previousRange);
@@ -9,6 +9,7 @@ async function copyTextToClipboard(text) {
9
9
  textarea.setAttribute('readonly', '');
10
10
  textarea.style.position = 'fixed';
11
11
  textarea.style.opacity = '0';
12
+ const previousFocus = document.activeElement;
12
13
  document.body.appendChild(textarea);
13
14
  const selection = document.getSelection();
14
15
  const previousRange = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : null;
@@ -20,6 +21,9 @@ async function copyTextToClipboard(text) {
20
21
  copied = false;
21
22
  }
22
23
  textarea.remove();
24
+ if (previousFocus instanceof HTMLElement) previousFocus.focus({
25
+ preventScroll: true
26
+ });
23
27
  if (previousRange && selection) {
24
28
  selection.removeAllRanges();
25
29
  selection.addRange(previousRange);
@@ -27,11 +27,11 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  useAncestorDensity: ()=>useAncestorDensity
28
28
  });
29
29
  const external_react_namespaceObject = require("react");
30
- const useIsomorphicLayoutEffect = "u" < typeof window ? external_react_namespaceObject.useEffect : external_react_namespaceObject.useLayoutEffect;
30
+ const external_use_isomorphic_layout_effect_cjs_namespaceObject = require("./use-isomorphic-layout-effect.cjs");
31
31
  function useAncestorDensity(node, enabled) {
32
32
  const [density, setDensity] = external_react_namespaceObject.useState(void 0);
33
33
  const watched = external_react_namespaceObject.useRef(null);
34
- useIsomorphicLayoutEffect(()=>{
34
+ (0, external_use_isomorphic_layout_effect_cjs_namespaceObject.useIsomorphicLayoutEffect)(()=>{
35
35
  const ancestor = enabled && node.current?.parentElement?.closest('[data-density="compact"]') || null;
36
36
  setDensity(ancestor ? 'compact' : void 0);
37
37
  if (watched.current?.ancestor === ancestor) return;
@@ -1,5 +1,5 @@
1
- import { useEffect, useLayoutEffect, useRef, useState } from "react";
2
- const useIsomorphicLayoutEffect = "u" < typeof window ? useEffect : useLayoutEffect;
1
+ import { useEffect, useRef, useState } from "react";
2
+ import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
3
3
  function useAncestorDensity(node, enabled) {
4
4
  const [density, setDensity] = useState(void 0);
5
5
  const watched = useRef(null);
@@ -0,0 +1,37 @@
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
+ useIsomorphicLayoutEffect: ()=>useIsomorphicLayoutEffect
28
+ });
29
+ const external_react_namespaceObject = require("react");
30
+ const useIsomorphicLayoutEffect = "u" < typeof window ? external_react_namespaceObject.useEffect : external_react_namespaceObject.useLayoutEffect;
31
+ exports.useIsomorphicLayoutEffect = __webpack_exports__.useIsomorphicLayoutEffect;
32
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
33
+ "useIsomorphicLayoutEffect"
34
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
35
+ Object.defineProperty(exports, '__esModule', {
36
+ value: true
37
+ });
@@ -0,0 +1,3 @@
1
+ import { useEffect } from 'react';
2
+ /** `useLayoutEffect` in the browser, `useEffect` on the server (avoids React's SSR warning). */
3
+ export declare const useIsomorphicLayoutEffect: typeof useEffect;
@@ -0,0 +1,3 @@
1
+ import { useEffect, useLayoutEffect } from "react";
2
+ const useIsomorphicLayoutEffect = "u" < typeof window ? useEffect : useLayoutEffect;
3
+ export { useIsomorphicLayoutEffect };