sanity-plugin-media 6.0.6 → 6.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
@@ -521,39 +521,39 @@ const useKeyPress = (hotkey, onPress) => {
521
521
  value: tag?._id
522
522
  }), acc;
523
523
  }, []), ASSETS_ACTIONS = {
524
- tagsAddComplete: createAction("actions/tagsAddComplete", function({ assets, tag }) {
524
+ tagsAddComplete: createAction("actions/tagsAddComplete", function prepare({ assets, tag }) {
525
525
  return { payload: {
526
526
  assets,
527
527
  tag
528
528
  } };
529
529
  }),
530
- tagsAddError: createAction("actions/tagsAddError", function({ assets, error, tag }) {
530
+ tagsAddError: createAction("actions/tagsAddError", function prepare({ assets, error, tag }) {
531
531
  return { payload: {
532
532
  assets,
533
533
  error,
534
534
  tag
535
535
  } };
536
536
  }),
537
- tagsAddRequest: createAction("actions/tagsAddRequest", function({ assets, tag }) {
537
+ tagsAddRequest: createAction("actions/tagsAddRequest", function prepare({ assets, tag }) {
538
538
  return { payload: {
539
539
  assets,
540
540
  tag
541
541
  } };
542
542
  }),
543
- tagsRemoveComplete: createAction("actions/tagsRemoveComplete", function({ assets, tag }) {
543
+ tagsRemoveComplete: createAction("actions/tagsRemoveComplete", function prepare({ assets, tag }) {
544
544
  return { payload: {
545
545
  assets,
546
546
  tag
547
547
  } };
548
548
  }),
549
- tagsRemoveError: createAction("actions/tagsRemoveError", function({ assets, error, tag }) {
549
+ tagsRemoveError: createAction("actions/tagsRemoveError", function prepare({ assets, error, tag }) {
550
550
  return { payload: {
551
551
  assets,
552
552
  error,
553
553
  tag
554
554
  } };
555
555
  }),
556
- tagsRemoveRequest: createAction("actions/tagsRemoveRequest", function({ assets, tag }) {
556
+ tagsRemoveRequest: createAction("actions/tagsRemoveRequest", function prepare({ assets, tag }) {
557
557
  return { payload: {
558
558
  assets,
559
559
  tag
@@ -561,7 +561,7 @@ const useKeyPress = (hotkey, onPress) => {
561
561
  })
562
562
  }, DIALOG_ACTIONS = {
563
563
  showTagCreate: createAction("dialog/showTagCreate"),
564
- showTagEdit: createAction("dialog/showTagEdit", function({ tagId }) {
564
+ showTagEdit: createAction("dialog/showTagEdit", function prepare({ tagId }) {
565
565
  return { payload: { tagId } };
566
566
  })
567
567
  }, tagsSlice = createSlice({
@@ -781,7 +781,7 @@ const useKeyPress = (hotkey, onPress) => {
781
781
  },
782
782
  tag
783
783
  }))));
784
- })), selectTagsByIds = (state) => state.tags.byIds, selectTags = createSelector([selectTagsByIds, (state) => state.tags.allIds], (byIds, allIds) => allIds.map((id) => byIds[id])), selectTagById = createSelector([selectTagsByIds, (_state, tagId) => tagId], (byIds, tagId) => byIds[tagId]), selectTagSelectOptions = (asset) => (state) => {
784
+ })), selectTagsByIds = (state) => state.tags.byIds, selectTagsAllIds = (state) => state.tags.allIds, selectTags = createSelector([selectTagsByIds, selectTagsAllIds], (byIds, allIds) => allIds.map((id) => byIds[id])), selectTagById = createSelector([selectTagsByIds, (_state, tagId) => tagId], (byIds, tagId) => byIds[tagId]), selectTagSelectOptions = (asset) => (state) => {
785
785
  let tags = asset?.opt?.media?.tags?.reduce((acc, v) => {
786
786
  let tagItem = state.tags.byIds[v._ref];
787
787
  return tagItem?.tag && acc.push(tagItem), acc;
@@ -839,7 +839,7 @@ const searchSlice = createSlice({
839
839
  })) : EMPTY;
840
840
  })), selectIsSearchFacetTag = createSelector([(state) => state.search.facets, (_state, tagId) => tagId], (searchFacets, tagId) => searchFacets.some((facet) => facet.name === "tag" && facet.type === "searchable" && (facet.operatorType === "references" || facet.operatorType === "doesNotReference") && facet.value?.value === tagId)), searchActions = { ...searchSlice.actions };
841
841
  var search_default = searchSlice.reducer;
842
- const UPLOADS_ACTIONS = { uploadComplete: createAction("uploads/uploadComplete", function({ asset }) {
842
+ const UPLOADS_ACTIONS = { uploadComplete: createAction("uploads/uploadComplete", function prepare({ asset }) {
843
843
  return { payload: { asset } };
844
844
  }) }, defaultOrder = ORDER_OPTIONS[0], initialState = {
845
845
  allIds: [],
@@ -1893,6 +1893,18 @@ const Container$2 = /* @__PURE__ */ styled(Box).withConfig({
1893
1893
  children: t1
1894
1894
  })
1895
1895
  }), $[3] = props, $[4] = t1, $[5] = t2) : t2 = $[5], t2;
1896
+ }, SingleValue = (props) => {
1897
+ let $ = c(5), t0;
1898
+ $[0] === props.children ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Text, {
1899
+ size: 1,
1900
+ textOverflow: "ellipsis",
1901
+ children: props.children
1902
+ }), $[0] = props.children, $[1] = t0);
1903
+ let t1;
1904
+ return $[2] !== props || $[3] !== t0 ? (t1 = /* @__PURE__ */ jsx(components.SingleValue, {
1905
+ ...props,
1906
+ children: t0
1907
+ }), $[2] = props, $[3] = t0, $[4] = t1) : t1 = $[4], t1;
1896
1908
  }, reactSelectComponents$1 = {
1897
1909
  ClearIndicator,
1898
1910
  DropdownIndicator: null,
@@ -1901,19 +1913,7 @@ const Container$2 = /* @__PURE__ */ styled(Box).withConfig({
1901
1913
  MenuList: MenuList$1,
1902
1914
  NoOptionsMessage,
1903
1915
  Option: Option$1,
1904
- SingleValue: (props) => {
1905
- let $ = c(5), t0;
1906
- $[0] === props.children ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx(Text, {
1907
- size: 1,
1908
- textOverflow: "ellipsis",
1909
- children: props.children
1910
- }), $[0] = props.children, $[1] = t0);
1911
- let t1;
1912
- return $[2] !== props || $[3] !== t0 ? (t1 = /* @__PURE__ */ jsx(components.SingleValue, {
1913
- ...props,
1914
- children: t0
1915
- }), $[2] = props, $[3] = t0, $[4] = t1) : t1 = $[4], t1;
1916
- }
1916
+ SingleValue
1917
1917
  }, SearchFacetTags = (t0) => {
1918
1918
  let $ = c(24), { facet } = t0, scheme = useColorSchemeValue(), dispatch = useDispatch(), tags = useTypedSelector(_temp$25), tagsFetching = useTypedSelector(_temp2$17), t1;
1919
1919
  $[0] === tags ? t1 = $[1] : (t1 = getTagSelectOptions(tags), $[0] = tags, $[1] = t1);
@@ -4534,8 +4534,7 @@ const selectCombinedItems = createSelector([(state) => state.assets.allIds, (sta
4534
4534
  })(({ $scheme }) => css`cursor:pointer;height:${32}px;transition:all 300ms;@media (hover:hover) and (pointer:fine){&:hover{background:${getSchemeColor($scheme, "bg")};}}`), StyledWarningOutlineIcon = /* @__PURE__ */ styled(WarningFilledIcon).withConfig({
4535
4535
  displayName: "StyledWarningOutlineIcon",
4536
4536
  componentId: "sc-1uiydw-3"
4537
- })(({ theme }) => ({ color: theme.sanity.color.spot.red }));
4538
- var CardAsset_default = memo((props) => {
4537
+ })(({ theme }) => ({ color: theme.sanity.color.spot.red })), CardAsset = (props) => {
4539
4538
  let $ = c(63), { id, selected } = props, scheme = useColorSchemeValue(), shiftPressed = useKeyPress("shift"), dispatch = useDispatch(), lastPicked = useTypedSelector(_temp$10), t0;
4540
4539
  $[0] === id ? t0 = $[1] : (t0 = (state_0) => selectAssetById(state_0, id), $[0] = id, $[1] = t0);
4541
4540
  let item = useTypedSelector(t0), asset = item?.asset, error = item?.error, isOpaque = item?.asset?.metadata?.isOpaque, picked = item?.picked, updating = item?.updating, { onSelect } = useAssetSourceActions();
@@ -4712,7 +4711,8 @@ var CardAsset_default = memo((props) => {
4712
4711
  ]
4713
4712
  })
4714
4713
  }), $[57] = item.updating, $[58] = picked, $[59] = t11, $[60] = t15, $[61] = t16, $[62] = t17) : t17 = $[62], t17;
4715
- });
4714
+ };
4715
+ var CardAsset_default = memo(CardAsset);
4716
4716
  function _temp$10(state) {
4717
4717
  return state.assets.lastPicked;
4718
4718
  }
@@ -4771,7 +4771,7 @@ const createThrottler = (concurrency = 4) => {
4771
4771
  }), hexFromBuffer = (buffer) => Array.prototype.map.call(new Uint8Array(buffer), (x) => `00${x.toString(16)}`.slice(-2)).join(""), hashFile$ = (file) => !window.crypto || !window.crypto.subtle || !window.FileReader ? throwError({
4772
4772
  message: "Unable to generate hash: uploads are only allowed in secure contexts",
4773
4773
  statusCode: 500
4774
- }) : readFile$(file).pipe(mergeMap((arrayBuffer) => window.crypto.subtle.digest("SHA-1", arrayBuffer)), map(hexFromBuffer)), uploadAsset$ = withMaxConcurrency((client, assetType, file, hash) => of(null).pipe(mergeMap(() => fetchExisting$(client, `sanity.${assetType}Asset`, hash)), mergeMap((existingAsset) => existingAsset ? throwError({
4774
+ }) : readFile$(file).pipe(mergeMap((arrayBuffer) => window.crypto.subtle.digest("SHA-1", arrayBuffer)), map(hexFromBuffer)), uploadSanityAsset$ = (client, assetType, file, hash) => of(null).pipe(mergeMap(() => fetchExisting$(client, `sanity.${assetType}Asset`, hash)), mergeMap((existingAsset) => existingAsset ? throwError({
4775
4775
  message: "Asset already exists",
4776
4776
  statusCode: 409
4777
4777
  }) : of(null)), mergeMap(() => client.observable.assets.upload(assetType, file, {
@@ -4787,7 +4787,7 @@ const createThrottler = (concurrency = 4) => {
4787
4787
  asset: event.body.document,
4788
4788
  id: event.body.document._id,
4789
4789
  type: "complete"
4790
- } : event))))), uploadsSlice = createSlice({
4790
+ } : event)))), uploadAsset$ = withMaxConcurrency(uploadSanityAsset$), uploadsSlice = createSlice({
4791
4791
  name: "uploads",
4792
4792
  initialState: {
4793
4793
  allIds: [],
@@ -5239,8 +5239,7 @@ const ContainerGrid = /* @__PURE__ */ styled(Grid).withConfig({
5239
5239
  })(({ $scheme }) => css`cursor:pointer;@media (hover:hover) and (pointer:fine){&:hover{background:${getSchemeColor($scheme, "bg2")};}}`), StyledWarningIcon = /* @__PURE__ */ styled(WarningFilledIcon).withConfig({
5240
5240
  displayName: "StyledWarningIcon",
5241
5241
  componentId: "sc-6mcfu2-2"
5242
- })(({ theme }) => ({ color: theme.sanity.color.spot.red }));
5243
- var TableRowAsset_default = memo((props) => {
5242
+ })(({ theme }) => ({ color: theme.sanity.color.spot.red })), TableRowAsset = (props) => {
5244
5243
  let $ = c(145), { id, selected } = props, scheme = useColorSchemeValue(), shiftPressed = useKeyPress("shift"), [referenceCountVisible, setReferenceCountVisible] = useState(!1), refCountVisibleTimeout = useRef(null), dispatch = useDispatch(), lastPicked = useTypedSelector(_temp$6), t0;
5245
5244
  $[0] === id ? t0 = $[1] : (t0 = (state_0) => selectAssetById(state_0, id), $[0] = id, $[1] = t0);
5246
5245
  let item = useTypedSelector(t0), mediaIndex = useMediaIndex(), asset = item?.asset, error = item?.error, isOpaque = item?.asset?.metadata?.isOpaque, picked = item?.picked, updating = item?.updating, { onSelect } = useAssetSourceActions(), t1;
@@ -5587,7 +5586,8 @@ var TableRowAsset_default = memo((props) => {
5587
5586
  t65
5588
5587
  ]
5589
5588
  }), $[130] = item.updating, $[131] = scheme, $[132] = selected, $[133] = t13, $[134] = t22, $[135] = t28, $[136] = t36, $[137] = t41, $[138] = t47, $[139] = t5, $[140] = t55, $[141] = t60, $[142] = t65, $[143] = t9, $[144] = t66) : t66 = $[144], t66;
5590
- });
5589
+ };
5590
+ var TableRowAsset_default = memo(TableRowAsset);
5591
5591
  function _temp$6(state) {
5592
5592
  return state.assets.lastPicked;
5593
5593
  }