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