sanity-plugin-mux-input 2.3.3 → 2.3.4
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.cjs +58 -18
- package/lib/index.cjs.map +1 -1
- package/lib/index.esm.js +58 -19
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +58 -19
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { useClient as useClient$1, createHookFromObservableFactory, useDocumentS
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { ErrorOutlineIcon, RetrieveIcon, RetryIcon, CheckmarkCircleIcon, SortIcon, WarningOutlineIcon, EditIcon, PublishIcon, DocumentIcon, TrashIcon, CheckmarkIcon, RevertIcon, SearchIcon, ClockIcon, CropIcon, CalendarIcon, TagIcon, LockIcon, PlayIcon, PlugIcon, UploadIcon, ResetIcon, EllipsisHorizontalIcon, AddIcon, TranslateIcon, DocumentVideoIcon } from "@sanity/icons";
|
|
4
4
|
import { Card, Box, Spinner, Stack, Text, Checkbox, Button, Dialog, Flex, Heading, Code, MenuButton, Menu, MenuItem, Tooltip, Inline, useToast, TabList, Tab, TabPanel, TextInput, Label as Label$1, Grid, useClickOutside, Popover, MenuDivider, Radio, Autocomplete, rem } from "@sanity/ui";
|
|
5
|
-
import React, { useState, useMemo, useEffect, useRef, useId, memo, isValidElement, useCallback, useReducer, createElement, forwardRef, Suspense } from "react";
|
|
5
|
+
import React, { useState, useMemo, useEffect, useRef, useId, memo, isValidElement, useCallback, useReducer, PureComponent, createElement, forwardRef, Suspense } from "react";
|
|
6
6
|
import compact from "lodash/compact.js";
|
|
7
7
|
import toLower from "lodash/toLower.js";
|
|
8
8
|
import trim from "lodash/trim.js";
|
|
@@ -21,7 +21,6 @@ import isString from "lodash/isString.js";
|
|
|
21
21
|
import { useMemoObservable } from "react-rx";
|
|
22
22
|
import useSWR from "swr";
|
|
23
23
|
import scrollIntoView from "scroll-into-view-if-needed";
|
|
24
|
-
import { useErrorBoundary } from "use-error-boundary";
|
|
25
24
|
import { UpChunk } from "@mux/upchunk";
|
|
26
25
|
import { isValidElementType } from "react-is";
|
|
27
26
|
import LanguagesList from "iso-639-1";
|
|
@@ -144,7 +143,7 @@ function accumulateIntermediateState(currentState, pageResult) {
|
|
|
144
143
|
...currentData,
|
|
145
144
|
...("data" in pageResult && pageResult.data || []).filter(
|
|
146
145
|
// De-duplicate assets for safety
|
|
147
|
-
(asset) => !currentData.some((
|
|
146
|
+
(asset) => !currentData.some((a2) => a2.id === asset.id)
|
|
148
147
|
)
|
|
149
148
|
],
|
|
150
149
|
error: "error" in pageResult ? pageResult.error : (
|
|
@@ -218,7 +217,7 @@ function useImportMuxAssets() {
|
|
|
218
217
|
}), [assetsInSanity, assetsInSanityLoading] = useAssetsInSanity(documentStore), secretDocumentValues = useSecretsDocumentValues(), hasSecrets = !!((_a = secretDocumentValues.value.secrets) != null && _a.secretKey), [importError, setImportError] = useState(), [importState, setImportState] = useState("closed"), dialogOpen = importState !== "closed", muxAssets = useMuxAssets({
|
|
219
218
|
secrets: secretDocumentValues.value.secrets,
|
|
220
219
|
enabled: hasSecrets && dialogOpen
|
|
221
|
-
}), missingAssets = useMemo(() => assetsInSanity && muxAssets.data ? muxAssets.data.filter((
|
|
220
|
+
}), missingAssets = useMemo(() => assetsInSanity && muxAssets.data ? muxAssets.data.filter((a2) => !assetExistsInSanity(a2, assetsInSanity)) : void 0, [assetsInSanity, muxAssets.data]), [selectedAssets, setSelectedAssets] = useState([]), closeDialog = () => {
|
|
222
221
|
importState !== "importing" && setImportState("closed");
|
|
223
222
|
}, openDialog = () => {
|
|
224
223
|
importState === "closed" && setImportState("idle");
|
|
@@ -654,9 +653,9 @@ function ImportVideosDialog(props) {
|
|
|
654
653
|
{
|
|
655
654
|
asset,
|
|
656
655
|
selectAsset: (selected) => {
|
|
657
|
-
selected ? props.setSelectedAssets([...props.selectedAssets, asset]) : props.setSelectedAssets(props.selectedAssets.filter((
|
|
656
|
+
selected ? props.setSelectedAssets([...props.selectedAssets, asset]) : props.setSelectedAssets(props.selectedAssets.filter((a2) => a2.id !== asset.id));
|
|
658
657
|
},
|
|
659
|
-
selected: props.selectedAssets.some((
|
|
658
|
+
selected: props.selectedAssets.some((a2) => a2.id === asset.id)
|
|
660
659
|
},
|
|
661
660
|
asset.id
|
|
662
661
|
))
|
|
@@ -802,7 +801,7 @@ function VideoPlayer({
|
|
|
802
801
|
crossOrigin: "anonymous",
|
|
803
802
|
metadata: {
|
|
804
803
|
player_name: "Sanity Admin Dashboard",
|
|
805
|
-
player_version: "2.3.
|
|
804
|
+
player_version: "2.3.4",
|
|
806
805
|
page_type: "Preview Player"
|
|
807
806
|
},
|
|
808
807
|
style: {
|
|
@@ -1679,7 +1678,7 @@ function VideoInBrowser({
|
|
|
1679
1678
|
}
|
|
1680
1679
|
function VideosBrowser({ onSelect }) {
|
|
1681
1680
|
const { assets, isLoading, searchQuery, setSearchQuery, setSort, sort } = useAssets(), [editedAsset, setEditedAsset] = useState(null), freshEditedAsset = useMemo(
|
|
1682
|
-
() => assets.find((
|
|
1681
|
+
() => assets.find((a2) => a2._id === (editedAsset == null ? void 0 : editedAsset._id)) || editedAsset,
|
|
1683
1682
|
[editedAsset, assets]
|
|
1684
1683
|
), placement = onSelect ? "input" : "tool";
|
|
1685
1684
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1931,7 +1930,7 @@ const useSecretsFormState = (secrets) => useReducer(reducer, secrets, init), ids
|
|
|
1931
1930
|
"r"
|
|
1932
1931
|
];
|
|
1933
1932
|
function MuxLogo({ height = 26 }) {
|
|
1934
|
-
const id = useId(), [titleId,
|
|
1933
|
+
const id = useId(), [titleId, a2, b, c2, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = useMemo(
|
|
1935
1934
|
() => ids.map((field) => `${id}-${field}`),
|
|
1936
1935
|
[id]
|
|
1937
1936
|
);
|
|
@@ -1950,7 +1949,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
1950
1949
|
/* @__PURE__ */ jsxs(
|
|
1951
1950
|
"linearGradient",
|
|
1952
1951
|
{
|
|
1953
|
-
id:
|
|
1952
|
+
id: c2,
|
|
1954
1953
|
spreadMethod: "pad",
|
|
1955
1954
|
gradientTransform: "matrix(528.38055 0 0 -528.38055 63.801 159.5)",
|
|
1956
1955
|
gradientUnits: "userSpaceOnUse",
|
|
@@ -2332,7 +2331,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2332
2331
|
]
|
|
2333
2332
|
}
|
|
2334
2333
|
),
|
|
2335
|
-
/* @__PURE__ */ jsx("clipPath", { id:
|
|
2334
|
+
/* @__PURE__ */ jsx("clipPath", { id: a2, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2336
2335
|
/* @__PURE__ */ jsx("clipPath", { id: b, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M423.64 242h164.999V77H423.64Z" }) }),
|
|
2337
2336
|
/* @__PURE__ */ jsx("clipPath", { id: e, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2338
2337
|
/* @__PURE__ */ jsx("clipPath", { id: f, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M311.3 242h93.031V77H311.3Z" }) }),
|
|
@@ -2340,7 +2339,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2340
2339
|
/* @__PURE__ */ jsx("clipPath", { id: n, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M0 319h657.706V0H0Z" }) }),
|
|
2341
2340
|
/* @__PURE__ */ jsx("clipPath", { id: o, clipPathUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("path", { d: "M69.067 242H169.12V141.947H69.067Z" }) })
|
|
2342
2341
|
] }),
|
|
2343
|
-
/* @__PURE__ */ jsx("g", { clipPath: `url(#${
|
|
2342
|
+
/* @__PURE__ */ jsx("g", { clipPath: `url(#${a2})`, transform: "matrix(1.33333 0 0 -1.33333 0 425.333)", children: /* @__PURE__ */ jsx(
|
|
2344
2343
|
"g",
|
|
2345
2344
|
{
|
|
2346
2345
|
style: {
|
|
@@ -2351,7 +2350,7 @@ function MuxLogo({ height = 26 }) {
|
|
|
2351
2350
|
"path",
|
|
2352
2351
|
{
|
|
2353
2352
|
style: {
|
|
2354
|
-
fill: `url(#${
|
|
2353
|
+
fill: `url(#${c2})`,
|
|
2355
2354
|
stroke: "none"
|
|
2356
2355
|
},
|
|
2357
2356
|
d: "M558.674 82.142c6.855-6.855 17.969-6.855 24.824 0 6.854 6.855 6.854 17.969 0 24.823L453.605 236.858c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"
|
|
@@ -2665,9 +2664,49 @@ function ConfigureApi({ secrets, setDialogState }) {
|
|
|
2665
2664
|
}
|
|
2666
2665
|
);
|
|
2667
2666
|
}
|
|
2668
|
-
var ConfigureApi$1 = memo(ConfigureApi)
|
|
2667
|
+
var ConfigureApi$1 = memo(ConfigureApi), c = function(r) {
|
|
2668
|
+
var t, e;
|
|
2669
|
+
function n(t2) {
|
|
2670
|
+
var e2;
|
|
2671
|
+
return (e2 = r.call(this, t2) || this).state = { hasError: !1, error: null }, e2;
|
|
2672
|
+
}
|
|
2673
|
+
e = r, (t = n).prototype = Object.create(e.prototype), t.prototype.constructor = t, t.__proto__ = e, n.getDerivedStateFromError = function(r2) {
|
|
2674
|
+
return { hasError: !0, error: r2 };
|
|
2675
|
+
};
|
|
2676
|
+
var o = n.prototype;
|
|
2677
|
+
return o.componentDidCatch = function(r2, t2) {
|
|
2678
|
+
return this.props.onDidCatch(r2, t2);
|
|
2679
|
+
}, o.render = function() {
|
|
2680
|
+
var r2 = this.state, t2 = this.props, e2 = t2.render, n2 = t2.children, o2 = t2.renderError;
|
|
2681
|
+
return r2.hasError ? o2 ? o2({ error: r2.error }) : null : e2 ? e2() : n2 || null;
|
|
2682
|
+
}, n;
|
|
2683
|
+
}(PureComponent), u = function(r, t) {
|
|
2684
|
+
switch (t.type) {
|
|
2685
|
+
case "catch":
|
|
2686
|
+
return { didCatch: !0, error: t.error };
|
|
2687
|
+
case "reset":
|
|
2688
|
+
return { didCatch: !1, error: null };
|
|
2689
|
+
default:
|
|
2690
|
+
return r;
|
|
2691
|
+
}
|
|
2692
|
+
};
|
|
2693
|
+
function a(t) {
|
|
2694
|
+
var a2 = useReducer(u, { didCatch: !1, error: null }), i = a2[0], d = a2[1], h = useRef(null);
|
|
2695
|
+
function l() {
|
|
2696
|
+
return e = function(r, e2) {
|
|
2697
|
+
d({ type: "catch", error: r }), t && t.onDidCatch && t.onDidCatch(r, e2);
|
|
2698
|
+
}, function(t2) {
|
|
2699
|
+
return React.createElement(c, { onDidCatch: e, children: t2.children, render: t2.render, renderError: t2.renderError });
|
|
2700
|
+
};
|
|
2701
|
+
var e;
|
|
2702
|
+
}
|
|
2703
|
+
var p, s = useCallback(function() {
|
|
2704
|
+
h.current = l(), d({ type: "reset" });
|
|
2705
|
+
}, []);
|
|
2706
|
+
return { ErrorBoundary: (p = h.current, p !== null ? p : (h.current = l(), h.current)), didCatch: i.didCatch, error: i.error, reset: s };
|
|
2707
|
+
}
|
|
2669
2708
|
function ErrorBoundaryCard(props) {
|
|
2670
|
-
const { children, schemaType } = props, { push: pushToast } = useToast(), errorRef = useRef(null), { ErrorBoundary, didCatch, error, reset } =
|
|
2709
|
+
const { children, schemaType } = props, { push: pushToast } = useToast(), errorRef = useRef(null), { ErrorBoundary, didCatch, error, reset } = a({
|
|
2671
2710
|
onDidCatch: (err, errorInfo) => {
|
|
2672
2711
|
console.group(err.toString()), console.groupCollapsed("console.error"), console.error(err), console.groupEnd(), err.stack && (console.groupCollapsed("error.stack"), console.log(err.stack), console.groupEnd()), errorInfo != null && errorInfo.componentStack && (console.groupCollapsed("errorInfo.componentStack"), console.log(errorInfo.componentStack), console.groupEnd()), console.groupEnd(), pushToast({
|
|
2673
2712
|
status: "error",
|
|
@@ -3313,12 +3352,12 @@ function formatBytes(bytes, si = !1, dp = 1) {
|
|
|
3313
3352
|
if (Math.abs(bytes) < thresh)
|
|
3314
3353
|
return bytes + " B";
|
|
3315
3354
|
const units = si ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
|
3316
|
-
let
|
|
3355
|
+
let u2 = -1;
|
|
3317
3356
|
const r = 10 ** dp;
|
|
3318
3357
|
do
|
|
3319
|
-
bytes /= thresh, ++
|
|
3320
|
-
while (Math.round(Math.abs(bytes) * r) / r >= thresh &&
|
|
3321
|
-
return bytes.toFixed(dp) + " " + units[
|
|
3358
|
+
bytes /= thresh, ++u2;
|
|
3359
|
+
while (Math.round(Math.abs(bytes) * r) / r >= thresh && u2 < units.length - 1);
|
|
3360
|
+
return bytes.toFixed(dp) + " " + units[u2];
|
|
3322
3361
|
}
|
|
3323
3362
|
const SUPPORTED_MUX_LANGUAGES = [
|
|
3324
3363
|
{ label: "English", code: "en", state: "Stable" },
|