@adecore/editor-react 0.31.12 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/AnchoredPopup.js +73 -19
  2. package/dist/AttributionCard.js +162 -4
  3. package/dist/BaselineStatus.js +62 -8
  4. package/dist/CallHierarchyPanel.js +977 -60
  5. package/dist/ChangeReview.js +76 -25
  6. package/dist/CodeAuthorsCard.js +314 -14
  7. package/dist/CompletionPopup.js +490 -83
  8. package/dist/DiffView.js +548 -181
  9. package/dist/EditorContextMenu.js +352 -34
  10. package/dist/EditorView.js +276 -99
  11. package/dist/FindReplace.js +525 -67
  12. package/dist/HoverCard.js +378 -38
  13. package/dist/HoverSections.js +367 -56
  14. package/dist/LanguagePopups.js +95 -34
  15. package/dist/Markdown.js +41 -6
  16. package/dist/PanelResizeHandle.js +199 -66
  17. package/dist/PathText.js +49 -7
  18. package/dist/PeekPanel.js +675 -72
  19. package/dist/PickPopup.js +304 -34
  20. package/dist/RenameCard.js +679 -85
  21. package/dist/RenderedDocs.js +329 -58
  22. package/dist/SignatureCard.js +91 -7
  23. package/dist/SplitDiffView.js +344 -254
  24. package/dist/SymbolPicker.js +440 -85
  25. package/dist/call-hierarchy-model.js +102 -68
  26. package/dist/call-hierarchy.js +458 -359
  27. package/dist/code-actions-model.js +88 -76
  28. package/dist/code-actions.js +372 -283
  29. package/dist/code-authors.js +64 -55
  30. package/dist/code-vision-model.js +134 -127
  31. package/dist/code-vision.js +224 -206
  32. package/dist/completion-call.js +94 -67
  33. package/dist/completion-model.js +334 -244
  34. package/dist/completion.js +840 -649
  35. package/dist/conflict-model.js +35 -29
  36. package/dist/context-menu-rows.js +42 -17
  37. package/dist/context-menu.js +64 -46
  38. package/dist/definition-link.js +88 -85
  39. package/dist/diagnostics-model.js +74 -55
  40. package/dist/diagnostics.js +121 -100
  41. package/dist/diff-expansion.js +38 -35
  42. package/dist/diff-overlays.js +144 -22
  43. package/dist/diff-syntax.js +65 -42
  44. package/dist/diff-wordmarks.js +26 -23
  45. package/dist/doc-comment-model.js +265 -216
  46. package/dist/editor-language.js +177 -152
  47. package/dist/error-message.js +2 -2
  48. package/dist/find-query.js +49 -36
  49. package/dist/folding.js +81 -62
  50. package/dist/format-on-type.js +86 -67
  51. package/dist/highlight-layers.js +19 -20
  52. package/dist/highlights.js +105 -83
  53. package/dist/history.js +44 -38
  54. package/dist/holder.js +18 -18
  55. package/dist/host-types.js +1 -1
  56. package/dist/hover-content.js +167 -129
  57. package/dist/hover.js +285 -245
  58. package/dist/index.js +10 -10
  59. package/dist/inlay-hints.js +369 -324
  60. package/dist/key-priority.js +34 -31
  61. package/dist/language-ids.js +45 -42
  62. package/dist/line-edits.js +74 -28
  63. package/dist/line-text.js +18 -3
  64. package/dist/locales/en.json +38 -38
  65. package/dist/locales/nl.json +41 -41
  66. package/dist/models.js +1 -1
  67. package/dist/navigation-history.js +40 -41
  68. package/dist/navigation.js +141 -123
  69. package/dist/panel-size.js +8 -8
  70. package/dist/patch-decorations.js +236 -160
  71. package/dist/patch-layout.js +331 -262
  72. package/dist/paths.js +3 -3
  73. package/dist/peek-model.js +86 -69
  74. package/dist/peek.js +254 -192
  75. package/dist/pick.js +164 -157
  76. package/dist/popup-focus.js +5 -5
  77. package/dist/popup-placement.js +36 -21
  78. package/dist/popups.js +13 -13
  79. package/dist/project-language.js +228 -211
  80. package/dist/project-problems.js +81 -69
  81. package/dist/proposal-model.js +163 -126
  82. package/dist/recent-choices.js +25 -25
  83. package/dist/refresher.js +44 -49
  84. package/dist/rename-model.js +113 -113
  85. package/dist/rename.js +321 -233
  86. package/dist/rendered-docs.d.ts +4 -2
  87. package/dist/rendered-docs.js +384 -318
  88. package/dist/rendering-context.js +5 -3
  89. package/dist/rendering.js +22 -4
  90. package/dist/review-group.js +42 -39
  91. package/dist/row-host.d.ts +4 -2
  92. package/dist/row-host.js +90 -78
  93. package/dist/selection-ranges.js +21 -17
  94. package/dist/semantic-delta.js +22 -19
  95. package/dist/semantic-model.js +86 -73
  96. package/dist/semantic-tokens.js +201 -162
  97. package/dist/shortcut-keys.js +16 -10
  98. package/dist/signature-model.js +34 -28
  99. package/dist/signature.js +177 -129
  100. package/dist/snippet-field-transforms.js +118 -106
  101. package/dist/snippet-indent.js +48 -43
  102. package/dist/snippet-range-order.js +11 -11
  103. package/dist/snippet-session.js +703 -667
  104. package/dist/snippet-transform-client.js +59 -59
  105. package/dist/snippet-transform-format.js +285 -263
  106. package/dist/snippet-transform-protocol.js +1 -1
  107. package/dist/snippet-transform-queue.js +163 -153
  108. package/dist/snippet-transform-worker.js +42 -35
  109. package/dist/snippet-variable-names.js +1 -36
  110. package/dist/snippet-variables.js +53 -63
  111. package/dist/snippet.js +477 -405
  112. package/dist/split-alignment.js +47 -35
  113. package/dist/split-scroll.js +42 -40
  114. package/dist/symbol-links.js +33 -25
  115. package/dist/symbol-picker-model.js +126 -116
  116. package/dist/symbol-picker.js +98 -59
  117. package/dist/symbols.js +117 -88
  118. package/dist/testing.js +248 -165
  119. package/dist/timers.js +35 -30
  120. package/dist/use-panel-body.js +49 -8
  121. package/dist/use-problem-counts.js +29 -15
  122. package/dist/view-state.js +54 -33
  123. package/dist/word-diff.js +18 -18
  124. package/dist/workspace-edit.js +300 -249
  125. package/package.json +6 -6
  126. package/src/CallHierarchyPanel.tsx +2 -2
  127. package/src/DiffView.tsx +3 -3
  128. package/src/FindReplace.tsx +2 -2
  129. package/src/LanguagePopups.tsx +2 -0
  130. package/src/PeekPanel.tsx +3 -3
  131. package/src/RenderedDocs.tsx +9 -10
  132. package/src/SymbolPicker.tsx +2 -2
  133. package/src/diff-overlays.tsx +6 -4
  134. package/src/locales/en.json +38 -38
  135. package/src/locales/nl.json +41 -41
  136. package/src/rendered-docs.ts +14 -3
  137. package/src/row-host.ts +14 -3
@@ -1,37 +1,80 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { useId, useLayoutEffect, useRef, useState } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { formatShortcut } from '@adecore/ui';
6
6
  import { kindLetterOf, kindToneOf, rowWindow } from './completion-model.js';
7
- import { SourceLine, SymbolSections } from './HoverSections.js';
8
- import { PathText } from './PathText.js';
7
+ import { SourceLine, SymbolSections } from "./HoverSections.js";
8
+ import { PathText } from "./PathText.js";
9
9
  import { keepFocusOutOfList } from './popup-focus.js';
10
10
  import { placeBeside, placePopup } from './popup-placement.js';
11
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
12
  const TONES = {
12
- callable: 'bg-accent-soft text-accent',
13
- value: 'bg-status-running/15 text-status-running',
14
- type: 'bg-status-idle/15 text-status-idle',
15
- other: 'bg-surface-hover text-text-muted'
13
+ callable: 'bg-accent-soft text-accent',
14
+ value: 'bg-status-running/15 text-status-running',
15
+ type: 'bg-status-idle/15 text-status-idle',
16
+ other: 'bg-surface-hover text-text-muted'
16
17
  };
17
18
  /* The label with the characters that match what was typed set apart. */
18
- function MarkedLabel({ label, matches }) {
19
- if (matches.length === 0) {
20
- return _jsx(_Fragment, { children: label });
19
+ function MarkedLabel(t0) {
20
+ const $ = _c(7);
21
+ const {
22
+ label,
23
+ matches
24
+ } = t0;
25
+ if (matches.length === 0) {
26
+ let t1;
27
+ if ($[0] !== label) {
28
+ t1 = /*#__PURE__*/_jsx(_Fragment, {
29
+ children: label
30
+ });
31
+ $[0] = label;
32
+ $[1] = t1;
33
+ } else {
34
+ t1 = $[1];
21
35
  }
22
- const marked = new Set(matches);
36
+ return t1;
37
+ }
38
+ let t1;
39
+ if ($[2] !== matches) {
40
+ t1 = new Set(matches);
41
+ $[2] = matches;
42
+ $[3] = t1;
43
+ } else {
44
+ t1 = $[3];
45
+ }
46
+ const marked = t1;
47
+ let t2;
48
+ if ($[4] !== label || $[5] !== marked) {
23
49
  const runs = [];
24
50
  for (let at = 0; at < label.length; at++) {
25
- const isMarked = marked.has(at);
26
- const last = runs[runs.length - 1];
27
- if (last !== undefined && last.marked === isMarked) {
28
- last.text += label[at];
29
- }
30
- else {
31
- runs.push({ text: label[at], marked: isMarked });
32
- }
51
+ const isMarked = marked.has(at);
52
+ const last = runs[runs.length - 1];
53
+ if (last !== undefined && last.marked === isMarked) {
54
+ last.text = last.text + label[at];
55
+ } else {
56
+ runs.push({
57
+ text: label[at],
58
+ marked: isMarked
59
+ });
60
+ }
33
61
  }
34
- return (_jsx(_Fragment, { children: runs.map((run, index) => run.marked ? (_jsx("span", { className: "font-semibold text-accent", children: run.text }, index)) : (run.text)) }));
62
+ t2 = /*#__PURE__*/_jsx(_Fragment, {
63
+ children: runs.map(_temp)
64
+ });
65
+ $[4] = label;
66
+ $[5] = marked;
67
+ $[6] = t2;
68
+ } else {
69
+ t2 = $[6];
70
+ }
71
+ return t2;
72
+ }
73
+ function _temp(run, index) {
74
+ return run.marked ? /*#__PURE__*/_jsx("span", {
75
+ className: "font-semibold text-accent",
76
+ children: run.text
77
+ }, index) : run.text;
35
78
  }
36
79
  const CARD = 'fixed top-0 left-0 z-(--z-popup) overflow-hidden rounded-lg border border-border bg-surface-raised text-text shadow-(--float-shadow)';
37
80
  const ROW_HEIGHT = 24;
@@ -47,69 +90,433 @@ const ROW_CHROME = 72;
47
90
  * documentation of the active one beside it, or under it when the window has no room at its side. A
48
91
  * press on a row never takes the focus from the editor, so typing goes on while the list is open.
49
92
  */
50
- export function CompletionPopup({ language, view, rect }) {
51
- const { t } = useTranslation('editor');
52
- const toggle = language.shortcuts.triggerCompletion;
53
- const detailsKey = toggle === null ? null : formatShortcut(toggle, toggle.apple);
54
- const listId = useId();
55
- const list = useRef(null);
56
- const docs = useRef(null);
57
- const activeRow = useRef(null);
58
- // The widest row so far in characters, which only grows, so the list never narrows or jumps while it is typed into.
59
- const [widest, setWidest] = useState(0);
60
- // Only the rows near the visible ones are drawn: a list of 150 is mostly out of sight, and every keystroke makes it again.
61
- const [listTop, setListTop] = useState(0);
62
- const need = Math.max(0, ...view.rows.slice(0, VISIBLE_ROWS * 2).map((row) => row.label.length + 2 + row.description.length));
63
- if (need > widest) {
64
- setWidest(need);
65
- }
66
- // Every render: the word moves when the editor scrolls, and the list and the documentation change size with what they hold.
67
- useLayoutEffect(() => {
68
- const card = list.current;
69
- if (card === null) {
70
- return;
71
- }
72
- const viewport = {
73
- width: window.innerWidth,
74
- height: window.innerHeight
93
+ export function CompletionPopup(t0) {
94
+ const $ = _c(78);
95
+ const {
96
+ language,
97
+ view,
98
+ rect
99
+ } = t0;
100
+ const {
101
+ t
102
+ } = useTranslation("editor");
103
+ const toggle = language.shortcuts.triggerCompletion;
104
+ let t1;
105
+ if ($[0] !== toggle) {
106
+ t1 = toggle === null ? null : formatShortcut(toggle, toggle.apple);
107
+ $[0] = toggle;
108
+ $[1] = t1;
109
+ } else {
110
+ t1 = $[1];
111
+ }
112
+ const detailsKey = t1;
113
+ const listId = useId();
114
+ const list = useRef(null);
115
+ const docs = useRef(null);
116
+ const activeRow = useRef(null);
117
+ const [widest, setWidest] = useState(0);
118
+ const [listTop, setListTop] = useState(0);
119
+ let t2;
120
+ if ($[2] !== view.rows) {
121
+ t2 = Math.max(0, ...view.rows.slice(0, VISIBLE_ROWS * 2).map(_temp2));
122
+ $[2] = view.rows;
123
+ $[3] = t2;
124
+ } else {
125
+ t2 = $[3];
126
+ }
127
+ const need = t2;
128
+ if (need > widest) {
129
+ setWidest(need);
130
+ }
131
+ let t3;
132
+ if ($[4] !== rect) {
133
+ t3 = () => {
134
+ const card = list.current;
135
+ if (card === null) {
136
+ return;
137
+ }
138
+ const viewport = {
139
+ width: window.innerWidth,
140
+ height: window.innerHeight
141
+ };
142
+ const side = docs.current;
143
+ const size = {
144
+ width: card.offsetWidth,
145
+ height: card.offsetHeight
146
+ };
147
+ const sideSize = side === null ? null : {
148
+ width: side.offsetWidth,
149
+ height: side.offsetHeight
150
+ };
151
+ const placed = placePopup(rect, size, viewport, {
152
+ gap: 2
153
+ });
154
+ card.style.left = `${Math.round(placed.left)}px`;
155
+ card.style.top = `${Math.round(placed.top)}px`;
156
+ card.style.visibility = "visible";
157
+ if (side !== null && sideSize !== null) {
158
+ const box = {
159
+ left: Math.round(placed.left),
160
+ top: Math.round(placed.top),
161
+ ...size
75
162
  };
76
- const side = docs.current;
77
- // Every size is read before the first write, so the page is laid out once and not after each of them.
78
- const size = { width: card.offsetWidth, height: card.offsetHeight };
79
- const sideSize = side === null ? null : { width: side.offsetWidth, height: side.offsetHeight };
80
- const placed = placePopup(rect, size, viewport, { gap: 2 });
81
- card.style.left = `${Math.round(placed.left)}px`;
82
- card.style.top = `${Math.round(placed.top)}px`;
83
- card.style.visibility = 'visible';
84
- if (side !== null && sideSize !== null) {
85
- const box = {
86
- left: Math.round(placed.left),
87
- top: Math.round(placed.top),
88
- ...size
89
- };
90
- const beside = placeBeside(box, sideSize, viewport);
91
- side.style.left = `${Math.round(beside.left)}px`;
92
- side.style.top = `${Math.round(beside.top)}px`;
93
- side.style.maxHeight = `${Math.floor(beside.maxHeight)}px`;
94
- side.style.visibility = 'visible';
95
- }
163
+ const beside = placeBeside(box, sideSize, viewport);
164
+ side.style.left = `${Math.round(beside.left)}px`;
165
+ side.style.top = `${Math.round(beside.top)}px`;
166
+ side.style.maxHeight = `${Math.floor(beside.maxHeight)}px`;
167
+ side.style.visibility = "visible";
168
+ }
169
+ };
170
+ $[4] = rect;
171
+ $[5] = t3;
172
+ } else {
173
+ t3 = $[5];
174
+ }
175
+ useLayoutEffect(t3);
176
+ let t4;
177
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
178
+ t4 = () => {
179
+ activeRow.current?.scrollIntoView({
180
+ block: "nearest"
181
+ });
182
+ };
183
+ $[6] = t4;
184
+ } else {
185
+ t4 = $[6];
186
+ }
187
+ let t5;
188
+ if ($[7] !== view.active || $[8] !== view.rows) {
189
+ t5 = [view.active, view.rows];
190
+ $[7] = view.active;
191
+ $[8] = view.rows;
192
+ $[9] = t5;
193
+ } else {
194
+ t5 = $[9];
195
+ }
196
+ useLayoutEffect(t4, t5);
197
+ const total = view.rows.length;
198
+ let t6;
199
+ if ($[10] !== listTop || $[11] !== total || $[12] !== view.active) {
200
+ t6 = rowWindow(listTop, view.active, total, ROW_HEIGHT, VISIBLE_ROWS, OVERSCAN_ROWS, LIST_PADDING);
201
+ $[10] = listTop;
202
+ $[11] = total;
203
+ $[12] = view.active;
204
+ $[13] = t6;
205
+ } else {
206
+ t6 = $[13];
207
+ }
208
+ const {
209
+ first,
210
+ last
211
+ } = t6;
212
+ let t7;
213
+ if ($[14] !== listId) {
214
+ t7 = index => `${listId}-option-${index}`;
215
+ $[14] = listId;
216
+ $[15] = t7;
217
+ } else {
218
+ t7 = $[15];
219
+ }
220
+ const optionId = t7;
221
+ const activeId = view.active >= first && view.active < last ? optionId(view.active) : undefined;
222
+ let t8;
223
+ if ($[16] !== activeId || $[17] !== language.editor || $[18] !== listId) {
224
+ t8 = () => {
225
+ language.editor.setInputPopup({
226
+ controls: listId,
227
+ activeDescendant: activeId
228
+ });
229
+ return () => language.editor.setInputPopup(null);
230
+ };
231
+ $[16] = activeId;
232
+ $[17] = language.editor;
233
+ $[18] = listId;
234
+ $[19] = t8;
235
+ } else {
236
+ t8 = $[19];
237
+ }
238
+ let t9;
239
+ if ($[20] !== activeId || $[21] !== language || $[22] !== listId) {
240
+ t9 = [language, listId, activeId];
241
+ $[20] = activeId;
242
+ $[21] = language;
243
+ $[22] = listId;
244
+ $[23] = t9;
245
+ } else {
246
+ t9 = $[23];
247
+ }
248
+ useLayoutEffect(t8, t9);
249
+ let t10;
250
+ if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
251
+ t10 = {
252
+ visibility: "hidden"
253
+ };
254
+ $[24] = t10;
255
+ } else {
256
+ t10 = $[24];
257
+ }
258
+ let t11;
259
+ if ($[25] !== language.editor) {
260
+ t11 = keepFocusOutOfList(() => language.editor.focus());
261
+ $[25] = language.editor;
262
+ $[26] = t11;
263
+ } else {
264
+ t11 = $[26];
265
+ }
266
+ const t12 = `calc(${Math.max(widest, need)}ch + ${ROW_CHROME}px)`;
267
+ let t13;
268
+ if ($[27] !== t12) {
269
+ t13 = /*#__PURE__*/_jsx("div", {
270
+ "aria-hidden": true,
271
+ className: "h-0 overflow-hidden font-mono text-code",
272
+ style: {
273
+ width: t12
274
+ }
275
+ });
276
+ $[27] = t12;
277
+ $[28] = t13;
278
+ } else {
279
+ t13 = $[28];
280
+ }
281
+ let t14;
282
+ let t15;
283
+ if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
284
+ t14 = {
285
+ maxHeight: ROW_HEIGHT * VISIBLE_ROWS + 8
286
+ };
287
+ t15 = event_0 => setListTop(event_0.currentTarget.scrollTop);
288
+ $[29] = t14;
289
+ $[30] = t15;
290
+ } else {
291
+ t14 = $[29];
292
+ t15 = $[30];
293
+ }
294
+ const t16 = first * ROW_HEIGHT;
295
+ let t17;
296
+ if ($[31] !== t16) {
297
+ t17 = /*#__PURE__*/_jsx("div", {
298
+ "aria-hidden": true,
299
+ style: {
300
+ height: t16
301
+ }
302
+ });
303
+ $[31] = t16;
304
+ $[32] = t17;
305
+ } else {
306
+ t17 = $[32];
307
+ }
308
+ let t18;
309
+ if ($[33] !== first || $[34] !== language.completion || $[35] !== last || $[36] !== optionId || $[37] !== total || $[38] !== view.active || $[39] !== view.rows) {
310
+ t18 = view.rows.slice(first, last).map((row_0, offset) => {
311
+ const index_0 = first + offset;
312
+ return /*#__PURE__*/_jsxs("button", {
313
+ id: optionId(index_0),
314
+ ref: index_0 === view.active ? activeRow : undefined,
315
+ type: "button",
316
+ role: "option",
317
+ tabIndex: -1,
318
+ "aria-selected": index_0 === view.active,
319
+ "aria-setsize": total,
320
+ "aria-posinset": index_0 + 1,
321
+ "data-active": index_0 === view.active,
322
+ className: "flex h-6 w-full items-center gap-2 overflow-hidden rounded-md px-1.5 text-left text-xs cursor-row",
323
+ onClick: () => void language.completion.accept(false, index_0),
324
+ children: [/*#__PURE__*/_jsx("span", {
325
+ className: `grid size-4 shrink-0 place-items-center rounded-sm font-mono text-xs leading-none font-semibold ${TONES[kindToneOf(row_0.kind)]}`,
326
+ children: kindLetterOf(row_0.kind)
327
+ }), /*#__PURE__*/_jsx("span", {
328
+ className: `max-w-full shrink-0 truncate font-mono text-code ${row_0.deprecated ? "line-through" : ""}`,
329
+ children: /*#__PURE__*/_jsx(MarkedLabel, {
330
+ label: row_0.label,
331
+ matches: row_0.matches
332
+ })
333
+ }), /*#__PURE__*/_jsx("span", {
334
+ className: "min-w-0 grow truncate font-mono text-text-faint",
335
+ children: row_0.detail
336
+ }), /*#__PURE__*/_jsx(PathText, {
337
+ path: row_0.description,
338
+ className: "max-w-[60%] font-mono text-text-faint"
339
+ })]
340
+ }, `${index_0}:${row_0.label}`);
341
+ });
342
+ $[33] = first;
343
+ $[34] = language.completion;
344
+ $[35] = last;
345
+ $[36] = optionId;
346
+ $[37] = total;
347
+ $[38] = view.active;
348
+ $[39] = view.rows;
349
+ $[40] = t18;
350
+ } else {
351
+ t18 = $[40];
352
+ }
353
+ const t19 = (total - last) * ROW_HEIGHT;
354
+ let t20;
355
+ if ($[41] !== t19) {
356
+ t20 = /*#__PURE__*/_jsx("div", {
357
+ "aria-hidden": true,
358
+ style: {
359
+ height: t19
360
+ }
361
+ });
362
+ $[41] = t19;
363
+ $[42] = t20;
364
+ } else {
365
+ t20 = $[42];
366
+ }
367
+ let t21;
368
+ if ($[43] !== listId || $[44] !== t17 || $[45] !== t18 || $[46] !== t20) {
369
+ t21 = /*#__PURE__*/_jsxs("div", {
370
+ id: listId,
371
+ role: "listbox",
372
+ className: "w-0 min-w-full overflow-y-auto p-1",
373
+ style: t14,
374
+ onScroll: t15,
375
+ children: [t17, t18, t20]
96
376
  });
97
- useLayoutEffect(() => {
98
- activeRow.current?.scrollIntoView({ block: 'nearest' });
99
- }, [view.active, view.rows]);
100
- const total = view.rows.length;
101
- const { first, last } = rowWindow(listTop, view.active, total, ROW_HEIGHT, VISIBLE_ROWS, OVERSCAN_ROWS, LIST_PADDING);
102
- const optionId = (index) => `${listId}-option-${index}`;
103
- const activeId = view.active >= first && view.active < last ? optionId(view.active) : undefined;
104
- // The focus stays in the text, so the input is what names the list and its active option.
105
- useLayoutEffect(() => {
106
- language.editor.setInputPopup({ controls: listId, activeDescendant: activeId });
107
- return () => language.editor.setInputPopup(null);
108
- }, [language, listId, activeId]);
109
- return createPortal(_jsxs(_Fragment, { children: [_jsxs("div", { ref: list, className: `${CARD} flex w-max max-w-[min(560px,calc(100vw-16px))] min-w-[340px] flex-col`, style: { visibility: 'hidden' }, onPointerDown: (event) => event.preventDefault(), ...keepFocusOutOfList(() => language.editor.focus()), children: [_jsx("div", { "aria-hidden": true, className: "h-0 overflow-hidden font-mono text-code", style: {
110
- width: `calc(${Math.max(widest, need)}ch + ${ROW_CHROME}px)`
111
- } }), _jsxs("div", { id: listId, role: "listbox", className: "w-0 min-w-full overflow-y-auto p-1", style: { maxHeight: ROW_HEIGHT * VISIBLE_ROWS + 8 }, onScroll: (event) => setListTop(event.currentTarget.scrollTop), children: [_jsx("div", { "aria-hidden": true, style: { height: first * ROW_HEIGHT } }), view.rows.slice(first, last).map((row, offset) => {
112
- const index = first + offset;
113
- return (_jsxs("button", { id: optionId(index), ref: index === view.active ? activeRow : undefined, type: "button", role: "option", tabIndex: -1, "aria-selected": index === view.active, "aria-setsize": total, "aria-posinset": index + 1, "data-active": index === view.active, className: "flex h-6 w-full items-center gap-2 overflow-hidden rounded-md px-1.5 text-left text-xs cursor-row", onClick: () => void language.completion.accept(false, index), children: [_jsx("span", { className: `grid size-4 shrink-0 place-items-center rounded-sm font-mono text-xs leading-none font-semibold ${TONES[kindToneOf(row.kind)]}`, children: kindLetterOf(row.kind) }), _jsx("span", { className: `max-w-full shrink-0 truncate font-mono text-code ${row.deprecated ? 'line-through' : ''}`, children: _jsx(MarkedLabel, { label: row.label, matches: row.matches }) }), _jsx("span", { className: "min-w-0 grow truncate font-mono text-text-faint", children: row.detail }), _jsx(PathText, { path: row.description, className: "max-w-[60%] font-mono text-text-faint" })] }, `${index}:${row.label}`));
114
- }), _jsx("div", { "aria-hidden": true, style: { height: (total - last) * ROW_HEIGHT } })] }), _jsxs("div", { className: "flex items-center gap-3 border-t border-border px-2 py-1 text-xs whitespace-nowrap text-text-faint", children: [_jsxs("span", { children: ["\u21B5 ", t('language.completion.insert')] }), _jsxs("span", { children: ["\u21E5 ", t('language.completion.replace')] }), detailsKey !== null && (_jsxs("span", { children: [detailsKey, " ", t('language.completion.details')] })), _jsx("span", { className: "ml-auto", children: view.server })] })] }), view.detailsOpen && view.docs !== null && (_jsxs("div", { ref: docs, className: `${CARD} flex w-[360px] flex-col divide-y divide-border overflow-y-auto select-text`, style: { visibility: 'hidden' }, onPointerDown: (event) => event.preventDefault(), children: [view.docs.source !== '' && (_jsx("div", { className: "px-3 py-2", children: _jsx(SourceLine, { text: view.docs.source, language: view.highlightLanguage }) })), _jsx(SymbolSections, { text: view.docs.text })] }))] }), document.body);
377
+ $[43] = listId;
378
+ $[44] = t17;
379
+ $[45] = t18;
380
+ $[46] = t20;
381
+ $[47] = t21;
382
+ } else {
383
+ t21 = $[47];
384
+ }
385
+ let t22;
386
+ if ($[48] !== t) {
387
+ t22 = t("language.completion.insert");
388
+ $[48] = t;
389
+ $[49] = t22;
390
+ } else {
391
+ t22 = $[49];
392
+ }
393
+ let t23;
394
+ if ($[50] !== t22) {
395
+ t23 = /*#__PURE__*/_jsxs("span", {
396
+ children: ["\u21B5 ", t22]
397
+ });
398
+ $[50] = t22;
399
+ $[51] = t23;
400
+ } else {
401
+ t23 = $[51];
402
+ }
403
+ let t24;
404
+ if ($[52] !== t) {
405
+ t24 = t("language.completion.replace");
406
+ $[52] = t;
407
+ $[53] = t24;
408
+ } else {
409
+ t24 = $[53];
410
+ }
411
+ let t25;
412
+ if ($[54] !== t24) {
413
+ t25 = /*#__PURE__*/_jsxs("span", {
414
+ children: ["\u21E5 ", t24]
415
+ });
416
+ $[54] = t24;
417
+ $[55] = t25;
418
+ } else {
419
+ t25 = $[55];
420
+ }
421
+ let t26;
422
+ if ($[56] !== detailsKey || $[57] !== t) {
423
+ t26 = detailsKey !== null && /*#__PURE__*/_jsxs("span", {
424
+ children: [detailsKey, " ", t("language.completion.details")]
425
+ });
426
+ $[56] = detailsKey;
427
+ $[57] = t;
428
+ $[58] = t26;
429
+ } else {
430
+ t26 = $[58];
431
+ }
432
+ let t27;
433
+ if ($[59] !== view.server) {
434
+ t27 = /*#__PURE__*/_jsx("span", {
435
+ className: "ml-auto",
436
+ children: view.server
437
+ });
438
+ $[59] = view.server;
439
+ $[60] = t27;
440
+ } else {
441
+ t27 = $[60];
442
+ }
443
+ let t28;
444
+ if ($[61] !== t23 || $[62] !== t25 || $[63] !== t26 || $[64] !== t27) {
445
+ t28 = /*#__PURE__*/_jsxs("div", {
446
+ className: "flex items-center gap-3 border-t border-border px-2 py-1 text-xs whitespace-nowrap text-text-faint",
447
+ children: [t23, t25, t26, t27]
448
+ });
449
+ $[61] = t23;
450
+ $[62] = t25;
451
+ $[63] = t26;
452
+ $[64] = t27;
453
+ $[65] = t28;
454
+ } else {
455
+ t28 = $[65];
456
+ }
457
+ let t29;
458
+ if ($[66] !== t11 || $[67] !== t13 || $[68] !== t21 || $[69] !== t28) {
459
+ t29 = /*#__PURE__*/_jsxs("div", {
460
+ ref: list,
461
+ className: `${CARD} flex w-max max-w-[min(560px,calc(100vw-16px))] min-w-[340px] flex-col`,
462
+ style: t10,
463
+ onPointerDown: _temp3,
464
+ ...t11,
465
+ children: [t13, t21, t28]
466
+ });
467
+ $[66] = t11;
468
+ $[67] = t13;
469
+ $[68] = t21;
470
+ $[69] = t28;
471
+ $[70] = t29;
472
+ } else {
473
+ t29 = $[70];
474
+ }
475
+ let t30;
476
+ if ($[71] !== view.detailsOpen || $[72] !== view.docs || $[73] !== view.highlightLanguage) {
477
+ t30 = view.detailsOpen && view.docs !== null && /*#__PURE__*/_jsxs("div", {
478
+ ref: docs,
479
+ className: `${CARD} flex w-[360px] flex-col divide-y divide-border overflow-y-auto select-text`,
480
+ style: {
481
+ visibility: "hidden"
482
+ },
483
+ onPointerDown: _temp4,
484
+ children: [view.docs.source !== "" && /*#__PURE__*/_jsx("div", {
485
+ className: "px-3 py-2",
486
+ children: /*#__PURE__*/_jsx(SourceLine, {
487
+ text: view.docs.source,
488
+ language: view.highlightLanguage
489
+ })
490
+ }), /*#__PURE__*/_jsx(SymbolSections, {
491
+ text: view.docs.text
492
+ })]
493
+ });
494
+ $[71] = view.detailsOpen;
495
+ $[72] = view.docs;
496
+ $[73] = view.highlightLanguage;
497
+ $[74] = t30;
498
+ } else {
499
+ t30 = $[74];
500
+ }
501
+ let t31;
502
+ if ($[75] !== t29 || $[76] !== t30) {
503
+ t31 = createPortal(/*#__PURE__*/_jsxs(_Fragment, {
504
+ children: [t29, t30]
505
+ }), document.body);
506
+ $[75] = t29;
507
+ $[76] = t30;
508
+ $[77] = t31;
509
+ } else {
510
+ t31 = $[77];
511
+ }
512
+ return t31;
513
+ }
514
+ function _temp4(event_1) {
515
+ return event_1.preventDefault();
516
+ }
517
+ function _temp3(event) {
518
+ return event.preventDefault();
115
519
  }
520
+ function _temp2(row) {
521
+ return row.label.length + 2 + row.description.length;
522
+ }