@thibezer/ui-components-kit 2.4.1 → 2.6.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 +180 -193
- package/README.md +35 -6
- package/dist/canvas.cjs +59 -59
- package/dist/canvas.js +1395 -1725
- package/dist/components/ui-barra-ferramentas/ferramentas-comum.d.ts +12 -0
- package/dist/components/ui-barra-ferramentas/tipos.d.ts +30 -0
- package/dist/components/ui-barra-ferramentas/ui-paleta-ferramentas.d.ts +35 -5
- package/dist/components/ui-barra-ferramentas/ui-ribbon.d.ts +16 -8
- package/dist/components/ui-canvas-cad/cad-feicoes.d.ts +1 -15
- package/dist/components/ui-canvas-cad/cad-ferramentas-barra.d.ts +1 -8
- package/dist/components/ui-canvas-cad/cad-snap.d.ts +0 -2
- package/dist/components/ui-canvas-cad/ui-canvas-cad.d.ts +0 -7
- package/dist/components/ui-cores/tipos.d.ts +0 -2
- package/dist/components/ui-cores/ui-controle-cores.d.ts +3 -8
- package/dist/components/ui-cores/ui-seletor-cor.d.ts +1 -3
- package/dist/components/ui-tabela/tabela-corpo.d.ts +4 -0
- package/dist/components/ui-tabela/tabela-dom.d.ts +3 -0
- package/dist/components/ui-tabela/tabela-header.d.ts +3 -1
- package/dist/components/ui-tabela/tabela-interacao.d.ts +3 -1
- package/dist/components/ui-tabela/tabela-ordenacao.d.ts +5 -3
- package/dist/components/ui-tabela/tabela-orquestrador-dados.d.ts +13 -1
- package/dist/components/ui-tabela/tabela-redimensionamento.d.ts +11 -2
- package/dist/components/ui-tabela/tabela-remota.d.ts +17 -4
- package/dist/components/ui-tabela/tabela-renderizador.d.ts +2 -0
- package/dist/components/ui-tabela/tabela-selecao.d.ts +2 -0
- package/dist/components/ui-tabela/tipos.d.ts +15 -0
- package/dist/components/ui-tabela/ui-tabela.d.ts +28 -4
- package/dist/cores.cjs +1 -1
- package/dist/cores.js +1 -1
- package/dist/custom-elements.json +6367 -5537
- package/dist/data.cjs +1 -1
- package/dist/data.js +54 -50
- package/dist/gerencigeo-canvas/canvas_interacao.d.ts +0 -2
- package/dist/gerencigeo-canvas/feature_desenho.d.ts +0 -2
- package/dist/gerencigeo-canvas/feature_desenho_controle.d.ts +0 -3
- package/dist/gerencigeo-canvas/feature_editor_vertices.d.ts +4 -51
- package/dist/index.cjs +1 -1
- package/dist/index.js +94 -90
- package/dist/register.cjs +1 -1
- package/dist/register.js +3 -3
- package/dist/tabela.cjs +1 -1
- package/dist/tabela.js +42 -38
- package/dist/tipos-elementos.d.ts +22 -11
- package/dist/tipos-vue.d.ts +21 -11
- package/dist/tools.cjs +1 -1
- package/dist/tools.js +1 -1
- package/dist/ui-botao-OGJV6Vfk.js +165 -0
- package/dist/ui-botao-psS1juof.cjs +12 -0
- package/dist/ui-controle-cores-BS0WYPdi.js +572 -0
- package/dist/ui-controle-cores-Er6ZcQ7U.cjs +111 -0
- package/dist/ui-paleta-ferramentas-Ccmo-rB5.cjs +21 -0
- package/dist/ui-paleta-ferramentas-DNN5i6nL.js +860 -0
- package/dist/ui-tabela-propriedades-BecPqC-e.cjs +141 -0
- package/dist/ui-tabela-propriedades-BokvDD3b.js +2648 -0
- package/package.json +1 -1
- package/dist/ui-controle-cores-DgEza3wF.js +0 -612
- package/dist/ui-controle-cores-uY__TgwW.cjs +0 -117
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thibezer/ui-components-kit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Web Components nativos (W3C Custom Elements + Shadow DOM) para interfaces densas de GIS, CAD e formulários, sem dependência de framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
|
@@ -1,612 +0,0 @@
|
|
|
1
|
-
var j = Object.defineProperty;
|
|
2
|
-
var M = (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) => M(c, typeof o != "symbol" ? o + "" : o, e);
|
|
4
|
-
import { d as $, S as E } from "./ssr-safe-5cWfJP-s.js";
|
|
5
|
-
import { L as A } from "./listener-bag-DQgv7OON.js";
|
|
6
|
-
const S = [
|
|
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 k(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 z(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 C(c) {
|
|
35
|
-
if (!Array.isArray(c)) return [];
|
|
36
|
-
const o = /* @__PURE__ */ new Set();
|
|
37
|
-
for (const e of c) {
|
|
38
|
-
const t = k(e);
|
|
39
|
-
t && t !== "none" && o.add(t);
|
|
40
|
-
}
|
|
41
|
-
return [...o];
|
|
42
|
-
}
|
|
43
|
-
function L(c) {
|
|
44
|
-
return String(c ?? "").replace(/[&<>"']/g, (o) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[o]);
|
|
45
|
-
}
|
|
46
|
-
const O = ':host{--_t: var(--ui-cor-texto, #e1e1e6);--_t2: var(--ui-cor-texto-secundario, #9696a6);--_linha: var(--ui-cor-borda, rgba(255, 255, 255, .12));--_realce: color-mix(in srgb, var(--_t) 8%, transparent);--_realce-forte: color-mix(in srgb, var(--_t) 16%, transparent);--_campo: color-mix(in srgb, var(--ui-cor-fundo, #0b0b0d) 70%, transparent);--_destaque: var(--ui-cor-primaria, #00e08a);--_sobre-destaque: var(--ui-cor-texto-sobre-primaria, #000000);--_vermelho: #ef4444;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, color-mix(in srgb, var(--ui-cor-fundo-menu, #18181c) 95%, transparent));backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);border:1px solid var(--_linha);border-radius:12px;box-shadow:var(--ui-sombra-lg, 0 16px 40px rgba(0, 0, 0, .6)),0 2px 8px #00000040;color:var(--_t);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}:host(:focus){outline: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 var(--_linha)}.titulo{display:flex;align-items:center;gap:6px;font-weight:600;font-size:12.5px;color:var(--_t);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.titulo svg{flex-shrink:0;color:var(--_destaque)}.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:var(--_t2);font-size:14px;cursor:pointer;transition:all .15s ease}.fechar:hover{background:var(--_realce-forte);color:var(--_t)}.abas{display:flex;gap:2px;margin-bottom:10px;padding:2px;background:var(--_campo);border:1px solid var(--_linha);border-radius:8px}.aba{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;padding:5px 6px;background:transparent;border:none;border-radius:6px;color:var(--_t2);font-size:11px;font-weight:600;cursor:pointer;transition:all .15s ease}.aba:hover{background:var(--_realce);color:var(--_t)}.aba[aria-selected=true]{background:var(--_realce-forte);color:var(--_t);box-shadow:0 1px 3px #00000040}.aba-amostra{width:11px;height:11px;border:1px solid var(--_linha);border-radius:2.5px}.aba-amostra--sem-cor{background:linear-gradient(to top right,transparent calc(50% - 1px),var(--_vermelho) calc(50% - 1px),var(--_vermelho) calc(50% + 1px),transparent calc(50% + 1px)),var(--_realce-forte)}.aba-amostra--traco{border:2.5px solid #ffffff;background:transparent}.previa{display:flex;height:34px;margin-bottom:10px;overflow:hidden;background:var(--_campo);border:1px solid var(--_linha);border-radius:7px;box-shadow:inset 0 1px 3px #00000040}.previa-metade{flex:1;position:relative;display:flex;align-items:center;justify-content:center;background:repeating-conic-gradient(var(--_realce-forte) 0% 25%,transparent 0% 50%) 50% / 10px 10px}.previa-metade+.previa-metade{border-left:1px solid var(--_linha)}.previa-cor{position:absolute;top:0;right:0;bottom:0;left:0;transition:background-color .12s ease}.previa-cor--sem-cor{background:transparent!important;overflow:hidden}.previa-cor--sem-cor:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(to top right,transparent calc(50% - 1px),var(--_vermelho) calc(50% - 1px),var(--_vermelho) calc(50% + 1px),transparent calc(50% + 1px))}.previa-metade span{position:relative;z-index:2;padding:1px 5px;background:#0000008c;border-radius:3px;font-size:9.5px;font-weight:600;letter-spacing:.3px;color:#fff}.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:9px;color:var(--_t2);font-weight:600;pointer-events:none}.hex input{width:100%;height:28px;padding:0 8px 0 21px;background:var(--_campo);border:1px solid var(--_linha);border-radius:6px;outline:none;color:var(--_t);font-family:var(--ui-fonte-codigo, ui-monospace, "Cascadia Mono", Consolas, monospace);font-size:12px;letter-spacing:.5px;text-transform:uppercase;-webkit-user-select:text;user-select:text;transition:border-color .15s ease,box-shadow .15s ease}.hex input::placeholder{color:var(--_t2);opacity:.7}.hex input:hover{border-color:color-mix(in srgb,var(--_t) 35%,transparent)}.hex input:focus{border-color:var(--_destaque);box-shadow:0 0 0 2px color-mix(in srgb,var(--_destaque) 25%,transparent)}.nativo{position:relative;display:flex;align-items:center;justify-content:center;width:28px;height:28px;flex-shrink:0;overflow:hidden;background:var(--_realce);border:1px solid var(--_linha);border-radius:6px;color:var(--_t2);cursor:pointer;transition:border-color .15s ease,color .15s ease}.nativo:hover,.nativo:focus-within{border-color:color-mix(in srgb,var(--_t) 45%,transparent);color:var(--_t)}.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:var(--_campo);border:1px solid var(--_linha);border-radius:8px}.opacidade[hidden]{display:none}.opacidade-cabecalho{display:flex;align-items:center;justify-content:space-between;margin-bottom:7px;color:var(--_t2);font-size:11px}.opacidade-valor{font-weight:700;font-variant-numeric:tabular-nums;color:var(--_destaque)}.opacidade input[type=range]{width:100%;height:14px;margin:0;background:transparent;outline:none;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.opacidade input[type=range]::-webkit-slider-runnable-track{height:6px;background:linear-gradient(to right,var(--_destaque) var(--pct, 0%),var(--_realce-forte) var(--pct, 0%));border-radius:3px}.opacidade input[type=range]::-moz-range-track{height:6px;background:var(--_realce-forte);border-radius:3px}.opacidade input[type=range]::-moz-range-progress{height:6px;background:var(--_destaque);border-radius:3px}.opacidade input[type=range]::-webkit-slider-thumb{width:14px;height:14px;margin-top:-4px;background:#fff;border:2px solid var(--_destaque);border-radius:50%;box-shadow:0 1px 4px #00000080;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.opacidade input[type=range]::-moz-range-thumb{width:11px;height:11px;background:#fff;border:2px solid var(--_destaque);border-radius:50%;box-shadow:0 1px 4px #00000080;cursor:pointer}.opacidade-atalhos{display:flex;gap:4px;margin-top:7px}.opacidade-atalhos button{flex:1;padding:3px 0;background:var(--_realce);border:1px solid var(--_linha);border-radius:4px;color:var(--_t2);font-size:10px;text-align:center;cursor:pointer;transition:all .12s ease}.opacidade-atalhos button:hover{background:var(--_realce-forte);color:var(--_t)}.opacidade-atalhos button.ativo{background:var(--_destaque);border-color:var(--_destaque);color:var(--_sobre-destaque);font-weight:700}.rotulo-secao{margin:8px 0 5px;color:var(--_t2);font-size:10.5px;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 color-mix(in srgb,var(--_t) 25%,transparent);border-radius:5px;cursor:pointer;transition:transform .12s ease,border-color .12s ease}.amostra:hover{z-index:2;border-color:var(--_t);transform:scale(1.15)}.amostra.ativo{z-index:1;border:2px solid #ffffff;box-shadow:0 0 0 2px var(--_destaque),0 1px 4px #0006}.sem-cor{display:flex;align-items:center;justify-content:center;gap:6px;width:100%;margin-top:6px;padding:6px;background:#ef44441a;border:1px solid rgba(239,68,68,.35);border-radius:6px;color:var(--ui-cor-texto-erro, #fca5a5);font-size:11.5px;font-weight:600;cursor:pointer;transition:all .15s ease}.sem-cor:hover{background:#ef444433;border-color:var(--_vermelho)}.sem-cor.ativo{background:var(--_vermelho);border-color:var(--_vermelho);color:#fff}.rodape{display:flex;justify-content:flex-end;gap:6px;margin-top:10px;padding-top:8px;border-top:1px solid var(--_linha)}.rodape button{padding:5px 12px;border:none;border-radius:6px;font-size:11.5px;font-weight:600;cursor:pointer;transition:all .15s ease}.botao-concluir{background:var(--_destaque);color:var(--_sobre-destaque)}.botao-concluir:hover{filter:brightness(1.1)}.botao-cancelar{background:var(--_realce);color:var(--_t2)}.botao-cancelar:hover{background:var(--_realce-forte);color:var(--_t)}button:focus-visible,input:focus-visible,.nativo:focus-within{outline:2px solid var(--_destaque);outline-offset:1px}.hex input:focus-visible{outline:none}@media (prefers-reduced-motion: reduce){:host{animation:none}.amostra,.amostra:hover{transition:none;transform:none}}', D = [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 A());
|
|
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", [...S]);
|
|
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.hasAttribute("tabindex") || this.setAttribute("tabindex", "-1"), 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 = k(e.cor);
|
|
78
|
-
this._preenchimento = k(e.preenchimento) ?? (this._alvo === "preenchimento" ? a : null) ?? "#00e08a", this._traco = k(e.traco) ?? (this._alvo === "traco" ? a : null) ?? "#ffffff", this._opacidade = z(e.opacidade), this._mostrarOpacidade = e.mostrarOpacidade, this._misto = e.misto === !0, this._coresProjeto = C(e.coresProjeto), this._paleta = e.paleta ? C(e.paleta) : [...S], 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 = k(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 = z(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(), this.setAttribute("aria-label", this._titulo);
|
|
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()}" aria-pressed="false"></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>${L(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
|
-
${D.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" aria-pressed="false" 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
|
-
const e = (d) => this.raiz.querySelector(d), t = this.cor, a = t === "none";
|
|
216
|
-
this.raiz.querySelectorAll("[data-alvo]").forEach((d) => {
|
|
217
|
-
d.setAttribute("aria-selected", String(d.dataset.alvo === this._alvo));
|
|
218
|
-
});
|
|
219
|
-
const i = e(".aba-amostra--preenchimento");
|
|
220
|
-
i && (i.classList.toggle("aba-amostra--sem-cor", this._preenchimento === "none"), i.style.backgroundColor = this._preenchimento === "none" ? "" : this._preenchimento);
|
|
221
|
-
const s = e(".aba-amostra--traco");
|
|
222
|
-
s && (s.style.borderColor = this._traco === "none" ? "#ef4444" : this._traco);
|
|
223
|
-
const n = e(".opacidade");
|
|
224
|
-
n && (n.hidden = !this.opacidadeVisivel);
|
|
225
|
-
const m = (d, b) => String(d ? b : 1), u = (d, b, P) => {
|
|
226
|
-
d && (d.classList.toggle("previa-cor--sem-cor", b === "none"), d.style.backgroundColor = b === "none" ? "" : b, d.style.opacity = b === "none" ? "" : P);
|
|
227
|
-
}, x = this._alvo === "preenchimento", f = x ? this.inicial.preenchimento : this.inicial.traco;
|
|
228
|
-
u(e(".previa-cor--original"), f, m(x, this.inicial.opacidade)), u(e(".previa-cor--nova"), t, m(x, this._opacidade));
|
|
229
|
-
const p = e(".previa-rotulo-nova");
|
|
230
|
-
p && (p.textContent = this._misto ? "MISTO (?)" : "NOVA");
|
|
231
|
-
const r = e(".hex-entrada");
|
|
232
|
-
r && !this.campoEmFoco(r) && (r.value = a ? "" : t.slice(1).toUpperCase(), r.placeholder = a ? "NENHUM" : "00E08A");
|
|
233
|
-
const g = e(".nativo-entrada");
|
|
234
|
-
g && (g.value = a ? "#00e08a" : t);
|
|
235
|
-
const v = Math.round(this._opacidade * 100), h = e(".opacidade-entrada");
|
|
236
|
-
h && (h.value = String(v), h.style.setProperty("--pct", `${v}%`), h.setAttribute("aria-valuetext", `${v}%`));
|
|
237
|
-
const w = e(".opacidade-valor");
|
|
238
|
-
w && (w.textContent = `${v}%`), this.raiz.querySelectorAll("[data-opacidade]").forEach((d) => {
|
|
239
|
-
d.classList.toggle("ativo", Math.abs(Number(d.dataset.opacidade) - this._opacidade) < 0.02);
|
|
240
|
-
}), this.raiz.querySelectorAll(".amostra").forEach((d) => {
|
|
241
|
-
const b = d.dataset.cor === t;
|
|
242
|
-
d.classList.toggle("ativo", b), d.setAttribute("aria-pressed", String(b));
|
|
243
|
-
});
|
|
244
|
-
const _ = e(".sem-cor");
|
|
245
|
-
_ == null || _.classList.toggle("ativo", a), _ == null || _.setAttribute("aria-pressed", String(a));
|
|
246
|
-
}
|
|
247
|
-
/** `activeElement` lança em alguns DOMs simulados quando o foco está em outra árvore de sombra. */
|
|
248
|
-
campoEmFoco(e) {
|
|
249
|
-
try {
|
|
250
|
-
return this.raiz.activeElement === e;
|
|
251
|
-
} catch {
|
|
252
|
-
return !1;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
vincularEventos() {
|
|
256
|
-
const e = this.raiz;
|
|
257
|
-
e.querySelectorAll("[data-alvo]").forEach((n) => {
|
|
258
|
-
this.listeners.add(n, "click", () => this.trocarAlvo(n.dataset.alvo));
|
|
259
|
-
}), e.querySelectorAll("[data-cor]").forEach((n) => {
|
|
260
|
-
this.listeners.add(n, "click", () => this.definirCor(n.dataset.cor || ""));
|
|
261
|
-
}), e.querySelectorAll("[data-opacidade]").forEach((n) => {
|
|
262
|
-
this.listeners.add(n, "click", () => this.definirOpacidade(Number(n.dataset.opacidade)));
|
|
263
|
-
});
|
|
264
|
-
const t = e.querySelector(".opacidade-entrada");
|
|
265
|
-
this.listeners.add(t, "input", () => this.definirOpacidade(Number(t.value) / 100));
|
|
266
|
-
const a = e.querySelector(".hex-entrada"), i = (n) => {
|
|
267
|
-
const m = a.value.trim().replace(/^#/, "");
|
|
268
|
-
(/^[0-9a-f]{6}$/i.test(m) || n && /^[0-9a-f]{3}$/i.test(m)) && this.definirCor(`#${m}`);
|
|
269
|
-
};
|
|
270
|
-
this.listeners.add(a, "input", () => i(!1)), this.listeners.add(a, "change", () => {
|
|
271
|
-
i(!0), this.atualizarVisual();
|
|
272
|
-
}), this.listeners.add(a, "keydown", (n) => {
|
|
273
|
-
n.key === "Enter" && (n.preventDefault(), i(!0), this.confirmar());
|
|
274
|
-
});
|
|
275
|
-
const s = e.querySelector(".nativo-entrada");
|
|
276
|
-
this.listeners.add(s, "input", () => this.definirCor(s.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());
|
|
277
|
-
}
|
|
278
|
-
emitir(e, t) {
|
|
279
|
-
this.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
$("ui-seletor-cor", N);
|
|
283
|
-
let y = null;
|
|
284
|
-
function T(c) {
|
|
285
|
-
y == null || y.descartar();
|
|
286
|
-
const o = document.createElement("ui-seletor-cor"), { ancora: e, focar: t, aoAlterar: a, aoConfirmar: i, aoCancelar: s, aoTrocarAlvo: n, ...m } = c;
|
|
287
|
-
o.configurar(m);
|
|
288
|
-
const u = new A();
|
|
289
|
-
let x = !0;
|
|
290
|
-
const f = () => {
|
|
291
|
-
if (!x) return !1;
|
|
292
|
-
x = !1, u.cleanup();
|
|
293
|
-
const r = document.activeElement === o;
|
|
294
|
-
return o.remove(), r && e instanceof HTMLElement && e.isConnected && e.focus({ preventScroll: !0 }), y === p && (y = null), !0;
|
|
295
|
-
}, p = {
|
|
296
|
-
elemento: o,
|
|
297
|
-
get aberto() {
|
|
298
|
-
return x;
|
|
299
|
-
},
|
|
300
|
-
fechar(r = !0) {
|
|
301
|
-
r ? o.confirmar() : f();
|
|
302
|
-
},
|
|
303
|
-
descartar() {
|
|
304
|
-
f();
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
return u.add(o, "ui-cor-input", (r) => a == null ? void 0 : a(r.detail)), u.add(o, "ui-cor-confirmar", (r) => {
|
|
308
|
-
f() && (i == null || i(r.detail));
|
|
309
|
-
}), u.add(o, "ui-cor-cancelar", (r) => {
|
|
310
|
-
f() && (s == null || s(r.detail));
|
|
311
|
-
}), u.add(o, "ui-alvo-change", (r) => {
|
|
312
|
-
r.stopPropagation(), n == null || n(r.detail.alvo);
|
|
313
|
-
}), u.add(o, "pointerdown", (r) => r.stopPropagation()), u.add(o, "click", (r) => r.stopPropagation()), document.body.appendChild(o), q(o, e), y = p, t && o.focus({ preventScroll: !0 }), u.add(window, "resize", () => q(o, e)), u.add(window, "pointerdown", (r) => {
|
|
314
|
-
const g = r.composedPath();
|
|
315
|
-
!g.includes(o) && !g.includes(e) && p.fechar(!0);
|
|
316
|
-
}, !0), u.add(window, "keydown", (r) => {
|
|
317
|
-
var v, h;
|
|
318
|
-
if (r.key === "Escape") {
|
|
319
|
-
r.preventDefault(), r.stopPropagation(), p.fechar(!0);
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
const g = (h = (v = r.composedPath()[0]) == null ? void 0 : v.matches) == null ? void 0 : h.call(v, 'input[type="text"]');
|
|
323
|
-
(r.key === "x" || r.key === "X") && !r.ctrlKey && !r.metaKey && !r.altKey && !r.shiftKey && !g && (r.preventDefault(), r.stopPropagation(), o.trocarAlvo(o.alvo === "preenchimento" ? "traco" : "preenchimento"));
|
|
324
|
-
}, !0), p;
|
|
325
|
-
}
|
|
326
|
-
function F(c = !0) {
|
|
327
|
-
y == null || y.fechar(c);
|
|
328
|
-
}
|
|
329
|
-
function q(c, o) {
|
|
330
|
-
const t = o.getBoundingClientRect(), a = c.offsetWidth, i = c.offsetHeight;
|
|
331
|
-
let s = t.right + 10;
|
|
332
|
-
s + a > window.innerWidth - 10 && (s = Math.max(10, t.left - a - 10));
|
|
333
|
-
let n = t.top;
|
|
334
|
-
n + i > window.innerHeight - 10 && (n = Math.max(10, window.innerHeight - i - 10)), c.style.left = `${Math.round(s)}px`, c.style.top = `${Math.round(n)}px`;
|
|
335
|
-
}
|
|
336
|
-
const B = ':host{--_a: var(--ui-controle-cores-amostra, 26px);--_pilha: calc(var(--_a) * 5 / 3);--_borda: color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 30%, transparent);--_borda-forte: color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 70%, transparent);--_base: var(--ui-cor-superficie, #1d1d22);--_destaque: var(--ui-cor-primaria, #00e08a);--_vermelho: #ef4444;display:inline-block;flex-shrink:0;-webkit-user-select:none;user-select:none}:host([hidden]){display:none}*,*:before,*:after{box-sizing:border-box}.pilha{display:flex;align-items:stretch;gap:6px}.amostras{position:relative;flex:none;width:var(--_pilha);height:var(--_pilha)}.amostra{position:absolute;width:var(--_a);height:var(--_a);padding:0;background:var(--_base);border:1px solid var(--_borda);border-radius:6px;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 #00000059}.amostra:hover{border-color:var(--_borda-forte);transform:scale(1.05)}.amostra:focus-visible{outline:2px solid var(--ui-cor-texto, #e1e1e6);outline-offset:2px}.amostra--ativa,.amostra--ativa:hover{z-index:3;border-color:var(--_destaque);box-shadow:0 0 0 1.5px var(--_destaque),0 2px 6px #00000059}:host([so-traco]) .amostra--preenchimento{opacity:.4}.face{position:absolute;top:3px;right:3px;bottom:3px;left:3px;border-radius:3.5px;pointer-events:none}.face--traco{background:transparent;border:4px solid #ffffff}.face--sem-cor{background:repeating-conic-gradient(#3a3a45,#3a3a45 25%,#24242b 0%,#24242b 50%) 50% / 6px 6px!important;border-color:#ef44448c!important;overflow:hidden}.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),var(--_vermelho) calc(50% - 1px),var(--_vermelho) calc(50% + 1px),transparent calc(50% + 1px))}.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:12px;font-weight:800;line-height:1;text-shadow:0 1px 2px rgba(0,0,0,.8)}.acoes{display:flex;flex:none;flex-direction:column;gap:2px;width:16px}.acao{display:flex;flex:1;align-items:center;justify-content:center;min-height:0;padding:0;background:transparent;border:0;border-radius:4px;color:var(--ui-cor-texto-secundario, #9696a6);cursor:pointer;transition:color .15s ease,background .15s ease}.acao:hover{background:color-mix(in srgb,var(--ui-cor-texto, #e1e1e6) 12%,transparent);color:var(--_destaque)}.acao:focus-visible{outline:2px solid var(--ui-cor-texto, #e1e1e6);outline-offset:1px}.acao svg{width:12px;height:12px}.acao--sem-cor:hover{background:#ef444433;color:var(--_vermelho)}.icone-padrao{position:relative;width:11px;height:11px}.ponto{position:absolute;width:7px;height:7px;border-radius:1.5px}.ponto--preenchimento{top:0;left:0;background:#00e08a;border:1px solid var(--_borda-forte)}.ponto--traco{right:0;bottom:0;background:var(--_base);border:1.5px solid #ffffff}:host([desabilitado]) .pilha{opacity:.5}:host([desabilitado]) .amostra,:host([desabilitado]) .acao{cursor:not-allowed;pointer-events:none}@media (prefers-reduced-motion: reduce){.amostra,.acao{transition:none}.amostra:hover{transform:none}}';
|
|
337
|
-
class H extends E {
|
|
338
|
-
constructor() {
|
|
339
|
-
super();
|
|
340
|
-
l(this, "raiz");
|
|
341
|
-
l(this, "listeners", new A());
|
|
342
|
-
l(this, "renderizado", !1);
|
|
343
|
-
l(this, "_preenchimento", "#00e08a");
|
|
344
|
-
l(this, "_traco", "#ffffff");
|
|
345
|
-
l(this, "_opacidade", 0.35);
|
|
346
|
-
l(this, "_alvo", "preenchimento");
|
|
347
|
-
l(this, "_misto", { preenchimento: !1, traco: !1 });
|
|
348
|
-
l(this, "_padrao", { preenchimento: "#00e08a", traco: "#ffffff" });
|
|
349
|
-
l(this, "_coresProjeto", []);
|
|
350
|
-
l(this, "_atalhos", {});
|
|
351
|
-
l(this, "seletor", null);
|
|
352
|
-
l(this, "estadoAoAbrir", null);
|
|
353
|
-
this.raiz = this.attachShadow({ mode: "open" });
|
|
354
|
-
}
|
|
355
|
-
static get observedAttributes() {
|
|
356
|
-
return ["preenchimento", "traco", "opacidade", "alvo", "padrao-preenchimento", "padrao-traco", "desabilitado"];
|
|
357
|
-
}
|
|
358
|
-
connectedCallback() {
|
|
359
|
-
this.renderizado || this.renderizar(), this.listeners.cleanup(), this.vincularEventos(), this.atualizar();
|
|
360
|
-
}
|
|
361
|
-
disconnectedCallback() {
|
|
362
|
-
this.fecharSeletor(!0), this.listeners.cleanup();
|
|
363
|
-
}
|
|
364
|
-
attributeChangedCallback(e, t, a) {
|
|
365
|
-
if (t !== a) {
|
|
366
|
-
if (e === "desabilitado") {
|
|
367
|
-
this.hasAttribute("desabilitado") && this.fecharSeletor(!1), this.atualizar();
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
if (a !== null) {
|
|
371
|
-
if (e === "preenchimento") this.definirCores({ preenchimento: a });
|
|
372
|
-
else if (e === "traco") this.definirCores({ traco: a });
|
|
373
|
-
else if (e === "opacidade") this.definirCores({ opacidade: Number(a) });
|
|
374
|
-
else if (e === "alvo") this.definirAlvo(a);
|
|
375
|
-
else if (e === "padrao-preenchimento" || e === "padrao-traco") {
|
|
376
|
-
const i = k(a);
|
|
377
|
-
if (!i) return;
|
|
378
|
-
e === "padrao-preenchimento" ? this._padrao.preenchimento = i : this._padrao.traco = i, this.atualizar();
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
/* ---------- Propriedades ---------- */
|
|
384
|
-
get preenchimento() {
|
|
385
|
-
return this._preenchimento;
|
|
386
|
-
}
|
|
387
|
-
set preenchimento(e) {
|
|
388
|
-
this.definirCores({ preenchimento: e });
|
|
389
|
-
}
|
|
390
|
-
get traco() {
|
|
391
|
-
return this._traco;
|
|
392
|
-
}
|
|
393
|
-
set traco(e) {
|
|
394
|
-
this.definirCores({ traco: e });
|
|
395
|
-
}
|
|
396
|
-
get opacidade() {
|
|
397
|
-
return this._opacidade;
|
|
398
|
-
}
|
|
399
|
-
set opacidade(e) {
|
|
400
|
-
this.definirCores({ opacidade: e });
|
|
401
|
-
}
|
|
402
|
-
get alvo() {
|
|
403
|
-
return this._alvo;
|
|
404
|
-
}
|
|
405
|
-
set alvo(e) {
|
|
406
|
-
this.definirAlvo(e);
|
|
407
|
-
}
|
|
408
|
-
/** Cores oferecidas em "Cores do projeto" no seletor. */
|
|
409
|
-
get coresProjeto() {
|
|
410
|
-
return [...this._coresProjeto];
|
|
411
|
-
}
|
|
412
|
-
set coresProjeto(e) {
|
|
413
|
-
this._coresProjeto = C(e);
|
|
414
|
-
}
|
|
415
|
-
/** Teclas exibidas nas dicas dos botões (ex.: `{ inverter: 'Shift+X' }`). */
|
|
416
|
-
get atalhos() {
|
|
417
|
-
return { ...this._atalhos };
|
|
418
|
-
}
|
|
419
|
-
set atalhos(e) {
|
|
420
|
-
this._atalhos = { ...e || {} }, this.atualizar();
|
|
421
|
-
}
|
|
422
|
-
get seletorAberto() {
|
|
423
|
-
var e;
|
|
424
|
-
return !!((e = this.seletor) != null && e.aberto);
|
|
425
|
-
}
|
|
426
|
-
/* ---------- Métodos (sem eventos) ---------- */
|
|
427
|
-
/** Define cores e/ou opacidade sem emitir eventos. Valores inválidos são ignorados; uma cor definida deixa de ser "mista". */
|
|
428
|
-
definirCores(e = {}) {
|
|
429
|
-
const t = k(e.preenchimento), a = k(e.traco);
|
|
430
|
-
t && (this._preenchimento = t, this._misto.preenchimento = !1), a && (this._traco = a, this._misto.traco = !1), e.opacidade !== void 0 && (this._opacidade = z(e.opacidade, this._opacidade)), this.atualizar();
|
|
431
|
-
}
|
|
432
|
-
obterCores() {
|
|
433
|
-
return { preenchimento: this._preenchimento, traco: this._traco, opacidade: this._opacidade, alvo: this._alvo };
|
|
434
|
-
}
|
|
435
|
-
/** Marca a amostra como ativa sem emitir eventos. */
|
|
436
|
-
definirAlvo(e) {
|
|
437
|
-
this._alvo = e === "traco" ? "traco" : "preenchimento", this.atualizar(), this.sincronizarSeletor();
|
|
438
|
-
}
|
|
439
|
-
/** Mostra "?" nas amostras cujas cores divergem na seleção atual. */
|
|
440
|
-
definirMisto(e = {}) {
|
|
441
|
-
this._misto = { preenchimento: !!e.preenchimento, traco: !!e.traco }, this.atualizar();
|
|
442
|
-
}
|
|
443
|
-
/* ---------- Ações (emitem eventos) ---------- */
|
|
444
|
-
/** Alterna o alvo ativo entre preenchimento e traço; emite `ui-alvo-change`. */
|
|
445
|
-
alternarAlvo() {
|
|
446
|
-
this.mudarAlvo(this._alvo === "traco" ? "preenchimento" : "traco");
|
|
447
|
-
}
|
|
448
|
-
/** Troca preenchimento e traço; emite `ui-cores-change` confirmado. */
|
|
449
|
-
inverter() {
|
|
450
|
-
const e = this._preenchimento;
|
|
451
|
-
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");
|
|
452
|
-
}
|
|
453
|
-
/** "Sem cor" no alvo indicado (padrão: o ativo); emite `ui-cores-change` confirmado. */
|
|
454
|
-
semCor(e = this._alvo) {
|
|
455
|
-
const t = e === "traco" ? "traco" : "preenchimento";
|
|
456
|
-
t === "traco" ? this._traco = "none" : this._preenchimento = "none", this._misto[t] = !1, this.atualizar(), this.emitirCores(!0, [t], "sem-cor");
|
|
457
|
-
}
|
|
458
|
-
/** Volta às cores de `padrao-preenchimento` e `padrao-traco`; emite `ui-cores-change` confirmado. */
|
|
459
|
-
restaurarPadrao() {
|
|
460
|
-
this._preenchimento = this._padrao.preenchimento, this._traco = this._padrao.traco, this._misto = { preenchimento: !1, traco: !1 }, this.atualizar(), this.emitirCores(!0, ["preenchimento", "traco"], "padrao");
|
|
461
|
-
}
|
|
462
|
-
/** Abre o seletor de cor ancorado na amostra do alvo (que passa a ser o ativo). Com `focar`, leva o foco do teclado para o painel. */
|
|
463
|
-
abrirSeletor(e = this._alvo, t = !1) {
|
|
464
|
-
if (this.hasAttribute("desabilitado") || (this.mudarAlvo(e === "traco" ? "traco" : "preenchimento"), this.seletorAberto)) return;
|
|
465
|
-
const a = this.raiz.querySelector(`[data-alvo="${this._alvo}"]`) || this;
|
|
466
|
-
this.estadoAoAbrir = this.obterCores(), this.seletor = T({
|
|
467
|
-
ancora: a,
|
|
468
|
-
titulo: this.getAttribute("titulo-seletor") || "Cores e estilo",
|
|
469
|
-
modo: "duplo",
|
|
470
|
-
alvo: this._alvo,
|
|
471
|
-
preenchimento: this._preenchimento,
|
|
472
|
-
traco: this._traco,
|
|
473
|
-
opacidade: this._opacidade,
|
|
474
|
-
misto: this._misto[this._alvo],
|
|
475
|
-
coresProjeto: this._coresProjeto,
|
|
476
|
-
focar: t,
|
|
477
|
-
aoAlterar: (i) => this.aplicarDoSeletor(i, !1),
|
|
478
|
-
aoConfirmar: (i) => {
|
|
479
|
-
this.seletor = null, this.aplicarDoSeletor(i, !0);
|
|
480
|
-
},
|
|
481
|
-
aoCancelar: () => {
|
|
482
|
-
this.seletor = null, this.estadoAoAbrir = null;
|
|
483
|
-
},
|
|
484
|
-
aoTrocarAlvo: (i) => this.mudarAlvo(i)
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Fecha o seletor aberto por este controle. Com `confirmar` (padrão), grava o que foi editado;
|
|
489
|
-
* sem ele, cancela: as cores iniciais voltam (com um `ui-cores-change` não confirmado) e nada é confirmado.
|
|
490
|
-
*/
|
|
491
|
-
fecharSeletor(e = !0) {
|
|
492
|
-
const t = this.seletor;
|
|
493
|
-
t && (e ? t.fechar(!0) : t.elemento.cancelar());
|
|
494
|
-
}
|
|
495
|
-
/* ---------- Interno ---------- */
|
|
496
|
-
mudarAlvo(e) {
|
|
497
|
-
e !== this._alvo && (this._alvo = e, this.atualizar(), this.sincronizarSeletor(), this.dispatchEvent(new CustomEvent("ui-alvo-change", { detail: { alvo: e }, bubbles: !0, composed: !0 })));
|
|
498
|
-
}
|
|
499
|
-
/** Mantém a aba do seletor aberto igual ao alvo do controle. */
|
|
500
|
-
sincronizarSeletor() {
|
|
501
|
-
var e, t;
|
|
502
|
-
(t = (e = this.seletor) == null ? void 0 : e.elemento) == null || t.trocarAlvo(this._alvo);
|
|
503
|
-
}
|
|
504
|
-
aplicarDoSeletor(e, t) {
|
|
505
|
-
const a = (s) => {
|
|
506
|
-
const n = [];
|
|
507
|
-
return e.preenchimento !== s.preenchimento && n.push("preenchimento"), e.traco !== s.traco && n.push("traco"), e.opacidade !== s.opacidade && n.push("opacidade"), n;
|
|
508
|
-
}, i = a(this.obterCores());
|
|
509
|
-
if (this._preenchimento = e.preenchimento, this._traco = e.traco, this._opacidade = e.opacidade, i.includes("preenchimento") && (this._misto.preenchimento = !1), i.includes("traco") && (this._misto.traco = !1), this.atualizar(), !t) {
|
|
510
|
-
i.length && this.emitirCores(!1, i, "seletor");
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
this.emitirCores(!0, this.estadoAoAbrir ? a(this.estadoAoAbrir) : i, "seletor"), this.estadoAoAbrir = null;
|
|
514
|
-
}
|
|
515
|
-
emitirCores(e, t, a) {
|
|
516
|
-
const i = { ...this.obterCores(), confirmado: e, alterados: t, origem: a };
|
|
517
|
-
this.dispatchEvent(new CustomEvent("ui-cores-change", { detail: i, bubbles: !0, composed: !0 }));
|
|
518
|
-
}
|
|
519
|
-
dica(e, t) {
|
|
520
|
-
return t ? `${e} [${t}]` : e;
|
|
521
|
-
}
|
|
522
|
-
renderizar() {
|
|
523
|
-
this.raiz.innerHTML = `
|
|
524
|
-
<style>${B}</style>
|
|
525
|
-
<div class="pilha" part="pilha" role="group" aria-label="Cores de desenho">
|
|
526
|
-
<div class="amostras" part="amostras">
|
|
527
|
-
<button type="button" class="amostra amostra--traco" data-alvo="traco" part="amostra amostra-traco">
|
|
528
|
-
<span class="face face--traco"></span>
|
|
529
|
-
</button>
|
|
530
|
-
<button type="button" class="amostra amostra--preenchimento" data-alvo="preenchimento" part="amostra amostra-preenchimento">
|
|
531
|
-
<span class="face face--preenchimento"></span>
|
|
532
|
-
</button>
|
|
533
|
-
</div>
|
|
534
|
-
<div class="acoes" part="acoes">
|
|
535
|
-
<button type="button" class="acao acao--inverter" data-acao="inverter" part="acao acao-inverter" aria-label="Inverter preenchimento e traço">
|
|
536
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
537
|
-
<path d="m16 3 4 4-4 4"/><path d="M20 7H4"/><path d="m8 21-4-4 4-4"/><path d="M4 17h16"/>
|
|
538
|
-
</svg>
|
|
539
|
-
</button>
|
|
540
|
-
<button type="button" class="acao acao--sem-cor" data-acao="sem-cor" part="acao acao-sem-cor" aria-label="Sem cor">
|
|
541
|
-
<svg viewBox="0 0 24 24" fill="none" stroke-width="2.4" stroke-linecap="round" aria-hidden="true">
|
|
542
|
-
<circle cx="12" cy="12" r="8" stroke="currentColor"/>
|
|
543
|
-
<line x1="6.5" y1="6.5" x2="17.5" y2="17.5" stroke="#ef4444"/>
|
|
544
|
-
</svg>
|
|
545
|
-
</button>
|
|
546
|
-
<button type="button" class="acao acao--padrao" data-acao="padrao" part="acao acao-padrao" aria-label="Restaurar cores padrão">
|
|
547
|
-
<span class="icone-padrao" aria-hidden="true">
|
|
548
|
-
<span class="ponto ponto--preenchimento"></span>
|
|
549
|
-
<span class="ponto ponto--traco"></span>
|
|
550
|
-
</span>
|
|
551
|
-
</button>
|
|
552
|
-
</div>
|
|
553
|
-
</div>
|
|
554
|
-
`, this.renderizado = !0;
|
|
555
|
-
}
|
|
556
|
-
vincularEventos() {
|
|
557
|
-
const e = this.raiz;
|
|
558
|
-
e.querySelectorAll("[data-alvo]").forEach((a) => {
|
|
559
|
-
const i = a.dataset.alvo;
|
|
560
|
-
this.listeners.add(a, "click", (s) => {
|
|
561
|
-
s.stopPropagation(), i !== this._alvo ? this.mudarAlvo(i) : this.seletorAberto ? this.fecharSeletor(!0) : this.abrirSeletor(i);
|
|
562
|
-
}), this.listeners.add(a, "dblclick", (s) => {
|
|
563
|
-
s.stopPropagation(), this.abrirSeletor(i);
|
|
564
|
-
}), this.listeners.add(a, "keydown", (s) => {
|
|
565
|
-
s.key !== "Enter" && s.key !== " " || (s.preventDefault(), i === this._alvo && this.seletorAberto ? this.fecharSeletor(!0) : this.abrirSeletor(i, !0));
|
|
566
|
-
}), this.listeners.add(a, "keyup", (s) => {
|
|
567
|
-
s.key === " " && s.preventDefault();
|
|
568
|
-
});
|
|
569
|
-
});
|
|
570
|
-
const t = (a, i) => {
|
|
571
|
-
this.listeners.add(e.querySelector(`[data-acao="${a}"]`), "click", (s) => {
|
|
572
|
-
s.stopPropagation(), i();
|
|
573
|
-
});
|
|
574
|
-
};
|
|
575
|
-
t("inverter", () => this.inverter()), t("sem-cor", () => this.semCor()), t("padrao", () => this.restaurarPadrao());
|
|
576
|
-
}
|
|
577
|
-
atualizar() {
|
|
578
|
-
if (!this.renderizado) return;
|
|
579
|
-
const e = this.raiz, t = this._atalhos, a = this.hasAttribute("desabilitado"), i = (f, p) => p ? "Misto (?) [várias cores na seleção]" : f === "none" ? "Sem cor" : f, s = (f, p, r, g, v = "") => {
|
|
580
|
-
const h = e.querySelector(`[data-alvo="${f}"]`), w = h == null ? void 0 : h.querySelector(".face");
|
|
581
|
-
if (!h || !w) return;
|
|
582
|
-
const _ = this._alvo === f;
|
|
583
|
-
h.classList.toggle("amostra--ativa", _), h.setAttribute("aria-pressed", String(_)), h.disabled = a, w.classList.toggle("face--misto", r), w.classList.toggle("face--sem-cor", !r && p === "none");
|
|
584
|
-
const d = f === "traco" ? "borderColor" : "backgroundColor";
|
|
585
|
-
w.style[d] = r || p === "none" ? "" : p;
|
|
586
|
-
const b = `${g}: ${i(p, r)}${v}`;
|
|
587
|
-
h.title = this.dica(`${b} — clique para ativar, clique de novo para editar`, t.alternar), h.setAttribute("aria-label", b);
|
|
588
|
-
}, n = this._preenchimento === "none" || this._misto.preenchimento ? "" : `, opacidade ${Math.round(this._opacidade * 100)}%`;
|
|
589
|
-
s("preenchimento", this._preenchimento, this._misto.preenchimento, "Preenchimento", n), s("traco", this._traco, this._misto.traco, "Traço / contorno");
|
|
590
|
-
const m = (f, p) => {
|
|
591
|
-
const r = e.querySelector(`[data-acao="${f}"]`);
|
|
592
|
-
r && (r.title = p, r.disabled = a);
|
|
593
|
-
};
|
|
594
|
-
m("inverter", this.dica("Inverter preenchimento e traço", t.inverter)), m("sem-cor", this.dica("Sem cor no alvo ativo", t.semCor)), m("padrao", this.dica("Restaurar cores padrão", t.padrao));
|
|
595
|
-
const u = e.querySelector(".ponto--preenchimento");
|
|
596
|
-
u && (u.style.backgroundColor = this._padrao.preenchimento === "none" ? "transparent" : this._padrao.preenchimento);
|
|
597
|
-
const x = e.querySelector(".ponto--traco");
|
|
598
|
-
x && (x.style.borderColor = this._padrao.traco === "none" ? "#ef4444" : this._padrao.traco);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
$("ui-controle-cores", H);
|
|
602
|
-
export {
|
|
603
|
-
S as P,
|
|
604
|
-
H as U,
|
|
605
|
-
N as a,
|
|
606
|
-
T as b,
|
|
607
|
-
C as c,
|
|
608
|
-
z as d,
|
|
609
|
-
L as e,
|
|
610
|
-
F as f,
|
|
611
|
-
k as n
|
|
612
|
-
};
|