sanity-plugin-media 4.0.0 → 4.1.1

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
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), icons = require("@sanity/icons"), ui = require("@sanity/ui"), react = require("react"), groq = require("groq"), reactRedux = require("react-redux"), toolkit = require("@reduxjs/toolkit"), nanoid = require("nanoid"), reduxObservable = require("redux-observable"), rxjs = require("rxjs"), operators$1 = require("rxjs/operators"), uuid = require("@sanity/uuid"), styledComponents = require("styled-components"), pluralize = require("pluralize"), reactNprogress = require("@tanem/react-nprogress"), color = require("@sanity/color"), Select = require("react-select"), reactVirtuoso = require("react-virtuoso"), zod = require("@hookform/resolvers/zod"), reactHookForm = require("react-hook-form"), z = require("zod"), format = require("date-fns/format"), filesize = require("filesize"), copy = require("copy-to-clipboard"), router = require("sanity/router"), reactFileIcon = require("react-file-icon"), CreatableSelect = require("react-select/creatable"), formatRelative = require("date-fns/formatRelative"), reactDropzone = require("react-dropzone");
3
+ var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), icons = require("@sanity/icons"), ui = require("@sanity/ui"), react = require("react"), groq = require("groq"), reactRedux = require("react-redux"), toolkit = require("@reduxjs/toolkit"), nanoid = require("nanoid"), reduxObservable = require("redux-observable"), rxjs = require("rxjs"), operators$1 = require("rxjs/operators"), uuid = require("@sanity/uuid"), styledComponents = require("styled-components"), pluralize = require("pluralize"), reactNprogress = require("@tanem/react-nprogress"), color = require("@sanity/color"), Select = require("react-select"), reactVirtuoso = require("react-virtuoso"), zod = require("@hookform/resolvers/zod"), reactHookForm = require("react-hook-form"), z = require("zod"), dateFns = require("date-fns"), filesize = require("filesize"), copy = require("copy-to-clipboard"), router = require("sanity/router"), reactFileIcon = require("react-file-icon"), CreatableSelect = require("react-select/creatable"), reactDropzone = require("react-dropzone");
4
4
  function _interopDefaultCompat(e) {
5
5
  return e && typeof e == "object" && "default" in e ? e : { default: e };
6
6
  }
@@ -19,7 +19,7 @@ function _interopNamespaceCompat(e) {
19
19
  }
20
20
  }), n.default = e, Object.freeze(n);
21
21
  }
22
- var groq__default = /* @__PURE__ */ _interopDefaultCompat(groq), pluralize__default = /* @__PURE__ */ _interopDefaultCompat(pluralize), Select__default = /* @__PURE__ */ _interopDefaultCompat(Select), z__namespace = /* @__PURE__ */ _interopNamespaceCompat(z), format__default = /* @__PURE__ */ _interopDefaultCompat(format), filesize__default = /* @__PURE__ */ _interopDefaultCompat(filesize), copy__default = /* @__PURE__ */ _interopDefaultCompat(copy), CreatableSelect__default = /* @__PURE__ */ _interopDefaultCompat(CreatableSelect), formatRelative__default = /* @__PURE__ */ _interopDefaultCompat(formatRelative);
22
+ var groq__default = /* @__PURE__ */ _interopDefaultCompat(groq), pluralize__default = /* @__PURE__ */ _interopDefaultCompat(pluralize), Select__default = /* @__PURE__ */ _interopDefaultCompat(Select), z__namespace = /* @__PURE__ */ _interopNamespaceCompat(z), filesize__default = /* @__PURE__ */ _interopDefaultCompat(filesize), copy__default = /* @__PURE__ */ _interopDefaultCompat(copy), CreatableSelect__default = /* @__PURE__ */ _interopDefaultCompat(CreatableSelect);
23
23
  function getDefaultExportFromCjs(x) {
24
24
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
25
25
  }
@@ -467,7 +467,10 @@ const useKeyPress = (hotkey, onPress) => {
467
467
  fn: (value, _field) => value ? `references('${value}')` : void 0,
468
468
  label: "includes"
469
469
  }
