@m4l/graphics 7.0.14 → 7.0.16-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.
@@ -1,7 +1,7 @@
1
1
  import { createStore as S } from "zustand";
2
2
  import { devtools as c } from "zustand/middleware";
3
3
  import { immer as p } from "zustand/middleware/immer";
4
- import { getPaletteByPreset as a, typographyOld as d, shadows as h, getColorPresets as u, createCustomShadows as f } from "@m4l/styles";
4
+ import { getPaletteByPreset as a, createCustomShadows as d, shadows as h, typographyOld as u, getColorPresets as f } from "@m4l/styles";
5
5
  import { alpha as U } from "@mui/system";
6
6
  import { d as s } from "./constants.js";
7
7
  function g(r, o = "m4l") {
@@ -18,7 +18,7 @@ const n = (r) => {
18
18
  const o = r.themeUserSettings || s, m = o.themeMode === "light", t = a(o.themeColor), e = m ? t.light : t.dark;
19
19
  r.themeOptions = {
20
20
  ...r.themeOptions,
21
- ...d,
21
+ ...u,
22
22
  palette: {
23
23
  ...r.themeOptions?.palette ?? {},
24
24
  ...e
@@ -28,10 +28,10 @@ const n = (r) => {
28
28
  shadows: m ? h.light : h.dark,
29
29
  customShadows: {
30
30
  primary: `0 8px 16px 0 ${U(
31
- u(o.themeColor)?.main || "#fff",
31
+ f(o.themeColor)?.main || "#fff",
32
32
  0.2
33
33
  )}`,
34
- ...f(o.themeMode)
34
+ ...d(o.themeMode)
35
35
  },
36
36
  stretch: o.themeStretch
37
37
  }, g(r.themeOptions);
package/hooks/index.d.ts CHANGED
@@ -11,3 +11,4 @@ export { useResizeObserver } from './useResizeObserver';
11
11
  export { useResponsiveDesktop } from './useResponsive';
12
12
  export { useThemeSettingsStore } from './useThemSettingsStore';
13
13
  export { usePaginate } from './usePaginate';
14
+ export { useRows } from './useRows';
@@ -0,0 +1,11 @@
1
+ import { UseRowsProps } from './types';
2
+ /**
3
+ * Hook para obtener las filas de la lista de elementos
4
+ */
5
+ export declare const useRows: <TRow>(props: UseRowsProps<TRow>) => {
6
+ rows: unknown[];
7
+ clearRows: () => void;
8
+ refresh: () => void;
9
+ setRows: (rows: TRow[]) => void;
10
+ loading: boolean;
11
+ };
@@ -0,0 +1,70 @@
1
+ import { useReducer as D, useRef as F, useCallback as i, useEffect as u } from "react";
2
+ import { useHostTools as I, useNetwork as W, useModuleSkeleton as b, useModuleDictionary as A } from "@m4l/core";
3
+ import { u as G } from "../useFirstRender/index.js";
4
+ import { r as M, g as H, s as q } from "./state.js";
5
+ const v = (R) => {
6
+ const {
7
+ endPoint: y,
8
+ timeout: m = 5e3,
9
+ queryParams: s,
10
+ fireOnChangeParms: n = !1,
11
+ fireOnFirstLoad: S = !0,
12
+ startProgress: g,
13
+ stopProgress: h,
14
+ isRemote: E = !0,
15
+ bodyToSnakeCase: P = !1,
16
+ responseToCamelCase: O = !1,
17
+ initialRows: T = [],
18
+ onNetworkError: l,
19
+ refreshOnChangeDictionary: c = !1
20
+ } = R, [t, e] = D(
21
+ M,
22
+ H(n, S, T)
23
+ ), { startProgress: w, stopProgress: C } = I(), { networkOperation: k } = W(), f = b(), { getLabel: _ } = A(), p = F(s), d = G([s]), r = i(() => {
24
+ e({ type: "INCREMENT_REFRESH" });
25
+ }, []);
26
+ u(() => {
27
+ q(d, t, s, p.current, n) && r(), p.current = s;
28
+ }, [s, d, t, n, r]), u(() => {
29
+ let o = !0;
30
+ if (t.countRefresh !== 0)
31
+ return e({ type: "SET_LOADING", payload: !0 }), k({
32
+ method: "GET",
33
+ endPoint: y,
34
+ timeout: m,
35
+ parms: {
36
+ ...s
37
+ },
38
+ bodyToSnakeCase: P,
39
+ responseToCamelCase: O,
40
+ options: {
41
+ startProgress: g || w,
42
+ stopProgress: h || C
43
+ },
44
+ isRemote: E
45
+ }).then((a) => {
46
+ o && e({ type: "SET_ROWS", payload: a.data });
47
+ }).catch((a) => {
48
+ e({ type: "SET_ROWS", payload: [] }), l && l(a.status);
49
+ }).finally(() => {
50
+ e({ type: "SET_LOADING", payload: !1 });
51
+ }), function() {
52
+ o = !1;
53
+ };
54
+ }, [t.countRefresh]), u(() => {
55
+ !f && c && r();
56
+ }, [_, c, f]);
57
+ const N = i(() => {
58
+ e({ type: "CLEAR_ROWS" });
59
+ }, []), L = i((o) => e({ type: "SET_ROWS", payload: o }), [e]);
60
+ return {
61
+ rows: t.rows,
62
+ clearRows: N,
63
+ refresh: r,
64
+ setRows: L,
65
+ loading: t.loading
66
+ };
67
+ };
68
+ export {
69
+ v as u
70
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ export interface State<TRow> {
2
+ countRefresh: number;
3
+ rows: TRow[];
4
+ fireOnFirstLoad: boolean;
5
+ loading: boolean;
6
+ }
7
+ export type Action<TRow> = {
8
+ type: 'INCREMENT_REFRESH';
9
+ } | {
10
+ type: 'SET_ROWS';
11
+ payload: TRow[];
12
+ } | {
13
+ type: 'SET_LOADING';
14
+ payload: boolean;
15
+ } | {
16
+ type: 'CLEAR_ROWS';
17
+ };
18
+ /**
19
+ * Obtiene el estado inicial de la lista de elementos
20
+ */
21
+ export declare const getInitialState: <TRow>(fireOnChangeParms: boolean, fireOnFirstLoad: boolean, initialRows: TRow[]) => State<TRow>;
22
+ /**
23
+ * Reducer para actualizar el estado de la lista de elementos
24
+ */
25
+ export declare const reducer: <TRow>(state: State<TRow>, action: Action<TRow>) => State<TRow>;
26
+ /**
27
+ * Verifica si se debe actualizar la lista de elementos
28
+ */
29
+ export declare const shouldRefresh: <T>(isFirstRender: boolean, state: State<T>, currentParams: any, previousParams: any, fireOnChangeParms: boolean) => boolean;
@@ -0,0 +1,25 @@
1
+ import { d as n } from "../../not_recognized/index.js";
2
+ const t = (r, e, s) => ({
3
+ countRefresh: r ? 1 : 0,
4
+ rows: s,
5
+ fireOnFirstLoad: e,
6
+ loading: !1
7
+ }), f = (r, e) => {
8
+ switch (e.type) {
9
+ case "INCREMENT_REFRESH":
10
+ return { ...r, countRefresh: r.countRefresh + 1 };
11
+ case "SET_ROWS":
12
+ return { ...r, rows: e.payload };
13
+ case "SET_LOADING":
14
+ return { ...r, loading: e.payload };
15
+ case "CLEAR_ROWS":
16
+ return { ...r, rows: [] };
17
+ default:
18
+ return r;
19
+ }
20
+ }, c = (r, e, s, u, o) => !!(r && e.fireOnFirstLoad || !r && !n(u, s) && o);
21
+ export {
22
+ t as g,
23
+ f as r,
24
+ c as s
25
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { AxiosOptions, NetworkProps } from '@m4l/core';
2
+ export interface UseRowsProps<TRow> extends Pick<NetworkProps, 'endPoint' | 'timeout' | 'isRemote' | 'bodyToSnakeCase' | 'responseToCamelCase'>, AxiosOptions {
3
+ fireOnChangeParms?: boolean;
4
+ fireOnFirstLoad?: boolean;
5
+ queryParams: Record<string, unknown>;
6
+ initialRows?: TRow[];
7
+ onNetworkError?: (code: number) => void;
8
+ refreshOnChangeDictionary?: boolean;
9
+ }
package/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { G as r } from "./components/GlobalStyles/index.js";
2
- import { g as s } from "./contexts/LocalesContext/helper.js";
2
+ import { g as t } from "./contexts/LocalesContext/helper.js";
3
3
  import { F as m, a as p } from "./contexts/FormatterContext/index.js";
4
- import { L as f, a as i } from "./contexts/LocalesContext/index.js";
4
+ import { L as u, a as f } from "./contexts/LocalesContext/index.js";
5
5
  import { R as n, a as v } from "./contexts/ResponsiveContainerContext/index.js";
6
6
  import { H as l, a as T } from "./contexts/HostThemeContext/index.js";
7
7
  import { D as c, a as C } from "./contexts/DeviceTypeContext/index.js";
8
- import { d as P } from "./contexts/ThemeSettingsContext/constants.js";
8
+ import { d as h } from "./contexts/ThemeSettingsContext/constants.js";
9
9
  import { T as S, a as F } from "./contexts/ThemeSettingsContext/ThemeSettingsContext.js";
10
10
  import { u as D } from "./hooks/useFirstRender/index.js";
11
11
  import { u as b } from "./hooks/useFormatter/index.js";
12
- import { u as k } from "./hooks/useIsMountedRef/index.js";
12
+ import { u as y } from "./hooks/useIsMountedRef/index.js";
13
13
  import { u as z } from "./hooks/useLocales/index.js";
14
14
  import { u as G } from "./hooks/useResponsiveContainer/index.js";
15
15
  import { u as M } from "./hooks/useUserAgent/index.js";
@@ -20,8 +20,9 @@ import { u as B } from "./hooks/useResizeObserver/index.js";
20
20
  import { u as K } from "./hooks/useResponsive/index.js";
21
21
  import { u as V } from "./hooks/useThemSettingsStore/index.js";
22
22
  import { u as Y } from "./hooks/usePaginate/index.js";
23
- import { c as _ } from "./utils/strings.js";
24
- import { g as ee } from "./utils/anchorEl.js";
23
+ import { u as _ } from "./hooks/useRows/index.js";
24
+ import { c as ee } from "./utils/strings.js";
25
+ import { g as re } from "./utils/anchorEl.js";
25
26
  export {
26
27
  c as DeviceTypeContext,
27
28
  C as DeviceTypeProvider,
@@ -30,27 +31,28 @@ export {
30
31
  r as GlobalStyles,
31
32
  l as HostThemeContext,
32
33
  T as HostThemeProvider,
33
- f as LocalesContext,
34
- i as LocalesProvider,
34
+ u as LocalesContext,
35
+ f as LocalesProvider,
35
36
  n as ResponsiveContainerContext,
36
37
  v as ResponsiveContainerProvider,
37
38
  S as ThemeSettingsContext,
38
39
  F as ThemeSettingsProvider,
39
- _ as capitalize,
40
- P as defaultThemeSettings,
41
- ee as getAnchorElPositionWindow,
42
- s as getLocaleFromNetwork,
40
+ ee as capitalize,
41
+ h as defaultThemeSettings,
42
+ re as getAnchorElPositionWindow,
43
+ t as getLocaleFromNetwork,
43
44
  D as useFirstRender,
44
45
  b as useFormatter,
45
46
  j as useHostTheme,
46
47
  E as useIsMobile,
47
- k as useIsMountedRef,
48
+ y as useIsMountedRef,
48
49
  z as useLocales,
49
50
  U as useOffSetTop,
50
51
  Y as usePaginate,
51
52
  B as useResizeObserver,
52
53
  G as useResponsiveContainerStore,
53
54
  K as useResponsiveDesktop,
55
+ _ as useRows,
54
56
  V as useThemeSettingsStore,
55
57
  M as useUserAgent
56
58
  };
@@ -0,0 +1,224 @@
1
+ var x = Object.getOwnPropertyNames, G = Object.getOwnPropertySymbols, B = Object.prototype.hasOwnProperty;
2
+ function O(r, e) {
3
+ return function(t, n, a) {
4
+ return r(t, n, a) && e(t, n, a);
5
+ };
6
+ }
7
+ function d(r) {
8
+ return function(u, t, n) {
9
+ if (!u || !t || typeof u != "object" || typeof t != "object")
10
+ return r(u, t, n);
11
+ var a = n.cache, l = a.get(u), c = a.get(t);
12
+ if (l && c)
13
+ return l === t && c === u;
14
+ a.set(u, t), a.set(t, u);
15
+ var f = r(u, t, n);
16
+ return a.delete(u), a.delete(t), f;
17
+ };
18
+ }
19
+ function A(r) {
20
+ return x(r).concat(G(r));
21
+ }
22
+ var $ = Object.hasOwn || function(r, e) {
23
+ return B.call(r, e);
24
+ };
25
+ function y(r, e) {
26
+ return r || e ? r === e : r === e || r !== r && e !== e;
27
+ }
28
+ var P = "_owner", j = Object.getOwnPropertyDescriptor, w = Object.keys;
29
+ function D(r, e, u) {
30
+ var t = r.length;
31
+ if (e.length !== t)
32
+ return !1;
33
+ for (; t-- > 0; )
34
+ if (!u.equals(r[t], e[t], t, t, r, e, u))
35
+ return !1;
36
+ return !0;
37
+ }
38
+ function M(r, e) {
39
+ return y(r.getTime(), e.getTime());
40
+ }
41
+ function S(r, e, u) {
42
+ if (r.size !== e.size)
43
+ return !1;
44
+ for (var t = {}, n = r.entries(), a = 0, l, c; (l = n.next()) && !l.done; ) {
45
+ for (var f = e.entries(), p = !1, i = 0; (c = f.next()) && !c.done; ) {
46
+ var o = l.value, s = o[0], E = o[1], v = c.value, m = v[0], R = v[1];
47
+ !p && !t[i] && (p = u.equals(s, m, a, i, r, e, u) && u.equals(E, R, s, m, r, e, u)) && (t[i] = !0), i++;
48
+ }
49
+ if (!p)
50
+ return !1;
51
+ a++;
52
+ }
53
+ return !0;
54
+ }
55
+ function k(r, e, u) {
56
+ var t = w(r), n = t.length;
57
+ if (w(e).length !== n)
58
+ return !1;
59
+ for (var a; n-- > 0; )
60
+ if (a = t[n], a === P && (r.$$typeof || e.$$typeof) && r.$$typeof !== e.$$typeof || !$(e, a) || !u.equals(r[a], e[a], a, a, r, e, u))
61
+ return !1;
62
+ return !0;
63
+ }
64
+ function g(r, e, u) {
65
+ var t = A(r), n = t.length;
66
+ if (A(e).length !== n)
67
+ return !1;
68
+ for (var a, l, c; n-- > 0; )
69
+ if (a = t[n], a === P && (r.$$typeof || e.$$typeof) && r.$$typeof !== e.$$typeof || !$(e, a) || !u.equals(r[a], e[a], a, a, r, e, u) || (l = j(r, a), c = j(e, a), (l || c) && (!l || !c || l.configurable !== c.configurable || l.enumerable !== c.enumerable || l.writable !== c.writable)))
70
+ return !1;
71
+ return !0;
72
+ }
73
+ function I(r, e) {
74
+ return y(r.valueOf(), e.valueOf());
75
+ }
76
+ function N(r, e) {
77
+ return r.source === e.source && r.flags === e.flags;
78
+ }
79
+ function T(r, e, u) {
80
+ if (r.size !== e.size)
81
+ return !1;
82
+ for (var t = {}, n = r.values(), a, l; (a = n.next()) && !a.done; ) {
83
+ for (var c = e.values(), f = !1, p = 0; (l = c.next()) && !l.done; )
84
+ !f && !t[p] && (f = u.equals(a.value, l.value, a.value, l.value, r, e, u)) && (t[p] = !0), p++;
85
+ if (!f)
86
+ return !1;
87
+ }
88
+ return !0;
89
+ }
90
+ function W(r, e) {
91
+ var u = r.length;
92
+ if (e.length !== u)
93
+ return !1;
94
+ for (; u-- > 0; )
95
+ if (r[u] !== e[u])
96
+ return !1;
97
+ return !0;
98
+ }
99
+ var z = "[object Arguments]", _ = "[object Boolean]", V = "[object Date]", U = "[object Map]", J = "[object Number]", L = "[object Object]", X = "[object RegExp]", Z = "[object Set]", F = "[object String]", H = Array.isArray, h = typeof ArrayBuffer == "function" && ArrayBuffer.isView ? ArrayBuffer.isView : null, C = Object.assign, K = Object.prototype.toString.call.bind(Object.prototype.toString);
100
+ function Q(r) {
101
+ var e = r.areArraysEqual, u = r.areDatesEqual, t = r.areMapsEqual, n = r.areObjectsEqual, a = r.arePrimitiveWrappersEqual, l = r.areRegExpsEqual, c = r.areSetsEqual, f = r.areTypedArraysEqual;
102
+ return function(i, o, s) {
103
+ if (i === o)
104
+ return !0;
105
+ if (i == null || o == null || typeof i != "object" || typeof o != "object")
106
+ return i !== i && o !== o;
107
+ var E = i.constructor;
108
+ if (E !== o.constructor)
109
+ return !1;
110
+ if (E === Object)
111
+ return n(i, o, s);
112
+ if (H(i))
113
+ return e(i, o, s);
114
+ if (h != null && h(i))
115
+ return f(i, o, s);
116
+ if (E === Date)
117
+ return u(i, o, s);
118
+ if (E === RegExp)
119
+ return l(i, o, s);
120
+ if (E === Map)
121
+ return t(i, o, s);
122
+ if (E === Set)
123
+ return c(i, o, s);
124
+ var v = K(i);
125
+ return v === V ? u(i, o, s) : v === X ? l(i, o, s) : v === U ? t(i, o, s) : v === Z ? c(i, o, s) : v === L ? typeof i.then != "function" && typeof o.then != "function" && n(i, o, s) : v === z ? n(i, o, s) : v === _ || v === J || v === F ? a(i, o, s) : !1;
126
+ };
127
+ }
128
+ function Y(r) {
129
+ var e = r.circular, u = r.createCustomConfig, t = r.strict, n = {
130
+ areArraysEqual: t ? g : D,
131
+ areDatesEqual: M,
132
+ areMapsEqual: t ? O(S, g) : S,
133
+ areObjectsEqual: t ? g : k,
134
+ arePrimitiveWrappersEqual: I,
135
+ areRegExpsEqual: N,
136
+ areSetsEqual: t ? O(T, g) : T,
137
+ areTypedArraysEqual: t ? g : W
138
+ };
139
+ if (u && (n = C({}, n, u(n))), e) {
140
+ var a = d(n.areArraysEqual), l = d(n.areMapsEqual), c = d(n.areObjectsEqual), f = d(n.areSetsEqual);
141
+ n = C({}, n, {
142
+ areArraysEqual: a,
143
+ areMapsEqual: l,
144
+ areObjectsEqual: c,
145
+ areSetsEqual: f
146
+ });
147
+ }
148
+ return n;
149
+ }
150
+ function b(r) {
151
+ return function(e, u, t, n, a, l, c) {
152
+ return r(e, u, c);
153
+ };
154
+ }
155
+ function rr(r) {
156
+ var e = r.circular, u = r.comparator, t = r.createState, n = r.equals, a = r.strict;
157
+ if (t)
158
+ return function(f, p) {
159
+ var i = t(), o = i.cache, s = o === void 0 ? e ? /* @__PURE__ */ new WeakMap() : void 0 : o, E = i.meta;
160
+ return u(f, p, {
161
+ cache: s,
162
+ equals: n,
163
+ meta: E,
164
+ strict: a
165
+ });
166
+ };
167
+ if (e)
168
+ return function(f, p) {
169
+ return u(f, p, {
170
+ cache: /* @__PURE__ */ new WeakMap(),
171
+ equals: n,
172
+ meta: void 0,
173
+ strict: a
174
+ });
175
+ };
176
+ var l = {
177
+ cache: void 0,
178
+ equals: n,
179
+ meta: void 0,
180
+ strict: a
181
+ };
182
+ return function(f, p) {
183
+ return u(f, p, l);
184
+ };
185
+ }
186
+ var er = q();
187
+ q({ strict: !0 });
188
+ q({ circular: !0 });
189
+ q({
190
+ circular: !0,
191
+ strict: !0
192
+ });
193
+ q({
194
+ createInternalComparator: function() {
195
+ return y;
196
+ }
197
+ });
198
+ q({
199
+ strict: !0,
200
+ createInternalComparator: function() {
201
+ return y;
202
+ }
203
+ });
204
+ q({
205
+ circular: !0,
206
+ createInternalComparator: function() {
207
+ return y;
208
+ }
209
+ });
210
+ q({
211
+ circular: !0,
212
+ createInternalComparator: function() {
213
+ return y;
214
+ },
215
+ strict: !0
216
+ });
217
+ function q(r) {
218
+ r === void 0 && (r = {});
219
+ var e = r.circular, u = e === void 0 ? !1 : e, t = r.createInternalComparator, n = r.createState, a = r.strict, l = a === void 0 ? !1 : a, c = Y(r), f = Q(c), p = t ? t(f) : b(f);
220
+ return rr({ circular: u, comparator: f, createState: n, equals: p, strict: l });
221
+ }
222
+ export {
223
+ er as d
224
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/graphics",
3
- "version": "7.0.14",
3
+ "version": "7.0.16-beta.1",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team*",
6
6
  "type": "module",
@@ -12,7 +12,6 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "date-fns": "^2.30.0",
15
- "immer": "^9.0.21",
16
15
  "lodash-es": "^4.17.21",
17
16
  "zustand": "4.3.6"
18
17
  },