@moises.ai/design-system 4.20.9 → 4.21.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 +4961 -4468
- package/package.json +1 -1
- package/src/components/PanControl/PanControl.jsx +15 -6
- package/src/components/PanControl/PanControl.stories.jsx +12 -2
- package/src/components/ProjectsList/ProjectItem/ListItems.jsx +106 -0
- package/src/components/ProjectsList/ProjectItem/ListItems.module.css +43 -0
- package/src/components/ProjectsList/ProjectItem/ProjectItem.jsx +13 -84
- package/src/components/ProjectsList/ProjectItem/ProjectItem.module.css +0 -44
- package/src/components/ProjectsList/ProjectItemStemSeparation/ListStems.jsx +108 -0
- package/src/components/ProjectsList/ProjectItemStemSeparation/ListStems.module.css +43 -0
- package/src/components/ProjectsList/ProjectItemStemSeparation/ProjectItemStemSeparation.jsx +153 -0
- package/src/components/ProjectsList/ProjectItemStemSeparation/ProjectItemStemSeparation.module.css +68 -0
- package/src/components/ProjectsList/ProjectItemStemSeparation/StemSeparationForm.jsx +82 -0
- package/src/components/ProjectsList/ProjectItemStemSeparation/StemSeparationForm.module.css +40 -0
- package/src/components/ProjectsList/ProjectItemStemSeparation/use-form.js +46 -0
- package/src/components/ProjectsList/ProjectItemStemSeparation/utils.js +170 -0
- package/src/components/ProjectsList/ProjectTrack/ProjectTrack.jsx +12 -4
- package/src/components/ProjectsList/ProjectTrack/ProjectTrack.module.css +6 -2
- package/src/components/ProjectsList/ProjectsList.jsx +14 -3
- package/src/components/ProjectsList/ProjectsList.stories.jsx +47 -0
- package/src/components/ProjectsList/context.js +2 -0
- package/src/components/ProjectsList/utils-stories.js +425 -215
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@ export const PanControl = ({
|
|
|
23
23
|
minValue = -0.65,
|
|
24
24
|
maxValue = 0.65,
|
|
25
25
|
showTooltip = true,
|
|
26
|
+
tooltipValueMode = 'normalized',
|
|
26
27
|
tooltipDelayDuration = 0,
|
|
27
28
|
tooltipCloseDelay = 500,
|
|
28
29
|
}) => {
|
|
@@ -293,13 +294,21 @@ export const PanControl = ({
|
|
|
293
294
|
}, [value, disabled, minValue, maxValue])
|
|
294
295
|
|
|
295
296
|
const panValueText = useMemo(() => {
|
|
296
|
-
const
|
|
297
|
-
|
|
297
|
+
const display =
|
|
298
|
+
tooltipValueMode === 'mapped'
|
|
299
|
+
? denormalize(value, minValue, maxValue)
|
|
300
|
+
: clampNorm(value)
|
|
301
|
+
const pct = Math.round(display * 100)
|
|
298
302
|
return `Pan: ${Math.abs(pct) < 1 ? 0 : pct}`
|
|
299
|
-
}, [value, minValue, maxValue])
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
+
}, [value, minValue, maxValue, tooltipValueMode])
|
|
304
|
+
|
|
305
|
+
const ariaPanPct = useMemo(() => {
|
|
306
|
+
const display =
|
|
307
|
+
tooltipValueMode === 'mapped'
|
|
308
|
+
? denormalize(value, minValue, maxValue)
|
|
309
|
+
: clampNorm(value)
|
|
310
|
+
return Math.round(display * 100)
|
|
311
|
+
}, [value, minValue, maxValue, tooltipValueMode])
|
|
303
312
|
|
|
304
313
|
const handlePointerEnter = () => {
|
|
305
314
|
if (disabled) return
|
|
@@ -71,7 +71,7 @@ export default {
|
|
|
71
71
|
minValue: {
|
|
72
72
|
control: { type: 'number', step: 0.01 },
|
|
73
73
|
description:
|
|
74
|
-
'Minimum mapped value (normalized -1
|
|
74
|
+
'Minimum mapped value for the visual arc (normalized -1 maps to this). Also used by tooltip when tooltipValueMode is "mapped".',
|
|
75
75
|
table: {
|
|
76
76
|
type: { summary: 'number' },
|
|
77
77
|
defaultValue: { summary: -0.65 },
|
|
@@ -80,12 +80,22 @@ export default {
|
|
|
80
80
|
maxValue: {
|
|
81
81
|
control: { type: 'number', step: 0.01 },
|
|
82
82
|
description:
|
|
83
|
-
'Maximum mapped value (normalized 1
|
|
83
|
+
'Maximum mapped value for the visual arc (normalized 1 maps to this). Also used by tooltip when tooltipValueMode is "mapped".',
|
|
84
84
|
table: {
|
|
85
85
|
type: { summary: 'number' },
|
|
86
86
|
defaultValue: { summary: 0.65 },
|
|
87
87
|
},
|
|
88
88
|
},
|
|
89
|
+
tooltipValueMode: {
|
|
90
|
+
control: 'select',
|
|
91
|
+
options: ['normalized', 'mapped'],
|
|
92
|
+
description:
|
|
93
|
+
'Tooltip/aria scale: "normalized" shows -100..100 from the control position; "mapped" shows the minValue/maxValue scale (e.g. ±65).',
|
|
94
|
+
table: {
|
|
95
|
+
type: { summary: "'normalized' | 'mapped'" },
|
|
96
|
+
defaultValue: { summary: 'normalized' },
|
|
97
|
+
},
|
|
98
|
+
},
|
|
89
99
|
showTooltip: {
|
|
90
100
|
control: 'boolean',
|
|
91
101
|
description: 'Shows the pan value tooltip on hover/focus/drag',
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Flex, Text, Separator, Spinner, Button } from '@radix-ui/themes'
|
|
2
|
+
import { Collapsible } from 'radix-ui'
|
|
3
|
+
import { useState, useContext, useCallback, useMemo, useEffect } from 'react'
|
|
4
|
+
import { ArrowLeftIcon, NoMusicIcon, ChevronDownIcon, ChevronUpIcon } from '../../../icons'
|
|
5
|
+
import { ProjectsListContext } from '../context'
|
|
6
|
+
import styles from './ListItems.module.css'
|
|
7
|
+
|
|
8
|
+
const ListItems = ({
|
|
9
|
+
id,
|
|
10
|
+
type,
|
|
11
|
+
tracks: allTracks = [],
|
|
12
|
+
loading = false,
|
|
13
|
+
children,
|
|
14
|
+
labels = {},
|
|
15
|
+
}) => {
|
|
16
|
+
const { onInsertAllTracks, openedItem } = useContext(ProjectsListContext)
|
|
17
|
+
const [showAllTracks, setShowAllTracks] = useState(false)
|
|
18
|
+
|
|
19
|
+
const visibleTracks = useMemo(() => allTracks.slice(0, 6), [allTracks])
|
|
20
|
+
const extraTracks = useMemo(() => allTracks.slice(6), [allTracks])
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (openedItem !== id) {
|
|
24
|
+
setShowAllTracks(false)
|
|
25
|
+
}
|
|
26
|
+
}, [openedItem, id])
|
|
27
|
+
|
|
28
|
+
const handleClickShowAllTracks = useCallback((e) => {
|
|
29
|
+
e.preventDefault()
|
|
30
|
+
e.stopPropagation()
|
|
31
|
+
setShowAllTracks(!showAllTracks)
|
|
32
|
+
}, [showAllTracks])
|
|
33
|
+
|
|
34
|
+
const handleInsertAllTracks = useCallback((e) => {
|
|
35
|
+
e.stopPropagation()
|
|
36
|
+
let tracksFiltered = []
|
|
37
|
+
if (type === 'voice') {
|
|
38
|
+
tracksFiltered = allTracks.filter((track) => !track.loading && track.transfers?.length > 0)
|
|
39
|
+
} else {
|
|
40
|
+
tracksFiltered = allTracks.filter((track) => !track.loading && track.audioUrl)
|
|
41
|
+
}
|
|
42
|
+
onInsertAllTracks?.(tracksFiltered)
|
|
43
|
+
}, [onInsertAllTracks, allTracks, type])
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Collapsible.Root open={openedItem === id} className={styles.tracksCollapsible}>
|
|
47
|
+
<Collapsible.Content className={styles.tracksContent}>
|
|
48
|
+
<Flex direction="column" pt="2">
|
|
49
|
+
{type !== 'voice' && allTracks.length === 0 && !loading && (
|
|
50
|
+
<Flex direction="row" gap="3" p="5" pt="2" align="center" justify="center">
|
|
51
|
+
<NoMusicIcon width={16} height={16} style={{ color: 'var(--neutral-alpha-10)' }} />
|
|
52
|
+
<Text size="2" style={{ color: 'var(--neutral-alpha-10)' }}>{labels.noTracks || 'This file has no tracks'}</Text>
|
|
53
|
+
</Flex>
|
|
54
|
+
)}
|
|
55
|
+
|
|
56
|
+
{loading && (
|
|
57
|
+
<Flex direction="row" gap="3" p="5" align="center" justify="center">
|
|
58
|
+
<Spinner width={16} height={16} style={{ color: 'var(--neutral-alpha-10)' }} />
|
|
59
|
+
<Text size="2" style={{ color: 'var(--neutral-alpha-10)' }}>{labels.loading || 'Loading tracks...'}</Text>
|
|
60
|
+
</Flex>
|
|
61
|
+
)}
|
|
62
|
+
|
|
63
|
+
{allTracks.length > 0 && (
|
|
64
|
+
<Flex direction="column" gap="1">
|
|
65
|
+
{typeof children === 'function' ? (
|
|
66
|
+
<>
|
|
67
|
+
{children({ projectId: id, tracks: visibleTracks })}
|
|
68
|
+
{extraTracks.length > 0 && (
|
|
69
|
+
<Collapsible.Root open={showAllTracks} className={styles.extraTracksCollapsible}>
|
|
70
|
+
<Collapsible.Content className={styles.tracksContent}>
|
|
71
|
+
<Flex direction="column" gap="1" className={styles.extraTracksInner}>
|
|
72
|
+
{children({ projectId: id, tracks: extraTracks })}
|
|
73
|
+
</Flex>
|
|
74
|
+
</Collapsible.Content>
|
|
75
|
+
</Collapsible.Root>
|
|
76
|
+
)}
|
|
77
|
+
</>
|
|
78
|
+
) : children}
|
|
79
|
+
|
|
80
|
+
<Flex direction="row" gap="3" p="2" align="center" justify="center">
|
|
81
|
+
<Button variant="ghost" color="gray" style={{ flex: '1' }}
|
|
82
|
+
onClick={handleInsertAllTracks}
|
|
83
|
+
>
|
|
84
|
+
<ArrowLeftIcon width={16} height={16} /> {labels.insertAll || 'Insert all'}
|
|
85
|
+
</Button>
|
|
86
|
+
|
|
87
|
+
{allTracks.length > 6 && (
|
|
88
|
+
<>
|
|
89
|
+
<Separator orientation="vertical" />
|
|
90
|
+
|
|
91
|
+
<Button variant="ghost" color="gray" style={{ flex: '1' }} onClick={handleClickShowAllTracks}>
|
|
92
|
+
{showAllTracks ? labels.showLess || 'Show less' : labels.showMore || 'Show more'}
|
|
93
|
+
{showAllTracks ? <ChevronUpIcon width={16} height={16} /> : <ChevronDownIcon width={16} height={16} />}
|
|
94
|
+
</Button>
|
|
95
|
+
</>
|
|
96
|
+
)}
|
|
97
|
+
</Flex>
|
|
98
|
+
</Flex>
|
|
99
|
+
)}
|
|
100
|
+
</Flex>
|
|
101
|
+
</Collapsible.Content>
|
|
102
|
+
</Collapsible.Root>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default ListItems
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.tracksCollapsible {
|
|
2
|
+
width: 100%;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.extraTracksCollapsible {
|
|
6
|
+
width: 100%;
|
|
7
|
+
margin-top: calc(-1 * var(--space-1));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.extraTracksInner {
|
|
11
|
+
padding-top: var(--space-1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.tracksContent {
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
width: 100%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.tracksContent[data-state='open'] {
|
|
20
|
+
animation: projectItemSlideDown 0.3s ease;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.tracksContent[data-state='closed'] {
|
|
24
|
+
animation: projectItemSlideUp 0.3s ease;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@keyframes projectItemSlideDown {
|
|
28
|
+
from {
|
|
29
|
+
height: 0;
|
|
30
|
+
}
|
|
31
|
+
to {
|
|
32
|
+
height: var(--radix-collapsible-content-height);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@keyframes projectItemSlideUp {
|
|
37
|
+
from {
|
|
38
|
+
height: var(--radix-collapsible-content-height);
|
|
39
|
+
}
|
|
40
|
+
to {
|
|
41
|
+
height: 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Flex, Text
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ArrowLeftIcon, NoMusicIcon, ChevronDownIcon, ChevronUpIcon, InfoIcon } from '../../../icons'
|
|
1
|
+
import { Flex, Text } from '@radix-ui/themes'
|
|
2
|
+
import { useContext, useCallback } from 'react'
|
|
3
|
+
import { InfoIcon } from '../../../icons'
|
|
5
4
|
import { ProjectsListContext } from '../context'
|
|
6
5
|
import { ProductsBrandPattern } from '../../ProductsBrandPattern/ProductsBrandPattern'
|
|
6
|
+
import ListItems from './ListItems'
|
|
7
7
|
import styles from './ProjectItem.module.css'
|
|
8
8
|
|
|
9
9
|
const ProjectItem = ({
|
|
@@ -21,15 +21,10 @@ const ProjectItem = ({
|
|
|
21
21
|
}) => {
|
|
22
22
|
const {
|
|
23
23
|
projects,
|
|
24
|
-
onInsertAllTracks,
|
|
25
24
|
onProjectClick,
|
|
26
25
|
openedItem,
|
|
27
26
|
setOpenedItem,
|
|
28
27
|
} = useContext(ProjectsListContext)
|
|
29
|
-
const [showAllTracks, setShowAllTracks] = useState(false)
|
|
30
|
-
|
|
31
|
-
const visibleTracks = useMemo(() => allTracks.slice(0, 6), [allTracks])
|
|
32
|
-
const extraTracks = useMemo(() => allTracks.slice(6), [allTracks])
|
|
33
28
|
|
|
34
29
|
const handleClickProject = useCallback(() => {
|
|
35
30
|
if (failed) return
|
|
@@ -39,29 +34,11 @@ const ProjectItem = ({
|
|
|
39
34
|
setOpenedItem(null)
|
|
40
35
|
onProjectClick?.(project, false)
|
|
41
36
|
} else {
|
|
42
|
-
setShowAllTracks(false)
|
|
43
37
|
setOpenedItem(id)
|
|
44
38
|
onProjectClick?.(project, true)
|
|
45
39
|
}
|
|
46
40
|
}, [id, openedItem, setOpenedItem, onProjectClick, projects, failed])
|
|
47
41
|
|
|
48
|
-
const handleClickShowAllTracks = useCallback((e) => {
|
|
49
|
-
e.preventDefault()
|
|
50
|
-
e.stopPropagation()
|
|
51
|
-
setShowAllTracks(!showAllTracks)
|
|
52
|
-
}, [showAllTracks])
|
|
53
|
-
|
|
54
|
-
const handleInsertAllTracks = useCallback((e) => {
|
|
55
|
-
e.stopPropagation()
|
|
56
|
-
let tracksFiltered = []
|
|
57
|
-
if (type === 'voice') {
|
|
58
|
-
tracksFiltered = allTracks.filter((track) => !track.loading && track.transfers?.length > 0)
|
|
59
|
-
} else {
|
|
60
|
-
tracksFiltered = allTracks.filter((track) => !track.loading && track.audioUrl)
|
|
61
|
-
}
|
|
62
|
-
onInsertAllTracks?.(tracksFiltered)
|
|
63
|
-
}, [onInsertAllTracks, allTracks, type])
|
|
64
|
-
|
|
65
42
|
return (
|
|
66
43
|
<Flex
|
|
67
44
|
direction="column"
|
|
@@ -103,63 +80,15 @@ const ProjectItem = ({
|
|
|
103
80
|
</Flex>
|
|
104
81
|
</Flex>
|
|
105
82
|
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
{loading && (
|
|
117
|
-
<Flex direction="row" gap="3" p="5" align="center" justify="center">
|
|
118
|
-
<Spinner width={16} height={16} style={{ color: 'var(--neutral-alpha-10)' }} />
|
|
119
|
-
<Text size="2" style={{ color: 'var(--neutral-alpha-10)' }}>{labels.loading || 'Loading tracks...'}</Text>
|
|
120
|
-
</Flex>
|
|
121
|
-
)}
|
|
122
|
-
|
|
123
|
-
{allTracks.length > 0 && (
|
|
124
|
-
<Flex direction="column" gap="1">
|
|
125
|
-
{typeof children === 'function' ? (
|
|
126
|
-
<>
|
|
127
|
-
{children({ projectId: id, tracks: visibleTracks })}
|
|
128
|
-
{extraTracks.length > 0 && (
|
|
129
|
-
<Collapsible.Root open={showAllTracks} className={styles.extraTracksCollapsible}>
|
|
130
|
-
<Collapsible.Content className={styles.tracksContent}>
|
|
131
|
-
<Flex direction="column" gap="1" className={styles.extraTracksInner}>
|
|
132
|
-
{children({ projectId: id, tracks: extraTracks })}
|
|
133
|
-
</Flex>
|
|
134
|
-
</Collapsible.Content>
|
|
135
|
-
</Collapsible.Root>
|
|
136
|
-
)}
|
|
137
|
-
</>
|
|
138
|
-
) : children}
|
|
139
|
-
|
|
140
|
-
<Flex direction="row" gap="3" p="2" align="center" justify="center">
|
|
141
|
-
<Button variant="ghost" color="gray" style={{ flex: '1' }}
|
|
142
|
-
onClick={handleInsertAllTracks}
|
|
143
|
-
>
|
|
144
|
-
<ArrowLeftIcon width={16} height={16} /> {labels.insertAll || 'Insert all'}
|
|
145
|
-
</Button>
|
|
146
|
-
|
|
147
|
-
{allTracks.length > 6 && (
|
|
148
|
-
<>
|
|
149
|
-
<Separator orientation="vertical" />
|
|
150
|
-
|
|
151
|
-
<Button variant="ghost" color="gray" style={{ flex: '1' }} onClick={handleClickShowAllTracks}>
|
|
152
|
-
{showAllTracks ? labels.showLess || 'Show less' : labels.showMore || 'Show more'}
|
|
153
|
-
{showAllTracks ? <ChevronUpIcon width={16} height={16} /> : <ChevronDownIcon width={16} height={16} />}
|
|
154
|
-
</Button>
|
|
155
|
-
</>
|
|
156
|
-
)}
|
|
157
|
-
</Flex>
|
|
158
|
-
</Flex>
|
|
159
|
-
)}
|
|
160
|
-
</Flex>
|
|
161
|
-
</Collapsible.Content>
|
|
162
|
-
</Collapsible.Root>
|
|
83
|
+
<ListItems
|
|
84
|
+
id={id}
|
|
85
|
+
type={type}
|
|
86
|
+
tracks={allTracks}
|
|
87
|
+
loading={loading}
|
|
88
|
+
labels={labels}
|
|
89
|
+
>
|
|
90
|
+
{children}
|
|
91
|
+
</ListItems>
|
|
163
92
|
</Flex>
|
|
164
93
|
)
|
|
165
94
|
}
|
|
@@ -51,47 +51,3 @@
|
|
|
51
51
|
background: rgba(216, 244, 246, 0.04);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
.tracksCollapsible {
|
|
56
|
-
width: 100%;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.extraTracksCollapsible {
|
|
60
|
-
width: 100%;
|
|
61
|
-
margin-top: calc(-1 * var(--space-1));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.extraTracksInner {
|
|
65
|
-
padding-top: var(--space-1);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.tracksContent {
|
|
69
|
-
overflow: hidden;
|
|
70
|
-
width: 100%;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.tracksContent[data-state='open'] {
|
|
74
|
-
animation: projectItemSlideDown 0.3s ease;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.tracksContent[data-state='closed'] {
|
|
78
|
-
animation: projectItemSlideUp 0.3s ease;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@keyframes projectItemSlideDown {
|
|
82
|
-
from {
|
|
83
|
-
height: 0;
|
|
84
|
-
}
|
|
85
|
-
to {
|
|
86
|
-
height: var(--radix-collapsible-content-height);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@keyframes projectItemSlideUp {
|
|
91
|
-
from {
|
|
92
|
-
height: var(--radix-collapsible-content-height);
|
|
93
|
-
}
|
|
94
|
-
to {
|
|
95
|
-
height: 0;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Flex, Text, Separator, Spinner, Button } from '@radix-ui/themes'
|
|
2
|
+
import { Collapsible } from 'radix-ui'
|
|
3
|
+
import { useState, useContext, useCallback, useMemo, useEffect } from 'react'
|
|
4
|
+
import { ArrowLeftIcon, NoMusicIcon, ChevronDownIcon, ChevronUpIcon } from '../../../icons'
|
|
5
|
+
import { ProjectsListContext } from '../context'
|
|
6
|
+
import styles from './ListStems.module.css'
|
|
7
|
+
|
|
8
|
+
const ListStems = ({
|
|
9
|
+
id,
|
|
10
|
+
type,
|
|
11
|
+
tracks: allTracks = [],
|
|
12
|
+
loading = false,
|
|
13
|
+
children,
|
|
14
|
+
labels = {},
|
|
15
|
+
open,
|
|
16
|
+
}) => {
|
|
17
|
+
const { onInsertAllTracks, openedItem } = useContext(ProjectsListContext)
|
|
18
|
+
const isOpen = open ?? openedItem === id
|
|
19
|
+
const [showAllTracks, setShowAllTracks] = useState(false)
|
|
20
|
+
|
|
21
|
+
const visibleTracks = useMemo(() => allTracks.slice(0, 6), [allTracks])
|
|
22
|
+
const extraTracks = useMemo(() => allTracks.slice(6), [allTracks])
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (openedItem !== id) {
|
|
26
|
+
setShowAllTracks(false)
|
|
27
|
+
}
|
|
28
|
+
}, [openedItem, id])
|
|
29
|
+
|
|
30
|
+
const handleClickShowAllTracks = useCallback((e) => {
|
|
31
|
+
e.preventDefault()
|
|
32
|
+
e.stopPropagation()
|
|
33
|
+
setShowAllTracks(!showAllTracks)
|
|
34
|
+
}, [showAllTracks])
|
|
35
|
+
|
|
36
|
+
const handleInsertAllTracks = useCallback((e) => {
|
|
37
|
+
e.stopPropagation()
|
|
38
|
+
let tracksFiltered = []
|
|
39
|
+
if (type === 'voice') {
|
|
40
|
+
tracksFiltered = allTracks.filter((track) => !track.loading && track.transfers?.length > 0)
|
|
41
|
+
} else {
|
|
42
|
+
tracksFiltered = allTracks.filter((track) => !track.loading && track.audioUrl)
|
|
43
|
+
}
|
|
44
|
+
onInsertAllTracks?.(tracksFiltered)
|
|
45
|
+
}, [onInsertAllTracks, allTracks, type])
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Collapsible.Root open={isOpen} className={styles.tracksCollapsible}>
|
|
49
|
+
<Collapsible.Content className={styles.tracksContent}>
|
|
50
|
+
<Flex direction="column" pt="2">
|
|
51
|
+
{type !== 'voice' && allTracks.length === 0 && !loading && (
|
|
52
|
+
<Flex direction="row" gap="3" p="5" pt="2" align="center" justify="center">
|
|
53
|
+
<NoMusicIcon width={16} height={16} style={{ color: 'var(--neutral-alpha-10)' }} />
|
|
54
|
+
<Text size="2" style={{ color: 'var(--neutral-alpha-10)' }}>{labels.noTracks || 'This file has no tracks'}</Text>
|
|
55
|
+
</Flex>
|
|
56
|
+
)}
|
|
57
|
+
|
|
58
|
+
{loading && (
|
|
59
|
+
<Flex direction="row" gap="3" p="5" align="center" justify="center">
|
|
60
|
+
<Spinner width={16} height={16} style={{ color: 'var(--neutral-alpha-10)' }} />
|
|
61
|
+
<Text size="2" style={{ color: 'var(--neutral-alpha-10)' }}>{labels.loading || 'Loading tracks...'}</Text>
|
|
62
|
+
</Flex>
|
|
63
|
+
)}
|
|
64
|
+
|
|
65
|
+
{allTracks.length > 0 && (
|
|
66
|
+
<Flex direction="column" gap="1">
|
|
67
|
+
{typeof children === 'function' ? (
|
|
68
|
+
<>
|
|
69
|
+
{children({ projectId: id, tracks: visibleTracks })}
|
|
70
|
+
{extraTracks.length > 0 && (
|
|
71
|
+
<Collapsible.Root open={showAllTracks} className={styles.extraTracksCollapsible}>
|
|
72
|
+
<Collapsible.Content className={styles.tracksContent}>
|
|
73
|
+
<Flex direction="column" gap="1" className={styles.extraTracksInner}>
|
|
74
|
+
{children({ projectId: id, tracks: extraTracks })}
|
|
75
|
+
</Flex>
|
|
76
|
+
</Collapsible.Content>
|
|
77
|
+
</Collapsible.Root>
|
|
78
|
+
)}
|
|
79
|
+
</>
|
|
80
|
+
) : children}
|
|
81
|
+
|
|
82
|
+
<Flex direction="row" gap="3" p="2" align="center" justify="center">
|
|
83
|
+
<Button variant="ghost" color="gray" style={{ flex: '1' }}
|
|
84
|
+
onClick={handleInsertAllTracks}
|
|
85
|
+
>
|
|
86
|
+
<ArrowLeftIcon width={16} height={16} /> {labels.insertAll || 'Insert all'}
|
|
87
|
+
</Button>
|
|
88
|
+
|
|
89
|
+
{allTracks.length > 6 && (
|
|
90
|
+
<>
|
|
91
|
+
<Separator orientation="vertical" />
|
|
92
|
+
|
|
93
|
+
<Button variant="ghost" color="gray" style={{ flex: '1' }} onClick={handleClickShowAllTracks}>
|
|
94
|
+
{showAllTracks ? labels.showLess || 'Show less' : labels.showMore || 'Show more'}
|
|
95
|
+
{showAllTracks ? <ChevronUpIcon width={16} height={16} /> : <ChevronDownIcon width={16} height={16} />}
|
|
96
|
+
</Button>
|
|
97
|
+
</>
|
|
98
|
+
)}
|
|
99
|
+
</Flex>
|
|
100
|
+
</Flex>
|
|
101
|
+
)}
|
|
102
|
+
</Flex>
|
|
103
|
+
</Collapsible.Content>
|
|
104
|
+
</Collapsible.Root>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default ListStems
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.tracksCollapsible {
|
|
2
|
+
width: 100%;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.extraTracksCollapsible {
|
|
6
|
+
width: 100%;
|
|
7
|
+
margin-top: calc(-1 * var(--space-1));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.extraTracksInner {
|
|
11
|
+
padding-top: var(--space-1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.tracksContent {
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
width: 100%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.tracksContent[data-state='open'] {
|
|
20
|
+
animation: projectItemSlideDown 0.3s ease;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.tracksContent[data-state='closed'] {
|
|
24
|
+
animation: projectItemSlideUp 0.3s ease;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@keyframes projectItemSlideDown {
|
|
28
|
+
from {
|
|
29
|
+
height: 0;
|
|
30
|
+
}
|
|
31
|
+
to {
|
|
32
|
+
height: var(--radix-collapsible-content-height);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@keyframes projectItemSlideUp {
|
|
37
|
+
from {
|
|
38
|
+
height: var(--radix-collapsible-content-height);
|
|
39
|
+
}
|
|
40
|
+
to {
|
|
41
|
+
height: 0;
|
|
42
|
+
}
|
|
43
|
+
}
|