{"id":13599680,"url":"https://github.com/ejmudi/react-autocomplete-hint","last_synced_at":"2025-04-10T17:31:51.295Z","repository":{"id":40558376,"uuid":"282451784","full_name":"ejmudi/react-autocomplete-hint","owner":"ejmudi","description":"A React component for Autocomplete Hint.","archived":false,"fork":false,"pushed_at":"2023-03-02T21:35:48.000Z","size":1596,"stargazers_count":164,"open_issues_count":9,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T23:46:31.635Z","etag":null,"topics":["autocomplete","lookahead","react","typeahead"],"latest_commit_sha":null,"homepage":"https://ejmudi.github.io/react-autocomplete-hint/","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/ejmudi.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}},"created_at":"2020-07-25T13:42:22.000Z","updated_at":"2024-05-02T11:58:57.000Z","dependencies_parsed_at":"2024-01-13T17:12:01.142Z","dependency_job_id":"b427cfa9-2bb6-4efd-b1fd-3243660be8fe","html_url":"https://github.com/ejmudi/react-autocomplete-hint","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejmudi%2Freact-autocomplete-hint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejmudi%2Freact-autocomplete-hint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejmudi%2Freact-autocomplete-hint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejmudi%2Freact-autocomplete-hint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ejmudi","download_url":"https://codeload.github.com/ejmudi/react-autocomplete-hint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261994,"owners_count":21074229,"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":["autocomplete","lookahead","react","typeahead"],"created_at":"2024-08-01T17:01:08.992Z","updated_at":"2025-04-10T17:31:50.780Z","avatar_url":"https://github.com/ejmudi.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# react-autocomplete-hint\nA React component for Autocomplete Hint.\n\n![NPM](https://img.shields.io/npm/l/react-autocomplete-hint)\n![npm](https://img.shields.io/npm/v/react-autocomplete-hint)\n[![Build Status](https://travis-ci.com/ejmudi/react-autocomplete-hint.svg?branch=master)](https://travis-ci.com/ejmudi/react-autocomplete-hint)\n[![codecov](https://codecov.io/gh/ejmudi/react-autocomplete-hint/graph/badge.svg)](https://codecov.io/gh/ejmudi/react-autocomplete-hint)\n\n![](demo/demo.gif)\n\n\n## Demo\n\nDemo can be found here: [https://ejmudi.github.io/react-autocomplete-hint/](https://ejmudi.github.io/react-autocomplete-hint/)\n\n\n## Installation\n```\nnpm install --save react-autocomplete-hint\n```\nor\n```\nyarn add react-autocomplete-hint\n```\n\n\n## Usage\n```jsx\nimport { Hint } from 'react-autocomplete-hint';\n\nconst options = [\"orange\", \"banana\", \"apple\"];\n\n// OR\n\nconst options = [\n    {id: 1, label: \"orange\"}, \n    {id: '2', label: \"banana\"}, \n    {id: 3, label: \"apple\"}\n];\n\n\u003cHint options={options}\u003e\n    \u003cinput\n        value={text}\n        onChange={e =\u003e setText(e.target.value)} /\u003e\n\u003c/Hint\u003e\n\n```\n\nClick on the hint or use your keyboard **Right** key, **Tab** key (if `allowTabFill` is set to true), or **Enter** key (if `allowEnterFill` is set to true) to fill your input with the suggested hint.\n\n\n## Props\n\n#### options (required): `Array\u003cstring\u003e | Array\u003cobject\u003e`\n\n#### disableHint (optional): `Boolean`\n\n#### allowTabFill (optional): `Boolean`\n\n#### allowEnterFill (optional): `Boolean`\n\n#### onFill (optional): `(value: string | object)=\u003e void`\n\n#### onHint (optional): `(value: string | object | undefined)=\u003e void`\n\n#### valueModifier (optional): `(value: string)=\u003e string`\n\n\n## object option\nIf you're using objects for your options. object schema is as follows:\n\n#### id: `string | number`\n#### label: `string`\n\n\n## onFill\nReturns the option selected immediately the input is filled with the suggested hint. \n\nNote that it won't return the selected option with the casing the user typed, rather it returns the option with the casing specified in your options prop. For example, if the options are specified like this:...\n\n```jsx\nconst options = [\"orange\", \"banana\", \"apple\"];\n```\n...and the input gets filled with *\"ORange\"*, onFill will still return *\"orange\"*.\n\n\n## onHint\nReturns the current hint.\n\n\n## valueModifier\nThis prop accepts a function that modifies your input value before it is saved in state.\n\nIt is typically useful when you are not setting `e.target.value` directly in state and need to modify the target value to \nsome other value first before setting it in state.\n\nExample: A case where you need to set the input value to uppercase irrespective of the casing the user types in:\n\n```jsx\nconst options = [\"orange\", \"banana\", \"apple\"];\n\nconst modifyValue = (value: string) =\u003e value.toUpperCase();\n\n\u003cHint options={options} valueModifier={modifyValue}\u003e\n    \u003cinput\n        value={text}\n        onChange={e =\u003e setText(modifyValue(e.target.value))} /\u003e\n\u003c/Hint\u003e\n```\nNote: Not setting the `valueModifier` prop in cases like this might result to a malformed hint.\n\n\n## Duplicate data\nIf you are using objects for your options, You may have unexpected results if your data options contain objects with duplicate labels. For this reason, it is highly recommended that you pass in objects with unique labels if possible.\n\nFor example, if you pass in `optionsWithDuplicateLabels` as seen below and you then fill the input with the *orange* hint, the orange will be the first orange object found in the array as can be seen in the `onFill` prop:\n\n```jsx\nconst optionsWithDuplicateLabels = [\n    {id: \"1\", label: \"orange\"},\n    {id: \"2\", label: \"orange\"},\n    {id: \"3\", label: \"banana\"}\n];\n\n\u003cHint options={optionsWithDuplicateLabels} onFill={value=\u003e {\n    // will always log {id: \"1\", label: \"orange\"} when orange is selected\n    // {id: \"2\", label: \"orange\"} will never be logged.\n    console.log(value);\n}}\u003e\n    \u003cinput\n        value={text}\n        onChange={e =\u003e setText(e.target.value)} /\u003e\n\u003c/Hint\u003e\n\n```\n\n\n## License\n[MIT](LICENSE)\n\nInspired by [React Bootstrap Typeahead](https://github.com/ericgio/react-bootstrap-typeahead).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejmudi%2Freact-autocomplete-hint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fejmudi%2Freact-autocomplete-hint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejmudi%2Freact-autocomplete-hint/lists"}