@moises.ai/design-system 3.12.2 → 3.13.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 +2775 -2702
- package/package.json +1 -1
- package/src/components/DropdownMenu/DropdownMenu.jsx +3 -0
- package/src/components/DropdownMenu/DropdownMenu.stories.jsx +86 -0
- package/src/components/SpecialDialog/SpecialDialog.jsx +65 -0
- package/src/components/SpecialDialog/SpecialDialog.module.css +69 -0
- package/src/components/SpecialDialog/SpecialDialog.stories.jsx +146 -0
- package/src/index.jsx +1 -0
- package/src/lib/menu/renderItem.jsx +11 -2
package/package.json
CHANGED
|
@@ -20,6 +20,7 @@ export const DropdownMenu = memo(
|
|
|
20
20
|
closeOnSelect = true,
|
|
21
21
|
sideOffset = 5,
|
|
22
22
|
matchTriggerWidth = false,
|
|
23
|
+
showSelectedItemBackground = true,
|
|
23
24
|
wrapCloseMenu,
|
|
24
25
|
...props
|
|
25
26
|
}) => {
|
|
@@ -87,6 +88,7 @@ export const DropdownMenu = memo(
|
|
|
87
88
|
onSelectionChange,
|
|
88
89
|
closeOnSelect,
|
|
89
90
|
closeMenu,
|
|
91
|
+
showSelectedItemBackground,
|
|
90
92
|
),
|
|
91
93
|
)}
|
|
92
94
|
</ScrollArea>
|
|
@@ -116,6 +118,7 @@ export const DropdownMenu = memo(
|
|
|
116
118
|
onSelectionChange,
|
|
117
119
|
closeOnSelect,
|
|
118
120
|
closeMenu,
|
|
121
|
+
showSelectedItemBackground,
|
|
119
122
|
),
|
|
120
123
|
)}
|
|
121
124
|
</DropdownMenuRadix.Content>
|
|
@@ -231,6 +231,58 @@ The \`options\` prop accepts an array of objects with the following types:
|
|
|
231
231
|
defaultValue: { summary: 'false' },
|
|
232
232
|
},
|
|
233
233
|
},
|
|
234
|
+
maxHeight: {
|
|
235
|
+
control: { type: 'number' },
|
|
236
|
+
description:
|
|
237
|
+
'Maximum content height. When provided, wraps menu content in a vertical ScrollArea',
|
|
238
|
+
table: {
|
|
239
|
+
type: { summary: 'number | string' },
|
|
240
|
+
defaultValue: { summary: 'undefined' },
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
sideOffset: {
|
|
244
|
+
control: { type: 'number' },
|
|
245
|
+
description: 'Distance in pixels between trigger and menu content',
|
|
246
|
+
table: {
|
|
247
|
+
type: { summary: 'number' },
|
|
248
|
+
defaultValue: { summary: '5' },
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
showSelectedItemBackground: {
|
|
252
|
+
control: { type: 'boolean' },
|
|
253
|
+
description:
|
|
254
|
+
'When true, checked checkbox items get the selected background style',
|
|
255
|
+
table: {
|
|
256
|
+
type: { summary: 'boolean' },
|
|
257
|
+
defaultValue: { summary: 'true' },
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
open: {
|
|
261
|
+
control: { type: 'boolean' },
|
|
262
|
+
description:
|
|
263
|
+
'Controlled open state. When defined, menu visibility is controlled externally',
|
|
264
|
+
table: {
|
|
265
|
+
type: { summary: 'boolean' },
|
|
266
|
+
defaultValue: { summary: 'undefined' },
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
onOpenChange: {
|
|
270
|
+
control: false,
|
|
271
|
+
description: 'Callback fired whenever open state changes',
|
|
272
|
+
table: {
|
|
273
|
+
type: { summary: '(open: boolean) => void' },
|
|
274
|
+
defaultValue: { summary: 'undefined' },
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
wrapCloseMenu: {
|
|
278
|
+
control: false,
|
|
279
|
+
description:
|
|
280
|
+
'Allows wrapping internal close behavior and receiving a close callback',
|
|
281
|
+
table: {
|
|
282
|
+
type: { summary: '(close: () => void) => () => void' },
|
|
283
|
+
defaultValue: { summary: 'undefined' },
|
|
284
|
+
},
|
|
285
|
+
},
|
|
234
286
|
},
|
|
235
287
|
}
|
|
236
288
|
|
|
@@ -416,6 +468,40 @@ export const MatchTriggerWidth = {
|
|
|
416
468
|
),
|
|
417
469
|
}
|
|
418
470
|
|
|
471
|
+
export const CheckboxWithoutSelectedBackground = {
|
|
472
|
+
args: {
|
|
473
|
+
showSelectedItemBackground: false,
|
|
474
|
+
side: 'bottom',
|
|
475
|
+
align: 'end',
|
|
476
|
+
trigger: (
|
|
477
|
+
<IconButton>
|
|
478
|
+
<DotsVerticalIcon />
|
|
479
|
+
</IconButton>
|
|
480
|
+
),
|
|
481
|
+
options: [
|
|
482
|
+
{
|
|
483
|
+
type: 'checkbox',
|
|
484
|
+
key: 'option-1',
|
|
485
|
+
label: 'Voice',
|
|
486
|
+
checked: true,
|
|
487
|
+
onChange: (checked) => console.log('Voice:', checked),
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
type: 'checkbox',
|
|
491
|
+
key: 'option-2',
|
|
492
|
+
label: 'Instrumental',
|
|
493
|
+
checked: false,
|
|
494
|
+
onChange: (checked) => console.log('Instrumental:', checked),
|
|
495
|
+
},
|
|
496
|
+
],
|
|
497
|
+
},
|
|
498
|
+
render: (args) => (
|
|
499
|
+
<Flex justify="center" align="start" height="300px">
|
|
500
|
+
<DropdownMenu {...args} />
|
|
501
|
+
</Flex>
|
|
502
|
+
),
|
|
503
|
+
}
|
|
504
|
+
|
|
419
505
|
export const CustomWithSwitch = {
|
|
420
506
|
render: () => {
|
|
421
507
|
const [access, setAccess] = useState('private')
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import classNames from 'classnames'
|
|
2
|
+
import { Dialog, Flex } from '@radix-ui/themes'
|
|
3
|
+
import { CloseIcon } from '../../icons/CloseIcon'
|
|
4
|
+
import styles from './SpecialDialog.module.css'
|
|
5
|
+
|
|
6
|
+
export const SpecialDialog = ({
|
|
7
|
+
title,
|
|
8
|
+
description,
|
|
9
|
+
open,
|
|
10
|
+
onOpenChange,
|
|
11
|
+
children,
|
|
12
|
+
icon,
|
|
13
|
+
image,
|
|
14
|
+
imageAlt = '',
|
|
15
|
+
className,
|
|
16
|
+
...props
|
|
17
|
+
}) => {
|
|
18
|
+
const showImage = Boolean(image)
|
|
19
|
+
const showIcon = Boolean(icon) && !showImage
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Dialog.Root open={open} onOpenChange={onOpenChange}>
|
|
23
|
+
<Dialog.Content
|
|
24
|
+
className={classNames(styles.content, className)}
|
|
25
|
+
{...props}
|
|
26
|
+
>
|
|
27
|
+
<div className={styles.hero}>
|
|
28
|
+
{showImage ? (
|
|
29
|
+
<img
|
|
30
|
+
className={styles.heroImage}
|
|
31
|
+
src={image}
|
|
32
|
+
alt={imageAlt}
|
|
33
|
+
/>
|
|
34
|
+
) : null}
|
|
35
|
+
{showIcon ? <div className={styles.heroIcon}>{icon}</div> : null}
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<Dialog.Close asChild>
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
className={styles.close}
|
|
42
|
+
aria-label="Close"
|
|
43
|
+
>
|
|
44
|
+
<CloseIcon width={18} height={18} color="white" />
|
|
45
|
+
</button>
|
|
46
|
+
</Dialog.Close>
|
|
47
|
+
|
|
48
|
+
<Flex p="5" align="center" direction="column" gap="5">
|
|
49
|
+
<Flex align="center" direction="column" gap="2">
|
|
50
|
+
<Dialog.Title size="5" align="center" weight="bold" mb="0">
|
|
51
|
+
{title}
|
|
52
|
+
</Dialog.Title>
|
|
53
|
+
<Dialog.Description align="center" size="2" mb="0">
|
|
54
|
+
{description}
|
|
55
|
+
</Dialog.Description>
|
|
56
|
+
</Flex>
|
|
57
|
+
|
|
58
|
+
{children}
|
|
59
|
+
</Flex>
|
|
60
|
+
</Dialog.Content>
|
|
61
|
+
</Dialog.Root>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
SpecialDialog.displayName = 'SpecialDialog'
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* Overrides Radix .rt-BaseDialogContent (shadow reads as an outline) */
|
|
2
|
+
.content {
|
|
3
|
+
position: relative;
|
|
4
|
+
width: 360px;
|
|
5
|
+
max-width: 360px;
|
|
6
|
+
padding: 0;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
border: none !important;
|
|
9
|
+
outline: none !important;
|
|
10
|
+
box-shadow: none !important;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.content:focus,
|
|
14
|
+
.content:focus-visible {
|
|
15
|
+
outline: none !important;
|
|
16
|
+
box-shadow: none !important;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.hero {
|
|
20
|
+
position: relative;
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
height: 180px;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
background: linear-gradient(180deg, #013641 0%, #011a1f 100%);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.heroImage {
|
|
30
|
+
position: absolute;
|
|
31
|
+
inset: 0;
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
object-fit: cover;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.heroIcon {
|
|
38
|
+
position: relative;
|
|
39
|
+
z-index: 1;
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.close {
|
|
46
|
+
position: absolute;
|
|
47
|
+
top: 16px;
|
|
48
|
+
right: 16px;
|
|
49
|
+
z-index: 2;
|
|
50
|
+
margin: 0;
|
|
51
|
+
padding: 0;
|
|
52
|
+
border: none;
|
|
53
|
+
background: transparent;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
color: var(--gray-1, #fcfcfd);
|
|
56
|
+
display: inline-flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
line-height: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.close:focus-visible {
|
|
63
|
+
outline: 2px solid var(--cyan-8, #00a2c7);
|
|
64
|
+
outline-offset: 2px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.close:hover {
|
|
68
|
+
opacity: 0.88;
|
|
69
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { StarFilledIcon } from '@radix-ui/react-icons'
|
|
3
|
+
import { fn } from '@storybook/test'
|
|
4
|
+
import { SpecialDialog } from './SpecialDialog'
|
|
5
|
+
import { Button } from '../Button/Button'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/SpecialDialog',
|
|
9
|
+
component: SpecialDialog,
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
docs: {
|
|
13
|
+
description: {
|
|
14
|
+
component: `
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
\`\`\`jsx
|
|
18
|
+
import { SpecialDialog, Button } from '@moises.ai/design-system'
|
|
19
|
+
|
|
20
|
+
const MyComponent = () => {
|
|
21
|
+
const [open, setOpen] = useState(false)
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<Button type="button" onClick={() => setOpen(true)}>
|
|
25
|
+
Open dialog
|
|
26
|
+
</Button>
|
|
27
|
+
<SpecialDialog
|
|
28
|
+
open={open}
|
|
29
|
+
onOpenChange={setOpen}
|
|
30
|
+
icon={<StarFilledIcon width={48} height={48} color="white" />}
|
|
31
|
+
title="Special Dialog"
|
|
32
|
+
description="This is a special dialog"
|
|
33
|
+
>
|
|
34
|
+
<Button variant="solid" color="cyan">Action</Button>
|
|
35
|
+
</SpecialDialog>
|
|
36
|
+
</>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
\`\`\`
|
|
40
|
+
`,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
tags: ['autodocs'],
|
|
45
|
+
argTypes: {
|
|
46
|
+
children: {
|
|
47
|
+
description:
|
|
48
|
+
'The dialog content - can be button, text or icon',
|
|
49
|
+
control: { type: 'text' },
|
|
50
|
+
table: {
|
|
51
|
+
type: { summary: 'React.ReactNode' },
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
open: {
|
|
55
|
+
description: 'When true, the dialog is visible (controlled)',
|
|
56
|
+
control: { type: 'boolean' },
|
|
57
|
+
table: {
|
|
58
|
+
type: { summary: 'boolean' },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
onOpenChange: {
|
|
62
|
+
action: 'openChange',
|
|
63
|
+
description: 'Called with the next open state (use to sync controlled `open`)',
|
|
64
|
+
table: {
|
|
65
|
+
type: { summary: '(open: boolean) => void' },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
icon: {
|
|
69
|
+
description:
|
|
70
|
+
'Optional icon centered in the header area (ignored if `image` is set)',
|
|
71
|
+
control: { disable: true },
|
|
72
|
+
table: {
|
|
73
|
+
type: { summary: 'React.ReactNode' },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
image: {
|
|
77
|
+
description: 'Optional image URL for the header; `object-fit: cover`, fills the 180px header',
|
|
78
|
+
control: { type: 'text' },
|
|
79
|
+
table: {
|
|
80
|
+
type: { summary: 'string' },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
imageAlt: {
|
|
84
|
+
description: 'Alt text for the header image',
|
|
85
|
+
control: { type: 'text' },
|
|
86
|
+
table: {
|
|
87
|
+
type: { summary: 'string' },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const Default = {
|
|
94
|
+
render: (args) => {
|
|
95
|
+
const [open, setOpen] = useState(false)
|
|
96
|
+
const onOpenChange = (next) => {
|
|
97
|
+
setOpen(next)
|
|
98
|
+
args.onOpenChange?.(next)
|
|
99
|
+
}
|
|
100
|
+
return (
|
|
101
|
+
<>
|
|
102
|
+
<Button type="button" variant="solid" color="cyan" onClick={() => setOpen(true)}>
|
|
103
|
+
Open dialog
|
|
104
|
+
</Button>
|
|
105
|
+
|
|
106
|
+
<SpecialDialog {...args} open={open} onOpenChange={onOpenChange}>
|
|
107
|
+
<Button size="4" variant="solid" color="cyan" style={{ width: '100%' }}>Action</Button>
|
|
108
|
+
</SpecialDialog>
|
|
109
|
+
</>
|
|
110
|
+
)
|
|
111
|
+
},
|
|
112
|
+
args: {
|
|
113
|
+
onOpenChange: fn(),
|
|
114
|
+
icon: <StarFilledIcon width={48} height={48} color="white" />,
|
|
115
|
+
title: 'Special Dialog',
|
|
116
|
+
description: 'This is a special dialog',
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const WithHeaderImage = {
|
|
121
|
+
render: (args) => {
|
|
122
|
+
const [open, setOpen] = useState(false)
|
|
123
|
+
const onOpenChange = (next) => {
|
|
124
|
+
setOpen(next)
|
|
125
|
+
args.onOpenChange?.(next)
|
|
126
|
+
}
|
|
127
|
+
return (
|
|
128
|
+
<>
|
|
129
|
+
<Button type="button" variant="solid" color="cyan" onClick={() => setOpen(true)}>
|
|
130
|
+
Open dialog
|
|
131
|
+
</Button>
|
|
132
|
+
<SpecialDialog {...args} open={open} onOpenChange={onOpenChange}>
|
|
133
|
+
<Button size="4" variant="solid" color="cyan" style={{ width: '100%' }}>Action</Button>
|
|
134
|
+
</SpecialDialog>
|
|
135
|
+
</>
|
|
136
|
+
)
|
|
137
|
+
},
|
|
138
|
+
args: {
|
|
139
|
+
onOpenChange: fn(),
|
|
140
|
+
image:
|
|
141
|
+
'https://images.unsplash.com/photo-1511379938547-c1f69419868d?w=720&h=360&fit=crop',
|
|
142
|
+
imageAlt: 'Studio headphones',
|
|
143
|
+
title: 'Special Dialog',
|
|
144
|
+
description: 'Header uses an image with cover fit. Example action button is full width.',
|
|
145
|
+
},
|
|
146
|
+
}
|
package/src/index.jsx
CHANGED
|
@@ -148,3 +148,4 @@ export { TrackHeader } from './components/TrackHeader/TrackHeader'
|
|
|
148
148
|
export { useForm } from './components/useForm/useForm'
|
|
149
149
|
export { VoiceConversionForm } from './components/VoiceConversionForm/VoiceConversionForm'
|
|
150
150
|
export { Waveform } from './components/VoiceConversionForm/Waveform/Waveform'
|
|
151
|
+
export { SpecialDialog } from './components/SpecialDialog/SpecialDialog'
|
|
@@ -15,6 +15,7 @@ export const createRenderItem = (MenuPrimitives) => {
|
|
|
15
15
|
onSelectionChange,
|
|
16
16
|
closeOnSelect = true,
|
|
17
17
|
closeMenu,
|
|
18
|
+
showSelectedItemBackground = true,
|
|
18
19
|
) => {
|
|
19
20
|
switch (opt.type) {
|
|
20
21
|
case 'custom':
|
|
@@ -81,7 +82,14 @@ export const createRenderItem = (MenuPrimitives) => {
|
|
|
81
82
|
|
|
82
83
|
<MenuPrimitives.SubContent className={styles.menuSubContent}>
|
|
83
84
|
{opt?.children?.map((child) =>
|
|
84
|
-
renderItem(
|
|
85
|
+
renderItem(
|
|
86
|
+
child,
|
|
87
|
+
size,
|
|
88
|
+
onSelectionChange,
|
|
89
|
+
closeOnSelect,
|
|
90
|
+
closeMenu,
|
|
91
|
+
showSelectedItemBackground,
|
|
92
|
+
),
|
|
85
93
|
)}
|
|
86
94
|
</MenuPrimitives.SubContent>
|
|
87
95
|
</MenuPrimitives.Sub>
|
|
@@ -151,7 +159,8 @@ export const createRenderItem = (MenuPrimitives) => {
|
|
|
151
159
|
styles.menuItem,
|
|
152
160
|
styles.menuCheckboxItem,
|
|
153
161
|
{
|
|
154
|
-
[styles.menuItemSelected]:
|
|
162
|
+
[styles.menuItemSelected]:
|
|
163
|
+
opt.checked && showSelectedItemBackground,
|
|
155
164
|
[styles[`menuItem-size-${size}`]]: size,
|
|
156
165
|
[styles.red]: opt.color === 'red' && !opt.disabled,
|
|
157
166
|
[styles.cyan]: opt.color === 'cyan' && !opt.disabled,
|