@aurouscia/au-color-picker 0.2.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,181 +1,191 @@
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
- import A from "color-convert";
3
- function we(m, f) {
4
- const g = m.x - f.x, d = m.y - f.y;
5
- return g ** 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(m, f) {
8
- const g = m.x - f.x, d = m.y - f.y;
9
- return Math.atan2(d, g);
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(m) {
12
- let f = m, g = 0, d = 0;
13
- for (; f !== null; )
14
- g += f.offsetTop, d += f.offsetLeft, f = f.offsetParent;
15
- return { y: g, 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 H = 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(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
- let o;
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)
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 x = A.hex.hsv(p.initialHex);
35
- S.value = x[0], M.value = x[1], i.value = x[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
- c = n, l = s, o = c.getImageData(0, 0, H, q), j(), e(), X(), c.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 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
- 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(n) {
50
- return 360 * ((Se(n, $) + Math.PI) / (2 * Math.PI));
49
+ function j(o) {
50
+ return 360 * ((Se(o, N) + Math.PI) / (2 * Math.PI));
51
51
  }
52
- function y(n) {
53
- const s = we($, n);
54
- return s > D && s < 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 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;
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 t(n) {
67
- const s = n.x - h, a = n.y - h;
68
- let v = s / L, x = 1 - a / L;
69
- return v > 1 ? v = 1 : v < 0 && (v = 0), x > 1 ? x = 1 : x < 0 && (x = 0), { s: 100 * v, v: 100 * x };
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 I(n) {
72
- return !(n.x < h || n.x > B || n.y < h || n.y > B);
71
+ function n(o) {
72
+ return !(o.x < P || o.x > R || o.y < P || o.y > R);
73
73
  }
74
- let T = !1, u = "none", k = !1;
75
- function Z(n, s) {
76
- if (T || s && !k)
74
+ let I = !1, B = "none", v = !1;
75
+ function S(o, s) {
76
+ if (I || s && !v)
77
77
  return;
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;
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
- u !== "none" && X(!0), T = !1;
85
+ B !== "none" && X(!0), I = !1;
86
86
  }
87
- function W() {
88
- u = "none", k = !1;
87
+ function Z() {
88
+ B = "none", v = !1;
89
89
  }
90
- function ve(n) {
90
+ function ve(o) {
91
91
  let s, a;
92
- if ("touches" in n) {
93
- s = n.touches[0].pageX, a = n.touches[0].pageY;
94
- const v = Ie(d.value);
95
- s -= v.x, a -= v.y;
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
- s = n.offsetX, a = n.offsetY;
98
- return s = s * H / F, a = a * H / F, { x: s, 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(n) {
101
- if (n) {
102
- const pe = A.hsv.hex([S.value, M.value, i.value]);
103
- de("changed", pe);
100
+ function X(o) {
101
+ if (o) {
102
+ const pe = E.hsv.hex([C.value, D.value, A.value]);
103
+ fe("changed", pe);
104
104
  }
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();
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 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();
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
- const de = g;
115
- return f({ enforceTo: fe }), ge(() => {
116
- R(), window.addEventListener("touchend", W), window.addEventListener("mouseup", W);
117
- }), me(() => {
118
- window.removeEventListener("touchend", W), window.removeEventListener("mouseup", W);
119
- }), (n, s) => (N(), _("div", {
114
+ const fe = y;
115
+ return i({ enforceTo: de }), ge(() => {
116
+ g(), window.addEventListener("touchend", Z), window.addEventListener("mouseup", Z);
117
+ }), ye(() => {
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: s[0] || (s[0] = (a) => Z(a, !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
126
  onMousedown: s[1] || (s[1] = (a) => {
127
- Z(a), ye(k) ? k.value = !0 : k = !0;
127
+ S(a), me(v) ? v.value = !0 : v = !0;
128
128
  })
129
129
  }, [
130
- r("canvas", {
131
- width: H,
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
- r("canvas", {
137
- width: H,
138
- height: q,
136
+ l("canvas", {
137
+ width: _,
138
+ height: L,
139
139
  ref_key: "cursorCvs",
140
- ref: C
140
+ ref: w
141
141
  }, null, 512)
142
142
  ], 36));
143
143
  }
144
- }), ee = (m, f) => {
145
- const g = m.__vccOpts || m;
146
- for (const [d, C] of f)
147
- g[d] = C;
148
- return g;
149
- }, He = /* @__PURE__ */ ee(Be, [["__scopeId", "data-v-505caf85"]]);
150
- function le(m) {
151
- return /^#([0-9A-F]{3}){1,2}$/i.test(m);
144
+ }), ee = (d, i) => {
145
+ const y = d.__vccOpts || d;
146
+ for (const [f, w] of i)
147
+ y[f] = w;
148
+ return y;
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(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;
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
- function C() {
159
- f.value = !1;
158
+ function w() {
159
+ i.value = !1;
160
+ }
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
+ return;
168
+ }
169
+ i.value = !i.value;
160
170
  }
161
- function c() {
162
- f.value = !f.value;
171
+ function N(x) {
172
+ d.panelClickStopPropagation && x.stopPropagation();
163
173
  }
164
- return { hexValue: g, panelShow: f, closePanel: C, togglePanel: c, entryStylesActual: d };
174
+ return { hexValue: y, panelShow: i, closePanel: w, togglePanel: p, panelBodyClick: N, entryStylesActual: f };
165
175
  }
166
176
  function ie() {
167
177
  window.alert("https://www.npmjs.com/package/@aurouscia/au-color-picker");
168
178
  }
169
- const Ne = { class: "acpRing" }, _e = { class: "acpParams" }, De = {
179
+ const He = { class: "acp" }, Ne = { class: "acpRing" }, Re = { class: "acpParams" }, _e = {
170
180
  key: 0,
171
181
  class: "acpSingleInput"
172
- }, Me = ["value"], Re = {
182
+ }, Te = ["value"], Me = {
173
183
  key: 1,
174
184
  class: "acpTripleInputs"
175
- }, Te = ["value"], Ae = ["value"], $e = ["value"], Ee = {
185
+ }, Ae = ["value"], $e = ["value"], Ee = ["value"], Ve = {
176
186
  key: 2,
177
187
  class: "acpTripleInputs"
178
- }, Ve = ["value"], qe = ["value"], Le = ["value"], Oe = { class: "acpDoneBtn" }, Ue = /* @__PURE__ */ Q({
188
+ }, qe = ["value"], Le = ["value"], Oe = ["value"], Ue = { class: "acpDoneBtn" }, ze = /* @__PURE__ */ Q({
179
189
  __name: "AuColorPicker",
180
190
  props: {
181
191
  initial: {},
@@ -184,163 +194,164 @@ const Ne = { class: "acpRing" }, _e = { class: "acpParams" }, De = {
184
194
  entryClassName: {},
185
195
  pos: {},
186
196
  panelBaseZIndex: {},
197
+ entryRespondDelay: {},
198
+ panelClickStopPropagation: { type: Boolean },
187
199
  showPackageName: { type: Boolean }
188
200
  },
189
201
  emits: ["change", "done"],
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();
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), $();
194
206
  }
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;
199
- if ("value" in e) {
200
- const I = e.value;
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;
201
213
  if (I && le(I)) {
202
- c.value = o(I), (t = C.value) == null || t.enforceTo(c.value), R();
214
+ r.value = g(I), (n = w.value) == null || n.enforceTo(r.value), $();
203
215
  return;
204
216
  }
205
- e.value = c.value;
217
+ t.value = r.value;
206
218
  }
207
219
  }
208
- function i(y, e) {
220
+ function u(m, t) {
209
221
  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);
215
- if (isNaN(u))
216
- t.value = "0";
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";
217
229
  else {
218
- u > 255 ? u = 255 : u < 0 && (u = 0);
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();
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(), $();
221
233
  return;
222
234
  }
223
235
  }
224
236
  }
225
237
  }
226
- function p(y, e) {
238
+ function e(m, t) {
227
239
  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);
233
- if (isNaN(u))
234
- t.value = "0";
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";
235
247
  else {
236
- e === "h" ? u > 359 && (u = 359) : u > 100 && (u = 100), u < 0 && (u = 0);
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();
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), $();
239
251
  return;
240
252
  }
241
253
  }
242
254
  }
243
255
  }
244
- function o(y) {
245
- return y.startsWith("#") ? y.toUpperCase() : "#" + y.toUpperCase();
256
+ function g(m) {
257
+ return m.startsWith("#") ? m.toUpperCase() : "#" + m.toUpperCase();
246
258
  }
247
- function R() {
248
- z("change", c.value);
259
+ function $() {
260
+ W("change", r.value);
249
261
  }
250
262
  function j() {
251
- return c.value;
263
+ return r.value;
252
264
  }
253
265
  re(() => {
254
- d.initial && le(d.initial) && (c.value = o(d.initial));
266
+ f.initial && le(f.initial) && (r.value = g(f.initial));
255
267
  });
256
- const z = g;
257
- return f({ closePanel: $, getCurrentHex: j }), Y(l, (y) => {
258
- y === !1 && z("done", c.value);
259
- }), (y, e) => (N(), _("div", {
260
- class: "acp",
261
- onClick: e[10] || (e[10] = (t) => t.stopPropagation())
262
- }, [
263
- r("div", {
264
- class: he(y.entryClassName || "acpEntry"),
265
- style: O(P(U)),
266
- onClick: e[0] || (e[0] = //@ts-ignore
267
- (...t) => P(w) && P(w)(...t))
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", {
273
+ class: he(m.entryClassName || "acpEntry"),
274
+ style: U(h(z)),
275
+ onClick: t[0] || (t[0] = //@ts-ignore
276
+ (...n) => h(x) && h(x)(...n))
268
277
  }, null, 6),
269
- P(l) ? (N(), _("div", {
278
+ h(p) ? (T(), M("div", {
270
279
  key: 0,
271
280
  class: "acpPanel",
272
- style: O({ zIndex: (y.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))
273
284
  }, [
274
- r("div", Ne, [
275
- ue(He, {
285
+ l("div", Ne, [
286
+ ue(De, {
276
287
  ref_key: "ring",
277
- ref: C,
278
- "initial-hex": P(c),
279
- onChanged: D,
280
- "show-package-name": y.showPackageName
288
+ ref: w,
289
+ "initial-hex": h(r),
290
+ onChanged: P,
291
+ "show-package-name": m.showPackageName
281
292
  }, null, 8, ["initial-hex", "show-package-name"])
282
293
  ]),
283
- r("div", _e, [
284
- G(r("select", {
285
- "onUpdate:modelValue": e[1] || (e[1] = (t) => h.value = t)
286
- }, e[11] || (e[11] = [
287
- r("option", { value: "hex" }, "HEX", -1),
288
- r("option", { value: "rgb" }, "RGB", -1),
289
- r("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)
290
301
  ]), 512), [
291
- [xe, h.value]
302
+ [xe, R.value]
292
303
  ]),
293
- h.value == "hex" ? (N(), _("div", De, [
294
- r("input", {
295
- value: P(c),
296
- onBlur: M,
304
+ R.value == "hex" ? (T(), M("div", _e, [
305
+ l("input", {
306
+ value: h(r),
307
+ onBlur: A,
297
308
  spellcheck: "false",
298
309
  maxlength: "7"
299
- }, null, 40, Me)
300
- ])) : h.value == "rgb" ? (N(), _("div", Re, [
301
- r("input", {
302
- value: B.value[0],
303
- onBlur: e[2] || (e[2] = (t) => i(t, "r"))
304
- }, null, 40, Te),
305
- r("input", {
306
- value: B.value[1],
307
- onBlur: e[3] || (e[3] = (t) => i(t, "g"))
310
+ }, null, 40, Te)
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"))
308
315
  }, null, 40, Ae),
309
- r("input", {
310
- value: B.value[2],
311
- onBlur: e[4] || (e[4] = (t) => i(t, "b"))
312
- }, null, 40, $e)
313
- ])) : (N(), _("div", Ee, [
314
- r("input", {
315
- value: S.value[0],
316
- onBlur: e[5] || (e[5] = (t) => p(t, "h"))
317
- }, null, 40, Ve),
318
- r("input", {
319
- value: S.value[1],
320
- onBlur: e[6] || (e[6] = (t) => p(t, "s"))
316
+ l("input", {
317
+ value: C.value[1],
318
+ onBlur: t[3] || (t[3] = (n) => u(n, "g"))
319
+ }, null, 40, $e),
320
+ l("input", {
321
+ value: C.value[2],
322
+ onBlur: t[4] || (t[4] = (n) => u(n, "b"))
323
+ }, null, 40, Ee)
324
+ ])) : (T(), M("div", Ve, [
325
+ l("input", {
326
+ value: D.value[0],
327
+ onBlur: t[5] || (t[5] = (n) => e(n, "h"))
321
328
  }, 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)
329
+ l("input", {
330
+ value: D.value[1],
331
+ onBlur: t[6] || (t[6] = (n) => e(n, "s"))
332
+ }, null, 40, Le),
333
+ l("input", {
334
+ value: D.value[2],
335
+ onBlur: t[7] || (t[7] = (n) => e(n, "v"))
336
+ }, null, 40, Oe)
326
337
  ]))
327
338
  ]),
328
- r("div", Oe, [
329
- r("button", {
330
- onClick: e[8] || (e[8] = //@ts-ignore
331
- (...t) => P($) && P($)(...t))
339
+ l("div", Ue, [
340
+ l("button", {
341
+ onClick: t[8] || (t[8] = //@ts-ignore
342
+ (...n) => h(N) && h(N)(...n))
332
343
  }, "OK")
333
344
  ]),
334
- y.showPackageName ? (N(), _("div", {
345
+ m.showPackageName ? (T(), M("div", {
335
346
  key: 0,
336
347
  class: "acpPackageName",
337
- onClick: e[9] || (e[9] = //@ts-ignore
338
- (...t) => P(ie) && P(ie)(...t))
348
+ onClick: t[9] || (t[9] = //@ts-ignore
349
+ (...n) => h(ie) && h(ie)(...n))
339
350
  }, " au-color-picker ")) : J("", !0)
340
351
  ], 4)) : J("", !0)
341
352
  ]));
342
353
  }
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({
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({
344
355
  __name: "AuColorPickerPresetsNested",
345
356
  props: {
346
357
  initialSelectedPreset: {},
@@ -351,100 +362,104 @@ const Ne = { class: "acpRing" }, _e = { class: "acpParams" }, De = {
351
362
  entryClassName: {},
352
363
  pos: {},
353
364
  panelBaseZIndex: {},
365
+ entryRespondDelay: {},
366
+ panelClickStopPropagation: { type: Boolean },
354
367
  showPackageName: { type: Boolean }
355
368
  },
356
369
  emits: ["change", "done", "presetSwitched"],
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");
359
- function h(i) {
360
- i ? (w.value = i.name, d.value = i.colorHex) : (w.value = void 0, d.value = D.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);
361
374
  }
362
- const B = f;
363
- function S(i) {
364
- d.value = i, D.value = i, B("change", i);
375
+ const C = i;
376
+ function D(u) {
377
+ f.value = u, P.value = u, C("change", u);
365
378
  }
366
- function M(i) {
367
- d.value = i, D.value = i, c();
379
+ function A(u) {
380
+ f.value = u, P.value = u, r();
368
381
  }
369
- return Y(C, (i) => {
370
- i === !1 && B("done", d.value);
371
- }), Y(w, (i) => {
372
- B("presetSwitched", i);
382
+ return Y(w, (u) => {
383
+ u === !1 && C("done", f.value);
384
+ }), Y(b, (u) => {
385
+ C("presetSwitched", u);
373
386
  }), re(() => {
374
- var i;
375
- if (g.initial && (d.value = g.initial, D.value = g.initial), g.initialSelectedPreset) {
376
- const p = (i = g.presets) == null ? void 0 : i.find((o) => o.name === g.initialSelectedPreset);
377
- p && h(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);
378
391
  }
379
- }), (i, p) => (N(), _("div", We, [
380
- r("div", {
392
+ }), (u, e) => (T(), M("div", Ze, [
393
+ l("div", {
381
394
  class: "acpEntry",
382
- style: O(P($)),
383
- onClick: p[0] || (p[0] = //@ts-ignore
384
- (...o) => P(l) && P(l)(...o))
395
+ style: U(h(x)),
396
+ onClick: e[0] || (e[0] = //@ts-ignore
397
+ (...g) => h(p) && h(p)(...g))
385
398
  }, null, 4),
386
- P(C) ? (N(), _("div", {
399
+ h(w) ? (T(), M("div", {
387
400
  key: 0,
388
401
  class: "acpPanel",
389
- style: O({ zIndex: (i.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))
390
405
  }, [
391
- r("div", Ze, [
392
- r("label", je, [
393
- ue(ze, {
394
- initial: D.value,
395
- onChange: S,
396
- onDone: M,
406
+ l("div", je, [
407
+ l("label", Xe, [
408
+ ue(We, {
409
+ initial: P.value,
410
+ onChange: D,
411
+ onDone: A,
397
412
  "entry-class-name": "acpPresetBody",
398
413
  ref_key: "customPicker",
399
- ref: U,
400
- "show-package-name": i.showPackageName
414
+ ref: z,
415
+ "show-package-name": u.showPackageName
401
416
  }, null, 8, ["initial", "show-package-name"]),
402
- G(r("input", {
417
+ G(l("input", {
403
418
  name: "colorType",
404
419
  type: "radio",
405
420
  id: "acpColorPresetCustom",
406
421
  value: void 0,
407
- "onUpdate:modelValue": p[1] || (p[1] = (o) => w.value = o),
408
- onClick: p[2] || (p[2] = (o) => h())
422
+ "onUpdate:modelValue": e[1] || (e[1] = (g) => b.value = g),
423
+ onClick: e[2] || (e[2] = (g) => R())
409
424
  }, null, 512), [
410
- [te, w.value]
425
+ [te, b.value]
411
426
  ]),
412
- p[5] || (p[5] = r("div", { class: "acpPresetName" }, "自定义", -1))
427
+ e[6] || (e[6] = l("div", { class: "acpPresetName" }, "自定义", -1))
413
428
  ]),
414
- p[6] || (p[6] = r("div", { class: "acpSep" }, null, -1)),
415
- (N(!0), _(Pe, null, ke(i.presets, (o) => (N(), _("label", {
416
- 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}`
417
432
  }, [
418
- r("div", {
433
+ l("div", {
419
434
  class: "acpPresetBody",
420
- style: O({ backgroundColor: o.colorHex })
435
+ style: U({ backgroundColor: g.colorHex })
421
436
  }, null, 4),
422
- G(r("input", {
437
+ G(l("input", {
423
438
  name: "colorType",
424
439
  type: "radio",
425
- id: `acpColorPreset${o.name}`,
426
- value: o.name,
427
- "onUpdate:modelValue": p[3] || (p[3] = (R) => w.value = R),
428
- onClick: (R) => h(o)
429
- }, null, 8, Fe), [
430
- [te, w.value]
440
+ id: `acpColorPreset${g.name}`,
441
+ value: g.name,
442
+ "onUpdate:modelValue": e[3] || (e[3] = ($) => b.value = $),
443
+ onClick: ($) => R(g)
444
+ }, null, 8, Ke), [
445
+ [te, b.value]
431
446
  ]),
432
- r("div", Ke, Ce(o.name), 1)
433
- ], 8, Xe))), 256)),
434
- p[7] || (p[7] = r("div", { class: "acpSep" }, null, -1))
447
+ l("div", Ye, Ce(g.name), 1)
448
+ ], 8, Fe))), 256)),
449
+ e[8] || (e[8] = l("div", { class: "acpSep" }, null, -1))
435
450
  ]),
436
- r("div", Ye, [
437
- r("button", {
438
- onClick: p[4] || (p[4] = //@ts-ignore
439
- (...o) => P(c) && P(c)(...o))
451
+ l("div", Ge, [
452
+ l("button", {
453
+ onClick: e[4] || (e[4] = //@ts-ignore
454
+ (...g) => h(r) && h(r)(...g))
440
455
  }, "OK")
441
456
  ])
442
457
  ], 4)) : J("", !0)
443
458
  ]));
444
459
  }
445
- }), et = /* @__PURE__ */ ee(Ge, [["__scopeId", "data-v-e312908b"]]);
460
+ }), tt = /* @__PURE__ */ ee(Je, [["__scopeId", "data-v-6a0f5881"]]);
446
461
  export {
447
- ze as AuColorPicker,
448
- et as AuColorPickerPresetsNested,
449
- He as AuColorPickerRing
462
+ We as AuColorPicker,
463
+ tt as AuColorPickerPresetsNested,
464
+ De as AuColorPickerRing
450
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-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
+ .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}
@@ -6,6 +6,8 @@ export interface PickerProps {
6
6
  entryClassName?: string;
7
7
  pos?: 'left' | 'right';
8
8
  panelBaseZIndex?: number;
9
+ entryRespondDelay?: number;
10
+ panelClickStopPropagation?: boolean;
9
11
  showPackageName?: boolean;
10
12
  }
11
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.2.0",
17
+ "version": "0.4.0",
18
18
  "type": "module",
19
19
  "files": [
20
20
  "dist"