@m4l/layouts 9.3.8 → 9.3.9-BE28072025-beta.1

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,12 +1,12 @@
1
1
  import { PropertyValueProps, RHFTextFieldProps } from '@m4l/components';
2
2
  interface PropertyValueFieldBase extends Pick<PropertyValueProps, 'semanticWidth'> {
3
3
  name: string;
4
- type: 'RHFTexfField' | 'component';
4
+ type: 'RHFTextField' | 'component';
5
5
  label: string;
6
6
  mandatory?: boolean;
7
7
  }
8
- interface PropertyValueRHFTexfField extends PropertyValueFieldBase, Pick<RHFTextFieldProps, 'multiline' | 'rows'> {
9
- type: 'RHFTexfField';
8
+ interface PropertyValueRHFTextField extends PropertyValueFieldBase, Pick<RHFTextFieldProps, 'multiline' | 'rows'> {
9
+ type: 'RHFTextField';
10
10
  readOnly?: boolean;
11
11
  disabled?: boolean;
12
12
  textFieldType?: React.InputHTMLAttributes<unknown>['type'];
@@ -16,7 +16,7 @@ export interface PropertyValueOtherComponent<T extends React.ComponentType<any>>
16
16
  component: T;
17
17
  componentProps: React.ComponentProps<T>;
18
18
  }
19
- export type PropertyValueField = PropertyValueRHFTexfField | PropertyValueOtherComponent<any>;
19
+ export type PropertyValueField = PropertyValueRHFTextField | PropertyValueOtherComponent<any>;
20
20
  export type UseDynamicPaperFormProps = {
21
21
  fields: PropertyValueField[];
22
22
  title: string;
@@ -15,7 +15,7 @@ function useDynamicPaperForm(props) {
15
15
  isForm,
16
16
  children: fields.map((field) => {
17
17
  let component;
18
- if (field.type === "RHFTexfField") {
18
+ if (field.type === "RHFTextField") {
19
19
  component = /* @__PURE__ */ jsx(
20
20
  RHFTextField,
21
21
  {
@@ -1,5 +1,12 @@
1
1
  import { NetworkProps } from '@m4l/core';
2
- export interface UseNetworkConfirmActionProps<T> {
2
+ export type NetworkConfirmResponse = {
3
+ message: string;
4
+ };
5
+ export type ToastConfig = {
6
+ title: string;
7
+ description?: string;
8
+ };
9
+ export interface UseNetworkActionConfirmProps<T, K extends NetworkConfirmResponse = NetworkConfirmResponse> {
3
10
  /**
4
11
  * Función para refrescar la lista
5
12
  */
@@ -11,9 +18,13 @@ export interface UseNetworkConfirmActionProps<T> {
11
18
  /**
12
19
  * Título del modal
13
20
  */
14
- title: string;
21
+ title: string | ((obj: T) => string);
15
22
  /**
16
23
  * Mensaje del modal
17
24
  */
18
- message: string;
25
+ message: string | ((obj: T) => string);
26
+ /**
27
+ * Configuración personalizada de la notificación de toast success, si retorna undefined o null no se muestra la notificación
28
+ */
29
+ customToastConfig?: (obj: T, response: K) => ToastConfig | undefined | null;
19
30
  }
@@ -1,7 +1,7 @@
1
- import { UseNetworkConfirmActionProps } from './types';
1
+ import { NetworkConfirmResponse, UseNetworkActionConfirmProps } from './types';
2
2
  /**
3
3
  * Obtiene las acciones de fila
4
4
  */
5
- export declare function useNetworkActionConfirm<T>(props: UseNetworkConfirmActionProps<T>): {
5
+ export declare function useNetworkActionConfirm<T, K extends NetworkConfirmResponse = NetworkConfirmResponse>(props: UseNetworkActionConfirmProps<T, K>): {
6
6
  onAction: (obj: T) => void;
7
7
  };
@@ -3,7 +3,7 @@ import { useModal, useWindowToolsMF, WindowConfirm } from "@m4l/components";
3
3
  import { useNetwork, useHostTools } from "@m4l/core";
4
4
  import { useCallback } from "react";
5
5
  function useNetworkActionConfirm(props) {
6
- const { fullRefresh, getEndPoint, title, message } = props;
6
+ const { fullRefresh, getEndPoint, title, message, customToastConfig } = props;
7
7
  const { networkOperation } = useNetwork();
8
8
  const { toast } = useHostTools();
9
9
  const { openModal, closeModal } = useModal();
@@ -16,22 +16,29 @@ function useNetworkActionConfirm(props) {
16
16
  },
17
17
  ...getEndPoint(obj)
18
18
  }).then((response) => {
19
- toast({ title: `${response.message}` }, { type: "success" });
19
+ if (customToastConfig) {
20
+ const toastConfig = customToastConfig(obj, response);
21
+ if (toastConfig) {
22
+ toast(toastConfig, { type: "success" });
23
+ }
24
+ } else {
25
+ toast({ title: `${response.message}` }, { type: "success" });
26
+ }
20
27
  }).catch((response) => {
21
28
  toast({ title: `${response.message}` }, { type: "error" });
22
29
  }).finally(() => {
23
30
  fullRefresh(obj);
24
31
  });
25
32
  closeModal();
26
- }, [closeModal, fullRefresh, networkOperation, toast, startProgress, stopProgress, getEndPoint]);
33
+ }, [networkOperation, startProgress, stopProgress, getEndPoint, closeModal, customToastConfig, toast, fullRefresh]);
27
34
  const onAction = useCallback(
28
35
  (obj) => {
29
36
  openModal({
30
37
  window: /* @__PURE__ */ jsx(
31
38
  WindowConfirm,
32
39
  {
33
- title,
34
- msg: message,
40
+ title: typeof title === "function" ? title(obj) : title,
41
+ msg: typeof message === "function" ? message(obj) : message,
35
42
  onClickIntro: () => onConfirm(obj)
36
43
  }
37
44
  ),
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@m4l/layouts",
3
- "version": "9.3.8",
3
+ "version": "9.3.9-BE28072025-beta.1",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team",
6
6
  "lint-staged": {
7
7
  "*.{js,ts,tsx}": "eslint --fix --max-warnings 0"
8
8
  },
9
9
  "peerDependencies": {
10
- "@m4l/components": "^9.0.0",
10
+ "@m4l/components": "9.3.1-BE28072025-beta.1",
11
11
  "@m4l/core": "^2.0.0",
12
- "@m4l/graphics": "^7.0.0",
13
- "@m4l/styles": "^7.0.0"
12
+ "@m4l/graphics": "7.1.3-BE28072025-beta.1",
13
+ "@m4l/styles": "7.1.31-BE28072025-beta.1"
14
14
  },
15
15
  "resolutions": {
16
16
  "glob": "^10.4.5",