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