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