@onewelcome/react-lib-components 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Button/IconButton.d.ts +2 -1
- package/dist/DataGrid/DataGrid.d.ts +1 -0
- package/dist/DataGrid/DataGridActions/DataGridActions.d.ts +2 -1
- package/dist/Form/Form.d.ts +3 -3
- package/dist/Notifications/SlideInModal/SlideInModal.d.ts +1 -1
- package/dist/Tabs/Tab.d.ts +5 -9
- package/dist/Tabs/TabButton.d.ts +3 -6
- package/dist/Tabs/Tabs.d.ts +1 -2
- package/dist/hooks/useDebouncedCallback.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/react-lib-components.cjs.development.js +472 -395
- package/dist/react-lib-components.cjs.development.js.map +1 -1
- package/dist/react-lib-components.cjs.production.min.js +1 -1
- package/dist/react-lib-components.cjs.production.min.js.map +1 -1
- package/dist/react-lib-components.esm.js +473 -397
- package/dist/react-lib-components.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/Breadcrumbs/Breadcrumbs.tsx +46 -38
- package/src/Button/BaseButton.tsx +23 -20
- package/src/Button/Button.module.scss +9 -0
- package/src/Button/Button.tsx +40 -40
- package/src/Button/IconButton.tsx +28 -28
- package/src/ContextMenu/ContextMenu.tsx +161 -160
- package/src/ContextMenu/ContextMenuItem.tsx +55 -49
- package/src/DataGrid/DataGrid.tsx +1 -0
- package/src/DataGrid/DataGridActions/DataGridActions.module.scss +1 -1
- package/src/DataGrid/DataGridActions/DataGridActions.test.tsx +4 -2
- package/src/DataGrid/DataGridActions/DataGridActions.tsx +95 -87
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.tsx +64 -64
- package/src/DataGrid/DataGridBody/DataGridCell.tsx +42 -44
- package/src/DataGrid/DataGridBody/DataGridRow.tsx +29 -29
- package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +78 -78
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.tsx +48 -48
- package/src/Form/Checkbox/Checkbox.tsx +134 -130
- package/src/Form/Fieldset/Fieldset.tsx +81 -78
- package/src/Form/Form.tsx +9 -4
- package/src/Form/FormControl/FormControl.module.scss +1 -20
- package/src/Form/FormControl/FormControl.tsx +36 -35
- package/src/Form/FormGroup/FormGroup.tsx +62 -62
- package/src/Form/FormHelperText/FormHelperText.tsx +19 -18
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +58 -53
- package/src/Form/Input/Input.tsx +90 -87
- package/src/Form/Label/Label.tsx +17 -16
- package/src/Form/Radio/Radio.tsx +91 -91
- package/src/Form/Select/Option.tsx +66 -60
- package/src/Form/Select/Select.tsx +207 -209
- package/src/Form/Textarea/Textarea.tsx +51 -53
- package/src/Form/Toggle/Toggle.tsx +26 -23
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.tsx +51 -43
- package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +112 -106
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.tsx +67 -62
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +42 -37
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +94 -94
- package/src/Form/Wrapper/Wrapper/Wrapper.tsx +73 -73
- package/src/Icon/Icon.module.scss +1 -0
- package/src/Icon/Icon.tsx +19 -16
- package/src/Link/Link.tsx +68 -63
- package/src/Notifications/BaseModal/BaseModal.tsx +68 -68
- package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.tsx +13 -10
- package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.tsx +33 -25
- package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +20 -17
- package/src/Notifications/Dialog/Dialog.tsx +83 -83
- package/src/Notifications/Dialog/DialogActions/DialogActions.tsx +17 -14
- package/src/Notifications/Dialog/DialogTitle/DialogTitle.tsx +15 -12
- package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.tsx +40 -40
- package/src/Notifications/SlideInModal/SlideInModal.module.scss +5 -5
- package/src/Notifications/SlideInModal/SlideInModal.test.tsx +7 -2
- package/src/Notifications/SlideInModal/SlideInModal.tsx +47 -27
- package/src/Pagination/Pagination.tsx +169 -169
- package/src/Popover/Popover.module.scss +1 -0
- package/src/Popover/Popover.tsx +43 -33
- package/src/ProgressBar/ProgressBar.tsx +17 -14
- package/src/Skeleton/Skeleton.tsx +23 -20
- package/src/StatusIndicator/StatusIndicator.tsx +18 -15
- package/src/Tabs/{TabPanel.module.scss → Tab.module.scss} +1 -1
- package/src/Tabs/Tab.test.tsx +1 -39
- package/src/Tabs/Tab.tsx +16 -10
- package/src/Tabs/TabButton.module.scss +0 -4
- package/src/Tabs/TabButton.test.tsx +3 -31
- package/src/Tabs/TabButton.tsx +35 -49
- package/src/Tabs/Tabs.test.tsx +40 -33
- package/src/Tabs/Tabs.tsx +107 -101
- package/src/TextEllipsis/TextEllipsis.tsx +50 -41
- package/src/Tiles/Tile.tsx +58 -56
- package/src/Tiles/Tiles.tsx +44 -41
- package/src/Tooltip/Tooltip.tsx +101 -100
- package/src/Typography/Typography.tsx +47 -44
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.tsx +55 -52
- package/src/Wizard/WizardSteps/WizardSteps.tsx +25 -22
- package/src/hooks/useDebouncedCallback.test.ts +140 -0
- package/src/hooks/useDebouncedCallback.tsx +32 -0
- package/src/index.ts +1 -0
- package/src/mixins.module.scss +2 -2
- package/src/util/helper.test.tsx +0 -28
- package/dist/Tabs/TabPanel.d.ts +0 -8
- package/src/Tabs/TabPanel.test.tsx +0 -92
- package/src/Tabs/TabPanel.tsx +0 -43
|
@@ -14,7 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, {
|
|
17
|
+
import React, {
|
|
18
|
+
ComponentPropsWithRef,
|
|
19
|
+
ForwardRefRenderFunction,
|
|
20
|
+
Fragment,
|
|
21
|
+
useRef,
|
|
22
|
+
useState
|
|
23
|
+
} from "react";
|
|
18
24
|
import { Button, Props as ButtonProps } from "../../Button/Button";
|
|
19
25
|
import { IconButton } from "../../Button/IconButton";
|
|
20
26
|
import { Icon, Icons } from "../../Icon/Icon";
|
|
@@ -29,97 +35,99 @@ export interface Props extends ComponentPropsWithRef<"div"> {
|
|
|
29
35
|
addBtnProps?: ButtonProps;
|
|
30
36
|
columnsBtnProps?: ButtonProps;
|
|
31
37
|
searchBtnProps?: ButtonProps;
|
|
38
|
+
searchIconBtnProps?: ButtonProps;
|
|
32
39
|
headers: HeaderCell[];
|
|
33
40
|
onColumnToggled: (colName: ColumnName) => void;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
const DataGridActionsComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
44
|
+
{
|
|
45
|
+
className,
|
|
46
|
+
enableAddBtn,
|
|
47
|
+
enableColumnsBtn,
|
|
48
|
+
enableSearchBtn,
|
|
49
|
+
addBtnProps = {},
|
|
50
|
+
columnsBtnProps = {},
|
|
51
|
+
searchBtnProps = {},
|
|
52
|
+
searchIconBtnProps = {},
|
|
53
|
+
headers,
|
|
54
|
+
onColumnToggled,
|
|
55
|
+
...rest
|
|
56
|
+
}: Props,
|
|
57
|
+
ref
|
|
58
|
+
) => {
|
|
59
|
+
const isHidden = !(enableAddBtn || enableColumnsBtn || enableSearchBtn);
|
|
60
|
+
const [showColsPopover, setShowColsPopover] = useState(false);
|
|
61
|
+
const showColumnBtn = useRef<HTMLButtonElement>(null);
|
|
55
62
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
return isHidden ? null : (
|
|
64
|
+
<div {...rest} ref={ref} className={`${classes["actions"]} ${className ?? ""}`}>
|
|
65
|
+
<div className={classes["left-actions"]}>
|
|
66
|
+
{enableAddBtn && (
|
|
67
|
+
<Button
|
|
68
|
+
color="primary"
|
|
69
|
+
startIcon={<Icon icon={Icons.Plus} />}
|
|
70
|
+
title="Add item"
|
|
71
|
+
type="button"
|
|
72
|
+
variant="outline"
|
|
73
|
+
children="Add item"
|
|
74
|
+
{...addBtnProps}
|
|
75
|
+
/>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
<div className={classes["right-actions"]}>
|
|
79
|
+
{enableColumnsBtn && (
|
|
80
|
+
<Fragment>
|
|
60
81
|
<Button
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{
|
|
82
|
+
startIcon={<Icon icon={Icons.Change} />}
|
|
83
|
+
title="Show/hide columns"
|
|
84
|
+
variant="text"
|
|
85
|
+
children="Columns"
|
|
86
|
+
{...columnsBtnProps}
|
|
87
|
+
className={`${classes["desktop"]} ${columnsBtnProps?.className ?? ""}`}
|
|
88
|
+
ref={showColumnBtn}
|
|
89
|
+
onClick={() => setShowColsPopover(true)}
|
|
90
|
+
/>
|
|
91
|
+
<IconButton
|
|
92
|
+
title="Show/hide columns"
|
|
93
|
+
{...columnsBtnProps}
|
|
94
|
+
onClick={() => setShowColsPopover(true)}
|
|
95
|
+
className={`${classes["mobile"]} ${columnsBtnProps?.className ?? ""}`}
|
|
96
|
+
>
|
|
97
|
+
<Icon icon={Icons.Change} />
|
|
98
|
+
</IconButton>
|
|
99
|
+
<DataGridColumnsToggle
|
|
100
|
+
aria-hidden={!showColsPopover}
|
|
101
|
+
open={showColsPopover}
|
|
102
|
+
headers={headers}
|
|
103
|
+
onClose={() => setShowColsPopover(false)}
|
|
104
|
+
onToggleClicked={onColumnToggled}
|
|
105
|
+
anchorEl={showColumnBtn}
|
|
68
106
|
/>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<Icon icon={Icons.Change} />
|
|
91
|
-
</IconButton>
|
|
92
|
-
<DataGridColumnsToggle
|
|
93
|
-
aria-hidden={!showColsPopover}
|
|
94
|
-
open={showColsPopover}
|
|
95
|
-
headers={headers}
|
|
96
|
-
onClose={() => setShowColsPopover(false)}
|
|
97
|
-
onToggleClicked={onColumnToggled}
|
|
98
|
-
anchorEl={showColumnBtn}
|
|
99
|
-
/>
|
|
100
|
-
</Fragment>
|
|
101
|
-
)}
|
|
102
|
-
{enableSearchBtn && (
|
|
103
|
-
<Fragment>
|
|
104
|
-
<Button
|
|
105
|
-
startIcon={<Icon icon={Icons.TableSearch} />}
|
|
106
|
-
title="Search"
|
|
107
|
-
variant="text"
|
|
108
|
-
children="Search"
|
|
109
|
-
{...searchBtnProps}
|
|
110
|
-
className={`${classes["desktop"]} ${searchBtnProps?.className ?? ""}`}
|
|
111
|
-
/>
|
|
112
|
-
<IconButton
|
|
113
|
-
title="Search"
|
|
114
|
-
{...searchBtnProps}
|
|
115
|
-
className={`${classes["mobile"]} ${columnsBtnProps?.className ?? ""}`}
|
|
116
|
-
>
|
|
117
|
-
<Icon icon={Icons.TableSearch} />
|
|
118
|
-
</IconButton>
|
|
119
|
-
</Fragment>
|
|
120
|
-
)}
|
|
121
|
-
</div>
|
|
107
|
+
</Fragment>
|
|
108
|
+
)}
|
|
109
|
+
{enableSearchBtn && (
|
|
110
|
+
<Fragment>
|
|
111
|
+
<Button
|
|
112
|
+
startIcon={<Icon icon={Icons.TableSearch} />}
|
|
113
|
+
title="Search"
|
|
114
|
+
variant="text"
|
|
115
|
+
children="Search"
|
|
116
|
+
{...searchBtnProps}
|
|
117
|
+
className={`${classes["desktop"]} ${searchBtnProps?.className ?? ""}`}
|
|
118
|
+
/>
|
|
119
|
+
<IconButton
|
|
120
|
+
title="Search"
|
|
121
|
+
{...searchIconBtnProps}
|
|
122
|
+
className={`${classes["mobile"]} ${columnsBtnProps?.className ?? ""}`}
|
|
123
|
+
>
|
|
124
|
+
<Icon icon={Icons.TableSearch} />
|
|
125
|
+
</IconButton>
|
|
126
|
+
</Fragment>
|
|
127
|
+
)}
|
|
122
128
|
</div>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const DataGridActions = React.forwardRef(DataGridActionsComponent);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { Fragment, useState } from "react";
|
|
17
|
+
import React, { ForwardRefRenderFunction, Fragment, useState } from "react";
|
|
18
18
|
import { IconButton } from "../../Button/IconButton";
|
|
19
19
|
import { Toggle } from "../../Form/Toggle/Toggle";
|
|
20
20
|
import { Icon, Icons } from "../../Icon/Icon";
|
|
@@ -35,70 +35,70 @@ export interface Props extends PopoverProps {
|
|
|
35
35
|
domRoot?: HTMLElement;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const labelledId = id + "_header";
|
|
38
|
+
const DataGridColumnsToggleComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
39
|
+
{
|
|
40
|
+
open,
|
|
41
|
+
headers,
|
|
42
|
+
titleLabel = "Show columns",
|
|
43
|
+
closeButtonTitle = "Close show columns dialog",
|
|
44
|
+
onClose,
|
|
45
|
+
onToggleClicked,
|
|
46
|
+
className,
|
|
47
|
+
domRoot = document.body,
|
|
48
|
+
...rest
|
|
49
|
+
}: Props,
|
|
50
|
+
ref
|
|
51
|
+
) => {
|
|
52
|
+
const [id] = useState(generateID());
|
|
53
|
+
const labelledId = id + "_header";
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
const toggles = headers.map(item => (
|
|
56
|
+
<Toggle
|
|
57
|
+
key={item.name}
|
|
58
|
+
name={item.name}
|
|
59
|
+
checked={!item.hidden}
|
|
60
|
+
onChange={() => onToggleClicked(item.name)}
|
|
61
|
+
>
|
|
62
|
+
{item.headline}
|
|
63
|
+
</Toggle>
|
|
64
|
+
));
|
|
66
65
|
|
|
67
|
-
|
|
66
|
+
const handleBackdropClick = () => onClose();
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)}
|
|
84
|
-
{open && (
|
|
85
|
-
<Fragment>
|
|
86
|
-
<div className={classes["header"]}>
|
|
87
|
-
<Typography id={labelledId} className={classes["title"]} tag="span" variant="h4">
|
|
88
|
-
{titleLabel}
|
|
89
|
-
</Typography>
|
|
90
|
-
<IconButton
|
|
91
|
-
onClick={onClose}
|
|
92
|
-
className={`${classes["close-btn"]}`}
|
|
93
|
-
title={closeButtonTitle}
|
|
94
|
-
>
|
|
95
|
-
<Icon icon={Icons.Times} />
|
|
96
|
-
</IconButton>
|
|
97
|
-
</div>
|
|
98
|
-
<div className={classes["content"]}>{toggles}</div>
|
|
99
|
-
</Fragment>
|
|
68
|
+
return (
|
|
69
|
+
<Popover
|
|
70
|
+
{...rest}
|
|
71
|
+
ref={ref}
|
|
72
|
+
className={`${classes["popover"]} ${className}`}
|
|
73
|
+
show={open}
|
|
74
|
+
role="dialog"
|
|
75
|
+
aria-modal="true"
|
|
76
|
+
aria-labelledby={labelledId}
|
|
77
|
+
>
|
|
78
|
+
{open &&
|
|
79
|
+
createPortal(
|
|
80
|
+
<div className={classes["backdrop"]} onClick={handleBackdropClick}></div>,
|
|
81
|
+
domRoot
|
|
100
82
|
)}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
83
|
+
{open && (
|
|
84
|
+
<Fragment>
|
|
85
|
+
<div className={classes["header"]}>
|
|
86
|
+
<Typography id={labelledId} className={classes["title"]} tag="span" variant="h4">
|
|
87
|
+
{titleLabel}
|
|
88
|
+
</Typography>
|
|
89
|
+
<IconButton
|
|
90
|
+
onClick={onClose}
|
|
91
|
+
className={`${classes["close-btn"]}`}
|
|
92
|
+
title={closeButtonTitle}
|
|
93
|
+
>
|
|
94
|
+
<Icon icon={Icons.Times} />
|
|
95
|
+
</IconButton>
|
|
96
|
+
</div>
|
|
97
|
+
<div className={classes["content"]}>{toggles}</div>
|
|
98
|
+
</Fragment>
|
|
99
|
+
)}
|
|
100
|
+
</Popover>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const DataGridColumnsToggle = React.forwardRef(DataGridColumnsToggleComponent);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { ComponentPropsWithRef, ReactChild } from "react";
|
|
17
|
+
import React, { ForwardRefRenderFunction, ComponentPropsWithRef, ReactChild } from "react";
|
|
18
18
|
import { Typography } from "../../Typography/Typography";
|
|
19
19
|
import classes from "./DataGridCell.module.scss";
|
|
20
20
|
|
|
@@ -27,48 +27,46 @@ export interface Props extends ComponentPropsWithRef<"td"> {
|
|
|
27
27
|
disableContextMenuColumn?: boolean;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
let cellStyle: React.CSSProperties = {};
|
|
30
|
+
const DataGridCellComponent: ForwardRefRenderFunction<HTMLTableCellElement, Props> = (
|
|
31
|
+
{
|
|
32
|
+
children,
|
|
33
|
+
className,
|
|
34
|
+
isLoading,
|
|
35
|
+
spacing,
|
|
36
|
+
cellIndex,
|
|
37
|
+
columnLength,
|
|
38
|
+
disableContextMenuColumn,
|
|
39
|
+
...rest
|
|
40
|
+
}: Props,
|
|
41
|
+
ref
|
|
42
|
+
) => {
|
|
43
|
+
let cellStyle: React.CSSProperties = {};
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<td
|
|
58
|
-
{...rest}
|
|
59
|
-
ref={ref}
|
|
60
|
-
style={{ ...rest.style, ...cellStyle }}
|
|
61
|
-
className={`${classes["cell"]} ${className ?? ""}`}
|
|
62
|
-
>
|
|
63
|
-
{isLoading && (
|
|
64
|
-
<div className={classes["loading"]} aria-busy="true" aria-live="polite"></div>
|
|
65
|
-
)}
|
|
66
|
-
{!isLoading && (
|
|
67
|
-
<Typography variant="body" tag="span">
|
|
68
|
-
{children}
|
|
69
|
-
</Typography>
|
|
70
|
-
)}
|
|
71
|
-
</td>
|
|
72
|
-
);
|
|
45
|
+
if (cellIndex === 0) {
|
|
46
|
+
cellStyle.paddingLeft = spacing?.paddingLeft;
|
|
47
|
+
}
|
|
48
|
+
if (
|
|
49
|
+
(cellIndex === columnLength && !disableContextMenuColumn) ||
|
|
50
|
+
(columnLength && cellIndex === columnLength - 1 && disableContextMenuColumn)
|
|
51
|
+
) {
|
|
52
|
+
cellStyle.paddingRight = spacing?.paddingRight;
|
|
73
53
|
}
|
|
74
|
-
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<td
|
|
57
|
+
{...rest}
|
|
58
|
+
ref={ref}
|
|
59
|
+
style={{ ...rest.style, ...cellStyle }}
|
|
60
|
+
className={`${classes["cell"]} ${className ?? ""}`}
|
|
61
|
+
>
|
|
62
|
+
{isLoading && <div className={classes["loading"]} aria-busy="true" aria-live="polite"></div>}
|
|
63
|
+
{!isLoading && (
|
|
64
|
+
<Typography variant="body" tag="span">
|
|
65
|
+
{children}
|
|
66
|
+
</Typography>
|
|
67
|
+
)}
|
|
68
|
+
</td>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const DataGridCell = React.forwardRef(DataGridCellComponent);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { ComponentPropsWithRef } from "react";
|
|
17
|
+
import React, { ForwardRefRenderFunction, ComponentPropsWithRef } from "react";
|
|
18
18
|
import { HeaderCell } from "../datagrid.interfaces";
|
|
19
19
|
import classes from "./DataGridRow.module.scss";
|
|
20
20
|
|
|
@@ -25,34 +25,34 @@ export interface Props extends ComponentPropsWithRef<"tr"> {
|
|
|
25
25
|
disableContextMenuColumn?: boolean;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
28
|
+
const DataGridRowComponent: ForwardRefRenderFunction<HTMLTableRowElement, Props> = (
|
|
29
|
+
{ children, className, headers, isLoading, spacing, disableContextMenuColumn, ...rest }: Props,
|
|
30
|
+
ref
|
|
31
|
+
) => {
|
|
32
|
+
const visibleCells = React.Children.map(children as React.ReactElement[], (child, index) => {
|
|
33
|
+
if (child) {
|
|
34
|
+
const cellWithSpacing = React.cloneElement(child, {
|
|
35
|
+
spacing: spacing,
|
|
36
|
+
cellIndex: index,
|
|
37
|
+
columnLength: headers?.length,
|
|
38
|
+
disableContextMenuColumn
|
|
39
|
+
});
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
const visible = headers && headers.length > index ? !headers[index].hidden : true;
|
|
42
|
+
return visible && cellWithSpacing;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
});
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
const classNames = [classes["row"]];
|
|
48
|
+
className && classNames.push(className);
|
|
49
|
+
isLoading && classNames.push(classes["loading"]);
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
return (
|
|
52
|
+
<tr {...rest} ref={ref} className={classNames.join(" ")}>
|
|
53
|
+
{visibleCells}
|
|
54
|
+
</tr>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const DataGridRow = React.forwardRef(DataGridRowComponent);
|