sanity-plugin-media 5.0.7 → 5.0.8

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.js CHANGED
@@ -4,7 +4,7 @@ import { useClient, useColorSchemeValue, useSchema, Preview, useDocumentStore, W
4
4
  import { Inline, Button, usePortal, MenuButton, Menu as Menu$2, MenuItem, MenuDivider, Box, studioTheme, Flex, Label, Text, rem, TextInput, Card, MenuGroup, useMediaIndex, Tooltip, Switch, Popover, Stack, Dialog as Dialog$1, TextArea, TabList, Tab, TabPanel, Container as Container$2, Spinner, Checkbox, Grid, useToast, PortalProvider, useLayer, Portal } from "@sanity/ui";
5
5
  import { useRef, useCallback, useEffect, createContext, useContext, useMemo, useState, memo, Component } from "react";
6
6
  import { isHotkey } from "is-hotkey-esm";
7
- import { css, createGlobalStyle, styled } from "styled-components";
7
+ import { createGlobalStyle, css, styled } from "styled-components";
8
8
  import { useSelector, useDispatch, Provider } from "react-redux";
9
9
  import { createAction, createSlice, isAnyOf, createSelector, combineReducers, configureStore } from "@reduxjs/toolkit";
10
10
  import pluralize from "pluralize";
@@ -45,7 +45,7 @@ import { ArrowUpIcon } from "@sanity/icons/ArrowUp";
45
45
  import { EditIcon } from "@sanity/icons/Edit";
46
46
  import { TrashIcon } from "@sanity/icons/Trash";
47
47
  import { ComposeIcon } from "@sanity/icons/Compose";
48
- import { Icon } from "@sanity/icons";
48
+ import { ArrowRightIcon } from "@sanity/icons/ArrowRight";
49
49
  import { UploadIcon } from "@sanity/icons/Upload";
50
50
  import { CheckmarkCircleIcon } from "@sanity/icons/CheckmarkCircle";
51
51
  import { WarningFilledIcon } from "@sanity/icons/WarningFilled";
@@ -75,7 +75,7 @@ const useKeyPress = (hotkey, onPress) => {
75
75
  return context;
76
76
  }, useVersionedClient = () => useClient({
77
77
  apiVersion: "2025-10-02"
78
- }), customScrollbar = css`::-webkit-scrollbar{width:14px;}::-webkit-scrollbar-thumb{border-radius:10px;border:4px solid rgba(0,0,0,0);background:var(--card-border-color);background-clip:padding-box;&:hover{background:var(--card-muted-fg-color);background-clip:padding-box;}}`, GlobalStyle = createGlobalStyle`.media__custom-scrollbar{${customScrollbar}}div[data-ui="Box"]{${customScrollbar}}div[data-ui="Dialog"]{background-color:rgba(15,17,18,0.9);}`, useTypedSelector = useSelector, ORDER_DICTIONARY = {
78
+ }), customScrollbar = /* @__PURE__ */ css(["::-webkit-scrollbar{width:14px;}::-webkit-scrollbar-thumb{border-radius:10px;border:4px solid rgba(0,0,0,0);background:var(--card-border-color);background-clip:padding-box;&:hover{background:var(--card-muted-fg-color);background-clip:padding-box;}}"]), GlobalStyle = /* @__PURE__ */ createGlobalStyle([".media__custom-scrollbar{", '}div[data-ui="Box"]{', '}div[data-ui="Dialog"]{background-color:rgba(15,17,18,0.9);}'], customScrollbar, customScrollbar), useTypedSelector = useSelector, ORDER_DICTIONARY = {
79
79
  _createdAt: {
80
80
  asc: "Last created: Oldest first",
81
81
  desc: "Last created: Newest first"
@@ -1729,7 +1729,7 @@ const Container$1 = /* @__PURE__ */ styled(Box).withConfig({
1729
1729
  })(({
1730
1730
  $scheme,
1731
1731
  theme
1732
- }) => css`background:${getSchemeColor($scheme, "bg")};border-radius:${rem(theme.sanity.radius[2])};`), SearchFacet = (props) => {
1732
+ }) => css(["background:", ";border-radius:", ";"], getSchemeColor($scheme, "bg"), rem(theme.sanity.radius[2]))), SearchFacet = (props) => {
1733
1733
  const {
1734
1734
  children,
1735
1735
  facet
@@ -1972,7 +1972,7 @@ const Container$1 = /* @__PURE__ */ styled(Box).withConfig({
1972
1972
  componentId: "sc-cuu8kf-0"
1973
1973
  })(({
1974
1974
  theme
1975
- }) => css`> *{margin-bottom:${rem(theme.sanity.space[2])};}`), SearchFacets = (props) => {
1975
+ }) => css(["> *{margin-bottom:", ";}"], rem(theme.sanity.space[2]))), SearchFacets = (props) => {
1976
1976
  const {
1977
1977
  layout = "inline"
1978
1978
  } = props, searchFacets = useTypedSelector((state) => state.search.facets), Items2 = searchFacets.map((facet) => {
@@ -2308,7 +2308,7 @@ const getAssetResolution = (asset) => `${asset.metadata.dimensions.width}x${asse
2308
2308
  componentId: "sc-19eu02y-0"
2309
2309
  })(({
2310
2310
  theme
2311
- }) => css`text{font-family:${theme.sanity.fonts.text.family} !important;font-size:8px !important;font-weight:500 !important;}`), FileIcon = (props) => {
2311
+ }) => css(["text{font-family:", " !important;font-size:8px !important;font-weight:500 !important;}"], theme.sanity.fonts.text.family)), FileIcon = (props) => {
2312
2312
  const {
2313
2313
  extension,
2314
2314
  onClick,
@@ -2347,10 +2347,10 @@ const getAssetResolution = (asset) => `${asset.metadata.dimensions.width}x${asse
2347
2347
  ] }) : content = "No unpublished changes" : content = "There are validation errors that need to be fixed before this document can be published", /* @__PURE__ */ jsx(Tooltip, { animate: !0, content: /* @__PURE__ */ jsx(Box, { padding: 3, style: {
2348
2348
  maxWidth: "185px"
2349
2349
  }, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: content }) }), disabled: "ontouchstart" in window, placement: "top", portal: !0, children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Button, { disabled, fontSize: 1, onClick, text: "Save and close", tone: "primary" }) }) });
2350
- }, Image$1 = styled.img.withConfig({
2350
+ }, Image$1 = /* @__PURE__ */ styled.img.withConfig({
2351
2351
  displayName: "Image",
2352
2352
  componentId: "sc-hf3ld2-0"
2353
- })`--checkerboard-color:${(props) => props.$scheme ? getSchemeColor(props.$scheme, "bg2") : "inherit"};display:block;width:100%;height:100%;object-fit:contain;${(props) => props.$showCheckerboard && css`background-image:linear-gradient(45deg,var(--checkerboard-color) 25%,transparent 25%),linear-gradient(-45deg,var(--checkerboard-color) 25%,transparent 25%),linear-gradient(45deg,transparent 75%,var(--checkerboard-color) 75%),linear-gradient(-45deg,transparent 75%,var(--checkerboard-color) 75%);background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0;`}`, {
2353
+ })(["--checkerboard-color:", ";display:block;width:100%;height:100%;object-fit:contain;", ""], (props) => props.$scheme ? getSchemeColor(props.$scheme, "bg2") : "inherit", (props) => props.$showCheckerboard && css(["background-image:linear-gradient(45deg,var(--checkerboard-color) 25%,transparent 25%),linear-gradient(-45deg,var(--checkerboard-color) 25%,transparent 25%),linear-gradient(45deg,transparent 75%,var(--checkerboard-color) 75%),linear-gradient(-45deg,transparent 75%,var(--checkerboard-color) 75%);background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0;"])), {
2354
2354
  radius: themeRadius,
2355
2355
  space: themeSpace
2356
2356
  } = studioTheme, reactSelectStyles = (scheme) => ({
@@ -3058,13 +3058,13 @@ const DialogAssetEdit = (props) => {
3058
3058
  ]
3059
3059
  }
3060
3060
  ) : null;
