@moises.ai/design-system 4.18.7 → 4.18.10
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,5 +1,5 @@
|
|
|
1
1
|
import { Flex, Text, Spinner } from '@radix-ui/themes'
|
|
2
|
-
import { useCallback, useContext, useEffect, useMemo,
|
|
2
|
+
import { useCallback, useContext, useEffect, useMemo, useState } from 'react'
|
|
3
3
|
import { ArrowLeftIcon } from '../../../icons'
|
|
4
4
|
import { ProjectsListContext } from '../context'
|
|
5
5
|
import { NumberPicker } from '../../NumberPicker/NumberPicker'
|
|
@@ -7,11 +7,7 @@ import { UserIcon } from '../../../icons'
|
|
|
7
7
|
import { Button } from '../../Button/Button'
|
|
8
8
|
import styles from './ProjectTrackVoice.module.css'
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const ProjectTrackVoice = ({
|
|
13
|
-
...props
|
|
14
|
-
}) => {
|
|
10
|
+
const ProjectTrackVoice = ({ ...props }) => {
|
|
15
11
|
const { onClickTrack, onChangeTransfer, projects, labels = {} } = useContext(ProjectsListContext)
|
|
16
12
|
const { projectId, id, title, cover, transfers, audioUrl, loading: _loading } = props
|
|
17
13
|
|
|
@@ -19,24 +15,29 @@ const ProjectTrackVoice = ({
|
|
|
19
15
|
|
|
20
16
|
const max = 24
|
|
21
17
|
const min = -24
|
|
22
|
-
const [pitchShiftSelected, setpitchShiftSelected] = useState(
|
|
23
|
-
|
|
24
|
-
const [loading, setLoading] = useState(_loading)
|
|
25
|
-
const debounceRef = useRef(null)
|
|
18
|
+
const [pitchShiftSelected, setpitchShiftSelected] = useState(null)
|
|
26
19
|
|
|
27
20
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (!_loading && hasTransfers) {
|
|
21
|
+
if (hasTransfers && pitchShiftSelected === null) {
|
|
31
22
|
setpitchShiftSelected(parseInt(transfers?.[0]?.pitchShift ?? 0))
|
|
32
23
|
}
|
|
33
|
-
}, [
|
|
24
|
+
}, [hasTransfers, pitchShiftSelected])
|
|
25
|
+
|
|
26
|
+
const loading = useMemo(() => {
|
|
27
|
+
if (
|
|
28
|
+
(!hasTransfers && _loading) ||
|
|
29
|
+
(hasTransfers && pitchShiftSelected === null)
|
|
30
|
+
) {
|
|
31
|
+
return true
|
|
32
|
+
}
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
if (pitchShiftSelected) {
|
|
35
|
+
const currentTransfer = transfers.find((transfer) => parseInt(transfer.pitchShift) === pitchShiftSelected)
|
|
36
|
+
return currentTransfer?.loading === true || !currentTransfer?.audioUrl
|
|
38
37
|
}
|
|
39
|
-
|
|
38
|
+
|
|
39
|
+
return false
|
|
40
|
+
}, [_loading, hasTransfers, pitchShiftSelected, transfers])
|
|
40
41
|
|
|
41
42
|
const getAudioUrl = useCallback((pitchShift) => {
|
|
42
43
|
return hasTransfers ? transfers?.find((transfer) => parseInt(transfer.pitchShift) === pitchShift)?.audioUrl : audioUrl
|
|
@@ -44,20 +45,16 @@ const ProjectTrackVoice = ({
|
|
|
44
45
|
|
|
45
46
|
const handleChangeTransfer = useCallback((value) => {
|
|
46
47
|
setpitchShiftSelected(value)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
pitchShift: value,
|
|
58
|
-
})
|
|
59
|
-
}, DEBOUNCE_MS)
|
|
60
|
-
}, [onChangeTransfer, projectId, id, title, getAudioUrl, projects])
|
|
48
|
+
const newAudioUrl = getAudioUrl(value)
|
|
49
|
+
const project = projects.find((project) => project.id === projectId)
|
|
50
|
+
onChangeTransfer?.(project, {
|
|
51
|
+
id,
|
|
52
|
+
title,
|
|
53
|
+
audioUrl: newAudioUrl,
|
|
54
|
+
processTrack: !newAudioUrl,
|
|
55
|
+
pitchShift: value,
|
|
56
|
+
})
|
|
57
|
+
}, [onChangeTransfer, projectId, id, title, transfers])
|
|
61
58
|
|
|
62
59
|
const handleClickTrack = useCallback((e) => {
|
|
63
60
|
e.stopPropagation()
|
|
@@ -66,18 +63,12 @@ const ProjectTrackVoice = ({
|
|
|
66
63
|
return
|
|
67
64
|
}
|
|
68
65
|
|
|
69
|
-
const processTrack = (!hasTransfers && !audioUrl)
|
|
70
|
-
|
|
71
|
-
if (processTrack) {
|
|
72
|
-
setLoading(true)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
66
|
onClickTrack?.({
|
|
76
67
|
...props,
|
|
77
68
|
id,
|
|
78
69
|
title,
|
|
79
70
|
audioUrl: hasTransfers || audioUrl ? getAudioUrl(pitchShiftSelected) : null,
|
|
80
|
-
processTrack,
|
|
71
|
+
processTrack: !hasTransfers && !audioUrl,
|
|
81
72
|
})
|
|
82
73
|
}, [onClickTrack, props, id, title, getAudioUrl, pitchShiftSelected, hasTransfers, loading, audioUrl])
|
|
83
74
|
|
|
@@ -120,19 +111,19 @@ const ProjectTrackVoice = ({
|
|
|
120
111
|
)}
|
|
121
112
|
|
|
122
113
|
{!hasTransfers && !audioUrl && !loading ? (
|
|
123
|
-
<Flex align="center" justify="center"
|
|
114
|
+
<Flex align="center" justify="center" pr="2">
|
|
124
115
|
<Button variant="soft" color="gray" size="1">
|
|
125
116
|
{labels.process || 'Process'}
|
|
126
117
|
</Button>
|
|
127
118
|
</Flex>
|
|
128
|
-
) : (
|
|
119
|
+
) : hasTransfers ? (
|
|
129
120
|
<NumberPicker
|
|
130
121
|
min={min}
|
|
131
122
|
max={max}
|
|
132
123
|
value={pitchShiftSelected}
|
|
133
124
|
onChange={handleChangeTransfer}
|
|
134
125
|
/>
|
|
135
|
-
)}
|
|
126
|
+
) : null}
|
|
136
127
|
</Flex>
|
|
137
128
|
</Flex>
|
|
138
129
|
)
|
|
@@ -262,7 +262,7 @@ export const WithTrackVoiceStates = {
|
|
|
262
262
|
"type": "voice",
|
|
263
263
|
"tracks": [
|
|
264
264
|
{
|
|
265
|
-
"id": "
|
|
265
|
+
"id": "q8pzli0h38ptcx211133q09h2al-0",
|
|
266
266
|
"title": "Joyce",
|
|
267
267
|
"type": "voice",
|
|
268
268
|
"loading": true,
|
|
@@ -273,6 +273,21 @@ export const WithTrackVoiceStates = {
|
|
|
273
273
|
"type": "voice",
|
|
274
274
|
"cover": "https://picsum.photos/101/101",
|
|
275
275
|
"transfers": [],
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"id": "q8pzli0h38ptcxq09h2al3-0",
|
|
279
|
+
"title": "Derek",
|
|
280
|
+
"type": "voice",
|
|
281
|
+
"cover": "https://picsum.photos/103/103",
|
|
282
|
+
"transfers": [{
|
|
283
|
+
"id": "q8pzli0h38ptcxq09h1122al",
|
|
284
|
+
"pitchShift": "12",
|
|
285
|
+
"audioUrl": "https://d3-stage.moises.ai/v3/download/moises-stage--tasks-us-east1/operations/VOICETRANSFER_A/0b926e1f-52ce-4581-9f76-09545eed1c61/vocals.m4"
|
|
286
|
+
}, {
|
|
287
|
+
"id": "q8pzli0h38ptcxq03339h2al2",
|
|
288
|
+
"pitchShift": "13",
|
|
289
|
+
"audioUrl": "https://d3-stage.moises.ai/v3/download/moises-stage--tasks-us-east1/operations/VOICETRANSFER_A/0a6c2a03-320e-49f2-9ea6-a5ad7bbb6141/vocals.m4a"
|
|
290
|
+
}],
|
|
276
291
|
}
|
|
277
292
|
]
|
|
278
293
|
}],
|