@aurouscia/au-color-picker 0.0.6 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/au-color-picker.es.js +330 -224
- package/dist/style.css +1 -1
- package/dist/types/components/AuColorPicker.vue.d.ts +8 -19
- package/dist/types/components/AuColorPickerPresetsNested.vue.d.ts +9 -0
- package/dist/types/components/AuColorPickerRing.vue.d.ts +4 -4
- package/dist/types/components/common/pickerProps.d.ts +14 -0
- package/dist/types/index.d.ts +3 -2
- package/package.json +8 -4
- package/dist/types/components/AuColorPickerWithPresets.vue.d.ts +0 -2
- package/dist/types/components/utils/elementOffsetPos.d.ts +0 -4
- package/dist/types/components/utils/isValidHex.d.ts +0 -1
- package/dist/types/components/utils/pt.d.ts +0 -4
- package/dist/types/components/utils/ptAzi.d.ts +0 -2
- package/dist/types/components/utils/ptDist.d.ts +0 -2
- package/dist/vite.svg +0 -1
|
@@ -1,325 +1,431 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
return
|
|
1
|
+
import { defineComponent as G, ref as b, onMounted as pe, onUnmounted as ge, openBlock as B, createElementBlock as D, normalizeStyle as U, isRef as ye, createElementVNode as i, computed as K, onBeforeMount as le, watch as ae, normalizeClass as me, unref as k, createVNode as ie, withDirectives as Y, vModelSelect as xe, createCommentVNode as re, vModelRadio as Q, Fragment as he, renderList as Ce, toDisplayString as Pe } from "vue";
|
|
2
|
+
import A from "color-convert";
|
|
3
|
+
function ke(p, v) {
|
|
4
|
+
const y = p.x - v.x, f = p.y - v.y;
|
|
5
|
+
return y ** 2 + f ** 2;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
return Math.atan2(
|
|
7
|
+
function Se(p, v) {
|
|
8
|
+
const y = p.x - v.x, f = p.y - v.y;
|
|
9
|
+
return Math.atan2(f, y);
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
let v =
|
|
11
|
+
function Ie(p) {
|
|
12
|
+
let v = p, y = 0, f = 0;
|
|
13
13
|
for (; v !== null; )
|
|
14
|
-
|
|
15
|
-
return { y
|
|
14
|
+
y += v.offsetTop, f += v.offsetLeft, v = v.offsetParent;
|
|
15
|
+
return { y, x: f };
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const _ = 400, L = 400, F = 200, we = 200, ee = 190, te = 150, O = 200, ne = 16, se = 3, be = /* @__PURE__ */ G({
|
|
18
18
|
__name: "AuColorPickerRing",
|
|
19
19
|
props: {
|
|
20
20
|
initialHex: {}
|
|
21
21
|
},
|
|
22
22
|
emits: ["changed"],
|
|
23
|
-
setup(
|
|
24
|
-
const
|
|
25
|
-
let
|
|
26
|
-
const
|
|
27
|
-
let
|
|
23
|
+
setup(p, { expose: v, emit: y }) {
|
|
24
|
+
const f = b(), P = b();
|
|
25
|
+
let u, l;
|
|
26
|
+
const $ = { x: 199, y: 199 }, I = (ee + te) / 2, V = ee ** 2, M = te ** 2, h = (_ - O) / 2, H = h + O, S = b(0), R = b(100), d = b(100), g = p;
|
|
27
|
+
let a;
|
|
28
28
|
function T() {
|
|
29
|
-
var
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
29
|
+
var o, c;
|
|
30
|
+
const t = (o = f.value) == null ? void 0 : o.getContext("2d"), n = (c = P.value) == null ? void 0 : c.getContext("2d");
|
|
31
|
+
if (!t || !n)
|
|
32
32
|
throw Error("canvas context getting error");
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
|
|
33
|
+
if (g.initialHex) {
|
|
34
|
+
const x = A.hex.hsv(g.initialHex);
|
|
35
|
+
S.value = x[0], R.value = x[1], d.value = x[2];
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
u = t, l = n, a = u.getImageData(0, 0, _, L), X(), e(), j(), u.putImageData(a, 0, 0);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
for (let
|
|
41
|
-
for (let
|
|
42
|
-
const
|
|
43
|
-
if (o
|
|
44
|
-
const
|
|
45
|
-
|
|
39
|
+
function X() {
|
|
40
|
+
for (let t = 0; t < _; t++)
|
|
41
|
+
for (let n = 0; n < L; n++) {
|
|
42
|
+
const o = { x: t, y: n };
|
|
43
|
+
if (m(o)) {
|
|
44
|
+
const c = o.y * _ * 4 + o.x * 4, x = z(o), E = A.hsv.rgb([x, 100, 100]);
|
|
45
|
+
a.data[c] = E[0], a.data[c + 1] = E[1], a.data[c + 2] = E[2], a.data[c + 3] = 255;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
return 360 * ((
|
|
49
|
+
function z(t) {
|
|
50
|
+
return 360 * ((Se(t, $) + Math.PI) / (2 * Math.PI));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
return
|
|
52
|
+
function m(t) {
|
|
53
|
+
const n = ke($, t);
|
|
54
|
+
return n > M && n < V;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
for (let
|
|
58
|
-
for (let
|
|
59
|
-
const
|
|
60
|
-
if (w(
|
|
61
|
-
const
|
|
62
|
-
|
|
56
|
+
function e() {
|
|
57
|
+
for (let t = 0; t < _; t++)
|
|
58
|
+
for (let n = 0; n < L; n++) {
|
|
59
|
+
const o = { x: t, y: n };
|
|
60
|
+
if (w(o)) {
|
|
61
|
+
const c = o.y * _ * 4 + o.x * 4, { s: x, v: E } = s(o), q = A.hsv.rgb([S.value, x, E]);
|
|
62
|
+
a.data[c] = q[0], a.data[c + 1] = q[1], a.data[c + 2] = q[2], a.data[c + 3] = 255;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
const
|
|
68
|
-
let
|
|
69
|
-
return
|
|
66
|
+
function s(t) {
|
|
67
|
+
const n = t.x - h, o = t.y - h;
|
|
68
|
+
let c = n / O, x = 1 - o / O;
|
|
69
|
+
return c > 1 ? c = 1 : c < 0 && (c = 0), x > 1 ? x = 1 : x < 0 && (x = 0), { s: 100 * c, v: 100 * x };
|
|
70
70
|
}
|
|
71
|
-
function w(
|
|
72
|
-
return !(
|
|
71
|
+
function w(t) {
|
|
72
|
+
return !(t.x < h || t.x > H || t.y < h || t.y > H);
|
|
73
73
|
}
|
|
74
|
-
let
|
|
75
|
-
function
|
|
76
|
-
if (
|
|
74
|
+
let N = !1, r = "none", C = !1;
|
|
75
|
+
function Z(t, n) {
|
|
76
|
+
if (N || n && !C)
|
|
77
77
|
return;
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
78
|
+
N = !0;
|
|
79
|
+
const o = ce(t);
|
|
80
|
+
if (r === "none" && (w(o) ? r = "square" : m(o) && (r = "ring")), r === "ring" && (t.preventDefault(), S.value = z(o), e(), u.putImageData(a, 0, 0)), r === "square") {
|
|
81
|
+
t.preventDefault();
|
|
82
|
+
const c = s(o);
|
|
83
|
+
R.value = c.s, d.value = c.v;
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
r !== "none" && j(!0), N = !1;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
87
|
+
function W() {
|
|
88
|
+
r = "none", C = !1;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
let
|
|
92
|
-
if ("touches" in
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
90
|
+
function ce(t) {
|
|
91
|
+
let n, o;
|
|
92
|
+
if ("touches" in t) {
|
|
93
|
+
n = t.touches[0].pageX, o = t.touches[0].pageY;
|
|
94
|
+
const c = Ie(f.value);
|
|
95
|
+
n -= c.x, o -= c.y;
|
|
96
96
|
} else
|
|
97
|
-
|
|
98
|
-
return
|
|
97
|
+
n = t.offsetX, o = t.offsetY;
|
|
98
|
+
return n = n * _ / F, o = o * _ / F, { x: n, y: o };
|
|
99
99
|
}
|
|
100
|
-
function j(
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
|
|
100
|
+
function j(t) {
|
|
101
|
+
if (t) {
|
|
102
|
+
const de = A.hsv.hex([S.value, R.value, d.value]);
|
|
103
|
+
fe("changed", de);
|
|
104
104
|
}
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
const q =
|
|
108
|
-
|
|
105
|
+
const n = (S.value / 360 * 2 + 1) * Math.PI, o = Math.cos(n) * I + _ / 2, c = Math.sin(n) * I + L / 2, x = R.value / 100 * O + h, E = (1 - d.value / 100) * O + h;
|
|
106
|
+
l.reset(), l.lineWidth = 4, l.strokeStyle = "black", l.beginPath(), l.arc(o, c, ne - 2, 0, 2 * Math.PI), l.stroke(), l.beginPath(), l.arc(o, c, se, 0, 2 * Math.PI), l.fill();
|
|
107
|
+
const q = d.value > 50 ? "black" : "#ddd";
|
|
108
|
+
l.strokeStyle = q, l.fillStyle = q, l.beginPath(), l.arc(x, E, ne - 2, 0, 2 * Math.PI), l.stroke(), l.beginPath(), l.arc(x, E, se, 0, 2 * Math.PI), l.fill();
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
const
|
|
112
|
-
|
|
110
|
+
function ve(t) {
|
|
111
|
+
const n = A.hex.hsv(t);
|
|
112
|
+
S.value = n[0], R.value = n[1], d.value = n[2], e(), u.putImageData(a, 0, 0), j();
|
|
113
113
|
}
|
|
114
|
-
const
|
|
115
|
-
return v({ enforceTo:
|
|
116
|
-
T(), window.addEventListener("touchend",
|
|
117
|
-
}),
|
|
118
|
-
window.removeEventListener("touchend",
|
|
119
|
-
}), (
|
|
114
|
+
const fe = y;
|
|
115
|
+
return v({ enforceTo: ve }), pe(() => {
|
|
116
|
+
T(), window.addEventListener("touchend", W), window.addEventListener("mouseup", W);
|
|
117
|
+
}), ge(() => {
|
|
118
|
+
window.removeEventListener("touchend", W), window.removeEventListener("mouseup", W);
|
|
119
|
+
}), (t, n) => (B(), D("div", {
|
|
120
120
|
class: "acpRingBody",
|
|
121
|
-
style:
|
|
122
|
-
onTouchstart:
|
|
123
|
-
onTouchmove:
|
|
124
|
-
onTouchend:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
W(n), ie(O) ? O.value = !0 : O = !0;
|
|
121
|
+
style: U({ width: F + "px", height: we + "px" }),
|
|
122
|
+
onTouchstart: Z,
|
|
123
|
+
onTouchmove: Z,
|
|
124
|
+
onTouchend: W,
|
|
125
|
+
onMousemove: n[0] || (n[0] = (o) => Z(o, !0)),
|
|
126
|
+
onMousedown: n[1] || (n[1] = (o) => {
|
|
127
|
+
Z(o), ye(C) ? C.value = !0 : C = !0;
|
|
129
128
|
})
|
|
130
129
|
}, [
|
|
131
|
-
|
|
132
|
-
width:
|
|
133
|
-
height:
|
|
130
|
+
i("canvas", {
|
|
131
|
+
width: _,
|
|
132
|
+
height: L,
|
|
134
133
|
ref_key: "cvs",
|
|
135
|
-
ref:
|
|
134
|
+
ref: f
|
|
136
135
|
}, null, 512),
|
|
137
|
-
|
|
138
|
-
width:
|
|
139
|
-
height:
|
|
136
|
+
i("canvas", {
|
|
137
|
+
width: _,
|
|
138
|
+
height: L,
|
|
140
139
|
ref_key: "cursorCvs",
|
|
141
|
-
ref:
|
|
140
|
+
ref: P
|
|
142
141
|
}, null, 512)
|
|
143
142
|
], 36));
|
|
144
143
|
}
|
|
145
|
-
}),
|
|
146
|
-
const
|
|
147
|
-
for (const [
|
|
148
|
-
|
|
149
|
-
return
|
|
150
|
-
},
|
|
151
|
-
function
|
|
152
|
-
return /^#([0-9A-F]{3}){1,2}$/i.test(
|
|
144
|
+
}), J = (p, v) => {
|
|
145
|
+
const y = p.__vccOpts || p;
|
|
146
|
+
for (const [f, P] of v)
|
|
147
|
+
y[f] = P;
|
|
148
|
+
return y;
|
|
149
|
+
}, _e = /* @__PURE__ */ J(be, [["__scopeId", "data-v-505caf85"]]);
|
|
150
|
+
function oe(p) {
|
|
151
|
+
return /^#([0-9A-F]{3}){1,2}$/i.test(p);
|
|
153
152
|
}
|
|
154
|
-
|
|
153
|
+
function ue(p) {
|
|
154
|
+
const v = b(!1), y = b("#ff0000"), f = K(() => {
|
|
155
|
+
let l = {};
|
|
156
|
+
return v.value || (l.boxShadow = "none"), p.entryStyles && Object.assign(l, p.entryStyles), v.value && (l.transition = "0s", Object.assign(l, p.entryActiveStyles)), l.backgroundColor = y.value, p.pos === "right" ? l.right = "0px" : l.left = "0px", l;
|
|
157
|
+
});
|
|
158
|
+
function P() {
|
|
159
|
+
v.value = !1;
|
|
160
|
+
}
|
|
161
|
+
function u() {
|
|
162
|
+
v.value = !v.value;
|
|
163
|
+
}
|
|
164
|
+
return { hexValue: y, panelShow: v, closePanel: P, togglePanel: u, entryStylesActual: f };
|
|
165
|
+
}
|
|
166
|
+
const He = { class: "acpRing" }, Be = { class: "acpParams" }, De = {
|
|
155
167
|
key: 0,
|
|
156
168
|
class: "acpSingleInput"
|
|
157
|
-
},
|
|
169
|
+
}, Me = ["value"], Re = {
|
|
158
170
|
key: 1,
|
|
159
171
|
class: "acpTripleInputs"
|
|
160
|
-
},
|
|
172
|
+
}, Te = ["value"], Ne = ["value"], Ae = ["value"], $e = {
|
|
161
173
|
key: 2,
|
|
162
174
|
class: "acpTripleInputs"
|
|
163
|
-
},
|
|
175
|
+
}, Ee = ["value"], Ve = ["value"], qe = ["value"], Le = { class: "acpDoneBtn" }, Oe = /* @__PURE__ */ G({
|
|
164
176
|
__name: "AuColorPicker",
|
|
165
177
|
props: {
|
|
166
178
|
inital: {},
|
|
167
179
|
entryStyles: {},
|
|
168
180
|
entryActiveStyles: {},
|
|
181
|
+
entryClassName: {},
|
|
169
182
|
pos: {},
|
|
170
|
-
panelBaseZIndex: {}
|
|
183
|
+
panelBaseZIndex: {},
|
|
184
|
+
presets: {}
|
|
171
185
|
},
|
|
172
186
|
emits: ["change", "done"],
|
|
173
|
-
setup(
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}), I = S(), u = S(!1);
|
|
178
|
-
function N() {
|
|
179
|
-
u.value = !1;
|
|
180
|
-
}
|
|
181
|
-
function U() {
|
|
182
|
-
u.value = !u.value;
|
|
187
|
+
setup(p, { expose: v, emit: y }) {
|
|
188
|
+
const f = p, P = b(), { hexValue: u, panelShow: l, closePanel: $, togglePanel: I, entryStylesActual: V } = ue(f);
|
|
189
|
+
function M(m) {
|
|
190
|
+
u.value = a(m), T();
|
|
183
191
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
const M = S("hex"), r = S("#ff0000"), b = Y(() => k.hex.rgb(r.value)), m = Y(() => k.hex.hsv(r.value));
|
|
188
|
-
function B(l) {
|
|
192
|
+
const h = b("hex"), H = K(() => A.hex.rgb(u.value)), S = K(() => A.hex.hsv(u.value));
|
|
193
|
+
function R(m) {
|
|
189
194
|
var s;
|
|
190
|
-
const
|
|
191
|
-
if ("value" in
|
|
192
|
-
const
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
+
const e = m.target;
|
|
196
|
+
if ("value" in e) {
|
|
197
|
+
const w = e.value;
|
|
198
|
+
if (w && oe(w)) {
|
|
199
|
+
u.value = a(w), (s = P.value) == null || s.enforceTo(u.value), T();
|
|
195
200
|
return;
|
|
196
201
|
}
|
|
197
|
-
|
|
202
|
+
e.value = u.value;
|
|
198
203
|
}
|
|
199
204
|
}
|
|
200
|
-
function
|
|
201
|
-
var
|
|
202
|
-
const s =
|
|
205
|
+
function d(m, e) {
|
|
206
|
+
var w;
|
|
207
|
+
const s = m.target;
|
|
203
208
|
if ("value" in s) {
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
let
|
|
207
|
-
if (isNaN(
|
|
209
|
+
const N = s.value;
|
|
210
|
+
if (N) {
|
|
211
|
+
let r = parseInt(N);
|
|
212
|
+
if (isNaN(r))
|
|
208
213
|
s.value = "0";
|
|
209
214
|
else {
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
215
|
+
r > 255 ? r = 255 : r < 0 && (r = 0);
|
|
216
|
+
const C = [...H.value];
|
|
217
|
+
e == "r" ? C[0] = r : e == "g" ? C[1] = r : C[2] = r, u.value = a(A.rgb.hex(C)), (w = P.value) == null || w.enforceTo(u.value), s.value = r.toString(), T();
|
|
213
218
|
return;
|
|
214
219
|
}
|
|
215
220
|
}
|
|
216
221
|
}
|
|
217
222
|
}
|
|
218
|
-
function
|
|
219
|
-
var
|
|
220
|
-
const s =
|
|
223
|
+
function g(m, e) {
|
|
224
|
+
var w;
|
|
225
|
+
const s = m.target;
|
|
221
226
|
if ("value" in s) {
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
let
|
|
225
|
-
if (isNaN(
|
|
227
|
+
const N = s.value;
|
|
228
|
+
if (N) {
|
|
229
|
+
let r = parseInt(N);
|
|
230
|
+
if (isNaN(r))
|
|
226
231
|
s.value = "0";
|
|
227
232
|
else {
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
233
|
+
e === "h" ? r > 359 && (r = 359) : r > 100 && (r = 100), r < 0 && (r = 0);
|
|
234
|
+
const C = [...S.value];
|
|
235
|
+
e == "h" ? C[0] = r : e == "s" ? C[1] = r : C[2] = r, u.value = a(A.hsv.hex(C)), s.value = r.toString(), (w = P.value) == null || w.enforceTo(u.value), T();
|
|
231
236
|
return;
|
|
232
237
|
}
|
|
233
238
|
}
|
|
234
239
|
}
|
|
235
240
|
}
|
|
236
|
-
function
|
|
237
|
-
return
|
|
241
|
+
function a(m) {
|
|
242
|
+
return m.startsWith("#") ? m.toUpperCase() : "#" + m.toUpperCase();
|
|
238
243
|
}
|
|
239
244
|
function T() {
|
|
240
|
-
z("change",
|
|
245
|
+
z("change", u.value);
|
|
246
|
+
}
|
|
247
|
+
function X() {
|
|
248
|
+
return u.value;
|
|
241
249
|
}
|
|
242
|
-
|
|
243
|
-
|
|
250
|
+
le(() => {
|
|
251
|
+
f.inital && oe(f.inital) && (u.value = a(f.inital));
|
|
244
252
|
});
|
|
245
|
-
const z =
|
|
246
|
-
return v({ closePanel:
|
|
247
|
-
|
|
248
|
-
}), (
|
|
253
|
+
const z = y;
|
|
254
|
+
return v({ closePanel: $, getCurrentHex: X }), ae(l, (m) => {
|
|
255
|
+
m === !1 && z("done", u.value);
|
|
256
|
+
}), (m, e) => (B(), D("div", {
|
|
249
257
|
class: "acp",
|
|
250
|
-
onClick:
|
|
258
|
+
onClick: e[9] || (e[9] = (s) => s.stopPropagation())
|
|
251
259
|
}, [
|
|
252
|
-
|
|
253
|
-
class: "acpEntry",
|
|
254
|
-
style:
|
|
255
|
-
onClick:
|
|
256
|
-
|
|
257
|
-
|
|
260
|
+
i("div", {
|
|
261
|
+
class: me(m.entryClassName || "acpEntry"),
|
|
262
|
+
style: U(k(V)),
|
|
263
|
+
onClick: e[0] || (e[0] = //@ts-ignore
|
|
264
|
+
(...s) => k(I) && k(I)(...s))
|
|
265
|
+
}, null, 6),
|
|
266
|
+
k(l) ? (B(), D("div", {
|
|
258
267
|
key: 0,
|
|
259
268
|
class: "acpPanel",
|
|
260
|
-
style:
|
|
269
|
+
style: U({ zIndex: (m.panelBaseZIndex || 0) + 100 })
|
|
261
270
|
}, [
|
|
262
|
-
|
|
263
|
-
|
|
271
|
+
i("div", He, [
|
|
272
|
+
ie(_e, {
|
|
264
273
|
ref_key: "ring",
|
|
265
|
-
ref:
|
|
266
|
-
initialHex:
|
|
267
|
-
onChanged:
|
|
274
|
+
ref: P,
|
|
275
|
+
initialHex: k(u),
|
|
276
|
+
onChanged: M
|
|
268
277
|
}, null, 8, ["initialHex"])
|
|
269
278
|
]),
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
"onUpdate:modelValue":
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
279
|
+
i("div", Be, [
|
|
280
|
+
Y(i("select", {
|
|
281
|
+
"onUpdate:modelValue": e[1] || (e[1] = (s) => h.value = s)
|
|
282
|
+
}, e[10] || (e[10] = [
|
|
283
|
+
i("option", { value: "hex" }, "HEX", -1),
|
|
284
|
+
i("option", { value: "rgb" }, "RGB", -1),
|
|
285
|
+
i("option", { value: "hsv" }, "HSV", -1)
|
|
277
286
|
]), 512), [
|
|
278
|
-
[
|
|
287
|
+
[xe, h.value]
|
|
279
288
|
]),
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
value:
|
|
283
|
-
onBlur:
|
|
289
|
+
h.value == "hex" ? (B(), D("div", De, [
|
|
290
|
+
i("input", {
|
|
291
|
+
value: k(u),
|
|
292
|
+
onBlur: R,
|
|
284
293
|
spellcheck: "false",
|
|
285
294
|
maxlength: "7"
|
|
286
|
-
}, null, 40,
|
|
287
|
-
])) :
|
|
288
|
-
|
|
289
|
-
value:
|
|
290
|
-
onBlur:
|
|
291
|
-
}, null, 40,
|
|
292
|
-
|
|
293
|
-
value:
|
|
294
|
-
onBlur:
|
|
295
|
-
}, null, 40,
|
|
296
|
-
|
|
297
|
-
value:
|
|
298
|
-
onBlur:
|
|
299
|
-
}, null, 40,
|
|
300
|
-
])) : (
|
|
301
|
-
|
|
302
|
-
value:
|
|
303
|
-
onBlur:
|
|
304
|
-
}, null, 40,
|
|
305
|
-
|
|
306
|
-
value:
|
|
307
|
-
onBlur:
|
|
308
|
-
}, null, 40,
|
|
309
|
-
|
|
310
|
-
value:
|
|
311
|
-
onBlur:
|
|
312
|
-
}, null, 40,
|
|
295
|
+
}, null, 40, Me)
|
|
296
|
+
])) : h.value == "rgb" ? (B(), D("div", Re, [
|
|
297
|
+
i("input", {
|
|
298
|
+
value: H.value[0],
|
|
299
|
+
onBlur: e[2] || (e[2] = (s) => d(s, "r"))
|
|
300
|
+
}, null, 40, Te),
|
|
301
|
+
i("input", {
|
|
302
|
+
value: H.value[1],
|
|
303
|
+
onBlur: e[3] || (e[3] = (s) => d(s, "g"))
|
|
304
|
+
}, null, 40, Ne),
|
|
305
|
+
i("input", {
|
|
306
|
+
value: H.value[2],
|
|
307
|
+
onBlur: e[4] || (e[4] = (s) => d(s, "b"))
|
|
308
|
+
}, null, 40, Ae)
|
|
309
|
+
])) : (B(), D("div", $e, [
|
|
310
|
+
i("input", {
|
|
311
|
+
value: S.value[0],
|
|
312
|
+
onBlur: e[5] || (e[5] = (s) => g(s, "h"))
|
|
313
|
+
}, null, 40, Ee),
|
|
314
|
+
i("input", {
|
|
315
|
+
value: S.value[1],
|
|
316
|
+
onBlur: e[6] || (e[6] = (s) => g(s, "s"))
|
|
317
|
+
}, null, 40, Ve),
|
|
318
|
+
i("input", {
|
|
319
|
+
value: S.value[2],
|
|
320
|
+
onBlur: e[7] || (e[7] = (s) => g(s, "v"))
|
|
321
|
+
}, null, 40, qe)
|
|
313
322
|
]))
|
|
314
323
|
]),
|
|
315
|
-
|
|
316
|
-
|
|
324
|
+
i("div", Le, [
|
|
325
|
+
i("button", {
|
|
326
|
+
onClick: e[8] || (e[8] = //@ts-ignore
|
|
327
|
+
(...s) => k($) && k($)(...s))
|
|
328
|
+
}, "OK")
|
|
329
|
+
])
|
|
330
|
+
], 4)) : re("", !0)
|
|
331
|
+
]));
|
|
332
|
+
}
|
|
333
|
+
}), Ue = /* @__PURE__ */ J(Oe, [["__scopeId", "data-v-3439ba22"]]), ze = { class: "acp" }, We = { class: "acpNamedPresets" }, Ze = { for: "acpColorPresetCustom" }, Xe = ["for"], je = ["id", "value", "onClick"], Fe = { class: "acpPresetName" }, Ke = { class: "acpDoneBtn" }, Ye = /* @__PURE__ */ G({
|
|
334
|
+
__name: "AuColorPickerPresetsNested",
|
|
335
|
+
props: {
|
|
336
|
+
inital: {},
|
|
337
|
+
entryStyles: {},
|
|
338
|
+
entryActiveStyles: {},
|
|
339
|
+
entryClassName: {},
|
|
340
|
+
pos: {},
|
|
341
|
+
panelBaseZIndex: {},
|
|
342
|
+
presets: {}
|
|
343
|
+
},
|
|
344
|
+
emits: ["change", "done"],
|
|
345
|
+
setup(p, { emit: v }) {
|
|
346
|
+
const y = p, { hexValue: f, panelShow: P, closePanel: u, togglePanel: l, entryStylesActual: $ } = ue(y), I = b(), V = b(), M = b("#ff0000");
|
|
347
|
+
function h(d) {
|
|
348
|
+
d ? (I.value = d.name, f.value = d.colorHex) : V.value && (I.value = void 0, f.value = M.value);
|
|
349
|
+
}
|
|
350
|
+
const H = v;
|
|
351
|
+
function S(d) {
|
|
352
|
+
f.value = d, M.value = d, H("change", d);
|
|
353
|
+
}
|
|
354
|
+
function R(d) {
|
|
355
|
+
f.value = d, M.value = d, u();
|
|
356
|
+
}
|
|
357
|
+
return ae(P, (d) => {
|
|
358
|
+
d === !1 && H("done", f.value);
|
|
359
|
+
}), le(() => {
|
|
360
|
+
y.inital && (f.value = y.inital, M.value = y.inital);
|
|
361
|
+
}), (d, g) => (B(), D("div", ze, [
|
|
362
|
+
i("div", {
|
|
363
|
+
class: "acpEntry",
|
|
364
|
+
style: U(k($)),
|
|
365
|
+
onClick: g[0] || (g[0] = //@ts-ignore
|
|
366
|
+
(...a) => k(l) && k(l)(...a))
|
|
367
|
+
}, null, 4),
|
|
368
|
+
k(P) ? (B(), D("div", {
|
|
369
|
+
key: 0,
|
|
370
|
+
class: "acpPanel",
|
|
371
|
+
style: U({ zIndex: (d.panelBaseZIndex || 0) + 100 })
|
|
372
|
+
}, [
|
|
373
|
+
i("div", We, [
|
|
374
|
+
i("label", Ze, [
|
|
375
|
+
ie(Ue, {
|
|
376
|
+
inital: M.value,
|
|
377
|
+
onChange: S,
|
|
378
|
+
onDone: R,
|
|
379
|
+
"entry-class-name": "acpPresetBody",
|
|
380
|
+
ref_key: "customPicker",
|
|
381
|
+
ref: V
|
|
382
|
+
}, null, 8, ["inital"]),
|
|
383
|
+
Y(i("input", {
|
|
384
|
+
name: "colorType",
|
|
385
|
+
type: "radio",
|
|
386
|
+
id: "acpColorPresetCustom",
|
|
387
|
+
value: void 0,
|
|
388
|
+
"onUpdate:modelValue": g[1] || (g[1] = (a) => I.value = a),
|
|
389
|
+
onClick: g[2] || (g[2] = (a) => h())
|
|
390
|
+
}, null, 512), [
|
|
391
|
+
[Q, I.value]
|
|
392
|
+
]),
|
|
393
|
+
g[5] || (g[5] = i("div", { class: "acpPresetName" }, "自定义", -1))
|
|
394
|
+
]),
|
|
395
|
+
g[6] || (g[6] = i("div", { class: "acpSep" }, null, -1)),
|
|
396
|
+
(B(!0), D(he, null, Ce(d.presets, (a) => (B(), D("label", {
|
|
397
|
+
for: `acpColorPreset${a.name}`
|
|
398
|
+
}, [
|
|
399
|
+
i("div", {
|
|
400
|
+
class: "acpPresetBody",
|
|
401
|
+
style: U({ backgroundColor: a.colorHex })
|
|
402
|
+
}, null, 4),
|
|
403
|
+
Y(i("input", {
|
|
404
|
+
name: "colorType",
|
|
405
|
+
type: "radio",
|
|
406
|
+
id: `acpColorPreset${a.name}`,
|
|
407
|
+
value: a.name,
|
|
408
|
+
"onUpdate:modelValue": g[3] || (g[3] = (T) => I.value = T),
|
|
409
|
+
onClick: (T) => h(a)
|
|
410
|
+
}, null, 8, je), [
|
|
411
|
+
[Q, I.value]
|
|
412
|
+
]),
|
|
413
|
+
i("div", Fe, Pe(a.name), 1)
|
|
414
|
+
], 8, Xe))), 256)),
|
|
415
|
+
g[7] || (g[7] = i("div", { class: "acpSep" }, null, -1))
|
|
416
|
+
]),
|
|
417
|
+
i("div", Ke, [
|
|
418
|
+
i("button", {
|
|
419
|
+
onClick: g[4] || (g[4] = //@ts-ignore
|
|
420
|
+
(...a) => k(u) && k(u)(...a))
|
|
421
|
+
}, "OK")
|
|
317
422
|
])
|
|
318
|
-
], 4)) :
|
|
423
|
+
], 4)) : re("", !0)
|
|
319
424
|
]));
|
|
320
425
|
}
|
|
321
|
-
}),
|
|
426
|
+
}), Qe = /* @__PURE__ */ J(Ye, [["__scopeId", "data-v-66671b10"]]);
|
|
322
427
|
export {
|
|
323
|
-
|
|
324
|
-
|
|
428
|
+
Ue as AuColorPicker,
|
|
429
|
+
Qe as AuColorPickerPresetsNested,
|
|
430
|
+
_e as AuColorPickerRing
|
|
325
431
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.acpRingBody[data-v-
|
|
1
|
+
.acpRingBody[data-v-505caf85]{position:relative}canvas[data-v-505caf85]{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}[data-v-3439ba22]{margin:0;padding:0}.acpSep[data-v-3439ba22]{height:2px;border-radius:100px;flex-grow:0;flex-shrink:0;background-color:#ddd}.acpPresetBody[data-v-3439ba22]{width:25px;height:25px;border-radius:1000px;cursor:pointer}.acpDoneBtn[data-v-3439ba22]{display:flex;justify-content:center;align-items:center;margin:8px}.acpDoneBtn button[data-v-3439ba22]{background:none;border:none;font-weight:700;color:gray;font-size:16px;cursor:pointer}.acpDoneBtn button[data-v-3439ba22]:hover{color:#000}.acpEntry[data-v-3439ba22]{width:30px;height:30px;cursor:pointer;border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acpPanel[data-v-3439ba22]{border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff;margin-top:3px;position:absolute}.acp[data-v-3439ba22]{position:relative;width:fit-content}.acp label[data-v-3439ba22]{-webkit-user-select:none;user-select:none;white-space:nowrap;cursor:pointer}.acp input[type=radio][data-v-3439ba22]{cursor:pointer}.acpParams[data-v-3439ba22]{display:flex;justify-content:space-between;align-items:center;padding:5px}.acpParams select[data-v-3439ba22],.acpParams input[data-v-3439ba22]{margin:0;padding:2px;display:block;font-size:16px;box-sizing:border-box;height:24px;line-height:24px}.acpParams input[data-v-3439ba22]{text-align:center}.acpParams .acpSingleInput input[data-v-3439ba22]{width:120px}.acpParams .acpTripleInputs[data-v-3439ba22]{display:flex;justify-content:space-around}.acpParams .acpTripleInputs input[data-v-3439ba22]{width:40px}[data-v-66671b10]{margin:0;padding:0}.acpSep[data-v-66671b10]{height:2px;border-radius:100px;flex-grow:0;flex-shrink:0;background-color:#ddd}.acpPresetBody[data-v-66671b10]{width:25px;height:25px;border-radius:1000px;cursor:pointer}.acpDoneBtn[data-v-66671b10]{display:flex;justify-content:center;align-items:center;margin:8px}.acpDoneBtn button[data-v-66671b10]{background:none;border:none;font-weight:700;color:gray;font-size:16px;cursor:pointer}.acpDoneBtn button[data-v-66671b10]:hover{color:#000}.acpEntry[data-v-66671b10]{width:30px;height:30px;cursor:pointer;border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acpPanel[data-v-66671b10]{border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff;margin-top:3px;position:absolute}.acp[data-v-66671b10]{position:relative;width:fit-content}.acp label[data-v-66671b10]{-webkit-user-select:none;user-select:none;white-space:nowrap;cursor:pointer}.acp input[type=radio][data-v-66671b10]{cursor:pointer}.acpNamedPresets[data-v-66671b10]{margin:5px;display:flex;flex-direction:column;gap:4px}.acpNamedPresets[data-v-66671b10]>*{display:flex;justify-content:flex-start;align-items:center;gap:5px}.acpNamedPresets>* .acpPresetName[data-v-66671b10]{color:#666}.acpNamedPresets>* .acpPresetName[data-v-66671b10]:hover{color:#000}
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare function
|
|
3
|
-
declare const _default: import(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
pos?: "left" | "right";
|
|
8
|
-
panelBaseZIndex?: number;
|
|
9
|
-
}, {
|
|
10
|
-
closePanel: typeof closePanel;
|
|
11
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
1
|
+
import { PickerProps } from './common/pickerProps';
|
|
2
|
+
declare function getCurrentHex(): string;
|
|
3
|
+
declare const _default: import('vue').DefineComponent<PickerProps, {
|
|
4
|
+
closePanel: () => void;
|
|
5
|
+
getCurrentHex: typeof getCurrentHex;
|
|
6
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
12
7
|
done: (hexStr: string) => any;
|
|
13
8
|
change: (hexStr: string) => any;
|
|
14
|
-
}, string, import(
|
|
15
|
-
inital?: string;
|
|
16
|
-
entryStyles?: CSSProperties;
|
|
17
|
-
entryActiveStyles?: CSSProperties;
|
|
18
|
-
pos?: "left" | "right";
|
|
19
|
-
panelBaseZIndex?: number;
|
|
20
|
-
}> & Readonly<{
|
|
9
|
+
}, string, import('vue').PublicProps, Readonly<PickerProps> & Readonly<{
|
|
21
10
|
onDone?: ((hexStr: string) => any) | undefined;
|
|
22
11
|
onChange?: ((hexStr: string) => any) | undefined;
|
|
23
|
-
}>, {}, {}, {}, {}, string, import(
|
|
12
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
24
13
|
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PickerProps } from './common/pickerProps';
|
|
2
|
+
declare const _default: import('vue').DefineComponent<PickerProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
|
+
done: (hexStr: string) => any;
|
|
4
|
+
change: (hexStr: string) => any;
|
|
5
|
+
}, string, import('vue').PublicProps, Readonly<PickerProps> & Readonly<{
|
|
6
|
+
onDone?: ((hexStr: string) => any) | undefined;
|
|
7
|
+
onChange?: ((hexStr: string) => any) | undefined;
|
|
8
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
export default _default;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { HEX } from 'color-convert/conversions';
|
|
2
2
|
declare function enforceTo(hex: HEX): void;
|
|
3
|
-
declare const _default: import(
|
|
3
|
+
declare const _default: import('vue').DefineComponent<{
|
|
4
4
|
initialHex?: string;
|
|
5
5
|
}, {
|
|
6
6
|
enforceTo: typeof enforceTo;
|
|
7
|
-
}, {}, {}, {}, import(
|
|
7
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
8
8
|
changed: (hex: string) => any;
|
|
9
|
-
}, string, import(
|
|
9
|
+
}, string, import('vue').PublicProps, Readonly<{
|
|
10
10
|
initialHex?: string;
|
|
11
11
|
}> & Readonly<{
|
|
12
12
|
onChanged?: ((hex: string) => any) | undefined;
|
|
13
|
-
}>, {}, {}, {}, {}, string, import(
|
|
13
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
14
14
|
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CSSProperties } from 'vue';
|
|
2
|
+
export interface PickerProps {
|
|
3
|
+
inital?: string;
|
|
4
|
+
entryStyles?: CSSProperties;
|
|
5
|
+
entryActiveStyles?: CSSProperties;
|
|
6
|
+
entryClassName?: string;
|
|
7
|
+
pos?: 'left' | 'right';
|
|
8
|
+
panelBaseZIndex?: number;
|
|
9
|
+
presets?: NamedPreset[];
|
|
10
|
+
}
|
|
11
|
+
export interface NamedPreset {
|
|
12
|
+
colorHex: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { default as AuColorPicker } from
|
|
2
|
-
export { default as AuColorPickerRing } from
|
|
1
|
+
export { default as AuColorPicker } from './components/AuColorPicker.vue';
|
|
2
|
+
export { default as AuColorPickerRing } from './components/AuColorPickerRing.vue';
|
|
3
|
+
export { default as AuColorPickerPresetsNested } from './components/AuColorPickerPresetsNested.vue';
|
package/package.json
CHANGED
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
"url": "https://gitee.com/au114514/au-color-picker"
|
|
10
10
|
},
|
|
11
11
|
"description": "vue3颜色选择器组件",
|
|
12
|
-
"keywords": [
|
|
13
|
-
|
|
12
|
+
"keywords": [
|
|
13
|
+
"vue",
|
|
14
|
+
"color",
|
|
15
|
+
"component"
|
|
16
|
+
],
|
|
17
|
+
"version": "0.1.1",
|
|
14
18
|
"type": "module",
|
|
15
19
|
"files": [
|
|
16
20
|
"dist"
|
|
@@ -28,7 +32,7 @@
|
|
|
28
32
|
"types": "./dist/types/index.d.ts",
|
|
29
33
|
"scripts": {
|
|
30
34
|
"dev": "vite",
|
|
31
|
-
"build": "vite build
|
|
35
|
+
"build": "vite build",
|
|
32
36
|
"prepack": "npm run build"
|
|
33
37
|
},
|
|
34
38
|
"dependencies": {
|
|
@@ -42,6 +46,6 @@
|
|
|
42
46
|
"sass": "^1.81.0",
|
|
43
47
|
"typescript": "5.6.3",
|
|
44
48
|
"vite": "^5.4.11",
|
|
45
|
-
"
|
|
49
|
+
"vite-plugin-dts": "^4.3.0"
|
|
46
50
|
}
|
|
47
51
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
-
export default _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isValidHex(color: string): boolean;
|
package/dist/vite.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|