@havue/components 1.2.0 → 1.2.2

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.
@@ -1941,6 +1941,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1941
1941
  "step-strictly": "",
1942
1942
  min: 0,
1943
1943
  max: 255,
1944
+ "value-on-clear": 0,
1944
1945
  step: 1,
1945
1946
  controls: false
1946
1947
  }, null, 8, ["modelValue", "disabled"]),
@@ -1952,6 +1953,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1952
1953
  "step-strictly": "",
1953
1954
  min: 0,
1954
1955
  max: 255,
1956
+ "value-on-clear": 0,
1955
1957
  step: 1,
1956
1958
  controls: false
1957
1959
  }, null, 8, ["modelValue", "disabled"]),
@@ -1963,6 +1965,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1963
1965
  "step-strictly": "",
1964
1966
  min: 0,
1965
1967
  max: 255,
1968
+ "value-on-clear": 0,
1966
1969
  step: 1,
1967
1970
  controls: false
1968
1971
  }, null, 8, ["modelValue", "disabled"])
@@ -1976,6 +1979,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1976
1979
  onChange: handleHsvColorChange,
1977
1980
  min: 0,
1978
1981
  max: 360,
1982
+ "value-on-clear": 0,
1979
1983
  "step-strictly": "",
1980
1984
  step: 1,
1981
1985
  controls: false
@@ -1987,6 +1991,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1987
1991
  onChange: handleHsvColorChange,
1988
1992
  min: 0,
1989
1993
  max: 100,
1994
+ "value-on-clear": 0,
1990
1995
  "step-strictly": "",
1991
1996
  step: 1,
1992
1997
  controls: false
@@ -1999,6 +2004,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1999
2004
  "step-strictly": "",
2000
2005
  min: 0,
2001
2006
  max: 100,
2007
+ "value-on-clear": 0,
2002
2008
  controls: false
2003
2009
  }, null, 8, ["modelValue", "disabled"])
2004
2010
  ])
@@ -2645,21 +2651,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2645
2651
  };
2646
2652
  }
2647
2653
  });
2648
- const _export_sfc = (sfc, props) => {
2649
- const target = sfc.__vccOpts || sfc;
2650
- for (const [key, val] of props) {
2651
- target[key] = val;
2652
- }
2653
- return target;
2654
- };
2655
- const ColorArea = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-d4f5b081"]]);
2656
2654
  const _hoisted_1$4 = { class: "hv-color_picker__form mb-12" };
2657
2655
  const _hoisted_2$3 = { class: "hv-color-picker__form-type" };
2658
2656
  const _hoisted_3$2 = { class: "hv-color-picker__form-body" };
2659
2657
  const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
2660
- ...{
2661
- name: "HvColorPickerNormal"
2662
- },
2663
2658
  __name: "ColorForm",
2664
2659
  props: {
2665
2660
  modelValue: {},
@@ -2759,6 +2754,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2759
2754
  disabled: props.disabled,
2760
2755
  min: 0,
2761
2756
  max: isRGB.value ? 255 : 360,
2757
+ "value-on-clear": 0,
2762
2758
  step: 1,
2763
2759
  controls: false
2764
2760
  }, null, 8, ["modelValue", "disabled", "max"]),
@@ -2770,6 +2766,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2770
2766
  disabled: props.disabled,
2771
2767
  min: 0,
2772
2768
  max: isRGB.value ? 255 : 100,
2769
+ "value-on-clear": 0,
2773
2770
  step: 1,
2774
2771
  controls: false
2775
2772
  }, null, 8, ["modelValue", "disabled", "max"]),
@@ -2781,6 +2778,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2781
2778
  disabled: props.disabled,
2782
2779
  min: 0,
2783
2780
  max: isRGB.value ? 255 : 100,
2781
+ "value-on-clear": 0,
2784
2782
  step: 1,
2785
2783
  controls: false
2786
2784
  }, null, 8, ["modelValue", "disabled", "max"]),
