@registrucentras/rc-ses-react-components 2.6.0 → 2.7.2
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/README.md +1 -1
- package/dist/assets/icons/phosphorIcons.d.ts +4 -0
- package/dist/components/overlays/BottomSheet/index.d.ts +3 -1
- package/dist/components/overlays/Drawer/Drawer.types.d.ts +4 -0
- package/dist/components/overlays/Drawer/index.d.ts +1 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +820 -790
- package/package.json +2 -1
- package/src/assets/icons/phosphorIcons.ts +2 -0
- package/src/components/form/inputs/PhoneInputFormControl/index.test.tsx +11 -0
- package/src/components/form/inputs/PhoneInputFormControl/index.tsx +1 -0
- package/src/components/form/inputs/Select/index.test.tsx +11 -0
- package/src/components/form/inputs/Select/index.tsx +2 -0
- package/src/components/overlays/BottomSheet/index.test.tsx +31 -0
- package/src/components/overlays/BottomSheet/index.tsx +17 -3
- package/src/components/overlays/Drawer/Drawer.types.ts +4 -0
- package/src/components/overlays/Drawer/index.test.tsx +31 -0
- package/src/components/overlays/Drawer/index.tsx +14 -12
- package/src/i18n/namespaces/input/en.json +5 -2
- package/src/i18n/namespaces/input/lt.json +5 -2
- package/src/stories/organisms/BottomSheet.stories.tsx +18 -0
- package/src/stories/organisms/Drawer.stories.tsx +36 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@registrucentras/rc-ses-react-components",
|
|
3
3
|
"author": "VĮ REGISTRŲ CENTRAS",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.7.2",
|
|
5
5
|
"description": "RC SES React komponentų biblioteka",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
"@testing-library/react": "^16.3.0",
|
|
96
96
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
97
97
|
"@types/js-cookie": "^3.0.6",
|
|
98
|
+
"@types/node": "^24.19.2",
|
|
98
99
|
"@types/react": "^18.3.3",
|
|
99
100
|
"@types/react-dom": "^18.3.0",
|
|
100
101
|
"@vitejs/plugin-react": "^4.3.4",
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
ClockIcon as Clock,
|
|
21
21
|
CopyIcon as Copy,
|
|
22
22
|
EnvelopeSimpleIcon as EnvelopeSimple,
|
|
23
|
+
FunnelIcon as Funnel,
|
|
23
24
|
InfoIcon as Info,
|
|
24
25
|
ListIcon as List,
|
|
25
26
|
MagnifyingGlassIcon as MagnifyingGlass,
|
|
@@ -119,6 +120,7 @@ export const ExpandChevronsIcon = /* @__PURE__ */ createIcon(ArrowsOutLineVertic
|
|
|
119
120
|
weight: 'bold',
|
|
120
121
|
name: 'ExpandChevronsIcon',
|
|
121
122
|
})
|
|
123
|
+
export const FunnelIcon = /* @__PURE__ */ createIcon(Funnel)
|
|
122
124
|
export const InfoFillIcon = /* @__PURE__ */ createIcon(Info, { weight: 'fill' })
|
|
123
125
|
export const InfoIcon = /* @__PURE__ */ createIcon(Info)
|
|
124
126
|
export const ListIcon = /* @__PURE__ */ createIcon(List)
|
|
@@ -89,6 +89,17 @@ describe('RcSesPhoneInputFormControl', () => {
|
|
|
89
89
|
expect(screen.queryByText('Lithuania')).not.toBeInTheDocument()
|
|
90
90
|
})
|
|
91
91
|
|
|
92
|
+
test('shows the translated empty state when the search matches nothing', () => {
|
|
93
|
+
render(<TestComponent />)
|
|
94
|
+
openDropdown()
|
|
95
|
+
|
|
96
|
+
fireEvent.change(screen.getByPlaceholderText('search'), {
|
|
97
|
+
target: { value: 'XYZXYZ' },
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
expect(screen.getByText('noOptionsText')).toBeInTheDocument()
|
|
101
|
+
})
|
|
102
|
+
|
|
92
103
|
test('selecting a country updates the dial code and mask', () => {
|
|
93
104
|
render(<TestComponent />)
|
|
94
105
|
openDropdown()
|
|
@@ -223,6 +223,7 @@ function RcSesPhoneInputFormControl(props: Props) {
|
|
|
223
223
|
}
|
|
224
224
|
getOptionLabel={(option) => option.name}
|
|
225
225
|
isOptionEqualToValue={(o, v) => o.code === v.code}
|
|
226
|
+
noOptionsText={t('noOptionsText')}
|
|
226
227
|
onChange={(e, selection) => {
|
|
227
228
|
e.preventDefault()
|
|
228
229
|
setAnchorEl(null)
|
|
@@ -195,6 +195,17 @@ describe('RcSesSelect', () => {
|
|
|
195
195
|
expect(screen.getByRole('combobox')).toHaveAttribute('readonly')
|
|
196
196
|
})
|
|
197
197
|
|
|
198
|
+
test('shows a Lithuanian empty state when the typed text matches no option', async () => {
|
|
199
|
+
render(<TestWrapper />)
|
|
200
|
+
|
|
201
|
+
const input = screen.getByRole('combobox')
|
|
202
|
+
fireEvent.mouseDown(input)
|
|
203
|
+
fireEvent.change(input, { target: { value: 'JSD' } })
|
|
204
|
+
|
|
205
|
+
expect(await screen.findByText('Rezultatų nerasta')).toBeInTheDocument()
|
|
206
|
+
expect(screen.queryByText('No options')).not.toBeInTheDocument()
|
|
207
|
+
})
|
|
208
|
+
|
|
198
209
|
test('drops the value from the form by default when the field unmounts', () => {
|
|
199
210
|
render(<UnregisterTestWrapper />)
|
|
200
211
|
|
|
@@ -404,6 +404,8 @@ function RcSesSelect<TFieldValues extends FieldValues = FieldValues>(
|
|
|
404
404
|
clearOnBlur={false}
|
|
405
405
|
handleHomeEndKeys={false}
|
|
406
406
|
loading={loading}
|
|
407
|
+
loadingText={t('loadingText')}
|
|
408
|
+
noOptionsText={t('noOptionsText')}
|
|
407
409
|
popupIcon={<CaretDownIcon size={20} fillColor={palette.grey['600']} />}
|
|
408
410
|
value={resolvedValue}
|
|
409
411
|
inputValue={resolvedInputValue}
|
|
@@ -57,6 +57,37 @@ describe('RcSesBottomSheet', () => {
|
|
|
57
57
|
expect(onSecondaryAction).toHaveBeenCalledTimes(1)
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
+
it('disables only the primary button when primaryActionDisabled is set', () => {
|
|
61
|
+
const onPrimaryAction = vi.fn()
|
|
62
|
+
const onSecondaryAction = vi.fn()
|
|
63
|
+
render(
|
|
64
|
+
<RcSesBottomSheet
|
|
65
|
+
open
|
|
66
|
+
onClose={vi.fn()}
|
|
67
|
+
title='Filtrai'
|
|
68
|
+
primaryActionLabel='Taikyti'
|
|
69
|
+
onPrimaryAction={onPrimaryAction}
|
|
70
|
+
primaryActionDisabled
|
|
71
|
+
secondaryActionLabel='Atšaukti'
|
|
72
|
+
onSecondaryAction={onSecondaryAction}
|
|
73
|
+
>
|
|
74
|
+
Content
|
|
75
|
+
</RcSesBottomSheet>,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
const primaryButton = screen.getByRole('button', { name: 'Taikyti' })
|
|
79
|
+
const secondaryButton = screen.getByRole('button', { name: 'Atšaukti' })
|
|
80
|
+
|
|
81
|
+
expect(primaryButton).toBeDisabled()
|
|
82
|
+
expect(secondaryButton).toBeEnabled()
|
|
83
|
+
|
|
84
|
+
fireEvent.click(primaryButton)
|
|
85
|
+
fireEvent.click(secondaryButton)
|
|
86
|
+
|
|
87
|
+
expect(onPrimaryAction).not.toHaveBeenCalled()
|
|
88
|
+
expect(onSecondaryAction).toHaveBeenCalledTimes(1)
|
|
89
|
+
})
|
|
90
|
+
|
|
60
91
|
it('renders no footer when no action label is given', () => {
|
|
61
92
|
render(
|
|
62
93
|
<RcSesBottomSheet open onClose={vi.fn()} title='Filtrai'>
|
|
@@ -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',
|
|
@@ -217,19 +221,29 @@ function RcSesBottomSheet({
|
|
|
217
221
|
<Box
|
|
218
222
|
sx={{
|
|
219
223
|
display: 'flex',
|
|
220
|
-
justifyContent: 'flex-end',
|
|
221
224
|
gap: 1.5,
|
|
222
225
|
padding: SHEET.actionsPadding,
|
|
223
226
|
flexShrink: 0,
|
|
224
227
|
}}
|
|
225
228
|
>
|
|
226
229
|
{secondaryActionLabel && (
|
|
227
|
-
<RcSesButton
|
|
230
|
+
<RcSesButton
|
|
231
|
+
variant='outlined'
|
|
232
|
+
color='grey'
|
|
233
|
+
onClick={onSecondaryAction}
|
|
234
|
+
disabled={secondaryActionDisabled}
|
|
235
|
+
sx={{ flex: 1 }}
|
|
236
|
+
>
|
|
228
237
|
{secondaryActionLabel}
|
|
229
238
|
</RcSesButton>
|
|
230
239
|
)}
|
|
231
240
|
{primaryActionLabel && (
|
|
232
|
-
<RcSesButton
|
|
241
|
+
<RcSesButton
|
|
242
|
+
variant='contained'
|
|
243
|
+
onClick={onPrimaryAction}
|
|
244
|
+
disabled={primaryActionDisabled}
|
|
245
|
+
sx={{ flex: 1 }}
|
|
246
|
+
>
|
|
233
247
|
{primaryActionLabel}
|
|
234
248
|
</RcSesButton>
|
|
235
249
|
)}
|
|
@@ -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) => {
|
|
@@ -124,16 +126,7 @@ const RcSesDrawer = ({
|
|
|
124
126
|
gap: '1rem',
|
|
125
127
|
}}
|
|
126
128
|
>
|
|
127
|
-
<Typography
|
|
128
|
-
id={headerId}
|
|
129
|
-
component='h2'
|
|
130
|
-
sx={{
|
|
131
|
-
fontSize: '14px',
|
|
132
|
-
fontStyle: 'normal',
|
|
133
|
-
fontWeight: 600,
|
|
134
|
-
lineHeight: '20px',
|
|
135
|
-
}}
|
|
136
|
-
>
|
|
129
|
+
<Typography id={headerId} variant='h6'>
|
|
137
130
|
{title}
|
|
138
131
|
</Typography>
|
|
139
132
|
<RcSesButton
|
|
@@ -172,12 +165,21 @@ const RcSesDrawer = ({
|
|
|
172
165
|
}}
|
|
173
166
|
>
|
|
174
167
|
{secondaryActionLabel && (
|
|
175
|
-
<RcSesButton
|
|
168
|
+
<RcSesButton
|
|
169
|
+
variant='outlined'
|
|
170
|
+
color='grey'
|
|
171
|
+
onClick={onSecondaryAction}
|
|
172
|
+
disabled={secondaryActionDisabled}
|
|
173
|
+
>
|
|
176
174
|
{secondaryActionLabel}
|
|
177
175
|
</RcSesButton>
|
|
178
176
|
)}
|
|
179
177
|
{primaryActionLabel && (
|
|
180
|
-
<RcSesButton
|
|
178
|
+
<RcSesButton
|
|
179
|
+
variant='contained'
|
|
180
|
+
onClick={onPrimaryAction}
|
|
181
|
+
disabled={primaryActionDisabled}
|
|
182
|
+
>
|
|
181
183
|
{primaryActionLabel}
|
|
182
184
|
</RcSesButton>
|
|
183
185
|
)}
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"countrySelectorLabel": "Select country phone code"
|
|
49
49
|
},
|
|
50
50
|
"search": "Search",
|
|
51
|
-
"invalid": "Invalid phone number format"
|
|
51
|
+
"invalid": "Invalid phone number format",
|
|
52
|
+
"noOptionsText": "No results found"
|
|
52
53
|
},
|
|
53
54
|
|
|
54
55
|
"RcSesSearchableField": {
|
|
@@ -58,7 +59,9 @@
|
|
|
58
59
|
|
|
59
60
|
"RcSesSelect": {
|
|
60
61
|
"searchPlaceholder": "Search",
|
|
61
|
-
"selectAllLabel": "All"
|
|
62
|
+
"selectAllLabel": "All",
|
|
63
|
+
"noOptionsText": "No results found",
|
|
64
|
+
"loadingText": "Loading..."
|
|
62
65
|
},
|
|
63
66
|
|
|
64
67
|
"RcSesSearchInput": {
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"countrySelectorLabel": "Šalies telefono numerio kodo pasirinkimas"
|
|
49
49
|
},
|
|
50
50
|
"search": "Ieškoti",
|
|
51
|
-
"invalid": "Klaidingas telefono numerio formatas"
|
|
51
|
+
"invalid": "Klaidingas telefono numerio formatas",
|
|
52
|
+
"noOptionsText": "Rezultatų nerasta"
|
|
52
53
|
},
|
|
53
54
|
|
|
54
55
|
"RcSesSearchableField": {
|
|
@@ -58,7 +59,9 @@
|
|
|
58
59
|
|
|
59
60
|
"RcSesSelect": {
|
|
60
61
|
"searchPlaceholder": "Ieškoti",
|
|
61
|
-
"selectAllLabel": "Visi"
|
|
62
|
+
"selectAllLabel": "Visi",
|
|
63
|
+
"noOptionsText": "Rezultatų nerasta",
|
|
64
|
+
"loadingText": "Kraunama..."
|
|
62
65
|
},
|
|
63
66
|
|
|
64
67
|
"RcSesSearchInput": {
|
|
@@ -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
|
+
}
|