470
- }, ORDER_OPTIONS = [
470
+ }, SUPPORTED_ASSET_TYPES = [
471
+ "file",
472
+ "image"
473
+ ], ORDER_OPTIONS = [
471
474
  {
472
475
  direction: "desc",
473
476
  field: "_createdAt"
@@ -1250,7 +1253,9 @@ const UPLOADS_ACTIONS = {
1250
1253
  originalFilename,
1251
1254
  size,
1252
1255
  source {
1253
- name
1256
+ name,
1257
+ id,
1258
+ url,
1254
1259
  },
1255
1260
  title,
1256
1261
  url
@@ -2353,15 +2358,21 @@ const Container$1 = styledComponents.styled(ui.Box)(({ $scheme, theme }) => styl
2353
2358
  let creditLineExcludeSources;
2354
2359
  return options?.creditLine?.excludeSources && (creditLineExcludeSources = Array.isArray(options?.creditLine?.excludeSources) ? options.creditLine.excludeSources : [options?.creditLine?.excludeSources]), {
2355
2360
  dropzone: { maxSize: options?.maximumUploadSize },
2361
+ components: {
2362
+ details: options?.components?.details
2363
+ },
2356
2364
  creditLine: {
2357
2365
  enabled: options?.creditLine?.enabled || !1,
2358
2366
  excludeSources: creditLineExcludeSources
2359
- }
2367
+ },
2368
+ directUploads: options?.directUploads ?? !0
2360
2369
  };
2361
2370
  }, [
2362
2371
  options?.creditLine?.enabled,
2372
+ options?.components,
2363
2373
  options?.creditLine?.excludeSources,
2364
- options?.maximumUploadSize
2374
+ options?.maximumUploadSize,
2375
+ options?.directUploads
2365
2376
  ]);
2366
2377
  return /* @__PURE__ */ jsxRuntime.jsx(ToolOptionsContext.Provider, { value, children });
2367
2378
  }, useToolOptions = () => {
@@ -2760,7 +2771,7 @@ const imageDprUrl = (asset, options) => {
2760
2771
  Row,
2761
2772
  {
2762
2773
  label: "Original date",
2763
- value: format__default.default(new Date(exif.DateTimeOriginal), "PPp")
2774
+ value: dateFns.format(new Date(exif.DateTimeOriginal), "PPp")
2764
2775
  }
2765
2776
  )
2766
2777
  ] }) })
@@ -2820,7 +2831,51 @@ const imageDprUrl = (asset, options) => {
2820
2831
  }
2821
2832
  }
2822
2833
  ) : /* @__PURE__ */ jsxRuntime.jsx(FileIcon, { extension: asset.extension, width: "50%" });
