@eccenca/gui-elements 23.3.1 → 23.4.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 +23 -1
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js +3 -2
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/cjs/cmem/ActivityControl/SilkActivityControl.js +11 -6
- package/dist/cjs/cmem/ActivityControl/SilkActivityControl.js.map +1 -1
- package/dist/cjs/cmem/DateTimeDisplay/ElapsedDateTimeDisplay.js +7 -4
- package/dist/cjs/cmem/DateTimeDisplay/ElapsedDateTimeDisplay.js.map +1 -1
- 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/Icon/TestIcon.js +4 -4
- package/dist/cjs/components/Icon/TestIcon.js.map +1 -1
- package/dist/cjs/components/Icon/canonicalIconNames.js +5 -0
- package/dist/cjs/components/Icon/canonicalIconNames.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/cmem/ActivityControl/ActivityControlWidget.js +3 -2
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/esm/cmem/ActivityControl/SilkActivityControl.js +14 -9
- package/dist/esm/cmem/ActivityControl/SilkActivityControl.js.map +1 -1
- package/dist/esm/cmem/DateTimeDisplay/ElapsedDateTimeDisplay.js +8 -4
- package/dist/esm/cmem/DateTimeDisplay/ElapsedDateTimeDisplay.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/Icon/TestIcon.js +4 -4
- package/dist/esm/components/Icon/TestIcon.js.map +1 -1
- package/dist/esm/components/Icon/canonicalIconNames.js +5 -0
- package/dist/esm/components/Icon/canonicalIconNames.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/cmem/ActivityControl/ActivityControlTypes.d.ts +1 -0
- package/dist/types/cmem/ActivityControl/ActivityControlWidget.d.ts +4 -0
- package/dist/types/cmem/ActivityControl/SilkActivityControl.d.ts +8 -4
- package/dist/types/cmem/DateTimeDisplay/ElapsedDateTimeDisplay.d.ts +5 -4
- 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/Icon/TestIcon.d.ts +2 -1
- package/dist/types/components/Icon/canonicalIconNames.d.ts +1 -1
- 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 +6 -3
- package/src/cmem/ActivityControl/ActivityControlTypes.ts +2 -0
- package/src/cmem/ActivityControl/ActivityControlWidget.tsx +6 -0
- package/src/cmem/ActivityControl/SilkActivityControl.tsx +78 -46
- package/src/cmem/DateTimeDisplay/ElapsedDateTimeDisplay.tsx +12 -4
- 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/Icon/TestIcon.tsx +9 -13
- package/src/components/Icon/canonicalIconNames.tsx +10 -0
- package/src/components/Icon/stories/Icon.stories.tsx +17 -30
- package/src/components/Icon/stories/TestIcon.stories.tsx +8 -9
- package/src/components/OverviewItem/overviewitem.scss +27 -33
- 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,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":"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"}
|
|
@@ -1,110 +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 {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;
|