{"id":17466637,"url":"https://github.com/liammartens/sanity-plugin-autocomplete-input","last_synced_at":"2025-04-13T15:13:10.011Z","repository":{"id":42076012,"uuid":"438354935","full_name":"LiamMartens/sanity-plugin-autocomplete-input","owner":"LiamMartens","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-23T16:14:09.000Z","size":124,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T15:13:05.422Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiamMartens.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-12-14T18:13:50.000Z","updated_at":"2022-08-11T08:30:02.000Z","dependencies_parsed_at":"2023-11-23T17:25:36.187Z","dependency_job_id":null,"html_url":"https://github.com/LiamMartens/sanity-plugin-autocomplete-input","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"67bc967c00304653e5e9479c849026fb31470a29"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiamMartens%2Fsanity-plugin-autocomplete-input","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiamMartens%2Fsanity-plugin-autocomplete-input/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiamMartens%2Fsanity-plugin-autocomplete-input/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiamMartens%2Fsanity-plugin-autocomplete-input/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiamMartens","download_url":"https://codeload.github.com/LiamMartens/sanity-plugin-autocomplete-input/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248732486,"owners_count":21152852,"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":[],"created_at":"2024-10-18T13:57:22.208Z","updated_at":"2025-04-13T15:13:09.978Z","avatar_url":"https://github.com/LiamMartens.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sanity-plugin-autocomplete-input\n*Note: the main branch is now a V3 plugin. For V2 checkout v1.x*\n\n[![https://img.shields.io/npm/v/sanity-plugin-autocomplete-input](https://img.shields.io/npm/v/sanity-plugin-autocomplete-input)](https://www.npmjs.com/package/sanity-plugin-autocomplete-input)\n\n![example](https://raw.githubusercontent.com/LiamMartens/sanity-plugin-autocomplete-input/main/docs/img/example.gif)\n\nThis plugin is similar to the [Autocomplete Tags Plugin](https://www.sanity.io/plugins/autocomplete-tags), but it acts as a single text input as opposed to an array of tags. The input can also be customized to change the autocomplete options.\n\n## Installation\n\n```\nnpm install --save sanity-plugin-autocomplete-input\n```\n\nor\n\n```\nyarn add sanity-plugin-autocomplete-input\n```\n\n## Usage\n\nAdd it as a plugin in sanity.config.ts (or .js):\n\n```js\nimport { autocompletInput } from \"sanity-plugin-autocomplete-input\";\n\nexport default defineConfig({\n  // ...\n  plugins: [autocompletInput()],\n});\n```\n\nYou can just use it as a schema type. To customize the autocomplete list you have 3 options:\n\n1. Specify the `autocompleteFieldPath` option, which the plugin will use to look for documents with the same field path to aggregate the option values.\n2. Manually specify options in the schema option\n3. Specify your own GROQ query returning a `[{ \"value\": \"foobar\" }]` format (you can use a `transform` function if this is not achievable using GROQ only)\n\n```javascript\nexport default {\n  fields: [\n    {\n      name: \"autocomplete-input\",\n      type: \"autocomplete\",\n      options: {\n        // specify field path\n        autocompleteFieldPath: \"title\",\n        // this option can be used to disable using \"new\" values\n        disableNew: false,\n        // manually specify options\n        options: [{ value: \"Option 1\" }, { value: \"Option 2\" }],\n        // specify custom groq query\n        groq: {\n          query: '*[_type == $type] { \"value\": title }',\n          params: {\n            type: \"page\",\n          },\n          transform: (values) =\u003e values,\n        },\n      },\n    },\n  ],\n};\n```\n\n### Advanced GROQ parameters\n\nIt is also possible to refer to the current parent value (for a top-level field this would be the current document) by passing a function to the `params` option:\n\n```javascript\nexport default {\n  fields: [\n    {\n      name: \"autocomplete-input\",\n      type: \"autocomplete\",\n      options: {\n        groq: {\n          query: \"*[_id != $docId]\",\n          params: (parent) =\u003e ({\n            docId: parent?._id,\n          }),\n        },\n      },\n    },\n  ],\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliammartens%2Fsanity-plugin-autocomplete-input","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliammartens%2Fsanity-plugin-autocomplete-input","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliammartens%2Fsanity-plugin-autocomplete-input/lists"}