@m4l/components 9.1.73 → 9.1.75
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/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index.js +1 -1
- package/components/DataGrid/formatters/ColumnDateFormatter/index.js +1 -1
- package/components/ObjectLogs/index.d.ts +4 -0
- package/components/ObjectLogs/index.js +1 -1
- package/components/formatters/ConcatenatedFormatter/ConcatenatedFormatter.d.ts +32 -0
- package/components/formatters/ConcatenatedFormatter/ConcatenatedFormatter.js +62 -0
- package/components/formatters/ConcatenatedFormatter/ConcatenatedFormatter.styles.d.ts +2 -0
- package/components/formatters/ConcatenatedFormatter/ConcatenatedFormatter.styles.js +11 -0
- package/components/formatters/ConcatenatedFormatter/constants.d.ts +1 -0
- package/components/formatters/ConcatenatedFormatter/constants.js +4 -0
- package/components/formatters/ConcatenatedFormatter/slots/ConcatenatedFormatterEnum.d.ts +3 -0
- package/components/formatters/ConcatenatedFormatter/slots/ConcatenatedFormatterEnum.js +7 -0
- package/components/formatters/ConcatenatedFormatter/slots/ConcatenatedFormatterSlots.d.ts +1 -0
- package/components/formatters/ConcatenatedFormatter/slots/ConcatenatedFormatterSlots.js +12 -0
- package/components/formatters/ConcatenatedFormatter/test/index.test.d.ts +1 -0
- package/components/formatters/ConcatenatedFormatter/types.d.ts +21 -1
- package/components/formatters/DateFormatter/DateFormatter.d.ts +38 -0
- package/components/formatters/DateFormatter/DateFormatter.js +73 -0
- package/components/formatters/DateFormatter/DateFormatter.styles.d.ts +2 -0
- package/components/formatters/DateFormatter/DateFormatter.styles.js +17 -0
- package/components/formatters/DateFormatter/constants.d.ts +1 -0
- package/components/formatters/DateFormatter/constants.js +4 -0
- package/components/formatters/DateFormatter/slots/DateFormatterEnum.d.ts +3 -0
- package/components/formatters/DateFormatter/slots/DateFormatterEnum.js +7 -0
- package/components/formatters/DateFormatter/slots/DateFormatterSlots.d.ts +1 -0
- package/components/formatters/DateFormatter/slots/DateFormatterSlots.js +12 -0
- package/components/formatters/DateFormatter/tests/DateFormatter.test.d.ts +1 -0
- package/components/formatters/DateFormatter/types.d.ts +30 -2
- package/components/formatters/index.d.ts +2 -2
- package/components/mui_extended/Typography/typography.styles.js +17 -3
- package/index.js +2 -2
- package/package.json +1 -1
- package/components/formatters/ConcatenatedFormatter/index.d.ts +0 -14
- package/components/formatters/ConcatenatedFormatter/index.js +0 -37
- package/components/formatters/ConcatenatedFormatter/index.test.d.ts +0 -4
- package/components/formatters/DateFormatter/index.d.ts +0 -17
- package/components/formatters/DateFormatter/index.js +0 -43
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getPropertyByString } from "@m4l/core";
|
|
3
|
-
import { C as ConcatenatedFormatter } from "../../../formatters/ConcatenatedFormatter/
|
|
3
|
+
import { C as ConcatenatedFormatter } from "../../../formatters/ConcatenatedFormatter/ConcatenatedFormatter.js";
|
|
4
4
|
function ColumnConcatenatedValueFormatter(props) {
|
|
5
5
|
const { fieldValue, fieldSeparator, Component } = props;
|
|
6
6
|
return (obProps) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getPropertyByString } from "@m4l/core";
|
|
3
|
-
import { D as DateFormatter } from "../../../formatters/DateFormatter/
|
|
3
|
+
import { D as DateFormatter } from "../../../formatters/DateFormatter/DateFormatter.js";
|
|
4
4
|
function ColumnDateFormatter(props) {
|
|
5
5
|
const { fieldValue, presentationType, Component } = props;
|
|
6
6
|
return (obProps) => {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { LogsProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* TODO: Documentar
|
|
4
|
+
* @author cesar - automatic
|
|
5
|
+
* @createdAt 2025-01-15 15:48:39 - automatic
|
|
6
|
+
* @updatedAt 2025-01-15 15:48:39 - automatic
|
|
7
|
+
* @updatedUser cesar - automatic
|
|
4
8
|
*/
|
|
5
9
|
export declare function ObjectLogs(props: LogsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,7 +3,7 @@ import { useState, useCallback, useMemo, useEffect } from "react";
|
|
|
3
3
|
import { useModuleDictionary, useEnvironment, usePaginate } from "@m4l/core";
|
|
4
4
|
import { C as Container, A as Actions, G as GridWrapper } from "./styles.js";
|
|
5
5
|
import { D as DataGrid } from "../DataGrid/index.js";
|
|
6
|
-
import { D as DateFormatter } from "../formatters/DateFormatter/
|
|
6
|
+
import { D as DateFormatter } from "../formatters/DateFormatter/DateFormatter.js";
|
|
7
7
|
import { D as DetailFormatter } from "./components/DetailFormatter/index.js";
|
|
8
8
|
import { D as DynamicFilter } from "../DynamicFilter/DynamicFilter.js";
|
|
9
9
|
import { T as TEST_PROP_ID } from "../../test/constants_no_mock.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ConcatenatedFormatterRootStyled } from './slots/ConcatenatedFormatterSlots';
|
|
3
|
+
import { ConcatenatedFormatterProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Concatena un arrays de strings y/o numbers. Retorna un string
|
|
6
|
+
* @param values Array de strings o numnbers a concatenar
|
|
7
|
+
* @param separator String utilizado como separador entre componentes del array
|
|
8
|
+
* @returns string
|
|
9
|
+
* @example
|
|
10
|
+
* const data = ['10 enero','15 febrero','22 marzo']
|
|
11
|
+
*
|
|
12
|
+
* const result = getFormatConcatenated(data,' | ');
|
|
13
|
+
* console.log(result); // "10 enero | 15 febrero | 22 marzo"
|
|
14
|
+
*/
|
|
15
|
+
export declare function getFormatConcatenated(values: Array<string | number>, separator: string | number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Concatena un arrays de strings y/o numbers. Retorna un JSX
|
|
18
|
+
* @param props {values: Array<string> Valores a concatenar, separator: string Separador entre valores concatenados, Component: ElementType Componente que abraza la respuesta}
|
|
19
|
+
* @returns
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
*
|
|
23
|
+
* <ConcatenatedFormatter
|
|
24
|
+
* value = {['10 enero','15 febrero','22 marzo']}
|
|
25
|
+
* separator= ' | '
|
|
26
|
+
* color='text.primary'
|
|
27
|
+
* size='medium'
|
|
28
|
+
* variant='body'
|
|
29
|
+
* />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function ConcatenatedFormatter<T extends React.ElementType = typeof ConcatenatedFormatterRootStyled>(props: ConcatenatedFormatterProps): JSX.Element;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
|
+
import { g as getPropDataTestId } from "../../../test/getNameDataTestId.js";
|
|
5
|
+
import { a as getComponentSlotRoot } from "../../../utils/getComponentSlotRoot.js";
|
|
6
|
+
import { C as ConcatenatedFormatterRootStyled } from "./slots/ConcatenatedFormatterSlots.js";
|
|
7
|
+
import { C as CONTATENATED_FORMATTER_KEY_COMPONENT } from "./constants.js";
|
|
8
|
+
import { C as ConcatenatedFormatterSlots } from "./slots/ConcatenatedFormatterEnum.js";
|
|
9
|
+
import { u as useComponentSize } from "../../../hooks/useComponentSize/useComponentSize.js";
|
|
10
|
+
function getFormatConcatenated(values, separator) {
|
|
11
|
+
const returnSymbol = "";
|
|
12
|
+
if (values === null) {
|
|
13
|
+
return returnSymbol;
|
|
14
|
+
}
|
|
15
|
+
if (!Array.isArray(values)) {
|
|
16
|
+
return values.toString();
|
|
17
|
+
} else {
|
|
18
|
+
if (values.length === 0) {
|
|
19
|
+
return returnSymbol;
|
|
20
|
+
} else {
|
|
21
|
+
const result = values.map((value) => {
|
|
22
|
+
if (value === null || value === void 0) {
|
|
23
|
+
return returnSymbol;
|
|
24
|
+
} else {
|
|
25
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
26
|
+
return value.toString();
|
|
27
|
+
} else {
|
|
28
|
+
return returnSymbol;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const output = result.join(separator.toString());
|
|
33
|
+
return output.trim();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function ConcatenatedFormatter(props) {
|
|
38
|
+
const { values = [], separator = " ", Component = ConcatenatedFormatterRootStyled, color, size = "medium", dataTestid, className } = props;
|
|
39
|
+
const { currentSize } = useComponentSize(size);
|
|
40
|
+
const formatterContatenated = useMemo(
|
|
41
|
+
() => getFormatConcatenated(values, separator),
|
|
42
|
+
[values, separator]
|
|
43
|
+
);
|
|
44
|
+
if (Component === React.Fragment) {
|
|
45
|
+
return /* @__PURE__ */ jsx(Fragment, { children: formatterContatenated });
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
Component,
|
|
49
|
+
{
|
|
50
|
+
color,
|
|
51
|
+
size: currentSize,
|
|
52
|
+
variant: "body",
|
|
53
|
+
className: clsx(getComponentSlotRoot(CONTATENATED_FORMATTER_KEY_COMPONENT), className),
|
|
54
|
+
...getPropDataTestId(CONTATENATED_FORMATTER_KEY_COMPONENT, ConcatenatedFormatterSlots.root, dataTestid),
|
|
55
|
+
children: formatterContatenated
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
ConcatenatedFormatter as C,
|
|
61
|
+
getFormatConcatenated as g
|
|
62
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CONTATENATED_FORMATTER_KEY_COMPONENT = "M4LConcatenatedFormatter";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ConcatenatedFormatterRootStyled: 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').Theme> & Record<string, unknown>, {}, {}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { styled } from "@mui/material";
|
|
2
|
+
import { T as Typography } from "../../../mui_extended/Typography/Typography.js";
|
|
3
|
+
import { c as concatenatedFormatterStyles } from "../ConcatenatedFormatter.styles.js";
|
|
4
|
+
import { C as CONTATENATED_FORMATTER_KEY_COMPONENT } from "../constants.js";
|
|
5
|
+
import { C as ConcatenatedFormatterSlots } from "./ConcatenatedFormatterEnum.js";
|
|
6
|
+
const ConcatenatedFormatterRootStyled = styled(Typography, {
|
|
7
|
+
name: CONTATENATED_FORMATTER_KEY_COMPONENT,
|
|
8
|
+
slot: ConcatenatedFormatterSlots.root
|
|
9
|
+
})(concatenatedFormatterStyles.root);
|
|
10
|
+
export {
|
|
11
|
+
ConcatenatedFormatterRootStyled as C
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { ElementType } from 'react';
|
|
2
|
+
import { Theme } from '@mui/material';
|
|
3
|
+
import { Sizes } from '@m4l/styles';
|
|
4
|
+
import { M4LOverridesStyleRules } from 'src/@types/augmentations';
|
|
5
|
+
import { TypographyProps } from '../../mui_extended/Typography/types';
|
|
6
|
+
import { ConcatenatedFormatterSlots as Slots } from './slots/ConcatenatedFormatterEnum';
|
|
7
|
+
import { CONTATENATED_FORMATTER_KEY_COMPONENT } from './constants';
|
|
2
8
|
/**
|
|
3
9
|
* values: Array de strings a concatenar
|
|
4
10
|
* separator: String usado para concatenar el array de strings
|
|
5
11
|
* Component: Tipo de componente HTML que "abraza" el resultado
|
|
6
12
|
*/
|
|
7
|
-
export interface ConcatenatedFormatterProps {
|
|
13
|
+
export interface ConcatenatedFormatterProps extends Pick<TypographyProps, 'color' | 'dataTestid' | 'className'> {
|
|
14
|
+
/**
|
|
15
|
+
* Valores de información que se usarán para concatenar al texto final.
|
|
16
|
+
*/
|
|
8
17
|
values: Array<string | number>;
|
|
18
|
+
/**
|
|
19
|
+
* Cadena de texto que se usa para dividir los valores de información final.
|
|
20
|
+
*/
|
|
9
21
|
separator?: string | number;
|
|
22
|
+
/**
|
|
23
|
+
* Componente personalizado que puede dar la presentación del formatter
|
|
24
|
+
*/
|
|
10
25
|
Component?: ElementType;
|
|
26
|
+
/**
|
|
27
|
+
* Tamaño del componente.
|
|
28
|
+
*/
|
|
29
|
+
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
11
30
|
}
|
|
31
|
+
export type ConcatenatedFormatterStyles = M4LOverridesStyleRules<keyof typeof Slots, typeof CONTATENATED_FORMATTER_KEY_COMPONENT, Theme>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DateFormatterProps, PresentationType } from './types';
|
|
3
|
+
declare type Maybe<T> = T | undefined | null;
|
|
4
|
+
/**
|
|
5
|
+
* Formatea un valor de fecha en formato UTC, a un formato legible para humanos. Retorna un string
|
|
6
|
+
* @param presentationType Fecha, fecha-hora u hora
|
|
7
|
+
* @param value Valor a convertir
|
|
8
|
+
* @param format Formato
|
|
9
|
+
* @returns string
|
|
10
|
+
* @author cesar - automatic
|
|
11
|
+
* @createdAt 2025-01-15 15:48:39 - automatic
|
|
12
|
+
* @updatedAt 2025-01-15 15:48:39 - automatic
|
|
13
|
+
* @updatedUser cesar - automatic
|
|
14
|
+
*/
|
|
15
|
+
export declare function useFormatDate(presentationType: PresentationType, value: Maybe<Date | string | number>, format?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* DateFormatter
|
|
18
|
+
* A component for formatting date values into various presentation styles such as text or custom wrappers.
|
|
19
|
+
* @param {DateFormatterProps} props - The properties for the component.
|
|
20
|
+
* presentationType - Specifies how the date value should be represented:
|
|
21
|
+
* - `'datetime'`: Displays date and time.
|
|
22
|
+
* - `'date'`: Displays only the date.
|
|
23
|
+
* - `'time'`: Displays only the time.
|
|
24
|
+
* [value=null] - The date value to be formatted.
|
|
25
|
+
* [Component=DateFormatterRootStyled] - A custom wrapper component for the formatted output.
|
|
26
|
+
* [dataTestId] - A unique identifier for testing purposes, used as a `data-testid` attribute.
|
|
27
|
+
* [className] - A custom class name to apply to the component.
|
|
28
|
+
* @example
|
|
29
|
+
* <DateFormatter presentationType="datetime" value={new Date()} />
|
|
30
|
+
* // Renders "2024-12-06 15:57:50"
|
|
31
|
+
* @returns JSX.Element
|
|
32
|
+
* @author cesar
|
|
33
|
+
* @createdAt 2025-01-15 15:48:39 - automatic
|
|
34
|
+
* @updatedAt 2025-01-15 15:48:39 - automatic
|
|
35
|
+
* @updatedUser cesar - automatic
|
|
36
|
+
*/
|
|
37
|
+
export declare function DateFormatter<T extends React.ElementType>(props: DateFormatterProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import { useFormatter } from "@m4l/graphics";
|
|
4
|
+
import { D as DateFormatterRootStyled } from "./slots/DateFormatterSlots.js";
|
|
5
|
+
import { D as DateFormatterSlots } from "./slots/DateFormatterEnum.js";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { a as getComponentSlotRoot } from "../../../utils/getComponentSlotRoot.js";
|
|
8
|
+
import { g as getPropDataTestId } from "../../../test/getNameDataTestId.js";
|
|
9
|
+
import { D as DATE_FORMATTER_KEY_COMPONENT } from "./constants.js";
|
|
10
|
+
function useFormatDate(presentationType, value, format) {
|
|
11
|
+
const { dateFormatter } = useFormatter();
|
|
12
|
+
let finalFormat = format || dateFormatter.datetimeFormat;
|
|
13
|
+
let result;
|
|
14
|
+
let resultDate;
|
|
15
|
+
if (value === void 0 || value === null) {
|
|
16
|
+
return "-";
|
|
17
|
+
}
|
|
18
|
+
switch (presentationType) {
|
|
19
|
+
case "datetime":
|
|
20
|
+
finalFormat = format || dateFormatter.datetimeFormat;
|
|
21
|
+
break;
|
|
22
|
+
case "date":
|
|
23
|
+
finalFormat = format || dateFormatter.dateFormat;
|
|
24
|
+
break;
|
|
25
|
+
case "time":
|
|
26
|
+
finalFormat = format || dateFormatter.timeFormat;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
31
|
+
resultDate = new Date(value);
|
|
32
|
+
} else {
|
|
33
|
+
resultDate = value;
|
|
34
|
+
}
|
|
35
|
+
result = dateFormatter.formatDate(resultDate, finalFormat);
|
|
36
|
+
return result;
|
|
37
|
+
} catch (_e) {
|
|
38
|
+
result = "-";
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function DateFormatter(props) {
|
|
43
|
+
const {
|
|
44
|
+
presentationType,
|
|
45
|
+
value,
|
|
46
|
+
format,
|
|
47
|
+
Component = DateFormatterRootStyled,
|
|
48
|
+
dataTestId,
|
|
49
|
+
className,
|
|
50
|
+
componentProps
|
|
51
|
+
} = props;
|
|
52
|
+
const formattedDate = useFormatDate(presentationType, value, format);
|
|
53
|
+
const memoComponent = useMemo(() => {
|
|
54
|
+
return formattedDate;
|
|
55
|
+
}, [formattedDate]);
|
|
56
|
+
if (Component === React.Fragment) {
|
|
57
|
+
return /* @__PURE__ */ jsx(Fragment, { children: memoComponent });
|
|
58
|
+
}
|
|
59
|
+
return /* @__PURE__ */ jsx(
|
|
60
|
+
Component,
|
|
61
|
+
{
|
|
62
|
+
className: clsx(getComponentSlotRoot(DATE_FORMATTER_KEY_COMPONENT), className),
|
|
63
|
+
...getPropDataTestId(DATE_FORMATTER_KEY_COMPONENT, DateFormatterSlots.root, dataTestId),
|
|
64
|
+
role: "dateFormatter-role",
|
|
65
|
+
...componentProps,
|
|
66
|
+
children: memoComponent
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
DateFormatter as D,
|
|
72
|
+
useFormatDate as u
|
|
73
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const dateFormatterStyles = {
|
|
2
|
+
/**
|
|
3
|
+
* Root style
|
|
4
|
+
* @author cesar - automatic
|
|
5
|
+
* @createdAt 2025-01-15 15:48:39 - automatic
|
|
6
|
+
* @updatedAt 2025-01-15 15:48:39 - automatic
|
|
7
|
+
* @updatedUser cesar - automatic
|
|
8
|
+
*/
|
|
9
|
+
root: () => ({
|
|
10
|
+
display: "flex",
|
|
11
|
+
flexDirection: "column",
|
|
12
|
+
alignItems: "flex-start"
|
|
13
|
+
})
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
dateFormatterStyles as d
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DATE_FORMATTER_KEY_COMPONENT = "M4LDateFormatter";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DateFormatterRootStyled: 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> & Record<string, unknown>, {}, {}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { styled } from "@mui/material/styles";
|
|
2
|
+
import { D as DATE_FORMATTER_KEY_COMPONENT } from "../constants.js";
|
|
3
|
+
import { D as DateFormatterSlots } from "./DateFormatterEnum.js";
|
|
4
|
+
import { d as dateFormatterStyles } from "../DateFormatter.styles.js";
|
|
5
|
+
import { T as Typography } from "../../../mui_extended/Typography/Typography.js";
|
|
6
|
+
const DateFormatterRootStyled = styled(Typography, {
|
|
7
|
+
name: DATE_FORMATTER_KEY_COMPONENT,
|
|
8
|
+
slot: DateFormatterSlots.root
|
|
9
|
+
})(dateFormatterStyles?.root);
|
|
10
|
+
export {
|
|
11
|
+
DateFormatterRootStyled as D
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
import { Maybe } from '@m4l/core';
|
|
2
|
+
import { DateFormatterRootStyled } from './slots/DateFormatterSlots';
|
|
3
|
+
import { DATE_FORMATTER_KEY_COMPONENT } from './constants';
|
|
4
|
+
import { OverridesStyleRules } from '@mui/material/styles/overrides';
|
|
5
|
+
import { Theme } from '@mui/material';
|
|
6
|
+
import { DateFormatterSlots } from './slots/DateFormatterEnum';
|
|
7
|
+
/**
|
|
8
|
+
* Maps to the keys in `DateFormatterSlots`, defining slot-specific styling or customization.
|
|
9
|
+
*/
|
|
10
|
+
export type DateFormatter = keyof typeof DateFormatterSlots;
|
|
11
|
+
/**
|
|
12
|
+
* Defines the presentation type for the DateFormatter component.
|
|
13
|
+
*/
|
|
2
14
|
export type PresentationType = 'date' | 'datetime' | 'time';
|
|
15
|
+
/**
|
|
16
|
+
* Value that can be formatted by the DateFormatter component.
|
|
17
|
+
*/
|
|
3
18
|
export type valueType = Date | string | number;
|
|
4
|
-
export interface DateFormatterProps {
|
|
5
|
-
Component?:
|
|
19
|
+
export interface DateFormatterProps<T extends React.ElementType = typeof DateFormatterRootStyled> {
|
|
20
|
+
Component?: T;
|
|
6
21
|
presentationType: PresentationType;
|
|
7
22
|
format?: string;
|
|
8
23
|
value: Maybe<Date | string | number>;
|
|
24
|
+
dataTestId?: string;
|
|
25
|
+
className?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Props for the custom component.
|
|
28
|
+
*/
|
|
29
|
+
componentProps?: React.ComponentPropsWithoutRef<T>;
|
|
9
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Styles for customizing the `BooleanFormatter` component.
|
|
33
|
+
*
|
|
34
|
+
* This type allows partial overriding of the default styles through Material-UI's `OverridesStyleRules`.
|
|
35
|
+
* It integrates with the Material-UI `Theme` to ensure consistent theming.
|
|
36
|
+
*/
|
|
37
|
+
export type DateFormatterStyles = OverridesStyleRules<DateFormatter, typeof DATE_FORMATTER_KEY_COMPONENT, Theme>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { BooleanFormatter } from './BooleanFormatter/BooleanFormatter';
|
|
2
|
-
export { useFormatDate as getFormatDate, DateFormatter } from './DateFormatter';
|
|
2
|
+
export { useFormatDate as getFormatDate, DateFormatter } from './DateFormatter/DateFormatter';
|
|
3
3
|
export { UncertaintyFormatter, getUncertaintyFormat } from './UncertaintyFormatter';
|
|
4
4
|
export { PointsFormatter, getFormatPoints } from './PointsFormatter/PointsFormatter';
|
|
5
|
-
export { getFormatConcatenated, ConcatenatedFormatter } from './ConcatenatedFormatter';
|
|
5
|
+
export { getFormatConcatenated, ConcatenatedFormatter } from './ConcatenatedFormatter/ConcatenatedFormatter';
|
|
6
6
|
export { useFormatPeriod, PeriodFormatter } from './PeriodFormatter/PeriodFormatter';
|
|
7
7
|
export { PriceFormatter, getFormatPrice } from './PriceFormatter';
|
|
8
8
|
export * from './DistanceToNowFormatter';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { g as getHeightSizeStyles } from "../../../utils/getHeightSizeStyles.js";
|
|
1
2
|
import { g as getTypographyStyles } from "../../../utils/getTypographyStyles.js";
|
|
2
3
|
const typographyStyles = {
|
|
3
4
|
/**
|
|
@@ -5,8 +6,8 @@ const typographyStyles = {
|
|
|
5
6
|
* Componente extendido de MUI Typography, que permite personalizar los estilos del componente.
|
|
6
7
|
* @author Bruce Escobar - automatic
|
|
7
8
|
* @createdAt 2024-10-22 09:41:31 - automatic
|
|
8
|
-
* @updatedAt 2025-01-
|
|
9
|
-
* @updatedUser
|
|
9
|
+
* @updatedAt 2025-01-20 10:20:09 - automatic
|
|
10
|
+
* @updatedUser cesar - automatic
|
|
10
11
|
*/
|
|
11
12
|
root: ({ ownerState, theme }) => ({
|
|
12
13
|
cursor: "default",
|
|
@@ -38,7 +39,20 @@ const typographyStyles = {
|
|
|
38
39
|
)
|
|
39
40
|
}
|
|
40
41
|
}),
|
|
41
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Slot: skeleton
|
|
44
|
+
* @author cesar - automatic
|
|
45
|
+
* @createdAt 2025-01-20 09:47:08 - automatic
|
|
46
|
+
* @updatedAt 2025-01-20 10:20:09 - automatic
|
|
47
|
+
* @updatedUser cesar - automatic
|
|
48
|
+
*/
|
|
49
|
+
skeleton: ({ theme, ownerState }) => ({
|
|
50
|
+
...getHeightSizeStyles(
|
|
51
|
+
theme.generalSettings.isMobile,
|
|
52
|
+
ownerState.size || "medium",
|
|
53
|
+
"base"
|
|
54
|
+
)
|
|
55
|
+
})
|
|
42
56
|
};
|
|
43
57
|
export {
|
|
44
58
|
typographyStyles as t
|
package/index.js
CHANGED
|
@@ -42,10 +42,10 @@ import { R as R11 } from "./components/hook-form/RHFTextField/RHFTextField.js";
|
|
|
42
42
|
import { R as R12 } from "./components/hook-form/RHFTextFieldPassword/RHFTextFieldPassword.js";
|
|
43
43
|
import { R as R13 } from "./components/hook-form/RHFUpload/RHFUploadImage/RHFUploadImage.js";
|
|
44
44
|
import { B } from "./components/formatters/BooleanFormatter/BooleanFormatter.js";
|
|
45
|
-
import { D as D2, u as u4 } from "./components/formatters/DateFormatter/
|
|
45
|
+
import { D as D2, u as u4 } from "./components/formatters/DateFormatter/DateFormatter.js";
|
|
46
46
|
import { U, g as g7 } from "./components/formatters/UncertaintyFormatter/index.js";
|
|
47
47
|
import { P as P2, g as g8 } from "./components/formatters/PointsFormatter/PointsFormatter.js";
|
|
48
|
-
import { C, g as g9 } from "./components/formatters/ConcatenatedFormatter/
|
|
48
|
+
import { C, g as g9 } from "./components/formatters/ConcatenatedFormatter/ConcatenatedFormatter.js";
|
|
49
49
|
import { P as P3, u as u5 } from "./components/formatters/PeriodFormatter/PeriodFormatter.js";
|
|
50
50
|
import { P as P4, g as g10 } from "./components/formatters/PriceFormatter/index.js";
|
|
51
51
|
import { g as g11 } from "./components/formatters/DistanceToNowFormatter/dictionary.js";
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ConcatenatedFormatterProps } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Concatena un arrays de strings y/o numbers. Retorna un string
|
|
4
|
-
* @param values Array de strings o numnbers a concatenar
|
|
5
|
-
* @param separator String utilizado como separador entre componentes del array
|
|
6
|
-
* @returns string
|
|
7
|
-
*/
|
|
8
|
-
export declare function getFormatConcatenated(values: Array<string | number>, separator: string | number): string;
|
|
9
|
-
/**
|
|
10
|
-
* Concatena un arrays de strings y/o numbers. Retorna un JSX
|
|
11
|
-
* @param props {values: Array<string> Valores a concatenar, separator: string Separador entre valores concatenados, Component: ElementType Componente que abraza la respuesta}
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
export declare function ConcatenatedFormatter(props: ConcatenatedFormatterProps): JSX.Element;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { W as WrapperComponent } from "../../WrapperComponent/index.js";
|
|
3
|
-
function getFormatConcatenated(values, separator) {
|
|
4
|
-
const returnSymbol = "";
|
|
5
|
-
if (values === null) {
|
|
6
|
-
return returnSymbol;
|
|
7
|
-
}
|
|
8
|
-
if (!Array.isArray(values)) {
|
|
9
|
-
return values.toString();
|
|
10
|
-
} else {
|
|
11
|
-
if (values.length === 0) {
|
|
12
|
-
return returnSymbol;
|
|
13
|
-
} else {
|
|
14
|
-
const result = values.map((value) => {
|
|
15
|
-
if (value === null || value === void 0) {
|
|
16
|
-
return returnSymbol;
|
|
17
|
-
} else {
|
|
18
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
19
|
-
return value.toString();
|
|
20
|
-
} else {
|
|
21
|
-
return returnSymbol;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const output = result.join(separator.toString());
|
|
26
|
-
return output.trim();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function ConcatenatedFormatter(props) {
|
|
31
|
-
const { values = [], separator = " ", Component = WrapperComponent } = props;
|
|
32
|
-
return /* @__PURE__ */ jsx(Component, { children: getFormatConcatenated(values, separator) });
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
ConcatenatedFormatter as C,
|
|
36
|
-
getFormatConcatenated as g
|
|
37
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DateFormatterProps, PresentationType } from './types';
|
|
2
|
-
declare type Maybe<T> = T | undefined | null;
|
|
3
|
-
/**
|
|
4
|
-
* Formatea un valor de fecha en formato UTC, a un formato legible para humanos. Retorna un string
|
|
5
|
-
* @param presentationType Fecha, fecha-hora u hora
|
|
6
|
-
* @param value Valor a convertir
|
|
7
|
-
* @param format Formato
|
|
8
|
-
* @returns string
|
|
9
|
-
*/
|
|
10
|
-
export declare function useFormatDate(presentationType: PresentationType, value: Maybe<Date | string | number>, format?: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Formatea un valor de fecha en formato UTC, a un formato legible para humanos. Retorna un JSX
|
|
13
|
-
* @param props DateFormatterProps
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
export declare function DateFormatter(props: DateFormatterProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useFormatter } from "@m4l/graphics";
|
|
3
|
-
import { W as WrapperComponent } from "../../WrapperComponent/index.js";
|
|
4
|
-
function useFormatDate(presentationType, value, format) {
|
|
5
|
-
const { dateFormatter } = useFormatter();
|
|
6
|
-
let finalFormat = format || dateFormatter.datetimeFormat;
|
|
7
|
-
let result;
|
|
8
|
-
let resultDate;
|
|
9
|
-
if (value === void 0 || value === null) {
|
|
10
|
-
return "-";
|
|
11
|
-
}
|
|
12
|
-
switch (presentationType) {
|
|
13
|
-
case "datetime":
|
|
14
|
-
finalFormat = format || dateFormatter.datetimeFormat;
|
|
15
|
-
break;
|
|
16
|
-
case "date":
|
|
17
|
-
finalFormat = format || dateFormatter.dateFormat;
|
|
18
|
-
break;
|
|
19
|
-
case "time":
|
|
20
|
-
finalFormat = format || dateFormatter.timeFormat;
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
if (typeof value === "number" || typeof value === "string") {
|
|
25
|
-
resultDate = new Date(value);
|
|
26
|
-
} else {
|
|
27
|
-
resultDate = value;
|
|
28
|
-
}
|
|
29
|
-
result = dateFormatter.formatDate(resultDate, finalFormat);
|
|
30
|
-
return result;
|
|
31
|
-
} catch (_e) {
|
|
32
|
-
result = "-";
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function DateFormatter(props) {
|
|
37
|
-
const { presentationType, value, format, Component = WrapperComponent } = props;
|
|
38
|
-
return /* @__PURE__ */ jsx(Component, { children: useFormatDate(presentationType, value, format) });
|
|
39
|
-
}
|
|
40
|
-
export {
|
|
41
|
-
DateFormatter as D,
|
|
42
|
-
useFormatDate as u
|
|
43
|
-
};
|