@keboola/design 8.0.0 → 9.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.
@@ -1,5 +1,6 @@
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
5
  import { EditorView, EditorState, KeyBinding } from '@uiw/react-codemirror';
5
6
  import { SqlDialectName } from '@keboola/codemirror-lang-sql';
@@ -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,28 @@ 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;
21
34
  autocompletions?: string[];
35
+ /**
36
+ * Completions that depend on where the cursor is — a column list offered only
37
+ * after its table, say. Wins over both `autocompletions` and `completeAny`,
38
+ * which stay the right props for a list that is the same everywhere in the
39
+ * document and for having no list at all. Like them, it opens on typing.
40
+ */
41
+ completionSource?: CompletionSource;
42
+ /**
43
+ * Configuration variables, completed into `{{name}}`. Independent of
44
+ * `completionSource`: both are offered, so a caller keeps its own completions and
45
+ * gets variables spelled the way the rest of the platform writes them.
46
+ */
47
+ variables?: EditorVariable[];
22
48
  extraKeys?: Record<string, () => void>;
23
49
  withToggleCommentHint?: boolean;
24
50
  withAutofocus?: boolean;
@@ -38,7 +64,7 @@ type Props$2 = {
38
64
  readOnly?: boolean;
39
65
  onChange: (value: string) => void;
40
66
  });
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;
67
+ declare const CodeEditor: ({ value, previousValue, onChange, mode, placeholder, ariaLabel, searchQuery, searchMatchIndex, readOnly, autocompletions, completionSource, variables, extraKeys, withToggleCommentHint, withAutofocus, withLineNumbers, withLineWrapping, withCollapseUnchanged, withCopyButton, completeAny, help, helpPostfix, renderAdditionalButtons, className, }: Props$2) => react_jsx_runtime.JSX.Element;
42
68
 
43
69
  type HighlightedLines = {
44
70
  from: number;
@@ -71,7 +97,7 @@ type Props$1 = {
71
97
  lineNumbers?: boolean;
72
98
  className?: string;
73
99
  schema?: SQLNamespace;
74
- variables?: string[];
100
+ variables?: EditorVariable[];
75
101
  defaultSchema?: string;
76
102
  defaultDatabase?: string;
77
103
  highlightLines?: HighlightedLines;
@@ -112,4 +138,4 @@ type Props = {
112
138
  };
113
139
  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
140
 
115
- export { CodeEditor, type LANGUAGE_MODE, LANGUAGE_MODES, MergeEditor, SqlEditor, isLanguageMode };
141
+ export { CodeEditor, type EditorVariable, type LANGUAGE_MODE, LANGUAGE_MODES, MergeEditor, SqlEditor, isLanguageMode };
package/dist/editors.d.ts CHANGED
@@ -1,5 +1,6 @@
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
5
  import { EditorView, EditorState, KeyBinding } from '@uiw/react-codemirror';
5
6
  import { SqlDialectName } from '@keboola/codemirror-lang-sql';
@@ -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,28 @@ 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;
21
34
  autocompletions?: string[];
35
+ /**
36
+ * Completions that depend on where the cursor is — a column list offered only
37
+ * after its table, say. Wins over both `autocompletions` and `completeAny`,
38
+ * which stay the right props for a list that is the same everywhere in the
39
+ * document and for having no list at all. Like them, it opens on typing.
40
+ */
41
+ completionSource?: CompletionSource;
42
+ /**
43
+ * Configuration variables, completed into `{{name}}`. Independent of
44
+ * `completionSource`: both are offered, so a caller keeps its own completions and
45
+ * gets variables spelled the way the rest of the platform writes them.
46
+ */
47
+ variables?: EditorVariable[];
22
48
  extraKeys?: Record<string, () => void>;
23
49
  withToggleCommentHint?: boolean;
24
50
  withAutofocus?: boolean;
@@ -38,7 +64,7 @@ type Props$2 = {
38
64
  readOnly?: boolean;
39
65
  onChange: (value: string) => void;
40
66
  });
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;
67
+ declare const CodeEditor: ({ value, previousValue, onChange, mode, placeholder, ariaLabel, searchQuery, searchMatchIndex, readOnly, autocompletions, completionSource, variables, extraKeys, withToggleCommentHint, withAutofocus, withLineNumbers, withLineWrapping, withCollapseUnchanged, withCopyButton, completeAny, help, helpPostfix, renderAdditionalButtons, className, }: Props$2) => react_jsx_runtime.JSX.Element;
42
68
 
43
69
  type HighlightedLines = {
44
70
  from: number;
@@ -71,7 +97,7 @@ type Props$1 = {
71
97
  lineNumbers?: boolean;
72
98
  className?: string;
73
99
  schema?: SQLNamespace;
74
- variables?: string[];
100
+ variables?: EditorVariable[];
75
101
  defaultSchema?: string;
76
102
  defaultDatabase?: string;
77
103
  highlightLines?: HighlightedLines;
@@ -112,4 +138,4 @@ type Props = {
112
138
  };
113
139
  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
140
 
115
- export { CodeEditor, type LANGUAGE_MODE, LANGUAGE_MODES, MergeEditor, SqlEditor, isLanguageMode };
141
+ export { CodeEditor, type EditorVariable, type LANGUAGE_MODE, LANGUAGE_MODES, MergeEditor, SqlEditor, isLanguageMode };