@eccenca/gui-elements 24.1.0 → 24.2.0-featuresupportprojectvariableautocompletioncmem5572.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 (119) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +10 -7
  3. package/dist/cjs/cmem/markdown/Markdown.js +13 -11
  4. package/dist/cjs/cmem/markdown/Markdown.js.map +1 -1
  5. package/dist/cjs/cmem/markdown/highlightSearchWords.js +6 -1
  6. package/dist/cjs/cmem/markdown/highlightSearchWords.js.map +1 -1
  7. package/dist/cjs/common/Intent/index.js +4 -11
  8. package/dist/cjs/common/Intent/index.js.map +1 -1
  9. package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js +37 -26
  10. package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
  11. package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js +2 -2
  12. package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -1
  13. package/dist/cjs/components/Button/Button.js +2 -2
  14. package/dist/cjs/components/Button/Button.js.map +1 -1
  15. package/dist/cjs/components/ContextOverlay/ContextMenu.js +3 -2
  16. package/dist/cjs/components/ContextOverlay/ContextMenu.js.map +1 -1
  17. package/dist/cjs/components/ContextOverlay/ContextOverlay.js +46 -2
  18. package/dist/cjs/components/ContextOverlay/ContextOverlay.js.map +1 -1
  19. package/dist/cjs/components/Form/FieldItem.js +3 -2
  20. package/dist/cjs/components/Form/FieldItem.js.map +1 -1
  21. package/dist/cjs/components/Form/FieldSet.js +3 -2
  22. package/dist/cjs/components/Form/FieldSet.js.map +1 -1
  23. package/dist/cjs/components/Icon/canonicalIconNames.js +1 -0
  24. package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
  25. package/dist/cjs/components/MultiSelect/MultiSelect.js +18 -14
  26. package/dist/cjs/components/MultiSelect/MultiSelect.js.map +1 -1
  27. package/dist/cjs/components/Notification/Notification.js +7 -4
  28. package/dist/cjs/components/Notification/Notification.js.map +1 -1
  29. package/dist/cjs/components/OverviewItem/OverviewItemActions.js +9 -2
  30. package/dist/cjs/components/OverviewItem/OverviewItemActions.js.map +1 -1
  31. package/dist/cjs/components/Spinner/Spinner.js +7 -5
  32. package/dist/cjs/components/Spinner/Spinner.js.map +1 -1
  33. package/dist/cjs/components/Tooltip/Tooltip.js +75 -7
  34. package/dist/cjs/components/Tooltip/Tooltip.js.map +1 -1
  35. package/dist/esm/cmem/markdown/Markdown.js +13 -11
  36. package/dist/esm/cmem/markdown/Markdown.js.map +1 -1
  37. package/dist/esm/cmem/markdown/highlightSearchWords.js +6 -1
  38. package/dist/esm/cmem/markdown/highlightSearchWords.js.map +1 -1
  39. package/dist/esm/common/Intent/index.js +14 -10
  40. package/dist/esm/common/Intent/index.js.map +1 -1
  41. package/dist/esm/components/AutoSuggestion/AutoSuggestion.js +42 -33
  42. package/dist/esm/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
  43. package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js +2 -2
  44. package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -1
  45. package/dist/esm/components/Button/Button.js +2 -2
  46. package/dist/esm/components/Button/Button.js.map +1 -1
  47. package/dist/esm/components/ContextOverlay/ContextMenu.js +3 -2
  48. package/dist/esm/components/ContextOverlay/ContextMenu.js.map +1 -1
  49. package/dist/esm/components/ContextOverlay/ContextOverlay.js +63 -3
  50. package/dist/esm/components/ContextOverlay/ContextOverlay.js.map +1 -1
  51. package/dist/esm/components/Form/FieldItem.js +3 -2
  52. package/dist/esm/components/Form/FieldItem.js.map +1 -1
  53. package/dist/esm/components/Form/FieldSet.js +3 -2
  54. package/dist/esm/components/Form/FieldSet.js.map +1 -1
  55. package/dist/esm/components/Icon/canonicalIconNames.js +1 -0
  56. package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
  57. package/dist/esm/components/MultiSelect/MultiSelect.js +18 -14
  58. package/dist/esm/components/MultiSelect/MultiSelect.js.map +1 -1
  59. package/dist/esm/components/Notification/Notification.js +7 -4
  60. package/dist/esm/components/Notification/Notification.js.map +1 -1
  61. package/dist/esm/components/OverviewItem/OverviewItemActions.js +25 -2
  62. package/dist/esm/components/OverviewItem/OverviewItemActions.js.map +1 -1
  63. package/dist/esm/components/Spinner/Spinner.js +9 -5
  64. package/dist/esm/components/Spinner/Spinner.js.map +1 -1
  65. package/dist/esm/components/Tooltip/Tooltip.js +92 -8
  66. package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
  67. package/dist/types/cmem/markdown/Markdown.d.ts +8 -1
  68. package/dist/types/common/Intent/index.d.ts +10 -1
  69. package/dist/types/components/AutoSuggestion/AutoSuggestion.d.ts +5 -1
  70. package/dist/types/components/AutoSuggestion/ExtendedCodeEditor.d.ts +5 -1
  71. package/dist/types/components/Button/Button.d.ts +5 -1
  72. package/dist/types/components/ContextOverlay/ContextMenu.d.ts +9 -2
  73. package/dist/types/components/ContextOverlay/ContextOverlay.d.ts +6 -1
  74. package/dist/types/components/Form/FieldItem.d.ts +10 -1
  75. package/dist/types/components/Form/FieldSet.d.ts +10 -1
  76. package/dist/types/components/Icon/canonicalIconNames.d.ts +1 -0
  77. package/dist/types/components/MultiSelect/MultiSelect.d.ts +12 -4
  78. package/dist/types/components/Notification/Notification.d.ts +10 -1
  79. package/dist/types/components/OverviewItem/OverviewItemActions.d.ts +13 -1
  80. package/dist/types/components/ProgressBar/ProgressBar.d.ts +2 -2
  81. package/dist/types/components/Spinner/Spinner.d.ts +8 -3
  82. package/dist/types/components/Structure/TitleSubsection.d.ts +7 -0
  83. package/dist/types/components/Table/TableContainer.d.ts +2 -2
  84. package/dist/types/components/Table/TableExpandRow.d.ts +1 -1
  85. package/dist/types/components/Table/index.d.ts +1 -0
  86. package/dist/types/components/Tabs/Tab.d.ts +14 -0
  87. package/dist/types/components/Tooltip/Tooltip.d.ts +9 -1
  88. package/package.json +47 -48
  89. package/src/cmem/markdown/Markdown.tsx +25 -14
  90. package/src/cmem/markdown/highlightSearchWords.test.ts +8 -2
  91. package/src/cmem/markdown/highlightSearchWords.ts +6 -1
  92. package/src/common/Intent/index.ts +6 -6
  93. package/src/components/AutoSuggestion/AutoSuggestion.tsx +50 -32
  94. package/src/components/AutoSuggestion/ExtendedCodeEditor.tsx +8 -0
  95. package/src/components/Button/Button.stories.tsx +10 -6
  96. package/src/components/Button/Button.tsx +7 -2
  97. package/src/components/ContextOverlay/ContextMenu.stories.tsx +1 -1
  98. package/src/components/ContextOverlay/ContextMenu.tsx +26 -13
  99. package/src/components/ContextOverlay/ContextOverlay.tsx +83 -5
  100. package/src/components/Form/FieldItem.tsx +14 -3
  101. package/src/components/Form/FieldSet.tsx +13 -2
  102. package/src/components/Form/Stories/FieldItem.stories.tsx +4 -0
  103. package/src/components/Form/Stories/FieldSet.stories.tsx +4 -0
  104. package/src/components/Icon/canonicalIconNames.tsx +1 -0
  105. package/src/components/MultiSelect/MultiSelect.tsx +27 -15
  106. package/src/components/MultiSuggestField/MultiSuggestField.stories.tsx +6 -0
  107. package/src/components/Notification/Notification.stories.tsx +4 -0
  108. package/src/components/Notification/Notification.tsx +17 -4
  109. package/src/components/OverviewItem/OverviewItemActions.tsx +24 -1
  110. package/src/components/OverviewItem/stories/OverviewItemList.stories.tsx +2 -7
  111. package/src/components/OverviewItem/stories/OverviewItemListPerformance.tsx +174 -0
  112. package/src/components/OverviewItem/stories/OverviewItemPerformance.stories.tsx +19 -0
  113. package/src/components/Spinner/Spinner.tsx +13 -5
  114. package/src/components/Spinner/Stories/spinner.stories.tsx +6 -1
  115. package/src/components/Table/TableContainer.tsx +2 -2
  116. package/src/components/Table/TableExpandRow.tsx +1 -1
  117. package/src/components/Table/index.tsx +1 -0
  118. package/src/components/Tooltip/Tooltip.stories.tsx +3 -2
  119. package/src/components/Tooltip/Tooltip.tsx +121 -10
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.1.0",
4
+ "version": "24.2.0-featuresupportprojectvariableautocompletioncmem5572.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",
@@ -68,42 +68,44 @@
68
68
  "autolint:all": "yarn autolint:scripts && yarn autolint:styles && yarn autolint:prettier"
