@m4l/components 9.1.45 → 9.1.46

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.
@@ -1,3 +1,4 @@
1
+ import { default as React } from 'react';
1
2
  import { BooleanFormatterProps } from './types';
2
3
  /**
3
4
  * BooleanFormatter
@@ -10,10 +11,12 @@ import { BooleanFormatterProps } from './types';
10
11
  * - `'check'`: Displays an icon representing `true` or `false`.
11
12
  * [value=false]
12
13
  * The boolean value to be formatted.
13
- * [Component=WrapperComponent]
14
+ * [Component=BooleanFormatterRootStyled]
14
15
  * A custom wrapper component for the formatted output.
15
16
  * [dataTestId]
16
17
  * A unique identifier for testing purposes, used as a `data-testid` attribute.
18
+ * [className]
19
+ * A custom class name to apply to the component.
17
20
  * @example
18
21
  * <BooleanFormatter presentationType="string_yes_no" value={true} />
19
22
  * // Renders "Yes"
@@ -26,4 +29,4 @@ import { BooleanFormatterProps } from './types';
26
29
  * @updatedAt 2024-12-10 14:11:20 - automatic
27
30
  * @updatedUser cesar - automatic
28
31
  */
29
- export declare function BooleanFormatter(props: BooleanFormatterProps): import("react/jsx-runtime").JSX.Element;
32
+ export declare function BooleanFormatter<T extends React.ElementType>(props: BooleanFormatterProps<T>): string | import("react/jsx-runtime").JSX.Element;
@@ -1,47 +1,50 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { useMemo } from "react";
2
+ import React, { useMemo } from "react";
3
3
  import { useModuleDictionary, useEnvironment } from "@m4l/core";
4
- import { W as WrapperComponent } from "../../WrapperComponent/index.js";
5
4
  import { L as LABEL_BOOLEAN_YES, a as LABEL_BOOLEAN_NO, b as LABEL_BOOLEAN_TRUE, c as LABEL_BOOLEAN_FALSE } from "./dictionary.js";
6
5
  import clsx from "clsx";
7
6
  import { a as getComponentSlotRoot } from "../../../utils/getComponentSlotRoot.js";
8
7
  import { B as BOOLEAN_FORMATTER_KEY_COMPONENT } from "./constants.js";
9
8
  import { a as getPropDataTestId } from "../../../test/getNameDataTestId.js";
10
- import { T as TextStyled, F as FormatterRootStyled, B as BooleanFormatterIconStyled } from "./slots/BooleanFormatterSlots.js";
9
+ import { B as BooleanFormatterIconStyled, a as BooleanFormatterRootStyled } from "./slots/BooleanFormatterSlots.js";
11
10
  import { B as BooleanFormatterSlots } from "./slots/BooleanFormatterEnum.js";
