@havue/components 1.1.2 → 1.2.1

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 (29) hide show
  1. package/dist/components.full.js +1167 -145
  2. package/dist/components.full.min.js +1 -1
  3. package/dist/components.full.min.js.map +1 -1
  4. package/dist/components.mjs +164 -0
  5. package/dist/components.umd.js +162 -2
  6. package/dist/style.css +1 -1
  7. package/dist/types/color-picker/src/color-picker-normal/ColorPicker.vue.d.ts +16 -0
  8. package/dist/types/color-picker/src/color-picker-normal/children/ColorArea/ColorArea.vue.d.ts +18 -0
  9. package/dist/types/color-picker/src/color-picker-normal/children/ColorArea/hooks/useInteraction.d.ts +9 -0
  10. package/dist/types/color-picker/src/color-picker-normal/children/ColorForm/ColorForm.vue.d.ts +11 -0
  11. package/dist/types/color-picker/src/color-picker-rainbow/ColorPicker.vue.d.ts +15 -0
  12. package/dist/types/color-picker/src/{children → color-picker-rainbow/children}/ColorForm/ColorForm.vue.d.ts +1 -0
  13. package/dist/types/color-picker/src/color-picker-rainbow/children/PresetColors/PresetColors.vue.d.ts +10 -0
  14. package/dist/types/color-picker/src/{hooks → color-picker-rainbow/hooks}/useOperateEvent.d.ts +4 -1
  15. package/dist/types/color-picker/src/{utils → color-picker-rainbow/utils}/color.d.ts +6 -6
  16. package/dist/types/color-picker/src/constants/index.d.ts +1 -0
  17. package/dist/types/color-picker/src/index.d.ts +24 -2
  18. package/dist/types/drag-and-drop/src/Draggable.vue.d.ts +2 -2
  19. package/dist/types/drag-and-drop/src/Droppable.vue.d.ts +1 -0
  20. package/dist/types/drag-and-drop/src/manager/index.d.ts +12 -14
  21. package/dist/types/ip-input/src/IpInput.vue.d.ts +13 -0
  22. package/dist/types/ip-input/src/index.d.ts +3 -0
  23. package/dist/types/ip-input/src/utils/index.d.ts +14 -0
  24. package/dist/types/src/index.d.ts +1 -0
  25. package/package.json +5 -5
  26. package/dist/types/color-picker/src/ColorPicker.vue.d.ts +0 -18
  27. /package/dist/types/color-picker/src/{children → color-picker-normal/children}/PresetColors/PresetColors.vue.d.ts +0 -0
  28. /package/dist/types/color-picker/src/{hooks → color-picker-rainbow/hooks}/useColorArea.d.ts +0 -0
  29. /package/dist/types/color-picker/src/{utils → color-picker-rainbow/utils}/tools.d.ts +0 -0
@@ -1,5 +1,5 @@
1
- (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.components = {}, global.Vue));
1
+ (function(global2, factory) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.components = {}, global2.Vue));
3
3
  })(this, function(exports2, vue) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -13,6 +13,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
13
13
  };
14
14
  return main;
15
15
  };
16
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
16
17
  function getDefaultExportFromCjs(x) {
17
18
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
18
19
  }
@@ -197,10 +198,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
197
198
  var simpleSwizzleExports = simpleSwizzle.exports;
198
199
  var colorNames = colorName;
199
200
  var swizzle = simpleSwizzleExports;
200
- var hasOwnProperty = Object.hasOwnProperty;
201
+ var hasOwnProperty$1 = Object.hasOwnProperty;
201
202
  var reverseNames = /* @__PURE__ */ Object.create(null);
202
203
  for (var name in colorNames) {
203
- if (hasOwnProperty.call(colorNames, name)) {
204
+ if (hasOwnProperty$1.call(colorNames, name)) {
204
205
  reverseNames[colorNames[name]] = name;
205
206
  }
206
207
  }
@@ -289,7 +290,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
289
290
  if (match[1] === "transparent") {
290
291
  return [0, 0, 0, 0];
291
292
  }
292
- if (!hasOwnProperty.call(colorNames, match[1])) {
293
+ if (!hasOwnProperty$1.call(colorNames, match[1])) {
293
294
  return null;
294
295
  }
295
296
  rgb = colorNames[match[1]];
@@ -1715,7 +1716,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1715
1716
  getColorByCoordinate
1716
1717
  };
1717
1718
  }
1718
- function throttle(fn, time = 200) {
1719
+ function throttle$2(fn, time = 200) {
1719
1720
  let timer = null;
1720
1721
  return function(...args) {
1721
1722
  const ctx = this;
@@ -1729,13 +1730,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1729
1730
  }
1730
1731
  };
1731
1732
  }
1732
- function useOperateEvent() {
1733
+ function useOperateEvent(options) {
1733
1734
  const colorAreaRef = vue.ref();
1734
1735
  const circlePickerCoordinate = vue.reactive({
1735
1736
  x: 0,
1736
1737
  y: 0
1737
1738
  });
1739
+ const isDisabled = vue.computed(() => {
1740
+ return vue.isRef(options.disabled) ? options.disabled.value : options.disabled;
1741
+ });
1738
1742
  function handleTouchStart(e) {
1743
+ if (isDisabled.value) {
1744
+ return;
1745
+ }
1739
1746
  if (e.touches.length === 0) {
1740
1747
  return;
1741
1748
  }
@@ -1763,6 +1770,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1763
1770
  document.body.removeEventListener("touchend", handleTouchEnd);
1764
1771
  }
1765
1772
  function handleMounseDown(e) {
1773
+ if (isDisabled.value) {
1774
+ return;
1775
+ }
1766
1776
  document.body.addEventListener("mousemove", handleMouseMove);
1767
1777
  document.body.addEventListener("mouseup", handleMouseUp);
1768
1778
  handleCirclePickerCoordinateChange({
@@ -1771,14 +1781,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1771
1781
  });
1772
1782
  }
1773
1783
  function handleMouseMove(e) {
1784
+ if (!(e.buttons && 1)) {
1785
+ handleMouseUp();
1786
+ return;
1787
+ }
1774
1788
  handleCirclePickerCoordinateChange({
1775
1789
  x: e.clientX,
1776
1790
  y: e.clientY
1777
1791
  });
1778
1792
  }
1779
- const handleCirclePickerCoordinateChange = throttle(handleCirclePickerCoordinateChangeFn, 20);
1793
+ const handleCirclePickerCoordinateChange = throttle$2(handleCirclePickerCoordinateChangeFn, 20);
1780
1794
  function handleCirclePickerCoordinateChangeFn(point) {
1781
1795
  var _a;
1796
+ if (isDisabled.value) {
1797
+ return;
1798
+ }
1782
1799
  const { x: clientX, y: clientY } = point;
1783
1800
  const colorAreaRect = (_a = colorAreaRef.value) == null ? void 0 : _a.getBoundingClientRect();
1784
1801
  if (!colorAreaRect) {
@@ -1840,26 +1857,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1840
1857
  setCirclePickerCoordinate
1841
1858
  };
1842
1859
  }
1843
- const _hoisted_1$3 = { class: "hv-color-picker__color-form" };
1844
- const _hoisted_2$2 = { class: "mb-12" };
1845
- const _hoisted_3$2 = { class: "hv-color-picker__form-group mb-12" };
1846
- const _hoisted_4$2 = { class: "hv-color-picker__form-group mb-12" };
1847
- const DEFAULT_COLOR$1 = "#ffffff";
1848
- const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
1860
+ const DEFAULT_COLOR = "#FFFFFF";
1861
+ const _hoisted_1$7 = { class: "hv-color-picker__color-form" };
1862
+ const _hoisted_2$6 = { class: "mb-12" };
1863
+ const _hoisted_3$5 = { class: "hv-color-picker__form-group mb-12" };
1864
+ const _hoisted_4$3 = { class: "hv-color-picker__form-group mb-12" };
1865
+ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
1849
1866
  __name: "ColorForm",
1850
1867
  props: {
1851
- modelValue: {}
1868
+ modelValue: {},
1869
+ disabled: { type: Boolean }
1852
1870
  },
1853
1871
  emits: ["change"],
1854
1872
  setup(__props, { emit: __emit }) {
1855
1873
  const props = __props;
1856
1874
  const emits = __emit;
1857
- const hexColor = vue.ref(Color$1(props.modelValue || DEFAULT_COLOR$1).hex());
1875
+ const hexColor = vue.ref(Color$1(props.modelValue || DEFAULT_COLOR).hex());
1858
1876
  const formInputRGB = vue.reactive(
1859
- Color$1(hexColor.value || DEFAULT_COLOR$1).rgb().object()
1877
+ Color$1(hexColor.value || DEFAULT_COLOR).rgb().object()
1860
1878
  );
1861
1879
  const formInputHSV = vue.reactive(
1862
- Color$1(hexColor.value || DEFAULT_COLOR$1).hsv().object()
1880
+ Color$1(hexColor.value || DEFAULT_COLOR).hsv().object()
1863
1881
  );
1864
1882
  function hexFormater(value) {
1865
1883
  return `#${value.replace(/[^0-9A-F]/gi, "").slice(0, 6).toUpperCase()}`;
@@ -1903,89 +1921,102 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1903
1921
  return (_ctx, _cache) => {
1904
1922
  const _component_el_input = vue.resolveComponent("el-input");
1905
1923
  const _component_el_input_number = vue.resolveComponent("el-input-number");
1906
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
1907
- vue.createElementVNode("div", _hoisted_2$2, [
1924
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
1925
+ vue.createElementVNode("div", _hoisted_2$6, [
1908
1926
  vue.createVNode(_component_el_input, {
1909
1927
  modelValue: hexColor.value,
1910
1928
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => hexColor.value = $event),
1929
+ disabled: props.disabled,
1911
1930
  formatter: hexFormater,
1912
1931
  onChange: handleHexColorChange
1913
- }, null, 8, ["modelValue"])
1932
+ }, null, 8, ["modelValue", "disabled"])
1914
1933
  ]),
1915
- vue.createElementVNode("div", _hoisted_3$2, [
1934
+ vue.createElementVNode("div", _hoisted_3$5, [
1916
1935
  _cache[7] || (_cache[7] = vue.createElementVNode("div", { class: "hv-color-picker__form-label" }, "RGB", -1)),
1917
1936
  vue.createVNode(_component_el_input_number, {
1918
1937
  modelValue: formInputRGB.r,
1919
1938
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => formInputRGB.r = $event),
1939
+ disabled: props.disabled,
1920
1940
  onChange: handleRgbColorChange,
1921
1941
  "step-strictly": "",
1922
1942
  min: 0,
1923
1943
  max: 255,
1944
+ "value-on-clear": 0,
1924
1945
  step: 1,
1925
1946
  controls: false
1926
- }, null, 8, ["modelValue"]),
1947
+ }, null, 8, ["modelValue", "disabled"]),
1927
1948
  vue.createVNode(_component_el_input_number, {
1928
1949
  modelValue: formInputRGB.g,
1929
1950
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => formInputRGB.g = $event),
1951
+ disabled: props.disabled,
1930
1952
  onChange: handleRgbColorChange,
1931
1953
  "step-strictly": "",
1932
1954
  min: 0,
1933
1955
  max: 255,
1956
+ "value-on-clear": 0,
1934
1957
  step: 1,
1935
1958
  controls: false
1936
- }, null, 8, ["modelValue"]),
1959
+ }, null, 8, ["modelValue", "disabled"]),
1937
1960
  vue.createVNode(_component_el_input_number, {
1938
1961
  modelValue: formInputRGB.b,
1939
1962
  "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => formInputRGB.b = $event),
1963
+ disabled: props.disabled,
1940
1964
  onChange: handleRgbColorChange,
1941
1965
  "step-strictly": "",
1942
1966
  min: 0,
1943
1967
  max: 255,
1968
+ "value-on-clear": 0,
1944
1969
  step: 1,
1945
1970
  controls: false
1946
- }, null, 8, ["modelValue"])
1971
+ }, null, 8, ["modelValue", "disabled"])
1947
1972
  ]),
