@m4l/graphics 0.1.51 → 0.1.53

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.
@@ -0,0 +1,9 @@
1
+ import "react";
2
+ var l = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
3
+ function t(e) {
4
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
5
+ }
6
+ export {
7
+ l as c,
8
+ t as g
9
+ };
@@ -0,0 +1,4 @@
1
+ import "@mui/material/styles";
2
+ import "@mui/material";
3
+ import "@m4l/styles";
4
+ import "react/jsx-runtime";
@@ -0,0 +1,2 @@
1
+ import { BreakPointsType } from "./types";
2
+ export declare const BREAKPOINTS: BreakPointsType;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { ResponsiveContainerProviderProps } from './types';
3
+ declare const ResponsiveContainerContext: import("react").Context<(Omit<Omit<import("zustand").StoreApi<import("./types").ResponsiveContainerStateWithActions>, "setState"> & {
4
+ setState<A extends string | {
5
+ type: unknown;
6
+ }>(partial: import("./types").ResponsiveContainerStateWithActions | Partial<import("./types").ResponsiveContainerStateWithActions> | ((state: import("./types").ResponsiveContainerStateWithActions) => import("./types").ResponsiveContainerStateWithActions | Partial<import("./types").ResponsiveContainerStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
7
+ }, "setState"> & {
8
+ setState(nextStateOrUpdater: import("./types").ResponsiveContainerStateWithActions | Partial<import("./types").ResponsiveContainerStateWithActions> | ((state: import("immer/dist/internal").WritableDraft<import("./types").ResponsiveContainerStateWithActions>) => void), shouldReplace?: boolean | undefined, action?: string | {
9
+ type: unknown;
10
+ } | undefined): void;
11
+ }) | null>;
12
+ declare const ResponsiveContainerProvider: (props: ResponsiveContainerProviderProps) => import("react").JSX.Element;
13
+ export { ResponsiveContainerProvider, ResponsiveContainerContext };
@@ -0,0 +1,11 @@
1
+ import { InitialResponsiveContainerProps, ResponsiveContainerStateWithActions } from './types';
2
+ export declare const createResponsiveContainerStore: (initProps: InitialResponsiveContainerProps) => Omit<Omit<import("zustand").StoreApi<ResponsiveContainerStateWithActions>, "setState"> & {
3
+ setState<A extends string | {
4
+ type: unknown;
5
+ }>(partial: ResponsiveContainerStateWithActions | Partial<ResponsiveContainerStateWithActions> | ((state: ResponsiveContainerStateWithActions) => ResponsiveContainerStateWithActions | Partial<ResponsiveContainerStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
6
+ }, "setState"> & {
7
+ setState(nextStateOrUpdater: ResponsiveContainerStateWithActions | Partial<ResponsiveContainerStateWithActions> | ((state: import("immer/dist/internal").WritableDraft<ResponsiveContainerStateWithActions>) => void), shouldReplace?: boolean | undefined, action?: string | {
8
+ type: unknown;
9
+ } | undefined): void;
10
+ };
11
+ export declare type ResponsiveContainerStore = ReturnType<typeof createResponsiveContainerStore>;
@@ -0,0 +1,28 @@
1
+ /// <reference types="react" />
2
+ export declare type BreakpointType = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
3
+ export declare type BreakPointsType = Record<BreakpointType, number>;
4
+ export interface ResponsiveRelativeContextProps {
5
+ breakPoint: BreakpointType;
6
+ }
7
+ export interface ResponsiveContainerProviderProps {
8
+ observedDivRef: Element | Text | null;
9
+ children: React.ReactNode;
10
+ }
11
+ export declare type CurrentState = {
12
+ width: number;
13
+ height: number;
14
+ mounted: boolean;
15
+ breakpoint: BreakpointType;
16
+ };
17
+ export interface ResponsiveContainerState {
18
+ breakPoint: BreakpointType;
19
+ isUpSm: boolean;
20
+ isXs: boolean;
21
+ }
22
+ export interface InitialResponsiveContainerProps extends Pick<ResponsiveContainerState, 'breakPoint' | 'isUpSm' | 'isXs'> {
23
+ }
24
+ export interface ResponsiveContainerStateWithActions extends ResponsiveContainerState {
25
+ responsiveContainerActions: {
26
+ setBreakpoint: (breakPoint: BreakpointType) => void;
27
+ };
28
+ }
@@ -0,0 +1,76 @@
1
+ import "./FormatterContext/index.92336f4c.js";
2
+ import "./LocalesContext/index.53f0b702.js";
3
+ import { createContext as d, useRef as p, useMemo as v, useLayoutEffect as f } from "react";
4
+ import { c as u, d as R, i as g, l as h } from "../node_modules.dbab0abd.js";
5
+ import { jsx as x } from "react/jsx-runtime";
6
+ import "date-fns/locale/en-US";
7
+ import "./HostThemeContext/index.4291ba89.js";
8
+ const m = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, S = (c) => {
9
+ const a = {
10
+ ...c
11
+ };
12
+ return u(
13
+ R(
14
+ g((r, t) => ({
15
+ ...a,
16
+ responsiveContainerActions: {
17
+ setBreakpoint: (e) => {
18
+ r(
19
+ (i) => {
20
+ console.log("current breakpoint", e), i.breakPoint = e, i.isUpSm = e !== "xs" && e !== "sm", i.isXs = e == "xs";
21
+ }
22
+ );
23
+ }
24
+ }
25
+ })),
26
+ { name: "Responsive Relative Store" }
27
+ )
28
+ );
29
+ }, b = d(null), A = (c) => {
30
+ const {
31
+ children: a,
32
+ observedDivRef: r
33
+ } = c, t = p();
34
+ t.current || (t.current = S({
35
+ breakPoint: "md",
36
+ isUpSm: !1,
37
+ isXs: !1
38
+ }));
39
+ const e = () => {
40
+ const o = r;
41
+ if (o instanceof HTMLElement && o.clientWidth) {
42
+ const s = Object.keys(m);
43
+ for (let n = 0; n < s.length; n++) {
44
+ const l = s[n];
45
+ if (o.clientWidth <= m[l]) {
46
+ t.current?.getState().responsiveContainerActions.setBreakpoint(l);
47
+ break;
48
+ }
49
+ }
50
+ console.log("node.clientWidth", o.clientWidth), console.log("onResizeMemo", t.current?.getState().breakPoint);
51
+ }
52
+ }, i = v(() => h.exports.throttle(e, 200, {
53
+ leading: !1,
54
+ trailing: !0
55
+ }), [e]);
56
+ return f(() => {
57
+ const o = () => {
58
+ i();
59
+ }, s = r;
60
+ if (s && s instanceof Element) {
61
+ const n = new ResizeObserver((l) => {
62
+ o();
63
+ });
64
+ return n.observe(s), () => {
65
+ n.disconnect();
66
+ };
67
+ }
68
+ }, [r]), /* @__PURE__ */ x(b.Provider, {
69
+ value: t.current,
70
+ children: a
71
+ });
72
+ };
73
+ export {
74
+ b as R,
75
+ A as a
76
+ };
@@ -1,6 +1,8 @@
1
1
  export * from './FormatterContext';
2
2
  export type { Formatters, DateFormatter, NumberFormatter, CurrencyFormatter, } from './FormatterContext/types';
3
3
  export * from './LocalesContext';
4
+ export * from './ResponsiveContainerContext';
5
+ export type { BreakpointType } from './ResponsiveContainerContext/types';
4
6
  export type { NetworkLocaleType, LocaleType } from './LocalesContext/types';
5
7
  export { getLocaleFromNetwork } from './LocalesContext/helper';
6
8
  export * from './HostThemeContext';
@@ -0,0 +1,49 @@
1
+ import { useRef as r, useEffect as n, useState as f, useContext as i, useLayoutEffect as c } from "react";
2
+ import { H as m } from "../contexts/HostThemeContext/index.4291ba89.js";
3
+ import "../contexts/FormatterContext/index.92336f4c.js";
4
+ import "../contexts/LocalesContext/index.53f0b702.js";
5
+ import "../contexts/index.921576cc.js";
6
+ import "@m4l/styles";
7
+ function b() {
8
+ const e = r(!0);
9
+ return n(
10
+ () => () => {
11
+ e.current = !1;
12
+ },
13
+ []
14
+ ), e;
15
+ }
16
+ function h(e) {
17
+ const [o, t] = f(!1), s = e || 100;
18
+ return n(() => (window.onscroll = () => {
19
+ window.pageYOffset > s ? t(!0) : t(!1);
20
+ }, () => {
21
+ window.onscroll = null;
22
+ }), [s]), o;
23
+ }
24
+ const v = () => {
25
+ const e = i(m);
26
+ if (!e)
27
+ throw new Error("useHostTheme context must be use inside HostThemeProvider");
28
+ return e;
29
+ };
30
+ function x(e) {
31
+ const o = r(null);
32
+ return c(() => {
33
+ const t = o?.current;
34
+ if (!t)
35
+ return;
36
+ const s = new ResizeObserver((u) => {
37
+ e(t, u[0]);
38
+ });
39
+ return s.observe(t), () => {
40
+ s.disconnect();
41
+ };
42
+ }, [e, o.current]), o;
43
+ }
44
+ export {
45
+ h as a,
46
+ v as b,
47
+ x as c,
48
+ b as u
49
+ };
package/hooks/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { useFirstRender } from './useFirstRender';
2
2
  export { useFormatter } from './useFormatter';
3
3
  export { useIsMountedRef } from './useIsMountedRef';
4
4
  export { useLocales } from './useLocales';
5
+ export { useResponsiveContainerStore } from './useResponsiveContainer';
5
6
  export { useOffSetTop } from './useOffSetTop';
6
7
  export { useHostTheme } from './useHostTheme';
7
8
  export { useResizeObserver } from './useResizeObserver';
@@ -0,0 +1,17 @@
1
+ import { useContext as t } from "react";
2
+ import { u as r } from "../../node_modules.dbab0abd.js";
3
+ import { R as n } from "../../contexts/index.921576cc.js";
4
+ import { useResponsive as i } from "@m4l/styles";
5
+ function f(e, s) {
6
+ const o = t(n);
7
+ if (!o)
8
+ throw new Error("useAreasStore context must be use inside AreasContext");
9
+ return r(o, e, s);
10
+ }
11
+ function c() {
12
+ return i("up", "sm");
13
+ }
14
+ export {
15
+ c as a,
16
+ f as u
17
+ };
@@ -0,0 +1,2 @@
1
+ import { ResponsiveContainerStateWithActions } from '../../contexts/ResponsiveContainerContext/types';
2
+ export declare function useResponsiveContainerStore<T>(selector: (state: ResponsiveContainerStateWithActions) => T, equalityFn?: (left: T, right: T) => boolean): T;
package/index.js CHANGED
@@ -1,39 +1,45 @@
1
- import { G as x } from "./components/GlobalStyle/index.fff91e86.js";
2
- import { L as n, a as c, g as d } from "./contexts/LocalesContext/index.53f0b702.js";
3
- import { F as v, a as C } from "./contexts/FormatterContext/index.92336f4c.js";
4
- import { H as g, a as h } from "./contexts/HostThemeContext/index.4291ba89.js";
5
- import { u as P } from "./hooks/useFirstRender/index.1e9b02fb.js";
6
- import { u as T } from "./hooks/useFormatter/index.57ac8cca.js";
7
- import { b as k, u as w, a as z, c as G } from "./hooks/index.33d67709.js";
8
- import { u as S } from "./hooks/useLocales/index.d5a80aff.js";
9
- import { u as A } from "./hooks/useResponsive/index.1409e387.js";
10
- import { C as E, g as I } from "./utils/index.6909c662.js";
1
+ import { G as l } from "./components/GlobalStyle/index.fff91e86.js";
2
+ import { F as C, a as R } from "./contexts/FormatterContext/index.92336f4c.js";
3
+ import { L as c, a as F, g as L } from "./contexts/LocalesContext/index.53f0b702.js";
4
+ import { R as g, a as h } from "./contexts/index.921576cc.js";
5
+ import { H as T, a as b } from "./contexts/HostThemeContext/index.4291ba89.js";
6
+ import { u as k } from "./hooks/useFirstRender/index.1e9b02fb.js";
7
+ import { u as z } from "./hooks/useFormatter/index.57ac8cca.js";
8
+ import { b as O, u as y, a as A, c as D } from "./hooks/index.66afb19b.js";
9
+ import { u as I } from "./hooks/useLocales/index.d5a80aff.js";
10
+ import { u as N, a as W } from "./hooks/useResponsive/index.c9515afc.js";
11
+ import { C as q, g as B } from "./utils/index.6909c662.js";
11
12
  import "@mui/material/styles";
12
13
  import "@mui/material";
13
14
  import "@m4l/styles";
14
15
  import "react/jsx-runtime";
15
16
  import "react";
17
+ import "@m4l/core";
16
18
  import "@mui/x-date-pickers/AdapterDateFns";
17
19
  import "@mui/x-date-pickers";
18
- import "@m4l/core";
19
20
  import "date-fns/locale/en-US";
21
+ import "./node_modules.dbab0abd.js";
22
+ import "./commonjs.e3daa2e5.js";
20
23
  export {
21
- E as Capitalize,
22
- v as FormatterContext,
23
- C as FormatterProvider,
24
- x as GlobalStyles,
25
- g as HostThemeContext,
26
- h as HostThemeProvider,
27
- n as LocalesContext,
28
- c as LocalesProvider,
29
- I as getAnchorElPositionWindow,
30
- d as getLocaleFromNetwork,
31
- P as useFirstRender,
32
- T as useFormatter,
33
- k as useHostTheme,
34
- w as useIsMountedRef,
35
- S as useLocales,
36
- z as useOffSetTop,
37
- G as useResizeObserver,
38
- A as useResponsiveDesktop
24
+ q as Capitalize,
25
+ C as FormatterContext,
26
+ R as FormatterProvider,
27
+ l as GlobalStyles,
28
+ T as HostThemeContext,
29
+ b as HostThemeProvider,
30
+ c as LocalesContext,
31
+ F as LocalesProvider,
32
+ g as ResponsiveContainerContext,
33
+ h as ResponsiveContainerProvider,
34
+ B as getAnchorElPositionWindow,
35
+ L as getLocaleFromNetwork,
36
+ k as useFirstRender,
37
+ z as useFormatter,
38
+ O as useHostTheme,
39
+ y as useIsMountedRef,
40
+ I as useLocales,
41
+ A as useOffSetTop,
42
+ D as useResizeObserver,
43
+ N as useResponsiveContainerStore,
44
+ W as useResponsiveDesktop
39
45
  };