@aurouscia/au-color-picker 1.0.2-dev.3 → 1.0.2-dev.4

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