Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

trap-focus-svelte

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trap-focus-svelte - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

4

dist/index.d.ts

@@ -8,6 +8,6 @@ interface TrapOptions {

/** Locks focus within a wrapper element */
declare function lockFocus(node: HTMLElement, options?: TrapOptions): {
declare function trapFocus(node: HTMLElement, options?: TrapOptions): {
update(options: TrapOptions): void;
destroy(): void;
};
export { lockFocus };
export { trapFocus };

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

function n(n,t,u,o){return n.addEventListener(t,u,o),()=>n.removeEventListener(t,u,o)}var t=[],u=!1;n(document,"keydown",function(n){u=n.shiftKey&&"Tab"===n.key}),exports.lockFocus=function(o,r){var i,c;void 0===r&&(r={active:!0});var e=r.wrap,f=void 0===e?o:e,a=r.active,d=[].concat(f.querySelectorAll("*")).filter(function(n){return n.tabIndex>=0}),v=null!=(i=d.at(0))?i:f,l=null!=(c=d.at(-1))?c:f;function m(n){return void 0===n&&(n=f),t.at(-1).wrap.contains(n)}t.push({wrap:f,t:document.activeElement}),v.focus();var s=n(v,"blur",function(){a&&m()&&u&&l.focus()}),b=n(l,"blur",function(){a&&m()&&!u&&v.focus()}),p=n(document,"focusin",function(n){a&&!m(n.target)&&(u?l:v).focus()});return{update:function(n){a=n.active},destroy:function(){p(),s(),b(),t.pop().t.focus()}}};
function n(n,t,u,o){return n.addEventListener(t,u,o),()=>n.removeEventListener(t,u,o)}var t=[],u=!1;n(document,"keydown",function(n){u=n.shiftKey&&"Tab"===n.key}),exports.trapFocus=function(o,r){var i,c;void 0===r&&(r={active:!0});var e=r.wrap,f=void 0===e?o:e,a=r.active,d=[].concat(f.querySelectorAll("*")).filter(function(n){return n.tabIndex>=0}),v=null!=(i=d.at(0))?i:f,l=null!=(c=d.at(-1))?c:f;function m(n){return void 0===n&&(n=f),t.at(-1).wrap.contains(n)}t.push({wrap:f,t:document.activeElement}),v.focus();var s=n(v,"blur",function(){a&&m()&&u&&l.focus()}),b=n(l,"blur",function(){a&&m()&&!u&&v.focus()}),p=n(document,"focusin",function(n){a&&!m(n.target)&&(u?l:v).focus()});return{update:function(n){a=n.active},destroy:function(){p(),s(),b(),t.pop().t.focus()}}};

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

import{listen as t}from"svelte/internal";let e=[],n=!1;function r(r,o={active:!0}){var u,l;let{wrap:c=r,active:a}=o;const i=[...c.querySelectorAll("*")].filter(t=>t.tabIndex>=0),d=null!=(u=i.at(0))?u:c,m=null!=(l=i.at(-1))?l:c;function s(t=c){return e.at(-1).wrap.contains(t)}e.push({wrap:c,t:document.activeElement}),d.focus();const p=t(d,"blur",()=>{a&&s()&&n&&m.focus()}),v=t(m,"blur",()=>{a&&s()&&!n&&d.focus()}),f=t(document,"focusin",t=>{a&&!s(t.target)&&(n?m:d).focus()});return{update(t){a=t.active},destroy(){f(),p(),v(),e.pop().t.focus()}}}t(document,"keydown",t=>{n=t.shiftKey&&"Tab"===t.key});export{r as lockFocus};
import{listen as t}from"svelte/internal";let e=[],n=!1;function r(r,o={active:!0}){var u,l;let{wrap:c=r,active:a}=o;const i=[...c.querySelectorAll("*")].filter(t=>t.tabIndex>=0),d=null!=(u=i.at(0))?u:c,m=null!=(l=i.at(-1))?l:c;function s(t=c){return e.at(-1).wrap.contains(t)}e.push({wrap:c,t:document.activeElement}),d.focus();const p=t(d,"blur",()=>{a&&s()&&n&&m.focus()}),v=t(m,"blur",()=>{a&&s()&&!n&&d.focus()}),f=t(document,"focusin",t=>{a&&!s(t.target)&&(n?m:d).focus()});return{update(t){a=t.active},destroy(){f(),p(),v(),e.pop().t.focus()}}}t(document,"keydown",t=>{n=t.shiftKey&&"Tab"===t.key});export{r as trapFocus};

@@ -26,3 +26,3 @@ import { listen } from 'svelte/internal'

/** Locks focus within a wrapper element */
function lockFocus(node: HTMLElement, options: TrapOptions = { active: true }) {
function trapFocus(node: HTMLElement, options: TrapOptions = { active: true }) {
let { wrap = node, active } = options

@@ -88,2 +88,2 @@

export { lockFocus }
export { trapFocus }
{
"name": "trap-focus-svelte",
"version": "0.0.1",
"license": "MIT",
"description": "Small 0.4kB focus trap that supports stacking, toggling, and custom scope",
"keywords": [
"focus",
"focus trap",
"focus lock",
"svelte"
],
"author": "Hank Dollman <hank@henrygd.me> (https://henrygd.me)",
"repository": {
"type": "git",
"url": "https://github.com/henrygd/trap-focus-svelte.git"
},
"bugs": {
"url": "https://github.com/henrygd/trap-focus-svelte/issues"
},
"homepage": "https://trap-focus-svelte.henrygd.me",
"type": "module",
"source": "index.ts",
"exports": {
".": {
"import": "./dist/trap-focus-svelte.svelte.js",
"require": "./dist/trap-focus-svelte.cjs",
"default": "./dist/trap-focus-svelte.svelte.js"
},
"./svelte": "./dist/trap-focus-svelte.svelte.js",
"./vanilla": "./dist/trap-focus-svelte.mjs"
},
"svelte": "./dist/trap-focus-svelte.svelte.js",
"mangle": {
"regex": "^lastActiveElement$"
},
"scripts": {
"build": "run-p build-cjs build-module build-svelte && sed -i 's/Promise.resolve();//' dist/*",
"build-cjs": "microbundle -i index.ts -o ./dist/trap-focus-svelte.cjs.js --no-pkg-main -f cjs --sourcemap false",
"build-module": "microbundle -i index.ts -o ./dist/trap-focus-svelte.mjs --no-pkg-main -f modern --sourcemap false",
"build-svelte": "microbundle -i index.ts -o ./dist/trap-focus-svelte.svelte.js --no-pkg-main -f modern --external svelte --sourcemap false",
"dev": "vite demo",
"demo-build": "vite build demo",
"preview": "vite demo preview",
"check": "svelte-check --tsconfig ./tsconfig.json"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^2.0.2",
"@tsconfig/svelte": "^3.0.0",
"hide-show-scroll": "^2.0.0",
"microbundle": "^0.15.1",
"npm-run-all": "^4.1.5",
"svelte": "^3.55.1",
"svelte-check": "^2.10.3",
"tslib": "^2.5.0",
"typescript": "^4.9.3",
"vite": "^4.1.0"
}
}
"name": "trap-focus-svelte",
"version": "0.1.0",
"license": "MIT",
"description": "Small 0.4kB focus trap that supports stacking, toggling, and custom scope",
"keywords": [
"focus",
"focus trap",
"focus lock",
"svelte"
],
"author": "Hank Dollman <hank@henrygd.me> (https://henrygd.me)",
"repository": {
"type": "git",
"url": "https://github.com/henrygd/trap-focus-svelte.git"
},
"bugs": {
"url": "https://github.com/henrygd/trap-focus-svelte/issues"
},
"homepage": "https://trap-focus-svelte.henrygd.me",
"type": "module",
"source": "index.ts",
"exports": {
".": {
"import": "./dist/trap-focus-svelte.svelte.js",
"require": "./dist/trap-focus-svelte.cjs",
"default": "./dist/trap-focus-svelte.svelte.js"
},
"./svelte": "./dist/trap-focus-svelte.svelte.js",
"./vanilla": "./dist/trap-focus-svelte.mjs"
},
"svelte": "./dist/trap-focus-svelte.svelte.js",
"mangle": {
"regex": "^lastActiveElement$"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^2.0.2",
"@tsconfig/svelte": "^3.0.0",
"hide-show-scroll": "^2.0.0",
"microbundle": "^0.15.1",
"npm-run-all": "^4.1.5",
"svelte": "^3.55.1",
"svelte-check": "^2.10.3",
"tslib": "^2.5.0",
"typescript": "^4.9.3",
"vite": "^4.1.0"
},
"scripts": {
"build": "run-p build-cjs build-module build-svelte && sed -i 's/Promise.resolve();//' dist/*",
"build-cjs": "microbundle -i index.ts -o ./dist/trap-focus-svelte.cjs.js --no-pkg-main -f cjs --sourcemap false",
"build-module": "microbundle -i index.ts -o ./dist/trap-focus-svelte.mjs --no-pkg-main -f modern --sourcemap false",
"build-svelte": "microbundle -i index.ts -o ./dist/trap-focus-svelte.svelte.js --no-pkg-main -f modern --external svelte --sourcemap false",
"dev": "vite demo",
"demo-build": "vite build demo",
"preview": "vite demo preview",
"check": "svelte-check --tsconfig ./tsconfig.json"
}
}

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