sanity-plugin-media 5.0.5 → 5.0.7
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.d.ts +14 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -10
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ImageIcon } from "@sanity/icons/Image";
|
|
1
2
|
import { SanityAssetDocument, SanityImageAssetDocument } from "@sanity/client";
|
|
2
3
|
import { ComponentType, JSX } from "react";
|
|
3
4
|
import * as z from "zod";
|
|
@@ -22,11 +23,11 @@ declare const tagOptionSchema: z.ZodObject<{
|
|
|
22
23
|
label: z.ZodString;
|
|
23
24
|
value: z.ZodString;
|
|
24
25
|
}, "strip", z.ZodTypeAny, {
|
|
25
|
-
value: string;
|
|
26
26
|
label: string;
|
|
27
|
-
}, {
|
|
28
27
|
value: string;
|
|
28
|
+
}, {
|
|
29
29
|
label: string;
|
|
30
|
+
value: string;
|
|
30
31
|
}>;
|
|
31
32
|
declare function getAssetFormSchema(locales?: {
|
|
32
33
|
id: string;
|
|
@@ -40,35 +41,35 @@ declare function getAssetFormSchema(locales?: {
|
|
|
40
41
|
label: z.ZodString;
|
|
41
42
|
value: z.ZodString;
|
|
42
43
|
}, "strip", z.ZodTypeAny, {
|
|
43
|
-
value: string;
|
|
44
44
|
label: string;
|
|
45
|
-
}, {
|
|
46
45
|
value: string;
|
|
46
|
+
}, {
|
|
47
47
|
label: string;
|
|
48
|
+
value: string;
|
|
48
49
|
}>, "many">>;
|
|
49
50
|
}, "strip", z.ZodTypeAny, {
|
|
50
51
|
tags: {
|
|
51
|
-
value: string;
|
|
52
52
|
label: string;
|
|
53
|
+
value: string;
|
|
53
54
|
}[] | null;
|
|
54
55
|
}, {
|
|
55
56
|
tags: {
|
|
56
|
-
value: string;
|
|
57
57
|
label: string;
|
|
58
|
+
value: string;
|
|
58
59
|
}[] | null;
|
|
59
60
|
}>;
|
|
60
61
|
}, "strip", z.ZodTypeAny, {
|
|
61
62
|
media: {
|
|
62
63
|
tags: {
|
|
63
|
-
value: string;
|
|
64
64
|
label: string;
|
|
65
|
+
value: string;
|
|
65
66
|
}[] | null;
|
|
66
67
|
};
|
|
67
68
|
}, {
|
|
68
69
|
media: {
|
|
69
70
|
tags: {
|
|
70
|
-
value: string;
|
|
71
71
|
label: string;
|
|
72
|
+
value: string;
|
|
72
73
|
}[] | null;
|
|
73
74
|
};
|
|
74
75
|
}>;
|
|
@@ -79,28 +80,28 @@ declare function getAssetFormSchema(locales?: {
|
|
|
79
80
|
opt: {
|
|
80
81
|
media: {
|
|
81
82
|
tags: {
|
|
82
|
-
value: string;
|
|
83
83
|
label: string;
|
|
84
|
+
value: string;
|
|
84
85
|
}[] | null;
|
|
85
86
|
};
|
|
86
87
|
};
|
|
88
|
+
title?: string | z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
|
|
87
89
|
altText?: string | z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
|
|
88
90
|
description?: string | z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
|
|
89
|
-
title?: string | z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
|
|
90
91
|
creditLine?: string | z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
|
|
91
92
|
}, {
|
|
92
93
|
originalFilename: string;
|
|
93
94
|
opt: {
|
|
94
95
|
media: {
|
|
95
96
|
tags: {
|
|
96
|
-
value: string;
|
|
97
97
|
label: string;
|
|
98
|
+
value: string;
|
|
98
99
|
}[] | null;
|
|
99
100
|
};
|
|
100
101
|
};
|
|
102
|
+
title?: string | z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
|
|
101
103
|
altText?: string | z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
|
|
102
104
|
description?: string | z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
|
|
103
|
-
title?: string | z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
|
|
104
105
|
creditLine?: string | z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
|
|
105
106
|
}>;
|
|
106
107
|
type MediaTagsOptions = {
|
|
@@ -158,7 +159,7 @@ type SanityReference = {
|
|
|
158
159
|
type TagSelectOption = z.infer<typeof tagOptionSchema>;
|
|
159
160
|
declare const mediaAssetSource: {
|
|
160
161
|
component: (props: import("sanity").AssetSourceComponentProps) => import("react").JSX.Element;
|
|
161
|
-
icon:
|
|
162
|
+
icon: typeof ImageIcon;
|
|
162
163
|
name: string;
|
|
163
164
|
title: string;
|
|
164
165
|
};
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/components/DialogAssetEdit/Details.tsx","../src/formSchema/index.ts","../src/types/index.ts","../src/plugin.tsx","../src/components/AutoTagInputWrapper/index.tsx","../src/utils/mediaField.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/components/DialogAssetEdit/Details.tsx","../src/formSchema/index.ts","../src/types/index.ts","../src/plugin.tsx","../src/components/AutoTagInputWrapper/index.tsx","../src/utils/mediaField.ts"],"mappings":";;;;;;KAqBY,YAAA;EACV,YAAA;EACA,eAAA,GAAkB,KAAA;EAClB,OAAA,EAAS,OAAA,CAAQ,aAAA;EACjB,MAAA,EAAQ,WAAA,CAAY,aAAA;EACpB,QAAA,EAAU,eAAA,CAAgB,aAAA;EAC1B,aAAA,EAAe,eAAA;EACf,eAAA,EAAiB,eAAA;EACjB,YAAA,EAAc,KAAA;EAC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QV,KAAA,mBAAK,MAAA,QAAA,gBAAA;AAAA,KCVN,iBAAA,GAAoB,UAAU;EACxC,SAAS;AAAA;;;;;;AJIX;;;;;;;;;;;;;;iBIkBgB,YAAA,CAAa,KAAA,EAAO,iBAAiB,mBAAA,GAAA,CAAA,OAAA;AAAA,KC7BhD,qBAAA,GAAwB,IAAA,CAAK,eAAA,eAChC,mBAAA;EACE,IAAA;EACA,SAAA;EACA,OAAA,GAAU,eAAA;AAAA;AAAA,KAGT,oBAAA,GAAuB,IAAA,CAAK,cAAA,eAC/B,mBAAA;EACE,IAAA;EACA,SAAA;EACA,OAAA,GAAU,cAAA;AAAA;AAAA,KAGT,qBAAA,GAAwB,IAAA,CAAK,eAAA,eAChC,mBAAA;EACE,OAAA,GAAU,eAAA;IAA8B,SAAA;EAAA;EACxC,UAAA;IAAa,KAAA,SAAc,YAAA;EAAA;AAAA,IACzB,eAAA,GACJ,iBAAA;AAAA,KAEG,oBAAA,GAAuB,IAAA,CAAK,cAAA,eAC/B,mBAAA;EACE,OAAA,GAAU,cAAA;IAA6B,SAAA;EAAA;EACvC,UAAA;IAAa,KAAA,SAAc,YAAA;EAAA;AAAA,IACzB,eAAA,GACJ,iBAAA;;;;;;;;;;;;;;;;;;;;;ALFgB;iBKyBF,UAAA,CAAW,MAAA,EAAQ,qBAAA,GAAwB,qBAAqB;AAAA,iBAChE,UAAA,CAAW,MAAA,EAAQ,oBAAA,GAAuB,oBAAoB"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { ImageIcon } from "@sanity/icons/Image";
|
|
3
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, 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
|
-
import { useRef, useCallback, useEffect, createContext, useContext, useMemo, useState,
|
|
5
|
+
import { useRef, useCallback, useEffect, createContext, useContext, useMemo, useState, memo, Component } from "react";
|
|
6
6
|
import { isHotkey } from "is-hotkey-esm";
|
|
7
7
|
import { css, createGlobalStyle, styled } from "styled-components";
|
|
8
8
|
import { useSelector, useDispatch, Provider } from "react-redux";
|
|
@@ -14,19 +14,42 @@ import { delay, mergeMap, filter, withLatestFrom, catchError, switchMap, bufferT
|
|
|
14
14
|
import groq from "groq";
|
|
15
15
|
import { nanoid } from "nanoid";
|
|
16
16
|
import { uuid } from "@sanity/uuid";
|
|
17
|
+
import { ThLargeIcon } from "@sanity/icons/ThLarge";
|
|
18
|
+
import { ThListIcon } from "@sanity/icons/ThList";
|
|
19
|
+
import { SortIcon } from "@sanity/icons/Sort";
|
|
17
20
|
import { useNProgress } from "@tanem/react-nprogress";
|
|
21
|
+
import { SelectIcon } from "@sanity/icons/Select";
|
|
22
|
+
import { CloseIcon } from "@sanity/icons/Close";
|
|
18
23
|
import { hues, white } from "@sanity/color";
|
|
19
24
|
import Select, { components } from "react-select";
|
|
20
25
|
import { Virtuoso, VirtuosoGrid, GroupedVirtuoso } from "react-virtuoso";
|
|
26
|
+
import { AddIcon } from "@sanity/icons/Add";
|
|
27
|
+
import { SearchIcon } from "@sanity/icons/Search";
|
|
28
|
+
import { PlugIcon } from "@sanity/icons/Plug";
|
|
21
29
|
import { Controller, useForm } from "react-hook-form";
|
|
22
30
|
import * as z from "zod";
|
|
23
31
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
32
|
+
import { DownloadIcon } from "@sanity/icons/Download";
|
|
24
33
|
import { format, formatRelative } from "date-fns";
|
|
25
34
|
import filesize from "filesize";
|
|
35
|
+
import { ClipboardIcon } from "@sanity/icons/Clipboard";
|
|
26
36
|
import copy from "copy-to-clipboard";
|
|
27
37
|
import { useIntentLink } from "sanity/router";
|
|
28
38
|
import { FileIcon as FileIcon$1, defaultStyles } from "react-file-icon";
|
|
29
39
|
import CreatableSelect from "react-select/creatable";
|
|
40
|
+
import { ChevronDownIcon } from "@sanity/icons/ChevronDown";
|
|
41
|
+
import { ErrorOutlineIcon } from "@sanity/icons/ErrorOutline";
|
|
42
|
+
import { WarningOutlineIcon } from "@sanity/icons/WarningOutline";
|
|
43
|
+
import { ArrowDownIcon } from "@sanity/icons/ArrowDown";
|
|
44
|
+
import { ArrowUpIcon } from "@sanity/icons/ArrowUp";
|
|
45
|
+
import { EditIcon } from "@sanity/icons/Edit";
|
|
46
|
+
import { TrashIcon } from "@sanity/icons/Trash";
|
|
47
|
+
import { ComposeIcon } from "@sanity/icons/Compose";
|
|
48
|
+
import { Icon } from "@sanity/icons";
|
|
49
|
+
import { UploadIcon } from "@sanity/icons/Upload";
|
|
50
|
+
import { CheckmarkCircleIcon } from "@sanity/icons/CheckmarkCircle";
|
|
51
|
+
import { WarningFilledIcon } from "@sanity/icons/WarningFilled";
|
|
52
|
+
import { ChevronUpIcon } from "@sanity/icons/ChevronUp";
|
|
30
53
|
import { useDropzone } from "react-dropzone";
|
|
31
54
|
const useKeyPress = (hotkey, onPress) => {
|
|
32
55
|
const keyPressed = useRef(!1), downHandler = useCallback((e) => {
|
|
@@ -2471,7 +2494,7 @@ const getAssetResolution = (asset) => `${asset.metadata.dimensions.width}x${asse
|
|
|
2471
2494
|
error
|
|
2472
2495
|
] }) }), fallbackPlacements: ["top", "left"], placement: "right", portal: !0, children: /* @__PURE__ */ jsx(StyledErrorOutlineIcon, {}) }) })
|
|
2473
2496
|
] }) }),
|
|
2474
|
-
description && /* @__PURE__ */ jsx(Box, { marginY: 3, children: /* @__PURE__ */ jsx(Text, { htmlFor: name, muted: !0, size: 1, children: description }) })
|
|
2497
|
+
description && /* @__PURE__ */ jsx(Box, { marginY: 3, children: /* @__PURE__ */ jsx(Text, { as: "label", htmlFor: name, muted: !0, size: 1, children: description }) })
|
|
2475
2498
|
] });
|
|
2476
2499
|
}, FormFieldInputTags = (props) => {
|
|
2477
2500
|
const {
|
|
@@ -2526,7 +2549,7 @@ const getAssetResolution = (asset) => `${asset.metadata.dimensions.width}x${asse
|
|
|
2526
2549
|
]
|
|
2527
2550
|
}
|
|
2528
2551
|
);
|
|
2529
|
-
}, FormFieldInputText =
|
|
2552
|
+
}, FormFieldInputText = (props) => {
|
|
2530
2553
|
const {
|
|
2531
2554
|
description,
|
|
2532
2555
|
disabled,
|
|
@@ -2535,13 +2558,14 @@ const getAssetResolution = (asset) => `${asset.metadata.dimensions.width}x${asse
|
|
|
2535
2558
|
name,
|
|
2536
2559
|
placeholder,
|
|
2537
2560
|
value,
|
|
2561
|
+
ref,
|
|
2538
2562
|
...rest
|
|
2539
2563
|
} = props;
|
|
2540
2564
|
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
2541
2565
|
/* @__PURE__ */ jsx(FormFieldInputLabel, { description, error, label, name }),
|
|
2542
2566
|
/* @__PURE__ */ jsx(TextInput, { ...rest, autoComplete: "off", autoFocus: !0, defaultValue: value, disabled, id: name, name, placeholder, ref })
|
|
2543
2567
|
] });
|
|
2544
|
-
}
|
|
2568
|
+
}, FormFieldInputTextarea = (props) => {
|
|
2545
2569
|
const {
|
|
2546
2570
|
description,
|
|
2547
2571
|
disabled,
|
|
@@ -2551,13 +2575,14 @@ const getAssetResolution = (asset) => `${asset.metadata.dimensions.width}x${asse
|
|
|
2551
2575
|
placeholder,
|
|
2552
2576
|
rows,
|
|
2553
2577
|
value,
|
|
2578
|
+
ref,
|
|
2554
2579
|
...rest
|
|
2555
2580
|
} = props;
|
|
2556
2581
|
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
2557
2582
|
/* @__PURE__ */ jsx(FormFieldInputLabel, { description, error, label, name }),
|
|
2558
2583
|
/* @__PURE__ */ jsx(TextArea, { ...rest, autoComplete: "off", defaultValue: value, disabled, id: name, name, placeholder, ref, rows })
|
|
2559
2584
|
] });
|
|
2560
|
-
}
|
|
2585
|
+
};
|
|
2561
2586
|
function toStringField(value) {
|
|
2562
2587
|
if (typeof value == "string") return value;
|
|
2563
2588
|
if (typeof value == "object" && value !== null)
|
|
@@ -3723,22 +3748,24 @@ const CardWrapper = styled(Flex).withConfig({
|
|
|
3723
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({
|
|
3724
3749
|
displayName: "StyledItemContainer",
|
|
3725
3750
|
componentId: "sc-9owt7i-0"
|
|
3726
|
-
})`height:${CARD_HEIGHT}px;width:${CARD_WIDTH}px;`, ItemContainer =
|
|
3751
|
+
})`height:${CARD_HEIGHT}px;width:${CARD_WIDTH}px;`, ItemContainer = (props) => {
|
|
3727
3752
|
const {
|
|
3728
3753
|
context,
|
|
3754
|
+
ref,
|
|
3729
3755
|
...rest
|
|
3730
3756
|
} = props;
|
|
3731
3757
|
return /* @__PURE__ */ jsx(StyledItemContainer, { ref, ...rest });
|
|
3732
|
-
}
|
|
3758
|
+
}, StyledListContainer = styled.div.withConfig({
|
|
3733
3759
|
displayName: "StyledListContainer",
|
|
3734
3760
|
componentId: "sc-9owt7i-1"
|
|
3735
|
-
})`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 =
|
|
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) => {
|
|
3736
3762
|
const {
|
|
3737
3763
|
context,
|
|
3764
|
+
ref,
|
|
3738
3765
|
...rest
|
|
3739
3766
|
} = props;
|
|
3740
3767
|
return /* @__PURE__ */ jsx(StyledListContainer, { ref, ...rest });
|
|
3741
|
-
}
|
|
3768
|
+
}, AssetGridVirtualized = (props) => {
|
|
3742
3769
|
const {
|
|
3743
3770
|
items,
|
|
3744
3771
|
onLoadMore
|