@aurouscia/au-color-picker 0.4.0 → 0.4.2

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