@registrucentras/rc-ses-react-components 2.5.1 → 2.7.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 (34) hide show
  1. package/dist/assets/icons/phosphorIcons.d.ts +4 -0
  2. package/dist/components/common/FilterChip/index.d.ts +8 -0
  3. package/dist/components/common/StepCard/StepCardFooter/index.d.ts +4 -1
  4. package/dist/components/common/StepCard/index.d.ts +1 -1
  5. package/dist/components/common/StepCard/types.d.ts +31 -0
  6. package/dist/components/overlays/BottomSheet/index.d.ts +3 -1
  7. package/dist/components/overlays/Drawer/Drawer.types.d.ts +4 -0
  8. package/dist/components/overlays/Drawer/index.d.ts +1 -1
  9. package/dist/library/index.d.ts +2 -1
  10. package/dist/library/types.d.ts +3 -2
  11. package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
  12. package/dist/registrucentras-rc-ses-react-components.js +1480 -1363
  13. package/package.json +1 -1
  14. package/src/assets/icons/phosphorIcons.ts +2 -0
  15. package/src/components/common/FilterChip/index.test.tsx +71 -0
  16. package/src/components/common/FilterChip/index.tsx +89 -0
  17. package/src/components/common/StepCard/StepCardFooter/index.test.tsx +187 -0
  18. package/src/components/common/StepCard/StepCardFooter/index.tsx +59 -24
  19. package/src/components/common/StepCard/index.test.tsx +31 -0
  20. package/src/components/common/StepCard/index.tsx +4 -0
  21. package/src/components/common/StepCard/types.ts +33 -0
  22. package/src/components/overlays/BottomSheet/index.test.tsx +31 -0
  23. package/src/components/overlays/BottomSheet/index.tsx +15 -2
  24. package/src/components/overlays/Drawer/Drawer.types.ts +4 -0
  25. package/src/components/overlays/Drawer/index.test.tsx +31 -0
  26. package/src/components/overlays/Drawer/index.tsx +13 -2
  27. package/src/i18n/namespaces/input/en.json +6 -0
  28. package/src/i18n/namespaces/input/lt.json +6 -0
  29. package/src/library/index.ts +3 -1
  30. package/src/library/types.ts +6 -0
  31. package/src/stories/atoms/FilterChip.stories.tsx +104 -0
  32. package/src/stories/molecules/StepCard.stories.tsx +86 -2
  33. package/src/stories/organisms/BottomSheet.stories.tsx +18 -0
  34. package/src/stories/organisms/Drawer.stories.tsx +36 -0
@@ -59,8 +59,10 @@ export interface RcSesBottomSheetProps extends Omit<
59
59
  onBack?: () => void
60
60
  primaryActionLabel?: string
61
61
  onPrimaryAction?: () => void
62
+ primaryActionDisabled?: boolean
62
63
  secondaryActionLabel?: string
63
64
  onSecondaryAction?: () => void
65
+ secondaryActionDisabled?: boolean
64
66
  disableBackdropClose?: boolean
65
67
  size?: 'sm' | 'md'
