@havue/components 1.1.2 → 1.2.0

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 +1096 -97
  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,96 @@ 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,
1924
1944
  step: 1,
1925
1945
  controls: false
1926
- }, null, 8, ["modelValue"]),
1946
+ }, null, 8, ["modelValue", "disabled"]),
1927
1947
  vue.createVNode(_component_el_input_number, {
1928
1948
  modelValue: formInputRGB.g,
1929
1949
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => formInputRGB.g = $event),
1950
+ disabled: props.disabled,
1930
1951
  onChange: handleRgbColorChange,
1931
1952
  "step-strictly": "",
1932
1953
  min: 0,
1933
1954
  max: 255,
1934
1955
  step: 1,
1935
1956
  controls: false
1936
- }, null, 8, ["modelValue"]),
1957
+ }, null, 8, ["modelValue", "disabled"]),
1937
1958
  vue.createVNode(_component_el_input_number, {
1938
1959
  modelValue: formInputRGB.b,
1939
1960
  "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => formInputRGB.b = $event),
1961
+ disabled: props.disabled,
1940
1962
  onChange: handleRgbColorChange,
1941
1963
  "step-strictly": "",
1942
1964
  min: 0,
1943
1965
  max: 255,
1944
1966
  step: 1,
1945
1967
  controls: false
1946
- }, null, 8, ["modelValue"])
1968
+ }, null, 8, ["modelValue", "disabled"])
1947
1969
  ]),
1948
- vue.createElementVNode("div", _hoisted_4$2, [
1970
+ vue.createElementVNode("div", _hoisted_4$3, [
1949
1971
  _cache[8] || (_cache[8] = vue.createElementVNode("div", { class: "hv-color-picker__form-label" }, "HSV", -1)),
1950
1972
  vue.createVNode(_component_el_input_number, {
1951
1973
  modelValue: formInputHSV.h,
1952
1974
  "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => formInputHSV.h = $event),
1975
+ disabled: props.disabled,
1953
1976
  onChange: handleHsvColorChange,
1954
1977
  min: 0,
1955
1978
  max: 360,
1956
1979
  "step-strictly": "",
1957
1980
  step: 1,
1958
1981
  controls: false
1959
- }, null, 8, ["modelValue"]),
1982
+ }, null, 8, ["modelValue", "disabled"]),
1960
1983
  vue.createVNode(_component_el_input_number, {
1961
1984
  modelValue: formInputHSV.s,
1962
1985
  "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => formInputHSV.s = $event),
1986
+ disabled: props.disabled,
1963
1987
  onChange: handleHsvColorChange,
1964
1988
  min: 0,
1965
1989
  max: 100,
1966
1990
  "step-strictly": "",
1967
1991
  step: 1,
1968
1992
  controls: false
1969
- }, null, 8, ["modelValue"]),
1993
+ }, null, 8, ["modelValue", "disabled"]),
1970
1994
  vue.createVNode(_component_el_input_number, {
1971
1995
  modelValue: formInputHSV.v,
1972
1996
  "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => formInputHSV.v = $event),
1997
+ disabled: props.disabled,
1973
1998
  onChange: handleHsvColorChange,
1974
1999
  "step-strictly": "",
1975
2000
  min: 0,
1976
2001
  max: 100,
1977
2002
  controls: false
1978
- }, null, 8, ["modelValue"])
2003
+ }, null, 8, ["modelValue", "disabled"])
1979
2004
  ])
1980
2005
  ]);
1981
2006
  };
1982
2007
  }
1983
2008
  });
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({
2009
+ const _hoisted_1$6 = { class: "hv-color-picker__preset" };
2010
+ const _hoisted_2$5 = { class: "hv-color-picker__preset-title" };
2011
+ const _hoisted_3$4 = { class: "hv-color-picker__preset-list" };
2012
+ const _hoisted_4$2 = ["onClick"];
2013
+ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
1989
2014
  __name: "PresetColors",
1990
2015
  props: {
1991
2016
  title: {},
@@ -2024,50 +2049,53 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2024
2049
  emits("change", color2);
2025
2050
  }
2026
2051
  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, [
2052
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
2053
+ vue.createElementVNode("div", _hoisted_2$5, vue.toDisplayString(props.title || "Preset colors"), 1),
2054
+ vue.createElementVNode("div", _hoisted_3$4, [
2030
2055
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(preColors.value, (color2) => {
2031
2056
  return vue.openBlock(), vue.createElementBlock("div", {
2032
2057
  class: "hv-color-picker__preset-list-item",
2033
2058
  onClick: ($event) => handleClickColor(color2),
2034
2059
  key: color2,
2035
2060
  style: vue.normalizeStyle({ backgroundColor: color2 })
2036
- }, null, 12, _hoisted_4$1);
2061
+ }, null, 12, _hoisted_4$2);
2037
2062
  }), 128))
2038
2063
  ])
2039
2064
  ]);
2040
2065
  };
2041
2066
  }
