sanity-plugin-media 4.3.0 → 4.3.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/LICENSE +4 -4
- package/README.md +12 -12
- package/dist/index.d.mts +263 -195
- package/dist/index.d.ts +263 -195
- package/dist/index.js +83 -203
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -203
- package/dist/index.mjs.map +1 -1
- package/package.json +42 -64
- package/src/__tests__/fixtures/createEpicTestStore.ts +5 -4
- package/src/__tests__/fixtures/mockSanityClient.ts +8 -8
- package/src/__tests__/fixtures/renderWithProviders.tsx +8 -7
- package/src/__tests__/fixtures/rootState.ts +4 -4
- package/src/components/AssetGridVirtualized/index.tsx +8 -7
- package/src/components/AssetMetadata/index.tsx +6 -5
- package/src/components/AssetTableVirtualized/index.tsx +7 -6
- package/src/components/AutoTagInputWrapper/index.tsx +9 -4
- package/src/components/Browser/Browser.test.tsx +9 -8
- package/src/components/Browser/index.tsx +2 -1
- package/src/components/Browser/useBrowserInit.ts +9 -9
- package/src/components/ButtonAssetCopy/index.tsx +1 -0
- package/src/components/ButtonViewGroup/index.tsx +4 -3
- package/src/components/CardAsset/CardAsset.test.tsx +53 -52
- package/src/components/CardAsset/index.tsx +52 -49
- package/src/components/CardUpload/index.tsx +7 -6
- package/src/components/Controls/index.tsx +7 -6
- package/src/components/DebugControls/index.tsx +5 -4
- package/src/components/DialogAssetEdit/Details.tsx +3 -2
- package/src/components/DialogAssetEdit/DialogAssetEdit.test.tsx +28 -27
- package/src/components/DialogAssetEdit/index.tsx +37 -37
- package/src/components/DialogConfirm/index.tsx +2 -1
- package/src/components/DialogSearchFacets/index.tsx +3 -2
- package/src/components/DialogTagCreate/DialogTagCreate.test.tsx +16 -15
- package/src/components/DialogTagCreate/index.tsx +11 -10
- package/src/components/DialogTagEdit/DialogTagEdit.test.tsx +28 -27
- package/src/components/DialogTagEdit/index.tsx +17 -16
- package/src/components/DialogTags/index.tsx +4 -3
- package/src/components/Dialogs/index.tsx +2 -3
- package/src/components/DocumentList/index.tsx +2 -3
- package/src/components/FileAssetPreview/index.tsx +2 -2
- package/src/components/FormBuilderTool/FormBuilderTool.test.tsx +12 -11
- package/src/components/FormBuilderTool/index.tsx +2 -1
- package/src/components/FormFieldInputLabel/index.tsx +1 -2
- package/src/components/FormFieldInputTags/index.tsx +4 -3
- package/src/components/FormSubmitButton/index.tsx +1 -1
- package/src/components/Header/index.tsx +3 -3
- package/src/components/Image/index.tsx +10 -4
- package/src/components/Items/index.tsx +5 -4
- package/src/components/Notifications/index.tsx +3 -2
- package/src/components/OrderSelect/index.tsx +4 -3
- package/src/components/PickedBar/index.tsx +2 -1
- package/src/components/Progress/index.tsx +3 -3
- package/src/components/ReduxProvider/index.tsx +15 -12
- package/src/components/SearchFacet/index.tsx +3 -2
- package/src/components/SearchFacetNumber/index.tsx +8 -8
- package/src/components/SearchFacetSelect/index.tsx +7 -8
- package/src/components/SearchFacetString/index.tsx +1 -1
- package/src/components/SearchFacetTags/index.tsx +13 -12
- package/src/components/SearchFacets/index.tsx +2 -3
- package/src/components/SearchFacetsControl/index.tsx +13 -12
- package/src/components/TableHeader/index.tsx +18 -17
- package/src/components/TableHeaderItem/index.tsx +4 -4
- package/src/components/TableRowAsset/index.tsx +37 -36
- package/src/components/TableRowUpload/index.tsx +7 -6
- package/src/components/Tag/index.tsx +8 -7
- package/src/components/TagView/index.tsx +2 -2
- package/src/components/TagViewHeader/index.tsx +5 -4
- package/src/components/TagsPanel/index.tsx +3 -3
- package/src/components/TagsVirtualized/index.tsx +25 -24
- package/src/components/TextInputSearch/index.tsx +3 -2
- package/src/components/UploadDropzone/UploadDropzone.test.tsx +8 -7
- package/src/components/UploadDropzone/index.tsx +14 -13
- package/src/config/orders.ts +6 -6
- package/src/config/searchFacets.ts +56 -55
- package/src/constants.ts +15 -14
- package/src/contexts/AssetSourceDispatchContext.tsx +1 -1
- package/src/contexts/ToolOptionsContext.tsx +6 -5
- package/src/formSchema/index.test.ts +6 -5
- package/src/formSchema/index.ts +5 -5
- package/src/hooks/useBreakpointIndex.ts +6 -6
- package/src/hooks/useKeyPress.ts +2 -2
- package/src/hooks/usePortalPopoverProps.ts +1 -1
- package/src/modules/assets/actions.ts +8 -7
- package/src/modules/assets/deleteAndUpdateEpics.test.ts +18 -17
- package/src/modules/assets/fetchEpic.test.ts +12 -11
- package/src/modules/assets/index.ts +134 -133
- package/src/modules/assets/reducer.test.ts +9 -8
- package/src/modules/assets/tagsAndListenerEpics.test.ts +36 -35
- package/src/modules/debug/index.ts +3 -3
- package/src/modules/dialog/actions.ts +2 -2
- package/src/modules/dialog/epics.test.ts +29 -28
- package/src/modules/dialog/index.ts +36 -35
- package/src/modules/dialog/reducer.test.ts +31 -30
- package/src/modules/index.ts +9 -9
- package/src/modules/notifications/epics.test.ts +71 -70
- package/src/modules/notifications/index.ts +50 -49
- package/src/modules/notifications/reducer.test.ts +8 -7
- package/src/modules/search/index.test.ts +2 -1
- package/src/modules/search/index.ts +22 -22
- package/src/modules/selected/index.ts +2 -2
- package/src/modules/selectors.test.ts +4 -3
- package/src/modules/selectors.ts +5 -5
- package/src/modules/tags/epics.test.ts +16 -15
- package/src/modules/tags/index.test.ts +2 -1
- package/src/modules/tags/index.ts +82 -81
- package/src/modules/uploads/actions.ts +3 -3
- package/src/modules/uploads/epics.test.ts +13 -12
- package/src/modules/uploads/index.test.ts +8 -7
- package/src/modules/uploads/index.ts +48 -47
- package/src/operators/checkTagName.test.ts +7 -6
- package/src/operators/checkTagName.ts +6 -5
- package/src/operators/debugThrottle.ts +4 -4
- package/src/plugin.tsx +18 -18
- package/src/schemas/tag.ts +7 -7
- package/src/styled/react-select/creatable.tsx +40 -39
- package/src/styled/react-select/single.tsx +39 -38
- package/src/types/index.ts +4 -3
- package/src/utils/applyMediaTags.ts +11 -10
- package/src/utils/blocksToText.test.ts +5 -4
- package/src/utils/blocksToText.ts +2 -2
- package/src/utils/constructFilter.test.ts +15 -14
- package/src/utils/constructFilter.ts +7 -7
- package/src/utils/generatePreviewBlobUrl.test.ts +6 -5
- package/src/utils/generatePreviewBlobUrl.ts +2 -2
- package/src/utils/getAssetResolution.test.ts +3 -2
- package/src/utils/getDocumentAssetIds.test.ts +7 -6
- package/src/utils/getDocumentAssetIds.ts +2 -2
- package/src/utils/getSchemeColor.test.ts +1 -0
- package/src/utils/getSchemeColor.ts +9 -9
- package/src/utils/getTagSelectOptions.test.ts +6 -5
- package/src/utils/getTagSelectOptions.ts +1 -1
- package/src/utils/getUniqueDocuments.test.ts +4 -3
- package/src/utils/getUniqueDocuments.ts +2 -2
- package/src/utils/imageDprUrl.test.ts +4 -3
- package/src/utils/imageDprUrl.ts +1 -1
- package/src/utils/isSupportedAssetType.test.ts +1 -0
- package/src/utils/mediaField.ts +4 -3
- package/src/utils/sanitizeFormData.test.ts +14 -13
- package/src/utils/typeGuards.test.ts +2 -1
- package/src/utils/uploadSanityAsset.test.ts +5 -4
- package/src/utils/uploadSanityAsset.ts +17 -16
- package/src/utils/withMaxConcurrency.test.ts +5 -4
- package/src/utils/withMaxConcurrency.ts +4 -4
- package/src/utils/zodFormResolver.ts +17 -0
- package/v2-incompatible.js +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useClient, useColorSchemeValue, useSchema, Preview, useDocumentStore, WithReferringDocuments, useFormValue, definePlugin } from "sanity";
|
|
3
2
|
import { ThLargeIcon, ThListIcon, SortIcon, CloseIcon, SelectIcon, AddIcon, SearchIcon, PlugIcon, ClipboardIcon, DownloadIcon, ChevronDownIcon, ErrorOutlineIcon, WarningOutlineIcon, EditIcon, ArrowUpIcon, ArrowDownIcon, TrashIcon, ComposeIcon, Icon, UploadIcon, WarningFilledIcon, CheckmarkCircleIcon, ChevronUpIcon, ImageIcon } from "@sanity/icons";
|
|
3
|
+
import { useClient, useColorSchemeValue, useSchema, Preview, useDocumentStore, WithReferringDocuments, useFormValue, definePlugin } from "sanity";
|
|
4
4
|
import { Inline, Button, usePortal, MenuButton, Menu as Menu$2, MenuItem, MenuDivider, Box, studioTheme, rem, Flex, Label, Text, 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, forwardRef, memo, Component } from "react";
|
|
6
|
+
import { isHotkey } from "is-hotkey-esm";
|
|
6
7
|
import { css, createGlobalStyle, styled } from "styled-components";
|
|
7
8
|
import { useSelector, useDispatch, Provider } from "react-redux";
|
|
8
9
|
import { createAction, createSlice, isAnyOf, createSelector, combineReducers, configureStore } from "@reduxjs/toolkit";
|
|
@@ -17,9 +18,9 @@ import { useNProgress } from "@tanem/react-nprogress";
|
|
|
17
18
|
import { hues, white } from "@sanity/color";
|
|
18
19
|
import Select, { components } from "react-select";
|
|
19
20
|
import { Virtuoso, VirtuosoGrid, GroupedVirtuoso } from "react-virtuoso";
|
|
20
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
21
21
|
import { Controller, useForm } from "react-hook-form";
|
|
22
22
|
import * as z from "zod";
|
|
23
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
23
24
|
import { format, formatRelative } from "date-fns";
|
|
24
25
|
import filesize from "filesize";
|
|
25
26
|
import copy from "copy-to-clipboard";
|
|
@@ -27,143 +28,6 @@ import { useIntentLink } from "sanity/router";
|
|
|
27
28
|
import { FileIcon as FileIcon$1, defaultStyles } from "react-file-icon";
|
|
28
29
|
import CreatableSelect from "react-select/creatable";
|
|
29
30
|
import { useDropzone } from "react-dropzone";
|
|
30
|
-
function getDefaultExportFromCjs(x) {
|
|
31
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
|
|
32
|
-
}
|
|
33
|
-
var lib = {}, hasRequiredLib;
|
|
34
|
-
function requireLib() {
|
|
35
|
-
if (hasRequiredLib) return lib;
|
|
36
|
-
hasRequiredLib = 1, Object.defineProperty(lib, "__esModule", {
|
|
37
|
-
value: !0
|
|
38
|
-
});
|
|
39
|
-
for (var IS_MAC = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.platform), MODIFIERS = {
|
|
40
|
-
alt: "altKey",
|
|
41
|
-
control: "ctrlKey",
|
|
42
|
-
meta: "metaKey",
|
|
43
|
-
shift: "shiftKey"
|
|
44
|
-
}, ALIASES = {
|
|
45
|
-
add: "+",
|
|
46
|
-
break: "pause",
|
|
47
|
-
cmd: "meta",
|
|
48
|
-
command: "meta",
|
|
49
|
-
ctl: "control",
|
|
50
|
-
ctrl: "control",
|
|
51
|
-
del: "delete",
|
|
52
|
-
down: "arrowdown",
|
|
53
|
-
esc: "escape",
|
|
54
|
-
ins: "insert",
|
|
55
|
-
left: "arrowleft",
|
|
56
|
-
mod: IS_MAC ? "meta" : "control",
|
|
57
|
-
opt: "alt",
|
|
58
|
-
option: "alt",
|
|
59
|
-
return: "enter",
|
|
60
|
-
right: "arrowright",
|
|
61
|
-
space: " ",
|
|
62
|
-
spacebar: " ",
|
|
63
|
-
up: "arrowup",
|
|
64
|
-
win: "meta",
|
|
65
|
-
windows: "meta"
|
|
66
|
-
}, CODES = {
|
|
67
|
-
backspace: 8,
|
|
68
|
-
tab: 9,
|
|
69
|
-
enter: 13,
|
|
70
|
-
shift: 16,
|
|
71
|
-
control: 17,
|
|
72
|
-
alt: 18,
|
|
73
|
-
pause: 19,
|
|
74
|
-
capslock: 20,
|
|
75
|
-
escape: 27,
|
|
76
|
-
" ": 32,
|
|
77
|
-
pageup: 33,
|
|
78
|
-
pagedown: 34,
|
|
79
|
-
end: 35,
|
|
80
|
-
home: 36,
|
|
81
|
-
arrowleft: 37,
|
|
82
|
-
arrowup: 38,
|
|
83
|
-
arrowright: 39,
|
|
84
|
-
arrowdown: 40,
|
|
85
|
-
insert: 45,
|
|
86
|
-
delete: 46,
|
|
87
|
-
meta: 91,
|
|
88
|
-
numlock: 144,
|
|
89
|
-
scrolllock: 145,
|
|
90
|
-
";": 186,
|
|
91
|
-
"=": 187,
|
|
92
|
-
",": 188,
|
|
93
|
-
"-": 189,
|
|
94
|
-
".": 190,
|
|
95
|
-
"/": 191,
|
|
96
|
-
"`": 192,
|
|
97
|
-
"[": 219,
|
|
98
|
-
"\\": 220,
|
|
99
|
-
"]": 221,
|
|
100
|
-
"'": 222
|
|
101
|
-
}, f = 1; f < 20; f++)
|
|
102
|
-
CODES["f" + f] = 111 + f;
|
|
103
|
-
function isHotkey2(hotkey, options, event) {
|
|
104
|
-
options && !("byKey" in options) && (event = options, options = null), Array.isArray(hotkey) || (hotkey = [hotkey]);
|
|
105
|
-
var array = hotkey.map(function(string) {
|
|
106
|
-
return parseHotkey(string, options);
|
|
107
|
-
}), check = function(e) {
|
|
108
|
-
return array.some(function(object) {
|
|
109
|
-
return compareHotkey(object, e);
|
|
110
|
-
});
|
|
111
|
-
}, ret = event == null ? check : check(event);
|
|
112
|
-
return ret;
|
|
113
|
-
}
|
|
114
|
-
function isCodeHotkey(hotkey, event) {
|
|
115
|
-
return isHotkey2(hotkey, event);
|
|
116
|
-
}
|
|
117
|
-
function isKeyHotkey(hotkey, event) {
|
|
118
|
-
return isHotkey2(hotkey, { byKey: !0 }, event);
|
|
119
|
-
}
|
|
120
|
-
function parseHotkey(hotkey, options) {
|
|
121
|
-
var byKey = options && options.byKey, ret = {};
|
|
122
|
-
hotkey = hotkey.replace("++", "+add");
|
|
123
|
-
var values = hotkey.split("+"), length = values.length;
|
|
124
|
-
for (var k in MODIFIERS)
|
|
125
|
-
ret[MODIFIERS[k]] = !1;
|
|
126
|
-
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
127
|
-
try {
|
|
128
|
-
for (var _iterator = values[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
129
|
-
var value = _step.value, optional = value.endsWith("?") && value.length > 1;
|
|
130
|
-
optional && (value = value.slice(0, -1));
|
|
131
|
-
var name = toKeyName(value), modifier = MODIFIERS[name];
|
|
132
|
-
if (value.length > 1 && !modifier && !ALIASES[value] && !CODES[name])
|
|
133
|
-
throw new TypeError('Unknown modifier: "' + value + '"');
|
|
134
|
-
(length === 1 || !modifier) && (byKey ? ret.key = name : ret.which = toKeyCode(value)), modifier && (ret[modifier] = optional ? null : !0);
|
|
135
|
-
}
|
|
136
|
-
} catch (err) {
|
|
137
|
-
_didIteratorError = !0, _iteratorError = err;
|
|
138
|
-
} finally {
|
|
139
|
-
try {
|
|
140
|
-
!_iteratorNormalCompletion && _iterator.return && _iterator.return();
|
|
141
|
-
} finally {
|
|
142
|
-
if (_didIteratorError)
|
|
143
|
-
throw _iteratorError;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return ret;
|
|
147
|
-
}
|
|
148
|
-
function compareHotkey(object, event) {
|
|
149
|
-
for (var key in object) {
|
|
150
|
-
var expected = object[key], actual = void 0;
|
|
151
|
-
if (expected != null && (key === "key" && event.key != null ? actual = event.key.toLowerCase() : key === "which" ? actual = expected === 91 && event.which === 93 ? 91 : event.which : actual = event[key], !(actual == null && expected === !1) && actual !== expected))
|
|
152
|
-
return !1;
|
|
153
|
-
}
|
|
154
|
-
return !0;
|
|
155
|
-
}
|
|
156
|
-
function toKeyCode(name) {
|
|
157
|
-
name = toKeyName(name);
|
|
158
|
-
var code = CODES[name] || name.toUpperCase().charCodeAt(0);
|
|
159
|
-
return code;
|
|
160
|
-
}
|
|
161
|
-
function toKeyName(name) {
|
|
162
|
-
return name = name.toLowerCase(), name = ALIASES[name] || name, name;
|
|
163
|
-
}
|
|
164
|
-
return lib.default = isHotkey2, lib.isHotkey = isHotkey2, lib.isCodeHotkey = isCodeHotkey, lib.isKeyHotkey = isKeyHotkey, lib.parseHotkey = parseHotkey, lib.compareHotkey = compareHotkey, lib.toKeyCode = toKeyCode, lib.toKeyName = toKeyName, lib;
|
|
165
|
-
}
|
|
166
|
-
var libExports = requireLib(), isHotkey = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
|
|
167
31
|
const useKeyPress = (hotkey, onPress) => {
|
|
168
32
|
const keyPressed = useRef(!1), downHandler = useCallback(
|
|
169
33
|
(e) => {
|
|
@@ -2708,7 +2572,13 @@ const imageDprUrl = (asset, options) => {
|
|
|
2708
2572
|
}, sanitizeFormData = (formData) => Object.keys(formData).reduce((acc, key) => {
|
|
2709
2573
|
const val = formData[key];
|
|
2710
2574
|
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;
|
|
2711
|
-
}, {}), isFileAsset = (asset) => asset._type === "sanity.fileAsset", isImageAsset = (asset) => asset._type === "sanity.imageAsset"
|
|
2575
|
+
}, {}), isFileAsset = (asset) => asset._type === "sanity.fileAsset", isImageAsset = (asset) => asset._type === "sanity.imageAsset";
|
|
2576
|
+
function zodFormResolver(schema) {
|
|
2577
|
+
return zodResolver(
|
|
2578
|
+
schema
|
|
2579
|
+
);
|
|
2580
|
+
}
|
|
2581
|
+
const getAssetResolution = (asset) => `${asset.metadata.dimensions.width}x${asset.metadata.dimensions.height}px`, ButtonAssetCopy = ({ disabled, url }) => {
|
|
2712
2582
|
const popoverProps = usePortalPopoverProps(), refPopoverTimeout = useRef(null), [popoverVisible, setPopoverVisible] = useState(!1), handleClick = () => {
|
|
2713
2583
|
refPopoverTimeout.current && clearTimeout(refPopoverTimeout.current), setPopoverVisible(!0), copy(url), refPopoverTimeout.current = setTimeout(() => {
|
|
2714
2584
|
setPopoverVisible(!1);
|
|
@@ -2893,12 +2763,17 @@ const imageDprUrl = (asset, options) => {
|
|
|
2893
2763
|
object-fit: contain;
|
|
2894
2764
|
|
|
2895
2765
|
${(props) => props.$showCheckerboard && css`
|
|
2896
|
-
background-image:
|
|
2766
|
+
background-image:
|
|
2767
|
+
linear-gradient(45deg, var(--checkerboard-color) 25%, transparent 25%),
|
|
2897
2768
|
linear-gradient(-45deg, var(--checkerboard-color) 25%, transparent 25%),
|
|
2898
2769
|
linear-gradient(45deg, transparent 75%, var(--checkerboard-color) 75%),
|
|
2899
2770
|
linear-gradient(-45deg, transparent 75%, var(--checkerboard-color) 75%);
|
|
2900
2771
|
background-size: 20px 20px;
|
|
2901
|
-
background-position:
|
|
2772
|
+
background-position:
|
|
2773
|
+
0 0,
|
|
2774
|
+
0 10px,
|
|
2775
|
+
10px -10px,
|
|
2776
|
+
-10px 0;
|
|
2902
2777
|
`}
|
|
2903
2778
|
`, { radius: themeRadius, space: themeSpace } = studioTheme, reactSelectStyles = (scheme) => ({
|
|
2904
2779
|
control: (styles, { isFocused }) => {
|
|
@@ -3332,7 +3207,7 @@ const DialogAssetEdit = (props) => {
|
|
|
3332
3207
|
} = useForm({
|
|
3333
3208
|
defaultValues: generateDefaultValues(assetItem?.asset),
|
|
3334
3209
|
mode: "onChange",
|
|
3335
|
-
resolver:
|
|
3210
|
+
resolver: zodFormResolver(getAssetFormSchema(locales))
|
|
3336
3211
|
}), formUpdating = !assetItem || assetItem?.updating, handleClose = useCallback(() => {
|
|
3337
3212
|
dispatch(dialogActions.remove({ id }));
|
|
3338
3213
|
}, [dispatch, id]), handleDelete = useCallback(() => {
|
|
@@ -3650,7 +3525,7 @@ const DialogAssetEdit = (props) => {
|
|
|
3650
3525
|
name: ""
|
|
3651
3526
|
},
|
|
3652
3527
|
mode: "onChange",
|
|
3653
|
-
resolver:
|
|
3528
|
+
resolver: zodFormResolver(tagFormSchema)
|
|
3654
3529
|
}), formUpdating = creating, handleClose = () => {
|
|
3655
3530
|
dispatch(dialogActions.clear());
|
|
3656
3531
|
}, onSubmit = (formData) => {
|
|
@@ -3700,7 +3575,7 @@ const DialogAssetEdit = (props) => {
|
|
|
3700
3575
|
} = useForm({
|
|
3701
3576
|
defaultValues: generateDefaultValues(tagItem?.tag),
|
|
3702
3577
|
mode: "onChange",
|
|
3703
|
-
resolver:
|
|
3578
|
+
resolver: zodFormResolver(tagFormSchema)
|
|
3704
3579
|
}), formUpdating = !tagItem || tagItem?.updating, handleClose = () => {
|
|
3705
3580
|
dispatch(dialogActions.remove({ id }));
|
|
3706
3581
|
}, onSubmit = (formData) => {
|
|
@@ -4144,38 +4019,40 @@ const DialogAssetEdit = (props) => {
|
|
|
4144
4019
|
overflow: hidden;
|
|
4145
4020
|
position: relative;
|
|
4146
4021
|
width: 100%;
|
|
4147
|
-
`, CardContainer = styled(Flex)(
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4022
|
+
`, CardContainer = styled(Flex)(({
|
|
4023
|
+
$picked,
|
|
4024
|
+
theme,
|
|
4025
|
+
$updating
|
|
4026
|
+
}) => css`
|
|
4027
|
+
border: 1px solid transparent;
|
|
4028
|
+
height: 100%;
|
|
4029
|
+
pointer-events: ${$updating ? "none" : "auto"};
|
|
4030
|
+
position: relative;
|
|
4031
|
+
transition: all 300ms;
|
|
4032
|
+
user-select: none;
|
|
4033
|
+
width: 100%;
|
|
4156
4034
|
|
|
4157
|
-
|
|
4035
|
+
border: ${$picked ? `1px solid ${theme.sanity.color.spot.orange} !important` : "1px solid inherit"};
|
|
4158
4036
|
|
|
4159
|
-
|
|
4160
|
-
@media (hover: hover) and (pointer: fine) {
|
|
4161
|
-
&:hover {
|
|
4162
|
-
border: 1px solid var(--card-border-color);
|
|
4163
|
-
}
|
|
4164
|
-
}
|
|
4165
|
-
`}
|
|
4166
|
-
`
|
|
4167
|
-
), ContextActionContainer$2 = styled(Flex)(
|
|
4168
|
-
({ $scheme }) => css`
|
|
4169
|
-
cursor: pointer;
|
|
4170
|
-
height: ${PANEL_HEIGHT}px;
|
|
4171
|
-
transition: all 300ms;
|
|
4037
|
+
${!$updating && css`
|
|
4172
4038
|
@media (hover: hover) and (pointer: fine) {
|
|
4173
4039
|
&:hover {
|
|
4174
|
-
|
|
4040
|
+
border: 1px solid var(--card-border-color);
|
|
4175
4041
|
}
|
|
4176
4042
|
}
|
|
4177
|
-
`
|
|
4178
|
-
),
|
|
4043
|
+
`}
|
|
4044
|
+
`), ContextActionContainer$2 = styled(Flex)(({
|
|
4045
|
+
$scheme
|
|
4046
|
+
}) => css`
|
|
4047
|
+
cursor: pointer;
|
|
4048
|
+
height: ${PANEL_HEIGHT}px;
|
|
4049
|
+
transition: all 300ms;
|
|
4050
|
+
@media (hover: hover) and (pointer: fine) {
|
|
4051
|
+
&:hover {
|
|
4052
|
+
background: ${getSchemeColor($scheme, "bg")};
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
`), StyledWarningOutlineIcon = styled(WarningFilledIcon)(({ theme }) => ({
|
|
4179
4056
|
color: theme.sanity.color.spot.red
|
|
4180
4057
|
})), CardAsset$1 = (props) => {
|
|
4181
4058
|
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();
|
|
@@ -4734,16 +4611,16 @@ const CardWrapper = styled(Flex)`
|
|
|
4734
4611
|
]
|
|
4735
4612
|
}
|
|
4736
4613
|
) });
|
|
4737
|
-
}, ContextActionContainer$1 = styled(Flex)(
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
}
|
|
4614
|
+
}, ContextActionContainer$1 = styled(Flex)(({
|
|
4615
|
+
$scheme
|
|
4616
|
+
}) => css`
|
|
4617
|
+
cursor: pointer;
|
|
4618
|
+
@media (hover: hover) and (pointer: fine) {
|
|
4619
|
+
&:hover {
|
|
4620
|
+
background: ${getSchemeColor($scheme, "bg")};
|
|
4744
4621
|
}
|
|
4745
|
-
|
|
4746
|
-
), TableHeader = () => {
|
|
4622
|
+
}
|
|
4623
|
+
`), TableHeader = () => {
|
|
4747
4624
|
const scheme = useColorSchemeValue(), dispatch = useDispatch(), fetching = useTypedSelector((state) => state.assets.fetching), itemsLength = useTypedSelector(selectAssetsLength), numPickedAssets = useTypedSelector(selectAssetsPickedLength), mediaIndex = useMediaIndex(), { onSelect } = useAssetSourceActions(), allSelected = numPickedAssets === itemsLength, handleContextActionClick = (e) => {
|
|
4748
4625
|
e.stopPropagation(), dispatch(allSelected ? assetsActions.pickClear() : assetsActions.pickAll());
|
|
4749
4626
|
};
|
|
@@ -4818,16 +4695,16 @@ const CardWrapper = styled(Flex)`
|
|
|
4818
4695
|
}
|
|
4819
4696
|
}
|
|
4820
4697
|
`}
|
|
4821
|
-
`), ContextActionContainer = styled(Flex)(
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
}
|
|
4698
|
+
`), ContextActionContainer = styled(Flex)(({
|
|
4699
|
+
$scheme
|
|
4700
|
+
}) => css`
|
|
4701
|
+
cursor: pointer;
|
|
4702
|
+
@media (hover: hover) and (pointer: fine) {
|
|
4703
|
+
&:hover {
|
|
4704
|
+
background: ${getSchemeColor($scheme, "bg2")};
|
|
4828
4705
|
}
|
|
4829
|
-
|
|
4830
|
-
), StyledWarningIcon = styled(WarningFilledIcon)(({ theme }) => ({
|
|
4706
|
+
}
|
|
4707
|
+
`), StyledWarningIcon = styled(WarningFilledIcon)(({ theme }) => ({
|
|
4831
4708
|
color: theme.sanity.color.spot.red
|
|
4832
4709
|
})), TableRowAsset$1 = (props) => {
|
|
4833
4710
|
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(
|
|
@@ -5259,24 +5136,15 @@ const TableRowUpload = (props) => {
|
|
|
5259
5136
|
] })
|
|
5260
5137
|
}
|
|
5261
5138
|
);
|
|
5262
|
-
}
|
|
5263
|
-
assets: [],
|
|
5264
|
-
document: void 0,
|
|
5265
|
-
documentAssetIds: []
|
|
5266
|
-
}, selectedSlice = createSlice({
|
|
5267
|
-
name: "selected",
|
|
5268
|
-
initialState: initialState$1,
|
|
5269
|
-
reducers: {}
|
|
5270
|
-
});
|
|
5271
|
-
var selectedReducer = selectedSlice.reducer;
|
|
5139
|
+
};
|
|
5272
5140
|
function messageFromGenericErrorPayload(payload) {
|
|
5273
5141
|
return !payload || typeof payload != "object" ? "Unknown error" : "error" in payload && payload.error && typeof payload.error == "object" && payload.error !== null && "message" in payload.error ? String(payload.error.message) : "message" in payload && typeof payload.message == "string" ? String(payload.message) : "Unknown error";
|
|
5274
5142
|
}
|
|
5275
|
-
const initialState = {
|
|
5143
|
+
const initialState$1 = {
|
|
5276
5144
|
items: []
|
|
5277
5145
|
}, notificationsSlice = createSlice({
|
|
5278
5146
|
name: "notifications",
|
|
5279
|
-
initialState,
|
|
5147
|
+
initialState: initialState$1,
|
|
5280
5148
|
reducers: {
|
|
5281
5149
|
add(state, action) {
|
|
5282
5150
|
const { asset, status, title } = action.payload;
|
|
@@ -5377,6 +5245,16 @@ const initialState = {
|
|
|
5377
5245
|
mergeMap(() => of(notificationsSlice.actions.add({ status: "info", title: "Tag updated" })))
|
|
5378
5246
|
), notificationsActions = { ...notificationsSlice.actions };
|
|
5379
5247
|
var notificationsReducer = notificationsSlice.reducer;
|
|
5248
|
+
const initialState = {
|
|
5249
|
+
assets: [],
|
|
5250
|
+
document: void 0,
|
|
5251
|
+
documentAssetIds: []
|
|
5252
|
+
}, selectedSlice = createSlice({
|
|
5253
|
+
name: "selected",
|
|
5254
|
+
initialState,
|
|
5255
|
+
reducers: {}
|
|
5256
|
+
});
|
|
5257
|
+
var selectedReducer = selectedSlice.reducer;
|
|
5380
5258
|
const rootEpic = combineEpics(
|
|
5381
5259
|
assetsDeleteEpic,
|
|
5382
5260
|
assetsFetchEpic,
|
|
@@ -5782,7 +5660,6 @@ const plugin = {
|
|
|
5782
5660
|
}, tool = {
|
|
5783
5661
|
...plugin,
|
|
5784
5662
|
component: Tool,
|
|
5785
|
-
// @ts-expect-error TS doesn't know about this internal field see https://github.com/sanity-io/sanity/pull/7980
|
|
5786
5663
|
__internalApplicationType: "sanity/media"
|
|
5787
5664
|
}, media = definePlugin((options) => ({
|
|
5788
5665
|
name: "media",
|
|
@@ -5859,7 +5736,11 @@ function AutoTagInput(props) {
|
|
|
5859
5736
|
}).catch((err) => {
|
|
5860
5737
|
console.error("[sanity-plugin-media] Failed to apply auto-tags:", err);
|
|
5861
5738
|
const label = mediaTags.length === 1 ? "tag" : "tags";
|
|
5862
|
-
toast.push({
|
|
5739
|
+
toast.push({
|
|
5740
|
+
closable: !0,
|
|
5741
|
+
status: "error",
|
|
5742
|
+
title: `Failed to apply the media ${label} ${mediaTags.join(", ")}`
|
|
5743
|
+
});
|
|
5863
5744
|
});
|
|
5864
5745
|
}, [currentAssetRef, mediaTags, client, createTagsOnUpload]), renderDefault(props);
|
|
5865
5746
|
}
|