69
69
  },
70
70
  "dependencies": {
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",
76
- "@codemirror/lang-javascript": "^6.2.2",
71
+ "@blueprintjs/colors": "^5.1.8",
72
+ "@blueprintjs/core": "^5.18.0",
73
+ "@blueprintjs/select": "^5.3.19",
74
+ "@carbon/icons": "^11.58.0",
75
+ "@carbon/react": "^1.80.1",
76
+ "@codemirror/lang-javascript": "^6.2.3",
77
77
  "@codemirror/lang-json": "^6.0.1",
78
- "@codemirror/lang-markdown": "^6.3.1",
78
+ "@codemirror/lang-markdown": "^6.3.2",
79
79
  "@codemirror/lang-sql": "^6.8.0",
80
80
  "@codemirror/lang-xml": "^6.1.0",
81
81
  "@codemirror/lang-yaml": "^6.1.2",
82
- "@codemirror/legacy-modes": "^6.4.2",
82
+ "@codemirror/legacy-modes": "^6.5.0",
83
83
  "@mavrin/remark-typograf": "^2.2.0",
84
84
  "classnames": "^2.5.1",
85
85
  "codemirror": "^6.0.1",
86
86
  "color": "^4.2.3",
87
- "compute-scroll-into-view": "^3.1.0",
87
+ "compute-scroll-into-view": "^3.1.1",
88
88
  "jshint": "^2.13.6",
89
89
  "lodash": "^4.17.21",
90
- "n3": "^1.23.1",
90
+ "n3": "^1.25.1",
91
91
  "re-resizable": "^6.10.3",
92
92
  "react": "^16.13.1",
93
93
  "react-dom": "^16.13.1",
94
94
  "react-flow-renderer": "9.7.4",
95
95
  "react-flow-renderer-lts": "npm:react-flow-renderer@^10.3.17",
96
96
  "react-inlinesvg": "^3.0.3",
97
- "react-markdown": "^8.0.7",
97
+ "react-markdown": "^10.1.0",
98
+ "react-markdown-deprecated": "npm:react-markdown@^8.0.7",
98
99
  "react-syntax-highlighter": "^15.6.1",
99
- "rehype-raw": "^6.1.1",
100
- "remark-definition-list": "^1.2.0",
101
- "remark-gfm": "^3.0.1",
102
- "remark-parse": "^10.0.2",
100
+ "rehype-external-links": "^3.0.0",
101
+ "rehype-raw": "^7.0.0",
102
+ "remark-definition-list": "^2.0.0",
103
+ "remark-gfm": "^4.0.1",
104
+ "remark-parse": "^11.0.0",
103
105
  "reset-css": "^5.0.2",
104
106
  "unified": "^11.0.5",
105
107
  "wicg-inert": "^3.1.3",
106
- "xml-formatter": "^3.6.3"
108
+ "xml-formatter": "^3.6.5"
107
109
  },
