@mcistudio/unoui-vue 1.2.5 → 1.2.6
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/dist/chunks/{colorpicker-B-kSQ2Gh.js → colorpicker-CyhB3GJP.js} +227 -204
- package/dist/chunks/colorpicker-CyhB3GJP.js.map +1 -0
- package/dist/colorpicker/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/chunks/colorpicker-B-kSQ2Gh.js.map +0 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { t as e } from "./_plugin-vue_export-helper-B3ysoDQm.js";
|
|
2
2
|
import { getUiAttrStyle as t, getUiExposeAttrs as n } from "../attrs.js";
|
|
3
|
-
import { clampAlpha as r, clampHue as i, clampPercent as a, cloneHsba as o, colorToHsba as s, hsbToRgb as c, hsbaToCss as
|
|
4
|
-
import { cva as
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { clsx as
|
|
3
|
+
import { clampAlpha as r, clampHue as i, clampPercent as a, cloneHsba as o, colorToHsba as s, hsbToRgb as c, hsbaToCss as l, normalizeDegree as ee, normalizeRgba as u, parseCssColor as d, rgbaToCss as f, rgbaToHex as p } from "../colorpicker/color.js";
|
|
4
|
+
import { cva as te } from "class-variance-authority";
|
|
5
|
+
import { Fragment as ne, Teleport as re, computed as m, createBlock as ie, createCommentVNode as h, createElementBlock as g, createElementVNode as _, defineComponent as v, mergeProps as ae, nextTick as oe, normalizeClass as y, normalizeStyle as b, onMounted as se, onUnmounted as ce, openBlock as x, reactive as le, ref as S, renderList as ue, toDisplayString as de, unref as C, useAttrs as fe, useTemplateRef as w, watch as T, withModifiers as E } from "vue";
|
|
6
|
+
import { clsx as pe } from "clsx";
|
|
7
7
|
//#region src/colorpicker/ColorPicker.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
-
var
|
|
8
|
+
var me = ["disabled", "aria-expanded"], he = {
|
|
9
9
|
key: 0,
|
|
10
10
|
class: "flex h-10 items-center gap-1 border-b border-medium px-3"
|
|
11
|
-
},
|
|
11
|
+
}, ge = [
|
|
12
12
|
"title",
|
|
13
13
|
"aria-label",
|
|
14
14
|
"onClick"
|
|
15
|
-
],
|
|
15
|
+
], _e = {
|
|
16
16
|
key: 1,
|
|
17
17
|
class: "border-b border-medium py-2"
|
|
18
|
-
},
|
|
18
|
+
}, ve = {
|
|
19
19
|
"data-ui-colorpicker-gradient-row": "true",
|
|
20
20
|
class: "flex items-center mx-3"
|
|
21
|
-
},
|
|
21
|
+
}, ye = [
|
|
22
22
|
"aria-label",
|
|
23
23
|
"onPointerdown",
|
|
24
24
|
"onKeydown"
|
|
25
|
-
],
|
|
25
|
+
], be = {
|
|
26
26
|
key: 0,
|
|
27
27
|
"data-ui-colorpicker-degree-group": "true",
|
|
28
28
|
class: "flex shrink-0 items-center"
|
|
29
|
-
},
|
|
29
|
+
}, xe = { class: "min-w-9 text-right font-mono text-xs text-tertiary" }, Se = { class: "grid gap-3 p-3" }, Ce = { class: "flex items-center gap-3" }, we = ["disabled"], Te = { class: "grid min-w-0 flex-1 gap-2" }, Ee = { class: "ui-colorpicker-checker size-8 shrink-0 overflow-hidden rounded-full border border-medium" }, De = ["value", "aria-invalid"], Oe = { class: "rounded border border-medium bg-secondary px-2 py-1 text-right font-mono text-tertiary" }, ke = 260, Ae = 4, D = 8, je = 10, Me = 200, Ne = 24, Pe = /*#__PURE__*/ e(/* @__PURE__ */ v({
|
|
30
30
|
inheritAttrs: !1,
|
|
31
31
|
__name: "ColorPicker",
|
|
32
32
|
props: {
|
|
@@ -46,16 +46,16 @@ var ve = ["disabled", "aria-expanded"], ye = {
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
emits: ["update:modelValue", "changed"],
|
|
49
|
-
setup(e, { emit:
|
|
50
|
-
let
|
|
49
|
+
setup(e, { emit: te }) {
|
|
50
|
+
let v = e, Pe = te, Le = fe(), O = w("rootRef"), k = w("panelRef"), Re = w("paletteRef"), ze = w("hueBarRef"), Be = w("opacityBarRef"), Ve = w("gradientBarRef"), He = w("degreeRef"), A = S(!1), j = S("solid"), M = S(90), N = S(null), Ue = S(null), P = S(null), We = S(!1), Ge = S(!1), Ke = S(!1), F = S(""), I = S(!1), qe = S(!1), L = S([]), R = le({
|
|
51
51
|
h: 0,
|
|
52
52
|
s: 0,
|
|
53
53
|
b: 0,
|
|
54
54
|
a: 1
|
|
55
|
-
}), z =
|
|
55
|
+
}), z = le({
|
|
56
56
|
top: 0,
|
|
57
57
|
left: 0
|
|
58
|
-
}), Je =
|
|
58
|
+
}), Je = S(!1), Ye = 0, B = null, Xe = !1, Ze = null, Qe = "", V = null, $e = [
|
|
59
59
|
{
|
|
60
60
|
mode: "solid",
|
|
61
61
|
label: "纯色"
|
|
@@ -68,42 +68,42 @@ var ve = ["disabled", "aria-expanded"], ye = {
|
|
|
68
68
|
mode: "radial",
|
|
69
69
|
label: "径向渐变"
|
|
70
70
|
}
|
|
71
|
-
], et = (e, t) => e === void 0 ? t : e === "false" ? !1 : e === "true" || e === "" ? !0 : e, H =
|
|
72
|
-
if (
|
|
73
|
-
let e = L.value.find((e) => e.id ===
|
|
71
|
+
], et = (e, t) => e === void 0 ? t : e === "false" ? !1 : e === "true" || e === "" ? !0 : e, H = m(() => c(R)), tt = m(() => {
|
|
72
|
+
if (j.value === "solid") return H.value;
|
|
73
|
+
let e = L.value.find((e) => e.id === N.value) ?? L.value[0];
|
|
74
74
|
return e ? c(e.color) : H.value;
|
|
75
|
-
}), nt =
|
|
75
|
+
}), nt = m(() => p(X(tt.value))), U = m(() => et(v.allowGradient, !0)), W = m(() => et(v.allowAlpha, !0)), rt = m(() => f(c({
|
|
76
76
|
h: R.h,
|
|
77
77
|
s: 100,
|
|
78
78
|
b: 100,
|
|
79
79
|
a: 1
|
|
80
|
-
}))), it =
|
|
81
|
-
let e =
|
|
80
|
+
}))), it = m(() => bt().map((e) => `${l(e.color)} ${e.percent}%`).join(",")), at = m(() => j.value === "linear" ? `linear-gradient(${M.value}deg,${it.value})` : j.value === "radial" ? `radial-gradient(circle,${it.value})` : f(H.value)), ot = m(() => `linear-gradient(to right,${it.value || `${f(H.value)} 0%,${f(H.value)} 100%`})`), st = m(() => {
|
|
81
|
+
let e = u({
|
|
82
82
|
...H.value,
|
|
83
83
|
a: 1
|
|
84
84
|
});
|
|
85
85
|
return `linear-gradient(to right, rgba(${e.r},${e.g},${e.b},0), rgba(${e.r},${e.g},${e.b},1))`;
|
|
86
|
-
}), ct =
|
|
87
|
-
size:
|
|
88
|
-
focused:
|
|
89
|
-
disabled:
|
|
90
|
-
}))), ut =
|
|
86
|
+
}), ct = m(() => j.value === "solid" ? f(H.value) : at.value), lt = m(() => pe(Le.class, Fe({
|
|
87
|
+
size: v.size,
|
|
88
|
+
focused: A.value,
|
|
89
|
+
disabled: v.disabled
|
|
90
|
+
}))), ut = m(() => Ie({ size: v.size })), dt = m(() => v.disabled || !Je.value), ft = m(() => ({
|
|
91
91
|
position: "fixed",
|
|
92
92
|
top: `${z.top}px`,
|
|
93
93
|
left: `${z.left}px`,
|
|
94
|
-
width: `${
|
|
95
|
-
maxHeight: `calc(100vh - ${
|
|
94
|
+
width: `${ke}px`,
|
|
95
|
+
maxHeight: `calc(100vh - ${D * 2}px)`,
|
|
96
96
|
overflowY: "auto",
|
|
97
97
|
zIndex: 2e3
|
|
98
|
-
})), pt =
|
|
98
|
+
})), pt = m(() => ({
|
|
99
99
|
background: rt.value,
|
|
100
100
|
height: "9rem"
|
|
101
|
-
})), mt =
|
|
101
|
+
})), mt = m(() => ({ gridTemplateColumns: "minmax(0, 1fr) 56px" })), ht = m(() => ({
|
|
102
102
|
left: `${R.s}%`,
|
|
103
103
|
top: `${100 - R.b}%`,
|
|
104
|
-
backgroundColor:
|
|
105
|
-
})), gt =
|
|
106
|
-
|
|
104
|
+
backgroundColor: f(H.value)
|
|
105
|
+
})), gt = m(() => ({ left: `${R.h / 360 * 100}%` })), _t = m(() => ({ left: `${R.a * 100}%` })), vt = m(() => ({ transform: `translateY(-50%) rotate(${M.value - 90}deg)` }));
|
|
106
|
+
T(() => v.modelValue, (e) => {
|
|
107
107
|
if (e && (e === Ze || Dt(e) === Qe)) {
|
|
108
108
|
Ze = null, Qe = "";
|
|
109
109
|
return;
|
|
@@ -112,13 +112,13 @@ var ve = ["disabled", "aria-expanded"], ye = {
|
|
|
112
112
|
}, {
|
|
113
113
|
deep: !0,
|
|
114
114
|
immediate: !0
|
|
115
|
-
}),
|
|
116
|
-
e
|
|
117
|
-
}),
|
|
115
|
+
}), T(A, (e) => {
|
|
116
|
+
e ? Ft() : B?.();
|
|
117
|
+
}), T(nt, (e) => {
|
|
118
118
|
qe.value || (F.value = e, I.value = !1);
|
|
119
|
-
}, { immediate: !0 }),
|
|
120
|
-
!e &&
|
|
121
|
-
}),
|
|
119
|
+
}, { immediate: !0 }), T(U, (e) => {
|
|
120
|
+
!e && j.value !== "solid" && (j.value = "solid", J());
|
|
121
|
+
}), T(W, (e) => {
|
|
122
122
|
if (e) return;
|
|
123
123
|
let t = !1;
|
|
124
124
|
R.a !== 1 && (R.a = 1, t = !0), L.value.forEach((e) => {
|
|
@@ -147,48 +147,48 @@ var ve = ["disabled", "aria-expanded"], ye = {
|
|
|
147
147
|
}
|
|
148
148
|
function St(e) {
|
|
149
149
|
if (!e?.gradients?.length) return xt();
|
|
150
|
-
let t = e.gradients.filter((e) => e && typeof e == "object").slice(0,
|
|
150
|
+
let t = e.gradients.filter((e) => e && typeof e == "object").slice(0, je).map((e) => K(e.percent, s(e.color)));
|
|
151
151
|
return t.length >= 2 ? t : t.length === 1 ? [t[0], K(100, t[0].color)] : xt();
|
|
152
152
|
}
|
|
153
153
|
function Ct() {
|
|
154
|
-
L.value.length >= 2 || (L.value = xt(),
|
|
154
|
+
L.value.length >= 2 || (L.value = xt(), N.value = L.value[0]?.id ?? null);
|
|
155
155
|
}
|
|
156
156
|
function wt() {
|
|
157
|
-
if (
|
|
157
|
+
if (j.value === "solid") return;
|
|
158
158
|
Ct();
|
|
159
|
-
let e = L.value.find((e) => e.id ===
|
|
160
|
-
e && (
|
|
159
|
+
let e = L.value.find((e) => e.id === N.value) ?? L.value[0];
|
|
160
|
+
e && (N.value = e.id, G(e.color));
|
|
161
161
|
}
|
|
162
162
|
function q() {
|
|
163
|
-
if (
|
|
163
|
+
if (j.value === "solid") return;
|
|
164
164
|
Ct();
|
|
165
|
-
let e = L.value.find((e) => e.id ===
|
|
165
|
+
let e = L.value.find((e) => e.id === N.value);
|
|
166
166
|
e && (e.color = Y(R));
|
|
167
167
|
}
|
|
168
168
|
function Tt(e) {
|
|
169
169
|
Xe = !0;
|
|
170
170
|
let t = U.value && yt(e?.mode) ? e.mode : "solid", n = e?.color ?? e?.gradients?.[0]?.color;
|
|
171
|
-
|
|
171
|
+
j.value = t, M.value = ee(e?.degree), G(s(n)), L.value = St(e), N.value = L.value[0]?.id ?? null, t !== "solid" && wt(), Xe = !1;
|
|
172
172
|
}
|
|
173
173
|
function Et() {
|
|
174
|
-
if (
|
|
174
|
+
if (j.value === "solid") {
|
|
175
175
|
let e = X(H.value);
|
|
176
176
|
return {
|
|
177
177
|
mode: "solid",
|
|
178
178
|
color: e,
|
|
179
|
-
hex:
|
|
180
|
-
css: `background-color:${
|
|
179
|
+
hex: p(e),
|
|
180
|
+
css: `background-color:${f(e)}`
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
183
|
let e = bt().map((e) => ({
|
|
184
184
|
percent: e.percent,
|
|
185
185
|
color: X(c(e.color))
|
|
186
|
-
})), t = e.map((e) => `${
|
|
187
|
-
return
|
|
186
|
+
})), t = e.map((e) => `${f(e.color)} ${e.percent}%`).join(",");
|
|
187
|
+
return j.value === "linear" ? {
|
|
188
188
|
mode: "linear",
|
|
189
|
-
degree:
|
|
189
|
+
degree: M.value,
|
|
190
190
|
gradients: e,
|
|
191
|
-
css: `background-image:linear-gradient(${
|
|
191
|
+
css: `background-image:linear-gradient(${M.value}deg,${t})`
|
|
192
192
|
} : {
|
|
193
193
|
mode: "radial",
|
|
194
194
|
gradients: e,
|
|
@@ -198,7 +198,7 @@ var ve = ["disabled", "aria-expanded"], ye = {
|
|
|
198
198
|
function J() {
|
|
199
199
|
if (Xe) return;
|
|
200
200
|
let e = Et();
|
|
201
|
-
Ze = e, Qe = Dt(e),
|
|
201
|
+
Ze = e, Qe = Dt(e), Pe("update:modelValue", e), Pe("changed", e);
|
|
202
202
|
}
|
|
203
203
|
function Dt(e) {
|
|
204
204
|
return JSON.stringify(e);
|
|
@@ -208,20 +208,20 @@ var ve = ["disabled", "aria-expanded"], ye = {
|
|
|
208
208
|
return W.value || (t.a = 1), t;
|
|
209
209
|
}
|
|
210
210
|
function X(e) {
|
|
211
|
-
let t =
|
|
211
|
+
let t = u(e);
|
|
212
212
|
return W.value || (t.a = 1), t;
|
|
213
213
|
}
|
|
214
214
|
function Z() {
|
|
215
215
|
V !== null && (window.clearTimeout(V), V = null);
|
|
216
216
|
}
|
|
217
217
|
function Ot(e = {}) {
|
|
218
|
-
let t =
|
|
218
|
+
let t = d(F.value);
|
|
219
219
|
if (!t) return I.value = !0, null;
|
|
220
|
-
let n = X(t), r =
|
|
221
|
-
if (I.value = !1, e.formatInput && (F.value = r), G(i),
|
|
220
|
+
let n = X(t), r = p(n), i = Y(s(n));
|
|
221
|
+
if (I.value = !1, e.formatInput && (F.value = r), G(i), j.value !== "solid") {
|
|
222
222
|
Ct();
|
|
223
|
-
let e = L.value.find((e) => e.id ===
|
|
224
|
-
e && (
|
|
223
|
+
let e = L.value.find((e) => e.id === N.value) ?? L.value[0];
|
|
224
|
+
e && (N.value = e.id, e.color = i);
|
|
225
225
|
}
|
|
226
226
|
return J(), r;
|
|
227
227
|
}
|
|
@@ -231,12 +231,12 @@ var ve = ["disabled", "aria-expanded"], ye = {
|
|
|
231
231
|
function At() {
|
|
232
232
|
Z(), V = window.setTimeout(() => {
|
|
233
233
|
V = null, Ot();
|
|
234
|
-
},
|
|
234
|
+
}, Me);
|
|
235
235
|
}
|
|
236
236
|
function jt(e) {
|
|
237
237
|
let t = e.target.value;
|
|
238
238
|
F.value = t;
|
|
239
|
-
let n =
|
|
239
|
+
let n = d(t);
|
|
240
240
|
I.value = t.trim() !== "" && !n, n ? At() : Z();
|
|
241
241
|
}
|
|
242
242
|
function Mt(e) {
|
|
@@ -257,305 +257,328 @@ var ve = ["disabled", "aria-expanded"], ye = {
|
|
|
257
257
|
t && e.target instanceof HTMLInputElement && (e.target.value = t);
|
|
258
258
|
}
|
|
259
259
|
function Ft() {
|
|
260
|
-
return
|
|
261
|
-
let e =
|
|
260
|
+
return oe(() => {
|
|
261
|
+
let e = O.value;
|
|
262
262
|
if (!e) return;
|
|
263
|
-
let t = e.getBoundingClientRect(), n =
|
|
264
|
-
z.left = Math.max(
|
|
263
|
+
let t = e.getBoundingClientRect(), n = k.value?.offsetHeight || 360, r = window.innerWidth, i = window.innerHeight, a = r - ke - D, o = t.bottom + Ae, s = t.top - n - Ae;
|
|
264
|
+
z.left = Math.max(D, Math.min(t.left, a)), z.top = o + n <= i - D ? o : Math.max(D, s);
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
267
|
function It(e) {
|
|
268
|
-
|
|
268
|
+
v.disabled || (A.value = e);
|
|
269
269
|
}
|
|
270
270
|
function Lt() {
|
|
271
|
-
It(!
|
|
271
|
+
It(!A.value);
|
|
272
272
|
}
|
|
273
273
|
function Rt(e) {
|
|
274
|
-
|
|
274
|
+
v.disabled || e !== "solid" && !U.value || (j.value = e, j.value !== "solid" && wt(), J());
|
|
275
275
|
}
|
|
276
276
|
function zt(e) {
|
|
277
|
-
let t =
|
|
277
|
+
let t = Re.value?.getBoundingClientRect();
|
|
278
278
|
t && (R.s = a(Q(e.clientX, t.left, t.width) * 100), R.b = a((1 - Q(e.clientY, t.top, t.height)) * 100), q(), J());
|
|
279
279
|
}
|
|
280
280
|
function Bt(e) {
|
|
281
|
-
let t =
|
|
281
|
+
let t = ze.value?.getBoundingClientRect();
|
|
282
282
|
t && (R.h = Math.round(Q(e.clientX, t.left, t.width) * 360), q(), J());
|
|
283
283
|
}
|
|
284
284
|
function Vt(e) {
|
|
285
285
|
if (!W.value) return;
|
|
286
|
-
let t =
|
|
286
|
+
let t = Be.value?.getBoundingClientRect();
|
|
287
287
|
t && (R.a = r(Q(e.clientX, t.left, t.width)), q(), J());
|
|
288
288
|
}
|
|
289
289
|
function Ht(e) {
|
|
290
|
-
let t =
|
|
290
|
+
let t = He.value?.getBoundingClientRect();
|
|
291
291
|
if (!t) return;
|
|
292
292
|
let n = t.left + t.width / 2, r = t.top + t.height / 2, a = Math.atan2(r - e.clientY, e.clientX - n);
|
|
293
|
-
|
|
293
|
+
M.value = i(90 - Math.floor(a * 180 / Math.PI)), J();
|
|
294
294
|
}
|
|
295
295
|
function Ut(e) {
|
|
296
296
|
return L.value.length > 2 && L.value.some((t) => t.id === e);
|
|
297
297
|
}
|
|
298
298
|
function Wt(e, t) {
|
|
299
|
-
return e.clientY < t.top -
|
|
299
|
+
return e.clientY < t.top - Ne || e.clientY > t.bottom + Ne;
|
|
300
300
|
}
|
|
301
301
|
function Gt(e, t) {
|
|
302
|
-
let n =
|
|
303
|
-
!n || !r || (r.percent = a(Q(e.clientX, n.left, n.width) * 100),
|
|
302
|
+
let n = Ve.value?.getBoundingClientRect(), r = L.value.find((e) => e.id === t);
|
|
303
|
+
!n || !r || (r.percent = a(Q(e.clientX, n.left, n.width) * 100), P.value = Ut(t) && Wt(e, n) ? t : null, J());
|
|
304
304
|
}
|
|
305
305
|
function Q(e, t, n) {
|
|
306
306
|
return !Number.isFinite(n) || n <= 0 ? 0 : Math.min(1, Math.max(0, (e - t) / n));
|
|
307
307
|
}
|
|
308
308
|
function $(e, t, n, r) {
|
|
309
|
-
if (
|
|
309
|
+
if (v.disabled) return !1;
|
|
310
310
|
e.preventDefault(), B?.(), t(e);
|
|
311
|
-
let i = (e) =>
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
311
|
+
let i = e.currentTarget ?? null, a = typeof e.pointerId == "number" ? e.pointerId : null, o = (e) => a === null || e.pointerId === a, s = !1;
|
|
312
|
+
if (a !== null && typeof i?.setPointerCapture == "function") try {
|
|
313
|
+
i.setPointerCapture(a), s = typeof i.hasPointerCapture == "function" ? i.hasPointerCapture(a) : !0;
|
|
314
|
+
} catch {
|
|
315
|
+
s = !1;
|
|
316
|
+
}
|
|
317
|
+
function c() {
|
|
318
|
+
window.removeEventListener("pointermove", l, !0), window.removeEventListener("pointerup", ee, !0), window.removeEventListener("pointercancel", u, !0), window.removeEventListener("blur", d), i?.removeEventListener("lostpointercapture", f), s && a !== null && i?.hasPointerCapture?.(a) && i.releasePointerCapture(a), B === p && (B = null);
|
|
319
|
+
}
|
|
320
|
+
function l(e) {
|
|
321
|
+
if (o(e)) {
|
|
322
|
+
if (v.disabled) {
|
|
323
|
+
p();
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
e.preventDefault(), t(e);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function ee(e) {
|
|
330
|
+
o(e) && (c(), n?.(e));
|
|
331
|
+
}
|
|
332
|
+
function u(e) {
|
|
333
|
+
o(e) && (c(), r?.());
|
|
334
|
+
}
|
|
335
|
+
function d() {
|
|
336
|
+
c(), r?.();
|
|
337
|
+
}
|
|
338
|
+
function f() {
|
|
339
|
+
c(), r?.();
|
|
340
|
+
}
|
|
341
|
+
function p() {
|
|
342
|
+
c(), r?.();
|
|
343
|
+
}
|
|
344
|
+
return window.addEventListener("pointermove", l, !0), window.addEventListener("pointerup", ee, !0), window.addEventListener("pointercancel", u, !0), window.addEventListener("blur", d), s && i?.addEventListener("lostpointercapture", f), B = p, !0;
|
|
321
345
|
}
|
|
322
346
|
function Kt(e) {
|
|
323
347
|
$(e, zt);
|
|
324
348
|
}
|
|
325
349
|
function qt(e) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
});
|
|
350
|
+
let t = () => {
|
|
351
|
+
We.value = !1;
|
|
352
|
+
};
|
|
353
|
+
$(e, Bt, t, t) && (We.value = !0);
|
|
331
354
|
}
|
|
332
355
|
function Jt(e) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
});
|
|
356
|
+
let t = () => {
|
|
357
|
+
Ge.value = !1;
|
|
358
|
+
};
|
|
359
|
+
$(e, Vt, t, t) && (Ge.value = !0);
|
|
338
360
|
}
|
|
339
361
|
function Yt(e) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
});
|
|
362
|
+
let t = () => {
|
|
363
|
+
Ke.value = !1;
|
|
364
|
+
};
|
|
365
|
+
$(e, Ht, t, t) && (Ke.value = !0);
|
|
345
366
|
}
|
|
346
367
|
function Xt(e) {
|
|
347
|
-
if (!U.value ||
|
|
348
|
-
let t =
|
|
368
|
+
if (!U.value || j.value === "solid" || L.value.length >= je) return;
|
|
369
|
+
let t = Ve.value?.getBoundingClientRect();
|
|
349
370
|
if (!t) return;
|
|
350
371
|
let n = K(Q(e.clientX, t.left, t.width) * 100, R);
|
|
351
|
-
L.value.push(n),
|
|
372
|
+
L.value.push(n), N.value = n.id, J();
|
|
352
373
|
}
|
|
353
374
|
function Zt(e) {
|
|
354
|
-
|
|
375
|
+
v.disabled || Xt(e);
|
|
355
376
|
}
|
|
356
377
|
function Qt(e, t) {
|
|
357
|
-
if (
|
|
378
|
+
if (v.disabled) return;
|
|
358
379
|
let n = L.value.find((e) => e.id === t);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
380
|
+
if (!n) return;
|
|
381
|
+
let r = () => {
|
|
382
|
+
Ue.value = null, P.value = null;
|
|
383
|
+
};
|
|
384
|
+
$(e, (e) => Gt(e, t), () => {
|
|
385
|
+
P.value === t && en(t), r();
|
|
386
|
+
}, r) && (N.value = n.id, Ue.value = n.id, G(n.color));
|
|
364
387
|
}
|
|
365
388
|
function $t(e, t) {
|
|
366
389
|
let n = L.value.find((e) => e.id === t);
|
|
367
|
-
!n ||
|
|
390
|
+
!n || v.disabled || (e.key === "ArrowLeft" || e.key === "ArrowRight") && (e.preventDefault(), N.value = n.id, n.percent = a(n.percent + (e.key === "ArrowLeft" ? -1 : 1)), J());
|
|
368
391
|
}
|
|
369
|
-
function en(e =
|
|
392
|
+
function en(e = N.value) {
|
|
370
393
|
if (e === null || L.value.length <= 2) return;
|
|
371
|
-
|
|
394
|
+
P.value === e && (P.value = null);
|
|
372
395
|
let t = L.value.findIndex((t) => t.id === e);
|
|
373
396
|
if (t === -1) return;
|
|
374
397
|
L.value.splice(t, 1);
|
|
375
398
|
let n = L.value[Math.min(t, L.value.length - 1)];
|
|
376
|
-
|
|
399
|
+
N.value = n?.id ?? null, n && G(n.color), J();
|
|
377
400
|
}
|
|
378
401
|
async function tn() {
|
|
379
|
-
if (
|
|
402
|
+
if (v.disabled || typeof window > "u") return;
|
|
380
403
|
let e = window.EyeDropper;
|
|
381
404
|
if (e) try {
|
|
382
405
|
G(s((await new e().open()).sRGBHex)), q(), J();
|
|
383
406
|
} catch {}
|
|
384
407
|
}
|
|
385
408
|
function nn(e) {
|
|
386
|
-
e.key === "Enter" || e.key === " " ? (e.preventDefault(), Lt()) : e.key === "Escape" && (
|
|
409
|
+
e.key === "Enter" || e.key === " " ? (e.preventDefault(), Lt()) : e.key === "Escape" && (A.value = !1);
|
|
387
410
|
}
|
|
388
411
|
function rn(e) {
|
|
389
|
-
if (!
|
|
390
|
-
let t = e.target, n =
|
|
391
|
-
n && r && (
|
|
412
|
+
if (!A.value) return;
|
|
413
|
+
let t = e.target, n = O.value && !O.value.contains(t), r = k.value && !k.value.contains(t);
|
|
414
|
+
n && r && (A.value = !1);
|
|
392
415
|
}
|
|
393
416
|
function an(e) {
|
|
394
|
-
|
|
417
|
+
A.value && e.key === "Escape" && (A.value = !1);
|
|
395
418
|
}
|
|
396
419
|
function on() {
|
|
397
|
-
|
|
420
|
+
A.value && Ft();
|
|
398
421
|
}
|
|
399
|
-
return
|
|
422
|
+
return se(() => {
|
|
400
423
|
Je.value = typeof window < "u" && "EyeDropper" in window, document.addEventListener("pointerdown", rn, !0), document.addEventListener("keydown", an), document.addEventListener("scroll", on, !0), window.addEventListener("resize", on);
|
|
401
|
-
}),
|
|
424
|
+
}), ce(() => {
|
|
402
425
|
B?.(), Z(), document.removeEventListener("pointerdown", rn, !0), document.removeEventListener("keydown", an), document.removeEventListener("scroll", on, !0), window.removeEventListener("resize", on);
|
|
403
|
-
}), (r, i) => (
|
|
426
|
+
}), (r, i) => (x(), g("div", {
|
|
404
427
|
ref_key: "rootRef",
|
|
405
|
-
ref:
|
|
428
|
+
ref: O,
|
|
406
429
|
class: "relative inline-flex align-middle",
|
|
407
|
-
style:
|
|
408
|
-
}, [
|
|
430
|
+
style: b(C(t)(C(Le)))
|
|
431
|
+
}, [_("button", ae(C(n)(C(Le)), {
|
|
409
432
|
"data-ui-colorpicker": "true",
|
|
410
433
|
type: "button",
|
|
411
434
|
class: lt.value,
|
|
412
435
|
disabled: e.disabled,
|
|
413
|
-
"aria-expanded":
|
|
436
|
+
"aria-expanded": A.value,
|
|
414
437
|
"aria-haspopup": "dialog",
|
|
415
438
|
"aria-label": "选择颜色",
|
|
416
439
|
onClick: Lt,
|
|
417
440
|
onKeydown: nn
|
|
418
|
-
}), [
|
|
441
|
+
}), [_("span", { class: y(ut.value) }, [_("span", {
|
|
419
442
|
class: "block h-full w-full rounded-[inherit]",
|
|
420
|
-
style:
|
|
421
|
-
}, null, 4)], 2)], 16,
|
|
443
|
+
style: b({ background: ct.value })
|
|
444
|
+
}, null, 4)], 2)], 16, me), (x(), ie(re, { to: "body" }, [A.value ? (x(), g("div", {
|
|
422
445
|
key: 0,
|
|
423
446
|
ref_key: "panelRef",
|
|
424
|
-
ref:
|
|
447
|
+
ref: k,
|
|
425
448
|
role: "dialog",
|
|
426
449
|
"aria-label": "颜色选择器",
|
|
427
|
-
style:
|
|
450
|
+
style: b(ft.value),
|
|
428
451
|
class: "ui-colorpicker-panel rounded-lg border border-medium bg-primary text-primary shadow-xl outline-none",
|
|
429
|
-
onContextmenu: i[0] ||=
|
|
430
|
-
onPointerdown: i[1] ||=
|
|
431
|
-
onSelectstart: i[2] ||=
|
|
452
|
+
onContextmenu: i[0] ||= E(() => {}, ["prevent"]),
|
|
453
|
+
onPointerdown: i[1] ||= E(() => {}, ["stop"]),
|
|
454
|
+
onSelectstart: i[2] ||= E(() => {}, ["prevent"])
|
|
432
455
|
}, [
|
|
433
|
-
U.value ? (
|
|
456
|
+
U.value ? (x(), g("div", he, [(x(), g(ne, null, ue($e, (e) => _("button", {
|
|
434
457
|
key: e.mode,
|
|
435
458
|
type: "button",
|
|
436
459
|
title: e.label,
|
|
437
460
|
"aria-label": e.label,
|
|
438
461
|
class: "flex size-6 items-center justify-center rounded bg-transparent",
|
|
439
462
|
onClick: (t) => Rt(e.mode)
|
|
440
|
-
}, [
|
|
441
|
-
e.mode ===
|
|
442
|
-
e.mode === "solid" ? e.mode ===
|
|
443
|
-
e.mode === "linear" ? e.mode ===
|
|
444
|
-
e.mode === "radial" ? e.mode ===
|
|
445
|
-
]]) }, null, 2)], 8,
|
|
446
|
-
U.value &&
|
|
463
|
+
}, [_("span", { class: y(["size-3.5 rounded-full border transition-[border-color,background,filter]", [
|
|
464
|
+
e.mode === j.value ? "border-[#ff7d3a]" : "border-[#7d7d7d] grayscale",
|
|
465
|
+
e.mode === "solid" ? e.mode === j.value ? "bg-[#ffc9b6]" : "bg-[#e2e2e2]" : "",
|
|
466
|
+
e.mode === "linear" ? e.mode === j.value ? "bg-[linear-gradient(180deg,#ffc9b6,#ff5011)]" : "bg-[linear-gradient(180deg,#ffffff,#999999)]" : "",
|
|
467
|
+
e.mode === "radial" ? e.mode === j.value ? "bg-[radial-gradient(circle,#ffc9b6,#ff5011)]" : "bg-[radial-gradient(circle,#ffffff,#999999)]" : ""
|
|
468
|
+
]]) }, null, 2)], 8, ge)), 64))])) : h("", !0),
|
|
469
|
+
U.value && j.value !== "solid" ? (x(), g("div", _e, [_("div", ve, [_("div", {
|
|
447
470
|
class: "relative h-4 min-w-0 flex-1 rounded-full border border-medium ui-colorpicker-checker",
|
|
448
471
|
onPointerdown: Zt,
|
|
449
472
|
ref_key: "gradientBarRef",
|
|
450
|
-
ref:
|
|
451
|
-
}, [
|
|
473
|
+
ref: Ve
|
|
474
|
+
}, [_("div", {
|
|
452
475
|
class: "absolute inset-0 rounded-full",
|
|
453
|
-
style:
|
|
454
|
-
}, null, 4), (
|
|
476
|
+
style: b({ background: ot.value })
|
|
477
|
+
}, null, 4), (x(!0), g(ne, null, ue(L.value, (e) => (x(), g("button", {
|
|
455
478
|
key: e.id,
|
|
456
479
|
type: "button",
|
|
457
|
-
class:
|
|
458
|
-
e.id ===
|
|
459
|
-
e.id ===
|
|
460
|
-
e.id ===
|
|
480
|
+
class: y(["ui-colorpicker-stop absolute top-1/2 size-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(100,116,139,0.75)] outline-none transition-[box-shadow,opacity,transform] hover:scale-125 focus-visible:ring-2 focus-visible:ring-brand/30", [
|
|
481
|
+
e.id === N.value ? "z-10 ring-2 ring-brand-500" : "",
|
|
482
|
+
e.id === Ue.value ? "scale-125" : "",
|
|
483
|
+
e.id === P.value ? "opacity-50" : ""
|
|
461
484
|
]]),
|
|
462
|
-
style:
|
|
485
|
+
style: b({
|
|
463
486
|
left: `${e.percent}%`,
|
|
464
|
-
background:
|
|
487
|
+
background: C(l)(e.color)
|
|
465
488
|
}),
|
|
466
489
|
"aria-label": `渐变节点 ${e.percent}%`,
|
|
467
|
-
onPointerdown:
|
|
490
|
+
onPointerdown: E((t) => Qt(t, e.id), ["stop"]),
|
|
468
491
|
onKeydown: (t) => $t(t, e.id)
|
|
469
|
-
}, null, 46,
|
|
492
|
+
}, null, 46, ye))), 128))], 544), j.value === "linear" ? (x(), g("div", be, [_("span", xe, de(M.value) + "°", 1), _("div", {
|
|
470
493
|
ref_key: "degreeRef",
|
|
471
|
-
ref:
|
|
494
|
+
ref: He,
|
|
472
495
|
"data-ui-colorpicker-degree": "true",
|
|
473
496
|
class: "relative size-6 overflow-visible rounded-full border border-strong bg-secondary",
|
|
474
497
|
onPointerdown: Yt
|
|
475
|
-
}, [
|
|
498
|
+
}, [_("span", {
|
|
476
499
|
"data-ui-colorpicker-degree-pointer": "true",
|
|
477
500
|
class: "pointer-events-none absolute left-1/2 top-1/2 size-0 origin-left",
|
|
478
|
-
style:
|
|
479
|
-
}, [i[3] ||=
|
|
501
|
+
style: b(vt.value)
|
|
502
|
+
}, [i[3] ||= _("span", {
|
|
480
503
|
"data-ui-colorpicker-degree-line": "true",
|
|
481
504
|
class: "absolute left-0 top-0 h-0.5 w-2.5 -translate-y-1/2 rounded-full bg-[var(--color-border-strong)]"
|
|
482
|
-
}, null, -1),
|
|
505
|
+
}, null, -1), _("span", {
|
|
483
506
|
"data-ui-colorpicker-degree-handle": "true",
|
|
484
|
-
class:
|
|
485
|
-
}, null, 2)], 4)], 544)])) :
|
|
486
|
-
|
|
487
|
-
|
|
507
|
+
class: y(["pointer-events-auto absolute left-2.5 top-0 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full border border-strong bg-primary transition-[background-color,border-color,box-shadow,transform] hover:scale-125 hover:border-brand hover:bg-brand-50 hover:shadow-[0_0_0_2px_rgba(59,130,246,0.18)]", Ke.value ? "scale-125 border-brand bg-brand-50 shadow-[0_0_0_2px_rgba(59,130,246,0.18)]" : ""])
|
|
508
|
+
}, null, 2)], 4)], 544)])) : h("", !0)])])) : h("", !0),
|
|
509
|
+
_("div", Se, [
|
|
510
|
+
_("div", {
|
|
488
511
|
ref_key: "paletteRef",
|
|
489
|
-
ref:
|
|
512
|
+
ref: Re,
|
|
490
513
|
"data-ui-colorpicker-palette": "true",
|
|
491
514
|
class: "ui-colorpicker-palette relative overflow-hidden rounded-md border border-medium",
|
|
492
|
-
style:
|
|
515
|
+
style: b(pt.value),
|
|
493
516
|
onPointerdown: Kt
|
|
494
517
|
}, [
|
|
495
|
-
i[4] ||=
|
|
496
|
-
i[5] ||=
|
|
497
|
-
|
|
518
|
+
i[4] ||= _("div", { class: "ui-colorpicker-palette-layer ui-colorpicker-palette-light" }, null, -1),
|
|
519
|
+
i[5] ||= _("div", { class: "ui-colorpicker-palette-layer ui-colorpicker-palette-dark" }, null, -1),
|
|
520
|
+
_("span", {
|
|
498
521
|
class: "ui-colorpicker-picker absolute size-3 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(15,23,42,0.55)]",
|
|
499
|
-
style:
|
|
522
|
+
style: b(ht.value)
|
|
500
523
|
}, null, 4)
|
|
501
524
|
], 36),
|
|
502
|
-
|
|
503
|
-
|
|
525
|
+
_("div", Ce, [
|
|
526
|
+
_("button", {
|
|
504
527
|
type: "button",
|
|
505
528
|
class: "flex size-8 shrink-0 items-center justify-center rounded-md border border-medium bg-secondary text-tertiary transition-colors hover:border-brand/40 hover:text-brand disabled:cursor-not-allowed disabled:opacity-50",
|
|
506
529
|
disabled: dt.value,
|
|
507
530
|
"aria-label": "屏幕取色",
|
|
508
531
|
title: "屏幕取色",
|
|
509
532
|
onClick: tn
|
|
510
|
-
}, [...i[6] ||= [
|
|
511
|
-
|
|
533
|
+
}, [...i[6] ||= [_("span", { class: "i-lucide:pipette size-4" }, null, -1)]], 8, we),
|
|
534
|
+
_("div", Te, [_("div", {
|
|
512
535
|
ref_key: "hueBarRef",
|
|
513
|
-
ref:
|
|
536
|
+
ref: ze,
|
|
514
537
|
class: "ui-colorpicker-huebar relative h-3 rounded-full border border-medium",
|
|
515
538
|
onPointerdown: qt
|
|
516
|
-
}, [
|
|
539
|
+
}, [_("span", {
|
|
517
540
|
"data-ui-colorpicker-hue-handle": "true",
|
|
518
|
-
class:
|
|
519
|
-
style:
|
|
520
|
-
}, null, 6)], 544), W.value ? (
|
|
541
|
+
class: y(["ui-colorpicker-bar-picker absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(15,23,42,0.55)] transition-transform hover:scale-125", We.value ? "scale-125" : ""]),
|
|
542
|
+
style: b(gt.value)
|
|
543
|
+
}, null, 6)], 544), W.value ? (x(), g("div", {
|
|
521
544
|
key: 0,
|
|
522
545
|
ref_key: "opacityBarRef",
|
|
523
|
-
ref:
|
|
546
|
+
ref: Be,
|
|
524
547
|
"data-ui-colorpicker-opacity": "true",
|
|
525
548
|
class: "ui-colorpicker-checker relative h-3 rounded-full border border-medium",
|
|
526
549
|
onPointerdown: Jt
|
|
527
|
-
}, [
|
|
550
|
+
}, [_("div", {
|
|
528
551
|
class: "absolute inset-0 rounded-full",
|
|
529
|
-
style:
|
|
530
|
-
}, null, 4),
|
|
552
|
+
style: b({ background: st.value })
|
|
553
|
+
}, null, 4), _("span", {
|
|
531
554
|
"data-ui-colorpicker-opacity-handle": "true",
|
|
532
|
-
class:
|
|
533
|
-
style:
|
|
534
|
-
}, null, 6)], 544)) :
|
|
535
|
-
|
|
555
|
+
class: y(["ui-colorpicker-bar-picker absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(15,23,42,0.55)] transition-transform hover:scale-125", Ge.value ? "scale-125" : ""]),
|
|
556
|
+
style: b(_t.value)
|
|
557
|
+
}, null, 6)], 544)) : h("", !0)]),
|
|
558
|
+
_("span", Ee, [_("span", {
|
|
536
559
|
class: "block h-full w-full rounded-full",
|
|
537
|
-
style:
|
|
560
|
+
style: b({ background: ct.value })
|
|
538
561
|
}, null, 4)])
|
|
539
562
|
]),
|
|
540
|
-
|
|
563
|
+
_("div", {
|
|
541
564
|
"data-ui-colorpicker-input-row": "true",
|
|
542
565
|
class: "ui-colorpicker-input-row grid items-center gap-2 text-xs",
|
|
543
|
-
style:
|
|
544
|
-
}, [
|
|
566
|
+
style: b(mt.value)
|
|
567
|
+
}, [_("input", {
|
|
545
568
|
"data-ui-colorpicker-color-input": "true",
|
|
546
|
-
class:
|
|
569
|
+
class: y(["min-w-0 rounded border bg-secondary px-2 py-1 font-mono text-secondary outline-none transition-colors focus:border-brand", I.value ? "border-[#ff4d4f]" : "border-medium"]),
|
|
547
570
|
value: F.value,
|
|
548
571
|
"aria-invalid": I.value,
|
|
549
572
|
spellcheck: "false",
|
|
550
573
|
onFocus: Nt,
|
|
551
574
|
onInput: jt,
|
|
552
|
-
onKeydown:
|
|
575
|
+
onKeydown: E(Mt, ["stop"]),
|
|
553
576
|
onBlur: Pt
|
|
554
|
-
}, null, 42,
|
|
577
|
+
}, null, 42, De), _("span", Oe, de(W.value ? Math.round(R.a * 100) : 100) + "%", 1)], 4)
|
|
555
578
|
])
|
|
556
|
-
], 36)) :
|
|
579
|
+
], 36)) : h("", !0)]))], 4));
|
|
557
580
|
}
|
|
558
|
-
}), [["__scopeId", "data-v-
|
|
581
|
+
}), [["__scopeId", "data-v-2d93e88c"]]), Fe = te("group/ui-colorpicker inline-flex shrink-0 items-center justify-center overflow-hidden border bg-primary align-middle transition-colors duration-150", {
|
|
559
582
|
variants: {
|
|
560
583
|
size: {
|
|
561
584
|
sm: "rounded-md p-1",
|
|
@@ -576,7 +599,7 @@ var ve = ["disabled", "aria-expanded"], ye = {
|
|
|
576
599
|
focused: !1,
|
|
577
600
|
disabled: !1
|
|
578
601
|
}
|
|
579
|
-
}),
|
|
602
|
+
}), Ie = te("ui-colorpicker-checker block shrink-0 overflow-hidden rounded-[inherit]", {
|
|
580
603
|
variants: { size: {
|
|
581
604
|
sm: "size-5",
|
|
582
605
|
md: "size-6",
|
|
@@ -585,6 +608,6 @@ var ve = ["disabled", "aria-expanded"], ye = {
|
|
|
585
608
|
defaultVariants: { size: "md" }
|
|
586
609
|
});
|
|
587
610
|
//#endregion
|
|
588
|
-
export {
|
|
611
|
+
export { Fe as n, Pe as r, Ie as t };
|
|
589
612
|
|
|
590
|
-
//# sourceMappingURL=colorpicker-
|
|
613
|
+
//# sourceMappingURL=colorpicker-CyhB3GJP.js.map
|