# @dzik/mentions

> Mentions component for Angular.

Latest version **1.0.8** (published 2022-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dzik/mentions
pnpm add @dzik/mentions
yarn add @dzik/mentions
bun add @dzik/mentions
```

## 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.8 |
| Published | 2022-09-02 |
| First published | 2022-09-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 923.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | krystianjjj |
| Maintainers | krystianjjj |
| Keywords | angular, javascript, typescript, component, mentions, input-highlight, autocomplete |

## Links

- npm: https://www.npmjs.com/package/@dzik/mentions
- Repository: https://github.com/krystian-jedrzejowski/flxng
- Homepage: https://github.com/krystian-jedrzejowski/flxng#readme
- Issues: https://github.com/krystian-jedrzejowski/flxng/issues
- npm.io page: https://npm.io/package/@dzik/mentions

## Dependencies (1)

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

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.8 (latest) — 2022-09-02
- 1.0.7 — 2022-09-01

## README

# Angular @Mentions Component forked from @flxng/mentions with some fixes and improvements
**@dzik/mentions**



Flexible, lightweight, easy-to-use, without external dependencies - Mentions component for Angular.


## Docs and Demo
https://flxng.codeeve.com/#/mentions

![Mentions GIF](https://media.giphy.com/media/lbmJHnfOIiolzvJ0ZC/giphy.gif)


## Getting Started
Installation:
```bash
$ npm i @dzik/mentions
```

After importing the module the lib is ready to use:
```typescript
import { MentionsModule } from '@dzik/mentions';

@NgModule({
  imports: [MentionsModule],
  declarations: [],
})
export class DemoModule {}
```

## Usage
Check also [Docs and Demo](https://flxng.codeeve.com/#/mentions).

### @Inputs
Name | Description | Type | Default
--- | --- | --- | ---
`textInputElement` | Reference to the text input element. | `HTMLTextAreaElement` | Required
`menuTemplate` | Reference to the menu template (used to display the search results). | `TemplateRef` | Required
`getChoiceLabel` | A function that formats the selected choice once selected. The result (label) is also used as a choice identifier (e.g. when editing choices).  | `(choice: any) => string` | Required
`triggerCharacter` | The character which will trigger the search. | `string` | `@`
`searchRegexp` | The regular expression that will match the search text after the trigger character. No match will hide the menu. | `RegExp` | `/^\w*$/`
`closeMenuOnBlur` | Whether to close the menu when the host `textInputElement` loses focus. | `boolean` | `false`
`selectedChoices` | Pre-set choices for edit text mode, or to select/mark choices from outside the mentions component. | `any[]` | `[]`
`tagCssClass` | The CSS class to add to highlighted tags. | `string` | `''`

### @Outputs
Name | Description | Output type
--- | --- | ---
`search` | Called on user input after entering trigger character. Emits search term to search by. | `string`
`menuShow` | Called when the choices menu is shown. | `void`
`menuHide` | Called when the choices menu is hidden. | `void`
`choiceSelected` | Called when a choice is selected. | `ChoiceWithIndices`
`choiceRemoved` | Called when a choice is removed. | `ChoiceWithIndices`
`selectedChoicesChange` | Called when a choice is selected, removed, or if any of the choices' indices change. | `ChoiceWithIndices[]`
`tagClick` | Called when the area over a tag is clicked. | `TagMouseEvent`
`tagMouseEnter` | Called when the area over a tag is moused over. | `TagMouseEvent`
`tagMouseLeave` | Called when the area over the tag has the mouse removed from it. | `TagMouseEvent`

### Basic example
```html
<div class="relative-block-container">
  <textarea cols="42"
            rows="6"
            #textareaRef
            placeholder="Enter '@' and start typing..."
            [(ngModel)]="text"></textarea>

  <flx-mentions [textInputElement]="textareaRef"
                [menuTemplate]="menuTemplate"
                [triggerCharacter]="'@'"
                [getChoiceLabel]="getChoiceLabel"
                [searchRegexp]="'^([-&.\\w]+ *){0,3}$'"
                (search)="loadChoices($event)"
                (selectedChoicesChange)="onSelectedChoicesChange($event)"
                (menuShow)="onMenuShow()"
                (menuHide)="onMenuHide()"></flx-mentions>

  <ng-template #menuTemplate
               let-selectChoice="selectChoice">
    <ul class="flx-selectable-list">
      <li *ngFor="let user of choices"
          class="flx-selectable-list-item"
          (click)="selectChoice(user)">
        <span title="{{user.name}}">{{user.name}}</span>
      </li>
    </ul>
  </ng-template>
</div>
```

More examples [here](https://flxng.codeeve.com/#/mentions).

## Support
All suggestions and improvements are welcome and appreciated.


## License
The [MIT License](https://github.com/seidme/flxng/blob/master/LICENSE).

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