@m4l/components 9.1.58 → 9.1.59

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.
@@ -7,7 +7,7 @@ import { PaperFormProps } from './types';
7
7
  * **********************************************************************
8
8
  * @author Andrés Quintero - automatic
9
9
  * @createdAt 2024-11-20 14:00:24 - automatic
10
- * @updatedAt 2024-11-22 11:15:45 - automatic
11
- * @updatedUser Andrés Quintero - automatic
10
+ * @updatedAt 2025-01-08 15:43:10 - automatic
11
+ * @updatedUser cesar - automatic
12
12
  */
13
13
  export declare function PaperForm(props: PaperFormProps): import("react/jsx-runtime").JSX.Element;
@@ -4,14 +4,42 @@ import { P as PaperFormRootStyled, C as ContentStyled } from "./slots/PaperFormS
4
4
  import { useRef } from "react";
5
5
  import { a as getComponentSlotRoot } from "../../utils/getComponentSlotRoot.js";
6
6
  import { P as PAPER_FORM_KEY } from "./constants.js";
7
+ import { P as PropertyValue } from "../PropertyValue/PropertyValue.js";
8
+ const isPropertyValue = (child) => typeof child === "object" && child !== null && "property" in child && "value" in child;
9
+ const renderChildren = (children) => {
10
+ if (Array.isArray(children)) {
11
+ return children.map(
12
+ (child) => isPropertyValue(child) ? /* @__PURE__ */ jsx(PropertyValue, { ...child }, child.property) : child
13
+ );
14
+ }
15
+ return children;
16
+ };
7
17
  function PaperForm(props) {
8
- const { urlIcon, title, children, dataTestId, color = "default", size } = props;
18
+ const {
19
+ urlIcon,
20
+ title,
21
+ children,
22
+ dataTestId,
23
+ color = "default",
24
+ size = "medium",
25
+ isForm = false,
26
+ variant = "standard"
27
+ } = props;
9
28
  const paperFormRef = useRef(null);
10
29
  const rootClass = getComponentSlotRoot(PAPER_FORM_KEY);
11
- return /* @__PURE__ */ jsxs(PaperFormRootStyled, { className: rootClass, ref: paperFormRef, ownerState: {}, ...process.env.NODE_ENV !== "production" ? { "data-testid": dataTestId } : {}, children: [
12
- /* @__PURE__ */ jsx(Header, { urlIcon, title, color, size }),
13
- /* @__PURE__ */ jsx(ContentStyled, { ownerState: {}, children })
14
- ] });
30
+ return /* @__PURE__ */ jsxs(
31
+ PaperFormRootStyled,
32
+ {
33
+ className: rootClass,
34
+ ref: paperFormRef,
35
+ ownerState: { isForm, color, variant },
36
+ ...process.env.NODE_ENV !== "production" ? { "data-testid": dataTestId } : {},
37
+ children: [
38
+ /* @__PURE__ */ jsx(Header, { urlIcon, title, color, size }),
39
+ /* @__PURE__ */ jsx(ContentStyled, { ownerState: { isForm }, children: renderChildren(children) })
40
+ ]
41
+ }
42
+ );
15
43
  }
16
44
  export {
17
45
  PaperForm as P
@@ -6,8 +6,8 @@ const paperFormStyles = {
6
6
  ***********************************************************
7
7
  * @author Andrés Quintero - automatic
8
8
  * @createdAt 2024-11-20 14:00:24 - automatic
9
- * @updatedAt 2024-11-22 10:38:00 - automatic
10
- * @updatedUser Andrés Quintero - automatic
9
+ * @updatedAt 2025-01-08 10:46:48 - automatic
10
+ * @updatedUser cesar - automatic
11
11
  */
12
12
  paperFormRoot: ({ theme }) => ({
13
13
  borderRadius: theme.size.borderRadius.r1,
@@ -25,8 +25,8 @@ const paperFormStyles = {
25
25
  ***********************************************************
26
26
  * @author Andrés Quintero - automatic
27
27
  * @createdAt 2024-11-20 14:00:24 - automatic
28
- * @updatedAt 2024-11-22 10:38:00 - automatic
29
- * @updatedUser Andrés Quintero - automatic
28
+ * @updatedAt 2025-01-08 10:46:48 - automatic
29
+ * @updatedUser cesar - automatic
30
30
  */
31
31
  containerHeader: ({ theme, ownerState }) => ({
32
32
  display: "flex",
@@ -46,8 +46,8 @@ const paperFormStyles = {
46
46
  ***********************************************************
47
47
  * @author Andrés Quintero - automatic
48
48
  * @createdAt 2024-11-20 14:00:24 - automatic
49
- * @updatedAt 2024-11-22 10:38:00 - automatic
50
- * @updatedUser Andrés Quintero - automatic
49
+ * @updatedAt 2025-01-08 10:46:48 - automatic
50
+ * @updatedUser cesar - automatic
51
51
  */
52
52
  containerTitle: ({ theme }) => ({
53
53
  color: theme.vars.palette.text.primary,
@@ -65,8 +65,8 @@ const paperFormStyles = {
65
65
  ***********************************************************
66
66
  * @author Andrés Quintero - automatic
67
67
  * @createdAt 2024-11-20 14:00:24 - automatic
68
- * @updatedAt 2024-11-22 10:38:00 - automatic
69
- * @updatedUser Andrés Quintero - automatic
68
+ * @updatedAt 2025-01-08 10:46:48 - automatic
69
+ * @updatedUser cesar - automatic
70
70
  */
71
71
  containerIcon: () => ({
72
72
  display: "grid",
@@ -79,17 +79,18 @@ const paperFormStyles = {
79
79
  ***********************************************************
80
80
  * @author Andrés Quintero - automatic
81
81
  * @createdAt 2024-11-20 14:00:24 - automatic
82
- * @updatedAt 2024-11-22 10:38:00 - automatic
83
- * @updatedUser Andrés Quintero - automatic
82
+ * @updatedAt 2025-01-08 10:46:48 - automatic
83
+ * @updatedUser cesar - automatic
84
84
  */
85
85
  containerContent: ({ theme, ownerState }) => ({
86
86
  width: "100%",
87
87
  height: "auto",
88
88
  display: "flex",
89
- flexDirection: "column",
90
- alignItems: "center",
91
- justifyContent: "center",
92
- gap: ownerState.isForm ? theme.vars.size.baseSpacings.sp2 : theme.vars.size.baseSpacings.sp0,
89
+ flexDirection: ownerState.isForm ? "row" : "column",
90
+ alignItems: ownerState.isForm ? "flex-start" : "center",
91
+ justifyContent: ownerState.isForm ? "flex-start" : "center",
92
+ gap: ownerState.isForm ? theme.vars.size.baseSpacings.sp3 : theme.vars.size.baseSpacings.sp0,
93
+ flexWrap: ownerState.isForm ? "wrap" : "nowrap",
93
94
  padding: theme.vars.size.baseSpacings.sp3,
94
95
  background: theme.vars.palette.background.default
95
96
  })
@@ -4,10 +4,11 @@ import { OverridesStyleRules } from '@mui/material/styles/overrides';
4
4
  import { PAPER_FORM_KEY } from './constants';
5
5
  import { Theme } from '@mui/material/styles';
6
6
  import { ComponentPalletColor, Sizes } from '@m4l/styles';
7
+ import { PropertyValueProps } from '../PropertyValue/types';
7
8
  export interface PaperFormProps {
8
9
  urlIcon?: string;
9
10
  title: string;
10
- children: ReactNode;
11
+ children?: ReactNode | PropertyValueProps[];
11
12
  variant?: 'standard';
12
13
  color?: Extract<ComponentPalletColor, 'default'>;
13
14
  size?: Extract<Sizes, 'small' | 'medium'>;
@@ -3,7 +3,7 @@ import { PropertyValueProps } from './types';
3
3
  * PropertyValue component is used to display a property and its value in a form or not.
4
4
  * @author cesar - automatic
5
5
  * @createdAt 2024-12-19 14:44:17 - automatic
6
- * @updatedAt 2024-12-30 09:30:27 - automatic
6
+ * @updatedAt 2025-01-08 11:15:49 - automatic
7
7
  * @updatedUser cesar - automatic
8
8
  */
9
9
  export declare function PropertyValue(props: PropertyValueProps): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,9 @@ import { T as TEST_PROPS_DATA, P as PROPERTY_VALUE_KEY_COMPONENT, C as COMPONENT
5
5
  import { a as getPropDataTestId, g as getNameDataTestId } from "../../test/getNameDataTestId.js";
6
6
  import { P as PropertyValueRootStyled, a as PropertyStyled, V as ValueStyled } from "./slots/PropertyValueSlots.js";
7
7
  import { a as getComponentSlotRoot } from "../../utils/getComponentSlotRoot.js";
8
+ import { u as useComponentSize } from "../../hooks/useComponentSize/useComponentSize.js";
8
9
  import { L as Label } from "../Label/Label.js";
10
+ import { T as TextField } from "../mui_extended/TextField/TextField.js";
9
11
  import { T as Typography } from "../mui_extended/Typography/Typography.js";
10
12
  import { I as Icon } from "../Icon/Icon.js";
11
13
  function PropertyValue(props) {
@@ -20,8 +22,11 @@ function PropertyValue(props) {
20
22
  mandatory,
21
23
  mandatoryMessage,
22
24
  helperMessage,
23
- semanticWidth = "fullWidth"
25
+ semanticWidth = "fullWidth",
26
+ size = "medium"
24
27
  } = props;
28
+ const { currentSize } = useComponentSize(size);
29
+ const normalizedSize = currentSize === "large" ? "medium" : currentSize;
25
30
  const ownerState = {
26
31
  disabled: isForm && disabled ? disabled : false,
27
32
  isForm: isForm ? true : false,
@@ -42,8 +47,23 @@ function PropertyValue(props) {
42
47
  return startAdornment;
43
48
  };
44
49
  const renderValue = () => {
50
+ if (isForm) {
51
+ if (typeof value === "string" || typeof value === "number") {
52
+ return /* @__PURE__ */ jsx(
53
+ TextField,
54
+ {
55
+ size: normalizedSize,
56
+ defaultValue: value,
57
+ disabled,
58
+ helperText: helperMessage,
59
+ fullWidth: true
60
+ }
61
+ );
62
+ }
63
+ return value;
64
+ }
45
65
  if (typeof value === "string") {
46
- return /* @__PURE__ */ jsx(Typography, { variant: "bodyDens", children: value });
66
+ return /* @__PURE__ */ jsx(Typography, { size: normalizedSize, variant: "bodyDens", children: value });
47
67
  }
48
68
  return value;
49
69
  };
@@ -64,6 +84,7 @@ function PropertyValue(props) {
64
84
  /* @__PURE__ */ jsx(
65
85
  Label,
66
86
  {
87
+ size: normalizedSize,
67
88
  label: property,
68
89
  mandatory,
69
90
  mandatoryMessage,
@@ -71,14 +92,7 @@ function PropertyValue(props) {
71
92
  }
72
93
  )
73
94
  ] }),
74
- /* @__PURE__ */ jsx(
75
- ValueStyled,
76
- {
77
- role: "property-value-value-role",
78
- ownerState,
79
- children: renderValue()
80
- }
81
- )
95
+ /* @__PURE__ */ jsx(ValueStyled, { role: "property-value-value-role", ownerState, children: renderValue() })
82
96
  ]
83
97
  }
84
98
  );
@@ -4,6 +4,7 @@ import { PROPERTY_VALUE_KEY_COMPONENT } from './constants';
4
4
  import { Theme } from '@mui/material';
5
5
  import { OverridesStyleRules } from '@mui/material/styles/overrides';
6
6
  import { PropertyValueSlots } from './slots/PropertyValueEnum';
7
+ import { Sizes } from '@m4l/styles';
7
8
  /**
8
9
  * Tipos de valores posibles para los componentes dentro de `PropertyValue`.
9
10
  */
@@ -77,6 +78,10 @@ export interface PropertyValueProps extends PropertyProps, ValueProps, Omit<Labe
77
78
  * Define el ancho semántico del componente según el contenido.
78
79
  */
79
80
  semanticWidth?: SemanticWidthOptions;
81
+ /**
82
+ * Propiedad de tamaño para el componente `PropertyValue`.
83
+ */
84
+ size?: Extract<Sizes, 'small' | 'medium'>;
80
85
  }
81
86
  /**
82
87
  * Estado del propietario para el componente `PropertyValue`, utilizado para personalizar estilos y comportamientos.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "9.1.58",
3
+ "version": "9.1.59",
4
4
  "license": "UNLICENSED",
5
5
  "lint-staged": {
6
6
  "*.{js,ts,tsx}": "eslint --fix --max-warnings 0"