kd-lane-chart-v3 0.0.2 → 0.0.4

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,39 @@ 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
+ const percentX = Math.max(0, relX) / containerW * 100;
368
+ const percentY = Math.max(0, relY) / containerH * 100;
369
+ menu.style.left = percentX + "%";
370
+ menu.style.top = percentY + "%";
371
+ menu.classList.add("vue-simple-context-menu--active");
372
+ },
373
+ // 以 .kd-lane-chart-container 作为定位父元素(其 position 为 relative)
374
+ getContainer(menu) {
375
+ if (menu.closest) {
376
+ return menu.closest(".kd-lane-chart-container");
358
377
  }
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";
378
+ let el = menu.parentElement;
379
+ while (el) {
380
+ if (el.classList && el.classList.contains("kd-lane-chart-container")) {
381
+ return el;
382
+ }
383
+ el = el.parentElement;
363
384
  }
364
- menu.classList.add("vue-simple-context-menu--active");
385
+ return null;
365
386
  },
366
387
  hideContextMenu() {
367
388
  const element = this.$refs.refUl;
@@ -419,7 +440,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
419
440
  ])
420
441
  ]);
421
442
  }
422
- const VueSimpleContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c], ["__scopeId", "data-v-00600889"]]);
443
+ const VueSimpleContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c], ["__scopeId", "data-v-38ac9b6e"]]);
423
444
  class CustomStrategy {
424
445
  constructor(strategy) {
425
446
  this.strategy = strategy;
@@ -1819,7 +1840,7 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
1819
1840
  createVNode(_component_el_color_picker, {
1820
1841
  modelValue: $data.formData.lineColor,
1821
1842
  "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => $data.formData.lineColor = $event),
1822
- disabled: $data.formData.isGradient,
1843
+ disabled: $data.formData.isGradient || $props.formDisable,
1823
1844
  class: "kd-color-picker-wrapper",
1824
1845
  "popper-class": "kd-color-picker"
1825
1846
  }, null, 8, ["modelValue", "disabled"])
@@ -1836,7 +1857,7 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
1836
1857
  modelValue: $data.formData.lineType,
1837
1858
  "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => $data.formData.lineType = $event),
1838
1859
  placeholder: "请选择",
1839
- disabled: $data.formData.isGradient,
1860
+ disabled: $data.formData.isGradient || $props.formDisable,
1840
1861
  "popper-class": "kd-curve-2d-select-popup"
1841
1862
  }, {
1842
1863
  default: withCtx(() => [
@@ -1893,7 +1914,7 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
1893
1914
  ])
1894
1915
  ]);
1895
1916
  }
1896
- const LineEdit = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a], ["__scopeId", "data-v-3405e8de"]]);
1917
+ const LineEdit = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a], ["__scopeId", "data-v-36fe0bb1"]]);
1897
1918
  const _sfc_main$9 = {
1898
1919
  inject: ["upsertTemplate", "setTargetData", "setExpanded"],
1899
1920
  props: {
@@ -2216,7 +2237,8 @@ const _sfc_main$8 = {
2216
2237
  expandedKeys: [],
2217
2238
  currentNodeKey: "",
2218
2239
  targetData: void 0,
2219
- treeKey: ""
2240
+ treeKey: "",
2241
+ tooltipVisible: {}
2220
2242
  };
2221
2243
  },
2222
2244
  methods: {
@@ -2230,9 +2252,16 @@ const _sfc_main$8 = {
2230
2252
  }
2231
2253
  return nameConfig.paramName;
2232
2254
  },
2255
+ handleMouseEnter(event, nodeId) {
2256
+ const target = event.currentTarget;
2257
+ const isOverflow = target.scrollWidth > target.offsetWidth;
2258
+ this.tooltipVisible[nodeId] = isOverflow;
2259
+ },
2260
+ handleMouseLeave(_, nodeId) {
2261
+ this.tooltipVisible[nodeId] = false;
2262
+ },
2233
2263
  setTargetData(targetData) {
2234
2264
  this.targetData = targetData;
2235
- console.log(targetData, "333333333");
2236
2265
  this.setExpanded();
2237
2266
  const dataType = judgeRawDataType(targetData);
2238
2267
  switch (dataType) {
@@ -2493,9 +2522,11 @@ const _sfc_main$8 = {
2493
2522
  }
2494
2523
  };
2495
2524
  const _hoisted_1$8 = ["onContextmenu"];
2496
- const _hoisted_2$7 = { style: { "padding-left": "5px" } };
2497
- const _hoisted_3$5 = { class: "rtd-config-side-option" };
2525
+ const _hoisted_2$7 = ["onMouseover", "onMouseleave"];
2526
+ const _hoisted_3$5 = { style: { "padding-left": "5px" } };
2527
+ const _hoisted_4$5 = { class: "rtd-config-side-option" };
2498
2528
  function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2529
+ const _component_el_tooltip = resolveComponent("el-tooltip");
2499
2530
  const _component_Star = resolveComponent("Star");
2500
2531
  const _component_el_icon = resolveComponent("el-icon");
2501
2532
  const _component_el_tree = resolveComponent("el-tree");
@@ -2537,8 +2568,22 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2537
2568
  class: "custom-tree-node",
2538
2569
  onContextmenu: withModifiers(($event) => $options.showRightWindows($event, data, node), ["prevent"])
2539
2570
  }, [
2540
- createElementVNode("span", null, toDisplayString(node.label), 1),
2541
- withDirectives(createElementVNode("span", _hoisted_2$7, [
2571
+ createVNode(_component_el_tooltip, {
2572
+ content: node.label,
2573
+ placement: "right",
2574
+ manual: true,
2575
+ visible: $data.tooltipVisible[node.id]
2576
+ }, {
2577
+ default: withCtx(() => [
2578
+ createElementVNode("span", {
2579
+ class: "tree-node-label",
2580
+ onMouseover: ($event) => $options.handleMouseEnter($event, node.id),
2581
+ onMouseleave: ($event) => $options.handleMouseLeave($event, node.id)
2582
+ }, toDisplayString(node.label), 41, _hoisted_2$7)
2583
+ ]),
2584
+ _: 2
2585
+ }, 1032, ["content", "visible"]),
2586
+ withDirectives(createElementVNode("span", _hoisted_3$5, [
2542
2587
  createVNode(_component_el_icon, null, {
2543
2588
  default: withCtx(() => [
2544
2589
  createVNode(_component_Star)
@@ -2552,7 +2597,7 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2552
2597
  ]),
2553
2598
  _: 1
2554
2599
  }, 8, ["data", "current-node-key", "default-expanded-keys", "onNodeClick", "onNodeExpand", "onNodeCollapse"])),
2555
- createElementVNode("div", _hoisted_3$5, [
2600
+ createElementVNode("div", _hoisted_4$5, [
2556
2601
  createVNode(_component_el_button, { onClick: $options.addTemplate }, {
2557
2602
  default: withCtx(() => [..._cache[0] || (_cache[0] = [
2558
2603
  createTextVNode("新增模板", -1)
@@ -2604,7 +2649,7 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2604
2649
  [_directive_loading, $data.curveConfigLoading]
2605
2650
  ]);
2606
2651
  }
2607
- const RealTimeCurveConfig = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8], ["__scopeId", "data-v-8606346c"]]);
2652
+ const RealTimeCurveConfig = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8], ["__scopeId", "data-v-1fb6ec88"]]);
2608
2653
  const ACTION_TYPE = {
2609
2654
  UPSERT_LINE: "upsertLine",
2610
2655
  DELETE_LINE: "delLine"
@@ -3965,7 +4010,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
3965
4010
  ], 2)) : createCommentVNode("", true)
3966
4011
  ], 544);
3967
4012
  }
3968
- const KdLaneContainerComponent = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-424f38c2"]]);
4013
+ const KdLaneContainerComponent = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-192e257e"]]);
3969
4014
  const SLIDER_GROUP_ID = "depthSliderGroup";
3970
4015
  function pad2(n) {
3971
4016
  return n < 10 ? "0" + n : "" + n;