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