@eccenca/gui-elements 23.0.0-rc.3 → 23.0.0-rc.5
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 +15 -0
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js +2 -1
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/cjs/common/utils/colorDecideContrastvalue.js +18 -0
- package/dist/cjs/common/utils/colorDecideContrastvalue.js.map +1 -0
- package/dist/cjs/common/utils/getColorConfiguration.js +9 -5
- package/dist/cjs/common/utils/getColorConfiguration.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js +18 -16
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/AutoSuggestionList.js +15 -2
- package/dist/cjs/components/AutoSuggestion/AutoSuggestionList.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/SingleLineCodeEditor.js +3 -2
- package/dist/cjs/components/AutoSuggestion/SingleLineCodeEditor.js.map +1 -1
- package/dist/cjs/components/AutocompleteField/AutoCompleteField.js +12 -14
- package/dist/cjs/components/AutocompleteField/AutoCompleteField.js.map +1 -1
- package/dist/cjs/components/Breadcrumb/BreadcrumbList.js +28 -8
- package/dist/cjs/components/Breadcrumb/BreadcrumbList.js.map +1 -1
- package/dist/cjs/components/Card/Card.js +1 -1
- package/dist/cjs/components/Card/CardContent.js.map +1 -1
- package/dist/cjs/components/ContextOverlay/ContextMenu.js +3 -3
- package/dist/cjs/components/ContextOverlay/ContextMenu.js.map +1 -1
- package/dist/cjs/components/Form/FieldItem.js +4 -1
- package/dist/cjs/components/Form/FieldItem.js.map +1 -1
- package/dist/cjs/components/Form/FieldItemRow.js +7 -6
- package/dist/cjs/components/Form/FieldItemRow.js.map +1 -1
- package/dist/cjs/components/Grid/Grid.js +1 -1
- package/dist/cjs/components/Grid/Grid.js.map +1 -1
- package/dist/cjs/components/Grid/GridColumn.js +1 -1
- package/dist/cjs/components/Grid/GridColumn.js.map +1 -1
- package/dist/cjs/components/Grid/GridRow.js.map +1 -1
- package/dist/cjs/components/HoverToggler/HoverToggler.js +33 -0
- package/dist/cjs/components/HoverToggler/HoverToggler.js.map +1 -0
- package/dist/cjs/components/Icon/canonicalIconNames.js +45 -0
- package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/cjs/components/InteractionGate/InteractionGate.js +67 -0
- package/dist/cjs/components/InteractionGate/InteractionGate.js.map +1 -0
- package/dist/cjs/components/Pagination/Pagination.js.map +1 -1
- package/dist/cjs/components/Spinner/Spinner.js +6 -6
- package/dist/cjs/components/Spinner/Spinner.js.map +1 -1
- package/dist/cjs/components/Switch/Switch.js +4 -2
- package/dist/cjs/components/Switch/Switch.js.map +1 -1
- package/dist/cjs/components/Tabs/Tab.js +2 -1
- package/dist/cjs/components/Tabs/Tab.js.map +1 -1
- package/dist/cjs/components/Tabs/TabPanel.js +29 -0
- package/dist/cjs/components/Tabs/TabPanel.js.map +1 -0
- package/dist/cjs/components/Tag/Tag.js +2 -1
- package/dist/cjs/components/Tag/Tag.js.map +1 -1
- package/dist/cjs/components/Tag/TagList.js +1 -1
- package/dist/cjs/components/Tag/TagList.js.map +1 -1
- package/dist/cjs/components/TextField/TextField.js +3 -0
- package/dist/cjs/components/TextField/TextField.js.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.js +9 -2
- package/dist/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/cjs/components/Tree/Tree.js +37 -0
- package/dist/cjs/components/Tree/Tree.js.map +1 -0
- package/dist/cjs/index.js +14 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js +2 -1
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/esm/common/utils/colorDecideContrastvalue.js +14 -0
- package/dist/esm/common/utils/colorDecideContrastvalue.js.map +1 -0
- package/dist/esm/common/utils/getColorConfiguration.js +9 -5
- package/dist/esm/common/utils/getColorConfiguration.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js +35 -33
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/AutoSuggestionList.js +25 -2
- package/dist/esm/components/AutoSuggestion/AutoSuggestionList.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/SingleLineCodeEditor.js +3 -2
- package/dist/esm/components/AutoSuggestion/SingleLineCodeEditor.js.map +1 -1
- package/dist/esm/components/AutocompleteField/AutoCompleteField.js +18 -20
- package/dist/esm/components/AutocompleteField/AutoCompleteField.js.map +1 -1
- package/dist/esm/components/Breadcrumb/BreadcrumbList.js +9 -8
- package/dist/esm/components/Breadcrumb/BreadcrumbList.js.map +1 -1
- package/dist/esm/components/Card/Card.js +1 -1
- package/dist/esm/components/Card/CardContent.js.map +1 -1
- package/dist/esm/components/ContextOverlay/ContextMenu.js +3 -3
- package/dist/esm/components/ContextOverlay/ContextMenu.js.map +1 -1
- package/dist/esm/components/Form/FieldItem.js +4 -1
- package/dist/esm/components/Form/FieldItem.js.map +1 -1
- package/dist/esm/components/Form/FieldItemRow.js +7 -6
- package/dist/esm/components/Form/FieldItemRow.js.map +1 -1
- package/dist/esm/components/Grid/Grid.js +1 -1
- package/dist/esm/components/Grid/Grid.js.map +1 -1
- package/dist/esm/components/Grid/GridColumn.js +1 -1
- package/dist/esm/components/Grid/GridColumn.js.map +1 -1
- package/dist/esm/components/Grid/GridRow.js.map +1 -1
- package/dist/esm/components/HoverToggler/HoverToggler.js +37 -0
- package/dist/esm/components/HoverToggler/HoverToggler.js.map +1 -0
- package/dist/esm/components/Icon/canonicalIconNames.js +45 -0
- package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/esm/components/InteractionGate/InteractionGate.js +54 -0
- package/dist/esm/components/InteractionGate/InteractionGate.js.map +1 -0
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/Spinner/Spinner.js +7 -7
- package/dist/esm/components/Spinner/Spinner.js.map +1 -1
- package/dist/esm/components/Switch/Switch.js +4 -2
- package/dist/esm/components/Switch/Switch.js.map +1 -1
- package/dist/esm/components/Tabs/Tab.js +2 -1
- package/dist/esm/components/Tabs/Tab.js.map +1 -1
- package/dist/esm/components/Tabs/TabPanel.js +35 -0
- package/dist/esm/components/Tabs/TabPanel.js.map +1 -0
- package/dist/esm/components/Tag/Tag.js +2 -1
- package/dist/esm/components/Tag/Tag.js.map +1 -1
- package/dist/esm/components/Tag/TagList.js +1 -1
- package/dist/esm/components/Tag/TagList.js.map +1 -1
- package/dist/esm/components/TextField/TextField.js +3 -0
- package/dist/esm/components/TextField/TextField.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +9 -2
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/components/Tree/Tree.js +40 -0
- package/dist/esm/components/Tree/Tree.js.map +1 -0
- package/dist/esm/index.js +10 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/types/cmem/ActivityControl/ActivityControlTypes.d.ts +1 -0
- package/dist/types/cmem/markdown/Markdown.d.ts +1 -2
- package/dist/types/common/utils/colorDecideContrastvalue.d.ts +9 -0
- package/dist/types/components/AutoSuggestion/AutoSuggestion.d.ts +7 -1
- package/dist/types/components/AutoSuggestion/AutoSuggestionList.d.ts +3 -3
- package/dist/types/components/AutoSuggestion/SingleLineCodeEditor.d.ts +1 -1
- package/dist/types/components/AutocompleteField/AutoCompleteField.d.ts +1 -1
- package/dist/types/components/Card/CardContent.d.ts +2 -2
- package/dist/types/components/ContextOverlay/ContextMenu.d.ts +3 -1
- package/dist/types/components/Form/FieldItem.d.ts +6 -3
- package/dist/types/components/Form/FieldItemRow.d.ts +11 -3
- package/dist/types/components/Grid/Grid.d.ts +6 -1
- package/dist/types/components/Grid/GridColumn.d.ts +8 -1
- package/dist/types/components/Grid/GridRow.d.ts +7 -1
- package/dist/types/components/HoverToggler/HoverToggler.d.ts +24 -0
- package/dist/types/components/Icon/canonicalIconNames.d.ts +1 -1
- package/dist/types/components/InteractionGate/InteractionGate.d.ts +28 -0
- package/dist/types/components/Notification/Notification.d.ts +1 -1
- package/dist/types/components/Pagination/Pagination.d.ts +21 -4
- package/dist/types/components/Spinner/Spinner.d.ts +7 -1
- package/dist/types/components/Switch/Switch.d.ts +5 -1
- package/dist/types/components/Tabs/TabPanel.d.ts +21 -0
- package/dist/types/components/Tooltip/Tooltip.d.ts +12 -1
- package/dist/types/components/Tree/Tree.d.ts +43 -0
- package/dist/types/index.d.ts +6 -2
- package/package.json +3 -2
- package/src/cmem/ActivityControl/ActivityControlTypes.ts +3 -1
- package/src/cmem/ActivityControl/ActivityControlWidget.tsx +2 -1
- package/src/cmem/markdown/Markdown.tsx +1 -1
- package/src/common/utils/colorDecideContrastvalue.ts +28 -0
- package/src/common/utils/getColorConfiguration.ts +10 -5
- package/src/components/AutoSuggestion/AutoSuggestion.scss +16 -10
- package/src/components/AutoSuggestion/AutoSuggestion.tsx +81 -52
- package/src/components/AutoSuggestion/AutoSuggestionList.tsx +7 -3
- package/src/components/AutoSuggestion/SingleLineCodeEditor.tsx +8 -3
- package/src/components/AutoSuggestion/tests/AutoSuggestionList.test.tsx +1 -1
- package/src/components/AutoSuggestion/tests/SingleLineCodeEditor.test.tsx +2 -1
- package/src/components/AutocompleteField/AutoCompleteField.tsx +10 -8
- package/src/components/AutocompleteField/stories/AutoCompleteField.stories.tsx +15 -4
- package/src/components/Breadcrumb/BreadcrumbList.tsx +10 -8
- package/src/components/Breadcrumb/breadcrumb.scss +4 -0
- package/src/components/Breadcrumb/stories/BreadcrumbList.stories.tsx +1 -0
- package/src/components/Card/Card.tsx +1 -1
- package/src/components/Card/CardContent.tsx +2 -2
- package/src/components/ContextOverlay/ContextMenu.tsx +4 -0
- package/src/components/Form/FieldItem.tsx +6 -3
- package/src/components/Form/FieldItemRow.tsx +28 -6
- package/src/components/Form/form.scss +6 -0
- package/src/components/Grid/Grid.tsx +9 -3
- package/src/components/Grid/GridColumn.tsx +10 -2
- package/src/components/Grid/GridRow.tsx +8 -1
- package/src/components/HoverToggler/HoverToggler.stories.tsx +20 -0
- package/src/components/HoverToggler/HoverToggler.tsx +58 -0
- package/src/components/HoverToggler/hovertoggler.scss +45 -0
- package/src/components/Icon/canonicalIconNames.tsx +58 -0
- package/src/components/InteractionGate/InteractionGate.stories.tsx +32 -0
- package/src/components/InteractionGate/InteractionGate.tsx +76 -0
- package/src/components/InteractionGate/interactiongate.scss +11 -0
- package/src/components/Link/link.scss +9 -0
- package/src/components/Notification/Notification.tsx +1 -1
- package/src/components/Pagination/Pagination.tsx +22 -6
- package/src/components/SimpleTable/simpletable.scss +62 -2
- package/src/components/Spinner/Spinner.tsx +13 -5
- package/src/components/Spinner/spinner.scss +14 -0
- package/src/components/Switch/Switch.tsx +10 -5
- package/src/components/Tabs/Tab.tsx +2 -1
- package/src/components/Tabs/TabPanel.tsx +43 -0
- package/src/components/Tabs/stories/TabPanel.stories.tsx +21 -0
- package/src/components/Tabs/tabs.scss +1 -5
- package/src/components/Tag/Tag.tsx +2 -1
- package/src/components/Tag/TagList.tsx +1 -1
- package/src/components/Tag/tag.scss +1 -0
- package/src/components/TextField/TextField.tsx +4 -0
- package/src/components/TextField/stories/TextField.stories.tsx +1 -0
- package/src/components/TextField/textfield.scss +25 -1
- package/src/components/Tooltip/Tooltip.stories.tsx +15 -7
- package/src/components/Tooltip/Tooltip.tsx +24 -1
- package/src/components/Tooltip/tooltip.scss +4 -0
- package/src/components/Tree/Tree.stories.tsx +63 -0
- package/src/components/Tree/Tree.tsx +61 -0
- package/src/components/Tree/tree.scss +28 -0
- package/src/includes/carbon-components/_variables.scss +3 -1
- package/src/index.scss +5 -2
- package/src/index.ts +16 -5
|
@@ -13,8 +13,9 @@ import {
|
|
|
13
13
|
Tooltip,
|
|
14
14
|
} from "./../../";
|
|
15
15
|
import { ISuggestionWithReplacementInfo } from "./AutoSuggestion";
|
|
16
|
+
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
16
17
|
|
|
17
|
-
export interface IDropdownProps {
|
|
18
|
+
export interface IDropdownProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
18
19
|
// The options of the drop down
|
|
19
20
|
options: Array<ISuggestionWithReplacementInfo>;
|
|
20
21
|
// Called when an item has been selected from the drop down
|
|
@@ -78,6 +79,8 @@ export const AutoSuggestionList = ({
|
|
|
78
79
|
left,
|
|
79
80
|
currentlyFocusedIndex,
|
|
80
81
|
itemToHighlight,
|
|
82
|
+
style,
|
|
83
|
+
...otherDivProps
|
|
81
84
|
}: IDropdownProps) => {
|
|
82
85
|
const [hoveredItem, setHoveredItem] = React.useState<
|
|
83
86
|
ISuggestionWithReplacementInfo | undefined
|
|
@@ -132,8 +135,9 @@ export const AutoSuggestionList = ({
|
|
|
132
135
|
if (!loadingOrHasSuggestions || !isOpen) return null;
|
|
133
136
|
return (
|
|
134
137
|
<div
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
{...otherDivProps}
|
|
139
|
+
className={`${eccgui}-autosuggestion__dropdown`}
|
|
140
|
+
style={{ ...style, left }}
|
|
137
141
|
ref={dropdownRef}
|
|
138
142
|
>
|
|
139
143
|
{loading ? (
|
|
@@ -4,6 +4,7 @@ import React from "react";
|
|
|
4
4
|
import { Controlled as ControlledEditor } from "react-codemirror2";
|
|
5
5
|
import { Classes as BlueprintClassNames } from "@blueprintjs/core";
|
|
6
6
|
import {Editor as CodeMirrorEditor} from "codemirror";
|
|
7
|
+
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
7
8
|
|
|
8
9
|
export interface IEditorProps {
|
|
9
10
|
// Is called with the editor instance that allows access via the CodeMirror API
|
|
@@ -11,7 +12,7 @@ export interface IEditorProps {
|
|
|
11
12
|
// Called whenever the editor content changes
|
|
12
13
|
onChange: (value: string) => any
|
|
13
14
|
// Called when the cursor position changes
|
|
14
|
-
onCursorChange: (pos: any, coords: any) => any
|
|
15
|
+
onCursorChange: (pos: any, coords: any, scrollinfo: any) => any
|
|
15
16
|
// The editor theme, e.g. "sparql"
|
|
16
17
|
mode?: string
|
|
17
18
|
// The initial value of the editor
|
|
@@ -49,7 +50,7 @@ const SingleLineCodeEditor = ({
|
|
|
49
50
|
showScrollBar = true
|
|
50
51
|
}: IEditorProps) => {
|
|
51
52
|
return (
|
|
52
|
-
<div className={
|
|
53
|
+
<div className={`${eccgui}-singlelinecodeeditor ${BlueprintClassNames.INPUT}`}>
|
|
53
54
|
<ControlledEditor
|
|
54
55
|
editorDidMount={(editor) => {
|
|
55
56
|
editor.on("beforeChange", (_, change) => {
|
|
@@ -82,7 +83,11 @@ const SingleLineCodeEditor = ({
|
|
|
82
83
|
}
|
|
83
84
|
}}
|
|
84
85
|
onCursor={(editor, data) => {
|
|
85
|
-
onCursorChange(
|
|
86
|
+
onCursorChange(
|
|
87
|
+
data,
|
|
88
|
+
editor.cursorCoords(true, "local"),
|
|
89
|
+
editor.getScrollInfo()
|
|
90
|
+
);
|
|
86
91
|
}}
|
|
87
92
|
onBeforeChange={(_editor, _data, value) => {
|
|
88
93
|
const trimmedValue = value.replace(/\n/g, "");
|
|
@@ -71,7 +71,7 @@ describe("Dropdown list", () => {
|
|
|
71
71
|
left: 10
|
|
72
72
|
}
|
|
73
73
|
const {container} = render(<AutoSuggestionList {...props} />)
|
|
74
|
-
const parentDiv:HTMLElement = container.querySelector(
|
|
74
|
+
const parentDiv:HTMLElement = container.querySelector(`.${eccgui}-autosuggestion__dropdown`)!!
|
|
75
75
|
const leftOffset = Number(parentDiv.style.left.replace(/px$/,""));
|
|
76
76
|
expect(leftOffset).toBe(props.left)
|
|
77
77
|
})
|
|
@@ -5,6 +5,7 @@ import SingleLineEditor, {
|
|
|
5
5
|
IEditorProps,
|
|
6
6
|
} from "../SingleLineCodeEditor";
|
|
7
7
|
import CodeMirror from "codemirror";
|
|
8
|
+
import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
|
|
8
9
|
|
|
9
10
|
describe("SingleLineCodeEditor", () => {
|
|
10
11
|
let props: IEditorProps,
|
|
@@ -26,7 +27,7 @@ describe("SingleLineCodeEditor", () => {
|
|
|
26
27
|
|
|
27
28
|
it("should render properly", () => {
|
|
28
29
|
const { container } = render(<SingleLineEditor {...props} />);
|
|
29
|
-
expect(container.querySelector(
|
|
30
|
+
expect(container.querySelector(`.${eccgui}-singlelinecodeeditor`)).not.toBeNull();
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
it("should set the editorInstance immediately it's mounted", () => {
|
|
@@ -149,17 +149,15 @@ AutoCompleteField.defaultProps = {
|
|
|
149
149
|
|
|
150
150
|
/** Style object to be used in menu option items. */
|
|
151
151
|
export interface IElementWidth {
|
|
152
|
-
|
|
152
|
+
minWidth: string;
|
|
153
|
+
//width: string
|
|
153
154
|
maxWidth: string
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
/** Hook that returns the element width of the given ref.*/
|
|
157
158
|
const elementWidth = (elRef: IRefObject<HTMLInputElement> | null): IElementWidth => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
} else {
|
|
161
|
-
return { width: "40rem", maxWidth: "90vw" }
|
|
162
|
-
}
|
|
159
|
+
const minWidth = (elRef && elRef.current) ? elRef.current.offsetWidth + "px" : "20rem";
|
|
160
|
+
return { minWidth, maxWidth: "90vw" };
|
|
163
161
|
}
|
|
164
162
|
|
|
165
163
|
/** Auto-complete input widget. */
|
|
@@ -194,6 +192,7 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
194
192
|
const [filtered, setFiltered] = useState<T[]>([]);
|
|
195
193
|
|
|
196
194
|
const BlueprintSuggestAutocomplete = Suggest.ofType<T>();
|
|
195
|
+
const readOnly = !!otherProps.inputProps?.readOnly
|
|
197
196
|
|
|
198
197
|
// Sets the query to the item value if it has a valid string value
|
|
199
198
|
const setQueryToSelectedValue = (item?: T) => {
|
|
@@ -223,7 +222,7 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
223
222
|
);
|
|
224
223
|
|
|
225
224
|
useEffect(() => {
|
|
226
|
-
if (!disabled && hasFocus) {
|
|
225
|
+
if (!disabled && !readOnly && hasFocus) {
|
|
227
226
|
setListLoading(true);
|
|
228
227
|
const timeout: number = window.setTimeout(async () => {
|
|
229
228
|
fetchQueryResults(query);
|
|
@@ -351,7 +350,7 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
351
350
|
return <Notification danger={true} message={requestError} />
|
|
352
351
|
}
|
|
353
352
|
// Optional clear button to reset the selected value
|
|
354
|
-
const clearButton = reset &&
|
|
353
|
+
const clearButton = !readOnly && !disabled && reset &&
|
|
355
354
|
selectedItem != null &&
|
|
356
355
|
reset.resettableValue(selectedItem) ? (
|
|
357
356
|
<IconButton
|
|
@@ -370,7 +369,9 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
370
369
|
onBlur: handleOnFocusOut,
|
|
371
370
|
onFocus: handleOnFocusIn,
|
|
372
371
|
...otherProps.inputProps,
|
|
372
|
+
title: (selectedItem !== undefined && (readOnly || disabled)) ? itemValueString(selectedItem) : otherProps.inputProps?.title,
|
|
373
373
|
};
|
|
374
|
+
const preventOverlayOnReadonly = readOnly ? { isOpen: false } : {}
|
|
374
375
|
const updatedContextOverlayProps: Partial<Omit<ContextOverlayProps, "content" | "children">> = {
|
|
375
376
|
minimal: true,
|
|
376
377
|
placement: "bottom-start",
|
|
@@ -378,6 +379,7 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
378
379
|
rootBoundary: "viewport",
|
|
379
380
|
onClosed: onPopoverClose,
|
|
380
381
|
...otherProps.contextOverlayProps,
|
|
382
|
+
...preventOverlayOnReadonly,
|
|
381
383
|
}
|
|
382
384
|
if(selectedItem !== undefined) {
|
|
383
385
|
// Makes sure that even when an empty string is selected, the placeholder won't be shown.
|
|
@@ -20,6 +20,7 @@ export const Default = Template.bind({});
|
|
|
20
20
|
export const AdaptQueryAfterSelection = Template.bind({})
|
|
21
21
|
export const AllowReset = Template.bind({})
|
|
22
22
|
export const AllowCustomValues = Template.bind({})
|
|
23
|
+
export const ReadOnlyState = Template.bind({})
|
|
23
24
|
|
|
24
25
|
// Renders string values as string
|
|
25
26
|
const defaultRenderer = (item: string) => item
|
|
@@ -37,7 +38,7 @@ const defaultArgs: IAutoCompleteFieldProps<string, string> = {
|
|
|
37
38
|
console.log(`Entry '${elem}' selected!`)
|
|
38
39
|
},
|
|
39
40
|
itemValueSelector: defaultRenderer,
|
|
40
|
-
noResultText: "No result"
|
|
41
|
+
noResultText: "No result",
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
// Changes the search query for the selected item, e.g. when the rendered item text should be different from the query finding this item.
|
|
@@ -67,9 +68,19 @@ const allowCustomValues: IAutoCompleteFieldProps<string, string> = {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
|
|
71
|
+
// Changes the search query for the selected item, e.g. when the rendered item text should be different from the query finding this item.
|
|
72
|
+
const readOnlyState: IAutoCompleteFieldProps<string, string> = {
|
|
73
|
+
...defaultArgs,
|
|
74
|
+
initialValue: "search item B",
|
|
75
|
+
inputProps: {
|
|
76
|
+
readOnly: true
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
70
80
|
Default.args = defaultArgs;
|
|
71
|
-
AdaptQueryAfterSelection.args = adaptQueryAfterSelection
|
|
72
|
-
AllowReset.args = resetSelection
|
|
73
|
-
AllowCustomValues.args = allowCustomValues
|
|
81
|
+
AdaptQueryAfterSelection.args = adaptQueryAfterSelection;
|
|
82
|
+
AllowReset.args = resetSelection;
|
|
83
|
+
AllowCustomValues.args = allowCustomValues;
|
|
84
|
+
ReadOnlyState.args = readOnlyState;
|
|
74
85
|
|
|
75
86
|
export default AutoCompleteFieldStory
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, {useCallback} from "react";
|
|
2
2
|
import {
|
|
3
3
|
Breadcrumbs2 as BlueprintBreadcrumbList,
|
|
4
4
|
Breadcrumbs2Props as BlueprintBreadcrumbsProps,
|
|
@@ -60,7 +60,7 @@ function BreadcrumbList({
|
|
|
60
60
|
latenOverflow = false,
|
|
61
61
|
...otherBlueprintBreadcrumbsProps
|
|
62
62
|
}: BreadcrumbListProps) {
|
|
63
|
-
const renderBreadcrumb = (propsBreadcrumb: BreadcrumbItemProps) => {
|
|
63
|
+
const renderBreadcrumb = useCallback((propsBreadcrumb: BreadcrumbItemProps) => {
|
|
64
64
|
const {onClick, ...otherProps} = propsBreadcrumb;
|
|
65
65
|
return (
|
|
66
66
|
<BreadcrumbItem
|
|
@@ -75,11 +75,15 @@ function BreadcrumbList({
|
|
|
75
75
|
}
|
|
76
76
|
/>
|
|
77
77
|
);
|
|
78
|
-
};
|
|
78
|
+
}, [onItemClick]);
|
|
79
79
|
|
|
80
|
-
const renderCurrentBreadcrumb = (propsBreadcrumb: BreadcrumbItemProps) => {
|
|
80
|
+
const renderCurrentBreadcrumb = React.useCallback((propsBreadcrumb: BreadcrumbItemProps) => {
|
|
81
81
|
return <BreadcrumbItem {...propsBreadcrumb} current={true} /*itemDivider={itemDivider}*/ />;
|
|
82
|
-
};
|
|
82
|
+
}, []);
|
|
83
|
+
|
|
84
|
+
const overflowListProps = React.useMemo(() => ignoreOverflow ? {
|
|
85
|
+
minVisibleItems: otherBlueprintBreadcrumbsProps.items.length,
|
|
86
|
+
} : {}, [ignoreOverflow, otherBlueprintBreadcrumbsProps.items.length])
|
|
83
87
|
|
|
84
88
|
return (
|
|
85
89
|
<BlueprintBreadcrumbList
|
|
@@ -93,9 +97,7 @@ function BreadcrumbList({
|
|
|
93
97
|
minVisibleItems={1}
|
|
94
98
|
breadcrumbRenderer={renderBreadcrumb}
|
|
95
99
|
currentBreadcrumbRenderer={renderCurrentBreadcrumb}
|
|
96
|
-
overflowListProps={
|
|
97
|
-
minVisibleItems: otherBlueprintBreadcrumbsProps.items.length,
|
|
98
|
-
} : {}}
|
|
100
|
+
overflowListProps={overflowListProps}
|
|
99
101
|
/>
|
|
100
102
|
);
|
|
101
103
|
}
|
|
@@ -21,6 +21,7 @@ Default.args = {
|
|
|
21
21
|
{text: "Main click category", onClick: () => alert("Breadcrumb click")},
|
|
22
22
|
{text: <div>Sub category item</div>, href: "#"},
|
|
23
23
|
{text: <span>Disabled breadcrumb with a very long title</span>, disabled: true},
|
|
24
|
+
{text: <a href="#wrong">Wrongly placed link inside link</a>},
|
|
24
25
|
{text: "Current breadcrumb item", current: true}
|
|
25
26
|
],
|
|
26
27
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
3
3
|
|
|
4
|
-
export interface
|
|
4
|
+
export interface CardContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -12,7 +12,7 @@ function CardContent({
|
|
|
12
12
|
children,
|
|
13
13
|
className='',
|
|
14
14
|
...otherProps
|
|
15
|
-
}:
|
|
15
|
+
}: CardContentProps) {
|
|
16
16
|
return (
|
|
17
17
|
<div
|
|
18
18
|
{...otherProps}
|
|
@@ -38,6 +38,8 @@ interface ContextMenuProps extends TestableComponent {
|
|
|
38
38
|
* Props to spread to `ContextOverlay` that is used to display the dropdown.
|
|
39
39
|
*/
|
|
40
40
|
contextOverlayProps?: Partial<Omit<ContextOverlayProps, "content" | "children" | "className">>
|
|
41
|
+
/** Disables the button to open the menu. */
|
|
42
|
+
disabled?: boolean
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
/**
|
|
@@ -49,6 +51,7 @@ function ContextMenu({
|
|
|
49
51
|
togglerElement = "item-moremenu",
|
|
50
52
|
togglerText = "Show more options",
|
|
51
53
|
contextOverlayProps,
|
|
54
|
+
disabled,
|
|
52
55
|
togglerLarge = false,
|
|
53
56
|
/* FIXME: The Tooltip component can interfere with the opened menu, since it is implemented via portal and may cover the menu,
|
|
54
57
|
so by default we use the title attribute instead of Tooltip. */
|
|
@@ -68,6 +71,7 @@ function ContextMenu({
|
|
|
68
71
|
name={[togglerElement]}
|
|
69
72
|
text={togglerText}
|
|
70
73
|
large={togglerLarge}
|
|
74
|
+
disabled={!!disabled}
|
|
71
75
|
data-test-id={restProps["data-test-id"]}
|
|
72
76
|
/>
|
|
73
77
|
) : (
|
|
@@ -13,7 +13,7 @@ import {TestableComponent} from "../interfaces";
|
|
|
13
13
|
* input id could be created when not given
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
interface
|
|
16
|
+
export interface FieldItemProps extends React.HTMLAttributes<HTMLDivElement>, TestableComponent {
|
|
17
17
|
hasStatePrimary?: boolean
|
|
18
18
|
hasStateSuccess?: boolean
|
|
19
19
|
hasStateWarning?: boolean
|
|
@@ -26,6 +26,9 @@ interface IProps extends TestableComponent {
|
|
|
26
26
|
messageText?: string
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Form element that manages the combination of label, helper texts, input element and feedback messages.
|
|
31
|
+
*/
|
|
29
32
|
function FieldItem({
|
|
30
33
|
hasStatePrimary = false,
|
|
31
34
|
hasStateSuccess = false,
|
|
@@ -38,7 +41,7 @@ function FieldItem({
|
|
|
38
41
|
helperText,
|
|
39
42
|
messageText,
|
|
40
43
|
...otherProps
|
|
41
|
-
}:
|
|
44
|
+
}: FieldItemProps) {
|
|
42
45
|
let classIntent = "";
|
|
43
46
|
switch (true) {
|
|
44
47
|
case hasStatePrimary:
|
|
@@ -79,10 +82,10 @@ function FieldItem({
|
|
|
79
82
|
|
|
80
83
|
return (
|
|
81
84
|
<div
|
|
82
|
-
data-test-id={otherProps["data-test-id"]}
|
|
83
85
|
className={
|
|
84
86
|
`${eccgui}-fielditem` + (className ? " " + className : "") + (disabled ? ` ${eccgui}-fielditem--disabled` : "")
|
|
85
87
|
}
|
|
88
|
+
{...otherProps}
|
|
86
89
|
>
|
|
87
90
|
{label}
|
|
88
91
|
{userhelp}
|
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export interface FieldItemRowProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* If set to `true` all `FieldItem` childrens have the same width.
|
|
7
|
+
*/
|
|
8
|
+
justifyItemWidths?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Allows to display `FieldItem` children horizontally in one row.
|
|
13
|
+
*/
|
|
14
|
+
function FieldItemRow({
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
|
+
justifyItemWidths = false,
|
|
18
|
+
...otherProps
|
|
19
|
+
}: FieldItemRowProps) {
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
className={
|
|
23
|
+
`${eccgui}-fielditem__row` +
|
|
24
|
+
(justifyItemWidths ? ` ${eccgui}-fielditem__row--justified` : "") +
|
|
25
|
+
(className ? ` ${className}` : "")
|
|
26
|
+
}
|
|
27
|
+
{...otherProps}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
10
32
|
}
|
|
11
33
|
|
|
12
34
|
export default FieldItemRow;
|
|
@@ -2,14 +2,20 @@ import React from "react";
|
|
|
2
2
|
// import PropTypes from 'prop-types';
|
|
3
3
|
import { Grid as CarbonGrid } from "carbon-components-react";
|
|
4
4
|
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
5
|
+
import {GridDefaultProps} from "carbon-components-react/lib/components/Grid/Grid";
|
|
6
|
+
|
|
7
|
+
interface GridProps extends GridDefaultProps {
|
|
8
|
+
verticalStretchable?: boolean
|
|
9
|
+
useAbsoluteSpace?: boolean
|
|
10
|
+
}
|
|
5
11
|
|
|
6
12
|
function Grid({
|
|
7
13
|
children,
|
|
8
|
-
verticalStretchable,
|
|
9
|
-
useAbsoluteSpace,
|
|
14
|
+
verticalStretchable = false,
|
|
15
|
+
useAbsoluteSpace = false,
|
|
10
16
|
className = '',
|
|
11
17
|
...restProps
|
|
12
|
-
}:
|
|
18
|
+
}: GridProps) {
|
|
13
19
|
return (
|
|
14
20
|
<CarbonGrid
|
|
15
21
|
{...restProps}
|
|
@@ -2,6 +2,14 @@ import React from "react";
|
|
|
2
2
|
// import PropTypes from 'prop-types';
|
|
3
3
|
import { Column as CarbonColumn } from "carbon-components-react";
|
|
4
4
|
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
5
|
+
import {ColumnDefaultProps} from "carbon-components-react/lib/components/Grid/Column";
|
|
6
|
+
|
|
7
|
+
interface GridColumnProps extends ColumnDefaultProps {
|
|
8
|
+
small?: boolean
|
|
9
|
+
medium?: boolean
|
|
10
|
+
full?: boolean
|
|
11
|
+
verticalAlign?: "center"
|
|
12
|
+
}
|
|
5
13
|
|
|
6
14
|
function GridColumn({
|
|
7
15
|
children,
|
|
@@ -9,9 +17,9 @@ function GridColumn({
|
|
|
9
17
|
small = false,
|
|
10
18
|
medium = false,
|
|
11
19
|
full = true,
|
|
12
|
-
verticalAlign
|
|
20
|
+
verticalAlign,
|
|
13
21
|
...otherProps
|
|
14
|
-
}:
|
|
22
|
+
}: GridColumnProps) {
|
|
15
23
|
let sizeConfig = {};
|
|
16
24
|
if (small) sizeConfig = { md:2, lg:3 };
|
|
17
25
|
if (medium) sizeConfig = { md:3, lg:5 };
|
|
@@ -2,6 +2,13 @@ import React from "react";
|
|
|
2
2
|
// import PropTypes from 'prop-types';
|
|
3
3
|
import { Row as CarbonRow } from "carbon-components-react";
|
|
4
4
|
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
5
|
+
import {RowDefaultProps} from "carbon-components-react/lib/components/Grid/Row";
|
|
6
|
+
|
|
7
|
+
interface GridRowProps extends RowDefaultProps {
|
|
8
|
+
dontWrapColumns?: boolean
|
|
9
|
+
fullHeight?: boolean
|
|
10
|
+
verticalStretched?: boolean
|
|
11
|
+
}
|
|
5
12
|
|
|
6
13
|
function GridRow({
|
|
7
14
|
children,
|
|
@@ -10,7 +17,7 @@ function GridRow({
|
|
|
10
17
|
fullHeight = false,
|
|
11
18
|
verticalStretched,
|
|
12
19
|
...otherProps
|
|
13
|
-
}:
|
|
20
|
+
}: GridRowProps) {
|
|
14
21
|
return (
|
|
15
22
|
<CarbonRow
|
|
16
23
|
{...otherProps}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ComponentStory, ComponentMeta } from "@storybook/react";
|
|
3
|
+
import { HoverToggler } from "./../../index";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Components/HoverToggler",
|
|
7
|
+
component: HoverToggler,
|
|
8
|
+
argTypes: {
|
|
9
|
+
},
|
|
10
|
+
} as ComponentMeta<typeof HoverToggler>;
|
|
11
|
+
|
|
12
|
+
const Template: ComponentStory<typeof HoverToggler> = (args) => (
|
|
13
|
+
<HoverToggler {...args} style={{height: "auto"}} />
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const Default = Template.bind({});
|
|
17
|
+
Default.args = {
|
|
18
|
+
baseContent: "Base content.",
|
|
19
|
+
hoverContent: <>Content<br/>on <a href="#">hover</a>.</>
|
|
20
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
3
|
+
|
|
4
|
+
interface HoverTogglerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
5
|
+
/**
|
|
6
|
+
* Additional CSS class name.
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The content that is shown when not hovered.
|
|
11
|
+
*/
|
|
12
|
+
baseContent: JSX.Element;
|
|
13
|
+
baseContentProps?: Omit<React.HTMLAttributes<HTMLDivElement>, "children">;
|
|
14
|
+
/**
|
|
15
|
+
* The content that is shown when hovered.
|
|
16
|
+
*/
|
|
17
|
+
hoverContent: JSX.Element;
|
|
18
|
+
hoverContentProps?: Omit<React.HTMLAttributes<HTMLDivElement>, "children">;
|
|
19
|
+
/**
|
|
20
|
+
* Display as inline element.
|
|
21
|
+
*/
|
|
22
|
+
inline?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Displays a specific element. Displays another element when hovered. */
|
|
26
|
+
export const HoverToggler = ({
|
|
27
|
+
className = "",
|
|
28
|
+
baseContent,
|
|
29
|
+
baseContentProps,
|
|
30
|
+
hoverContent,
|
|
31
|
+
hoverContentProps,
|
|
32
|
+
inline = false,
|
|
33
|
+
style,
|
|
34
|
+
...otherProps
|
|
35
|
+
}: HoverTogglerProps) => {
|
|
36
|
+
return (<div
|
|
37
|
+
className={
|
|
38
|
+
`${eccgui}-hovertoggler__wrapper` +
|
|
39
|
+
(inline ? ` ${eccgui}-hovertoggler--inline` : "")
|
|
40
|
+
}
|
|
41
|
+
style={style}
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
className={
|
|
45
|
+
`${eccgui}-hovertoggler` +
|
|
46
|
+
(className ? ` ${className}` : "")
|
|
47
|
+
}
|
|
48
|
+
{...otherProps}
|
|
49
|
+
>
|
|
50
|
+
<div className={`${eccgui}-hovertoggler__basecontent`}>
|
|
51
|
+
<div className={`${eccgui}-hovertoggler__wrappercontent`} {...baseContentProps}>{ baseContent }</div>
|
|
52
|
+
</div>
|
|
53
|
+
<div className={`${eccgui}-hovertoggler__hovercontent`}>
|
|
54
|
+
<div tabIndex={0} className={`${eccgui}-hovertoggler__wrappercontent`} {...hoverContentProps}>{ hoverContent }</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>);
|
|
58
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.#{$eccgui}-hovertoggler__wrapper {
|
|
2
|
+
width: 100%;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: flex-start;
|
|
6
|
+
align-items: center;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.#{$eccgui}-hovertoggler--inline {
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
width: auto;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.#{$eccgui}-hovertoggler {
|
|
15
|
+
display: flex;
|
|
16
|
+
width: 200%;
|
|
17
|
+
justify-content: flex-start;
|
|
18
|
+
align-items: stretch;
|
|
19
|
+
flex-shrink: 0;
|
|
20
|
+
|
|
21
|
+
.#{$eccgui}-hovertoggler--inline > & {
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.#{$eccgui}-hovertoggler__basecontent,
|
|
27
|
+
.#{$eccgui}-hovertoggler__hovercontent {
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
order: 1;
|
|
30
|
+
flex-grow: 0;
|
|
31
|
+
flex-shrink: 0;
|
|
32
|
+
width: 50%;
|
|
33
|
+
display: flex;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
align-items: center;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.#{$eccgui}-hovertoggler__hovercontent {
|
|
39
|
+
order: 2;
|
|
40
|
+
|
|
41
|
+
.#{$eccgui}-hovertoggler:hover > &,
|
|
42
|
+
&:focus-within {
|
|
43
|
+
order: 0;
|
|
44
|
+
}
|
|
45
|
+
}
|