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