1948
- vue.createElementVNode("div", _hoisted_4$2, [
1973
+ vue.createElementVNode("div", _hoisted_4$3, [
1949
1974
  _cache[8] || (_cache[8] = vue.createElementVNode("div", { class: "hv-color-picker__form-label" }, "HSV", -1)),
1950
1975
  vue.createVNode(_component_el_input_number, {
1951
1976
  modelValue: formInputHSV.h,
1952
1977
  "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => formInputHSV.h = $event),
1978
+ disabled: props.disabled,
1953
1979
  onChange: handleHsvColorChange,
1954
1980
  min: 0,
1955
1981
  max: 360,
1982
+ "value-on-clear": 0,
1956
1983
  "step-strictly": "",
1957
1984
  step: 1,
1958
1985
  controls: false
1959
- }, null, 8, ["modelValue"]),
1986
+ }, null, 8, ["modelValue", "disabled"]),
1960
1987
  vue.createVNode(_component_el_input_number, {
1961
1988
  modelValue: formInputHSV.s,
1962
1989
  "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => formInputHSV.s = $event),
1990
+ disabled: props.disabled,
1963
1991
  onChange: handleHsvColorChange,
1964
1992
  min: 0,
1965
1993
  max: 100,
1994
+ "value-on-clear": 0,
1966
1995
  "step-strictly": "",
1967
1996
  step: 1,
1968
1997
  controls: false
1969
- }, null, 8, ["modelValue"]),
1998
+ }, null, 8, ["modelValue", "disabled"]),
1970
1999
  vue.createVNode(_component_el_input_number, {
1971
2000
  modelValue: formInputHSV.v,
1972
2001
  "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => formInputHSV.v = $event),
2002
+ disabled: props.disabled,
1973
2003
  onChange: handleHsvColorChange,
1974
2004
  "step-strictly": "",
1975
2005
  min: 0,
1976
2006
  max: 100,
2007
+ "value-on-clear": 0,
1977
2008
  controls: false
1978
- }, null, 8, ["modelValue"])
2009
+ }, null, 8, ["modelValue", "disabled"])
1979
2010
  ])
1980
2011
  ]);
1981
2012
  };
1982
2013
  }
1983
2014
  });
1984
- const _hoisted_1$2 = { class: "hv-color-picker__preset" };
1985
- const _hoisted_2$1 = { class: "hv-color-picker__preset-title" };
1986
- const _hoisted_3$1 = { class: "hv-color-picker__preset-list" };
1987
- const _hoisted_4$1 = ["onClick"];
1988
- const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
2015
+ const _hoisted_1$6 = { class: "hv-color-picker__preset" };
2016
+ const _hoisted_2$5 = { class: "hv-color-picker__preset-title" };
2017
+ const _hoisted_3$4 = { class: "hv-color-picker__preset-list" };
2018
+ const _hoisted_4$2 = ["onClick"];
2019
+ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
1989
2020
  __name: "PresetColors",
1990
2021
  props: {
1991
2022
  title: {},
@@ -2024,50 +2055,53 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2024
2055
  emits("change", color2);
2025
2056
  }
2026
2057
  return (_ctx, _cache) => {
2027
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
2028
- vue.createElementVNode("div", _hoisted_2$1, vue.toDisplayString(props.title || "系统预设色彩"), 1),
2029
- vue.createElementVNode("div", _hoisted_3$1, [
2058
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
2059
+ vue.createElementVNode("div", _hoisted_2$5, vue.toDisplayString(props.title || "Preset colors"), 1),
2060
+ vue.createElementVNode("div", _hoisted_3$4, [
2030
2061
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(preColors.value, (color2) => {
2031
2062
  return vue.openBlock(), vue.createElementBlock("div", {
2032
2063
  class: "hv-color-picker__preset-list-item",
2033
2064
  onClick: ($event) => handleClickColor(color2),
2034
2065
  key: color2,
2035
2066
  style: vue.normalizeStyle({ backgroundColor: color2 })
2036
- }, null, 12, _hoisted_4$1);
2067
+ }, null, 12, _hoisted_4$2);
2037
2068
  }), 128))
2038
2069
  ])
2039
2070
  ]);
2040
2071
  };
2041
2072
  }
2042
2073
  });
2043
- const _hoisted_1$1 = { class: "hv-color-picker" };
2044
- const _hoisted_2 = { class: "hv-color-picker__title" };
2045
- const _hoisted_3 = { class: "hv-color-picker__area-outer" };
2046
- const _hoisted_4 = { class: "hv-color-picker__slider" };
2047
- const DEFAULT_COLOR = "#FFFFFF";
2048
- const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
2074
+ const _hoisted_1$5 = { class: "hv-color-picker" };
2075
+ const _hoisted_2$4 = { class: "hv-color-picker__title" };
2076
+ const _hoisted_3$3 = { class: "hv-color-picker__area-outer" };
2077
+ const _hoisted_4$1 = { class: "hv-color-picker__slider" };
2078
+ const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
2049
2079
  ...{
2050
2080
  name: "HvColorPicker"
2051
2081
  },
2052
2082
  __name: "ColorPicker",
2053
- props: /* @__PURE__ */ vue.mergeModels({
2083
+ props: {
2084
+ modelValue: { default: DEFAULT_COLOR },
2085
+ disabled: { type: Boolean },
2054
2086
  title: {},
2055
2087
  presetTitle: {},
2056
2088
  presetColors: {}
2057
- }, {
2058
- "modelValue": {
2059
- type: String,
2060
- default: DEFAULT_COLOR
2061
- },
2062
- "modelModifiers": {}
2063
- }),
2064
- emits: /* @__PURE__ */ vue.mergeModels(["update:model-value"], ["update:modelValue"]),
2089
+ },
2090
+ emits: ["update:model-value"],
2065
2091
  setup(__props, { emit: __emit }) {
2066
2092
  const props = __props;
2067
2093
  const emits = __emit;
2094
+ const isDisabled = vue.computed(() => props.disabled);
2068
2095
  const { colorAreaCanvas, getColorByCoordinate, getCoordinateByColor, canvasWidth, canvasHeight } = useColorArea();
2069
- const { colorAreaRef, circlePickerCoordinate, setCirclePickerCoordinate } = useOperateEvent();
2070
- const color2 = vue.useModel(__props, "modelValue");
2096
+ const { colorAreaRef, circlePickerCoordinate, setCirclePickerCoordinate } = useOperateEvent({ disabled: isDisabled });
2097
+ const color2 = vue.computed({
2098
+ get() {
2099
+ return props.modelValue;
2100
+ },
2101
+ set(value) {
2102
+ emits("update:model-value", value);
2103
+ }
2104
+ });
2071
2105
  const lightColor = vue.ref(Color$1(DEFAULT_COLOR));
2072
2106
  const colorDepth = vue.ref(100);
2073
2107
  const originHexColor = vue.computed(() => {
@@ -2130,6 +2164,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2130
2164
  }
2131
2165
  );
2132
2166
  function handleColorChange(hex) {
2167
+ if (props.disabled) {
2168
+ return;
2169
+ }
2133
2170
  const color22 = hexToColor(hex);
2134
2171
  const { color: lightRgb, value: depth } = getLightColorAndDepth(color22);
2135
2172
  lightColor.value = lightRgb;
@@ -2142,11 +2179,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2142
2179
  });
2143
2180
  return (_ctx, _cache) => {
2144
2181
  const _component_ElSlider = vue.resolveComponent("ElSlider");
2145
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
2146
- vue.createElementVNode("div", _hoisted_2, vue.toDisplayString(props.title || "颜色编辑器"), 1),
2147
- vue.createElementVNode("div", _hoisted_3, [
2182
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, [
2183
+ vue.createElementVNode("div", _hoisted_2$4, vue.toDisplayString(props.title || "Color picker"), 1),
2184
+ vue.createElementVNode("div", _hoisted_3$3, [
2148
2185
  vue.createElementVNode("div", {
2149
- class: "hv-color-picker__area",
2186
+ class: vue.normalizeClass(["hv-color-picker__area", isDisabled.value ? "is-disabled" : ""]),
2150
2187
  ref_key: "colorAreaRef",
2151
2188
  ref: colorAreaRef
2152
2189
  }, [
@@ -2158,27 +2195,841 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2158
2195
  class: "hv-color-picker__circle",
2159
2196
  style: vue.normalizeStyle(cilcleStyle.value)
2160
2197
  }, null, 4)
2161
- ], 512)
2198
+ ], 2)
2162
2199
  ]),
2163
- vue.createElementVNode("div", _hoisted_4, [
2200
+ vue.createElementVNode("div", _hoisted_4$1, [
2164
2201
  vue.createVNode(_component_ElSlider, {
2165
2202
  modelValue: colorDepth.value,
2166
2203
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => colorDepth.value = $event),
2204
+ disabled: props.disabled,
2167
2205
  min: 0,
2168
2206
  max: 100,
2169
2207
  "show-tooltip": false,
2170
2208
  style: vue.normalizeStyle(sliderBackStyle.value)
2171
- }, null, 8, ["modelValue", "style"]),
2209
+ }, null, 8, ["modelValue", "disabled", "style"]),
2172
2210
  vue.createElementVNode("div", {
2173
2211
  class: "hv-color-picker__origin-color",
2174
2212
  style: vue.normalizeStyle({ backgroundColor: originHexColor.value })
2175
2213
  }, null, 4)
2176
2214
  ]),
