@m4l/graphics 0.1.19 → 0.1.20
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/dist/package.json +1 -1
- package/package.json +4 -5
- package/.eslintignore +0 -2
- package/.eslintrc.cjs +0 -118
- package/.gitignore +0 -24
- package/.gitlab-ci.yml +0 -15
- package/.prettierignore +0 -3
- package/.prettierrc.json +0 -26
- package/.vscode/settings.json +0 -50
- package/src/components/ProgressBarStyle/index.tsx +0 -39
- package/src/components/index.ts +0 -3
- package/src/contexts/FormatterContext/index.tsx +0 -131
- package/src/contexts/FormatterContext/types.ts +0 -73
- package/src/contexts/HostThemeContext/index.tsx +0 -85
- package/src/contexts/HostThemeContext/types.ts +0 -16
- package/src/contexts/LocalesContext/helper.ts +0 -67
- package/src/contexts/LocalesContext/index.tsx +0 -152
- package/src/contexts/LocalesContext/types.ts +0 -37
- package/src/contexts/index.ts +0 -15
- package/src/hooks/index.ts +0 -8
- package/src/hooks/useFirstRender/index.ts +0 -17
- package/src/hooks/useFormatter/index.ts +0 -10
- package/src/hooks/useHostTheme/index.ts +0 -10
- package/src/hooks/useIsMountedRef/index.ts +0 -16
- package/src/hooks/useLocales/index.ts +0 -10
- package/src/hooks/useOffSetTop.ts +0 -26
- package/src/hooks/useResponsive/index.ts +0 -44
- package/src/index.ts +0 -25
- package/src/theme/breakpoints.ts +0 -13
- package/src/theme/defaultThemeOptions.ts +0 -42
- package/src/theme/overrides/Accordion.ts +0 -85
- package/src/theme/overrides/Alert.tsx +0 -74
- package/src/theme/overrides/Autocomplete.ts +0 -31
- package/src/theme/overrides/Avatar.ts +0 -29
- package/src/theme/overrides/Backdrop.ts +0 -26
- package/src/theme/overrides/Badge.ts +0 -17
- package/src/theme/overrides/Breadcrumbs.ts +0 -16
- package/src/theme/overrides/Button.ts +0 -62
- package/src/theme/overrides/ButtonGroup.ts +0 -51
- package/src/theme/overrides/Card.ts +0 -36
- package/src/theme/overrides/Checkbox.tsx +0 -54
- package/src/theme/overrides/Chip.tsx +0 -49
- package/src/theme/overrides/ControlLabel.ts +0 -29
- package/src/theme/overrides/CssBaseline.ts +0 -46
- package/src/theme/overrides/CustomIcons.tsx +0 -122
- package/src/theme/overrides/DataGrid.ts +0 -101
- package/src/theme/overrides/Dialog.ts +0 -60
- package/src/theme/overrides/Drawer.ts +0 -30
- package/src/theme/overrides/Fab.ts +0 -40
- package/src/theme/overrides/IconButton.ts +0 -35
- package/src/theme/overrides/Input.ts +0 -94
- package/src/theme/overrides/InputLabel.ts +0 -17
- package/src/theme/overrides/Link.ts +0 -20
- package/src/theme/overrides/List.ts +0 -37
- package/src/theme/overrides/LoadingButton.ts +0 -28
- package/src/theme/overrides/Menu.ts +0 -20
- package/src/theme/overrides/Pagination.ts +0 -38
- package/src/theme/overrides/Paper.ts +0 -27
- package/src/theme/overrides/Popover.ts +0 -16
- package/src/theme/overrides/Progress.ts +0 -27
- package/src/theme/overrides/Radio.ts +0 -21
- package/src/theme/overrides/Rating.tsx +0 -30
- package/src/theme/overrides/Select.tsx +0 -14
- package/src/theme/overrides/Skeleton.ts +0 -19
- package/src/theme/overrides/Slider.ts +0 -31
- package/src/theme/overrides/Stepper.ts +0 -15
- package/src/theme/overrides/SvgIcon.ts +0 -21
- package/src/theme/overrides/Switch.ts +0 -35
- package/src/theme/overrides/Table.ts +0 -95
- package/src/theme/overrides/Tabs.ts +0 -61
- package/src/theme/overrides/Timeline.ts +0 -23
- package/src/theme/overrides/ToggleButton.ts +0 -54
- package/src/theme/overrides/Tooltip.ts +0 -20
- package/src/theme/overrides/TreeView.tsx +0 -25
- package/src/theme/overrides/Typography.ts +0 -18
- package/src/theme/overrides/index.ts +0 -102
- package/src/theme/palette.ts +0 -216
- package/src/theme/shadows.ts +0 -110
- package/src/theme/stretch.ts +0 -10
- package/src/theme/typography.ts +0 -91
- package/src/types/index.ts +0 -9
- package/src/utils/anchorEl.ts +0 -146
- package/src/utils/getColorPresets.ts +0 -91
- package/src/utils/getFontValue.ts +0 -73
- package/src/utils/strings.ts +0 -1
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -29
- package/tsconfig.node.json +0 -8
- package/vite.config.ts +0 -234
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/graphics",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "M4L Team",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"build": "tsc && vite build && yarn build:package",
|
|
10
10
|
"build:monorepo": "tsc && vite build && yarn build:package",
|
|
11
11
|
"release": "yarn build && npm publish ./dist",
|
|
12
|
-
"release:monorepo": "yarn build:monorepo
|
|
12
|
+
"release:monorepo": "yarn build:monorepo",
|
|
13
|
+
"publish": "npm publish ./dist",
|
|
13
14
|
"lint": "npx eslint src",
|
|
14
15
|
"lint:fix": "npm run lint -- --fix",
|
|
15
16
|
"prettier": "npx prettier src --check",
|
|
@@ -58,9 +59,7 @@
|
|
|
58
59
|
"vite": "3.1.0",
|
|
59
60
|
"vite-plugin-dts": "1.2.0"
|
|
60
61
|
},
|
|
61
|
-
"files": [
|
|
62
|
-
"*"
|
|
63
|
-
],
|
|
62
|
+
"files": ["dist/**"],
|
|
64
63
|
"source": "src/index.ts",
|
|
65
64
|
"main": "./dist/index.js",
|
|
66
65
|
"module": "./dist/index.js",
|
package/.eslintignore
DELETED
package/.eslintrc.cjs
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
const prettierOptions = JSON.parse(fs.readFileSync(path.resolve(__dirname, '.prettierrc.json'), 'utf8'));
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
env: {
|
|
9
|
-
browser: true,
|
|
10
|
-
es2021: true,
|
|
11
|
-
},
|
|
12
|
-
extends: [
|
|
13
|
-
'plugin:react/recommended',
|
|
14
|
-
// 'airbnb',
|
|
15
|
-
'eslint:recommended',
|
|
16
|
-
'plugin:jsx-a11y/recommended',
|
|
17
|
-
'plugin:import/typescript',
|
|
18
|
-
'plugin:react/jsx-runtime',
|
|
19
|
-
'plugin:prettier/recommended',
|
|
20
|
-
'plugin:@typescript-eslint/recommended',
|
|
21
|
-
'prettier',
|
|
22
|
-
],
|
|
23
|
-
parser: '@typescript-eslint/parser',
|
|
24
|
-
parserOptions: {
|
|
25
|
-
ecmaFeatures: {
|
|
26
|
-
jsx: true,
|
|
27
|
-
},
|
|
28
|
-
ecmaVersion: 'latest',
|
|
29
|
-
sourceType: 'module',
|
|
30
|
-
},
|
|
31
|
-
plugins: ['react', '@typescript-eslint', 'import', 'jsx-a11y', 'react-hooks', 'prettier', 'unused-imports'],
|
|
32
|
-
rules: {
|
|
33
|
-
'prettier/prettier': ['error', prettierOptions],
|
|
34
|
-
'react/jsx-filename-extension': [1, {extensions: ['.ts', '.tsx']}], //En que archivos va a haber jsx
|
|
35
|
-
'@typescript-eslint/no-explicit-any':"off",
|
|
36
|
-
'react/jsx-props-no-spreading':"off", //Que se pueda usar el spread
|
|
37
|
-
"react/prop-types":"off", //Desactivar los proptypes
|
|
38
|
-
"react/require-default-props":"off", //Cuando se usan props parametros opcionales no es necesariio definir los valores por defecto
|
|
39
|
-
"react/jsx-no-useless-fragment":"warn", //No usar jsx dentro de un fragment
|
|
40
|
-
"react/no-unstable-nested-components": [
|
|
41
|
-
"off",
|
|
42
|
-
{ "allowAsProps": true }
|
|
43
|
-
],
|
|
44
|
-
"@typescript-eslint/no-empty-interface":"warn",
|
|
45
|
-
"@typescript-eslint/ban-ts-comment":"off",
|
|
46
|
-
"no-empty-pattern":"warn",
|
|
47
|
-
"no-shadow":"warn", //que se puedan declarar las mismas variables dentro del scope
|
|
48
|
-
'no-console': 'off', //Que no se puedan imprimir en la consola
|
|
49
|
-
"no-empty": "off",
|
|
50
|
-
// "no-empty-function": "error",
|
|
51
|
-
"@typescript-eslint/no-empty-function": "off","no-unused-vars": "off",
|
|
52
|
-
"@typescript-eslint/no-unused-vars": [
|
|
53
|
-
"warn", // or "error"
|
|
54
|
-
{
|
|
55
|
-
"argsIgnorePattern": "^_",
|
|
56
|
-
"varsIgnorePattern": "^_",
|
|
57
|
-
"caughtErrorsIgnorePattern": "^_"
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
|
|
61
|
-
'import/extensions': [
|
|
62
|
-
'off',
|
|
63
|
-
'ignorePackages',
|
|
64
|
-
{
|
|
65
|
-
// js: 'never',
|
|
66
|
-
// mjs: 'never',
|
|
67
|
-
// jsx: 'never',
|
|
68
|
-
ts: 'never', //se especifica q tipo de librerias se pueden importar
|
|
69
|
-
tsx: 'never',
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
'import/prefer-default-export': 'off',
|
|
73
|
-
},
|
|
74
|
-
overrides: [
|
|
75
|
-
{
|
|
76
|
-
files: ['**/*.ts?(x)','**/*.js?(x)'],
|
|
77
|
-
rules: {
|
|
78
|
-
'prettier/prettier': ['warn', prettierOptions],
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
settings: {
|
|
83
|
-
"react": {
|
|
84
|
-
"createClass": "createReactClass", // Regex for Component Factory to use,
|
|
85
|
-
// default to "createReactClass"
|
|
86
|
-
"pragma": "React", // Pragma to use, default to "React"
|
|
87
|
-
"fragment": "Fragment", // Fragment to use (may be a property of <pragma>), default to "Fragment"
|
|
88
|
-
"version": "detect", // React version. "detect" automatically picks the version you have installed.
|
|
89
|
-
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
|
|
90
|
-
// It will default to "latest" and warn if missing, and to "detect" in the future
|
|
91
|
-
"flowVersion": "0.53" // Flow version
|
|
92
|
-
},
|
|
93
|
-
'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx'],
|
|
94
|
-
'import/resolver': { //Permite encontrar los alias de los paths de importación
|
|
95
|
-
alias: {
|
|
96
|
-
map: [['~', path.resolve(__dirname)]],
|
|
97
|
-
extensions: ['.ts', '.js', '.tsx'],
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// {
|
|
104
|
-
// "jsxSingleQuote": false,
|
|
105
|
-
// "singleQuote": true,
|
|
106
|
-
// "semi": true,
|
|
107
|
-
// "tabWidth": 4,
|
|
108
|
-
// "trailingComma": "all",
|
|
109
|
-
// "printWidth": 100,
|
|
110
|
-
// "bracketSpacing": false,
|
|
111
|
-
// "bracketSameLine": false,
|
|
112
|
-
// "useTabs": false,
|
|
113
|
-
// "arrowParens": "always",
|
|
114
|
-
// "endOfLine": "crlf",
|
|
115
|
-
// "proseWrap": "preserve",
|
|
116
|
-
// "quoteProps": "as-needed",
|
|
117
|
-
// "htmlWhitespaceSensitivity": "css"
|
|
118
|
-
// }
|
package/.gitignore
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Logs
|
|
2
|
-
logs
|
|
3
|
-
*.log
|
|
4
|
-
npm-debug.log*
|
|
5
|
-
yarn-debug.log*
|
|
6
|
-
yarn-error.log*
|
|
7
|
-
pnpm-debug.log*
|
|
8
|
-
lerna-debug.log*
|
|
9
|
-
|
|
10
|
-
node_modules
|
|
11
|
-
dist
|
|
12
|
-
dist-ssr
|
|
13
|
-
*.local
|
|
14
|
-
package-lock.json
|
|
15
|
-
|
|
16
|
-
# Editor directories and files
|
|
17
|
-
.idea
|
|
18
|
-
.DS_Store
|
|
19
|
-
*.suo
|
|
20
|
-
*.ntvs*
|
|
21
|
-
*.njsproj
|
|
22
|
-
*.sln
|
|
23
|
-
*.sw?
|
|
24
|
-
./docs/*
|
package/.gitlab-ci.yml
DELETED
package/.prettierignore
DELETED
package/.prettierrc.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"printWidth": 100,
|
|
3
|
-
"endOfLine":"auto",
|
|
4
|
-
"tabWidth": 4,
|
|
5
|
-
"useTabs": false,
|
|
6
|
-
"semi": true,
|
|
7
|
-
"singleQuote": true,
|
|
8
|
-
"trailingComma": "all",
|
|
9
|
-
"arrowParens" : "avoid",
|
|
10
|
-
"bracketSpacing": true,
|
|
11
|
-
"bracketSameLine":false,
|
|
12
|
-
"proseWrap": "never",
|
|
13
|
-
"quoteProps": "as-needed",
|
|
14
|
-
"singleAttributePerLine":false ,
|
|
15
|
-
|
|
16
|
-
"overrides": [
|
|
17
|
-
{
|
|
18
|
-
"files": ".prettierrc",
|
|
19
|
-
"options": { "parser": "typescript" }
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
package/.vscode/settings.json
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"explorer.confirmDelete": false,
|
|
3
|
-
"code-runner.clearPreviousOutput": true,
|
|
4
|
-
"explorer.confirmDragAndDrop": false,
|
|
5
|
-
"liveServer.settings.donotShowInfoMsg": true,
|
|
6
|
-
"prettier.eslintIntegration": true,
|
|
7
|
-
"editor.codeActionsOnSave": {
|
|
8
|
-
"source.fixAll.eslint": true
|
|
9
|
-
},
|
|
10
|
-
"eslint.probe": [
|
|
11
|
-
"javascriptreact",
|
|
12
|
-
"typescript",
|
|
13
|
-
"typescriptreact",
|
|
14
|
-
"html",
|
|
15
|
-
"markdown"
|
|
16
|
-
],
|
|
17
|
-
"color-highlight.matchRgbWithNoFunction": true,
|
|
18
|
-
"color-highlight.matchWords": true,
|
|
19
|
-
"[typescript]": {
|
|
20
|
-
"editor.defaultFormatter": "vscode.typescript-language-features"
|
|
21
|
-
},
|
|
22
|
-
"thunder-client.codeSnippetLanguage": "js-axios",
|
|
23
|
-
"editor.formatOnSave": false,
|
|
24
|
-
"[typescriptreact]": {
|
|
25
|
-
"editor.defaultFormatter": "vscode.typescript-language-features"
|
|
26
|
-
},
|
|
27
|
-
"javascript.updateImportsOnFileMove.enabled": "always",
|
|
28
|
-
"typescript.updateImportsOnFileMove.enabled": "always",
|
|
29
|
-
// "git.autofetch": true,
|
|
30
|
-
"eslint.nodeEnv": "",
|
|
31
|
-
// "prettier.useEditorConfig": false,
|
|
32
|
-
// "prettier.typescriptEnable": [
|
|
33
|
-
// "typescript",
|
|
34
|
-
// "typescriptreact"
|
|
35
|
-
// ],
|
|
36
|
-
// "prettier.tabWidth": 4,
|
|
37
|
-
// "prettier.jsonEnable": [
|
|
38
|
-
// "json"
|
|
39
|
-
// ],
|
|
40
|
-
// "prettier.trailingComma": "all",
|
|
41
|
-
// "prettier.singleQuote": true,
|
|
42
|
-
// "prettier.printWidth": 100,
|
|
43
|
-
// "prettier.bracketSpacing": true,
|
|
44
|
-
// "prettier.singleAttributePerLine": false,
|
|
45
|
-
// "prettier.graphqlEnable": [
|
|
46
|
-
// "graphql"
|
|
47
|
-
// ],
|
|
48
|
-
// "eslint.rules.customizations": [],
|
|
49
|
-
// "eslint.runtime": ""
|
|
50
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// @mui
|
|
2
|
-
import { useTheme } from '@mui/material/styles';
|
|
3
|
-
import { GlobalStyles } from '@mui/material';
|
|
4
|
-
|
|
5
|
-
// -------------ddd---------------------------------------------------------
|
|
6
|
-
|
|
7
|
-
export function ProgressBarStyle() {
|
|
8
|
-
const theme = useTheme();
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<GlobalStyles
|
|
12
|
-
styles={{
|
|
13
|
-
'#nprogress': {
|
|
14
|
-
pointerEvents: 'none',
|
|
15
|
-
'& .bar': {
|
|
16
|
-
top: 0,
|
|
17
|
-
left: 0,
|
|
18
|
-
height: 2,
|
|
19
|
-
width: '100%',
|
|
20
|
-
position: 'fixed',
|
|
21
|
-
zIndex: theme.zIndex.snackbar,
|
|
22
|
-
backgroundColor: theme.palette.primary.main,
|
|
23
|
-
boxShadow: `0 0 2px ${theme.palette.primary.main}`,
|
|
24
|
-
},
|
|
25
|
-
'& .peg': {
|
|
26
|
-
right: 0,
|
|
27
|
-
opacity: 1,
|
|
28
|
-
width: 100,
|
|
29
|
-
height: '100%',
|
|
30
|
-
display: 'block',
|
|
31
|
-
position: 'absolute',
|
|
32
|
-
transform: 'rotate(3deg) translate(0px, -4px)',
|
|
33
|
-
boxShadow: `0 0 10px ${theme.palette.primary.main}, 0 0 5px ${theme.palette.primary.main}`,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
}}
|
|
37
|
-
/>
|
|
38
|
-
);
|
|
39
|
-
}
|
package/src/components/index.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-duplicates */
|
|
2
|
-
import { createContext, useState, useEffect, useCallback } from 'react';
|
|
3
|
-
import { EmitEvents, useHostTools, usePropageteMF } from '@m4l/core';
|
|
4
|
-
import { FormatterProviderProps, FormatterContextProps, Formatters } from './types';
|
|
5
|
-
import { useFirstRender } from '../../hooks/useFirstRender';
|
|
6
|
-
|
|
7
|
-
// ----------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
const FormatterContext = createContext<FormatterContextProps | null>(null);
|
|
10
|
-
/**
|
|
11
|
-
* @function
|
|
12
|
-
* Componente encargado de proveer un contexto que permita saber los diferentes forrmatos,
|
|
13
|
-
* Segunda linea
|
|
14
|
-
* @param props Objeto de propiedades
|
|
15
|
-
* @version 1.0.0
|
|
16
|
-
* @author Juan Andrés Escobar
|
|
17
|
-
* @date 2023-02-11
|
|
18
|
-
* @beta
|
|
19
|
-
* @link
|
|
20
|
-
*/
|
|
21
|
-
function FormatterProvider(props: FormatterProviderProps) {
|
|
22
|
-
const { children, isMicroFrontEnd, currencyFormatter, numberFormatter, dateFormatter } = props;
|
|
23
|
-
|
|
24
|
-
const currencyDecimalDigits = currencyFormatter?.decimalDigits || 0;
|
|
25
|
-
const currencyCode = currencyFormatter?.code || 'USD';
|
|
26
|
-
|
|
27
|
-
const decimalSymbol = numberFormatter?.decimalSymbol || (0.1).toLocaleString().substring(1, 2);
|
|
28
|
-
const thousandsSymbol =
|
|
29
|
-
numberFormatter?.thousandsSymbol || (1000).toLocaleString().substring(1, 2);
|
|
30
|
-
|
|
31
|
-
const dateFormat = dateFormatter?.dateFormat || 'yyyy-MM-dd';
|
|
32
|
-
const dateMask = dateFormatter?.dateMask || '____-__-__';
|
|
33
|
-
|
|
34
|
-
const datetimeFormat = dateFormatter?.datetimeFormat || 'yyyy-MM-dd HH:mm:ss';
|
|
35
|
-
const datetimeMask = dateFormatter?.datetimeMask || '____-__-__ __:__:__';
|
|
36
|
-
|
|
37
|
-
const timeFormat = dateFormatter?.timeFormat || 'HH:mm:ss';
|
|
38
|
-
const timeMask = dateFormatter?.timeMask || '__:__:__';
|
|
39
|
-
|
|
40
|
-
const formatDate =
|
|
41
|
-
dateFormatter?.formatDate ||
|
|
42
|
-
(() => {
|
|
43
|
-
throw new Error('Incorrect use of formatDate');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const firstRender = useFirstRender();
|
|
47
|
-
const { events_emit } = useHostTools();
|
|
48
|
-
const [currentFormatterValues, setCurrentFormatterValues] = useState<Formatters>({
|
|
49
|
-
currencyFormatter: {
|
|
50
|
-
decimalDigits: currencyDecimalDigits,
|
|
51
|
-
code: currencyCode,
|
|
52
|
-
},
|
|
53
|
-
numberFormatter: { decimalSymbol, thousandsSymbol },
|
|
54
|
-
dateFormatter: {
|
|
55
|
-
dateFormat,
|
|
56
|
-
dateMask,
|
|
57
|
-
datetimeFormat,
|
|
58
|
-
datetimeMask,
|
|
59
|
-
timeFormat,
|
|
60
|
-
timeMask,
|
|
61
|
-
formatDate,
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const onChangeFormatter = useCallback((newFormmaterValues: Formatters) => {
|
|
66
|
-
setCurrentFormatterValues(newFormmaterValues);
|
|
67
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
|
-
}, []);
|
|
69
|
-
|
|
70
|
-
//Matricular la propagación hacia los microfronends
|
|
71
|
-
usePropageteMF({
|
|
72
|
-
isMicroFrontEnd,
|
|
73
|
-
event: EmitEvents.EMMIT_EVENT_HOST_FORMATTER_CHANGE,
|
|
74
|
-
setHandler: onChangeFormatter,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (isMicroFrontEnd) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (firstRender) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const newFormatterValues: Formatters = {
|
|
87
|
-
currencyFormatter: { decimalDigits: currencyDecimalDigits, code: currencyCode },
|
|
88
|
-
numberFormatter: { decimalSymbol, thousandsSymbol },
|
|
89
|
-
dateFormatter: {
|
|
90
|
-
dateFormat,
|
|
91
|
-
dateMask,
|
|
92
|
-
datetimeFormat,
|
|
93
|
-
datetimeMask,
|
|
94
|
-
timeFormat,
|
|
95
|
-
timeMask,
|
|
96
|
-
formatDate,
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
setCurrentFormatterValues(newFormatterValues);
|
|
101
|
-
|
|
102
|
-
events_emit(EmitEvents.EMMIT_EVENT_HOST_FORMATTER_CHANGE, newFormatterValues);
|
|
103
|
-
|
|
104
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
105
|
-
}, [
|
|
106
|
-
firstRender,
|
|
107
|
-
currencyCode,
|
|
108
|
-
currencyDecimalDigits,
|
|
109
|
-
decimalSymbol,
|
|
110
|
-
thousandsSymbol,
|
|
111
|
-
dateFormat,
|
|
112
|
-
dateMask,
|
|
113
|
-
datetimeFormat,
|
|
114
|
-
datetimeMask,
|
|
115
|
-
timeFormat,
|
|
116
|
-
timeMask,
|
|
117
|
-
formatDate,
|
|
118
|
-
]);
|
|
119
|
-
|
|
120
|
-
return (
|
|
121
|
-
<FormatterContext.Provider
|
|
122
|
-
value={{
|
|
123
|
-
...currentFormatterValues,
|
|
124
|
-
}}
|
|
125
|
-
>
|
|
126
|
-
{children}
|
|
127
|
-
</FormatterContext.Provider>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export { FormatterProvider, FormatterContext };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { Locale } from 'date-fns';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
export interface CurrencyFormatter {
|
|
5
|
-
code: string;
|
|
6
|
-
// symbol: string;
|
|
7
|
-
decimalDigits: number;
|
|
8
|
-
}
|
|
9
|
-
export interface NumberFormatter {
|
|
10
|
-
decimalSymbol: string;
|
|
11
|
-
thousandsSymbol: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @author
|
|
15
|
-
*/
|
|
16
|
-
export interface DateFormatter {
|
|
17
|
-
dateFormat: string;
|
|
18
|
-
datetimeFormat: string;
|
|
19
|
-
dateMask: string;
|
|
20
|
-
datetimeMask: string;
|
|
21
|
-
timeFormat: string;
|
|
22
|
-
timeMask: string;
|
|
23
|
-
|
|
24
|
-
formatDate: (date: Date | number, format: string, options?: any) => string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface OptionalDateFormatter {
|
|
28
|
-
dateFormat?: string;
|
|
29
|
-
datetimeFormat?: string;
|
|
30
|
-
dateMask?: string;
|
|
31
|
-
datetimeMask?: string;
|
|
32
|
-
timeFormat?: string;
|
|
33
|
-
timeMask?: string;
|
|
34
|
-
|
|
35
|
-
formatDate: (
|
|
36
|
-
date: Date | number,
|
|
37
|
-
format: string,
|
|
38
|
-
options?: {
|
|
39
|
-
locale?: Locale;
|
|
40
|
-
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
41
|
-
firstWeekContainsDate?: number;
|
|
42
|
-
useAdditionalWeekYearTokens?: boolean;
|
|
43
|
-
useAdditionalDayOfYearTokens?: boolean;
|
|
44
|
-
},
|
|
45
|
-
) => string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface Formatters {
|
|
49
|
-
currencyFormatter: CurrencyFormatter;
|
|
50
|
-
dateFormatter: DateFormatter;
|
|
51
|
-
numberFormatter: NumberFormatter;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface OptionalFormatters {
|
|
55
|
-
//Formatos asociados a la moneda
|
|
56
|
-
currencyFormatter?: CurrencyFormatter;
|
|
57
|
-
//Formatos asociados a los numeros
|
|
58
|
-
dateFormatter?: OptionalDateFormatter;
|
|
59
|
-
//Formatos asociados a las fechas
|
|
60
|
-
numberFormatter?: NumberFormatter;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* @interface
|
|
64
|
-
*/
|
|
65
|
-
export interface FormatterProviderProps extends OptionalFormatters {
|
|
66
|
-
//Propiedad que permite identificar el rol del componente, si es host hay algun cambio de algun parametro, lo propaga a los MFs, de lo contrario, esta escuchando los cambios del host
|
|
67
|
-
isMicroFrontEnd: boolean;
|
|
68
|
-
|
|
69
|
-
//Componentes a los que se va a dar cobertura
|
|
70
|
-
children: ReactNode;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export type FormatterContextProps = Formatters;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { createContext, useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { CssBaseline } from '@mui/material';
|
|
3
|
-
import {
|
|
4
|
-
ThemeOptions,
|
|
5
|
-
createTheme,
|
|
6
|
-
ThemeProvider as MUIThemeProvider,
|
|
7
|
-
StyledEngineProvider,
|
|
8
|
-
} from '@mui/material/styles';
|
|
9
|
-
|
|
10
|
-
// muis
|
|
11
|
-
// hooks
|
|
12
|
-
// utils
|
|
13
|
-
// config
|
|
14
|
-
// @type
|
|
15
|
-
import { HostThemeContextType, HostThemeProviderProps } from './types';
|
|
16
|
-
import { EmitEvents, useHostTools } from '@m4l/core';
|
|
17
|
-
|
|
18
|
-
// ----------------------------------------------------------------------
|
|
19
|
-
|
|
20
|
-
const HostThemeContext = createContext<HostThemeContextType | null>(null);
|
|
21
|
-
|
|
22
|
-
function HostThemeProvider(props: HostThemeProviderProps) {
|
|
23
|
-
const { children, hostThemeOptions, fnComponentsOverrides, isMicroFrontEnd } = props;
|
|
24
|
-
const [finalThemeOptions, setFinalThemeOptions] = useState<ThemeOptions>(hostThemeOptions);
|
|
25
|
-
const { events_add_listener, events_remove_listener, events_emit } = useHostTools();
|
|
26
|
-
const [isFirstTime, setIsFirstTime] = useState(true);
|
|
27
|
-
|
|
28
|
-
const finalTheme = useMemo(() => {
|
|
29
|
-
const theme = createTheme(finalThemeOptions);
|
|
30
|
-
theme.components = fnComponentsOverrides(theme);
|
|
31
|
-
return theme;
|
|
32
|
-
}, [finalThemeOptions]);
|
|
33
|
-
|
|
34
|
-
const onUpdateOverrides = useCallback((newThemeOptions: ThemeOptions) => {
|
|
35
|
-
setFinalThemeOptions(newThemeOptions);
|
|
36
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
-
}, []);
|
|
38
|
-
|
|
39
|
-
//Matricular el cambio de tema si es
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (isMicroFrontEnd) {
|
|
42
|
-
events_add_listener(EmitEvents.EMMIT_EVENT_HOST_THEME_CHANGE, onUpdateOverrides);
|
|
43
|
-
}
|
|
44
|
-
return () => {
|
|
45
|
-
if (isMicroFrontEnd) {
|
|
46
|
-
events_remove_listener(EmitEvents.EMMIT_EVENT_HOST_THEME_CHANGE, onUpdateOverrides);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
|
-
//Cuando cambie las opciones del tema debido al usuario
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (isFirstTime) {
|
|
54
|
-
setIsFirstTime(false);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (!isMicroFrontEnd) {
|
|
59
|
-
setFinalThemeOptions(hostThemeOptions);
|
|
60
|
-
events_emit(EmitEvents.EMMIT_EVENT_HOST_THEME_CHANGE, hostThemeOptions);
|
|
61
|
-
}
|
|
62
|
-
}, [hostThemeOptions]);
|
|
63
|
-
|
|
64
|
-
// const updateHostThemeOptions = useCallback((newThemeOptions: ThemeOptions) => {
|
|
65
|
-
// setFinalThemeOptions(newThemeOptions);
|
|
66
|
-
// }, []);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<HostThemeContext.Provider
|
|
70
|
-
value={{
|
|
71
|
-
hostThemeOptions: finalThemeOptions,
|
|
72
|
-
fnComponentsOverrides,
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
75
|
-
<StyledEngineProvider injectFirst>
|
|
76
|
-
<MUIThemeProvider theme={finalTheme}>
|
|
77
|
-
<CssBaseline enableColorScheme />
|
|
78
|
-
{children}
|
|
79
|
-
</MUIThemeProvider>
|
|
80
|
-
</StyledEngineProvider>
|
|
81
|
-
</HostThemeContext.Provider>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export { HostThemeProvider, HostThemeContext };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ThemeOptions, Theme } from '@mui/material/styles';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
export type EventFunListener = (...args: any[]) => void;
|
|
5
|
-
|
|
6
|
-
export interface HostThemeType {
|
|
7
|
-
hostThemeOptions: ThemeOptions;
|
|
8
|
-
fnComponentsOverrides: (theme: Theme) => any;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface HostThemeProviderProps extends HostThemeType {
|
|
12
|
-
isMicroFrontEnd: boolean;
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type HostThemeContextType = HostThemeType;
|