@eccenca/gui-elements 24.0.0 → 24.1.0-rc.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 (61) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/cmem/react-flow/StickyNoteModal/StickyNoteModal.js +3 -3
  3. package/dist/cjs/cmem/react-flow/StickyNoteModal/StickyNoteModal.js.map +1 -1
  4. package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js +3 -3
  5. package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -1
  6. package/dist/cjs/components/MultiSelect/MultiSelect.js +1 -0
  7. package/dist/cjs/components/MultiSelect/MultiSelect.js.map +1 -1
  8. package/dist/cjs/extensions/codemirror/CodeMirror.js +58 -6
  9. package/dist/cjs/extensions/codemirror/CodeMirror.js.map +1 -1
  10. package/dist/cjs/extensions/codemirror/debouncedLinter.js +18 -0
  11. package/dist/cjs/extensions/codemirror/debouncedLinter.js.map +1 -0
  12. package/dist/cjs/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js +6 -6
  13. package/dist/cjs/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js.map +1 -1
  14. package/dist/cjs/extensions/codemirror/linters/jsLinter.js +36 -0
  15. package/dist/cjs/extensions/codemirror/linters/jsLinter.js.map +1 -0
  16. package/dist/cjs/extensions/codemirror/linters/turtleLinter.js +81 -0
  17. package/dist/cjs/extensions/codemirror/linters/turtleLinter.js.map +1 -0
  18. package/dist/cjs/extensions/codemirror/types.js +3 -0
  19. package/dist/cjs/extensions/codemirror/types.js.map +1 -0
  20. package/dist/esm/cmem/react-flow/StickyNoteModal/StickyNoteModal.js +4 -4
  21. package/dist/esm/cmem/react-flow/StickyNoteModal/StickyNoteModal.js.map +1 -1
  22. package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js +14 -3
  23. package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -1
  24. package/dist/esm/components/MultiSelect/MultiSelect.js +1 -0
  25. package/dist/esm/components/MultiSelect/MultiSelect.js.map +1 -1
  26. package/dist/esm/extensions/codemirror/CodeMirror.js +58 -7
  27. package/dist/esm/extensions/codemirror/CodeMirror.js.map +1 -1
  28. package/dist/esm/extensions/codemirror/debouncedLinter.js +15 -0
  29. package/dist/esm/extensions/codemirror/debouncedLinter.js.map +1 -0
  30. package/dist/esm/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js +6 -6
  31. package/dist/esm/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js.map +1 -1
  32. package/dist/esm/extensions/codemirror/linters/jsLinter.js +32 -0
  33. package/dist/esm/extensions/codemirror/linters/jsLinter.js.map +1 -0
  34. package/dist/esm/extensions/codemirror/linters/turtleLinter.js +77 -0
  35. package/dist/esm/extensions/codemirror/linters/turtleLinter.js.map +1 -0
  36. package/dist/esm/extensions/codemirror/types.js +2 -0
  37. package/dist/esm/extensions/codemirror/types.js.map +1 -0
  38. package/dist/types/cmem/react-flow/StickyNoteModal/StickyNoteModal.d.ts +5 -1
  39. package/dist/types/components/AutoSuggestion/ExtendedCodeEditor.d.ts +11 -6
  40. package/dist/types/components/Structure/TitleSubsection.d.ts +2 -1
  41. package/dist/types/components/Tabs/Tab.d.ts +6 -4
  42. package/dist/types/extensions/codemirror/CodeMirror.d.ts +23 -5
  43. package/dist/types/extensions/codemirror/debouncedLinter.d.ts +4 -0
  44. package/dist/types/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.d.ts +2 -2
  45. package/dist/types/extensions/codemirror/linters/jsLinter.d.ts +5 -0
  46. package/dist/types/extensions/codemirror/linters/turtleLinter.d.ts +5 -0
  47. package/dist/types/extensions/codemirror/types.d.ts +5 -0
  48. package/dist/types/extensions/react-flow/versionsupport.d.ts +1 -1
  49. package/package.json +41 -31
  50. package/src/cmem/react-flow/StickyNoteModal/StickyNoteModal.tsx +16 -2
  51. package/src/components/AutoSuggestion/ExtendedCodeEditor.tsx +29 -6
  52. package/src/components/MultiSelect/MultiSelect.tsx +1 -0
  53. package/src/components/TextField/stories/TextField.stories.tsx +2 -1
  54. package/src/extensions/codemirror/CodeMirror.stories.tsx +30 -0
  55. package/src/extensions/codemirror/CodeMirror.tsx +86 -9
  56. package/src/extensions/codemirror/_codemirror.scss +96 -0
  57. package/src/extensions/codemirror/debouncedLinter.ts +26 -0
  58. package/src/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.ts +6 -7
  59. package/src/extensions/codemirror/linters/jsLinter.ts +38 -0
  60. package/src/extensions/codemirror/linters/turtleLinter.ts +102 -0
  61. package/src/extensions/codemirror/types.ts +7 -0
