sanity-plugin-mux-input 2.6.0 → 2.8.0
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 +7 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/components/VideoThumbnail.tsx +6 -7
- package/src/hooks/useInView.ts +6 -9
- package/src/schema.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-mux-input",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "An input component that integrates Sanity Studio with Mux video encoding/hosting service.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"@sanity/semantic-release-preset": "^5.0.0",
|
|
77
77
|
"@sanity/vision": "^3.77.2",
|
|
78
78
|
"@types/lodash": "^4.17.15",
|
|
79
|
-
"@types/react": "^
|
|
80
|
-
"@types/react-is": "^
|
|
79
|
+
"@types/react": "^19.0.10",
|
|
80
|
+
"@types/react-is": "^19.0.0",
|
|
81
81
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
82
82
|
"@typescript-eslint/parser": "^7.18.0",
|
|
83
83
|
"eslint": "^8.57.1",
|
|
@@ -93,17 +93,17 @@
|
|
|
93
93
|
"npm-run-all2": "^5.0.2",
|
|
94
94
|
"prettier": "^3.5.2",
|
|
95
95
|
"prettier-plugin-packagejson": "^2.5.9",
|
|
96
|
-
"react": "^
|
|
97
|
-
"react-dom": "^
|
|
98
|
-
"react-is": "^
|
|
96
|
+
"react": "^19.0.0",
|
|
97
|
+
"react-dom": "^19.0.0",
|
|
98
|
+
"react-is": "^19.0.0",
|
|
99
99
|
"sanity": "^3.77.2",
|
|
100
100
|
"semantic-release": "^24.2.3",
|
|
101
101
|
"styled-components": "^6.1.15",
|
|
102
102
|
"typescript": "5.7.3"
|
|
103
103
|
},
|
|
104
104
|
"peerDependencies": {
|
|
105
|
-
"react": "^18",
|
|
106
|
-
"react-is": "^18",
|
|
105
|
+
"react": "^18.3 || ^19",
|
|
106
|
+
"react-is": "^18.3 || ^19",
|
|
107
107
|
"sanity": "^3.42.0",
|
|
108
108
|
"styled-components": "^5 || ^6"
|
|
109
109
|
},
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {ErrorOutlineIcon} from '@sanity/icons'
|
|
2
2
|
import {Box, Card, CardTone, Spinner, Stack, Text} from '@sanity/ui'
|
|
3
|
-
import {useMemo, useState} from 'react'
|
|
3
|
+
import {useMemo, useRef, useState} from 'react'
|
|
4
4
|
import {styled} from 'styled-components'
|
|
5
5
|
|
|
6
6
|
import {useClient} from '../hooks/useClient'
|
|
7
|
-
import useInView from '../hooks/useInView'
|
|
7
|
+
import {useInView} from '../hooks/useInView'
|
|
8
8
|
import {THUMBNAIL_ASPECT_RATIO} from '../util/constants'
|
|
9
9
|
import {getAnimatedPosterSrc} from '../util/getAnimatedPosterSrc'
|
|
10
10
|
import {getPosterSrc} from '../util/getPosterSrc'
|
|
@@ -36,7 +36,8 @@ export default function VideoThumbnail({
|
|
|
36
36
|
width?: number
|
|
37
37
|
staticImage?: boolean
|
|
38
38
|
}) {
|
|
39
|
-
const
|
|
39
|
+
const ref = useRef<HTMLDivElement | null>(null)
|
|
40
|
+
const inView = useInView(ref)
|
|
40
41
|
const posterWidth = width || 250
|
|
41
42
|
|
|
42
43
|
const [status, setStatus] = useState<ImageStatus>('loading')
|
|
@@ -74,7 +75,7 @@ export default function VideoThumbnail({
|
|
|
74
75
|
}}
|
|
75
76
|
border
|
|
76
77
|
radius={2}
|
|
77
|
-
ref={ref
|
|
78
|
+
ref={ref}
|
|
78
79
|
tone={STATUS_TO_TONE[status]}
|
|
79
80
|
>
|
|
80
81
|
{inView ? (
|
|
@@ -116,9 +117,7 @@ export default function VideoThumbnail({
|
|
|
116
117
|
alt={`Preview for ${staticImage ? 'image' : 'video'} ${asset.filename || asset.assetId}`}
|
|
117
118
|
onLoad={handleLoad}
|
|
118
119
|
onError={handleError}
|
|
119
|
-
style={{
|
|
120
|
-
opacity: status === 'loaded' ? 1 : 0,
|
|
121
|
-
}}
|
|
120
|
+
style={{opacity: status === 'loaded' ? 1 : 0}}
|
|
122
121
|
/>
|
|
123
122
|
</>
|
|
124
123
|
) : null}
|
package/src/hooks/useInView.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {useEffect, useRef, useState} from 'react'
|
|
1
|
+
import {useEffect, useState} from 'react'
|
|
3
2
|
|
|
4
3
|
type IntersectionOptions = {
|
|
5
4
|
root?: Element | null
|
|
@@ -8,11 +7,11 @@ type IntersectionOptions = {
|
|
|
8
7
|
onChange?: (inView: boolean) => void
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
function useInView
|
|
10
|
+
export function useInView(
|
|
11
|
+
ref: React.RefObject<HTMLDivElement | null>,
|
|
12
12
|
options: IntersectionOptions = {}
|
|
13
|
-
)
|
|
13
|
+
) {
|
|
14
14
|
const [inView, setInView] = useState(false)
|
|
15
|
-
const ref = useRef(null)
|
|
16
15
|
|
|
17
16
|
useEffect(() => {
|
|
18
17
|
if (!ref.current) return
|
|
@@ -37,9 +36,7 @@ function useInView<RefElement = HTMLElement>(
|
|
|
37
36
|
return () => {
|
|
38
37
|
if (toObserve) observer.unobserve(toObserve)
|
|
39
38
|
}
|
|
40
|
-
}, [options])
|
|
39
|
+
}, [options, ref])
|
|
41
40
|
|
|
42
|
-
return
|
|
41
|
+
return inView
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
export default useInView
|