@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.
@@ -0,0 +1,291 @@
1
+ import {
2
+ List,
3
+ ListItemButton,
4
+ ListItemText,
5
+ Typography,
6
+ useMediaQuery,
7
+ } from '@mui/material'
8
+ import { Meta, StoryObj } from '@storybook/react-vite'
9
+ import { useState } from 'react'
10
+
11
+ import RcSesButton from '@/components/common/Button'
12
+ import RcSesBottomSheet, {
13
+ RcSesBottomSheetProps,
14
+ } from '@/components/overlays/BottomSheet'
15
+
16
+ const meta: Meta<typeof RcSesBottomSheet> = {
17
+ component: RcSesBottomSheet,
18
+ title: 'Organisms/BottomSheet',
19
+ parameters: {
20
+ layout: 'centered',
21
+ docs: {
22
+ description: {
23
+ component:
24
+ 'A standalone sheet-as-modal, unrelated to RcSesDialog/RcSesModal: optional title, ' +
25
+ 'a free-form content slot, and up to two labeled action buttons. There is no desktop ' +
26
+ 'presentation - "inherits the Modal contract" only means scrim + focus trap + Esc ' +
27
+ 'while the sheet is open. See the Composition story for how a consumer decides when ' +
28
+ 'to show it versus rendering the same content inline.',
29
+ },
30
+ },
31
+ viewport: {
32
+ options: {
33
+ mobile375: { name: 'Mobile 375', styles: { height: '900px', width: '375px' } },
34
+ },
35
+ },
36
+ },
37
+ tags: ['autodocs', 'no-snapshot'],
38
+ }
39
+
40
+ export default meta
41
+ type Story = StoryObj<typeof RcSesBottomSheet>
42
+
43
+ const BRANCHES = [
44
+ 'Vilniaus padalinys',
45
+ 'Kauno padalinys',
46
+ 'Klaipėdos padalinys',
47
+ 'Šiaulių padalinys',
48
+ 'Panevėžio padalinys',
49
+ ]
50
+
51
+ function BranchList({
52
+ branches,
53
+ onSelect,
54
+ }: {
55
+ branches: string[]
56
+ onSelect: (branch: string) => void
57
+ }) {
58
+ return (
59
+ <List disablePadding>
60
+ {branches.map((branch, index) => (
61
+ // Demo data has no stable id and can repeat when the list is padded for the scroll story.
62
+ // eslint-disable-next-line react/no-array-index-key
63
+ <ListItemButton key={`${branch}-${index}`} onClick={() => onSelect(branch)}>
64
+ <ListItemText primary={branch} />
65
+ </ListItemButton>
66
+ ))}
67
+ </List>
68
+ )
69
+ }
70
+
71
+ function BottomSheetDemo(
72
+ args: Partial<RcSesBottomSheetProps> & { longContent?: boolean },
73
+ ) {
74
+ const { longContent, ...sheetArgs } = args
75
+ const [open, setOpen] = useState(false)
76
+ const branches = longContent ? [...BRANCHES, ...BRANCHES, ...BRANCHES] : BRANCHES
77
+
78
+ return (
79
+ <>
80
+ <RcSesButton onClick={() => setOpen(true)} variant='contained'>
81
+ Pasirinkti padalinį
82
+ </RcSesButton>
83
+ <RcSesBottomSheet
84
+ title='Pasirinkite padalinį'
85
+ {...sheetArgs}
86
+ open={open}
87
+ onClose={() => setOpen(false)}
88
+ >
89
+ <BranchList branches={branches} onSelect={() => setOpen(false)} />
90
+ </RcSesBottomSheet>
91
+ </>
92
+ )
93
+ }
94
+
95
+ export const Default: Story = {
96
+ render: (args) => <BottomSheetDemo {...args} />,
97
+ }
98
+
99
+ export const WithActions: Story = {
100
+ render: (args) => <BottomSheetDemo {...args} />,
101
+ args: {
102
+ primaryActionLabel: 'Taikyti',
103
+ secondaryActionLabel: 'Atšaukti',
104
+ },
105
+ parameters: {
106
+ docs: {
107
+ description: {
108
+ story:
109
+ 'Up to two labeled buttons - both optional, and independent of each other.',
110
+ },
111
+ },
112
+ },
113
+ }
114
+
115
+ export const WithoutTitle: Story = {
116
+ render: (args) => <BottomSheetDemo {...args} title={undefined} />,
117
+ parameters: {
118
+ docs: {
119
+ description: {
120
+ story:
121
+ 'The header itself is optional: with no `title` and no `showBack`, only the handle and content render.',
122
+ },
123
+ },
124
+ },
125
+ }
126
+
127
+ export const MediumWidth: Story = {
128
+ render: (args) => <BottomSheetDemo {...args} />,
129
+ args: {
130
+ size: 'md',
131
+ },
132
+ parameters: {
133
+ docs: {
134
+ description: {
135
+ story:
136
+ '`size="md"` caps and centers the sheet width instead of the `sm` full-bleed ' +
137
+ 'default - the consumer picks this based on where the sheet is used, the component ' +
138
+ 'never infers it from the viewport.',
139
+ },
140
+ },
141
+ },
142
+ }
143
+
144
+ export const ScrollableContent: Story = {
145
+ render: (args) => <BottomSheetDemo {...args} longContent />,
146
+ parameters: {
147
+ docs: {
148
+ description: {
149
+ story:
150
+ 'A long list scrolls inside the content slot; the handle, header and footer stay put.',
151
+ },
152
+ },
153
+ },
154
+ }
155
+
156
+ export const WithoutBackdropClose: Story = {
157
+ render: (args) => <BottomSheetDemo {...args} />,
158
+ args: {
159
+ disableBackdropClose: true,
160
+ },
161
+ parameters: {
162
+ docs: {
163
+ description: {
164
+ story:
165
+ 'Tapping the backdrop no longer closes the sheet. Esc and the drag handle still do.',
166
+ },
167
+ },
168
+ },
169
+ }
170
+
171
+ function WithBackDemo() {
172
+ const [open, setOpen] = useState(false)
173
+ const [selectedBranch, setSelectedBranch] = useState<string | null>(null)
174
+
175
+ const handleClose = () => {
176
+ setOpen(false)
177
+ setSelectedBranch(null)
178
+ }
179
+
180
+ return (
181
+ <>
182
+ <RcSesButton onClick={() => setOpen(true)} variant='contained'>
183
+ Pasirinkti padalinį
184
+ </RcSesButton>
185
+ <RcSesBottomSheet
186
+ open={open}
187
+ onClose={handleClose}
188
+ title={selectedBranch || 'Pasirinkite padalinį'}
189
+ showBack={!!selectedBranch}
190
+ onBack={() => setSelectedBranch(null)}
191
+ >
192
+ {selectedBranch ? (
193
+ <Typography variant='body1'>Adresas, darbo laikas ir kontaktai.</Typography>
194
+ ) : (
195
+ <BranchList branches={BRANCHES} onSelect={setSelectedBranch} />
196
+ )}
197
+ </RcSesBottomSheet>
198
+ </>
199
+ )
200
+ }
201
+
202
+ export const WithBack: Story = {
203
+ render: () => <WithBackDemo />,
204
+ parameters: {
205
+ docs: {
206
+ description: {
207
+ story:
208
+ '`showBack` is for a multi-step sheet: selecting a branch drills into a detail step, ' +
209
+ 'and "Atgal" returns to the list without closing the sheet.',
210
+ },
211
+ },
212
+ },
213
+ }
214
+
215
+ function CompositionDemo() {
216
+ const isMobile = useMediaQuery('(max-width:599.95px)')
217
+ const [open, setOpen] = useState(false)
218
+ const [selectedBranch, setSelectedBranch] = useState<string | null>(null)
219
+
220
+ if (!isMobile) {
221
+ return (
222
+ <List disablePadding sx={{ width: 360 }}>
223
+ {BRANCHES.map((branch) => (
224
+ <ListItemButton
225
+ key={branch}
226
+ selected={branch === selectedBranch}
227
+ onClick={() => setSelectedBranch(branch)}
228
+ >
229
+ <ListItemText primary={branch} />
230
+ </ListItemButton>
231
+ ))}
232
+ </List>
233
+ )
234
+ }
235
+
236
+ return (
237
+ <>
238
+ <RcSesButton onClick={() => setOpen(true)} variant='outlined'>
239
+ {selectedBranch ?? 'Pasirinkti padalinį'}
240
+ </RcSesButton>
241
+ <RcSesBottomSheet
242
+ open={open}
243
+ onClose={() => setOpen(false)}
244
+ title='Pasirinkite padalinį'
245
+ >
246
+ <BranchList
247
+ branches={BRANCHES}
248
+ onSelect={(branch) => {
249
+ setSelectedBranch(branch)
250
+ setOpen(false)
251
+ }}
252
+ />
253
+ </RcSesBottomSheet>
254
+ </>
255
+ )
256
+ }
257
+
258
+ export const Composition: Story = {
259
+ render: () => <CompositionDemo />,
260
+ tags: ['!no-snapshot'],
261
+ parameters: {
262
+ docs: {
263
+ description: {
264
+ story:
265
+ 'How a consumer composes this: desktop renders the branch list inline (no overlay ' +
266
+ 'at all); resize below 600px and the same picker becomes a "Pasirinkti padalinį" ' +
267
+ 'trigger that opens the sheet. There is no desktop version of the sheet itself - the ' +
268
+ 'switch happens at the page-composition level, not inside the component.',
269
+ },
270
+ },
271
+ },
272
+ }
273
+
274
+ // The stories above all start closed, so their baselines only capture the
275
+ // trigger. This one renders the sheet open at 375 so the visual suite has a
276
+ // reference for the sheet itself.
277
+ export const OpenMobileViewport: Story = {
278
+ render: () => (
279
+ <RcSesBottomSheet
280
+ open
281
+ onClose={() => undefined}
282
+ title='Pasirinkite padalinį'
283
+ primaryActionLabel='Taikyti'
284
+ secondaryActionLabel='Atšaukti'
285
+ >
286
+ <BranchList branches={BRANCHES} onSelect={() => undefined} />
287
+ </RcSesBottomSheet>
288
+ ),
289
+ tags: ['viewport-375', '!autodocs', '!no-snapshot'],
290
+ globals: { viewport: { value: 'mobile375' } },
291
+ }
@@ -29,59 +29,83 @@ const MuiAutocomplete: Components['MuiAutocomplete'] = {
29
29
  },
