@srothgan/sanity-plugin-autocomplete-input 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @srothgan/sanity-plugin-autocomplete-input
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@srothgan/sanity-plugin-autocomplete-input)](https://www.npmjs.com/package/@srothgan/sanity-plugin-autocomplete-input)
4
+ [![npm downloads](https://img.shields.io/npm/dt/@srothgan/sanity-plugin-autocomplete-input)](https://www.npmjs.com/package/@srothgan/sanity-plugin-autocomplete-input)
5
+ [![license](https://img.shields.io/npm/l/@srothgan/sanity-plugin-autocomplete-input)](./LICENSE)
4
6
  [![Original Repository](https://img.shields.io/badge/original-LiamMartens%2Fsanity--plugin--autocomplete--input-blue)](https://github.com/LiamMartens/sanity-plugin-autocomplete-input)
5
7
 
6
8
  ![example](https://raw.githubusercontent.com/LiamMartens/sanity-plugin-autocomplete-input/main/docs/img/example.gif)
@@ -169,7 +171,8 @@ This maintained fork includes the following enhancements:
169
171
  - **Sanity v4 & v5 Support**: Fully compatible with both Sanity Studio v4 and v5
170
172
  - **React 18 & 19 Support**: Works with React 18 (Sanity v4) and React 19 (Sanity v5)
171
173
  - **Modern Build Tooling**: Migrated from Babel to SWC for faster builds
172
- - **TypeScript 5.3**: Updated to latest TypeScript with improved type safety
174
+ - **TypeScript 5.9**: Updated to latest TypeScript with improved type safety
175
+ - **Rust-based Tooling**: Using Oxfmt for formatting and Oxlint for linting (alongside ESLint)
173
176
 
174
177
  ### Maintained & Active
175
178
 
package/dist/index.cjs CHANGED
@@ -46,7 +46,11 @@ const AutoCompleteInput = (props) => {
46
46
  setLoading(!0), sanityClient.fetch(groqQuery, resolvedParams).then((results) => {
47
47
  if (Array.isArray(results)) {
48
48
  const transformedResults = transform ? transform(results) : results, compactedValues = compact__default.default(transformedResults.map((doc) => get__default.default(doc, "value")));
49
- setOptions(compactedValues.map((optionValue) => ({ value: String(optionValue) }))), setLoading(!1);
49
+ setOptions(
50
+ compactedValues.map((optionValue) => ({
51
+ value: String(optionValue)
52
+ }))
53
+ ), setLoading(!1);
50
54
  }
51
55
  });
52
56
  }, [schemaType.options, documentValue, sanityClient]), /* @__PURE__ */ jsxRuntime.jsx(
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/AutoCompleteInput.tsx","../src/schemas/autocompleteString.ts","../src/index.ts"],"sourcesContent":["import {Autocomplete, Card, Text} from '@sanity/ui'\nimport compact from 'just-compact'\nimport get from 'just-safe-get'\nimport unique from 'just-unique'\nimport React, {useCallback, useEffect, useMemo, useState} from 'react'\nimport {\n PatchEvent,\n set,\n StringInputProps,\n StringSchemaType,\n unset,\n useClient,\n useFormValue,\n} from 'sanity'\n\nimport type {InputOptions, Option} from './types/index.js'\n\nexport type AutocompleteSchemaType = Omit<StringSchemaType, 'options'> & {\n options?: StringSchemaType['options'] & InputOptions\n}\nexport type InputProps = StringInputProps<AutocompleteSchemaType>\n\nexport const AutoCompleteInput = (props: InputProps): React.ReactElement => {\n const {id, schemaType, value, validationError, readOnly, onChange} = props\n\n const sanityClient = useClient()\n const documentValue = useFormValue([])\n const [loading, setLoading] = useState(false)\n const [query, setQuery] = React.useState('')\n const [options, setOptions] = React.useState<Option[]>([])\n const canCreateNew = schemaType.options?.disableNew !== true\n\n const optionsList = useMemo<(Option & {isNew?: boolean})[]>(() => {\n const uniqueOptions = unique(\n options.map(({value: optionValue}) => optionValue),\n false,\n true,\n )\n const queryInOptions = uniqueOptions.find((optionValue) => optionValue === query)\n if (!queryInOptions && canCreateNew) {\n return [\n ...uniqueOptions.map((optionValue) => ({value: optionValue})),\n {value: query, isNew: true},\n ]\n }\n\n return uniqueOptions.map((optionValue) => ({value: optionValue}))\n }, [query, options, canCreateNew])\n\n const handleQueryChange = useCallback((queryValue: string | null) => {\n setQuery(queryValue ?? '')\n }, [])\n\n const handleChange = useCallback(\n (newValue: string) => {\n onChange(PatchEvent.from(newValue ? set(newValue) : unset()))\n },\n [onChange],\n )\n\n const renderOption = useCallback(\n (option: Option & {isNew?: boolean}) => (\n <Card as=\"button\" padding={3} tone={option.isNew ? 'primary' : 'default'} shadow={1}>\n {option.isNew ? (\n canCreateNew && <Text>Create new option &quot;{option.value}&quot;</Text>\n ) : (\n <Text>{option.value}</Text>\n )}\n </Card>\n ),\n [canCreateNew],\n )\n\n useEffect(() => {\n if (schemaType.options?.options) {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setOptions(schemaType.options.options)\n setLoading(false)\n return\n }\n\n const path = schemaType.options?.autocompleteFieldPath ?? 'title'\n const {\n query: groqQuery,\n transform,\n params = {},\n } = schemaType.options?.groq || {\n query: `*[defined(${path})] { \"value\": ${path} }`,\n }\n\n const resolvedParams =\n typeof params === 'function'\n ? params(documentValue as Record<string, unknown> | undefined)\n : params\n\n setLoading(true)\n sanityClient.fetch(groqQuery, resolvedParams).then((results) => {\n if (Array.isArray(results)) {\n const transformedResults = transform ? transform(results) : results\n const compactedValues = compact(transformedResults.map((doc) => get(doc, 'value')))\n setOptions(compactedValues.map((optionValue) => ({value: String(optionValue)})))\n setLoading(false)\n }\n })\n }, [schemaType.options, documentValue, sanityClient])\n\n return (\n <Autocomplete\n id={id}\n readOnly={readOnly ?? false}\n customValidity={validationError}\n loading={loading}\n disabled={loading}\n options={optionsList}\n value={value ?? ''}\n onChange={handleChange}\n onQueryChange={handleQueryChange}\n renderOption={renderOption}\n />\n )\n}\n","import {defineType, StringDefinition} from 'sanity'\n\nimport {AutoCompleteInput} from '../AutoCompleteInput.js'\nimport type {InputOptions} from '../types/index.js'\n\nconst typeName = 'autocomplete' as const\n\n/**\n * @public\n */\nexport interface AutocompleteStringDefinition extends Omit<\n StringDefinition,\n 'type' | 'fields' | 'options'\n> {\n type: typeof typeName\n options?: InputOptions\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n autocomplete: AutocompleteStringDefinition\n }\n}\n\nexport const autocompleteString = defineType({\n name: typeName,\n type: 'string',\n title: 'Autocomplete',\n components: {input: AutoCompleteInput},\n})\n","import {definePlugin} from 'sanity'\n\nimport {autocompleteString} from './schemas/autocompleteString.js'\n\nexport const autocompletInput = definePlugin({\n name: 'sanity-plugin-autocomplete-input',\n schema: {\n types: [autocompleteString],\n },\n})\n"],"names":["useClient","useFormValue","useState","React","useMemo","unique","useCallback","PatchEvent","set","unset","jsx","Card","Text","useEffect","compact","get","Autocomplete","defineType","definePlugin"],"mappings":";;;;;;;AAsBO,MAAM,oBAAoB,CAAC,UAA0C;AAC1E,QAAM,EAAC,IAAI,YAAY,OAAO,iBAAiB,UAAU,aAAY,OAE/D,eAAeA,OAAAA,UAAA,GACf,gBAAgBC,OAAAA,aAAa,EAAE,GAC/B,CAAC,SAAS,UAAU,IAAIC,MAAAA,SAAS,EAAK,GACtC,CAAC,OAAO,QAAQ,IAAIC,eAAAA,QAAM,SAAS,EAAE,GACrC,CAAC,SAAS,UAAU,IAAIA,eAAAA,QAAM,SAAmB,EAAE,GACnD,eAAe,WAAW,SAAS,eAAe,IAElD,cAAcC,MAAAA,QAAwC,MAAM;AAChE,UAAM,gBAAgBC,gBAAAA;AAAAA,MACpB,QAAQ,IAAI,CAAC,EAAC,OAAO,YAAA,MAAiB,WAAW;AAAA,MACjD;AAAA,MACA;AAAA,IAAA;AAGF,WAAI,CADmB,cAAc,KAAK,CAAC,gBAAgB,gBAAgB,KAAK,KACzD,eACd;AAAA,MACL,GAAG,cAAc,IAAI,CAAC,iBAAiB,EAAC,OAAO,cAAa;AAAA,MAC5D,EAAC,OAAO,OAAO,OAAO,GAAA;AAAA,IAAI,IAIvB,cAAc,IAAI,CAAC,iBAAiB,EAAC,OAAO,cAAa;AAAA,EAClE,GAAG,CAAC,OAAO,SAAS,YAAY,CAAC,GAE3B,oBAAoBC,kBAAY,CAAC,eAA8B;AACnE,aAA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AiB,EAAC,OAAO,OAAO,WAAW,EAAA,EAAG,CAAC,GAC/E,WAAW,EAAK;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,SAAS,eAAe,YAAY,CAAC,GAGlDL,2BAAAA;AAAAA,IAACM,GAAAA;AAAAA,IAAA;AAAA,MACC;AAAA,MACA,UAAU,YAAY;AAAA,MACtB,gBAAgB;AAAA,MAChB;AAAA,MACA,UAAU;AAAA,MACV,SAAS;AAAA,MACT,OAAO,SAAS;AAAA,MAChB,UAAU;AAAA,MACV,eAAe;AAAA,MACf;AAAA,IAAA;AAAA,EAAA;AAGN,GCnHM,WAAW,gBAoBJ,qBAAqBC,OAAAA,WAAW;AAAA,EAC3C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY,EAAC,OAAO,kBAAA;AACtB,CAAC,GC1BY,mBAAmBC,OAAAA,aAAa;AAAA,EAC3C,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,OAAO,CAAC,kBAAkB;AAAA,EAAA;AAE9B,CAAC;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/AutoCompleteInput.tsx","../src/schemas/autocompleteString.ts","../src/index.ts"],"sourcesContent":["import {Autocomplete, Card, Text} from '@sanity/ui'\nimport compact from 'just-compact'\nimport get from 'just-safe-get'\nimport unique from 'just-unique'\nimport React, {useCallback, useEffect, useMemo, useState} from 'react'\nimport {\n PatchEvent,\n set,\n StringInputProps,\n StringSchemaType,\n unset,\n useClient,\n useFormValue,\n} from 'sanity'\n\nimport type {InputOptions, Option} from './types/index.js'\n\nexport type AutocompleteSchemaType = Omit<StringSchemaType, 'options'> & {\n options?: StringSchemaType['options'] & InputOptions\n}\nexport type InputProps = StringInputProps<AutocompleteSchemaType>\n\nexport const AutoCompleteInput = (props: InputProps): React.ReactElement => {\n const {id, schemaType, value, validationError, readOnly, onChange} = props\n\n const sanityClient = useClient()\n const documentValue = useFormValue([])\n const [loading, setLoading] = useState(false)\n const [query, setQuery] = React.useState('')\n const [options, setOptions] = React.useState<Option[]>([])\n const canCreateNew = schemaType.options?.disableNew !== true\n\n const optionsList = useMemo<(Option & {isNew?: boolean})[]>(() => {\n const uniqueOptions = unique(\n options.map(({value: optionValue}) => optionValue),\n false,\n true,\n )\n const queryInOptions = uniqueOptions.find((optionValue) => optionValue === query)\n if (!queryInOptions && canCreateNew) {\n return [\n ...uniqueOptions.map((optionValue) => ({value: optionValue})),\n {value: query, isNew: true},\n ]\n }\n\n return uniqueOptions.map((optionValue) => ({value: optionValue}))\n }, [query, options, canCreateNew])\n\n const handleQueryChange = useCallback((queryValue: string | null) => {\n setQuery(queryValue ?? '')\n }, [])\n\n const handleChange = useCallback(\n (newValue: string) => {\n onChange(PatchEvent.from(newValue ? set(newValue) : unset()))\n },\n [onChange],\n )\n\n const renderOption = useCallback(\n (option: Option & {isNew?: boolean}) => (\n <Card as=\"button\" padding={3} tone={option.isNew ? 'primary' : 'default'} shadow={1}>\n {option.isNew ? (\n canCreateNew && <Text>Create new option &quot;{option.value}&quot;</Text>\n ) : (\n <Text>{option.value}</Text>\n )}\n </Card>\n ),\n [canCreateNew],\n )\n\n useEffect(() => {\n if (schemaType.options?.options) {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setOptions(schemaType.options.options)\n setLoading(false)\n return\n }\n\n const path = schemaType.options?.autocompleteFieldPath ?? 'title'\n const {\n query: groqQuery,\n transform,\n params = {},\n } = schemaType.options?.groq || {\n query: `*[defined(${path})] { \"value\": ${path} }`,\n }\n\n const resolvedParams =\n typeof params === 'function'\n ? params(documentValue as Record<string, unknown> | undefined)\n : params\n\n setLoading(true)\n sanityClient.fetch(groqQuery, resolvedParams).then((results) => {\n if (Array.isArray(results)) {\n const transformedResults = transform ? transform(results) : results\n const compactedValues = compact(transformedResults.map((doc) => get(doc, 'value')))\n setOptions(\n compactedValues.map((optionValue) => ({\n value: String(optionValue),\n })),\n )\n setLoading(false)\n }\n })\n }, [schemaType.options, documentValue, sanityClient])\n\n return (\n <Autocomplete\n id={id}\n readOnly={readOnly ?? false}\n customValidity={validationError}\n loading={loading}\n disabled={loading}\n options={optionsList}\n value={value ?? ''}\n onChange={handleChange}\n onQueryChange={handleQueryChange}\n renderOption={renderOption}\n />\n )\n}\n","import {defineType, StringDefinition} from 'sanity'\n\nimport {AutoCompleteInput} from '../AutoCompleteInput.js'\nimport type {InputOptions} from '../types/index.js'\n\nconst typeName = 'autocomplete' as const\n\n/**\n * @public\n */\nexport interface AutocompleteStringDefinition extends Omit<\n StringDefinition,\n 'type' | 'fields' | 'options'\n> {\n type: typeof typeName\n options?: InputOptions\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n autocomplete: AutocompleteStringDefinition\n }\n}\n\nexport const autocompleteString = defineType({\n name: typeName,\n type: 'string',\n title: 'Autocomplete',\n components: {input: AutoCompleteInput},\n})\n","import {definePlugin} from 'sanity'\n\nimport {autocompleteString} from './schemas/autocompleteString.js'\n\nexport const autocompletInput = definePlugin({\n name: 'sanity-plugin-autocomplete-input',\n schema: {\n types: [autocompleteString],\n },\n})\n"],"names":["useClient","useFormValue","useState","React","useMemo","unique","useCallback","PatchEvent","set","unset","jsx","Card","Text","useEffect","compact","get","Autocomplete","defineType","definePlugin"],"mappings":";;;;;;;AAsBO,MAAM,oBAAoB,CAAC,UAA0C;AAC1E,QAAM,EAAC,IAAI,YAAY,OAAO,iBAAiB,UAAU,aAAY,OAE/D,eAAeA,OAAAA,UAAA,GACf,gBAAgBC,OAAAA,aAAa,EAAE,GAC/B,CAAC,SAAS,UAAU,IAAIC,MAAAA,SAAS,EAAK,GACtC,CAAC,OAAO,QAAQ,IAAIC,eAAAA,QAAM,SAAS,EAAE,GACrC,CAAC,SAAS,UAAU,IAAIA,eAAAA,QAAM,SAAmB,EAAE,GACnD,eAAe,WAAW,SAAS,eAAe,IAElD,cAAcC,MAAAA,QAAwC,MAAM;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{ Plugin as Plugin_2 } from "sanity";
2
2
 
3
- export declare const autocompletInput: Plugin_2<void>
3
+ export declare const autocompletInput: Plugin_2<void>;
4
4
 
5
- export {}
5
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import {Plugin as Plugin_2} from 'sanity'
1
+ import { Plugin as Plugin_2 } from "sanity";
2
2
 
3
- export declare const autocompletInput: Plugin_2<void>
3
+ export declare const autocompletInput: Plugin_2<void>;
4
4
 
5
- export {}
5
+ export {};
package/dist/index.js CHANGED
@@ -46,7 +46,11 @@ const AutoCompleteInput = (props) => {
46
46
  setLoading(!0), sanityClient.fetch(groqQuery, resolvedParams).then((results) => {
47
47
  if (Array.isArray(results)) {
48
48
  const transformedResults = transform ? transform(results) : results, compactedValues = compact(transformedResults.map((doc) => get(doc, "value")));
49
- setOptions(compactedValues.map((optionValue) => ({ value: String(optionValue) }))), setLoading(!1);
49
+ setOptions(
50
+ compactedValues.map((optionValue) => ({
51
+ value: String(optionValue)
52
+ }))
53
+ ), setLoading(!1);
50
54
  }
51
55
  });
52
56
  }, [schemaType.options, documentValue, sanityClient]), /* @__PURE__ */ jsx(
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/AutoCompleteInput.tsx","../src/schemas/autocompleteString.ts","../src/index.ts"],"sourcesContent":["import {Autocomplete, Card, Text} from '@sanity/ui'\nimport compact from 'just-compact'\nimport get from 'just-safe-get'\nimport unique from 'just-unique'\nimport React, {useCallback, useEffect, useMemo, useState} from 'react'\nimport {\n PatchEvent,\n set,\n StringInputProps,\n StringSchemaType,\n unset,\n useClient,\n useFormValue,\n} from 'sanity'\n\nimport type {InputOptions, Option} from './types/index.js'\n\nexport type AutocompleteSchemaType = Omit<StringSchemaType, 'options'> & {\n options?: StringSchemaType['options'] & InputOptions\n}\nexport type InputProps = StringInputProps<AutocompleteSchemaType>\n\nexport const AutoCompleteInput = (props: InputProps): React.ReactElement => {\n const {id, schemaType, value, validationError, readOnly, onChange} = props\n\n const sanityClient = useClient()\n const documentValue = useFormValue([])\n const [loading, setLoading] = useState(false)\n const [query, setQuery] = React.useState('')\n const [options, setOptions] = React.useState<Option[]>([])\n const canCreateNew = schemaType.options?.disableNew !== true\n\n const optionsList = useMemo<(Option & {isNew?: boolean})[]>(() => {\n const uniqueOptions = unique(\n options.map(({value: optionValue}) => optionValue),\n false,\n true,\n )\n const queryInOptions = uniqueOptions.find((optionValue) => optionValue === query)\n if (!queryInOptions && canCreateNew) {\n return [\n ...uniqueOptions.map((optionValue) => ({value: optionValue})),\n {value: query, isNew: true},\n ]\n }\n\n return uniqueOptions.map((optionValue) => ({value: optionValue}))\n }, [query, options, canCreateNew])\n\n const handleQueryChange = useCallback((queryValue: string | null) => {\n setQuery(queryValue ?? '')\n }, [])\n\n const handleChange = useCallback(\n (newValue: string) => {\n onChange(PatchEvent.from(newValue ? set(newValue) : unset()))\n },\n [onChange],\n )\n\n const renderOption = useCallback(\n (option: Option & {isNew?: boolean}) => (\n <Card as=\"button\" padding={3} tone={option.isNew ? 'primary' : 'default'} shadow={1}>\n {option.isNew ? (\n canCreateNew && <Text>Create new option &quot;{option.value}&quot;</Text>\n ) : (\n <Text>{option.value}</Text>\n )}\n </Card>\n ),\n [canCreateNew],\n )\n\n useEffect(() => {\n if (schemaType.options?.options) {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setOptions(schemaType.options.options)\n setLoading(false)\n return\n }\n\n const path = schemaType.options?.autocompleteFieldPath ?? 'title'\n const {\n query: groqQuery,\n transform,\n params = {},\n } = schemaType.options?.groq || {\n query: `*[defined(${path})] { \"value\": ${path} }`,\n }\n\n const resolvedParams =\n typeof params === 'function'\n ? params(documentValue as Record<string, unknown> | undefined)\n : params\n\n setLoading(true)\n sanityClient.fetch(groqQuery, resolvedParams).then((results) => {\n if (Array.isArray(results)) {\n const transformedResults = transform ? transform(results) : results\n const compactedValues = compact(transformedResults.map((doc) => get(doc, 'value')))\n setOptions(compactedValues.map((optionValue) => ({value: String(optionValue)})))\n setLoading(false)\n }\n })\n }, [schemaType.options, documentValue, sanityClient])\n\n return (\n <Autocomplete\n id={id}\n readOnly={readOnly ?? false}\n customValidity={validationError}\n loading={loading}\n disabled={loading}\n options={optionsList}\n value={value ?? ''}\n onChange={handleChange}\n onQueryChange={handleQueryChange}\n renderOption={renderOption}\n />\n )\n}\n","import {defineType, StringDefinition} from 'sanity'\n\nimport {AutoCompleteInput} from '../AutoCompleteInput.js'\nimport type {InputOptions} from '../types/index.js'\n\nconst typeName = 'autocomplete' as const\n\n/**\n * @public\n */\nexport interface AutocompleteStringDefinition extends Omit<\n StringDefinition,\n 'type' | 'fields' | 'options'\n> {\n type: typeof typeName\n options?: InputOptions\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n autocomplete: AutocompleteStringDefinition\n }\n}\n\nexport const autocompleteString = defineType({\n name: typeName,\n type: 'string',\n title: 'Autocomplete',\n components: {input: AutoCompleteInput},\n})\n","import {definePlugin} from 'sanity'\n\nimport {autocompleteString} from './schemas/autocompleteString.js'\n\nexport const autocompletInput = definePlugin({\n name: 'sanity-plugin-autocomplete-input',\n schema: {\n types: [autocompleteString],\n },\n})\n"],"names":[],"mappings":";;;;;;;AAsBO,MAAM,oBAAoB,CAAC,UAA0C;AAC1E,QAAM,EAAC,IAAI,YAAY,OAAO,iBAAiB,UAAU,aAAY,OAE/D,eAAe,UAAA,GACf,gBAAgB,aAAa,EAAE,GAC/B,CAAC,SAAS,UAAU,IAAI,SAAS,EAAK,GACtC,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,EAAE,GACrC,CAAC,SAAS,UAAU,IAAI,MAAM,SAAmB,EAAE,GACnD,eAAe,WAAW,SAAS,eAAe,IAElD,cAAc,QAAwC,MAAM;AAChE,UAAM,gBAAgB;AAAA,MACpB,QAAQ,IAAI,CAAC,EAAC,OAAO,YAAA,MAAiB,WAAW;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AAEN,eAAW,EAAI,GACf,aAAa,MAAM,WAAW,cAAc,EAAE,KAAK,CAAC,YAAY;AAC9D,UAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,cAAM,qBAAqB,YAAY,UAAU,OAAO,IAAI,SACtD,kBAAkB,QAAQ,mBAAmB,IAAI,CAAC,QAAQ,IAAI,KAAK,OAAO,CAAC,CAAC;AAClF,mBAAW,gBAAgB,IAAI,CAAC,iBAAiB,EAAC,OAAO,OAAO,WAAW,EAAA,EAAG,CAAC,GAC/E,WAAW,EAAK;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,SAAS,eAAe,YAAY,CAAC,GAGlD;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,UAAU,YAAY;AAAA,MACtB,gBAAgB;AAAA,MAChB;AAAA,MACA,UAAU;AAAA,MACV,SAAS;AAAA,MACT,OAAO,SAAS;AAAA,MAChB,UAAU;AAAA,MACV,eAAe;AAAA,MACf;AAAA,IAAA;AAAA,EAAA;AAGN,GCnHM,WAAW,gBAoBJ,qBAAqB,WAAW;AAAA,EAC3C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY,EAAC,OAAO,kBAAA;AACtB,CAAC,GC1BY,mBAAmB,aAAa;AAAA,EAC3C,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,OAAO,CAAC,kBAAkB;AAAA,EAAA;AAE9B,CAAC;"}
1
+ {"version":3,"file":"index.js","sources":["../src/AutoCompleteInput.tsx","../src/schemas/autocompleteString.ts","../src/index.ts"],"sourcesContent":["import {Autocomplete, Card, Text} from '@sanity/ui'\nimport compact from 'just-compact'\nimport get from 'just-safe-get'\nimport unique from 'just-unique'\nimport React, {useCallback, useEffect, useMemo, useState} from 'react'\nimport {\n PatchEvent,\n set,\n StringInputProps,\n StringSchemaType,\n unset,\n useClient,\n useFormValue,\n} from 'sanity'\n\nimport type {InputOptions, Option} from './types/index.js'\n\nexport type AutocompleteSchemaType = Omit<StringSchemaType, 'options'> & {\n options?: StringSchemaType['options'] & InputOptions\n}\nexport type InputProps = StringInputProps<AutocompleteSchemaType>\n\nexport const AutoCompleteInput = (props: InputProps): React.ReactElement => {\n const {id, schemaType, value, validationError, readOnly, onChange} = props\n\n const sanityClient = useClient()\n const documentValue = useFormValue([])\n const [loading, setLoading] = useState(false)\n const [query, setQuery] = React.useState('')\n const [options, setOptions] = React.useState<Option[]>([])\n const canCreateNew = schemaType.options?.disableNew !== true\n\n const optionsList = useMemo<(Option & {isNew?: boolean})[]>(() => {\n const uniqueOptions = unique(\n options.map(({value: optionValue}) => optionValue),\n false,\n true,\n )\n const queryInOptions = uniqueOptions.find((optionValue) => optionValue === query)\n if (!queryInOptions && canCreateNew) {\n return [\n ...uniqueOptions.map((optionValue) => ({value: optionValue})),\n {value: query, isNew: true},\n ]\n }\n\n return uniqueOptions.map((optionValue) => ({value: optionValue}))\n }, [query, options, canCreateNew])\n\n const handleQueryChange = useCallback((queryValue: string | null) => {\n setQuery(queryValue ?? '')\n }, [])\n\n const handleChange = useCallback(\n (newValue: string) => {\n onChange(PatchEvent.from(newValue ? set(newValue) : unset()))\n },\n [onChange],\n )\n\n const renderOption = useCallback(\n (option: Option & {isNew?: boolean}) => (\n <Card as=\"button\" padding={3} tone={option.isNew ? 'primary' : 'default'} shadow={1}>\n {option.isNew ? (\n canCreateNew && <Text>Create new option &quot;{option.value}&quot;</Text>\n ) : (\n <Text>{option.value}</Text>\n )}\n </Card>\n ),\n [canCreateNew],\n )\n\n useEffect(() => {\n if (schemaType.options?.options) {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setOptions(schemaType.options.options)\n setLoading(false)\n return\n }\n\n const path = schemaType.options?.autocompleteFieldPath ?? 'title'\n const {\n query: groqQuery,\n transform,\n params = {},\n } = schemaType.options?.groq || {\n query: `*[defined(${path})] { \"value\": ${path} }`,\n }\n\n const resolvedParams =\n typeof params === 'function'\n ? params(documentValue as Record<string, unknown> | undefined)\n : params\n\n setLoading(true)\n sanityClient.fetch(groqQuery, resolvedParams).then((results) => {\n if (Array.isArray(results)) {\n const transformedResults = transform ? transform(results) : results\n const compactedValues = compact(transformedResults.map((doc) => get(doc, 'value')))\n setOptions(\n compactedValues.map((optionValue) => ({\n value: String(optionValue),\n })),\n )\n setLoading(false)\n }\n })\n }, [schemaType.options, documentValue, sanityClient])\n\n return (\n <Autocomplete\n id={id}\n readOnly={readOnly ?? false}\n customValidity={validationError}\n loading={loading}\n disabled={loading}\n options={optionsList}\n value={value ?? ''}\n onChange={handleChange}\n onQueryChange={handleQueryChange}\n renderOption={renderOption}\n />\n )\n}\n","import {defineType, StringDefinition} from 'sanity'\n\nimport {AutoCompleteInput} from '../AutoCompleteInput.js'\nimport type {InputOptions} from '../types/index.js'\n\nconst typeName = 'autocomplete' as const\n\n/**\n * @public\n */\nexport interface AutocompleteStringDefinition extends Omit<\n StringDefinition,\n 'type' | 'fields' | 'options'\n> {\n type: typeof typeName\n options?: InputOptions\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'color' narrow correctly when using defineTyp/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n autocomplete: AutocompleteStringDefinition\n }\n}\n\nexport const autocompleteString = defineType({\n name: typeName,\n type: 'string',\n title: 'Autocomplete',\n components: {input: AutoCompleteInput},\n})\n","import {definePlugin} from 'sanity'\n\nimport {autocompleteString} from './schemas/autocompleteString.js'\n\nexport const autocompletInput = definePlugin({\n name: 'sanity-plugin-autocomplete-input',\n schema: {\n types: [autocompleteString],\n },\n})\n"],"names":[],"mappings":";;;;;;;AAsBO,MAAM,oBAAoB,CAAC,UAA0C;AAC1E,QAAM,EAAC,IAAI,YAAY,OAAO,iBAAiB,UAAU,aAAY,OAE/D,eAAe,UAAA,GACf,gBAAgB,aAAa,EAAE,GAC/B,CAAC,SAAS,UAAU,IAAI,SAAS,EAAK,GACtC,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,EAAE,GACrC,CAAC,SAA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ACP;AAAA,MACA,SAAS,CAAA;AAAA,IAAC,IACR,WAAW,SAAS,QAAQ;AAAA,MAC9B,OAAO,aAAa,IAAI,iBAAiB,IAAI;AAAA,IAAA,GAGzC,iBACJ,OAAO,UAAW,aACd,OAAO,aAAoD,IAC3D;AAEN,eAAW,EAAI,GACf,aAAa,MAAM,WAAW,cAAc,EAAE,KAAK,CAAC,YAAY;AAC9D,UAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,cAAM,qBAAqB,YAAY,UAAU,OAAO,IAAI,SACtD,kBAAkB,QAAQ,mBAAmB,IAAI,CAAC,QAAQ,IAAI,KAAK,OAAO,CAAC,CAAC;AAClF;AAAA,UACE,gBAAgB,IAAI,CAAC,iBAAiB;AAAA,YACpC,OAAO,OAAO,WAAW;AAAA,UAAA,EACzB;AAAA,QAAA,GAEJ,WAAW,EAAK;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,SAAS,eAAe,YAAY,CAAC,GAGlD;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,UAAU,YAAY;AAAA,MACtB,gBAAgB;AAAA,MAChB;AAAA,MACA,UAAU;AAAA,MACV,SAAS;AAAA,MACT,OAAO,SAAS;AAAA,MAChB,UAAU;AAAA,MACV,eAAe;AAAA,MACf;AAAA,IAAA;AAAA,EAAA;AAGN,GCvHM,WAAW,gBAoBJ,qBAAqB,WAAW;AAAA,EAC3C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY,EAAC,OAAO,kBAAA;AACtB,CAAC,GC1BY,mBAAmB,aAAa;AAAA,EAC3C,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,OAAO,CAAC,kBAAkB;AAAA,EAAA;AAE9B,CAAC;"}
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "@srothgan/sanity-plugin-autocomplete-input",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Autocomplete input plugin for Sanity",
5
5
  "keywords": [
6
- "sanity",
7
- "sanity-plugin",
8
6
  "autocomplete",
9
7
  "input",
10
- "v4",
11
- "v5",
12
8
  "maintained",
13
- "sanity-v5"
9
+ "sanity",
10
+ "sanity-plugin",
11
+ "sanity-v5",
12
+ "v4",
13
+ "v5"
14
14
  ],
15
+ "bugs": {
16
+ "url": "https://github.com/srothgan/srothgan-sanity-plugin-autocomplete-input/issues"
17
+ },
15
18
  "license": "MIT",
16
19
  "author": "Simon Rothgang <simonrothgang@gmail.com>",
17
20
  "contributors": [
@@ -21,8 +24,21 @@
21
24
  "url": "https://github.com/LiamMartens"
22
25
  }
23
26
  ],
24
- "sideEffects": false,
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/srothgan/srothgan-sanity-plugin-autocomplete-input"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "sanity.json",
34
+ "src",
35
+ "v2-incompatible.js"
36
+ ],
25
37
  "type": "module",
38
+ "sideEffects": false,
39
+ "main": "./dist/index.cjs",
40
+ "module": "./dist/index.js",
41
+ "types": "./dist/index.d.ts",
26
42
  "exports": {
27
43
  ".": {
28
44
  "source": "./src/index.ts",
@@ -32,15 +48,6 @@
32
48
  },
33
49
  "./package.json": "./package.json"
34
50
  },
35
- "main": "./dist/index.cjs",
36
- "module": "./dist/index.js",
37
- "types": "./dist/index.d.ts",
38
- "files": [
39
- "dist",
40
- "sanity.json",
41
- "src",
42
- "v2-incompatible.js"
43
- ],
44
51
  "publishConfig": {
45
52
  "exports": {
46
53
  ".": {
@@ -53,20 +60,14 @@
53
60
  },
54
61
  "scripts": {
55
62
  "build": "plugin-kit verify-package --silent && pkg-utils build --strict --check --clean",
56
- "format": "prettier --write --cache --ignore-unknown .",
57
- "format:check": "prettier --check --cache --ignore-unknown .",
63
+ "format": "oxfmt",
64
+ "format:check": "oxfmt --check",
58
65
  "link-watch": "plugin-kit link-watch",
59
- "lint": "eslint .",
66
+ "lint": "oxlint && eslint .",
67
+ "lint:fix": "oxlint --fix && eslint . --fix",
60
68
  "prepublishOnly": "npm run build",
61
69
  "watch": "pkg-utils watch --strict"
62
70
  },
63
- "repository": {
64
- "type": "git",
65
- "url": "https://github.com/srothgan/srothgan-sanity-plugin-autocomplete-input"
66
- },
67
- "bugs": {
68
- "url": "https://github.com/srothgan/srothgan-sanity-plugin-autocomplete-input/issues"
69
- },
70
71
  "dependencies": {
71
72
  "@sanity/incompatible-plugin": "^1.0.5",
72
73
  "just-compact": "^3.2.0",
@@ -77,6 +78,7 @@
77
78
  "devDependencies": {
78
79
  "@eslint/eslintrc": "^3.2.0",
79
80
  "@eslint/js": "^9.39.2",
81
+ "@oxlint/migrate": "^1.36.0",
80
82
  "@sanity/pkg-utils": "^10.2.3",
81
83
  "@sanity/plugin-kit": "^4.0.20",
82
84
  "@sanity/ui": "^3.1.11",
@@ -84,13 +86,12 @@
84
86
  "@typescript-eslint/eslint-plugin": "^8.50.1",
85
87
  "@typescript-eslint/parser": "^8.50.1",
86
88
  "eslint": "^9.39.2",
87
- "eslint-config-prettier": "^10.1.8",
88
89
  "eslint-config-sanity": "^7.1.4",
89
- "eslint-plugin-prettier": "^5.5.4",
90
+ "eslint-plugin-oxlint": "^1.36.0",
90
91
  "eslint-plugin-react": "^7.37.5",
91
92
  "eslint-plugin-react-hooks": "^7.0.1",
92
- "prettier": "^3.7.4",
93
- "prettier-plugin-packagejson": "^2.5.20",
93
+ "oxfmt": "^0.21.0",
94
+ "oxlint": "^1.36.0",
94
95
  "react": "^19.2.3",
95
96
  "react-dom": "^19.2.3",
96
97
  "sanity": "^5.1.0",
@@ -102,10 +103,10 @@
102
103
  "react": "^18 || ^19",
103
104
  "sanity": "^4 || ^5"
104
105
  },
106
+ "browserslist": "extends @sanity/browserslist-config",
105
107
  "engines": {
106
108
  "node": ">=18"
107
109
  },
108
- "browserslist": "extends @sanity/browserslist-config",
109
110
  "sanityPlugin": {
110
111
  "verifyPackage": {
111
112
  "eslintImports": false
@@ -98,7 +98,11 @@ export const AutoCompleteInput = (props: InputProps): React.ReactElement => {
98
98
  if (Array.isArray(results)) {
99
99
  const transformedResults = transform ? transform(results) : results
100
100
  const compactedValues = compact(transformedResults.map((doc) => get(doc, 'value')))
101
- setOptions(compactedValues.map((optionValue) => ({value: String(optionValue)})))
101
+ setOptions(
102
+ compactedValues.map((optionValue) => ({
103
+ value: String(optionValue),
104
+ })),
105
+ )
102
106
  setLoading(false)
103
107
  }
104
108
  })