@eccenca/gui-elements 24.0.0-rc.5 → 24.0.1
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/CHANGELOG.md +22 -1
- package/dist/cjs/components/Application/helper.js +25 -2
- package/dist/cjs/components/Application/helper.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js +9 -1
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/extensions/markText.js +2 -2
- package/dist/cjs/components/AutoSuggestion/extensions/markText.js.map +1 -1
- package/dist/cjs/components/Icon/canonicalIconNames.js +1 -0
- package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/cjs/components/MultiSelect/MultiSelect.js +1 -0
- package/dist/cjs/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/cjs/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js +22 -13
- package/dist/cjs/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js.map +1 -1
- package/dist/esm/components/Application/helper.js +25 -2
- package/dist/esm/components/Application/helper.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js +20 -12
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/extensions/markText.js +2 -2
- package/dist/esm/components/AutoSuggestion/extensions/markText.js.map +1 -1
- package/dist/esm/components/Icon/canonicalIconNames.js +1 -0
- package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/esm/components/MultiSelect/MultiSelect.js +1 -0
- package/dist/esm/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/esm/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js +19 -10
- package/dist/esm/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js.map +1 -1
- package/dist/types/components/AutoSuggestion/AutoSuggestion.d.ts +4 -1
- package/dist/types/components/CodeAutocompleteField/CodeAutocompleteField.d.ts +2 -1
- package/dist/types/components/Icon/canonicalIconNames.d.ts +1 -0
- package/dist/types/components/Structure/TitleSubsection.d.ts +2 -1
- package/dist/types/components/Tabs/Tab.d.ts +6 -4
- package/dist/types/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.d.ts +7 -5
- package/dist/types/extensions/react-flow/versionsupport.d.ts +1 -1
- package/package.json +41 -31
- package/src/components/Application/helper.ts +30 -2
- package/src/components/AutoSuggestion/AutoSuggestion.tsx +13 -0
- package/src/components/AutoSuggestion/extensions/markText.ts +1 -2
- package/src/components/CodeAutocompleteField/CodeAutocompleteField.tsx +1 -1
- package/src/components/Icon/canonicalIconNames.tsx +1 -0
- package/src/components/MultiSelect/MultiSelect.tsx +1 -0
- package/src/components/Pagination/pagination.scss +1 -0
- package/src/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.ts +20 -11
|
@@ -28,20 +28,48 @@ export const useApplicationHeaderOverModals = (elevate: boolean, className: stri
|
|
|
28
28
|
export const useDropzoneMonitor = (enabledTypes: string[]) => {
|
|
29
29
|
React.useEffect(() => {
|
|
30
30
|
const monitor = window.document.body;
|
|
31
|
+
let timestampMonitorEnabled = 0;
|
|
32
|
+
let processDragleave: any;
|
|
31
33
|
|
|
32
34
|
const addMonitor = (event: DragEvent) => {
|
|
35
|
+
// stop default, so that also no files cannot executed by browser without demand
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
|
|
38
|
+
if (processDragleave) {
|
|
39
|
+
// stop removeMonitor process if it happend shortly before
|
|
40
|
+
clearTimeout(processDragleave);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// only process if monitor is not already enabled
|
|
44
|
+
if (timestampMonitorEnabled > 0) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// stop the event here to prevent double execution
|
|
49
|
+
event.stopImmediatePropagation();
|
|
50
|
+
|
|
51
|
+
// enable monitoring only for supported types of dragged elements
|
|
33
52
|
const types = event.dataTransfer?.types || [];
|
|
34
53
|
const monitorTypes = [...new Set(types.filter((type) => enabledTypes.includes(type)))];
|
|
35
54
|
if (monitorTypes.length > 0 && !monitor.dataset.monitorDropzone) {
|
|
36
55
|
monitor.dataset.monitorDropzone = monitorTypes.join(" ");
|
|
37
56
|
}
|
|
38
|
-
|
|
57
|
+
|
|
58
|
+
timestampMonitorEnabled = Date.now();
|
|
39
59
|
};
|
|
40
60
|
|
|
41
61
|
const removeMonitor = (event: DragEvent) => {
|
|
42
|
-
|
|
62
|
+
const removeAction = () => {
|
|
43
63
|
delete monitor.dataset.monitorDropzone;
|
|
44
64
|
event.preventDefault();
|
|
65
|
+
timestampMonitorEnabled = 0;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
if (event.type === "dragleave") {
|
|
69
|
+
// use timeout function for dragleave to prevent useless removeMonitor actions
|
|
70
|
+
processDragleave = setTimeout(removeAction, 250);
|
|
71
|
+
} else {
|
|
72
|
+
removeAction();
|
|
45
73
|
}
|
|
46
74
|
};
|
|
47
75
|
|
|
@@ -161,6 +161,10 @@ export interface AutoSuggestionProps {
|
|
|
161
161
|
multiline?: boolean;
|
|
162
162
|
// The editor theme, e.g. "sparql"
|
|
163
163
|
mode?: SupportedCodeEditorModes;
|
|
164
|
+
|
|
165
|
+
/** If this is enabled the value of the editor is replaced with the initialValue if it changes.
|
|
166
|
+
* FIXME: This property is a workaround for some "controlled" usages of the component via the initialValue property. */
|
|
167
|
+
reInitOnInitialValueChange?: boolean;
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
// Meta data regarding a request
|
|
@@ -192,6 +196,7 @@ const AutoSuggestion = ({
|
|
|
192
196
|
validationRequestDelay = 200,
|
|
193
197
|
mode,
|
|
194
198
|
multiline = false,
|
|
199
|
+
reInitOnInitialValueChange = false,
|
|
195
200
|
}: AutoSuggestionProps) => {
|
|
196
201
|
const value = React.useRef<string>(initialValue);
|
|
197
202
|
const cursorPosition = React.useRef(0);
|
|
@@ -229,6 +234,14 @@ const AutoSuggestion = ({
|
|
|
229
234
|
|
|
230
235
|
const pathIsValid = validationResponse?.valid ?? true;
|
|
231
236
|
|
|
237
|
+
React.useEffect(() => {
|
|
238
|
+
if (reInitOnInitialValueChange && initialValue != null && cm) {
|
|
239
|
+
dispatch({
|
|
240
|
+
changes: { from: 0, to: cm?.state?.doc.length, insert: initialValue },
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}, [initialValue, cm, reInitOnInitialValueChange]);
|
|
244
|
+
|
|
232
245
|
const setCurrentIndex = (newIndex: number) => {
|
|
233
246
|
editorState.index = newIndex;
|
|
234
247
|
setFocusedIndex(newIndex);
|
|
@@ -35,7 +35,6 @@ type marksConfig = {
|
|
|
35
35
|
|
|
36
36
|
export const markText = (config: marksConfig) => {
|
|
37
37
|
const docLength = config.view.state.doc.length;
|
|
38
|
-
if (!docLength) return { from: 0, to: 0 };
|
|
39
38
|
const strikeMark = Decoration.mark({
|
|
40
39
|
class: config.className,
|
|
41
40
|
attributes: {
|
|
@@ -43,10 +42,10 @@ export const markText = (config: marksConfig) => {
|
|
|
43
42
|
},
|
|
44
43
|
});
|
|
45
44
|
const stopRange = Math.min(config.to, docLength);
|
|
45
|
+
if (!docLength || config.from === stopRange) return { from: 0, to: 0 };
|
|
46
46
|
config.view.dispatch({
|
|
47
47
|
effects: addMarks.of([strikeMark.range(config.from, stopRange)] as any),
|
|
48
48
|
});
|
|
49
|
-
|
|
50
49
|
return { from: config.from, to: stopRange };
|
|
51
50
|
};
|
|
52
51
|
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
4
4
|
import AutoSuggestion, { AutoSuggestionProps } from "../AutoSuggestion/AutoSuggestion";
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export interface CodeAutocompleteFieldProps extends AutoSuggestionProps {}
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Input component that allows partial, fine-grained auto-completion, i.e. of sub-strings of the input string.
|
|
@@ -124,6 +124,7 @@ const canonicalIcons = {
|
|
|
124
124
|
"operation-filteredit": icons.FilterEdit,
|
|
125
125
|
"operation-filterremove": icons.FilterRemove,
|
|
126
126
|
"operation-filter": icons.Filter,
|
|
127
|
+
"operation-format-codeblock": icons.CodeBlock,
|
|
127
128
|
"operation-fix": icons.Tools,
|
|
128
129
|
"operation-link": icons.Link,
|
|
129
130
|
"operation-logout": icons.Logout,
|
|
@@ -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) {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//modes imports
|
|
4
|
-
import { markdown } from "@codemirror/lang-markdown";
|
|
1
|
+
//adapted v6 modes imports
|
|
2
|
+
import { javascript } from "@codemirror/lang-javascript";
|
|
5
3
|
import { json } from "@codemirror/lang-json";
|
|
4
|
+
import { markdown } from "@codemirror/lang-markdown";
|
|
5
|
+
import { sql } from "@codemirror/lang-sql";
|
|
6
6
|
import { xml } from "@codemirror/lang-xml";
|
|
7
|
-
import {
|
|
7
|
+
import { yaml } from "@codemirror/lang-yaml";
|
|
8
|
+
import { defaultHighlightStyle, LanguageSupport, StreamLanguage, StreamParser } from "@codemirror/language";
|
|
9
|
+
//legacy mode imports
|
|
10
|
+
import { jinja2 } from "@codemirror/legacy-modes/mode/jinja2";
|
|
11
|
+
import { mathematica } from "@codemirror/legacy-modes/mode/mathematica";
|
|
12
|
+
import { ntriples } from "@codemirror/legacy-modes/mode/ntriples";
|
|
8
13
|
import { python } from "@codemirror/legacy-modes/mode/python";
|
|
9
14
|
import { sparql } from "@codemirror/legacy-modes/mode/sparql";
|
|
10
|
-
import { sql } from "@codemirror/legacy-modes/mode/sql";
|
|
11
15
|
import { turtle } from "@codemirror/legacy-modes/mode/turtle";
|
|
12
|
-
import { jinja2 } from "@codemirror/legacy-modes/mode/jinja2";
|
|
13
|
-
import { yaml } from "@codemirror/legacy-modes/mode/yaml";
|
|
14
|
-
import { ntriples } from "@codemirror/legacy-modes/mode/ntriples";
|
|
15
|
-
import { mathematica } from "@codemirror/legacy-modes/mode/mathematica";
|
|
16
16
|
|
|
17
17
|
//adaptations
|
|
18
18
|
import { adaptedSyntaxHighlighting } from "../tests/codemirrorTestHelper";
|
|
@@ -35,10 +35,19 @@ const supportedModes = {
|
|
|
35
35
|
export const supportedCodeEditorModes = Object.keys(supportedModes) as Array<keyof typeof supportedModes>;
|
|
36
36
|
export type SupportedCodeEditorModes = (typeof supportedCodeEditorModes)[number];
|
|
37
37
|
|
|
38
|
+
const v6AdaptedModes: ReadonlyMap<SupportedCodeEditorModes, boolean> = new Map([
|
|
39
|
+
["json", true],
|
|
40
|
+
["markdown", true],
|
|
41
|
+
["xml", true],
|
|
42
|
+
["sql", true],
|
|
43
|
+
["yaml", true],
|
|
44
|
+
["javascript", true],
|
|
45
|
+
]);
|
|
46
|
+
|
|
38
47
|
export const useCodeMirrorModeExtension = (mode?: SupportedCodeEditorModes) => {
|
|
39
48
|
return !mode
|
|
40
49
|
? adaptedSyntaxHighlighting(defaultHighlightStyle)
|
|
41
|
-
:
|
|
50
|
+
: v6AdaptedModes.has(mode)
|
|
42
51
|
? ((typeof supportedModes[mode] === "function" ? supportedModes[mode] : () => {}) as () => LanguageSupport)()
|
|
43
52
|
: StreamLanguage?.define(supportedModes[mode] as StreamParser<unknown>);
|
|
44
53
|
};
|