sanity-plugin-internationalized-array 1.6.0 → 1.6.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/LICENSE +1 -1
- package/README.md +26 -0
- package/lib/{src/index.d.ts → index.d.ts} +6 -1
- package/lib/index.esm.js +9483 -4
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +9483 -4
- package/lib/index.js.map +1 -1
- package/package.json +46 -34
- package/src/cache.ts +1 -0
- package/src/components/InternationalizedArray.tsx +30 -17
- package/src/components/Table.tsx +1 -1
- package/src/components/getSelectedValue.ts +3 -1
- package/src/components/getToneFromValidation.ts +3 -1
- package/src/schema/array.ts +12 -7
- package/src/schema/object.ts +2 -8
- package/src/types.ts +7 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -76,6 +76,32 @@ languages: async () => {
|
|
|
76
76
|
}
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
The async function contains a configured Sanity Client in the first parameter, allowing you to store Language options as documents. Your query should return an array of objects with an `id` and `title`.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
languages: async (client) => {
|
|
83
|
+
const response = await client.fetch(`*[_type == "language"]{ id, title }`)
|
|
84
|
+
return response
|
|
85
|
+
},
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Additionally, you can "pick" fields from a document, to pass into the query. For example, if you have a concept of "Markets" where only certain language fields are required in certain markets.
|
|
89
|
+
|
|
90
|
+
In this example, each language document has an array of strings called `markets` to declare where that language can be used. And the document being authored has a single `market` field.
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
select: {
|
|
94
|
+
market: 'market'
|
|
95
|
+
},
|
|
96
|
+
languages: async (client, {market = ``}) => {
|
|
97
|
+
const response = await client.fetch(
|
|
98
|
+
`*[_type == "language" && $market in markets]{ id, title }`,
|
|
99
|
+
{market}
|
|
100
|
+
)
|
|
101
|
+
return response
|
|
102
|
+
},
|
|
103
|
+
```
|
|
104
|
+
|
|
79
105
|
## Using more complex field types
|
|
80
106
|
|
|
81
107
|
For more control over the `value` field, you can pass a schema definition into the `fieldTypes` array.
|
|
@@ -5,7 +5,12 @@ import type {Rule} from 'sanity'
|
|
|
5
5
|
import type {RuleTypeConstraint} from 'sanity'
|
|
6
6
|
import type {SanityClient} from 'sanity'
|
|
7
7
|
|
|
8
|
-
export declare type AllowedType =
|
|
8
|
+
export declare type AllowedType =
|
|
9
|
+
| 'string'
|
|
10
|
+
| 'number'
|
|
11
|
+
| 'boolean'
|
|
12
|
+
| 'text'
|
|
13
|
+
| 'reference'
|
|
9
14
|
|
|
10
15
|
export declare type ArrayConfig = {
|
|
11
16
|
name: string
|