2177
- vue.createVNode(_sfc_main$5, {
2215
+ vue.createVNode(_sfc_main$a, {
2178
2216
  "model-value": color2.value,
2217
+ disabled: props.disabled,
2179
2218
  onChange: handleColorChange
2180
- }, null, 8, ["model-value"]),
2181
- vue.createVNode(_sfc_main$4, {
2219
+ }, null, 8, ["model-value", "disabled"]),
2220
+ vue.createVNode(_sfc_main$9, {
2221
+ onChange: handleColorChange,
2222
+ title: props.presetTitle,
2223
+ presetColors: props.presetColors
2224
+ }, null, 8, ["title", "presetColors"])
2225
+ ]);
2226
+ };
2227
+ }
2228
+ });
2229
+ function isObject$3(value) {
2230
+ var type = typeof value;
2231
+ return value != null && (type == "object" || type == "function");
2232
+ }
2233
+ var isObject_1 = isObject$3;
2234
+ var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
2235
+ var _freeGlobal = freeGlobal$1;
2236
+ var freeGlobal = _freeGlobal;
2237
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
2238
+ var root$2 = freeGlobal || freeSelf || Function("return this")();
2239
+ var _root = root$2;
2240
+ var root$1 = _root;
2241
+ var now$1 = function() {
2242
+ return root$1.Date.now();
2243
+ };
2244
+ var now_1 = now$1;
2245
+ var reWhitespace = /\s/;
2246
+ function trimmedEndIndex$1(string) {
2247
+ var index = string.length;
2248
+ while (index-- && reWhitespace.test(string.charAt(index))) {
2249
+ }
2250
+ return index;
2251
+ }
2252
+ var _trimmedEndIndex = trimmedEndIndex$1;
2253
+ var trimmedEndIndex = _trimmedEndIndex;
2254
+ var reTrimStart = /^\s+/;
2255
+ function baseTrim$1(string) {
2256
+ return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
2257
+ }
2258
+ var _baseTrim = baseTrim$1;
2259
+ var root = _root;
2260
+ var Symbol$3 = root.Symbol;
2261
+ var _Symbol = Symbol$3;
2262
+ var Symbol$2 = _Symbol;
2263
+ var objectProto$1 = Object.prototype;
2264
+ var hasOwnProperty = objectProto$1.hasOwnProperty;
2265
+ var nativeObjectToString$1 = objectProto$1.toString;
2266
+ var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : void 0;
2267
+ function getRawTag$1(value) {
2268
+ var isOwn = hasOwnProperty.call(value, symToStringTag$1), tag = value[symToStringTag$1];
2269
+ try {
2270
+ value[symToStringTag$1] = void 0;
2271
+ var unmasked = true;
2272
+ } catch (e) {
2273
+ }
2274
+ var result = nativeObjectToString$1.call(value);
2275
+ if (unmasked) {
2276
+ if (isOwn) {
2277
+ value[symToStringTag$1] = tag;
2278
+ } else {
2279
+ delete value[symToStringTag$1];
2280
+ }
2281
+ }
2282
+ return result;
2283
+ }
2284
+ var _getRawTag = getRawTag$1;
2285
+ var objectProto = Object.prototype;
2286
+ var nativeObjectToString = objectProto.toString;
2287
+ function objectToString$1(value) {
2288
+ return nativeObjectToString.call(value);
2289
+ }
2290
+ var _objectToString = objectToString$1;
2291
+ var Symbol$1 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
2292
+ var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
2293
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
2294
+ function baseGetTag$1(value) {
2295
+ if (value == null) {
2296
+ return value === void 0 ? undefinedTag : nullTag;
2297
+ }
2298
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
2299
+ }
2300
+ var _baseGetTag = baseGetTag$1;
2301
+ function isObjectLike$1(value) {
2302
+ return value != null && typeof value == "object";
2303
+ }
2304
+ var isObjectLike_1 = isObjectLike$1;
2305
+ var baseGetTag = _baseGetTag, isObjectLike = isObjectLike_1;
2306
+ var symbolTag = "[object Symbol]";
2307
+ function isSymbol$1(value) {
2308
+ return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
2309
+ }
2310
+ var isSymbol_1 = isSymbol$1;
2311
+ var baseTrim = _baseTrim, isObject$2 = isObject_1, isSymbol = isSymbol_1;
2312
+ var NAN = 0 / 0;
2313
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
2314
+ var reIsBinary = /^0b[01]+$/i;
2315
+ var reIsOctal = /^0o[0-7]+$/i;
2316
+ var freeParseInt = parseInt;
2317
+ function toNumber$1(value) {
2318
+ if (typeof value == "number") {
2319
+ return value;
2320
+ }
2321
+ if (isSymbol(value)) {
2322
+ return NAN;
2323
+ }
2324
+ if (isObject$2(value)) {
2325
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
2326
+ value = isObject$2(other) ? other + "" : other;
2327
+ }
2328
+ if (typeof value != "string") {
2329
+ return value === 0 ? value : +value;
2330
+ }
2331
+ value = baseTrim(value);
2332
+ var isBinary = reIsBinary.test(value);
2333
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
2334
+ }
2335
+ var toNumber_1 = toNumber$1;
2336
+ var isObject$1 = isObject_1, now = now_1, toNumber = toNumber_1;
2337
+ var FUNC_ERROR_TEXT$1 = "Expected a function";
2338
+ var nativeMax = Math.max, nativeMin = Math.min;
2339
+ function debounce$1(func, wait, options) {
2340
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
2341
+ if (typeof func != "function") {
2342
+ throw new TypeError(FUNC_ERROR_TEXT$1);
2343
+ }
2344
+ wait = toNumber(wait) || 0;
2345
+ if (isObject$1(options)) {
2346
+ leading = !!options.leading;
2347
+ maxing = "maxWait" in options;
2348
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
2349
+ trailing = "trailing" in options ? !!options.trailing : trailing;
2350
+ }
2351
+ function invokeFunc(time) {
2352
+ var args = lastArgs, thisArg = lastThis;
2353
+ lastArgs = lastThis = void 0;
2354
+ lastInvokeTime = time;
2355
+ result = func.apply(thisArg, args);
2356
+ return result;
2357
+ }
2358
+ function leadingEdge(time) {
2359
+ lastInvokeTime = time;
2360
+ timerId = setTimeout(timerExpired, wait);
2361
+ return leading ? invokeFunc(time) : result;
2362
+ }
2363
+ function remainingWait(time) {
2364
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
2365
+ return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
2366
+ }
2367
+ function shouldInvoke(time) {
2368
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
2369
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
2370
+ }
2371
+ function timerExpired() {
2372
+ var time = now();
2373
+ if (shouldInvoke(time)) {
2374
+ return trailingEdge(time);
2375
+ }
2376
+ timerId = setTimeout(timerExpired, remainingWait(time));
2377
+ }
2378
+ function trailingEdge(time) {
2379
+ timerId = void 0;
2380
+ if (trailing && lastArgs) {
2381
+ return invokeFunc(time);
2382
+ }
2383
+ lastArgs = lastThis = void 0;
2384
+ return result;
2385
+ }
2386
+ function cancel() {
2387
+ if (timerId !== void 0) {
2388
+ clearTimeout(timerId);
2389
+ }
2390
+ lastInvokeTime = 0;
2391
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
2392
+ }
2393
+ function flush() {
2394
+ return timerId === void 0 ? result : trailingEdge(now());
2395
+ }
2396
+ function debounced() {
2397
+ var time = now(), isInvoking = shouldInvoke(time);
2398
+ lastArgs = arguments;
2399
+ lastThis = this;
2400
+ lastCallTime = time;
2401
+ if (isInvoking) {
2402
+ if (timerId === void 0) {
2403
+ return leadingEdge(lastCallTime);
2404
+ }
2405
+ if (maxing) {
2406
+ clearTimeout(timerId);
2407
+ timerId = setTimeout(timerExpired, wait);
2408
+ return invokeFunc(lastCallTime);
2409
+ }
2410
+ }
2411
+ if (timerId === void 0) {
2412
+ timerId = setTimeout(timerExpired, wait);
2413
+ }
2414
+ return result;
2415
+ }
2416
+ debounced.cancel = cancel;
2417
+ debounced.flush = flush;
2418
+ return debounced;
2419
+ }
2420
+ var debounce_1 = debounce$1;
2421
+ var debounce = debounce_1, isObject = isObject_1;
2422
+ var FUNC_ERROR_TEXT = "Expected a function";
2423
+ function throttle(func, wait, options) {
2424
+ var leading = true, trailing = true;
2425
+ if (typeof func != "function") {
2426
+ throw new TypeError(FUNC_ERROR_TEXT);
2427
+ }
2428
+ if (isObject(options)) {
2429
+ leading = "leading" in options ? !!options.leading : leading;
2430
+ trailing = "trailing" in options ? !!options.trailing : trailing;
2431
+ }
2432
+ return debounce(func, wait, {
2433
+ "leading": leading,
2434
+ "maxWait": wait,
2435
+ "trailing": trailing
2436
+ });
2437
+ }
2438
+ var throttle_1 = throttle;
2439
+ const throttle$1 = /* @__PURE__ */ getDefaultExportFromCjs(throttle_1);
2440
+ let lastPoint = {
2441
+ x: void 0,
2442
+ y: void 0
2443
+ };
2444
+ function useInteraction(disabled) {
2445
+ const colorAreaRef = vue.ref();
2446
+ const circlePickerCoordinate = vue.reactive({
2447
+ x: 100,
2448
+ y: 100
2449
+ });
2450
+ function handleTouchStart(e) {
2451
+ if (disabled.value) {
2452
+ return;
2453
+ }
2454
+ if (e.touches.length === 0) {
2455
+ return;
2456
+ }
2457
+ e.preventDefault();
2458
+ const { clientX, clientY } = e.touches[0];
2459
+ handleCirclePickerCoordinateChange({
2460
+ x: clientX,
2461
+ y: clientY
2462
+ });
2463
+ document.body.addEventListener("touchmove", handleTouchMove);
2464
+ document.body.addEventListener("touchend", handleTouchEnd);
2465
+ }
2466
+ function handleTouchMove(e) {
2467
+ if (disabled.value) {
2468
+ return;
2469
+ }
2470
+ if (e.touches.length > 1) {
2471
+ return;
2472
+ }
2473
+ const { clientX, clientY } = e.touches[0];
2474
+ handleCirclePickerCoordinateChange({
2475
+ x: clientX,
2476
+ y: clientY
2477
+ });
2478
+ }
2479
+ function handleTouchEnd() {
2480
+ document.body.removeEventListener("touchmove", handleTouchMove);
2481
+ document.body.removeEventListener("touchend", handleTouchEnd);
2482
+ }
2483
+ function handleMounseDown(e) {
2484
+ if (disabled.value) {
2485
+ return;
2486
+ }
2487
+ document.body.addEventListener("mousemove", handleMouseMove);
2488
+ document.body.addEventListener("mouseup", handleMouseUp);
2489
+ handleCirclePickerCoordinateChange({
2490
+ x: e.clientX,
2491
+ y: e.clientY
2492
+ });
2493
+ }
2494
+ function handleMouseMove(e) {
2495
+ if (disabled.value) {
2496
+ return;
2497
+ }
2498
+ if (!(e.buttons && 1)) {
2499
+ handleMouseUp();
2500
+ return;
2501
+ }
2502
+ handleCirclePickerCoordinateChange({
2503
+ x: e.clientX,
2504
+ y: e.clientY
2505
+ });
2506
+ }
2507
+ const handleCirclePickerCoordinateChange = throttle$1(handleCirclePickerCoordinateChangeFn, 20);
2508
+ function handleCirclePickerCoordinateChangeFn(point) {
2509
+ var _a;
2510
+ const { x: clientX, y: clientY } = point;
2511
+ if (lastPoint.x == point.x && lastPoint.y == point.y) {
2512
+ return;
2513
+ }
2514
+ lastPoint = point;
2515
+ const colorAreaRect = (_a = colorAreaRef.value) == null ? void 0 : _a.getBoundingClientRect();
2516
+ if (!colorAreaRect) {
2517
+ return;
2518
+ }
2519
+ const { left, top, width, height } = colorAreaRect;
2520
+ let x = 0;
2521
+ let y = 0;
2522
+ if (clientX <= left) {
2523
+ x = 0;
2524
+ } else if (clientX >= left + width) {
2525
+ x = width;
2526
+ } else {
2527
+ x = clientX - left;
2528
+ }
2529
+ if (clientY <= top) {
2530
+ y = 0;
2531
+ } else if (clientY >= top + height) {
2532
+ y = height;
2533
+ } else {
2534
+ y = clientY - top;
2535
+ }
2536
+ circlePickerCoordinate.x = x / width * 100;
2537
+ circlePickerCoordinate.y = (height - y) / height * 100;
2538
+ }
2539
+ function handleMouseUp() {
2540
+ document.body.removeEventListener("mousemove", handleMouseMove);
2541
+ document.body.removeEventListener("mouseup", handleMouseUp);
2542
+ }
2543
+ function setCirclePickerCoordinate(x, y) {
2544
+ circlePickerCoordinate.x = x;
2545
+ circlePickerCoordinate.y = y;
2546
+ }
2547
+ vue.onMounted(() => {
2548
+ var _a, _b;
2549
+ (_a = colorAreaRef.value) == null ? void 0 : _a.addEventListener("touchstart", handleTouchStart);
2550
+ (_b = colorAreaRef.value) == null ? void 0 : _b.addEventListener("mousedown", handleMounseDown);
2551
+ });
2552
+ vue.onBeforeUnmount(() => {
2553
+ var _a, _b;
2554
+ (_a = colorAreaRef.value) == null ? void 0 : _a.removeEventListener("touchstart", handleTouchStart);
2555
+ document.body.removeEventListener("touchmove", handleTouchMove);
2556
+ document.body.removeEventListener("touchend", handleTouchEnd);
2557
+ (_b = colorAreaRef.value) == null ? void 0 : _b.removeEventListener("mousedown", handleMounseDown);
2558
+ document.body.removeEventListener("mousemove", handleMouseMove);
2559
+ document.body.removeEventListener("mouseup", handleMouseUp);
2560
+ });
2561
+ return {
2562
+ colorAreaRef,
2563
+ circlePickerCoordinate,
2564
+ setCirclePickerCoordinate
2565
+ };
2566
+ }
2567
+ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
2568
+ __name: "ColorArea",
2569
+ props: {
2570
+ saturation: { default: 100 },
2571
+ value: { default: 100 },
2572
+ color: {},
2573
+ hueColor: {},
2574
+ disabled: { type: Boolean }
2575
+ },
2576
+ emits: ["update:saturation", "update:value"],
2577
+ setup(__props, { emit: __emit }) {
2578
+ const emits = __emit;
2579
+ const props = __props;
2580
+ const saturationv = vue.computed({
2581
+ get() {
2582
+ return props.saturation;
2583
+ },
2584
+ set(value2) {
2585
+ emits("update:saturation", value2);
2586
+ }
2587
+ });
2588
+ const value = vue.computed({
2589
+ get() {
2590
+ return props.value;
2591
+ },
2592
+ set(value2) {
2593
+ emits("update:value", value2);
2594
+ }
2595
+ });
2596
+ const isDisabled = vue.computed(() => {
2597
+ return props.disabled;
2598
+ });
2599
+ const { colorAreaRef, circlePickerCoordinate, setCirclePickerCoordinate } = useInteraction(isDisabled);
2600
+ const state = vue.reactive({
2601
+ hexColor: "",
2602
+ bgHexColor: ""
2603
+ });
2604
+ vue.watch(
2605
+ () => props.color,
2606
+ (c) => {
2607
+ const color2 = Color$1(c);
2608
+ state.hexColor = color2.hex();
2609
+ let { h, s, v } = color2.hsv().object();
2610
+ state.bgHexColor = Color$1({ h, s: 100, v: 100 }).hex();
2611
+ const curColor = Color$1.hsv({ h, s: circlePickerCoordinate.x, v: circlePickerCoordinate.y }).hex();
2612
+ if (curColor == color2.hex()) {
2613
+ s = circlePickerCoordinate.x;
2614
+ }
2615
+ setCirclePickerCoordinate(s, v);
2616
+ },
2617
+ {
2618
+ immediate: true
2619
+ }
2620
+ );
2621
+ vue.watch(
2622
+ circlePickerCoordinate,
2623
+ (val) => {
2624
+ saturationv.value = val.x;
2625
+ value.value = val.y;
2626
+ },
2627
+ {
2628
+ deep: true
2629
+ }
2630
+ );
2631
+ return (_ctx, _cache) => {
2632
+ return vue.openBlock(), vue.createElementBlock("div", {
2633
+ ref_key: "colorAreaRef",
2634
+ ref: colorAreaRef,
2635
+ class: "hv-color-picker__color-area-outer"
2636
+ }, [
2637
+ vue.createElementVNode("div", {
2638
+ class: "hv-color-picker__color-area",
2639
+ style: vue.normalizeStyle({ backgroundColor: props.hueColor })
2640
+ }, [
2641
+ vue.createElementVNode("div", {
2642
+ class: "hv-color-picker__circle",
2643
+ style: vue.normalizeStyle({
2644
+ backgroundColor: state.hexColor,
2645
+ left: `${vue.unref(circlePickerCoordinate).x}%`,
2646
+ bottom: `${vue.unref(circlePickerCoordinate).y}%`
2647
+ })
2648
+ }, null, 4)
2649
+ ], 4)
2650
+ ], 512);
2651
+ };
2652
+ }
2653
+ });
2654
+ const _export_sfc = (sfc, props) => {
2655
+ const target = sfc.__vccOpts || sfc;
2656
+ for (const [key, val] of props) {
2657
+ target[key] = val;
2658
+ }
2659
+ return target;
2660
+ };
2661
+ const ColorArea = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-d4f5b081"]]);
2662
+ const _hoisted_1$4 = { class: "hv-color_picker__form mb-12" };
2663
+ const _hoisted_2$3 = { class: "hv-color-picker__form-type" };
2664
+ const _hoisted_3$2 = { class: "hv-color-picker__form-body" };
2665
+ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
2666
+ __name: "ColorForm",
2667
+ props: {
2668
+ modelValue: {},
2669
+ disabled: { type: Boolean },
2670
+ enableAlpha: { type: Boolean }
2671
+ },
2672
+ emits: ["update:modelValue"],
2673
+ setup(__props, { emit: __emit }) {
2674
+ const SelectOptions = ["RGB", "HSL", "HSV"];
2675
+ const props = __props;
2676
+ const emits = __emit;
2677
+ const formType = vue.ref("RGB");
2678
+ const formInputState = vue.ref([255, 255, 255, 100]);
2679
+ const isRGB = vue.computed(() => {
2680
+ return formType.value === "RGB";
2681
+ });
2682
+ vue.watch(
2683
+ () => props.modelValue,
2684
+ () => {
2685
+ handleFormTypeChange();
2686
+ },
2687
+ {
2688
+ immediate: true
2689
+ }
2690
+ );
2691
+ function handleFormTypeChange() {
2692
+ const color2 = Color$1(props.modelValue);
2693
+ const alpha = color2.alpha() * 100;
2694
+ switch (formType.value) {
2695
+ case "RGB": {
2696
+ const arr = color2.rgb().array();
2697
+ formInputState.value = [...arr.slice(0, 3), alpha];
2698
+ break;
2699
+ }
2700
+ case "HSL": {
2701
+ const arr = color2.hsl().array();
2702
+ formInputState.value = [...arr.slice(0, 3), alpha];
2703
+ break;
2704
+ }
2705
+ case "HSV": {
2706
+ const arr = color2.hsv().array();
2707
+ formInputState.value = [...arr.slice(0, 3), alpha];
2708
+ break;
2709
+ }
2710
+ }
2711
+ }
2712
+ function handleColorChange() {
2713
+ let color2 = Color$1(DEFAULT_COLOR);
2714
+ switch (formType.value) {
2715
+ case "RGB": {
2716
+ color2 = Color$1.rgb(...formInputState.value.slice(0, 3));
2717
+ break;
2718
+ }
2719
+ case "HSL": {
2720
+ color2 = Color$1.hsl(...formInputState.value.slice(0, 3));
2721
+ break;
2722
+ }
2723
+ case "HSV": {
2724
+ color2 = Color$1.hsv(...formInputState.value.slice(0, 3));
2725
+ break;
2726
+ }
2727
+ }
2728
+ emits("update:modelValue", color2.alpha(props.enableAlpha ? formInputState.value[3] / 100 : 1).hexa());
2729
+ }
2730
+ return (_ctx, _cache) => {
2731
+ const _component_el_option = vue.resolveComponent("el-option");
2732
+ const _component_el_select = vue.resolveComponent("el-select");
2733
+ const _component_el_input_number = vue.resolveComponent("el-input-number");
2734
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
2735
+ vue.createElementVNode("div", _hoisted_2$3, [
2736
+ vue.createVNode(_component_el_select, {
2737
+ modelValue: formType.value,
2738
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formType.value = $event),
2739
+ disabled: props.disabled,
2740
+ "popper-class": "hv-color-picker-popper",
2741
+ onChange: handleFormTypeChange,
2742
+ teleported: false
2743
+ }, {
2744
+ default: vue.withCtx(() => [
2745
+ (vue.openBlock(), vue.createElementBlock(vue.Fragment, null, vue.renderList(SelectOptions, (item) => {
2746
+ return vue.createVNode(_component_el_option, {
2747
+ key: item,
2748
+ label: item,
2749
+ value: item
2750
+ }, null, 8, ["label", "value"]);
2751
+ }), 64))
2752
+ ]),
2753
+ _: 1
2754
+ }, 8, ["modelValue", "disabled"])
2755
+ ]),
2756
+ vue.createElementVNode("div", _hoisted_3$2, [
2757
+ vue.createVNode(_component_el_input_number, {
2758
+ modelValue: formInputState.value[0],
2759
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => formInputState.value[0] = $event),
2760
+ onChange: handleColorChange,
2761
+ "step-strictly": "",
2762
+ disabled: props.disabled,
2763
+ min: 0,
2764
+ max: isRGB.value ? 255 : 360,
2765
+ "value-on-clear": 0,
2766
+ step: 1,
2767
+ controls: false
2768
+ }, null, 8, ["modelValue", "disabled", "max"]),
2769
+ vue.createVNode(_component_el_input_number, {
2770
+ modelValue: formInputState.value[1],
2771
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => formInputState.value[1] = $event),
2772
+ onChange: handleColorChange,
2773
+ "step-strictly": "",
2774
+ disabled: props.disabled,
2775
+ min: 0,
2776
+ max: isRGB.value ? 255 : 100,
2777
+ "value-on-clear": 0,
2778
+ step: 1,
2779
+ controls: false
2780
+ }, null, 8, ["modelValue", "disabled", "max"]),
2781
+ vue.createVNode(_component_el_input_number, {
2782
+ modelValue: formInputState.value[2],
2783
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => formInputState.value[2] = $event),
2784
+ onChange: handleColorChange,
2785
+ "step-strictly": "",
2786
+ disabled: props.disabled,
2787
+ min: 0,
2788
+ max: isRGB.value ? 255 : 100,
2789
+ "value-on-clear": 0,
2790
+ step: 1,
2791
+ controls: false
2792
+ }, null, 8, ["modelValue", "disabled", "max"]),
2793
+ props.enableAlpha ? (vue.openBlock(), vue.createBlock(_component_el_input_number, {
2794
+ key: 0,
2795
+ modelValue: formInputState.value[3],
2796
+ "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => formInputState.value[3] = $event),
2797
+ onChange: handleColorChange,
2798
+ class: "hv-color-picker__form-opacity",
2799
+ "step-strictly": "",
2800
+ disabled: props.disabled,
2801
+ min: 0,
2802
+ max: 100,
2803
+ "value-on-clear": 0,
2804
+ step: 1,
2805
+ controls: false
2806
+ }, {
2807
+ suffix: vue.withCtx(() => _cache[5] || (_cache[5] = [
2808
+ vue.createElementVNode("span", null, "%", -1)
2809
+ ])),
2810
+ _: 1
2811
+ }, 8, ["modelValue", "disabled"])) : vue.createCommentVNode("", true)
2812
+ ])
2813
+ ]);
2814
+ };
2815
+ }
2816
+ });
2817
+ const ColorForm = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-0118404d"]]);
2818
+ const _hoisted_1$3 = { class: "hv-color-picker__preset" };
2819
+ const _hoisted_2$2 = { class: "hv-color-picker__preset-title" };
2820
+ const _hoisted_3$1 = { class: "hv-color-picker__preset-list" };
2821
+ const _hoisted_4 = ["onClick"];
2822
+ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
2823
+ __name: "PresetColors",
2824
+ props: {
2825
+ title: {},
2826
+ presetColors: {}
2827
+ },
2828
+ emits: ["change"],
2829
+ setup(__props, { emit: __emit }) {
2830
+ const defaultPresetColors = [
2831
+ "#000000",
2832
+ "#FFFFFF",
2833
+ "#E3822D",
2834
+ "#DCE24F",
2835
+ "#1DCF69",
2836
+ "#6DE5B9",
2837
+ "#11A1F2",
2838
+ "#AA43FF",
2839
+ "#F0689C",
2840
+ "#F8D28B",
2841
+ "#606368",
2842
+ "#E83C34",
2843
+ "#EEBE29",
2844
+ "#89F0AC",
2845
+ "#2FBC9E",
2846
+ "#56CCF2",
2847
+ "#1C1DFA",
2848
+ "#DC88F5",
2849
+ "#D4C595",
2850
+ "#C52F65"
2851
+ ];
2852
+ const props = __props;
2853
+ const preColors = vue.computed(() => {
2854
+ return !props.presetColors ? defaultPresetColors : props.presetColors;
2855
+ });
2856
+ const emits = __emit;
2857
+ function handleClickColor(color2) {
2858
+ emits("change", color2);
2859
+ }
2860
+ return (_ctx, _cache) => {
2861
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
2862
+ vue.createElementVNode("div", _hoisted_2$2, vue.toDisplayString(props.title || "Reset colors"), 1),
2863
+ vue.createElementVNode("div", _hoisted_3$1, [
2864
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(preColors.value, (color2) => {
2865
+ return vue.openBlock(), vue.createElementBlock("div", {
2866
+ class: "hv-color-picker__preset-list-item",
2867
+ onClick: ($event) => handleClickColor(color2),
2868
+ key: color2,
2869
+ style: vue.normalizeStyle({ backgroundColor: color2 })
2870
+ }, null, 12, _hoisted_4);
2871
+ }), 128))
2872
+ ])
2873
+ ]);
2874
+ };
2875
+ }
2876
+ });
2877
+ const PresetColors = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-c15cc053"]]);
2878
+ const _hoisted_1$2 = { class: "hv-color-picker-normal" };
2879
+ const _hoisted_2$1 = { class: "hv-color-picker__color-select-box" };
2880
+ const _hoisted_3 = { class: "hv-color-picker__sliders" };
2881
+ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
2882
+ ...{
2883
+ name: "HvColorPickerNormal"
2884
+ },
2885
+ __name: "ColorPicker",
2886
+ props: {
2887
+ modelValue: { default: DEFAULT_COLOR },
2888
+ disabled: { type: Boolean },
2889
+ enableAlpha: { type: Boolean, default: true },
2890
+ presetTitle: {},
2891
+ presetColors: {}
2892
+ },
2893
+ emits: ["update:model-value"],
2894
+ setup(__props, { emit: __emit }) {
2895
+ const emits = __emit;
2896
+ const props = __props;
2897
+ const color2 = vue.computed({
2898
+ get() {
2899
+ return props.modelValue;
2900
+ },
2901
+ set(value2) {
2902
+ emits("update:model-value", value2);
2903
+ }
2904
+ });
2905
+ const isSupportEyeDropper = !!window.EyeDropper;
2906
+ const colorAreaRef = vue.ref();
2907
+ const hue = vue.ref(0);
2908
+ const alpha = vue.ref(0);
2909
+ const saturationv = vue.ref(100);
2910
+ const value = vue.ref(100);
2911
+ const fullAlphaColor = vue.computed(() => {
2912
+ return Color$1(color2.value).alpha(1).hex();
2913
+ });
2914
+ vue.watch(
2915
+ color2,
2916
+ (c) => {
2917
+ const color22 = Color$1(c);
2918
+ const { h, s } = color22.hsv().object();
2919
+ saturationv.value = s;
2920
+ const equlValues = [0, 360];
2921
+ alpha.value = props.enableAlpha ? Math.round(color22.alpha() * 100) : 100;
2922
+ const curColor = Color$1.hsv({ h: hue.value, s: saturationv.value, v: value.value, alpha: alpha.value }).hexa();
2923
+ if (curColor !== color22.hexa()) {
2924
+ if (!(equlValues.includes(h) && equlValues.includes(hue.value))) {
2925
+ hue.value = h;
2926
+ }
2927
+ }
2928
+ },
2929
+ {
2930
+ immediate: true
2931
+ }
2932
+ );
2933
+ const hueColor = vue.computed(() => {
2934
+ const color22 = Color$1({ h: hue.value, s: 100, v: 100 });
2935
+ return color22.hex();
2936
+ });
2937
+ vue.watch([hue, alpha, saturationv, value], () => {
2938
+ reCompColor();
2939
+ });
2940
+ const reCompColor = throttle$1(
2941
+ function reCompColor2() {
2942
+ const newColor = Color$1({ h: hue.value, s: saturationv.value, v: value.value, alpha: alpha.value / 100 });
2943
+ color2.value = props.enableAlpha ? newColor.hexa() : newColor.hex();
2944
+ },
2945
+ 50,
2946
+ {
2947
+ leading: false,
2948
+ trailing: true
2949
+ }
2950
+ );
2951
+ function handleOpenEyeDropper() {
2952
+ if (props.disabled) {
2953
+ return;
2954
+ }
2955
+ const eyeDropper = new window.EyeDropper();
2956
+ eyeDropper.open().then((result) => {
2957
+ color2.value = result.sRGBHex;
2958
+ }).catch((e) => {
2959
+ console.error("Eyedropper failed to get color", e);
2960
+ });
2961
+ }
2962
+ function handleColorChange(hex) {
2963
+ if (props.disabled) {
2964
+ return;
2965
+ }
2966
+ color2.value = hex;
2967
+ }
2968
+ return (_ctx, _cache) => {
2969
+ const _component_ElSlider = vue.resolveComponent("ElSlider");
2970
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
2971
+ vue.createVNode(ColorArea, {
2972
+ ref_key: "colorAreaRef",
2973
+ ref: colorAreaRef,
2974
+ "hue-color": hueColor.value,
2975
+ color: color2.value,
2976
+ saturation: saturationv.value,
2977
+ "onUpdate:saturation": _cache[0] || (_cache[0] = ($event) => saturationv.value = $event),
2978
+ value: value.value,
2979
+ "onUpdate:value": _cache[1] || (_cache[1] = ($event) => value.value = $event),
2980
+ disabled: props.disabled
2981
+ }, null, 8, ["hue-color", "color", "saturation", "value", "disabled"]),
2982
+ vue.createElementVNode("div", _hoisted_2$1, [
2983
+ isSupportEyeDropper ? (vue.openBlock(), vue.createElementBlock("svg", {
2984
+ key: 0,
2985
+ onClick: handleOpenEyeDropper,
2986
+ class: vue.normalizeClass(["hv-color-picker__dropper", props.disabled ? "is-disabled" : ""]),
2987
+ width: "28",
2988
+ height: "28",
2989
+ viewBox: "0 0 28 28",
2990
+ fill: "none",
2991
+ xmlns: "http://www.w3.org/2000/svg"
2992
+ }, _cache[5] || (_cache[5] = [
2993
+ vue.createElementVNode("path", {
2994
+ d: "M22.9297 5.8C21.863 4.73333 20.263 4.73333 19.1964 5.8L15.463 9.53332L14.3963 8.59999C13.863 8.06666 13.063 8.06666 12.5296 8.59999C11.9963 9.13332 11.9963 9.93332 12.5296 10.4667L13.463 11.4L5.72967 19.1333C5.19634 19.6666 4.39634 21.6666 5.72967 23C7.06299 24.3333 9.06299 23.5333 9.59632 23L17.3296 15.2666L18.263 16.2C18.7964 16.7333 19.5964 16.7333 20.1297 16.2C20.663 15.6666 20.663 14.8666 20.1297 14.3333L19.1964 13.4L22.9297 9.66666C23.9964 8.46666 23.9964 6.86666 22.9297 5.8ZM8.39632 21.6666H7.06299V20.3333L14.7963 12.6L16.1296 13.9333C15.9963 13.9333 8.39632 21.6666 8.39632 21.6666Z",
2995
+ fill: "currentcolor"
2996
+ }, null, -1)
2997
+ ]), 2)) : vue.createCommentVNode("", true),
2998
+ vue.createElementVNode("div", _hoisted_3, [
2999
+ vue.createVNode(_component_ElSlider, {
3000
+ modelValue: hue.value,
3001
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => hue.value = $event),
3002
+ min: 0,
3003
+ max: 360,
3004
+ disabled: props.disabled,
3005
+ "show-tooltip": false,
3006
+ class: "hv-color-picker__hue-slider",
3007
+ style: vue.normalizeStyle({
3008
+ "--el-slider-button-bg-color": hueColor.value
3009
+ })
3010
+ }, null, 8, ["modelValue", "disabled", "style"]),
3011
+ props.enableAlpha ? (vue.openBlock(), vue.createBlock(_component_ElSlider, {
3012
+ key: 0,
3013
+ modelValue: alpha.value,
3014
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => alpha.value = $event),
3015
+ min: 0,
3016
+ max: 100,
3017
+ disabled: props.disabled,
3018
+ "show-tooltip": false,
3019
+ class: "hv-color-picker__alpha-slider",
3020
+ style: vue.normalizeStyle({
3021
+ "--hv-cur-full-alpha-color": fullAlphaColor.value
3022
+ })
3023
+ }, null, 8, ["modelValue", "disabled", "style"])) : vue.createCommentVNode("", true)
3024
+ ])
3025
+ ]),
3026
+ vue.createVNode(ColorForm, {
3027
+ "model-value": color2.value,
3028
+ "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => color2.value = $event),
3029
+ disabled: props.disabled,
3030
+ "enable-alpha": props.enableAlpha
3031
+ }, null, 8, ["model-value", "disabled", "enable-alpha"]),
3032
+ vue.createVNode(PresetColors, {
2182
3033
  onChange: handleColorChange,
2183
3034
  title: props.presetTitle,
2184
3035
  presetColors: props.presetColors
@@ -2187,7 +3038,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2187
3038
  };
2188
3039
  }