@@ -2789,10 +2787,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2789
2787
  modelValue: formInputState.value[3],
2790
2788
  "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => formInputState.value[3] = $event),
2791
2789
  onChange: handleColorChange,
2790
+ class: "hv-color-picker__form-opacity",
2792
2791
  "step-strictly": "",
2793
2792
  disabled: props.disabled,
2794
2793
  min: 0,
2795
2794
  max: 100,
2795
+ "value-on-clear": 0,
2796
2796
  step: 1,
2797
2797
  controls: false
2798
2798
  }, {
@@ -2806,7 +2806,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2806
2806
  };
2807
2807
  }
2808
2808
  });
2809
- const ColorForm = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-855a2e17"]]);
2810
2809
  const _hoisted_1$3 = { class: "hv-color-picker__preset" };
2811
2810
  const _hoisted_2$2 = { class: "hv-color-picker__preset-title" };
2812
2811
  const _hoisted_3$1 = { class: "hv-color-picker__preset-list" };
@@ -2866,7 +2865,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2866
2865
  };
2867
2866
  }
2868
2867
  });
2869
- const PresetColors = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-c15cc053"]]);
2870
2868
  const _hoisted_1$2 = { class: "hv-color-picker-normal" };
2871
2869
  const _hoisted_2$1 = { class: "hv-color-picker__color-select-box" };
2872
2870
  const _hoisted_3 = { class: "hv-color-picker__sliders" };
@@ -2909,13 +2907,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2909
2907
  const color22 = Color$1(c);
2910
2908
  const { h, s } = color22.hsv().object();
2911
2909
  saturationv.value = s;
2912
- const equlValues = [0, 360];
2913
2910
  alpha.value = props.enableAlpha ? Math.round(color22.alpha() * 100) : 100;
2914
- const curColor = Color$1.hsv({ h: hue.value, s: saturationv.value, v: value.value, alpha: alpha.value }).hexa();
2915
- if (curColor !== color22.hexa()) {
2916
- if (!(equlValues.includes(h) && equlValues.includes(hue.value))) {
2917
- hue.value = h;
2918
- }
2911
+ const curColor = Color$1.hsv({ h: hue.value, s: saturationv.value, v: value.value, alpha: alpha.value });
2912
+ if (curColor.hex() !== color22.hex()) {
2913
+ hue.value = h;
2919
2914
  }
2920
2915
  },
2921
2916
  {
@@ -2960,7 +2955,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2960
2955
  return (_ctx, _cache) => {
2961
2956
  const _component_ElSlider = vue.resolveComponent("ElSlider");
2962
2957
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
2963
- vue.createVNode(ColorArea, {
2958
+ vue.createVNode(_sfc_main$7, {
2964
2959
  ref_key: "colorAreaRef",
2965
2960
  ref: colorAreaRef,
2966
2961
  "hue-color": hueColor.value,
@@ -3015,13 +3010,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3015
3010
  }, null, 8, ["modelValue", "disabled", "style"])) : vue.createCommentVNode("", true)
3016
3011
  ])
3017
3012
  ]),
3018
- vue.createVNode(ColorForm, {
3013
+ vue.createVNode(_sfc_main$6, {
3019
3014
  "model-value": color2.value,
3020
3015
  "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => color2.value = $event),
3021
3016
  disabled: props.disabled,
3022
3017
  "enable-alpha": props.enableAlpha
3023
3018
  }, null, 8, ["model-value", "disabled", "enable-alpha"]),
3024
- vue.createVNode(PresetColors, {
3019
+ vue.createVNode(_sfc_main$5, {
3025
3020
  onChange: handleColorChange,
3026
3021
  title: props.presetTitle,
3027
3022
  presetColors: props.presetColors
@@ -3030,10 +3025,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3030
3025
  };
3031
3026
  }
3032
3027
  });
3033
- const ColorPickerNormal = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-fbafd973"]]);
3034
3028
  const HvColorPicker = withInstall(_sfc_main$8);
3035
3029
  const HvColorPickerRainbow = HvColorPicker;
3036
- const HvColorPickerNormal = withInstall(ColorPickerNormal);
3030
+ const HvColorPickerNormal = withInstall(_sfc_main$4);
3037
3031
  class EventBus {
3038
3032
  constructor() {
3039
3033
  __publicField(this, "_eventMap");
@@ -3091,7 +3085,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3091
3085
  }
3092
3086
  updateDargInfo(type, data) {
3093
3087
  if (type === void 0 || type === null) {
3094
- throw new Error("请传入拖动元素 type");
3088
+ throw new Error("Expected to get a drag type, but received ", type);
3095
3089
  }
3096
3090
  this.isDragStart = true;
3097
3091
  this.dragType = type;
@@ -3344,10 +3338,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3344
3338
  const { x, y } = params;
3345
3339
  const startEl = document.elementFromPoint(x, y);
3346
3340
  if (!props.disabled && dragItemRef.value && dragItemRef.value.contains(startEl)) {
3347
- if (immediateDirections.value.includes(ImmediateEnumType.ALL)) {
3348
- handleStart(params);
3349
- return;
3350
- }
3351
3341
  isDownThis.value = true;
3352
3342
  downPosition.x = x;
3353
3343
  downPosition.y = y;
@@ -3355,7 +3345,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3355
3345
  };
3356
3346
  const onFirstMove = (params, event) => {
3357
3347
  const { x, y } = params;
3358
- const directions = immediateDirections.value.filter((item) => item !== ImmediateEnumType.ALL);
3348
+ const directions = immediateDirections.value;
3359
3349
  if (isDownThis.value && !props.disabled && directions.length) {
3360
3350
  const distanceH = x - downPosition.x;
3361
3351
  const distanceHAbs = Math.abs(distanceH);
@@ -3365,11 +3355,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3365
3355
  const isMaxH = distanceHAbs === max;
3366
3356
  const isMaxV = distanceVAbs === max;
3367
3357
  let isImmediate = false;
3368
- if (isMaxH) {
3369
- isImmediate = directions.includes(ImmediateEnumType.LEFT) && distanceH < 0 || directions.includes(ImmediateEnumType.RIGHT) && distanceH > 0;
3370
- }
3371
- if (isMaxV && !isImmediate) {
3372
- isImmediate = directions.includes(ImmediateEnumType.TOP) && distanceV < 0 || directions.includes(ImmediateEnumType.BOTTOM) && distanceV > 0;
3358
+ if (directions.includes(ImmediateEnumType.ALL)) {
3359
+ isImmediate = true;
3360
+ } else {
3361
+ if (isMaxH) {
3362
+ isImmediate = directions.includes(ImmediateEnumType.LEFT) && distanceH < 0 || directions.includes(ImmediateEnumType.RIGHT) && distanceH > 0;
3363
+ }
3364
+ if (isMaxV && !isImmediate) {
3365
+ isImmediate = directions.includes(ImmediateEnumType.TOP) && distanceV < 0 || directions.includes(ImmediateEnumType.BOTTOM) && distanceV > 0;
3366
+ }
3373
3367
  }
3374
3368
  if (isImmediate) {
3375
3369
  event.preventDefault();
@@ -3388,6 +3382,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3388
3382
  }
3389
3383
  };
3390
3384
  const onMove = (params) => {
3385
+ if (props.disabled) {
3386
+ isDragThis.value = false;
3387
+ return;
3388
+ }
3391
3389
  const { point } = params;
3392
3390
  if (isDragThis.value) {
3393
3391
  handleMove(point);
@@ -3435,21 +3433,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3435
3433
  ref: dragItemRef,
3436
3434
  class: vue.normalizeClass(["hv-draggable", _ctx.disabled ? "disabled" : ""])
3437
3435
  }, [
3438
- vue.renderSlot(_ctx.$slots, "default", {}, void 0, true),
3436
+ vue.renderSlot(_ctx.$slots, "default"),
3439
3437
  isDragThis.value ? (vue.openBlock(), vue.createElementBlock("div", {
3440
3438
  key: 0,
3441
3439
  class: "hv-draggable__clone-item",
3442
3440
  style: vue.normalizeStyle(cloneNodeStyle.value)
3443
3441
  }, [
3444
3442
  vue.renderSlot(_ctx.$slots, "drag-item", {}, () => [
3445
- vue.renderSlot(_ctx.$slots, "default", {}, void 0, true)
3446
- ], true)
3443
+ vue.renderSlot(_ctx.$slots, "default")
3444
+ ])
3447
3445
  ], 4)) : vue.createCommentVNode("", true)
3448
3446
  ], 2);
3449
3447
  };
3450
3448
  }
3451
3449
  });
