@eccenca/gui-elements 23.1.0-easynav.3 → 23.1.0-easynav.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 +7 -0
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js +6 -4
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/cjs/cmem/ActivityControl/SilkActivityControl.js +33 -8
- package/dist/cjs/cmem/ActivityControl/SilkActivityControl.js.map +1 -1
- package/dist/cjs/cmem/ConfidenceValue/ConfidenceValue.js +52 -0
- package/dist/cjs/cmem/ConfidenceValue/ConfidenceValue.js.map +1 -0
- package/dist/cjs/cmem/ConfidenceValue/index.js +14 -0
- package/dist/cjs/cmem/ConfidenceValue/index.js.map +1 -0
- package/dist/cjs/cmem/index.js +11 -0
- package/dist/cjs/cmem/index.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/SingleLineCodeEditor.js +8 -10
- package/dist/cjs/components/AutoSuggestion/SingleLineCodeEditor.js.map +1 -1
- package/dist/cjs/components/Card/Card.js +7 -6
- package/dist/cjs/components/Card/Card.js.map +1 -1
- package/dist/cjs/components/Card/CardContent.js +4 -2
- package/dist/cjs/components/Card/CardContent.js.map +1 -1
- package/dist/cjs/components/Card/CardHeader.js.map +1 -1
- package/dist/cjs/components/Icon/canonicalIconNames.js +6 -0
- package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/cjs/components/Pagination/Pagination.js +24 -9
- package/dist/cjs/components/Pagination/Pagination.js.map +1 -1
- package/dist/cjs/components/ProgressBar/index.js +14 -0
- package/dist/cjs/components/ProgressBar/index.js.map +1 -0
- package/dist/cjs/components/Switch/Switch.js +2 -2
- package/dist/cjs/components/Switch/Switch.js.map +1 -1
- package/dist/cjs/components/Table/Table.js +45 -0
- package/dist/cjs/components/Table/Table.js.map +1 -0
- package/dist/cjs/components/{SimpleTable → Table}/TableContainer.js +7 -8
- package/dist/cjs/components/Table/TableContainer.js.map +1 -0
- package/dist/cjs/components/Table/TableExpandHeader.js +34 -0
- package/dist/cjs/components/Table/TableExpandHeader.js.map +1 -0
- package/dist/cjs/components/Table/TableExpandRow.js +42 -0
- package/dist/cjs/components/Table/TableExpandRow.js.map +1 -0
- package/dist/cjs/components/Table/index.js +29 -0
- package/dist/cjs/components/Table/index.js.map +1 -0
- package/dist/cjs/components/Tag/TagList.js.map +1 -1
- package/dist/cjs/components/Tag/index.js +11 -0
- package/dist/cjs/components/Tag/index.js.map +1 -0
- package/dist/cjs/components/TextField/TextField.js +25 -9
- package/dist/cjs/components/TextField/TextField.js.map +1 -1
- package/dist/cjs/components/index.js +4 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/index.js +3 -19
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js +6 -4
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/esm/cmem/ActivityControl/SilkActivityControl.js +35 -10
- package/dist/esm/cmem/ActivityControl/SilkActivityControl.js.map +1 -1
- package/dist/esm/cmem/ConfidenceValue/ConfidenceValue.js +56 -0
- package/dist/esm/cmem/ConfidenceValue/ConfidenceValue.js.map +1 -0
- package/dist/esm/cmem/ConfidenceValue/index.js +2 -0
- package/dist/esm/cmem/ConfidenceValue/index.js.map +1 -0
- package/dist/esm/cmem/index.js +1 -0
- package/dist/esm/cmem/index.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/SingleLineCodeEditor.js +8 -10
- package/dist/esm/components/AutoSuggestion/SingleLineCodeEditor.js.map +1 -1
- package/dist/esm/components/Card/Card.js +7 -6
- package/dist/esm/components/Card/Card.js.map +1 -1
- package/dist/esm/components/Card/CardContent.js +4 -2
- package/dist/esm/components/Card/CardContent.js.map +1 -1
- package/dist/esm/components/Card/CardHeader.js.map +1 -1
- package/dist/esm/components/Icon/canonicalIconNames.js +6 -0
- package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js +25 -10
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/ProgressBar/index.js +2 -0
- package/dist/esm/components/ProgressBar/index.js.map +1 -0
- package/dist/esm/components/Switch/Switch.js +2 -2
- package/dist/esm/components/Switch/Switch.js.map +1 -1
- package/dist/esm/components/Table/Table.js +50 -0
- package/dist/esm/components/Table/Table.js.map +1 -0
- package/dist/esm/components/{SimpleTable → Table}/TableContainer.js +7 -8
- package/dist/esm/components/Table/TableContainer.js.map +1 -0
- package/dist/esm/components/Table/TableExpandHeader.js +40 -0
- package/dist/esm/components/Table/TableExpandHeader.js.map +1 -0
- package/dist/esm/components/Table/TableExpandRow.js +48 -0
- package/dist/esm/components/Table/TableExpandRow.js.map +1 -0
- package/dist/esm/components/Table/index.js +15 -0
- package/dist/esm/components/Table/index.js.map +1 -0
- package/dist/esm/components/Tag/TagList.js.map +1 -1
- package/dist/esm/components/Tag/index.js +4 -0
- package/dist/esm/components/Tag/index.js.map +1 -0
- package/dist/esm/components/TextField/TextField.js +26 -10
- package/dist/esm/components/TextField/TextField.js.map +1 -1
- package/dist/esm/components/index.js +4 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/index.js +3 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/types/cmem/ActivityControl/ActivityControlWidget.d.ts +1 -1
- package/dist/types/cmem/ActivityControl/SilkActivityControl.d.ts +6 -2
- package/dist/types/cmem/ConfidenceValue/ConfidenceValue.d.ts +46 -0
- package/dist/types/cmem/ConfidenceValue/index.d.ts +1 -0
- package/dist/types/cmem/index.d.ts +1 -0
- package/dist/types/components/Card/Card.d.ts +5 -1
- package/dist/types/components/Card/CardContent.d.ts +7 -1
- package/dist/types/components/Card/CardHeader.d.ts +9 -1
- package/dist/types/components/Icon/IconButton.d.ts +1 -1
- package/dist/types/components/Icon/canonicalIconNames.d.ts +1 -1
- package/dist/types/components/Pagination/Pagination.d.ts +5 -1
- package/dist/types/components/ProgressBar/index.d.ts +1 -0
- package/dist/types/components/Switch/Switch.d.ts +5 -1
- package/dist/types/components/Table/Table.d.ts +32 -0
- package/dist/types/components/Table/TableContainer.d.ts +13 -0
- package/dist/types/components/Table/TableExpandHeader.d.ts +13 -0
- package/dist/types/components/Table/TableExpandRow.d.ts +13 -0
- package/dist/types/components/Table/index.d.ts +13 -0
- package/dist/types/components/Tag/Tag.d.ts +1 -1
- package/dist/types/components/Tag/TagList.d.ts +5 -2
- package/dist/types/components/Tag/index.d.ts +4 -0
- package/dist/types/components/TextField/TextField.d.ts +9 -0
- package/dist/types/components/index.d.ts +4 -0
- package/dist/types/index.d.ts +1 -6
- package/package.json +1 -1
- package/src/cmem/ActivityControl/ActivityControlWidget.tsx +5 -5
- package/src/cmem/ActivityControl/SilkActivityControl.tsx +44 -17
- package/src/cmem/ConfidenceValue/ConfidenceValue.stories.tsx +22 -0
- package/src/cmem/ConfidenceValue/ConfidenceValue.tsx +116 -0
- package/src/cmem/ConfidenceValue/confidencevalue.scss +49 -0
- package/src/cmem/ConfidenceValue/index.ts +1 -0
- package/src/cmem/_index.scss +1 -0
- package/src/cmem/index.ts +2 -0
- package/src/components/AutoSuggestion/SingleLineCodeEditor.tsx +8 -10
- package/src/components/AutoSuggestion/tests/SingleLineCodeEditor.test.tsx +5 -0
- package/src/components/Badge/badge.scss +2 -5
- package/src/components/Card/Card.tsx +11 -5
- package/src/components/Card/CardContent.tsx +12 -1
- package/src/components/Card/CardHeader.tsx +9 -1
- package/src/components/Card/card.scss +108 -3
- package/src/components/Checkbox/checkbox.scss +6 -2
- package/src/components/Icon/IconButton.tsx +1 -1
- package/src/components/Icon/canonicalIconNames.tsx +13 -0
- package/src/components/Menu/menu.scss +4 -0
- package/src/components/OverviewItem/overviewitem.scss +2 -2
- package/src/components/Pagination/Pagination.tsx +29 -9
- package/src/components/Pagination/pagination.scss +16 -0
- package/src/components/ProgressBar/index.ts +1 -0
- package/src/components/Switch/Switch.tsx +6 -2
- package/src/components/Table/Table.tsx +88 -0
- package/src/components/Table/TableContainer.tsx +49 -0
- package/src/components/Table/TableExpandHeader.tsx +51 -0
- package/src/components/Table/TableExpandRow.tsx +64 -0
- package/src/components/Table/index.tsx +41 -0
- package/src/components/Table/table.scss +318 -0
- package/src/components/Tag/Tag.tsx +1 -1
- package/src/components/Tag/TagList.tsx +5 -3
- package/src/components/Tag/index.ts +5 -0
- package/src/components/Tag/{Tag.stories.tsx → stories/Tag.stories.tsx} +3 -2
- package/src/components/Tag/stories/TagList.stories.tsx +28 -0
- package/src/components/Tag/tag.scss +1 -0
- package/src/components/TextField/TextField.tsx +43 -12
- package/src/components/TextField/stories/TextField.stories.tsx +3 -0
- package/src/components/TextField/textfield.scss +23 -1
- package/src/components/Tree/tree.scss +4 -0
- package/src/components/index.scss +1 -0
- package/src/components/index.ts +5 -0
- package/src/extensions/react-flow/_config.scss +1 -1
- package/src/extensions/react-flow/edges/_edges.scss +25 -24
- package/src/extensions/react-flow/edges/stories/EdgeLabel.stories.tsx +3 -2
- package/src/extensions/react-flow/nodes/_nodes.scss +3 -4
- package/src/index.scss +0 -1
- package/src/index.ts +5 -38
- package/dist/cjs/components/SimpleTable/TableContainer.js.map +0 -1
- package/dist/cjs/components/SimpleTable/index.js +0 -16
- package/dist/cjs/components/SimpleTable/index.js.map +0 -1
- package/dist/esm/components/SimpleTable/TableContainer.js.map +0 -1
- package/dist/esm/components/SimpleTable/index.js +0 -4
- package/dist/esm/components/SimpleTable/index.js.map +0 -1
- package/dist/types/components/SimpleTable/TableContainer.d.ts +0 -3
- package/dist/types/components/SimpleTable/index.d.ts +0 -3
- package/src/components/SimpleTable/TableContainer.tsx +0 -20
- package/src/components/SimpleTable/index.tsx +0 -4
- package/src/components/SimpleTable/simpletable.scss +0 -180
|
@@ -5,7 +5,7 @@ import Icon from "./Icon";
|
|
|
5
5
|
import { TestIconProps } from "./TestIcon";
|
|
6
6
|
import {ValidIconName} from "./canonicalIconNames";
|
|
7
7
|
|
|
8
|
-
interface IconButtonProps extends Omit<ButtonProps, "icon" | "rightIcon" | "text" | "minimal" | "tooltip"> {
|
|
8
|
+
export interface IconButtonProps extends Omit<ButtonProps, "icon" | "rightIcon" | "text" | "minimal" | "tooltip"> {
|
|
9
9
|
/**
|
|
10
10
|
* Canonical icon name, or an array of strings.
|
|
11
11
|
* In case of the array the first valid icon name is used.
|
|
@@ -62,6 +62,7 @@ export type ValidIconName =
|
|
|
62
62
|
| "item-save"
|
|
63
63
|
| "item-settings"
|
|
64
64
|
| "item-shuffle"
|
|
65
|
+
| "item-skip-forward"
|
|
65
66
|
| "item-start"
|
|
66
67
|
| "item-stop"
|
|
67
68
|
| "item-upload"
|
|
@@ -116,15 +117,20 @@ export type ValidIconName =
|
|
|
116
117
|
| "state-unchecked"
|
|
117
118
|
| "state-warning"
|
|
118
119
|
| "toggler-caret"
|
|
120
|
+
| "toggler-caretright"
|
|
121
|
+
| "toggler-caretdown"
|
|
119
122
|
| "toggler-maximize"
|
|
120
123
|
| "toggler-minimize"
|
|
121
124
|
| "toggler-moveleft"
|
|
122
125
|
| "toggler-moveright"
|
|
126
|
+
| "toggler-rowexpand"
|
|
127
|
+
| "toggler-rowcollapse"
|
|
123
128
|
| "toggler-showless"
|
|
124
129
|
| "toggler-showmore"
|
|
125
130
|
| "toggler-star-empty"
|
|
126
131
|
| "toggler-star-filled"
|
|
127
132
|
| "toggler-tree"
|
|
133
|
+
| "form-template"
|
|
128
134
|
| "undefined";
|
|
129
135
|
|
|
130
136
|
export type CarbonIconType = React.ComponentType<CarbonIconProps>;
|
|
@@ -198,6 +204,7 @@ const canonicalIconNames: Record<ValidIconName, CarbonIconType> = {
|
|
|
198
204
|
"item-save": icons.Save,
|
|
199
205
|
"item-settings": icons.Settings,
|
|
200
206
|
"item-shuffle": icons.Shuffle,
|
|
207
|
+
"item-skip-forward": icons.SkipForwardFilled,
|
|
201
208
|
"item-start": icons.PlayFilledAlt,
|
|
202
209
|
"item-stop": icons.StopFilledAlt,
|
|
203
210
|
"item-upload": icons.Upload,
|
|
@@ -258,16 +265,22 @@ const canonicalIconNames: Record<ValidIconName, CarbonIconType> = {
|
|
|
258
265
|
"state-warning": icons.WarningAltFilled,
|
|
259
266
|
|
|
260
267
|
"toggler-caret": icons.CaretSort,
|
|
268
|
+
"toggler-caretright": icons.CaretRight,
|
|
269
|
+
"toggler-caretdown": icons.CaretDown,
|
|
261
270
|
"toggler-maximize": icons.Maximize,
|
|
262
271
|
"toggler-minimize": icons.Minimize,
|
|
263
272
|
"toggler-moveleft": icons.ChevronLeft,
|
|
264
273
|
"toggler-moveright": icons.ChevronRight,
|
|
274
|
+
"toggler-rowexpand": icons.RowExpand,
|
|
275
|
+
"toggler-rowcollapse": icons.RowCollapse,
|
|
265
276
|
"toggler-showless": icons.ChevronUp,
|
|
266
277
|
"toggler-showmore": icons.ChevronDown,
|
|
267
278
|
"toggler-star-empty": icons.Star,
|
|
268
279
|
"toggler-star-filled": icons.StarFilled,
|
|
269
280
|
"toggler-tree": icons.TreeViewAlt,
|
|
270
281
|
|
|
282
|
+
"form-template": icons.Parameter,
|
|
283
|
+
|
|
271
284
|
undefined: icons.Undefined,
|
|
272
285
|
};
|
|
273
286
|
|
|
@@ -176,9 +176,9 @@ $eccgui-size-overviewitem-line-typo-large-lineheight: $eccgui-size-typo-subtitle
|
|
|
176
176
|
justify-content: flex-end;
|
|
177
177
|
align-items: center;
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
&:not(:first-child) {
|
|
180
180
|
margin-left: mini-units(1);
|
|
181
|
-
|
|
181
|
+
}
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
.#{$eccgui}-overviewitem__actions--hiddeninteractions {
|
|
@@ -26,6 +26,10 @@ export interface PaginationProps extends CarbonPaginationProps {
|
|
|
26
26
|
* Hide prev/next arrows to navigate through the pages.
|
|
27
27
|
*/
|
|
28
28
|
hideNavigationArrows?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Element is displayed with dividing borders.
|
|
31
|
+
*/
|
|
32
|
+
hideBorders?: boolean;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
function Pagination({
|
|
@@ -34,6 +38,7 @@ function Pagination({
|
|
|
34
38
|
hideInfoText = false,
|
|
35
39
|
hidePageSelect = false,
|
|
36
40
|
hideNavigationArrows = false,
|
|
41
|
+
hideBorders = false,
|
|
37
42
|
...otherProps
|
|
38
43
|
}: PaginationProps) {
|
|
39
44
|
return (
|
|
@@ -45,7 +50,8 @@ function Pagination({
|
|
|
45
50
|
(hidePageSizeConfiguration ? ` ${eccgui}-pagination--hidepagesize` : "") +
|
|
46
51
|
(hideInfoText ? ` ${eccgui}-pagination--hideinfotext` : "") +
|
|
47
52
|
(hidePageSelect ? ` ${eccgui}-pagination--hidepageselect` : "") +
|
|
48
|
-
(hideNavigationArrows ? ` ${eccgui}-pagination--hidenavigation` : "")
|
|
53
|
+
(hideNavigationArrows ? ` ${eccgui}-pagination--hidenavigation` : "") +
|
|
54
|
+
(hideBorders ? ` ${eccgui}-pagination--hideborders` : "")
|
|
49
55
|
}
|
|
50
56
|
/>
|
|
51
57
|
);
|
|
@@ -74,19 +80,33 @@ export const usePagination = ({
|
|
|
74
80
|
initialPageSize,
|
|
75
81
|
}: IPaginationOptions) => {
|
|
76
82
|
const minSize = Math.min(...pageSizes);
|
|
77
|
-
const
|
|
83
|
+
const _pagination = React.useRef<IPaginationDetails>({
|
|
78
84
|
total: 0,
|
|
79
85
|
current: 1,
|
|
80
86
|
limit: initialPageSize ? initialPageSize : minSize,
|
|
81
87
|
minPageSize: minSize,
|
|
82
|
-
})
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
})
|
|
89
|
+
const [pagination, _setPagination] = useState<IPaginationDetails>(_pagination.current);
|
|
90
|
+
const setPagination = React.useCallback((newPagination: IPaginationDetails) => {
|
|
91
|
+
// Check if pagination has actually changed
|
|
92
|
+
const current = _pagination.current
|
|
93
|
+
if (newPagination.current !== current.current ||
|
|
94
|
+
newPagination.minPageSize !== current.minPageSize ||
|
|
95
|
+
newPagination.limit !== current.limit ||
|
|
96
|
+
newPagination.total !== current.total) {
|
|
97
|
+
_pagination.current = newPagination
|
|
98
|
+
_setPagination(newPagination)
|
|
99
|
+
}
|
|
100
|
+
}, [])
|
|
101
|
+
const onPaginationChange = React.useCallback(({ page, pageSize }: {page: any, pageSize: any}) => {
|
|
102
|
+
setPagination({ ..._pagination.current, current: page, limit: pageSize });
|
|
103
|
+
}, [setPagination]);
|
|
86
104
|
// When the total number of pageable items changes, this function must be called
|
|
87
|
-
const onTotalChange = (total: number): void => {
|
|
88
|
-
|
|
89
|
-
|
|
105
|
+
const onTotalChange = React.useCallback((total: number): void => {
|
|
106
|
+
if(_pagination.current.total !== total) {
|
|
107
|
+
setPagination({ ..._pagination.current, total: total, current: 1 });
|
|
108
|
+
}
|
|
109
|
+
}, [setPagination]);
|
|
90
110
|
const paginationElement = (
|
|
91
111
|
<Pagination
|
|
92
112
|
onChange={onPaginationChange}
|
|
@@ -46,3 +46,19 @@ span.#{$prefix}--pagination__text {
|
|
|
46
46
|
display: none;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
.#{$eccgui}-pagination--hideborders {
|
|
51
|
+
border-top: none;
|
|
52
|
+
|
|
53
|
+
.#{$prefix}--select__item-count .#{$prefix}--select-input {
|
|
54
|
+
border-right: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.#{$prefix}--select__page-number .#{$prefix}--select-input {
|
|
58
|
+
border-left: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.#{$prefix}--pagination__button {
|
|
62
|
+
border-left: none;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ProgressBar";
|
|
@@ -10,16 +10,20 @@ export interface SwitchProps extends Omit<BlueprintSwitchProps, "onChange"> {
|
|
|
10
10
|
* Event handler for changed state.
|
|
11
11
|
*/
|
|
12
12
|
onChange?: (value: boolean) => any
|
|
13
|
+
/**
|
|
14
|
+
* class names
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
function Switch({onChange, ...otherProps}: SwitchProps) {
|
|
19
|
+
function Switch({onChange, className, ...otherProps}: SwitchProps) {
|
|
16
20
|
const handleChange = (e: SyntheticEvent<HTMLInputElement>) => {
|
|
17
21
|
const checked = !!(e as any).target?.checked
|
|
18
22
|
onChange && onChange(checked);
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
return <BlueprintSwitch
|
|
22
|
-
className={`${eccgui}-switch`}
|
|
26
|
+
className={`${eccgui}-switch ${className}`}
|
|
23
27
|
{...otherProps}
|
|
24
28
|
onChange={handleChange}
|
|
25
29
|
/>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
Table as CarbonTable,
|
|
4
|
+
TableProps as CarbonTableProps,
|
|
5
|
+
DataTableSize as CarbonDataTableSize,
|
|
6
|
+
} from "carbon-components-react";
|
|
7
|
+
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
8
|
+
|
|
9
|
+
type TableRowHeightSizeDepracted = "compact" | "tall"; // @deprecated
|
|
10
|
+
export type TableRowHeightSize = "small" | "medium" | "large" | TableRowHeightSizeDepracted;
|
|
11
|
+
|
|
12
|
+
export interface TableProps extends Omit<
|
|
13
|
+
CarbonTableProps,
|
|
14
|
+
"size" | "overflowMenuOnHover" | "stickyHeader" | "useStaticWidth"
|
|
15
|
+
>, React.TableHTMLAttributes<HTMLTableElement> {
|
|
16
|
+
/**
|
|
17
|
+
* Sets basically the height of a row inside the table.
|
|
18
|
+
* Please use only `small`, `medium` and `large`.
|
|
19
|
+
* `compact` and `tall` are deprecated.
|
|
20
|
+
*/
|
|
21
|
+
size?: TableRowHeightSize;
|
|
22
|
+
/**
|
|
23
|
+
* All rows are divided by horizontal borders.
|
|
24
|
+
*/
|
|
25
|
+
hasDivider?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* This will lead to a `colgroup` element within the `table` setting `with` styles for each column.
|
|
28
|
+
* The table is then displayed `fixed`.
|
|
29
|
+
* All values need to be valid CSS width expression, e.g. `30px`, `5rem`, `40%`.
|
|
30
|
+
* If you need to add more attributes to the `col` elements, e.g. class names, then you need to control `colgroup` and `fixed` table by yourself.
|
|
31
|
+
*/
|
|
32
|
+
columnWidths?: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Table is displayed without any own coloring.
|
|
35
|
+
* For example this can be used for sub tables inside other elements with already set background colors.
|
|
36
|
+
* Zebra styles won't work if this option is enabled!
|
|
37
|
+
*/
|
|
38
|
+
colorless?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const tableRowHeightSizes: Record<string, CarbonDataTableSize> = {
|
|
42
|
+
// current values
|
|
43
|
+
"small": "xs",
|
|
44
|
+
"medium": "sm",
|
|
45
|
+
"large": "md",
|
|
46
|
+
// deprecated values
|
|
47
|
+
"compact": "xs",
|
|
48
|
+
"tall": "md",
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function Table({
|
|
52
|
+
className = "",
|
|
53
|
+
size = "medium",
|
|
54
|
+
hasDivider = true,
|
|
55
|
+
columnWidths,
|
|
56
|
+
colorless,
|
|
57
|
+
children,
|
|
58
|
+
...otherCarbonTableProps
|
|
59
|
+
}: TableProps) {
|
|
60
|
+
|
|
61
|
+
let colLayout : boolean | JSX.Element = false;
|
|
62
|
+
if (!!columnWidths && columnWidths.length > 0) {
|
|
63
|
+
colLayout = (
|
|
64
|
+
<colgroup className={`${eccgui}-simpletable__layout`}>
|
|
65
|
+
{columnWidths.map((width,i) => <col key={i} style={{ width }}/>)}
|
|
66
|
+
</colgroup>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<CarbonTable
|
|
72
|
+
className={
|
|
73
|
+
`${eccgui}-simpletable ${eccgui}-simpletable--${size}` +
|
|
74
|
+
(hasDivider ? ` ${eccgui}-simpletable--rowdivider` : "") +
|
|
75
|
+
(colLayout ? ` ${eccgui}-simpletable--haslayout` : "") +
|
|
76
|
+
(colorless ? ` ${eccgui}-simpletable--colorless` : "") +
|
|
77
|
+
(className ? ` ${className}` : "")
|
|
78
|
+
}
|
|
79
|
+
{...otherCarbonTableProps}
|
|
80
|
+
size={tableRowHeightSizes[size]}
|
|
81
|
+
>
|
|
82
|
+
{!!colLayout && colLayout}
|
|
83
|
+
{children}
|
|
84
|
+
</CarbonTable>
|
|
85
|
+
) ;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default Table;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
DataTable as CarbonDataTable,
|
|
4
|
+
DataTableProps as CarbonDataTableProps,
|
|
5
|
+
TableContainerProps as CarbonTableContainerProps
|
|
6
|
+
} from "carbon-components-react";
|
|
7
|
+
import { TableRowHeightSize, tableRowHeightSizes } from "./Table";
|
|
8
|
+
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
9
|
+
|
|
10
|
+
interface TableDataContainerProps extends Omit<
|
|
11
|
+
CarbonDataTableProps,
|
|
12
|
+
"size" | "overflowMenuOnHover" | "stickyHeader" | "useStaticWidth"
|
|
13
|
+
>, React.TableHTMLAttributes<HTMLTableElement> {
|
|
14
|
+
children(signature: any): JSX.Element;
|
|
15
|
+
size?: TableRowHeightSize;
|
|
16
|
+
}
|
|
17
|
+
interface TableSimpleContainerProps extends Omit<
|
|
18
|
+
CarbonTableContainerProps,
|
|
19
|
+
"description" | "stickyHeader" | "title" | "useStaticWidth"
|
|
20
|
+
>, React.HTMLAttributes<HTMLDivElement> {
|
|
21
|
+
children?: JSX.Element;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type TableContainerProps = TableDataContainerProps | TableSimpleContainerProps;
|
|
25
|
+
|
|
26
|
+
function TableContainer({
|
|
27
|
+
className = "",
|
|
28
|
+
...otherProps
|
|
29
|
+
}: TableContainerProps) {
|
|
30
|
+
|
|
31
|
+
const otherDataTableProps = otherProps as TableDataContainerProps;
|
|
32
|
+
|
|
33
|
+
return !!otherDataTableProps.headers || !!otherDataTableProps.rows ? (
|
|
34
|
+
<CarbonDataTable.TableContainer className={`${eccgui}-simpletable__container ` + className}>
|
|
35
|
+
<CarbonDataTable
|
|
36
|
+
{...otherDataTableProps}
|
|
37
|
+
size={
|
|
38
|
+
otherDataTableProps.size
|
|
39
|
+
? tableRowHeightSizes[otherDataTableProps.size]
|
|
40
|
+
: tableRowHeightSizes.medium
|
|
41
|
+
}
|
|
42
|
+
/>
|
|
43
|
+
</CarbonDataTable.TableContainer>
|
|
44
|
+
) : (
|
|
45
|
+
<CarbonDataTable.TableContainer {...otherProps} className={`${eccgui}-simpletable__container ` + className} />
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default TableContainer;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
TableExpandHeader as CarbonTableExpandHeader,
|
|
4
|
+
TableExpandHeaderProps as CarbonTableExpandHeaderProps,
|
|
5
|
+
} from "carbon-components-react";
|
|
6
|
+
import IconButton from "./../Icon/IconButton";
|
|
7
|
+
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
8
|
+
|
|
9
|
+
export interface TableExpandHeaderProps extends Omit<
|
|
10
|
+
CarbonTableExpandHeaderProps,
|
|
11
|
+
"children" | "ariaLabel" | "enableExpando" | "expandIconDescription"
|
|
12
|
+
>, React.ThHTMLAttributes<HTMLTableCellElement> {
|
|
13
|
+
/**
|
|
14
|
+
* This text is displayed as tooltip for the button that toggles the expanded/collapsed state.
|
|
15
|
+
*/
|
|
16
|
+
togglerText: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Adds a button to the table header that can trigger a function to expand/collapse all rows of the table.
|
|
21
|
+
*/
|
|
22
|
+
function TableExpandHeader ({
|
|
23
|
+
togglerText,
|
|
24
|
+
isExpanded,
|
|
25
|
+
onExpand,
|
|
26
|
+
className,
|
|
27
|
+
enableToggle,
|
|
28
|
+
...otherCarbonTableExpandHeaderProps
|
|
29
|
+
}: TableExpandHeaderProps) {
|
|
30
|
+
|
|
31
|
+
const toggleButton = isExpanded ?
|
|
32
|
+
React.cloneElement(<IconButton name="toggler-rowcollapse" text={togglerText} />, {onClick: onExpand}) :
|
|
33
|
+
React.cloneElement(<IconButton name="toggler-rowexpand" text={togglerText} />, {onClick: onExpand});
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<CarbonTableExpandHeader
|
|
37
|
+
className={
|
|
38
|
+
`${eccgui}-simpletable__headexpander` +
|
|
39
|
+
(!!className ? ` ${className}` : "")
|
|
40
|
+
}
|
|
41
|
+
isExpanded={isExpanded}
|
|
42
|
+
onExpand={onExpand}
|
|
43
|
+
enableToggle={false}
|
|
44
|
+
{...otherCarbonTableExpandHeaderProps}
|
|
45
|
+
>
|
|
46
|
+
{ enableToggle && toggleButton }
|
|
47
|
+
</CarbonTableExpandHeader>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default TableExpandHeader;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
TableExpandRowProps as CarbonTableExpandRowProps,
|
|
4
|
+
} from "carbon-components-react";
|
|
5
|
+
import {usePrefix as carbonPrefix} from "carbon-components-react/es/index"
|
|
6
|
+
import IconButton from "./../Icon/IconButton";
|
|
7
|
+
import { TableCell } from "./index";
|
|
8
|
+
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
9
|
+
|
|
10
|
+
export interface TableExpandRowProps extends Omit<
|
|
11
|
+
CarbonTableExpandRowProps,
|
|
12
|
+
"ariaLabel" | "expandIconDescription"
|
|
13
|
+
>, React.HTMLAttributes<HTMLTableRowElement> {
|
|
14
|
+
/**
|
|
15
|
+
* This text is displayed as tooltip for the button that toggles the expanded/collapsed state.
|
|
16
|
+
*/
|
|
17
|
+
togglerText: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Table row that is suffixed by a cell containing a button to expand/collapse this row.
|
|
22
|
+
*/
|
|
23
|
+
function TableExpandRow ({
|
|
24
|
+
togglerText,
|
|
25
|
+
isExpanded,
|
|
26
|
+
isSelected,
|
|
27
|
+
onExpand,
|
|
28
|
+
className,
|
|
29
|
+
children,
|
|
30
|
+
...otherCarbonTableExpandRowProps
|
|
31
|
+
}: TableExpandRowProps) {
|
|
32
|
+
|
|
33
|
+
const carbonClassPrefix = carbonPrefix();
|
|
34
|
+
|
|
35
|
+
const toggleButton = isExpanded ?
|
|
36
|
+
React.cloneElement(<IconButton name="toggler-showless" text={togglerText} />, {onClick: onExpand}) :
|
|
37
|
+
React.cloneElement(<IconButton name="toggler-showmore" text={togglerText} />, {onClick: onExpand});
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<tr
|
|
41
|
+
className={
|
|
42
|
+
`${eccgui}-simpletable__row` +
|
|
43
|
+
` ${carbonClassPrefix}--parent-row` +
|
|
44
|
+
(isExpanded ? ` ${carbonClassPrefix}--expandable-row` : "") +
|
|
45
|
+
(isSelected ? ` ${carbonClassPrefix}--data-table--selected` : "") +
|
|
46
|
+
(!!className ? ` ${className}` : "")
|
|
47
|
+
}
|
|
48
|
+
data-parent-row={true}
|
|
49
|
+
{...otherCarbonTableExpandRowProps}
|
|
50
|
+
>
|
|
51
|
+
<TableCell
|
|
52
|
+
className={
|
|
53
|
+
`${eccgui}-simpletable__rowexpander` +
|
|
54
|
+
` ${carbonClassPrefix}--table-expand`
|
|
55
|
+
}
|
|
56
|
+
>
|
|
57
|
+
{ toggleButton }
|
|
58
|
+
</TableCell>
|
|
59
|
+
{ children }
|
|
60
|
+
</tr>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default TableExpandRow;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TableHead as CarbonTableHead,
|
|
3
|
+
TableBody as CarbonTableBody,
|
|
4
|
+
TableRow as CarbonTableRow,
|
|
5
|
+
TableExpandedRow as CarbonTableExpandedRow,
|
|
6
|
+
TableHeader, // as CarbonTableHeader,
|
|
7
|
+
TableCell as CarbonTableCell,
|
|
8
|
+
} from "carbon-components-react";
|
|
9
|
+
|
|
10
|
+
import TableContainer, { TableContainerProps } from "./TableContainer";
|
|
11
|
+
import Table, { TableProps } from "./Table";
|
|
12
|
+
import TableExpandHeader, { TableExpandHeaderProps } from "./TableExpandHeader";
|
|
13
|
+
import TableExpandRow, { TableExpandRowProps } from "./TableExpandRow";
|
|
14
|
+
|
|
15
|
+
// TODO, we may simple wrap to add own classes
|
|
16
|
+
const TableHead = CarbonTableHead;
|
|
17
|
+
const TableBody = CarbonTableBody;
|
|
18
|
+
const TableRow = CarbonTableRow;
|
|
19
|
+
const TableExpandedRow = CarbonTableExpandedRow;
|
|
20
|
+
// const TableHeader = CarbonTableHeader;
|
|
21
|
+
const TableCell = CarbonTableCell;
|
|
22
|
+
|
|
23
|
+
export type {
|
|
24
|
+
TableContainerProps,
|
|
25
|
+
TableProps,
|
|
26
|
+
TableExpandHeaderProps,
|
|
27
|
+
TableExpandRowProps,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
TableContainer,
|
|
32
|
+
Table,
|
|
33
|
+
TableHead,
|
|
34
|
+
TableBody,
|
|
35
|
+
TableRow,
|
|
36
|
+
TableExpandRow,
|
|
37
|
+
TableExpandedRow,
|
|
38
|
+
TableHeader,
|
|
39
|
+
TableExpandHeader,
|
|
40
|
+
TableCell,
|
|
41
|
+
};
|