@aurouscia/au-color-picker 0.4.5 → 0.5.0

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