108
110
  "devDependencies": {
109
111
  "@babel/core": "^7.26.10",
@@ -114,42 +116,42 @@
114
116
  "@babel/preset-flow": "^7.25.9",
115
117
  "@babel/preset-react": "^7.26.3",
116
118
  "@babel/preset-typescript": "^7.27.0",
117
- "@eslint/compat": "^1.2.4",
118
- "@eslint/eslintrc": "^3.2.0",
119
- "@eslint/js": "^9.17.0",
120
- "@storybook/addon-actions": "^8.6.9",
121
- "@storybook/addon-essentials": "^8.6.9",
122
- "@storybook/addon-jest": "^8.6.9",
123
- "@storybook/addon-links": "^8.6.9",
124
- "@storybook/addon-webpack5-compiler-babel": "^3.0.5",
125
- "@storybook/cli": "^8.6.9",
119
+ "@eslint/compat": "^1.2.8",
120
+ "@eslint/eslintrc": "^3.3.1",
121
+ "@eslint/js": "^9.24.0",
122
+ "@storybook/addon-actions": "^8.6.12",
123
+ "@storybook/addon-essentials": "^8.6.12",
124
+ "@storybook/addon-jest": "^8.6.12",
125
+ "@storybook/addon-links": "^8.6.12",
126
+ "@storybook/addon-webpack5-compiler-babel": "^3.0.6",
127
+ "@storybook/cli": "^8.6.12",
126
128
  "@storybook/preset-scss": "^1.0.3",
127
- "@storybook/react": "^8.6.9",
128
- "@storybook/react-webpack5": "^8.6.9",
129
- "@storybook/test": "^8.6.9",
129
+ "@storybook/react": "^8.6.12",
130
+ "@storybook/react-webpack5": "^8.6.12",
131
+ "@storybook/test": "^8.6.12",
130
132
  "@testing-library/jest-dom": "^6.6.3",
131
- "@testing-library/react": "^12.1.2",
133
+ "@testing-library/react": "^12.1.5",
132
134
  "@types/codemirror": "^5.60.15",
133
135
  "@types/color": "^3.0.6",
134
136
  "@types/jest": "^29.5.14",
135
137
  "@types/jshint": "^2.12.4",
136
- "@types/lodash": "^4.17.13",
137
- "@types/n3": "^1.21.1",
138
+ "@types/lodash": "^4.17.16",
139
+ "@types/n3": "^1.24.2",
138
140
  "@types/react-syntax-highlighter": "^15.5.13",
139
- "@typescript-eslint/eslint-plugin": "^8.18.1",
140
- "@typescript-eslint/parser": "^8.18.1",
141
+ "@typescript-eslint/eslint-plugin": "^8.30.1",
142
+ "@typescript-eslint/parser": "^8.30.1",
141
143
  "babel-jest": "^29.7.0",
142
- "chromatic": "^11.27.0",
143
- "eslint": "^9.17.0",
144
- "eslint-plugin-react": "^7.37.2",
145
- "eslint-plugin-react-hooks": "^5.1.0",
144
+ "chromatic": "^11.28.0",
145
+ "eslint": "^9.24.0",
146
+ "eslint-plugin-react": "^7.37.5",
147
+ "eslint-plugin-react-hooks": "^5.2.0",
146
148
  "eslint-plugin-simple-import-sort": "^12.1.1",
147
149
  "husky": "4",
148
150
  "identity-obj-proxy": "^3.0.0",
149
151
  "jest": "^29.7.0",
150
152
  "jest-environment-jsdom": "^29.7.0",
151
153
  "jest-pnp-resolver": "^1.2.3",
152
- "lint-staged": "^15.2.11",
154
+ "lint-staged": "^15.5.1",
153
155
  "node-sass-package-importer": "^5.3.3",
154
156
  "path": "^0.12.7",
155
157
  "prettier": "^2.8.8",
@@ -159,10 +161,10 @@
159
161
  "rimraf": "^5.0.10",
160
162
  "sass": "1.62.1",
161
163
  "sass-loader": "10.3.1",
162
- "storybook": "^8.6.9",
163
- "stylelint": "^15.11.0",
164
- "stylelint-config-recess-order": "^4.6.0",
165
- "stylelint-config-standard-scss": "^9.0.0",
164
+ "storybook": "^8.6.12",
165
+ "stylelint": "^16.18.0",
166
+ "stylelint-config-recess-order": "^6.0.0",
167
+ "stylelint-config-standard-scss": "^14.0.0",
166
168
  "ts-node": "^10.9.2",
167
169
  "tsc-esm-fix": "^3.1.2",
168
170
  "typescript": "5.5.3",
@@ -175,12 +177,9 @@
175
177
  "react-dom": ">=16"
176
178
  },
