Socket
Socket
Sign inDemoInstall

@spectrum-web-components/reactive-controllers

Package Overview
Dependencies
Maintainers
7
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spectrum-web-components/reactive-controllers - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

6

package.json
{
"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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc