{"id":25158442,"url":"https://github.com/raiper34/ngx-focus-control","last_synced_at":"2025-04-30T11:12:35.440Z","repository":{"id":38192123,"uuid":"411049391","full_name":"Raiper34/ngx-focus-control","owner":"Raiper34","description":"Library to provide tools to work with focus and focusable elements to improve user interfaces and accessibility.","archived":false,"fork":false,"pushed_at":"2025-04-08T18:22:44.000Z","size":4465,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-26T00:03:51.516Z","etag":null,"topics":["accessibility","angular","directives","focus"],"latest_commit_sha":null,"homepage":"https://ngx-focus-control.netlify.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Raiper34.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-09-27T21:33:49.000Z","updated_at":"2025-04-08T18:22:47.000Z","dependencies_parsed_at":"2024-04-01T19:50:47.900Z","dependency_job_id":null,"html_url":"https://github.com/Raiper34/ngx-focus-control","commit_stats":{"total_commits":102,"total_committers":1,"mean_commits":102.0,"dds":0.0,"last_synced_commit":"96b5d8689e33af3f9fee90d02a28309a5edef59b"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raiper34%2Fngx-focus-control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raiper34%2Fngx-focus-control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raiper34%2Fngx-focus-control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raiper34%2Fngx-focus-control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Raiper34","download_url":"https://codeload.github.com/Raiper34/ngx-focus-control/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251687006,"owners_count":21627509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accessibility","angular","directives","focus"],"created_at":"2025-02-09T01:51:44.746Z","updated_at":"2025-04-30T11:12:35.432Z","avatar_url":"https://github.com/Raiper34.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/ngx-focus-control.svg)](https://badge.fury.io/js/ngx-focus-control)\n[![CircleCI](https://circleci.com/gh/Raiper34/ngx-focus-control.svg?style=shield)](https://circleci.com/gh/Raiper34/ngx-focus-control)\n[![Coverage Status](https://coveralls.io/repos/github/Raiper34/ngx-focus-control/badge.svg?branch=main)](https://coveralls.io/github/Raiper34/ngx-focus-control?branch=main)\n[![GitHub issues](https://img.shields.io/github/issues/Raiper34/ngx-focus-control)](https://github.com/Raiper34/ngx-focus-control/issues)\n![npm bundle size](https://img.shields.io/bundlephobia/min/ngx-focus-control)\n![NPM](https://img.shields.io/npm/l/ngx-focus-control)\n[![demo](https://badgen.net/badge/demo/online/orange)](https://ngx-focus-control.netlify.app/)\n[![stack blitz](https://badgen.net/badge/stackblitz/online/orange)](https://stackblitz.com/edit/angular-ivy-nsumon)\n[![Gitter](https://img.shields.io/gitter/room/raiper34/ngx-focus-control)](https://gitter.im/ngx-focus-control/community?source=orgpage)\n\n![ngc focus control logo](logo.svg)\n# Ngx Focus Control\nAngular library to provide tools to work with focus and focusable elements to improve user interfaces and accessibility.\n\n# Version compatibility\n| Angular version | Ngx focus control version |\n|-----------------|---------------------------|\n| 8 - 13          | 0.0.0 - 3.x.x             |\n| 14              | 4.x.x                     |\n| 15              | 5.x.x                     |\n| 16              | 6.x.x                     |\n| 17              | 7.x.x                     |\n\n# Instalation\n\n`npm install ngx-focus-control --save`\n\nthen add `NgxFocusControlModule` into module imports\n```typescript\nimport {NgxFocusControlModule} from 'ngx-focus-control';\n\n@NgModule({\n// ...\n  imports: [\n    // ...\n    NgxFocusControlModule,\n    // ...\n  ],\n// ...\n})\n```\n\n# Usage\nSee [DEMO](https://ngx-focus-control.netlify.app/) app for usage.\n\n# Directives\n- ### Focus auto directive\nauto-focuses element when an element is created, a page is visited, or delay data bidding is changed. Users can define delay of focus. 0 is the default delay when a delay is not specified.\n```html\n\u003cinput placeholder=\"Input\" class=\"input\" [fuAuto]=\"500\"\u003e\n```\n- ### Focus control directive\nallows the user to manually define the next and/or previous focus target.\n```html\n\u003cinput placeholder=\"Input 1\" class=\"input\" id=\"input-1\" [fuControl]=\"{next: '#input-3', previous: input2}\"\u003e\n\u003cinput #input2 placeholder=\"Input 2\" class=\"input\" id=\"input-2\" [fuControl]=\"{next: '#input-1', previous: '#input-3'}\"\u003e\n\u003cinput placeholder=\"Input 3\" class=\"input\" id=\"input-3\" [fuControl]=\"{next: input2, previous: '#input-1'}\"\u003e\n```\n- ### Focus selector directive\nallows the user to manually define the next and previous focus target by the given query selector.\n```html\n\u003cinput placeholder=\"Input 1\" class=\"input focus-selector-item\" [fuSelector]=\"'.focus-selector-item'\"\u003e\n\u003cinput placeholder=\"Input 2\" class=\"input\"\u003e\n\u003cinput placeholder=\"Input 3\" class=\"input focus-selector-item\" [fuSelector]=\"'.focus-selector-item'\"\u003e\n```\n- ### Focus group directive\nallows merging focusable elements into the group. The user focuses the whole group and can enter into this group by Enter press and leave the group by Escape press.\n```html\n\u003cdiv tabindex=\"0\" id=\"group-1\" class=\"box focus-selector-parent\" [fuGroup]=\"{selector: '.focus-group-item'}\"\u003e\n  \u003cdiv class=\"subtitle has-text-black\"\u003eGroup\u003c/div\u003e\n  \u003cinput type=\"text\" tabindex=\"-1\" placeholder=\"Input 1\" class=\"input focus-group-item\" id=\"input-1\"\u003e\n  \u003cinput type=\"text\" tabindex=\"-1\" placeholder=\"Input 2\" class=\"input focus-group-item\" id=\"input-2\"\u003e\n\u003c/div\u003e\n```\n- ### Focus lock directive\nlocks some area (div, span...). The first and last focusable child of the directive element are connected together (the next focus target of the last child is the first child and vice versa), useful for accessible modals.\n```html\n\u003cdiv id=\"lock-1\" class=\"box focus-selector-parent\" fuLock\u003e\n  \u003cinput type=\"text\" placeholder=\"Input 1\" class=\"input\" id=\"input-1\"\u003e\n  \u003cinput type=\"text\" placeholder=\"Input 2\" class=\"input\" id=\"input-2\"\u003e\n  \u003cinput type=\"text\" placeholder=\"Input 3\" class=\"input\" id=\"input-3\"\u003e\n\u003c/div\u003e\n```\n- ### Focus if directive\nfocuses the element when condition bidding changes to True or blurs the element when condition bidding changes to False. Instead of primitive value, you can also pass observable, which focuses element when observable emits True and blur element when observable emits False.\n```html\n\u003cinput type=\"text\" placeholder=\"Input 16\" class=\"input\" id=\"input-16\" [fuIf]=\"condition\"\u003e\n\u003cinput type=\"text\" placeholder=\"Input 17\" class=\"input\" id=\"input-17\" [fuIf]=\"observable$\"\u003e\n```\n- ### Focus switch directives\non parent element with some variable focuses child element with the value provided in focus case directive that matches. It matches the first element from top to bottom. If there is no match and you use the focus default directive, the element with this directive is focused. Value needs to change, to focus the element (if the switch variable has got value 0, and you set the variable again to 0, the element will not be focused). You can also pass observable into focus switch directive (works similar as in focus if directive).\n```html\n\u003cng-container [fuSwitch]=\"switchValue\"\u003e\n  \u003cinput type=\"text\" placeholder=\"Input 1\" class=\"input\" id=\"input-1\" [fuCase]=\"'option-1'\"\u003e\n  \u003cinput type=\"text\" placeholder=\"Input 2\" class=\"input\" id=\"input-2\" [fuCase]=\"'option-2'\"\u003e\n  \u003cinput type=\"text\" placeholder=\"Input 3\" class=\"input\" id=\"input-3\" [fuCase]=\"'option-3'\"\u003e\n  \u003cinput type=\"text\" placeholder=\"Input 4 Default\" class=\"input\" id=\"input-4\" fuDefault\u003e\n\u003c/ng-container\u003e\n\u003cbutton class=\"button is-success\" (click)=\"switchValue = 'option-1'\"\u003eFocus Input 1\u003c/button\u003e\n\u003cbutton class=\"button is-success\" (click)=\"switchValue = 'option-2'\"\u003eFocus Input 2\u003c/button\u003e\n\u003cbutton class=\"button is-success\" (click)=\"switchValue = 'option-3'\"\u003eFocus Input 3\u003c/button\u003e\n\u003cbutton class=\"button is-success\" (click)=\"switchValue = 'option-100'\"\u003eSwitch to non-existing value\u003c/button\u003e\n```\n- ### Focus history directive\nstores focused elements into history and thanks to history service `FocusHistoryService` you can go back in focus history using `focusHistoryService.focusPrevious()`.\n```html\n\u003cinput type=\"text\" placeholder=\"Input 1\" class=\"input\" id=\"input-1\" fuHistory\u003e\n\u003cinput type=\"text\" placeholder=\"Input 2\" class=\"input\" id=\"input-2\" fuHistory\u003e\n\u003cbutton class=\"button is-info\" (click)=\"focusHistoryService.focusPrevious()\"\u003eFocus previous\u003c/button\u003e\n```\n```ts\nimport {FocusHistoryService} from 'ngx-focus-control';\n...\nconstructor(public readonly focusHistoryService: FocusHistoryService) { }\n```\n\n- ### Focus unleavable directive\ndoes not allow leaving a focusable element when the provided condition is met.\n```html\n\u003cinput placeholder=\"Input 1\" class=\"input\" [(ngModel)]=\"inputContent\" [fuUnleavable]=\"inputContent.length \u003c 5\"\u003e\n```\n\n# License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraiper34%2Fngx-focus-control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraiper34%2Fngx-focus-control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraiper34%2Fngx-focus-control/lists"}