@m4l/widgets 0.6.0-beta-pkg-801-ajustes-mf-52.0 → 0.6.0

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 +1 @@
1
- {"version":3,"file":"ChartPie.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/ChartPie/ChartPie.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAUjE;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,aAAa,oDAoC3D;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"ChartPie.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/ChartPie/ChartPie.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAUjE;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,aAAa,oDAsC3D;AAED,eAAe,QAAQ,CAAC"}
@@ -1,31 +1,33 @@
1
1
  import { jsx as t, jsxs as o } from "@emotion/react/jsx-runtime";
2
- import m from "echarts-for-react";
3
- import { useRef as d } from "react";
4
- import { CustomLegend as f } from "./subcomponents/CustomLegend/CustomLegend.js";
5
- import { ChartPieRootStyled as c, ChartPieParentStyled as p, ChartContainerStyled as u, LegendContainerStyled as C } from "./slots/ChartPieSlots.js";
6
- import { useChartPieData as g } from "./hooks/useChartPieData.js";
7
- import { useChartResize as y } from "./hooks/useChartResize.js";
8
- function E({ values: n, size: i, sx: a }) {
9
- const e = d(null), { data: r, options: h } = g(n), s = y(e), l = {
2
+ import d from "echarts-for-react";
3
+ import { useRef as f } from "react";
4
+ import { CustomLegend as c } from "./subcomponents/CustomLegend/CustomLegend.js";
5
+ import { ChartPieRootStyled as p, ChartPieParentStyled as u, ChartContainerStyled as C, LegendContainerStyled as y } from "./slots/ChartPieSlots.js";
6
+ import { useChartPieData as R } from "./hooks/useChartPieData.js";
7
+ import { useChartResize as g } from "./hooks/useChartResize.js";
8
+ function L({ values: n, size: a, sx: i }) {
9
+ const e = f(null), { data: r, options: s } = R(n), { setParentElement: h, onChartReady: l } = g(e), m = {
10
10
  length: r.length
11
11
  };
12
- return /* @__PURE__ */ t(c, { sx: a, children: /* @__PURE__ */ o(p, { children: [
13
- /* @__PURE__ */ t(u, { ref: s, children: /* @__PURE__ */ t(
14
- m,
12
+ return /* @__PURE__ */ t(p, { sx: i, children: /* @__PURE__ */ o(u, { children: [
13
+ /* @__PURE__ */ t(C, { ref: h, children: /* @__PURE__ */ t(
14
+ d,
15
15
  {
16
16
  ref: e,
17
- option: h,
17
+ option: s,
18
18
  style: { height: "100%", width: "100%" },
19
19
  notMerge: !0,
20
- lazyUpdate: !0
20
+ lazyUpdate: !0,
21
+ autoResize: !1,
22
+ onChartReady: l
21
23
  }
22
24
  ) }),
23
- /* @__PURE__ */ o(C, { ownerState: l, children: [
25
+ /* @__PURE__ */ o(y, { ownerState: m, children: [
24
26
  /* @__PURE__ */ t(
25
- f,
27
+ c,
26
28
  {
27
29
  data: r,
28
- size: i
30
+ size: a
29
31
  }
30
32
  ),
31
33
  " "
@@ -33,6 +35,6 @@ function E({ values: n, size: i, sx: a }) {
33
35
  ] }) });
34
36
  }
35
37
  export {
36
- E as ChartPie,
37
- E as default
38
+ L as ChartPie,
39
+ L as default
38
40
  };
@@ -1,8 +1,12 @@
1
+ import { EChartsType } from 'echarts';
1
2
  import { default as ReactECharts } from 'echarts-for-react';
2
3
  /**
3
- * Custom hook to resize the chart when the container size changes.
4
+ * Resize a ready pie chart when its visible container size changes.
4
5
  * @param chartRef - Reference to the chart element
5
- * @returns Reference setter for the chart parent element
6
+ * @returns Parent reference setter and final chart readiness callback.
6
7
  */
7
- export declare function useChartResize(chartRef: React.RefObject<ReactECharts | null>): (node: HTMLDivElement | null) => void;
8
+ export declare function useChartResize(chartRef: React.RefObject<ReactECharts | null>): {
9
+ setParentElement: import('react').Dispatch<import('react').SetStateAction<HTMLDivElement | null>>;
10
+ onChartReady: (instance: EChartsType) => void;
11
+ };
8
12
  //# sourceMappingURL=useChartResize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useChartResize.d.ts","sourceRoot":"","sources":["../../../../../../../packages/widgets/src/charts/ChartPie/hooks/useChartResize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAGlD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,yCAoB5E"}
1
+ {"version":3,"file":"useChartResize.d.ts","sourceRoot":"","sources":["../../../../../../../packages/widgets/src/charts/ChartPie/hooks/useChartResize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC;;6BAwB/B,WAAW;EAkBxD"}
@@ -1,17 +1,21 @@
1
- import { useEffect as s } from "react";
2
- import { useStateRef as a, useSizeContainer as o } from "@m4l/components";
3
- function l(e) {
4
- const [t, n] = a(null), r = o(t, {
5
- throttleTime: 200,
6
- excludePadding: !1,
7
- leading: !0,
8
- trailing: !0
9
- });
10
- return s(() => {
11
- const i = e.current?.getEchartsInstance();
12
- window.requestAnimationFrame(() => i?.resize());
13
- }, [r, e]), n;
1
+ import { useState as h, useRef as d, useCallback as u, useLayoutEffect as f } from "react";
2
+ function m(o) {
3
+ const [n, a] = h(null), c = d(null), t = u(() => {
4
+ const e = o.current?.getEchartsInstance();
5
+ if (!e || e !== c.current || e.isDisposed())
6
+ return;
7
+ const r = e.getDom(), s = r.clientWidth, i = r.clientHeight;
8
+ !r.isConnected || s <= 0 || i <= 0 || (e.getWidth() !== s || e.getHeight() !== i) && e.resize({ width: s, height: i, animation: { duration: 0 } });
9
+ }, [o]), l = u((e) => {
10
+ c.current = e, t();
11
+ }, [t]);
12
+ return f(() => {
13
+ if (!n)
14
+ return;
15
+ const e = new ResizeObserver(t);
16
+ return e.observe(n), t(), () => e.disconnect();
17
+ }, [n, t]), { setParentElement: a, onChartReady: l };
14
18
  }
15
19
  export {
16
- l as useChartResize
20
+ m as useChartResize
17
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/widgets",
3
- "version": "0.6.0-beta-pkg-801-ajustes-mf-52.0",
3
+ "version": "0.6.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },