@m4l/widgets 0.0.2-beta-add-widgets-piechart.0 → 0.0.2-beta-add-widget-piechart.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":"Pie.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/Pie/Pie.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUxC;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,QAAQ,oDAgC7C;AAED,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"Pie.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/Pie/Pie.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUvD;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,QAAQ,oDAoC7C;AAED,eAAe,GAAG,CAAC"}
package/charts/Pie/Pie.js CHANGED
@@ -1,28 +1,30 @@
1
- import { jsx as e, jsxs as r } from "@emotion/react/jsx-runtime";
2
- import s from "echarts-for-react";
1
+ import { jsx as t, jsxs as o } from "@emotion/react/jsx-runtime";
2
+ import m from "echarts-for-react";
3
3
  import { useRef as d } from "react";
4
- import { CustomLegend as l } from "./subcomponents/CustomLegend/CustomLegend.js";
5
- import { PieRootStyled as f, PieParentStyled as h, ChartContainerStyled as p, LegendContainerStyled as c } from "./slots/PieSlots.js";
6
- import { usePieChartData as u } from "./hooks/usePieChartData.js";
7
- import { useChartResize as C } from "./hooks/useChartResize.js";
8
- function z({ values: o, size: i }) {
9
- const t = d(null), { data: n, options: a } = u(o), m = C(t);
10
- return /* @__PURE__ */ e(f, { children: /* @__PURE__ */ r(h, { children: [
11
- /* @__PURE__ */ e(p, { ref: m, children: /* @__PURE__ */ e(
12
- s,
4
+ import { CustomLegend as h } from "./subcomponents/CustomLegend/CustomLegend.js";
5
+ import { PieRootStyled as f, PieParentStyled as c, ChartContainerStyled as p, LegendContainerStyled as u } from "./slots/PieSlots.js";
6
+ import { usePieChartData as C } from "./hooks/usePieChartData.js";
7
+ import { useChartResize as g } from "./hooks/useChartResize.js";
8
+ function z({ values: n, size: i }) {
9
+ const e = d(null), { data: r, options: a } = C(n), s = g(e), l = {
10
+ length: r.length
11
+ };
12
+ return /* @__PURE__ */ t(f, { children: /* @__PURE__ */ o(c, { children: [
13
+ /* @__PURE__ */ t(p, { ref: s, children: /* @__PURE__ */ t(
14
+ m,
13
15
  {
14
- ref: t,
16
+ ref: e,
15
17
  option: a,
16
18
  style: { height: "100%", width: "100%" },
17
19
  notMerge: !0,
18
20
  lazyUpdate: !0
19
21
  }
20
22
  ) }),
21
- /* @__PURE__ */ r(c, { children: [
22
- /* @__PURE__ */ e(
23
- l,
23
+ /* @__PURE__ */ o(u, { ownerState: l, children: [
24
+ /* @__PURE__ */ t(
25
+ h,
24
26
  {
25
- data: n,
27
+ data: r,
26
28
  size: i
27
29
  }
28
30
  ),
@@ -1 +1 @@
1
- {"version":3,"file":"Pie.styles.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/Pie/Pie.styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,eAAO,MAAM,SAAS,EAAE,SAyMvB,CAAC"}
1
+ {"version":3,"file":"Pie.styles.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/Pie/Pie.styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,eAAO,MAAM,SAAS,EAAE,SAgNvB,CAAC"}
@@ -44,17 +44,20 @@ const a = {
44
44
  "@container root (max-width: 359px) and (max-height: 300px)": {
45
45
  width: "100%",
46
46
  height: "100%",
47
- maxWidth: "100%"
47
+ maxWidth: "100%",
48
+ maxHeight: "100%"
48
49
  },
49
50
  "@container root (max-height: 65px)": {
50
51
  width: "100%",
51
52
  height: "100%",
52
- maxWidth: "100%"
53
+ maxWidth: "100%",
54
+ maxHeight: "100%"
53
55
  },
54
56
  "@container root (max-width: 120px)": {
55
57
  width: "100%",
56
58
  height: "100%",
57
- maxWidth: "100%"
59
+ maxWidth: "100%",
60
+ maxHeight: "100%"
58
61
  }
59
62
  }),
60
63
  /**
@@ -62,40 +65,31 @@ const a = {
62
65
  * Caja derecha: contenedor de la leyenda. CustomLegend se renderiza dentro.
63
66
  * ********************************************************************
64
67
  */
65
- legendContainer: ({ theme: e }) => ({
66
- display: "flex",
68
+ legendContainer: ({ theme: e, ownerState: t }) => ({
69
+ display: "grid",
70
+ gridAutoFlow: "row",
71
+ gridAutoRows: "auto",
72
+ gridTemplateColumns: t?.length && t.length <= 3 ? "300px" : "repeat(auto-fill, 160px)",
67
73
  flex: "1 0 100px",
68
- flexFlow: "column wrap",
69
74
  width: "100%",
70
75
  height: "100%",
71
- maxHeight: "150px",
72
- alignSelf: "center",
73
- // overflow: 'auto',
74
- justifyContent: "flex-start",
75
- alignContent: "flex-start",
76
- gap: e.vars.size.baseSpacings.sp6,
76
+ overflow: "hidden",
77
+ alignContent: "center",
78
+ gap: e?.vars?.size.baseSpacings.sp6 ?? "16px",
77
79
  "@container root (min-width: 0px) and (max-width: 299px)": {
78
- flexFlow: "column nowrap",
80
+ gridAutoFlow: "row",
81
+ gridTemplateColumns: "1fr",
82
+ gridTemplateRows: "auto",
79
83
  alignContent: "flex-start",
80
- alignItems: "flex-start",
81
- justifyContent: "flex-start",
82
- // overflow: 'auto',
83
- maxHeight: "fit-content",
84
- maxWidth: "100px"
85
- },
86
- "@container root (min-width: 300px) and (max-width: 344px)": {
87
84
  justifyContent: "center",
88
- flexFlow: "column nowrap",
89
- alignContent: "flex-start",
90
- alignItems: "flex-start",
91
- // overflow: 'auto',
85
+ overflow: "visible",
92
86
  maxHeight: "fit-content",
93
87
  maxWidth: "100px"
94
88
  },
95
89
  "@container root (max-width: 359px) and (max-height: 300px)": {
96
90
  display: "none"
97
91
  },
98
- "@container root (max-height: 65px)": {
92
+ "@container root (max-height: 130px)": {
99
93
  display: "none"
100
94
  },
101
95
  "@container root (max-width: 120px)": {
@@ -110,7 +104,8 @@ const a = {
110
104
  legendItem: ({ theme: e }) => ({
111
105
  display: "flex",
112
106
  alignItems: "center",
113
- gap: e.vars.size.baseSpacings.sp2,
107
+ width: "fit-content",
108
+ gap: e?.vars?.size.baseSpacings.sp2 ?? "8px",
114
109
  border: "1px solid transparent",
115
110
  transition: "all 0.3s",
116
111
  boxSizing: "border-box"
@@ -124,7 +119,7 @@ const a = {
124
119
  width: 11,
125
120
  height: 11,
126
121
  borderRadius: "30%",
127
- backgroundColor: e.vars.palette.chips[t?.color]?.outlined.color,
122
+ backgroundColor: e?.vars?.palette.chips[t?.color].contained.color ?? "#000000",
128
123
  flexShrink: 0
129
124
  }),
130
125
  /**
@@ -133,7 +128,7 @@ const a = {
133
128
  * ******************************************************************
134
129
  */
135
130
  legendItemTextContainer: ({ theme: e }) => ({
136
- color: e.vars.palette.text.primary,
131
+ color: e?.vars?.palette.text.primary ?? "#323B3B",
137
132
  flex: 1,
138
133
  minWidth: 0,
139
134
  display: "flex",
@@ -147,7 +142,7 @@ const a = {
147
142
  legendItemTextSubContainer: ({ theme: e }) => ({
148
143
  display: "flex",
149
144
  alignItems: "center",
150
- gap: e.vars.size.baseSpacings["sp2-5"],
145
+ gap: e?.vars?.size.baseSpacings["sp2-5"] ?? "10px",
151
146
  justifyContent: "flex-start"
152
147
  }),
153
148
  /**
@@ -156,7 +151,7 @@ const a = {
156
151
  * ******************************************************************
157
152
  */
158
153
  legendItemName: ({ theme: e, ownerState: t }) => ({
159
- ...i(e.generalSettings.isMobile, t?.size || "medium", "subtitleDens"),
154
+ ...i(e?.generalSettings?.isMobile ?? !1, t?.size || "medium", "subtitleDens"),
160
155
  fontFamily: "Jura",
161
156
  whiteSpace: "nowrap",
162
157
  overflow: "hidden",
@@ -168,13 +163,16 @@ const a = {
168
163
  * ******************************************************************
169
164
  */
170
165
  legendItemValueBadge: ({ theme: e, ownerState: t }) => ({
171
- ...i(e.generalSettings.isMobile, t?.size || "medium", "body"),
166
+ ...i(e?.generalSettings?.isMobile ?? !1, t?.size || "medium", "body"),
172
167
  fontFamily: "Inter",
173
- padding: `0 ${e.vars.size.baseSpacings.sp1}`,
174
- borderRadius: e.vars.size.borderRadius.r1,
175
- backgroundColor: e.vars.palette.chips[t?.color]?.contained.backgroundColor,
176
- color: e.vars.palette.chips[t?.color]?.contained.color,
177
- flexShrink: 0
168
+ padding: `0 ${e?.vars?.size.baseSpacings.sp1 ?? "4px"}`,
169
+ borderRadius: e?.vars?.size.borderRadius.r1 ?? "4px",
170
+ backgroundColor: e?.vars?.palette.chips[t?.color].contained.backgroundColor ?? "#F8FAFC",
171
+ color: e?.vars?.palette.chips[t?.color].contained.color ?? "#323B3B",
172
+ flexShrink: 0,
173
+ whiteSpace: "nowrap",
174
+ overflow: "hidden",
175
+ textOverflow: "ellipsis"
178
176
  }),
179
177
  /**
180
178
  * ******************************************************************
@@ -182,9 +180,9 @@ const a = {
182
180
  * ******************************************************************
183
181
  */
184
182
  legendItemCategory: ({ theme: e, ownerState: t }) => ({
185
- ...i(e.generalSettings.isMobile, t?.size || "medium", "body"),
183
+ ...i(e?.generalSettings?.isMobile ?? !1, t?.size || "medium", "body"),
186
184
  fontFamily: "Inter",
187
- color: e.vars.palette.text.secondary,
185
+ color: e?.vars?.palette.text.secondary ?? "#64748B",
188
186
  whiteSpace: "nowrap",
189
187
  overflow: "hidden",
190
188
  textOverflow: "ellipsis"
@@ -1,7 +1,7 @@
1
1
  import { PieChartData } from '../types';
2
2
  import { Theme } from '@mui/material/styles';
3
3
  /**
4
- * Builds ECharts option config for the pie chart from data and theme.
4
+ * Construye la configuración de opciones de ECharts para el gráfico de pastel desde los datos y el tema.
5
5
  */
6
6
  export declare function generateOptions(data: PieChartData[], theme: Theme): {
7
7
  baseOption: {
@@ -14,9 +14,7 @@ export declare function generateOptions(data: PieChartData[], theme: Theme): {
14
14
  series: ({
15
15
  type: string;
16
16
  coordinateSystem: string;
17
- /**
18
- * Custom renderItem for ECharts pie series.
19
- */
17
+ /** ECharts custom renderItem for the pie series. */
20
18
  renderItem: (params: any, api: any) => {
21
19
  type: string;
22
20
  children: ({
@@ -82,9 +80,7 @@ export declare function generateOptions(data: PieChartData[], theme: Theme): {
82
80
  };
83
81
  };
84
82
  coordinateSystem?: undefined;
85
- /**
86
- * Custom renderItem for ECharts pie series.
87
- */
83
+ /** ECharts custom renderItem for the pie series. */
88
84
  renderItem?: undefined;
89
85
  })[];
90
86
  };
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../../../../packages/widgets/src/charts/Pie/helpers/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK;;;;;;;;;;;YAmBxD;;eAEG;iCAC2B,GAAG,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAH3C;;eAEG;;;;EAuEZ;AAED,eAAO,MAAM,cAAc;;;;;;CAM1B,CAAC"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../../../../packages/widgets/src/charts/Pie/helpers/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK;;;;;;;;;;;YAsBxD,oDAAoD;iCACtB,GAAG,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAD3C,oDAAoD;;;;EAuE7D;AAED,eAAO,MAAM,cAAc;;;;;;CAM1B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  function u(e, t) {
2
- const n = o(t.vars.palette.background.base), i = o(t.vars.palette.border.disabled), c = o(t.vars.palette.background.default), p = o(t.vars.palette.text.primary);
2
+ const o = n(t.vars?.palette?.background?.base ?? "#F8FAFC"), i = n(t.vars?.palette?.border?.disabled ?? "#F1F5F9"), c = n(t.vars?.palette?.background?.default ?? "#FFFFFF"), p = n(t.vars?.palette?.text?.primary ?? "#323B3B");
3
3
  return {
4
4
  baseOption: {
5
5
  tooltip: {
@@ -12,11 +12,9 @@ function u(e, t) {
12
12
  {
13
13
  type: "custom",
14
14
  coordinateSystem: "none",
15
- /**
16
- * Custom renderItem for ECharts pie series.
17
- */
15
+ /** ECharts custom renderItem for the pie series. */
18
16
  renderItem: function(d, r) {
19
- const a = r.getWidth() / 2, s = r.getHeight() / 2, l = Math.min(r.getWidth(), r.getHeight());
17
+ const a = r.getWidth() / 2, l = r.getHeight() / 2, s = Math.min(r.getWidth(), r.getHeight());
20
18
  return {
21
19
  type: "group",
22
20
  children: [
@@ -24,11 +22,11 @@ function u(e, t) {
24
22
  type: "circle",
25
23
  shape: {
26
24
  cx: a,
27
- cy: s,
28
- r: l * 0.36
25
+ cy: l,
26
+ r: s * 0.36
29
27
  },
30
28
  style: {
31
- fill: n,
29
+ fill: o,
32
30
  stroke: i
33
31
  },
34
32
  z: -10
@@ -37,9 +35,9 @@ function u(e, t) {
37
35
  type: "ring",
38
36
  shape: {
39
37
  cx: a,
40
- cy: s,
41
- r0: l * 0.19,
42
- r: l * 0.33
38
+ cy: l,
39
+ r0: s * 0.19,
40
+ r: s * 0.33
43
41
  },
44
42
  style: {
45
43
  fill: c
@@ -82,8 +80,8 @@ function u(e, t) {
82
80
  }
83
81
  };
84
82
  }
85
- function o(e) {
86
- return e = e.replace("var(", ""), e = e.replace(")", ""), getComputedStyle(document.documentElement).getPropertyValue(e).trim();
83
+ function n(e) {
84
+ return e.includes("#") ? e : (e = e.replace("var(", ""), e = e.replace(")", ""), getComputedStyle(document.documentElement).getPropertyValue(e).trim());
87
85
  }
88
86
  export {
89
87
  u as generateOptions
@@ -1 +1 @@
1
- {"version":3,"file":"remap.d.ts","sourceRoot":"","sources":["../../../../../../../packages/widgets/src/charts/Pie/helpers/remap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGvD;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,YAAY,EAAE,CAYpE"}
1
+ {"version":3,"file":"remap.d.ts","sourceRoot":"","sources":["../../../../../../../packages/widgets/src/charts/Pie/helpers/remap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGvD;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,YAAY,EAAE,CAapE"}
@@ -1,17 +1,18 @@
1
- import { BASE_TAG_OBJECT_COLORS_LIGHT as e } from "@m4l/styles";
2
- function n(r) {
3
- return r.map((o) => ({
4
- name: o.title,
5
- value: o.r,
6
- valueFormatted: o.v,
1
+ import { BASE_TAG_OBJECT_COLORS_LIGHT as t } from "@m4l/styles";
2
+ function n(o) {
3
+ return o.map((r) => ({
4
+ name: r.title,
5
+ value: r.r,
6
+ valueFormatted: r.v,
7
7
  itemStyle: {
8
- color: l(o.palletColor)
8
+ color: e(r.palletColor)
9
9
  },
10
- colorName: o.palletColor
10
+ colorName: r.palletColor,
11
+ lenght: o.length
11
12
  }));
12
13
  }
13
- function l(r) {
14
- return r.includes("#") ? r : e[r].contained.backgroundColorTone;
14
+ function e(o) {
15
+ return o.includes("#") ? o : t[o].contained.backgroundColorTone;
15
16
  }
16
17
  export {
17
18
  n as remapData
@@ -1,6 +1,6 @@
1
1
  import { PieProps } from '../types';
2
2
  /**
3
- * Returns remapped pie data and ECharts options for the given values and current theme.
3
+ * Retorna los datos remapeados del gráfico de pastel y las opciones de ECharts para los valores dados y el tema actual.
4
4
  */
5
5
  export declare function usePieChartData(values: PieProps['values']): {
6
6
  data: import('..').PieChartData[];
@@ -15,7 +15,7 @@ export declare const LegendItemStyled: import('@emotion/styled').StyledComponent
15
15
  }, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
16
16
  export declare const LegendItemColorStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
17
17
  ownerState?: (Partial<import('../types').PieOwnerState> & Record<string, unknown>) | undefined;
18
- }, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
18
+ }, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
19
19
  export declare const LegendItemTextContainerStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
20
20
  ownerState?: (Partial<import('../types').PieOwnerState> & Record<string, unknown>) | undefined;
21
21
  }, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
@@ -1 +1 @@
1
- {"version":3,"file":"PieSlots.d.ts","sourceRoot":"","sources":["../../../../../../../packages/widgets/src/charts/Pie/slots/PieSlots.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,aAAa;;6NAGL,CAAC;AAEtB,eAAO,MAAM,eAAe;;6NAGL,CAAC;AAExB,eAAO,MAAM,oBAAoB;;6NAGL,CAAC;AAE7B,eAAO,MAAM,qBAAqB;;6NAGL,CAAC;AAE9B,eAAO,MAAM,gBAAgB;;6NAGL,CAAC;AAEzB,eAAO,MAAM,qBAAqB;;yGAIL,CAAC;AAE9B,eAAO,MAAM,6BAA6B;;6NAGL,CAAC;AAEtC,eAAO,MAAM,gCAAgC;;6NAGL,CAAC;AAEzC,eAAO,MAAM,oBAAoB,EAAE,GAGP,CAAC;AAE7B,eAAO,MAAM,0BAA0B,EAAE,GAGP,CAAC;AAEnC,eAAO,MAAM,wBAAwB,EAAE,GAGP,CAAC"}
1
+ {"version":3,"file":"PieSlots.d.ts","sourceRoot":"","sources":["../../../../../../../packages/widgets/src/charts/Pie/slots/PieSlots.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa;;6NAGL,CAAC;AAEtB,eAAO,MAAM,eAAe;;6NAGL,CAAC;AAExB,eAAO,MAAM,oBAAoB;;6NAGL,CAAC;AAE7B,eAAO,MAAM,qBAAqB;;6NAGL,CAAC;AAE9B,eAAO,MAAM,gBAAgB;;6NAGL,CAAC;AAEzB,eAAO,MAAM,qBAAqB;;6NAGL,CAAC;AAE9B,eAAO,MAAM,6BAA6B;;6NAGL,CAAC;AAEtC,eAAO,MAAM,gCAAgC;;6NAGL,CAAC;AAEzC,eAAO,MAAM,oBAAoB,EAAE,GAGP,CAAC;AAE7B,eAAO,MAAM,0BAA0B,EAAE,GAGP,CAAC;AAEnC,eAAO,MAAM,wBAAwB,EAAE,GAGP,CAAC"}
@@ -3,29 +3,28 @@ import { Typography as d } from "@mui/material";
3
3
  import { pieStyles as t } from "../Pie.styles.js";
4
4
  import { PieSlots as n } from "./PieEnum.js";
5
5
  import { PIE_KEY_COMPONENT as o } from "../constants.js";
6
- const s = e("div", {
6
+ const g = e("div", {
7
7
  name: o,
8
8
  slot: n.pieRoot
9
- })(t.pieRoot), I = e("div", {
9
+ })(t.pieRoot), s = e("div", {
10
10
  name: o,
11
11
  slot: n.pieParent
12
- })(t.pieParent), C = e("div", {
12
+ })(t.pieParent), I = e("div", {
13
13
  name: o,
14
14
  slot: n.chartContainer
15
- })(t.chartContainer), y = e("div", {
15
+ })(t.chartContainer), C = e("div", {
16
16
  name: o,
17
17
  slot: n.legendContainer
18
- })(t.legendContainer), S = e("div", {
18
+ })(t.legendContainer), y = e("div", {
19
19
  name: o,
20
20
  slot: n.legendItem
21
- })(t.legendItem), p = e("div", {
21
+ })(t.legendItem), S = e("div", {
22
22
  name: o,
23
- slot: n.legendItemColor,
24
- shouldForwardProp: (l) => l !== "ownerState"
23
+ slot: n.legendItemColor
25
24
  })(t.legendItemColor), c = e("div", {
26
25
  name: o,
27
26
  slot: n.legendItemTextContainer
28
- })(t.legendItemTextContainer), P = e("div", {
27
+ })(t.legendItemTextContainer), p = e("div", {
29
28
  name: o,
30
29
  slot: n.legendItemTextSubContainer
31
30
  })(t.legendItemTextSubContainer), v = e(d, {
@@ -34,20 +33,20 @@ const s = e("div", {
34
33
  })(t.legendItemName), L = e(d, {
35
34
  name: o,
36
35
  slot: n.legendItemValueBadge
37
- })(t.legendItemValueBadge), T = e(d, {
36
+ })(t.legendItemValueBadge), P = e(d, {
38
37
  name: o,
39
38
  slot: n.legendItemCategory
40
39
  })(t.legendItemCategory);
41
40
  export {
42
- C as ChartContainerStyled,
43
- y as LegendContainerStyled,
44
- T as LegendItemCategoryStyled,
45
- p as LegendItemColorStyled,
41
+ I as ChartContainerStyled,
42
+ C as LegendContainerStyled,
43
+ P as LegendItemCategoryStyled,
44
+ S as LegendItemColorStyled,
46
45
  v as LegendItemNameStyled,
47
- S as LegendItemStyled,
46
+ y as LegendItemStyled,
48
47
  c as LegendItemTextContainerStyled,
49
- P as LegendItemTextSubContainerStyled,
48
+ p as LegendItemTextSubContainerStyled,
50
49
  L as LegendItemValueBadgeStyled,
51
- I as PieParentStyled,
52
- s as PieRootStyled
50
+ s as PieParentStyled,
51
+ g as PieRootStyled
53
52
  };
@@ -1 +1 @@
1
- {"version":3,"file":"CustomLegend.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/widgets/src/charts/Pie/subcomponents/CustomLegend/CustomLegend.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAYjD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,iBAAiB,sDAgC7D"}
1
+ {"version":3,"file":"CustomLegend.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/widgets/src/charts/Pie/subcomponents/CustomLegend/CustomLegend.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAYjD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,iBAAiB,sDAiC7D"}
@@ -1,23 +1,24 @@
1
- import { jsxs as d, jsx as t } from "@emotion/react/jsx-runtime";
2
- import { LegendItemStyled as m, LegendItemColorStyled as a, LegendItemTextContainerStyled as c, LegendItemTextSubContainerStyled as g, LegendItemNameStyled as i, LegendItemValueBadgeStyled as S, LegendItemCategoryStyled as y } from "../../slots/PieSlots.js";
3
- function u({ data: r, size: l }) {
1
+ import { jsxs as d, jsx as n } from "@emotion/react/jsx-runtime";
2
+ import { LegendItemStyled as m, LegendItemColorStyled as a, LegendItemTextContainerStyled as g, LegendItemTextSubContainerStyled as c, LegendItemNameStyled as i, LegendItemValueBadgeStyled as S, LegendItemCategoryStyled as h } from "../../slots/PieSlots.js";
3
+ function s({ data: r, size: l }) {
4
4
  return r.map((e, o) => {
5
- const n = {
5
+ const t = {
6
6
  color: e.colorName,
7
+ length: e.lenght,
7
8
  size: l
8
9
  };
9
10
  return /* @__PURE__ */ d(
10
11
  m,
11
12
  {
12
- ownerState: n,
13
+ ownerState: t,
13
14
  children: [
14
- /* @__PURE__ */ t(a, { ownerState: n }),
15
- /* @__PURE__ */ d(c, { children: [
16
- /* @__PURE__ */ d(g, { children: [
17
- /* @__PURE__ */ t(i, { children: e.name.split(":")[1] }),
18
- /* @__PURE__ */ t(S, { ownerState: n, children: e.valueFormatted })
15
+ /* @__PURE__ */ n(a, { ownerState: t }),
16
+ /* @__PURE__ */ d(g, { children: [
17
+ /* @__PURE__ */ d(c, { children: [
18
+ /* @__PURE__ */ n(i, { ownerState: t, children: e.name.split(":")[1] }),
19
+ /* @__PURE__ */ n(S, { ownerState: t, children: e.valueFormatted })
19
20
  ] }),
20
- /* @__PURE__ */ t(y, { children: e.name.split(":")[0] })
21
+ /* @__PURE__ */ n(h, { ownerState: t, children: e.name.split(":")[0] })
21
22
  ] })
22
23
  ]
23
24
  },
@@ -26,5 +27,5 @@ function u({ data: r, size: l }) {
26
27
  });
27
28
  }
28
29
  export {
29
- u as CustomLegend
30
+ s as CustomLegend
30
31
  };
@@ -41,9 +41,12 @@ export interface PieChartData {
41
41
  };
42
42
  /** Muestra el color de la categoría. */
43
43
  colorName: string;
44
+ /** Muestra el largo de los datos. */
45
+ lenght: number;
44
46
  }
45
47
  export type PieOwnerState = {
46
48
  color?: PieChartData['colorName'];
49
+ length?: PieChartData['lenght'];
47
50
  size?: PieProps['size'];
48
51
  selected?: boolean;
49
52
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/Pie/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,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,EAAE,OAAO,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,YAAY,GAAI,MAAM,OAAO,QAAQ,CAAC;AAClD,MAAM,MAAM,SAAS,GAAG,sBAAsB,CAAC,YAAY,EAAE,OAAO,iBAAiB,EAAE,KAAK,CAAC,CAAC"}
@@ -0,0 +1,349 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+
4
+ /**
5
+ * Mock Service Worker.
6
+ * @see https://github.com/mswjs/msw
7
+ * - Please do NOT modify this file.
8
+ */
9
+
10
+ const PACKAGE_VERSION = '2.12.10'
11
+ const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
12
+ const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
13
+ const activeClientIds = new Set()
14
+
15
+ addEventListener('install', function () {
16
+ self.skipWaiting()
17
+ })
18
+
19
+ addEventListener('activate', function (event) {
20
+ event.waitUntil(self.clients.claim())
21
+ })
22
+
23
+ addEventListener('message', async function (event) {
24
+ const clientId = Reflect.get(event.source || {}, 'id')
25
+
26
+ if (!clientId || !self.clients) {
27
+ return
28
+ }
29
+
30
+ const client = await self.clients.get(clientId)
31
+
32
+ if (!client) {
33
+ return
34
+ }
35
+
36
+ const allClients = await self.clients.matchAll({
37
+ type: 'window',
38
+ })
39
+
40
+ switch (event.data) {
41
+ case 'KEEPALIVE_REQUEST': {
42
+ sendToClient(client, {
43
+ type: 'KEEPALIVE_RESPONSE',
44
+ })
45
+ break
46
+ }
47
+
48
+ case 'INTEGRITY_CHECK_REQUEST': {
49
+ sendToClient(client, {
50
+ type: 'INTEGRITY_CHECK_RESPONSE',
51
+ payload: {
52
+ packageVersion: PACKAGE_VERSION,
53
+ checksum: INTEGRITY_CHECKSUM,
54
+ },
55
+ })
56
+ break
57
+ }
58
+
59
+ case 'MOCK_ACTIVATE': {
60
+ activeClientIds.add(clientId)
61
+
62
+ sendToClient(client, {
63
+ type: 'MOCKING_ENABLED',
64
+ payload: {
65
+ client: {
66
+ id: client.id,
67
+ frameType: client.frameType,
68
+ },
69
+ },
70
+ })
71
+ break
72
+ }
73
+
74
+ case 'CLIENT_CLOSED': {
75
+ activeClientIds.delete(clientId)
76
+
77
+ const remainingClients = allClients.filter((client) => {
78
+ return client.id !== clientId
79
+ })
80
+
81
+ // Unregister itself when there are no more clients
82
+ if (remainingClients.length === 0) {
83
+ self.registration.unregister()
84
+ }
85
+
86
+ break
87
+ }
88
+ }
89
+ })
90
+
91
+ addEventListener('fetch', function (event) {
92
+ const requestInterceptedAt = Date.now()
93
+
94
+ // Bypass navigation requests.
95
+ if (event.request.mode === 'navigate') {
96
+ return
97
+ }
98
+
99
+ // Opening the DevTools triggers the "only-if-cached" request
100
+ // that cannot be handled by the worker. Bypass such requests.
101
+ if (
102
+ event.request.cache === 'only-if-cached' &&
103
+ event.request.mode !== 'same-origin'
104
+ ) {
105
+ return
106
+ }
107
+
108
+ // Bypass all requests when there are no active clients.
109
+ // Prevents the self-unregistered worked from handling requests
110
+ // after it's been terminated (still remains active until the next reload).
111
+ if (activeClientIds.size === 0) {
112
+ return
113
+ }
114
+
115
+ const requestId = crypto.randomUUID()
116
+ event.respondWith(handleRequest(event, requestId, requestInterceptedAt))
117
+ })
118
+
119
+ /**
120
+ * @param {FetchEvent} event
121
+ * @param {string} requestId
122
+ * @param {number} requestInterceptedAt
123
+ */
124
+ async function handleRequest(event, requestId, requestInterceptedAt) {
125
+ const client = await resolveMainClient(event)
126
+ const requestCloneForEvents = event.request.clone()
127
+ const response = await getResponse(
128
+ event,
129
+ client,
130
+ requestId,
131
+ requestInterceptedAt,
132
+ )
133
+
134
+ // Send back the response clone for the "response:*" life-cycle events.
135
+ // Ensure MSW is active and ready to handle the message, otherwise
136
+ // this message will pend indefinitely.
137
+ if (client && activeClientIds.has(client.id)) {
138
+ const serializedRequest = await serializeRequest(requestCloneForEvents)
139
+
140
+ // Clone the response so both the client and the library could consume it.
141
+ const responseClone = response.clone()
142
+
143
+ sendToClient(
144
+ client,
145
+ {
146
+ type: 'RESPONSE',
147
+ payload: {
148
+ isMockedResponse: IS_MOCKED_RESPONSE in response,
149
+ request: {
150
+ id: requestId,
151
+ ...serializedRequest,
152
+ },
153
+ response: {
154
+ type: responseClone.type,
155
+ status: responseClone.status,
156
+ statusText: responseClone.statusText,
157
+ headers: Object.fromEntries(responseClone.headers.entries()),
158
+ body: responseClone.body,
159
+ },
160
+ },
161
+ },
162
+ responseClone.body ? [serializedRequest.body, responseClone.body] : [],
163
+ )
164
+ }
165
+
166
+ return response
167
+ }
168
+
169
+ /**
170
+ * Resolve the main client for the given event.
171
+ * Client that issues a request doesn't necessarily equal the client
172
+ * that registered the worker. It's with the latter the worker should
173
+ * communicate with during the response resolving phase.
174
+ * @param {FetchEvent} event
175
+ * @returns {Promise<Client | undefined>}
176
+ */
177
+ async function resolveMainClient(event) {
178
+ const client = await self.clients.get(event.clientId)
179
+
180
+ if (activeClientIds.has(event.clientId)) {
181
+ return client
182
+ }
183
+
184
+ if (client?.frameType === 'top-level') {
185
+ return client
186
+ }
187
+
188
+ const allClients = await self.clients.matchAll({
189
+ type: 'window',
190
+ })
191
+
192
+ return allClients
193
+ .filter((client) => {
194
+ // Get only those clients that are currently visible.
195
+ return client.visibilityState === 'visible'
196
+ })
197
+ .find((client) => {
198
+ // Find the client ID that's recorded in the
199
+ // set of clients that have registered the worker.
200
+ return activeClientIds.has(client.id)
201
+ })
202
+ }
203
+
204
+ /**
205
+ * @param {FetchEvent} event
206
+ * @param {Client | undefined} client
207
+ * @param {string} requestId
208
+ * @param {number} requestInterceptedAt
209
+ * @returns {Promise<Response>}
210
+ */
211
+ async function getResponse(event, client, requestId, requestInterceptedAt) {
212
+ // Clone the request because it might've been already used
213
+ // (i.e. its body has been read and sent to the client).
214
+ const requestClone = event.request.clone()
215
+
216
+ function passthrough() {
217
+ // Cast the request headers to a new Headers instance
218
+ // so the headers can be manipulated with.
219
+ const headers = new Headers(requestClone.headers)
220
+
221
+ // Remove the "accept" header value that marked this request as passthrough.
222
+ // This prevents request alteration and also keeps it compliant with the
223
+ // user-defined CORS policies.
224
+ const acceptHeader = headers.get('accept')
225
+ if (acceptHeader) {
226
+ const values = acceptHeader.split(',').map((value) => value.trim())
227
+ const filteredValues = values.filter(
228
+ (value) => value !== 'msw/passthrough',
229
+ )
230
+
231
+ if (filteredValues.length > 0) {
232
+ headers.set('accept', filteredValues.join(', '))
233
+ } else {
234
+ headers.delete('accept')
235
+ }
236
+ }
237
+
238
+ return fetch(requestClone, { headers })
239
+ }
240
+
241
+ // Bypass mocking when the client is not active.
242
+ if (!client) {
243
+ return passthrough()
244
+ }
245
+
246
+ // Bypass initial page load requests (i.e. static assets).
247
+ // The absence of the immediate/parent client in the map of the active clients
248
+ // means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
249
+ // and is not ready to handle requests.
250
+ if (!activeClientIds.has(client.id)) {
251
+ return passthrough()
252
+ }
253
+
254
+ // Notify the client that a request has been intercepted.
255
+ const serializedRequest = await serializeRequest(event.request)
256
+ const clientMessage = await sendToClient(
257
+ client,
258
+ {
259
+ type: 'REQUEST',
260
+ payload: {
261
+ id: requestId,
262
+ interceptedAt: requestInterceptedAt,
263
+ ...serializedRequest,
264
+ },
265
+ },
266
+ [serializedRequest.body],
267
+ )
268
+
269
+ switch (clientMessage.type) {
270
+ case 'MOCK_RESPONSE': {
271
+ return respondWithMock(clientMessage.data)
272
+ }
273
+
274
+ case 'PASSTHROUGH': {
275
+ return passthrough()
276
+ }
277
+ }
278
+
279
+ return passthrough()
280
+ }
281
+
282
+ /**
283
+ * @param {Client} client
284
+ * @param {any} message
285
+ * @param {Array<Transferable>} transferrables
286
+ * @returns {Promise<any>}
287
+ */
288
+ function sendToClient(client, message, transferrables = []) {
289
+ return new Promise((resolve, reject) => {
290
+ const channel = new MessageChannel()
291
+
292
+ channel.port1.onmessage = (event) => {
293
+ if (event.data && event.data.error) {
294
+ return reject(event.data.error)
295
+ }
296
+
297
+ resolve(event.data)
298
+ }
299
+
300
+ client.postMessage(message, [
301
+ channel.port2,
302
+ ...transferrables.filter(Boolean),
303
+ ])
304
+ })
305
+ }
306
+
307
+ /**
308
+ * @param {Response} response
309
+ * @returns {Response}
310
+ */
311
+ function respondWithMock(response) {
312
+ // Setting response status code to 0 is a no-op.
313
+ // However, when responding with a "Response.error()", the produced Response
314
+ // instance will have status code set to 0. Since it's not possible to create
315
+ // a Response instance with status code 0, handle that use-case separately.
316
+ if (response.status === 0) {
317
+ return Response.error()
318
+ }
319
+
320
+ const mockedResponse = new Response(response.body, response)
321
+
322
+ Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
323
+ value: true,
324
+ enumerable: true,
325
+ })
326
+
327
+ return mockedResponse
328
+ }
329
+
330
+ /**
331
+ * @param {Request} request
332
+ */
333
+ async function serializeRequest(request) {
334
+ return {
335
+ url: request.url,
336
+ mode: request.mode,
337
+ method: request.method,
338
+ headers: Object.fromEntries(request.headers.entries()),
339
+ cache: request.cache,
340
+ credentials: request.credentials,
341
+ destination: request.destination,
342
+ integrity: request.integrity,
343
+ redirect: request.redirect,
344
+ referrer: request.referrer,
345
+ referrerPolicy: request.referrerPolicy,
346
+ body: await request.arrayBuffer(),
347
+ keepalive: request.keepalive,
348
+ }
349
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/widgets",
3
- "version": "0.0.2-beta-add-widgets-piechart.0",
3
+ "version": "0.0.2-beta-add-widget-piechart.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },