{"id":16428806,"url":"https://github.com/netanelbasal/nb-choices","last_synced_at":"2025-03-21T04:30:58.937Z","repository":{"id":57309057,"uuid":"116357181","full_name":"NetanelBasal/nb-choices","owner":"NetanelBasal","description":"Angular wrapper for choices.js, vanilla, lightweight, configurable select box/text input plugin","archived":false,"fork":false,"pushed_at":"2018-06-23T19:58:49.000Z","size":1171,"stargazers_count":32,"open_issues_count":7,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-01T02:41:22.895Z","etag":null,"topics":["angular","checkbox","choice","custom","dropdown","multiselect","select","tags","vanilla"],"latest_commit_sha":null,"homepage":"https://joshuajohnson.co.uk/Choices/","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/NetanelBasal.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}},"created_at":"2018-01-05T07:41:46.000Z","updated_at":"2023-09-08T17:34:45.000Z","dependencies_parsed_at":"2022-08-29T10:51:16.030Z","dependency_job_id":null,"html_url":"https://github.com/NetanelBasal/nb-choices","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fnb-choices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fnb-choices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fnb-choices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fnb-choices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NetanelBasal","download_url":"https://codeload.github.com/NetanelBasal/nb-choices/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244109575,"owners_count":20399559,"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","checkbox","choice","custom","dropdown","multiselect","select","tags","vanilla"],"created_at":"2024-10-11T08:19:07.582Z","updated_at":"2025-03-21T04:30:58.579Z","avatar_url":"https://github.com/NetanelBasal.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 📢 Angular Choices \n**Angular wrapper for choices.js** - vanilla, lightweight, configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency.\n\nLive Demo - https://stackblitz.com/edit/nb-choices\n\n## 🍭 Features\n\n - Angular forms support\n - Custom Angular templates\n - Placeholder support out of the box\n - Works with observables and the async pipe\n - Custom checkbox in multiple dropdowns\n - Escaping your HTML out of the box\n - Modern styling\n \n![Demo](https://s18.postimg.org/6z2aazzwp/choices-demo.gif)\n\n## Installation\n```\nnpm install nb-choices\nyarn add nb-choices\n```\n\n## Style\n`@import '~nb-choices/nb-choices.scss'` \n\n\n ## Examples\n\n#### Single Select\n```html\n\u003cchoices [formControl]=\"control\"\n         [choices]=\"options\"\n         placeholder=\"Choose...\"\u003e\u003c/choices\u003e\n\n```\n\n\n#### Single Select - Combo box\n```html\n \u003cchoices [formControl]=\"control\"\n          [isCombo]=\"true\"\n          [choices]=\"options\"\n          placeholder=\"Choose...\"\u003e\u003c/choices\u003e\n```\n\n              \n#### Single Select - Group\n```ts\nthis.options = [{\n  label: 'Group one',\n  id: 1,\n  choices: [\n    { value: 'Child One', label: 'Child One' },\n    { value: 'Child Two', label: 'Child Two' },\n  ]\n },\n {\n   label: 'Group two',\n   id: 2,\n   choices: [\n     { value: 'Child Four', label: 'Child Three' },\n     { value: 'Child Five', label: 'Child Four' },\n   ]\n}];\n```\n```html\n\u003cchoices [formControl]=\"control\"\n         [choices]=\"options\"\n         placeholder=\"Choose...\"\u003e\u003c/choices\u003e\n```\n\n\n#### With Custom Template\n```ts\nthis.options = [{\n      value: 'chrome',\n      label: 'Chrome',\n      customProperties: {\n        icon: 'chrome'\n      }\n    },\n    {\n      value: 'explorer',\n      label: 'Explorer',\n      customProperties: {\n        icon: 'internet-explorer'\n    }\n }];\n\n```\n```html\n\u003cng-template #tpl let-data\u003e\n \u003ci class=\"fa fa-{{data.customProperties?.icon}}\"\u003e\u003c/i\u003e {{data.label}}\n\u003c/ng-template\u003e\n\n\u003cchoices [formControl]=\"control\"\n         [isCombo]=\"true\"\n         [choiceTemplate]=\"tpl\"\n         [choices]=\"options\"\n         placeholder=\"Choose...\"\u003e\u003c/choices\u003e\n```\n\n             \n#### With Observables\n```ts\nngOnInit() {\n  this.loading = true;\n  this.options$ = timer(500).mapTo(this.options).do(() =\u003e {\n    this.loading = false\n  });\n}\n```\n```html\n\u003cchoices [formControl]=\"control\"\n         [isCombo]=\"true\"\n         [loading]=\"loading\"\n         [choices]=\"options$ | async\"\n         placeholder=\"Choose...\"\u003e\u003c/choices\u003e\n```\n      \n   \n\n#### Multiple Select\n```html\n\u003cchoices [isMultiple]=\"true\"\n         [choices]=\"options\"\n         [isCombo]=\"true\"\n         [formControl]=\"control\"\n         placeholder=\"Choose skills...\"\u003e\u003c/choices\u003e\n```\n#### Multiple Select - With Checkbox\n```html\n\u003cchoices [isMultiple]=\"true\"\n         [choices]=\"options\"\n         [withCheckbox]=\"true\"\n         [isCombo]=\"true\"\n         [formControl]=\"control\"\n         placeholder=\"Choose skills...\"\u003e\u003c/choices\u003e\n```\n#### Controls\n```html\n\u003cchoices [formControl]=\"control\"\n         [isCombo]=\"true\"\n         #choices=\"choices\"\n         [choices]=\"options\"\n         placeholder=\"Choose...\"\u003e\u003c/choices\u003e\n\n\u003cbutton (click)=\"choices.toggleDropdown(true)\"\u003eShow\u003c/button\u003e\n\u003cbutton (click)=\"choices.toggleDropdown()\"\u003eHide\u003c/button\u003e\n\u003cbutton (click)=\"choices.disable()\"\u003eDisable\u003c/button\u003e\n\u003cbutton (click)=\"choices.enable()\"\u003eEnable\u003c/button\u003e\n\u003cbutton (click)=\"choices.clear()\"\u003eReset\u003c/button\u003e\n\u003cbutton (click)=\"choicesMultiple.clearMultiple()\"\u003eReset multiple select\u003c/button\u003e\n```\n#### Text\n\n```html\n\u003cchoices [text]=\"true\" [items]=\"textOptions\" [formControl]=\"controText\" #choicesText=\"choices\"\u003e\u003c/choices\u003e\n\n\u003cbutton (click)=\"choicesText.clearMultiple()\"\u003eReset\u003c/button\u003e\n```\n\n#### Configuration\nThe default configurations of `nb-choices` for selects are:\n```ts\n{\n  placeholderValue: context.placeholder,\n  searchEnabled: context.isCombo,\n  searchPlaceholderValue: context.searchPlaceholder,\n  silent: true,\n  removeItems: true,\n  removeItemButton: true,\n  duplicateItems: false,\n  resetScrollPosition: false,\n  searchResultLimit: 10000,\n  fuseOptions: {\n    threshold: 0.2,\n  },\n  shouldSort: false,\n  shouldSortItems: false,\n  renderSelectedChoices: 'always',\n  loadingText: 'Loading...',\n  noResultsText: 'No results found',\n  noChoicesText: 'No choices to choose from',\n  itemSelectText: '',\n}\n```\nThe default configurations of `nb-choices` for texts are:\n\n```ts\n{\n  duplicateItems: false,\n  removeItemButton: true,\n}\n```\n\nYou can extend the configurations by providing the `CHOICES_CONFIG` provider for **selects** or the `CHOICES_TEXT_CONFIG` for **texts**. \n\nFor example:\n```ts\nproviders: [{provide: CHOICES_CONFIG, useValue: { removeItems: false }}]\n```\n     \n\n#### Options\n| @Inputs()         | Description                                     | Default     |\n|-------------------|-------------------------------------------------|-------------|\n| isMultiple        | Whether the select should be multiple           | `false`     |\n| placeholder       | The value to show when the control is empty     | `Choose..`  |\n| isCombo           | Whether to show the search box                  | `true`      |\n| text              | Whether is a text type                          | `false`     |\n| searchPlaceholder | The value to show on the search input           | `Search..`  |\n| labelKey          | The label which bound to the option text        | `label`     |\n| valueKey          | The value which bound to the option value       | `value`     |\n| choices           | The list of choices                             | `[]`        |\n| items             | The list of items (relevant for text)           | `[]`        |\n| choiceTemplate    | TemplateRef that will replace the default view  | `null`      |\n| loadingText       | The loading text                                | `Loading..` |\n| textConfig        | The text config                                 | `{}`        |\n| withCheckbox      | Whether to show a checkbox in multiple dropdown | `false`     |\n| loading           | Whether to show the loading text                | `false`     |\n\n\n| @Outputs() | Description                                                 |\n|------------|-------------------------------------------------------------|\n| onSearch   | Triggered when a user types into an input to search choices |\n\n\n#### Custom Styling\nYou can customize the style by modifying the `nb-choices.scss` and include it in your application. \n\n#### TODO\n- Add Tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetanelbasal%2Fnb-choices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetanelbasal%2Fnb-choices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetanelbasal%2Fnb-choices/lists"}