3452
- const Draggable = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-2309f70a"]]);
3453
3450
  const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
3454
3451
  ...{
3455
3452
  name: "HvDroppable"
@@ -3492,6 +3489,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3492
3489
  }
3493
3490
  const onMove = (params) => {
3494
3491
  if (props.disabled) {
3492
+ isEntered.value = false;
3495
3493
  return;
3496
3494
  }
3497
3495
  const { type, data, point } = params;
@@ -3511,13 +3509,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3511
3509
  }
3512
3510
  };
3513
3511
  const onEnd = ({ type, point, data }) => {
3514
- if (props.disabled) {
3515
- return;
3516
- }
3517
- if (dropAreaRef.value && acceptDragTypeList.value.includes(type) && isEntered.value) {
3512
+ if (!props.disabled && dropAreaRef.value && acceptDragTypeList.value.includes(type) && isEntered.value) {
3518
3513
  const { position } = getPositionInArea(point);
3519
3514
  emits("drop", type, position, data);
3520
3515
  }
3516
+ isEntered.value = false;
3521
3517
  };
3522
3518
  vue.onMounted(() => {
3523
3519
  DnDManagerInstance.on("move", onMove);
@@ -3538,7 +3534,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3538
3534
  };
3539
3535
  }
3540
3536
  });
3541
- const HvDraggable = withInstall(Draggable);
3537
+ const HvDraggable = withInstall(_sfc_main$3);
3542
3538
  const HvDroppable = withInstall(_sfc_main$2);
3543
3539
  function useDragAndScale(target, operateTarget, options) {
3544
3540
  const _options = vue.computed(() => {
@@ -3904,28 +3900,34 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3904
3900
  x: clientX,
3905
3901
  y: clientY
3906
3902
  });
3907
- document.body.addEventListener("touchcancel", onTouchEnd, { capture: true });
3908
- document.body.addEventListener("touchmove", onTouchMove, { capture: true });
3909
- document.body.addEventListener("touchend", onTouchEnd, { capture: true });
3903
+ document.body.addEventListener("touchcancel", onTouchEnd);
3904
+ document.body.addEventListener("touchmove", onTouchMove);
3905
+ document.body.addEventListener("touchend", onTouchEnd);
3910
3906
  }
