@m4l/graphics 0.1.0 → 0.1.4

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.
@@ -37,7 +37,6 @@ function HostThemeProvider(props) {
37
37
  }
38
38
  return () => {
39
39
  if (isMicroFrontEnd) {
40
- console.log("****** REMOVE LISTENER host_theme_change");
41
40
  events_remove_listener("host_theme_change", onUpdateOverrides);
42
41
  }
43
42
  };
@@ -7,7 +7,7 @@ export declare type LangType = {
7
7
  icon: string;
8
8
  };
9
9
  export declare type LocalesContextProps = {
10
- currentLang: any;
10
+ currentLang: LangType;
11
11
  onChangeLang: (newlang: string) => void;
12
12
  allLang: Array<LangType>;
13
13
  };
@@ -33,10 +33,11 @@ function LocalesProvider({
33
33
  }], []);
34
34
  const [currentLang, setCurrentLang] = useState(LANGS.find((_lang) => _lang.value === langStorage) || LANGS[0]);
35
35
  const onChangeLang = (newlang) => {
36
+ console.log("onChangeLang", newlang);
36
37
  setLangStorage(newlang);
37
38
  setCurrentLang(LANGS.find((_lang) => _lang.value === newlang) || LANGS[0]);
38
- console.log("new lagn", newlang, currentLang);
39
39
  };
