@aurouscia/au-color-picker 1.0.1 → 1.0.2-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/au-color-picker.css +1 -1
- package/dist/au-color-picker.es.js +259 -243
- package/package.json +1 -1
package/dist/au-color-picker.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.acpRingBody[data-v-
|
|
1
|
+
.acpRingBody[data-v-a9c85b21]{position:relative}canvas[data-v-a9c85b21]{position:absolute;inset:0;width:100%;height:100%}[data-v-dc351014]{margin:0;padding:0}.acpSep[data-v-dc351014]{height:2px;border-radius:100px;flex-grow:0;flex-shrink:0;background-color:#ddd}.acpPresetBody[data-v-dc351014]{width:25px;height:25px;border-radius:1000px;cursor:pointer}.acpDoneBtn[data-v-dc351014]{display:flex;justify-content:center;align-items:center;margin:8px;-webkit-user-select:none;user-select:none}.acpDoneBtn button[data-v-dc351014]{background:none;border:none;font-weight:700;color:gray;font-size:16px;cursor:pointer}.acpDoneBtn button[data-v-dc351014]:hover{color:#000}.acpEntry[data-v-dc351014]{width:30px;height:30px;cursor:pointer;border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acpPanel[data-v-dc351014]{border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff;margin-top:3px;position:absolute}.acp[data-v-dc351014]{position:relative;width:fit-content}.acp label[data-v-dc351014]{-webkit-user-select:none;user-select:none;white-space:nowrap;cursor:pointer}.acp input[type=radio][data-v-dc351014]{cursor:pointer}.acpPackageName[data-v-dc351014]{position:absolute;left:2px;bottom:3px;font-size:8px;color:#ccc;text-align:right;cursor:pointer;-webkit-user-select:none;user-select:none}.acpParams[data-v-dc351014]{display:flex;justify-content:space-between;align-items:center;padding:5px}.acpParams select[data-v-dc351014],.acpParams input[data-v-dc351014]{margin:0;padding:2px;display:block;font-size:16px;box-sizing:border-box;height:24px;line-height:24px}.acpParams select[data-v-dc351014]{-webkit-user-select:none;user-select:none}.acpParams input[data-v-dc351014]{text-align:center}.acpParams .acpSingleInput input[data-v-dc351014]{width:120px}.acpParams .acpTripleInputs[data-v-dc351014]{display:flex;justify-content:space-around}.acpParams .acpTripleInputs input[data-v-dc351014]{width:40px}[data-v-1e965bbc]{margin:0;padding:0}.acpSep[data-v-1e965bbc]{height:2px;border-radius:100px;flex-grow:0;flex-shrink:0;background-color:#ddd}.acpPresetBody[data-v-1e965bbc]{width:25px;height:25px;border-radius:1000px;cursor:pointer}.acpDoneBtn[data-v-1e965bbc]{display:flex;justify-content:center;align-items:center;margin:8px;-webkit-user-select:none;user-select:none}.acpDoneBtn button[data-v-1e965bbc]{background:none;border:none;font-weight:700;color:gray;font-size:16px;cursor:pointer}.acpDoneBtn button[data-v-1e965bbc]:hover{color:#000}.acpEntry[data-v-1e965bbc]{width:30px;height:30px;cursor:pointer;border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acpPanel[data-v-1e965bbc]{border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff;margin-top:3px;position:absolute}.acp[data-v-1e965bbc]{position:relative;width:fit-content}.acp label[data-v-1e965bbc]{-webkit-user-select:none;user-select:none;white-space:nowrap;cursor:pointer}.acp input[type=radio][data-v-1e965bbc]{cursor:pointer}.acpNamedPresets[data-v-1e965bbc]{margin:5px;display:flex;flex-direction:column;gap:4px}.acpNamedPresets[data-v-1e965bbc]>*{display:flex;justify-content:flex-start;align-items:center;gap:5px}.acpNamedPresets>* .acpPresetName[data-v-1e965bbc]{color:#666}.acpNamedPresets>* .acpPresetName[data-v-1e965bbc]:hover{color:#000}
|
|
@@ -1,199 +1,215 @@
|
|
|
1
|
-
import { defineComponent as te, ref as I, onMounted as ye, onUnmounted as
|
|
2
|
-
import
|
|
3
|
-
function Ie(
|
|
4
|
-
const m =
|
|
5
|
-
return m ** 2 +
|
|
1
|
+
import { defineComponent as te, ref as I, onMounted as ye, onUnmounted as he, createElementBlock as N, openBlock as R, normalizeStyle as j, isRef as xe, createElementVNode as c, computed as F, onBeforeMount as ue, watch as W, createCommentVNode as G, unref as x, normalizeClass as Pe, createVNode as ce, withDirectives as Q, vModelSelect as ke, vModelRadio as oe, Fragment as Ce, renderList as Se, toDisplayString as we } from "vue";
|
|
2
|
+
import M from "color-convert";
|
|
3
|
+
function Ie(i, h) {
|
|
4
|
+
const m = i.x - h.x, o = i.y - h.y;
|
|
5
|
+
return m ** 2 + o ** 2;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
const m =
|
|
9
|
-
return Math.atan2(
|
|
7
|
+
function Be(i, h) {
|
|
8
|
+
const m = i.x - h.x, o = i.y - h.y;
|
|
9
|
+
return Math.atan2(o, m);
|
|
10
10
|
}
|
|
11
|
-
const
|
|
11
|
+
const T = 400, O = 400, Y = 200, be = 200, le = 190, se = 150, _ = 200, ae = 16, ie = 3, Ve = /* @__PURE__ */ te({
|
|
12
12
|
__name: "AuColorPickerRing",
|
|
13
13
|
props: {
|
|
14
14
|
initialHex: {}
|
|
15
15
|
},
|
|
16
16
|
emits: ["changed"],
|
|
17
|
-
setup(
|
|
18
|
-
const
|
|
17
|
+
setup(i, { expose: h, emit: m }) {
|
|
18
|
+
const o = I(), g = I();
|
|
19
19
|
let u, d;
|
|
20
|
-
const k = { x: 199, y: 199 },
|
|
21
|
-
let
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const k = { x: 199, y: 199 }, A = (le + se) / 2, $ = le ** 2, U = se ** 2, b = (T - _) / 2, H = b + _, P = I(0), S = I(100), w = I(100), V = i;
|
|
21
|
+
let s;
|
|
22
|
+
function r() {
|
|
23
|
+
try {
|
|
24
|
+
const l = o.value?.getContext("2d"), e = g.value?.getContext("2d");
|
|
25
|
+
if (!l || !e)
|
|
26
|
+
throw Error("canvas context getting error");
|
|
27
|
+
if (V.initialHex) {
|
|
28
|
+
const n = M.hex.hsv(V.initialHex);
|
|
29
|
+
P.value = n[0], S.value = n[1], w.value = n[2];
|
|
30
|
+
}
|
|
31
|
+
u = l, d = e, s = u.createImageData(T, O), p(), y(), K(), createImageBitmap(s).then((n) => {
|
|
32
|
+
u.drawImage(n, 0, 0);
|
|
33
|
+
});
|
|
34
|
+
} catch (l) {
|
|
35
|
+
const e = document.createElement("div");
|
|
36
|
+
e.innerText = JSON.stringify(l), document.documentElement.appendChild(e);
|
|
29
37
|
}
|
|
30
|
-
u = s, d = a, n = u.getImageData(0, 0, D, _), f(), y(), Y(), u.putImageData(n, 0, 0);
|
|
31
38
|
}
|
|
32
|
-
function
|
|
33
|
-
for (let
|
|
34
|
-
for (let
|
|
35
|
-
const
|
|
36
|
-
if (X(
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
+
function p() {
|
|
40
|
+
for (let l = 0; l < T; l++)
|
|
41
|
+
for (let e = 0; e < O; e++) {
|
|
42
|
+
const n = { x: l, y: e };
|
|
43
|
+
if (X(n)) {
|
|
44
|
+
const f = n.y * T * 4 + n.x * 4, B = D(n), q = M.hsv.rgb([B, 100, 100]);
|
|
45
|
+
s.data[f] = q[0], s.data[f + 1] = q[1], s.data[f + 2] = q[2], s.data[f + 3] = 255;
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
|
-
function
|
|
43
|
-
return 360 * ((
|
|
49
|
+
function D(l) {
|
|
50
|
+
return 360 * ((Be(l, k) + Math.PI) / (2 * Math.PI));
|
|
44
51
|
}
|
|
45
|
-
function X(
|
|
46
|
-
const
|
|
47
|
-
return
|
|
52
|
+
function X(l) {
|
|
53
|
+
const e = Ie(k, l);
|
|
54
|
+
return e > U && e < $;
|
|
48
55
|
}
|
|
49
56
|
function y() {
|
|
50
|
-
for (let
|
|
51
|
-
for (let
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
|
|
57
|
+
for (let l = 0; l < T; l++)
|
|
58
|
+
for (let e = 0; e < O; e++) {
|
|
59
|
+
const n = { x: l, y: e };
|
|
60
|
+
if (a(n)) {
|
|
61
|
+
const f = n.y * T * 4 + n.x * 4, { s: B, v: q } = t(n), L = M.hsv.rgb([P.value, B, q]);
|
|
62
|
+
s.data[f] = L[0], s.data[f + 1] = L[1], s.data[f + 2] = L[2], s.data[f + 3] = 255;
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
|
-
function
|
|
60
|
-
const
|
|
61
|
-
let
|
|
62
|
-
return
|
|
66
|
+
function t(l) {
|
|
67
|
+
const e = l.x - b, n = l.y - b;
|
|
68
|
+
let f = e / _, B = 1 - n / _;
|
|
69
|
+
return f > 1 ? f = 1 : f < 0 && (f = 0), B > 1 ? B = 1 : B < 0 && (B = 0), { s: 100 * f, v: 100 * B };
|
|
63
70
|
}
|
|
64
|
-
function
|
|
65
|
-
return !(
|
|
71
|
+
function a(l) {
|
|
72
|
+
return !(l.x < b || l.x > H || l.y < b || l.y > H);
|
|
66
73
|
}
|
|
67
|
-
let
|
|
68
|
-
function
|
|
69
|
-
if (
|
|
74
|
+
let E = !1, v = "none", C = I(!1);
|
|
75
|
+
function J(l, e) {
|
|
76
|
+
if (E || e && !C.value)
|
|
70
77
|
return;
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
if (v === "none" && (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
E = !0;
|
|
79
|
+
const n = fe(l);
|
|
80
|
+
if (v === "none" && (a(n) ? v = "square" : X(n) && (v = "ring")), v === "ring" && (l.preventDefault(), P.value = D(n), y(), createImageBitmap(s).then((f) => {
|
|
81
|
+
u.drawImage(f, 0, 0);
|
|
82
|
+
})), v === "square") {
|
|
83
|
+
l.preventDefault();
|
|
84
|
+
const f = t(n);
|
|
85
|
+
S.value = f.s, w.value = f.v;
|
|
77
86
|
}
|
|
78
|
-
v !== "none" &&
|
|
87
|
+
v !== "none" && K(!0), E = !1;
|
|
79
88
|
}
|
|
80
89
|
function Z() {
|
|
81
90
|
v = "none", C.value = !1;
|
|
82
91
|
}
|
|
83
|
-
function fe(
|
|
84
|
-
let
|
|
85
|
-
if (!
|
|
92
|
+
function fe(l) {
|
|
93
|
+
let e, n;
|
|
94
|
+
if (!o.value)
|
|
86
95
|
return { x: -1, y: -1 };
|
|
87
|
-
if ("touches" in
|
|
88
|
-
const
|
|
89
|
-
|
|
96
|
+
if ("touches" in l) {
|
|
97
|
+
const f = o.value.getBoundingClientRect();
|
|
98
|
+
e = l.touches[0].clientX - f.left, n = l.touches[0].clientY - f.top;
|
|
90
99
|
} else
|
|
91
|
-
|
|
92
|
-
return
|
|
100
|
+
e = l.offsetX, n = l.offsetY;
|
|
101
|
+
return e = e * T / Y, n = n * T / Y, { x: e, y: n };
|
|
93
102
|
}
|
|
94
|
-
function
|
|
95
|
-
if (
|
|
96
|
-
const ge =
|
|
103
|
+
function K(l) {
|
|
104
|
+
if (l) {
|
|
105
|
+
const ge = M.hsv.hex([P.value, S.value, w.value]);
|
|
97
106
|
me("changed", ge);
|
|
98
107
|
}
|
|
99
|
-
const
|
|
100
|
-
d.reset(), d.lineWidth = 4, d.strokeStyle = "black", d.beginPath(), d.arc(
|
|
108
|
+
const e = (P.value / 360 * 2 + 1) * Math.PI, n = Math.cos(e) * A + T / 2, f = Math.sin(e) * A + O / 2, B = S.value / 100 * _ + b, q = (1 - w.value / 100) * _ + b;
|
|
109
|
+
d.reset(), d.lineWidth = 4, d.strokeStyle = "black", d.beginPath(), d.arc(n, f, ae - 2, 0, 2 * Math.PI), d.stroke(), d.beginPath(), d.arc(n, f, ie, 0, 2 * Math.PI), d.fill();
|
|
101
110
|
const L = w.value > 50 ? "black" : "#ddd";
|
|
102
|
-
d.strokeStyle = L, d.fillStyle = L, d.beginPath(), d.arc(
|
|
111
|
+
d.strokeStyle = L, d.fillStyle = L, d.beginPath(), d.arc(B, q, ae - 2, 0, 2 * Math.PI), d.stroke(), d.beginPath(), d.arc(B, q, ie, 0, 2 * Math.PI), d.fill();
|
|
103
112
|
}
|
|
104
|
-
function pe(
|
|
105
|
-
|
|
106
|
-
|
|
113
|
+
function pe(l) {
|
|
114
|
+
try {
|
|
115
|
+
const e = M.hex.hsv(l);
|
|
116
|
+
throw P.value = e[0], S.value = e[1], w.value = e[2], y(), createImageBitmap(s).then((n) => {
|
|
117
|
+
u.drawImage(n, 0, 0);
|
|
118
|
+
}), K(), new Error("hi");
|
|
119
|
+
} catch (e) {
|
|
120
|
+
const n = document.createElement("div");
|
|
121
|
+
console.error(e.message), n.innerText = JSON.stringify(e.message), document.documentElement.appendChild(n);
|
|
122
|
+
}
|
|
107
123
|
}
|
|
108
124
|
const me = m;
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
}),
|
|
125
|
+
return h({ enforceTo: pe }), ye(() => {
|
|
126
|
+
r(), window.addEventListener("touchend", Z), window.addEventListener("mouseup", Z);
|
|
127
|
+
}), he(() => {
|
|
112
128
|
window.removeEventListener("touchend", Z), window.removeEventListener("mouseup", Z);
|
|
113
|
-
}), (
|
|
129
|
+
}), (l, e) => (R(), N("div", {
|
|
114
130
|
class: "acpRingBody",
|
|
115
|
-
style: j({ width:
|
|
116
|
-
onTouchstart:
|
|
117
|
-
onTouchmove:
|
|
131
|
+
style: j({ width: Y + "px", height: be + "px" }),
|
|
132
|
+
onTouchstart: J,
|
|
133
|
+
onTouchmove: J,
|
|
118
134
|
onTouchend: Z,
|
|
119
|
-
onMousemove:
|
|
120
|
-
onMousedown:
|
|
121
|
-
|
|
135
|
+
onMousemove: e[0] || (e[0] = (n) => J(n, !0)),
|
|
136
|
+
onMousedown: e[1] || (e[1] = (n) => {
|
|
137
|
+
J(n), xe(C) ? C.value = !0 : C = !0;
|
|
122
138
|
})
|
|
123
139
|
}, [
|
|
124
140
|
c("canvas", {
|
|
125
|
-
width:
|
|
126
|
-
height:
|
|
141
|
+
width: T,
|
|
142
|
+
height: O,
|
|
127
143
|
ref_key: "cvs",
|
|
128
|
-
ref:
|
|
144
|
+
ref: o
|
|
129
145
|
}, null, 512),
|
|
130
146
|
c("canvas", {
|
|
131
|
-
width:
|
|
132
|
-
height:
|
|
147
|
+
width: T,
|
|
148
|
+
height: O,
|
|
133
149
|
ref_key: "cursorCvs",
|
|
134
150
|
ref: g
|
|
135
151
|
}, null, 512)
|
|
136
152
|
], 36));
|
|
137
153
|
}
|
|
138
|
-
}), ne = (
|
|
139
|
-
const m =
|
|
140
|
-
for (const [
|
|
141
|
-
m[
|
|
154
|
+
}), ne = (i, h) => {
|
|
155
|
+
const m = i.__vccOpts || i;
|
|
156
|
+
for (const [o, g] of h)
|
|
157
|
+
m[o] = g;
|
|
142
158
|
return m;
|
|
143
|
-
},
|
|
144
|
-
function ee(
|
|
145
|
-
return /^#([0-9A-F]{3}){1,2}$/i.test(
|
|
159
|
+
}, Te = /* @__PURE__ */ ne(Ve, [["__scopeId", "data-v-a9c85b21"]]);
|
|
160
|
+
function ee(i) {
|
|
161
|
+
return /^#([0-9A-F]{3}){1,2}$/i.test(i);
|
|
146
162
|
}
|
|
147
|
-
function de(
|
|
148
|
-
const m = I(!1),
|
|
163
|
+
function de(i, h) {
|
|
164
|
+
const m = I(!1), o = F(() => {
|
|
149
165
|
let k = {};
|
|
150
|
-
return m.value || (k.boxShadow = "none"),
|
|
166
|
+
return m.value || (k.boxShadow = "none"), i.entryStyles && Object.assign(k, i.entryStyles), m.value && (k.transition = "0s", Object.assign(k, i.entryActiveStyles)), k.backgroundColor = h.value, k;
|
|
151
167
|
});
|
|
152
168
|
function g() {
|
|
153
169
|
m.value = !1;
|
|
154
170
|
}
|
|
155
171
|
let u = 0;
|
|
156
172
|
function d() {
|
|
157
|
-
if (
|
|
173
|
+
if (i.entryRespondDelay && (window.clearTimeout(u), !m.value)) {
|
|
158
174
|
u = window.setTimeout(() => {
|
|
159
175
|
m.value = !0;
|
|
160
|
-
},
|
|
176
|
+
}, i.entryRespondDelay);
|
|
161
177
|
return;
|
|
162
178
|
}
|
|
163
179
|
m.value = !m.value;
|
|
164
180
|
}
|
|
165
|
-
return { panelShow: m, closePanel: g, togglePanel: d, entryStylesActual:
|
|
181
|
+
return { panelShow: m, closePanel: g, togglePanel: d, entryStylesActual: o };
|
|
166
182
|
}
|
|
167
183
|
function re() {
|
|
168
184
|
window.alert("https://www.npmjs.com/package/@aurouscia/au-color-picker");
|
|
169
185
|
}
|
|
170
|
-
function
|
|
171
|
-
return
|
|
186
|
+
function z(i) {
|
|
187
|
+
return i.startsWith("#") ? i.toUpperCase() : "#" + i.toUpperCase();
|
|
172
188
|
}
|
|
173
|
-
function ve(
|
|
189
|
+
function ve(i) {
|
|
174
190
|
return {
|
|
175
191
|
panelStyles: F(() => {
|
|
176
|
-
const m =
|
|
177
|
-
let
|
|
178
|
-
const u =
|
|
179
|
-
return typeof u == "number" ?
|
|
192
|
+
const m = i.panelBaseZIndex;
|
|
193
|
+
let o, g;
|
|
194
|
+
const u = i.pos;
|
|
195
|
+
return typeof u == "number" ? o = u + "px" : u == "left" ? g = "0px" : o = "0px", {
|
|
180
196
|
zIndex: (m || 0) + 100,
|
|
181
|
-
left:
|
|
197
|
+
left: o,
|
|
182
198
|
right: g
|
|
183
199
|
};
|
|
184
200
|
})
|
|
185
201
|
};
|
|
186
202
|
}
|
|
187
|
-
const
|
|
203
|
+
const Ne = { class: "acp" }, Re = { class: "acpRing" }, De = { class: "acpParams" }, He = {
|
|
188
204
|
key: 0,
|
|
189
205
|
class: "acpSingleInput"
|
|
190
|
-
},
|
|
206
|
+
}, Ee = ["value"], Me = {
|
|
191
207
|
key: 1,
|
|
192
208
|
class: "acpTripleInputs"
|
|
193
|
-
},
|
|
209
|
+
}, Ae = ["value"], $e = ["value"], qe = ["value"], Ue = {
|
|
194
210
|
key: 2,
|
|
195
211
|
class: "acpTripleInputs"
|
|
196
|
-
}, Le = ["value"],
|
|
212
|
+
}, Le = ["value"], Oe = ["value"], _e = ["value"], ze = { class: "acpDoneBtn" }, We = /* @__PURE__ */ te({
|
|
197
213
|
__name: "AuColorPicker",
|
|
198
214
|
props: {
|
|
199
215
|
modelValue: {},
|
|
@@ -208,160 +224,160 @@ const Te = { class: "acp" }, Ne = { class: "acpRing" }, Re = { class: "acpParams
|
|
|
208
224
|
showPackageName: { type: Boolean }
|
|
209
225
|
},
|
|
210
226
|
emits: ["done", "update:modelValue"],
|
|
211
|
-
setup(
|
|
212
|
-
const
|
|
227
|
+
setup(i, { expose: h, emit: m }) {
|
|
228
|
+
const o = i, g = I(), u = I("#ff0000"), { panelShow: d, closePanel: k, togglePanel: A, entryStylesActual: $ } = de(o, u), { panelStyles: U } = ve(o);
|
|
213
229
|
function b(y) {
|
|
214
|
-
u.value =
|
|
230
|
+
u.value = z(y), r();
|
|
215
231
|
}
|
|
216
|
-
const H = I("hex"),
|
|
232
|
+
const H = I("hex"), P = F(() => M.hex.rgb(u.value)), S = F(() => M.hex.hsv(u.value));
|
|
217
233
|
function w(y) {
|
|
218
|
-
const
|
|
219
|
-
if ("value" in
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
222
|
-
u.value =
|
|
234
|
+
const t = y.target;
|
|
235
|
+
if ("value" in t) {
|
|
236
|
+
const a = t.value;
|
|
237
|
+
if (a && ee(a)) {
|
|
238
|
+
u.value = z(a), g.value?.enforceTo(u.value), r();
|
|
223
239
|
return;
|
|
224
240
|
}
|
|
225
|
-
|
|
241
|
+
t.value = u.value;
|
|
226
242
|
}
|
|
227
243
|
}
|
|
228
|
-
function
|
|
229
|
-
const
|
|
230
|
-
if ("value" in
|
|
231
|
-
const
|
|
232
|
-
if (
|
|
233
|
-
let v = parseInt(
|
|
244
|
+
function V(y, t) {
|
|
245
|
+
const a = y.target;
|
|
246
|
+
if ("value" in a) {
|
|
247
|
+
const E = a.value;
|
|
248
|
+
if (E) {
|
|
249
|
+
let v = parseInt(E);
|
|
234
250
|
if (isNaN(v))
|
|
235
|
-
|
|
251
|
+
a.value = "0";
|
|
236
252
|
else {
|
|
237
253
|
v > 255 ? v = 255 : v < 0 && (v = 0);
|
|
238
|
-
const C = [...
|
|
239
|
-
|
|
254
|
+
const C = [...P.value];
|
|
255
|
+
t == "r" ? C[0] = v : t == "g" ? C[1] = v : C[2] = v, u.value = z(M.rgb.hex(C)), g.value?.enforceTo(u.value), a.value = v.toString(), r();
|
|
240
256
|
return;
|
|
241
257
|
}
|
|
242
258
|
}
|
|
243
259
|
}
|
|
244
260
|
}
|
|
245
|
-
function
|
|
246
|
-
const
|
|
247
|
-
if ("value" in
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
250
|
-
let v = parseInt(
|
|
261
|
+
function s(y, t) {
|
|
262
|
+
const a = y.target;
|
|
263
|
+
if ("value" in a) {
|
|
264
|
+
const E = a.value;
|
|
265
|
+
if (E) {
|
|
266
|
+
let v = parseInt(E);
|
|
251
267
|
if (isNaN(v))
|
|
252
|
-
|
|
268
|
+
a.value = "0";
|
|
253
269
|
else {
|
|
254
|
-
|
|
270
|
+
t === "h" ? v > 359 && (v = 359) : v > 100 && (v = 100), v < 0 && (v = 0);
|
|
255
271
|
const C = [...S.value];
|
|
256
|
-
|
|
272
|
+
t == "h" ? C[0] = v : t == "s" ? C[1] = v : C[2] = v, u.value = z(M.hsv.hex(C)), a.value = v.toString(), g.value?.enforceTo(u.value), r();
|
|
257
273
|
return;
|
|
258
274
|
}
|
|
259
275
|
}
|
|
260
276
|
}
|
|
261
277
|
}
|
|
262
|
-
function
|
|
278
|
+
function r() {
|
|
263
279
|
X("update:modelValue", u.value);
|
|
264
280
|
}
|
|
265
|
-
function
|
|
281
|
+
function p() {
|
|
266
282
|
return u.value;
|
|
267
283
|
}
|
|
268
|
-
function
|
|
284
|
+
function D(y) {
|
|
269
285
|
if (ee(y)) {
|
|
270
|
-
const
|
|
271
|
-
u.value =
|
|
286
|
+
const t = z(y);
|
|
287
|
+
u.value = t, g.value?.enforceTo(t);
|
|
272
288
|
}
|
|
273
289
|
}
|
|
274
290
|
ue(() => {
|
|
275
|
-
|
|
291
|
+
o.modelValue ? D(o.modelValue) : o.initial && D(o.initial);
|
|
276
292
|
});
|
|
277
293
|
const X = m;
|
|
278
|
-
return
|
|
279
|
-
y && y !== u.value &&
|
|
294
|
+
return h({ closePanel: k, getCurrentHex: p, enforceTo: D }), W(() => o.modelValue, (y) => {
|
|
295
|
+
y && y !== u.value && D(y);
|
|
280
296
|
}), W(d, (y) => {
|
|
281
297
|
y === !1 && X("done");
|
|
282
|
-
}), (y,
|
|
298
|
+
}), (y, t) => (R(), N("div", Ne, [
|
|
283
299
|
c("div", {
|
|
284
|
-
class:
|
|
285
|
-
style: j(
|
|
286
|
-
onClick:
|
|
287
|
-
(...
|
|
300
|
+
class: Pe(i.entryClassName || "acpEntry"),
|
|
301
|
+
style: j(x($)),
|
|
302
|
+
onClick: t[0] || (t[0] = //@ts-ignore
|
|
303
|
+
(...a) => x(A) && x(A)(...a))
|
|
288
304
|
}, null, 6),
|
|
289
|
-
|
|
305
|
+
x(d) ? (R(), N("div", {
|
|
290
306
|
key: 0,
|
|
291
307
|
class: "acpPanel",
|
|
292
|
-
style: j(
|
|
293
|
-
onClick:
|
|
308
|
+
style: j(x(U)),
|
|
309
|
+
onClick: t[10] || (t[10] = (a) => i.panelClickStopPropagation && a.stopPropagation())
|
|
294
310
|
}, [
|
|
295
|
-
c("div",
|
|
296
|
-
ce(
|
|
311
|
+
c("div", Re, [
|
|
312
|
+
ce(Te, {
|
|
297
313
|
ref_key: "ring",
|
|
298
314
|
ref: g,
|
|
299
315
|
"initial-hex": u.value,
|
|
300
316
|
onChanged: b,
|
|
301
|
-
"show-package-name":
|
|
317
|
+
"show-package-name": i.showPackageName
|
|
302
318
|
}, null, 8, ["initial-hex", "show-package-name"])
|
|
303
319
|
]),
|
|
304
|
-
c("div",
|
|
320
|
+
c("div", De, [
|
|
305
321
|
Q(c("select", {
|
|
306
|
-
"onUpdate:modelValue":
|
|
307
|
-
}, [...
|
|
322
|
+
"onUpdate:modelValue": t[1] || (t[1] = (a) => H.value = a)
|
|
323
|
+
}, [...t[11] || (t[11] = [
|
|
308
324
|
c("option", { value: "hex" }, "HEX", -1),
|
|
309
325
|
c("option", { value: "rgb" }, "RGB", -1),
|
|
310
326
|
c("option", { value: "hsv" }, "HSV", -1)
|
|
311
327
|
])], 512), [
|
|
312
328
|
[ke, H.value]
|
|
313
329
|
]),
|
|
314
|
-
H.value == "hex" ? (
|
|
330
|
+
H.value == "hex" ? (R(), N("div", He, [
|
|
315
331
|
c("input", {
|
|
316
332
|
value: u.value,
|
|
317
333
|
onBlur: w,
|
|
318
334
|
spellcheck: "false",
|
|
319
335
|
maxlength: "7"
|
|
320
|
-
}, null, 40,
|
|
321
|
-
])) : H.value == "rgb" ? (
|
|
336
|
+
}, null, 40, Ee)
|
|
337
|
+
])) : H.value == "rgb" ? (R(), N("div", Me, [
|
|
322
338
|
c("input", {
|
|
323
|
-
value:
|
|
324
|
-
onBlur:
|
|
325
|
-
}, null, 40,
|
|
339
|
+
value: P.value[0],
|
|
340
|
+
onBlur: t[2] || (t[2] = (a) => V(a, "r"))
|
|
341
|
+
}, null, 40, Ae),
|
|
326
342
|
c("input", {
|
|
327
|
-
value:
|
|
328
|
-
onBlur:
|
|
343
|
+
value: P.value[1],
|
|
344
|
+
onBlur: t[3] || (t[3] = (a) => V(a, "g"))
|
|
329
345
|
}, null, 40, $e),
|
|
330
346
|
c("input", {
|
|
331
|
-
value:
|
|
332
|
-
onBlur:
|
|
347
|
+
value: P.value[2],
|
|
348
|
+
onBlur: t[4] || (t[4] = (a) => V(a, "b"))
|
|
333
349
|
}, null, 40, qe)
|
|
334
|
-
])) : (
|
|
350
|
+
])) : (R(), N("div", Ue, [
|
|
335
351
|
c("input", {
|
|
336
352
|
value: S.value[0],
|
|
337
|
-
onBlur:
|
|
353
|
+
onBlur: t[5] || (t[5] = (a) => s(a, "h"))
|
|
338
354
|
}, null, 40, Le),
|
|
339
355
|
c("input", {
|
|
340
356
|
value: S.value[1],
|
|
341
|
-
onBlur:
|
|
342
|
-
}, null, 40,
|
|
357
|
+
onBlur: t[6] || (t[6] = (a) => s(a, "s"))
|
|
358
|
+
}, null, 40, Oe),
|
|
343
359
|
c("input", {
|
|
344
360
|
value: S.value[2],
|
|
345
|
-
onBlur:
|
|
346
|
-
}, null, 40,
|
|
361
|
+
onBlur: t[7] || (t[7] = (a) => s(a, "v"))
|
|
362
|
+
}, null, 40, _e)
|
|
347
363
|
]))
|
|
348
364
|
]),
|
|
349
|
-
c("div",
|
|
365
|
+
c("div", ze, [
|
|
350
366
|
c("button", {
|
|
351
|
-
onClick:
|
|
352
|
-
(...
|
|
367
|
+
onClick: t[8] || (t[8] = //@ts-ignore
|
|
368
|
+
(...a) => x(k) && x(k)(...a))
|
|
353
369
|
}, "OK")
|
|
354
370
|
]),
|
|
355
|
-
|
|
371
|
+
i.showPackageName ? (R(), N("div", {
|
|
356
372
|
key: 0,
|
|
357
373
|
class: "acpPackageName",
|
|
358
|
-
onClick:
|
|
359
|
-
(...
|
|
360
|
-
}, " au-color-picker ")) :
|
|
361
|
-
], 4)) :
|
|
374
|
+
onClick: t[9] || (t[9] = //@ts-ignore
|
|
375
|
+
(...a) => x(re) && x(re)(...a))
|
|
376
|
+
}, " au-color-picker ")) : G("", !0)
|
|
377
|
+
], 4)) : G("", !0)
|
|
362
378
|
]));
|
|
363
379
|
}
|
|
364
|
-
}), je = /* @__PURE__ */ ne(We, [["__scopeId", "data-v-dc351014"]]), Xe = { class: "acp" }, Ze = { class: "acpNamedPresets" }, Fe = ["for", "onClick"],
|
|
380
|
+
}), je = /* @__PURE__ */ ne(We, [["__scopeId", "data-v-dc351014"]]), Xe = { class: "acp" }, Ze = { class: "acpNamedPresets" }, Fe = ["for", "onClick"], Je = ["id", "value"], Ke = { class: "acpPresetName" }, Ye = { class: "acpDoneBtn" }, Ge = /* @__PURE__ */ te({
|
|
365
381
|
__name: "AuColorPickerPresetsNested",
|
|
366
382
|
props: {
|
|
367
383
|
modelValueSelectedPreset: {},
|
|
@@ -380,111 +396,111 @@ const Te = { class: "acp" }, Ne = { class: "acpRing" }, Re = { class: "acpParams
|
|
|
380
396
|
showPackageName: { type: Boolean }
|
|
381
397
|
},
|
|
382
398
|
emits: ["done", "update:modelValue", "update:modelValueSelectedPreset"],
|
|
383
|
-
setup(
|
|
384
|
-
const
|
|
385
|
-
let
|
|
386
|
-
return g.value && (
|
|
387
|
-
}), { panelShow:
|
|
388
|
-
function
|
|
389
|
-
g.value =
|
|
399
|
+
setup(i, { expose: h, emit: m }) {
|
|
400
|
+
const o = i, g = I(), u = I(), d = I("#ff0000"), k = F(() => {
|
|
401
|
+
let s = null;
|
|
402
|
+
return g.value && (s = o.presets?.find((p) => p.name == g.value)?.colorHex), s || d.value;
|
|
403
|
+
}), { panelShow: A, closePanel: $, togglePanel: U, entryStylesActual: b } = de(o, k), { panelStyles: H } = ve(o);
|
|
404
|
+
function P(s) {
|
|
405
|
+
g.value = s?.name, S("update:modelValueSelectedPreset", s?.name);
|
|
390
406
|
}
|
|
391
407
|
const S = m;
|
|
392
|
-
W(d, (
|
|
393
|
-
S("update:modelValue",
|
|
408
|
+
W(d, (s) => {
|
|
409
|
+
S("update:modelValue", s);
|
|
394
410
|
});
|
|
395
|
-
function w(
|
|
396
|
-
if (ee(
|
|
397
|
-
const
|
|
398
|
-
d.value =
|
|
411
|
+
function w(s) {
|
|
412
|
+
if (ee(s)) {
|
|
413
|
+
const r = z(s);
|
|
414
|
+
d.value = r, u.value?.enforceTo(r);
|
|
399
415
|
}
|
|
400
416
|
}
|
|
401
|
-
function
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
417
|
+
function V(s) {
|
|
418
|
+
s || P(void 0);
|
|
419
|
+
const r = o.presets?.find((p) => p.name === s);
|
|
420
|
+
r && P(r);
|
|
405
421
|
}
|
|
406
|
-
return
|
|
407
|
-
|
|
408
|
-
}), W(() =>
|
|
409
|
-
|
|
410
|
-
}), W(() =>
|
|
411
|
-
|
|
422
|
+
return h({ closePanel: $, enforceCustomValueTo: w, enforcePresetTo: V }), W(A, (s) => {
|
|
423
|
+
s === !1 && S("done");
|
|
424
|
+
}), W(() => o.modelValue, (s) => {
|
|
425
|
+
s && w(s);
|
|
426
|
+
}), W(() => o.modelValueSelectedPreset, (s) => {
|
|
427
|
+
V(s);
|
|
412
428
|
}), ue(() => {
|
|
413
|
-
|
|
414
|
-
}), (
|
|
429
|
+
o.modelValue ? w(o.modelValue) : o.initial && w(o.initial), o.modelValueSelectedPreset ? V(o.modelValueSelectedPreset) : o.initialSelectedPreset && V(o.initialSelectedPreset);
|
|
430
|
+
}), (s, r) => (R(), N("div", Xe, [
|
|
415
431
|
c("div", {
|
|
416
432
|
class: "acpEntry",
|
|
417
|
-
style: j(
|
|
418
|
-
onClick:
|
|
419
|
-
(...
|
|
433
|
+
style: j(x(b)),
|
|
434
|
+
onClick: r[0] || (r[0] = //@ts-ignore
|
|
435
|
+
(...p) => x(U) && x(U)(...p))
|
|
420
436
|
}, null, 4),
|
|
421
|
-
|
|
437
|
+
x(A) ? (R(), N("div", {
|
|
422
438
|
key: 0,
|
|
423
439
|
class: "acpPanel",
|
|
424
|
-
style: j(
|
|
425
|
-
onClick:
|
|
440
|
+
style: j(x(H)),
|
|
441
|
+
onClick: r[6] || (r[6] = (p) => i.panelClickStopPropagation && p.stopPropagation())
|
|
426
442
|
}, [
|
|
427
443
|
c("div", Ze, [
|
|
428
444
|
c("label", {
|
|
429
445
|
for: "acpColorPresetCustom",
|
|
430
|
-
onClick:
|
|
446
|
+
onClick: r[3] || (r[3] = (p) => P(void 0))
|
|
431
447
|
}, [
|
|
432
448
|
ce(je, {
|
|
433
449
|
modelValue: d.value,
|
|
434
|
-
"onUpdate:modelValue":
|
|
435
|
-
onDone:
|
|
450
|
+
"onUpdate:modelValue": r[1] || (r[1] = (p) => d.value = p),
|
|
451
|
+
onDone: x($),
|
|
436
452
|
"entry-class-name": "acpPresetBody",
|
|
437
453
|
ref_key: "customPicker",
|
|
438
454
|
ref: u,
|
|
439
|
-
"show-package-name":
|
|
440
|
-
pos:
|
|
455
|
+
"show-package-name": i.showPackageName,
|
|
456
|
+
pos: i.posInternal
|
|
441
457
|
}, null, 8, ["modelValue", "onDone", "show-package-name", "pos"]),
|
|
442
458
|
Q(c("input", {
|
|
443
459
|
name: "colorType",
|
|
444
460
|
type: "radio",
|
|
445
461
|
id: "acpColorPresetCustom",
|
|
446
462
|
value: void 0,
|
|
447
|
-
"onUpdate:modelValue":
|
|
463
|
+
"onUpdate:modelValue": r[2] || (r[2] = (p) => g.value = p)
|
|
448
464
|
}, null, 512), [
|
|
449
465
|
[oe, g.value]
|
|
450
466
|
]),
|
|
451
|
-
|
|
467
|
+
r[7] || (r[7] = c("div", { class: "acpPresetName" }, "自定义", -1))
|
|
452
468
|
]),
|
|
453
|
-
|
|
454
|
-
(
|
|
455
|
-
for: `acpColorPreset${
|
|
456
|
-
onClick: (
|
|
457
|
-
key:
|
|
469
|
+
r[8] || (r[8] = c("div", { class: "acpSep" }, null, -1)),
|
|
470
|
+
(R(!0), N(Ce, null, Se(i.presets, (p) => (R(), N("label", {
|
|
471
|
+
for: `acpColorPreset${p.name}`,
|
|
472
|
+
onClick: (D) => P(p),
|
|
473
|
+
key: p.name
|
|
458
474
|
}, [
|
|
459
475
|
c("div", {
|
|
460
476
|
class: "acpPresetBody",
|
|
461
|
-
style: j({ backgroundColor:
|
|
477
|
+
style: j({ backgroundColor: p.colorHex })
|
|
462
478
|
}, null, 4),
|
|
463
479
|
Q(c("input", {
|
|
464
480
|
name: "colorType",
|
|
465
481
|
type: "radio",
|
|
466
|
-
id: `acpColorPreset${
|
|
467
|
-
value:
|
|
468
|
-
"onUpdate:modelValue":
|
|
469
|
-
}, null, 8,
|
|
482
|
+
id: `acpColorPreset${p.name}`,
|
|
483
|
+
value: p.name,
|
|
484
|
+
"onUpdate:modelValue": r[4] || (r[4] = (D) => g.value = D)
|
|
485
|
+
}, null, 8, Je), [
|
|
470
486
|
[oe, g.value]
|
|
471
487
|
]),
|
|
472
|
-
c("div",
|
|
488
|
+
c("div", Ke, we(p.name), 1)
|
|
473
489
|
], 8, Fe))), 128)),
|
|
474
|
-
|
|
490
|
+
r[9] || (r[9] = c("div", { class: "acpSep" }, null, -1))
|
|
475
491
|
]),
|
|
476
|
-
c("div",
|
|
492
|
+
c("div", Ye, [
|
|
477
493
|
c("button", {
|
|
478
|
-
onClick:
|
|
479
|
-
(...
|
|
494
|
+
onClick: r[5] || (r[5] = //@ts-ignore
|
|
495
|
+
(...p) => x($) && x($)(...p))
|
|
480
496
|
}, "OK")
|
|
481
497
|
])
|
|
482
|
-
], 4)) :
|
|
498
|
+
], 4)) : G("", !0)
|
|
483
499
|
]));
|
|
484
500
|
}
|
|
485
|
-
}), tt = /* @__PURE__ */ ne(
|
|
501
|
+
}), tt = /* @__PURE__ */ ne(Ge, [["__scopeId", "data-v-1e965bbc"]]);
|
|
486
502
|
export {
|
|
487
503
|
je as AuColorPicker,
|
|
488
504
|
tt as AuColorPickerPresetsNested,
|
|
489
|
-
|
|
505
|
+
Te as AuColorPickerRing
|
|
490
506
|
};
|