@registrucentras/rc-ses-react-components 2.5.0 → 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.
- package/dist/components/common/FilterChip/index.d.ts +8 -0
- package/dist/components/common/StepCard/StepCardFooter/index.d.ts +4 -1
- package/dist/components/common/StepCard/index.d.ts +1 -1
- package/dist/components/common/StepCard/types.d.ts +31 -0
- package/dist/library/index.d.ts +2 -1
- package/dist/library/types.d.ts +3 -2
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +1287 -1203
- package/package.json +1 -1
- package/src/components/common/FilterChip/index.test.tsx +71 -0
- package/src/components/common/FilterChip/index.tsx +89 -0
- package/src/components/common/StepCard/StepCardFooter/index.test.tsx +187 -0
- package/src/components/common/StepCard/StepCardFooter/index.tsx +59 -24
- package/src/components/common/StepCard/index.test.tsx +31 -0
- package/src/components/common/StepCard/index.tsx +4 -0
- package/src/components/common/StepCard/types.ts +33 -0
- package/src/components/form/inputs/Select/index.tsx +3 -1
- package/src/i18n/namespaces/input/en.json +6 -0
- package/src/i18n/namespaces/input/lt.json +6 -0
- package/src/library/index.ts +3 -1
- package/src/library/types.ts +6 -0
- package/src/stories/atoms/FilterChip.stories.tsx +104 -0
- package/src/stories/foundations/ThemedMuiComponents.stories.tsx +31 -0
- package/src/stories/molecules/StepCard.stories.tsx +86 -2
- package/src/theme/light/MuiAutocomplete.ts +5 -1
package/src/library/index.ts
CHANGED
|
@@ -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
|
}
|
package/src/library/types.ts
CHANGED
|
@@ -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,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Autocomplete,
|
|
2
3
|
Box,
|
|
3
4
|
Card,
|
|
4
5
|
CardContent,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
TableContainer,
|
|
12
13
|
TableHead,
|
|
13
14
|
TableRow,
|
|
15
|
+
TextField,
|
|
14
16
|
Tooltip,
|
|
15
17
|
Typography,
|
|
16
18
|
} from '@mui/material'
|
|
@@ -29,6 +31,9 @@ import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
|
29
31
|
* 2. **The wrapper never shows it open.** `MuiTooltip` is styled through
|
|
30
32
|
* `RcSesTooltip`, but that component owns its open state internally and no
|
|
31
33
|
* story can force it, so the popper never reaches a baseline.
|
|
34
|
+
* 3. **The wrappers restyle it.** `RcSesSelect` and `PhoneInput` lay their
|
|
35
|
+
* `MuiAutocomplete` options out as rows, so the theme's own option layout -
|
|
36
|
+
* what a consumer's plain Autocomplete gets - is covered by nothing else.
|
|
32
37
|
*
|
|
33
38
|
* Either way these render the plain MUI component under the theme, so a broken
|
|
34
39
|
* or silently dead override surfaces as a pixel diff.
|
|
@@ -175,3 +180,29 @@ export const TooltipSlots: Story = {
|
|
|
175
180
|
</Stack>
|
|
176
181
|
),
|
|
177
182
|
}
|
|
183
|
+
|
|
184
|
+
const autocompleteOptions = [
|
|
185
|
+
{ group: 'Paslaugos', label: 'Išrašo užsakymas' },
|
|
186
|
+
{
|
|
187
|
+
group: 'Paslaugos',
|
|
188
|
+
label:
|
|
189
|
+
'Nekilnojamojo turto registro duomenų teikimo leidžiamosios kreipties būdu naudojantis saityno paslauga',
|
|
190
|
+
},
|
|
191
|
+
{ group: 'Puslapiai', label: 'Kontaktai' },
|
|
192
|
+
]
|
|
193
|
+
|
|
194
|
+
export const AutocompleteSlots: Story = {
|
|
195
|
+
name: 'Autocomplete',
|
|
196
|
+
// Short options next to one that wraps, so a change to the theme's option
|
|
197
|
+
// alignment shows: the short ones move while the wrapping one cannot.
|
|
198
|
+
render: () => (
|
|
199
|
+
<Box sx={{ pb: '16rem', width: 480 }}>
|
|
200
|
+
<Autocomplete
|
|
201
|
+
groupBy={(option) => option.group}
|
|
202
|
+
open
|
|
203
|
+
options={autocompleteOptions}
|
|
204
|
+
renderInput={(params) => <TextField {...params} label='Paieška' />}
|
|
205
|
+
/>
|
|
206
|
+
</Box>
|
|
207
|
+
),
|
|
208
|
+
}
|
|
@@ -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
|
|
@@ -48,8 +48,12 @@ const MuiAutocomplete: Components['MuiAutocomplete'] = {
|
|
|
48
48
|
textTransform: 'none',
|
|
49
49
|
},
|
|
50
50
|
|
|
51
|
+
// Options stack as a column here, so alignItems is the horizontal
|
|
52
|
+
// axis: 'center' would centre the text of every consumer's
|
|
53
|
+
// Autocomplete. Components that lay options out as a row (Select,
|
|
54
|
+
// PhoneInput) set their own vertical centring.
|
|
51
55
|
'.MuiAutocomplete-option': {
|
|
52
|
-
alignItems: '
|
|
56
|
+
alignItems: 'flex-start',
|
|
53
57
|
backgroundColor: 'transparent',
|
|
54
58
|
borderRadius: 0,
|
|
55
59
|
color: palette.grey['900'],
|