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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanity-plugin-mux-input",
3
- "version": "2.6.0",
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": "^18.3.18",
80
- "@types/react-is": "^18.3.1",
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": "^18.3.1",
97
- "react-dom": "^18.3.1",
98
- "react-is": "^18.3.1",
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 {inView, ref} = useInView()
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 as any}
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}
@@ -1,5 +1,4 @@
1
- import type {RefObject} from 'react'
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<RefElement = HTMLElement>(
10
+ export function useInView(
11
+ ref: React.RefObject<HTMLDivElement | null>,
12
12
  options: IntersectionOptions = {}
13
- ): {inView: boolean; ref: RefObject<RefElement>} {
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 {inView, ref}
41
+ return inView
43
42
  }
44
-
45
- export default useInView
package/src/schema.ts CHANGED
@@ -141,7 +141,7 @@ const muxAssetData = {
141
141
 
142
142
  const muxVideoAsset = {
143
143
  name: 'mux.videoAsset',
144
- type: 'object',
144
+ type: 'document',
145
145
  title: 'Video asset',
146
146
  fields: [
147
147
  {