@cloudscape-design/chart-components 1.0.162 → 1.0.164

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.
Files changed (47) hide show
  1. package/core/chart-api/chart-extra-pointer.d.ts +3 -2
  2. package/core/chart-api/chart-extra-pointer.js +15 -6
  3. package/core/chart-api/chart-extra-pointer.js.map +1 -1
  4. package/core/chart-api/chart-extra-zoom.d.ts +58 -1
  5. package/core/chart-api/chart-extra-zoom.js +451 -23
  6. package/core/chart-api/chart-extra-zoom.js.map +1 -1
  7. package/core/chart-api/index.d.ts +11 -2
  8. package/core/chart-api/index.js +25 -9
  9. package/core/chart-api/index.js.map +1 -1
  10. package/core/chart-core.js +11 -5
  11. package/core/chart-core.js.map +1 -1
  12. package/core/chart-zoom/zoom-state-machine.d.ts +65 -0
  13. package/core/chart-zoom/zoom-state-machine.js +77 -0
  14. package/core/chart-zoom/zoom-state-machine.js.map +1 -0
  15. package/core/chart-zoom/zoom-utils.d.ts +8 -0
  16. package/core/chart-zoom/zoom-utils.js +47 -0
  17. package/core/chart-zoom/zoom-utils.js.map +1 -0
  18. package/core/components/{core-zoom.d.ts → core-zoom-controls.d.ts} +0 -3
  19. package/core/components/core-zoom-controls.js +30 -0
  20. package/core/components/core-zoom-controls.js.map +1 -0
  21. package/core/components/core-zoom-cursor.d.ts +7 -0
  22. package/core/components/core-zoom-cursor.js +10 -0
  23. package/core/components/core-zoom-cursor.js.map +1 -0
  24. package/core/components/core-zoom-live-region.d.ts +4 -0
  25. package/core/components/core-zoom-live-region.js +11 -0
  26. package/core/components/core-zoom-live-region.js.map +1 -0
  27. package/core/i18n-utils.d.ts +8 -0
  28. package/core/i18n-utils.js +15 -4
  29. package/core/i18n-utils.js.map +1 -1
  30. package/core/styles.css.js +24 -22
  31. package/core/styles.scoped.css +62 -22
  32. package/core/styles.selectors.js +24 -22
  33. package/core/test-classes/styles.css.js +38 -33
  34. package/core/test-classes/styles.scoped.css +38 -33
  35. package/core/test-classes/styles.selectors.js +38 -33
  36. package/core/utils.d.ts +1 -0
  37. package/core/utils.js +6 -0
  38. package/core/utils.js.map +1 -1
  39. package/internal/chart-styles.d.ts +12 -0
  40. package/internal/chart-styles.js +13 -1
  41. package/internal/chart-styles.js.map +1 -1
  42. package/internal/environment.js +1 -1
  43. package/internal/environment.json +1 -1
  44. package/internal/manifest.json +1 -1
  45. package/package.json +2 -2
  46. package/core/components/core-zoom.js +0 -20
  47. package/core/components/core-zoom.js.map +0 -1
@@ -1,42 +1,266 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ import { KeyCode } from "@cloudscape-design/component-toolkit/internal";
3
4
  import * as Styles from "../../internal/chart-styles";
4
5
  import { fireNonCancelableEvent } from "../../internal/events";
5
6
  import AsyncStore from "../../internal/utils/async-store";
6
7
  import { SVGRendererSingle } from "../../internal/utils/renderer-utils";
8
+ import { canZoomInto, INACTIVE_ZOOM_STATE, isZooming, zoomReducer, } from "../chart-zoom/zoom-state-machine";
9
+ import { createStopMapper, findNearestIndex, getCursorStops, getPageStep } from "../chart-zoom/zoom-utils";
10
+ import { getFormatter } from "../formatters";
11
+ import { isInsidePlot } from "../utils";
7
12
  import testClasses from "../test-classes/styles.css.js";
