@eccenca/gui-elements 23.0.0-rc.3 → 23.0.0-rc.4
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 +13 -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 +9 -7
- 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 +35 -0
- package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/cjs/components/InteractionGate/InteractionGate.js +66 -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/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 +12 -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 +15 -13
- 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 +35 -0
- package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/esm/components/InteractionGate/InteractionGate.js +53 -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/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 +9 -5
- package/dist/esm/index.js.map +1 -1
- 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/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 +23 -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/Tooltip/Tooltip.d.ts +12 -1
- package/dist/types/components/Tree/Tree.d.ts +43 -0
- package/dist/types/index.d.ts +5 -2
- package/package.json +3 -2
- 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 +5 -2
- 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 +5 -2
- 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 +46 -0
- package/src/components/InteractionGate/InteractionGate.stories.tsx +32 -0
- package/src/components/InteractionGate/InteractionGate.tsx +65 -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/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/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 +14 -5
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Tree as BlueprintTree, TreeProps as BlueprintTreeProps, TreeNode as BlueprintTreeNode, TreeNodeInfo as BlueprintTreeNodeInfo } from "@blueprintjs/core";
|
|
3
|
+
import { IconProps } from "./../Icon/Icon";
|
|
4
|
+
export interface TreeNodeInfo<T = {}> extends Omit<BlueprintTreeNodeInfo<T>, "childNodes" | "icon"> {
|
|
5
|
+
/**
|
|
6
|
+
* Child tree nodes of this node.
|
|
7
|
+
*/
|
|
8
|
+
childNodes?: Array<TreeNodeInfo<T>>;
|
|
9
|
+
/**
|
|
10
|
+
* `<Icon />` element to render next to the node's label.
|
|
11
|
+
*/
|
|
12
|
+
icon?: React.ReactElement<IconProps>;
|
|
13
|
+
}
|
|
14
|
+
export interface TreeNodeProps<T = {}> extends TreeNodeInfo<T> {
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
contentRef?: (node: TreeNode<T>, element: HTMLDivElement | null) => void;
|
|
17
|
+
depth: number;
|
|
18
|
+
key?: string | number;
|
|
19
|
+
onClick?: (node: TreeNode<T>, e: React.MouseEvent<HTMLDivElement>) => void;
|
|
20
|
+
onCollapse?: (node: TreeNode<T>, e: React.MouseEvent<HTMLSpanElement>) => void;
|
|
21
|
+
onContextMenu?: (node: TreeNode<T>, e: React.MouseEvent<HTMLDivElement>) => void;
|
|
22
|
+
onDoubleClick?: (node: TreeNode<T>, e: React.MouseEvent<HTMLDivElement>) => void;
|
|
23
|
+
onExpand?: (node: TreeNode<T>, e: React.MouseEvent<HTMLSpanElement>) => void;
|
|
24
|
+
onMouseEnter?: (node: TreeNode<T>, e: React.MouseEvent<HTMLDivElement>) => void;
|
|
25
|
+
onMouseLeave?: (node: TreeNode<T>, e: React.MouseEvent<HTMLDivElement>) => void;
|
|
26
|
+
path: number[];
|
|
27
|
+
}
|
|
28
|
+
export declare class TreeNode<T = {}> extends BlueprintTreeNode<TreeNodeProps<T>> {
|
|
29
|
+
}
|
|
30
|
+
export declare class TreeNodeShadow<T = {}> extends React.Component<TreeNodeProps<T>> {
|
|
31
|
+
}
|
|
32
|
+
export interface TreeProps<T = {}> extends Omit<BlueprintTreeProps<T>, "contents"> {
|
|
33
|
+
/**
|
|
34
|
+
* Tree contents.
|
|
35
|
+
*/
|
|
36
|
+
contents: ReadonlyArray<TreeNodeInfo<T>>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Tree component to display a tree structure.
|
|
40
|
+
* Have a look to the underlaying [BlueprintJS Tree](https://blueprintjs.com/docs/#core/components/tree) component for examples how to use handlers.
|
|
41
|
+
* Use only our `<Icon />` elements in the tree nodes!
|
|
42
|
+
*/
|
|
43
|
+
export declare const Tree: typeof BlueprintTree;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import Highlighter from "./components/Typography/Highlighter";
|
|
|
19
19
|
import Grid from "./components/Grid/Grid";
|
|
20
20
|
import GridRow from "./components/Grid/GridRow";
|
|
21
21
|
import GridColumn from "./components/Grid/GridColumn";
|
|
22
|
+
import { HoverToggler } from "./components/HoverToggler/HoverToggler";
|
|
22
23
|
import WorkspaceContent from "./components/Workspace/WorkspaceContent";
|
|
23
24
|
import WorkspaceMain from "./components/Workspace/WorkspaceMain";
|
|
24
25
|
import WorkspaceSide from "./components/Workspace/WorkspaceSide";
|
|
@@ -77,6 +78,7 @@ import Accordion from "./components/Accordion/Accordion";
|
|
|
77
78
|
import AccordionItem from "./components/Accordion/AccordionItem";
|
|
78
79
|
import Link from "./components/Link/Link";
|
|
79
80
|
import Spinner from "./components/Spinner/Spinner";
|
|
81
|
+
import InteractionGate from "./components/InteractionGate/InteractionGate";
|
|
80
82
|
import { PropertyName, PropertyValue, PropertyValuePair, PropertyValueList } from "./components/PropertyValuePair";
|
|
81
83
|
import * as TypographyClassNames from "./components/Typography/classnames";
|
|
82
84
|
import { ProgressBar } from "./components/ProgressBar/ProgressBar";
|
|
@@ -90,9 +92,10 @@ declare const HelperClasses: {
|
|
|
90
92
|
};
|
|
91
93
|
declare const Utilities: {
|
|
92
94
|
openInNewTab: (event: import("react").MouseEvent<HTMLElement, MouseEvent>, handler?: ((e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void) | undefined, url?: string | undefined) => void;
|
|
95
|
+
decideContrastColorValue: ({ testColor, lightColor, darkColor }: import("./common/utils/colorDecideContrastvalue").decideContrastColorValueProps) => string;
|
|
93
96
|
};
|
|
94
|
-
export { ApplicationContainer, ApplicationHeader, ApplicationContent, ApplicationSidebarNavigation, ApplicationSidebarToggler, ApplicationTitle, ApplicationToolbar, ApplicationToolbarSection, ApplicationToolbarAction, ApplicationToolbarPanel, AutoSuggestion, AutoSuggestionList, SingleLineCodeEditor, HtmlContentBlock, OverflowText, WhiteSpaceContainer, Highlighter, Grid, GridRow, GridColumn, List, WorkspaceContent, WorkspaceMain, WorkspaceSide, WorkspaceHeader, Menu, MenuItem, MenuDivider, ContextOverlay, ContextMenu, OverviewItem, OverviewItemDepiction, OverviewItemDescription, OverviewItemLine, OverviewItemActions, OverviewItemList, TableContainer, Table, TableHead, TableRow, TableBody, TableCell, TableHeader, Icon, IconButton, Label, Button, Checkbox, RadioButton, Tabs, Tab, TabTitle, TextField, TextArea, SearchField, Switch, NumericInput, FieldItem, FieldItemRow, FieldSet, BreadcrumbList, BreadcrumbItem, Modal, SimpleDialog, AlertDialog, Card, CardHeader, CardTitle, CardOptions, CardContent, CardActions, CardActionsAux, Spacing, Divider, Tooltip, Section, SectionHeader, TitlePage, TitleMainsection, TitleSubsection, Accordion, AccordionItem, Toolbar, ToolbarSection, Tag, TagList, Pagination, Notification, Link, Spinner, PropertyName, PropertyValue, PropertyValuePair, PropertyValueList, Toast, HelperClasses, Select,
|
|
95
|
-
|
|
97
|
+
export { ApplicationContainer, ApplicationHeader, ApplicationContent, ApplicationSidebarNavigation, ApplicationSidebarToggler, ApplicationTitle, ApplicationToolbar, ApplicationToolbarSection, ApplicationToolbarAction, ApplicationToolbarPanel, AutoSuggestion, AutoSuggestionList, SingleLineCodeEditor, HtmlContentBlock, OverflowText, WhiteSpaceContainer, Highlighter, Grid, GridRow, GridColumn, List, WorkspaceContent, WorkspaceMain, WorkspaceSide, WorkspaceHeader, Menu, MenuItem, MenuDivider, ContextOverlay, ContextMenu, OverviewItem, OverviewItemDepiction, OverviewItemDescription, OverviewItemLine, OverviewItemActions, OverviewItemList, TableContainer, Table, TableHead, TableRow, TableBody, TableCell, TableHeader, Icon, IconButton, Label, Button, Checkbox, RadioButton, Tabs, Tab, TabTitle, TextField, TextArea, SearchField, Switch, NumericInput, FieldItem, FieldItemRow, FieldSet, BreadcrumbList, BreadcrumbItem, Modal, SimpleDialog, AlertDialog, Card, CardHeader, CardTitle, CardOptions, CardContent, CardActions, CardActionsAux, HoverToggler, Spacing, Divider, Tooltip, Section, SectionHeader, TitlePage, TitleMainsection, TitleSubsection, Accordion, AccordionItem, Toolbar, ToolbarSection, Tag, TagList, Pagination, Notification, Link, Spinner, InteractionGate, PropertyName, PropertyValue, PropertyValuePair, PropertyValueList, Toast, HelperClasses, Select, MultiSelect, AutoCompleteField, ProgressBar, Iframe, IframeModal, Utilities, LegacyReplacements, };
|
|
98
|
+
export * from "./components/Tree/Tree";
|
|
96
99
|
export * from "./cmem";
|
|
97
100
|
export * from "./extensions";
|
|
98
101
|
export * from "./components/interfaces";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eccenca/gui-elements",
|
|
3
3
|
"description": "GUI elements based on other libraries, usable in React application, written in Typescript.",
|
|
4
|
-
"version": "23.0.0-rc.
|
|
4
|
+
"version": "23.0.0-rc.4",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/eccenca/gui-elements",
|
|
7
7
|
"bugs": "https://github.com/eccenca/gui-elements/issues",
|
|
@@ -87,7 +87,8 @@
|
|
|
87
87
|
"remark-gfm": "^3.0.0",
|
|
88
88
|
"remark-parse": "^10.0.0",
|
|
89
89
|
"reset-css": "^5.0.1",
|
|
90
|
-
"unified": "^10.1.1"
|
|
90
|
+
"unified": "^10.1.1",
|
|
91
|
+
"wicg-inert": "^3.1.2"
|
|
91
92
|
},
|
|
92
93
|
"devDependencies": {
|
|
93
94
|
"@babel/core": "7.9.0",
|
|
@@ -177,7 +177,8 @@ export function ActivityControlWidget(props: IActivityControlProps) {
|
|
|
177
177
|
disabled={action.disabled}
|
|
178
178
|
hasStateWarning={action.hasStateWarning}
|
|
179
179
|
tooltipProps={{
|
|
180
|
-
hoverOpenDelay: 200
|
|
180
|
+
hoverOpenDelay: 200,
|
|
181
|
+
placement: "bottom"
|
|
181
182
|
}}
|
|
182
183
|
/>
|
|
183
184
|
);
|
|
@@ -8,7 +8,7 @@ import React from "react";
|
|
|
8
8
|
import { HtmlContentBlock } from "../../index";
|
|
9
9
|
import { PluggableList } from "react-markdown/lib/react-markdown";
|
|
10
10
|
|
|
11
|
-
interface MarkdownParserProps {
|
|
11
|
+
export interface MarkdownParserProps {
|
|
12
12
|
children: string;
|
|
13
13
|
// allow HTML as partial content, otherwise escape HTML tags (pls use with caution)
|
|
14
14
|
allowHtml?: boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Color from "color";
|
|
2
|
+
|
|
3
|
+
export type colorValue = Color | string;
|
|
4
|
+
|
|
5
|
+
export interface decideContrastColorValueProps {
|
|
6
|
+
// The color that is used to test if it need a light or dark color as contrast value.
|
|
7
|
+
testColor: colorValue;
|
|
8
|
+
// the light color that can be used on a dark color
|
|
9
|
+
lightColor?: colorValue;
|
|
10
|
+
// the dark color that can be used on a light color
|
|
11
|
+
darkColor?: colorValue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const decideContrastColorValue = ({
|
|
15
|
+
testColor,
|
|
16
|
+
lightColor = "#fff",
|
|
17
|
+
darkColor = "#000"
|
|
18
|
+
}: decideContrastColorValueProps): string => {
|
|
19
|
+
let contrastColor = "";
|
|
20
|
+
try {
|
|
21
|
+
contrastColor = Color(testColor).isLight() ? Color(darkColor).rgb().toString() : Color(lightColor).rgb().toString();
|
|
22
|
+
} catch(ex) {
|
|
23
|
+
console.warn("Received invalid colors", {testColor, lightColor, darkColor});
|
|
24
|
+
}
|
|
25
|
+
return contrastColor;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default decideContrastColorValue;
|
|
@@ -4,17 +4,22 @@ import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
|
4
4
|
// Configurations can be found in `src/cmem/react-flow/configuration/_colors-*.scss`
|
|
5
5
|
type colorconfigs = "react-flow-graph" | "react-flow-linking" | "react-flow-workflow" | "stickynotes";
|
|
6
6
|
|
|
7
|
+
const colorConfigurationMemo = new Map<colorconfigs, any>()
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* Read and returns color values provided by CSS custom properties.
|
|
9
11
|
* They are defined for special CSS classes.
|
|
10
12
|
* Currently color configurations for the react flow editors are supported.
|
|
11
13
|
**/
|
|
12
14
|
const getColorConfiguration = (configId: colorconfigs) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if(!colorConfigurationMemo.has(configId)) {
|
|
16
|
+
colorConfigurationMemo.set(configId, new CssCustomProperties({
|
|
17
|
+
selectorText: `.${eccgui}-configuration--colors__${configId}`,
|
|
18
|
+
removeDashPrefix: true,
|
|
19
|
+
returnObject: true,
|
|
20
|
+
}).customProperties())
|
|
21
|
+
}
|
|
22
|
+
return colorConfigurationMemo.get(configId)!!;
|
|
18
23
|
};
|
|
19
24
|
|
|
20
25
|
export default getColorConfiguration;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
.ecc-auto-suggestion-box {
|
|
1
|
+
.#{$eccgui}-autosuggestion {
|
|
4
2
|
position: relative;
|
|
5
3
|
|
|
6
4
|
&__dropdown {
|
|
@@ -8,7 +6,7 @@
|
|
|
8
6
|
// TODO: Replace by variable
|
|
9
7
|
background-color: #fff;
|
|
10
8
|
position: absolute;
|
|
11
|
-
top:
|
|
9
|
+
top: 0;
|
|
12
10
|
z-index:2;
|
|
13
11
|
display: flex;
|
|
14
12
|
flex-flow: column wrap;
|
|
@@ -28,7 +26,7 @@
|
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
.#{$eccgui}-singlelinecodeeditor {
|
|
32
30
|
position: relative;
|
|
33
31
|
|
|
34
32
|
.CodeMirror {
|
|
@@ -59,12 +57,20 @@
|
|
|
59
57
|
line-height: calc(#{$eccgui-size-textfield-height-regular} - 4px - 6px);
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
pre.CodeMirror-line
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
pre.CodeMirror-line,
|
|
61
|
+
pre.CodeMirror-placeholder,
|
|
62
|
+
pre.CodeMirror-line-like {
|
|
63
|
+
font-family: $eccgui-font-family-default;
|
|
64
|
+
font-size: $eccgui-size-typo-base;
|
|
65
65
|
padding: 3px 0;
|
|
66
66
|
height: calc(#{$eccgui-size-textfield-height-regular} - 4px - 6px);
|
|
67
|
+
line-height: calc(#{$eccgui-size-textfield-height-regular} - 4px - 6px);
|
|
67
68
|
box-sizing: content-box;
|
|
69
|
+
color: $input-color;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
pre.CodeMirror-placeholder {
|
|
73
|
+
color: $input-placeholder-color;
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
.CodeMirror-cursor {
|
|
@@ -87,13 +93,13 @@
|
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
|
|
96
|
+
.#{$eccgui}-autosuggestion__text--highlighted {
|
|
91
97
|
display: inline-block;
|
|
92
98
|
background-color: $eccgui-color-warning-background;
|
|
93
99
|
color:$eccgui-color-warning-text;
|
|
94
100
|
}
|
|
95
101
|
|
|
96
|
-
|
|
102
|
+
.#{$eccgui}-autosuggestion__text--highlighted-error {
|
|
97
103
|
background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==");
|
|
98
104
|
background-position: left bottom;
|
|
99
105
|
background-repeat: repeat-x;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, {useEffect, useMemo, useState} from "react";
|
|
2
2
|
import CodeMirror from "codemirror";
|
|
3
|
-
import {FieldItem, IconButton, Spinner, Toolbar, ToolbarSection} from "./../../";
|
|
3
|
+
import {FieldItem, IconButton, Spinner, Toolbar, ToolbarSection, ContextOverlay} from "./../../";
|
|
4
4
|
import {Classes as BlueprintClassNames} from "@blueprintjs/core";
|
|
5
|
+
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
5
6
|
|
|
6
7
|
//custom components
|
|
7
8
|
import SingleLineCodeEditor, {IRange} from "./SingleLineCodeEditor";
|
|
@@ -102,6 +103,12 @@ export interface IProps {
|
|
|
102
103
|
placeholder?: string
|
|
103
104
|
/** If the horizontal scrollbars should be shown. */
|
|
104
105
|
showScrollBar?: boolean
|
|
106
|
+
/** Delay in ms before an auto-completion request should be send after nothing is typed in anymore.
|
|
107
|
+
* This should prevent the UI to send too many requests to the backend. */
|
|
108
|
+
autoCompletionRequestDelay?: number
|
|
109
|
+
/** Delay in ms before a validation request should be send after nothing is typed in anymore.
|
|
110
|
+
* This should prevent the UI to send too many requests to the backend. */
|
|
111
|
+
validationRequestDelay?: number
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
/** Input component that allows partial, fine-grained auto-completion, i.e. of sub-strings of the input string.
|
|
@@ -121,11 +128,13 @@ const AutoSuggestion = ({
|
|
|
121
128
|
rightElement,
|
|
122
129
|
useTabForCompletions = false,
|
|
123
130
|
placeholder,
|
|
124
|
-
showScrollBar = true
|
|
131
|
+
showScrollBar = true,
|
|
132
|
+
autoCompletionRequestDelay = 1000,
|
|
133
|
+
validationRequestDelay = 200
|
|
125
134
|
}: IProps) => {
|
|
126
135
|
const [value, setValue] = React.useState(initialValue);
|
|
127
136
|
const [cursorPosition, setCursorPosition] = React.useState(0);
|
|
128
|
-
const [
|
|
137
|
+
const [horizontalShift, setHorizontalShift] = React.useState<number>(0);
|
|
129
138
|
const [shouldShowDropdown, setShouldShowDropdown] = React.useState(false);
|
|
130
139
|
const [suggestions, setSuggestions] = React.useState<ISuggestionWithReplacementInfo[]>([]);
|
|
131
140
|
const [suggestionsPending, setSuggestionsPending] = React.useState(false);
|
|
@@ -177,7 +186,7 @@ const AutoSuggestion = ({
|
|
|
177
186
|
const marker = editorInstance.markText(
|
|
178
187
|
{line: 0, ch: from},
|
|
179
188
|
{line: 0, ch: to},
|
|
180
|
-
{className:
|
|
189
|
+
{className: `${eccgui}-autosuggestion__text--highlighted`}
|
|
181
190
|
);
|
|
182
191
|
return () => marker.clear()
|
|
183
192
|
}
|
|
@@ -194,7 +203,7 @@ const AutoSuggestion = ({
|
|
|
194
203
|
const marker = editorInstance.markText(
|
|
195
204
|
{ line: 0, ch: start },
|
|
196
205
|
{ line: 0, ch: end },
|
|
197
|
-
{ className:
|
|
206
|
+
{ className: `${eccgui}-autosuggestion__text--highlighted-error`, title: message }
|
|
198
207
|
);
|
|
199
208
|
setErrorMarkers((previousMarkers) => {
|
|
200
209
|
previousMarkers.forEach(marker => marker.clear())
|
|
@@ -252,8 +261,8 @@ const AutoSuggestion = ({
|
|
|
252
261
|
}, [checkInput])
|
|
253
262
|
|
|
254
263
|
const checkValuePathValidity = useMemo(
|
|
255
|
-
() => debounce((inputString: string) => asyncCheckInput(inputString),
|
|
256
|
-
[asyncCheckInput]
|
|
264
|
+
() => debounce((inputString: string) => asyncCheckInput(inputString), validationRequestDelay),
|
|
265
|
+
[asyncCheckInput, validationRequestDelay]
|
|
257
266
|
)
|
|
258
267
|
|
|
259
268
|
const asyncHandleEditorInputChange = useMemo(() => async (inputString: string, cursorPosition: number) => {
|
|
@@ -270,8 +279,8 @@ const AutoSuggestion = ({
|
|
|
270
279
|
}, [fetchSuggestions])
|
|
271
280
|
|
|
272
281
|
const handleEditorInputChange = useMemo(() =>
|
|
273
|
-
debounce((inputString: string, cursorPosition: number) => asyncHandleEditorInputChange(inputString, cursorPosition),
|
|
274
|
-
[asyncHandleEditorInputChange]
|
|
282
|
+
debounce((inputString: string, cursorPosition: number) => asyncHandleEditorInputChange(inputString, cursorPosition), autoCompletionRequestDelay),
|
|
283
|
+
[asyncHandleEditorInputChange, autoCompletionRequestDelay]
|
|
275
284
|
)
|
|
276
285
|
|
|
277
286
|
React.useEffect(() => {
|
|
@@ -294,9 +303,9 @@ const AutoSuggestion = ({
|
|
|
294
303
|
onChange(val)
|
|
295
304
|
};
|
|
296
305
|
|
|
297
|
-
const handleCursorChange = (pos: any, coords: any) => {
|
|
306
|
+
const handleCursorChange = (pos: any, coords: any, scrollinfo: any) => {
|
|
298
307
|
setCursorPosition(pos.ch);
|
|
299
|
-
|
|
308
|
+
setHorizontalShift(Math.min(coords.left, Math.max(coords.left - scrollinfo.left, 0)));
|
|
300
309
|
};
|
|
301
310
|
|
|
302
311
|
const handleInputEditorKeyPress = (event: KeyboardEvent) => {
|
|
@@ -382,48 +391,68 @@ const AutoSuggestion = ({
|
|
|
382
391
|
}, [])
|
|
383
392
|
|
|
384
393
|
const hasError = !!value && !pathIsValid && !pathValidationPending;
|
|
385
|
-
const autoSuggestionInput =
|
|
386
|
-
<div
|
|
387
|
-
<
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
394
|
+
const autoSuggestionInput = (
|
|
395
|
+
<div id={id} className={`${eccgui}-autosuggestion`}>
|
|
396
|
+
<div className={`${eccgui}-autosuggestion__inputfield ${BlueprintClassNames.INPUT_GROUP} ${BlueprintClassNames.FILL} ${hasError ? BlueprintClassNames.INTENT_DANGER : ""}`}>
|
|
397
|
+
<ContextOverlay
|
|
398
|
+
minimal
|
|
399
|
+
fill
|
|
400
|
+
isOpen={shouldShowDropdown}
|
|
401
|
+
placement="bottom-start"
|
|
402
|
+
openOnTargetFocus={false}
|
|
403
|
+
autoFocus={false}
|
|
404
|
+
content={(
|
|
405
|
+
<AutoSuggestionList
|
|
406
|
+
id={id+"__dropdown"}
|
|
407
|
+
left={horizontalShift}
|
|
408
|
+
loading={suggestionsPending}
|
|
409
|
+
options={suggestions}
|
|
410
|
+
isOpen={!suggestionsPending && shouldShowDropdown}
|
|
411
|
+
onItemSelectionChange={handleDropdownChange}
|
|
412
|
+
currentlyFocusedIndex={focusedIndex}
|
|
413
|
+
itemToHighlight={handleItemHighlighting}
|
|
414
|
+
/>
|
|
415
|
+
)}
|
|
416
|
+
>
|
|
417
|
+
<SingleLineCodeEditor
|
|
418
|
+
mode="null"
|
|
419
|
+
setEditorInstance={setEditorInstance}
|
|
420
|
+
onChange={handleChange}
|
|
421
|
+
onCursorChange={handleCursorChange}
|
|
422
|
+
initialValue={value}
|
|
423
|
+
onFocusChange={handleInputFocus}
|
|
424
|
+
onKeyDown={handleInputEditorKeyPress}
|
|
425
|
+
enableTab={useTabForCompletions}
|
|
426
|
+
placeholder={placeholder}
|
|
427
|
+
onSelection={setSelectedTextRanges}
|
|
428
|
+
showScrollBar={showScrollBar}
|
|
429
|
+
/>
|
|
430
|
+
</ContextOverlay>
|
|
431
|
+
{!!value && (
|
|
432
|
+
<span className={BlueprintClassNames.INPUT_ACTION}>
|
|
433
|
+
<IconButton
|
|
434
|
+
data-test-id={"value-path-clear-btn"}
|
|
435
|
+
name="operation-clear"
|
|
436
|
+
text={clearIconText}
|
|
437
|
+
onClick={handleInputEditorClear}
|
|
438
|
+
/>
|
|
439
|
+
</span>
|
|
440
|
+
)}
|
|
441
|
+
</div>
|
|
410
442
|
</div>
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
<ToolbarSection canGrow={true}>{autoSuggestionInput}</ToolbarSection>
|
|
425
|
-
{rightElement && <ToolbarSection>{rightElement}</ToolbarSection>}
|
|
426
|
-
</Toolbar> : autoSuggestionInput
|
|
443
|
+
);
|
|
444
|
+
|
|
445
|
+
const withRightElement = rightElement || leftElement ? (
|
|
446
|
+
<Toolbar noWrap>
|
|
447
|
+
{leftElement && <ToolbarSection>{leftElement}</ToolbarSection>}
|
|
448
|
+
<ToolbarSection canGrow canShrink>
|
|
449
|
+
<div style={{minWidth: "100%", maxWidth: "100%"}}>
|
|
450
|
+
{autoSuggestionInput}
|
|
451
|
+
</div>
|
|
452
|
+
</ToolbarSection>
|
|
453
|
+
{rightElement && <ToolbarSection>{rightElement}</ToolbarSection>}
|
|
454
|
+
</Toolbar>
|
|
455
|
+
) : autoSuggestionInput
|
|
427
456
|
|
|
428
457
|
return label ? (
|
|
429
458
|
<FieldItem
|
|
@@ -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,7 @@ export const AutoSuggestionList = ({
|
|
|
78
79
|
left,
|
|
79
80
|
currentlyFocusedIndex,
|
|
80
81
|
itemToHighlight,
|
|
82
|
+
...otherDivProps
|
|
81
83
|
}: IDropdownProps) => {
|
|
82
84
|
const [hoveredItem, setHoveredItem] = React.useState<
|
|
83
85
|
ISuggestionWithReplacementInfo | undefined
|
|
@@ -132,7 +134,8 @@ export const AutoSuggestionList = ({
|
|
|
132
134
|
if (!loadingOrHasSuggestions || !isOpen) return null;
|
|
133
135
|
return (
|
|
134
136
|
<div
|
|
135
|
-
|
|
137
|
+
{...otherDivProps}
|
|
138
|
+
className={`${eccgui}-autosuggestion__dropdown`}
|
|
136
139
|
style={{ left }}
|
|
137
140
|
ref={dropdownRef}
|
|
138
141
|
>
|
|
@@ -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", () => {
|
|
@@ -223,7 +223,7 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
223
223
|
);
|
|
224
224
|
|
|
225
225
|
useEffect(() => {
|
|
226
|
-
if (!disabled && hasFocus) {
|
|
226
|
+
if (!disabled && !otherProps.inputProps?.readOnly && hasFocus) {
|
|
227
227
|
setListLoading(true);
|
|
228
228
|
const timeout: number = window.setTimeout(async () => {
|
|
229
229
|
fetchQueryResults(query);
|
|
@@ -351,7 +351,7 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
351
351
|
return <Notification danger={true} message={requestError} />
|
|
352
352
|
}
|
|
353
353
|
// Optional clear button to reset the selected value
|
|
354
|
-
const clearButton = reset &&
|
|
354
|
+
const clearButton = !disabled && reset &&
|
|
355
355
|
selectedItem != null &&
|
|
356
356
|
reset.resettableValue(selectedItem) ? (
|
|
357
357
|
<IconButton
|
|
@@ -370,7 +370,9 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
370
370
|
onBlur: handleOnFocusOut,
|
|
371
371
|
onFocus: handleOnFocusIn,
|
|
372
372
|
...otherProps.inputProps,
|
|
373
|
+
title: (selectedItem !== undefined && (!!otherProps.inputProps?.readOnly || disabled)) ? itemValueString(selectedItem) : otherProps.inputProps?.title,
|
|
373
374
|
};
|
|
375
|
+
const preventOverlayOnReadonly = !!otherProps.inputProps?.readOnly ? { isOpen: false } : {}
|
|
374
376
|
const updatedContextOverlayProps: Partial<Omit<ContextOverlayProps, "content" | "children">> = {
|
|
375
377
|
minimal: true,
|
|
376
378
|
placement: "bottom-start",
|
|
@@ -378,6 +380,7 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
378
380
|
rootBoundary: "viewport",
|
|
379
381
|
onClosed: onPopoverClose,
|
|
380
382
|
...otherProps.contextOverlayProps,
|
|
383
|
+
...preventOverlayOnReadonly,
|
|
381
384
|
}
|
|
382
385
|
if(selectedItem !== undefined) {
|
|
383
386
|
// 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
|