@m4l/layouts 9.1.15 → 9.2.0-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.
- package/components/DynamicTabs/DynamicTabs.d.ts +5 -0
- package/components/DynamicTabs/DynamicTabs.js +39 -0
- package/components/DynamicTabs/index.d.ts +2 -0
- package/components/DynamicTabs/index.js +1 -0
- package/components/DynamicTabs/types.d.ts +31 -0
- package/components/DynamicTabs/useDynamicTabs.d.ts +9 -0
- package/components/DynamicTabs/useDynamicTabs.js +23 -0
- package/components/index.d.ts +1 -0
- package/constants.d.ts +4 -0
- package/constants.js +33 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/useDynamicAccordions/types.d.ts +20 -19
- package/hooks/useDynamicAccordions/useBaseAccordions.d.ts +1 -1
- package/hooks/useDynamicAccordions/useBaseAccordions.js +11 -7
- package/hooks/useNetworkActionConfirm/index.d.ts +1 -0
- package/hooks/useNetworkActionConfirm/index.js +1 -0
- package/hooks/useNetworkActionConfirm/types.d.ts +19 -0
- package/hooks/useNetworkActionConfirm/useNetworkActionConfirm.d.ts +7 -0
- package/hooks/useNetworkActionConfirm/useNetworkActionConfirm.js +49 -0
- package/index.d.ts +1 -0
- package/index.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Stack, Tabs, Tab, TabContent } from "@m4l/components";
|
|
3
|
+
import { u as useDynamicTabs } from "./useDynamicTabs.js";
|
|
4
|
+
function DynamicTabs(props) {
|
|
5
|
+
const { currentTab, finalTabs, handleChangeTab } = useDynamicTabs(props);
|
|
6
|
+
return (
|
|
7
|
+
//Bruce, que no se tenga que usar este style, como podemos lograr esto?
|
|
8
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "column", style: { flexGrow: 1, overflow: "hidden" }, children: [
|
|
9
|
+
/* @__PURE__ */ jsx(
|
|
10
|
+
Tabs,
|
|
11
|
+
{
|
|
12
|
+
value: currentTab,
|
|
13
|
+
scrollButtons: "auto",
|
|
14
|
+
variant: "scrollable",
|
|
15
|
+
allowScrollButtonsMobile: true,
|
|
16
|
+
onChange: (_e, value) => handleChangeTab(value),
|
|
17
|
+
children: finalTabs.map((tab) => {
|
|
18
|
+
const { value, tabProps } = tab;
|
|
19
|
+
return /* @__PURE__ */ jsx(Tab, { value, label: tabProps?.label }, value);
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
),
|
|
23
|
+
finalTabs.map((tab) => {
|
|
24
|
+
const isMatched = tab.value === currentTab;
|
|
25
|
+
return (isMatched || !tab.unmountable) && /* @__PURE__ */ jsx(
|
|
26
|
+
TabContent,
|
|
27
|
+
{
|
|
28
|
+
style: { display: isMatched ? "flex" : "none" },
|
|
29
|
+
children: tab.tabContent
|
|
30
|
+
},
|
|
31
|
+
tab.value
|
|
32
|
+
);
|
|
33
|
+
})
|
|
34
|
+
] })
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
DynamicTabs as D
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TabProps } from '@m4l/components';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
export interface DynamicTab {
|
|
4
|
+
/**
|
|
5
|
+
* "unmountable" Indica si el tab se desmonta cuando el tab no está seleccionado, default: true
|
|
6
|
+
*/
|
|
7
|
+
unmountable?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* "value" Valor o key del tab
|
|
10
|
+
*/
|
|
11
|
+
value: string;
|
|
12
|
+
/**
|
|
13
|
+
* "tabContent" Contenido del tab, debe ser un componente que acepte como mínimo
|
|
14
|
+
* la prop "data" (DetailComponentProps) que será inyectada automáticamente
|
|
15
|
+
*/
|
|
16
|
+
tabContent: React.ReactNode; /**Elemento no instanciado de react, solamente la funcion */
|
|
17
|
+
/**
|
|
18
|
+
* tabProps: Propiedades del componente del tab.
|
|
19
|
+
*/
|
|
20
|
+
tabProps?: TabProps;
|
|
21
|
+
}
|
|
22
|
+
export interface DynamicTabsProps {
|
|
23
|
+
/**
|
|
24
|
+
* "defaultTab" Valor o key del tab por defecto, default: el primer tab
|
|
25
|
+
*/
|
|
26
|
+
defaultTab: string;
|
|
27
|
+
/**
|
|
28
|
+
* "tabs" Lista de tabs con los siguientes campos:
|
|
29
|
+
*/
|
|
30
|
+
tabs: DynamicTab[];
|
|
31
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DynamicTab, DynamicTabsProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Componente para mostrar un listado de tabs y contenido en un MasterDetail, basado en las props
|
|
4
|
+
*/
|
|
5
|
+
export declare function useDynamicTabs(props: DynamicTabsProps): {
|
|
6
|
+
currentTab: string;
|
|
7
|
+
finalTabs: DynamicTab[];
|
|
8
|
+
handleChangeTab: (newValue: string) => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useState, useMemo } from "react";
|
|
2
|
+
function useDynamicTabs(props) {
|
|
3
|
+
const { tabs, defaultTab } = props;
|
|
4
|
+
const [currentTab, setCurrentTab] = useState(defaultTab);
|
|
5
|
+
const handleChangeTab = (newValue) => {
|
|
6
|
+
setCurrentTab(newValue);
|
|
7
|
+
};
|
|
8
|
+
const finalTabs = useMemo(() => {
|
|
9
|
+
const arrTabs = [...tabs];
|
|
10
|
+
return arrTabs.map((tab) => ({
|
|
11
|
+
...tab,
|
|
12
|
+
unmountable: tab.unmountable === void 0 ? true : tab.unmountable
|
|
13
|
+
}));
|
|
14
|
+
}, [tabs]);
|
|
15
|
+
return {
|
|
16
|
+
currentTab,
|
|
17
|
+
finalTabs,
|
|
18
|
+
handleChangeTab
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
useDynamicTabs as u
|
|
23
|
+
};
|
package/components/index.d.ts
CHANGED
package/constants.d.ts
ADDED
package/constants.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const LIMIT_RECORDS_500_CONFIG = [
|
|
2
|
+
{
|
|
3
|
+
limit: 1,
|
|
4
|
+
label: "1"
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
limit: 5,
|
|
8
|
+
label: "5"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
limit: 10,
|
|
12
|
+
label: "10"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
limit: 20,
|
|
16
|
+
label: "20"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
limit: 50,
|
|
20
|
+
label: "50"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
limit: 100,
|
|
24
|
+
label: "100"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
limit: 500,
|
|
28
|
+
label: "500"
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
export {
|
|
32
|
+
LIMIT_RECORDS_500_CONFIG as L
|
|
33
|
+
};
|
package/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
import { AccordionProps } from '@m4l/components';
|
|
1
|
+
import { AccordionProps, PropertyValueProps } from '@m4l/components';
|
|
2
2
|
import { ModuleDetailTabContent } from '../../components/ModuleDetailTabs';
|
|
3
3
|
export type DynamicAccordionValue<T extends any = any, K extends any = any> = (data: T, endPointData?: K) => string | React.ReactNode;
|
|
4
|
+
export interface DynamicAccordionProperty<T extends any = any, K extends any = any> extends Omit<PropertyValueProps, 'value' | 'property'> {
|
|
5
|
+
/**
|
|
6
|
+
* "dictionaryId": Id de la propiedad en el diccionario para mostrar en el label
|
|
7
|
+
*/
|
|
8
|
+
dictionaryId: string;
|
|
9
|
+
/**
|
|
10
|
+
* "getValue": Función que se encarga de obtener el valor de la propiedad
|
|
11
|
+
*/
|
|
12
|
+
getValue: DynamicAccordionValue<T, K>;
|
|
13
|
+
/**
|
|
14
|
+
* "privilegeToView": Si se requiere un privilegio para ver el valor
|
|
15
|
+
*/
|
|
16
|
+
privilegeToView?: string;
|
|
17
|
+
/**
|
|
18
|
+
* isForm
|
|
19
|
+
*/
|
|
20
|
+
isForm?: boolean;
|
|
21
|
+
}
|
|
4
22
|
export interface ConfigDynamicAccordion<T extends any = any, K extends any = any> {
|
|
5
23
|
/**
|
|
6
24
|
* "icon": Icono de la propiedad
|
|
@@ -17,24 +35,7 @@ export interface ConfigDynamicAccordion<T extends any = any, K extends any = any
|
|
|
17
35
|
/**
|
|
18
36
|
* "properties": Propiedades que se ven en el accordion
|
|
19
37
|
*/
|
|
20
|
-
properties:
|
|
21
|
-
/**
|
|
22
|
-
* "icon": Icono de la propiedad
|
|
23
|
-
*/
|
|
24
|
-
icon?: string | React.ReactNode;
|
|
25
|
-
/**
|
|
26
|
-
* "dictionaryId": Id de la propiedad en el diccionario para mostrar en el label
|
|
27
|
-
*/
|
|
28
|
-
dictionaryId: string;
|
|
29
|
-
/**
|
|
30
|
-
* "getValue": Función que se encarga de obtener el valor de la propiedad
|
|
31
|
-
*/
|
|
32
|
-
getValue: DynamicAccordionValue<T, K>;
|
|
33
|
-
/**
|
|
34
|
-
* "privilegeToView": Si se requiere un privilegio para ver el valor
|
|
35
|
-
*/
|
|
36
|
-
privilegeToView?: string;
|
|
37
|
-
}[];
|
|
38
|
+
properties: DynamicAccordionProperty<T, K>[];
|
|
38
39
|
}
|
|
39
40
|
export interface useDynamicAccordionsProps<T extends any = any, K extends any = any> {
|
|
40
41
|
configDynamicAccordions: ConfigDynamicAccordion<T, K>[];
|
|
@@ -2,4 +2,4 @@ import { useBaseDynamicAccordionsProps } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Hook que se encarga de gestionar los accordions del detalle de inventario
|
|
4
4
|
*/
|
|
5
|
-
export declare function useBaseAccordions(props: useBaseDynamicAccordionsProps): import("react/jsx-runtime").JSX.Element[];
|
|
5
|
+
export declare function useBaseAccordions(props: useBaseDynamicAccordionsProps): import("react/jsx-runtime").JSX.Element[] | null;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { Accordion, PropertyValue } from "@m4l/components";
|
|
2
|
+
import { useMemo, createElement } from "react";
|
|
3
|
+
import { Accordion, Stack, PropertyValue } from "@m4l/components";
|
|
4
4
|
import { useModuleDictionary } from "@m4l/core";
|
|
5
5
|
function useBaseAccordions(props) {
|
|
6
6
|
const { data, endPointData, configDynamicAccordions: accordions } = props;
|
|
7
7
|
const { getLabel } = useModuleDictionary();
|
|
8
8
|
const AccordionsComponents = useMemo(() => {
|
|
9
|
+
if (!data) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
9
12
|
return accordions.map((accordion) => {
|
|
10
13
|
return /* @__PURE__ */ jsx(
|
|
11
14
|
Accordion,
|
|
@@ -15,17 +18,18 @@ function useBaseAccordions(props) {
|
|
|
15
18
|
accordionProps: {
|
|
16
19
|
...accordion.accordionProps
|
|
17
20
|
},
|
|
18
|
-
children: accordion.properties.map((property) => {
|
|
21
|
+
children: /* @__PURE__ */ jsx(Stack, { direction: "column", gap: "8px", children: accordion.properties.map((property) => {
|
|
19
22
|
const value = property.getValue(data, endPointData);
|
|
20
|
-
return /* @__PURE__ */
|
|
23
|
+
return /* @__PURE__ */ createElement(
|
|
21
24
|
PropertyValue,
|
|
22
25
|
{
|
|
26
|
+
...property,
|
|
27
|
+
key: property.dictionaryId,
|
|
23
28
|
property: getLabel(property.dictionaryId),
|
|
24
29
|
value
|
|
25
|
-
}
|
|
26
|
-
property.dictionaryId
|
|
30
|
+
}
|
|
27
31
|
);
|
|
28
|
-
})
|
|
32
|
+
}) })
|
|
29
33
|
},
|
|
30
34
|
accordion.dictionaryId
|
|
31
35
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useNetworkActionConfirm';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NetworkProps } from '@m4l/core';
|
|
2
|
+
export interface UseNetworkConfirmActionProps<T> {
|
|
3
|
+
/**
|
|
4
|
+
* Función para refrescar la lista
|
|
5
|
+
*/
|
|
6
|
+
fullRefresh: (obj: T) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Función para obtener el endpoint
|
|
9
|
+
*/
|
|
10
|
+
getEndPoint: (obj: T) => NetworkProps;
|
|
11
|
+
/**
|
|
12
|
+
* Título del modal
|
|
13
|
+
*/
|
|
14
|
+
title: string;
|
|
15
|
+
/**
|
|
16
|
+
* Mensaje del modal
|
|
17
|
+
*/
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useModal, useWindowToolsMF, WindowConfirm } from "@m4l/components";
|
|
3
|
+
import { useNetwork, useHostTools } from "@m4l/core";
|
|
4
|
+
import { useCallback } from "react";
|
|
5
|
+
function useNetworkActionConfirm(props) {
|
|
6
|
+
const { fullRefresh, getEndPoint, title, message } = props;
|
|
7
|
+
const { networkOperation } = useNetwork();
|
|
8
|
+
const { toast } = useHostTools();
|
|
9
|
+
const { openModal, closeModal } = useModal();
|
|
10
|
+
const { startProgress, stopProgress } = useWindowToolsMF();
|
|
11
|
+
const onConfirm = useCallback((obj) => {
|
|
12
|
+
networkOperation({
|
|
13
|
+
options: {
|
|
14
|
+
startProgress,
|
|
15
|
+
stopProgress
|
|
16
|
+
},
|
|
17
|
+
...getEndPoint(obj)
|
|
18
|
+
}).then((response) => {
|
|
19
|
+
toast({ title: `${response.message}` }, { type: "success" });
|
|
20
|
+
}).catch((response) => {
|
|
21
|
+
toast({ title: `${response.message}` }, { type: "error" });
|
|
22
|
+
}).finally(() => {
|
|
23
|
+
fullRefresh(obj);
|
|
24
|
+
});
|
|
25
|
+
closeModal();
|
|
26
|
+
}, [closeModal, fullRefresh, networkOperation, toast, startProgress, stopProgress, getEndPoint]);
|
|
27
|
+
const onAction = useCallback(
|
|
28
|
+
(obj) => {
|
|
29
|
+
openModal({
|
|
30
|
+
window: /* @__PURE__ */ jsx(
|
|
31
|
+
WindowConfirm,
|
|
32
|
+
{
|
|
33
|
+
title,
|
|
34
|
+
msg: message,
|
|
35
|
+
onClickIntro: () => onConfirm(obj)
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
variant: "delete",
|
|
39
|
+
initialWidth: 300,
|
|
40
|
+
initialHeight: 350
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
[message, onConfirm, openModal, title]
|
|
44
|
+
);
|
|
45
|
+
return { onAction };
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
useNetworkActionConfirm as u
|
|
49
|
+
};
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { L } from "./constants.js";
|
|
1
2
|
import { M } from "./components/MFNoAuthApp/index.js";
|
|
2
3
|
import { M as M2 } from "./components/MFHostApp/MFHostApp.js";
|
|
3
4
|
import { M as M3 } from "./components/ModuleDetailTabs/ModuleDetailTabs.js";
|
|
5
|
+
import { D } from "./components/DynamicTabs/DynamicTabs.js";
|
|
4
6
|
import { A, a } from "./contexts/AuthContext/index.js";
|
|
5
7
|
import { M as M4 } from "./layouts/ModuleLayout/ModuleLayout.js";
|
|
6
8
|
import { N } from "./layouts/NoAuthModuleLayout/index.js";
|
|
@@ -13,10 +15,13 @@ import { u as u2 } from "./hooks/useAuth/index.js";
|
|
|
13
15
|
import { u as u3 } from "./hooks/useModule/index.js";
|
|
14
16
|
import { u as u4 } from "./hooks/useDynamicAccordions/useDynamicAccordions.js";
|
|
15
17
|
import { c, u as u5 } from "./hooks/useDynamicPaperForm/useDynamicPaperForm.js";
|
|
18
|
+
import { u as u6 } from "./hooks/useNetworkActionConfirm/useNetworkActionConfirm.js";
|
|
16
19
|
import { c as c2 } from "./utils/createAppMF.js";
|
|
17
20
|
export {
|
|
18
21
|
A as AuthContext,
|
|
19
22
|
a as AuthProvider,
|
|
23
|
+
D as DynamicTabs,
|
|
24
|
+
L as LIMIT_RECORDS_500_CONFIG,
|
|
20
25
|
M2 as MFHostApp,
|
|
21
26
|
M as MFNoAuthApp,
|
|
22
27
|
M5 as MasterDetailLayout,
|
|
@@ -34,5 +39,6 @@ export {
|
|
|
34
39
|
u4 as useDynamicAccordions,
|
|
35
40
|
u5 as useDynamicPaperForm,
|
|
36
41
|
u as useMasterDetail,
|
|
37
|
-
u3 as useModule
|
|
42
|
+
u3 as useModule,
|
|
43
|
+
u6 as useNetworkActionConfirm
|
|
38
44
|
};
|