@spectrum-web-components/reactive-controllers 0.2.6-devmode.0 → 0.3.0
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/package.json +2 -2
- package/src/FocusGroup.js +1 -216
- package/src/FocusGroup.js.map +1 -1
- package/src/MatchMedia.js +1 -25
- package/src/MatchMedia.js.map +1 -1
- package/src/RovingTabindex.js +1 -64
- package/src/RovingTabindex.js.map +1 -1
- package/src/index.js +1 -2
- package/src/index.js.map +1 -1
- package/test/match-media.test.js +2 -18
- package/test/match-media.test.js.map +1 -1
- package/test/roving-tabindex-integration.test.js +2 -80
- package/test/roving-tabindex-integration.test.js.map +1 -1
- package/test/roving-tabindex.test.js +1 -15
- package/test/roving-tabindex.test.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/reactive-controllers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"sideEffects": [
|
|
69
69
|
"./**/*.dev.js"
|
|
70
70
|
],
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "05c81318844160db3f8156144106e643507fef97"
|
|
72
72
|
}
|
package/src/FocusGroup.js
CHANGED
|
@@ -1,217 +1,2 @@
|
|
|
1
|
-
export class FocusGroupController {
|
|
2
|
-
constructor(host, {
|
|
3
|
-
direction,
|
|
4
|
-
elementEnterAction,
|
|
5
|
-
elements,
|
|
6
|
-
focusInIndex,
|
|
7
|
-
isFocusableElement,
|
|
8
|
-
listenerScope
|
|
9
|
-
} = { elements: () => [] }) {
|
|
10
|
-
this._currentIndex = -1;
|
|
11
|
-
this._direction = () => "both";
|
|
12
|
-
this.directionLength = 5;
|
|
13
|
-
this.elementEnterAction = (_el) => {
|
|
14
|
-
return;
|
|
15
|
-
};
|
|
16
|
-
this._focused = false;
|
|
17
|
-
this._focusInIndex = (_elements) => 0;
|
|
18
|
-
this.isFocusableElement = (_el) => true;
|
|
19
|
-
this._listenerScope = () => this.host;
|
|
20
|
-
this.offset = 0;
|
|
21
|
-
this.handleFocusin = (event) => {
|
|
22
|
-
if (!this.isEventWithinListenerScope(event))
|
|
23
|
-
return;
|
|
24
|
-
if (this.isRelatedTargetAnElement(event)) {
|
|
25
|
-
this.hostContainsFocus();
|
|
26
|
-
}
|
|
27
|
-
const path = event.composedPath();
|
|
28
|
-
let targetIndex = -1;
|
|
29
|
-
path.find((el) => {
|
|
30
|
-
targetIndex = this.elements.indexOf(el);
|
|
31
|
-
return targetIndex !== -1;
|
|
32
|
-
});
|
|
33
|
-
this.currentIndex = targetIndex > -1 ? targetIndex : this.currentIndex;
|
|
34
|
-
};
|
|
35
|
-
this.handleFocusout = (event) => {
|
|
36
|
-
if (this.isRelatedTargetAnElement(event)) {
|
|
37
|
-
this.hostNoLongerContainsFocus();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
this.handleKeydown = (event) => {
|
|
41
|
-
if (!this.acceptsEventCode(event.code) || event.defaultPrevented) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
let diff = 0;
|
|
45
|
-
switch (event.code) {
|
|
46
|
-
case "ArrowRight":
|
|
47
|
-
diff += 1;
|
|
48
|
-
break;
|
|
49
|
-
case "ArrowDown":
|
|
50
|
-
diff += this.direction === "grid" ? this.directionLength : 1;
|
|
51
|
-
break;
|
|
52
|
-
case "ArrowLeft":
|
|
53
|
-
diff -= 1;
|
|
54
|
-
break;
|
|
55
|
-
case "ArrowUp":
|
|
56
|
-
diff -= this.direction === "grid" ? this.directionLength : 1;
|
|
57
|
-
break;
|
|
58
|
-
case "End":
|
|
59
|
-
this.currentIndex = 0;
|
|
60
|
-
diff -= 1;
|
|
61
|
-
break;
|
|
62
|
-
case "Home":
|
|
63
|
-
this.currentIndex = this.elements.length - 1;
|
|
64
|
-
diff += 1;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
event.preventDefault();
|
|
68
|
-
if (this.direction === "grid" && this.currentIndex + diff < 0) {
|
|
69
|
-
this.currentIndex = 0;
|
|
70
|
-
} else if (this.direction === "grid" && this.currentIndex + diff > this.elements.length - 1) {
|
|
71
|
-
this.currentIndex = this.elements.length - 1;
|
|
72
|
-
} else {
|
|
73
|
-
this.setCurrentIndexCircularly(diff);
|
|
74
|
-
}
|
|
75
|
-
this.elementEnterAction(this.elements[this.currentIndex]);
|
|
76
|
-
this.focus();
|
|
77
|
-
};
|
|
78
|
-
this.host = host;
|
|
79
|
-
this.host.addController(this);
|
|
80
|
-
this._elements = elements;
|
|
81
|
-
this.isFocusableElement = isFocusableElement || this.isFocusableElement;
|
|
82
|
-
if (typeof direction === "string") {
|
|
83
|
-
this._direction = () => direction;
|
|
84
|
-
} else if (typeof direction === "function") {
|
|
85
|
-
this._direction = direction;
|
|
86
|
-
}
|
|
87
|
-
this.elementEnterAction = elementEnterAction || this.elementEnterAction;
|
|
88
|
-
if (typeof focusInIndex === "number") {
|
|
89
|
-
this._focusInIndex = () => focusInIndex;
|
|
90
|
-
} else if (typeof focusInIndex === "function") {
|
|
91
|
-
this._focusInIndex = focusInIndex;
|
|
92
|
-
}
|
|
93
|
-
if (typeof listenerScope === "object") {
|
|
94
|
-
this._listenerScope = () => listenerScope;
|
|
95
|
-
} else if (typeof listenerScope === "function") {
|
|
96
|
-
this._listenerScope = listenerScope;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
get currentIndex() {
|
|
100
|
-
if (this._currentIndex === -1) {
|
|
101
|
-
this._currentIndex = this.focusInIndex;
|
|
102
|
-
}
|
|
103
|
-
return this._currentIndex - this.offset;
|
|
104
|
-
}
|
|
105
|
-
set currentIndex(currentIndex) {
|
|
106
|
-
this._currentIndex = currentIndex + this.offset;
|
|
107
|
-
}
|
|
108
|
-
get direction() {
|
|
109
|
-
return this._direction();
|
|
110
|
-
}
|
|
111
|
-
get elements() {
|
|
112
|
-
if (!this.cachedElements) {
|
|
113
|
-
this.cachedElements = this._elements();
|
|
114
|
-
}
|
|
115
|
-
return this.cachedElements;
|
|
116
|
-
}
|
|
117
|
-
set focused(focused) {
|
|
118
|
-
if (focused === this.focused)
|
|
119
|
-
return;
|
|
120
|
-
this._focused = focused;
|
|
121
|
-
}
|
|
122
|
-
get focused() {
|
|
123
|
-
return this._focused;
|
|
124
|
-
}
|
|
125
|
-
get focusInElement() {
|
|
126
|
-
return this.elements[this.focusInIndex];
|
|
127
|
-
}
|
|
128
|
-
get focusInIndex() {
|
|
129
|
-
return this._focusInIndex(this.elements);
|
|
130
|
-
}
|
|
131
|
-
isEventWithinListenerScope(event) {
|
|
132
|
-
if (this._listenerScope() === this.host)
|
|
133
|
-
return true;
|
|
134
|
-
return event.composedPath().includes(this._listenerScope());
|
|
135
|
-
}
|
|
136
|
-
update({ elements } = { elements: () => [] }) {
|
|
137
|
-
this.unmanage();
|
|
138
|
-
this._elements = elements;
|
|
139
|
-
this.clearElementCache();
|
|
140
|
-
this.manage();
|
|
141
|
-
}
|
|
142
|
-
focus(options) {
|
|
143
|
-
let focusElement = this.elements[this.currentIndex];
|
|
144
|
-
if (!focusElement || !this.isFocusableElement(focusElement)) {
|
|
145
|
-
this.setCurrentIndexCircularly(1);
|
|
146
|
-
focusElement = this.elements[this.currentIndex];
|
|
147
|
-
}
|
|
148
|
-
if (focusElement && this.isFocusableElement(focusElement)) {
|
|
149
|
-
focusElement.focus(options);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
clearElementCache(offset = 0) {
|
|
153
|
-
delete this.cachedElements;
|
|
154
|
-
this.offset = offset;
|
|
155
|
-
}
|
|
156
|
-
setCurrentIndexCircularly(diff) {
|
|
157
|
-
const { length } = this.elements;
|
|
158
|
-
let steps = length;
|
|
159
|
-
let nextIndex = (length + this.currentIndex + diff) % length;
|
|
160
|
-
while (steps && this.elements[nextIndex] && !this.isFocusableElement(this.elements[nextIndex])) {
|
|
161
|
-
nextIndex = (length + nextIndex + diff) % length;
|
|
162
|
-
steps -= 1;
|
|
163
|
-
}
|
|
164
|
-
this.currentIndex = nextIndex;
|
|
165
|
-
}
|
|
166
|
-
hostContainsFocus() {
|
|
167
|
-
this.host.addEventListener("focusout", this.handleFocusout);
|
|
168
|
-
this.host.addEventListener("keydown", this.handleKeydown);
|
|
169
|
-
this.focused = true;
|
|
170
|
-
}
|
|
171
|
-
hostNoLongerContainsFocus() {
|
|
172
|
-
this.host.addEventListener("focusin", this.handleFocusin);
|
|
173
|
-
this.host.removeEventListener("focusout", this.handleFocusout);
|
|
174
|
-
this.host.removeEventListener("keydown", this.handleKeydown);
|
|
175
|
-
this.currentIndex = this.focusInIndex;
|
|
176
|
-
this.focused = false;
|
|
177
|
-
}
|
|
178
|
-
isRelatedTargetAnElement(event) {
|
|
179
|
-
const relatedTarget = event.relatedTarget;
|
|
180
|
-
return !this.elements.includes(relatedTarget);
|
|
181
|
-
}
|
|
182
|
-
acceptsEventCode(code) {
|
|
183
|
-
if (code === "End" || code === "Home") {
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
switch (this.direction) {
|
|
187
|
-
case "horizontal":
|
|
188
|
-
return code === "ArrowLeft" || code === "ArrowRight";
|
|
189
|
-
case "vertical":
|
|
190
|
-
return code === "ArrowUp" || code === "ArrowDown";
|
|
191
|
-
case "both":
|
|
192
|
-
case "grid":
|
|
193
|
-
return code.startsWith("Arrow");
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
manage() {
|
|
197
|
-
this.addEventListeners();
|
|
198
|
-
}
|
|
199
|
-
unmanage() {
|
|
200
|
-
this.removeEventListeners();
|
|
201
|
-
}
|
|
202
|
-
addEventListeners() {
|
|
203
|
-
this.host.addEventListener("focusin", this.handleFocusin);
|
|
204
|
-
}
|
|
205
|
-
removeEventListeners() {
|
|
206
|
-
this.host.removeEventListener("focusin", this.handleFocusin);
|
|
207
|
-
this.host.removeEventListener("focusout", this.handleFocusout);
|
|
208
|
-
this.host.removeEventListener("keydown", this.handleKeydown);
|
|
209
|
-
}
|
|
210
|
-
hostConnected() {
|
|
211
|
-
this.addEventListeners();
|
|
212
|
-
}
|
|
213
|
-
hostDisconnected() {
|
|
214
|
-
this.removeEventListeners();
|
|
215
|
-
}
|
|
216
|
-
}
|
|
1
|
+
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()}}
|
|
217
2
|
//# sourceMappingURL=FocusGroup.js.map
|
package/src/FocusGroup.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["FocusGroup.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { ReactiveController, ReactiveElement } from 'lit';\n\ntype DirectionTypes = 'horizontal' | 'vertical' | 'both' | 'grid';\nexport type FocusGroupConfig<T> = {\n focusInIndex?: (_elements: T[]) => number;\n direction?: DirectionTypes | (() => DirectionTypes);\n elementEnterAction?: (el: T) => void;\n elements: () => T[];\n isFocusableElement?: (el: T) => boolean;\n listenerScope?: HTMLElement | (() => HTMLElement);\n};\n\nexport class FocusGroupController<T extends HTMLElement>\n implements ReactiveController\n{\n protected cachedElements?: T[];\n\n get currentIndex(): number {\n if (this._currentIndex === -1) {\n this._currentIndex = this.focusInIndex;\n }\n return this._currentIndex - this.offset;\n }\n\n set currentIndex(currentIndex) {\n this._currentIndex = currentIndex + this.offset;\n }\n\n private _currentIndex = -1;\n\n get direction(): DirectionTypes {\n return this._direction();\n }\n\n _direction = (): DirectionTypes => 'both';\n\n public directionLength = 5;\n\n elementEnterAction = (_el: T): void => {\n return;\n };\n\n get elements(): T[] {\n if (!this.cachedElements) {\n this.cachedElements = this._elements();\n }\n return this.cachedElements;\n }\n\n private _elements!: () => T[];\n\n protected set focused(focused: boolean) {\n if (focused === this.focused) return;\n this._focused = focused;\n }\n\n protected get focused(): boolean {\n return this._focused;\n }\n\n private _focused = false;\n\n get focusInElement(): T {\n return this.elements[this.focusInIndex];\n }\n\n get focusInIndex(): number {\n return this._focusInIndex(this.elements);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _focusInIndex = (_elements: T[]): number => 0;\n\n host: ReactiveElement;\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isFocusableElement = (_el: T): boolean => true;\n\n isEventWithinListenerScope(event: Event): boolean {\n if (this._listenerScope() === this.host) return true;\n return event.composedPath().includes(this._listenerScope());\n }\n\n _listenerScope = (): HTMLElement => this.host;\n\n // When elements are virtualized, the delta between the first element\n // and the first rendered element.\n offset = 0;\n\n constructor(\n host: ReactiveElement,\n {\n direction,\n elementEnterAction,\n elements,\n focusInIndex,\n isFocusableElement,\n listenerScope,\n }: FocusGroupConfig<T> = { elements: () => [] }\n ) {\n this.host = host;\n this.host.addController(this);\n this._elements = elements;\n this.isFocusableElement = isFocusableElement || this.isFocusableElement;\n // @TODO: abstract a method to simplify the conditional wrapping of the values as functions.\n if (typeof direction === 'string') {\n this._direction = () => direction;\n } else if (typeof direction === 'function') {\n this._direction = direction;\n }\n this.elementEnterAction = elementEnterAction || this.elementEnterAction;\n if (typeof focusInIndex === 'number') {\n this._focusInIndex = () => focusInIndex;\n } else if (typeof focusInIndex === 'function') {\n this._focusInIndex = focusInIndex;\n }\n if (typeof listenerScope === 'object') {\n this._listenerScope = () => listenerScope;\n } else if (typeof listenerScope === 'function') {\n this._listenerScope = listenerScope;\n }\n }\n\n update({ elements }: FocusGroupConfig<T> = { elements: () => [] }): void {\n this.unmanage();\n this._elements = elements;\n this.clearElementCache();\n this.manage();\n }\n\n focus(options?: FocusOptions): void {\n let focusElement = this.elements[this.currentIndex];\n if (!focusElement || !this.isFocusableElement(focusElement)) {\n this.setCurrentIndexCircularly(1);\n focusElement = this.elements[this.currentIndex];\n }\n if (focusElement && this.isFocusableElement(focusElement)) {\n focusElement.focus(options);\n }\n }\n\n clearElementCache(offset = 0): void {\n delete this.cachedElements;\n this.offset = offset;\n }\n\n setCurrentIndexCircularly(diff: number): void {\n const { length } = this.elements;\n let steps = length;\n // start at a possibly not 0 index\n let nextIndex = (length + this.currentIndex + diff) % length;\n while (\n // don't cycle the elements more than once\n steps &&\n this.elements[nextIndex] &&\n !this.isFocusableElement(this.elements[nextIndex])\n ) {\n nextIndex = (length + nextIndex + diff) % length;\n steps -= 1;\n }\n this.currentIndex = nextIndex;\n }\n\n hostContainsFocus(): void {\n this.host.addEventListener('focusout', this.handleFocusout);\n this.host.addEventListener('keydown', this.handleKeydown);\n this.focused = true;\n }\n\n hostNoLongerContainsFocus(): void {\n this.host.addEventListener('focusin', this.handleFocusin);\n this.host.removeEventListener('focusout', this.handleFocusout);\n this.host.removeEventListener('keydown', this.handleKeydown);\n this.currentIndex = this.focusInIndex;\n this.focused = false;\n }\n\n isRelatedTargetAnElement(event: FocusEvent): boolean {\n const relatedTarget = event.relatedTarget as null | Element;\n return !this.elements.includes(relatedTarget as T);\n }\n\n handleFocusin = (event: FocusEvent): void => {\n if (!this.isEventWithinListenerScope(event)) return;\n if (this.isRelatedTargetAnElement(event)) {\n this.hostContainsFocus();\n }\n const path = event.composedPath() as T[];\n let targetIndex = -1;\n path.find((el) => {\n targetIndex = this.elements.indexOf(el);\n return targetIndex !== -1;\n });\n this.currentIndex = targetIndex > -1 ? targetIndex : this.currentIndex;\n };\n\n handleFocusout = (event: FocusEvent): void => {\n if (this.isRelatedTargetAnElement(event)) {\n this.hostNoLongerContainsFocus();\n }\n };\n\n acceptsEventCode(code: string): boolean {\n if (code === 'End' || code === 'Home') {\n return true;\n }\n switch (this.direction) {\n case 'horizontal':\n return code === 'ArrowLeft' || code === 'ArrowRight';\n case 'vertical':\n return code === 'ArrowUp' || code === 'ArrowDown';\n case 'both':\n case 'grid':\n return code.startsWith('Arrow');\n }\n }\n\n handleKeydown = (event: KeyboardEvent): void => {\n if (!this.acceptsEventCode(event.code) || event.defaultPrevented) {\n return;\n }\n let diff = 0;\n switch (event.code) {\n case 'ArrowRight':\n diff += 1;\n break;\n case 'ArrowDown':\n diff += this.direction === 'grid' ? this.directionLength : 1;\n break;\n case 'ArrowLeft':\n diff -= 1;\n break;\n case 'ArrowUp':\n diff -= this.direction === 'grid' ? this.directionLength : 1;\n break;\n case 'End':\n this.currentIndex = 0;\n diff -= 1;\n break;\n case 'Home':\n this.currentIndex = this.elements.length - 1;\n diff += 1;\n break;\n }\n event.preventDefault();\n if (this.direction === 'grid' && this.currentIndex + diff < 0) {\n this.currentIndex = 0;\n } else if (\n this.direction === 'grid' &&\n this.currentIndex + diff > this.elements.length - 1\n ) {\n this.currentIndex = this.elements.length - 1;\n } else {\n this.setCurrentIndexCircularly(diff);\n }\n // To allow the `focusInIndex` to be calculated with the \"after\" state of the keyboard interaction\n // do `elementEnterAction` _before_ focusing the next element.\n this.elementEnterAction(this.elements[this.currentIndex]);\n this.focus();\n };\n\n manage(): void {\n this.addEventListeners();\n }\n\n unmanage(): void {\n this.removeEventListeners();\n }\n\n addEventListeners(): void {\n this.host.addEventListener('focusin', this.handleFocusin);\n }\n\n removeEventListeners(): void {\n this.host.removeEventListener('focusin', this.handleFocusin);\n this.host.removeEventListener('focusout', this.handleFocusout);\n this.host.removeEventListener('keydown', this.handleKeydown);\n }\n\n hostConnected(): void {\n this.addEventListeners();\n }\n\n hostDisconnected(): void {\n this.removeEventListeners();\n }\n}\n"],
|
|
5
|
-
"mappings": "AAuBO,aAAM,
|
|
5
|
+
"mappings": "AAuBO,aAAM,oBAEb,CA2EI,YACI,EACA,CACI,YACA,qBACA,WACA,eACA,qBACA,iBACqB,CAAE,SAAU,IAAM,CAAC,CAAE,EAChD,CAvEM,mBAAgB,GAMxB,gBAAa,IAAsB,OAE5B,qBAAkB,EAEzB,wBAAqB,AAAC,GAAiB,CA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,KAAK,KAAK,oBAAoB,UAAW,KAAK,aAAa,EAC3D,KAAK,KAAK,oBAAoB,WAAY,KAAK,cAAc,EAC7D,KAAK,KAAK,oBAAoB,UAAW,KAAK,aAAa,CAC/D,CAEA,eAAsB,CAClB,KAAK,kBAAkB,CAC3B,CAEA,kBAAyB,CACrB,KAAK,qBAAqB,CAC9B,CACJ",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/MatchMedia.js
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
export const DARK_MODE
|
|
2
|
-
export const IS_MOBILE = "(max-width: 700px) and (hover: none) and (pointer: coarse), (max-height: 700px) and (hover: none) and (pointer: coarse)";
|
|
3
|
-
export class MatchMediaController {
|
|
4
|
-
constructor(host, query) {
|
|
5
|
-
this.key = Symbol("match-media-key");
|
|
6
|
-
this.matches = false;
|
|
7
|
-
this.host = host;
|
|
8
|
-
this.media = window.matchMedia(query);
|
|
9
|
-
this.matches = this.media.matches;
|
|
10
|
-
this.onChange = this.onChange.bind(this);
|
|
11
|
-
host.addController(this);
|
|
12
|
-
}
|
|
13
|
-
hostConnected() {
|
|
14
|
-
this.media.addEventListener("change", this.onChange);
|
|
15
|
-
}
|
|
16
|
-
hostDisconnected() {
|
|
17
|
-
this.media.removeEventListener("change", this.onChange);
|
|
18
|
-
}
|
|
19
|
-
onChange(event) {
|
|
20
|
-
if (this.matches === event.matches)
|
|
21
|
-
return;
|
|
22
|
-
this.matches = event.matches;
|
|
23
|
-
this.host.requestUpdate(this.key, !this.matches);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
1
|
+
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))}}
|
|
26
2
|
//# sourceMappingURL=MatchMedia.js.map
|
package/src/MatchMedia.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["MatchMedia.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { ReactiveController, ReactiveElement } from 'lit';\n\nexport const DARK_MODE = '(prefers-color-scheme: dark)';\nexport const IS_MOBILE =\n '(max-width: 700px) and (hover: none) and (pointer: coarse), (max-height: 700px) and (hover: none) and (pointer: coarse)';\n\nexport class MatchMediaController implements ReactiveController {\n key = Symbol('match-media-key');\n\n matches = false;\n\n protected host: ReactiveElement;\n\n protected media: MediaQueryList;\n\n constructor(host: ReactiveElement, query: string) {\n this.host = host;\n this.media = window.matchMedia(query);\n this.matches = this.media.matches;\n this.onChange = this.onChange.bind(this);\n host.addController(this);\n }\n\n public hostConnected(): void {\n this.media.addEventListener('change', this.onChange);\n }\n\n public hostDisconnected(): void {\n this.media.removeEventListener('change', this.onChange);\n }\n\n protected onChange(event: MediaQueryListEvent): void {\n if (this.matches === event.matches) return;\n this.matches = event.matches;\n this.host.requestUpdate(this.key, !this.matches);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAaO,
|
|
5
|
+
"mappings": "AAaO,YAAM,WAAY,+BACZ,UACT,0HAEG,aAAM,oBAAmD,CAS5D,YAAY,EAAuB,EAAe,CARlD,SAAM,OAAO,iBAAiB,EAE9B,aAAU,GAON,KAAK,KAAO,EACZ,KAAK,MAAQ,OAAO,WAAW,CAAK,EACpC,KAAK,QAAU,KAAK,MAAM,QAC1B,KAAK,SAAW,KAAK,SAAS,KAAK,IAAI,EACvC,EAAK,cAAc,IAAI,CAC3B,CAEO,eAAsB,CACzB,KAAK,MAAM,iBAAiB,SAAU,KAAK,QAAQ,CACvD,CAEO,kBAAyB,CAC5B,KAAK,MAAM,oBAAoB,SAAU,KAAK,QAAQ,CAC1D,CAEU,SAAS,EAAkC,CACjD,AAAI,KAAK,UAAY,EAAM,SAC3B,MAAK,QAAU,EAAM,QACrB,KAAK,KAAK,cAAc,KAAK,IAAK,CAAC,KAAK,OAAO,EACnD,CACJ",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/RovingTabindex.js
CHANGED
|
@@ -1,65 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export class RovingTabindexController extends FocusGroupController {
|
|
3
|
-
constructor() {
|
|
4
|
-
super(...arguments);
|
|
5
|
-
this.managed = true;
|
|
6
|
-
this.manageIndexesAnimationFrame = 0;
|
|
7
|
-
}
|
|
8
|
-
set focused(focused) {
|
|
9
|
-
if (focused === this.focused)
|
|
10
|
-
return;
|
|
11
|
-
super.focused = focused;
|
|
12
|
-
this.manageTabindexes();
|
|
13
|
-
}
|
|
14
|
-
get focused() {
|
|
15
|
-
return super.focused;
|
|
16
|
-
}
|
|
17
|
-
clearElementCache(offset = 0) {
|
|
18
|
-
cancelAnimationFrame(this.manageIndexesAnimationFrame);
|
|
19
|
-
super.clearElementCache(offset);
|
|
20
|
-
if (!this.managed)
|
|
21
|
-
return;
|
|
22
|
-
this.manageIndexesAnimationFrame = requestAnimationFrame(() => this.manageTabindexes());
|
|
23
|
-
}
|
|
24
|
-
manageTabindexes() {
|
|
25
|
-
if (this.focused) {
|
|
26
|
-
this.updateTabindexes(() => ({ tabIndex: -1 }));
|
|
27
|
-
} else {
|
|
28
|
-
this.updateTabindexes((el) => {
|
|
29
|
-
return {
|
|
30
|
-
removeTabIndex: el.contains(this.focusInElement) && el !== this.focusInElement,
|
|
31
|
-
tabIndex: el === this.focusInElement ? 0 : -1
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
updateTabindexes(getTabIndex) {
|
|
37
|
-
this.elements.forEach((el) => {
|
|
38
|
-
const { tabIndex, removeTabIndex } = getTabIndex(el);
|
|
39
|
-
if (!removeTabIndex) {
|
|
40
|
-
el.tabIndex = tabIndex;
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
el.removeAttribute("tabindex");
|
|
44
|
-
const updatable = el;
|
|
45
|
-
if (updatable.requestUpdate)
|
|
46
|
-
updatable.requestUpdate();
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
manage() {
|
|
50
|
-
this.managed = true;
|
|
51
|
-
this.manageTabindexes();
|
|
52
|
-
super.manage();
|
|
53
|
-
}
|
|
54
|
-
unmanage() {
|
|
55
|
-
this.managed = false;
|
|
56
|
-
this.updateTabindexes(() => ({ tabIndex: 0 }));
|
|
57
|
-
super.unmanage();
|
|
58
|
-
}
|
|
59
|
-
hostUpdated() {
|
|
60
|
-
if (!this.host.hasUpdated) {
|
|
61
|
-
this.manageTabindexes();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
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()}}
|
|
65
2
|
//# sourceMappingURL=RovingTabindex.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["RovingTabindex.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { FocusGroupConfig, FocusGroupController } from './FocusGroup.js';\n\nexport type RovingTabindexConfig<T> = FocusGroupConfig<T>;\ninterface UpdateTabIndexes {\n tabIndex: number;\n removeTabIndex?: boolean;\n}\n\nexport class RovingTabindexController<\n T extends HTMLElement\n> extends FocusGroupController<T> {\n protected override set focused(focused: boolean) {\n if (focused === this.focused) return;\n super.focused = focused;\n this.manageTabindexes();\n }\n\n protected override get focused(): boolean {\n return super.focused;\n }\n\n private managed = true;\n\n private manageIndexesAnimationFrame = 0;\n\n override clearElementCache(offset = 0): void {\n cancelAnimationFrame(this.manageIndexesAnimationFrame);\n super.clearElementCache(offset);\n if (!this.managed) return;\n\n this.manageIndexesAnimationFrame = requestAnimationFrame(() =>\n this.manageTabindexes()\n );\n }\n\n manageTabindexes(): void {\n if (this.focused) {\n this.updateTabindexes(() => ({ tabIndex: -1 }));\n } else {\n this.updateTabindexes((el: HTMLElement): UpdateTabIndexes => {\n return {\n removeTabIndex:\n el.contains(this.focusInElement) &&\n el !== this.focusInElement,\n tabIndex: el === this.focusInElement ? 0 : -1,\n };\n });\n }\n }\n\n updateTabindexes(getTabIndex: (el: HTMLElement) => UpdateTabIndexes): void {\n this.elements.forEach((el) => {\n const { tabIndex, removeTabIndex } = getTabIndex(el);\n if (!removeTabIndex) {\n el.tabIndex = tabIndex;\n return;\n }\n el.removeAttribute('tabindex');\n const updatable = el as unknown as {\n requestUpdate?: () => void;\n };\n if (updatable.requestUpdate) updatable.requestUpdate();\n });\n }\n\n override manage(): void {\n this.managed = true;\n this.manageTabindexes();\n super.manage();\n }\n\n override unmanage(): void {\n this.managed = false;\n this.updateTabindexes(() => ({ tabIndex: 0 }));\n super.unmanage();\n }\n\n hostUpdated(): void {\n if (!this.host.hasUpdated) {\n this.manageTabindexes();\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAWA
|
|
5
|
+
"mappings": "AAWA,uDAQO,aAAM,gCAEH,EAAwB,CAF3B,kCAaK,aAAU,GAEV,iCAA8B,KAZf,SAAQ,EAAkB,CAC7C,AAAI,IAAY,KAAK,SACrB,OAAM,QAAU,EAChB,KAAK,iBAAiB,EAC1B,IAEuB,UAAmB,CACtC,MAAO,OAAM,OACjB,CAMS,kBAAkB,EAAS,EAAS,CAGzC,AAFA,qBAAqB,KAAK,2BAA2B,EACrD,MAAM,kBAAkB,CAAM,EAC1B,AAAC,KAAK,SAEV,MAAK,4BAA8B,sBAAsB,IACrD,KAAK,iBAAiB,CAC1B,EACJ,CAEA,kBAAyB,CACrB,AAAI,KAAK,QACL,KAAK,iBAAiB,IAAO,EAAE,SAAU,EAAG,EAAE,EAE9C,KAAK,iBAAiB,AAAC,GACZ,EACH,eACI,EAAG,SAAS,KAAK,cAAc,GAC/B,IAAO,KAAK,eAChB,SAAU,IAAO,KAAK,eAAiB,EAAI,EAC/C,EACH,CAET,CAEA,iBAAiB,EAA0D,CACvE,KAAK,SAAS,QAAQ,AAAC,GAAO,CAC1B,KAAM,CAAE,WAAU,kBAAmB,EAAY,CAAE,EACnD,GAAI,CAAC,EAAgB,CACjB,EAAG,SAAW,EACd,MACJ,CACA,EAAG,gBAAgB,UAAU,EAC7B,KAAM,GAAY,EAGlB,AAAI,EAAU,eAAe,EAAU,cAAc,CACzD,CAAC,CACL,CAES,QAAe,CACpB,KAAK,QAAU,GACf,KAAK,iBAAiB,EACtB,MAAM,OAAO,CACjB,CAES,UAAiB,CACtB,KAAK,QAAU,GACf,KAAK,iBAAiB,IAAO,EAAE,SAAU,CAAE,EAAE,EAC7C,MAAM,SAAS,CACnB,CAEA,aAAoB,CAChB,AAAK,KAAK,KAAK,YACX,KAAK,iBAAiB,CAE9B,CACJ",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/index.js
CHANGED
package/src/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nexport * from './MatchMedia.js';\nexport * from './RovingTabindex.js';\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,6BACA",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/match-media.test.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { expect, fixture, nextFrame } from "@open-wc/testing";
|
|
3
|
-
import { setViewport } from "@web/test-runner-commands";
|
|
4
|
-
import { MatchMediaController } from "@spectrum-web-components/reactive-controllers/src/MatchMedia.js";
|
|
5
|
-
describe("Match Media", () => {
|
|
6
|
-
it("responds to media changes", async () => {
|
|
7
|
-
class TestEl extends LitElement {
|
|
8
|
-
}
|
|
9
|
-
customElements.define("test-match-media-el", TestEl);
|
|
10
|
-
const el = await fixture(html`
|
|
1
|
+
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`
|
|
11
2
|
<test-match-media-el></test-match-media-el>
|
|
12
|
-
`);
|
|
13
|
-
const controller = new MatchMediaController(el, "(min-width: 500px)");
|
|
14
|
-
expect(controller.matches).to.be.true;
|
|
15
|
-
await setViewport({ width: 360, height: 640 });
|
|
16
|
-
await nextFrame();
|
|
17
|
-
expect(controller.matches).to.be.false;
|
|
18
|
-
});
|
|
19
|
-
});
|
|
3
|
+
`),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})});
|
|
20
4
|
//# sourceMappingURL=match-media.test.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["match-media.test.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { html, LitElement } from 'lit';\nimport { expect, fixture, nextFrame } from '@open-wc/testing';\nimport { setViewport } from '@web/test-runner-commands';\nimport { MatchMediaController } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';\n\ndescribe('Match Media', () => {\n it('responds to media changes', async () => {\n class TestEl extends LitElement {}\n customElements.define('test-match-media-el', TestEl);\n const el = await fixture(\n html`\n <test-match-media-el></test-match-media-el>\n `\n );\n const controller = new MatchMediaController(\n el as LitElement & { shadowRoot: ShadowRoot },\n '(min-width: 500px)'\n );\n expect(controller.matches).to.be.true;\n await setViewport({ width: 360, height: 640 });\n // Allow viewport update to propagate.\n await nextFrame();\n expect(controller.matches).to.be.false;\n });\n});\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,2CACA,sEACA,wDACA,uGAEA,SAAS,cAAe,IAAM,CAC1B,GAAG,4BAA6B,SAAY,CACxC,MAAM,SAAe,EAAW,CAAC,CACjC,eAAe,OAAO,sBAAuB,CAAM,EACnD,KAAM,GAAK,KAAM,GACb;AAAA;AAAA,aAGJ,EACM,EAAa,GAAI,GACnB,EACA,oBACJ,EACA,EAAO,EAAW,OAAO,EAAE,GAAG,GAAG,KACjC,KAAM,GAAY,CAAE,MAAO,IAAK,OAAQ,GAAI,CAAC,EAE7C,KAAM,GAAU,EAChB,EAAO,EAAW,OAAO,EAAE,GAAG,GAAG,KACrC,CAAC,CACL,CAAC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "@spectrum-web-components/action-group/sp-action-group.js";
|
|
3
|
-
import "@spectrum-web-components/tabs/sp-tab-panel.js";
|
|
4
|
-
import "@spectrum-web-components/tabs/sp-tab.js";
|
|
5
|
-
import "@spectrum-web-components/tabs/sp-tabs.js";
|
|
6
|
-
import { elementUpdated, expect, fixture, nextFrame } from "@open-wc/testing";
|
|
7
|
-
import { html } from "@spectrum-web-components/base";
|
|
8
|
-
import { sendKeys } from "@web/test-runner-commands";
|
|
9
|
-
import { sendMouse } from "../../../test/plugins/browser.js";
|
|
10
|
-
const createTabs = async () => {
|
|
11
|
-
const tabs = await fixture(html`
|
|
1
|
+
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`
|
|
12
2
|
<sp-tabs selected="second">
|
|
13
3
|
<sp-tab label="Tab 1" value="first"></sp-tab>
|
|
14
4
|
<sp-tab label="Tab 2" value="second"></sp-tab>
|
|
@@ -53,73 +43,5 @@ const createTabs = async () => {
|
|
|
53
43
|
</sp-action-group>
|
|
54
44
|
</sp-tab-panel>
|
|
55
45
|
</sp-tabs>
|
|
56
|
-
`);
|
|
57
|
-
await elementUpdated(tabs);
|
|
58
|
-
return tabs;
|
|
59
|
-
};
|
|
60
|
-
describe("Action Group inside of Tabs", () => {
|
|
61
|
-
it("accurately navigates the desired element", async () => {
|
|
62
|
-
const el = await createTabs();
|
|
63
|
-
const tab1 = el.querySelector('sp-tab[value="first"]');
|
|
64
|
-
const tab2 = el.querySelector('sp-tab[value="second"]');
|
|
65
|
-
const tab3 = el.querySelector('sp-tab[value="third"]');
|
|
66
|
-
const tabPanel1 = el.querySelector('sp-tab-panel[value="first"]');
|
|
67
|
-
const tabPanel2 = el.querySelector('sp-tab-panel[value="second"]');
|
|
68
|
-
const tabPanel3 = el.querySelector('sp-tab-panel[value="third"]');
|
|
69
|
-
const actionGroup1 = tabPanel1.querySelector("sp-action-group");
|
|
70
|
-
const actionGroup2 = tabPanel2.querySelector("sp-action-group");
|
|
71
|
-
const actionGroup3 = tabPanel3.querySelector("sp-action-group");
|
|
72
|
-
const actionButton1 = actionGroup1.querySelector("[selected]");
|
|
73
|
-
const actionButton2 = actionGroup2.querySelector("[selected]");
|
|
74
|
-
const actionButton3 = actionGroup3.querySelector("[selected]");
|
|
75
|
-
el.focus();
|
|
76
|
-
expect(el.contains(document.activeElement)).to.be.true;
|
|
77
|
-
expect(document.activeElement === tab2).to.be.true;
|
|
78
|
-
actionGroup2.focus();
|
|
79
|
-
expect(document.activeElement === actionButton2).to.be.true;
|
|
80
|
-
await nextFrame();
|
|
81
|
-
await sendKeys({
|
|
82
|
-
press: "ArrowLeft"
|
|
83
|
-
});
|
|
84
|
-
expect(document.activeElement === tab1).to.be.false;
|
|
85
|
-
expect(actionGroup2.contains(document.activeElement)).to.be.true;
|
|
86
|
-
el.focus();
|
|
87
|
-
expect(document.activeElement === tab2).to.be.true;
|
|
88
|
-
await sendKeys({
|
|
89
|
-
press: "ArrowRight"
|
|
90
|
-
});
|
|
91
|
-
expect(document.activeElement === tab3).to.be.true;
|
|
92
|
-
await sendKeys({
|
|
93
|
-
press: "Enter"
|
|
94
|
-
});
|
|
95
|
-
expect(document.activeElement === tab3).to.be.true;
|
|
96
|
-
actionGroup3.focus();
|
|
97
|
-
expect(document.activeElement === actionButton3).to.be.true;
|
|
98
|
-
await sendKeys({
|
|
99
|
-
press: "ArrowLeft"
|
|
100
|
-
});
|
|
101
|
-
expect(document.activeElement === tab2).to.be.false;
|
|
102
|
-
expect(actionGroup3.contains(document.activeElement)).to.be.true;
|
|
103
|
-
const boundingRect = tab1.getBoundingClientRect();
|
|
104
|
-
await sendMouse({
|
|
105
|
-
steps: [
|
|
106
|
-
{
|
|
107
|
-
type: "click",
|
|
108
|
-
position: [
|
|
109
|
-
boundingRect.left + boundingRect.width / 2,
|
|
110
|
-
boundingRect.top + boundingRect.height / 2
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
});
|
|
115
|
-
expect(document.activeElement === tab1).to.be.true;
|
|
116
|
-
actionGroup1.focus();
|
|
117
|
-
expect(document.activeElement === actionButton1).to.be.true;
|
|
118
|
-
await sendKeys({
|
|
119
|
-
press: "ArrowRight"
|
|
120
|
-
});
|
|
121
|
-
expect(document.activeElement === tab2).to.be.false;
|
|
122
|
-
expect(actionGroup1.contains(document.activeElement)).to.be.true;
|
|
123
|
-
});
|
|
124
|
-
});
|
|
46
|
+
`);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})});
|
|
125
47
|
//# sourceMappingURL=roving-tabindex-integration.test.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["roving-tabindex-integration.test.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport { ActionButton } from '@spectrum-web-components/action-button';\nimport '@spectrum-web-components/action-group/sp-action-group.js';\nimport { ActionGroup } from '@spectrum-web-components/action-group';\nimport '@spectrum-web-components/tabs/sp-tab-panel.js';\nimport '@spectrum-web-components/tabs/sp-tab.js';\nimport '@spectrum-web-components/tabs/sp-tabs.js';\nimport { Tab, TabPanel, Tabs } from '@spectrum-web-components/tabs';\nimport { elementUpdated, expect, fixture, nextFrame } from '@open-wc/testing';\nimport { html } from '@spectrum-web-components/base';\nimport { sendKeys } from '@web/test-runner-commands';\nimport { sendMouse } from '../../../test/plugins/browser.js';\n\nconst createTabs = async (): Promise<Tabs> => {\n const tabs = await fixture<Tabs>(\n html`\n <sp-tabs selected=\"second\">\n <sp-tab label=\"Tab 1\" value=\"first\"></sp-tab>\n <sp-tab label=\"Tab 2\" value=\"second\"></sp-tab>\n <sp-tab label=\"Tab 3\" value=\"third\"></sp-tab>\n <sp-tab-panel value=\"first\">\n <sp-action-group selects=\"single\">\n <sp-action-button selected value=\"1\">\n Single Button 1\n </sp-action-button>\n <sp-action-button value=\"2\">\n Single Button 2\n </sp-action-button>\n <sp-action-button value=\"3\">\n Single Button 3\n </sp-action-button>\n </sp-action-group>\n </sp-tab-panel>\n <sp-tab-panel value=\"second\">\n <sp-action-group selects=\"multiple\">\n <sp-action-button value=\"1\">\n Multiple Button 1\n </sp-action-button>\n <sp-action-button selected value=\"2\">\n Multiple Button 2\n </sp-action-button>\n <sp-action-button selected value=\"3\">\n Multiple Button 3\n </sp-action-button>\n </sp-action-group>\n </sp-tab-panel>\n <sp-tab-panel value=\"third\">\n <sp-action-group>\n <sp-action-button value=\"1\">\n None Button 1\n </sp-action-button>\n <sp-action-button value=\"2\">\n None Button 2\n </sp-action-button>\n <sp-action-button selected value=\"3\">\n None Button 3\n </sp-action-button>\n </sp-action-group>\n </sp-tab-panel>\n </sp-tabs>\n `\n );\n await elementUpdated(tabs);\n return tabs;\n};\n\ndescribe('Action Group inside of Tabs', () => {\n it('accurately navigates the desired element', async () => {\n const el = await createTabs();\n const tab1 = el.querySelector('sp-tab[value=\"first\"]') as Tab;\n const tab2 = el.querySelector('sp-tab[value=\"second\"]');\n const tab3 = el.querySelector('sp-tab[value=\"third\"]') as Tab;\n const tabPanel1 = el.querySelector(\n 'sp-tab-panel[value=\"first\"]'\n ) as TabPanel;\n const tabPanel2 = el.querySelector(\n 'sp-tab-panel[value=\"second\"]'\n ) as TabPanel;\n const tabPanel3 = el.querySelector(\n 'sp-tab-panel[value=\"third\"]'\n ) as TabPanel;\n const actionGroup1 = tabPanel1.querySelector(\n 'sp-action-group'\n ) as ActionGroup;\n const actionGroup2 = tabPanel2.querySelector(\n 'sp-action-group'\n ) as ActionGroup;\n const actionGroup3 = tabPanel3.querySelector(\n 'sp-action-group'\n ) as ActionGroup;\n const actionButton1 = actionGroup1.querySelector(\n '[selected]'\n ) as ActionButton;\n const actionButton2 = actionGroup2.querySelector(\n '[selected]'\n ) as ActionButton;\n const actionButton3 = actionGroup3.querySelector(\n '[selected]'\n ) as ActionButton;\n\n el.focus();\n expect(el.contains(document.activeElement)).to.be.true;\n expect(document.activeElement === tab2).to.be.true;\n\n actionGroup2.focus();\n expect(document.activeElement === actionButton2).to.be.true;\n\n await nextFrame();\n await sendKeys({\n press: 'ArrowLeft',\n });\n\n expect(document.activeElement === tab1).to.be.false;\n expect(actionGroup2.contains(document.activeElement)).to.be.true;\n\n el.focus();\n expect(document.activeElement === tab2).to.be.true;\n\n await sendKeys({\n press: 'ArrowRight',\n });\n\n expect(document.activeElement === tab3).to.be.true;\n\n await sendKeys({\n press: 'Enter',\n });\n\n expect(document.activeElement === tab3).to.be.true;\n\n actionGroup3.focus();\n expect(document.activeElement === actionButton3).to.be.true;\n\n await sendKeys({\n press: 'ArrowLeft',\n });\n\n expect(document.activeElement === tab2).to.be.false;\n expect(actionGroup3.contains(document.activeElement)).to.be.true;\n\n const boundingRect = tab1.getBoundingClientRect();\n // tab1.click() doesn't current reach into the focus management here.\n await sendMouse({\n steps: [\n {\n type: 'click',\n position: [\n boundingRect.left + boundingRect.width / 2,\n boundingRect.top + boundingRect.height / 2,\n ],\n },\n ],\n });\n expect(document.activeElement === tab1).to.be.true;\n\n actionGroup1.focus();\n expect(document.activeElement === actionButton1).to.be.true;\n\n await sendKeys({\n press: 'ArrowRight',\n });\n\n expect(document.activeElement === tab2).to.be.false;\n expect(actionGroup1.contains(document.activeElement)).to.be.true;\n });\n});\n"],
|
|
5
|
-
"mappings": "AAWA
|
|
5
|
+
"mappings": "AAWA,mEAEA,iEAEA,sDACA,gDACA,iDAEA,0FACA,qDACA,qDACA,6DAEA,KAAM,GAAa,SAA2B,CAC1C,KAAM,GAAO,KAAM,GACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SA8CJ,EACA,YAAM,GAAe,CAAI,EAClB,CACX,EAEA,SAAS,8BAA+B,IAAM,CAC1C,GAAG,2CAA4C,SAAY,CACvD,KAAM,GAAK,KAAM,GAAW,EACtB,EAAO,EAAG,cAAc,uBAAuB,EA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U,CACZ,MAAO,CACH,CACI,KAAM,QACN,SAAU,CACN,EAAa,KAAO,EAAa,MAAQ,EACzC,EAAa,IAAM,EAAa,OAAS,CAC7C,CACJ,CACJ,CACJ,CAAC,EACD,EAAO,SAAS,gBAAkB,CAAI,EAAE,GAAG,GAAG,KAE9C,EAAa,MAAM,EACnB,EAAO,SAAS,gBAAkB,CAAa,EAAE,GAAG,GAAG,KAEvD,KAAM,GAAS,CACX,MAAO,YACX,CAAC,EAED,EAAO,SAAS,gBAAkB,CAAI,EAAE,GAAG,GAAG,MAC9C,EAAO,EAAa,SAAS,SAAS,aAAa,CAAC,EAAE,GAAG,GAAG,IAChE,CAAC,CACL,CAAC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { expect } from "@open-wc/testing";
|
|
3
|
-
import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";
|
|
4
|
-
describe("RovingTabindex", () => {
|
|
5
|
-
it("constructs with defaults", async () => {
|
|
6
|
-
class TestEl extends LitElement {
|
|
7
|
-
}
|
|
8
|
-
customElements.define("test-roving-tabindex-el", TestEl);
|
|
9
|
-
const el = new TestEl();
|
|
10
|
-
const controller = new RovingTabindexController(el);
|
|
11
|
-
expect(controller.direction).to.equal("both");
|
|
12
|
-
expect(controller.focusInIndex).to.equal(0);
|
|
13
|
-
expect(controller.isFocusableElement(el)).to.be.true;
|
|
14
|
-
});
|
|
15
|
-
});
|
|
1
|
+
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})});
|
|
16
2
|
//# sourceMappingURL=roving-tabindex.test.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["roving-tabindex.test.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { LitElement } from 'lit';\nimport { expect } from '@open-wc/testing';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\n\ndescribe('RovingTabindex', () => {\n it('constructs with defaults', async () => {\n class TestEl extends LitElement {}\n customElements.define('test-roving-tabindex-el', TestEl);\n const el = new TestEl();\n const controller = new RovingTabindexController(\n el as LitElement & { shadowRoot: ShadowRoot }\n );\n expect(controller.direction).to.equal('both');\n expect(controller.focusInIndex).to.equal(0);\n expect(controller.isFocusableElement(el)).to.be.true;\n });\n});\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,iCACA,0CACA,+GAEA,SAAS,iBAAkB,IAAM,CAC7B,GAAG,2BAA4B,SAAY,CACvC,MAAM,SAAe,EAAW,CAAC,CACjC,eAAe,OAAO,0BAA2B,CAAM,EACvD,KAAM,GAAK,GAAI,GACT,EAAa,GAAI,GACnB,CACJ,EACA,EAAO,EAAW,SAAS,EAAE,GAAG,MAAM,MAAM,EAC5C,EAAO,EAAW,YAAY,EAAE,GAAG,MAAM,CAAC,EAC1C,EAAO,EAAW,mBAAmB,CAAE,CAAC,EAAE,GAAG,GAAG,IACpD,CAAC,CACL,CAAC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|