3061
- }, TagContainer = styled(Flex).withConfig({
3061
+ }, TagContainer = /* @__PURE__ */ styled(Flex).withConfig({
3062
3062
  displayName: "TagContainer",
3063
3063
  componentId: "sc-sujhn-0"
3064
- })`height:${PANEL_HEIGHT}px;`, ButtonContainer = styled(Flex).withConfig({
3064
+ })(["height:", "px;"], PANEL_HEIGHT), ButtonContainer = /* @__PURE__ */ styled(Flex).withConfig({
3065
3065
  displayName: "ButtonContainer",
3066
3066
  componentId: "sc-sujhn-1"
3067
- })`@media (pointer:fine){visibility:hidden;}@media (hover:hover) and (pointer:fine){${TagContainer}:hover &{visibility:visible;}}`, TagButton = (props) => {
3067
+ })(["@media (pointer:fine){visibility:hidden;}@media (hover:hover) and (pointer:fine){", ":hover &{visibility:visible;}}"], TagContainer), TagButton = (props) => {
3068
3068
  const {
3069
3069
  disabled,
3070
3070
  icon,
@@ -3276,7 +3276,7 @@ const DialogAssetEdit = (props) => {
3276
3276
  selectedDocument && /* @__PURE__ */ jsx(Box, { display: ["none", "none", "block"], children: /* @__PURE__ */ jsxs(Text, { children: [
3277
3277
  /* @__PURE__ */ jsx("span", { style: {
3278
3278
  margin: "0 0.5em"
3279
- }, children: /* @__PURE__ */ jsx(Icon, { symbol: "arrow-right" }) }),
3279
+ }, children: /* @__PURE__ */ jsx(ArrowRightIcon, {}) }),
3280
3280
  /* @__PURE__ */ jsx("span", { style: {
3281
3281
  textTransform: "capitalize"
3282
3282
  }, children: selectedDocument._type })
@@ -3324,22 +3324,22 @@ const DialogAssetEdit = (props) => {
3324
3324
  id,
3325
3325
  type: "upload"
3326
3326
  })), ...assetItems];
3327
- }), CardWrapper$1 = styled(Flex).withConfig({
3327
+ }), CardWrapper$1 = /* @__PURE__ */ styled(Flex).withConfig({
3328
3328
  displayName: "CardWrapper",
3329
3329
  componentId: "sc-88amzd-0"
3330
- })`box-sizing:border-box;height:100%;overflow:hidden;position:relative;width:100%;`, CardContainer = /* @__PURE__ */ styled(Flex).withConfig({
3330
+ })(["box-sizing:border-box;height:100%;overflow:hidden;position:relative;width:100%;"]), CardContainer = /* @__PURE__ */ styled(Flex).withConfig({
3331
3331
  displayName: "CardContainer",
3332
3332
  componentId: "sc-88amzd-1"
3333
3333
  })(({
3334
3334
  $picked,
3335
3335
  theme,
3336
3336
  $updating
3337
- }) => css`border:1px solid transparent;height:100%;pointer-events:${$updating ? "none" : "auto"};position:relative;transition:all 300ms;user-select:none;width:100%;border:${$picked ? `1px solid ${theme.sanity.color.spot.orange} !important` : "1px solid inherit"};${!$updating && css`@media (hover:hover) and (pointer:fine){&:hover{border:1px solid var(--card-border-color);}}`}`), ContextActionContainer$2 = /* @__PURE__ */ styled(Flex).withConfig({
3337
+ }) => css(["border:1px solid transparent;height:100%;pointer-events:", ";position:relative;transition:all 300ms;user-select:none;width:100%;border:", ";", ""], $updating ? "none" : "auto", $picked ? `1px solid ${theme.sanity.color.spot.orange} !important` : "1px solid inherit", !$updating && css(["@media (hover:hover) and (pointer:fine){&:hover{border:1px solid var(--card-border-color);}}"]))), ContextActionContainer$2 = /* @__PURE__ */ styled(Flex).withConfig({
3338
3338
  displayName: "ContextActionContainer",
3339
3339
  componentId: "sc-88amzd-2"
3340
3340
  })(({
3341
3341
  $scheme
3342
- }) => css`cursor:pointer;height:${PANEL_HEIGHT}px;transition:all 300ms;@media (hover:hover) and (pointer:fine){&:hover{background:${getSchemeColor($scheme, "bg")};}}`), StyledWarningOutlineIcon = /* @__PURE__ */ styled(WarningFilledIcon).withConfig({
3342
+ }) => css(["cursor:pointer;height:", "px;transition:all 300ms;@media (hover:hover) and (pointer:fine){&:hover{background:", ";}}"], PANEL_HEIGHT, getSchemeColor($scheme, "bg"))), StyledWarningOutlineIcon = /* @__PURE__ */ styled(WarningFilledIcon).withConfig({
3343
3343
  displayName: "StyledWarningOutlineIcon",
3344
3344
  componentId: "sc-88amzd-3"
3345
3345
  })(({
@@ -3670,10 +3670,10 @@ const createThrottler = (concurrency = DEFAULT_CONCURRENCY) => {
3670
3670
  ...uploadsSlice.actions
3671
3671
  };
3672
3672
  var uploadsReducer = uploadsSlice.reducer;
3673
- const CardWrapper = styled(Flex).withConfig({
3673
+ const CardWrapper = /* @__PURE__ */ styled(Flex).withConfig({
3674
3674
  displayName: "CardWrapper",
3675
3675
  componentId: "sc-11n35er-0"
3676
- })`box-sizing:border-box;height:100%;overflow:hidden;position:relative;width:100%;`, CardUpload = (props) => {
3676
+ })(["box-sizing:border-box;height:100%;overflow:hidden;position:relative;width:100%;"]), CardUpload = (props) => {
3677
3677
  const {
3678
3678
  id
3679
3679
  } = props, scheme = useColorSchemeValue(), dispatch = useDispatch(), item = useTypedSelector((state) => selectUploadById(state, id));
@@ -3745,20 +3745,20 @@ const CardWrapper = styled(Flex).withConfig({
3745
3745
  }, CARD_HEIGHT = 220, CARD_WIDTH = 240, VirtualCell = memo(({
3746
3746
  item,
3747
3747
  selected
3748
- }) => item?.type === "asset" ? /* @__PURE__ */ jsx(CardAsset, { id: item.id, selected }) : item?.type === "upload" ? /* @__PURE__ */ jsx(CardUpload, { id: item.id }) : null), StyledItemContainer = styled.div.withConfig({
3748
+ }) => item?.type === "asset" ? /* @__PURE__ */ jsx(CardAsset, { id: item.id, selected }) : item?.type === "upload" ? /* @__PURE__ */ jsx(CardUpload, { id: item.id }) : null), StyledItemContainer = /* @__PURE__ */ styled.div.withConfig({
3749
3749
  displayName: "StyledItemContainer",
3750
3750
  componentId: "sc-9owt7i-0"
3751
- })`height:${CARD_HEIGHT}px;width:${CARD_WIDTH}px;`, ItemContainer = (props) => {
3751
+ })(["height:", "px;width:", "px;"], CARD_HEIGHT, CARD_WIDTH), ItemContainer = (props) => {
3752
3752
  const {
3753
3753
  context,
3754
3754
  ref,
3755
3755
  ...rest
3756
3756
  } = props;
3757
3757
  return /* @__PURE__ */ jsx(StyledItemContainer, { ref, ...rest });
3758
- }, StyledListContainer = styled.div.withConfig({
3758
+ }, StyledListContainer = /* @__PURE__ */ styled.div.withConfig({
3759
3759
  displayName: "StyledListContainer",
3760
3760
  componentId: "sc-9owt7i-1"
3761
- })`display:grid;grid-template-columns:repeat(auto-fill,${CARD_WIDTH}px);grid-template-rows:repeat(auto-fill,${CARD_HEIGHT}px);justify-content:center;margin:0 auto;`, ListContainer = (props) => {
3761
+ })(["display:grid;grid-template-columns:repeat(auto-fill,", "px);grid-template-rows:repeat(auto-fill,", "px);justify-content:center;margin:0 auto;"], CARD_WIDTH, CARD_HEIGHT), ListContainer = (props) => {
3762
3762
  const {
3763
3763
  context,
3764
3764
  ref,
@@ -3818,7 +3818,7 @@ const CardWrapper = styled(Flex).withConfig({
3818
3818
  componentId: "sc-i9fhtm-0"
3819
3819
  })(({
3820
3820
  $scheme
3821
- }) => css`cursor:pointer;@media (hover:hover) and (pointer:fine){&:hover{background:${getSchemeColor($scheme, "bg")};}}`), TableHeader = () => {
3821
+ }) => css(["cursor:pointer;@media (hover:hover) and (pointer:fine){&:hover{background:", ";}}"], getSchemeColor($scheme, "bg"))), TableHeader = () => {
3822
3822
  const scheme = useColorSchemeValue(), dispatch = useDispatch(), fetching = useTypedSelector((state) => state.assets.fetching), itemsLength = useTypedSelector(selectAssetsLength), numPickedAssets = useTypedSelector(selectAssetsPickedLength), mediaIndex = useMediaIndex(), {
3823
3823
  onSelect
3824
3824
  } = useAssetSourceActions(), allSelected = numPickedAssets === itemsLength, handleContextActionClick = (e) => {
@@ -3864,12 +3864,12 @@ const CardWrapper = styled(Flex).withConfig({
3864
3864
  $scheme,
3865
3865
  $selected,
3866
3866
  $updating
3867
- }) => css`align-items:center;cursor:${$selected ? "default" : "pointer"};height:100%;pointer-events:${$updating ? "none" : "auto"};user-select:none;white-space:nowrap;${!$updating && css`@media (hover:hover) and (pointer:fine){&:hover{background:${getSchemeColor($scheme, "bg")};}}`}`), ContextActionContainer = /* @__PURE__ */ styled(Flex).withConfig({
3867
+ }) => css(["align-items:center;cursor:", ";height:100%;pointer-events:", ";user-select:none;white-space:nowrap;", ""], $selected ? "default" : "pointer", $updating ? "none" : "auto", !$updating && css(["@media (hover:hover) and (pointer:fine){&:hover{background:", ";}}"], getSchemeColor($scheme, "bg")))), ContextActionContainer = /* @__PURE__ */ styled(Flex).withConfig({
3868
3868
  displayName: "ContextActionContainer",
3869
3869
  componentId: "sc-1nb1qw9-1"
3870
3870
  })(({
3871
3871
  $scheme
3872
- }) => css`cursor:pointer;@media (hover:hover) and (pointer:fine){&:hover{background:${getSchemeColor($scheme, "bg2")};}}`), StyledWarningIcon = /* @__PURE__ */ styled(WarningFilledIcon).withConfig({
3872
+ }) => css(["cursor:pointer;@media (hover:hover) and (pointer:fine){&:hover{background:", ";}}"], getSchemeColor($scheme, "bg2"))), StyledWarningIcon = /* @__PURE__ */ styled(WarningFilledIcon).withConfig({
3873
3873
  displayName: "StyledWarningIcon",
3874
3874
  componentId: "sc-1nb1qw9-2"
3875
3875
  })(({
@@ -4373,13 +4373,13 @@ const TagsPanel = () => useTypedSelector((state) => state.tags.panelVisible) ? /
4373
4373
  right: 0,
4374
4374
  top: 0,
4375
4375
  width: "100%"
4376
- }, children: /* @__PURE__ */ jsx(TagView, {}) }) }) : null, UploadContainer = styled.div.withConfig({
4376
+ }, children: /* @__PURE__ */ jsx(TagView, {}) }) }) : null, UploadContainer = /* @__PURE__ */ styled.div.withConfig({
4377
4377
  displayName: "UploadContainer",
4378
4378
  componentId: "sc-1wiv2t5-0"
4379
- })`color:white;height:100%;min-height:100%;right:0;top:0;width:100%;&:focus{outline:none;}`, DragActiveContainer = styled.div.withConfig({
4379
+ })(["color:white;height:100%;min-height:100%;right:0;top:0;width:100%;&:focus{outline:none;}"]), DragActiveContainer = /* @__PURE__ */ styled.div.withConfig({
4380
4380
  displayName: "DragActiveContainer",
4381
4381
  componentId: "sc-1wiv2t5-1"
4382
- })`align-items:center;background:rgba(0,0,0,0.75);display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;width:100%;z-index:3;`;
4382
+ })(["align-items:center;background:rgba(0,0,0,0.75);display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;width:100%;z-index:3;"]);
4383
4383
  async function filterFiles(fileList) {
4384
4384
  const files = Array.from(fileList), filteredFiles = [];
4385
4385
  for (const file of files)