@keboola/design 9.1.0 → 10.1.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 (84) hide show
  1. package/AGENTS.md +117 -40
  2. package/COMPONENT-API.md +31 -9
  3. package/README.md +3 -3
  4. package/dist/MermaidDiagram-EOKJHQQV.js +10 -0
  5. package/dist/MermaidDiagram-EOKJHQQV.js.map +1 -0
  6. package/dist/charts.d.ts +31 -2
  7. package/dist/charts.js +6 -9
  8. package/dist/charts.js.map +1 -1
  9. package/dist/chunk-63NSN2VL.js +274 -0
  10. package/dist/chunk-63NSN2VL.js.map +1 -0
  11. package/dist/{rjsf.cjs → chunk-6FPEI4EM.js} +1491 -5701
  12. package/dist/chunk-6FPEI4EM.js.map +1 -0
  13. package/dist/chunk-7PUUHEJQ.js +1313 -0
  14. package/dist/chunk-7PUUHEJQ.js.map +1 -0
  15. package/dist/chunk-BOHNXTMM.js +606 -0
  16. package/dist/chunk-BOHNXTMM.js.map +1 -0
  17. package/dist/{testing.cjs → chunk-C3L3TBBT.js} +33 -164
  18. package/dist/chunk-C3L3TBBT.js.map +1 -0
  19. package/dist/chunk-CTCFYWJC.js +407 -0
  20. package/dist/chunk-CTCFYWJC.js.map +1 -0
  21. package/dist/chunk-ESBL3IPF.js +23 -0
  22. package/dist/chunk-ESBL3IPF.js.map +1 -0
  23. package/dist/chunk-IJTHFNNJ.js +261 -0
  24. package/dist/chunk-IJTHFNNJ.js.map +1 -0
  25. package/dist/chunk-JP7PNHLH.js +40 -0
  26. package/dist/chunk-JP7PNHLH.js.map +1 -0
  27. package/dist/chunk-KPNAW5MU.js +229 -0
  28. package/dist/chunk-KPNAW5MU.js.map +1 -0
  29. package/dist/chunk-L37JJ6MR.js +152 -0
  30. package/dist/chunk-L37JJ6MR.js.map +1 -0
  31. package/dist/chunk-Q7NWXLCT.js +90 -0
  32. package/dist/chunk-Q7NWXLCT.js.map +1 -0
  33. package/dist/chunk-SYIEF644.js +1016 -0
  34. package/dist/chunk-SYIEF644.js.map +1 -0
  35. package/dist/chunk-VMFSRV5H.js +16 -0
  36. package/dist/chunk-VMFSRV5H.js.map +1 -0
  37. package/dist/chunk-VPPM7UUQ.js +47 -0
  38. package/dist/chunk-VPPM7UUQ.js.map +1 -0
  39. package/dist/chunk-XV3UUOYF.js +845 -0
  40. package/dist/chunk-XV3UUOYF.js.map +1 -0
  41. package/dist/editors.d.ts +27 -3
  42. package/dist/editors.js +85 -2081
  43. package/dist/editors.js.map +1 -1
  44. package/dist/icons.d.ts +29 -8
  45. package/dist/icons.js +2 -361
  46. package/dist/icons.js.map +1 -1
  47. package/dist/index.d.ts +709 -425
  48. package/dist/index.js +5042 -13885
  49. package/dist/index.js.map +1 -1
  50. package/dist/markdown-editor.js +41 -3426
  51. package/dist/markdown-editor.js.map +1 -1
  52. package/dist/mermaid.js +8 -1129
  53. package/dist/mermaid.js.map +1 -1
  54. package/dist/rjsf.js +180 -9381
  55. package/dist/rjsf.js.map +1 -1
  56. package/dist/styles.css +1 -1
  57. package/dist/testing.js +5 -357
  58. package/dist/testing.js.map +1 -1
  59. package/package.json +28 -73
  60. package/src/styles.css +60 -3
  61. package/src/theme.css +1 -0
  62. package/dist/charts.cjs +0 -268
  63. package/dist/charts.cjs.map +0 -1
  64. package/dist/charts.d.cts +0 -181
  65. package/dist/constants-D3gaMY-W.d.cts +0 -39
  66. package/dist/editors.cjs +0 -2440
  67. package/dist/editors.cjs.map +0 -1
  68. package/dist/editors.d.cts +0 -165
  69. package/dist/icons.cjs +0 -23888
  70. package/dist/icons.cjs.map +0 -1
  71. package/dist/icons.d.cts +0 -20
  72. package/dist/index.cjs +0 -24894
  73. package/dist/index.cjs.map +0 -1
  74. package/dist/index.d.cts +0 -10438
  75. package/dist/markdown-editor.cjs +0 -4636
  76. package/dist/markdown-editor.cjs.map +0 -1
  77. package/dist/markdown-editor.d.cts +0 -75
  78. package/dist/mermaid.cjs +0 -1138
  79. package/dist/mermaid.cjs.map +0 -1
  80. package/dist/mermaid.d.cts +0 -15
  81. package/dist/rjsf.cjs.map +0 -1
  82. package/dist/rjsf.d.cts +0 -55
  83. package/dist/testing.cjs.map +0 -1
  84. package/dist/testing.d.cts +0 -25
package/dist/editors.js CHANGED
@@ -1,2031 +1,20 @@
1
- import { createContext, useRef, useEffect, useLayoutEffect, useMemo, useCallback, useSyncExternalStore, useState, use, Children, Fragment as Fragment$1 } from 'react';
2
- import { completeAnyWord, autocompletion } from '@codemirror/autocomplete';
3
- import { jsonParseLinter, json } from '@codemirror/lang-json';
4
- import { linter } from '@codemirror/lint';
5
- import { unifiedMergeView } from '@codemirror/merge';
6
- import { EditorView, Decoration, ViewPlugin, gutter, GutterMarker, keymap as keymap$1, placeholder, tooltips, gutterLineClass } from '@codemirror/view';
7
- import CodeMirror, { keymap, EditorState, EditorView as EditorView$1 } from '@uiw/react-codemirror';
8
- import { clsx } from 'clsx';
9
- import { extendTailwindMerge } from 'tailwind-merge';
10
- import { Root as Root$1, Trigger, Portal, Content } from '@radix-ui/react-tooltip';
11
- import { cva } from 'class-variance-authority';
12
- import { keboolaLegacySidebar, keboolaLegacyTopnav } from '@keboola/brand-registry';
1
+ import { LINE_HEIGHT_PX, PANE_HEADER_HEIGHT_PX, CHANGE_CLASS } from './chunk-VMFSRV5H.js';
2
+ import { useThemedExtension, isDarkScheme, resolveToken, buildBasicSetup } from './chunk-7PUUHEJQ.js';
3
+ export { CodeEditor, LANGUAGE_MODES, SqlEditor, isLanguageMode } from './chunk-7PUUHEJQ.js';
4
+ import { useStableCallback } from './chunk-Q7NWXLCT.js';
5
+ import './chunk-L37JJ6MR.js';
6
+ import './chunk-ESBL3IPF.js';
7
+ import { Button } from './chunk-CTCFYWJC.js';
8
+ import { X, ChevronsRight, ChevronsLeft } from './chunk-BOHNXTMM.js';
9
+ import './chunk-63NSN2VL.js';
10
+ import { cn } from './chunk-JP7PNHLH.js';
13
11
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
14
- import { Root, Slottable } from '@radix-ui/react-slot';
15
- import { X, ChevronsRight, ChevronsLeft, Loader2, Copy } from 'lucide-react';
16
- import { javascript } from '@codemirror/lang-javascript';
17
- import { python } from '@codemirror/lang-python';
18
- import { sql, PLSQL, MSSQL, PostgreSQL, MySQL } from '@codemirror/lang-sql';
19
- import { StreamLanguage } from '@codemirror/language';
20
- import { r } from '@codemirror/legacy-modes/mode/r';
21
- import { shell } from '@codemirror/legacy-modes/mode/shell';
22
- import { toml } from '@codemirror/legacy-modes/mode/toml';
23
- import { githubLightInit } from '@uiw/codemirror-theme-github';
24
- import { installExtensions, getSqlDialect } from '@keboola/codemirror-lang-sql';
12
+ import { useRef, useCallback, useMemo, useEffect } from 'react';
13
+ import { Decoration, GutterMarker, EditorView, gutterLineClass } from '@codemirror/view';
14
+ import CodeMirror from '@uiw/react-codemirror';
25
15
  import colors from '@keboola/tailwind-config/colors';
26
- import { simpleMode } from '@codemirror/legacy-modes/mode/simple-mode';
27
- import { StateEffect, StateField, RangeSet, Compartment, RangeSetBuilder } from '@codemirror/state';
28
- import { defaultKeymap } from '@codemirror/commands';
16
+ import { StateEffect, StateField, RangeSet, RangeSetBuilder } from '@codemirror/state';
29
17
 
