sanity-plugin-media 4.3.5 → 4.3.6
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.cjs +2529 -3561
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +190 -413
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +190 -413
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2532 -3564
- package/dist/index.js.map +1 -1
- package/package.json +26 -23
- package/src/__tests__/fixtures/mockSanityClient.ts +3 -3
- package/src/components/AssetGridVirtualized/index.tsx +3 -3
- package/src/components/AssetMetadata/index.tsx +1 -1
- package/src/components/AssetTableVirtualized/index.tsx +2 -2
- package/src/components/AutoTagInputWrapper/index.tsx +1 -3
- package/src/components/CardAsset/CardAsset.test.tsx +6 -6
- package/src/components/DialogAssetEdit/Details.tsx +2 -2
- package/src/components/DialogAssetEdit/DialogAssetEdit.test.tsx +1 -1
- package/src/components/DialogAssetEdit/index.tsx +5 -4
- package/src/components/DialogConfirm/index.tsx +2 -0
- package/src/components/DialogSearchFacets/index.tsx +1 -1
- package/src/components/DialogTagCreate/index.tsx +10 -2
- package/src/components/DialogTagEdit/DialogTagEdit.test.tsx +1 -1
- package/src/components/DialogTagEdit/index.tsx +18 -7
- package/src/components/DialogTags/index.tsx +1 -1
- package/src/components/Dialogs/index.tsx +1 -1
- package/src/components/Header/index.tsx +1 -1
- package/src/components/Items/index.tsx +1 -1
- package/src/components/Notifications/index.tsx +2 -2
- package/src/components/SearchFacet/index.tsx +1 -1
- package/src/components/SearchFacetSelect/index.tsx +2 -2
- package/src/components/SearchFacets/index.tsx +1 -1
- package/src/components/TableRowAsset/index.tsx +0 -1
- package/src/components/TagsVirtualized/index.tsx +2 -2
- package/src/components/UploadDropzone/index.tsx +1 -1
- package/src/config/orders.ts +1 -1
- package/src/contexts/AssetSourceDispatchContext.tsx +7 -6
- package/src/contexts/DropzoneDispatchContext.tsx +2 -4
- package/src/contexts/ToolOptionsContext.tsx +1 -0
- package/src/formSchema/index.ts +1 -1
- package/src/hooks/useBreakpointIndex.ts +5 -4
- package/src/modules/assets/deleteAndUpdateEpics.test.ts +2 -2
- package/src/modules/assets/fetchEpic.test.ts +1 -1
- package/src/modules/assets/index.ts +26 -69
- package/src/modules/assets/reducer.test.ts +3 -3
- package/src/modules/assets/tagsAndListenerEpics.test.ts +3 -3
- package/src/modules/dialog/epics.test.ts +1 -1
- package/src/modules/dialog/index.ts +2 -2
- package/src/modules/index.ts +3 -10
- package/src/modules/notifications/epics.test.ts +5 -5
- package/src/modules/notifications/index.ts +1 -1
- package/src/modules/search/index.test.ts +2 -2
- package/src/modules/search/index.ts +1 -1
- package/src/modules/tags/epics.test.ts +2 -2
- package/src/modules/tags/index.test.ts +2 -2
- package/src/modules/tags/index.ts +19 -19
- package/src/modules/uploads/epics.test.ts +2 -2
- package/src/modules/uploads/index.test.ts +3 -3
- package/src/modules/uploads/index.ts +3 -13
- package/src/styled/react-select/creatable.tsx +4 -4
- package/src/styled/react-select/single.tsx +9 -9
- package/src/types/index.ts +0 -33
- package/src/types/sanity-ui.d.ts +0 -1
- package/src/utils/generatePreviewBlobUrl.test.ts +0 -2
- package/src/utils/getDocumentAssetIds.ts +2 -2
- package/src/hooks/useOnScreen.ts +0 -34
|
@@ -27,7 +27,7 @@ export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig =>
|
|
|
27
27
|
'margin': 0,
|
|
28
28
|
'minHeight': '35px',
|
|
29
29
|
'outline': 'none',
|
|
30
|
-
'padding': rem(themeSpace[1]),
|
|
30
|
+
'padding': rem(themeSpace[1]!),
|
|
31
31
|
'transition': 'none',
|
|
32
32
|
'&:hover': {
|
|
33
33
|
boxShadow: `inset 0 0 0 1px ${getSchemeColor(scheme, 'inputHoveredBorder')}`,
|
|
@@ -42,7 +42,7 @@ export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig =>
|
|
|
42
42
|
...styles,
|
|
43
43
|
color: 'var(--card-fg-color)',
|
|
44
44
|
fontFamily: studioTheme.fonts.text.family,
|
|
45
|
-
marginLeft: rem(themeSpace[2]),
|
|
45
|
+
marginLeft: rem(themeSpace[2]!),
|
|
46
46
|
}),
|
|
47
47
|
menuList: (styles) => ({
|
|
48
48
|
...styles,
|
|
@@ -77,7 +77,7 @@ export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig =>
|
|
|
77
77
|
'backgroundColor': isFocused ? getSchemeColor(scheme, 'spotBlue') : 'transparent',
|
|
78
78
|
'borderRadius': themeRadius[2],
|
|
79
79
|
'color': isFocused ? getSchemeColor(scheme, 'bg') : 'inherit',
|
|
80
|
-
'padding': `${rem(themeSpace[1])} ${rem(themeSpace[2])}`,
|
|
80
|
+
'padding': `${rem(themeSpace[1]!)} ${rem(themeSpace[2]!)}`,
|
|
81
81
|
'&:hover': {
|
|
82
82
|
backgroundColor: getSchemeColor(scheme, 'spotBlue'),
|
|
83
83
|
color: getSchemeColor(scheme, 'bg'),
|
|
@@ -85,7 +85,7 @@ export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig =>
|
|
|
85
85
|
}),
|
|
86
86
|
placeholder: (styles) => ({
|
|
87
87
|
...styles,
|
|
88
|
-
marginLeft: rem(themeSpace[2]),
|
|
88
|
+
marginLeft: rem(themeSpace[2]!),
|
|
89
89
|
}),
|
|
90
90
|
valueContainer: (styles) => ({
|
|
91
91
|
...styles,
|
|
@@ -30,7 +30,7 @@ export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig =>
|
|
|
30
30
|
'border': 'none',
|
|
31
31
|
'borderRadius': themeRadius[2],
|
|
32
32
|
boxShadow,
|
|
33
|
-
'fontSize': themeTextSizes[1]
|
|
33
|
+
'fontSize': themeTextSizes[1]!.fontSize,
|
|
34
34
|
'minHeight': '25px',
|
|
35
35
|
'opacity': isDisabled ? 0.5 : 'inherit',
|
|
36
36
|
'outline': 'none',
|
|
@@ -44,8 +44,8 @@ export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig =>
|
|
|
44
44
|
...styles,
|
|
45
45
|
color: 'var(--card-fg-color)',
|
|
46
46
|
fontFamily: studioTheme.fonts.text.family,
|
|
47
|
-
fontSize: themeTextSizes[1]
|
|
48
|
-
marginLeft: rem(themeSpace[2]),
|
|
47
|
+
fontSize: themeTextSizes[1]!.fontSize,
|
|
48
|
+
marginLeft: rem(themeSpace[2]!),
|
|
49
49
|
}),
|
|
50
50
|
menuList: (styles) => ({
|
|
51
51
|
...styles,
|
|
@@ -54,7 +54,7 @@ export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig =>
|
|
|
54
54
|
noOptionsMessage: (styles) => ({
|
|
55
55
|
...styles,
|
|
56
56
|
fontFamily: studioTheme.fonts.text.family,
|
|
57
|
-
fontSize: themeTextSizes[1]
|
|
57
|
+
fontSize: themeTextSizes[1]!.fontSize,
|
|
58
58
|
lineHeight: '1em',
|
|
59
59
|
}),
|
|
60
60
|
option: (styles, {isFocused}) => ({
|
|
@@ -62,10 +62,10 @@ export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig =>
|
|
|
62
62
|
'backgroundColor': isFocused ? getSchemeColor(scheme, 'spotBlue') : 'transparent',
|
|
63
63
|
'borderRadius': themeRadius[2],
|
|
64
64
|
'color': isFocused ? getSchemeColor(scheme, 'bg') : 'inherit',
|
|
65
|
-
'fontSize': themeTextSizes[1]
|
|
65
|
+
'fontSize': themeTextSizes[1]!.fontSize,
|
|
66
66
|
'lineHeight': '1em',
|
|
67
67
|
'margin': 0,
|
|
68
|
-
'padding': rem(themeSpace[1]),
|
|
68
|
+
'padding': rem(themeSpace[1]!),
|
|
69
69
|
'&:hover': {
|
|
70
70
|
backgroundColor: getSchemeColor(scheme, 'spotBlue'),
|
|
71
71
|
color: getSchemeColor(scheme, 'bg'),
|
|
@@ -73,8 +73,8 @@ export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig =>
|
|
|
73
73
|
}),
|
|
74
74
|
placeholder: (styles) => ({
|
|
75
75
|
...styles,
|
|
76
|
-
fontSize: themeTextSizes[1]
|
|
77
|
-
marginLeft: rem(themeSpace[2]),
|
|
76
|
+
fontSize: themeTextSizes[1]!.fontSize,
|
|
77
|
+
marginLeft: rem(themeSpace[2]!),
|
|
78
78
|
paddingLeft: 0,
|
|
79
79
|
}),
|
|
80
80
|
singleValue: (styles) => ({
|
|
@@ -82,7 +82,7 @@ export const reactSelectStyles = (scheme: ThemeColorSchemeKey): StylesConfig =>
|
|
|
82
82
|
alignItems: 'center',
|
|
83
83
|
display: 'inline-flex',
|
|
84
84
|
height: '100%',
|
|
85
|
-
marginLeft: rem(themeSpace[2]),
|
|
85
|
+
marginLeft: rem(themeSpace[2]!),
|
|
86
86
|
}),
|
|
87
87
|
valueContainer: (styles) => ({
|
|
88
88
|
...styles,
|
package/src/types/index.ts
CHANGED
|
@@ -10,12 +10,9 @@ import type {Epic} from 'redux-observable'
|
|
|
10
10
|
import * as z from 'zod'
|
|
11
11
|
|
|
12
12
|
import type {DetailsProps} from '../components/DialogAssetEdit/Details'
|
|
13
|
-
import type {SUPPORTED_ASSET_TYPES} from '../constants'
|
|
14
13
|
import {getAssetFormSchema, tagFormSchema, tagOptionSchema} from '../formSchema'
|
|
15
14
|
import type {RootReducerState} from '../modules/types'
|
|
16
15
|
|
|
17
|
-
export type AssetTypes = (typeof SUPPORTED_ASSET_TYPES)[number]
|
|
18
|
-
|
|
19
16
|
export type MediaTagsOptions = {
|
|
20
17
|
mediaTags?: string[]
|
|
21
18
|
}
|
|
@@ -91,8 +88,6 @@ export type Block = {
|
|
|
91
88
|
|
|
92
89
|
export type BrowserView = 'grid' | 'table'
|
|
93
90
|
|
|
94
|
-
export type ButtonVariant = 'danger' | 'default' | 'secondary'
|
|
95
|
-
|
|
96
91
|
// TODO: rename
|
|
97
92
|
export type CardAssetData = {
|
|
98
93
|
id: string
|
|
@@ -112,8 +107,6 @@ export type Dialog =
|
|
|
112
107
|
| DialogTagEditProps
|
|
113
108
|
| DialogTagsProps
|
|
114
109
|
|
|
115
|
-
export type DialogAction = 'deleteAsset' | 'deleteTag'
|
|
116
|
-
|
|
117
110
|
export type DialogAssetEditProps = {
|
|
118
111
|
assetId?: string
|
|
119
112
|
closeDialogId?: string
|
|
@@ -163,16 +156,6 @@ export type DialogTagEditProps = {
|
|
|
163
156
|
type: 'tagEdit'
|
|
164
157
|
}
|
|
165
158
|
|
|
166
|
-
export type Document = {
|
|
167
|
-
_createdAt: string
|
|
168
|
-
_id: string
|
|
169
|
-
_rev: string
|
|
170
|
-
_type: string
|
|
171
|
-
_updatedAt: string
|
|
172
|
-
name?: string
|
|
173
|
-
title?: string
|
|
174
|
-
}
|
|
175
|
-
|
|
176
159
|
export type HttpError = {
|
|
177
160
|
message: string
|
|
178
161
|
statusCode: number
|
|
@@ -311,12 +294,6 @@ export type SearchFacetOperators = Record<
|
|
|
311
294
|
}
|
|
312
295
|
>
|
|
313
296
|
|
|
314
|
-
export type SanityUploadCompleteEvent = {
|
|
315
|
-
asset: SanityAssetDocument | SanityImageAssetDocument
|
|
316
|
-
id: string
|
|
317
|
-
type: 'complete'
|
|
318
|
-
}
|
|
319
|
-
|
|
320
297
|
export type SanityUploadProgressEvent = {
|
|
321
298
|
lengthComputable: boolean
|
|
322
299
|
loaded: number
|
|
@@ -326,16 +303,6 @@ export type SanityUploadProgressEvent = {
|
|
|
326
303
|
type: 'progress'
|
|
327
304
|
}
|
|
328
305
|
|
|
329
|
-
export type SanityUploadResponseEvent = {
|
|
330
|
-
body: {document: Partial<SanityAssetDocument | SanityImageAssetDocument>}
|
|
331
|
-
headers: Record<string, string>
|
|
332
|
-
method: string
|
|
333
|
-
statusCode: number
|
|
334
|
-
statusMessage: string
|
|
335
|
-
type: 'response'
|
|
336
|
-
url: string // preview image?
|
|
337
|
-
}
|
|
338
|
-
|
|
339
306
|
export type Span = {
|
|
340
307
|
_key: string
|
|
341
308
|
text: string
|
package/src/types/sanity-ui.d.ts
CHANGED
|
@@ -28,13 +28,11 @@ describe('generatePreviewBlobUrl$', () => {
|
|
|
28
28
|
vi.spyOn(el, 'getContext').mockReturnValue({
|
|
29
29
|
drawImage: vi.fn(),
|
|
30
30
|
} as unknown as CanvasRenderingContext2D)
|
|
31
|
-
/* eslint-disable callback-return, consistent-return -- HTMLCanvasElement#toBlob sync test stub */
|
|
32
31
|
el.toBlob = function toBlob(cb: ((blob: Blob | null) => void) | null | undefined) {
|
|
33
32
|
if (cb) {
|
|
34
33
|
cb(new Blob(['x'], {type: 'image/jpeg'}))
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
|
-
/* eslint-enable callback-return, consistent-return */
|
|
38
36
|
return el
|
|
39
37
|
}
|
|
40
38
|
return origCreateElement(tagName)
|
|
@@ -12,8 +12,8 @@ const getAssetIds = (node: Record<string, any>, acc: string[] = []) => {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
if (isPlainObject(node)) {
|
|
15
|
-
if (node?.asset?._type === 'reference' && node?.asset?._ref) {
|
|
16
|
-
acc.push(node
|
|
15
|
+
if (node?.['asset']?._type === 'reference' && node?.['asset']?._ref) {
|
|
16
|
+
acc.push(node['asset']._ref)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
Object.values(node).forEach((val) => {
|
package/src/hooks/useOnScreen.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {type RefObject, useEffect, useState} from 'react'
|
|
2
|
-
|
|
3
|
-
const useOnScreen = (ref: RefObject<HTMLElement>, options = {}, once: boolean) => {
|
|
4
|
-
const [isIntersecting, setIntersecting] = useState(false)
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const observer = new IntersectionObserver(([entry]: IntersectionObserverEntry[]) => {
|
|
8
|
-
// Update state when observer callback fires
|
|
9
|
-
setIntersecting(entry.isIntersecting)
|
|
10
|
-
|
|
11
|
-
// Stop observing
|
|
12
|
-
if (once && entry.isIntersecting) {
|
|
13
|
-
if (ref.current && observer) {
|
|
14
|
-
observer.unobserve(ref.current)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}, options)
|
|
18
|
-
|
|
19
|
-
if (ref.current && observer) {
|
|
20
|
-
observer.observe(ref.current)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Stop observing on unmount
|
|
24
|
-
return () => {
|
|
25
|
-
if (ref.current && observer) {
|
|
26
|
-
observer.unobserve(ref.current)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}, [])
|
|
30
|
-
|
|
31
|
-
return isIntersecting
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default useOnScreen
|