@wrrdev/fenix-ui 1.0.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/README.md +117 -0
- package/dist/cdn.d.ts +6 -0
- package/dist/cdn.d.ts.map +1 -0
- package/dist/components/alert/alert.d.ts +14 -0
- package/dist/components/alert/alert.d.ts.map +1 -0
- package/dist/components/alert/alert.js +74 -0
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/alert/index.d.ts +8 -0
- package/dist/components/alert/index.d.ts.map +1 -0
- package/dist/components/alert/index.js +7 -0
- package/dist/components/alert/index.js.map +1 -0
- package/dist/components/autocomplete/autocomplete.d.ts +20 -0
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -0
- package/dist/components/autocomplete/autocomplete.js +144 -0
- package/dist/components/autocomplete/autocomplete.js.map +1 -0
- package/dist/components/autocomplete/index.d.ts +8 -0
- package/dist/components/autocomplete/index.d.ts.map +1 -0
- package/dist/components/autocomplete/index.js +7 -0
- package/dist/components/autocomplete/index.js.map +1 -0
- package/dist/components/badge/badge.d.ts +14 -0
- package/dist/components/badge/badge.d.ts.map +1 -0
- package/dist/components/badge/badge.js +46 -0
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.d.ts.map +1 -0
- package/dist/components/badge/index.js +7 -0
- package/dist/components/badge/index.js.map +1 -0
- package/dist/components/button/button.d.ts +30 -0
- package/dist/components/button/button.d.ts.map +1 -0
- package/dist/components/button/button.js +194 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.d.ts.map +1 -0
- package/dist/components/button/index.js +7 -0
- package/dist/components/button/index.js.map +1 -0
- package/dist/components/calendar/calendar.d.ts +39 -0
- package/dist/components/calendar/calendar.d.ts.map +1 -0
- package/dist/components/calendar/calendar.js +346 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.d.ts.map +1 -0
- package/dist/components/calendar/index.js +7 -0
- package/dist/components/calendar/index.js.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +24 -0
- package/dist/components/checkbox/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox/checkbox.js +142 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.d.ts.map +1 -0
- package/dist/components/checkbox/index.js +7 -0
- package/dist/components/checkbox/index.js.map +1 -0
- package/dist/components/datepicker/datepicker.d.ts +62 -0
- package/dist/components/datepicker/datepicker.d.ts.map +1 -0
- package/dist/components/datepicker/datepicker.js +441 -0
- package/dist/components/datepicker/datepicker.js.map +1 -0
- package/dist/components/datepicker/index.d.ts +3 -0
- package/dist/components/datepicker/index.d.ts.map +1 -0
- package/dist/components/datepicker/index.js +8 -0
- package/dist/components/datepicker/index.js.map +1 -0
- package/dist/components/dialog/dialog.d.ts +19 -0
- package/dist/components/dialog/dialog.d.ts.map +1 -0
- package/dist/components/dialog/dialog.js +134 -0
- package/dist/components/dialog/dialog.js.map +1 -0
- package/dist/components/dialog/index.d.ts +8 -0
- package/dist/components/dialog/index.d.ts.map +1 -0
- package/dist/components/dialog/index.js +7 -0
- package/dist/components/dialog/index.js.map +1 -0
- package/dist/components/drawer/drawer.d.ts +27 -0
- package/dist/components/drawer/drawer.d.ts.map +1 -0
- package/dist/components/drawer/drawer.js +195 -0
- package/dist/components/drawer/drawer.js.map +1 -0
- package/dist/components/drawer/index.d.ts +8 -0
- package/dist/components/drawer/index.d.ts.map +1 -0
- package/dist/components/drawer/index.js +7 -0
- package/dist/components/drawer/index.js.map +1 -0
- package/dist/components/dropdown/dropdown.d.ts +28 -0
- package/dist/components/dropdown/dropdown.d.ts.map +1 -0
- package/dist/components/dropdown/dropdown.js +137 -0
- package/dist/components/dropdown/dropdown.js.map +1 -0
- package/dist/components/dropdown/index.d.ts +9 -0
- package/dist/components/dropdown/index.d.ts.map +1 -0
- package/dist/components/dropdown/index.js +9 -0
- package/dist/components/dropdown/index.js.map +1 -0
- package/dist/components/floatlabel/floatlabel.d.ts +42 -0
- package/dist/components/floatlabel/floatlabel.d.ts.map +1 -0
- package/dist/components/floatlabel/floatlabel.js +270 -0
- package/dist/components/floatlabel/floatlabel.js.map +1 -0
- package/dist/components/floatlabel/index.d.ts +2 -0
- package/dist/components/floatlabel/index.d.ts.map +1 -0
- package/dist/components/floatlabel/index.js +7 -0
- package/dist/components/floatlabel/index.js.map +1 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.d.ts.map +1 -0
- package/dist/components/input/index.js +7 -0
- package/dist/components/input/index.js.map +1 -0
- package/dist/components/input/input.d.ts +22 -0
- package/dist/components/input/input.d.ts.map +1 -0
- package/dist/components/input/input.js +169 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/multiselect/index.d.ts +2 -0
- package/dist/components/multiselect/index.d.ts.map +1 -0
- package/dist/components/multiselect/index.js +7 -0
- package/dist/components/multiselect/index.js.map +1 -0
- package/dist/components/multiselect/multiselect.d.ts +32 -0
- package/dist/components/multiselect/multiselect.d.ts.map +1 -0
- package/dist/components/multiselect/multiselect.js +389 -0
- package/dist/components/multiselect/multiselect.js.map +1 -0
- package/dist/components/pagination/index.d.ts +8 -0
- package/dist/components/pagination/index.d.ts.map +1 -0
- package/dist/components/pagination/index.js +7 -0
- package/dist/components/pagination/index.js.map +1 -0
- package/dist/components/pagination/pagination.d.ts +23 -0
- package/dist/components/pagination/pagination.d.ts.map +1 -0
- package/dist/components/pagination/pagination.js +121 -0
- package/dist/components/pagination/pagination.js.map +1 -0
- package/dist/components/progress/index.d.ts +8 -0
- package/dist/components/progress/index.d.ts.map +1 -0
- package/dist/components/progress/index.js +7 -0
- package/dist/components/progress/index.js.map +1 -0
- package/dist/components/progress/progress.d.ts +18 -0
- package/dist/components/progress/progress.d.ts.map +1 -0
- package/dist/components/progress/progress.js +99 -0
- package/dist/components/progress/progress.js.map +1 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/index.d.ts.map +1 -0
- package/dist/components/radio/index.js +7 -0
- package/dist/components/radio/index.js.map +1 -0
- package/dist/components/radio/radio.d.ts +23 -0
- package/dist/components/radio/radio.d.ts.map +1 -0
- package/dist/components/radio/radio.js +133 -0
- package/dist/components/radio/radio.js.map +1 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.d.ts.map +1 -0
- package/dist/components/select/index.js +7 -0
- package/dist/components/select/index.js.map +1 -0
- package/dist/components/select/select.d.ts +36 -0
- package/dist/components/select/select.d.ts.map +1 -0
- package/dist/components/select/select.js +287 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/skeleton/index.d.ts +8 -0
- package/dist/components/skeleton/index.d.ts.map +1 -0
- package/dist/components/skeleton/index.js +7 -0
- package/dist/components/skeleton/index.js.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +13 -0
- package/dist/components/skeleton/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton/skeleton.js +57 -0
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/index.d.ts.map +1 -0
- package/dist/components/spinner/index.js +7 -0
- package/dist/components/spinner/index.js.map +1 -0
- package/dist/components/spinner/spinner.d.ts +16 -0
- package/dist/components/spinner/spinner.d.ts.map +1 -0
- package/dist/components/spinner/spinner.js +50 -0
- package/dist/components/spinner/spinner.js.map +1 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.d.ts.map +1 -0
- package/dist/components/switch/index.js +7 -0
- package/dist/components/switch/index.js.map +1 -0
- package/dist/components/switch/switch.d.ts +22 -0
- package/dist/components/switch/switch.d.ts.map +1 -0
- package/dist/components/switch/switch.js +115 -0
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.d.ts.map +1 -0
- package/dist/components/table/index.js +7 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/table/table.d.ts +38 -0
- package/dist/components/table/table.d.ts.map +1 -0
- package/dist/components/table/table.js +258 -0
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/tabs/index.d.ts +9 -0
- package/dist/components/tabs/index.d.ts.map +1 -0
- package/dist/components/tabs/index.js +9 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +38 -0
- package/dist/components/tabs/tabs.d.ts.map +1 -0
- package/dist/components/tabs/tabs.js +162 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/textarea/index.d.ts +8 -0
- package/dist/components/textarea/index.d.ts.map +1 -0
- package/dist/components/textarea/index.js +7 -0
- package/dist/components/textarea/index.js.map +1 -0
- package/dist/components/textarea/textarea.d.ts +19 -0
- package/dist/components/textarea/textarea.d.ts.map +1 -0
- package/dist/components/textarea/textarea.js +109 -0
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/toast/index.d.ts +8 -0
- package/dist/components/toast/index.d.ts.map +1 -0
- package/dist/components/toast/index.js +8 -0
- package/dist/components/toast/index.js.map +1 -0
- package/dist/components/toast/toast.d.ts +40 -0
- package/dist/components/toast/toast.d.ts.map +1 -0
- package/dist/components/toast/toast.js +176 -0
- package/dist/components/toast/toast.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +8 -0
- package/dist/components/tooltip/index.d.ts.map +1 -0
- package/dist/components/tooltip/index.js +7 -0
- package/dist/components/tooltip/index.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +14 -0
- package/dist/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip/tooltip.js +86 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/core/base.d.ts +29 -0
- package/dist/core/base.d.ts.map +1 -0
- package/dist/core/base.js +41 -0
- package/dist/core/base.js.map +1 -0
- package/dist/core/css.d.ts +6 -0
- package/dist/core/css.d.ts.map +1 -0
- package/dist/core/css.js +11 -0
- package/dist/core/css.js.map +1 -0
- package/dist/core/define.d.ts +8 -0
- package/dist/core/define.d.ts.map +1 -0
- package/dist/core/define.js +10 -0
- package/dist/core/define.js.map +1 -0
- package/dist/core/presets.d.ts +40 -0
- package/dist/core/presets.d.ts.map +1 -0
- package/dist/core/presets.js +80 -0
- package/dist/core/presets.js.map +1 -0
- package/dist/core/theme.d.ts +47 -0
- package/dist/core/theme.d.ts.map +1 -0
- package/dist/core/theme.js +76 -0
- package/dist/core/theme.js.map +1 -0
- package/dist/core/tokens.d.ts +36 -0
- package/dist/core/tokens.d.ts.map +1 -0
- package/dist/core/tokens.js +83 -0
- package/dist/core/tokens.js.map +1 -0
- package/dist/docs/app.d.ts +37 -0
- package/dist/docs/app.d.ts.map +1 -0
- package/dist/fenix-ui.esm.js +4471 -0
- package/dist/fenix-ui.esm.js.map +1 -0
- package/dist/fenix-ui.umd.min.js +2022 -0
- package/dist/fenix-ui2.esm.js +82 -0
- package/dist/fenix-ui2.esm.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/auto-import.d.ts +18 -0
- package/dist/plugins/auto-import.d.ts.map +1 -0
- package/dist/plugins/auto-import.js +69 -0
- package/dist/plugins/auto-import.js.map +1 -0
- package/dist/plugins/index.d.ts +25 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +21 -0
- package/dist/plugins/index.js.map +1 -0
- package/package.json +169 -0
|
@@ -0,0 +1,2022 @@
|
|
|
1
|
+
(function(k){typeof define=="function"&&define.amd?define(k):k()})(function(){"use strict";var qt=k=>{throw TypeError(k)};var ue=(k,m,p)=>m.has(k)||qt("Cannot "+p);var Dt=(k,m,p)=>m.has(k)?qt("Cannot add the same private member more than once"):m instanceof WeakSet?m.add(k):m.set(k,p);var Mt=(k,m,p)=>(ue(k,m,"access private method"),p);var C,Nt;const k=new Map;function m(g){return k.set(g.name,g),g}m({name:"fenix",label:"Fenix (padrão)",tokens:{}}),m({name:"seiya",label:"Seiya",tokens:{color:{primary:"#e11d48",secondary:"#fb7185",info:"#f43f5e",danger:"#be123c"},radius:{sm:"6px",md:"10px",lg:"16px"}}}),m({name:"shiryu",label:"Shiryu",tokens:{color:{primary:"#0d9488",secondary:"#2dd4bf",success:"#059669",info:"#14b8a6"},radius:{sm:"4px",md:"8px",lg:"14px"}}}),m({name:"hyoga",label:"Hyoga",tokens:{color:{primary:"#0284c7",secondary:"#38bdf8",info:"#06b6d4",danger:"#e11d48"},surface:{surface:"#f0f9ff","surface-hover":"#e0f2fe"},radius:{sm:"8px",md:"12px",lg:"18px"}}}),m({name:"shun",label:"Shun",tokens:{color:{primary:"#db2777",secondary:"#f472b6",info:"#ec4899",warning:"#c026d3"},radius:{sm:"10px",md:"14px",lg:"20px"}}}),m({name:"ikki",label:"Ikki",tokens:{color:{primary:"#ea580c",secondary:"#fb923c",danger:"#dc2626",warning:"#f59e0b"},radius:{sm:"2px",md:"4px",lg:"6px"}}}),m({name:"aiolia",label:"Aiolia",tokens:{color:{primary:"#b45309",secondary:"#f59e0b",warning:"#eab308",info:"#84cc16"},radius:{sm:"6px",md:"12px",lg:"20px"}}});function p(g,...t){return g.reduce((e,r,s)=>e+r+(s<t.length?String(t[s]):""),"")}const et=class et extends HTMLElement{static get observedAttributes(){return[]}constructor(){super(),this.root=this.attachShadow({mode:"open"})}attributeChangedCallback(){this.isConnected&&this.render()}connectedCallback(){this.render()}disconnectedCallback(){}hasAttr(t){return this.hasAttribute(t)}getAttr(t,e=""){var r;return(r=this.getAttribute(t))!=null?r:e}toggleAttr(t,e){e?this.setAttribute(t,""):this.removeAttribute(t)}setTemplate(t){const e=this.constructor.styles;this.root.innerHTML=`<style>${e}</style>${t}`}};et.styles="";let x=et;function v(g,t){var e;return typeof customElements!="undefined"&&!customElements.get(g)&&customElements.define(g,t),(e=customElements.get(g))!=null?e:t}const rt=class rt extends x{constructor(){super(...arguments),this.spawnRipple=t=>{if(this.hasAttr("disabled")||this.hasAttr("loading"))return;const e=getComputedStyle(this).getPropertyValue("--fx-effect-ripple").trim();if(e==="0"||e==="false")return;const r=this.root.querySelector(".btn");if(!r)return;const s=r.getBoundingClientRect(),o=Math.max(s.width,s.height),a=document.createElement("span");a.className="btn__ripple",a.style.width=a.style.height=`${o}px`,a.style.left=`${t.clientX-s.left-o/2}px`,a.style.top=`${t.clientY-s.top-o/2}px`,r.appendChild(a),a.addEventListener("animationend",()=>a.remove())}}static get observedAttributes(){return["variant","size","disabled","loading","type","full"]}get size(){const t=this.getAttr("size","md");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get disabled(){return this.hasAttr("disabled")}set disabled(t){this.toggleAttr("disabled",!!t)}get loading(){return this.hasAttr("loading")}set loading(t){this.toggleAttr("loading",!!t)}render(){const t=this.hasAttr("loading"),e=this.hasAttr("disabled")||t,r=this.getAttr("type","button");this.setTemplate(`
|
|
2
|
+
<button class="btn" part="button" type="${r}">
|
|
3
|
+
<span class="btn__icon" part="icon"><slot name="icon"></slot></span>
|
|
4
|
+
<span class="btn__label" part="label"><slot></slot></span>
|
|
5
|
+
${t?'<span class="btn__spinner" aria-hidden="true"></span>':""}
|
|
6
|
+
</button>
|
|
7
|
+
`);const s=this.root.querySelector(".btn");if(!s)return;const o=s.querySelector(".btn__icon slot"),a=this.root.querySelector(".btn__icon"),l=!!(o!=null&&o.assignedNodes({flatten:!0}).some(i=>{var c;return i.nodeType===Node.ELEMENT_NODE||((c=i.textContent)!=null?c:"").trim()!==""}));a==null||a.toggleAttribute("hidden",!l),e?(s.setAttribute("disabled",""),s.setAttribute("aria-disabled","true")):(s.removeAttribute("disabled"),s.removeAttribute("aria-disabled")),t?s.setAttribute("aria-busy","true"):s.removeAttribute("aria-busy")}connectedCallback(){super.connectedCallback(),this.addEventListener("pointerdown",this.spawnRipple)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("pointerdown",this.spawnRipple)}};rt.styles=p`
|
|
8
|
+
:host {
|
|
9
|
+
display: inline-block;
|
|
10
|
+
vertical-align: middle;
|
|
11
|
+
}
|
|
12
|
+
.btn {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
text-align: center;
|
|
17
|
+
gap: var(--fx-space-sm);
|
|
18
|
+
font-family: var(--fx-font-family);
|
|
19
|
+
font-size: var(--fx-font-size);
|
|
20
|
+
font-weight: var(--fx-font-weight);
|
|
21
|
+
line-height: var(--fx-font-line-height);
|
|
22
|
+
padding: var(--fx-space-md) var(--fx-space-xl);
|
|
23
|
+
border-radius: var(--fx-radius-md);
|
|
24
|
+
border: 1px solid transparent;
|
|
25
|
+
color: #fff;
|
|
26
|
+
background: var(--fx-color-primary);
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
user-select: none;
|
|
29
|
+
text-decoration: none;
|
|
30
|
+
transition:
|
|
31
|
+
background-color var(--fx-motion-duration-normal) var(--fx-motion-easing),
|
|
32
|
+
border-color var(--fx-motion-duration-normal) var(--fx-motion-easing),
|
|
33
|
+
transform var(--fx-motion-duration-fast) var(--fx-motion-easing),
|
|
34
|
+
box-shadow var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
35
|
+
}
|
|
36
|
+
.btn:focus-visible {
|
|
37
|
+
outline: 2px solid var(--fx-color-primary);
|
|
38
|
+
outline-offset: 2px;
|
|
39
|
+
}
|
|
40
|
+
.btn:hover { filter: brightness(0.88); }
|
|
41
|
+
.btn:active { transform: translateY(1px); }
|
|
42
|
+
|
|
43
|
+
/* Tamanhos — alturas vindas dos tokens (personalizáveis por preset) */
|
|
44
|
+
.btn { min-height: var(--fx-size-md); }
|
|
45
|
+
:host([size='sm']) .btn { padding: var(--fx-space-sm) var(--fx-space-lg); font-size: var(--fx-font-size); min-height: var(--fx-size-sm); }
|
|
46
|
+
:host([size='lg']) .btn { padding: var(--fx-space-lg) var(--fx-space-xl); font-size: calc(var(--fx-font-size) + 4px); min-height: var(--fx-size-lg); }
|
|
47
|
+
|
|
48
|
+
/* Full width */
|
|
49
|
+
:host([full]) .btn { width: 100%; }
|
|
50
|
+
|
|
51
|
+
/* Variantes */
|
|
52
|
+
:host([variant='secondary']) .btn { background: var(--fx-color-secondary); }
|
|
53
|
+
:host([variant='success']) .btn { background: var(--fx-color-success); }
|
|
54
|
+
:host([variant='warning']) .btn { background: var(--fx-color-warning); }
|
|
55
|
+
:host([variant='danger']) .btn { background: var(--fx-color-danger); }
|
|
56
|
+
:host([variant='ghost']) .btn { background: transparent; color: var(--fx-text-default); }
|
|
57
|
+
:host([variant='ghost']) .btn:hover { background: var(--fx-surface-surface-hover); filter: none; }
|
|
58
|
+
:host([variant='outline']) .btn { background: transparent; color: var(--fx-color-primary); border-color: var(--fx-color-primary); }
|
|
59
|
+
:host([variant='outline']) .btn:hover { background: var(--fx-surface-surface-hover); filter: none; }
|
|
60
|
+
|
|
61
|
+
/* Ícone e spinner */
|
|
62
|
+
.btn__icon { display: inline-flex; }
|
|
63
|
+
.btn__icon[hidden] { display: none; }
|
|
64
|
+
.btn__label { display: inline-flex; align-items: center; justify-content: center; }
|
|
65
|
+
.btn[hidden] { display: none; }
|
|
66
|
+
.btn__spinner {
|
|
67
|
+
width: 1em;
|
|
68
|
+
height: 1em;
|
|
69
|
+
border: 2px solid currentColor;
|
|
70
|
+
border-top-color: transparent;
|
|
71
|
+
border-radius: var(--fx-radius-full);
|
|
72
|
+
animation: fx-spin var(--fx-motion-duration-normal) linear infinite;
|
|
73
|
+
}
|
|
74
|
+
@keyframes fx-spin { to { transform: rotate(360deg); } }
|
|
75
|
+
|
|
76
|
+
/* Estados */
|
|
77
|
+
:host([disabled]) .btn,
|
|
78
|
+
:host([loading]) .btn {
|
|
79
|
+
opacity: 0.55;
|
|
80
|
+
cursor: not-allowed;
|
|
81
|
+
pointer-events: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Efeito ripple (). Desative com effect.ripple: '0' no preset. */
|
|
85
|
+
.btn {
|
|
86
|
+
position: relative;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
}
|
|
89
|
+
.btn__ripple {
|
|
90
|
+
position: absolute;
|
|
91
|
+
border-radius: var(--fx-radius-full);
|
|
92
|
+
background: currentColor;
|
|
93
|
+
opacity: 0.28;
|
|
94
|
+
transform: scale(0);
|
|
95
|
+
animation: fx-ripple 600ms var(--fx-motion-easing) forwards;
|
|
96
|
+
pointer-events: none;
|
|
97
|
+
}
|
|
98
|
+
@keyframes fx-ripple {
|
|
99
|
+
to {
|
|
100
|
+
transform: scale(2.6);
|
|
101
|
+
opacity: 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
@media (prefers-reduced-motion: reduce) {
|
|
105
|
+
.btn__ripple { display: none; }
|
|
106
|
+
}
|
|
107
|
+
`;let L=rt;function _t(){return v("fx-button",L)}_t();const st=class st extends x{static get observedAttributes(){return["variant","round"]}render(){this.setTemplate('<span class="badge" part="badge"><slot></slot></span>')}};st.styles=p`
|
|
108
|
+
:host {
|
|
109
|
+
display: inline-flex;
|
|
110
|
+
vertical-align: middle;
|
|
111
|
+
}
|
|
112
|
+
.badge {
|
|
113
|
+
display: inline-flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
font-family: var(--fx-font-family);
|
|
116
|
+
font-size: calc(var(--fx-font-size) - 2px);
|
|
117
|
+
font-weight: var(--fx-font-weight);
|
|
118
|
+
line-height: 1;
|
|
119
|
+
padding: var(--fx-space-xs) var(--fx-space-sm);
|
|
120
|
+
border-radius: var(--fx-radius-full);
|
|
121
|
+
border: 1px solid var(--fx-border-default);
|
|
122
|
+
background: var(--fx-surface-background);
|
|
123
|
+
color: var(--fx-text-muted);
|
|
124
|
+
white-space: nowrap;
|
|
125
|
+
}
|
|
126
|
+
:host([variant='primary']) .badge { background: var(--fx-color-primary); color: #fff; border-color: transparent; }
|
|
127
|
+
:host([variant='success']) .badge { background: var(--fx-color-success); color: #fff; border-color: transparent; }
|
|
128
|
+
:host([variant='warning']) .badge { background: var(--fx-color-warning); color: #fff; border-color: transparent; }
|
|
129
|
+
:host([variant='danger']) .badge { background: var(--fx-color-danger); color: #fff; border-color: transparent; }
|
|
130
|
+
:host([variant='info']) .badge { background: var(--fx-color-info); color: #fff; border-color: transparent; }
|
|
131
|
+
:host(:not([round])) .badge { border-radius: var(--fx-radius-sm); }
|
|
132
|
+
`;let T=st;function Pt(){return v("fx-badge",T)}Pt();const ot=class ot extends x{static get observedAttributes(){return["size"]}get size(){const t=this.getAttr("size","md");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}render(){this.setTemplate('<span class="spinner" part="spinner" role="status" aria-label="Carregando"></span>')}};ot.styles=p`
|
|
133
|
+
:host {
|
|
134
|
+
display: inline-block;
|
|
135
|
+
vertical-align: middle;
|
|
136
|
+
}
|
|
137
|
+
/* Escala: sm 16px · md 24px (padrão) · lg 32px */
|
|
138
|
+
.spinner {
|
|
139
|
+
display: inline-block;
|
|
140
|
+
width: var(--fx-space-xl, 20px);
|
|
141
|
+
height: var(--fx-space-xl, 20px);
|
|
142
|
+
border: 2px solid var(--fx-border-default, #e2e8f0);
|
|
143
|
+
border-top-color: var(--fx-color-primary, #2563eb);
|
|
144
|
+
border-radius: var(--fx-radius-full, 9999px);
|
|
145
|
+
animation: fx-spin 0.8s linear infinite;
|
|
146
|
+
}
|
|
147
|
+
:host([size='sm']) .spinner { width: var(--fx-space-lg, 16px); height: var(--fx-space-lg, 16px); }
|
|
148
|
+
:host([size='lg']) .spinner { width: 32px; height: 32px; border-width: 3px; }
|
|
149
|
+
@keyframes fx-spin { to { transform: rotate(360deg); } }
|
|
150
|
+
@media (prefers-reduced-motion: reduce) {
|
|
151
|
+
.spinner { animation-duration: 2.5s; }
|
|
152
|
+
}
|
|
153
|
+
`;let q=ot;function jt(){return v("fx-spinner",q)}jt();const at=class at extends x{static get observedAttributes(){return["size","disabled","placeholder","searchable","clearable","error","success"]}get size(){const t=this.getAttr("size","md");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get value(){return this.getAttr("value")}set value(t){this.setAttribute("value",t)}get disabled(){return this.hasAttr("disabled")}set disabled(t){this.toggleAttr("disabled",!!t)}get options(){return[...this.querySelectorAll("option")].map(t=>{var e,r,s,o,a;return{value:(s=(r=t.getAttribute("value"))!=null?r:(e=t.textContent)==null?void 0:e.trim())!=null?s:"",label:(a=(o=t.textContent)==null?void 0:o.trim())!=null?a:""}})}connectedCallback(){super.connectedCallback(),this.observer=new MutationObserver(()=>this.render()),this.observer.observe(this,{childList:!0,subtree:!0,characterData:!0}),this.docListener=t=>{this.hasAttr("open")&&(t.composedPath().includes(this)||(this.removeAttribute("open"),this.render()))},document.addEventListener("click",this.docListener)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.observer)==null||t.disconnect(),this.docListener&&document.removeEventListener("click",this.docListener)}select(t){this.value=t,this.removeAttribute("open"),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{value:t}}))}render(){var d,u,y,$,w,E,z;const t=this.hasAttr("open"),e=this.root.querySelector(".search"),r=(d=e==null?void 0:e.value)!=null?d:"",s=e!=null&&this.root.activeElement===e,o=s?e.selectionStart:null,a=this.options;let l=this.getAttr("value");if(!l){const b=this.querySelector("option[selected]");l=($=(y=b==null?void 0:b.getAttribute("value"))!=null?y:(u=b==null?void 0:b.textContent)==null?void 0:u.trim())!=null?$:""}const i=(E=(w=a.find(b=>b.value===l))==null?void 0:w.label)!=null?E:"",c=this.getAttr("placeholder","Selecione…"),h=r?a.filter(b=>b.label.toLowerCase().includes(r.toLowerCase())):a;this.setTemplate(`
|
|
154
|
+
<span class="trigger" part="trigger" role="button" tabindex="${this.disabled?-1:0}" aria-haspopup="listbox" aria-expanded="${t}">
|
|
155
|
+
<span class="${i?"label":"placeholder"}">${i||c}</span>
|
|
156
|
+
<span class="actions">
|
|
157
|
+
${this.hasAttr("clearable")&&l?'<button type="button" class="clear" part="clear" aria-label="Limpar">×</button>':""}
|
|
158
|
+
<span class="caret">▼</span>
|
|
159
|
+
</span>
|
|
160
|
+
</span>
|
|
161
|
+
<div class="panel" part="panel" role="listbox">
|
|
162
|
+
${this.hasAttr("searchable")?`<input class="search" part="search" type="text" placeholder="${this.getAttr("search-placeholder","Pesquisar…")}">`:""}
|
|
163
|
+
${h.map(b=>`
|
|
164
|
+
<button type="button" class="opt" role="option" data-value="${b.value}"
|
|
165
|
+
aria-selected="${b.value===l}">${b.label}</button>`).join("")}
|
|
166
|
+
${h.length===0?`<div class="empty">${this.getAttr("no-results","Nenhum resultado")}</div>`:""}
|
|
167
|
+
</div>
|
|
168
|
+
`),t&&this.setAttribute("open","");const n=this.root.querySelector(".search");if(n&&(n.value=r,n.addEventListener("input",()=>this.render()),n.addEventListener("click",b=>b.stopPropagation()),s)){n.focus();try{n.setSelectionRange(o,o)}catch(b){}}const f=this.root.querySelector(".trigger");f&&(this.disabled&&f.setAttribute("aria-disabled","true"),f.addEventListener("click",b=>{var Tt;this.disabled||b.target.closest(".clear")||(this.toggleAttribute("open"),this.render(),(Tt=this.root.querySelector(".search"))==null||Tt.focus())}),f.addEventListener("keydown",b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),f.click())}),(z=this.root.querySelector(".clear"))==null||z.addEventListener("click",b=>{b.stopPropagation(),this.value="",this.removeAttribute("open"),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{value:""}}))}),this.root.querySelectorAll(".opt").forEach(b=>{b.addEventListener("click",()=>this.select(b.dataset.value))}))}};at.styles=p`
|
|
169
|
+
:host {
|
|
170
|
+
display: inline-block;
|
|
171
|
+
vertical-align: middle;
|
|
172
|
+
font-family: var(--fx-font-family);
|
|
173
|
+
font-size: var(--fx-font-size);
|
|
174
|
+
position: relative;
|
|
175
|
+
}
|
|
176
|
+
.trigger {
|
|
177
|
+
display: inline-flex;
|
|
178
|
+
align-items: center;
|
|
179
|
+
justify-content: space-between;
|
|
180
|
+
gap: var(--fx-space-sm);
|
|
181
|
+
box-sizing: border-box;
|
|
182
|
+
min-height: var(--fx-size-md);
|
|
183
|
+
min-width: 200px;
|
|
184
|
+
font: inherit;
|
|
185
|
+
font-weight: var(--fx-font-weight);
|
|
186
|
+
color: var(--fx-text-default);
|
|
187
|
+
text-align: left;
|
|
188
|
+
background-color: var(--fx-surface-background);
|
|
189
|
+
border: 1px solid var(--fx-border-default);
|
|
190
|
+
border-radius: var(--fx-radius-md);
|
|
191
|
+
padding: var(--fx-space-xs) var(--fx-space-md);
|
|
192
|
+
cursor: pointer;
|
|
193
|
+
transition:
|
|
194
|
+
border-color var(--fx-motion-duration-normal) var(--fx-motion-easing),
|
|
195
|
+
box-shadow var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
196
|
+
}
|
|
197
|
+
.trigger:hover { border-color: var(--fx-border-hover); }
|
|
198
|
+
.trigger:focus-visible,
|
|
199
|
+
:host([open]) .trigger {
|
|
200
|
+
outline: none;
|
|
201
|
+
border-color: var(--fx-color-primary);
|
|
202
|
+
box-shadow: var(--fx-effect-focus-ring, none);
|
|
203
|
+
}
|
|
204
|
+
:host([size='sm']) .trigger { min-width: 180px; min-height: var(--fx-size-sm); }
|
|
205
|
+
:host([size='lg']) .trigger { min-height: var(--fx-size-lg); font-size: calc(var(--fx-font-size) + 4px); }
|
|
206
|
+
/* Validação */
|
|
207
|
+
:host([error]) .trigger,
|
|
208
|
+
:host([invalid]) .trigger {
|
|
209
|
+
border-color: var(--fx-color-danger, #dc2626);
|
|
210
|
+
}
|
|
211
|
+
:host([error]) .trigger:focus-visible,
|
|
212
|
+
:host([invalid]) .trigger:focus-visible,
|
|
213
|
+
:host([error][open]) .trigger,
|
|
214
|
+
:host([invalid][open]) .trigger {
|
|
215
|
+
border-color: var(--fx-color-danger, #dc2626);
|
|
216
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-color-danger, #dc2626) 18%, transparent);
|
|
217
|
+
}
|
|
218
|
+
:host([success]) .trigger,
|
|
219
|
+
:host([valid]) .trigger {
|
|
220
|
+
border-color: var(--fx-color-success, #16a34a);
|
|
221
|
+
}
|
|
222
|
+
:host([success]) .trigger:focus-visible,
|
|
223
|
+
:host([valid]) .trigger:focus-visible,
|
|
224
|
+
:host([success][open]) .trigger,
|
|
225
|
+
:host([valid][open]) .trigger {
|
|
226
|
+
border-color: var(--fx-color-success, #16a34a);
|
|
227
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-color-success, #16a34a) 18%, transparent);
|
|
228
|
+
}
|
|
229
|
+
:host([disabled]) .trigger,
|
|
230
|
+
.trigger[aria-disabled='true'] { opacity: 0.55; cursor: not-allowed; background-color: var(--fx-surface-surface-hover); }
|
|
231
|
+
/* O rótulo encolhe (ellipsis) e os ícones NUNCA saem do campo. */
|
|
232
|
+
.label,
|
|
233
|
+
.placeholder {
|
|
234
|
+
flex: 1 1 auto;
|
|
235
|
+
min-width: 0;
|
|
236
|
+
overflow: hidden;
|
|
237
|
+
text-overflow: ellipsis;
|
|
238
|
+
white-space: nowrap;
|
|
239
|
+
}
|
|
240
|
+
.placeholder { color: var(--fx-text-muted); }
|
|
241
|
+
.actions {
|
|
242
|
+
display: inline-flex;
|
|
243
|
+
align-items: center;
|
|
244
|
+
gap: var(--fx-space-xs, 8px);
|
|
245
|
+
flex-shrink: 0;
|
|
246
|
+
}
|
|
247
|
+
.caret { font-size: calc(var(--fx-font-size) - 3px); color: var(--fx-text-muted); pointer-events: none; }
|
|
248
|
+
|
|
249
|
+
/* Painel do dropdown */
|
|
250
|
+
.panel {
|
|
251
|
+
position: absolute;
|
|
252
|
+
top: calc(100% + 4px);
|
|
253
|
+
left: 0;
|
|
254
|
+
z-index: var(--fx-z-dropdown, 1000);
|
|
255
|
+
width: max(100%, 220px);
|
|
256
|
+
max-height: 260px;
|
|
257
|
+
overflow-y: auto;
|
|
258
|
+
display: none;
|
|
259
|
+
background: var(--fx-surface-background);
|
|
260
|
+
border: 1px solid var(--fx-border-default);
|
|
261
|
+
border-radius: var(--fx-radius-md);
|
|
262
|
+
box-shadow: var(--fx-shadow-lg);
|
|
263
|
+
}
|
|
264
|
+
:host([open]) .panel { display: block; }
|
|
265
|
+
.search {
|
|
266
|
+
position: sticky;
|
|
267
|
+
top: 0;
|
|
268
|
+
width: 100%;
|
|
269
|
+
box-sizing: border-box;
|
|
270
|
+
font: inherit;
|
|
271
|
+
color: var(--fx-text-default);
|
|
272
|
+
background: var(--fx-surface-background);
|
|
273
|
+
border: none;
|
|
274
|
+
border-bottom: 1px solid var(--fx-border-default);
|
|
275
|
+
padding: var(--fx-space-sm) var(--fx-space-md);
|
|
276
|
+
outline: none;
|
|
277
|
+
}
|
|
278
|
+
.opt {
|
|
279
|
+
display: block;
|
|
280
|
+
width: 100%;
|
|
281
|
+
text-align: left;
|
|
282
|
+
font: inherit;
|
|
283
|
+
color: var(--fx-text-default);
|
|
284
|
+
background: none;
|
|
285
|
+
border: none;
|
|
286
|
+
padding: var(--fx-space-sm) var(--fx-space-md);
|
|
287
|
+
cursor: pointer;
|
|
288
|
+
}
|
|
289
|
+
/* Hover e selecionado com a cor primária do tema (igual ao multiselect). */
|
|
290
|
+
.opt:hover { background: color-mix(in srgb, var(--fx-color-primary) 12%, transparent); }
|
|
291
|
+
.opt[aria-selected='true'] {
|
|
292
|
+
background: color-mix(in srgb, var(--fx-color-primary) 18%, transparent);
|
|
293
|
+
color: var(--fx-color-primary);
|
|
294
|
+
font-weight: var(--fx-font-weight);
|
|
295
|
+
}
|
|
296
|
+
.empty { padding: var(--fx-space-sm) var(--fx-space-md); color: var(--fx-text-muted); }
|
|
297
|
+
|
|
298
|
+
/* Clearable */
|
|
299
|
+
.clear {
|
|
300
|
+
border: none;
|
|
301
|
+
background: transparent;
|
|
302
|
+
color: var(--fx-text-muted);
|
|
303
|
+
font-size: calc(var(--fx-font-size) + 2px);
|
|
304
|
+
line-height: 1;
|
|
305
|
+
cursor: pointer;
|
|
306
|
+
padding: 0;
|
|
307
|
+
}
|
|
308
|
+
.clear:hover { color: var(--fx-color-danger); }
|
|
309
|
+
.clear[hidden] { display: none; }
|
|
310
|
+
`;let D=at;function Rt(){return v("fx-select",D)}Rt();const it=class it extends x{static get observedAttributes(){return["type","size","placeholder","disabled","readonly","min","max","step"]}get size(){const t=this.getAttr("size","md");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get value(){return this.getAttr("value")}set value(t){this.setAttribute("value",t)}get disabled(){return this.hasAttr("disabled")}set disabled(t){this.toggleAttr("disabled",!!t)}render(){const t=this.getAttr("type","text"),e=this.getAttr("placeholder"),r=this.hasAttr("readonly"),s=this.hasAttr("disabled"),o=this.getAttr("min"),a=this.getAttr("max"),l=this.getAttr("step");this.setTemplate(`
|
|
311
|
+
${this.hasAttr("clearable")?'<div class="wrap">':""}
|
|
312
|
+
<input class="field" part="input" type="${t}"
|
|
313
|
+
${e?`placeholder="${e}"`:""}
|
|
314
|
+
${o?`min="${o}"`:""} ${a?`max="${a}"`:""} ${l?`step="${l}"`:""}
|
|
315
|
+
/>
|
|
316
|
+
${this.hasAttr("clearable")?'<button type="button" class="clear" part="clear" aria-label="Limpar" tabindex="-1">×</button></div>':""}
|
|
317
|
+
`);const i=this.root.querySelector(".field");if(!i)return;i.value=this.getAttr("value"),s&&i.setAttribute("disabled",""),r&&i.setAttribute("readonly","");const c=f=>{this.value=i.value,this.dispatchEvent(new CustomEvent(f,{bubbles:!0,composed:!0,detail:{value:i.value}}))};i.addEventListener("input",f=>{f.stopPropagation(),c("input")}),i.addEventListener("change",f=>{f.stopPropagation(),c("change")});const h=this.root.querySelector(".clear"),n=()=>{h==null||h.toggleAttribute("hidden",i.value==="")};n(),h==null||h.addEventListener("click",()=>{i.value="",n(),c("input"),c("change"),i.focus()}),i.addEventListener("input",n)}};it.styles=p`
|
|
318
|
+
:host {
|
|
319
|
+
display: inline-block;
|
|
320
|
+
vertical-align: middle;
|
|
321
|
+
font-family: var(--fx-font-family);
|
|
322
|
+
font-size: var(--fx-font-size);
|
|
323
|
+
}
|
|
324
|
+
.field {
|
|
325
|
+
font-family: inherit;
|
|
326
|
+
font-size: inherit;
|
|
327
|
+
min-height: var(--fx-size-md);
|
|
328
|
+
font-weight: var(--fx-font-weight);
|
|
329
|
+
color: var(--fx-text-default);
|
|
330
|
+
background-color: var(--fx-surface-background);
|
|
331
|
+
border: 1px solid var(--fx-border-default);
|
|
332
|
+
border-radius: var(--fx-radius-md);
|
|
333
|
+
padding: var(--fx-space-md) var(--fx-space-lg);
|
|
334
|
+
width: 260px;
|
|
335
|
+
box-sizing: border-box;
|
|
336
|
+
transition:
|
|
337
|
+
border-color var(--fx-motion-duration-normal) var(--fx-motion-easing),
|
|
338
|
+
box-shadow var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
339
|
+
}
|
|
340
|
+
.field::placeholder { color: var(--fx-text-muted); opacity: 1; }
|
|
341
|
+
.field:hover { border-color: var(--fx-border-hover); }
|
|
342
|
+
.field:focus-visible {
|
|
343
|
+
outline: none;
|
|
344
|
+
border-color: var(--fx-color-primary);
|
|
345
|
+
box-shadow: var(--fx-effect-focus-ring, none);
|
|
346
|
+
}
|
|
347
|
+
.field:disabled,
|
|
348
|
+
.field[readonly] {
|
|
349
|
+
opacity: 0.55;
|
|
350
|
+
cursor: not-allowed;
|
|
351
|
+
background-color: var(--fx-surface-surface-hover);
|
|
352
|
+
}
|
|
353
|
+
/* Validação: sobrescrevem a borda/foco via token do preset. */
|
|
354
|
+
:host([error]) .field,
|
|
355
|
+
:host([invalid]) .field,
|
|
356
|
+
:host([error]) .field:focus-visible,
|
|
357
|
+
:host([invalid]) .field:focus-visible {
|
|
358
|
+
border-color: var(--fx-color-danger, #dc2626);
|
|
359
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-color-danger, #dc2626) 18%, transparent);
|
|
360
|
+
}
|
|
361
|
+
:host([success]) .field,
|
|
362
|
+
:host([valid]) .field,
|
|
363
|
+
:host([success]) .field:focus-visible,
|
|
364
|
+
:host([valid]) .field:focus-visible {
|
|
365
|
+
border-color: var(--fx-color-success, #16a34a);
|
|
366
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-color-success, #16a34a) 18%, transparent);
|
|
367
|
+
}
|
|
368
|
+
:host([size='sm']) .field { padding: var(--fx-space-sm) var(--fx-space-md); font-size: var(--fx-font-size); width: 220px; min-height: var(--fx-size-sm); }
|
|
369
|
+
:host([size='lg']) .field { padding: var(--fx-space-lg) var(--fx-space-xl); font-size: calc(var(--fx-font-size) + 4px); width: 300px; min-height: var(--fx-size-lg); }
|
|
370
|
+
/* Clearable */
|
|
371
|
+
:host([clearable]) { position: relative; display: inline-flex; }
|
|
372
|
+
.wrap { position: relative; display: inline-flex; align-items: center; }
|
|
373
|
+
:host([clearable]) .field { padding-right: var(--fx-space-xl); }
|
|
374
|
+
.clear {
|
|
375
|
+
position: absolute;
|
|
376
|
+
right: var(--fx-space-xs);
|
|
377
|
+
border: none;
|
|
378
|
+
background: transparent;
|
|
379
|
+
color: var(--fx-text-muted);
|
|
380
|
+
font-size: calc(var(--fx-font-size) + 4px);
|
|
381
|
+
line-height: 1;
|
|
382
|
+
cursor: pointer;
|
|
383
|
+
padding: 0 var(--fx-space-xs);
|
|
384
|
+
border-radius: var(--fx-radius-full);
|
|
385
|
+
}
|
|
386
|
+
.clear:hover { color: var(--fx-color-danger); }
|
|
387
|
+
.clear[hidden] { display: none; }
|
|
388
|
+
`;let M=it;function Bt(){return v("fx-input",M)}Bt();const nt=class nt extends x{static get observedAttributes(){return["checked","disabled","size"]}get size(){const t=this.getAttr("size","md");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get checked(){return this.hasAttr("checked")}set checked(t){this.toggleAttr("checked",!!t)}get disabled(){return this.hasAttr("disabled")}set disabled(t){this.toggleAttr("disabled",!!t)}render(){this.setTemplate(`
|
|
389
|
+
<button class="switch" part="switch" type="button" role="switch"
|
|
390
|
+
aria-checked="${this.checked}" ${this.hasAttr("disabled")?"disabled":""}>
|
|
391
|
+
<span class="track" part="track"><span class="thumb" part="thumb"></span></span>
|
|
392
|
+
<span class="label" part="label"><slot></slot></span>
|
|
393
|
+
</button>
|
|
394
|
+
`);const t=this.root.querySelector(".switch");t&&t.addEventListener("click",()=>{this.hasAttr("disabled")||(this.checked=!this.checked,t.setAttribute("aria-checked",String(this.checked)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.checked}})))})}};nt.styles=p`
|
|
395
|
+
:host {
|
|
396
|
+
display: inline-flex;
|
|
397
|
+
vertical-align: middle;
|
|
398
|
+
font-family: var(--fx-font-family);
|
|
399
|
+
font-size: var(--fx-font-size);
|
|
400
|
+
}
|
|
401
|
+
.switch {
|
|
402
|
+
display: inline-flex;
|
|
403
|
+
align-items: center;
|
|
404
|
+
gap: var(--fx-space-sm);
|
|
405
|
+
cursor: pointer;
|
|
406
|
+
user-select: none;
|
|
407
|
+
background: none;
|
|
408
|
+
border: none;
|
|
409
|
+
padding: 0;
|
|
410
|
+
color: var(--fx-text-default);
|
|
411
|
+
font: inherit;
|
|
412
|
+
}
|
|
413
|
+
.track {
|
|
414
|
+
position: relative;
|
|
415
|
+
width: 40px;
|
|
416
|
+
height: 22px;
|
|
417
|
+
border-radius: var(--fx-radius-full);
|
|
418
|
+
background: var(--fx-border-default);
|
|
419
|
+
flex-shrink: 0;
|
|
420
|
+
transition: background-color var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
421
|
+
}
|
|
422
|
+
.thumb {
|
|
423
|
+
position: absolute;
|
|
424
|
+
top: 3px;
|
|
425
|
+
left: 3px;
|
|
426
|
+
width: 16px;
|
|
427
|
+
height: 16px;
|
|
428
|
+
border-radius: var(--fx-radius-full);
|
|
429
|
+
background: #fff;
|
|
430
|
+
box-shadow: var(--fx-shadow-sm);
|
|
431
|
+
transition: transform var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
432
|
+
}
|
|
433
|
+
:host([checked]) .track { background: var(--fx-color-primary); }
|
|
434
|
+
:host([checked]) .thumb { transform: translateX(18px); }
|
|
435
|
+
.switch:focus-visible .track {
|
|
436
|
+
outline: none;
|
|
437
|
+
box-shadow: var(--fx-effect-focus-ring, none);
|
|
438
|
+
}
|
|
439
|
+
.label { display: inline-flex; align-items: center; }
|
|
440
|
+
:host([disabled]) .switch { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
|
|
441
|
+
/* Escala: sm 32×18 · md 40×22 (padrão) · lg 48×26 */
|
|
442
|
+
:host([size='sm']) .track { width: 32px; height: 18px; }
|
|
443
|
+
:host([size='sm']) .thumb { top: 2px; left: 2px; width: 14px; height: 14px; }
|
|
444
|
+
:host([size='sm'][checked]) .thumb { transform: translateX(14px); }
|
|
445
|
+
:host([size='lg']) .track { width: 48px; height: 26px; }
|
|
446
|
+
:host([size='lg']) .thumb { top: 4px; left: 4px; width: 18px; height: 18px; }
|
|
447
|
+
:host([size='lg'][checked]) .thumb { transform: translateX(22px); }
|
|
448
|
+
`;let N=nt;function Ht(){return v("fx-switch",N)}Ht();const lt=class lt extends x{constructor(){super(...arguments),this.selected=new Set}static get observedAttributes(){return["disabled","placeholder"]}get values(){const t=this.getAttr("values");return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}set values(t){this.setAttribute("values",t.join(","))}get disabled(){return this.hasAttr("disabled")}set disabled(t){this.toggleAttr("disabled",!!t)}get options(){return[...this.querySelectorAll("option")].map(t=>{var e,r,s,o,a;return{value:(s=(r=t.getAttribute("value"))!=null?r:(e=t.textContent)==null?void 0:e.trim())!=null?s:"",label:(a=(o=t.textContent)==null?void 0:o.trim())!=null?a:""}})}connectedCallback(){this.selected=new Set(this.values),super.connectedCallback(),this.observer=new MutationObserver(()=>this.render()),this.observer.observe(this,{childList:!0,subtree:!0,characterData:!0}),this.docListener=t=>{this.hasAttr("open")&&(t.composedPath().includes(this)||(this.removeAttribute("open"),this.render()))},document.addEventListener("click",this.docListener)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.observer)==null||t.disconnect(),this.docListener&&document.removeEventListener("click",this.docListener)}commit(){this.values=[...this.selected],this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{values:[...this.selected]}}))}toggleValue(t){this.selected.has(t)?this.selected.delete(t):this.selected.add(t),this.commit()}render(){var c,h,n,f;const t=this.hasAttr("open"),e=(h=(c=this.root.querySelector(".search"))==null?void 0:c.value)!=null?h:"",r=this.options;for(const d of[...this.selected])r.some(u=>u.value===d)||this.selected.delete(d);const s=r.filter(d=>this.selected.has(d.value)),o=this.getAttr("placeholder","Selecione…"),a=e?r.filter(d=>d.label.toLowerCase().includes(e.toLowerCase())):r;this.setTemplate(`
|
|
449
|
+
<span class="trigger" part="trigger" role="button" tabindex="${this.disabled?-1:0}" aria-haspopup="listbox" aria-expanded="${t}" aria-disabled="${this.disabled}">
|
|
450
|
+
<span class="lead">
|
|
451
|
+
${s.length?s.map(d=>`
|
|
452
|
+
<span class="chip" data-value="${d.value}">
|
|
453
|
+
${d.label}
|
|
454
|
+
<span class="chip__x" role="button" aria-label="Remover ${d.label}">×</span>
|
|
455
|
+
</span>`).join(""):`<span class="placeholder">${o}</span>`}
|
|
456
|
+
</span>
|
|
457
|
+
<span class="trigger-right">
|
|
458
|
+
${this.hasAttr("clearable")&&s.length?'<button type="button" class="icon-btn clear" part="clear" aria-label="Limpar seleção">×</button>':""}
|
|
459
|
+
<span class="caret">▼</span>
|
|
460
|
+
</span>
|
|
461
|
+
</span>
|
|
462
|
+
<div class="panel" part="panel" role="listbox" aria-multiselectable="true">
|
|
463
|
+
<div class="panel-header">
|
|
464
|
+
<span class="count">${s.length} selecionado${s.length===1?"":"s"}</span>
|
|
465
|
+
${this.hasAttr("clearable")&&s.length?'<button type="button" class="clear-all">Limpar tudo</button>':""}
|
|
466
|
+
</div>
|
|
467
|
+
${this.hasAttr("searchable")?`<input class="search" part="search" type="text" placeholder="${this.getAttr("search-placeholder","Pesquisar…")}">`:""}
|
|
468
|
+
<ul class="list">
|
|
469
|
+
${a.map(d=>`
|
|
470
|
+
<li><button type="button" class="opt" role="option" data-value="${d.value}"
|
|
471
|
+
aria-selected="${this.selected.has(d.value)}">
|
|
472
|
+
<span class="box" aria-hidden="true"></span>${d.label}
|
|
473
|
+
</button></li>`).join("")}
|
|
474
|
+
${a.length===0?`<li class="empty">${this.getAttr("no-results","Nenhum resultado")}</li>`:""}
|
|
475
|
+
</ul>
|
|
476
|
+
</div>
|
|
477
|
+
`),t&&this.setAttribute("open","");const l=this.root.querySelector(".search");l&&(l.value=e,l.addEventListener("input",()=>{var y;const d=(y=l.selectionStart)!=null?y:l.value.length;this.render();const u=this.root.querySelector(".search");u&&(u.focus(),u.setSelectionRange(d,d))}),l.addEventListener("click",d=>d.stopPropagation()));const i=this.root.querySelector(".trigger");i&&(i.addEventListener("click",d=>{if(!this.disabled&&!d.target.closest(".clear")&&!d.target.closest(".chip__x")){if(this.toggleAttribute("open"),this.hasAttr("open")){const u=this.getBoundingClientRect();this.toggleAttribute("up",u.bottom+300>window.innerHeight&&u.top>300)}else this.removeAttribute("up");this.render()}}),i.addEventListener("keydown",d=>{this.disabled||(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),i.dispatchEvent(new MouseEvent("click",{bubbles:!0})))}),(n=this.root.querySelector(".clear"))==null||n.addEventListener("click",d=>{d.stopPropagation(),this.selected.clear(),this.commit()}),(f=this.root.querySelector(".clear-all"))==null||f.addEventListener("click",d=>{d.stopPropagation(),this.selected.clear(),this.commit()}),this.root.querySelectorAll(".chip").forEach(d=>{var u;(u=d.querySelector(".chip__x"))==null||u.addEventListener("click",y=>{y.stopPropagation(),this.toggleValue(d.dataset.value)})}),this.root.querySelectorAll(".opt").forEach(d=>{d.addEventListener("click",()=>this.toggleValue(d.dataset.value))}))}};lt.styles=p`
|
|
478
|
+
:host {
|
|
479
|
+
display: inline-block;
|
|
480
|
+
vertical-align: middle;
|
|
481
|
+
font-family: var(--fx-font-family);
|
|
482
|
+
font-size: var(--fx-font-size);
|
|
483
|
+
position: relative;
|
|
484
|
+
}
|
|
485
|
+
.trigger {
|
|
486
|
+
display: inline-flex;
|
|
487
|
+
align-items: center;
|
|
488
|
+
flex-wrap: nowrap;
|
|
489
|
+
gap: var(--fx-space-xs);
|
|
490
|
+
width: 240px;
|
|
491
|
+
box-sizing: border-box;
|
|
492
|
+
min-height: var(--fx-size-md);
|
|
493
|
+
padding: var(--fx-space-xs) var(--fx-space-md);
|
|
494
|
+
font: inherit;
|
|
495
|
+
color: var(--fx-text-default);
|
|
496
|
+
background-color: var(--fx-surface-background);
|
|
497
|
+
border: 1px solid var(--fx-border-default);
|
|
498
|
+
border-radius: var(--fx-radius-md);
|
|
499
|
+
cursor: pointer;
|
|
500
|
+
text-align: left;
|
|
501
|
+
transition: border-color var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
502
|
+
}
|
|
503
|
+
/* Área dos chips: encolhe e quebra linha internamente,
|
|
504
|
+
mantendo os ícones sempre dentro do componente. */
|
|
505
|
+
.lead {
|
|
506
|
+
display: inline-flex;
|
|
507
|
+
flex-wrap: wrap;
|
|
508
|
+
gap: var(--fx-space-xs);
|
|
509
|
+
flex: 1;
|
|
510
|
+
min-width: 0;
|
|
511
|
+
overflow: hidden;
|
|
512
|
+
}
|
|
513
|
+
:host([size='sm']) .trigger { min-height: var(--fx-size-sm); width: 200px; }
|
|
514
|
+
:host([size='lg']) .trigger { min-height: var(--fx-size-lg); width: 280px; font-size: calc(var(--fx-font-size) + 4px); }
|
|
515
|
+
/* Validação */
|
|
516
|
+
:host([error]) .trigger,
|
|
517
|
+
:host([invalid]) .trigger {
|
|
518
|
+
border-color: var(--fx-color-danger, #dc2626);
|
|
519
|
+
}
|
|
520
|
+
:host([error]) .trigger:focus-visible,
|
|
521
|
+
:host([invalid]) .trigger:focus-visible,
|
|
522
|
+
:host([error][open]) .trigger,
|
|
523
|
+
:host([invalid][open]) .trigger {
|
|
524
|
+
border-color: var(--fx-color-danger, #dc2626);
|
|
525
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-color-danger, #dc2626) 18%, transparent);
|
|
526
|
+
}
|
|
527
|
+
:host([success]) .trigger,
|
|
528
|
+
:host([valid]) .trigger {
|
|
529
|
+
border-color: var(--fx-color-success, #16a34a);
|
|
530
|
+
}
|
|
531
|
+
:host([success]) .trigger:focus-visible,
|
|
532
|
+
:host([valid]) .trigger:focus-visible,
|
|
533
|
+
:host([success][open]) .trigger,
|
|
534
|
+
:host([valid][open]) .trigger {
|
|
535
|
+
border-color: var(--fx-color-success, #16a34a);
|
|
536
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-color-success, #16a34a) 18%, transparent);
|
|
537
|
+
}
|
|
538
|
+
.trigger:hover { border-color: var(--fx-border-hover); }
|
|
539
|
+
.trigger:focus-visible {
|
|
540
|
+
outline: none;
|
|
541
|
+
border-color: var(--fx-color-primary);
|
|
542
|
+
box-shadow: var(--fx-effect-focus-ring, none);
|
|
543
|
+
}
|
|
544
|
+
.trigger[aria-expanded='true'] { border-color: var(--fx-color-primary); }
|
|
545
|
+
.placeholder { color: var(--fx-text-muted); }
|
|
546
|
+
.chip {
|
|
547
|
+
display: inline-flex;
|
|
548
|
+
align-items: center;
|
|
549
|
+
gap: 4px;
|
|
550
|
+
background: color-mix(in srgb, var(--fx-color-primary) 14%, transparent);
|
|
551
|
+
color: var(--fx-color-primary);
|
|
552
|
+
border-radius: var(--fx-radius-sm);
|
|
553
|
+
padding: 2px 6px;
|
|
554
|
+
font-size: calc(var(--fx-font-size) - 2px);
|
|
555
|
+
}
|
|
556
|
+
.chip__x {
|
|
557
|
+
border: none;
|
|
558
|
+
background: none;
|
|
559
|
+
color: inherit;
|
|
560
|
+
cursor: pointer;
|
|
561
|
+
font-size: calc(var(--fx-font-size) - 1px);
|
|
562
|
+
line-height: 1;
|
|
563
|
+
padding: 0;
|
|
564
|
+
}
|
|
565
|
+
.trigger-right {
|
|
566
|
+
margin-left: auto;
|
|
567
|
+
display: inline-flex;
|
|
568
|
+
align-items: center;
|
|
569
|
+
gap: 4px;
|
|
570
|
+
color: var(--fx-text-muted);
|
|
571
|
+
}
|
|
572
|
+
.icon-btn {
|
|
573
|
+
border: none;
|
|
574
|
+
background: none;
|
|
575
|
+
color: inherit;
|
|
576
|
+
cursor: pointer;
|
|
577
|
+
font-size: calc(var(--fx-font-size) + 2px);
|
|
578
|
+
line-height: 1;
|
|
579
|
+
padding: 0 2px;
|
|
580
|
+
border-radius: var(--fx-radius-full);
|
|
581
|
+
}
|
|
582
|
+
.icon-btn:hover { color: var(--fx-color-danger); }
|
|
583
|
+
.caret {
|
|
584
|
+
font-size: calc(var(--fx-font-size) - 3px);
|
|
585
|
+
transition: transform var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
586
|
+
}
|
|
587
|
+
:host([open]) .caret { transform: rotate(180deg); }
|
|
588
|
+
|
|
589
|
+
/* Painel (overlay ) */
|
|
590
|
+
.panel {
|
|
591
|
+
position: absolute;
|
|
592
|
+
top: calc(100% + 4px);
|
|
593
|
+
left: 0;
|
|
594
|
+
z-index: var(--fx-z-dropdown, 1000);
|
|
595
|
+
width: max(100%, 240px);
|
|
596
|
+
background: var(--fx-surface-background);
|
|
597
|
+
border: 1px solid var(--fx-border-default);
|
|
598
|
+
border-radius: var(--fx-radius-md);
|
|
599
|
+
box-shadow: var(--fx-shadow-lg);
|
|
600
|
+
display: none;
|
|
601
|
+
overflow: hidden;
|
|
602
|
+
}
|
|
603
|
+
:host([up]) .panel {
|
|
604
|
+
top: auto;
|
|
605
|
+
bottom: calc(100% + 4px);
|
|
606
|
+
}
|
|
607
|
+
:host([open]) .panel { display: block; }
|
|
608
|
+
.panel-header {
|
|
609
|
+
display: flex;
|
|
610
|
+
align-items: center;
|
|
611
|
+
justify-content: space-between;
|
|
612
|
+
gap: var(--fx-space-sm);
|
|
613
|
+
padding: var(--fx-space-xs) var(--fx-space-md);
|
|
614
|
+
border-bottom: 1px solid var(--fx-border-default);
|
|
615
|
+
background: var(--fx-surface-surface-hover);
|
|
616
|
+
}
|
|
617
|
+
.count { font-size: calc(var(--fx-font-size) - 2px); color: var(--fx-text-muted); }
|
|
618
|
+
.clear-all {
|
|
619
|
+
border: none;
|
|
620
|
+
background: none;
|
|
621
|
+
font: inherit;
|
|
622
|
+
font-size: calc(var(--fx-font-size) - 2px);
|
|
623
|
+
color: var(--fx-color-primary);
|
|
624
|
+
cursor: pointer;
|
|
625
|
+
padding: 0;
|
|
626
|
+
}
|
|
627
|
+
.clear-all:hover { text-decoration: underline; }
|
|
628
|
+
.search {
|
|
629
|
+
width: 100%;
|
|
630
|
+
box-sizing: border-box;
|
|
631
|
+
font: inherit;
|
|
632
|
+
color: var(--fx-text-default);
|
|
633
|
+
background: var(--fx-surface-background);
|
|
634
|
+
border: none;
|
|
635
|
+
border-bottom: 1px solid var(--fx-border-default);
|
|
636
|
+
padding: var(--fx-space-sm) var(--fx-space-md);
|
|
637
|
+
outline: none;
|
|
638
|
+
}
|
|
639
|
+
.list {
|
|
640
|
+
max-height: 240px;
|
|
641
|
+
overflow-y: auto;
|
|
642
|
+
list-style: none;
|
|
643
|
+
margin: 0;
|
|
644
|
+
padding: var(--fx-space-3xs, 4px);
|
|
645
|
+
}
|
|
646
|
+
.opt {
|
|
647
|
+
display: flex;
|
|
648
|
+
align-items: center;
|
|
649
|
+
gap: var(--fx-space-sm);
|
|
650
|
+
width: 100%;
|
|
651
|
+
padding: var(--fx-space-xs) var(--fx-space-md);
|
|
652
|
+
border: none;
|
|
653
|
+
background: none;
|
|
654
|
+
font: inherit;
|
|
655
|
+
color: var(--fx-text-default);
|
|
656
|
+
cursor: pointer;
|
|
657
|
+
border-radius: var(--fx-radius-sm);
|
|
658
|
+
text-align: left;
|
|
659
|
+
}
|
|
660
|
+
.opt:hover { background: color-mix(in srgb, var(--fx-color-primary) 12%, transparent); }
|
|
661
|
+
.opt[aria-selected='true'] {
|
|
662
|
+
background: color-mix(in srgb, var(--fx-color-primary) 16%, transparent);
|
|
663
|
+
color: var(--fx-color-primary);
|
|
664
|
+
font-weight: var(--fx-font-weight);
|
|
665
|
+
}
|
|
666
|
+
/* Checkbox visual */
|
|
667
|
+
.box {
|
|
668
|
+
width: 16px;
|
|
669
|
+
height: 16px;
|
|
670
|
+
flex-shrink: 0;
|
|
671
|
+
display: inline-flex;
|
|
672
|
+
align-items: center;
|
|
673
|
+
justify-content: center;
|
|
674
|
+
border: 2px solid var(--fx-border-default);
|
|
675
|
+
border-radius: calc(var(--fx-radius-sm) / 2);
|
|
676
|
+
font-size: 11px;
|
|
677
|
+
line-height: 1;
|
|
678
|
+
color: transparent;
|
|
679
|
+
transition:
|
|
680
|
+
background-color var(--fx-motion-duration-fast) var(--fx-motion-easing),
|
|
681
|
+
border-color var(--fx-motion-duration-fast) var(--fx-motion-easing),
|
|
682
|
+
color var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
683
|
+
}
|
|
684
|
+
.opt[aria-selected='true'] .box {
|
|
685
|
+
background: var(--fx-color-primary);
|
|
686
|
+
border-color: var(--fx-color-primary);
|
|
687
|
+
color: #fff;
|
|
688
|
+
}
|
|
689
|
+
.opt[aria-selected='true'] .box::after { content: '✓'; }
|
|
690
|
+
.empty { padding: var(--fx-space-md); color: var(--fx-text-muted); text-align: center; }
|
|
691
|
+
:host([disabled]) .trigger { opacity: 0.55; cursor: not-allowed; background: var(--fx-surface-surface-hover); }
|
|
692
|
+
`;let _=lt;function Vt(){return v("fx-multiselect",_)}Vt();const A=(g,t,e)=>g*1e4+t*100+e;function S(g){const t=/^(\d{4})(?:-(\d{2}))?(?:-(\d{2}))?$/.exec(g.trim());if(!t)return null;const e=+t[1],r=t[2]?+t[2]:1,s=t[3]?+t[3]:null;return s!==null?{lo:A(e,r,s),hi:A(e,r,s)}:t[2]?{lo:A(e,r,1),hi:A(e,r,31)}:{lo:A(e,1,1),hi:A(e,12,31)}}const dt=class dt extends x{constructor(){super(...arguments),this.view="days",this.cursor={y:new Date().getFullYear(),m:new Date().getMonth()},this.pickStart=null,this.pickEnd=null}static get observedAttributes(){return["value","start","end","min","max","range","mode","values","locale","disabled"]}get mode(){const t=this.getAttr("mode");return t==="range"||t==="multiple"?t:this.hasAttr("range")?"range":"single"}set mode(t){this.setAttribute("mode",t)}get range(){return this.mode==="range"}set range(t){this.toggleAttr("range",!!t)}get values(){const t=this.getAttr("values");return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}set values(t){this.setAttribute("values",t.join(","))}get value(){return this.getAttr("value")}set value(t){this.setAttribute("value",t)}bounds(){return{min:S(this.getAttr("min","")),max:S(this.getAttr("max",""))}}locale(){return this.getAttr("locale","pt-BR")}fmt(t,e){try{return new Intl.DateTimeFormat(this.locale(),t).format(e)}catch(r){return new Intl.DateTimeFormat("pt-BR",t).format(e)}}dayDisabled(t,e,r){const{min:s,max:o}=this.bounds(),a=A(t,e+1,r);return s!==null&&a<s.lo||o!==null&&a>o.hi}monthDisabled(t,e){const{min:r,max:s}=this.bounds(),o=A(t,e,1),a=A(t,e,31);return r!==null&&a<r.lo||s!==null&&o>s.hi}yearDisabled(t){const{min:e,max:r}=this.bounds(),s=A(t,1,1),o=A(t,12,31);return e!==null&&o<e.lo||r!==null&&s>r.hi}dayKeyOf(t){return A(t.getFullYear(),t.getMonth()+1,t.getDate())}keyToDate(t){return new Date(Math.floor(t/1e4),Math.floor(t/100)%100-1,t%100)}iso(t){const e=this.keyToDate(t),r=s=>String(s).padStart(2,"0");return`${e.getFullYear()}-${r(e.getMonth()+1)}-${r(e.getDate())}`}selection(){const t=new Set(this.values.map(r=>{var s,o;return(o=(s=S(r))==null?void 0:s.lo)!=null?o:0}).filter(Boolean));if(this.mode==="range"){let r=this.pickStart,s=this.pickEnd;const o=S(this.getAttr("start","")),a=S(this.getAttr("end",""));return r===null&&o&&(r=o.lo),s===null&&a&&(s=a.lo),{start:r,end:s,single:null,multi:t}}if(this.mode==="multiple")return{start:null,end:null,single:null,multi:t};const e=S(this.getAttr("value",""));return{start:null,end:null,single:e?e.lo:null,multi:t}}emit(){if(this.mode==="range"){const t={start:this.pickStart!==null?this.iso(this.pickStart):this.getAttr("start",""),end:this.pickEnd!==null?this.iso(this.pickEnd):this.getAttr("end","")};this.setAttribute("start",t.start),this.setAttribute("end",t.end),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:t}))}else if(this.mode==="multiple"){const t=this.values;this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{values:t}}))}else{const t=this.getAttr("value");this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{value:t}}))}}pickDay(t){if(this.mode==="range"){if(this.pickStart===null||this.pickEnd!==null){this.pickStart=t,this.pickEnd=null,this.setAttribute("start",this.iso(t)),this.removeAttribute("end"),this.render();return}t<this.pickStart?[this.pickStart,this.pickEnd]=[t,this.pickStart]:this.pickEnd=t,this.emit()}else if(this.mode==="multiple"){const e=new Set(this.values),r=this.iso(t);e.has(r)?e.delete(r):e.add(r),this.values=[...e].sort(),this.emit()}else this.value=this.iso(t),this.emit();this.render()}navigate(t){if(this.view==="days"){const e=new Date(this.cursor.y,this.cursor.m+t,1);this.cursor={y:e.getFullYear(),m:e.getMonth()}}else this.view==="months"?this.cursor.y+=t:this.cursor.y+=t*12;this.render()}render(){const t=this.dayKeyOf(new Date),e=this.selection(),r=this.locale(),s={days:this.fmt({month:"long",year:"numeric"},new Date(this.cursor.y,this.cursor.m,1)),months:String(this.cursor.y),years:`${Math.floor(this.cursor.y/12)*12} – ${Math.floor(this.cursor.y/12)*12+11}`};let o="";if(this.view==="days")o=[...Array(7)].map((c,h)=>this.fmt({weekday:"short"},new Date(2024,8,1+h))).map(c=>`<span class="wd">${c}</span>`).join("")+this.daysHtml(t,e,r);else if(this.view==="months")o=[...Array(12)].map((i,c)=>{const h=this.monthDisabled(this.cursor.y,c+1);return`<button type="button" class="cell" data-month="${c}" ${h?"disabled":""}>${this.fmt({month:"short"},new Date(this.cursor.y,c,1))}</button>`}).join("");else{const i=Math.floor(this.cursor.y/12)*12;o=[...Array(12)].map((c,h)=>{const n=i+h,f=this.yearDisabled(n);return`<button type="button" class="cell" data-year="${n}" ${f?"disabled":""}>${n}</button>`}).join("")}const a=this.view==="days"?'data-goto="months"':this.view==="months"?'data-goto="years"':"";this.setTemplate(`
|
|
693
|
+
<div class="head">
|
|
694
|
+
<button type="button" class="nav" data-nav="-1" aria-label="Anterior">‹</button>
|
|
695
|
+
<button type="button" class="title" part="title" ${a}>${s[this.view]}</button>
|
|
696
|
+
<button type="button" class="nav" data-nav="1" aria-label="Próximo">›</button>
|
|
697
|
+
</div>
|
|
698
|
+
<div class="grid ${this.view}">${o}</div>
|
|
699
|
+
`),this.root.querySelectorAll("[data-nav]").forEach(i=>i.addEventListener("click",()=>this.navigate(Number(i.dataset.nav))));const l=this.root.querySelector("[data-goto]");l==null||l.addEventListener("click",()=>{this.view=l.dataset.goto,this.render()}),this.root.querySelectorAll("[data-day]").forEach(i=>i.addEventListener("click",()=>this.pickDay(Number(i.dataset.day)))),this.root.querySelectorAll("[data-month]").forEach(i=>i.addEventListener("click",()=>{this.cursor.m=Number(i.dataset.month),this.view="days",this.render()})),this.root.querySelectorAll("[data-year]").forEach(i=>i.addEventListener("click",()=>{this.cursor.y=Number(i.dataset.year),this.view="months",this.render()}))}daysHtml(t,e,r){const{y:s,m:o}=this.cursor,a=new Date(s,o,1).getDay(),l=new Date(s,o+1,0).getDate(),i=new Date(s,o,0).getDate();let c="";for(let h=a-1;h>=0;h--)c+=`<span class="cell muted">${i-h}</span>`;for(let h=1;h<=l;h++){const n=A(s,o+1,h),f=e.single===n||e.start===n||e.end===n||e.multi.has(n),d=e.start!==null&&e.end!==null&&n>e.start&&n<e.end,u=["cell",f?"sel":"",d?"in-range":"",n===t?"today":""].filter(Boolean).join(" ");c+=`<button type="button" class="${u}" data-day="${n}" ${this.dayDisabled(s,o,h)?"disabled":""}>${h}</button>`}return c}};dt.styles=p`
|
|
700
|
+
:host {
|
|
701
|
+
display: inline-block;
|
|
702
|
+
font-family: var(--fx-font-family);
|
|
703
|
+
font-size: var(--fx-font-size);
|
|
704
|
+
color: var(--fx-text-default);
|
|
705
|
+
background: var(--fx-surface-background);
|
|
706
|
+
border: 1px solid var(--fx-border-default);
|
|
707
|
+
border-radius: var(--fx-radius-md);
|
|
708
|
+
box-shadow: var(--fx-shadow-sm);
|
|
709
|
+
padding: var(--fx-space-sm);
|
|
710
|
+
user-select: none;
|
|
711
|
+
}
|
|
712
|
+
:host([disabled]) { opacity: 0.55; pointer-events: none; }
|
|
713
|
+
.head {
|
|
714
|
+
display: flex;
|
|
715
|
+
align-items: center;
|
|
716
|
+
justify-content: space-between;
|
|
717
|
+
gap: var(--fx-space-xs);
|
|
718
|
+
margin-bottom: var(--fx-space-xs);
|
|
719
|
+
}
|
|
720
|
+
.nav,
|
|
721
|
+
.title {
|
|
722
|
+
border: none;
|
|
723
|
+
background: none;
|
|
724
|
+
color: var(--fx-text-default);
|
|
725
|
+
cursor: pointer;
|
|
726
|
+
font: inherit;
|
|
727
|
+
border-radius: var(--fx-radius-sm);
|
|
728
|
+
padding: var(--fx-space-3xs, 4px) var(--fx-space-xs);
|
|
729
|
+
}
|
|
730
|
+
.nav:hover, .title:hover { background: var(--fx-surface-surface-hover); }
|
|
731
|
+
.title { font-weight: var(--fx-font-weight); text-transform: capitalize; flex: 1; }
|
|
732
|
+
.grid {
|
|
733
|
+
display: grid;
|
|
734
|
+
grid-template-columns: repeat(7, 34px);
|
|
735
|
+
gap: 2px;
|
|
736
|
+
}
|
|
737
|
+
.grid.months, .grid.years { grid-template-columns: repeat(4, minmax(52px, 1fr)); }
|
|
738
|
+
.wd {
|
|
739
|
+
text-align: center;
|
|
740
|
+
color: var(--fx-text-muted);
|
|
741
|
+
font-size: calc(var(--fx-font-size) - 2px);
|
|
742
|
+
padding: var(--fx-space-3xs, 4px) 0;
|
|
743
|
+
text-transform: capitalize;
|
|
744
|
+
}
|
|
745
|
+
.cell {
|
|
746
|
+
position: relative;
|
|
747
|
+
border: none;
|
|
748
|
+
background: none;
|
|
749
|
+
font: inherit;
|
|
750
|
+
color: var(--fx-text-default);
|
|
751
|
+
height: 32px;
|
|
752
|
+
border-radius: var(--fx-radius-sm);
|
|
753
|
+
cursor: pointer;
|
|
754
|
+
display: inline-flex;
|
|
755
|
+
align-items: center;
|
|
756
|
+
justify-content: center;
|
|
757
|
+
}
|
|
758
|
+
.cell:hover { background: color-mix(in srgb, var(--fx-color-primary) 12%, transparent); }
|
|
759
|
+
.cell.muted { color: var(--fx-text-disabled); }
|
|
760
|
+
.cell.today::after {
|
|
761
|
+
content: '';
|
|
762
|
+
position: absolute;
|
|
763
|
+
bottom: 3px;
|
|
764
|
+
width: 4px;
|
|
765
|
+
height: 4px;
|
|
766
|
+
border-radius: var(--fx-radius-full);
|
|
767
|
+
background: var(--fx-color-primary);
|
|
768
|
+
}
|
|
769
|
+
.cell.sel {
|
|
770
|
+
background: var(--fx-color-primary);
|
|
771
|
+
color: #fff;
|
|
772
|
+
font-weight: var(--fx-font-weight);
|
|
773
|
+
}
|
|
774
|
+
.cell.sel::after { background: #fff; }
|
|
775
|
+
.cell.in-range {
|
|
776
|
+
background: color-mix(in srgb, var(--fx-color-primary) 16%, transparent);
|
|
777
|
+
border-radius: 0;
|
|
778
|
+
}
|
|
779
|
+
.grid.months .cell, .grid.years .cell { height: 40px; }
|
|
780
|
+
.cell[disabled] { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
|
|
781
|
+
`;let P=dt;function It(){return v("fx-calendar",P)}It();const ct=class ct extends x{constructor(){super(...arguments),this.time={h:0,m:0,s:0}}static get observedAttributes(){return["value","start","end","values","mode","min","max","placeholder","disabled","format","show-time","free-text"]}get mode(){const t=this.getAttr("mode","single");return["single","range","multiple"].includes(t)?t:"single"}set mode(t){this.setAttribute("mode",t)}get value(){return this.getAttr("value")}set value(t){this.setAttribute("value",t)}get values(){const t=this.getAttr("values");return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}set values(t){this.setAttribute("values",t.join(","))}get disabled(){return this.hasAttr("disabled")}set disabled(t){this.toggleAttr("disabled",!!t)}connectedCallback(){super.connectedCallback(),this.docListener=t=>{this.hasAttr("open")&&(t.composedPath().includes(this)||this.removeAttribute("open"))},document.addEventListener("click",this.docListener)}disconnectedCallback(){super.disconnectedCallback(),this.docListener&&document.removeEventListener("click",this.docListener)}formatDate(t){if(!t)return"";const e=this.getAttr("format");if(!e)return t.split("T")[0];const[r,s]=t.split("T"),[o="",a="",l=""]=r.split("-"),[i="00",c="00",h="00"]=(s!=null?s:"").split(":");return e.replace(/yyyy/gi,"").replace(/MM/g,"").replace(/mm/g,"").replace(/dd/gi,"").replace(/HH/g,"").replace(/SS/gi,"").replace(/\u0001/g,o).replace(/\u0002/g,a).replace(/\u0003/g,l).replace(/\u0004/g,i).replace(/\u0005/g,c).replace(/\u0006/g,h)}displayText(){if(this.mode==="range"){const e=this.getAttr("start"),r=this.getAttr("end");if(this.hasAttr("show-time"),!e&&!r)return"";if(this.hasAttr("show-time")){const s=o=>o?`${this.formatDate(o)} ${this.timeText()}`:o?`${this.formatDate(o)} …`:"";return e&&r?`${s(e)} → ${s(r)}`:s(e)}return e&&r?`${this.formatDate(e)} → ${this.formatDate(r)}`:e?`${this.formatDate(e)} → …`:""}if(this.mode==="multiple")return this.values.map(e=>this.formatDate(e)).join(", ");const t=this.formatDate(this.value);return t&&this.hasAttr("show-time")?`${t} ${this.timeText()}`:t}timeText(){const t=e=>String(e).padStart(2,"0");return`${t(this.time.h)}:${t(this.time.m)}:${t(this.time.s)}`}loadTimeFromValue(){const e=(this.value||this.getAttr("start")||"").split("T")[1];if(!e)return;const[r,s,o]=e.split(":").map(a=>parseInt(a,10));this.time={h:r||0,m:s||0,s:o||0}}withTime(t){return t&&(this.hasAttr("show-time")?`${t}T${this.timeText()}`:t)}render(){var h,n;const t=this.disabled,e=this.hasAttr("clearable"),r=this.displayText(),s=r.length>0,o=this.hasAttr("show-time");this.loadTimeFromValue();let a=`min="${this.getAttr("min")}" max="${this.getAttr("max")}"`;if(this.mode==="range")a+=` range start="${this.getAttr("start")}" end="${this.getAttr("end")}"`;else if(this.mode==="multiple"){const f=this.values.map(d=>d.split("T")[0]).join(",");a+=` mode="multiple" values="${f}"`}else{const f=(h=this.value.split("T")[0])!=null?h:"";a+=` value="${f}"`}this.setTemplate(`
|
|
782
|
+
<div class="field" part="field">
|
|
783
|
+
<input class="display" part="display" type="text" ${this.hasAttr("free-text")&&!t?"":"readonly"}
|
|
784
|
+
placeholder="${this.getAttr("placeholder","dd/mm/aaaa")}"
|
|
785
|
+
value="${r}" ${t?"disabled":""}>
|
|
786
|
+
<button type="button" class="clear" part="clear" aria-label="Limpar"
|
|
787
|
+
${e&&s?"":"hidden"}>
|
|
788
|
+
×
|
|
789
|
+
</button>
|
|
790
|
+
<span class="cal-icon" part="icon" aria-hidden="true">
|
|
791
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none"
|
|
792
|
+
stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
793
|
+
<rect x="3" y="4" width="18" height="18" rx="2"/>
|
|
794
|
+
<path d="M16 2v4M8 2v4M3 10h18"/>
|
|
795
|
+
</svg>
|
|
796
|
+
</span>
|
|
797
|
+
</div>
|
|
798
|
+
<div class="pop" part="popover">
|
|
799
|
+
<fx-calendar ${a}></fx-calendar>
|
|
800
|
+
${o?`<div class="time-row" part="time">
|
|
801
|
+
<input class="t-h" type="number" min="0" max="23" value="${this.time.h}" aria-label="Hora"><span class="sep">:</span>
|
|
802
|
+
<input class="t-m" type="number" min="0" max="59" value="${this.time.m}" aria-label="Minuto"><span class="sep">:</span>
|
|
803
|
+
<input class="t-s" type="number" min="0" max="59" value="${this.time.s}" aria-label="Segundo">
|
|
804
|
+
</div>`:""}
|
|
805
|
+
</div>
|
|
806
|
+
`);const l=this.root.querySelector(".field");if(!l||t)return;l.addEventListener("click",f=>{if(!f.target.closest(".clear")&&!(this.hasAttr("free-text")&&f.target.classList.contains("display")))if(this.toggleAttribute("open"),this.hasAttr("open")){const d=this.getBoundingClientRect();this.toggleAttribute("up",d.bottom+340>window.innerHeight&&d.top>340)}else this.removeAttribute("up")}),(n=this.root.querySelector(".clear"))==null||n.addEventListener("click",f=>{f.stopPropagation(),this.removeAttribute("value"),this.removeAttribute("start"),this.removeAttribute("end"),this.removeAttribute("values"),this.removeAttribute("open"),this.render(),this.emitChange({})});const i=this.root.querySelector(".pop fx-calendar");i==null||i.addEventListener("change",f=>{var u;const d=(u=f.detail)!=null?u:{};(d.start!==void 0||d.end!==void 0)&&(d.start?this.setAttribute("start",this.withTime(d.start)):this.removeAttribute("start"),d.end?this.setAttribute("end",this.withTime(d.end)):this.removeAttribute("end")),d.values!==void 0&&(this.values=d.values.map(y=>this.withTime(y))),d.value!==void 0&&(d.value?this.setAttribute("value",this.withTime(d.value)):this.removeAttribute("value"),this.mode==="single"&&this.removeAttribute("open")),this.render(),this.emitChange(d)});const c=this.root.querySelector(".display");if(c&&this.hasAttr("free-text")&&!t&&(c.addEventListener("keydown",f=>{f.key==="Enter"&&(f.preventDefault(),this.commitTyped(c))}),c.addEventListener("blur",()=>this.commitTyped(c))),o){const f=()=>{const d=this.root.querySelector(".t-h"),u=this.root.querySelector(".t-m"),y=this.root.querySelector(".t-s"),$=(z,b)=>Math.min(b,Math.max(0,parseInt(z!=null?z:"0",10)||0));this.time={h:$(d==null?void 0:d.value,23),m:$(u==null?void 0:u.value,59),s:$(y==null?void 0:y.value,59)};const w=z=>z.split("T")[0]?`${z.split("T")[0]}T${this.timeText()}`:z;this.value&&this.setAttribute("value",w(this.value)),this.getAttr("start")&&this.setAttribute("start",w(this.getAttr("start"))),this.getAttr("end")&&this.setAttribute("end",w(this.getAttr("end"))),this.values.length&&(this.values=this.values.map(z=>w(z)));const E=this.root.querySelector(".display");E&&(E.value=this.displayText()),this.emitChange({value:this.value})};[".t-h",".t-m",".t-s"].forEach(d=>{var u;(u=this.root.querySelector(d))==null||u.addEventListener("input",f)})}}emitChange(t){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:t}))}parseTyped(t){var y,$;const e=t.trim();if(!e)return null;const r=this.getAttr("format","dd/mm/yyyy").toLowerCase(),s=["dd","mm","yyyy"].filter(w=>r.includes(w));if(s.length<3)return null;const o=e.split(new RegExp("[^0-9]+")).filter(Boolean);if(o.length!==3)return null;const a={};s.forEach((w,E)=>a[w]=o[E]);const l=`${a.yyyy}-${((y=a.mm)!=null?y:"").padStart(2,"0")}-${(($=a.dd)!=null?$:"").padStart(2,"0")}`,i=new Date(`${l}T12:00:00`);if(Number.isNaN(i.getTime()))return null;const[c,h,n]=l.split("-").map(w=>parseInt(w,10));if(i.getFullYear()!==c||i.getMonth()+1!==h||i.getDate()!==n)return null;const f=(w,E)=>w.split("T")[0].localeCompare(E.split("T")[0]),d=this.getAttr("min"),u=this.getAttr("max");return d&&f(l,d)<0||u&&f(l,u)>0?null:l}commitTyped(t){const e=this.parseTyped(t.value);if(!e){t.classList.add("invalid"),this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,composed:!0,detail:{text:t.value}})),t.value=this.displayText(),setTimeout(()=>t.classList.remove("invalid"),1500);return}if(this.mode==="single")this.setAttribute("value",this.withTime(e)),this.emitChange({value:this.value});else if(this.mode==="range"){if(!this.getAttr("start")||this.getAttr("start")&&this.getAttr("end"))this.setAttribute("start",this.withTime(e)),this.removeAttribute("end");else{const[r,s]=[this.getAttr("start").split("T")[0],e].sort();this.setAttribute("start",this.withTime(r)),this.setAttribute("end",this.withTime(s))}this.emitChange({start:this.getAttr("start"),end:this.getAttr("end")})}else{const r=this.values.filter(s=>s.split("T")[0]!==e);r.push(this.withTime(e)),this.values=r,this.emitChange({values:this.values})}this.render()}};ct.styles=p`
|
|
807
|
+
:host {
|
|
808
|
+
display: inline-block;
|
|
809
|
+
vertical-align: middle;
|
|
810
|
+
font-family: var(--fx-font-family);
|
|
811
|
+
font-size: var(--fx-font-size);
|
|
812
|
+
position: relative;
|
|
813
|
+
}
|
|
814
|
+
.field {
|
|
815
|
+
display: inline-flex;
|
|
816
|
+
align-items: center;
|
|
817
|
+
gap: var(--fx-space-xs);
|
|
818
|
+
width: 100%;
|
|
819
|
+
box-sizing: border-box;
|
|
820
|
+
/* Base = tamanho padrão (md): 40px */
|
|
821
|
+
min-height: var(--fx-size-md, 40px);
|
|
822
|
+
min-width: 150px;
|
|
823
|
+
padding: var(--fx-space-xs) var(--fx-space-md);
|
|
824
|
+
background-color: var(--fx-surface-background);
|
|
825
|
+
border: 1px solid var(--fx-border-default);
|
|
826
|
+
border-radius: var(--fx-radius-md);
|
|
827
|
+
cursor: pointer;
|
|
828
|
+
transition:
|
|
829
|
+
border-color var(--fx-motion-duration-normal) var(--fx-motion-easing),
|
|
830
|
+
box-shadow var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
831
|
+
}
|
|
832
|
+
:host([size='sm']) .field { min-height: 32px; min-width: 180px; }
|
|
833
|
+
:host([size='md']) .field { min-height: 40px; }
|
|
834
|
+
:host([size='lg']) .field { min-height: 48px; min-width: 220px; font-size: calc(var(--fx-font-size) + 4px); }
|
|
835
|
+
/* Range e multiple exibem mais de uma data: campo mais largo */
|
|
836
|
+
:host([mode='range']) .field { min-width: 250px; }
|
|
837
|
+
:host([mode='multiple']) .field { min-width: 220px; }
|
|
838
|
+
:host([mode='range'][size='lg']) .field { min-width: 360px; }
|
|
839
|
+
:host([mode='multiple'][size='lg']) .field { min-width: 320px; }
|
|
840
|
+
:host([show-time]) .field { min-width: 250px; }
|
|
841
|
+
/* Validação */
|
|
842
|
+
:host([error]) .field,
|
|
843
|
+
:host([invalid]) .field {
|
|
844
|
+
border-color: var(--fx-color-danger, #dc2626);
|
|
845
|
+
}
|
|
846
|
+
:host([error]) .field:focus-within,
|
|
847
|
+
:host([invalid]) .field:focus-within,
|
|
848
|
+
:host([error][open]) .field,
|
|
849
|
+
:host([invalid][open]) .field {
|
|
850
|
+
border-color: var(--fx-color-danger, #dc2626);
|
|
851
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-color-danger, #dc2626) 18%, transparent);
|
|
852
|
+
}
|
|
853
|
+
:host([success]) .field,
|
|
854
|
+
:host([valid]) .field {
|
|
855
|
+
border-color: var(--fx-color-success, #16a34a);
|
|
856
|
+
}
|
|
857
|
+
:host([success]) .field:focus-within,
|
|
858
|
+
:host([valid]) .field:focus-within,
|
|
859
|
+
:host([success][open]) .field,
|
|
860
|
+
:host([valid][open]) .field {
|
|
861
|
+
border-color: var(--fx-color-success, #16a34a);
|
|
862
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-color-success, #16a34a) 18%, transparent);
|
|
863
|
+
}
|
|
864
|
+
.field:hover { border-color: var(--fx-border-hover); }
|
|
865
|
+
.field:focus-within {
|
|
866
|
+
outline: none;
|
|
867
|
+
border-color: var(--fx-color-primary);
|
|
868
|
+
box-shadow: var(--fx-effect-focus-ring, none);
|
|
869
|
+
}
|
|
870
|
+
.display {
|
|
871
|
+
flex: 1;
|
|
872
|
+
border: none;
|
|
873
|
+
background: none;
|
|
874
|
+
font: inherit;
|
|
875
|
+
color: var(--fx-text-default);
|
|
876
|
+
outline: none;
|
|
877
|
+
cursor: pointer;
|
|
878
|
+
text-align: left;
|
|
879
|
+
padding: 0;
|
|
880
|
+
min-width: 0;
|
|
881
|
+
}
|
|
882
|
+
.display::placeholder { color: var(--fx-text-muted); }
|
|
883
|
+
.cal-icon { color: var(--fx-text-muted); display: inline-flex; pointer-events: none; }
|
|
884
|
+
.clear {
|
|
885
|
+
border: none;
|
|
886
|
+
background: none;
|
|
887
|
+
color: var(--fx-text-muted);
|
|
888
|
+
cursor: pointer;
|
|
889
|
+
font-size: calc(var(--fx-font-size) + 4px);
|
|
890
|
+
line-height: 1;
|
|
891
|
+
padding: 0 2px;
|
|
892
|
+
border-radius: var(--fx-radius-full);
|
|
893
|
+
}
|
|
894
|
+
.clear:hover { color: var(--fx-color-danger); }
|
|
895
|
+
.clear[hidden] { display: none; }
|
|
896
|
+
.pop {
|
|
897
|
+
position: absolute;
|
|
898
|
+
top: calc(100% + 4px);
|
|
899
|
+
left: 0;
|
|
900
|
+
z-index: var(--fx-z-dropdown, 1000);
|
|
901
|
+
display: none;
|
|
902
|
+
background: var(--fx-surface-background);
|
|
903
|
+
border: 1px solid var(--fx-border-default);
|
|
904
|
+
border-radius: var(--fx-radius-md);
|
|
905
|
+
box-shadow: var(--fx-shadow-lg);
|
|
906
|
+
overflow: hidden;
|
|
907
|
+
}
|
|
908
|
+
:host([up]) .pop {
|
|
909
|
+
top: auto;
|
|
910
|
+
bottom: calc(100% + 4px);
|
|
911
|
+
}
|
|
912
|
+
:host([open]) .pop { display: block; }
|
|
913
|
+
.time-row {
|
|
914
|
+
display: flex;
|
|
915
|
+
align-items: center;
|
|
916
|
+
gap: var(--fx-space-xs);
|
|
917
|
+
padding: var(--fx-space-sm) var(--fx-space-md);
|
|
918
|
+
border-top: 1px solid var(--fx-border-default);
|
|
919
|
+
background: var(--fx-surface-background);
|
|
920
|
+
border-radius: 0 0 var(--fx-radius-md) var(--fx-radius-md);
|
|
921
|
+
font-size: calc(var(--fx-font-size) - 2px);
|
|
922
|
+
color: var(--fx-text-default);
|
|
923
|
+
}
|
|
924
|
+
.time-row label { color: var(--fx-text-muted); }
|
|
925
|
+
.time-row input {
|
|
926
|
+
width: 38px;
|
|
927
|
+
font: inherit;
|
|
928
|
+
color: var(--fx-text-default);
|
|
929
|
+
background: var(--fx-surface-background);
|
|
930
|
+
border: 1px solid var(--fx-border-default);
|
|
931
|
+
border-radius: var(--fx-radius-sm);
|
|
932
|
+
padding: 2px 2px;
|
|
933
|
+
outline: none;
|
|
934
|
+
text-align: center;
|
|
935
|
+
-moz-appearance: textfield;
|
|
936
|
+
appearance: textfield;
|
|
937
|
+
}
|
|
938
|
+
.time-row input::-webkit-outer-spin-button,
|
|
939
|
+
.time-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
|
|
940
|
+
.time-row .sep { color: var(--fx-text-muted); font-weight: bold; padding: 0 1px; }
|
|
941
|
+
.time-row input:focus {
|
|
942
|
+
border-color: var(--fx-color-primary);
|
|
943
|
+
box-shadow: var(--fx-effect-focus-ring, none);
|
|
944
|
+
}
|
|
945
|
+
:host([disabled]) .field { opacity: 0.55; cursor: not-allowed; background: var(--fx-surface-surface-hover); }
|
|
946
|
+
:host([disabled]) .display { cursor: not-allowed; }
|
|
947
|
+
:host([free-text]) .display { cursor: text; }
|
|
948
|
+
:host([free-text]) .display.invalid { border-bottom: 2px solid var(--fx-color-danger); }
|
|
949
|
+
`;let j=ct;function Yt(){return v("fx-datepicker",j)}Yt();const ft=class ft extends x{static get observedAttributes(){return["checked","disabled","indeterminate"]}get checked(){return this.hasAttr("checked")}set checked(t){this.toggleAttr("checked",!!t)}get indeterminate(){return this.hasAttr("indeterminate")}set indeterminate(t){this.toggleAttr("indeterminate",!!t)}get disabled(){return this.hasAttr("disabled")}set disabled(t){this.toggleAttr("disabled",!!t)}get size(){const t=this.getAttr("size","md");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}render(){const t=this.size==="sm"?"14px":this.size==="lg"?"22px":"18px";this.style.getPropertyValue("--fx-size-checkbox")||this.style.setProperty("--fx-size-checkbox",t),this.setTemplate(`
|
|
950
|
+
<span class="box" part="box" role="checkbox" tabindex="0"
|
|
951
|
+
aria-checked="${this.indeterminate?"mixed":this.checked}"
|
|
952
|
+
aria-disabled="${this.disabled}">
|
|
953
|
+
<span class="control" part="control">
|
|
954
|
+
<span class="mark">${this.indeterminate?"–":"✓"}</span>
|
|
955
|
+
</span>
|
|
956
|
+
<span class="label" part="label"><slot></slot></span>
|
|
957
|
+
</span>
|
|
958
|
+
`);const e=this.root.querySelector(".box");e&&(e.addEventListener("click",()=>this.toggle()),e.addEventListener("keydown",r=>{(r.key===" "||r.key==="Enter")&&(r.preventDefault(),this.toggle())}))}toggle(){this.disabled||(this.indeterminate=!1,this.checked=!this.checked,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.checked,value:this.getAttr("value")}})))}};ft.styles=p`
|
|
959
|
+
:host {
|
|
960
|
+
display: inline-flex;
|
|
961
|
+
vertical-align: middle;
|
|
962
|
+
font-family: var(--fx-font-family);
|
|
963
|
+
font-size: var(--fx-font-size);
|
|
964
|
+
}
|
|
965
|
+
.box {
|
|
966
|
+
display: inline-flex;
|
|
967
|
+
align-items: center;
|
|
968
|
+
gap: var(--fx-space-sm);
|
|
969
|
+
cursor: pointer;
|
|
970
|
+
user-select: none;
|
|
971
|
+
color: var(--fx-text-default);
|
|
972
|
+
-webkit-tap-highlight-color: transparent;
|
|
973
|
+
}
|
|
974
|
+
.control {
|
|
975
|
+
width: var(--fx-size-checkbox, 18px);
|
|
976
|
+
height: var(--fx-size-checkbox, 18px);
|
|
977
|
+
flex-shrink: 0;
|
|
978
|
+
display: inline-flex;
|
|
979
|
+
align-items: center;
|
|
980
|
+
justify-content: center;
|
|
981
|
+
border: 2px solid var(--fx-border-hover);
|
|
982
|
+
border-radius: calc(var(--fx-radius-sm) + 2px);
|
|
983
|
+
background: var(--fx-surface-background);
|
|
984
|
+
color: #fff;
|
|
985
|
+
font-size: calc(var(--fx-size-checkbox, 18px) - 6px);
|
|
986
|
+
line-height: 1;
|
|
987
|
+
transition:
|
|
988
|
+
background-color var(--fx-motion-duration-fast) var(--fx-motion-easing),
|
|
989
|
+
border-color var(--fx-motion-duration-fast) var(--fx-motion-easing),
|
|
990
|
+
box-shadow var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
991
|
+
}
|
|
992
|
+
.box:hover .control { border-color: var(--fx-color-primary); }
|
|
993
|
+
.box:focus-visible .control {
|
|
994
|
+
outline: none;
|
|
995
|
+
box-shadow: var(--fx-effect-focus-ring, none);
|
|
996
|
+
}
|
|
997
|
+
:host([checked]) .control {
|
|
998
|
+
background: var(--fx-color-primary);
|
|
999
|
+
border-color: var(--fx-color-primary);
|
|
1000
|
+
}
|
|
1001
|
+
:host([indeterminate]) .control {
|
|
1002
|
+
background: var(--fx-color-primary);
|
|
1003
|
+
border-color: var(--fx-color-primary);
|
|
1004
|
+
}
|
|
1005
|
+
/* Validação */
|
|
1006
|
+
:host([error]) .control,
|
|
1007
|
+
:host([invalid]) .control { border-color: var(--fx-color-danger, #dc2626); }
|
|
1008
|
+
:host([success]) .control,
|
|
1009
|
+
:host([valid]) .control { border-color: var(--fx-color-success, #16a34a); }
|
|
1010
|
+
.mark { visibility: hidden; }
|
|
1011
|
+
:host([checked]) .mark,
|
|
1012
|
+
:host([indeterminate]) .mark { visibility: visible; }
|
|
1013
|
+
.label { display: inline-flex; align-items: center; }
|
|
1014
|
+
:host([disabled]) .box {
|
|
1015
|
+
opacity: 0.55;
|
|
1016
|
+
cursor: not-allowed;
|
|
1017
|
+
pointer-events: none;
|
|
1018
|
+
}
|
|
1019
|
+
`;let R=ft;function Kt(){return v("fx-checkbox",R)}Kt();const ht=class ht extends x{static get observedAttributes(){return["checked","disabled"]}get checked(){return this.hasAttr("checked")}set checked(t){this.toggleAttr("checked",!!t)}get disabled(){return this.hasAttr("disabled")}set disabled(t){this.toggleAttr("disabled",!!t)}get size(){const t=this.getAttr("size","md");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}render(){const t=this.size==="sm"?"14px":this.size==="lg"?"22px":"18px";this.style.getPropertyValue("--fx-size-radio")||this.style.setProperty("--fx-size-radio",t),this.setTemplate(`
|
|
1020
|
+
<span class="box" part="box" role="radio" tabindex="0"
|
|
1021
|
+
aria-checked="${this.checked}" aria-disabled="${this.disabled}">
|
|
1022
|
+
<span class="control" part="control"><span class="dot" part="dot"></span></span>
|
|
1023
|
+
<span class="label" part="label"><slot></slot></span>
|
|
1024
|
+
</span>
|
|
1025
|
+
`);const e=this.root.querySelector(".box");e&&(e.addEventListener("click",()=>this.select()),e.addEventListener("keydown",r=>{(r.key===" "||r.key==="Enter")&&(r.preventDefault(),this.select())}))}select(){if(this.disabled||this.checked)return;const t=this.getAttr("name");t&&document.querySelectorAll(`fx-radio[name="${t}"]`).forEach(e=>{e.checked=!1}),this.checked=!0,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:!0,value:this.getAttr("value")}}))}};ht.styles=p`
|
|
1026
|
+
:host {
|
|
1027
|
+
display: inline-flex;
|
|
1028
|
+
vertical-align: middle;
|
|
1029
|
+
font-family: var(--fx-font-family);
|
|
1030
|
+
font-size: var(--fx-font-size);
|
|
1031
|
+
}
|
|
1032
|
+
.box {
|
|
1033
|
+
display: inline-flex;
|
|
1034
|
+
align-items: center;
|
|
1035
|
+
gap: var(--fx-space-sm);
|
|
1036
|
+
cursor: pointer;
|
|
1037
|
+
user-select: none;
|
|
1038
|
+
color: var(--fx-text-default);
|
|
1039
|
+
-webkit-tap-highlight-color: transparent;
|
|
1040
|
+
}
|
|
1041
|
+
.control {
|
|
1042
|
+
width: var(--fx-size-radio, 18px);
|
|
1043
|
+
height: var(--fx-size-radio, 18px);
|
|
1044
|
+
flex-shrink: 0;
|
|
1045
|
+
display: inline-flex;
|
|
1046
|
+
align-items: center;
|
|
1047
|
+
justify-content: center;
|
|
1048
|
+
border: 2px solid var(--fx-border-hover);
|
|
1049
|
+
border-radius: var(--fx-radius-full);
|
|
1050
|
+
background: var(--fx-surface-background);
|
|
1051
|
+
transition:
|
|
1052
|
+
border-color var(--fx-motion-duration-fast) var(--fx-motion-easing),
|
|
1053
|
+
box-shadow var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
1054
|
+
}
|
|
1055
|
+
.box:hover .control { border-color: var(--fx-color-primary); }
|
|
1056
|
+
.box:focus-visible .control {
|
|
1057
|
+
outline: none;
|
|
1058
|
+
box-shadow: var(--fx-effect-focus-ring, none);
|
|
1059
|
+
}
|
|
1060
|
+
.dot {
|
|
1061
|
+
width: calc(100% - 8px);
|
|
1062
|
+
height: calc(100% - 8px);
|
|
1063
|
+
border-radius: var(--fx-radius-full);
|
|
1064
|
+
background: var(--fx-color-primary);
|
|
1065
|
+
transform: scale(0);
|
|
1066
|
+
transition: transform var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
1067
|
+
}
|
|
1068
|
+
:host([checked]) .control { border-color: var(--fx-color-primary); }
|
|
1069
|
+
:host([checked]) .dot { transform: scale(1); }
|
|
1070
|
+
/* Validação */
|
|
1071
|
+
:host([error]) .control,
|
|
1072
|
+
:host([invalid]) .control { border-color: var(--fx-color-danger, #dc2626); }
|
|
1073
|
+
:host([success]) .control,
|
|
1074
|
+
:host([valid]) .control { border-color: var(--fx-color-success, #16a34a); }
|
|
1075
|
+
.label { display: inline-flex; align-items: center; }
|
|
1076
|
+
:host([disabled]) .box {
|
|
1077
|
+
opacity: 0.55;
|
|
1078
|
+
cursor: not-allowed;
|
|
1079
|
+
pointer-events: none;
|
|
1080
|
+
}
|
|
1081
|
+
`;let B=ht;function Xt(){return v("fx-radio",B)}Xt();const ut=class ut extends x{constructor(){super(...arguments),this.data=[],this.page=0,this.sortField="",this.sortDir=1,this.filters={}}static get observedAttributes(){return["pagination","rows","rows-options","striped","empty-message","pagination-position"]}get rowsPerPage(){const t=Number(this.getAttr("rows","10"));return t>0?t:10}set rowsPerPage(t){this.setAttribute("rows",String(t))}get columns(){return[...this.querySelectorAll("fx-column")].map(t=>{var e,r,s,o,a;return{field:(e=t.getAttribute("field"))!=null?e:"",header:(s=(r=t.getAttribute("header"))!=null?r:t.getAttribute("field"))!=null?s:"",sortable:t.hasAttribute("sortable"),filterable:t.hasAttribute("filterable"),align:(o=t.getAttribute("align"))!=null?o:"left",template:(a=t.querySelector("template"))!=null?a:void 0}})}connectedCallback(){if(super.connectedCallback(),!this.data.length)try{const t=this.getAttr("data");t&&(this.data=JSON.parse(t))}catch(t){}new MutationObserver(()=>this.render()).observe(this,{childList:!0,subtree:!0})}computeRows(){let t=[...this.data];for(const[r,s]of Object.entries(this.filters)){if(!s)continue;const o=s.toLowerCase();t=t.filter(a=>{var l;return String((l=a[r])!=null?l:"").toLowerCase().includes(o)})}const e=t.length;if(this.sortField&&t.sort((r,s)=>{const o=r[this.sortField],a=s[this.sortField];return typeof o=="number"&&typeof a=="number"?(o-a)*this.sortDir:String(o!=null?o:"").localeCompare(String(a!=null?a:""),"pt-BR")*this.sortDir}),this.hasAttr("pagination")){const r=this.page*this.rowsPerPage;t=t.slice(r,r+this.rowsPerPage)}return{rows:t,total:e}}cellHtml(t,e){const r=e[t.field];return t.template?t.template.innerHTML.replace(/\{\{(\w+)\}\}/g,(s,o)=>{var a;return o==="value"?String(r!=null?r:""):o==="row"?"":String((a=e[o])!=null?a:"")}):String(r!=null?r:"")}render(){var h;const t=this.columns.filter(n=>n.field),{rows:e,total:r}=this.computeRows(),s=this.hasAttr("pagination"),o=Math.max(1,Math.ceil(r/this.rowsPerPage));this.page>=o&&(this.page=o-1);const a=t.map(n=>{const f=this.sortField===n.field?this.sortDir===1?"▲":"▼":"";return`<th part="header" class="${n.sortable?"sortable":""}" style="text-align:${n.align}" data-field="${n.field}">${n.header}${f?`<span class="sort-ind">${f}</span>`:""}</th>`}).join(""),l=t.some(n=>n.filterable)?`<tr class="filter-row">${t.map(n=>{var f;return`<th style="text-align:${n.align}">${n.filterable?`<input class="filter" data-field="${n.field}" placeholder="Filtrar…" value="${(f=this.filters[n.field])!=null?f:""}">`:""}</th>`}).join("")}</tr>`:"",i=e.length?e.map((n,f)=>`<tr part="row" data-index="${f}">${t.map(d=>`<td part="cell" style="text-align:${d.align}">${this.cellHtml(d,n)}</td>`).join("")}</tr>`).join(""):`<tr><td class="empty" colspan="${t.length||1}">${this.getAttr("empty-message","Nenhum registro encontrado")}</td></tr>`,c=s?`
|
|
1082
|
+
<div class="pager" part="pager">
|
|
1083
|
+
<span class="info">Página ${this.page+1} de ${o} · ${r} registros</span>
|
|
1084
|
+
<button type="button" class="pg-btn" data-pg="first" ${this.page===0?"disabled":""}>«</button>
|
|
1085
|
+
<button type="button" class="pg-btn" data-pg="prev" ${this.page===0?"disabled":""}>‹</button>
|
|
1086
|
+
${Array.from({length:o},(n,f)=>`<button type="button" class="pg-btn" data-pg="${f}" aria-current="${f===this.page}">${f+1}</button>`).join("")}
|
|
1087
|
+
<button type="button" class="pg-btn" data-pg="next" ${this.page>=o-1?"disabled":""}>›</button>
|
|
1088
|
+
<button type="button" class="pg-btn" data-pg="last" ${this.page>=o-1?"disabled":""}>»</button>
|
|
1089
|
+
<label class="info">Por página:
|
|
1090
|
+
<select class="rows-sel">${this.getAttr("rows-options","5,10,20,50").split(",").map(n=>n.trim()).map(n=>`<option value="${n}" ${Number(n)===this.rowsPerPage?"selected":""}>${n}</option>`).join("")}</select>
|
|
1091
|
+
</label>
|
|
1092
|
+
</div>`:"";this.setTemplate(`
|
|
1093
|
+
<div class="scroll">
|
|
1094
|
+
<table part="table">
|
|
1095
|
+
<thead><tr>${a}</tr>${l}</thead>
|
|
1096
|
+
<tbody>${i}</tbody>
|
|
1097
|
+
</table>
|
|
1098
|
+
</div>
|
|
1099
|
+
${c}
|
|
1100
|
+
`),this.root.querySelectorAll("th.sortable").forEach(n=>{n.addEventListener("click",()=>{const f=n.dataset.field;this.sortField===f?this.sortDir=this.sortDir===1?-1:1:(this.sortField=f,this.sortDir=1),this.render(),this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,composed:!0,detail:{field:this.sortField,direction:this.sortDir===1?"asc":"desc"}}))})}),this.root.querySelectorAll(".filter").forEach(n=>{n.addEventListener("input",()=>{this.filters[n.dataset.field]=n.value,this.page=0;const f=n.dataset.field,d=n.selectionStart;this.render();const u=this.root.querySelector(`.filter[data-field="${f}"]`);u&&(u.focus(),u.setSelectionRange(d,d))}),n.addEventListener("click",f=>f.stopPropagation())}),this.root.querySelectorAll(".pg-btn").forEach(n=>{n.addEventListener("click",()=>{const f=n.dataset.pg;this.page=f==="first"?0:f==="prev"?Math.max(0,this.page-1):f==="next"?Math.min(o-1,this.page+1):f==="last"?o-1:Number(f),this.render(),this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,composed:!0,detail:{page:this.page+1,pages:o,rowsPerPage:this.rowsPerPage,total:r}}))})}),(h=this.root.querySelector(".rows-sel"))==null||h.addEventListener("change",n=>{this.rowsPerPage=Number(n.target.value),this.page=0,this.render()}),this.root.querySelectorAll("tbody tr[data-index]").forEach(n=>{n.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("row-click",{bubbles:!0,composed:!0,detail:{row:e[Number(n.dataset.index)],index:Number(n.dataset.index)}}))})})}};ut.styles=p`
|
|
1101
|
+
:host {
|
|
1102
|
+
display: block;
|
|
1103
|
+
font-family: var(--fx-font-family);
|
|
1104
|
+
font-size: var(--fx-font-size);
|
|
1105
|
+
color: var(--fx-text-default);
|
|
1106
|
+
}
|
|
1107
|
+
.scroll { overflow-x: auto; border: 1px solid var(--fx-border-default); border-radius: var(--fx-radius-md); }
|
|
1108
|
+
table { width: 100%; border-collapse: collapse; }
|
|
1109
|
+
th {
|
|
1110
|
+
text-align: left;
|
|
1111
|
+
padding: var(--fx-space-sm) var(--fx-space-md);
|
|
1112
|
+
background: var(--fx-surface-background);
|
|
1113
|
+
border-bottom: 2px solid var(--fx-border-default);
|
|
1114
|
+
white-space: nowrap;
|
|
1115
|
+
user-select: none;
|
|
1116
|
+
}
|
|
1117
|
+
th.sortable { cursor: pointer; }
|
|
1118
|
+
th.sortable:hover { color: var(--fx-color-primary); }
|
|
1119
|
+
.sort-ind { font-size: calc(var(--fx-font-size) - 4px); margin-left: var(--fx-space-3xs, 2px); }
|
|
1120
|
+
.filter-row th { padding: var(--fx-space-3xs, 4px) var(--fx-space-md) var(--fx-space-sm); border-bottom-width: 1px; }
|
|
1121
|
+
.filter {
|
|
1122
|
+
width: 100%;
|
|
1123
|
+
box-sizing: border-box;
|
|
1124
|
+
font: inherit;
|
|
1125
|
+
font-size: calc(var(--fx-font-size) - 2px);
|
|
1126
|
+
color: var(--fx-text-default);
|
|
1127
|
+
background: var(--fx-surface-background);
|
|
1128
|
+
border: 1px solid var(--fx-border-default);
|
|
1129
|
+
border-radius: var(--fx-radius-sm);
|
|
1130
|
+
padding: var(--fx-space-3xs, 4px) var(--fx-space-xs);
|
|
1131
|
+
outline: none;
|
|
1132
|
+
}
|
|
1133
|
+
.filter:focus { border-color: var(--fx-color-primary); box-shadow: var(--fx-effect-focus-ring, none); }
|
|
1134
|
+
td {
|
|
1135
|
+
padding: var(--fx-space-sm) var(--fx-space-md);
|
|
1136
|
+
border-bottom: 1px solid var(--fx-border-default);
|
|
1137
|
+
}
|
|
1138
|
+
tbody tr { cursor: pointer; transition: background-color var(--fx-motion-duration-fast) var(--fx-motion-easing); }
|
|
1139
|
+
tbody tr:hover { background: color-mix(in srgb, var(--fx-color-primary) 8%, transparent); }
|
|
1140
|
+
:host([striped]) tbody tr:nth-child(even) { background: var(--fx-surface-background); }
|
|
1141
|
+
:host([striped]) tbody tr:hover { background: color-mix(in srgb, var(--fx-color-primary) 8%, transparent); }
|
|
1142
|
+
.empty { text-align: center; padding: var(--fx-space-xl); color: var(--fx-text-muted); }
|
|
1143
|
+
.pager {
|
|
1144
|
+
display: flex;
|
|
1145
|
+
align-items: center;
|
|
1146
|
+
gap: var(--fx-space-sm);
|
|
1147
|
+
flex-wrap: wrap;
|
|
1148
|
+
padding: var(--fx-space-sm) 0;
|
|
1149
|
+
}
|
|
1150
|
+
:host([pagination-position='center']) .pager { justify-content: center; }
|
|
1151
|
+
:host([pagination-position='right']) .pager { justify-content: flex-end; }
|
|
1152
|
+
.pager .info { color: var(--fx-text-muted); font-size: calc(var(--fx-font-size) - 2px); }
|
|
1153
|
+
.pg-btn {
|
|
1154
|
+
font: inherit;
|
|
1155
|
+
font-size: calc(var(--fx-font-size) - 2px);
|
|
1156
|
+
color: var(--fx-text-default);
|
|
1157
|
+
background: var(--fx-surface-background);
|
|
1158
|
+
border: 1px solid var(--fx-border-default);
|
|
1159
|
+
border-radius: var(--fx-radius-sm);
|
|
1160
|
+
padding: var(--fx-space-3xs, 4px) var(--fx-space-sm);
|
|
1161
|
+
cursor: pointer;
|
|
1162
|
+
transition: border-color var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
1163
|
+
}
|
|
1164
|
+
.pg-btn:hover:not(:disabled) { border-color: var(--fx-color-primary); color: var(--fx-color-primary); }
|
|
1165
|
+
.pg-btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
1166
|
+
.pg-btn[aria-current='true'] {
|
|
1167
|
+
background: var(--fx-color-primary);
|
|
1168
|
+
border-color: var(--fx-color-primary);
|
|
1169
|
+
color: #fff;
|
|
1170
|
+
font-weight: var(--fx-font-weight);
|
|
1171
|
+
}
|
|
1172
|
+
.rows-sel {
|
|
1173
|
+
font: inherit;
|
|
1174
|
+
font-size: calc(var(--fx-font-size) - 2px);
|
|
1175
|
+
color: var(--fx-text-default);
|
|
1176
|
+
background: var(--fx-surface-background);
|
|
1177
|
+
border: 1px solid var(--fx-border-default);
|
|
1178
|
+
border-radius: var(--fx-radius-sm);
|
|
1179
|
+
padding: 2px var(--fx-space-xs);
|
|
1180
|
+
outline: none;
|
|
1181
|
+
}
|
|
1182
|
+
`;let H=ut;function Ft(){return v("fx-table",H)}Ft();const pt=class pt extends x{constructor(){super(...arguments),this.targetControl=null,this.observer=null,this.listenersReady=!1}static get observedAttributes(){return["variant","error","invalid","success","valid"]}render(){var l;const t=this.findControl(),r=this.findLabel(),s=r?(l=r.textContent)==null?void 0:l.replace(/\s+/g," ").trim():"",o=r&&r.getAttribute("for")||"",a=this.getAttribute("variant")==="over";this.setTemplate(`
|
|
1183
|
+
<div class="wrapper" part="wrapper">
|
|
1184
|
+
${a?`<label class="flabel" part="label" for="${o}">${s}</label>`:""}
|
|
1185
|
+
<div class="field-box" part="field">
|
|
1186
|
+
<slot></slot>
|
|
1187
|
+
${a?"":`<label class="flabel" part="label" for="${o}">${s}</label>`}
|
|
1188
|
+
</div>
|
|
1189
|
+
<div class="error-message" part="error"></div>
|
|
1190
|
+
</div>
|
|
1191
|
+
`),r&&r.setAttribute("hidden",""),this.attachEvents(),this.syncControlReference(t),this.syncState(),this.applyError()}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.observer)==null||t.disconnect()}findControl(){var t;return(t=Array.from(this.children).find(e=>e.tagName.toLowerCase()!=="label"))!=null?t:null}findLabel(){var t;return(t=Array.from(this.children).find(e=>e.tagName.toLowerCase()==="label"))!=null?t:null}attachEvents(){const t=this.root.querySelector("slot");t&&t.addEventListener("slotchange",()=>{const e=this.findControl();this.syncControlReference(e),this.syncState(),this.applyError()}),!this.listenersReady&&(this.listenersReady=!0,this.addEventListener("focusin",()=>this.syncState()),this.addEventListener("focusout",()=>setTimeout(()=>this.syncState(),60)),this.addEventListener("input",()=>this.syncState()),this.addEventListener("change",()=>this.syncState()))}syncControlReference(t=this.targetControl){var e;t!==this.targetControl&&((e=this.observer)==null||e.disconnect(),this.observer=null,this.targetControl=t,t&&(this.observer=new MutationObserver(()=>this.syncState()),this.observer.observe(t,{attributes:!0,attributeFilter:["value","values","start","end","open"]})))}syncState(){var a,l,i;if(this.targetControl&&!this.targetControl.isConnected&&(this.targetControl=null,(a=this.observer)==null||a.disconnect(),this.observer=null),!this.targetControl){this.removeAttribute("active"),this.removeAttribute("focus");return}const t=this.targetControl,e=t.getAttribute?((l=t.getAttribute("value"))!=null?l:"").trim():"",r=t.getAttribute?((i=t.getAttribute("values"))!=null?i:"").trim():"",s=!!(typeof t.value=="string"&&t.value.trim()!==""||Array.isArray(t.values)&&t.values.length>0||e!==""||r!==""||t.hasAttribute&&(t.hasAttribute("open")||t.hasAttribute("start"))),o=this.isFocusedInside();s||o?(this.setAttribute("active",""),o?this.setAttribute("focus",""):this.removeAttribute("focus")):(this.removeAttribute("active"),this.removeAttribute("focus"))}applyError(){var r;const t=this.hasAttr("error")||this.hasAttr("invalid"),e=this.root.querySelector(".error-message");if(e&&(e.textContent=t?((r=this.getAttribute("error-text"))==null?void 0:r.trim())||"Valor inválido":""),this.targetControl&&typeof this.targetControl.setAttribute=="function"){const s=this.targetControl;t?(s.setAttribute("error",""),s.removeAttribute("success")):this.hasAttr("success")||this.hasAttr("valid")?(s.setAttribute("success",""),s.removeAttribute("error")):(s.removeAttribute("error"),s.removeAttribute("success"))}}isWithin(t){let e=t;for(;e&&e!==this;)e=e.parentElement;return e===this}isFocusedInside(){const t=document.activeElement;return!!(t&&this.isWithin(t))}};pt.styles=p`
|
|
1192
|
+
:host {
|
|
1193
|
+
display: inline-block;
|
|
1194
|
+
position: relative;
|
|
1195
|
+
font-family: var(--fx-font-family);
|
|
1196
|
+
font-size: var(--fx-font-size);
|
|
1197
|
+
vertical-align: middle;
|
|
1198
|
+
}
|
|
1199
|
+
.wrapper {
|
|
1200
|
+
position: relative;
|
|
1201
|
+
display: inline-block;
|
|
1202
|
+
width: 100%;
|
|
1203
|
+
}
|
|
1204
|
+
/* Caixa do campo: referência de posicionamento da label flutuante
|
|
1205
|
+
(isolada da mensagem de erro, que cresce o wrapper). */
|
|
1206
|
+
.field-box {
|
|
1207
|
+
position: relative;
|
|
1208
|
+
display: inline-block;
|
|
1209
|
+
width: 100%;
|
|
1210
|
+
}
|
|
1211
|
+
:host([variant="in"]) .field-box {
|
|
1212
|
+
padding-top: var(--fx-space-xs, 6px);
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/* ---- label base (variant="on", padrão): sobre a borda superior ---- */
|
|
1216
|
+
.flabel {
|
|
1217
|
+
position: absolute;
|
|
1218
|
+
left: var(--fx-space-md, 12px);
|
|
1219
|
+
top: 0;
|
|
1220
|
+
transform: translateY(-50%);
|
|
1221
|
+
font-size: calc(var(--fx-font-size, 14px) - 3px);
|
|
1222
|
+
font-weight: 600;
|
|
1223
|
+
color: var(--fx-text-muted, #94a3b8);
|
|
1224
|
+
background-color: var(--fx-surface-background, #fff);
|
|
1225
|
+
padding: 0 4px;
|
|
1226
|
+
line-height: 1;
|
|
1227
|
+
border-radius: 2px;
|
|
1228
|
+
pointer-events: none;
|
|
1229
|
+
z-index: 2;
|
|
1230
|
+
white-space: nowrap;
|
|
1231
|
+
transition:
|
|
1232
|
+
top var(--fx-motion-duration-normal, 180ms)
|
|
1233
|
+
var(--fx-motion-easing, ease-in-out),
|
|
1234
|
+
transform var(--fx-motion-duration-normal, 180ms)
|
|
1235
|
+
var(--fx-motion-easing, ease-in-out),
|
|
1236
|
+
font-size var(--fx-motion-duration-normal, 180ms)
|
|
1237
|
+
var(--fx-motion-easing, ease-in-out),
|
|
1238
|
+
color var(--fx-motion-duration-normal, 180ms)
|
|
1239
|
+
var(--fx-motion-easing, ease-in-out);
|
|
1240
|
+
}
|
|
1241
|
+
:host([active]) .flabel {
|
|
1242
|
+
color: var(--fx-color-primary, #4f46e5);
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
/* ---- variant="in": label como placeholder dentro, sobe ao focar/valor ---- */
|
|
1246
|
+
:host([variant="in"]) .flabel {
|
|
1247
|
+
top: 50%;
|
|
1248
|
+
transform: translateY(-50%);
|
|
1249
|
+
font-size: var(--fx-font-size, 14px);
|
|
1250
|
+
font-weight: var(--fx-font-weight, 400);
|
|
1251
|
+
background: transparent;
|
|
1252
|
+
padding: 0;
|
|
1253
|
+
}
|
|
1254
|
+
:host([variant="in"][active]) .flabel {
|
|
1255
|
+
top: 0;
|
|
1256
|
+
transform: translateY(-50%);
|
|
1257
|
+
font-size: calc(var(--fx-font-size, 14px) - 3px);
|
|
1258
|
+
font-weight: 600;
|
|
1259
|
+
background-color: var(--fx-surface-background, #fff);
|
|
1260
|
+
padding: 0 5px;
|
|
1261
|
+
color: var(--fx-color-primary, #4f46e5);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
/* ---- variant="over": label estática ACIMA do campo (fora, em fluxo) ---- */
|
|
1265
|
+
:host([variant="over"]) {
|
|
1266
|
+
display: block;
|
|
1267
|
+
}
|
|
1268
|
+
:host([variant="over"]) .flabel {
|
|
1269
|
+
position: static;
|
|
1270
|
+
display: block;
|
|
1271
|
+
margin-bottom: var(--fx-space-xs, 4px);
|
|
1272
|
+
background: transparent;
|
|
1273
|
+
padding: 0;
|
|
1274
|
+
font-size: calc(var(--fx-font-size, 14px) - 3px);
|
|
1275
|
+
font-weight: 600;
|
|
1276
|
+
white-space: normal;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
/* ---- estados de erro / sucesso ---- */
|
|
1280
|
+
:host([error]) .flabel,
|
|
1281
|
+
:host([invalid]) .flabel {
|
|
1282
|
+
color: var(--fx-color-danger, #dc2626);
|
|
1283
|
+
}
|
|
1284
|
+
:host([success]) .flabel,
|
|
1285
|
+
:host([valid]) .flabel {
|
|
1286
|
+
color: var(--fx-color-success, #10b981);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
/* ---- mensagem de erro sob o campo (fonte menor) ---- */
|
|
1290
|
+
.error-message {
|
|
1291
|
+
display: none;
|
|
1292
|
+
margin-top: var(--fx-space-xs, 4px);
|
|
1293
|
+
margin-left: var(--fx-space-md, 12px);
|
|
1294
|
+
font-size: calc(var(--fx-font-size, 14px) - 3px);
|
|
1295
|
+
font-weight: 500;
|
|
1296
|
+
color: var(--fx-color-danger, #dc2626);
|
|
1297
|
+
line-height: 1.2;
|
|
1298
|
+
}
|
|
1299
|
+
:host([error]) .error-message,
|
|
1300
|
+
:host([invalid]) .error-message {
|
|
1301
|
+
display: block;
|
|
1302
|
+
}
|
|
1303
|
+
`;let V=pt;function Ot(){return v("fx-floatlabel",V)}Ot();const bt=class bt extends x{static get observedAttributes(){return["size","placeholder","disabled","readonly","rows","maxlength"]}get size(){const t=this.getAttr("size","md");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get value(){return this.getAttr("value")}set value(t){this.setAttribute("value",t)}render(){const t=this.getAttr("placeholder"),e=this.hasAttr("readonly"),r=this.hasAttr("disabled"),s=this.getAttr("rows"),o=this.getAttr("maxlength");this.setTemplate(`<textarea class="field" part="textarea"
|
|
1304
|
+
${t?`placeholder="${t}"`:""}
|
|
1305
|
+
${s?`rows="${s}"`:""}
|
|
1306
|
+
${o?`maxlength="${o}"`:""}
|
|
1307
|
+
></textarea>`);const a=this.root.querySelector(".field");if(!a)return;a.value=this.getAttr("value"),r&&a.setAttribute("disabled",""),e&&a.setAttribute("readonly","");const l=i=>{this.value=a.value,this.dispatchEvent(new CustomEvent(i,{bubbles:!0,composed:!0,detail:{value:a.value}}))};a.addEventListener("input",i=>{i.stopPropagation(),l("input")}),a.addEventListener("change",i=>{i.stopPropagation(),l("change")})}};bt.styles=p`
|
|
1308
|
+
:host {
|
|
1309
|
+
display: inline-block;
|
|
1310
|
+
vertical-align: middle;
|
|
1311
|
+
font-family: var(--fx-font-family);
|
|
1312
|
+
font-size: var(--fx-font-size);
|
|
1313
|
+
}
|
|
1314
|
+
.field {
|
|
1315
|
+
font-family: inherit;
|
|
1316
|
+
font-size: inherit;
|
|
1317
|
+
font-weight: var(--fx-font-weight);
|
|
1318
|
+
color: var(--fx-text-default);
|
|
1319
|
+
background-color: var(--fx-surface-background);
|
|
1320
|
+
border: 1px solid var(--fx-border-default);
|
|
1321
|
+
border-radius: var(--fx-radius-md);
|
|
1322
|
+
padding: var(--fx-space-md) var(--fx-space-lg);
|
|
1323
|
+
width: 260px;
|
|
1324
|
+
min-height: calc(var(--fx-size-md) + 40px);
|
|
1325
|
+
resize: vertical;
|
|
1326
|
+
box-sizing: border-box;
|
|
1327
|
+
transition:
|
|
1328
|
+
border-color var(--fx-motion-duration-normal) var(--fx-motion-easing),
|
|
1329
|
+
box-shadow var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
1330
|
+
}
|
|
1331
|
+
.field::placeholder { color: var(--fx-text-muted); opacity: 1; }
|
|
1332
|
+
.field:hover { border-color: var(--fx-border-hover); }
|
|
1333
|
+
.field:focus-visible {
|
|
1334
|
+
outline: none;
|
|
1335
|
+
border-color: var(--fx-color-primary);
|
|
1336
|
+
box-shadow: var(--fx-effect-focus-ring, none);
|
|
1337
|
+
}
|
|
1338
|
+
.field:disabled,
|
|
1339
|
+
.field[readonly] {
|
|
1340
|
+
opacity: 0.55;
|
|
1341
|
+
cursor: not-allowed;
|
|
1342
|
+
background-color: var(--fx-surface-surface-hover);
|
|
1343
|
+
}
|
|
1344
|
+
:host([error]) .field, :host([invalid]) .field {
|
|
1345
|
+
border-color: var(--fx-color-danger, #dc2626);
|
|
1346
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-color-danger, #dc2626) 18%, transparent);
|
|
1347
|
+
}
|
|
1348
|
+
:host([success]) .field, :host([valid]) .field {
|
|
1349
|
+
border-color: var(--fx-color-success, #16a34a);
|
|
1350
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-color-success, #16a34a) 18%, transparent);
|
|
1351
|
+
}
|
|
1352
|
+
:host([size='sm']) .field { width: 220px; min-height: var(--fx-size-sm); padding: var(--fx-space-sm) var(--fx-space-md); }
|
|
1353
|
+
:host([size='lg']) .field { width: 300px; min-height: calc(var(--fx-size-lg) + 80px); }
|
|
1354
|
+
`;let I=bt;function Jt(){return v("fx-textarea",I)}Jt();const xt=class xt extends x{static get observedAttributes(){return["open","size","heading"]}get open(){return this.hasAttr("open")}set open(t){this.toggleAttr("open",t)}render(){const t=this.open,e=this.getAttr("heading");if(this.setTemplate(`
|
|
1355
|
+
<div class="overlay" part="overlay" ${t?"":"hidden"}>
|
|
1356
|
+
<div class="dialog" role="dialog" aria-modal="true" aria-label="${e}">
|
|
1357
|
+
<header>
|
|
1358
|
+
<h2>${e}</h2>
|
|
1359
|
+
<button type="button" class="close" part="close" aria-label="Fechar">×</button>
|
|
1360
|
+
</header>
|
|
1361
|
+
<div class="body"><slot></slot></div>
|
|
1362
|
+
<footer part="footer"><slot name="footer"></slot></footer>
|
|
1363
|
+
</div>
|
|
1364
|
+
</div>
|
|
1365
|
+
`),!t)return;const r=this.root.querySelector(".overlay"),s=this.root.querySelector(".close"),o=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))};r==null||r.addEventListener("click",l=>{l.target===r&&o()}),s==null||s.addEventListener("click",o);const a=l=>{l.key==="Escape"&&(l.stopPropagation(),o())};document.addEventListener("keydown",a,{once:!0}),this._cleanup=()=>document.removeEventListener("keydown",a),requestAnimationFrame(()=>{var l;return(l=this.root.querySelector(".dialog"))==null?void 0:l.focus()}),this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0}))}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._cleanup)==null||t.call(this)}};xt.styles=p`
|
|
1366
|
+
:host { display: contents; }
|
|
1367
|
+
.overlay {
|
|
1368
|
+
position: fixed;
|
|
1369
|
+
inset: 0;
|
|
1370
|
+
background: color-mix(in srgb, var(--fx-text-default, #000) 45%, transparent);
|
|
1371
|
+
backdrop-filter: blur(3px);
|
|
1372
|
+
-webkit-backdrop-filter: blur(3px);
|
|
1373
|
+
display: flex;
|
|
1374
|
+
align-items: center;
|
|
1375
|
+
justify-content: center;
|
|
1376
|
+
z-index: var(--fx-z-modal, 1100);
|
|
1377
|
+
animation: fade var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
1378
|
+
}
|
|
1379
|
+
.overlay[hidden] { display: none; }
|
|
1380
|
+
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
|
|
1381
|
+
.dialog {
|
|
1382
|
+
background: var(--fx-surface-background);
|
|
1383
|
+
border: 1px solid var(--fx-border-default);
|
|
1384
|
+
border-radius: var(--fx-radius-lg);
|
|
1385
|
+
box-shadow: var(--fx-shadow-xl);
|
|
1386
|
+
width: min(560px, calc(100vw - 32px));
|
|
1387
|
+
max-height: calc(100vh - 64px);
|
|
1388
|
+
display: flex;
|
|
1389
|
+
flex-direction: column;
|
|
1390
|
+
font-family: var(--fx-font-family);
|
|
1391
|
+
animation: pop var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
1392
|
+
}
|
|
1393
|
+
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
|
|
1394
|
+
:host([size='sm']) .dialog { width: min(400px, calc(100vw - 32px)); }
|
|
1395
|
+
:host([size='lg']) .dialog { width: min(800px, calc(100vw - 32px)); }
|
|
1396
|
+
header {
|
|
1397
|
+
display: flex;
|
|
1398
|
+
align-items: center;
|
|
1399
|
+
justify-content: space-between;
|
|
1400
|
+
padding: var(--fx-space-lg) var(--fx-space-xl);
|
|
1401
|
+
border-bottom: 1px solid var(--fx-border-default);
|
|
1402
|
+
}
|
|
1403
|
+
h2 {
|
|
1404
|
+
margin: 0;
|
|
1405
|
+
font-size: calc(var(--fx-font-size) + 2px);
|
|
1406
|
+
font-weight: 600;
|
|
1407
|
+
color: var(--fx-text-default);
|
|
1408
|
+
}
|
|
1409
|
+
.close {
|
|
1410
|
+
border: none;
|
|
1411
|
+
background: transparent;
|
|
1412
|
+
color: var(--fx-text-muted);
|
|
1413
|
+
font-size: calc(var(--fx-font-size) + 6px);
|
|
1414
|
+
cursor: pointer;
|
|
1415
|
+
line-height: 1;
|
|
1416
|
+
padding: 0 var(--fx-space-xs);
|
|
1417
|
+
border-radius: var(--fx-radius-full);
|
|
1418
|
+
}
|
|
1419
|
+
.close:hover { color: var(--fx-color-danger); }
|
|
1420
|
+
.body {
|
|
1421
|
+
padding: var(--fx-space-lg) var(--fx-space-xl);
|
|
1422
|
+
overflow-y: auto;
|
|
1423
|
+
color: var(--fx-text-default);
|
|
1424
|
+
font-size: var(--fx-font-size);
|
|
1425
|
+
}
|
|
1426
|
+
footer {
|
|
1427
|
+
padding: var(--fx-space-md) var(--fx-space-xl);
|
|
1428
|
+
border-top: 1px solid var(--fx-border-default);
|
|
1429
|
+
display: flex;
|
|
1430
|
+
justify-content: flex-end;
|
|
1431
|
+
gap: var(--fx-space-sm);
|
|
1432
|
+
}
|
|
1433
|
+
footer[hidden] { display: none; }
|
|
1434
|
+
`;let Y=xt;function Ut(){return v("fx-dialog",Y)}Ut();const Ct={success:"var(--fx-color-success, #10b981)",error:"var(--fx-color-danger, #f43f5e)",info:"var(--fx-color-info, #0ea5e9)",warning:"var(--fx-color-warning, #f59e0b)"},Lt={success:"✓",error:"✕",warning:"!",info:"i"},Wt=`
|
|
1435
|
+
:host { display: contents; }
|
|
1436
|
+
.card {
|
|
1437
|
+
display: flex; align-items: flex-start; gap: 10px;
|
|
1438
|
+
min-width: 260px; max-width: 360px;
|
|
1439
|
+
background: var(--fx-surface-background, #fff);
|
|
1440
|
+
color: var(--fx-text-default, #1e293b);
|
|
1441
|
+
border: 1px solid var(--fx-border-default, #e2e8f0);
|
|
1442
|
+
border-left: 4px solid var(--kind);
|
|
1443
|
+
border-radius: var(--fx-radius-md, 8px);
|
|
1444
|
+
box-shadow: var(--fx-shadow-lg, 0 10px 30px rgba(0,0,0,.14));
|
|
1445
|
+
padding: var(--fx-space-sm, 8px) var(--fx-space-md, 12px);
|
|
1446
|
+
font-family: inherit;
|
|
1447
|
+
animation: fx-toast-in .25s ease;
|
|
1448
|
+
}
|
|
1449
|
+
@keyframes fx-toast-in { from { opacity: 0; transform: translateY(-6px); } }
|
|
1450
|
+
.card.leaving { opacity: 0; transition: opacity .2s ease; }
|
|
1451
|
+
.icon {
|
|
1452
|
+
width: 22px; height: 22px; border-radius: 50%;
|
|
1453
|
+
background: var(--kind);
|
|
1454
|
+
color: #fff;
|
|
1455
|
+
display: flex; align-items: center; justify-content: center;
|
|
1456
|
+
font-size: 12px; font-weight: 700;
|
|
1457
|
+
flex: none; margin-top: 2px;
|
|
1458
|
+
user-select: none;
|
|
1459
|
+
}
|
|
1460
|
+
.body { flex: 1; min-width: 0; }
|
|
1461
|
+
.title { font-weight: 600; font-size: 14px; }
|
|
1462
|
+
.msg { font-size: calc(var(--fx-font-size, 14px) - 2px); color: var(--fx-text-muted, #64748b); margin-top: 2px; word-break: break-word; white-space: pre-line; }
|
|
1463
|
+
.close {
|
|
1464
|
+
all: unset; cursor: pointer; flex: none; line-height: 1;
|
|
1465
|
+
color: var(--fx-text-muted, #64748b); font-size: 15px; padding: 2px 4px; border-radius: 4px;
|
|
1466
|
+
}
|
|
1467
|
+
.close:hover { color: var(--fx-color-danger, #f43f5e); background: var(--fx-surface-surface-hover, rgba(0,0,0,.05)); }
|
|
1468
|
+
`;class Gt extends HTMLElement{constructor(){super();Dt(this,C);this.timer=null,this.attachShadow({mode:"open"})}static get observedAttributes(){return["kind","title","message","duration"]}connectedCallback(){var s;this.shadowRoot.firstChild||Mt(this,C,Nt).call(this);const e=Number((s=this.getAttribute("duration"))!=null?s:"4000"),r=e===0?0:Math.max(Number.isNaN(e)?4e3:e,1e3);!Number.isNaN(r)&&r>0&&!this.timer&&(this.timer=setTimeout(()=>this.dismiss(),r))}disconnectedCallback(){this.timer&&clearTimeout(this.timer),this.timer=null}dismiss(){this.timer&&clearTimeout(this.timer),this.timer=null;const e=this.shadowRoot.querySelector(".card");e?(e.classList.add("leaving"),setTimeout(()=>this.remove(),200)):this.remove()}}C=new WeakSet,Nt=function(){var i,c,h,n;const e=this.getAttribute("kind")||"info",r=(i=this.getAttribute("title"))!=null?i:"",s=(c=this.getAttribute("message"))!=null?c:"",o=(h=Ct[e])!=null?h:Ct.info;this.shadowRoot.innerHTML=`
|
|
1469
|
+
<style>${Wt}</style>
|
|
1470
|
+
<div class="card" style="--kind:${o}" role="status" part="card">
|
|
1471
|
+
<span class="icon">${(n=Lt[e])!=null?n:Lt.info}</span>
|
|
1472
|
+
<div class="body">
|
|
1473
|
+
${r?'<div class="title"></div>':""}
|
|
1474
|
+
${s?'<div class="msg"></div>':""}
|
|
1475
|
+
</div>
|
|
1476
|
+
<button class="close" aria-label="Fechar">✕</button>
|
|
1477
|
+
</div>`;const a=this.shadowRoot.querySelector(".title"),l=this.shadowRoot.querySelector(".msg");a&&(a.textContent=r),l&&(l.textContent=s),this.shadowRoot.querySelector(".close").addEventListener("click",()=>this.dismiss())};function Qt(g){let t=document.querySelector(`[data-fx-toast-region="${g}"]`);if(!t){t=document.createElement("div"),t.setAttribute("data-fx-toast-region",g);const[e,r]=g.split("-"),s=t.style;s.position="fixed",s[e]="16px",r==="center"?(s.left="50%",s.transform="translateX(-50%)"):s[r]="16px",s.display="flex",s.flexDirection="column",s.gap="8px",s.zIndex="1100",s.pointerEvents="none",new MutationObserver(()=>{t.querySelectorAll("*").forEach(o=>o.style.pointerEvents="auto")}).observe(t,{childList:!0}),document.body.appendChild(t)}return t}class Zt{constructor(){this.seq=0,this.map=new Map,this.success=(t,e,r)=>this.push("success",t,e,r),this.error=(t,e,r)=>this.push("error",t,e,r),this.info=(t,e,r)=>this.push("info",t,e,r),this.warning=(t,e,r)=>this.push("warning",t,e,r)}push(t,e,r,s){var c,h,n;const o=++this.seq,a=typeof r=="string"?r:r==null?void 0:r.message,l={...typeof r=="object"&&r?r:void 0,...s},i=document.createElement("fx-toast");return i.setAttribute("kind",t),i.setAttribute("title",e),a&&i.setAttribute("message",a),i.setAttribute("position",(c=l.position)!=null?c:"top-right"),i.setAttribute("duration",String((h=l.duration)!=null?h:4e3)),Qt((n=l.position)!=null?n:"top-right").appendChild(i),this.map.set(o,i),o}close(t){var e;(e=this.map.get(t))==null||e.dismiss(),this.map.delete(t)}}const te=new Zt;globalThis.FenixToast=te;function ee(){customElements.get("fx-toast")||customElements.define("fx-toast",Gt)}ee();const vt=class vt extends x{static get observedAttributes(){return["content","position"]}render(){const t=this.getAttr("content");this.setTemplate(`
|
|
1478
|
+
<slot></slot>
|
|
1479
|
+
<span class="bubble" part="bubble" role="tooltip">${t}</span>
|
|
1480
|
+
`)}};vt.styles=p`
|
|
1481
|
+
:host {
|
|
1482
|
+
position: relative;
|
|
1483
|
+
display: inline-flex;
|
|
1484
|
+
font-family: var(--fx-font-family);
|
|
1485
|
+
}
|
|
1486
|
+
.bubble {
|
|
1487
|
+
position: absolute;
|
|
1488
|
+
background: var(--fx-text-default, #1e293b);
|
|
1489
|
+
color: var(--fx-surface-background, #fff);
|
|
1490
|
+
font-size: calc(var(--fx-font-size, 14px) - 2px);
|
|
1491
|
+
line-height: 1.45;
|
|
1492
|
+
padding: var(--fx-space-xs) var(--fx-space-md);
|
|
1493
|
+
border-radius: var(--fx-radius-sm);
|
|
1494
|
+
box-shadow: var(--fx-shadow-md);
|
|
1495
|
+
width: max-content;
|
|
1496
|
+
min-width: 60px;
|
|
1497
|
+
max-width: var(--fx-tooltip-max-width, 320px);
|
|
1498
|
+
white-space: normal;
|
|
1499
|
+
text-align: center;
|
|
1500
|
+
opacity: 0;
|
|
1501
|
+
visibility: hidden;
|
|
1502
|
+
transition: opacity var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
1503
|
+
z-index: var(--fx-z-tooltip, 1050);
|
|
1504
|
+
pointer-events: none;
|
|
1505
|
+
}
|
|
1506
|
+
:host(:hover) .bubble,
|
|
1507
|
+
:host(:focus-within) .bubble {
|
|
1508
|
+
opacity: 1;
|
|
1509
|
+
visibility: visible;
|
|
1510
|
+
}
|
|
1511
|
+
/* position top (padrão) */
|
|
1512
|
+
.bubble { bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); }
|
|
1513
|
+
.bubble::after {
|
|
1514
|
+
content: '';
|
|
1515
|
+
position: absolute;
|
|
1516
|
+
top: 100%;
|
|
1517
|
+
left: 50%;
|
|
1518
|
+
transform: translateX(-50%);
|
|
1519
|
+
border: 5px solid transparent;
|
|
1520
|
+
border-top-color: var(--fx-text-default, #1e293b);
|
|
1521
|
+
}
|
|
1522
|
+
/* bottom */
|
|
1523
|
+
:host([position='bottom']) .bubble { bottom: auto; top: calc(100% + 6px); }
|
|
1524
|
+
:host([position='bottom']) .bubble::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--fx-text-default, #1e293b); }
|
|
1525
|
+
/* left */
|
|
1526
|
+
:host([position='left']) .bubble {
|
|
1527
|
+
right: calc(100% + 6px); left: auto; top: 50%; bottom: auto; transform: translateY(-50%);
|
|
1528
|
+
}
|
|
1529
|
+
:host([position='left']) .bubble::after {
|
|
1530
|
+
top: 50%; left: 100%; transform: translateY(-50%);
|
|
1531
|
+
border: 5px solid transparent; border-left-color: var(--fx-text-default, #1e293b);
|
|
1532
|
+
}
|
|
1533
|
+
/* right */
|
|
1534
|
+
:host([position='right']) .bubble {
|
|
1535
|
+
right: auto; left: calc(100% + 6px); top: 50%; bottom: auto; transform: translateY(-50%);
|
|
1536
|
+
}
|
|
1537
|
+
:host([position='right']) .bubble::after {
|
|
1538
|
+
top: 50%; left: auto; right: 100%; transform: translateY(-50%);
|
|
1539
|
+
border: 5px solid transparent; border-right-color: var(--fx-text-default, #1e293b);
|
|
1540
|
+
}
|
|
1541
|
+
`;let K=vt;function re(){return v("fx-tooltip",K)}re();const gt=class gt extends x{static get observedAttributes(){return["value"]}get value(){return this.getAttr("value")}set value(t){this.setAttribute("value",t)}render(){var r;const t=Array.from(this.querySelectorAll("fx-tab")),e=this.value||((r=t[0])==null?void 0:r.getAttribute("tab"))||"";this.setTemplate(`
|
|
1542
|
+
<div class="list" role="tablist">
|
|
1543
|
+
${t.map(s=>{var l,i;const o=(l=s.getAttribute("tab"))!=null?l:"",a=s.hasAttribute("disabled");return`<button type="button" class="tab" role="tab" part="tab"
|
|
1544
|
+
data-tab="${o}" aria-selected="${o===e}"
|
|
1545
|
+
${a?'aria-disabled="true" data-disabled="true"':""}>${(i=s.textContent)==null?void 0:i.trim()}</button>`}).join("")}
|
|
1546
|
+
</div>
|
|
1547
|
+
<slot></slot>
|
|
1548
|
+
`),this.panels.forEach(s=>{s.getAttribute("tab")===e?s.removeAttribute("hidden"):s.setAttribute("hidden","")}),this.root.querySelectorAll(".tab").forEach(s=>{s.addEventListener("click",()=>{var o;s.hasAttribute("data-disabled")||(this.value=(o=s.dataset.tab)!=null?o:"",this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{value:this.value}})))})})}get panels(){const t=Array.from(this.querySelectorAll("fx-tab-panel"));if(t.length)return t;const e=[];let r=this.nextElementSibling;for(;r&&!r.matches("fx-tabs");)r.matches("fx-tab-panel")?e.push(r):e.push(...Array.from(r.querySelectorAll(":scope > fx-tab-panel"))),r=r.nextElementSibling;return e}};gt.styles=p`
|
|
1549
|
+
:host {
|
|
1550
|
+
display: block;
|
|
1551
|
+
font-family: var(--fx-font-family);
|
|
1552
|
+
}
|
|
1553
|
+
.list {
|
|
1554
|
+
display: flex;
|
|
1555
|
+
gap: var(--fx-space-xs);
|
|
1556
|
+
border-bottom: 2px solid var(--fx-border-default);
|
|
1557
|
+
}
|
|
1558
|
+
.tab {
|
|
1559
|
+
border: none;
|
|
1560
|
+
background: transparent;
|
|
1561
|
+
font-family: inherit;
|
|
1562
|
+
font-size: var(--fx-font-size);
|
|
1563
|
+
color: var(--fx-text-muted);
|
|
1564
|
+
padding: var(--fx-space-md) var(--fx-space-lg);
|
|
1565
|
+
cursor: pointer;
|
|
1566
|
+
position: relative;
|
|
1567
|
+
transition: color var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
1568
|
+
}
|
|
1569
|
+
.tab::after {
|
|
1570
|
+
content: '';
|
|
1571
|
+
position: absolute;
|
|
1572
|
+
left: 0; right: 0; bottom: -2px;
|
|
1573
|
+
height: 2px;
|
|
1574
|
+
background: transparent;
|
|
1575
|
+
transition: background var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
1576
|
+
}
|
|
1577
|
+
.tab:hover { color: var(--fx-text-default); }
|
|
1578
|
+
.tab[data-disabled] {
|
|
1579
|
+
color: var(--fx-border-default);
|
|
1580
|
+
cursor: not-allowed;
|
|
1581
|
+
opacity: 0.6;
|
|
1582
|
+
}
|
|
1583
|
+
.tab[data-disabled]:hover { color: var(--fx-border-default); }
|
|
1584
|
+
.tab[aria-selected='true'] {
|
|
1585
|
+
color: var(--fx-color-primary);
|
|
1586
|
+
font-weight: 600;
|
|
1587
|
+
}
|
|
1588
|
+
.tab[aria-selected='true']::after { background: var(--fx-color-primary); }
|
|
1589
|
+
.tab:focus-visible {
|
|
1590
|
+
outline: none;
|
|
1591
|
+
box-shadow: var(--fx-effect-focus-ring, none);
|
|
1592
|
+
border-radius: var(--fx-radius-sm);
|
|
1593
|
+
}
|
|
1594
|
+
/* Os <fx-tab> originais são renderizados como botões no shadow DOM.
|
|
1595
|
+
Sem isto, o <slot> os projetaria de novo como texto cru abaixo das abas. */
|
|
1596
|
+
::slotted(fx-tab) {
|
|
1597
|
+
display: none !important;
|
|
1598
|
+
}
|
|
1599
|
+
`;let X=gt;const mt=class mt extends x{constructor(){super(...arguments),this._initialized=!1}static get observedAttributes(){return["tab"]}get tab(){return this.getAttr("tab")}get visible(){return!this.hasAttr("hidden")}set visible(t){this.toggleAttr("hidden",!t)}render(){var t;if(this.setTemplate("<slot></slot>"),!this._initialized){const e=(t=this.closest("fx-tabs"))!=null?t:(()=>{let s=this.previousElementSibling;for(;s;){if(s.matches("fx-tabs"))return s;s=s.previousElementSibling}return null})(),r=e&&e.getAttribute("value")||"";this.getAttribute("tab")!==r&&this.setAttribute("hidden",""),this._initialized=!0}}};mt.styles=p`
|
|
1600
|
+
:host { display: block; padding: var(--fx-space-lg) 0; font-family: var(--fx-font-family); color: var(--fx-text-default); }
|
|
1601
|
+
:host([hidden]) { display: none; }
|
|
1602
|
+
`;let F=mt;function se(){return v("fx-tabs",X)}function oe(){return v("fx-tab-panel",F)}se(),oe();const yt=class yt extends x{constructor(){super(...arguments),this._done=!1}static get observedAttributes(){return["value","indeterminate","variant","label","hide-label","size"]}get value(){return Number(this.getAttr("value","0"))||0}set value(t){this.setAttribute("value",String(Math.min(100,Math.max(0,t))))}render(){const t=Math.min(100,Math.max(0,this.value)),e=this.hasAttr("indeterminate"),r=this.getAttr("label"),s=!e&&!this.hasAttr("hide-label");this.setTemplate(`
|
|
1603
|
+
${r?`<div class="caption" part="caption">${r}</div>`:""}
|
|
1604
|
+
<div class="row">
|
|
1605
|
+
<div class="track" part="track" role="progressbar"
|
|
1606
|
+
aria-valuenow="${t}" aria-valuemin="0" aria-valuemax="100">
|
|
1607
|
+
<div class="bar" part="bar" style="width: ${e?"40%":`${t}%`}"></div>
|
|
1608
|
+
</div>
|
|
1609
|
+
${s?`<span class="pct">${t}%</span>`:""}
|
|
1610
|
+
</div>
|
|
1611
|
+
`),!this._done&&!this.hasAttr("indeterminate")&&t>=100&&(this._done=!0,this.dispatchEvent(new CustomEvent("complete",{bubbles:!0,composed:!0}))),t<100&&(this._done=!1)}};yt.styles=p`
|
|
1612
|
+
:host {
|
|
1613
|
+
display: block;
|
|
1614
|
+
font-family: var(--fx-font-family);
|
|
1615
|
+
--_color: var(--fx-color-primary);
|
|
1616
|
+
}
|
|
1617
|
+
:host([variant='success']) { --_color: var(--fx-color-success); }
|
|
1618
|
+
:host([variant='warning']) { --_color: var(--fx-color-warning); }
|
|
1619
|
+
:host([variant='danger']) { --_color: var(--fx-color-danger); }
|
|
1620
|
+
.row {
|
|
1621
|
+
display: flex;
|
|
1622
|
+
align-items: center;
|
|
1623
|
+
gap: var(--fx-space-md);
|
|
1624
|
+
}
|
|
1625
|
+
.track {
|
|
1626
|
+
flex: 1;
|
|
1627
|
+
height: 8px;
|
|
1628
|
+
background: var(--fx-surface-surface-hover);
|
|
1629
|
+
border-radius: var(--fx-radius-full);
|
|
1630
|
+
overflow: hidden;
|
|
1631
|
+
}
|
|
1632
|
+
:host([size='sm']) .track { height: 4px; }
|
|
1633
|
+
:host([size='lg']) .track { height: 12px; }
|
|
1634
|
+
.bar {
|
|
1635
|
+
height: 100%;
|
|
1636
|
+
width: 0%;
|
|
1637
|
+
background: var(--_color);
|
|
1638
|
+
border-radius: var(--fx-radius-full);
|
|
1639
|
+
transition: width var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
1640
|
+
}
|
|
1641
|
+
:host([indeterminate]) .bar {
|
|
1642
|
+
width: 40%;
|
|
1643
|
+
animation: slide 1.2s ease-in-out infinite;
|
|
1644
|
+
}
|
|
1645
|
+
@keyframes slide {
|
|
1646
|
+
from { transform: translateX(-100%); }
|
|
1647
|
+
to { transform: translateX(350%); }
|
|
1648
|
+
}
|
|
1649
|
+
.pct {
|
|
1650
|
+
font-size: calc(var(--fx-font-size) - 2px);
|
|
1651
|
+
color: var(--fx-text-default);
|
|
1652
|
+
font-weight: 600;
|
|
1653
|
+
min-width: 34px;
|
|
1654
|
+
text-align: right;
|
|
1655
|
+
}
|
|
1656
|
+
.caption {
|
|
1657
|
+
font-size: calc(var(--fx-font-size) - 2px);
|
|
1658
|
+
color: var(--fx-text-muted);
|
|
1659
|
+
margin-bottom: var(--fx-space-xs);
|
|
1660
|
+
}
|
|
1661
|
+
`;let O=yt;function ae(){return v("fx-progress",O)}ae();const wt=class wt extends x{static get observedAttributes(){return["variant","width","height","lines"]}render(){const t=this.getAttr("variant","text"),e=this.getAttr("width"),r=this.getAttr("height"),s=`${e?`width:${e};`:""}${r?`height:${r};`:""}`;if(t==="circle"){const a=r||e||"40px",l=s.includes("height")?s:`width:${a};height:${a};`;this.setTemplate(`<div class="bone circle" part="bone" style="${l}"></div>`);return}if(t==="rect"){const a=s||"width:100%;height:80px;";this.setTemplate(`<div class="bone" part="bone" style="${a}"></div>`);return}const o=Number(this.getAttr("lines","3"))||3;this.setTemplate(`
|
|
1662
|
+
${Array.from({length:o},()=>'<div class="bone text"></div>').join("")}
|
|
1663
|
+
`)}};wt.styles=p`
|
|
1664
|
+
:host { display: block; width: 100%; min-width: 80px; font-family: var(--fx-font-family); }
|
|
1665
|
+
.bone {
|
|
1666
|
+
background: linear-gradient(
|
|
1667
|
+
90deg,
|
|
1668
|
+
var(--fx-surface-surface-hover) 25%,
|
|
1669
|
+
color-mix(in srgb, var(--fx-surface-surface-hover) 55%, var(--fx-surface-background)) 50%,
|
|
1670
|
+
var(--fx-surface-surface-hover) 75%
|
|
1671
|
+
);
|
|
1672
|
+
background-size: 200% 100%;
|
|
1673
|
+
animation: shimmer 1.4s ease-in-out infinite;
|
|
1674
|
+
border-radius: var(--fx-radius-sm);
|
|
1675
|
+
}
|
|
1676
|
+
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
|
|
1677
|
+
.bone[hidden] { display: none; }
|
|
1678
|
+
.text { height: 12px; width: 100%; margin-bottom: var(--fx-space-sm); }
|
|
1679
|
+
.text:last-of-type { width: 60%; margin-bottom: 0; }
|
|
1680
|
+
.circle { border-radius: var(--fx-radius-full); }
|
|
1681
|
+
`;let J=wt;function ie(){return v("fx-skeleton",J)}ie();const kt=class kt extends x{static get observedAttributes(){return["variant","title","dismissible"]}render(){var s,o;const t=this.getAttr("variant","info"),e=this.getAttr("title"),r={info:"ℹ",success:"✓",warning:"⚠",danger:"✕"};this.setTemplate(`
|
|
1682
|
+
<div class="alert" part="alert" role="alert">
|
|
1683
|
+
<span class="icon">${(s=r[t])!=null?s:"ℹ"}</span>
|
|
1684
|
+
<div class="content">
|
|
1685
|
+
${e?`<div class="title">${e}</div>`:""}
|
|
1686
|
+
<div class="body"><slot></slot></div>
|
|
1687
|
+
</div>
|
|
1688
|
+
${this.hasAttr("dismissible")?'<button type="button" class="close" aria-label="Fechar">×</button>':""}
|
|
1689
|
+
</div>
|
|
1690
|
+
`),(o=this.root.querySelector(".close"))==null||o.addEventListener("click",()=>{this.hidden=!0,this.dispatchEvent(new CustomEvent("dismiss",{bubbles:!0,composed:!0}))})}};kt.styles=p`
|
|
1691
|
+
:host {
|
|
1692
|
+
display: block;
|
|
1693
|
+
font-family: var(--fx-font-family);
|
|
1694
|
+
--_color: var(--fx-color-primary);
|
|
1695
|
+
--_bg: color-mix(in srgb, var(--fx-color-primary) 10%, var(--fx-surface-background));
|
|
1696
|
+
}
|
|
1697
|
+
:host([variant='success']) { --_color: var(--fx-color-success); --_bg: color-mix(in srgb, var(--fx-color-success) 10%, var(--fx-surface-background)); }
|
|
1698
|
+
:host([variant='warning']) { --_color: var(--fx-color-warning); --_bg: color-mix(in srgb, var(--fx-color-warning) 12%, var(--fx-surface-background)); }
|
|
1699
|
+
:host([variant='danger']) { --_color: var(--fx-color-danger); --_bg: color-mix(in srgb, var(--fx-color-danger) 10%, var(--fx-surface-background)); }
|
|
1700
|
+
.alert {
|
|
1701
|
+
display: flex;
|
|
1702
|
+
align-items: flex-start;
|
|
1703
|
+
gap: var(--fx-space-md);
|
|
1704
|
+
background: var(--_bg);
|
|
1705
|
+
border: 1px solid color-mix(in srgb, var(--_color) 30%, transparent);
|
|
1706
|
+
border-radius: var(--fx-radius-md);
|
|
1707
|
+
padding: var(--fx-space-md) var(--fx-space-lg);
|
|
1708
|
+
font-size: var(--fx-font-size);
|
|
1709
|
+
color: var(--fx-text-default);
|
|
1710
|
+
}
|
|
1711
|
+
:host([hidden]) { display: none; }
|
|
1712
|
+
.icon { color: var(--_color); font-weight: bold; line-height: 1.4; }
|
|
1713
|
+
.content { flex: 1; }
|
|
1714
|
+
.title { font-weight: 600; }
|
|
1715
|
+
.body { margin-top: 2px; }
|
|
1716
|
+
.close {
|
|
1717
|
+
border: none; background: transparent; cursor: pointer;
|
|
1718
|
+
color: var(--fx-text-muted); font-size: calc(var(--fx-font-size) + 2px);
|
|
1719
|
+
line-height: 1; padding: 0; border-radius: var(--fx-radius-full);
|
|
1720
|
+
}
|
|
1721
|
+
.close:hover { color: var(--_color); }
|
|
1722
|
+
`;let U=kt;function ne(){return v("fx-alert",U)}ne();const At=class At extends x{static get observedAttributes(){return["label","position","open"]}get open(){return this.hasAttr("open")}set open(t){this.toggleAttr("open",t)}render(){const t=this.getAttr("label","Ações"),e=Array.from(this.querySelectorAll("fx-dropdown-item"));this.setTemplate(`
|
|
1723
|
+
<span class="trigger" role="button" tabindex="0" part="trigger"
|
|
1724
|
+
aria-haspopup="menu" aria-expanded="${this.open}">
|
|
1725
|
+
${t} ▾
|
|
1726
|
+
</span>
|
|
1727
|
+
<div class="panel" role="menu" part="panel">
|
|
1728
|
+
${e.length?e.map(s=>{var o;return`<div class="item-slot"><slot name="_${(o=s.getAttribute("value"))!=null?o:""}"></slot></div>`}):'<div class="empty">Nenhuma ação</div>'}
|
|
1729
|
+
<slot></slot>
|
|
1730
|
+
</div>
|
|
1731
|
+
`);const r=this.root.querySelector(".trigger");r==null||r.addEventListener("click",s=>{s.stopPropagation(),document.querySelectorAll("fx-dropdown[open]").forEach(o=>{o!==this&&(o.open=!1)}),this.open=!this.open}),r==null||r.addEventListener("keydown",s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),this.open=!this.open)}),e.forEach(s=>{s.addEventListener("click",()=>{var o;this.open=!1,this.dispatchEvent(new CustomEvent("select",{bubbles:!0,composed:!0,detail:{value:(o=s.getAttribute("value"))!=null?o:""}}))})})}};At.styles=p`
|
|
1732
|
+
:host {
|
|
1733
|
+
position: relative;
|
|
1734
|
+
display: inline-block;
|
|
1735
|
+
font-family: var(--fx-font-family);
|
|
1736
|
+
font-size: var(--fx-font-size);
|
|
1737
|
+
}
|
|
1738
|
+
.trigger { min-height: var(--fx-size-md); }
|
|
1739
|
+
.panel {
|
|
1740
|
+
position: absolute;
|
|
1741
|
+
top: calc(100% + 4px);
|
|
1742
|
+
min-width: 180px;
|
|
1743
|
+
background: var(--fx-surface-background);
|
|
1744
|
+
border: 1px solid var(--fx-border-default);
|
|
1745
|
+
border-radius: var(--fx-radius-md);
|
|
1746
|
+
box-shadow: var(--fx-shadow-lg);
|
|
1747
|
+
padding: var(--fx-space-xs);
|
|
1748
|
+
z-index: var(--fx-z-dropdown, 1000);
|
|
1749
|
+
display: none;
|
|
1750
|
+
}
|
|
1751
|
+
:host([open]) .panel { display: block; }
|
|
1752
|
+
/* left = alinhado à esquerda do trigger; right = à direita; center = centrado */
|
|
1753
|
+
:host([position='left']) .panel,
|
|
1754
|
+
:host([position='bottom-left']) .panel { left: 0; right: auto; }
|
|
1755
|
+
:host([position='center']) .panel {
|
|
1756
|
+
left: 50%;
|
|
1757
|
+
transform: translateX(-50%);
|
|
1758
|
+
}
|
|
1759
|
+
:host([position='right']) .panel,
|
|
1760
|
+
:host([position='bottom-right']) .panel { right: 0; left: auto; }
|
|
1761
|
+
:host(:not([position])) .panel { left: 0; right: auto; }
|
|
1762
|
+
::slotted(fx-dropdown-item) { display: block; }
|
|
1763
|
+
.empty { color: var(--fx-text-muted); font-size: calc(var(--fx-font-size) - 2px); padding: var(--fx-space-sm); }
|
|
1764
|
+
`;let W=At;const zt=class zt extends x{static get observedAttributes(){return["value"]}get value(){return this.getAttr("value")}set value(t){this.setAttribute("value",t)}render(){this.setTemplate('<button type="button" class="item" part="item" role="menuitem"><slot></slot></button>')}};zt.styles=p`
|
|
1765
|
+
:host {
|
|
1766
|
+
display: block;
|
|
1767
|
+
font-family: var(--fx-font-family);
|
|
1768
|
+
font-size: var(--fx-font-size);
|
|
1769
|
+
}
|
|
1770
|
+
.item {
|
|
1771
|
+
display: block;
|
|
1772
|
+
width: 100%;
|
|
1773
|
+
text-align: left;
|
|
1774
|
+
border: none;
|
|
1775
|
+
background: transparent;
|
|
1776
|
+
font-family: inherit;
|
|
1777
|
+
font-size: inherit;
|
|
1778
|
+
color: var(--fx-text-default);
|
|
1779
|
+
padding: var(--fx-space-sm) var(--fx-space-md);
|
|
1780
|
+
cursor: pointer;
|
|
1781
|
+
border-radius: var(--fx-radius-sm);
|
|
1782
|
+
transition: background var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
1783
|
+
}
|
|
1784
|
+
.item:hover { background: color-mix(in srgb, var(--fx-color-primary) 12%, var(--fx-surface-background)); color: var(--fx-color-primary); }
|
|
1785
|
+
`;let G=zt;function le(){return v("fx-dropdown",W)}function de(){return v("fx-dropdown-item",G)}le(),de();const $t=class $t extends x{constructor(){super(...arguments),this._onKeydown=()=>{}}static get observedAttributes(){return["open","title","position"]}get open(){return this.hasAttr("open")}set open(t){this.toggleAttr("open",t)}get title(){return this.getAttr("title")}set title(t){this.setAttribute("title",t)}get position(){const t=this.getAttr("position");return["left","right","top","bottom"].includes(t)?t:"right"}set position(t){this.setAttribute("position",t)}render(){var r,s;const t=this.getAttr("title");this.setTemplate(`
|
|
1786
|
+
<div class="overlay" part="overlay"></div>
|
|
1787
|
+
<div class="panel" part="panel" role="dialog" aria-modal="true" aria-label="${t||"Drawer"}">
|
|
1788
|
+
${t!==""?`<div class="header" part="header"><span class="title">${t}</span><button type="button" class="close" part="close" aria-label="Fechar">✕</button></div>`:""}
|
|
1789
|
+
<div class="body" part="body"><slot></slot></div>
|
|
1790
|
+
</div>
|
|
1791
|
+
`);const e=()=>{this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0})))};(r=this.root.querySelector(".overlay"))==null||r.addEventListener("click",e),(s=this.root.querySelector(".close"))==null||s.addEventListener("click",e)}connectedCallback(){var t;(t=super.connectedCallback)==null||t.call(this),this._onKeydown=e=>{e.key==="Escape"&&this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0})))},document.addEventListener("keydown",this._onKeydown)}disconnectedCallback(){var t;document.removeEventListener("keydown",this._onKeydown),(t=super.disconnectedCallback)==null||t.call(this)}};$t.styles=p`
|
|
1792
|
+
:host {
|
|
1793
|
+
display: contents;
|
|
1794
|
+
font-family: var(--fx-font-family);
|
|
1795
|
+
font-size: var(--fx-font-size);
|
|
1796
|
+
color: var(--fx-text-default);
|
|
1797
|
+
}
|
|
1798
|
+
.overlay {
|
|
1799
|
+
display: none;
|
|
1800
|
+
position: fixed;
|
|
1801
|
+
inset: 0;
|
|
1802
|
+
background: color-mix(
|
|
1803
|
+
in srgb,
|
|
1804
|
+
var(--fx-text-default, #000) 45%,
|
|
1805
|
+
transparent
|
|
1806
|
+
);
|
|
1807
|
+
backdrop-filter: blur(3px);
|
|
1808
|
+
-webkit-backdrop-filter: blur(3px);
|
|
1809
|
+
z-index: var(--fx-z-overlay, 1090);
|
|
1810
|
+
animation: fade var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
1811
|
+
}
|
|
1812
|
+
:host([open]) .overlay {
|
|
1813
|
+
display: block;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
.panel {
|
|
1817
|
+
position: fixed;
|
|
1818
|
+
background: var(--fx-surface-background);
|
|
1819
|
+
box-shadow: var(--fx-shadow-xl);
|
|
1820
|
+
z-index: var(--fx-z-modal, 1000);
|
|
1821
|
+
display: flex;
|
|
1822
|
+
flex-direction: column;
|
|
1823
|
+
overflow: auto;
|
|
1824
|
+
}
|
|
1825
|
+
:host(:not([open])) .panel {
|
|
1826
|
+
display: none;
|
|
1827
|
+
}
|
|
1828
|
+
:host([open]) .panel {
|
|
1829
|
+
display: flex;
|
|
1830
|
+
}
|
|
1831
|
+
/* left / right — altura total, largura mínima fixa e expansível */
|
|
1832
|
+
:host([position="left"]) .panel,
|
|
1833
|
+
:host(:not([position])) .panel,
|
|
1834
|
+
:host([position="right"]) .panel {
|
|
1835
|
+
top: 0;
|
|
1836
|
+
bottom: 0;
|
|
1837
|
+
width: var(--fx-drawer-width, 360px);
|
|
1838
|
+
min-width: 300px;
|
|
1839
|
+
max-width: 90vw;
|
|
1840
|
+
}
|
|
1841
|
+
:host([position="left"]) .panel {
|
|
1842
|
+
left: 0;
|
|
1843
|
+
}
|
|
1844
|
+
:host([position="right"]) .panel,
|
|
1845
|
+
:host(:not([position])) .panel {
|
|
1846
|
+
right: 0;
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
/* top / bottom — largura total, altura mínima fixa e expansível */
|
|
1850
|
+
:host([position="top"]) .panel,
|
|
1851
|
+
:host([position="bottom"]) .panel {
|
|
1852
|
+
left: 0;
|
|
1853
|
+
right: 0;
|
|
1854
|
+
height: var(--fx-drawer-height, 280px);
|
|
1855
|
+
min-height: 180px;
|
|
1856
|
+
max-height: 85vh;
|
|
1857
|
+
}
|
|
1858
|
+
:host([position="top"]) .panel {
|
|
1859
|
+
top: 0;
|
|
1860
|
+
}
|
|
1861
|
+
:host([position="bottom"]) .panel {
|
|
1862
|
+
bottom: 0;
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
.header {
|
|
1866
|
+
display: flex;
|
|
1867
|
+
align-items: center;
|
|
1868
|
+
gap: var(--fx-space-sm);
|
|
1869
|
+
min-height: var(--fx-size-lg);
|
|
1870
|
+
padding: var(--fx-space-sm) var(--fx-space-md);
|
|
1871
|
+
border-bottom: 1px solid var(--fx-border-default);
|
|
1872
|
+
flex: none;
|
|
1873
|
+
position: sticky;
|
|
1874
|
+
top: 0;
|
|
1875
|
+
background: var(--fx-surface-background);
|
|
1876
|
+
}
|
|
1877
|
+
.title {
|
|
1878
|
+
font-weight: 700;
|
|
1879
|
+
flex: 1;
|
|
1880
|
+
overflow: hidden;
|
|
1881
|
+
text-overflow: ellipsis;
|
|
1882
|
+
white-space: nowrap;
|
|
1883
|
+
}
|
|
1884
|
+
.close {
|
|
1885
|
+
border: none;
|
|
1886
|
+
background: transparent;
|
|
1887
|
+
cursor: pointer;
|
|
1888
|
+
color: var(--fx-text-muted);
|
|
1889
|
+
width: 28px;
|
|
1890
|
+
height: 28px;
|
|
1891
|
+
line-height: 1;
|
|
1892
|
+
border-radius: var(--fx-radius-sm);
|
|
1893
|
+
font-size: 16px;
|
|
1894
|
+
transition: background var(--fx-motion-duration-fast)
|
|
1895
|
+
var(--fx-motion-easing);
|
|
1896
|
+
}
|
|
1897
|
+
.close:hover {
|
|
1898
|
+
background: color-mix(
|
|
1899
|
+
in srgb,
|
|
1900
|
+
var(--fx-color-danger) 14%,
|
|
1901
|
+
var(--fx-surface-background)
|
|
1902
|
+
);
|
|
1903
|
+
color: var(--fx-color-danger);
|
|
1904
|
+
}
|
|
1905
|
+
.body {
|
|
1906
|
+
padding: var(--fx-space-md);
|
|
1907
|
+
flex: 1;
|
|
1908
|
+
}
|
|
1909
|
+
`;let Q=$t;function ce(){return v("fx-drawer",Q)}ce();const Et=class Et extends x{static get observedAttributes(){return["page","total","rows","rows-options","position"]}get page(){return Number(this.getAttr("page","1"))||1}set page(t){this.setAttribute("page",String(t))}get total(){return Number(this.getAttr("total","0"))||0}set total(t){this.setAttribute("total",String(t))}get rows(){return Number(this.getAttr("rows","10"))||10}set rows(t){this.setAttribute("rows",String(t))}get pages(){return Math.max(1,Math.ceil(this.total/this.rows))}render(){const t=this.pages,e=Math.min(Math.max(1,this.page),t),r=(this.getAttr("rows-options","5,10,20,50")||"").split(",").map(c=>c.trim()).filter(Boolean),s=[];for(let c=Math.max(1,e-2);c<=Math.min(t,e+2);c++)s.push(c);const o=l(e,this.rows),a=Math.min(e*this.rows,this.total);this.setTemplate(`
|
|
1910
|
+
<span class="info">${this.total?`${o}-${a} de ${this.total}`:"0 itens"}</span>
|
|
1911
|
+
<button type="button" class="nav" part="prev" data-go="${e-1}" ${e<=1?"disabled":""}>‹</button>
|
|
1912
|
+
${s[0]!==1&&t>5?'<button type="button" class="nav" data-go="1">1</button>':""}
|
|
1913
|
+
${s.map(c=>`<button type="button" class="nav ${c===e?"active":""}" data-go="${c}">${c}</button>`).join("")}
|
|
1914
|
+
${s[s.length-1]!==t&&t>5?`<button type="button" class="nav" data-go="${t}">${t}</button>`:""}
|
|
1915
|
+
<button type="button" class="nav" part="next" data-go="${e+1}" ${e>=t?"disabled":""}>›</button>
|
|
1916
|
+
${r.length?`
|
|
1917
|
+
<select class="nav" part="rows" aria-label="Itens por página">
|
|
1918
|
+
${r.map(c=>`<option value="${c}" ${Number(c)===this.rows?"selected":""}>${c}</option>`).join("")}
|
|
1919
|
+
</select>`:""}
|
|
1920
|
+
`);function l(c,h){return(c-1)*h+1}this.root.querySelectorAll(".nav[data-go]").forEach(c=>{c.addEventListener("click",()=>{const h=Number(c.dataset.go);h>=1&&h<=t&&h!==e&&(this.page=h,this.emit())})});const i=this.root.querySelector("select.nav");i==null||i.addEventListener("change",()=>{this.rows=Number(i.value),this.page=1,this.emit()})}emit(){this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,composed:!0,detail:{page:this.page,rows:this.rows}}))}};Et.styles=p`
|
|
1921
|
+
:host {
|
|
1922
|
+
display: flex;
|
|
1923
|
+
align-items: center;
|
|
1924
|
+
gap: var(--fx-space-sm);
|
|
1925
|
+
font-family: var(--fx-font-family);
|
|
1926
|
+
font-size: var(--fx-font-size);
|
|
1927
|
+
color: var(--fx-text-default);
|
|
1928
|
+
}
|
|
1929
|
+
:host([position='center']) { justify-content: center; }
|
|
1930
|
+
:host([position='right']) { justify-content: flex-end; }
|
|
1931
|
+
.nav {
|
|
1932
|
+
min-width: var(--fx-size-sm);
|
|
1933
|
+
height: var(--fx-size-sm);
|
|
1934
|
+
border: 1px solid var(--fx-border-default);
|
|
1935
|
+
background: var(--fx-surface-background);
|
|
1936
|
+
color: var(--fx-text-default);
|
|
1937
|
+
font-family: inherit;
|
|
1938
|
+
font-size: calc(var(--fx-font-size) - 2px);
|
|
1939
|
+
border-radius: var(--fx-radius-sm);
|
|
1940
|
+
cursor: pointer;
|
|
1941
|
+
padding: 0 var(--fx-space-sm);
|
|
1942
|
+
transition:
|
|
1943
|
+
border-color var(--fx-motion-duration-fast) var(--fx-motion-easing),
|
|
1944
|
+
background var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
1945
|
+
}
|
|
1946
|
+
.nav:hover:not([disabled]) { border-color: var(--fx-color-primary); color: var(--fx-color-primary); }
|
|
1947
|
+
.nav[disabled] { opacity: 0.5; cursor: not-allowed; }
|
|
1948
|
+
.nav.active {
|
|
1949
|
+
background: var(--fx-color-primary);
|
|
1950
|
+
border-color: var(--fx-color-primary);
|
|
1951
|
+
color: #fff;
|
|
1952
|
+
font-weight: 600;
|
|
1953
|
+
}
|
|
1954
|
+
.info { color: var(--fx-text-muted); font-size: calc(var(--fx-font-size) - 2px); }
|
|
1955
|
+
select.nav { cursor: pointer; }
|
|
1956
|
+
`;let Z=Et;function fe(){return v("fx-pagination",Z)}fe();const St=class St extends x{static get observedAttributes(){return["size","placeholder","source","disabled","min-chars"]}get size(){const t=this.getAttr("size","md");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get value(){return this.getAttr("value")}set value(t){this.setAttribute("value",t)}get source(){try{const t=JSON.parse(this.getAttr("source","[]"));return Array.isArray(t)?t.map(String):[]}catch(t){return[]}}render(){const t=this.getAttr("placeholder");this.setTemplate(`
|
|
1957
|
+
<input class="field" part="input" type="text"
|
|
1958
|
+
${t?`placeholder="${t}"`:""} autocomplete="off"/>
|
|
1959
|
+
<div class="list" part="list" role="listbox"></div>
|
|
1960
|
+
`);const e=this.root.querySelector(".field");if(!e)return;e.value=this.value,this.hasAttr("disabled")&&e.setAttribute("disabled","");const r=this.root.querySelector(".list"),s=Number(this.getAttr("min-chars","1"))||1,o=()=>{if(!r)return;const a=e.value.toLowerCase(),l=this.source.filter(i=>i.toLowerCase().includes(a)).slice(0,8);r.innerHTML=l.length?l.map(i=>`<button type="button" class="opt" role="option" data-v="${i}">${i}</button>`).join(""):'<div class="empty">Nenhum resultado</div>',r.querySelectorAll(".opt").forEach(i=>{i.addEventListener("click",()=>{var c;e.value=(c=i.dataset.v)!=null?c:"",this.value=e.value,this.toggleAttr("open",!1),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,composed:!0,detail:{value:this.value}}))})}),this.toggleAttr("open",!0)};e.addEventListener("input",()=>{this.value=e.value,o()}),e.addEventListener("focus",()=>{e.value.length>=s&&o()}),document.addEventListener("click",a=>{this.contains(a.target)||this.toggleAttr("open",!1)})}};St.styles=p`
|
|
1961
|
+
:host {
|
|
1962
|
+
position: relative;
|
|
1963
|
+
display: inline-block;
|
|
1964
|
+
font-family: var(--fx-font-family);
|
|
1965
|
+
font-size: var(--fx-font-size);
|
|
1966
|
+
}
|
|
1967
|
+
input {
|
|
1968
|
+
font-family: inherit;
|
|
1969
|
+
font-size: inherit;
|
|
1970
|
+
font-weight: var(--fx-font-weight);
|
|
1971
|
+
color: var(--fx-text-default);
|
|
1972
|
+
background-color: var(--fx-surface-background);
|
|
1973
|
+
border: 1px solid var(--fx-border-default);
|
|
1974
|
+
border-radius: var(--fx-radius-md);
|
|
1975
|
+
padding: var(--fx-space-md) var(--fx-space-lg);
|
|
1976
|
+
width: 260px;
|
|
1977
|
+
min-height: var(--fx-size-md);
|
|
1978
|
+
box-sizing: border-box;
|
|
1979
|
+
transition:
|
|
1980
|
+
border-color var(--fx-motion-duration-normal) var(--fx-motion-easing),
|
|
1981
|
+
box-shadow var(--fx-motion-duration-normal) var(--fx-motion-easing);
|
|
1982
|
+
}
|
|
1983
|
+
input::placeholder { color: var(--fx-text-muted); opacity: 1; }
|
|
1984
|
+
input:hover { border-color: var(--fx-border-hover); }
|
|
1985
|
+
input:focus-visible {
|
|
1986
|
+
outline: none;
|
|
1987
|
+
border-color: var(--fx-color-primary);
|
|
1988
|
+
box-shadow: var(--fx-effect-focus-ring, none);
|
|
1989
|
+
}
|
|
1990
|
+
:host([size='sm']) input { width: 220px; min-height: var(--fx-size-sm); padding: var(--fx-space-sm) var(--fx-space-md); }
|
|
1991
|
+
:host([size='lg']) input { width: 300px; min-height: var(--fx-size-lg); }
|
|
1992
|
+
.list {
|
|
1993
|
+
position: absolute;
|
|
1994
|
+
top: calc(100% + 4px);
|
|
1995
|
+
left: 0;
|
|
1996
|
+
right: 0;
|
|
1997
|
+
background: var(--fx-surface-background);
|
|
1998
|
+
border: 1px solid var(--fx-border-default);
|
|
1999
|
+
border-radius: var(--fx-radius-md);
|
|
2000
|
+
box-shadow: var(--fx-shadow-lg);
|
|
2001
|
+
z-index: var(--fx-z-dropdown, 1000);
|
|
2002
|
+
max-height: 220px;
|
|
2003
|
+
overflow-y: auto;
|
|
2004
|
+
display: none;
|
|
2005
|
+
}
|
|
2006
|
+
:host([open]) .list { display: block; }
|
|
2007
|
+
.opt {
|
|
2008
|
+
display: block;
|
|
2009
|
+
width: 100%;
|
|
2010
|
+
text-align: left;
|
|
2011
|
+
border: none;
|
|
2012
|
+
background: transparent;
|
|
2013
|
+
font-family: inherit;
|
|
2014
|
+
font-size: inherit;
|
|
2015
|
+
color: var(--fx-text-default);
|
|
2016
|
+
padding: var(--fx-space-sm) var(--fx-space-md);
|
|
2017
|
+
cursor: pointer;
|
|
2018
|
+
transition: background var(--fx-motion-duration-fast) var(--fx-motion-easing);
|
|
2019
|
+
}
|
|
2020
|
+
.opt:hover { background: color-mix(in srgb, var(--fx-color-primary) 12%, var(--fx-surface-background)); color: var(--fx-color-primary); }
|
|
2021
|
+
.empty { color: var(--fx-text-muted); font-size: calc(var(--fx-font-size) - 2px); padding: var(--fx-space-sm) var(--fx-space-md); }
|
|
2022
|
+
`;let tt=St;function he(){return v("fx-autocomplete",tt)}he()});
|