@srothgan/sanity-plugin-autocomplete-input 3.0.1 → 3.0.3

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
@@ -47,37 +47,61 @@ export default defineConfig({
47
47
  });
48
48
  ```
49
49
 
50
- You can just use it as a schema type. To customize the autocomplete list you have 3 options:
50
+ ### Configuration Options
51
51
 
52
- 1. Specify the `autocompleteFieldPath` option, which the plugin will use to look for documents with the same field path to aggregate the option values.
53
- 2. Manually specify options in the schema option
54
- 3. Specify your own GROQ query returning a `[{ "value": "foobar" }]` format (you can use a `transform` function if this is not achievable using GROQ only)
52
+ You can configure the autocomplete behavior using one of three approaches:
53
+
54
+ #### 1. Auto-aggregate from Existing Documents
55
+
56
+ The plugin automatically collects unique values from documents with the same field:
55
57
 
56
58
  ```javascript
57
- export default {
58
- fields: [
59
- {
60
- name: "autocomplete-input",
61
- type: "autocomplete",
62
- options: {
63
- // specify field path
64
- autocompleteFieldPath: "title",
65
- // this option can be used to disable using "new" values
66
- disableNew: false,
67
- // manually specify options
68
- options: [{ value: "Option 1" }, { value: "Option 2" }],
69
- // specify custom groq query
70
- groq: {
71
- query: '*[_type == $type] { "value": title }',
72
- params: {
73
- type: "page",
74
- },
75
- transform: (values) => values,
76
- },
59
+ {
60
+ name: "category",
61
+ type: "autocomplete",
62
+ options: {
63
+ autocompleteFieldPath: "category", // aggregates from all documents with this field
64
+ disableNew: false, // optional: prevent users from creating new values
65
+ },
66
+ }
67
+ ```
68
+
69
+ #### 2. Manual Options List
70
+
71
+ Provide a predefined list of options:
72
+
73
+ ```javascript
74
+ {
75
+ name: "status",
76
+ type: "autocomplete",
77
+ options: {
78
+ options: [
79
+ { value: "Draft" },
80
+ { value: "Published" },
81
+ { value: "Archived" }
82
+ ],
83
+ },
84
+ }
85
+ ```
86
+
87
+ #### 3. Custom GROQ Query
88
+
89
+ Define your own query for maximum flexibility:
90
+
91
+ ```javascript
92
+ {
93
+ name: "author",
94
+ type: "autocomplete",
95
+ options: {
96
+ groq: {
97
+ query: '*[_type == $type] { "value": title }',
98
+ params: {
99
+ type: "author",
77
100
  },
101
+ transform: (values) => values, // optional: transform results
78
102
  },
79
- ],
80
- };
103
+ },
104
+ }
81
105
  ```
82
106
 
83
107
  ### Advanced GROQ parameters
@@ -103,24 +127,7 @@ export default {
103
127
  };
104
128
  ```
105
129
 
106
- ## Differences from Original
107
-
108
- This maintained fork includes the following enhancements:
109
-
110
- ### Updated Dependencies
111
- - **Sanity v4 & v5 Support**: Fully compatible with both Sanity Studio v4 and v5
112
- - **React 18 & 19 Support**: Works with React 18 (Sanity v4) and React 19 (Sanity v5)
113
- - **Modern Build Tooling**: Migrated from Babel to SWC for faster builds
114
- - **TypeScript 5.3**: Updated to latest TypeScript with improved type safety
115
-
116
- ### Maintained & Active
117
- - Regular dependency updates for security and compatibility
118
- - Active issue tracking and bug fixes
119
- - Community-driven improvements
120
-
121
- All original functionality and API remain unchanged for seamless migration.
122
-
123
- ## TypeScript Usage
130
+ ### TypeScript Usage
124
131
 
125
132
  The plugin is written in TypeScript and exports all necessary types:
126
133
 
@@ -153,6 +160,23 @@ export default defineConfig({
153
160
  })
154
161
  ```
155
162
 
163
+ ## Differences from Original
164
+
165
+ This maintained fork includes the following enhancements:
166
+
167
+ ### Updated Dependencies
168
+ - **Sanity v4 & v5 Support**: Fully compatible with both Sanity Studio v4 and v5
169
+ - **React 18 & 19 Support**: Works with React 18 (Sanity v4) and React 19 (Sanity v5)
170
+ - **Modern Build Tooling**: Migrated from Babel to SWC for faster builds
171
+ - **TypeScript 5.3**: Updated to latest TypeScript with improved type safety
172
+
173
+ ### Maintained & Active
174
+ - Regular dependency updates for security and compatibility
175
+ - Active issue tracking and bug fixes
176
+ - Community-driven improvements
177
+
178
+ All original functionality and API remain unchanged for seamless migration.
179
+
156
180
  ## Troubleshooting
157
181
 
158
182
  ### Plugin not appearing in Studio
@@ -66,7 +66,6 @@ export const AutoCompleteInput = (props)=>{
66
66
  }
67
67
  });
68
68
  }, [
69
- query,
70
69
  schemaType.options,
71
70
  documentValue,
72
71
  sanityClient
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srothgan/sanity-plugin-autocomplete-input",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {