@sanity/orderable-document-list 0.0.9 → 0.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.
Files changed (38) hide show
  1. package/.prettierrc.js +6 -0
  2. package/.releaserc.json +4 -0
  3. package/.semantic-release/sanity-orderable-document-list-0.1.0.tgz +0 -0
  4. package/CHANGELOG.md +16 -0
  5. package/LICENSE +1 -1
  6. package/README.md +15 -2
  7. package/lib/Document.js +8 -21
  8. package/lib/Document.js.map +1 -1
  9. package/lib/DocumentListQuery.js +15 -47
  10. package/lib/DocumentListQuery.js.map +1 -1
  11. package/lib/DocumentListWrapper.js +11 -32
  12. package/lib/DocumentListWrapper.js.map +1 -1
  13. package/lib/DraggableList.js +56 -90
  14. package/lib/DraggableList.js.map +1 -1
  15. package/lib/Feedback.js +0 -6
  16. package/lib/Feedback.js.map +1 -1
  17. package/lib/OrderableContext.js +0 -4
  18. package/lib/OrderableContext.js.map +1 -1
  19. package/lib/OrderableDocumentList.js +0 -24
  20. package/lib/OrderableDocumentList.js.map +1 -1
  21. package/lib/desk-structure/orderableDocumentListDeskItem.js +6 -14
  22. package/lib/desk-structure/orderableDocumentListDeskItem.js.map +1 -1
  23. package/lib/fields/orderRankField.js +0 -16
  24. package/lib/fields/orderRankField.js.map +1 -1
  25. package/lib/fields/orderRankOrdering.js +0 -2
  26. package/lib/fields/orderRankOrdering.js.map +1 -1
  27. package/lib/helpers/constants.js.map +1 -1
  28. package/lib/helpers/initialRank.js +0 -2
  29. package/lib/helpers/initialRank.js.map +1 -1
  30. package/lib/helpers/reorderDocuments.js +51 -64
  31. package/lib/helpers/reorderDocuments.js.map +1 -1
  32. package/lib/helpers/resetOrder.js +3 -16
  33. package/lib/helpers/resetOrder.js.map +1 -1
  34. package/lib/index.js +0 -3
  35. package/lib/index.js.map +1 -1
  36. package/package.json +25 -20
  37. package/src/DocumentListWrapper.js +2 -3
  38. package/src/desk-structure/orderableDocumentListDeskItem.js +2 -2
@@ -4,128 +4,98 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = DraggableList;
7
-
8
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
-
10
8
  var _react = _interopRequireWildcard(require("react"));
11
-
12
9
  var _reactBeautifulDnd = require("react-beautiful-dnd");
13
-
14
10
  var _deskTool = require("@sanity/desk-tool");
15
-
16
11
  var _ui = require("@sanity/ui");
17
-
18
12
  var _client = _interopRequireDefault(require("part:@sanity/base/client"));
19
-
20
13
  var _Document = _interopRequireDefault(require("./Document"));
21
-
22
14
  var _reorderDocuments2 = require("./helpers/reorderDocuments");
23
-
24
15
  var _constants = require("./helpers/constants");
25
-
26
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
-
28
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
-
30
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
19
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
33
-
34
20
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
35
-
36
21
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
37
-
38
22
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
39
-
40
23
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
41
-
42
24
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
43
-
44
25
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
45
-
46
26
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
47
-
48
27
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
49
-
50
28
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
51
-
52
29
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
53
-
54
30
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
55
-
56
31
  var client = _client.default.withConfig({
57
32
  apiVersion: '2021-09-01'
58
33
  });
59
-
60
34
  var getItemStyle = (draggableStyle, itemIsUpdating) => _objectSpread({
61
35
  userSelect: 'none',
62
36
  transition: "opacity 500ms ease-in-out",
63
37
  opacity: itemIsUpdating ? 0.2 : 1,
64
38
  pointerEvents: itemIsUpdating ? "none" : undefined
65
39
  }, draggableStyle);
66
-
67
40
  var cardTone = settings => {
68
41
  var isDuplicate = settings.isDuplicate,
69
- isGhosting = settings.isGhosting,
70
- isDragging = settings.isDragging,
71
- isSelected = settings.isSelected;
42
+ isGhosting = settings.isGhosting,
43
+ isDragging = settings.isDragging,
44
+ isSelected = settings.isSelected;
72
45
  if (isGhosting) return "transparent";
73
46
  if (isDragging || isSelected) return "primary";
74
47
  if (isDuplicate) return "caution";
75
48
  return undefined;
76
49
  };
77
-
78
50
  function DraggableList(_ref) {
79
51
  var data = _ref.data,
80
- type = _ref.type,
81
- listIsUpdating = _ref.listIsUpdating,
82
- setListIsUpdating = _ref.setListIsUpdating;
52
+ type = _ref.type,
53
+ listIsUpdating = _ref.listIsUpdating,
54
+ setListIsUpdating = _ref.setListIsUpdating;
83
55
  var toast = (0, _ui.useToast)();
84
56
  var router = (0, _deskTool.usePaneRouter)();
85
- var navigateIntent = router.navigateIntent; // Maintains local state order before transaction completes
57
+ var navigateIntent = router.navigateIntent;
86
58
 
59
+ // Maintains local state order before transaction completes
87
60
  var _useState = (0, _react.useState)(data),
88
- _useState2 = _slicedToArray(_useState, 2),
89
- orderedData = _useState2[0],
90
- setOrderedData = _useState2[1]; // Update local state when documents change from an outside source
91
-
61
+ _useState2 = _slicedToArray(_useState, 2),
62
+ orderedData = _useState2[0],
63
+ setOrderedData = _useState2[1];
92
64
 
65
+ // Update local state when documents change from an outside source
93
66
  (0, _react.useEffect)(() => {
94
67
  if (!listIsUpdating) setOrderedData(data);
95
68
  /* eslint-disable-next-line react-hooks/exhaustive-deps */
96
69
  }, [data]);
97
-
98
70
  var _useState3 = (0, _react.useState)(""),
99
- _useState4 = _slicedToArray(_useState3, 2),
100
- draggingId = _useState4[0],
101
- setDraggingId = _useState4[1];
102
-
71
+ _useState4 = _slicedToArray(_useState3, 2),
72
+ draggingId = _useState4[0],
73
+ setDraggingId = _useState4[1];
103
74
  var _useState5 = (0, _react.useState)([]),
104
- _useState6 = _slicedToArray(_useState5, 2),
105
- selectedIds = _useState6[0],
106
- setSelectedIds = _useState6[1];
107
-
75
+ _useState6 = _slicedToArray(_useState5, 2),
76
+ selectedIds = _useState6[0],
77
+ setSelectedIds = _useState6[1];
108
78
  var clearSelected = () => setSelectedIds([]);
109
-
110
79
  var handleSelect = (clickedId, index, nativeEvent) => {
111
80
  var isSelected = selectedIds.includes(clickedId);
112
81
  var selectMultiple = nativeEvent.shiftKey;
113
82
  var isUsingWindows = navigator.appVersion.indexOf('Win') !== -1;
114
83
  var selectAdditional = isUsingWindows ? nativeEvent.ctrlKey : nativeEvent.metaKey;
115
- var updatedIds = []; // No modifier keys pressed during click:
84
+ var updatedIds = [];
85
+
86
+ // No modifier keys pressed during click:
116
87
  // - update selected to just this one
117
88
  // - open document
118
-
119
89
  if (!selectMultiple && !selectAdditional) {
120
90
  navigateIntent('edit', {
121
91
  id: clickedId,
122
92
  type
123
93
  });
124
94
  return setSelectedIds([clickedId]);
125
- } // Shift key was held, add id's between last selected and this one
126
- // ...before adding this one
127
-
95
+ }
128
96
 
97
+ // Shift key was held, add id's between last selected and this one
98
+ // ...before adding this one
129
99
  if (selectMultiple && !isSelected) {
130
100
  var lastSelectedId = selectedIds.at(-1);
131
101
  var lastSelectedIndex = orderedData.findIndex(item => item._id === lastSelectedId);
@@ -140,10 +110,8 @@ function DraggableList(_ref) {
140
110
  // Toggle on a single id
141
111
  updatedIds = [...selectedIds, clickedId];
142
112
  }
143
-
144
113
  return setSelectedIds(updatedIds);
145
114
  };
146
-
147
115
  var transactPatches = /*#__PURE__*/function () {
148
116
  var _ref2 = _asyncToGenerator(function* (patches, message) {
149
117
  var transaction = client.transaction();
@@ -166,62 +134,62 @@ function DraggableList(_ref) {
166
134
  });
167
135
  });
168
136
  });
169
-
170
137
  return function transactPatches(_x, _x2) {
171
138
  return _ref2.apply(this, arguments);
172
139
  };
173
140
  }();
174
-
175
141
  var handleDragEnd = (result, entities) => {
176
142
  setDraggingId("");
177
-
178
143
  var _ref3 = result !== null && result !== void 0 ? result : {},
179
- source = _ref3.source,
180
- destination = _ref3.destination,
181
- draggableId = _ref3.draggableId; // Don't do anything if nothing changed
182
-
144
+ source = _ref3.source,
145
+ destination = _ref3.destination,
146
+ draggableId = _ref3.draggableId;
183
147
 
184
- if (source.index === destination.index) return; // Don't do anything if we don't have the entitites
148
+ // Don't do anything if nothing changed
149
+ if (source.index === destination.index) return;
185
150
 
186
- if (!(entities !== null && entities !== void 0 && entities.length)) return; // A document can be dragged without being one-of-many-selected
151
+ // Don't do anything if we don't have the entitites
152
+ if (!(entities !== null && entities !== void 0 && entities.length)) return;
187
153
 
188
- var effectedIds = selectedIds !== null && selectedIds !== void 0 && selectedIds.length ? selectedIds : [draggableId]; // Don't do anything if we don't have ids to effect
154
+ // A document can be dragged without being one-of-many-selected
155
+ var effectedIds = selectedIds !== null && selectedIds !== void 0 && selectedIds.length ? selectedIds : [draggableId];
189
156
 
190
- if (!(effectedIds !== null && effectedIds !== void 0 && effectedIds.length)) return; // Update state to update styles + prevent data refetching
157
+ // Don't do anything if we don't have ids to effect
158
+ if (!(effectedIds !== null && effectedIds !== void 0 && effectedIds.length)) return;
191
159
 
160
+ // Update state to update styles + prevent data refetching
192
161
  setListIsUpdating(true);
193
162
  setSelectedIds(effectedIds);
194
-
195
163
  var _reorderDocuments = (0, _reorderDocuments2.reorderDocuments)({
196
- entities,
197
- selectedIds: effectedIds,
198
- source,
199
- destination
200
- }),
201
- newOrder = _reorderDocuments.newOrder,
202
- patches = _reorderDocuments.patches,
203
- message = _reorderDocuments.message; // Update local state
204
-
205
-
164
+ entities,
165
+ selectedIds: effectedIds,
166
+ source,
167
+ destination
168
+ }),
169
+ newOrder = _reorderDocuments.newOrder,
170
+ patches = _reorderDocuments.patches,
171
+ message = _reorderDocuments.message;
172
+
173
+ // Update local state
206
174
  if (newOrder !== null && newOrder !== void 0 && newOrder.length) {
207
175
  setOrderedData(newOrder);
208
- } // Transact new order patches
209
-
176
+ }
210
177
 
178
+ // Transact new order patches
211
179
  if (patches !== null && patches !== void 0 && patches.length) {
212
180
  transactPatches(patches, message);
213
181
  }
214
182
  };
215
-
216
183
  var handleDragStart = start => {
217
184
  var id = start.draggableId;
218
- var selected = selectedIds.includes(id); // if dragging an item that is not selected - unselect all items
185
+ var selected = selectedIds.includes(id);
219
186
 
187
+ // if dragging an item that is not selected - unselect all items
220
188
  if (!selected) clearSelected();
221
189
  setDraggingId(id);
222
- }; // Move one document up or down one place, by fake invoking the drag function
223
-
190
+ };
224
191
 
