@spectrum-web-components/shared
Advanced tools
Comparing version 0.30.1-overlay.42 to 0.31.0
{ | ||
"name": "@spectrum-web-components/shared", | ||
"version": "0.30.1-overlay.42+cf3483d85", | ||
"version": "0.31.0", | ||
"publishConfig": { | ||
@@ -92,3 +92,3 @@ "access": "public" | ||
"@lit-labs/observers": "^2.0.0", | ||
"@spectrum-web-components/base": "^0.30.1-overlay.42+cf3483d85", | ||
"@spectrum-web-components/base": "^0.31.0", | ||
"focus-visible": "^5.1.0" | ||
@@ -101,3 +101,3 @@ }, | ||
], | ||
"gitHead": "cf3483d85cf3f933e902734894850f8242d29e6c" | ||
"gitHead": "a30eeed27948a9a372b792b751f968c54337ab9e" | ||
} |
import type { SpectrumElement } from '@spectrum-web-components/base'; | ||
export declare const firstFocusableIn: (root: HTMLElement | ShadowRoot) => SpectrumElement | null; | ||
export declare const firstFocusableSlottedIn: (root: HTMLSlotElement) => SpectrumElement | null; |
@@ -9,8 +9,2 @@ "use strict"; | ||
}; | ||
export const firstFocusableSlottedIn = (root) => { | ||
const firstFocusable = root.assignedElements().find( | ||
(element) => element.matches(firstFocusableSelector) | ||
); | ||
return firstFocusable; | ||
}; | ||
//# sourceMappingURL=first-focusable-in.dev.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";const e='button:not([tabindex="-1"]), [href]:not([tabindex="-1"]), input:not([tabindex="-1"]), select:not([tabindex="-1"]), textarea:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), [focusable]:not([tabindex="-1"])';export const firstFocusableIn=t=>t.querySelector(e),firstFocusableSlottedIn=t=>t.assignedElements().find(o=>o.matches(e)); | ||
"use strict";const e='button:not([tabindex="-1"]), [href]:not([tabindex="-1"]), input:not([tabindex="-1"]), select:not([tabindex="-1"]), textarea:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), [focusable]:not([tabindex="-1"])';export const firstFocusableIn=t=>t.querySelector(e); | ||
//# sourceMappingURL=first-focusable-in.js.map |
@@ -24,3 +24,3 @@ "use strict"; | ||
this.autofocus = false; | ||
this._tabIndex = -1; | ||
this._tabIndex = 0; | ||
this.manipulatingTabindex = false; | ||
@@ -27,0 +27,0 @@ this._recentlyConnected = false; |
@@ -1,2 +0,2 @@ | ||
"use strict";var u=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var n=(s,a,e,t)=>{for(var i=t>1?void 0:t?b(a,e):a,o=s.length-1,r;o>=0;o--)(r=s[o])&&(i=(t?r(a,e,i):r(i))||i);return t&&i&&u(a,e,i),i};import{SpectrumElement as h}from"@spectrum-web-components/base";import{property as l}from"@spectrum-web-components/base/src/decorators.js";import{FocusVisiblePolyfillMixin as c}from"./focus-visible.js";function d(){return new Promise(s=>requestAnimationFrame(()=>s()))}export class Focusable extends c(h){constructor(){super(...arguments);this.disabled=!1;this.autofocus=!1;this._tabIndex=-1;this.manipulatingTabindex=!1;this._recentlyConnected=!1}get tabIndex(){if(this.focusElement===this){const t=this.hasAttribute("tabindex")?Number(this.getAttribute("tabindex")):NaN;return isNaN(t)?-1:t}const e=parseFloat(this.hasAttribute("tabindex")&&this.getAttribute("tabindex")||"0");return this.disabled||e<0?-1:this.focusElement?this.focusElement.tabIndex:e}set tabIndex(e){if(this.manipulatingTabindex){this.manipulatingTabindex=!1;return}if(this.focusElement===this){if(e!==this._tabIndex){this._tabIndex=e;const t=this.disabled?"-1":""+e;this.manipulatingTabindex=!0,this.setAttribute("tabindex",t)}return}if(e===-1?this.addEventListener("pointerdown",this.onPointerdownManagementOfTabIndex):(this.manipulatingTabindex=!0,this.removeEventListener("pointerdown",this.onPointerdownManagementOfTabIndex)),e===-1||this.disabled){this.setAttribute("tabindex","-1"),this.removeAttribute("focusable"),e!==-1&&this.manageFocusElementTabindex(e);return}this.setAttribute("focusable",""),this.hasAttribute("tabindex")?this.removeAttribute("tabindex"):this.manipulatingTabindex=!1,this.manageFocusElementTabindex(e)}onPointerdownManagementOfTabIndex(){this.tabIndex===-1&&(this.tabIndex=0,this.focus({preventScroll:!0}))}async manageFocusElementTabindex(e){this.focusElement||await this.updateComplete,e===null?this.focusElement.removeAttribute("tabindex"):this.focusElement.tabIndex=e}get focusElement(){throw new Error("Must implement focusElement getter!")}focus(e){this.disabled||!this.focusElement||(this.focusElement!==this?this.focusElement.focus(e):HTMLElement.prototype.focus.apply(this,[e]))}blur(){const e=this.focusElement||this;e!==this?e.blur():HTMLElement.prototype.blur.apply(this)}click(){if(this.disabled)return;const e=this.focusElement||this;e!==this?e.click():HTMLElement.prototype.click.apply(this)}manageAutoFocus(){this.autofocus&&(this.dispatchEvent(new KeyboardEvent("keydown",{code:"Tab"})),this.focusElement.focus())}firstUpdated(e){super.firstUpdated(e),(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")!=="-1")&&this.setAttribute("focusable","")}update(e){e.has("disabled")&&this.handleDisabledChanged(this.disabled,e.get("disabled")),super.update(e)}updated(e){super.updated(e),e.has("disabled")&&this.disabled&&this.blur()}async handleDisabledChanged(e,t){const i=()=>this.focusElement!==this&&typeof this.focusElement.disabled!="undefined";e?(this.manipulatingTabindex=!0,this.setAttribute("tabindex","-1"),await this.updateComplete,i()?this.focusElement.disabled=!0:this.setAttribute("aria-disabled","true")):t&&(this.manipulatingTabindex=!0,this.focusElement===this?this.setAttribute("tabindex",""+this._tabIndex):this.removeAttribute("tabindex"),await this.updateComplete,i()?this.focusElement.disabled=!1:this.removeAttribute("aria-disabled"))}async getUpdateComplete(){const e=await super.getUpdateComplete();return this._recentlyConnected&&(this._recentlyConnected=!1,await d(),await d()),e}connectedCallback(){super.connectedCallback(),this._recentlyConnected=!0,this.updateComplete.then(()=>{this.manageAutoFocus()})}}n([l({type:Boolean,reflect:!0})],Focusable.prototype,"disabled",2),n([l({type:Boolean})],Focusable.prototype,"autofocus",2),n([l({type:Number})],Focusable.prototype,"tabIndex",1); | ||
"use strict";var u=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var n=(s,a,e,t)=>{for(var i=t>1?void 0:t?b(a,e):a,o=s.length-1,r;o>=0;o--)(r=s[o])&&(i=(t?r(a,e,i):r(i))||i);return t&&i&&u(a,e,i),i};import{SpectrumElement as h}from"@spectrum-web-components/base";import{property as l}from"@spectrum-web-components/base/src/decorators.js";import{FocusVisiblePolyfillMixin as c}from"./focus-visible.js";function d(){return new Promise(s=>requestAnimationFrame(()=>s()))}export class Focusable extends c(h){constructor(){super(...arguments);this.disabled=!1;this.autofocus=!1;this._tabIndex=0;this.manipulatingTabindex=!1;this._recentlyConnected=!1}get tabIndex(){if(this.focusElement===this){const t=this.hasAttribute("tabindex")?Number(this.getAttribute("tabindex")):NaN;return isNaN(t)?-1:t}const e=parseFloat(this.hasAttribute("tabindex")&&this.getAttribute("tabindex")||"0");return this.disabled||e<0?-1:this.focusElement?this.focusElement.tabIndex:e}set tabIndex(e){if(this.manipulatingTabindex){this.manipulatingTabindex=!1;return}if(this.focusElement===this){if(e!==this._tabIndex){this._tabIndex=e;const t=this.disabled?"-1":""+e;this.manipulatingTabindex=!0,this.setAttribute("tabindex",t)}return}if(e===-1?this.addEventListener("pointerdown",this.onPointerdownManagementOfTabIndex):(this.manipulatingTabindex=!0,this.removeEventListener("pointerdown",this.onPointerdownManagementOfTabIndex)),e===-1||this.disabled){this.setAttribute("tabindex","-1"),this.removeAttribute("focusable"),e!==-1&&this.manageFocusElementTabindex(e);return}this.setAttribute("focusable",""),this.hasAttribute("tabindex")?this.removeAttribute("tabindex"):this.manipulatingTabindex=!1,this.manageFocusElementTabindex(e)}onPointerdownManagementOfTabIndex(){this.tabIndex===-1&&(this.tabIndex=0,this.focus({preventScroll:!0}))}async manageFocusElementTabindex(e){this.focusElement||await this.updateComplete,e===null?this.focusElement.removeAttribute("tabindex"):this.focusElement.tabIndex=e}get focusElement(){throw new Error("Must implement focusElement getter!")}focus(e){this.disabled||!this.focusElement||(this.focusElement!==this?this.focusElement.focus(e):HTMLElement.prototype.focus.apply(this,[e]))}blur(){const e=this.focusElement||this;e!==this?e.blur():HTMLElement.prototype.blur.apply(this)}click(){if(this.disabled)return;const e=this.focusElement||this;e!==this?e.click():HTMLElement.prototype.click.apply(this)}manageAutoFocus(){this.autofocus&&(this.dispatchEvent(new KeyboardEvent("keydown",{code:"Tab"})),this.focusElement.focus())}firstUpdated(e){super.firstUpdated(e),(!this.hasAttribute("tabindex")||this.getAttribute("tabindex")!=="-1")&&this.setAttribute("focusable","")}update(e){e.has("disabled")&&this.handleDisabledChanged(this.disabled,e.get("disabled")),super.update(e)}updated(e){super.updated(e),e.has("disabled")&&this.disabled&&this.blur()}async handleDisabledChanged(e,t){const i=()=>this.focusElement!==this&&typeof this.focusElement.disabled!="undefined";e?(this.manipulatingTabindex=!0,this.setAttribute("tabindex","-1"),await this.updateComplete,i()?this.focusElement.disabled=!0:this.setAttribute("aria-disabled","true")):t&&(this.manipulatingTabindex=!0,this.focusElement===this?this.setAttribute("tabindex",""+this._tabIndex):this.removeAttribute("tabindex"),await this.updateComplete,i()?this.focusElement.disabled=!1:this.removeAttribute("aria-disabled"))}async getUpdateComplete(){const e=await super.getUpdateComplete();return this._recentlyConnected&&(this._recentlyConnected=!1,await d(),await d()),e}connectedCallback(){super.connectedCallback(),this._recentlyConnected=!0,this.updateComplete.then(()=>{this.manageAutoFocus()})}}n([l({type:Boolean,reflect:!0})],Focusable.prototype,"disabled",2),n([l({type:Boolean})],Focusable.prototype,"autofocus",2),n([l({type:Number})],Focusable.prototype,"tabIndex",1); | ||
//# sourceMappingURL=focusable.js.map |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
0
195087
1206
+ Added@spectrum-web-components/base@0.31.0(transitive)
- Removed@spectrum-web-components/base@0.30.1-overlay.42(transitive)