New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tolefocus

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tolefocus - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

2

dist/bundles/tolefocus.bundle.umd.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.tolefocus=e.tolefocus||{})}(this,function(e){"use strict";var t=function(){function e(){this.items=[],this.orderedItems=[]}return e.prototype.add=function(e,t){var r=this.items.findIndex(function(t){return t.object===e});r>=0?t>=0&&(this.items[r].order=t,this.reorder()):(this.items.push({object:e,order:t}),this.reorder())},e.prototype.reorder=function(){var e=this,t=[],r=this.items.filter(function(e){return!!e.order}),o=this.items.filter(function(e){return!e.order});r.forEach(function(e){t[e.order-1]=e});for(var n=0,i=0,s=this.items.length;i<s;i++)void 0===t[i]&&n<o.length&&(t[i]=o[n++]);this.orderedItems=[],t.forEach(function(t){void 0!==t&&e.orderedItems.push(t)})},e.prototype.remove=function(e){var t=this.items.findIndex(function(t){return t.object===e});t>=0&&this.items.splice(t,1),this.reorder()},e}(),r=9,o=function(){function e(e){var t=this;this.element=e,this.keyPressHandler=function(e){b.enabled&&e.keyCode===r&&(e.shiftKey?b.focusPrior(t.element):b.focusNext(t.element),e.preventDefault(),e.stopPropagation())},this.handle()}return e.prototype.unhandle=function(){this.element.removeEventListener("keydown",this.keyPressHandler)},e.prototype.handle=function(){var e=this.element;e.addEventListener("keydown",this.keyPressHandler)},e}(),n="TOLEFOCUS_INFO",i=function(){function e(e,r,o,n){void 0===o&&(o=""),void 0===n&&(n=""),this.parentGroup=e,this.groupElement=r,this.headBehavior=o,this.tailBehavior=n,this.items=new t}return Object.defineProperty(e.prototype,"count",{get:function(){return this.items.orderedItems.length},enumerable:!0,configurable:!0}),e.prototype.add=function(t,r){this.items.add(t,r),t instanceof e?t.groupElement[n]||(t.groupElement[n]={parentGroup:this,group:t}):(t.setAttribute("tabindex","-1"),t[n]||(t[n]={parentGroup:this,eventsHandler:new o(t)}))},e.prototype.remove=function(t){t instanceof e||!t[n]||t[n].eventsHandler.unhandle(),this.items.remove(t)},e.prototype.fistElementRecursively=function(){for(var t=0,r=this.items.orderedItems;t<r.length;t++){var o=r[t].object;if(!(o instanceof e))return o;var n=o.fistElementRecursively();if(n)return n}},e.prototype.lastElementRecursively=function(){for(var t=this.items.orderedItems.length-1;t>=0;t--){var r=this.items.orderedItems[t].object;if(!(r instanceof e))return r;var o=r.lastElementRecursively();if(o)return o}},e.prototype.locateElementRecursively=function(t){for(var r=0,o=0,n=this.items.orderedItems;o<n.length;o++){var i=n[o].object;if(i instanceof e){var s=i.locateElementRecursively(t);if(s.group)return s}else if(i===t)return{group:this,elementIndex:r};r++}return{group:void 0,elementIndex:void 0}},e.prototype.getItemIndexByElement=function(t){return this.items.orderedItems.findIndex(function(r){return r.object instanceof e&&r.object.groupElement===t||!(r.object instanceof e)&&r.object===t})},e.prototype.getNextElement=function(t){var r,o=this.getItemIndexByElement(t);if(o>=0)if(o<this.items.orderedItems.length-1)r=o+1;else if("loop"===this.tailBehavior)r=0;else if("stop"===this.tailBehavior)r=o;else if(this.parentGroup){var n=this.parentGroup.getNextElement(this.groupElement);if(n)return n}if(void 0!==r){var i=this.items.orderedItems[r];return i.object instanceof e?i.object.fistElementRecursively():i.object}},e.prototype.getPriorElement=function(t){var r,o=this.getItemIndexByElement(t);if(o>=0)if(o>0)r=o-1;else if("loop"===this.headBehavior)r=this.items.orderedItems.length-1;else if("stop"===this.headBehavior)r=o;else if(this.parentGroup){var n=this.parentGroup.getPriorElement(this.groupElement);if(n)return n}if(void 0!==r){var i=this.items.orderedItems[r];return i.object instanceof e?i.object.lastElementRecursively():i.object}},e}(),s=100,u=function(){function e(e,t){var r=this;this.element=e,this.callback=t,this.check=function(){var e=c.canElementGetFocus(r.element);e!==r.focusable&&(r.focusable=e,r.callback(r.focusable))},this.focusable=c.canElementGetFocus(e),this.intervalHandle=setInterval(this.check,s)}return e.prototype.stop=function(){clearInterval(this.intervalHandle)},e}(),l="TOLEFOCUS_INSPECTOR",a=function(){function e(){}return e.prototype.removeGroup=function(e){var t=this.getElementInfo(e);t.parentGroup.remove(t.group)},e.prototype.removeElement=function(e){var t=this.getElementInfo(e);t.parentGroup.remove(e),e[l]&&e[l].stop()},e.prototype.getElementInfo=function(e){return e[n]},e.prototype.isGroup=function(e){var t=e.getAttribute(f);return null!==t&&void 0!==t},e.prototype.isElement=function(e){var t=e.getAttribute(p);return h.indexOf(e.tagName.toLowerCase())>=0||null!==t&&void 0!==t},e.prototype.processRemovedElement=function(e){e.getAttribute&&(this.isGroup(e)?this.removeGroup(e):this.isElement(e)&&this.removeElement(e))},e.prototype.locateParentGroupElement=function(e){for(var t=e;null!==(t=t.parentElement);)if(this.isGroup(t))return t;return t},e.prototype.getElementOrder=function(e){var t=e.getAttribute(p);if(null!==t&&void 0!==t&&""!==t)return parseInt(t,10)},e.prototype.getGroupProperties=function(e){var t=e.getAttribute(f);if(""===t)return{head:void 0,tail:void 0};var r,o,n=t.split(" ").filter(function(e){return""!==e}).filter(function(e,t){return t<2});return 1===n.length?(r=n[0],o=n[0]):2===n.length&&(o=n[0],r=n[1]),{head:o,tail:r}},e.prototype.addGroup=function(e){var t=this.locateParentGroupElement(e),r=t?this.getElementInfo(t).group:b.root,o=this.getGroupProperties(e),n=o.head,s=o.tail,u=new i(r,e,n,s);r.add(u,this.getElementOrder(e))},e.prototype.canElementGetFocus=function(e){var t=null!==e.offsetParent,r=!!e.disabled;return t&&!r},e.prototype.addElement=function(e){var t=this.locateParentGroupElement(e),r=t?this.getElementInfo(t).group:b.root;r.add(e,this.getElementOrder(e));var o=e.getAttribute(d);null!==o&&void 0!==o&&(this.canElementGetFocus(e)&&e.focus(),o===m&&(e[l]=new u(e,function(t){t&&e.focus()})))},e.prototype.processAddedElement=function(e){e.getAttribute&&(this.isGroup(e)?this.addGroup(e):this.isElement(e)&&this.addElement(e))},e.prototype.processFromElement=function(e){for(var t=h.concat(["["+f+"]","["+p+"]"]).join(","),r=e.querySelectorAll(t),o=0,n=r.length;o<n;o++)this.processAddedElement(r.item(o))},e}(),c=new a,f="focus-group",p="focus-order",d="autofocus",h=["a","select","button","input","textarea"],m="observe",v=function(){function e(){this._enabled=!1}return Object.defineProperty(e.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),e.prototype.focusNext=function(e){var t=this.root.locateElementRecursively(e).group;if(t){for(var r=t.getNextElement(e);!c.canElementGetFocus(r);){var o=c.getElementInfo(r);r=o.parentGroup.getNextElement(r)}r&&r.focus()}},e.prototype.focusPrior=function(e){var t=this.root.locateElementRecursively(e).group;if(t){for(var r=t.getPriorElement(e);!c.canElementGetFocus(r);){var o=c.getElementInfo(r);r=o.parentGroup.getPriorElement(r)}r&&r.focus()}},e.prototype.disable=function(){this._enabled&&(this._enabled=!1)},e.prototype.enable=function(e){this._enabled&&this.disable(),e||(e=document.body),this._root=new i(null,null,"loop","loop"),this._enabled=!0,c.processFromElement(e)},e}(),b=new v,y=function(){function e(){var e=this;this._enabled=!1,this.observer=new MutationObserver(function(t){return e.observerCallback(t)})}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rootElement",{get:function(){return this._rootElement},enumerable:!0,configurable:!0}),e.prototype.disable=function(){this._enabled&&(this.observer.disconnect(),this._enabled=!1)},e.prototype.enable=function(e){this._enabled&&this.disable(),e||(e=document.body);var t={childList:!0,subtree:!0};this.observer.observe(e,t)},e.prototype.observerCallback=function(e){var t=this;e.forEach(function(e){return t.processMutation(e)})},e.prototype.processMutation=function(e){if("childList"===e.type){for(var t=0,r=e.addedNodes.length;t<r;t++)c.processAddedElement(e.addedNodes.item(t));for(var t=0,r=e.removedNodes.length;t<r;t++)c.processRemovedElement(e.removedNodes.item(t))}},e}(),g=new y;e.focusManager=b,e.focusObserver=g,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.tolefocus=e.tolefocus||{})}(this,function(e){"use strict";var t=function(){function e(){this.items=[],this.orderedItems=[]}return e.prototype.insert=function(e,t,r){var o=this.items.findIndex(function(e){return e.object===t});if(o>=0){if(o===e&&r>=0)return this.items[o].order=r,void this.reorder();this.items.splice(o,1)}e||0===e?this.items.splice(e,0,{object:t,order:r}):this.items.push({object:t,order:r}),this.reorder()},e.prototype.reorder=function(){var e=this,t=[],r=this.items.filter(function(e){return!!e.order}),o=this.items.filter(function(e){return!e.order});r.forEach(function(e){t[e.order-1]=e});for(var n=0,i=0,s=this.items.length;i<s;i++)void 0===t[i]&&n<o.length&&(t[i]=o[n++]);this.orderedItems=[],t.forEach(function(t){void 0!==t&&e.orderedItems.push(t)})},e.prototype.remove=function(e){var t=this.items.findIndex(function(t){return t.object===e});t>=0&&this.items.splice(t,1),this.reorder()},e}(),r=9,o=function(){function e(e){var t=this;this.element=e,this.keyPressHandler=function(e){b.enabled&&e.keyCode===r&&(e.shiftKey?b.focusPrior(t.element):b.focusNext(t.element),e.preventDefault(),e.stopPropagation())},this.handle()}return e.prototype.unhandle=function(){this.element.removeEventListener("keydown",this.keyPressHandler)},e.prototype.handle=function(){var e=this.element;e.addEventListener("keydown",this.keyPressHandler)},e}(),n=100,i=function(){function e(e,t){var r=this;this.element=e,this.callback=t,this.check=function(){var e=l.canElementGetFocus(r.element);e!==r.focusable&&(r.focusable=e,r.callback(r.focusable))},this.focusable=l.canElementGetFocus(e),this.intervalHandle=setInterval(this.check,n)}return e.prototype.stop=function(){clearInterval(this.intervalHandle)},e}(),s="TOLEFOCUS_INSPECTOR",u=function(){function e(){}return e.prototype.getFocusElementsSelector=function(){return h.concat(["["+p+"]","["+f+"]"]).join(",")},e.prototype.removeGroup=function(e){var t=this.getElementInfo(e);t.parentGroup.remove(t.group)},e.prototype.removeElement=function(e){var t=this.getElementInfo(e);t.parentGroup.remove(e),e[s]&&e[s].stop()},e.prototype.getElementInfo=function(e){return e[a]},e.prototype.isGroup=function(e){var t=e.getAttribute(p);return null!==t&&void 0!==t},e.prototype.isElement=function(e){var t=e.getAttribute(f);return h.indexOf(e.tagName.toLowerCase())>=0||null!==t&&void 0!==t},e.prototype.processRemovedElement=function(e){e.getAttribute&&(this.isGroup(e)?this.removeGroup(e):this.isElement(e)&&this.removeElement(e))},e.prototype.locateParentGroupElement=function(e){for(var t=e;null!==(t=t.parentElement);)if(this.isGroup(t))return t;return t},e.prototype.getElementOrder=function(e){var t=e.getAttribute(f);if(null!==t&&void 0!==t&&""!==t)return parseInt(t,10)},e.prototype.isGroupChildren=function(e,t){for(;null!==t.parentElement;){if(this.isGroup(t.parentElement)||t.parentElement===document.body)return t.parentElement===e;t=t.parentElement}return!1},e.prototype.getDOMOrderInGroup=function(e,t){for(var r=e.querySelectorAll(this.getFocusElementsSelector()),o=[],n=0,i=r.length;n<i;n++){var s=r.item(n);this.isGroupChildren(e,s)&&o.push(s)}for(var n=0,i=o.length;n<i;n++)if(o[n]===t)return n},e.prototype.getGroupProperties=function(e){var t=e.getAttribute(p);if(""===t)return{head:void 0,tail:void 0};var r,o,n=t.split(" ").filter(function(e){return""!==e}).filter(function(e,t){return t<2});return 1===n.length?(r=n[0],o=n[0]):2===n.length&&(o=n[0],r=n[1]),{head:o,tail:r}},e.prototype.addGroup=function(e){var t=this.locateParentGroupElement(e),r=t?this.getElementInfo(t).group:b.root,o=this.getGroupProperties(e),n=o.head,i=o.tail,s=new c(r,e,n,i);r.add(s,this.getElementOrder(e))},e.prototype.canElementGetFocus=function(e){var t=null!==e.offsetParent,r=!!e.disabled;return t&&!r},e.prototype.addElement=function(e){var t=this.locateParentGroupElement(e),r=t?this.getElementInfo(t).group:b.root;r.add(e,this.getElementOrder(e));var o=e.getAttribute(d);null!==o&&void 0!==o&&(this.canElementGetFocus(e)&&e.focus(),o===m&&(e[s]=new i(e,function(t){t&&e.focus()})))},e.prototype.processAddedElement=function(e){e.getAttribute&&(this.isGroup(e)?this.addGroup(e):this.isElement(e)&&this.addElement(e))},e.prototype.processFromElement=function(e){for(var t=e.querySelectorAll(this.getFocusElementsSelector()),r=0,o=t.length;r<o;r++)this.processAddedElement(t.item(r))},e}(),l=new u,a="TOLEFOCUS_INFO",c=function(){function e(e,r,o,n){void 0===o&&(o=""),void 0===n&&(n=""),this.parentGroup=e,this.groupElement=r,this.headBehavior=o,this.tailBehavior=n,this.items=new t}return Object.defineProperty(e.prototype,"count",{get:function(){return this.items.orderedItems.length},enumerable:!0,configurable:!0}),e.prototype.add=function(t,r){var n;t instanceof e?(n=l.getDOMOrderInGroup(this.groupElement,t.groupElement),t.groupElement[a]||(t.groupElement[a]={parentGroup:this,group:t})):(n=l.getDOMOrderInGroup(this.groupElement,t),t.setAttribute("tabindex","-1"),t[a]||(t[a]={parentGroup:this,eventsHandler:new o(t)})),this.items.insert(n,t,r)},e.prototype.remove=function(t){t instanceof e||!t[a]||t[a].eventsHandler.unhandle(),this.items.remove(t)},e.prototype.fistElementRecursively=function(){for(var t=0,r=this.items.orderedItems;t<r.length;t++){var o=r[t].object;if(!(o instanceof e))return o;var n=o.fistElementRecursively();if(n)return n}},e.prototype.lastElementRecursively=function(){for(var t=this.items.orderedItems.length-1;t>=0;t--){var r=this.items.orderedItems[t].object;if(!(r instanceof e))return r;var o=r.lastElementRecursively();if(o)return o}},e.prototype.locateElementRecursively=function(t){for(var r=0,o=0,n=this.items.orderedItems;o<n.length;o++){var i=n[o].object;if(i instanceof e){var s=i.locateElementRecursively(t);if(s.group)return s}else if(i===t)return{group:this,elementIndex:r};r++}return{group:void 0,elementIndex:void 0}},e.prototype.getItemIndexByElement=function(t){return this.items.orderedItems.findIndex(function(r){return r.object instanceof e&&r.object.groupElement===t||!(r.object instanceof e)&&r.object===t})},e.prototype.getNextElement=function(t){var r,o=this.getItemIndexByElement(t);if(o>=0)if(o<this.items.orderedItems.length-1)r=o+1;else if("loop"===this.tailBehavior)r=0;else if("stop"===this.tailBehavior)r=o;else if(this.parentGroup){var n=this.parentGroup.getNextElement(this.groupElement);if(n)return n}if(void 0!==r){var i=this.items.orderedItems[r];return i.object instanceof e?i.object.fistElementRecursively():i.object}},e.prototype.getPriorElement=function(t){var r,o=this.getItemIndexByElement(t);if(o>=0)if(o>0)r=o-1;else if("loop"===this.headBehavior)r=this.items.orderedItems.length-1;else if("stop"===this.headBehavior)r=o;else if(this.parentGroup){var n=this.parentGroup.getPriorElement(this.groupElement);if(n)return n}if(void 0!==r){var i=this.items.orderedItems[r];return i.object instanceof e?i.object.lastElementRecursively():i.object}},e}(),p="focus-group",f="focus-order",d="autofocus",h=["a","select","button","input","textarea"],m="observe",v=function(){function e(){this._enabled=!1}return Object.defineProperty(e.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),e.prototype.focusNext=function(e){var t=this.root.locateElementRecursively(e).group;if(t){for(var r=t.getNextElement(e);!l.canElementGetFocus(r);){var o=l.getElementInfo(r);r=o.parentGroup.getNextElement(r)}r&&r.focus()}},e.prototype.focusPrior=function(e){var t=this.root.locateElementRecursively(e).group;if(t){for(var r=t.getPriorElement(e);!l.canElementGetFocus(r);){var o=l.getElementInfo(r);r=o.parentGroup.getPriorElement(r)}r&&r.focus()}},e.prototype.disable=function(){this._enabled&&(this._enabled=!1)},e.prototype.enable=function(e){this._enabled&&this.disable(),e||(e=document.body),this._root=new c(null,e,"loop","loop"),this._enabled=!0,l.processFromElement(e)},e}(),b=new v,g=function(){function e(){var e=this;this._enabled=!1,this.observer=new MutationObserver(function(t){return e.observerCallback(t)})}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rootElement",{get:function(){return this._rootElement},enumerable:!0,configurable:!0}),e.prototype.disable=function(){this._enabled&&(this.observer.disconnect(),this._enabled=!1)},e.prototype.enable=function(e){this._enabled&&this.disable(),e||(e=document.body);var t={childList:!0,subtree:!0};this.observer.observe(e,t)},e.prototype.observerCallback=function(e){var t=this;e.forEach(function(e){return t.processMutation(e)})},e.prototype.processMutation=function(e){if("childList"===e.type){for(var t=0,r=e.addedNodes.length;t<r;t++)l.processAddedElement(e.addedNodes.item(t));for(var t=0,r=e.removedNodes.length;t<r;t++)l.processRemovedElement(e.removedNodes.item(t))}},e}(),E=new g;e.focusManager=b,e.focusObserver=E,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -5,2 +5,3 @@ import { ElementInfo } from "../core/FocusGroup";

export declare class DomProcessor {
private getFocusElementsSelector();
removeGroup(element: HTMLElement): void;

@@ -14,2 +15,4 @@ removeElement(element: HTMLElement): void;

getElementOrder(element: HTMLElement): number;
isGroupChildren(group: HTMLElement, element: HTMLElement): boolean;
getDOMOrderInGroup(groupElement: HTMLElement, element: HTMLElement): number;
getGroupProperties(element: HTMLElement): {

@@ -16,0 +19,0 @@ head: string;

@@ -8,5 +8,5 @@ export declare type OrderedItem<TItem> = {

orderedItems: OrderedItem<TItem>[];
add(object: TItem, order?: number): void;
insert(index: number, object: TItem, order?: number): void;
private reorder();
remove(object: TItem): void;
}
{
"name": "tolefocus",
"version": "0.1.1",
"version": "0.1.2",
"description": "Agnostic Framework Focus Manager",

@@ -5,0 +5,0 @@ "scripts": {

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