@srothgan/sanity-plugin-autocomplete-input 3.0.2 → 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 +68 -44
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,37 +47,61 @@ export default defineConfig({
|
|
|
47
47
|
});
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
### Configuration Options
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
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
|