30
30
  paper: {
31
31
  backgroundColor: 'white',
32
- borderRadius: '.375rem',
32
+ border: `1px solid ${palette.grey['200']}`,
33
+ borderRadius: '.75rem',
34
+ boxShadow: '0px 4px 16px 0px rgba(0, 0, 0, 0.08)',
33
35
  fontSize: '.9375rem',
34
- lineHeight: '1.125rem',
36
+ lineHeight: '1.375rem',
35
37
 
36
38
  '.MuiAutocomplete-listbox': {
37
39
  '.MuiAutocomplete-groupLabel': {
38
- color: palette.primary['600'],
40
+ color: palette.grey['900'],
39
41
  fontFamily: '"Public Sans", sans-serif',
40
- fontSize: '.75rem',
42
+ fontSize: '.875rem',
41
43
  fontStyle: 'normal',
42
- fontWeight: 500,
43
- letterSpacing: '.0075rem',
44
- lineHeight: '140%',
45
- padding: '.5rem .75rem .25rem',
46
- textTransform: 'uppercase',
44
+ fontWeight: 600,
45
+ letterSpacing: 'normal',
46
+ lineHeight: '1.25rem',
47
+ padding: '.75rem 1rem',
48
+ textTransform: 'none',
47
49
  },
48
50
 
49
51
  '.MuiAutocomplete-option': {
50
- alignItems: 'flex-start',
52
+ alignItems: 'center',
51
53
  backgroundColor: 'transparent',
52
- borderRadius: '.375rem',
54
+ borderRadius: 0,
53
55
  color: palette.grey['900'],
54
56
  flexDirection: 'column',
55
- margin: '0 .375rem',
56
- padding: '.8125rem .75rem',
57
+ margin: 0,
58
+ minHeight: '3rem',
59
+ padding: '.75rem 1rem',
57
60
  transition: 'background-color 150ms cubic-bezier(0.4, 0, 0.2, 1)',
58
61
 
59
62
  '&:hover': {
60
63
  backgroundColor: palette.grey['100'],
61
64
  },
62
65
 
63
- '&.Mui-focused': {
64
- backgroundColor: palette.grey['100'],
66
+ '&.Mui-focused:not(:hover)': {
67
+ backgroundColor: 'transparent',
68
+ boxShadow: `inset 0 0 0 2px ${palette.primary.main}`,
65
69
  },
66
70
 
67
71
  '&.Mui-selected': {
68
- backgroundColor: 'transparent',
72
+ backgroundColor: palette.primary['50'],
69
73
 
70
74
  '&:hover, &.Mui-focused': {
71
- backgroundColor: palette.grey['100'],
75
+ backgroundColor: palette.primary['50'],
72
76
  },
73
77
  },
74
78
 
75
79
  '&[aria-selected="true"]': {
76
- backgroundColor: 'transparent',
80
+ backgroundColor: palette.primary['50'],
77
81
  },
78
82
 
79
83
  '&[aria-selected="true"].Mui-focused, &[aria-selected="true"]:hover': {
80
- backgroundColor: palette.grey['100'],
84
+ backgroundColor: palette.primary['50'],
85
+ },
86
+
87
+ '&.Mui-disabled': {
88
+ color: palette.grey['500'],
89
+ opacity: 1,
90
+ },
91
+
92
+ '&.rc-ses-select-option--indent-single': {
93
+ paddingLeft: '2.5rem',
94
+ },
95
+ '&.rc-ses-select-option--indent-multi': {
96
+ paddingLeft: '2rem',
97
+ },
98
+
99
+ '&.Mui-selected .rc-ses-select-option-label': {
100
+ color: palette.primary['700'],
81
101
  },
82
102
 
83
103
  '.rc-ses-select-option-label': {
84
104
  display: 'block',
105
+ fontFamily: '"Public Sans", sans-serif',
106
+ fontSize: '.9375rem',
107
+ fontWeight: 400,
108
+ lineHeight: '1.375rem',
85
109
  overflowWrap: 'anywhere',
86
110
  },
87
111
  '.rc-ses-select-option-description': {