@hybridcore/ui 1.6.22 → 1.6.23

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,45 +1,211 @@
1
- import { R as T, A as Y } from "../../../AnimatedTheme-ktdO3Bel.js";
2
- import { useThemeProps as R, useTheme as E } from "@mui/material";
3
- import I from "lodash";
4
- import { useId as G, useRef as O, useEffect as P } from "react";
5
- import { humanizeLabel as V } from "../_common/format.js";
1
+ import { R as O, A as L } from "../../../AnimatedTheme-ktdO3Bel.js";
2
+ import { useThemeProps as X, useTheme as S } from "@mui/material";
3
+ import j from "lodash";
4
+ import { useId as E, useRef as Y, useEffect as z } from "react";
5
+ import { humanizeLabel as I } from "../_common/format.js";
6
6
  import { attachCombinedAxisTooltip as q } from "../_common/tooltip.js";
7
- import { colorSetFromPalette as z, applyDateAxisLabelFormat as B, applyValueFormat as H } from "../_common/utils.js";
8
- import { c as i } from "../../../Entity-BJCuhdq_.js";
9
- import { X as N, V as U } from "../../../AxisRenderer-BCQoUJw6.js";
10
- import { X as W } from "../../../XYCursor-CVUSpqb9.js";
11
- import { A as F, a as Z } from "../../../AxisRendererY-AXWvGU6r.js";
12
- import { C as _ } from "../../../CategoryAxis-B6NqW8qd.js";
13
- import { L as $ } from "../../../LineSeries-D_IL2qGF.js";
14
- import { D as j, G as J } from "../../../GaplessDateAxis-B2g2jgSG.js";
15
- import { S as K } from "../../../Scrollbar-CTI7_8Qw.js";
16
- import { D as M } from "../../../DateAxis-DEXKps1S.js";
17
- const xe = (X) => {
18
- const f = R({ props: X, name: "HCLogaritmicScale" }), {
19
- dimensions: t,
20
- values: s,
21
- data: p,
22
- initDelay: k = 0,
23
- baseInterval: h,
24
- colors: A,
25
- skipEmptyDates: x = !1,
26
- sx: L,
27
- ...S
28
- } = f, a = E(), g = `hc-logaritmic-scale-${G().replace(/:/g, "")}`, c = O(null);
29
- let n = null;
30
- t.length < 1 ? n = "LogaritmicScale requires at least 1 dimension" : s.length < 1 && (n = "LogaritmicScale requires at least 1 value"), P(() => {
31
- if (n) return;
32
- let d;
33
- return d = setTimeout(() => {
34
- var w, v, D, b;
35
- const e = T.new(g);
36
- c.current = e, e.setThemes([Y.new(e)]), e.interfaceColors.setAll({
37
- text: i(a.palette.text.primary),
38
- grid: i(a.palette.divider),
39
- stroke: i(a.palette.divider)
7
+ import { colorSetFromPalette as H, applyDateAxisLabelFormat as U, applyValueFormat as W } from "../_common/utils.js";
8
+ import { m as R, q as Z, f as x, c as f } from "../../../Entity-BJCuhdq_.js";
9
+ import { X as $, V as J } from "../../../AxisRenderer-BCQoUJw6.js";
10
+ import { X as K } from "../../../XYCursor-CVUSpqb9.js";
11
+ import { A as N, a as Q } from "../../../AxisRendererY-AXWvGU6r.js";
12
+ import { C as tt } from "../../../CategoryAxis-B6NqW8qd.js";
13
+ import { L as et } from "../../../LineSeries-D_IL2qGF.js";
14
+ import { D as st, G as it } from "../../../GaplessDateAxis-B2g2jgSG.js";
15
+ import { R as V } from "../../../RoundedRectangle-BKLX1LKM.js";
16
+ import { C, G as rt } from "../../../Tooltip-vyZRZWih.js";
17
+ import { B as at } from "../../../Button-BLY4PVJC.js";
18
+ import { D as nt } from "../../../DateAxis-DEXKps1S.js";
19
+ class D extends C {
20
+ constructor() {
21
+ super(...arguments), Object.defineProperty(this, "thumb", {
22
+ enumerable: !0,
23
+ configurable: !0,
24
+ writable: !0,
25
+ value: this._makeThumb()
26
+ }), Object.defineProperty(this, "startGrip", {
27
+ enumerable: !0,
28
+ configurable: !0,
29
+ writable: !0,
30
+ value: this._makeButton()
31
+ }), Object.defineProperty(this, "endGrip", {
32
+ enumerable: !0,
33
+ configurable: !0,
34
+ writable: !0,
35
+ value: this._makeButton()
36
+ }), Object.defineProperty(this, "_thumbBusy", {
37
+ enumerable: !0,
38
+ configurable: !0,
39
+ writable: !0,
40
+ value: !1
41
+ }), Object.defineProperty(this, "_startDown", {
42
+ enumerable: !0,
43
+ configurable: !0,
44
+ writable: !0,
45
+ value: !1
46
+ }), Object.defineProperty(this, "_endDown", {
47
+ enumerable: !0,
48
+ configurable: !0,
49
+ writable: !0,
50
+ value: !1
51
+ }), Object.defineProperty(this, "_thumbDown", {
52
+ enumerable: !0,
53
+ configurable: !0,
54
+ writable: !0,
55
+ value: !1
56
+ }), Object.defineProperty(this, "_gripDown", {
57
+ enumerable: !0,
58
+ configurable: !0,
59
+ writable: !0,
60
+ value: void 0
61
+ });
62
+ }
63
+ _addOrientationClass() {
64
+ this._settings.themeTags = R(this._settings.themeTags, ["scrollbar", this._settings.orientation]), this._settings.background || (this._settings.background = V.new(this._root, {
65
+ themeTags: R(this._settings.themeTags, ["main", "background"])
66
+ }));
67
+ }
68
+ _makeButton() {
69
+ return this.children.push(at.new(this._root, {
70
+ themeTags: ["resize", "button", this.get("orientation")],
71
+ icon: rt.new(this._root, {
72
+ themeTags: ["icon"]
73
+ })
74
+ }));
75
+ }
76
+ _makeThumb() {
77
+ return this.children.push(V.new(this._root, {
78
+ themeTags: ["thumb", this.get("orientation")]
79
+ }));
80
+ }
81
+ _handleAnimation(t) {
82
+ t && this._disposers.push(t.events.on("stopped", () => {
83
+ this.setPrivateRaw("isBusy", !1), this._thumbBusy = !1;
84
+ }));
85
+ }
86
+ _afterNew() {
87
+ this._addOrientationClass(), super._afterNew();
88
+ const t = this.startGrip, e = this.endGrip, i = this.thumb, o = this.get("background");
89
+ o && this._disposers.push(o.events.on("click", (s) => {
90
+ this.setPrivateRaw("isBusy", !0);
91
+ const n = this._display.toLocal(s.point), h = this.width(), l = this.height(), d = this.get("orientation");
92
+ let u;
93
+ d == "vertical" ? u = (n.y - i.height() / 2) / l : u = (n.x - i.width() / 2) / h;
94
+ let a, p;
95
+ d == "vertical" ? (a = u * l, p = "y") : (a = u * h, p = "x");
96
+ const m = this.get("animationDuration", 0);
97
+ m > 0 ? (this._thumbBusy = !0, this._handleAnimation(this.thumb.animate({ key: p, to: a, duration: m, easing: this.get("animationEasing") }))) : (this.thumb.set(p, a), this._root.events.once("frameended", () => {
98
+ this.setPrivateRaw("isBusy", !1);
99
+ }));
100
+ })), this._disposers.push(i.events.on("dblclick", (s) => {
101
+ if (!Z(s.originalEvent, this))
102
+ return;
103
+ const n = this.get("animationDuration", 0), h = this.get("animationEasing");
104
+ this.animate({ key: "start", to: 0, duration: n, easing: h }), this.animate({ key: "end", to: 1, duration: n, easing: h });
105
+ })), this._disposers.push(t.events.on("pointerdown", () => {
106
+ this.setPrivateRaw("isBusy", !0), this._startDown = !0, this._gripDown = "start";
107
+ })), this._disposers.push(e.events.on("pointerdown", () => {
108
+ this.setPrivateRaw("isBusy", !0), this._endDown = !0, this._gripDown = "end";
109
+ })), this._disposers.push(i.events.on("pointerdown", () => {
110
+ this.setPrivateRaw("isBusy", !0), this._thumbDown = !0, this._gripDown = void 0;
111
+ })), this._disposers.push(t.events.on("globalpointerup", () => {
112
+ this._startDown && (this.setPrivateRaw("isBusy", !1), this._released()), this._startDown = !1;
113
+ })), this._disposers.push(e.events.on("globalpointerup", () => {
114
+ this._endDown && (this.setPrivateRaw("isBusy", !1), this._released()), this._endDown = !1;
115
+ })), this._disposers.push(i.events.on("globalpointerup", () => {
116
+ this._thumbDown && (this.setPrivateRaw("isBusy", !1), this._released()), this._thumbDown = !1;
117
+ })), this._disposers.push(t.on("x", () => {
118
+ this._updateThumb();
119
+ })), this._disposers.push(e.on("x", () => {
120
+ this._updateThumb();
121
+ })), this._disposers.push(t.on("y", () => {
122
+ this._updateThumb();
123
+ })), this._disposers.push(e.on("y", () => {
124
+ this._updateThumb();
125
+ })), this._disposers.push(i.events.on("positionchanged", () => {
126
+ this._updateGripsByThumb();
127
+ })), this.get("orientation") == "vertical" ? (t.set("x", 0), e.set("x", 0), this._disposers.push(i.adapters.add("y", (s) => Math.max(Math.min(Number(s), this.height() - i.height()), 0))), this._disposers.push(i.adapters.add("x", (s) => this.width() / 2)), this._disposers.push(t.adapters.add("x", (s) => this.width() / 2)), this._disposers.push(e.adapters.add("x", (s) => this.width() / 2)), this._disposers.push(t.adapters.add("y", (s) => Math.max(Math.min(Number(s), this.height()), 0))), this._disposers.push(e.adapters.add("y", (s) => Math.max(Math.min(Number(s), this.height()), 0)))) : (t.set("y", 0), e.set("y", 0), this._disposers.push(i.adapters.add("x", (s) => Math.max(Math.min(Number(s), this.width() - i.width()), 0))), this._disposers.push(i.adapters.add("y", (s) => this.height() / 2)), this._disposers.push(t.adapters.add("y", (s) => this.height() / 2)), this._disposers.push(e.adapters.add("y", (s) => this.height() / 2)), this._disposers.push(t.adapters.add("x", (s) => Math.max(Math.min(Number(s), this.width()), 0))), this._disposers.push(e.adapters.add("x", (s) => Math.max(Math.min(Number(s), this.width()), 0))));
128
+ }
129
+ _updateChildren() {
130
+ super._updateChildren(), (this.isDirty("end") || this.isDirty("start") || this._sizeDirty) && this.updateGrips();
131
+ }
132
+ _changed() {
133
+ if (super._changed(), this.isDirty("start") || this.isDirty("end")) {
134
+ const t = "rangechanged";
135
+ this.events.isEnabled(t) && this.events.dispatch(t, { type: t, target: this, start: this.get("start", 0), end: this.get("end", 1), grip: this._gripDown });
136
+ }
137
+ }
138
+ _released() {
139
+ const t = "released";
140
+ this.events.isEnabled(t) && this.events.dispatch(t, { type: t, target: this });
141
+ }
142
+ /**
143
+ * @ignore
144
+ */
145
+ updateGrips() {
146
+ const t = this.startGrip, e = this.endGrip, i = this.get("orientation"), o = this.height(), s = this.width();
147
+ i == "vertical" ? (t.set("y", o * this.get("start", 0)), e.set("y", o * this.get("end", 1))) : (t.set("x", s * this.get("start", 0)), e.set("x", s * this.get("end", 1)));
148
+ const n = this.getPrivate("positionTextFunction"), h = Math.round(this.get("start", 0) * 100), l = Math.round(this.get("end", 0) * 100);
149
+ let d, u;
150
+ n ? (d = n.call(this, this.get("start", 0)), u = n.call(this, this.get("end", 0))) : (d = h + "%", u = l + "%"), t.set("ariaLabel", this._t("From %1", void 0, d)), t.set("ariaValueNow", "" + h), t.set("ariaValueText", h + "%"), t.set("ariaValueMin", "0"), t.set("ariaValueMax", "100"), e.set("ariaLabel", this._t("To %1", void 0, u)), e.set("ariaValueNow", "" + l), e.set("ariaValueText", l + "%"), e.set("ariaValueMin", "0"), e.set("ariaValueMax", "100");
151
+ }
152
+ _updateThumb() {
153
+ const t = this.thumb, e = this.startGrip, i = this.endGrip, o = this.height(), s = this.width();
154
+ let n = e.x(), h = i.x(), l = e.y(), d = i.y(), u = 0, a = 1;
155
+ this.get("orientation") == "vertical" ? x(l) && x(d) && (!this._thumbBusy && !t.isDragging() && (t.set("height", d - l), t.set("y", l)), u = l / o, a = d / o) : x(n) && x(h) && (!this._thumbBusy && !t.isDragging() && (t.set("width", h - n), t.set("x", n)), u = n / s, a = h / s), this.getPrivate("isBusy") && (this.get("start") != u || this.get("end") != a) && (this.set("start", u), this.set("end", a));
156
+ const p = this.getPrivate("positionTextFunction"), m = Math.round(this.get("start", 0) * 100), _ = Math.round(this.get("end", 0) * 100);
157
+ let g, w;
158
+ p ? (g = p.call(this, this.get("start", 0)), w = p.call(this, this.get("end", 0))) : (g = m + "%", w = _ + "%"), t.set("ariaLabel", this._t("From %1 to %2", void 0, g, w)), t.set("ariaValueNow", "" + m), t.set("ariaValueText", m + "%");
159
+ }
160
+ _updateGripsByThumb() {
161
+ const t = this.thumb, e = this.startGrip, i = this.endGrip;
162
+ if (this.get("orientation") == "vertical") {
163
+ const o = t.height();
164
+ e.set("y", t.y()), i.set("y", t.y() + o);
165
+ } else {
166
+ const o = t.width();
167
+ e.set("x", t.x()), i.set("x", t.x() + o);
168
+ }
169
+ }
170
+ }
171
+ Object.defineProperty(D, "className", {
172
+ enumerable: !0,
173
+ configurable: !0,
174
+ writable: !0,
175
+ value: "Scrollbar"
176
+ });
177
+ Object.defineProperty(D, "classNames", {
178
+ enumerable: !0,
179
+ configurable: !0,
180
+ writable: !0,
181
+ value: C.classNames.concat([D.className])
182
+ });
183
+ const Gt = (G) => {
184
+ const t = X({ props: G, name: "HCLogaritmicScale" }), {
185
+ dimensions: e,
186
+ values: i,
187
+ data: o,
188
+ initDelay: s = 0,
189
+ baseInterval: n,
190
+ colors: h,
191
+ skipEmptyDates: l = !1,
192
+ sx: d,
193
+ ...u
194
+ } = t, a = S(), m = `hc-logaritmic-scale-${E().replace(/:/g, "")}`, _ = Y(null);
195
+ let g = null;
196
+ e.length < 1 ? g = "LogaritmicScale requires at least 1 dimension" : i.length < 1 && (g = "LogaritmicScale requires at least 1 value"), z(() => {
197
+ if (g) return;
198
+ let T;
199
+ return T = setTimeout(() => {
200
+ var P, B, M, F;
201
+ const r = O.new(m);
202
+ _.current = r, r.setThemes([L.new(r)]), r.interfaceColors.setAll({
203
+ text: f(a.palette.text.primary),
204
+ grid: f(a.palette.divider),
205
+ stroke: f(a.palette.divider)
40
206
  });
41
- const r = e.container.children.push(
42
- N.new(e, {
207
+ const c = r.container.children.push(
208
+ $.new(r, {
43
209
  panX: !0,
44
210
  panY: !0,
45
211
  wheelX: "none",
@@ -48,81 +214,81 @@ const xe = (X) => {
48
214
  pinchZoomX: !0
49
215
  })
50
216
  );
51
- r.set("colors", z(e, A)), r.set(
217
+ c.set("colors", H(r, h)), c.set(
52
218
  "cursor",
53
- W.new(e, { behavior: "none" })
219
+ K.new(r, { behavior: "none" })
54
220
  ).lineY.set("visible", !1);
55
- let o, u = p;
56
- if (t[0].type === "date") {
57
- u = I.orderBy(p, [t[0].value]);
58
- const l = x ? J : M;
59
- o = r.xAxes.push(
60
- l.new(e, {
221
+ let b, A = o;
222
+ if (e[0].type === "date") {
223
+ A = j.orderBy(o, [e[0].value]);
224
+ const y = l ? it : nt;
225
+ b = c.xAxes.push(
226
+ y.new(r, {
61
227
  maxDeviation: 0.1,
62
228
  groupData: !1,
63
- baseInterval: h || { timeUnit: "day", count: 1 },
64
- renderer: F.new(e, {})
229
+ baseInterval: n || { timeUnit: "day", count: 1 },
230
+ renderer: N.new(r, {})
65
231
  })
66
- ), (w = o.get("renderer")) == null || w.grid.template.setAll({
67
- stroke: i(a.palette.divider),
232
+ ), (P = b.get("renderer")) == null || P.grid.template.setAll({
233
+ stroke: f(a.palette.divider),
68
234
  strokeOpacity: 1
69
- }), B(o, t[0]);
235
+ }), U(b, e[0]);
70
236
  } else
71
- o = r.xAxes.push(
72
- _.new(e, {
73
- categoryField: t[0].value,
74
- renderer: F.new(e, {})
237
+ b = c.xAxes.push(
238
+ tt.new(r, {
239
+ categoryField: e[0].value,
240
+ renderer: N.new(r, {})
75
241
  })
76
- ), e.numberFormatter.setAll({
242
+ ), r.numberFormatter.setAll({
77
243
  numberFormat: "#",
78
244
  numericFields: ["valueX"]
79
- }), o.data.setAll(u), (v = o.get("renderer")) == null || v.grid.template.setAll({
80
- stroke: i(a.palette.divider),
245
+ }), b.data.setAll(A), (B = b.get("renderer")) == null || B.grid.template.setAll({
246
+ stroke: f(a.palette.divider),
81
247
  strokeOpacity: 1
82
248
  });
83
- const y = r.yAxes.push(
84
- U.new(e, {
249
+ const k = c.yAxes.push(
250
+ J.new(r, {
85
251
  logarithmic: !0,
86
- renderer: Z.new(e, { minorGridEnabled: !0 })
252
+ renderer: Q.new(r, { minorGridEnabled: !0 })
87
253
  })
88
254
  );
89
- (D = y.get("renderer")) == null || D.grid.template.setAll({
90
- stroke: i(a.palette.divider),
255
+ (M = k.get("renderer")) == null || M.grid.template.setAll({
256
+ stroke: f(a.palette.divider),
91
257
  strokeOpacity: 1
92
- }), s.forEach((l) => {
93
- const m = r.series.push(
94
- $.new(e, {
95
- name: l.label ?? V(l.name),
96
- xAxis: o,
97
- yAxis: y,
98
- valueYField: l.dataFieldName,
99
- ...t[0].type === "date" ? { valueXField: t[0].value } : { categoryXField: t[0].value }
258
+ }), i.forEach((y) => {
259
+ const v = c.series.push(
260
+ et.new(r, {
261
+ name: y.label ?? I(y.name),
262
+ xAxis: b,
263
+ yAxis: k,
264
+ valueYField: y.dataFieldName,
265
+ ...e[0].type === "date" ? { valueXField: e[0].value } : { categoryXField: e[0].value }
100
266
  })
101
267
  );
102
- m.strokes.template.setAll({ strokeWidth: 3 }), t[0].type === "date" && (m.data.processor = j.new(e, {
268
+ v.strokes.template.setAll({ strokeWidth: 3 }), e[0].type === "date" && (v.data.processor = st.new(r, {
103
269
  dateFormat: "i",
104
- dateFields: [t[0].value]
105
- })), m.data.setAll(u), m.appear(1e3);
270
+ dateFields: [e[0].value]
271
+ })), v.data.setAll(A), v.appear(1e3);
106
272
  }), q({
107
- root: e,
108
- chart: r,
109
- xAxis: o,
273
+ root: r,
274
+ chart: c,
275
+ xAxis: b,
110
276
  theme: a,
111
- isDateAxis: t[0].type === "date",
112
- baseInterval: h,
277
+ isDateAxis: e[0].type === "date",
278
+ baseInterval: n,
113
279
  follow: !0
114
- }), r.set(
280
+ }), c.set(
115
281
  "scrollbarX",
116
- K.new(e, { orientation: "horizontal" })
117
- ), H(e, (b = s == null ? void 0 : s[0]) == null ? void 0 : b.format), r.appear(1e3, 100);
118
- }, k), () => {
119
- var e;
120
- d && clearTimeout(d), (e = c.current) == null || e.dispose(), c.current = null;
282
+ D.new(r, { orientation: "horizontal" })
283
+ ), W(r, (F = i == null ? void 0 : i[0]) == null ? void 0 : F.format), c.appear(1e3, 100);
284
+ }, s), () => {
285
+ var r;
286
+ T && clearTimeout(T), (r = _.current) == null || r.dispose(), _.current = null;
121
287
  };
122
- }, [p, t, s, a.palette.mode, A, x]);
123
- const C = { ...f };
124
- return { chartId: g, ownerState: C, sx: L, error: n, other: S };
288
+ }, [o, e, i, a.palette.mode, h, l]);
289
+ const w = { ...t };
290
+ return { chartId: m, ownerState: w, sx: d, error: g, other: u };
125
291
  };
126
292
  export {
127
- xe as useLogaritmicScaleLogic
293
+ Gt as useLogaritmicScaleLogic
128
294
  };
package/dist/main.d.ts CHANGED
@@ -787,21 +787,31 @@ export declare interface ForecastConeChartProps {
787
787
  * Omit for the single-cone behaviour (cone extracted from `data`).
788
788
  */
789
789
  forecasts?: ForecastSnapshot[];
790
+ /**
791
+ * Multi-cone mode only. When `true` (default) each forecast origin gets a
792
+ * bullet on the history line: hovering one previews that run's cone, clicking
793
+ * it selects the run. When `false` the origins are marked with faint dashed
794
+ * ticks instead and only the pager switches cones.
795
+ */
796
+ showOriginMarkers?: boolean;
790
797
  /** Vertical "now" marker; defaults to the last history timestamp. */
791
798
  nowValue?: number | string;
792
799
  /** Band/centre hue (theme token or CSS color). Defaults to a theme token. */
793
800
  color?: string;
794
801
  /**
795
- * History line behaviour across missing dates. `true` (default) bridges gaps
796
- * (and connects the history end to the cone apex); `false` breaks the line
797
- * wherever a history point is missing and drops the bridge to the forecast.
798
- * Affects the history series only the bands/centre are contiguous.
802
+ * Line behaviour across missing dates. `true` (default) bridges gaps (and, in
803
+ * single-cone mode, connects the history end to the cone apex); `false` breaks
804
+ * the line wherever a point is missing and drops the bridge to the forecast.
805
+ * Applies to the history line and to the cone (bands + centre) alike, so a
806
+ * horizon row missing its bounds splits the cone instead of bridging it.
799
807
  */
800
808
  connectMissingData?: boolean;
801
809
  /**
802
- * When `true`, the date axis drops intervals with no data (`GaplessDateAxis`),
803
- * so only dates with values are shown. Default `false` keeps the continuous
804
- * timeline.
810
+ * When `true` (default), the date axis drops intervals with no data
811
+ * (`GaplessDateAxis`), so only dates with values are shown closed hours and
812
+ * weekends collapse instead of rendering as flat gaps. `false` keeps the
813
+ * continuous timeline. In multi-cone mode the axis is fed the union of every
814
+ * snapshot's dates, so the frame stays fixed while scrubbing.
805
815
  */
806
816
  skipEmptyDates?: boolean;
807
817
  baseInterval?: BaseInterval;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hybridcore/ui",
3
3
  "description": "Hybrid Core UI Library",
4
- "version": "1.6.22",
4
+ "version": "1.6.23",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",
@@ -1,171 +0,0 @@
1
- import { R as b } from "./RoundedRectangle-BKLX1LKM.js";
2
- import { C as w, G as v } from "./Tooltip-vyZRZWih.js";
3
- import { B as x } from "./Button-BLY4PVJC.js";
4
- import { m as f, q as D, f as g } from "./Entity-BJCuhdq_.js";
5
- class _ extends w {
6
- constructor() {
7
- super(...arguments), Object.defineProperty(this, "thumb", {
8
- enumerable: !0,
9
- configurable: !0,
10
- writable: !0,
11
- value: this._makeThumb()
12
- }), Object.defineProperty(this, "startGrip", {
13
- enumerable: !0,
14
- configurable: !0,
15
- writable: !0,
16
- value: this._makeButton()
17
- }), Object.defineProperty(this, "endGrip", {
18
- enumerable: !0,
19
- configurable: !0,
20
- writable: !0,
21
- value: this._makeButton()
22
- }), Object.defineProperty(this, "_thumbBusy", {
23
- enumerable: !0,
24
- configurable: !0,
25
- writable: !0,
26
- value: !1
27
- }), Object.defineProperty(this, "_startDown", {
28
- enumerable: !0,
29
- configurable: !0,
30
- writable: !0,
31
- value: !1
32
- }), Object.defineProperty(this, "_endDown", {
33
- enumerable: !0,
34
- configurable: !0,
35
- writable: !0,
36
- value: !1
37
- }), Object.defineProperty(this, "_thumbDown", {
38
- enumerable: !0,
39
- configurable: !0,
40
- writable: !0,
41
- value: !1
42
- }), Object.defineProperty(this, "_gripDown", {
43
- enumerable: !0,
44
- configurable: !0,
45
- writable: !0,
46
- value: void 0
47
- });
48
- }
49
- _addOrientationClass() {
50
- this._settings.themeTags = f(this._settings.themeTags, ["scrollbar", this._settings.orientation]), this._settings.background || (this._settings.background = b.new(this._root, {
51
- themeTags: f(this._settings.themeTags, ["main", "background"])
52
- }));
53
- }
54
- _makeButton() {
55
- return this.children.push(x.new(this._root, {
56
- themeTags: ["resize", "button", this.get("orientation")],
57
- icon: v.new(this._root, {
58
- themeTags: ["icon"]
59
- })
60
- }));
61
- }
62
- _makeThumb() {
63
- return this.children.push(b.new(this._root, {
64
- themeTags: ["thumb", this.get("orientation")]
65
- }));
66
- }
67
- _handleAnimation(t) {
68
- t && this._disposers.push(t.events.on("stopped", () => {
69
- this.setPrivateRaw("isBusy", !1), this._thumbBusy = !1;
70
- }));
71
- }
72
- _afterNew() {
73
- this._addOrientationClass(), super._afterNew();
74
- const t = this.startGrip, s = this.endGrip, i = this.thumb, n = this.get("background");
75
- n && this._disposers.push(n.events.on("click", (e) => {
76
- this.setPrivateRaw("isBusy", !0);
77
- const a = this._display.toLocal(e.point), r = this.width(), o = this.height(), u = this.get("orientation");
78
- let h;
79
- u == "vertical" ? h = (a.y - i.height() / 2) / o : h = (a.x - i.width() / 2) / r;
80
- let d, l;
81
- u == "vertical" ? (d = h * o, l = "y") : (d = h * r, l = "x");
82
- const p = this.get("animationDuration", 0);
83
- p > 0 ? (this._thumbBusy = !0, this._handleAnimation(this.thumb.animate({ key: l, to: d, duration: p, easing: this.get("animationEasing") }))) : (this.thumb.set(l, d), this._root.events.once("frameended", () => {
84
- this.setPrivateRaw("isBusy", !1);
85
- }));
86
- })), this._disposers.push(i.events.on("dblclick", (e) => {
87
- if (!D(e.originalEvent, this))
88
- return;
89
- const a = this.get("animationDuration", 0), r = this.get("animationEasing");
90
- this.animate({ key: "start", to: 0, duration: a, easing: r }), this.animate({ key: "end", to: 1, duration: a, easing: r });
91
- })), this._disposers.push(t.events.on("pointerdown", () => {
92
- this.setPrivateRaw("isBusy", !0), this._startDown = !0, this._gripDown = "start";
93
- })), this._disposers.push(s.events.on("pointerdown", () => {
94
- this.setPrivateRaw("isBusy", !0), this._endDown = !0, this._gripDown = "end";
95
- })), this._disposers.push(i.events.on("pointerdown", () => {
96
- this.setPrivateRaw("isBusy", !0), this._thumbDown = !0, this._gripDown = void 0;
97
- })), this._disposers.push(t.events.on("globalpointerup", () => {
98
- this._startDown && (this.setPrivateRaw("isBusy", !1), this._released()), this._startDown = !1;
99
- })), this._disposers.push(s.events.on("globalpointerup", () => {
100
- this._endDown && (this.setPrivateRaw("isBusy", !1), this._released()), this._endDown = !1;
101
- })), this._disposers.push(i.events.on("globalpointerup", () => {
102
- this._thumbDown && (this.setPrivateRaw("isBusy", !1), this._released()), this._thumbDown = !1;
103
- })), this._disposers.push(t.on("x", () => {
104
- this._updateThumb();
105
- })), this._disposers.push(s.on("x", () => {
106
- this._updateThumb();
107
- })), this._disposers.push(t.on("y", () => {
108
- this._updateThumb();
109
- })), this._disposers.push(s.on("y", () => {
110
- this._updateThumb();
111
- })), this._disposers.push(i.events.on("positionchanged", () => {
112
- this._updateGripsByThumb();
113
- })), this.get("orientation") == "vertical" ? (t.set("x", 0), s.set("x", 0), this._disposers.push(i.adapters.add("y", (e) => Math.max(Math.min(Number(e), this.height() - i.height()), 0))), this._disposers.push(i.adapters.add("x", (e) => this.width() / 2)), this._disposers.push(t.adapters.add("x", (e) => this.width() / 2)), this._disposers.push(s.adapters.add("x", (e) => this.width() / 2)), this._disposers.push(t.adapters.add("y", (e) => Math.max(Math.min(Number(e), this.height()), 0))), this._disposers.push(s.adapters.add("y", (e) => Math.max(Math.min(Number(e), this.height()), 0)))) : (t.set("y", 0), s.set("y", 0), this._disposers.push(i.adapters.add("x", (e) => Math.max(Math.min(Number(e), this.width() - i.width()), 0))), this._disposers.push(i.adapters.add("y", (e) => this.height() / 2)), this._disposers.push(t.adapters.add("y", (e) => this.height() / 2)), this._disposers.push(s.adapters.add("y", (e) => this.height() / 2)), this._disposers.push(t.adapters.add("x", (e) => Math.max(Math.min(Number(e), this.width()), 0))), this._disposers.push(s.adapters.add("x", (e) => Math.max(Math.min(Number(e), this.width()), 0))));
114
- }
115
- _updateChildren() {
116
- super._updateChildren(), (this.isDirty("end") || this.isDirty("start") || this._sizeDirty) && this.updateGrips();
117
- }
118
- _changed() {
119
- if (super._changed(), this.isDirty("start") || this.isDirty("end")) {
120
- const t = "rangechanged";
121
- this.events.isEnabled(t) && this.events.dispatch(t, { type: t, target: this, start: this.get("start", 0), end: this.get("end", 1), grip: this._gripDown });
122
- }
123
- }
124
- _released() {
125
- const t = "released";
126
- this.events.isEnabled(t) && this.events.dispatch(t, { type: t, target: this });
127
- }
128
- /**
129
- * @ignore
130
- */
131
- updateGrips() {
132
- const t = this.startGrip, s = this.endGrip, i = this.get("orientation"), n = this.height(), e = this.width();
133
- i == "vertical" ? (t.set("y", n * this.get("start", 0)), s.set("y", n * this.get("end", 1))) : (t.set("x", e * this.get("start", 0)), s.set("x", e * this.get("end", 1)));
134
- const a = this.getPrivate("positionTextFunction"), r = Math.round(this.get("start", 0) * 100), o = Math.round(this.get("end", 0) * 100);
135
- let u, h;
136
- a ? (u = a.call(this, this.get("start", 0)), h = a.call(this, this.get("end", 0))) : (u = r + "%", h = o + "%"), t.set("ariaLabel", this._t("From %1", void 0, u)), t.set("ariaValueNow", "" + r), t.set("ariaValueText", r + "%"), t.set("ariaValueMin", "0"), t.set("ariaValueMax", "100"), s.set("ariaLabel", this._t("To %1", void 0, h)), s.set("ariaValueNow", "" + o), s.set("ariaValueText", o + "%"), s.set("ariaValueMin", "0"), s.set("ariaValueMax", "100");
137
- }
138
- _updateThumb() {
139
- const t = this.thumb, s = this.startGrip, i = this.endGrip, n = this.height(), e = this.width();
140
- let a = s.x(), r = i.x(), o = s.y(), u = i.y(), h = 0, d = 1;
141
- this.get("orientation") == "vertical" ? g(o) && g(u) && (!this._thumbBusy && !t.isDragging() && (t.set("height", u - o), t.set("y", o)), h = o / n, d = u / n) : g(a) && g(r) && (!this._thumbBusy && !t.isDragging() && (t.set("width", r - a), t.set("x", a)), h = a / e, d = r / e), this.getPrivate("isBusy") && (this.get("start") != h || this.get("end") != d) && (this.set("start", h), this.set("end", d));
142
- const l = this.getPrivate("positionTextFunction"), p = Math.round(this.get("start", 0) * 100), y = Math.round(this.get("end", 0) * 100);
143
- let c, m;
144
- l ? (c = l.call(this, this.get("start", 0)), m = l.call(this, this.get("end", 0))) : (c = p + "%", m = y + "%"), t.set("ariaLabel", this._t("From %1 to %2", void 0, c, m)), t.set("ariaValueNow", "" + p), t.set("ariaValueText", p + "%");
145
- }
146
- _updateGripsByThumb() {
147
- const t = this.thumb, s = this.startGrip, i = this.endGrip;
148
- if (this.get("orientation") == "vertical") {
149
- const n = t.height();
150
- s.set("y", t.y()), i.set("y", t.y() + n);
151
- } else {
152
- const n = t.width();
153
- s.set("x", t.x()), i.set("x", t.x() + n);
154
- }
155
- }
156
- }
157
- Object.defineProperty(_, "className", {
158
- enumerable: !0,
159
- configurable: !0,
160
- writable: !0,
161
- value: "Scrollbar"
162
- });
163
- Object.defineProperty(_, "classNames", {
164
- enumerable: !0,
165
- configurable: !0,
166
- writable: !0,
167
- value: w.classNames.concat([_.className])
168
- });
169
- export {
170
- _ as S
171
- };