kd-lane-chart-v3 0.0.1 → 0.0.3

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/esm/index.js CHANGED
@@ -342,7 +342,6 @@ const _sfc_main$c = {
342
342
  if (!menu) {
343
343
  return;
344
344
  }
345
- console.log(this.positionInfo);
346
345
  const { left = 0, top = 0 } = this.positionInfo;
347
346
  if (!this.menuWidth || !this.menuHeight) {
348
347
  menu.style.visibility = "hidden";
@@ -351,17 +350,37 @@ const _sfc_main$c = {
351
350
  this.menuHeight = menu.offsetHeight;
352
351
  menu.removeAttribute("style");
353
352
  }
354
- if (this.menuWidth + event.pageX >= window.innerWidth) {
355
- menu.style.left = event.pageX - this.menuWidth - left + 2 + "px";
356
- } else {
357
- menu.style.left = event.pageX - left + 2 + "px";
353
+ const container = this.getContainer(menu);
354
+ const rect = container ? container.getBoundingClientRect() : { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight };
355
+ const clientX = typeof event.clientX === "number" ? event.clientX : event.pageX;
356
+ const clientY = typeof event.clientY === "number" ? event.clientY : event.pageY;
357
+ const containerW = rect.right - rect.left;
358
+ const containerH = rect.bottom - rect.top;
359
+ let relX = clientX - rect.left - left + 2;
360
+ let relY = clientY - rect.top - top + 2;
361
+ if (relX + this.menuWidth > containerW) {
362
+ relX = clientX - rect.left - this.menuWidth - left + 2;
363
+ }
364
+ if (relY + this.menuHeight > containerH) {
365
+ relY = clientY - rect.top - this.menuHeight - top + 2;
366
+ }
367
+ menu.style.left = Math.max(0, relX) + "px";
368
+ menu.style.top = Math.max(0, relY) + "px";
369
+ menu.classList.add("vue-simple-context-menu--active");
370
+ },
371
+ // 以 .kd-lane-chart-container 作为定位父元素(其 position 为 relative)
372
+ getContainer(menu) {
373
+ if (menu.closest) {
374
+ return menu.closest(".kd-lane-chart-container");
358
375
  }
359
- if (this.menuHeight + event.pageY >= window.innerHeight) {
360
- menu.style.top = event.pageY - this.menuHeight - top + 2 + "px";
361
- } else {
362
- menu.style.top = event.pageY - top + 2 + "px";
376
+ let el = menu.parentElement;
377
+ while (el) {
378
+ if (el.classList && el.classList.contains("kd-lane-chart-container")) {
379
+ return el;
380
+ }
381
+ el = el.parentElement;
363
382
  }
364
- menu.classList.add("vue-simple-context-menu--active");
383
+ return null;
365
384
  },
366
385
  hideContextMenu() {
367
386
  const element = this.$refs.refUl;
@@ -419,7 +438,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
419
438
  ])
420
439
  ]);
421
440
  }
422
- const VueSimpleContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c], ["__scopeId", "data-v-00600889"]]);
441
+ const VueSimpleContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c], ["__scopeId", "data-v-35b025bb"]]);
423
442
  class CustomStrategy {
424
443
  constructor(strategy) {
425
444
  this.strategy = strategy;
@@ -1819,7 +1838,7 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
1819
1838
  createVNode(_component_el_color_picker, {
1820
1839
  modelValue: $data.formData.lineColor,
1821
1840
  "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => $data.formData.lineColor = $event),
1822
- disabled: $data.formData.isGradient,
1841
+ disabled: $data.formData.isGradient || $props.formDisable,
1823
1842
  class: "kd-color-picker-wrapper",
1824
1843
  "popper-class": "kd-color-picker"
1825
1844
  }, null, 8, ["modelValue", "disabled"])
@@ -1836,7 +1855,7 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
1836
1855
  modelValue: $data.formData.lineType,
1837
1856
  "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => $data.formData.lineType = $event),
1838
1857
  placeholder: "请选择",
1839
- disabled: $data.formData.isGradient,
1858
+ disabled: $data.formData.isGradient || $props.formDisable,
1840
1859
  "popper-class": "kd-curve-2d-select-popup"
1841
1860
  }, {
1842
1861
  default: withCtx(() => [
@@ -1893,7 +1912,7 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
1893
1912
  ])
1894
1913
  ]);
1895
1914
  }
1896
- const LineEdit = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a], ["__scopeId", "data-v-3405e8de"]]);
1915
+ const LineEdit = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a], ["__scopeId", "data-v-36fe0bb1"]]);
1897
1916
  const _sfc_main$9 = {
1898
1917
  inject: ["upsertTemplate", "setTargetData", "setExpanded"],
1899
1918
  props: {
@@ -3965,7 +3984,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
3965
3984
  ], 2)) : createCommentVNode("", true)
3966
3985
  ], 544);
3967
3986
  }
3968
- const KdLaneContainerComponent = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-424f38c2"]]);
3987
+ const KdLaneContainerComponent = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-f37f9567"]]);
3969
3988
  const SLIDER_GROUP_ID = "depthSliderGroup";
3970
3989
  function pad2(n) {
3971
3990
  return n < 10 ? "0" + n : "" + n;