177
179
  "resolutions": {
178
- "**/@types/react": "^17.0.83",
180
+ "**/@types/react": "^17.0.85",
179
181
  "node-sass-package-importer/**/postcss": "^8.4.49",
180
- "**/cross-spawn": "^7.0.5 ",
181
- "**/micromatch": "^4.0.8",
182
- "**/@babel/runtime": "^7.26.10",
183
- "**/@babel/helpers": "^7.26.10"
182
+ "hast-util-from-parse5": "8.0.0"
184
183
  },
185
184
  "husky": {
186
185
  "hooks": {
@@ -1,15 +1,21 @@
1
1
  import React from "react";
2
2
  import ReactMarkdown from "react-markdown";
3
- import { PluggableList } from "react-markdown/lib/react-markdown";
3
+ /**
4
+ * Recreate the old type to provide support until next major
5
+ */
6
+ import { PluggableList as PluggableListDeprecated } from "react-markdown-deprecated/lib/react-markdown";
4
7
  import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
5
8
  // @ts-ignore: No declaration file for module (TODO: should be @ts-expect-error but GUI elements is used inside project with `noImplicitAny=false`)
6
9
  import remarkTypograf from "@mavrin/remark-typograf";
10
+ import rehypeExternalLinks from "rehype-external-links";
7
11
  import rehypeRaw from "rehype-raw";
8
12
  import { remarkDefinitionList } from "remark-definition-list";
9
13
  import remarkGfm from "remark-gfm";
14
+ import { PluggableList as PluggableListUnified } from "unified";
10
15
 
11
16
  import { CLASSPREFIX as eccgui } from "../../configuration/constants";
12
17
  import { HtmlContentBlock, HtmlContentBlockProps, TestableComponent } from "../../index";
18
+ type PluggableList = PluggableListUnified | PluggableListDeprecated;
13
19
 
14
20
  export interface MarkdownProps extends TestableComponent {
15
21
  children: string;
@@ -35,6 +41,7 @@ export interface MarkdownProps extends TestableComponent {
35
41
  /**
36
42
  * Additional reHype plugins to execute.
37
43
  * @see https://github.com/remarkjs/react-markdown#architecture
44
+ * @deprecated (v25) this property won't support `PluggableList` from "react-markdown/lib/react-markdown" with the next major version, only the one from `unified` will be supported then.
38
45
  */
39
46
  reHypePlugins?: PluggableList;
40
47
  /**
@@ -54,9 +61,9 @@ const configDefault = {
54
61
  @see https://github.com/remarkjs/react-markdown#api
55
62
  */
56
63
  // @see https://github.com/remarkjs/remark/blob/main/doc/plugins.md#list-of-plugins
57
- remarkPlugins: [remarkGfm, remarkTypograf, remarkDefinitionList] as PluggableList,
64
+ remarkPlugins: [remarkGfm, remarkTypograf, remarkDefinitionList] as PluggableListUnified,
58
65
  // @see https://github.com/rehypejs/rehype/blob/main/doc/plugins.md#list-of-plugins
59
- rehypePlugins: [] as PluggableList,
66
+ rehypePlugins: [] as PluggableListUnified,
60
67
  allowedElements: [
61
68
  // default markdown
62
69
  "a",
@@ -110,6 +117,13 @@ export const Markdown = ({
110
117
  htmlContentBlockProps,
111
118
  ...otherProps
112
119
  }: MarkdownProps) => {
120
+ const configHtmlExternalLinks = {
121
+ rel: ["nofollow"],
122
+ target: linkTargetName,
123
+ };
124
+
125
+ configDefault.rehypePlugins = configDefault.rehypePlugins.concat([[rehypeExternalLinks, configHtmlExternalLinks]]);
126
+
113
127
  const configHtml = allowHtml
114
128
  ? {
115
129
  rehypePlugins: [...configDefault.rehypePlugins].concat([rehypeRaw]),
@@ -132,14 +146,10 @@ export const Markdown = ({
132
146
  ...configDefault,
133
147
  ...configHtml,
134
148
  ...configTextOnly,
135
- linkTarget: linkTargetName
136
- ? (href: string, _children: any, _title: string) => {
137
- const linkTarget = href.charAt(0) !== "#" ? linkTargetName : "";
138
- return linkTarget as React.HTMLAttributeAnchorTarget;
139
- }
140
- : undefined,
141
149
  components: {
150
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
151
  code(props: any) {
152
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
143
153
  const { children, className, node, inline, ...rest } = props;
144
154
  const match = /language-(\w+)/.exec(className || "");
145
155
  return match ? (
@@ -159,14 +169,15 @@ export const Markdown = ({
159
169
  );
160
170
  },
161
171
  },
172
+ allowedElements,
162
173
  };
163
- allowedElements && (reactMarkdownProperties.allowedElements = allowedElements);
164
- reHypePlugins &&
165
- reHypePlugins.forEach(
166
- (plugin) => (reactMarkdownProperties.rehypePlugins = [...reactMarkdownProperties.rehypePlugins, plugin])
174
+
175
+ if (reHypePlugins) {
176
+ reactMarkdownProperties.rehypePlugins = reactMarkdownProperties.rehypePlugins.concat(
177
+ reHypePlugins as PluggableListUnified
167
178
  );
179
+ }
168
180
 
169
- // @ts-ignore because against the lib spec it does not allow a function for linkTarget.
170
181
  const markdownDisplay = <ReactMarkdown {...reactMarkdownProperties} />;
171
182
  return inheritBlock && !(otherProps["data-test-id"] || htmlContentBlockProps) ? (
172
183
  markdownDisplay
@@ -9,7 +9,12 @@ describe("Highlight search words reHype plugin", () => {
9
9
  const highlightSearchWordsPlugin = markdownUtils.highlightSearchWordsPluginFactory(searchQuery);
10
10
  const highlightSearchWordTransformer = highlightSearchWordsPlugin();
11
11
  const textNode = (text: string): Text => ({ type: "text", value: text });
12
- const markNode = (text: string): Element => ({ type: "element", tagName: "mark", children: [textNode(text)] });
12
+ const markNode = (text: string): Element => ({
13
+ type: "element",
14
+ tagName: "mark",
15
+ properties: {},
16
+ children: [textNode(text)],
17
+ });
13
18
  const result = highlightSearchWordTransformer(
14
19
  {
15
20
  type: "root",
@@ -17,12 +22,13 @@ describe("Highlight search words reHype plugin", () => {
17
22
  {
18
23
  type: "element",
19
24
  tagName: "p",
25
+ properties: {},
20
26
  children: [textNode("Text with abc query words xyz.")],
21
27
  },
22
28
  ],
23
29
  },
24
30
  new VFile(),
25
- // eslint-disable-next-line @typescript-eslint/no-empty-function
31
+
26
32
  () => {}
27
33
  );
28
34
  const rootChildren = (result as Root).children;
@@ -25,7 +25,12 @@ const highlightSearchWordsPluginFactory = (searchQuery: string | undefined) => {
25
25
  let matchArray = multiWordRegex.exec(text);
26
26
  while (matchArray !== null) {
27
27
  result.push(createTextNode(text.slice(offset, matchArray.index)));
28
- result.push({ type: "element", tagName: "mark", children: [createTextNode(matchArray[0])] });
28
+ result.push({
29
+ type: "element",
30
+ tagName: "mark",
31
+ properties: {},
32
+ children: [createTextNode(matchArray[0])],
33
+ });
29
34
  offset = multiWordRegex.lastIndex;
30
35
  matchArray = multiWordRegex.exec(text);
31
36
  }
@@ -1,16 +1,16 @@
1
1
  import { CLASSPREFIX as eccgui } from "../../configuration/constants";
2
+ import { Intent as BlueprintIntent } from "@blueprintjs/core";
2
3
 
3
- export type IntentTypes = "none" | "neutral" | "primary" | "accent" | "info" | "success" | "warning" | "danger";
4
+ export type IntentBlueprint = BlueprintIntent;
5
+ export const DefinitionsBlueprint = BlueprintIntent;
6
+
7
+ export type IntentTypes = IntentBlueprint | "neutral" | "accent" | "info";
4
8
 
5
9
  export const Definitions: { [key: string]: IntentTypes } = {
6
- PRIMARY: "primary",
10
+ ...DefinitionsBlueprint,
7
11
  ACCENT: "accent",
8
12
  NEUTRAL: "neutral",
9
- NONE: "none",
10
- SUCCESS: "success",
11
13
  INFO: "info",
12
- WARNING: "warning",
13
- DANGER: "danger",
14
14
  };
15
15
 
16
16
  export const intentClassName = (intent: IntentTypes) => {
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import React, { useEffect, useMemo, useState } from "react";
2
3
  import { Classes as BlueprintClassNames } from "@blueprintjs/core";
3
4
  import { EditorView, Rect } from "@codemirror/view";
@@ -165,6 +166,10 @@ export interface AutoSuggestionProps {
165
166
  /** If this is enabled the value of the editor is replaced with the initialValue if it changes.
166
167
  * FIXME: This property is a workaround for some "controlled" usages of the component via the initialValue property. */
167
168
  reInitOnInitialValueChange?: boolean;
169
+ /** Optional height of the component */
170
+ height?: number | string;
171
+ /** Set read-only mode. Default: false */
172
+ readOnly?: boolean;
168
173
  }
169
174
 
170
175
  // Meta data regarding a request
@@ -197,6 +202,8 @@ const AutoSuggestion = ({
197
202
  mode,
198
203
  multiline = false,
199
204
  reInitOnInitialValueChange = false,
205
+ height,
206
+ readOnly,
200
207
  }: AutoSuggestionProps) => {
201
208
  const value = React.useRef<string>(initialValue);
202
209
  const cursorPosition = React.useRef(0);
@@ -207,7 +214,7 @@ const AutoSuggestion = ({
207
214
  const suggestionRequestData = React.useRef<RequestMetaData>({ requestId: undefined });
208
215
  const [pathValidationPending, setPathValidationPending] = React.useState(false);
209
216
  const validationRequestData = React.useRef<RequestMetaData>({ requestId: undefined });
210
- const [, setErrorMarkers] = React.useState<any[]>([]);
217
+ const errorMarkers = React.useRef<any[]>([]);
211
218
  const [validationResponse, setValidationResponse] = useState<CodeAutocompleteFieldValidationResult | undefined>(
212
219
  undefined
213
220
  );
@@ -219,8 +226,8 @@ const AutoSuggestion = ({
219
226
  CodeAutocompleteFieldSuggestionWithReplacementInfo | undefined
220
227
  >(undefined);
221
228
  const [cm, setCM] = React.useState<EditorView>();
222
- const currentCm = React.useRef<EditorView>()
223
- currentCm.current = cm
229
+ const currentCm = React.useRef<EditorView>();
230
+ currentCm.current = cm;
224
231
  const isFocused = React.useRef(false);
225
232
  const autoSuggestionDivRef = React.useRef<HTMLDivElement>(null);
226
233
  /** Mutable editor state, since this needs to be current in scope of the SingleLineEditorComponent. */
@@ -242,16 +249,16 @@ const AutoSuggestion = ({
242
249
  changes: { from: 0, to: currentCm.current.state?.doc.length, insert: initialValue },
243
250
  });
244
251
  // Validate initial value change
245
- checkValuePathValidity(initialValue)
252
+ checkValuePathValidity(initialValue);
246
253
  }
247
254
  }, [initialValue, reInitOnInitialValueChange]);
248
255
 
249
256
  React.useEffect(() => {
250
- if(currentCm.current) {
257
+ if (currentCm.current) {
251
258
  // Validate initial value
252
- checkValuePathValidity(initialValue)
259
+ checkValuePathValidity(initialValue);
253
260
  }
254
- }, [currentCm.current!!])
261
+ }, [!!currentCm.current]);
255
262
 
256
263
  const setCurrentIndex = (newIndex: number) => {
257
264
  editorState.index = newIndex;
@@ -263,10 +270,9 @@ const AutoSuggestion = ({
263
270
  editorState.cm = cm;
264
271
  }, [cm, editorState]);
265
272
 
266
- const dispatch = // eslint-disable-next-line @typescript-eslint/no-empty-function
267
- (
268
- typeof editorState?.cm?.dispatch === "function" ? editorState?.cm?.dispatch : () => {}
269
- ) as EditorView["dispatch"];
273
+ const dispatch = (
274
+ typeof editorState?.cm?.dispatch === "function" ? editorState?.cm?.dispatch : () => {}
275
+ ) as EditorView["dispatch"];
270
276
 
271
277
  React.useEffect(() => {
272
278
  editorState.dropdownShown = shouldShowDropdown;
@@ -288,8 +294,9 @@ const AutoSuggestion = ({
288
294
  return () => removeMarkFromText({ view: cm, from, to });
289
295
  }
290
296
  } else {
291
- //remove redundant markers
292
- cm && removeMarkFromText({ view: cm, from: 0, to: cm.state?.doc.length });
297
+ if (cm) {
298
+ removeMarkFromText({ view: cm, from: 0, to: cm.state?.doc.length });
299
+ }
293
300
  }
294
301
  return;
295
302
  }, [highlightedElement, selectedTextRanges, cm]);
@@ -298,9 +305,17 @@ const AutoSuggestion = ({
298
305
  React.useEffect(() => {
299
306
  const parseError = validationResponse?.parseError;
300
307
  if (cm) {
308
+ const clearCurrentErrorMarker = () => {
309
+ if (errorMarkers.current.length) {
310
+ const [from, to] = errorMarkers.current;
311
+ removeMarkFromText({ view: cm, from, to });
312
+ errorMarkers.current = [];
313
+ }
314
+ };
301
315
  if (parseError) {
302
316
  const { message, start, end } = parseError;
303
317
  const { toOffset, fromOffset } = getOffsetRange(cm, start, end);
318
+ clearCurrentErrorMarker();
304
319
  const { from, to } = markText({
305
320
  view: cm,
306
321
  from: fromOffset,
@@ -308,22 +323,14 @@ const AutoSuggestion = ({
308
323
  className: `${eccgui}-autosuggestion__text--highlighted-error`,
309
324
  title: message,
310
325
  });
311
-
312
- setErrorMarkers((previousMarkers) => {
313
- previousMarkers.forEach((m) => removeMarkFromText({ view: cm, from: m.from, to: m.to }));
314
- return [from, to];
315
- });
326
+ errorMarkers.current = [from, to];
316
327
  } else {
317
- // Valid, clear all error markers
318
- setErrorMarkers((previous) => {
319
- previous.forEach((m) => removeMarkFromText({ view: cm, from: m.from, to: m.to }));
320
- return [];
321
- });
328
+ clearCurrentErrorMarker();
322
329
  }
323
330
  }
324
331
 
325
332
  const isValid = validationResponse?.valid === undefined || validationResponse.valid;
326
- onInputChecked && onInputChecked(isValid);
333
+ onInputChecked?.(isValid);
327
334
  }, [validationResponse?.valid, validationResponse?.parseError, cm, onInputChecked]);
328
335
 
329
336
  /** generate suggestions and also populate the replacement indexes dict */
@@ -390,6 +397,7 @@ const AutoSuggestion = ({
390
397
  try {
391
398
  const result: CodeAutocompleteFieldValidationResult | undefined = await checkInput(inputString);
392
399
  setValidationResponse(result);
400
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
393
401
  } catch (e) {
394
402
  setValidationResponse(undefined);
395
403
  // TODO: Error handling
@@ -425,6 +433,7 @@ const AutoSuggestion = ({
425
433
  setSuggestionResponse(result);
426
434
  }
427
435
  }
436
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
428
437
  } catch (e) {
429
438
  setSuggestionResponse(undefined);
430
439
  // TODO: Error handling
@@ -445,12 +454,14 @@ const AutoSuggestion = ({
445
454
  [asyncHandleEditorInputChange, autoCompletionRequestDelay]
446
455
  );
447
456
 
448
- const handleChange = (val: string) => {
449
- value.current = val;
450
- checkValuePathValidity.cancel();
451
- checkValuePathValidity(value.current);
452
- onChange(val);
453
- };
457
+ const handleChange = React.useMemo(() => {
458
+ return (val: string) => {
459
+ value.current = val;
460
+ checkValuePathValidity.cancel();
461
+ checkValuePathValidity(value.current);
462
+ onChange(val);
463
+ };
464
+ }, [onChange, checkValuePathValidity]);
454
465
 
455
466
  const handleCursorChange = (cursor: number, coords: Rect, scrollinfo: HTMLElement, view: EditorView) => {
456
467
  //cursor here is offset from line 1, autosuggestion works with cursor per-line.
@@ -534,8 +545,13 @@ const AutoSuggestion = ({
534
545
  };
535
546
 
536
547
  const handleInputFocus = (focusState: boolean) => {
537
- onFocusChange && onFocusChange(focusState);
538
- focusState ? setShouldShowDropdown(true) : closeDropDown();
548
+ onFocusChange?.(focusState);
549
+ if (focusState) {
550
+ setShouldShowDropdown(true);
551
+ } else {
552
+ closeDropDown();
553
+ }
554
+
539
555
  if (!isFocused.current && focusState) {
540
556
  // Just got focus
541
557
  // Clear suggestions and repeat suggestion request, something else might have changed while this component was not focused
@@ -643,6 +659,8 @@ const AutoSuggestion = ({
643
659
  showScrollBar={showScrollBar}
644
660
  multiline={multiline}
645
661
  onMouseDown={handleInputMouseDown}
662
+ height={height}
663
+ readOnly={readOnly}
646
664
  />
647
665
  );
648
666
  }, [
@@ -61,6 +61,10 @@ export interface ExtendedCodeEditorProps {
61
61
  | "additionalExtensions"
62
62
  | "outerDivAttributes"
63
63
  >;
64
+ /** Optional height of the component */
65
+ height?: number | string;
66
+ /** Set read-only mode. Default: false */
67
+ readOnly?: boolean;
64
68
  }
65
69
 
66
70
  export type IEditorProps = ExtendedCodeEditorProps;
@@ -80,6 +84,8 @@ export const ExtendedCodeEditor = ({
80
84
  onCursorChange,
81
85
  onSelection,
82
86
  codeEditorProps,
87
+ height,
88
+ readOnly,
83
89
  }: ExtendedCodeEditorProps) => {
84
90
  const initialContent = React.useRef(multiline ? initialValue : initialValue.replace(/[\r\n]/g, " "));
85
91
  const multilineExtensions = multiline
@@ -104,6 +110,8 @@ export const ExtendedCodeEditor = ({
104
110
  mode={mode}
105
111
  name=""
106
112
  enableTab={enableTab}
113
+ height={height}
114
+ readOnly={readOnly}
107
115
  additionalExtensions={[...multilineExtensions]}
108
116
  outerDivAttributes={{
109
117
  className: `${eccgui}-${
@@ -18,6 +18,10 @@ export default {
18
18
  onClick: {
19
19
  action: "clicked",
20
20
  },
21
+ intent: {
22
+ ...helpersArgTypes.exampleIntent,
23
+ options: ["UNDEFINED", "primary", "success", "warning", "danger"],
24
+ },
21
25
  },
22
26
  } as Meta<typeof Button>;
23
27
 
@@ -67,17 +71,17 @@ const TemplateSemantic: StoryFn<typeof Button> = (args) => (
67
71
  export const ButtonSemantics = TemplateSemantic.bind({});
68
72
  ButtonSemantics.args = FullExample.args;
69
73
 
70
- const TemplateState: StoryFn<typeof Button> = (args) => (
74
+ const TemplateIntent: StoryFn<typeof Button> = (args) => (
71
75
  <OverlaysProvider>
72
- <Button {...args} text="Success" hasStateSuccess />
76
+ <Button {...args} text="Success" intent="success" />
73
77
  <Spacing vertical />
74
- <Button {...args} text="Warning" hasStateWarning />
78
+ <Button {...args} text="Warning" intent="warning" />
75
79
  <Spacing vertical />
76
- <Button {...args} text="Danger" hasStateDanger />
80
+ <Button {...args} text="Danger" intent="danger" />
77
81
  </OverlaysProvider>
78
82
  );
79
- export const ButtonStates = TemplateState.bind({});
80
- ButtonStates.args = FullExample.args;
83
+ export const ButtonIntent = TemplateIntent.bind({});
84
+ ButtonIntent.args = FullExample.args;
81
85
 
82
86
  const TemplateContent: StoryFn<typeof Button> = (args) => (
83
87
  <OverlaysProvider>
@@ -32,18 +32,22 @@ interface AdditionalButtonProps {
32
32
  elevated?: boolean;
33
33
  /**
34
34
  * The button is displayed with primary color scheme.
35
+ * @deprecated (v25) use `intent="primary"` instead.
35
36
  */
36
37
  hasStatePrimary?: boolean;
37
38
  /**
38
39
  * The button is displayed with success (some type of green) color scheme.
40
+ * @deprecated (v25) use `intent="success"` instead.
39
41
  */
40
42
  hasStateSuccess?: boolean;
41
43
  /**
42
44
  * The button is displayed with warning (some type of orange) color scheme.
45
+ * @deprecated (v25) use `intent="warning"` instead.
43
46
  */
44
47
  hasStateWarning?: boolean;
45
48
  /**
46
49
  * The button is displayed with danger (some type of red) color scheme.
50
+ * @deprecated (v25) use `intent="danger"` instead.
47
51
  */
48
52
  hasStateDanger?: boolean;
49
53
  /**
@@ -100,6 +104,7 @@ export const Button = ({
100
104
  tooltipProps,
101
105
  badge,
102
106
  badgeProps = { size: "small", position: "top-right", maxLength: 2 },
107
+ intent,
103
108
  ...restProps
104
109
  }: ButtonProps) => {
105
110
  let intention;
@@ -120,13 +125,13 @@ export const Button = ({
120
125
  break;
121
126
  }
122
127
 
123
- const ButtonType: any = restProps.href ? BlueprintAnchorButton : BlueprintButton;
128
+ const ButtonType = restProps.href ? BlueprintAnchorButton : BlueprintButton;
124
129
 
125
130
  const button = (
126
131
  <ButtonType
127
132
  {...restProps}
128
133
  className={`${eccgui}-button ` + className}
129
- intent={intention}
134
+ intent={(intent || intention) as BlueprintIntent}
130
135
  icon={typeof icon === "string" ? <Icon name={icon} /> : icon}
131
136
  rightIcon={typeof rightIcon === "string" ? <Icon name={rightIcon} /> : rightIcon}
132
137
  >
@@ -10,7 +10,7 @@ export default {
10
10
  subcomponents: { MenuItem },
11
11
  argTypes: {
12
12
  children: {
13
- control: "none",
13
+ control: false,
14
14
  },
15
15
  },
16
16
  } as Meta<typeof ContextMenu>;