@registrucentras/rc-ses-react-components 2.6.0 → 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.
- 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 +815 -776
- package/package.json +1 -1
- package/src/assets/icons/phosphorIcons.ts +2 -0
- package/src/components/overlays/BottomSheet/index.test.tsx +31 -0
- package/src/components/overlays/BottomSheet/index.tsx +15 -2
- 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 +13 -2
- package/src/stories/organisms/BottomSheet.stories.tsx +18 -0
- package/src/stories/organisms/Drawer.stories.tsx +36 -0
package/package.json
CHANGED
|
@@ -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)
|
|
@@ -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',
|
|
@@ -224,12 +228,21 @@ function RcSesBottomSheet({
|
|
|
224
228
|
}}
|
|
225
229
|
>
|
|
226
230
|
{secondaryActionLabel && (
|
|
227
|
-
<RcSesButton
|
|
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
|
|
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
|
|
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
|
|
187
|
+
<RcSesButton
|
|
188
|
+
variant='contained'
|
|
189
|
+
onClick={onPrimaryAction}
|
|
190
|
+
disabled={primaryActionDisabled}
|
|
191
|
+
>
|
|
181
192
|
{primaryActionLabel}
|
|
182
193
|
</RcSesButton>
|
|
183
194
|
)}
|
|
@@ -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
|
+
}
|