2042
2067
  });
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({
2068
+ const _hoisted_1$5 = { class: "hv-color-picker" };
2069
+ const _hoisted_2$4 = { class: "hv-color-picker__title" };
2070
+ const _hoisted_3$3 = { class: "hv-color-picker__area-outer" };
2071
+ const _hoisted_4$1 = { class: "hv-color-picker__slider" };
2072
+ const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
2049
2073
  ...{
2050
2074
  name: "HvColorPicker"
2051
2075
  },
2052
2076
  __name: "ColorPicker",
2053
- props: /* @__PURE__ */ vue.mergeModels({
2077
+ props: {
2078
+ modelValue: { default: DEFAULT_COLOR },
2079
+ disabled: { type: Boolean },
2054
2080
  title: {},
2055
2081
  presetTitle: {},
2056
2082
  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"]),
2083
+ },
2084
+ emits: ["update:model-value"],
2065
2085
  setup(__props, { emit: __emit }) {
2066
2086
  const props = __props;
2067
2087
  const emits = __emit;
2088
+ const isDisabled = vue.computed(() => props.disabled);
2068
2089
  const { colorAreaCanvas, getColorByCoordinate, getCoordinateByColor, canvasWidth, canvasHeight } = useColorArea();
2069
- const { colorAreaRef, circlePickerCoordinate, setCirclePickerCoordinate } = useOperateEvent();
2070
- const color2 = vue.useModel(__props, "modelValue");
2090
+ const { colorAreaRef, circlePickerCoordinate, setCirclePickerCoordinate } = useOperateEvent({ disabled: isDisabled });
2091
+ const color2 = vue.computed({
2092
+ get() {
2093
+ return props.modelValue;
2094
+ },
2095
+ set(value) {
2096
+ emits("update:model-value", value);
2097
+ }
2098
+ });
2071
2099
  const lightColor = vue.ref(Color$1(DEFAULT_COLOR));
2072
2100
  const colorDepth = vue.ref(100);
2073
2101
  const originHexColor = vue.computed(() => {
@@ -2130,6 +2158,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2130
2158
  }
2131
2159
  );
2132
2160
  function handleColorChange(hex) {
2161
+ if (props.disabled) {
2162
+ return;
2163
+ }
2133
2164
  const color22 = hexToColor(hex);
2134
2165
  const { color: lightRgb, value: depth } = getLightColorAndDepth(color22);
2135
2166
  lightColor.value = lightRgb;
@@ -2142,11 +2173,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2142
2173
  });
2143
2174
  return (_ctx, _cache) => {
2144
2175
  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, [
2176
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, [
2177
+ vue.createElementVNode("div", _hoisted_2$4, vue.toDisplayString(props.title || "Color picker"), 1),
2178
+ vue.createElementVNode("div", _hoisted_3$3, [
2148
2179
  vue.createElementVNode("div", {
2149
- class: "hv-color-picker__area",
2180
+ class: vue.normalizeClass(["hv-color-picker__area", isDisabled.value ? "is-disabled" : ""]),
2150
2181
  ref_key: "colorAreaRef",
2151
2182
  ref: colorAreaRef
2152
2183
  }, [
@@ -2158,27 +2189,839 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2158
2189
  class: "hv-color-picker__circle",
2159
2190
  style: vue.normalizeStyle(cilcleStyle.value)
2160
2191
  }, null, 4)
2161
- ], 512)
2192
+ ], 2)
2162
2193
  ]),
2163
- vue.createElementVNode("div", _hoisted_4, [
2194
+ vue.createElementVNode("div", _hoisted_4$1, [
2164
2195
  vue.createVNode(_component_ElSlider, {
2165
2196
  modelValue: colorDepth.value,
2166
2197
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => colorDepth.value = $event),
2198
+ disabled: props.disabled,
2167
2199
  min: 0,
2168
2200
  max: 100,
2169
2201
  "show-tooltip": false,
2170
2202
  style: vue.normalizeStyle(sliderBackStyle.value)
2171
- }, null, 8, ["modelValue", "style"]),
2203
+ }, null, 8, ["modelValue", "disabled", "style"]),
2172
2204
  vue.createElementVNode("div", {
2173
2205
  class: "hv-color-picker__origin-color",
2174
2206
  style: vue.normalizeStyle({ backgroundColor: originHexColor.value })
2175
2207
  }, null, 4)
2176
2208
  ]),
2177
- vue.createVNode(_sfc_main$5, {
2209
+ vue.createVNode(_sfc_main$a, {
2178
2210
  "model-value": color2.value,
2211
+ disabled: props.disabled,
2179
2212
  onChange: handleColorChange
2180
- }, null, 8, ["model-value"]),
2181
- vue.createVNode(_sfc_main$4, {
2213
+ }, null, 8, ["model-value", "disabled"]),
2214
+ vue.createVNode(_sfc_main$9, {
2215
+ onChange: handleColorChange,
2216
+ title: props.presetTitle,
2217
+ presetColors: props.presetColors
2218
+ }, null, 8, ["title", "presetColors"])
2219
+ ]);
2220
+ };
2221
+ }
2222
+ });
2223
+ function isObject$3(value) {
2224
+ var type = typeof value;
2225
+ return value != null && (type == "object" || type == "function");
2226
+ }
2227
+ var isObject_1 = isObject$3;
2228
+ var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
2229
+ var _freeGlobal = freeGlobal$1;
2230
+ var freeGlobal = _freeGlobal;
2231
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
2232
+ var root$2 = freeGlobal || freeSelf || Function("return this")();
2233
+ var _root = root$2;
2234
+ var root$1 = _root;
2235
+ var now$1 = function() {
2236
+ return root$1.Date.now();
2237
+ };
2238
+ var now_1 = now$1;
2239
+ var reWhitespace = /\s/;
2240
+ function trimmedEndIndex$1(string) {
2241
+ var index = string.length;
2242
+ while (index-- && reWhitespace.test(string.charAt(index))) {
2243
+ }
2244
+ return index;
2245
+ }
2246
+ var _trimmedEndIndex = trimmedEndIndex$1;
2247
+ var trimmedEndIndex = _trimmedEndIndex;
2248
+ var reTrimStart = /^\s+/;
2249
+ function baseTrim$1(string) {
2250
+ return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
2251
+ }
2252
+ var _baseTrim = baseTrim$1;
2253
+ var root = _root;
2254
+ var Symbol$3 = root.Symbol;
2255
+ var _Symbol = Symbol$3;
2256
+ var Symbol$2 = _Symbol;
2257
+ var objectProto$1 = Object.prototype;
2258
+ var hasOwnProperty = objectProto$1.hasOwnProperty;
2259
+ var nativeObjectToString$1 = objectProto$1.toString;
2260
+ var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : void 0;
2261
+ function getRawTag$1(value) {
2262
+ var isOwn = hasOwnProperty.call(value, symToStringTag$1), tag = value[symToStringTag$1];
2263
+ try {
2264
+ value[symToStringTag$1] = void 0;
2265
+ var unmasked = true;
2266
+ } catch (e) {
2267
+ }
2268
+ var result = nativeObjectToString$1.call(value);
2269
+ if (unmasked) {
2270
+ if (isOwn) {
2271
+ value[symToStringTag$1] = tag;
2272
+ } else {
2273
+ delete value[symToStringTag$1];
2274
+ }
2275
+ }
2276
+ return result;
2277
+ }
2278
+ var _getRawTag = getRawTag$1;
2279
+ var objectProto = Object.prototype;
2280
+ var nativeObjectToString = objectProto.toString;
2281
+ function objectToString$1(value) {
2282
+ return nativeObjectToString.call(value);
2283
+ }
2284
+ var _objectToString = objectToString$1;
2285
+ var Symbol$1 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
2286
+ var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
2287
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
2288
+ function baseGetTag$1(value) {
2289
+ if (value == null) {
2290
+ return value === void 0 ? undefinedTag : nullTag;
2291
+ }
2292
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
2293
+ }
2294
+ var _baseGetTag = baseGetTag$1;
2295
+ function isObjectLike$1(value) {
2296
+ return value != null && typeof value == "object";
2297
+ }
2298
+ var isObjectLike_1 = isObjectLike$1;
2299
+ var baseGetTag = _baseGetTag, isObjectLike = isObjectLike_1;
2300
+ var symbolTag = "[object Symbol]";
2301
+ function isSymbol$1(value) {
2302
+ return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
2303
+ }
2304
+ var isSymbol_1 = isSymbol$1;
2305
+ var baseTrim = _baseTrim, isObject$2 = isObject_1, isSymbol = isSymbol_1;
2306
+ var NAN = 0 / 0;
2307
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
2308
+ var reIsBinary = /^0b[01]+$/i;
2309
+ var reIsOctal = /^0o[0-7]+$/i;
2310
+ var freeParseInt = parseInt;
2311
+ function toNumber$1(value) {
2312
+ if (typeof value == "number") {
2313
+ return value;
2314
+ }
2315
+ if (isSymbol(value)) {
2316
+ return NAN;
2317
+ }
2318
+ if (isObject$2(value)) {
2319
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
2320
+ value = isObject$2(other) ? other + "" : other;
2321
+ }
2322
+ if (typeof value != "string") {
2323
+ return value === 0 ? value : +value;
2324
+ }
2325
+ value = baseTrim(value);
2326
+ var isBinary = reIsBinary.test(value);
2327
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
2328
+ }
2329
+ var toNumber_1 = toNumber$1;
2330
+ var isObject$1 = isObject_1, now = now_1, toNumber = toNumber_1;
2331
+ var FUNC_ERROR_TEXT$1 = "Expected a function";
2332
+ var nativeMax = Math.max, nativeMin = Math.min;
2333
+ function debounce$1(func, wait, options) {
2334
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
2335
+ if (typeof func != "function") {
2336
+ throw new TypeError(FUNC_ERROR_TEXT$1);
2337
+ }
2338
+ wait = toNumber(wait) || 0;
2339
+ if (isObject$1(options)) {
2340
+ leading = !!options.leading;
2341
+ maxing = "maxWait" in options;
2342
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
2343
+ trailing = "trailing" in options ? !!options.trailing : trailing;
2344
+ }
2345
+ function invokeFunc(time) {
2346
+ var args = lastArgs, thisArg = lastThis;
2347
+ lastArgs = lastThis = void 0;
2348
+ lastInvokeTime = time;
2349
+ result = func.apply(thisArg, args);
2350
+ return result;
2351
+ }
2352
+ function leadingEdge(time) {
2353
+ lastInvokeTime = time;
2354
+ timerId = setTimeout(timerExpired, wait);
2355
+ return leading ? invokeFunc(time) : result;
2356
+ }
2357
+ function remainingWait(time) {
2358
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
2359
+ return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
2360
+ }
2361
+ function shouldInvoke(time) {
2362
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
2363
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
2364
+ }
2365
+ function timerExpired() {
2366
+ var time = now();
2367
+ if (shouldInvoke(time)) {
2368
+ return trailingEdge(time);
2369
+ }
2370
+ timerId = setTimeout(timerExpired, remainingWait(time));
2371
+ }
2372
+ function trailingEdge(time) {
2373
+ timerId = void 0;
2374
+ if (trailing && lastArgs) {
2375
+ return invokeFunc(time);
2376
+ }
2377
+ lastArgs = lastThis = void 0;
2378
+ return result;
2379
+ }
2380
+ function cancel() {
2381
+ if (timerId !== void 0) {
2382
+ clearTimeout(timerId);
2383
+ }
2384
+ lastInvokeTime = 0;
2385
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
2386
+ }
2387
+ function flush() {
2388
+ return timerId === void 0 ? result : trailingEdge(now());
2389
+ }
2390
+ function debounced() {
2391
+ var time = now(), isInvoking = shouldInvoke(time);
2392
+ lastArgs = arguments;
2393
+ lastThis = this;
2394
+ lastCallTime = time;
2395
+ if (isInvoking) {
2396
+ if (timerId === void 0) {
2397
+ return leadingEdge(lastCallTime);
2398
+ }
2399
+ if (maxing) {
2400
+ clearTimeout(timerId);
2401
+ timerId = setTimeout(timerExpired, wait);
2402
+ return invokeFunc(lastCallTime);
2403
+ }
2404
+ }
2405
+ if (timerId === void 0) {
2406
+ timerId = setTimeout(timerExpired, wait);
2407
+ }
2408
+ return result;
2409
+ }
2410
+ debounced.cancel = cancel;
2411
+ debounced.flush = flush;
2412
+ return debounced;
2413
+ }
2414
+ var debounce_1 = debounce$1;
2415
+ var debounce = debounce_1, isObject = isObject_1;
2416
+ var FUNC_ERROR_TEXT = "Expected a function";
2417
+ function throttle(func, wait, options) {
2418
+ var leading = true, trailing = true;
2419
+ if (typeof func != "function") {
2420
+ throw new TypeError(FUNC_ERROR_TEXT);
2421
+ }
2422
+ if (isObject(options)) {
2423
+ leading = "leading" in options ? !!options.leading : leading;
2424
+ trailing = "trailing" in options ? !!options.trailing : trailing;
2425
+ }
2426
+ return debounce(func, wait, {
2427
+ "leading": leading,
2428
+ "maxWait": wait,
2429
+ "trailing": trailing
2430
+ });
2431
+ }
2432
+ var throttle_1 = throttle;
2433
+ const throttle$1 = /* @__PURE__ */ getDefaultExportFromCjs(throttle_1);
2434
+ let lastPoint = {
2435
+ x: void 0,
2436
+ y: void 0
2437
+ };
2438
+ function useInteraction(disabled) {
2439
+ const colorAreaRef = vue.ref();
2440
+ const circlePickerCoordinate = vue.reactive({
2441
+ x: 100,
2442
+ y: 100
2443
+ });
2444
+ function handleTouchStart(e) {
2445
+ if (disabled.value) {
2446
+ return;
2447
+ }
2448
+ if (e.touches.length === 0) {
2449
+ return;
2450
+ }
2451
+ e.preventDefault();
2452
+ const { clientX, clientY } = e.touches[0];
2453
+ handleCirclePickerCoordinateChange({
2454
+ x: clientX,
2455
+ y: clientY
2456
+ });
2457
+ document.body.addEventListener("touchmove", handleTouchMove);
2458
+ document.body.addEventListener("touchend", handleTouchEnd);
2459
+ }
2460
+ function handleTouchMove(e) {
2461
+ if (disabled.value) {
2462
+ return;
2463
+ }
2464
+ if (e.touches.length > 1) {
2465
+ return;
2466
+ }
2467
+ const { clientX, clientY } = e.touches[0];
2468
+ handleCirclePickerCoordinateChange({
2469
+ x: clientX,
2470
+ y: clientY
2471
+ });
2472
+ }
2473
+ function handleTouchEnd() {
2474
+ document.body.removeEventListener("touchmove", handleTouchMove);
2475
+ document.body.removeEventListener("touchend", handleTouchEnd);
2476
+ }
2477
+ function handleMounseDown(e) {
2478
+ if (disabled.value) {
2479
+ return;
2480
+ }
2481
+ document.body.addEventListener("mousemove", handleMouseMove);
2482
+ document.body.addEventListener("mouseup", handleMouseUp);
2483
+ handleCirclePickerCoordinateChange({
2484
+ x: e.clientX,
2485
+ y: e.clientY
2486
+ });
2487
+ }
2488
+ function handleMouseMove(e) {
2489
+ if (disabled.value) {
2490
+ return;
2491
+ }
2492
+ if (!(e.buttons && 1)) {
2493
+ handleMouseUp();
2494
+ return;
2495
+ }
2496
+ handleCirclePickerCoordinateChange({
2497
+ x: e.clientX,
2498
+ y: e.clientY
2499
+ });
2500
+ }
2501
+ const handleCirclePickerCoordinateChange = throttle$1(handleCirclePickerCoordinateChangeFn, 20);
2502
+ function handleCirclePickerCoordinateChangeFn(point) {
2503
+ var _a;
2504
+ const { x: clientX, y: clientY } = point;
2505
+ if (lastPoint.x == point.x && lastPoint.y == point.y) {
2506
+ return;
2507
+ }
2508
+ lastPoint = point;
2509
+ const colorAreaRect = (_a = colorAreaRef.value) == null ? void 0 : _a.getBoundingClientRect();
2510
+ if (!colorAreaRect) {
2511
+ return;
2512
+ }
2513
+ const { left, top, width, height } = colorAreaRect;
2514
+ let x = 0;
2515
+ let y = 0;
2516
+ if (clientX <= left) {
2517
+ x = 0;
2518
+ } else if (clientX >= left + width) {
2519
+ x = width;
2520
+ } else {
2521
+ x = clientX - left;
2522
+ }
2523
+ if (clientY <= top) {
2524
+ y = 0;
2525
+ } else if (clientY >= top + height) {
2526
+ y = height;
2527
+ } else {
2528
+ y = clientY - top;
2529
+ }
2530
+ circlePickerCoordinate.x = x / width * 100;
2531
+ circlePickerCoordinate.y = (height - y) / height * 100;
2532
+ }
2533
+ function handleMouseUp() {
2534
+ document.body.removeEventListener("mousemove", handleMouseMove);
2535
+ document.body.removeEventListener("mouseup", handleMouseUp);
2536
+ }
2537
+ function setCirclePickerCoordinate(x, y) {
2538
+ circlePickerCoordinate.x = x;
2539
+ circlePickerCoordinate.y = y;
2540
+ }
2541
+ vue.onMounted(() => {
2542
+ var _a, _b;
2543
+ (_a = colorAreaRef.value) == null ? void 0 : _a.addEventListener("touchstart", handleTouchStart);
2544
+ (_b = colorAreaRef.value) == null ? void 0 : _b.addEventListener("mousedown", handleMounseDown);
2545
+ });
2546
+ vue.onBeforeUnmount(() => {
2547
+ var _a, _b;
2548
+ (_a = colorAreaRef.value) == null ? void 0 : _a.removeEventListener("touchstart", handleTouchStart);
2549
+ document.body.removeEventListener("touchmove", handleTouchMove);
2550
+ document.body.removeEventListener("touchend", handleTouchEnd);
2551
+ (_b = colorAreaRef.value) == null ? void 0 : _b.removeEventListener("mousedown", handleMounseDown);
2552
+ document.body.removeEventListener("mousemove", handleMouseMove);
2553
+ document.body.removeEventListener("mouseup", handleMouseUp);
2554
+ });
2555
+ return {
2556
+ colorAreaRef,
2557
+ circlePickerCoordinate,
2558
+ setCirclePickerCoordinate
2559
+ };
2560
+ }
2561
+ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
2562
+ __name: "ColorArea",
2563
+ props: {
2564
+ saturation: { default: 100 },
2565
+ value: { default: 100 },
2566
+ color: {},
2567
+ hueColor: {},
2568
+ disabled: { type: Boolean }
2569
+ },
2570
+ emits: ["update:saturation", "update:value"],
2571
+ setup(__props, { emit: __emit }) {
2572
+ const emits = __emit;
2573
+ const props = __props;
2574
+ const saturationv = vue.computed({
2575
+ get() {
2576
+ return props.saturation;
2577
+ },
2578
+ set(value2) {
2579
+ emits("update:saturation", value2);
2580
+ }
2581
+ });
2582
+ const value = vue.computed({
2583
+ get() {
2584
+ return props.value;
2585
+ },
2586
+ set(value2) {
2587
+ emits("update:value", value2);
2588
+ }
2589
+ });
2590
+ const isDisabled = vue.computed(() => {
2591
+ return props.disabled;
2592
+ });
2593
+ const { colorAreaRef, circlePickerCoordinate, setCirclePickerCoordinate } = useInteraction(isDisabled);
2594
+ const state = vue.reactive({
2595
+ hexColor: "",
2596
+ bgHexColor: ""
2597
+ });
2598
+ vue.watch(
2599
+ () => props.color,
2600
+ (c) => {
2601
+ const color2 = Color$1(c);
2602
+ state.hexColor = color2.hex();
2603
+ let { h, s, v } = color2.hsv().object();
2604
+ state.bgHexColor = Color$1({ h, s: 100, v: 100 }).hex();
2605
+ const curColor = Color$1.hsv({ h, s: circlePickerCoordinate.x, v: circlePickerCoordinate.y }).hex();
2606
+ if (curColor == color2.hex()) {
2607
+ s = circlePickerCoordinate.x;
2608
+ }
2609
+ setCirclePickerCoordinate(s, v);
2610
+ },
2611
+ {
2612
+ immediate: true
2613
+ }
2614
+ );
2615
+ vue.watch(
2616
+ circlePickerCoordinate,
2617
+ (val) => {
2618
+ saturationv.value = val.x;
2619
+ value.value = val.y;
2620
+ },
2621
+ {
2622
+ deep: true
2623
+ }
2624
+ );
2625
+ return (_ctx, _cache) => {
2626
+ return vue.openBlock(), vue.createElementBlock("div", {
2627
+ ref_key: "colorAreaRef",
2628
+ ref: colorAreaRef,
2629
+ class: "hv-color-picker__color-area-outer"
2630
+ }, [
2631
+ vue.createElementVNode("div", {
2632
+ class: "hv-color-picker__color-area",
2633
+ style: vue.normalizeStyle({ backgroundColor: props.hueColor })
2634
+ }, [
2635
+ vue.createElementVNode("div", {
2636
+ class: "hv-color-picker__circle",
2637
+ style: vue.normalizeStyle({
2638
+ backgroundColor: state.hexColor,
2639
+ left: `${vue.unref(circlePickerCoordinate).x}%`,
2640
+ bottom: `${vue.unref(circlePickerCoordinate).y}%`
2641
+ })
2642
+ }, null, 4)
2643
+ ], 4)
2644
+ ], 512);
2645
+ };
2646
+ }
2647
+ });
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
+ const _hoisted_1$4 = { class: "hv-color_picker__form mb-12" };
2657
+ const _hoisted_2$3 = { class: "hv-color-picker__form-type" };
2658
+ const _hoisted_3$2 = { class: "hv-color-picker__form-body" };
2659
+ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
2660
+ ...{
2661
+ name: "HvColorPickerNormal"
2662
+ },
2663
+ __name: "ColorForm",
2664
+ props: {
2665
+ modelValue: {},
2666
+ disabled: { type: Boolean },
2667
+ enableAlpha: { type: Boolean }
2668
+ },
2669
+ emits: ["update:modelValue"],
2670
+ setup(__props, { emit: __emit }) {
2671
+ const SelectOptions = ["RGB", "HSL", "HSV"];
2672
+ const props = __props;
2673
+ const emits = __emit;
2674
+ const formType = vue.ref("RGB");
2675
+ const formInputState = vue.ref([255, 255, 255, 100]);
2676
+ const isRGB = vue.computed(() => {
2677
+ return formType.value === "RGB";
2678
+ });
2679
+ vue.watch(
2680
+ () => props.modelValue,
2681
+ () => {
2682
+ handleFormTypeChange();
2683
+ },
2684
+ {
2685
+ immediate: true
2686
+ }
2687
+ );
2688
+ function handleFormTypeChange() {
2689
+ const color2 = Color$1(props.modelValue);
2690
+ const alpha = color2.alpha() * 100;
2691
+ switch (formType.value) {
2692
+ case "RGB": {
2693
+ const arr = color2.rgb().array();
2694
+ formInputState.value = [...arr.slice(0, 3), alpha];
2695
+ break;
2696
+ }
2697
+ case "HSL": {
2698
+ const arr = color2.hsl().array();
2699
+ formInputState.value = [...arr.slice(0, 3), alpha];
2700
+ break;
2701
+ }
2702
+ case "HSV": {
2703
+ const arr = color2.hsv().array();
2704
+ formInputState.value = [...arr.slice(0, 3), alpha];
2705
+ break;
2706
+ }
2707
+ }
2708
+ }
2709
+ function handleColorChange() {
2710
+ let color2 = Color$1(DEFAULT_COLOR);
2711
+ switch (formType.value) {
2712
+ case "RGB": {
2713
+ color2 = Color$1.rgb(...formInputState.value.slice(0, 3));
2714
+ break;
2715
+ }
2716
+ case "HSL": {
2717
+ color2 = Color$1.hsl(...formInputState.value.slice(0, 3));
2718
+ break;
2719
+ }
2720
+ case "HSV": {
2721
+ color2 = Color$1.hsv(...formInputState.value.slice(0, 3));
2722
+ break;
2723
+ }
2724
+ }
2725
+ emits("update:modelValue", color2.alpha(props.enableAlpha ? formInputState.value[3] / 100 : 1).hexa());
2726
+ }
2727
+ return (_ctx, _cache) => {
2728
+ const _component_el_option = vue.resolveComponent("el-option");
2729
+ const _component_el_select = vue.resolveComponent("el-select");
2730
+ const _component_el_input_number = vue.resolveComponent("el-input-number");
2731
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
2732
+ vue.createElementVNode("div", _hoisted_2$3, [
2733
+ vue.createVNode(_component_el_select, {
2734
+ modelValue: formType.value,
2735
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formType.value = $event),
2736
+ disabled: props.disabled,
2737
+ "popper-class": "hv-color-picker-popper",
2738
+ onChange: handleFormTypeChange,
2739
+ teleported: false
2740
+ }, {
2741
+ default: vue.withCtx(() => [
2742
+ (vue.openBlock(), vue.createElementBlock(vue.Fragment, null, vue.renderList(SelectOptions, (item) => {
2743
+ return vue.createVNode(_component_el_option, {
2744
+ key: item,
2745
+ label: item,
2746
+ value: item
2747
+ }, null, 8, ["label", "value"]);
2748
+ }), 64))
2749
+ ]),
2750
+ _: 1
2751
+ }, 8, ["modelValue", "disabled"])
2752
+ ]),
2753
+ vue.createElementVNode("div", _hoisted_3$2, [
2754
+ vue.createVNode(_component_el_input_number, {
2755
+ modelValue: formInputState.value[0],
2756
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => formInputState.value[0] = $event),
2757
+ onChange: handleColorChange,
2758
+ "step-strictly": "",
2759
+ disabled: props.disabled,
2760
+ min: 0,
2761
+ max: isRGB.value ? 255 : 360,
2762
+ step: 1,
2763
+ controls: false
2764
+ }, null, 8, ["modelValue", "disabled", "max"]),
2765
+ vue.createVNode(_component_el_input_number, {
2766
+ modelValue: formInputState.value[1],
2767
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => formInputState.value[1] = $event),
2768
+ onChange: handleColorChange,
2769
+ "step-strictly": "",
2770
+ disabled: props.disabled,
2771
+ min: 0,
2772
+ max: isRGB.value ? 255 : 100,
2773
+ step: 1,
2774
+ controls: false
2775
+ }, null, 8, ["modelValue", "disabled", "max"]),
2776
+ vue.createVNode(_component_el_input_number, {
2777
+ modelValue: formInputState.value[2],
2778
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => formInputState.value[2] = $event),
2779
+ onChange: handleColorChange,
2780
+ "step-strictly": "",
2781
+ disabled: props.disabled,
2782
+ min: 0,
2783
+ max: isRGB.value ? 255 : 100,
2784
+ step: 1,
2785
+ controls: false
2786
+ }, null, 8, ["modelValue", "disabled", "max"]),
2787
+ props.enableAlpha ? (vue.openBlock(), vue.createBlock(_component_el_input_number, {
2788
+ key: 0,
2789
+ modelValue: formInputState.value[3],
2790
+ "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => formInputState.value[3] = $event),
2791
+ onChange: handleColorChange,
2792
+ "step-strictly": "",
2793
+ disabled: props.disabled,
2794
+ min: 0,
2795
+ max: 100,
2796
+ step: 1,
2797
+ controls: false
2798
+ }, {
2799
+ suffix: vue.withCtx(() => _cache[5] || (_cache[5] = [
2800
+ vue.createElementVNode("span", null, "%", -1)
2801
+ ])),
2802
+ _: 1
2803
+ }, 8, ["modelValue", "disabled"])) : vue.createCommentVNode("", true)
2804
+ ])
2805
+ ]);
2806
+ };
2807
+ }
2808
+ });
2809
+ const ColorForm = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-855a2e17"]]);
2810
+ const _hoisted_1$3 = { class: "hv-color-picker__preset" };
2811
+ const _hoisted_2$2 = { class: "hv-color-picker__preset-title" };
2812
+ const _hoisted_3$1 = { class: "hv-color-picker__preset-list" };
2813
+ const _hoisted_4 = ["onClick"];
2814
+ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
2815
+ __name: "PresetColors",
2816
+ props: {
2817
+ title: {},
2818
+ presetColors: {}
2819
+ },
2820
+ emits: ["change"],
2821
+ setup(__props, { emit: __emit }) {
2822
+ const defaultPresetColors = [
2823
+ "#000000",
2824
+ "#FFFFFF",
2825
+ "#E3822D",
2826
+ "#DCE24F",
2827
+ "#1DCF69",
2828
+ "#6DE5B9",
2829
+ "#11A1F2",
2830
+ "#AA43FF",
2831
+ "#F0689C",
2832
+ "#F8D28B",
2833
+ "#606368",
2834
+ "#E83C34",
2835
+ "#EEBE29",
2836
+ "#89F0AC",
2837
+ "#2FBC9E",
2838
+ "#56CCF2",
2839
+ "#1C1DFA",
2840
+ "#DC88F5",
2841
+ "#D4C595",
2842
+ "#C52F65"
2843
+ ];
2844
+ const props = __props;
2845
+ const preColors = vue.computed(() => {
2846
+ return !props.presetColors ? defaultPresetColors : props.presetColors;
2847
+ });
2848
+ const emits = __emit;
2849
+ function handleClickColor(color2) {
2850
+ emits("change", color2);
2851
+ }
2852
+ return (_ctx, _cache) => {
2853
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
2854
+ vue.createElementVNode("div", _hoisted_2$2, vue.toDisplayString(props.title || "Reset colors"), 1),
2855
+ vue.createElementVNode("div", _hoisted_3$1, [
2856
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(preColors.value, (color2) => {
2857
+ return vue.openBlock(), vue.createElementBlock("div", {
2858
+ class: "hv-color-picker__preset-list-item",
2859
+ onClick: ($event) => handleClickColor(color2),
2860
+ key: color2,
2861
+ style: vue.normalizeStyle({ backgroundColor: color2 })
2862
+ }, null, 12, _hoisted_4);
2863
+ }), 128))
2864
+ ])
2865
+ ]);
2866
+ };
2867
+ }
2868
+ });
2869
+ const PresetColors = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-c15cc053"]]);
2870
+ const _hoisted_1$2 = { class: "hv-color-picker-normal" };
2871
+ const _hoisted_2$1 = { class: "hv-color-picker__color-select-box" };
2872
+ const _hoisted_3 = { class: "hv-color-picker__sliders" };
2873
+ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
2874
+ ...{
2875
+ name: "HvColorPickerNormal"
2876
+ },
2877
+ __name: "ColorPicker",
2878
+ props: {
2879
+ modelValue: { default: DEFAULT_COLOR },
2880
+ disabled: { type: Boolean },
2881
+ enableAlpha: { type: Boolean, default: true },
2882
+ presetTitle: {},
2883
+ presetColors: {}
2884
+ },
2885
+ emits: ["update:model-value"],
2886
+ setup(__props, { emit: __emit }) {
2887
+ const emits = __emit;
2888
+ const props = __props;
2889
+ const color2 = vue.computed({
2890
+ get() {
2891
+ return props.modelValue;
2892
+ },
2893
+ set(value2) {
2894
+ emits("update:model-value", value2);
2895
+ }
2896
+ });
2897
+ const isSupportEyeDropper = !!window.EyeDropper;
2898
+ const colorAreaRef = vue.ref();
2899
+ const hue = vue.ref(0);
2900
+ const alpha = vue.ref(0);
2901
+ const saturationv = vue.ref(100);
2902
+ const value = vue.ref(100);
2903
+ const fullAlphaColor = vue.computed(() => {
2904
+ return Color$1(color2.value).alpha(1).hex();
2905
+ });
2906
+ vue.watch(
2907
+ color2,
2908
+ (c) => {
2909
+ const color22 = Color$1(c);
2910
+ const { h, s } = color22.hsv().object();
2911
+ saturationv.value = s;
2912
+ const equlValues = [0, 360];
2913
+ 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
+ }
2919
+ }
2920
+ },
2921
+ {
2922
+ immediate: true
2923
+ }
2924
+ );
2925
+ const hueColor = vue.computed(() => {
2926
+ const color22 = Color$1({ h: hue.value, s: 100, v: 100 });
2927
+ return color22.hex();
2928
+ });
2929
+ vue.watch([hue, alpha, saturationv, value], () => {
2930
+ reCompColor();
2931
+ });
2932
+ const reCompColor = throttle$1(
2933
+ function reCompColor2() {
2934
+ const newColor = Color$1({ h: hue.value, s: saturationv.value, v: value.value, alpha: alpha.value / 100 });
2935
+ color2.value = props.enableAlpha ? newColor.hexa() : newColor.hex();
2936
+ },
2937
+ 50,
2938
+ {
2939
+ leading: false,
2940
+ trailing: true
2941
+ }
2942
+ );
2943
+ function handleOpenEyeDropper() {
2944
+ if (props.disabled) {
2945
+ return;
2946
+ }
2947
+ const eyeDropper = new window.EyeDropper();
2948
+ eyeDropper.open().then((result) => {
2949
+ color2.value = result.sRGBHex;
2950
+ }).catch((e) => {
2951
+ console.error("Eyedropper failed to get color", e);
2952
+ });
2953
+ }
2954
+ function handleColorChange(hex) {
2955
+ if (props.disabled) {
2956
+ return;
2957
+ }
2958
+ color2.value = hex;
2959
+ }
2960
+ return (_ctx, _cache) => {
2961
+ const _component_ElSlider = vue.resolveComponent("ElSlider");
2962
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
2963
+ vue.createVNode(ColorArea, {
2964
+ ref_key: "colorAreaRef",
2965
+ ref: colorAreaRef,
2966
+ "hue-color": hueColor.value,
2967
+ color: color2.value,
2968
+ saturation: saturationv.value,
2969
+ "onUpdate:saturation": _cache[0] || (_cache[0] = ($event) => saturationv.value = $event),
2970
+ value: value.value,
2971
+ "onUpdate:value": _cache[1] || (_cache[1] = ($event) => value.value = $event),
2972
+ disabled: props.disabled
2973
+ }, null, 8, ["hue-color", "color", "saturation", "value", "disabled"]),
2974
+ vue.createElementVNode("div", _hoisted_2$1, [
2975
+ isSupportEyeDropper ? (vue.openBlock(), vue.createElementBlock("svg", {
2976
+ key: 0,
2977
+ onClick: handleOpenEyeDropper,
2978
+ class: vue.normalizeClass(["hv-color-picker__dropper", props.disabled ? "is-disabled" : ""]),
2979
+ width: "28",
2980
+ height: "28",
2981
+ viewBox: "0 0 28 28",
2982
+ fill: "none",
2983
+ xmlns: "http://www.w3.org/2000/svg"
2984
+ }, _cache[5] || (_cache[5] = [
2985
+ vue.createElementVNode("path", {
2986
+ 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",
2987
+ fill: "currentcolor"
2988
+ }, null, -1)
2989
+ ]), 2)) : vue.createCommentVNode("", true),
2990
+ vue.createElementVNode("div", _hoisted_3, [
2991
+ vue.createVNode(_component_ElSlider, {
2992
+ modelValue: hue.value,
2993
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => hue.value = $event),
2994
+ min: 0,
2995
+ max: 360,
2996
+ disabled: props.disabled,
2997
+ "show-tooltip": false,
2998
+ class: "hv-color-picker__hue-slider",
2999
+ style: vue.normalizeStyle({
3000
+ "--el-slider-button-bg-color": hueColor.value
3001
+ })
3002
+ }, null, 8, ["modelValue", "disabled", "style"]),
3003
+ props.enableAlpha ? (vue.openBlock(), vue.createBlock(_component_ElSlider, {
3004
+ key: 0,
3005
+ modelValue: alpha.value,
3006
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => alpha.value = $event),
3007
+ min: 0,
3008
+ max: 100,
3009
+ disabled: props.disabled,
3010
+ "show-tooltip": false,
3011
+ class: "hv-color-picker__alpha-slider",
3012
+ style: vue.normalizeStyle({
3013
+ "--hv-cur-full-alpha-color": fullAlphaColor.value
3014
+ })
3015
+ }, null, 8, ["modelValue", "disabled", "style"])) : vue.createCommentVNode("", true)
3016
+ ])
3017
+ ]),
3018
+ vue.createVNode(ColorForm, {
3019
+ "model-value": color2.value,
3020
+ "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => color2.value = $event),
3021
+ disabled: props.disabled,
3022
+ "enable-alpha": props.enableAlpha
3023
+ }, null, 8, ["model-value", "disabled", "enable-alpha"]),
3024
+ vue.createVNode(PresetColors, {
2182
3025
  onChange: handleColorChange,
2183
3026
  title: props.presetTitle,
2184
3027
  presetColors: props.presetColors
@@ -2187,7 +3030,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2187
3030
  };
2188
3031
  }
