@sanity/orderable-document-list
2.0.92.0.10
~
Modified (5 files)
Index: package/dist/index.js
===================================================================
--- package/dist/index.js
+++ package/dist/index.js
@@ -326,10 +326,10 @@
children: [displayedData.map((item_3, index_1) => /* @__PURE__ */ jsx(Draggable, {
draggableId: item_3._id,
index: index_1,
children: (innerProvided, innerSnapshot) => {
- let isSelected_0 = selectedIds.includes(item_3._id), isDragging = innerSnapshot.isDragging, isGhosting = !!(!isDragging && draggingId && isSelected_0), isUpdating = listIsUpdating && isSelected_0, isDisabled = !item_3[ORDER_FIELD_NAME], tone = cardTone({
- isDuplicate: duplicateOrders.includes(item_3[ORDER_FIELD_NAME]),
+ let isSelected_0 = selectedIds.includes(item_3._id), isDragging = innerSnapshot.isDragging, isGhosting = !!(!isDragging && draggingId && isSelected_0), isUpdating = listIsUpdating && isSelected_0, isDisabled = !item_3[ORDER_FIELD_NAME], isDuplicate = duplicateOrders.includes(item_3[ORDER_FIELD_NAME]), tone = cardTone({
+ isDuplicate,
isGhosting,
isDragging,
isSelected: isSelected_0
}), selectedCount = selectedIds.length, dragBadge = isDragging && selectedCount > 1 ? selectedCount : !1; Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,7 +1,7 @@
{
"name": "@sanity/orderable-document-list",
- "version": "2.0.9",
+ "version": "2.0.10",
"description": "Drag-and-drop Document Ordering without leaving the Editing surface",
"keywords": [
"sanity",
"sanity-plugin"
@@ -29,23 +29,23 @@
"dependencies": {
"@hello-pangea/dnd": "^18.0.1",
"@sanity/client": "^7.23.0",
"@sanity/icons": "^5.0.0",
- "@sanity/ui": "^3.3.1",
+ "@sanity/ui": "^3.3.5",
"lexorank": "^1.0.5",
- "sanity-plugin-utils": "^2.0.6"
+ "sanity-plugin-utils": "^2.0.7"
},
"devDependencies": {
"@sanity/tsconfig": "^2.2.0",
- "@sanity/tsdown-config": "^0.11.0",
+ "@sanity/tsdown-config": "^0.13.1",
"@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3",
"babel-plugin-react-compiler": "^1.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"sanity": "^6.3.0",
"styled-components": "^6.4.3",
- "tsdown": "^0.22.3"
+ "tsdown": "^0.22.5"
},
"peerDependencies": {
"react": "^19.2",
"react-dom": "^19.2", Index: package/dist/index.d.ts.map
===================================================================
--- package/dist/index.d.ts.map
+++ package/dist/index.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/fields/orderRankField.ts","../src/fields/orderRankOrdering.ts","../src/desk-structure/orderableDocumentListDeskItem.ts","../src/OrderableDocumentList.tsx"],"mappings":";;;;;KASY,eAAA;AAAA,UCHK,eAAA,SAAwB,OAAA,CACvC,IAAA,CAAK,gBAAA;EAEL,IAAA;EACA,eAAA,GAAkB,eAAA;AAAA;AAAA,cAGP,cAAA,GAAc,MAAA,EAAY,eAAA,KAAkB,eAAe;AAAA,cCT3D,iBAAA,EAAmB,YAI/B;AAAA,UCCgB,mBAAA;EACf,IAAA;EACA,EAAA;EACA,KAAA;EACA,IAAA,GAAO,aAAA;EACP,MAAA,GAAS,MAAA;EACT,MAAA;EACA,SAAA,GAAY,QAAA;EACZ,YAAA;EACA,OAAA,EAAS,aAAA;EACT,CAAA,EAAG,gBAAA;AAAA;AAAA,iBAGW,6BAAA,CAA8B,MAAA,EAAQ,mBAAA,GAAsB,QAAQ;AAAA,UCfnE,0BAAA;EACf,OAAA;IACE,IAAA;IACA,MAAA,EAAQ,YAAA;IACR,MAAA;IACA,MAAA,GAAS,MAAM;IACf,cAAA;EAAA;AAAA;AAAA,UAIM,KAAA;EACR,cAAA;EACA,qBAAA,EAAuB,WAAW;AAAA;AAAA,cAIvB,qBAAA,SAA8B,SAAA,CAAU,0BAAA,EAA4B,KAAA;EAC/E,WAAA,CAAY,KAAA,EAAO,0BAAA;EAQnB,cAAA;IACE,cAAA;IAMA,UAAA,QAAU,OAAA;EAAA;EAyBH,MAAA,oBAAM,GAAA,CAAA,OAAA;AAAA"}
\ No newline at end of file
+{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/fields/orderRankField.ts","../src/fields/orderRankOrdering.ts","../src/desk-structure/orderableDocumentListDeskItem.ts","../src/OrderableDocumentList.tsx"],"mappings":";;;;;KASY;UCHK,wBAAwB,QACvC,KAAK;EAEL;EACA,kBAAkB;;cAGP,iBAAc,QAAY,oBAAkB;cCT5C,mBAAmB;UCKf;EACf;EACA;EACA;EACA,OAAO;EACP,SAAS;EACT;EACA,YAAY;EACZ;EACA,SAAS;EACT,GAAG;;iBAGW,8BAA8B,QAAQ,sBAAsB;UCf3D;EACf;IACE;IACA,QAAQ;IACR;IACA,SAAS;IACT;;;UAIM;EACR;EACA,uBAAuB;;cAIZ,8BAA8B,UAAU,4BAA4B;EAC/E,YAAY,OAAO;EAQnB;IACE;IAMA,kBAAU;;EAyBH,0BAAM,IAAA"}
\ No newline at end of file Index: package/dist/index.js.map
===================================================================
--- package/dist/index.js.map
+++ package/dist/index.js.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"index.js","names":["ORDER_FIELD_NAME","const","API_VERSION","LexoRank","parseOrderRank","value","fallback","console","warn","parse","err","Error","message","String","LexoRank","NewItemPosition","parseOrderRank","initialRank","compareRankValue","newItemPosition","compareRank","min","rank","genPrev","genNext","toString","defineField","FieldDefinition","StringDefinition","API_VERSION","ORDER_FIELD_NAME","initialRank","NewItemPosition","RankFieldConfig","Partial","Omit","type","newItemPosition","orderRankField","config","Error","rest","title","readOnly","hidden","name","initialValue","value","getClient","direction","lastDocOrderRank","apiVersion","fetch","order","tag","createContext","OrderableContextValue","showIncrements","OrderableContext","ChevronDownIcon","ChevronUpIcon","DragHandleIcon","AvatarCounter","Card","Box","Button","Flex","Text","Tooltip","useContext","useSchema","PreviewCard","Preview","DocumentStatusIndicator","DocumentStatus","useDocumentVersionInfo","usePaneRouter","OrderableContext","SanityDocumentWithOrder","DocumentProps","doc","entities","increment","index","nextIndex","docId","isFirst","isLast","dragBadge","Document","t0","$","_c","showIncrements","schema","router","versionsInfo","_id","ChildLink","groupIndex","routerPanesState","currentDoc","id","t1","replace","pressed","selected","length","t2","_type","get","schemaType","t3","draft","published","versions","tooltip","t4","Symbol","for","flexShrink","t5","t6","t7","width","t8","t9","t10","t11","t12","t13","t14","t15","SanityClient","useClient","usePerspective","API_VERSION","useSanityClient","$","_c","perspectiveStack","t0","Symbol","for","apiVersion","t1","t2","withConfig","perspective","DraggableLocation","LexoRank","PatchOperations","SanityDocumentWithOrder","ORDER_FIELD_NAME","parseOrderRank","ReorderArgs","entities","selectedIds","source","destination","ReorderReturn","newOrder","patches","message","lexicographicalSort","a","b","reorderDocuments","startIndex","index","endIndex","isMovingUp","selectedItems","filter","item","includes","_id","length","join","all","selected","reduce","acc","cur","curIndex","prevIndex","prevRank","min","curRank","nextIndex","nextRank","max","betweenRank","between","selectedItem","toString","flatMap","doc","docPatches","set","startsWith","hasPublished","push","replace","allSorted","sort","DragDropContext","Draggable","Droppable","DropResult","DraggableLocation","Box","Card","useToast","useEffect","useState","useMemo","useCallback","CSSProperties","PatchOperations","usePaneRouter","Document","useSanityClient","ORDER_FIELD_NAME","reorderDocuments","SanityDocumentWithOrder","ListSetting","isDuplicate","isGhosting","isDragging","isSelected","DragResultLike","draggableId","source","destination","DraggableListProps","data","listIsUpdating","setListIsUpdating","val","getItemStyle","draggableStyle","itemIsUpdating","userSelect","transition","opacity","pointerEvents","undefined","cardTone","settings","DraggableList","toast","router","groupIndex","routerPanesState","currentDoc","id","orderedData","setOrderedData","displayedData","draggingId","setDraggingId","selectedIds","setSelectedIds","clearSelected","handleSelect","clickedId","index","nativeEvent","MouseEvent","includes","selectMultiple","shiftKey","isUsingWindows","navigator","appVersion","indexOf","selectAdditional","ctrlKey","metaKey","updatedIds","preventDefault","lastSelectedId","length","lastSelectedIndex","findIndex","item","_id","firstSelected","lastSelected","betweenIds","filter","_","itemIndex","map","client","transactPatches","patches","message","transaction","forEach","docId","ops","patch","updated","commit","visibility","tag","push","title","results","status","description","handleDragEnd","result","entities","effectedIds","newOrder","handleDragStart","start","selected","incrementIndex","shiftFrom","shiftTo","droppableId","onWindowKeyDown","event","KeyboardEvent","key","window","addEventListener","removeEventListener","duplicateOrders","orderField","onDragEnd","provided","droppableProps","innerRef","innerProvided","innerSnapshot","Boolean","isUpdating","isDisabled","tone","selectedCount","dragBadge","draggableProps","dragHandleProps","style","e","placeholder","getPublishedId","getVersionFromId","isDraftId","isPublishedId","isVersionId","SanityDocumentWithOrder","isVersionForCurrentPerspective","document","perspectiveName","publishedId","_id","getFilteredDedupedDocs","documents","flatDocuments","flat","dedupedDocuments","cur","versionFromId","isCorrectVersion","push","hasMatchingVersion","some","doc","hasDraft","hasDuplicatePublished","baseId","hasVersion","hasPublished","replace","ORDER_FIELD_NAME","DocumentListQueryProps","type","filter","params","Record","currentVersion","DocumentListQueryResult","query","queryParams","DEFAULT_PARAMS","getDocumentQuery","perspectiveFilter","querySelect","queryOrder","queryFields","order","Box","Flex","Container","Spinner","Stack","Text","useMemo","useState","useListeningQuery","Feedback","DraggableList","ORDER_FIELD_NAME","getFilteredDedupedDocs","getDocumentQuery","DocumentListQueryProps","SanityDocumentWithOrder","DocumentListQuery","props","$","_c","listIsUpdating","setListIsUpdating","t0","query","queryParams","t1","Symbol","for","t2","params","initialValue","data","_queryData","loading","error","t3","Array","isArray","queryData","t4","currentVersion","t5","filter","_temp","unorderedDataCount","length","t6","width","height","t7","overflow","t8","t9","doc","useToast","Box","ToastParams","useEffect","useMemo","useSchema","Feedback","DocumentListQuery","ORDER_FIELD_NAME","OrderableContext","DocumentListWrapperProps","showIncrements","type","resetOrderTransaction","filter","params","Record","currentVersion","DocumentListWrapper","t0","$","_c","toast","schema","t1","orderableContextValue","t2","t3","title","status","push","t4","bb0","t5","Symbol","for","typeSchema","get","fields","some","_temp","t6","t7","t8","_temp2","schemaIsInvalid","field_0","field","name","MultipleMutationResult","SanityClient","LexoRank","ORDER_FIELD_NAME","getDocumentQuery","DocumentListQueryProps","ResetOrderParams","client","currentVersion","resetOrder","params","Promise","queryProps","query","queryParams","documents","fetch","Array","_id","_type","tag","length","aLexoRank","min","transaction","map","doc","reduce","trx","documentId","genNext","patch","set","toString","commit","visibility","SanityClient","ToastParams","Component","DocumentListWrapper","resetOrder","OrderableDocumentListProps","options","type","client","filter","params","Record","currentVersion","State","showIncrements","resetOrderTransaction","OrderableDocumentList","constructor","props","state","actionHandlers","setState","status","title","closable","update","reorderWasSuccessful","results","length","render","GenerateIcon","SortIcon","ComponentType","ConfigContext","ListItem","MenuItem","StructureBuilder","API_VERSION","OrderableDocumentList","OrderableListConfig","type","id","title","icon","params","Record","filter","menuItems","createIntent","context","S","orderableDocumentListDeskItem","config","Error","schema","getClient","maybePerspectiveStack","Reflect","get","perspectiveStack","Array","isArray","every","item","client","apiVersion","currentVersion","listTitle","listId","listIcon","typeTitle","defaultMenuItems","push","menuItem","intent","serialize","listItem","schemaType","child","Object","assign","documentTypeList","canHandleIntent","_intentName","__preserveInstance","key","component","options","action"],"sources":["../src/helpers/constants.ts","../src/helpers/parseOrderRank.ts","../src/helpers/initialRank.ts","../src/fields/orderRankField.ts","../src/fields/orderRankOrdering.ts","../src/OrderableContext.ts","../src/Document.tsx","../src/helpers/client.ts","../src/helpers/reorderDocuments.ts","../src/DraggableList.tsx","../src/helpers/getFilteredDedupedDocs.ts","../src/helpers/query.ts","../src/DocumentListQuery.tsx","../src/DocumentListWrapper.tsx","../src/helpers/resetOrder.ts","../src/OrderableDocumentList.tsx","../src/desk-structure/orderableDocumentListDeskItem.ts"],"sourcesContent":["export const ORDER_FIELD_NAME = `orderRank` as const\n\n// same version we are using in the vision plugin\nexport const API_VERSION = `v2025-06-27` as const\n","import {LexoRank} from 'lexorank'\n\n// Safely parse a LexoRank string; fall back if invalid\nexport function parseOrderRank(value: unknown, fallback: LexoRank): LexoRank {\n if (typeof value !== 'string') {\n console.warn('[orderable-document-list] Invalid orderRank value (expected string):', value)\n return fallback\n }\n\n try {\n return LexoRank.parse(value)\n } catch (err) {\n console.warn(\n '[orderable-document-list] Failed to parse orderRank value:',\n value,\n 'Error:',\n err instanceof Error ? err.message : String(err),\n )\n return fallback\n }\n}\n","import {LexoRank} from 'lexorank'\n\nimport type {NewItemPosition} from '../types'\nimport {parseOrderRank} from './parseOrderRank'\n\n// Use in initial value field by passing in the rank value of the last document\n// If not value passed, generate a sensibly low rank\nexport function initialRank(\n compareRankValue: unknown = ``,\n newItemPosition: NewItemPosition = 'after',\n) {\n const compareRank = parseOrderRank(compareRankValue, LexoRank.min())\n const rank =\n newItemPosition === 'before' ? compareRank.genPrev().genPrev() : compareRank.genNext().genNext()\n\n return rank.toString()\n}\n","import {defineField, type FieldDefinition, type StringDefinition} from 'sanity'\n\nimport {API_VERSION, ORDER_FIELD_NAME} from '../helpers/constants'\nimport {initialRank} from '../helpers/initialRank'\nimport type {NewItemPosition} from '../types'\n\nexport interface RankFieldConfig extends Partial<\n Omit<StringDefinition, 'name' | 'type' | 'initialValue'>\n> {\n type: string\n newItemPosition?: NewItemPosition\n}\n\nexport const orderRankField = (config: RankFieldConfig): FieldDefinition<'string'> => {\n if (!config?.type) {\n throw new Error(\n `\n type must be provided.\n Example: orderRankField({type: 'category'})\n `,\n )\n }\n\n const {type, newItemPosition = 'after', ...rest} = config\n return defineField({\n title: 'Order Rank',\n readOnly: true,\n hidden: true,\n ...rest,\n name: ORDER_FIELD_NAME,\n type: 'string',\n initialValue: async (value, {getClient}) => {\n void value\n const direction = newItemPosition === 'before' ? 'asc' : 'desc'\n\n const lastDocOrderRank = await getClient({apiVersion: API_VERSION}).fetch<string | undefined>(\n `*[_type == $type]|order(@[$order] ${direction})[0][$order]`,\n {type, order: ORDER_FIELD_NAME},\n {tag: 'orderable-document-list.last-doc-order-rank'},\n )\n return initialRank(lastDocOrderRank, newItemPosition)\n },\n })\n}\n","import type {SortOrdering} from 'sanity'\n\nimport {ORDER_FIELD_NAME} from '../helpers/constants'\n\nexport const orderRankOrdering: SortOrdering = {\n title: 'Ordered',\n name: 'ordered',\n by: [{field: ORDER_FIELD_NAME, direction: 'asc'}],\n}\n","import {createContext} from 'react'\n\nexport interface OrderableContextValue {\n showIncrements?: boolean\n}\n\nexport const OrderableContext = createContext<OrderableContextValue>({})\n","import {ChevronDownIcon} from '@sanity/icons/ChevronDown'\nimport {ChevronUpIcon} from '@sanity/icons/ChevronUp'\nimport {DragHandleIcon} from '@sanity/icons/DragHandle'\nimport {AvatarCounter, Card, Box, Button, Flex, Text, Tooltip} from '@sanity/ui'\nimport {useContext} from 'react'\nimport {\n useSchema,\n PreviewCard,\n Preview,\n DocumentStatusIndicator,\n DocumentStatus,\n useDocumentVersionInfo,\n} from 'sanity'\nimport {usePaneRouter} from 'sanity/structure'\n\nimport {OrderableContext} from './OrderableContext'\nimport type {SanityDocumentWithOrder} from './types'\n\nexport interface DocumentProps {\n doc: SanityDocumentWithOrder\n entities: SanityDocumentWithOrder[]\n increment: (\n index: number,\n nextIndex: number,\n docId: string,\n entities: SanityDocumentWithOrder[],\n ) => void\n index: number\n isFirst: boolean\n isLast: boolean\n dragBadge: number | false\n}\n\nexport function Document({\n doc,\n increment,\n entities,\n index,\n isFirst,\n isLast,\n dragBadge,\n}: DocumentProps) {\n const {showIncrements} = useContext(OrderableContext)\n const schema = useSchema()\n const router = usePaneRouter()\n const versionsInfo = useDocumentVersionInfo(doc._id)\n\n const {ChildLink, groupIndex, routerPanesState} = router\n\n const currentDoc = routerPanesState[groupIndex + 1]?.[0]?.id || false\n const pressed = currentDoc === doc._id || currentDoc === doc._id.replace(`drafts.`, ``)\n const selected = pressed && routerPanesState.length === groupIndex + 2\n const schemaType = schema.get(doc._type)\n\n if (!schemaType) {\n return null\n }\n\n const tooltip = (\n <DocumentStatus\n draft={versionsInfo.draft}\n published={versionsInfo.published}\n versions={versionsInfo.versions}\n />\n )\n\n return (\n <PreviewCard\n __unstable_focusRing\n // @ts-expect-error PreviewCard's polymorphic `as` prop does not accept ChildLink's type.\n as={ChildLink}\n data-as=\"a\"\n data-ui=\"PaneItem\"\n radius={2}\n pressed={pressed}\n selected={selected}\n sizing=\"border\"\n tabIndex={-1}\n tone=\"inherit\"\n width=\"100%\"\n flex={1}\n childId={doc._id}\n >\n <Flex align=\"center\">\n <Box paddingX={2} style={{flexShrink: 0}}>\n <Text size={2}>\n <DragHandleIcon cursor=\"grab\" />\n </Text>\n </Box>\n {showIncrements && (\n <Flex style={{flexShrink: 0}} align=\"center\" gap={1} paddingRight={1}>\n <Button\n padding={2}\n mode=\"ghost\"\n onClick={() => increment(index, index - 1, doc._id, entities)}\n disabled={isFirst}\n icon={ChevronUpIcon}\n />\n <Button\n padding={2}\n mode=\"ghost\"\n disabled={isLast}\n onClick={() => increment(index, index + 1, doc._id, entities)}\n icon={ChevronDownIcon}\n />\n </Flex>\n )}\n <Box style={{width: `100%`}}>\n <Flex flex={1} align=\"center\" justify=\"space-between\" paddingRight={3}>\n <Preview layout=\"default\" value={doc} schemaType={schemaType} />\n\n <Tooltip content={tooltip} portal placement=\"right\" boundaryElement={null}>\n <Flex align=\"center\" style={{flexShrink: 0}}>\n <DocumentStatusIndicator\n draft={versionsInfo.draft}\n published={versionsInfo.published}\n versions={versionsInfo.versions}\n />\n </Flex>\n </Tooltip>\n </Flex>\n </Box>\n {dragBadge && (\n <Card tone=\"default\" marginRight={4} radius={5}>\n <AvatarCounter count={dragBadge} />\n </Card>\n )}\n </Flex>\n </PreviewCard>\n )\n}\n","import {type SanityClient, useClient, usePerspective} from 'sanity'\n\nimport {API_VERSION} from './constants'\n\nexport function useSanityClient(): SanityClient {\n const {perspectiveStack} = usePerspective()\n\n return useClient({apiVersion: API_VERSION}).withConfig({perspective: perspectiveStack})\n}\n","import type {DraggableLocation} from '@hello-pangea/dnd'\nimport {LexoRank} from 'lexorank'\nimport type {PatchOperations} from 'sanity'\n\nimport type {SanityDocumentWithOrder} from '../types'\nimport {ORDER_FIELD_NAME} from './constants'\nimport {parseOrderRank} from './parseOrderRank'\n\nexport interface ReorderArgs {\n entities: SanityDocumentWithOrder[]\n selectedIds: string[]\n source: DraggableLocation\n destination: DraggableLocation\n}\n\nexport interface ReorderReturn {\n newOrder: SanityDocumentWithOrder[]\n patches: [string, PatchOperations][]\n message: string\n}\n\nfunction lexicographicalSort(a: SanityDocumentWithOrder, b: SanityDocumentWithOrder) {\n if (!a[ORDER_FIELD_NAME] || !b[ORDER_FIELD_NAME]) {\n return 0\n } else if (a[ORDER_FIELD_NAME] < b[ORDER_FIELD_NAME]) {\n return -1\n } else if (a[ORDER_FIELD_NAME] > b[ORDER_FIELD_NAME]) {\n return 1\n }\n return 0\n}\n\nexport const reorderDocuments = ({\n entities,\n selectedIds,\n source,\n destination,\n}: ReorderArgs): ReorderReturn => {\n const startIndex = source.index\n const endIndex = destination.index\n const isMovingUp = startIndex > endIndex\n const selectedItems = entities.filter((item) => selectedIds.includes(item._id))\n const message = [\n 'Moved',\n selectedItems.length === 1 ? '1 document' : `${selectedItems.length} documents`,\n isMovingUp ? 'up' : 'down',\n 'from position',\n `${startIndex + 1} to ${endIndex + 1}`,\n ].join(' ')\n\n const {all, selected} = entities.reduce<{\n all: SanityDocumentWithOrder[]\n selected: SanityDocumentWithOrder[]\n }>(\n (acc, cur, curIndex) => {\n // Selected items get spread in below, so skip them here\n if (selectedIds.includes(cur._id)) {\n return {all: acc.all, selected: acc.selected}\n }\n\n // Drop selected items in\n if (curIndex === endIndex) {\n const prevIndex = curIndex - 1\n const prevRank = parseOrderRank(entities[prevIndex]?.[ORDER_FIELD_NAME], LexoRank.min())\n const curRank = parseOrderRank(cur[ORDER_FIELD_NAME], LexoRank.min())\n const nextIndex = curIndex + 1\n const nextRank = parseOrderRank(entities[nextIndex]?.[ORDER_FIELD_NAME], LexoRank.max())\n\n let betweenRank = isMovingUp ? prevRank.between(curRank) : curRank.between(nextRank)\n\n // For each selected item, assign a new orderRank between now and next\n for (const selectedItem of selectedItems) {\n selectedItem[ORDER_FIELD_NAME] = betweenRank.toString()\n betweenRank = isMovingUp ? betweenRank.between(curRank) : betweenRank.between(nextRank)\n }\n\n return {\n // The `all` array gets sorted by order field later anyway\n // so that this probably isn't necessary ¯\\_(ツ)_/¯\n all: isMovingUp\n ? [...acc.all, ...selectedItems, cur]\n : [...acc.all, cur, ...selectedItems],\n selected: selectedItems,\n }\n }\n\n return {all: [...acc.all, cur], selected: acc.selected}\n },\n {all: [], selected: []},\n )\n\n const patches = selected.flatMap((doc) => {\n const docPatches: [string, PatchOperations][] = [\n [\n doc._id,\n {\n set: {\n [ORDER_FIELD_NAME]: doc[ORDER_FIELD_NAME],\n },\n },\n ],\n ]\n\n // If it's a draft, we need to patch the published document as well\n if (doc._id.startsWith('drafts.') && doc.hasPublished) {\n docPatches.push([\n doc._id.replace('drafts.', ''),\n {\n set: {\n [ORDER_FIELD_NAME]: doc[ORDER_FIELD_NAME],\n },\n },\n ])\n }\n\n return docPatches\n })\n\n // Safety-check to make sure everything is in order\n const allSorted = all.sort(lexicographicalSort)\n\n return {newOrder: allSorted, patches, message}\n}\n","import {\n DragDropContext,\n Draggable,\n Droppable,\n type DropResult,\n type DraggableLocation,\n} from '@hello-pangea/dnd'\nimport {Box, Card, useToast} from '@sanity/ui'\nimport {useEffect, useState, useMemo, useCallback, type CSSProperties} from 'react'\nimport type {PatchOperations} from 'sanity'\nimport {usePaneRouter} from 'sanity/structure'\n\nimport {Document} from './Document'\nimport {useSanityClient} from './helpers/client'\nimport {ORDER_FIELD_NAME} from './helpers/constants'\nimport {reorderDocuments} from './helpers/reorderDocuments'\nimport type {SanityDocumentWithOrder} from './types'\n\ninterface ListSetting {\n isDuplicate: boolean\n isGhosting: boolean\n isDragging: boolean\n isSelected: boolean\n}\n\ninterface DragResultLike {\n draggableId: string\n source: DraggableLocation\n destination: DraggableLocation | null\n}\n\nexport interface DraggableListProps {\n data: SanityDocumentWithOrder[]\n listIsUpdating: boolean\n setListIsUpdating: (val: boolean) => void\n}\n\nconst getItemStyle = (\n draggableStyle: CSSProperties | undefined,\n itemIsUpdating: boolean,\n): CSSProperties => ({\n userSelect: 'none',\n transition: 'opacity 500ms ease-in-out',\n opacity: itemIsUpdating ? 0.2 : 1,\n pointerEvents: itemIsUpdating ? 'none' : undefined,\n ...draggableStyle,\n})\n\nconst cardTone = (settings: ListSetting) => {\n const {isDuplicate, isGhosting, isDragging, isSelected} = settings\n\n if (isGhosting) return 'transparent'\n if (isDragging || isSelected) return 'primary'\n if (isDuplicate) return 'caution'\n\n return undefined\n}\n\nexport function DraggableList({data, listIsUpdating, setListIsUpdating}: DraggableListProps) {\n const toast = useToast()\n const router = usePaneRouter()\n const {groupIndex, routerPanesState} = router\n\n const currentDoc = routerPanesState[groupIndex + 1]?.[0]?.id || false\n\n // Maintains local state order before transaction completes\n const [orderedData, setOrderedData] = useState<SanityDocumentWithOrder[]>(data)\n const displayedData = listIsUpdating ? orderedData : data\n\n const [draggingId, setDraggingId] = useState('')\n const [selectedIds, setSelectedIds] = useState<string[]>(currentDoc ? [currentDoc] : [])\n\n const clearSelected = useCallback(() => setSelectedIds([]), [setSelectedIds])\n\n const handleSelect = useCallback(\n (clickedId: string, index: number, nativeEvent: MouseEvent) => {\n const isSelected = selectedIds.includes(clickedId)\n const selectMultiple = nativeEvent.shiftKey\n const isUsingWindows = navigator.appVersion.indexOf('Win') !== -1\n const selectAdditional = isUsingWindows ? nativeEvent.ctrlKey : nativeEvent.metaKey\n\n let updatedIds: string[] = []\n\n // No modifier keys pressed during click:\n // - update selected to just this one\n // - open document\n if (!selectMultiple && !selectAdditional) {\n return setSelectedIds([clickedId])\n }\n\n // If shift key was held, prevent default to avoid new window opening\n if (selectMultiple) {\n nativeEvent.preventDefault()\n }\n\n // Shift key was held, add id's between last selected and this one\n // ...before adding this one\n if (selectMultiple && !isSelected) {\n const lastSelectedId = selectedIds[selectedIds.length - 1] ?? clickedId\n const lastSelectedIndex = displayedData.findIndex((item) => item._id === lastSelectedId)\n\n const firstSelected = index < lastSelectedIndex ? index : lastSelectedIndex\n const lastSelected = index > lastSelectedIndex ? index : lastSelectedIndex\n\n const betweenIds = displayedData\n .filter((_, itemIndex) => itemIndex > firstSelected && itemIndex < lastSelected)\n .map((item) => item._id)\n\n updatedIds = [...selectedIds, ...betweenIds, clickedId]\n } else if (isSelected) {\n // Toggle off a single id\n updatedIds = selectedIds.filter((id) => id !== clickedId)\n } else {\n // Toggle on a single id\n updatedIds = [...selectedIds, clickedId]\n }\n\n return setSelectedIds(updatedIds)\n },\n [displayedData, selectedIds],\n )\n\n const client = useSanityClient()\n\n const transactPatches = useCallback(\n async (patches: [string, PatchOperations][], message: string) => {\n const transaction = client.transaction()\n\n patches.forEach(([docId, ops]) => {\n transaction.patch(docId, ops)\n })\n\n try {\n const updated = await transaction.commit({\n visibility: 'sync',\n tag: 'orderable-document-list.reorder',\n })\n clearSelected()\n setDraggingId('')\n setListIsUpdating(false)\n toast.push({\n title: `${\n updated.results.length === 1 ? '1 document' : `${updated.results.length} documents`\n } reordered`,\n status: 'success',\n description: message,\n })\n } catch {\n setDraggingId('')\n setListIsUpdating(false)\n toast.push({\n title: 'Reordering failed',\n status: 'error',\n })\n }\n },\n [client, clearSelected, setListIsUpdating, toast],\n )\n\n const handleDragEnd = useCallback(\n (result: DragResultLike | undefined, entities: SanityDocumentWithOrder[]) => {\n setDraggingId('')\n\n const {source, destination, draggableId} = result ?? {}\n\n // Don't do anything if nothing changed\n if (source?.index === destination?.index) return\n\n // Don't do anything if we don't have the entitites\n if (!entities.length || !draggableId || !source || !destination) return\n\n // A document can be dragged without being one-of-many-selected\n const effectedIds = selectedIds.length > 0 ? selectedIds : [draggableId]\n\n // Don't do anything if we don't have ids to effect\n if (effectedIds.length === 0) return\n\n // Update state to update styles + prevent data refetching\n setListIsUpdating(true)\n setSelectedIds(effectedIds)\n\n const {newOrder, patches, message} = reorderDocuments({\n entities,\n selectedIds: effectedIds,\n source,\n destination,\n })\n\n // Update local state\n if (newOrder.length > 0) {\n setOrderedData(newOrder)\n }\n\n // Transact new order patches\n if (patches.length > 0) {\n void transactPatches(patches, message)\n }\n },\n [selectedIds, transactPatches, setListIsUpdating],\n )\n\n const handleDragStart = useCallback(\n (start: {draggableId: string}) => {\n const id = start.draggableId\n const selected = selectedIds.includes(id)\n\n // if dragging an item that is not selected - unselect all items\n if (!selected) clearSelected()\n\n setDraggingId(id)\n },\n [selectedIds, clearSelected],\n )\n\n // Move one document up or down one place, by fake invoking the drag function\n const incrementIndex = useCallback(\n (shiftFrom: number, shiftTo: number, id: string, entities: SanityDocumentWithOrder[]) => {\n const result: DragResultLike = {\n draggableId: id,\n source: {droppableId: 'documentSortZone', index: shiftFrom},\n destination: {droppableId: 'documentSortZone', index: shiftTo},\n }\n\n return handleDragEnd(result, entities)\n },\n [handleDragEnd],\n )\n\n const onWindowKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n clearSelected()\n }\n },\n [clearSelected],\n )\n\n useEffect(() => {\n window.addEventListener('keydown', onWindowKeyDown)\n\n return () => {\n window.removeEventListener('keydown', onWindowKeyDown)\n }\n }, [onWindowKeyDown])\n\n // Find all items with duplicate order field\n const duplicateOrders = useMemo(() => {\n if (displayedData.length === 0) return []\n\n const orderField = displayedData.map((item) => item[ORDER_FIELD_NAME])\n\n return orderField.filter((item, index) => orderField.indexOf(item) !== index)\n }, [displayedData])\n\n const onDragEnd = useCallback(\n (result: DropResult) => handleDragEnd(result, displayedData),\n [displayedData, handleDragEnd],\n )\n\n return (\n <DragDropContext onDragStart={handleDragStart} onDragEnd={onDragEnd}>\n <Droppable droppableId=\"documentSortZone\">\n {(provided) => (\n <div {...provided.droppableProps} ref={provided.innerRef}>\n {displayedData.map((item, index) => (\n <Draggable\n key={`${item._id}-${item[ORDER_FIELD_NAME]}`}\n draggableId={item._id}\n index={index}\n >\n {(innerProvided, innerSnapshot) => {\n const isSelected = selectedIds.includes(item._id)\n const isDragging = innerSnapshot.isDragging\n const isGhosting = Boolean(!isDragging && draggingId && isSelected)\n const isUpdating = listIsUpdating && isSelected\n const isDisabled = !item[ORDER_FIELD_NAME]\n const isDuplicate = duplicateOrders.includes(item[ORDER_FIELD_NAME])\n const tone = cardTone({isDuplicate, isGhosting, isDragging, isSelected})\n const selectedCount = selectedIds.length\n\n const dragBadge = isDragging && selectedCount > 1 ? selectedCount : false\n\n return (\n <div\n ref={innerProvided.innerRef}\n {...innerProvided.draggableProps}\n {...innerProvided.dragHandleProps}\n style={\n isDisabled\n ? {opacity: 0.2, pointerEvents: 'none'}\n : getItemStyle(innerProvided.draggableProps.style, isUpdating)\n }\n >\n <Box paddingBottom={1}>\n <Card\n tone={tone}\n shadow={isDragging ? 2 : undefined}\n radius={2}\n onClick={(e) => handleSelect(item._id, index, e.nativeEvent)}\n >\n <Document\n doc={item}\n entities={displayedData}\n increment={incrementIndex}\n index={index}\n isFirst={index === 0}\n isLast={index === displayedData.length - 1}\n dragBadge={dragBadge}\n />\n </Card>\n </Box>\n </div>\n )\n }}\n </Draggable>\n ))}\n {provided.placeholder}\n </div>\n )}\n </Droppable>\n </DragDropContext>\n )\n}\n","import {getPublishedId, getVersionFromId, isDraftId, isPublishedId, isVersionId} from 'sanity'\n\nimport type {SanityDocumentWithOrder} from '../types'\n\nconst isVersionForCurrentPerspective = (\n document: SanityDocumentWithOrder,\n perspectiveName: string,\n publishedId: string,\n) => {\n return (\n document._id &&\n isVersionId(document._id) &&\n getVersionFromId(document._id) === perspectiveName &&\n getPublishedId(document._id) === publishedId\n )\n}\n\n// this removes dedupped docs from the list and makes sure that it keeps the right docs\n// in the list while preserving the order established by the orderRank field\nexport const getFilteredDedupedDocs = (\n documents: SanityDocumentWithOrder[],\n perspectiveName?: string,\n): SanityDocumentWithOrder[] => {\n // Flatten the documents array in case it's nested (like in test data)\n const flatDocuments = documents.flat()\n const dedupedDocuments: SanityDocumentWithOrder[] = []\n\n for (const cur of flatDocuments) {\n if (!cur._id) {\n continue\n }\n\n // Handle version-only documents\n if (isVersionId(cur._id)) {\n const versionFromId = getVersionFromId(cur._id)\n const isCorrectVersion = versionFromId === perspectiveName\n\n // Only include versions that match the current perspective\n if (\n perspectiveName &&\n perspectiveName !== 'drafts' &&\n perspectiveName !== 'published' &&\n isCorrectVersion\n ) {\n dedupedDocuments.push(cur)\n }\n continue\n }\n\n // Handle published perspective - only include published documents\n if (perspectiveName === 'published') {\n if (isPublishedId(cur._id)) {\n dedupedDocuments.push(cur)\n }\n continue\n }\n\n // in situations where the document is not a draft, we need to check if\n // the version should override a published document or a draft\n if (!isDraftId(cur._id)) {\n const publishedId = getPublishedId(cur._id)\n\n // Check if there's a version that matches the perspectiveName\n const hasMatchingVersion =\n perspectiveName && perspectiveName !== 'drafts' && perspectiveName !== 'published'\n ? flatDocuments.some((doc) =>\n isVersionForCurrentPerspective(doc, perspectiveName, publishedId),\n )\n : false\n\n // Check if there's a draft\n const hasDraft = flatDocuments.some((doc) => doc._id === `drafts.${cur._id}`)\n const hasDuplicatePublished = flatDocuments.some((doc) => doc !== cur && doc._id === cur._id)\n\n // Priority: version > draft > published\n // If there's a matching version, skip published\n if (!hasMatchingVersion && !hasDraft && !hasDuplicatePublished) {\n dedupedDocuments.push(cur)\n }\n continue\n }\n\n // For drafts, check if there's a version for this document in version perspective\n if (perspectiveName && perspectiveName !== 'drafts' && perspectiveName !== 'published') {\n const baseId = getPublishedId(cur._id)\n const hasVersion = flatDocuments.some((doc) =>\n isVersionForCurrentPerspective(doc, perspectiveName, baseId),\n )\n\n // If there's a version for this document, skip the draft\n if (hasVersion) {\n continue\n }\n }\n\n // Check if the draft has a published version\n cur.hasPublished = flatDocuments.some((doc) => doc._id === cur._id.replace(`drafts.`, ``))\n\n dedupedDocuments.push(cur)\n }\n\n return dedupedDocuments\n}\n","import {ORDER_FIELD_NAME} from './constants'\n\nexport interface DocumentListQueryProps {\n type: string\n filter?: string\n params?: Record<string, unknown>\n currentVersion?: string\n}\n\nexport interface DocumentListQueryResult {\n query: string\n queryParams: Record<string, string | number | boolean | string[]>\n}\n\nconst DEFAULT_PARAMS = {}\n\nexport function getDocumentQuery({\n type,\n filter,\n params = DEFAULT_PARAMS,\n currentVersion,\n}: DocumentListQueryProps): DocumentListQueryResult {\n let perspectiveFilter = null\n if (currentVersion === 'published') {\n perspectiveFilter = '!(_id in path(\"drafts.**\")) && !(_id in path(\"versions.**\"))'\n } else if (currentVersion === 'drafts') {\n // Show drafts, and published when no draft exists\n perspectiveFilter = `\n (_id in path(\"drafts.**\") || (!(_id in path(\"drafts.**\")) && !(_id in path(\"versions.**\"))))\n `\n } else {\n // Default behavior: prioritize drafts over published when both exist\n // the priority should be a version\n perspectiveFilter = `(sanity::partOfRelease($currentVersion) || (!(_id in path(\"drafts.**\")) && !(_id in path(\"versions.**\"))) || (_id in path(\"drafts.**\")))`\n }\n\n const querySelect = `*[_type == $type ${perspectiveFilter ? `&& ${perspectiveFilter}` : ''}${filter ? `&& ${filter}` : ''}]`\n const queryOrder = `|order(@[$order] asc)`\n const queryFields = `{_id, _type, ${ORDER_FIELD_NAME}}`\n\n const query = `${querySelect}${queryOrder}${queryFields}`\n const queryParams = {\n ...params,\n type,\n order: ORDER_FIELD_NAME,\n ...(currentVersion && {currentVersion}),\n }\n\n return {query, queryParams}\n}\n","import {Box, Flex, Container, Spinner, Stack, Text} from '@sanity/ui'\nimport {useMemo, useState} from 'react'\nimport {useListeningQuery, Feedback} from 'sanity-plugin-utils'\n\nimport {DraggableList} from './DraggableList'\nimport {ORDER_FIELD_NAME} from './helpers/constants'\nimport {getFilteredDedupedDocs} from './helpers/getFilteredDedupedDocs'\nimport {getDocumentQuery, type DocumentListQueryProps} from './helpers/query'\nimport type {SanityDocumentWithOrder} from './types'\n\nexport function DocumentListQuery(props: DocumentListQueryProps) {\n const [listIsUpdating, setListIsUpdating] = useState(false)\n\n const {query, queryParams} = getDocumentQuery(props)\n\n const {\n data: _queryData,\n loading,\n error,\n } = useListeningQuery<SanityDocumentWithOrder[]>(query, {\n params: queryParams,\n initialValue: [],\n })\n\n const queryData = useMemo(() => (Array.isArray(_queryData) ? _queryData : []), [_queryData])\n\n const data = useMemo(\n () => getFilteredDedupedDocs(queryData, props.currentVersion),\n [props.currentVersion, queryData],\n )\n\n const unorderedDataCount = useMemo(\n () => data.filter((doc) => !doc[ORDER_FIELD_NAME]).length,\n [data],\n )\n\n if (loading) {\n return (\n <Flex style={{width: `100%`, height: `100%`}} align=\"center\" justify=\"center\">\n <Spinner />\n </Flex>\n )\n }\n\n if (error) {\n return (\n <Box padding={2}>\n <Feedback tone=\"critical\" title=\"There was an error\" description=\"Please try again later\" />\n </Box>\n )\n }\n\n if (data.length === 0) {\n return (\n <Flex align=\"center\" direction=\"column\" height=\"fill\" justify=\"center\">\n <Container width={1}>\n <Box paddingX={4} paddingY={5}>\n <Text align=\"center\" muted>\n No documents of this type\n </Text>\n </Box>\n </Container>\n </Flex>\n )\n }\n\n return (\n <Stack gap={1} style={{overflow: `auto`, height: `100%`}}>\n <Box padding={2}>\n {unorderedDataCount > 0 && (\n <Box marginBottom={2}>\n <Feedback\n tone=\"caution\"\n description={\n <>\n {unorderedDataCount}/{data.length} documents have no order. Select{' '}\n <strong>Reset Order</strong> from the menu above to fix.\n </>\n }\n />\n </Box>\n )}\n <DraggableList\n data={data}\n listIsUpdating={listIsUpdating}\n setListIsUpdating={setListIsUpdating}\n />\n </Box>\n </Stack>\n )\n}\n","import {useToast, Box, type ToastParams} from '@sanity/ui'\nimport {useEffect, useMemo} from 'react'\nimport {useSchema} from 'sanity'\nimport {Feedback} from 'sanity-plugin-utils'\n\nimport {DocumentListQuery} from './DocumentListQuery'\nimport {ORDER_FIELD_NAME} from './helpers/constants'\nimport {OrderableContext} from './OrderableContext'\n\nexport interface DocumentListWrapperProps {\n showIncrements: boolean\n type: string\n resetOrderTransaction: ToastParams\n filter?: string\n params?: Record<string, unknown>\n currentVersion?: string\n}\n\n// 1. Validate first that the schema has been configured for ordering\n// 2. Setup context for showIncrements\nexport function DocumentListWrapper({\n type,\n showIncrements,\n resetOrderTransaction,\n filter,\n params,\n currentVersion,\n}: DocumentListWrapperProps) {\n const toast = useToast()\n const schema = useSchema()\n const orderableContextValue = useMemo(() => ({showIncrements}), [showIncrements])\n\n useEffect(() => {\n if (resetOrderTransaction?.title && resetOrderTransaction?.status) {\n toast.push(resetOrderTransaction)\n }\n }, [resetOrderTransaction, toast])\n\n const schemaIsInvalid = useMemo(() => {\n // Option not passed\n if (!type) {\n return (\n <>\n No <code>type</code> was configured\n </>\n )\n }\n\n const typeSchema = schema.get(type)\n\n // Schema not found\n if (!typeSchema) {\n return (\n <>\n Schema <code>{type}</code> not found\n </>\n )\n }\n\n // Schema lacks an order field\n if (\n !('fields' in typeSchema) ||\n !typeSchema.fields.some((field) => field?.name === ORDER_FIELD_NAME)\n ) {\n return (\n <>\n Schema <code>{type}</code> must have an <code>{ORDER_FIELD_NAME}</code> field of type{' '}\n <code>string</code>\n </>\n )\n }\n\n // Schema's order field is not a string\n if (\n 'fields' in typeSchema &&\n typeSchema.fields.some(\n (field) => field?.name === ORDER_FIELD_NAME && field?.type?.name !== 'string',\n )\n ) {\n return (\n <>\n <code>{ORDER_FIELD_NAME}</code> field on Schema <code>{type}</code> must be{' '}\n <code>string</code> type\n </>\n )\n }\n\n return ''\n }, [type, schema])\n\n if (schemaIsInvalid) {\n return (\n <Box padding={2}>\n <Feedback description={schemaIsInvalid} tone=\"caution\" />\n </Box>\n )\n }\n\n return (\n <OrderableContext.Provider value={orderableContextValue}>\n <DocumentListQuery\n type={type}\n filter={filter}\n params={params}\n currentVersion={currentVersion}\n />\n </OrderableContext.Provider>\n )\n}\n","import type {MultipleMutationResult, SanityClient} from '@sanity/client'\nimport {LexoRank} from 'lexorank'\n\nimport {ORDER_FIELD_NAME} from './constants'\nimport {getDocumentQuery, type DocumentListQueryProps} from './query'\n\nexport interface ResetOrderParams extends DocumentListQueryProps {\n client: SanityClient\n currentVersion?: string\n}\n\n// Function to wipe and re-do ordering with LexoRank\n// Will at least attempt to start with the current order\nexport async function resetOrder(params: ResetOrderParams): Promise<MultipleMutationResult | null> {\n const {client, currentVersion, ...queryProps} = params\n const {query, queryParams} = getDocumentQuery({...queryProps, currentVersion})\n\n const documents = await client.fetch<\n Array<{\n _id: string\n _type: string\n [ORDER_FIELD_NAME]: string\n }>\n >(query, queryParams, {\n tag: 'orderable-document-list.reset-order',\n })\n\n if (documents.length === 0) {\n return null\n }\n\n let aLexoRank = LexoRank.min()\n\n const transaction = documents\n .map((doc) => doc._id)\n .reduce((trx, documentId) => {\n // Generate next rank before even the first document so there's room to move!\n aLexoRank = aLexoRank.genNext().genNext()\n\n return trx.patch(documentId, {\n set: {[ORDER_FIELD_NAME]: aLexoRank.toString()},\n })\n }, client.transaction())\n\n return transaction.commit({\n visibility: 'async',\n tag: 'orderable-document-list.reset-order',\n })\n}\n","import type {SanityClient} from '@sanity/client'\nimport type {ToastParams} from '@sanity/ui'\nimport {Component} from 'react'\n\nimport {DocumentListWrapper} from './DocumentListWrapper'\nimport {resetOrder} from './helpers/resetOrder'\n\nexport interface OrderableDocumentListProps {\n options: {\n type: string\n client: SanityClient\n filter?: string\n params?: Record<string, unknown>\n currentVersion?: string\n }\n}\n\ninterface State {\n showIncrements: boolean\n resetOrderTransaction: ToastParams\n}\n\n// Must use a Class Component here so the actionHandlers can be called\nexport class OrderableDocumentList extends Component<OrderableDocumentListProps, State> {\n constructor(props: OrderableDocumentListProps) {\n super(props)\n this.state = {\n showIncrements: false,\n resetOrderTransaction: {},\n }\n }\n\n actionHandlers = {\n showIncrements: () => {\n this.setState((state) => ({\n showIncrements: !state.showIncrements,\n }))\n },\n\n resetOrder: async () => {\n this.setState(() => ({\n resetOrderTransaction: {\n status: `info`,\n title: `Reordering started...`,\n closable: true,\n },\n }))\n\n const update = await resetOrder(this.props.options)\n\n const reorderWasSuccessful = update?.results?.length\n\n this.setState(() => ({\n resetOrderTransaction: {\n status: reorderWasSuccessful ? `success` : `info`,\n title: reorderWasSuccessful\n ? `Reordered ${update.results.length === 1 ? `Document` : `Documents`}`\n : `Reordering failed`,\n closable: true,\n },\n }))\n },\n }\n\n override render() {\n const {options} = this.props\n const {type, filter, params, currentVersion} = options\n\n if (!type) {\n return null\n }\n\n return (\n <DocumentListWrapper\n filter={filter}\n params={params}\n type={type}\n showIncrements={this.state.showIncrements}\n resetOrderTransaction={this.state.resetOrderTransaction}\n currentVersion={currentVersion}\n />\n )\n }\n}\n","import {GenerateIcon} from '@sanity/icons/Generate'\nimport {SortIcon} from '@sanity/icons/Sort'\nimport {type ComponentType} from 'react'\nimport type {ConfigContext} from 'sanity'\nimport {type ListItem, type MenuItem, type StructureBuilder} from 'sanity/structure'\n\nimport {API_VERSION} from '../helpers/constants'\nimport {OrderableDocumentList} from '../OrderableDocumentList'\n\nexport interface OrderableListConfig {\n type: string\n id?: string\n title?: string\n icon?: ComponentType\n params?: Record<string, unknown>\n filter?: string\n menuItems?: MenuItem[]\n createIntent?: boolean\n context: ConfigContext\n S: StructureBuilder\n}\n\nexport function orderableDocumentListDeskItem(config: OrderableListConfig): ListItem {\n if (!config?.type || !config.context || !config.S) {\n throw new Error(`\n type, context and S (StructureBuilder) must be provided.\n context and S are available when configuring structure.\n Example: orderableDocumentListDeskItem({type: 'category'})\n `)\n }\n\n const {type, filter, menuItems = [], createIntent, params, title, icon, id, context, S} = config\n const {schema, getClient} = context\n const maybePerspectiveStack: unknown = Reflect.get(context, 'perspectiveStack')\n const perspectiveStack =\n Array.isArray(maybePerspectiveStack) &&\n maybePerspectiveStack.every((item): item is string => typeof item === 'string')\n ? maybePerspectiveStack\n : []\n const client = getClient({apiVersion: API_VERSION})\n // the first position in the perspective stack is the current version\n const currentVersion = perspectiveStack[0]\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 const defaultMenuItems = [...menuItems]\n\n if (createIntent !== false) {\n defaultMenuItems.push(\n S.menuItem()\n .title(`Create new ${typeTitle}`)\n .intent({type: 'create', params: {type}})\n .serialize(),\n )\n }\n\n return S.listItem()\n .title(listTitle)\n .id(listId)\n .icon(listIcon)\n .schemaType(type)\n .child(\n Object.assign(\n S.documentTypeList(type)\n .canHandleIntent(\n (_intentName, params) => createIntent !== false && params?.['type'] === type,\n )\n .serialize(),\n {\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, client, currentVersion},\n menuItems: [\n ...defaultMenuItems,\n S.menuItem().title(`Reset Order`).icon(GenerateIcon).action(`resetOrder`).serialize(),\n S.menuItem()\n .title(`Toggle Increments`)\n .icon(SortIcon)\n .action(`showIncrements`)\n .serialize(),\n ],\n },\n ),\n )\n .serialize()\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,MAAaA,mBAAmB,aAGnBE,cAAc;ACA3B,SAAgBE,eAAeC,OAAgBC,UAA8B;CAC3E,IAAI,OAAOD,SAAU,UAEnB,OADAE,QAAQC,KAAK,wEAAwEH,KAAK,GACnFC;CAGT,IAAI;EACF,OAAOH,SAASM,MAAMJ,KAAK;CAC7B,SAASK,KAAK;EAOZ,OANAH,QAAQC,KACN,8DACAH,OACA,UACAK,eAAeC,QAAQD,IAAIE,UAAUC,OAAOH,GAAG,CACjD,GACOJ;CACT;AACF;ACbA,SAAgBW,YACdC,mBAA4B,IAC5BC,kBAAmC,SACnC;CACA,IAAMC,cAAcJ,eAAeE,kBAAkBJ,SAASO,IAAI,CAAC;CAInE,QAFEF,oBAAoB,WAAWC,YAAYG,QAAQ,CAAC,CAACA,QAAQ,IAAIH,YAAYI,QAAQ,CAAC,CAACA,QAAQ,EAAA,CAErFC,SAAS;AACvB;ACHA,MAAaa,kBAAkBC,WAAuD;CACpF,IAAI,CAACA,QAAQH,MACX,MAAUI,MACR,2FAIF;CAGF,IAAM,EAACJ,MAAMC,kBAAkB,SAAS,GAAGI,SAAQF;CACnD,OAAOb,YAAY;EACjBgB,O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MAAM;EAAUI,QAAQ,EAACJ,KAAI;CAAC,CAAC,CAAC,CACxCmC,UAAU,CACf,GAGKzB,EAAE0B,SAAS,CAAC,CAChBlC,MAAMyB,SAAS,CAAC,CAChB1B,GAAG2B,MAAM,CAAC,CACVzB,KAAK0B,QAAQ,CAAC,CACdQ,WAAWrC,IAAI,CAAC,CAChBsC,MACCC,OAAOC,OACL9B,EAAE+B,iBAAiBzC,IAAI,CAAC,CACrB0C,iBACEC,aAAavC,WAAWI,iBAAiB,MAASJ,QAAS,SAAYJ,IAC1E,CAAC,CACAmC,UAAU,GACb;EAEES,oBAAoB;EAEpBC,KAAKjB;EAEL5B,MAAM;EACN8C,WAAWhD;EACXiD,SAAS;GAAC/C;GAAMM;GAAQF;GAAQoB;GAAQE;EAAc;EACtDnB,WAAW;GACT,GAAGwB;GACHrB,EAAEuB,SAAS,CAAC,CAAC/B,MAAM,aAAa,CAAC,CAACC,KAAKb,YAAY,CAAC,CAAC0D,OAAO,YAAY,CAAC,CAACb,UAAU;GACpFzB,EAAEuB,SAAS,CAAC,CACT/B,MAAM,mBAAmB,CAAC,CAC1BC,KAAKZ,QAAQ,CAAC,CACdyD,OAAO,gBAAgB,CAAC,CACxBb,UAAU;EAAC;CAElB,CACF,CACF,CAAC,CACAA,UAAU;AACf"}
\ No newline at end of file
+{"version":3,"file":"index.js","names":["ORDER_FIELD_NAME","const","API_VERSION","LexoRank","parseOrderRank","value","fallback","console","warn","parse","err","Error","message","String","LexoRank","NewItemPosition","parseOrderRank","initialRank","compareRankValue","newItemPosition","compareRank","min","rank","genPrev","genNext","toString","defineField","FieldDefinition","StringDefinition","API_VERSION","ORDER_FIELD_NAME","initialRank","NewItemPosition","RankFieldConfig","Partial","Omit","type","newItemPosition","orderRankField","config","Error","rest","title","readOnly","hidden","name","initialValue","value","getClient","direction","lastDocOrderRank","apiVersion","fetch","order","tag","createContext","OrderableContextValue","showIncrements","OrderableContext","ChevronDownIcon","ChevronUpIcon","DragHandleIcon","AvatarCounter","Card","Box","Button","Flex","Text","Tooltip","useContext","useSchema","PreviewCard","Preview","DocumentStatusIndicator","DocumentStatus","useDocumentVersionInfo","usePaneRouter","OrderableContext","SanityDocumentWithOrder","DocumentProps","doc","entities","increment","index","nextIndex","docId","isFirst","isLast","dragBadge","Document","t0","$","_c","showIncrements","schema","router","versionsInfo","_id","ChildLink","groupIndex","routerPanesState","currentDoc","id","t1","replace","pressed","selected","length","t2","_type","get","schemaType","t3","draft","published","versions","tooltip","t4","Symbol","for","flexShrink","t5","t6","t7","width","t8","t9","t10","t11","t12","t13","t14","t15","SanityClient","useClient","usePerspective","API_VERSION","useSanityClient","$","_c","perspectiveStack","t0","Symbol","for","apiVersion","t1","t2","withConfig","perspective","DraggableLocation","LexoRank","PatchOperations","SanityDocumentWithOrder","ORDER_FIELD_NAME","parseOrderRank","ReorderArgs","entities","selectedIds","source","destination","ReorderReturn","newOrder","patches","message","lexicographicalSort","a","b","reorderDocuments","startIndex","index","endIndex","isMovingUp","selectedItems","filter","item","includes","_id","length","join","all","selected","reduce","acc","cur","curIndex","prevIndex","prevRank","min","curRank","nextIndex","nextRank","max","betweenRank","between","selectedItem","toString","flatMap","doc","docPatches","set","startsWith","hasPublished","push","replace","allSorted","sort","DragDropContext","Draggable","Droppable","DropResult","DraggableLocation","Box","Card","useToast","useEffect","useState","useMemo","useCallback","CSSProperties","PatchOperations","usePaneRouter","Document","useSanityClient","ORDER_FIELD_NAME","reorderDocuments","SanityDocumentWithOrder","ListSetting","isDuplicate","isGhosting","isDragging","isSelected","DragResultLike","draggableId","source","destination","DraggableListProps","data","listIsUpdating","setListIsUpdating","val","getItemStyle","draggableStyle","itemIsUpdating","userSelect","transition","opacity","pointerEvents","undefined","cardTone","settings","DraggableList","toast","router","groupIndex","routerPanesState","currentDoc","id","orderedData","setOrderedData","displayedData","draggingId","setDraggingId","selectedIds","setSelectedIds","clearSelected","handleSelect","clickedId","index","nativeEvent","MouseEvent","includes","selectMultiple","shiftKey","isUsingWindows","navigator","appVersion","indexOf","selectAdditional","ctrlKey","metaKey","updatedIds","preventDefault","lastSelectedId","length","lastSelectedIndex","findIndex","item","_id","firstSelected","lastSelected","betweenIds","filter","_","itemIndex","map","client","transactPatches","patches","message","transaction","forEach","docId","ops","patch","updated","commit","visibility","tag","push","title","results","status","description","handleDragEnd","result","entities","effectedIds","newOrder","handleDragStart","start","selected","incrementIndex","shiftFrom","shiftTo","droppableId","onWindowKeyDown","event","KeyboardEvent","key","window","addEventListener","removeEventListener","duplicateOrders","orderField","onDragEnd","provided","droppableProps","innerRef","innerProvided","innerSnapshot","Boolean","isUpdating","isDisabled","tone","selectedCount","dragBadge","draggableProps","dragHandleProps","style","e","placeholder","getPublishedId","getVersionFromId","isDraftId","isPublishedId","isVersionId","SanityDocumentWithOrder","isVersionForCurrentPerspective","document","perspectiveName","publishedId","_id","getFilteredDedupedDocs","documents","flatDocuments","flat","dedupedDocuments","cur","versionFromId","isCorrectVersion","push","hasMatchingVersion","some","doc","hasDraft","hasDuplicatePublished","baseId","hasVersion","hasPublished","replace","ORDER_FIELD_NAME","DocumentListQueryProps","type","filter","params","Record","currentVersion","DocumentListQueryResult","query","queryParams","DEFAULT_PARAMS","getDocumentQuery","perspectiveFilter","querySelect","queryOrder","queryFields","order","Box","Flex","Container","Spinner","Stack","Text","useMemo","useState","useListeningQuery","Feedback","DraggableList","ORDER_FIELD_NAME","getFilteredDedupedDocs","getDocumentQuery","DocumentListQueryProps","SanityDocumentWithOrder","DocumentListQuery","props","$","_c","listIsUpdating","setListIsUpdating","t0","query","queryParams","t1","Symbol","for","t2","params","initialValue","data","_queryData","loading","error","t3","Array","isArray","queryData","t4","currentVersion","t5","filter","_temp","unorderedDataCount","length","t6","width","height","t7","overflow","t8","t9","doc","useToast","Box","ToastParams","useEffect","useMemo","useSchema","Feedback","DocumentListQuery","ORDER_FIELD_NAME","OrderableContext","DocumentListWrapperProps","showIncrements","type","resetOrderTransaction","filter","params","Record","currentVersion","DocumentListWrapper","t0","$","_c","toast","schema","t1","orderableContextValue","t2","t3","title","status","push","t4","bb0","t5","Symbol","for","typeSchema","get","fields","some","_temp","t6","t7","t8","_temp2","schemaIsInvalid","field_0","field","name","MultipleMutationResult","SanityClient","LexoRank","ORDER_FIELD_NAME","getDocumentQuery","DocumentListQueryProps","ResetOrderParams","client","currentVersion","resetOrder","params","Promise","queryProps","query","queryParams","documents","fetch","Array","_id","_type","tag","length","aLexoRank","min","transaction","map","doc","reduce","trx","documentId","genNext","patch","set","toString","commit","visibility","SanityClient","ToastParams","Component","DocumentListWrapper","resetOrder","OrderableDocumentListProps","options","type","client","filter","params","Record","currentVersion","State","showIncrements","resetOrderTransaction","OrderableDocumentList","constructor","props","state","actionHandlers","setState","status","title","closable","update","reorderWasSuccessful","results","length","render","GenerateIcon","SortIcon","ComponentType","ConfigContext","ListItem","MenuItem","StructureBuilder","API_VERSION","OrderableDocumentList","OrderableListConfig","type","id","title","icon","params","Record","filter","menuItems","createIntent","context","S","orderableDocumentListDeskItem","config","Error","schema","getClient","maybePerspectiveStack","Reflect","get","perspectiveStack","Array","isArray","every","item","client","apiVersion","currentVersion","listTitle","listId","listIcon","typeTitle","defaultMenuItems","push","menuItem","intent","serialize","listItem","schemaType","child","Object","assign","documentTypeList","canHandleIntent","_intentName","__preserveInstance","key","component","options","action"],"sources":["../src/helpers/constants.ts","../src/helpers/parseOrderRank.ts","../src/helpers/initialRank.ts","../src/fields/orderRankField.ts","../src/fields/orderRankOrdering.ts","../src/OrderableContext.ts","../src/Document.tsx","../src/helpers/client.ts","../src/helpers/reorderDocuments.ts","../src/DraggableList.tsx","../src/helpers/getFilteredDedupedDocs.ts","../src/helpers/query.ts","../src/DocumentListQuery.tsx","../src/DocumentListWrapper.tsx","../src/helpers/resetOrder.ts","../src/OrderableDocumentList.tsx","../src/desk-structure/orderableDocumentListDeskItem.ts"],"sourcesContent":["export const ORDER_FIELD_NAME = `orderRank` as const\n\n// same version we are using in the vision plugin\nexport const API_VERSION = `v2025-06-27` as const\n","import {LexoRank} from 'lexorank'\n\n// Safely parse a LexoRank string; fall back if invalid\nexport function parseOrderRank(value: unknown, fallback: LexoRank): LexoRank {\n if (typeof value !== 'string') {\n console.warn('[orderable-document-list] Invalid orderRank value (expected string):', value)\n return fallback\n }\n\n try {\n return LexoRank.parse(value)\n } catch (err) {\n console.warn(\n '[orderable-document-list] Failed to parse orderRank value:',\n value,\n 'Error:',\n err instanceof Error ? err.message : String(err),\n )\n return fallback\n }\n}\n","import {LexoRank} from 'lexorank'\n\nimport type {NewItemPosition} from '../types'\nimport {parseOrderRank} from './parseOrderRank'\n\n// Use in initial value field by passing in the rank value of the last document\n// If not value passed, generate a sensibly low rank\nexport function initialRank(\n compareRankValue: unknown = ``,\n newItemPosition: NewItemPosition = 'after',\n) {\n const compareRank = parseOrderRank(compareRankValue, LexoRank.min())\n const rank =\n newItemPosition === 'before' ? compareRank.genPrev().genPrev() : compareRank.genNext().genNext()\n\n return rank.toString()\n}\n","import {defineField, type FieldDefinition, type StringDefinition} from 'sanity'\n\nimport {API_VERSION, ORDER_FIELD_NAME} from '../helpers/constants'\nimport {initialRank} from '../helpers/initialRank'\nimport type {NewItemPosition} from '../types'\n\nexport interface RankFieldConfig extends Partial<\n Omit<StringDefinition, 'name' | 'type' | 'initialValue'>\n> {\n type: string\n newItemPosition?: NewItemPosition\n}\n\nexport const orderRankField = (config: RankFieldConfig): FieldDefinition<'string'> => {\n if (!config?.type) {\n throw new Error(\n `\n type must be provided.\n Example: orderRankField({type: 'category'})\n `,\n )\n }\n\n const {type, newItemPosition = 'after', ...rest} = config\n return defineField({\n title: 'Order Rank',\n readOnly: true,\n hidden: true,\n ...rest,\n name: ORDER_FIELD_NAME,\n type: 'string',\n initialValue: async (value, {getClient}) => {\n void value\n const direction = newItemPosition === 'before' ? 'asc' : 'desc'\n\n const lastDocOrderRank = await getClient({apiVersion: API_VERSION}).fetch<string | undefined>(\n `*[_type == $type]|order(@[$order] ${direction})[0][$order]`,\n {type, order: ORDER_FIELD_NAME},\n {tag: 'orderable-document-list.last-doc-order-rank'},\n )\n return initialRank(lastDocOrderRank, newItemPosition)\n },\n })\n}\n","import type {SortOrdering} from 'sanity'\n\nimport {ORDER_FIELD_NAME} from '../helpers/constants'\n\nexport const orderRankOrdering: SortOrdering = {\n title: 'Ordered',\n name: 'ordered',\n by: [{field: ORDER_FIELD_NAME, direction: 'asc'}],\n}\n","import {createContext} from 'react'\n\nexport interface OrderableContextValue {\n showIncrements?: boolean\n}\n\nexport const OrderableContext = createContext<OrderableContextValue>({})\n","import {ChevronDownIcon} from '@sanity/icons/ChevronDown'\nimport {ChevronUpIcon} from '@sanity/icons/ChevronUp'\nimport {DragHandleIcon} from '@sanity/icons/DragHandle'\nimport {AvatarCounter, Card, Box, Button, Flex, Text, Tooltip} from '@sanity/ui'\nimport {useContext} from 'react'\nimport {\n useSchema,\n PreviewCard,\n Preview,\n DocumentStatusIndicator,\n DocumentStatus,\n useDocumentVersionInfo,\n} from 'sanity'\nimport {usePaneRouter} from 'sanity/structure'\n\nimport {OrderableContext} from './OrderableContext'\nimport type {SanityDocumentWithOrder} from './types'\n\nexport interface DocumentProps {\n doc: SanityDocumentWithOrder\n entities: SanityDocumentWithOrder[]\n increment: (\n index: number,\n nextIndex: number,\n docId: string,\n entities: SanityDocumentWithOrder[],\n ) => void\n index: number\n isFirst: boolean\n isLast: boolean\n dragBadge: number | false\n}\n\nexport function Document({\n doc,\n increment,\n entities,\n index,\n isFirst,\n isLast,\n dragBadge,\n}: DocumentProps) {\n const {showIncrements} = useContext(OrderableContext)\n const schema = useSchema()\n const router = usePaneRouter()\n const versionsInfo = useDocumentVersionInfo(doc._id)\n\n const {ChildLink, groupIndex, routerPanesState} = router\n\n const currentDoc = routerPanesState[groupIndex + 1]?.[0]?.id || false\n const pressed = currentDoc === doc._id || currentDoc === doc._id.replace(`drafts.`, ``)\n const selected = pressed && routerPanesState.length === groupIndex + 2\n const schemaType = schema.get(doc._type)\n\n if (!schemaType) {\n return null\n }\n\n const tooltip = (\n <DocumentStatus\n draft={versionsInfo.draft}\n published={versionsInfo.published}\n versions={versionsInfo.versions}\n />\n )\n\n return (\n <PreviewCard\n __unstable_focusRing\n // @ts-expect-error PreviewCard's polymorphic `as` prop does not accept ChildLink's type.\n as={ChildLink}\n data-as=\"a\"\n data-ui=\"PaneItem\"\n radius={2}\n pressed={pressed}\n selected={selected}\n sizing=\"border\"\n tabIndex={-1}\n tone=\"inherit\"\n width=\"100%\"\n flex={1}\n childId={doc._id}\n >\n <Flex align=\"center\">\n <Box paddingX={2} style={{flexShrink: 0}}>\n <Text size={2}>\n <DragHandleIcon cursor=\"grab\" />\n </Text>\n </Box>\n {showIncrements && (\n <Flex style={{flexShrink: 0}} align=\"center\" gap={1} paddingRight={1}>\n <Button\n padding={2}\n mode=\"ghost\"\n onClick={() => increment(index, index - 1, doc._id, entities)}\n disabled={isFirst}\n icon={ChevronUpIcon}\n />\n <Button\n padding={2}\n mode=\"ghost\"\n disabled={isLast}\n onClick={() => increment(index, index + 1, doc._id, entities)}\n icon={ChevronDownIcon}\n />\n </Flex>\n )}\n <Box style={{width: `100%`}}>\n <Flex flex={1} align=\"center\" justify=\"space-between\" paddingRight={3}>\n <Preview layout=\"default\" value={doc} schemaType={schemaType} />\n\n <Tooltip content={tooltip} portal placement=\"right\" boundaryElement={null}>\n <Flex align=\"center\" style={{flexShrink: 0}}>\n <DocumentStatusIndicator\n draft={versionsInfo.draft}\n published={versionsInfo.published}\n versions={versionsInfo.versions}\n />\n </Flex>\n </Tooltip>\n </Flex>\n </Box>\n {dragBadge && (\n <Card tone=\"default\" marginRight={4} radius={5}>\n <AvatarCounter count={dragBadge} />\n </Card>\n )}\n </Flex>\n </PreviewCard>\n )\n}\n","import {type SanityClient, useClient, usePerspective} from 'sanity'\n\nimport {API_VERSION} from './constants'\n\nexport function useSanityClient(): SanityClient {\n const {perspectiveStack} = usePerspective()\n\n return useClient({apiVersion: API_VERSION}).withConfig({perspective: perspectiveStack})\n}\n","import type {DraggableLocation} from '@hello-pangea/dnd'\nimport {LexoRank} from 'lexorank'\nimport type {PatchOperations} from 'sanity'\n\nimport type {SanityDocumentWithOrder} from '../types'\nimport {ORDER_FIELD_NAME} from './constants'\nimport {parseOrderRank} from './parseOrderRank'\n\nexport interface ReorderArgs {\n entities: SanityDocumentWithOrder[]\n selectedIds: string[]\n source: DraggableLocation\n destination: DraggableLocation\n}\n\nexport interface ReorderReturn {\n newOrder: SanityDocumentWithOrder[]\n patches: [string, PatchOperations][]\n message: string\n}\n\nfunction lexicographicalSort(a: SanityDocumentWithOrder, b: SanityDocumentWithOrder) {\n if (!a[ORDER_FIELD_NAME] || !b[ORDER_FIELD_NAME]) {\n return 0\n } else if (a[ORDER_FIELD_NAME] < b[ORDER_FIELD_NAME]) {\n return -1\n } else if (a[ORDER_FIELD_NAME] > b[ORDER_FIELD_NAME]) {\n return 1\n }\n return 0\n}\n\nexport const reorderDocuments = ({\n entities,\n selectedIds,\n source,\n destination,\n}: ReorderArgs): ReorderReturn => {\n const startIndex = source.index\n const endIndex = destination.index\n const isMovingUp = startIndex > endIndex\n const selectedItems = entities.filter((item) => selectedIds.includes(item._id))\n const message = [\n 'Moved',\n selectedItems.length === 1 ? '1 document' : `${selectedItems.length} documents`,\n isMovingUp ? 'up' : 'down',\n 'from position',\n `${startIndex + 1} to ${endIndex + 1}`,\n ].join(' ')\n\n const {all, selected} = entities.reduce<{\n all: SanityDocumentWithOrder[]\n selected: SanityDocumentWithOrder[]\n }>(\n (acc, cur, curIndex) => {\n // Selected items get spread in below, so skip them here\n if (selectedIds.includes(cur._id)) {\n return {all: acc.all, selected: acc.selected}\n }\n\n // Drop selected items in\n if (curIndex === endIndex) {\n const prevIndex = curIndex - 1\n const prevRank = parseOrderRank(entities[prevIndex]?.[ORDER_FIELD_NAME], LexoRank.min())\n const curRank = parseOrderRank(cur[ORDER_FIELD_NAME], LexoRank.min())\n const nextIndex = curIndex + 1\n const nextRank = parseOrderRank(entities[nextIndex]?.[ORDER_FIELD_NAME], LexoRank.max())\n\n let betweenRank = isMovingUp ? prevRank.between(curRank) : curRank.between(nextRank)\n\n // For each selected item, assign a new orderRank between now and next\n for (const selectedItem of selectedItems) {\n selectedItem[ORDER_FIELD_NAME] = betweenRank.toString()\n betweenRank = isMovingUp ? betweenRank.between(curRank) : betweenRank.between(nextRank)\n }\n\n return {\n // The `all` array gets sorted by order field later anyway\n // so that this probably isn't necessary ¯\\_(ツ)_/¯\n all: isMovingUp\n ? [...acc.all, ...selectedItems, cur]\n : [...acc.all, cur, ...selectedItems],\n selected: selectedItems,\n }\n }\n\n return {all: [...acc.all, cur], selected: acc.selected}\n },\n {all: [], selected: []},\n )\n\n const patches = selected.flatMap((doc) => {\n const docPatches: [string, PatchOperations][] = [\n [\n doc._id,\n {\n set: {\n [ORDER_FIELD_NAME]: doc[ORDER_FIELD_NAME],\n },\n },\n ],\n ]\n\n // If it's a draft, we need to patch the published document as well\n if (doc._id.startsWith('drafts.') && doc.hasPublished) {\n docPatches.push([\n doc._id.replace('drafts.', ''),\n {\n set: {\n [ORDER_FIELD_NAME]: doc[ORDER_FIELD_NAME],\n },\n },\n ])\n }\n\n return docPatches\n })\n\n // Safety-check to make sure everything is in order\n const allSorted = all.sort(lexicographicalSort)\n\n return {newOrder: allSorted, patches, message}\n}\n","import {\n DragDropContext,\n Draggable,\n Droppable,\n type DropResult,\n type DraggableLocation,\n} from '@hello-pangea/dnd'\nimport {Box, Card, useToast} from '@sanity/ui'\nimport {useEffect, useState, useMemo, useCallback, type CSSProperties} from 'react'\nimport type {PatchOperations} from 'sanity'\nimport {usePaneRouter} from 'sanity/structure'\n\nimport {Document} from './Document'\nimport {useSanityClient} from './helpers/client'\nimport {ORDER_FIELD_NAME} from './helpers/constants'\nimport {reorderDocuments} from './helpers/reorderDocuments'\nimport type {SanityDocumentWithOrder} from './types'\n\ninterface ListSetting {\n isDuplicate: boolean\n isGhosting: boolean\n isDragging: boolean\n isSelected: boolean\n}\n\ninterface DragResultLike {\n draggableId: string\n source: DraggableLocation\n destination: DraggableLocation | null\n}\n\nexport interface DraggableListProps {\n data: SanityDocumentWithOrder[]\n listIsUpdating: boolean\n setListIsUpdating: (val: boolean) => void\n}\n\nconst getItemStyle = (\n draggableStyle: CSSProperties | undefined,\n itemIsUpdating: boolean,\n): CSSProperties => ({\n userSelect: 'none',\n transition: 'opacity 500ms ease-in-out',\n opacity: itemIsUpdating ? 0.2 : 1,\n pointerEvents: itemIsUpdating ? 'none' : undefined,\n ...draggableStyle,\n})\n\nconst cardTone = (settings: ListSetting) => {\n const {isDuplicate, isGhosting, isDragging, isSelected} = settings\n\n if (isGhosting) return 'transparent'\n if (isDragging || isSelected) return 'primary'\n if (isDuplicate) return 'caution'\n\n return undefined\n}\n\nexport function DraggableList({data, listIsUpdating, setListIsUpdating}: DraggableListProps) {\n const toast = useToast()\n const router = usePaneRouter()\n const {groupIndex, routerPanesState} = router\n\n const currentDoc = routerPanesState[groupIndex + 1]?.[0]?.id || false\n\n // Maintains local state order before transaction completes\n const [orderedData, setOrderedData] = useState<SanityDocumentWithOrder[]>(data)\n const displayedData = listIsUpdating ? orderedData : data\n\n const [draggingId, setDraggingId] = useState('')\n const [selectedIds, setSelectedIds] = useState<string[]>(currentDoc ? [currentDoc] : [])\n\n const clearSelected = useCallback(() => setSelectedIds([]), [setSelectedIds])\n\n const handleSelect = useCallback(\n (clickedId: string, index: number, nativeEvent: MouseEvent) => {\n const isSelected = selectedIds.includes(clickedId)\n const selectMultiple = nativeEvent.shiftKey\n const isUsingWindows = navigator.appVersion.indexOf('Win') !== -1\n const selectAdditional = isUsingWindows ? nativeEvent.ctrlKey : nativeEvent.metaKey\n\n let updatedIds: string[] = []\n\n // No modifier keys pressed during click:\n // - update selected to just this one\n // - open document\n if (!selectMultiple && !selectAdditional) {\n return setSelectedIds([clickedId])\n }\n\n // If shift key was held, prevent default to avoid new window opening\n if (selectMultiple) {\n nativeEvent.preventDefault()\n }\n\n // Shift key was held, add id's between last selected and this one\n // ...before adding this one\n if (selectMultiple && !isSelected) {\n const lastSelectedId = selectedIds[selectedIds.length - 1] ?? clickedId\n const lastSelectedIndex = displayedData.findIndex((item) => item._id === lastSelectedId)\n\n const firstSelected = index < lastSelectedIndex ? index : lastSelectedIndex\n const lastSelected = index > lastSelectedIndex ? index : lastSelectedIndex\n\n const betweenIds = displayedData\n .filter((_, itemIndex) => itemIndex > firstSelected && itemIndex < lastSelected)\n .map((item) => item._id)\n\n updatedIds = [...selectedIds, ...betweenIds, clickedId]\n } else if (isSelected) {\n // Toggle off a single id\n updatedIds = selectedIds.filter((id) => id !== clickedId)\n } else {\n // Toggle on a single id\n updatedIds = [...selectedIds, clickedId]\n }\n\n return setSelectedIds(updatedIds)\n },\n [displayedData, selectedIds],\n )\n\n const client = useSanityClient()\n\n const transactPatches = useCallback(\n async (patches: [string, PatchOperations][], message: string) => {\n const transaction = client.transaction()\n\n patches.forEach(([docId, ops]) => {\n transaction.patch(docId, ops)\n })\n\n try {\n const updated = await transaction.commit({\n visibility: 'sync',\n tag: 'orderable-document-list.reorder',\n })\n clearSelected()\n setDraggingId('')\n setListIsUpdating(false)\n toast.push({\n title: `${\n updated.results.length === 1 ? '1 document' : `${updated.results.length} documents`\n } reordered`,\n status: 'success',\n description: message,\n })\n } catch {\n setDraggingId('')\n setListIsUpdating(false)\n toast.push({\n title: 'Reordering failed',\n status: 'error',\n })\n }\n },\n [client, clearSelected, setListIsUpdating, toast],\n )\n\n const handleDragEnd = useCallback(\n (result: DragResultLike | undefined, entities: SanityDocumentWithOrder[]) => {\n setDraggingId('')\n\n const {source, destination, draggableId} = result ?? {}\n\n // Don't do anything if nothing changed\n if (source?.index === destination?.index) return\n\n // Don't do anything if we don't have the entitites\n if (!entities.length || !draggableId || !source || !destination) return\n\n // A document can be dragged without being one-of-many-selected\n const effectedIds = selectedIds.length > 0 ? selectedIds : [draggableId]\n\n // Don't do anything if we don't have ids to effect\n if (effectedIds.length === 0) return\n\n // Update state to update styles + prevent data refetching\n setListIsUpdating(true)\n setSelectedIds(effectedIds)\n\n const {newOrder, patches, message} = reorderDocuments({\n entities,\n selectedIds: effectedIds,\n source,\n destination,\n })\n\n // Update local state\n if (newOrder.length > 0) {\n setOrderedData(newOrder)\n }\n\n // Transact new order patches\n if (patches.length > 0) {\n void transactPatches(patches, message)\n }\n },\n [selectedIds, transactPatches, setListIsUpdating],\n )\n\n const handleDragStart = useCallback(\n (start: {draggableId: string}) => {\n const id = start.draggableId\n const selected = selectedIds.includes(id)\n\n // if dragging an item that is not selected - unselect all items\n if (!selected) clearSelected()\n\n setDraggingId(id)\n },\n [selectedIds, clearSelected],\n )\n\n // Move one document up or down one place, by fake invoking the drag function\n const incrementIndex = useCallback(\n (shiftFrom: number, shiftTo: number, id: string, entities: SanityDocumentWithOrder[]) => {\n const result: DragResultLike = {\n draggableId: id,\n source: {droppableId: 'documentSortZone', index: shiftFrom},\n destination: {droppableId: 'documentSortZone', index: shiftTo},\n }\n\n return handleDragEnd(result, entities)\n },\n [handleDragEnd],\n )\n\n const onWindowKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n clearSelected()\n }\n },\n [clearSelected],\n )\n\n useEffect(() => {\n window.addEventListener('keydown', onWindowKeyDown)\n\n return () => {\n window.removeEventListener('keydown', onWindowKeyDown)\n }\n }, [onWindowKeyDown])\n\n // Find all items with duplicate order field\n const duplicateOrders = useMemo(() => {\n if (displayedData.length === 0) return []\n\n const orderField = displayedData.map((item) => item[ORDER_FIELD_NAME])\n\n return orderField.filter((item, index) => orderField.indexOf(item) !== index)\n }, [displayedData])\n\n const onDragEnd = useCallback(\n (result: DropResult) => handleDragEnd(result, displayedData),\n [displayedData, handleDragEnd],\n )\n\n return (\n <DragDropContext onDragStart={handleDragStart} onDragEnd={onDragEnd}>\n <Droppable droppableId=\"documentSortZone\">\n {(provided) => (\n <div {...provided.droppableProps} ref={provided.innerRef}>\n {displayedData.map((item, index) => (\n <Draggable\n key={`${item._id}-${item[ORDER_FIELD_NAME]}`}\n draggableId={item._id}\n index={index}\n >\n {(innerProvided, innerSnapshot) => {\n const isSelected = selectedIds.includes(item._id)\n const isDragging = innerSnapshot.isDragging\n const isGhosting = Boolean(!isDragging && draggingId && isSelected)\n const isUpdating = listIsUpdating && isSelected\n const isDisabled = !item[ORDER_FIELD_NAME]\n const isDuplicate = duplicateOrders.includes(item[ORDER_FIELD_NAME])\n const tone = cardTone({isDuplicate, isGhosting, isDragging, isSelected})\n const selectedCount = selectedIds.length\n\n const dragBadge = isDragging && selectedCount > 1 ? selectedCount : false\n\n return (\n <div\n ref={innerProvided.innerRef}\n {...innerProvided.draggableProps}\n {...innerProvided.dragHandleProps}\n style={\n isDisabled\n ? {opacity: 0.2, pointerEvents: 'none'}\n : getItemStyle(innerProvided.draggableProps.style, isUpdating)\n }\n >\n <Box paddingBottom={1}>\n <Card\n tone={tone}\n shadow={isDragging ? 2 : undefined}\n radius={2}\n onClick={(e) => handleSelect(item._id, index, e.nativeEvent)}\n >\n <Document\n doc={item}\n entities={displayedData}\n increment={incrementIndex}\n index={index}\n isFirst={index === 0}\n isLast={index === displayedData.length - 1}\n dragBadge={dragBadge}\n />\n </Card>\n </Box>\n </div>\n )\n }}\n </Draggable>\n ))}\n {provided.placeholder}\n </div>\n )}\n </Droppable>\n </DragDropContext>\n )\n}\n","import {getPublishedId, getVersionFromId, isDraftId, isPublishedId, isVersionId} from 'sanity'\n\nimport type {SanityDocumentWithOrder} from '../types'\n\nconst isVersionForCurrentPerspective = (\n document: SanityDocumentWithOrder,\n perspectiveName: string,\n publishedId: string,\n) => {\n return (\n document._id &&\n isVersionId(document._id) &&\n getVersionFromId(document._id) === perspectiveName &&\n getPublishedId(document._id) === publishedId\n )\n}\n\n// this removes dedupped docs from the list and makes sure that it keeps the right docs\n// in the list while preserving the order established by the orderRank field\nexport const getFilteredDedupedDocs = (\n documents: SanityDocumentWithOrder[],\n perspectiveName?: string,\n): SanityDocumentWithOrder[] => {\n // Flatten the documents array in case it's nested (like in test data)\n const flatDocuments = documents.flat()\n const dedupedDocuments: SanityDocumentWithOrder[] = []\n\n for (const cur of flatDocuments) {\n if (!cur._id) {\n continue\n }\n\n // Handle version-only documents\n if (isVersionId(cur._id)) {\n const versionFromId = getVersionFromId(cur._id)\n const isCorrectVersion = versionFromId === perspectiveName\n\n // Only include versions that match the current perspective\n if (\n perspectiveName &&\n perspectiveName !== 'drafts' &&\n perspectiveName !== 'published' &&\n isCorrectVersion\n ) {\n dedupedDocuments.push(cur)\n }\n continue\n }\n\n // Handle published perspective - only include published documents\n if (perspectiveName === 'published') {\n if (isPublishedId(cur._id)) {\n dedupedDocuments.push(cur)\n }\n continue\n }\n\n // in situations where the document is not a draft, we need to check if\n // the version should override a published document or a draft\n if (!isDraftId(cur._id)) {\n const publishedId = getPublishedId(cur._id)\n\n // Check if there's a version that matches the perspectiveName\n const hasMatchingVersion =\n perspectiveName && perspectiveName !== 'drafts' && perspectiveName !== 'published'\n ? flatDocuments.some((doc) =>\n isVersionForCurrentPerspective(doc, perspectiveName, publishedId),\n )\n : false\n\n // Check if there's a draft\n const hasDraft = flatDocuments.some((doc) => doc._id === `drafts.${cur._id}`)\n const hasDuplicatePublished = flatDocuments.some((doc) => doc !== cur && doc._id === cur._id)\n\n // Priority: version > draft > published\n // If there's a matching version, skip published\n if (!hasMatchingVersion && !hasDraft && !hasDuplicatePublished) {\n dedupedDocuments.push(cur)\n }\n continue\n }\n\n // For drafts, check if there's a version for this document in version perspective\n if (perspectiveName && perspectiveName !== 'drafts' && perspectiveName !== 'published') {\n const baseId = getPublishedId(cur._id)\n const hasVersion = flatDocuments.some((doc) =>\n isVersionForCurrentPerspective(doc, perspectiveName, baseId),\n )\n\n // If there's a version for this document, skip the draft\n if (hasVersion) {\n continue\n }\n }\n\n // Check if the draft has a published version\n cur.hasPublished = flatDocuments.some((doc) => doc._id === cur._id.replace(`drafts.`, ``))\n\n dedupedDocuments.push(cur)\n }\n\n return dedupedDocuments\n}\n","import {ORDER_FIELD_NAME} from './constants'\n\nexport interface DocumentListQueryProps {\n type: string\n filter?: string\n params?: Record<string, unknown>\n currentVersion?: string\n}\n\nexport interface DocumentListQueryResult {\n query: string\n queryParams: Record<string, string | number | boolean | string[]>\n}\n\nconst DEFAULT_PARAMS = {}\n\nexport function getDocumentQuery({\n type,\n filter,\n params = DEFAULT_PARAMS,\n currentVersion,\n}: DocumentListQueryProps): DocumentListQueryResult {\n let perspectiveFilter = null\n if (currentVersion === 'published') {\n perspectiveFilter = '!(_id in path(\"drafts.**\")) && !(_id in path(\"versions.**\"))'\n } else if (currentVersion === 'drafts') {\n // Show drafts, and published when no draft exists\n perspectiveFilter = `\n (_id in path(\"drafts.**\") || (!(_id in path(\"drafts.**\")) && !(_id in path(\"versions.**\"))))\n `\n } else {\n // Default behavior: prioritize drafts over published when both exist\n // the priority should be a version\n perspectiveFilter = `(sanity::partOfRelease($currentVersion) || (!(_id in path(\"drafts.**\")) && !(_id in path(\"versions.**\"))) || (_id in path(\"drafts.**\")))`\n }\n\n const querySelect = `*[_type == $type ${perspectiveFilter ? `&& ${perspectiveFilter}` : ''}${filter ? `&& ${filter}` : ''}]`\n const queryOrder = `|order(@[$order] asc)`\n const queryFields = `{_id, _type, ${ORDER_FIELD_NAME}}`\n\n const query = `${querySelect}${queryOrder}${queryFields}`\n const queryParams = {\n ...params,\n type,\n order: ORDER_FIELD_NAME,\n ...(currentVersion && {currentVersion}),\n }\n\n return {query, queryParams}\n}\n","import {Box, Flex, Container, Spinner, Stack, Text} from '@sanity/ui'\nimport {useMemo, useState} from 'react'\nimport {useListeningQuery, Feedback} from 'sanity-plugin-utils'\n\nimport {DraggableList} from './DraggableList'\nimport {ORDER_FIELD_NAME} from './helpers/constants'\nimport {getFilteredDedupedDocs} from './helpers/getFilteredDedupedDocs'\nimport {getDocumentQuery, type DocumentListQueryProps} from './helpers/query'\nimport type {SanityDocumentWithOrder} from './types'\n\nexport function DocumentListQuery(props: DocumentListQueryProps) {\n const [listIsUpdating, setListIsUpdating] = useState(false)\n\n const {query, queryParams} = getDocumentQuery(props)\n\n const {\n data: _queryData,\n loading,\n error,\n } = useListeningQuery<SanityDocumentWithOrder[]>(query, {\n params: queryParams,\n initialValue: [],\n })\n\n const queryData = useMemo(() => (Array.isArray(_queryData) ? _queryData : []), [_queryData])\n\n const data = useMemo(\n () => getFilteredDedupedDocs(queryData, props.currentVersion),\n [props.currentVersion, queryData],\n )\n\n const unorderedDataCount = useMemo(\n () => data.filter((doc) => !doc[ORDER_FIELD_NAME]).length,\n [data],\n )\n\n if (loading) {\n return (\n <Flex style={{width: `100%`, height: `100%`}} align=\"center\" justify=\"center\">\n <Spinner />\n </Flex>\n )\n }\n\n if (error) {\n return (\n <Box padding={2}>\n <Feedback tone=\"critical\" title=\"There was an error\" description=\"Please try again later\" />\n </Box>\n )\n }\n\n if (data.length === 0) {\n return (\n <Flex align=\"center\" direction=\"column\" height=\"fill\" justify=\"center\">\n <Container width={1}>\n <Box paddingX={4} paddingY={5}>\n <Text align=\"center\" muted>\n No documents of this type\n </Text>\n </Box>\n </Container>\n </Flex>\n )\n }\n\n return (\n <Stack gap={1} style={{overflow: `auto`, height: `100%`}}>\n <Box padding={2}>\n {unorderedDataCount > 0 && (\n <Box marginBottom={2}>\n <Feedback\n tone=\"caution\"\n description={\n <>\n {unorderedDataCount}/{data.length} documents have no order. Select{' '}\n <strong>Reset Order</strong> from the menu above to fix.\n </>\n }\n />\n </Box>\n )}\n <DraggableList\n data={data}\n listIsUpdating={listIsUpdating}\n setListIsUpdating={setListIsUpdating}\n />\n </Box>\n </Stack>\n )\n}\n","import {useToast, Box, type ToastParams} from '@sanity/ui'\nimport {useEffect, useMemo} from 'react'\nimport {useSchema} from 'sanity'\nimport {Feedback} from 'sanity-plugin-utils'\n\nimport {DocumentListQuery} from './DocumentListQuery'\nimport {ORDER_FIELD_NAME} from './helpers/constants'\nimport {OrderableContext} from './OrderableContext'\n\nexport interface DocumentListWrapperProps {\n showIncrements: boolean\n type: string\n resetOrderTransaction: ToastParams\n filter?: string\n params?: Record<string, unknown>\n currentVersion?: string\n}\n\n// 1. Validate first that the schema has been configured for ordering\n// 2. Setup context for showIncrements\nexport function DocumentListWrapper({\n type,\n showIncrements,\n resetOrderTransaction,\n filter,\n params,\n currentVersion,\n}: DocumentListWrapperProps) {\n const toast = useToast()\n const schema = useSchema()\n const orderableContextValue = useMemo(() => ({showIncrements}), [showIncrements])\n\n useEffect(() => {\n if (resetOrderTransaction?.title && resetOrderTransaction?.status) {\n toast.push(resetOrderTransaction)\n }\n }, [resetOrderTransaction, toast])\n\n const schemaIsInvalid = useMemo(() => {\n // Option not passed\n if (!type) {\n return (\n <>\n No <code>type</code> was configured\n </>\n )\n }\n\n const typeSchema = schema.get(type)\n\n // Schema not found\n if (!typeSchema) {\n return (\n <>\n Schema <code>{type}</code> not found\n </>\n )\n }\n\n // Schema lacks an order field\n if (\n !('fields' in typeSchema) ||\n !typeSchema.fields.some((field) => field?.name === ORDER_FIELD_NAME)\n ) {\n return (\n <>\n Schema <code>{type}</code> must have an <code>{ORDER_FIELD_NAME}</code> field of type{' '}\n <code>string</code>\n </>\n )\n }\n\n // Schema's order field is not a string\n if (\n 'fields' in typeSchema &&\n typeSchema.fields.some(\n (field) => field?.name === ORDER_FIELD_NAME && field?.type?.name !== 'string',\n )\n ) {\n return (\n <>\n <code>{ORDER_FIELD_NAME}</code> field on Schema <code>{type}</code> must be{' '}\n <code>string</code> type\n </>\n )\n }\n\n return ''\n }, [type, schema])\n\n if (schemaIsInvalid) {\n return (\n <Box padding={2}>\n <Feedback description={schemaIsInvalid} tone=\"caution\" />\n </Box>\n )\n }\n\n return (\n <OrderableContext.Provider value={orderableContextValue}>\n <DocumentListQuery\n type={type}\n filter={filter}\n params={params}\n currentVersion={currentVersion}\n />\n </OrderableContext.Provider>\n )\n}\n","import type {MultipleMutationResult, SanityClient} from '@sanity/client'\nimport {LexoRank} from 'lexorank'\n\nimport {ORDER_FIELD_NAME} from './constants'\nimport {getDocumentQuery, type DocumentListQueryProps} from './query'\n\nexport interface ResetOrderParams extends DocumentListQueryProps {\n client: SanityClient\n currentVersion?: string\n}\n\n// Function to wipe and re-do ordering with LexoRank\n// Will at least attempt to start with the current order\nexport async function resetOrder(params: ResetOrderParams): Promise<MultipleMutationResult | null> {\n const {client, currentVersion, ...queryProps} = params\n const {query, queryParams} = getDocumentQuery({...queryProps, currentVersion})\n\n const documents = await client.fetch<\n Array<{\n _id: string\n _type: string\n [ORDER_FIELD_NAME]: string\n }>\n >(query, queryParams, {\n tag: 'orderable-document-list.reset-order',\n })\n\n if (documents.length === 0) {\n return null\n }\n\n let aLexoRank = LexoRank.min()\n\n const transaction = documents\n .map((doc) => doc._id)\n .reduce((trx, documentId) => {\n // Generate next rank before even the first document so there's room to move!\n aLexoRank = aLexoRank.genNext().genNext()\n\n return trx.patch(documentId, {\n set: {[ORDER_FIELD_NAME]: aLexoRank.toString()},\n })\n }, client.transaction())\n\n return transaction.commit({\n visibility: 'async',\n tag: 'orderable-document-list.reset-order',\n })\n}\n","import type {SanityClient} from '@sanity/client'\nimport type {ToastParams} from '@sanity/ui'\nimport {Component} from 'react'\n\nimport {DocumentListWrapper} from './DocumentListWrapper'\nimport {resetOrder} from './helpers/resetOrder'\n\nexport interface OrderableDocumentListProps {\n options: {\n type: string\n client: SanityClient\n filter?: string\n params?: Record<string, unknown>\n currentVersion?: string\n }\n}\n\ninterface State {\n showIncrements: boolean\n resetOrderTransaction: ToastParams\n}\n\n// Must use a Class Component here so the actionHandlers can be called\nexport class OrderableDocumentList extends Component<OrderableDocumentListProps, State> {\n constructor(props: OrderableDocumentListProps) {\n super(props)\n this.state = {\n showIncrements: false,\n resetOrderTransaction: {},\n }\n }\n\n actionHandlers = {\n showIncrements: () => {\n this.setState((state) => ({\n showIncrements: !state.showIncrements,\n }))\n },\n\n resetOrder: async () => {\n this.setState(() => ({\n resetOrderTransaction: {\n status: `info`,\n title: `Reordering started...`,\n closable: true,\n },\n }))\n\n const update = await resetOrder(this.props.options)\n\n const reorderWasSuccessful = update?.results?.length\n\n this.setState(() => ({\n resetOrderTransaction: {\n status: reorderWasSuccessful ? `success` : `info`,\n title: reorderWasSuccessful\n ? `Reordered ${update.results.length === 1 ? `Document` : `Documents`}`\n : `Reordering failed`,\n closable: true,\n },\n }))\n },\n }\n\n override render() {\n const {options} = this.props\n const {type, filter, params, currentVersion} = options\n\n if (!type) {\n return null\n }\n\n return (\n <DocumentListWrapper\n filter={filter}\n params={params}\n type={type}\n showIncrements={this.state.showIncrements}\n resetOrderTransaction={this.state.resetOrderTransaction}\n currentVersion={currentVersion}\n />\n )\n }\n}\n","import {GenerateIcon} from '@sanity/icons/Generate'\nimport {SortIcon} from '@sanity/icons/Sort'\nimport {type ComponentType} from 'react'\nimport type {ConfigContext} from 'sanity'\nimport {type ListItem, type MenuItem, type StructureBuilder} from 'sanity/structure'\n\nimport {API_VERSION} from '../helpers/constants'\nimport {OrderableDocumentList} from '../OrderableDocumentList'\n\nexport interface OrderableListConfig {\n type: string\n id?: string\n title?: string\n icon?: ComponentType\n params?: Record<string, unknown>\n filter?: string\n menuItems?: MenuItem[]\n createIntent?: boolean\n context: ConfigContext\n S: StructureBuilder\n}\n\nexport function orderableDocumentListDeskItem(config: OrderableListConfig): ListItem {\n if (!config?.type || !config.context || !config.S) {\n throw new Error(`\n type, context and S (StructureBuilder) must be provided.\n context and S are available when configuring structure.\n Example: orderableDocumentListDeskItem({type: 'category'})\n `)\n }\n\n const {type, filter, menuItems = [], createIntent, params, title, icon, id, context, S} = config\n const {schema, getClient} = context\n const maybePerspectiveStack: unknown = Reflect.get(context, 'perspectiveStack')\n const perspectiveStack =\n Array.isArray(maybePerspectiveStack) &&\n maybePerspectiveStack.every((item): item is string => typeof item === 'string')\n ? maybePerspectiveStack\n : []\n const client = getClient({apiVersion: API_VERSION})\n // the first position in the perspective stack is the current version\n const currentVersion = perspectiveStack[0]\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 const defaultMenuItems = [...menuItems]\n\n if (createIntent !== false) {\n defaultMenuItems.push(\n S.menuItem()\n .title(`Create new ${typeTitle}`)\n .intent({type: 'create', params: {type}})\n .serialize(),\n )\n }\n\n return S.listItem()\n .title(listTitle)\n .id(listId)\n .icon(listIcon)\n .schemaType(type)\n .child(\n Object.assign(\n S.documentTypeList(type)\n .canHandleIntent(\n (_intentName, params) => createIntent !== false && params?.['type'] === type,\n )\n .serialize(),\n {\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, client, currentVersion},\n menuItems: [\n ...defaultMenuItems,\n S.menuItem().title(`Reset Order`).icon(GenerateIcon).action(`resetOrder`).serialize(),\n S.menuItem()\n .title(`Toggle Increments`)\n .icon(SortIcon)\n .action(`showIncrements`)\n .serialize(),\n ],\n },\n ),\n )\n .serialize()\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,MAAaA,mBAAmB,aAGnBE,cAAc;ACA3B,SAAgBE,eAAeC,OAAgBC,UAA8B;CAC3E,IAAI,OAAOD,SAAU,UAEnB,OADAE,QAAQC,KAAK,wEAAwEH,KAAK,GACnFC;CAGT,IAAI;EACF,OAAOH,SAASM,MAAMJ,KAAK;CAC7B,SAASK,KAAK;EAOZ,OANAH,QAAQC,KACN,8DACAH,OACA,UACAK,eAAeC,QAAQD,IAAIE,UAAUC,OAAOH,GAAG,CACjD,GACOJ;CACT;AACF;ACbA,SAAgBW,YACdC,mBAA4B,IAC5BC,kBAAmC,SACnC;CACA,IAAMC,cAAcJ,eAAeE,kBAAkBJ,SAASO,IAAI,CAAC;CAInE,QAFEF,oBAAoB,WAAWC,YAAYG,QAAQ,CAAC,CAACA,QAAQ,IAAIH,YAAYI,QAAQ,CAAC,CAACA,QAAQ,EAAA,CAErFC,SAAS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,CAAC,EAAEE,SAASF,MACvC+B,mBAAmB,CAAC,GAAGxB,SAAS;CAWtC,OATIC,iBAAiB,MACnBuB,iBAAiBC,KACftB,EAAEuB,SAAS,CAAC,CACT/B,MAAM,cAAc4B,WAAW,CAAC,CAChCI,OAAO;EAAClC,MAAM;EAAUI,QAAQ,EAACJ,KAAI;CAAC,CAAC,CAAC,CACxCmC,UAAU,CACf,GAGKzB,EAAE0B,SAAS,CAAC,CAChBlC,MAAMyB,SAAS,CAAC,CAChB1B,GAAG2B,MAAM,CAAC,CACVzB,KAAK0B,QAAQ,CAAC,CACdQ,WAAWrC,IAAI,CAAC,CAChBsC,MACCC,OAAOC,OACL9B,EAAE+B,iBAAiBzC,IAAI,CAAC,CACrB0C,iBACEC,aAAavC,WAAWI,iBAAiB,MAASJ,QAAS,SAAYJ,IAC1E,CAAC,CACAmC,UAAU,GACb;EAEES,oBAAoB;EAEpBC,KAAKjB;EAEL5B,MAAM;EACN8C,WAAWhD;EACXiD,SAAS;GAAC/C;GAAMM;GAAQF;GAAQoB;GAAQE;EAAc;EACtDnB,WAAW;GACT,GAAGwB;GACHrB,EAAEuB,SAAS,CAAC,CAAC/B,MAAM,aAAa,CAAC,CAACC,KAAKb,YAAY,CAAC,CAAC0D,OAAO,YAAY,CAAC,CAACb,UAAU;GACpFzB,EAAEuB,SAAS,CAAC,CACT/B,MAAM,mBAAmB,CAAC,CAC1BC,KAAKZ,QAAQ,CAAC,CACdyD,OAAO,gBAAgB,CAAC,CACxBb,UAAU;EAAC;CAElB,CACF,CACF,CAAC,CACAA,UAAU;AACf"}
\ No newline at end of file Index: package/README.md
===================================================================
--- package/README.md
+++ package/README.md
@@ -85,9 +85,11 @@
}),
// ... all other desk items, e.g. all other document types not already included
// @see https://www.sanity.io/docs/studio/structure-builder-cheat-sheet#k4eb3b1891dc2
- ...S.documentTypeListItems().filter((item) => !(['category', 'project'].includes(item.getId())))
+ ...S.documentTypeListItems().filter(
+ (item) => !['category', 'project'].includes(item.getId()),
+ ),
])
},
}),
],
@@ -193,8 +195,7 @@
Uses [kvandakes](https://github.com/kvandake)'s [TypeScript implementation](https://github.com/kvandake/lexorank-ts) of [Jira's Lexorank](https://www.youtube.com/watch?v=OjQv9xMoFbg) to create a "lexographical" Document order.
Put simply it updates the position of an individual – or many – Documents in an ordered list without updating any others. It's fast.
-
## License
[MIT](LICENSE) © Sanity.io