@sanity/orderable-document-list

2.0.262.0.27
~

Modified (6 files)

Index: package/dist/index.js
===================================================================
--- package/dist/index.js
+++ package/dist/index.js
@@ -402,24 +402,19 @@
 	for (let cur of flatDocuments) if (cur._id) {
 		if (isVersionId(cur._id)) {
 			let isCorrectVersion = getVersionFromId(cur._id) === perspectiveName;
 			perspectiveName && perspectiveName !== "drafts" && perspectiveName !== "published" && isCorrectVersion && dedupedDocuments.push(cur);
-			continue;
-		}
-		if (perspectiveName === "published") {
-			isPublishedId(cur._id) && dedupedDocuments.push(cur);
-			continue;
-		}
-		if (!isDraftId(cur._id)) {
+		} else if (perspectiveName === "published") isPublishedId(cur._id) && dedupedDocuments.push(cur);
+		else if (isDraftId(cur._id)) {
+			if (perspectiveName && perspectiveName !== "drafts" && perspectiveName !== "published") {
+				let baseId = getPublishedId(cur._id);
+				if (flatDocuments.some((doc) => isVersionForCurrentPerspective(doc, perspectiveName, baseId))) continue;
+			}
+			cur.hasPublished = flatDocuments.some((doc) => doc._id === cur._id.replace("drafts.", "")), dedupedDocuments.push(cur);
+		} else {
 			let publishedId = getPublishedId(cur._id), hasMatchingVersion = perspectiveName && perspectiveName !== "drafts" && perspectiveName !== "published" ? flatDocuments.some((doc) => isVersionForCurrentPerspective(doc, perspectiveName, publishedId)) : !1, hasDraft = flatDocuments.some((doc) => doc._id === `drafts.${cur._id}`), hasDuplicatePublished = flatDocuments.some((doc) => doc !== cur && doc._id === cur._id);
 			!hasMatchingVersion && !hasDraft && !hasDuplicatePublished && dedupedDocuments.push(cur);
-			continue;
 		}
-		if (perspectiveName && perspectiveName !== "drafts" && perspectiveName !== "published") {
-			let baseId = getPublishedId(cur._id);
-			if (flatDocuments.some((doc) => isVersionForCurrentPerspective(doc, perspectiveName, baseId))) continue;
-		}
-		cur.hasPublished = flatDocuments.some((doc) => doc._id === cur._id.replace("drafts.", "")), dedupedDocuments.push(cur);
 	}
 	return dedupedDocuments;
 }, DEFAULT_PARAMS = {};
 function getDocumentQuery({ type, filter, params = DEFAULT_PARAMS, currentVersion }) {
Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,7 +1,7 @@
 {
   "name": "@sanity/orderable-document-list",
-  "version": "2.0.26",
+  "version": "2.0.27",
   "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": "^8.9.0",
     "@sanity/icons": "^5.2.3",
-    "@sanity/ui": "^4.4.0",
+    "@sanity/ui": "^4.4.4",
     "lexorank": "^1.0.5",
-    "sanity-plugin-utils": "^2.0.20"
+    "sanity-plugin-utils": "^2.0.21"
   },
   "devDependencies": {
     "@sanity/tsconfig": "^2.2.1",
-    "@sanity/tsdown-config": "^0.27.1",
+    "@sanity/tsdown-config": "^0.28.8",
     "@types/react": "^19.3.0",
     "@types/react-dom": "^19.3.0",
     "oxc-transform-react": "^0.153.0",
     "react": "^19.3.0",
     "react-dom": "^19.3.0",
-    "sanity": "^6.16.0",
+    "sanity": "^6.18.0",
     "styled-components": "^6.5.3",
-    "tsdown": "^0.22.14"
+    "tsdown": "^0.23.1"
   },
   "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;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;;;;;;EAMF,MAAM;IACJ;MACE;MACA,kBAAkB;;;;iBAKR,wBAAuB,SAAS,OAAM,6CAA0B,IAAA"}
\ 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;;qBAGP,iBAAc,QAAY,oBAAkB;qBCT5C,mBAAmB;UCKf;EACf;EACA;EACA;EACA,OAAO;EACP,SAAS;EACT;EACA,YAAY;EACZ;EACA,SAAS;EACT,GAAG;;wBAGW,8BAA8B,QAAQ,sBAAsB;UCf3D;EACf;IACE;IACA,QAAQ;IACR;IACA,SAAS;IACT;;;;;;EAMF,MAAM;IACJ;MACE;MACA,kBAAkB;;;;wBAKR,wBAAuB,SAAS,OAAM,6CAA0B,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":["{\n  doc,\n  increment,\n  entities,\n  index,\n  isFirst,\n  isLast,\n  dragBadge,\n}: DocumentProps","currentDoc === doc._id || currentDoc === doc._id.replace(`drafts.`, ``)","_id","schema.get(doc._type)","_type","<DocumentStatus\n      draft={versionsInfo.draft}\n      published={versionsInfo.published}\n      versions={versionsInfo.versions}\n    />","draft","published","versions","{flexShrink: 0}","<Box paddingX={2} style={{flexShrink: 0}}>\n          <Text size={2}>\n            <DragHandleIcon cursor=\"grab\" />\n          </Text>\n        </Box>","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        )","{width: `100%`}","<Preview layout=\"default\" value={doc} schemaType={schemaType} />","<Flex align=\"center\" style={{flexShrink: 0}}>\n                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\n                <DocumentStatusIndicator\n                  draft={versionsInfo.draft}\n                  published={versionsInfo.published}\n                  versions={versionsInfo.versions}\n                />\n              </Flex>","<Tooltip content={tooltip} portal placement=\"right\" boundaryElement={null}>\n              <Flex align=\"center\" style={{flexShrink: 0}}>\n                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\n                <DocumentStatusIndicator\n                  draft={versionsInfo.draft}\n                  published={versionsInfo.published}\n                  versions={versionsInfo.versions}\n                />\n              </Flex>\n            </Tooltip>","<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                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\n                <DocumentStatusIndicator\n                  draft={versionsInfo.draft}\n                  published={versionsInfo.published}\n                  versions={versionsInfo.versions}\n                />\n              </Flex>\n            </Tooltip>\n          </Flex>\n        </Box>","dragBadge && (\n          <Card tone=\"default\" marginRight={4} radius={5}>\n            <AvatarCounter count={dragBadge} />\n          </Card>\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                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\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>","<PreviewCard\n      __unstable_focusRing\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                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\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>","_c","{apiVersion: API_VERSION}","useClient({apiVersion: API_VERSION}).withConfig({perspective: perspectiveStack})","useClient({apiVersion: API_VERSION})","_c","{data, listIsUpdating, setListIsUpdating}: DraggableListProps","currentDoc ? [currentDoc] : []","() => setSelectedIds([])","useCallback(() => setSelectedIds([]), [setSelectedIds])","(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    }","(item) => item._id","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  )","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    }","[docId, ops]","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  )","(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    }","selectedIds.length","patches","message","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  )","(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    }","id","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  )","(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    }","result","entities","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  )","(event: KeyboardEvent) => {\n      if (event.key === 'Escape') {\n        clearSelected()\n      }\n    }","useCallback(\n    (event: KeyboardEvent) => {\n      if (event.key === 'Escape') {\n        clearSelected()\n      }\n    },\n    [clearSelected],\n  )","[onWindowKeyDown]","() => {\n    window.addEventListener('keydown', onWindowKeyDown)\n\n    return () => {\n      window.removeEventListener('keydown', onWindowKeyDown)\n    }\n  }","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])","[]","orderField.filter((item, index) => orderField.indexOf(item) !== index)","(item) => item[ORDER_FIELD_NAME]","item","index","(result: DropResult) => handleDragEnd(result, displayedData)","useCallback(\n    (result: DropResult) => handleDragEnd(result, displayedData),\n    [displayedData, handleDragEnd],\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>","displayedData.length","isSelected","<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>","_c","_temp","_temp2","getDocumentQuery(props)","[]","{\n    params: queryParams,\n    initialValue: [],\n  }","Array.isArray(_queryData) ? _queryData : []","useMemo(() => (Array.isArray(_queryData) ? _queryData : []), [_queryData])","getFilteredDedupedDocs(queryData, props.currentVersion)","currentVersion","useMemo(\n    () => getFilteredDedupedDocs(queryData, props.currentVersion),\n    [props.currentVersion, queryData],\n  )","data.filter((doc) => !doc[ORDER_FIELD_NAME])","(doc) => !doc[ORDER_FIELD_NAME]","{width: `100%`, height: `100%`}","<Flex style={{width: `100%`, height: `100%`}} align=\"center\" justify=\"center\">\n        <Spinner />\n      </Flex>","<Box padding={2}>\n        <Feedback tone=\"critical\" title=\"There was an error\" description=\"Please try again later\" />\n      </Box>","<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>","{overflow: `auto`, height: `100%`}","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        )","length","<DraggableList\n          data={data}\n          listIsUpdating={listIsUpdating}\n          setListIsUpdating={setListIsUpdating}\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>","_c","_temp","_Fragment","{\n  type,\n  showIncrements,\n  resetOrderTransaction,\n  filter,\n  params,\n  currentVersion,\n}: DocumentListWrapperProps","{showIncrements}","useMemo(() => ({showIncrements}), [showIncrements])","() => {\n    if (resetOrderTransaction?.title && resetOrderTransaction?.status) {\n      toast.push(resetOrderTransaction)\n    }\n  }","[resetOrderTransaction, toast]","resetOrderTransaction?.title","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          No <code>type</code> was configured\n        </>","<>\n          Schema <code>{type}</code> not found\n        </>","(field) => field?.name === ORDER_FIELD_NAME","<code>{type}</code>","<code>{ORDER_FIELD_NAME}</code>","<code>string</code>","<>\n          Schema <code>{type}</code> must have an <code>{ORDER_FIELD_NAME}</code> field of type{' '}\n          <code>string</code>\n        </>","(field) => field?.name === ORDER_FIELD_NAME && field?.type?.name !== 'string'","<>\n          <code>{ORDER_FIELD_NAME}</code> field on Schema <code>{type}</code> must be{' '}\n          <code>string</code> type\n        </>","<Box padding={2}>\n        <Feedback description={schemaIsInvalid} tone=\"caution\" />\n      </Box>","<DocumentListQuery\n        type={type}\n        filter={filter}\n        params={params}\n        currentVersion={currentVersion}\n      />","<OrderableContext.Provider value={orderableContextValue}>\n      <DocumentListQuery\n        type={type}\n        filter={filter}\n        params={params}\n        currentVersion={currentVersion}\n      />\n    </OrderableContext.Provider>","OrderableContext.Provider","field","_c","_Fragment","_temp","{options, ref}: OrderableDocumentListProps","{}","() => ({\n      actionHandlers: {\n        showIncrements: () => {\n          setShowIncrements((state) => !state)\n        },\n\n        resetOrder: async () => {\n          setResetOrderTransaction({\n            status: `info`,\n            title: `Reordering started...`,\n            closable: true,\n          })\n\n          const update = await resetOrder(options)\n\n          const reorderWasSuccessful = update?.results?.length\n\n          setResetOrderTransaction({\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      // The pane stores this handle in state, so only re-create it when needed\n      // to avoid update loops.\n    })","[options]","(state) => !state","<DocumentListWrapper\n      filter={filter}\n      params={params}\n      type={type}\n      showIncrements={showIncrements}\n      resetOrderTransaction={resetOrderTransaction}\n      currentVersion={currentVersion}\n    />","_c","\"type\""],"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} from '@sanity/ui'\nimport {Tooltip} from '@sanity/ui/tooltip'\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  // oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only\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    // oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only\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      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                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\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} from '@sanity/ui'\nimport {useToast} from '@sanity/ui/toast'\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 {Box} from '@sanity/ui'\nimport {useToast, type ToastParams} from '@sanity/ui/toast'\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/toast'\nimport {useImperativeHandle, useState, type Ref} 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   * Structure menu actions look up `actionHandlers` on the pane component\n   * instance. Expose them via `useImperativeHandle`.\n   */\n  ref?: Ref<{\n    actionHandlers: {\n      showIncrements: () => void\n      resetOrder: () => Promise<void>\n    }\n  }>\n}\n\nexport function OrderableDocumentList({options, ref}: OrderableDocumentListProps) {\n  const [showIncrements, setShowIncrements] = useState(false)\n  const [resetOrderTransaction, setResetOrderTransaction] = useState<ToastParams>({})\n\n  useImperativeHandle(\n    ref,\n    () => ({\n      actionHandlers: {\n        showIncrements: () => {\n          setShowIncrements((state) => !state)\n        },\n\n        resetOrder: async () => {\n          setResetOrderTransaction({\n            status: `info`,\n            title: `Reordering started...`,\n            closable: true,\n          })\n\n          const update = await resetOrder(options)\n\n          const reorderWasSuccessful = update?.results?.length\n\n          setResetOrderTransaction({\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      // The pane stores this handle in state, so only re-create it when needed\n      // to avoid update loops.\n    }),\n    [options],\n  )\n\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={showIncrements}\n      resetOrderTransaction={resetOrderTransaction}\n      currentVersion={currentVersion}\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,MAAa,mBAAmB,aAGnB,cAAc;ACA3B,SAAgB,eAAe,OAAgB,UAA8B;CAC3E,IAAI,OAAO,SA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AC1E,CAAC,CACA,UAAU,GACb;EAEE,oBAAoB;EAEpB,KAAK;EAEL,MAAM;EACN,WAAW;EACX,SAAS;GAAC;GAAM;GAAQ;GAAQ;GAAQ;EAAc;EACtD,WAAW;GACT,GAAG;GACH,EAAE,SAAS,CAAC,CAAC,MAAM,aAAa,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,OAAO,YAAY,CAAC,CAAC,UAAU;GACpF,EAAE,SAAS,CAAC,CACT,MAAM,mBAAmB,CAAC,CAC1B,KAAK,QAAQ,CAAC,CACd,OAAO,gBAAgB,CAAC,CACxB,UAAU;EACf;CACF,CACF,CACF,CAAC,CACA,UAAU;AACf"}
\ No newline at end of file
+{"version":3,"file":"index.js","names":["{\n  doc,\n  increment,\n  entities,\n  index,\n  isFirst,\n  isLast,\n  dragBadge,\n}: DocumentProps","currentDoc === doc._id || currentDoc === doc._id.replace(`drafts.`, ``)","_id","schema.get(doc._type)","_type","<DocumentStatus\n      draft={versionsInfo.draft}\n      published={versionsInfo.published}\n      versions={versionsInfo.versions}\n    />","draft","published","versions","{flexShrink: 0}","<Box paddingX={2} style={{flexShrink: 0}}>\n          <Text size={2}>\n            <DragHandleIcon cursor=\"grab\" />\n          </Text>\n        </Box>","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        )","{width: `100%`}","<Preview layout=\"default\" value={doc} schemaType={schemaType} />","<Flex align=\"center\" style={{flexShrink: 0}}>\n                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\n                <DocumentStatusIndicator\n                  draft={versionsInfo.draft}\n                  published={versionsInfo.published}\n                  versions={versionsInfo.versions}\n                />\n              </Flex>","<Tooltip content={tooltip} portal placement=\"right\" boundaryElement={null}>\n              <Flex align=\"center\" style={{flexShrink: 0}}>\n                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\n                <DocumentStatusIndicator\n                  draft={versionsInfo.draft}\n                  published={versionsInfo.published}\n                  versions={versionsInfo.versions}\n                />\n              </Flex>\n            </Tooltip>","<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                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\n                <DocumentStatusIndicator\n                  draft={versionsInfo.draft}\n                  published={versionsInfo.published}\n                  versions={versionsInfo.versions}\n                />\n              </Flex>\n            </Tooltip>\n          </Flex>\n        </Box>","dragBadge && (\n          <Card tone=\"default\" marginRight={4} radius={5}>\n            <AvatarCounter count={dragBadge} />\n          </Card>\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                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\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>","<PreviewCard\n      __unstable_focusRing\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                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\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>","_c","{apiVersion: API_VERSION}","useClient({apiVersion: API_VERSION}).withConfig({perspective: perspectiveStack})","useClient({apiVersion: API_VERSION})","_c","{data, listIsUpdating, setListIsUpdating}: DraggableListProps","currentDoc ? [currentDoc] : []","() => setSelectedIds([])","useCallback(() => setSelectedIds([]), [setSelectedIds])","(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    }","(item) => item._id","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  )","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    }","[docId, ops]","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  )","(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    }","selectedIds.length","patches","message","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  )","(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    }","id","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  )","(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    }","result","entities","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  )","(event: KeyboardEvent) => {\n      if (event.key === 'Escape') {\n        clearSelected()\n      }\n    }","useCallback(\n    (event: KeyboardEvent) => {\n      if (event.key === 'Escape') {\n        clearSelected()\n      }\n    },\n    [clearSelected],\n  )","[onWindowKeyDown]","() => {\n    window.addEventListener('keydown', onWindowKeyDown)\n\n    return () => {\n      window.removeEventListener('keydown', onWindowKeyDown)\n    }\n  }","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])","[]","orderField.filter((item, index) => orderField.indexOf(item) !== index)","(item) => item[ORDER_FIELD_NAME]","item","index","(result: DropResult) => handleDragEnd(result, displayedData)","useCallback(\n    (result: DropResult) => handleDragEnd(result, displayedData),\n    [displayedData, handleDragEnd],\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>","displayedData.length","isSelected","<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>","_c","_temp","_temp2","getDocumentQuery(props)","[]","{\n    params: queryParams,\n    initialValue: [],\n  }","Array.isArray(_queryData) ? _queryData : []","useMemo(() => (Array.isArray(_queryData) ? _queryData : []), [_queryData])","getFilteredDedupedDocs(queryData, props.currentVersion)","currentVersion","useMemo(\n    () => getFilteredDedupedDocs(queryData, props.currentVersion),\n    [props.currentVersion, queryData],\n  )","data.filter((doc) => !doc[ORDER_FIELD_NAME])","(doc) => !doc[ORDER_FIELD_NAME]","{width: `100%`, height: `100%`}","<Flex style={{width: `100%`, height: `100%`}} align=\"center\" justify=\"center\">\n        <Spinner />\n      </Flex>","<Box padding={2}>\n        <Feedback tone=\"critical\" title=\"There was an error\" description=\"Please try again later\" />\n      </Box>","<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>","{overflow: `auto`, height: `100%`}","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        )","length","<DraggableList\n          data={data}\n          listIsUpdating={listIsUpdating}\n          setListIsUpdating={setListIsUpdating}\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>","_c","_temp","_Fragment","{\n  type,\n  showIncrements,\n  resetOrderTransaction,\n  filter,\n  params,\n  currentVersion,\n}: DocumentListWrapperProps","{showIncrements}","useMemo(() => ({showIncrements}), [showIncrements])","() => {\n    if (resetOrderTransaction?.title && resetOrderTransaction?.status) {\n      toast.push(resetOrderTransaction)\n    }\n  }","[resetOrderTransaction, toast]","resetOrderTransaction?.title","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          No <code>type</code> was configured\n        </>","<>\n          Schema <code>{type}</code> not found\n        </>","(field) => field?.name === ORDER_FIELD_NAME","<code>{type}</code>","<code>{ORDER_FIELD_NAME}</code>","<code>string</code>","<>\n          Schema <code>{type}</code> must have an <code>{ORDER_FIELD_NAME}</code> field of type{' '}\n          <code>string</code>\n        </>","(field) => field?.name === ORDER_FIELD_NAME && field?.type?.name !== 'string'","<>\n          <code>{ORDER_FIELD_NAME}</code> field on Schema <code>{type}</code> must be{' '}\n          <code>string</code> type\n        </>","<Box padding={2}>\n        <Feedback description={schemaIsInvalid} tone=\"caution\" />\n      </Box>","<DocumentListQuery\n        type={type}\n        filter={filter}\n        params={params}\n        currentVersion={currentVersion}\n      />","<OrderableContext.Provider value={orderableContextValue}>\n      <DocumentListQuery\n        type={type}\n        filter={filter}\n        params={params}\n        currentVersion={currentVersion}\n      />\n    </OrderableContext.Provider>","OrderableContext.Provider","field","_c","_Fragment","_temp","{options, ref}: OrderableDocumentListProps","{}","() => ({\n      actionHandlers: {\n        showIncrements: () => {\n          setShowIncrements((state) => !state)\n        },\n\n        resetOrder: async () => {\n          setResetOrderTransaction({\n            status: `info`,\n            title: `Reordering started...`,\n            closable: true,\n          })\n\n          const update = await resetOrder(options)\n\n          const reorderWasSuccessful = update?.results?.length\n\n          setResetOrderTransaction({\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      // The pane stores this handle in state, so only re-create it when needed\n      // to avoid update loops.\n    })","[options]","(state) => !state","<DocumentListWrapper\n      filter={filter}\n      params={params}\n      type={type}\n      showIncrements={showIncrements}\n      resetOrderTransaction={resetOrderTransaction}\n      currentVersion={currentVersion}\n    />","_c","\"type\""],"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} from '@sanity/ui'\nimport {Tooltip} from '@sanity/ui/tooltip'\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  // oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only\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    // oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only\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      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                {/* oxlint-disable-next-line typescript/no-deprecated -- the replacements are sanity 6.11+ only */}\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} from '@sanity/ui'\nimport {useToast} from '@sanity/ui/toast'\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 {Box} from '@sanity/ui'\nimport {useToast, type ToastParams} from '@sanity/ui/toast'\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/toast'\nimport {useImperativeHandle, useState, type Ref} 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   * Structure menu actions look up `actionHandlers` on the pane component\n   * instance. Expose them via `useImperativeHandle`.\n   */\n  ref?: Ref<{\n    actionHandlers: {\n      showIncrements: () => void\n      resetOrder: () => Promise<void>\n    }\n  }>\n}\n\nexport function OrderableDocumentList({options, ref}: OrderableDocumentListProps) {\n  const [showIncrements, setShowIncrements] = useState(false)\n  const [resetOrderTransaction, setResetOrderTransaction] = useState<ToastParams>({})\n\n  useImperativeHandle(\n    ref,\n    () => ({\n      actionHandlers: {\n        showIncrements: () => {\n          setShowIncrements((state) => !state)\n        },\n\n        resetOrder: async () => {\n          setResetOrderTransaction({\n            status: `info`,\n            title: `Reordering started...`,\n            closable: true,\n          })\n\n          const update = await resetOrder(options)\n\n          const reorderWasSuccessful = update?.results?.length\n\n          setResetOrderTransaction({\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      // The pane stores this handle in state, so only re-create it when needed\n      // to avoid update loops.\n    }),\n    [options],\n  )\n\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={showIncrements}\n      resetOrderTransaction={resetOrderTransaction}\n      currentVersion={currentVersion}\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,MAAa,mBAAmB,aAGnB,cAAc;ACA3B,SAAgB,eAAe,OAAgB,UAA8B;CAC3E,IAAI,OAAO,SAAU,UAEnB,OADA,QAAQ,KAAK,wEAAwE,KAAK,GACnF;CAGT,IAAI;EACF,OAAO,SAAS,MAAM,KAAK;CAC7B,SAAS,KAAK;EAOZ,OANA,QAAQ,KACN,8DACA,OACA,UACA,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CACjD,GACO;CACT;AACF;ACbA,SAAgB,YACd,mBAA4B,IAC5B,kBAAmC,SACnC;CACA,IAAM,cAAc,eAAe,kBAAkB,SAAS,IAAI,CAAC;CAInE,QA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ACd,OAAO,gBAAgB,CAAC,CACxB,UAAU;EACf;CACF,CACF,CACF,CAAC,CACA,UAAU;AACf"}
\ No newline at end of file
Index: package/README.md
===================================================================
--- package/README.md
+++ package/README.md
@@ -49,11 +49,11 @@
 The config parameter requires `type`, `S` and `context`. It also accepts `title`, `icon`, `filter` and `params`.
 `S` and `context` are available in desk-tool structure callback, and should be forwarded as is:
 
 ```ts
+import {orderableDocumentListDeskItem} from '@sanity/orderable-document-list'
 import {defineConfig} from 'sanity'
 import {structureTool, StructureBuilder} from 'sanity/structure'
-import {orderableDocumentListDeskItem} from '@sanity/orderable-document-list'
 
 export default defineConfig({
   //...
   plugins: [
Index: package/dist/index.d.ts
===================================================================
--- package/dist/index.d.ts
+++ package/dist/index.d.ts
@@ -7,10 +7,10 @@
 interface RankFieldConfig extends Partial<Omit<StringDefinition, 'name' | 'type' | 'initialValue'>> {
   type: string;
   newItemPosition?: NewItemPosition;
 }
-declare const orderRankField: (config: RankFieldConfig) => FieldDefinition<'string'>;
-declare const orderRankOrdering: SortOrdering;
+export declare const orderRankField: (config: RankFieldConfig) => FieldDefinition<'string'>;
+export declare const orderRankOrdering: SortOrdering;
 interface OrderableListConfig {
   type: string;
   id?: string;
   title?: string;
@@ -21,9 +21,9 @@
   createIntent?: boolean;
   context: ConfigContext;
   S: StructureBuilder;
 }
-declare function orderableDocumentListDeskItem(config: OrderableListConfig): ListItem;
+export declare function orderableDocumentListDeskItem(config: OrderableListConfig): ListItem;
 interface OrderableDocumentListProps {
   options: {
     type: string;
     client: SanityClient;
@@ -41,7 +41,7 @@
       resetOrder: () => Promise<void>;
     };
   }>;
 }
-declare function OrderableDocumentList({ options, ref }: OrderableDocumentListProps): import("react").JSX.Element | null;
-export { OrderableDocumentList, type OrderableListConfig, type RankFieldConfig, orderRankField, orderRankOrdering, orderableDocumentListDeskItem };
+export declare function OrderableDocumentList({ options, ref }: OrderableDocumentListProps): import("react").JSX.Element | null;
+export type { OrderableListConfig, RankFieldConfig };
 //# sourceMappingURL=index.d.ts.map
\ No newline at end of file