sanity-plugin-mux-input 2.2.1 → 2.2.2

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 CHANGED
@@ -59,7 +59,7 @@ function tokenize(string) {
59
59
  function toGroqParams(terms) {
60
60
  const params = {};
61
61
  return terms.reduce((acc, term, i) => {
62
- acc["t".concat(i)] = "*".concat(term, "*");
62
+ acc["t".concat(i)] = "".concat(term, "*");
63
63
  return acc;
64
64
  }, params);
65
65
  }
@@ -76,7 +76,7 @@ function extractTermsFromQuery(query) {
76
76
  const remainingTerms = lodash.uniq(lodash.compact(tokenize(lodash.toLower(unquotedQuery))));
77
77
  return [...quotedTerms, ...remainingTerms];
78
78
  }
79
- const SEARCH_PATHS = ["filename", "assetId", "_id"];
79
+ const SEARCH_PATHS = ["filename"];
80
80
  function createConstraints(terms) {
81
81
  const constraints = terms.map((_term, i) => SEARCH_PATHS.map(joinedPath => "".concat(joinedPath, " match $t").concat(i))).filter(constraint => constraint.length > 0);
82
82
  return constraints.map(constraint => "(".concat(constraint.join(" || "), ")"));
@@ -116,9 +116,9 @@ const useAssetDocuments = sanity.createHookFromObservableFactory(_ref => {
116
116
  } = _ref;
117
117
  const search = createSearchFilter(searchQuery);
118
118
  const filter = ['_type == "mux.videoAsset"', ...search.filter].filter(Boolean).join(" && ");
119
- const query = ASSET_SORT_OPTIONS[sort].groq;
119
+ const sortFragment = ASSET_SORT_OPTIONS[sort].groq;
120
120
  return documentStore.listenQuery( /* groq */
121
- "*[".concat(filter, "] | order(").concat(query, ")"), search.params, {
121
+ "*[".concat(filter, "] | order(").concat(sortFragment, ")"), search.params, {
122
122
  apiVersion: SANITY_API_VERSION
123
123
  });
124
124
  });
@@ -197,7 +197,7 @@ const cacheNs = "sanity-plugin-mux-input";
197
197
  const muxSecretsDocumentId = "secrets.mux";
198
198
  const DIALOGS_Z_INDEX = 6e4;
199
199
  const THUMBNAIL_ASPECT_RATIO = 16 / 9;
200
- const MIN_ASPECT_RATIO = 1;
200
+ const MIN_ASPECT_RATIO = 5 / 4;
201
201
  function FormField(props) {
202
202
  const {
203
203
  children,
@@ -354,7 +354,7 @@ function getVideoSrc(_ref3) {
354
354
  return "https://stream.mux.com/".concat(playbackId, ".m3u8?").concat(searchParams);
355
355
  }
356
356
  var name = "sanity-plugin-mux-input";
357
- var version = "2.2.1";
357
+ var version = "2.2.2";
358
358
  var description = "An input component that integrates Sanity Studio with Mux video encoding/hosting service.";
359
359
  var keywords = ["sanity", "video", "mux", "input", "plugin", "sanity-plugin", "media"];
360
360
  var homepage = "https://github.com/sanity-io/sanity-plugin-mux-input#readme";
@@ -442,7 +442,7 @@ var devDependencies = {
442
442
  husky: "^8.0.3",
443
443
  "lint-staged": "^13.2.3",
444
444
  next: "^13.4.12",
445
- "next-sanity": "^5.1.3",
445
+ "next-sanity": "^5.1.6",
446
446
  "npm-run-all": "^4.1.5",
447
447
  prettier: "^3.0.1",
448
448
  "prettier-plugin-packagejson": "^2.4.5",
@@ -784,29 +784,28 @@ function DocumentPreview(props) {
784
784
  children: PreviewComponent
785
785
  });
786
786
  }
787
- var __freeze$b = Object.freeze;
788
- var __defProp$c = Object.defineProperty;
789
- var __template$b = (cooked, raw) => __freeze$b(__defProp$c(cooked, "raw", {
790
- value: __freeze$b(raw || cooked.slice())
787
+ var __freeze$c = Object.freeze;
788
+ var __defProp$d = Object.defineProperty;
789
+ var __template$c = (cooked, raw) => __freeze$c(__defProp$d(cooked, "raw", {
790
+ value: __freeze$c(raw || cooked.slice())
791
791
  }));
792
- var _a$b;
793
- const Container = styled__default.default(ui.Box)(_a$b || (_a$b = __template$b(["\n * {\n color: ", ";\n }\n a {\n text-decoration: none;\n }\n h2 {\n font-size: ", ";\n }\n"])), props => props.theme.sanity.color.base.fg, props => props.theme.sanity.fonts.text.sizes[1]);
794
- const FileReferences = props => {
792
+ var _a$c;
793
+ const Container = styled__default.default(ui.Box)(_a$c || (_a$c = __template$c(["\n * {\n color: ", ";\n }\n a {\n text-decoration: none;\n }\n h2 {\n font-size: ", ";\n }\n"])), props => props.theme.sanity.color.base.fg, props => props.theme.sanity.fonts.text.sizes[1]);
794
+ const VideoReferences = props => {
795
795
  var _a2;
796
796
  const schema = sanity.useSchema();
797
797
  if (!props.isLoaded) {
798
798
  return /* @__PURE__ */jsxRuntime.jsx(SpinnerBox, {});
799
799
  }
800
800
  if (!((_a2 = props.references) == null ? void 0 : _a2.length)) {
801
- return /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
802
- size: 2,
803
- weight: "bold",
804
- muted: true,
805
- style: {
806
- marginTop: "1.5rem",
807
- textAlign: "center"
808
- },
809
- children: "No documents are using this file"
801
+ return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
802
+ border: true,
803
+ radius: 3,
804
+ padding: 3,
805
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
806
+ size: 2,
807
+ children: "No documents are using this video"
808
+ })
810
809
  });
811
810
  }
812
811
  const documentPairs = sanity.collate(props.references || []);
@@ -879,9 +878,9 @@ function DeleteDialog(_ref7) {
879
878
  }
880
879
  }
881
880
  return /* @__PURE__ */jsxRuntime.jsx(ui.Dialog, {
882
- header: "Delete file",
881
+ header: "Delete video",
883
882
  zOffset: DIALOGS_Z_INDEX,
884
- id: "deleting-file-details-dialog",
883
+ id: "deleting-video-details-dialog",
885
884
  onClose: cancelDelete,
886
885
  onClickOutside: cancelDelete,
887
886
  width: 1,
@@ -895,7 +894,7 @@ function DeleteDialog(_ref7) {
895
894
  icon: icons.TrashIcon,
896
895
  fontSize: 2,
897
896
  padding: 3,
898
- text: "Delete file",
897
+ text: "Delete video",
899
898
  tone: "critical",
900
899
  onClick: confirmDelete,
901
900
  disabled: ["processing_deletion", "checkingReferences", "cantDelete"].some(s => s === state)
@@ -915,7 +914,7 @@ function DeleteDialog(_ref7) {
915
914
  children: [state === "checkingReferences" && /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
916
915
  children: [/* @__PURE__ */jsxRuntime.jsx(ui.Heading, {
917
916
  size: 2,
918
- children: "Checking if file can be deleted"
917
+ children: "Checking if video can be deleted"
919
918
  }), /* @__PURE__ */jsxRuntime.jsx(SpinnerBox, {})]
920
919
  }), state === "cantDelete" && /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
921
920
  children: [/* @__PURE__ */jsxRuntime.jsx(ui.Heading, {
@@ -926,8 +925,8 @@ function DeleteDialog(_ref7) {
926
925
  style: {
927
926
  marginBottom: "2rem"
928
927
  },
929
- children: ["There are ", references == null ? void 0 : references.length, " document", references && references.length > 0 && "s", " ", "pointing to this file. Remove their references to this file or delete them before proceeding."]
930
- }), /* @__PURE__ */jsxRuntime.jsx(FileReferences, {
928
+ children: ["There are ", references == null ? void 0 : references.length, " document", references && references.length > 0 && "s", " ", "pointing to this video. Remove their references to this file or delete them before proceeding."]
929
+ }), /* @__PURE__ */jsxRuntime.jsx(VideoReferences, {
931
930
  references,
932
931
  isLoaded: !referencesLoading,
933
932
  placement
@@ -935,7 +934,7 @@ function DeleteDialog(_ref7) {
935
934
  }), state === "confirm" && /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
936
935
  children: [/* @__PURE__ */jsxRuntime.jsx(ui.Heading, {
937
936
  size: 2,
938
- children: "Are you sure you want to delete this file?"
937
+ children: "Are you sure you want to delete this video?"
939
938
  }), /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
940
939
  size: 2,
941
940
  children: "This action is irreversible"
@@ -971,7 +970,7 @@ function DeleteDialog(_ref7) {
971
970
  }), state === "processing_deletion" && /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
972
971
  children: [/* @__PURE__ */jsxRuntime.jsx(ui.Heading, {
973
972
  size: 2,
974
- children: "Deleting file..."
973
+ children: "Deleting video..."
975
974
  }), /* @__PURE__ */jsxRuntime.jsx(SpinnerBox, {})]
976
975
  }), state === "error_deleting" && /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
977
976
  children: [/* @__PURE__ */jsxRuntime.jsx(ui.Heading, {
@@ -979,7 +978,7 @@ function DeleteDialog(_ref7) {
979
978
  children: "Something went wrong!"
980
979
  }), /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
981
980
  size: 2,
982
- children: "Try deleting the file again by clicking the button below"
981
+ children: "Try deleting the video again by clicking the button below"
983
982
  })]
984
983
  })]
985
984
  })
@@ -1026,7 +1025,7 @@ function getVideoMetadata(doc) {
1026
1025
  max_stored_frame_rate: (_f = doc.data) == null ? void 0 : _f.max_stored_frame_rate
1027
1026
  };
1028
1027
  }
