@registrucentras/rc-ses-react-components 2.5.1 → 2.6.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.
@@ -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