@aurouscia/au-color-picker 0.4.1 → 0.4.3

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