@cas-smartdesign/token-selector 1.0.4 → 1.0.5
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/dist/docs/button.mjs
CHANGED
|
@@ -72,8 +72,9 @@ const r=class s extends HTMLElement{memoizedTemplate(){const t=this.is();if(s.TE
|
|
|
72
72
|
outline: 1px dashed #111;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
:
|
|
76
|
-
|
|
75
|
+
.icon:not([src]),
|
|
76
|
+
.icon[src=""],
|
|
77
|
+
.icon[src="data:,"] {
|
|
77
78
|
display: none;
|
|
78
79
|
}
|
|
79
80
|
|
|
@@ -96,8 +97,10 @@ const r=class s extends HTMLElement{memoizedTemplate(){const t=this.is();if(s.TE
|
|
|
96
97
|
max-width: var(--sd-button-max-icon-size, 32px);
|
|
97
98
|
}
|
|
98
99
|
</style>
|
|
99
|
-
<
|
|
100
|
+
<slot name="icon">
|
|
101
|
+
<img class="icon" src="data:," alt part="icon" />
|
|
102
|
+
</slot>
|
|
100
103
|
<div class="content">
|
|
101
104
|
<slot></slot>
|
|
102
105
|
</div>
|
|
103
|
-
`,
|
|
106
|
+
`,n=class o extends d{constructor(){super(),this._isSpaceOrEnterKeyDown=!1,this.addEventListener("keydown",t=>{this.isSpaceOrEnter(t)&&(this._isSpaceOrEnterKeyDown=!0,t.preventDefault())}),this.addEventListener("keyup",t=>{this.isSpaceOrEnter(t)&&this._isSpaceOrEnterKeyDown==!0&&(this._isSpaceOrEnterKeyDown=!1,this.click())}),this.addEventListener("click",t=>{if(this.disabled||this.hasAttribute("disabled")){t.stopImmediatePropagation();return}const e=this.getAttribute("type")?.toLowerCase()?.trim();if(e!=="submit"&&e!=="reset")return;const i=this.closest("form");i&&e==="submit"&&i.requestSubmit(),i&&e==="reset"&&i.reset()},{capture:!0})}get imageElement(){return this._image}get icon(){return this.getAttribute("icon")}set icon(t){this.icon!==t&&(t?this.setAttribute("icon",t):this.removeAttribute("icon"),this.updateIcon())}get primary(){return this.hasAttribute("primary")}set primary(t){t?this.setAttribute("primary",""):this.removeAttribute("primary")}get disabled(){return this.getAttribute("aria-disabled")=="true"}set disabled(t){this.setAttribute("aria-disabled",t.toString())}static get observedAttributes(){return["icon"]}is(){return o.ID}template(){const t=document.createElement("template");return t.innerHTML=c,t}isSpaceOrEnter(t){switch(t.key){case" ":case"Space":case"Enter":return!0;default:return!1}}click(){!this.disabled&&!this.hasAttribute("disabled")&&super.click()}connectedCallback(){super.connectedCallback(),this.hasAttribute("tabIndex")||(this.tabIndex=0),this._image=this.shadowRoot.querySelector(".icon"),this.updateIcon(),this.hasAttribute("role")||this.setAttribute("role","button")}attributeChangedCallback(){this.updateIcon()}updateIcon(){if(this._image){const t=this.getAttribute("icon");t&&(this._image.src=t)}}};n.ID="sd-button";let a=n;customElements.get(a.ID)||customElements.define(a.ID,a);
|