@oliasoft-open-source/charts-library 4.3.3-beta-7 → 4.3.3-beta-9

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.
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import { produce } from "immer";
11
11
  import { round as round$2, displayNumber, isCloseTo, roundByMagnitude } from "@oliasoft-open-source/units";
12
12
  import cx from "classnames";
13
13
  import { Icon, Tooltip as Tooltip$2, Button, Flex, Text, Menu, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer, Portal } from "@oliasoft-open-source/react-ui-library";
14
- import { isEmpty, isArray as isArray$2, some, has, cloneDeep, defaultTo, findIndex, set as set$2, isNil, debounce as debounce$3, map as map$3, find, get as get$1, values } from "lodash";
14
+ import { isEmpty, isArray as isArray$2, some, has, cloneDeep, defaultTo, findIndex, set as set$2, isNil, debounce as debounce$3, isFunction as isFunction$2, map as map$3, find, get as get$1, values } from "lodash";
15
15
  import { roundNumberToPrecision } from "@oliasoft-open-source/units/dist/rounding/rounding";
16
16
  /*!
17
17
  * @kurkle/color v0.3.2
@@ -26170,7 +26170,6 @@ const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAn
26170
26170
  activeAnnotation.yMax = newCenterY + metrics.height / 2;
26171
26171
  }
26172
26172
  }
26173
- chart2 == null ? void 0 : chart2.update();
26174
26173
  if (activeAnnotation == null ? void 0 : activeAnnotation.onDrag) {
26175
26174
  activeAnnotation.onDrag({ x: x2, y: y2 }, cloneDeep(activeAnnotation));
26176
26175
  }
@@ -26212,9 +26211,13 @@ const handleAnnotationMouseUp = (isDragging2, activeAnnotation, chart2, setDragg
26212
26211
  if (!isNil((_b2 = (_a2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _a2.style) == null ? void 0 : _b2.cursor)) {
26213
26212
  chart2.canvas.style.cursor = CursorStyle.Pointer;
26214
26213
  }
26214
+ }
26215
+ if (chart2 == null ? void 0 : chart2.canvas) {
26215
26216
  setDraggingState(false, null);
26217
+ chart2 == null ? void 0 : chart2.update();
26218
+ } else {
26219
+ console.error("Canvas is not available during mouse up");
26216
26220
  }
26217
- chart2 == null ? void 0 : chart2.update();
26218
26221
  }
26219
26222
  };
26220
26223
  const annotationLabel = (ctx, annotations, scales) => {
@@ -26280,10 +26283,9 @@ const annotationDraggerPlugin = {
26280
26283
  };
26281
26284
  }
26282
26285
  },
26283
- afterUpdate(chart2) {
26284
- var _a2, _b2, _c2, _d2, _e2, _f2;
26286
+ afterRender(chart2) {
26287
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
26285
26288
  const { canvas: canvas2, scales, hoveredAnnotationId } = chart2;
26286
- console.log(chart2);
26287
26289
  const pluginOptions = ((_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.annotationDraggerPlugin) || {
26288
26290
  enabled: false
26289
26291
  };
@@ -26303,9 +26305,15 @@ const annotationDraggerPlugin = {
26303
26305
  }
26304
26306
  };
26305
26307
  if (!((_f2 = canvas2 == null ? void 0 : canvas2.dataset) == null ? void 0 : _f2.annotationDraggerInitialized) && (pluginOptions == null ? void 0 : pluginOptions.enabled) && hoveredAnnotationId) {
26306
- if (!isNil(canvas2) && !isEmpty(canvas2) && (canvas2 == null ? void 0 : canvas2.addEventListener)) {
26307
- console.log(cloneDeep(canvas2));
26308
- canvas2 == null ? void 0 : canvas2.addEventListener(MouseEvents.MOUSEDOWN, (event) => {
26308
+ console.group("Condition");
26309
+ console.log("addEventListener", (_g2 = chart2 == null ? void 0 : chart2.canvas) == null ? void 0 : _g2.addEventListener);
26310
+ console.log("nil", !isNil(canvas2));
26311
+ console.log("isEmpty", !isEmpty(canvas2));
26312
+ console.log("isFunction", isFunction$2(canvas2.addEventListener));
26313
+ console.groupEnd();
26314
+ if (!isNil(canvas2) && !isEmpty(canvas2) && isFunction$2(canvas2.addEventListener)) {
26315
+ console.log("Canvas exists and has addEventListener:", canvas2);
26316
+ canvas2.addEventListener(MouseEvents.MOUSEDOWN, (event) => {
26309
26317
  var _a3, _b3, _c3;
26310
26318
  handleAnnotationMouseDown(
26311
26319
  event,
@@ -26316,7 +26324,7 @@ const annotationDraggerPlugin = {
26316
26324
  chart2.hoveredAnnotationId
26317
26325
  );
26318
26326
  });
26319
- canvas2 == null ? void 0 : canvas2.addEventListener(MouseEvents.MOUSEMOVE, (event) => {
26327
+ canvas2.addEventListener(MouseEvents.MOUSEMOVE, (event) => {
26320
26328
  handleAnnotationMouseMove(
26321
26329
  event,
26322
26330
  canvas2,
@@ -26328,7 +26336,7 @@ const annotationDraggerPlugin = {
26328
26336
  chart2
26329
26337
  );
26330
26338
  });
26331
- canvas2 == null ? void 0 : canvas2.addEventListener(MouseEvents.MOUSEUP, () => {
26339
+ canvas2.addEventListener(MouseEvents.MOUSEUP, () => {
26332
26340
  handleAnnotationMouseUp(
26333
26341
  isDragging2,
26334
26342
  activeAnnotation,
@@ -26336,17 +26344,25 @@ const annotationDraggerPlugin = {
26336
26344
  setDraggingState
26337
26345
  );
26338
26346
  });
26347
+ canvas2.dataset.annotationDraggerInitialized = "true";
26348
+ } else {
26349
+ console.error(
26350
+ "Canvas is null, empty, or does not support addEventListener:",
26351
+ canvas2
26352
+ );
26339
26353
  }
26340
- canvas2.dataset.annotationDraggerInitialized = "true";
26341
26354
  }
26342
26355
  if (!pluginOptions.enabled) {
26343
- canvas2 == null ? void 0 : canvas2.removeEventListener(MouseEvents.MOUSEDOWN, () => {
26344
- });
26345
- canvas2 == null ? void 0 : canvas2.removeEventListener(MouseEvents.MOUSEMOVE, () => {
26346
- });
26347
- canvas2 == null ? void 0 : canvas2.removeEventListener(MouseEvents.MOUSEUP, () => {
26348
- });
26349
- canvas2.dataset.annotationDraggerInitialized = "";
26356
+ if (canvas2 && isFunction$2(canvas2.removeEventListener)) {
26357
+ console.log("Removing event listeners from canvas:", canvas2);
26358
+ canvas2.removeEventListener(MouseEvents.MOUSEDOWN, () => {
26359
+ });
26360
+ canvas2.removeEventListener(MouseEvents.MOUSEMOVE, () => {
26361
+ });
26362
+ canvas2.removeEventListener(MouseEvents.MOUSEUP, () => {
26363
+ });
26364
+ canvas2.dataset.annotationDraggerInitialized = "";
26365
+ }
26350
26366
  }
26351
26367
  }
26352
26368
  };