@aurouscia/au-color-picker 0.1.0 → 0.1.2
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
|
@@ -1,2 +1,75 @@
|
|
|
1
1
|
# au-color-picker
|
|
2
|
-
vue3
|
|
2
|
+
vue3颜色选择控件,支持鼠标/手指的点击和拖动
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
## 用法
|
|
7
|
+
```shell
|
|
8
|
+
npm i @aurouscia/au-color-picker
|
|
9
|
+
```
|
|
10
|
+
```ts
|
|
11
|
+
//main.ts(必须导入样式)
|
|
12
|
+
import '@aurouscia/au-color-picker/style.css'
|
|
13
|
+
|
|
14
|
+
//xxx.vue
|
|
15
|
+
import { AuColorPicker } from '@aurouscia/au-color-picker';
|
|
16
|
+
import { AuColorPickerPresetsNested } from '@aurouscia/au-color-picker';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 仅自定义
|
|
20
|
+
```vue
|
|
21
|
+
<AuColorPicker
|
|
22
|
+
:inital="初始值"
|
|
23
|
+
@change="值变化回调"
|
|
24
|
+
@done="面板关闭回调"
|
|
25
|
+
></AuColorPicker>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 预设+自定义
|
|
29
|
+
```ts
|
|
30
|
+
const presets:NamedPreset[] = [
|
|
31
|
+
{
|
|
32
|
+
name: '水系',
|
|
33
|
+
colorHex: '#c3e5eb'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: '绿地',
|
|
37
|
+
colorHex: '#ceeda4'
|
|
38
|
+
},
|
|
39
|
+
]
|
|
40
|
+
```
|
|
41
|
+
```vue
|
|
42
|
+
<AuColorPickerPresetsNested
|
|
43
|
+
:inital="初始值"
|
|
44
|
+
:presets="预设列表"
|
|
45
|
+
:initial-selected-preset="初始选择预设"
|
|
46
|
+
@change="值变化回调" @done="面板关闭回调"
|
|
47
|
+
@presetSwitched="预设切换回调"
|
|
48
|
+
></AuColorPickerPresetsNested>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 组件属性定义
|
|
52
|
+
```ts
|
|
53
|
+
//AuColorPicker的属性
|
|
54
|
+
export interface PickerProps{
|
|
55
|
+
inital?: string //初始值
|
|
56
|
+
entryStyles?: CSSProperties //入口按钮的样式
|
|
57
|
+
entryActiveStyles?: CSSProperties //入口按钮的样式(当面板展开)
|
|
58
|
+
entryClassName?: string //入口按钮的类名
|
|
59
|
+
pos?: 'left'|'right', //面板靠左还是靠右
|
|
60
|
+
panelBaseZIndex?:number, //面板的zIndex基础值
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//AuColorPickerPresetsNested的属性
|
|
64
|
+
export interface PickerWithPresetsProps extends PickerProps{
|
|
65
|
+
initialSelectedPreset?:string //初始选择预设名称(undefined即为自定义)
|
|
66
|
+
presets?: NamedPreset[] //预设列表
|
|
67
|
+
}
|
|
68
|
+
export interface NamedPreset{
|
|
69
|
+
colorHex:string, //预设值
|
|
70
|
+
name:string //预设名称
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 许可证
|
|
75
|
+
MIT
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { defineComponent as
|
|
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
2
|
import A from "color-convert";
|
|
3
|
-
function ke(
|
|
4
|
-
const
|
|
5
|
-
return
|
|
3
|
+
function ke(y, f) {
|
|
4
|
+
const g = y.x - f.x, d = y.y - f.y;
|
|
5
|
+
return g ** 2 + d ** 2;
|
|
6
6
|
}
|
|
7
|
-
function Se(
|
|
8
|
-
const
|
|
9
|
-
return Math.atan2(
|
|
7
|
+
function Se(y, f) {
|
|
8
|
+
const g = y.x - f.x, d = y.y - f.y;
|
|
9
|
+
return Math.atan2(d, g);
|
|
10
10
|
}
|
|
11
|
-
function Ie(
|
|
12
|
-
let
|
|
13
|
-
for (;
|
|
14
|
-
|
|
15
|
-
return { y, x:
|
|
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 };
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const H = 400, L = 400, F = 200, we = 200, te = 190, ne = 150, O = 200, se = 16, oe = 3, _e = /* @__PURE__ */ J({
|
|
18
18
|
__name: "AuColorPickerRing",
|
|
19
19
|
props: {
|
|
20
20
|
initialHex: {}
|
|
21
21
|
},
|
|
22
22
|
emits: ["changed"],
|
|
23
|
-
setup(
|
|
24
|
-
const
|
|
25
|
-
let
|
|
26
|
-
const $ = { x: 199, y: 199 },
|
|
27
|
-
let
|
|
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;
|
|
27
|
+
let o;
|
|
28
28
|
function T() {
|
|
29
|
-
var
|
|
30
|
-
const 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
31
|
if (!t || !n)
|
|
32
32
|
throw Error("canvas context getting error");
|
|
33
|
-
if (
|
|
34
|
-
const x = A.hex.hsv(
|
|
35
|
-
|
|
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];
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
c = t, a = n, o = c.getImageData(0, 0, H, L), X(), e(), j(), c.putImageData(o, 0, 0);
|
|
38
38
|
}
|
|
39
39
|
function X() {
|
|
40
|
-
for (let t = 0; t <
|
|
40
|
+
for (let t = 0; t < H; t++)
|
|
41
41
|
for (let n = 0; n < L; n++) {
|
|
42
|
-
const
|
|
43
|
-
if (m(
|
|
44
|
-
const
|
|
45
|
-
|
|
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]);
|
|
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
|
}
|
|
@@ -54,65 +54,65 @@ const _ = 400, L = 400, F = 200, we = 200, ee = 190, te = 150, O = 200, ne = 16,
|
|
|
54
54
|
return n > M && n < V;
|
|
55
55
|
}
|
|
56
56
|
function e() {
|
|
57
|
-
for (let t = 0; t <
|
|
57
|
+
for (let t = 0; t < H; t++)
|
|
58
58
|
for (let n = 0; n < L; n++) {
|
|
59
|
-
const
|
|
60
|
-
if (w(
|
|
61
|
-
const
|
|
62
|
-
|
|
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;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
function s(t) {
|
|
67
|
-
const n = t.x - h,
|
|
68
|
-
let
|
|
69
|
-
return
|
|
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 };
|
|
70
70
|
}
|
|
71
71
|
function w(t) {
|
|
72
|
-
return !(t.x < h || t.x >
|
|
72
|
+
return !(t.x < h || t.x > b || t.y < h || t.y > b);
|
|
73
73
|
}
|
|
74
|
-
let N = !1,
|
|
74
|
+
let N = !1, u = "none", P = !1;
|
|
75
75
|
function Z(t, n) {
|
|
76
|
-
if (N || n && !
|
|
76
|
+
if (N || n && !P)
|
|
77
77
|
return;
|
|
78
78
|
N = !0;
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
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
81
|
t.preventDefault();
|
|
82
|
-
const
|
|
83
|
-
R.value =
|
|
82
|
+
const v = s(l);
|
|
83
|
+
R.value = v.s, i.value = v.v;
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
u !== "none" && j(!0), N = !1;
|
|
86
86
|
}
|
|
87
87
|
function W() {
|
|
88
|
-
|
|
88
|
+
u = "none", P = !1;
|
|
89
89
|
}
|
|
90
90
|
function ce(t) {
|
|
91
|
-
let n,
|
|
91
|
+
let n, l;
|
|
92
92
|
if ("touches" in t) {
|
|
93
|
-
n = t.touches[0].pageX,
|
|
94
|
-
const
|
|
95
|
-
n -=
|
|
93
|
+
n = t.touches[0].pageX, l = t.touches[0].pageY;
|
|
94
|
+
const v = Ie(d.value);
|
|
95
|
+
n -= v.x, l -= v.y;
|
|
96
96
|
} else
|
|
97
|
-
n = t.offsetX,
|
|
98
|
-
return n = n *
|
|
97
|
+
n = t.offsetX, l = t.offsetY;
|
|
98
|
+
return n = n * H / F, l = l * H / F, { x: n, y: l };
|
|
99
99
|
}
|
|
100
100
|
function j(t) {
|
|
101
101
|
if (t) {
|
|
102
|
-
const de = A.hsv.hex([
|
|
102
|
+
const de = A.hsv.hex([I.value, R.value, i.value]);
|
|
103
103
|
fe("changed", de);
|
|
104
104
|
}
|
|
105
|
-
const n = (
|
|
106
|
-
|
|
107
|
-
const q =
|
|
108
|
-
|
|
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();
|
|
109
109
|
}
|
|
110
110
|
function ve(t) {
|
|
111
111
|
const n = A.hex.hsv(t);
|
|
112
|
-
|
|
112
|
+
I.value = n[0], R.value = n[1], i.value = n[2], e(), c.putImageData(o, 0, 0), j();
|
|
113
113
|
}
|
|
114
|
-
const fe =
|
|
115
|
-
return
|
|
114
|
+
const fe = g;
|
|
115
|
+
return f({ enforceTo: ve }), pe(() => {
|
|
116
116
|
T(), window.addEventListener("touchend", W), window.addEventListener("mouseup", W);
|
|
117
117
|
}), ge(() => {
|
|
118
118
|
window.removeEventListener("touchend", W), window.removeEventListener("mouseup", W);
|
|
@@ -122,46 +122,46 @@ const _ = 400, L = 400, F = 200, we = 200, ee = 190, te = 150, O = 200, ne = 16,
|
|
|
122
122
|
onTouchstart: Z,
|
|
123
123
|
onTouchmove: Z,
|
|
124
124
|
onTouchend: W,
|
|
125
|
-
onMousemove: n[0] || (n[0] = (
|
|
126
|
-
onMousedown: n[1] || (n[1] = (
|
|
127
|
-
Z(
|
|
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;
|
|
128
128
|
})
|
|
129
129
|
}, [
|
|
130
|
-
|
|
131
|
-
width:
|
|
130
|
+
r("canvas", {
|
|
131
|
+
width: H,
|
|
132
132
|
height: L,
|
|
133
133
|
ref_key: "cvs",
|
|
134
|
-
ref:
|
|
134
|
+
ref: d
|
|
135
135
|
}, null, 512),
|
|
136
|
-
|
|
137
|
-
width:
|
|
136
|
+
r("canvas", {
|
|
137
|
+
width: H,
|
|
138
138
|
height: L,
|
|
139
139
|
ref_key: "cursorCvs",
|
|
140
|
-
ref:
|
|
140
|
+
ref: C
|
|
141
141
|
}, null, 512)
|
|
142
142
|
], 36));
|
|
143
143
|
}
|
|
144
|
-
}),
|
|
145
|
-
const
|
|
146
|
-
for (const [
|
|
147
|
-
|
|
148
|
-
return
|
|
149
|
-
},
|
|
150
|
-
function
|
|
151
|
-
return /^#([0-9A-F]{3}){1,2}$/i.test(
|
|
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);
|
|
152
152
|
}
|
|
153
|
-
function ue(
|
|
154
|
-
const
|
|
155
|
-
let
|
|
156
|
-
return
|
|
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;
|
|
157
157
|
});
|
|
158
|
-
function
|
|
159
|
-
|
|
158
|
+
function C() {
|
|
159
|
+
f.value = !1;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
|
|
161
|
+
function c() {
|
|
162
|
+
f.value = !f.value;
|
|
163
163
|
}
|
|
164
|
-
return { hexValue:
|
|
164
|
+
return { hexValue: g, panelShow: f, closePanel: C, togglePanel: c, entryStylesActual: d };
|
|
165
165
|
}
|
|
166
166
|
const He = { class: "acpRing" }, Be = { class: "acpParams" }, De = {
|
|
167
167
|
key: 0,
|
|
@@ -172,7 +172,7 @@ const He = { class: "acpRing" }, Be = { class: "acpParams" }, De = {
|
|
|
172
172
|
}, Te = ["value"], Ne = ["value"], Ae = ["value"], $e = {
|
|
173
173
|
key: 2,
|
|
174
174
|
class: "acpTripleInputs"
|
|
175
|
-
}, Ee = ["value"], Ve = ["value"], qe = ["value"], Le = { class: "acpDoneBtn" }, Oe = /* @__PURE__ */
|
|
175
|
+
}, Ee = ["value"], Ve = ["value"], qe = ["value"], Le = { class: "acpDoneBtn" }, Oe = /* @__PURE__ */ J({
|
|
176
176
|
__name: "AuColorPicker",
|
|
177
177
|
props: {
|
|
178
178
|
inital: {},
|
|
@@ -180,149 +180,148 @@ const He = { class: "acpRing" }, Be = { class: "acpParams" }, De = {
|
|
|
180
180
|
entryActiveStyles: {},
|
|
181
181
|
entryClassName: {},
|
|
182
182
|
pos: {},
|
|
183
|
-
panelBaseZIndex: {}
|
|
184
|
-
presets: {}
|
|
183
|
+
panelBaseZIndex: {}
|
|
185
184
|
},
|
|
186
185
|
emits: ["change", "done"],
|
|
187
|
-
setup(
|
|
188
|
-
const
|
|
186
|
+
setup(y, { expose: f, emit: g }) {
|
|
187
|
+
const d = y, C = _(), { hexValue: c, panelShow: a, closePanel: $, togglePanel: S, entryStylesActual: V } = ue(d);
|
|
189
188
|
function M(m) {
|
|
190
|
-
|
|
189
|
+
c.value = o(m), T();
|
|
191
190
|
}
|
|
192
|
-
const h =
|
|
191
|
+
const h = _("hex"), b = K(() => A.hex.rgb(c.value)), I = K(() => A.hex.hsv(c.value));
|
|
193
192
|
function R(m) {
|
|
194
193
|
var s;
|
|
195
194
|
const e = m.target;
|
|
196
195
|
if ("value" in e) {
|
|
197
196
|
const w = e.value;
|
|
198
|
-
if (w &&
|
|
199
|
-
|
|
197
|
+
if (w && le(w)) {
|
|
198
|
+
c.value = o(w), (s = C.value) == null || s.enforceTo(c.value), T();
|
|
200
199
|
return;
|
|
201
200
|
}
|
|
202
|
-
e.value =
|
|
201
|
+
e.value = c.value;
|
|
203
202
|
}
|
|
204
203
|
}
|
|
205
|
-
function
|
|
204
|
+
function i(m, e) {
|
|
206
205
|
var w;
|
|
207
206
|
const s = m.target;
|
|
208
207
|
if ("value" in s) {
|
|
209
208
|
const N = s.value;
|
|
210
209
|
if (N) {
|
|
211
|
-
let
|
|
212
|
-
if (isNaN(
|
|
210
|
+
let u = parseInt(N);
|
|
211
|
+
if (isNaN(u))
|
|
213
212
|
s.value = "0";
|
|
214
213
|
else {
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
e == "r" ?
|
|
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();
|
|
218
217
|
return;
|
|
219
218
|
}
|
|
220
219
|
}
|
|
221
220
|
}
|
|
222
221
|
}
|
|
223
|
-
function
|
|
222
|
+
function p(m, e) {
|
|
224
223
|
var w;
|
|
225
224
|
const s = m.target;
|
|
226
225
|
if ("value" in s) {
|
|
227
226
|
const N = s.value;
|
|
228
227
|
if (N) {
|
|
229
|
-
let
|
|
230
|
-
if (isNaN(
|
|
228
|
+
let u = parseInt(N);
|
|
229
|
+
if (isNaN(u))
|
|
231
230
|
s.value = "0";
|
|
232
231
|
else {
|
|
233
|
-
e === "h" ?
|
|
234
|
-
const
|
|
235
|
-
e == "h" ?
|
|
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();
|
|
236
235
|
return;
|
|
237
236
|
}
|
|
238
237
|
}
|
|
239
238
|
}
|
|
240
239
|
}
|
|
241
|
-
function
|
|
240
|
+
function o(m) {
|
|
242
241
|
return m.startsWith("#") ? m.toUpperCase() : "#" + m.toUpperCase();
|
|
243
242
|
}
|
|
244
243
|
function T() {
|
|
245
|
-
z("change",
|
|
244
|
+
z("change", c.value);
|
|
246
245
|
}
|
|
247
246
|
function X() {
|
|
248
|
-
return
|
|
247
|
+
return c.value;
|
|
249
248
|
}
|
|
250
|
-
|
|
251
|
-
|
|
249
|
+
ae(() => {
|
|
250
|
+
d.inital && le(d.inital) && (c.value = o(d.inital));
|
|
252
251
|
});
|
|
253
|
-
const z =
|
|
254
|
-
return
|
|
255
|
-
m === !1 && z("done",
|
|
252
|
+
const z = g;
|
|
253
|
+
return f({ closePanel: $, getCurrentHex: X }), Y(a, (m) => {
|
|
254
|
+
m === !1 && z("done", c.value);
|
|
256
255
|
}), (m, e) => (B(), D("div", {
|
|
257
256
|
class: "acp",
|
|
258
257
|
onClick: e[9] || (e[9] = (s) => s.stopPropagation())
|
|
259
258
|
}, [
|
|
260
|
-
|
|
259
|
+
r("div", {
|
|
261
260
|
class: me(m.entryClassName || "acpEntry"),
|
|
262
261
|
style: U(k(V)),
|
|
263
262
|
onClick: e[0] || (e[0] = //@ts-ignore
|
|
264
|
-
(...s) => k(
|
|
263
|
+
(...s) => k(S) && k(S)(...s))
|
|
265
264
|
}, null, 6),
|
|
266
|
-
k(
|
|
265
|
+
k(a) ? (B(), D("div", {
|
|
267
266
|
key: 0,
|
|
268
267
|
class: "acpPanel",
|
|
269
268
|
style: U({ zIndex: (m.panelBaseZIndex || 0) + 100 })
|
|
270
269
|
}, [
|
|
271
|
-
|
|
272
|
-
ie(
|
|
270
|
+
r("div", He, [
|
|
271
|
+
ie(be, {
|
|
273
272
|
ref_key: "ring",
|
|
274
|
-
ref:
|
|
275
|
-
initialHex: k(
|
|
273
|
+
ref: C,
|
|
274
|
+
initialHex: k(c),
|
|
276
275
|
onChanged: M
|
|
277
276
|
}, null, 8, ["initialHex"])
|
|
278
277
|
]),
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
r("div", Be, [
|
|
279
|
+
G(r("select", {
|
|
281
280
|
"onUpdate:modelValue": e[1] || (e[1] = (s) => h.value = s)
|
|
282
281
|
}, e[10] || (e[10] = [
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
r("option", { value: "hex" }, "HEX", -1),
|
|
283
|
+
r("option", { value: "rgb" }, "RGB", -1),
|
|
284
|
+
r("option", { value: "hsv" }, "HSV", -1)
|
|
286
285
|
]), 512), [
|
|
287
|
-
[
|
|
286
|
+
[he, h.value]
|
|
288
287
|
]),
|
|
289
288
|
h.value == "hex" ? (B(), D("div", De, [
|
|
290
|
-
|
|
291
|
-
value: k(
|
|
289
|
+
r("input", {
|
|
290
|
+
value: k(c),
|
|
292
291
|
onBlur: R,
|
|
293
292
|
spellcheck: "false",
|
|
294
293
|
maxlength: "7"
|
|
295
294
|
}, null, 40, Me)
|
|
296
295
|
])) : h.value == "rgb" ? (B(), D("div", Re, [
|
|
297
|
-
|
|
298
|
-
value:
|
|
299
|
-
onBlur: e[2] || (e[2] = (s) =>
|
|
296
|
+
r("input", {
|
|
297
|
+
value: b.value[0],
|
|
298
|
+
onBlur: e[2] || (e[2] = (s) => i(s, "r"))
|
|
300
299
|
}, null, 40, Te),
|
|
301
|
-
|
|
302
|
-
value:
|
|
303
|
-
onBlur: e[3] || (e[3] = (s) =>
|
|
300
|
+
r("input", {
|
|
301
|
+
value: b.value[1],
|
|
302
|
+
onBlur: e[3] || (e[3] = (s) => i(s, "g"))
|
|
304
303
|
}, null, 40, Ne),
|
|
305
|
-
|
|
306
|
-
value:
|
|
307
|
-
onBlur: e[4] || (e[4] = (s) =>
|
|
304
|
+
r("input", {
|
|
305
|
+
value: b.value[2],
|
|
306
|
+
onBlur: e[4] || (e[4] = (s) => i(s, "b"))
|
|
308
307
|
}, null, 40, Ae)
|
|
309
308
|
])) : (B(), D("div", $e, [
|
|
310
|
-
|
|
311
|
-
value:
|
|
312
|
-
onBlur: e[5] || (e[5] = (s) =>
|
|
309
|
+
r("input", {
|
|
310
|
+
value: I.value[0],
|
|
311
|
+
onBlur: e[5] || (e[5] = (s) => p(s, "h"))
|
|
313
312
|
}, null, 40, Ee),
|
|
314
|
-
|
|
315
|
-
value:
|
|
316
|
-
onBlur: e[6] || (e[6] = (s) =>
|
|
313
|
+
r("input", {
|
|
314
|
+
value: I.value[1],
|
|
315
|
+
onBlur: e[6] || (e[6] = (s) => p(s, "s"))
|
|
317
316
|
}, null, 40, Ve),
|
|
318
|
-
|
|
319
|
-
value:
|
|
320
|
-
onBlur: e[7] || (e[7] = (s) =>
|
|
317
|
+
r("input", {
|
|
318
|
+
value: I.value[2],
|
|
319
|
+
onBlur: e[7] || (e[7] = (s) => p(s, "v"))
|
|
321
320
|
}, null, 40, qe)
|
|
322
321
|
]))
|
|
323
322
|
]),
|
|
324
|
-
|
|
325
|
-
|
|
323
|
+
r("div", Le, [
|
|
324
|
+
r("button", {
|
|
326
325
|
onClick: e[8] || (e[8] = //@ts-ignore
|
|
327
326
|
(...s) => k($) && k($)(...s))
|
|
328
327
|
}, "OK")
|
|
@@ -330,102 +329,109 @@ const He = { class: "acpRing" }, Be = { class: "acpParams" }, De = {
|
|
|
330
329
|
], 4)) : re("", !0)
|
|
331
330
|
]));
|
|
332
331
|
}
|
|
333
|
-
}), Ue = /* @__PURE__ */
|
|
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({
|
|
334
333
|
__name: "AuColorPickerPresetsNested",
|
|
335
334
|
props: {
|
|
335
|
+
initialSelectedPreset: {},
|
|
336
|
+
presets: {},
|
|
336
337
|
inital: {},
|
|
337
338
|
entryStyles: {},
|
|
338
339
|
entryActiveStyles: {},
|
|
339
340
|
entryClassName: {},
|
|
340
341
|
pos: {},
|
|
341
|
-
panelBaseZIndex: {}
|
|
342
|
-
presets: {}
|
|
342
|
+
panelBaseZIndex: {}
|
|
343
343
|
},
|
|
344
|
-
emits: ["change", "done"],
|
|
345
|
-
setup(
|
|
346
|
-
const
|
|
347
|
-
function h(
|
|
348
|
-
|
|
344
|
+
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);
|
|
349
349
|
}
|
|
350
|
-
const
|
|
351
|
-
function
|
|
352
|
-
|
|
350
|
+
const b = f;
|
|
351
|
+
function I(i) {
|
|
352
|
+
d.value = i, M.value = i, b("change", i);
|
|
353
353
|
}
|
|
354
|
-
function R(
|
|
355
|
-
|
|
354
|
+
function R(i) {
|
|
355
|
+
d.value = i, M.value = i, c();
|
|
356
356
|
}
|
|
357
|
-
return
|
|
358
|
-
|
|
359
|
-
}),
|
|
360
|
-
|
|
361
|
-
}), (
|
|
362
|
-
i
|
|
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);
|
|
366
|
+
}
|
|
367
|
+
}), (i, p) => (B(), D("div", ze, [
|
|
368
|
+
r("div", {
|
|
363
369
|
class: "acpEntry",
|
|
364
370
|
style: U(k($)),
|
|
365
|
-
onClick:
|
|
366
|
-
(...
|
|
371
|
+
onClick: p[0] || (p[0] = //@ts-ignore
|
|
372
|
+
(...o) => k(a) && k(a)(...o))
|
|
367
373
|
}, null, 4),
|
|
368
|
-
k(
|
|
374
|
+
k(C) ? (B(), D("div", {
|
|
369
375
|
key: 0,
|
|
370
376
|
class: "acpPanel",
|
|
371
|
-
style: U({ zIndex: (
|
|
377
|
+
style: U({ zIndex: (i.panelBaseZIndex || 0) + 100 })
|
|
372
378
|
}, [
|
|
373
|
-
|
|
374
|
-
|
|
379
|
+
r("div", We, [
|
|
380
|
+
r("label", Ze, [
|
|
375
381
|
ie(Ue, {
|
|
376
382
|
inital: M.value,
|
|
377
|
-
onChange:
|
|
383
|
+
onChange: I,
|
|
378
384
|
onDone: R,
|
|
379
385
|
"entry-class-name": "acpPresetBody",
|
|
380
386
|
ref_key: "customPicker",
|
|
381
387
|
ref: V
|
|
382
388
|
}, null, 8, ["inital"]),
|
|
383
|
-
|
|
389
|
+
G(r("input", {
|
|
384
390
|
name: "colorType",
|
|
385
391
|
type: "radio",
|
|
386
392
|
id: "acpColorPresetCustom",
|
|
387
393
|
value: void 0,
|
|
388
|
-
"onUpdate:modelValue":
|
|
389
|
-
onClick:
|
|
394
|
+
"onUpdate:modelValue": p[1] || (p[1] = (o) => S.value = o),
|
|
395
|
+
onClick: p[2] || (p[2] = (o) => h())
|
|
390
396
|
}, null, 512), [
|
|
391
|
-
[
|
|
397
|
+
[ee, S.value]
|
|
392
398
|
]),
|
|
393
|
-
|
|
399
|
+
p[5] || (p[5] = r("div", { class: "acpPresetName" }, "自定义", -1))
|
|
394
400
|
]),
|
|
395
|
-
|
|
396
|
-
(B(!0), D(
|
|
397
|
-
for: `acpColorPreset${
|
|
401
|
+
p[6] || (p[6] = r("div", { class: "acpSep" }, null, -1)),
|
|
402
|
+
(B(!0), D(xe, null, Pe(i.presets, (o) => (B(), D("label", {
|
|
403
|
+
for: `acpColorPreset${o.name}`
|
|
398
404
|
}, [
|
|
399
|
-
|
|
405
|
+
r("div", {
|
|
400
406
|
class: "acpPresetBody",
|
|
401
|
-
style: U({ backgroundColor:
|
|
407
|
+
style: U({ backgroundColor: o.colorHex })
|
|
402
408
|
}, null, 4),
|
|
403
|
-
|
|
409
|
+
G(r("input", {
|
|
404
410
|
name: "colorType",
|
|
405
411
|
type: "radio",
|
|
406
|
-
id: `acpColorPreset${
|
|
407
|
-
value:
|
|
408
|
-
"onUpdate:modelValue":
|
|
409
|
-
onClick: (T) => h(
|
|
412
|
+
id: `acpColorPreset${o.name}`,
|
|
413
|
+
value: o.name,
|
|
414
|
+
"onUpdate:modelValue": p[3] || (p[3] = (T) => S.value = T),
|
|
415
|
+
onClick: (T) => h(o)
|
|
410
416
|
}, null, 8, je), [
|
|
411
|
-
[
|
|
417
|
+
[ee, S.value]
|
|
412
418
|
]),
|
|
413
|
-
|
|
419
|
+
r("div", Fe, Ce(o.name), 1)
|
|
414
420
|
], 8, Xe))), 256)),
|
|
415
|
-
|
|
421
|
+
p[7] || (p[7] = r("div", { class: "acpSep" }, null, -1))
|
|
416
422
|
]),
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
onClick:
|
|
420
|
-
(...
|
|
423
|
+
r("div", Ke, [
|
|
424
|
+
r("button", {
|
|
425
|
+
onClick: p[4] || (p[4] = //@ts-ignore
|
|
426
|
+
(...o) => k(c) && k(c)(...o))
|
|
421
427
|
}, "OK")
|
|
422
428
|
])
|
|
423
429
|
], 4)) : re("", !0)
|
|
424
430
|
]));
|
|
425
431
|
}
|
|
426
|
-
}), Qe = /* @__PURE__ */
|
|
432
|
+
}), Qe = /* @__PURE__ */ Q(Ye, [["__scopeId", "data-v-d110590d"]]);
|
|
427
433
|
export {
|
|
428
434
|
Ue as AuColorPicker,
|
|
429
435
|
Qe as AuColorPickerPresetsNested,
|
|
430
|
-
|
|
436
|
+
be as AuColorPickerRing
|
|
431
437
|
};
|
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-
|
|
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,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: import('vue').DefineComponent<
|
|
1
|
+
import { PickerWithPresetsProps } from './common/pickerProps';
|
|
2
|
+
declare const _default: import('vue').DefineComponent<PickerWithPresetsProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
done: (hexStr: string) => any;
|
|
4
4
|
change: (hexStr: string) => any;
|
|
5
|
-
|
|
5
|
+
presetSwitched: (name: string | undefined) => any;
|
|
6
|
+
}, string, import('vue').PublicProps, Readonly<PickerWithPresetsProps> & Readonly<{
|
|
6
7
|
onDone?: ((hexStr: string) => any) | undefined;
|
|
7
8
|
onChange?: ((hexStr: string) => any) | undefined;
|
|
9
|
+
onPresetSwitched?: ((name: string | undefined) => any) | undefined;
|
|
8
10
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
9
11
|
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CSSProperties } from 'vue';
|
|
2
|
+
export interface PickerProps {
|
|
3
|
+
inital?: string;
|
|
4
|
+
entryStyles?: CSSProperties;
|
|
5
|
+
entryActiveStyles?: CSSProperties;
|
|
6
|
+
entryClassName?: string;
|
|
7
|
+
pos?: 'left' | 'right';
|
|
8
|
+
panelBaseZIndex?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface PickerWithPresetsProps extends PickerProps {
|
|
11
|
+
initialSelectedPreset?: string;
|
|
12
|
+
presets?: NamedPreset[];
|
|
13
|
+
}
|
|
14
|
+
export interface NamedPreset {
|
|
15
|
+
colorHex: string;
|
|
16
|
+
name: string;
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"color",
|
|
15
15
|
"component"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.1.
|
|
17
|
+
"version": "0.1.2",
|
|
18
18
|
"type": "module",
|
|
19
19
|
"files": [
|
|
20
20
|
"dist"
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/color-convert": "^2.0.4",
|
|
44
|
-
"@types/node": "^22.10.
|
|
45
|
-
"@vitejs/plugin-vue": "^5.2.
|
|
44
|
+
"@types/node": "^22.10.1",
|
|
45
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
46
46
|
"sass": "^1.81.0",
|
|
47
|
-
"typescript": "5.
|
|
47
|
+
"typescript": "^5.7.2",
|
|
48
48
|
"vite": "^5.4.11",
|
|
49
49
|
"vite-plugin-dts": "^4.3.0"
|
|
50
50
|
}
|