@eccenca/gui-elements 23.3.1 → 23.4.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.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js +61 -19
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/AutoSuggestionList.js +4 -18
- package/dist/cjs/components/AutoSuggestion/AutoSuggestionList.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js +65 -0
- package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -0
- package/dist/cjs/components/AutoSuggestion/index.js +3 -3
- package/dist/cjs/components/AutoSuggestion/index.js.map +1 -1
- package/dist/cjs/components/Card/CardHeader.js +19 -18
- package/dist/cjs/components/Card/CardHeader.js.map +1 -1
- package/dist/cjs/components/Grid/GridColumn.js +3 -3
- package/dist/cjs/components/Grid/GridColumn.js.map +1 -1
- package/dist/cjs/components/PropertyValuePair/PropertyName.js +4 -2
- package/dist/cjs/components/PropertyValuePair/PropertyName.js.map +1 -1
- package/dist/cjs/components/PropertyValuePair/PropertyValue.js +6 -4
- package/dist/cjs/components/PropertyValuePair/PropertyValue.js.map +1 -1
- package/dist/cjs/components/PropertyValuePair/PropertyValuePair.js +13 -3
- package/dist/cjs/components/PropertyValuePair/PropertyValuePair.js.map +1 -1
- package/dist/cjs/components/Skeleton/Skeleton.js +30 -0
- package/dist/cjs/components/Skeleton/Skeleton.js.map +1 -0
- package/dist/cjs/components/Skeleton/classnames.js +6 -0
- package/dist/cjs/components/Skeleton/classnames.js.map +1 -0
- package/dist/cjs/components/Table/TableCell.js +3 -2
- package/dist/cjs/components/Table/TableCell.js.map +1 -1
- package/dist/cjs/components/TextField/useTextValidation.js.map +1 -1
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js +82 -40
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/AutoSuggestionList.js +6 -20
- package/dist/esm/components/AutoSuggestion/AutoSuggestionList.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js +70 -0
- package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -0
- package/dist/esm/components/AutoSuggestion/index.js +2 -2
- package/dist/esm/components/AutoSuggestion/index.js.map +1 -1
- package/dist/esm/components/Card/CardHeader.js +15 -14
- package/dist/esm/components/Card/CardHeader.js.map +1 -1
- package/dist/esm/components/Grid/GridColumn.js +3 -3
- package/dist/esm/components/Grid/GridColumn.js.map +1 -1
- package/dist/esm/components/PropertyValuePair/PropertyName.js +4 -2
- package/dist/esm/components/PropertyValuePair/PropertyName.js.map +1 -1
- package/dist/esm/components/PropertyValuePair/PropertyValue.js +6 -4
- package/dist/esm/components/PropertyValuePair/PropertyValue.js.map +1 -1
- package/dist/esm/components/PropertyValuePair/PropertyValuePair.js +13 -3
- package/dist/esm/components/PropertyValuePair/PropertyValuePair.js.map +1 -1
- package/dist/esm/components/Skeleton/Skeleton.js +24 -0
- package/dist/esm/components/Skeleton/Skeleton.js.map +1 -0
- package/dist/esm/components/Skeleton/classnames.js +3 -0
- package/dist/esm/components/Skeleton/classnames.js.map +1 -0
- package/dist/esm/components/Table/TableCell.js +4 -3
- package/dist/esm/components/Table/TableCell.js.map +1 -1
- package/dist/esm/components/TextField/useTextValidation.js.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/components/AutoSuggestion/AutoSuggestion.d.ts +8 -2
- package/dist/types/components/AutoSuggestion/AutoSuggestionList.d.ts +6 -4
- package/dist/types/components/AutoSuggestion/{SingleLineCodeEditor.d.ts → ExtendedCodeEditor.d.ts} +7 -4
- package/dist/types/components/AutoSuggestion/index.d.ts +3 -3
- package/dist/types/components/Card/CardHeader.d.ts +2 -2
- package/dist/types/components/Grid/GridColumn.d.ts +1 -0
- package/dist/types/components/PropertyValuePair/PropertyName.d.ts +7 -1
- package/dist/types/components/PropertyValuePair/PropertyValue.d.ts +7 -1
- package/dist/types/components/PropertyValuePair/PropertyValuePair.d.ts +5 -1
- package/dist/types/components/Skeleton/Skeleton.d.ts +13 -0
- package/dist/types/components/Skeleton/classnames.d.ts +1 -0
- package/dist/types/components/Table/TableCell.d.ts +7 -2
- package/dist/types/components/TextField/useTextValidation.d.ts +1 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/package.json +1 -1
- package/src/components/AutoSuggestion/AutoSuggestion.tsx +84 -31
- package/src/components/AutoSuggestion/AutoSuggestionList.tsx +11 -42
- package/src/components/AutoSuggestion/ExtendedCodeEditor.tsx +129 -0
- package/src/components/AutoSuggestion/index.ts +3 -11
- package/src/components/AutoSuggestion/tests/AutoSuggestionList.test.tsx +83 -84
- package/src/components/AutoSuggestion/tests/{SingleLineCodeEditor.test.tsx → ExtendedCodeEditor.test.tsx} +7 -7
- package/src/components/Card/CardHeader.tsx +23 -25
- package/src/components/Grid/GridColumn.tsx +15 -13
- package/src/components/Pagination/pagination.scss +6 -1
- package/src/components/PropertyValuePair/PropertyName.tsx +21 -2
- package/src/components/PropertyValuePair/PropertyValue.tsx +21 -5
- package/src/components/PropertyValuePair/PropertyValuePair.tsx +23 -4
- package/src/components/PropertyValuePair/propertyvalue.scss +6 -1
- package/src/components/PropertyValuePair/stories/PropertyName.stories.tsx +18 -0
- package/src/components/PropertyValuePair/stories/PropertyValue.stories.tsx +18 -0
- package/src/components/PropertyValuePair/stories/PropertyValueList.stories.tsx +33 -0
- package/src/components/PropertyValuePair/stories/PropertyValuePair.stories.tsx +29 -0
- package/src/components/Skeleton/Skeleton.stories.tsx +29 -0
- package/src/components/Skeleton/Skeleton.tsx +32 -0
- package/src/components/Skeleton/classnames.ts +3 -0
- package/src/components/Skeleton/skeleton.scss +1 -0
- package/src/components/Table/TableCell.tsx +12 -8
- package/src/components/Table/stories/TableCell.stories.tsx +30 -0
- package/src/components/Table/table.scss +96 -50
- package/src/components/TextField/stories/TextField.stories.tsx +21 -18
- package/src/components/TextField/useTextValidation.ts +82 -68
- package/src/components/index.scss +1 -0
- package/src/components/index.ts +1 -0
- package/src/extensions/codemirror/_codemirror.scss +1 -0
- package/src/index.ts +2 -0
- package/dist/cjs/components/AutoSuggestion/SingleLineCodeEditor.js +0 -53
- package/dist/cjs/components/AutoSuggestion/SingleLineCodeEditor.js.map +0 -1
- package/dist/esm/components/AutoSuggestion/SingleLineCodeEditor.js +0 -47
- package/dist/esm/components/AutoSuggestion/SingleLineCodeEditor.js.map +0 -1
- package/src/components/AutoSuggestion/SingleLineCodeEditor.tsx +0 -110
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import React, {ChangeEventHandler} from "react";
|
|
2
|
-
|
|
1
|
+
import React, { ChangeEventHandler } from "react";
|
|
2
|
+
|
|
3
|
+
import chars from "../../common/utils/characters";
|
|
3
4
|
|
|
4
5
|
export interface InvisibleCharacterWarningProps {
|
|
5
6
|
/**
|
|
6
7
|
* If set, the function is called after every value change what invisible characters have been detected.
|
|
8
|
+
* The input component must be controlled for this callback to be triggered.
|
|
7
9
|
*/
|
|
8
|
-
callback: (detectedCodePoints: Set<number>) => any
|
|
10
|
+
callback: (detectedCodePoints: Set<number>) => any;
|
|
9
11
|
/**
|
|
10
12
|
* The delay in milliseconds after which an input string should be checked. Only the most recent value will be checked.
|
|
11
13
|
* A higher value will reduce the probability that the typing stalls.
|
|
12
14
|
*
|
|
13
15
|
* Default: 500
|
|
14
16
|
*/
|
|
15
|
-
callbackDelay?: number
|
|
17
|
+
callbackDelay?: number;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
interface Props<T = Element> {
|
|
@@ -20,84 +22,96 @@ interface Props<T = Element> {
|
|
|
20
22
|
value?: string | ReadonlyArray<string> | number | undefined;
|
|
21
23
|
readOnly?: boolean | undefined;
|
|
22
24
|
disabled?: boolean | undefined;
|
|
23
|
-
onChange?: ChangeEventHandler<T
|
|
25
|
+
onChange?: ChangeEventHandler<T>;
|
|
24
26
|
/**
|
|
25
27
|
* If set, allows to be informed of invisible, hard to spot characters in the string value.
|
|
26
28
|
*/
|
|
27
|
-
invisibleCharacterWarning?: InvisibleCharacterWarningProps
|
|
29
|
+
invisibleCharacterWarning?: InvisibleCharacterWarningProps;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
/** Validates the string value for invisible characters. */
|
|
31
|
-
export const useTextValidation = <T>({value, onChange, invisibleCharacterWarning}: Props<T>) => {
|
|
32
|
-
const callback = invisibleCharacterWarning?.callback
|
|
33
|
-
const callbackDelay = invisibleCharacterWarning?.callbackDelay
|
|
33
|
+
export const useTextValidation = <T>({ value, onChange, invisibleCharacterWarning }: Props<T>) => {
|
|
34
|
+
const callback = invisibleCharacterWarning?.callback;
|
|
35
|
+
const callbackDelay = invisibleCharacterWarning?.callbackDelay;
|
|
34
36
|
const state = React.useRef<{
|
|
35
|
-
checkedValue?: string | ReadonlyArray<string> | number
|
|
36
|
-
timeout?: number
|
|
37
|
-
detectedCodePoints: Set<number
|
|
38
|
-
}>({detectedCodePoints: new Set()})
|
|
37
|
+
checkedValue?: string | ReadonlyArray<string> | number;
|
|
38
|
+
timeout?: number;
|
|
39
|
+
detectedCodePoints: Set<number>;
|
|
40
|
+
}>({ detectedCodePoints: new Set() });
|
|
39
41
|
const clearState = React.useCallback(() => {
|
|
40
|
-
state.current.timeout && clearTimeout(state.current.timeout)
|
|
41
|
-
state.current.checkedValue = undefined
|
|
42
|
-
state.current.detectedCodePoints = new Set()
|
|
43
|
-
}, [])
|
|
44
|
-
const detectionRegex = React.useMemo(() => chars.invisibleZeroWidthCharacters.createRegex(), [])
|
|
45
|
-
const detectIssues = React.useCallback(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
state.current.timeout && clearTimeout(state.current.timeout);
|
|
43
|
+
state.current.checkedValue = undefined;
|
|
44
|
+
state.current.detectedCodePoints = new Set();
|
|
45
|
+
}, []);
|
|
46
|
+
const detectionRegex = React.useMemo(() => chars.invisibleZeroWidthCharacters.createRegex(), []);
|
|
47
|
+
const detectIssues = React.useCallback(
|
|
48
|
+
(value: string): void => {
|
|
49
|
+
detectionRegex.lastIndex = 0;
|
|
50
|
+
let matchArray = detectionRegex.exec(value);
|
|
51
|
+
while (matchArray) {
|
|
52
|
+
const codePoint = matchArray[0].codePointAt(0);
|
|
53
|
+
if (codePoint) {
|
|
54
|
+
state.current.detectedCodePoints.add(codePoint);
|
|
55
|
+
}
|
|
56
|
+
matchArray = detectionRegex.exec(value);
|
|
52
57
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
},
|
|
59
|
+
[detectionRegex]
|
|
60
|
+
);
|
|
56
61
|
// Checks if the value contains any problematic characters with a small delay.
|
|
57
|
-
const checkValue = React.useCallback(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
checkValue(value)
|
|
76
|
-
clearState()
|
|
62
|
+
const checkValue = React.useCallback(
|
|
63
|
+
(value: string | ReadonlyArray<string> | number) => {
|
|
64
|
+
state.current.detectedCodePoints = new Set();
|
|
65
|
+
if (typeof value === "number") {
|
|
66
|
+
clearState();
|
|
67
|
+
} else if (typeof value === "string") {
|
|
68
|
+
detectIssues(value);
|
|
69
|
+
} else {
|
|
70
|
+
value.forEach((arrayValue) => detectIssues(arrayValue));
|
|
71
|
+
}
|
|
72
|
+
callback?.(state.current.detectedCodePoints);
|
|
73
|
+
},
|
|
74
|
+
[callback, clearState, detectIssues]
|
|
75
|
+
);
|
|
76
|
+
const scheduleCheck = React.useCallback(
|
|
77
|
+
(value: string | ReadonlyArray<string> | number) => {
|
|
78
|
+
if (state.current.checkedValue === value) {
|
|
79
|
+
return;
|
|
77
80
|
}
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
state.current.checkedValue = value;
|
|
82
|
+
state.current.timeout = window.setTimeout(() => {
|
|
83
|
+
if (state.current.checkedValue === value) {
|
|
84
|
+
checkValue(value);
|
|
85
|
+
clearState();
|
|
86
|
+
}
|
|
87
|
+
}, callbackDelay ?? 500);
|
|
88
|
+
},
|
|
89
|
+
[checkValue, clearState, callbackDelay]
|
|
90
|
+
);
|
|
80
91
|
// Do check via onChange handler
|
|
81
|
-
const wrappedOnChangeHandler: ChangeEventHandler<T> = React.useCallback(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
const wrappedOnChangeHandler: ChangeEventHandler<T> = React.useCallback(
|
|
93
|
+
(event) => {
|
|
94
|
+
const { value } = event.target as any;
|
|
95
|
+
if (value != null && typeof value === "string") {
|
|
96
|
+
scheduleCheck(value);
|
|
97
|
+
} else {
|
|
98
|
+
clearState();
|
|
99
|
+
}
|
|
100
|
+
onChange?.(event);
|
|
101
|
+
},
|
|
102
|
+
[clearState, onChange, scheduleCheck]
|
|
103
|
+
);
|
|
90
104
|
// No callback, return
|
|
91
|
-
if(!callback) {
|
|
92
|
-
return onChange
|
|
105
|
+
if (!callback) {
|
|
106
|
+
return onChange;
|
|
93
107
|
}
|
|
94
|
-
if(value == null && onChange == null) {
|
|
95
|
-
return onChange
|
|
108
|
+
if (value == null && onChange == null) {
|
|
109
|
+
return onChange;
|
|
96
110
|
}
|
|
97
|
-
if(value != null) {
|
|
98
|
-
scheduleCheck(value)
|
|
99
|
-
return onChange
|
|
111
|
+
if (value != null) {
|
|
112
|
+
scheduleCheck(value);
|
|
113
|
+
return onChange;
|
|
100
114
|
} else {
|
|
101
|
-
return wrappedOnChangeHandler
|
|
115
|
+
return wrappedOnChangeHandler;
|
|
102
116
|
}
|
|
103
|
-
}
|
|
117
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -34,6 +34,7 @@ export * from "./RadioButton/RadioButton";
|
|
|
34
34
|
export * from "./Select/Select";
|
|
35
35
|
export * from "./Separation/Divider";
|
|
36
36
|
export * from "./Separation/Spacing";
|
|
37
|
+
export * from "./Skeleton/Skeleton";
|
|
37
38
|
export * from "./Spinner/Spinner";
|
|
38
39
|
export * from "./Structure";
|
|
39
40
|
export * from "./Switch/Switch";
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
.CodeMirror {
|
|
10
10
|
clip-path: unset !important; // we may check later why they set inset(0) now
|
|
11
11
|
border-radius: $pt-border-radius;
|
|
12
|
+
height: 290px;
|
|
12
13
|
|
|
13
14
|
// get them a "border" like input boxes from blueprintjs
|
|
14
15
|
box-shadow: input-transition-shadow($input-shadow-color-focus), $pt-input-box-shadow;
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ClassNames as IntentClassNames } from "./common/Intent";
|
|
2
|
+
import * as Skeleton from "./components/Skeleton/classnames";
|
|
2
3
|
import * as TypographyClassNames from "./components/Typography/classnames";
|
|
3
4
|
import * as LegacyReplacements from "./legacy-replacements";
|
|
4
5
|
|
|
5
6
|
const ClassNames = {
|
|
7
|
+
Skeleton,
|
|
6
8
|
Typography: TypographyClassNames,
|
|
7
9
|
Intent: IntentClassNames,
|
|
8
10
|
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SingleLineCodeEditor = void 0;
|
|
7
|
-
require("codemirror/addon/display/placeholder.js");
|
|
8
|
-
require("codemirror/mode/sparql/sparql.js");
|
|
9
|
-
const react_1 = __importDefault(require("react"));
|
|
10
|
-
const react_codemirror2_1 = require("react-codemirror2");
|
|
11
|
-
const core_1 = require("@blueprintjs/core");
|
|
12
|
-
const constants_1 = require("../../configuration/constants");
|
|
13
|
-
/** A single-line code editor. */
|
|
14
|
-
const SingleLineCodeEditor = ({ setEditorInstance, onChange, onCursorChange, mode, initialValue, onFocusChange, onKeyDown, onSelection, enableTab = false, placeholder, showScrollBar = true }) => {
|
|
15
|
-
const singleLineInitialContent = react_1.default.useRef(initialValue.replace(/[\r\n]/g, " "));
|
|
16
|
-
return (react_1.default.createElement("div", { className: `${constants_1.CLASSPREFIX}-singlelinecodeeditor ${core_1.Classes.INPUT}` },
|
|
17
|
-
react_1.default.createElement(react_codemirror2_1.UnControlled, { editorDidMount: (editor) => {
|
|
18
|
-
editor.on("beforeChange", (_, change) => {
|
|
19
|
-
// Prevent the user from entering new-line characters, since this is supposed to be a one-line editor.
|
|
20
|
-
if (change.update && typeof change.update === "function" && change.text.length > 1) {
|
|
21
|
-
change.update(change.from, change.to, [change.text.join("")]);
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
});
|
|
25
|
-
setEditorInstance(editor);
|
|
26
|
-
}, value: singleLineInitialContent.current, onFocus: () => onFocusChange(true), onBlur: () => onFocusChange(false), options: {
|
|
27
|
-
mode: mode,
|
|
28
|
-
lineNumbers: false,
|
|
29
|
-
theme: "xq-light",
|
|
30
|
-
extraKeys: enableTab ? undefined : { Tab: false },
|
|
31
|
-
placeholder,
|
|
32
|
-
scrollbarStyle: showScrollBar ? "native" : "null"
|
|
33
|
-
}, onSelection: (_editor, data) => {
|
|
34
|
-
if (Array.isArray(data === null || data === void 0 ? void 0 : data.ranges)) {
|
|
35
|
-
onSelection(data.ranges
|
|
36
|
-
.map((r) => ({ from: r.from().ch, to: r.to().ch }))
|
|
37
|
-
.filter((r) => r.from !== r.to));
|
|
38
|
-
}
|
|
39
|
-
}, onCursor: (editor, data) => {
|
|
40
|
-
onCursorChange(data, editor.cursorCoords(true, "local"), editor.getScrollInfo());
|
|
41
|
-
}, onBeforeChange: (_editor, data, _, next) => {
|
|
42
|
-
// Reduce multiple lines to a single line
|
|
43
|
-
if (data.text.length > 1) {
|
|
44
|
-
_editor.setValue(data.text.join(""));
|
|
45
|
-
}
|
|
46
|
-
next();
|
|
47
|
-
}, onChange: (_editor, _data, value) => {
|
|
48
|
-
onChange(value);
|
|
49
|
-
}, onKeyDown: (_, event) => onKeyDown(event) })));
|
|
50
|
-
};
|
|
51
|
-
exports.SingleLineCodeEditor = SingleLineCodeEditor;
|
|
52
|
-
exports.default = exports.SingleLineCodeEditor;
|
|
53
|
-
//# sourceMappingURL=SingleLineCodeEditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SingleLineCodeEditor.js","sourceRoot":"","sources":["../../../../src/components/AutoSuggestion/SingleLineCodeEditor.tsx"],"names":[],"mappings":";;;;;;AAAA,mDAAgD;AAChD,4CAA0C;AAC1C,kDAA0B;AAC1B,yDAAqE;AACrE,4CAAiE;AAEjE,6DAAoE;AAiCpE,iCAAiC;AAC1B,MAAM,oBAAoB,GAAG,CAAC,EACjC,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,SAAS,EACT,WAAW,EACX,SAAS,GAAG,KAAK,EACjB,WAAW,EACX,aAAa,GAAG,IAAI,EACI,EAAE,EAAE;IAC5B,MAAM,wBAAwB,GAAG,eAAK,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAA;IACnF,OAAO,CACH,uCAAK,SAAS,EAAE,GAAG,uBAAM,yBAAyB,cAAmB,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AAE,CAAC,CAAC,EAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAC,CAAC,CAAC;yBACrD,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;iBAC1C;YACH,CAAC,EACD,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;gBACzB,cAAc,CACV,IAAI,EACJ,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,EAClC,MAAM,CAAC,aAAa,EAAE,CACzB,CAAC;YACJ,CAAC,EACD,cAAc,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;gBACvC,yCAAyC;gBACzC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;oBACtB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;iBACvC;gBACD,IAAI,EAAE,CAAA;YACV,CAAC,EACD,QAAQ,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;gBAChC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC,EAED,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,GACzC,CACE,CACP,CAAC;AACJ,CAAC,CAAC;AAnEW,QAAA,oBAAoB,wBAmE/B;AAEF,kBAAe,4BAAoB,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import "codemirror/addon/display/placeholder.js";
|
|
2
|
-
import "codemirror/mode/sparql/sparql.js";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { UnControlled as UnControlledEditor } from "react-codemirror2";
|
|
5
|
-
import { Classes as BlueprintClassNames } from "@blueprintjs/core";
|
|
6
|
-
import { CLASSPREFIX as eccgui } from "../../configuration/constants.js";
|
|
7
|
-
/** A single-line code editor. */
|
|
8
|
-
export var SingleLineCodeEditor = function (_a) {
|
|
9
|
-
var setEditorInstance = _a.setEditorInstance, onChange = _a.onChange, onCursorChange = _a.onCursorChange, mode = _a.mode, initialValue = _a.initialValue, onFocusChange = _a.onFocusChange, onKeyDown = _a.onKeyDown, onSelection = _a.onSelection, _b = _a.enableTab, enableTab = _b === void 0 ? false : _b, placeholder = _a.placeholder, _c = _a.showScrollBar, showScrollBar = _c === void 0 ? true : _c;
|
|
10
|
-
var singleLineInitialContent = React.useRef(initialValue.replace(/[\r\n]/g, " "));
|
|
11
|
-
return (React.createElement("div", { className: eccgui + "-singlelinecodeeditor " + BlueprintClassNames.INPUT },
|
|
12
|
-
React.createElement(UnControlledEditor, { editorDidMount: function (editor) {
|
|
13
|
-
editor.on("beforeChange", function (_, change) {
|
|
14
|
-
// Prevent the user from entering new-line characters, since this is supposed to be a one-line editor.
|
|
15
|
-
if (change.update && typeof change.update === "function" && change.text.length > 1) {
|
|
16
|
-
change.update(change.from, change.to, [change.text.join("")]);
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
19
|
-
});
|
|
20
|
-
setEditorInstance(editor);
|
|
21
|
-
}, value: singleLineInitialContent.current, onFocus: function () { return onFocusChange(true); }, onBlur: function () { return onFocusChange(false); }, options: {
|
|
22
|
-
mode: mode,
|
|
23
|
-
lineNumbers: false,
|
|
24
|
-
theme: "xq-light",
|
|
25
|
-
extraKeys: enableTab ? undefined : { Tab: false },
|
|
26
|
-
placeholder: placeholder,
|
|
27
|
-
scrollbarStyle: showScrollBar ? "native" : "null"
|
|
28
|
-
}, onSelection: function (_editor, data) {
|
|
29
|
-
if (Array.isArray(data === null || data === void 0 ? void 0 : data.ranges)) {
|
|
30
|
-
onSelection(data.ranges
|
|
31
|
-
.map(function (r) { return ({ from: r.from().ch, to: r.to().ch }); })
|
|
32
|
-
.filter(function (r) { return r.from !== r.to; }));
|
|
33
|
-
}
|
|
34
|
-
}, onCursor: function (editor, data) {
|
|
35
|
-
onCursorChange(data, editor.cursorCoords(true, "local"), editor.getScrollInfo());
|
|
36
|
-
}, onBeforeChange: function (_editor, data, _, next) {
|
|
37
|
-
// Reduce multiple lines to a single line
|
|
38
|
-
if (data.text.length > 1) {
|
|
39
|
-
_editor.setValue(data.text.join(""));
|
|
40
|
-
}
|
|
41
|
-
next();
|
|
42
|
-
}, onChange: function (_editor, _data, value) {
|
|
43
|
-
onChange(value);
|
|
44
|
-
}, onKeyDown: function (_, event) { return onKeyDown(event); } })));
|
|
45
|
-
};
|
|
46
|
-
export default SingleLineCodeEditor;
|
|
47
|
-
//# sourceMappingURL=SingleLineCodeEditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SingleLineCodeEditor.js","sourceRoot":"","sources":["../../../../src/components/AutoSuggestion/SingleLineCodeEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,yCAAyC,CAAA;AAChD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,YAAY,IAAI,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAC,OAAO,IAAI,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAC,WAAW,IAAI,MAAM,EAAC,MAAM,+BAA+B,CAAC;AAiCpE,iCAAiC;AACjC,MAAM,CAAC,IAAM,oBAAoB,GAAG,UAAC,EAYT;QAXxB,iBAAiB,uBAAA,EACjB,QAAQ,cAAA,EACR,cAAc,oBAAA,EACd,IAAI,UAAA,EACJ,YAAY,kBAAA,EACZ,aAAa,mBAAA,EACb,SAAS,eAAA,EACT,WAAW,iBAAA,EACX,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA,EACjB,WAAW,iBAAA,EACX,qBAAoB,EAApB,aAAa,mBAAG,I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
|
-
import "codemirror/mode/sparql/sparql.js";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import {UnControlled as UnControlledEditor} from "react-codemirror2";
|
|
5
|
-
import {Classes as BlueprintClassNames} from "@blueprintjs/core";
|
|
6
|
-
import {Editor as CodeMirrorEditor} from "codemirror";
|
|
7
|
-
import {CLASSPREFIX as eccgui} from "../../configuration/constants";
|
|
8
|
-
|
|
9
|
-
export interface IRange {
|
|
10
|
-
from: number
|
|
11
|
-
to: number
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface SingleLineCodeEditorProps {
|
|
15
|
-
// Is called with the editor instance that allows access via the CodeMirror API
|
|
16
|
-
setEditorInstance: (editor: CodeMirrorEditor) => any
|
|
17
|
-
// Called whenever the editor content changes
|
|
18
|
-
onChange: (value: string) => any
|
|
19
|
-
// Called when the cursor position changes
|
|
20
|
-
onCursorChange: (pos: any, coords: any, scrollinfo: any) => any
|
|
21
|
-
// The editor theme, e.g. "sparql"
|
|
22
|
-
mode?: string
|
|
23
|
-
// The initial value of the editor
|
|
24
|
-
initialValue: string
|
|
25
|
-
// Called when the focus status changes
|
|
26
|
-
onFocusChange: (focused: boolean) => any
|
|
27
|
-
// Called when the user presses a key
|
|
28
|
-
onKeyDown: (event: KeyboardEvent) => any
|
|
29
|
-
// Called when the user selects text
|
|
30
|
-
onSelection: (ranges: IRange[]) => any
|
|
31
|
-
// 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.
|
|
32
|
-
enableTab?: boolean
|
|
33
|
-
/** Placeholder tobe shown when no text has been entered, yet. */
|
|
34
|
-
placeholder?: string
|
|
35
|
-
showScrollBar?: boolean
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type IEditorProps = SingleLineCodeEditorProps;
|
|
39
|
-
|
|
40
|
-
/** A single-line code editor. */
|
|
41
|
-
export const SingleLineCodeEditor = ({
|
|
42
|
-
setEditorInstance,
|
|
43
|
-
onChange,
|
|
44
|
-
onCursorChange,
|
|
45
|
-
mode,
|
|
46
|
-
initialValue,
|
|
47
|
-
onFocusChange,
|
|
48
|
-
onKeyDown,
|
|
49
|
-
onSelection,
|
|
50
|
-
enableTab = false,
|
|
51
|
-
placeholder,
|
|
52
|
-
showScrollBar = true
|
|
53
|
-
}: SingleLineCodeEditorProps) => {
|
|
54
|
-
const singleLineInitialContent = React.useRef(initialValue.replace(/[\r\n]/g, " "))
|
|
55
|
-
return (
|
|
56
|
-
<div className={`${eccgui}-singlelinecodeeditor ${BlueprintClassNames.INPUT}`}>
|
|
57
|
-
<UnControlledEditor
|
|
58
|
-
editorDidMount={(editor: any) => {
|
|
59
|
-
editor.on("beforeChange", (_: any, change: any) => {
|
|
60
|
-
// Prevent the user from entering new-line characters, since this is supposed to be a one-line editor.
|
|
61
|
-
if (change.update && typeof change.update === "function" && change.text.length > 1) {
|
|
62
|
-
change.update(change.from, change.to, [change.text.join("")]);
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
});
|
|
66
|
-
setEditorInstance(editor);
|
|
67
|
-
}}
|
|
68
|
-
value={singleLineInitialContent.current}
|
|
69
|
-
onFocus={() => onFocusChange(true)}
|
|
70
|
-
onBlur={() => onFocusChange(false)}
|
|
71
|
-
options={{
|
|
72
|
-
mode: mode,
|
|
73
|
-
lineNumbers: false,
|
|
74
|
-
theme: "xq-light",
|
|
75
|
-
extraKeys: enableTab ? undefined : {Tab: false},
|
|
76
|
-
placeholder,
|
|
77
|
-
scrollbarStyle: showScrollBar ? "native" : "null"
|
|
78
|
-
}}
|
|
79
|
-
onSelection={(_editor, data) => {
|
|
80
|
-
if(Array.isArray(data?.ranges)) {
|
|
81
|
-
onSelection(data.ranges
|
|
82
|
-
.map((r: any) => ({from: r.from().ch, to: r.to().ch}))
|
|
83
|
-
.filter((r: any) => r.from !== r.to))
|
|
84
|
-
}
|
|
85
|
-
}}
|
|
86
|
-
onCursor={(editor, data) => {
|
|
87
|
-
onCursorChange(
|
|
88
|
-
data,
|
|
89
|
-
editor.cursorCoords(true, "local"),
|
|
90
|
-
editor.getScrollInfo()
|
|
91
|
-
);
|
|
92
|
-
}}
|
|
93
|
-
onBeforeChange={(_editor, data, _, next) => {
|
|
94
|
-
// Reduce multiple lines to a single line
|
|
95
|
-
if (data.text.length > 1) {
|
|
96
|
-
_editor.setValue(data.text.join(""))
|
|
97
|
-
}
|
|
98
|
-
next()
|
|
99
|
-
}}
|
|
100
|
-
onChange={(_editor, _data, value) => {
|
|
101
|
-
onChange(value);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
onKeyDown={(_, event) => onKeyDown(event)}
|
|
105
|
-
/>
|
|
106
|
-
</div>
|
|
107
|
-
);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export default SingleLineCodeEditor;
|