# needy-element

> An angular directive to shake a form field when it is invalid (needs attention).

Latest version **1.0.4** (published 2023-10-24) · 0 weekly downloads

## Install

```sh
npm install needy-element
pnpm add needy-element
yarn add needy-element
bun add needy-element
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2023-10-24 |
| First published | 2023-07-26 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 103.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | T Motsoeneng |
| Maintainers | tshepo-m |
| Keywords | needy-element, angular, directive, error, shake, form-field, element, front-end, front end |

## Links

- npm: https://www.npmjs.com/package/needy-element
- npm.io page: https://npm.io/package/needy-element

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.0.4 (latest) — 2023-10-24
- 1.0.3 — 2023-09-27
- 1.0.2 — 2023-09-20
- 1.0.1 — 2023-09-13
- 1.0.0 — 2023-09-12
- 0.0.6 — 2023-09-01
- 0.0.5 — 2023-09-01
- 0.0.4 — 2023-09-01
- 0.0.3 — 2023-07-26
- 0.0.2 — 2023-07-26
- 0.0.1 — 2023-07-26

## README

# NeedyElement

An angular directive to shake a form field when it is invalid (needs attention).

[![My Skills](https://skills.thijs.gg/icons?i=angular)](https://skills.thijs.gg)

###### This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 15.0.0.

## Installation :wrench:

```
npm install needy-element
```
:warning: **Note:** Please don't forget to import the module `NeedyElementModule`, in the appropriate module when using in an Angular project.

## Usage :woman_mechanic:

This directive was designed to be applied on a Mat-Form-Field in a Reactive form, and the prerequisites are:
- a form group
- form controls
- control validation to trigger the directive 

By default, the directive will shake an element when it has the "mat-form-field-invalid" class, but you can specify a different class to trigger the directive, when using it with other elements other than the mat-form-field.

### Using on a mat-form-field (trigger when the field is invalid)
```
<div>
   <mat-form-field needy>
      <input matInput id="someId" 
        formControlName="someFormControl" required>
   </mat-form-field>
</div>
```

### Using on a custom element (trigger when the specified class is added to the element) 
```
<div>
  <input id="someElement" [needy]="trigger-class"/>
</div>
```
:warning: **Note:** The directive will trigger (shake the element) when the class is detected on the element, when adding it using the method below or some other method: 
```
  document.getElementById('someElement').classList.add('trigger-class');
```

## Examples :desktop_computer:

If you need more detailed examples, please visit: 
  https://stackblitz.com/edit/stackblitz-starters-wvqznt?file=src%2Fapp%2Fapp.component.ts

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