30
- // src/components/CodeEditor/CodeEditor.tsx
31
-
32
- // src/constants/keyCodes.ts
33
- var keyCodes = {
34
- ENTER: "Enter",
35
- ESCAPE: "Escape",
36
- SPACE: " "
37
- };
38
- var useStableCallback = (callback) => {
39
- const latestRef = useRef(callback);
40
- useLayoutEffect(() => {
41
- latestRef.current = callback;
42
- }, [callback]);
43
- return useCallback((...args) => latestRef.current(...args), []);
44
- };
45
- var twMerge = extendTailwindMerge({
46
- prefix: "tw"
47
- });
48
- var cn = (...classes) => twMerge(clsx(...classes));
49
-
50
- // src/utils/copyToClipboard.ts
51
- var copyToClipboard = (text) => {
52
- return navigator.clipboard.writeText(text);
53
- };
54
-
55
- // src/components/ThemeProvider/utils.ts
56
- var createTheme = (brand) => ({
57
- id: brand.id,
58
- name: brand.name,
59
- shell: brand.shell,
60
- logo: brand.logo
61
- });
62
-
63
- // src/components/ThemeProvider/defaults.ts
64
- [keboolaLegacySidebar.id, keboolaLegacyTopnav.id];
65
- var DEFAULT_COLOR_SCHEME = "light";
66
- var DEFAULT_BRAND_ID = "design-system";
67
- var defaultBrand = {
68
- id: DEFAULT_BRAND_ID,
69
- name: "Design System",
70
- shell: "sidebar"};
71
- var defaultTheme = createTheme(defaultBrand);
72
-
73
- // src/components/ThemeProvider/context.tsx
74
- var noop = () => void 0;
75
- var defaultContext = {
76
- scheme: DEFAULT_COLOR_SCHEME,
77
- resolvedScheme: DEFAULT_COLOR_SCHEME,
78
- setScheme: noop,
79
- brandId: defaultTheme.id,
80
- setBrand: noop,
81
- themes: [defaultTheme],
82
- currentTheme: defaultTheme
83
- };
84
- createContext(defaultContext);
85
- var ArgoDesignContext = createContext(true);
86
- var useArgoDesign = () => use(ArgoDesignContext);
87
- var tooltipVariants = cva(
88
- [
89
- "tailwindcss-preflight",
90
- "tw:inline-block",
91
- "tw:break-anywhere",
92
- "tw:max-h-96",
93
- "tw:overflow-y-auto",
94
- "tw:z-[1060]",
95
- // legacy (dark) chrome — default
96
- "tw:rounded",
97
- "tw:bg-neutral-800",
98
- "tw:text-white",
99
- // argo chrome overrides — semantic floating-panel tokens
100
- "tw:data-[argo=true]:rounded-2xl",
101
- "tw:data-[argo=true]:border",
102
- "tw:data-[argo=true]:border-solid",
103
- "tw:data-[argo=true]:border-border",
104
- "tw:data-[argo=true]:bg-popover",
105
- "tw:data-[argo=true]:text-popover-foreground",
106
- "tw:data-[argo=true]:shadow-md",
107
- // argo open animation
108
- "tw:data-[argo=true]:data-[state=delayed-open]:animate-in",
109
- "tw:data-[argo=true]:data-[state=instant-open]:animate-in",
110
- "tw:data-[argo=true]:data-[state=delayed-open]:fade-in-0",
111
- "tw:data-[argo=true]:data-[state=instant-open]:fade-in-0",
112
- "tw:data-[argo=true]:data-[state=delayed-open]:zoom-in-95",
113
- "tw:data-[argo=true]:data-[state=instant-open]:zoom-in-95",
114
- // argo closed animation
115
- "tw:data-[argo=true]:data-[state=closed]:animate-out",
116
- "tw:data-[argo=true]:data-[state=closed]:fade-out-0",
117
- "tw:data-[argo=true]:data-[state=closed]:zoom-out-95",
118
- // argo position animation
119
- "tw:data-[argo=true]:data-[side=bottom]:slide-in-from-top-2",
120
- "tw:data-[argo=true]:data-[side=left]:slide-in-from-right-2",
121
- "tw:data-[argo=true]:data-[side=right]:slide-in-from-left-2",
122
- "tw:data-[argo=true]:data-[side=top]:slide-in-from-bottom-2"
123
- ],
124
- {
125
- defaultVariants: {
126
- variant: "action"
127
- },
128
- variants: {
129
- variant: {
130
- action: [
131
- "tw:max-w-fit",
132
- "tw:px-3",
133
- "tw:py-2",
134
- "tw:text-center",
135
- "tw:text-xs",
136
- "tw:font-medium",
137
- // Legacy chrome uppercases the action tooltip; the Keboola V2 brand
138
- // (`data-brand="keboola"`) renders it in standard case instead.
139
- "tw:uppercase",
140
- "tw:tracking-wider",
141
- "tw:[[data-brand=keboola]_&]:normal-case",
142
- "tw:[[data-brand=keboola]_&]:tracking-normal"
143
- ],
144
- explanatory: [
145
- "tw:max-w-80",
146
- "tw:px-4",
147
- "tw:py-3",
148
- "tw:text-left",
149
- "tw:text-sm",
150
- "tw:font-normal"
151
- ]
152
- }
153
- }
154
- }
155
- );
156
- var TooltipContent = ({
157
- className,
158
- variant,
159
- keepOpenOnPointerDownOutside = false,
160
- children,
161
- onPointerDownOutside,
162
- sideOffset = 8,
163
- collisionPadding = 8,
164
- hideWhenDetached = true,
165
- placement = "right",
166
- ...rest
167
- }) => {
168
- const renderArgo = useArgoDesign();
169
- const handlePointerDownOutside = (event) => {
170
- if (keepOpenOnPointerDownOutside) event.preventDefault();
171
- onPointerDownOutside?.(event);
172
- };
173
- return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(
174
- Content,
175
- {
176
- ...rest,
177
- "data-tooltip-content": renderArgo ? void 0 : true,
178
- "data-argo": renderArgo,
179
- sideOffset,
180
- collisionPadding,
181
- onPointerDownOutside: handlePointerDownOutside,
182
- className: tooltipVariants({ className, variant }),
183
- hideWhenDetached,
184
- side: placement,
185
- children
186
- }
187
- ) });
188
- };
189
- var DELAY_SHOW_TOOLTIP = 300;
190
- var TooltipRoot = ({ children, delayDuration = DELAY_SHOW_TOOLTIP, ...rest }) => /* @__PURE__ */ jsx(Root$1, { ...rest, delayDuration, children });
191
- var TooltipTrigger = ({
192
- ref,
193
- children,
194
- className,
195
- keepOpenOnClick = false,
196
- onClick,
197
- onPointerDown,
198
- asChild,
199
- ...rest
200
- }) => {
201
- const handleClick = (event) => {
202
- if (keepOpenOnClick) event.preventDefault();
203
- onClick?.(event);
204
- };
205
- const handlePointerDown = (event) => {
206
- if (keepOpenOnClick) event.preventDefault();
207
- onPointerDown?.(event);
208
- };
209
- return /* @__PURE__ */ jsx(
210
- Trigger,
211
- {
212
- ...rest,
213
- asChild: true,
214
- ref,
215
- className: cn("tailwindcss-preflight", className),
216
- onClick: handleClick,
217
- onPointerDown: handlePointerDown,
218
- children: asChild ? children : (
219
- // Default-mode trigger wraps children in a span so Radix has a
220
- // single DOM element to attach handlers to. `tailwindcss-preflight`
221
- // (merged in via Slot) activates Tailwind's preflight inside the
222
- // span, which sets `svg { display: block }` — without an inline-flex
223
- // container that would stack any bare Lucide icon onto its own
224
- // line. `tw:inline-flex tw:items-center` keeps icon + text aligned.
225
- /* @__PURE__ */ jsx("span", { className: "tw:inline-flex tw:items-center", children })
226
- )
227
- }
228
- );
229
- };
230
- var ACTION_TOOLTIP_LIMIT = 30;
231
- var Tooltip = ({
232
- tooltip,
233
- children,
234
- className,
235
- keepOpenOnTriggerClick = false,
236
- variant,
237
- placement = "right",
238
- forceHide = false,
239
- forceShow = false,
240
- delayDuration,
241
- // trigger props
242
- triggerAsChild = false
243
- }) => {
244
- const [open, setOpen] = useState(false);
245
- const resolvedVariant = (() => {
246
- if (!!variant) return variant;
247
- if (typeof tooltip === "string" && tooltip.length > ACTION_TOOLTIP_LIMIT) return "explanatory";
248
- return "action";
249
- })();
250
- const isActionVariant = resolvedVariant === "action";
251
- const handleKeyUp = (event) => {
252
- if (![keyCodes.ENTER, keyCodes.SPACE].includes(event.key)) return;
253
- event.stopPropagation();
254
- };
255
- return /* @__PURE__ */ jsxs(
256
- TooltipRoot,
257
- {
258
- open: !!tooltip && (open || forceShow) && !forceHide,
259
- onOpenChange: setOpen,
260
- delayDuration,
261
- disableHoverableContent: isActionVariant,
262
- children: [
263
- /* @__PURE__ */ jsx(
264
- TooltipTrigger,
265
- {
266
- asChild: triggerAsChild,
267
- keepOpenOnClick: keepOpenOnTriggerClick,
268
- onKeyUp: handleKeyUp,
269
- children
270
- }
271
- ),
272
- /* @__PURE__ */ jsx(
273
- TooltipContent,
274
- {
275
- className,
276
- variant: resolvedVariant,
277
- placement,
278
- keepOpenOnPointerDownOutside: keepOpenOnTriggerClick,
279
- children: tooltip
280
- }
281
- )
282
- ]
283
- }
284
- );
285
- };
286
- Tooltip.Root = TooltipRoot;
287
- Tooltip.Content = TooltipContent;
288
- Tooltip.Trigger = TooltipTrigger;
289
-
290
- // src/utils/escapeStringRegexp.ts
291
- var escapeStringRegexp = (string) => string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
292
-
293
- // src/utils/isMac.ts
294
- var getIsMac = () => {
295
- if (typeof navigator !== "undefined" && "userAgentData" in navigator) {
296
- const platform = navigator.userAgentData.platform;
297
- if (typeof platform === "string") {
298
- return platform.toLowerCase() === "macos";
299
- }
300
- }
301
- if (typeof navigator !== "undefined" && typeof navigator.platform === "string") {
302
- return navigator.platform.toUpperCase().indexOf("MAC") >= 0;
303
- }
304
- return false;
305
- };
306
- var isMac = getIsMac();
307
- var helpVariants = cva(["tw:m-0", "tw:text-xs"], {
308
- defaultVariants: {
309
- state: "default"
310
- },
311
- variants: {
312
- state: {
313
- default: ["tw:text-muted-foreground"],
314
- warning: ["tw:text-warning"]
315
- }
316
- }
317
- });
318
- var HelpBlock = ({ children, className, state = "default", ...rest }) => {
319
- if (!children) return null;
320
- return /* @__PURE__ */ jsx("p", { ...rest, className: helpVariants({ state, className }), children });
321
- };
322
- var variants = cva(
323
- [
324
- "tailwindcss-preflight",
325
- "tw:group/button",
326
- "tw:border-box",
327
- // layout
328
- "tw:relative",
329
- "tw:flex",
330
- "tw:items-center",
331
- "tw:justify-center",
332
- "tw:gap-2",
333
- // text — chrome weight/tracking are brand-overridable tokens
334
- // (`--font-weight-medium` / `--letter-spacing-chrome`). Casing: standard case is
335
- // the default; only legacy brands (`keboola-legacy-*`) uppercase the chrome, so
336
- // modern brands (incl. Keboola V2) read naturally. Mirrors the V2 standard-case
337
- // treatment shipped for Tooltip/Badge (PR 7629).
338
- "tw:text-xs",
339
- "tw:leading-5",
340
- "tw:font-medium",
341
- "tw:[[data-brand^=keboola-legacy]_&]:tracking-chrome",
342
- "tw:[[data-brand^=keboola-legacy]_&]:uppercase",
343
- // border — legacy (non-argo) chrome uses a fixed radius, not the brand token.
344
- "tw:rounded",
345
- "tw:border",
346
- "tw:border-transparent",
347
- // styling
348
- "tw:shadow-none",
349
- "tw:[a]:cursor-pointer",
350
- // explicitly set for anchor
351
- "tw:focus-visible:outline",
352
- "tw:focus-visible:outline-1",
353
- "tw:focus-visible:-outline-offset-1",
354
- "tw:focus-visible:outline-ring",
355
- "tw:focus-visible:ring-4",
356
- "tw:focus-visible:ring-ring/30",
357
- // disabled
358
- "tw:disabled:opacity-40",
359
- "tw:disabled:cursor-not-allowed",
360
- // anchor support
361
- "tw:!no-underline",
362
- "tw:aria-disabled:opacity-40",
363
- "tw:aria-disabled:cursor-not-allowed",
364
- "tw:[&_svg]:shrink-0"
365
- ],
366
- {
367
- defaultVariants: {
368
- size: "medium",
369
- variant: "primary",
370
- block: false
371
- },
372
- variants: {
373
- block: {
374
- true: ["tw:w-full"]
375
- },
376
- variant: {
377
- primary: [
378
- "tw:text-white",
379
- "tw:bg-primary-500",
380
- "tw:focus:text-white",
381
- "tw:hover:text-white",
382
- "tw:hover:not-disabled:bg-primary-600",
383
- "tw:active:not-disabled:bg-primary-800",
384
- // anchor disabled override
385
- "tw:aria-disabled:!bg-primary-500"
386
- ],
387
- secondary: [
388
- "tw:text-white",
389
- "tw:bg-secondary-500",
390
- "tw:focus:text-white",
391
- "tw:hover:text-white",
392
- "tw:hover:not-disabled:bg-secondary-700",
393
- "tw:active:not-disabled:bg-secondary-800",
394
- // anchor disabled override
395
- "tw:aria-disabled:!bg-secondary-500"
396
- ],
397
- danger: [
398
- "tw:text-white",
399
- "tw:bg-error-500",
400
- "tw:focus:text-white",
401
- "tw:hover:text-white",
402
- "tw:hover:not-disabled:bg-error-600",
403
- "tw:active:not-disabled:bg-error-700",
404
- // anchor disabled override
405
- "tw:aria-disabled:!bg-error-500"
406
- ],
407
- invisible: [
408
- "tw:text-neutral-800",
409
- "tw:bg-transparent",
410
- "tw:focus:text-neutral-800",
411
- "tw:hover:not-disabled:bg-neutral-100",
412
- "tw:hover:text-neutral-800",
413
- "tw:active:not-disabled:bg-neutral-150",
414
- // contrasting icon on hover/active
415
- "tw:[&_svg]:text-neutral-400",
416
- "tw:hover:not-disabled:[&_svg]:text-secondary-600",
417
- "tw:active:not-disabled:[&_svg]:text-secondary-600",
418
- // anchor disabled override
419
- "tw:aria-disabled:!bg-transparent"
420
- ],
421
- outline: [
422
- "tw:text-neutral-800",
423
- "tw:bg-white",
424
- // border
425
- "tw:!border-neutral-200",
426
- "tw:hover:text-neutral-800",
427
- "tw:focus:text-neutral-800",
428
- "tw:hover:not-disabled:!border-neutral-300",
429
- "tw:hover:not-disabled:bg-neutral-100",
430
- "tw:active:not-disabled:bg-neutral-200",
431
- // contrasting icon hover, same as invisible
432
- "tw:[&_svg]:text-neutral-400",
433
- "tw:not-disabled:hover:[&_svg]:text-secondary-600",
434
- "tw:active:not-disabled:[&_svg]:text-secondary-600",
435
- // anchor disabled override
436
- "tw:aria-disabled:!bg-white",
437
- "tw:aria-disabled:!border-neutral-200"
438
- ],
439
- inline: [
440
- "tw:text-neutral-800",
441
- "tw:bg-transparent",
442
- "tw:rounded-full",
443
- "tw:[&_svg]:text-neutral-400",
444
- "tw:not-disabled:hover:[&_svg]:text-secondary-600",
445
- "tw:not-disabled:focus:[&_svg]:text-secondary-600"
446
- ]
447
- },
448
- size: {
449
- medium: [
450
- "tw:max-h-10",
451
- "tw:min-h-10",
452
- "tw:px-4",
453
- "tw:py-2.5",
454
- 'tw:[&_svg:not([class*="tw:size-"])]:size-4'
455
- ],
456
- small: [
457
- "tw:max-h-8",
458
- "tw:min-h-8",
459
- "tw:px-4",
460
- "tw:py-1.5",
461
- 'tw:[&_svg:not([class*="tw:size-"])]:size-4'
462
- ],
463
- large: [
464
- "tw:max-h-12",
465
- "tw:min-h-12",
466
- "tw:px-4",
467
- "tw:py-3.5",
468
- 'tw:[&_svg:not([class*="tw:size-"])]:size-4'
469
- ],
470
- "icon-lg": ["tw:size-12", "tw:p-0", 'tw:[&_svg:not([class*="tw:size-"])]:size-6'],
471
- icon: ["tw:size-10", "tw:p-0", 'tw:[&_svg:not([class*="tw:size-"])]:size-4'],
472
- "icon-sm": ["tw:size-8", "tw:p-0", 'tw:[&_svg:not([class*="tw:size-"])]:size-4'],
473
- "icon-xs": ["tw:size-6", "tw:p-0", 'tw:[&_svg:not([class*="tw:size-"])]:size-4'],
474
- "icon-2xs": [
475
- "tw:!inline-flex",
476
- "tw:size-5",
477
- "tw:max-h-5",
478
- 'tw:[&_svg:not([class*="tw:size-"])]:size-3'
479
- ],
480
- "icon-3xs": ["tw:h-fit", "tw:w-fit", 'tw:[&_svg:not([class*="tw:size-"])]:size-4']
481
- }
482
- }
483
- }
484
- );
485
- var argoVariants = cva(
486
- [
487
- "tailwindcss-preflight",
488
- // layout
489
- "tw:relative",
490
- "tw:inline-flex",
491
- "tw:items-center",
492
- "tw:justify-center",
493
- "tw:whitespace-nowrap",
494
- "tw:gap-2",
495
- // border
496
- "tw:border",
497
- "tw:border-transparent",
498
- "tw:rounded-[var(--radius-lg,0.25rem)]",
499
- // text
500
- "tw:font-medium",
501
- "tw:select-none",
502
- // focus visible
503
- "tw:!outline-hidden",
504
- "tw:focus-visible:ring-2",
505
- // disabled
506
- "tw:disabled:cursor-not-allowed",
507
- "tw:disabled:opacity-50",
508
- "tw:active:opacity-60",
509
- "tw:transition-all",
510
- "tw:bg-clip-padding",
511
- // anchor support
512
- "tw:!no-underline",
513
- "tw:aria-disabled:cursor-not-allowed",
514
- "tw:aria-disabled:opacity-50",
515
- // icon
516
- "tw:shrink-0",
517
- "tw:[&_svg]:pointer-events-none",
518
- "tw:[&_svg]:shrink-0",
519
- "tw:[&_svg:not([class*='tw:size-'])]:size-4"
520
- ],
521
- {
522
- defaultVariants: {
523
- variant: "primary",
524
- size: "medium"
525
- },
526
- variants: {
527
- block: {
528
- true: ["tw:w-full"]
529
- },
530
- variant: {
531
- primary: [
532
- "tw:bg-primary",
533
- "tw:text-primary-foreground",
534
- "tw:[a]:hover:bg-primary/80",
535
- "tw:hover:not-disabled:bg-primary/90",
536
- "tw:hover:text-primary-foreground",
537
- "tw:focus:text-primary-foreground",
538
- "tw:focus-visible:border-primary",
539
- "tw:focus-visible:ring-ring/50"
540
- ],
541
- secondary: [
542
- "tw:bg-primary/10",
543
- "tw:text-primary",
544
- "tw:hover:not-disabled:bg-primary/20",
545
- "tw:focus-visible:border-primary",
546
- "tw:focus-visible:ring-ring/50"
547
- ],
548
- // should be called "destructive" by Figma
549
- danger: [
550
- "tw:bg-destructive",
551
- "tw:text-destructive-foreground",
552
- "tw:hover:text-destructive-foreground",
553
- "tw:focus:text-destructive-foreground",
554
- "tw:focus-visible:border-destructive",
555
- "tw:focus-visible:ring-destructive/20"
556
- ],
557
- outline: [
558
- "tw:!border-input",
559
- "tw:bg-background",
560
- // Semantic base text color so the label/icon flips in dark mode
561
- // (matches `invisible`); previously unset → inherited a fixed dark color.
562
- "tw:text-foreground",
563
- // Hover follows the brand primary (translucent tint), matching the
564
- // `secondary` variant — not the fixed `accent` blue.
565
- "tw:hover:not-disabled:bg-primary/10",
566
- "tw:hover:not-disabled:text-primary",
567
- "tw:hover:active:bg-background",
568
- "tw:focus-visible:!border-primary",
569
- "tw:focus-visible:ring-ring/50"
570
- ],
571
- // should be called "ghost" by Figma
572
- invisible: [
573
- "tw:bg-transparent",
574
- "tw:text-foreground",
575
- "tw:hover:not-disabled:bg-primary/10",
576
- "tw:hover:not-disabled:text-primary",
577
- "tw:hover:not-disabled:border-primary/10",
578
- "tw:focus-visible:ring-ring/50"
579
- ],
580
- // should be called "link" by Figma
581
- inline: [
582
- "tw:bg-transparent",
583
- "tw:text-primary",
584
- "tw:hover:underline",
585
- "tw:hover:active:bg-transparent",
586
- "tw:focus-visible:ring-ring/50"
587
- ]
588
- },
589
- size: {
590
- // should be called "default" by Figma
591
- medium: ["tw:max-h-9", "tw:py-2", "tw:px-4", "tw:text-sm"],
592
- // should be called "small" by Figma
593
- small: ["tw:max-h-8", "tw:py-2", "tw:px-3", "tw:text-xs"],
594
- // should be called "large" by Figma
595
- large: ["tw:max-h-10", "tw:py-2.5", "tw:px-6", "tw:text-sm"],
596
- "icon-lg": ["tw:size-10"],
597
- icon: ["tw:size-9"],
598
- "icon-sm": ["tw:size-8"],
599
- // unsupported in ARGO, remove when old design is gone
600
- "icon-xs": [],
601
- "icon-2xs": [],
602
- "icon-3xs": []
603
- }
604
- }
605
- }
606
- );
607
- var Button = ({
608
- ref,
609
- children,
610
- disabled = false,
611
- className,
612
- type = "button",
613
- isLoading = false,
614
- asChild = false,
615
- onClick,
616
- variant = "primary",
617
- size = "medium",
618
- block = false,
619
- ...buttonProps
620
- }) => {
621
- const renderArgo = useArgoDesign();
622
- const Comp = asChild ? Root : "button";
623
- const isIconOnly = String(size).startsWith("icon");
624
- const classNames = renderArgo ? argoVariants({ variant, size, block, className }) : variants({ size, variant, block, className });
625
- const handleClick = (event) => {
626
- const isAnchor = event.currentTarget.tagName === "A";
627
- if (isAnchor && disabled) {
628
- event.preventDefault();
629
- return;
630
- }
631
- onClick?.(event);
632
- };
633
- return /* @__PURE__ */ jsxs(
634
- Comp,
635
- {
636
- ...buttonProps,
637
- ref,
638
- disabled,
639
- "aria-disabled": disabled,
640
- "data-variant": variant,
641
- "data-icon-only": isIconOnly,
642
- type,
643
- onClick: handleClick,
644
- className: cn(classNames),
645
- children: [
646
- isLoading && /* @__PURE__ */ jsx(Loader2, { className: "tw:size-4 tw:shrink-0 tw:animate-spin" }),
647
- /* @__PURE__ */ jsx(Slottable, { children: isLoading && isIconOnly ? null : children })
648
- ]
649
- }
650
- );
651
- };
652
- var Clipboard2 = ({
653
- ref,
654
- text: textProp,
655
- children,
656
- tooltip = "Copy to Clipboard",
657
- tooltipPlacement = "top",
658
- tooltipVariant: tooltipVariantProp = "action",
659
- asChild = false,
660
- onClick,
661
- className,
662
- ...restButtonProps
663
- }) => {
664
- const [isTooltipOpen, setIsTooltipOpen] = useState(false);
665
- const [state, setState] = useState("ready");
666
- const text = typeof textProp === "function" ? textProp() : textProp;
667
- const copy = async (text2) => {
668
- try {
669
- if (!document.hasFocus()) window.focus();
670
- await copyToClipboard(text2);
671
- setState("copied");
672
- } catch {
673
- setState("error");
674
- }
675
- };
676
- const handleOnClick = (event) => {
677
- setIsTooltipOpen(true);
678
- if (text && state === "ready") void copy(text);
679
- onClick?.(event);
680
- };
681
- const handleOnOpenChange = (open) => {
682
- if (!open && state !== "ready") setState("ready");
683
- setIsTooltipOpen(open);
684
- };
685
- const tooltipContent = (() => {
686
- if (!text) return "Nothing to copy";
687
- if (state === "error") return "Failed to copy";
688
- if (state === "copied") return "Copied to Clipboard";
689
- return tooltip;
690
- })();
691
- const tooltipVariant = state === "ready" && !!text ? tooltipVariantProp : "action";
692
- const hasTooltipContent = tooltipContent !== null && tooltipContent !== void 0;
693
- return /* @__PURE__ */ jsxs(Tooltip.Root, { open: isTooltipOpen, onOpenChange: handleOnOpenChange, children: [
694
- /* @__PURE__ */ jsx(
695
- Tooltip.Trigger,
696
- {
697
- ...restButtonProps,
698
- asChild,
699
- keepOpenOnClick: true,
700
- onClick: handleOnClick,
701
- className: cn("tw:cursor-pointer", className),
702
- ref,
703
- children: children ?? text
704
- }
705
- ),
706
- hasTooltipContent && /* @__PURE__ */ jsx(
707
- Tooltip.Content,
708
- {
709
- keepOpenOnPointerDownOutside: true,
710
- placement: tooltipPlacement,
711
- variant: tooltipVariant,
712
- children: tooltipContent
713
- }
714
- )
715
- ] });
716
- };
717
- var DEFAULT_ICON = /* @__PURE__ */ jsx(Copy, {});
718
- var DEFAULT_ARIA_LABEL = "Copy";
719
- var ClipboardButton = ({
720
- // clipboard props
721
- text,
722
- tooltip,
723
- tooltipPlacement,
724
- tooltipVariant,
725
- // button props
726
- icon = DEFAULT_ICON,
727
- variant = "outline",
728
- children,
729
- ...rest
730
- }) => {
731
- const defaultAriaLabel = typeof tooltip === "string" && tooltip.trim() ? tooltip : DEFAULT_ARIA_LABEL;
732
- const ariaLabel = rest["aria-label"] ?? (children == null ? defaultAriaLabel : void 0);
733
- return /* @__PURE__ */ jsx(
734
- Clipboard2,
735
- {
736
- asChild: true,
737
- tooltip,
738
- tooltipPlacement,
739
- tooltipVariant,
740
- text,
741
- children: /* @__PURE__ */ jsxs(Button, { ...rest, "aria-label": ariaLabel, variant, disabled: !text, children: [
742
- icon,
743
- children
744
- ] })
745
- }
746
- );
747
- };
748
- var ButtonToolbar = ({ value, children }) => {
749
- if (!value && !children) return null;
750
- return /* @__PURE__ */ jsxs("div", { className: "tw:pointer-events-auto tw:ml-auto tw:mr-4 tw:flex tw:w-fit tw:gap-1 tw:overflow-visible tw:rounded-lg tw:border tw:border-solid tw:border-border tw:!bg-background tw:p-[3px] tw:shadow", children: [
751
- !!value && /* @__PURE__ */ jsx(ClipboardButton, { size: "icon-sm", variant: "invisible", text: value }),
752
- children
753
- ] });
754
- };
755
- var COMMANDS = [
756
- "run-operation",
757
- "run",
758
- "test",
759
- "seed",
760
- "snapshot",
761
- "list",
762
- "ls",
763
- "compile",
764
- "build",
765
- "deps",
766
- "docs",
767
- "source"
768
- ];
769
- var SUBCOMMANDS = { docs: ["generate"], source: ["freshness"] };
770
- var ARGUMENTS = ["--select", "--exclude", "--selector", "--defer", "--resource-type", "-s"];
771
- var SELECTORS = ["--select", "--exclude", "-s"];
772
- var METHODS = [
773
- "path:",
774
- "source:",
775
- "tag:",
776
- "package:",
777
- "config:",
778
- "test_type:",
779
- "test_name:",
780
- "state:",
781
- "exposure:",
782
- "metric:",
783
- "result:",
784
- "source_status:",
785
- "column_name:"
786
- ];
787
- var FLAGS = [
788
- "--fail-fast",
789
- "--warn-error",
790
- "--favor-state",
791
- "--vars",
792
- "--models",
793
- "--threads",
794
- "--profiles-dir",
795
- "--profile",
796
- "--full-refresh"
797
- ];
798
- var COMMAND_PHRASES = COMMANDS.flatMap((command) => {
799
- const subcommands = SUBCOMMANDS[command];
800
- return subcommands ? subcommands.map((subcommand) => `${command} ${subcommand}`) : [command];
801
- });
802
- var alternation = (list) => [...list].sort((a, b) => b.length - a.length).join("|");
803
- var word = (list) => new RegExp(`^\\s+(?:${alternation(list)})\\b`, "i");
804
- var prefix = (list) => new RegExp(`^\\s+(?:${alternation(list)})`, "i");
805
- var WORD = /[\w:-]*$/;
806
- var asOptions = (list, type) => list.map((label) => ({ label, type }));
807
- var DBT = [{ label: "dbt", type: "keyword" }];
808
- var COMMAND_OPTIONS = asOptions(COMMANDS, "keyword");
809
- var SUBCOMMAND_OPTIONS = Object.fromEntries(
810
- Object.entries(SUBCOMMANDS).map(([command, subcommands]) => [
811
- command,
812
- asOptions(subcommands, "keyword")
813
- ])
814
- );
815
- var ARGUMENT_OPTIONS = asOptions(ARGUMENTS, "variable");
816
- var FLAG_OPTIONS = asOptions(FLAGS, "constant");
817
- var METHOD_OPTIONS = asOptions(METHODS, "property");
818
- var optionsAfter = (words) => {
819
- const [step, command, ...rest] = words;
820
- if (step === void 0) return DBT;
821
- if (step.toLowerCase() !== "dbt") return [];
822
- if (command === void 0) return COMMAND_OPTIONS;
823
- const subcommands = SUBCOMMAND_OPTIONS[command.toLowerCase()];
824
- if (subcommands && rest.length === 0) return subcommands;
825
- const lastArgument = rest.filter((it) => it.startsWith("-")).at(-1);
826
- const selecting = lastArgument !== void 0 && SELECTORS.includes(lastArgument.toLowerCase());
827
- return selecting ? [...ARGUMENT_OPTIONS, ...FLAG_OPTIONS, ...METHOD_OPTIONS] : [...ARGUMENT_OPTIONS, ...FLAG_OPTIONS];
828
- };
829
- var complete = (context) => {
830
- const typed = context.matchBefore(WORD);
831
- if (!typed?.text && !context.explicit) return null;
832
- const from = typed?.from ?? context.pos;
833
- const line = context.state.doc.lineAt(from);
834
- const options = optionsAfter(
835
- line.text.slice(0, from - line.from).split(/\s+/).filter(Boolean)
836
- );
837
- return options.length > 0 ? { from, options, validFor: WORD } : null;
838
- };
839
- var dbt = simpleMode({
840
- languageData: {
841
- // `toggleComment` is a no-op without these, so Mod-/ silently does nothing.
842
- commentTokens: { line: "--", block: { open: "/*", close: "*/" } },
843
- autocomplete: complete
844
- },
845
- start: [
846
- { regex: /"(?:[^\\]|\\.)*?(?:"|$)/, token: "string" },
847
- // Word-bounded, so `dbtX` is not a dbt step whose first word happens to
848
- // colour — the same thing the completion source asks of it.
849
- { regex: /dbt\b/, token: "keyword", sol: true },
850
- { regex: word(COMMAND_PHRASES), token: "keyword" },
851
- { regex: word(ARGUMENTS), token: "variableName" },
852
- { regex: prefix(METHODS), token: "propertyName" },
853
- { regex: prefix(FLAGS), token: "attributeName" },
854
- { regex: /(?:@|\*|,|\+\d+|\d+\+|\+)/, token: "operator" },
855
- { regex: /'.*'/, token: "string" },
856
- { regex: /true|false/, token: "atom" }
857
- ]
858
- });
859
-
860
- // src/components/CodeEditor/modes/jsonnet.ts
861
- var COMMENT_END = /^\*\//;
862
- var COMMENT_START = /^\/\/|^#/;
863
- var C_COMMENT_START = /^\/\*/;
864
- var TEXT_BLOCK = /^\|\|\|/;
865
- var TEXT_BLOCK_END = /^\s*\|\|\|/;
866
- var RAW_DOUBLE = /^""/;
867
- var RAW_SINGLE = /^''/;
868
- var CLOSE_DOUBLE = /^"/;
869
- var CLOSE_SINGLE = /^'/;
870
- var ESCAPE = /^\\[\\"'/bfnrt0]/;
871
- var UNICODE_ESCAPE = /^\\u[0-9a-fA-F]{4}/;
872
- var BACKSLASH = /^\\/;
873
- var IMPORT = /^import(?:str)?\s*(@?)(["'])/;
874
- var QUOTE = /^(@?)(["'])/;
875
- var ROOT = /^\$/;
876
- var NUMBER = /^(?:\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?/i;
877
- var OPERATOR = /^[-+/*=<>!&~^|$%]+/;
878
- var IDENTIFIER = /^[a-zA-Z_][a-zA-Z0-9_]*/;
879
- var KEYWORDS = {
880
- local: "keyword",
881
- self: "keyword",
882
- super: "keyword",
883
- assert: "keyword",
884
- function: "keyword",
885
- if: "keyword",
886
- then: "keyword",
887
- else: "keyword",
888
- for: "keyword",
889
- in: "keyword",
890
- tailstrict: "keyword",
891
- error: "keyword",
892
- true: "atom",
893
- false: "atom",
894
- null: "atom"
895
- };
896
- var jsonnet = {
897
- name: "jsonnet",
898
- // `toggleComment` is a no-op without these, so Mod-/ silently does nothing.
899
- languageData: { commentTokens: { line: "//", block: { open: "/*", close: "*/" } } },
900
- startState: () => ({
901
- cComment: false,
902
- textBlock: false,
903
- textBlockIndent: null,
904
- string: false,
905
- importString: false,
906
- stringSingle: false,
907
- stringRaw: false
908
- }),
909
- token: (stream, state) => {
910
- if (state.cComment) {
911
- if (stream.match(COMMENT_END)) {
912
- state.cComment = false;
913
- return "comment";
914
- }
915
- stream.next();
916
- return "comment";
917
- }
918
- if (state.textBlock) {
919
- if (state.textBlockIndent == null) {
920
- if (stream.match(TEXT_BLOCK_END)) {
921
- state.textBlock = false;
922
- return "string";
923
- }
924
- state.textBlockIndent = stream.indentation();
925
- }
926
- if (stream.indentation() >= state.textBlockIndent) {
927
- stream.skipToEnd();
928
- return "string";
929
- }
930
- if (stream.match(TEXT_BLOCK_END)) {
931
- state.textBlock = false;
932
- return "string";
933
- }
934
- stream.next();
935
- return "invalid";
936
- }
937
- if (state.string || state.importString) {
938
- const style = state.string ? "string" : "meta";
939
- if (state.stringRaw) {
940
- if (stream.match(state.stringSingle ? RAW_SINGLE : RAW_DOUBLE)) return "escape";
941
- } else {
942
- if (stream.match(ESCAPE)) return "escape";
943
- if (stream.match(UNICODE_ESCAPE)) return "escape";
944
- if (stream.match(BACKSLASH)) return "invalid";
945
- }
946
- if (stream.match(state.stringSingle ? CLOSE_SINGLE : CLOSE_DOUBLE)) {
947
- state.string = false;
948
- state.importString = false;
949
- return style;
950
- }
951
- stream.next();
952
- return style;
953
- }
954
- if (stream.match(COMMENT_START)) {
955
- stream.skipToEnd();
956
- return "comment";
957
- }
958
- if (stream.match(C_COMMENT_START)) {
959
- state.cComment = true;
960
- return "comment";
961
- }
962
- const imported = stream.match(IMPORT);
963
- if (Array.isArray(imported)) {
964
- state.importString = true;
965
- state.stringRaw = imported[1] === "@";
966
- state.stringSingle = imported[2] === "'";
967
- return "meta";
968
- }
969
- const quoted = stream.match(QUOTE);
970
- if (Array.isArray(quoted)) {
971
- state.string = true;
972
- state.stringRaw = quoted[1] === "@";
973
- state.stringSingle = quoted[2] === "'";
974
- return "string";
975
- }
976
- if (stream.match(TEXT_BLOCK)) {
977
- state.textBlock = true;
978
- state.textBlockIndent = null;
979
- return "string";
980
- }
981
- if (stream.match(ROOT)) return "keyword";
982
- if (stream.match(NUMBER)) return "number";
983
- if (stream.match(OPERATOR)) return "operator";
984
- const identifier = stream.match(IDENTIFIER);
985
- if (Array.isArray(identifier)) return KEYWORDS[identifier[0]] ?? null;
986
- stream.next();
987
- return null;
988
- }
989
- };
990
- var resolveToken = (token, fallbackChannels, alpha) => {
991
- const channels = typeof document === "undefined" ? fallbackChannels : getComputedStyle(document.documentElement).getPropertyValue(`--${token}`).trim() || fallbackChannels;
992
- return alpha === void 0 ? `rgb(${channels})` : `rgb(${channels} / ${alpha})`;
993
- };
994
- var SSR_SIGNAL = "ssr";
995
- var readThemeSignal = () => {
996
- if (typeof document === "undefined") return SSR_SIGNAL;
997
- const root = document.documentElement;
998
- return `${root.getAttribute("data-theme") ?? ""}:${root.getAttribute("data-brand") ?? ""}`;
999
- };
1000
- var subscribeThemeSignal = (onChange) => {
1001
- if (typeof document === "undefined") return () => {
1002
- };
1003
- const observer = new MutationObserver(onChange);
1004
- observer.observe(document.documentElement, {
1005
- attributes: true,
1006
- attributeFilter: ["data-theme", "data-brand"]
1007
- });
1008
- return () => observer.disconnect();
1009
- };
1010
- var useThemeSignal = () => useSyncExternalStore(subscribeThemeSignal, readThemeSignal, () => SSR_SIGNAL);
1011
- var themeCache = /* @__PURE__ */ new Map();
1012
- var useThemedExtension = (cacheKey, build) => {
1013
- const themeSignal = useThemeSignal();
1014
- const key = `${themeSignal} ${cacheKey}`;
1015
- let cached = themeCache.get(key);
1016
- if (!cached) {
1017
- cached = build();
1018
- themeCache.set(key, cached);
1019
- }
1020
- return cached;
1021
- };
1022
-
1023
- // src/components/CodeEditor/helpers.ts
1024
- var LANGUAGE_MODES = [
1025
- "application/json",
1026
- "text/plain",
1027
- "text/x-python",
1028
- "text/x-sql",
1029
- "text/x-mysql",
1030
- "text/x-pgsql",
1031
- "text/x-mssql",
1032
- // Snowflake, under a historical name — these strings are a published prop contract.
1033
- "text/x-sfsql",
1034
- "text/x-plsql",
1035
- "text/x-rsrc",
1036
- "text/x-sh",
1037
- "text/x-toml",
1038
- "text/jsonnet",
1039
- "text/x-dbt",
1040
- "text/javascript",
1041
- "text/typescript"
1042
- ];
1043
- var isLanguageMode = (mode) => LANGUAGE_MODES.includes(mode);
1044
- var buildBaseThemeStyles = () => ({
1045
- "*": { lineHeight: "20px" },
1046
- "*::selection": {
1047
- backgroundColor: resolveToken("primary", "31 143 255"),
1048
- color: `${resolveToken("primary-foreground", "255 255 255")} !important`
1049
- },
1050
- '&.cm-editor:has(.cm-content[contenteditable="false"])': {
1051
- backgroundColor: resolveToken("secondary", "226 232 240")
1052
- },
1053
- '&.cm-editor:has(.cm-content[contenteditable="false"]) .cm-gutters': {
1054
- backgroundColor: resolveToken("border", "229 231 235")
1055
- },
1056
- "&.cm-editor .cm-scroller": { overflowAnchor: "none" },
1057
- "&.cm-editor, &.cm-editor .cm-scroller": {
1058
- minHeight: "100%",
1059
- flexGrow: 1,
1060
- alignItems: "stretch !important",
1061
- outline: "none"
1062
- },
1063
- ".cm-gutter.cm-foldGutter": { display: "none !important" },
1064
- ".cm-gutter.cm-lineNumbers": { paddingLeft: "20px", paddingRight: "6px" },
1065
- ".cm-gutters": { height: "auto" },
1066
- // tokens overrides
1067
- ".cm-line .tok-string": { color: colors.warning[700] },
1068
- // merge (diff) view
1069
- '&[class*="cm-merge-"] .cm-deletedLine': { backgroundColor: colors.error[100] },
1070
- '&[class*="cm-merge-"] .cm-changedLine': { backgroundColor: colors.green[100] },
1071
- '&[class*="cm-merge-"] .cm-deletedLineGutter': { backgroundColor: colors.error[200] },
1072
- '&[class*="cm-merge-"] .cm-changedLineGutter': { backgroundColor: colors.green[200] },
1073
- '&[class*="cm-merge-"] .cm-deletedText': { background: colors.error[200] },
1074
- '&[class*="cm-merge-"] .cm-changedText': { background: colors.green[200] },
1075
- '&[class*="cm-merge-"]': {
1076
- backgroundColor: `${colors.white} !important`
1077
- },
1078
- '&[class*="cm-merge-"] .cm-gutters': {
1079
- backgroundColor: `${colors.white} !important`
1080
- },
1081
- ".cm-changeGutter": { position: "absolute", zIndex: -1, width: "100%", paddingLeft: 0 },
1082
- '&[class*="cm-merge-"] .cm-changedLine,&[class*="cm-merge-"] .cm-line, &[class*="cm-merge-"] .cm-deletedChunk': { paddingLeft: 0 }
1083
- });
1084
- var ALWAYS_OFF = {
1085
- drawSelection: false,
1086
- foldGutter: false,
1087
- foldKeymap: false,
1088
- highlightActiveLine: false,
1089
- highlightActiveLineGutter: false
1090
- };
1091
- var buildBasicSetup = (readOnly) => ({
1092
- ...ALWAYS_OFF,
1093
- ...readOnly ? {
1094
- closeBrackets: false,
1095
- closeBracketsKeymap: false,
1096
- lintKeymap: false,
1097
- indentOnInput: false,
1098
- rectangularSelection: false,
1099
- dropCursor: false,
1100
- highlightSelectionMatches: false
1101
- } : null
1102
- });
1103
- var buildCustomTheme = () => githubLightInit({
1104
- settings: {
1105
- fontFamily: `'SFMono-Regular', 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New'`,
1106
- background: resolveToken("background", "249 250 251"),
1107
- foreground: resolveToken("foreground", "30 41 59"),
1108
- gutterBackground: resolveToken("muted", "241 245 249"),
1109
- gutterForeground: resolveToken("muted-foreground", "100 116 139"),
1110
- gutterBorder: "transparent",
1111
- lineHighlight: "transparent",
1112
- selection: resolveToken("primary", "31 143 255")
1113
- }
1114
- });
1115
- var getLanguageMode = (mode) => {
1116
- switch (mode) {
1117
- case void 0:
1118
- case "application/json":
1119
- return json();
1120
- case "text/x-python":
1121
- return python();
1122
- case "text/x-sql":
1123
- return sql({ upperCaseKeywords: true });
1124
- case "text/x-mysql":
1125
- return sql({ upperCaseKeywords: true, dialect: MySQL });
1126
- case "text/x-pgsql":
1127
- return sql({ upperCaseKeywords: true, dialect: PostgreSQL });
1128
- case "text/x-mssql":
1129
- return sql({ upperCaseKeywords: true, dialect: MSSQL });
1130
- case "text/x-sfsql":
1131
- return sql({ upperCaseKeywords: true, dialect: getSqlDialect("snowflake") });
1132
- case "text/x-plsql":
1133
- return sql({ upperCaseKeywords: true, dialect: PLSQL });
1134
- case "text/x-rsrc":
1135
- return StreamLanguage.define(r);
1136
- case "text/x-sh":
1137
- return StreamLanguage.define(shell);
1138
- case "text/x-toml":
1139
- return StreamLanguage.define(toml);
1140
- case "text/jsonnet":
1141
- return StreamLanguage.define(jsonnet);
1142
- case "text/x-dbt":
1143
- return StreamLanguage.define(dbt);
1144
- case "text/javascript":
1145
- return javascript({ jsx: true });
1146
- case "text/typescript":
1147
- return javascript({ jsx: true, typescript: true });
1148
- // No language — `text/plain` lands here, and so does any mode added to
1149
- // LANGUAGE_MODES without an arm above. Unstyled text is the safe degradation;
1150
- // a `json()` default would colour unrelated content as if it were JSON.
1151
- default:
1152
- return [];
1153
- }
1154
- };
1155
- var shouldLintJson = (mode, readOnly) => mode === "application/json" && !readOnly;
1156
- var setSearchEffect = StateEffect.define();
1157
- function findMatches(doc, query) {
1158
- if (!query) return [];
1159
- const text = doc.toString();
1160
- try {
1161
- const regex = new RegExp(escapeStringRegexp(query), "gi");
1162
- return Array.from(text.matchAll(regex)).map((match, index) => {
1163
- const from = match.index;
1164
- const to = from + match[0].length;
1165
- return { from, to, text: match[0], localIndex: index };
1166
- });
1167
- } catch (e) {
1168
- console.warn("Invalid search regex:", e);
1169
- return [];
1170
- }
1171
- }
1172
- function createDecorations(matches, selectedLocalIndex) {
1173
- const decorations = matches.map((match) => {
1174
- const isSelected = match.localIndex === selectedLocalIndex;
1175
- const decoration = Decoration.mark({
1176
- class: isSelected ? "cm-searchMatch-selected" : "cm-searchMatch"
1177
- });
1178
- return decoration.range(match.from, match.to);
1179
- });
1180
- return Decoration.set(decorations, true);
1181
- }
1182
- var searchField = StateField.define({
1183
- create() {
1184
- return {
1185
- query: "",
1186
- selectedMatchIndex: void 0,
1187
- matches: [],
1188
- decorations: Decoration.none
1189
- };
1190
- },
1191
- update(state, tr) {
1192
- let newState = state;
1193
- for (const effect of tr.effects) {
1194
- if (!effect.is(setSearchEffect)) {
1195
- continue;
1196
- }
1197
- const { query, selectedMatchIndex } = effect.value;
1198
- const matches = findMatches(tr.state.doc, query);
1199
- const decorations = createDecorations(matches, selectedMatchIndex);
1200
- newState = {
1201
- query,
1202
- selectedMatchIndex,
1203
- matches,
1204
- decorations
1205
- };
1206
- }
1207
- if (tr.docChanged && newState.query) {
1208
- const matches = findMatches(tr.state.doc, newState.query);
1209
- const decorations = createDecorations(matches, newState.selectedMatchIndex);
1210
- newState = {
1211
- ...newState,
1212
- matches,
1213
- decorations
1214
- };
1215
- }
1216
- return newState;
1217
- },
1218
- provide: (field) => EditorView.decorations.from(field, (state) => state.decorations)
1219
- });
1220
- var searchViewPlugin = ViewPlugin.fromClass(
1221
- class {
1222
- lastSelectedIndex;
1223
- update(update) {
1224
- const state = update.state.field(searchField);
1225
- if (state.selectedMatchIndex !== void 0 && state.selectedMatchIndex !== this.lastSelectedIndex) {
1226
- const match = state.matches[state.selectedMatchIndex];
1227
- if (match) {
1228
- requestAnimationFrame(() => {
1229
- update.view.dispatch({
1230
- effects: EditorView.scrollIntoView(match.from, { y: "center" })
1231
- });
1232
- });
1233
- }
1234
- this.lastSelectedIndex = state.selectedMatchIndex;
1235
- }
1236
- if (state.selectedMatchIndex === void 0) {
1237
- this.lastSelectedIndex = void 0;
1238
- }
1239
- }
1240
- }
1241
- );
1242
- var searchTheme = EditorView.baseTheme({
1243
- ".cm-searchMatch": {
1244
- backgroundColor: colors.blue[100]
1245
- },
1246
- ".cm-searchMatch > span": {
1247
- color: `${colors.blue[600]} !important`
1248
- },
1249
- ".cm-searchMatch-selected": {
1250
- backgroundColor: colors.blue[600]
1251
- },
1252
- ".cm-searchMatch-selected > span": {
1253
- color: `${colors.white} !important`
1254
- }
1255
- });
1256
- function searchExtension() {
1257
- return [searchField, searchViewPlugin, searchTheme];
1258
- }
1259
- function updateSearch(view, query, selectedMatchIndex) {
1260
- view.dispatch({ effects: setSearchEffect.of({ query, selectedMatchIndex }) });
1261
- }
1262
- var KbdSeparator = ({ className, ...props }) => /* @__PURE__ */ jsx("span", { ...props, className: cn("tw:text-xs tw:text-muted-foreground", className) });
1263
- var KbdGroup = ({ ref, className, children, separator, ...props }) => {
1264
- return /* @__PURE__ */ jsx(
1265
- "kbd",
1266
- {
1267
- ...props,
1268
- ref,
1269
- className: cn("tw:inline-flex", "tw:items-center", "tw:gap-1", className),
1270
- children: separator ? (
1271
- // oxlint-disable-next-line react-x/no-children-to-array
1272
- Children.toArray(children).map((child, index) => (
1273
- // oxlint-disable-next-line
1274
- /* @__PURE__ */ jsxs(Fragment$1, { children: [
1275
- index > 0 && /* @__PURE__ */ jsx(KbdSeparator, { children: separator }),
1276
- child
1277
- ] }, index)
1278
- ))
1279
- ) : children
1280
- }
1281
- );
1282
- };
1283
- var kbdVariants = cva(
1284
- [
1285
- "tailwindcss-preflight",
1286
- // style
1287
- "tw:pointer-events-none",
1288
- "tw:w-fit",
1289
- "tw:h-5",
1290
- "tw:min-w-5",
1291
- // layout
1292
- "tw:inline-flex",
1293
- "tw:items-center",
1294
- "tw:justify-center",
1295
- "tw:gap-1",
1296
- "tw:shrink-0",
1297
- // spacing
1298
- "tw:px-1",
1299
- 'tw:[&_svg:not([class*="size-"])]:size-2.5',
1300
- "tw:text-xs",
1301
- "tw:font-medium",
1302
- "tw:rounded"
1303
- ],
1304
- {
1305
- defaultVariants: {
1306
- variant: "default"
1307
- },
1308
- variants: {
1309
- variant: {
1310
- default: "tw:bg-muted tw:text-muted-foreground",
1311
- primary: "tw:bg-white/20 tw:text-white"
1312
- }
1313
- }
1314
- }
1315
- );
1316
- var Kbd = ({ children, className, variant, ...rest }) => /* @__PURE__ */ jsx("kbd", { ...rest, className: kbdVariants({ className, variant }), children });
1317
- Kbd.Group = KbdGroup;
1318
- Kbd.Separator = KbdSeparator;
1319
- var ToggleComponentHelp = () => /* @__PURE__ */ jsxs("div", { children: [
1320
- "Use ",
1321
- /* @__PURE__ */ jsx(Kbd, { children: isMac ? "Command+/" : "Ctrl+/" }),
1322
- " to toggle comments."
1323
- ] });
1324
- var establishesFixedContainingBlock = (style) => style.transform !== "none" || style.translate !== "none" || style.rotate !== "none" || style.scale !== "none" || style.perspective !== "none" || style.filter !== "none" || style.backdropFilter !== "none" || /\b(paint|layout|strict|content)\b/.test(style.contain) || /\b(transform|perspective|filter|contain)\b/.test(style.willChange);
1325
- var crops = (style) => style.overflowX !== "visible" || style.overflowY !== "visible" || style.maskImage !== "none" || style.contentVisibility !== "visible" || /\b(paint|strict|content)\b/.test(style.contain);
1326
- var findTooltipHost = (from) => {
1327
- let outermostCropper = null;
1328
- for (let node = from.parentElement; node && node !== document.body; node = node.parentElement) {
1329
- const style = getComputedStyle(node);
1330
- if (crops(style)) {
1331
- outermostCropper = node;
1332
- } else if (establishesFixedContainingBlock(style)) {
1333
- return outermostCropper?.parentElement ?? node;
1334
- }
1335
- }
1336
- return outermostCropper?.parentElement ?? null;
1337
- };
1338
- var tooltipsExtension = () => {
1339
- const layer = new Compartment();
1340
- return [
1341
- layer.of(tooltips()),
1342
- ViewPlugin.define((view) => {
1343
- const scheduled = setTimeout(() => {
1344
- if (!view.dom.isConnected) return;
1345
- const parent = findTooltipHost(view.dom);
1346
- if (parent) view.dispatch({ effects: layer.reconfigure(tooltips({ parent })) });
1347
- });
1348
- return { destroy: () => clearTimeout(scheduled) };
1349
- })
1350
- ];
1351
- };
1352
- var useTooltipsExtension = () => useMemo(tooltipsExtension, []);
1353
-
1354
- // src/components/CodeEditor/variableCompletion.ts
1355
- var BOOST = 2e3;
1356
- var NAME = String.raw`[\w-]*`;
1357
- var AT_CARET = new RegExp(String.raw`(?:\{{1,2} ?)?${NAME}$`);
1358
- var NAME_AT_END = new RegExp(`${NAME}$`);
1359
- var OPENING = /\{{1,2} ?$/;
1360
- var CLOSING = /^ ?\}{1,2}/;
1361
- var completeVariables = (variables = []) => {
1362
- if (variables.length === 0) return () => null;
1363
- const options = variables.map(({ name, value }) => ({
1364
- // The bare name: `SqlEditor` filters prefix-only while `CodeEditor` filters
1365
- // fuzzily, and this is the only spelling both accept whether or not the caret
1366
- // has typed the braces. The braces are `displayLabel`, which is what renders.
1367
- label: name,
1368
- displayLabel: `{{${name}}}`,
1369
- detail: value,
1370
- type: "variable",
1371
- boost: BOOST,
1372
- apply: (view, completion, from, to) => {
1373
- const { doc } = view.state;
1374
- const line = doc.lineAt(from);
1375
- const insert = `{{${completion.label}}}`;
1376
- const opening = OPENING.exec(doc.sliceString(line.from, from));
1377
- const closing = CLOSING.exec(doc.sliceString(to, line.to));
1378
- const start = opening ? from - opening[0].length : from;
1379
- const end = closing ? to + closing[0].length : to;
1380
- view.dispatch({
1381
- changes: { from: start, to: end, insert },
1382
- selection: { anchor: start + insert.length }
1383
- });
1384
- }
1385
- }));
1386
- return (context) => {
1387
- const match = context.matchBefore(AT_CARET);
1388
- if (!match?.text) return null;
1389
- const [name = ""] = NAME_AT_END.exec(match.text) ?? [];
1390
- return { from: match.to - name.length, options };
1391
- };
1392
- };
1393
- var useVariableCompletion = (variables = []) => useStableCallback(completeVariables(variables));
1394
- var emptyObject = {};
1395
- var CodeEditor = ({
1396
- value,
1397
- previousValue,
1398
- onChange,
1399
- mode = "application/json",
1400
- placeholder: placeholder$1 = "",
1401
- ariaLabel,
1402
- searchQuery,
1403
- searchMatchIndex,
1404
- readOnly = false,
1405
- inputLocked = false,
1406
- autocompletions,
1407
- completionSource,
1408
- variables,
1409
- extraKeys = emptyObject,
1410
- withToggleCommentHint = false,
1411
- withAutofocus = false,
1412
- withLineNumbers = true,
1413
- withLineWrapping = true,
1414
- withCollapseUnchanged = false,
1415
- withCopyButton = false,
1416
- completeAny = false,
1417
- help = null,
1418
- helpPostfix = null,
1419
- renderAdditionalButtons,
1420
- className
1421
- }) => {
1422
- const handleChange = useStableCallback((next) => onChange?.(next));
1423
- const withSearch = searchQuery !== void 0;
1424
- const editorRef = useRef(null);
1425
- useEffect(() => {
1426
- const view = editorRef.current?.view;
1427
- if (view && withSearch) updateSearch(view, searchQuery, searchMatchIndex);
1428
- }, [withSearch, searchQuery, searchMatchIndex]);
1429
- const handleCreateEditor = useStableCallback((view) => {
1430
- if (searchQuery) updateSearch(view, searchQuery, searchMatchIndex);
1431
- });
1432
- const extraKeysRef = useRef(extraKeys);
1433
- useLayoutEffect(() => {
1434
- extraKeysRef.current = extraKeys;
1435
- });
1436
- const boundKeysSignature = Object.keys(extraKeys).join("\n");
1437
- const boundKeys = useMemo(
1438
- () => boundKeysSignature.split("\n").filter(Boolean),
1439
- [boundKeysSignature]
1440
- );
1441
- const tooltipLayer = useTooltipsExtension();
1442
- const variableCompletion = useVariableCompletion(variables);
1443
- const customTheme = useThemedExtension("editor:syntax", buildCustomTheme);
1444
- const baseTheme = useThemedExtension(
1445
- "code-editor:chrome",
1446
- () => EditorView.theme(buildBaseThemeStyles())
1447
- );
1448
- const commonExtensions = useMemo(() => {
1449
- const callerCompletions = completionSource ?? (completeAny ? completeAnyWord : autocompletions?.length ? autocompletions : null);
1450
- const completionEntries = [
1451
- ...callerCompletions ? [{ autocomplete: callerCompletions }] : [],
1452
- { autocomplete: variableCompletion }
1453
- ];
1454
- return [
1455
- getLanguageMode(mode),
1456
- shouldLintJson(mode, readOnly) ? linter(jsonParseLinter()) : [],
1457
- withLineWrapping ? EditorView.lineWrapping : [],
1458
- EditorState.languageData.of(() => completionEntries),
1459
- keymap$1.of(
1460
- boundKeys.map((key) => ({
1461
- key,
1462
- run: () => {
1463
- extraKeysRef.current[key]?.();
1464
- return true;
1465
- }
1466
- }))
1467
- ),
1468
- readOnly ? [] : [
1469
- // CodeMirror's own default. Gating it on the props hid completions the
1470
- // *language* supplies — dbt's vocabulary, Snowflake's keywords — behind
1471
- // a shortcut, and macOS leaves no usable one. With nothing to offer, no
1472
- // popup opens anyway.
1473
- autocompletion()
1474
- ],
1475
- ariaLabel ? EditorView.contentAttributes.of({ "aria-label": ariaLabel }) : [],
1476
- withSearch ? searchExtension() : [],
1477
- tooltipLayer,
1478
- baseTheme
1479
- ];
1480
- }, [
1481
- autocompletions,
1482
- completionSource,
1483
- variableCompletion,
1484
- completeAny,
1485
- boundKeys,
1486
- mode,
1487
- readOnly,
1488
- withLineWrapping,
1489
- baseTheme,
1490
- ariaLabel,
1491
- withSearch,
1492
- tooltipLayer
1493
- ]);
1494
- const extensions = useMemo(() => {
1495
- return [
1496
- ...commonExtensions,
1497
- placeholder(placeholder$1),
1498
- EditorView.editable.of(!readOnly),
1499
- // The lock is this facet and nothing else. `contenteditable` is what the
1500
- // read-only wash keys off, and `basicSetup` is what holds the undo history,
1501
- // so leaving both alone is what makes the lock invisible.
1502
- EditorState.readOnly.of(readOnly || inputLocked),
1503
- previousValue ? unifiedMergeView({
1504
- original: previousValue,
1505
- mergeControls: false,
1506
- highlightChanges: false,
1507
- collapseUnchanged: withCollapseUnchanged ? {} : void 0
1508
- }) : []
1509
- ];
1510
- }, [commonExtensions, placeholder$1, readOnly, inputLocked, previousValue, withCollapseUnchanged]);
1511
- const config = useMemo(() => {
1512
- return {
1513
- ...buildBasicSetup(readOnly),
1514
- lineNumbers: withLineNumbers,
1515
- // Mod-f opens CodeMirror's own panel, which would run a second query and a
1516
- // second match count over the same document beside the caller's input.
1517
- ...withSearch ? { searchKeymap: false } : null
1518
- };
1519
- }, [withLineNumbers, readOnly, withSearch]);
1520
- const additionalButtons = renderAdditionalButtons?.(value);
1521
- const hasToolbar = withCopyButton && !!value || !!additionalButtons;
1522
- return (
1523
- // oxlint-disable-next-line jsx-a11y/no-static-element-interactions
1524
- /* @__PURE__ */ jsxs(
1525
- "div",
1526
- {
1527
- className: cn(
1528
- "tw:relative tw:flex tw:min-h-0 tw:flex-col tw:[&_.cm-mergeViewEditor]:overflow-visible tw:[&_.cm-mergeViewEditors]:h-full tw:[&_.cm-mergeView]:h-full tw:[&_>div]:h-full tw:[&_>div]:overflow-auto tw:[&_>div]:bg-background",
1529
- { "tw:mt-8": hasToolbar },
1530
- className
1531
- ),
1532
- onKeyDown: (event) => {
1533
- if (event.key === keyCodes.ESCAPE) {
1534
- event.stopPropagation();
1535
- }
1536
- },
1537
- children: [
1538
- hasToolbar && /* @__PURE__ */ jsx("div", { className: "tw:pointer-events-none tw:absolute tw:z-10 tw:flex tw:!h-auto tw:w-full tw:translate-y-[calc(-100%_+_8px)] tw:!overflow-visible tw:!bg-transparent", children: /* @__PURE__ */ jsx("div", { className: "tw:flex-1", children: /* @__PURE__ */ jsx(ButtonToolbar, { value: withCopyButton ? value : void 0, children: additionalButtons }) }) }),
1539
- /* @__PURE__ */ jsx(
1540
- CodeMirror,
1541
- {
1542
- ref: editorRef,
1543
- onCreateEditor: handleCreateEditor,
1544
- theme: customTheme,
1545
- value,
1546
- onChange: handleChange,
1547
- extensions,
1548
- autoFocus: withAutofocus,
1549
- basicSetup: config
1550
- }
1551
- ),
1552
- !readOnly && (withToggleCommentHint || help || helpPostfix) && /* @__PURE__ */ jsxs(HelpBlock, { className: "tw:mt-2 tw:flex tw:flex-wrap tw:gap-1", children: [
1553
- help,
1554
- withToggleCommentHint ? /* @__PURE__ */ jsx(ToggleComponentHelp, {}) : null,
1555
- helpPostfix
1556
- ] })
1557
- ]
1558
- }
1559
- )
1560
- );
1561
- };
1562
- var activeQueryFirstLine = Decoration.line({ class: "cm-active-query cm-active-query-first" });
1563
- var activeQueryMiddleLine = Decoration.line({ class: "cm-active-query" });
1564
- var activeQueryLastLine = Decoration.line({ class: "cm-active-query cm-active-query-last" });
1565
- var activeQuerySingleLine = Decoration.line({
1566
- class: "cm-active-query cm-active-query-first cm-active-query-last"
1567
- });
1568
- var findActiveQueryRange = (doc, cursorPos, boundaries) => {
1569
- if (boundaries.length === 0) return null;
1570
- let match = boundaries[boundaries.length - 1];
1571
- for (const boundary of boundaries) {
1572
- if (cursorPos <= boundary.to) {
1573
- match = boundary;
1574
- break;
1575
- }
1576
- }
1577
- if (!match) return null;
1578
- const queryText = doc.slice(match.from, match.to);
1579
- const leadingWhitespace = queryText.length - queryText.trimStart().length;
1580
- const trailingWhitespace = queryText.length - queryText.trimEnd().length;
1581
- const trimmedStart = match.from + leadingWhitespace;
1582
- const trimmedEnd = match.to - trailingWhitespace;
1583
- if (trimmedStart >= trimmedEnd) return null;
1584
- return { from: trimmedStart, to: trimmedEnd };
1585
- };
1586
- var computeBoundaries = (queries) => {
1587
- const boundaries = [];
1588
- let offset = 0;
1589
- for (const query of queries) {
1590
- boundaries.push({ from: offset, to: offset + query.length });
1591
- offset += query.length;
1592
- }
1593
- return boundaries;
1594
- };
1595
- var mapBoundariesThroughChanges = (boundaries, changes) => {
1596
- const prevLen = changes.length;
1597
- const mapped = [];
1598
- for (const b of boundaries) {
1599
- const from = changes.mapPos(Math.max(0, Math.min(b.from, prevLen)), -1);
1600
- const to = changes.mapPos(Math.max(0, Math.min(b.to, prevLen)), 1);
1601
- if (from < to) mapped.push({ from, to });
1602
- }
1603
- return mapped;
1604
- };
1605
- var buildDecorations = (view, range) => {
1606
- const startLine = view.state.doc.lineAt(range.from).number;
1607
- const endLine = view.state.doc.lineAt(range.to).number;
1608
- const decorations = [];
1609
- for (let lineNum = startLine; lineNum <= endLine; lineNum++) {
1610
- const lineStart = view.state.doc.line(lineNum).from;
1611
- if (startLine === endLine) {
1612
- decorations.push(activeQuerySingleLine.range(lineStart));
1613
- } else if (lineNum === startLine) {
1614
- decorations.push(activeQueryFirstLine.range(lineStart));
1615
- } else if (lineNum === endLine) {
1616
- decorations.push(activeQueryLastLine.range(lineStart));
1617
- } else {
1618
- decorations.push(activeQueryMiddleLine.range(lineStart));
1619
- }
1620
- }
1621
- return Decoration.set(decorations);
1622
- };
1623
- var activeQueryHighlight = (splitQueries) => {
1624
- return [
1625
- ViewPlugin.fromClass(
1626
- class {
1627
- decorations = Decoration.none;
1628
- debounceTimer = null;
1629
- seq = 0;
1630
- cachedDoc = "";
1631
- cachedBoundaries = [];
1632
- destroyed = false;
1633
- constructor(view) {
1634
- this.scheduleDocParse(view);
1635
- }
1636
- update(update) {
1637
- if (update.focusChanged && !update.view.hasFocus) {
1638
- this.decorations = Decoration.none;
1639
- return;
1640
- }
1641
- if (update.docChanged) {
1642
- if (this.cachedBoundaries.length > 0) {
1643
- this.cachedBoundaries = mapBoundariesThroughChanges(
1644
- this.cachedBoundaries,
1645
- update.changes
1646
- );
1647
- this.cachedDoc = update.state.doc.toString();
1648
- this.updateFromCache(update.view);
1649
- }
1650
- this.scheduleDocParse(update.view);
1651
- } else if (update.selectionSet || update.focusChanged && update.view.hasFocus) {
1652
- this.updateFromCache(update.view);
1653
- }
1654
- }
1655
- destroy() {
1656
- this.destroyed = true;
1657
- if (this.debounceTimer) clearTimeout(this.debounceTimer);
1658
- }
1659
- /**
1660
- * Update decorations using cached query boundaries.
1661
- * Only mutates this.decorations — does NOT call view.dispatch().
1662
- * When called from update() (sync), CodeMirror picks up the new
1663
- * decorations via the accessor. When called from the async
1664
- * scheduleDocParse callback, the caller must dispatch separately.
1665
- */
1666
- updateFromCache(view) {
1667
- if (!view.hasFocus) {
1668
- this.decorations = Decoration.none;
1669
- return;
1670
- }
1671
- const { main } = view.state.selection;
1672
- if (main.from !== main.to) {
1673
- this.decorations = Decoration.none;
1674
- return;
1675
- }
1676
- const doc = view.state.doc.toString();
1677
- if (doc !== this.cachedDoc) return;
1678
- if (this.cachedBoundaries.length === 0) {
1679
- this.decorations = Decoration.none;
1680
- return;
1681
- }
1682
- const range = findActiveQueryRange(doc, main.head, this.cachedBoundaries);
1683
- this.decorations = range ? buildDecorations(view, range) : Decoration.none;
1684
- }
1685
- /** Parse queries async (debounced) and update decorations. */
1686
- scheduleDocParse(view) {
1687
- if (this.debounceTimer) clearTimeout(this.debounceTimer);
1688
- this.debounceTimer = setTimeout(async () => {
1689
- const seq = ++this.seq;
1690
- const doc = view.state.doc.toString();
1691
- if (!doc.trim()) {
1692
- this.cachedDoc = doc;
1693
- this.cachedBoundaries = [];
1694
- if (this.decorations !== Decoration.none) {
1695
- this.decorations = Decoration.none;
1696
- if (!this.destroyed) view.dispatch();
1697
- }
1698
- return;
1699
- }
1700
- let queries;
1701
- try {
1702
- queries = await splitQueries(doc);
1703
- } catch {
1704
- return;
1705
- }
1706
- if (this.destroyed || seq !== this.seq) return;
1707
- this.cachedDoc = doc;
1708
- this.cachedBoundaries = computeBoundaries(queries);
1709
- this.updateFromCache(view);
1710
- if (!this.destroyed) view.dispatch();
1711
- }, 100);
1712
- }
1713
- },
1714
- { decorations: (v) => v.decorations }
1715
- ),
1716
- EditorView.baseTheme({
1717
- ".cm-active-query": {
1718
- boxShadow: `inset -1px 0 0 0 ${colors.blue[300]}, inset 1px 0 0 0 ${colors.blue[300]}`,
1719
- marginRight: "8px"
1720
- },
1721
- ".cm-active-query-first": {
1722
- boxShadow: `inset -1px 0 0 0 ${colors.blue[300]}, inset 1px 0 0 0 ${colors.blue[300]}, inset 0 1px 0 0 ${colors.blue[300]}`,
1723
- borderRadius: "4px 4px 0 0"
1724
- },
1725
- ".cm-active-query-last": {
1726
- boxShadow: `inset -1px 0 0 0 ${colors.blue[300]}, inset 1px 0 0 0 ${colors.blue[300]}, inset 0 -1px 0 0 ${colors.blue[300]}`,
1727
- borderRadius: "0 0 4px 4px"
1728
- },
1729
- ".cm-active-query-first.cm-active-query-last": {
1730
- boxShadow: `inset 0 0 0 1px ${colors.blue[300]}`,
1731
- borderRadius: "4px"
1732
- }
1733
- })
1734
- ];
1735
- };
1736
- var HighlightMarker = class extends GutterMarker {
1737
- toDOM() {
1738
- const marker = document.createElement("div");
1739
- marker.className = "cm-highlight-marker";
1740
- return marker;
1741
- }
1742
- };
1743
- var highlightMarker = new HighlightMarker();
1744
- var forEachLineInRange = (doc, from, to, callback) => {
1745
- const results = [];
1746
- const fromLine = Math.max(1, from + 1);
1747
- const toLine = Math.min(doc.lines, to + 1);
1748
- for (let i = fromLine; i <= toLine; i++) {
1749
- const line = doc.line(i);
1750
- results.push(callback(line.from));
1751
- }
1752
- return results;
1753
- };
1754
- var setHighlightedLinesEffect = StateEffect.define();
1755
- var highlightedLinesField = StateField.define({
1756
- create() {
1757
- return null;
1758
- },
1759
- update(value, transaction) {
1760
- for (const effect of transaction.effects) {
1761
- if (effect.is(setHighlightedLinesEffect)) {
1762
- return effect.value;
1763
- }
1764
- }
1765
- return value;
1766
- }
1767
- });
1768
- var highlightGutter = gutter({
1769
- class: "cm-highlight-gutter",
1770
- markers: (view) => {
1771
- const highlightInfo = view.state.field(highlightedLinesField, false);
1772
- if (!highlightInfo) {
1773
- return RangeSet.empty;
1774
- }
1775
- const markers = forEachLineInRange(
1776
- view.state.doc,
1777
- highlightInfo.from,
1778
- highlightInfo.to,
1779
- (lineFrom) => highlightMarker.range(lineFrom)
1780
- );
1781
- return RangeSet.of(markers);
1782
- }
1783
- });
1784
- var errorLineDecorations = StateField.define({
1785
- create() {
1786
- return Decoration.none;
1787
- },
1788
- update(decorations, transaction) {
1789
- decorations = decorations.map(transaction.changes);
1790
- for (const effect of transaction.effects) {
1791
- if (!effect.is(setHighlightedLinesEffect)) {
1792
- continue;
1793
- }
1794
- if (!effect.value || !effect.value.error) {
1795
- return Decoration.none;
1796
- }
1797
- const decorationArray = forEachLineInRange(
1798
- transaction.state.doc,
1799
- effect.value.error.from,
1800
- effect.value.error.to,
1801
- (lineFrom) => Decoration.line({ class: "cm-error-line" }).range(lineFrom)
1802
- );
1803
- return Decoration.set(decorationArray);
1804
- }
1805
- return decorations;
1806
- },
1807
- provide: (f) => EditorView.decorations.from(f)
1808
- });
1809
- var processingLineDecorations = StateField.define({
1810
- create() {
1811
- return Decoration.none;
1812
- },
1813
- update(decorations, transaction) {
1814
- decorations = decorations.map(transaction.changes);
1815
- for (const effect of transaction.effects) {
1816
- if (!effect.is(setHighlightedLinesEffect)) {
1817
- continue;
1818
- }
1819
- if (!effect.value || !effect.value.processing) {
1820
- return Decoration.none;
1821
- }
1822
- const decorationArray = forEachLineInRange(
1823
- transaction.state.doc,
1824
- effect.value.processing.from,
1825
- effect.value.processing.to,
1826
- (lineFrom) => Decoration.line({ class: "cm-processing-line" }).range(lineFrom)
1827
- );
1828
- return Decoration.set(decorationArray);
1829
- }
1830
- return decorations;
1831
- },
1832
- provide: (f) => EditorView.decorations.from(f)
1833
- });
1834
- var highlightedLinesTheme = EditorView.baseTheme({
1835
- ".cm-highlight-gutter": {
1836
- width: "2px",
1837
- marginRight: "2px"
1838
- },
1839
- ".cm-highlight-marker": {
1840
- width: "2px",
1841
- height: "100%",
1842
- backgroundColor: colors.blue[500]
1843
- },
1844
- ".cm-error-line": {
1845
- backgroundColor: `${colors.error[100]} !important`
1846
- },
1847
- ".cm-processing-line": {
1848
- backgroundColor: `${colors.blue[100]} !important`
1849
- }
1850
- });
1851
- function highlightingExtension() {
1852
- return [
1853
- highlightedLinesField,
1854
- highlightGutter,
1855
- errorLineDecorations,
1856
- processingLineDecorations,
1857
- highlightedLinesTheme
1858
- ];
1859
- }
1860
- function updateHighlighting(view, lines) {
1861
- view.dispatch({ effects: setHighlightedLinesEffect.of(lines ?? null) });
1862
- }
1863
- var OWN_KEYMAPS = {
1864
- defaultKeymap: false,
1865
- completionKeymap: false,
1866
- searchKeymap: false
1867
- };
1868
- var CUSTOM_KEYMAP = [
1869
- {
1870
- key: "Escape",
1871
- stopPropagation: true,
1872
- run: (view) => {
1873
- view.contentDOM.blur();
1874
- return true;
1875
- }
1876
- }
1877
- ];
1878
- var OWN_KEYMAP_EXTENSION = keymap.of([...defaultKeymap, ...CUSTOM_KEYMAP]);
1879
- var buildTheme = () => ({
1880
- ...buildBaseThemeStyles(),
1881
- "&.cm-editor": {
1882
- border: "solid 1px transparent",
1883
- background: resolveToken("card", "255 255 255"),
1884
- borderRadius: "8px",
1885
- paddingTop: "8px",
1886
- paddingBottom: "8px"
1887
- },
1888
- '&.cm-editor:has(.cm-content[contenteditable="true"]):hover': {
1889
- borderColor: resolveToken("ring", "31 143 255")
1890
- },
1891
- '&.cm-editor:has(.cm-content[contenteditable="true"]):focus-within': {
1892
- borderColor: resolveToken("ring", "31 143 255"),
1893
- boxShadow: `0 0 0 4px ${resolveToken("ring", "31 143 255", 0.3)}`
1894
- },
1895
- "&.cm-editor .cm-scroller": { overflowAnchor: "none" },
1896
- "&.cm-editor :is(.cm-gutters,.cm-scroller)": { background: resolveToken("card", "255 255 255") },
1897
- '&.cm-editor:has(.cm-content[contenteditable="false"])': {
1898
- background: resolveToken("muted", "241 245 249")
1899
- },
1900
- '&.cm-editor:has(.cm-content[contenteditable="false"]) :is(.cm-scroller,.cm-gutters)': {
1901
- background: resolveToken("muted", "241 245 249")
1902
- }
1903
- });
1904
- var SqlEditor = ({
1905
- value,
1906
- onChange,
1907
- onSelectionChange,
1908
- onCreateEditor,
1909
- onDestroyEditor,
1910
- onBlurEditor,
1911
- onFocusEditor,
1912
- placeholder = "",
1913
- searchQuery = "",
1914
- searchMatchIndex,
1915
- readOnly = false,
1916
- queryParser,
1917
- autoFocus = false,
1918
- lineNumbers = true,
1919
- className,
1920
- schema,
1921
- variables,
1922
- defaultDatabase,
1923
- defaultSchema,
1924
- highlightLines,
1925
- dialect
1926
- }) => {
1927
- const editorRef = useRef(null);
1928
- const handleChange = useStableCallback((next) => onChange?.(next));
1929
- const parseQueries = useStableCallback(async (sql2) => await queryParser?.(sql2) ?? []);
1930
- const handleBlur = useStableCallback((view) => onBlurEditor?.(view));
1931
- const handleFocus = useStableCallback((view) => onFocusEditor?.(view));
1932
- const handleUpdate = useStableCallback((update) => {
1933
- if (update.selectionSet) {
1934
- const { main } = update.state.selection;
1935
- onSelectionChange?.(update.state.sliceDoc(main.from, main.to));
1936
- }
1937
- });
1938
- const variableCompletion = useVariableCompletion(variables);
1939
- const withQueryParser = queryParser !== void 0;
1940
- const tooltipLayer = useTooltipsExtension();
1941
- const customTheme = useThemedExtension("editor:syntax", buildCustomTheme);
1942
- const themeExtension = useThemedExtension(
1943
- "sql-editor:chrome",
1944
- () => EditorView$1.theme(buildTheme())
1945
- );
1946
- const extensions = useMemo(() => {
1947
- return [
1948
- EditorView$1.lineWrapping,
1949
- OWN_KEYMAP_EXTENSION,
1950
- ...installExtensions({
1951
- schema,
1952
- defaultDatabase,
1953
- defaultSchema,
1954
- variableCompletion,
1955
- dialect
1956
- }),
1957
- searchExtension(),
1958
- highlightingExtension(),
1959
- withQueryParser ? activeQueryHighlight(parseQueries) : [],
1960
- tooltipLayer,
1961
- themeExtension,
1962
- EditorView$1.domEventHandlers({
1963
- blur: (_, view) => handleBlur(view),
1964
- focus: (_, view) => handleFocus(view)
1965
- })
1966
- ];
1967
- }, [
1968
- withQueryParser,
1969
- parseQueries,
1970
- schema,
1971
- defaultDatabase,
1972
- defaultSchema,
1973
- variableCompletion,
1974
- dialect,
1975
- handleBlur,
1976
- handleFocus,
1977
- themeExtension,
1978
- tooltipLayer
1979
- ]);
1980
- const defaultSetup = useMemo(() => {
1981
- return { ...buildBasicSetup(readOnly), ...OWN_KEYMAPS, lineNumbers };
1982
- }, [readOnly, lineNumbers]);
1983
- useEffect(() => {
1984
- if (editorRef.current?.view) {
1985
- updateHighlighting(editorRef.current.view, highlightLines);
1986
- }
1987
- }, [highlightLines]);
1988
- useEffect(() => {
1989
- if (editorRef.current?.view) {
1990
- updateSearch(editorRef.current.view, searchQuery, searchMatchIndex);
1991
- }
1992
- }, [searchQuery, searchMatchIndex]);
1993
- const handleDestroy = useStableCallback(() => onDestroyEditor?.());
1994
- useEffect(() => handleDestroy, [handleDestroy]);
1995
- const handleCreate = useStableCallback((view, state) => {
1996
- onCreateEditor?.(view, state);
1997
- if (highlightLines) {
1998
- updateHighlighting(view, highlightLines);
1999
- }
2000
- if (searchQuery) {
2001
- updateSearch(view, searchQuery, searchMatchIndex);
2002
- }
2003
- });
2004
- return /* @__PURE__ */ jsx(
2005
- CodeMirror,
2006
- {
2007
- ref: editorRef,
2008
- theme: customTheme,
2009
- extensions,
2010
- value,
2011
- onChange: handleChange,
2012
- onUpdate: handleUpdate,
2013
- onCreateEditor: handleCreate,
2014
- autoFocus,
2015
- placeholder,
2016
- className,
2017
- readOnly,
2018
- editable: !readOnly,
2019
- basicSetup: defaultSetup
2020
- }
2021
- );
2022
- };
2023
-
2024
- // src/components/MergeEditor/constants.ts
2025
- var CHANGE_CLASS = {
2026
- SAFE: "safe"};
2027
- var LINE_HEIGHT_PX = 20;
2028
- var PANE_HEADER_HEIGHT_PX = 58;
2029
18
  var AcceptButton = ({ side, onAccept }) => {
2030
19
  const label = `Accept ${side === "left" ? "production" : "branch"} version`;
2031
20
  const Chevron = side === "left" ? ChevronsRight : ChevronsLeft;
@@ -2080,62 +69,70 @@ var ConflictGutterMarker = class extends GutterMarker {
2080
69
  };
2081
70
  var safeGutterMarker = new SafeGutterMarker();
2082
71
  var conflictGutterMarker = new ConflictGutterMarker();
2083
- var createDiffHighlightExtension = () => {
2084
- const field = StateField.define({
2085
- create: () => ({ decorations: Decoration.none, gutterMarkers: RangeSet.empty }),
2086
- update(value, tr) {
2087
- let payload = null;
2088
- for (const effect of tr.effects) {
2089
- if (effect.is(setHighlightedLines)) {
2090
- payload = effect.value;
2091
- }
2092
- }
2093
- if (!payload) {
2094
- return {
2095
- decorations: value.decorations.map(tr.changes),
2096
- gutterMarkers: value.gutterMarkers.map(tr.changes)
2097
- };
2098
- }
2099
- const decoBuilder = new RangeSetBuilder();
2100
- const gutterBuilder = new RangeSetBuilder();
2101
- const doc = tr.state.doc;
2102
- const { lines, classification } = payload;
2103
- const sorted = [...lines].filter((l) => l >= 1 && l <= doc.lines).sort((a, b) => a - b);
2104
- for (const i of sorted) {
2105
- const cls = classification.get(i);
2106
- if (!cls) continue;
2107
- const isSafe = cls === CHANGE_CLASS.SAFE;
2108
- const line = doc.line(i);
2109
- decoBuilder.add(line.from, line.from, isSafe ? safeDecoration : conflictDecoration);
2110
- gutterBuilder.add(line.from, line.from, isSafe ? safeGutterMarker : conflictGutterMarker);
72
+ var createDiffHighlightExtension = () => StateField.define({
73
+ create: () => ({ decorations: Decoration.none, gutterMarkers: RangeSet.empty }),
74
+ update(value, tr) {
75
+ let payload = null;
76
+ for (const effect of tr.effects) {
77
+ if (effect.is(setHighlightedLines)) {
78
+ payload = effect.value;
2111
79
  }
80
+ }
81
+ if (!payload) {
2112
82
  return {
2113
- decorations: decoBuilder.finish(),
2114
- gutterMarkers: gutterBuilder.finish()
83
+ decorations: value.decorations.map(tr.changes),
84
+ gutterMarkers: value.gutterMarkers.map(tr.changes)
2115
85
  };
2116
- },
2117
- provide: (f) => [
2118
- EditorView.decorations.from(f, (val) => val.decorations),
2119
- gutterLineClass.from(f, (val) => val.gutterMarkers)
2120
- ]
2121
- });
2122
- const theme = EditorView.theme({
86
+ }
87
+ const decoBuilder = new RangeSetBuilder();
88
+ const gutterBuilder = new RangeSetBuilder();
89
+ const doc = tr.state.doc;
90
+ const { lines, classification } = payload;
91
+ const sorted = [...lines].filter((l) => l >= 1 && l <= doc.lines).sort((a, b) => a - b);
92
+ for (const i of sorted) {
93
+ const cls = classification.get(i);
94
+ if (!cls) continue;
95
+ const isSafe = cls === CHANGE_CLASS.SAFE;
96
+ const line = doc.line(i);
97
+ decoBuilder.add(line.from, line.from, isSafe ? safeDecoration : conflictDecoration);
98
+ gutterBuilder.add(line.from, line.from, isSafe ? safeGutterMarker : conflictGutterMarker);
99
+ }
100
+ return {
101
+ decorations: decoBuilder.finish(),
102
+ gutterMarkers: gutterBuilder.finish()
103
+ };
104
+ },
105
+ provide: (f) => [
106
+ EditorView.decorations.from(f, (val) => val.decorations),
107
+ gutterLineClass.from(f, (val) => val.gutterMarkers)
108
+ ]
109
+ });
110
+ var DARK_LINE_ALPHA = "29";
111
+ var DARK_GUTTER_ALPHA = "47";
112
+ var buildDiffHighlightTheme = () => {
113
+ const dark = isDarkScheme();
114
+ const line = (hue, pastel) => dark ? `${hue}${DARK_LINE_ALPHA}` : pastel;
115
+ const gutter = (hue, pastel) => dark ? `${hue}${DARK_GUTTER_ALPHA}` : pastel;
116
+ const safeNumber = dark ? colors.green[300] : colors.green[900];
117
+ const conflictNumber = dark ? colors.warning[300] : colors.warning[800];
118
+ return EditorView.theme({
2123
119
  ".cm-merge-safe-line": {
2124
- backgroundColor: `${colors.green[100]} !important`,
120
+ backgroundColor: `${line(colors.green[500], colors.green[100])} !important`,
2125
121
  boxShadow: `inset 3px 0 0 ${colors.green[500]}`
2126
122
  },
2127
123
  ".cm-merge-conflict-line": {
2128
- backgroundColor: `${colors.warning[100]} !important`,
124
+ backgroundColor: `${line(colors.warning[500], colors.warning[100])} !important`,
2129
125
  boxShadow: `inset 3px 0 0 ${colors.warning[500]}`
2130
126
  },
2131
127
  ".cm-merge-safe-gutter": {
2132
- backgroundColor: `${colors.green[200]} !important`
128
+ backgroundColor: `${gutter(colors.green[500], colors.green[200])} !important`,
129
+ color: safeNumber
2133
130
  },
2134
131
  ".cm-merge-conflict-gutter": {
2135
- backgroundColor: `${colors.warning[200]} !important`
132
+ backgroundColor: `${gutter(colors.warning[500], colors.warning[200])} !important`,
133
+ color: conflictNumber
2136
134
  }
2137
135
  });
2138
- return [field, theme];
2139
136
  };
2140
137
  var updateHighlightedLines = (view, lines, classification) => {
2141
138
  view.dispatch({ effects: setHighlightedLines.of({ lines, classification }) });
@@ -2156,27 +153,30 @@ var MergePane = ({
2156
153
  }) => {
2157
154
  const editorRef = useRef(null);
2158
155
  const handleChange = useStableCallback((next) => onChange?.(next));
2159
- const themeExtension = useThemedExtension(
2160
- `merge-pane:${deleted}`,
2161
- () => EditorView.theme({
156
+ const themeExtension = useThemedExtension(`merge-pane:${deleted}`, () => {
157
+ const dark = isDarkScheme();
158
+ const deletedSurface = dark ? `${colors.error[500]}1f` : colors.error[100];
159
+ const deletedGutter = dark ? `${colors.error[500]}3d` : colors.error[200];
160
+ const deletedGutterText = dark ? colors.error[300] : colors.error[700];
161
+ return EditorView.theme({
2162
162
  "&.cm-editor": {
2163
163
  height: "100%",
2164
- backgroundColor: deleted ? colors.error[100] : resolveToken("background", "249 250 251"),
164
+ backgroundColor: deleted ? deletedSurface : resolveToken("background", "249 250 251"),
2165
165
  // Pair the token-driven surface with a token-driven text color so line
2166
166
  // content stays readable when the pane's `--background` goes dark.
2167
- // The deleted pane keeps default dark text on its fixed light-red wash.
2168
- ...deleted ? {} : { color: resolveToken("foreground", "30 41 59") },
167
+ color: resolveToken("foreground", "30 41 59"),
2169
168
  outline: "none"
2170
169
  },
2171
170
  ".cm-gutters": {
2172
- backgroundColor: deleted ? colors.error[200] : resolveToken("muted", "241 245 249"),
2173
- ...deleted ? {} : { color: resolveToken("muted-foreground", "100 116 139") }
171
+ backgroundColor: deleted ? deletedGutter : resolveToken("muted", "241 245 249"),
172
+ color: deleted ? deletedGutterText : resolveToken("muted-foreground", "100 116 139")
2174
173
  },
2175
174
  "*": { lineHeight: `${LINE_HEIGHT_PX}px` },
2176
175
  ".cm-lineNumbers .cm-gutterElement": { padding: "0 0 0 25px" }
2177
- })
2178
- );
176
+ });
177
+ });
2179
178
  const diffHighlightExtension = useMemo(() => createDiffHighlightExtension(), []);
179
+ const diffHighlightTheme = useThemedExtension("merge-diff-highlight", buildDiffHighlightTheme);
2180
180
  const basicSetup = useMemo(
2181
181
  () => ({ ...buildBasicSetup(readOnly), lineNumbers: true }),
2182
182
  [readOnly]
@@ -2184,6 +184,7 @@ var MergePane = ({
2184
184
  const extensions = useMemo(
2185
185
  () => [
2186
186
  diffHighlightExtension,
187
+ diffHighlightTheme,
2187
188
  themeExtension,
2188
189
  // Recalc viewport after every doc change so late-settling layouts (alerts
2189
190
  // appearing above the editor) don't leave trailing lines blank.
@@ -2193,7 +194,7 @@ var MergePane = ({
2193
194
  }
2194
195
  })
2195
196
  ],
2196
- [diffHighlightExtension, themeExtension]
197
+ [diffHighlightExtension, diffHighlightTheme, themeExtension]
2197
198
  );
2198
199
  useEffect(() => {
2199
200
  const view = editorRef.current?.view;
@@ -2232,7 +233,7 @@ var MergePane = ({
2232
233
  className: cn(
2233
234
  "tw:flex tw:min-w-0 tw:flex-1 tw:flex-col tw:overflow-hidden",
2234
235
  className,
2235
- deleted && "tw:border-error-300"
236
+ deleted && "tw:border-error-300 tw:[[data-theme=dark]_&]:border-error-500/50"
2236
237
  ),
2237
238
  children: [
2238
239
  header && /* @__PURE__ */ jsx(
@@ -2240,7 +241,10 @@ var MergePane = ({
2240
241
  {
2241
242
  className: cn(
2242
243
  "tw:px-4 tw:py-3",
2243
- deleted ? "tw:border-b tw:border-error-200 tw:bg-error-100" : "tw:bg-background",
244
+ // Same light/dark split as the editor wash below — `PaneHeader` pins
245
+ // `text-foreground`, which goes near-white and vanishes on the
246
+ // opaque light-red band.
247
+ deleted ? "tw:border-b tw:border-error-200 tw:bg-error-100 tw:[[data-theme=dark]_&]:border-error-500/30 tw:[[data-theme=dark]_&]:bg-error-500/15" : "tw:bg-background",
2244
248
  headerClassName
2245
249
  ),
2246
250
  children: header
@@ -2424,6 +428,6 @@ var MergeEditor = ({
2424
428
  );
2425
429
  };
2426
430
 
2427
- export { CodeEditor, LANGUAGE_MODES, MergeEditor, SqlEditor, isLanguageMode };
431
+ export { MergeEditor };
2428
432
  //# sourceMappingURL=editors.js.map
2429
433
  //# sourceMappingURL=editors.js.map