2189
3040
  });
2190
- const HvColorPicker = withInstall(_sfc_main$3);
3041
+ const ColorPickerNormal = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-fbafd973"]]);
3042
+ const HvColorPicker = withInstall(_sfc_main$8);
3043
+ const HvColorPickerRainbow = HvColorPicker;
3044
+ const HvColorPickerNormal = withInstall(ColorPickerNormal);
2191
3045
  class EventBus {
2192
3046
  constructor() {
2193
3047
  __publicField(this, "_eventMap");
@@ -2223,22 +3077,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2223
3077
  class DnDManager extends EventBus {
2224
3078
  constructor() {
2225
3079
  super();
2226
- /** 是否开始拖动 */
3080
+ /** 是否开始拖动 | Whether to start dragging */
2227
3081
  __publicField(this, "isDragStart", false);
2228
- /** 拖动元素类型 */
3082
+ /** 拖动元素类型 | Drag type */
2229
3083
  __publicField(this, "dragType");
2230
- /** Draggable传递的数据,
2231
- * 供Droppable使用
2232
- */
3084
+ /** Draggable传递的数据,供Droppable使用 | Draggable passes data for use by Droppable */
2233
3085
  __publicField(this, "dragData");
2234
3086
  __publicField(this, "isSendFirstMovePos", false);
2235
- /** 移动端长按一定时间才触发 onStart */
3087
+ /** 长按一定时间才触发 onStart | Press and hold for a certain amount of time to trigger onStart */
2236
3088
  __publicField(this, "touchStartPressTime", 300);
2237
- /** touchstart事件触发的时的时间 */
3089
+ /** 点击触发时的时间 | The time at which the click is triggered */
2238
3090
  __publicField(this, "touchStartTime", 0);
2239
- /** touchstart时间触发的位置 */
3091
+ /** 点击触发的位置 | The position where the click event is triggered */
2240
3092
  __publicField(this, "touchStartPosition", { x: 0, y: 0 });
2241
- /** onMove最后位置 */
3093
+ /** onMove最后位置 | onMove last position */
2242
3094
  __publicField(this, "lastMovePoint", { x: 0, y: 0 });
2243
3095
  __publicField(this, "emitTouchStartTimer");
2244
3096
  __publicField(this, "destroy", () => {
@@ -2247,7 +3099,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2247
3099
  }
2248
3100
  updateDargInfo(type, data) {
2249
3101
  if (type === void 0 || type === null) {
2250
- throw new Error("请传入拖动元素 type");
3102
+ throw new Error("Expected to get a drag type, but received ", type);
2251
3103
  }
2252
3104
  this.isDragStart = true;
2253
3105
  this.dragType = type;
@@ -2256,14 +3108,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2256
3108
  this.emitTouchStartTimer = void 0;
2257
3109
  }
2258
3110
  /**
2259
- * 通知 Draggable 开始点击
3111
+ * 通知 Draggable 开始点击 | Tell Draggable to start clicking
2260
3112
  * @param point
2261
3113
  */
2262
3114
  onDown(point) {
2263
3115
  this.emit("down", point);
2264
3116
  }
2265
3117
  /**
2266
- * 通知 Draggable 拖拽开始
3118
+ * 第一次移动时,通知 Draggable | On the first move, notify Draggable
2267
3119
  * @param point
2268
3120
  */
2269
3121
  onFirstMove(point, e) {
@@ -2274,7 +3126,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2274
3126
  this.emit("first-move", point, e);
2275
3127
  }
2276
3128
  /**
2277
- * 通知 Draggable 拖拽开始
3129
+ * 通知 Draggable 拖拽开始 | Notify Draggable to begin the drag
2278
3130
  * @param point
2279
3131
  */
2280
3132
  onStart(point) {
@@ -2284,7 +3136,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2284
3136
  this.emit("start", point);
2285
3137
  }
2286
3138
  /**
2287
- * 通知 Draggable 移动
3139
+ * 通知 Draggable 移动 | Notify Draggable to move
2288
3140
  * @param point
2289
3141
  * @returns
2290
3142
  */
@@ -2300,7 +3152,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2300
3152
  });
2301
3153
  }
2302
3154
  /**
2303
- * 结束拖拽
3155
+ * 结束拖拽 | Ending drag
2304
3156
  * @returns
2305
3157
  */
2306
3158
  onEnd() {
@@ -2454,7 +3306,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2454
3306
  }
2455
3307
  }
2456
3308
  const DnDManagerInstance = new DnDManager();
2457
- const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
3309
+ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
2458
3310
  ...{
2459
3311
  name: "HvDraggable"
2460
3312
  },
@@ -2500,10 +3352,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2500
3352
  const { x, y } = params;
2501
3353
  const startEl = document.elementFromPoint(x, y);
2502
3354
  if (!props.disabled && dragItemRef.value && dragItemRef.value.contains(startEl)) {
2503
- if (immediateDirections.value.includes(ImmediateEnumType.ALL)) {
2504
- handleStart(params);
2505
- return;
2506
- }
2507
3355
  isDownThis.value = true;
2508
3356
  downPosition.x = x;
2509
3357
  downPosition.y = y;
@@ -2511,7 +3359,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2511
3359
  };
2512
3360
  const onFirstMove = (params, event) => {
2513
3361
  const { x, y } = params;
2514
- const directions = immediateDirections.value.filter((item) => item !== ImmediateEnumType.ALL);
3362
+ const directions = immediateDirections.value;
2515
3363
  if (isDownThis.value && !props.disabled && directions.length) {
2516
3364
  const distanceH = x - downPosition.x;
2517
3365
  const distanceHAbs = Math.abs(distanceH);
@@ -2521,11 +3369,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2521
3369
  const isMaxH = distanceHAbs === max;
2522
3370
  const isMaxV = distanceVAbs === max;
2523
3371
  let isImmediate = false;
2524
- if (isMaxH) {
2525
- isImmediate = directions.includes(ImmediateEnumType.LEFT) && distanceH < 0 || directions.includes(ImmediateEnumType.RIGHT) && distanceH > 0;
2526
- }
2527
- if (isMaxV && !isImmediate) {
2528
- isImmediate = directions.includes(ImmediateEnumType.TOP) && distanceV < 0 || directions.includes(ImmediateEnumType.BOTTOM) && distanceV > 0;
3372
+ if (directions.includes(ImmediateEnumType.ALL)) {
3373
+ isImmediate = true;
3374
+ } else {
3375
+ if (isMaxH) {
3376
+ isImmediate = directions.includes(ImmediateEnumType.LEFT) && distanceH < 0 || directions.includes(ImmediateEnumType.RIGHT) && distanceH > 0;
3377
+ }
3378
+ if (isMaxV && !isImmediate) {
3379
+ isImmediate = directions.includes(ImmediateEnumType.TOP) && distanceV < 0 || directions.includes(ImmediateEnumType.BOTTOM) && distanceV > 0;
3380
+ }
2529
3381
  }
2530
3382
  if (isImmediate) {
2531
3383
  event.preventDefault();
@@ -2544,6 +3396,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2544
3396
  }
2545
3397
  };
2546
3398
  const onMove = (params) => {
3399
+ if (props.disabled) {
3400
+ isDragThis.value = false;
3401
+ return;
3402
+ }
2547
3403
  const { point } = params;
2548
3404
  if (isDragThis.value) {
2549
3405
  handleMove(point);
@@ -2597,7 +3453,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2597
3453
  class: "hv-draggable__clone-item",
2598
3454
  style: vue.normalizeStyle(cloneNodeStyle.value)
2599
3455
  }, [
2600
- vue.renderSlot(_ctx.$slots, "hv-drag-item", {}, () => [
3456
+ vue.renderSlot(_ctx.$slots, "drag-item", {}, () => [
2601
3457
  vue.renderSlot(_ctx.$slots, "default", {}, void 0, true)
2602
3458
  ], true)
2603
3459
  ], 4)) : vue.createCommentVNode("", true)
@@ -2605,21 +3461,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2605
3461
  };
2606
3462
  }
2607
3463
  });
