@spectrum-web-components/reactive-controllers
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "@spectrum-web-components/reactive-controllers", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"publishConfig": { | ||
@@ -45,3 +45,3 @@ "access": "public" | ||
"dependencies": { | ||
"lit": "^2.0.2", | ||
"lit": "^2.1.2", | ||
"tslib": "^2.0.0" | ||
@@ -51,3 +51,3 @@ }, | ||
"customElements": "custom-elements.json", | ||
"gitHead": "f23b15ec952d7450272a8275524c905e028b4ddc" | ||
"gitHead": "57aba8030b6af96af4015a0aa830e342a17dc219" | ||
} |
@@ -37,7 +37,9 @@ import type { ReactiveController, ReactiveElement } from 'lit'; | ||
_listenerScope: () => HTMLElement; | ||
offset: number; | ||
private managed; | ||
constructor(host: ReactiveElement, { direction, elementEnterAction, elements, focusInIndex, isFocusableElement, listenerScope, }?: RovingTabindexConfig<T>); | ||
update({ elements }?: RovingTabindexConfig<T>): void; | ||
focus(options?: FocusOptions): void; | ||
private manageIndexesAnimationFrame; | ||
clearElementCache(): void; | ||
clearElementCache(offset?: number): void; | ||
setCurrentIndexCircularly(diff: number): void; | ||
@@ -44,0 +46,0 @@ hostContainsFocus(): void; |
@@ -17,2 +17,5 @@ export class RovingTabindexController { | ||
this._listenerScope = () => this.host; | ||
// When elements are virtualized, the delta between the first element | ||
// and the first rendered element. | ||
this.offset = 0; | ||
this.managed = true; | ||
@@ -67,3 +70,12 @@ this.manageIndexesAnimationFrame = 0; | ||
event.preventDefault(); | ||
this.setCurrentIndexCircularly(diff); | ||
if (this.direction === 'grid' && this.currentIndex + diff < 0) { | ||
this.currentIndex = 0; | ||
} | ||
else if (this.direction === 'grid' && | ||
this.currentIndex + diff > this.elements.length - 1) { | ||
this.currentIndex = this.elements.length - 1; | ||
} | ||
else { | ||
this.setCurrentIndexCircularly(diff); | ||
} | ||
// To allow the `focusInIndex` to be calculated with the "after" state of the keyboard interaction | ||
@@ -102,6 +114,6 @@ // do `elementEnterAction` _before_ focusing the next element. | ||
} | ||
return this._currentIndex; | ||
return this._currentIndex - this.offset; | ||
} | ||
set currentIndex(currentIndex) { | ||
this._currentIndex = currentIndex; | ||
this._currentIndex = currentIndex + this.offset; | ||
} | ||
@@ -137,2 +149,8 @@ get direction() { | ||
} | ||
update({ elements } = { elements: () => [] }) { | ||
this.unmanage(); | ||
this._elements = elements; | ||
this.clearElementCache(); | ||
this.manage(); | ||
} | ||
focus(options) { | ||
@@ -142,5 +160,6 @@ var _a; | ||
} | ||
clearElementCache() { | ||
clearElementCache(offset = 0) { | ||
delete this.cachedElements; | ||
cancelAnimationFrame(this.manageIndexesAnimationFrame); | ||
this.offset = offset; | ||
if (!this.managed) | ||
@@ -147,0 +166,0 @@ return; |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
51408
12
380
1
Updatedlit@^2.1.2