├── .eslintrc.cjs ├── .gitignore ├── .npmrc ├── .nvmrc ├── .prettierrc.json ├── .storybook ├── main.ts └── preview.ts ├── LICENSE ├── README.md ├── env.d.ts ├── package.json ├── src ├── FocusLock.vue ├── index.ts └── stories │ ├── GroupStory.stories.ts │ ├── GroupStory.vue │ ├── LockStory.stories.ts │ ├── LockStory.vue │ ├── NoFocusGuardsStory.stories.ts │ ├── NoFocusGuardsStory.vue │ ├── NoTailingGuardStory.stories.ts │ └── NoTailingGuardStory.vue ├── tsconfig.json ├── vite.config.ts └── yarn.lock /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | require('@rushstack/eslint-patch/modern-module-resolution') 3 | 4 | module.exports = { 5 | root: true, 6 | extends: [ 7 | 'plugin:vue/vue3-essential', 8 | 'eslint:recommended', 9 | '@vue/eslint-config-typescript', 10 | '@vue/eslint-config-prettier/skip-formatting', 11 | 'plugin:storybook/recommended', 12 | 'plugin:prettier-vue/recommended' 13 | ], 14 | parserOptions: { 15 | ecmaVersion: 'latest' 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | .DS_Store 12 | dist 13 | dist-ssr 14 | coverage 15 | *.local 16 | 17 | /cypress/videos/ 18 | /cypress/screenshots/ 19 | 20 | # Editor directories and files 21 | .vscode/* 22 | .idea 23 | *.suo 24 | *.ntvs* 25 | *.njsproj 26 | *.sln 27 | *.sw? 28 | 29 | *.tsbuildinfo 30 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 18 -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/prettierrc", 3 | "semi": false, 4 | "tabWidth": 2, 5 | "singleQuote": true, 6 | "printWidth": 100, 7 | "trailingComma": "none" 8 | } -------------------------------------------------------------------------------- /.storybook/main.ts: -------------------------------------------------------------------------------- 1 | import type { StorybookConfig } from '@storybook/vue3-vite' 2 | 3 | const config: StorybookConfig = { 4 | stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], 5 | addons: [ 6 | '@storybook/addon-links', 7 | '@storybook/addon-essentials', 8 | '@storybook/addon-interactions' 9 | ], 10 | framework: { 11 | name: '@storybook/vue3-vite', 12 | options: {} 13 | }, 14 | docs: { 15 | autodocs: 'tag' 16 | } 17 | } 18 | export default config 19 | -------------------------------------------------------------------------------- /.storybook/preview.ts: -------------------------------------------------------------------------------- 1 | import type { Preview } from '@storybook/vue3' 2 | 3 | const preview: Preview = { 4 | parameters: { 5 | actions: { argTypesRegex: '^on[A-Z].*' }, 6 | controls: { 7 | matchers: { 8 | color: /(background|color)$/i, 9 | date: /Date$/i 10 | } 11 | } 12 | } 13 | } 14 | 15 | export default preview 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Anton 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-focus-lock 2 | It is a trap! We got your focus and will not let him out! 3 | 4 | [![NPM](https://nodei.co/npm/vue-focus-lock.png?downloads=true&stars=true)](https://nodei.co/npm/vue-focus-lock/) 5 | 6 | ---- 7 | 8 | - __Vue3 users__ - use v3+ `vue-focus-lock@3` 9 | - __Vue2 users__ - use v2+ `vue-focus-lock@2` 10 | 11 | ---- 12 | 13 | This is a small, but very useful for: 14 | - Modal dialogs. You can not leave it with "Tab", ie tab-out. 15 | - Focused tasks. It will always brings you back. 16 | 17 | You have to use it in _every_ modal dialog, or you `a11y` will be shitty. 18 | 19 | # How to use 20 | Just wrap something with focus lock, and focus will be `moved inside` on mount. 21 | ```html 22 | 23 | You can not leave this form 24 |