sanity-plugin-utils 1.6.7 → 1.7.0
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/LICENSE +1 -1
- package/README.md +40 -20
- package/package.json +5 -5
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
> This is a **Sanity Studio v3** plugin.
|
|
2
|
-
|
|
3
1
|
## Installation
|
|
4
2
|
|
|
5
3
|
```sh
|
|
@@ -34,10 +32,13 @@ The `data` variable will be constantly updated as changes are made to the data r
|
|
|
34
32
|
import {useListeningQuery} from 'sanity-plugin-utils'
|
|
35
33
|
|
|
36
34
|
export default function DocumentList() {
|
|
37
|
-
const {data, loading, error} = useListeningQuery<SanityDocument[]>(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
const {data, loading, error} = useListeningQuery<SanityDocument[]>(
|
|
36
|
+
`*[_type == $type]`,
|
|
37
|
+
{
|
|
38
|
+
params: {type: 'pet'},
|
|
39
|
+
initialValue: [],
|
|
40
|
+
}
|
|
41
|
+
)
|
|
41
42
|
|
|
42
43
|
if (loading) {
|
|
43
44
|
return <Spinner />
|
|
@@ -93,11 +94,7 @@ import {useOpenInNewPane} from 'sanity-plugin-utils'
|
|
|
93
94
|
export default function SidePetOpener(pet: SanityDocument) {
|
|
94
95
|
const openInNewPane = useOpenInNewPane(pet._id, pet._type)
|
|
95
96
|
|
|
96
|
-
return (
|
|
97
|
-
<Button onClick={() => openInNewPane()}>
|
|
98
|
-
{pet.title}
|
|
99
|
-
</Button>
|
|
100
|
-
)
|
|
97
|
+
return <Button onClick={() => openInNewPane()}>{pet.title}</Button>
|
|
101
98
|
}
|
|
102
99
|
```
|
|
103
100
|
|
|
@@ -117,7 +114,10 @@ export default function PetPics(pet: SanityDocument) {
|
|
|
117
114
|
<ul>
|
|
118
115
|
{pet.pics.map((pic) => (
|
|
119
116
|
<li key={pic._key}>
|
|
120
|
-
<img
|
|
117
|
+
<img
|
|
118
|
+
src={builder.source(pic).width(200).height(200).url()}
|
|
119
|
+
alt={pic.altText}
|
|
120
|
+
/>
|
|
121
121
|
</li>
|
|
122
122
|
))}
|
|
123
123
|
</ul>
|
|
@@ -127,7 +127,7 @@ export default function PetPics(pet: SanityDocument) {
|
|
|
127
127
|
|
|
128
128
|
### useImageUrlBuilderImage()
|
|
129
129
|
|
|
130
|
-
As above, but pre-configured with an image source.
|
|
130
|
+
As above, but pre-configured with an image source.
|
|
131
131
|
|
|
132
132
|
Useful if you only have one image in your component.
|
|
133
133
|
|
|
@@ -149,22 +149,42 @@ Component for consistently displaying feedback in a card with a title, text and
|
|
|
149
149
|
import {Feedback, useListeningQuery} from 'sanity-plugin-utils'
|
|
150
150
|
|
|
151
151
|
export default function DocumentList() {
|
|
152
|
-
const {data, loading, error} = useListeningQuery(
|
|
152
|
+
const {data, loading, error} = useListeningQuery(
|
|
153
|
+
`*[_type == "task" && !complete]`
|
|
154
|
+
)
|
|
153
155
|
|
|
154
156
|
if (loading) {
|
|
155
|
-
return
|
|
157
|
+
return (
|
|
158
|
+
<Feedback
|
|
159
|
+
tone="primary"
|
|
160
|
+
title="Please hold"
|
|
161
|
+
description="Fetching tasks..."
|
|
162
|
+
/>
|
|
163
|
+
)
|
|
156
164
|
}
|
|
157
165
|
|
|
158
166
|
if (error) {
|
|
159
167
|
return (
|
|
160
|
-
<Feedback
|
|
168
|
+
<Feedback
|
|
169
|
+
tone="critical"
|
|
170
|
+
title="There was an error"
|
|
171
|
+
description="Please try again later"
|
|
172
|
+
/>
|
|
161
173
|
)
|
|
162
174
|
}
|
|
163
175
|
|
|
164
176
|
return data?.length > 0 ? (
|
|
165
|
-
<Feedback
|
|
177
|
+
<Feedback
|
|
178
|
+
tone="caution"
|
|
179
|
+
title="There are unfinished tasks"
|
|
180
|
+
description="Please get to work"
|
|
181
|
+
/>
|
|
166
182
|
) : (
|
|
167
|
-
<Feedback
|
|
183
|
+
<Feedback
|
|
184
|
+
tone="success"
|
|
185
|
+
title="You're all done"
|
|
186
|
+
description="You should feel accomplished"
|
|
187
|
+
/>
|
|
168
188
|
)
|
|
169
189
|
}
|
|
170
190
|
```
|
|
@@ -208,7 +228,7 @@ export default function Report(documents) {
|
|
|
208
228
|
|
|
209
229
|
### `UserSelectMenu`
|
|
210
230
|
|
|
211
|
-
A Menu component for searching and interacting with users. Requires Users to be passed into the component.
|
|
231
|
+
A Menu component for searching and interacting with users. Requires Users to be passed into the component.
|
|
212
232
|
|
|
213
233
|
```tsx
|
|
214
234
|
import {UserSelectMenu} from 'sanity-plugin-utils'
|
|
@@ -216,7 +236,7 @@ import {UserSelectMenu} from 'sanity-plugin-utils'
|
|
|
216
236
|
export default function Report() {
|
|
217
237
|
const users = useProjectUsers({apiVersion: `2023-01-01`})
|
|
218
238
|
const [selectedUsers, setSelectedUsers] = useState([])
|
|
219
|
-
|
|
239
|
+
|
|
220
240
|
return (
|
|
221
241
|
<UserSelectMenu
|
|
222
242
|
userList={users}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Handy hooks and clever components for Sanity Studio v3",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"format": "prettier --write --cache --ignore-unknown ."
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@sanity/icons": "^3.
|
|
54
|
+
"@sanity/icons": "^3.7.4",
|
|
55
55
|
"@sanity/incompatible-plugin": "^1.0.5",
|
|
56
|
-
"@sanity/ui": "^
|
|
56
|
+
"@sanity/ui": "^3.1.8",
|
|
57
57
|
"react-fast-compare": "^3.2.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
@@ -82,13 +82,13 @@
|
|
|
82
82
|
"rimraf": "^4.4.1",
|
|
83
83
|
"sanity": "^3.67.1",
|
|
84
84
|
"semantic-release": "^22.0.0",
|
|
85
|
-
"styled-components": "^6.1
|
|
85
|
+
"styled-components": "^6.1",
|
|
86
86
|
"typescript": "^5.4.5"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
89
|
"react": "^18 || ^19",
|
|
90
90
|
"rxjs": "^7.8.1",
|
|
91
|
-
"sanity": "^3.
|
|
91
|
+
"sanity": "^3.67.1 || ^4.0.0",
|
|
92
92
|
"styled-components": "^6.1"
|
|
93
93
|
},
|
|
94
94
|
"engines": {
|