@m4l/core 0.0.24 → 0.0.27

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.
Files changed (86) hide show
  1. package/dist/contexts/EnvironmentContext/index.d.ts +5 -0
  2. package/dist/contexts/EnvironmentContext/index.js +24 -0
  3. package/{src/contexts/EnvironmentContext/types.ts → dist/contexts/EnvironmentContext/types.d.ts} +1 -3
  4. package/dist/contexts/FlagsContext/index.d.ts +5 -0
  5. package/dist/contexts/FlagsContext/index.js +34 -0
  6. package/{src/contexts/FlagsContext/types.ts → dist/contexts/FlagsContext/types.d.ts} +1 -7
  7. package/dist/contexts/HostToolsContext/index.d.ts +6 -0
  8. package/dist/contexts/HostToolsContext/index.js +24 -0
  9. package/{src/contexts/HostToolsContext/types.ts → dist/contexts/HostToolsContext/types.d.ts} +1 -3
  10. package/dist/contexts/ModuleDictionaryContext/index.d.ts +5 -0
  11. package/dist/contexts/ModuleDictionaryContext/index.js +88 -0
  12. package/{src/contexts/ModuleDictionaryContext/types.ts → dist/contexts/ModuleDictionaryContext/types.d.ts} +1 -4
  13. package/dist/contexts/NetworkContext/index.d.ts +5 -0
  14. package/dist/contexts/NetworkContext/index.js +26 -0
  15. package/{src/contexts/NetworkContext/types.ts → dist/contexts/NetworkContext/types.d.ts} +2 -6
  16. package/{src/contexts/index.ts → dist/contexts/index.d.ts} +0 -0
  17. package/dist/external/axios.js +1299 -0
  18. package/dist/external/snakecase-keys.js +18 -0
  19. package/{src/hooks/index.ts → dist/hooks/index.d.ts} +6 -4
  20. package/dist/hooks/useEnvironment/index.d.ts +2 -0
  21. package/dist/hooks/useEnvironment/index.js +9 -0
  22. package/dist/hooks/useFlags/index.d.ts +3 -0
  23. package/dist/hooks/useFlags/index.js +23 -0
  24. package/dist/hooks/useHostTools/index.d.ts +2 -0
  25. package/dist/hooks/useHostTools/index.js +9 -0
  26. package/dist/hooks/useLocalStorage/index.d.ts +1 -0
  27. package/dist/hooks/useLocalStorage/index.js +21 -0
  28. package/dist/hooks/useModuleDictionary/index.d.ts +1 -0
  29. package/dist/hooks/useModuleDictionary/index.js +9 -0
  30. package/dist/hooks/useNetwork/index.d.ts +2 -0
  31. package/dist/hooks/useNetwork/index.js +9 -0
  32. package/dist/hooks/usePaginate/index.d.ts +15 -0
  33. package/dist/hooks/usePaginate/index.js +72 -0
  34. package/dist/hooks/usePaginate/types.d.ts +6 -0
  35. package/dist/index.d.ts +6 -0
  36. package/dist/index.js +20 -0
  37. package/dist/node_modules.js +100 -0
  38. package/{src/types/dictionary.ts → dist/types/dictionary.d.ts} +1 -5
  39. package/{src/types/index.ts → dist/types/index.d.ts} +5 -20
  40. package/dist/types/index.js +6 -0
  41. package/dist/utils/axiosOperation/index.d.ts +2 -0
  42. package/{src/utils/axiosOperation/types.ts → dist/utils/axiosOperation/types.d.ts} +1 -1
  43. package/dist/utils/getLocalStorage.d.ts +1 -0
  44. package/dist/utils/getPropertyByString.d.ts +1 -0
  45. package/{src/utils/index.ts → dist/utils/index.d.ts} +0 -0
  46. package/dist/utils/index.js +33 -0
  47. package/dist/utils/setLocalStorage.d.ts +1 -0
  48. package/dist/utils/voidFunction.d.ts +1 -0
  49. package/dist/vendor.js +32 -0
  50. package/{src → dist}/vite-env.d.ts +0 -0
  51. package/package.json +4 -2
  52. package/.eslintignore +0 -2
  53. package/.eslintrc.cjs +0 -109
  54. package/.prettierignore +0 -2
  55. package/.prettierrc.json +0 -26
  56. package/.vscode/settings.json +0 -50
  57. package/README copy.md +0 -0
  58. package/index.html +0 -13
  59. package/package_with_dependicies.json +0 -75
  60. package/src/contexts/EnvironmentContext/index.tsx +0 -37
  61. package/src/contexts/FlagsContext/index.tsx +0 -50
  62. package/src/contexts/HostToolsContext/index.tsx +0 -34
  63. package/src/contexts/ModuleDictionaryContext/index.tsx +0 -109
  64. package/src/contexts/NetworkContext/index.tsx +0 -44
  65. package/src/hooks/useEnvironment/index.test.tsx +0 -36
  66. package/src/hooks/useEnvironment/index.ts +0 -13
  67. package/src/hooks/useFlags/index.ts +0 -33
  68. package/src/hooks/useHostTools/index.ts +0 -13
  69. package/src/hooks/useLocalStorage/index.ts +0 -23
  70. package/src/hooks/useModuleDictionary/index.ts +0 -11
  71. package/src/hooks/useNetwork/index.ts +0 -13
  72. package/src/index.ts +0 -43
  73. package/src/indexFlags.ts +0 -1
  74. package/src/isolation/App.tsx +0 -24
  75. package/src/main.tsx +0 -10
  76. package/src/prueba.d1.t1 +0 -10
  77. package/src/test/setup.ts +0 -1
  78. package/src/test/utils.tsx +0 -20
  79. package/src/utils/axiosOperation/index.ts +0 -140
  80. package/src/utils/getLocalStorage.ts +0 -8
  81. package/src/utils/getPropertyByString.ts +0 -10
  82. package/src/utils/setLocalStorage.ts +0 -12
  83. package/src/utils/voidFunction.ts +0 -2
  84. package/tsconfig.json +0 -37
  85. package/tsconfig.node.json +0 -10
  86. package/vite.config.ts +0 -178
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { EnvironmentProviderProps } from './types';
3
+ declare const EnvironmentContext: import("react").Context<import("../..").EnvironmentType>;
4
+ declare function EnvironmentProvider(props: EnvironmentProviderProps): JSX.Element;
5
+ export { EnvironmentProvider, EnvironmentContext };
@@ -0,0 +1,24 @@
1
+ import { createContext, useState } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ const initialValue = {
4
+ isLocalhost: true,
5
+ host: "",
6
+ domain_token: "",
7
+ host_api_local: "",
8
+ host_api_remote: "",
9
+ host_static_assets: "",
10
+ environment: ""
11
+ };
12
+ const EnvironmentContext = createContext(initialValue);
13
+ function EnvironmentProvider(props) {
14
+ const {
15
+ children,
16
+ ...other
17
+ } = props;
18
+ const [finalEnvironment] = useState(other);
19
+ return /* @__PURE__ */ jsx(EnvironmentContext.Provider, {
20
+ value: finalEnvironment,
21
+ children
22
+ });
23
+ }
24
+ export { EnvironmentContext as E, EnvironmentProvider as a };
@@ -1,8 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { EnvironmentType } from '../../types';
3
-
4
3
  export interface EnvironmentProviderProps extends EnvironmentType {
5
4
  children: ReactNode;
6
5
  }
