sanity 5.0.1-next.39 → 5.0.1-next.40
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/_chunks-es/package.js +1 -1
- package/lib/_chunks-es/version.js +1 -1
- package/lib/index.js +76 -69
- package/lib/index.js.map +1 -1
- package/package.json +14 -14
|
@@ -7,7 +7,7 @@ try {
|
|
|
7
7
|
try {
|
|
8
8
|
buildVersion = buildVersion || // This is replaced by `@sanity/pkg-utils` at build time
|
|
9
9
|
// and must always be references by its full static name, e.g. no optional chaining, no `if (process && process.env)` etc.
|
|
10
|
-
"5.0.1-next.
|
|
10
|
+
"5.0.1-next.40+b3a4fe2b2f";
|
|
11
11
|
} catch {
|
|
12
12
|
}
|
|
13
13
|
const SANITY_VERSION = buildVersion || `${version}-dev`;
|
package/lib/index.js
CHANGED
|
@@ -22111,7 +22111,7 @@ const Overlay$2 = styled(Layer)`
|
|
|
22111
22111
|
function uploadTarget$1(Component2) {
|
|
22112
22112
|
const FileTarget2 = fileTarget(Component2);
|
|
22113
22113
|
return forwardRef(function(props2, forwardedRef) {
|
|
22114
|
-
const $ = c(
|
|
22114
|
+
const $ = c(68);
|
|
22115
22115
|
let children, isReadOnly, onSelectFile, onSetHoveringFiles, pasteTarget, rest, toneFromProps, types;
|
|
22116
22116
|
$[0] !== props2 ? ({
|
|
22117
22117
|
children,
|
|
@@ -22132,109 +22132,116 @@ function uploadTarget$1(Component2) {
|
|
|
22132
22132
|
$[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[9] = t0) : t0 = $[9];
|
|
22133
22133
|
const [filesToUpload, setFilesToUpload] = useState(t0), [showAssetSourceDestinationPicker, setShowAssetSourceDestinationPicker] = useState(!1), [tone, setTone] = useState(toneFromProps || (isReadOnly ? "transparent" : "default")), assetSourceDestinationName = useRef(null);
|
|
22134
22134
|
let t1;
|
|
22135
|
-
$[10] !==
|
|
22136
|
-
|
|
22137
|
-
rejected.length > 0 && pushToast({
|
|
22135
|
+
$[10] !== pushToast || $[11] !== t ? (t1 = (rejected) => {
|
|
22136
|
+
pushToast({
|
|
22138
22137
|
closable: !0,
|
|
22139
22138
|
status: "warning",
|
|
22140
22139
|
title: t("inputs.array.error.cannot-upload-unable-to-convert", {
|
|
22141
22140
|
count: rejected.length
|
|
22142
22141
|
}),
|
|
22143
|
-
description: rejected.map(
|
|
22144
|
-
})
|
|
22142
|
+
description: rejected.map(_temp$3m)
|
|
22143
|
+
});
|
|
22144
|
+
}, $[10] = pushToast, $[11] = t, $[12] = t1) : t1 = $[12];
|
|
22145
|
+
const alertRejectedFiles = t1;
|
|
22146
|
+
let t2;
|
|
22147
|
+
$[13] !== alertRejectedFiles || $[14] !== formBuilder || $[15] !== onSelectFile || $[16] !== types ? (t2 = (files) => {
|
|
22148
|
+
const filesAndAssetSources = getFilesAndAssetSources(files, types, assetSourceDestinationName.current, formBuilder), ready = filesAndAssetSources.filter(_temp2$1o), rejected_0 = filesAndAssetSources.filter(_temp3$C);
|
|
22149
|
+
rejected_0.length > 0 && alertRejectedFiles(rejected_0), onSelectFile && ready.forEach((entry_1) => {
|
|
22145
22150
|
onSelectFile({
|
|
22146
22151
|
assetSource: entry_1.assetSource,
|
|
22147
22152
|
schemaType: entry_1.schemaType,
|
|
22148
22153
|
file: entry_1.file
|
|
22149
22154
|
});
|
|
22150
22155
|
});
|
|
22151
|
-
}, $[
|
|
22152
|
-
const handleUploadFiles =
|
|
22153
|
-
let
|
|
22154
|
-
$[
|
|
22156
|
+
}, $[13] = alertRejectedFiles, $[14] = formBuilder, $[15] = onSelectFile, $[16] = types, $[17] = t2) : t2 = $[17];
|
|
22157
|
+
const handleUploadFiles = t2;
|
|
22158
|
+
let t3;
|
|
22159
|
+
$[18] !== alertRejectedFiles || $[19] !== formBuilder || $[20] !== handleUploadFiles || $[21] !== isReadOnly || $[22] !== types ? (t3 = (files_0) => {
|
|
22155
22160
|
if (isReadOnly || types.length === 0)
|
|
22156
22161
|
return;
|
|
22157
|
-
const
|
|
22158
|
-
if (ready_0.length === 0)
|
|
22162
|
+
const filesAndAssetSources_0 = getFilesAndAssetSources(files_0, types, assetSourceDestinationName.current, formBuilder), ready_0 = filesAndAssetSources_0.filter(_temp4$h);
|
|
22163
|
+
if (ready_0.length === 0) {
|
|
22164
|
+
alertRejectedFiles(filesAndAssetSources_0);
|
|
22159
22165
|
return;
|
|
22166
|
+
}
|
|
22160
22167
|
const allAssetSources = types.flatMap((type) => resolveUploadAssetSources?.(type, formBuilder) ?? []);
|
|
22161
22168
|
if (uniqBy(allAssetSources, "name").length > 1 && !assetSourceDestinationName.current) {
|
|
22162
22169
|
setShowAssetSourceDestinationPicker(!0), setFilesToUpload(files_0);
|
|
22163
22170
|
return;
|
|
22164
22171
|
}
|
|
22165
22172
|
setShowAssetSourceDestinationPicker(!1), setFilesToUpload([]), handleUploadFiles(ready_0.map(_temp5$a));
|
|
22166
|
-
}, $[
|
|
22167
|
-
const handleFiles =
|
|
22168
|
-
let t3;
|
|
22169
|
-
$[21] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = [], $[21] = t3) : t3 = $[21];
|
|
22170
|
-
const [hoveringFiles, setHoveringFiles] = useState(t3);
|
|
22173
|
+
}, $[18] = alertRejectedFiles, $[19] = formBuilder, $[20] = handleUploadFiles, $[21] = isReadOnly, $[22] = types, $[23] = t3) : t3 = $[23];
|
|
22174
|
+
const handleFiles = t3;
|
|
22171
22175
|
let t4;
|
|
22172
|
-
$[
|
|
22176
|
+
$[24] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = [], $[24] = t4) : t4 = $[24];
|
|
22177
|
+
const [hoveringFiles, setHoveringFiles] = useState(t4);
|
|
22178
|
+
let t5;
|
|
22179
|
+
$[25] !== formBuilder || $[26] !== isReadOnly || $[27] !== onSetHoveringFiles || $[28] !== types ? (t5 = (files_1) => {
|
|
22173
22180
|
if (isReadOnly)
|
|
22174
22181
|
return;
|
|
22175
22182
|
setHoveringFiles(files_1);
|
|
22176
22183
|
const acceptedFiles = files_1.filter((file) => types.some((type_0) => resolveUploadAssetSources(type_0, formBuilder, file).length > 0));
|
|
22177
22184
|
files_1.length - acceptedFiles.length > 0 ? setTone("critical") : acceptedFiles.length > 0 ? setTone("primary") : setTone("default"), onSetHoveringFiles && onSetHoveringFiles(files_1);
|
|
22178
|
-
}, $[
|
|
22179
|
-
const handleFilesOver =
|
|
22180
|
-
let t5;
|
|
22181
|
-
$[27] !== isReadOnly || $[28] !== onSetHoveringFiles ? (t5 = () => {
|
|
22182
|
-
isReadOnly || (setHoveringFiles([]), setTone("default"), onSetHoveringFiles && onSetHoveringFiles([]), setFilesToUpload([]));
|
|
22183
|
-
}, $[27] = isReadOnly, $[28] = onSetHoveringFiles, $[29] = t5) : t5 = $[29];
|
|
22184
|
-
const handleFilesOut = t5;
|
|
22185
|
+
}, $[25] = formBuilder, $[26] = isReadOnly, $[27] = onSetHoveringFiles, $[28] = types, $[29] = t5) : t5 = $[29];
|
|
22186
|
+
const handleFilesOver = t5;
|
|
22185
22187
|
let t6;
|
|
22186
|
-
|
|
22187
|
-
|
|
22188
|
-
|
|
22189
|
-
|
|
22190
|
-
t6 = uniqBy(allAssetSourcesWithUpload, "name"), $[30] = formBuilder, $[31] = types, $[32] = t6;
|
|
22191
|
-
} else
|
|
22192
|
-
t6 = $[32];
|
|
22193
|
-
const assetSourcesWithUploadByName = t6;
|
|
22188
|
+
$[30] !== isReadOnly || $[31] !== onSetHoveringFiles ? (t6 = () => {
|
|
22189
|
+
isReadOnly || (setHoveringFiles([]), setTone("default"), onSetHoveringFiles && onSetHoveringFiles([]), setFilesToUpload([]));
|
|
22190
|
+
}, $[30] = isReadOnly, $[31] = onSetHoveringFiles, $[32] = t6) : t6 = $[32];
|
|
22191
|
+
const handleFilesOut = t6;
|
|
22194
22192
|
let t7;
|
|
22195
|
-
$[
|
|
22196
|
-
|
|
22197
|
-
|
|
22198
|
-
|
|
22193
|
+
if ($[33] !== formBuilder || $[34] !== types) {
|
|
22194
|
+
let t82;
|
|
22195
|
+
$[36] !== formBuilder ? (t82 = (type_1) => resolveUploadAssetSources?.(type_1, formBuilder) ?? [], $[36] = formBuilder, $[37] = t82) : t82 = $[37];
|
|
22196
|
+
const allAssetSourcesWithUpload = types.flatMap(t82);
|
|
22197
|
+
t7 = uniqBy(allAssetSourcesWithUpload, "name"), $[33] = formBuilder, $[34] = types, $[35] = t7;
|
|
22198
|
+
} else
|
|
22199
|
+
t7 = $[35];
|
|
22200
|
+
const assetSourcesWithUploadByName = t7;
|
|
22199
22201
|
let t8;
|
|
22200
|
-
$[38] !==
|
|
22202
|
+
$[38] !== filesToUpload || $[39] !== handleUploadFiles ? (t8 = (assetSource) => {
|
|
22203
|
+
assetSourceDestinationName.current = assetSource?.name ?? null, filesToUpload.length > 0 && assetSource && handleUploadFiles(filesToUpload), setFilesToUpload([]), setShowAssetSourceDestinationPicker(!1), assetSourceDestinationName.current = null;
|
|
22204
|
+
}, $[38] = filesToUpload, $[39] = handleUploadFiles, $[40] = t8) : t8 = $[40];
|
|
22205
|
+
const handleSetAssetSourceDestination = t8;
|
|
22206
|
+
let t9;
|
|
22207
|
+
$[41] !== handleFilesOver ? (t9 = () => {
|
|
22201
22208
|
handleFilesOver([]), setFilesToUpload([]), setShowAssetSourceDestinationPicker(!1), assetSourceDestinationName.current = null;
|
|
22202
|
-
}, $[
|
|
22203
|
-
const handleUploadDestinationPickerClose =
|
|
22204
|
-
let t10;
|
|
22205
|
-
$[40] !== t || $[41] !== t9 ? (t10 = t("inputs.files.common.placeholder.select-asset-source-upload-destination", {
|
|
22206
|
-
context: t9
|
|
22207
|
-
}), $[40] = t, $[41] = t9, $[42] = t10) : t10 = $[42];
|
|
22208
|
-
const uploadDestinationPickerText = t10;
|
|
22209
|
+
}, $[41] = handleFilesOver, $[42] = t9) : t9 = $[42];
|
|
22210
|
+
const handleUploadDestinationPickerClose = t9, t10 = types.length > 1 ? "array" : types[0].name;
|
|
22209
22211
|
let t11;
|
|
22210
|
-
$[43] !==
|
|
22211
|
-
|
|
22212
|
-
|
|
22213
|
-
|
|
22212
|
+
$[43] !== t || $[44] !== t10 ? (t11 = t("inputs.files.common.placeholder.select-asset-source-upload-destination", {
|
|
22213
|
+
context: t10
|
|
22214
|
+
}), $[43] = t, $[44] = t10, $[45] = t11) : t11 = $[45];
|
|
22215
|
+
const uploadDestinationPickerText = t11;
|
|
22216
|
+
let t12;
|
|
22217
|
+
$[46] !== assetSourcesWithUploadByName || $[47] !== handleSetAssetSourceDestination || $[48] !== handleUploadDestinationPickerClose || $[49] !== showAssetSourceDestinationPicker || $[50] !== uploadDestinationPickerText ? (t12 = showAssetSourceDestinationPicker && /* @__PURE__ */ jsx(UploadDestinationPicker, { assetSources: assetSourcesWithUploadByName, onSelectAssetSource: handleSetAssetSourceDestination, onClose: handleUploadDestinationPickerClose, text: uploadDestinationPickerText }), $[46] = assetSourcesWithUploadByName, $[47] = handleSetAssetSourceDestination, $[48] = handleUploadDestinationPickerClose, $[49] = showAssetSourceDestinationPicker, $[50] = uploadDestinationPickerText, $[51] = t12) : t12 = $[51];
|
|
22218
|
+
const t13 = toneFromProps || tone;
|
|
22214
22219
|
let t14;
|
|
22215
|
-
$[52] !==
|
|
22216
|
-
t13,
|
|
22217
|
-
children
|
|
22218
|
-
] }), $[52] = children, $[53] = forwardedRef, $[54] = handleFiles, $[55] = handleFilesOut, $[56] = handleFilesOver, $[57] = pasteTarget, $[58] = rest, $[59] = t12, $[60] = t13, $[61] = t14) : t14 = $[61];
|
|
22220
|
+
$[52] !== hoveringFiles || $[53] !== types ? (t14 = hoveringFiles.length > 0 && /* @__PURE__ */ jsx(Overlay$2, { zOffset: 10, children: /* @__PURE__ */ jsx(DropMessage$1, { hoveringFiles, types }) }), $[52] = hoveringFiles, $[53] = types, $[54] = t14) : t14 = $[54];
|
|
22219
22221
|
let t15;
|
|
22220
|
-
|
|
22221
|
-
|
|
22222
|
-
|
|
22223
|
-
] }), $[62] =
|
|
22222
|
+
$[55] !== children || $[56] !== forwardedRef || $[57] !== handleFiles || $[58] !== handleFilesOut || $[59] !== handleFilesOver || $[60] !== pasteTarget || $[61] !== rest || $[62] !== t13 || $[63] !== t14 ? (t15 = /* @__PURE__ */ jsxs(FileTarget2, { ...rest, tone: t13, ref: forwardedRef, onFiles: handleFiles, onFilesOver: handleFilesOver, onFilesOut: handleFilesOut, pasteTarget, children: [
|
|
22223
|
+
t14,
|
|
22224
|
+
children
|
|
22225
|
+
] }), $[55] = children, $[56] = forwardedRef, $[57] = handleFiles, $[58] = handleFilesOut, $[59] = handleFilesOver, $[60] = pasteTarget, $[61] = rest, $[62] = t13, $[63] = t14, $[64] = t15) : t15 = $[64];
|
|
22226
|
+
let t16;
|
|
22227
|
+
return $[65] !== t12 || $[66] !== t15 ? (t16 = /* @__PURE__ */ jsxs(Root$t, { children: [
|
|
22228
|
+
t12,
|
|
22229
|
+
t15
|
|
22230
|
+
] }), $[65] = t12, $[66] = t15, $[67] = t16) : t16 = $[67], t16;
|
|
22224
22231
|
});
|
|
22225
22232
|
}
|
|
22226
22233
|
function getFilesAndAssetSources(files, types, assetSourceDestinationName, formBuilder) {
|
|
22227
|
-
const imageType = types.find((type) => type.name === "image"),
|
|
22234
|
+
const imageType = types.find((type) => type.name === "image"), fileType = types.find((type) => type.name === "file");
|
|
22228
22235
|
return files.map((file) => {
|
|
22229
|
-
const
|
|
22230
|
-
if (
|
|
22236
|
+
const imageAssetSource = imageType && resolveUploadAssetSources(imageType, formBuilder, file).find((source) => !assetSourceDestinationName || source.name === assetSourceDestinationName) || null;
|
|
22237
|
+
if (imageType && file.type.startsWith("image/") && imageAssetSource)
|
|
22231
22238
|
return {
|
|
22232
22239
|
file,
|
|
22233
22240
|
schemaType: imageType,
|
|
22234
22241
|
assetSource: imageAssetSource
|
|
22235
22242
|
};
|
|
22236
|
-
const
|
|
22237
|
-
return
|
|
22243
|
+
const fileAssetSource = fileType && resolveUploadAssetSources(fileType, formBuilder, file).find((source) => !assetSourceDestinationName || source.name === assetSourceDestinationName) || null;
|
|
22244
|
+
return fileType && fileAssetSource ? {
|
|
22238
22245
|
file,
|
|
22239
22246
|
schemaType: fileType,
|
|
22240
22247
|
assetSource: fileAssetSource
|
|
@@ -22245,13 +22252,7 @@ function getFilesAndAssetSources(files, types, assetSourceDestinationName, formB
|
|
|
22245
22252
|
};
|
|
22246
22253
|
});
|
|
22247
22254
|
}
|
|
22248
|
-
function _temp$3m(
|
|
22249
|
-
return entry.assetSource !== null;
|
|
22250
|
-
}
|
|
22251
|
-
function _temp2$1o(entry_0) {
|
|
22252
|
-
return entry_0.assetSource === null;
|
|
22253
|
-
}
|
|
22254
|
-
function _temp3$C(task, i) {
|
|
22255
|
+
function _temp$3m(task, i) {
|
|
22255
22256
|
return /* @__PURE__ */ jsxs(Flex, { gap: 2, padding: 2, children: [
|
|
22256
22257
|
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text$1, { weight: "medium", children: task.file.name }) }),
|
|
22257
22258
|
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Text$1, { size: 1, children: [
|
|
@@ -22261,6 +22262,12 @@ function _temp3$C(task, i) {
|
|
|
22261
22262
|
] }) })
|
|
22262
22263
|
] }, i);
|
|
22263
22264
|
}
|
|
22265
|
+
function _temp2$1o(entry) {
|
|
22266
|
+
return entry.assetSource !== null;
|
|
22267
|
+
}
|
|
22268
|
+
function _temp3$C(entry_0) {
|
|
22269
|
+
return entry_0.assetSource === null;
|
|
22270
|
+
}
|
|
22264
22271
|
function _temp4$h(entry_2) {
|
|
22265
22272
|
return entry_2.assetSource !== null;
|
|
22266
22273
|
}
|