66
68
  onClose?: (
@@ -76,8 +78,10 @@ function RcSesBottomSheet({
76
78
  onBack,
77
79
  primaryActionLabel,
78
80
  onPrimaryAction,
81
+ primaryActionDisabled,
79
82
  secondaryActionLabel,
80
83
  onSecondaryAction,
84
+ secondaryActionDisabled,
81
85
  onClose,
82
86
  disableBackdropClose = false,
83
87
  size = 'sm',
@@ -224,12 +228,21 @@ function RcSesBottomSheet({
224
228
  }}
225
229
  >
226
230
  {secondaryActionLabel && (
227
- <RcSesButton variant='outlined' color='grey' onClick={onSecondaryAction}>
231
+ <RcSesButton
232
+ variant='outlined'
233
+ color='grey'
234
+ onClick={onSecondaryAction}
235
+ disabled={secondaryActionDisabled}
236
+ >
228
237
  {secondaryActionLabel}
229
238
  </RcSesButton>
230
239
  )}
231
240
  {primaryActionLabel && (
232
- <RcSesButton variant='contained' onClick={onPrimaryAction}>
241
+ <RcSesButton
242
+ variant='contained'
243
+ onClick={onPrimaryAction}
244
+ disabled={primaryActionDisabled}
245
+ >
233
246
  {primaryActionLabel}
234
247
  </RcSesButton>
235
248
  )}
@@ -21,10 +21,14 @@ export interface RcSesDrawerProps {
21
21
  secondaryActionLabel?: string
22
22
  /** Callback fired when secondary action button is clicked */
23
23
  onSecondaryAction?: () => void
24
+ /** Whether the secondary action button is disabled */
25
+ secondaryActionDisabled?: boolean
24
26
  /** Label for the primary (right) action button */
25
27
  primaryActionLabel?: string
26
28
  /** Callback fired when primary action button is clicked */
27
29
  onPrimaryAction?: () => void
30
+ /** Whether the primary action button is disabled */
31
+ primaryActionDisabled?: boolean
28
32
  /** Test IDs for testing */
29
33
  testIds?: RcSesDrawerTestIds
30
34
  /** Optional CSS class name */
@@ -137,6 +137,37 @@ describe('RcSesDrawer', () => {
137
137
  expect(onSecondaryAction).toHaveBeenCalledTimes(1)
138
138
  })
139
139
 
140
+ it('disables only the primary button when primaryActionDisabled is set', () => {
141
+ const onPrimaryAction = vi.fn()
142
+ const onSecondaryAction = vi.fn()
143
+ render(
144
+ <RcSesDrawer
145
+ isOpen
146
+ title='Test Drawer'
147
+ onClose={vi.fn()}
148
+ secondaryActionLabel='Cancel'
149
+ onSecondaryAction={onSecondaryAction}
150
+ primaryActionLabel='Apply'
151
+ onPrimaryAction={onPrimaryAction}
152
+ primaryActionDisabled
153
+ >
154
+ Test content
155
+ </RcSesDrawer>,
156
+ )
157
+
158
+ const secondaryButton = screen.getByRole('button', { name: 'Cancel' })
159
+ const primaryButton = screen.getByRole('button', { name: 'Apply' })
160
+
161
+ expect(primaryButton).toBeDisabled()
162
+ expect(secondaryButton).toBeEnabled()
163
+
164
+ fireEvent.click(primaryButton)
165
+ fireEvent.click(secondaryButton)
166
+
167
+ expect(onPrimaryAction).not.toHaveBeenCalled()
168
+ expect(onSecondaryAction).toHaveBeenCalledTimes(1)
169
+ })
170
+
140
171
  it('has proper ARIA attributes', () => {
141
172
  render(
142
173
  <RcSesDrawer isOpen title='Test Drawer' onClose={vi.fn()}>
@@ -39,8 +39,10 @@ const RcSesDrawer = ({
39
39
  children,
40
40
  secondaryActionLabel,
41
41
  onSecondaryAction,
42
+ secondaryActionDisabled,
42
43
  primaryActionLabel,
43
44
  onPrimaryAction,
45
+ primaryActionDisabled,
44
46
  testIds,
45
47
  className,
46
48
  }: RcSesDrawerProps) => {
@@ -172,12 +174,21 @@ const RcSesDrawer = ({
172
174
  }}
173
175
  >
174
176
  {secondaryActionLabel && (
175
- <RcSesButton variant='link' onClick={onSecondaryAction}>
177
+ <RcSesButton
178
+ variant='outlined'
179
+ color='grey'
180
+ onClick={onSecondaryAction}
181
+ disabled={secondaryActionDisabled}
182
+ >
176
183
  {secondaryActionLabel}
177
184
  </RcSesButton>
178
185
  )}
179
186
  {primaryActionLabel && (
180
- <RcSesButton variant='contained' onClick={onPrimaryAction}>
187
+ <RcSesButton
188
+ variant='contained'
189
+ onClick={onPrimaryAction}
190
+ disabled={primaryActionDisabled}
191
+ >
181
192
  {primaryActionLabel}
182
193
  </RcSesButton>
183
194
  )}
@@ -94,6 +94,12 @@
94
94
  "aria": {
95
95
  "back": "Back"
96
96
  }
97
+ },
98
+
99
+ "RcSesFilterChip": {
100
+ "aria": {
101
+ "label": "Remove filter: {{label}}"
102
+ }
97
103
  }
98
104
  }
99
105
  }
@@ -94,6 +94,12 @@
94
94
  "aria": {
95
95
  "back": "Atgal"
96
96
  }
97
+ },
98
+
99
+ "RcSesFilterChip": {
100
+ "aria": {
101
+ "label": "Pašalinti filtrą: {{label}}"
102
+ }
97
103
  }
98
104
  }
99
105
  }
@@ -17,6 +17,7 @@ import RcSesCard from '@/components/common/Card'
17
17
  import RcSesCardShell from '@/components/common/CardShell'
18
18
  import RcSesCardFooter from '@/components/common/CardShell/CardFooter'
19
19
  import DataPagination from '@/components/common/DataPagination'
20
+ import RcSesFilterChip from '@/components/common/FilterChip'
20
21
  import RcSesIconWithCircularBackground from '@/components/common/IconWithCircularBackground'
21
22
  import RcSesIconWithSquareBackground from '@/components/common/IconWithSquareBackground'
22
23
  import RcSesImageCard from '@/components/common/ImageCard'
@@ -84,6 +85,7 @@ export { RcSesAdvancedList, RcSesAdvancedListItem, RcSesAdvancedListItemShell }
84
85
  export {
85
86
  RcSesAlert,
86
87
  RcSesBadge,
88
+ RcSesFilterChip,
87
89
  RcSesBreadcrumbs,
88
90
  RcSesButton,
89
91
  RcSesButtonWithPopover,
@@ -99,9 +101,9 @@ export {
99
101
  RcSesImageCard,
100
102
  RcSesSnackbar,
101
103
  RcSesSnackbarProvider,
102
- RcSesModal,
103
104
  RcSesStepCard,
104
105
  RcSesSwitch,
106
+ RcSesModal,
105
107
  RcSesBottomSheet,
106
108
  RcSesDrawer,
107
109
  }
@@ -15,6 +15,7 @@ import {
15
15
  RcSesCardShellProps,
16
16
  RcSesCardShellTestIds,
17
17
  } from '@/components/common/CardShell/types'
18
+ import { RcSesFilterChipProps } from '@/components/common/FilterChip'
18
19
  import { ListWithIconsProps } from '@/components/common/ListWithIcons'
19
20
  import {
20
21
  ListWithIconsItemData,
@@ -34,6 +35,8 @@ import {
34
35
  import { RcSesSideNavItem, RcSesSideNavOverflow } from '@/components/common/SideNav'
35
36
  import { RcSesSideNavLayoutProps } from '@/components/common/SideNav/SideNavLayout'
36
37
  import {
38
+ RcSesStepCardAction,
39
+ RcSesStepCardActions,
37
40
  RcSesStepCardProps,
38
41
  RcSesStepCardTestIds,
39
42
  } from '@/components/common/StepCard/types'
@@ -84,6 +87,7 @@ export type {
84
87
  RcSesLoaderSize,
85
88
  RcSesCardFormContainerProps,
86
89
  RcSesCardProps,
90
+ RcSesFilterChipProps,
87
91
  RcSesCardShellProps,
88
92
  RcSesCardShellTestIds,
89
93
  RcSesTitleBlockProps,
@@ -107,6 +111,8 @@ export type {
107
111
  RcSesSideNavItem,
108
112
  RcSesSideNavLayoutProps,
109
113
  RcSesSideNavOverflow,
114
+ RcSesStepCardAction,
115
+ RcSesStepCardActions,
110
116
  RcSesStepCardProps,
111
117
  RcSesStepCardTestIds,
112
118
  }
@@ -0,0 +1,104 @@
1
+ import { Box } from '@mui/material'
2
+ import { grey } from '@mui/material/colors'
3
+ import type { Meta, StoryObj } from '@storybook/react-vite'
4
+ import { useState } from 'react'
5
+
6
+ import RcSesFilterChip from '@/components/common/FilterChip'
7
+
8
+ type Story = StoryObj<typeof RcSesFilterChip>
9
+
10
+ const meta: Meta<typeof RcSesFilterChip> = {
11
+ title: 'Atoms/FilterChip',
12
+ component: RcSesFilterChip,
13
+ tags: ['autodocs'],
14
+ args: {
15
+ label: 'Filter label',
16
+ onRemove: () => {},
17
+ },
18
+ }
19
+
20
+ export default meta
21
+
22
+ export const Default: Story = {
23
+ render: (args) => {
24
+ const [visible, setVisible] = useState(true)
25
+
26
+ if (!visible) {
27
+ return <Box sx={{ color: grey[500] }}>Filter removed (reload page to reset)</Box>
28
+ }
29
+
30
+ return <RcSesFilterChip {...args} onRemove={() => setVisible(false)} />
31
+ },
32
+ parameters: {
33
+ docs: {
34
+ source: {
35
+ code: `
36
+
37
+ const [visible, setVisible] = useState(true)
38
+
39
+ return (
40
+ <RcSesFilterChip
41
+ label="Filter label"
42
+ onRemove={() => setVisible(false)}
43
+ />
44
+ )`,
45
+ },
46
+ },
47
+ },
48
+ }
49
+
50
+ export const LongLabelEdgeCase: Story = {
51
+ render: (args) => {
52
+ const [removedStates, setRemovedStates] = useState<Set<string>>(new Set())
53
+
54
+ const toggleRemoved = (key: string) => {
55
+ const newSet = new Set(removedStates)
56
+ if (newSet.has(key)) {
57
+ newSet.delete(key)
58
+ } else {
59
+ newSet.add(key)
60
+ }
61
+ setRemovedStates(newSet)
62
+ }
63
+
64
+ return (
65
+ <Box sx={{ display: 'flex', flexDirection: 'column', gap: '2rem' }}>
66
+ <Box>
67
+ <Box sx={{ mb: 1, fontSize: '0.875rem', fontWeight: 500, color: grey[600] }}>
68
+ Long Label (truncated with tooltip)
69
+ </Box>
70
+ <Box sx={{ maxWidth: '250px', mb: 1, p: 1, border: `1px dashed ${grey[300]}` }}>
71
+ {removedStates.has('long') ? (
72
+ <Box sx={{ color: grey[500], fontSize: '0.875rem' }}>
73
+ Filter removed (reload page to reset)
74
+ </Box>
75
+ ) : (
76
+ <RcSesFilterChip
77
+ {...args}
78
+ label='This is a very long filter label that will be truncated'
79
+ onRemove={() => toggleRemoved('long')}
80
+ />
81
+ )}
82
+ </Box>
83
+ <Box sx={{ fontSize: '0.8125rem', color: grey[500] }}>
84
+ Container width: 250px. Hover to see full text in tooltip.
85
+ </Box>
86
+ </Box>
87
+ </Box>
88
+ )
89
+ },
90
+ parameters: {
91
+ docs: {
92
+ source: {
93
+ code: `// Rest State
94
+ <RcSesFilterChip label="Filter label" onRemove={() => {}} />
95
+
96
+ // Long Label (truncated with tooltip)
97
+ <RcSesFilterChip
98
+ label="This is a very long filter label that will be truncated"
99
+ onRemove={() => {}}
100
+ />`,
101
+ },
102
+ },
103
+ },
104
+ }
@@ -1,6 +1,6 @@
1
- import { Box, Button, Typography } from '@mui/material'
1
+ import { Box, Button, TextField, Typography } from '@mui/material'
2
2
  import type { Meta, StoryObj } from '@storybook/react-vite'
3
- import { ComponentProps, useState } from 'react'
3
+ import { ComponentProps, FormEvent, useState } from 'react'
4
4
 
5
5
  import RcSesCardFooter from '@/components/common/CardShell/CardFooter'
6
6
  import RcSesStepCard from '@/components/common/StepCard'
@@ -151,6 +151,90 @@ export const CustomFooter: Story = {
151
151
  ),
152
152
  }
153
153
 
154
+ function FormSubmitDemo(args: StepCardDemoProps) {
155
+ const [activeStep, setActiveStep] = useState(0)
156
+ const [saving, setSaving] = useState(false)
157
+ const isLastStep = activeStep === STEP_COUNT - 1
158
+ const formId = `step-${activeStep}-form`
159
+
160
+ const handleSubmit = (event: FormEvent) => {
161
+ event.preventDefault()
162
+ setSaving(true)
163
+ setTimeout(() => {
164
+ setSaving(false)
165
+ setActiveStep((prev) => Math.min(prev + 1, STEP_COUNT - 1))
166
+ }, 1500)
167
+ }
168
+
169
+ return (
170
+ <Fields>
171
+ <FieldView>
172
+ <RcSesStepCard
173
+ {...args}
174
+ activeStep={activeStep}
175
+ stepCount={STEP_COUNT}
176
+ totalPrice='4,01 €'
177
+ onBack={() => setActiveStep((prev) => Math.max(prev - 1, 0))}
178
+ actions={{
179
+ next: {
180
+ form: formId,
181
+ loading: saving,
182
+ ...(isLastStep ? { label: 'Pateikti', icon: null } : {}),
183
+ },
184
+ back: { disabled: saving },
185
+ cancel: false,
186
+ }}
187
+ >
188
+ <Box
189
+ component='form'
190
+ id={formId}
191
+ key={formId}
192
+ onSubmit={handleSubmit}
193
+ sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}
194
+ >
195
+ <TextField label='Vardas' size='small' fullWidth required />
196
+ <TextField label='Pavardė' size='small' fullWidth required />
197
+ </Box>
198
+ </RcSesStepCard>
199
+ </FieldView>
200
+ </Fields>
201
+ )
202
+ }
203
+
204
+ /**
205
+ * Form wizard without payments. Each step owns its `<form>`, and
206
+ * `actions.next.form` makes the CTA that form's submit button, so Enter in a
207
+ * field submits too. No `Atšaukti` on the first step (`cancel: false`); the
208
+ * last step is `Pateikti` with no cart icon, next to the total price.
209
+ */
210
+ export const FormSubmit: Story = {
211
+ render: (args) => <FormSubmitDemo {...args} />,
212
+ }
213
+
214
+ /**
215
+ * Last step with a custom CTA → `actions.next = { label: 'Pateikti', icon: null }`
216
+ * swaps the cart CTA for a neutral one in flows without a basket; the price
217
+ * summary stays.
218
+ */
219
+ export const LastStepCustomCTA: Story = {
220
+ render: (args) => (
221
+ <Fields>
222
+ <FieldView>
223
+ <RcSesStepCard
224
+ {...args}
225
+ activeStep={STEP_COUNT - 1}
226
+ stepCount={STEP_COUNT}
227
+ totalPriceLabel='Suma (2 × 5,00 €)'
228
+ totalPrice='10,00 €'
229
+ actions={{ next: { label: 'Patvirtinti', icon: null } }}
230
+ >
231
+ <DemoContent />
232
+ </RcSesStepCard>
233
+ </FieldView>
234
+ </Fields>
235
+ ),
236
+ }
237
+
154
238
  /**
155
239
  * Last-step footer pinned at a 375px viewport - the trailing CTA + price
156
240
  * summary stack above the leading button and the price row goes inline, per
@@ -289,3 +289,21 @@ export const OpenMobileViewport: Story = {
289
289
  tags: ['viewport-375', '!autodocs', '!no-snapshot'],
290
290
  globals: { viewport: { value: 'mobile375' } },
291
291
  }
292
+
293
+ export const DisabledActionsMobileViewport: Story = {
294
+ render: () => (
295
+ <RcSesBottomSheet
296
+ open
297
+ onClose={() => undefined}
298
+ title='Pasirinkite padalinį'
299
+ primaryActionLabel='Taikyti'
300
+ primaryActionDisabled
301
+ secondaryActionLabel='Atšaukti'
302
+ secondaryActionDisabled
303
+ >
304
+ <BranchList branches={BRANCHES} onSelect={() => undefined} />
305
+ </RcSesBottomSheet>
306
+ ),
307
+ tags: ['viewport-375', '!autodocs', '!no-snapshot'],
308
+ globals: { viewport: { value: 'mobile375' } },
309
+ }
@@ -88,3 +88,39 @@ export const Default: Story = {
88
88
  },
89
89
  },
90
90
  }
91
+
92
+ export const DisabledActions: Story = {
93
+ args: {
94
+ isOpen: true,
95
+ onClose: () => {},
96
+ secondaryActionDisabled: true,
97
+ primaryActionDisabled: true,
98
+ },
99
+ render: (args) => <RcSesDrawer {...args} />,
100
+ tags: ['!autodocs'],
101
+ parameters: {
102
+ docs: {
103
+ description: {
104
+ story:
105
+ 'Each footer action can be disabled independently via primaryActionDisabled and secondaryActionDisabled - useful while no filters are selected yet, or while a request is in flight.',
106
+ },
107
+ source: {
108
+ code: `<RcSesDrawer
109
+ isOpen={isOpen}
110
+ onClose={() => setIsOpen(false)}
111
+ title='Filtrai'
112
+ secondaryActionLabel='Išvalyti'
113
+ secondaryActionDisabled
114
+ primaryActionLabel='Rodyti paslaugas'
115
+ primaryActionDisabled
116
+ >
117
+ <Stack sx={{ gap: '1rem' }}>
118
+ <Typography variant='body2'>
119
+ Turinys (slot) - filtrai, paieška, sąrašas
120
+ </Typography>
121
+ </Stack>
122
+ </RcSesDrawer>`,
123
+ },
124
+ },
125
+ },
126
+ }