@thibezer/ui-components-kit 2.6.1 → 2.7.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 +49 -0
- package/dist/acessibilidade-CSzX-DkG.cjs +1 -0
- package/dist/acessibilidade-CUlSXc2X.js +38 -0
- package/dist/camadas.cjs +94 -94
- package/dist/camadas.js +1218 -1124
- package/dist/campo-texto.cjs +1 -1
- package/dist/campo-texto.js +1 -1
- package/dist/canvas.cjs +66 -65
- package/dist/canvas.js +3769 -3389
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/components/ui-alerta/ui-toast.d.ts +4 -15
- package/dist/components/ui-avatar/ui-avatar.d.ts +11 -0
- package/dist/components/ui-badge/ui-badge.d.ts +2 -0
- package/dist/components/ui-barra-ferramentas/paleta-atalhos.d.ts +16 -0
- package/dist/components/ui-barra-ferramentas/paleta-pressao-longa.d.ts +24 -0
- package/dist/components/ui-barra-ferramentas/ribbon-render.d.ts +14 -0
- package/dist/components/ui-barra-ferramentas/ribbon-teclado.d.ts +17 -0
- package/dist/components/ui-barra-ferramentas/ui-paleta-ferramentas.d.ts +1 -7
- package/dist/components/ui-barra-ferramentas/ui-ribbon.d.ts +0 -1
- package/dist/components/ui-camadas/camadas-arraste-controles.d.ts +2 -0
- package/dist/components/ui-camadas/camadas-arvore-renderer.d.ts +4 -11
- package/dist/components/ui-camadas/camadas-colecao.d.ts +27 -0
- package/dist/components/ui-camadas/camadas-drag-drop.d.ts +13 -1
- package/dist/components/ui-camadas/camadas-drop-ops.d.ts +31 -0
- package/dist/components/ui-camadas/camadas-hierarquia.d.ts +10 -0
- package/dist/components/ui-camadas/camadas-lembranca.d.ts +34 -0
- package/dist/components/ui-camadas/camadas-render.d.ts +14 -0
- package/dist/components/ui-camadas/camadas-renomear.d.ts +12 -0
- package/dist/components/ui-camadas/camadas-selecao-api.d.ts +17 -0
- package/dist/components/ui-camadas/camadas-thumb.d.ts +1 -0
- package/dist/components/ui-camadas/ui-camadas.d.ts +3 -5
- package/dist/components/ui-canvas-cad/cad-acessibilidade.d.ts +15 -0
- package/dist/components/ui-canvas-cad/cad-atributos-sync.d.ts +2 -1
- package/dist/components/ui-canvas-cad/cad-broadcast.d.ts +1 -1
- package/dist/components/ui-canvas-cad/cad-evento-coordenadas.d.ts +22 -0
- package/dist/components/ui-canvas-cad/cad-eventos-canvas.d.ts +3 -8
- package/dist/components/ui-canvas-cad/cad-feicoes-camera.d.ts +26 -0
- package/dist/components/ui-canvas-cad/cad-feicoes-consulta.d.ts +21 -0
- package/dist/components/ui-canvas-cad/cad-feicoes-dados.d.ts +39 -0
- package/dist/components/ui-canvas-cad/cad-feicoes-desenho.d.ts +68 -0
- package/dist/components/ui-canvas-cad/cad-feicoes-edicao.d.ts +37 -0
- package/dist/components/ui-canvas-cad/cad-feicoes-operacoes.d.ts +48 -0
- package/dist/components/ui-canvas-cad/cad-feicoes-ponteiro.d.ts +24 -0
- package/dist/components/ui-canvas-cad/cad-feicoes-selecao-regiao.d.ts +22 -0
- package/dist/components/ui-canvas-cad/cad-feicoes-tipos.d.ts +53 -0
- package/dist/components/ui-canvas-cad/cad-feicoes-versoes.d.ts +33 -0
- package/dist/components/ui-canvas-cad/cad-feicoes.d.ts +26 -106
- package/dist/components/ui-canvas-cad/cad-inicializador.d.ts +3 -1
- package/dist/components/ui-canvas-cad/cad-leaflet-adaptador.d.ts +5 -0
- package/dist/components/ui-canvas-cad/cad-selecao-pontos.d.ts +5 -0
- package/dist/components/ui-canvas-cad/tipos.d.ts +37 -0
- package/dist/components/ui-canvas-cad/ui-canvas-cad.d.ts +4 -1
- package/dist/components/ui-checkbox/ui-checkbox.d.ts +4 -1
- package/dist/components/ui-mapa/mapa-atributos.d.ts +14 -0
- package/dist/components/ui-mapa/mapa-basemaps.d.ts +7 -0
- package/dist/components/ui-mapa/mapa-icones.d.ts +4 -0
- package/dist/components/ui-mapa/mapa-leaflet.d.ts +5 -0
- package/dist/components/ui-mapa/mapa-vinculo-pai.d.ts +22 -0
- package/dist/components/ui-mapa/tipos.d.ts +13 -0
- package/dist/components/ui-mapa/ui-mapa-linha.d.ts +12 -5
- package/dist/components/ui-mapa/ui-mapa-marcador.d.ts +15 -6
- package/dist/components/ui-mapa/ui-mapa.d.ts +14 -1
- package/dist/components/ui-modal/modal-acessibilidade.d.ts +5 -5
- package/dist/components/ui-modal/modal-foco.d.ts +28 -0
- package/dist/components/ui-modal/ui-modal.d.ts +1 -11
- package/dist/components/ui-radio/radio-grupo-registry.d.ts +10 -0
- package/dist/components/ui-radio/ui-radio.d.ts +9 -2
- package/dist/components/ui-skeleton/ui-skeleton.d.ts +9 -0
- package/dist/components/ui-switch/ui-switch.d.ts +3 -1
- package/dist/components/ui-tabela/tabela-estados.d.ts +16 -0
- package/dist/components/ui-tabela/tabela-rolagem.d.ts +44 -0
- package/dist/components/ui-tabela/tabela-teclado.d.ts +16 -0
- package/dist/components/ui-tabela/ui-tabela.d.ts +1 -19
- package/dist/components/ui-tooltip/tooltip-popover.d.ts +7 -0
- package/dist/components/ui-tooltip/tooltip-posicionamento.d.ts +29 -0
- package/dist/components/ui-tooltip/ui-tooltip.d.ts +24 -1
- package/dist/core/opcoes.d.ts +9 -0
- package/dist/core/rotulo-controle.d.ts +13 -0
- package/dist/core/tipos-toast.d.ts +16 -0
- package/dist/core/ui-bus.d.ts +9 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +12 -11
- package/dist/custom-elements.json +19484 -14657
- package/dist/data.cjs +1 -1
- package/dist/data.js +2 -2
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.js +21 -21
- package/dist/form-validacao-BlQFxUVj.js +104 -0
- package/dist/form-validacao-DIeyQVH5.cjs +1 -0
- package/dist/forms.cjs +1 -1
- package/dist/forms.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +46 -46
- package/dist/mapa.cjs +11 -16
- package/dist/mapa.js +242 -170
- package/dist/modal.cjs +1 -1
- package/dist/modal.js +1 -1
- package/dist/opcoes-CJYLi6kd.js +12 -0
- package/dist/opcoes-CkyDxBuQ.cjs +1 -0
- package/dist/register.cjs +1 -1
- package/dist/register.js +12 -13
- package/dist/tabela.cjs +1 -1
- package/dist/tabela.js +1 -1
- package/dist/tipos-elementos.d.ts +8 -3
- package/dist/tipos-vue.d.ts +8 -3
- package/dist/tools.cjs +1 -1
- package/dist/tools.js +1 -1
- package/dist/ui-badge-ChiiiO1r.js +197 -0
- package/dist/ui-badge-DUCxyAG6.cjs +28 -0
- package/dist/{zero-js-triggers-C_KrvFOQ.js → ui-bus-CUd99VJi.js} +36 -103
- package/dist/ui-bus-XqBLlTYQ.cjs +1 -0
- package/dist/ui-campo-texto-CHTfMO-H.cjs +16 -0
- package/dist/ui-campo-texto-gum_jDdI.js +380 -0
- package/dist/ui-card-BNYCQ7g-.js +119 -0
- package/dist/ui-card-BrjBL-yo.cjs +20 -0
- package/dist/ui-controle-cores-BS0WYPdi.js +572 -0
- package/dist/ui-controle-cores-Er6ZcQ7U.cjs +111 -0
- package/dist/ui-modal-BkYvNP0G.js +214 -0
- package/dist/ui-modal-CUNbpbZ1.cjs +18 -0
- package/dist/ui-paleta-ferramentas-Ksh6gMW3.js +890 -0
- package/dist/ui-paleta-ferramentas-bDLPbiGA.cjs +21 -0
- package/dist/ui-segmented-BOaGRQw4.cjs +19 -0
- package/dist/ui-segmented-kbO1BLVs.js +439 -0
- package/dist/ui-skeleton-B2Rgrv8o.js +648 -0
- package/dist/ui-skeleton-BilwGdOm.js +634 -0
- package/dist/ui-skeleton-DiOxTBZK.cjs +52 -0
- package/dist/ui-skeleton-SPYqku8P.cjs +52 -0
- package/dist/ui-skeleton-W9uwIceA.js +585 -0
- package/dist/ui-skeleton-gZrJipCC.cjs +52 -0
- package/dist/ui-switch-BX6U5Ykm.cjs +53 -0
- package/dist/ui-switch-DO5jR0hy.js +915 -0
- package/dist/ui-tabela-propriedades-D9Echt2X.js +2667 -0
- package/dist/ui-tabela-propriedades-DzZlyNZ_.cjs +141 -0
- package/dist/zero-js-triggers-CJT988bR.js +83 -0
- package/dist/zero-js-triggers-CgM9IIQB.cjs +1 -0
- package/package.json +10 -3
- package/dist/ui-skeleton-DI4_9WOX.js +0 -428
- package/dist/ui-skeleton-elhKIh2B.cjs +0 -33
- package/dist/ui-toast-Bp_NlM5G.js +0 -156
- package/dist/ui-toast-DGTZKne5.cjs +0 -20
- package/dist/zero-js-triggers-C_gtaojZ.cjs +0 -1
|
@@ -0,0 +1,915 @@
|
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var k = (o, i, t) => i in o ? _(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
|
|
3
|
+
var a = (o, i, t) => k(o, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
+
import { L as u } from "./listener-bag-DQgv7OON.js";
|
|
5
|
+
import { a as y } from "./parts-CaoQiCfI.js";
|
|
6
|
+
import { d as h } from "./ssr-safe-5cWfJP-s.js";
|
|
7
|
+
import { F as d, r as w } from "./ui-campo-texto-gum_jDdI.js";
|
|
8
|
+
import { g as b, o as g, c as m } from "./acessibilidade-CUlSXc2X.js";
|
|
9
|
+
class A {
|
|
10
|
+
constructor(i, t, e) {
|
|
11
|
+
a(this, "scrollHandler");
|
|
12
|
+
a(this, "resizeHandler");
|
|
13
|
+
a(this, "posicionar", () => {
|
|
14
|
+
if (this.isMobileOrBottomSheet()) {
|
|
15
|
+
this.content.style.top = "", this.content.style.left = "", this.content.style.minWidth = "";
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const i = this.button.getBoundingClientRect();
|
|
19
|
+
this.content.style.top = `${Math.round(i.bottom + 2)}px`, this.content.style.left = `${Math.round(i.left)}px`, this.content.style.minWidth = `${Math.round(Math.max(i.width, 120))}px`, this.ajustarAoViewport(i);
|
|
20
|
+
});
|
|
21
|
+
this.host = i, this.button = t, this.content = e;
|
|
22
|
+
}
|
|
23
|
+
isMobileOrBottomSheet() {
|
|
24
|
+
return typeof window > "u" ? !1 : window.innerWidth <= 640 || this.host.hasAttribute("bottom-sheet") || this.host.hasAttribute("modo-mobile");
|
|
25
|
+
}
|
|
26
|
+
/** Com a lista já visível (medida real): abre para cima se faltar espaço embaixo e não deixa sair pela lateral. */
|
|
27
|
+
ajustarAoViewport(i) {
|
|
28
|
+
const t = this.content.offsetHeight, e = this.content.offsetWidth;
|
|
29
|
+
if (t <= 0 || typeof window > "u") return;
|
|
30
|
+
const s = 8;
|
|
31
|
+
i.bottom + 2 + t > window.innerHeight - s && i.top - 2 - t >= s && (this.content.style.top = `${Math.round(i.top - 2 - t)}px`), i.left + e > window.innerWidth - s && (this.content.style.left = `${Math.max(s, Math.round(window.innerWidth - s - e))}px`);
|
|
32
|
+
}
|
|
33
|
+
ativarAcompanhamento(i) {
|
|
34
|
+
if (this.scrollHandler = i, this.resizeHandler = this.posicionar, window.addEventListener("scroll", this.scrollHandler, { capture: !0, passive: !0 }), window.addEventListener("resize", this.resizeHandler, { passive: !0 }), typeof this.content.showPopover == "function")
|
|
35
|
+
try {
|
|
36
|
+
this.content.showPopover();
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
this.posicionar();
|
|
40
|
+
}
|
|
41
|
+
desativarAcompanhamento() {
|
|
42
|
+
if (this.scrollHandler && (window.removeEventListener("scroll", this.scrollHandler, { capture: !0 }), this.scrollHandler = void 0), this.resizeHandler && (window.removeEventListener("resize", this.resizeHandler), this.resizeHandler = void 0), typeof this.content.hidePopover == "function")
|
|
43
|
+
try {
|
|
44
|
+
this.content.hidePopover();
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class E {
|
|
50
|
+
constructor(i) {
|
|
51
|
+
a(this, "focusedIndex", -1);
|
|
52
|
+
this.listElement = i;
|
|
53
|
+
}
|
|
54
|
+
focarPrimeiroItem() {
|
|
55
|
+
const i = Array.from(this.listElement.querySelectorAll(".ui-lista-flutuante__item"));
|
|
56
|
+
if (i.length > 0) {
|
|
57
|
+
const t = i.findIndex((e) => e.classList.contains("ui-lista-flutuante__item--selecionado"));
|
|
58
|
+
this.focusedIndex = Math.max(0, t), i[this.focusedIndex].focus();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
resetarFoco() {
|
|
62
|
+
this.focusedIndex = -1;
|
|
63
|
+
}
|
|
64
|
+
moverFoco(i) {
|
|
65
|
+
const t = Array.from(this.listElement.querySelectorAll(".ui-lista-flutuante__item"));
|
|
66
|
+
t.length !== 0 && (this.focusedIndex += i, this.focusedIndex < 0 && (this.focusedIndex = t.length - 1), this.focusedIndex >= t.length && (this.focusedIndex = 0), t[this.focusedIndex].focus());
|
|
67
|
+
}
|
|
68
|
+
tratarKeydownLista(i, t, e, s, r) {
|
|
69
|
+
if (i.key === "ArrowDown")
|
|
70
|
+
i.preventDefault(), this.moverFoco(1);
|
|
71
|
+
else if (i.key === "ArrowUp")
|
|
72
|
+
i.preventDefault(), this.moverFoco(-1);
|
|
73
|
+
else if (i.key === "Home" || i.key === "End") {
|
|
74
|
+
i.preventDefault();
|
|
75
|
+
const n = i.key === "End";
|
|
76
|
+
this.focusedIndex = n ? -1 : 0, n ? this.moverFoco(-1) : this.moverFoco(0);
|
|
77
|
+
} else i.key === "Tab" ? s() : i.key === "Enter" || i.key === " " ? (i.preventDefault(), this.focusedIndex >= 0 && this.focusedIndex < t.length && e(t[this.focusedIndex])) : i.key === "Escape" && (i.preventDefault(), s(), r.focus());
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const S = ':host{display:inline-block;position:relative;width:100%;box-sizing:border-box;font-family:var(--ui-fonte-base, "Inter", sans-serif)}:host([inline]){width:auto}.ui-lista-flutuante__container{display:flex;flex-direction:column;width:100%;position:relative}.ui-lista-flutuante__label{font-family:var(--ui-fonte-base, "Inter", sans-serif);font-size:var(--ui-tamanho-corpo-sm, 13px);font-weight:var(--ui-peso-medio, 500);color:var(--ui-cor-texto, #e1e1e6);margin-bottom:4px;-webkit-user-select:none;user-select:none;flex-shrink:0}.ui-lista-flutuante__asterisco{color:var(--ui-cor-texto-erro, #ff5555);margin-left:2px}.ui-lista-flutuante__gatilho{display:flex;align-items:center;justify-content:space-between;gap:6px;width:100%;height:var(--ui-campo-altura, 100%);min-height:var(--ui-campo-altura, var(--ui-altura-minima, 15px));padding:0 8px;background-color:var(--ui-cor-fundo-elevado, #1a1a1e);color:var(--ui-cor-texto, #e1e1e6);border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .12));border-radius:var(--ui-raio-borda, 6px);font-family:var(--ui-fonte-base, "Inter", sans-serif);font-size:clamp(11px,.85rem,13px);line-height:1;cursor:pointer;box-sizing:border-box;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:border-color .15s ease,background-color .15s ease}.ui-lista-flutuante__gatilho:hover:not(:disabled){border-color:var(--ui-cor-primaria, #00E08A)}.ui-lista-flutuante__gatilho:disabled{opacity:.5;cursor:not-allowed}.ui-lista-flutuante__texto{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;text-align:left}.ui-lista-flutuante__seta{font-size:10px;line-height:1;display:inline-flex;align-items:center;justify-content:center;transition:transform .2s ease;color:var(--ui-cor-texto-secundario, #888899);flex-shrink:0;shape-rendering:geometricPrecision}:host([aberta]) .ui-lista-flutuante__seta{transform:rotate(180deg)}.ui-lista-flutuante__backdrop{display:none;position:fixed;top:0;left:0;width:100vw;height:100vh;background:transparent;-webkit-backdrop-filter:none;backdrop-filter:none;z-index:calc(var(--ui-z-popover, 1050) - 1)}:host([aberta]) .ui-lista-flutuante__backdrop{display:block}:host(:not([aberta])) .ui-lista-flutuante__conteudo{display:none!important}:host([aberta]) .ui-lista-flutuante__conteudo{display:block}.ui-lista-flutuante__conteudo{position:fixed;margin:0;padding:4px;list-style:none;background-color:var(--ui-cor-fundo-menu, #18181c);border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .14));border-radius:var(--ui-raio-borda, 6px);box-shadow:var(--ui-sombra-lg, 0 8px 28px rgba(0, 0, 0, .55));max-height:220px;overflow-y:auto;z-index:var(--ui-z-popover, 1050);box-sizing:border-box;inset:auto}.ui-lista-flutuante__sheet-header{display:none;width:100%;margin-bottom:8px}.ui-lista-flutuante__handle{width:36px;height:4px;border-radius:2px;background-color:color-mix(in srgb,var(--ui-cor-texto, #e1e1e6) 25%,transparent);margin:2px auto 8px}.ui-lista-flutuante__sheet-title-bar{display:flex;align-items:center;justify-content:space-between;width:100%;padding:4px 6px 8px;border-bottom:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .08));margin-bottom:6px}.ui-lista-flutuante__sheet-titulo{font-size:13px;font-weight:600;color:var(--ui-cor-primaria, #00E08A);letter-spacing:.3px;text-transform:uppercase}.ui-lista-flutuante__sheet-close{background:transparent;border:none;color:var(--ui-cor-texto-secundario, #888899);font-size:14px;cursor:pointer;padding:4px 8px;border-radius:var(--ui-raio-sm, 4px);display:flex;align-items:center;justify-content:center;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:color .15s,background-color .15s}.ui-lista-flutuante__sheet-close:hover{color:#fff;background-color:color-mix(in srgb,var(--ui-cor-texto, #e1e1e6) 8%,transparent)}.ui-lista-flutuante__item{padding:6px 10px;font-family:var(--ui-fonte-base, "Inter", sans-serif);font-size:12px;line-height:1.2;color:var(--ui-cor-texto, #e1e1e6);border-radius:var(--ui-raio-sm, 4px);cursor:pointer;display:flex;align-items:center;justify-content:space-between;gap:8px;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background-color .12s ease,color .12s ease;-webkit-user-select:none;user-select:none}.ui-lista-flutuante__item:hover{background-color:var(--ui-cor-hover-menu, rgba(255, 255, 255, .08))}.ui-lista-flutuante__item--selecionado{background-color:color-mix(in srgb,var(--ui-cor-primaria, #00E08A) 15%,transparent);color:var(--ui-cor-primaria, #00E08A);font-weight:600}.ui-lista-flutuante__item--selecionado:after{content:"✓";font-size:11px;color:var(--ui-cor-primaria, #00E08A)}@media (max-width: 640px){.ui-lista-flutuante__gatilho{min-height:max(var(--ui-campo-altura, 38px),38px);font-size:15px}:host([aberta]) .ui-lista-flutuante__backdrop{background-color:#00000059;-webkit-backdrop-filter:none;backdrop-filter:none}.ui-lista-flutuante__conteudo{position:fixed!important;bottom:0!important;top:auto!important;left:0!important;width:100vw!important;max-width:100vw!important;min-width:100vw!important;max-height:70vh!important;max-height:70dvh!important;border-radius:var(--ui-raio-xl, 16px) var(--ui-raio-xl, 16px) 0 0!important;border-bottom:none!important;padding:10px 16px calc(24px + env(safe-area-inset-bottom,0px)) 16px!important;box-shadow:0 -8px 32px #000000b3!important;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;animation:ui-bottom-sheet-slide .22s cubic-bezier(.4,0,.2,1)}.ui-lista-flutuante__sheet-header{display:flex!important;flex-direction:column!important}.ui-lista-flutuante__sheet-close{min-width:44px;min-height:44px;font-size:18px}.ui-lista-flutuante__item{padding:12px 14px!important;font-size:15px!important;margin-bottom:3px}}:host([bottom-sheet][aberta]) .ui-lista-flutuante__backdrop,:host([modo-mobile][aberta]) .ui-lista-flutuante__backdrop{background-color:#00000059;-webkit-backdrop-filter:none;backdrop-filter:none}:host([bottom-sheet]) .ui-lista-flutuante__conteudo,:host([modo-mobile]) .ui-lista-flutuante__conteudo{position:fixed!important;bottom:0!important;top:auto!important;left:0!important;width:100vw!important;max-width:100vw!important;min-width:100vw!important;max-height:70vh!important;max-height:70dvh!important;border-radius:var(--ui-raio-xl, 16px) var(--ui-raio-xl, 16px) 0 0!important;border-bottom:none!important;padding:10px 16px calc(24px + env(safe-area-inset-bottom,0px)) 16px!important;box-shadow:0 -8px 32px #000000b3!important;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;animation:ui-bottom-sheet-slide .22s cubic-bezier(.4,0,.2,1)}:host([bottom-sheet]) .ui-lista-flutuante__sheet-header,:host([modo-mobile]) .ui-lista-flutuante__sheet-header{display:flex!important;flex-direction:column!important}:host([bottom-sheet]) .ui-lista-flutuante__sheet-close,:host([modo-mobile]) .ui-lista-flutuante__sheet-close{min-width:44px;min-height:44px;font-size:18px}:host([bottom-sheet]) .ui-lista-flutuante__item,:host([modo-mobile]) .ui-lista-flutuante__item{padding:12px 14px!important;font-size:15px!important;margin-bottom:3px}@keyframes ui-bottom-sheet-slide{0%{transform:translateY(100%)}to{transform:translateY(0)}}', C = [
|
|
81
|
+
"aberta",
|
|
82
|
+
"texto-padrao",
|
|
83
|
+
"value",
|
|
84
|
+
"disabled",
|
|
85
|
+
"bottom-sheet",
|
|
86
|
+
"modo-mobile",
|
|
87
|
+
"label",
|
|
88
|
+
"rotulo",
|
|
89
|
+
"placeholder",
|
|
90
|
+
"tamanho",
|
|
91
|
+
"size",
|
|
92
|
+
"altura",
|
|
93
|
+
"height",
|
|
94
|
+
"densidade",
|
|
95
|
+
"name",
|
|
96
|
+
"obrigatorio",
|
|
97
|
+
"required",
|
|
98
|
+
"mensagem-validacao",
|
|
99
|
+
"aria-label"
|
|
100
|
+
];
|
|
101
|
+
function L() {
|
|
102
|
+
return `
|
|
103
|
+
<style>${S}</style>
|
|
104
|
+
<div class="ui-lista-flutuante__container">
|
|
105
|
+
<label class="ui-lista-flutuante__label" part="rotulo" style="display: none;"></label>
|
|
106
|
+
<div class="ui-lista-flutuante__backdrop"></div>
|
|
107
|
+
<button class="ui-lista-flutuante__gatilho" part="campo" aria-haspopup="listbox" aria-expanded="false" type="button">
|
|
108
|
+
<span class="ui-lista-flutuante__texto" part="valor"></span>
|
|
109
|
+
<span class="ui-lista-flutuante__seta" part="seta">▼</span>
|
|
110
|
+
</button>
|
|
111
|
+
<div class="ui-lista-flutuante__conteudo" part="lista" role="listbox" popover="manual">
|
|
112
|
+
<div class="ui-lista-flutuante__sheet-header">
|
|
113
|
+
<div class="ui-lista-flutuante__handle"></div>
|
|
114
|
+
<div class="ui-lista-flutuante__sheet-title-bar">
|
|
115
|
+
<span class="ui-lista-flutuante__sheet-titulo">Selecione uma opção</span>
|
|
116
|
+
<button class="ui-lista-flutuante__sheet-close" type="button" aria-label="Fechar">✕</button>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
<ul class="ui-lista-flutuante__lista" style="margin: 0; padding: 0; list-style: none;"></ul>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
function f(o, i, t) {
|
|
125
|
+
o.innerHTML = "", i.forEach((e) => {
|
|
126
|
+
const s = document.createElement("li"), r = String(e.id) === String(t);
|
|
127
|
+
s.className = `ui-lista-flutuante__item ${r ? "ui-lista-flutuante__item--selecionado" : ""}`, s.setAttribute("data-id", e.id), s.textContent = e.label, s.role = "option", s.tabIndex = -1, s.setAttribute("part", r ? "opcao opcao-selecionada" : "opcao"), r && s.setAttribute("aria-selected", "true"), o.appendChild(s);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function z(o, i) {
|
|
131
|
+
o.querySelectorAll(".ui-lista-flutuante__item").forEach((e) => {
|
|
132
|
+
const s = e.getAttribute("data-id");
|
|
133
|
+
y(e, "opcao-selecionada", s === String(i)), s === String(i) ? (e.classList.add("ui-lista-flutuante__item--selecionado"), e.setAttribute("aria-selected", "true")) : (e.classList.remove("ui-lista-flutuante__item--selecionado"), e.removeAttribute("aria-selected"));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
class x extends d {
|
|
137
|
+
constructor() {
|
|
138
|
+
super();
|
|
139
|
+
a(this, "labelElement");
|
|
140
|
+
a(this, "button");
|
|
141
|
+
a(this, "content");
|
|
142
|
+
a(this, "listElement");
|
|
143
|
+
a(this, "textoElement");
|
|
144
|
+
a(this, "backdropElement");
|
|
145
|
+
a(this, "sheetTituloElement");
|
|
146
|
+
a(this, "sheetCloseButton");
|
|
147
|
+
a(this, "idsAcessibilidade");
|
|
148
|
+
a(this, "listeners", new u());
|
|
149
|
+
a(this, "_itens", []);
|
|
150
|
+
a(this, "_value", "");
|
|
151
|
+
a(this, "_defaultValue", "");
|
|
152
|
+
a(this, "_defaultCapturado", !1);
|
|
153
|
+
a(this, "observer");
|
|
154
|
+
a(this, "posicionamento");
|
|
155
|
+
a(this, "teclado");
|
|
156
|
+
a(this, "toggleLista", (t) => {
|
|
157
|
+
t.stopPropagation(), !this.disabled && (this.hasAttribute("aberta") ? this.fechar() : this.abrir());
|
|
158
|
+
});
|
|
159
|
+
a(this, "handleKeyDown", (t) => {
|
|
160
|
+
if (!this.disabled) {
|
|
161
|
+
if (t.key === "Escape" && this.hasAttribute("aberta")) {
|
|
162
|
+
t.preventDefault(), this.fechar();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
(t.key === "Enter" || t.key === " " || t.key === "ArrowDown" || t.key === "ArrowUp") && (t.preventDefault(), this.hasAttribute("aberta") ? this.teclado.focarPrimeiroItem() : this.abrir());
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
a(this, "handleListKeyDown", (t) => {
|
|
169
|
+
this.hasAttribute("aberta") && this.teclado.tratarKeydownLista(
|
|
170
|
+
t,
|
|
171
|
+
this._itens,
|
|
172
|
+
(e) => this.selecionarItem(e),
|
|
173
|
+
this.fechar,
|
|
174
|
+
this.button
|
|
175
|
+
);
|
|
176
|
+
});
|
|
177
|
+
a(this, "fechar", () => {
|
|
178
|
+
this.hasAttribute("aberta") && (this.removeAttribute("aberta"), this.posicionamento.desativarAcompanhamento(), this.teclado.resetarFoco());
|
|
179
|
+
});
|
|
180
|
+
a(this, "handleClickFora", (t) => {
|
|
181
|
+
if (!this.hasAttribute("aberta")) return;
|
|
182
|
+
const e = t.composedPath();
|
|
183
|
+
!e.includes(this) && !e.includes(this.content) && this.fechar();
|
|
184
|
+
});
|
|
185
|
+
/** Clicar no rótulo foca o controle (comportamento do <select> nativo), sem abrir a lista. */
|
|
186
|
+
a(this, "focarGatilho", () => {
|
|
187
|
+
this.disabled || this.button.focus();
|
|
188
|
+
});
|
|
189
|
+
a(this, "handleHostClick", (t) => {
|
|
190
|
+
m(this, t) && this.focarGatilho();
|
|
191
|
+
});
|
|
192
|
+
a(this, "handleListClick", (t) => {
|
|
193
|
+
var n;
|
|
194
|
+
t.stopPropagation();
|
|
195
|
+
const e = (n = t.target) == null ? void 0 : n.closest("li[data-id]");
|
|
196
|
+
if (!e) return;
|
|
197
|
+
const s = e.getAttribute("data-id"), r = this._itens.find((c) => String(c.id) === String(s));
|
|
198
|
+
r && this.selecionarItem(r);
|
|
199
|
+
});
|
|
200
|
+
const t = this.attachShadow({ mode: "open" });
|
|
201
|
+
t.innerHTML = L(), this.labelElement = t.querySelector(".ui-lista-flutuante__label"), this.button = t.querySelector(".ui-lista-flutuante__gatilho"), this.content = t.querySelector(".ui-lista-flutuante__conteudo"), this.listElement = t.querySelector(".ui-lista-flutuante__lista"), this.textoElement = t.querySelector(".ui-lista-flutuante__texto"), this.backdropElement = t.querySelector(".ui-lista-flutuante__backdrop"), this.sheetTituloElement = t.querySelector(".ui-lista-flutuante__sheet-titulo"), this.sheetCloseButton = t.querySelector(".ui-lista-flutuante__sheet-close");
|
|
202
|
+
const e = b("ui-select");
|
|
203
|
+
this.idsAcessibilidade = {
|
|
204
|
+
label: `${e}-label`,
|
|
205
|
+
gatilho: `${e}-gatilho`,
|
|
206
|
+
texto: `${e}-texto`,
|
|
207
|
+
lista: `${e}-lista`
|
|
208
|
+
}, this.labelElement.id = this.idsAcessibilidade.label, this.button.id = this.idsAcessibilidade.gatilho, this.textoElement.id = this.idsAcessibilidade.texto, this.content.id = this.idsAcessibilidade.lista, this.button.setAttribute("aria-controls", this.idsAcessibilidade.lista), this.posicionamento = new A(this, this.button, this.content), this.teclado = new E(this.listElement);
|
|
209
|
+
}
|
|
210
|
+
static get observedAttributes() {
|
|
211
|
+
return C;
|
|
212
|
+
}
|
|
213
|
+
connectedCallback() {
|
|
214
|
+
this.listeners.cleanup(), this.listeners.add(this.button, "click", this.toggleLista), this.listeners.add(this.button, "keydown", this.handleKeyDown), this.listeners.add(this.content, "keydown", this.handleListKeyDown), this.listeners.add(this.backdropElement, "click", this.fechar), this.listeners.add(this.listElement, "click", this.handleListClick), this.listeners.add(this.sheetCloseButton, "click", (t) => {
|
|
215
|
+
t.stopPropagation(), this.fechar();
|
|
216
|
+
}), this.listeners.add(document, "click", this.handleClickFora), this.listeners.add(this.labelElement, "click", this.focarGatilho), this.listeners.add(this, "click", this.handleHostClick), this._defaultCapturado || (this._defaultValue = this.getAttribute("value") || "", this._defaultCapturado = !0), this.carregarItensFilhos(), this.syncState(), this.observer = new MutationObserver(() => this.carregarItensFilhos()), this.observer.observe(this, { childList: !0, subtree: !0 });
|
|
217
|
+
}
|
|
218
|
+
carregarItensFilhos() {
|
|
219
|
+
const t = Array.from(this.querySelectorAll('option, ui-opcao, [role="option"], [data-opcao], [data-value]:not(input):not(select)'));
|
|
220
|
+
t.length > 0 && (this._itens = t.map((e, s) => {
|
|
221
|
+
var n;
|
|
222
|
+
const r = e.getAttribute("value") || e.getAttribute("data-value") || String(s + 1);
|
|
223
|
+
return {
|
|
224
|
+
id: r,
|
|
225
|
+
label: ((n = e.textContent) == null ? void 0 : n.trim()) || r || `Opção ${s + 1}`
|
|
226
|
+
};
|
|
227
|
+
}), f(this.listElement, this._itens, this._value), this.syncLabel());
|
|
228
|
+
}
|
|
229
|
+
disconnectedCallback() {
|
|
230
|
+
this.listeners.cleanup(), this.observer && this.observer.disconnect(), this.fechar();
|
|
231
|
+
}
|
|
232
|
+
attributeChangedCallback(t, e, s) {
|
|
233
|
+
t === "aberta" && this.button.setAttribute("aria-expanded", String(s !== null)), (t === "texto-padrao" || t === "placeholder" || t === "label" || t === "rotulo" || t === "aria-label") && this.syncLabel(), t === "value" && s !== this._value && (this.value = s || ""), t === "disabled" && (this.button.disabled = this.disabled), (t === "altura" || t === "height") && (s ? this.style.setProperty("--ui-campo-altura", isNaN(Number(s)) ? s : `${s}px`) : this.style.removeProperty("--ui-campo-altura"));
|
|
234
|
+
}
|
|
235
|
+
get value() {
|
|
236
|
+
return this._value;
|
|
237
|
+
}
|
|
238
|
+
set value(t) {
|
|
239
|
+
this._value = t, this.setAttribute("value", t), this.internals.setFormValue(t), this.syncLabel(), z(this.listElement, this._value), this.atualizarValidade();
|
|
240
|
+
}
|
|
241
|
+
get label() {
|
|
242
|
+
return this.getAttribute("label") || this.getAttribute("rotulo") || "";
|
|
243
|
+
}
|
|
244
|
+
set label(t) {
|
|
245
|
+
t ? this.setAttribute("label", t) : (this.removeAttribute("label"), this.removeAttribute("rotulo")), this.syncLabel();
|
|
246
|
+
}
|
|
247
|
+
get disabled() {
|
|
248
|
+
return this.hasAttribute("disabled") || this._formDisabled;
|
|
249
|
+
}
|
|
250
|
+
set disabled(t) {
|
|
251
|
+
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled"), this.button.disabled = this.disabled;
|
|
252
|
+
}
|
|
253
|
+
get name() {
|
|
254
|
+
return this.getAttribute("name") || "";
|
|
255
|
+
}
|
|
256
|
+
set name(t) {
|
|
257
|
+
this.setAttribute("name", t);
|
|
258
|
+
}
|
|
259
|
+
get type() {
|
|
260
|
+
return "select-one";
|
|
261
|
+
}
|
|
262
|
+
atualizarValidade() {
|
|
263
|
+
if (!this.internals || typeof this.internals.setValidity != "function") return;
|
|
264
|
+
if (this.disabled) {
|
|
265
|
+
this.internals.setValidity({});
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (this._customErrorMessage) {
|
|
269
|
+
this.internals.setValidity({ customError: !0 }, this._customErrorMessage, this.button);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if ((this.hasAttribute("obrigatorio") || this.hasAttribute("required")) && (!this._value || this._value.trim() === "")) {
|
|
273
|
+
const e = this.getAttribute("mensagem-validacao") || "Selecione um item da lista.";
|
|
274
|
+
this.internals.setValidity({ valueMissing: !0 }, e, this.button);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
this.internals.setValidity({});
|
|
278
|
+
}
|
|
279
|
+
// === Ciclo de Vida Form-Associated Custom Elements (W3C FACE) ===
|
|
280
|
+
formDisabledCallback(t) {
|
|
281
|
+
this._formDisabled = t, this.button.disabled = this.disabled, this.disabled && this.fechar();
|
|
282
|
+
}
|
|
283
|
+
formResetCallback() {
|
|
284
|
+
this.value = this._defaultValue;
|
|
285
|
+
}
|
|
286
|
+
formStateRestoreCallback(t, e) {
|
|
287
|
+
typeof t == "string" && (this.value = t);
|
|
288
|
+
}
|
|
289
|
+
get itens() {
|
|
290
|
+
return this._itens;
|
|
291
|
+
}
|
|
292
|
+
set itens(t) {
|
|
293
|
+
this._itens = t || [], f(this.listElement, this._itens, this._value), this.syncLabel();
|
|
294
|
+
}
|
|
295
|
+
abrir() {
|
|
296
|
+
this.disabled || this.hasAttribute("aberta") || (this.setAttribute("aberta", ""), this.posicionamento.posicionar(), this.posicionamento.ativarAcompanhamento(this.fechar));
|
|
297
|
+
}
|
|
298
|
+
syncLabel() {
|
|
299
|
+
const t = this.getAttribute("label") || this.getAttribute("rotulo");
|
|
300
|
+
if (t)
|
|
301
|
+
w(this.labelElement, t, this.required, "ui-lista-flutuante__asterisco"), this.labelElement.style.display = "block", this.sheetTituloElement.textContent = t, this.button.setAttribute("aria-labelledby", `${this.idsAcessibilidade.label} ${this.idsAcessibilidade.texto}`), this.content.setAttribute("aria-labelledby", this.idsAcessibilidade.label), this.button.removeAttribute("aria-label"), this.content.removeAttribute("aria-label");
|
|
302
|
+
else {
|
|
303
|
+
this.labelElement.style.display = "none", this.sincronizarRotuloExterno();
|
|
304
|
+
const s = this.getAttribute("texto-padrao") || this.getAttribute("placeholder") || "Opções";
|
|
305
|
+
this.sheetTituloElement.textContent = s;
|
|
306
|
+
}
|
|
307
|
+
const e = this._itens.find((s) => String(s.id) === String(this._value));
|
|
308
|
+
if (e)
|
|
309
|
+
this.textoElement.textContent = e.label;
|
|
310
|
+
else {
|
|
311
|
+
const s = this.getAttribute("texto-padrao") || this.getAttribute("placeholder") || "Opções";
|
|
312
|
+
this.textoElement.textContent = s;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
/** Sem o atributo `label`, usa o rótulo de fora do Shadow DOM (aria-label, <label for>, <label> envolvente). */
|
|
316
|
+
sincronizarRotuloExterno() {
|
|
317
|
+
this.button.removeAttribute("aria-labelledby"), this.content.removeAttribute("aria-labelledby");
|
|
318
|
+
const t = g(this, this.internals);
|
|
319
|
+
t ? (this.button.setAttribute("aria-labelledby", `${this.idsAcessibilidade.gatilho} ${this.idsAcessibilidade.texto}`), this.button.setAttribute("aria-label", t), this.content.setAttribute("aria-label", t)) : (this.button.removeAttribute("aria-label"), this.content.removeAttribute("aria-label"));
|
|
320
|
+
}
|
|
321
|
+
syncState() {
|
|
322
|
+
const t = this.getAttribute("altura") || this.getAttribute("height");
|
|
323
|
+
t && this.style.setProperty("--ui-campo-altura", isNaN(Number(t)) ? t : `${t}px`), this.hasAttribute("value") && (this._value = this.getAttribute("value") || "", this.internals.setFormValue(this._value)), this.syncLabel(), this.atualizarValidade();
|
|
324
|
+
}
|
|
325
|
+
selecionarItem(t) {
|
|
326
|
+
var r;
|
|
327
|
+
const e = (r = this.shadowRoot) == null ? void 0 : r.activeElement, s = !!e && this.content.contains(e);
|
|
328
|
+
this.value = t.id, this.fechar(), s && this.button.focus(), this.dispatchEvent(
|
|
329
|
+
new CustomEvent("ui-selecionar", {
|
|
330
|
+
detail: t,
|
|
331
|
+
bubbles: !0,
|
|
332
|
+
composed: !0
|
|
333
|
+
})
|
|
334
|
+
), this.dispatchEvent(
|
|
335
|
+
new Event("input", {
|
|
336
|
+
bubbles: !0,
|
|
337
|
+
composed: !0
|
|
338
|
+
})
|
|
339
|
+
), this.dispatchEvent(
|
|
340
|
+
new Event("change", {
|
|
341
|
+
bubbles: !0,
|
|
342
|
+
composed: !0
|
|
343
|
+
})
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
class q extends x {
|
|
348
|
+
}
|
|
349
|
+
h("ui-lista-flutuante", x);
|
|
350
|
+
h("ui-select", q);
|
|
351
|
+
const D = ':host{display:inline-flex;align-items:center;box-sizing:border-box;font-family:var(--ui-fonte-base, "Inter", sans-serif);vertical-align:middle}.ui-checkbox{display:inline-flex;align-items:center;gap:8px;cursor:pointer;-webkit-user-select:none;user-select:none;line-height:1;outline:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent}.ui-checkbox--disabled{opacity:.5;cursor:not-allowed!important;pointer-events:none}.ui-checkbox__box{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;min-width:16px;min-height:16px;background-color:var(--ui-cor-fundo-elevado, #1a1a1e);border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .16));border-radius:var(--ui-raio-sm, 4px);box-sizing:border-box;transition:background-color .15s ease,border-color .15s ease,box-shadow .15s ease;flex-shrink:0}.ui-checkbox:focus-visible .ui-checkbox__box,.ui-checkbox--foco .ui-checkbox__box{border-color:var(--ui-cor-primaria, #00E08A);box-shadow:0 0 0 2px color-mix(in srgb,var(--ui-cor-primaria, #00E08A) 25%,transparent)}.ui-checkbox--checked .ui-checkbox__box,.ui-checkbox--indeterminate .ui-checkbox__box{background-color:var(--ui-cor-primaria, #00E08A);border-color:var(--ui-cor-primaria, #00E08A);color:var(--ui-cor-texto-sobre-primaria, #000000)}.ui-checkbox__mark{width:12px;height:12px;display:flex;align-items:center;justify-content:center;transition:transform .15s cubic-bezier(.4,0,.2,1),opacity .15s ease;transform:scale(0);opacity:0}.ui-checkbox--checked .ui-checkbox__mark,.ui-checkbox--indeterminate .ui-checkbox__mark{transform:scale(1);opacity:1}.ui-checkbox__mark svg{width:100%;height:100%;fill:none;stroke:currentColor;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;shape-rendering:geometricPrecision}.ui-checkbox__label{display:inline-flex;align-items:center;font-size:clamp(11px,.85rem,14px);color:var(--ui-cor-texto, #e1e1e6);line-height:1}.ui-checkbox--label-esquerda{flex-direction:row-reverse}@media (max-width: 640px){.ui-checkbox{min-height:40px;padding:4px 0}.ui-checkbox__box{width:20px;height:20px;min-width:20px;min-height:20px}.ui-checkbox__mark{width:14px;height:14px}.ui-checkbox__label{font-size:14px}}';
|
|
352
|
+
function p({ host: o, internals: i, controle: t, rotulo: e, texto: s }) {
|
|
353
|
+
if (s) {
|
|
354
|
+
e.textContent = s, e.style.display = "inline", t.setAttribute("aria-labelledby", e.id), t.removeAttribute("aria-label");
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
e.style.display = "none", t.removeAttribute("aria-labelledby");
|
|
358
|
+
const r = g(o, i);
|
|
359
|
+
r ? t.setAttribute("aria-label", r) : t.removeAttribute("aria-label");
|
|
360
|
+
}
|
|
361
|
+
class I extends d {
|
|
362
|
+
constructor() {
|
|
363
|
+
super();
|
|
364
|
+
a(this, "containerElement");
|
|
365
|
+
a(this, "markElement");
|
|
366
|
+
a(this, "labelElement");
|
|
367
|
+
a(this, "listeners", new u());
|
|
368
|
+
a(this, "_defaultChecked", !1);
|
|
369
|
+
a(this, "_defaultIndeterminate", !1);
|
|
370
|
+
a(this, "handleClick", (t) => {
|
|
371
|
+
t.preventDefault(), this.alternar();
|
|
372
|
+
});
|
|
373
|
+
a(this, "handleHostClick", (t) => {
|
|
374
|
+
m(this, t) && (this.alternar(), this.containerElement.focus());
|
|
375
|
+
});
|
|
376
|
+
a(this, "handleKeyDown", (t) => {
|
|
377
|
+
(t.key === " " || t.key === "Enter") && (t.preventDefault(), this.alternar());
|
|
378
|
+
});
|
|
379
|
+
a(this, "handleFocus", () => {
|
|
380
|
+
this.containerElement.classList.add("ui-checkbox--foco");
|
|
381
|
+
});
|
|
382
|
+
a(this, "handleBlur", () => {
|
|
383
|
+
this.containerElement.classList.remove("ui-checkbox--foco");
|
|
384
|
+
});
|
|
385
|
+
const t = this.attachShadow({ mode: "open" });
|
|
386
|
+
t.innerHTML = `
|
|
387
|
+
<style>${D}</style>
|
|
388
|
+
<div class="ui-checkbox" part="base" tabindex="0" role="checkbox" aria-checked="false">
|
|
389
|
+
<span class="ui-checkbox__box" part="controle">
|
|
390
|
+
<span class="ui-checkbox__mark" part="indicador"></span>
|
|
391
|
+
</span>
|
|
392
|
+
<span class="ui-checkbox__label" part="rotulo" style="display: none;"></span>
|
|
393
|
+
</div>
|
|
394
|
+
`, this.containerElement = t.querySelector(".ui-checkbox"), this.markElement = t.querySelector(".ui-checkbox__mark"), this.labelElement = t.querySelector(".ui-checkbox__label"), this.labelElement.id = b("ui-checkbox-label");
|
|
395
|
+
}
|
|
396
|
+
static get observedAttributes() {
|
|
397
|
+
return [
|
|
398
|
+
"marcado",
|
|
399
|
+
"checked",
|
|
400
|
+
"indeterminado",
|
|
401
|
+
"indeterminate",
|
|
402
|
+
"disabled",
|
|
403
|
+
"value",
|
|
404
|
+
"label",
|
|
405
|
+
"posicao-label",
|
|
406
|
+
"name",
|
|
407
|
+
"obrigatorio",
|
|
408
|
+
"required",
|
|
409
|
+
"mensagem-validacao"
|
|
410
|
+
];
|
|
411
|
+
}
|
|
412
|
+
connectedCallback() {
|
|
413
|
+
this.listeners.cleanup(), this.listeners.add(this.containerElement, "click", this.handleClick), this.listeners.add(this.containerElement, "keydown", this.handleKeyDown), this.listeners.add(this.containerElement, "focus", this.handleFocus), this.listeners.add(this.containerElement, "blur", this.handleBlur), this.listeners.add(this, "click", this.handleHostClick), this._defaultChecked = this.hasAttribute("marcado") || this.hasAttribute("checked"), this._defaultIndeterminate = this.hasAttribute("indeterminado") || this.hasAttribute("indeterminate"), this.syncState();
|
|
414
|
+
}
|
|
415
|
+
disconnectedCallback() {
|
|
416
|
+
this.listeners.cleanup();
|
|
417
|
+
}
|
|
418
|
+
attributeChangedCallback(t, e, s) {
|
|
419
|
+
this.syncState();
|
|
420
|
+
}
|
|
421
|
+
get marcado() {
|
|
422
|
+
return this.hasAttribute("marcado") || this.hasAttribute("checked");
|
|
423
|
+
}
|
|
424
|
+
set marcado(t) {
|
|
425
|
+
t ? this.setAttribute("marcado", "") : (this.removeAttribute("marcado"), this.removeAttribute("checked")), this.syncState();
|
|
426
|
+
}
|
|
427
|
+
get checked() {
|
|
428
|
+
return this.marcado;
|
|
429
|
+
}
|
|
430
|
+
set checked(t) {
|
|
431
|
+
this.marcado = t;
|
|
432
|
+
}
|
|
433
|
+
get value() {
|
|
434
|
+
return this.getAttribute("value") || "on";
|
|
435
|
+
}
|
|
436
|
+
set value(t) {
|
|
437
|
+
this.setAttribute("value", t), this.syncState();
|
|
438
|
+
}
|
|
439
|
+
get name() {
|
|
440
|
+
return this.getAttribute("name") || "";
|
|
441
|
+
}
|
|
442
|
+
set name(t) {
|
|
443
|
+
this.setAttribute("name", t), this.syncState();
|
|
444
|
+
}
|
|
445
|
+
get indeterminado() {
|
|
446
|
+
return this.hasAttribute("indeterminado") || this.hasAttribute("indeterminate");
|
|
447
|
+
}
|
|
448
|
+
set indeterminado(t) {
|
|
449
|
+
t ? this.setAttribute("indeterminado", "") : (this.removeAttribute("indeterminado"), this.removeAttribute("indeterminate")), this.syncState();
|
|
450
|
+
}
|
|
451
|
+
get disabled() {
|
|
452
|
+
return this.hasAttribute("disabled") || this._formDisabled;
|
|
453
|
+
}
|
|
454
|
+
set disabled(t) {
|
|
455
|
+
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled"), this.syncState();
|
|
456
|
+
}
|
|
457
|
+
get type() {
|
|
458
|
+
return "checkbox";
|
|
459
|
+
}
|
|
460
|
+
atualizarValidade() {
|
|
461
|
+
if (!this.internals || typeof this.internals.setValidity != "function") return;
|
|
462
|
+
if (this.disabled) {
|
|
463
|
+
this.internals.setValidity({});
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
if (this._customErrorMessage) {
|
|
467
|
+
this.internals.setValidity({ customError: !0 }, this._customErrorMessage, this.containerElement);
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
if ((this.hasAttribute("obrigatorio") || this.hasAttribute("required")) && !this.marcado) {
|
|
471
|
+
const e = this.getAttribute("mensagem-validacao") || "Marque esta caixa para continuar.";
|
|
472
|
+
this.internals.setValidity({ valueMissing: !0 }, e, this.containerElement);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
this.internals.setValidity({});
|
|
476
|
+
}
|
|
477
|
+
/** `focus()` no host leva o foco ao controle interno (necessário para o foco de validação do formulário). */
|
|
478
|
+
focus(t) {
|
|
479
|
+
this.containerElement.focus(t);
|
|
480
|
+
}
|
|
481
|
+
alternar() {
|
|
482
|
+
this.disabled || (this.indeterminado ? (this.indeterminado = !1, this.marcado = !0) : this.marcado = !this.marcado, this.dispatchEvent(
|
|
483
|
+
new CustomEvent("ui-change", {
|
|
484
|
+
detail: {
|
|
485
|
+
marcado: this.marcado,
|
|
486
|
+
indeterminado: this.indeterminado,
|
|
487
|
+
value: this.getAttribute("value") || ""
|
|
488
|
+
},
|
|
489
|
+
bubbles: !0,
|
|
490
|
+
composed: !0
|
|
491
|
+
})
|
|
492
|
+
), this.dispatchEvent(
|
|
493
|
+
new Event("change", {
|
|
494
|
+
bubbles: !0,
|
|
495
|
+
composed: !0
|
|
496
|
+
})
|
|
497
|
+
));
|
|
498
|
+
}
|
|
499
|
+
syncState() {
|
|
500
|
+
const t = this.marcado, e = this.indeterminado, s = this.disabled, r = this.getAttribute("label"), n = this.getAttribute("posicao-label") || "direita";
|
|
501
|
+
this.containerElement.setAttribute(
|
|
502
|
+
"aria-checked",
|
|
503
|
+
e ? "mixed" : String(t)
|
|
504
|
+
), s ? (this.containerElement.classList.add("ui-checkbox--disabled"), this.containerElement.setAttribute("tabindex", "-1"), this.containerElement.setAttribute("aria-disabled", "true")) : (this.containerElement.classList.remove("ui-checkbox--disabled"), this.containerElement.setAttribute("tabindex", "0"), this.containerElement.removeAttribute("aria-disabled")), t ? this.containerElement.classList.add("ui-checkbox--checked") : this.containerElement.classList.remove("ui-checkbox--checked"), e ? this.containerElement.classList.add("ui-checkbox--indeterminate") : this.containerElement.classList.remove("ui-checkbox--indeterminate"), n === "esquerda" ? this.containerElement.classList.add("ui-checkbox--label-esquerda") : this.containerElement.classList.remove("ui-checkbox--label-esquerda"), e ? this.markElement.innerHTML = `
|
|
505
|
+
<svg viewBox="0 0 24 24">
|
|
506
|
+
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
507
|
+
</svg>
|
|
508
|
+
` : t ? this.markElement.innerHTML = `
|
|
509
|
+
<svg viewBox="0 0 24 24">
|
|
510
|
+
<polyline points="20 6 9 17 4 12"></polyline>
|
|
511
|
+
</svg>
|
|
512
|
+
` : this.markElement.innerHTML = "", p({
|
|
513
|
+
host: this,
|
|
514
|
+
internals: this.internals,
|
|
515
|
+
controle: this.containerElement,
|
|
516
|
+
rotulo: this.labelElement,
|
|
517
|
+
texto: r
|
|
518
|
+
}), t ? this.internals.setFormValue(this.getAttribute("value") || "on") : this.internals.setFormValue(null), this.atualizarValidade();
|
|
519
|
+
}
|
|
520
|
+
// === Ciclo de Vida Form-Associated Custom Elements (W3C FACE) ===
|
|
521
|
+
formResetCallback() {
|
|
522
|
+
this.marcado = this._defaultChecked, this.indeterminado = this._defaultIndeterminate, this.syncState();
|
|
523
|
+
}
|
|
524
|
+
formStateRestoreCallback(t, e) {
|
|
525
|
+
typeof t == "string" ? this.marcado = t === (this.getAttribute("value") || "on") : typeof t == "boolean" && (this.marcado = t), this.syncState();
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
h("ui-checkbox", I);
|
|
529
|
+
const V = ':host{display:inline-flex;align-items:center;box-sizing:border-box;font-family:var(--ui-fonte-base, "Inter", sans-serif);vertical-align:middle}.ui-radio{display:inline-flex;align-items:center;gap:8px;cursor:pointer;-webkit-user-select:none;user-select:none;line-height:1;outline:none}.ui-radio--disabled{opacity:.5;cursor:not-allowed!important;pointer-events:none}.ui-radio__circle{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;min-width:16px;min-height:16px;background-color:var(--ui-cor-fundo-elevado, #1a1a1e);border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .16));border-radius:50%;box-sizing:border-box;transition:background-color .15s ease,border-color .15s ease,box-shadow .15s ease;flex-shrink:0}.ui-radio:focus-visible .ui-radio__circle,.ui-radio--foco .ui-radio__circle{border-color:var(--ui-cor-primaria, #00E08A);box-shadow:0 0 0 2px color-mix(in srgb,var(--ui-cor-primaria, #00E08A) 25%,transparent)}.ui-radio--checked .ui-radio__circle{border-color:var(--ui-cor-primaria, #00E08A)}.ui-radio__dot{width:8px;height:8px;border-radius:50%;background-color:var(--ui-cor-primaria, #00E08A);transition:transform .15s cubic-bezier(.4,0,.2,1),opacity .15s ease;transform:scale(0);opacity:0}.ui-radio--checked .ui-radio__dot{transform:scale(1);opacity:1}.ui-radio__label{display:inline-flex;align-items:center;font-size:clamp(11px,.85rem,14px);color:var(--ui-cor-texto, #e1e1e6);line-height:1}.ui-radio--label-esquerda{flex-direction:row-reverse}';
|
|
530
|
+
class l {
|
|
531
|
+
static getScopeNode(i) {
|
|
532
|
+
return i.closest("form") || i.getRootNode() || document;
|
|
533
|
+
}
|
|
534
|
+
/** Registra (ou re-registra, se o nome ou o escopo mudaram) o radio no grupo do seu nome atual. */
|
|
535
|
+
static registrar(i) {
|
|
536
|
+
this.desregistrar(i);
|
|
537
|
+
const t = i.name;
|
|
538
|
+
if (!t) return;
|
|
539
|
+
const e = this.getScopeNode(i);
|
|
540
|
+
let s = this.registry.get(e);
|
|
541
|
+
s || (s = /* @__PURE__ */ new Map(), this.registry.set(e, s));
|
|
542
|
+
let r = s.get(t);
|
|
543
|
+
r || (r = /* @__PURE__ */ new Set(), s.set(t, r)), r.add(i), this.registros.set(i, { scope: e, nome: t });
|
|
544
|
+
}
|
|
545
|
+
static desregistrar(i) {
|
|
546
|
+
const t = this.registros.get(i);
|
|
547
|
+
if (!t) return;
|
|
548
|
+
this.registros.delete(i);
|
|
549
|
+
const e = this.registry.get(t.scope), s = e == null ? void 0 : e.get(t.nome);
|
|
550
|
+
!e || !s || (s.delete(i), s.size === 0 && e.delete(t.nome), e.size === 0 && this.registry.delete(t.scope));
|
|
551
|
+
}
|
|
552
|
+
/** Radios do mesmo grupo que `radio`, usando o registro (não o nome atual, que pode ainda não ter sido registrado). */
|
|
553
|
+
static obterRadiosDoGrupo(i) {
|
|
554
|
+
var s;
|
|
555
|
+
const t = this.registros.get(i);
|
|
556
|
+
if (!t) return [];
|
|
557
|
+
const e = (s = this.registry.get(t.scope)) == null ? void 0 : s.get(t.nome);
|
|
558
|
+
return e ? Array.from(e) : [];
|
|
559
|
+
}
|
|
560
|
+
static desmarcarOutros(i) {
|
|
561
|
+
this.obterRadiosDoGrupo(i).forEach((t) => {
|
|
562
|
+
t !== i && (t.removeAttribute("marcado"), t.removeAttribute("checked"), t.syncState());
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
/** Reavalia o tabindex (roving) dos radios; use depois de entrar, sair ou mudar de grupo. */
|
|
566
|
+
static atualizarGrupo(i) {
|
|
567
|
+
i.forEach((t) => t.atualizarTabindex());
|
|
568
|
+
}
|
|
569
|
+
static tratarNavegacaoTeclado(i, t) {
|
|
570
|
+
if (!["ArrowDown", "ArrowRight", "ArrowUp", "ArrowLeft"].includes(i.key)) return;
|
|
571
|
+
i.preventDefault();
|
|
572
|
+
const e = this.obterRadiosDoGrupo(t).filter((c) => !c.disabled && c.isConnected);
|
|
573
|
+
if (e.length <= 1) return;
|
|
574
|
+
const s = e.indexOf(t), r = i.key === "ArrowDown" || i.key === "ArrowRight", n = (s + (r ? 1 : -1) + e.length) % e.length;
|
|
575
|
+
if (n !== s) {
|
|
576
|
+
const c = e[n];
|
|
577
|
+
c.selecionar(), c.focus();
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
a(l, "registry", /* @__PURE__ */ new WeakMap()), a(l, "registros", /* @__PURE__ */ new WeakMap());
|
|
582
|
+
class R extends d {
|
|
583
|
+
constructor() {
|
|
584
|
+
super();
|
|
585
|
+
a(this, "containerElement");
|
|
586
|
+
a(this, "labelElement");
|
|
587
|
+
a(this, "listeners", new u());
|
|
588
|
+
a(this, "_defaultChecked", !1);
|
|
589
|
+
a(this, "handleClick", (t) => {
|
|
590
|
+
t.preventDefault(), this.selecionar(), this.containerElement.focus();
|
|
591
|
+
});
|
|
592
|
+
a(this, "handleHostClick", (t) => {
|
|
593
|
+
m(this, t) && (this.selecionar(), this.containerElement.focus());
|
|
594
|
+
});
|
|
595
|
+
a(this, "handleKeyDown", (t) => {
|
|
596
|
+
t.key === " " || t.key === "Enter" ? (t.preventDefault(), this.selecionar()) : l.tratarNavegacaoTeclado(t, this);
|
|
597
|
+
});
|
|
598
|
+
a(this, "handleFocus", () => {
|
|
599
|
+
this.containerElement.classList.add("ui-radio--foco");
|
|
600
|
+
});
|
|
601
|
+
a(this, "handleBlur", () => {
|
|
602
|
+
this.containerElement.classList.remove("ui-radio--foco");
|
|
603
|
+
});
|
|
604
|
+
const t = this.attachShadow({ mode: "open" });
|
|
605
|
+
t.innerHTML = `
|
|
606
|
+
<style>${V}</style>
|
|
607
|
+
<div class="ui-radio" part="base" tabindex="0" role="radio" aria-checked="false">
|
|
608
|
+
<span class="ui-radio__circle" part="controle">
|
|
609
|
+
<span class="ui-radio__dot" part="indicador"></span>
|
|
610
|
+
</span>
|
|
611
|
+
<span class="ui-radio__label" part="rotulo" style="display: none;"></span>
|
|
612
|
+
</div>
|
|
613
|
+
`, this.containerElement = t.querySelector(".ui-radio"), this.labelElement = t.querySelector(".ui-radio__label"), this.labelElement.id = b("ui-radio-label");
|
|
614
|
+
}
|
|
615
|
+
static get observedAttributes() {
|
|
616
|
+
return [
|
|
617
|
+
"marcado",
|
|
618
|
+
"checked",
|
|
619
|
+
"name",
|
|
620
|
+
"nome",
|
|
621
|
+
"disabled",
|
|
622
|
+
"value",
|
|
623
|
+
"label",
|
|
624
|
+
"posicao-label",
|
|
625
|
+
"obrigatorio",
|
|
626
|
+
"required",
|
|
627
|
+
"mensagem-validacao"
|
|
628
|
+
];
|
|
629
|
+
}
|
|
630
|
+
connectedCallback() {
|
|
631
|
+
this.listeners.cleanup(), this.listeners.add(this.containerElement, "click", this.handleClick), this.listeners.add(this.containerElement, "keydown", this.handleKeyDown), this.listeners.add(this.containerElement, "focus", this.handleFocus), this.listeners.add(this.containerElement, "blur", this.handleBlur), this.listeners.add(this, "click", this.handleHostClick), this._defaultChecked = this.hasAttribute("marcado") || this.hasAttribute("checked"), l.registrar(this), this.syncState(), l.atualizarGrupo(l.obterRadiosDoGrupo(this).filter((t) => t !== this));
|
|
632
|
+
}
|
|
633
|
+
disconnectedCallback() {
|
|
634
|
+
this.listeners.cleanup();
|
|
635
|
+
const t = l.obterRadiosDoGrupo(this).filter((e) => e !== this && e.isConnected);
|
|
636
|
+
l.desregistrar(this), l.atualizarGrupo(t);
|
|
637
|
+
}
|
|
638
|
+
attributeChangedCallback(t, e, s) {
|
|
639
|
+
if ((t === "name" || t === "nome") && this.isConnected) {
|
|
640
|
+
const r = l.obterRadiosDoGrupo(this).filter((n) => n !== this);
|
|
641
|
+
l.registrar(this), this.syncState(), l.atualizarGrupo([...r, ...l.obterRadiosDoGrupo(this).filter((n) => n !== this)]);
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
this.syncState();
|
|
645
|
+
}
|
|
646
|
+
get marcado() {
|
|
647
|
+
return this.hasAttribute("marcado") || this.hasAttribute("checked");
|
|
648
|
+
}
|
|
649
|
+
set marcado(t) {
|
|
650
|
+
t ? this.setAttribute("marcado", "") : (this.removeAttribute("marcado"), this.removeAttribute("checked"));
|
|
651
|
+
}
|
|
652
|
+
get name() {
|
|
653
|
+
return this.getAttribute("name") || this.getAttribute("nome") || "";
|
|
654
|
+
}
|
|
655
|
+
set name(t) {
|
|
656
|
+
this.setAttribute("name", t);
|
|
657
|
+
}
|
|
658
|
+
get disabled() {
|
|
659
|
+
return this.hasAttribute("disabled") || this._formDisabled;
|
|
660
|
+
}
|
|
661
|
+
set disabled(t) {
|
|
662
|
+
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled"), this.syncState();
|
|
663
|
+
}
|
|
664
|
+
get type() {
|
|
665
|
+
return "radio";
|
|
666
|
+
}
|
|
667
|
+
atualizarValidade() {
|
|
668
|
+
if (!this.internals || typeof this.internals.setValidity != "function") return;
|
|
669
|
+
if (this.disabled) {
|
|
670
|
+
this.internals.setValidity({});
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
if (this._customErrorMessage) {
|
|
674
|
+
this.internals.setValidity({ customError: !0 }, this._customErrorMessage, this.containerElement);
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
const t = l.obterRadiosDoGrupo(this);
|
|
678
|
+
if ((this.required || t.length > 0 && t.some((s) => s.required)) && !(this.marcado || t.length > 0 && t.some((r) => r.marcado))) {
|
|
679
|
+
const r = this.getAttribute("mensagem-validacao") || "Selecione uma opção.";
|
|
680
|
+
this.internals.setValidity({ valueMissing: !0 }, r, this.containerElement);
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
this.internals.setValidity({});
|
|
684
|
+
}
|
|
685
|
+
focus(t) {
|
|
686
|
+
this.containerElement.focus(t);
|
|
687
|
+
}
|
|
688
|
+
selecionar() {
|
|
689
|
+
this.disabled || this.marcado || (this.marcado = !0, l.desmarcarOutros(this), this.dispatchEvent(
|
|
690
|
+
new CustomEvent("ui-change", {
|
|
691
|
+
detail: {
|
|
692
|
+
marcado: !0,
|
|
693
|
+
name: this.name,
|
|
694
|
+
value: this.getAttribute("value") || ""
|
|
695
|
+
},
|
|
696
|
+
bubbles: !0,
|
|
697
|
+
composed: !0
|
|
698
|
+
})
|
|
699
|
+
), this.dispatchEvent(
|
|
700
|
+
new Event("change", {
|
|
701
|
+
bubbles: !0,
|
|
702
|
+
composed: !0
|
|
703
|
+
})
|
|
704
|
+
), l.obterRadiosDoGrupo(this).forEach((t) => t.atualizarValidade()));
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Roving tabindex: só um radio do grupo entra na ordem de Tab (o marcado; sem marcado, o primeiro habilitado).
|
|
708
|
+
* Isolado de `syncState` para reavaliar os vizinhos sem mexer no valor/validade do formulário.
|
|
709
|
+
*/
|
|
710
|
+
atualizarTabindex() {
|
|
711
|
+
if (this.disabled) {
|
|
712
|
+
this.containerElement.setAttribute("tabindex", "-1");
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
const t = l.obterRadiosDoGrupo(this).filter((e) => e.isConnected || e === this);
|
|
716
|
+
if (t.length === 0) {
|
|
717
|
+
this.containerElement.setAttribute("tabindex", "0");
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (t.some((e) => e.marcado))
|
|
721
|
+
this.containerElement.setAttribute("tabindex", this.marcado ? "0" : "-1");
|
|
722
|
+
else {
|
|
723
|
+
const e = t.find((s) => !s.disabled);
|
|
724
|
+
this.containerElement.setAttribute("tabindex", e === this ? "0" : "-1");
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
syncState() {
|
|
728
|
+
const t = this.marcado, e = this.disabled, s = this.getAttribute("label"), r = this.getAttribute("posicao-label") || "direita";
|
|
729
|
+
this.containerElement.setAttribute("aria-checked", String(t)), this.atualizarTabindex(), e ? (this.containerElement.classList.add("ui-radio--disabled"), this.containerElement.setAttribute("aria-disabled", "true")) : (this.containerElement.classList.remove("ui-radio--disabled"), this.containerElement.removeAttribute("aria-disabled")), t ? this.containerElement.classList.add("ui-radio--checked") : this.containerElement.classList.remove("ui-radio--checked"), r === "esquerda" ? this.containerElement.classList.add("ui-radio--label-esquerda") : this.containerElement.classList.remove("ui-radio--label-esquerda"), p({
|
|
730
|
+
host: this,
|
|
731
|
+
internals: this.internals,
|
|
732
|
+
controle: this.containerElement,
|
|
733
|
+
rotulo: this.labelElement,
|
|
734
|
+
texto: s
|
|
735
|
+
}), t ? this.internals.setFormValue(this.getAttribute("value") || "on") : this.internals.setFormValue(null), this.atualizarValidade();
|
|
736
|
+
}
|
|
737
|
+
// === Ciclo de Vida Form-Associated Custom Elements (W3C FACE) ===
|
|
738
|
+
formResetCallback() {
|
|
739
|
+
this.marcado = this._defaultChecked, this._defaultChecked ? this.internals.setFormValue(this.getAttribute("value") || "on") : this.internals.setFormValue(null), this.atualizarValidade();
|
|
740
|
+
}
|
|
741
|
+
formStateRestoreCallback(t, e) {
|
|
742
|
+
typeof t == "string" ? this.marcado = t === (this.getAttribute("value") || "on") : typeof t == "boolean" && (this.marcado = t), this.syncState();
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
h("ui-radio", R);
|
|
746
|
+
const M = ':host{display:inline-flex;align-items:center;box-sizing:border-box;font-family:var(--ui-fonte-base, "Inter", sans-serif);vertical-align:middle}.ui-switch{display:inline-flex;align-items:center;gap:8px;cursor:pointer;-webkit-user-select:none;user-select:none;line-height:1;outline:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent}.ui-switch--disabled{opacity:.5;cursor:not-allowed!important;pointer-events:none}.ui-switch__track{display:inline-flex;align-items:center;position:relative;width:36px;height:20px;background-color:var(--ui-cor-fundo-elevado, #1a1a1e);border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .16));border-radius:var(--ui-raio-pill, 999px);box-sizing:border-box;padding:1px;transition:background-color .2s ease,border-color .2s ease,box-shadow .2s ease;flex-shrink:0}.ui-switch:focus-visible .ui-switch__track,.ui-switch--foco .ui-switch__track{border-color:var(--ui-cor-primaria, #00E08A);box-shadow:0 0 0 2px color-mix(in srgb,var(--ui-cor-primaria, #00E08A) 25%,transparent)}.ui-switch--checked .ui-switch__track{background-color:var(--ui-cor-primaria, #00E08A);border-color:var(--ui-cor-primaria, #00E08A)}.ui-switch__thumb{display:block;width:16px;height:16px;background-color:#fff;border-radius:50%;box-shadow:var(--ui-sombra-sm, 0 1px 3px rgba(0, 0, 0, .3));transition:transform .2s cubic-bezier(.4,0,.2,1),background-color .2s ease;transform:translate(0)}.ui-switch--checked .ui-switch__thumb{transform:translate(16px);background-color:var(--ui-cor-texto-sobre-primaria, #000000)}.ui-switch--sm .ui-switch__track{width:28px;height:16px;padding:1px}.ui-switch--sm .ui-switch__thumb{width:12px;height:12px}.ui-switch--sm.ui-switch--checked .ui-switch__thumb{transform:translate(12px)}.ui-switch--lg .ui-switch__track{width:44px;height:24px;padding:1px}.ui-switch--lg .ui-switch__thumb{width:20px;height:20px}.ui-switch--lg.ui-switch--checked .ui-switch__thumb{transform:translate(20px)}.ui-switch__label{display:inline-flex;align-items:center;font-size:clamp(11px,.85rem,14px);color:var(--ui-cor-texto, #e1e1e6);line-height:1}.ui-switch--label-esquerda{flex-direction:row-reverse}@media (max-width: 640px){.ui-switch{min-height:40px;padding:4px 0}.ui-switch__label{font-size:14px}}';
|
|
747
|
+
class v extends d {
|
|
748
|
+
constructor() {
|
|
749
|
+
super();
|
|
750
|
+
a(this, "containerElement");
|
|
751
|
+
a(this, "labelElement");
|
|
752
|
+
a(this, "labelId");
|
|
753
|
+
a(this, "listeners", new u());
|
|
754
|
+
a(this, "_defaultChecked", !1);
|
|
755
|
+
a(this, "handleClick", (t) => {
|
|
756
|
+
t.preventDefault(), this.alternar();
|
|
757
|
+
});
|
|
758
|
+
a(this, "handleHostClick", (t) => {
|
|
759
|
+
m(this, t) && (this.alternar(), this.containerElement.focus());
|
|
760
|
+
});
|
|
761
|
+
a(this, "handleKeyDown", (t) => {
|
|
762
|
+
(t.key === " " || t.key === "Enter") && (t.preventDefault(), this.alternar());
|
|
763
|
+
});
|
|
764
|
+
a(this, "handleFocus", () => {
|
|
765
|
+
this.containerElement.classList.add("ui-switch--foco");
|
|
766
|
+
});
|
|
767
|
+
a(this, "handleBlur", () => {
|
|
768
|
+
this.containerElement.classList.remove("ui-switch--foco");
|
|
769
|
+
});
|
|
770
|
+
const t = this.attachShadow({ mode: "open" });
|
|
771
|
+
t.innerHTML = `
|
|
772
|
+
<style>${M}</style>
|
|
773
|
+
<div class="ui-switch" part="base" tabindex="0" role="switch" aria-checked="false">
|
|
774
|
+
<span class="ui-switch__track" part="controle">
|
|
775
|
+
<span class="ui-switch__thumb" part="indicador"></span>
|
|
776
|
+
</span>
|
|
777
|
+
<span class="ui-switch__label" part="rotulo" style="display: none;"></span>
|
|
778
|
+
</div>
|
|
779
|
+
`, this.containerElement = t.querySelector(".ui-switch"), this.labelElement = t.querySelector(".ui-switch__label"), this.labelId = b("ui-switch-label"), this.labelElement.id = this.labelId;
|
|
780
|
+
}
|
|
781
|
+
static get observedAttributes() {
|
|
782
|
+
return [
|
|
783
|
+
"ativo",
|
|
784
|
+
"ligado",
|
|
785
|
+
"checked",
|
|
786
|
+
"disabled",
|
|
787
|
+
"tamanho",
|
|
788
|
+
"size",
|
|
789
|
+
"label",
|
|
790
|
+
"posicao-label",
|
|
791
|
+
"value",
|
|
792
|
+
"name",
|
|
793
|
+
"obrigatorio",
|
|
794
|
+
"required",
|
|
795
|
+
"mensagem-validacao",
|
|
796
|
+
"aria-label"
|
|
797
|
+
];
|
|
798
|
+
}
|
|
799
|
+
connectedCallback() {
|
|
800
|
+
this.listeners.cleanup(), this.listeners.add(this.containerElement, "click", this.handleClick), this.listeners.add(this.containerElement, "keydown", this.handleKeyDown), this.listeners.add(this.containerElement, "focus", this.handleFocus), this.listeners.add(this.containerElement, "blur", this.handleBlur), this.listeners.add(this, "click", this.handleHostClick), this._defaultChecked = this.hasAttribute("ativo") || this.hasAttribute("ligado") || this.hasAttribute("checked"), this.syncState();
|
|
801
|
+
}
|
|
802
|
+
disconnectedCallback() {
|
|
803
|
+
this.listeners.cleanup();
|
|
804
|
+
}
|
|
805
|
+
attributeChangedCallback(t, e, s) {
|
|
806
|
+
this.syncState();
|
|
807
|
+
}
|
|
808
|
+
get ativo() {
|
|
809
|
+
return this.hasAttribute("ativo") || this.hasAttribute("ligado") || this.hasAttribute("checked");
|
|
810
|
+
}
|
|
811
|
+
set ativo(t) {
|
|
812
|
+
t ? this.setAttribute("ativo", "") : (this.removeAttribute("ativo"), this.removeAttribute("ligado"), this.removeAttribute("checked")), this.syncState();
|
|
813
|
+
}
|
|
814
|
+
get checked() {
|
|
815
|
+
return this.ativo;
|
|
816
|
+
}
|
|
817
|
+
set checked(t) {
|
|
818
|
+
this.ativo = t;
|
|
819
|
+
}
|
|
820
|
+
get value() {
|
|
821
|
+
return this.getAttribute("value") || "on";
|
|
822
|
+
}
|
|
823
|
+
set value(t) {
|
|
824
|
+
this.setAttribute("value", t), this.syncState();
|
|
825
|
+
}
|
|
826
|
+
get name() {
|
|
827
|
+
return this.getAttribute("name") || "";
|
|
828
|
+
}
|
|
829
|
+
set name(t) {
|
|
830
|
+
this.setAttribute("name", t), this.syncState();
|
|
831
|
+
}
|
|
832
|
+
get disabled() {
|
|
833
|
+
return this.hasAttribute("disabled") || this._formDisabled;
|
|
834
|
+
}
|
|
835
|
+
set disabled(t) {
|
|
836
|
+
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled"), this.syncState();
|
|
837
|
+
}
|
|
838
|
+
get type() {
|
|
839
|
+
return "checkbox";
|
|
840
|
+
}
|
|
841
|
+
atualizarValidade() {
|
|
842
|
+
if (!this.internals || typeof this.internals.setValidity != "function") return;
|
|
843
|
+
if (this.disabled) {
|
|
844
|
+
this.internals.setValidity({});
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
if (this._customErrorMessage) {
|
|
848
|
+
this.internals.setValidity({ customError: !0 }, this._customErrorMessage, this.containerElement);
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
if ((this.hasAttribute("obrigatorio") || this.hasAttribute("required")) && !this.ativo) {
|
|
852
|
+
const e = this.getAttribute("mensagem-validacao") || "Ative este interruptor para continuar.";
|
|
853
|
+
this.internals.setValidity({ valueMissing: !0 }, e, this.containerElement);
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
this.internals.setValidity({});
|
|
857
|
+
}
|
|
858
|
+
/** `focus()` no host leva o foco ao controle interno (necessário para o foco de validação do formulário). */
|
|
859
|
+
focus(t) {
|
|
860
|
+
this.containerElement.focus(t);
|
|
861
|
+
}
|
|
862
|
+
alternar() {
|
|
863
|
+
this.disabled || (this.ativo = !this.ativo, this.dispatchEvent(
|
|
864
|
+
new CustomEvent("ui-change", {
|
|
865
|
+
detail: {
|
|
866
|
+
ativo: this.ativo,
|
|
867
|
+
value: this.getAttribute("value") || ""
|
|
868
|
+
},
|
|
869
|
+
bubbles: !0,
|
|
870
|
+
composed: !0
|
|
871
|
+
})
|
|
872
|
+
), this.dispatchEvent(
|
|
873
|
+
new Event("change", {
|
|
874
|
+
bubbles: !0,
|
|
875
|
+
composed: !0
|
|
876
|
+
})
|
|
877
|
+
));
|
|
878
|
+
}
|
|
879
|
+
syncState() {
|
|
880
|
+
const t = this.ativo, e = this.disabled, s = this.getAttribute("tamanho") || this.getAttribute("size") || "md", r = this.getAttribute("label"), n = this.getAttribute("posicao-label") || "direita";
|
|
881
|
+
this.containerElement.setAttribute("aria-checked", String(t)), e ? (this.containerElement.classList.add("ui-switch--disabled"), this.containerElement.setAttribute("tabindex", "-1"), this.containerElement.setAttribute("aria-disabled", "true")) : (this.containerElement.classList.remove("ui-switch--disabled"), this.containerElement.setAttribute("tabindex", "0"), this.containerElement.removeAttribute("aria-disabled")), t ? this.containerElement.classList.add("ui-switch--checked") : this.containerElement.classList.remove("ui-switch--checked"), this.containerElement.classList.remove("ui-switch--sm", "ui-switch--md", "ui-switch--lg"), ["sm", "md", "lg"].includes(s) ? this.containerElement.classList.add(`ui-switch--${s}`) : this.containerElement.classList.add("ui-switch--md"), n === "esquerda" ? this.containerElement.classList.add("ui-switch--label-esquerda") : this.containerElement.classList.remove("ui-switch--label-esquerda"), p({
|
|
882
|
+
host: this,
|
|
883
|
+
internals: this.internals,
|
|
884
|
+
controle: this.containerElement,
|
|
885
|
+
rotulo: this.labelElement,
|
|
886
|
+
texto: r
|
|
887
|
+
}), t ? this.internals.setFormValue(this.getAttribute("value") || "on") : this.internals.setFormValue(null), this.atualizarValidade();
|
|
888
|
+
}
|
|
889
|
+
// === Ciclo de Vida Form-Associated Custom Elements (W3C FACE) ===
|
|
890
|
+
formResetCallback() {
|
|
891
|
+
this.ativo = this._defaultChecked, this.syncState();
|
|
892
|
+
}
|
|
893
|
+
formStateRestoreCallback(t, e) {
|
|
894
|
+
typeof t == "string" ? this.ativo = t === (this.getAttribute("value") || "on") : typeof t == "boolean" && (this.ativo = t), this.syncState();
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
class F extends v {
|
|
898
|
+
}
|
|
899
|
+
h("ui-switch", v);
|
|
900
|
+
h("ui-toggle", F);
|
|
901
|
+
export {
|
|
902
|
+
C as A,
|
|
903
|
+
A as L,
|
|
904
|
+
l as R,
|
|
905
|
+
I as U,
|
|
906
|
+
E as a,
|
|
907
|
+
x as b,
|
|
908
|
+
R as c,
|
|
909
|
+
q as d,
|
|
910
|
+
v as e,
|
|
911
|
+
F as f,
|
|
912
|
+
z as g,
|
|
913
|
+
L as h,
|
|
914
|
+
f as r
|
|
915
|
+
};
|