sanity-plugin-media 2.4.2-canary.0 → 2.4.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/dist/index.js CHANGED
@@ -555,22 +555,18 @@ const useKeyPress = (hotkey, onPress) => {
555
555
  const { tagId } = action.payload;
556
556
  delete state.byIds[tagId].error;
557
557
  }).addMatcher(
558
- (action) => [
559
- ASSETS_ACTIONS.tagsAddComplete.type,
560
- ASSETS_ACTIONS.tagsAddError.type,
561
- ASSETS_ACTIONS.tagsRemoveComplete.type,
562
- ASSETS_ACTIONS.tagsRemoveError.type
563
- ].includes(action.type),
558
+ toolkit.isAnyOf(
559
+ ASSETS_ACTIONS.tagsAddComplete,
560
+ ASSETS_ACTIONS.tagsAddError,
561
+ ASSETS_ACTIONS.tagsRemoveComplete,
562
+ ASSETS_ACTIONS.tagsRemoveError
563
+ ),
564
564
  (state, action) => {
565
565
  const { tag } = action.payload;
566
566
  state.byIds[tag._id].updating = !1;
567
567
  }
568
568
  ).addMatcher(
569
- (action) => [
570
- ASSETS_ACTIONS.tagsAddRequest.type,
571
- //
572
- ASSETS_ACTIONS.tagsRemoveRequest.type
573
- ].includes(action.type),
569
+ toolkit.isAnyOf(ASSETS_ACTIONS.tagsAddRequest, ASSETS_ACTIONS.tagsRemoveRequest),
574
570
  (state, action) => {
575
571
  const { tag } = action.payload;
576
572
  state.byIds[tag._id].updating = !0;
@@ -895,7 +891,7 @@ const useKeyPress = (hotkey, onPress) => {
895
891
  return tagItem?.tag && acc.push(tagItem), acc;
896
892
  }, []);
897
893
  return tags && tags?.length > 0 ? getTagSelectOptions(tags) : null;
898
- }, tagsActions = tagsSlice.actions;
894
+ }, tagsActions = { ...tagsSlice.actions };
899
895
  var tagsReducer = tagsSlice.reducer;
900
896
  const initialState$6 = {
901
897
  facets: [],
@@ -956,7 +952,7 @@ const initialState$6 = {
956
952
  value: tagItem?.tag?._id
957
953
  }
958
954
  })
959
- ) : rxjs.empty();
955
+ ) : rxjs.EMPTY;
960
956
  })
961
957
  ), selectIsSearchFacetTag = toolkit.createSelector(
962
958
  [
@@ -966,7 +962,7 @@ const initialState$6 = {
966
962
  (searchFacets, tagId) => searchFacets.some(
967
963
  (facet) => facet.name === "tag" && facet.type === "searchable" && (facet.operatorType === "references" || facet.operatorType === "doesNotReference") && facet.value?.value === tagId
968
964
  )
969
- ), searchActions = searchSlice.actions;
965
+ ), searchActions = { ...searchSlice.actions };
970
966
  var searchReducer = searchSlice.reducer;
971
967
  const UPLOADS_ACTIONS = {
972
968
  uploadComplete: toolkit.createAction(
@@ -1284,7 +1280,7 @@ const UPLOADS_ACTIONS = {
1284
1280
  const nextPageIndex = Math.floor(state.assets.allIds.length / state.assets.pageSize);
1285
1281
  return rxjs.of(assetsActions.loadPageIndex({ pageIndex: nextPageIndex }));
1286
1282
  }
1287
- return rxjs.empty();
1283
+ return rxjs.EMPTY;
1288
1284
  })
1289
1285
  ), filterAssetWithoutTag = (tag) => (asset) => (asset?.asset?.opt?.media?.tags?.findIndex((t) => t._ref === tag?._id) ?? -1) < 0, patchOperationTagAppend = ({ tag }) => (patch) => patch.setIfMissing({ opt: {} }).setIfMissing({ "opt.media": {} }).setIfMissing({ "opt.media.tags": [] }).append("opt.media.tags", [{ _key: nanoid.nanoid(), _ref: tag?._id, _type: "reference", _weak: !0 }]), patchOperationTagUnset = ({ asset, tag }) => (patch) => patch.ifRevisionId(asset?.asset?._rev).unset([`opt.media.tags[_ref == "${tag._id}"]`]), assetsOrderSetEpic = (action$) => action$.pipe(
1290
1286
  operators$1.filter(assetsActions.orderSet.match),
@@ -1467,7 +1463,7 @@ const UPLOADS_ACTIONS = {
1467
1463
  ), selectAssetsPickedLength = toolkit.createSelector(
1468
1464
  [selectAssetsPicked],
1469
1465
  (assetsPicked) => assetsPicked.length
1470
- ), assetsActions = assetsSlice.actions;
1466
+ ), assetsActions = { ...assetsSlice.actions };
1471
1467
  var assetsReducer = assetsSlice.reducer;