@@ -37,11 +37,13 @@ export declare const transformTabProperties: ({ title, dontShrink, className, ba
37
37
  suppressContentEditableWarning?: boolean | undefined;
38
38
  suppressHydrationWarning?: boolean | undefined;
39
39
  accessKey?: string | undefined;
40
+ autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
40
41
  autoFocus?: boolean | undefined;
41
42
  contentEditable?: (boolean | "true" | "false") | "inherit" | undefined;
42
43
  contextMenu?: string | undefined;
43
44
  dir?: string | undefined;
44
45
  draggable?: (boolean | "true" | "false") | undefined;
46
+ enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
45
47
  hidden?: boolean | undefined;
46
48
  id: import("@blueprintjs/core").TabId;
47
49
  lang?: string | undefined;
@@ -63,7 +65,6 @@ export declare const transformTabProperties: ({ title, dontShrink, className, ba
63
65
  rev?: string | undefined;
64
66
  typeof?: string | undefined;
65
67
  vocab?: string | undefined;
66
- autoCapitalize?: string | undefined;
67
68
  autoCorrect?: string | undefined;
68
69
  autoSave?: string | undefined;
69
70
  color?: string | undefined;
@@ -288,8 +289,8 @@ export declare const transformTabProperties: ({ title, dontShrink, className, ba
288
289
  onTransitionEnd?: React.TransitionEventHandler<HTMLDivElement> | undefined;
289
290
  onTransitionEndCapture?: React.TransitionEventHandler<HTMLDivElement> | undefined;
290
291
  icon?: import("@blueprintjs/core").IconName | import("@blueprintjs/core").MaybeElement;
291
- tagProps?: Omit<import("@blueprintjs/core").TagProps, "children">;
292
292
  panel?: React.JSX.Element | ((props: import("@blueprintjs/core/lib/esm/components/tabs/tab").TabIdProps) => React.JSX.Element);
293
+ tagProps?: Omit<import("@blueprintjs/core").TagProps, "children">;
293
294
  panelClassName?: string;
294
295
  tagContent?: import("@blueprintjs/core").TagProps["children"];
295
296
  key: import("@blueprintjs/core").TabId;
@@ -307,11 +308,13 @@ export declare const transformTabProperties: ({ title, dontShrink, className, ba
307
308
  suppressContentEditableWarning?: boolean | undefined;
308
309
  suppressHydrationWarning?: boolean | undefined;
309
310
  accessKey?: string | undefined;
311
+ autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
310
312
  autoFocus?: boolean | undefined;
311
313
  contentEditable?: (boolean | "true" | "false") | "inherit" | undefined;
312
314
  contextMenu?: string | undefined;
313
315
  dir?: string | undefined;
314
316
  draggable?: (boolean | "true" | "false") | undefined;
317
+ enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
315
318
  hidden?: boolean | undefined;
316
319
  id: import("@blueprintjs/core").TabId;
317
320
  lang?: string | undefined;
@@ -333,7 +336,6 @@ export declare const transformTabProperties: ({ title, dontShrink, className, ba
333
336
  rev?: string | undefined;
334
337
  typeof?: string | undefined;
335
338
  vocab?: string | undefined;
336
- autoCapitalize?: string | undefined;
337
339
  autoCorrect?: string | undefined;
338
340
  autoSave?: string | undefined;
339
341
  color?: string | undefined;
@@ -558,8 +560,8 @@ export declare const transformTabProperties: ({ title, dontShrink, className, ba
558
560
  onTransitionEnd?: React.TransitionEventHandler<HTMLDivElement> | undefined;
559
561
  onTransitionEndCapture?: React.TransitionEventHandler<HTMLDivElement> | undefined;
560
562
  icon?: import("@blueprintjs/core").IconName | import("@blueprintjs/core").MaybeElement;
561
- tagProps?: Omit<import("@blueprintjs/core").TagProps, "children">;
562
563
  panel?: React.JSX.Element | ((props: import("@blueprintjs/core/lib/esm/components/tabs/tab").TabIdProps) => React.JSX.Element);
564
+ tagProps?: Omit<import("@blueprintjs/core").TagProps, "children">;
563
565
  panelClassName?: string;
564
566
  tagContent?: import("@blueprintjs/core").TagProps["children"];
565
567
  key: import("@blueprintjs/core").TabId;
@@ -1,9 +1,11 @@
1
1
  import React from "react";
2
2
  import { Extension } from "@codemirror/state";
3
3
  import { EditorView, Rect } from "@codemirror/view";
4
+ import { IntentTypes } from "../../common/Intent";
5
+ import { TestableComponent } from "../../components/interfaces";
4
6
  import { SupportedCodeEditorModes } from "./hooks/useCodemirrorModeExtension.hooks";
5
- export interface CodeEditorProps {
6
- setEditorView?: (editor: EditorView | undefined) => any;
7
+ export interface CodeEditorProps extends TestableComponent {
8
+ setEditorView?: (editor: EditorView | undefined) => void;
7
9
  /**
8
10
  * `name` attribute of connected textarea element.
9
11
  */
@@ -25,7 +27,7 @@ export interface CodeEditorProps {
25
27
  /**
26
28
  * Called when the focus status changes
27
29
  */
28
- onFocusChange?: (focused: boolean) => any;
30
+ onFocusChange?: (focused: boolean) => void;
29
31
  /**
30
32
  * Called when the user presses a key
31
33
  */
@@ -40,7 +42,7 @@ export interface CodeEditorProps {
40
42
  onSelection?: (ranges: {
41
43
  from: number;
42
44
  to: number;
43
- }[]) => any;
45
+ }[]) => void;
44
46
  /**
45
47
  * Called when the cursor position changes
46
48
  */
@@ -101,11 +103,27 @@ export interface CodeEditorProps {
101
103
  * If the <Tab> key is enabled as normal input, i.e. it won't have the behavior of changing to the next input element, expected in a web app.
102
104
  */
103
105
  enableTab?: boolean;
106
+ /**
107
+ * Enables linting feature in the editor ("turtle" and "javascript" modes can use linting currently).
108
+ */
109
+ useLinting?: boolean;
110
+ /**
111
+ * Autofocus the editor when it is rendered
112
+ */
113
+ autoFocus?: boolean;
114
+ /**
115
+ * Intent state of the code editor.
116
+ */
117
+ intent?: IntentTypes | "edited" | "removed";
118
+ /**
119
+ * Disables the editor.
120
+ */
121
+ disabled?: boolean;
104
122
  }
105
123
  /**
106
124
  * Includes a code editor, currently we use CodeMirror library as base.
107
125
  */
108
126
  export declare const CodeEditor: {
109
- ({ onChange, onSelection, onMouseDown, onFocusChange, onKeyDown, onCursorChange, name, id, mode, preventLineNumbers, defaultValue, readOnly, shouldHaveMinimalSetup, wrapLines, onScroll, setEditorView, supportCodeFolding, shouldHighlightActiveLine, outerDivAttributes, tabIntentSize, tabIntentStyle, placeholder, additionalExtensions, tabForceSpaceForModes, enableTab, height, }: CodeEditorProps): React.JSX.Element;
127
+ ({ onChange, onSelection, onMouseDown, onFocusChange, onKeyDown, onCursorChange, name, id, mode, preventLineNumbers, defaultValue, readOnly, shouldHaveMinimalSetup, wrapLines, onScroll, setEditorView, supportCodeFolding, shouldHighlightActiveLine, outerDivAttributes, tabIntentSize, tabIntentStyle, placeholder, additionalExtensions, tabForceSpaceForModes, enableTab, height, useLinting, "data-test-id": dataTestId, autoFocus, disabled, intent, ...otherCodeEditorProps }: CodeEditorProps): React.JSX.Element;
110
128
  supportedModes: ("markdown" | "python" | "sparql" | "turtle" | "xml" | "yaml" | "jinja2" | "json" | "ntriples" | "mathematica" | "sql" | "javascript")[];
111
129
  };
@@ -0,0 +1,4 @@
1
+ import { Diagnostic } from "@codemirror/lint";
2
+ import { EditorView } from "@codemirror/view";
3
+ import { Linter } from "./types";
4
+ export declare const debouncedLinter: (lintFunction: Linter, time?: number) => (view: EditorView) => Promise<readonly Diagnostic[]>;
@@ -1,7 +1,7 @@
1
- import { StreamParser } from "@codemirror/language";
2
- import { markdown } from "@codemirror/lang-markdown";
3
1
  import { json } from "@codemirror/lang-json";
2
+ import { markdown } from "@codemirror/lang-markdown";
4
3
  import { xml } from "@codemirror/lang-xml";
4
+ import { StreamParser } from "@codemirror/language";
5
5
  import { sql } from "@codemirror/legacy-modes/mode/sql";
6
6
  declare const supportedModes: {
7
7
  readonly markdown: typeof markdown;
@@ -0,0 +1,5 @@
1
+ import { ExtensionCreator } from "../types";
2
+ /**
3
+ * Sets up the javascript linter. Documentation: https://codemirror.net/examples/lint/
4
+ */
5
+ export declare const jsLinter: ExtensionCreator;
@@ -0,0 +1,5 @@
1
+ import { ExtensionCreator } from "../types";
2
+ /**
3
+ * Sets up the turtle linter. Documentation: https://codemirror.net/examples/lint/
4
+ */
5
+ export declare const turtleLinter: ExtensionCreator;
@@ -0,0 +1,5 @@
1
+ import { Diagnostic } from "@codemirror/lint";
2
+ import { Extension } from "@codemirror/state";
3
+ import { EditorView } from "@codemirror/view";
4
+ export type Linter = (view: EditorView) => ReadonlyArray<Diagnostic> | Promise<ReadonlyArray<Diagnostic>>;
5
+ export type ExtensionCreator<T = unknown> = (options?: T) => Extension;
@@ -4,4 +4,4 @@ export interface ReacFlowVersionSupportProps {
4
4
  */
5
5
  flowVersion?: "legacy" | "next" | "none";
6
6
  }
7
- export declare const useReactFlowVersion: () => "none" | "legacy" | "next";
7
+ export declare const useReactFlowVersion: () => "none" | "next" | "legacy";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eccenca/gui-elements",
3
3
  "description": "GUI elements based on other libraries, usable in React application, written in Typescript.",
4
- "version": "24.0.0",
4
+ "version": "24.1.0-rc.0",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/eccenca/gui-elements",
7
7
  "bugs": "https://github.com/eccenca/gui-elements/issues",
@@ -28,7 +28,7 @@
28
28
  "registry": "https://registry.npmjs.org"
29
29
  },
30
30
  "engines": {
31
- "node": ">=18"
31
+ "node": ">=18.18.0"
32
32
  },
33
33
  "style": "src/index.scss",
34
34
  "main": "dist/cjs/index.js",
@@ -47,6 +47,7 @@
47
47
  "scripts"
48
48
  ],
49
49
  "scripts": {
50
+ "project:clean": "yarn test:clean && yarn build:clean && yarn storybook:clean && rimraf yarn-error.log",
50
51
  "build:clean": "rimraf dist/",
51
52
  "build:esm": "tsc --project .typescript/tsbuild-esm.json && ./scripts/fix-esm-dist",
52
53
  "build:cjs": "tsc --project .typescript/tsbuild-cjs.json && ./scripts/fix-cjs-dist",
@@ -55,21 +56,23 @@
55
56
  "compile-scss": "ts-node -O \"{ \\\"esModuleInterop\\\": true, \\\"module\\\": \\\"commonjs\\\"}\" ./scripts/compile-sass.ts",
56
57
  "storybook": "storybook dev -p 6006 --no-open",
57
58
  "build-storybook": "storybook build --webpack-stats-json",
59
+ "storybook:clean": "rimraf storybook-static/",
58
60
  "test": "jest",
59
61
  "test:ci": "jest --ci --reporters='default'",
60
62
  "test:coverage": "jest --collectCoverage",
61
63
  "test:generate-output": "jest --json --outputFile=.jest-test-results.json",
64
+ "test:clean": "rimraf .jest-test-results.json && rimraf coverage/",
62
65
  "autolint:scripts": "eslint --fix .storybook/ blueprint/ scripts/ src/ index.ts || exit 0",
63
66
  "autolint:styles": "stylelint \"{.storybook,src}/**/*.{css,scss}\" --fix || exit 0",
64
67
  "autolint:prettier": "prettier \"{.github,.storybook,.typescript,blueprint,scripts,src}/**/*\" .* *.json *.md *.ts --write --ignore-unknown",
65
68
  "autolint:all": "yarn autolint:scripts && yarn autolint:styles && yarn autolint:prettier"
66
69
  },
67
70
  "dependencies": {
68
- "@blueprintjs/colors": "^5.1.1",
69
- "@blueprintjs/core": "^5.11.0",
70
- "@blueprintjs/select": "^5.2.2",
71
- "@carbon/icons": "^11.47.1",
72
- "@carbon/react": "^1.64.1",
71
+ "@blueprintjs/colors": "^5.1.5",
72
+ "@blueprintjs/core": "^5.16.2",
73
+ "@blueprintjs/select": "^5.3.7",
74
+ "@carbon/icons": "^11.53.0",
75
+ "@carbon/react": "^1.72.0",
73
76
  "@codemirror/lang-json": "^6.0.1",
74
77
  "@codemirror/lang-markdown": "^6.3.1",
75
78
  "@codemirror/lang-xml": "^6.1.0",
@@ -78,7 +81,9 @@
78
81
  "codemirror": "^6.0.1",
79
82
  "color": "^4.2.3",
80
83
  "compute-scroll-into-view": "^3.1.0",
84
+ "jshint": "^2.13.6",
81
85
  "lodash": "^4.17.21",
86
+ "n3": "^1.23.1",
82
87
  "re-resizable": "^6.10.1",
83
88
  "react": "^16.13.1",
84
89
  "react-dom": "^16.13.1",
@@ -98,44 +103,49 @@
98
103
  },
99
104
  "devDependencies": {
100
105
  "@babel/core": "^7.26.0",
101
- "@babel/plugin-proposal-class-properties": "^7.16.7",
102
- "@babel/plugin-proposal-private-methods": "^7.16.11",
106
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
107
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
103
108
  "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
104
109
  "@babel/preset-env": "^7.26.0",
105
110
  "@babel/preset-flow": "^7.25.9",
106
- "@babel/preset-react": "^7.25.9",
111
+ "@babel/preset-react": "^7.26.3",
107
112
  "@babel/preset-typescript": "^7.26.0",
108
- "@storybook/addon-actions": "^8.4.3",
109
- "@storybook/addon-essentials": "^8.4.3",
110
- "@storybook/addon-jest": "^8.4.3",
111
- "@storybook/addon-links": "^8.4.3",
113
+ "@eslint/compat": "^1.2.4",
114
+ "@eslint/eslintrc": "^3.2.0",
115
+ "@eslint/js": "^9.17.0",
116
+ "@storybook/addon-actions": "^8.4.7",
117
+ "@storybook/addon-essentials": "^8.4.7",
118
+ "@storybook/addon-jest": "^8.4.7",
119
+ "@storybook/addon-links": "^8.4.7",
112
120
  "@storybook/addon-webpack5-compiler-babel": "^3.0.3",
113
- "@storybook/cli": "^8.4.3",
121
+ "@storybook/cli": "^8.4.7",
114
122
  "@storybook/preset-scss": "^1.0.3",
115
- "@storybook/react": "^8.4.3",
116
- "@storybook/react-webpack5": "^8.4.3",
117
- "@storybook/test": "^8.4.3",
123
+ "@storybook/react": "^8.4.7",
124
+ "@storybook/react-webpack5": "^8.4.7",
125
+ "@storybook/test": "^8.4.7",
118
126
  "@testing-library/jest-dom": "^6.6.3",
119
127
  "@testing-library/react": "^12.1.2",
120
128
  "@types/codemirror": "^5.60.15",
121
129
  "@types/color": "^3.0.6",
122
- "@types/jest": "^29.5.12",
123
- "@types/lodash": "^4.17.7",
130
+ "@types/jest": "^29.5.14",
131
+ "@types/jshint": "^2.12.4",
132
+ "@types/lodash": "^4.17.13",
133
+ "@types/n3": "^1.21.1",
124
134
  "@types/react-syntax-highlighter": "^15.5.13",
125
- "@typescript-eslint/eslint-plugin": "^5.62.0",
126
- "@typescript-eslint/parser": "^5.62.0",
135
+ "@typescript-eslint/eslint-plugin": "^8.18.1",
136
+ "@typescript-eslint/parser": "^8.18.1",
127
137
  "babel-jest": "^29.7.0",
128
- "chromatic": "^11.18.1",
129
- "eslint": "^8.57.0",
130
- "eslint-plugin-react": "^7.35.0",
131
- "eslint-plugin-react-hooks": "^4.6.2",
138
+ "chromatic": "^11.20.2",
139
+ "eslint": "^9.17.0",
140
+ "eslint-plugin-react": "^7.37.2",
141
+ "eslint-plugin-react-hooks": "^5.1.0",
132
142
  "eslint-plugin-simple-import-sort": "^12.1.1",
133
143
  "husky": "4",
134
144
  "identity-obj-proxy": "^3.0.0",
135
145
  "jest": "^29.7.0",
136
146
  "jest-environment-jsdom": "^29.7.0",
137
147
  "jest-pnp-resolver": "^1.2.3",
138
- "lint-staged": "^15.2.9",
148
+ "lint-staged": "^15.2.11",
139
149
  "node-sass-package-importer": "^5.3.3",
140
150
  "path": "^0.12.7",
141
151
  "prettier": "^2.8.8",
@@ -145,12 +155,12 @@
145
155
  "rimraf": "^5.0.10",
146
156
  "sass": "1.62.1",
147
157
  "sass-loader": "10.3.1",
148
- "storybook": "^8.4.3",
158
+ "storybook": "^8.4.7",
149
159
  "stylelint": "^15.11.0",
150
160
  "stylelint-config-recess-order": "^4.6.0",
151
161
  "stylelint-config-standard-scss": "^9.0.0",
152
162
  "ts-node": "^10.9.2",
153
- "tsc-esm-fix": "^3.0.2",
163
+ "tsc-esm-fix": "^3.1.2",
154
164
  "typescript": "5.5.3",
155
165
  "url-loader": "^4.1.1",
156
166
  "yargs": "^17.7.2"
@@ -161,8 +171,8 @@
161
171
  "react-dom": ">=16"
162
172
  },
163
173
  "resolutions": {
164
- "**/@types/react": "^17.0.80",
165
- "node-sass-package-importer/**/postcss": "^8.4.41",
174
+ "**/@types/react": "^17.0.83",
175
+ "node-sass-package-importer/**/postcss": "^8.4.49",
166
176
  "**/cross-spawn": "^7.0.5 ",
167
177
  "**/micromatch": "^4.0.8"
168
178
  },
@@ -4,7 +4,16 @@ import getColorConfiguration from "../../../common/utils/getColorConfiguration";
4
4
  import { CodeEditor } from "../../../extensions";
5
5
  import { ReactFlowHotkeyContext } from "../extensions/ReactFlowHotkeyContext";
6
6
 
7
- import { Button, FieldItem, Icon, SimpleDialog, SimpleDialogProps, Tag, TagList } from "./../../../index";
7
+ import {
8
+ Button,
9
+ CodeEditorProps,
10
+ FieldItem,
11
+ Icon,
12
+ SimpleDialog,
13
+ SimpleDialogProps,
14
+ Tag,
15
+ TagList,
16
+ } from "./../../../index";
8
17
 
9
18
  export type StickyNoteModalTranslationKeys = "modalTitle" | "noteLabel" | "colorLabel" | "saveButton" | "cancelButton";
10
19
 
@@ -32,10 +41,14 @@ export interface StickyNoteModalProps {
32
41
  * Forward other properties to the `SimpleModal` element that is used for this dialog.
33
42
  */
34
43
  simpleDialogProps?: Omit<SimpleDialogProps, "size" | "title" | "hasBorder" | "isOpen" | "onClose" | "actions">;
44
+ /**
45
+ * Code editor props
46
+ */
47
+ codeEditorProps?: Omit<CodeEditorProps, "defaultValue" | "onChange" | "preventLinuNumbers" | "id" | "name">;
35
48
  }
36
49
 
37
50
  export const StickyNoteModal: React.FC<StickyNoteModalProps> = React.memo(
38
- ({ metaData, onClose, onSubmit, translate, simpleDialogProps }) => {
51
+ ({ metaData, onClose, onSubmit, translate, simpleDialogProps, codeEditorProps }) => {
39
52
  const refNote = React.useRef<string>(metaData?.note ?? "");
40
53
  const [color, setSelectedColor] = React.useState<string>(metaData?.color ?? "");
41
54
  const noteColors: [string, string][] = Object.entries(getColorConfiguration("stickynotes")).map(
@@ -123,6 +136,7 @@ export const StickyNoteModal: React.FC<StickyNoteModalProps> = React.memo(
123
136
  refNote.current = value;
124
137
  }}
125
138
  defaultValue={refNote.current}
139
+ {...codeEditorProps}
126
140
  />
127
141
  </FieldItem>
128
142
  <FieldItem
@@ -4,7 +4,7 @@ import { EditorState } from "@codemirror/state";
4
4
  import { EditorView, lineNumbers, Rect } from "@codemirror/view";
5
5
 
6
6
  import { CLASSPREFIX as eccgui } from "../../configuration/constants";
7
- import { CodeEditor } from "../../extensions/codemirror/CodeMirror";
7
+ import { CodeEditor, CodeEditorProps } from "../../extensions/codemirror/CodeMirror";
8
8
  //hooks
9
9
  import { SupportedCodeEditorModes } from "../../extensions/codemirror/hooks/useCodemirrorModeExtension.hooks";
10
10
 
@@ -15,23 +15,23 @@ export interface IRange {
15
15
 
16
16
  export interface ExtendedCodeEditorProps {
17
17
  // Is called with the editor instance that allows access via the CodeMirror API
18
- setCM: (editor: EditorView | undefined) => any;
18
+ setCM: (editor: EditorView | undefined) => void;
19
19
  // Called whenever the editor content changes
20
- onChange: (value: string) => any;
20
+ onChange: (value: string) => void;
21
21
  // Called when the cursor position changes
22
- onCursorChange: (pos: number, coords: Rect, scrollinfo: HTMLElement, cm: EditorView) => any;
22
+ onCursorChange: (pos: number, coords: Rect, scrollinfo: HTMLElement, cm: EditorView) => void;
23
23
  // The editor theme, e.g. "sparql"
24
24
  mode?: SupportedCodeEditorModes;
25
25
  // The initial value of the editor
26
26
  initialValue: string;
27
27
  // Called when the focus status changes
28
- onFocusChange: (focused: boolean) => any;
28
+ onFocusChange: (focused: boolean) => void;
29
29
  // Called when the user presses a key
30
30
  onKeyDown: (event: KeyboardEvent) => boolean;
31
31
  // function invoked when any click occurs
32
32
  onMouseDown?: (view: EditorView) => void;
33
33
  // Called when the user selects text
34
- onSelection: (ranges: IRange[]) => any;
34
+ onSelection: (ranges: IRange[]) => void;
35
35
  // If the <Tab> key is enabled as normal input, i.e. it won't have the behavior of changing to the next input element, expected in a web app.
36
36
  enableTab?: boolean;
37
37
  /** Placeholder to be shown when no text has been entered, yet. */
@@ -40,6 +40,27 @@ export interface ExtendedCodeEditorProps {
40
40
  showScrollBar?: boolean;
41
41
  /** allow multiline entries when new line characters are entered */
42
42
  multiline?: boolean;
43
+ /**
44
+ * Code editor props
45
+ */
46
+ codeEditorProps?: Omit<
47
+ CodeEditorProps,
48
+ | "defaultValue"
49
+ | "setEditorView"
50
+ | "onChange"
51
+ | "onCursorChange"
52
+ | "onFocusChange"
53
+ | "onKeyDown"
54
+ | "onSelection"
55
+ | "onMouseDown"
56
+ | "shouldHaveMinimalSetup"
57
+ | "preventLineNumbers"
58
+ | "mode"
59
+ | "name"
60
+ | "enableTab"
61
+ | "additionalExtensions"
62
+ | "outerDivAttributes"
63
+ >;
43
64
  }
44
65
 
45
66
  export type IEditorProps = ExtendedCodeEditorProps;
@@ -58,6 +79,7 @@ export const ExtendedCodeEditor = ({
58
79
  placeholder,
59
80
  onCursorChange,
60
81
  onSelection,
82
+ codeEditorProps,
61
83
  }: ExtendedCodeEditorProps) => {
62
84
  const initialContent = React.useRef(multiline ? initialValue : initialValue.replace(/[\r\n]/g, " "));
63
85
  const multilineExtensions = multiline
@@ -88,6 +110,7 @@ export const ExtendedCodeEditor = ({
88
110
  multiline ? "codeeditor" : `singlelinecodeeditor ${BlueprintClassNames.INPUT}`
89
111
  }`,
90
112
  }}
113
+ {...codeEditorProps}
91
114
  />
92
115
  );
93
116
  };
@@ -323,6 +323,7 @@ function MultiSelect<T>({
323
323
  * @param query
324
324
  */
325
325
  const onQueryChange = (query: string) => {
326
+ setFilteredItems([]);
326
327
  if (query.length && query !== requestState.current.query) {
327
328
  requestState.current.query = query;
328
329
  if (requestState.current.timeoutId) {
@@ -31,6 +31,7 @@ Default.args = {
31
31
  fullWidth: false,
32
32
  placeholder: "placeholder text",
33
33
  readOnly: false,
34
+ disabled: false,
34
35
  };
35
36
 
36
37
  /** Text field with default value that contains a zero width/invisible character.
@@ -46,7 +47,7 @@ const invisibleCharacterWarningProps: TextFieldProps = {
46
47
  const codePointsString = [...Array.from(codePoints)]
47
48
  .map((n) => {
48
49
  const info = characters.invisibleZeroWidthCharacters.codePointMap.get(n);
49
- return info.fullLabel;
50
+ return info?.fullLabel;
50
51
  })
51
52
  .join(", ");
52
53
  alert("Invisible character detected in input string. Code points: " + codePointsString);
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
2
  import { Meta, StoryFn } from "@storybook/react";
3
3
 
4
+ import { helpersArgTypes } from "../../../.storybook/helpers";
5
+
4
6
  import { CodeEditor } from "./CodeMirror";
5
7
 
6
8
  export default {
@@ -11,6 +13,9 @@ export default {
11
13
  onChange: {
12
14
  action: "value changed",
13
15
  },
16
+ intent: {
17
+ ...helpersArgTypes.exampleIntent,
18
+ },
14
19
  },
15
20
  } as Meta<typeof CodeEditor>;
16
21
 
@@ -22,3 +27,28 @@ BasicExample.args = {
22
27
  mode: "markdown",
23
28
  defaultValue: "**test me**",
24
29
  };
30
+
31
+ export const LinterExample = TemplateFull.bind({});
32
+ LinterExample.args = {
33
+ name: "codeinput",
34
+ defaultValue: "**test me**",
35
+ mode: "javascript",
36
+ useLinting: true,
37
+ autoFocus: true,
38
+ };
39
+
40
+ export const DisabledExample = TemplateFull.bind({});
41
+ DisabledExample.args = {
42
+ name: "codeinput",
43
+ defaultValue: "**test me**",
44
+ mode: "javascript",
45
+ disabled: true,
46
+ };
47
+
48
+ export const IntentExample = TemplateFull.bind({});
49
+ IntentExample.args = {
50
+ name: "codeinput",
51
+ defaultValue: "**test me**",
52
+ mode: "javascript",
53
+ intent: "warning",
54
+ };