3907
+ let touchmoveRafId = null;
3911
3908
  function onTouchMove(e) {
3912
- if (_disabled.value || isOperateStart !== true) {
3913
- isOperateStart = false;
3914
- return;
3909
+ if (touchmoveRafId) {
3910
+ cancelAnimationFrame(touchmoveRafId);
3915
3911
  }
3916
- e.preventDefault();
3917
- e.stopPropagation();
3918
- if (e.touches.length > 1) {
3919
- onEnd();
3920
- return;
3921
- }
3922
- const { clientX, clientY } = e.touches[0];
3923
- if (clientX === startPoint.x && clientY === startPoint.y) {
3924
- return;
3925
- }
3926
- onMove({
3927
- x: clientX,
3928
- y: clientY
3912
+ touchmoveRafId = requestAnimationFrame(() => {
3913
+ if (_disabled.value || isOperateStart !== true) {
3914
+ isOperateStart = false;
3915
+ return;
3916
+ }
3917
+ e.preventDefault();
3918
+ e.stopPropagation();
3919
+ if (e.touches.length > 1) {
3920
+ onEnd();
3921
+ return;
3922
+ }
3923
+ const { clientX, clientY } = e.touches[0];
3924
+ if (clientX === startPoint.x && clientY === startPoint.y) {
3925
+ return;
3926
+ }
3927
+ onMove({
3928
+ x: clientX,
3929
+ y: clientY
3930
+ });
3929
3931
  });
3930
3932
  }
3931
3933
  function onTouchEnd() {
@@ -3937,7 +3939,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3937
3939
  isMoved = false;
3938
3940
  return;
3939
3941
  }
3940
- onEnd();
3942
+ requestAnimationFrame(() => onEnd());
3941
3943
  }
3942
3944
  function onMouseDown(e) {
3943
3945
  e.preventDefault();
@@ -3949,23 +3951,29 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3949
3951
  x: clientX,
3950
3952
  y: clientY
3951
3953
  });
3952
- document.body.addEventListener("mousemove", onMouseMove, { capture: true });
3953
- document.body.addEventListener("mouseup", onMouseUp, { capture: true });
3954
+ document.body.addEventListener("mousemove", onMouseMove);
3955
+ document.body.addEventListener("mouseup", onMouseUp);
3954
3956
  }
3957
+ let mousemoveRafId = null;
3955
3958
  function onMouseMove(e) {
3956
- if (_disabled.value || isOperateStart !== true) {
3957
- isOperateStart = false;
3958
- return;
3959
+ if (mousemoveRafId) {
3960
+ cancelAnimationFrame(mousemoveRafId);
3959
3961
  }
3960
- e.preventDefault();
3961
- if ((e.buttons & 1) === 0) {
3962
- onEnd();
3963
- return;
3964
- }
3965
- const { clientX, clientY } = e;
3966
- onMove({
3967
- x: clientX,
3968
- y: clientY
3962
+ mousemoveRafId = requestAnimationFrame(() => {
3963
+ if (_disabled.value || isOperateStart !== true) {
3964
+ isOperateStart = false;
3965
+ return;
3966
+ }
3967
+ e.preventDefault();
3968
+ if ((e.buttons & 1) === 0) {
3969
+ onEnd();
3970
+ return;
3971
+ }
3972
+ const { clientX, clientY } = e;
3973
+ onMove({
3974
+ x: clientX,
3975
+ y: clientY
3976
+ });
3969
3977
  });
3970
3978
  }
3971
3979
  function onMouseUp() {
@@ -3975,11 +3983,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3975
3983
  isOperateStart = false;
3976
3984
  return;
3977
3985
  }
3978
- onEnd();
3986
+ requestAnimationFrame(() => onEnd());
3979
3987
  }
3980
3988
  function bindEvent() {
3981
3989
  removeEvent();
3982
- _operateEl.value.addEventListener("touchstart", onTouchStart, { capture: true });
3990
+ _operateEl.value.addEventListener("touchstart", onTouchStart);
3983
3991
  _operateEl.value.addEventListener("mousedown", onMouseDown);
3984
3992
  }
3985
3993
  function removeEvent() {
@@ -4206,6 +4214,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4206
4214
  });
4207
4215
  const HvIpInput = withInstall(_sfc_main);
4208
4216
  exports2.DEFAULT_COLOR = DEFAULT_COLOR;
4217
+ exports2.DnDManagerInstance = DnDManagerInstance;
4209
4218
  exports2.HvColorPicker = HvColorPicker;
4210
4219
  exports2.HvColorPickerNormal = HvColorPickerNormal;
4211
4220
  exports2.HvColorPickerRainbow = HvColorPickerRainbow;