7
-
8
- export type EnvironmentContextType = EnvironmentType;
6
+ export declare type EnvironmentContextType = EnvironmentType;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { FlagsContextProps, FlagsProviderProps } from './types';
3
+ declare const FlagsContext: import("react").Context<FlagsContextProps>;
4
+ declare function FlagsProvider({ children }: FlagsProviderProps): JSX.Element;
5
+ export { FlagsProvider, FlagsContext };
@@ -0,0 +1,34 @@
1
+ import { createContext, useState, useCallback } from "react";
2
+ import { v as voidFunction } from "../../utils/index.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ const initialState = {
5
+ flags: [],
6
+ clearFlags: voidFunction,
7
+ addFlag: voidFunction
8
+ };
9
+ const FlagsContext = createContext(initialState);
10
+ function FlagsProvider({
11
+ children
12
+ }) {
13
+ const [flags, setFlags] = useState([]);
14
+ const clearFlags = useCallback(() => {
15
+ setFlags([]);
16
+ }, []);
17
+ const addFlag = useCallback((newFlag) => {
18
+ setFlags((oldFlags) => {
19
+ if (oldFlags.findIndex((f) => f === newFlag) < 0) {
20
+ return [...oldFlags, newFlag];
21
+ }
22
+ return [...oldFlags];
23
+ });
24
+ }, []);
25
+ return /* @__PURE__ */ jsx(FlagsContext.Provider, {
26
+ value: {
27
+ flags,
28
+ addFlag,
29
+ clearFlags
30
+ },
31
+ children
32
+ });
33
+ }
34
+ export { FlagsContext as F, FlagsProvider as a };
@@ -1,14 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
-
3
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
4
2
  export interface FlagsProviderProps {
5
3
  children: ReactNode;
6
4
  }
