{"id":17405841,"url":"https://github.com/Brakebein/ngx-tagify","last_synced_at":"2025-02-28T10:32:54.348Z","repository":{"id":38298862,"uuid":"327708947","full_name":"Brakebein/ngx-tagify","owner":"Brakebein","description":"Angular library that wraps https://github.com/yaireo/tagify/","archived":false,"fork":false,"pushed_at":"2024-11-30T15:26:49.000Z","size":4503,"stargazers_count":26,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-30T15:29:27.375Z","etag":null,"topics":["angular","angular-library","tagify"],"latest_commit_sha":null,"homepage":"","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/Brakebein.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2021-01-07T19:42:59.000Z","updated_at":"2024-11-30T15:24:52.000Z","dependencies_parsed_at":"2024-03-24T11:31:19.054Z","dependency_job_id":"d3d13afa-2a82-4285-a961-f1bbac71fc0c","html_url":"https://github.com/Brakebein/ngx-tagify","commit_stats":{"total_commits":101,"total_committers":5,"mean_commits":20.2,"dds":0.2178217821782178,"last_synced_commit":"8aacbe5b0ce50a60e5b2f6bde86488cb41833359"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brakebein%2Fngx-tagify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brakebein%2Fngx-tagify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brakebein%2Fngx-tagify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Brakebein%2Fngx-tagify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Brakebein","download_url":"https://codeload.github.com/Brakebein/ngx-tagify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241138482,"owners_count":19916333,"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":["angular","angular-library","tagify"],"created_at":"2024-10-16T21:01:14.345Z","updated_at":"2025-02-28T10:32:54.341Z","avatar_url":"https://github.com/Brakebein.png","language":"TypeScript","funding_links":[],"categories":["Framework Interoperability"],"sub_categories":["Wrappers"],"readme":"# ngx-tagify\n\nProper Angular library that wraps [@yaireo/tagify](https://github.com/yairEO/tagify).\nIt allows multiple instances of tagify, implements ControlValueAccessor (for use with `ngModel` and reactive forms), and includes proper type declarations.\n\n__[Demo](https://brakebein.github.io/ngx-tagify/)__\n\n* [Install](#install)\n* [Component](#component)\n  * [Usage with ngModel](#usage-with-ngmodel)\n  * [Usage with Reactive Forms](#usage-with-reactive-forms)\n  * [Predefined values](#predefined-values)\n  * [Inputs](#inputs)\n  * [Outputs](#outputs)\n* [Service](#service)\n* [Styling](#styling)\n* [FAQ](#faq)\n\n## Install\n\nInstall via npm:\n\n    npm install ngx-tagify\n\nImport module:\n\n```typescript\nimport { TagifyModule } from 'ngx-tagify'; \n\n@NgModule({\n  imports: [\n    ...\n    TagifyModule,\n    ...\n  ]\n})\nexport class AppModule {}\n```\n\nInclude styling (see [below](#styling)).\n\n## Component\n\nYou can use the `\u003ctagify\u003e` component either with `ngModel` or with reactive forms.\nEither way, it takes a `string` or an array of `TagData`, i.e. an `Object` that contains a unique property `value`:\n\n```typescript\ninterface TagData {\n  value: string;\n  [key: string]: any;\n}\n```\n\nIf a string is passed, it gets parsed for tags by Tagify. The returned string is the stringified tags array or, if `mode: 'mix'`, the mixed text and tags string.\n\n### Usage with `ngModel`\n\nImport `FormsModule` to your module.\n\n```html\n\u003ctagify\n  [(ngModel)]=\"tags\"\n  inputClass=\"form-control\"\n  [settings]=\"settings\"\n  [whitelist]=\"whitelist$\"\n  [readonly]=\"readonly\"\n  [disabled]=\"disabled\"\n  (add)=\"onAdd($event)\"\n  (remove)=\"onRemove($event)\"\n\u003e\u003c/tagify\u003e\n```\n\n```typescript\nimport { Component } from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\nimport { TagData, TagifySettings } from 'ngx-tagify';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: './app.component.html',\n  styleUrls: ['./app.component.css']\n})\nexport class AppComponent {\n    \n  tags: TagData[] = [{ value: 'foo' }];\n  // tags = 'foo'; -\u003e if you want to pass as string\n    \n  settings: TagifySettings = {\n    placeholder: 'Start typing...',\n    blacklist: ['fucking', 'shit'],\n    callbacks: {\n      click: (e) =\u003e { console.log(e.detail); }\n    }\n  };\n  \n  whitelist$ = new BehaviorSubject\u003cstring[]\u003e(['hello', 'world']);\n  \n  readonly = false;\n  \n  disabled = false;\n  \n  onAdd(tagify) {\n    console.log('added a tag', tagify);  \n  }\n  \n  onRemove(tags) {\n    console.log('removed a tag', tags);\n  }\n  \n}\n```\n\n__Note:__ The component only recognizes reference changes, it won't deep check for changes within the array.\n`this.tags.push({value: 'bar'});` won't do anything.\nInstead, use `this.tags = this.tags.concat([{value: 'bar'}]);` (or similar) to update changes.\n\n### Usage with Reactive Forms\n\nImport `ReactiveFormsModule` to your module.\n\n```html\n\u003cform [formGroup]=\"form\"\u003e\n  \u003ctagify formControlName=\"tags\"\u003e\u003c/tagify\u003e\n\u003c/form\u003e\n```\n\n```typescript\nimport { Component, OnInit } from '@angular/core';\nimport { FormControl, FormGroup } from '@angular/forms';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: './app.component.html',\n  styleUrls: ['./app.component.css']\n})\nexport class AppComponent implements OnInit {\n  \n  form = new FormGroup({\n    tags: new FormControl([{ value: 'Reactive' }])\n  });\n    \n  ngOnInit(): void {\n      \n    this.form.valueChanges.subscribe(value =\u003e {\n      console.log('form value changed', value);\n    });\n      \n  }\n  \n}\n```\n\n### Predefined values\n\nUse `ngModel` or reactive forms with an initial string value that gets parsed by Tagify.\n\nIf you want to pass predefined tags as text, but receive a tags array as output, pass the value as text between `\u003ctagify\u003e\u003c/tagify\u003e`. Mixed text \u0026 tags are also supported.\n```html\n\u003ctagify\u003etag 1, tag 2\u003c/tagify\u003e\n```\n```html\n\u003ctagify [settings]=\"{ mode: 'mix' }\"\u003e\n  [[Eric Cartman]] and [[kyle]] do not know [[homer simpson]] because he's a relic.\n\u003c/tagify\u003e\n```\n\nAngular has problems with hard-coded single curly braces. Use property binding to add predefined tags with json syntax.\n\n```typescript\noriginalText = '[[{\"id\":200, \"value\":\"cartman\", \"title\":\"Eric Cartman\"}]] and [[kyle]] do not know [[{\"value\":\"homer simpson\", \"readonly\":true}]] because he\\'s a relic.';\n```\n```html\n\u003ctagify [settings]=\"{ mode: 'mix' }\"\u003e\n  {{ originalText }}\n\u003c/tagify\u003e\n```\n\n### Inputs\n\n| \u003c!-- --\u003e     | \u003c!-- --\u003e                                                                                                                                                                                               |\n|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `settings`   | _Type:_ `TagifySettings`\u003cbr\u003eSee [tagify/Settings](https://github.com/yairEO/tagify#settings).                                                                                                          |\n| `inputClass` | _Type:_ `string`\u003cbr\u003eApply one or more CSS classes to the input field (e.g. Bootstrap's `form-control`).                                                                                                |\n| `whitelist`  | _Type:_ `Observable\u003cstring[]\\|TagData[]\u003e`\u003cbr\u003eExecution of the observable updates the whitelist of tagify. You can listen to user's inputs and update the whitelist respectively using this observable. |\n| `readonly`   | _Type:_ `boolean`\u003cbr\u003eDynamically change readonly status.                                                                                                                                               |\n| `disabled`   | _Type:_ `boolean`\u003cbr\u003eDynamically change disabled status.                                                                                                                                               |\n| `name`       | _Type:_ `string`\u003cbr\u003eUse the name attribute if you want to access the tagify component via the [service](#service). This name should be unique.                                                         |\n\n### Outputs\n\n| \u003c!-- --\u003e | \u003c!-- --\u003e |\n|---|---|\n|`add`|Fires when a tag has been added.|\n|`remove`|Fires when a tag has been removed.|\n|`tInput`|Listen to the `input` event of the tagify input element.|\n\nListen to all other events by defining respective callbacks ([tagify/Events](https://github.com/yairEO/tagify#events)).\n\n\n## Service\n\nYou can also gain access to the full [tagify API](https://github.com/yairEO/tagify#methods) via a service.\nProvide a `name`, such that the tagify instance will be available via the service.\n\n```html\n\u003ctagify name=\"example\"\u003e\u003c/tagify\u003e\n\u003cbutton (click)=\"addTags()\"\u003eAdd tags\u003c/button\u003e\n```\n\n```typescript\nimport { Component } from '@angular/core';\nimport { TagifyService } from 'ngx-tagify';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: './app.component.html',\n  styleUrls: ['./app.component.css']\n})\nexport class AppComponent {\n  \n  constructor(\n    private tagifyService: TagifyService\n  ) {}\n  \n  addTags() {\n    this.tagifyService.get('example').addTags(['this', 'is', 'cool']);\n  }\n  \n}\n```\n\nThe original Tagify class is also exposed and can be used for type declarations or custom implementations.\n\n```typescript\nimport { Tagify } from 'ngx-tagify';\n\nconst tagify: Tagify = new Tagify(inputElement);\n```\n\n## Styling\n\nYou have two options to include the styling of Tagify.\n\n__Option 1:__ Modify your `angular.json` by adding the `.scss` file to the `styles` property.\n\n```json\n\"options\": {\n  \"styles\": [\n    \"node_modules/ngx-tagify/styles/tagify.scss\",\n    \"src/styles.scss\"\n  ]\n}\n```\n\n__Option 2:__ If you want to override some of the styling, import it to a sass file. Have a look at [tagify/CSS Variables](https://github.com/yairEO/tagify#css-variables) and respective demo page for details.\n\n```scss\n// src/styles.scss\n@import \"ngx-tagify/styles/tagify\";\n\n.tagify\n  --tags-border-color: #ff0000;\n```\n\n#### Usage with Bootstrap\n\nIf you are using Bootstrap as CSS framework (as used in the demo), you might need to tweak some styles in order that Tagify looks pretty:\n\n```scss\n.tagify {\n  --tag-pad: 0 0.5rem;\n  line-height: 1.5;\n}\n.tagify__input:empty::before {\n  line-height: inherit;\n}\n.tagify.form-control {\n  height: unset;\n}\n```\n\n\n## FAQ\n\n### I'm getting TS compilation error!\n\nYou are getting TypeScript compilation error with an error output like this:\n\n```\n node_modules/@types/yaireo__tagify/index.d.ts:475:1\n    475 export = Tagify;\n        ~~~~~~~~~~~~~~~~\n    This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.\n```\n\nTo resolve this issue, set `allowSyntheticDefaultImports` within `compilerOptions` in your `tsconfig.json`:\n\n```json\n{\n  \"compilerOptions\": {\n    \n    \"allowSyntheticDefaultImports\": true,\n    \n  }\n}\n```\n\n### I'm getting build error because stylesheet could not be found!\n\n```\nModule build failed (from ./node_modules/@angular-devkit/build-angular/node_modules/sass-loader/dist/cjs.js):\nCan't find stylesheet to import.\n  ╷\n1 │ @import \"@yaireo/tagify/src/tagify\";\n  │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  ╵\n  node_modules/ngx-tagify/styles/tagify.scss 1:9  root stylesheet\n```\n\nMake sure you include `node_modules` in the `stylePreprocessorOptions` within your `angular.json`:\n\n```json\n\"stylePreprocessorOptions\": {\n  \"includePaths\": [\"node_modules\"]\n},\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBrakebein%2Fngx-tagify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBrakebein%2Fngx-tagify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBrakebein%2Fngx-tagify/lists"}