Socket
Socket
Sign inDemoInstall

@spectrum-web-components/button

Package Overview
Dependencies
Maintainers
7
Versions
232
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 0.30.1-overlay.42 to 0.31.0

custom-elements.json

16

package.json
{
"name": "@spectrum-web-components/button",
"version": "0.30.1-overlay.42+cf3483d85",
"version": "0.31.0",
"publishConfig": {

@@ -85,8 +85,8 @@ "access": "public"

"dependencies": {
"@spectrum-web-components/base": "^0.30.1-overlay.42+cf3483d85",
"@spectrum-web-components/clear-button": "^0.30.1-overlay.42+cf3483d85",
"@spectrum-web-components/close-button": "^0.30.1-overlay.42+cf3483d85",
"@spectrum-web-components/icon": "^0.30.1-overlay.42+cf3483d85",
"@spectrum-web-components/icons-ui": "^0.30.1-overlay.42+cf3483d85",
"@spectrum-web-components/shared": "^0.30.1-overlay.42+cf3483d85"
"@spectrum-web-components/base": "^0.31.0",
"@spectrum-web-components/clear-button": "^0.31.0",
"@spectrum-web-components/close-button": "^0.31.0",
"@spectrum-web-components/icon": "^0.31.0",
"@spectrum-web-components/icons-ui": "^0.31.0",
"@spectrum-web-components/shared": "^0.31.0"
},

@@ -102,3 +102,3 @@ "devDependencies": {

],
"gitHead": "cf3483d85cf3f933e902734894850f8242d29e6c"
"gitHead": "a30eeed27948a9a372b792b751f968c54337ab9e"
}

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

if (!this.hasAttribute("tabindex")) {
this.tabIndex = 0;
this.setAttribute("tabindex", "0");
}

@@ -173,0 +173,0 @@ this.manageAnchor();

@@ -12,3 +12,3 @@ "use strict";var d=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=(o,r,e,t)=>{for(var i=t>1?void 0:t?c(r,e):r,a=o.length-1,h;a>=0;a--)(h=o[a])&&(i=(t?h(r,e,i):h(i))||i);return t&&i&&d(r,e,i),i};import{html as n}from"@spectrum-web-components/base";import{property as l,query as u}from"@spectrum-web-components/base/src/decorators.js";import{LikeAnchor as p}from"@spectrum-web-components/shared/src/like-anchor.js";import{Focusable as v}from"@spectrum-web-components/shared/src/focusable.js";import{ObserveSlotText as m}from"@spectrum-web-components/shared/src/observe-slot-text.js";import b from"./button-base.css.js";export class ButtonBase extends m(p(v),"",["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[b]}get focusElement(){return this}get hasLabel(){return this.slotHasContent}get buttonContent(){return[n`

${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}}handleRemoveActive(){this.active=!1}handlePointerdown(){this.active=!0}manageAnchor(){this.href&&this.href.length>0?(this.getAttribute("role")==="button"&&this.setAttribute("role","link"),this.removeEventListener("click",this.shouldProxyClick)):((!this.hasAttribute("role")||this.getAttribute("role")==="link")&&this.setAttribute("role","button"),this.addEventListener("click",this.shouldProxyClick))}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("tabindex")||(this.tabIndex=0),this.manageAnchor(),this.addEventListener("keydown",this.handleKeydown),this.addEventListener("keypress",this.handleKeypress),this.addEventListener("pointerdown",this.handlePointerdown)}updated(e){super.updated(e),e.has("href")&&this.manageAnchor(),e.has("label")&&this.setAttribute("aria-label",this.label||""),e.has("active")&&(this.active?(this.addEventListener("focusout",this.handleRemoveActive),this.addEventListener("pointerup",this.handleRemoveActive),this.addEventListener("pointercancel",this.handleRemoveActive),this.addEventListener("pointerleave",this.handleRemoveActive)):(this.removeEventListener("focusout",this.handleRemoveActive),this.removeEventListener("pointerup",this.handleRemoveActive),this.removeEventListener("pointercancel",this.handleRemoveActive),this.removeEventListener("pointerleave",this.handleRemoveActive))),this.anchorElement&&(this.anchorElement.addEventListener("focus",this.proxyFocus),this.anchorElement.tabIndex=-1)}}s([l({type:Boolean,reflect:!0})],ButtonBase.prototype,"active",2),s([l({type:String})],ButtonBase.prototype,"type",2),s([u(".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}}handleRemoveActive(){this.active=!1}handlePointerdown(){this.active=!0}manageAnchor(){this.href&&this.href.length>0?(this.getAttribute("role")==="button"&&this.setAttribute("role","link"),this.removeEventListener("click",this.shouldProxyClick)):((!this.hasAttribute("role")||this.getAttribute("role")==="link")&&this.setAttribute("role","button"),this.addEventListener("click",this.shouldProxyClick))}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.manageAnchor(),this.addEventListener("keydown",this.handleKeydown),this.addEventListener("keypress",this.handleKeypress),this.addEventListener("pointerdown",this.handlePointerdown)}updated(e){super.updated(e),e.has("href")&&this.manageAnchor(),e.has("label")&&this.setAttribute("aria-label",this.label||""),e.has("active")&&(this.active?(this.addEventListener("focusout",this.handleRemoveActive),this.addEventListener("pointerup",this.handleRemoveActive),this.addEventListener("pointercancel",this.handleRemoveActive),this.addEventListener("pointerleave",this.handleRemoveActive)):(this.removeEventListener("focusout",this.handleRemoveActive),this.removeEventListener("pointerup",this.handleRemoveActive),this.removeEventListener("pointercancel",this.handleRemoveActive),this.removeEventListener("pointerleave",this.handleRemoveActive))),this.anchorElement&&(this.anchorElement.addEventListener("focus",this.proxyFocus),this.anchorElement.tabIndex=-1)}}s([l({type:Boolean,reflect:!0})],ButtonBase.prototype,"active",2),s([l({type:String})],ButtonBase.prototype,"type",2),s([u(".anchor")],ButtonBase.prototype,"anchorElement",2);
//# sourceMappingURL=ButtonBase.js.map

@@ -179,2 +179,20 @@ "use strict";

});
it("`disabled` manages `tabindex`", async () => {
const el = await fixture(
html`
<sp-button disabled>Button</sp-button>
`
);
await elementUpdated(el);
expect(el.tabIndex).to.equal(-1);
expect(el.getAttribute("tabindex")).to.equal("-1");
el.disabled = false;
await elementUpdated(el);
expect(el.tabIndex).to.equal(0);
expect(el.getAttribute("tabindex")).to.equal("0");
el.disabled = true;
await elementUpdated(el);
expect(el.tabIndex).to.equal(-1);
expect(el.getAttribute("tabindex")).to.equal("-1");
});
it("manages `aria-disabled`", async () => {

@@ -181,0 +199,0 @@ const el = await fixture(

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc