@vertigis/react-ui 14.3.1 → 14.3.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/InlineHelp/InlineHelp.js
CHANGED
|
@@ -13,6 +13,7 @@ const PREFIX = "GcxInlineHelp";
|
|
|
13
13
|
export const inlineHelpClasses = {
|
|
14
14
|
root: `${PREFIX}-root`,
|
|
15
15
|
paper: `${PREFIX}-paper`,
|
|
16
|
+
button: `${PREFIX}-button`,
|
|
16
17
|
errorIcon: `${PREFIX}-errorIcon`,
|
|
17
18
|
};
|
|
18
19
|
const LTR_ORIGIN = {
|
|
@@ -25,9 +26,9 @@ const RTL_ORIGIN = {
|
|
|
25
26
|
};
|
|
26
27
|
// Popover styling needs to be applied separately here, since the popover will
|
|
27
28
|
// not be a child of the Root in the DOM due to use of a React portal.
|
|
28
|
-
const StyledPopover = styled(Popover)(({ theme: { spacing } }) => ({
|
|
29
|
+
const StyledPopover = styled(Popover)(({ theme: { spacing, typography: { pxToRem }, }, }) => ({
|
|
29
30
|
[`& .${inlineHelpClasses.paper}`]: {
|
|
30
|
-
maxWidth:
|
|
31
|
+
maxWidth: pxToRem(350),
|
|
31
32
|
padding: spacing(2),
|
|
32
33
|
wordWrap: "break-word",
|
|
33
34
|
},
|
|
@@ -39,9 +40,9 @@ const InlineHelp = forwardRef(({ children, classes: classesProp, className, icon
|
|
|
39
40
|
const formControl = useFormControl();
|
|
40
41
|
const handleIconPopoverOpen = (event) => setIconBtnEl(event.currentTarget);
|
|
41
42
|
const handleIconPopoverClose = () => setIconBtnEl(undefined);
|
|
42
|
-
return (_jsxs(Box, { className: clsx(classes.root, className), ref: ref, ...other, children: [_jsx(IconButton, { onClick: handleIconPopoverOpen, title: title, size: "small", "data-test": `${PREFIX}-button`, className: clsx({
|
|
43
|
+
return (_jsxs(Box, { className: clsx(classes.root, className), ref: ref, ...other, children: [_jsx(IconButton, { onClick: handleIconPopoverOpen, title: title, size: "small", "data-test": `${PREFIX}-button`, className: clsx(classes.button, {
|
|
43
44
|
[classes.errorIcon]: formControl?.error,
|
|
44
|
-
}), children: icon ? icon : _jsx(HelpIcon, {}) }), _jsxs(StyledPopover, { anchorEl: iconBtnEl, open: !!iconBtnEl, classes: { paper: classes.paper }, anchorOrigin: theme.direction === "rtl" ? RTL_ORIGIN : LTR_ORIGIN, transformOrigin: theme.direction === "rtl" ? RTL_ORIGIN : LTR_ORIGIN, onClose: () => {
|
|
45
|
+
}), children: icon ? icon : _jsx(HelpIcon, { fontSize: "small" }) }), _jsxs(StyledPopover, { anchorEl: iconBtnEl, open: !!iconBtnEl, classes: { paper: classes.paper }, anchorOrigin: theme.direction === "rtl" ? RTL_ORIGIN : LTR_ORIGIN, transformOrigin: theme.direction === "rtl" ? RTL_ORIGIN : LTR_ORIGIN, onClose: () => {
|
|
45
46
|
handleIconPopoverClose();
|
|
46
47
|
onClose?.();
|
|
47
48
|
}, children: [_jsx(Typography, { children: children }), url && (_jsx(Link, { align: "right", display: "block", href: url.href, onClick: () => url.onClick?.(url.href), target: "_blank", variant: "body2", children: url.label }))] })] }));
|