@keboola/design 8.0.0 → 9.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.
@@ -1,7 +1,8 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
+ import { CompletionSource } from '@codemirror/autocomplete';
3
4
  import { SQLNamespace } from '@codemirror/lang-sql';
4
- import { EditorView, EditorState, KeyBinding } from '@uiw/react-codemirror';
5
+ import { EditorView, EditorState } from '@uiw/react-codemirror';
5
6
  import { SqlDialectName } from '@keboola/codemirror-lang-sql';
6
7
  export { SqlDialectName } from '@keboola/codemirror-lang-sql';
7
8
  import { M as MergeConflict, C as ChangeClassification } from './constants-D3gaMY-W.cjs';
@@ -10,6 +11,11 @@ declare const LANGUAGE_MODES: readonly ["application/json", "text/plain", "text/
10
11
  type LANGUAGE_MODE = (typeof LANGUAGE_MODES)[number];
11
12
  declare const isLanguageMode: (mode: string) => mode is LANGUAGE_MODE;
12
13
 
14
+ type EditorVariable = {
15
+ name: string;
16
+ value?: string;
17
+ };
18
+
13
19
  type Props$2 = {
14
20
  value: string;
15
21
  previousValue?: string;
@@ -17,8 +23,48 @@ type Props$2 = {
17
23
  placeholder?: string;
18
24
  /** Names the editable region for screen readers — the editor has no visible label of its own. */
19
25
  ariaLabel?: string;
26
+ /**
27
+ * Highlights every occurrence and scrolls the selected one into view. The find
28
+ * UI is the caller's — pass the query it holds, and omit both props entirely to
29
+ * leave the search extension uninstalled.
30
+ */
31
+ searchQuery?: string;
32
+ searchMatchIndex?: number;
20
33
  readOnly?: boolean;
34
+ /**
35
+ * Refuses edits while leaving the editor looking and behaving as it did — for a
36
+ * transient lock such as an in-flight save, where a keystroke landing mid-request
37
+ * would be overwritten by the response. `readOnly` is the wrong prop for that:
38
+ * it turns the editor into a viewer, greying the surface and taking the lint
39
+ * marks and completions with it.
40
+ */
41
+ inputLocked?: boolean;
42
+ /**
43
+ * A flat list of completions, offered everywhere in the document. One word per
44
+ * label: CodeMirror derives the pattern for the word being completed from the
45
+ * labels' characters, so a space in one widens it across whitespace and the
46
+ * editor offers nothing past the first word of a line. A phrase belongs in
47
+ * `completionSource`.
48
+ *
49
+ * Compared by identity, like `completionSource` — hand the editor a stable array.
50
+ */
21
51
  autocompletions?: string[];
52
+ /**
53
+ * Completions that depend on where the cursor is — a column list offered only
54
+ * after its table, say. Wins over both `autocompletions` and `completeAny`,
55
+ * which stay the right props for a list that is the same everywhere in the
56
+ * document and for having no list at all. Like them, it opens on typing.
57
+ *
58
+ * Compared by identity: build it in a `useMemo` or the editor rebuilds its whole
59
+ * extension tree on every render.
60
+ */
61
+ completionSource?: CompletionSource;
62
+ /**
63
+ * Configuration variables, completed into `{{name}}`. Independent of
64
+ * `completionSource`: both are offered, so a caller keeps its own completions and
65
+ * gets variables spelled the way the rest of the platform writes them.
66
+ */
67
+ variables?: EditorVariable[];
22
68
  extraKeys?: Record<string, () => void>;
23
69
  withToggleCommentHint?: boolean;
24
70
  withAutofocus?: boolean;
@@ -38,7 +84,7 @@ type Props$2 = {
38
84
  readOnly?: boolean;
39
85
  onChange: (value: string) => void;
40
86
  });
41
- declare const CodeEditor: ({ value, previousValue, onChange, mode, placeholder, ariaLabel, readOnly, autocompletions, extraKeys, withToggleCommentHint, withAutofocus, withLineNumbers, withLineWrapping, withCollapseUnchanged, withCopyButton, completeAny, help, helpPostfix, renderAdditionalButtons, className, }: Props$2) => react_jsx_runtime.JSX.Element;
87
+ declare const CodeEditor: ({ value, previousValue, onChange, mode, placeholder, ariaLabel, searchQuery, searchMatchIndex, readOnly, inputLocked, autocompletions, completionSource, variables, extraKeys, withToggleCommentHint, withAutofocus, withLineNumbers, withLineWrapping, withCollapseUnchanged, withCopyButton, completeAny, help, helpPostfix, renderAdditionalButtons, className, }: Props$2) => react_jsx_runtime.JSX.Element;
42
88
 
43
89
  type HighlightedLines = {
44
90
  from: number;
@@ -65,19 +111,23 @@ type Props$1 = {
65
111
  placeholder?: string;
66
112
  searchQuery?: string;
67
113
  searchMatchIndex?: number;
68
- extraKeys?: KeyBinding[];
69
114
  queryParser?: (sql: string) => Promise<string[]>;
70
115
  autoFocus?: boolean;
71
116
  lineNumbers?: boolean;
72
117
  className?: string;
118
+ /**
119
+ * A schema is too large to compare by value, so this one prop keeps the
120
+ * identity requirement every other prop here is now free of: hand the editor
121
+ * a stable object, or it rebuilds its whole extension tree on every render.
122
+ */
73
123
  schema?: SQLNamespace;
74
- variables?: string[];
124
+ variables?: EditorVariable[];
75
125
  defaultSchema?: string;
76
126
  defaultDatabase?: string;
77
127
  highlightLines?: HighlightedLines;
78
128
  dialect?: SqlDialectName;
79
129
  };
80
- declare const SqlEditor: ({ value, onChange, onSelectionChange, onCreateEditor, onDestroyEditor, onBlurEditor, onFocusEditor, placeholder, searchQuery, searchMatchIndex, readOnly, extraKeys, queryParser, autoFocus, lineNumbers, className, schema, variables, defaultDatabase, defaultSchema, highlightLines, dialect, }: Props$1) => react_jsx_runtime.JSX.Element;
130
+ declare const SqlEditor: ({ value, onChange, onSelectionChange, onCreateEditor, onDestroyEditor, onBlurEditor, onFocusEditor, placeholder, searchQuery, searchMatchIndex, readOnly, queryParser, autoFocus, lineNumbers, className, schema, variables, defaultDatabase, defaultSchema, highlightLines, dialect, }: Props$1) => react_jsx_runtime.JSX.Element;
81
131
 
82
132
  type Props = {
83
133
  mergeValue: string;
@@ -112,4 +162,4 @@ type Props = {
112
162
  };
113
163
  declare const MergeEditor: ({ mergeValue, handleMergeChange, leftText, rightText, leftConflicts, rightConflicts, leftHighlightedLines, rightHighlightedLines, leftClassification, rightClassification, mergeHighlightedLines, mergeClassification, acceptLeft, acceptRight, dismissLeft, dismissRight, leftHeader, middleHeader, middleHeaderClassName, middleClassName, rightHeader, className, leftDeleted, rightDeleted, }: Props) => react_jsx_runtime.JSX.Element;
114
164
 
115
- export { CodeEditor, type LANGUAGE_MODE, LANGUAGE_MODES, MergeEditor, SqlEditor, isLanguageMode };
165
+ export { CodeEditor, type EditorVariable, type LANGUAGE_MODE, LANGUAGE_MODES, MergeEditor, SqlEditor, isLanguageMode };
package/dist/editors.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
+ import { CompletionSource } from '@codemirror/autocomplete';
3
4
  import { SQLNamespace } from '@codemirror/lang-sql';
4
- import { EditorView, EditorState, KeyBinding } from '@uiw/react-codemirror';
5
+ import { EditorView, EditorState } from '@uiw/react-codemirror';
5
6
  import { SqlDialectName } from '@keboola/codemirror-lang-sql';
6
7
  export { SqlDialectName } from '@keboola/codemirror-lang-sql';
7
8
  import { M as MergeConflict, C as ChangeClassification } from './constants-D3gaMY-W.js';
@@ -10,6 +11,11 @@ declare const LANGUAGE_MODES: readonly ["application/json", "text/plain", "text/
10
11
  type LANGUAGE_MODE = (typeof LANGUAGE_MODES)[number];
11
12
  declare const isLanguageMode: (mode: string) => mode is LANGUAGE_MODE;
12
13
 
14
+ type EditorVariable = {
15
+ name: string;
16
+ value?: string;
17
+ };
18
+
13
19
  type Props$2 = {
14
20
  value: string;
15
21
  previousValue?: string;
@@ -17,8 +23,48 @@ type Props$2 = {
17
23
  placeholder?: string;
18
24
  /** Names the editable region for screen readers — the editor has no visible label of its own. */
19
25
  ariaLabel?: string;
26
+ /**
27
+ * Highlights every occurrence and scrolls the selected one into view. The find
28
+ * UI is the caller's — pass the query it holds, and omit both props entirely to
29
+ * leave the search extension uninstalled.
30
+ */
31
+ searchQuery?: string;
32
+ searchMatchIndex?: number;
20
33
  readOnly?: boolean;
34
+ /**
35
+ * Refuses edits while leaving the editor looking and behaving as it did — for a
36
+ * transient lock such as an in-flight save, where a keystroke landing mid-request
37
+ * would be overwritten by the response. `readOnly` is the wrong prop for that:
38
+ * it turns the editor into a viewer, greying the surface and taking the lint
39
+ * marks and completions with it.
40
+ */
41
+ inputLocked?: boolean;
42
+ /**
43
+ * A flat list of completions, offered everywhere in the document. One word per
44
+ * label: CodeMirror derives the pattern for the word being completed from the
45
+ * labels' characters, so a space in one widens it across whitespace and the
46
+ * editor offers nothing past the first word of a line. A phrase belongs in
47
+ * `completionSource`.
48
+ *
49
+ * Compared by identity, like `completionSource` — hand the editor a stable array.
50
+ */
21
51
  autocompletions?: string[];
52
+ /**
53
+ * Completions that depend on where the cursor is — a column list offered only
54
+ * after its table, say. Wins over both `autocompletions` and `completeAny`,
55
+ * which stay the right props for a list that is the same everywhere in the
56
+ * document and for having no list at all. Like them, it opens on typing.
57
+ *
58
+ * Compared by identity: build it in a `useMemo` or the editor rebuilds its whole
59
+ * extension tree on every render.
60
+ */
61
+ completionSource?: CompletionSource;
62
+ /**
63
+ * Configuration variables, completed into `{{name}}`. Independent of
64
+ * `completionSource`: both are offered, so a caller keeps its own completions and
65
+ * gets variables spelled the way the rest of the platform writes them.
66
+ */
67
+ variables?: EditorVariable[];
22
68
  extraKeys?: Record<string, () => void>;
23
69
  withToggleCommentHint?: boolean;
24
70
  withAutofocus?: boolean;
@@ -38,7 +84,7 @@ type Props$2 = {
38
84
  readOnly?: boolean;
39
85
  onChange: (value: string) => void;
40
86
  });
41
- declare const CodeEditor: ({ value, previousValue, onChange, mode, placeholder, ariaLabel, readOnly, autocompletions, extraKeys, withToggleCommentHint, withAutofocus, withLineNumbers, withLineWrapping, withCollapseUnchanged, withCopyButton, completeAny, help, helpPostfix, renderAdditionalButtons, className, }: Props$2) => react_jsx_runtime.JSX.Element;
87
+ declare const CodeEditor: ({ value, previousValue, onChange, mode, placeholder, ariaLabel, searchQuery, searchMatchIndex, readOnly, inputLocked, autocompletions, completionSource, variables, extraKeys, withToggleCommentHint, withAutofocus, withLineNumbers, withLineWrapping, withCollapseUnchanged, withCopyButton, completeAny, help, helpPostfix, renderAdditionalButtons, className, }: Props$2) => react_jsx_runtime.JSX.Element;
42
88
 
43
89
  type HighlightedLines = {
44
90
  from: number;
@@ -65,19 +111,23 @@ type Props$1 = {
65
111
  placeholder?: string;
66
112
  searchQuery?: string;
67
113
  searchMatchIndex?: number;
68
- extraKeys?: KeyBinding[];
69
114
  queryParser?: (sql: string) => Promise<string[]>;
70
115
  autoFocus?: boolean;
71
116
  lineNumbers?: boolean;
72
117
  className?: string;
118
+ /**
119
+ * A schema is too large to compare by value, so this one prop keeps the
120
+ * identity requirement every other prop here is now free of: hand the editor
121
+ * a stable object, or it rebuilds its whole extension tree on every render.
122
+ */
73
123
  schema?: SQLNamespace;
74
- variables?: string[];
124
+ variables?: EditorVariable[];
75
125
  defaultSchema?: string;
76
126
  defaultDatabase?: string;
77
127
  highlightLines?: HighlightedLines;
78
128
  dialect?: SqlDialectName;
79
129
  };
80
- declare const SqlEditor: ({ value, onChange, onSelectionChange, onCreateEditor, onDestroyEditor, onBlurEditor, onFocusEditor, placeholder, searchQuery, searchMatchIndex, readOnly, extraKeys, queryParser, autoFocus, lineNumbers, className, schema, variables, defaultDatabase, defaultSchema, highlightLines, dialect, }: Props$1) => react_jsx_runtime.JSX.Element;
130
+ declare const SqlEditor: ({ value, onChange, onSelectionChange, onCreateEditor, onDestroyEditor, onBlurEditor, onFocusEditor, placeholder, searchQuery, searchMatchIndex, readOnly, queryParser, autoFocus, lineNumbers, className, schema, variables, defaultDatabase, defaultSchema, highlightLines, dialect, }: Props$1) => react_jsx_runtime.JSX.Element;
81
131
 
82
132
  type Props = {
83
133
  mergeValue: string;
@@ -112,4 +162,4 @@ type Props = {
112
162
  };
113
163
  declare const MergeEditor: ({ mergeValue, handleMergeChange, leftText, rightText, leftConflicts, rightConflicts, leftHighlightedLines, rightHighlightedLines, leftClassification, rightClassification, mergeHighlightedLines, mergeClassification, acceptLeft, acceptRight, dismissLeft, dismissRight, leftHeader, middleHeader, middleHeaderClassName, middleClassName, rightHeader, className, leftDeleted, rightDeleted, }: Props) => react_jsx_runtime.JSX.Element;
114
164
 
115
- export { CodeEditor, type LANGUAGE_MODE, LANGUAGE_MODES, MergeEditor, SqlEditor, isLanguageMode };
165
+ export { CodeEditor, type EditorVariable, type LANGUAGE_MODE, LANGUAGE_MODES, MergeEditor, SqlEditor, isLanguageMode };