2608
- const _export_sfc = (sfc, props) => {
2609
- const target = sfc.__vccOpts || sfc;
2610
- for (const [key, val] of props) {
2611
- target[key] = val;
2612
- }
2613
- return target;
2614
- };
2615
- const Draggable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-e9c66d0f"]]);
2616
- const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
3464
+ const Draggable = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-695472bf"]]);
3465
+ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
2617
3466
  ...{
2618
3467
  name: "HvDroppable"
2619
3468
  },
2620
3469
  __name: "Droppable",
2621
3470
  props: {
2622
- acceptDragType: {}
3471
+ acceptDragType: {},
3472
+ disabled: { type: Boolean }
2623
3473
  },
2624
3474
  emits: ["enter", "move", "drop", "leave"],
2625
3475
  setup(__props, { emit: __emit }) {
@@ -2653,6 +3503,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2653
3503
  };
2654
3504
  }
2655
3505
  const onMove = (params) => {
3506
+ if (props.disabled) {
3507
+ isEntered.value = false;
3508
+ return;
3509
+ }
2656
3510
  const { type, data, point } = params;
2657
3511
  if (dropAreaRef.value && acceptDragTypeList.value.includes(type)) {
2658
3512
  const { isInArea, position } = getPositionInArea(point);
@@ -2670,10 +3524,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2670
3524
  }
2671
3525
  };