40
+ console.log("Render LocalesProvider", langStorage);
40
41
  return /* @__PURE__ */ jsx(LocalesContext.Provider, {
41
42
  value: {
42
43
  currentLang,
package/index.d.ts CHANGED
@@ -6,5 +6,9 @@ export type { GradientsPaletteOptions } from './theme/palette';
6
6
  export type { ChartPaletteOptions } from './theme/palette';
7
7
  export type { GridPaletteOptions } from './theme/palette';
8
8
  export { defaultThemeOptions } from './theme/defaultThemeOptions';
9
+ export { shadows, customShadows } from './theme/shadows';
10
+ export { palette, type ColorSchema } from './theme/palette';
11
+ export { getColorPresets, colorPresets, defaultPreset } from './utils/getColorPresets';
12
+ export { getFontValue as GetFontValue } from './utils/getFontValue';
9
13
  export { default as fnComponentsOverrides } from './theme/overrides';
10
14
  export type { HostThemeType } from './types';
package/index.js CHANGED
@@ -6,6 +6,9 @@ export { u as useIsMountedRef, a as useOffSetTop } from "./hooks/index.js";
6
6
  export { u as useLocales } from "./hooks/useLocales/index.js";
7
7
  export { u as useHostTheme } from "./hooks/useHostTheme/index.js";
8
8
  export { d as defaultThemeOptions } from "./theme/defaultThemeOptions.js";
9
+ export { c as customShadows, s as shadows } from "./theme/shadows.js";
10
+ export { p as palette } from "./theme/palette.js";
11
+ export { a as GetFontValue, c as colorPresets, d as defaultPreset, g as getColorPresets } from "./utils/index.js";
9
12
  export { f as fnComponentsOverrides } from "./theme/overrides.js";
10
13
  import "@mui/material/styles";
11
14
  import "@mui/material";
@@ -19,6 +22,3 @@ import "date-fns/locale/en-US";
19
22
  import "@m4l/core";
20
23
  import "@mui/material/useMediaQuery";
21
24
  import "./theme/typography.js";
22
- import "./utils/index.js";
23
- import "./theme/palette.js";
24
- import "./theme/shadows.js";
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "@m4l/graphics",
3
- "version": "0.1.0",
3
+ "version": "0.1.4",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team",
6
6
  "dependencies": {
7
7
  "@m4l/core": "*",
8
- "@mui/material": "^5.8.7",
9
8
  "@mui/x-date-pickers": "^5.0.0-beta.3",
10
- "date-fns": "^2.29.2",
11
- "react": "^17.0.0 || 18.x"
9
+ "date-fns": "^2.29.2"
10
+ },
11
+ "peerDependencies": {
12
+ "@mui/material": "^5.10.4",
13
+ "@mui/system": "^5.10.4",
14
+ "@types/react": "^17.0.0 || ^18.0.0",
15
+ "react": "^17.0.0 || ^18.0.0",
16
+ "react-dom": "^17.0.0 || ^18.0.0"
12
17
  },
13
18
  "files": [
14
19
  "*"
@@ -320,3 +320,4 @@ export declare const palette: {
320
320
  readonly divider: string;
321
321
  };
322
322
  };
323
+ export default palette;
@@ -60,7 +60,7 @@ export declare const customShadows: {
60
60
  dropdown: string;
61
61
  };
62
62
  };
63
- declare const shadows: {
63
+ export declare const shadows: {
64
64
  light: Shadows;
65
65
  dark: Shadows;
66
66
  };
@@ -146,7 +146,7 @@ export declare const redPreset: {
146
146
  darker: string;
147
147
  contrastText: string;
148
148
  };
149
- export default function getColorPresets(presetsKey: ThemeColorPresets): {
149
+ export declare function getColorPresets(presetsKey: ThemeColorPresets): {
150
150
  LightSelected: string;
151
151
  LightSelectedHover: string;
152
152
  DarkSelected: string;
@@ -167,3 +167,4 @@ export default function getColorPresets(presetsKey: ThemeColorPresets): {
167
167
  darker: string;
168
168
  contrastText: string;
169
169
  };
170
+ export default getColorPresets;
@@ -16,7 +16,7 @@ export declare function responsiveFontSizes({ sm, md, lg }: {
16
16
  fontSize: string;
17
17
  };
18
18
  };
19
- export declare function GetFontValue(variant: Variant): {
19
+ export declare function getFontValue(variant: Variant): {
20
20
  fontSize: number;
21
21
  lineHeight: number;
22
22
  fontWeight: import("csstype").Property.FontWeight | undefined;
package/utils/index.js CHANGED
@@ -1,6 +1,9 @@
1
- import "@mui/material/styles";
2
- import "@mui/material/useMediaQuery";
1
+ import { useTheme } from "@mui/material/styles";
2
+ import { u as useResponsive } from "../hooks/useResponsive/index.js";
3
3
  import { p as palette } from "../theme/palette.js";
4
+ function remToPx(value) {
5
+ return Math.round(parseFloat(value) * 16);
6
+ }
4
7
  function pxToRem(value) {
5
8
  return `${value / 16}rem`;
6
9
  }
@@ -17,6 +20,25 @@ function responsiveFontSizes({ sm, md, lg }) {
17
20
  }
18
21
  };
19
22
  }
23
+ function useWidth() {
24
+ const theme = useTheme();
25
+ const keys = [...theme.breakpoints.keys].reverse();
26
+ return keys.reduce((output, key) => {
27
+ const matches = useResponsive("up", key);
28
+ return !output && matches ? key : output;
29
+ }, null) || "xs";
30
+ }
31
+ function getFontValue(variant) {
32
+ const theme = useTheme();
33
+ const breakpoints = useWidth();
34
+ const key = theme.breakpoints.up(breakpoints === "xl" ? "lg" : breakpoints);
35
+ const hasResponsive = variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "h5" || variant === "h6";
36
+ const getFont = hasResponsive && theme.typography[variant][key] ? theme.typography[variant][key] : theme.typography[variant];
37
+ const fontSize = remToPx(getFont.fontSize);
38
+ const lineHeight = Number(theme.typography[variant].lineHeight) * fontSize;
39
+ const { fontWeight, letterSpacing } = theme.typography[variant];
40
+ return { fontSize, lineHeight, fontWeight, letterSpacing };
41
+ }
20
42
  const colorPresets = [
21
43
  {
22
44
  name: "default",
@@ -88,4 +110,4 @@ function getColorPresets(presetsKey) {
88
110
  default: defaultPreset
89
111
  }[presetsKey];
90
112
  }
91
- export { getColorPresets as g, pxToRem as p, responsiveFontSizes as r };
113
+ export { getFontValue as a, colorPresets as c, defaultPreset as d, getColorPresets as g, pxToRem as p, responsiveFontSizes as r };