8
- // Chart helper that implements zooming into a range of the first x-axis. The range is controlled by the consumer
9
- // with the zoomRange property: the helper applies it to the axis, and marks it on the plot.
13
+ // Chart helper that implements zooming into a range of the first x-axis.
10
14
  export class ChartExtraZoom extends AsyncStore {
11
- constructor(context) {
12
- super({ zoomed: false, announcement: "" });
15
+ constructor(context, handlers) {
16
+ super({
17
+ zooming: false,
18
+ zoomed: false,
19
+ canZoom: true,
20
+ announcement: "",
21
+ announcementKey: 0,
22
+ });
23
+ this.interaction = INACTIVE_ZOOM_STATE;
24
+ this.pressIndex = null;
25
+ this.localExtremes = null;
26
+ this.values = [];
27
+ // A press that sets a zoom boundary is followed by a chart click, which can arrive after the press has ended zoom mode.
28
+ // The pointer stays locked until that click, so that it does not pin a tooltip or reach the consumer's click handler.
29
+ this.pressClickPending = false;
30
+ this.container = null;
31
+ this.cursorElement = null;
32
+ this.controlsElement = null;
33
+ this.zoomButton = null;
34
+ this.resetButton = null;
13
35
  this.rangeBand = new SVGRendererSingle();
14
36
  this.rangeBorders = new SVGRendererSingle();
37
+ this.selectionBand = new SVGRendererSingle();
38
+ this.selectionStart = new SVGRendererSingle();
39
+ this.setCursor = (element) => {
40
+ this.cursorElement = element;
41
+ };
42
+ this.setControls = (element) => {
43
+ this.controlsElement = element;
44
+ };
45
+ this.setZoomButton = (button) => {
46
+ this.zoomButton = button;
47
+ };
48
+ this.setResetButton = (button) => {
49
+ this.resetButton = button;
50
+ };
51
+ this.onChartLoad = (chart) => {
52
+ if (!chart.container) {
53
+ return;
54
+ }
55
+ this.container = chart.container;
56
+ this.container.addEventListener("pointerdown", this.onPlotPointerDown);
57
+ this.container.addEventListener("pointermove", this.onPlotPointerMove);
58
+ this.container.addEventListener("click", this.onContainerClick);
59
+ this.container.ownerDocument.addEventListener("pointerup", this.onDocumentPointerUp);
60
+ this.container.ownerDocument.addEventListener("pointercancel", this.onDocumentPointerCancel);
61
+ };
15
62
  this.onChartRender = () => {
63
+ const previousValues = this.values;
16
64
  this.reconcile(this.context.chart());
65
+ if (!this.enabled) {
66
+ return;
67
+ }
68
+ this.updateValues();
69
+ const stopMapper = createStopMapper(previousValues, this.values);
70
+ this.dispatch({ type: "rendered", stopMapper });
71
+ if (this.pressIndex !== null) {
72
+ this.pressIndex = stopMapper.nearest(this.pressIndex);
73
+ }
74
+ this.updateCanZoom();
17
75
  };
18
76
  this.onChartDestroy = () => {
77
+ const container = this.container;
78
+ container === null || container === void 0 ? void 0 : container.removeEventListener("pointerdown", this.onPlotPointerDown);
79
+ container === null || container === void 0 ? void 0 : container.removeEventListener("pointermove", this.onPlotPointerMove);
80
+ container === null || container === void 0 ? void 0 : container.removeEventListener("click", this.onContainerClick);
81
+ container === null || container === void 0 ? void 0 : container.ownerDocument.removeEventListener("pointerup", this.onDocumentPointerUp);
82
+ container === null || container === void 0 ? void 0 : container.ownerDocument.removeEventListener("pointercancel", this.onDocumentPointerCancel);
83
+ this.container = null;
19
84
  this.rangeBand.destroy();
20
85
  this.rangeBorders.destroy();
86
+ this.selectionBand.destroy();
87
+ this.selectionStart.destroy();
21
88
  };
22
89
  // Called when the zoom settings or the controlled zoom range change.
23
90
  this.onZoomPropsChange = () => {
24
91
  const chart = this.context.chartOrNull;
92
+ if (!this.enabled) {
93
+ this.localExtremes = null;
94
+ this.interaction = INACTIVE_ZOOM_STATE;
95
+ this.pressIndex = null;
96
+ this.pressClickPending = false;
97
+ this.hideOverlay();
98
+ this.setCommon({ zooming: false });
99
+ }
25
100
  if (chart) {
26
101
  this.reconcile(chart);
102
+ if (this.enabled) {
103
+ this.updateValues();
104
+ this.updateCanZoom();
105
+ }
27
106
  }
28
107
  };
29
- // The chart cannot reset a controlled range on its own: it asks the consumer to show the full range.
108
+ this.enterZoomMode = () => {
109
+ this.dispatch({ type: "enter" });
110
+ };
111
+ this.exitZoomMode = (reason) => {
112
+ this.dispatch({ type: "cancel", reason });
113
+ };
30
114
  this.resetZoom = () => {
115
+ var _a;
31
116
  if (this.getExtremes()) {
117
+ // The chart cannot reset a controlled range on its own: it asks the consumer to show the full range.
118
+ if (!this.controlled) {
119
+ this.localExtremes = null;
120
+ this.applyExtremes(this.context.chart());
121
+ }
122
+ this.announce((_a = this.labels.zoomResetAnnouncementText) !== null && _a !== void 0 ? _a : "");
32
123
  fireNonCancelableEvent(this.context.handlers.onZoomRangeChange, { zoomRange: null });
33
- this.set((prev) => { var _a; return ({ ...prev, announcement: (_a = this.context.settings.labels.zoomResetAnnouncementText) !== null && _a !== void 0 ? _a : "" }); });
34
124
  }
125
+ // The Reset button goes away with the range, so the focus moves on before that happens.
126
+ this.moveFocus("zoomButton");
127
+ };
128
+ this.onCursorKeyDown = (event) => {
129
+ const xAxis = this.xAxis;
130
+ if (!xAxis || this.interaction.type === "inactive") {
131
+ return;
132
+ }
133
+ const { cursorIndex } = this.interaction;
134
+ const vertical = !isXAxisHorizontal(xAxis);
135
+ const pageStop = getPageStep(this.values.length);
136
+ const arrowStop = isPixelForward(xAxis, this.values) ? 1 : -1;
137
+ let handled = true;
138
+ switch (event.keyCode) {
139
+ case vertical ? KeyCode.up : KeyCode.left:
140
+ this.dispatchInput({ type: "move", index: cursorIndex - arrowStop });
141
+ break;
142
+ case vertical ? KeyCode.down : KeyCode.right:
143
+ this.dispatchInput({ type: "move", index: cursorIndex + arrowStop });
144
+ break;
145
+ case KeyCode.pageUp:
146
+ this.dispatchInput({ type: "move", index: cursorIndex - pageStop });
147
+ break;
148
+ case KeyCode.pageDown:
149
+ this.dispatchInput({ type: "move", index: cursorIndex + pageStop });
150
+ break;
151
+ case KeyCode.home:
152
+ this.dispatchInput({ type: "move", index: 0 });
153
+ break;
154
+ case KeyCode.end:
155
+ this.dispatchInput({ type: "move", index: this.values.length - 1 });
156
+ break;
157
+ case KeyCode.enter:
158
+ case KeyCode.space:
159
+ this.dispatchInput({ type: "commit" });
160
+ break;
161
+ case KeyCode.escape:
162
+ this.exitZoomMode("escape");
163
+ break;
164
+ default:
165
+ handled = false;
166
+ }
167
+ if (handled) {
168
+ event.preventDefault();
169
+ event.stopPropagation();
170
+ }
171
+ };
172
+ this.onBlur = (event) => {
173
+ if (!this.isFocusWithinZoom(event.relatedTarget)) {
174
+ this.exitZoomMode("blur");
175
+ }
176
+ };
177
+ this.onPlotPointerDown = (event) => {
178
+ this.pressClickPending = false;
179
+ if (!isZooming(this.interaction) || (event.pointerType === "mouse" && event.button)) {
180
+ return;
181
+ }
182
+ const chart = this.context.chartOrNull;
183
+ const xAxis = this.xAxis;
184
+ const values = this.values;
185
+ if (!chart || !xAxis) {
186
+ return;
187
+ }
188
+ const { chartX, chartY } = chart.pointer.normalize(event);
189
+ if (!isInsidePlot(chart, chartX, chartY)) {
190
+ return;
191
+ }
192
+ this.pressClickPending = true;
193
+ this.pressIndex = findStopAtPointer(values, xAxis, chartX, chartY);
194
+ event.preventDefault();
195
+ };
196
+ this.onPlotPointerMove = (event) => {
197
+ if (!isZooming(this.interaction) || this.pressIndex !== null) {
198
+ return;
199
+ }
200
+ const chart = this.context.chartOrNull;
201
+ const xAxis = this.xAxis;
202
+ const values = this.values;
203
+ if (!chart || !xAxis) {
204
+ return;
205
+ }
206
+ const { chartX, chartY } = chart.pointer.normalize(event);
207
+ if (isInsidePlot(chart, chartX, chartY)) {
208
+ this.dispatch({ type: "move", index: findStopAtPointer(values, xAxis, chartX, chartY) });
209
+ }
210
+ };
211
+ this.onContainerClick = () => {
212
+ this.pressClickPending = false;
213
+ };
214
+ this.onDocumentPointerUp = (event) => {
215
+ var _a;
216
+ if (!(event.target instanceof Node && ((_a = this.container) === null || _a === void 0 ? void 0 : _a.contains(event.target)))) {
217
+ this.pressClickPending = false;
218
+ }
219
+ const index = this.pressIndex;
220
+ if (index !== null) {
221
+ this.pressIndex = null;
222
+ this.dispatch({ type: "move", index });
223
+ this.dispatch({ type: "commit" });
224
+ }
225
+ };
226
+ this.onDocumentPointerCancel = () => {
227
+ this.pressIndex = null;
228
+ this.pressClickPending = false;
35
229
  };
36
230
  this.context = context;
231
+ this.handlers = handlers;
232
+ }
233
+ get pointerLocked() {
234
+ return isZooming(this.interaction) || this.pressClickPending;
235
+ }
236
+ updateCanZoom() {
237
+ const canZoom = canZoomInto(this.values.length);
238
+ if (canZoom !== this.get().canZoom) {
239
+ this.setCommon({ canZoom });
240
+ }
241
+ }
242
+ isFocusWithinZoom(target) {
243
+ var _a;
244
+ return target instanceof Node && (target === this.cursorElement || !!((_a = this.controlsElement) === null || _a === void 0 ? void 0 : _a.contains(target)));
245
+ }
246
+ get enabled() {
247
+ return this.context.settings.zoomEnabled;
248
+ }
249
+ get labels() {
250
+ return this.context.settings.labels;
251
+ }
252
+ get xAxis() {
253
+ var _a, _b, _c;
254
+ return (_c = (_b = (_a = this.context.chartOrNull) === null || _a === void 0 ? void 0 : _a.xAxis) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : null;
255
+ }
256
+ get controlled() {
257
+ return this.context.state.zoomRange !== undefined;
37
258
  }
38
259
  getExtremes() {
39
- return this.context.settings.zoomEnabled ? extremesFromRange(this.context.state.zoomRange) : null;
260
+ if (!this.enabled) {
261
+ return null;
262
+ }
263
+ return this.controlled ? extremesFromRange(this.context.state.zoomRange) : this.localExtremes;
40
264
  }
41
265
  // Applies the zoom range to the chart and draws it. Runs on every chart render, and once more after a zoom prop
42
266
  // change, when the context holds the new range.
@@ -61,11 +285,106 @@ export class ChartExtraZoom extends AsyncStore {
61
285
  xAxis.setExtremes(undefined, undefined, true, false);
62
286
  }
63
287
  }
64
- // Zooming clears the reset announcement, so that LiveRegion announces the next reset again. When the range is
65
- // cleared, the announcement made by Reset is kept.
66
- const zoomed = !!extremes;
67
- if (zoomed !== this.get().zoomed) {
68
- this.set(({ announcement }) => ({ zoomed, announcement: zoomed ? "" : announcement }));
288
+ if (!!extremes !== this.get().zoomed) {
289
+ this.setCommon({ zoomed: !!extremes });
290
+ }
291
+ }
292
+ updateValues() {
293
+ this.values = getCursorStops(this.context.derived, this.xAxis);
294
+ }
295
+ formatValue(value) {
296
+ var _a;
297
+ return getFormatter((_a = this.xAxis) !== null && _a !== void 0 ? _a : undefined)(value);
298
+ }
299
+ announce(text) {
300
+ this.setCommon({ announcement: text, announcementKey: this.get().announcementKey + 1 });
301
+ }
302
+ setCommon(update) {
303
+ this.set((state) => ({ ...state, ...update }));
304
+ }
305
+ dispatch(event) {
306
+ const previous = this.interaction;
307
+ const { state, effects } = zoomReducer(previous, event, { valuesCount: this.values.length });
308
+ if (state === previous && effects.length === 0) {
309
+ return;
310
+ }
311
+ this.interaction = state;
312
+ if (!isZooming(state)) {
313
+ this.pressIndex = null;
314
+ }
315
+ if (isZooming(state) !== isZooming(previous)) {
316
+ this.setCommon({ zooming: isZooming(state) });
317
+ if (isZooming(state)) {
318
+ this.handlers.onHideTooltip();
319
+ }
320
+ }
321
+ for (const effect of effects) {
322
+ this.runEffect(effect);
323
+ }
324
+ this.syncOverlay();
325
+ // The focus moves last, once the overlay shows the cursor at its position.
326
+ for (const effect of effects) {
327
+ if (effect.type === "focus") {
328
+ this.moveFocus(effect.target);
329
+ }
330
+ }
331
+ }
332
+ dispatchInput(event) {
333
+ if (this.pressIndex === null) {
334
+ this.dispatch(event);
335
+ }
336
+ }
337
+ moveFocus(target) {
338
+ var _a, _b, _c;
339
+ switch (target) {
340
+ case "cursor":
341
+ (_a = this.cursorElement) === null || _a === void 0 ? void 0 : _a.focus();
342
+ break;
343
+ case "zoomButton":
344
+ (_b = this.zoomButton) === null || _b === void 0 ? void 0 : _b.focus();
345
+ break;
346
+ case "resetButton":
347
+ (_c = this.resetButton) === null || _c === void 0 ? void 0 : _c.focus();
348
+ break;
349
+ }
350
+ }
351
+ runEffect(effect) {
352
+ var _a, _b, _c;
353
+ switch (effect.type) {
354
+ case "announce":
355
+ this.announce(this.describeAnnouncement(effect.announcement));
356
+ break;
357
+ case "applyZoom": {
358
+ const values = this.values;
359
+ const fromValue = values[effect.fromIndex];
360
+ const toValue = values[effect.toIndex];
361
+ if (fromValue === undefined || toValue === undefined) {
362
+ break;
363
+ }
364
+ const min = Math.min(fromValue, toValue);
365
+ const max = Math.max(fromValue, toValue);
366
+ this.announce((_c = (_b = (_a = this.labels).zoomRangeChangeAnnouncementText) === null || _b === void 0 ? void 0 : _b.call(_a, this.formatValue(min), this.formatValue(max))) !== null && _c !== void 0 ? _c : "");
367
+ if (!this.controlled) {
368
+ this.localExtremes = { min, max };
369
+ this.applyExtremes(this.context.chart());
370
+ }
371
+ fireNonCancelableEvent(this.context.handlers.onZoomRangeChange, {
372
+ zoomRange: { x: { startValue: min, endValue: max } },
373
+ });
374
+ break;
375
+ }
376
+ }
377
+ }
378
+ describeAnnouncement(announcement) {
379
+ var _a, _b, _c, _d, _e, _f, _g;
380
+ const values = this.values;
381
+ switch (announcement.type) {
382
+ case "zoomModeEntered":
383
+ return (_c = (_b = (_a = this.labels).zoomModeEnteredAnnouncementText) === null || _b === void 0 ? void 0 : _b.call(_a, this.formatValue(values[announcement.index]))) !== null && _c !== void 0 ? _c : "";
384
+ case "startPointSet":
385
+ return (_f = (_e = (_d = this.labels).zoomStartPointAnnouncementText) === null || _e === void 0 ? void 0 : _e.call(_d, this.formatValue(values[announcement.index]))) !== null && _f !== void 0 ? _f : "";
386
+ case "zoomModeExited":
387
+ return (_g = this.labels.zoomModeExitedAnnouncementText) !== null && _g !== void 0 ? _g : "";
69
388
  }
70
389
  }
71
390
  // Marks the zoomed range on the plot with a tinted band and a border at each end.
@@ -81,29 +400,138 @@ export class ChartExtraZoom extends AsyncStore {
81
400
  return;
82
401
  }
83
402
  // In an inverted chart the x-axis runs vertically, so the band and the borders span the plot horizontally.
84
- const horizontal = xAxis.horiz !== false;
85
403
  const { plotLeft, plotTop, plotWidth, plotHeight } = chart;
86
- const from = xAxis.toPixels(extremes.min, false);
87
- const to = xAxis.toPixels(extremes.max, false);
88
- const start = Math.min(from, to);
89
- // A range of a single value still needs a visible band, hence the minimum of one pixel.
90
- const size = Math.max(1, Math.abs(to - from));
91
- const band = horizontal
92
- ? { x: start, y: plotTop, width: size, height: plotHeight }
93
- : { x: plotLeft, y: start, width: plotWidth, height: size };
94
- const border = (pixel) => horizontal
404
+ const from = valueToPixel(xAxis, extremes.min);
405
+ const to = valueToPixel(xAxis, extremes.max);
406
+ const border = (pixel) => isXAxisHorizontal(xAxis)
95
407
  ? `M ${pixel} ${plotTop} L ${pixel} ${plotTop + plotHeight}`
96
408
  : `M ${plotLeft} ${pixel} L ${plotLeft + plotWidth} ${pixel}`;
97
- this.rangeBand.rect(chart.renderer, { ...Styles.zoomRangeBand, ...band, class: testClasses["zoom-range"] });
409
+ this.rangeBand.rect(chart.renderer, {
410
+ ...Styles.zoomRangeBand,
411
+ ...getBandRect(chart, xAxis, extremes.min, extremes.max),
412
+ class: testClasses["zoom-range"],
413
+ });
98
414
  this.rangeBorders.path(chart.renderer, {
99
415
  ...Styles.zoomRangeBorders,
100
416
  d: `${border(from)} ${border(to)}`,
101
417
  class: testClasses["zoom-range-borders"],
102
418
  });
103
419
  }
420
+ syncOverlay() {
421
+ var _a, _b, _c;
422
+ const chart = this.context.chartOrNull;
423
+ const xAxis = this.xAxis;
424
+ const values = this.values;
425
+ const state = this.interaction;
426
+ if (!chart || !xAxis || state.type === "inactive") {
427
+ this.hideOverlay();
428
+ return;
429
+ }
430
+ const origin = { left: chart.container.offsetLeft, top: chart.container.offsetTop };
431
+ const cursorValue = values[state.cursorIndex];
432
+ const anchorValue = state.type === "pendingSecondInput" ? values[state.startIndex] : null;
433
+ applyRect(this.cursorElement, getDividerRect(chart, xAxis, cursorValue), origin);
434
+ this.drawSelection(chart, xAxis, anchorValue, cursorValue);
435
+ const cursor = this.cursorElement;
436
+ if (cursor) {
437
+ cursor.setAttribute("aria-valuemin", `${values[0]}`);
438
+ cursor.setAttribute("aria-valuemax", `${values[values.length - 1]}`);
439
+ cursor.setAttribute("aria-valuenow", `${cursorValue}`);
440
+ cursor.setAttribute("aria-valuetext", anchorValue === null
441
+ ? this.formatValue(cursorValue)
442
+ : ((_c = (_b = (_a = this.labels).zoomSelectionAnnouncementText) === null || _b === void 0 ? void 0 : _b.call(_a, this.formatValue(anchorValue), this.formatValue(cursorValue))) !== null && _c !== void 0 ? _c : ""));
443
+ }
444
+ }
445
+ drawSelection(chart, xAxis, anchorValue, cursorValue) {
446
+ this.selectionBand.hide();
447
+ this.selectionStart.hide();
448
+ if (anchorValue === null) {
449
+ return;
450
+ }
451
+ this.selectionBand.rect(chart.renderer, {
452
+ ...Styles.zoomSelectionBand,
453
+ ...getBandRect(chart, xAxis, anchorValue, cursorValue),
454
+ class: testClasses["zoom-selection"],
455
+ });
456
+ this.selectionStart.rect(chart.renderer, {
457
+ ...Styles.zoomSelectionDivider,
458
+ ...getDividerRect(chart, xAxis, anchorValue),
459
+ class: testClasses["zoom-selection-start"],
460
+ });
461
+ }
462
+ hideOverlay() {
463
+ this.selectionBand.hide();
464
+ this.selectionStart.hide();
465
+ if (this.cursorElement) {
466
+ this.cursorElement.style.visibility = "hidden";
467
+ }
468
+ }
104
469
  }
105
470
  function extremesFromRange(zoomRange) {
106
471
  const x = zoomRange === null || zoomRange === void 0 ? void 0 : zoomRange.x;
107
472
  return x ? { min: Math.min(x.startValue, x.endValue), max: Math.max(x.startValue, x.endValue) } : null;
108
473
  }
474
+ function isXAxisHorizontal(xAxis) {
475
+ return xAxis.horiz !== false;
476
+ }
477
+ function findStopAtPointer(values, xAxis, chartX, chartY) {
478
+ const pixel = isXAxisHorizontal(xAxis) ? chartX : chartY;
479
+ const index = findNearestIndex(values, xAxis.toValue(pixel, false));
480
+ if (xAxis.options.type !== "logarithmic") {
481
+ return index;
482
+ }
483
+ const distance = (i) => Math.abs(valueToPixel(xAxis, values[i]) - pixel);
484
+ let nearest = index;
485
+ for (const candidate of [index - 1, index + 1]) {
486
+ if (candidate >= 0 && candidate < values.length && distance(candidate) < distance(nearest)) {
487
+ nearest = candidate;
488
+ }
489
+ }
490
+ return nearest;
491
+ }
492
+ function valueToPixel(xAxis, value) {
493
+ return xAxis.toPixels(value, false);
494
+ }
495
+ function isPixelForward(xAxis, values) {
496
+ if (values.length < 2) {
497
+ return true;
498
+ }
499
+ return valueToPixel(xAxis, values[values.length - 1]) >= valueToPixel(xAxis, values[0]);
500
+ }
501
+ function getDividerRect(chart, xAxis, value) {
502
+ const pixel = valueToPixel(xAxis, value);
503
+ return isXAxisHorizontal(xAxis)
504
+ ? {
505
+ x: pixel - Styles.zoomDividerThickness / 2,
506
+ y: chart.plotTop,
507
+ width: Styles.zoomDividerThickness,
508
+ height: chart.plotHeight,
509
+ }
510
+ : {
511
+ x: chart.plotLeft,
512
+ y: pixel - Styles.zoomDividerThickness / 2,
513
+ width: chart.plotWidth,
514
+ height: Styles.zoomDividerThickness,
515
+ };
516
+ }
517
+ function getBandRect(chart, xAxis, fromValue, toValue) {
518
+ const fromPixel = valueToPixel(xAxis, fromValue);
519
+ const toPixel = valueToPixel(xAxis, toValue);
520
+ const start = Math.min(fromPixel, toPixel);
521
+ // A range of a single value still needs a visible band, hence the minimum of one pixel.
522
+ const size = Math.max(1, Math.abs(toPixel - fromPixel));
523
+ return isXAxisHorizontal(xAxis)
524
+ ? { x: start, y: chart.plotTop, width: size, height: chart.plotHeight }
525
+ : { x: chart.plotLeft, y: start, width: chart.plotWidth, height: size };
526
+ }
527
+ function applyRect(element, rect, origin) {
528
+ if (!element) {
529
+ return;
530
+ }
531
+ element.style.visibility = "visible";
532
+ element.style.left = `${origin.left + rect.x}px`;
533
+ element.style.top = `${origin.top + rect.y}px`;
534
+ element.style.width = `${rect.width}px`;
535
+ element.style.height = `${rect.height}px`;
536
+ }
109
537
  //# sourceMappingURL=chart-extra-zoom.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-extra-zoom.js","sourceRoot":"","sources":["../../../../src/core/chart-api/chart-extra-zoom.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAIxE,OAAO,WAAW,MAAM,+BAA+B,CAAC;AAaxD,iHAAiH;AACjH,4FAA4F;AAC5F,MAAM,OAAO,cAAe,SAAQ,UAA6B;IAK/D,YAAY,OAA0B;QACpC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC;QAJrC,cAAS,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACpC,iBAAY,GAAG,IAAI,iBAAiB,EAAE,CAAC;QAOxC,kBAA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,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAC9D,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE,CAC/B,UAAU;YACR,CAAC,CAAC,KAAK,KAAK,IAAI,OAAO,MAAM,KAAK,IAAI,OAAO,GAAG,UAAU,EAAE;YAC5D,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,MAAM,QAAQ,GAAG,SAAS,IAAI,KAAK,EAAE,CAAC;QAClE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,GAAG,MAAM,CAAC,aAAa,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAC5G,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACrC,GAAG,MAAM,CAAC,gBAAgB;YAC1B,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,EAAE;YAClC,KAAK,EAAE,WAAW,CAAC,oBAAoB,CAAC;SACzC,CAAC,CAAC;IACL,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,SAAuC;IAChE,MAAM,CAAC,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,CAAC,CAAC;IACvB,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACzG,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport * as Styles from \"../../internal/chart-styles\";\nimport { fireNonCancelableEvent } from \"../../internal/events\";\nimport AsyncStore from \"../../internal/utils/async-store\";\nimport { SafeChart } from \"../../internal/utils/highcharts\";\nimport { SVGRendererSingle } from \"../../internal/utils/renderer-utils\";\nimport { ZoomRange } from \"../internal-interfaces\";\nimport { ChartExtraContext } from \"./chart-extra-context\";\n\nimport testClasses from \"../test-classes/styles.css.js\";\n\n// The reactive state is used to propagate changes to the zoom controls and announcer components.\nexport interface ReactiveZoomState {\n zoomed: boolean;\n announcement: string;\n}\n\ninterface ZoomExtremes {\n min: number;\n max: number;\n}\n\n// Chart helper that implements zooming into a range of the first x-axis. The range is controlled by the consumer\n// with the zoomRange property: the helper applies it to the axis, and marks it on the plot.\nexport class ChartExtraZoom extends AsyncStore<ReactiveZoomState> {\n private context: ChartExtraContext;\n private rangeBand = new SVGRendererSingle();\n private rangeBorders = new SVGRendererSingle();\n\n constructor(context: ChartExtraContext) {\n super({ zoomed: false, announcement: \"\" });\n this.context = context;\n }\n\n public onChartRender = () => {\n this.reconcile(this.context.chart());\n };\n\n public onChartDestroy = () => {\n this.rangeBand.destroy();\n this.rangeBorders.destroy();\n };\n\n // Called when the zoom settings or the controlled zoom range change.\n public onZoomPropsChange = () => {\n const chart = this.context.chartOrNull;\n if (chart) {\n this.reconcile(chart);\n }\n };\n\n // The chart cannot reset a controlled range on its own: it asks the consumer to show the full range.\n public resetZoom = () => {\n if (this.getExtremes()) {\n fireNonCancelableEvent(this.context.handlers.onZoomRangeChange, { zoomRange: null });\n this.set((prev) => ({ ...prev, announcement: this.context.settings.labels.zoomResetAnnouncementText ?? \"\" }));\n }\n };\n\n private getExtremes(): null | ZoomExtremes {\n return this.context.settings.zoomEnabled ? extremesFromRange(this.context.state.zoomRange) : null;\n }\n\n // Applies the zoom range to the chart and draws it. Runs on every chart render, and once more after a zoom prop\n // change, when the context holds the new range.\n private reconcile(chart: SafeChart) {\n this.applyExtremes(chart);\n this.drawRange(chart);\n }\n\n // The range is applied imperatively: Highcharts keeps the extremes set with setExtremes through chart updates,\n // and falls back to the min and max declared in the axis options when they are cleared. The axis is only\n // updated when its range differs, so the redraw it causes does not update it again. Extremes the zoom did not\n // apply are left to the consumer.\n private applyExtremes(chart: SafeChart) {\n const extremes = this.getExtremes();\n const xAxis = chart.xAxis?.[0];\n if (xAxis) {\n const { userMin, userMax } = xAxis.getExtremes();\n if (extremes && (userMin !== extremes.min || userMax !== extremes.max)) {\n xAxis.setExtremes(extremes.min, extremes.max, true, false);\n } else if (!extremes && this.get().zoomed && (userMin !== undefined || userMax !== undefined)) {\n xAxis.setExtremes(undefined, undefined, true, false);\n }\n }\n // Zooming clears the reset announcement, so that LiveRegion announces the next reset again. When the range is\n // cleared, the announcement made by Reset is kept.\n const zoomed = !!extremes;\n if (zoomed !== this.get().zoomed) {\n this.set(({ announcement }) => ({ zoomed, announcement: zoomed ? \"\" : announcement }));\n }\n }\n\n // Marks the zoomed range on the plot with a tinted band and a border at each end.\n private drawRange(chart: SafeChart) {\n const extremes = this.getExtremes();\n const xAxis = chart.xAxis?.[0];\n // Hiding first destroys elements that belong to a chart instance Highcharts has replaced, so that they are drawn\n // again on the current one, like the tooltip cursor.\n this.rangeBand.hide();\n this.rangeBorders.hide();\n if (!extremes || !xAxis) {\n return;\n }\n // In an inverted chart the x-axis runs vertically, so the band and the borders span the plot horizontally.\n const horizontal = xAxis.horiz !== false;\n const { plotLeft, plotTop, plotWidth, plotHeight } = chart;\n const from = xAxis.toPixels(extremes.min, false);\n const to = xAxis.toPixels(extremes.max, false);\n const start = Math.min(from, to);\n // A range of a single value still needs a visible band, hence the minimum of one pixel.\n const size = Math.max(1, Math.abs(to - from));\n const band = horizontal\n ? { x: start, y: plotTop, width: size, height: plotHeight }\n : { x: plotLeft, y: start, width: plotWidth, height: size };\n const border = (pixel: number) =>\n horizontal\n ? `M ${pixel} ${plotTop} L ${pixel} ${plotTop + plotHeight}`\n : `M ${plotLeft} ${pixel} L ${plotLeft + plotWidth} ${pixel}`;\n this.rangeBand.rect(chart.renderer, { ...Styles.zoomRangeBand, ...band, class: testClasses[\"zoom-range\"] });\n this.rangeBorders.path(chart.renderer, {\n ...Styles.zoomRangeBorders,\n d: `${border(from)} ${border(to)}`,\n class: testClasses[\"zoom-range-borders\"],\n });\n }\n}\n\nfunction extremesFromRange(zoomRange: undefined | null | ZoomRange): null | ZoomExtremes {\n const x = zoomRange?.x;\n return x ? { min: Math.min(x.startValue, x.endValue), max: Math.max(x.startValue, x.endValue) } : null;\n}\n"]}
1
+ {"version":3,"file":"chart-extra-zoom.js","sourceRoot":"","sources":["../../../../src/core/chart-api/chart-extra-zoom.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAItC,OAAO,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;AAExE,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,SAAS,EAMT,WAAW,GAEZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC3G,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,OAAO,WAAW,MAAM,+BAA+B,CAAC;AA0BxD,yEAAyE;AACzE,MAAM,OAAO,cAAe,SAAQ,UAA6B;IAoB/D,YAAY,OAA0B,EAAE,QAAgC;QACtE,KAAK,CAAC;YACJ,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,IAAI;YACb,YAAY,EAAE,EAAE;YAChB,eAAe,EAAE,CAAC;SACnB,CAAC,CAAC;QAxBG,gBAAW,GAAc,m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;IACrC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC;IACjD,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC;IAC/C,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC;AAC5C,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport { KeyCode } from \"@cloudscape-design/component-toolkit/internal\";\n\nimport * as Styles from \"../../internal/chart-styles\";\nimport { fireNonCancelableEvent } from \"../../internal/events\";\nimport AsyncStore from \"../../internal/utils/async-store\";\nimport { SafeChart } from \"../../internal/utils/highcharts\";\nimport { SVGRendererSingle } from \"../../internal/utils/renderer-utils\";\nimport {\n canZoomInto,\n INACTIVE_ZOOM_STATE,\n isZooming,\n ZoomAnnouncement,\n ZoomCancelReason,\n ZoomEffect,\n ZoomEvent,\n ZoomFocusTarget,\n zoomReducer,\n ZoomState,\n} from \"../chart-zoom/zoom-state-machine\";\nimport { createStopMapper, findNearestIndex, getCursorStops, getPageStep } from \"../chart-zoom/zoom-utils\";\nimport { getFormatter } from \"../formatters\";\nimport { Rect } from \"../interfaces\";\nimport { ZoomRange } from \"../internal-interfaces\";\nimport { isInsidePlot } from \"../utils\";\nimport { ChartExtraContext } from \"./chart-extra-context\";\n\nimport testClasses from \"../test-classes/styles.css.js\";\n\n// The reactive state is used to propagate changes to the zoom controls and announcer components.\nexport interface ReactiveZoomState {\n zoomed: boolean;\n zooming: boolean;\n canZoom: boolean;\n announcement: string;\n // Changes with every announcement. The live region is keyed by it, so that an announcement repeating the previous\n // text, like setting the same start point twice, is announced again.\n announcementKey: number;\n}\n\nexport interface ChartExtraZoomHandlers {\n onHideTooltip(): void;\n}\n\nexport interface FocusableControl {\n focus(): void;\n}\n\ninterface ZoomExtremes {\n min: number;\n max: number;\n}\n\n// Chart helper that implements zooming into a range of the first x-axis.\nexport class ChartExtraZoom extends AsyncStore<ReactiveZoomState> {\n private context: ChartExtraContext;\n private handlers: ChartExtraZoomHandlers;\n private interaction: ZoomState = INACTIVE_ZOOM_STATE;\n private pressIndex: null | number = null;\n private localExtremes: null | ZoomExtremes = null;\n private values: number[] = [];\n // A press that sets a zoom boundary is followed by a chart click, which can arrive after the press has ended zoom mode.\n // The pointer stays locked until that click, so that it does not pin a tooltip or reach the consumer's click handler.\n private pressClickPending = false;\n private container: null | HTMLElement = null;\n private cursorElement: null | HTMLElement = null;\n private controlsElement: null | HTMLElement = null;\n private zoomButton: null | FocusableControl = null;\n private resetButton: null | FocusableControl = null;\n private rangeBand = new SVGRendererSingle();\n private rangeBorders = new SVGRendererSingle();\n private selectionBand = new SVGRendererSingle();\n private selectionStart = new SVGRendererSingle();\n\n constructor(context: ChartExtraContext, handlers: ChartExtraZoomHandlers) {\n super({\n zooming: false,\n zoomed: false,\n canZoom: true,\n announcement: \"\",\n announcementKey: 0,\n });\n this.context = context;\n this.handlers = handlers;\n }\n\n public get pointerLocked() {\n return isZooming(this.interaction) || this.pressClickPending;\n }\n\n public setCursor = (element: null | HTMLElement) => {\n this.cursorElement = element;\n };\n\n public setControls = (element: null | HTMLElement) => {\n this.controlsElement = element;\n };\n\n public setZoomButton = (button: null | FocusableControl) => {\n this.zoomButton = button;\n };\n\n public setResetButton = (button: null | FocusableControl) => {\n this.resetButton = button;\n };\n\n public onChartLoad = (chart: SafeChart) => {\n if (!chart.container) {\n return;\n }\n this.container = chart.container;\n this.container.addEventListener(\"pointerdown\", this.onPlotPointerDown);\n this.container.addEventListener(\"pointermove\", this.onPlotPointerMove);\n this.container.addEventListener(\"click\", this.onContainerClick);\n this.container.ownerDocument.addEventListener(\"pointerup\", this.onDocumentPointerUp);\n this.container.ownerDocument.addEventListener(\"pointercancel\", this.onDocumentPointerCancel);\n };\n\n public onChartRender = () => {\n const previousValues = this.values;\n this.reconcile(this.context.chart());\n if (!this.enabled) {\n return;\n }\n this.updateValues();\n const stopMapper = createStopMapper(previousValues, this.values);\n this.dispatch({ type: \"rendered\", stopMapper });\n if (this.pressIndex !== null) {\n this.pressIndex = stopMapper.nearest(this.pressIndex);\n }\n this.updateCanZoom();\n };\n\n public onChartDestroy = () => {\n const container = this.container;\n container?.removeEventListener(\"pointerdown\", this.onPlotPointerDown);\n container?.removeEventListener(\"pointermove\", this.onPlotPointerMove);\n container?.removeEventListener(\"click\", this.onContainerClick);\n container?.ownerDocument.removeEventListener(\"pointerup\", this.onDocumentPointerUp);\n container?.ownerDocument.removeEventListener(\"pointercancel\", this.onDocumentPointerCancel);\n this.container = null;\n this.rangeBand.destroy();\n this.rangeBorders.destroy();\n this.selectionBand.destroy();\n this.selectionStart.destroy();\n };\n\n // Called when the zoom settings or the controlled zoom range change.\n public onZoomPropsChange = () => {\n const chart = this.context.chartOrNull;\n if (!this.enabled) {\n this.localExtremes = null;\n this.interaction = INACTIVE_ZOOM_STATE;\n this.pressIndex = null;\n this.pressClickPending = false;\n this.hideOverlay();\n this.setCommon({ zooming: false });\n }\n if (chart) {\n this.reconcile(chart);\n if (this.enabled) {\n this.updateValues();\n this.updateCanZoom();\n }\n }\n };\n\n public enterZoomMode = () => {\n this.dispatch({ type: \"enter\" });\n };\n\n public exitZoomMode = (reason: ZoomCancelReason) => {\n this.dispatch({ type: \"cancel\", reason });\n };\n\n public resetZoom = () => {\n if (this.getExtremes()) {\n // The chart cannot reset a controlled range on its own: it asks the consumer to show the full range.\n if (!this.controlled) {\n this.localExtremes = null;\n this.applyExtremes(this.context.chart());\n }\n this.announce(this.labels.zoomResetAnnouncementText ?? \"\");\n fireNonCancelableEvent(this.context.handlers.onZoomRangeChange, { zoomRange: null });\n }\n // The Reset button goes away with the range, so the focus moves on before that happens.\n this.moveFocus(\"zoomButton\");\n };\n\n public onCursorKeyDown = (event: React.KeyboardEvent) => {\n const xAxis = this.xAxis;\n if (!xAxis || this.interaction.type === \"inactive\") {\n return;\n }\n const { cursorIndex } = this.interaction;\n const vertical = !isXAxisHorizontal(xAxis);\n const pageStop = getPageStep(this.values.length);\n const arrowStop = isPixelForward(xAxis, this.values) ? 1 : -1;\n let handled = true;\n switch (event.keyCode) {\n case vertical ? KeyCode.up : KeyCode.left:\n this.dispatchInput({ type: \"move\", index: cursorIndex - arrowStop });\n break;\n case vertical ? KeyCode.down : KeyCode.right:\n this.dispatchInput({ type: \"move\", index: cursorIndex + arrowStop });\n break;\n case KeyCode.pageUp:\n this.dispatchInput({ type: \"move\", index: cursorIndex - pageStop });\n break;\n case KeyCode.pageDown:\n this.dispatchInput({ type: \"move\", index: cursorIndex + pageStop });\n break;\n case KeyCode.home:\n this.dispatchInput({ type: \"move\", index: 0 });\n break;\n case KeyCode.end:\n this.dispatchInput({ type: \"move\", index: this.values.length - 1 });\n break;\n case KeyCode.enter:\n case KeyCode.space:\n this.dispatchInput({ type: \"commit\" });\n break;\n case KeyCode.escape:\n this.exitZoomMode(\"escape\");\n break;\n default:\n handled = false;\n }\n if (handled) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n\n public onBlur = (event: React.FocusEvent) => {\n if (!this.isFocusWithinZoom(event.relatedTarget)) {\n this.exitZoomMode(\"blur\");\n }\n };\n\n private updateCanZoom() {\n const canZoom = canZoomInto(this.values.length);\n if (canZoom !== this.get().canZoom) {\n this.setCommon({ canZoom });\n }\n }\n\n private isFocusWithinZoom(target: EventTarget | null) {\n return target instanceof Node && (target === this.cursorElement || !!this.controlsElement?.contains(target));\n }\n\n private get enabled() {\n return this.context.settings.zoomEnabled;\n }\n\n private get labels() {\n return this.context.settings.labels;\n }\n\n private get xAxis(): null | Highcharts.Axis {\n return this.context.chartOrNull?.xAxis?.[0] ?? null;\n }\n\n private get controlled() {\n return this.context.state.zoomRange !== undefined;\n }\n\n private getExtremes(): null | ZoomExtremes {\n if (!this.enabled) {\n return null;\n }\n return this.controlled ? extremesFromRange(this.context.state.zoomRange) : this.localExtremes;\n }\n\n // Applies the zoom range to the chart and draws it. Runs on every chart render, and once more after a zoom prop\n // change, when the context holds the new range.\n private reconcile(chart: SafeChart) {\n this.applyExtremes(chart);\n this.drawRange(chart);\n }\n\n // The range is applied imperatively: Highcharts keeps the extremes set with setExtremes through chart updates,\n // and falls back to the min and max declared in the axis options when they are cleared. The axis is only\n // updated when its range differs, so the redraw it causes does not update it again. Extremes the zoom did not\n // apply are left to the consumer.\n private applyExtremes(chart: SafeChart) {\n const extremes = this.getExtremes();\n const xAxis = chart.xAxis?.[0];\n if (xAxis) {\n const { userMin, userMax } = xAxis.getExtremes();\n if (extremes && (userMin !== extremes.min || userMax !== extremes.max)) {\n xAxis.setExtremes(extremes.min, extremes.max, true, false);\n } else if (!extremes && this.get().zoomed && (userMin !== undefined || userMax !== undefined)) {\n xAxis.setExtremes(undefined, undefined, true, false);\n }\n }\n if (!!extremes !== this.get().zoomed) {\n this.setCommon({ zoomed: !!extremes });\n }\n }\n\n private updateValues() {\n this.values = getCursorStops(this.context.derived, this.xAxis);\n }\n\n private formatValue(value: number): string {\n return getFormatter(this.xAxis ?? undefined)(value);\n }\n\n private announce(text: string) {\n this.setCommon({ announcement: text, announcementKey: this.get().announcementKey + 1 });\n }\n\n private setCommon(update: Partial<ReactiveZoomState>) {\n this.set((state) => ({ ...state, ...update }));\n }\n\n private dispatch(event: ZoomEvent) {\n const previous = this.interaction;\n const { state, effects } = zoomReducer(previous, event, { valuesCount: this.values.length });\n if (state === previous && effects.length === 0) {\n return;\n }\n this.interaction = state;\n if (!isZooming(state)) {\n this.pressIndex = null;\n }\n if (isZooming(state) !== isZooming(previous)) {\n this.setCommon({ zooming: isZooming(state) });\n if (isZooming(state)) {\n this.handlers.onHideTooltip();\n }\n }\n for (const effect of effects) {\n this.runEffect(effect);\n }\n this.syncOverlay();\n // The focus moves last, once the overlay shows the cursor at its position.\n for (const effect of effects) {\n if (effect.type === \"focus\") {\n this.moveFocus(effect.target);\n }\n }\n }\n\n private dispatchInput(event: ZoomEvent) {\n if (this.pressIndex === null) {\n this.dispatch(event);\n }\n }\n\n private moveFocus(target: ZoomFocusTarget) {\n switch (target) {\n case \"cursor\":\n this.cursorElement?.focus();\n break;\n case \"zoomButton\":\n this.zoomButton?.focus();\n break;\n case \"resetButton\":\n this.resetButton?.focus();\n break;\n }\n }\n\n private runEffect(effect: ZoomEffect) {\n switch (effect.type) {\n case \"announce\":\n this.announce(this.describeAnnouncement(effect.announcement));\n break;\n case \"applyZoom\": {\n const values = this.values;\n const fromValue = values[effect.fromIndex];\n const toValue = values[effect.toIndex];\n if (fromValue === undefined || toValue === undefined) {\n break;\n }\n const min = Math.min(fromValue, toValue);\n const max = Math.max(fromValue, toValue);\n this.announce(\n this.labels.zoomRangeChangeAnnouncementText?.(this.formatValue(min), this.formatValue(max)) ?? \"\",\n );\n if (!this.controlled) {\n this.localExtremes = { min, max };\n this.applyExtremes(this.context.chart());\n }\n fireNonCancelableEvent(this.context.handlers.onZoomRangeChange, {\n zoomRange: { x: { startValue: min, endValue: max } },\n });\n break;\n }\n }\n }\n\n private describeAnnouncement(announcement: ZoomAnnouncement): string {\n const values = this.values;\n switch (announcement.type) {\n case \"zoomModeEntered\":\n return this.labels.zoomModeEnteredAnnouncementText?.(this.formatValue(values[announcement.index])) ?? \"\";\n case \"startPointSet\":\n return this.labels.zoomStartPointAnnouncementText?.(this.formatValue(values[announcement.index])) ?? \"\";\n case \"zoomModeExited\":\n return this.labels.zoomModeExitedAnnouncementText ?? \"\";\n }\n }\n\n // Marks the zoomed range on the plot with a tinted band and a border at each end.\n private drawRange(chart: SafeChart) {\n const extremes = this.getExtremes();\n const xAxis = chart.xAxis?.[0];\n // Hiding first destroys elements that belong to a chart instance Highcharts has replaced, so that they are drawn\n // again on the current one, like the tooltip cursor.\n this.rangeBand.hide();\n this.rangeBorders.hide();\n if (!extremes || !xAxis) {\n return;\n }\n // In an inverted chart the x-axis runs vertically, so the band and the borders span the plot horizontally.\n const { plotLeft, plotTop, plotWidth, plotHeight } = chart;\n const from = valueToPixel(xAxis, extremes.min);\n const to = valueToPixel(xAxis, extremes.max);\n const border = (pixel: number) =>\n isXAxisHorizontal(xAxis)\n ? `M ${pixel} ${plotTop} L ${pixel} ${plotTop + plotHeight}`\n : `M ${plotLeft} ${pixel} L ${plotLeft + plotWidth} ${pixel}`;\n this.rangeBand.rect(chart.renderer, {\n ...Styles.zoomRangeBand,\n ...getBandRect(chart, xAxis, extremes.min, extremes.max),\n class: testClasses[\"zoom-range\"],\n });\n this.rangeBorders.path(chart.renderer, {\n ...Styles.zoomRangeBorders,\n d: `${border(from)} ${border(to)}`,\n class: testClasses[\"zoom-range-borders\"],\n });\n }\n\n private syncOverlay() {\n const chart = this.context.chartOrNull as null | Highcharts.Chart;\n const xAxis = this.xAxis;\n const values = this.values;\n const state = this.interaction;\n if (!chart || !xAxis || state.type === \"inactive\") {\n this.hideOverlay();\n return;\n }\n const origin = { left: chart.container.offsetLeft, top: chart.container.offsetTop };\n const cursorValue = values[state.cursorIndex];\n const anchorValue = state.type === \"pendingSecondInput\" ? values[state.startIndex] : null;\n applyRect(this.cursorElement, getDividerRect(chart, xAxis, cursorValue), origin);\n this.drawSelection(chart, xAxis, anchorValue, cursorValue);\n const cursor = this.cursorElement;\n if (cursor) {\n cursor.setAttribute(\"aria-valuemin\", `${values[0]}`);\n cursor.setAttribute(\"aria-valuemax\", `${values[values.length - 1]}`);\n cursor.setAttribute(\"aria-valuenow\", `${cursorValue}`);\n cursor.setAttribute(\n \"aria-valuetext\",\n anchorValue === null\n ? this.formatValue(cursorValue)\n : (this.labels.zoomSelectionAnnouncementText?.(\n this.formatValue(anchorValue),\n this.formatValue(cursorValue),\n ) ?? \"\"),\n );\n }\n }\n\n private drawSelection(\n chart: Highcharts.Chart,\n xAxis: Highcharts.Axis,\n anchorValue: null | number,\n cursorValue: number,\n ) {\n this.selectionBand.hide();\n this.selectionStart.hide();\n if (anchorValue === null) {\n return;\n }\n this.selectionBand.rect(chart.renderer, {\n ...Styles.zoomSelectionBand,\n ...getBandRect(chart, xAxis, anchorValue, cursorValue),\n class: testClasses[\"zoom-selection\"],\n });\n this.selectionStart.rect(chart.renderer, {\n ...Styles.zoomSelectionDivider,\n ...getDividerRect(chart, xAxis, anchorValue),\n class: testClasses[\"zoom-selection-start\"],\n });\n }\n\n private hideOverlay() {\n this.selectionBand.hide();\n this.selectionStart.hide();\n if (this.cursorElement) {\n this.cursorElement.style.visibility = \"hidden\";\n }\n }\n\n private onPlotPointerDown = (event: PointerEvent) => {\n this.pressClickPending = false;\n if (!isZooming(this.interaction) || (event.pointerType === \"mouse\" && event.button)) {\n return;\n }\n const chart = this.context.chartOrNull;\n const xAxis = this.xAxis;\n const values = this.values;\n if (!chart || !xAxis) {\n return;\n }\n const { chartX, chartY } = chart.pointer.normalize(event);\n if (!isInsidePlot(chart as Highcharts.Chart, chartX, chartY)) {\n return;\n }\n this.pressClickPending = true;\n this.pressIndex = findStopAtPointer(values, xAxis, chartX, chartY);\n event.preventDefault();\n };\n\n private onPlotPointerMove = (event: PointerEvent) => {\n if (!isZooming(this.interaction) || this.pressIndex !== null) {\n return;\n }\n const chart = this.context.chartOrNull;\n const xAxis = this.xAxis;\n const values = this.values;\n if (!chart || !xAxis) {\n return;\n }\n const { chartX, chartY } = chart.pointer.normalize(event);\n if (isInsidePlot(chart as Highcharts.Chart, chartX, chartY)) {\n this.dispatch({ type: \"move\", index: findStopAtPointer(values, xAxis, chartX, chartY) });\n }\n };\n\n private onContainerClick = () => {\n this.pressClickPending = false;\n };\n\n private onDocumentPointerUp = (event: PointerEvent) => {\n if (!(event.target instanceof Node && this.container?.contains(event.target))) {\n this.pressClickPending = false;\n }\n const index = this.pressIndex;\n if (index !== null) {\n this.pressIndex = null;\n this.dispatch({ type: \"move\", index });\n this.dispatch({ type: \"commit\" });\n }\n };\n\n private onDocumentPointerCancel = () => {\n this.pressIndex = null;\n this.pressClickPending = false;\n };\n}\n\nfunction extremesFromRange(zoomRange: undefined | null | ZoomRange): null | ZoomExtremes {\n const x = zoomRange?.x;\n return x ? { min: Math.min(x.startValue, x.endValue), max: Math.max(x.startValue, x.endValue) } : null;\n}\n\nfunction isXAxisHorizontal(xAxis: Pick<Highcharts.Axis, \"horiz\">): boolean {\n return xAxis.horiz !== false;\n}\n\nfunction findStopAtPointer(values: readonly number[], xAxis: Highcharts.Axis, chartX: number, chartY: number): number {\n const pixel = isXAxisHorizontal(xAxis) ? chartX : chartY;\n const index = findNearestIndex(values, xAxis.toValue(pixel, false));\n if (xAxis.options.type !== \"logarithmic\") {\n return index;\n }\n const distance = (i: number) => Math.abs(valueToPixel(xAxis, values[i]) - pixel);\n let nearest = index;\n for (const candidate of [index - 1, index + 1]) {\n if (candidate >= 0 && candidate < values.length && distance(candidate) < distance(nearest)) {\n nearest = candidate;\n }\n }\n return nearest;\n}\n\nfunction valueToPixel(xAxis: Highcharts.Axis, value: number): number {\n return xAxis.toPixels(value, false);\n}\n\nfunction isPixelForward(xAxis: Highcharts.Axis, values: readonly number[]): boolean {\n if (values.length < 2) {\n return true;\n }\n return valueToPixel(xAxis, values[values.length - 1]) >= valueToPixel(xAxis, values[0]);\n}\n\nfunction getDividerRect(chart: SafeChart, xAxis: Highcharts.Axis, value: number): Rect {\n const pixel = valueToPixel(xAxis, value);\n return isXAxisHorizontal(xAxis)\n ? {\n x: pixel - Styles.zoomDividerThickness / 2,\n y: chart.plotTop,\n width: Styles.zoomDividerThickness,\n height: chart.plotHeight,\n }\n : {\n x: chart.plotLeft,\n y: pixel - Styles.zoomDividerThickness / 2,\n width: chart.plotWidth,\n height: Styles.zoomDividerThickness,\n };\n}\n\nfunction getBandRect(chart: SafeChart, xAxis: Highcharts.Axis, fromValue: number, toValue: number): Rect {\n const fromPixel = valueToPixel(xAxis, fromValue);\n const toPixel = valueToPixel(xAxis, toValue);\n const start = Math.min(fromPixel, toPixel);\n // A range of a single value still needs a visible band, hence the minimum of one pixel.\n const size = Math.max(1, Math.abs(toPixel - fromPixel));\n return isXAxisHorizontal(xAxis)\n ? { x: start, y: chart.plotTop, width: size, height: chart.plotHeight }\n : { x: chart.plotLeft, y: start, width: chart.plotWidth, height: size };\n}\n\ninterface OverlayOrigin {\n left: number;\n top: number;\n}\n\nfunction applyRect(element: null | HTMLElement, rect: Rect, origin: OverlayOrigin) {\n if (!element) {\n return;\n }\n element.style.visibility = \"visible\";\n element.style.left = `${origin.left + rect.x}px`;\n element.style.top = `${origin.top + rect.y}px`;\n element.style.width = `${rect.width}px`;\n element.style.height = `${rect.height}px`;\n}\n"]}