@registrucentras/rc-ses-react-components 1.6.5 → 1.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.
Files changed (71) hide show
  1. package/dist/assets/icons/ArrowsClockwiseIcon.d.ts +3 -0
  2. package/dist/assets/icons/SearchHelpIcon.d.ts +3 -0
  3. package/dist/assets/icons/SearchXIcon.d.ts +3 -0
  4. package/dist/components/common/Breadcrumbs/index.d.ts +3 -1
  5. package/dist/components/common/Snackbar/SnackbarProvider.d.ts +22 -0
  6. package/dist/components/common/Snackbar/config.d.ts +21 -0
  7. package/dist/components/common/Snackbar/index.d.ts +16 -0
  8. package/dist/components/common/Snackbar/types.d.ts +2 -0
  9. package/dist/components/form/inputs/CheckboxFormControl.d.ts +2 -0
  10. package/dist/components/form/inputs/FormControlLabel.d.ts +10 -0
  11. package/dist/components/form/inputs/SearchInput/index.d.ts +27 -0
  12. package/dist/components/form/inputs/SimpleCheckbox.d.ts +6 -0
  13. package/dist/components/layout/ServiceHeader.d.ts +2 -1
  14. package/dist/components/utils/loading.d.ts +3 -0
  15. package/dist/library/icons.d.ts +5 -1
  16. package/dist/library/index.d.ts +11 -2
  17. package/dist/library/types.d.ts +3 -1
  18. package/dist/registrucentras-rc-ses-react-components.cjs +10 -27
  19. package/dist/registrucentras-rc-ses-react-components.js +3484 -2897
  20. package/dist/stories/components/actions/Button.stories.d.ts +5 -0
  21. package/dist/stories/components/{SelectableCardList.stories.d.ts → display/SelectableCardList.stories.d.ts} +1 -1
  22. package/dist/stories/components/feedback/Snackbar.stories.d.ts +143 -0
  23. package/dist/stories/components/form/CheckboxFormControl.stories.d.ts +3 -0
  24. package/dist/stories/components/form/SimpleCheckbox.stories.d.ts +19 -0
  25. package/dist/stories/components/inputs/SearchInput.stories.d.ts +11 -0
  26. package/dist/stories/components/layout/ServiceHeader.stories.d.ts +1 -0
  27. package/dist/theme/light/MuiOutlinedInput.d.ts +3 -0
  28. package/dist/theme/light/index.d.ts +6 -0
  29. package/dist/theme/palette.d.ts +9 -1
  30. package/package.json +1 -1
  31. package/src/assets/icons/ArrowsClockwiseIcon.tsx +16 -0
  32. package/src/assets/icons/CheckIcon.tsx +1 -1
  33. package/src/assets/icons/SearchHelpIcon.tsx +44 -0
  34. package/src/assets/icons/SearchXIcon.tsx +41 -0
  35. package/src/components/common/Breadcrumbs/index.tsx +4 -3
  36. package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +5 -3
  37. package/src/components/common/ListWithIcons/index.tsx +1 -1
  38. package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +3 -1
  39. package/src/components/common/Snackbar/SnackbarProvider.tsx +78 -0
  40. package/src/components/common/Snackbar/config.ts +77 -0
  41. package/src/components/common/Snackbar/index.test.tsx +119 -0
  42. package/src/components/common/Snackbar/index.tsx +181 -0
  43. package/src/components/common/Snackbar/types.ts +2 -0
  44. package/src/components/form/inputs/Checkbox.tsx +2 -2
  45. package/src/components/form/inputs/CheckboxFormControl.test.tsx +68 -0
  46. package/src/components/form/inputs/CheckboxFormControl.tsx +48 -29
  47. package/src/components/form/inputs/FormControlLabel.tsx +36 -0
  48. package/src/components/form/inputs/SearchInput/index.test.tsx +203 -0
  49. package/src/components/form/inputs/SearchInput/index.tsx +282 -0
  50. package/src/components/form/inputs/SimpleCheckbox.tsx +23 -0
  51. package/src/components/layout/ServiceHeader.tsx +22 -8
  52. package/src/components/utils/loading.tsx +9 -0
  53. package/src/i18n/namespaces/input/en.json +11 -0
  54. package/src/i18n/namespaces/input/lt.json +11 -0
  55. package/src/library/icons.ts +8 -0
  56. package/src/library/index.ts +15 -1
  57. package/src/library/types.ts +9 -1
  58. package/src/stories/Colors.mdx +127 -0
  59. package/src/stories/components/actions/Button.stories.tsx +130 -0
  60. package/src/stories/components/{SelectableCardList.stories.tsx → display/SelectableCardList.stories.tsx} +36 -19
  61. package/src/stories/components/feedback/Snackbar.stories.tsx +504 -0
  62. package/src/stories/components/form/CheckboxFormControl.stories.tsx +312 -2
  63. package/src/stories/components/form/SimpleCheckbox.stories.tsx +52 -0
  64. package/src/stories/components/icons/Icons.stories.tsx +35 -0
  65. package/src/stories/components/inputs/SearchInput.stories.tsx +134 -0
  66. package/src/stories/components/layout/ServiceHeader.stories.tsx +43 -8
  67. package/src/theme/light/MuiButton.tsx +34 -1
  68. package/src/theme/light/MuiOutlinedInput.ts +15 -0
  69. package/src/theme/light/index.tsx +8 -0
  70. package/src/theme/light/themePalette.tsx +2 -0
  71. package/src/theme/palette.tsx +11 -1