1472
1468
  const customScrollbar = styledComponents.css`
1473
1469
  ::-webkit-scrollbar {
@@ -1636,16 +1632,18 @@ const customScrollbar = styledComponents.css`
1636
1632
  tagsActions.deleteComplete.type,
1637
1633
  tagsActions.updateComplete.type
1638
1634
  ),
1639
- operators$1.filter((action) => !!action?.payload?.closeDialogId),
1635
+ operators$1.filter(
1636
+ (action) => !!action?.payload?.closeDialogId
1637
+ ),
1640
1638
  operators$1.mergeMap((action) => {
1641
1639
  const dialogId = action?.payload?.closeDialogId;
1642
- return dialogId ? rxjs.of(dialogSlice.actions.remove({ id: dialogId })) : rxjs.empty();
1640
+ return dialogId ? rxjs.of(dialogSlice.actions.remove({ id: dialogId })) : rxjs.EMPTY;
1643
1641
  })
1644
1642
  ), dialogTagCreateEpic = (action$) => action$.pipe(
1645
1643
  operators$1.filter(tagsActions.createComplete.match),
1646
1644
  operators$1.mergeMap((action) => {
1647
1645
  const { assetId, tag } = action?.payload;
1648
- return assetId ? rxjs.of(dialogSlice.actions.inlineTagCreate({ tag, assetId })) : tag._id ? rxjs.of(dialogSlice.actions.remove({ id: "tagCreate" })) : rxjs.empty();
1646
+ return assetId ? rxjs.of(dialogSlice.actions.inlineTagCreate({ tag, assetId })) : tag._id ? rxjs.of(dialogSlice.actions.remove({ id: "tagCreate" })) : rxjs.EMPTY;
1649
1647
  })
1650
1648
  ), dialogTagDeleteEpic = (action$) => action$.pipe(
1651
1649
  operators$1.filter(tagsActions.listenerDeleteQueueComplete.match),
@@ -1653,7 +1651,7 @@ const customScrollbar = styledComponents.css`
1653
1651
  const { tagIds } = action?.payload;
1654
1652
  return rxjs.of(dialogSlice.actions.inlineTagRemove({ tagIds }));
1655
1653
  })
1656
- ), dialogActions = dialogSlice.actions;
1654
+ ), dialogActions = { ...dialogSlice.actions };
1657
1655
  var dialogReducer = dialogSlice.reducer;
1658
1656
  const ButtonViewGroup = () => {
1659
1657
  const dispatch = reactRedux.useDispatch(), view = useTypedSelector((state) => state.assets.view);
@@ -2113,22 +2111,16 @@ const Container$1 = styledComponents.styled(ui.Box)(({ scheme, theme }) => style
2113
2111
  margin: 0,
2114
2112
  padding: 0
2115
2113
  })
2116
- }), ClearIndicator = (props) => (
2117
- // @ts-expect-error - fix typings later
2118
- /* @__PURE__ */ jsxRuntime.jsx(Select.components.ClearIndicator, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
2119
- ui.Box,
2120
- {
2121
- paddingRight: 1,
2122
- style: {
2123
- transform: "scale(0.85)"
2124
- },
2125
- children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 0, children: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseIcon, {}) })
2126
- }
2127
- ) })
2128
- ), Menu$1 = (props) => (
2129
- // @ts-expect-error - fix typings later
2130
- /* @__PURE__ */ jsxRuntime.jsx(Select.components.Menu, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 1, shadow: 2, children: props.children }) })
2131
- ), MenuList$1 = (props) => {
2114
+ }), ClearIndicator = (props) => /* @__PURE__ */ jsxRuntime.jsx(Select.components.ClearIndicator, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
2115
+ ui.Box,
2116
+ {
2117
+ paddingRight: 1,
2118
+ style: {
2119
+ transform: "scale(0.85)"
2120
+ },
2121
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 0, children: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseIcon, {}) })
2122
+ }
2123
+ ) }), Menu$1 = (props) => /* @__PURE__ */ jsxRuntime.jsx(Select.components.Menu, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 1, shadow: 2, children: props.children }) }), MenuList$1 = (props) => {
2132
2124
  const { children } = props, MAX_ROWS = 5, OPTION_HEIGHT = 33;
2133
2125
  if (Array.isArray(children)) {
2134
2126
  const height = children.length > MAX_ROWS ? OPTION_HEIGHT * MAX_ROWS : children.length * OPTION_HEIGHT;
@@ -2146,10 +2138,7 @@ const Container$1 = styledComponents.styled(ui.Box)(({ scheme, theme }) => style
2146
2138
  );
2147
2139
  }
2148
2140
  return /* @__PURE__ */ jsxRuntime.jsx(Select.components.MenuList, { ...props, children });
2149
- }, NoOptionsMessage = (props) => /* @__PURE__ */ jsxRuntime.jsx(Select.components.NoOptionsMessage, { ...props, children: props.children }), Option$1 = (props) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Select.components.Option, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingY: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, style: { color: "inherit" }, textOverflow: "ellipsis", children: props.children }) }) }) }), SingleValue = (props) => (
2150
- // @ts-expect-error - fix typings later
2151
- /* @__PURE__ */ jsxRuntime.jsx(Select.components.SingleValue, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, textOverflow: "ellipsis", children: props.children }) })
2152
- ), reactSelectComponents$1 = {
2141
+ }, NoOptionsMessage = (props) => /* @__PURE__ */ jsxRuntime.jsx(Select.components.NoOptionsMessage, { ...props, children: props.children }), Option$1 = (props) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Select.components.Option, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingY: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, style: { color: "inherit" }, textOverflow: "ellipsis", children: props.children }) }) }) }), SingleValue = (props) => /* @__PURE__ */ jsxRuntime.jsx(Select.components.SingleValue, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, textOverflow: "ellipsis", children: props.children }) }), reactSelectComponents$1 = {
2153
2142
  ClearIndicator,
2154
2143
  DropdownIndicator: null,
2155
2144
  IndicatorSeparator: null,
@@ -2483,7 +2472,7 @@ const Container$1 = styledComponents.styled(ui.Box)(({ scheme, theme }) => style
2483
2472
  state.enabled = !state.enabled;
2484
2473
  }
2485
2474
  }
2486
- }), debugActions = debugSlice.actions;
2475
+ }), debugActions = { ...debugSlice.actions };
2487
2476
  var debugReducer = debugSlice.reducer;
2488
2477
  const DebugControls = () => {
2489
2478
  const dispatch = reactRedux.useDispatch(), badConnection = useTypedSelector((state) => state.debug.badConnection), debugEnabled = useTypedSelector((state) => state.debug.enabled), handleChange = (e) => {
@@ -2560,7 +2549,7 @@ const imageDprUrl = (asset, options) => {
2560
2549
  const val = formData[key];
2561
2550
  return typeof val == "object" && val !== null && val.constructor !== Array ? acc[key] = sanitizeFormData(val) : val === "" || typeof val > "u" || val?.length === 0 ? acc[key] = null : typeof val == "string" && val ? acc[key] = formData[key].trim() : acc[key] = formData[key], acc;
2562
2551
  }, {}), isFileAsset = (asset) => asset._type === "sanity.fileAsset", isImageAsset = (asset) => asset._type === "sanity.imageAsset", getAssetResolution = (asset) => `${asset.metadata.dimensions.width}x${asset.metadata.dimensions.height}px`, ButtonAssetCopy = ({ disabled, url }) => {
2563
- const popoverProps = usePortalPopoverProps(), refPopoverTimeout = react.useRef(null), [popoverVisible, setPopoverVisible] = react.useState(!1), handleClick = () => {
2552
+ const popoverProps = usePortalPopoverProps(), refPopoverTimeout = react.useRef(), [popoverVisible, setPopoverVisible] = react.useState(!1), handleClick = () => {
2564
2553
  refPopoverTimeout.current && clearTimeout(refPopoverTimeout.current), setPopoverVisible(!0), copy__default.default(url), refPopoverTimeout.current = setTimeout(() => {
2565
2554
  setPopoverVisible(!1);
2566
2555
  }, 1250);
@@ -2796,13 +2785,7 @@ const imageDprUrl = (asset, options) => {
2796
2785
  margin: 0,
2797
2786
  padding: 0
2798
2787
  })
2799
- }), DropdownIndicator = (props) => (
2800
- // @ts-expect-error - fix typings later
2801
- /* @__PURE__ */ jsxRuntime.jsx(Select.components.DropdownIndicator, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingX: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDownIcon, {}) }) }) })
2802
- ), Menu = (props) => (
2803
- // @ts-expect-error - fix typings later
2804
- /* @__PURE__ */ jsxRuntime.jsx(Select.components.Menu, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 1, shadow: 2, children: props.children }) })
2805
- ), MenuList = (props) => {
2788
+ }), DropdownIndicator = (props) => /* @__PURE__ */ jsxRuntime.jsx(Select.components.DropdownIndicator, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingX: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDownIcon, {}) }) }) }), Menu = (props) => /* @__PURE__ */ jsxRuntime.jsx(Select.components.Menu, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 1, shadow: 2, children: props.children }) }), MenuList = (props) => {
2806
2789
  const { children } = props, MAX_ROWS = 5, OPTION_HEIGHT = 37;
2807
2790
  if (Array.isArray(children)) {
2808
2791
  const height = children.length > MAX_ROWS ? OPTION_HEIGHT * MAX_ROWS : children.length * OPTION_HEIGHT;
@@ -2820,10 +2803,7 @@ const imageDprUrl = (asset, options) => {
2820
2803
  );
2821
2804
  }
2822
2805
  return /* @__PURE__ */ jsxRuntime.jsx(Select.components.MenuList, { ...props, children });
2823
- }, MultiValueLabel = (props) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 2, paddingRight: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "medium", children: /* @__PURE__ */ jsxRuntime.jsx(Select.components.MultiValueLabel, { ...props }) }) }), MultiValueRemove = (props) => (
2824
- // @ts-expect-error - fix typings later
2825
- /* @__PURE__ */ jsxRuntime.jsx(Select.components.MultiValueRemove, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseIcon, { color: "#1f2123" }) })
2826
- ), Option = (props) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingX: 1, paddingY: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Select.components.Option, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", children: [
2806
+ }, MultiValueLabel = (props) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 2, paddingRight: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "medium", children: /* @__PURE__ */ jsxRuntime.jsx(Select.components.MultiValueLabel, { ...props }) }) }), MultiValueRemove = (props) => /* @__PURE__ */ jsxRuntime.jsx(Select.components.MultiValueRemove, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseIcon, { color: "#1f2123" }) }), Option = (props) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingX: 1, paddingY: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Select.components.Option, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", children: [
2827
2807
  props.data.__isNew__ && /* @__PURE__ */ jsxRuntime.jsx(icons.AddIcon, { style: { marginRight: "3px" } }),
2828
2808
  props.children
2829
2809
  ] }) }) }), reactSelectComponents = {
@@ -4223,7 +4203,7 @@ toolkit.createSelector(
4223
4203
  [selectUploadsByIds, selectUploadsAllIds],
4224
4204
  (byIds, allIds) => allIds.map((id) => byIds[id])
4225
4205
  );
4226
- const uploadsActions = uploadsSlice.actions;
4206
+ const uploadsActions = { ...uploadsSlice.actions };
4227
4207
  var uploadsReducer = uploadsSlice.reducer;
4228
4208
  const CardWrapper = styledComponents.styled(ui.Flex)`
4229
4209
  box-sizing: border-box;
@@ -4351,6 +4331,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
4351
4331
  computeItemKey: (index) => items[index]?.id,
4352
4332
  components: {
4353
4333
  Item: ItemContainer,
4334
+ // @ts-expect-error - fix typings later
4354
4335
  List: ListContainer
4355
4336
  },
4356
4337
  endReached: onLoadMore,
@@ -4498,7 +4479,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
4498
4479
  `), StyledWarningIcon = styledComponents.styled(icons.WarningFilledIcon)(({ theme }) => ({
4499
4480
  color: theme.sanity.color.spot.red
4500
4481
  })), TableRowAsset = (props) => {
4501
- const { id, selected } = props, scheme = sanity.useColorSchemeValue(), shiftPressed = useKeyPress("shift"), [referenceCountVisible, setReferenceCountVisible] = react.useState(!1), refCountVisibleTimeout = react.useRef(null), dispatch = reactRedux.useDispatch(), lastPicked = useTypedSelector((state) => state.assets.lastPicked), item = useTypedSelector((state) => selectAssetById(state, id)), mediaIndex = ui.useMediaIndex(), asset = item?.asset, error = item?.error, isOpaque = item?.asset?.metadata?.isOpaque, picked = item?.picked, updating = item?.updating, { onSelect } = useAssetSourceActions(), handleContextActionClick = react.useCallback(
4482
+ const { id, selected } = props, scheme = sanity.useColorSchemeValue(), shiftPressed = useKeyPress("shift"), [referenceCountVisible, setReferenceCountVisible] = react.useState(!1), refCountVisibleTimeout = react.useRef(), dispatch = reactRedux.useDispatch(), lastPicked = useTypedSelector((state) => state.assets.lastPicked), item = useTypedSelector((state) => selectAssetById(state, id)), mediaIndex = ui.useMediaIndex(), asset = item?.asset, error = item?.error, isOpaque = item?.asset?.metadata?.isOpaque, picked = item?.picked, updating = item?.updating, { onSelect } = useAssetSourceActions(), handleContextActionClick = react.useCallback(
4502
4483
  (e) => {
4503
4484
  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 })));
4504
4485
  },
@@ -5031,7 +5012,7 @@ const initialState = {
5031
5012
  ), notificationsTagUpdateCompleteEpic = (action$) => action$.pipe(
5032
5013
  operators$1.filter(tagsActions.updateComplete.match),
5033
5014
  operators$1.mergeMap(() => rxjs.of(notificationsSlice.actions.add({ status: "info", title: "Tag updated" })))
5034
- ), notificationsActions = notificationsSlice.actions;
5015
+ ), notificationsActions = { ...notificationsSlice.actions };
5035
5016
  var notificationsReducer = notificationsSlice.reducer;
5036
5017
  const rootEpic = reduxObservable.combineEpics(
5037
5018
  assetsDeleteEpic,
@@ -5123,10 +5104,29 @@ class ReduxProvider extends react.Component {
5123
5104
  ...initialState$5,
5124
5105
  assetTypes: props?.assetType ? [props.assetType] : ["file", "image"]
5125
5106
  },
5107
+ debug: {
5108
+ badConnection: !1,
5109
+ enabled: !1
5110
+ },
5111
+ dialog: { items: [] },
5112
+ notifications: { items: [] },
5113
+ search: { facets: [], query: "" },
5126
5114
  selected: {
5127
5115
  assets: props.selectedAssets || [],
5128
5116
  document: props.document,
5129
5117
  documentAssetIds: props.document ? getDocumentAssetIds(props.document) : []
5118
+ },
5119
+ tags: {
5120
+ allIds: [],
5121
+ byIds: {},
5122
+ creating: !1,
5123
+ fetchCount: -1,
5124
+ fetching: !1,
5125
+ panelVisible: !0
5126
+ },
5127
+ uploads: {
5128
+ allIds: [],
5129
+ byIds: {}
5130
5130
  }
5131
5131
  }
5132
5132
  }), epicMiddleware.run(rootEpic);