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.esm.js
CHANGED
|
@@ -1059,7 +1059,8 @@ function DocumentCard(props) {
|
|
|
1059
1059
|
children: [/* @__PURE__ */jsx(Box, {
|
|
1060
1060
|
flex: 1,
|
|
1061
1061
|
children: /* @__PURE__ */jsx(Preview, {
|
|
1062
|
-
layout: "
|
|
1062
|
+
layout: "default",
|
|
1063
|
+
skipVisibilityCheck: true,
|
|
1063
1064
|
value: item,
|
|
1064
1065
|
schemaType: schema.get(item._type)
|
|
1065
1066
|
})
|
|
@@ -1113,6 +1114,21 @@ function DocumentCard(props) {
|
|
|
1113
1114
|
})]
|
|
1114
1115
|
});
|
|
1115
1116
|
}
|
|
1117
|
+
function getStyle(draggableStyle, virtualItem) {
|
|
1118
|
+
let transform = "translateY(".concat(virtualItem.start, "px)");
|
|
1119
|
+
if (draggableStyle && draggableStyle.transform) {
|
|
1120
|
+
const draggableTransformY = parseInt(draggableStyle.transform.split(",")[1].split("px")[0], 10);
|
|
1121
|
+
transform = "translateY(".concat(virtualItem.start + draggableTransformY, "px)");
|
|
1122
|
+
}
|
|
1123
|
+
return {
|
|
1124
|
+
position: "absolute",
|
|
1125
|
+
top: 0,
|
|
1126
|
+
left: 0,
|
|
1127
|
+
width: "100%",
|
|
1128
|
+
height: "".concat(virtualItem.size, "px"),
|
|
1129
|
+
transform
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1116
1132
|
function DocumentList(props) {
|
|
1117
1133
|
const {
|
|
1118
1134
|
data = [],
|
|
@@ -1131,17 +1147,20 @@ function DocumentList(props) {
|
|
|
1131
1147
|
return data.length ? filterItemsAndSort(data, state.id, selectedUserIds, selectedSchemaTypes) : [];
|
|
1132
1148
|
}, [data, selectedSchemaTypes, selectedUserIds, state.id]);
|
|
1133
1149
|
const parentRef = useRef(null);
|
|
1134
|
-
const
|
|
1135
|
-
count:
|
|
1150
|
+
const virtualizer = useVirtualizer({
|
|
1151
|
+
count: dataFiltered.length,
|
|
1136
1152
|
getScrollElement: () => parentRef.current,
|
|
1137
1153
|
getItemKey: index => {
|
|
1138
1154
|
var _a, _b, _c;
|
|
1139
1155
|
return (_c = (_b = (_a = dataFiltered[index]) == null ? void 0 : _a._metadata) == null ? void 0 : _b.documentId) != null ? _c : index;
|
|
1140
1156
|
},
|
|
1141
|
-
estimateSize: () =>
|
|
1142
|
-
overscan:
|
|
1157
|
+
estimateSize: () => 115,
|
|
1158
|
+
overscan: 7,
|
|
1159
|
+
measureElement: element => {
|
|
1160
|
+
return element.getBoundingClientRect().height || 115;
|
|
1161
|
+
}
|
|
1143
1162
|
});
|
|
1144
|
-
if (!data.length) {
|
|
1163
|
+
if (!data.length || !dataFiltered.length) {
|
|
1145
1164
|
return null;
|
|
1146
1165
|
}
|
|
1147
1166
|
return /* @__PURE__ */jsx("div", {
|
|
@@ -1149,44 +1168,53 @@ function DocumentList(props) {
|
|
|
1149
1168
|
style: {
|
|
1150
1169
|
height: "100%",
|
|
1151
1170
|
overflow: "auto",
|
|
1152
|
-
paddingTop: 1,
|
|
1153
1171
|
// Smooths scrollbar behaviour
|
|
1154
1172
|
overflowAnchor: "none",
|
|
1155
|
-
scrollBehavior: "auto"
|
|
1173
|
+
scrollBehavior: "auto",
|
|
1174
|
+
paddingTop: 1
|
|
1156
1175
|
},
|
|
1157
|
-
children:
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1176
|
+
children: /* @__PURE__ */jsx("div", {
|
|
1177
|
+
style: {
|
|
1178
|
+
height: "".concat(virtualizer.getTotalSize(), "px"),
|
|
1179
|
+
width: "100%",
|
|
1180
|
+
position: "relative"
|
|
1181
|
+
},
|
|
1182
|
+
children: virtualizer.getVirtualItems().map(virtualItem => {
|
|
1183
|
+
var _a;
|
|
1184
|
+
const item = dataFiltered[virtualItem.index];
|
|
1185
|
+
const {
|
|
1186
|
+
documentId,
|
|
1187
|
+
assignees
|
|
1188
|
+
} = (_a = item == null ? void 0 : item._metadata) != null ? _a : {};
|
|
1189
|
+
const isInvalid = invalidDocumentIds.includes(documentId);
|
|
1190
|
+
const meInAssignees = (user == null ? void 0 : user.id) ? assignees == null ? void 0 : assignees.includes(user.id) : false;
|
|
1191
|
+
const isDragDisabled = patchingIds.includes(documentId) || !userRoleCanDrop || isInvalid || !(state.requireAssignment ? state.requireAssignment && meInAssignees : true);
|
|
1192
|
+
return /* @__PURE__ */jsx(Draggable, {
|
|
1193
|
+
draggableId: documentId,
|
|
1194
|
+
index: virtualItem.index,
|
|
1195
|
+
isDragDisabled,
|
|
1196
|
+
children: (draggableProvided, draggableSnapshot) => /* @__PURE__ */jsx("div", {
|
|
1197
|
+
ref: draggableProvided.innerRef,
|
|
1198
|
+
...draggableProvided.draggableProps,
|
|
1199
|
+
...draggableProvided.dragHandleProps,
|
|
1200
|
+
style: getStyle(draggableProvided.draggableProps.style, virtualItem),
|
|
1201
|
+
children: /* @__PURE__ */jsx("div", {
|
|
1202
|
+
ref: virtualizer.measureElement,
|
|
1203
|
+
"data-index": virtualItem.index,
|
|
1204
|
+
children: /* @__PURE__ */jsx(DocumentCard, {
|
|
1205
|
+
userRoleCanDrop,
|
|
1206
|
+
isDragDisabled,
|
|
1207
|
+
isPatching: patchingIds.includes(documentId),
|
|
1208
|
+
isDragging: draggableSnapshot.isDragging,
|
|
1209
|
+
item,
|
|
1210
|
+
toggleInvalidDocumentId,
|
|
1211
|
+
userList,
|
|
1212
|
+
states
|
|
1213
|
+
})
|
|
1214
|
+
})
|
|
1187
1215
|
})
|
|
1188
|
-
})
|
|
1189
|
-
}
|
|
1216
|
+
}, virtualItem.key);
|
|
1217
|
+
})
|
|
1190
1218
|
})
|
|
1191
1219
|
});
|
|
1192
1220
|
}
|
|
@@ -1913,7 +1941,6 @@ function WorkflowTool(props) {
|
|
|
1913
1941
|
ref: provided.innerRef,
|
|
1914
1942
|
tone: snapshot.isDraggingOver ? "primary" : defaultCardTone,
|
|
1915
1943
|
height: "fill",
|
|
1916
|
-
paddingTop: 1,
|
|
1917
1944
|
children: [loading ? /* @__PURE__ */jsx(Flex, {
|
|
1918
1945
|
padding: 5,
|
|
1919
1946
|
align: "center",
|