@@ -0,0 +1,504 @@
1
+ import { Box, Button } from '@mui/material'
2
+ import type { Meta } from '@storybook/react'
3
+
4
+ import RcSesSnackbar from '@/components/common/Snackbar'
5
+ import {
6
+ RcSesSnackbarProvider,
7
+ useSnackbar,
8
+ } from '@/components/common/Snackbar/SnackbarProvider'
9
+ import { stateConfig } from '@/components/common/Snackbar/config'
10
+ import type { SnackbarState } from '@/components/common/Snackbar/types'
11
+
12
+ const getButtonColor = (state: SnackbarState): any => {
13
+ if (state === 'error') return 'error'
14
+ if (state === 'warning') return 'warning'
15
+ if (state === 'info') return 'info'
16
+ return undefined
17
+ }
18
+
19
+ const getStateLabel = (state: SnackbarState): string =>
20
+ state.charAt(0).toUpperCase() + state.slice(1).replace('-', ' ')
21
+
22
+ const meta: Meta<typeof RcSesSnackbar> = {
23
+ title: 'components/feedback/Snackbar',
24
+ component: RcSesSnackbar,
25
+ tags: ['autodocs'],
26
+ decorators: [
27
+ (Story) => (
28
+ <RcSesSnackbarProvider>
29
+ <Box sx={{ p: 4, pb: 16, minHeight: '300px' }}>
30
+ <Story />
31
+ </Box>
32
+ </RcSesSnackbarProvider>
33
+ ),
34
+ ],
35
+ }
36
+
37
+ export default meta
38
+
39
+ const COMPACT_CONFIG = [
40
+ { state: 'success' as SnackbarState, message: 'Sėkmingai išsaugota' },
41
+ { state: 'error' as SnackbarState, message: 'Įvyko klaida' },
42
+ { state: 'warning' as SnackbarState, message: 'Dėmesio pranešimas' },
43
+ { state: 'info' as SnackbarState, message: 'Informacinis pranešimas' },
44
+ ]
45
+
46
+ const STANDARD_CONFIG = [
47
+ {
48
+ state: 'success' as SnackbarState,
49
+ message: 'Sėkmingai išsaugota',
50
+ actionLabel: 'Atgal',
51
+ },
52
+ {
53
+ state: 'error' as SnackbarState,
54
+ message: 'Įvyko klaida',
55
+ actionLabel: 'Pakartoti',
56
+ },
57
+ {
58
+ state: 'warning' as SnackbarState,
59
+ message: 'Dėmesio pranešimas',
60
+ actionLabel: 'Sąlyga',
61
+ },
62
+ {
63
+ state: 'info' as SnackbarState,
64
+ message: 'Informacinis pranešimas',
65
+ actionLabel: 'Daugiau',
66
+ },
67
+ {
68
+ state: 'action-needed' as SnackbarState,
69
+ message: 'Reikalingas veiksmas',
70
+ actionLabel: 'Atlikti',
71
+ },
72
+ ]
73
+
74
+ export const Default = {
75
+ render: (args: any) => (
76
+ <Box sx={{ pb: 12 }}>
77
+ <RcSesSnackbar
78
+ key={`${args.state}-${args.message}-${args.size}-${args.persist}`}
79
+ {...args}
80
+ />
81
+ </Box>
82
+ ),
83
+ args: {
84
+ open: true,
85
+ state: 'success',
86
+ message: 'Sėkmingai išsaugota',
87
+ size: 'standard',
88
+ actionLabel: 'Atgal',
89
+ duration: 10000,
90
+ persist: true,
91
+ showClose: true,
92
+ dismissOnAction: true,
93
+ },
94
+ argTypes: {
95
+ open: {
96
+ control: 'boolean',
97
+ description: 'Control snackbar visibility',
98
+ },
99
+ state: {
100
+ control: 'select',
101
+ options: ['success', 'error', 'warning', 'info', 'action-needed'],
102
+ description: 'Snackbar state determines icon, color, and aria-live level',
103
+ },
104
+ message: {
105
+ control: 'text',
106
+ description: 'Notification message text (truncates with ellipsis)',
107
+ },
108
+ size: {
109
+ control: 'radio',
110
+ options: ['standard', 'compact'],
111
+ description: 'Standard (400×60px) or Compact (320×48px)',
112
+ },
113
+ duration: {
114
+ control: { type: 'number', min: 1000, max: 30000, step: 1000 },
115
+ description: 'Auto-dismiss duration in milliseconds (ignored if persist=true)',
116
+ },
117
+ persist: {
118
+ control: 'boolean',
119
+ description: 'If true, snackbar will not auto-dismiss',
120
+ },
121
+ showClose: {
122
+ control: 'boolean',
123
+ description: 'Show/hide close button',
124
+ },
125
+ dismissOnAction: {
126
+ control: 'boolean',
127
+ description: 'Close snackbar when action button is clicked',
128
+ },
129
+ actionLabel: {
130
+ control: 'text',
131
+ description: 'Action button label (only shown in standard size)',
132
+ },
133
+ onAction: {
134
+ action: 'onAction',
135
+ description: 'Callback when action button is clicked',
136
+ },
137
+ onClose: {
138
+ action: 'onClose',
139
+ description: 'Callback when snackbar closes',
140
+ },
141
+ },
142
+ parameters: {
143
+ docs: {
144
+ description: {
145
+ story:
146
+ 'Interactive playground to test different Snackbar configurations. Adjust all props using the controls above to see how the component responds in real-time. Use this for direct component testing.',
147
+ },
148
+ },
149
+ },
150
+ }
151
+
152
+ function SnackbarDemoCompactWithText() {
153
+ const { showSnackbar } = useSnackbar()
154
+
155
+ return (
156
+ <Box sx={{ display: 'flex', gap: 1, flexWrap: 'wrap' }}>
157
+ {COMPACT_CONFIG.map(({ state: snackbarState, message }) => {
158
+ const Icon = stateConfig[snackbarState].icon
159
+ return (
160
+ <Button
161
+ key={snackbarState}
162
+ variant='contained'
163
+ color={getButtonColor(snackbarState) as any}
164
+ startIcon={<Icon />}
165
+ onClick={() =>
166
+ showSnackbar({ state: snackbarState, message, size: 'compact' })
167
+ }
168
+ >
169
+ {getStateLabel(snackbarState)} (Compact)
170
+ </Button>
171
+ )
172
+ })}
173
+ </Box>
174
+ )
175
+ }
176
+
177
+ export const CompactWithText = {
178
+ render: () => <SnackbarDemoCompactWithText />,
179
+ parameters: {
180
+ docs: {
181
+ description: {
182
+ story:
183
+ 'Demonstrates compact-size snackbars across all 4 states. Compact size does not support action buttons.',
184
+ },
185
+ source: {
186
+ code: `// Setup at app root
187
+ import { RcSesSnackbarProvider } from 'rc-ses-react-components'
188
+
189
+ <RcSesSnackbarProvider>
190
+ <App />
191
+ </RcSesSnackbarProvider>
192
+
193
+ // Usage in component
194
+ const { showSnackbar } = useSnackbar()
195
+
196
+ // Show different state snackbars
197
+ showSnackbar({
198
+ state: 'success',
199
+ message: 'Sėkmingai išsaugota',
200
+ size: 'compact',
201
+ })
202
+
203
+ showSnackbar({
204
+ state: 'error',
205
+ message: 'Įvyko klaida',
206
+ size: 'compact',
207
+ })
208
+
209
+ showSnackbar({
210
+ state: 'warning',
211
+ message: 'Dėmesio pranešimas',
212
+ size: 'compact',
213
+ })
214
+
215
+ showSnackbar({
216
+ state: 'info',
217
+ message: 'Informacinis pranešimas',
218
+ size: 'compact',
219
+ })`,
220
+ },
221
+ },
222
+ },
223
+ }
224
+
225
+ function SnackbarDemoStandardWithButtons() {
226
+ const { showSnackbar } = useSnackbar()
227
+
228
+ return (
229
+ <Box sx={{ display: 'flex', gap: 1, flexWrap: 'wrap' }}>
230
+ {STANDARD_CONFIG.map(({ state: snackbarState, message, actionLabel }) => {
231
+ const Icon = stateConfig[snackbarState].icon
232
+ return (
233
+ <Button
234
+ key={snackbarState}
235
+ variant='contained'
236
+ color={getButtonColor(snackbarState) as any}
237
+ startIcon={<Icon />}
238
+ onClick={() =>
239
+ showSnackbar({
240
+ state: snackbarState,
241
+ message,
242
+ actionLabel,
243
+ size: 'standard',
244
+ onAction: () => {
245
+ // eslint-disable-next-line no-console
246
+ console.log(`${actionLabel} clicked`)
247
+ },
248
+ })
249
+ }
250
+ >
251
+ {getStateLabel(snackbarState)} (Standard)
252
+ </Button>
253
+ )
254
+ })}
255
+ </Box>
256
+ )
257
+ }
258
+
259
+ export const StandardWithButtons = {
260
+ render: () => <SnackbarDemoStandardWithButtons />,
261
+ parameters: {
262
+ docs: {
263
+ description: {
264
+ story: 'Demonstrates standard-size snackbars with action buttons.',
265
+ },
266
+ source: {
267
+ code: `// Setup at app root
268
+ import { RcSesSnackbarProvider } from 'rc-ses-react-components'
269
+
270
+ <RcSesSnackbarProvider>
271
+ <App />
272
+ </RcSesSnackbarProvider>
273
+
274
+ // Usage in component
275
+ const { showSnackbar } = useSnackbar()
276
+
277
+ // Success with action
278
+ showSnackbar({
279
+ state: 'success',
280
+ message: 'Sėkmingai išsaugota',
281
+ actionLabel: 'Atgal',
282
+ size: 'standard',
283
+ onAction: () => console.log('Atgal clicked'),
284
+ })
285
+
286
+ // Error with action
287
+ showSnackbar({
288
+ state: 'error',
289
+ message: 'Įvyko klaida',
290
+ actionLabel: 'Pakartoti',
291
+ size: 'standard',
292
+ onAction: () => console.log('Pakartoti clicked'),
293
+ })
294
+
295
+ // Warning with action
296
+ showSnackbar({
297
+ state: 'warning',
298
+ message: 'Dėmesio pranešimas',
299
+ actionLabel: 'Sąlyga',
300
+ size: 'standard',
301
+ onAction: () => console.log('Sąlyga clicked'),
302
+ })
303
+
304
+ // Info with action
305
+ showSnackbar({
306
+ state: 'info',
307
+ message: 'Informacinis pranešimas',
308
+ actionLabel: 'Daugiau',
309
+ size: 'standard',
310
+ onAction: () => console.log('Daugiau clicked'),
311
+ })
312
+
313
+ // Action needed with action
314
+ showSnackbar({
315
+ state: 'action-needed',
316
+ message: 'Reikalingas veiksmas',
317
+ actionLabel: 'Atlikti',
318
+ size: 'standard',
319
+ onAction: () => console.log('Atlikti clicked'),
320
+ })`,
321
+ },
322
+ },
323
+ },
324
+ }
325
+
326
+ function SnackbarDemoCustomDuration() {
327
+ const { showSnackbar } = useSnackbar()
328
+
329
+ return (
330
+ <Box sx={{ display: 'flex', gap: 1, flexWrap: 'wrap' }}>
331
+ <Button
332
+ variant='contained'
333
+ onClick={() =>
334
+ showSnackbar({
335
+ state: 'success',
336
+ message: 'Trumpai išsaugota (3s)',
337
+ duration: 3000,
338
+ })
339
+ }
340
+ >
341
+ 3s Duration
342
+ </Button>
343
+ <Button
344
+ variant='contained'
345
+ onClick={() =>
346
+ showSnackbar({
347
+ state: 'success',
348
+ message: 'Ilgiau išsaugota (10s)',
349
+ duration: 10000,
350
+ })
351
+ }
352
+ >
353
+ 10s Duration
354
+ </Button>
355
+ </Box>
356
+ )
357
+ }
358
+
359
+ export const CustomDuration = {
360
+ render: () => <SnackbarDemoCustomDuration />,
361
+ parameters: {
362
+ docs: {
363
+ description: {
364
+ story:
365
+ 'Demonstrates custom auto-dismiss durations (3s and 10s). Hover over a snackbar to pause the countdown timer - the auto-dismiss will resume when you move the mouse away.',
366
+ },
367
+ source: {
368
+ code: `// Setup at app root
369
+ import { RcSesSnackbarProvider } from 'rc-ses-react-components'
370
+
371
+ <RcSesSnackbarProvider>
372
+ <App />
373
+ </RcSesSnackbarProvider>
374
+
375
+ // Usage in component
376
+ const { showSnackbar } = useSnackbar()
377
+
378
+ // 3 second duration
379
+ showSnackbar({
380
+ state: 'success',
381
+ message: 'Trumpai išsaugota (3s)',
382
+ duration: 3000,
383
+ })
384
+
385
+ // 10 second duration
386
+ showSnackbar({
387
+ state: 'success',
388
+ message: 'Ilgiau išsaugota (10s)',
389
+ duration: 10000,
390
+ })`,
391
+ },
392
+ },
393
+ },
394
+ }
395
+
396
+ function SnackbarDemoPersistent() {
397
+ const { showSnackbar } = useSnackbar()
398
+
399
+ return (
400
+ <Box sx={{ display: 'flex', gap: 1, flexWrap: 'wrap' }}>
401
+ <Button
402
+ variant='contained'
403
+ onClick={() =>
404
+ showSnackbar({
405
+ state: 'action-needed',
406
+ message: 'Statiškas pranešimas',
407
+ actionLabel: 'Patvirtinti',
408
+ persist: true,
409
+ showClose: true,
410
+ onAction: () => {
411
+ // eslint-disable-next-line no-console
412
+ console.log('Patvirtinta')
413
+ },
414
+ })
415
+ }
416
+ >
417
+ Persistent Snackbar
418
+ </Button>
419
+ </Box>
420
+ )
421
+ }
422
+
423
+ export const Persistent = {
424
+ render: () => <SnackbarDemoPersistent />,
425
+ parameters: {
426
+ docs: {
427
+ description: {
428
+ story:
429
+ 'Demonstrates persistent snackbars that do not auto-dismiss. Users must click the action button or close button.',
430
+ },
431
+ source: {
432
+ code: `// Setup at app root
433
+ import { RcSesSnackbarProvider } from 'rc-ses-react-components'
434
+
435
+ <RcSesSnackbarProvider>
436
+ <App />
437
+ </RcSesSnackbarProvider>
438
+
439
+ // Usage in component
440
+ const { showSnackbar } = useSnackbar()
441
+
442
+ showSnackbar({
443
+ state: 'action-needed',
444
+ message: 'Statiškas pranešimas',
445
+ actionLabel: 'Patvirtinti',
446
+ persist: true,
447
+ showClose: true,
448
+ })`,
449
+ },
450
+ },
451
+ },
452
+ }
453
+
454
+ function SnackbarDemoLongText() {
455
+ const { showSnackbar } = useSnackbar()
456
+
457
+ return (
458
+ <Box sx={{ display: 'flex', gap: 1, flexWrap: 'wrap' }}>
459
+ <Button
460
+ variant='contained'
461
+ color='info'
462
+ onClick={() =>
463
+ showSnackbar({
464
+ state: 'info',
465
+ message:
466
+ 'Tai yra labai ilgas pranešimas kuris turėtų būti trumpintas su elipsu jei nepakanka vietos komponente. Šis tekstas skirtas testuoti teksto trumpinimą',
467
+ showClose: true,
468
+ })
469
+ }
470
+ >
471
+ Long Text (Truncation)
472
+ </Button>
473
+ </Box>
474
+ )
475
+ }
476
+
477
+ export const LongText = {
478
+ render: () => <SnackbarDemoLongText />,
479
+ parameters: {
480
+ docs: {
481
+ description: {
482
+ story:
483
+ 'Demonstrates how lengthy messages are truncated with ellipsis (...) when they exceed the snackbar width.',
484
+ },
485
+ source: {
486
+ code: `// Setup at app root
487
+ import { RcSesSnackbarProvider } from 'rc-ses-react-components'
488
+
489
+ <RcSesSnackbarProvider>
490
+ <App />
491
+ </RcSesSnackbarProvider>
492
+
493
+ // Usage in component
494
+ const { showSnackbar } = useSnackbar()
495
+
496
+ showSnackbar({
497
+ state: 'info',
498
+ message: 'Tai yra labai ilgas pranešimas kuris turėtų būti trump intas su elipsu jei nepakanka vietos komponente. Šis tekstas skirtas testuoti teksto trumpinimą',
499
+ showClose: true,
500
+ })`,
501
+ },
502
+ },
503
+ },
504
+ }