@aurouscia/au-color-picker 0.0.6 → 0.1.1

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,325 +1,431 @@
1
- import { defineComponent as ee, ref as S, onMounted as le, onUnmounted as ue, openBlock as L, createElementBlock as V, normalizeStyle as $, isRef as ie, createElementVNode as d, computed as Y, onBeforeMount as re, watch as ce, createVNode as ve, withDirectives as fe, vModelSelect as de, createCommentVNode as pe } from "vue";
2
- import k from "color-convert";
3
- function ge(g, v) {
4
- const x = g.x - v.x, c = g.y - v.y;
5
- return x ** 2 + c ** 2;
1
+ import { defineComponent as G, ref as b, onMounted as pe, onUnmounted as ge, openBlock as B, createElementBlock as D, normalizeStyle as U, isRef as ye, createElementVNode as i, computed as K, onBeforeMount as le, watch as ae, normalizeClass as me, unref as k, createVNode as ie, withDirectives as Y, vModelSelect as xe, createCommentVNode as re, vModelRadio as Q, Fragment as he, renderList as Ce, toDisplayString as Pe } from "vue";
2
+ import A from "color-convert";
3
+ function ke(p, v) {
4
+ const y = p.x - v.x, f = p.y - v.y;
5
+ return y ** 2 + f ** 2;
6
6
  }
7
- function he(g, v) {
8
- const x = g.x - v.x, c = g.y - v.y;
9
- return Math.atan2(c, x);
7
+ function Se(p, v) {
8
+ const y = p.x - v.x, f = p.y - v.y;
9
+ return Math.atan2(f, y);
10
10
  }
11
- function xe(g) {
12
- let v = g, x = 0, c = 0;
11
+ function Ie(p) {
12
+ let v = p, y = 0, f = 0;
13
13
  for (; v !== null; )
14
- x += v.offsetTop, c += v.offsetLeft, v = v.offsetParent;
15
- return { y: x, x: c };
14
+ y += v.offsetTop, f += v.offsetLeft, v = v.offsetParent;
15
+ return { y, x: f };
16
16
  }
17
- const C = 400, E = 400, Z = 200, ye = 200, F = 190, G = 150, A = 200, K = 16, J = 3, me = /* @__PURE__ */ ee({
17
+ const _ = 400, L = 400, F = 200, we = 200, ee = 190, te = 150, O = 200, ne = 16, se = 3, be = /* @__PURE__ */ G({
18
18
  __name: "AuColorPickerRing",
19
19
  props: {
20
20
  initialHex: {}
21
21
  },
22
22
  emits: ["changed"],
23
- setup(g, { expose: v, emit: x }) {
24
- const c = S(), H = S();
25
- let I, u;
26
- const N = { x: 199, y: 199 }, U = (F + G) / 2, X = F ** 2, M = G ** 2, r = (C - A) / 2, b = r + A, m = S(0), B = S(100), P = S(100), R = g;
27
- let f;
23
+ setup(p, { expose: v, emit: y }) {
24
+ const f = b(), P = b();
25
+ let u, l;
26
+ const $ = { x: 199, y: 199 }, I = (ee + te) / 2, V = ee ** 2, M = te ** 2, h = (_ - O) / 2, H = h + O, S = b(0), R = b(100), d = b(100), g = p;
27
+ let a;
28
28
  function T() {
29
- var n, a;
30
- const e = (n = c.value) == null ? void 0 : n.getContext("2d"), t = (a = H.value) == null ? void 0 : a.getContext("2d");
31
- if (!e || !t)
29
+ var o, c;
30
+ const t = (o = f.value) == null ? void 0 : o.getContext("2d"), n = (c = P.value) == null ? void 0 : c.getContext("2d");
31
+ if (!t || !n)
32
32
  throw Error("canvas context getting error");
33
- if (R.initialHex) {
34
- const h = k.hex.hsv(R.initialHex);
35
- m.value = h[0], B.value = h[1], P.value = h[2];
33
+ if (g.initialHex) {
34
+ const x = A.hex.hsv(g.initialHex);
35
+ S.value = x[0], R.value = x[1], d.value = x[2];
36
36
  }
37
- I = e, u = t, f = I.getImageData(0, 0, C, E), z(), s(), j(), I.putImageData(f, 0, 0);
37
+ u = t, l = n, a = u.getImageData(0, 0, _, L), X(), e(), j(), u.putImageData(a, 0, 0);
38
38
  }
39
- function z() {
40
- for (let e = 0; e < C; e++)
41
- for (let t = 0; t < E; t++) {
42
- const n = { x: e, y: t };
43
- if (o(n)) {
44
- const a = n.y * C * 4 + n.x * 4, h = l(n), _ = k.hsv.rgb([h, 100, 100]);
45
- f.data[a] = _[0], f.data[a + 1] = _[1], f.data[a + 2] = _[2], f.data[a + 3] = 255;
39
+ function X() {
40
+ for (let t = 0; t < _; t++)
41
+ for (let n = 0; n < L; n++) {
42
+ const o = { x: t, y: n };
43
+ if (m(o)) {
44
+ const c = o.y * _ * 4 + o.x * 4, x = z(o), E = A.hsv.rgb([x, 100, 100]);
45
+ a.data[c] = E[0], a.data[c + 1] = E[1], a.data[c + 2] = E[2], a.data[c + 3] = 255;
46
46
  }
47
47
  }
48
48
  }
49
- function l(e) {
50
- return 360 * ((he(e, N) + Math.PI) / (2 * Math.PI));
49
+ function z(t) {
50
+ return 360 * ((Se(t, $) + Math.PI) / (2 * Math.PI));
51
51
  }
52
- function o(e) {
53
- const t = ge(N, e);
54
- return t > M && t < X;
52
+ function m(t) {
53
+ const n = ke($, t);
54
+ return n > M && n < V;
55
55
  }
56
- function s() {
57
- for (let e = 0; e < C; e++)
58
- for (let t = 0; t < E; t++) {
59
- const n = { x: e, y: t };
60
- if (w(n)) {
61
- const a = n.y * C * 4 + n.x * 4, { s: h, v: _ } = y(n), q = k.hsv.rgb([m.value, h, _]);
62
- f.data[a] = q[0], f.data[a + 1] = q[1], f.data[a + 2] = q[2], f.data[a + 3] = 255;
56
+ function e() {
57
+ for (let t = 0; t < _; t++)
58
+ for (let n = 0; n < L; n++) {
59
+ const o = { x: t, y: n };
60
+ if (w(o)) {
61
+ const c = o.y * _ * 4 + o.x * 4, { s: x, v: E } = s(o), q = A.hsv.rgb([S.value, x, E]);
62
+ a.data[c] = q[0], a.data[c + 1] = q[1], a.data[c + 2] = q[2], a.data[c + 3] = 255;
63
63
  }
64
64
  }
65
65
  }
66
- function y(e) {
67
- const t = e.x - r, n = e.y - r;
68
- let a = t / A, h = 1 - n / A;
69
- return a > 1 ? a = 1 : a < 0 && (a = 0), h > 1 ? h = 1 : h < 0 && (h = 0), { s: 100 * a, v: 100 * h };
66
+ function s(t) {
67
+ const n = t.x - h, o = t.y - h;
68
+ let c = n / O, x = 1 - o / O;
69
+ return c > 1 ? c = 1 : c < 0 && (c = 0), x > 1 ? x = 1 : x < 0 && (x = 0), { s: 100 * c, v: 100 * x };
70
70
  }
71
- function w(e) {
72
- return !(e.x < r || e.x > b || e.y < r || e.y > b);
71
+ function w(t) {
72
+ return !(t.x < h || t.x > H || t.y < h || t.y > H);
73
73
  }
74
- let i = !1, p = "none", O = !1;
75
- function W(e, t) {
76
- if (i || t && !O)
74
+ let N = !1, r = "none", C = !1;
75
+ function Z(t, n) {
76
+ if (N || n && !C)
77
77
  return;
78
- i = !0;
79
- const n = ne(e);
80
- if (p === "none" && (w(n) ? p = "square" : o(n) && (p = "ring")), p === "ring" && (e.preventDefault(), m.value = l(n), s(), I.putImageData(f, 0, 0)), p === "square") {
81
- e.preventDefault();
82
- const a = y(n);
83
- B.value = a.s, P.value = a.v;
78
+ N = !0;
79
+ const o = ce(t);
80
+ if (r === "none" && (w(o) ? r = "square" : m(o) && (r = "ring")), r === "ring" && (t.preventDefault(), S.value = z(o), e(), u.putImageData(a, 0, 0)), r === "square") {
81
+ t.preventDefault();
82
+ const c = s(o);
83
+ R.value = c.s, d.value = c.v;
84
84
  }
85
- p !== "none" && j(!0), i = !1;
85
+ r !== "none" && j(!0), N = !1;
86
86
  }
87
- function D() {
88
- p = "none", O = !1;
87
+ function W() {
88
+ r = "none", C = !1;
89
89
  }
90
- function ne(e) {
91
- let t, n;
92
- if ("touches" in e) {
93
- t = e.touches[0].pageX, n = e.touches[0].pageY;
94
- const a = xe(c.value);
95
- t -= a.x, n -= a.y;
90
+ function ce(t) {
91
+ let n, o;
92
+ if ("touches" in t) {
93
+ n = t.touches[0].pageX, o = t.touches[0].pageY;
94
+ const c = Ie(f.value);
95
+ n -= c.x, o -= c.y;
96
96
  } else
97
- t = e.offsetX, n = e.offsetY;
98
- return t = t * C / Z, n = n * C / Z, { x: t, y: n };
97
+ n = t.offsetX, o = t.offsetY;
98
+ return n = n * _ / F, o = o * _ / F, { x: n, y: o };
99
99
  }
100
- function j(e) {
101
- if (e) {
102
- const ae = k.hsv.hex([m.value, B.value, P.value]);
103
- se("changed", ae);
100
+ function j(t) {
101
+ if (t) {
102
+ const de = A.hsv.hex([S.value, R.value, d.value]);
103
+ fe("changed", de);
104
104
  }
105
- const t = (m.value / 360 * 2 + 1) * Math.PI, n = Math.cos(t) * U + C / 2, a = Math.sin(t) * U + E / 2, h = B.value / 100 * A + r, _ = (1 - P.value / 100) * A + r;
106
- u.reset(), u.lineWidth = 4, u.strokeStyle = "black", u.beginPath(), u.arc(n, a, K - 2, 0, 2 * Math.PI), u.stroke(), u.beginPath(), u.arc(n, a, J, 0, 2 * Math.PI), u.fill();
107
- const q = P.value > 50 ? "black" : "#ddd";
108
- u.strokeStyle = q, u.fillStyle = q, u.beginPath(), u.arc(h, _, K - 2, 0, 2 * Math.PI), u.stroke(), u.beginPath(), u.arc(h, _, J, 0, 2 * Math.PI), u.fill();
105
+ const n = (S.value / 360 * 2 + 1) * Math.PI, o = Math.cos(n) * I + _ / 2, c = Math.sin(n) * I + L / 2, x = R.value / 100 * O + h, E = (1 - d.value / 100) * O + h;
106
+ l.reset(), l.lineWidth = 4, l.strokeStyle = "black", l.beginPath(), l.arc(o, c, ne - 2, 0, 2 * Math.PI), l.stroke(), l.beginPath(), l.arc(o, c, se, 0, 2 * Math.PI), l.fill();
107
+ const q = d.value > 50 ? "black" : "#ddd";
108
+ l.strokeStyle = q, l.fillStyle = q, l.beginPath(), l.arc(x, E, ne - 2, 0, 2 * Math.PI), l.stroke(), l.beginPath(), l.arc(x, E, se, 0, 2 * Math.PI), l.fill();
109
109
  }
110
- function oe(e) {
111
- const t = k.hex.hsv(e);
112
- m.value = t[0], B.value = t[1], P.value = t[2], s(), I.putImageData(f, 0, 0), j();
110
+ function ve(t) {
111
+ const n = A.hex.hsv(t);
112
+ S.value = n[0], R.value = n[1], d.value = n[2], e(), u.putImageData(a, 0, 0), j();
113
113
  }
114
- const se = x;
115
- return v({ enforceTo: oe }), le(() => {
116
- T(), window.addEventListener("touchend", D), window.addEventListener("mouseup", D);
117
- }), ue(() => {
118
- window.removeEventListener("touchend", D), window.removeEventListener("mouseup", D);
119
- }), (e, t) => (L(), V("div", {
114
+ const fe = y;
115
+ return v({ enforceTo: ve }), pe(() => {
116
+ T(), window.addEventListener("touchend", W), window.addEventListener("mouseup", W);
117
+ }), ge(() => {
118
+ window.removeEventListener("touchend", W), window.removeEventListener("mouseup", W);
119
+ }), (t, n) => (B(), D("div", {
120
120
  class: "acpRingBody",
121
- style: $({ width: Z + "px", height: ye + "px" }),
122
- onTouchstart: W,
123
- onTouchmove: W,
124
- onTouchend: D,
125
- onMouseleave: D,
126
- onMousemove: t[0] || (t[0] = (n) => W(n, !0)),
127
- onMousedown: t[1] || (t[1] = (n) => {
128
- W(n), ie(O) ? O.value = !0 : O = !0;
121
+ style: U({ width: F + "px", height: we + "px" }),
122
+ onTouchstart: Z,
123
+ onTouchmove: Z,
124
+ onTouchend: W,
125
+ onMousemove: n[0] || (n[0] = (o) => Z(o, !0)),
126
+ onMousedown: n[1] || (n[1] = (o) => {
127
+ Z(o), ye(C) ? C.value = !0 : C = !0;
129
128
  })
130
129
  }, [
131
- d("canvas", {
132
- width: C,
133
- height: E,
130
+ i("canvas", {
131
+ width: _,
132
+ height: L,
134
133
  ref_key: "cvs",
135
- ref: c
134
+ ref: f
136
135
  }, null, 512),
137
- d("canvas", {
138
- width: C,
139
- height: E,
136
+ i("canvas", {
137
+ width: _,
138
+ height: L,
140
139
  ref_key: "cursorCvs",
141
- ref: H
140
+ ref: P
142
141
  }, null, 512)
143
142
  ], 36));
144
143
  }
145
- }), te = (g, v) => {
146
- const x = g.__vccOpts || g;
147
- for (const [c, H] of v)
148
- x[c] = H;
149
- return x;
150
- }, Ce = /* @__PURE__ */ te(me, [["__scopeId", "data-v-7f97ab8e"]]);
151
- function Q(g) {
152
- return /^#([0-9A-F]{3}){1,2}$/i.test(g);
144
+ }), J = (p, v) => {
145
+ const y = p.__vccOpts || p;
146
+ for (const [f, P] of v)
147
+ y[f] = P;
148
+ return y;
149
+ }, _e = /* @__PURE__ */ J(be, [["__scopeId", "data-v-505caf85"]]);
150
+ function oe(p) {
151
+ return /^#([0-9A-F]{3}){1,2}$/i.test(p);
153
152
  }
154
- const Ie = { class: "acpRing" }, Pe = { class: "acpParams" }, Se = {
153
+ function ue(p) {
154
+ const v = b(!1), y = b("#ff0000"), f = K(() => {
155
+ let l = {};
156
+ return v.value || (l.boxShadow = "none"), p.entryStyles && Object.assign(l, p.entryStyles), v.value && (l.transition = "0s", Object.assign(l, p.entryActiveStyles)), l.backgroundColor = y.value, p.pos === "right" ? l.right = "0px" : l.left = "0px", l;
157
+ });
158
+ function P() {
159
+ v.value = !1;
160
+ }
161
+ function u() {
162
+ v.value = !v.value;
163
+ }
164
+ return { hexValue: y, panelShow: v, closePanel: P, togglePanel: u, entryStylesActual: f };
165
+ }
166
+ const He = { class: "acpRing" }, Be = { class: "acpParams" }, De = {
155
167
  key: 0,
156
168
  class: "acpSingleInput"
157
- }, ke = ["value"], we = {
169
+ }, Me = ["value"], Re = {
158
170
  key: 1,
159
171
  class: "acpTripleInputs"
160
- }, _e = ["value"], be = ["value"], Be = ["value"], He = {
172
+ }, Te = ["value"], Ne = ["value"], Ae = ["value"], $e = {
161
173
  key: 2,
162
174
  class: "acpTripleInputs"
163
- }, Me = ["value"], Re = ["value"], Te = ["value"], De = /* @__PURE__ */ ee({
175
+ }, Ee = ["value"], Ve = ["value"], qe = ["value"], Le = { class: "acpDoneBtn" }, Oe = /* @__PURE__ */ G({
164
176
  __name: "AuColorPicker",
165
177
  props: {
166
178
  inital: {},
167
179
  entryStyles: {},
168
180
  entryActiveStyles: {},
181
+ entryClassName: {},
169
182
  pos: {},
170
- panelBaseZIndex: {}
183
+ panelBaseZIndex: {},
184
+ presets: {}
171
185
  },
172
186
  emits: ["change", "done"],
173
- setup(g, { expose: v, emit: x }) {
174
- const c = g, H = Y(() => {
175
- let l = {};
176
- return u.value || (l.boxShadow = "none"), c.entryStyles && Object.assign(l, c.entryStyles), u.value && (l.transition = "0s", Object.assign(l, c.entryActiveStyles)), l.backgroundColor = r.value, c.pos === "right" ? l.right = "0px" : l.left = "0px", l;
177
- }), I = S(), u = S(!1);
178
- function N() {
179
- u.value = !1;
180
- }
181
- function U() {
182
- u.value = !u.value;
187
+ setup(p, { expose: v, emit: y }) {
188
+ const f = p, P = b(), { hexValue: u, panelShow: l, closePanel: $, togglePanel: I, entryStylesActual: V } = ue(f);
189
+ function M(m) {
190
+ u.value = a(m), T();
183
191
  }
184
- function X(l) {
185
- r.value = f(l), T();
186
- }
187
- const M = S("hex"), r = S("#ff0000"), b = Y(() => k.hex.rgb(r.value)), m = Y(() => k.hex.hsv(r.value));
188
- function B(l) {
192
+ const h = b("hex"), H = K(() => A.hex.rgb(u.value)), S = K(() => A.hex.hsv(u.value));
193
+ function R(m) {
189
194
  var s;
190
- const o = l.target;
191
- if ("value" in o) {
192
- const y = o.value;
193
- if (y && Q(y)) {
194
- r.value = f(y), (s = I.value) == null || s.enforceTo(r.value), T();
195
+ const e = m.target;
196
+ if ("value" in e) {
197
+ const w = e.value;
198
+ if (w && oe(w)) {
199
+ u.value = a(w), (s = P.value) == null || s.enforceTo(u.value), T();
195
200
  return;
196
201
  }
197
- o.value = r.value;
202
+ e.value = u.value;
198
203
  }
199
204
  }
200
- function P(l, o) {
201
- var y;
202
- const s = l.target;
205
+ function d(m, e) {
206
+ var w;
207
+ const s = m.target;
203
208
  if ("value" in s) {
204
- const w = s.value;
205
- if (w) {
206
- let i = parseInt(w);
207
- if (isNaN(i))
209
+ const N = s.value;
210
+ if (N) {
211
+ let r = parseInt(N);
212
+ if (isNaN(r))
208
213
  s.value = "0";
209
214
  else {
210
- i > 255 ? i = 255 : i < 0 && (i = 0);
211
- const p = [...b.value];
212
- o == "r" ? p[0] = i : o == "g" ? p[1] = i : p[2] = i, r.value = f(k.rgb.hex(p)), (y = I.value) == null || y.enforceTo(r.value), s.value = i.toString(), T();
215
+ r > 255 ? r = 255 : r < 0 && (r = 0);
216
+ const C = [...H.value];
217
+ e == "r" ? C[0] = r : e == "g" ? C[1] = r : C[2] = r, u.value = a(A.rgb.hex(C)), (w = P.value) == null || w.enforceTo(u.value), s.value = r.toString(), T();
213
218
  return;
214
219
  }
215
220
  }
216
221
  }
217
222
  }
218
- function R(l, o) {
219
- var y;
220
- const s = l.target;
223
+ function g(m, e) {
224
+ var w;
225
+ const s = m.target;
221
226
  if ("value" in s) {
222
- const w = s.value;
223
- if (w) {
224
- let i = parseInt(w);
225
- if (isNaN(i))
227
+ const N = s.value;
228
+ if (N) {
229
+ let r = parseInt(N);
230
+ if (isNaN(r))
226
231
  s.value = "0";
227
232
  else {
228
- o === "h" ? i > 359 && (i = 359) : i > 100 && (i = 100), i < 0 && (i = 0);
229
- const p = [...m.value];
230
- o == "h" ? p[0] = i : o == "s" ? p[1] = i : p[2] = i, r.value = f(k.hsv.hex(p)), s.value = i.toString(), (y = I.value) == null || y.enforceTo(r.value), T();
233
+ e === "h" ? r > 359 && (r = 359) : r > 100 && (r = 100), r < 0 && (r = 0);
234
+ const C = [...S.value];
235
+ e == "h" ? C[0] = r : e == "s" ? C[1] = r : C[2] = r, u.value = a(A.hsv.hex(C)), s.value = r.toString(), (w = P.value) == null || w.enforceTo(u.value), T();
231
236
  return;
232
237
  }
233
238
  }
234
239
  }
235
240
  }
236
- function f(l) {
237
- return l.startsWith("#") ? l.toUpperCase() : "#" + l.toUpperCase();
241
+ function a(m) {
242
+ return m.startsWith("#") ? m.toUpperCase() : "#" + m.toUpperCase();
238
243
  }
239
244
  function T() {
240
- z("change", r.value);
245
+ z("change", u.value);
246
+ }
247
+ function X() {
248
+ return u.value;
241
249
  }
242
- re(() => {
243
- c.inital && Q(c.inital) && (r.value = f(c.inital));
250
+ le(() => {
251
+ f.inital && oe(f.inital) && (u.value = a(f.inital));
244
252
  });
245
- const z = x;
246
- return v({ closePanel: N }), ce(u, (l) => {
247
- l === !1 && z("done", r.value);
248
- }), (l, o) => (L(), V("div", {
253
+ const z = y;
254
+ return v({ closePanel: $, getCurrentHex: X }), ae(l, (m) => {
255
+ m === !1 && z("done", u.value);
256
+ }), (m, e) => (B(), D("div", {
249
257
  class: "acp",
250
- onClick: o[7] || (o[7] = (s) => s.stopPropagation())
258
+ onClick: e[9] || (e[9] = (s) => s.stopPropagation())
251
259
  }, [
252
- d("div", {
253
- class: "acpEntry",
254
- style: $(H.value),
255
- onClick: U
256
- }, null, 4),
257
- u.value ? (L(), V("div", {
260
+ i("div", {
261
+ class: me(m.entryClassName || "acpEntry"),
262
+ style: U(k(V)),
263
+ onClick: e[0] || (e[0] = //@ts-ignore
264
+ (...s) => k(I) && k(I)(...s))
265
+ }, null, 6),
266
+ k(l) ? (B(), D("div", {
258
267
  key: 0,
259
268
  class: "acpPanel",
260
- style: $({ zIndex: (l.panelBaseZIndex || 0) + 100 })
269
+ style: U({ zIndex: (m.panelBaseZIndex || 0) + 100 })
261
270
  }, [
262
- d("div", Ie, [
263
- ve(Ce, {
271
+ i("div", He, [
272
+ ie(_e, {
264
273
  ref_key: "ring",
265
- ref: I,
266
- initialHex: r.value,
267
- onChanged: X
274
+ ref: P,
275
+ initialHex: k(u),
276
+ onChanged: M
268
277
  }, null, 8, ["initialHex"])
269
278
  ]),
270
- d("div", Pe, [
271
- fe(d("select", {
272
- "onUpdate:modelValue": o[0] || (o[0] = (s) => M.value = s)
273
- }, o[8] || (o[8] = [
274
- d("option", { value: "hex" }, "HEX", -1),
275
- d("option", { value: "rgb" }, "RGB", -1),
276
- d("option", { value: "hsv" }, "HSV", -1)
279
+ i("div", Be, [
280
+ Y(i("select", {
281
+ "onUpdate:modelValue": e[1] || (e[1] = (s) => h.value = s)
282
+ }, e[10] || (e[10] = [
283
+ i("option", { value: "hex" }, "HEX", -1),
284
+ i("option", { value: "rgb" }, "RGB", -1),
285
+ i("option", { value: "hsv" }, "HSV", -1)
277
286
  ]), 512), [
278
- [de, M.value]
287
+ [xe, h.value]
279
288
  ]),
280
- M.value == "hex" ? (L(), V("div", Se, [
281
- d("input", {
282
- value: r.value,
283
- onBlur: B,
289
+ h.value == "hex" ? (B(), D("div", De, [
290
+ i("input", {
291
+ value: k(u),
292
+ onBlur: R,
284
293
  spellcheck: "false",
285
294
  maxlength: "7"
286
- }, null, 40, ke)
287
- ])) : M.value == "rgb" ? (L(), V("div", we, [
288
- d("input", {
289
- value: b.value[0],
290
- onBlur: o[1] || (o[1] = (s) => P(s, "r"))
291
- }, null, 40, _e),
292
- d("input", {
293
- value: b.value[1],
294
- onBlur: o[2] || (o[2] = (s) => P(s, "g"))
295
- }, null, 40, be),
296
- d("input", {
297
- value: b.value[2],
298
- onBlur: o[3] || (o[3] = (s) => P(s, "b"))
299
- }, null, 40, Be)
300
- ])) : (L(), V("div", He, [
301
- d("input", {
302
- value: m.value[0],
303
- onBlur: o[4] || (o[4] = (s) => R(s, "h"))
304
- }, null, 40, Me),
305
- d("input", {
306
- value: m.value[1],
307
- onBlur: o[5] || (o[5] = (s) => R(s, "s"))
308
- }, null, 40, Re),
309
- d("input", {
310
- value: m.value[2],
311
- onBlur: o[6] || (o[6] = (s) => R(s, "v"))
312
- }, null, 40, Te)
295
+ }, null, 40, Me)
296
+ ])) : h.value == "rgb" ? (B(), D("div", Re, [
297
+ i("input", {
298
+ value: H.value[0],
299
+ onBlur: e[2] || (e[2] = (s) => d(s, "r"))
300
+ }, null, 40, Te),
301
+ i("input", {
302
+ value: H.value[1],
303
+ onBlur: e[3] || (e[3] = (s) => d(s, "g"))
304
+ }, null, 40, Ne),
305
+ i("input", {
306
+ value: H.value[2],
307
+ onBlur: e[4] || (e[4] = (s) => d(s, "b"))
308
+ }, null, 40, Ae)
309
+ ])) : (B(), D("div", $e, [
310
+ i("input", {
311
+ value: S.value[0],
312
+ onBlur: e[5] || (e[5] = (s) => g(s, "h"))
313
+ }, null, 40, Ee),
314
+ i("input", {
315
+ value: S.value[1],
316
+ onBlur: e[6] || (e[6] = (s) => g(s, "s"))
317
+ }, null, 40, Ve),
318
+ i("input", {
319
+ value: S.value[2],
320
+ onBlur: e[7] || (e[7] = (s) => g(s, "v"))
321
+ }, null, 40, qe)
313
322
  ]))
314
323
  ]),
315
- d("div", { class: "acpDoneBtn" }, [
316
- d("button", { onClick: N }, "OK")
324
+ i("div", Le, [
325
+ i("button", {
326
+ onClick: e[8] || (e[8] = //@ts-ignore
327
+ (...s) => k($) && k($)(...s))
328
+ }, "OK")
329
+ ])
330
+ ], 4)) : re("", !0)
331
+ ]));
332
+ }
333
+ }), Ue = /* @__PURE__ */ J(Oe, [["__scopeId", "data-v-3439ba22"]]), ze = { class: "acp" }, We = { class: "acpNamedPresets" }, Ze = { for: "acpColorPresetCustom" }, Xe = ["for"], je = ["id", "value", "onClick"], Fe = { class: "acpPresetName" }, Ke = { class: "acpDoneBtn" }, Ye = /* @__PURE__ */ G({
334
+ __name: "AuColorPickerPresetsNested",
335
+ props: {
336
+ inital: {},
337
+ entryStyles: {},
338
+ entryActiveStyles: {},
339
+ entryClassName: {},
340
+ pos: {},
341
+ panelBaseZIndex: {},
342
+ presets: {}
343
+ },
344
+ emits: ["change", "done"],
345
+ setup(p, { emit: v }) {
346
+ const y = p, { hexValue: f, panelShow: P, closePanel: u, togglePanel: l, entryStylesActual: $ } = ue(y), I = b(), V = b(), M = b("#ff0000");
347
+ function h(d) {
348
+ d ? (I.value = d.name, f.value = d.colorHex) : V.value && (I.value = void 0, f.value = M.value);
349
+ }
350
+ const H = v;
351
+ function S(d) {
352
+ f.value = d, M.value = d, H("change", d);
353
+ }
354
+ function R(d) {
355
+ f.value = d, M.value = d, u();
356
+ }
357
+ return ae(P, (d) => {
358
+ d === !1 && H("done", f.value);
359
+ }), le(() => {
360
+ y.inital && (f.value = y.inital, M.value = y.inital);
361
+ }), (d, g) => (B(), D("div", ze, [
362
+ i("div", {
363
+ class: "acpEntry",
364
+ style: U(k($)),
365
+ onClick: g[0] || (g[0] = //@ts-ignore
366
+ (...a) => k(l) && k(l)(...a))
367
+ }, null, 4),
368
+ k(P) ? (B(), D("div", {
369
+ key: 0,
370
+ class: "acpPanel",
371
+ style: U({ zIndex: (d.panelBaseZIndex || 0) + 100 })
372
+ }, [
373
+ i("div", We, [
374
+ i("label", Ze, [
375
+ ie(Ue, {
376
+ inital: M.value,
377
+ onChange: S,
378
+ onDone: R,
379
+ "entry-class-name": "acpPresetBody",
380
+ ref_key: "customPicker",
381
+ ref: V
382
+ }, null, 8, ["inital"]),
383
+ Y(i("input", {
384
+ name: "colorType",
385
+ type: "radio",
386
+ id: "acpColorPresetCustom",
387
+ value: void 0,
388
+ "onUpdate:modelValue": g[1] || (g[1] = (a) => I.value = a),
389
+ onClick: g[2] || (g[2] = (a) => h())
390
+ }, null, 512), [
391
+ [Q, I.value]
392
+ ]),
393
+ g[5] || (g[5] = i("div", { class: "acpPresetName" }, "自定义", -1))
394
+ ]),
395
+ g[6] || (g[6] = i("div", { class: "acpSep" }, null, -1)),
396
+ (B(!0), D(he, null, Ce(d.presets, (a) => (B(), D("label", {
397
+ for: `acpColorPreset${a.name}`
398
+ }, [
399
+ i("div", {
400
+ class: "acpPresetBody",
401
+ style: U({ backgroundColor: a.colorHex })
402
+ }, null, 4),
403
+ Y(i("input", {
404
+ name: "colorType",
405
+ type: "radio",
406
+ id: `acpColorPreset${a.name}`,
407
+ value: a.name,
408
+ "onUpdate:modelValue": g[3] || (g[3] = (T) => I.value = T),
409
+ onClick: (T) => h(a)
410
+ }, null, 8, je), [
411
+ [Q, I.value]
412
+ ]),
413
+ i("div", Fe, Pe(a.name), 1)
414
+ ], 8, Xe))), 256)),
415
+ g[7] || (g[7] = i("div", { class: "acpSep" }, null, -1))
416
+ ]),
417
+ i("div", Ke, [
418
+ i("button", {
419
+ onClick: g[4] || (g[4] = //@ts-ignore
420
+ (...a) => k(u) && k(u)(...a))
421
+ }, "OK")
317
422
  ])
318
- ], 4)) : pe("", !0)
423
+ ], 4)) : re("", !0)
319
424
  ]));
320
425
  }
321
- }), Ae = /* @__PURE__ */ te(De, [["__scopeId", "data-v-ba98e434"]]);
426
+ }), Qe = /* @__PURE__ */ J(Ye, [["__scopeId", "data-v-66671b10"]]);
322
427
  export {
323
- Ae as AuColorPicker,
324
- Ce as AuColorPickerRing
428
+ Ue as AuColorPicker,
429
+ Qe as AuColorPickerPresetsNested,
430
+ _e as AuColorPickerRing
325
431
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .acpRingBody[data-v-7f97ab8e]{position:relative}canvas[data-v-7f97ab8e]{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}.acpEntry[data-v-ba98e434]{width:30px;height:30px;cursor:pointer;border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acpPanel[data-v-ba98e434]{margin-top:3px;position:absolute}.acpPanel .acpParams[data-v-ba98e434]{display:flex;justify-content:space-between;align-items:center;padding:5px}.acpPanel .acpParams select[data-v-ba98e434],.acpPanel .acpParams input[data-v-ba98e434]{margin:0;padding:2px;display:block;font-size:16px;box-sizing:border-box;height:24px;line-height:24px}.acpPanel .acpParams input[data-v-ba98e434]{text-align:center}.acpPanel .acpParams .acpSingleInput input[data-v-ba98e434]{width:120px}.acpPanel .acpParams .acpTripleInputs[data-v-ba98e434]{display:flex;justify-content:space-around}.acpPanel .acpParams .acpTripleInputs input[data-v-ba98e434]{width:40px}.acpPanel .acpDoneBtn[data-v-ba98e434]{display:flex;justify-content:center;align-items:center;padding:8px}.acpPanel .acpDoneBtn button[data-v-ba98e434]{background:none;border:none;color:gray;font-size:16px;cursor:pointer}.acpPanel .acpDoneBtn button[data-v-ba98e434]:hover{color:#000}.acpPanel[data-v-ba98e434]{border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acp[data-v-ba98e434]{position:relative;width:fit-content}
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-3439ba22]{margin:0;padding:0}.acpSep[data-v-3439ba22]{height:2px;border-radius:100px;flex-grow:0;flex-shrink:0;background-color:#ddd}.acpPresetBody[data-v-3439ba22]{width:25px;height:25px;border-radius:1000px;cursor:pointer}.acpDoneBtn[data-v-3439ba22]{display:flex;justify-content:center;align-items:center;margin:8px}.acpDoneBtn button[data-v-3439ba22]{background:none;border:none;font-weight:700;color:gray;font-size:16px;cursor:pointer}.acpDoneBtn button[data-v-3439ba22]:hover{color:#000}.acpEntry[data-v-3439ba22]{width:30px;height:30px;cursor:pointer;border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acpPanel[data-v-3439ba22]{border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff;margin-top:3px;position:absolute}.acp[data-v-3439ba22]{position:relative;width:fit-content}.acp label[data-v-3439ba22]{-webkit-user-select:none;user-select:none;white-space:nowrap;cursor:pointer}.acp input[type=radio][data-v-3439ba22]{cursor:pointer}.acpParams[data-v-3439ba22]{display:flex;justify-content:space-between;align-items:center;padding:5px}.acpParams select[data-v-3439ba22],.acpParams input[data-v-3439ba22]{margin:0;padding:2px;display:block;font-size:16px;box-sizing:border-box;height:24px;line-height:24px}.acpParams input[data-v-3439ba22]{text-align:center}.acpParams .acpSingleInput input[data-v-3439ba22]{width:120px}.acpParams .acpTripleInputs[data-v-3439ba22]{display:flex;justify-content:space-around}.acpParams .acpTripleInputs input[data-v-3439ba22]{width:40px}[data-v-66671b10]{margin:0;padding:0}.acpSep[data-v-66671b10]{height:2px;border-radius:100px;flex-grow:0;flex-shrink:0;background-color:#ddd}.acpPresetBody[data-v-66671b10]{width:25px;height:25px;border-radius:1000px;cursor:pointer}.acpDoneBtn[data-v-66671b10]{display:flex;justify-content:center;align-items:center;margin:8px}.acpDoneBtn button[data-v-66671b10]{background:none;border:none;font-weight:700;color:gray;font-size:16px;cursor:pointer}.acpDoneBtn button[data-v-66671b10]:hover{color:#000}.acpEntry[data-v-66671b10]{width:30px;height:30px;cursor:pointer;border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acpPanel[data-v-66671b10]{border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff;margin-top:3px;position:absolute}.acp[data-v-66671b10]{position:relative;width:fit-content}.acp label[data-v-66671b10]{-webkit-user-select:none;user-select:none;white-space:nowrap;cursor:pointer}.acp input[type=radio][data-v-66671b10]{cursor:pointer}.acpNamedPresets[data-v-66671b10]{margin:5px;display:flex;flex-direction:column;gap:4px}.acpNamedPresets[data-v-66671b10]>*{display:flex;justify-content:flex-start;align-items:center;gap:5px}.acpNamedPresets>* .acpPresetName[data-v-66671b10]{color:#666}.acpNamedPresets>* .acpPresetName[data-v-66671b10]:hover{color:#000}
@@ -1,24 +1,13 @@
1
- import { CSSProperties } from 'vue';
2
- declare function closePanel(): void;
3
- declare const _default: import("vue").DefineComponent<{
4
- inital?: string;
5
- entryStyles?: CSSProperties;
6
- entryActiveStyles?: CSSProperties;
7
- pos?: "left" | "right";
8
- panelBaseZIndex?: number;
9
- }, {
10
- closePanel: typeof closePanel;
11
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
1
+ import { PickerProps } from './common/pickerProps';
2
+ declare function getCurrentHex(): string;
3
+ declare const _default: import('vue').DefineComponent<PickerProps, {
4
+ closePanel: () => void;
5
+ getCurrentHex: typeof getCurrentHex;
6
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
12
7
  done: (hexStr: string) => any;
13
8
  change: (hexStr: string) => any;
14
- }, string, import("vue").PublicProps, Readonly<{
15
- inital?: string;
16
- entryStyles?: CSSProperties;
17
- entryActiveStyles?: CSSProperties;
18
- pos?: "left" | "right";
19
- panelBaseZIndex?: number;
20
- }> & Readonly<{
9
+ }, string, import('vue').PublicProps, Readonly<PickerProps> & Readonly<{
21
10
  onDone?: ((hexStr: string) => any) | undefined;
22
11
  onChange?: ((hexStr: string) => any) | undefined;
23
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
24
13
  export default _default;
@@ -0,0 +1,9 @@
1
+ import { PickerProps } from './common/pickerProps';
2
+ declare const _default: import('vue').DefineComponent<PickerProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
3
+ done: (hexStr: string) => any;
4
+ change: (hexStr: string) => any;
5
+ }, string, import('vue').PublicProps, Readonly<PickerProps> & Readonly<{
6
+ onDone?: ((hexStr: string) => any) | undefined;
7
+ onChange?: ((hexStr: string) => any) | undefined;
8
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
9
+ export default _default;
@@ -1,14 +1,14 @@
1
1
  import { HEX } from 'color-convert/conversions';
2
2
  declare function enforceTo(hex: HEX): void;
3
- declare const _default: import("vue").DefineComponent<{
3
+ declare const _default: import('vue').DefineComponent<{
4
4
  initialHex?: string;
5
5
  }, {
6
6
  enforceTo: typeof enforceTo;
7
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
8
8
  changed: (hex: string) => any;
9
- }, string, import("vue").PublicProps, Readonly<{
9
+ }, string, import('vue').PublicProps, Readonly<{
10
10
  initialHex?: string;
11
11
  }> & Readonly<{
12
12
  onChanged?: ((hex: string) => any) | undefined;
13
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
14
14
  export default _default;
@@ -0,0 +1,14 @@
1
+ import { CSSProperties } from 'vue';
2
+ export interface PickerProps {
3
+ inital?: string;
4
+ entryStyles?: CSSProperties;
5
+ entryActiveStyles?: CSSProperties;
6
+ entryClassName?: string;
7
+ pos?: 'left' | 'right';
8
+ panelBaseZIndex?: number;
9
+ presets?: NamedPreset[];
10
+ }
11
+ export interface NamedPreset {
12
+ colorHex: string;
13
+ name: string;
14
+ }
@@ -1,2 +1,3 @@
1
- export { default as AuColorPicker } from "./components/AuColorPicker.vue";
2
- export { default as AuColorPickerRing } from "./components/AuColorPickerRing.vue";
1
+ export { default as AuColorPicker } from './components/AuColorPicker.vue';
2
+ export { default as AuColorPickerRing } from './components/AuColorPickerRing.vue';
3
+ export { default as AuColorPickerPresetsNested } from './components/AuColorPickerPresetsNested.vue';
package/package.json CHANGED
@@ -9,8 +9,12 @@
9
9
  "url": "https://gitee.com/au114514/au-color-picker"
10
10
  },
11
11
  "description": "vue3颜色选择器组件",
12
- "keywords": ["vue", "color", "component"],
13
- "version": "0.0.6",
12
+ "keywords": [
13
+ "vue",
14
+ "color",
15
+ "component"
16
+ ],
17
+ "version": "0.1.1",
14
18
  "type": "module",
15
19
  "files": [
16
20
  "dist"
@@ -28,7 +32,7 @@
28
32
  "types": "./dist/types/index.d.ts",
29
33
  "scripts": {
30
34
  "dev": "vite",
31
- "build": "vite build && vue-tsc",
35
+ "build": "vite build",
32
36
  "prepack": "npm run build"
33
37
  },
34
38
  "dependencies": {
@@ -42,6 +46,6 @@
42
46
  "sass": "^1.81.0",
43
47
  "typescript": "5.6.3",
44
48
  "vite": "^5.4.11",
45
- "vue-tsc": "2.1.6"
49
+ "vite-plugin-dts": "^4.3.0"
46
50
  }
47
51
  }
@@ -1,2 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
- export default _default;
@@ -1,4 +0,0 @@
1
- export declare function elementOffsetPos(el: HTMLElement): {
2
- y: number;
3
- x: number;
4
- };
@@ -1 +0,0 @@
1
- export declare function isValidHex(color: string): boolean;
@@ -1,4 +0,0 @@
1
- export interface Pt {
2
- x: number;
3
- y: number;
4
- }
@@ -1,2 +0,0 @@
1
- import { Pt } from "./pt";
2
- export declare function ptAzi(pt: Pt, center: Pt): number;
@@ -1,2 +0,0 @@
1
- import { Pt } from "./pt";
2
- export declare function ptDistSq(a: Pt, b: Pt): number;
package/dist/vite.svg DELETED
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>