192
+ // Move one document up or down one place, by fake invoking the drag function
225
193
  var incrementIndex = (shiftFrom, shiftTo, id, entities) => {
226
194
  var result = {
227
195
  draggableId: id,
@@ -234,20 +202,19 @@ function DraggableList(_ref) {
234
202
  };
235
203
  return handleDragEnd(result, entities);
236
204
  };
237
-
238
205
  var onWindowKeyDown = event => {
239
206
  if (event.key === 'Escape') {
240
207
  clearSelected();
241
208
  }
242
209
  };
243
-
244
210
  (0, _react.useEffect)(() => {
245
211
  window.addEventListener('keydown', onWindowKeyDown);
246
212
  return () => {
247
213
  window.removeEventListener('keydown', onWindowKeyDown);
248
214
  };
249
- }, []); // Find all items with duplicate order field
215
+ }, []);
250
216
 
217
+ // Find all items with duplicate order field
251
218
  var duplicateOrders = (0, _react.useMemo)(() => {
252
219
  if (!orderedData.length) return [];
253
220
  var orderField = orderedData.map(item => item[_constants.ORDER_FIELD_NAME]);
@@ -263,8 +230,8 @@ function DraggableList(_ref) {
263
230
  }), orderedData.map((item, index) => /*#__PURE__*/_react.default.createElement(_reactBeautifulDnd.Draggable, {
264
231
  key: "".concat(item._id, "-").concat(item[_constants.ORDER_FIELD_NAME]),
265
232
  draggableId: item._id,
266
- index: index // onClick={(event) => handleDraggableClick(event, provided, snapshot)}
267
-
233
+ index: index
234
+ // onClick={(event) => handleDraggableClick(event, provided, snapshot)}
268
235
  }, (innerProvided, innerSnapshot) => {
269
236
  var isSelected = selectedIds.includes(item._id);
270
237
  var isDragging = innerSnapshot.isDragging;
@@ -302,7 +269,6 @@ function DraggableList(_ref) {
302
269
  }))));
303
270
  })), provided.placeholder)));
304
271
  }
