@thibezer/ui-components-kit 2.11.0 → 2.12.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/CHANGELOG.md +557 -486
- package/README.md +1 -1
- package/dist/alvo-digitavel-CzCvNVQ3.js +23 -0
- package/dist/alvo-digitavel-DbH0hYFf.cjs +1 -0
- package/dist/camadas.cjs +111 -106
- package/dist/camadas.js +1061 -895
- package/dist/canvas.cjs +27 -27
- package/dist/canvas.js +801 -819
- package/dist/components/ui-camadas/camadas-arvore-renderer.d.ts +3 -0
- package/dist/components/ui-camadas/camadas-colecao.d.ts +1 -1
- package/dist/components/ui-camadas/camadas-drop-ops.d.ts +3 -0
- package/dist/components/ui-camadas/camadas-eventos-camadas.d.ts +2 -0
- package/dist/components/ui-camadas/camadas-hierarquia.d.ts +12 -2
- package/dist/components/ui-camadas/camadas-host.d.ts +6 -0
- package/dist/components/ui-camadas/camadas-metricas.d.ts +2 -1
- package/dist/components/ui-camadas/camadas-selecao.d.ts +2 -2
- package/dist/components/ui-camadas/tipos.d.ts +1 -0
- package/dist/components/ui-camadas/ui-camadas.d.ts +3 -0
- package/dist/components/ui-cores/cores-utils.d.ts +1 -1
- package/dist/components/ui-cores/tipos.d.ts +2 -2
- package/dist/components/ui-cores/ui-controle-cores.d.ts +1 -1
- package/dist/components/ui-cores/ui-seletor-cor.d.ts +8 -4
- package/dist/components/ui-tabela-propriedades/editores-basicos.d.ts +4 -1
- package/dist/components/ui-tabela-propriedades/propriedades-dom-utils.d.ts +2 -0
- package/dist/components/ui-tabela-propriedades/propriedades-gerenciador-valores.d.ts +3 -0
- package/dist/components/ui-tabela-propriedades/propriedades-painel-controles.d.ts +1 -0
- package/dist/components/ui-tabela-propriedades/tipos.d.ts +14 -0
- package/dist/components/ui-tabela-propriedades/ui-tabela-propriedades.d.ts +20 -0
- package/dist/cores.cjs +1 -1
- package/dist/cores.js +2 -2
- package/dist/custom-elements.json +24710 -21951
- package/dist/data.cjs +1 -1
- package/dist/data.js +79 -72
- package/dist/form-validacao-BIOXxt-1.js +140 -0
- package/dist/form-validacao-ytRYSF3E.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +163 -156
- package/dist/register.cjs +1 -1
- package/dist/register.js +3 -3
- package/dist/svg-seguro-BsbNQqpd.js +50 -0
- package/dist/svg-seguro-C76iLlAZ.cjs +1 -0
- package/dist/tabela.cjs +1 -1
- package/dist/tabela.js +71 -64
- package/dist/tipos-elementos.d.ts +111 -6
- package/dist/tipos-react.d.ts +4 -0
- package/dist/tipos-vue.d.ts +100 -6
- package/dist/ui-badge-BxT-sDmV.cjs +28 -0
- package/dist/ui-badge-C0eKBI8E.js +183 -0
- package/dist/ui-botao-BOOnP8ds.cjs +12 -0
- package/dist/ui-botao-DfqSivHl.js +165 -0
- package/dist/ui-botao-OGJV6Vfk.js +165 -0
- package/dist/ui-botao-psS1juof.cjs +12 -0
- package/dist/ui-campo-texto-Cnn2UAkS.cjs +16 -0
- package/dist/ui-campo-texto-Uu2dJE_0.js +379 -0
- package/dist/ui-card-B86lJXTP.cjs +20 -0
- package/dist/ui-card-C_o5_0cB.js +111 -0
- package/dist/{ui-controle-cores-DMtTUtLk.js → ui-controle-cores-B4R6ct4I.js} +9 -10
- package/dist/ui-controle-cores-BS0WYPdi.js +572 -0
- package/dist/{ui-controle-cores-CohlwXJK.cjs → ui-controle-cores-C8um-If9.cjs} +2 -2
- package/dist/ui-controle-cores-CHMKGemo.cjs +141 -0
- package/dist/ui-controle-cores-Dog7ERYv.js +697 -0
- package/dist/ui-controle-cores-Er6ZcQ7U.cjs +111 -0
- package/dist/ui-modal-CvGFGh1h.cjs +18 -0
- package/dist/ui-modal-DBOtSTbR.js +238 -0
- package/dist/ui-paleta-ferramentas-CEZYcN4J.js +624 -0
- package/dist/ui-paleta-ferramentas-CU4icLl0.js +1171 -0
- package/dist/ui-paleta-ferramentas-Ccmo-rB5.cjs +21 -0
- package/dist/ui-paleta-ferramentas-DLwZHIDv.cjs +21 -0
- package/dist/ui-paleta-ferramentas-DNN5i6nL.js +860 -0
- package/dist/ui-paleta-ferramentas-Dbj1kBS9.cjs +18 -0
- package/dist/ui-paleta-ferramentas-DbwdWVtT.js +1173 -0
- package/dist/ui-paleta-ferramentas-bvqxj1Yd.cjs +21 -0
- package/dist/ui-segmented-D6b6zxVs.cjs +19 -0
- package/dist/ui-segmented-DyF5YLsV.js +418 -0
- package/dist/ui-segmented-rn9RxRGM.cjs +19 -0
- package/dist/ui-segmented-wUraId2e.js +412 -0
- package/dist/ui-seletor-cor-C4U2eqxY.cjs +82 -0
- package/dist/ui-seletor-cor-D2_C6Aor.js +391 -0
- package/dist/ui-skeleton-DI4_9WOX.js +428 -0
- package/dist/ui-skeleton-SPYqku8P.cjs +52 -0
- package/dist/ui-skeleton-W9uwIceA.js +585 -0
- package/dist/ui-skeleton-elhKIh2B.cjs +33 -0
- package/dist/ui-switch-BcOqOkiV.js +856 -0
- package/dist/ui-switch-D7iPKDj-.cjs +53 -0
- package/dist/ui-tabela-propriedades-BBr5sqki.cjs +145 -0
- package/dist/ui-tabela-propriedades-BecPqC-e.cjs +141 -0
- package/dist/ui-tabela-propriedades-BokvDD3b.js +2648 -0
- package/dist/ui-tabela-propriedades-Boy7I5yW.js +2412 -0
- package/dist/ui-tabela-propriedades-C-PeuW1i.cjs +141 -0
- package/dist/ui-tabela-propriedades-CyPyKXtB.js +3013 -0
- package/dist/ui-tabela-propriedades-Df9ajC6M.js +2648 -0
- package/dist/ui-tabela-propriedades-DqvPilK_.cjs +142 -0
- package/dist/ui-toast-Bp_NlM5G.js +156 -0
- package/dist/ui-toast-DGTZKne5.cjs +20 -0
- package/dist/zero-js-triggers-C_KrvFOQ.js +244 -0
- package/dist/zero-js-triggers-C_gtaojZ.cjs +1 -0
- package/package.json +187 -186
- package/dist/ui-seletor-cor-D9iI7yew.js +0 -413
- package/dist/ui-seletor-cor-Ft06TEUH.cjs +0 -110
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
var j = Object.defineProperty;
|
|
2
|
+
var q = (c, o, e) => o in c ? j(c, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[o] = e;
|
|
3
|
+
var l = (c, o, e) => q(c, typeof o != "symbol" ? o + "" : o, e);
|
|
4
|
+
import { d as $, S as E } from "./ssr-safe-5cWfJP-s.js";
|
|
5
|
+
import { L as C } from "./listener-bag-DQgv7OON.js";
|
|
6
|
+
const A = [
|
|
7
|
+
"#00e08a",
|
|
8
|
+
"#38bdf8",
|
|
9
|
+
"#3b82f6",
|
|
10
|
+
"#6366f1",
|
|
11
|
+
"#a855f7",
|
|
12
|
+
"#ec4899",
|
|
13
|
+
"#ef4444",
|
|
14
|
+
"#f97316",
|
|
15
|
+
"#eab308",
|
|
16
|
+
"#84cc16",
|
|
17
|
+
"#14b8a6",
|
|
18
|
+
"#ffffff",
|
|
19
|
+
"#94a3b8",
|
|
20
|
+
"#0f172a"
|
|
21
|
+
];
|
|
22
|
+
function v(c) {
|
|
23
|
+
if (typeof c != "string") return null;
|
|
24
|
+
const o = c.trim().toLowerCase();
|
|
25
|
+
if (o === "none" || o === "transparent") return "none";
|
|
26
|
+
if (/^#[0-9a-f]{6}$/.test(o)) return o;
|
|
27
|
+
const e = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(o);
|
|
28
|
+
return e ? `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}` : null;
|
|
29
|
+
}
|
|
30
|
+
function w(c, o = 0.35) {
|
|
31
|
+
const e = typeof c == "string" ? parseFloat(c) : Number(c);
|
|
32
|
+
return Number.isFinite(e) ? Math.max(0, Math.min(1, e)) : o;
|
|
33
|
+
}
|
|
34
|
+
function z(c) {
|
|
35
|
+
if (!Array.isArray(c)) return [];
|
|
36
|
+
const o = /* @__PURE__ */ new Set();
|
|
37
|
+
for (const e of c) {
|
|
38
|
+
const t = v(e);
|
|
39
|
+
t && t !== "none" && o.add(t);
|
|
40
|
+
}
|
|
41
|
+
return [...o];
|
|
42
|
+
}
|
|
43
|
+
function M(c) {
|
|
44
|
+
return String(c ?? "").replace(/[&<>"']/g, (o) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[o]);
|
|
45
|
+
}
|
|
46
|
+
const O = ':host{position:fixed;top:0;left:0;z-index:var(--ui-seletor-cor-z, 10000);display:block;width:260px;max-height:calc(100vh - 20px);overflow-y:auto;box-sizing:border-box;padding:12px;background:var(--ui-seletor-cor-fundo, rgba(18, 18, 24, .95));backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);border:1px solid rgba(255,255,255,.14);border-radius:12px;box-shadow:0 16px 40px #000000b3,0 2px 8px #0006;color:#f1f5f9;font-family:var(--ui-fonte-base, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:12px;-webkit-user-select:none;user-select:none;animation:ui-seletor-cor-entrada .18s cubic-bezier(.16,1,.3,1)}:host([hidden]){display:none}*,*:before,*:after{box-sizing:border-box}@keyframes ui-seletor-cor-entrada{0%{opacity:0;transform:scale(.96) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}button{font-family:inherit}.cabecalho{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;padding-bottom:8px;border-bottom:1px solid rgba(255,255,255,.08)}.titulo{display:flex;align-items:center;gap:6px;font-weight:600;font-size:12.5px;color:#fff;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.titulo svg{flex-shrink:0}.fechar{display:flex;align-items:center;justify-content:center;width:22px;height:22px;flex-shrink:0;padding:0;background:transparent;border:none;border-radius:4px;color:#94a3b8;font-size:14px;cursor:pointer;transition:all .15s ease}.fechar:hover{background:#ffffff1a;color:#fff}.abas{display:flex;gap:2px;margin-bottom:10px;padding:2px;background:#00000059;border:1px solid rgba(255,255,255,.08);border-radius:7px}.aba{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:5px 6px;background:transparent;border:none;border-radius:5px;color:#94a3b8;font-size:11px;font-weight:600;cursor:pointer;transition:all .15s ease}.aba:hover{background:#ffffff0f;color:#fff}.aba[aria-selected=true]{background:#ffffff24;color:#fff;box-shadow:0 1px 3px #0000004d}.aba-amostra{width:10px;height:10px;border-radius:2px}.aba-amostra--traco{border:2px solid #ffffff;background:transparent}.previa{display:flex;height:32px;margin-bottom:10px;overflow:hidden;background:#1e1e24;border:1px solid rgba(255,255,255,.15);border-radius:6px;box-shadow:inset 0 1px 3px #0006}.previa-metade{flex:1;position:relative;display:flex;align-items:center;justify-content:center;background-image:linear-gradient(45deg,#2a2a33 25%,transparent 25%),linear-gradient(-45deg,#2a2a33 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#2a2a33 75%),linear-gradient(-45deg,transparent 75%,#2a2a33 75%);background-size:10px 10px;background-position:0 0,0 5px,5px -5px,-5px 0}.previa-cor{position:absolute;top:0;right:0;bottom:0;left:0;transition:background-color .12s ease}.previa-cor--sem-cor{background:transparent!important}.previa-cor--sem-cor:after{content:"";position:absolute;top:50%;left:10%;width:80%;height:2px;background:#ef4444;transform:rotate(-30deg)}.previa-metade span{position:relative;z-index:2;font-size:9.5px;font-weight:600;color:#ffffffd9;text-shadow:0 1px 2px rgba(0,0,0,.9)}.linha-hex{display:flex;align-items:center;gap:8px;margin-bottom:10px}.hex{flex:1;position:relative;display:flex;align-items:center}.hex-prefixo{position:absolute;left:8px;color:#64748b;font-weight:600;pointer-events:none}.hex input{width:100%;padding:5px 8px 5px 20px;background:#0006;border:1px solid rgba(255,255,255,.18);border-radius:6px;outline:none;color:#fff;font-family:var(--ui-fonte-codigo, monospace);font-size:12px;text-transform:uppercase;-webkit-user-select:text;user-select:text;transition:border-color .15s ease}.hex input:focus{border-color:var(--ui-cor-primaria, #00e08a)}.nativo{position:relative;display:flex;align-items:center;justify-content:center;width:28px;height:28px;flex-shrink:0;overflow:hidden;background:#ffffff0d;border:1px solid rgba(255,255,255,.2);border-radius:6px;color:#cbd5e1;cursor:pointer}.nativo:hover{border-color:#ffffff80}.nativo input{position:absolute;top:-8px;right:-8px;bottom:-8px;left:-8px;width:150%;height:150%;opacity:0;cursor:pointer}.opacidade{margin-bottom:10px;padding:8px;background:#00000040;border:1px solid rgba(255,255,255,.06);border-radius:8px}.opacidade[hidden]{display:none}.opacidade-cabecalho{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px;color:#cbd5e1;font-size:11px}.opacidade-valor{font-weight:700;color:var(--ui-cor-primaria, #00e08a)}.opacidade input[type=range]{width:100%;height:6px;margin:0;background:#ffffff2e;border-radius:3px;outline:none;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.opacidade input[type=range]::-webkit-slider-thumb{width:14px;height:14px;background:#fff;border:2px solid var(--ui-cor-primaria, #00e08a);border-radius:50%;box-shadow:0 1px 4px #0009;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.opacidade input[type=range]::-moz-range-thumb{width:12px;height:12px;background:#fff;border:2px solid var(--ui-cor-primaria, #00e08a);border-radius:50%;cursor:pointer}.opacidade-atalhos{display:flex;gap:4px;margin-top:6px}.opacidade-atalhos button{flex:1;padding:2px 0;background:#ffffff0f;border:1px solid rgba(255,255,255,.1);border-radius:4px;color:#94a3b8;font-size:10px;text-align:center;cursor:pointer;transition:all .12s ease}.opacidade-atalhos button:hover{background:#ffffff24;color:#fff}.opacidade-atalhos button.ativo{background:var(--ui-cor-primaria, #00e08a);border-color:var(--ui-cor-primaria, #00e08a);color:#0f172a;font-weight:700}.rotulo-secao{margin:8px 0 5px;color:#94a3b8;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.5px}.amostras{display:grid;grid-template-columns:repeat(7,1fr);gap:5px;margin-bottom:8px}.amostra{position:relative;aspect-ratio:1;padding:0;border:1px solid rgba(255,255,255,.2);border-radius:4px;cursor:pointer;transition:transform .12s ease,border-color .12s ease}.amostra:hover{z-index:2;border-color:#fff;transform:scale(1.15)}.amostra.ativo{border:2px solid #ffffff;box-shadow:0 0 0 1.5px var(--ui-cor-primaria, #00e08a)}.sem-cor{display:flex;align-items:center;justify-content:center;gap:6px;width:100%;margin-top:6px;padding:6px;background:#ef44441f;border:1px solid rgba(239,68,68,.35);border-radius:6px;color:#fca5a5;font-size:11.5px;font-weight:600;cursor:pointer;transition:all .15s ease}.sem-cor:hover{background:#ef444438;border-color:#ef4444;color:#fff}.sem-cor.ativo{background:#ef4444;border-color:#ef4444;color:#fff}.rodape{display:flex;justify-content:flex-end;gap:6px;margin-top:10px;padding-top:8px;border-top:1px solid rgba(255,255,255,.08)}.rodape button{padding:4px 10px;border:none;border-radius:5px;font-size:11.5px;font-weight:600;cursor:pointer;transition:all .15s ease}.botao-concluir{background:var(--ui-cor-primaria, #00e08a);color:#0f172a}.botao-concluir:hover{filter:brightness(1.1)}.botao-cancelar{background:#ffffff14;color:#94a3b8}.botao-cancelar:hover{background:#ffffff26;color:#fff}button:focus-visible,input:focus-visible{outline:2px solid var(--ui-cor-primaria, #00e08a);outline-offset:1px}', L = [0.25, 0.35, 0.5, 0.75, 1];
|
|
47
|
+
class N extends E {
|
|
48
|
+
constructor() {
|
|
49
|
+
super();
|
|
50
|
+
l(this, "raiz");
|
|
51
|
+
l(this, "listeners", new C());
|
|
52
|
+
l(this, "_titulo", "Seletor de cor");
|
|
53
|
+
l(this, "_duplo", !0);
|
|
54
|
+
l(this, "_alvo", "preenchimento");
|
|
55
|
+
l(this, "_preenchimento", "#00e08a");
|
|
56
|
+
l(this, "_traco", "#ffffff");
|
|
57
|
+
l(this, "_opacidade", 0.35);
|
|
58
|
+
l(this, "_mostrarOpacidade");
|
|
59
|
+
l(this, "_misto", !1);
|
|
60
|
+
l(this, "_coresProjeto", []);
|
|
61
|
+
l(this, "_paleta", [...A]);
|
|
62
|
+
l(this, "inicial", { preenchimento: "#00e08a", traco: "#ffffff", opacidade: 0.35 });
|
|
63
|
+
this.raiz = this.attachShadow({ mode: "open" });
|
|
64
|
+
}
|
|
65
|
+
connectedCallback() {
|
|
66
|
+
this.hasAttribute("role") || this.setAttribute("role", "dialog"), this.renderizar();
|
|
67
|
+
}
|
|
68
|
+
disconnectedCallback() {
|
|
69
|
+
this.listeners.cleanup();
|
|
70
|
+
}
|
|
71
|
+
/* ---------- API pública ---------- */
|
|
72
|
+
/** Define o estado inicial (também usado pelo "Cancelar" para restaurar). */
|
|
73
|
+
configurar(e = {}) {
|
|
74
|
+
this._titulo = e.titulo || "Seletor de cor";
|
|
75
|
+
const t = e.preenchimento !== void 0 && e.traco !== void 0;
|
|
76
|
+
this._duplo = e.modo ? e.modo === "duplo" : t, this._alvo = e.alvo === "traco" ? "traco" : "preenchimento";
|
|
77
|
+
const a = v(e.cor);
|
|
78
|
+
this._preenchimento = v(e.preenchimento) ?? (this._alvo === "preenchimento" ? a : null) ?? "#00e08a", this._traco = v(e.traco) ?? (this._alvo === "traco" ? a : null) ?? "#ffffff", this._opacidade = w(e.opacidade), this._mostrarOpacidade = e.mostrarOpacidade, this._misto = e.misto === !0, this._coresProjeto = z(e.coresProjeto), this._paleta = e.paleta ? z(e.paleta) : [...A], this.inicial = { preenchimento: this._preenchimento, traco: this._traco, opacidade: this._opacidade }, this.isConnected && this.renderizar();
|
|
79
|
+
}
|
|
80
|
+
get alvo() {
|
|
81
|
+
return this._alvo;
|
|
82
|
+
}
|
|
83
|
+
/** Cor do alvo em edição. */
|
|
84
|
+
get cor() {
|
|
85
|
+
return this._alvo === "traco" ? this._traco : this._preenchimento;
|
|
86
|
+
}
|
|
87
|
+
get opacidade() {
|
|
88
|
+
return this._opacidade;
|
|
89
|
+
}
|
|
90
|
+
obterEstado() {
|
|
91
|
+
return {
|
|
92
|
+
alvo: this._alvo,
|
|
93
|
+
cor: this.cor,
|
|
94
|
+
preenchimento: this._preenchimento,
|
|
95
|
+
traco: this._traco,
|
|
96
|
+
opacidade: this._opacidade
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Alterna entre Preenchimento e Traço (só no modo duplo). */
|
|
100
|
+
trocarAlvo(e) {
|
|
101
|
+
const t = e === "traco" ? "traco" : "preenchimento";
|
|
102
|
+
!this._duplo || t === this._alvo || (this._alvo = t, this.atualizarVisual(), this.emitir("ui-alvo-change", { alvo: t }));
|
|
103
|
+
}
|
|
104
|
+
/** Aplica uma cor ao alvo em edição e emite `ui-cor-input`. Cores inválidas são ignoradas. */
|
|
105
|
+
definirCor(e) {
|
|
106
|
+
const t = v(e);
|
|
107
|
+
t && (this._alvo === "traco" ? this._traco = t : this._preenchimento = t, this._misto = !1, this.atualizarVisual(), this.emitir("ui-cor-input", this.obterEstado()));
|
|
108
|
+
}
|
|
109
|
+
/** Opacidade do preenchimento (0 a 1); emite `ui-cor-input`. */
|
|
110
|
+
definirOpacidade(e) {
|
|
111
|
+
this._opacidade = w(e, this._opacidade), this.atualizarVisual(), this.emitir("ui-cor-input", this.obterEstado());
|
|
112
|
+
}
|
|
113
|
+
confirmar() {
|
|
114
|
+
this.emitir("ui-cor-confirmar", this.obterEstado());
|
|
115
|
+
}
|
|
116
|
+
/** Restaura as cores iniciais (emitindo `ui-cor-input`) e emite `ui-cor-cancelar`. */
|
|
117
|
+
cancelar() {
|
|
118
|
+
this._preenchimento = this.inicial.preenchimento, this._traco = this.inicial.traco, this._opacidade = this.inicial.opacidade, this.atualizarVisual(), this.emitir("ui-cor-input", this.obterEstado()), this.emitir("ui-cor-cancelar", this.obterEstado());
|
|
119
|
+
}
|
|
120
|
+
/* ---------- Renderização ---------- */
|
|
121
|
+
get opacidadeVisivel() {
|
|
122
|
+
return this._mostrarOpacidade ?? this._alvo === "preenchimento";
|
|
123
|
+
}
|
|
124
|
+
renderizar() {
|
|
125
|
+
this.listeners.cleanup();
|
|
126
|
+
const e = (t) => t.map((a) => `
|
|
127
|
+
<button type="button" class="amostra" data-cor="${a}" style="background-color: ${a};" title="${a.toUpperCase()}" aria-label="Cor ${a.toUpperCase()}"></button>
|
|
128
|
+
`).join("");
|
|
129
|
+
this.raiz.innerHTML = `
|
|
130
|
+
<style>${O}</style>
|
|
131
|
+
<div class="cabecalho">
|
|
132
|
+
<span class="titulo">
|
|
133
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
134
|
+
<path d="M12 2.69l5.66 5.66a8 8 0 1 1-11.31 0z"/>
|
|
135
|
+
</svg>
|
|
136
|
+
<span>${M(this._titulo)}</span>
|
|
137
|
+
</span>
|
|
138
|
+
<button type="button" class="fechar" data-acao="fechar" title="Fechar (Esc)" aria-label="Fechar">✕</button>
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
${this._duplo ? `
|
|
142
|
+
<div class="abas" role="tablist" aria-label="Alvo da cor">
|
|
143
|
+
<button type="button" class="aba" role="tab" data-alvo="preenchimento" title="Preenchimento">
|
|
144
|
+
<span class="aba-amostra aba-amostra--preenchimento"></span>
|
|
145
|
+
Preenchimento
|
|
146
|
+
</button>
|
|
147
|
+
<button type="button" class="aba" role="tab" data-alvo="traco" title="Traço / contorno">
|
|
148
|
+
<span class="aba-amostra aba-amostra--traco"></span>
|
|
149
|
+
Traço
|
|
150
|
+
</button>
|
|
151
|
+
</div>
|
|
152
|
+
` : ""}
|
|
153
|
+
|
|
154
|
+
<div class="previa">
|
|
155
|
+
<div class="previa-metade" title="Cor original">
|
|
156
|
+
<div class="previa-cor previa-cor--original"></div>
|
|
157
|
+
<span>ORIGINAL</span>
|
|
158
|
+
</div>
|
|
159
|
+
<div class="previa-metade" title="Nova cor">
|
|
160
|
+
<div class="previa-cor previa-cor--nova"></div>
|
|
161
|
+
<span class="previa-rotulo-nova">NOVA</span>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<div class="linha-hex">
|
|
166
|
+
<label class="hex">
|
|
167
|
+
<span class="hex-prefixo">#</span>
|
|
168
|
+
<input type="text" class="hex-entrada" maxlength="7" spellcheck="false" autocomplete="off" aria-label="Cor em hexadecimal" />
|
|
169
|
+
</label>
|
|
170
|
+
<label class="nativo" title="Abrir o seletor de cor do sistema">
|
|
171
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
|
172
|
+
<circle cx="12" cy="12" r="10"/>
|
|
173
|
+
<path d="M12 2a10 10 0 0 1 10 10"/>
|
|
174
|
+
</svg>
|
|
175
|
+
<input type="color" class="nativo-entrada" aria-label="Seletor de cor do sistema" />
|
|
176
|
+
</label>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<div class="opacidade">
|
|
180
|
+
<div class="opacidade-cabecalho">
|
|
181
|
+
<span>Opacidade do preenchimento</span>
|
|
182
|
+
<span class="opacidade-valor"></span>
|
|
183
|
+
</div>
|
|
184
|
+
<input type="range" class="opacidade-entrada" min="0" max="100" step="1" aria-label="Opacidade do preenchimento" />
|
|
185
|
+
<div class="opacidade-atalhos">
|
|
186
|
+
${L.map((t) => `<button type="button" data-opacidade="${t}">${Math.round(t * 100)}%</button>`).join("")}
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
${this._coresProjeto.length ? `
|
|
191
|
+
<div class="rotulo-secao">Cores do projeto</div>
|
|
192
|
+
<div class="amostras">${e(this._coresProjeto)}</div>
|
|
193
|
+
` : ""}
|
|
194
|
+
|
|
195
|
+
${this._paleta.length ? `
|
|
196
|
+
<div class="rotulo-secao">Paleta padrão</div>
|
|
197
|
+
<div class="amostras">${e(this._paleta)}</div>
|
|
198
|
+
` : ""}
|
|
199
|
+
|
|
200
|
+
<button type="button" class="sem-cor" data-cor="none" title="Sem cor (vazado / transparente)">
|
|
201
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" aria-hidden="true">
|
|
202
|
+
<circle cx="12" cy="12" r="9"/>
|
|
203
|
+
<line x1="5.5" y1="5.5" x2="18.5" y2="18.5"/>
|
|
204
|
+
</svg>
|
|
205
|
+
Sem cor (vazado / transparente)
|
|
206
|
+
</button>
|
|
207
|
+
|
|
208
|
+
<div class="rodape">
|
|
209
|
+
<button type="button" class="botao-cancelar" data-acao="cancelar">Cancelar</button>
|
|
210
|
+
<button type="button" class="botao-concluir" data-acao="concluir">Concluir</button>
|
|
211
|
+
</div>
|
|
212
|
+
`, this.vincularEventos(), this.atualizarVisual();
|
|
213
|
+
}
|
|
214
|
+
atualizarVisual() {
|
|
215
|
+
var S;
|
|
216
|
+
const e = (f) => this.raiz.querySelector(f), t = this.cor, a = t === "none";
|
|
217
|
+
this.raiz.querySelectorAll("[data-alvo]").forEach((f) => {
|
|
218
|
+
f.setAttribute("aria-selected", String(f.dataset.alvo === this._alvo));
|
|
219
|
+
});
|
|
220
|
+
const r = e(".aba-amostra--preenchimento");
|
|
221
|
+
r && (r.style.backgroundColor = this._preenchimento === "none" ? "transparent" : this._preenchimento);
|
|
222
|
+
const n = e(".aba-amostra--traco");
|
|
223
|
+
n && (n.style.borderColor = this._traco === "none" ? "#ef4444" : this._traco);
|
|
224
|
+
const s = e(".opacidade");
|
|
225
|
+
s && (s.hidden = !this.opacidadeVisivel);
|
|
226
|
+
const d = (f, _) => String(f ? _ : 1), u = (f, _, P) => {
|
|
227
|
+
f && (f.classList.toggle("previa-cor--sem-cor", _ === "none"), f.style.backgroundColor = _ === "none" ? "" : _, f.style.opacity = _ === "none" ? "" : P);
|
|
228
|
+
}, h = this._alvo === "preenchimento", m = h ? this.inicial.preenchimento : this.inicial.traco;
|
|
229
|
+
u(e(".previa-cor--original"), m, d(h, this.inicial.opacidade)), u(e(".previa-cor--nova"), t, d(h, this._opacidade));
|
|
230
|
+
const i = e(".previa-rotulo-nova");
|
|
231
|
+
i && (i.textContent = this._misto ? "MISTO (?)" : "NOVA");
|
|
232
|
+
const p = e(".hex-entrada");
|
|
233
|
+
p && this.raiz.activeElement !== p && (p.value = a ? "" : t.slice(1).toUpperCase(), p.placeholder = a ? "NENHUM" : "00E08A");
|
|
234
|
+
const b = e(".nativo-entrada");
|
|
235
|
+
b && (b.value = a ? "#00e08a" : t);
|
|
236
|
+
const g = Math.round(this._opacidade * 100), k = e(".opacidade-entrada");
|
|
237
|
+
k && (k.value = String(g));
|
|
238
|
+
const y = e(".opacidade-valor");
|
|
239
|
+
y && (y.textContent = `${g}%`), this.raiz.querySelectorAll("[data-opacidade]").forEach((f) => {
|
|
240
|
+
f.classList.toggle("ativo", Math.abs(Number(f.dataset.opacidade) - this._opacidade) < 0.02);
|
|
241
|
+
}), this.raiz.querySelectorAll(".amostra").forEach((f) => {
|
|
242
|
+
f.classList.toggle("ativo", f.dataset.cor === t);
|
|
243
|
+
}), (S = e(".sem-cor")) == null || S.classList.toggle("ativo", a);
|
|
244
|
+
}
|
|
245
|
+
vincularEventos() {
|
|
246
|
+
const e = this.raiz;
|
|
247
|
+
e.querySelectorAll("[data-alvo]").forEach((s) => {
|
|
248
|
+
this.listeners.add(s, "click", () => this.trocarAlvo(s.dataset.alvo));
|
|
249
|
+
}), e.querySelectorAll("[data-cor]").forEach((s) => {
|
|
250
|
+
this.listeners.add(s, "click", () => this.definirCor(s.dataset.cor || ""));
|
|
251
|
+
}), e.querySelectorAll("[data-opacidade]").forEach((s) => {
|
|
252
|
+
this.listeners.add(s, "click", () => this.definirOpacidade(Number(s.dataset.opacidade)));
|
|
253
|
+
});
|
|
254
|
+
const t = e.querySelector(".opacidade-entrada");
|
|
255
|
+
this.listeners.add(t, "input", () => this.definirOpacidade(Number(t.value) / 100));
|
|
256
|
+
const a = e.querySelector(".hex-entrada"), r = (s) => {
|
|
257
|
+
const d = a.value.trim().replace(/^#/, "");
|
|
258
|
+
(/^[0-9a-f]{6}$/i.test(d) || s && /^[0-9a-f]{3}$/i.test(d)) && this.definirCor(`#${d}`);
|
|
259
|
+
};
|
|
260
|
+
this.listeners.add(a, "input", () => r(!1)), this.listeners.add(a, "change", () => {
|
|
261
|
+
r(!0), this.atualizarVisual();
|
|
262
|
+
}), this.listeners.add(a, "keydown", (s) => {
|
|
263
|
+
s.key === "Enter" && (s.preventDefault(), r(!0), this.confirmar());
|
|
264
|
+
});
|
|
265
|
+
const n = e.querySelector(".nativo-entrada");
|
|
266
|
+
this.listeners.add(n, "input", () => this.definirCor(n.value)), this.listeners.add(e.querySelector('[data-acao="fechar"]'), "click", () => this.confirmar()), this.listeners.add(e.querySelector('[data-acao="concluir"]'), "click", () => this.confirmar()), this.listeners.add(e.querySelector('[data-acao="cancelar"]'), "click", () => this.cancelar());
|
|
267
|
+
}
|
|
268
|
+
emitir(e, t) {
|
|
269
|
+
this.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
$("ui-seletor-cor", N);
|
|
273
|
+
let x = null;
|
|
274
|
+
function D(c) {
|
|
275
|
+
x == null || x.descartar();
|
|
276
|
+
const o = document.createElement("ui-seletor-cor"), { ancora: e, aoAlterar: t, aoConfirmar: a, aoCancelar: r, aoTrocarAlvo: n, ...s } = c;
|
|
277
|
+
o.configurar(s);
|
|
278
|
+
const d = new C();
|
|
279
|
+
let u = !0;
|
|
280
|
+
const h = () => u ? (u = !1, d.cleanup(), o.remove(), x === m && (x = null), !0) : !1, m = {
|
|
281
|
+
elemento: o,
|
|
282
|
+
get aberto() {
|
|
283
|
+
return u;
|
|
284
|
+
},
|
|
285
|
+
fechar(i = !0) {
|
|
286
|
+
i ? o.confirmar() : h();
|
|
287
|
+
},
|
|
288
|
+
descartar() {
|
|
289
|
+
h();
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
return d.add(o, "ui-cor-input", (i) => t == null ? void 0 : t(i.detail)), d.add(o, "ui-cor-confirmar", (i) => {
|
|
293
|
+
h() && (a == null || a(i.detail));
|
|
294
|
+
}), d.add(o, "ui-cor-cancelar", (i) => {
|
|
295
|
+
h() && (r == null || r(i.detail));
|
|
296
|
+
}), d.add(o, "ui-alvo-change", (i) => n == null ? void 0 : n(i.detail.alvo)), d.add(o, "pointerdown", (i) => i.stopPropagation()), d.add(o, "click", (i) => i.stopPropagation()), document.body.appendChild(o), B(o, e), x = m, d.add(window, "pointerdown", (i) => {
|
|
297
|
+
const p = i.composedPath();
|
|
298
|
+
!p.includes(o) && !p.includes(e) && m.fechar(!0);
|
|
299
|
+
}, !0), d.add(window, "keydown", (i) => {
|
|
300
|
+
var b, g;
|
|
301
|
+
if (i.key === "Escape") {
|
|
302
|
+
i.preventDefault(), i.stopPropagation(), m.fechar(!0);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const p = (g = (b = i.composedPath()[0]) == null ? void 0 : b.matches) == null ? void 0 : g.call(b, 'input[type="text"]');
|
|
306
|
+
(i.key === "x" || i.key === "X") && !i.ctrlKey && !i.metaKey && !i.altKey && !i.shiftKey && !p && (i.preventDefault(), i.stopPropagation(), o.trocarAlvo(o.alvo === "preenchimento" ? "traco" : "preenchimento"));
|
|
307
|
+
}, !0), m;
|
|
308
|
+
}
|
|
309
|
+
function R(c = !0) {
|
|
310
|
+
x == null || x.fechar(c);
|
|
311
|
+
}
|
|
312
|
+
function B(c, o) {
|
|
313
|
+
const t = o.getBoundingClientRect(), a = c.offsetWidth, r = c.offsetHeight;
|
|
314
|
+
let n = t.right + 10;
|
|
315
|
+
n + a > window.innerWidth - 10 && (n = Math.max(10, t.left - a - 10));
|
|
316
|
+
let s = t.top;
|
|
317
|
+
s + r > window.innerHeight - 10 && (s = Math.max(10, window.innerHeight - r - 10)), c.style.left = `${Math.round(n)}px`, c.style.top = `${Math.round(s)}px`;
|
|
318
|
+
}
|
|
319
|
+
const T = ':host{display:inline-block;flex-shrink:0;-webkit-user-select:none;user-select:none}:host([hidden]){display:none}*,*:before,*:after{box-sizing:border-box}.pilha{position:relative;width:34px;height:34px}.amostra{position:absolute;width:20px;height:20px;padding:0;background:#2a2a31;border:1px solid rgba(255,255,255,.28);border-radius:5px;cursor:pointer;transition:transform .15s ease,border-color .15s ease,box-shadow .15s ease,opacity .15s ease}.amostra--traco{right:0;bottom:0;z-index:1}.amostra--preenchimento{top:0;left:0;z-index:2;box-shadow:0 2px 6px #00000080}.amostra:hover{border-color:#fff9;transform:scale(1.06)}.amostra:focus-visible{outline:none;border-color:#ffffffd9}.amostra--ativa{z-index:3;border-color:var(--ui-cor-primaria, #00e08a);box-shadow:0 0 0 1.5px var(--ui-cor-primaria, #00e08a),0 2px 6px #00000080}:host([so-traco]) .amostra--preenchimento{opacity:.4}.face{position:absolute;top:2px;right:2px;bottom:2px;left:2px;border-radius:3px;pointer-events:none}.face--traco{background:transparent;border:4px solid #ffffff}.face--sem-cor{background:repeating-conic-gradient(#33333d,#33333d 25%,#222228 0%,#222228 50%) 50% / 4px 4px!important;border-color:#ef444480!important}.face--sem-cor:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(to top right,transparent calc(50% - 1px),#ef4444 calc(50% - 1px),#ef4444 calc(50% + 1px),transparent calc(50% + 1px));pointer-events:none}.face--misto{display:flex;align-items:center;justify-content:center;background:#2e2e38!important;border-color:#64748b!important}.face--misto:after{content:"?";color:#fff;font-size:11px;font-weight:800;line-height:1;text-shadow:0 1px 2px rgba(0,0,0,.8)}.canto{position:absolute;z-index:4;display:flex;align-items:center;justify-content:center;width:13px;height:13px;padding:0;background:transparent;border:0;border-radius:3px;color:var(--ui-cor-texto-secundario, #888899);cursor:pointer;transition:color .15s ease,background .15s ease}.canto:hover{background:#ffffff1a;color:var(--ui-cor-primaria, #00e08a)}.canto:focus-visible{outline:1px solid var(--ui-cor-primaria, #00e08a)}.canto--inverter{top:0;right:0}.canto--inverter svg{width:11px;height:11px}.canto--padrao{left:0;bottom:0}.ponto{position:absolute;width:7px;height:7px;border-radius:1.5px}.ponto--preenchimento{top:1px;left:1px;background:#00e08a;border:1px solid rgba(255,255,255,.5)}.ponto--traco{right:1px;bottom:1px;background:transparent;border:1.5px solid #ffffff}.canto--sem-cor{left:11px;bottom:0}.canto--sem-cor svg{width:10px;height:10px}.canto--sem-cor:hover{background:#ef444433;color:#ef4444}:host([desabilitado]) .pilha{opacity:.5;pointer-events:none}';
|
|
320
|
+
class V extends E {
|
|
321
|
+
constructor() {
|
|
322
|
+
super();
|
|
323
|
+
l(this, "raiz");
|
|
324
|
+
l(this, "listeners", new C());
|
|
325
|
+
l(this, "renderizado", !1);
|
|
326
|
+
l(this, "_preenchimento", "#00e08a");
|
|
327
|
+
l(this, "_traco", "#ffffff");
|
|
328
|
+
l(this, "_opacidade", 0.35);
|
|
329
|
+
l(this, "_alvo", "preenchimento");
|
|
330
|
+
l(this, "_misto", { preenchimento: !1, traco: !1 });
|
|
331
|
+
l(this, "_padrao", { preenchimento: "#00e08a", traco: "#ffffff" });
|
|
332
|
+
l(this, "_coresProjeto", []);
|
|
333
|
+
l(this, "_atalhos", {});
|
|
334
|
+
l(this, "seletor", null);
|
|
335
|
+
l(this, "estadoAoAbrir", null);
|
|
336
|
+
this.raiz = this.attachShadow({ mode: "open" });
|
|
337
|
+
}
|
|
338
|
+
static get observedAttributes() {
|
|
339
|
+
return ["preenchimento", "traco", "opacidade", "alvo", "padrao-preenchimento", "padrao-traco"];
|
|
340
|
+
}
|
|
341
|
+
connectedCallback() {
|
|
342
|
+
this.renderizado || this.renderizar(), this.listeners.cleanup(), this.vincularEventos(), this.atualizar();
|
|
343
|
+
}
|
|
344
|
+
disconnectedCallback() {
|
|
345
|
+
this.fecharSeletor(!0), this.listeners.cleanup();
|
|
346
|
+
}
|
|
347
|
+
attributeChangedCallback(e, t, a) {
|
|
348
|
+
if (!(t === a || a === null)) {
|
|
349
|
+
if (e === "preenchimento") this.definirCores({ preenchimento: a });
|
|
350
|
+
else if (e === "traco") this.definirCores({ traco: a });
|
|
351
|
+
else if (e === "opacidade") this.definirCores({ opacidade: Number(a) });
|
|
352
|
+
else if (e === "alvo") this.definirAlvo(a);
|
|
353
|
+
else if (e === "padrao-preenchimento" || e === "padrao-traco") {
|
|
354
|
+
const r = v(a);
|
|
355
|
+
if (!r) return;
|
|
356
|
+
e === "padrao-preenchimento" ? this._padrao.preenchimento = r : this._padrao.traco = r, this.atualizar();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/* ---------- Propriedades ---------- */
|
|
361
|
+
get preenchimento() {
|
|
362
|
+
return this._preenchimento;
|
|
363
|
+
}
|
|
364
|
+
set preenchimento(e) {
|
|
365
|
+
this.definirCores({ preenchimento: e });
|
|
366
|
+
}
|
|
367
|
+
get traco() {
|
|
368
|
+
return this._traco;
|
|
369
|
+
}
|
|
370
|
+
set traco(e) {
|
|
371
|
+
this.definirCores({ traco: e });
|
|
372
|
+
}
|
|
373
|
+
get opacidade() {
|
|
374
|
+
return this._opacidade;
|
|
375
|
+
}
|
|
376
|
+
set opacidade(e) {
|
|
377
|
+
this.definirCores({ opacidade: e });
|
|
378
|
+
}
|
|
379
|
+
get alvo() {
|
|
380
|
+
return this._alvo;
|
|
381
|
+
}
|
|
382
|
+
set alvo(e) {
|
|
383
|
+
this.definirAlvo(e);
|
|
384
|
+
}
|
|
385
|
+
/** Cores oferecidas em "Cores do projeto" no seletor. */
|
|
386
|
+
get coresProjeto() {
|
|
387
|
+
return [...this._coresProjeto];
|
|
388
|
+
}
|
|
389
|
+
set coresProjeto(e) {
|
|
390
|
+
this._coresProjeto = z(e);
|
|
391
|
+
}
|
|
392
|
+
/** Teclas exibidas nas dicas dos botões (ex.: `{ inverter: 'Shift+X' }`). */
|
|
393
|
+
get atalhos() {
|
|
394
|
+
return { ...this._atalhos };
|
|
395
|
+
}
|
|
396
|
+
set atalhos(e) {
|
|
397
|
+
this._atalhos = { ...e || {} }, this.atualizar();
|
|
398
|
+
}
|
|
399
|
+
get seletorAberto() {
|
|
400
|
+
var e;
|
|
401
|
+
return !!((e = this.seletor) != null && e.aberto);
|
|
402
|
+
}
|
|
403
|
+
/* ---------- Métodos (sem eventos) ---------- */
|
|
404
|
+
/** Define cores e/ou opacidade sem emitir eventos. Valores inválidos são ignorados; uma cor definida deixa de ser "mista". */
|
|
405
|
+
definirCores(e = {}) {
|
|
406
|
+
const t = v(e.preenchimento), a = v(e.traco);
|
|
407
|
+
t && (this._preenchimento = t, this._misto.preenchimento = !1), a && (this._traco = a, this._misto.traco = !1), e.opacidade !== void 0 && (this._opacidade = w(e.opacidade, this._opacidade)), this.atualizar();
|
|
408
|
+
}
|
|
409
|
+
obterCores() {
|
|
410
|
+
return { preenchimento: this._preenchimento, traco: this._traco, opacidade: this._opacidade, alvo: this._alvo };
|
|
411
|
+
}
|
|
412
|
+
/** Marca a amostra como ativa sem emitir eventos. */
|
|
413
|
+
definirAlvo(e) {
|
|
414
|
+
this._alvo = e === "traco" ? "traco" : "preenchimento", this.atualizar();
|
|
415
|
+
}
|
|
416
|
+
/** Mostra "?" nas amostras cujas cores divergem na seleção atual. */
|
|
417
|
+
definirMisto(e = {}) {
|
|
418
|
+
this._misto = { preenchimento: !!e.preenchimento, traco: !!e.traco }, this.atualizar();
|
|
419
|
+
}
|
|
420
|
+
/* ---------- Ações (emitem eventos) ---------- */
|
|
421
|
+
/** Alterna o alvo ativo entre preenchimento e traço; emite `ui-alvo-change`. */
|
|
422
|
+
alternarAlvo() {
|
|
423
|
+
this.mudarAlvo(this._alvo === "traco" ? "preenchimento" : "traco");
|
|
424
|
+
}
|
|
425
|
+
/** Troca preenchimento e traço; emite `ui-cores-change` confirmado. */
|
|
426
|
+
inverter() {
|
|
427
|
+
const e = this._preenchimento;
|
|
428
|
+
this._preenchimento = this._traco, this._traco = e, this._misto = { preenchimento: this._misto.traco, traco: this._misto.preenchimento }, this.atualizar(), this.emitirCores(!0, ["preenchimento", "traco"], "inverter");
|
|
429
|
+
}
|
|
430
|
+
/** "Sem cor" no alvo indicado (padrão: o ativo); emite `ui-cores-change` confirmado. */
|
|
431
|
+
semCor(e = this._alvo) {
|
|
432
|
+
const t = e === "traco" ? "traco" : "preenchimento";
|
|
433
|
+
t === "traco" ? this._traco = "none" : this._preenchimento = "none", this._misto[t] = !1, this.atualizar(), this.emitirCores(!0, [t], "sem-cor");
|
|
434
|
+
}
|
|
435
|
+
/** Volta às cores de `padrao-preenchimento` e `padrao-traco`; emite `ui-cores-change` confirmado. */
|
|
436
|
+
restaurarPadrao() {
|
|
437
|
+
this._preenchimento = this._padrao.preenchimento, this._traco = this._padrao.traco, this._misto = { preenchimento: !1, traco: !1 }, this.atualizar(), this.emitirCores(!0, ["preenchimento", "traco"], "padrao");
|
|
438
|
+
}
|
|
439
|
+
/** Abre o seletor de cor ancorado na amostra do alvo (que passa a ser o ativo). */
|
|
440
|
+
abrirSeletor(e = this._alvo) {
|
|
441
|
+
if (this.hasAttribute("desabilitado") || (this.mudarAlvo(e === "traco" ? "traco" : "preenchimento"), this.seletorAberto)) return;
|
|
442
|
+
const t = this.raiz.querySelector(`[data-alvo="${this._alvo}"]`) || this;
|
|
443
|
+
this.estadoAoAbrir = this.obterCores(), this.seletor = D({
|
|
444
|
+
ancora: t,
|
|
445
|
+
titulo: this.getAttribute("titulo-seletor") || "Cores e estilo",
|
|
446
|
+
modo: "duplo",
|
|
447
|
+
alvo: this._alvo,
|
|
448
|
+
preenchimento: this._preenchimento,
|
|
449
|
+
traco: this._traco,
|
|
450
|
+
opacidade: this._opacidade,
|
|
451
|
+
misto: this._misto[this._alvo],
|
|
452
|
+
coresProjeto: this._coresProjeto,
|
|
453
|
+
aoAlterar: (a) => this.aplicarDoSeletor(a, !1),
|
|
454
|
+
aoConfirmar: (a) => {
|
|
455
|
+
this.seletor = null, this.aplicarDoSeletor(a, !0);
|
|
456
|
+
},
|
|
457
|
+
aoCancelar: () => {
|
|
458
|
+
this.seletor = null, this.estadoAoAbrir = null;
|
|
459
|
+
},
|
|
460
|
+
aoTrocarAlvo: (a) => this.mudarAlvo(a)
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
/** Fecha o seletor aberto por este controle (confirmando, por padrão). */
|
|
464
|
+
fecharSeletor(e = !0) {
|
|
465
|
+
const t = this.seletor;
|
|
466
|
+
t && (e ? t.fechar(!0) : (this.seletor = null, t.fechar(!1)));
|
|
467
|
+
}
|
|
468
|
+
/* ---------- Interno ---------- */
|
|
469
|
+
mudarAlvo(e) {
|
|
470
|
+
e !== this._alvo && (this._alvo = e, this.atualizar(), this.dispatchEvent(new CustomEvent("ui-alvo-change", { detail: { alvo: e }, bubbles: !0, composed: !0 })));
|
|
471
|
+
}
|
|
472
|
+
aplicarDoSeletor(e, t) {
|
|
473
|
+
const a = (n) => {
|
|
474
|
+
const s = [];
|
|
475
|
+
return e.preenchimento !== n.preenchimento && s.push("preenchimento"), e.traco !== n.traco && s.push("traco"), e.opacidade !== n.opacidade && s.push("opacidade"), s;
|
|
476
|
+
}, r = a(this.obterCores());
|
|
477
|
+
if (this._preenchimento = e.preenchimento, this._traco = e.traco, this._opacidade = e.opacidade, r.includes("preenchimento") && (this._misto.preenchimento = !1), r.includes("traco") && (this._misto.traco = !1), this.atualizar(), !t) {
|
|
478
|
+
r.length && this.emitirCores(!1, r, "seletor");
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
this.emitirCores(!0, this.estadoAoAbrir ? a(this.estadoAoAbrir) : r, "seletor"), this.estadoAoAbrir = null;
|
|
482
|
+
}
|
|
483
|
+
emitirCores(e, t, a) {
|
|
484
|
+
const r = { ...this.obterCores(), confirmado: e, alterados: t, origem: a };
|
|
485
|
+
this.dispatchEvent(new CustomEvent("ui-cores-change", { detail: r, bubbles: !0, composed: !0 }));
|
|
486
|
+
}
|
|
487
|
+
dica(e, t) {
|
|
488
|
+
return t ? `${e} [${t}]` : e;
|
|
489
|
+
}
|
|
490
|
+
renderizar() {
|
|
491
|
+
this.raiz.innerHTML = `
|
|
492
|
+
<style>${T}</style>
|
|
493
|
+
<div class="pilha" part="pilha">
|
|
494
|
+
<button type="button" class="amostra amostra--traco" data-alvo="traco" part="amostra amostra-traco">
|
|
495
|
+
<span class="face face--traco"></span>
|
|
496
|
+
</button>
|
|
497
|
+
<button type="button" class="amostra amostra--preenchimento" data-alvo="preenchimento" part="amostra amostra-preenchimento">
|
|
498
|
+
<span class="face face--preenchimento"></span>
|
|
499
|
+
</button>
|
|
500
|
+
<button type="button" class="canto canto--inverter" data-acao="inverter" aria-label="Inverter preenchimento e traço">
|
|
501
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
502
|
+
<path d="m16 3 4 4-4 4"/><path d="M20 7H4"/><path d="m8 21-4-4 4-4"/><path d="M4 17h16"/>
|
|
503
|
+
</svg>
|
|
504
|
+
</button>
|
|
505
|
+
<button type="button" class="canto canto--sem-cor" data-acao="sem-cor" aria-label="Sem cor">
|
|
506
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="#ef4444" stroke-width="2.4" stroke-linecap="round" aria-hidden="true">
|
|
507
|
+
<circle cx="12" cy="12" r="8" stroke="currentColor"/>
|
|
508
|
+
<line x1="6.5" y1="6.5" x2="17.5" y2="17.5" stroke="#ef4444"/>
|
|
509
|
+
</svg>
|
|
510
|
+
</button>
|
|
511
|
+
<button type="button" class="canto canto--padrao" data-acao="padrao" aria-label="Restaurar cores padrão">
|
|
512
|
+
<span class="ponto ponto--preenchimento"></span>
|
|
513
|
+
<span class="ponto ponto--traco"></span>
|
|
514
|
+
</button>
|
|
515
|
+
</div>
|
|
516
|
+
`, this.renderizado = !0;
|
|
517
|
+
}
|
|
518
|
+
vincularEventos() {
|
|
519
|
+
const e = this.raiz;
|
|
520
|
+
e.querySelectorAll("[data-alvo]").forEach((a) => {
|
|
521
|
+
const r = a.dataset.alvo;
|
|
522
|
+
this.listeners.add(a, "click", (n) => {
|
|
523
|
+
n.stopPropagation(), r !== this._alvo ? this.mudarAlvo(r) : this.seletorAberto ? this.fecharSeletor(!0) : this.abrirSeletor(r);
|
|
524
|
+
}), this.listeners.add(a, "dblclick", (n) => {
|
|
525
|
+
n.stopPropagation(), this.abrirSeletor(r);
|
|
526
|
+
}), this.listeners.add(a, "keydown", (n) => {
|
|
527
|
+
(n.key === "Enter" || n.key === " ") && (n.preventDefault(), this.abrirSeletor(r));
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
const t = (a, r) => {
|
|
531
|
+
this.listeners.add(e.querySelector(`[data-acao="${a}"]`), "click", (n) => {
|
|
532
|
+
n.stopPropagation(), r();
|
|
533
|
+
});
|
|
534
|
+
};
|
|
535
|
+
t("inverter", () => this.inverter()), t("sem-cor", () => this.semCor()), t("padrao", () => this.restaurarPadrao());
|
|
536
|
+
}
|
|
537
|
+
atualizar() {
|
|
538
|
+
if (!this.renderizado) return;
|
|
539
|
+
const e = this.raiz, t = this._atalhos, a = (u, h) => h ? "Misto (?) [várias cores na seleção]" : u === "none" ? "Sem cor" : u, r = (u, h, m, i) => {
|
|
540
|
+
const p = e.querySelector(`[data-alvo="${u}"]`), b = p == null ? void 0 : p.querySelector(".face");
|
|
541
|
+
if (!p || !b) return;
|
|
542
|
+
const g = this._alvo === u;
|
|
543
|
+
p.classList.toggle("amostra--ativa", g), p.setAttribute("aria-pressed", String(g)), b.classList.toggle("face--misto", m), b.classList.toggle("face--sem-cor", !m && h === "none");
|
|
544
|
+
const k = u === "traco" ? "borderColor" : "backgroundColor";
|
|
545
|
+
b.style[k] = m || h === "none" ? "" : h;
|
|
546
|
+
const y = `${i}: ${a(h, m)}`;
|
|
547
|
+
p.title = this.dica(`${y} — clique para ativar, clique de novo para editar`, t.alternar), p.setAttribute("aria-label", y);
|
|
548
|
+
};
|
|
549
|
+
r("preenchimento", this._preenchimento, this._misto.preenchimento, "Preenchimento"), r("traco", this._traco, this._misto.traco, "Traço / contorno");
|
|
550
|
+
const n = (u, h) => {
|
|
551
|
+
const m = e.querySelector(`[data-acao="${u}"]`);
|
|
552
|
+
m && (m.title = h);
|
|
553
|
+
};
|
|
554
|
+
n("inverter", this.dica("Inverter preenchimento e traço", t.inverter)), n("sem-cor", this.dica("Sem cor no alvo ativo", t.semCor)), n("padrao", this.dica("Restaurar cores padrão", t.padrao));
|
|
555
|
+
const s = e.querySelector(".ponto--preenchimento");
|
|
556
|
+
s && (s.style.backgroundColor = this._padrao.preenchimento === "none" ? "transparent" : this._padrao.preenchimento);
|
|
557
|
+
const d = e.querySelector(".ponto--traco");
|
|
558
|
+
d && (d.style.borderColor = this._padrao.traco === "none" ? "#ef4444" : this._padrao.traco);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
$("ui-controle-cores", V);
|
|
562
|
+
export {
|
|
563
|
+
A as P,
|
|
564
|
+
V as U,
|
|
565
|
+
N as a,
|
|
566
|
+
D as b,
|
|
567
|
+
z as c,
|
|
568
|
+
w as d,
|
|
569
|
+
M as e,
|
|
570
|
+
R as f,
|
|
571
|
+
v as n
|
|
572
|
+
};
|