2189
3032
  });
2190
- const HvColorPicker = withInstall(_sfc_main$3);
3033
+ const ColorPickerNormal = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-fbafd973"]]);
3034
+ const HvColorPicker = withInstall(_sfc_main$8);
3035
+ const HvColorPickerRainbow = HvColorPicker;
3036
+ const HvColorPickerNormal = withInstall(ColorPickerNormal);
2191
3037
  class EventBus {
2192
3038
  constructor() {
2193
3039
  __publicField(this, "_eventMap");
@@ -2223,22 +3069,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2223
3069
  class DnDManager extends EventBus {
2224
3070
  constructor() {
2225
3071
  super();
2226
- /** 是否开始拖动 */
3072
+ /** 是否开始拖动 | Whether to start dragging */
2227
3073
  __publicField(this, "isDragStart", false);
2228
- /** 拖动元素类型 */
3074
+ /** 拖动元素类型 | Drag type */
2229
3075
  __publicField(this, "dragType");
2230
- /** Draggable传递的数据,
2231
- * 供Droppable使用
2232
- */
3076
+ /** Draggable传递的数据,供Droppable使用 | Draggable passes data for use by Droppable */
2233
3077
  __publicField(this, "dragData");
2234
3078
  __publicField(this, "isSendFirstMovePos", false);
2235
- /** 移动端长按一定时间才触发 onStart */
3079
+ /** 长按一定时间才触发 onStart | Press and hold for a certain amount of time to trigger onStart */
2236
3080
  __publicField(this, "touchStartPressTime", 300);
2237
- /** touchstart事件触发的时的时间 */
3081
+ /** 点击触发时的时间 | The time at which the click is triggered */
2238
3082
  __publicField(this, "touchStartTime", 0);
2239
- /** touchstart时间触发的位置 */
3083
+ /** 点击触发的位置 | The position where the click event is triggered */
2240
3084
  __publicField(this, "touchStartPosition", { x: 0, y: 0 });
2241
- /** onMove最后位置 */
3085
+ /** onMove最后位置 | onMove last position */
2242
3086
  __publicField(this, "lastMovePoint", { x: 0, y: 0 });
2243
3087
  __publicField(this, "emitTouchStartTimer");
2244
3088
  __publicField(this, "destroy", () => {
@@ -2256,14 +3100,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2256
3100
  this.emitTouchStartTimer = void 0;
2257
3101
  }
2258
3102
  /**
2259
- * 通知 Draggable 开始点击
3103
+ * 通知 Draggable 开始点击 | Tell Draggable to start clicking
2260
3104
  * @param point
2261
3105
  */
2262
3106
  onDown(point) {
2263
3107
  this.emit("down", point);
2264
3108
  }
2265
3109
  /**
2266
- * 通知 Draggable 拖拽开始
3110
+ * 第一次移动时,通知 Draggable | On the first move, notify Draggable
2267
3111
  * @param point
2268
3112
  */
2269
3113
  onFirstMove(point, e) {
@@ -2274,7 +3118,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2274
3118
  this.emit("first-move", point, e);
2275
3119
  }
2276
3120
  /**
2277
- * 通知 Draggable 拖拽开始
3121
+ * 通知 Draggable 拖拽开始 | Notify Draggable to begin the drag
2278
3122
  * @param point
2279
3123
  */
2280
3124
  onStart(point) {
@@ -2284,7 +3128,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2284
3128
  this.emit("start", point);
2285
3129
  }
2286
3130
  /**
2287
- * 通知 Draggable 移动
3131
+ * 通知 Draggable 移动 | Notify Draggable to move
2288
3132
  * @param point
2289
3133
  * @returns
2290
3134
  */
@@ -2300,7 +3144,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2300
3144
  });
2301
3145
  }
2302
3146
  /**
2303
- * 结束拖拽
3147
+ * 结束拖拽 | Ending drag
2304
3148
  * @returns
2305
3149
  */
2306
3150
  onEnd() {
@@ -2454,7 +3298,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2454
3298
  }
2455
3299
  }
2456
3300
  const DnDManagerInstance = new DnDManager();
2457
- const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
3301
+ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
2458
3302
  ...{
2459
3303
  name: "HvDraggable"
2460
3304
  },
@@ -2597,7 +3441,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2597
3441
  class: "hv-draggable__clone-item",
2598
3442
  style: vue.normalizeStyle(cloneNodeStyle.value)
2599
3443
  }, [
2600
- vue.renderSlot(_ctx.$slots, "hv-drag-item", {}, () => [
3444
+ vue.renderSlot(_ctx.$slots, "drag-item", {}, () => [
2601
3445
  vue.renderSlot(_ctx.$slots, "default", {}, void 0, true)
2602
3446
  ], true)
2603
3447
  ], 4)) : vue.createCommentVNode("", true)
