@sanity/orderable-document-list 1.0.3 → 1.1.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/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # @sanity/orderable-document-list
2
2
 
3
- >This is a **Sanity Studio v3** plugin.
3
+ > This is a **Sanity Studio v3** plugin.
4
4
  > For the v2 version, please refer to the [v2-branch](https://github.com/sanity-io/orderable-document-list/tree/studio-v2).
5
5
 
6
6
  # What is it?
7
+
7
8
  Drag-and-drop Document Ordering without leaving the Editing surface.
8
9
 
9
10
  ![2022-04-26 12 23 39](https://user-images.githubusercontent.com/9684022/165289621-dbd9d841-028e-40c7-be14-7398fcdb1210.gif)
@@ -15,18 +16,19 @@ This plugin aims to be OS-like in that you can select and move multiple document
15
16
  A Sanity Studio with [Desk Structure](https://www.sanity.io/docs/structure-builder-introduction) configured:
16
17
 
17
18
  ```ts
18
- import {defineConfig} from "sanity";
19
- import {deskTool, StructureBuilder} from "sanity/desk";
19
+ import {defineConfig} from 'sanity'
20
+ import {deskTool, StructureBuilder} from 'sanity/desk'
20
21
 
21
22
  export default defineConfig({
22
- //...
23
- plugins: [
24
- deskTool({
25
- structure: (S, context) => { /* Strucure code */},
26
- })
27
- ]
23
+ //...
24
+ plugins: [
25
+ deskTool({
26
+ structure: (S, context) => {
27
+ /* Structure code */
28
+ },
29
+ }),
30
+ ],
28
31
  })
29
-
30
32
  ```
31
33
 
32
34
  ## Installation
@@ -51,43 +53,43 @@ The config parameter requires `type`, `S` and `context`. It also accepts `title`
51
53
  `S` and `context` are available in desk-tool structure callback, and should be forwarded as is:
52
54
 
53
55
  ```ts
54
- import {defineConfig} from "sanity";
55
- import {deskTool, StructureBuilder} from "sanity/desk";
56
+ import {defineConfig} from 'sanity'
57
+ import {deskTool, StructureBuilder} from 'sanity/desk'
56
58
  import {orderableDocumentListDeskItem} from '@sanity/orderable-document-list'
57
59
 
58
60
  export default defineConfig({
59
- //...
60
- plugins: [
61
- deskTool({
62
- structure: (S, context) => {
63
- return S.list()
64
- .title('Content')
65
- .items([
66
- // Minimum required configuration
67
- orderableDocumentListDeskItem({type: 'category', S, context}),
68
-
69
- // Optional configuration
70
- orderableDocumentListDeskItem({
71
- type: 'project',
72
- title: 'Projects',
73
- icon: Paint,
74
- // Required if using multiple lists of the same 'type'
75
- id: 'orderable-en-projects',
76
- // See notes on adding a `filter` below
77
- filter: `__i18n_lang == $lang`,
78
- params: {
79
- lang: 'en_US'
80
- },
81
- // pass from the structure callback params above
82
- S,
83
- context
84
- }),
85
-
86
- // ... all other desk items
87
- ])
88
- },
89
- })
90
- ]
61
+ //...
62
+ plugins: [
63
+ deskTool({
64
+ structure: (S, context) => {
65
+ return S.list()
66
+ .title('Content')
67
+ .items([
68
+ // Minimum required configuration
69
+ orderableDocumentListDeskItem({type: 'category', S, context}),
70
+
71
+ // Optional configuration
72
+ orderableDocumentListDeskItem({
73
+ type: 'project',
74
+ title: 'Projects',
75
+ icon: Paint,
76
+ // Required if using multiple lists of the same 'type'
77
+ id: 'orderable-en-projects',
78
+ // See notes on adding a `filter` below
79
+ filter: `__i18n_lang == $lang`,
80
+ params: {
81
+ lang: 'en_US',
82
+ },
83
+ // pass from the structure callback params above
84
+ S,
85
+ context,
86
+ }),
87
+
88
+ // ... all other desk items
89
+ ])
90
+ },
91
+ }),
92
+ ],
91
93
  })
92
94
  ```
93
95
 
@@ -120,7 +122,7 @@ export default defineConfig({
120
122
  schema: {
121
123
  types: (previousTypes) => {
122
124
  return [
123
- ...previousTypes,
125
+ ...previousTypes,
124
126
  {
125
127
  name: "category",
126
128
  title: "Category",
@@ -146,10 +148,10 @@ export default defineConfig({
146
148
 
147
149
  ### 3. Generate initial Ranks
148
150
 
149
- On first load, your Document list will not have any Order. You can select "Reset Order" from the menu in the top right of the list.
151
+ On first load, your Document list will not have any Order. You can select "Reset Order" from the menu in the top right of the list.
150
152
  You can also re-run this at any time.
151
153
 
152
- The `orderRankField` will query the last Document to set an `initialValue` to come after it.
154
+ The `orderRankField` will query the last Document to set an `initialValue` to come after it.
153
155
  New Documents always start at the end of the Ordered list.
154
156
 
155
157
  ## Querying Ordered Documents
@@ -176,6 +178,7 @@ To get this first version out the door there are few configuration settings and
176
178
  Feedback and PRs welcome :)
177
179
 
178
180
  ### Breaking change in the v3 version
181
+
179
182
  `orderableDocumentListDeskItem` requires context from sanity config now.
180
183
  See the examples above.
181
184
 
@@ -185,10 +188,6 @@ Uses [kvandakes](https://github.com/kvandake)'s [TypeScript implementation](http
185
188
 
186
189
  Put simply it updates the position of an individual – or many – Documents in an ordered list without updating any others. It's fast.
187
190
 
188
- ## License
189
-
190
- MIT-licensed. See LICENSE.
191
-
192
191
  ## Develop & test
193
192
 
194
193
  This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
@@ -203,3 +202,7 @@ Run ["CI & Release" workflow](https://github.com/sanity-io/orderable-document-li
203
202
  Make sure to select the v3 branch and check "Release new version".
204
203
 
205
204
  Semantic release will only release on configured branches, so it is safe to run release on any branch.
205
+
206
+ ## License
207
+
208
+ [MIT](LICENSE) © Sanity.io
@@ -2,6 +2,7 @@ import {ComponentType} from 'react'
2
2
  import type {ConfigContext} from 'sanity'
3
3
  import {FieldDefinitionBase} from 'sanity'
4
4
  import {ListItem} from 'sanity/desk'
5
+ import {SortOrdering} from 'sanity'
5
6
  import {StringDefinition} from 'sanity'
6
7
  import {StructureBuilder} from 'sanity/desk'
7
8
  import {WidenInitialValue} from 'sanity'
@@ -28,14 +29,7 @@ export declare const orderRankField: (config: RankFieldConfig) => {
28
29
  WidenValidation &
29
30
  WidenInitialValue
30
31
 
31
- export declare const orderRankOrdering: {
32
- title: string
33
- name: string
34
- by: {
35
- field: 'orderRank'
36
- direction: string
37
- }[]
38
- }
32
+ export declare const orderRankOrdering: SortOrdering
39
33
 
40
34
  export declare interface RankFieldConfig {
41
35
  type: string