@havue/components 1.1.1 → 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.
- package/dist/components.full.js +1291 -286
- package/dist/components.full.min.js +1 -1
- package/dist/components.full.min.js.map +1 -1
- package/dist/components.mjs +164 -0
- package/dist/components.umd.js +162 -2
- package/dist/style.css +1 -1
- package/dist/types/color-picker/src/color-picker-normal/ColorPicker.vue.d.ts +16 -0
- package/dist/types/color-picker/src/color-picker-normal/children/ColorArea/ColorArea.vue.d.ts +18 -0
- package/dist/types/color-picker/src/color-picker-normal/children/ColorArea/hooks/useInteraction.d.ts +9 -0
- package/dist/types/color-picker/src/color-picker-normal/children/ColorForm/ColorForm.vue.d.ts +11 -0
- package/dist/types/color-picker/src/color-picker-rainbow/ColorPicker.vue.d.ts +15 -0
- package/dist/types/color-picker/src/{children → color-picker-rainbow/children}/ColorForm/ColorForm.vue.d.ts +1 -0
- package/dist/types/color-picker/src/color-picker-rainbow/children/PresetColors/PresetColors.vue.d.ts +10 -0
- package/dist/types/color-picker/src/{hooks → color-picker-rainbow/hooks}/useOperateEvent.d.ts +4 -1
- package/dist/types/color-picker/src/{utils → color-picker-rainbow/utils}/color.d.ts +6 -6
- package/dist/types/color-picker/src/constants/index.d.ts +1 -0
- package/dist/types/color-picker/src/index.d.ts +24 -2
- package/dist/types/drag-and-drop/src/Draggable.vue.d.ts +2 -2
- package/dist/types/drag-and-drop/src/Droppable.vue.d.ts +1 -0
- package/dist/types/drag-and-drop/src/manager/index.d.ts +14 -17
- package/dist/types/ip-input/src/IpInput.vue.d.ts +13 -0
- package/dist/types/ip-input/src/index.d.ts +3 -0
- package/dist/types/ip-input/src/utils/index.d.ts +14 -0
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +5 -5
- package/dist/types/color-picker/src/ColorPicker.vue.d.ts +0 -18
- /package/dist/types/color-picker/src/{children → color-picker-normal/children}/PresetColors/PresetColors.vue.d.ts +0 -0
- /package/dist/types/color-picker/src/{hooks → color-picker-rainbow/hooks}/useColorArea.d.ts +0 -0
- /package/dist/types/color-picker/src/{utils → color-picker-rainbow/utils}/tools.d.ts +0 -0
package/dist/components.full.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue"], factory) : (
|
|
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]];
|
|
@@ -1619,7 +1620,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1619
1620
|
const secondColor = colorItems[1];
|
|
1620
1621
|
const curColorType = maxColor.type + secondColor.type;
|
|
1621
1622
|
let coordinateX = 0;
|
|
1622
|
-
|
|
1623
|
+
const coordinateY = colorItems[2].value;
|
|
1623
1624
|
if (curColorType === "rg" || curColorType === "gr") {
|
|
1624
1625
|
coordinateX = 255;
|
|
1625
1626
|
if (secondColor.type === "r") {
|
|
@@ -1656,8 +1657,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1656
1657
|
}
|
|
1657
1658
|
const scaleX = canvasWidth / width;
|
|
1658
1659
|
const scaleY = canvasHeight / height;
|
|
1659
|
-
x = Math.min(x * scaleX, canvasWidth - 1);
|
|
1660
|
-
y = Math.min(y * scaleY, canvasHeight - 1);
|
|
1660
|
+
x = Math.round(Math.min(x * scaleX, canvasWidth - 1));
|
|
1661
|
+
y = Math.round(Math.min(y * scaleY, canvasHeight - 1));
|
|
1661
1662
|
const color2 = getBaseColorFromCoodinage(x, y);
|
|
1662
1663
|
return color2;
|
|
1663
1664
|
}
|
|
@@ -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,46 +1730,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1729
1730
|
}
|
|
1730
1731
|
};
|
|
1731
1732
|
}
|
|
1732
|
-
|
|
1733
|
-
constructor() {
|
|
1734
|
-
__publicField(this, "_eventMap");
|
|
1735
|
-
this._eventMap = /* @__PURE__ */ new Map();
|
|
1736
|
-
}
|
|
1737
|
-
on(key, handler) {
|
|
1738
|
-
const handlers = this._eventMap.get(key);
|
|
1739
|
-
if (handlers) {
|
|
1740
|
-
handlers.add(handler);
|
|
1741
|
-
} else {
|
|
1742
|
-
const set = /* @__PURE__ */ new Set();
|
|
1743
|
-
set.add(handler);
|
|
1744
|
-
this._eventMap.set(key, set);
|
|
1745
|
-
}
|
|
1746
|
-
}
|
|
1747
|
-
off(key, handler) {
|
|
1748
|
-
const handlers = this._eventMap.get(key);
|
|
1749
|
-
if (!handlers) return;
|
|
1750
|
-
if (handler) {
|
|
1751
|
-
handlers.delete(handler);
|
|
1752
|
-
} else {
|
|
1753
|
-
handlers.clear();
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
emit(key, ...payload) {
|
|
1757
|
-
const handlers = this._eventMap.get(key);
|
|
1758
|
-
if (!handlers) return;
|
|
1759
|
-
for (const callback of handlers.values()) {
|
|
1760
|
-
callback(...payload);
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
|
1765
|
-
function useOperateEvent() {
|
|
1733
|
+
function useOperateEvent(options) {
|
|
1766
1734
|
const colorAreaRef = vue.ref();
|
|
1767
1735
|
const circlePickerCoordinate = vue.reactive({
|
|
1768
1736
|
x: 0,
|
|
1769
1737
|
y: 0
|
|
1770
1738
|
});
|
|
1739
|
+
const isDisabled = vue.computed(() => {
|
|
1740
|
+
return vue.isRef(options.disabled) ? options.disabled.value : options.disabled;
|
|
1741
|
+
});
|
|
1771
1742
|
function handleTouchStart(e) {
|
|
1743
|
+
if (isDisabled.value) {
|
|
1744
|
+
return;
|
|
1745
|
+
}
|
|
1772
1746
|
if (e.touches.length === 0) {
|
|
1773
1747
|
return;
|
|
1774
1748
|
}
|
|
@@ -1796,6 +1770,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1796
1770
|
document.body.removeEventListener("touchend", handleTouchEnd);
|
|
1797
1771
|
}
|
|
1798
1772
|
function handleMounseDown(e) {
|
|
1773
|
+
if (isDisabled.value) {
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1799
1776
|
document.body.addEventListener("mousemove", handleMouseMove);
|
|
1800
1777
|
document.body.addEventListener("mouseup", handleMouseUp);
|
|
1801
1778
|
handleCirclePickerCoordinateChange({
|
|
@@ -1804,14 +1781,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1804
1781
|
});
|
|
1805
1782
|
}
|
|
1806
1783
|
function handleMouseMove(e) {
|
|
1784
|
+
if (!(e.buttons && 1)) {
|
|
1785
|
+
handleMouseUp();
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1807
1788
|
handleCirclePickerCoordinateChange({
|
|
1808
1789
|
x: e.clientX,
|
|
1809
1790
|
y: e.clientY
|
|
1810
1791
|
});
|
|
1811
1792
|
}
|
|
1812
|
-
const handleCirclePickerCoordinateChange = throttle(handleCirclePickerCoordinateChangeFn, 20);
|
|
1793
|
+
const handleCirclePickerCoordinateChange = throttle$2(handleCirclePickerCoordinateChangeFn, 20);
|
|
1813
1794
|
function handleCirclePickerCoordinateChangeFn(point) {
|
|
1814
1795
|
var _a;
|
|
1796
|
+
if (isDisabled.value) {
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1815
1799
|
const { x: clientX, y: clientY } = point;
|
|
1816
1800
|
const colorAreaRect = (_a = colorAreaRef.value) == null ? void 0 : _a.getBoundingClientRect();
|
|
1817
1801
|
if (!colorAreaRect) {
|
|
@@ -1834,8 +1818,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1834
1818
|
} else {
|
|
1835
1819
|
y = clientY - top;
|
|
1836
1820
|
}
|
|
1837
|
-
circlePickerCoordinate.x =
|
|
1838
|
-
circlePickerCoordinate.y =
|
|
1821
|
+
circlePickerCoordinate.x = x;
|
|
1822
|
+
circlePickerCoordinate.y = y;
|
|
1839
1823
|
}
|
|
1840
1824
|
function handleMouseUp() {
|
|
1841
1825
|
document.body.removeEventListener("mousemove", handleMouseMove);
|
|
@@ -1855,23 +1839,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1855
1839
|
}
|
|
1856
1840
|
vue.onMounted(() => {
|
|
1857
1841
|
var _a, _b;
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
} else {
|
|
1861
|
-
(_b = colorAreaRef.value) == null ? void 0 : _b.addEventListener("mousedown", handleMounseDown);
|
|
1862
|
-
}
|
|
1842
|
+
(_a = colorAreaRef.value) == null ? void 0 : _a.addEventListener("touchstart", handleTouchStart);
|
|
1843
|
+
(_b = colorAreaRef.value) == null ? void 0 : _b.addEventListener("mousedown", handleMounseDown);
|
|
1863
1844
|
});
|
|
1864
1845
|
vue.onBeforeUnmount(() => {
|
|
1865
1846
|
var _a, _b;
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
document.body.removeEventListener("mousemove", handleMouseMove);
|
|
1873
|
-
document.body.removeEventListener("mouseup", handleMouseUp);
|
|
1874
|
-
}
|
|
1847
|
+
(_a = colorAreaRef.value) == null ? void 0 : _a.removeEventListener("touchstart", handleTouchStart);
|
|
1848
|
+
document.body.removeEventListener("touchmove", handleTouchMove);
|
|
1849
|
+
document.body.removeEventListener("touchend", handleTouchEnd);
|
|
1850
|
+
(_b = colorAreaRef.value) == null ? void 0 : _b.removeEventListener("mousedown", handleMounseDown);
|
|
1851
|
+
document.body.removeEventListener("mousemove", handleMouseMove);
|
|
1852
|
+
document.body.removeEventListener("mouseup", handleMouseUp);
|
|
1875
1853
|
});
|
|
1876
1854
|
return {
|
|
1877
1855
|
colorAreaRef,
|
|
@@ -1879,26 +1857,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1879
1857
|
setCirclePickerCoordinate
|
|
1880
1858
|
};
|
|
1881
1859
|
}
|
|
1882
|
-
const
|
|
1883
|
-
const
|
|
1884
|
-
const
|
|
1885
|
-
const
|
|
1886
|
-
const
|
|
1887
|
-
const _sfc_main$
|
|
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({
|
|
1888
1866
|
__name: "ColorForm",
|
|
1889
1867
|
props: {
|
|
1890
|
-
modelValue: {}
|
|
1868
|
+
modelValue: {},
|
|
1869
|
+
disabled: { type: Boolean }
|
|
1891
1870
|
},
|
|
1892
1871
|
emits: ["change"],
|
|
1893
1872
|
setup(__props, { emit: __emit }) {
|
|
1894
1873
|
const props = __props;
|
|
1895
1874
|
const emits = __emit;
|
|
1896
|
-
const hexColor = vue.ref(Color$1(props.modelValue || DEFAULT_COLOR
|
|
1875
|
+
const hexColor = vue.ref(Color$1(props.modelValue || DEFAULT_COLOR).hex());
|
|
1897
1876
|
const formInputRGB = vue.reactive(
|
|
1898
|
-
Color$1(hexColor.value || DEFAULT_COLOR
|
|
1877
|
+
Color$1(hexColor.value || DEFAULT_COLOR).rgb().object()
|
|
1899
1878
|
);
|
|
1900
1879
|
const formInputHSV = vue.reactive(
|
|
1901
|
-
Color$1(hexColor.value || DEFAULT_COLOR
|
|
1880
|
+
Color$1(hexColor.value || DEFAULT_COLOR).hsv().object()
|
|
1902
1881
|
);
|
|
1903
1882
|
function hexFormater(value) {
|
|
1904
1883
|
return `#${value.replace(/[^0-9A-F]/gi, "").slice(0, 6).toUpperCase()}`;
|
|
@@ -1942,89 +1921,897 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1942
1921
|
return (_ctx, _cache) => {
|
|
1943
1922
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
1944
1923
|
const _component_el_input_number = vue.resolveComponent("el-input-number");
|
|
1945
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
1946
|
-
vue.createElementVNode("div", _hoisted_2$
|
|
1924
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
|
|
1925
|
+
vue.createElementVNode("div", _hoisted_2$6, [
|
|
1947
1926
|
vue.createVNode(_component_el_input, {
|
|
1948
1927
|
modelValue: hexColor.value,
|
|
1949
1928
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => hexColor.value = $event),
|
|
1929
|
+
disabled: props.disabled,
|
|
1950
1930
|
formatter: hexFormater,
|
|
1951
1931
|
onChange: handleHexColorChange
|
|
1952
|
-
}, null, 8, ["modelValue"])
|
|
1932
|
+
}, null, 8, ["modelValue", "disabled"])
|
|
1953
1933
|
]),
|
|
1954
|
-
vue.createElementVNode("div", _hoisted_3$
|
|
1934
|
+
vue.createElementVNode("div", _hoisted_3$5, [
|
|
1955
1935
|
_cache[7] || (_cache[7] = vue.createElementVNode("div", { class: "hv-color-picker__form-label" }, "RGB", -1)),
|
|
1956
1936
|
vue.createVNode(_component_el_input_number, {
|
|
1957
1937
|
modelValue: formInputRGB.r,
|
|
1958
1938
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => formInputRGB.r = $event),
|
|
1939
|
+
disabled: props.disabled,
|
|
1959
1940
|
onChange: handleRgbColorChange,
|
|
1960
1941
|
"step-strictly": "",
|
|
1961
1942
|
min: 0,
|
|
1962
1943
|
max: 255,
|
|
1963
1944
|
step: 1,
|
|
1964
1945
|
controls: false
|
|
1965
|
-
}, null, 8, ["modelValue"]),
|
|
1946
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
1966
1947
|
vue.createVNode(_component_el_input_number, {
|
|
1967
1948
|
modelValue: formInputRGB.g,
|
|
1968
1949
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => formInputRGB.g = $event),
|
|
1950
|
+
disabled: props.disabled,
|
|
1969
1951
|
onChange: handleRgbColorChange,
|
|
1970
1952
|
"step-strictly": "",
|
|
1971
1953
|
min: 0,
|
|
1972
1954
|
max: 255,
|
|
1973
1955
|
step: 1,
|
|
1974
1956
|
controls: false
|
|
1975
|
-
}, null, 8, ["modelValue"]),
|
|
1957
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
1976
1958
|
vue.createVNode(_component_el_input_number, {
|
|
1977
1959
|
modelValue: formInputRGB.b,
|
|
1978
1960
|
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => formInputRGB.b = $event),
|
|
1961
|
+
disabled: props.disabled,
|
|
1979
1962
|
onChange: handleRgbColorChange,
|
|
1980
1963
|
"step-strictly": "",
|
|
1981
1964
|
min: 0,
|
|
1982
1965
|
max: 255,
|
|
1983
1966
|
step: 1,
|
|
1984
1967
|
controls: false
|
|
1985
|
-
}, null, 8, ["modelValue"])
|
|
1986
|
-
]),
|
|
1987
|
-
vue.createElementVNode("div", _hoisted_4$
|
|
1988
|
-
_cache[8] || (_cache[8] = vue.createElementVNode("div", { class: "hv-color-picker__form-label" }, "HSV", -1)),
|
|
1968
|
+
}, null, 8, ["modelValue", "disabled"])
|
|
1969
|
+
]),
|
|
1970
|
+
vue.createElementVNode("div", _hoisted_4$3, [
|
|
1971
|
+
_cache[8] || (_cache[8] = vue.createElementVNode("div", { class: "hv-color-picker__form-label" }, "HSV", -1)),
|
|
1972
|
+
vue.createVNode(_component_el_input_number, {
|
|
1973
|
+
modelValue: formInputHSV.h,
|
|
1974
|
+
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => formInputHSV.h = $event),
|
|
1975
|
+
disabled: props.disabled,
|
|
1976
|
+
onChange: handleHsvColorChange,
|
|
1977
|
+
min: 0,
|
|
1978
|
+
max: 360,
|
|
1979
|
+
"step-strictly": "",
|
|
1980
|
+
step: 1,
|
|
1981
|
+
controls: false
|
|
1982
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
1983
|
+
vue.createVNode(_component_el_input_number, {
|
|
1984
|
+
modelValue: formInputHSV.s,
|
|
1985
|
+
"onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => formInputHSV.s = $event),
|
|
1986
|
+
disabled: props.disabled,
|
|
1987
|
+
onChange: handleHsvColorChange,
|
|
1988
|
+
min: 0,
|
|
1989
|
+
max: 100,
|
|
1990
|
+
"step-strictly": "",
|
|
1991
|
+
step: 1,
|
|
1992
|
+
controls: false
|
|
1993
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
1994
|
+
vue.createVNode(_component_el_input_number, {
|
|
1995
|
+
modelValue: formInputHSV.v,
|
|
1996
|
+
"onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => formInputHSV.v = $event),
|
|
1997
|
+
disabled: props.disabled,
|
|
1998
|
+
onChange: handleHsvColorChange,
|
|
1999
|
+
"step-strictly": "",
|
|
2000
|
+
min: 0,
|
|
2001
|
+
max: 100,
|
|
2002
|
+
controls: false
|
|
2003
|
+
}, null, 8, ["modelValue", "disabled"])
|
|
2004
|
+
])
|
|
2005
|
+
]);
|
|
2006
|
+
};
|
|
2007
|
+
}
|
|
2008
|
+
});
|
|
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({
|
|
2014
|
+
__name: "PresetColors",
|
|
2015
|
+
props: {
|
|
2016
|
+
title: {},
|
|
2017
|
+
presetColors: {}
|
|
2018
|
+
},
|
|
2019
|
+
emits: ["change"],
|
|
2020
|
+
setup(__props, { emit: __emit }) {
|
|
2021
|
+
const defaultPresetColors = [
|
|
2022
|
+
"#000000",
|
|
2023
|
+
"#FFFFFF",
|
|
2024
|
+
"#E3822D",
|
|
2025
|
+
"#DCE24F",
|
|
2026
|
+
"#1DCF69",
|
|
2027
|
+
"#6DE5B9",
|
|
2028
|
+
"#11A1F2",
|
|
2029
|
+
"#AA43FF",
|
|
2030
|
+
"#F0689C",
|
|
2031
|
+
"#F8D28B",
|
|
2032
|
+
"#606368",
|
|
2033
|
+
"#E83C34",
|
|
2034
|
+
"#EEBE29",
|
|
2035
|
+
"#89F0AC",
|
|
2036
|
+
"#2FBC9E",
|
|
2037
|
+
"#56CCF2",
|
|
2038
|
+
"#1C1DFA",
|
|
2039
|
+
"#DC88F5",
|
|
2040
|
+
"#D4C595",
|
|
2041
|
+
"#C52F65"
|
|
2042
|
+
];
|
|
2043
|
+
const props = __props;
|
|
2044
|
+
const preColors = vue.computed(() => {
|
|
2045
|
+
return !props.presetColors ? defaultPresetColors : props.presetColors;
|
|
2046
|
+
});
|
|
2047
|
+
const emits = __emit;
|
|
2048
|
+
function handleClickColor(color2) {
|
|
2049
|
+
emits("change", color2);
|
|
2050
|
+
}
|
|
2051
|
+
return (_ctx, _cache) => {
|
|
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, [
|
|
2055
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(preColors.value, (color2) => {
|
|
2056
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2057
|
+
class: "hv-color-picker__preset-list-item",
|
|
2058
|
+
onClick: ($event) => handleClickColor(color2),
|
|
2059
|
+
key: color2,
|
|
2060
|
+
style: vue.normalizeStyle({ backgroundColor: color2 })
|
|
2061
|
+
}, null, 12, _hoisted_4$2);
|
|
2062
|
+
}), 128))
|
|
2063
|
+
])
|
|
2064
|
+
]);
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
});
|
|
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({
|
|
2073
|
+
...{
|
|
2074
|
+
name: "HvColorPicker"
|
|
2075
|
+
},
|
|
2076
|
+
__name: "ColorPicker",
|
|
2077
|
+
props: {
|
|
2078
|
+
modelValue: { default: DEFAULT_COLOR },
|
|
2079
|
+
disabled: { type: Boolean },
|
|
2080
|
+
title: {},
|
|
2081
|
+
presetTitle: {},
|
|
2082
|
+
presetColors: {}
|
|
2083
|
+
},
|
|
2084
|
+
emits: ["update:model-value"],
|
|
2085
|
+
setup(__props, { emit: __emit }) {
|
|
2086
|
+
const props = __props;
|
|
2087
|
+
const emits = __emit;
|
|
2088
|
+
const isDisabled = vue.computed(() => props.disabled);
|
|
2089
|
+
const { colorAreaCanvas, getColorByCoordinate, getCoordinateByColor, canvasWidth, canvasHeight } = useColorArea();
|
|
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
|
+
});
|
|
2099
|
+
const lightColor = vue.ref(Color$1(DEFAULT_COLOR));
|
|
2100
|
+
const colorDepth = vue.ref(100);
|
|
2101
|
+
const originHexColor = vue.computed(() => {
|
|
2102
|
+
if (lightColor.value) {
|
|
2103
|
+
const hex = getOriginHexByLightAndDepth(lightColor.value, colorDepth.value);
|
|
2104
|
+
return hex;
|
|
2105
|
+
}
|
|
2106
|
+
return DEFAULT_COLOR;
|
|
2107
|
+
});
|
|
2108
|
+
vue.watch(color2, (val) => {
|
|
2109
|
+
const hex = getOriginHexByLightAndDepth(lightColor.value, colorDepth.value);
|
|
2110
|
+
if (hex === val) {
|
|
2111
|
+
return;
|
|
2112
|
+
}
|
|
2113
|
+
handleColorChange(val);
|
|
2114
|
+
});
|
|
2115
|
+
vue.watch(
|
|
2116
|
+
() => circlePickerCoordinate,
|
|
2117
|
+
(coordianate) => {
|
|
2118
|
+
var _a;
|
|
2119
|
+
const rect = (_a = colorAreaRef.value) == null ? void 0 : _a.getBoundingClientRect();
|
|
2120
|
+
if (!rect) {
|
|
2121
|
+
return;
|
|
2122
|
+
}
|
|
2123
|
+
const color22 = getColorByCoordinate(coordianate.x, coordianate.y, rect.width, rect.height);
|
|
2124
|
+
lightColor.value = color22;
|
|
2125
|
+
},
|
|
2126
|
+
{
|
|
2127
|
+
deep: true
|
|
2128
|
+
}
|
|
2129
|
+
);
|
|
2130
|
+
const cilcleStyle = vue.computed(() => {
|
|
2131
|
+
if (!color2.value) {
|
|
2132
|
+
return {
|
|
2133
|
+
top: "100%",
|
|
2134
|
+
left: "0",
|
|
2135
|
+
backgroundColor: "#ffffff"
|
|
2136
|
+
};
|
|
2137
|
+
}
|
|
2138
|
+
return {
|
|
2139
|
+
top: circlePickerCoordinate.y + "px",
|
|
2140
|
+
left: circlePickerCoordinate.x + "px",
|
|
2141
|
+
backgroundColor: lightColor.value.hex()
|
|
2142
|
+
};
|
|
2143
|
+
});
|
|
2144
|
+
const sliderBackStyle = vue.computed(() => {
|
|
2145
|
+
const lightHex = colorToHex(lightColor.value);
|
|
2146
|
+
return {
|
|
2147
|
+
"--el-slider-runway-bg-color": `linear-gradient(to right, #000000, ${lightHex})`,
|
|
2148
|
+
"--el-slider-main-bg-color": lightHex
|
|
2149
|
+
};
|
|
2150
|
+
});
|
|
2151
|
+
vue.watch(
|
|
2152
|
+
() => originHexColor.value,
|
|
2153
|
+
(value, oldValue) => {
|
|
2154
|
+
if (value !== oldValue) {
|
|
2155
|
+
emits("update:model-value", value);
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
);
|
|
2160
|
+
function handleColorChange(hex) {
|
|
2161
|
+
if (props.disabled) {
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
const color22 = hexToColor(hex);
|
|
2165
|
+
const { color: lightRgb, value: depth } = getLightColorAndDepth(color22);
|
|
2166
|
+
lightColor.value = lightRgb;
|
|
2167
|
+
colorDepth.value = depth;
|
|
2168
|
+
const coordin = getCoordinateByColor(lightRgb);
|
|
2169
|
+
setCirclePickerCoordinate(coordin.x, coordin.y, canvasWidth, canvasHeight);
|
|
2170
|
+
}
|
|
2171
|
+
vue.onMounted(() => {
|
|
2172
|
+
handleColorChange(color2.value);
|
|
2173
|
+
});
|
|
2174
|
+
return (_ctx, _cache) => {
|
|
2175
|
+
const _component_ElSlider = vue.resolveComponent("ElSlider");
|
|
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, [
|
|
2179
|
+
vue.createElementVNode("div", {
|
|
2180
|
+
class: vue.normalizeClass(["hv-color-picker__area", isDisabled.value ? "is-disabled" : ""]),
|
|
2181
|
+
ref_key: "colorAreaRef",
|
|
2182
|
+
ref: colorAreaRef
|
|
2183
|
+
}, [
|
|
2184
|
+
vue.createElementVNode("canvas", {
|
|
2185
|
+
ref_key: "colorAreaCanvas",
|
|
2186
|
+
ref: colorAreaCanvas
|
|
2187
|
+
}, null, 512),
|
|
2188
|
+
vue.createElementVNode("div", {
|
|
2189
|
+
class: "hv-color-picker__circle",
|
|
2190
|
+
style: vue.normalizeStyle(cilcleStyle.value)
|
|
2191
|
+
}, null, 4)
|
|
2192
|
+
], 2)
|
|
2193
|
+
]),
|
|
2194
|
+
vue.createElementVNode("div", _hoisted_4$1, [
|
|
2195
|
+
vue.createVNode(_component_ElSlider, {
|
|
2196
|
+
modelValue: colorDepth.value,
|
|
2197
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => colorDepth.value = $event),
|
|
2198
|
+
disabled: props.disabled,
|
|
2199
|
+
min: 0,
|
|
2200
|
+
max: 100,
|
|
2201
|
+
"show-tooltip": false,
|
|
2202
|
+
style: vue.normalizeStyle(sliderBackStyle.value)
|
|
2203
|
+
}, null, 8, ["modelValue", "disabled", "style"]),
|
|
2204
|
+
vue.createElementVNode("div", {
|
|
2205
|
+
class: "hv-color-picker__origin-color",
|
|
2206
|
+
style: vue.normalizeStyle({ backgroundColor: originHexColor.value })
|
|
2207
|
+
}, null, 4)
|
|
2208
|
+
]),
|
|
2209
|
+
vue.createVNode(_sfc_main$a, {
|
|
2210
|
+
"model-value": color2.value,
|
|
2211
|
+
disabled: props.disabled,
|
|
2212
|
+
onChange: handleColorChange
|
|
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"]),
|
|
1989
2765
|
vue.createVNode(_component_el_input_number, {
|
|
1990
|
-
modelValue:
|
|
1991
|
-
"onUpdate:modelValue": _cache[
|
|
1992
|
-
onChange:
|
|
1993
|
-
min: 0,
|
|
1994
|
-
max: 360,
|
|
2766
|
+
modelValue: formInputState.value[1],
|
|
2767
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => formInputState.value[1] = $event),
|
|
2768
|
+
onChange: handleColorChange,
|
|
1995
2769
|
"step-strictly": "",
|
|
2770
|
+
disabled: props.disabled,
|
|
2771
|
+
min: 0,
|
|
2772
|
+
max: isRGB.value ? 255 : 100,
|
|
1996
2773
|
step: 1,
|
|
1997
2774
|
controls: false
|
|
1998
|
-
}, null, 8, ["modelValue"]),
|
|
2775
|
+
}, null, 8, ["modelValue", "disabled", "max"]),
|
|
1999
2776
|
vue.createVNode(_component_el_input_number, {
|
|
2000
|
-
modelValue:
|
|
2001
|
-
"onUpdate:modelValue": _cache[
|
|
2002
|
-
onChange:
|
|
2003
|
-
min: 0,
|
|
2004
|
-
max: 100,
|
|
2777
|
+
modelValue: formInputState.value[2],
|
|
2778
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => formInputState.value[2] = $event),
|
|
2779
|
+
onChange: handleColorChange,
|
|
2005
2780
|
"step-strictly": "",
|
|
2781
|
+
disabled: props.disabled,
|
|
2782
|
+
min: 0,
|
|
2783
|
+
max: isRGB.value ? 255 : 100,
|
|
2006
2784
|
step: 1,
|
|
2007
2785
|
controls: false
|
|
2008
|
-
}, null, 8, ["modelValue"]),
|
|
2009
|
-
vue.
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
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,
|
|
2013
2792
|
"step-strictly": "",
|
|
2793
|
+
disabled: props.disabled,
|
|
2014
2794
|
min: 0,
|
|
2015
2795
|
max: 100,
|
|
2796
|
+
step: 1,
|
|
2016
2797
|
controls: false
|
|
2017
|
-
},
|
|
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)
|
|
2018
2804
|
])
|
|
2019
2805
|
]);
|
|
2020
2806
|
};
|
|
2021
2807
|
}
|
|
2022
2808
|
});
|
|
2023
|
-
const
|
|
2024
|
-
const
|
|
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" };
|
|
2025
2812
|
const _hoisted_3$1 = { class: "hv-color-picker__preset-list" };
|
|
2026
|
-
const _hoisted_4
|
|
2027
|
-
const _sfc_main$
|
|
2813
|
+
const _hoisted_4 = ["onClick"];
|
|
2814
|
+
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
2028
2815
|
__name: "PresetColors",
|
|
2029
2816
|
props: {
|
|
2030
2817
|
title: {},
|
|
@@ -2063,8 +2850,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2063
2850
|
emits("change", color2);
|
|
2064
2851
|
}
|
|
2065
2852
|
return (_ctx, _cache) => {
|
|
2066
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
2067
|
-
vue.createElementVNode("div", _hoisted_2$
|
|
2853
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
|
|
2854
|
+
vue.createElementVNode("div", _hoisted_2$2, vue.toDisplayString(props.title || "Reset colors"), 1),
|
|
2068
2855
|
vue.createElementVNode("div", _hoisted_3$1, [
|
|
2069
2856
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(preColors.value, (color2) => {
|
|
2070
2857
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
@@ -2072,152 +2859,169 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2072
2859
|
onClick: ($event) => handleClickColor(color2),
|
|
2073
2860
|
key: color2,
|
|
2074
2861
|
style: vue.normalizeStyle({ backgroundColor: color2 })
|
|
2075
|
-
}, null, 12, _hoisted_4
|
|
2862
|
+
}, null, 12, _hoisted_4);
|
|
2076
2863
|
}), 128))
|
|
2077
2864
|
])
|
|
2078
2865
|
]);
|
|
2079
2866
|
};
|
|
2080
2867
|
}
|
|
2081
2868
|
});
|
|
2082
|
-
const
|
|
2083
|
-
const
|
|
2084
|
-
const
|
|
2085
|
-
const
|
|
2086
|
-
const
|
|
2087
|
-
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
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({
|
|
2088
2874
|
...{
|
|
2089
|
-
name: "
|
|
2875
|
+
name: "HvColorPickerNormal"
|
|
2090
2876
|
},
|
|
2091
2877
|
__name: "ColorPicker",
|
|
2092
|
-
props:
|
|
2093
|
-
|
|
2878
|
+
props: {
|
|
2879
|
+
modelValue: { default: DEFAULT_COLOR },
|
|
2880
|
+
disabled: { type: Boolean },
|
|
2881
|
+
enableAlpha: { type: Boolean, default: true },
|
|
2094
2882
|
presetTitle: {},
|
|
2095
2883
|
presetColors: {}
|
|
2096
|
-
},
|
|
2097
|
-
|
|
2098
|
-
type: String,
|
|
2099
|
-
default: DEFAULT_COLOR
|
|
2100
|
-
},
|
|
2101
|
-
"modelModifiers": {}
|
|
2102
|
-
}),
|
|
2103
|
-
emits: /* @__PURE__ */ vue.mergeModels(["update:model-value"], ["update:modelValue"]),
|
|
2884
|
+
},
|
|
2885
|
+
emits: ["update:model-value"],
|
|
2104
2886
|
setup(__props, { emit: __emit }) {
|
|
2105
|
-
const props = __props;
|
|
2106
2887
|
const emits = __emit;
|
|
2107
|
-
const
|
|
2108
|
-
const
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
const hex = getOriginHexByLightAndDepth(lightColor.value, colorDepth.value);
|
|
2115
|
-
return hex;
|
|
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);
|
|
2116
2895
|
}
|
|
2117
|
-
return DEFAULT_COLOR;
|
|
2118
2896
|
});
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
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();
|
|
2125
2905
|
});
|
|
2126
2906
|
vue.watch(
|
|
2127
|
-
|
|
2128
|
-
(
|
|
2129
|
-
|
|
2130
|
-
const
|
|
2131
|
-
|
|
2132
|
-
|
|
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
|
+
}
|
|
2133
2919
|
}
|
|
2134
|
-
const color22 = getColorByCoordinate(coordianate.x, coordianate.y, rect.width, rect.height);
|
|
2135
|
-
lightColor.value = color22;
|
|
2136
2920
|
},
|
|
2137
2921
|
{
|
|
2138
|
-
|
|
2922
|
+
immediate: true
|
|
2139
2923
|
}
|
|
2140
2924
|
);
|
|
2141
|
-
const
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
top: "100%",
|
|
2145
|
-
left: "0",
|
|
2146
|
-
backgroundColor: "#ffffff"
|
|
2147
|
-
};
|
|
2148
|
-
}
|
|
2149
|
-
return {
|
|
2150
|
-
top: circlePickerCoordinate.y + "px",
|
|
2151
|
-
left: circlePickerCoordinate.x + "px",
|
|
2152
|
-
backgroundColor: lightColor.value.hex()
|
|
2153
|
-
};
|
|
2925
|
+
const hueColor = vue.computed(() => {
|
|
2926
|
+
const color22 = Color$1({ h: hue.value, s: 100, v: 100 });
|
|
2927
|
+
return color22.hex();
|
|
2154
2928
|
});
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
return {
|
|
2158
|
-
"--el-slider-runway-bg-color": `linear-gradient(to right, #000000, ${lightHex})`,
|
|
2159
|
-
"--el-slider-main-bg-color": lightHex
|
|
2160
|
-
};
|
|
2929
|
+
vue.watch([hue, alpha, saturationv, value], () => {
|
|
2930
|
+
reCompColor();
|
|
2161
2931
|
});
|
|
2162
|
-
|
|
2163
|
-
()
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
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
|
|
2169
2941
|
}
|
|
2170
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
|
+
}
|
|
2171
2954
|
function handleColorChange(hex) {
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
const coordin = getCoordinateByColor(lightRgb);
|
|
2177
|
-
setCirclePickerCoordinate(coordin.x, coordin.y, canvasWidth, canvasHeight);
|
|
2955
|
+
if (props.disabled) {
|
|
2956
|
+
return;
|
|
2957
|
+
}
|
|
2958
|
+
color2.value = hex;
|
|
2178
2959
|
}
|
|
2179
|
-
vue.onMounted(() => {
|
|
2180
|
-
handleColorChange(color2.value);
|
|
2181
|
-
});
|
|
2182
2960
|
return (_ctx, _cache) => {
|
|
2183
2961
|
const _component_ElSlider = vue.resolveComponent("ElSlider");
|
|
2184
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
2185
|
-
vue.
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
vue.
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
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
|
+
])
|
|
2215
3017
|
]),
|
|
2216
|
-
vue.createVNode(
|
|
3018
|
+
vue.createVNode(ColorForm, {
|
|
2217
3019
|
"model-value": color2.value,
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
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, {
|
|
2221
3025
|
onChange: handleColorChange,
|
|
2222
3026
|
title: props.presetTitle,
|
|
2223
3027
|
presetColors: props.presetColors
|
|
@@ -2226,26 +3030,59 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2226
3030
|
};
|
|
2227
3031
|
}
|
|
2228
3032
|
});
|
|
2229
|
-
const
|
|
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);
|
|
3037
|
+
class EventBus {
|
|
3038
|
+
constructor() {
|
|
3039
|
+
__publicField(this, "_eventMap");
|
|
3040
|
+
this._eventMap = /* @__PURE__ */ new Map();
|
|
3041
|
+
}
|
|
3042
|
+
on(key, handler) {
|
|
3043
|
+
const handlers = this._eventMap.get(key);
|
|
3044
|
+
if (handlers) {
|
|
3045
|
+
handlers.add(handler);
|
|
3046
|
+
} else {
|
|
3047
|
+
const set = /* @__PURE__ */ new Set();
|
|
3048
|
+
set.add(handler);
|
|
3049
|
+
this._eventMap.set(key, set);
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
off(key, handler) {
|
|
3053
|
+
const handlers = this._eventMap.get(key);
|
|
3054
|
+
if (!handlers) return;
|
|
3055
|
+
if (handler) {
|
|
3056
|
+
handlers.delete(handler);
|
|
3057
|
+
} else {
|
|
3058
|
+
handlers.clear();
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
emit(key, ...payload) {
|
|
3062
|
+
const handlers = this._eventMap.get(key);
|
|
3063
|
+
if (!handlers) return;
|
|
3064
|
+
for (const callback of handlers.values()) {
|
|
3065
|
+
callback(...payload);
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
2230
3069
|
class DnDManager extends EventBus {
|
|
2231
3070
|
constructor() {
|
|
2232
3071
|
super();
|
|
2233
|
-
/** 是否开始拖动 */
|
|
3072
|
+
/** 是否开始拖动 | Whether to start dragging */
|
|
2234
3073
|
__publicField(this, "isDragStart", false);
|
|
2235
|
-
/** 拖动元素类型 */
|
|
3074
|
+
/** 拖动元素类型 | Drag type */
|
|
2236
3075
|
__publicField(this, "dragType");
|
|
2237
|
-
/** Draggable
|
|
2238
|
-
* 供Droppable使用
|
|
2239
|
-
*/
|
|
3076
|
+
/** Draggable传递的数据,供Droppable使用 | Draggable passes data for use by Droppable */
|
|
2240
3077
|
__publicField(this, "dragData");
|
|
2241
3078
|
__publicField(this, "isSendFirstMovePos", false);
|
|
2242
|
-
/**
|
|
3079
|
+
/** 长按一定时间才触发 onStart | Press and hold for a certain amount of time to trigger onStart */
|
|
2243
3080
|
__publicField(this, "touchStartPressTime", 300);
|
|
2244
|
-
/**
|
|
3081
|
+
/** 点击触发时的时间 | The time at which the click is triggered */
|
|
2245
3082
|
__publicField(this, "touchStartTime", 0);
|
|
2246
|
-
/**
|
|
3083
|
+
/** 点击触发的位置 | The position where the click event is triggered */
|
|
2247
3084
|
__publicField(this, "touchStartPosition", { x: 0, y: 0 });
|
|
2248
|
-
/** onMove最后位置 */
|
|
3085
|
+
/** onMove最后位置 | onMove last position */
|
|
2249
3086
|
__publicField(this, "lastMovePoint", { x: 0, y: 0 });
|
|
2250
3087
|
__publicField(this, "emitTouchStartTimer");
|
|
2251
3088
|
__publicField(this, "destroy", () => {
|
|
@@ -2263,14 +3100,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2263
3100
|
this.emitTouchStartTimer = void 0;
|
|
2264
3101
|
}
|
|
2265
3102
|
/**
|
|
2266
|
-
* 通知 Draggable 开始点击
|
|
3103
|
+
* 通知 Draggable 开始点击 | Tell Draggable to start clicking
|
|
2267
3104
|
* @param point
|
|
2268
3105
|
*/
|
|
2269
3106
|
onDown(point) {
|
|
2270
3107
|
this.emit("down", point);
|
|
2271
3108
|
}
|
|
2272
3109
|
/**
|
|
2273
|
-
*
|
|
3110
|
+
* 第一次移动时,通知 Draggable | On the first move, notify Draggable
|
|
2274
3111
|
* @param point
|
|
2275
3112
|
*/
|
|
2276
3113
|
onFirstMove(point, e) {
|
|
@@ -2281,7 +3118,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2281
3118
|
this.emit("first-move", point, e);
|
|
2282
3119
|
}
|
|
2283
3120
|
/**
|
|
2284
|
-
* 通知 Draggable 拖拽开始
|
|
3121
|
+
* 通知 Draggable 拖拽开始 | Notify Draggable to begin the drag
|
|
2285
3122
|
* @param point
|
|
2286
3123
|
*/
|
|
2287
3124
|
onStart(point) {
|
|
@@ -2291,7 +3128,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2291
3128
|
this.emit("start", point);
|
|
2292
3129
|
}
|
|
2293
3130
|
/**
|
|
2294
|
-
* 通知 Draggable 移动
|
|
3131
|
+
* 通知 Draggable 移动 | Notify Draggable to move
|
|
2295
3132
|
* @param point
|
|
2296
3133
|
* @returns
|
|
2297
3134
|
*/
|
|
@@ -2307,7 +3144,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2307
3144
|
});
|
|
2308
3145
|
}
|
|
2309
3146
|
/**
|
|
2310
|
-
* 结束拖拽
|
|
3147
|
+
* 结束拖拽 | Ending drag
|
|
2311
3148
|
* @returns
|
|
2312
3149
|
*/
|
|
2313
3150
|
onEnd() {
|
|
@@ -2432,15 +3269,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2432
3269
|
const onMouseDown = this.onMouseDown.bind(this);
|
|
2433
3270
|
const onMouseMove = this.onMouseMove.bind(this);
|
|
2434
3271
|
const onMouseUp = this.onMouseUp.bind(this);
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
document.body.addEventListener("mousemove", onMouseMove);
|
|
2442
|
-
document.body.addEventListener("mouseup", onMouseUp);
|
|
2443
|
-
}
|
|
3272
|
+
document.body.addEventListener("touchstart", onTouchStart, { passive: false });
|
|
3273
|
+
document.body.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
3274
|
+
document.body.addEventListener("touchend", onTouchEnd, { passive: false });
|
|
3275
|
+
document.body.addEventListener("mousedown", onMouseDown);
|
|
3276
|
+
document.body.addEventListener("mousemove", onMouseMove);
|
|
3277
|
+
document.body.addEventListener("mouseup", onMouseUp);
|
|
2444
3278
|
this.destroy = () => {
|
|
2445
3279
|
document.body.removeEventListener("touchstart", onTouchStart);
|
|
2446
3280
|
document.body.removeEventListener("touchmove", onTouchMove);
|
|
@@ -2464,7 +3298,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2464
3298
|
}
|
|
2465
3299
|
}
|
|
2466
3300
|
const DnDManagerInstance = new DnDManager();
|
|
2467
|
-
const _sfc_main$
|
|
3301
|
+
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
2468
3302
|
...{
|
|
2469
3303
|
name: "HvDraggable"
|
|
2470
3304
|
},
|
|
@@ -2506,7 +3340,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2506
3340
|
transform: `translate(${cloneNodePosition.x}px, ${cloneNodePosition.y}px) translate(-50%, -50%)`
|
|
2507
3341
|
};
|
|
2508
3342
|
});
|
|
2509
|
-
|
|
3343
|
+
const onDown = (params) => {
|
|
2510
3344
|
const { x, y } = params;
|
|
2511
3345
|
const startEl = document.elementFromPoint(x, y);
|
|
2512
3346
|
if (!props.disabled && dragItemRef.value && dragItemRef.value.contains(startEl)) {
|
|
@@ -2518,8 +3352,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2518
3352
|
downPosition.x = x;
|
|
2519
3353
|
downPosition.y = y;
|
|
2520
3354
|
}
|
|
2521
|
-
}
|
|
2522
|
-
|
|
3355
|
+
};
|
|
3356
|
+
const onFirstMove = (params, event) => {
|
|
2523
3357
|
const { x, y } = params;
|
|
2524
3358
|
const directions = immediateDirections.value.filter((item) => item !== ImmediateEnumType.ALL);
|
|
2525
3359
|
if (isDownThis.value && !props.disabled && directions.length) {
|
|
@@ -2545,21 +3379,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2545
3379
|
return;
|
|
2546
3380
|
}
|
|
2547
3381
|
}
|
|
2548
|
-
}
|
|
2549
|
-
|
|
3382
|
+
};
|
|
3383
|
+
const onStart = (params) => {
|
|
2550
3384
|
const { x, y } = params;
|
|
2551
3385
|
const startEl = document.elementFromPoint(x, y);
|
|
2552
3386
|
if (!props.disabled && dragItemRef.value && dragItemRef.value.contains(startEl)) {
|
|
2553
3387
|
handleStart(params);
|
|
2554
3388
|
}
|
|
2555
|
-
}
|
|
2556
|
-
|
|
3389
|
+
};
|
|
3390
|
+
const onMove = (params) => {
|
|
2557
3391
|
const { point } = params;
|
|
2558
3392
|
if (isDragThis.value) {
|
|
2559
3393
|
handleMove(point);
|
|
2560
3394
|
}
|
|
2561
|
-
}
|
|
2562
|
-
|
|
3395
|
+
};
|
|
3396
|
+
const onEnd = () => {
|
|
2563
3397
|
isDownThis.value = false;
|
|
2564
3398
|
isDragThis.value = false;
|
|
2565
3399
|
Object.assign(downPosition, {
|
|
@@ -2570,7 +3404,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2570
3404
|
x: 0,
|
|
2571
3405
|
y: 0
|
|
2572
3406
|
});
|
|
2573
|
-
}
|
|
3407
|
+
};
|
|
2574
3408
|
function handleStart(point) {
|
|
2575
3409
|
isDragThis.value = true;
|
|
2576
3410
|
cloneNodePosition.x = point.x;
|
|
@@ -2581,6 +3415,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2581
3415
|
cloneNodePosition.x = point.x;
|
|
2582
3416
|
cloneNodePosition.y = point.y;
|
|
2583
3417
|
}
|
|
3418
|
+
vue.onMounted(() => {
|
|
3419
|
+
DnDManagerInstance.on("down", onDown);
|
|
3420
|
+
DnDManagerInstance.on("first-move", onFirstMove);
|
|
3421
|
+
DnDManagerInstance.on("start", onStart);
|
|
3422
|
+
DnDManagerInstance.on("move", onMove);
|
|
3423
|
+
DnDManagerInstance.on("end", onEnd);
|
|
3424
|
+
});
|
|
3425
|
+
vue.onBeforeUnmount(() => {
|
|
3426
|
+
DnDManagerInstance.off("down", onDown);
|
|
3427
|
+
DnDManagerInstance.off("first-move", onFirstMove);
|
|
3428
|
+
DnDManagerInstance.off("start", onStart);
|
|
3429
|
+
DnDManagerInstance.off("move", onMove);
|
|
3430
|
+
DnDManagerInstance.off("end", onEnd);
|
|
3431
|
+
});
|
|
2584
3432
|
return (_ctx, _cache) => {
|
|
2585
3433
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2586
3434
|
ref_key: "dragItemRef",
|
|
@@ -2593,7 +3441,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2593
3441
|
class: "hv-draggable__clone-item",
|
|
2594
3442
|
style: vue.normalizeStyle(cloneNodeStyle.value)
|
|
2595
3443
|
}, [
|
|
2596
|
-
vue.renderSlot(_ctx.$slots, "
|
|
3444
|
+
vue.renderSlot(_ctx.$slots, "drag-item", {}, () => [
|
|
2597
3445
|
vue.renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
2598
3446
|
], true)
|
|
2599
3447
|
], 4)) : vue.createCommentVNode("", true)
|
|
@@ -2601,21 +3449,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2601
3449
|
};
|
|
2602
3450
|
}
|
|
2603
3451
|
});
|
|
2604
|
-
const
|
|
2605
|
-
|
|
2606
|
-
for (const [key, val] of props) {
|
|
2607
|
-
target[key] = val;
|
|
2608
|
-
}
|
|
2609
|
-
return target;
|
|
2610
|
-
};
|
|
2611
|
-
const Draggable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-1d116395"]]);
|
|
2612
|
-
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({
|
|
2613
3454
|
...{
|
|
2614
3455
|
name: "HvDroppable"
|
|
2615
3456
|
},
|
|
2616
3457
|
__name: "Droppable",
|
|
2617
3458
|
props: {
|
|
2618
|
-
acceptDragType: {}
|
|
3459
|
+
acceptDragType: {},
|
|
3460
|
+
disabled: { type: Boolean }
|
|
2619
3461
|
},
|
|
2620
3462
|
emits: ["enter", "move", "drop", "leave"],
|
|
2621
3463
|
setup(__props, { emit: __emit }) {
|
|
@@ -2648,7 +3490,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2648
3490
|
}
|
|
2649
3491
|
};
|
|
2650
3492
|
}
|
|
2651
|
-
|
|
3493
|
+
const onMove = (params) => {
|
|
3494
|
+
if (props.disabled) {
|
|
3495
|
+
return;
|
|
3496
|
+
}
|
|
2652
3497
|
const { type, data, point } = params;
|
|
2653
3498
|
if (dropAreaRef.value && acceptDragTypeList.value.includes(type)) {
|
|
2654
3499
|
const { isInArea, position } = getPositionInArea(point);
|
|
@@ -2664,12 +3509,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2664
3509
|
emits("leave", type, data);
|
|
2665
3510
|
}
|
|
2666
3511
|
}
|
|
2667
|
-
}
|
|
2668
|
-
|
|
3512
|
+
};
|
|
3513
|
+
const onEnd = ({ type, point, data }) => {
|
|
3514
|
+
if (props.disabled) {
|
|
3515
|
+
return;
|
|
3516
|
+
}
|
|
2669
3517
|
if (dropAreaRef.value && acceptDragTypeList.value.includes(type) && isEntered.value) {
|
|
2670
3518
|
const { position } = getPositionInArea(point);
|
|
2671
3519
|
emits("drop", type, position, data);
|
|
2672
3520
|
}
|
|
3521
|
+
};
|
|
3522
|
+
vue.onMounted(() => {
|
|
3523
|
+
DnDManagerInstance.on("move", onMove);
|
|
3524
|
+
DnDManagerInstance.on("end", onEnd);
|
|
3525
|
+
});
|
|
3526
|
+
vue.onBeforeUnmount(() => {
|
|
3527
|
+
DnDManagerInstance.off("move", onMove);
|
|
3528
|
+
DnDManagerInstance.off("end", onEnd);
|
|
2673
3529
|
});
|
|
2674
3530
|
return (_ctx, _cache) => {
|
|
2675
3531
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
@@ -2683,7 +3539,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2683
3539
|
}
|
|
2684
3540
|
});
|
|
2685
3541
|
const HvDraggable = withInstall(Draggable);
|
|
2686
|
-
const HvDroppable = withInstall(_sfc_main$
|
|
3542
|
+
const HvDroppable = withInstall(_sfc_main$2);
|
|
2687
3543
|
function useDragAndScale(target, operateTarget, options) {
|
|
2688
3544
|
const _options = vue.computed(() => {
|
|
2689
3545
|
return vue.isRef(options) ? vue.toValue(options) : options;
|
|
@@ -3123,31 +3979,25 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3123
3979
|
}
|
|
3124
3980
|
function bindEvent() {
|
|
3125
3981
|
removeEvent();
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
} else {
|
|
3129
|
-
_operateEl.value.addEventListener("mousedown", onMouseDown);
|
|
3130
|
-
}
|
|
3982
|
+
_operateEl.value.addEventListener("touchstart", onTouchStart, { capture: true });
|
|
3983
|
+
_operateEl.value.addEventListener("mousedown", onMouseDown);
|
|
3131
3984
|
}
|
|
3132
3985
|
function removeEvent() {
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
document.body.removeEventListener("mousemove", onMouseMove);
|
|
3141
|
-
document.body.removeEventListener("mouseup", onMouseUp);
|
|
3142
|
-
}
|
|
3986
|
+
_operateEl.value.removeEventListener("touchstart", onTouchStart);
|
|
3987
|
+
document.body.removeEventListener("touchmove", onTouchMove);
|
|
3988
|
+
document.body.removeEventListener("touchend", onTouchEnd);
|
|
3989
|
+
document.body.removeEventListener("touchcancel", onTouchEnd);
|
|
3990
|
+
_operateEl.value.removeEventListener("mousedown", onMouseDown);
|
|
3991
|
+
document.body.removeEventListener("mousemove", onMouseMove);
|
|
3992
|
+
document.body.removeEventListener("mouseup", onMouseUp);
|
|
3143
3993
|
}
|
|
3144
3994
|
vue.onBeforeUnmount(() => {
|
|
3145
3995
|
isOperateStart = false;
|
|
3146
3996
|
removeEvent();
|
|
3147
3997
|
});
|
|
3148
3998
|
}
|
|
3149
|
-
const _hoisted_1 = { class: "hv-drag-and-scale__zoom-mark" };
|
|
3150
|
-
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({
|
|
3151
4001
|
...{
|
|
3152
4002
|
name: "HvDragAndScale"
|
|
3153
4003
|
},
|
|
@@ -3190,7 +4040,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3190
4040
|
ref: targetRef
|
|
3191
4041
|
}, [
|
|
3192
4042
|
vue.renderSlot(_ctx.$slots, "default"),
|
|
3193
|
-
vue.createElementVNode("div", _hoisted_1, [
|
|
4043
|
+
vue.createElementVNode("div", _hoisted_1$1, [
|
|
3194
4044
|
vue.createElementVNode("div", {
|
|
3195
4045
|
class: vue.normalizeClass(["hv-drag-and-scale__area-box", props.disabled ? "disabled" : ""]),
|
|
3196
4046
|
ref_key: "operateRef",
|
|
@@ -3203,10 +4053,165 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3203
4053
|
};
|
|
3204
4054
|
}
|
|
3205
4055
|
});
|
|
3206
|
-
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;
|
|
3207
4209
|
exports2.HvColorPicker = HvColorPicker;
|
|
4210
|
+
exports2.HvColorPickerNormal = HvColorPickerNormal;
|
|
4211
|
+
exports2.HvColorPickerRainbow = HvColorPickerRainbow;
|
|
3208
4212
|
exports2.HvDragAndScale = HvDragAndScale;
|
|
3209
4213
|
exports2.HvDraggable = HvDraggable;
|
|
3210
4214
|
exports2.HvDroppable = HvDroppable;
|
|
4215
|
+
exports2.HvIpInput = HvIpInput;
|
|
3211
4216
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
3212
4217
|
});
|