@eccenca/gui-elements 22.1.0 → 23.0.0-rc.2
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 +39 -0
- package/README.md +1 -11
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js +4 -10
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/cjs/cmem/react-flow/ReactFlow/ReactFlow.js +9 -2
- package/dist/cjs/cmem/react-flow/ReactFlow/ReactFlow.js.map +1 -1
- package/dist/cjs/cmem/react-flow/configuration/customLabel.js +13 -0
- package/dist/cjs/cmem/react-flow/configuration/customLabel.js.map +1 -0
- package/dist/cjs/cmem/react-flow/configuration/graph.js +1 -6
- package/dist/cjs/cmem/react-flow/configuration/graph.js.map +1 -1
- package/dist/cjs/cmem/react-flow/configuration/inverseEdge.js +13 -0
- package/dist/cjs/cmem/react-flow/configuration/inverseEdge.js.map +1 -0
- package/dist/cjs/cmem/react-flow/configuration/linking.js +1 -6
- package/dist/cjs/cmem/react-flow/configuration/linking.js.map +1 -1
- package/dist/cjs/cmem/react-flow/configuration/workflow.js +1 -6
- package/dist/cjs/cmem/react-flow/configuration/workflow.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js +19 -19
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/AutoSuggestionList.js +4 -12
- package/dist/cjs/components/AutoSuggestion/AutoSuggestionList.js.map +1 -1
- package/dist/cjs/components/AutocompleteField/AutoCompleteField.js +15 -6
- package/dist/cjs/components/AutocompleteField/AutoCompleteField.js.map +1 -1
- package/dist/cjs/components/Button/Button.js +2 -2
- package/dist/cjs/components/Button/Button.js.map +1 -1
- package/dist/cjs/components/ContextOverlay/ContextMenu.js +6 -5
- package/dist/cjs/components/ContextOverlay/ContextMenu.js.map +1 -1
- package/dist/cjs/components/ContextOverlay/ContextOverlay.js +6 -8
- package/dist/cjs/components/ContextOverlay/ContextOverlay.js.map +1 -1
- package/dist/cjs/components/Dialog/SimpleDialog.js +9 -4
- package/dist/cjs/components/Dialog/SimpleDialog.js.map +1 -1
- package/dist/cjs/components/Form/FieldItem.js +2 -2
- package/dist/cjs/components/Form/FieldItem.js.map +1 -1
- package/dist/cjs/components/Icon/Icon.js +2 -2
- package/dist/cjs/components/Icon/Icon.js.map +1 -1
- package/dist/cjs/components/Icon/IconButton.js +2 -2
- package/dist/cjs/components/Icon/IconButton.js.map +1 -1
- package/dist/cjs/components/Icon/canonicalIconNames.js +10 -0
- package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/cjs/components/Iframe/IframeModal.js +2 -6
- package/dist/cjs/components/Iframe/IframeModal.js.map +1 -1
- package/dist/cjs/components/Label/Label.js +6 -6
- package/dist/cjs/components/Label/Label.js.map +1 -1
- package/dist/cjs/components/Menu/MenuItem.js +2 -5
- package/dist/cjs/components/Menu/MenuItem.js.map +1 -1
- package/dist/cjs/components/MultiSelect/MultiSelect.js +8 -10
- package/dist/cjs/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/cjs/components/Select/Select.js +29 -0
- package/dist/cjs/components/Select/Select.js.map +1 -0
- package/dist/cjs/components/Tabs/TabTitle.js +2 -4
- package/dist/cjs/components/Tabs/TabTitle.js.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.js +7 -4
- package/dist/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/cjs/extensions/codemirror/CodeMirror.js +59 -0
- package/dist/cjs/extensions/codemirror/CodeMirror.js.map +1 -0
- package/dist/cjs/extensions/index.js +15 -0
- package/dist/cjs/extensions/index.js.map +1 -0
- package/dist/cjs/extensions/react-flow/edges/EdgeDefault.js +5 -5
- package/dist/cjs/extensions/react-flow/edges/EdgeDefault.js.map +1 -1
- package/dist/cjs/extensions/react-flow/edges/EdgeTools.js +2 -1
- package/dist/cjs/extensions/react-flow/edges/EdgeTools.js.map +1 -1
- package/dist/cjs/extensions/react-flow/handles/HandleContent.js +1 -1
- package/dist/cjs/extensions/react-flow/handles/HandleContent.js.map +1 -1
- package/dist/cjs/extensions/react-flow/index.js +5 -1
- package/dist/cjs/extensions/react-flow/index.js.map +1 -1
- package/dist/cjs/extensions/react-flow/markers/MarkerArrowClosedInverse.js +13 -0
- package/dist/cjs/extensions/react-flow/markers/MarkerArrowClosedInverse.js.map +1 -0
- package/dist/cjs/extensions/react-flow/markers/ReactFlowMarkers.js +15 -0
- package/dist/cjs/extensions/react-flow/markers/ReactFlowMarkers.js.map +1 -0
- package/dist/cjs/extensions/react-flow/nodes/NodeTools.js +1 -3
- package/dist/cjs/extensions/react-flow/nodes/NodeTools.js.map +1 -1
- package/dist/cjs/index.js +4 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js +4 -10
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/esm/cmem/react-flow/ReactFlow/ReactFlow.js +9 -2
- package/dist/esm/cmem/react-flow/ReactFlow/ReactFlow.js.map +1 -1
- package/dist/esm/cmem/react-flow/configuration/customLabel.js +10 -0
- package/dist/esm/cmem/react-flow/configuration/customLabel.js.map +1 -0
- package/dist/esm/cmem/react-flow/configuration/graph.js +1 -2
- package/dist/esm/cmem/react-flow/configuration/graph.js.map +1 -1
- package/dist/esm/cmem/react-flow/configuration/inverseEdge.js +10 -0
- package/dist/esm/cmem/react-flow/configuration/inverseEdge.js.map +1 -0
- package/dist/esm/cmem/react-flow/configuration/linking.js +1 -2
- package/dist/esm/cmem/react-flow/configuration/linking.js.map +1 -1
- package/dist/esm/cmem/react-flow/configuration/workflow.js +1 -2
- package/dist/esm/cmem/react-flow/configuration/workflow.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js +23 -21
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/AutoSuggestionList.js +4 -12
- package/dist/esm/components/AutoSuggestion/AutoSuggestionList.js.map +1 -1
- package/dist/esm/components/AutocompleteField/AutoCompleteField.js +32 -23
- package/dist/esm/components/AutocompleteField/AutoCompleteField.js.map +1 -1
- package/dist/esm/components/Button/Button.js +2 -2
- package/dist/esm/components/Button/Button.js.map +1 -1
- package/dist/esm/components/ContextOverlay/ContextMenu.js +6 -5
- package/dist/esm/components/ContextOverlay/ContextMenu.js.map +1 -1
- package/dist/esm/components/ContextOverlay/ContextOverlay.js +6 -8
- package/dist/esm/components/ContextOverlay/ContextOverlay.js.map +1 -1
- package/dist/esm/components/Dialog/SimpleDialog.js +25 -4
- package/dist/esm/components/Dialog/SimpleDialog.js.map +1 -1
- package/dist/esm/components/Form/FieldItem.js +2 -2
- package/dist/esm/components/Form/FieldItem.js.map +1 -1
- package/dist/esm/components/Icon/Icon.js +2 -2
- package/dist/esm/components/Icon/Icon.js.map +1 -1
- package/dist/esm/components/Icon/IconButton.js +2 -2
- package/dist/esm/components/Icon/IconButton.js.map +1 -1
- package/dist/esm/components/Icon/canonicalIconNames.js +10 -0
- package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/esm/components/Iframe/IframeModal.js +2 -22
- package/dist/esm/components/Iframe/IframeModal.js.map +1 -1
- package/dist/esm/components/Label/Label.js +6 -6
- package/dist/esm/components/Label/Label.js.map +1 -1
- package/dist/esm/components/Menu/MenuItem.js +2 -5
- package/dist/esm/components/Menu/MenuItem.js.map +1 -1
- package/dist/esm/components/MultiSelect/MultiSelect.js +5 -7
- package/dist/esm/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/esm/components/Select/Select.js +35 -0
- package/dist/esm/components/Select/Select.js.map +1 -0
- package/dist/esm/components/Tabs/TabTitle.js +2 -4
- package/dist/esm/components/Tabs/TabTitle.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +7 -4
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/extensions/codemirror/CodeMirror.js +34 -0
- package/dist/esm/extensions/codemirror/CodeMirror.js.map +1 -0
- package/dist/esm/extensions/index.js +3 -0
- package/dist/esm/extensions/index.js.map +1 -0
- package/dist/esm/extensions/react-flow/edges/EdgeDefault.js +6 -6
- package/dist/esm/extensions/react-flow/edges/EdgeDefault.js.map +1 -1
- package/dist/esm/extensions/react-flow/edges/EdgeTools.js +2 -1
- package/dist/esm/extensions/react-flow/edges/EdgeTools.js.map +1 -1
- package/dist/esm/extensions/react-flow/handles/HandleContent.js +1 -1
- package/dist/esm/extensions/react-flow/handles/HandleContent.js.map +1 -1
- package/dist/esm/extensions/react-flow/index.js +2 -0
- package/dist/esm/extensions/react-flow/index.js.map +1 -1
- package/dist/esm/extensions/react-flow/markers/MarkerArrowClosedInverse.js +6 -0
- package/dist/esm/extensions/react-flow/markers/MarkerArrowClosedInverse.js.map +1 -0
- package/dist/esm/extensions/react-flow/markers/ReactFlowMarkers.js +8 -0
- package/dist/esm/extensions/react-flow/markers/ReactFlowMarkers.js.map +1 -0
- package/dist/esm/extensions/react-flow/nodes/NodeTools.js +1 -3
- package/dist/esm/extensions/react-flow/nodes/NodeTools.js.map +1 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/types/cmem/react-flow/ReactFlow/ReactFlow.d.ts +2 -3
- package/dist/types/cmem/react-flow/configuration/customLabel.d.ts +8 -0
- package/dist/types/cmem/react-flow/configuration/graph.d.ts +1 -2
- package/dist/types/cmem/react-flow/configuration/inverseEdge.d.ts +8 -0
- package/dist/types/cmem/react-flow/configuration/linking.d.ts +1 -2
- package/dist/types/cmem/react-flow/configuration/workflow.d.ts +1 -2
- package/dist/types/components/AutocompleteField/AutoCompleteField.d.ts +7 -4
- package/dist/types/components/Button/Button.d.ts +2 -2
- package/dist/types/components/ContextOverlay/ContextMenu.d.ts +37 -3
- package/dist/types/components/ContextOverlay/ContextOverlay.d.ts +12 -1
- package/dist/types/components/Dialog/SimpleDialog.d.ts +5 -1
- package/dist/types/components/Form/FieldItem.d.ts +3 -2
- package/dist/types/components/Icon/Icon.d.ts +32 -7
- package/dist/types/components/Icon/IconButton.d.ts +21 -7
- package/dist/types/components/Icon/canonicalIconNames.d.ts +1 -1
- package/dist/types/components/Label/Label.d.ts +30 -2
- package/dist/types/components/Menu/MenuItem.d.ts +3 -7
- package/dist/types/components/MultiSelect/MultiSelect.d.ts +13 -9
- package/dist/types/components/Select/Select.d.ts +22 -0
- package/dist/types/components/Tooltip/Tooltip.d.ts +13 -11
- package/dist/types/components/interfaces.d.ts +1 -0
- package/dist/types/extensions/codemirror/CodeMirror.d.ts +35 -0
- package/dist/types/extensions/index.d.ts +2 -0
- package/dist/types/extensions/react-flow/edges/EdgeDefault.d.ts +3 -0
- package/dist/types/extensions/react-flow/edges/EdgeTools.d.ts +2 -2
- package/dist/types/extensions/react-flow/index.d.ts +2 -0
- package/dist/types/extensions/react-flow/markers/MarkerArrowClosedInverse.d.ts +2 -0
- package/dist/types/extensions/react-flow/markers/ReactFlowMarkers.d.ts +2 -0
- package/dist/types/extensions/react-flow/nodes/NodeTools.d.ts +2 -2
- package/dist/types/index.d.ts +3 -2
- package/package.json +16 -9
- package/src/cmem/ActivityControl/ActivityControlWidget.stories.tsx +2 -2
- package/src/cmem/ActivityControl/ActivityControlWidget.tsx +5 -10
- package/src/cmem/react-flow/ReactFlow/ReactFlow.stories.tsx +160 -51
- package/src/cmem/react-flow/ReactFlow/ReactFlow.tsx +12 -3
- package/src/cmem/react-flow/configuration/_colors-graph.scss +35 -0
- package/src/cmem/react-flow/configuration/_colors-linking.scss +29 -0
- package/src/cmem/react-flow/configuration/_colors-workflow.scss +22 -0
- package/src/cmem/react-flow/configuration/_colors.scss +3 -3
- package/src/cmem/react-flow/configuration/customLabel.ts +11 -0
- package/src/cmem/react-flow/configuration/graph.ts +0 -2
- package/src/cmem/react-flow/configuration/inverseEdge.ts +11 -0
- package/src/cmem/react-flow/configuration/linking.ts +0 -2
- package/src/cmem/react-flow/configuration/workflow.ts +0 -2
- package/src/common/utils/CssCustomProperties.ts +135 -0
- package/src/common/utils/getColorConfiguration.ts +21 -0
- package/src/components/Accordion/accordion.scss +7 -0
- package/src/components/AutoSuggestion/AutoSuggestion.tsx +23 -23
- package/src/components/AutoSuggestion/AutoSuggestionList.tsx +15 -17
- package/src/components/AutoSuggestion/tests/AutoSuggestionList.test.tsx +1 -1
- package/src/components/AutocompleteField/AutoCompleteField.tsx +44 -19
- package/src/components/AutocompleteField/autocompletefield.scss +5 -3
- package/src/components/AutocompleteField/stories/AutoCompleteField.stories.tsx +75 -0
- package/src/components/Button/Button.tsx +3 -3
- package/src/components/ContextOverlay/ContextMenu.stories.tsx +30 -0
- package/src/components/ContextOverlay/ContextMenu.tsx +46 -8
- package/src/components/ContextOverlay/ContextOverlay.stories.tsx +148 -0
- package/src/components/ContextOverlay/ContextOverlay.tsx +16 -9
- package/src/components/ContextOverlay/contextoverlay.scss +3 -3
- package/src/components/Dialog/SimpleDialog.tsx +25 -4
- package/src/components/Form/FieldItem.tsx +4 -4
- package/src/components/Icon/Icon.tsx +33 -18
- package/src/components/Icon/IconButton.tsx +24 -19
- package/src/components/Icon/canonicalIconNames.tsx +12 -0
- package/src/components/Icon/stories/Icon.stories.tsx +52 -0
- package/src/components/Icon/stories/IconButton.stories.tsx +27 -0
- package/src/components/Iframe/IframeModal.tsx +6 -17
- package/src/components/Label/Label.stories.tsx +27 -0
- package/src/components/Label/Label.tsx +47 -15
- package/src/components/Menu/MenuItem.tsx +9 -16
- package/src/components/Menu/menu.scss +4 -3
- package/src/components/MultiSelect/MultiSelect.tsx +30 -18
- package/src/components/Select/Select.stories.tsx +35 -0
- package/src/components/Select/Select.tsx +38 -0
- package/src/components/Select/_select.scss +8 -0
- package/src/components/Tabs/TabTitle.tsx +2 -4
- package/src/components/Tabs/tabs.scss +1 -1
- package/src/components/Tag/tag.scss +26 -22
- package/src/components/Tooltip/Tooltip.stories.tsx +36 -0
- package/src/components/Tooltip/Tooltip.tsx +23 -18
- package/src/components/Tooltip/tooltip.scss +6 -6
- package/src/components/Typography/typography.scss +1 -0
- package/src/components/interfaces.ts +3 -1
- package/src/extensions/_index.scss +5 -0
- package/src/extensions/codemirror/CodeMirror.stories.tsx +26 -0
- package/src/extensions/codemirror/CodeMirror.tsx +82 -0
- package/src/extensions/codemirror/_codemirror.scss +31 -0
- package/src/extensions/index.ts +2 -0
- package/src/extensions/react-flow/edges/EdgeDefault.tsx +7 -2
- package/src/extensions/react-flow/edges/EdgeTools.tsx +6 -4
- package/src/extensions/react-flow/handles/HandleContent.tsx +0 -1
- package/src/extensions/react-flow/index.ts +2 -0
- package/src/extensions/react-flow/markers/MarkerArrowClosedInverse.tsx +25 -0
- package/src/extensions/react-flow/markers/ReactFlowMarkers.tsx +13 -0
- package/src/extensions/react-flow/nodes/NodeTools.tsx +10 -7
- package/src/extensions/react-flow/nodes/stories/NodeContent.stories.tsx +18 -0
- package/src/includes/blueprintjs/_variables.scss +1 -1
- package/src/index.scss +10 -9
- package/src/index.ts +4 -2
- package/dist/cjs/cmem/react-flow/configuration/_colors-graph.module.scss +0 -35
- package/dist/cjs/cmem/react-flow/configuration/_colors-linking.module.scss +0 -29
- package/dist/cjs/cmem/react-flow/configuration/_colors-workflow.module.scss +0 -22
- package/dist/esm/cmem/react-flow/configuration/_colors-graph.module.scss +0 -35
- package/dist/esm/cmem/react-flow/configuration/_colors-linking.module.scss +0 -29
- package/dist/esm/cmem/react-flow/configuration/_colors-workflow.module.scss +0 -22
- package/src/cmem/react-flow/configuration/_colors-graph.module.scss +0 -35
- package/src/cmem/react-flow/configuration/_colors-linking.module.scss +0 -29
- package/src/cmem/react-flow/configuration/_colors-workflow.module.scss +0 -22
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EdgeDefault } from "./../../../extensions/react-flow/edges/EdgeDefault";
|
|
2
|
+
import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault";
|
|
3
|
+
|
|
4
|
+
export const edgeTypes = {
|
|
5
|
+
default: EdgeDefault,
|
|
6
|
+
straight: EdgeDefault,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const nodeTypes = {
|
|
10
|
+
default: NodeDefault,
|
|
11
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EdgeDefault } from "./../../../extensions/react-flow/edges/EdgeDefault";
|
|
2
2
|
import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault";
|
|
3
|
-
import colors from "./_colors-graph.module.scss";
|
|
4
3
|
|
|
5
4
|
const edgeTypes = {
|
|
6
5
|
default: EdgeDefault,
|
|
@@ -25,5 +24,4 @@ const nodeTypes = {
|
|
|
25
24
|
export {
|
|
26
25
|
edgeTypes,
|
|
27
26
|
nodeTypes,
|
|
28
|
-
colors,
|
|
29
27
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EdgeDefault } from "./../../../extensions/react-flow/edges/EdgeDefault";
|
|
2
|
+
import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault";
|
|
3
|
+
|
|
4
|
+
export const edgeTypes = {
|
|
5
|
+
default: EdgeDefault,
|
|
6
|
+
straight: EdgeDefault,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const nodeTypes = {
|
|
10
|
+
default: NodeDefault,
|
|
11
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { EdgeStep } from "./../../../extensions/react-flow/edges/EdgeStep";
|
|
3
3
|
import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault";
|
|
4
|
-
import colors from "./_colors-linking.module.scss";
|
|
5
4
|
|
|
6
5
|
const edgeTypes = {
|
|
7
6
|
default: EdgeStep,
|
|
@@ -24,5 +23,4 @@ const nodeTypes = {
|
|
|
24
23
|
export {
|
|
25
24
|
edgeTypes,
|
|
26
25
|
nodeTypes,
|
|
27
|
-
colors,
|
|
28
26
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EdgeStep } from "./../../../extensions/react-flow/edges/EdgeStep";
|
|
2
2
|
import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault";
|
|
3
|
-
import colors from "./_colors-workflow.module.scss";
|
|
4
3
|
|
|
5
4
|
const edgeTypes = {
|
|
6
5
|
default: EdgeStep,
|
|
@@ -21,5 +20,4 @@ const nodeTypes = {
|
|
|
21
20
|
export {
|
|
22
21
|
edgeTypes,
|
|
23
22
|
nodeTypes,
|
|
24
|
-
colors,
|
|
25
23
|
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on CSS Tricks tutorial.
|
|
3
|
+
* @see https://css-tricks.com/how-to-get-all-custom-properties-on-a-page-in-javascript/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
type AllowedCSSRule = CSSStyleRule | CSSPageRule; // they have necessary `selectorText` and `style` properties
|
|
7
|
+
|
|
8
|
+
interface getLocalCssStyleRulesProps {
|
|
9
|
+
cssRuleType?: "CSSStyleRule" | "CSSPageRule";
|
|
10
|
+
selectorText?: string;
|
|
11
|
+
}
|
|
12
|
+
interface getLocalCssStyleRulePropertiesProps extends getLocalCssStyleRulesProps {
|
|
13
|
+
propertyType?: "all" | "normal" | "custom";
|
|
14
|
+
}
|
|
15
|
+
interface getCustomPropertiesProps extends getLocalCssStyleRulesProps {
|
|
16
|
+
removeDashPrefix?: boolean;
|
|
17
|
+
returnObject?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default class CssCustomProperties {
|
|
21
|
+
|
|
22
|
+
getterDefaultProps = {} as getCustomPropertiesProps;
|
|
23
|
+
customprops = {};
|
|
24
|
+
|
|
25
|
+
constructor(props: getCustomPropertiesProps = {}) {
|
|
26
|
+
this.getterDefaultProps = props;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Methods
|
|
30
|
+
|
|
31
|
+
customProperties = (props: getCustomPropertiesProps = {}) => {
|
|
32
|
+
// FIXME:
|
|
33
|
+
// in case of performance issues results should get saved at least into intern variables
|
|
34
|
+
// other cache strategies could be also tested
|
|
35
|
+
if (Object.keys(this.customprops).length > 1) {
|
|
36
|
+
return this.customprops;
|
|
37
|
+
}
|
|
38
|
+
const customprops = CssCustomProperties.listCustomProperties({
|
|
39
|
+
...this.getterDefaultProps,
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
42
|
+
this.customprops = customprops;
|
|
43
|
+
return customprops;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static listLocalStylesheets = (): CSSStyleSheet[] => {
|
|
47
|
+
if (document && document.styleSheets) {
|
|
48
|
+
return (Array.from(document.styleSheets) as CSSStyleSheet[])
|
|
49
|
+
.filter((stylesheet) => {
|
|
50
|
+
// is inline stylesheet or from same domain
|
|
51
|
+
if (!stylesheet.href) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return stylesheet.href.indexOf(window.location.origin) === 0;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return [] as CSSStyleSheet[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static listLocalCssRules = (): CSSRule[] => {
|
|
62
|
+
return CssCustomProperties.listLocalStylesheets()
|
|
63
|
+
.map((stylesheet) => {
|
|
64
|
+
return Array.from(stylesheet.cssRules);
|
|
65
|
+
})
|
|
66
|
+
.flat();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static listLocalCssStyleRules = (filter: getLocalCssStyleRulesProps = {}): AllowedCSSRule[] => {
|
|
70
|
+
const {cssRuleType = "CSSStyleRule", selectorText} = filter;
|
|
71
|
+
const cssStyleRules = CssCustomProperties.listLocalCssRules()
|
|
72
|
+
.filter((rule) => {
|
|
73
|
+
const cssrule = rule as AllowedCSSRule;
|
|
74
|
+
if((cssrule).style) {
|
|
75
|
+
if (cssrule.constructor.name !== cssRuleType) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (!!selectorText && cssrule.selectorText !== selectorText) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return true;
|
|
82
|
+
} else {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
return cssStyleRules as AllowedCSSRule[]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static listLocalCssStyleRuleProperties = (filter: getLocalCssStyleRulePropertiesProps = {}) => {
|
|
90
|
+
const { propertyType = "all", ...otherFilters } = filter;
|
|
91
|
+
return CssCustomProperties.listLocalCssStyleRules(otherFilters)
|
|
92
|
+
.map((cssrule) => {
|
|
93
|
+
return [...cssrule.style]
|
|
94
|
+
.map((propertyname) => {
|
|
95
|
+
return [
|
|
96
|
+
propertyname.trim(),
|
|
97
|
+
cssrule.style.getPropertyValue(propertyname).trim()
|
|
98
|
+
];
|
|
99
|
+
});
|
|
100
|
+
})
|
|
101
|
+
.flat()
|
|
102
|
+
.filter((declaration) => {
|
|
103
|
+
switch(propertyType) {
|
|
104
|
+
case "normal":
|
|
105
|
+
return declaration[0].indexOf("--") !== 0;
|
|
106
|
+
case "custom":
|
|
107
|
+
return declaration[0].indexOf("--") === 0;
|
|
108
|
+
}
|
|
109
|
+
return true; // case "all"
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static listCustomProperties = (props: getCustomPropertiesProps = {}) => {
|
|
114
|
+
const {
|
|
115
|
+
removeDashPrefix = true,
|
|
116
|
+
returnObject = true,
|
|
117
|
+
...filterProps
|
|
118
|
+
} = props;
|
|
119
|
+
|
|
120
|
+
const customProperties = CssCustomProperties.listLocalCssStyleRuleProperties({
|
|
121
|
+
...filterProps,
|
|
122
|
+
propertyType: "custom",
|
|
123
|
+
}).map((declaration) => {
|
|
124
|
+
if (removeDashPrefix) {
|
|
125
|
+
return [
|
|
126
|
+
declaration[0].substr(2),
|
|
127
|
+
declaration[1]
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
return declaration;
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return returnObject ? Object.fromEntries(customProperties) : customProperties;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import CssCustomProperties from "./CssCustomProperties";
|
|
2
|
+
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
3
|
+
|
|
4
|
+
// Configurations can be found in `src/cmem/react-flow/configuration/_colors-*.scss`
|
|
5
|
+
type colorconfigs = "react-flow-graph" | "react-flow-linking" | "react-flow-workflow";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Read and returns color values provided by CSS custom properties.
|
|
9
|
+
* They are defined for special CSS classes.
|
|
10
|
+
* Currently color configurations for the react flow editors are supported.
|
|
11
|
+
**/
|
|
12
|
+
const getColorConfiguration = (configId: colorconfigs) => {
|
|
13
|
+
return new CssCustomProperties({
|
|
14
|
+
selectorText: `.${eccgui}-configuration--colors__${configId}`,
|
|
15
|
+
cssRuleType: "CSSStyleRule",
|
|
16
|
+
removeDashPrefix: true,
|
|
17
|
+
returnObject: true,
|
|
18
|
+
}).customProperties();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default getColorConfiguration;
|
|
@@ -32,9 +32,16 @@
|
|
|
32
32
|
.#{$prefix}--accordion__content {
|
|
33
33
|
padding: $eccgui-size-block-whitespace / 2;
|
|
34
34
|
margin: 0 calc(1rem + #{$eccgui-size-block-whitespace / 2}) 0 $eccgui-size-block-whitespace / 2;
|
|
35
|
+
display: block;
|
|
36
|
+
opacity: 0;
|
|
37
|
+
position: fixed;
|
|
38
|
+
left: -5000em;
|
|
35
39
|
|
|
36
40
|
.#{$prefix}--accordion__item--active & {
|
|
37
41
|
padding: $eccgui-size-block-whitespace / 2 $eccgui-size-block-whitespace / 2 $eccgui-size-block-whitespace $eccgui-size-block-whitespace / 2;
|
|
42
|
+
opacity: 1;
|
|
43
|
+
position: static;
|
|
44
|
+
left: auto;
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
.#{$prefix}--accordion--start & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {useEffect, useMemo, useState} from "react";
|
|
2
2
|
import CodeMirror from "codemirror";
|
|
3
3
|
import {FieldItem, IconButton, Spinner, Toolbar, ToolbarSection} from "./../../";
|
|
4
4
|
import {Classes as BlueprintClassNames} from "@blueprintjs/core";
|
|
@@ -235,7 +235,7 @@ const AutoSuggestion = ({
|
|
|
235
235
|
editorState.index = 0
|
|
236
236
|
}, [suggestionResponse, editorState]);
|
|
237
237
|
|
|
238
|
-
const asyncCheckInput = async (inputString: string) => {
|
|
238
|
+
const asyncCheckInput = useMemo(() => async (inputString: string) => {
|
|
239
239
|
if(!checkInput) {
|
|
240
240
|
return
|
|
241
241
|
}
|
|
@@ -249,16 +249,29 @@ const AutoSuggestion = ({
|
|
|
249
249
|
} finally {
|
|
250
250
|
setPathValidationPending(false)
|
|
251
251
|
}
|
|
252
|
-
}
|
|
252
|
+
}, [checkInput])
|
|
253
253
|
|
|
254
|
-
const checkValuePathValidity =
|
|
255
|
-
debounce((inputString: string) => asyncCheckInput(inputString),
|
|
256
|
-
[
|
|
254
|
+
const checkValuePathValidity = useMemo(
|
|
255
|
+
() => debounce((inputString: string) => asyncCheckInput(inputString), 1000),
|
|
256
|
+
[asyncCheckInput]
|
|
257
257
|
)
|
|
258
258
|
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
const asyncHandleEditorInputChange = useMemo(() => async (inputString: string, cursorPosition: number) => {
|
|
260
|
+
setSuggestionsPending(true)
|
|
261
|
+
try {
|
|
262
|
+
const result: IPartialAutoCompleteResult | undefined = await fetchSuggestions(inputString, cursorPosition)
|
|
263
|
+
setSuggestionResponse(result)
|
|
264
|
+
} catch(e) {
|
|
265
|
+
setSuggestionResponse(undefined)
|
|
266
|
+
// TODO: Error handling
|
|
267
|
+
} finally {
|
|
268
|
+
setSuggestionsPending(false)
|
|
269
|
+
}
|
|
270
|
+
}, [fetchSuggestions])
|
|
271
|
+
|
|
272
|
+
const handleEditorInputChange = useMemo(() =>
|
|
273
|
+
debounce((inputString: string, cursorPosition: number) => asyncHandleEditorInputChange(inputString, cursorPosition), 1000),
|
|
274
|
+
[asyncHandleEditorInputChange]
|
|
262
275
|
)
|
|
263
276
|
|
|
264
277
|
React.useEffect(() => {
|
|
@@ -276,19 +289,6 @@ const AutoSuggestion = ({
|
|
|
276
289
|
return checkValuePathValidity.cancel
|
|
277
290
|
}, [value, checkValuePathValidity])
|
|
278
291
|
|
|
279
|
-
const asyncHandleEditorInputChange = async (inputString: string, cursorPosition: number) => {
|
|
280
|
-
setSuggestionsPending(true)
|
|
281
|
-
try {
|
|
282
|
-
const result: IPartialAutoCompleteResult | undefined = await fetchSuggestions(inputString, cursorPosition)
|
|
283
|
-
setSuggestionResponse(result)
|
|
284
|
-
} catch(e) {
|
|
285
|
-
setSuggestionResponse(undefined)
|
|
286
|
-
// TODO: Error handling
|
|
287
|
-
} finally {
|
|
288
|
-
setSuggestionsPending(false)
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
292
|
const handleChange = (val: string) => {
|
|
293
293
|
setValue(val);
|
|
294
294
|
onChange(val)
|
|
@@ -427,7 +427,7 @@ const AutoSuggestion = ({
|
|
|
427
427
|
|
|
428
428
|
return label ? (
|
|
429
429
|
<FieldItem
|
|
430
|
-
|
|
430
|
+
labelProps={{
|
|
431
431
|
text: (
|
|
432
432
|
<>
|
|
433
433
|
{label}
|
|
@@ -143,23 +143,21 @@ export const AutoSuggestionList = ({
|
|
|
143
143
|
{options.map((item, index) => (
|
|
144
144
|
<MenuItem
|
|
145
145
|
key={index}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
},
|
|
146
|
+
active={currentlyFocusedIndex === index}
|
|
147
|
+
onMouseDown={(e: any) => e.preventDefault()}
|
|
148
|
+
onClick={() => onItemSelectionChange(item)}
|
|
149
|
+
text={(
|
|
150
|
+
<Item
|
|
151
|
+
ref={generateRef(index)}
|
|
152
|
+
item={item}
|
|
153
|
+
/>
|
|
154
|
+
)}
|
|
155
|
+
onMouseEnter={() => setHoveredItem(item)}
|
|
156
|
+
onMouseLeave={() => setHoveredItem(undefined)}
|
|
157
|
+
onMouseOver={() => {
|
|
158
|
+
if (item.value !== hoveredItem?.value) {
|
|
159
|
+
setHoveredItem(item);
|
|
160
|
+
}
|
|
163
161
|
}}
|
|
164
162
|
/>
|
|
165
163
|
))}
|
|
@@ -84,7 +84,7 @@ describe("Dropdown list", () => {
|
|
|
84
84
|
options: mockOptions
|
|
85
85
|
}
|
|
86
86
|
const {container} = render(<AutoSuggestionList {...props} />)
|
|
87
|
-
const activeListItems = Array.from(container.querySelectorAll("li .
|
|
87
|
+
const activeListItems = Array.from(container.querySelectorAll("li .bp4-menu-item.bp4-active"))
|
|
88
88
|
expect(activeListItems.length).toBe(1)
|
|
89
89
|
})
|
|
90
90
|
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
import React, {useEffect, useRef, useState} from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
HTMLInputProps as BlueprintHTMLInputProps,
|
|
4
|
+
InputGroupProps as BlueprintInputGroupProps,
|
|
5
|
+
IRefObject
|
|
6
|
+
} from "@blueprintjs/core";
|
|
7
|
+
import {
|
|
8
|
+
Suggest2 as Suggest
|
|
9
|
+
} from "@blueprintjs/select";
|
|
10
|
+
import {
|
|
11
|
+
Highlighter,
|
|
12
|
+
IconButton,
|
|
13
|
+
Menu,
|
|
14
|
+
Notification,
|
|
15
|
+
MenuItem,
|
|
16
|
+
OverflowText,
|
|
17
|
+
Spinner,
|
|
18
|
+
ContextOverlayProps,
|
|
19
|
+
} from "../../index";
|
|
5
20
|
import {CLASSPREFIX as eccgui} from "../../configuration/constants";
|
|
6
21
|
|
|
7
22
|
type SearchFunction<T extends any> = (value: string) => T[];
|
|
@@ -70,12 +85,12 @@ export interface IAutoCompleteFieldProps<T extends any, UPDATE_VALUE extends any
|
|
|
70
85
|
* `query` and `onQueryChange` instead of `inputProps.value` and
|
|
71
86
|
* `inputProps.onChange`.
|
|
72
87
|
*/
|
|
73
|
-
inputProps?:
|
|
88
|
+
inputProps?: BlueprintInputGroupProps & BlueprintHTMLInputProps;
|
|
74
89
|
|
|
75
90
|
/**
|
|
76
|
-
* Optional props of the
|
|
91
|
+
* Optional props of the internally used `<ContextOverlay/>` element..
|
|
77
92
|
*/
|
|
78
|
-
|
|
93
|
+
contextOverlayProps?: Partial<Omit<ContextOverlayProps, "content" | "children">>
|
|
79
94
|
|
|
80
95
|
/** Defines if a value can be reset, i.e. a reset icon is shown and the value is set to a specific value.
|
|
81
96
|
* When undefined, a value cannot be reset.
|
|
@@ -122,6 +137,9 @@ export interface IAutoCompleteFieldProps<T extends any, UPDATE_VALUE extends any
|
|
|
122
137
|
* @param selectedValue The currently selected value.
|
|
123
138
|
*/
|
|
124
139
|
resetQueryToValue?(selectedValue: T): string
|
|
140
|
+
|
|
141
|
+
/** If an error occurs during the auto-completion request, the error details will be prefixed with this string. */
|
|
142
|
+
requestErrorPrefix?: string
|
|
125
143
|
}
|
|
126
144
|
|
|
127
145
|
AutoCompleteField.defaultProps = {
|
|
@@ -160,6 +178,7 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
160
178
|
itemValueRenderer,
|
|
161
179
|
resetQueryToValue,
|
|
162
180
|
itemValueString,
|
|
181
|
+
requestErrorPrefix = "",
|
|
163
182
|
...otherProps
|
|
164
183
|
} = props;
|
|
165
184
|
const [selectedItem, setSelectedItem] = useState<T | undefined>(initialValue);
|
|
@@ -169,11 +188,12 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
169
188
|
const [query, setQuery] = useState<string>("");
|
|
170
189
|
const [hasFocus, setHasFocus] = useState<boolean>(false);
|
|
171
190
|
const [highlightingEnabled, setHighlightingEnabled] = useState<boolean>(true);
|
|
191
|
+
const [requestError, setRequestError] = useState<string | undefined>(undefined)
|
|
172
192
|
|
|
173
193
|
// The suggestions that match the user's input
|
|
174
194
|
const [filtered, setFiltered] = useState<T[]>([]);
|
|
175
195
|
|
|
176
|
-
const
|
|
196
|
+
const BlueprintSuggestAutocomplete = Suggest.ofType<T>();
|
|
177
197
|
|
|
178
198
|
// Sets the query to the item value if it has a valid string value
|
|
179
199
|
const setQueryToSelectedValue = (item?: T) => {
|
|
@@ -262,6 +282,7 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
262
282
|
// Fetches the results for the given query
|
|
263
283
|
const fetchQueryResults = async (input: string) => {
|
|
264
284
|
setListLoading(true);
|
|
285
|
+
setRequestError(undefined)
|
|
265
286
|
try {
|
|
266
287
|
let result = await onSearch(input);
|
|
267
288
|
const onlySelectItemReturned = result.length <= 1 && selectedItem && input.length > 0 &&
|
|
@@ -282,8 +303,9 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
282
303
|
}
|
|
283
304
|
setHighlightingEnabled(enableHighlighting);
|
|
284
305
|
setFiltered(result);
|
|
285
|
-
} catch (e) {
|
|
286
|
-
|
|
306
|
+
} catch (e: any) {
|
|
307
|
+
const details = e?.message ?? ""
|
|
308
|
+
setRequestError(requestErrorPrefix + details)
|
|
287
309
|
} finally {
|
|
288
310
|
setListLoading(false);
|
|
289
311
|
}
|
|
@@ -325,6 +347,9 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
325
347
|
onChange?.(resetValue);
|
|
326
348
|
setQuery("");
|
|
327
349
|
};
|
|
350
|
+
const requestErrorRenderer = () => {
|
|
351
|
+
return <Notification danger={true} message={requestError} />
|
|
352
|
+
}
|
|
328
353
|
// Optional clear button to reset the selected value
|
|
329
354
|
const clearButton = reset &&
|
|
330
355
|
selectedItem != null &&
|
|
@@ -339,21 +364,20 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
339
364
|
/>
|
|
340
365
|
) : undefined;
|
|
341
366
|
// Additional properties for the input element of the auto-completion widget
|
|
342
|
-
const updatedInputProps:
|
|
367
|
+
const updatedInputProps: BlueprintInputGroupProps & BlueprintHTMLInputProps = {
|
|
343
368
|
rightElement: clearButton,
|
|
344
369
|
autoFocus: autoFocus,
|
|
345
370
|
onBlur: handleOnFocusOut,
|
|
346
371
|
onFocus: handleOnFocusIn,
|
|
347
372
|
...otherProps.inputProps,
|
|
348
373
|
};
|
|
349
|
-
const
|
|
374
|
+
const updatedContextOverlayProps: Partial<Omit<ContextOverlayProps, "content" | "children">> = {
|
|
350
375
|
minimal: true,
|
|
351
|
-
|
|
376
|
+
placement: "bottom-start",
|
|
352
377
|
popoverClassName: `${eccgui}-autocompletefield__options`,
|
|
353
|
-
|
|
354
|
-
boundary: "window",
|
|
378
|
+
rootBoundary: "viewport",
|
|
355
379
|
onClosed: onPopoverClose,
|
|
356
|
-
...otherProps.
|
|
380
|
+
...otherProps.contextOverlayProps,
|
|
357
381
|
}
|
|
358
382
|
if(selectedItem !== undefined) {
|
|
359
383
|
// Makes sure that even when an empty string is selected, the placeholder won't be shown.
|
|
@@ -375,12 +399,13 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
375
399
|
} : {}
|
|
376
400
|
return (
|
|
377
401
|
<div ref={fieldRef}>
|
|
378
|
-
<
|
|
402
|
+
<BlueprintSuggestAutocomplete
|
|
379
403
|
className={`${eccgui}-autocompletefield__input`}
|
|
380
404
|
disabled={disabled}
|
|
381
|
-
|
|
405
|
+
// Need to display error messages in list
|
|
406
|
+
items={requestError ? [requestError as T] : filtered}
|
|
382
407
|
inputValueRenderer={selectedItem !== undefined ? itemValueRenderer : () => ""}
|
|
383
|
-
itemRenderer={optionRenderer}
|
|
408
|
+
itemRenderer={requestError ? requestErrorRenderer : optionRenderer}
|
|
384
409
|
itemsEqual={areEqualItems}
|
|
385
410
|
noResults={<MenuItem disabled={true} text={noResultText} style={fieldWidthLimits} />}
|
|
386
411
|
onItemSelect={onSelectionChange}
|
|
@@ -388,7 +413,7 @@ export function AutoCompleteField<T extends any, UPDATE_VALUE extends any>(props
|
|
|
388
413
|
closeOnSelect={true}
|
|
389
414
|
query={query}
|
|
390
415
|
// This leads to odd compile errors without "as any"
|
|
391
|
-
popoverProps={
|
|
416
|
+
popoverProps={updatedContextOverlayProps as any}
|
|
392
417
|
selectedItem={selectedItem}
|
|
393
418
|
fill
|
|
394
419
|
{...createNewItemProps}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {ComponentMeta, ComponentStory} from "@storybook/react";
|
|
3
|
+
|
|
4
|
+
import {AutoCompleteField, IAutoCompleteFieldProps} from "../AutoCompleteField";
|
|
5
|
+
import {extractSearchWords, matchesAllWords} from "../../Typography/Highlighter";
|
|
6
|
+
import {createNewItemRendererFactory} from "../autoCompleteFieldUtils";
|
|
7
|
+
|
|
8
|
+
const AutoCompleteFieldStory: ComponentMeta<typeof AutoCompleteField> = {
|
|
9
|
+
title: "Components/AutoCompleteField",
|
|
10
|
+
component: AutoCompleteField,
|
|
11
|
+
argTypes: {
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Template: ComponentStory<typeof AutoCompleteField> = (args) => (
|
|
16
|
+
<AutoCompleteField {...args}></AutoCompleteField>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const Default = Template.bind({});
|
|
20
|
+
export const AdaptQueryAfterSelection = Template.bind({})
|
|
21
|
+
export const AllowReset = Template.bind({})
|
|
22
|
+
export const AllowCustomValues = Template.bind({})
|
|
23
|
+
|
|
24
|
+
// Renders string values as string
|
|
25
|
+
const defaultRenderer = (item: string) => item
|
|
26
|
+
|
|
27
|
+
const defaultArgs: IAutoCompleteFieldProps<string, string> = {
|
|
28
|
+
itemRenderer: (item: string) => `Rendered item: ${item}`,
|
|
29
|
+
itemValueRenderer: (item: string) => `Selected item: ${item}`,
|
|
30
|
+
itemValueString: (item: string) => `Query: ${item}`,
|
|
31
|
+
onSearch: (query: string) => {
|
|
32
|
+
const multiWord = extractSearchWords(query, true)
|
|
33
|
+
return ["search item A", "search element B", "search object C"]
|
|
34
|
+
.filter(word => matchesAllWords(word.toLowerCase(), multiWord))
|
|
35
|
+
},
|
|
36
|
+
onChange: elem => {
|
|
37
|
+
console.log(`Entry '${elem}' selected!`)
|
|
38
|
+
},
|
|
39
|
+
itemValueSelector: defaultRenderer,
|
|
40
|
+
noResultText: "No result"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Changes the search query for the selected item, e.g. when the rendered item text should be different from the query finding this item.
|
|
44
|
+
const adaptQueryAfterSelection: IAutoCompleteFieldProps<string, string> = {
|
|
45
|
+
...defaultArgs,
|
|
46
|
+
resetQueryToValue: (selectedValue: string) => selectedValue
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Allows to reset a selection
|
|
50
|
+
const resetSelection: IAutoCompleteFieldProps<string, string> = {
|
|
51
|
+
...defaultArgs,
|
|
52
|
+
reset: {
|
|
53
|
+
resetValue: "",
|
|
54
|
+
resetButtonText: "Clear selected value",
|
|
55
|
+
resettableValue: (value: string) => true
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const allowCustomValues: IAutoCompleteFieldProps<string, string> = {
|
|
60
|
+
...defaultArgs,
|
|
61
|
+
createNewItem: {
|
|
62
|
+
itemRenderer: createNewItemRendererFactory(
|
|
63
|
+
(query: string) => `Create new item: ${query}`,
|
|
64
|
+
"item-add-artefact"
|
|
65
|
+
),
|
|
66
|
+
itemFromQuery: item => item,
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
Default.args = defaultArgs;
|
|
71
|
+
AdaptQueryAfterSelection.args = adaptQueryAfterSelection
|
|
72
|
+
AllowReset.args = resetSelection
|
|
73
|
+
AllowCustomValues.args = allowCustomValues
|
|
74
|
+
|
|
75
|
+
export default AutoCompleteFieldStory
|
|
@@ -52,7 +52,7 @@ export interface ButtonProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
52
52
|
/**
|
|
53
53
|
* Object with additional properties for the tooltip.
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
tooltipProps?: Partial<Omit<TooltipProps, "content" | "children">>;
|
|
56
56
|
/**
|
|
57
57
|
* If an URL is set then the button is included as HTML anchor element instead of a button form element.
|
|
58
58
|
*/
|
|
@@ -79,7 +79,7 @@ function Button({
|
|
|
79
79
|
icon,
|
|
80
80
|
rightIcon,
|
|
81
81
|
tooltip = null,
|
|
82
|
-
|
|
82
|
+
tooltipProps,
|
|
83
83
|
...restProps
|
|
84
84
|
}: ButtonProps & AnchorOrButtonProps) {
|
|
85
85
|
let intention;
|
|
@@ -117,7 +117,7 @@ function Button({
|
|
|
117
117
|
);
|
|
118
118
|
|
|
119
119
|
return (tooltip && !restProps.loading) ? (
|
|
120
|
-
<Tooltip content={tooltip} {...
|
|
120
|
+
<Tooltip content={tooltip} {...tooltipProps}>
|
|
121
121
|
<span>{button}</span>
|
|
122
122
|
</Tooltip>
|
|
123
123
|
) : (
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ComponentStory, ComponentMeta } from "@storybook/react";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ContextMenu,
|
|
6
|
+
MenuItem,
|
|
7
|
+
} from "../../index";
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: "Components/ContextMenu",
|
|
11
|
+
component: ContextMenu,
|
|
12
|
+
subcomponents: { MenuItem },
|
|
13
|
+
argTypes: {
|
|
14
|
+
children: {
|
|
15
|
+
control: "none",
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
} as ComponentMeta<typeof ContextMenu>;
|
|
19
|
+
|
|
20
|
+
const Template: ComponentStory<typeof ContextMenu> = (args) => (
|
|
21
|
+
<ContextMenu {...args} />
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export const Default = Template.bind({});
|
|
25
|
+
Default.args = {
|
|
26
|
+
children: [
|
|
27
|
+
<MenuItem key="m0" text={"First option"} />,
|
|
28
|
+
<MenuItem key="m1" text={"Item two"} />
|
|
29
|
+
]
|
|
30
|
+
}
|