7
-
8
- export type Flag = string;
9
-
10
- // Interface para almacenar el estado del contexto
11
- // Interface para indicar las propiedas y metodos que comparte el contexto
5
+ export declare type Flag = string;
12
6
  export interface FlagsContextProps {
13
7
  flags: Array<Flag>;
14
8
  clearFlags: () => void;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { HostToolsType } from '../../types';
3
+ import type { HostToolsProviderProps } from './types';
4
+ declare const HostToolsContext: import("react").Context<HostToolsType>;
5
+ declare function HostToolsProvider(props: HostToolsProviderProps): JSX.Element;
6
+ export { HostToolsProvider, HostToolsContext };
@@ -0,0 +1,24 @@
1
+ import { createContext, useState } from "react";
2
+ import { v as voidFunction } from "../../utils/index.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ const initialValue = {
5
+ toast: () => 0,
6
+ startProgress: voidFunction,
7
+ stopProgress: voidFunction,
8
+ events_add_listener: voidFunction,
9
+ events_remove_listener: voidFunction,
10
+ events_emit: voidFunction
11
+ };
12
+ const HostToolsContext = createContext(initialValue);
13
+ function HostToolsProvider(props) {
14
+ const {
15
+ children,
16
+ ...hostTools
17
+ } = props;
18
+ const [finalTools] = useState(hostTools);
19
+ return /* @__PURE__ */ jsx(HostToolsContext.Provider, {
20
+ value: finalTools,
21
+ children
22
+ });
23
+ }
24
+ export { HostToolsContext as H, HostToolsProvider as a };
@@ -1,8 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { HostToolsType } from '../../types';
3
-
4
3
  export interface HostToolsProviderProps extends HostToolsType {
5
4
  children: ReactNode;
6
5
  }
7
-
8
- export type HostToolsContextType = HostToolsType;
6
+ export declare type HostToolsContextType = HostToolsType;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { ModuleDictionaryContextProps, ModuleDictionaryProviderProps } from './types';
3
+ declare const ModuleDictionaryContext: import("react").Context<ModuleDictionaryContextProps>;
4
+ declare function ModuleDictionaryProvider(props: ModuleDictionaryProviderProps): JSX.Element;
5
+ export { ModuleDictionaryProvider, ModuleDictionaryContext };
@@ -0,0 +1,88 @@
1
+ import { createContext, useState, useLayoutEffect, useCallback } from "react";
2
+ import { u as useFlags } from "../../hooks/useFlags/index.js";
3
+ import { u as useHostTools } from "../../hooks/useHostTools/index.js";
4
+ import { u as useNetwork } from "../../hooks/useNetwork/index.js";
5
+ import { u as useEnvironment } from "../../hooks/useEnvironment/index.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ const initialState = {
8
+ getLabel: () => "..",
9
+ getModuleLabel: () => "No dictionary context"
10
+ };
11
+ const ModuleDictionaryContext = createContext(initialState);
12
+ function ModuleDictionaryProvider(props) {
13
+ const {
14
+ children,
15
+ componentsDictionary,
16
+ moduleId,
17
+ moduleName = "module_name",
18
+ currentLang = "us",
19
+ isAuth = true
20
+ } = props;
21
+ const {
22
+ addFlag
23
+ } = useFlags();
24
+ const [moduleDictionary, setModuleDictionary] = useState(void 0);
25
+ const {
26
+ domain_token
27
+ } = useEnvironment();
28
+ const {
29
+ startProgress,
30
+ stopProgress
31
+ } = useHostTools();
32
+ const {
33
+ networkOperation
34
+ } = useNetwork();
35
+ useLayoutEffect(() => {
36
+ let mounted = true;
37
+ startProgress();
38
+ networkOperation({
39
+ method: "GET",
40
+ endPoint: isAuth ? `dictionaries/${moduleId}` : `na/dictionaries/${moduleId}`,
41
+ parms: {
42
+ comps: componentsDictionary,
43
+ ...isAuth ? {} : {
44
+ domain_token
45
+ }
46
+ }
47
+ }).then((response) => {
48
+ if (mounted) {
49
+ setModuleDictionary({
50
+ ...response
51
+ });
52
+ addFlag("dictionary_loaded");
53
+ }
54
+ }).finally(() => {
55
+ stopProgress();
56
+ });
57
+ return function cleanUp() {
58
+ mounted = false;
59
+ };
60
+ }, [currentLang]);
61
+ const getLabel = useCallback((key) => {
62
+ if (moduleDictionary === void 0)
63
+ return "No dictionary";
64
+ if (key === void 0)
65
+ return "No key";
66
+ const parts = key.split(".");
67
+ if (parts.length === 2) {
68
+ if (moduleDictionary[parts[0]] && moduleDictionary[parts[0]][parts[1]]) {
69
+ return moduleDictionary[parts[0]][parts[1]];
70
+ }
71
+ } else if (parts.length === 1) {
72
+ if (moduleDictionary.data && moduleDictionary.data[key]) {
73
+ return moduleDictionary.data[key];
74
+ }
75
+ }
76
+ return `No dictionary:${key}`;
77
+ }, [moduleDictionary]);
78
+ const getModuleLabel = useCallback(() => getLabel(moduleName), [moduleName, getLabel]);
79
+ return /* @__PURE__ */ jsx(ModuleDictionaryContext.Provider, {
80
+ value: {
81
+ moduleDictionary,
82
+ getLabel,
83
+ getModuleLabel
84
+ },
85
+ children
86
+ });
87
+ }
88
+ export { ModuleDictionaryContext as M, ModuleDictionaryProvider as a };
@@ -1,16 +1,13 @@
1
1
  import { ReactNode } from 'react';