2823
- }, { radius: themeRadius, space: themeSpace } = ui.studioTheme, reactSelectStyles = (scheme) => ({
2834
+ }, FormSubmitButton = (props) => {
2835
+ const { disabled, isValid, lastUpdated, onClick } = props;
2836
+ let content;
2837
+ return isValid ? lastUpdated ? content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2838
+ "Last updated",
2839
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
2840
+ " ",
2841
+ dateFns.format(new Date(lastUpdated), "PPp")
2842
+ ] }) : content = "No unpublished changes" : content = "There are validation errors that need to be fixed before this document can be published", /* @__PURE__ */ jsxRuntime.jsx(
2843
+ ui.Tooltip,
2844
+ {
2845
+ animate: !0,
2846
+ content: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, style: { maxWidth: "185px" }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: content }) }),
2847
+ disabled: "ontouchstart" in window,
2848
+ placement: "top",
2849
+ portal: !0,
2850
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
2851
+ ui.Button,
2852
+ {
2853
+ disabled,
2854
+ fontSize: 1,
2855
+ onClick,
2856
+ text: "Save and close",
2857
+ tone: "primary"
2858
+ }
2859
+ ) })
2860
+ }
2861
+ );
2862
+ }, Image$1 = styledComponents.styled.img`
2863
+ --checkerboard-color: ${(props) => props.$scheme ? getSchemeColor(props.$scheme, "bg2") : "inherit"};
2864
+
2865
+ display: block;
2866
+ width: 100%;
2867
+ height: 100%;
2868
+ object-fit: contain;
2869
+
2870
+ ${(props) => props.$showCheckerboard && styledComponents.css`
2871
+ background-image: linear-gradient(45deg, var(--checkerboard-color) 25%, transparent 25%),
2872
+ linear-gradient(-45deg, var(--checkerboard-color) 25%, transparent 25%),
2873
+ linear-gradient(45deg, transparent 75%, var(--checkerboard-color) 75%),
2874
+ linear-gradient(-45deg, transparent 75%, var(--checkerboard-color) 75%);
2875
+ background-size: 20px 20px;
2876
+ background-position: 0 0, 0 10px, 10px -10px, -10px 0;
2877
+ `}
2878
+ `, { radius: themeRadius, space: themeSpace } = ui.studioTheme, reactSelectStyles = (scheme) => ({
2824
2879
  control: (styles, { isFocused }) => {
2825
2880
  let boxShadow = "inset 0 0 0 1px var(--card-border-color)";
2826
2881
  return isFocused && (boxShadow = `inset 0 0 0 1px ${getSchemeColor(scheme, "inputEnabledBorder")},
@@ -3044,55 +3099,99 @@ const imageDprUrl = (asset, options) => {
3044
3099
  }
3045
3100
  )
3046
3101
  ] });
3047
- }), FormSubmitButton = (props) => {
3048
- const { disabled, isValid, lastUpdated, onClick } = props;
3049
- let content;
3050
- return isValid ? lastUpdated ? content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3051
- "Last updated",
3052
- /* @__PURE__ */ jsxRuntime.jsx("br", {}),
3053
- " ",
3054
- format__default.default(new Date(lastUpdated), "PPp")
3055
- ] }) : content = "No unpublished changes" : content = "There are validation errors that need to be fixed before this document can be published", /* @__PURE__ */ jsxRuntime.jsx(
3056
- ui.Tooltip,
3057
- {
3058
- animate: !0,
3059
- content: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, style: { maxWidth: "185px" }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: content }) }),
3060
- disabled: "ontouchstart" in window,
3061
- placement: "top",
3062
- portal: !0,
3063
- children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
3064
- ui.Button,
3065
- {
3066
- disabled,
3067
- fontSize: 1,
3068
- onClick,
3069
- text: "Save and close",
3070
- tone: "primary"
3071
- }
3072
- ) })
3073
- }
3074
- );
3075
- }, Image$1 = styledComponents.styled.img`
3076
- --checkerboard-color: ${(props) => props.$scheme ? getSchemeColor(props.$scheme, "bg2") : "inherit"};
3077
-
3078
- display: block;
3079
- width: 100%;
3080
- height: 100%;
3081
- object-fit: contain;
3082
-
3083
- ${(props) => props.$showCheckerboard && styledComponents.css`
3084
- background-image: linear-gradient(45deg, var(--checkerboard-color) 25%, transparent 25%),
3085
- linear-gradient(-45deg, var(--checkerboard-color) 25%, transparent 25%),
3086
- linear-gradient(45deg, transparent 75%, var(--checkerboard-color) 75%),
3087
- linear-gradient(-45deg, transparent 75%, var(--checkerboard-color) 75%);
3088
- background-size: 20px 20px;
3089
- background-position: 0 0, 0 10px, 10px -10px, -10px 0;
3090
- `}
3091
- `, DialogAssetEdit = (props) => {
3102
+ });
3103
+ function Details({
3104
+ formUpdating,
3105
+ handleCreateTag,
3106
+ control,
3107
+ errors,
3108
+ register,
3109
+ allTagOptions,
3110
+ assetTagOptions,
3111
+ currentAsset,
3112
+ creditLine
3113
+ }) {
3114
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
3115
+ /* @__PURE__ */ jsxRuntime.jsx(
3116
+ FormFieldInputTags,
3117
+ {
3118
+ control,
3119
+ disabled: formUpdating,
3120
+ error: errors?.opt?.media?.tags?.message,
3121
+ label: "Tags",
3122
+ name: "opt.media.tags",
3123
+ onCreateTag: handleCreateTag,
3124
+ options: allTagOptions,
3125
+ placeholder: "Select or create...",
3126
+ value: assetTagOptions
3127
+ }
3128
+ ),
3129
+ /* @__PURE__ */ jsxRuntime.jsx(
3130
+ FormFieldInputText,
3131
+ {
3132
+ ...register("originalFilename"),
3133
+ disabled: formUpdating,
3134
+ error: errors?.originalFilename?.message,
3135
+ label: "Filename",
3136
+ name: "originalFilename",
3137
+ value: currentAsset?.originalFilename
3138
+ }
3139
+ ),
3140
+ /* @__PURE__ */ jsxRuntime.jsx(
3141
+ FormFieldInputText,
3142
+ {
3143
+ ...register("title"),
3144
+ disabled: formUpdating,
3145
+ error: errors?.title?.message,
3146
+ label: "Title",
3147
+ name: "title",
3148
+ value: currentAsset?.title
3149
+ }
3150
+ ),
3151
+ /* @__PURE__ */ jsxRuntime.jsx(
3152
+ FormFieldInputText,
3153
+ {
3154
+ ...register("altText"),
3155
+ disabled: formUpdating,
3156
+ error: errors?.altText?.message,
3157
+ label: "Alt Text",
3158
+ name: "altText",
3159
+ value: currentAsset?.altText
3160
+ }
3161
+ ),
3162
+ /* @__PURE__ */ jsxRuntime.jsx(
3163
+ FormFieldInputTextarea,
3164
+ {
3165
+ ...register("description"),
3166
+ disabled: formUpdating,
3167
+ error: errors?.description?.message,
3168
+ label: "Description",
3169
+ name: "description",
3170
+ rows: 5,
3171
+ value: currentAsset?.description
3172
+ }
3173
+ ),
3174
+ creditLine?.enabled && /* @__PURE__ */ jsxRuntime.jsx(
3175
+ FormFieldInputText,
3176
+ {
3177
+ ...register("creditLine"),
3178
+ error: errors?.creditLine?.message,
3179
+ label: "Credit",
3180
+ name: "creditLine",
3181
+ value: currentAsset?.creditLine,
3182
+ disabled: formUpdating || creditLine?.excludeSources?.includes(currentAsset?.source?.name)
3183
+ }
3184
+ )
3185
+ ] });
3186
+ }
3187
+ function renderDefaultDetails(props) {
3188
+ return /* @__PURE__ */ jsxRuntime.jsx(Details, { ...props });
3189
+ }
3190
+ const DialogAssetEdit = (props) => {
3092
3191
  const {
3093
3192
  children,
3094
3193
  dialog: { assetId, id, lastCreatedTag, lastRemovedTagIds }
3095
- } = props, client = useVersionedClient(), scheme = sanity.useColorSchemeValue(), documentStore = sanity.useDocumentStore(), dispatch = reactRedux.useDispatch(), assetItem = useTypedSelector((state) => selectAssetById(state, String(assetId))), tags = useTypedSelector(selectTags), assetUpdatedPrev = react.useRef(void 0), [assetSnapshot, setAssetSnapshot] = react.useState(assetItem?.asset), [tabSection, setTabSection] = react.useState("details"), currentAsset = assetItem ? assetItem?.asset : assetSnapshot, allTagOptions = getTagSelectOptions(tags), assetTagOptions = useTypedSelector(selectTagSelectOptions(currentAsset)), { creditLine } = useToolOptions(), generateDefaultValues = react.useCallback(
3194
+ } = props, client = useVersionedClient(), scheme = sanity.useColorSchemeValue(), documentStore = sanity.useDocumentStore(), dispatch = reactRedux.useDispatch(), assetItem = useTypedSelector((state) => selectAssetById(state, String(assetId))), tags = useTypedSelector(selectTags), assetUpdatedPrev = react.useRef(void 0), [assetSnapshot, setAssetSnapshot] = react.useState(assetItem?.asset), [tabSection, setTabSection] = react.useState("details"), currentAsset = assetItem ? assetItem?.asset : assetSnapshot, allTagOptions = getTagSelectOptions(tags), assetTagOptions = useTypedSelector(selectTagSelectOptions(currentAsset)), { creditLine, components: { details: CustomDetails } = {} } = useToolOptions(), generateDefaultValues = react.useCallback(
3096
3195
  (asset) => ({
3097
3196
  altText: asset?.altText || "",
3098
3197
  creditLine: asset?.creditLine || "",
@@ -3207,7 +3306,21 @@ const imageDprUrl = (asset, options) => {
3207
3306
  }
3208
3307
  )
3209
3308
  ] }) });
3210
- return currentAsset ? /* @__PURE__ */ jsxRuntime.jsxs(
3309
+ if (!currentAsset)
3310
+ return null;
3311
+ const detailsProps = {
3312
+ control,
3313
+ errors,
3314
+ formUpdating,
3315
+ register,
3316
+ setValue,
3317
+ assetTagOptions,
3318
+ allTagOptions,
3319
+ handleCreateTag,
3320
+ currentAsset,
3321
+ creditLine
3322
+ };
3323
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3211
3324
  Dialog,
3212
3325
  {
3213
3326
  animate: !0,
@@ -3256,78 +3369,13 @@ const imageDprUrl = (asset, options) => {
3256
3369
  "aria-labelledby": "details",
3257
3370
  hidden: tabSection !== "details",
3258
3371
  id: "details-panel",
3259
- children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
3260
- /* @__PURE__ */ jsxRuntime.jsx(
3261
- FormFieldInputTags,
3262
- {
3263
- control,
3264
- disabled: formUpdating,
3265
- error: errors?.opt?.media?.tags?.message,
3266
- label: "Tags",
3267
- name: "opt.media.tags",
3268
- onCreateTag: handleCreateTag,
3269
- options: allTagOptions,
3270
- placeholder: "Select or create...",
3271
- value: assetTagOptions
3272
- }
3273
- ),
3274
- /* @__PURE__ */ jsxRuntime.jsx(
3275
- FormFieldInputText,
3276
- {
3277
- ...register("originalFilename"),
3278
- disabled: formUpdating,
3279
- error: errors?.originalFilename?.message,
3280
- label: "Filename",
3281
- name: "originalFilename",
3282
- value: currentAsset?.originalFilename
3283
- }
3284
- ),
3285
- /* @__PURE__ */ jsxRuntime.jsx(
3286
- FormFieldInputText,
3287
- {
3288
- ...register("title"),
3289
- disabled: formUpdating,
3290
- error: errors?.title?.message,
3291
- label: "Title",
3292
- name: "title",
3293
- value: currentAsset?.title
3294
- }
3295
- ),
3296
- /* @__PURE__ */ jsxRuntime.jsx(
3297
- FormFieldInputText,
3298
- {
3299
- ...register("altText"),
3300
- disabled: formUpdating,
3301
- error: errors?.altText?.message,
3302
- label: "Alt Text",
3303
- name: "altText",
3304
- value: currentAsset?.altText
3305
- }
3306
- ),
3307
- /* @__PURE__ */ jsxRuntime.jsx(
3308
- FormFieldInputTextarea,
3309
- {
3310
- ...register("description"),
3311
- disabled: formUpdating,
3312
- error: errors?.description?.message,
3313
- label: "Description",
3314
- name: "description",
3315
- rows: 5,
3316
- value: currentAsset?.description
3317
- }
3318
- ),
3319
- creditLine?.enabled && /* @__PURE__ */ jsxRuntime.jsx(
3320
- FormFieldInputText,
3321
- {
3322
- ...register("creditLine"),
3323
- error: errors?.creditLine?.message,
3324
- label: "Credit",
3325
- name: "creditLine",
3326
- value: currentAsset?.creditLine,
3327
- disabled: formUpdating || creditLine?.excludeSources?.includes(currentAsset?.source?.name)
3328
- }
3329
- )
3330
- ] })
3372
+ children: CustomDetails ? /* @__PURE__ */ jsxRuntime.jsx(
3373
+ CustomDetails,
3374
+ {
3375
+ ...detailsProps,
3376
+ renderDefaultDetails
3377
+ }
3378
+ ) : /* @__PURE__ */ jsxRuntime.jsx(Details, { ...detailsProps })
3331
3379
  }
3332
3380
  ),
3333
3381
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3367,7 +3415,7 @@ const imageDprUrl = (asset, options) => {
3367
3415
  children
3368
3416
  ]
3369
3417
  }
3370
- ) : null;
3418
+ );
3371
3419
  }, DialogConfirm = (props) => {
3372
3420
  const { children, dialog } = props, dispatch = reactRedux.useDispatch(), handleClose = () => {
3373
3421
  dispatch(dialogActions.remove({ id: dialog?.id }));
@@ -3856,7 +3904,7 @@ const imageDprUrl = (asset, options) => {
3856
3904
  throw new Error("useDropzoneActions must be used within an DropzoneDispatchProvider");
3857
3905
  return context;
3858
3906
  }, Header = (props) => {
3859
- const { onClose } = props, { open } = useDropzoneActions(), { onSelect } = useAssetSourceActions(), assetTypes = useTypedSelector((state) => state.assets.assetTypes), selectedDocument = useTypedSelector((state) => state.selected.document);
3907
+ const { onClose } = props, { open } = useDropzoneActions(), { onSelect } = useAssetSourceActions(), assetTypes = useTypedSelector((state) => state.assets.assetTypes), selectedDocument = useTypedSelector((state) => state.selected.document), { directUploads } = useToolOptions();
3860
3908
  return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingY: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "space-between", children: [
3861
3909
  /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, marginX: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Inline, { style: { whiteSpace: "nowrap" }, children: [
3862
3910
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { textOverflow: "ellipsis", weight: "semibold", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: onSelect ? `Insert ${assetTypes.join(" or ")}` : "Browse Assets" }) }),
@@ -3866,15 +3914,14 @@ const imageDprUrl = (asset, options) => {
3866
3914
  ] }) })
3867
3915
  ] }) }),
3868
3916
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { marginX: 2, children: [
3869
- /* @__PURE__ */ jsxRuntime.jsx(
3917
+ directUploads && /* @__PURE__ */ jsxRuntime.jsx(
3870
3918
  ui.Button,
3871
3919
  {
3872
3920
  fontSize: 1,
3873
3921
  icon: icons.UploadIcon,
3874
3922
  mode: "bleed",
3875
3923
  onClick: open,
3876
- text: `Upload ${assetTypes.length === 1 ? pluralize__default.default(assetTypes[0]) : "assets"}`,
3877
- tone: "primary"
3924
+ text: `Upload ${assetTypes.length === 1 ? pluralize__default.default(assetTypes[0]) : "assets"}`
3878
3925
  }
3879
3926
  ),
3880
3927
  onClose && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { flexShrink: 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -3965,7 +4012,7 @@ const imageDprUrl = (asset, options) => {
3965
4012
  `
3966
4013
  ), StyledWarningOutlineIcon = styledComponents.styled(icons.WarningFilledIcon)(({ theme }) => ({
3967
4014
  color: theme.sanity.color.spot.red
3968
- })), CardAsset = (props) => {
4015
+ })), CardAsset$1 = (props) => {
3969
4016
  const { id, selected } = props, scheme = sanity.useColorSchemeValue(), shiftPressed = useKeyPress("shift"), dispatch = reactRedux.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();
3970
4017
  if (!asset)
3971
4018
  return null;
@@ -4095,7 +4142,7 @@ const imageDprUrl = (asset, options) => {
4095
4142
  )
4096
4143
  ] }) });