2672
3526
  const onEnd = ({ type, point, data }) => {
2673
- if (dropAreaRef.value && acceptDragTypeList.value.includes(type) && isEntered.value) {
3527
+ if (!props.disabled && dropAreaRef.value && acceptDragTypeList.value.includes(type) && isEntered.value) {
2674
3528
  const { position } = getPositionInArea(point);
2675
3529
  emits("drop", type, position, data);
2676
3530
  }
3531
+ isEntered.value = false;
2677
3532
  };
2678
3533
  vue.onMounted(() => {
2679
3534
  DnDManagerInstance.on("move", onMove);
@@ -2695,7 +3550,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2695
3550
  }
2696
3551
  });
2697
3552
  const HvDraggable = withInstall(Draggable);
2698
- const HvDroppable = withInstall(_sfc_main$1);
3553
+ const HvDroppable = withInstall(_sfc_main$2);
2699
3554
  function useDragAndScale(target, operateTarget, options) {
2700
3555
  const _options = vue.computed(() => {
2701
3556
  return vue.isRef(options) ? vue.toValue(options) : options;
@@ -3060,28 +3915,34 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3060
3915
  x: clientX,
3061
3916
  y: clientY
3062
3917
  });
3063
- document.body.addEventListener("touchcancel", onTouchEnd, { capture: true });
3064
- document.body.addEventListener("touchmove", onTouchMove, { capture: true });
3065
- document.body.addEventListener("touchend", onTouchEnd, { capture: true });
3918
+ document.body.addEventListener("touchcancel", onTouchEnd);
3919
+ document.body.addEventListener("touchmove", onTouchMove);
3920
+ document.body.addEventListener("touchend", onTouchEnd);
3066
3921
  }
3922
+ let touchmoveRafId = null;
3067
3923
  function onTouchMove(e) {
3068
- if (_disabled.value || isOperateStart !== true) {
3069
- isOperateStart = false;
3070
- return;
3071
- }
3072
- e.preventDefault();
3073
- e.stopPropagation();
3074
- if (e.touches.length > 1) {
3075
- onEnd();
3076
- return;
3077
- }
3078
- const { clientX, clientY } = e.touches[0];
3079
- if (clientX === startPoint.x && clientY === startPoint.y) {
3080
- return;
3924
+ if (touchmoveRafId) {
3925
+ cancelAnimationFrame(touchmoveRafId);
3081
3926
  }
3082
- onMove({
3083
- x: clientX,
3084
- y: clientY
3927
+ touchmoveRafId = requestAnimationFrame(() => {
3928
+ if (_disabled.value || isOperateStart !== true) {
3929
+ isOperateStart = false;
3930
+ return;
3931
+ }
3932
+ e.preventDefault();
3933
+ e.stopPropagation();
3934
+ if (e.touches.length > 1) {
3935
+ onEnd();
3936
+ return;
3937
+ }
3938
+ const { clientX, clientY } = e.touches[0];
3939
+ if (clientX === startPoint.x && clientY === startPoint.y) {
3940
+ return;
3941
+ }
3942
+ onMove({
3943
+ x: clientX,
3944
+ y: clientY
3945
+ });
3085
3946
  });
3086
3947
  }
3087
3948
  function onTouchEnd() {
@@ -3093,7 +3954,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3093
3954
  isMoved = false;
3094
3955
  return;
3095
3956
  }
3096
- onEnd();
3957
+ requestAnimationFrame(() => onEnd());
3097
3958
  }
3098
3959
  function onMouseDown(e) {
3099
3960
  e.preventDefault();
@@ -3105,23 +3966,29 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3105
3966
  x: clientX,
3106
3967
  y: clientY
3107
3968
  });
3108
- document.body.addEventListener("mousemove", onMouseMove, { capture: true });
3109
- document.body.addEventListener("mouseup", onMouseUp, { capture: true });
3969
+ document.body.addEventListener("mousemove", onMouseMove);
3970
+ document.body.addEventListener("mouseup", onMouseUp);
3110
3971
  }
