@thibezer/ui-components-kit 2.26.1 → 2.28.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 +19 -0
- package/README.md +822 -822
- package/dist/canvas.cjs +61 -61
- package/dist/canvas.js +1228 -1143
- package/dist/components/ui-canvas-cad/ui-canvas-cad.d.ts +6 -0
- package/dist/components/ui-cores/ui-controle-cores.d.ts +5 -1
- package/dist/cores.cjs +2 -2
- package/dist/cores.js +80 -80
- package/dist/custom-elements.json +21802 -21782
- package/dist/gerencigeo-canvas/index.d.ts +2 -0
- package/dist/gerencigeo-canvas/mapa_core.d.ts +5 -0
- package/dist/gerencigeo-canvas/sigef_consultor.d.ts +24 -8
- package/dist/gerencigeo-canvas/sigef_dados.d.ts +46 -0
- package/dist/tipos-elementos.d.ts +3 -1
- package/dist/tipos-vue.d.ts +3 -1
- package/package.json +1 -1
|
@@ -92,6 +92,12 @@ export declare class UICanvasCAD extends SafeHTMLElement {
|
|
|
92
92
|
*/
|
|
93
93
|
get aceitarOrigem(): boolean;
|
|
94
94
|
set aceitarOrigem(val: boolean);
|
|
95
|
+
/**
|
|
96
|
+
* Atributo `sem-popup-sigef`: o clique com a camada SIGEF ativa não abre o popup do kit; o componente só consulta o
|
|
97
|
+
* Geoportal do INCRA e emite `ui-sigef-parcelas` (`SigefParcelasDetail`: `consultando` → `concluida` | `erro`, com as
|
|
98
|
+
* parcelas já organizadas) para o app montar o próprio popup. Sem o atributo, o popup do kit continua como antes.
|
|
99
|
+
*/
|
|
100
|
+
private aplicarPopupSigef;
|
|
95
101
|
/**
|
|
96
102
|
* Quando os popups abrem (atributo `popups`): `sob-demanda` (padrão) só por duplo clique sobre a feição/camada ou por
|
|
97
103
|
* `abrirPopupFeicao()`, sem mover o mapa; `automatico` abre ao clicar e o Leaflet ajusta a vista (comportamento antigo);
|
|
@@ -11,7 +11,11 @@ import { AlvoCor, AtalhosControleCores, ValorCor } from './tipos';
|
|
|
11
11
|
* - O kit não registra atalhos de teclado; quem usa chama `alternarAlvo()`, `inverter()`,
|
|
12
12
|
* `semCor()` e `restaurarPadrao()` e pode exibir as teclas nas dicas via `atalhos`.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* Layout (atributo `layout`): `lado` (padrão, ações em coluna ao lado), `abaixo` (ações em linha sob as amostras,
|
|
15
|
+
* para colunas estreitas), `compacto` (só as amostras; ações pela API) e `mini` (uma amostra só, a do alvo ativo;
|
|
16
|
+
* alterne o alvo por `alternarAlvo()`). `auto` ocupa a largura do contêiner sem transbordar: a amostra encolhe e as ações passam de ao lado para abaixo (< 66px) e somem (< 40px). Tamanhos: `--ui-controle-cores-amostra`, `--ui-controle-cores-acao`.
|
|
17
|
+
*
|
|
18
|
+
* Atributos: layout, preenchimento, traco, opacidade, espessura-traco, alvo (preenchimento|traco), padrao-preenchimento,
|
|
15
19
|
* padrao-traco, titulo-seletor, so-traco, desabilitado
|
|
16
20
|
* Propriedades: preenchimento, traco, opacidade, espessuraTraco, alvo, coresProjeto, atalhos, seletorAberto
|
|
17
21
|
* Métodos: definirCores(), obterCores(), definirAlvo(), alternarAlvo(), definirMisto(), inverter(),
|
package/dist/cores.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var T=Object.defineProperty;var w=(u,p,e)=>p in u?T(u,p,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[p]=e;var i=(u,p,e)=>w(u,typeof p!="symbol"?p+"":p,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});;/* empty css */const s=require("./cores-utils-BmkzhA1v.cjs"),v=require("./kit-base-BmkPi5Rz.cjs"),f=require("./ui-seletor-cor-D_ifitEN.cjs"),q=':host{--_a: var(--ui-controle-cores-amostra, 26px);--_pilha: calc(var(--_a) * 5 / 3);--_borda: color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 30%, transparent);--_borda-forte: color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 70%, transparent);--_base: var(--ui-fundo-superficie, var(--ui-cor-superficie, #1d1d22));--_destaque: var(--ui-cor-primaria, #00e08a);--_vermelho: #ef4444;display:inline-block;flex-shrink:0;-webkit-user-select:none;user-select:none}:host([hidden]){display:none}*,*:before,*:after{box-sizing:border-box}.pilha{display:flex;align-items:stretch;gap:6px}.amostras{position:relative;flex:none;width:var(--_pilha);height:var(--_pilha)}.amostra{position:absolute;width:var(--_a);height:var(--_a);padding:0;background:var(--_base);border:1px solid var(--_borda);border-radius:6px;cursor:pointer;transition:transform .15s ease,border-color .15s ease,box-shadow .15s ease,opacity .15s ease}.amostra--traco{right:0;bottom:0;z-index:1}.amostra--preenchimento{top:0;left:0;z-index:2;box-shadow:0 2px 6px #00000059}.amostra:hover{border-color:var(--_borda-forte);transform:scale(1.05)}.amostra:focus-visible{outline:2px solid var(--ui-cor-texto, #e1e1e6);outline-offset:2px}.amostra--ativa,.amostra--ativa:hover{z-index:3;border-color:var(--_destaque);box-shadow:0 0 0 1.5px var(--_destaque),0 2px 6px #00000059}:host([so-traco]) .amostra--preenchimento{opacity:.4}.face{position:absolute;top:3px;right:3px;bottom:3px;left:3px;border-radius:3.5px;pointer-events:none}.face--traco{background:transparent;border:4px solid #ffffff}.face--sem-cor{background:repeating-conic-gradient(#3a3a45,#3a3a45 25%,#24242b 0%,#24242b 50%) 50% / 6px 6px!important;border-color:#ef44448c!important;overflow:hidden}.face--sem-cor:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(to top right,transparent calc(50% - 1px),var(--_vermelho) calc(50% - 1px),var(--_vermelho) calc(50% + 1px),transparent calc(50% + 1px))}.face--misto{display:flex;align-items:center;justify-content:center;background:#2e2e38!important;border-color:#64748b!important}.face--misto:after{content:"?";color:#fff;font-size:12px;font-weight:800;line-height:1;text-shadow:0 1px 2px rgba(0,0,0,.8)}.acoes{display:flex;flex:none;flex-direction:column;gap:2px;width:16px}.acao{display:flex;flex:1;align-items:center;justify-content:center;min-height:0;padding:0;background:transparent;border:0;border-radius:4px;color:var(--ui-cor-texto-secundario, #9696a6);cursor:pointer;transition:color .15s ease,background .15s ease}.acao:hover{background:color-mix(in srgb,var(--ui-cor-texto, #e1e1e6) 12%,transparent);color:var(--_destaque)}.acao:focus-visible{outline:2px solid var(--ui-cor-texto, #e1e1e6);outline-offset:1px}.acao svg{width:12px;height:12px}.acao--sem-cor:hover{background:#ef444433;color:var(--_vermelho)}.icone-padrao{position:relative;width:11px;height:11px}.ponto{position:absolute;width:7px;height:7px;border-radius:1.5px}.ponto--preenchimento{top:0;left:0;background:#00e08a;border:1px solid var(--_borda-forte)}.ponto--traco{right:0;bottom:0;background:var(--_base);border:1.5px solid #ffffff}:host([desabilitado]) .pilha{opacity:.5}:host([desabilitado]) .amostra,:host([desabilitado]) .acao{cursor:not-allowed;pointer-events:none}@media (prefers-reduced-motion: reduce){.amostra,.acao{transition:none}.amostra:hover{transform:none}}';class z extends v.SafeHTMLElement{constructor(){super();i(this,"raiz");i(this,"listeners",new v.ListenerBag);i(this,"renderizado",!1);i(this,"_preenchimento","#00e08a");i(this,"_traco","#ffffff");i(this,"_opacidade",.35);i(this,"_espessuraTraco",2.5);i(this,"_alvo","preenchimento");i(this,"_misto",{preenchimento:!1,traco:!1});i(this,"_padrao",{preenchimento:"#00e08a",traco:"#ffffff"});i(this,"_coresProjeto",[]);i(this,"_atalhos",{});i(this,"seletor",null);i(this,"estadoAoAbrir",null);this.raiz=this.attachShadow({mode:"open"})}static get observedAttributes(){return["preenchimento","traco","opacidade","espessura-traco","alvo","padrao-preenchimento","padrao-traco","desabilitado"]}connectedCallback(){this.renderizado||this.renderizar(),this.listeners.cleanup(),this.vincularEventos(),this.atualizar()}disconnectedCallback(){this.fecharSeletor(!0),this.listeners.cleanup()}attributeChangedCallback(e,t,r){if(t!==r){if(e==="desabilitado"){this.hasAttribute("desabilitado")&&this.fecharSeletor(!1),this.atualizar();return}if(r!==null){if(e==="preenchimento")this.definirCores({preenchimento:r});else if(e==="traco")this.definirCores({traco:r});else if(e==="opacidade")this.definirCores({opacidade:Number(r)});else if(e==="espessura-traco")this.definirCores({espessuraTraco:s.normalizarEspessura(r)});else if(e==="alvo")this.definirAlvo(r);else if(e==="padrao-preenchimento"||e==="padrao-traco"){const a=s.normalizarCor(r);if(!a)return;e==="padrao-preenchimento"?this._padrao.preenchimento=a:this._padrao.traco=a,this.atualizar()}}}}get preenchimento(){return this._preenchimento}set preenchimento(e){this.definirCores({preenchimento:e})}get traco(){return this._traco}set traco(e){this.definirCores({traco:e})}get opacidade(){return this._opacidade}set opacidade(e){this.definirCores({opacidade:e})}get espessuraTraco(){return this._espessuraTraco}set espessuraTraco(e){this.definirCores({espessuraTraco:e})}get alvo(){return this._alvo}set alvo(e){this.definirAlvo(e)}get coresProjeto(){return[...this._coresProjeto]}set coresProjeto(e){this._coresProjeto=s.coresUnicas(e)}get atalhos(){return{...this._atalhos}}set atalhos(e){this._atalhos={...e||{}},this.atualizar()}get seletorAberto(){var e;return!!((e=this.seletor)!=null&&e.aberto)}definirCores(e={}){const t=s.normalizarCor(e.preenchimento),r=s.normalizarCor(e.traco);t&&(this._preenchimento=t,this._misto.preenchimento=!1),r&&(this._traco=r,this._misto.traco=!1),e.opacidade!==void 0&&(this._opacidade=s.normalizarOpacidade(e.opacidade,this._opacidade)),e.espessuraTraco!==void 0&&(this._espessuraTraco=s.normalizarEspessura(e.espessuraTraco,this._espessuraTraco)),this.atualizar()}obterCores(){return{preenchimento:this._preenchimento,traco:this._traco,opacidade:this._opacidade,espessuraTraco:this._espessuraTraco,alvo:this._alvo}}definirAlvo(e){this._alvo=e==="traco"?"traco":"preenchimento",this.atualizar(),this.sincronizarSeletor()}definirMisto(e={}){this._misto={preenchimento:!!e.preenchimento,traco:!!e.traco},this.atualizar()}alternarAlvo(){this.mudarAlvo(this._alvo==="traco"?"preenchimento":"traco")}inverter(){const e=this._preenchimento;this._preenchimento=this._traco,this._traco=e,this._misto={preenchimento:this._misto.traco,traco:this._misto.preenchimento},this.atualizar(),this.emitirCores(!0,["preenchimento","traco"],"inverter")}semCor(e=this._alvo){const t=e==="traco"?"traco":"preenchimento";t==="traco"?this._traco="none":this._preenchimento="none",this._misto[t]=!1,this.atualizar(),this.emitirCores(!0,[t],"sem-cor")}restaurarPadrao(){this._preenchimento=this._padrao.preenchimento,this._traco=this._padrao.traco,this._misto={preenchimento:!1,traco:!1},this.atualizar(),this.emitirCores(!0,["preenchimento","traco"],"padrao")}abrirSeletor(e=this._alvo,t=!1){if(this.hasAttribute("desabilitado")||(this.mudarAlvo(e==="traco"?"traco":"preenchimento"),this.seletorAberto))return;const r=this.raiz.querySelector(`[data-alvo="${this._alvo}"]`)||this;this.estadoAoAbrir=this.obterCores(),this.seletor=f.abrirSeletorCor({ancora:r,titulo:this.getAttribute("titulo-seletor")||"Cores e estilo",modo:"duplo",alvo:this._alvo,preenchimento:this._preenchimento,traco:this._traco,opacidade:this._opacidade,espessuraTraco:this._espessuraTraco,misto:this._misto[this._alvo],focar:t,aoAlterar:a=>this.aplicarDoSeletor(a,!1),aoConfirmar:a=>{this.seletor=null,this.aplicarDoSeletor(a,!0)},aoCancelar:()=>{this.seletor=null,this.estadoAoAbrir=null},aoTrocarAlvo:a=>this.mudarAlvo(a)})}fecharSeletor(e=!0){const t=this.seletor;t&&(e?t.fechar(!0):t.elemento.cancelar())}mudarAlvo(e){e!==this._alvo&&(this._alvo=e,this.atualizar(),this.sincronizarSeletor(),this.dispatchEvent(new CustomEvent("ui-alvo-change",{detail:{alvo:e},bubbles:!0,composed:!0})))}sincronizarSeletor(){var e,t;(t=(e=this.seletor)==null?void 0:e.elemento)==null||t.trocarAlvo(this._alvo)}aplicarDoSeletor(e,t){const r=o=>{const d=[];return e.preenchimento!==o.preenchimento&&d.push("preenchimento"),e.traco!==o.traco&&d.push("traco"),e.opacidade!==o.opacidade&&d.push("opacidade"),e.espessuraTraco!==void 0&&Math.abs(e.espessuraTraco-o.espessuraTraco)>.05&&d.push("espessuraTraco"),d},a=r(this.obterCores());if(this._preenchimento=e.preenchimento,this._traco=e.traco,this._opacidade=e.opacidade,e.espessuraTraco!==void 0&&(this._espessuraTraco=e.espessuraTraco),a.includes("preenchimento")&&(this._misto.preenchimento=!1),a.includes("traco")&&(this._misto.traco=!1),this.atualizar(),!t){a.length&&this.emitirCores(!1,a,"seletor");return}this.emitirCores(!0,this.estadoAoAbrir?r(this.estadoAoAbrir):a,"seletor"),this.estadoAoAbrir=null}emitirCores(e,t,r){const a={...this.obterCores(),confirmado:e,alterados:t,origem:r};this.dispatchEvent(new CustomEvent("ui-cores-change",{detail:a,bubbles:!0,composed:!0}))}dica(e,t){return t?`${e} [${t}]`:e}renderizar(){this.raiz.innerHTML=`
|
|
1
|
+
"use strict";var k=Object.defineProperty;var T=(u,p,e)=>p in u?k(u,p,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[p]=e;var i=(u,p,e)=>T(u,typeof p!="symbol"?p+"":p,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});;/* empty css */const s=require("./cores-utils-BmkzhA1v.cjs"),v=require("./kit-base-BmkPi5Rz.cjs"),f=require("./ui-seletor-cor-D_ifitEN.cjs"),q=':host{--_a: var(--ui-controle-cores-amostra, 26px);--_pilha: calc(var(--_a) * 5 / 3);--_borda: color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 30%, transparent);--_borda-forte: color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 70%, transparent);--_base: var(--ui-fundo-superficie, var(--ui-cor-superficie, #1d1d22));--_destaque: var(--ui-cor-primaria, #00e08a);--_vermelho: #ef4444;display:inline-block;flex-shrink:0;-webkit-user-select:none;user-select:none}:host([hidden]){display:none}*,*:before,*:after{box-sizing:border-box}.pilha{display:flex;align-items:stretch;gap:6px}.amostras{position:relative;flex:none;width:var(--_pilha);height:var(--_pilha)}.amostra{position:absolute;width:var(--_a);height:var(--_a);padding:0;background:var(--_base);border:1px solid var(--_borda);border-radius:6px;cursor:pointer;transition:transform .15s ease,border-color .15s ease,box-shadow .15s ease,opacity .15s ease}.amostra--traco{right:0;bottom:0;z-index:1}.amostra--preenchimento{top:0;left:0;z-index:2;box-shadow:0 2px 6px #00000059}.amostra:hover{border-color:var(--_borda-forte);transform:scale(1.05)}.amostra:focus-visible{outline:2px solid var(--ui-cor-texto, #e1e1e6);outline-offset:2px}.amostra--ativa,.amostra--ativa:hover{z-index:3;border-color:var(--_destaque);box-shadow:0 0 0 1.5px var(--_destaque),0 2px 6px #00000059}:host([so-traco]) .amostra--preenchimento{opacity:.4}.face{position:absolute;top:3px;right:3px;bottom:3px;left:3px;border-radius:3.5px;pointer-events:none}.face--traco{background:transparent;border:4px solid #ffffff}.face--sem-cor{background:repeating-conic-gradient(#3a3a45,#3a3a45 25%,#24242b 0%,#24242b 50%) 50% / 6px 6px!important;border-color:#ef44448c!important;overflow:hidden}.face--sem-cor:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(to top right,transparent calc(50% - 1px),var(--_vermelho) calc(50% - 1px),var(--_vermelho) calc(50% + 1px),transparent calc(50% + 1px))}.face--misto{display:flex;align-items:center;justify-content:center;background:#2e2e38!important;border-color:#64748b!important}.face--misto:after{content:"?";color:#fff;font-size:12px;font-weight:800;line-height:1;text-shadow:0 1px 2px rgba(0,0,0,.8)}.acoes{display:flex;flex:none;flex-direction:column;gap:2px;width:16px}.acao{display:flex;flex:1;align-items:center;justify-content:center;min-height:0;padding:0;background:transparent;border:0;border-radius:4px;color:var(--ui-cor-texto-secundario, #9696a6);cursor:pointer;transition:color .15s ease,background .15s ease}.acao:hover{background:color-mix(in srgb,var(--ui-cor-texto, #e1e1e6) 12%,transparent);color:var(--_destaque)}.acao:focus-visible{outline:2px solid var(--ui-cor-texto, #e1e1e6);outline-offset:1px}.acao svg{width:12px;height:12px}.acao--sem-cor:hover{background:#ef444433;color:var(--_vermelho)}.icone-padrao{position:relative;width:11px;height:11px}.ponto{position:absolute;width:7px;height:7px;border-radius:1.5px}.ponto--preenchimento{top:0;left:0;background:#00e08a;border:1px solid var(--_borda-forte)}.ponto--traco{right:0;bottom:0;background:var(--_base);border:1.5px solid #ffffff}:host([layout="abaixo"]) .pilha{flex-direction:column;align-items:flex-start;gap:4px}:host([layout="abaixo"]) .acoes{flex-direction:row;width:var(--_pilha);height:var(--ui-controle-cores-acao, 22px)}:host([layout="abaixo"]) .acao svg{width:14px;height:14px}:host([layout="abaixo"]) .icone-padrao{width:13px;height:13px}:host([layout="compacto"]) .acoes{display:none}:host([layout="auto"]){display:block;width:100%;max-width:100%;min-width:0;container-type:inline-size}:host([layout="auto"]) .pilha{--_a: min(var(--ui-controle-cores-amostra, 26px), 60cqw);--_pilha: calc(var(--_a) * 5 / 3);justify-content:center;flex-direction:column;align-items:center;gap:4px}:host([layout="auto"]) .acoes{flex-direction:row;width:var(--_pilha);height:var(--ui-controle-cores-acao, 22px)}:host([layout="auto"]) .acao{min-width:0}:host([layout="auto"]) .acao svg{max-width:100%}@container (min-width: 66px){:host([layout="auto"]) .pilha{--_a: min(var(--ui-controle-cores-amostra, 26px), calc((100cqw - 22px) * 3 / 5));flex-direction:row;align-items:stretch;gap:6px}:host([layout="auto"]) .acoes{flex-direction:column;width:16px;height:auto}}@container (max-width: 39px){:host([layout="auto"]) .acoes{display:none}}:host([layout="mini"]){--_pilha: var(--_a)}:host([layout="mini"]) .acoes{display:none}:host([layout="mini"]) .amostra{top:0;left:0;right:auto;bottom:auto;opacity:0;pointer-events:none}:host([layout="mini"]) .amostra--ativa{opacity:1;pointer-events:auto}:host([layout="mini"]) .amostra--ativa:hover{transform:none}:host([desabilitado]) .pilha{opacity:.5}:host([desabilitado]) .amostra,:host([desabilitado]) .acao{cursor:not-allowed;pointer-events:none}@media (prefers-reduced-motion: reduce){.amostra,.acao{transition:none}.amostra:hover{transform:none}}';class C extends v.SafeHTMLElement{constructor(){super();i(this,"raiz");i(this,"listeners",new v.ListenerBag);i(this,"renderizado",!1);i(this,"_preenchimento","#00e08a");i(this,"_traco","#ffffff");i(this,"_opacidade",.35);i(this,"_espessuraTraco",2.5);i(this,"_alvo","preenchimento");i(this,"_misto",{preenchimento:!1,traco:!1});i(this,"_padrao",{preenchimento:"#00e08a",traco:"#ffffff"});i(this,"_coresProjeto",[]);i(this,"_atalhos",{});i(this,"seletor",null);i(this,"estadoAoAbrir",null);this.raiz=this.attachShadow({mode:"open"})}static get observedAttributes(){return["preenchimento","traco","opacidade","espessura-traco","alvo","padrao-preenchimento","padrao-traco","desabilitado"]}connectedCallback(){this.renderizado||this.renderizar(),this.listeners.cleanup(),this.vincularEventos(),this.atualizar()}disconnectedCallback(){this.fecharSeletor(!0),this.listeners.cleanup()}attributeChangedCallback(e,t,a){if(t!==a){if(e==="desabilitado"){this.hasAttribute("desabilitado")&&this.fecharSeletor(!1),this.atualizar();return}if(a!==null){if(e==="preenchimento")this.definirCores({preenchimento:a});else if(e==="traco")this.definirCores({traco:a});else if(e==="opacidade")this.definirCores({opacidade:Number(a)});else if(e==="espessura-traco")this.definirCores({espessuraTraco:s.normalizarEspessura(a)});else if(e==="alvo")this.definirAlvo(a);else if(e==="padrao-preenchimento"||e==="padrao-traco"){const o=s.normalizarCor(a);if(!o)return;e==="padrao-preenchimento"?this._padrao.preenchimento=o:this._padrao.traco=o,this.atualizar()}}}}get preenchimento(){return this._preenchimento}set preenchimento(e){this.definirCores({preenchimento:e})}get traco(){return this._traco}set traco(e){this.definirCores({traco:e})}get opacidade(){return this._opacidade}set opacidade(e){this.definirCores({opacidade:e})}get espessuraTraco(){return this._espessuraTraco}set espessuraTraco(e){this.definirCores({espessuraTraco:e})}get alvo(){return this._alvo}set alvo(e){this.definirAlvo(e)}get coresProjeto(){return[...this._coresProjeto]}set coresProjeto(e){this._coresProjeto=s.coresUnicas(e)}get atalhos(){return{...this._atalhos}}set atalhos(e){this._atalhos={...e||{}},this.atualizar()}get seletorAberto(){var e;return!!((e=this.seletor)!=null&&e.aberto)}definirCores(e={}){const t=s.normalizarCor(e.preenchimento),a=s.normalizarCor(e.traco);t&&(this._preenchimento=t,this._misto.preenchimento=!1),a&&(this._traco=a,this._misto.traco=!1),e.opacidade!==void 0&&(this._opacidade=s.normalizarOpacidade(e.opacidade,this._opacidade)),e.espessuraTraco!==void 0&&(this._espessuraTraco=s.normalizarEspessura(e.espessuraTraco,this._espessuraTraco)),this.atualizar()}obterCores(){return{preenchimento:this._preenchimento,traco:this._traco,opacidade:this._opacidade,espessuraTraco:this._espessuraTraco,alvo:this._alvo}}definirAlvo(e){this._alvo=e==="traco"?"traco":"preenchimento",this.atualizar(),this.sincronizarSeletor()}definirMisto(e={}){this._misto={preenchimento:!!e.preenchimento,traco:!!e.traco},this.atualizar()}alternarAlvo(){this.mudarAlvo(this._alvo==="traco"?"preenchimento":"traco")}inverter(){const e=this._preenchimento;this._preenchimento=this._traco,this._traco=e,this._misto={preenchimento:this._misto.traco,traco:this._misto.preenchimento},this.atualizar(),this.emitirCores(!0,["preenchimento","traco"],"inverter")}semCor(e=this._alvo){const t=e==="traco"?"traco":"preenchimento";t==="traco"?this._traco="none":this._preenchimento="none",this._misto[t]=!1,this.atualizar(),this.emitirCores(!0,[t],"sem-cor")}restaurarPadrao(){this._preenchimento=this._padrao.preenchimento,this._traco=this._padrao.traco,this._misto={preenchimento:!1,traco:!1},this.atualizar(),this.emitirCores(!0,["preenchimento","traco"],"padrao")}abrirSeletor(e=this._alvo,t=!1){if(this.hasAttribute("desabilitado")||(this.mudarAlvo(e==="traco"?"traco":"preenchimento"),this.seletorAberto))return;const a=this.raiz.querySelector(`[data-alvo="${this._alvo}"]`)||this;this.estadoAoAbrir=this.obterCores(),this.seletor=f.abrirSeletorCor({ancora:a,titulo:this.getAttribute("titulo-seletor")||"Cores e estilo",modo:"duplo",alvo:this._alvo,preenchimento:this._preenchimento,traco:this._traco,opacidade:this._opacidade,espessuraTraco:this._espessuraTraco,misto:this._misto[this._alvo],focar:t,aoAlterar:o=>this.aplicarDoSeletor(o,!1),aoConfirmar:o=>{this.seletor=null,this.aplicarDoSeletor(o,!0)},aoCancelar:()=>{this.seletor=null,this.estadoAoAbrir=null},aoTrocarAlvo:o=>this.mudarAlvo(o)})}fecharSeletor(e=!0){const t=this.seletor;t&&(e?t.fechar(!0):t.elemento.cancelar())}mudarAlvo(e){e!==this._alvo&&(this._alvo=e,this.atualizar(),this.sincronizarSeletor(),this.dispatchEvent(new CustomEvent("ui-alvo-change",{detail:{alvo:e},bubbles:!0,composed:!0})))}sincronizarSeletor(){var e,t;(t=(e=this.seletor)==null?void 0:e.elemento)==null||t.trocarAlvo(this._alvo)}aplicarDoSeletor(e,t){const a=r=>{const d=[];return e.preenchimento!==r.preenchimento&&d.push("preenchimento"),e.traco!==r.traco&&d.push("traco"),e.opacidade!==r.opacidade&&d.push("opacidade"),e.espessuraTraco!==void 0&&Math.abs(e.espessuraTraco-r.espessuraTraco)>.05&&d.push("espessuraTraco"),d},o=a(this.obterCores());if(this._preenchimento=e.preenchimento,this._traco=e.traco,this._opacidade=e.opacidade,e.espessuraTraco!==void 0&&(this._espessuraTraco=e.espessuraTraco),o.includes("preenchimento")&&(this._misto.preenchimento=!1),o.includes("traco")&&(this._misto.traco=!1),this.atualizar(),!t){o.length&&this.emitirCores(!1,o,"seletor");return}this.emitirCores(!0,this.estadoAoAbrir?a(this.estadoAoAbrir):o,"seletor"),this.estadoAoAbrir=null}emitirCores(e,t,a){const o={...this.obterCores(),confirmado:e,alterados:t,origem:a};this.dispatchEvent(new CustomEvent("ui-cores-change",{detail:o,bubbles:!0,composed:!0}))}dica(e,t){return t?`${e} [${t}]`:e}renderizar(){this.raiz.innerHTML=`
|
|
2
2
|
<style>${q}</style>
|
|
3
3
|
<div class="pilha" part="pilha" role="group" aria-label="Cores de desenho">
|
|
4
4
|
<div class="amostras" part="amostras">
|
|
@@ -29,4 +29,4 @@
|
|
|
29
29
|
</button>
|
|
30
30
|
</div>
|
|
31
31
|
</div>
|
|
32
|
-
`,this.renderizado=!0}vincularEventos(){const e=this.raiz;e.querySelectorAll("[data-alvo]").forEach(
|
|
32
|
+
`,this.renderizado=!0}vincularEventos(){const e=this.raiz;e.querySelectorAll("[data-alvo]").forEach(a=>{const o=a.dataset.alvo;this.listeners.add(a,"click",r=>{r.stopPropagation(),o!==this._alvo?this.mudarAlvo(o):this.seletorAberto?this.fecharSeletor(!0):this.abrirSeletor(o)}),this.listeners.add(a,"dblclick",r=>{r.stopPropagation(),this.abrirSeletor(o)}),this.listeners.add(a,"keydown",r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),o===this._alvo&&this.seletorAberto?this.fecharSeletor(!0):this.abrirSeletor(o,!0))}),this.listeners.add(a,"keyup",r=>{r.key===" "&&r.preventDefault()})});const t=(a,o)=>{this.listeners.add(e.querySelector(`[data-acao="${a}"]`),"click",r=>{r.stopPropagation(),o()})};t("inverter",()=>this.inverter()),t("sem-cor",()=>this.semCor()),t("padrao",()=>this.restaurarPadrao())}atualizar(){if(!this.renderizado)return;const e=this.raiz,t=this._atalhos,a=this.hasAttribute("desabilitado"),o=(n,c)=>c?"Misto (?) [várias cores na seleção]":n==="none"?"Sem cor":n,r=(n,c,l,A,S="")=>{const h=e.querySelector(`[data-alvo="${n}"]`),m=h==null?void 0:h.querySelector(".face");if(!h||!m)return;const g=this._alvo===n;h.classList.toggle("amostra--ativa",g),h.setAttribute("aria-pressed",String(g)),h.disabled=a,m.classList.toggle("face--misto",l),m.classList.toggle("face--sem-cor",!l&&c==="none");const w=n==="traco"?"borderColor":"backgroundColor";m.style[w]=l||c==="none"?"":c,n==="traco"&&c!=="none"&&!l&&(m.style.borderWidth=`${Math.max(2,Math.min(4.5,this._espessuraTraco))}px`);const y=`${A}: ${o(c,l)}${S}`;h.title=this.dica(`${y} — clique para ativar, clique de novo para editar`,t.alternar),h.setAttribute("aria-label",y)},d=this._preenchimento==="none"||this._misto.preenchimento?"":`, opacidade ${Math.round(this._opacidade*100)}%`;r("preenchimento",this._preenchimento,this._misto.preenchimento,"Preenchimento",d);const z=this._traco==="none"||this._misto.traco?"":`, espessura ${this._espessuraTraco}px`;r("traco",this._traco,this._misto.traco,"Traço / contorno",z);const b=(n,c)=>{const l=e.querySelector(`[data-acao="${n}"]`);l&&(l.title=c,l.disabled=a)};b("inverter",this.dica("Inverter preenchimento e traço",t.inverter)),b("sem-cor",this.dica("Sem cor no alvo ativo",t.semCor)),b("padrao",this.dica("Restaurar cores padrão",t.padrao));const _=e.querySelector(".ponto--preenchimento");_&&(_.style.backgroundColor=this._padrao.preenchimento==="none"?"transparent":this._padrao.preenchimento);const x=e.querySelector(".ponto--traco");x&&(x.style.borderColor=this._padrao.traco==="none"?"#ef4444":this._padrao.traco)}}v.definirCustomElement("ui-controle-cores",C);exports.PALETA_CORES_PADRAO=s.PALETA_CORES_PADRAO;exports.coresUnicas=s.coresUnicas;exports.escaparHtml=s.escaparHtml;exports.normalizarCor=s.normalizarCor;exports.normalizarEspessura=s.normalizarEspessura;exports.normalizarOpacidade=s.normalizarOpacidade;exports.UISeletorCor=f.UISeletorCor;exports.abrirSeletorCor=f.abrirSeletorCor;exports.fecharSeletorCor=f.fecharSeletorCor;exports.UIControleCores=C;
|
package/dist/cores.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var z = Object.defineProperty;
|
|
2
|
+
var k = (d, h, e) => h in d ? z(d, h, { enumerable: !0, configurable: !0, writable: !0, value: e }) : d[h] = e;
|
|
3
|
+
var i = (d, h, e) => k(d, typeof h != "symbol" ? h + "" : h, e);
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { b as g, n as
|
|
5
|
+
import { b as g, n as f, c as S, a as T } from "./cores-utils-DMyqWvZh.js";
|
|
6
6
|
import { P as O, e as N } from "./cores-utils-DMyqWvZh.js";
|
|
7
|
-
import { S as
|
|
7
|
+
import { S as q, L as P, d as $ } from "./kit-base-CBXA66aM.js";
|
|
8
8
|
import { a as E } from "./ui-seletor-cor-CPjA9vhZ.js";
|
|
9
9
|
import { U as F, f as G } from "./ui-seletor-cor-CPjA9vhZ.js";
|
|
10
|
-
const M = ':host{--_a: var(--ui-controle-cores-amostra, 26px);--_pilha: calc(var(--_a) * 5 / 3);--_borda: color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 30%, transparent);--_borda-forte: color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 70%, transparent);--_base: var(--ui-fundo-superficie, var(--ui-cor-superficie, #1d1d22));--_destaque: var(--ui-cor-primaria, #00e08a);--_vermelho: #ef4444;display:inline-block;flex-shrink:0;-webkit-user-select:none;user-select:none}:host([hidden]){display:none}*,*:before,*:after{box-sizing:border-box}.pilha{display:flex;align-items:stretch;gap:6px}.amostras{position:relative;flex:none;width:var(--_pilha);height:var(--_pilha)}.amostra{position:absolute;width:var(--_a);height:var(--_a);padding:0;background:var(--_base);border:1px solid var(--_borda);border-radius:6px;cursor:pointer;transition:transform .15s ease,border-color .15s ease,box-shadow .15s ease,opacity .15s ease}.amostra--traco{right:0;bottom:0;z-index:1}.amostra--preenchimento{top:0;left:0;z-index:2;box-shadow:0 2px 6px #00000059}.amostra:hover{border-color:var(--_borda-forte);transform:scale(1.05)}.amostra:focus-visible{outline:2px solid var(--ui-cor-texto, #e1e1e6);outline-offset:2px}.amostra--ativa,.amostra--ativa:hover{z-index:3;border-color:var(--_destaque);box-shadow:0 0 0 1.5px var(--_destaque),0 2px 6px #00000059}:host([so-traco]) .amostra--preenchimento{opacity:.4}.face{position:absolute;top:3px;right:3px;bottom:3px;left:3px;border-radius:3.5px;pointer-events:none}.face--traco{background:transparent;border:4px solid #ffffff}.face--sem-cor{background:repeating-conic-gradient(#3a3a45,#3a3a45 25%,#24242b 0%,#24242b 50%) 50% / 6px 6px!important;border-color:#ef44448c!important;overflow:hidden}.face--sem-cor:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(to top right,transparent calc(50% - 1px),var(--_vermelho) calc(50% - 1px),var(--_vermelho) calc(50% + 1px),transparent calc(50% + 1px))}.face--misto{display:flex;align-items:center;justify-content:center;background:#2e2e38!important;border-color:#64748b!important}.face--misto:after{content:"?";color:#fff;font-size:12px;font-weight:800;line-height:1;text-shadow:0 1px 2px rgba(0,0,0,.8)}.acoes{display:flex;flex:none;flex-direction:column;gap:2px;width:16px}.acao{display:flex;flex:1;align-items:center;justify-content:center;min-height:0;padding:0;background:transparent;border:0;border-radius:4px;color:var(--ui-cor-texto-secundario, #9696a6);cursor:pointer;transition:color .15s ease,background .15s ease}.acao:hover{background:color-mix(in srgb,var(--ui-cor-texto, #e1e1e6) 12%,transparent);color:var(--_destaque)}.acao:focus-visible{outline:2px solid var(--ui-cor-texto, #e1e1e6);outline-offset:1px}.acao svg{width:12px;height:12px}.acao--sem-cor:hover{background:#ef444433;color:var(--_vermelho)}.icone-padrao{position:relative;width:11px;height:11px}.ponto{position:absolute;width:7px;height:7px;border-radius:1.5px}.ponto--preenchimento{top:0;left:0;background:#00e08a;border:1px solid var(--_borda-forte)}.ponto--traco{right:0;bottom:0;background:var(--_base);border:1.5px solid #ffffff}:host([desabilitado]) .pilha{opacity:.5}:host([desabilitado]) .amostra,:host([desabilitado]) .acao{cursor:not-allowed;pointer-events:none}@media (prefers-reduced-motion: reduce){.amostra,.acao{transition:none}.amostra:hover{transform:none}}';
|
|
11
|
-
class j extends
|
|
10
|
+
const M = ':host{--_a: var(--ui-controle-cores-amostra, 26px);--_pilha: calc(var(--_a) * 5 / 3);--_borda: color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 30%, transparent);--_borda-forte: color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 70%, transparent);--_base: var(--ui-fundo-superficie, var(--ui-cor-superficie, #1d1d22));--_destaque: var(--ui-cor-primaria, #00e08a);--_vermelho: #ef4444;display:inline-block;flex-shrink:0;-webkit-user-select:none;user-select:none}:host([hidden]){display:none}*,*:before,*:after{box-sizing:border-box}.pilha{display:flex;align-items:stretch;gap:6px}.amostras{position:relative;flex:none;width:var(--_pilha);height:var(--_pilha)}.amostra{position:absolute;width:var(--_a);height:var(--_a);padding:0;background:var(--_base);border:1px solid var(--_borda);border-radius:6px;cursor:pointer;transition:transform .15s ease,border-color .15s ease,box-shadow .15s ease,opacity .15s ease}.amostra--traco{right:0;bottom:0;z-index:1}.amostra--preenchimento{top:0;left:0;z-index:2;box-shadow:0 2px 6px #00000059}.amostra:hover{border-color:var(--_borda-forte);transform:scale(1.05)}.amostra:focus-visible{outline:2px solid var(--ui-cor-texto, #e1e1e6);outline-offset:2px}.amostra--ativa,.amostra--ativa:hover{z-index:3;border-color:var(--_destaque);box-shadow:0 0 0 1.5px var(--_destaque),0 2px 6px #00000059}:host([so-traco]) .amostra--preenchimento{opacity:.4}.face{position:absolute;top:3px;right:3px;bottom:3px;left:3px;border-radius:3.5px;pointer-events:none}.face--traco{background:transparent;border:4px solid #ffffff}.face--sem-cor{background:repeating-conic-gradient(#3a3a45,#3a3a45 25%,#24242b 0%,#24242b 50%) 50% / 6px 6px!important;border-color:#ef44448c!important;overflow:hidden}.face--sem-cor:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(to top right,transparent calc(50% - 1px),var(--_vermelho) calc(50% - 1px),var(--_vermelho) calc(50% + 1px),transparent calc(50% + 1px))}.face--misto{display:flex;align-items:center;justify-content:center;background:#2e2e38!important;border-color:#64748b!important}.face--misto:after{content:"?";color:#fff;font-size:12px;font-weight:800;line-height:1;text-shadow:0 1px 2px rgba(0,0,0,.8)}.acoes{display:flex;flex:none;flex-direction:column;gap:2px;width:16px}.acao{display:flex;flex:1;align-items:center;justify-content:center;min-height:0;padding:0;background:transparent;border:0;border-radius:4px;color:var(--ui-cor-texto-secundario, #9696a6);cursor:pointer;transition:color .15s ease,background .15s ease}.acao:hover{background:color-mix(in srgb,var(--ui-cor-texto, #e1e1e6) 12%,transparent);color:var(--_destaque)}.acao:focus-visible{outline:2px solid var(--ui-cor-texto, #e1e1e6);outline-offset:1px}.acao svg{width:12px;height:12px}.acao--sem-cor:hover{background:#ef444433;color:var(--_vermelho)}.icone-padrao{position:relative;width:11px;height:11px}.ponto{position:absolute;width:7px;height:7px;border-radius:1.5px}.ponto--preenchimento{top:0;left:0;background:#00e08a;border:1px solid var(--_borda-forte)}.ponto--traco{right:0;bottom:0;background:var(--_base);border:1.5px solid #ffffff}:host([layout="abaixo"]) .pilha{flex-direction:column;align-items:flex-start;gap:4px}:host([layout="abaixo"]) .acoes{flex-direction:row;width:var(--_pilha);height:var(--ui-controle-cores-acao, 22px)}:host([layout="abaixo"]) .acao svg{width:14px;height:14px}:host([layout="abaixo"]) .icone-padrao{width:13px;height:13px}:host([layout="compacto"]) .acoes{display:none}:host([layout="auto"]){display:block;width:100%;max-width:100%;min-width:0;container-type:inline-size}:host([layout="auto"]) .pilha{--_a: min(var(--ui-controle-cores-amostra, 26px), 60cqw);--_pilha: calc(var(--_a) * 5 / 3);justify-content:center;flex-direction:column;align-items:center;gap:4px}:host([layout="auto"]) .acoes{flex-direction:row;width:var(--_pilha);height:var(--ui-controle-cores-acao, 22px)}:host([layout="auto"]) .acao{min-width:0}:host([layout="auto"]) .acao svg{max-width:100%}@container (min-width: 66px){:host([layout="auto"]) .pilha{--_a: min(var(--ui-controle-cores-amostra, 26px), calc((100cqw - 22px) * 3 / 5));flex-direction:row;align-items:stretch;gap:6px}:host([layout="auto"]) .acoes{flex-direction:column;width:16px;height:auto}}@container (max-width: 39px){:host([layout="auto"]) .acoes{display:none}}:host([layout="mini"]){--_pilha: var(--_a)}:host([layout="mini"]) .acoes{display:none}:host([layout="mini"]) .amostra{top:0;left:0;right:auto;bottom:auto;opacity:0;pointer-events:none}:host([layout="mini"]) .amostra--ativa{opacity:1;pointer-events:auto}:host([layout="mini"]) .amostra--ativa:hover{transform:none}:host([desabilitado]) .pilha{opacity:.5}:host([desabilitado]) .amostra,:host([desabilitado]) .acao{cursor:not-allowed;pointer-events:none}@media (prefers-reduced-motion: reduce){.amostra,.acao{transition:none}.amostra:hover{transform:none}}';
|
|
11
|
+
class j extends q {
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
i(this, "raiz");
|
|
15
|
+
i(this, "listeners", new P());
|
|
16
|
+
i(this, "renderizado", !1);
|
|
17
|
+
i(this, "_preenchimento", "#00e08a");
|
|
18
|
+
i(this, "_traco", "#ffffff");
|
|
19
|
+
i(this, "_opacidade", 0.35);
|
|
20
|
+
i(this, "_espessuraTraco", 2.5);
|
|
21
|
+
i(this, "_alvo", "preenchimento");
|
|
22
|
+
i(this, "_misto", { preenchimento: !1, traco: !1 });
|
|
23
|
+
i(this, "_padrao", { preenchimento: "#00e08a", traco: "#ffffff" });
|
|
24
|
+
i(this, "_coresProjeto", []);
|
|
25
|
+
i(this, "_atalhos", {});
|
|
26
|
+
i(this, "seletor", null);
|
|
27
|
+
i(this, "estadoAoAbrir", null);
|
|
28
28
|
this.raiz = this.attachShadow({ mode: "open" });
|
|
29
29
|
}
|
|
30
30
|
static get observedAttributes() {
|
|
@@ -36,22 +36,22 @@ class j extends P {
|
|
|
36
36
|
disconnectedCallback() {
|
|
37
37
|
this.fecharSeletor(!0), this.listeners.cleanup();
|
|
38
38
|
}
|
|
39
|
-
attributeChangedCallback(e, t,
|
|
40
|
-
if (t !==
|
|
39
|
+
attributeChangedCallback(e, t, a) {
|
|
40
|
+
if (t !== a) {
|
|
41
41
|
if (e === "desabilitado") {
|
|
42
42
|
this.hasAttribute("desabilitado") && this.fecharSeletor(!1), this.atualizar();
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
if (
|
|
46
|
-
if (e === "preenchimento") this.definirCores({ preenchimento:
|
|
47
|
-
else if (e === "traco") this.definirCores({ traco:
|
|
48
|
-
else if (e === "opacidade") this.definirCores({ opacidade: Number(
|
|
49
|
-
else if (e === "espessura-traco") this.definirCores({ espessuraTraco: g(
|
|
50
|
-
else if (e === "alvo") this.definirAlvo(
|
|
45
|
+
if (a !== null) {
|
|
46
|
+
if (e === "preenchimento") this.definirCores({ preenchimento: a });
|
|
47
|
+
else if (e === "traco") this.definirCores({ traco: a });
|
|
48
|
+
else if (e === "opacidade") this.definirCores({ opacidade: Number(a) });
|
|
49
|
+
else if (e === "espessura-traco") this.definirCores({ espessuraTraco: g(a) });
|
|
50
|
+
else if (e === "alvo") this.definirAlvo(a);
|
|
51
51
|
else if (e === "padrao-preenchimento" || e === "padrao-traco") {
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
54
|
-
e === "padrao-preenchimento" ? this._padrao.preenchimento =
|
|
52
|
+
const o = f(a);
|
|
53
|
+
if (!o) return;
|
|
54
|
+
e === "padrao-preenchimento" ? this._padrao.preenchimento = o : this._padrao.traco = o, this.atualizar();
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -92,7 +92,7 @@ class j extends P {
|
|
|
92
92
|
return [...this._coresProjeto];
|
|
93
93
|
}
|
|
94
94
|
set coresProjeto(e) {
|
|
95
|
-
this._coresProjeto =
|
|
95
|
+
this._coresProjeto = S(e);
|
|
96
96
|
}
|
|
97
97
|
/** Teclas exibidas nas dicas dos botões (ex.: `{ inverter: 'Shift+X' }`). */
|
|
98
98
|
get atalhos() {
|
|
@@ -108,8 +108,8 @@ class j extends P {
|
|
|
108
108
|
/* ---------- Métodos (sem eventos) ---------- */
|
|
109
109
|
/** Define cores, opacidade e/ou espessura sem emitir eventos. Valores inválidos são ignorados; uma cor definida deixa de ser "mista". */
|
|
110
110
|
definirCores(e = {}) {
|
|
111
|
-
const t =
|
|
112
|
-
t && (this._preenchimento = t, this._misto.preenchimento = !1),
|
|
111
|
+
const t = f(e.preenchimento), a = f(e.traco);
|
|
112
|
+
t && (this._preenchimento = t, this._misto.preenchimento = !1), a && (this._traco = a, this._misto.traco = !1), e.opacidade !== void 0 && (this._opacidade = T(e.opacidade, this._opacidade)), e.espessuraTraco !== void 0 && (this._espessuraTraco = g(e.espessuraTraco, this._espessuraTraco)), this.atualizar();
|
|
113
113
|
}
|
|
114
114
|
obterCores() {
|
|
115
115
|
return {
|
|
@@ -150,9 +150,9 @@ class j extends P {
|
|
|
150
150
|
/** Abre o seletor de cor ancorado na amostra do alvo (que passa a ser o ativo). Com `focar`, leva o foco do teclado para o painel. */
|
|
151
151
|
abrirSeletor(e = this._alvo, t = !1) {
|
|
152
152
|
if (this.hasAttribute("desabilitado") || (this.mudarAlvo(e === "traco" ? "traco" : "preenchimento"), this.seletorAberto)) return;
|
|
153
|
-
const
|
|
153
|
+
const a = this.raiz.querySelector(`[data-alvo="${this._alvo}"]`) || this;
|
|
154
154
|
this.estadoAoAbrir = this.obterCores(), this.seletor = E({
|
|
155
|
-
ancora:
|
|
155
|
+
ancora: a,
|
|
156
156
|
titulo: this.getAttribute("titulo-seletor") || "Cores e estilo",
|
|
157
157
|
modo: "duplo",
|
|
158
158
|
alvo: this._alvo,
|
|
@@ -162,14 +162,14 @@ class j extends P {
|
|
|
162
162
|
espessuraTraco: this._espessuraTraco,
|
|
163
163
|
misto: this._misto[this._alvo],
|
|
164
164
|
focar: t,
|
|
165
|
-
aoAlterar: (
|
|
166
|
-
aoConfirmar: (
|
|
167
|
-
this.seletor = null, this.aplicarDoSeletor(
|
|
165
|
+
aoAlterar: (o) => this.aplicarDoSeletor(o, !1),
|
|
166
|
+
aoConfirmar: (o) => {
|
|
167
|
+
this.seletor = null, this.aplicarDoSeletor(o, !0);
|
|
168
168
|
},
|
|
169
169
|
aoCancelar: () => {
|
|
170
170
|
this.seletor = null, this.estadoAoAbrir = null;
|
|
171
171
|
},
|
|
172
|
-
aoTrocarAlvo: (
|
|
172
|
+
aoTrocarAlvo: (o) => this.mudarAlvo(o)
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
@@ -190,19 +190,19 @@ class j extends P {
|
|
|
190
190
|
(t = (e = this.seletor) == null ? void 0 : e.elemento) == null || t.trocarAlvo(this._alvo);
|
|
191
191
|
}
|
|
192
192
|
aplicarDoSeletor(e, t) {
|
|
193
|
-
const
|
|
193
|
+
const a = (r) => {
|
|
194
194
|
const p = [];
|
|
195
|
-
return e.preenchimento !==
|
|
196
|
-
},
|
|
197
|
-
if (this._preenchimento = e.preenchimento, this._traco = e.traco, this._opacidade = e.opacidade, e.espessuraTraco !== void 0 && (this._espessuraTraco = e.espessuraTraco),
|
|
198
|
-
|
|
195
|
+
return e.preenchimento !== r.preenchimento && p.push("preenchimento"), e.traco !== r.traco && p.push("traco"), e.opacidade !== r.opacidade && p.push("opacidade"), e.espessuraTraco !== void 0 && Math.abs(e.espessuraTraco - r.espessuraTraco) > 0.05 && p.push("espessuraTraco"), p;
|
|
196
|
+
}, o = a(this.obterCores());
|
|
197
|
+
if (this._preenchimento = e.preenchimento, this._traco = e.traco, this._opacidade = e.opacidade, e.espessuraTraco !== void 0 && (this._espessuraTraco = e.espessuraTraco), o.includes("preenchimento") && (this._misto.preenchimento = !1), o.includes("traco") && (this._misto.traco = !1), this.atualizar(), !t) {
|
|
198
|
+
o.length && this.emitirCores(!1, o, "seletor");
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
|
-
this.emitirCores(!0, this.estadoAoAbrir ?
|
|
201
|
+
this.emitirCores(!0, this.estadoAoAbrir ? a(this.estadoAoAbrir) : o, "seletor"), this.estadoAoAbrir = null;
|
|
202
202
|
}
|
|
203
|
-
emitirCores(e, t,
|
|
204
|
-
const
|
|
205
|
-
this.dispatchEvent(new CustomEvent("ui-cores-change", { detail:
|
|
203
|
+
emitirCores(e, t, a) {
|
|
204
|
+
const o = { ...this.obterCores(), confirmado: e, alterados: t, origem: a };
|
|
205
|
+
this.dispatchEvent(new CustomEvent("ui-cores-change", { detail: o, bubbles: !0, composed: !0 }));
|
|
206
206
|
}
|
|
207
207
|
dica(e, t) {
|
|
208
208
|
return t ? `${e} [${t}]` : e;
|
|
@@ -243,45 +243,45 @@ class j extends P {
|
|
|
243
243
|
}
|
|
244
244
|
vincularEventos() {
|
|
245
245
|
const e = this.raiz;
|
|
246
|
-
e.querySelectorAll("[data-alvo]").forEach((
|
|
247
|
-
const
|
|
248
|
-
this.listeners.add(
|
|
249
|
-
|
|
250
|
-
}), this.listeners.add(
|
|
251
|
-
|
|
252
|
-
}), this.listeners.add(
|
|
253
|
-
|
|
254
|
-
}), this.listeners.add(
|
|
255
|
-
|
|
246
|
+
e.querySelectorAll("[data-alvo]").forEach((a) => {
|
|
247
|
+
const o = a.dataset.alvo;
|
|
248
|
+
this.listeners.add(a, "click", (r) => {
|
|
249
|
+
r.stopPropagation(), o !== this._alvo ? this.mudarAlvo(o) : this.seletorAberto ? this.fecharSeletor(!0) : this.abrirSeletor(o);
|
|
250
|
+
}), this.listeners.add(a, "dblclick", (r) => {
|
|
251
|
+
r.stopPropagation(), this.abrirSeletor(o);
|
|
252
|
+
}), this.listeners.add(a, "keydown", (r) => {
|
|
253
|
+
r.key !== "Enter" && r.key !== " " || (r.preventDefault(), o === this._alvo && this.seletorAberto ? this.fecharSeletor(!0) : this.abrirSeletor(o, !0));
|
|
254
|
+
}), this.listeners.add(a, "keyup", (r) => {
|
|
255
|
+
r.key === " " && r.preventDefault();
|
|
256
256
|
});
|
|
257
257
|
});
|
|
258
|
-
const t = (
|
|
259
|
-
this.listeners.add(e.querySelector(`[data-acao="${
|
|
260
|
-
|
|
258
|
+
const t = (a, o) => {
|
|
259
|
+
this.listeners.add(e.querySelector(`[data-acao="${a}"]`), "click", (r) => {
|
|
260
|
+
r.stopPropagation(), o();
|
|
261
261
|
});
|
|
262
262
|
};
|
|
263
263
|
t("inverter", () => this.inverter()), t("sem-cor", () => this.semCor()), t("padrao", () => this.restaurarPadrao());
|
|
264
264
|
}
|
|
265
265
|
atualizar() {
|
|
266
266
|
if (!this.renderizado) return;
|
|
267
|
-
const e = this.raiz, t = this._atalhos,
|
|
268
|
-
const l = e.querySelector(`[data-alvo="${
|
|
267
|
+
const e = this.raiz, t = this._atalhos, a = this.hasAttribute("desabilitado"), o = (s, n) => n ? "Misto (?) [várias cores na seleção]" : s === "none" ? "Sem cor" : s, r = (s, n, c, C, w = "") => {
|
|
268
|
+
const l = e.querySelector(`[data-alvo="${s}"]`), u = l == null ? void 0 : l.querySelector(".face");
|
|
269
269
|
if (!l || !u) return;
|
|
270
|
-
const _ = this._alvo ===
|
|
271
|
-
l.classList.toggle("amostra--ativa", _), l.setAttribute("aria-pressed", String(_)), l.disabled =
|
|
272
|
-
const
|
|
273
|
-
u.style[
|
|
274
|
-
const x = `${
|
|
270
|
+
const _ = this._alvo === s;
|
|
271
|
+
l.classList.toggle("amostra--ativa", _), l.setAttribute("aria-pressed", String(_)), l.disabled = a, u.classList.toggle("face--misto", c), u.classList.toggle("face--sem-cor", !c && n === "none");
|
|
272
|
+
const A = s === "traco" ? "borderColor" : "backgroundColor";
|
|
273
|
+
u.style[A] = c || n === "none" ? "" : n, s === "traco" && n !== "none" && !c && (u.style.borderWidth = `${Math.max(2, Math.min(4.5, this._espessuraTraco))}px`);
|
|
274
|
+
const x = `${C}: ${o(n, c)}${w}`;
|
|
275
275
|
l.title = this.dica(`${x} — clique para ativar, clique de novo para editar`, t.alternar), l.setAttribute("aria-label", x);
|
|
276
276
|
}, p = this._preenchimento === "none" || this._misto.preenchimento ? "" : `, opacidade ${Math.round(this._opacidade * 100)}%`;
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
const c = e.querySelector(`[data-acao="${
|
|
282
|
-
c && (c.title = n, c.disabled =
|
|
277
|
+
r("preenchimento", this._preenchimento, this._misto.preenchimento, "Preenchimento", p);
|
|
278
|
+
const y = this._traco === "none" || this._misto.traco ? "" : `, espessura ${this._espessuraTraco}px`;
|
|
279
|
+
r("traco", this._traco, this._misto.traco, "Traço / contorno", y);
|
|
280
|
+
const m = (s, n) => {
|
|
281
|
+
const c = e.querySelector(`[data-acao="${s}"]`);
|
|
282
|
+
c && (c.title = n, c.disabled = a);
|
|
283
283
|
};
|
|
284
|
-
|
|
284
|
+
m("inverter", this.dica("Inverter preenchimento e traço", t.inverter)), m("sem-cor", this.dica("Sem cor no alvo ativo", t.semCor)), m("padrao", this.dica("Restaurar cores padrão", t.padrao));
|
|
285
285
|
const b = e.querySelector(".ponto--preenchimento");
|
|
286
286
|
b && (b.style.backgroundColor = this._padrao.preenchimento === "none" ? "transparent" : this._padrao.preenchimento);
|
|
287
287
|
const v = e.querySelector(".ponto--traco");
|
|
@@ -294,10 +294,10 @@ export {
|
|
|
294
294
|
j as UIControleCores,
|
|
295
295
|
F as UISeletorCor,
|
|
296
296
|
E as abrirSeletorCor,
|
|
297
|
-
|
|
297
|
+
S as coresUnicas,
|
|
298
298
|
N as escaparHtml,
|
|
299
299
|
G as fecharSeletorCor,
|
|
300
|
-
|
|
300
|
+
f as normalizarCor,
|
|
301
301
|
g as normalizarEspessura,
|
|
302
|
-
|
|
302
|
+
T as normalizarOpacidade
|
|
303
303
|
};
|