@spectrum-web-components/reactive-controllers
Advanced tools
Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "@spectrum-web-components/reactive-controllers", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"publishConfig": { | ||
@@ -28,2 +28,6 @@ "access": "public" | ||
"./package.json": "./package.json", | ||
"./src/Color.js": { | ||
"development": "./src/Color.dev.js", | ||
"default": "./src/Color.js" | ||
}, | ||
"./src/FocusGroup.js": { | ||
@@ -33,2 +37,6 @@ "development": "./src/FocusGroup.dev.js", | ||
}, | ||
"./src/LanguageResolution.js": { | ||
"development": "./src/LanguageResolution.dev.js", | ||
"default": "./src/LanguageResolution.js" | ||
}, | ||
"./src/MatchMedia.js": { | ||
@@ -73,3 +81,3 @@ "development": "./src/MatchMedia.dev.js", | ||
], | ||
"gitHead": "05c81318844160db3f8156144106e643507fef97" | ||
"gitHead": "15588c72c774b17cfac605b20ac52a27d123bd03" | ||
} |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
export class FocusGroupController { | ||
@@ -2,0 +3,0 @@ constructor(host, { |
@@ -1,2 +0,2 @@ | ||
export class FocusGroupController{constructor(e,{direction:t,elementEnterAction:s,elements:n,focusInIndex:i,isFocusableElement:r,listenerScope:o}={elements:()=>[]}){this._currentIndex=-1;this._direction=()=>"both";this.directionLength=5;this.elementEnterAction=e=>{};this._focused=!1;this._focusInIndex=e=>0;this.isFocusableElement=e=>!0;this._listenerScope=()=>this.host;this.offset=0;this.handleFocusin=e=>{if(!this.isEventWithinListenerScope(e))return;this.isRelatedTargetAnElement(e)&&this.hostContainsFocus();const t=e.composedPath();let s=-1;t.find(n=>(s=this.elements.indexOf(n),s!==-1)),this.currentIndex=s>-1?s:this.currentIndex};this.handleFocusout=e=>{this.isRelatedTargetAnElement(e)&&this.hostNoLongerContainsFocus()};this.handleKeydown=e=>{if(!this.acceptsEventCode(e.code)||e.defaultPrevented)return;let t=0;switch(e.code){case"ArrowRight":t+=1;break;case"ArrowDown":t+=this.direction==="grid"?this.directionLength:1;break;case"ArrowLeft":t-=1;break;case"ArrowUp":t-=this.direction==="grid"?this.directionLength:1;break;case"End":this.currentIndex=0,t-=1;break;case"Home":this.currentIndex=this.elements.length-1,t+=1;break}e.preventDefault(),this.direction==="grid"&&this.currentIndex+t<0?this.currentIndex=0:this.direction==="grid"&&this.currentIndex+t>this.elements.length-1?this.currentIndex=this.elements.length-1:this.setCurrentIndexCircularly(t),this.elementEnterAction(this.elements[this.currentIndex]),this.focus()};this.host=e,this.host.addController(this),this._elements=n,this.isFocusableElement=r||this.isFocusableElement,typeof t=="string"?this._direction=()=>t:typeof t=="function"&&(this._direction=t),this.elementEnterAction=s||this.elementEnterAction,typeof i=="number"?this._focusInIndex=()=>i:typeof i=="function"&&(this._focusInIndex=i),typeof o=="object"?this._listenerScope=()=>o:typeof o=="function"&&(this._listenerScope=o)}get currentIndex(){return this._currentIndex===-1&&(this._currentIndex=this.focusInIndex),this._currentIndex-this.offset}set currentIndex(e){this._currentIndex=e+this.offset}get direction(){return this._direction()}get elements(){return this.cachedElements||(this.cachedElements=this._elements()),this.cachedElements}set focused(e){e!==this.focused&&(this._focused=e)}get focused(){return this._focused}get focusInElement(){return this.elements[this.focusInIndex]}get focusInIndex(){return this._focusInIndex(this.elements)}isEventWithinListenerScope(e){return this._listenerScope()===this.host?!0:e.composedPath().includes(this._listenerScope())}update({elements:e}={elements:()=>[]}){this.unmanage(),this._elements=e,this.clearElementCache(),this.manage()}focus(e){let t=this.elements[this.currentIndex];(!t||!this.isFocusableElement(t))&&(this.setCurrentIndexCircularly(1),t=this.elements[this.currentIndex]),t&&this.isFocusableElement(t)&&t.focus(e)}clearElementCache(e=0){delete this.cachedElements,this.offset=e}setCurrentIndexCircularly(e){const{length:t}=this.elements;let s=t,n=(t+this.currentIndex+e)%t;for(;s&&this.elements[n]&&!this.isFocusableElement(this.elements[n]);)n=(t+n+e)%t,s-=1;this.currentIndex=n}hostContainsFocus(){this.host.addEventListener("focusout",this.handleFocusout),this.host.addEventListener("keydown",this.handleKeydown),this.focused=!0}hostNoLongerContainsFocus(){this.host.addEventListener("focusin",this.handleFocusin),this.host.removeEventListener("focusout",this.handleFocusout),this.host.removeEventListener("keydown",this.handleKeydown),this.currentIndex=this.focusInIndex,this.focused=!1}isRelatedTargetAnElement(e){const t=e.relatedTarget;return!this.elements.includes(t)}acceptsEventCode(e){if(e==="End"||e==="Home")return!0;switch(this.direction){case"horizontal":return e==="ArrowLeft"||e==="ArrowRight";case"vertical":return e==="ArrowUp"||e==="ArrowDown";case"both":case"grid":return e.startsWith("Arrow")}}manage(){this.addEventListeners()}unmanage(){this.removeEventListeners()}addEventListeners(){this.host.addEventListener("focusin",this.handleFocusin)}removeEventListeners(){this.host.removeEventListener("focusin",this.handleFocusin),this.host.removeEventListener("focusout",this.handleFocusout),this.host.removeEventListener("keydown",this.handleKeydown)}hostConnected(){this.addEventListeners()}hostDisconnected(){this.removeEventListeners()}} | ||
"use strict";export class FocusGroupController{constructor(e,{direction:t,elementEnterAction:s,elements:n,focusInIndex:i,isFocusableElement:r,listenerScope:o}={elements:()=>[]}){this._currentIndex=-1;this._direction=()=>"both";this.directionLength=5;this.elementEnterAction=e=>{};this._focused=!1;this._focusInIndex=e=>0;this.isFocusableElement=e=>!0;this._listenerScope=()=>this.host;this.offset=0;this.handleFocusin=e=>{if(!this.isEventWithinListenerScope(e))return;this.isRelatedTargetAnElement(e)&&this.hostContainsFocus();const t=e.composedPath();let s=-1;t.find(n=>(s=this.elements.indexOf(n),s!==-1)),this.currentIndex=s>-1?s:this.currentIndex};this.handleFocusout=e=>{this.isRelatedTargetAnElement(e)&&this.hostNoLongerContainsFocus()};this.handleKeydown=e=>{if(!this.acceptsEventCode(e.code)||e.defaultPrevented)return;let t=0;switch(e.code){case"ArrowRight":t+=1;break;case"ArrowDown":t+=this.direction==="grid"?this.directionLength:1;break;case"ArrowLeft":t-=1;break;case"ArrowUp":t-=this.direction==="grid"?this.directionLength:1;break;case"End":this.currentIndex=0,t-=1;break;case"Home":this.currentIndex=this.elements.length-1,t+=1;break}e.preventDefault(),this.direction==="grid"&&this.currentIndex+t<0?this.currentIndex=0:this.direction==="grid"&&this.currentIndex+t>this.elements.length-1?this.currentIndex=this.elements.length-1:this.setCurrentIndexCircularly(t),this.elementEnterAction(this.elements[this.currentIndex]),this.focus()};this.host=e,this.host.addController(this),this._elements=n,this.isFocusableElement=r||this.isFocusableElement,typeof t=="string"?this._direction=()=>t:typeof t=="function"&&(this._direction=t),this.elementEnterAction=s||this.elementEnterAction,typeof i=="number"?this._focusInIndex=()=>i:typeof i=="function"&&(this._focusInIndex=i),typeof o=="object"?this._listenerScope=()=>o:typeof o=="function"&&(this._listenerScope=o)}get currentIndex(){return this._currentIndex===-1&&(this._currentIndex=this.focusInIndex),this._currentIndex-this.offset}set currentIndex(e){this._currentIndex=e+this.offset}get direction(){return this._direction()}get elements(){return this.cachedElements||(this.cachedElements=this._elements()),this.cachedElements}set focused(e){e!==this.focused&&(this._focused=e)}get focused(){return this._focused}get focusInElement(){return this.elements[this.focusInIndex]}get focusInIndex(){return this._focusInIndex(this.elements)}isEventWithinListenerScope(e){return this._listenerScope()===this.host?!0:e.composedPath().includes(this._listenerScope())}update({elements:e}={elements:()=>[]}){this.unmanage(),this._elements=e,this.clearElementCache(),this.manage()}focus(e){let t=this.elements[this.currentIndex];(!t||!this.isFocusableElement(t))&&(this.setCurrentIndexCircularly(1),t=this.elements[this.currentIndex]),t&&this.isFocusableElement(t)&&t.focus(e)}clearElementCache(e=0){delete this.cachedElements,this.offset=e}setCurrentIndexCircularly(e){const{length:t}=this.elements;let s=t,n=(t+this.currentIndex+e)%t;for(;s&&this.elements[n]&&!this.isFocusableElement(this.elements[n]);)n=(t+n+e)%t,s-=1;this.currentIndex=n}hostContainsFocus(){this.host.addEventListener("focusout",this.handleFocusout),this.host.addEventListener("keydown",this.handleKeydown),this.focused=!0}hostNoLongerContainsFocus(){this.host.addEventListener("focusin",this.handleFocusin),this.host.removeEventListener("focusout",this.handleFocusout),this.host.removeEventListener("keydown",this.handleKeydown),this.currentIndex=this.focusInIndex,this.focused=!1}isRelatedTargetAnElement(e){const t=e.relatedTarget;return!this.elements.includes(t)}acceptsEventCode(e){if(e==="End"||e==="Home")return!0;switch(this.direction){case"horizontal":return e==="ArrowLeft"||e==="ArrowRight";case"vertical":return e==="ArrowUp"||e==="ArrowDown";case"both":case"grid":return e.startsWith("Arrow")}}manage(){this.addEventListeners()}unmanage(){this.removeEventListeners()}addEventListeners(){this.host.addEventListener("focusin",this.handleFocusin)}removeEventListeners(){this.host.removeEventListener("focusin",this.handleFocusin),this.host.removeEventListener("focusout",this.handleFocusout),this.host.removeEventListener("keydown",this.handleKeydown)}hostConnected(){this.addEventListeners()}hostDisconnected(){this.removeEventListeners()}} | ||
//# sourceMappingURL=FocusGroup.js.map |
@@ -0,3 +1,4 @@ | ||
"use strict"; | ||
export * from "./MatchMedia.dev.js"; | ||
export * from "./RovingTabindex.dev.js"; | ||
//# sourceMappingURL=index.dev.js.map |
@@ -1,2 +0,2 @@ | ||
export*from"./MatchMedia.js";export*from"./RovingTabindex.js"; | ||
"use strict";export*from"./MatchMedia.js";export*from"./RovingTabindex.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
export const DARK_MODE = "(prefers-color-scheme: dark)"; | ||
@@ -8,2 +9,3 @@ export const IS_MOBILE = "(max-width: 700px) and (hover: none) and (pointer: coarse), (max-height: 700px) and (hover: none) and (pointer: coarse)"; | ||
this.host = host; | ||
this.host.addController(this); | ||
this.media = window.matchMedia(query); | ||
@@ -15,6 +17,8 @@ this.matches = this.media.matches; | ||
hostConnected() { | ||
this.media.addEventListener("change", this.onChange); | ||
var _a; | ||
(_a = this.media) == null ? void 0 : _a.addEventListener("change", this.onChange); | ||
} | ||
hostDisconnected() { | ||
this.media.removeEventListener("change", this.onChange); | ||
var _a; | ||
(_a = this.media) == null ? void 0 : _a.removeEventListener("change", this.onChange); | ||
} | ||
@@ -21,0 +25,0 @@ onChange(event) { |
@@ -1,2 +0,2 @@ | ||
export const DARK_MODE="(prefers-color-scheme: dark)",IS_MOBILE="(max-width: 700px) and (hover: none) and (pointer: coarse), (max-height: 700px) and (hover: none) and (pointer: coarse)";export class MatchMediaController{constructor(e,t){this.key=Symbol("match-media-key");this.matches=!1;this.host=e,this.media=window.matchMedia(t),this.matches=this.media.matches,this.onChange=this.onChange.bind(this),e.addController(this)}hostConnected(){this.media.addEventListener("change",this.onChange)}hostDisconnected(){this.media.removeEventListener("change",this.onChange)}onChange(e){this.matches!==e.matches&&(this.matches=e.matches,this.host.requestUpdate(this.key,!this.matches))}} | ||
"use strict";export const DARK_MODE="(prefers-color-scheme: dark)",IS_MOBILE="(max-width: 700px) and (hover: none) and (pointer: coarse), (max-height: 700px) and (hover: none) and (pointer: coarse)";export class MatchMediaController{constructor(e,t){this.key=Symbol("match-media-key");this.matches=!1;this.host=e,this.host.addController(this),this.media=window.matchMedia(t),this.matches=this.media.matches,this.onChange=this.onChange.bind(this),e.addController(this)}hostConnected(){var e;(e=this.media)==null||e.addEventListener("change",this.onChange)}hostDisconnected(){var e;(e=this.media)==null||e.removeEventListener("change",this.onChange)}onChange(e){this.matches!==e.matches&&(this.matches=e.matches,this.host.requestUpdate(this.key,!this.matches))}} | ||
//# sourceMappingURL=MatchMedia.js.map |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
import { FocusGroupController } from "./FocusGroup.dev.js"; | ||
@@ -22,3 +23,5 @@ export class RovingTabindexController extends FocusGroupController { | ||
return; | ||
this.manageIndexesAnimationFrame = requestAnimationFrame(() => this.manageTabindexes()); | ||
this.manageIndexesAnimationFrame = requestAnimationFrame( | ||
() => this.manageTabindexes() | ||
); | ||
} | ||
@@ -25,0 +28,0 @@ manageTabindexes() { |
@@ -1,2 +0,2 @@ | ||
import{FocusGroupController as s}from"./FocusGroup.js";export class RovingTabindexController extends s{constructor(){super(...arguments);this.managed=!0;this.manageIndexesAnimationFrame=0}set focused(e){e!==this.focused&&(super.focused=e,this.manageTabindexes())}get focused(){return super.focused}clearElementCache(e=0){cancelAnimationFrame(this.manageIndexesAnimationFrame),super.clearElementCache(e),this.managed&&(this.manageIndexesAnimationFrame=requestAnimationFrame(()=>this.manageTabindexes()))}manageTabindexes(){this.focused?this.updateTabindexes(()=>({tabIndex:-1})):this.updateTabindexes(e=>({removeTabIndex:e.contains(this.focusInElement)&&e!==this.focusInElement,tabIndex:e===this.focusInElement?0:-1}))}updateTabindexes(e){this.elements.forEach(a=>{const{tabIndex:t,removeTabIndex:i}=e(a);if(!i){a.tabIndex=t;return}a.removeAttribute("tabindex");const n=a;n.requestUpdate&&n.requestUpdate()})}manage(){this.managed=!0,this.manageTabindexes(),super.manage()}unmanage(){this.managed=!1,this.updateTabindexes(()=>({tabIndex:0})),super.unmanage()}hostUpdated(){this.host.hasUpdated||this.manageTabindexes()}} | ||
"use strict";import{FocusGroupController as s}from"./FocusGroup.js";export class RovingTabindexController extends s{constructor(){super(...arguments);this.managed=!0;this.manageIndexesAnimationFrame=0}set focused(e){e!==this.focused&&(super.focused=e,this.manageTabindexes())}get focused(){return super.focused}clearElementCache(e=0){cancelAnimationFrame(this.manageIndexesAnimationFrame),super.clearElementCache(e),this.managed&&(this.manageIndexesAnimationFrame=requestAnimationFrame(()=>this.manageTabindexes()))}manageTabindexes(){this.focused?this.updateTabindexes(()=>({tabIndex:-1})):this.updateTabindexes(e=>({removeTabIndex:e.contains(this.focusInElement)&&e!==this.focusInElement,tabIndex:e===this.focusInElement?0:-1}))}updateTabindexes(e){this.elements.forEach(a=>{const{tabIndex:t,removeTabIndex:i}=e(a);if(!i){a.tabIndex=t;return}a.removeAttribute("tabindex");const n=a;n.requestUpdate&&n.requestUpdate()})}manage(){this.managed=!0,this.manageTabindexes(),super.manage()}unmanage(){this.managed=!1,this.updateTabindexes(()=>({tabIndex:0})),super.unmanage()}hostUpdated(){this.host.hasUpdated||this.manageTabindexes()}} | ||
//# sourceMappingURL=RovingTabindex.js.map |
@@ -1,4 +0,26 @@ | ||
import{html as i,LitElement as m}from"lit";import{expect as e,fixture as s,nextFrame as r}from"@open-wc/testing";import{setViewport as c}from"@web/test-runner-commands";import{MatchMediaController as h}from"@spectrum-web-components/reactive-controllers/src/MatchMedia.js";describe("Match Media",()=>{it("responds to media changes",async()=>{class a extends m{}customElements.define("test-match-media-el",a);const o=await s(i` | ||
"use strict"; | ||
import { html, LitElement } from "lit"; | ||
import { expect, fixture, nextFrame } from "@open-wc/testing"; | ||
import { setViewport } from "@web/test-runner-commands"; | ||
import { MatchMediaController } from "@spectrum-web-components/reactive-controllers/src/MatchMedia.js"; | ||
describe("Match Media", () => { | ||
it("responds to media changes", async () => { | ||
class TestEl extends LitElement { | ||
} | ||
customElements.define("test-match-media-el", TestEl); | ||
const el = await fixture( | ||
html` | ||
<test-match-media-el></test-match-media-el> | ||
`),t=new h(o,"(min-width: 500px)");e(t.matches).to.be.true,await c({width:360,height:640}),await r(),e(t.matches).to.be.false})}); | ||
` | ||
); | ||
const controller = new MatchMediaController( | ||
el, | ||
"(min-width: 500px)" | ||
); | ||
expect(controller.matches).to.be.true; | ||
await setViewport({ width: 360, height: 640 }); | ||
await nextFrame(); | ||
expect(controller.matches).to.be.false; | ||
}); | ||
}); | ||
//# sourceMappingURL=match-media.test.js.map |
@@ -1,2 +0,14 @@ | ||
import"@spectrum-web-components/action-button/sp-action-button.js";import"@spectrum-web-components/action-group/sp-action-group.js";import"@spectrum-web-components/tabs/sp-tab-panel.js";import"@spectrum-web-components/tabs/sp-tab.js";import"@spectrum-web-components/tabs/sp-tabs.js";import{elementUpdated as f,expect as t,fixture as g,nextFrame as y}from"@open-wc/testing";import{html as B}from"@spectrum-web-components/base";import{sendKeys as o}from"@web/test-runner-commands";import{sendMouse as E}from"../../../test/plugins/browser.js";const w=async()=>{const e=await g(B` | ||
"use strict"; | ||
import "@spectrum-web-components/action-button/sp-action-button.js"; | ||
import "@spectrum-web-components/action-group/sp-action-group.js"; | ||
import "@spectrum-web-components/tabs/sp-tab-panel.js"; | ||
import "@spectrum-web-components/tabs/sp-tab.js"; | ||
import "@spectrum-web-components/tabs/sp-tabs.js"; | ||
import { elementUpdated, expect, fixture, nextFrame } from "@open-wc/testing"; | ||
import { html } from "@spectrum-web-components/base"; | ||
import { sendKeys } from "@web/test-runner-commands"; | ||
import { sendMouse } from "../../../test/plugins/browser.js"; | ||
const createTabs = async () => { | ||
const tabs = await fixture( | ||
html` | ||
<sp-tabs selected="second"> | ||
@@ -46,3 +58,90 @@ <sp-tab label="Tab 1" value="first"></sp-tab> | ||
</sp-tabs> | ||
`);return await f(e),e};describe("Action Group inside of Tabs",()=>{it("accurately navigates the desired element",async()=>{const e=await w(),s=e.querySelector('sp-tab[value="first"]'),a=e.querySelector('sp-tab[value="second"]'),l=e.querySelector('sp-tab[value="third"]'),r=e.querySelector('sp-tab-panel[value="first"]'),p=e.querySelector('sp-tab-panel[value="second"]'),b=e.querySelector('sp-tab-panel[value="third"]'),c=r.querySelector("sp-action-group"),u=p.querySelector("sp-action-group"),i=b.querySelector("sp-action-group"),m=c.querySelector("[selected]"),d=u.querySelector("[selected]"),v=i.querySelector("[selected]");e.focus(),t(e.contains(document.activeElement)).to.be.true,t(document.activeElement===a).to.be.true,u.focus(),t(document.activeElement===d).to.be.true,await y(),await o({press:"ArrowLeft"}),t(document.activeElement===s).to.be.false,t(u.contains(document.activeElement)).to.be.true,e.focus(),t(document.activeElement===a).to.be.true,await o({press:"ArrowRight"}),t(document.activeElement===l).to.be.true,await o({press:"Enter"}),t(document.activeElement===l).to.be.true,i.focus(),t(document.activeElement===v).to.be.true,await o({press:"ArrowLeft"}),t(document.activeElement===a).to.be.false,t(i.contains(document.activeElement)).to.be.true;const n=s.getBoundingClientRect();await E({steps:[{type:"click",position:[n.left+n.width/2,n.top+n.height/2]}]}),t(document.activeElement===s).to.be.true,c.focus(),t(document.activeElement===m).to.be.true,await o({press:"ArrowRight"}),t(document.activeElement===a).to.be.false,t(c.contains(document.activeElement)).to.be.true})}); | ||
` | ||
); | ||
await elementUpdated(tabs); | ||
return tabs; | ||
}; | ||
describe("Action Group inside of Tabs", () => { | ||
it("accurately navigates the desired element", async () => { | ||
const el = await createTabs(); | ||
const tab1 = el.querySelector('sp-tab[value="first"]'); | ||
const tab2 = el.querySelector('sp-tab[value="second"]'); | ||
const tab3 = el.querySelector('sp-tab[value="third"]'); | ||
const tabPanel1 = el.querySelector( | ||
'sp-tab-panel[value="first"]' | ||
); | ||
const tabPanel2 = el.querySelector( | ||
'sp-tab-panel[value="second"]' | ||
); | ||
const tabPanel3 = el.querySelector( | ||
'sp-tab-panel[value="third"]' | ||
); | ||
const actionGroup1 = tabPanel1.querySelector( | ||
"sp-action-group" | ||
); | ||
const actionGroup2 = tabPanel2.querySelector( | ||
"sp-action-group" | ||
); | ||
const actionGroup3 = tabPanel3.querySelector( | ||
"sp-action-group" | ||
); | ||
const actionButton1 = actionGroup1.querySelector( | ||
"[selected]" | ||
); | ||
const actionButton2 = actionGroup2.querySelector( | ||
"[selected]" | ||
); | ||
const actionButton3 = actionGroup3.querySelector( | ||
"[selected]" | ||
); | ||
el.focus(); | ||
expect(el.contains(document.activeElement)).to.be.true; | ||
expect(document.activeElement === tab2).to.be.true; | ||
actionGroup2.focus(); | ||
expect(document.activeElement === actionButton2).to.be.true; | ||
await nextFrame(); | ||
await sendKeys({ | ||
press: "ArrowLeft" | ||
}); | ||
expect(document.activeElement === tab1).to.be.false; | ||
expect(actionGroup2.contains(document.activeElement)).to.be.true; | ||
el.focus(); | ||
expect(document.activeElement === tab2).to.be.true; | ||
await sendKeys({ | ||
press: "ArrowRight" | ||
}); | ||
expect(document.activeElement === tab3).to.be.true; | ||
await sendKeys({ | ||
press: "Enter" | ||
}); | ||
expect(document.activeElement === tab3).to.be.true; | ||
actionGroup3.focus(); | ||
expect(document.activeElement === actionButton3).to.be.true; | ||
await sendKeys({ | ||
press: "ArrowLeft" | ||
}); | ||
expect(document.activeElement === tab2).to.be.false; | ||
expect(actionGroup3.contains(document.activeElement)).to.be.true; | ||
const boundingRect = tab1.getBoundingClientRect(); | ||
await sendMouse({ | ||
steps: [ | ||
{ | ||
type: "click", | ||
position: [ | ||
boundingRect.left + boundingRect.width / 2, | ||
boundingRect.top + boundingRect.height / 2 | ||
] | ||
} | ||
] | ||
}); | ||
expect(document.activeElement === tab1).to.be.true; | ||
actionGroup1.focus(); | ||
expect(document.activeElement === actionButton1).to.be.true; | ||
await sendKeys({ | ||
press: "ArrowRight" | ||
}); | ||
expect(document.activeElement === tab2).to.be.false; | ||
expect(actionGroup1.contains(document.activeElement)).to.be.true; | ||
}); | ||
}); | ||
//# sourceMappingURL=roving-tabindex-integration.test.js.map |
@@ -1,2 +0,19 @@ | ||
import{LitElement as s}from"lit";import{expect as t}from"@open-wc/testing";import{RovingTabindexController as i}from"@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";describe("RovingTabindex",()=>{it("constructs with defaults",async()=>{class o extends s{}customElements.define("test-roving-tabindex-el",o);const n=new o,e=new i(n);t(e.direction).to.equal("both"),t(e.focusInIndex).to.equal(0),t(e.isFocusableElement(n)).to.be.true})}); | ||
"use strict"; | ||
import { LitElement } from "lit"; | ||
import { expect } from "@open-wc/testing"; | ||
import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js"; | ||
describe("RovingTabindex", () => { | ||
it("constructs with defaults", async () => { | ||
class TestEl extends LitElement { | ||
} | ||
customElements.define("test-roving-tabindex-el", TestEl); | ||
const el = new TestEl(); | ||
const controller = new RovingTabindexController( | ||
el | ||
); | ||
expect(controller.direction).to.equal("both"); | ||
expect(controller.focusInIndex).to.equal(0); | ||
expect(controller.isFocusableElement(el)).to.be.true; | ||
}); | ||
}); | ||
//# sourceMappingURL=roving-tabindex.test.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
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
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 4 instances 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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
149586
41
955
12