1029
- function useFileDetails(props) {
1028
+ function useVideoDetails(props) {
1030
1029
  const documentStore = sanity.useDocumentStore();
1031
1030
  const toast = ui.useToast();
1032
1031
  const client = useClient();
@@ -1067,9 +1066,11 @@ function useFileDetails(props) {
1067
1066
  filename
1068
1067
  }));
1069
1068
  toast.push({
1070
- title: "File name updated",
1069
+ title: "Video title updated",
1070
+ description: "New title: ".concat(filename),
1071
1071
  status: "success"
1072
1072
  });
1073
+ props.closeDialog();
1073
1074
  } catch (error) {
1074
1075
  toast.push({
1075
1076
  title: "Failed updating file name",
@@ -1120,7 +1121,7 @@ const VideoDetails = props => {
1120
1121
  handleClose,
1121
1122
  confirmClose,
1122
1123
  saveChanges
1123
- } = useFileDetails(props);
1124
+ } = useVideoDetails(props);
1124
1125
  const isSaving = state === "saving";
1125
1126
  const [containerHeight, setContainerHeight] = React.useState(null);
1126
1127
  const contentsRef = React__default.default.useRef(null);
@@ -1131,13 +1132,10 @@ const VideoDetails = props => {
1131
1132
  return /* @__PURE__ */jsxRuntime.jsxs(ui.Dialog, {
1132
1133
  header: displayInfo.title,
1133
1134
  zOffset: DIALOGS_Z_INDEX,
1134
- id: "file-details-dialog",
1135
+ id: "video-details-dialog",
1135
1136
  onClose: handleClose,
1136
1137
  onClickOutside: handleClose,
1137
1138
  width: 2,
1138
- style: {
1139
- minHeight: "50vh"
1140
- },
1141
1139
  position: "fixed",
1142
1140
  footer: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
1143
1141
  padding: 3,
@@ -1178,7 +1176,7 @@ const VideoDetails = props => {
1178
1176
  }), state === "closing" && /* @__PURE__ */jsxRuntime.jsx(ui.Dialog, {
1179
1177
  header: "You have unsaved changes",
1180
1178
  zOffset: DIALOGS_Z_INDEX,
1181
- id: "closing-file-details-dialog",
1179
+ id: "closing-video-details-dialog",
1182
1180
  onClose: () => confirmClose(false),
1183
1181
  onClickOutside: () => confirmClose(false),
1184
1182
  width: 1,
@@ -1258,11 +1256,11 @@ const VideoDetails = props => {
1258
1256
  label: "Details",
1259
1257
  onClick: () => setTab("details"),
1260
1258
  selected: tab === "details"
1261
- }), references && references.length > 0 && /* @__PURE__ */jsxRuntime.jsx(ui.Tab, {
1259
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Tab, {
1262
1260
  "aria-controls": "references-panel",
1263
1261
  icon: icons.SearchIcon,
1264
1262
  id: "references-tab",
1265
- label: "Used by (".concat(references.length, ")"),
1263
+ label: "Used by ".concat(references ? "(".concat(references.length, ")") : ""),
1266
1264
  onClick: () => setTab("references"),
1267
1265
  selected: tab === "references"
1268
1266
  })]
@@ -1273,8 +1271,8 @@ const VideoDetails = props => {
1273
1271
  children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
1274
1272
  space: 4,
1275
1273
  children: [/* @__PURE__ */jsxRuntime.jsx(AssetInput, {
1276
- label: "File name",
1277
- description: "Not visible to users. Useful for finding files later.",
1274
+ label: "Video title or file name",
1275
+ description: "Not visible to users. Useful for finding videos later.",
1278
1276
  value: filename || "",
1279
1277
  onInput: e => setFilename(e.currentTarget.value),
1280
1278
  disabled: state !== "idle"
@@ -1314,7 +1312,7 @@ const VideoDetails = props => {
1314
1312
  "aria-labelledby": "references-tab",
1315
1313
  id: "references-panel",
1316
1314
  hidden: tab !== "references",
1317
- children: /* @__PURE__ */jsxRuntime.jsx(FileReferences, {
1315
+ children: /* @__PURE__ */jsxRuntime.jsx(VideoReferences, {
1318
1316
  references,
1319
1317
  isLoaded: !referencesLoading,
1320
1318
  placement: props.placement
@@ -1406,13 +1404,13 @@ function getAnimatedPosterSrc(_ref10) {
1406
1404
  }
1407
1405
  return "https://image.mux.com/".concat(playbackId, "/animated.gif?").concat(searchParams);
1408
1406
  }
1409
- var __freeze$a = Object.freeze;
1410
- var __defProp$b = Object.defineProperty;
1411
- var __template$a = (cooked, raw) => __freeze$a(__defProp$b(cooked, "raw", {
1412
- value: __freeze$a(raw || cooked.slice())
1407
+ var __freeze$b = Object.freeze;
1408
+ var __defProp$c = Object.defineProperty;
1409
+ var __template$b = (cooked, raw) => __freeze$b(__defProp$c(cooked, "raw", {
1410
+ value: __freeze$b(raw || cooked.slice())
1413
1411
  }));
1414
- var _a$a;
1415
- const Image = styled__default.default.img(_a$a || (_a$a = __template$a(["\n transition: opacity 0.175s ease-out 0s;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center center;\n"])));
1412
+ var _a$b;
1413
+ const Image = styled__default.default.img(_a$b || (_a$b = __template$b(["\n transition: opacity 0.175s ease-out 0s;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center center;\n"])));
1416
1414
  const STATUS_TO_TONE = {
1417
1415
  loading: "transparent",
1418
1416
  error: "critical",
@@ -1492,13 +1490,13 @@ function VideoThumbnail(_ref11) {
1492
1490
  }) : null
1493
1491
  });
1494
1492
  }
1495
- var __freeze$9 = Object.freeze;
1496
- var __defProp$a = Object.defineProperty;
1497
- var __template$9 = (cooked, raw) => __freeze$9(__defProp$a(cooked, "raw", {
1498
- value: __freeze$9(raw || cooked.slice())
1493
+ var __freeze$a = Object.freeze;
1494
+ var __defProp$b = Object.defineProperty;
1495
+ var __template$a = (cooked, raw) => __freeze$a(__defProp$b(cooked, "raw", {
1496
+ value: __freeze$a(raw || cooked.slice())
1499
1497
  }));
1500
- var _a$9;
1501
- const PlayButton = styled__default.default.button(_a$9 || (_a$9 = __template$9(["\n display: block;\n padding: 0;\n margin: 0;\n border: none;\n border-radius: 0.1875rem;\n position: relative;\n cursor: pointer;\n\n &::after {\n content: '';\n background: var(--card-fg-color);\n opacity: 0;\n display: block;\n position: absolute;\n inset: 0;\n z-index: 10;\n transition: 0.15s ease-out;\n border-radius: inherit;\n }\n\n > div[data-play] {\n z-index: 11;\n opacity: 0;\n transition: 0.15s 0.05s ease-out;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n color: var(--card-fg-color);\n background: var(--card-bg-color);\n width: auto;\n height: 30%;\n aspect-ratio: 1;\n border-radius: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n box-sizing: border-box;\n > svg {\n display: block;\n width: 70%;\n height: auto;\n // Visual balance to center-align the icon\n transform: translateX(5%);\n }\n }\n\n &:hover,\n &:focus {\n &::after {\n opacity: 0.3;\n }\n > div[data-play] {\n opacity: 1;\n }\n }\n"])));
1498
+ var _a$a;
1499
+ const PlayButton = styled__default.default.button(_a$a || (_a$a = __template$a(["\n display: block;\n padding: 0;\n margin: 0;\n border: none;\n border-radius: 0.1875rem;\n position: relative;\n cursor: pointer;\n\n &::after {\n content: '';\n background: var(--card-fg-color);\n opacity: 0;\n display: block;\n position: absolute;\n inset: 0;\n z-index: 10;\n transition: 0.15s ease-out;\n border-radius: inherit;\n }\n\n > div[data-play] {\n z-index: 11;\n opacity: 0;\n transition: 0.15s 0.05s ease-out;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n color: var(--card-fg-color);\n background: var(--card-bg-color);\n width: auto;\n height: 30%;\n aspect-ratio: 1;\n border-radius: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n box-sizing: border-box;\n > svg {\n display: block;\n width: 70%;\n height: auto;\n // Visual balance to center-align the icon\n transform: translateX(5%);\n }\n }\n\n &:hover,\n &:focus {\n &::after {\n opacity: 0.3;\n }\n > div[data-play] {\n opacity: 1;\n }\n }\n"])));
1502
1500
  function VideoInBrowser(_ref12) {
1503
1501
  let {
1504
1502
  onSelect,
@@ -1622,6 +1620,9 @@ function VideosBrowser(_ref13) {
1622
1620
  children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
1623
1621
  padding: 4,
1624
1622
  space: 4,
1623
+ style: {
1624
+ minHeight: "50vh"
1625
+ },
1625
1626
  children: [/* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
1626
1627
  justify: "space-between",
1627
1628
  align: "center",
@@ -1632,7 +1633,7 @@ function VideosBrowser(_ref13) {
1632
1633
  value: searchQuery,
1633
1634
  icon: icons.SearchIcon,
1634
1635
  onInput: e => setSearchQuery(e.currentTarget.value),
1635
- placeholder: "Search files"
1636
+ placeholder: "Search videos"
1636
1637
  }), /* @__PURE__ */jsxRuntime.jsx(SelectSortOptions, {
1637
1638
  setSort,
1638
1639
  sort
@@ -1655,13 +1656,15 @@ function VideosBrowser(_ref13) {
1655
1656
  }, asset._id))
1656
1657
  })]
1657
1658
  }), isLoading && /* @__PURE__ */jsxRuntime.jsx(SpinnerBox, {}), !isLoading && assets.length === 0 && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
1658
- padding: 2,
1659
+ padding: 4,
1659
1660
  marginY: 4,
1660
1661
  border: true,
1661
1662
  radius: 2,
1663
+ tone: "transparent",
1662
1664
  children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
1663
1665
  align: "center",
1664
1666
  muted: true,
1667
+ size: 3,
1665
1668
  children: searchQuery ? 'No videos found for "'.concat(searchQuery, '"') : "No videos in this dataset"
1666
1669
  })
1667
1670
  })]
@@ -2130,6 +2133,13 @@ function SelectAssets(_ref14) {
2130
2133
  onSelect: handleSelect
2131
2134
  });
2132
2135
  }
2136
+ var __freeze$9 = Object.freeze;
2137
+ var __defProp$a = Object.defineProperty;
2138
+ var __template$9 = (cooked, raw) => __freeze$9(__defProp$a(cooked, "raw", {
2139
+ value: __freeze$9(raw || cooked.slice())
2140
+ }));
2141
+ var _a$9;
2142
+ const StyledDialog = styled__default.default(ui.Dialog)(_a$9 || (_a$9 = __template$9(["\n > div[data-ui='DialogCard'] > div[data-ui='Card'] {\n height: 100%;\n }\n"])));
2133
2143
  function InputBrowser(_ref15) {
2134
2144
  let {
2135
2145
  setDialogState,
@@ -2138,7 +2148,7 @@ function InputBrowser(_ref15) {
2138
2148
  } = _ref15;
2139
2149
  const id = "InputBrowser".concat(React.useId());
2140
2150
  const handleClose = React.useCallback(() => setDialogState(false), [setDialogState]);
2141
- return /* @__PURE__ */jsxRuntime.jsx(ui.Dialog, {
2151
+ return /* @__PURE__ */jsxRuntime.jsx(StyledDialog, {
2142
2152
  __unstable_autoFocus: true,
2143
2153
  header: "Select video",
2144
2154
  id,
@@ -2299,7 +2309,7 @@ const Player = _ref17 => {
2299
2309
  return /* @__PURE__ */jsxRuntime.jsx(UploadProgress, {
2300
2310
  progress: 100,
2301
2311
  filename: asset == null ? void 0 : asset.filename,
2302
- text: isLoading !== true && isLoading || "Waiting for Mux to complete the file",
2312
+ text: isLoading !== true && isLoading || "Waiting for Mux to complete the upload",
2303
2313
  onCancel: readOnly ? void 0 : () => handleCancelUpload()
2304
2314
  });
2305
2315
  }