{"id":15991188,"url":"https://github.com/bradmartin/cache-autocomplete","last_synced_at":"2025-09-05T05:31:30.694Z","repository":{"id":57192396,"uuid":"79667328","full_name":"bradmartin/cache-autocomplete","owner":"bradmartin","description":"Simple auto complete for the web with caching.","archived":false,"fork":false,"pushed_at":"2018-01-07T18:14:58.000Z","size":672,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-28T18:55:16.504Z","etag":null,"topics":["bradmartin","cache-autocomplete","no-dependencies","typescript","ui-components","web"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bradmartin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-21T19:21:04.000Z","updated_at":"2020-04-24T19:09:42.000Z","dependencies_parsed_at":"2022-08-24T05:21:13.132Z","dependency_job_id":null,"html_url":"https://github.com/bradmartin/cache-autocomplete","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradmartin%2Fcache-autocomplete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradmartin%2Fcache-autocomplete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradmartin%2Fcache-autocomplete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradmartin%2Fcache-autocomplete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bradmartin","download_url":"https://codeload.github.com/bradmartin/cache-autocomplete/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232024708,"owners_count":18461968,"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":["bradmartin","cache-autocomplete","no-dependencies","typescript","ui-components","web"],"created_at":"2024-10-08T05:42:38.290Z","updated_at":"2024-12-31T19:58:12.173Z","avatar_url":"https://github.com/bradmartin.png","language":"TypeScript","funding_links":["https://www.paypal.me/bradwayne88"],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/cache-autocomplete.svg)](https://www.npmjs.com/package/cache-autocomplete)\n[![npm](https://img.shields.io/npm/dt/cache-autocomplete.svg?label=npm%20downloads)](https://www.npmjs.com/package/cache-autocomplete)\n[![GitHub stars](https://img.shields.io/github/stars/bradmartin/cache-autocomplete.svg)](https://github.com/bradmartin/cache-autocomplete/stargazers)\n[![PayPal Donate](https://img.shields.io/badge/Donate-PayPal-ff4081.svg)](https://www.paypal.me/bradwayne88)\n\n\n# Cache-AutoComplete\n#### Probably not what you're looking for, but it works for me :stuck_out_tongue: :poop:\n\n### File size = *7.09kb* - gzipped = *2.44kb*\n\n![CacheAutoComplete](screens/cacheAutoComplete.gif)\n\n### Explanation\nI needed a simple auto complete component for a web app that supported keyboard navigation.\nI wanted something light weight and flexible.\nAfter searching around, nothing fit my use case or desire. The component\ndefaults to Material Design-like styling. This is customizable by setting `itemClass` and `listClass` when creating the component. PRs welcome to improve functionality.\nJust want to keep this light weight :smile:\n\n\n### Installation\n`npm install cache-autocomplete`\n\n### Usage\n`cacheautocomplete` is exposed as a library thanks to Webpack so using a `\u003cscript\u003e` tag on your html will work. You can also import/require what you need using the module if you're using a module loader for your app.\n### JS\n```js\nvar CAC = new cacheautocomplete.AutoComplete({\n            element: document.getElementById(\"myAutoComplete\"), // required - the dom element to tie into\n            url: 'https://api.test.com/api/customer/typeahead?name={{ value }}\u0026apikey=84', // required and must use the `{{ value }}` to inject the rootElement's current value when typing\n            itemTemplate: '\u003cdiv\u003e \u003ch3\u003e{{ Name }}\u003c/h3\u003e \u003cimg src=\"{{ ProfilePic }} /\u003e \u003c/div\u003e', // required\n            keys: ['Name', 'ProfilePic']\n            onSelect: function (selectedItem, autoComplete) { // optional - callback when an item is selected via keyboard or mouse event\n                console.log(selectedItem);\n                rootInput.value = selectedItem.SomeProp;\n            }\n        });\n\n```\n\n### HTML\n```html\n\u003cinput id=\"myAutoComplete\" type=\"text\" /\u003e\n```\n\n### Public Methods\n- `clearCache(url?: string)` - If a url is specified only that url is removed from storage.\nIf no url is specified all CacheAutoComplete items are removed from storage.\n\n\n### CacheAutoCompleteOptions \n```ts\ninterface CACompleteOptions {\n    element: HTMLInputElement; /// The HTML Input element to use as the anchor.\n    url: string; /// The URL to ping for remote data.\n    itemTemplate: any; /// The response data Key property to display\n    keys: string[]; // The keys are used to create the correct template for the items. See example for correct usage.\n    onSelect: Function; /// callback function when a list item is selected via keyboard or mouse - this is optional but you likely need to use it and set the rootInput value to some prop in your list objects\n    minLength?: number; /// optional - default is 1\n    cache?: boolean; /// optional - default is true\n    listClass?: string; /// css class to style the list\n    itemClass?: string; /// css class to style items in the list.\n}\n```\n### Contributing\n- `git clone https://github.com/bradmartin/cache-autocomplete.git`\n- `npm install` - install deps\n- `npm run dev` - will transpile and kick off the webpack dev server\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradmartin%2Fcache-autocomplete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbradmartin%2Fcache-autocomplete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradmartin%2Fcache-autocomplete/lists"}