@@ -2605,21 +3449,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2605
3449
  };
2606
3450
  }
2607
3451
  });
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({
3452
+ const Draggable = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-2309f70a"]]);
3453
+ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
2617
3454
  ...{
2618
3455
  name: "HvDroppable"
2619
3456
  },
2620
3457
  __name: "Droppable",
2621
3458
  props: {
2622
- acceptDragType: {}
3459
+ acceptDragType: {},
3460
+ disabled: { type: Boolean }
2623
3461
  },
2624
3462
  emits: ["enter", "move", "drop", "leave"],
2625
3463
  setup(__props, { emit: __emit }) {
@@ -2653,6 +3491,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2653
3491
  };
2654
3492
  }
2655
3493
  const onMove = (params) => {
3494
+ if (props.disabled) {
3495
+ return;
3496
+ }
2656
3497
  const { type, data, point } = params;
2657
3498
  if (dropAreaRef.value && acceptDragTypeList.value.includes(type)) {
2658
3499
  const { isInArea, position } = getPositionInArea(point);
@@ -2670,6 +3511,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2670
3511
  }
2671
3512
  };
2672
3513
  const onEnd = ({ type, point, data }) => {
3514
+ if (props.disabled) {
3515
+ return;
3516
+ }
2673
3517
  if (dropAreaRef.value && acceptDragTypeList.value.includes(type) && isEntered.value) {
2674
3518
  const { position } = getPositionInArea(point);
2675
3519
  emits("drop", type, position, data);
@@ -2695,7 +3539,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2695
3539
  }
2696
3540
  });