305
-
306
272
  DraggableList.propTypes = {
307
273
  data: _propTypes.default.arrayOf(_propTypes.default.shape({
308
274
  _id: _propTypes.default.string
@@ -1 +1 @@
1
- {"version":3,"file":"DraggableList.js","names":["client","sanityClient","withConfig","apiVersion","getItemStyle","draggableStyle","itemIsUpdating","userSelect","transition","opacity","pointerEvents","undefined","cardTone","settings","isDuplicate","isGhosting","isDragging","isSelected","DraggableList","data","type","listIsUpdating","setListIsUpdating","toast","useToast","router","usePaneRouter","navigateIntent","useState","orderedData","setOrderedData","useEffect","draggingId","setDraggingId","selectedIds","setSelectedIds","clearSelected","handleSelect","clickedId","index","nativeEvent","includes","selectMultiple","shiftKey","isUsingWindows","navigator","appVersion","indexOf","selectAdditional","ctrlKey","metaKey","updatedIds","id","lastSelectedId","at","lastSelectedIndex","findIndex","item","_id","firstSelected","lastSelected","betweenIds","filter","itemIndex","map","transactPatches","patches","message","transaction","forEach","patchArgs","patch","commit","then","updated","push","title","results","length","status","description","catch","handleDragEnd","result","entities","source","destination","draggableId","effectedIds","reorderDocuments","newOrder","handleDragStart","start","selected","incrementIndex","shiftFrom","shiftTo","onWindowKeyDown","event","key","window","addEventListener","removeEventListener","duplicateOrders","useMemo","orderField","ORDER_FIELD_NAME","provided","snapshot","droppableProps","innerRef","innerProvided","innerSnapshot","Boolean","isUpdating","isDisabled","tone","draggableProps","dragHandleProps","style","placeholder","propTypes","PropTypes","arrayOf","shape","string","isRequired","bool","func"],"sources":["../src/DraggableList.js"],"sourcesContent":["import PropTypes from 'prop-types'\nimport React, {useMemo, useState, useEffect} from 'react'\nimport {DragDropContext, Droppable, Draggable} from 'react-beautiful-dnd'\nimport {usePaneRouter} from '@sanity/desk-tool'\nimport {Box, Card, useToast} from '@sanity/ui'\nimport sanityClient from 'part:@sanity/base/client'\n\nimport Document from './Document'\nimport {reorderDocuments} from './helpers/reorderDocuments'\nimport {ORDER_FIELD_NAME} from './helpers/constants'\n\nconst client = sanityClient.withConfig({\n apiVersion: '2021-09-01',\n})\n\nconst getItemStyle = (draggableStyle, itemIsUpdating) => ({\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) => {\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 default function DraggableList({data, type, listIsUpdating, setListIsUpdating}) {\n const toast = useToast()\n const router = usePaneRouter()\n const {navigateIntent} = router\n\n // Maintains local state order before transaction completes\n const [orderedData, setOrderedData] = useState(data)\n\n // Update local state when documents change from an outside source\n useEffect(() => {\n if (!listIsUpdating) setOrderedData(data)\n /* eslint-disable-next-line react-hooks/exhaustive-deps */\n }, [data])\n\n const [draggingId, setDraggingId] = useState(``)\n const [selectedIds, setSelectedIds] = useState([])\n\n const clearSelected = () => setSelectedIds([])\n\n const handleSelect = (clickedId, index, nativeEvent) => {\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 = []\n\n // No modifier keys pressed during click:\n // - update selected to just this one\n // - open document\n if (!selectMultiple && !selectAdditional) {\n navigateIntent('edit', {id: clickedId, type})\n return setSelectedIds([clickedId])\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.at(-1)\n const lastSelectedIndex = orderedData.findIndex((item) => item._id === lastSelectedId)\n\n const firstSelected = index < lastSelectedIndex ? index : lastSelectedIndex\n const lastSelected = index > lastSelectedIndex ? index : lastSelectedIndex\n\n const betweenIds = orderedData\n .filter((item, 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\n const transactPatches = async (patches, message) => {\n const transaction = client.transaction()\n\n patches.forEach((patchArgs) => transaction.patch(...patchArgs))\n\n await transaction\n .commit()\n .then((updated) => {\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 })\n .catch(() => {\n setDraggingId(``)\n setListIsUpdating(false)\n toast.push({\n title: `Reordering failed`,\n status: `critical`,\n })\n })\n }\n\n const handleDragEnd = (result, entities) => {\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) return\n\n // A document can be dragged without being one-of-many-selected\n const effectedIds = selectedIds?.length ? selectedIds : [draggableId]\n\n // Don't do anything if we don't have ids to effect\n if (!effectedIds?.length) 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) {\n setOrderedData(newOrder)\n }\n\n // Transact new order patches\n if (patches?.length) {\n transactPatches(patches, message)\n }\n }\n\n const handleDragStart = (start) => {\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\n // Move one document up or down one place, by fake invoking the drag function\n const incrementIndex = (shiftFrom, shiftTo, id, entities) => {\n const result = {\n draggableId: id,\n source: {index: shiftFrom},\n destination: {index: shiftTo},\n }\n\n return handleDragEnd(result, entities)\n }\n\n const onWindowKeyDown = (event) => {\n if (event.key === 'Escape') {\n clearSelected()\n }\n }\n\n useEffect(() => {\n window.addEventListener('keydown', onWindowKeyDown)\n\n return () => {\n window.removeEventListener('keydown', onWindowKeyDown)\n }\n }, [])\n\n // Find all items with duplicate order field\n const duplicateOrders = useMemo(() => {\n if (!orderedData.length) return []\n\n const orderField = orderedData.map((item) => item[ORDER_FIELD_NAME])\n\n return orderField.filter((item, index) => orderField.indexOf(item) !== index)\n }, [orderedData])\n\n return (\n <DragDropContext\n onDragStart={handleDragStart}\n onDragEnd={(result) => handleDragEnd(result, orderedData)}\n >\n <Droppable droppableId=\"documentSortZone\">\n {(provided, snapshot) => (\n <div {...provided.droppableProps} ref={provided.innerRef}>\n {orderedData.map((item, index) => (\n <Draggable\n key={`${item._id}-${item[ORDER_FIELD_NAME]}`}\n draggableId={item._id}\n index={index}\n // onClick={(event) => handleDraggableClick(event, provided, snapshot)}\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 = Boolean(!item[ORDER_FIELD_NAME])\n const isDuplicate = duplicateOrders.includes(item[ORDER_FIELD_NAME])\n const tone = cardTone({isDuplicate, isGhosting, isDragging, isSelected})\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, isGhosting)\n }\n >\n <Box paddingBottom={1}>\n <Card tone={tone} shadow={isDragging ? `2` : undefined} radius={2}>\n <Document\n doc={item}\n entities={orderedData}\n handleSelect={handleSelect}\n increment={incrementIndex}\n index={index}\n isFirst={index === 0}\n isLast={index === orderedData.length - 1}\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\nDraggableList.propTypes = {\n data: PropTypes.arrayOf(\n PropTypes.shape({\n _id: PropTypes.string,\n }).isRequired\n ).isRequired,\n type: PropTypes.string.isRequired,\n listIsUpdating: PropTypes.bool.isRequired,\n setListIsUpdating: PropTypes.func.isRequired,\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;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iBC,UANC;EAOxBzG,cAAc,EAAEqG,kBAAA,CAAUK,IAAV,CAAeD,UAPP;EAQxBxG,iBAAiB,EAAEoG,kBAAA,CAAUM,IAAV,CAAeF;AARV,CAA1B"}
1
+ {"version":3,"file":"DraggableList.js","names":["client","sanityClient","withConfig","apiVersion","getItemStyle","draggableStyle","itemIsUpdating","userSelect","transition","opacity","pointerEvents","undefined","cardTone","settings","isDuplicate","isGhosting","isDragging","isSelected","DraggableList","data","type","listIsUpdating","setListIsUpdating","toast","useToast","router","usePaneRouter","navigateIntent","useState","orderedData","setOrderedData","useEffect","draggingId","setDraggingId","selectedIds","setSelectedIds","clearSelected","handleSelect","clickedId","index","nativeEvent","includes","selectMultiple","shiftKey","isUsingWindows","navigator","appVersion","indexOf","selectAdditional","ctrlKey","metaKey","updatedIds","id","lastSelectedId","at","lastSelectedIndex","findIndex","item","_id","firstSelected","lastSelected","betweenIds","filter","itemIndex","map","transactPatches","patches","message","transaction","forEach","patchArgs","patch","commit","then","updated","push","title","results","length","status","description","catch","handleDragEnd","result","entities","source","destination","draggableId","effectedIds","reorderDocuments","newOrder","handleDragStart","start","selected","incrementIndex","shiftFrom","shiftTo","onWindowKeyDown","event","key","window","addEventListener","removeEventListener","duplicateOrders","useMemo","orderField","ORDER_FIELD_NAME","provided","snapshot","droppableProps","innerRef","innerProvided","innerSnapshot","Boolean","isUpdating","isDisabled","tone","draggableProps","dragHandleProps","style","placeholder","propTypes","PropTypes","arrayOf","shape","string","isRequired","bool","func"],"sources":["../src/DraggableList.js"],"sourcesContent":["import PropTypes from 'prop-types'\nimport React, {useMemo, useState, useEffect} from 'react'\nimport {DragDropContext, Droppable, Draggable} from 'react-beautiful-dnd'\nimport {usePaneRouter} from '@sanity/desk-tool'\nimport {Box, Card, useToast} from '@sanity/ui'\nimport sanityClient from 'part:@sanity/base/client'\n\nimport Document from './Document'\nimport {reorderDocuments} from './helpers/reorderDocuments'\nimport {ORDER_FIELD_NAME} from './helpers/constants'\n\nconst client = sanityClient.withConfig({\n apiVersion: '2021-09-01',\n})\n\nconst getItemStyle = (draggableStyle, itemIsUpdating) => ({\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) => {\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 default function DraggableList({data, type, listIsUpdating, setListIsUpdating}) {\n const toast = useToast()\n const router = usePaneRouter()\n const {navigateIntent} = router\n\n // Maintains local state order before transaction completes\n const [orderedData, setOrderedData] = useState(data)\n\n // Update local state when documents change from an outside source\n useEffect(() => {\n if (!listIsUpdating) setOrderedData(data)\n /* eslint-disable-next-line react-hooks/exhaustive-deps */\n }, [data])\n\n const [draggingId, setDraggingId] = useState(``)\n const [selectedIds, setSelectedIds] = useState([])\n\n const clearSelected = () => setSelectedIds([])\n\n const handleSelect = (clickedId, index, nativeEvent) => {\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 = []\n\n // No modifier keys pressed during click:\n // - update selected to just this one\n // - open document\n if (!selectMultiple && !selectAdditional) {\n navigateIntent('edit', {id: clickedId, type})\n return setSelectedIds([clickedId])\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.at(-1)\n const lastSelectedIndex = orderedData.findIndex((item) => item._id === lastSelectedId)\n\n const firstSelected = index < lastSelectedIndex ? index : lastSelectedIndex\n const lastSelected = index > lastSelectedIndex ? index : lastSelectedIndex\n\n const betweenIds = orderedData\n .filter((item, 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\n const transactPatches = async (patches, message) => {\n const transaction = client.transaction()\n\n patches.forEach((patchArgs) => transaction.patch(...patchArgs))\n\n await transaction\n .commit()\n .then((updated) => {\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 })\n .catch(() => {\n setDraggingId(``)\n setListIsUpdating(false)\n toast.push({\n title: `Reordering failed`,\n status: `critical`,\n })\n })\n }\n\n const handleDragEnd = (result, entities) => {\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) return\n\n // A document can be dragged without being one-of-many-selected\n const effectedIds = selectedIds?.length ? selectedIds : [draggableId]\n\n // Don't do anything if we don't have ids to effect\n if (!effectedIds?.length) 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) {\n setOrderedData(newOrder)\n }\n\n // Transact new order patches\n if (patches?.length) {\n transactPatches(patches, message)\n }\n }\n\n const handleDragStart = (start) => {\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\n // Move one document up or down one place, by fake invoking the drag function\n const incrementIndex = (shiftFrom, shiftTo, id, entities) => {\n const result = {\n draggableId: id,\n source: {index: shiftFrom},\n destination: {index: shiftTo},\n }\n\n return handleDragEnd(result, entities)\n }\n\n const onWindowKeyDown = (event) => {\n if (event.key === 'Escape') {\n clearSelected()\n }\n }\n\n useEffect(() => {\n window.addEventListener('keydown', onWindowKeyDown)\n\n return () => {\n window.removeEventListener('keydown', onWindowKeyDown)\n }\n }, [])\n\n // Find all items with duplicate order field\n const duplicateOrders = useMemo(() => {\n if (!orderedData.length) return []\n\n const orderField = orderedData.map((item) => item[ORDER_FIELD_NAME])\n\n return orderField.filter((item, index) => orderField.indexOf(item) !== index)\n }, [orderedData])\n\n return (\n <DragDropContext\n onDragStart={handleDragStart}\n onDragEnd={(result) => handleDragEnd(result, orderedData)}\n >\n <Droppable droppableId=\"documentSortZone\">\n {(provided, snapshot) => (\n <div {...provided.droppableProps} ref={provided.innerRef}>\n {orderedData.map((item, index) => (\n <Draggable\n key={`${item._id}-${item[ORDER_FIELD_NAME]}`}\n draggableId={item._id}\n index={index}\n // onClick={(event) => handleDraggableClick(event, provided, snapshot)}\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 = Boolean(!item[ORDER_FIELD_NAME])\n const isDuplicate = duplicateOrders.includes(item[ORDER_FIELD_NAME])\n const tone = cardTone({isDuplicate, isGhosting, isDragging, isSelected})\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, isGhosting)\n }\n >\n <Box paddingBottom={1}>\n <Card tone={tone} shadow={isDragging ? `2` : undefined} radius={2}>\n <Document\n doc={item}\n entities={orderedData}\n handleSelect={handleSelect}\n increment={incrementIndex}\n index={index}\n isFirst={index === 0}\n isLast={index === orderedData.length - 1}\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\nDraggableList.propTypes = {\n data: PropTypes.arrayOf(\n PropTypes.shape({\n _id: PropTypes.string,\n }).isRequired\n ).isRequired,\n type: PropTypes.string.isRequired,\n listIsUpdating: PropTypes.bool.isRequired,\n setListIsUpdating: PropTypes.func.isRequired,\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAoD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEpD,IAAMA,MAAM,GAAGC,eAAY,CAACC,UAAU,CAAC;EACrCC,UAAU,EAAE;AACd,CAAC,CAAC;AAEF,IAAMC,YAAY,GAAG,CAACC,cAAc,EAAEC,cAAc;EAClDC,UAAU,EAAE,MAAM;EAClBC,UAAU,6BAA6B;EACvCC,OAAO,EAAEH,cAAc,GAAG,GAAG,GAAG,CAAC;EACjCI,aAAa,EAAEJ,cAAc,YAAYK;AAAS,GAC/CN,cAAc,CACjB;AAEF,IAAMO,QAAQ,GAAIC,QAAQ,IAAK;EAC7B,IAAOC,WAAW,GAAwCD,QAAQ,CAA3DC,WAAW;IAAEC,UAAU,GAA4BF,QAAQ,CAA9CE,UAAU;IAAEC,UAAU,GAAgBH,QAAQ,CAAlCG,UAAU;IAAEC,UAAU,GAAIJ,QAAQ,CAAtBI,UAAU;EAEtD,IAAIF,UAAU,EAAE;EAChB,IAAIC,UAAU,IAAIC,UAAU,EAAE;EAC9B,IAAIH,WAAW,EAAE;EAEjB,OAAOH,SAAS;AAClB,CAAC;AAEc,SAASO,aAAa,OAAkD;EAAA,IAAhDC,IAAI,QAAJA,IAAI;IAAEC,IAAI,QAAJA,IAAI;IAAEC,cAAc,QAAdA,cAAc;IAAEC,iBAAiB,QAAjBA,iBAAiB;EAClF,IAAMC,KAAK,GAAG,IAAAC,YAAQ,GAAE;EACxB,IAAMC,MAAM,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;EACjCzG,cAAc,EAAEqG,kBAAS,CAACK,IAAI,CAACD,UAAU;EACzCxG,iBAAiB,EAAEoG,kBAAS,CAACM,IAAI,CAACF;AACpC,CAAC"}
package/lib/Feedback.js CHANGED
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Feedback;
7
-
8
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _ui = require("@sanity/ui");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  function Feedback(_ref) {
17
12
  var children = _ref.children;
18
13
  return /*#__PURE__*/_react.default.createElement(_ui.Box, {
@@ -24,7 +19,6 @@ function Feedback(_ref) {
24
19
  tone: "caution"
25
20
  }, /*#__PURE__*/_react.default.createElement(_ui.Text, null, children)));
26
21
  }
27
-
28
22
  Feedback.propTypes = {
29
23
  children: _propTypes.default.node.isRequired
30
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Feedback.js","names":["Feedback","children","propTypes","PropTypes","node","isRequired"],"sources":["../src/Feedback.js"],"sourcesContent":["import PropTypes from 'prop-types'\nimport React from 'react'\nimport {Box, Card, Text} from '@sanity/ui'\n\nexport default function Feedback({children}) {\n return (\n <Box padding={3}>\n <Card padding={4} radius={2} shadow={1} tone=\"caution\">\n <Text>{children}</Text>\n </Card>\n </Box>\n )\n}\n\nFeedback.propTypes = {\n children: PropTypes.node.isRequired,\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEe,SAASA,QAAT,OAA8B;EAAA,IAAXC,QAAW,QAAXA,QAAW;EAC3C,oBACE,6BAAC,OAAD;IAAK,OAAO,EAAE;EAAd,gBACE,6BAAC,QAAD;IAAM,OAAO,EAAE,CAAf;IAAkB,MAAM,EAAE,CAA1B;IAA6B,MAAM,EAAE,CAArC;IAAwC,IAAI,EAAC;EAA7C,gBACE,6BAAC,QAAD,QAAOA,QAAP,CADF,CADF,CADF;AAOD;;AAEDD,QAAQ,CAACE,SAAT,GAAqB;EACnBD,QAAQ,EAAEE,kBAAA,CAAUC,IAAV,CAAeC;AADN,CAArB"}
1
+ {"version":3,"file":"Feedback.js","names":["Feedback","children","propTypes","PropTypes","node","isRequired"],"sources":["../src/Feedback.js"],"sourcesContent":["import PropTypes from 'prop-types'\nimport React from 'react'\nimport {Box, Card, Text} from '@sanity/ui'\n\nexport default function Feedback({children}) {\n return (\n <Box padding={3}>\n <Card padding={4} radius={2} shadow={1} tone=\"caution\">\n <Text>{children}</Text>\n </Card>\n </Box>\n )\n}\n\nFeedback.propTypes = {\n children: PropTypes.node.isRequired,\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAA0C;AAE3B,SAASA,QAAQ,OAAa;EAAA,IAAXC,QAAQ,QAARA,QAAQ;EACxC,oBACE,6BAAC,OAAG;IAAC,OAAO,EAAE;EAAE,gBACd,6BAAC,QAAI;IAAC,OAAO,EAAE,CAAE;IAAC,MAAM,EAAE,CAAE;IAAC,MAAM,EAAE,CAAE;IAAC,IAAI,EAAC;EAAS,gBACpD,6BAAC,QAAI,QAAEA,QAAQ,CAAQ,CAClB,CACH;AAEV;AAEAD,QAAQ,CAACE,SAAS,GAAG;EACnBD,QAAQ,EAAEE,kBAAS,CAACC,IAAI,CAACC;AAC3B,CAAC"}
@@ -4,12 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.OrderableContext = void 0;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  var OrderableContext = /*#__PURE__*/_react.default.createContext({});
13
-
14
10
  exports.OrderableContext = OrderableContext;
15
11
  //# sourceMappingURL=OrderableContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OrderableContext.js","names":["OrderableContext","React","createContext"],"sources":["../src/OrderableContext.js"],"sourcesContent":["import React from 'react'\n\nexport const OrderableContext = React.createContext({})\n"],"mappings":";;;;;;;AAAA;;;;AAEO,IAAMA,gBAAgB,gBAAGC,cAAA,CAAMC,aAAN,CAAoB,EAApB,CAAzB"}
1
+ {"version":3,"file":"OrderableContext.js","names":["OrderableContext","React","createContext"],"sources":["../src/OrderableContext.js"],"sourcesContent":["import React from 'react'\n\nexport const OrderableContext = React.createContext({})\n"],"mappings":";;;;;;AAAA;AAAyB;AAElB,IAAMA,gBAAgB,gBAAGC,cAAK,CAACC,aAAa,CAAC,CAAC,CAAC,CAAC;AAAA"}
@@ -4,35 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
-
10
8
  var _react = _interopRequireWildcard(require("react"));
11
-
12
9
  var _DocumentListWrapper = _interopRequireDefault(require("./DocumentListWrapper"));
13
-
14
10
  var _resetOrder3 = require("./helpers/resetOrder");
15
-
16
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
14
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
23
-
24
15
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
25
-
26
16
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
-
28
17
  // Must use a Class Component here so the actionHandlers can be called
29
18
  class OrderableDocumentList extends _react.Component {
30
19
  constructor(props) {
31
20
  var _this;
32
-
33
21
  super(props);
34
22
  _this = this;
35
-
36
23
  _defineProperty(this, "actionHandlers", {
37
24
  showIncrements: () => {
38
25
  this.setState(state => ({
@@ -42,7 +29,6 @@ class OrderableDocumentList extends _react.Component {
42
29
  resetOrder: function () {
43
30
  var _resetOrder2 = _asyncToGenerator(function* () {
44
31
  var _update$results;
45
-
46
32
  _this.setState(() => ({
47
33
  resetOrderTransaction: {
48
34
  status: "info",
@@ -50,10 +36,8 @@ class OrderableDocumentList extends _react.Component {
50
36
  closable: true
51
37
  }
52
38
  }));
53
-
54
39
  var update = yield (0, _resetOrder3.resetOrder)(_this.props.options.type);
55
40
  var reorderWasSuccessful = update === null || update === void 0 ? void 0 : (_update$results = update.results) === null || _update$results === void 0 ? void 0 : _update$results.length;
56
-
57
41
  _this.setState(() => ({
58
42
  resetOrderTransaction: {
59
43
  status: reorderWasSuccessful ? "success" : "info",
@@ -62,24 +46,19 @@ class OrderableDocumentList extends _react.Component {
62
46
  }
63
47
  }));
64
48
  });
65
-
66
49
  function resetOrder() {
67
50
  return _resetOrder2.apply(this, arguments);
68
51
  }
69
-
70
52
  return resetOrder;
71
53
  }()
72
54
  });
73
-
74
55
  this.state = {
75
56
  showIncrements: false,
76
57
  resetOrderTransaction: {}
77
58
  };
78
59
  }
79
-
80
60
  render() {
81
61
  var _this$props, _this$props$options, _this$props2, _this$props2$options, _this$props3, _this$props3$options;
82
-
83
62
  return /*#__PURE__*/_react.default.createElement(_DocumentListWrapper.default, {
84
63
  type: this === null || this === void 0 ? void 0 : (_this$props = this.props) === null || _this$props === void 0 ? void 0 : (_this$props$options = _this$props.options) === null || _this$props$options === void 0 ? void 0 : _this$props$options.type,
85
64
  filter: this === null || this === void 0 ? void 0 : (_this$props2 = this.props) === null || _this$props2 === void 0 ? void 0 : (_this$props2$options = _this$props2.options) === null || _this$props2$options === void 0 ? void 0 : _this$props2$options.filter,
@@ -88,11 +67,8 @@ class OrderableDocumentList extends _react.Component {
88
67
  resetOrderTransaction: this.state.resetOrderTransaction
89
68
  });
90
69
  }
91
-
92
70
  }
93
-
94
71
  exports.default = OrderableDocumentList;
95
-
96
72
  _defineProperty(OrderableDocumentList, "propTypes", {
97
73
  options: _propTypes.default.shape({
98
74
  type: _propTypes.default.string,
@@ -1 +1 @@
1
- {"version":3,"file":"OrderableDocumentList.js","names":["OrderableDocumentList","Component","constructor","props","showIncrements","setState","state","resetOrder","resetOrderTransaction","status","title","closable","update","options","type","reorderWasSuccessful","results","length","render","filter","params","PropTypes","shape","string","object","isRequired"],"sources":["../src/OrderableDocumentList.js"],"sourcesContent":["import PropTypes from 'prop-types'\nimport React, {Component} from 'react'\n\nimport DocumentListWrapper from './DocumentListWrapper'\nimport {resetOrder} from './helpers/resetOrder'\n\n// Must use a Class Component here so the actionHandlers can be called\nexport default class OrderableDocumentList extends Component {\n static propTypes = {\n options: PropTypes.shape({\n type: PropTypes.string,\n filter: PropTypes.string,\n params: PropTypes.object,\n }).isRequired,\n }\n\n constructor(props) {\n super(props)\n this.state = {\n showIncrements: false,\n resetOrderTransaction: {},\n }\n }\n\n actionHandlers = {\n showIncrements: () => {\n this.setState((state) => ({\n showIncrements: !state.showIncrements,\n }))\n },\n\n resetOrder: async () => {\n this.setState(() => ({\n resetOrderTransaction: {\n status: `info`,\n title: `Reordering started...`,\n closable: true,\n },\n }))\n\n const update = await resetOrder(this.props.options.type)\n\n const reorderWasSuccessful = update?.results?.length\n\n this.setState(() => ({\n resetOrderTransaction: {\n status: reorderWasSuccessful ? `success` : `info`,\n title: reorderWasSuccessful\n ? `Reordered ${update.results.length === 1 ? `Document` : `Documents`}`\n : `Reordering failed`,\n closable: true,\n },\n }))\n },\n }\n\n render() {\n return (\n <DocumentListWrapper\n type={this?.props?.options?.type}\n filter={this?.props?.options?.filter}\n params={this?.props?.options?.params}\n showIncrements={this.state.showIncrements}\n resetOrderTransaction={this.state.resetOrderTransaction}\n />\n )\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;;;;;;;;;AAEA;AACe,MAAMA,qBAAN,SAAoCC,gBAApC,CAA8C;EAS3DC,WAAW,CAACC,KAAD,EAAQ;IAAA;;IACjB,MAAMA,KAAN,CADiB;IAAA;;IAAA,wCAQF;MACfC,cAAc,EAAE,MAAM;QACpB,KAAKC,QAAL,CAAeC,KAAD,KAAY;UACxBF,cAAc,EAAE,CAACE,KAAK,CAACF;QADC,CAAZ,CAAd;MAGD,CALc;MAOfG,UAAU;QAAA,qCAAE,aAAY;UAAA;;UACtB,KAAI,CAACF,QAAL,CAAc,OAAO;YACnBG,qBAAqB,EAAE;cACrBC,MAAM,QADe;cAErBC,KAAK,yBAFgB;cAGrBC,QAAQ,EAAE;YAHW;UADJ,CAAP,CAAd;;UAQA,IAAMC,MAAM,SAAS,IAAAL,uBAAA,EAAW,KAAI,CAACJ,KAAL,CAAWU,OAAX,CAAmBC,IAA9B,CAArB;UAEA,IAAMC,oBAAoB,GAAGH,MAAH,aAAGA,MAAH,0CAAGA,MAAM,CAAEI,OAAX,oDAAG,gBAAiBC,MAA9C;;UAEA,KAAI,CAACZ,QAAL,CAAc,OAAO;YACnBG,qBAAqB,EAAE;cACrBC,MAAM,EAAEM,oBAAoB,qBADP;cAErBL,KAAK,EAAEK,oBAAoB,uBACVH,MAAM,CAACI,OAAP,CAAeC,MAAf,KAA0B,CAA1B,2BADU,uBAFN;cAKrBN,QAAQ,EAAE;YALW;UADJ,CAAP,CAAd;QASD,CAtBS;;QAAA;UAAA;QAAA;;QAAA;MAAA;IAPK,CARE;;IAEjB,KAAKL,KAAL,GAAa;MACXF,cAAc,EAAE,KADL;MAEXI,qBAAqB,EAAE;IAFZ,CAAb;EAID;;EAkCDU,MAAM,GAAG;IAAA;;IACP,oBACE,6BAAC,4BAAD;MACE,IAAI,EAAE,IAAF,aAAE,IAAF,sCAAE,KAAMf,KAAR,uEAAE,YAAaU,OAAf,wDAAE,oBAAsBC,IAD9B;MAEE,MAAM,EAAE,IAAF,aAAE,IAAF,uCAAE,KAAMX,KAAR,yEAAE,aAAaU,OAAf,yDAAE,qBAAsBM,MAFhC;MAGE,MAAM,EAAE,IAAF,aAAE,IAAF,uCAAE,KAAMhB,KAAR,yEAAE,aAAaU,OAAf,yDAAE,qBAAsBO,MAHhC;MAIE,cAAc,EAAE,KAAKd,KAAL,CAAWF,cAJ7B;MAKE,qBAAqB,EAAE,KAAKE,KAAL,CAAWE;IALpC,EADF;EASD;;AA3D0D;;;;gBAAxCR,qB,eACA;EACjBa,OAAO,EAAEQ,kBAAA,CAAUC,KAAV,CAAgB;IACvBR,IAAI,EAAEO,kBAAA,CAAUE,MADO;IAEvBJ,MAAM,EAAEE,kBAAA,CAAUE,MAFK;IAGvBH,MAAM,EAAEC,kBAAA,CAAUG;EAHK,CAAhB,EAINC;AALc,C"}
1
+ {"version":3,"file":"OrderableDocumentList.js","names":["OrderableDocumentList","Component","constructor","props","showIncrements","setState","state","resetOrder","resetOrderTransaction","status","title","closable","update","options","type","reorderWasSuccessful","results","length","render","filter","params","PropTypes","shape","string","object","isRequired"],"sources":["../src/OrderableDocumentList.js"],"sourcesContent":["import PropTypes from 'prop-types'\nimport React, {Component} from 'react'\n\nimport DocumentListWrapper from './DocumentListWrapper'\nimport {resetOrder} from './helpers/resetOrder'\n\n// Must use a Class Component here so the actionHandlers can be called\nexport default class OrderableDocumentList extends Component {\n static propTypes = {\n options: PropTypes.shape({\n type: PropTypes.string,\n filter: PropTypes.string,\n params: PropTypes.object,\n }).isRequired,\n }\n\n constructor(props) {\n super(props)\n this.state = {\n showIncrements: false,\n resetOrderTransaction: {},\n }\n }\n\n actionHandlers = {\n showIncrements: () => {\n this.setState((state) => ({\n showIncrements: !state.showIncrements,\n }))\n },\n\n resetOrder: async () => {\n this.setState(() => ({\n resetOrderTransaction: {\n status: `info`,\n title: `Reordering started...`,\n closable: true,\n },\n }))\n\n const update = await resetOrder(this.props.options.type)\n\n const reorderWasSuccessful = update?.results?.length\n\n this.setState(() => ({\n resetOrderTransaction: {\n status: reorderWasSuccessful ? `success` : `info`,\n title: reorderWasSuccessful\n ? `Reordered ${update.results.length === 1 ? `Document` : `Documents`}`\n : `Reordering failed`,\n closable: true,\n },\n }))\n },\n }\n\n render() {\n return (\n <DocumentListWrapper\n type={this?.props?.options?.type}\n filter={this?.props?.options?.filter}\n params={this?.props?.options?.params}\n showIncrements={this.state.showIncrements}\n resetOrderTransaction={this.state.resetOrderTransaction}\n />\n )\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AACA;AAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAE/C;AACe,MAAMA,qBAAqB,SAASC,gBAAS,CAAC;EAS3DC,WAAW,CAACC,KAAK,EAAE;IAAA;IACjB,KAAK,CAACA,KAAK,CAAC;IAAA;IAAA,wCAOG;MACfC,cAAc,EAAE,MAAM;QACpB,IAAI,CAACC,QAAQ,CAAEC,KAAK,KAAM;UACxBF,cAAc,EAAE,CAACE,KAAK,CAACF;QAC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;MAC1C,qBAAqB,EAAE,IAAI,CAACE,KAAK,CAACE;IAAsB,EACxD;EAEN;AACF;AAAC;AAAA,gBA5DoBR,qBAAqB,eACrB;EACjBa,OAAO,EAAEQ,kBAAS,CAACC,KAAK,CAAC;IACvBR,IAAI,EAAEO,kBAAS,CAACE,MAAM;IACtBJ,MAAM,EAAEE,kBAAS,CAACE,MAAM;IACxBH,MAAM,EAAEC,kBAAS,CAACG;EACpB,CAAC,CAAC,CAACC;AACL,CAAC"}
@@ -4,33 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.orderableDocumentListDeskItem = orderableDocumentListDeskItem;
7
-
8
7
  var _structureBuilder = _interopRequireDefault(require("@sanity/desk-tool/structure-builder"));
9
-
10
8
  var _icons = require("@sanity/icons");
11
-
12
9
  var _schema = _interopRequireDefault(require("part:@sanity/base/schema"));
13
-
14
10
  var _OrderableDocumentList = _interopRequireDefault(require("../OrderableDocumentList"));
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  function orderableDocumentListDeskItem() {
19
13
  var _schema$get$title, _schema$get;
20
-
21
14
  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
22
-
23
15
  if (!(config !== null && config !== void 0 && config.type)) {
24
16
  throw new Error("\n \"type\" not defined in orderableDocumentListDeskItem parameters.\n \n\n\n Example: orderableDocumentListDeskItem({type: 'category'})\n ");
25
17
  }
26
-
27
18
  var type = config.type,
28
- filter = config.filter,
29
- params = config.params,
30
- title = config.title,
31
- icon = config.icon;
19
+ filter = config.filter,
20
+ params = config.params,
21
+ title = config.title,
22
+ icon = config.icon,
23
+ id = config.id;
32
24
  var listTitle = title !== null && title !== void 0 ? title : "Orderable ".concat(type);
33
- var listId = "orderable-".concat(type);
25
+ var listId = id !== null && id !== void 0 ? id : "orderable-".concat(type);
34
26
  var listIcon = icon !== null && icon !== void 0 ? icon : _icons.SortIcon;
35
27
  var typeTitle = (_schema$get$title = (_schema$get = _schema.default.get(type)) === null || _schema$get === void 0 ? void 0 : _schema$get.title) !== null && _schema$get$title !== void 0 ? _schema$get$title : type;
36
28
  return _structureBuilder.default.listItem(type).title(listTitle).id(listId).icon(listIcon).child(Object.assign(_structureBuilder.default.documentTypeList(type).serialize(), {