@hybridcore/ui 1.6.29 → 1.6.30

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,22 +1,23 @@
1
- import { R as z, T as H, A as Z } from "../../../AnimatedTheme-ktdO3Bel.js";
2
- import { useThemeProps as $, useTheme as j } from "@mui/material";
3
- import q from "lodash";
4
- import { useId as J, useRef as K, useEffect as Q } from "react";
5
- import { humanizeLabel as ee } from "../_common/format.js";
6
- import { attachCombinedAxisTooltip as te } from "../_common/tooltip.js";
7
- import { colorSetFromPalette as re, applyDateAxisLabelFormat as se, applyValueFormat as oe } from "../_common/utils.js";
8
- import { c as d, p as X, b as U } from "../../../Entity-BJCuhdq_.js";
9
- import { X as ae, V as ie } from "../../../AxisRenderer-BCQoUJw6.js";
10
- import { A as V, a as ne } from "../../../AxisRendererY-AXWvGU6r.js";
11
- import { C as le } from "../../../CategoryAxis-B6NqW8qd.js";
12
- import { L as me } from "../../../LineSeries-D_IL2qGF.js";
13
- import { D as pe, G as de } from "../../../GaplessDateAxis-B2g2jgSG.js";
14
- import { B as ce } from "../../../Bullet-Djj7Vs9T.js";
15
- import { C as ue } from "../../../Circle-BnfBNKBD.js";
16
- import { X as fe } from "../../../XYCursor-CVUSpqb9.js";
17
- import { L as he } from "../../../Legend-CFvQiIfn.js";
18
- import { D as Ae } from "../../../DateAxis-DEXKps1S.js";
19
- const _ = 1.1, ge = {
1
+ import { R as q, T as J, A as K } from "../../../AnimatedTheme-ktdO3Bel.js";
2
+ import { useThemeProps as Q, useTheme as ee } from "@mui/material";
3
+ import te from "lodash";
4
+ import { useId as re, useRef as se, useEffect as oe } from "react";
5
+ import { humanizeLabel as ae } from "../_common/format.js";
6
+ import { attachCombinedAxisTooltip as ie } from "../_common/tooltip.js";
7
+ import { colorSetFromPalette as ne, applyDateAxisLabelFormat as le, applyValueFormat as me } from "../_common/utils.js";
8
+ import { c, p as b, b as P } from "../../../Entity-BJCuhdq_.js";
9
+ import { X as pe, V as ce } from "../../../AxisRenderer-BCQoUJw6.js";
10
+ import { A as R, a as de } from "../../../AxisRendererY-AXWvGU6r.js";
11
+ import { C as ue } from "../../../CategoryAxis-B6NqW8qd.js";
12
+ import { L as fe } from "../../../LineSeries-D_IL2qGF.js";
13
+ import { D as he, G as ge } from "../../../GaplessDateAxis-B2g2jgSG.js";
14
+ import { B as Ae } from "../../../Bullet-Djj7Vs9T.js";
15
+ import { C as ye } from "../../../Circle-BnfBNKBD.js";
16
+ import { L as xe } from "../../../LinearGradient-CxQyCSEB.js";
17
+ import { X as we } from "../../../XYCursor-CVUSpqb9.js";
18
+ import { L as ke } from "../../../Legend-CFvQiIfn.js";
19
+ import { D as Ce } from "../../../DateAxis-DEXKps1S.js";
20
+ const S = 1.1, ve = {
20
21
  millisecond: 1,
21
22
  second: 1e3,
22
23
  minute: 6e4,
@@ -25,35 +26,37 @@ const _ = 1.1, ge = {
25
26
  week: 6048e5,
26
27
  month: 2592e6,
27
28
  year: 31536e6
28
- }, _e = (E) => {
29
- const b = $({ props: E, name: "HCLineChart" }), {
29
+ }, ze = (W) => {
30
+ const X = Q({ props: W, name: "HCLineChart" }), {
30
31
  dimensions: t,
31
32
  values: m,
32
33
  data: w,
33
- initDelay: P = 0,
34
- baseInterval: n,
35
- colors: L,
34
+ initDelay: B = 0,
35
+ baseInterval: l,
36
+ colors: G,
36
37
  connectMissingData: k = !0,
37
38
  skipEmptyDates: C = !1,
38
- sx: R,
39
- ...W
40
- } = b, l = j(), N = `hc-line-chart-${J().replace(/:/g, "")}`, v = K(null);
41
- let h = null;
42
- t.length < 1 ? h = "Missing dimensions config!" : m.length < 1 && (h = "Missing values config!"), Q(() => {
43
- if (h) return;
44
- let T;
45
- return T = setTimeout(() => {
46
- var G, O, I, M;
47
- const e = z.new(N);
48
- v.current = e;
49
- const S = H.new(e);
50
- e.setThemes([Z.new(e), S]), e.interfaceColors.setAll({
51
- text: d(l.palette.text.primary),
52
- grid: d(l.palette.divider),
53
- stroke: d(l.palette.divider)
39
+ areaFill: N = !1,
40
+ strokeDasharray: v,
41
+ sx: z,
42
+ ...H
43
+ } = X, p = ee(), O = `hc-line-chart-${re().replace(/:/g, "")}`, D = se(null);
44
+ let g = null;
45
+ t.length < 1 ? g = "Missing dimensions config!" : m.length < 1 && (g = "Missing values config!"), oe(() => {
46
+ if (g) return;
47
+ let F;
48
+ return F = setTimeout(() => {
49
+ var M, U, V, _;
50
+ const e = q.new(O);
51
+ D.current = e;
52
+ const $ = J.new(e);
53
+ e.setThemes([K.new(e), $]), e.interfaceColors.setAll({
54
+ text: c(p.palette.text.primary),
55
+ grid: c(p.palette.divider),
56
+ stroke: c(p.palette.divider)
54
57
  });
55
58
  const s = e.container.children.push(
56
- ae.new(e, {
59
+ pe.new(e, {
57
60
  panX: !0,
58
61
  panY: !0,
59
62
  wheelX: "none",
@@ -63,74 +66,74 @@ const _ = 1.1, ge = {
63
66
  maxTooltipDistance: -1,
64
67
  pinchZoomX: !0
65
68
  })
66
- );
67
- s.set("colors", re(e, L));
69
+ ), Y = ne(e, G);
70
+ s.set("colors", Y);
68
71
  let i, A = w;
69
72
  if (t[0].type === "date") {
70
- const o = C ? de : Ae;
73
+ const o = C ? ge : Ce;
71
74
  i = s.xAxes.push(
72
75
  o.new(e, {
73
76
  maxDeviation: 0.1,
74
77
  groupData: !1,
75
- baseInterval: n || { timeUnit: "day", count: 1 },
76
- renderer: V.new(e, {})
78
+ baseInterval: l || { timeUnit: "day", count: 1 },
79
+ renderer: R.new(e, {})
77
80
  })
78
- ), se(i, t[0]), A = q.orderBy(w, [t[0].value]);
81
+ ), le(i, t[0]), A = te.orderBy(w, [t[0].value]);
79
82
  } else
80
83
  i = s.xAxes.push(
81
- le.new(e, {
84
+ ue.new(e, {
82
85
  categoryField: t[0].value,
83
- renderer: V.new(e, {})
86
+ renderer: R.new(e, {})
84
87
  })
85
88
  ), e.numberFormatter.setAll({
86
89
  numberFormat: "#",
87
90
  numericFields: ["valueX"]
88
91
  }), i.data.setAll(A);
89
- const Y = s.yAxes.push(
90
- ie.new(e, {
91
- renderer: ne.new(e, {})
92
+ const I = s.yAxes.push(
93
+ ce.new(e, {
94
+ renderer: de.new(e, {})
92
95
  })
93
96
  );
94
- (G = i.get("renderer")) == null || G.grid.template.setAll({
95
- stroke: d(l.palette.divider),
97
+ (M = i.get("renderer")) == null || M.grid.template.setAll({
98
+ stroke: c(p.palette.divider),
96
99
  strokeOpacity: 1
97
- }), (O = i.get("renderer")) == null || O.labels.template.setAll({ paddingTop: 12 }), (I = Y.get("renderer")) == null || I.grid.template.setAll({
98
- stroke: d(l.palette.divider),
100
+ }), (U = i.get("renderer")) == null || U.labels.template.setAll({ paddingTop: 12 }), (V = I.get("renderer")) == null || V.grid.template.setAll({
101
+ stroke: c(p.palette.divider),
99
102
  strokeOpacity: 1
100
- }), m.forEach((o) => {
103
+ }), m.forEach((o, u) => {
101
104
  const a = s.series.push(
102
- me.new(e, {
105
+ fe.new(e, {
103
106
  // Legend/tooltip label: explicit override, else humanize the raw
104
107
  // backend field (snake_case / lowercase → Title Case).
105
- name: o.label ?? ee(o.name),
108
+ name: o.label ?? ae(o.name),
106
109
  xAxis: i,
107
- yAxis: Y,
110
+ yAxis: I,
108
111
  valueYField: o.dataFieldName,
109
112
  // When false, the line breaks at missing points. On a date axis the
110
113
  // break is auto-detected when adjacent points are spaced more than
111
114
  // `autoGapCount` (default 1.1) base intervals apart, so absent dates
112
115
  // surface as gaps instead of being bridged by a straight segment.
113
116
  connect: k,
114
- autoGapCount: _,
117
+ autoGapCount: S,
115
118
  ...t[0].type === "date" ? { valueXField: t[0].value } : { categoryXField: t[0].value }
116
119
  })
117
120
  );
118
- if (t[0].type === "date" && (a.data.processor = pe.new(e, {
121
+ if (t[0].type === "date" && (a.data.processor = he.new(e, {
119
122
  dateFormat: "i",
120
123
  dateFields: [t[0].value]
121
124
  })), t[0].type === "date" && !C) {
122
- const g = t[0].value, y = ge[(n == null ? void 0 : n.timeUnit) ?? "day"] * ((n == null ? void 0 : n.count) ?? 1), p = k ? 1 / 0 : y * _, x = A.map((r) => ({
123
- t: new Date(r[g]).getTime(),
125
+ const n = t[0].value, j = ve[(l == null ? void 0 : l.timeUnit) ?? "day"] * ((l == null ? void 0 : l.count) ?? 1), E = k ? 1 / 0 : j * S, x = A.map((r) => ({
126
+ t: new Date(r[n]).getTime(),
124
127
  hasValue: r[o.dataFieldName] !== null && r[o.dataFieldName] !== void 0
125
- })).filter((r) => r.hasValue && !Number.isNaN(r.t)), D = /* @__PURE__ */ new Set();
126
- x.forEach((r, u) => {
127
- const F = u > 0 ? r.t - x[u - 1].t : 1 / 0, f = u < x.length - 1 ? x[u + 1].t - r.t : 1 / 0;
128
- F > p && f > p && D.add(r.t);
129
- }), D.size > 0 && a.bullets.push((r, u, F) => {
130
- const f = F.dataContext;
131
- if (D.has(new Date(f == null ? void 0 : f[g]).getTime()))
132
- return ce.new(r, {
133
- sprite: ue.new(r, {
128
+ })).filter((r) => r.hasValue && !Number.isNaN(r.t)), T = /* @__PURE__ */ new Set();
129
+ x.forEach((r, f) => {
130
+ const L = f > 0 ? r.t - x[f - 1].t : 1 / 0, h = f < x.length - 1 ? x[f + 1].t - r.t : 1 / 0;
131
+ L > E && h > E && T.add(r.t);
132
+ }), T.size > 0 && a.bullets.push((r, f, L) => {
133
+ const h = L.dataContext;
134
+ if (T.has(new Date(h == null ? void 0 : h[n]).getTime()))
135
+ return Ae.new(r, {
136
+ sprite: ye.new(r, {
134
137
  radius: 3,
135
138
  fill: a.get("fill"),
136
139
  stroke: r.interfaceColors.get("background"),
@@ -139,38 +142,56 @@ const _ = 1.1, ge = {
139
142
  });
140
143
  });
141
144
  }
142
- a.data.setAll(A), a.strokes.template.setAll({ strokeWidth: 2 }), a.appear();
145
+ const y = N && m.length === 1;
146
+ if (a.data.setAll(A), a.strokes.template.setAll({
147
+ strokeWidth: 2,
148
+ ...v && { strokeDasharray: v }
149
+ }), y) {
150
+ const n = a.get("fill") ?? Y.getIndex(u);
151
+ a.fills.template.setAll({
152
+ visible: !0,
153
+ fillOpacity: 1,
154
+ fillGradient: xe.new(e, {
155
+ rotation: 90,
156
+ stops: [
157
+ { color: n, opacity: 0.6 },
158
+ { color: n, opacity: 0 }
159
+ ]
160
+ })
161
+ });
162
+ }
163
+ a.appear();
143
164
  }), s.set(
144
165
  "cursor",
145
- fe.new(e, { xAxis: i, behavior: "none" })
146
- ).lineY.set("visible", !1), te({
166
+ we.new(e, { xAxis: i, behavior: "none" })
167
+ ).lineY.set("visible", !1), ie({
147
168
  root: e,
148
169
  chart: s,
149
170
  xAxis: i,
150
- theme: l,
171
+ theme: p,
151
172
  isDateAxis: t[0].type === "date",
152
- baseInterval: n,
173
+ baseInterval: l,
153
174
  follow: !0
154
175
  });
155
- const c = s.bottomAxesContainer.children.push(
156
- he.new(e, {
157
- width: X(100),
176
+ const d = s.bottomAxesContainer.children.push(
177
+ ke.new(e, {
178
+ width: b(100),
158
179
  paddingTop: 10,
159
- centerX: X(50),
160
- x: X(50),
180
+ centerX: b(50),
181
+ x: b(50),
161
182
  layout: e.gridLayout
162
183
  })
163
184
  );
164
- c.itemContainers.template.events.on("pointerover", function(o) {
185
+ d.itemContainers.template.events.on("pointerover", function(o) {
165
186
  var y;
166
- const a = o.target, g = (y = a == null ? void 0 : a.dataItem) == null ? void 0 : y.dataContext;
167
- s.series.each(function(p) {
168
- p !== g ? p.strokes.template.setAll({
187
+ const u = o.target, a = (y = u == null ? void 0 : u.dataItem) == null ? void 0 : y.dataContext;
188
+ s.series.each(function(n) {
189
+ n !== a ? n.strokes.template.setAll({
169
190
  strokeOpacity: 0.15,
170
- stroke: d(0)
171
- }) : p.strokes.template.setAll({ strokeWidth: 3 });
191
+ stroke: c(0)
192
+ }) : n.strokes.template.setAll({ strokeWidth: 3 });
172
193
  });
173
- }), c.itemContainers.template.events.on("pointerout", function() {
194
+ }), d.itemContainers.template.events.on("pointerout", function() {
174
195
  s.series.each(function(o) {
175
196
  o.strokes.template.setAll({
176
197
  strokeOpacity: 1,
@@ -178,26 +199,28 @@ const _ = 1.1, ge = {
178
199
  stroke: o.get("fill")
179
200
  });
180
201
  });
181
- }), c.itemContainers.template.set("width", U), c.valueLabels.template.setAll({
182
- width: U,
202
+ }), d.itemContainers.template.set("width", P), d.valueLabels.template.setAll({
203
+ width: P,
183
204
  textAlign: "right"
184
- }), c.data.setAll(s.series.values), oe(e, (M = m == null ? void 0 : m[0]) == null ? void 0 : M.format), s.appear(1e3, 100);
185
- }, P), () => {
205
+ }), d.data.setAll(s.series.values), me(e, (_ = m == null ? void 0 : m[0]) == null ? void 0 : _.format), s.appear(1e3, 100);
206
+ }, B), () => {
186
207
  var e;
187
- T && clearTimeout(T), (e = v.current) == null || e.dispose(), v.current = null;
208
+ F && clearTimeout(F), (e = D.current) == null || e.dispose(), D.current = null;
188
209
  };
189
210
  }, [
190
211
  w,
191
212
  t,
192
213
  m,
193
- l.palette.mode,
194
- L,
214
+ p.palette.mode,
215
+ G,
195
216
  k,
196
- C
217
+ C,
218
+ N,
219
+ v
197
220
  ]);
198
- const B = { ...b };
199
- return { chartId: N, ownerState: B, sx: R, error: h, other: W };
221
+ const Z = { ...X };
222
+ return { chartId: O, ownerState: Z, sx: z, error: g, other: H };
200
223
  };
201
224
  export {
202
- _e as useLineChartLogic
225
+ ze as useLineChartLogic
203
226
  };