12
11
  function BooleanFormatter(props) {
13
- const { presentationType, value, Component = WrapperComponent, dataTestId } = props;
12
+ const { presentationType, value, Component = BooleanFormatterRootStyled, dataTestId, className, componentProps } = props;
14
13
  const { getLabel } = useModuleDictionary();
15
14
  const { host_static_assets, environment_assets } = useEnvironment();
16
15
  const final_value = value ?? false;
17
16
  const srcCheckTrue = `${host_static_assets}/${environment_assets}/frontend/components/data_grid/components/boolean_formatter/assets/icons/check_true.svg`;
18
17
  const srcCheckFalse = `${host_static_assets}/${environment_assets}/frontend/components/data_grid/components/boolean_formatter/assets/icons/check_false.svg`;
19
- const ownerState = { isTrue: final_value };
18
+ const ownerState = { value: final_value };
20
19
  const memoComponent = useMemo(() => {
21
20
  if (presentationType === "string_yes_no") {
22
- return /* @__PURE__ */ jsx(Component, { children: /* @__PURE__ */ jsx(TextStyled, { ownerState, children: final_value ? getLabel(LABEL_BOOLEAN_YES) : getLabel(LABEL_BOOLEAN_NO) }) });
21
+ return final_value ? getLabel(LABEL_BOOLEAN_YES) : getLabel(LABEL_BOOLEAN_NO);
23
22
  }
24
23
  if (presentationType === "string_true_false") {
25
- return /* @__PURE__ */ jsx(Component, { children: /* @__PURE__ */ jsx(TextStyled, { ownerState, children: final_value ? getLabel(LABEL_BOOLEAN_TRUE) : getLabel(LABEL_BOOLEAN_FALSE) }) });
24
+ return final_value ? getLabel(LABEL_BOOLEAN_TRUE) : getLabel(LABEL_BOOLEAN_FALSE);
26
25
  }
27
26
  return /* @__PURE__ */ jsx(
28
- FormatterRootStyled,
27
+ BooleanFormatterIconStyled,
29
28
  {
30
- className: clsx(getComponentSlotRoot(BOOLEAN_FORMATTER_KEY_COMPONENT)),
31
- ...getPropDataTestId(BOOLEAN_FORMATTER_KEY_COMPONENT, BooleanFormatterSlots.booleanFormatterRoot, dataTestId),
32
- role: "booleanStyled-role",
33
29
  ownerState,
34
- children: /* @__PURE__ */ jsx(Component, { children: /* @__PURE__ */ jsx(
35
- BooleanFormatterIconStyled,
36
- {
37
- ownerState,
38
- src: final_value ? srcCheckTrue : srcCheckFalse
39
- }
40
- ) })
30
+ src: final_value ? srcCheckTrue : srcCheckFalse
41
31
  }
42
32
  );
43
33
  }, [final_value, getLabel, presentationType, srcCheckTrue, srcCheckFalse]);
44
- return memoComponent;
34
+ if (Component === React.Fragment) {
35
+ return memoComponent;
36
+ }
37
+ return /* @__PURE__ */ jsx(
38
+ Component,
39
+ {
40
+ className: clsx(getComponentSlotRoot(BOOLEAN_FORMATTER_KEY_COMPONENT), className),
41
+ ...getPropDataTestId(BOOLEAN_FORMATTER_KEY_COMPONENT, BooleanFormatterSlots.root, dataTestId),
42
+ role: "booleanStyled-role",
43
+ ownerState,
44
+ ...componentProps,
45
+ children: memoComponent
46
+ }
47
+ );
45
48
  }
46
49
  export {
47
50
  BooleanFormatter as B
@@ -6,15 +6,20 @@ const booleanFormatterStyles = {
6
6
  * @updatedAt 2024-12-30 14:36:10 - automatic
7
7
  * @updatedUser Andrés Quintero - automatic
8
8
  */
9
- text: ({ theme }) => ({
9
+ root: ({ theme }) => ({
10
10
  "& .MuiSkeleton-text": {
11
11
  width: `${theme.vars.size.baseSpacings.sp7} !important`,
12
12
  borderRadius: theme.vars.size.borderRadius.r1
13
13
  }
14
14
  }),
15
- booleanFormatterRoot: {},
16
- booleanFormatterSkeleton: {},
17
- booleanFormatterIcon: {}
15
+ /**
16
+ * Styled del icono
17
+ */
18
+ icon: ({ theme }) => ({
19
+ "& .M4LIcon-icon": {
20
+ backgroundColor: theme.vars.palette.text.primary
21
+ }
22
+ })
18
23
  };
19
24
  export {
20
25
  booleanFormatterStyles as b
@@ -3,5 +3,5 @@ export declare const LABEL_BOOLEAN_YES = "boolean_formatter.boolean_yes";
3
3
  export declare const LABEL_BOOLEAN_NO = "boolean_formatter.boolean_no";
4
4
  export declare const LABEL_BOOLEAN_TRUE = "boolean_formatter.boolean_true";
5
5
  export declare const LABEL_BOOLEAN_FALSE = "boolean_formatter.boolean_false";
6
- export declare function getFormattersComponentsDictionary(): string[];
6
+ export declare function getBooleanFormatterComponentsDictionary(): string[];
7
7
  export declare const BOOLEAN_FORMATTER_DICTIONARY_LABELS: string[];
@@ -1,6 +1,4 @@
1
1
  export declare enum BooleanFormatterSlots {
2
- booleanFormatterRoot = "booleanFormatterRoot",
3
- booleanFormatterSkeleton = "booleanFormatterSkeleton",
4
- booleanFormatterIcon = "booleanFormatterIcon",
5
- text = "text"
2
+ icon = "icon",
3
+ root = "root"
6
4
  }
@@ -1,8 +1,6 @@
1
1
  var BooleanFormatterSlots = /* @__PURE__ */ ((BooleanFormatterSlots2) => {
2
- BooleanFormatterSlots2["booleanFormatterRoot"] = "booleanFormatterRoot";
3
- BooleanFormatterSlots2["booleanFormatterSkeleton"] = "booleanFormatterSkeleton";
4
- BooleanFormatterSlots2["booleanFormatterIcon"] = "booleanFormatterIcon";
5
- BooleanFormatterSlots2["text"] = "text";
2
+ BooleanFormatterSlots2["icon"] = "icon";
3
+ BooleanFormatterSlots2["root"] = "root";
6
4
  return BooleanFormatterSlots2;
7
5
  })(BooleanFormatterSlots || {});
8
6
  export {
@@ -1,12 +1,6 @@
1
- export declare const FormatterRootStyled: import('@emotion/styled').StyledComponent<Pick<import('../../FormatterRoot/types').FormatterRootProps, "children"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown> & {
2
- ownerState: Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown>;
3
- }, {}, {}>;
4
1
  export declare const BooleanFormatterIconStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../Icon/types').IconProps, keyof import('../../../Icon/types').IconProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown> & {
5
2
  ownerState: Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown>;
6
3
  }, {}, {}>;
7
- export declare const BooleanFormatterSkeletonStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../mui_extended/Skeleton/types').SkeletonProps, keyof import('../../../mui_extended/Skeleton/types').SkeletonProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown> & {
8
- ownerState: Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown>;
9
- }, {}, {}>;
10
- export declare const TextStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../mui_extended/Typography/types').TypographyProps, keyof import('../../../mui_extended/Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown> & {
4
+ export declare const BooleanFormatterRootStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../mui_extended/Typography/types').TypographyProps, keyof import('../../../mui_extended/Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material/styles').Theme> & Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown> & {
11
5
  ownerState: Partial<import('..').BooleanFormatterOwnerState> & Record<string, unknown>;
12
6
  }, {}, {}>;
@@ -2,28 +2,17 @@ import { styled } from "@mui/material/styles";
2
2
  import { B as BOOLEAN_FORMATTER_KEY_COMPONENT } from "../constants.js";
3
3
  import { B as BooleanFormatterSlots } from "./BooleanFormatterEnum.js";
4
4
  import { b as booleanFormatterStyles } from "../BooleanFormatter.styles.js";
5
- import { F as FormatterRoot } from "../../FormatterRoot/index.js";
6
5
  import { T as Typography } from "../../../mui_extended/Typography/Typography.js";
7
- import { S as Skeleton } from "../../../mui_extended/Skeleton/Skeleton.js";
8
6
  import { I as Icon } from "../../../Icon/Icon.js";
9
- const FormatterRootStyled = styled(FormatterRoot, {
10
- name: BOOLEAN_FORMATTER_KEY_COMPONENT,
11
- slot: BooleanFormatterSlots.booleanFormatterRoot
12
- })(booleanFormatterStyles?.booleanFormatterRoot);
13
7
  const BooleanFormatterIconStyled = styled(Icon, {
14
8
  name: BOOLEAN_FORMATTER_KEY_COMPONENT,
15
- slot: BooleanFormatterSlots.booleanFormatterIcon
16
- })(booleanFormatterStyles?.booleanFormatterIcon);
17
- styled(Skeleton, {
18
- name: BOOLEAN_FORMATTER_KEY_COMPONENT,
19
- slot: BooleanFormatterSlots.booleanFormatterSkeleton
20
- })(booleanFormatterStyles?.booleanFormatterSkeleton);
21
- const TextStyled = styled(Typography, {
9
+ slot: BooleanFormatterSlots.icon
10
+ })(booleanFormatterStyles?.icon);
11
+ const BooleanFormatterRootStyled = styled(Typography, {
22
12
  name: BOOLEAN_FORMATTER_KEY_COMPONENT,
23
- slot: BooleanFormatterSlots.text
24
- })(booleanFormatterStyles?.text);
13
+ slot: BooleanFormatterSlots.root
14
+ })(booleanFormatterStyles?.root);
25
15
  export {
26
16
  BooleanFormatterIconStyled as B,
27
- FormatterRootStyled as F,
28
- TextStyled as T
17
+ BooleanFormatterRootStyled as a
29
18
  };
@@ -1,5 +1,5 @@
1
1
  import { OverridesStyleRules } from '@mui/material/styles/overrides';
2
- import { BooleanFormatterSlots } from './slots';
2
+ import { BooleanFormatterRootStyled, BooleanFormatterSlots } from './slots';
3
3
  import { BOOLEAN_FORMATTER_KEY_COMPONENT } from './constants';
4
4
  import { Theme } from '@mui/material';
5
5
  /**
@@ -16,17 +16,22 @@ export type BooleanFormatter = keyof typeof BooleanFormatterSlots;
16
16
  /**
17
17
  * Properties for the `BooleanFormatter` component.
18
18
  */
19
- export interface BooleanFormatterProps {
20
- Component?: React.ElementType;
19
+ export interface BooleanFormatterProps<T extends React.ElementType = typeof BooleanFormatterRootStyled> {
20
+ Component?: T;
21
21
  presentationType: PresentationType;
22
22
  value?: boolean;
23
23
  dataTestId?: string;
24
+ className?: string;
25
+ /**
26
+ * Props para el componente personalizado.
27
+ */
28
+ componentProps?: React.ComponentPropsWithoutRef<T>;
24
29
  }
25
30
  /**
26
31
  * State properties for the `BooleanFormatter` component.
27
32
  */
28
33
  export interface BooleanFormatterOwnerState {
29
- isTrue?: boolean;
34
+ value?: boolean;
30
35
  [key: string]: unknown;
31
36
  }
32
37
  /**
@@ -34,7 +34,7 @@ export interface TypographyProps extends Omit<MUITypographyProps, 'color' | 'var
34
34
  /**
35
35
  * Contenido del componente.
36
36
  */
37
- children?: string;
37
+ children?: React.ReactNode;
38
38
  /**
39
39
  * Nombre identificador del componente, es útil para realizar pruebas del componente.
40
40
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.1.45",
3
+ "version": "9.1.46",
4
4
  "license": "UNLICENSED",
5
5
  "lint-staged": {
6
6
  "*.{js,ts,tsx}": "eslint --fix --max-warnings 0"
@@ -1,10 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { f as formatterClasses } from "../classes/index.js";
3
- import { F as FormatterRootContainer } from "./styles.js";
4
- const FormatterRoot = (props) => {
5
- const { children } = props;
6
- return /* @__PURE__ */ jsx(FormatterRootContainer, { className: formatterClasses.root, children });
7
- };
8
- export {
9
- FormatterRoot as F
10
- };
@@ -1,7 +0,0 @@
1
- import { styled } from "@mui/material";
2
- const FormatterRootContainer = styled("div")(({ theme }) => ({
3
- ...theme.components?.M4LFormatter?.styleOverrides || {}
4
- }));
5
- export {
6
- FormatterRootContainer as F
7
- };
@@ -1,13 +0,0 @@
1
- import { generateUtilityClasses } from "@mui/material";
2
- import "@mui/base";
3
- import { C as COMPONENT_CLASS_NAME } from "../constants.js";
4
- const formatterClasses = generateUtilityClasses(COMPONENT_CLASS_NAME, [
5
- /* elements */
6
- "root",
7
- "booleanFormatterIcon",
8
- "booleanFormatterCheck"
9
- /* states or variants of elements */
10
- ]);
11
- export {
12
- formatterClasses as f
13
- };
@@ -1,4 +0,0 @@
1
- const COMPONENT_CLASS_NAME = "M4LFormatter";
2
- export {
3
- COMPONENT_CLASS_NAME as C
4
- };