2697
3541
  const HvDraggable = withInstall(Draggable);
2698
- const HvDroppable = withInstall(_sfc_main$1);
3542
+ const HvDroppable = withInstall(_sfc_main$2);
2699
3543
  function useDragAndScale(target, operateTarget, options) {
2700
3544
  const _options = vue.computed(() => {
2701
3545
  return vue.isRef(options) ? vue.toValue(options) : options;
@@ -3152,8 +3996,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3152
3996
  removeEvent();
3153
3997
  });
3154
3998
  }
3155
- const _hoisted_1 = { class: "hv-drag-and-scale__zoom-mark" };
3156
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
3999
+ const _hoisted_1$1 = { class: "hv-drag-and-scale__zoom-mark" };
4000
+ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
3157
4001
  ...{
3158
4002
  name: "HvDragAndScale"
3159
4003
  },
@@ -3196,7 +4040,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3196
4040
  ref: targetRef
3197
4041
  }, [
3198
4042
  vue.renderSlot(_ctx.$slots, "default"),
3199
- vue.createElementVNode("div", _hoisted_1, [
4043
+ vue.createElementVNode("div", _hoisted_1$1, [
3200
4044
  vue.createElementVNode("div", {
3201
4045
  class: vue.normalizeClass(["hv-drag-and-scale__area-box", props.disabled ? "disabled" : ""]),
3202
4046
  ref_key: "operateRef",
@@ -3209,10 +4053,165 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3209
4053
  };
3210
4054
  }
3211
4055
  });
3212
- const HvDragAndScale = withInstall(_sfc_main);
4056
+ const HvDragAndScale = withInstall(_sfc_main$1);
4057
+ function getValidIPItemValue(val) {
4058
+ const num = parseInt(val + "");
4059
+ return isNaN(num) ? "" : num < 0 ? "0" : num > 255 ? "255" : num + "";
4060
+ }
4061
+ function getRange(el) {
4062
+ const ret = {
4063
+ begin: null,
4064
+ end: null,
4065
+ result: null
4066
+ };
4067
+ ret.begin = el.selectionStart || 0;
4068
+ ret.end = el.selectionEnd || 0;
4069
+ ret.result = el.value.substring(ret.begin, ret.end);
4070
+ el.focus();
4071
+ return ret;
4072
+ }
4073
+ const _hoisted_1 = ["value", "disabled", "onInput", "onKeydown", "onPaste"];
4074
+ const _hoisted_2 = { key: 0 };
4075
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
4076
+ ...{
4077
+ name: "HvIpInput"
4078
+ },
4079
+ __name: "IpInput",
4080
+ props: {
4081
+ modelValue: { default: "..." },
4082
+ disabled: { type: Boolean, default: false }
4083
+ },
4084
+ emits: ["update:model-value"],
4085
+ setup(__props, { emit: __emit }) {
4086
+ const emits = __emit;
4087
+ const props = __props;
4088
+ const inputRefs = vue.ref([]);
4089
+ const values = vue.ref([]);
4090
+ vue.watch(
4091
+ () => props.modelValue,
4092
+ (value) => {
4093
+ value = value + "";
4094
+ const strs = value.split(".");
4095
+ values.value = Array(4).fill("").map((_, i) => {
4096
+ return getValidIPItemValue(strs[i] + "");
4097
+ });
4098
+ },
4099
+ {
4100
+ immediate: true
4101
+ }
4102
+ );
4103
+ function onIPChange() {
4104
+ const ip = values.value.map((val) => getValidIPItemValue(val)).join(".");
4105
+ return emits("update:model-value", ip);
4106
+ }
4107
+ function handleChange(e, i) {
4108
+ var _a;
4109
+ if (props.disabled) {
4110
+ return;
4111
+ }
4112
+ const curValue = e.target.value;
4113
+ const num = getValidIPItemValue(curValue);
4114
+ values.value[i] = num;
4115
+ e.target.value = num;
4116
+ onIPChange();
4117
+ if (num === "") {
4118
+ return e.preventDefault();
4119
+ }
4120
+ if (String(num).length === 3 && i < 3) {
4121
+ (_a = inputRefs.value[i + 1]) == null ? void 0 : _a.focus();
4122
+ }
4123
+ }
4124
+ function handleKeyDown(e, i) {
4125
+ let domId = i;
4126
+ const { end } = getRange(e.target);
4127
+ switch (e.keyCode) {
4128
+ case 37:
4129
+ case 8: {
4130
+ if (end === 0 && i > 0) {
4131
+ domId = i - 1;
4132
+ }
4133
+ break;
4134
+ }
4135
+ case 39: {
4136
+ if (end === e.target.value.length && i < 3) {
4137
+ domId = i + 1;
4138
+ }
4139
+ break;
4140
+ }
4141
+ case 110:
4142
+ case 190: {
4143
+ e.preventDefault();
4144
+ if (i < 3) {
4145
+ domId = i + 1;
4146
+ }
4147
+ break;
4148
+ }
4149
+ }
4150
+ const inputEl = inputRefs.value[domId];
4151
+ inputEl.focus();
4152
+ if (domId < i) {
4153
+ const len = inputEl.value.length;
4154
+ inputEl.selectionStart = inputEl.selectionEnd = len;
4155
+ } else if (domId > i) {
4156
+ inputEl.selectionStart = inputEl.selectionEnd = 0;
4157
+ }
4158
+ }
4159
+ function handlePaste(e, i) {
4160
+ if (!e.clipboardData || !e.clipboardData.getData) {
4161
+ return;
4162
+ }
4163
+ const pasteData = e.clipboardData.getData("text/plain");
4164
+ if (!pasteData) {
4165
+ return;
4166
+ }
4167
+ const value = pasteData.split(".").map((v) => getValidIPItemValue(v));
4168
+ if (value.length !== 4 - i) {
4169
+ return;
4170
+ }
4171
+ if (!value.every((item) => item !== "")) {
4172
+ return;
4173
+ }
4174
+ value.forEach((val, j) => {
4175
+ values.value[i + j] = val + "";
4176
+ });
4177
+ onIPChange();
4178
+ return e.preventDefault();
4179
+ }
4180
+ return (_ctx, _cache) => {
4181
+ return vue.openBlock(), vue.createElementBlock("div", {
4182
+ class: vue.normalizeClass(["hv-ip-input", props.disabled ? "is-disabled" : ""])
4183
+ }, [
4184
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(values.value, (value, i) => {
4185
+ return vue.openBlock(), vue.createElementBlock("div", {
4186
+ class: "hv-ip-input-item",
4187
+ key: i
4188
+ }, [
4189
+ vue.createElementVNode("input", {
4190
+ ref_for: true,
4191
+ ref_key: "inputRefs",
4192
+ ref: inputRefs,
4193
+ type: "text",
4194
+ value,
4195
+ disabled: props.disabled,
4196
+ onInput: (e) => handleChange(e, i),
4197
+ onKeydown: (e) => handleKeyDown(e, i),
4198
+ onPaste: (e) => handlePaste(e, i)
4199
+ }, null, 40, _hoisted_1),
4200
+ i !== 3 ? (vue.openBlock(), vue.createElementBlock("i", _hoisted_2, ".")) : vue.createCommentVNode("", true)
4201
+ ]);
4202
+ }), 128))
4203
+ ], 2);
4204
+ };
4205
+ }
4206
+ });
4207
+ const HvIpInput = withInstall(_sfc_main);
4208
+ exports2.DEFAULT_COLOR = DEFAULT_COLOR;
3213
4209
  exports2.HvColorPicker = HvColorPicker;
4210
+ exports2.HvColorPickerNormal = HvColorPickerNormal;
4211
+ exports2.HvColorPickerRainbow = HvColorPickerRainbow;
3214
4212
  exports2.HvDragAndScale = HvDragAndScale;
3215
4213
  exports2.HvDraggable = HvDraggable;
3216
4214
  exports2.HvDroppable = HvDroppable;
4215
+ exports2.HvIpInput = HvIpInput;
3217
4216
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
3218
4217
  });