@vertigis/react-ui 11.2.0 → 11.2.1

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.
@@ -2,6 +2,7 @@ import type { ReactNode } from "react";
2
2
  export declare const inlineHelpClasses: {
3
3
  root: string;
4
4
  paper: string;
5
+ errorIcon: string;
5
6
  };
6
7
  export declare type InlineHelpClassKey = keyof typeof inlineHelpClasses;
7
8
  export declare type InlineHelpClasses = Record<InlineHelpClassKey, string>;
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import clsx from "clsx";
3
3
  import { forwardRef, useState } from "react";
4
4
  import Box from "../Box/index.js";
5
+ import { useFormControl } from "../FormControl/index.js";
5
6
  import IconButton from "../IconButton/index.js";
6
7
  import Link from "../Link/index.js";
7
8
  import Popover from "../Popover/index.js";
@@ -12,6 +13,7 @@ const PREFIX = "GcxInlineHelp";
12
13
  export const inlineHelpClasses = {
13
14
  root: `${PREFIX}-root`,
14
15
  paper: `${PREFIX}-paper`,
16
+ errorIcon: `${PREFIX}-errorIcon`,
15
17
  };
16
18
  const LTR_ORIGIN = {
17
19
  vertical: "top",
@@ -30,12 +32,21 @@ const StyledPopover = styled(Popover)(({ theme: { spacing } }) => ({
30
32
  wordWrap: "break-word",
31
33
  },
32
34
  }));
35
+ const Root = styled(Box)(({ theme: { spacing } }) => ({
36
+ [`& .${inlineHelpClasses.errorIcon}`]: {
37
+ color: "white",
38
+ marginTop: spacing(1),
39
+ },
40
+ }));
33
41
  const InlineHelp = forwardRef(function InlineHelp({ children, classes: classesProp, className, icon, title, url, ...other }, ref) {
34
42
  const [iconBtnEl, setIconBtnEl] = useState();
35
43
  const theme = useTheme();
36
44
  const classes = mergeStyles(inlineHelpClasses, classesProp);
45
+ const formControl = useFormControl();
37
46
  const handleIconPopoverOpen = (event) => setIconBtnEl(event.currentTarget);
38
47
  const handleIconPopoverClose = () => setIconBtnEl(undefined);
39
- return (_jsxs(Box, Object.assign({ className: clsx(classes.root, className), ref: ref }, other, { children: [_jsx(IconButton, Object.assign({ onClick: handleIconPopoverOpen, title: title, size: "small", "data-test": `${PREFIX}-button` }, { children: icon ? icon : _jsx(HelpIcon, {}, void 0) }), void 0), _jsxs(StyledPopover, Object.assign({ 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: handleIconPopoverClose }, { children: [_jsx(Typography, { children: children }, void 0), url && (_jsx(Link, Object.assign({ align: "right", display: "block", href: url.href, onClick: () => url.onClick?.(url.href), target: "_blank", variant: "body2" }, { children: url.label }), void 0))] }), void 0)] }), void 0));
48
+ return (_jsxs(Root, Object.assign({ className: clsx(classes.root, className), ref: ref }, other, { children: [_jsx(IconButton, Object.assign({ onClick: handleIconPopoverOpen, title: title, size: "small", "data-test": `${PREFIX}-button`, className: clsx({
49
+ [classes.errorIcon]: formControl?.error,
50
+ }) }, { children: icon ? icon : _jsx(HelpIcon, {}, void 0) }), void 0), _jsxs(StyledPopover, Object.assign({ 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: handleIconPopoverClose }, { children: [_jsx(Typography, { children: children }, void 0), url && (_jsx(Link, Object.assign({ align: "right", display: "block", href: url.href, onClick: () => url.onClick?.(url.href), target: "_blank", variant: "body2" }, { children: url.label }), void 0))] }), void 0)] }), void 0));
40
51
  });
41
52
  export default InlineHelp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertigis/react-ui",
3
- "version": "11.2.0",
3
+ "version": "11.2.1",
4
4
  "description": "Utilities and React components used in VertiGIS applications.",
5
5
  "keywords": [
6
6
  "vertigis",