@hybridcore/ui 1.5.79 → 1.5.82

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,293 @@
1
+ import { S as V, L as C, T, C as A, m as f, R as O, a as X, b as W, A as z, X as B, c as G, V as I, d as U, e as Z, f as q, g as J, p as M } from "../../../AxisRendererY-kADUad00.js";
2
+ import { useThemeProps as K } from "@mui/material";
3
+ import { useRef as R, useLayoutEffect as Q } from "react";
4
+ import { X as $, D as ee } from "../../../DateAxis-CMum47iz.js";
5
+ import { L as te } from "../../../LineSeries-CfcpoYla.js";
6
+ class D extends V {
7
+ constructor() {
8
+ super(...arguments), Object.defineProperty(this, "itemContainers", {
9
+ enumerable: !0,
10
+ configurable: !0,
11
+ writable: !0,
12
+ value: this.addDisposer(new C(T.new({}), () => A._new(this._root, {
13
+ themeTags: f(this.itemContainers.template.get("themeTags", []), ["legend", "item"]),
14
+ themeTagsSelf: f(this.itemContainers.template.get("themeTagsSelf", []), ["itemcontainer"]),
15
+ background: O.new(this._root, {
16
+ themeTags: f(this.itemContainers.template.get("themeTags", []), ["legend", "item", "background"]),
17
+ themeTagsSelf: f(this.itemContainers.template.get("themeTagsSelf", []), ["itemcontainer"])
18
+ })
19
+ }, [this.itemContainers.template])))
20
+ }), Object.defineProperty(this, "markers", {
21
+ enumerable: !0,
22
+ configurable: !0,
23
+ writable: !0,
24
+ value: this.addDisposer(new C(T.new({}), () => A._new(this._root, {
25
+ themeTags: f(this.markers.template.get("themeTags", []), ["legend", "marker"])
26
+ }, [this.markers.template])))
27
+ }), Object.defineProperty(this, "labels", {
28
+ enumerable: !0,
29
+ configurable: !0,
30
+ writable: !0,
31
+ value: this.addDisposer(new C(T.new({}), () => X._new(this._root, {
32
+ themeTags: f(this.labels.template.get("themeTags", []), ["legend", "label"])
33
+ }, [this.labels.template])))
34
+ }), Object.defineProperty(this, "valueLabels", {
35
+ enumerable: !0,
36
+ configurable: !0,
37
+ writable: !0,
38
+ value: this.addDisposer(new C(T.new({}), () => X._new(this._root, {
39
+ themeTags: f(this.valueLabels.template.get("themeTags", []), ["legend", "label", "value"])
40
+ }, [this.valueLabels.template])))
41
+ }), Object.defineProperty(this, "markerRectangles", {
42
+ enumerable: !0,
43
+ configurable: !0,
44
+ writable: !0,
45
+ value: this.addDisposer(new C(T.new({}), () => O._new(this._root, {
46
+ themeTags: f(this.markerRectangles.template.get("themeTags", []), ["legend", "marker", "rectangle"])
47
+ }, [this.markerRectangles.template])))
48
+ });
49
+ }
50
+ _afterNew() {
51
+ this._settings.themeTags = f(this._settings.themeTags, ["legend"]), this.fields.push("name", "stroke", "fill"), super._afterNew();
52
+ }
53
+ /**
54
+ * @ignore
55
+ */
56
+ makeItemContainer(e) {
57
+ const t = this.children.push(this.itemContainers.make());
58
+ return t._setDataItem(e), this.itemContainers.push(t), t.states.create("disabled", {}), t;
59
+ }
60
+ /**
61
+ * @ignore
62
+ */
63
+ makeMarker() {
64
+ const e = this.markers.make();
65
+ return this.markers.push(e), e.states.create("disabled", {}), e;
66
+ }
67
+ /**
68
+ * @ignore
69
+ */
70
+ makeLabel() {
71
+ const e = this.labels.make();
72
+ return e.states.create("disabled", {}), e;
73
+ }
74
+ /**
75
+ * @ignore
76
+ */
77
+ makeValueLabel() {
78
+ const e = this.valueLabels.make();
79
+ return e.states.create("disabled", {}), e;
80
+ }
81
+ /**
82
+ * @ignore
83
+ */
84
+ makeMarkerRectangle() {
85
+ const e = this.markerRectangles.make();
86
+ return e.states.create("disabled", {}), e;
87
+ }
88
+ processDataItem(e) {
89
+ super.processDataItem(e);
90
+ const t = this.makeItemContainer(e), c = this.get("nameField"), r = this.get("fillField"), l = this.get("strokeField");
91
+ if (t) {
92
+ const o = this.get("clickTarget", "itemContainer"), s = e.dataContext;
93
+ s && s.set && s.set("legendDataItem", e), t._setDataItem(e), e.set("itemContainer", t);
94
+ const m = this.makeMarker();
95
+ if (m) {
96
+ t.children.push(m), m._setDataItem(e), e.set("marker", m);
97
+ const i = this.get("useDefaultMarker"), k = m.children.push(this.makeMarkerRectangle());
98
+ let g = e.get("fill"), n = e.get("stroke");
99
+ e.set("markerRectangle", k), s && s.get && (g = s.get(r, g), n = s.get(l, n)), n || (n = g), i ? s.on && (s.on(r, () => {
100
+ k.set("fill", s.get(r));
101
+ }), s.on(l, () => {
102
+ k.set("stroke", s.get(l));
103
+ })) : s && s.createLegendMarker && s.createLegendMarker(), k.setAll({ fill: g, stroke: n });
104
+ const a = s.component;
105
+ a && a.updateLegendMarker && a.updateLegendMarker(s);
106
+ }
107
+ const d = this.makeLabel();
108
+ if (d) {
109
+ t.children.push(d), d._setDataItem(e), e.set("label", d), d.text.on("text", () => {
110
+ t.setRaw("ariaLabel", d.text._getText() + (this.get("clickTarget") !== "none" ? "; " + this._t("Press ENTER to toggle") : "")), t.markDirtyAccessibility();
111
+ }), s && s.get && e.set("name", s.get(c));
112
+ let i = e.get("name");
113
+ i && d.set("text", i);
114
+ }
115
+ const v = this.makeValueLabel();
116
+ if (v && (t.children.push(v), v._setDataItem(e), e.set("valueLabel", v)), s && s.show && (s.on("visible", (i) => {
117
+ t.set("disabled", !i);
118
+ }), s.get("visible") || t.set("disabled", !0), o != "none")) {
119
+ let i = t;
120
+ o == "marker" && (i = m), this._addClickEvents(i, s, e);
121
+ }
122
+ this.children.values.sort((i, k) => {
123
+ const g = i.dataItem.dataContext, n = k.dataItem.dataContext;
124
+ if (g && n) {
125
+ const a = this.data.indexOf(g), h = this.data.indexOf(n);
126
+ if (a > h)
127
+ return 1;
128
+ if (a < h)
129
+ return -1;
130
+ }
131
+ return 0;
132
+ }), s && s.updateLegendValue && s.updateLegendValue();
133
+ }
134
+ }
135
+ _addClickEvents(e, t, c) {
136
+ e.set("cursorOverStyle", "pointer"), e.events.on("pointerover", () => {
137
+ const r = t.component;
138
+ r && r.hoverDataItem && r.hoverDataItem(t);
139
+ }), e.events.on("pointerout", () => {
140
+ const r = t.component;
141
+ r && r.hoverDataItem && r.unhoverDataItem(t);
142
+ }), e.events.on("click", () => {
143
+ const r = c.get("label").text._getText();
144
+ t.show && t.isHidden && (t.isHidden() || t.get("visible") === !1) ? (t.show(), e.set("disabled", !1), this._root.readerAlert(this._t("%1 shown", this._root.locale, r))) : t.hide && (t.hide(), e.set("disabled", !0), this._root.readerAlert(this._t("%1 hidden", this._root.locale, r)));
145
+ });
146
+ }
147
+ /**
148
+ * @ignore
149
+ */
150
+ disposeDataItem(e) {
151
+ super.disposeDataItem(e);
152
+ const t = e.dataContext;
153
+ t && t.get && t.get("legendDataItem") == e && t.set("legendDataItem", void 0);
154
+ let c = e.get("itemContainer");
155
+ c && (this.itemContainers.removeValue(c), c.dispose());
156
+ let r = e.get("marker");
157
+ r && (this.markers.removeValue(r), r.dispose());
158
+ let l = e.get("markerRectangle");
159
+ l && (this.markerRectangles.removeValue(l), l.dispose());
160
+ let o = e.get("label");
161
+ o && (this.labels.removeValue(o), o.dispose());
162
+ let s = e.get("valueLabel");
163
+ s && (this.valueLabels.removeValue(s), s.dispose());
164
+ }
165
+ }
166
+ Object.defineProperty(D, "className", {
167
+ enumerable: !0,
168
+ configurable: !0,
169
+ writable: !0,
170
+ value: "Legend"
171
+ });
172
+ Object.defineProperty(D, "classNames", {
173
+ enumerable: !0,
174
+ configurable: !0,
175
+ writable: !0,
176
+ value: V.classNames.concat([D.className])
177
+ });
178
+ const le = (y) => {
179
+ const e = K({
180
+ props: y,
181
+ name: "MuiHighlightLineChart"
182
+ }), {
183
+ seriesData: t,
184
+ height: c = "500px",
185
+ width: r = "100%",
186
+ chartId: l = "highlight-line-chart",
187
+ showLegend: o = !0,
188
+ loading: s = !1,
189
+ emptyMessage: m = "No data available",
190
+ sx: d,
191
+ ...v
192
+ } = e, i = {
193
+ ...e,
194
+ height: c,
195
+ width: r,
196
+ chartId: l,
197
+ showLegend: o,
198
+ loading: s,
199
+ emptyMessage: m
200
+ }, k = R(null), g = R(null), n = R(null);
201
+ return Q(() => {
202
+ if (!n.current) return;
203
+ const a = W.new(n.current);
204
+ g.current = a, a.setThemes([z.new(a)]);
205
+ const h = a.container.children.push(
206
+ B.new(a, {
207
+ panX: !0,
208
+ panY: !0,
209
+ wheelX: "panX",
210
+ wheelY: "zoomX",
211
+ pinchZoomX: !0
212
+ })
213
+ );
214
+ k.current = h, h.set(
215
+ "cursor",
216
+ $.new(a, {
217
+ behavior: "zoomX"
218
+ })
219
+ ).lineY.set("visible", !1);
220
+ const E = h.xAxes.push(
221
+ ee.new(a, {
222
+ maxDeviation: 0.3,
223
+ baseInterval: { timeUnit: "day", count: 1 },
224
+ renderer: G.new(a, {
225
+ minorGridEnabled: !0
226
+ })
227
+ })
228
+ ), S = h.yAxes.push(
229
+ I.new(a, {
230
+ renderer: U.new(a, {})
231
+ })
232
+ ), _ = [], P = Z.new(a, {});
233
+ t.forEach((u, L) => {
234
+ const b = u.color ? q(u.color) : P.getIndex(L), p = h.series.push(
235
+ te.new(a, {
236
+ name: u.name,
237
+ xAxis: E,
238
+ yAxis: S,
239
+ valueYField: "value",
240
+ valueXField: "date",
241
+ stroke: b,
242
+ fill: b,
243
+ tooltip: J.new(a, {
244
+ labelText: "{name}: {valueY}"
245
+ })
246
+ })
247
+ );
248
+ p.strokes.template.setAll({
249
+ strokeWidth: 2
250
+ }), p.data.setAll(u.data), _.push(p);
251
+ });
252
+ let x = null;
253
+ o && (x = h.children.push(
254
+ D.new(a, {
255
+ centerX: M(50),
256
+ x: M(50),
257
+ layout: a.horizontalLayout
258
+ })
259
+ ), x.data.setAll(h.series.values));
260
+ const F = 1, N = 0.2, Y = 4, j = (u) => {
261
+ var p;
262
+ const b = (p = u.target.dataItem) == null ? void 0 : p.dataContext;
263
+ b && (b.strokes.template.set("strokeOpacity", 1), b.strokes.template.set("strokeWidth", Y), _.forEach((w) => {
264
+ w !== b && (w.strokes.template.set("strokeOpacity", N), w.strokes.template.set("strokeWidth", 1));
265
+ }));
266
+ }, H = (u) => {
267
+ var p;
268
+ ((p = u.target.dataItem) == null ? void 0 : p.dataContext) && _.forEach((w) => {
269
+ w.strokes.template.set("strokeOpacity", F), w.strokes.template.set("strokeWidth", 2);
270
+ });
271
+ };
272
+ return x && (x.markers.template.events.on("pointerover", j), x.markers.template.events.on("pointerout", H)), h.appear(1e3, 100), _.forEach((u, L) => {
273
+ u.appear(1e3, 100 * (L + 1));
274
+ }), () => {
275
+ a.dispose();
276
+ };
277
+ }, [l, t, o]), {
278
+ chartDivRef: n,
279
+ seriesData: t,
280
+ height: c,
281
+ width: r,
282
+ chartId: l,
283
+ showLegend: o,
284
+ loading: s,
285
+ emptyMessage: m,
286
+ sx: d,
287
+ other: v,
288
+ ownerState: i
289
+ };
290
+ };
291
+ export {
292
+ le as useHighlightLineChartLogic
293
+ };
@@ -0,0 +1,12 @@
1
+ import { styled as t } from "@mui/material";
2
+ const o = t("div", {
3
+ name: "MuiHighlightLineChart",
4
+ slot: "Root"
5
+ })(({ ownerState: i }) => ({
6
+ position: "relative",
7
+ width: i.width,
8
+ height: i.height
9
+ }));
10
+ export {
11
+ o as HighlightLineChartRoot
12
+ };