@keboola/design 3.2.3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -45,27 +45,9 @@ import * as ResizablePrimitive from 'react-resizable-panels';
45
45
  import * as RadixAvatar from '@radix-ui/react-avatar';
46
46
  import * as RadixTabs from '@radix-ui/react-tabs';
47
47
  import { diffLines, diffWords } from 'diff';
48
- import { Decoration, gutter, EditorView, ViewPlugin, GutterMarker, keymap, placeholder, gutterLineClass } from '@codemirror/view';
49
- import CodeMirror, { EditorState, EditorView as EditorView$1, keymap as keymap$1 } from '@uiw/react-codemirror';
50
- import colors3 from '@keboola/tailwind-config/colors';
51
- import { StateEffect, StateField, RangeSet, RangeSetBuilder } from '@codemirror/state';
52
48
  import { diff3Merge } from 'node-diff3';
53
49
  import { createFormHookContexts, createFormHook } from '@tanstack/react-form';
54
50
  import DOMPurify from 'dompurify';
55
- import { completeAnyWord, autocompletion } from '@codemirror/autocomplete';
56
- import { jsonParseLinter, json } from '@codemirror/lang-json';
57
- import { linter } from '@codemirror/lint';
58
- import { unifiedMergeView } from '@codemirror/merge';
59
- import { javascript } from '@codemirror/lang-javascript';
60
- import { python } from '@codemirror/lang-python';
61
- import { sql, PLSQL } from '@codemirror/lang-sql';
62
- import { StreamLanguage } from '@codemirror/language';
63
- import { r } from '@codemirror/legacy-modes/mode/r';
64
- import { shell } from '@codemirror/legacy-modes/mode/shell';
65
- import { githubLightInit } from '@uiw/codemirror-theme-github';
66
- import { sfsql } from '@keboola/codemirror-lang-sfsql';
67
- import { defaultKeymap } from '@codemirror/commands';
68
- import { installExtensions } from '@keboola/codemirror-lang-sql';
69
51
 
70
52
  var __defProp = Object.defineProperty;