4097
4144
  };
4098
- var CardAsset$1 = react.memo(CardAsset);
4145
+ var CardAsset = react.memo(CardAsset$1);
4099
4146
  const PREVIEW_WIDTH = 180, createBlob = (img) => new Promise((resolve) => {
4100
4147
  const imageAspect = img.width / img.height, canvas = document.createElement("canvas");
4101
4148
  canvas.width = PREVIEW_WIDTH, canvas.height = Math.max(PREVIEW_WIDTH / imageAspect, 1);
@@ -4452,7 +4499,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
4452
4499
  }
4453
4500
  ) });
4454
4501
  }, CARD_HEIGHT = 220, CARD_WIDTH = 240, VirtualCell = react.memo(
4455
- ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsxRuntime.jsx(CardAsset$1, { id: item.id, selected }) : item?.type === "upload" ? /* @__PURE__ */ jsxRuntime.jsx(CardUpload, { id: item.id }) : null
4502
+ ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsxRuntime.jsx(CardAsset, { id: item.id, selected }) : item?.type === "upload" ? /* @__PURE__ */ jsxRuntime.jsx(CardUpload, { id: item.id }) : null
4456
4503
  ), StyledItemContainer = styledComponents.styled.div`
4457
4504
  height: ${CARD_HEIGHT}px;
4458
4505
  width: ${CARD_WIDTH}px;
@@ -4617,7 +4664,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
4617
4664
  `
