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