@electrolux-oss/sanity-plugin-media 1.0.3 → 3.0.0

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/dist/index.mjs CHANGED
@@ -20,13 +20,12 @@ import { Virtuoso, VirtuosoGrid, GroupedVirtuoso } from "react-virtuoso";
20
20
  import { Controller, useForm } from "react-hook-form";
21
21
  import { zodResolver } from "@hookform/resolvers/zod";
22
22
  import * as z from "zod";
23
- import format from "date-fns/format";
23
+ import { format, formatRelative } from "date-fns";
24
24
  import filesize from "filesize";
25
25
  import copy from "copy-to-clipboard";
26
26
  import { useIntentLink } from "sanity/router";
27
27
  import { FileIcon as FileIcon$1, defaultStyles } from "react-file-icon";
28
28
  import CreatableSelect from "react-select/creatable";
29
- import formatRelative from "date-fns/formatRelative";
30
29
  import { useDropzone } from "react-dropzone";
31
30
  function getDefaultExportFromCjs(x) {
32
31
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
@@ -4049,7 +4048,7 @@ const imageDprUrl = (asset, options) => {
4049
4048
  `
4050
4049
  ), StyledWarningOutlineIcon = styled(WarningFilledIcon)(({ theme }) => ({
4051
4050
  color: theme.sanity.color.spot.red
4052
- })), CardAsset = (props) => {
4051
+ })), CardAsset$1 = (props) => {
4053
4052
  const { id, selected } = props, scheme = useColorSchemeValue(), shiftPressed = useKeyPress("shift"), dispatch = useDispatch(), lastPicked = useTypedSelector((state) => state.assets.lastPicked), item = useTypedSelector((state) => selectAssetById(state, id)), asset = item?.asset, error = item?.error, isOpaque = item?.asset?.metadata?.isOpaque, picked = item?.picked, updating = item?.updating, { onSelect } = useAssetSourceActions();
4054
4053
  if (!asset)
4055
4054
  return null;
@@ -4179,7 +4178,7 @@ const imageDprUrl = (asset, options) => {
4179
4178
  )
4180
4179
  ] }) });
4181
4180
  };
4182
- var CardAsset$1 = memo(CardAsset);
4181
+ var CardAsset = memo(CardAsset$1);
4183
4182
  const PREVIEW_WIDTH = 180, createBlob = (img) => new Promise((resolve) => {
4184
4183
  const imageAspect = img.width / img.height, canvas = document.createElement("canvas");
4185
4184
  canvas.width = PREVIEW_WIDTH, canvas.height = Math.max(PREVIEW_WIDTH / imageAspect, 1);
@@ -4536,7 +4535,7 @@ const CardWrapper = styled(Flex)`
4536
4535
  }
4537
4536
  ) });
4538
4537
  }, CARD_HEIGHT = 220, CARD_WIDTH = 240, VirtualCell = memo(
4539
- ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsx(CardAsset$1, { id: item.id, selected }) : item?.type === "upload" ? /* @__PURE__ */ jsx(CardUpload, { id: item.id }) : null
4538
+ ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsx(CardAsset, { id: item.id, selected }) : item?.type === "upload" ? /* @__PURE__ */ jsx(CardUpload, { id: item.id }) : null
4540
4539
  ), StyledItemContainer = styled.div`
4541
4540
  height: ${CARD_HEIGHT}px;
4542
4541
  width: ${CARD_WIDTH}px;
@@ -4701,7 +4700,7 @@ const CardWrapper = styled(Flex)`
4701
4700
  `
4702
4701
  ), StyledWarningIcon = styled(WarningFilledIcon)(({ theme }) => ({
4703
4702
  color: theme.sanity.color.spot.red
4704
- })), TableRowAsset = (props) => {
4703
+ })), TableRowAsset$1 = (props) => {
4705
4704
  const { id, selected } = props, scheme = useColorSchemeValue(), shiftPressed = useKeyPress("shift"), [referenceCountVisible, setReferenceCountVisible] = useState(!1), refCountVisibleTimeout = useRef(null), dispatch = useDispatch(), lastPicked = useTypedSelector((state) => state.assets.lastPicked), item = useTypedSelector((state) => selectAssetById(state, id)), mediaIndex = useMediaIndex(), asset = item?.asset, error = item?.error, isOpaque = item?.asset?.metadata?.isOpaque, picked = item?.picked, updating = item?.updating, { onSelect } = useAssetSourceActions(), handleContextActionClick = useCallback(
4706
4705
  (e) => {
4707
4706
  e.stopPropagation(), asset && (onSelect ? dispatch(dialogActions.showAssetEdit({ assetId: asset._id })) : shiftPressed.current && !picked ? dispatch(assetsActions.pickRange({ startId: lastPicked || asset._id, endId: asset._id })) : dispatch(assetsActions.pick({ assetId: asset._id, picked: !picked })));
@@ -4927,7 +4926,7 @@ const CardWrapper = styled(Flex)`
4927
4926
  }
4928
4927
  ) : null;
4929
4928
  };
4930
- var TableRowAsset$1 = memo(TableRowAsset);
4929
+ var TableRowAsset = memo(TableRowAsset$1);
4931
4930
  const TableRowUpload = (props) => {
4932
4931
  const { id } = props, scheme = useColorSchemeValue(), dispatch = useDispatch(), item = useTypedSelector((state) => selectUploadById(state, id)), mediaIndex = useMediaIndex();
4933
4932
  if (!item)
@@ -5041,7 +5040,7 @@ const TableRowUpload = (props) => {
5041
5040
  }
5042
5041
  );
5043
5042
  }, VirtualRow = memo(
5044
- ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsx(Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsx(TableRowAsset$1, { id: item.id, selected }) }) : item?.type === "upload" ? /* @__PURE__ */ jsx(Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsx(TableRowUpload, { id: item.id }) }) : null
5043
+ ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsx(Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsx(TableRowAsset, { id: item.id, selected }) }) : item?.type === "upload" ? /* @__PURE__ */ jsx(Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsx(TableRowUpload, { id: item.id }) }) : null
5045
5044
  ), AssetTableVirtualized = (props) => {
5046
5045
  const { items, onLoadMore } = props, selectedAssets = useTypedSelector((state) => state.selected.assets), selectedIds = selectedAssets && selectedAssets.map((asset) => asset._id) || [], totalCount = items?.length;
5047
5046
  return totalCount === 0 ? null : /* @__PURE__ */ jsx(