4618
4665
  ), StyledWarningIcon = styledComponents.styled(icons.WarningFilledIcon)(({ theme }) => ({
4619
4666
  color: theme.sanity.color.spot.red
4620
- })), TableRowAsset = (props) => {
4667
+ })), TableRowAsset$1 = (props) => {
4621
4668
  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(
4622
4669
  (e) => {
4623
4670
  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 })));
@@ -4798,7 +4845,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
4798
4845
  gridRow: mediaIndex < 3 ? 4 : "auto",
4799
4846
  opacity: opacityCell
4800
4847
  },
4801
- children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, style: { lineHeight: "2em" }, textOverflow: "ellipsis", children: formatRelative__default.default(new Date(asset._updatedAt), /* @__PURE__ */ new Date()) })
4848
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, style: { lineHeight: "2em" }, textOverflow: "ellipsis", children: dateFns.formatRelative(new Date(asset._updatedAt), /* @__PURE__ */ new Date()) })
4802
4849
  }
4803
4850
  ),
4804
4851
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -4843,7 +4890,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
4843
4890
  }
4844
4891
  ) : null;
4845
4892
  };
4846
- var TableRowAsset$1 = react.memo(TableRowAsset);
4893
+ var TableRowAsset = react.memo(TableRowAsset$1);
4847
4894
  const TableRowUpload = (props) => {
4848
4895
  const { id } = props, scheme = sanity.useColorSchemeValue(), dispatch = reactRedux.useDispatch(), item = useTypedSelector((state) => selectUploadById(state, id)), mediaIndex = ui.useMediaIndex();
4849
4896
  if (!item)
@@ -4957,7 +5004,7 @@ const TableRowUpload = (props) => {
4957
5004
  }
4958
5005
  );
