@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
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import React, {
|
|
18
18
|
ComponentPropsWithRef,
|
|
19
|
+
ForwardRefRenderFunction,
|
|
19
20
|
ReactElement,
|
|
20
21
|
ReactNode,
|
|
21
22
|
useEffect,
|
|
@@ -44,178 +45,178 @@ export interface Props extends ComponentPropsWithRef<"div"> {
|
|
|
44
45
|
onClose?: () => void;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const [childrenCount] = useState(React.Children.count(children));
|
|
48
|
+
const ContextMenuComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
49
|
+
{
|
|
50
|
+
trigger,
|
|
51
|
+
children,
|
|
52
|
+
decorativeElement,
|
|
53
|
+
id,
|
|
54
|
+
show = false,
|
|
55
|
+
onShow,
|
|
56
|
+
onClose,
|
|
57
|
+
placement = { horizontal: "right", vertical: "top" },
|
|
58
|
+
offset = { top: 0, bottom: 0, left: 0, right: 0 },
|
|
59
|
+
transformOrigin = { horizontal: "left", vertical: "top" },
|
|
60
|
+
domRoot = document.body,
|
|
61
|
+
...rest
|
|
62
|
+
}: Props,
|
|
63
|
+
ref
|
|
64
|
+
) => {
|
|
65
|
+
const anchorEl = useRef<HTMLButtonElement>(null);
|
|
66
|
+
const [showContextMenu, setShowContextMenu] = useState(show);
|
|
67
|
+
const [hasBeenClosed, setHasBeenClosed] = useState(false);
|
|
68
|
+
const [selectedContextMenuItem, setSelectedContextMenuItem] = useState(-1);
|
|
69
|
+
const [focusedContextMenuItem, setFocusedContextMenuItem] = useState(-1);
|
|
70
|
+
const [shouldClick, setShouldClick] =
|
|
71
|
+
useState(
|
|
72
|
+
false
|
|
73
|
+
); /** We need this, because whenever we use the arrow keys to select the contextmenu item, and we focus the currently selected item it fires the "click" listener in ContextMenuItem component. Instead, we only want this to fire if we press "enter" or "spacebar" so we set this to true whenever that is the case, and back to false when it has been executed. */
|
|
74
|
+
const [childrenCount] = useState(React.Children.count(children));
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const onArrowNavigation = (event: React.KeyboardEvent) => {
|
|
81
|
-
if (focusedContextMenuItem === -1 && selectedContextMenuItem !== -1) {
|
|
82
|
-
setFocusedContextMenuItem(selectedContextMenuItem);
|
|
83
|
-
}
|
|
76
|
+
if (!id) {
|
|
77
|
+
throw new Error("You need to provide an ID to the context menu");
|
|
78
|
+
}
|
|
84
79
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"ArrowRight",
|
|
90
|
-
"Enter",
|
|
91
|
-
"Space",
|
|
92
|
-
"Escape",
|
|
93
|
-
"End",
|
|
94
|
-
"Home"
|
|
95
|
-
];
|
|
80
|
+
const onArrowNavigation = (event: React.KeyboardEvent) => {
|
|
81
|
+
if (focusedContextMenuItem === -1 && selectedContextMenuItem !== -1) {
|
|
82
|
+
setFocusedContextMenuItem(selectedContextMenuItem);
|
|
83
|
+
}
|
|
96
84
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
85
|
+
const codesToPrevenDefault = [
|
|
86
|
+
"ArrowDown",
|
|
87
|
+
"ArrowUp",
|
|
88
|
+
"ArrowLeft",
|
|
89
|
+
"ArrowRight",
|
|
90
|
+
"Enter",
|
|
91
|
+
"Space",
|
|
92
|
+
"Escape",
|
|
93
|
+
"End",
|
|
94
|
+
"Home"
|
|
95
|
+
];
|
|
100
96
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
setShowContextMenu(true);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
setFocusedContextMenuItem(prevState => {
|
|
108
|
-
return prevState + 1 > childrenCount - 1 ? 0 : prevState + 1;
|
|
109
|
-
});
|
|
110
|
-
return;
|
|
111
|
-
case "ArrowUp":
|
|
112
|
-
setFocusedContextMenuItem(prevState => {
|
|
113
|
-
return prevState - 1 < 0 ? childrenCount - 1 : prevState - 1;
|
|
114
|
-
});
|
|
115
|
-
return;
|
|
116
|
-
case "Enter":
|
|
117
|
-
case "Space":
|
|
118
|
-
if (!showContextMenu) {
|
|
119
|
-
setShowContextMenu(true);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
97
|
+
if (codesToPrevenDefault.includes(event.code)) {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
}
|
|
122
100
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
case "Tab":
|
|
128
|
-
case "Escape":
|
|
129
|
-
setShowContextMenu(false);
|
|
101
|
+
switch (event.code) {
|
|
102
|
+
case "ArrowDown":
|
|
103
|
+
if (!showContextMenu) {
|
|
104
|
+
setShowContextMenu(true);
|
|
130
105
|
return;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return;
|
|
134
|
-
|
|
135
|
-
|
|
106
|
+
}
|
|
107
|
+
setFocusedContextMenuItem(prevState => {
|
|
108
|
+
return prevState + 1 > childrenCount - 1 ? 0 : prevState + 1;
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
case "ArrowUp":
|
|
112
|
+
setFocusedContextMenuItem(prevState => {
|
|
113
|
+
return prevState - 1 < 0 ? childrenCount - 1 : prevState - 1;
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
case "Enter":
|
|
117
|
+
case "Space":
|
|
118
|
+
if (!showContextMenu) {
|
|
119
|
+
setShowContextMenu(true);
|
|
136
120
|
return;
|
|
137
|
-
|
|
138
|
-
};
|
|
121
|
+
}
|
|
139
122
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
);
|
|
147
|
-
},
|
|
148
|
-
() => {
|
|
123
|
+
setShouldClick(true);
|
|
124
|
+
setSelectedContextMenuItem(focusedContextMenuItem);
|
|
125
|
+
setShowContextMenu(false);
|
|
126
|
+
return;
|
|
127
|
+
case "Tab":
|
|
128
|
+
case "Escape":
|
|
149
129
|
setShowContextMenu(false);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
130
|
+
return;
|
|
131
|
+
case "End":
|
|
132
|
+
setFocusedContextMenuItem(childrenCount - 1);
|
|
133
|
+
return;
|
|
134
|
+
case "Home":
|
|
135
|
+
setFocusedContextMenuItem(0);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
153
139
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
140
|
+
useBodyClick(
|
|
141
|
+
event => {
|
|
142
|
+
return (
|
|
143
|
+
showContextMenu &&
|
|
144
|
+
anchorEl.current !== event.target &&
|
|
145
|
+
anchorEl.current !== (event.target as HTMLElement).parentElement
|
|
146
|
+
);
|
|
147
|
+
},
|
|
148
|
+
() => {
|
|
149
|
+
setShowContextMenu(false);
|
|
150
|
+
},
|
|
151
|
+
showContextMenu
|
|
152
|
+
);
|
|
164
153
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (showContextMenu === true) {
|
|
156
|
+
onShow && onShow();
|
|
157
|
+
} else {
|
|
158
|
+
onClose && onClose();
|
|
159
|
+
!hasBeenClosed && setHasBeenClosed(true);
|
|
160
|
+
setFocusedContextMenuItem(-1);
|
|
161
|
+
hasBeenClosed && anchorEl.current && anchorEl.current.focus();
|
|
162
|
+
}
|
|
163
|
+
}, [showContextMenu]);
|
|
175
164
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
165
|
+
const renderTrigger = () =>
|
|
166
|
+
React.cloneElement(trigger, {
|
|
167
|
+
id: id,
|
|
168
|
+
"aria-haspopup": "true",
|
|
169
|
+
"aria-controls": `${id}-menu`,
|
|
170
|
+
"aria-expanded": showContextMenu,
|
|
171
|
+
onClick: () => setShowContextMenu(!showContextMenu),
|
|
172
|
+
tabIndex: 0,
|
|
173
|
+
ref: anchorEl
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const renderChildren = () => {
|
|
177
|
+
return React.Children.map(children, (child, index) => {
|
|
178
|
+
return React.cloneElement(child as ReactElement, {
|
|
179
|
+
onFocusChange: (childIndex: number) => setFocusedContextMenuItem(childIndex),
|
|
180
|
+
onSelectedChange: (childIndex: number) => {
|
|
181
|
+
setSelectedContextMenuItem(childIndex);
|
|
182
|
+
setShouldClick(false);
|
|
183
|
+
},
|
|
184
|
+
childIndex: index,
|
|
185
|
+
hasFocus: focusedContextMenuItem === index,
|
|
186
|
+
isSelected: selectedContextMenuItem === index,
|
|
187
|
+
contextMenuOpened: showContextMenu,
|
|
188
|
+
shouldClick: shouldClick
|
|
190
189
|
});
|
|
191
|
-
};
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
193
|
+
return (
|
|
194
|
+
<div {...rest} ref={ref} onKeyDown={onArrowNavigation} className={classes["context-menu"]}>
|
|
195
|
+
{renderTrigger()}
|
|
196
|
+
{createPortal(
|
|
197
|
+
<Popover
|
|
198
|
+
placement={placement}
|
|
199
|
+
transformOrigin={transformOrigin}
|
|
200
|
+
offset={offset}
|
|
201
|
+
anchorEl={anchorEl}
|
|
202
|
+
show={showContextMenu}
|
|
203
|
+
>
|
|
204
|
+
{decorativeElement && (
|
|
205
|
+
<div className={classes["decorative-element"]}>{decorativeElement}</div>
|
|
206
|
+
)}
|
|
207
|
+
<ul
|
|
208
|
+
className={`${classes["menu"]} ${decorativeElement ? classes["no-margin-top"] : ""}`}
|
|
209
|
+
id={`${id}-menu`}
|
|
210
|
+
aria-describedby={id}
|
|
211
|
+
role="menu"
|
|
203
212
|
>
|
|
204
|
-
{
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
</ul>
|
|
215
|
-
</Popover>,
|
|
216
|
-
domRoot
|
|
217
|
-
)}
|
|
218
|
-
</div>
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
);
|
|
213
|
+
{renderChildren()}
|
|
214
|
+
</ul>
|
|
215
|
+
</Popover>,
|
|
216
|
+
domRoot
|
|
217
|
+
)}
|
|
218
|
+
</div>
|
|
219
|
+
);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export const ContextMenu = React.forwardRef(ContextMenuComponent);
|
|
@@ -14,7 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, {
|
|
17
|
+
import React, {
|
|
18
|
+
ComponentPropsWithRef,
|
|
19
|
+
createRef,
|
|
20
|
+
ForwardRefRenderFunction,
|
|
21
|
+
RefObject,
|
|
22
|
+
useEffect
|
|
23
|
+
} from "react";
|
|
18
24
|
import classes from "./ContextMenuItem.module.scss";
|
|
19
25
|
|
|
20
26
|
export interface Props extends Omit<ComponentPropsWithRef<"button">, "onClick"> {
|
|
@@ -29,54 +35,54 @@ export interface Props extends Omit<ComponentPropsWithRef<"button">, "onClick">
|
|
|
29
35
|
onSelectedChange?: (childIndex: number) => void;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)
|
|
49
|
-
let innerButtonRef = (ref as RefObject<HTMLButtonElement>) || createRef<HTMLButtonElement>();
|
|
38
|
+
const ContextMenuItemComponent: ForwardRefRenderFunction<HTMLButtonElement, Props> = (
|
|
39
|
+
{
|
|
40
|
+
children,
|
|
41
|
+
onClick,
|
|
42
|
+
onFocusChange,
|
|
43
|
+
onSelectedChange,
|
|
44
|
+
hasFocus,
|
|
45
|
+
isSelected,
|
|
46
|
+
childIndex,
|
|
47
|
+
contextMenuOpened,
|
|
48
|
+
shouldClick,
|
|
49
|
+
className,
|
|
50
|
+
...rest
|
|
51
|
+
}: Props,
|
|
52
|
+
ref
|
|
53
|
+
) => {
|
|
54
|
+
let innerButtonRef = (ref as RefObject<HTMLButtonElement>) || createRef<HTMLButtonElement>();
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (isSelected && innerButtonRef.current && shouldClick) {
|
|
58
|
+
innerButtonRef.current.click();
|
|
59
|
+
}
|
|
60
|
+
}, [isSelected, shouldClick]);
|
|
56
61
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (innerButtonRef.current && hasFocus && contextMenuOpened) {
|
|
64
|
+
onFocusChange && childIndex && onFocusChange(childIndex);
|
|
65
|
+
innerButtonRef.current.focus();
|
|
66
|
+
}
|
|
67
|
+
}, [hasFocus, innerButtonRef, contextMenuOpened]);
|
|
63
68
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
return (
|
|
70
|
+
<li role="none" className={`${classes["context-menu-item"]} ${className ?? ""}`}>
|
|
71
|
+
<button
|
|
72
|
+
role="menuitem"
|
|
73
|
+
{...rest}
|
|
74
|
+
ref={innerButtonRef}
|
|
75
|
+
data-focus={hasFocus}
|
|
76
|
+
tabIndex={-1}
|
|
77
|
+
onClick={event => {
|
|
78
|
+
onClick && onClick(event);
|
|
79
|
+
onSelectedChange && childIndex && onSelectedChange(childIndex);
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
{children}
|
|
83
|
+
</button>
|
|
84
|
+
</li>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const ContextMenuItem = React.forwardRef(ContextMenuItemComponent);
|
|
@@ -37,6 +37,7 @@ export interface Props<T> extends Omit<ComponentPropsWithRef<"div">, "children">
|
|
|
37
37
|
addBtnProps?: ButtonProps;
|
|
38
38
|
columnsBtnProps?: ButtonProps;
|
|
39
39
|
searchBtnProps?: ButtonProps;
|
|
40
|
+
searchIconBtnProps?: ButtonProps;
|
|
40
41
|
};
|
|
41
42
|
emptyLabel?: string;
|
|
42
43
|
paginationProps?: PaginationProps;
|
|
@@ -105,6 +105,7 @@ describe("DataGridActions should render", () => {
|
|
|
105
105
|
const addBtnProps = { children: "button1", title: "title1" };
|
|
106
106
|
const columnsBtnProps = { children: "button2", title: "title2" };
|
|
107
107
|
const searchBtnProps = { children: "button3", title: "title3" };
|
|
108
|
+
const searchIconBtnProps = { title: "title4" };
|
|
108
109
|
const { dataGridActions, getAllByRole } = createDataGridActions(params => ({
|
|
109
110
|
...params,
|
|
110
111
|
enableAddBtn: true,
|
|
@@ -112,7 +113,8 @@ describe("DataGridActions should render", () => {
|
|
|
112
113
|
enableSearchBtn: true,
|
|
113
114
|
addBtnProps,
|
|
114
115
|
columnsBtnProps,
|
|
115
|
-
searchBtnProps
|
|
116
|
+
searchBtnProps,
|
|
117
|
+
searchIconBtnProps
|
|
116
118
|
}));
|
|
117
119
|
|
|
118
120
|
expect(dataGridActions).toBeDefined();
|
|
@@ -125,7 +127,7 @@ describe("DataGridActions should render", () => {
|
|
|
125
127
|
expect(mobileColumnsBtn).toHaveTextContent(columnsBtnProps.title);
|
|
126
128
|
expect(desktopSearchBtn).toHaveTextContent(searchBtnProps.children);
|
|
127
129
|
expect(desktopSearchBtn).toHaveAttribute("title", searchBtnProps.title);
|
|
128
|
-
expect(mobileSearchBtn).toHaveTextContent(
|
|
130
|
+
expect(mobileSearchBtn).toHaveTextContent(searchIconBtnProps.title);
|
|
129
131
|
});
|
|
130
132
|
});
|
|
131
133
|
|