@registrucentras/rc-ses-react-components 2.1.0 → 2.2.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/components/form/inputs/Select/Select.utils.d.ts +9 -0
- package/dist/components/form/inputs/Select/components/OptionCheckbox.d.ts +5 -0
- package/dist/components/form/inputs/Select/index.d.ts +18 -8
- package/dist/components/overlays/BottomSheet/index.d.ts +17 -0
- package/dist/components/overlays/BottomSheet/useSwipeToDismiss.d.ts +17 -0
- package/dist/library/index.d.ts +2 -1
- package/dist/library/types.d.ts +2 -0
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +3492 -3081
- package/package.json +1 -1
- package/src/components/form/inputs/Select/Select.utils.ts +24 -0
- package/src/components/form/inputs/Select/components/OptionCheckbox.tsx +46 -0
- package/src/components/form/inputs/Select/index.test.tsx +127 -0
- package/src/components/form/inputs/Select/index.tsx +426 -181
- package/src/components/overlays/BottomSheet/index.test.tsx +256 -0
- package/src/components/overlays/BottomSheet/index.tsx +242 -0
- package/src/components/overlays/BottomSheet/useSwipeToDismiss.test.ts +295 -0
- package/src/components/overlays/BottomSheet/useSwipeToDismiss.ts +138 -0
- package/src/i18n/namespaces/input/en.json +11 -0
- package/src/i18n/namespaces/input/lt.json +11 -0
- package/src/library/index.ts +2 -0
- package/src/library/types.ts +2 -0
- package/src/stories/atoms/Select.stories.tsx +33 -5
- package/src/stories/organisms/BottomSheet.stories.tsx +291 -0
- package/src/theme/light/MuiAutocomplete.ts +43 -19
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
2
|
+
import { beforeAll, describe, expect, it, vi } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import RcSesBottomSheet from '.'
|
|
5
|
+
|
|
6
|
+
describe('RcSesBottomSheet', () => {
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
// jsdom does not implement pointer capture; the handle calls it unconditionally.
|
|
9
|
+
Element.prototype.setPointerCapture = vi.fn()
|
|
10
|
+
Element.prototype.releasePointerCapture = vi.fn()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('renders as a dialog with the title as its accessible name', () => {
|
|
14
|
+
render(
|
|
15
|
+
<RcSesBottomSheet open onClose={vi.fn()} title='Pasirinkite padalinį'>
|
|
16
|
+
Content
|
|
17
|
+
</RcSesBottomSheet>,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
const dialog = screen.getByRole('dialog')
|
|
21
|
+
expect(dialog).toHaveAccessibleName('Pasirinkite padalinį')
|
|
22
|
+
expect(screen.getByText('Content')).toBeInTheDocument()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('renders without a header when neither title nor showBack is given', () => {
|
|
26
|
+
render(
|
|
27
|
+
<RcSesBottomSheet open onClose={vi.fn()}>
|
|
28
|
+
Content
|
|
29
|
+
</RcSesBottomSheet>,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
expect(screen.getByText('Content')).toBeInTheDocument()
|
|
33
|
+
expect(screen.queryAllByRole('button')).toHaveLength(0)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('renders the primary and secondary action buttons with their labels', () => {
|
|
37
|
+
const onPrimaryAction = vi.fn()
|
|
38
|
+
const onSecondaryAction = vi.fn()
|
|
39
|
+
render(
|
|
40
|
+
<RcSesBottomSheet
|
|
41
|
+
open
|
|
42
|
+
onClose={vi.fn()}
|
|
43
|
+
title='Filtrai'
|
|
44
|
+
primaryActionLabel='Taikyti'
|
|
45
|
+
onPrimaryAction={onPrimaryAction}
|
|
46
|
+
secondaryActionLabel='Atšaukti'
|
|
47
|
+
onSecondaryAction={onSecondaryAction}
|
|
48
|
+
>
|
|
49
|
+
Content
|
|
50
|
+
</RcSesBottomSheet>,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
fireEvent.click(screen.getByRole('button', { name: 'Taikyti' }))
|
|
54
|
+
fireEvent.click(screen.getByRole('button', { name: 'Atšaukti' }))
|
|
55
|
+
|
|
56
|
+
expect(onPrimaryAction).toHaveBeenCalledTimes(1)
|
|
57
|
+
expect(onSecondaryAction).toHaveBeenCalledTimes(1)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('renders no footer when no action label is given', () => {
|
|
61
|
+
render(
|
|
62
|
+
<RcSesBottomSheet open onClose={vi.fn()} title='Filtrai'>
|
|
63
|
+
Content
|
|
64
|
+
</RcSesBottomSheet>,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
expect(screen.queryAllByRole('button')).toHaveLength(0)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('does not render a back button by default', () => {
|
|
71
|
+
render(
|
|
72
|
+
<RcSesBottomSheet open onClose={vi.fn()} title='Filtrai'>
|
|
73
|
+
Content
|
|
74
|
+
</RcSesBottomSheet>,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
expect(screen.queryAllByRole('button')).toHaveLength(0)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('calls onBack, not onClose, when the back button is pressed', () => {
|
|
81
|
+
const onBack = vi.fn()
|
|
82
|
+
const onClose = vi.fn()
|
|
83
|
+
render(
|
|
84
|
+
<RcSesBottomSheet open onClose={onClose} onBack={onBack} showBack title='2 iš 2'>
|
|
85
|
+
Content
|
|
86
|
+
</RcSesBottomSheet>,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
fireEvent.click(screen.getByRole('button'))
|
|
90
|
+
|
|
91
|
+
expect(onBack).toHaveBeenCalledTimes(1)
|
|
92
|
+
expect(onClose).not.toHaveBeenCalled()
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('closes on Escape even when backdrop close is disabled', () => {
|
|
96
|
+
const onClose = vi.fn()
|
|
97
|
+
render(
|
|
98
|
+
<RcSesBottomSheet open onClose={onClose} title='Filtrai' disableBackdropClose>
|
|
99
|
+
Content
|
|
100
|
+
</RcSesBottomSheet>,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
fireEvent.keyDown(screen.getByRole('dialog'), { key: 'Escape' })
|
|
104
|
+
|
|
105
|
+
expect(onClose).toHaveBeenCalledWith(expect.anything(), 'escapeKeyDown')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('closes on backdrop click by default', () => {
|
|
109
|
+
const onClose = vi.fn()
|
|
110
|
+
render(
|
|
111
|
+
<RcSesBottomSheet open onClose={onClose} title='Filtrai'>
|
|
112
|
+
Content
|
|
113
|
+
</RcSesBottomSheet>,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
fireEvent.click(document.querySelector('.MuiBackdrop-root') as HTMLElement)
|
|
117
|
+
|
|
118
|
+
expect(onClose).toHaveBeenCalledWith(expect.anything(), 'backdropClick')
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('ignores backdrop clicks when disableBackdropClose is set', () => {
|
|
122
|
+
const onClose = vi.fn()
|
|
123
|
+
render(
|
|
124
|
+
<RcSesBottomSheet open onClose={onClose} title='Filtrai' disableBackdropClose>
|
|
125
|
+
Content
|
|
126
|
+
</RcSesBottomSheet>,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
fireEvent.click(document.querySelector('.MuiBackdrop-root') as HTMLElement)
|
|
130
|
+
|
|
131
|
+
expect(onClose).not.toHaveBeenCalled()
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('always anchors the paper to the bottom of the viewport - there is no desktop presentation', () => {
|
|
135
|
+
render(
|
|
136
|
+
<RcSesBottomSheet open onClose={vi.fn()} title='Pasirinkite padalinį'>
|
|
137
|
+
Content
|
|
138
|
+
</RcSesBottomSheet>,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
expect(document.querySelector('.MuiDialog-container')).toHaveStyle({
|
|
142
|
+
alignItems: 'flex-end',
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it('caps the sheet width for size="md" instead of the sm full-bleed default', () => {
|
|
147
|
+
render(
|
|
148
|
+
<RcSesBottomSheet open onClose={vi.fn()} title='Filtrai' size='md'>
|
|
149
|
+
Content
|
|
150
|
+
</RcSesBottomSheet>,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
expect(document.querySelector('.MuiDialog-paper')).toHaveStyle({ maxWidth: '480px' })
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
it('dismisses via a swipe on the handle past the distance threshold', () => {
|
|
157
|
+
const onClose = vi.fn()
|
|
158
|
+
render(
|
|
159
|
+
<RcSesBottomSheet open onClose={onClose} title='Filtrai'>
|
|
160
|
+
Content
|
|
161
|
+
</RcSesBottomSheet>,
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
const handle = screen.getByTestId('rc-ses-bottom-sheet-handle')
|
|
165
|
+
fireEvent.pointerDown(handle, { clientY: 0, pointerId: 1, isPrimary: true })
|
|
166
|
+
fireEvent.pointerUp(handle, { clientY: 150, pointerId: 1 })
|
|
167
|
+
|
|
168
|
+
expect(onClose).toHaveBeenCalledWith(expect.anything(), 'swipeDown')
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
it('does not dismiss when the handle drag stays under the threshold', () => {
|
|
172
|
+
const onClose = vi.fn()
|
|
173
|
+
render(
|
|
174
|
+
<RcSesBottomSheet open onClose={onClose} title='Filtrai'>
|
|
175
|
+
Content
|
|
176
|
+
</RcSesBottomSheet>,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
const handle = screen.getByTestId('rc-ses-bottom-sheet-handle')
|
|
180
|
+
fireEvent.pointerDown(handle, { clientY: 0, pointerId: 1, isPrimary: true })
|
|
181
|
+
fireEvent.pointerUp(handle, { clientY: 10, pointerId: 1 })
|
|
182
|
+
|
|
183
|
+
expect(onClose).not.toHaveBeenCalled()
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('lets a caller-supplied aria-describedby win over the generated one', () => {
|
|
187
|
+
render(
|
|
188
|
+
<RcSesBottomSheet
|
|
189
|
+
open
|
|
190
|
+
onClose={vi.fn()}
|
|
191
|
+
title='Filtrai'
|
|
192
|
+
aria-describedby='external-description'
|
|
193
|
+
>
|
|
194
|
+
Content
|
|
195
|
+
</RcSesBottomSheet>,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
expect(screen.getByRole('dialog')).toHaveAttribute(
|
|
199
|
+
'aria-describedby',
|
|
200
|
+
'external-description',
|
|
201
|
+
)
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it('does not dismiss on a pointercancel, even past the distance threshold', () => {
|
|
205
|
+
const onClose = vi.fn()
|
|
206
|
+
render(
|
|
207
|
+
<RcSesBottomSheet open onClose={onClose} title='Filtrai'>
|
|
208
|
+
Content
|
|
209
|
+
</RcSesBottomSheet>,
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
const handle = screen.getByTestId('rc-ses-bottom-sheet-handle')
|
|
213
|
+
fireEvent.pointerDown(handle, { clientY: 0, pointerId: 1, isPrimary: true })
|
|
214
|
+
fireEvent.pointerCancel(handle, { clientY: 150, pointerId: 1 })
|
|
215
|
+
|
|
216
|
+
expect(onClose).not.toHaveBeenCalled()
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
it('ignores a right-click on the handle', () => {
|
|
220
|
+
const onClose = vi.fn()
|
|
221
|
+
render(
|
|
222
|
+
<RcSesBottomSheet open onClose={onClose} title='Filtrai'>
|
|
223
|
+
Content
|
|
224
|
+
</RcSesBottomSheet>,
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
const handle = screen.getByTestId('rc-ses-bottom-sheet-handle')
|
|
228
|
+
fireEvent.pointerDown(handle, {
|
|
229
|
+
clientY: 0,
|
|
230
|
+
pointerId: 1,
|
|
231
|
+
pointerType: 'mouse',
|
|
232
|
+
button: 2,
|
|
233
|
+
isPrimary: true,
|
|
234
|
+
})
|
|
235
|
+
fireEvent.pointerUp(handle, { clientY: 150, pointerId: 1, pointerType: 'mouse' })
|
|
236
|
+
|
|
237
|
+
expect(onClose).not.toHaveBeenCalled()
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
it('passes the real pointer event through to onClose on swipe-dismiss', () => {
|
|
241
|
+
const onClose = vi.fn()
|
|
242
|
+
render(
|
|
243
|
+
<RcSesBottomSheet open onClose={onClose} title='Filtrai'>
|
|
244
|
+
Content
|
|
245
|
+
</RcSesBottomSheet>,
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
const handle = screen.getByTestId('rc-ses-bottom-sheet-handle')
|
|
249
|
+
fireEvent.pointerDown(handle, { clientY: 0, pointerId: 1, isPrimary: true })
|
|
250
|
+
fireEvent.pointerUp(handle, { clientY: 150, pointerId: 1 })
|
|
251
|
+
|
|
252
|
+
const [event, reason] = onClose.mock.calls[0]
|
|
253
|
+
expect(reason).toBe('swipeDown')
|
|
254
|
+
expect(event).toMatchObject({ type: 'pointerup' })
|
|
255
|
+
})
|
|
256
|
+
})
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
Fade,
|
|
4
|
+
Dialog as MuiDialog,
|
|
5
|
+
DialogProps as MuiDialogProps,
|
|
6
|
+
Slide,
|
|
7
|
+
Typography,
|
|
8
|
+
} from '@mui/material'
|
|
9
|
+
import { TransitionProps } from '@mui/material/transitions'
|
|
10
|
+
import {
|
|
11
|
+
ReactElement,
|
|
12
|
+
ReactNode,
|
|
13
|
+
PointerEvent as ReactPointerEvent,
|
|
14
|
+
forwardRef,
|
|
15
|
+
useCallback,
|
|
16
|
+
useId,
|
|
17
|
+
} from 'react'
|
|
18
|
+
import { useTranslation } from 'react-i18next'
|
|
19
|
+
|
|
20
|
+
import ArrowLeftIcon from '@/assets/icons/ArrowLeftIcon'
|
|
21
|
+
import usePrefersReducedMotion from '@/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion'
|
|
22
|
+
import RcSesButton from '@/components/common/Button'
|
|
23
|
+
import { grey } from '@/theme/palette'
|
|
24
|
+
|
|
25
|
+
import useSwipeToDismiss from './useSwipeToDismiss'
|
|
26
|
+
|
|
27
|
+
const SHEET = {
|
|
28
|
+
handleWidth: '2.25rem',
|
|
29
|
+
handleHeight: '0.25rem',
|
|
30
|
+
handleHitAreaPadding: '0.75rem 0',
|
|
31
|
+
headerPadding: '0 1.5rem 1rem',
|
|
32
|
+
contentPadding: '0 1.5rem 1.5rem',
|
|
33
|
+
actionsPadding: '0.75rem 1.5rem 1.5rem',
|
|
34
|
+
cornerRadius: '1rem',
|
|
35
|
+
maxHeight: '85vh',
|
|
36
|
+
titleFontSize: '1rem',
|
|
37
|
+
titleLineHeight: '1.375rem',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const SHEET_MAX_WIDTH = {
|
|
41
|
+
sm: '100%',
|
|
42
|
+
md: '480px',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const MOTION_DURATION = { enter: 280, exit: 200 }
|
|
46
|
+
|
|
47
|
+
const SlideUpTransition = forwardRef<
|
|
48
|
+
HTMLDivElement,
|
|
49
|
+
TransitionProps & { children: ReactElement<unknown> }
|
|
50
|
+
>((props, ref) => <Slide direction='up' ref={ref} {...props} />)
|
|
51
|
+
|
|
52
|
+
export interface RcSesBottomSheetProps extends Omit<
|
|
53
|
+
MuiDialogProps,
|
|
54
|
+
'children' | 'title' | 'PaperProps' | 'maxWidth' | 'onClose' | 'slots' | 'slotProps'
|
|
55
|
+
> {
|
|
56
|
+
title?: string
|
|
57
|
+
children?: ReactNode
|
|
58
|
+
showBack?: boolean
|
|
59
|
+
onBack?: () => void
|
|
60
|
+
primaryActionLabel?: string
|
|
61
|
+
onPrimaryAction?: () => void
|
|
62
|
+
secondaryActionLabel?: string
|
|
63
|
+
onSecondaryAction?: () => void
|
|
64
|
+
disableBackdropClose?: boolean
|
|
65
|
+
size?: 'sm' | 'md'
|
|
66
|
+
onClose?: (
|
|
67
|
+
event: unknown,
|
|
68
|
+
reason: 'backdropClick' | 'escapeKeyDown' | 'swipeDown',
|
|
69
|
+
) => void
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function RcSesBottomSheet({
|
|
73
|
+
title,
|
|
74
|
+
children,
|
|
75
|
+
showBack = false,
|
|
76
|
+
onBack,
|
|
77
|
+
primaryActionLabel,
|
|
78
|
+
onPrimaryAction,
|
|
79
|
+
secondaryActionLabel,
|
|
80
|
+
onSecondaryAction,
|
|
81
|
+
onClose,
|
|
82
|
+
disableBackdropClose = false,
|
|
83
|
+
size = 'sm',
|
|
84
|
+
open,
|
|
85
|
+
'aria-labelledby': ariaLabelledByProp,
|
|
86
|
+
'aria-describedby': ariaDescribedByProp,
|
|
87
|
+
scroll = 'paper',
|
|
88
|
+
transitionDuration = MOTION_DURATION,
|
|
89
|
+
...props
|
|
90
|
+
}: RcSesBottomSheetProps) {
|
|
91
|
+
const prefersReducedMotion = usePrefersReducedMotion()
|
|
92
|
+
const { t } = useTranslation('input', { keyPrefix: 'components.RcSesBottomSheet' })
|
|
93
|
+
const titleId = useId()
|
|
94
|
+
const contentId = useId()
|
|
95
|
+
|
|
96
|
+
const hasFooter = !!primaryActionLabel || !!secondaryActionLabel
|
|
97
|
+
|
|
98
|
+
if (process.env.NODE_ENV !== 'production' && showBack && !onBack) {
|
|
99
|
+
// eslint-disable-next-line no-console
|
|
100
|
+
console.warn(
|
|
101
|
+
'RcSesBottomSheet: `showBack` is set without an `onBack` handler - the back button will do nothing.',
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const handleClose = (event: unknown, reason: 'backdropClick' | 'escapeKeyDown') => {
|
|
106
|
+
if (disableBackdropClose && reason === 'backdropClick') return
|
|
107
|
+
onClose?.(event, reason)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const handleSwipeDismiss = useCallback(
|
|
111
|
+
(event: ReactPointerEvent<HTMLElement>) => onClose?.(event, 'swipeDown'),
|
|
112
|
+
[onClose],
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
const { paperRef, isDragging, handleProps } = useSwipeToDismiss({
|
|
116
|
+
open,
|
|
117
|
+
disableTransform: prefersReducedMotion,
|
|
118
|
+
onDismiss: handleSwipeDismiss,
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<MuiDialog
|
|
123
|
+
open={open}
|
|
124
|
+
onClose={handleClose}
|
|
125
|
+
{...props}
|
|
126
|
+
maxWidth={false}
|
|
127
|
+
aria-labelledby={ariaLabelledByProp ?? (title ? titleId : undefined)}
|
|
128
|
+
aria-describedby={ariaDescribedByProp ?? (children != null ? contentId : undefined)}
|
|
129
|
+
scroll={scroll}
|
|
130
|
+
slots={{ transition: prefersReducedMotion ? Fade : SlideUpTransition }}
|
|
131
|
+
slotProps={{
|
|
132
|
+
container: { sx: { alignItems: 'flex-end' } },
|
|
133
|
+
paper: {
|
|
134
|
+
ref: paperRef,
|
|
135
|
+
sx: {
|
|
136
|
+
margin: 0,
|
|
137
|
+
width: '100%',
|
|
138
|
+
maxWidth: SHEET_MAX_WIDTH[size],
|
|
139
|
+
maxHeight: SHEET.maxHeight,
|
|
140
|
+
borderRadius: `${SHEET.cornerRadius} ${SHEET.cornerRadius} 0 0`,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
}}
|
|
144
|
+
transitionDuration={transitionDuration}
|
|
145
|
+
>
|
|
146
|
+
<Box
|
|
147
|
+
aria-hidden
|
|
148
|
+
data-testid='rc-ses-bottom-sheet-handle'
|
|
149
|
+
{...handleProps}
|
|
150
|
+
sx={{
|
|
151
|
+
display: 'flex',
|
|
152
|
+
justifyContent: 'center',
|
|
153
|
+
padding: SHEET.handleHitAreaPadding,
|
|
154
|
+
flexShrink: 0,
|
|
155
|
+
touchAction: 'none',
|
|
156
|
+
cursor: isDragging ? 'grabbing' : 'grab',
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
<Box
|
|
160
|
+
sx={{
|
|
161
|
+
width: SHEET.handleWidth,
|
|
162
|
+
height: SHEET.handleHeight,
|
|
163
|
+
borderRadius: 999,
|
|
164
|
+
backgroundColor: grey['300'],
|
|
165
|
+
}}
|
|
166
|
+
/>
|
|
167
|
+
</Box>
|
|
168
|
+
|
|
169
|
+
{(title || showBack) && (
|
|
170
|
+
<Box
|
|
171
|
+
sx={{
|
|
172
|
+
display: 'flex',
|
|
173
|
+
alignItems: 'center',
|
|
174
|
+
gap: 1.5,
|
|
175
|
+
padding: SHEET.headerPadding,
|
|
176
|
+
flexShrink: 0,
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
{showBack && (
|
|
180
|
+
<RcSesButton
|
|
181
|
+
iconOnly
|
|
182
|
+
variant='outlined'
|
|
183
|
+
color='grey'
|
|
184
|
+
onClick={onBack}
|
|
185
|
+
aria-label={t('aria.back')}
|
|
186
|
+
>
|
|
187
|
+
<ArrowLeftIcon />
|
|
188
|
+
</RcSesButton>
|
|
189
|
+
)}
|
|
190
|
+
{title && (
|
|
191
|
+
<Typography
|
|
192
|
+
id={titleId}
|
|
193
|
+
variant='h3'
|
|
194
|
+
component='h2'
|
|
195
|
+
sx={{
|
|
196
|
+
flex: 1,
|
|
197
|
+
fontSize: SHEET.titleFontSize,
|
|
198
|
+
lineHeight: SHEET.titleLineHeight,
|
|
199
|
+
}}
|
|
200
|
+
>
|
|
201
|
+
{title}
|
|
202
|
+
</Typography>
|
|
203
|
+
)}
|
|
204
|
+
</Box>
|
|
205
|
+
)}
|
|
206
|
+
|
|
207
|
+
{children != null && (
|
|
208
|
+
<Box
|
|
209
|
+
id={contentId}
|
|
210
|
+
sx={{ padding: SHEET.contentPadding, overflowY: 'auto', flex: 1 }}
|
|
211
|
+
>
|
|
212
|
+
{children}
|
|
213
|
+
</Box>
|
|
214
|
+
)}
|
|
215
|
+
|
|
216
|
+
{hasFooter && (
|
|
217
|
+
<Box
|
|
218
|
+
sx={{
|
|
219
|
+
display: 'flex',
|
|
220
|
+
justifyContent: 'flex-end',
|
|
221
|
+
gap: 1.5,
|
|
222
|
+
padding: SHEET.actionsPadding,
|
|
223
|
+
flexShrink: 0,
|
|
224
|
+
}}
|
|
225
|
+
>
|
|
226
|
+
{secondaryActionLabel && (
|
|
227
|
+
<RcSesButton variant='outlined' color='grey' onClick={onSecondaryAction}>
|
|
228
|
+
{secondaryActionLabel}
|
|
229
|
+
</RcSesButton>
|
|
230
|
+
)}
|
|
231
|
+
{primaryActionLabel && (
|
|
232
|
+
<RcSesButton variant='contained' onClick={onPrimaryAction}>
|
|
233
|
+
{primaryActionLabel}
|
|
234
|
+
</RcSesButton>
|
|
235
|
+
)}
|
|
236
|
+
</Box>
|
|
237
|
+
)}
|
|
238
|
+
</MuiDialog>
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export default RcSesBottomSheet
|