@vertigis/react-ui 11.31.2 → 11.32.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.
@@ -3,10 +3,12 @@ import type { FormLabelClasses as MUIFormLabelClasses, FormLabelProps as MUIForm
3
3
  import type { OverridableComponent } from "@mui/material/OverridableComponent";
4
4
  declare const gcxFormLabelClasses: {
5
5
  errorIcon: string;
6
+ errorIconBackground: string;
6
7
  };
7
8
  export * from "@mui/material/FormLabel";
8
9
  export declare const formLabelClasses: {
9
10
  errorIcon: string;
11
+ errorIconBackground: string;
10
12
  root: string;
11
13
  colorSecondary: string;
12
14
  focused: string;
@@ -2,12 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import MUIFormLabel, { formLabelClasses as muiFormLabelClasses } from "@mui/material/FormLabel";
3
3
  import clsx from "clsx";
4
4
  import { forwardRef } from "react";
5
+ import Box from "../Box/index.js";
5
6
  import { useFormControl } from "../FormControl/index.js";
6
7
  import ErrorIcon from "../icons/Error.js";
7
8
  import { mergeStyles, styled } from "../styles/index.js";
8
9
  const PREFIX = "GcxFormLabel";
9
10
  const gcxFormLabelClasses = {
10
11
  errorIcon: `${PREFIX}-errorIcon`,
12
+ errorIconBackground: `${PREFIX}-errorIconBackground`,
11
13
  };
12
14
  // MUST be the first export, since some of the exports are overridden below.
13
15
  export * from "@mui/material/FormLabel";
@@ -18,7 +20,6 @@ export const formLabelClasses = {
18
20
  const StyledMUIFormLabel = styled(MUIFormLabel)(({ theme: { spacing, palette } }) => ({
19
21
  [`& .${formLabelClasses.errorIcon}`]: {
20
22
  fontSize: "0.875em",
21
- marginRight: spacing(0.5),
22
23
  },
23
24
  }));
24
25
  export const FormLabel = forwardRef(function FormLabel(props, ref) {
@@ -27,7 +28,7 @@ export const FormLabel = forwardRef(function FormLabel(props, ref) {
27
28
  // See https://github.com/mui-org/material-ui/pull/20278.
28
29
  const muiFormControl = useFormControl();
29
30
  const error = errorProp ?? muiFormControl?.error;
30
- const { errorIcon: errorIconClass, ...otherClasses } = mergeStyles(gcxFormLabelClasses, classes);
31
- return (_jsxs(StyledMUIFormLabel, { error: error, className: clsx("GcxFormLabel", className), ...other, classes: otherClasses, ref: ref, children: [error && _jsx(ErrorIcon, { className: errorIconClass, "data-test": "FormLabel-ErrorIcon" }), children] }));
31
+ const { errorIcon: errorIconClass, errorIconBackground: errorIconBackgroundClass, ...otherClasses } = mergeStyles(gcxFormLabelClasses, classes);
32
+ return (_jsxs(StyledMUIFormLabel, { error: error, className: clsx("GcxFormLabel", className), ...other, classes: otherClasses, ref: ref, children: [error && (_jsx(Box, { className: errorIconBackgroundClass, component: "span", children: _jsx(ErrorIcon, { className: errorIconClass, "data-test": "FormLabel-ErrorIcon" }) })), children] }));
32
33
  });
33
34
  export default FormLabel;
@@ -32,12 +32,6 @@ const StyledPopover = styled(Popover)(({ theme: { spacing } }) => ({
32
32
  wordWrap: "break-word",
33
33
  },
34
34
  }));
35
- const Root = styled(Box)(({ theme: { spacing } }) => ({
36
- [`& .${inlineHelpClasses.errorIcon}`]: {
37
- color: "white",
38
- marginTop: spacing(1),
39
- },
40
- }));
41
35
  const InlineHelp = forwardRef(function InlineHelp({ children, classes: classesProp, className, icon, title, url, ...other }, ref) {
42
36
  const [iconBtnEl, setIconBtnEl] = useState();
43
37
  const theme = useTheme();
@@ -45,7 +39,7 @@ const InlineHelp = forwardRef(function InlineHelp({ children, classes: classesPr
45
39
  const formControl = useFormControl();
46
40
  const handleIconPopoverOpen = (event) => setIconBtnEl(event.currentTarget);
47
41
  const handleIconPopoverClose = () => setIconBtnEl(undefined);
48
- return (_jsxs(Root, { className: clsx(classes.root, className), ref: ref, ...other, children: [_jsx(IconButton, { onClick: handleIconPopoverOpen, title: title, size: "small", "data-test": `${PREFIX}-button`, className: clsx({
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({
49
43
  [classes.errorIcon]: formControl?.error,
50
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: handleIconPopoverClose, 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 }))] })] }));
51
45
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertigis/react-ui",
3
- "version": "11.31.2",
3
+ "version": "11.32.0",
4
4
  "description": "Utilities and React components used in VertiGIS applications.",
5
5
  "keywords": [
6
6
  "vertigis",
@@ -141,6 +141,7 @@ const getMenuItemStyles = ({ palette, transitions }) => ({
141
141
  */
142
142
  function getOverrides(theme) {
143
143
  const { palette, shape, spacing, transitions, typography } = theme;
144
+ const isDarkMode = palette.mode === "dark";
144
145
  return {
145
146
  components: {
146
147
  MuiAutocomplete: {
@@ -389,10 +390,10 @@ function getOverrides(theme) {
389
390
  marginTop: 0,
390
391
  marginBottom: spacing(0.5),
391
392
  "&.Mui-error": {
392
- paddingLeft: spacing(1),
393
393
  borderRadius: shape.borderRadius,
394
- color: "white",
395
- backgroundColor: palette.error.main,
394
+ color: isDarkMode ? palette.text.primary : palette.error.main,
395
+ fontStyle: "italic",
396
+ backgroundColor: palette.background.default,
396
397
  },
397
398
  },
398
399
  },
@@ -402,17 +403,33 @@ function getOverrides(theme) {
402
403
  root: {
403
404
  // Override disabled background color that gets applied
404
405
  backgroundColor: "transparent",
405
- margin: spacing(1, 0),
406
+ margin: spacing(0.5, 0),
406
407
  color: "currentColor",
407
408
  // Clear InlineHelp button
408
409
  paddingRight: typography.pxToRem(32),
409
- lineHeight: 1,
410
+ lineHeight: 1.4,
410
411
  fontWeight: typography.fontWeightMedium,
411
412
  "&.Mui-error, &.Mui-error.Mui-focused": {
412
- padding: spacing(1),
413
413
  borderRadius: shape.borderRadius,
414
- color: "white",
415
- backgroundColor: palette.error.main,
414
+ color: palette.text.primary,
415
+ backgroundColor: palette.background.default,
416
+ // Error icon background circle
417
+ "& .GcxFormLabel-errorIconBackground": {
418
+ display: "inline-flex",
419
+ width: typography.pxToRem(22),
420
+ height: typography.pxToRem(22),
421
+ justifyContent: "center",
422
+ marginRight: "4px",
423
+ alignItems: "center",
424
+ borderRadius: "50%",
425
+ backgroundColor: isDarkMode
426
+ ? palette.text.primary
427
+ : palette.error.main,
428
+ },
429
+ },
430
+ "&.Mui-error .GcxFormLabel-errorIcon": {
431
+ margin: "0px 0px 2px 0px",
432
+ color: isDarkMode ? palette.error.main : palette.background.default,
416
433
  },
417
434
  "&.Mui-focused": {
418
435
  color: "currentColor",
@@ -467,13 +484,13 @@ function getOverrides(theme) {
467
484
  boxShadow: "none",
468
485
  },
469
486
  "&.Mui-error": {
470
- backgroundColor: alpha(palette.error.main, 0.15),
471
- borderColor: palette.error.main,
472
- boxShadow: `0 0 0 1px ${palette.error.main} inset`,
487
+ backgroundColor: "transparent",
488
+ borderColor: "transparent",
489
+ boxShadow: `0 0 0 1px ${isDarkMode ? palette.common.white : "transparent"} inset, 0 0 0 3px ${palette.error.main} inset, 0 0 0 4px ${isDarkMode ? palette.common.white : "transparent"} inset`,
473
490
  },
474
491
  "&.Mui-disabled": {
475
492
  borderColor: palette.grey[300],
476
- backgroundColor: palette.mode === "dark" ? palette.grey[900] : palette.grey[100],
493
+ backgroundColor: isDarkMode ? palette.grey[900] : palette.grey[100],
477
494
  },
478
495
  },
479
496
  inputMultiline: {
@@ -720,7 +737,7 @@ function getOverrides(theme) {
720
737
  },
721
738
  styleOverrides: {
722
739
  root: {
723
- backgroundColor: palette.mode === "dark" ? palette.grey[900] : palette.grey[100],
740
+ backgroundColor: isDarkMode ? palette.grey[900] : palette.grey[100],
724
741
  borderStyle: "solid",
725
742
  borderWidth: 1,
726
743
  borderColor: palette.grey[400],
@@ -758,7 +775,7 @@ function getOverrides(theme) {
758
775
  },
759
776
  head: {
760
777
  // Chosen to match PanelGroup in react-ui-internal.
761
- backgroundColor: palette.mode === "dark" ? palette.grey[900] : palette.grey[200],
778
+ backgroundColor: isDarkMode ? palette.grey[900] : palette.grey[200],
762
779
  fontWeight: "bold",
763
780
  fontSize: typography.pxToRem(14),
764
781
  },