epic-designer-cjh
Version:
基于vue3的设计器,可视化开发页面表单
220 lines (219 loc) • 5.75 kB
JavaScript
const S = {
black: "#000",
silver: "#C0C0C0",
gray: "#808080",
white: "#FFF",
maroon: "#800000",
red: "#F00",
purple: "#800080",
fuchsia: "#F0F",
green: "#008000",
lime: "#0F0",
olive: "#808000",
yellow: "#FF0",
navy: "#000080",
blue: "#00F",
teal: "#008080",
aqua: "#0FF",
transparent: "#0000"
}, a = "^\\s*", f = "\\s*$", g = "\\s*((\\.\\d+)|(\\d+(\\.\\d*)?))%\\s*", u = "\\s*((\\.\\d+)|(\\d+(\\.\\d*)?))\\s*", h = "([0-9A-Fa-f])", x = "([0-9A-Fa-f]{2})", H = new RegExp(`${a}hsl\\s*\\(${u},${g},${g}\\)${f}`), C = new RegExp(`${a}hsv\\s*\\(${u},${g},${g}\\)${f}`), I = new RegExp(`${a}hsla\\s*\\(${u},${g},${g},${u}\\)${f}`), M = new RegExp(`${a}hsva\\s*\\(${u},${g},${g},${u}\\)${f}`), N = new RegExp(`${a}rgb\\s*\\(${u},${u},${u}\\)${f}`), j = new RegExp(`${a}rgba\\s*\\(${u},${u},${u},${u}\\)${f}`), d = new RegExp(`${a}#${h}${h}${h}${f}`), F = new RegExp(`${a}#${x}${x}${x}${f}`), A = new RegExp(`${a}#${h}${h}${h}${h}${f}`), m = new RegExp(`${a}#${x}${x}${x}${x}${f}`);
function s(r) {
return parseInt(r, 16);
}
function P(r) {
try {
let e;
if (e = I.exec(r))
return [
c(e[1]),
i(e[5]),
i(e[9]),
l(e[13])
];
if (e = H.exec(r))
return [c(e[1]), i(e[5]), i(e[9]), 1];
throw new Error(`[seemly/hsla]: Invalid color value ${r}.`);
} catch (e) {
throw e;
}
}
function _(r) {
try {
let e;
if (e = M.exec(r))
return [
c(e[1]),
i(e[5]),
i(e[9]),
l(e[13])
];
if (e = C.exec(r))
return [c(e[1]), i(e[5]), i(e[9]), 1];
throw new Error(`[seemly/hsva]: Invalid color value ${r}.`);
} catch (e) {
throw e;
}
}
function p(r) {
try {
let e;
if (e = F.exec(r))
return [s(e[1]), s(e[2]), s(e[3]), 1];
if (e = N.exec(r))
return [$(e[1]), $(e[5]), $(e[9]), 1];
if (e = j.exec(r))
return [
$(e[1]),
$(e[5]),
$(e[9]),
l(e[13])
];
if (e = d.exec(r))
return [
s(e[1] + e[1]),
s(e[2] + e[2]),
s(e[3] + e[3]),
1
];
if (e = m.exec(r))
return [
s(e[1]),
s(e[2]),
s(e[3]),
l(s(e[4]) / 255)
];
if (e = A.exec(r))
return [
s(e[1] + e[1]),
s(e[2] + e[2]),
s(e[3] + e[3]),
l(s(e[4] + e[4]) / 255)
];
if (r in S)
return p(S[r]);
throw new Error(`[seemly/rgba]: Invalid color value ${r}.`);
} catch (e) {
throw e;
}
}
function U(r) {
return r > 1 ? 1 : r < 0 ? 0 : r;
}
function q(r, e, t) {
return `rgb(${$(r)}, ${$(e)}, ${$(t)})`;
}
function y(r, e, t, n) {
return `rgba(${$(r)}, ${$(e)}, ${$(t)}, ${U(n)})`;
}
function R(r, e, t, n, o) {
return $((r * e * (1 - n) + t * n) / o);
}
function B(r, e) {
Array.isArray(r) || (r = p(r)), Array.isArray(e) || (e = p(e));
const t = r[3], n = e[3], o = l(t + n - t * n);
return y(R(r[0], t, e[0], n, o), R(r[1], t, e[1], n, o), R(r[2], t, e[2], n, o), o);
}
function G(r, e) {
const [t, n, o, v = 1] = Array.isArray(r) ? r : p(r);
return e.alpha ? y(t, n, o, e.alpha) : y(t, n, o, v);
}
function J(r, e) {
const [t, n, o, v = 1] = Array.isArray(r) ? r : p(r), { lightness: w = 1, alpha: E = 1 } = e;
return D([t * w, n * w, o * w, v * E]);
}
function z(r) {
var e;
return (e = (Array.isArray(r) ? r : p(r))[3]) !== null && e !== void 0 ? e : 1;
}
function K(r) {
return `${z(r)}`;
}
function l(r) {
const e = Math.round(Number(r) * 100) / 100;
return e > 1 ? 1 : e < 0 ? 0 : e;
}
function c(r) {
const e = Math.round(Number(r));
return e >= 360 || e < 0 ? 0 : e;
}
function $(r) {
const e = Math.round(Number(r));
return e > 255 ? 255 : e < 0 ? 0 : e;
}
function i(r) {
const e = Math.round(Number(r));
return e > 100 ? 100 : e < 0 ? 0 : e;
}
function L(r) {
const [e, t, n] = Array.isArray(r) ? r : p(r);
return q(e, t, n);
}
function D(r) {
const [e, t, n] = r;
return 3 in r ? `rgba(${$(e)}, ${$(t)}, ${$(n)}, ${l(r[3])})` : `rgba(${$(e)}, ${$(t)}, ${$(n)}, 1)`;
}
function O(r) {
return `hsv(${c(r[0])}, ${i(r[1])}%, ${i(r[2])}%)`;
}
function Q(r) {
const [e, t, n] = r;
return 3 in r ? `hsva(${c(e)}, ${i(t)}%, ${i(n)}%, ${l(r[3])})` : `hsva(${c(e)}, ${i(t)}%, ${i(n)}%, 1)`;
}
function T(r) {
return `hsl(${c(r[0])}, ${i(r[1])}%, ${i(r[2])}%)`;
}
function W(r) {
const [e, t, n] = r;
return 3 in r ? `hsla(${c(e)}, ${i(t)}%, ${i(n)}%, ${l(r[3])})` : `hsla(${c(e)}, ${i(t)}%, ${i(n)}%, 1)`;
}
function X(r) {
if (typeof r == "string") {
let n;
if (n = F.exec(r))
return `${n[0]}FF`;
if (n = m.exec(r))
return n[0];
if (n = d.exec(r))
return `#${n[1]}${n[1]}${n[2]}${n[2]}${n[3]}${n[3]}FF`;
if (n = A.exec(r))
return `#${n[1]}${n[1]}${n[2]}${n[2]}${n[3]}${n[3]}${n[4]}${n[4]}`;
throw new Error(`[seemly/toHexString]: Invalid hex value ${r}.`);
}
const e = `#${r.slice(0, 3).map((n) => $(n).toString(16).toUpperCase().padStart(2, "0")).join("")}`, t = r.length === 3 ? "FF" : $(r[3] * 255).toString(16).padStart(2, "0").toUpperCase();
return e + t;
}
function Y(r) {
if (typeof r == "string") {
let e;
if (e = F.exec(r))
return e[0];
if (e = m.exec(r))
return e[0].slice(0, 7);
if (e = d.exec(r) || A.exec(r))
return `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`;
throw new Error(`[seemly/toHexString]: Invalid hex value ${r}.`);
}
return `#${r.slice(0, 3).map((e) => $(e).toString(16).toUpperCase().padStart(2, "0")).join("")}`;
}
export {
B as a,
K as b,
G as c,
_ as d,
l as e,
$ as f,
z as g,
P as h,
c as i,
i as j,
X as k,
T as l,
W as m,
O as n,
Q as o,
L as p,
D as q,
p as r,
J as s,
Y as t
};