@registrucentras/rc-ses-react-components 2.0.0-rc.4 → 2.0.0-rc.6
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/WarningCircleIcon.d.ts +1 -1
- package/dist/components/common/Alert/index.d.ts +8 -2
- package/dist/components/common/TitleBlock/types.d.ts +3 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +1581 -1479
- package/dist/stories/components/display/TitleBlock.stories.d.ts +1 -0
- package/dist/stories/components/feedback/Alert.stories.d.ts +4 -0
- package/package.json +1 -1
- package/src/assets/icons/WarningCircleIcon.tsx +8 -2
- package/src/components/common/Alert/index.test.tsx +157 -2
- package/src/components/common/Alert/index.tsx +144 -10
- package/src/components/common/TitleBlock/index.test.tsx +33 -0
- package/src/components/common/TitleBlock/index.tsx +3 -2
- package/src/components/common/TitleBlock/types.ts +3 -1
- package/src/stories/components/display/TitleBlock.stories.tsx +66 -0
- package/src/stories/components/feedback/Alert.stories.tsx +135 -4
- package/src/theme/light/MuiAlert.tsx +28 -20
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react-vite'
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
import { fn } from 'storybook/test'
|
|
2
4
|
|
|
3
5
|
import RcSesAlert from '@/components/common/Alert'
|
|
4
6
|
import FieldPreview from '@/components/storybook/FieldPreview'
|
|
@@ -9,12 +11,40 @@ import PreviewTitle from '@/components/storybook/PreviewTitle'
|
|
|
9
11
|
const lorem =
|
|
10
12
|
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard."
|
|
11
13
|
|
|
12
|
-
const severities
|
|
14
|
+
const severities: Array<'grey' | 'info' | 'success' | 'warning' | 'error'> = [
|
|
15
|
+
'grey',
|
|
16
|
+
'info',
|
|
17
|
+
'success',
|
|
18
|
+
'warning',
|
|
19
|
+
'error',
|
|
20
|
+
]
|
|
13
21
|
|
|
14
22
|
const meta: Meta<typeof RcSesAlert> = {
|
|
15
23
|
title: 'components/feedback/Alert',
|
|
16
24
|
component: RcSesAlert,
|
|
17
25
|
tags: ['autodocs'],
|
|
26
|
+
argTypes: {
|
|
27
|
+
severity: {
|
|
28
|
+
options: severities,
|
|
29
|
+
control: { type: 'select' },
|
|
30
|
+
},
|
|
31
|
+
variant: {
|
|
32
|
+
options: ['outlined', 'filled', 'standard'],
|
|
33
|
+
control: { type: 'select' },
|
|
34
|
+
},
|
|
35
|
+
showIcon: {
|
|
36
|
+
control: 'boolean',
|
|
37
|
+
},
|
|
38
|
+
showAction: {
|
|
39
|
+
control: 'boolean',
|
|
40
|
+
},
|
|
41
|
+
showClose: {
|
|
42
|
+
control: 'boolean',
|
|
43
|
+
},
|
|
44
|
+
actionLabel: {
|
|
45
|
+
control: 'text',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
18
48
|
}
|
|
19
49
|
|
|
20
50
|
export default meta
|
|
@@ -34,7 +64,7 @@ export const Main: Story = {
|
|
|
34
64
|
<FieldPreview>
|
|
35
65
|
<PreviewTitle>State previews</PreviewTitle>
|
|
36
66
|
{severities.map((severity) => (
|
|
37
|
-
<RcSesAlert key={severity} severity={severity}>
|
|
67
|
+
<RcSesAlert key={severity} severity={severity} sx={{ mb: 1 }}>
|
|
38
68
|
{lorem}
|
|
39
69
|
</RcSesAlert>
|
|
40
70
|
))}
|
|
@@ -44,6 +74,9 @@ export const Main: Story = {
|
|
|
44
74
|
args: {
|
|
45
75
|
children: lorem,
|
|
46
76
|
severity: 'info',
|
|
77
|
+
actionLabel: 'Veiksmas',
|
|
78
|
+
onActionClick: fn(),
|
|
79
|
+
onClose: fn(),
|
|
47
80
|
},
|
|
48
81
|
}
|
|
49
82
|
|
|
@@ -54,7 +87,7 @@ export const Main: Story = {
|
|
|
54
87
|
const renderVariants: Story['render'] = (args) => (
|
|
55
88
|
<>
|
|
56
89
|
{severities.map((severity) => (
|
|
57
|
-
<RcSesAlert key={severity} {...args} severity={severity}>
|
|
90
|
+
<RcSesAlert key={severity} {...args} severity={severity} sx={{ mb: 1 }}>
|
|
58
91
|
{lorem}
|
|
59
92
|
</RcSesAlert>
|
|
60
93
|
))}
|
|
@@ -76,6 +109,104 @@ export const Standard: Story = {
|
|
|
76
109
|
args: { variant: 'standard' },
|
|
77
110
|
}
|
|
78
111
|
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
// Action & close — buttons wired up, but not removing the alert on close
|
|
114
|
+
// (see Dismissible below for that). Clicks are logged in the Actions panel.
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
|
|
117
|
+
export const WithActionAndClose: Story = {
|
|
118
|
+
render: renderVariants,
|
|
119
|
+
args: {
|
|
120
|
+
actionLabel: 'Veiksmas',
|
|
121
|
+
onActionClick: fn(),
|
|
122
|
+
onClose: fn(),
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export const WithoutActionAndClose: Story = {
|
|
127
|
+
render: renderVariants,
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
131
|
+
// Toggles — Type × showIcon/showAction/showClose combinations
|
|
132
|
+
// ---------------------------------------------------------------------------
|
|
133
|
+
|
|
134
|
+
export const Toggles: Story = {
|
|
135
|
+
render: () => (
|
|
136
|
+
<>
|
|
137
|
+
<PreviewTitle>showIcon = false</PreviewTitle>
|
|
138
|
+
{severities.map((severity) => (
|
|
139
|
+
<RcSesAlert key={severity} severity={severity} showIcon={false} sx={{ mb: 1 }}>
|
|
140
|
+
{lorem}
|
|
141
|
+
</RcSesAlert>
|
|
142
|
+
))}
|
|
143
|
+
|
|
144
|
+
<PreviewTitle>action only (showClose = false)</PreviewTitle>
|
|
145
|
+
{severities.map((severity) => (
|
|
146
|
+
<RcSesAlert
|
|
147
|
+
key={severity}
|
|
148
|
+
severity={severity}
|
|
149
|
+
actionLabel='Veiksmas'
|
|
150
|
+
onActionClick={fn()}
|
|
151
|
+
onClose={fn()}
|
|
152
|
+
showClose={false}
|
|
153
|
+
sx={{ mb: 1 }}
|
|
154
|
+
>
|
|
155
|
+
{lorem}
|
|
156
|
+
</RcSesAlert>
|
|
157
|
+
))}
|
|
158
|
+
|
|
159
|
+
<PreviewTitle>close only (showAction = false)</PreviewTitle>
|
|
160
|
+
{severities.map((severity) => (
|
|
161
|
+
<RcSesAlert
|
|
162
|
+
key={severity}
|
|
163
|
+
severity={severity}
|
|
164
|
+
actionLabel='Veiksmas'
|
|
165
|
+
onActionClick={fn()}
|
|
166
|
+
onClose={fn()}
|
|
167
|
+
showAction={false}
|
|
168
|
+
sx={{ mb: 1 }}
|
|
169
|
+
>
|
|
170
|
+
{lorem}
|
|
171
|
+
</RcSesAlert>
|
|
172
|
+
))}
|
|
173
|
+
</>
|
|
174
|
+
),
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
// Dismissible — action logs to the console, close actually removes the alert
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
|
|
181
|
+
function DismissibleTemplate() {
|
|
182
|
+
const [visibleSeverities, setVisibleSeverities] = useState<
|
|
183
|
+
Array<(typeof severities)[number]>
|
|
184
|
+
>([...severities])
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<>
|
|
188
|
+
{visibleSeverities.map((severity) => (
|
|
189
|
+
<RcSesAlert
|
|
190
|
+
key={severity}
|
|
191
|
+
severity={severity}
|
|
192
|
+
actionLabel='Veiksmas'
|
|
193
|
+
onActionClick={() => console.log(`${severity} alert action clicked`)}
|
|
194
|
+
onClose={() =>
|
|
195
|
+
setVisibleSeverities((prev) => prev.filter((item) => item !== severity))
|
|
196
|
+
}
|
|
197
|
+
sx={{ mb: 1 }}
|
|
198
|
+
>
|
|
199
|
+
{lorem}
|
|
200
|
+
</RcSesAlert>
|
|
201
|
+
))}
|
|
202
|
+
</>
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export const Dismissible: Story = {
|
|
207
|
+
render: () => <DismissibleTemplate />,
|
|
208
|
+
}
|
|
209
|
+
|
|
79
210
|
// ---------------------------------------------------------------------------
|
|
80
211
|
// Container — full-bleed banner keeping content width-constrained
|
|
81
212
|
// ---------------------------------------------------------------------------
|
|
@@ -3,8 +3,7 @@ import { Components, createTheme } from '@mui/material'
|
|
|
3
3
|
import CheckCircleFillIcon from '@/assets/icons/CheckCircleFillIcon'
|
|
4
4
|
import CloseIcon from '@/assets/icons/CloseIcon'
|
|
5
5
|
import InfoFillIcon from '@/assets/icons/InfoFillIcon'
|
|
6
|
-
import
|
|
7
|
-
import WarningDiamondFillIcon from '@/assets/icons/WarningDiamondFillIcon'
|
|
6
|
+
import WarningCircleIcon from '@/assets/icons/WarningCircleIcon'
|
|
8
7
|
import WarningFillIcon from '@/assets/icons/WarningFillIcon'
|
|
9
8
|
|
|
10
9
|
import palette from '../palette'
|
|
@@ -15,11 +14,11 @@ const MuiAlert: Components['MuiAlert'] = {
|
|
|
15
14
|
defaultProps: {
|
|
16
15
|
elevation: 0,
|
|
17
16
|
iconMapping: {
|
|
18
|
-
grey: <InfoFillIcon />,
|
|
19
|
-
error: <
|
|
20
|
-
info: <
|
|
21
|
-
success: <CheckCircleFillIcon />,
|
|
22
|
-
warning: <WarningFillIcon />,
|
|
17
|
+
grey: <InfoFillIcon weight='regular' aria-hidden />,
|
|
18
|
+
error: <WarningCircleIcon weight='regular' aria-hidden />,
|
|
19
|
+
info: <InfoFillIcon weight='regular' aria-hidden />,
|
|
20
|
+
success: <CheckCircleFillIcon weight='regular' aria-hidden />,
|
|
21
|
+
warning: <WarningFillIcon weight='regular' aria-hidden />,
|
|
23
22
|
},
|
|
24
23
|
slots: {
|
|
25
24
|
closeIcon: CloseIcon,
|
|
@@ -69,13 +68,13 @@ const MuiAlert: Components['MuiAlert'] = {
|
|
|
69
68
|
paddingTop: 0,
|
|
70
69
|
|
|
71
70
|
[breakpoints.up('sm')]: {
|
|
72
|
-
alignSelf: 'center',
|
|
73
71
|
marginRight: '.75rem',
|
|
74
72
|
},
|
|
75
73
|
},
|
|
76
74
|
|
|
77
75
|
message: {
|
|
78
76
|
flexGrow: 1,
|
|
77
|
+
minWidth: 0,
|
|
79
78
|
overflowY: 'hidden',
|
|
80
79
|
|
|
81
80
|
[breakpoints.down('sm')]: {
|
|
@@ -194,53 +193,62 @@ const MuiAlert: Components['MuiAlert'] = {
|
|
|
194
193
|
outlined: {
|
|
195
194
|
fontSize: '.8125rem',
|
|
196
195
|
fontWeight: 400,
|
|
196
|
+
flexWrap: 'nowrap',
|
|
197
|
+
alignItems: 'center',
|
|
198
|
+
gap: '.75rem',
|
|
199
|
+
padding: '.75rem 1rem',
|
|
200
|
+
borderRadius: '0.5rem',
|
|
197
201
|
|
|
198
202
|
[breakpoints.up('md')]: {
|
|
199
203
|
fontSize: '.875rem',
|
|
200
204
|
},
|
|
201
205
|
|
|
206
|
+
'.MuiAlert-icon': {
|
|
207
|
+
alignSelf: 'flex-start',
|
|
208
|
+
margin: 0,
|
|
209
|
+
padding: 0,
|
|
210
|
+
},
|
|
211
|
+
|
|
202
212
|
'.MuiAlert-message': {
|
|
203
213
|
lineHeight: '1rem',
|
|
204
214
|
padding: 0,
|
|
205
215
|
|
|
206
|
-
[breakpoints.up('
|
|
216
|
+
[breakpoints.up('md')]: {
|
|
207
217
|
lineHeight: '1.25rem',
|
|
208
|
-
padding: '.125rem 0',
|
|
209
218
|
},
|
|
210
219
|
|
|
211
220
|
a: {
|
|
212
221
|
fontWeight: 600,
|
|
213
222
|
},
|
|
214
223
|
},
|
|
215
|
-
|
|
216
224
|
// Was outlined<Severity>; see the note on standard above.
|
|
217
225
|
'&.MuiAlert-colorGrey': {
|
|
218
226
|
backgroundColor: palette.grey['50'],
|
|
219
|
-
|
|
227
|
+
border: `1px solid ${palette.grey['200']}`,
|
|
220
228
|
|
|
221
229
|
'.MuiAlert-icon': {
|
|
222
230
|
color: palette.grey['600'],
|
|
223
231
|
},
|
|
224
232
|
},
|
|
225
233
|
'&.MuiAlert-colorError': {
|
|
226
|
-
backgroundColor: palette.error['
|
|
227
|
-
|
|
234
|
+
backgroundColor: palette.error['100'],
|
|
235
|
+
border: `1px solid ${palette.error['500']}`,
|
|
228
236
|
|
|
229
237
|
'.MuiAlert-icon': {
|
|
230
238
|
color: palette.error['600'],
|
|
231
239
|
},
|
|
232
240
|
},
|
|
233
241
|
'&.MuiAlert-colorInfo': {
|
|
234
|
-
backgroundColor: palette.primary['
|
|
235
|
-
|
|
242
|
+
backgroundColor: palette.primary['100'],
|
|
243
|
+
border: `1px solid ${palette.primary['400']}`,
|
|
236
244
|
|
|
237
245
|
'.MuiAlert-icon': {
|
|
238
|
-
color: palette.primary['
|
|
246
|
+
color: palette.primary['600'],
|
|
239
247
|
},
|
|
240
248
|
},
|
|
241
249
|
'&.MuiAlert-colorSuccess': {
|
|
242
250
|
backgroundColor: palette.secondary['100'],
|
|
243
|
-
|
|
251
|
+
border: `1px solid ${palette.secondary['500']}`,
|
|
244
252
|
|
|
245
253
|
'.MuiAlert-icon': {
|
|
246
254
|
color: palette.secondary['600'],
|
|
@@ -248,10 +256,10 @@ const MuiAlert: Components['MuiAlert'] = {
|
|
|
248
256
|
},
|
|
249
257
|
'&.MuiAlert-colorWarning': {
|
|
250
258
|
backgroundColor: palette.warning['100'],
|
|
251
|
-
|
|
259
|
+
border: `1px solid ${palette.warning['400']}`,
|
|
252
260
|
|
|
253
261
|
'.MuiAlert-icon': {
|
|
254
|
-
color: palette.warning['
|
|
262
|
+
color: palette.warning['500'],
|
|
255
263
|
},
|
|
256
264
|
},
|
|
257
265
|
},
|