@sanity/orderable-document-list 0.0.9 → 0.0.10

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
@@ -38,6 +38,8 @@ export default () =>
38
38
  type: 'project',
39
39
  title: 'Projects',
40
40
  icon: Paint
41
+ // Required if using multiple lists of the same 'type'
42
+ id: 'orderable-en-projects',
41
43
  // See notes on adding a `filter` below
42
44
  filter: `__i18n_lang == $lang`,
43
45
  params: {
@@ -48,7 +50,7 @@ export default () =>
48
50
  // ... all other desk items
49
51
  ```
50
52
 
51
- ** Caution: Adding a `filter` **
53
+ **Caution: Adding a `filter`**
52
54
 
53
55
  By default, the plugin will display _all_ documents of the same `type`. However, you may wish to add a `filter` to reduce this down to a subset of documents. A typical usecase is for [internationalized document schema](https://github.com/sanity-io/document-internationalization) to order documents of just the base language version.
54
56
 
@@ -28,9 +28,10 @@ function orderableDocumentListDeskItem() {
28
28
  filter = config.filter,
29
29
  params = config.params,
30
30
  title = config.title,
31
- icon = config.icon;
31
+ icon = config.icon,
32
+ id = config.id;
32
33
  var listTitle = title !== null && title !== void 0 ? title : "Orderable ".concat(type);
33
- var listId = "orderable-".concat(type);
34
+ var listId = id !== null && id !== void 0 ? id : "orderable-".concat(type);
34
35
  var listIcon = icon !== null && icon !== void 0 ? icon : _icons.SortIcon;
35
36
  var typeTitle = (_schema$get$title = (_schema$get = _schema.default.get(type)) === null || _schema$get === void 0 ? void 0 : _schema$get.title) !== null && _schema$get$title !== void 0 ? _schema$get$title : type;
36
37
  return _structureBuilder.default.listItem(type).title(listTitle).id(listId).icon(listIcon).child(Object.assign(_structureBuilder.default.documentTypeList(type).serialize(), {
@@ -1 +1 @@
1
- {"version":3,"file":"orderableDocumentListDeskItem.js","names":["orderableDocumentListDeskItem","config","type","Error","filter","params","title","icon","listTitle","listId","listIcon","SortIcon","typeTitle","schema","get","S","listItem","id","child","Object","assign","documentTypeList","serialize","__preserveInstance","key","component","OrderableDocumentList","options","menuItems","menuItem","intent","GenerateIcon","action"],"sources":["../../src/desk-structure/orderableDocumentListDeskItem.js"],"sourcesContent":["import S from '@sanity/desk-tool/structure-builder'\nimport {SortIcon, GenerateIcon} from '@sanity/icons'\nimport schema from 'part:@sanity/base/schema'\n\nimport OrderableDocumentList from '../OrderableDocumentList'\n\nexport function orderableDocumentListDeskItem(config = {}) {\n if (!config?.type) {\n throw new Error(`\n \"type\" not defined in orderableDocumentListDeskItem parameters.\n \\n\\n\n Example: orderableDocumentListDeskItem({type: 'category'})\n `)\n }\n\n const {type, filter, params, title, icon} = config\n\n const listTitle = title ?? `Orderable ${type}`\n const listId = `orderable-${type}`\n const listIcon = icon ?? SortIcon\n const typeTitle = schema.get(type)?.title ?? type\n\n return S.listItem(type)\n .title(listTitle)\n .id(listId)\n .icon(listIcon)\n .child(\n Object.assign(S.documentTypeList(type).serialize(), {\n // Prevents the component from re-rendering when switching documents\n __preserveInstance: true,\n // Prevents the component from NOT re-rendering when switching listItems\n key: listId,\n\n type: 'component',\n component: OrderableDocumentList,\n options: {type, filter, params},\n menuItems: [\n S.menuItem()\n .title(`Create new ${typeTitle}`)\n .intent({type: 'create', params: {type}})\n .serialize(),\n S.menuItem().title(`Reset Order`).icon(GenerateIcon).action(`resetOrder`).serialize(),\n S.menuItem().title(`Show Increments`).icon(SortIcon).action(`showIncrements`).serialize(),\n ],\n })\n )\n .serialize()\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;AAEO,SAASA,6BAAT,GAAoD;EAAA;;EAAA,IAAbC,MAAa,uEAAJ,EAAI;;EACzD,IAAI,EAACA,MAAD,aAACA,MAAD,eAACA,MAAM,CAAEC,IAAT,CAAJ,EAAmB;IACjB,MAAM,IAAIC,KAAJ,2JAAN;EAKD;;EAED,IAAOD,IAAP,GAA4CD,MAA5C,CAAOC,IAAP;EAAA,IAAaE,MAAb,GAA4CH,MAA5C,CAAaG,MAAb;EAAA,IAAqBC,MAArB,GAA4C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C,EAAqDqB,MAArD,mBAA8EV,SAA9E,EANS;EATuC,CAApD,CALG,EAwBJA,SAxBI,EAAP;AAyBD"}
1
+ {"version":3,"file":"orderableDocumentListDeskItem.js","names":["orderableDocumentListDeskItem","config","type","Error","filter","params","title","icon","id","listTitle","listId","listIcon","SortIcon","typeTitle","schema","get","S","listItem","child","Object","assign","documentTypeList","serialize","__preserveInstance","key","component","OrderableDocumentList","options","menuItems","menuItem","intent","GenerateIcon","action"],"sources":["../../src/desk-structure/orderableDocumentListDeskItem.js"],"sourcesContent":["import S from '@sanity/desk-tool/structure-builder'\nimport {SortIcon, GenerateIcon} from '@sanity/icons'\nimport schema from 'part:@sanity/base/schema'\n\nimport OrderableDocumentList from '../OrderableDocumentList'\n\nexport function orderableDocumentListDeskItem(config = {}) {\n if (!config?.type) {\n throw new Error(`\n \"type\" not defined in orderableDocumentListDeskItem parameters.\n \\n\\n\n Example: orderableDocumentListDeskItem({type: 'category'})\n `)\n }\n\n const {type, filter, params, title, icon, id} = config\n\n const listTitle = title ?? `Orderable ${type}`\n const listId = id ?? `orderable-${type}`\n const listIcon = icon ?? SortIcon\n const typeTitle = schema.get(type)?.title ?? type\n\n return S.listItem(type)\n .title(listTitle)\n .id(listId)\n .icon(listIcon)\n .child(\n Object.assign(S.documentTypeList(type).serialize(), {\n // Prevents the component from re-rendering when switching documents\n __preserveInstance: true,\n // Prevents the component from NOT re-rendering when switching listItems\n key: listId,\n\n type: 'component',\n component: OrderableDocumentList,\n options: {type, filter, params},\n menuItems: [\n S.menuItem()\n .title(`Create new ${typeTitle}`)\n .intent({type: 'create', params: {type}})\n .serialize(),\n S.menuItem().title(`Reset Order`).icon(GenerateIcon).action(`resetOrder`).serialize(),\n S.menuItem().title(`Show Increments`).icon(SortIcon).action(`showIncrements`).serialize(),\n ],\n })\n )\n .serialize()\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;AAEO,SAASA,6BAAT,GAAoD;EAAA;;EAAA,IAAbC,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EAAE,CACTZ,yBAAA,CAAEa,QAAF,GACGvB,KADH,sBACuBO,SADvB,GAEGiB,MAFH,CAEU;MAAC5B,IAAI,EAAE,QAAP;MAAiBG,MAAM,EAAE;QAACH;MAAD;IAAzB,CAFV,EAGGoB,SAHH,EADS,EAKTN,yBAAA,CAAEa,QAAF,GAAavB,KAAb,gBAAkCC,IAAlC,CAAuCwB,mBAAvC,EAAqDC,MAArD,eAA0EV,SAA1E,EALS,EAMTN,yBAAA,CAAEa,QAAF,GAAavB,KAAb,oBAAsCC,IAAtC,CAA2CK,eAA3C,EAAqDoB,MAArD,mBAA8EV,SAA9E,EANS;EATuC,CAApD,CALG,EAwBJA,SAxBI,EAAP;AAyBD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/orderable-document-list",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Drag-and-drop Document Ordering without leaving the Editing surface",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -13,10 +13,10 @@ export function orderableDocumentListDeskItem(config = {}) {
13
13
  `)
14
14
  }
15
15
 
16
- const {type, filter, params, title, icon} = config
16
+ const {type, filter, params, title, icon, id} = config
17
17
 
18
18
  const listTitle = title ?? `Orderable ${type}`
19
- const listId = `orderable-${type}`
19
+ const listId = id ?? `orderable-${type}`
20
20
  const listIcon = icon ?? SortIcon
21
21
  const typeTitle = schema.get(type)?.title ?? type
22
22