71
53
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -136,7 +118,6 @@ var createChangeInputEvent = (input) => {
136
118
  // src/constants/keyCodes.ts
137
119
  var keyCodes = {
138
120
  ENTER: "Enter",
139
- ESCAPE: "Escape",
140
121
  SPACE: " "
141
122
  };
142
123
  var ThemeContext = createContext(null);
@@ -6872,8 +6853,8 @@ var coerceColorPickerValue = (value) => {
6872
6853
  const body = extractHexBody(value);
6873
6854
  if (body === null || !HEX_CHARSET.test(body)) return PICKER_FALLBACK;
6874
6855
  if (body.length === 3 || body.length === 4) {
6875
- const [r2, g, b] = body;
6876
- return `#${r2}${r2}${g}${g}${b}${b}`.toLowerCase();
6856
+ const [r, g, b] = body;
6857
+ return `#${r}${r}${g}${g}${b}${b}`.toLowerCase();
6877
6858
  }
6878
6859
  if (body.length === 6 || body.length === 8) {
6879
6860
  return `#${body.slice(0, 6).toLowerCase()}`;
@@ -9314,7 +9295,11 @@ var AlertRoot = ({
9314
9295
  "has-[[data-slot=alert-icon]]:tw-gap-x-2",
9315
9296
  // fonts
9316
9297
  "tw-text-sm",
9298
+ // Legacy keeps the fixed neutral text; argo uses the semantic foreground
9299
+ // so the alert flips with the brand's light/dark palette (the categorical
9300
+ // variant tint stays — only the text token becomes brand-aware).
9317
9301
  "tw-text-neutral-800",
9302
+ "data-[argo=true]:tw-text-foreground",
9318
9303
  "tw-text-left",
9319
9304
  "tw-p-4",
9320
9305
  // border
@@ -10288,20 +10273,20 @@ var AIGradientsSvg = () => /* @__PURE__ */ jsx("svg", { width: "0", height: "0",
10288
10273
  // src/components/ThemeProvider/brandToCssVars.ts
10289
10274
  var brandToCssVars = (brand, resolvedMode) => {
10290
10275
  const vars = {};
10291
- const colors8 = resolvedMode === "dark" ? brand.colorsDark : brand.colors;
10292
- if (colors8) {
10293
- vars["--color-background"] = colors8.background;
10294
- vars["--color-foreground"] = colors8.foreground;
10295
- vars["--color-muted"] = colors8.muted;
10296
- vars["--color-muted-foreground"] = colors8.mutedForeground;
10297
- vars["--color-border"] = colors8.border;
10298
- vars["--color-primary"] = colors8.primary;
10299
- vars["--color-primary-foreground"] = colors8.primaryForeground;
10300
- vars["--color-destructive"] = colors8.destructive;
10301
- vars["--color-destructive-foreground"] = colors8.destructiveForeground;
10302
- if (colors8.accent !== void 0) vars["--color-accent"] = colors8.accent;
10303
- if (colors8.accentForeground !== void 0)
10304
- vars["--color-accent-foreground"] = colors8.accentForeground;
10276
+ const colors = resolvedMode === "dark" ? brand.colorsDark : brand.colors;
10277
+ if (colors) {
10278
+ vars["--color-background"] = colors.background;
10279
+ vars["--color-foreground"] = colors.foreground;
10280
+ vars["--color-muted"] = colors.muted;
10281
+ vars["--color-muted-foreground"] = colors.mutedForeground;
10282
+ vars["--color-border"] = colors.border;
10283
+ vars["--color-primary"] = colors.primary;
10284
+ vars["--color-primary-foreground"] = colors.primaryForeground;
10285
+ vars["--color-destructive"] = colors.destructive;
10286
+ vars["--color-destructive-foreground"] = colors.destructiveForeground;
10287
+ if (colors.accent !== void 0) vars["--color-accent"] = colors.accent;
10288
+ if (colors.accentForeground !== void 0)
10289
+ vars["--color-accent-foreground"] = colors.accentForeground;
10305
10290
  }
10306
10291
  const sidebar = resolvedMode === "dark" ? brand.sidebarColorsDark : brand.sidebarColors;
10307
10292
  if (sidebar) {
@@ -10679,6 +10664,7 @@ var PageLayout = Object.assign(Root25, {
10679
10664
  // src/blocks/PageHeader/styles.ts
10680
10665
  var titleRowClass = "tw-flex tw-flex-wrap tw-items-center tw-gap-x-3 tw-gap-y-2";
10681
10666
  var titleClass = "tw-m-0 tw-text-3xl tw-font-semibold tw-leading-9 tw-text-foreground tw-break-words";
10667
+ var titleCompactClass = "tw-m-0 tw-text-xl tw-font-semibold tw-leading-7 tw-text-foreground tw-break-words";
10682
10668
  var badgesClass = "tw-flex tw-flex-wrap tw-items-center tw-gap-2 [&_[data-slot=badge]]:tw-rounded-full [&_[data-slot=badge]]:tw-normal-case [&_[data-slot=badge]]:tw-tracking-normal [&_[data-slot=badge]]:tw-py-0";
10683
10669
  var descriptionClass = "tw-m-0 tw-max-w-[800px] tw-break-words tw-text-sm tw-leading-5 tw-text-muted-foreground";
10684
10670
  var PageHeaderDetail = ({
@@ -10690,6 +10676,7 @@ var PageHeaderDetail = ({
10690
10676
  titleIcon,
10691
10677
  badges,
10692
10678
  description,
10679
+ compact = false,
10693
10680
  primaryAction,
10694
10681
  secondaryAction,
10695
10682
  headerNav,
@@ -10703,7 +10690,7 @@ var PageHeaderDetail = ({
10703
10690
  /* @__PURE__ */ jsxs("div", { className: "tw-flex tw-min-w-0 tw-flex-1 tw-flex-col tw-gap-2 tw-pr-2", children: [
10704
10691
  /* @__PURE__ */ jsxs("div", { className: titleRowClass, children: [
10705
10692
  titleIcon && /* @__PURE__ */ jsx("span", { className: "tw-flex tw-shrink-0 tw-items-center", children: titleIcon }),
10706
- /* @__PURE__ */ jsx("h1", { className: titleClass, children: title }),
10693
+ /* @__PURE__ */ jsx("h1", { className: compact ? titleCompactClass : titleClass, children: title }),
10707
10694
  badges && /* @__PURE__ */ jsx("div", { className: badgesClass, children: badges })
10708
10695
  ] }),
10709
10696
  description && /* @__PURE__ */ jsx("p", { className: descriptionClass, children: description })
@@ -13991,423 +13978,6 @@ var DiffView = ({
13991
13978
  }
13992
13979
  );
13993
13980
  };
13994
-
13995
- // src/components/MergeEditor/constants.ts
13996
- var CHUNK_TYPE = {
13997
- UNCHANGED: "unchanged",
13998
- ADDED: "added",
13999
- REMOVED: "removed"
14000
- };
14001
- var CHANGE_CLASS = {
14002
- SAFE: "safe",
14003
- CONFLICT: "conflict"
14004
- };
14005
- var LINE_HEIGHT_PX = 20;
14006
- var PANE_HEADER_HEIGHT_PX = 58;
14007
- var AcceptButton = ({ side, onAccept, argo }) => {
14008
- const label = `Accept ${side === "left" ? "production" : "branch"} version`;
14009
- const Chevron = side === "left" ? icons_exports.ChevronsRight : icons_exports.ChevronsLeft;
14010
- return /* @__PURE__ */ jsx(
14011
- Button,
14012
- {
14013
- onClick: onAccept,
14014
- variant: "outline",
14015
- size: "icon-sm",
14016
- title: label,
14017
- "aria-label": label,
14018
- argo,
14019
- children: /* @__PURE__ */ jsx(Chevron, { className: "tw-size-5" })
14020
- }
14021
- );
14022
- };
14023
- var AcceptControls = ({
14024
- conflicts,
14025
- side,
14026
- onAccept,
14027
- onDismiss,
14028
- contentRef,
14029
- argo
14030
- }) => /* @__PURE__ */ jsx(
14031
- "div",
14032
- {
14033
- className: cn(
14034
- "tw-z-10 tw-flex tw-shrink-0 tw-flex-col tw-items-center",
14035
- conflicts.length > 0 ? "tw-w-7" : "tw-w-0"
14036
- ),
14037
- children: conflicts.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
14038
- /* @__PURE__ */ jsx("div", { className: "tw-shrink-0", style: { height: `${PANE_HEADER_HEIGHT_PX}px` } }),
14039
- /* @__PURE__ */ jsx("div", { className: "tw-relative tw-w-full tw-flex-1 tw-overflow-y-clip tw-overflow-x-visible", children: /* @__PURE__ */ jsx("div", { ref: contentRef, className: "tw-relative tw-size-full", children: conflicts.map((conflict) => {
14040
- const topLine = side === "left" ? conflict.oldStartLine : conflict.newStartLine;
14041
- const topOffset = (topLine - 1) * LINE_HEIGHT_PX - 2;
14042
- return /* @__PURE__ */ jsxs(
14043
- "div",
14044
- {
14045
- className: "tw-absolute tw-inset-x-0 tw-flex tw-flex-col tw-items-center tw-gap-0.5",
14046
- style: { top: `${topOffset}px` },
14047
- children: [
14048
- /* @__PURE__ */ jsx(AcceptButton, { side, onAccept: () => onAccept(conflict), argo }),
14049
- onDismiss && /* @__PURE__ */ jsx(
14050
- Button,
14051
- {
14052
- onClick: () => onDismiss(conflict),
14053
- variant: "outline",
14054
- size: "icon-sm",
14055
- title: "Dismiss",
14056
- "aria-label": `Dismiss ${side === "left" ? "production" : "branch"} change`,
14057
- argo,
14058
- children: /* @__PURE__ */ jsx(icons_exports.X, { className: "tw-size-4" })
14059
- }
14060
- )
14061
- ]
14062
- },
14063
- conflict.id
14064
- );
14065
- }) }) })
14066
- ] })
14067
- }
14068
- );
14069
- var setHighlightedLines = StateEffect.define();
14070
- var safeDecoration = Decoration.line({ class: "cm-merge-safe-line" });
14071
- var conflictDecoration = Decoration.line({ class: "cm-merge-conflict-line" });
14072
- var SafeGutterMarker = class extends GutterMarker {
14073
- elementClass = "cm-merge-safe-gutter";
14074
- };
14075
- var ConflictGutterMarker = class extends GutterMarker {
14076
- elementClass = "cm-merge-conflict-gutter";
14077
- };
14078
- var safeGutterMarker = new SafeGutterMarker();
14079
- var conflictGutterMarker = new ConflictGutterMarker();
14080
- var createDiffHighlightExtension = () => {
14081
- const field = StateField.define({
14082
- create: () => ({ decorations: Decoration.none, gutterMarkers: RangeSet.empty }),
14083
- update(value, tr) {
14084
- let payload = null;
14085
- for (const effect of tr.effects) {
14086
- if (effect.is(setHighlightedLines)) {
14087
- payload = effect.value;
14088
- }
14089
- }
14090
- if (!payload) {
14091
- return {
14092
- decorations: value.decorations.map(tr.changes),
14093
- gutterMarkers: value.gutterMarkers.map(tr.changes)
14094
- };
14095
- }
14096
- const decoBuilder = new RangeSetBuilder();
14097
- const gutterBuilder = new RangeSetBuilder();
14098
- const doc = tr.state.doc;
14099
- const { lines, classification } = payload;
14100
- const sorted = [...lines].filter((l) => l >= 1 && l <= doc.lines).sort((a, b) => a - b);
14101
- for (const i of sorted) {
14102
- const cls = classification.get(i);
14103
- if (!cls) continue;
14104
- const isSafe = cls === CHANGE_CLASS.SAFE;
14105
- const line = doc.line(i);
14106
- decoBuilder.add(line.from, line.from, isSafe ? safeDecoration : conflictDecoration);
14107
- gutterBuilder.add(line.from, line.from, isSafe ? safeGutterMarker : conflictGutterMarker);
14108
- }
14109
- return {
14110
- decorations: decoBuilder.finish(),
14111
- gutterMarkers: gutterBuilder.finish()
14112
- };
14113
- },
14114
- provide: (f) => [
14115
- EditorView.decorations.from(f, (val) => val.decorations),
14116
- gutterLineClass.from(f, (val) => val.gutterMarkers)
14117
- ]
14118
- });
14119
- const theme2 = EditorView.theme({
14120
- ".cm-merge-safe-line": {
14121
- backgroundColor: `${colors3.primary[100]} !important`,
14122
- boxShadow: `inset 3px 0 0 ${colors3.primary[500]}`
14123
- },
14124
- ".cm-merge-conflict-line": {
14125
- backgroundColor: `${colors3.warning[100]} !important`,
14126
- boxShadow: `inset 3px 0 0 ${colors3.warning[500]}`
14127
- },
14128
- ".cm-merge-safe-gutter": {
14129
- backgroundColor: `${colors3.primary[200]} !important`
14130
- },
14131
- ".cm-merge-conflict-gutter": {
14132
- backgroundColor: `${colors3.warning[200]} !important`
14133
- }
14134
- });
14135
- return [field, theme2];
14136
- };
14137
- var updateHighlightedLines = (view, lines, classification) => {
14138
- view.dispatch({ effects: setHighlightedLines.of({ lines, classification }) });
14139
- };
14140
- var EMPTY_LINES = /* @__PURE__ */ new Set();
14141
- var EMPTY_CLASSIFICATION = /* @__PURE__ */ new Map();
14142
- var MergePane = ({
14143
- value,
14144
- highlightedLines,
14145
- lineClassification,
14146
- readOnly = false,
14147
- onChange,
14148
- header,
14149
- headerClassName,
14150
- className,
14151
- onScrollDOMReady,
14152
- deleted = false
14153
- }) => {
14154
- const editorRef = useRef(null);
14155
- const extensions = useMemo(
14156
- () => [
14157
- createDiffHighlightExtension(),
14158
- EditorView.theme({
14159
- "&.cm-editor": {
14160
- height: "100%",
14161
- backgroundColor: deleted ? colors3.error[100] : colors3.neutral[50],
14162
- outline: "none"
14163
- },
14164
- ".cm-gutters": {
14165
- backgroundColor: deleted ? colors3.error[200] : colors3.neutral[100]
14166
- },
14167
- "*": { lineHeight: `${LINE_HEIGHT_PX}px` },
14168
- ".cm-lineNumbers .cm-gutterElement": { padding: "0 0 0 25px" }
14169
- }),
14170
- // Recalc viewport after every doc change so late-settling layouts (alerts
14171
- // appearing above the editor) don't leave trailing lines blank.
14172
- EditorView.updateListener.of((update) => {
14173
- if (update.docChanged) {
14174
- requestAnimationFrame(() => update.view.dispatch({}));
14175
- }
14176
- })
14177
- ],
14178
- [deleted]
14179
- );
14180
- useEffect(() => {
14181
- const view = editorRef.current?.view;
14182
- if (!view) return;
14183
- updateHighlightedLines(
14184
- view,
14185
- deleted ? EMPTY_LINES : highlightedLines,
14186
- deleted ? EMPTY_CLASSIFICATION : lineClassification
14187
- );
14188
- }, [highlightedLines, lineClassification, deleted]);
14189
- const handleCreateEditor = useCallback(
14190
- (view) => {
14191
- updateHighlightedLines(
14192
- view,
14193
- deleted ? EMPTY_LINES : highlightedLines,
14194
- deleted ? EMPTY_CLASSIFICATION : lineClassification
14195
- );
14196
- onScrollDOMReady?.(view.scrollDOM);
14197
- },
14198
- [highlightedLines, lineClassification, onScrollDOMReady, deleted]
14199
- );
14200
- useEffect(() => {
14201
- return () => onScrollDOMReady?.(null);
14202
- }, [onScrollDOMReady]);
14203
- useEffect(() => {
14204
- const view = editorRef.current?.view;
14205
- const wrapper = view?.dom.parentElement;
14206
- if (!view || !wrapper) return;
14207
- const observer = new ResizeObserver(() => view.dispatch({}));
14208
- observer.observe(wrapper);
14209
- return () => observer.disconnect();
14210
- }, []);
14211
- return /* @__PURE__ */ jsxs(
14212
- "div",
14213
- {
14214
- className: cn(
14215
- "tw-flex tw-min-w-0 tw-flex-1 tw-flex-col tw-overflow-hidden",
14216
- className,
14217
- deleted && "tw-border-error-300"
14218
- ),
14219
- children: [
14220
- header && /* @__PURE__ */ jsx(
14221
- "div",
14222
- {
14223
- className: cn(
14224
- "tw-px-4 tw-py-3",
14225
- deleted ? "tw-border-b tw-border-error-200 tw-bg-error-100" : "tw-bg-background",
14226
- headerClassName
14227
- ),
14228
- children: header
14229
- }
14230
- ),
14231
- /* @__PURE__ */ jsx("div", { className: "tw-flex tw-h-0 tw-flex-1 tw-flex-col [&_>div]:tw-h-full", children: /* @__PURE__ */ jsx(
14232
- CodeMirror,
14233
- {
14234
- ref: editorRef,
14235
- height: "100%",
14236
- value,
14237
- onChange,
14238
- extensions,
14239
- readOnly,
14240
- onCreateEditor: handleCreateEditor,
14241
- basicSetup: { lineNumbers: true, drawSelection: false }
14242
- }
14243
- ) })
14244
- ]
14245
- }
14246
- );
14247
- };
14248
- var useScrollSync = () => {
14249
- const scrollersRef = useRef([]);
14250
- const followersRef = useRef(/* @__PURE__ */ new Map());
14251
- const isSyncingRef = useRef(false);
14252
- const scrollerCallbacksRef = useRef(/* @__PURE__ */ new Map());
14253
- const followerCallbacksRef = useRef(/* @__PURE__ */ new Map());
14254
- const updateFollowers = useCallback(() => {
14255
- for (const [, { paneIndex, el }] of followersRef.current) {
14256
- const scroller = scrollersRef.current[paneIndex];
14257
- if (!scroller) continue;
14258
- el.style.transform = `translateY(-${scroller.scrollTop}px)`;
14259
- }
14260
- }, []);
14261
- const handleScroll = useCallback(
14262
- (e) => {
14263
- if (isSyncingRef.current) return;
14264
- isSyncingRef.current = true;
14265
- const sourceScrollTop = e.target.scrollTop;
14266
- for (const scroller of scrollersRef.current) {
14267
- if (!scroller || scroller === e.target) continue;
14268
- const targetMax = Math.max(0, scroller.scrollHeight - scroller.clientHeight);
14269
- scroller.scrollTop = Math.min(sourceScrollTop, targetMax);
14270
- }
14271
- updateFollowers();
14272
- isSyncingRef.current = false;
14273
- },
14274
- [updateFollowers]
14275
- );
14276
- const registerScroller = useCallback(
14277
- (index) => {
14278
- const existing = scrollerCallbacksRef.current.get(index);
14279
- if (existing) return existing;
14280
- const callback = (el) => {
14281
- const prev = scrollersRef.current[index];
14282
- if (prev === el) return;
14283
- prev?.removeEventListener("scroll", handleScroll);
14284
- scrollersRef.current[index] = el;
14285
- el?.addEventListener("scroll", handleScroll, { passive: true });
14286
- };
14287
- scrollerCallbacksRef.current.set(index, callback);
14288
- return callback;
14289
- },
14290
- [handleScroll]
14291
- );
14292
- const registerFollower = useCallback((paneIndex, key) => {
14293
- const existing = followerCallbacksRef.current.get(key);
14294
- if (existing) return existing;
14295
- const callback = (el) => {
14296
- if (el) {
14297
- followersRef.current.set(key, { paneIndex, el });
14298
- } else {
14299
- followersRef.current.delete(key);
14300
- }
14301
- };
14302
- followerCallbacksRef.current.set(key, callback);
14303
- return callback;
14304
- }, []);
14305
- return { registerScroller, registerFollower };
14306
- };
14307
- var EMPTY_LINES2 = /* @__PURE__ */ new Set();
14308
- var EMPTY_CLASSIFICATION2 = /* @__PURE__ */ new Map();
14309
- var MergeEditor = ({
14310
- mergeValue,
14311
- handleMergeChange,
14312
- leftText,
14313
- rightText,
14314
- leftConflicts,
14315
- rightConflicts,
14316
- leftHighlightedLines,
14317
- rightHighlightedLines,
14318
- leftClassification,
14319
- rightClassification,
14320
- mergeHighlightedLines,
14321
- mergeClassification,
14322
- acceptLeft,
14323
- acceptRight,
14324
- dismissLeft,
14325
- dismissRight,
14326
- leftHeader,
14327
- middleHeader,
14328
- middleHeaderClassName,
14329
- middleClassName,
14330
- rightHeader,
14331
- className,
14332
- argo,
14333
- leftDeleted = false,
14334
- rightDeleted = false
14335
- }) => {
14336
- const { registerScroller, registerFollower } = useScrollSync();
14337
- const anySideDeleted = leftDeleted || rightDeleted;
14338
- return /* @__PURE__ */ jsxs(
14339
- "div",
14340
- {
14341
- className: cn(
14342
- "tw-flex tw-h-full tw-min-h-0 tw-overflow-hidden tw-bg-background tw-gap-3",
14343
- className
14344
- ),
14345
- children: [
14346
- /* @__PURE__ */ jsx(
14347
- MergePane,
14348
- {
14349
- value: leftText,
14350
- highlightedLines: leftHighlightedLines,
14351
- lineClassification: leftClassification,
14352
- readOnly: true,
14353
- header: leftHeader,
14354
- className: "tw-rounded-r-lg tw-border tw-border-border",
14355
- onScrollDOMReady: registerScroller(0),
14356
- deleted: leftDeleted
14357
- }
14358
- ),
14359
- /* @__PURE__ */ jsx(
14360
- AcceptControls,
14361
- {
14362
- conflicts: leftDeleted ? [] : leftConflicts,
14363
- side: "left",
14364
- onAccept: acceptLeft,
14365
- onDismiss: dismissLeft,
14366
- contentRef: registerFollower(0, "left-controls"),
14367
- argo
14368
- }
14369
- ),
14370
- /* @__PURE__ */ jsx(
14371
- MergePane,
14372
- {
14373
- value: mergeValue,
14374
- highlightedLines: anySideDeleted ? EMPTY_LINES2 : mergeHighlightedLines,
14375
- lineClassification: anySideDeleted ? EMPTY_CLASSIFICATION2 : mergeClassification,
14376
- onChange: handleMergeChange,
14377
- header: middleHeader,
14378
- headerClassName: middleHeaderClassName,
14379
- className: cn("tw-border tw-border-border tw-rounded-lg", middleClassName),
14380
- onScrollDOMReady: registerScroller(1)
14381
- }
14382
- ),
14383
- /* @__PURE__ */ jsx(
14384
- AcceptControls,
14385
- {
14386
- conflicts: rightDeleted ? [] : rightConflicts,
14387
- side: "right",
14388
- onAccept: acceptRight,
14389
- onDismiss: dismissRight,
14390
- contentRef: registerFollower(2, "right-controls"),
14391
- argo
14392
- }
14393
- ),
14394
- /* @__PURE__ */ jsx(
14395
- MergePane,
14396
- {
14397
- value: rightText,
14398
- highlightedLines: rightHighlightedLines,
14399
- lineClassification: rightClassification,
14400
- readOnly: true,
14401
- header: rightHeader,
14402
- className: "tw-rounded-l-lg tw-border tw-border-border",
14403
- onScrollDOMReady: registerScroller(2),
14404
- deleted: rightDeleted
14405
- }
14406
- )
14407
- ]
14408
- }
14409
- );
14410
- };
14411
13981
  var PaneHeader = ({ label, sublabel }) => /* @__PURE__ */ jsxs("div", { children: [
14412
13982
  /* @__PURE__ */ jsx("p", { className: "tw-m-0 tw-text-sm tw-font-medium tw-text-foreground", children: label }),
14413
13983
  sublabel && /* @__PURE__ */ jsx("p", { className: "tw-m-0 tw-text-xs tw-text-muted-foreground", children: sublabel })
@@ -14437,6 +14007,17 @@ var ConflictStatusIndicator = ({ remainingConflicts, remainingSafeChanges }) =>
14437
14007
  }
14438
14008
  );
14439
14009
  };
14010
+
14011
+ // src/components/MergeEditor/constants.ts
14012
+ var CHUNK_TYPE = {
14013
+ UNCHANGED: "unchanged",
14014
+ ADDED: "added",
14015
+ REMOVED: "removed"
14016
+ };
14017
+ var CHANGE_CLASS = {
14018
+ SAFE: "safe",
14019
+ CONFLICT: "conflict"
14020
+ };
14440
14021
  var computeDiffChunks = (oldText, newText) => {
14441
14022
  const changes = diffLines(oldText, newText);
14442
14023
  const chunks = [];
@@ -15049,6 +14630,7 @@ var SelectField = ({
15049
14630
  required,
15050
14631
  help,
15051
14632
  className,
14633
+ items,
15052
14634
  options,
15053
14635
  placeholder,
15054
14636
  triggerClassName,
@@ -15058,6 +14640,7 @@ var SelectField = ({
15058
14640
  ...rootProps
15059
14641
  }) => {
15060
14642
  const field = useFieldContext();
14643
+ const resolved = items ?? options ?? [];
15061
14644
  return /* @__PURE__ */ jsx(FieldShell, { field, label, required, help, className, children: /* @__PURE__ */ jsxs(
15062
14645
  Select.Root,
15063
14646
  {
@@ -15079,7 +14662,7 @@ var SelectField = ({
15079
14662
  onBlur: field.handleBlur
15080
14663
  }
15081
14664
  ),
15082
- /* @__PURE__ */ jsx(Select.Content, { variant: variant === "argo" ? "argo" : "default", children: options.map((option) => /* @__PURE__ */ jsx(Select.Item, { value: option.value, children: option.label }, option.value)) })
14665
+ /* @__PURE__ */ jsx(Select.Content, { variant: variant === "argo" ? "argo" : "default", children: resolved.map((option) => /* @__PURE__ */ jsx(Select.Item, { value: option.value, children: option.label }, option.value)) })
15083
14666
  ]
15084
14667
  }
15085
14668
  ) });
@@ -15404,752 +14987,7 @@ var ZoomableSvg = ({ html, copyText, className }) => {
15404
14987
  }
15405
14988
  );
15406
14989
  };
15407
- var ButtonToolbar = ({ value, children }) => {
15408
- if (!value && !children) return null;
15409
- 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: [
15410
- !!value && /* @__PURE__ */ jsx(ClipboardButton, { size: "icon-sm", variant: "invisible", text: value }),
15411
- children
15412
- ] });
15413
- };
15414
- var baseThemeStyles = {
15415
- "*": { lineHeight: "20px" },
15416
- "*::selection": {
15417
- backgroundColor: colors3.secondary[500],
15418
- color: `${colors3.white} !important`
15419
- },
15420
- '&.cm-editor:has(.cm-content[contenteditable="false"])': { backgroundColor: colors3.neutral[150] },
15421
- '&.cm-editor:has(.cm-content[contenteditable="false"]) .cm-gutters': {
15422
- backgroundColor: colors3.neutral[200]
15423
- },
15424
- "&.cm-editor .cm-scroller": { overflowAnchor: "none" },
15425
- "&.cm-editor, &.cm-editor .cm-scroller": {
15426
- minHeight: "100%",
15427
- flexGrow: 1,
15428
- alignItems: "stretch !important",
15429
- outline: "none"
15430
- },
15431
- ".cm-gutter.cm-foldGutter": { display: "none !important" },
15432
- ".cm-gutter.cm-lineNumbers": { paddingLeft: "20px", paddingRight: "6px" },
15433
- ".cm-gutters": { height: "auto" },
15434
- // tokens overrides
15435
- ".cm-line .tok-string": { color: colors3.warning[700] },
15436
- // merge (diff) view
15437
- '&[class*="cm-merge-"] .cm-deletedLine': { backgroundColor: colors3.error[100] },
15438
- '&[class*="cm-merge-"] .cm-changedLine': { backgroundColor: colors3.primary[100] },
15439
- '&[class*="cm-merge-"] .cm-deletedLineGutter': { backgroundColor: colors3.error[200] },
15440
- '&[class*="cm-merge-"] .cm-changedLineGutter': { backgroundColor: colors3.primary[200] },
15441
- '&[class*="cm-merge-"] .cm-deletedText': { background: colors3.error[200] },
15442
- '&[class*="cm-merge-"] .cm-changedText': { background: colors3.primary[200] },
15443
- '&[class*="cm-merge-"]': {
15444
- backgroundColor: `${colors3.white} !important`
15445
- },
15446
- '&[class*="cm-merge-"] .cm-gutters': {
15447
- backgroundColor: `${colors3.white} !important`
15448
- },
15449
- ".cm-changeGutter": { position: "absolute", zIndex: -1, width: "100%", paddingLeft: 0 },
15450
- '&[class*="cm-merge-"] .cm-changedLine,&[class*="cm-merge-"] .cm-line, &[class*="cm-merge-"] .cm-deletedChunk': { paddingLeft: 0 }
15451
- };
15452
- var BASIS_SETUP = { drawSelection: false };
15453
- var customTheme = githubLightInit({
15454
- settings: {
15455
- fontFamily: `'SFMono-Regular', 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New'`,
15456
- background: colors3.neutral[50],
15457
- gutterBackground: colors3.neutral[100],
15458
- gutterBorder: "transparent",
15459
- lineHighlight: "transparent",
15460
- selection: colors3.secondary[500]
15461
- }
15462
- });
15463
- var getLanguageMode = (mode) => {
15464
- switch (mode) {
15465
- case "text/x-python":
15466
- return python();
15467
- case "text/x-sql":
15468
- return sql({ upperCaseKeywords: true });
15469
- case "text/x-sfsql":
15470
- return StreamLanguage.define(sfsql);
15471
- case "text/x-plsql":
15472
- return sql({ upperCaseKeywords: true, dialect: PLSQL });
15473
- case "text/x-rsrc":
15474
- return StreamLanguage.define(r);
15475
- case "text/x-sh":
15476
- return StreamLanguage.define(shell);
15477
- case "text/javascript":
15478
- return javascript({ jsx: true });
15479
- case "text/typescript":
15480
- return javascript({ jsx: true, typescript: true });
15481
- default:
15482
- return json();
15483
- }
15484
- };
15485
- var ToggleComponentHelp = () => /* @__PURE__ */ jsxs("div", { children: [
15486
- "Use ",
15487
- /* @__PURE__ */ jsx(Kbd, { children: "Ctrl+/" }),
15488
- " or ",
15489
- /* @__PURE__ */ jsx(Kbd, { children: "Command+/" }),
15490
- " to toggle comments."
15491
- ] });
15492
- var emptyArray = [];
15493
- var emptyObject = {};
15494
- var CodeEditor = ({
15495
- value,
15496
- previousValue,
15497
- onChange,
15498
- mode = "application/json",
15499
- placeholder: placeholder$1 = "",
15500
- readOnly = false,
15501
- autocompletions = emptyArray,
15502
- extraKeys = emptyObject,
15503
- withToggleCommentHint = false,
15504
- withAutofocus = false,
15505
- withLineNumbers = true,
15506
- withLineWrapping = true,
15507
- withCollapseUnchanged = false,
15508
- withCopyButton = true,
15509
- completeAny = false,
15510
- help = null,
15511
- helpPostfix = null,
15512
- renderAdditionalButtons,
15513
- className
15514
- }) => {
15515
- const commonExtensions = useMemo(() => {
15516
- return [
15517
- getLanguageMode(mode),
15518
- mode === "application/json" && linter(jsonParseLinter()),
15519
- withLineWrapping ? EditorView.lineWrapping : [],
15520
- EditorState.languageData.of(() => [
15521
- { autocomplete: completeAny ? completeAnyWord : autocompletions }
15522
- ]),
15523
- keymap.of(
15524
- Object.entries(extraKeys).map(([key, run]) => ({
15525
- key,
15526
- run: () => {
15527
- if (typeof run === "string") return run;
15528
- run();
15529
- return true;
15530
- }
15531
- }))
15532
- ),
15533
- autocompletion({ activateOnTyping: completeAny }),
15534
- EditorView.theme(baseThemeStyles)
15535
- ].filter(Boolean);
15536
- }, [autocompletions, completeAny, extraKeys, mode, withLineWrapping]);
15537
- const extensions = useMemo(() => {
15538
- return [
15539
- ...commonExtensions,
15540
- placeholder(placeholder$1),
15541
- EditorView.editable.of(!readOnly),
15542
- EditorState.readOnly.of(readOnly),
15543
- previousValue ? unifiedMergeView({
15544
- original: previousValue,
15545
- mergeControls: false,
15546
- highlightChanges: false,
15547
- collapseUnchanged: withCollapseUnchanged ? {} : void 0
15548
- }) : []
15549
- ];
15550
- }, [commonExtensions, placeholder$1, readOnly, previousValue, withCollapseUnchanged]);
15551
- const config = useMemo(() => {
15552
- return {
15553
- ...BASIS_SETUP,
15554
- lineNumbers: withLineNumbers
15555
- };
15556
- }, [withLineNumbers]);
15557
- return (
15558
- // oxlint-disable-next-line jsx-a11y/no-static-element-interactions
15559
- /* @__PURE__ */ jsxs(
15560
- "div",
15561
- {
15562
- className: cn(
15563
- "tw-relative tw-flex tw-min-h-0 tw-flex-col [&_.cm-mergeViewEditor]:tw-overflow-visible [&_.cm-mergeViewEditors]:tw-h-full [&_.cm-mergeView]:tw-h-full [&_>div]:tw-h-full [&_>div]:tw-overflow-auto [&_>div]:tw-bg-background",
15564
- { "tw-mt-5": !!renderAdditionalButtons },
15565
- className
15566
- ),
15567
- onKeyDown: (event) => {
15568
- if (event.key === keyCodes.ESCAPE) {
15569
- event.stopPropagation();
15570
- }
15571
- },
15572
- children: [
15573
- (withCopyButton || renderAdditionalButtons) && /* @__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: renderAdditionalButtons?.(value) }) }) }),
15574
- /* @__PURE__ */ jsx(
15575
- CodeMirror,
15576
- {
15577
- theme: customTheme,
15578
- value,
15579
- onChange,
15580
- extensions,
15581
- autoFocus: withAutofocus,
15582
- basicSetup: config
15583
- }
15584
- ),
15585
- !readOnly && (withToggleCommentHint || help || helpPostfix) && /* @__PURE__ */ jsxs(HelpBlock, { className: "tw-mt-2 tw-flex tw-flex-wrap tw-gap-1", children: [
15586
- help,
15587
- withToggleCommentHint ? /* @__PURE__ */ jsx(ToggleComponentHelp, {}) : null,
15588
- helpPostfix
15589
- ] })
15590
- ]
15591
- }
15592
- )
15593
- );
15594
- };
15595
- var activeQueryFirstLine = Decoration.line({ class: "cm-active-query cm-active-query-first" });
15596
- var activeQueryMiddleLine = Decoration.line({ class: "cm-active-query" });
15597
- var activeQueryLastLine = Decoration.line({ class: "cm-active-query cm-active-query-last" });
15598
- var activeQuerySingleLine = Decoration.line({
15599
- class: "cm-active-query cm-active-query-first cm-active-query-last"
15600
- });
15601
- var findActiveQueryRange = (doc, cursorPos, boundaries) => {
15602
- if (boundaries.length === 0) return null;
15603
- let match = boundaries[boundaries.length - 1];
15604
- for (const boundary of boundaries) {
15605
- if (cursorPos <= boundary.to) {
15606
- match = boundary;
15607
- break;
15608
- }
15609
- }
15610
- if (!match) return null;
15611
- const queryText = doc.slice(match.from, match.to);
15612
- const leadingWhitespace = queryText.length - queryText.trimStart().length;
15613
- const trailingWhitespace = queryText.length - queryText.trimEnd().length;
15614
- const trimmedStart = match.from + leadingWhitespace;
15615
- const trimmedEnd = match.to - trailingWhitespace;
15616
- if (trimmedStart >= trimmedEnd) return null;
15617
- return { from: trimmedStart, to: trimmedEnd };
15618
- };
15619
- var computeBoundaries = (queries) => {
15620
- const boundaries = [];
15621
- let offset = 0;
15622
- for (const query of queries) {
15623
- boundaries.push({ from: offset, to: offset + query.length });
15624
- offset += query.length;
15625
- }
15626
- return boundaries;
15627
- };
15628
- var mapBoundariesThroughChanges = (boundaries, changes) => {
15629
- const prevLen = changes.length;
15630
- const mapped = [];
15631
- for (const b of boundaries) {
15632
- const from = changes.mapPos(Math.max(0, Math.min(b.from, prevLen)), -1);
15633
- const to = changes.mapPos(Math.max(0, Math.min(b.to, prevLen)), 1);
15634
- if (from < to) mapped.push({ from, to });
15635
- }
15636
- return mapped;
15637
- };
15638
- var buildDecorations = (view, range) => {
15639
- const startLine = view.state.doc.lineAt(range.from).number;
15640
- const endLine = view.state.doc.lineAt(range.to).number;
15641
- const decorations = [];
15642
- for (let lineNum = startLine; lineNum <= endLine; lineNum++) {
15643
- const lineStart = view.state.doc.line(lineNum).from;
15644
- if (startLine === endLine) {
15645
- decorations.push(activeQuerySingleLine.range(lineStart));
15646
- } else if (lineNum === startLine) {
15647
- decorations.push(activeQueryFirstLine.range(lineStart));
15648
- } else if (lineNum === endLine) {
15649
- decorations.push(activeQueryLastLine.range(lineStart));
15650
- } else {
15651
- decorations.push(activeQueryMiddleLine.range(lineStart));
15652
- }
15653
- }
15654
- return Decoration.set(decorations);
15655
- };
15656
- var activeQueryHighlight = (splitQueries) => {
15657
- return [
15658
- ViewPlugin.fromClass(
15659
- class {
15660
- decorations = Decoration.none;
15661
- debounceTimer = null;
15662
- seq = 0;
15663
- cachedDoc = "";
15664
- cachedBoundaries = [];
15665
- destroyed = false;
15666
- constructor(view) {
15667
- this.scheduleDocParse(view);
15668
- }
15669
- update(update) {
15670
- if (update.focusChanged && !update.view.hasFocus) {
15671
- this.decorations = Decoration.none;
15672
- return;
15673
- }
15674
- if (update.docChanged) {
15675
- if (this.cachedBoundaries.length > 0) {
15676
- this.cachedBoundaries = mapBoundariesThroughChanges(
15677
- this.cachedBoundaries,
15678
- update.changes
15679
- );
15680
- this.cachedDoc = update.state.doc.toString();
15681
- this.updateFromCache(update.view);
15682
- }
15683
- this.scheduleDocParse(update.view);
15684
- } else if (update.selectionSet || update.focusChanged && update.view.hasFocus) {
15685
- this.updateFromCache(update.view);
15686
- }
15687
- }
15688
- destroy() {
15689
- this.destroyed = true;
15690
- if (this.debounceTimer) clearTimeout(this.debounceTimer);
15691
- }
15692
- /**
15693
- * Update decorations using cached query boundaries.
15694
- * Only mutates this.decorations — does NOT call view.dispatch().
15695
- * When called from update() (sync), CodeMirror picks up the new
15696
- * decorations via the accessor. When called from the async
15697
- * scheduleDocParse callback, the caller must dispatch separately.
15698
- */
15699
- updateFromCache(view) {
15700
- if (!view.hasFocus) {
15701
- this.decorations = Decoration.none;
15702
- return;
15703
- }
15704
- const { main } = view.state.selection;
15705
- if (main.from !== main.to) {
15706
- this.decorations = Decoration.none;
15707
- return;
15708
- }
15709
- const doc = view.state.doc.toString();
15710
- if (doc !== this.cachedDoc) return;
15711
- if (this.cachedBoundaries.length === 0) {
15712
- this.decorations = Decoration.none;
15713
- return;
15714
- }
15715
- const range = findActiveQueryRange(doc, main.head, this.cachedBoundaries);
15716
- this.decorations = range ? buildDecorations(view, range) : Decoration.none;
15717
- }
15718
- /** Parse queries async (debounced) and update decorations. */
15719
- scheduleDocParse(view) {
15720
- if (this.debounceTimer) clearTimeout(this.debounceTimer);
15721
- this.debounceTimer = setTimeout(async () => {
15722
- const seq = ++this.seq;
15723
- const doc = view.state.doc.toString();
15724
- if (!doc.trim()) {
15725
- this.cachedDoc = doc;
15726
- this.cachedBoundaries = [];
15727
- if (this.decorations !== Decoration.none) {
15728
- this.decorations = Decoration.none;
15729
- if (!this.destroyed) view.dispatch();
15730
- }
15731
- return;
15732
- }
15733
- let queries;
15734
- try {
15735
- queries = await splitQueries(doc);
15736
- } catch {
15737
- return;
15738
- }
15739
- if (this.destroyed || seq !== this.seq) return;
15740
- this.cachedDoc = doc;
15741
- this.cachedBoundaries = computeBoundaries(queries);
15742
- this.updateFromCache(view);
15743
- if (!this.destroyed) view.dispatch();
15744
- }, 100);
15745
- }
15746
- },
15747
- { decorations: (v) => v.decorations }
15748
- ),
15749
- EditorView.baseTheme({
15750
- ".cm-active-query": {
15751
- boxShadow: `inset -1px 0 0 0 ${colors3.secondary[300]}, inset 1px 0 0 0 ${colors3.secondary[300]}`,
15752
- marginRight: "8px"
15753
- },
15754
- ".cm-active-query-first": {
15755
- boxShadow: `inset -1px 0 0 0 ${colors3.secondary[300]}, inset 1px 0 0 0 ${colors3.secondary[300]}, inset 0 1px 0 0 ${colors3.secondary[300]}`,
15756
- borderRadius: "4px 4px 0 0"
15757
- },
15758
- ".cm-active-query-last": {
15759
- boxShadow: `inset -1px 0 0 0 ${colors3.secondary[300]}, inset 1px 0 0 0 ${colors3.secondary[300]}, inset 0 -1px 0 0 ${colors3.secondary[300]}`,
15760
- borderRadius: "0 0 4px 4px"
15761
- },
15762
- ".cm-active-query-first.cm-active-query-last": {
15763
- boxShadow: `inset 0 0 0 1px ${colors3.secondary[300]}`,
15764
- borderRadius: "4px"
15765
- }
15766
- })
15767
- ];
15768
- };
15769
-
15770
- // src/components/CodeEditor/highlighting.ts
15771
- var HighlightMarker = class extends GutterMarker {
15772
- toDOM() {
15773
- const marker = document.createElement("div");
15774
- marker.className = "cm-highlight-marker";
15775
- return marker;
15776
- }
15777
- };
15778
- var highlightMarker = new HighlightMarker();
15779
- var forEachLineInRange = (doc, from, to, callback) => {
15780
- const results = [];
15781
- const fromLine = Math.max(1, from + 1);
15782
- const toLine = Math.min(doc.lines, to + 1);
15783
- for (let i = fromLine; i <= toLine; i++) {
15784
- const line = doc.line(i);
15785
- results.push(callback(line.from));
15786
- }
15787
- return results;
15788
- };
15789
- var setHighlightedLinesEffect = StateEffect.define();
15790
- var highlightedLinesField = StateField.define({
15791
- create() {
15792
- return null;
15793
- },
15794
- update(value, transaction) {
15795
- for (const effect of transaction.effects) {
15796
- if (effect.is(setHighlightedLinesEffect)) {
15797
- return effect.value;
15798
- }
15799
- }
15800
- return value;
15801
- }
15802
- });
15803
- var highlightGutter = gutter({
15804
- class: "cm-highlight-gutter",
15805
- markers: (view) => {
15806
- const highlightInfo = view.state.field(highlightedLinesField, false);
15807
- if (!highlightInfo) {
15808
- return RangeSet.empty;
15809
- }
15810
- const markers = forEachLineInRange(
15811
- view.state.doc,
15812
- highlightInfo.from,
15813
- highlightInfo.to,
15814
- (lineFrom) => highlightMarker.range(lineFrom)
15815
- );
15816
- return RangeSet.of(markers);
15817
- }
15818
- });
15819
- var errorLineDecorations = StateField.define({
15820
- create() {
15821
- return Decoration.none;
15822
- },
15823
- update(decorations, transaction) {
15824
- decorations = decorations.map(transaction.changes);
15825
- for (const effect of transaction.effects) {
15826
- if (!effect.is(setHighlightedLinesEffect)) {
15827
- continue;
15828
- }
15829
- if (!effect.value || !effect.value.error) {
15830
- return Decoration.none;
15831
- }
15832
- const decorationArray = forEachLineInRange(
15833
- transaction.state.doc,
15834
- effect.value.error.from,
15835
- effect.value.error.to,
15836
- (lineFrom) => Decoration.line({ class: "cm-error-line" }).range(lineFrom)
15837
- );
15838
- return Decoration.set(decorationArray);
15839
- }
15840
- return decorations;
15841
- },
15842
- provide: (f) => EditorView.decorations.from(f)
15843
- });
15844
- var processingLineDecorations = StateField.define({
15845
- create() {
15846
- return Decoration.none;
15847
- },
15848
- update(decorations, transaction) {
15849
- decorations = decorations.map(transaction.changes);
15850
- for (const effect of transaction.effects) {
15851
- if (!effect.is(setHighlightedLinesEffect)) {
15852
- continue;
15853
- }
15854
- if (!effect.value || !effect.value.processing) {
15855
- return Decoration.none;
15856
- }
15857
- const decorationArray = forEachLineInRange(
15858
- transaction.state.doc,
15859
- effect.value.processing.from,
15860
- effect.value.processing.to,
15861
- (lineFrom) => Decoration.line({ class: "cm-processing-line" }).range(lineFrom)
15862
- );
15863
- return Decoration.set(decorationArray);
15864
- }
15865
- return decorations;
15866
- },
15867
- provide: (f) => EditorView.decorations.from(f)
15868
- });
15869
- var highlightedLinesTheme = EditorView.baseTheme({
15870
- ".cm-highlight-gutter": {
15871
- width: "2px",
15872
- marginRight: "2px"
15873
- },
15874
- ".cm-highlight-marker": {
15875
- width: "2px",
15876
- height: "100%",
15877
- backgroundColor: colors3.secondary[500]
15878
- },
15879
- ".cm-error-line": {
15880
- backgroundColor: `${colors3.error[100]} !important`
15881
- },
15882
- ".cm-processing-line": {
15883
- backgroundColor: `${colors3.secondary[100]} !important`
15884
- }
15885
- });
15886
- function highlightingExtension(queryParser) {
15887
- return [
15888
- highlightedLinesField,
15889
- highlightGutter,
15890
- errorLineDecorations,
15891
- processingLineDecorations,
15892
- highlightedLinesTheme,
15893
- ...queryParser ? activeQueryHighlight(queryParser) : []
15894
- ];
15895
- }
15896
- function updateHighlighting(view, lines) {
15897
- view.dispatch({ effects: setHighlightedLinesEffect.of(lines ?? null) });
15898
- }
15899
- var setSearchEffect = StateEffect.define();
15900
- function findMatches(doc, query) {
15901
- if (!query) return [];
15902
- const text = doc.toString();
15903
- try {
15904
- const regex = new RegExp(escapeStringRegexp(query), "gi");
15905
- return Array.from(text.matchAll(regex)).map((match, index) => {
15906
- const from = match.index;
15907
- const to = from + match[0].length;
15908
- return { from, to, text: match[0], localIndex: index };
15909
- });
15910
- } catch (e) {
15911
- console.warn("Invalid search regex:", e);
15912
- return [];
15913
- }
15914
- }
15915
- function createDecorations(matches, selectedLocalIndex) {
15916
- const decorations = matches.map((match) => {
15917
- const isSelected = match.localIndex === selectedLocalIndex;
15918
- const decoration = Decoration.mark({
15919
- class: isSelected ? "cm-searchMatch-selected" : "cm-searchMatch"
15920
- });
15921
- return decoration.range(match.from, match.to);
15922
- });
15923
- return Decoration.set(decorations, true);
15924
- }
15925
- var searchField = StateField.define({
15926
- create() {
15927
- return {
15928
- query: "",
15929
- selectedMatchIndex: void 0,
15930
- matches: [],
15931
- decorations: Decoration.none
15932
- };
15933
- },
15934
- update(state, tr) {
15935
- let newState = state;
15936
- for (const effect of tr.effects) {
15937
- if (!effect.is(setSearchEffect)) {
15938
- continue;
15939
- }
15940
- const { query, selectedMatchIndex } = effect.value;
15941
- const matches = findMatches(tr.state.doc, query);
15942
- const decorations = createDecorations(matches, selectedMatchIndex);
15943
- newState = {
15944
- query,
15945
- selectedMatchIndex,
15946
- matches,
15947
- decorations
15948
- };
15949
- }
15950
- if (tr.docChanged && newState.query) {
15951
- const matches = findMatches(tr.state.doc, newState.query);
15952
- const decorations = createDecorations(matches, newState.selectedMatchIndex);
15953
- newState = {
15954
- ...newState,
15955
- matches,
15956
- decorations
15957
- };
15958
- }
15959
- return newState;
15960
- },
15961
- provide: (field) => EditorView.decorations.from(field, (state) => state.decorations)
15962
- });
15963
- var searchViewPlugin = ViewPlugin.fromClass(
15964
- class {
15965
- lastSelectedIndex;
15966
- update(update) {
15967
- const state = update.state.field(searchField);
15968
- if (state.selectedMatchIndex !== void 0 && state.selectedMatchIndex !== this.lastSelectedIndex) {
15969
- const match = state.matches[state.selectedMatchIndex];
15970
- if (match) {
15971
- requestAnimationFrame(() => {
15972
- update.view.dispatch({
15973
- effects: EditorView.scrollIntoView(match.from, { y: "center" })
15974
- });
15975
- });
15976
- }
15977
- this.lastSelectedIndex = state.selectedMatchIndex;
15978
- }
15979
- if (state.selectedMatchIndex === void 0) {
15980
- this.lastSelectedIndex = void 0;
15981
- }
15982
- }
15983
- }
15984
- );
15985
- var searchTheme = EditorView.baseTheme({
15986
- ".cm-searchMatch": {
15987
- backgroundColor: colors3.secondary[100]
15988
- },
15989
- ".cm-searchMatch > span": {
15990
- color: `${colors3.secondary[600]} !important`
15991
- },
15992
- ".cm-searchMatch-selected": {
15993
- backgroundColor: colors3.secondary[600]
15994
- },
15995
- ".cm-searchMatch-selected > span": {
15996
- color: `${colors3.white} !important`
15997
- }
15998
- });
15999
- function searchExtension() {
16000
- return [searchField, searchViewPlugin, searchTheme];
16001
- }
16002
- function updateSearch(view, query, selectedMatchIndex) {
16003
- view.dispatch({ effects: setSearchEffect.of({ query, selectedMatchIndex }) });
16004
- }
16005
- var BASIS_SETUP2 = {
16006
- drawSelection: false,
16007
- defaultKeymap: false,
16008
- completionKeymap: false,
16009
- searchKeymap: false
16010
- };
16011
- var CUSTOM_KEYMAP = [
16012
- {
16013
- key: "Escape",
16014
- stopPropagation: true,
16015
- run: (view) => {
16016
- view.contentDOM.blur();
16017
- return true;
16018
- }
16019
- }
16020
- ];
16021
- var theme = {
16022
- ...baseThemeStyles,
16023
- "&.cm-editor": {
16024
- border: "solid 1px transparent",
16025
- background: colors3.white,
16026
- borderRadius: "8px",
16027
- paddingTop: "8px",
16028
- paddingBottom: "8px"
16029
- },
16030
- '&.cm-editor:has(.cm-content[contenteditable="true"]):hover': {
16031
- borderColor: colors3.secondary[500]
16032
- },
16033
- '&.cm-editor:has(.cm-content[contenteditable="true"]):focus-within': {
16034
- borderColor: colors3.secondary[500],
16035
- boxShadow: `0 0 0 4px ${colors3.secondary[200]}`
16036
- },
16037
- "&.cm-editor .cm-scroller": { overflowAnchor: "none" },
16038
- "&.cm-editor :is(.cm-gutters,.cm-scroller)": { background: colors3.white },
16039
- '&.cm-editor:has(.cm-content[contenteditable="false"])': { background: colors3.neutral[100] },
16040
- '&.cm-editor:has(.cm-content[contenteditable="false"]) :is(.cm-scroller,.cm-gutters)': {
16041
- background: colors3.neutral[100]
16042
- }
16043
- };
16044
- var SqlEditor = ({
16045
- value,
16046
- onChange,
16047
- onSelectionChange,
16048
- onCreateEditor,
16049
- onDestroyEditor,
16050
- onBlurEditor,
16051
- onFocusEditor,
16052
- placeholder = "",
16053
- searchQuery = "",
16054
- searchMatchIndex,
16055
- readOnly = false,
16056
- extraKeys,
16057
- queryParser,
16058
- autoFocus = false,
16059
- lineNumbers = true,
16060
- className,
16061
- schema,
16062
- variables,
16063
- defaultDatabase,
16064
- defaultSchema,
16065
- highlightLines,
16066
- dialect
16067
- }) => {
16068
- const editorRef = useRef(null);
16069
- const extensions = useMemo(() => {
16070
- const baseKeymap = [...defaultKeymap, ...CUSTOM_KEYMAP];
16071
- return [
16072
- EditorView$1.lineWrapping,
16073
- keymap$1.of(extraKeys ? [...extraKeys, ...baseKeymap] : baseKeymap),
16074
- ...installExtensions({ schema, defaultDatabase, defaultSchema, variables, dialect }),
16075
- searchExtension(),
16076
- highlightingExtension(queryParser),
16077
- EditorView$1.theme(theme),
16078
- onBlurEditor ? EditorView$1.domEventHandlers({ blur: (_, view) => onBlurEditor(view) }) : [],
16079
- onFocusEditor ? EditorView$1.domEventHandlers({ focus: (_, view) => onFocusEditor(view) }) : []
16080
- ];
16081
- }, [
16082
- extraKeys,
16083
- queryParser,
16084
- schema,
16085
- defaultDatabase,
16086
- defaultSchema,
16087
- variables,
16088
- dialect,
16089
- onBlurEditor,
16090
- onFocusEditor
16091
- ]);
16092
- const defaultSetup = useMemo(() => {
16093
- return { ...BASIS_SETUP2, lineNumbers };
16094
- }, [lineNumbers]);
16095
- useEffect(() => {
16096
- if (editorRef.current?.view) {
16097
- updateHighlighting(editorRef.current.view, highlightLines);
16098
- }
16099
- }, [highlightLines]);
16100
- useEffect(() => {
16101
- if (editorRef.current?.view) {
16102
- updateSearch(editorRef.current.view, searchQuery, searchMatchIndex);
16103
- }
16104
- }, [searchQuery, searchMatchIndex]);
16105
- useEffect(() => {
16106
- if (!onDestroyEditor) return;
16107
- return () => {
16108
- onDestroyEditor();
16109
- };
16110
- }, [onDestroyEditor]);
16111
- const handleOnCreate = useCallback(
16112
- (view, state) => {
16113
- onCreateEditor?.(view, state);
16114
- if (highlightLines) {
16115
- updateHighlighting(view, highlightLines);
16116
- }
16117
- if (searchQuery) {
16118
- updateSearch(view, searchQuery, searchMatchIndex);
16119
- }
16120
- },
16121
- [onCreateEditor, highlightLines, searchQuery, searchMatchIndex]
16122
- );
16123
- const handleOnUpdate = useCallback(
16124
- (update) => {
16125
- if (update.selectionSet) {
16126
- const { main } = update.state.selection;
16127
- const text = update.state.sliceDoc(main.from, main.to);
16128
- onSelectionChange?.(text);
16129
- }
16130
- },
16131
- [onSelectionChange]
16132
- );
16133
- return /* @__PURE__ */ jsx(
16134
- CodeMirror,
16135
- {
16136
- ref: editorRef,
16137
- theme: customTheme,
16138
- extensions,
16139
- value,
16140
- onChange,
16141
- onUpdate: handleOnUpdate,
16142
- onCreateEditor: handleOnCreate,
16143
- autoFocus,
16144
- placeholder,
16145
- className,
16146
- readOnly,
16147
- editable: !readOnly,
16148
- basicSetup: defaultSetup
16149
- }
16150
- );
16151
- };
16152
14990
 
16153
- export { Alert, AnswerSummary, AppShell, AutoSaveTextarea, Avatar, Badge, Breadcrumb, Button, ButtonGroup, ButtonInline, Calendar, Card, Checkbox, Clipboard, ClipboardButton, ClipboardInline, CodeEditor, Collapse, Collapsible, CollapsiblePanel, CollapsibleStepHeader, ColorInput, Combobox, Command, CommandGroup, CommandInput, CommandItem, CommandList, ConflictStatusIndicator, DateInput, DatePicker, DateRangeInput, DateRangePicker, DiffType, DiffView, DotsLoader, DropdownMenu, EmptyConfigurationActionCard, EmptySearchContent, EmptyState, ErrorState, FileUpload, FormGroup, FullScreenModal, FullScreenModalBody, FullScreenModalHeader, HelpBlock, HoverCard, InlineStepDetail, InlineStepLabel, InputGroup, InputOtp, Kbd, Label2 as Label, Link, MarkedText, MergeEditor, MessageBubble, Modal, MultiActionButtonGroup, MultiCombobox, Navbar, NumberInput, PageHeader, PageLayout, PageToolbar, Pagination, PaneHeader, PanelWithDetails, PasswordInput, PlanApproval, PlanRewritingIndicator, Popconfirm, Popover, Progress, PromptInput, Question, QuestionBlock, RadioGroup2 as RadioGroup, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Search, SearchForm, SearchInput, SearchInputWithNavigation, Select, Separator2 as Separator, Sheet, Sidebar, SidebarProvider, Skeleton, SkeletonList, Slider, SplitButton, SqlEditor, Stepper, SuggestedPrompt, Switch, Table, Tabs2 as Tabs, TabsContent, Tagger, TextInput, Textarea, ThemeDecorator, ThemeProvider, ThinkingIndicator, TimeInput, TimePicker, Timeline, Toaster, Toggle, ToggleGroup, Tooltip, TooltipProvider, Truncated, ZoomableSvg, argoVariants, cn, computeDiffRows, computeLineInformation, copyToClipboard, isMac, kbdVariants, keys, mergeRefs, resolveStorybookBrand, setServerFieldErrors, themeToolbarBrands, toast, useAppForm, useAutosizeInput, useColorScheme, useInputOtpContext, useIsLegacyBrand, useMergeDiff, useNotification, useScrollbarPosition, useSidebar, useTheme, withForm };
14991
+ export { Alert, AnswerSummary, AppShell, AutoSaveTextarea, Avatar, Badge, Breadcrumb, Button, ButtonGroup, ButtonInline, Calendar, Card, Checkbox, Clipboard, ClipboardButton, ClipboardInline, Collapse, Collapsible, CollapsiblePanel, CollapsibleStepHeader, ColorInput, Combobox, Command, CommandGroup, CommandInput, CommandItem, CommandList, ConflictStatusIndicator, DateInput, DatePicker, DateRangeInput, DateRangePicker, DiffType, DiffView, DotsLoader, DropdownMenu, EmptyConfigurationActionCard, EmptySearchContent, EmptyState, ErrorState, FileUpload, FormGroup, FullScreenModal, FullScreenModalBody, FullScreenModalHeader, HelpBlock, HoverCard, InlineStepDetail, InlineStepLabel, InputGroup, InputOtp, Kbd, Label2 as Label, Link, MarkedText, MessageBubble, Modal, MultiActionButtonGroup, MultiCombobox, Navbar, NumberInput, PageHeader, PageLayout, PageToolbar, Pagination, PaneHeader, PanelWithDetails, PasswordInput, PlanApproval, PlanRewritingIndicator, Popconfirm, Popover, Progress, PromptInput, Question, QuestionBlock, RadioGroup2 as RadioGroup, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Search, SearchForm, SearchInput, SearchInputWithNavigation, Select, Separator2 as Separator, Sheet, Sidebar, SidebarProvider, Skeleton, SkeletonList, Slider, SplitButton, Stepper, SuggestedPrompt, Switch, Table, Tabs2 as Tabs, TabsContent, Tagger, TextInput, Textarea, ThemeDecorator, ThemeProvider, ThinkingIndicator, TimeInput, TimePicker, Timeline, Toaster, Toggle, ToggleGroup, Tooltip, TooltipProvider, Truncated, ZoomableSvg, argoVariants, cn, computeDiffRows, computeLineInformation, copyToClipboard, isMac, kbdVariants, keys, mergeRefs, resolveStorybookBrand, setServerFieldErrors, themeToolbarBrands, toast, useAppForm, useAutosizeInput, useColorScheme, useInputOtpContext, useIsLegacyBrand, useMergeDiff, useNotification, useScrollbarPosition, useSidebar, useTheme, withForm };
16154
14992
  //# sourceMappingURL=index.js.map
16155
14993
  //# sourceMappingURL=index.js.map