sanity-plugin-workflow 1.0.0-beta.8 → 1.0.0-beta.9
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.esm.js +68 -41
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +68 -41
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/DocumentCard/index.tsx +2 -4
- package/src/components/DocumentList.tsx +98 -55
- package/src/components/WorkflowTool.tsx +0 -1
package/lib/index.js
CHANGED
|
@@ -1072,7 +1072,8 @@ function DocumentCard(props) {
|
|
|
1072
1072
|
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
1073
1073
|
flex: 1,
|
|
1074
1074
|
children: /* @__PURE__ */jsxRuntime.jsx(sanity.Preview, {
|
|
1075
|
-
layout: "
|
|
1075
|
+
layout: "default",
|
|
1076
|
+
skipVisibilityCheck: true,
|
|
1076
1077
|
value: item,
|
|
1077
1078
|
schemaType: schema.get(item._type)
|
|
1078
1079
|
})
|
|
@@ -1126,6 +1127,21 @@ function DocumentCard(props) {
|
|
|
1126
1127
|
})]
|
|
1127
1128
|
});
|
|
1128
1129
|
}
|
|
1130
|
+
function getStyle(draggableStyle, virtualItem) {
|
|
1131
|
+
let transform = "translateY(".concat(virtualItem.start, "px)");
|
|
1132
|
+
if (draggableStyle && draggableStyle.transform) {
|
|
1133
|
+
const draggableTransformY = parseInt(draggableStyle.transform.split(",")[1].split("px")[0], 10);
|
|
1134
|
+
transform = "translateY(".concat(virtualItem.start + draggableTransformY, "px)");
|
|
1135
|
+
}
|
|
1136
|
+
return {
|
|
1137
|
+
position: "absolute",
|
|
1138
|
+
top: 0,
|
|
1139
|
+
left: 0,
|
|
1140
|
+
width: "100%",
|
|
1141
|
+
height: "".concat(virtualItem.size, "px"),
|
|
1142
|
+
transform
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1129
1145
|
function DocumentList(props) {
|
|
1130
1146
|
const {
|
|
1131
1147
|
data = [],
|
|
@@ -1144,17 +1160,20 @@ function DocumentList(props) {
|
|
|
1144
1160
|
return data.length ? filterItemsAndSort(data, state.id, selectedUserIds, selectedSchemaTypes) : [];
|
|
1145
1161
|
}, [data, selectedSchemaTypes, selectedUserIds, state.id]);
|
|
1146
1162
|
const parentRef = React.useRef(null);
|
|
1147
|
-
const
|
|
1148
|
-
count:
|
|
1163
|
+
const virtualizer = reactVirtual.useVirtualizer({
|
|
1164
|
+
count: dataFiltered.length,
|
|
1149
1165
|
getScrollElement: () => parentRef.current,
|
|
1150
1166
|
getItemKey: index => {
|
|
1151
1167
|
var _a, _b, _c;
|
|
1152
1168
|
return (_c = (_b = (_a = dataFiltered[index]) == null ? void 0 : _a._metadata) == null ? void 0 : _b.documentId) != null ? _c : index;
|
|
1153
1169
|
},
|
|
1154
|
-
estimateSize: () =>
|
|
1155
|
-
overscan:
|
|
1170
|
+
estimateSize: () => 115,
|
|
1171
|
+
overscan: 7,
|
|
1172
|
+
measureElement: element => {
|
|
1173
|
+
return element.getBoundingClientRect().height || 115;
|
|
1174
|
+
}
|
|
1156
1175
|
});
|
|
1157
|
-
if (!data.length) {
|
|
1176
|
+
if (!data.length || !dataFiltered.length) {
|
|
1158
1177
|
return null;
|
|
1159
1178
|
}
|
|
1160
1179
|
return /* @__PURE__ */jsxRuntime.jsx("div", {
|
|
@@ -1162,44 +1181,53 @@ function DocumentList(props) {
|
|
|
1162
1181
|
style: {
|
|
1163
1182
|
height: "100%",
|
|
1164
1183
|
overflow: "auto",
|
|
1165
|
-
paddingTop: 1,
|
|
1166
1184
|
// Smooths scrollbar behaviour
|
|
1167
1185
|
overflowAnchor: "none",
|
|
1168
|
-
scrollBehavior: "auto"
|
|
1186
|
+
scrollBehavior: "auto",
|
|
1187
|
+
paddingTop: 1
|
|
1169
1188
|
},
|
|
1170
|
-
children:
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1189
|
+
children: /* @__PURE__ */jsxRuntime.jsx("div", {
|
|
1190
|
+
style: {
|
|
1191
|
+
height: "".concat(virtualizer.getTotalSize(), "px"),
|
|
1192
|
+
width: "100%",
|
|
1193
|
+
position: "relative"
|
|
1194
|
+
},
|
|
1195
|
+
children: virtualizer.getVirtualItems().map(virtualItem => {
|
|
1196
|
+
var _a;
|
|
1197
|
+
const item = dataFiltered[virtualItem.index];
|
|
1198
|
+
const {
|
|
1199
|
+
documentId,
|
|
1200
|
+
assignees
|
|
1201
|
+
} = (_a = item == null ? void 0 : item._metadata) != null ? _a : {};
|
|
1202
|
+
const isInvalid = invalidDocumentIds.includes(documentId);
|
|
1203
|
+
const meInAssignees = (user == null ? void 0 : user.id) ? assignees == null ? void 0 : assignees.includes(user.id) : false;
|
|
1204
|
+
const isDragDisabled = patchingIds.includes(documentId) || !userRoleCanDrop || isInvalid || !(state.requireAssignment ? state.requireAssignment && meInAssignees : true);
|
|
1205
|
+
return /* @__PURE__ */jsxRuntime.jsx(dnd.Draggable, {
|
|
1206
|
+
draggableId: documentId,
|
|
1207
|
+
index: virtualItem.index,
|
|
1208
|
+
isDragDisabled,
|
|
1209
|
+
children: (draggableProvided, draggableSnapshot) => /* @__PURE__ */jsxRuntime.jsx("div", {
|
|
1210
|
+
ref: draggableProvided.innerRef,
|
|
1211
|
+
...draggableProvided.draggableProps,
|
|
1212
|
+
...draggableProvided.dragHandleProps,
|
|
1213
|
+
style: getStyle(draggableProvided.draggableProps.style, virtualItem),
|
|
1214
|
+
children: /* @__PURE__ */jsxRuntime.jsx("div", {
|
|
1215
|
+
ref: virtualizer.measureElement,
|
|
1216
|
+
"data-index": virtualItem.index,
|
|
1217
|
+
children: /* @__PURE__ */jsxRuntime.jsx(DocumentCard, {
|
|
1218
|
+
userRoleCanDrop,
|
|
1219
|
+
isDragDisabled,
|
|
1220
|
+
isPatching: patchingIds.includes(documentId),
|
|
1221
|
+
isDragging: draggableSnapshot.isDragging,
|
|
1222
|
+
item,
|
|
1223
|
+
toggleInvalidDocumentId,
|
|
1224
|
+
userList,
|
|
1225
|
+
states
|
|
1226
|
+
})
|
|
1227
|
+
})
|
|
1200
1228
|
})
|
|
1201
|
-
})
|
|
1202
|
-
}
|
|
1229
|
+
}, virtualItem.key);
|
|
1230
|
+
})
|
|
1203
1231
|
})
|
|
1204
1232
|
});
|
|
1205
1233
|
}
|
|
@@ -1926,7 +1954,6 @@ function WorkflowTool(props) {
|
|
|
1926
1954
|
ref: provided.innerRef,
|
|
1927
1955
|
tone: snapshot.isDraggingOver ? "primary" : defaultCardTone,
|
|
1928
1956
|
height: "fill",
|
|
1929
|
-
paddingTop: 1,
|
|
1930
1957
|
children: [loading ? /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
1931
1958
|
padding: 5,
|
|
1932
1959
|
align: "center",
|