2
2
  import type { GetLabelType, ModuleDictionary } from 'src/types/dictionary';
3
-
4
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
5
3
  export interface ModuleDictionaryProviderProps {
6
4
  currentLang?: string;
7
5
  isAuth?: boolean;
8
6
  moduleId: number;
9
- moduleName?: string; //la llave donde reposa el nombre del modulo en el diccionario
7
+ moduleName?: string;
10
8
  componentsDictionary: string[];
11
9
  children: ReactNode;
12
10
  }
13
-
14
11
  export interface ModuleDictionaryContextProps {
15
12
  moduleDictionary?: ModuleDictionary;
16
13
  getLabel: GetLabelType;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { NetworkProviderProps } from './types';
3
+ declare const NetworkContext: import("react").Context<import("./types").NetworkType>;
4
+ declare function NetworkProvider(props: NetworkProviderProps): JSX.Element;
5
+ export { NetworkProvider, NetworkContext };
@@ -0,0 +1,26 @@
1
+ import { createContext, useCallback } from "react";
2
+ import { u as useEnvironment } from "../../hooks/useEnvironment/index.js";
3
+ import { u as useHostTools } from "../../hooks/useHostTools/index.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ const initialValue = {
6
+ networkOperation: () => Promise.resolve()
7
+ };
8
+ const NetworkContext = createContext(initialValue);
9
+ function NetworkProvider(props) {
10
+ const {
11
+ children,
12
+ axiosOperation
13
+ } = props;
14
+ const environment = useEnvironment();
15
+ const hostTools = useHostTools();
16
+ const networkOperation = useCallback(async (networkProps) => {
17
+ return axiosOperation(networkProps, environment, hostTools);
18
+ }, [axiosOperation]);
19
+ return /* @__PURE__ */ jsx(NetworkContext.Provider, {
20
+ value: {
21
+ networkOperation
22
+ },
23
+ children
24
+ });
25
+ }
26
+ export { NetworkContext as N, NetworkProvider as a };
@@ -1,15 +1,11 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { AxiosOperation, NetworkProps } from '../../types';
3
-
4
- export type EventFunListener = (...args: any[]) => void;
5
-
3
+ export declare type EventFunListener = (...args: any[]) => void;
6
4
  export interface NetworkType {
7
5
  networkOperation: (props: NetworkProps) => Promise<any>;
8
6
  }
9
-
10
7
  export interface NetworkProviderProps {
11
8
  axiosOperation: AxiosOperation;
12
9
  children: ReactNode;
13
10
  }
14
-
15
- export type NetworkContextType = NetworkType;
11
+ export declare type NetworkContextType = NetworkType;