🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@spectrum-web-components/button

Package Overview
Dependencies
Maintainers
7
Versions
395
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spectrum-web-components/button - npm Package Compare versions

Comparing version

to
1.7.0-snapshot.20250519143559

21

package.json
{
"name": "@spectrum-web-components/button",
"version": "1.6.1-preview-2d9fabee.20250507183133",
"version": "1.7.0-snapshot.20250519143559",
"publishConfig": {

@@ -92,14 +92,11 @@ "access": "public"

"dependencies": {
"@spectrum-web-components/base": "1.6.1-preview-2d9fabee.20250507183133",
"@spectrum-web-components/clear-button": "1.6.1-preview-2d9fabee.20250507183133",
"@spectrum-web-components/close-button": "1.6.1-preview-2d9fabee.20250507183133",
"@spectrum-web-components/icon": "1.6.1-preview-2d9fabee.20250507183133",
"@spectrum-web-components/icons-ui": "1.6.1-preview-2d9fabee.20250507183133",
"@spectrum-web-components/progress-circle": "1.6.1-preview-2d9fabee.20250507183133",
"@spectrum-web-components/reactive-controllers": "1.6.1-preview-2d9fabee.20250507183133",
"@spectrum-web-components/shared": "1.6.1-preview-2d9fabee.20250507183133"
"@spectrum-web-components/base": "1.7.0-snapshot.20250519143559",
"@spectrum-web-components/clear-button": "1.7.0-snapshot.20250519143559",
"@spectrum-web-components/close-button": "1.7.0-snapshot.20250519143559",
"@spectrum-web-components/icon": "1.7.0-snapshot.20250519143559",
"@spectrum-web-components/icons-ui": "1.7.0-snapshot.20250519143559",
"@spectrum-web-components/progress-circle": "1.7.0-snapshot.20250519143559",
"@spectrum-web-components/reactive-controllers": "1.7.0-snapshot.20250519143559",
"@spectrum-web-components/shared": "1.7.0-snapshot.20250519143559"
},
"devDependencies": {
"@spectrum-css/button": "14.1.6"
},
"types": "./src/index.d.ts",

@@ -106,0 +103,0 @@ "customElements": "custom-elements.json",

@@ -64,3 +64,3 @@ "use strict";

}
if (this.shouldProxyClick()) {
if (this.shouldProxyClick(event)) {
return;

@@ -72,4 +72,7 @@ }

}
shouldProxyClick() {
shouldProxyClick(event) {
let handled = false;
if (event && (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)) {
return false;
}
if (this.anchorElement) {

@@ -94,3 +97,4 @@ this.anchorElement.click();

ariaHidden: true,
className: "button anchor hidden"
className: "button anchor",
tabindex: -1
})}

@@ -177,4 +181,7 @@ `;

if (this.anchorElement) {
this.anchorElement.tabIndex = -1;
if (!this.anchorElement.hasAttribute("aria-hidden")) {
this.anchorElement.setAttribute("aria-hidden", "true");
}
this.anchorElement.addEventListener("focus", this.proxyFocus);
this.anchorElement.tabIndex = -1;
}

@@ -181,0 +188,0 @@ }

@@ -1,2 +0,2 @@

"use strict";var d=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var s=(a,i,e,t)=>{for(var r=t>1?void 0:t?u(i,e):i,n=a.length-1,l;n>=0;n--)(l=a[n])&&(r=(t?l(i,e,r):l(r))||r);return t&&r&&d(i,e,r),r};import{html as o}from"@spectrum-web-components/base";import{property as h,query as p}from"@spectrum-web-components/base/src/decorators.js";import{LikeAnchor as c}from"@spectrum-web-components/shared/src/like-anchor.js";import{Focusable as b}from"@spectrum-web-components/shared/src/focusable.js";import{ObserveSlotText as f}from"@spectrum-web-components/shared/src/observe-slot-text.js";import m from"./button-base.css.js";export class ButtonBase extends f(c(b),"",["sp-overlay,sp-tooltip"]){constructor(){super();this.active=!1;this.type="button";this.proxyFocus=this.proxyFocus.bind(this),this.addEventListener("click",this.handleClickCapture,{capture:!0})}static get styles(){return[m]}get focusElement(){return this}get hasLabel(){return this.slotHasContent}get buttonContent(){return[o`
"use strict";var u=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var s=(a,i,e,t)=>{for(var r=t>1?void 0:t?d(i,e):i,n=a.length-1,l;n>=0;n--)(l=a[n])&&(r=(t?l(i,e,r):l(r))||r);return t&&r&&u(i,e,r),r};import{html as o}from"@spectrum-web-components/base";import{property as h,query as c}from"@spectrum-web-components/base/src/decorators.js";import{LikeAnchor as p}from"@spectrum-web-components/shared/src/like-anchor.js";import{Focusable as b}from"@spectrum-web-components/shared/src/focusable.js";import{ObserveSlotText as f}from"@spectrum-web-components/shared/src/observe-slot-text.js";import m from"./button-base.css.js";export class ButtonBase extends f(p(b),"",["sp-overlay,sp-tooltip"]){constructor(){super();this.active=!1;this.type="button";this.proxyFocus=this.proxyFocus.bind(this),this.addEventListener("click",this.handleClickCapture,{capture:!0})}static get styles(){return[m]}get focusElement(){return this}get hasLabel(){return this.slotHasContent}get buttonContent(){return[o`
<slot name="icon" ?icon-only=${!this.hasLabel}></slot>

@@ -7,8 +7,8 @@ `,o`

</span>
`]}handleClickCapture(e){if(this.disabled)return e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),!1;this.shouldProxyClick()}proxyFocus(){this.focus()}shouldProxyClick(){let e=!1;if(this.anchorElement)this.anchorElement.click(),e=!0;else if(this.type!=="button"){const t=document.createElement("button");t.type=this.type,this.insertAdjacentElement("afterend",t),t.click(),t.remove(),e=!0}return e}renderAnchor(){return o`
`]}handleClickCapture(e){if(this.disabled)return e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),!1;this.shouldProxyClick(e)}proxyFocus(){this.focus()}shouldProxyClick(e){let t=!1;if(e&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey))return!1;if(this.anchorElement)this.anchorElement.click(),t=!0;else if(this.type!=="button"){const r=document.createElement("button");r.type=this.type,this.insertAdjacentElement("afterend",r),r.click(),r.remove(),t=!0}return t}renderAnchor(){return o`
${this.buttonContent}
${super.renderAnchor({id:"button",ariaHidden:!0,className:"button anchor hidden"})}
${super.renderAnchor({id:"button",ariaHidden:!0,className:"button anchor",tabindex:-1})}
`}renderButton(){return o`
${this.buttonContent}
`}render(){return this.href&&this.href.length>0?this.renderAnchor():this.renderButton()}handleKeydown(e){const{code:t}=e;switch(t){case"Space":e.preventDefault(),typeof this.href=="undefined"&&(this.addEventListener("keyup",this.handleKeyup),this.active=!0);break;default:break}}handleKeypress(e){const{code:t}=e;switch(t){case"Enter":case"NumpadEnter":this.click();break;default:break}}handleKeyup(e){const{code:t}=e;switch(t){case"Space":this.removeEventListener("keyup",this.handleKeyup),this.active=!1,this.click();break;default:break}}manageAnchor(){this.href&&this.href.length>0?(!this.hasAttribute("role")||this.getAttribute("role")==="button")&&this.setAttribute("role","link"):(!this.hasAttribute("role")||this.getAttribute("role")==="link")&&this.setAttribute("role","button")}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),e.has("label")&&(this.label?this.setAttribute("aria-label",this.label):this.removeAttribute("aria-label")),this.manageAnchor(),this.addEventListener("keydown",this.handleKeydown),this.addEventListener("keypress",this.handleKeypress)}updated(e){super.updated(e),e.has("href")&&this.manageAnchor(),this.anchorElement&&(this.anchorElement.addEventListener("focus",this.proxyFocus),this.anchorElement.tabIndex=-1)}update(e){super.update(e),e.has("label")&&(this.label?this.setAttribute("aria-label",this.label):this.removeAttribute("aria-label"))}}s([h({type:Boolean,reflect:!0})],ButtonBase.prototype,"active",2),s([h({type:String})],ButtonBase.prototype,"type",2),s([p(".anchor")],ButtonBase.prototype,"anchorElement",2);
`}render(){return this.href&&this.href.length>0?this.renderAnchor():this.renderButton()}handleKeydown(e){const{code:t}=e;switch(t){case"Space":e.preventDefault(),typeof this.href=="undefined"&&(this.addEventListener("keyup",this.handleKeyup),this.active=!0);break;default:break}}handleKeypress(e){const{code:t}=e;switch(t){case"Enter":case"NumpadEnter":this.click();break;default:break}}handleKeyup(e){const{code:t}=e;switch(t){case"Space":this.removeEventListener("keyup",this.handleKeyup),this.active=!1,this.click();break;default:break}}manageAnchor(){this.href&&this.href.length>0?(!this.hasAttribute("role")||this.getAttribute("role")==="button")&&this.setAttribute("role","link"):(!this.hasAttribute("role")||this.getAttribute("role")==="link")&&this.setAttribute("role","button")}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),e.has("label")&&(this.label?this.setAttribute("aria-label",this.label):this.removeAttribute("aria-label")),this.manageAnchor(),this.addEventListener("keydown",this.handleKeydown),this.addEventListener("keypress",this.handleKeypress)}updated(e){super.updated(e),e.has("href")&&this.manageAnchor(),this.anchorElement&&(this.anchorElement.tabIndex=-1,this.anchorElement.hasAttribute("aria-hidden")||this.anchorElement.setAttribute("aria-hidden","true"),this.anchorElement.addEventListener("focus",this.proxyFocus))}update(e){super.update(e),e.has("label")&&(this.label?this.setAttribute("aria-label",this.label):this.removeAttribute("aria-label"))}}s([h({type:Boolean,reflect:!0})],ButtonBase.prototype,"active",2),s([h({type:String})],ButtonBase.prototype,"type",2),s([c(".anchor")],ButtonBase.prototype,"anchorElement",2);
//# sourceMappingURL=ButtonBase.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet