@m4l/base 1.4.0 → 1.5.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/@types/types.d.ts CHANGED
@@ -50,4 +50,4 @@ declare module '@mui/material/styles' {
50
50
  variants?: ComponentsVariants['M4LTypography'];
51
51
  };
52
52
  }
53
- }
53
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../../../../packages/base/src/extended/mui/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,YAAY,qDA6B1C,CAAC"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../../../../packages/base/src/extended/mui/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,YAAY,qDAoC1C,CAAC"}
@@ -1,33 +1,35 @@
1
1
  import { jsx as s } from "@emotion/react/jsx-runtime";
2
- import d from "clsx";
3
- import { DEFAULT_TOOLTIP_OFFSET as n, TOOLTIP_CLASSES as i } from "./constants.js";
4
- import { RootStyled as f, TooltipStyled as S, TextStyled as c } from "./slots/TooltipSlots.js";
5
- const y = (r) => {
6
- const { size: t = "medium", children: m, title: o, className: l, offset: p = n, ...a } = r, e = t === "small" || t === "medium" ? t : "medium";
2
+ import f from "clsx";
3
+ import { DEFAULT_TOOLTIP_OFFSET as x, TOOLTIP_CLASSES as r } from "./constants.js";
4
+ import { resolveTooltipMaxWidth as T } from "./Tooltip.styles.js";
5
+ import { RootStyled as h, TooltipStyled as O, TextStyled as u } from "./slots/TooltipSlots.js";
6
+ const z = (l) => {
7
+ const { size: t = "medium", children: m, title: o, className: p, offset: a = x, maxWidth: d, ...n } = l, c = t === "small" || t === "medium" ? t : "medium", e = T(d), i = { size: c, maxWidth: e }, S = { maxWidth: e };
7
8
  return /* @__PURE__ */ s(
8
- f,
9
+ h,
9
10
  {
10
- className: d(i.root, l),
11
- ownerState: { size: e },
12
- title: typeof o == "string" ? /* @__PURE__ */ s(c, { className: i.text, ownerState: { size: e }, children: o }) : o,
11
+ className: f(r.root, p),
12
+ ownerState: i,
13
+ title: typeof o == "string" ? /* @__PURE__ */ s(u, { className: r.text, ownerState: i, children: o }) : o,
13
14
  slotProps: {
15
+ tooltip: S,
14
16
  popper: {
15
17
  modifiers: [
16
18
  {
17
19
  name: "offset",
18
20
  options: {
19
- offset: p
21
+ offset: a
20
22
  }
21
23
  }
22
24
  ]
23
25
  }
24
26
  },
25
- ...a,
26
- slots: { tooltip: S },
27
+ ...n,
28
+ slots: { tooltip: O },
27
29
  children: m
28
30
  }
29
31
  );
30
32
  };
31
33
  export {
32
- y as Tooltip
34
+ z as Tooltip
33
35
  };
@@ -1,3 +1,7 @@
1
- import { TooltipStyles } from './types';
1
+ import { TooltipProps, TooltipStyles } from './types';
2
+ /**
3
+ * Normalize tooltip maxWidth values so plain numeric inputs become valid CSS lengths.
4
+ */
5
+ export declare function resolveTooltipMaxWidth(maxWidth?: TooltipProps['maxWidth']): string | 300;
2
6
  export declare const tooltipStyles: TooltipStyles;
3
7
  //# sourceMappingURL=Tooltip.styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.styles.d.ts","sourceRoot":"","sources":["../../../../../../../packages/base/src/extended/mui/Tooltip/Tooltip.styles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqB,aAAa,EAAE,MAAM,SAAS,CAAC;AAEhE,eAAO,MAAM,aAAa,EAAE,aA4D3B,CAAC"}
1
+ {"version":3,"file":"Tooltip.styles.d.ts","sourceRoot":"","sources":["../../../../../../../packages/base/src/extended/mui/Tooltip/Tooltip.styles.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqB,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE9E;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,gBAoBzE;AAED,eAAO,MAAM,aAAa,EAAE,aA+D3B,CAAC"}
@@ -1,5 +1,15 @@
1
+ import { DEFAULT_TOOLTIP_MAX_WIDTH as r } from "./constants.js";
1
2
  import { getTypographyStyles as i } from "../../../utils/getTypographyStyles.js";
2
- const a = {
3
+ function s(t) {
4
+ if (typeof t == "number")
5
+ return `${t}px`;
6
+ if (typeof t == "string") {
7
+ const o = t.trim();
8
+ return o === "" ? r : /^\d+(\.\d+)?$/.test(o) ? `${o}px` : o;
9
+ }
10
+ return r;
11
+ }
12
+ const n = {
3
13
  /**
4
14
  * Root slot styles for the Tooltip primitive.
5
15
  */
@@ -7,24 +17,26 @@ const a = {
7
17
  /**
8
18
  * Text slot styles for string tooltip content.
9
19
  */
10
- text: ({ theme: o, ownerState: t }) => ({
11
- color: o.vars.palette.text.contrastText,
20
+ text: ({ theme: t, ownerState: o }) => ({
21
+ color: t.vars.palette.text.contrastText,
12
22
  ...i(
13
- o.generalSettings.isMobile,
14
- t?.size || "medium",
23
+ t.generalSettings.isMobile,
24
+ o?.size || "medium",
15
25
  "bodyStandard"
16
26
  )
17
27
  }),
18
28
  /**
19
29
  * Tooltip bubble slot styles.
20
30
  */
21
- tooltip: ({ theme: o }) => ({
22
- background: o.vars.palette.background.contrastDefault,
23
- padding: o.vars.size.baseSpacings.sp2,
24
- borderRadius: o.vars.size.borderRadius.r1,
25
- boxShadow: o.vars.customShadows.z3,
26
- minWidth: o.vars.size.baseSpacings.sp6,
27
- minHeight: o.vars.size.baseSpacings.sp3,
31
+ tooltip: ({ theme: t, maxWidth: o }) => ({
32
+ background: t.vars.palette.background.contrastDefault,
33
+ padding: t.vars.size.baseSpacings.sp2,
34
+ borderRadius: t.vars.size.borderRadius["r1-5"],
35
+ boxShadow: t.vars.customShadows.z3,
36
+ maxWidth: s(o),
37
+ wordWrap: "break-word",
38
+ minWidth: t.vars.size.baseSpacings.sp6,
39
+ minHeight: t.vars.size.baseSpacings.sp3,
28
40
  "&.MuiTooltip-tooltipPlacementRight .MuiTooltip-arrow": {
29
41
  left: "-6px"
30
42
  },
@@ -49,10 +61,10 @@ const a = {
49
61
  margin: "unset",
50
62
  "&::before": {
51
63
  transformOrigin: "unset",
52
- backgroundColor: o.vars.palette.background.contrastDefault,
53
- borderRadius: o.vars.size.borderRadius.r1,
54
- width: o.vars.size.baseSpacings.sp3,
55
- height: o.vars.size.baseSpacings.sp3,
64
+ backgroundColor: t.vars.palette.background.contrastDefault,
65
+ borderRadius: t.vars.size.borderRadius.r1,
66
+ width: t.vars.size.baseSpacings.sp3,
67
+ height: t.vars.size.baseSpacings.sp3,
56
68
  border: "unset",
57
69
  margin: "unset",
58
70
  transform: "rotate(45deg)"
@@ -61,5 +73,6 @@ const a = {
61
73
  })
62
74
  };
63
75
  export {
64
- a as tooltipStyles
76
+ s as resolveTooltipMaxWidth,
77
+ n as tooltipStyles
65
78
  };
@@ -10,4 +10,8 @@ export declare const TOOLTIP_CLASSES: Record<"root" | "tooltip" | "text", string
10
10
  * Default tooltip offset in pixels.
11
11
  */
12
12
  export declare const DEFAULT_TOOLTIP_OFFSET: [number, number];
13
+ /**
14
+ * Default readable width used by the owned tooltip bubble.
15
+ */
16
+ export declare const DEFAULT_TOOLTIP_MAX_WIDTH = 300;
13
17
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../../packages/base/src/extended/mui/Tooltip/constants.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,eAAe,6CAA2D,CAAC;AAExF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../../packages/base/src/extended/mui/Tooltip/constants.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,eAAe,6CAA2D,CAAC;AAExF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,yBAAyB,MAAM,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { getComponentClasses as o } from "../../../utils/getComponentSlotRoot.js";
2
- import { TooltipSlots as t } from "./slots/TooltipEnum.js";
3
- const T = "M4LTooltip", p = o(T, t), L = [0, 10];
2
+ import { TooltipSlots as T } from "./slots/TooltipEnum.js";
3
+ const t = "M4LTooltip", L = o(t, T), _ = [0, 10], n = 300;
4
4
  export {
5
- L as DEFAULT_TOOLTIP_OFFSET,
6
- p as TOOLTIP_CLASSES,
7
- T as TOOLTIP_KEY_COMPONENT
5
+ n as DEFAULT_TOOLTIP_MAX_WIDTH,
6
+ _ as DEFAULT_TOOLTIP_OFFSET,
7
+ L as TOOLTIP_CLASSES,
8
+ t as TOOLTIP_KEY_COMPONENT
8
9
  };
@@ -6,5 +6,5 @@ export declare const TextStyled: import('@emotion/styled').StyledComponent<impor
6
6
  }, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
7
7
  export declare const TooltipStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
8
8
  ownerState?: (Partial<import('..').TooltipOwnerState> & Record<string, unknown>) | undefined;
9
- }, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').HTMLAttributes<HTMLDivElement> | keyof import('react').ClassAttributes<HTMLDivElement>>, {}>;
9
+ }, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
10
10
  //# sourceMappingURL=TooltipSlots.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipSlots.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/base/src/extended/mui/Tooltip/slots/TooltipSlots.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU;;UAID,CAAC;AAEvB,eAAO,MAAM,UAAU;;yGAID,CAAC;AAEvB,eAAO,MAAM,aAAa;;6NAGD,CAAC"}
1
+ {"version":3,"file":"TooltipSlots.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/base/src/extended/mui/Tooltip/slots/TooltipSlots.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU;;UAID,CAAC;AAEvB,eAAO,MAAM,UAAU;;yGAID,CAAC;AAEvB,eAAO,MAAM,aAAa;;yGAID,CAAC"}
@@ -1,22 +1,23 @@
1
- import { Tooltip as p } from "@mui/material";
1
+ import { Tooltip as i } from "@mui/material";
2
2
  import { styled as t } from "@mui/material/styles";
3
3
  import { tooltipStyles as r } from "../Tooltip.styles.js";
4
- import { TOOLTIP_KEY_COMPONENT as l } from "../constants.js";
5
- import { TooltipSlots as e } from "./TooltipEnum.js";
6
- const a = t(p, {
7
- name: l,
8
- slot: e.root,
4
+ import { TOOLTIP_KEY_COMPONENT as e } from "../constants.js";
5
+ import { TooltipSlots as l } from "./TooltipEnum.js";
6
+ const n = t(i, {
7
+ name: e,
8
+ slot: l.root,
9
9
  shouldForwardProp: (o) => o !== "ownerState"
10
10
  })(r.root), S = t("div", {
11
- name: l,
12
- slot: e.text,
11
+ name: e,
12
+ slot: l.text,
13
13
  shouldForwardProp: (o) => o !== "ownerState"
14
14
  })(r.text), T = t("div", {
15
- name: l,
16
- slot: e.tooltip
15
+ name: e,
16
+ slot: l.tooltip,
17
+ shouldForwardProp: (o) => o !== "ownerState" && o !== "maxWidth"
17
18
  })(r.tooltip);
18
19
  export {
19
- a as RootStyled,
20
+ n as RootStyled,
20
21
  S as TextStyled,
21
22
  T as TooltipStyled
22
23
  };
@@ -1,6 +1,7 @@
1
1
  import { ComponentNameToClassKey, SxProps, Theme, TooltipProps as MUITooltipProps } from '@mui/material';
2
2
  import { OverridesStyleRules } from '@mui/material/styles/overrides';
3
3
  import { Sizes } from '@m4l/styles';
4
+ import { CSSProperties } from 'react';
4
5
  import { M4LOverridesStyleRules } from '../../../@types/augmentations';
5
6
  import { TOOLTIP_KEY_COMPONENT } from './constants';
6
7
  import { TooltipSlots } from './slots/TooltipEnum';
@@ -15,11 +16,13 @@ export interface TooltipProps extends Omit<MUITooltipProps, 'sx'> {
15
16
  placement?: MUITooltipProps['placement'];
16
17
  /** Popper offset relative to the anchor. */
17
18
  offset?: [number, number];
19
+ /** Maximum width applied to the tooltip bubble as pixels or any valid CSS length. */
20
+ maxWidth?: CSSProperties['maxWidth'];
18
21
  }
19
22
  /**
20
23
  * Owner state used by the styled Tooltip slots.
21
24
  */
22
- export type TooltipOwnerState = Pick<TooltipProps, 'size'>;
25
+ export type TooltipOwnerState = Pick<TooltipProps, 'size' | 'maxWidth'>;
23
26
  /**
24
27
  * Slot key union for the Tooltip component.
25
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../packages/base/src/extended/mui/Tooltip/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;GAEG;AACH,MA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