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