@registrucentras/rc-ses-react-components 2.1.0 → 2.3.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.
Files changed (35) hide show
  1. package/dist/components/common/AdvancedList/components/AdvancedListItem/index.d.ts +3 -0
  2. package/dist/components/common/AdvancedList/components/AdvancedListItemShell/AdvancedListItemShell.types.d.ts +31 -0
  3. package/dist/components/common/AdvancedList/components/AdvancedListItemShell/index.d.ts +11 -0
  4. package/dist/components/form/inputs/Select/Select.utils.d.ts +9 -0
  5. package/dist/components/form/inputs/Select/components/OptionCheckbox.d.ts +5 -0
  6. package/dist/components/form/inputs/Select/index.d.ts +18 -8
  7. package/dist/components/overlays/BottomSheet/index.d.ts +17 -0
  8. package/dist/components/overlays/BottomSheet/useSwipeToDismiss.d.ts +17 -0
  9. package/dist/library/index.d.ts +4 -2
  10. package/dist/library/types.d.ts +4 -0
  11. package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
  12. package/dist/registrucentras-rc-ses-react-components.js +3004 -2437
  13. package/package.json +1 -1
  14. package/src/components/common/AdvancedList/components/AdvancedListItem/index.tsx +4 -0
  15. package/src/components/common/AdvancedList/components/AdvancedListItemShell/AdvancedListItemShell.types.ts +35 -0
  16. package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.test.tsx +350 -0
  17. package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.tsx +247 -0
  18. package/src/components/form/inputs/Select/Select.utils.ts +24 -0
  19. package/src/components/form/inputs/Select/components/OptionCheckbox.tsx +46 -0
  20. package/src/components/form/inputs/Select/index.test.tsx +127 -0
  21. package/src/components/form/inputs/Select/index.tsx +426 -181
  22. package/src/components/overlays/BottomSheet/index.test.tsx +256 -0
  23. package/src/components/overlays/BottomSheet/index.tsx +242 -0
  24. package/src/components/overlays/BottomSheet/useSwipeToDismiss.test.ts +295 -0
  25. package/src/components/overlays/BottomSheet/useSwipeToDismiss.ts +138 -0
  26. package/src/i18n/namespaces/input/en.json +11 -0
  27. package/src/i18n/namespaces/input/lt.json +11 -0
  28. package/src/library/index.ts +4 -1
  29. package/src/library/types.ts +12 -0
  30. package/src/stories/atoms/Select.stories.tsx +33 -5
  31. package/src/stories/organisms/AdvancedListItem.stories.tsx +1 -1
  32. package/src/stories/organisms/AdvancedListItemShell.stories.tsx +866 -0
  33. package/src/stories/organisms/BottomSheet.stories.tsx +291 -0
  34. package/src/theme/light/MuiAutocomplete.ts +43 -19
  35. package/src/theme/light/MuiTypography.tsx +24 -24
@@ -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': {
@@ -5,15 +5,15 @@ import palette from '@/theme/palette'
5
5
  export const typography = {
6
6
  bodyRegularMuted: {
7
7
  color: palette.grey[500],
8
- fontSize: '0.9375rem',
8
+ fontSize: '0.9375rem', // 15px
9
9
  fontWeight: 400,
10
- lineHeight: '1.375rem',
10
+ lineHeight: '1.375rem', // 22px
11
11
  },
12
12
  priceEmphasis: {
13
13
  color: palette.grey[900],
14
- fontSize: '1.125rem',
14
+ fontSize: '1.125rem', // 18px
15
15
  fontWeight: 500,
16
- lineHeight: '1.5rem',
16
+ lineHeight: '1.5rem', // 24px
17
17
  },
18
18
  }
19
19
 
@@ -22,51 +22,51 @@ const MuiTypography: Components['MuiTypography'] = {
22
22
  root: {},
23
23
  h1: {
24
24
  fontWeight: '500',
25
- lineHeight: '2rem',
25
+ lineHeight: '2rem', // 32px
26
26
  },
27
27
  h2: {
28
- fontSize: '2rem',
28
+ fontSize: '2rem', // 32px
29
29
  fontWeight: '500',
30
- lineHeight: '2.75rem',
30
+ lineHeight: '2.75rem', // 44px
31
31
  },
32
32
  h3: {
33
- fontSize: '1.75rem',
33
+ fontSize: '1.75rem', // 28px
34
34
  fontWeight: '500',
35
- lineHeight: '2.375rem',
35
+ lineHeight: '2.375rem', // 38px
36
36
  },
37
37
  h4: {
38
- fontSize: '1.5rem',
38
+ fontSize: '1.5rem', // 24px
39
39
  fontWeight: '500',
40
- lineHeight: '1.75rem',
40
+ lineHeight: '1.75rem', // 28px
41
41
  },
42
42
  h5: {
43
- fontSize: '1.25rem',
43
+ fontSize: '1.25rem', // 20px
44
44
  fontWeight: '500',
45
- lineHeight: '1.6875rem',
45
+ lineHeight: '1.6875rem', // 27px
46
46
  },
47
47
  h6: {
48
- fontSize: '1.125rem',
48
+ fontSize: '1.125rem', // 18px
49
49
  fontWeight: '500',
50
- lineHeight: '1.5rem',
50
+ lineHeight: '1.5rem', // 24px
51
51
  },
52
52
  body1: {
53
- fontSize: '.9375rem',
54
- lineHeight: '1.125rem',
53
+ fontSize: '.9375rem', // 15px
54
+ lineHeight: '1.125rem', // 18px
55
55
  },
56
56
  body2: {
57
- fontSize: '.875rem',
58
- lineHeight: '1rem',
57
+ fontSize: '.875rem', // 14px
58
+ lineHeight: '1rem', // 16px
59
59
  },
60
60
  caption: {
61
- fontSize: '.8125rem',
62
- lineHeight: '1rem',
61
+ fontSize: '.8125rem', // 13px
62
+ lineHeight: '1rem', // 16px
63
63
  },
64
64
  subtitle1: {
65
- fontSize: '.75rem',
66
- lineHeight: '.875rem',
65
+ fontSize: '.75rem', // 12px
66
+ lineHeight: '.875rem', // 14px
67
67
  },
68
68
  subtitle2: {
69
- fontSize: '.6875rem',
69
+ fontSize: '.6875rem', // 11px
70
70
  },
71
71
  },
72
72
  }