3972
+ let mousemoveRafId = null;
3111
3973
  function onMouseMove(e) {
3112
- if (_disabled.value || isOperateStart !== true) {
3113
- isOperateStart = false;
3114
- return;
3974
+ if (mousemoveRafId) {
3975
+ cancelAnimationFrame(mousemoveRafId);
3115
3976
  }
3116
- e.preventDefault();
3117
- if ((e.buttons & 1) === 0) {
3118
- onEnd();
3119
- return;
3120
- }
3121
- const { clientX, clientY } = e;
3122
- onMove({
3123
- x: clientX,
3124
- y: clientY
3977
+ mousemoveRafId = requestAnimationFrame(() => {
3978
+ if (_disabled.value || isOperateStart !== true) {
3979
+ isOperateStart = false;
3980
+ return;
3981
+ }
3982
+ e.preventDefault();
3983
+ if ((e.buttons & 1) === 0) {
3984
+ onEnd();
3985
+ return;
3986
+ }
3987
+ const { clientX, clientY } = e;
3988
+ onMove({
3989
+ x: clientX,
3990
+ y: clientY
3991
+ });
3125
3992
  });
3126
3993
  }
3127
3994
  function onMouseUp() {
@@ -3131,11 +3998,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3131
3998
  isOperateStart = false;
3132
3999
  return;
3133
4000
  }
3134
- onEnd();
4001
+ requestAnimationFrame(() => onEnd());
3135
4002
  }
3136
4003
  function bindEvent() {
3137
4004
  removeEvent();
3138
- _operateEl.value.addEventListener("touchstart", onTouchStart, { capture: true });
4005
+ _operateEl.value.addEventListener("touchstart", onTouchStart);
3139
4006
  _operateEl.value.addEventListener("mousedown", onMouseDown);
3140
4007
  }
3141
4008
  function removeEvent() {
@@ -3152,8 +4019,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3152
4019
  removeEvent();
3153
4020
  });
3154
4021
  }
3155
- const _hoisted_1 = { class: "hv-drag-and-scale__zoom-mark" };
3156
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
4022
+ const _hoisted_1$1 = { class: "hv-drag-and-scale__zoom-mark" };
4023
+ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
3157
4024
  ...{
3158
4025
  name: "HvDragAndScale"
3159
4026
  },
@@ -3196,7 +4063,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3196
4063
  ref: targetRef
3197
4064
  }, [
3198
4065
  vue.renderSlot(_ctx.$slots, "default"),
3199
- vue.createElementVNode("div", _hoisted_1, [
4066
+ vue.createElementVNode("div", _hoisted_1$1, [
3200
4067
  vue.createElementVNode("div", {
3201
4068
  class: vue.normalizeClass(["hv-drag-and-scale__area-box", props.disabled ? "disabled" : ""]),
3202
4069
  ref_key: "operateRef",
@@ -3209,10 +4076,165 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3209
4076
  };
3210
4077
  }
3211
4078
  });
3212
- const HvDragAndScale = withInstall(_sfc_main);
4079
+ const HvDragAndScale = withInstall(_sfc_main$1);
4080
+ function getValidIPItemValue(val) {
4081
+ const num = parseInt(val + "");
4082
+ return isNaN(num) ? "" : num < 0 ? "0" : num > 255 ? "255" : num + "";
4083
+ }
4084
+ function getRange(el) {
4085
+ const ret = {
4086
+ begin: null,
4087
+ end: null,
4088
+ result: null
4089
+ };
4090
+ ret.begin = el.selectionStart || 0;
4091
+ ret.end = el.selectionEnd || 0;
4092
+ ret.result = el.value.substring(ret.begin, ret.end);
4093
+ el.focus();
4094
+ return ret;
4095
+ }
4096
+ const _hoisted_1 = ["value", "disabled", "onInput", "onKeydown", "onPaste"];
4097
+ const _hoisted_2 = { key: 0 };
4098
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
4099
+ ...{
4100
+ name: "HvIpInput"
4101
+ },
4102
+ __name: "IpInput",
4103
+ props: {
4104
+ modelValue: { default: "..." },
4105
+ disabled: { type: Boolean, default: false }
4106
+ },
4107
+ emits: ["update:model-value"],
4108
+ setup(__props, { emit: __emit }) {
4109
+ const emits = __emit;
4110
+ const props = __props;
4111
+ const inputRefs = vue.ref([]);
4112
+ const values = vue.ref([]);
4113
+ vue.watch(
4114
+ () => props.modelValue,
4115
+ (value) => {
4116
+ value = value + "";
4117
+ const strs = value.split(".");
4118
+ values.value = Array(4).fill("").map((_, i) => {
4119
+ return getValidIPItemValue(strs[i] + "");
4120
+ });
4121
+ },
4122
+ {
4123
+ immediate: true
4124
+ }
4125
+ );
4126
+ function onIPChange() {
4127
+ const ip = values.value.map((val) => getValidIPItemValue(val)).join(".");
4128
+ return emits("update:model-value", ip);
4129
+ }
4130
+ function handleChange(e, i) {
4131
+ var _a;
4132
+ if (props.disabled) {
4133
+ return;
4134
+ }
4135
+ const curValue = e.target.value;
4136
+ const num = getValidIPItemValue(curValue);
4137
+ values.value[i] = num;
4138
+ e.target.value = num;
4139
+ onIPChange();
4140
+ if (num === "") {
4141
+ return e.preventDefault();
4142
+ }
4143
+ if (String(num).length === 3 && i < 3) {
4144
+ (_a = inputRefs.value[i + 1]) == null ? void 0 : _a.focus();
4145
+ }
4146
+ }
4147
+ function handleKeyDown(e, i) {
4148
+ let domId = i;
4149
+ const { end } = getRange(e.target);
4150
+ switch (e.keyCode) {
4151
+ case 37:
4152
+ case 8: {
4153
+ if (end === 0 && i > 0) {
4154
+ domId = i - 1;
4155
+ }
4156
+ break;
4157
+ }
4158
+ case 39: {
4159
+ if (end === e.target.value.length && i < 3) {
4160
+ domId = i + 1;
4161
+ }
4162
+ break;
4163
+ }
4164
+ case 110:
4165
+ case 190: {
4166
+ e.preventDefault();
4167
+ if (i < 3) {
4168
+ domId = i + 1;
4169
+ }
4170
+ break;
4171
+ }
4172
+ }
4173
+ const inputEl = inputRefs.value[domId];
4174
+ inputEl.focus();
4175
+ if (domId < i) {
4176
+ const len = inputEl.value.length;
4177
+ inputEl.selectionStart = inputEl.selectionEnd = len;
4178
+ } else if (domId > i) {
4179
+ inputEl.selectionStart = inputEl.selectionEnd = 0;
4180
+ }
4181
+ }
4182
+ function handlePaste(e, i) {
4183
+ if (!e.clipboardData || !e.clipboardData.getData) {
4184
+ return;
4185
+ }
4186
+ const pasteData = e.clipboardData.getData("text/plain");
4187
+ if (!pasteData) {
4188
+ return;
4189
+ }
4190
+ const value = pasteData.split(".").map((v) => getValidIPItemValue(v));
4191
+ if (value.length !== 4 - i) {
4192
+ return;
4193
+ }
4194
+ if (!value.every((item) => item !== "")) {
4195
+ return;
4196
+ }
4197
+ value.forEach((val, j) => {
4198
+ values.value[i + j] = val + "";
4199
+ });
4200
+ onIPChange();
4201
+ return e.preventDefault();
4202
+ }
4203
+ return (_ctx, _cache) => {
4204
+ return vue.openBlock(), vue.createElementBlock("div", {
4205
+ class: vue.normalizeClass(["hv-ip-input", props.disabled ? "is-disabled" : ""])
4206
+ }, [
4207
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(values.value, (value, i) => {
4208
+ return vue.openBlock(), vue.createElementBlock("div", {
4209
+ class: "hv-ip-input-item",
4210
+ key: i
4211
+ }, [
4212
+ vue.createElementVNode("input", {
4213
+ ref_for: true,
4214
+ ref_key: "inputRefs",
4215
+ ref: inputRefs,
4216
+ type: "text",
4217
+ value,
4218
+ disabled: props.disabled,
4219
+ onInput: (e) => handleChange(e, i),
4220
+ onKeydown: (e) => handleKeyDown(e, i),
4221
+ onPaste: (e) => handlePaste(e, i)
4222
+ }, null, 40, _hoisted_1),
4223
+ i !== 3 ? (vue.openBlock(), vue.createElementBlock("i", _hoisted_2, ".")) : vue.createCommentVNode("", true)
4224
+ ]);
4225
+ }), 128))
4226
+ ], 2);
4227
+ };
4228
+ }
4229
+ });
4230
+ const HvIpInput = withInstall(_sfc_main);
4231
+ exports2.DEFAULT_COLOR = DEFAULT_COLOR;
3213
4232
  exports2.HvColorPicker = HvColorPicker;
4233
+ exports2.HvColorPickerNormal = HvColorPickerNormal;
4234
+ exports2.HvColorPickerRainbow = HvColorPickerRainbow;
3214
4235
  exports2.HvDragAndScale = HvDragAndScale;
3215
4236
  exports2.HvDraggable = HvDraggable;
3216
4237
  exports2.HvDroppable = HvDroppable;
4238
+ exports2.HvIpInput = HvIpInput;
3217
4239
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
3218
4240
  });