@sanity/orderable-document-list 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,2 +1,783 @@
1
- "use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){n(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("sanity"),i=require("lexorank"),s=require("@sanity/icons"),o=require("react/jsx-runtime"),a=require("react"),l=require("@sanity/ui"),d=require("@hello-pangea/dnd"),c=require("sanity/desk");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const p={title:"Ordered",name:"ordered",by:[{field:"orderRank",direction:"asc"}]},h=u(a).default.createContext({});function g(e){let{doc:t,increment:n,entities:i,handleSelect:d,index:c,isFirst:u,isLast:p}=e;const{showIncrements:g}=a.useContext(h),f=r.useSchema();return o.jsxs(l.Flex,{align:"center",children:[o.jsx(l.Box,{paddingX:3,style:{flexShrink:0},children:o.jsx(l.Text,{size:4,children:o.jsx(s.DragHandleIcon,{})})}),g&&o.jsxs(l.Flex,{style:{flexShrink:0},align:"center",gap:1,paddingRight:1,children:[o.jsx(l.Button,{padding:2,mode:"ghost",onClick:()=>n(c,c+-1,t._id,i),disabled:u,icon:s.ChevronUpIcon}),o.jsx(l.Button,{padding:2,mode:"ghost",disabled:p,onClick:()=>n(c,c+1,t._id,i),icon:s.ChevronDownIcon})]}),o.jsx(l.Button,{style:{width:"100%"},padding:2,mode:"bleed",onClick:e=>d(t._id,c,e.nativeEvent),children:o.jsx(l.Flex,{flex:1,align:"center",children:o.jsx(l.Box,{flex:1,children:o.jsx(r.Preview,{layout:"default",value:t,schemaType:f.get(t._type)})})})})]})}function f(e,t){return e.orderRank<t.orderRank?-1:e.orderRank>t.orderRank?1:0}function m(){return r.useClient({apiVersion:"2021-09-01"})}function x(e){let{data:n,type:r,listIsUpdating:s,setListIsUpdating:u}=e;const p=l.useToast(),h=c.usePaneRouter(),{navigateIntent:x}=h,[y,v]=a.useState(n);a.useEffect((()=>{s||v(n)}),[n]);const[b,j]=a.useState(""),[k,R]=a.useState([]),w=a.useCallback((()=>R([])),[R]),O=a.useCallback(((e,t,n)=>{const i=k.includes(e),s=n.shiftKey,o=-1!==navigator.appVersion.indexOf("Win")?n.ctrlKey:n.metaKey;let a=[];if(!s&&!o)return x("edit",{id:e,type:r}),R([e]);if(s&&!i){const n=k[k.length-1],r=y.findIndex((e=>e._id===n)),i=t<r?t:r,s=t>r?t:r,o=y.filter(((e,t)=>t>i&&t<s)).map((e=>e._id));a=[...k,...o,e]}else a=i?k.filter((t=>t!==e)):[...k,e];return R(a)}),[R,x,y,k,r]),I=m(),S=a.useCallback((async(e,t)=>{const n=I.transaction();e.forEach((e=>{let[t,r]=e;return n.patch(t,r)})),await n.commit().then((e=>{w(),j(""),u(!1),p.push({title:"".concat(1===e.results.length?"1 Document":"".concat(e.results.length," Documents")," Reordered"),status:"success",description:t})})).catch((()=>{j(""),u(!1),p.push({title:"Reordering failed",status:"error"})}))}),[I,j,w,u,p]),D=a.useCallback(((e,t)=>{j("");const{source:n,destination:r,draggableId:s}=null!=e?e:{};if((null==n?void 0:n.index)===(null==r?void 0:r.index))return;if(!(null==t?void 0:t.length)||!s)return;const o=(null==k?void 0:k.length)?k:[s];if(!(null==o?void 0:o.length))return;u(!0),R(o);const{newOrder:a,patches:l,message:d}=(e=>{let{entities:t,selectedIds:n,source:r,destination:s,debug:o=!1}=e;const a=r.index,l=s.index,d=a>l,c=t.filter((e=>n.includes(e._id))),u=["Moved",1===c.length?"1 Document":"".concat(c.length," Documents"),d?"up":"down","from position","".concat(a+1," to ").concat(l+1)].join(" "),{all:p,selected:h}=t.reduce(((e,r,s)=>{var o,a,u,p;if(n.includes(r._id))return{all:e.all,selected:e.selected};if(s===l){const n=s-1,l=(null==(o=t[n])?void 0:o.orderRank)?i.LexoRank.parse(null==(a=t[n])?void 0:a.orderRank):i.LexoRank.min(),h=i.LexoRank.parse(t[s].orderRank),g=s+1,f=(null==(u=t[g])?void 0:u.orderRank)?i.LexoRank.parse(null==(p=t[g])?void 0:p.orderRank):i.LexoRank.max();let m=d?l.between(h):h.between(f);for(let e=0;e<c.length;e+=1)c[e].orderRank=m.value,m=d?m.between(h):m.between(f);return{all:d?[...e.all,...c,r]:[...e.all,r,...c],selected:c}}return{all:[...e.all,r],selected:e.selected}}),{all:[],selected:[]}),g=h.map((e=>[e._id,{set:{orderRank:e.orderRank}}]));return{newOrder:p.sort(f),patches:g,message:u}})({entities:t,selectedIds:o,source:n,destination:r});(null==a?void 0:a.length)&&v(a),(null==l?void 0:l.length)&&S(l,d)}),[k,j,R,S,u]),_=a.useCallback((e=>{const t=e.draggableId;k.includes(t)||w(),j(t)}),[k,w,j]),C=a.useCallback(((e,t,n,r)=>D({draggableId:n,source:{index:e},destination:{index:t}},r)),[D]),E=a.useCallback((e=>{"Escape"===e.key&&w()}),[w]);a.useEffect((()=>(window.addEventListener("keydown",E),()=>{window.removeEventListener("keydown",E)})),[E]);const L=a.useMemo((()=>{if(!y.length)return[];const e=y.map((e=>e.orderRank));return e.filter(((t,n)=>e.indexOf(t)!==n))}),[y]),P=a.useCallback((e=>D(e,y)),[y,D]);return o.jsx(d.DragDropContext,{onDragStart:_,onDragEnd:P,children:o.jsx(d.Droppable,{droppableId:"documentSortZone",children:e=>o.jsxs("div",t(t({},e.droppableProps),{},{ref:e.innerRef,children:[y.map(((e,n)=>o.jsx(d.Draggable,{draggableId:e._id,index:n,children:(r,i)=>{const a=k.includes(e._id),d=i.isDragging,c=Boolean(!d&&b&&a),u=s&&a,p=Boolean(!e.orderRank),h=(e=>{const{isDuplicate:t,isGhosting:n,isDragging:r,isSelected:i}=e;return n?"transparent":r||i?"primary":t?"caution":void 0})({isDuplicate:L.includes(e.orderRank),isGhosting:c,isDragging:d,isSelected:a});return o.jsx("div",t(t(t({ref:r.innerRef},r.draggableProps),r.dragHandleProps),{},{style:p?{opacity:.2,pointerEvents:"none"}:(f=r.draggableProps.style,m=u,t({userSelect:"none",transition:"opacity 500ms ease-in-out",opacity:m?.2:1,pointerEvents:m?"none":void 0},f)),children:o.jsx(l.Box,{paddingBottom:1,children:o.jsx(l.Card,{tone:h,shadow:d?2:void 0,radius:2,children:o.jsx(g,{doc:e,entities:y,handleSelect:O,increment:C,index:n,isFirst:0===n,isLast:n===y.length-1})})})}));var f,m}},"".concat(e._id,"-").concat(e.orderRank)))),e.placeholder]}))})})}function y(e){let{children:t}=e;return o.jsx(l.Box,{padding:3,children:o.jsx(l.Card,{padding:4,radius:2,shadow:1,tone:"caution",children:o.jsx(l.Text,{children:t})})})}const v={};function b(e){let{type:t,filter:n,params:r=v}=e;const[i,s]=a.useState(!0),[d,c]=a.useState(!1),[u,p]=a.useState([]),h=m();a.useEffect((()=>{const e="*[_type == $type ".concat(n?"&& ".concat(n):"","]|order(@[$order] asc){\n _id, _type, ").concat("orderRank","\n }"),o=Object.assign(r,{type:t,order:"orderRank"});let a;const l=async()=>{h.fetch(e,o).then((e=>{const t=e.reduce(((t,n)=>{if(!n._id.startsWith("drafts.")){return e.some((e=>e._id==="drafts.".concat(n._id)))?t:[...t,n]}return[...t,n]}),[]);p(t),i&&s(!1)}))};return d||u.length||(async()=>{s(!0),await l(),a||(a=h.listen(e,o).subscribe((()=>l())))})(),()=>null==a?void 0:a.unsubscribe()}),[t]);const g=a.useMemo((()=>u.length?u.filter((e=>!e.orderRank)).length:0),[u]);return i?o.jsx(l.Flex,{style:{width:"100%",height:"100%"},align:"center",justify:"center",children:o.jsx(l.Spinner,{})}):o.jsxs(l.Stack,{space:1,style:{overflow:"auto",height:"100%"},children:[g>0&&o.jsxs(y,{children:[g,"/",u.length," Documents have no Order. Select"," ",o.jsx("strong",{children:"Reset Order"})," from the Menu above to fix."]}),o.jsx(l.Box,{padding:1,children:o.jsx(x,{data:u,type:t,listIsUpdating:d,setListIsUpdating:c})})]})}function j(e){let{type:t,showIncrements:n,resetOrderTransaction:i,filter:s,params:d}=e;const c=l.useToast(),u=r.useSchema();a.useEffect((()=>{(null==i?void 0:i.title)&&(null==i?void 0:i.status)&&c.push(i)}),[i,c]);const p=a.useMemo((()=>{if(!t)return o.jsxs(o.Fragment,{children:["No ",o.jsx("code",{children:"type"})," was configured"]});const e=u.get(t);return e?"fields"in e&&e.fields.some((e=>"orderRank"===(null==e?void 0:e.name)))?"fields"in e&&e.fields.some((e=>{var t;return"orderRank"===(null==e?void 0:e.name)&&"string"!==(null==(t=null==e?void 0:e.type)?void 0:t.name)}))?o.jsxs(o.Fragment,{children:[o.jsx("code",{children:"orderRank"})," field on Schema ",o.jsx("code",{children:t})," must be"," ",o.jsx("code",{children:"string"})," type"]}):"":o.jsxs(o.Fragment,{children:["Schema ",o.jsx("code",{children:t})," must have an ",o.jsx("code",{children:"orderRank"})," field of type"," ",o.jsx("code",{children:"string"})]}):o.jsxs(o.Fragment,{children:["Schema ",o.jsx("code",{children:t})," not found"]})}),[t,u]);return p?o.jsx(y,{children:p}):o.jsx(h.Provider,{value:{showIncrements:n},children:o.jsx(b,{type:t,filter:s,params:d})})}class k extends a.Component{constructor(e){super(e),this.actionHandlers={showIncrements:()=>{this.setState((e=>({showIncrements:!e.showIncrements})))},resetOrder:async()=>{var e;this.setState((()=>({resetOrderTransaction:{status:"info",title:"Reordering started...",closable:!0}})));const t=await async function(){let e=arguments.length>1?arguments[1]:void 0;const t="*[_type == $type]|order(@[$order] asc)._id",n={type:arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",order:"orderRank"},r=await e.fetch(t,n);if(!r.length)return null;const s=e.transaction();let o=i.LexoRank.min();for(let e=0;e<r.length;e+=1)o=o.genNext().genNext(),s.patch(r[e],{set:{orderRank:o.value}});return s.commit().then((e=>e)).catch((e=>e))}(this.props.options.type,this.props.options.client),n=null==(e=null==t?void 0:t.results)?void 0:e.length;this.setState((()=>({resetOrderTransaction:{status:n?"success":"info",title:n?"Reordered ".concat(1===t.results.length?"Document":"Documents"):"Reordering failed",closable:!0}})))}},this.state={showIncrements:!1,resetOrderTransaction:{}}}render(){var e,t,n,r,i,s;const a=null==(t=null==(e=null==this?void 0:this.props)?void 0:e.options)?void 0:t.type;return a?o.jsx(j,{filter:null==(r=null==(n=null==this?void 0:this.props)?void 0:n.options)?void 0:r.filter,params:null==(s=null==(i=null==this?void 0:this.props)?void 0:i.options)?void 0:s.params,type:a,showIncrements:this.state.showIncrements,resetOrderTransaction:this.state.resetOrderTransaction}):null}}exports.orderRankField=e=>{if(!(null==e?void 0:e.type))throw new Error("\n type must be provided.\n Example: orderRankField({type: 'category'})\n ");const{type:n}=e;return r.defineField(t(t({title:"Order Rank",readOnly:!0,hidden:!0},e),{},{name:"orderRank",type:"string",initialValue:async(e,t)=>{let{getClient:r}=t;return function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const t=e?i.LexoRank.parse(e):i.LexoRank.min();return t.genNext().genNext().value}(await r({apiVersion:"2021-09-01"}).fetch("*[_type == $type]|order(@[$order] desc)[0][$order]",{type:n,order:"orderRank"}))}}))},exports.orderRankOrdering=p,exports.orderableDocumentListDeskItem=function(e){var t,n;if(!(null==e?void 0:e.type)||!e.context||!e.S)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 ");const{type:r,filter:i,params:o,title:a,icon:l,id:d,context:c,S:u}=e,{schema:p,getClient:h}=c,g=h({apiVersion:"2021-09-01"}),f=null!=a?a:"Orderable ".concat(r),m=null!=d?d:"orderable-".concat(r),x=null!=l?l:s.SortIcon,y=null!=(n=null==(t=p.get(r))?void 0:t.title)?n:r;return u.listItem().title(f).id(m).icon(x).child(Object.assign(u.documentTypeList(r).serialize(),{__preserveInstance:!0,key:m,type:"component",component:k,options:{type:r,filter:i,params:o,client:g},menuItems:[u.menuItem().title("Create new ".concat(y)).intent({type:"create",params:{type:r}}).serialize(),u.menuItem().title("Reset Order").icon(s.GenerateIcon).action("resetOrder").serialize(),u.menuItem().title("Show Increments").icon(s.SortIcon).action("showIncrements").serialize()]})).serialize()};
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ });
6
+ var sanity = require('sanity');
7
+ var lexorank = require('lexorank');
8
+ var icons = require('@sanity/icons');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+ var React = require('react');
11
+ var ui = require('@sanity/ui');
12
+ var sanityPluginUtils = require('sanity-plugin-utils');
13
+ var dnd = require('@hello-pangea/dnd');
14
+ var desk = require('sanity/desk');
15
+ function _interopDefaultCompat(e) {
16
+ return e && typeof e === 'object' && 'default' in e ? e : {
17
+ default: e
18
+ };
19
+ }
20
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
21
+ const ORDER_FIELD_NAME = "orderRank";
22
+ function initialRank() {
23
+ let lastRankValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
24
+ const lastRank = lastRankValue ? lexorank.LexoRank.parse(lastRankValue) : lexorank.LexoRank.min();
25
+ const nextRank = lastRank.genNext().genNext();
26
+ return nextRank.toString();
27
+ }
28
+ const orderRankField = config => {
29
+ if (!(config == null ? void 0 : config.type)) {
30
+ throw new Error("\n type must be provided.\n Example: orderRankField({type: 'category'})\n ");
31
+ }
32
+ const {
33
+ type
34
+ } = config;
35
+ return sanity.defineField({
36
+ title: "Order Rank",
37
+ readOnly: true,
38
+ hidden: true,
39
+ ...config,
40
+ name: ORDER_FIELD_NAME,
41
+ type: "string",
42
+ initialValue: async (p, _ref) => {
43
+ let {
44
+ getClient
45
+ } = _ref;
46
+ const lastDocOrderRank = await getClient({
47
+ apiVersion: "2021-09-01"
48
+ }).fetch("*[_type == $type]|order(@[$order] desc)[0][$order]", {
49
+ type,
50
+ order: ORDER_FIELD_NAME
51
+ });
52
+ return initialRank(lastDocOrderRank);
53
+ }
54
+ });
55
+ };
56
+ const orderRankOrdering = {
57
+ title: "Ordered",
58
+ name: "ordered",
59
+ by: [{
60
+ field: ORDER_FIELD_NAME,
61
+ direction: "asc"
62
+ }]
63
+ };
64
+ const OrderableContext = React__default.default.createContext({});
65
+ function Document(_ref2) {
66
+ let {
67
+ doc,
68
+ increment,
69
+ entities,
70
+ index,
71
+ isFirst,
72
+ isLast,
73
+ dragBadge
74
+ } = _ref2;
75
+ var _a, _b;
76
+ const {
77
+ showIncrements
78
+ } = React.useContext(OrderableContext);
79
+ const schema = sanity.useSchema();
80
+ const router = desk.usePaneRouter();
81
+ const {
82
+ ChildLink,
83
+ groupIndex,
84
+ routerPanesState
85
+ } = router;
86
+ const currentDoc = ((_b = (_a = routerPanesState[groupIndex + 1]) == null ? void 0 : _a[0]) == null ? void 0 : _b.id) || false;
87
+ const pressed = currentDoc === doc._id || currentDoc === doc._id.replace("drafts.", "");
88
+ const selected = pressed && routerPanesState.length === groupIndex + 2;
89
+ const Link = React.useMemo(() => function LinkComponent(linkProps) {
90
+ return /* @__PURE__ */jsxRuntime.jsx(ChildLink, {
91
+ ...linkProps,
92
+ childId: doc._id
93
+ });
94
+ }, [ChildLink, doc._id]);
95
+ return /* @__PURE__ */jsxRuntime.jsx(sanity.PreviewCard, {
96
+ __unstable_focusRing: true,
97
+ as: Link,
98
+ "data-as": "a",
99
+ "data-ui": "PaneItem",
100
+ radius: 2,
101
+ pressed,
102
+ selected,
103
+ sizing: "border",
104
+ tabIndex: -1,
105
+ tone: "inherit",
106
+ width: "100%",
107
+ flex: 1,
108
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
109
+ align: "center",
110
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
111
+ paddingX: 3,
112
+ style: {
113
+ flexShrink: 0
114
+ },
115
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
116
+ size: 2,
117
+ children: /* @__PURE__ */jsxRuntime.jsx(icons.DragHandleIcon, {
118
+ cursor: "grab"
119
+ })
120
+ })
121
+ }), showIncrements && /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
122
+ style: {
123
+ flexShrink: 0
124
+ },
125
+ align: "center",
126
+ gap: 1,
127
+ paddingRight: 1,
128
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Button, {
129
+ padding: 2,
130
+ mode: "ghost",
131
+ onClick: () => increment(index, index + -1, doc._id, entities),
132
+ disabled: isFirst,
133
+ icon: icons.ChevronUpIcon
134
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
135
+ padding: 2,
136
+ mode: "ghost",
137
+ disabled: isLast,
138
+ onClick: () => increment(index, index + 1, doc._id, entities),
139
+ icon: icons.ChevronDownIcon
140
+ })]
141
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
142
+ style: {
143
+ width: "100%"
144
+ },
145
+ padding: 2,
146
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
147
+ flex: 1,
148
+ align: "center",
149
+ children: /* @__PURE__ */jsxRuntime.jsx(sanity.Preview, {
150
+ layout: "default",
151
+ value: doc,
152
+ schemaType: schema.get(doc._type)
153
+ })
154
+ })
155
+ }), dragBadge && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
156
+ tone: "default",
157
+ marginRight: 4,
158
+ radius: 5,
159
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.AvatarCounter, {
160
+ count: dragBadge
161
+ })
162
+ })]
163
+ })
164
+ });
165
+ }
166
+ function lexicographicalSort(a, b) {
167
+ if (!a[ORDER_FIELD_NAME] || !b[ORDER_FIELD_NAME]) {
168
+ return 0;
169
+ } else if (a[ORDER_FIELD_NAME] < b[ORDER_FIELD_NAME]) {
170
+ return -1;
171
+ } else if (a[ORDER_FIELD_NAME] > b[ORDER_FIELD_NAME]) {
172
+ return 1;
173
+ }
174
+ return 0;
175
+ }
176
+ const reorderDocuments = _ref3 => {
177
+ let {
178
+ entities,
179
+ selectedIds,
180
+ source,
181
+ destination
182
+ } = _ref3;
183
+ const startIndex = source.index;
184
+ const endIndex = destination.index;
185
+ const isMovingUp = startIndex > endIndex;
186
+ const selectedItems = entities.filter(item => selectedIds.includes(item._id));
187
+ const message = ["Moved", selectedItems.length === 1 ? "1 document" : "".concat(selectedItems.length, " documents"), isMovingUp ? "up" : "down", "from position", "".concat(startIndex + 1, " to ").concat(endIndex + 1)].join(" ");
188
+ const {
189
+ all,
190
+ selected
191
+ } = entities.reduce((acc, cur, curIndex) => {
192
+ var _a, _b, _c, _d;
193
+ if (selectedIds.includes(cur._id)) {
194
+ return {
195
+ all: acc.all,
196
+ selected: acc.selected
197
+ };
198
+ }
199
+ if (curIndex === endIndex) {
200
+ const prevIndex = curIndex - 1;
201
+ const prevRank = ((_a = entities[prevIndex]) == null ? void 0 : _a[ORDER_FIELD_NAME]) ? lexorank.LexoRank.parse((_b = entities[prevIndex]) == null ? void 0 : _b[ORDER_FIELD_NAME]) : lexorank.LexoRank.min();
202
+ const curRank = lexorank.LexoRank.parse(entities[curIndex][ORDER_FIELD_NAME]);
203
+ const nextIndex = curIndex + 1;
204
+ const nextRank = ((_c = entities[nextIndex]) == null ? void 0 : _c[ORDER_FIELD_NAME]) ? lexorank.LexoRank.parse((_d = entities[nextIndex]) == null ? void 0 : _d[ORDER_FIELD_NAME]) : lexorank.LexoRank.max();
205
+ let betweenRank = isMovingUp ? prevRank.between(curRank) : curRank.between(nextRank);
206
+ for (let selectedIndex = 0; selectedIndex < selectedItems.length; selectedIndex += 1) {
207
+ selectedItems[selectedIndex][ORDER_FIELD_NAME] = betweenRank.toString();
208
+ betweenRank = isMovingUp ? betweenRank.between(curRank) : betweenRank.between(nextRank);
209
+ }
210
+ return {
211
+ // The `all` array gets sorted by order field later anyway
212
+ // so that this probably isn't necessary ¯\_(ツ)_/¯
213
+ all: isMovingUp ? [...acc.all, ...selectedItems, cur] : [...acc.all, cur, ...selectedItems],
214
+ selected: selectedItems
215
+ };
216
+ }
217
+ return {
218
+ all: [...acc.all, cur],
219
+ selected: acc.selected
220
+ };
221
+ }, {
222
+ all: [],
223
+ selected: []
224
+ });
225
+ const patches = selected.flatMap(doc => {
226
+ const docPatches = [[doc._id, {
227
+ set: {
228
+ [ORDER_FIELD_NAME]: doc[ORDER_FIELD_NAME]
229
+ }
230
+ }]];
231
+ if (doc._id.startsWith("drafts.") && doc.hasPublished) {
232
+ docPatches.push([doc._id.replace("drafts.", ""), {
233
+ set: {
234
+ [ORDER_FIELD_NAME]: doc[ORDER_FIELD_NAME]
235
+ }
236
+ }]);
237
+ }
238
+ return docPatches;
239
+ });
240
+ const allSorted = all.sort(lexicographicalSort);
241
+ return {
242
+ newOrder: allSorted,
243
+ patches,
244
+ message
245
+ };
246
+ };
247
+ function useSanityClient() {
248
+ return sanity.useClient({
249
+ apiVersion: "2021-09-01"
250
+ });
251
+ }
252
+ const getItemStyle = (draggableStyle, itemIsUpdating) => ({
253
+ userSelect: "none",
254
+ transition: "opacity 500ms ease-in-out",
255
+ opacity: itemIsUpdating ? 0.2 : 1,
256
+ pointerEvents: itemIsUpdating ? "none" : void 0,
257
+ ...draggableStyle
258
+ });
259
+ const cardTone = settings => {
260
+ const {
261
+ isDuplicate,
262
+ isGhosting,
263
+ isDragging,
264
+ isSelected
265
+ } = settings;
266
+ if (isGhosting) return "transparent";
267
+ if (isDragging || isSelected) return "primary";
268
+ if (isDuplicate) return "caution";
269
+ return void 0;
270
+ };
271
+ function DraggableList(_ref4) {
272
+ let {
273
+ data,
274
+ listIsUpdating,
275
+ setListIsUpdating
276
+ } = _ref4;
277
+ var _a, _b;
278
+ const toast = ui.useToast();
279
+ const router = desk.usePaneRouter();
280
+ const {
281
+ groupIndex,
282
+ routerPanesState
283
+ } = router;
284
+ const currentDoc = ((_b = (_a = routerPanesState[groupIndex + 1]) == null ? void 0 : _a[0]) == null ? void 0 : _b.id) || false;
285
+ const [orderedData, setOrderedData] = React.useState(data);
286
+ React.useEffect(() => {
287
+ if (!listIsUpdating) setOrderedData(data);
288
+ }, [data]);
289
+ const [draggingId, setDraggingId] = React.useState("");
290
+ const [selectedIds, setSelectedIds] = React.useState(currentDoc ? [currentDoc] : []);
291
+ const clearSelected = React.useCallback(() => setSelectedIds([]), [setSelectedIds]);
292
+ const handleSelect = React.useCallback((clickedId, index, nativeEvent) => {
293
+ const isSelected = selectedIds.includes(clickedId);
294
+ const selectMultiple = nativeEvent.shiftKey;
295
+ const isUsingWindows = navigator.appVersion.indexOf("Win") !== -1;
296
+ const selectAdditional = isUsingWindows ? nativeEvent.ctrlKey : nativeEvent.metaKey;
297
+ let updatedIds = [];
298
+ if (!selectMultiple && !selectAdditional) {
299
+ return setSelectedIds([clickedId]);
300
+ }
301
+ if (selectMultiple) {
302
+ nativeEvent.preventDefault();
303
+ }
304
+ if (selectMultiple && !isSelected) {
305
+ const lastSelectedId = selectedIds[selectedIds.length - 1];
306
+ const lastSelectedIndex = orderedData.findIndex(item => item._id === lastSelectedId);
307
+ const firstSelected = index < lastSelectedIndex ? index : lastSelectedIndex;
308
+ const lastSelected = index > lastSelectedIndex ? index : lastSelectedIndex;
309
+ const betweenIds = orderedData.filter((item, itemIndex) => itemIndex > firstSelected && itemIndex < lastSelected).map(item => item._id);
310
+ updatedIds = [...selectedIds, ...betweenIds, clickedId];
311
+ } else if (isSelected) {
312
+ updatedIds = selectedIds.filter(id => id !== clickedId);
313
+ } else {
314
+ updatedIds = [...selectedIds, clickedId];
315
+ }
316
+ return setSelectedIds(updatedIds);
317
+ }, [setSelectedIds, orderedData, selectedIds]);
318
+ const client = useSanityClient();
319
+ const transactPatches = React.useCallback(async (patches, message) => {
320
+ const transaction = client.transaction();
321
+ patches.forEach(_ref5 => {
322
+ let [docId, ops] = _ref5;
323
+ return transaction.patch(docId, ops);
324
+ });
325
+ await transaction.commit().then(updated => {
326
+ clearSelected();
327
+ setDraggingId("");
328
+ setListIsUpdating(false);
329
+ toast.push({
330
+ title: "".concat(updated.results.length === 1 ? "1 Document" : "".concat(updated.results.length, " Documents"), " Reordered"),
331
+ status: "success",
332
+ description: message
333
+ });
334
+ }).catch(() => {
335
+ setDraggingId("");
336
+ setListIsUpdating(false);
337
+ toast.push({
338
+ title: "Reordering failed",
339
+ status: "error"
340
+ });
341
+ });
342
+ }, [client, setDraggingId, clearSelected, setListIsUpdating, toast]);
343
+ const handleDragEnd = React.useCallback((result, entities) => {
344
+ setDraggingId("");
345
+ const {
346
+ source,
347
+ destination,
348
+ draggableId
349
+ } = result != null ? result : {};
350
+ if ((source == null ? void 0 : source.index) === (destination == null ? void 0 : destination.index)) return;
351
+ if (!(entities == null ? void 0 : entities.length) || !draggableId) return;
352
+ const effectedIds = (selectedIds == null ? void 0 : selectedIds.length) ? selectedIds : [draggableId];
353
+ if (!(effectedIds == null ? void 0 : effectedIds.length)) return;
354
+ setListIsUpdating(true);
355
+ setSelectedIds(effectedIds);
356
+ const {
357
+ newOrder,
358
+ patches,
359
+ message
360
+ } = reorderDocuments({
361
+ entities,
362
+ selectedIds: effectedIds,
363
+ source,
364
+ destination
365
+ });
366
+ if (newOrder == null ? void 0 : newOrder.length) {
367
+ setOrderedData(newOrder);
368
+ }
369
+ if (patches == null ? void 0 : patches.length) {
370
+ transactPatches(patches, message);
371
+ }
372
+ }, [selectedIds, setDraggingId, setSelectedIds, transactPatches, setListIsUpdating]);
373
+ const handleDragStart = React.useCallback(start => {
374
+ const id = start.draggableId;
375
+ const selected = selectedIds.includes(id);
376
+ if (!selected) clearSelected();
377
+ setDraggingId(id);
378
+ }, [selectedIds, clearSelected, setDraggingId]);
379
+ const incrementIndex = React.useCallback((shiftFrom, shiftTo, id, entities) => {
380
+ const result = {
381
+ draggableId: id,
382
+ source: {
383
+ index: shiftFrom
384
+ },
385
+ destination: {
386
+ index: shiftTo
387
+ }
388
+ };
389
+ return handleDragEnd(result, entities);
390
+ }, [handleDragEnd]);
391
+ const onWindowKeyDown = React.useCallback(event => {
392
+ if (event.key === "Escape") {
393
+ clearSelected();
394
+ }
395
+ }, [clearSelected]);
396
+ React.useEffect(() => {
397
+ window.addEventListener("keydown", onWindowKeyDown);
398
+ return () => {
399
+ window.removeEventListener("keydown", onWindowKeyDown);
400
+ };
401
+ }, [onWindowKeyDown]);
402
+ const duplicateOrders = React.useMemo(() => {
403
+ if (!orderedData.length) return [];
404
+ const orderField = orderedData.map(item => item[ORDER_FIELD_NAME]);
405
+ return orderField.filter((item, index) => orderField.indexOf(item) !== index);
406
+ }, [orderedData]);
407
+ const onDragEnd = React.useCallback(result => handleDragEnd(result, orderedData), [orderedData, handleDragEnd]);
408
+ return /* @__PURE__ */jsxRuntime.jsx(dnd.DragDropContext, {
409
+ onDragStart: handleDragStart,
410
+ onDragEnd,
411
+ children: /* @__PURE__ */jsxRuntime.jsx(dnd.Droppable, {
412
+ droppableId: "documentSortZone",
413
+ children: provided => /* @__PURE__ */jsxRuntime.jsxs("div", {
414
+ ...provided.droppableProps,
415
+ ref: provided.innerRef,
416
+ children: [orderedData.map((item, index) => /* @__PURE__ */jsxRuntime.jsx(dnd.Draggable, {
417
+ draggableId: item._id,
418
+ index,
419
+ children: (innerProvided, innerSnapshot) => {
420
+ const isSelected = selectedIds.includes(item._id);
421
+ const isDragging = innerSnapshot.isDragging;
422
+ const isGhosting = Boolean(!isDragging && draggingId && isSelected);
423
+ const isUpdating = listIsUpdating && isSelected;
424
+ const isDisabled = Boolean(!item[ORDER_FIELD_NAME]);
425
+ const isDuplicate = duplicateOrders.includes(item[ORDER_FIELD_NAME]);
426
+ const tone = cardTone({
427
+ isDuplicate,
428
+ isGhosting,
429
+ isDragging,
430
+ isSelected
431
+ });
432
+ const selectedCount = selectedIds.length;
433
+ const dragBadge = isDragging && selectedCount > 1 ? selectedCount : false;
434
+ return /* @__PURE__ */jsxRuntime.jsx("div", {
435
+ ref: innerProvided.innerRef,
436
+ ...innerProvided.draggableProps,
437
+ ...innerProvided.dragHandleProps,
438
+ style: isDisabled ? {
439
+ opacity: 0.2,
440
+ pointerEvents: "none"
441
+ } : getItemStyle(innerProvided.draggableProps.style, isUpdating),
442
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
443
+ paddingBottom: 1,
444
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
445
+ tone,
446
+ shadow: isDragging ? 2 : void 0,
447
+ radius: 2,
448
+ onClick: e => handleSelect(item._id, index, e.nativeEvent),
449
+ children: /* @__PURE__ */jsxRuntime.jsx(Document, {
450
+ doc: item,
451
+ entities: orderedData,
452
+ increment: incrementIndex,
453
+ index,
454
+ isFirst: index === 0,
455
+ isLast: index === orderedData.length - 1,
456
+ dragBadge
457
+ })
458
+ })
459
+ })
460
+ });
461
+ }
462
+ }, "".concat(item._id, "-").concat(item[ORDER_FIELD_NAME]))), provided.placeholder]
463
+ })
464
+ })
465
+ });
466
+ }
467
+ const DEFAULT_PARAMS = {};
468
+ function DocumentListQuery(_ref6) {
469
+ let {
470
+ type,
471
+ filter,
472
+ params = DEFAULT_PARAMS
473
+ } = _ref6;
474
+ const [listIsUpdating, setListIsUpdating] = React.useState(false);
475
+ const [data, setData] = React.useState([]);
476
+ const query = "*[_type == $type ".concat(filter ? "&& ".concat(filter) : "", "]|order(@[$order] asc){\n _id, _type, ").concat(ORDER_FIELD_NAME, "\n }");
477
+ const queryParams = {
478
+ ...params,
479
+ type,
480
+ order: ORDER_FIELD_NAME
481
+ };
482
+ const {
483
+ data: queryData,
484
+ loading,
485
+ error
486
+ } = sanityPluginUtils.useListeningQuery(query, {
487
+ params: queryParams,
488
+ initialValue: []
489
+ });
490
+ React.useEffect(() => {
491
+ if (queryData) {
492
+ const filteredDocuments = queryData.reduce((acc, cur) => {
493
+ if (!cur._id.startsWith("drafts.")) {
494
+ const alsoHasDraft = queryData.some(doc => doc._id === "drafts.".concat(cur._id));
495
+ return alsoHasDraft ? acc : [...acc, cur];
496
+ }
497
+ cur.hasPublished = queryData.some(doc => doc._id === cur._id.replace("drafts.", ""));
498
+ return [...acc, cur];
499
+ }, []);
500
+ setData(filteredDocuments);
501
+ } else {
502
+ setData([]);
503
+ }
504
+ }, [queryData]);
505
+ const unorderedDataCount = React.useMemo(() => (data == null ? void 0 : data.length) ? data.filter(doc => !doc[ORDER_FIELD_NAME]).length : 0, [data]);
506
+ if (loading) {
507
+ return /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
508
+ style: {
509
+ width: "100%",
510
+ height: "100%"
511
+ },
512
+ align: "center",
513
+ justify: "center",
514
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {})
515
+ });
516
+ }
517
+ if (error) {
518
+ return /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
519
+ padding: 2,
520
+ children: /* @__PURE__ */jsxRuntime.jsx(sanityPluginUtils.Feedback, {
521
+ tone: "critical",
522
+ title: "There was an error",
523
+ description: "Please try again later"
524
+ })
525
+ });
526
+ }
527
+ if (!data || (data == null ? void 0 : data.length) == 0) return /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
528
+ align: "center",
529
+ direction: "column",
530
+ height: "fill",
531
+ justify: "center",
532
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Container, {
533
+ width: 1,
534
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
535
+ paddingX: 4,
536
+ paddingY: 5,
537
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
538
+ align: "center",
539
+ muted: true,
540
+ children: "No documents of this type"
541
+ })
542
+ })
543
+ })
544
+ });
545
+ return /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
546
+ space: 1,
547
+ style: {
548
+ overflow: "auto",
549
+ height: "100%"
550
+ },
551
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Box, {
552
+ padding: 2,
553
+ children: [unorderedDataCount > 0 && /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
554
+ marginBottom: 2,
555
+ children: /* @__PURE__ */jsxRuntime.jsx(sanityPluginUtils.Feedback, {
556
+ tone: "caution",
557
+ description: /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
558
+ children: [unorderedDataCount, "/", data == null ? void 0 : data.length, " documents have no order. Select", " ", /* @__PURE__ */jsxRuntime.jsx("strong", {
559
+ children: "Reset Order"
560
+ }), " from the menu above to fix."]
561
+ })
562
+ })
563
+ }), /* @__PURE__ */jsxRuntime.jsx(DraggableList, {
564
+ data,
565
+ listIsUpdating,
566
+ setListIsUpdating
567
+ })]
568
+ })
569
+ });
570
+ }
571
+ function DocumentListWrapper(_ref7) {
572
+ let {
573
+ type,
574
+ showIncrements,
575
+ resetOrderTransaction,
576
+ filter,
577
+ params
578
+ } = _ref7;
579
+ const toast = ui.useToast();
580
+ const schema = sanity.useSchema();
581
+ React.useEffect(() => {
582
+ if ((resetOrderTransaction == null ? void 0 : resetOrderTransaction.title) && (resetOrderTransaction == null ? void 0 : resetOrderTransaction.status)) {
583
+ toast.push(resetOrderTransaction);
584
+ }
585
+ }, [resetOrderTransaction, toast]);
586
+ const schemaIsInvalid = React.useMemo(() => {
587
+ if (!type) {
588
+ return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
589
+ children: ["No ", /* @__PURE__ */jsxRuntime.jsx("code", {
590
+ children: "type"
591
+ }), " was configured"]
592
+ });
593
+ }
594
+ const typeSchema = schema.get(type);
595
+ if (!typeSchema) {
596
+ return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
597
+ children: ["Schema ", /* @__PURE__ */jsxRuntime.jsx("code", {
598
+ children: type
599
+ }), " not found"]
600
+ });
601
+ }
602
+ if (!("fields" in typeSchema) || !typeSchema.fields.some(field => (field == null ? void 0 : field.name) === ORDER_FIELD_NAME)) {
603
+ return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
604
+ children: ["Schema ", /* @__PURE__ */jsxRuntime.jsx("code", {
605
+ children: type
606
+ }), " must have an ", /* @__PURE__ */jsxRuntime.jsx("code", {
607
+ children: ORDER_FIELD_NAME
608
+ }), " field of type", " ", /* @__PURE__ */jsxRuntime.jsx("code", {
609
+ children: "string"
610
+ })]
611
+ });
612
+ }
613
+ if ("fields" in typeSchema && typeSchema.fields.some(field => {
614
+ var _a;
615
+ return (field == null ? void 0 : field.name) === ORDER_FIELD_NAME && ((_a = field == null ? void 0 : field.type) == null ? void 0 : _a.name) !== "string";
616
+ })) {
617
+ return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
618
+ children: [/* @__PURE__ */jsxRuntime.jsx("code", {
619
+ children: ORDER_FIELD_NAME
620
+ }), " field on Schema ", /* @__PURE__ */jsxRuntime.jsx("code", {
621
+ children: type
622
+ }), " must be", " ", /* @__PURE__ */jsxRuntime.jsx("code", {
623
+ children: "string"
624
+ }), " type"]
625
+ });
626
+ }
627
+ return "";
628
+ }, [type, schema]);
629
+ if (schemaIsInvalid) {
630
+ return /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
631
+ padding: 2,
632
+ children: /* @__PURE__ */jsxRuntime.jsx(sanityPluginUtils.Feedback, {
633
+ description: schemaIsInvalid,
634
+ tone: "caution"
635
+ })
636
+ });
637
+ }
638
+ return /* @__PURE__ */jsxRuntime.jsx(OrderableContext.Provider, {
639
+ value: {
640
+ showIncrements
641
+ },
642
+ children: /* @__PURE__ */jsxRuntime.jsx(DocumentListQuery, {
643
+ type,
644
+ filter,
645
+ params
646
+ })
647
+ });
648
+ }
649
+ async function resetOrder() {
650
+ let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
651
+ let client = arguments.length > 1 ? arguments[1] : undefined;
652
+ const query = "*[_type == $type]|order(@[$order] asc)._id";
653
+ const queryParams = {
654
+ type,
655
+ order: ORDER_FIELD_NAME
656
+ };
657
+ const documents = await client.fetch(query, queryParams);
658
+ if (!documents.length) {
659
+ return null;
660
+ }
661
+ const transaction = client.transaction();
662
+ let aLexoRank = lexorank.LexoRank.min();
663
+ for (let index = 0; index < documents.length; index += 1) {
664
+ aLexoRank = aLexoRank.genNext().genNext();
665
+ transaction.patch(documents[index], {
666
+ set: {
667
+ [ORDER_FIELD_NAME]: aLexoRank.toString()
668
+ }
669
+ });
670
+ }
671
+ return transaction.commit().then(update => update).catch(err => err);
672
+ }
673
+ var __defProp = Object.defineProperty;
674
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
675
+ enumerable: true,
676
+ configurable: true,
677
+ writable: true,
678
+ value
679
+ }) : obj[key] = value;
680
+ var __publicField = (obj, key, value) => {
681
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
682
+ return value;
683
+ };
684
+ class OrderableDocumentList extends React.Component {
685
+ constructor(props) {
686
+ super(props);
687
+ __publicField(this, "actionHandlers", {
688
+ showIncrements: () => {
689
+ this.setState(state => ({
690
+ showIncrements: !state.showIncrements
691
+ }));
692
+ },
693
+ resetOrder: async () => {
694
+ var _a;
695
+ this.setState(() => ({
696
+ resetOrderTransaction: {
697
+ status: "info",
698
+ title: "Reordering started...",
699
+ closable: true
700
+ }
701
+ }));
702
+ const update = await resetOrder(this.props.options.type, this.props.options.client);
703
+ const reorderWasSuccessful = (_a = update == null ? void 0 : update.results) == null ? void 0 : _a.length;
704
+ this.setState(() => ({
705
+ resetOrderTransaction: {
706
+ status: reorderWasSuccessful ? "success" : "info",
707
+ title: reorderWasSuccessful ? "Reordered ".concat(update.results.length === 1 ? "Document" : "Documents") : "Reordering failed",
708
+ closable: true
709
+ }
710
+ }));
711
+ }
712
+ });
713
+ this.state = {
714
+ showIncrements: false,
715
+ resetOrderTransaction: {}
716
+ };
717
+ }
718
+ render() {
719
+ var _a, _b, _c, _d, _e, _f;
720
+ const type = (_b = (_a = this == null ? void 0 : this.props) == null ? void 0 : _a.options) == null ? void 0 : _b.type;
721
+ if (!type) {
722
+ return null;
723
+ }
724
+ return /* @__PURE__ */jsxRuntime.jsx(DocumentListWrapper, {
725
+ filter: (_d = (_c = this == null ? void 0 : this.props) == null ? void 0 : _c.options) == null ? void 0 : _d.filter,
726
+ params: (_f = (_e = this == null ? void 0 : this.props) == null ? void 0 : _e.options) == null ? void 0 : _f.params,
727
+ type,
728
+ showIncrements: this.state.showIncrements,
729
+ resetOrderTransaction: this.state.resetOrderTransaction
730
+ });
731
+ }
732
+ }
733
+ function orderableDocumentListDeskItem(config) {
734
+ var _a, _b;
735
+ if (!(config == null ? void 0 : config.type) || !config.context || !config.S) {
736
+ 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 ");
737
+ }
738
+ const {
739
+ type,
740
+ filter,
741
+ params,
742
+ title,
743
+ icon,
744
+ id,
745
+ context,
746
+ S
747
+ } = config;
748
+ const {
749
+ schema,
750
+ getClient
751
+ } = context;
752
+ const client = getClient({
753
+ apiVersion: "2021-09-01"
754
+ });
755
+ const listTitle = title != null ? title : "Orderable ".concat(type);
756
+ const listId = id != null ? id : "orderable-".concat(type);
757
+ const listIcon = icon != null ? icon : icons.SortIcon;
758
+ const typeTitle = (_b = (_a = schema.get(type)) == null ? void 0 : _a.title) != null ? _b : type;
759
+ return S.listItem().title(listTitle).id(listId).icon(listIcon).child(Object.assign(S.documentTypeList(type).serialize(), {
760
+ // Prevents the component from re-rendering when switching documents
761
+ __preserveInstance: true,
762
+ // Prevents the component from NOT re-rendering when switching listItems
763
+ key: listId,
764
+ type: "component",
765
+ component: OrderableDocumentList,
766
+ options: {
767
+ type,
768
+ filter,
769
+ params,
770
+ client
771
+ },
772
+ menuItems: [S.menuItem().title("Create new ".concat(typeTitle)).intent({
773
+ type: "create",
774
+ params: {
775
+ type
776
+ }
777
+ }).serialize(), S.menuItem().title("Reset Order").icon(icons.GenerateIcon).action("resetOrder").serialize(), S.menuItem().title("Toggle Increments").icon(icons.SortIcon).action("showIncrements").serialize()]
778
+ })).serialize();
779
+ }
780
+ exports.orderRankField = orderRankField;
781
+ exports.orderRankOrdering = orderRankOrdering;
782
+ exports.orderableDocumentListDeskItem = orderableDocumentListDeskItem;
2
783
  //# sourceMappingURL=index.js.map