sanity-plugin-cloudinary 1.4.1 → 2.0.1
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/LICENSE +1 -1
- package/README.md +2 -3
- package/dist/index.d.ts +88 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +726 -0
- package/dist/index.js.map +1 -0
- package/package.json +37 -72
- package/lib/index.d.ts +0 -93
- package/lib/index.esm.js +0 -774
- package/lib/index.esm.js.map +0 -1
- package/lib/index.js +0 -791
- package/lib/index.js.map +0 -1
- package/sanity.json +0 -8
- package/src/components/AssetDiff.tsx +0 -44
- package/src/components/AssetListFunctions.tsx +0 -100
- package/src/components/AssetPreview.tsx +0 -66
- package/src/components/CloudinaryInput.tsx +0 -121
- package/src/components/SecretsConfigView.tsx +0 -39
- package/src/components/VideoPlayer.tsx +0 -24
- package/src/components/WidgetInput.tsx +0 -66
- package/src/components/asset-source/CloudinaryAssetSource.tsx +0 -155
- package/src/components/asset-source/Icon.tsx +0 -93
- package/src/index.ts +0 -71
- package/src/schema/cloudinaryAsset.ts +0 -107
- package/src/schema/cloudinaryAssetContext.ts +0 -16
- package/src/schema/cloudinaryAssetContextCustom.ts +0 -21
- package/src/schema/cloudinaryAssetDerived.ts +0 -26
- package/src/types.ts +0 -72
- package/src/utils.ts +0 -115
- package/v2-incompatible.js +0 -11
package/dist/index.js
ADDED
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
import { DiffFromTo, PatchEvent, unset, set, defineType, setIfMissing, insert, ArrayOfObjectsFunctions, definePlugin, isArrayOfObjectsInputProps } from "sanity";
|
|
2
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { PlugIcon, DocumentIcon } from "@sanity/icons";
|
|
5
|
+
import { SettingsView, useSecrets } from "@sanity/studio-secrets";
|
|
6
|
+
import { Dialog, Flex, Button, Stack, Spinner, Text, Box, Grid } from "@sanity/ui";
|
|
7
|
+
import { useState, useRef, useEffect } from "react";
|
|
8
|
+
import { styled } from "styled-components";
|
|
9
|
+
import { nanoid } from "nanoid";
|
|
10
|
+
const widgetSrc = "https://media-library.cloudinary.com/global/all.js";
|
|
11
|
+
function assetUrl(asset) {
|
|
12
|
+
const [derived] = asset.derived ?? [];
|
|
13
|
+
return derived ? derived.secure_url ? derived.secure_url : derived.url : asset.secure_url ? asset.secure_url : asset.url;
|
|
14
|
+
}
|
|
15
|
+
const openMediaSelector = (cloudName, apiKey, multiple, insertHandler, selectedAsset) => {
|
|
16
|
+
loadJS(widgetSrc, () => {
|
|
17
|
+
const options = {
|
|
18
|
+
cloud_name: cloudName,
|
|
19
|
+
api_key: apiKey,
|
|
20
|
+
insert_caption: "Select",
|
|
21
|
+
multiple
|
|
22
|
+
};
|
|
23
|
+
selectedAsset && (options.asset = {
|
|
24
|
+
public_id: selectedAsset.public_id,
|
|
25
|
+
type: selectedAsset.type,
|
|
26
|
+
resource_type: selectedAsset.resource_type
|
|
27
|
+
}), window.cloudinary.openMediaLibrary(options, {
|
|
28
|
+
insertHandler
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}, createMediaLibrary = ({
|
|
32
|
+
cloudName,
|
|
33
|
+
apiKey,
|
|
34
|
+
inlineContainer,
|
|
35
|
+
libraryCreated,
|
|
36
|
+
insertHandler
|
|
37
|
+
}) => {
|
|
38
|
+
loadJS(widgetSrc, () => {
|
|
39
|
+
const options = {
|
|
40
|
+
cloud_name: cloudName,
|
|
41
|
+
api_key: apiKey,
|
|
42
|
+
insert_caption: "Select",
|
|
43
|
+
inline_container: inlineContainer,
|
|
44
|
+
remove_header: !0
|
|
45
|
+
};
|
|
46
|
+
libraryCreated(window.cloudinary.createMediaLibrary(options, {
|
|
47
|
+
insertHandler
|
|
48
|
+
}));
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
function loadJS(url, callback) {
|
|
52
|
+
const existingScript = document.getElementById("damWidget");
|
|
53
|
+
if (!existingScript) {
|
|
54
|
+
const script = document.createElement("script");
|
|
55
|
+
script.src = url, script.id = "damWidget", document.body.appendChild(script), script.addEventListener("load", () => {
|
|
56
|
+
callback();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return existingScript && callback ? callback() : !0;
|
|
60
|
+
}
|
|
61
|
+
function encodeSourceId(asset) {
|
|
62
|
+
const {
|
|
63
|
+
resource_type,
|
|
64
|
+
public_id,
|
|
65
|
+
type
|
|
66
|
+
} = asset;
|
|
67
|
+
return btoa(JSON.stringify({
|
|
68
|
+
public_id,
|
|
69
|
+
resource_type,
|
|
70
|
+
type
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
function encodeFilename(asset) {
|
|
74
|
+
return `${asset.public_id.split("/").slice(-1)[0]}.${asset.format}`;
|
|
75
|
+
}
|
|
76
|
+
function decodeSourceId(sourceId) {
|
|
77
|
+
let sourceIdDecoded;
|
|
78
|
+
try {
|
|
79
|
+
sourceIdDecoded = JSON.parse(atob(sourceId));
|
|
80
|
+
} catch {
|
|
81
|
+
}
|
|
82
|
+
return sourceIdDecoded;
|
|
83
|
+
}
|
|
84
|
+
const pluginConfigKeys = [{
|
|
85
|
+
key: "cloudName",
|
|
86
|
+
title: "Cloud name",
|
|
87
|
+
description: ""
|
|
88
|
+
}, {
|
|
89
|
+
key: "apiKey",
|
|
90
|
+
title: "API key",
|
|
91
|
+
description: ""
|
|
92
|
+
}], namespace = "cloudinary", SecretsConfigView = (props) => {
|
|
93
|
+
const $ = c(2);
|
|
94
|
+
let t0;
|
|
95
|
+
return $[0] !== props.onClose ? (t0 = /* @__PURE__ */ jsx(SettingsView, { title: "Cloudinary config", namespace, keys: pluginConfigKeys, onClose: props.onClose }), $[0] = props.onClose, $[1] = t0) : t0 = $[1], t0;
|
|
96
|
+
}, Widget = styled.div.withConfig({
|
|
97
|
+
displayName: "Widget",
|
|
98
|
+
componentId: "sc-14cieex-0"
|
|
99
|
+
})`height:70vh;`;
|
|
100
|
+
function CloudinaryAssetSource(props) {
|
|
101
|
+
const $ = c(30), {
|
|
102
|
+
onClose,
|
|
103
|
+
dialogHeaderTitle
|
|
104
|
+
} = props, [loadingMessage, setLoadingMessage] = useState("Loading Cloudinary Media Libary"), library = useRef(void 0), contentRef = useRef(null), {
|
|
105
|
+
secrets
|
|
106
|
+
} = useSecrets(namespace), cloudName = secrets?.cloudName, apiKey = secrets?.apiKey, [widgetId] = useState(_temp$2), [showSettings, setShowSettings] = useState(!1), propsRef = useRef(props);
|
|
107
|
+
let t0, t1;
|
|
108
|
+
$[0] !== props ? (t0 = () => {
|
|
109
|
+
propsRef.current = props;
|
|
110
|
+
}, t1 = [props], $[0] = props, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1);
|
|
111
|
+
let t2;
|
|
112
|
+
$[3] !== onClose ? (t2 = () => {
|
|
113
|
+
library.current && library.current.hide(), onClose();
|
|
114
|
+
}, $[3] = onClose, $[4] = t2) : t2 = $[4];
|
|
115
|
+
const handleClose = t2;
|
|
116
|
+
let t3, t4;
|
|
117
|
+
$[5] !== apiKey || $[6] !== cloudName || $[7] !== widgetId ? (t3 = () => {
|
|
118
|
+
!cloudName || !apiKey || createMediaLibrary({
|
|
119
|
+
cloudName,
|
|
120
|
+
apiKey,
|
|
121
|
+
inlineContainer: `#${widgetId}`,
|
|
122
|
+
libraryCreated: (lib) => {
|
|
123
|
+
library.current = lib;
|
|
124
|
+
const selectedAssets = propsRef.current.selectedAssets, firstSelectedAsset = selectedAssets ? selectedAssets[0] : null, iframe = contentRef.current && contentRef.current.firstChild;
|
|
125
|
+
if (iframe && iframe instanceof HTMLIFrameElement) {
|
|
126
|
+
setLoadingMessage(void 0);
|
|
127
|
+
let asset;
|
|
128
|
+
propsRef.current.selectionType === "single" && firstSelectedAsset && firstSelectedAsset.source && firstSelectedAsset.source.id && (asset = decodeSourceId(firstSelectedAsset.source.id));
|
|
129
|
+
const folder = asset ? {
|
|
130
|
+
path: asset.public_id.split("/").slice(0, -1).join("/"),
|
|
131
|
+
resource_type: "image"
|
|
132
|
+
} : {
|
|
133
|
+
path: "",
|
|
134
|
+
resource_type: "image"
|
|
135
|
+
};
|
|
136
|
+
lib && contentRef.current && (lib.show({
|
|
137
|
+
folder,
|
|
138
|
+
asset
|
|
139
|
+
}), contentRef.current.style.visibility = "visible");
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
insertHandler: (t52) => {
|
|
143
|
+
const {
|
|
144
|
+
assets
|
|
145
|
+
} = t52;
|
|
146
|
+
if (!library.current)
|
|
147
|
+
return;
|
|
148
|
+
const imageAssets = assets.filter(_temp2$2);
|
|
149
|
+
if (imageAssets.length === 0)
|
|
150
|
+
throw new Error("The selection did not contain any images.");
|
|
151
|
+
library.current.hide(), propsRef.current.onSelect(imageAssets.map((asset_1) => ({
|
|
152
|
+
kind: "url",
|
|
153
|
+
value: asset_1.derived && asset_1.derived[0] ? asset_1.derived[0].secure_url : asset_1.secure_url,
|
|
154
|
+
assetDocumentProps: {
|
|
155
|
+
_type: "sanity.imageAsset",
|
|
156
|
+
originalFilename: encodeFilename(asset_1),
|
|
157
|
+
source: {
|
|
158
|
+
id: encodeSourceId(asset_1),
|
|
159
|
+
name: `cloudinary:${cloudName}`
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
})));
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}, t4 = [cloudName, apiKey, widgetId], $[5] = apiKey, $[6] = cloudName, $[7] = widgetId, $[8] = t3, $[9] = t4) : (t3 = $[8], t4 = $[9]), useEffect(t3, t4);
|
|
166
|
+
const hasConfig = apiKey && cloudName, t5 = dialogHeaderTitle ?? "Select image from Cloudinary";
|
|
167
|
+
let t6;
|
|
168
|
+
$[10] !== showSettings ? (t6 = showSettings && /* @__PURE__ */ jsx(SecretsConfigView, { onClose: () => setShowSettings(!1) }), $[10] = showSettings, $[11] = t6) : t6 = $[11];
|
|
169
|
+
let t7;
|
|
170
|
+
$[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t7 = () => setShowSettings(!0), $[12] = t7) : t7 = $[12];
|
|
171
|
+
const t8 = hasConfig ? void 0 : "Configure Cloudinary plugin";
|
|
172
|
+
let t9;
|
|
173
|
+
$[13] !== t8 ? (t9 = /* @__PURE__ */ jsx(Flex, { flex: 1, justify: "flex-end", children: /* @__PURE__ */ jsx(Button, { color: "primary", icon: PlugIcon, mode: "bleed", title: "Configure", onClick: t7, tabIndex: 0, text: t8 }) }), $[13] = t8, $[14] = t9) : t9 = $[14];
|
|
174
|
+
let t10;
|
|
175
|
+
$[15] !== hasConfig || $[16] !== loadingMessage ? (t10 = hasConfig && loadingMessage && /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
|
|
176
|
+
/* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", children: /* @__PURE__ */ jsx(Spinner, { muted: !0 }) }),
|
|
177
|
+
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, align: "center", children: loadingMessage })
|
|
178
|
+
] }), $[15] = hasConfig, $[16] = loadingMessage, $[17] = t10) : t10 = $[17];
|
|
179
|
+
let t11;
|
|
180
|
+
$[18] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t11 = {
|
|
181
|
+
visibility: "hidden"
|
|
182
|
+
}, $[18] = t11) : t11 = $[18];
|
|
183
|
+
let t12;
|
|
184
|
+
$[19] !== widgetId ? (t12 = /* @__PURE__ */ jsx(Widget, { style: t11, ref: contentRef, id: widgetId }), $[19] = widgetId, $[20] = t12) : t12 = $[20];
|
|
185
|
+
let t13;
|
|
186
|
+
$[21] !== t10 || $[22] !== t12 || $[23] !== t6 || $[24] !== t9 ? (t13 = /* @__PURE__ */ jsxs(Box, { padding: 4, children: [
|
|
187
|
+
t6,
|
|
188
|
+
t9,
|
|
189
|
+
t10,
|
|
190
|
+
t12
|
|
191
|
+
] }), $[21] = t10, $[22] = t12, $[23] = t6, $[24] = t9, $[25] = t13) : t13 = $[25];
|
|
192
|
+
let t14;
|
|
193
|
+
return $[26] !== handleClose || $[27] !== t13 || $[28] !== t5 ? (t14 = /* @__PURE__ */ jsx(Dialog, { id: "cloudinary-asset-source", header: t5, onClose: handleClose, open: !0, width: 4, children: t13 }), $[26] = handleClose, $[27] = t13, $[28] = t5, $[29] = t14) : t14 = $[29], t14;
|
|
194
|
+
}
|
|
195
|
+
function _temp2$2(asset_0) {
|
|
196
|
+
return asset_0.resource_type === "image";
|
|
197
|
+
}
|
|
198
|
+
function _temp$2() {
|
|
199
|
+
return `cloundinaryWidget-${Date.now()}`;
|
|
200
|
+
}
|
|
201
|
+
function CloudinaryIcon() {
|
|
202
|
+
const $ = c(1);
|
|
203
|
+
let t0;
|
|
204
|
+
return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("svg", { version: "1.1", id: "Layer_1", x: "0px", y: "0px", width: "1em", height: "1em", viewBox: "0 0 141.732 141.747", enableBackground: "new 0 0 141.732 141.747", children: /* @__PURE__ */ jsxs("g", { children: [
|
|
205
|
+
/* @__PURE__ */ jsx("path", { fill: "#0071CE", d: `M115.585,109.242c-1.609,0-3.107-1.024-3.635-2.637c-0.657-2.008,0.438-4.169,2.447-4.826
|
|
206
|
+
c7.278-2.382,11.98-8.761,11.98-16.252c0-9.487-7.718-17.206-17.205-17.206c-0.659,0-1.368,0.052-2.231,0.164l-3.741,0.485
|
|
207
|
+
l-0.537-3.735c-2.299-16.016-16.251-28.094-32.454-28.094c-13.395,0-25.32,8.019-30.377,20.43l-0.952,2.335l-2.52,0.046
|
|
208
|
+
c-11.581,0.213-21.003,9.804-21.003,21.379c0,8.45,4.906,16.156,12.498,19.631c1.921,0.88,2.766,3.15,1.886,5.071
|
|
209
|
+
c-0.88,1.921-3.149,2.764-5.07,1.887C14.363,103.202,7.703,92.766,7.703,81.331c0-14.88,11.465-27.345,26.028-28.876
|
|
210
|
+
c6.71-14.03,20.773-22.965,36.477-22.965c18.796,0,35.135,13.178,39.372,31.184c13.519,0.219,24.45,11.284,24.45,24.854
|
|
211
|
+
c0,10.693-6.934,20.146-17.253,23.523C116.382,109.18,115.98,109.242,115.585,109.242z` }),
|
|
212
|
+
/* @__PURE__ */ jsx("path", { fill: "#DC8327", d: `M57.12,111.02c-0.001-0.001-0.001-0.001-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001
|
|
213
|
+
c0,0-0.001-0.001-0.001-0.001l-0.001-0.001c0,0-0.001,0-0.001-0.001h-0.001l-0.001-0.001c0.001-0.001-0.001-0.001-0.001-0.001
|
|
214
|
+
l-0.001-0.001c0,0-0.001,0-0.001,0l-0.001-0.001c0.001,0.001-0.001-0.001-0.001-0.001s-0.002-0.001-0.003-0.001l-0.001-0.001H57.1
|
|
215
|
+
c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001c-0.003-0.001-0.002-0.001-0.003-0.001c-0.001,0.001-0.001-0.001-0.002-0.001
|
|
216
|
+
l-0.001-0.001c0,0-0.001-0.001-0.002-0.001l-0.001-0.001c-0.001-0.001-0.003-0.001-0.004-0.001s-0.003-0.001-0.004-0.001
|
|
217
|
+
c-0.001-0.001-0.001-0.001-0.002-0.001h-0.001c-0.001-0.001-0.002-0.001-0.003-0.001c-0.001-0.001-0.003-0.001-0.003-0.001
|
|
218
|
+
c-0.001,0-0.001,0-0.001,0l-0.002-0.001c-0.001,0-0.001-0.001-0.001-0.001h-0.001c-0.059-0.021-0.122-0.034-0.188-0.037h-0.002
|
|
219
|
+
h-0.002c-0.001,0-0.001,0-0.002,0c0,0,0,0-0.001,0c0,0-0.001,0-0.001,0h-0.001c-0.001-0.001-0.001-0.001-0.001-0.001
|
|
220
|
+
c-0.001,0-0.002,0-0.002,0c-0.001,0-0.002,0-0.002,0h-0.001h-0.001h-0.001c-0.001,0-0.002,0-0.002,0h-0.001H56.86h-0.001h-0.001
|
|
221
|
+
c-0.001,0-0.001,0-0.001,0h-0.001h-0.001h-0.001h-0.001c-0.001,0-0.001,0-0.001,0c-1.656,0-3.011-1.348-3.021-3V74.29h2.567
|
|
222
|
+
c0.004,0,0.009,0,0.013,0c0.393,0.017,0.661-0.285,0.661-0.648c0-0.271-0.166-0.503-0.402-0.6l-12.379-8.544
|
|
223
|
+
c-0.222-0.153-0.515-0.153-0.737,0l-12.476,8.611c-0.234,0.161-0.335,0.456-0.251,0.727c0.085,0.271,0.335,0.455,0.619,0.455h2.58
|
|
224
|
+
l0.002,33.674c0.013,2.328,1.883,4.228,4.262,4.288c0.027,0.003,0.053,0.005,0.08,0.005h18.481c0.004,0,0.007,0,0.011,0
|
|
225
|
+
c0.17-0.003,0.324-0.071,0.438-0.18c0,0,0,0,0.001-0.001c0.002-0.002,0.004-0.004,0.005-0.005c0.001-0.001,0.002-0.001,0.003-0.003
|
|
226
|
+
c0,0,0.001-0.001,0.001-0.001l0.001-0.001l0.001-0.001l0.001-0.001l0.001-0.001c0.001-0.001,0.001-0.001,0.001-0.001
|
|
227
|
+
c0.002-0.001,0.001-0.001,0.002-0.002c0,0,0,0,0.001-0.001l0.001-0.001c0,0,0,0,0.001-0.001c0.112-0.116,0.182-0.273,0.183-0.447
|
|
228
|
+
v-0.002v-0.001v-0.001v-0.001v-0.001v-0.001v-0.001v-0.002C57.498,111.345,57.343,111.121,57.12,111.02z` }),
|
|
229
|
+
/* @__PURE__ */ jsx("path", { fill: "#F4B21B", d: `M83.889,111.02c0,0-0.001-0.001-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001
|
|
230
|
+
c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001h-0.001c0,0-0.001-0.001-0.001-0.001c0,0-0.001-0.001-0.001-0.001
|
|
231
|
+
c0.001-0.001-0.001-0.001-0.002-0.001l-0.001-0.001h-0.001c-0.001,0-0.001-0.001-0.001-0.001c-0.002,0.001-0.002-0.001-0.002-0.001
|
|
232
|
+
l-0.002-0.001l-0.001-0.001h-0.001c0,0-0.001-0.001-0.001-0.001l-0.001-0.001c-0.001-0.001-0.002-0.001-0.002-0.001
|
|
233
|
+
c-0.001,0.001-0.001-0.001-0.003-0.001l-0.001-0.001l-0.001-0.001c0,0-0.001,0-0.002-0.001c-0.001-0.001-0.003-0.001-0.004-0.001
|
|
234
|
+
s-0.003-0.001-0.004-0.001c-0.001-0.001-0.001-0.001-0.002-0.001c-0.001,0-0.001,0-0.002-0.001c0,0-0.001,0-0.002-0.001
|
|
235
|
+
c-0.003-0.001-0.001-0.001-0.002-0.001c-0.003,0-0.001,0-0.002-0.001c0,0-0.001-0.001-0.002-0.001l-0.001-0.001h-0.001
|
|
236
|
+
c-0.059-0.021-0.122-0.034-0.188-0.037h-0.002c-0.001,0-0.001,0-0.001,0c-0.001,0-0.002,0-0.002,0s-0.001,0-0.001,0h-0.001h-0.001
|
|
237
|
+
l-0.001-0.001c-0.001,0-0.002,0-0.002,0c-0.001,0-0.002,0-0.002,0h-0.001c-0.001,0-0.001,0-0.001,0h-0.001
|
|
238
|
+
c-0.001,0-0.002,0-0.002,0s-0.001,0-0.002,0h-0.001c0,0-0.001,0-0.001,0h-0.001c-0.001,0-0.001,0-0.001,0h-0.001h-0.001h-0.001
|
|
239
|
+
h-0.001c-0.001,0-0.001,0-0.001,0c-1.655,0-3.01-1.348-3.02-3V81.829h2.579c0.009-0.001,0.016-0.001,0.026,0
|
|
240
|
+
c0.358,0,0.648-0.29,0.648-0.648c0-0.271-0.166-0.503-0.402-0.6l-12.38-8.544c-0.222-0.153-0.515-0.153-0.737,0L57.86,80.647
|
|
241
|
+
c-0.234,0.161-0.335,0.456-0.251,0.727c0.085,0.271,0.335,0.455,0.619,0.455h2.568l0.002,26.135
|
|
242
|
+
c0.011,2.329,1.884,4.23,4.264,4.289c0.026,0.003,0.052,0.004,0.078,0.004h18.481c0.004,0,0.007,0,0.011,0
|
|
243
|
+
c0.17-0.003,0.324-0.071,0.438-0.18c0,0,0,0,0.001-0.001c0.002-0.002,0.006-0.004,0.005-0.005c0.001-0.001,0.002-0.001,0.003-0.003
|
|
244
|
+
c0.001-0.001,0.001-0.001,0.001-0.001l0.001-0.001l0.001-0.001c0,0,0.001,0,0.001-0.001l0.001-0.001
|
|
245
|
+
c0.001,0,0.001-0.001,0.001-0.001c0.003-0.001,0.002-0.001,0.002-0.002c0,0,0,0,0.001-0.001c0,0,0,0,0.001-0.001
|
|
246
|
+
c0,0,0,0,0.001-0.001c0.112-0.116,0.182-0.273,0.183-0.447v-0.002v-0.001v-0.001v-0.001v-0.001v-0.001v-0.001v-0.002
|
|
247
|
+
C84.267,111.345,84.112,111.121,83.889,111.02z` }),
|
|
248
|
+
/* @__PURE__ */ jsx("path", { fill: "#F2D864", d: `M110.667,111.02l-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001
|
|
249
|
+
c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001c-0.001,0-0.001,0-0.001-0.001h-0.001l-0.001-0.001
|
|
250
|
+
c-0.001-0.001-0.001-0.001-0.001-0.001s-0.001,0-0.001-0.001h-0.001c0,0-0.001-0.001-0.001-0.001
|
|
251
|
+
c-0.001,0.001-0.001-0.001-0.002-0.001c0.001-0.001-0.001-0.001-0.002-0.001l-0.001-0.001c-0.001,0-0.001,0-0.001,0
|
|
252
|
+
c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001c-0.003-0.001-0.002-0.001-0.002-0.001c-0.001,0.001-0.001-0.001-0.003-0.001
|
|
253
|
+
l-0.001-0.001c0.001-0.001-0.001-0.001-0.002-0.001c0,0-0.001,0-0.001-0.001c-0.001-0.001-0.003-0.001-0.004-0.001
|
|
254
|
+
s-0.003-0.001-0.004-0.001l-0.002-0.001c0,0-0.001,0-0.002-0.001l-0.002-0.001c-0.003-0.001-0.003-0.001-0.002-0.001
|
|
255
|
+
c-0.003,0-0.003,0-0.002-0.001c-0.001,0-0.001-0.001-0.001-0.001c-0.001,0-0.002-0.001-0.002-0.001h-0.001
|
|
256
|
+
c-0.059-0.021-0.122-0.034-0.188-0.037h-0.001c-0.001,0-0.002,0-0.002,0c-0.001,0-0.002,0-0.003,0h-0.001h-0.001h-0.001
|
|
257
|
+
c-0.001-0.001-0.001-0.001-0.002-0.001c0,0-0.001,0-0.002,0c0,0-0.001,0-0.002,0h-0.001c0,0-0.001,0-0.001,0h-0.001
|
|
258
|
+
c-0.001,0-0.002,0-0.002,0h-0.002c0,0,0,0-0.001,0c0,0-0.001,0-0.001,0h-0.001c0,0-0.001,0-0.001,0h-0.001h-0.001h-0.001H110.4
|
|
259
|
+
c0,0-0.001,0-0.001,0c-1.655,0-3.01-1.348-3.02-3V89.365h2.573c0.004,0,0.009,0,0.013,0c0.365-0.009,0.661-0.285,0.661-0.648
|
|
260
|
+
c0-0.271-0.166-0.503-0.402-0.6l-12.38-8.544c-0.221-0.153-0.515-0.153-0.737,0l-12.476,8.61c-0.234,0.161-0.335,0.456-0.251,0.727
|
|
261
|
+
c0.085,0.271,0.335,0.455,0.619,0.455h2.573l0.002,18.599c0.013,2.329,1.885,4.231,4.264,4.289
|
|
262
|
+
c0.026,0.003,0.052,0.004,0.078,0.004h18.481c0.004,0,0.007,0,0.011,0c0.17-0.003,0.324-0.071,0.438-0.18l0.001-0.001
|
|
263
|
+
c0.002-0.002,0.005-0.004,0.005-0.005c0.001-0.001,0.002-0.001,0.003-0.003c0,0,0.001-0.001,0.001-0.001l0.001-0.001l0.001-0.001
|
|
264
|
+
l0.001-0.001l0.001-0.001l0.001-0.001c0.003-0.001,0.001-0.001,0.002-0.002c0,0,0,0,0.001-0.001l0.001-0.001c0,0,0,0,0.001-0.001
|
|
265
|
+
c0.112-0.116,0.182-0.273,0.183-0.447v-0.002v-0.001v-0.001v-0.001v-0.001v-0.001v-0.001v-0.002
|
|
266
|
+
C111.045,111.345,110.889,111.121,110.667,111.02z` })
|
|
267
|
+
] }) }), $[0] = t0) : t0 = $[0], t0;
|
|
268
|
+
}
|
|
269
|
+
function VideoPlayer(props) {
|
|
270
|
+
const $ = c(6), {
|
|
271
|
+
src
|
|
272
|
+
} = props;
|
|
273
|
+
let t0;
|
|
274
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
275
|
+
width: "100%",
|
|
276
|
+
height: "auto"
|
|
277
|
+
}, $[0] = t0) : t0 = $[0];
|
|
278
|
+
const style = t0;
|
|
279
|
+
let t1;
|
|
280
|
+
$[1] !== src ? (t1 = /* @__PURE__ */ jsx("source", { src, type: "video/mp4" }), $[1] = src, $[2] = t1) : t1 = $[2];
|
|
281
|
+
let t2;
|
|
282
|
+
$[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx("track", { kind: "captions" }), $[3] = t2) : t2 = $[3];
|
|
283
|
+
let t3;
|
|
284
|
+
return $[4] !== t1 ? (t3 = /* @__PURE__ */ jsxs("video", { controls: !0, "aria-label": "Cloudinary video preview", style, children: [
|
|
285
|
+
t1,
|
|
286
|
+
t2
|
|
287
|
+
] }), $[4] = t1, $[5] = t3) : t3 = $[5], t3;
|
|
288
|
+
}
|
|
289
|
+
const CloudinaryDiffPreview = (t0) => {
|
|
290
|
+
const $ = c(8), {
|
|
291
|
+
value
|
|
292
|
+
} = t0;
|
|
293
|
+
if (!value)
|
|
294
|
+
return null;
|
|
295
|
+
let t1;
|
|
296
|
+
$[0] !== value ? (t1 = assetUrl(value), $[0] = value, $[1] = t1) : t1 = $[1];
|
|
297
|
+
const url = t1;
|
|
298
|
+
if (value.resource_type === "video" && url) {
|
|
299
|
+
let t22;
|
|
300
|
+
$[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t22 = {
|
|
301
|
+
display: "flex",
|
|
302
|
+
flexWrap: "wrap",
|
|
303
|
+
justifyContent: "space-between"
|
|
304
|
+
}, $[2] = t22) : t22 = $[2];
|
|
305
|
+
let t32;
|
|
306
|
+
return $[3] !== url ? (t32 = /* @__PURE__ */ jsx("section", { style: t22, children: /* @__PURE__ */ jsx(VideoPlayer, { src: url, kind: "diff" }) }), $[3] = url, $[4] = t32) : t32 = $[4], t32;
|
|
307
|
+
}
|
|
308
|
+
let t2;
|
|
309
|
+
$[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
310
|
+
maxWidth: "100%",
|
|
311
|
+
height: "auto"
|
|
312
|
+
}, $[5] = t2) : t2 = $[5];
|
|
313
|
+
let t3;
|
|
314
|
+
return $[6] !== url ? (t3 = /* @__PURE__ */ jsx("img", { alt: "preview", src: url, style: t2 }), $[6] = url, $[7] = t3) : t3 = $[7], t3;
|
|
315
|
+
}, AssetDiff = (t0) => {
|
|
316
|
+
const $ = c(3), {
|
|
317
|
+
diff,
|
|
318
|
+
schemaType
|
|
319
|
+
} = t0;
|
|
320
|
+
let t1;
|
|
321
|
+
return $[0] !== diff || $[1] !== schemaType ? (t1 = /* @__PURE__ */ jsx(DiffFromTo, { diff, schemaType, previewComponent: CloudinaryDiffPreview }), $[0] = diff, $[1] = schemaType, $[2] = t1) : t1 = $[2], t1;
|
|
322
|
+
}, AssetPreview = (t0) => {
|
|
323
|
+
const $ = c(21), {
|
|
324
|
+
value,
|
|
325
|
+
layout
|
|
326
|
+
} = t0;
|
|
327
|
+
let t1;
|
|
328
|
+
$[0] !== value ? (t1 = value && assetUrl(value), $[0] = value, $[1] = t1) : t1 = $[1];
|
|
329
|
+
const url = t1;
|
|
330
|
+
if (!value || !url)
|
|
331
|
+
return null;
|
|
332
|
+
switch (value.resource_type) {
|
|
333
|
+
case "video": {
|
|
334
|
+
const t2 = layout === "default" ? "80px" : "100%";
|
|
335
|
+
let t3;
|
|
336
|
+
$[2] !== t2 ? (t3 = {
|
|
337
|
+
maxWidth: t2
|
|
338
|
+
}, $[2] = t2, $[3] = t3) : t3 = $[3];
|
|
339
|
+
let t4;
|
|
340
|
+
$[4] !== url ? (t4 = /* @__PURE__ */ jsx(VideoPlayer, { src: url, kind: "player" }), $[4] = url, $[5] = t4) : t4 = $[5];
|
|
341
|
+
let t5;
|
|
342
|
+
return $[6] !== t3 || $[7] !== t4 ? (t5 = /* @__PURE__ */ jsx(Flex, { align: "center", style: t3, children: t4 }), $[6] = t3, $[7] = t4, $[8] = t5) : t5 = $[8], t5;
|
|
343
|
+
}
|
|
344
|
+
case "raw": {
|
|
345
|
+
let t2;
|
|
346
|
+
$[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(DocumentIcon, {}), $[9] = t2) : t2 = $[9];
|
|
347
|
+
let t3;
|
|
348
|
+
$[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = {
|
|
349
|
+
marginLeft: "0.5em"
|
|
350
|
+
}, $[10] = t3) : t3 = $[10];
|
|
351
|
+
const t4 = value.display_name ?? "Raw file";
|
|
352
|
+
let t5;
|
|
353
|
+
return $[11] !== t4 ? (t5 = /* @__PURE__ */ jsxs(Flex, { align: "center", children: [
|
|
354
|
+
t2,
|
|
355
|
+
/* @__PURE__ */ jsx(Text, { size: 1, style: t3, children: t4 })
|
|
356
|
+
] }), $[11] = t4, $[12] = t5) : t5 = $[12], t5;
|
|
357
|
+
}
|
|
358
|
+
default: {
|
|
359
|
+
let t2;
|
|
360
|
+
$[13] !== url || $[14] !== value.format ? (t2 = value.format === "pdf" ? url?.replace("image/upload", "image/upload/f_jpg,pg_1,l_text:Verdana_75_letter_spacing_14:PDF") : url, $[13] = url, $[14] = value.format, $[15] = t2) : t2 = $[15];
|
|
361
|
+
const t3 = layout === "default" ? "80px" : "100%";
|
|
362
|
+
let t4;
|
|
363
|
+
$[16] !== t3 ? (t4 = {
|
|
364
|
+
maxWidth: t3,
|
|
365
|
+
height: "auto"
|
|
366
|
+
}, $[16] = t3, $[17] = t4) : t4 = $[17];
|
|
367
|
+
let t5;
|
|
368
|
+
return $[18] !== t2 || $[19] !== t4 ? (t5 = /* @__PURE__ */ jsx(Flex, { align: "center", children: /* @__PURE__ */ jsx("img", { alt: "preview", src: t2, style: t4 }) }), $[18] = t2, $[19] = t4, $[20] = t5) : t5 = $[20], t5;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}, SetupButtonContainer = styled.div.withConfig({
|
|
372
|
+
displayName: "SetupButtonContainer",
|
|
373
|
+
componentId: "sc-10badjx-0"
|
|
374
|
+
})`position:relative;display:block;font-size:0.8em;transform:translate(0%,-10%);`, WidgetInput = (props) => {
|
|
375
|
+
const $ = c(21), {
|
|
376
|
+
onChange,
|
|
377
|
+
readOnly,
|
|
378
|
+
value,
|
|
379
|
+
openMediaSelector: openMediaSelector2
|
|
380
|
+
} = props;
|
|
381
|
+
let t0;
|
|
382
|
+
$[0] !== onChange ? (t0 = () => {
|
|
383
|
+
onChange(PatchEvent.from([unset()]));
|
|
384
|
+
}, $[0] = onChange, $[1] = t0) : t0 = $[1];
|
|
385
|
+
const removeValue = t0;
|
|
386
|
+
let t1;
|
|
387
|
+
$[2] !== props.onSetup ? (t1 = /* @__PURE__ */ jsx(SetupButtonContainer, { children: /* @__PURE__ */ jsx(Flex, { flex: 1, justify: "flex-end", children: /* @__PURE__ */ jsx(Button, { color: "primary", icon: PlugIcon, mode: "bleed", title: "Configure", onClick: props.onSetup, tabIndex: 0 }) }) }), $[2] = props.onSetup, $[3] = t1) : t1 = $[3];
|
|
388
|
+
let t2;
|
|
389
|
+
$[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
390
|
+
textAlign: "center",
|
|
391
|
+
width: "100%"
|
|
392
|
+
}, $[4] = t2) : t2 = $[4];
|
|
393
|
+
const t3 = value;
|
|
394
|
+
let t4;
|
|
395
|
+
$[5] !== t3 ? (t4 = /* @__PURE__ */ jsx(Flex, { style: t2, marginBottom: 2, children: /* @__PURE__ */ jsx(AssetPreview, { value: t3 }) }), $[5] = t3, $[6] = t4) : t4 = $[6];
|
|
396
|
+
let t5;
|
|
397
|
+
$[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = {
|
|
398
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(100px, 1fr))"
|
|
399
|
+
}, $[7] = t5) : t5 = $[7];
|
|
400
|
+
let t6;
|
|
401
|
+
$[8] !== openMediaSelector2 || $[9] !== readOnly ? (t6 = /* @__PURE__ */ jsx(Button, { disabled: readOnly, mode: "ghost", title: "Select an asset", tone: "default", onClick: openMediaSelector2, text: "Select\u2026" }), $[8] = openMediaSelector2, $[9] = readOnly, $[10] = t6) : t6 = $[10];
|
|
402
|
+
const t7 = readOnly || !value;
|
|
403
|
+
let t8;
|
|
404
|
+
$[11] !== removeValue || $[12] !== t7 ? (t8 = /* @__PURE__ */ jsx(Button, { disabled: t7, tone: "critical", mode: "ghost", title: "Remove asset", text: "Remove", onClick: removeValue }), $[11] = removeValue, $[12] = t7, $[13] = t8) : t8 = $[13];
|
|
405
|
+
let t9;
|
|
406
|
+
$[14] !== t6 || $[15] !== t8 ? (t9 = /* @__PURE__ */ jsxs(Grid, { gap: 1, style: t5, children: [
|
|
407
|
+
t6,
|
|
408
|
+
t8
|
|
409
|
+
] }), $[14] = t6, $[15] = t8, $[16] = t9) : t9 = $[16];
|
|
410
|
+
let t10;
|
|
411
|
+
return $[17] !== t1 || $[18] !== t4 || $[19] !== t9 ? (t10 = /* @__PURE__ */ jsxs(Stack, { children: [
|
|
412
|
+
t1,
|
|
413
|
+
t4,
|
|
414
|
+
t9
|
|
415
|
+
] }), $[17] = t1, $[18] = t4, $[19] = t9, $[20] = t10) : t10 = $[20], t10;
|
|
416
|
+
}, CloudinaryInput = (props) => {
|
|
417
|
+
const $ = c(17), [showSettings, setShowSettings] = useState(!1), {
|
|
418
|
+
secrets
|
|
419
|
+
} = useSecrets(namespace), {
|
|
420
|
+
onChange,
|
|
421
|
+
schemaType: type
|
|
422
|
+
} = props, value = props.value || void 0, valueKey = value?._key;
|
|
423
|
+
let t0;
|
|
424
|
+
$[0] !== onChange || $[1] !== type || $[2] !== valueKey ? (t0 = (payload) => {
|
|
425
|
+
const [asset] = payload.assets;
|
|
426
|
+
if (!asset)
|
|
427
|
+
return;
|
|
428
|
+
let updatedAsset;
|
|
429
|
+
const assetWithoutNulls = Object.fromEntries(Object.entries(asset).filter(_temp$1)), requiredFields = {
|
|
430
|
+
public_id: asset.public_id,
|
|
431
|
+
resource_type: asset.resource_type,
|
|
432
|
+
type: asset.type,
|
|
433
|
+
url: asset.url,
|
|
434
|
+
secure_url: asset.secure_url,
|
|
435
|
+
format: asset.format,
|
|
436
|
+
width: asset.width,
|
|
437
|
+
height: asset.height,
|
|
438
|
+
bytes: asset.bytes,
|
|
439
|
+
tags: asset.tags
|
|
440
|
+
};
|
|
441
|
+
if (updatedAsset = {
|
|
442
|
+
...assetWithoutNulls,
|
|
443
|
+
...requiredFields
|
|
444
|
+
}, asset.context) {
|
|
445
|
+
const objectWithRenamedKeys = Object.fromEntries(Object.entries(asset.context.custom).map(_temp2$1));
|
|
446
|
+
updatedAsset = {
|
|
447
|
+
...updatedAsset,
|
|
448
|
+
context: {
|
|
449
|
+
...asset.context,
|
|
450
|
+
custom: objectWithRenamedKeys
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
if (asset.derived) {
|
|
455
|
+
const derivedWithType = asset.derived.map(_temp3);
|
|
456
|
+
updatedAsset = {
|
|
457
|
+
...updatedAsset,
|
|
458
|
+
derived: derivedWithType
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
onChange(PatchEvent.from([set(Object.assign({
|
|
462
|
+
_type: type.name,
|
|
463
|
+
_version: 1,
|
|
464
|
+
_key: valueKey || nanoid()
|
|
465
|
+
}, updatedAsset))]));
|
|
466
|
+
}, $[0] = onChange, $[1] = type, $[2] = valueKey, $[3] = t0) : t0 = $[3];
|
|
467
|
+
const handleSelect = t0;
|
|
468
|
+
let t1;
|
|
469
|
+
$[4] !== handleSelect || $[5] !== secrets || $[6] !== value ? (t1 = secrets ? () => openMediaSelector(secrets.cloudName, secrets.apiKey, !1, handleSelect, value) : () => setShowSettings(!0), $[4] = handleSelect, $[5] = secrets, $[6] = value, $[7] = t1) : t1 = $[7];
|
|
470
|
+
const action = t1;
|
|
471
|
+
let t2;
|
|
472
|
+
$[8] !== showSettings ? (t2 = showSettings && /* @__PURE__ */ jsx(SecretsConfigView, { onClose: () => setShowSettings(!1) }), $[8] = showSettings, $[9] = t2) : t2 = $[9];
|
|
473
|
+
let t3;
|
|
474
|
+
$[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = () => setShowSettings(!0), $[10] = t3) : t3 = $[10];
|
|
475
|
+
let t4;
|
|
476
|
+
$[11] !== action || $[12] !== props ? (t4 = /* @__PURE__ */ jsx(WidgetInput, { onSetup: t3, openMediaSelector: action, ...props }), $[11] = action, $[12] = props, $[13] = t4) : t4 = $[13];
|
|
477
|
+
let t5;
|
|
478
|
+
return $[14] !== t2 || $[15] !== t4 ? (t5 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
479
|
+
t2,
|
|
480
|
+
t4
|
|
481
|
+
] }), $[14] = t2, $[15] = t4, $[16] = t5) : t5 = $[16], t5;
|
|
482
|
+
};
|
|
483
|
+
function _temp$1(t0) {
|
|
484
|
+
const [, assetValue] = t0;
|
|
485
|
+
return assetValue !== null;
|
|
486
|
+
}
|
|
487
|
+
function _temp2$1(t0) {
|
|
488
|
+
const [contextKey, contextValue] = t0;
|
|
489
|
+
return [contextKey.replace(/[^a-zA-Z0-9_]|-/g, "_"), contextValue];
|
|
490
|
+
}
|
|
491
|
+
function _temp3(derivedItem) {
|
|
492
|
+
return {
|
|
493
|
+
_type: "derived",
|
|
494
|
+
url: derivedItem.url,
|
|
495
|
+
secure_url: derivedItem.secure_url,
|
|
496
|
+
raw_transformation: derivedItem.raw_transformation
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
const cloudinaryAssetSchema = defineType({
|
|
500
|
+
type: "object",
|
|
501
|
+
name: "cloudinary.asset",
|
|
502
|
+
fields: [
|
|
503
|
+
{
|
|
504
|
+
type: "string",
|
|
505
|
+
name: "public_id"
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
type: "string",
|
|
509
|
+
name: "resource_type"
|
|
510
|
+
// "image", "?"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
type: "string",
|
|
514
|
+
name: "type"
|
|
515
|
+
// "upload", "?"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
type: "string",
|
|
519
|
+
name: "format"
|
|
520
|
+
// "jpg"
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
type: "number",
|
|
524
|
+
name: "version"
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
type: "url",
|
|
528
|
+
name: "url"
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
type: "url",
|
|
532
|
+
name: "secure_url"
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
type: "number",
|
|
536
|
+
name: "width"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
type: "number",
|
|
540
|
+
name: "height"
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
type: "number",
|
|
544
|
+
name: "bytes"
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
type: "number",
|
|
548
|
+
name: "duration"
|
|
549
|
+
// can be null
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
type: "array",
|
|
553
|
+
name: "tags",
|
|
554
|
+
of: [{
|
|
555
|
+
type: "string"
|
|
556
|
+
}]
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
type: "datetime",
|
|
560
|
+
name: "created_at"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
type: "array",
|
|
564
|
+
name: "derived",
|
|
565
|
+
of: [{
|
|
566
|
+
type: "cloudinary.assetDerived",
|
|
567
|
+
name: "derived"
|
|
568
|
+
}]
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
type: "string",
|
|
572
|
+
name: "access_mode"
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
type: "cloudinary.assetContext",
|
|
576
|
+
name: "context"
|
|
577
|
+
}
|
|
578
|
+
// metadata array of unknown content
|
|
579
|
+
],
|
|
580
|
+
components: {
|
|
581
|
+
input: CloudinaryInput,
|
|
582
|
+
diff: AssetDiff,
|
|
583
|
+
preview: AssetPreview
|
|
584
|
+
},
|
|
585
|
+
preview: {
|
|
586
|
+
select: {
|
|
587
|
+
url: "url",
|
|
588
|
+
resource_type: "resource_type",
|
|
589
|
+
derived: "derived.0.url"
|
|
590
|
+
},
|
|
591
|
+
prepare({
|
|
592
|
+
url,
|
|
593
|
+
derived,
|
|
594
|
+
resource_type
|
|
595
|
+
}) {
|
|
596
|
+
return {
|
|
597
|
+
title: url,
|
|
598
|
+
value: {
|
|
599
|
+
title: url,
|
|
600
|
+
resource_type,
|
|
601
|
+
url: derived || url
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}), AssetListFunctions = (props) => {
|
|
607
|
+
const $ = c(24), {
|
|
608
|
+
onValueCreate,
|
|
609
|
+
onChange
|
|
610
|
+
} = props, {
|
|
611
|
+
secrets,
|
|
612
|
+
loading
|
|
613
|
+
} = useSecrets(namespace), [showSettings, setShowSettings] = useState(!1);
|
|
614
|
+
let t0;
|
|
615
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setShowSettings(!0), $[0] = t0) : t0 = $[0];
|
|
616
|
+
const show = t0;
|
|
617
|
+
let t1;
|
|
618
|
+
$[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = () => setShowSettings(!1), $[1] = t1) : t1 = $[1];
|
|
619
|
+
const hide = t1;
|
|
620
|
+
let t2;
|
|
621
|
+
$[2] !== props.schemaType.of ? (t2 = props.schemaType.of.find(_temp), $[2] = props.schemaType.of, $[3] = t2) : t2 = $[3];
|
|
622
|
+
const cloudinaryType = t2;
|
|
623
|
+
if (!cloudinaryType)
|
|
624
|
+
throw new Error(`AssetListFunctions can only be used in array.of ${cloudinaryAssetSchema.name}, but it was array.of
|
|
625
|
+
${props.schemaType.of.map(_temp2).join(", ")}`);
|
|
626
|
+
let t3;
|
|
627
|
+
$[4] !== cloudinaryType || $[5] !== onChange || $[6] !== onValueCreate ? (t3 = (selected) => {
|
|
628
|
+
const items = selected.assets.map((asset) => Object.assign({}, asset, {
|
|
629
|
+
_version: 1
|
|
630
|
+
}, onValueCreate(cloudinaryType)));
|
|
631
|
+
onChange(PatchEvent.from([setIfMissing([]), insert(items, "after", [-1])]));
|
|
632
|
+
}, $[4] = cloudinaryType, $[5] = onChange, $[6] = onValueCreate, $[7] = t3) : t3 = $[7];
|
|
633
|
+
const handleSelect = t3;
|
|
634
|
+
let t4;
|
|
635
|
+
$[8] !== handleSelect || $[9] !== secrets ? (t4 = () => secrets && openMediaSelector(secrets.cloudName, secrets.apiKey, !0, handleSelect), $[8] = handleSelect, $[9] = secrets, $[10] = t4) : t4 = $[10];
|
|
636
|
+
const handleOpenSelector = t4;
|
|
637
|
+
let t5;
|
|
638
|
+
$[11] !== showSettings ? (t5 = showSettings && /* @__PURE__ */ jsx(SecretsConfigView, { onClose: hide }), $[11] = showSettings, $[12] = t5) : t5 = $[12];
|
|
639
|
+
let t6;
|
|
640
|
+
$[13] !== props ? (t6 = /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(ArrayOfObjectsFunctions, { ...props }) }), $[13] = props, $[14] = t6) : t6 = $[14];
|
|
641
|
+
let t7;
|
|
642
|
+
$[15] !== cloudinaryType || $[16] !== handleOpenSelector || $[17] !== loading || $[18] !== props.readOnly ? (t7 = cloudinaryType && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
643
|
+
/* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Button, { style: {
|
|
644
|
+
width: "100%"
|
|
645
|
+
}, disabled: props.readOnly || loading, mode: "bleed", text: "Add multiple", onClick: handleOpenSelector }) }),
|
|
646
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Button, { onClick: show, icon: PlugIcon, mode: "bleed", title: "Configure" }) })
|
|
647
|
+
] }), $[15] = cloudinaryType, $[16] = handleOpenSelector, $[17] = loading, $[18] = props.readOnly, $[19] = t7) : t7 = $[19];
|
|
648
|
+
let t8;
|
|
649
|
+
return $[20] !== t5 || $[21] !== t6 || $[22] !== t7 ? (t8 = /* @__PURE__ */ jsxs(Flex, { gap: 2, flex: 1, children: [
|
|
650
|
+
t5,
|
|
651
|
+
t6,
|
|
652
|
+
t7
|
|
653
|
+
] }), $[20] = t5, $[21] = t6, $[22] = t7, $[23] = t8) : t8 = $[23], t8;
|
|
654
|
+
};
|
|
655
|
+
function _temp(t) {
|
|
656
|
+
return t.name === cloudinaryAssetSchema.name;
|
|
657
|
+
}
|
|
658
|
+
function _temp2(t_0) {
|
|
659
|
+
return t_0.name;
|
|
660
|
+
}
|
|
661
|
+
const cloudinaryAssetContext = defineType({
|
|
662
|
+
type: "object",
|
|
663
|
+
name: "cloudinary.assetContext",
|
|
664
|
+
fields: [{
|
|
665
|
+
type: "cloudinary.assetContextCustom",
|
|
666
|
+
name: "custom"
|
|
667
|
+
}]
|
|
668
|
+
}), cloudinaryAssetContextCustom = defineType({
|
|
669
|
+
type: "object",
|
|
670
|
+
name: "cloudinary.assetContextCustom",
|
|
671
|
+
fields: [{
|
|
672
|
+
type: "string",
|
|
673
|
+
name: "alt"
|
|
674
|
+
}, {
|
|
675
|
+
type: "string",
|
|
676
|
+
name: "caption"
|
|
677
|
+
}]
|
|
678
|
+
}), cloudinaryAssetDerivedSchema = defineType({
|
|
679
|
+
type: "object",
|
|
680
|
+
name: "cloudinary.assetDerived",
|
|
681
|
+
fields: [{
|
|
682
|
+
type: "string",
|
|
683
|
+
name: "raw_transformation"
|
|
684
|
+
}, {
|
|
685
|
+
type: "url",
|
|
686
|
+
name: "url"
|
|
687
|
+
}, {
|
|
688
|
+
type: "url",
|
|
689
|
+
name: "secure_url"
|
|
690
|
+
}]
|
|
691
|
+
}), cloudinarySchemaPlugin = definePlugin({
|
|
692
|
+
name: "cloudinary-schema",
|
|
693
|
+
form: {
|
|
694
|
+
components: {
|
|
695
|
+
input: (props) => isArrayOfObjectsInputProps(props) && props.schemaType.of.find((t) => t.name === cloudinaryAssetSchema.name) ? props.renderDefault({
|
|
696
|
+
...props,
|
|
697
|
+
arrayFunctions: AssetListFunctions
|
|
698
|
+
}) : props.renderDefault(props)
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
schema: {
|
|
702
|
+
types: [cloudinaryAssetSchema, cloudinaryAssetDerivedSchema, cloudinaryAssetContext, cloudinaryAssetContextCustom]
|
|
703
|
+
}
|
|
704
|
+
}), cloudinaryImageSource = {
|
|
705
|
+
name: "cloudinary-image",
|
|
706
|
+
title: "Cloudinary",
|
|
707
|
+
icon: CloudinaryIcon,
|
|
708
|
+
component: CloudinaryAssetSource
|
|
709
|
+
}, cloudinaryAssetSourcePlugin = definePlugin({
|
|
710
|
+
name: "cloudinart-asset-source",
|
|
711
|
+
form: {
|
|
712
|
+
image: {
|
|
713
|
+
assetSources: [cloudinaryImageSource]
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
export {
|
|
718
|
+
cloudinaryAssetContext,
|
|
719
|
+
cloudinaryAssetContextCustom,
|
|
720
|
+
cloudinaryAssetDerivedSchema,
|
|
721
|
+
cloudinaryAssetSchema,
|
|
722
|
+
cloudinaryAssetSourcePlugin,
|
|
723
|
+
cloudinaryImageSource,
|
|
724
|
+
cloudinarySchemaPlugin
|
|
725
|
+
};
|
|
726
|
+
//# sourceMappingURL=index.js.map
|