# @apsc/focus-action

> Action to control focusin and focusout for Svelte directive use:

Latest version **0.0.5** (published 2023-02-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @apsc/focus-action
pnpm add @apsc/focus-action
yarn add @apsc/focus-action
bun add @apsc/focus-action
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2023-02-01 |
| First published | 2022-06-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Andrey Pavlenko |
| Maintainers | andrey-pavlenko |
| Keywords | svelte, action, focus |

## Links

- npm: https://www.npmjs.com/package/@apsc/focus-action
- Repository: https://github.com/andrey-pavlenko/svelte-components
- Homepage: https://github.com/andrey-pavlenko/svelte-components/tree/main/packages/focus-action#readme
- Issues: https://github.com/andrey-pavlenko/svelte-components/issues
- npm.io page: https://npm.io/package/@apsc/focus-action

## Recent versions

- 0.0.5 (latest) — 2023-02-01
- 0.0.4 — 2023-02-01
- 0.0.3 — 2022-10-02
- 0.0.2 — 2022-06-05
- 0.0.1 — 2022-06-02

## README

# Action to control `focusin` and `focusout` for Svelte directive `use`

- no dependencies
- based on `focusin` and `focusout` events.
- correctly detects loss of focus with `tab` key

### [Docs & Demo](https://andrey-pavlenko.github.io/svelte-components/?c=focus-action)

## Install

### NPM

```sh
npm i -D @apsc/focus-action
```

### PNPM

```sh
pnpm add -D @apsc/focus-action
```

## API

```ts
let focused = false;
const focusFns = [() => (focused = true), () => (focused = false)];

<div class:focused use:useFocus={focusFns}>
  ...
</div>;
```

Based on [`focusin`](https://developer.mozilla.org/en-US/docs/Web/API/Element/focusin_event) and [`focusout`](https://developer.mozilla.org/en-US/docs/Web/API/Element/focusout_event) events.

Executes callbacks when the node or its children gain or lose focus.

Ensure the `node` or its children [can be focused](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus)

---
_Source: https://npm.io/package/@apsc/focus-action · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
