@thibezer/ui-components-kit 2.12.0 → 2.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -84
- package/dist/camadas.cjs +85 -107
- package/dist/camadas.js +445 -519
- package/dist/components/ui-camadas/camadas-rodape.d.ts +5 -0
- package/dist/components/ui-texto-editavel/index.d.ts +2 -0
- package/dist/components/ui-texto-editavel/texto-editavel-teclado.d.ts +12 -0
- package/dist/components/ui-texto-editavel/texto-editavel-template.d.ts +2 -0
- package/dist/components/ui-texto-editavel/tipos.d.ts +14 -0
- package/dist/components/ui-texto-editavel/ui-texto-editavel.d.ts +82 -0
- package/dist/custom-elements.json +13975 -13202
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +194 -192
- package/dist/register.cjs +1 -1
- package/dist/register.js +1 -1
- package/dist/tipos-elementos.d.ts +26 -0
- package/dist/tipos-react.d.ts +2 -0
- package/dist/tipos-vue.d.ts +25 -0
- package/dist/ui-linha-BxhEBn27.js +749 -0
- package/dist/ui-linha-CcalUBDw.cjs +38 -0
- package/package.json +1 -1
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var S = (o, a, t) => a in o ? k(o, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[a] = t;
|
|
3
|
+
var l = (o, a, t) => S(o, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import { d as p, S as x } from "./ssr-safe-5cWfJP-s.js";
|
|
5
|
+
import { e as b, a as v, b as z } from "./opcoes-CupvWVIm.js";
|
|
6
|
+
import { F as A } from "./ui-campo-texto-19tIrmBK.js";
|
|
7
|
+
import { L as y } from "./listener-bag-DQgv7OON.js";
|
|
8
|
+
import { a as C } from "./parts-CaoQiCfI.js";
|
|
9
|
+
import { b as g, c as I } from "./altura-controle-vxQiXG4q.js";
|
|
10
|
+
const T = ':host{display:block;box-sizing:border-box;margin:0;padding:0;color:var(--ui-cor-texto, #e1e1e6);font-family:var(--ui-fonte-base, "Inter", sans-serif)}:host([inline]){display:inline-block}.ui-texto{margin:0;padding:0;box-sizing:border-box;font-family:inherit;color:inherit;font-size:inherit;font-weight:inherit;line-height:inherit;overflow-wrap:break-word}.ui-texto--h1{font-size:var(--ui-tamanho-h1, clamp(24px, 4vw, 36px));font-weight:var(--ui-peso-negrito, 700);line-height:var(--ui-altura-linha-titulo, 1.25);letter-spacing:-.5px}.ui-texto--h2{font-size:var(--ui-tamanho-h2, clamp(20px, 3vw, 28px));font-weight:var(--ui-peso-seminegrito, 600);line-height:var(--ui-altura-linha-titulo, 1.25);letter-spacing:-.3px}.ui-texto--h3{font-size:var(--ui-tamanho-h3, clamp(18px, 2.4vw, 24px));font-weight:var(--ui-peso-seminegrito, 600);line-height:var(--ui-altura-linha-titulo, 1.25)}.ui-texto--h4{font-size:var(--ui-tamanho-h4, clamp(16px, 2vw, 20px));font-weight:var(--ui-peso-medio, 500);line-height:var(--ui-altura-linha-titulo, 1.25)}.ui-texto--h5{font-size:var(--ui-tamanho-h5, clamp(14px, 1.6vw, 18px));font-weight:var(--ui-peso-medio, 500);line-height:var(--ui-altura-linha-titulo, 1.25)}.ui-texto--h6{font-size:var(--ui-tamanho-h6, clamp(13px, 1.2vw, 16px));font-weight:var(--ui-peso-seminegrito, 600);line-height:var(--ui-altura-linha-titulo, 1.25);text-transform:uppercase;letter-spacing:.5px}.ui-texto--corpo{font-size:var(--ui-tamanho-corpo, 14px);font-weight:var(--ui-peso-normal, 400);line-height:var(--ui-altura-linha-corpo, 1.5)}.ui-texto--corpo-sm{font-size:var(--ui-tamanho-corpo-sm, 13px);font-weight:var(--ui-peso-normal, 400);line-height:var(--ui-altura-linha-corpo, 1.5)}.ui-texto--caption{font-size:var(--ui-tamanho-caption, 11px);font-weight:var(--ui-peso-normal, 400);line-height:var(--ui-altura-linha-compacta, 1.2);color:var(--ui-cor-texto-secundario, #888899)}.ui-texto--codigo{font-family:var(--ui-fonte-codigo, monospace);font-size:var(--ui-tamanho-codigo, 12px);font-weight:var(--ui-peso-normal, 400);line-height:var(--ui-altura-linha-corpo, 1.5);background:var(--ui-cor-fundo-elevado, #1a1a1e);padding:2px 6px;border-radius:var(--ui-raio-sm, 4px);border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .12))}.ui-texto--cor-primaria{color:var(--ui-cor-primaria, #00E08A)}.ui-texto--cor-secundaria{color:var(--ui-cor-texto-secundario, #888899)}.ui-texto--cor-destaque{color:var(--ui-cor-destaque, #00E08A)}.ui-texto--cor-erro{color:var(--ui-cor-texto-erro, #ff5555)}.ui-texto--cor-sucesso{color:var(--ui-cor-texto-sucesso, #00E08A)}.ui-texto--cor-alerta{color:var(--ui-cor-texto-alerta, #ffb86c)}.ui-texto--peso-normal{font-weight:var(--ui-peso-normal, 400)!important}.ui-texto--peso-medio{font-weight:var(--ui-peso-medio, 500)!important}.ui-texto--peso-seminegrito{font-weight:var(--ui-peso-seminegrito, 600)!important}.ui-texto--peso-negrito{font-weight:var(--ui-peso-negrito, 700)!important}.ui-texto--alinhamento-esquerda{text-align:left}.ui-texto--alinhamento-centro{text-align:center}.ui-texto--alinhamento-direita{text-align:right}.ui-texto--alinhamento-justificado{text-align:justify;-webkit-hyphens:auto;hyphens:auto}.ui-texto--truncar{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block}.ui-texto--linhas{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:var(--ui-texto-linhas, 3);line-clamp:var(--ui-texto-linhas, 3);overflow:hidden}@media print{.ui-texto--linhas{-webkit-line-clamp:unset;line-clamp:unset;display:block;overflow:visible}}', f = ["h1", "h2", "h3", "h4", "h5", "h6", "corpo", "corpo-sm", "caption", "codigo"], q = ["primaria", "secundaria", "destaque", "erro", "sucesso", "alerta"], O = ["normal", "medio", "seminegrito", "negrito"], L = ["esquerda", "centro", "direita", "justificado"], N = /* @__PURE__ */ new Set([
|
|
11
|
+
"p",
|
|
12
|
+
"span",
|
|
13
|
+
"div",
|
|
14
|
+
"h1",
|
|
15
|
+
"h2",
|
|
16
|
+
"h3",
|
|
17
|
+
"h4",
|
|
18
|
+
"h5",
|
|
19
|
+
"h6",
|
|
20
|
+
"small",
|
|
21
|
+
"code",
|
|
22
|
+
"strong",
|
|
23
|
+
"em",
|
|
24
|
+
"label",
|
|
25
|
+
"blockquote",
|
|
26
|
+
"pre",
|
|
27
|
+
"b",
|
|
28
|
+
"i"
|
|
29
|
+
]), M = 50;
|
|
30
|
+
class D extends x {
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
l(this, "container", null);
|
|
34
|
+
l(this, "shadow", null);
|
|
35
|
+
if (typeof this.attachShadow == "function" && typeof document < "u") {
|
|
36
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
37
|
+
const t = document.createElement("p");
|
|
38
|
+
t.className = "ui-texto ui-texto--corpo", t.setAttribute("part", "base"), t.appendChild(document.createElement("slot")), this.container = t, this.shadow.innerHTML = `<style>${T}</style>`, this.shadow.appendChild(t);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
static get observedAttributes() {
|
|
42
|
+
return ["variante", "tag", "cor", "peso", "alinhamento", "truncar", "linhas"];
|
|
43
|
+
}
|
|
44
|
+
connectedCallback() {
|
|
45
|
+
this.render();
|
|
46
|
+
}
|
|
47
|
+
attributeChangedCallback(t, i, e) {
|
|
48
|
+
this.render();
|
|
49
|
+
}
|
|
50
|
+
resolveTag() {
|
|
51
|
+
const t = this.getAttribute("tag");
|
|
52
|
+
if (t) {
|
|
53
|
+
const e = t.toLowerCase().trim();
|
|
54
|
+
if (N.has(e))
|
|
55
|
+
return e;
|
|
56
|
+
console.warn(`[ui-texto] Tag "${t}" não permitida ou inválida. Utilizando fallback semântico.`);
|
|
57
|
+
}
|
|
58
|
+
const i = b(this.getAttribute("variante"), f, "corpo");
|
|
59
|
+
switch (i) {
|
|
60
|
+
case "h1":
|
|
61
|
+
case "h2":
|
|
62
|
+
case "h3":
|
|
63
|
+
case "h4":
|
|
64
|
+
case "h5":
|
|
65
|
+
case "h6":
|
|
66
|
+
return i;
|
|
67
|
+
case "caption":
|
|
68
|
+
return "small";
|
|
69
|
+
case "codigo":
|
|
70
|
+
return "code";
|
|
71
|
+
case "corpo-sm":
|
|
72
|
+
case "corpo":
|
|
73
|
+
default:
|
|
74
|
+
return "p";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
const { container: t, shadow: i } = this;
|
|
79
|
+
if (!t || !i) return;
|
|
80
|
+
const e = this.resolveTag(), r = b(this.getAttribute("variante"), f, "corpo"), s = v(this.getAttribute("cor"), q), n = v(this.getAttribute("peso"), O), u = v(this.getAttribute("alinhamento"), L), d = this.hasAttribute("truncar"), h = d ? 0 : z(this.getAttribute("linhas"), 1, M, 0);
|
|
81
|
+
let c = t;
|
|
82
|
+
t.tagName.toLowerCase() !== e && (c = document.createElement(e), c.setAttribute("part", "base"), c.appendChild(document.createElement("slot")), i.replaceChild(c, t), this.container = c);
|
|
83
|
+
const m = ["ui-texto", `ui-texto--${r}`];
|
|
84
|
+
s && m.push(`ui-texto--cor-${s}`), n && m.push(`ui-texto--peso-${n}`), u && m.push(`ui-texto--alinhamento-${u}`), d && m.push("ui-texto--truncar"), h > 0 && m.push("ui-texto--linhas"), c.className = m.join(" "), h > 0 ? c.style.setProperty("--ui-texto-linhas", String(h)) : c.style.removeProperty("--ui-texto-linhas");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
p("ui-texto", D);
|
|
88
|
+
const j = ':host{display:inline-block;box-sizing:border-box;vertical-align:middle}:host([largura-total]),:host([full-width]){display:block;width:100%}.ui-texto-editavel{position:relative;display:inline-flex;align-items:center;box-sizing:border-box;width:100%}.ui-texto-editavel__botao{display:inline-flex;align-items:center;justify-content:flex-start;gap:var(--ui-espaco-xs, 4px);width:100%;height:var(--ui-campo-altura, 34px);min-height:var(--ui-campo-altura, 34px);box-sizing:border-box;padding:0 12px;border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .12));border-radius:var(--ui-raio-borda, 6px);background:var(--ui-cor-botao-secundario-fundo, #1e1e24);color:var(--ui-cor-texto, #e1e1e6);font-family:var(--ui-fonte-base, "Inter", sans-serif);font-size:clamp(11px,.85rem,13px);font-weight:500;line-height:1.2;text-align:left;-webkit-user-select:none;user-select:none;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background-color .15s ease,border-color .15s ease,color .15s ease,box-shadow .15s ease}.ui-texto-editavel__botao:hover:not(:disabled){background:var(--ui-cor-botao-secundario-hover, #2a2a34);border-color:color-mix(in srgb,var(--ui-cor-texto, #e1e1e6) 24%,transparent)}.ui-texto-editavel__botao:focus-visible{outline:none;box-shadow:0 0 0 2px var(--ui-cor-fundo, #0b0b0d),0 0 0 4px var(--ui-cor-primaria, #00E08A)}.ui-texto-editavel__texto{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.ui-texto-editavel__texto--placeholder{color:var(--ui-cor-texto-silenciado, rgba(255, 255, 255, .45));font-style:italic}.ui-texto-editavel__input{display:inline-block;width:100%;height:var(--ui-campo-altura, 34px);min-height:var(--ui-campo-altura, 34px);box-sizing:border-box;padding:0 11px;border:1px solid var(--ui-cor-primaria, #00E08A);border-radius:var(--ui-raio-borda, 6px);background:var(--ui-cor-campo-fundo, #121217);color:var(--ui-cor-texto, #ffffff);font-family:var(--ui-fonte-base, "Inter", sans-serif);font-size:clamp(11px,.85rem,13px);font-weight:500;line-height:1.2;outline:none;box-shadow:0 0 0 1px var(--ui-cor-primaria, #00E08A),0 0 0 3px color-mix(in srgb,var(--ui-cor-primaria, #00E08A) 25%,transparent);transition:border-color .15s ease,box-shadow .15s ease}.ui-texto-editavel__input::selection{background:var(--ui-cor-primaria, #00E08A);color:#000}.ui-texto-editavel[data-modo=leitura] .ui-texto-editavel__input,.ui-texto-editavel[data-modo=edicao] .ui-texto-editavel__botao{display:none!important}.ui-texto-editavel--sm .ui-texto-editavel__botao,.ui-texto-editavel--sm .ui-texto-editavel__input{height:var(--ui-campo-altura-sm, 28px);min-height:var(--ui-campo-altura-sm, 28px);font-size:11px;padding-left:8px;padding-right:8px}.ui-texto-editavel--lg .ui-texto-editavel__botao,.ui-texto-editavel--lg .ui-texto-editavel__input{height:var(--ui-campo-altura-lg, 42px);min-height:var(--ui-campo-altura-lg, 42px);font-size:15px;padding-left:14px;padding-right:14px}.ui-texto-editavel--primario .ui-texto-editavel__botao,.ui-texto-editavel--primary .ui-texto-editavel__botao{background:var(--ui-cor-primaria, #00E08A);color:var(--ui-cor-texto-sobre-primaria, #000000);border-color:transparent;font-weight:600}.ui-texto-editavel--primario .ui-texto-editavel__botao:hover:not(:disabled),.ui-texto-editavel--primary .ui-texto-editavel__botao:hover:not(:disabled){filter:brightness(1.1)}.ui-texto-editavel--ghost .ui-texto-editavel__botao,.ui-texto-editavel--terciario .ui-texto-editavel__botao{background:transparent;color:var(--ui-cor-texto, #e1e1e6);border-color:transparent}.ui-texto-editavel--ghost .ui-texto-editavel__botao:hover:not(:disabled),.ui-texto-editavel--terciario .ui-texto-editavel__botao:hover:not(:disabled){background:var(--ui-cor-hover-menu, rgba(255, 255, 255, .08))}.ui-texto-editavel--outline .ui-texto-editavel__botao,.ui-texto-editavel--borda .ui-texto-editavel__botao{background:transparent;color:var(--ui-cor-texto, #e1e1e6);border-color:var(--ui-cor-borda, rgba(255, 255, 255, .2))}.ui-texto-editavel--outline .ui-texto-editavel__botao:hover:not(:disabled),.ui-texto-editavel--borda .ui-texto-editavel__botao:hover:not(:disabled){background:var(--ui-cor-hover-menu, rgba(255, 255, 255, .06));border-color:var(--ui-cor-primaria, #00E08A)}.ui-texto-editavel--texto .ui-texto-editavel__botao,.ui-texto-editavel--plano .ui-texto-editavel__botao{background:transparent;border-color:transparent;padding:0 4px;height:auto;min-height:unset;border-radius:4px}.ui-texto-editavel--texto .ui-texto-editavel__botao:hover:not(:disabled),.ui-texto-editavel--plano .ui-texto-editavel__botao:hover:not(:disabled){background:var(--ui-cor-hover-menu, rgba(255, 255, 255, .06));border-color:color-mix(in srgb,var(--ui-cor-borda, #ffffff) 15%,transparent)}.ui-texto-editavel--destaque .ui-texto-editavel__botao{background:var(--ui-cor-destaque, var(--ui-cor-primaria, #00E08A));color:var(--ui-cor-texto-sobre-primaria, #000000);border-color:transparent}.ui-texto-editavel--destrutivo .ui-texto-editavel__botao{background:var(--ui-cor-botao-destrutivo-fundo, #ff4444);color:var(--ui-cor-botao-destrutivo-texto, #ffffff);border-color:transparent}:host([disabled]){pointer-events:none;opacity:.55;cursor:not-allowed}.ui-texto-editavel__botao:disabled{cursor:not-allowed;opacity:.55}:host([readonly]) .ui-texto-editavel__botao,:host([somente-leitura]) .ui-texto-editavel__botao{cursor:default}', V = [
|
|
89
|
+
"valor",
|
|
90
|
+
"value",
|
|
91
|
+
"placeholder",
|
|
92
|
+
"variante",
|
|
93
|
+
"tamanho",
|
|
94
|
+
"disabled",
|
|
95
|
+
"desabilitado",
|
|
96
|
+
"readonly",
|
|
97
|
+
"somente-leitura",
|
|
98
|
+
"ao-perder-foco",
|
|
99
|
+
"obrigatorio",
|
|
100
|
+
"maxlength",
|
|
101
|
+
"limite-caracteres",
|
|
102
|
+
"name",
|
|
103
|
+
"nome"
|
|
104
|
+
];
|
|
105
|
+
function $(o) {
|
|
106
|
+
return `
|
|
107
|
+
<style>${o}</style>
|
|
108
|
+
<div class="ui-texto-editavel ui-texto-editavel--secundario" data-modo="leitura" part="base">
|
|
109
|
+
<button
|
|
110
|
+
class="ui-texto-editavel__botao"
|
|
111
|
+
part="botao"
|
|
112
|
+
type="button"
|
|
113
|
+
aria-description="Pressione Enter ou clique duas vezes para editar"
|
|
114
|
+
>
|
|
115
|
+
<span class="ui-texto-editavel__texto" part="texto"></span>
|
|
116
|
+
</button>
|
|
117
|
+
<input
|
|
118
|
+
class="ui-texto-editavel__input"
|
|
119
|
+
part="input"
|
|
120
|
+
type="text"
|
|
121
|
+
autocomplete="off"
|
|
122
|
+
spellcheck="false"
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
`;
|
|
126
|
+
}
|
|
127
|
+
function F(o, a) {
|
|
128
|
+
(o.key === "Enter" || o.key === "F2") && (o.preventDefault(), o.stopPropagation(), a());
|
|
129
|
+
}
|
|
130
|
+
function P(o, a, t) {
|
|
131
|
+
o.key === "Enter" ? (o.preventDefault(), o.stopPropagation(), a()) : o.key === "Escape" ? (o.preventDefault(), o.stopPropagation(), t()) : o.key === "Tab" && a();
|
|
132
|
+
}
|
|
133
|
+
class E extends A {
|
|
134
|
+
constructor() {
|
|
135
|
+
super();
|
|
136
|
+
l(this, "container");
|
|
137
|
+
l(this, "botaoElement");
|
|
138
|
+
l(this, "textoElement");
|
|
139
|
+
l(this, "inputElement");
|
|
140
|
+
l(this, "_modo", "leitura");
|
|
141
|
+
l(this, "_concluindo", !1);
|
|
142
|
+
l(this, "_valorInterno", "");
|
|
143
|
+
l(this, "_valorOriginalAoEditar", "");
|
|
144
|
+
l(this, "listeners", new y());
|
|
145
|
+
// === Handlers de Eventos ===
|
|
146
|
+
l(this, "handleDuploClique", (t) => {
|
|
147
|
+
t.stopPropagation(), !(this.disabled || this.readOnly) && this.editar();
|
|
148
|
+
});
|
|
149
|
+
l(this, "handleKeyDownBotao", (t) => {
|
|
150
|
+
this.disabled || this.readOnly || F(t, () => this.editar());
|
|
151
|
+
});
|
|
152
|
+
l(this, "handleKeyDownInput", (t) => {
|
|
153
|
+
P(
|
|
154
|
+
t,
|
|
155
|
+
() => this.salvar(),
|
|
156
|
+
() => this.cancelar()
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
l(this, "handleBlurInput", () => {
|
|
160
|
+
if (this._concluindo || this._modo !== "edicao") return;
|
|
161
|
+
const t = this.aoPerderFoco;
|
|
162
|
+
t === "cancelar" ? this.cancelar() : t === "salvar" && this.salvar();
|
|
163
|
+
});
|
|
164
|
+
const t = this.attachShadow({ mode: "open", delegatesFocus: !0 });
|
|
165
|
+
t.innerHTML = $(j), this.container = t.querySelector(".ui-texto-editavel"), this.botaoElement = t.querySelector(".ui-texto-editavel__botao"), this.textoElement = t.querySelector(".ui-texto-editavel__texto"), this.inputElement = t.querySelector(".ui-texto-editavel__input"), this._valorInterno = this.getAttribute("valor") ?? this.getAttribute("value") ?? "";
|
|
166
|
+
}
|
|
167
|
+
static get observedAttributes() {
|
|
168
|
+
return V;
|
|
169
|
+
}
|
|
170
|
+
connectedCallback() {
|
|
171
|
+
this.listeners.cleanup(), this.listeners.add(this.botaoElement, "dblclick", this.handleDuploClique), this.listeners.add(this.botaoElement, "keydown", this.handleKeyDownBotao), this.listeners.add(this.inputElement, "keydown", this.handleKeyDownInput), this.listeners.add(this.inputElement, "blur", this.handleBlurInput), this.syncState();
|
|
172
|
+
}
|
|
173
|
+
disconnectedCallback() {
|
|
174
|
+
this.listeners.cleanup();
|
|
175
|
+
}
|
|
176
|
+
attributeChangedCallback(t, i, e) {
|
|
177
|
+
(t === "valor" || t === "value") && e !== null && this._modo === "leitura" && (this._valorInterno = e), this.syncState();
|
|
178
|
+
}
|
|
179
|
+
// === API Pública Programática ===
|
|
180
|
+
/** Entra no modo de edição se o componente não estiver desabilitado ou em somente leitura. */
|
|
181
|
+
editar() {
|
|
182
|
+
this._modo === "edicao" || this.disabled || this.readOnly || (this._modo = "edicao", this._valorOriginalAoEditar = this._valorInterno, this.inputElement.value = this._valorInterno, this.container.setAttribute("data-modo", "edicao"), requestAnimationFrame(() => {
|
|
183
|
+
this.inputElement.focus(), this.inputElement.select();
|
|
184
|
+
}), this.dispararEventoModo());
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Salva as alterações feitas no modo de edição e retorna ao modo leitura.
|
|
188
|
+
* Dispara `ui-salvar` (cancelável com preventDefault()).
|
|
189
|
+
*/
|
|
190
|
+
salvar() {
|
|
191
|
+
if (this._modo !== "edicao" || this._concluindo) return !1;
|
|
192
|
+
this._concluindo = !0;
|
|
193
|
+
const i = this.inputElement.value.trim();
|
|
194
|
+
if (this.obrigatorio && i === "")
|
|
195
|
+
return this._concluindo = !1, this.cancelar(), !1;
|
|
196
|
+
const e = this._valorOriginalAoEditar;
|
|
197
|
+
if (i !== e) {
|
|
198
|
+
const r = new CustomEvent("ui-salvar", {
|
|
199
|
+
bubbles: !0,
|
|
200
|
+
composed: !0,
|
|
201
|
+
cancelable: !0,
|
|
202
|
+
detail: { valor: i, valorAnterior: e }
|
|
203
|
+
});
|
|
204
|
+
if (!this.dispatchEvent(r))
|
|
205
|
+
return this._concluindo = !1, !1;
|
|
206
|
+
this._valorInterno = i, this.setAttribute("valor", i), this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 }));
|
|
207
|
+
}
|
|
208
|
+
return this._modo = "leitura", this.container.setAttribute("data-modo", "leitura"), this.syncState(), requestAnimationFrame(() => {
|
|
209
|
+
this.botaoElement.focus();
|
|
210
|
+
}), this.dispararEventoModo(), this._concluindo = !1, !0;
|
|
211
|
+
}
|
|
212
|
+
/** Cancela as alterações e restaura o valor prévio à edição. */
|
|
213
|
+
cancelar() {
|
|
214
|
+
this._modo !== "edicao" || this._concluindo || (this._concluindo = !0, this.inputElement.value = this._valorOriginalAoEditar, this._modo = "leitura", this.container.setAttribute("data-modo", "leitura"), this.syncState(), this.dispatchEvent(
|
|
215
|
+
new CustomEvent("ui-cancelar", {
|
|
216
|
+
bubbles: !0,
|
|
217
|
+
composed: !0,
|
|
218
|
+
detail: { valor: this._valorInterno }
|
|
219
|
+
})
|
|
220
|
+
), requestAnimationFrame(() => {
|
|
221
|
+
this.botaoElement.focus();
|
|
222
|
+
}), this.dispararEventoModo(), this._concluindo = !1);
|
|
223
|
+
}
|
|
224
|
+
/** Informa se o componente está atualmente no modo de edição. */
|
|
225
|
+
estaEditando() {
|
|
226
|
+
return this._modo === "edicao";
|
|
227
|
+
}
|
|
228
|
+
dispararEventoModo() {
|
|
229
|
+
this.dispatchEvent(
|
|
230
|
+
new CustomEvent("ui-modo-alterado", {
|
|
231
|
+
bubbles: !0,
|
|
232
|
+
composed: !0,
|
|
233
|
+
detail: { modo: this._modo }
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
// === Sincronização do DOM & Form-Associated ===
|
|
238
|
+
syncState() {
|
|
239
|
+
const t = this._valorInterno, i = this.placeholder;
|
|
240
|
+
t.trim() !== "" ? (this.textoElement.textContent = t, this.textoElement.classList.remove("ui-texto-editavel__texto--placeholder")) : (this.textoElement.textContent = i, this.textoElement.classList.add("ui-texto-editavel__texto--placeholder"));
|
|
241
|
+
const e = this.variante, r = this.tamanho;
|
|
242
|
+
this.container.className = `ui-texto-editavel ui-texto-editavel--${e} ui-texto-editavel--${r}`;
|
|
243
|
+
const s = this.disabled;
|
|
244
|
+
this.botaoElement.disabled = s, this.inputElement.disabled = s;
|
|
245
|
+
const n = this.maxlength;
|
|
246
|
+
n !== null && n > 0 ? this.inputElement.maxLength = n : this.inputElement.removeAttribute("maxlength"), this.atualizarValidade();
|
|
247
|
+
}
|
|
248
|
+
atualizarValidade() {
|
|
249
|
+
this.internals && typeof this.internals.setFormValue == "function" && this.internals.setFormValue(this._valorInterno);
|
|
250
|
+
}
|
|
251
|
+
// === Getters e Setters ===
|
|
252
|
+
get valor() {
|
|
253
|
+
return this._valorInterno;
|
|
254
|
+
}
|
|
255
|
+
set valor(t) {
|
|
256
|
+
this._valorInterno = t ?? "", this.setAttribute("valor", this._valorInterno), this.syncState();
|
|
257
|
+
}
|
|
258
|
+
get value() {
|
|
259
|
+
return this.valor;
|
|
260
|
+
}
|
|
261
|
+
set value(t) {
|
|
262
|
+
this.valor = t;
|
|
263
|
+
}
|
|
264
|
+
get placeholder() {
|
|
265
|
+
return this.getAttribute("placeholder") || "Clique duas vezes para editar";
|
|
266
|
+
}
|
|
267
|
+
set placeholder(t) {
|
|
268
|
+
t ? this.setAttribute("placeholder", t) : this.removeAttribute("placeholder"), this.syncState();
|
|
269
|
+
}
|
|
270
|
+
get variante() {
|
|
271
|
+
return this.getAttribute("variante") || "secundario";
|
|
272
|
+
}
|
|
273
|
+
set variante(t) {
|
|
274
|
+
t ? this.setAttribute("variante", t) : this.removeAttribute("variante"), this.syncState();
|
|
275
|
+
}
|
|
276
|
+
get tamanho() {
|
|
277
|
+
return this.getAttribute("tamanho") || "md";
|
|
278
|
+
}
|
|
279
|
+
set tamanho(t) {
|
|
280
|
+
t ? this.setAttribute("tamanho", t) : this.removeAttribute("tamanho"), this.syncState();
|
|
281
|
+
}
|
|
282
|
+
get disabled() {
|
|
283
|
+
return this._formDisabled || this.hasAttribute("disabled") || this.hasAttribute("desabilitado");
|
|
284
|
+
}
|
|
285
|
+
set disabled(t) {
|
|
286
|
+
t ? this.setAttribute("disabled", "") : (this.removeAttribute("disabled"), this.removeAttribute("desabilitado")), this.syncState();
|
|
287
|
+
}
|
|
288
|
+
get readOnly() {
|
|
289
|
+
return this.hasAttribute("readonly") || this.hasAttribute("somente-leitura");
|
|
290
|
+
}
|
|
291
|
+
set readOnly(t) {
|
|
292
|
+
t ? this.setAttribute("readonly", "") : (this.removeAttribute("readonly"), this.removeAttribute("somente-leitura"));
|
|
293
|
+
}
|
|
294
|
+
get obrigatorio() {
|
|
295
|
+
return this.hasAttribute("obrigatorio") || this.hasAttribute("required");
|
|
296
|
+
}
|
|
297
|
+
set obrigatorio(t) {
|
|
298
|
+
t ? this.setAttribute("obrigatorio", "") : (this.removeAttribute("obrigatorio"), this.removeAttribute("required"));
|
|
299
|
+
}
|
|
300
|
+
get aoPerderFoco() {
|
|
301
|
+
const t = this.getAttribute("ao-perder-foco");
|
|
302
|
+
return t === "cancelar" || t === "ignorar" ? t : "salvar";
|
|
303
|
+
}
|
|
304
|
+
set aoPerderFoco(t) {
|
|
305
|
+
this.setAttribute("ao-perder-foco", t);
|
|
306
|
+
}
|
|
307
|
+
get maxlength() {
|
|
308
|
+
const t = this.getAttribute("maxlength") ?? this.getAttribute("limite-caracteres");
|
|
309
|
+
if (!t) return null;
|
|
310
|
+
const i = parseInt(t, 10);
|
|
311
|
+
return isNaN(i) ? null : i;
|
|
312
|
+
}
|
|
313
|
+
set maxlength(t) {
|
|
314
|
+
t !== null && t >= 0 ? this.setAttribute("maxlength", String(t)) : (this.removeAttribute("maxlength"), this.removeAttribute("limite-caracteres")), this.syncState();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
l(E, "formAssociated", !0);
|
|
318
|
+
p("ui-texto-editavel", E);
|
|
319
|
+
const B = ':host{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;font-family:var(--ui-fonte-base, "Inter", sans-serif);vertical-align:middle;position:relative}.ui-avatar{position:relative;display:inline-flex;align-items:center;justify-content:center;width:var(--ui-tamanho-avatar, 36px);height:var(--ui-tamanho-avatar, 36px);min-width:var(--ui-tamanho-avatar, 36px);min-height:var(--ui-tamanho-avatar, 36px);border-radius:50%;background-color:var(--ui-cor-fundo-elevado, #22222a);color:var(--ui-cor-primaria, #00E08A);font-weight:600;font-size:var(--ui-avatar-font-size, 14px);-webkit-user-select:none;user-select:none;box-sizing:border-box;overflow:hidden;border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .12));line-height:1}.ui-avatar__img{width:100%;height:100%;object-fit:cover;display:block}.ui-avatar--quadrado{border-radius:8px}.ui-avatar__status{position:absolute;bottom:0;right:0;width:25%;height:25%;min-width:8px;min-height:8px;max-width:14px;max-height:14px;border-radius:50%;border:2px solid var(--ui-cor-fundo-card, #121214);box-sizing:border-box}.ui-avatar__status--online{background-color:var(--ui-cor-primaria, #00E08A)}.ui-avatar__status--offline{background-color:#889}.ui-avatar__status--ausente{background-color:#ffb86c}.ui-avatar__status--ocupado{background-color:#f55}.ui-avatar--xs{--ui-tamanho-avatar: 20px;--ui-avatar-font-size: 10px}.ui-avatar--sm{--ui-tamanho-avatar: 28px;--ui-avatar-font-size: 11px}.ui-avatar--md{--ui-tamanho-avatar: 36px;--ui-avatar-font-size: 14px}.ui-avatar--lg{--ui-tamanho-avatar: 48px;--ui-avatar-font-size: 18px}.ui-avatar--xl{--ui-tamanho-avatar: 64px;--ui-avatar-font-size: 24px}', _ = ["xs", "sm", "md", "lg", "xl"], H = ["online", "offline", "ausente", "ocupado"], R = 8, U = 512;
|
|
320
|
+
class K extends x {
|
|
321
|
+
constructor() {
|
|
322
|
+
super();
|
|
323
|
+
l(this, "avatarElement");
|
|
324
|
+
l(this, "statusElement");
|
|
325
|
+
/** O que este componente escreveu em aria-label / aria-hidden (para distinguir do que o consumidor definiu). */
|
|
326
|
+
l(this, "_rotuloAuto", null);
|
|
327
|
+
l(this, "_ocultoAuto", !1);
|
|
328
|
+
l(this, "_sincronizando", !1);
|
|
329
|
+
const t = this.attachShadow({ mode: "open" });
|
|
330
|
+
t.innerHTML = `
|
|
331
|
+
<style>${B}</style>
|
|
332
|
+
<div class="ui-avatar">
|
|
333
|
+
<span class="ui-avatar__content"></span>
|
|
334
|
+
</div>
|
|
335
|
+
<span class="ui-avatar__status" style="display: none;"></span>
|
|
336
|
+
`, this.avatarElement = t.querySelector(".ui-avatar"), this.statusElement = t.querySelector(".ui-avatar__status");
|
|
337
|
+
}
|
|
338
|
+
static get observedAttributes() {
|
|
339
|
+
return [
|
|
340
|
+
"src",
|
|
341
|
+
"nome",
|
|
342
|
+
"name",
|
|
343
|
+
"tamanho",
|
|
344
|
+
"size",
|
|
345
|
+
"formato",
|
|
346
|
+
"status",
|
|
347
|
+
"aria-label"
|
|
348
|
+
];
|
|
349
|
+
}
|
|
350
|
+
connectedCallback() {
|
|
351
|
+
this.syncState();
|
|
352
|
+
}
|
|
353
|
+
attributeChangedCallback(t, i, e) {
|
|
354
|
+
this._sincronizando || this.syncState();
|
|
355
|
+
}
|
|
356
|
+
/** Iniciais por ponto de código (emoji e caracteres fora do BMP não são cortados ao meio). */
|
|
357
|
+
extrairIniciais(t) {
|
|
358
|
+
const i = t.trim().split(/\s+/).filter(Boolean);
|
|
359
|
+
if (i.length === 0) return "?";
|
|
360
|
+
if (i.length === 1)
|
|
361
|
+
return Array.from(i[0]).slice(0, 2).join("").toUpperCase();
|
|
362
|
+
const e = Array.from(i[0])[0], r = Array.from(i[i.length - 1])[0];
|
|
363
|
+
return (e + r).toUpperCase();
|
|
364
|
+
}
|
|
365
|
+
lerNome() {
|
|
366
|
+
return this.getAttribute("nome") || this.getAttribute("name") || "";
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Nome acessível: com nome, o host é uma imagem nomeada ("Ana, online"); sem nome, é decorativo.
|
|
370
|
+
* Um `aria-label`/`aria-hidden` definido pelo consumidor nunca é sobrescrito.
|
|
371
|
+
*/
|
|
372
|
+
sincronizarAcessibilidade(t, i) {
|
|
373
|
+
const e = this.getAttribute("aria-label"), r = e !== null && e !== this._rotuloAuto, s = this.hasAttribute("aria-hidden") && !this._ocultoAuto;
|
|
374
|
+
if (!(r || s)) {
|
|
375
|
+
if (this._sincronizando = !0, t) {
|
|
376
|
+
const n = i ? `${t}, ${i}` : t;
|
|
377
|
+
this.setAttribute("role", "img"), this.setAttribute("aria-label", n), this._rotuloAuto = n, this.removeAttribute("aria-hidden"), this._ocultoAuto = !1;
|
|
378
|
+
} else
|
|
379
|
+
this._rotuloAuto !== null && this.removeAttribute("aria-label"), this._rotuloAuto = null, this.removeAttribute("role"), this.setAttribute("aria-hidden", "true"), this._ocultoAuto = !0;
|
|
380
|
+
this._sincronizando = !1;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
syncState() {
|
|
384
|
+
const t = this.getAttribute("src"), i = this.lerNome(), e = (this.getAttribute("tamanho") || this.getAttribute("size") || "md").trim().toLowerCase(), r = this.getAttribute("formato"), s = v(this.getAttribute("status"), H);
|
|
385
|
+
this.avatarElement.className = "ui-avatar";
|
|
386
|
+
const n = v(e, _), u = parseInt(e, 10);
|
|
387
|
+
n ? (this.avatarElement.classList.add(`ui-avatar--${n}`), this.avatarElement.style.removeProperty("--ui-tamanho-avatar")) : Number.isFinite(u) && u >= R && u <= U ? this.avatarElement.style.setProperty("--ui-tamanho-avatar", `${u}px`) : (this.avatarElement.classList.add(`ui-avatar--${b(null, _, "md")}`), this.avatarElement.style.removeProperty("--ui-tamanho-avatar")), r === "quadrado" && this.avatarElement.classList.add("ui-avatar--quadrado");
|
|
388
|
+
const d = this.avatarElement.querySelector(".ui-avatar__content");
|
|
389
|
+
if (d)
|
|
390
|
+
if (t) {
|
|
391
|
+
const h = d.querySelector("img");
|
|
392
|
+
if (h && h.getAttribute("src") === t)
|
|
393
|
+
h.alt = "";
|
|
394
|
+
else {
|
|
395
|
+
d.textContent = "";
|
|
396
|
+
const c = document.createElement("img");
|
|
397
|
+
c.className = "ui-avatar__img", c.src = t, c.alt = "", c.onerror = () => {
|
|
398
|
+
this.renderFallback(d, this.lerNome());
|
|
399
|
+
}, d.appendChild(c);
|
|
400
|
+
}
|
|
401
|
+
} else
|
|
402
|
+
d.textContent = "", this.renderFallback(d, i);
|
|
403
|
+
this.sincronizarAcessibilidade(i, s), s ? (this.statusElement.className = `ui-avatar__status ui-avatar__status--${s}`, this.statusElement.style.display = "block", this.statusElement.setAttribute("aria-hidden", "true")) : this.statusElement.style.display = "none";
|
|
404
|
+
}
|
|
405
|
+
renderFallback(t, i) {
|
|
406
|
+
i ? t.textContent = this.extrairIniciais(i) : t.innerHTML = `
|
|
407
|
+
<svg viewBox="0 0 24 24" width="60%" height="60%" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
408
|
+
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
|
|
409
|
+
<circle cx="12" cy="7" r="4"></circle>
|
|
410
|
+
</svg>
|
|
411
|
+
`;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
p("ui-avatar", K);
|
|
415
|
+
class X {
|
|
416
|
+
constructor(a, t) {
|
|
417
|
+
l(this, "rafId", null);
|
|
418
|
+
l(this, "resizeObserver");
|
|
419
|
+
this.trackElement = a, this.indicadorElement = t;
|
|
420
|
+
}
|
|
421
|
+
iniciarObserver(a, t) {
|
|
422
|
+
typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => {
|
|
423
|
+
this.atualizar(), t && t();
|
|
424
|
+
}), this.resizeObserver.observe(a));
|
|
425
|
+
}
|
|
426
|
+
destruir() {
|
|
427
|
+
this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = void 0), this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null);
|
|
428
|
+
}
|
|
429
|
+
atualizar() {
|
|
430
|
+
this.rafId !== null && cancelAnimationFrame(this.rafId), this.rafId = requestAnimationFrame(() => {
|
|
431
|
+
this.rafId = null;
|
|
432
|
+
const a = this.trackElement.querySelector(".ui-segmented__item--ativo");
|
|
433
|
+
if (!a) {
|
|
434
|
+
this.indicadorElement.style.opacity = "0";
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const t = this.indicadorElement.parentElement, i = a.getBoundingClientRect(), e = t == null ? void 0 : t.getBoundingClientRect();
|
|
438
|
+
let r, s;
|
|
439
|
+
if (t && e && i.width > 0 && e.width > 0) {
|
|
440
|
+
const n = t.clientLeft || 0;
|
|
441
|
+
r = Number((i.left - e.left - n).toFixed(2)), s = Number(i.width.toFixed(2));
|
|
442
|
+
} else
|
|
443
|
+
r = Math.round(a.offsetLeft), s = Math.round(a.offsetWidth);
|
|
444
|
+
this.indicadorElement.style.transform = `translateX(${r}px)`, this.indicadorElement.style.width = `${s}px`, this.indicadorElement.style.opacity = "1";
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
function G(o, a, t, i) {
|
|
449
|
+
if (t) return;
|
|
450
|
+
const e = Array.from(
|
|
451
|
+
a.querySelectorAll(".ui-segmented__item:not(:disabled)")
|
|
452
|
+
);
|
|
453
|
+
if (e.length === 0) return;
|
|
454
|
+
const r = e.findIndex((u) => u.classList.contains("ui-segmented__item--ativo"));
|
|
455
|
+
let s = r;
|
|
456
|
+
if (o.key === "ArrowRight" || o.key === "ArrowDown")
|
|
457
|
+
o.preventDefault(), s = (r + 1) % e.length;
|
|
458
|
+
else if (o.key === "ArrowLeft" || o.key === "ArrowUp")
|
|
459
|
+
o.preventDefault(), s = (r - 1 + e.length) % e.length;
|
|
460
|
+
else if (o.key === "Home")
|
|
461
|
+
o.preventDefault(), s = 0;
|
|
462
|
+
else if (o.key === "End")
|
|
463
|
+
o.preventDefault(), s = e.length - 1;
|
|
464
|
+
else
|
|
465
|
+
return;
|
|
466
|
+
const n = e[s];
|
|
467
|
+
if (n && n.dataset.indice) {
|
|
468
|
+
const u = parseInt(n.dataset.indice, 10);
|
|
469
|
+
i(u);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const Q = ':host{display:inline-flex;vertical-align:middle;box-sizing:border-box;font-family:var(--ui-fonte-base, "Inter", sans-serif)}:host([largura-total]),:host([full-width]){display:block;width:100%}.ui-segmented{--_altura: var(--ui-campo-altura, 34px);--_moldura: 3px;display:inline-flex;position:relative;height:var(--_altura);background-color:var(--ui-cor-fundo, #0b0b0d);border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .12));border-radius:var(--ui-raio-borda, 8px);padding:var(--_moldura);box-sizing:border-box;-webkit-user-select:none;user-select:none;gap:2px;align-items:center}.ui-segmented--full{display:flex;width:100%}.ui-segmented--full .ui-segmented__item{flex:1}.ui-segmented--sm{--_moldura: 2px}.ui-segmented--sm .ui-segmented__item{font-size:12px;padding:0 8px}.ui-segmented--md .ui-segmented__item{font-size:13px;padding:0 14px}.ui-segmented--lg{--_moldura: 4px}.ui-segmented--lg .ui-segmented__item{font-size:14px;padding:0 18px}.ui-segmented__indicador{position:absolute;top:var(--_moldura);bottom:var(--_moldura);left:0;box-sizing:border-box;background-color:var(--ui-cor-fundo-card, #1e1e24);border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .16));border-radius:calc(var(--ui-raio-borda, 8px) - 2px);box-shadow:var(--ui-sombra-sm, 0 2px 8px rgba(0, 0, 0, .4));pointer-events:none;transition:transform .22s cubic-bezier(.16,1,.3,1),width .22s cubic-bezier(.16,1,.3,1),opacity .15s ease;z-index:1;opacity:0}.ui-segmented__item{position:relative;z-index:2;display:inline-flex;align-items:center;justify-content:center;gap:6px;background:transparent;border:none;color:var(--ui-cor-texto-secundario, #888899);font-family:inherit;font-weight:500;cursor:pointer;border-radius:calc(var(--ui-raio-borda, 8px) - 2px);line-height:1;white-space:nowrap;transition:color .15s ease;box-sizing:border-box;height:calc(var(--_altura) - 2px - 2 * var(--_moldura))}.ui-segmented__item:hover:not(:disabled){color:var(--ui-cor-texto, #e1e1e6)}.ui-segmented__item--ativo{color:var(--ui-cor-texto, #ffffff)!important;font-weight:600}.ui-segmented__item:focus-visible{outline:none;box-shadow:0 0 0 2px var(--ui-cor-primaria, #00E08A)}.ui-segmented__item:disabled{opacity:.35;cursor:not-allowed}.ui-segmented__icone{display:inline-flex;align-items:center;justify-content:center;line-height:1}.ui-segmented__icone ui-icone,.ui-segmented__icone svg{shape-rendering:geometricPrecision;display:inline-flex;align-items:center;justify-content:center}@media (max-width: 640px){.ui-segmented{--_altura: max(var(--ui-campo-altura, 34px), 38px)}}', W = [
|
|
473
|
+
"valor",
|
|
474
|
+
"value",
|
|
475
|
+
"name",
|
|
476
|
+
"disabled",
|
|
477
|
+
"tamanho",
|
|
478
|
+
"size",
|
|
479
|
+
"densidade",
|
|
480
|
+
"altura",
|
|
481
|
+
"height",
|
|
482
|
+
"largura-total",
|
|
483
|
+
"full-width",
|
|
484
|
+
"obrigatorio",
|
|
485
|
+
"required",
|
|
486
|
+
"mensagem-validacao"
|
|
487
|
+
];
|
|
488
|
+
function J() {
|
|
489
|
+
return `
|
|
490
|
+
<style>${Q}</style>
|
|
491
|
+
<div class="ui-segmented ui-segmented--md" part="base" role="radiogroup">
|
|
492
|
+
<div class="ui-segmented__indicador" part="indicador"></div>
|
|
493
|
+
<div class="ui-segmented__track" style="display: contents;"></div>
|
|
494
|
+
<slot style="display: none;"></slot>
|
|
495
|
+
</div>
|
|
496
|
+
`;
|
|
497
|
+
}
|
|
498
|
+
function Y(o, a, t, i, e) {
|
|
499
|
+
const r = document.createElement("button");
|
|
500
|
+
r.type = "button", r.role = "radio", r.className = "ui-segmented__item", r.setAttribute("part", o.valor === t ? "opcao opcao-selecionada" : "opcao"), r.dataset.valor = o.valor, r.dataset.indice = String(a);
|
|
501
|
+
const s = o.valor === t;
|
|
502
|
+
if (r.setAttribute("aria-checked", String(s)), r.tabIndex = s ? 0 : -1, s && r.classList.add("ui-segmented__item--ativo"), (i || o.disabled) && (r.disabled = !0), o.icone) {
|
|
503
|
+
const u = document.createElement("span");
|
|
504
|
+
u.className = "ui-segmented__icone";
|
|
505
|
+
const d = document.createElement("ui-icone");
|
|
506
|
+
d.setAttribute("nome", o.icone), d.setAttribute("tamanho", "14"), u.appendChild(d), r.appendChild(u);
|
|
507
|
+
}
|
|
508
|
+
const n = document.createElement("span");
|
|
509
|
+
return n.className = "ui-segmented__texto", n.textContent = o.rotulo, r.appendChild(n), r.addEventListener("click", (u) => {
|
|
510
|
+
u.stopPropagation(), e();
|
|
511
|
+
}), r;
|
|
512
|
+
}
|
|
513
|
+
class w extends A {
|
|
514
|
+
constructor() {
|
|
515
|
+
super();
|
|
516
|
+
l(this, "rootElement");
|
|
517
|
+
l(this, "trackElement");
|
|
518
|
+
l(this, "indicadorElement");
|
|
519
|
+
l(this, "slotElement");
|
|
520
|
+
l(this, "_opcoes", []);
|
|
521
|
+
l(this, "_defaultValue", "");
|
|
522
|
+
l(this, "listeners", new y());
|
|
523
|
+
l(this, "indicadorController");
|
|
524
|
+
l(this, "handleSlotChange", () => {
|
|
525
|
+
this._opcoes.length === 0 && this.carregarOpcoes();
|
|
526
|
+
});
|
|
527
|
+
l(this, "handleKeyDown", (t) => {
|
|
528
|
+
G(t, this.trackElement, this.disabled, (i) => {
|
|
529
|
+
this.selecionarIndice(i);
|
|
530
|
+
});
|
|
531
|
+
});
|
|
532
|
+
const t = this.attachShadow({ mode: "open" });
|
|
533
|
+
t.innerHTML = J(), this.rootElement = t.querySelector(".ui-segmented"), this.indicadorElement = t.querySelector(".ui-segmented__indicador"), this.trackElement = t.querySelector(".ui-segmented__track"), this.slotElement = t.querySelector("slot"), this.indicadorController = new X(
|
|
534
|
+
this.trackElement,
|
|
535
|
+
this.indicadorElement
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
static get observedAttributes() {
|
|
539
|
+
return W;
|
|
540
|
+
}
|
|
541
|
+
connectedCallback() {
|
|
542
|
+
this.listeners.cleanup(), this.listeners.add(this.rootElement, "keydown", this.handleKeyDown), this.listeners.add(this.slotElement, "slotchange", this.handleSlotChange), this._defaultValue || (this._defaultValue = this.getAttribute("valor") || this.getAttribute("value") || ""), this.indicadorController.iniciarObserver(this.rootElement), this.carregarOpcoes(), this.syncState();
|
|
543
|
+
}
|
|
544
|
+
disconnectedCallback() {
|
|
545
|
+
this.listeners.cleanup(), this.indicadorController.destruir();
|
|
546
|
+
}
|
|
547
|
+
attributeChangedCallback(t, i, e) {
|
|
548
|
+
i !== e && (t === "valor" || t === "value" ? this.atualizarSelecao(e || "") : this.syncState());
|
|
549
|
+
}
|
|
550
|
+
// === Ciclo de Vida Form-Associated Custom Elements (W3C FACE) ===
|
|
551
|
+
formResetCallback() {
|
|
552
|
+
this.valor = this._defaultValue, this.syncState();
|
|
553
|
+
}
|
|
554
|
+
formStateRestoreCallback(t, i) {
|
|
555
|
+
typeof t == "string" && (this.valor = t), this.syncState();
|
|
556
|
+
}
|
|
557
|
+
get type() {
|
|
558
|
+
return "select-one";
|
|
559
|
+
}
|
|
560
|
+
atualizarValidade() {
|
|
561
|
+
if (!this.internals || typeof this.internals.setValidity != "function") return;
|
|
562
|
+
if (this.disabled) {
|
|
563
|
+
this.internals.setValidity({});
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
if (this._customErrorMessage) {
|
|
567
|
+
this.internals.setValidity({ customError: !0 }, this._customErrorMessage, this.rootElement);
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
if ((this.hasAttribute("obrigatorio") || this.hasAttribute("required")) && (!this.valor || this.valor.trim() === "")) {
|
|
571
|
+
const i = this.getAttribute("mensagem-validacao") || "Selecione uma opção.";
|
|
572
|
+
this.internals.setValidity({ valueMissing: !0 }, i, this.rootElement);
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
this.internals.setValidity({});
|
|
576
|
+
}
|
|
577
|
+
get valor() {
|
|
578
|
+
return this.getAttribute("valor") || this.getAttribute("value") || "";
|
|
579
|
+
}
|
|
580
|
+
set valor(t) {
|
|
581
|
+
this.setAttribute("valor", t), this.atualizarSelecao(t);
|
|
582
|
+
}
|
|
583
|
+
get value() {
|
|
584
|
+
return this.valor;
|
|
585
|
+
}
|
|
586
|
+
set value(t) {
|
|
587
|
+
this.valor = t;
|
|
588
|
+
}
|
|
589
|
+
get name() {
|
|
590
|
+
return this.getAttribute("name") || "";
|
|
591
|
+
}
|
|
592
|
+
set name(t) {
|
|
593
|
+
this.setAttribute("name", t);
|
|
594
|
+
}
|
|
595
|
+
get disabled() {
|
|
596
|
+
return this.hasAttribute("disabled") || this._formDisabled;
|
|
597
|
+
}
|
|
598
|
+
set disabled(t) {
|
|
599
|
+
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
600
|
+
}
|
|
601
|
+
get opcoes() {
|
|
602
|
+
return this._opcoes;
|
|
603
|
+
}
|
|
604
|
+
set opcoes(t) {
|
|
605
|
+
this._opcoes = Array.isArray(t) ? t : [], this.renderizarOpcoes();
|
|
606
|
+
}
|
|
607
|
+
carregarOpcoes() {
|
|
608
|
+
const t = this.slotElement.assignedElements();
|
|
609
|
+
if (t.length > 0) {
|
|
610
|
+
const i = [];
|
|
611
|
+
t.forEach((e) => {
|
|
612
|
+
var r, s;
|
|
613
|
+
if (e instanceof HTMLElement) {
|
|
614
|
+
const n = e.getAttribute("valor") || e.getAttribute("value") || e.getAttribute("data-value") || ((r = e.textContent) == null ? void 0 : r.trim()) || "", u = e.getAttribute("label") || e.getAttribute("rotulo") || ((s = e.textContent) == null ? void 0 : s.trim()) || n, d = e.getAttribute("icone") || e.getAttribute("icon") || void 0, h = e.hasAttribute("disabled");
|
|
615
|
+
i.push({ valor: n, rotulo: u, icone: d, disabled: h });
|
|
616
|
+
}
|
|
617
|
+
}), this._opcoes = i, this.renderizarOpcoes();
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
renderizarOpcoes() {
|
|
621
|
+
this.trackElement.innerHTML = "";
|
|
622
|
+
const t = this.valor, i = this.disabled;
|
|
623
|
+
this._opcoes.forEach((r, s) => {
|
|
624
|
+
const n = Y(
|
|
625
|
+
r,
|
|
626
|
+
s,
|
|
627
|
+
t,
|
|
628
|
+
i,
|
|
629
|
+
() => this.selecionarIndice(s)
|
|
630
|
+
);
|
|
631
|
+
this.trackElement.appendChild(n);
|
|
632
|
+
});
|
|
633
|
+
const e = this.required || this.hasAttribute("sem-selecao-inicial");
|
|
634
|
+
!t && this._opcoes.length > 0 && !e ? this.selecionarIndice(0, !1) : this.indicadorController.atualizar(), this.atualizarValidade();
|
|
635
|
+
}
|
|
636
|
+
selecionarIndice(t, i = !0) {
|
|
637
|
+
var s, n;
|
|
638
|
+
if (this.disabled) return;
|
|
639
|
+
const e = this._opcoes[t];
|
|
640
|
+
if (!e || e.disabled) return;
|
|
641
|
+
const r = this.valor;
|
|
642
|
+
this.setAttribute("valor", e.valor), this.internals && ((n = (s = this.internals).setFormValue) == null || n.call(s, e.valor)), this.atualizarSelecao(e.valor), i && r !== e.valor && (this.dispatchEvent(
|
|
643
|
+
new CustomEvent("ui-change", {
|
|
644
|
+
detail: { valor: e.valor, rotulo: e.rotulo, indice: t },
|
|
645
|
+
bubbles: !0,
|
|
646
|
+
composed: !0
|
|
647
|
+
})
|
|
648
|
+
), this.dispatchEvent(
|
|
649
|
+
new CustomEvent("ui-selecionar", {
|
|
650
|
+
detail: { valor: e.valor, rotulo: e.rotulo, indice: t },
|
|
651
|
+
bubbles: !0,
|
|
652
|
+
composed: !0
|
|
653
|
+
})
|
|
654
|
+
));
|
|
655
|
+
}
|
|
656
|
+
atualizarSelecao(t) {
|
|
657
|
+
var e, r;
|
|
658
|
+
Array.from(this.trackElement.querySelectorAll(".ui-segmented__item")).forEach((s) => {
|
|
659
|
+
const n = s.dataset.valor === t;
|
|
660
|
+
s.classList.toggle("ui-segmented__item--ativo", n), C(s, "opcao-selecionada", n), s.setAttribute("aria-checked", String(n)), s.tabIndex = n ? 0 : -1, n && s.focus();
|
|
661
|
+
}), this.internals && ((r = (e = this.internals).setFormValue) == null || r.call(e, t)), this.indicadorController.atualizar(), this.atualizarValidade();
|
|
662
|
+
}
|
|
663
|
+
syncState() {
|
|
664
|
+
g(this);
|
|
665
|
+
const t = I(
|
|
666
|
+
this.getAttribute("tamanho") ?? this.getAttribute("size") ?? this.getAttribute("densidade")
|
|
667
|
+
) ?? "md", i = this.hasAttribute("largura-total") || this.hasAttribute("full-width"), e = this.disabled;
|
|
668
|
+
this.rootElement.className = `ui-segmented ui-segmented--${t}`, i && this.rootElement.classList.add("ui-segmented--full"), this.rootElement.setAttribute("aria-disabled", String(e)), Array.from(this.trackElement.querySelectorAll(".ui-segmented__item")).forEach((s) => {
|
|
669
|
+
s.disabled = e;
|
|
670
|
+
}), this.indicadorController.atualizar(), this.atualizarValidade();
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
class Z extends w {
|
|
674
|
+
}
|
|
675
|
+
p("ui-segmented", w);
|
|
676
|
+
p("ui-segmento", Z);
|
|
677
|
+
const tt = ':host{--_espaco: var(--ui-espaco-sm, 8px);display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;gap:var(--ui-linha-espaco, var(--_espaco));box-sizing:border-box;min-width:0;max-width:100%}:host([inline]){display:inline-flex;vertical-align:middle}:host([hidden]){display:none}:host([sem-quebra]){flex-wrap:nowrap}:host([espaco="nenhum"]){--_espaco: 0}:host([espaco="xs"]){--_espaco: var(--ui-espaco-xs, 4px)}:host([espaco="sm"]){--_espaco: var(--ui-espaco-sm, 8px)}:host([espaco="md"]){--_espaco: var(--ui-espaco-md, 16px)}:host([espaco="lg"]){--_espaco: var(--ui-espaco-lg, 24px)}:host([alinhar="inicio"]){align-items:flex-start}:host([alinhar="centro"]){align-items:center}:host([alinhar="fim"]){align-items:flex-end}:host([alinhar="esticar"]){align-items:stretch}:host([justificar="centro"]){justify-content:center}:host([justificar="fim"]){justify-content:flex-end}:host([justificar="entre"]){justify-content:space-between}:host([justificar="ao-redor"]){justify-content:space-around}::slotted(*){flex:0 0 auto;width:auto;max-width:100%;margin-top:0;margin-bottom:0}::slotted(ui-campo-texto),::slotted(ui-input),::slotted(ui-lista-flutuante),::slotted(ui-select){flex:1 1 var(--ui-linha-campo-base, 12rem);min-width:0}::slotted([expandir]){flex:1 1 0;min-width:0}';
|
|
678
|
+
class et extends x {
|
|
679
|
+
static get observedAttributes() {
|
|
680
|
+
return ["tamanho", "size", "densidade", "altura", "height"];
|
|
681
|
+
}
|
|
682
|
+
constructor() {
|
|
683
|
+
super();
|
|
684
|
+
const a = this.attachShadow({ mode: "open" });
|
|
685
|
+
a.innerHTML = `<style>${tt}</style><slot></slot>`;
|
|
686
|
+
}
|
|
687
|
+
connectedCallback() {
|
|
688
|
+
g(this);
|
|
689
|
+
}
|
|
690
|
+
attributeChangedCallback(a, t, i) {
|
|
691
|
+
t !== i && g(this);
|
|
692
|
+
}
|
|
693
|
+
lerTexto(a) {
|
|
694
|
+
return this.getAttribute(a);
|
|
695
|
+
}
|
|
696
|
+
definirTexto(a, t) {
|
|
697
|
+
t == null || t === "" ? this.removeAttribute(a) : this.setAttribute(a, String(t));
|
|
698
|
+
}
|
|
699
|
+
get tamanho() {
|
|
700
|
+
return this.lerTexto("tamanho");
|
|
701
|
+
}
|
|
702
|
+
set tamanho(a) {
|
|
703
|
+
this.definirTexto("tamanho", a);
|
|
704
|
+
}
|
|
705
|
+
get altura() {
|
|
706
|
+
return this.lerTexto("altura");
|
|
707
|
+
}
|
|
708
|
+
set altura(a) {
|
|
709
|
+
this.definirTexto("altura", a === null ? null : String(a));
|
|
710
|
+
}
|
|
711
|
+
get alinhar() {
|
|
712
|
+
return this.lerTexto("alinhar");
|
|
713
|
+
}
|
|
714
|
+
set alinhar(a) {
|
|
715
|
+
this.definirTexto("alinhar", a);
|
|
716
|
+
}
|
|
717
|
+
get justificar() {
|
|
718
|
+
return this.lerTexto("justificar");
|
|
719
|
+
}
|
|
720
|
+
set justificar(a) {
|
|
721
|
+
this.definirTexto("justificar", a);
|
|
722
|
+
}
|
|
723
|
+
get espaco() {
|
|
724
|
+
return this.lerTexto("espaco");
|
|
725
|
+
}
|
|
726
|
+
set espaco(a) {
|
|
727
|
+
this.definirTexto("espaco", a);
|
|
728
|
+
}
|
|
729
|
+
get semQuebra() {
|
|
730
|
+
return this.hasAttribute("sem-quebra");
|
|
731
|
+
}
|
|
732
|
+
set semQuebra(a) {
|
|
733
|
+
this.toggleAttribute("sem-quebra", !!a);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
p("ui-linha", et);
|
|
737
|
+
export {
|
|
738
|
+
W as A,
|
|
739
|
+
X as S,
|
|
740
|
+
K as U,
|
|
741
|
+
et as a,
|
|
742
|
+
w as b,
|
|
743
|
+
Z as c,
|
|
744
|
+
D as d,
|
|
745
|
+
E as e,
|
|
746
|
+
Y as f,
|
|
747
|
+
J as g,
|
|
748
|
+
G as t
|
|
749
|
+
};
|