4959
5006
  }, VirtualRow = react.memo(
4960
- ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx(TableRowAsset$1, { id: item.id, selected }) }) : item?.type === "upload" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx(TableRowUpload, { id: item.id }) }) : null
5007
+ ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx(TableRowAsset, { id: item.id, selected }) }) : item?.type === "upload" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx(TableRowUpload, { id: item.id }) }) : null
4961
5008
  ), AssetTableVirtualized = (props) => {
4962
5009
  const { items, onLoadMore } = props, selectedAssets = useTypedSelector((state) => state.selected.assets), selectedIds = selectedAssets && selectedAssets.map((asset) => asset._id) || [], totalCount = items?.length;
4963
5010
  return totalCount === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(
@@ -5220,6 +5267,9 @@ const rootEpic = reduxObservable.combineEpics(
5220
5267
  const assetIds = getAssetIds(document2);
5221
5268
  return [...new Set(assetIds.sort())];
5222
5269
  };
5270
+ function isSupportedAssetType(assetType) {
5271
+ return assetType ? SUPPORTED_ASSET_TYPES.includes(assetType) : !1;
5272
+ }
5223
5273
  class ReduxProvider extends react.Component {
5224
5274
  store;
5225
5275
  constructor(props) {
@@ -5250,7 +5300,7 @@ class ReduxProvider extends react.Component {
5250
5300
  preloadedState: {
5251
5301
  assets: {
5252
5302
  ...initialState$5,
5253
- assetTypes: props?.assetType ? [props.assetType] : ["file", "image"]
5303
+ assetTypes: isSupportedAssetType(props?.assetType) ? [props.assetType] : ["file", "image"]
5254
5304
  },
5255
5305
  debug: {
5256
5306
  badConnection: !1,
@@ -5342,7 +5392,8 @@ async function filterFiles(fileList) {
5342
5392
  }
5343
5393
  const UploadDropzone = (props) => {
5344
5394
  const { children } = props, {
5345
- dropzone: { maxSize }
5395
+ dropzone: { maxSize },
5396
+ directUploads
5346
5397
  } = useToolOptions(), { onSelect } = useAssetSourceActions(), dispatch = reactRedux.useDispatch(), assetTypes = useTypedSelector((state) => state.assets.assetTypes), isImageAssetType = assetTypes.length === 1 && assetTypes[0] === "image", handleDrop = async (acceptedFiles) => {
5347
5398
  acceptedFiles.forEach(
5348
5399
  (file) => dispatch(
@@ -5383,7 +5434,8 @@ const UploadDropzone = (props) => {
5383
5434
  noDrag: !!onSelect,
5384
5435
  onDrop: handleDrop,
5385
5436
  maxSize,
5386
- onDropRejected: handleDropRejected
5437
+ onDropRejected: handleDropRejected,
5438
+ disabled: !directUploads
5387
5439
  });
5388
5440
  return /* @__PURE__ */ jsxRuntime.jsx(DropzoneDispatchProvider, { open, children: /* @__PURE__ */ jsxRuntime.jsxs(UploadContainer, { ...getRootProps(), children: [
5389
5441
  /* @__PURE__ */ jsxRuntime.jsx("input", { ...getInputProps() }),