@registrucentras/rc-ses-react-components 1.10.0 → 1.12.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 (43) hide show
  1. package/README.md +5 -1
  2. package/dist/components/common/Badge/index.d.ts +10 -0
  3. package/dist/components/common/SelectableCardList/index.d.ts +1 -1
  4. package/dist/components/common/Switch/index.d.ts +10 -0
  5. package/dist/components/common/Tooltip/index.d.ts +20 -0
  6. package/dist/library/index.d.ts +5 -1
  7. package/dist/library/types.d.ts +2 -1
  8. package/dist/registrucentras-rc-ses-react-components.cjs +10 -10
  9. package/dist/registrucentras-rc-ses-react-components.js +3120 -2757
  10. package/dist/stories/components/display/Badge.stories.d.ts +9 -0
  11. package/dist/stories/components/display/SelectableCardList.stories.d.ts +8 -1
  12. package/dist/stories/components/display/Tooltip.stories.d.ts +48 -0
  13. package/dist/stories/components/inputs/Switch.stories.d.ts +17 -0
  14. package/dist/theme/light/MuiSwitch.d.ts +3 -0
  15. package/dist/theme/light/MuiTooltip.d.ts +3 -0
  16. package/package.json +1 -1
  17. package/src/components/common/Badge/index.test.tsx +129 -0
  18. package/src/components/common/Badge/index.tsx +162 -0
  19. package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +7 -5
  20. package/src/components/common/SelectableCardList/index.test.tsx +56 -2
  21. package/src/components/common/SelectableCardList/index.tsx +23 -10
  22. package/src/components/common/Switch/index.test.tsx +214 -0
  23. package/src/components/common/Switch/index.tsx +49 -0
  24. package/src/components/common/Tooltip/index.test.tsx +87 -0
  25. package/src/components/common/Tooltip/index.tsx +167 -0
  26. package/src/components/form/inputs/Select/index.test.tsx +102 -0
  27. package/src/components/form/inputs/Select/index.tsx +107 -53
  28. package/src/i18n/namespaces/common/en.json +3 -0
  29. package/src/i18n/namespaces/common/lt.json +3 -0
  30. package/src/i18n/namespaces/input/en.json +6 -0
  31. package/src/i18n/namespaces/input/lt.json +6 -0
  32. package/src/library/index.ts +6 -0
  33. package/src/library/types.ts +2 -0
  34. package/src/stories/components/display/Badge.stories.tsx +165 -0
  35. package/src/stories/components/display/SelectableCardList.stories.tsx +16 -0
  36. package/src/stories/components/display/Tooltip.stories.tsx +67 -0
  37. package/src/stories/components/inputs/Select.stories.tsx +38 -2
  38. package/src/stories/components/inputs/Switch.stories.tsx +70 -0
  39. package/src/theme/light/MuiAutocomplete.ts +3 -1
  40. package/src/theme/light/MuiInputBase.ts +4 -0
  41. package/src/theme/light/MuiSwitch.tsx +77 -0
  42. package/src/theme/light/MuiTooltip.ts +40 -0
  43. package/src/theme/light/index.tsx +4 -0
@@ -53,19 +53,22 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
53
53
  }
54
54
 
55
55
  function RcSesSelect(props: Props) {
56
- const [inputValue, setInputValue] = React.useState('')
57
56
  const [dropdownSearchValue, setDropdownSearchValue] = React.useState('')
58
57
  const [open, setOpen] = React.useState(false)
59
58
  const dropdownSearchOptionValue = '__dropdown-search-option__'
59
+ // rem widths reserved at the end of the input for the clear and dropdown adornments
60
+ const reservedSingleEndAdornmentWidth = 2
61
+ const reservedMultipleTagsEndAdornmentWidth = 2.2
62
+ const reservedMultipleWithCounterEndAdornmentWidth = 3
60
63
  const wrapperRef = React.useRef<HTMLDivElement>(null)
61
64
 
62
65
  const {
63
66
  multiple = false,
64
67
  clearable,
65
- limitTags = 1,
66
68
  control,
67
69
  errors,
68
70
  label,
71
+ limitTags,
69
72
  loading,
70
73
  onInputChange,
71
74
  options,
@@ -82,6 +85,7 @@ function RcSesSelect(props: Props) {
82
85
  const { disabled, name } = fieldProps
83
86
 
84
87
  const id = useMemo(() => fieldProps.id ?? uuidv4(), [fieldProps.id])
88
+ const selectedValueId = useMemo(() => `rc-ses-select-single-value-${id}`, [id])
85
89
 
86
90
  const {
87
91
  field: { onChange, value },
@@ -104,6 +108,20 @@ function RcSesSelect(props: Props) {
104
108
  return options.find((o) => o.value === value) ?? null
105
109
  }, [value, options, multiple])
106
110
 
111
+ const selectedSingleLabel =
112
+ !multiple && resolvedValue && !Array.isArray(resolvedValue) ? resolvedValue.label : ''
113
+
114
+ const selectedTagCount =
115
+ multiple && Array.isArray(resolvedValue) ? resolvedValue.length : 0
116
+ const hasLimitTagCounter =
117
+ multiple && (limitTags ?? -1) > -1 && selectedTagCount > (limitTags ?? -1)
118
+ const reservedMultipleEndAdornmentWidth = hasLimitTagCounter
119
+ ? reservedMultipleWithCounterEndAdornmentWidth
120
+ : reservedMultipleTagsEndAdornmentWidth
121
+
122
+ const [inputValue, setInputValue] = React.useState('')
123
+ const resolvedInputValue = dropdownSearch ? '' : inputValue
124
+
107
125
  const searchRowOption = useMemo<Option>(
108
126
  () => ({ label: '', value: dropdownSearchOptionValue }),
109
127
  [dropdownSearchOptionValue],
@@ -131,7 +149,10 @@ function RcSesSelect(props: Props) {
131
149
  }
132
150
  }
133
151
 
134
- const filteredOptions = useFilteredOptions(options, dropdownSearchValue)
152
+ const filteredOptions = useFilteredOptions(
153
+ options,
154
+ dropdownSearch ? dropdownSearchValue : inputValue,
155
+ )
135
156
 
136
157
  const selectedValues = Array.isArray(value) ? value : []
137
158
  const { allSelected: allFilteredSelected, toggle: handleSelectAll } = useSelectAll(
@@ -141,15 +162,22 @@ function RcSesSelect(props: Props) {
141
162
  )
142
163
 
143
164
  const filterOptions = (opts: Option[]) => {
144
- if (!dropdownSearch || hasCustomGroupBy) return opts
165
+ if (dropdownSearch && !hasCustomGroupBy) {
166
+ const [searchOption, ...realOptions] = opts
167
+ if (!dropdownSearchValue.trim()) return opts
145
168
 
146
- const [searchOption, ...realOptions] = opts
147
- if (!dropdownSearchValue.trim()) return opts
169
+ const filteredValues = new Set(filteredOptions.map((o) => o.value))
170
+ const filtered = realOptions.filter((opt) => filteredValues.has(opt.value))
148
171
 
149
- const filteredValues = new Set(filteredOptions.map((o) => o.value))
150
- const filtered = realOptions.filter((opt) => filteredValues.has(opt.value))
172
+ return [searchOption, ...filtered]
173
+ }
174
+
175
+ if (dropdownSearch && hasCustomGroupBy) return opts
151
176
 
152
- return [searchOption, ...filtered]
177
+ if (!inputValue.trim() || inputValue === selectedSingleLabel) return opts
178
+
179
+ const filteredValues = new Set(filteredOptions.map((o) => o.value))
180
+ return opts.filter((opt) => filteredValues.has(opt.value))
153
181
  }
154
182
 
155
183
  const closeDropdown = () => {
@@ -157,6 +185,13 @@ function RcSesSelect(props: Props) {
157
185
  setDropdownSearchValue('')
158
186
  }
159
187
 
188
+ // clear input when dropdown closes
189
+ const closeDropdownWithClear = () => {
190
+ setOpen(false)
191
+ setDropdownSearchValue('')
192
+ setInputValue('')
193
+ }
194
+
160
195
  const shouldKeepDropdownOpen = () => {
161
196
  const activeEl = document.activeElement
162
197
  if (!(activeEl instanceof Element)) return false
@@ -186,7 +221,7 @@ function RcSesSelect(props: Props) {
186
221
  open={open}
187
222
  onOpen={() => setOpen(true)}
188
223
  multiple={multiple}
189
- limitTags={multiple ? limitTags : undefined}
224
+ limitTags={multiple ? (limitTags ?? -1) : undefined}
190
225
  disableCloseOnSelect={multiple}
191
226
  disabled={disabled}
192
227
  disableClearable={clearable === false}
@@ -203,12 +238,11 @@ function RcSesSelect(props: Props) {
203
238
  }}
204
239
  loading={loading}
205
240
  value={resolvedValue}
206
- inputValue={dropdownSearch ? undefined : inputValue}
241
+ inputValue={resolvedInputValue}
207
242
  onChange={handleChange}
208
243
  onInputChange={(event, val, reason) => {
209
244
  if (dropdownSearch) return
210
-
211
- setInputValue(val ?? '')
245
+ setInputValue(val)
212
246
  onInputChange?.(event, val, reason)
213
247
  }}
214
248
  onClose={(_event, reason) => {
@@ -216,7 +250,7 @@ function RcSesSelect(props: Props) {
216
250
  deferCloseCheck()
217
251
  return
218
252
  }
219
- closeDropdown()
253
+ closeDropdownWithClear()
220
254
  }}
221
255
  isOptionEqualToValue={(option, val) => option.value === val.value}
222
256
  getOptionLabel={(option) => option.label}
@@ -247,9 +281,9 @@ function RcSesSelect(props: Props) {
247
281
  {...params}
248
282
  disabled={disabled}
249
283
  error={hasError}
250
- placeholder={placeholder}
284
+ placeholder={!multiple && selectedSingleLabel ? undefined : placeholder}
251
285
  sx={{
252
- ...(dropdownSearch
286
+ ...(dropdownSearch || (!multiple && selectedSingleLabel)
253
287
  ? {
254
288
  '& .MuiInputBase-input': {
255
289
  caretColor: 'transparent',
@@ -260,34 +294,39 @@ function RcSesSelect(props: Props) {
260
294
  ? {
261
295
  '& .MuiAutocomplete-inputRoot': {
262
296
  alignItems: 'center',
263
- pb: '0 !important',
264
- pt: '0 !important',
265
- },
266
- '& .MuiOutlinedInput-root': {
267
- alignItems: 'center',
268
- flexWrap: 'nowrap',
269
- height: '2.75rem',
270
- minHeight: '2.75rem',
271
- overflow: 'hidden',
272
- pl: '.375rem',
273
- py: 0,
297
+ pr: `calc(${reservedMultipleEndAdornmentWidth}rem) !important`,
274
298
  },
275
- '& .MuiAutocomplete-tag': {
276
- alignSelf: 'center',
277
- m: '0 .25rem 0 .35rem',
278
- maxWidth: 'calc(100% - 3.5rem)',
299
+ }
300
+ : {
301
+ '& .rc-ses-select-single-value': {
302
+ boxSizing: 'border-box',
303
+ display: 'block',
304
+ overflowWrap: 'anywhere',
305
+ paddingLeft: '.75rem',
306
+ pointerEvents: 'none',
307
+ width: '100%',
279
308
  },
280
309
  '& .MuiAutocomplete-input': {
281
- minWidth: 0,
310
+ marginRight: `calc(${reservedSingleEndAdornmentWidth}rem) !important`,
282
311
  },
283
- }
284
- : {}),
312
+ }),
285
313
  }}
286
314
  InputProps={{
287
315
  ...params.InputProps,
316
+ startAdornment:
317
+ !multiple && selectedSingleLabel ? (
318
+ <Box id={selectedValueId} className='rc-ses-select-single-value'>
319
+ {selectedSingleLabel}
320
+ </Box>
321
+ ) : (
322
+ params.InputProps.startAdornment
323
+ ),
288
324
  inputProps: {
289
325
  ...params.inputProps,
290
- readOnly: dropdownSearch,
326
+ 'aria-describedby':
327
+ !multiple && selectedSingleLabel ? selectedValueId : undefined,
328
+ value: !multiple && selectedSingleLabel ? '' : params.inputProps?.value,
329
+ readOnly: dropdownSearch || (!multiple && !!selectedSingleLabel),
291
330
  },
292
331
  }}
293
332
  />
@@ -458,28 +497,43 @@ function RcSesSelect(props: Props) {
458
497
  </Box>
459
498
  )
460
499
  }}
461
- renderTags={(tagValues, getTagProps) => {
462
- const visible = tagValues.slice(0, limitTags)
463
- const hiddenCount = tagValues.length - visible.length
500
+ renderTags={(tagValues, getTagProps, ownerState) => {
501
+ const visibleTagLimit = ownerState.limitTags ?? -1
502
+ const shouldLimitTags =
503
+ visibleTagLimit > -1 && tagValues.length > visibleTagLimit
504
+ const visibleTags = shouldLimitTags
505
+ ? tagValues.slice(0, visibleTagLimit)
506
+ : tagValues
507
+ const hiddenTagCount = tagValues.length - visibleTags.length
508
+
464
509
  return (
465
510
  <>
466
- {visible.map((option, index) => {
511
+ {visibleTags.map((option, index) => {
467
512
  const { key, ...tagProps } = getTagProps({ index })
468
- return <Chip key={key} label={option.label} size='small' {...tagProps} />
513
+ return (
514
+ <Chip
515
+ key={key}
516
+ label={option.label}
517
+ size='small'
518
+ sx={{
519
+ height: 'auto',
520
+ maxWidth: `calc(100% - ${reservedMultipleEndAdornmentWidth}rem)`,
521
+ '& .MuiChip-label': {
522
+ display: 'block',
523
+ overflowWrap: 'anywhere',
524
+ py: '.25rem',
525
+ textOverflow: 'clip',
526
+ whiteSpace: 'normal',
527
+ },
528
+ }}
529
+ {...tagProps}
530
+ />
531
+ )
469
532
  })}
470
- {hiddenCount > 0 && (
471
- <Box
472
- component='span'
473
- sx={{
474
- alignSelf: 'center',
475
- color: 'text.secondary',
476
- flexShrink: 0,
477
- fontSize: '.8125rem',
478
- ml: '.25rem',
479
- whiteSpace: 'nowrap',
480
- }}
481
- >
482
- +{hiddenCount}
533
+
534
+ {hiddenTagCount > 0 && (
535
+ <Box component='span' className='MuiAutocomplete-tag'>
536
+ {ownerState.getLimitTagsText?.(hiddenTagCount) ?? `+${hiddenTagCount}`}
483
537
  </Box>
484
538
  )}
485
539
  </>
@@ -14,6 +14,9 @@
14
14
  "SegmentedControl": {
15
15
  "options": "Options",
16
16
  "tabs": "Tabs"
17
+ },
18
+ "Tooltip": {
19
+ "trigger": "Explanation"
17
20
  }
18
21
  }
19
22
  }
@@ -14,6 +14,9 @@
14
14
  "SegmentedControl": {
15
15
  "options": "Parinktys",
16
16
  "tabs": "Skirtukai"
17
+ },
18
+ "Tooltip": {
19
+ "trigger": "Paaiškinimas"
17
20
  }
18
21
  }
19
22
  }
@@ -4,6 +4,12 @@
4
4
  "close": "Close"
5
5
  },
6
6
 
7
+ "RcSesBadge": {
8
+ "aria": {
9
+ "close": "Remove {{label}}"
10
+ }
11
+ },
12
+
7
13
  "RcSesButtonWithPopover": {
8
14
  "aria": {
9
15
  "label": "Additional information"
@@ -4,6 +4,12 @@
4
4
  "close": "Uždaryti"
5
5
  },
6
6
 
7
+ "RcSesBadge": {
8
+ "aria": {
9
+ "close": "Pašalinti {{label}}"
10
+ }
11
+ },
12
+
7
13
  "RcSesButtonWithPopover": {
8
14
  "aria": {
9
15
  "label": "Daugiau informacijos"
@@ -6,6 +6,7 @@ import RcSesIconProps from '@/assets/IconProps'
6
6
  import RcSesAccordion from '@/components/common/Accordion'
7
7
  import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
8
8
  import RcSesAlert from '@/components/common/Alert'
9
+ import RcSesBadge from '@/components/common/Badge'
9
10
  import RcSesBreadcrumbs from '@/components/common/Breadcrumbs'
10
11
  import RcSesButton from '@/components/common/Button'
11
12
  import RcSesButtonWithPopover from '@/components/common/Button/ButtonWithPopover'
@@ -20,10 +21,12 @@ import {
20
21
  RcSesSnackbarProvider,
21
22
  useSnackbar,
22
23
  } from '@/components/common/Snackbar/SnackbarProvider'
24
+ import RcSesSwitch from '@/components/common/Switch'
23
25
  import RcSesTab from '@/components/common/Tabs/Tab'
24
26
  import RcSesTabPanel from '@/components/common/Tabs/TabPanel'
25
27
  import RcSesTabs from '@/components/common/Tabs/Tabs'
26
28
  import RcSesTabsWrapper from '@/components/common/Tabs/TabsWrapper'
29
+ import RcSesTooltip from '@/components/common/Tooltip'
27
30
  import RcSesFormControlWrapper from '@/components/form/components/FormControlWrapper'
28
31
  import RcSesCheckbox from '@/components/form/inputs/Checkbox'
29
32
  import RcSesCheckboxFormControl from '@/components/form/inputs/CheckboxFormControl'
@@ -67,6 +70,7 @@ export { RcSesPalette, RcSesTheme }
67
70
  export { RcSesAccordion, useAccordionController }
68
71
  export {
69
72
  RcSesAlert,
73
+ RcSesBadge,
70
74
  RcSesBreadcrumbs,
71
75
  RcSesButton,
72
76
  RcSesButtonWithPopover,
@@ -80,6 +84,7 @@ export {
80
84
  RcSesSnackbar,
81
85
  RcSesSnackbarProvider,
82
86
  RcSesModal,
87
+ RcSesSwitch,
83
88
  }
84
89
  export { RcSesSegmentedControl }
85
90
  export { RcSesCheckbox, RcSesCheckboxFormControl, RcSesSimpleCheckbox }
@@ -94,6 +99,7 @@ export { RcSesSearchInput }
94
99
  export { RcSesSearchableField }
95
100
  export { RcSesSelect }
96
101
  export { RcSesTab, RcSesTabPanel, RcSesTabs, RcSesTabsWrapper }
102
+ export { RcSesTooltip }
97
103
  export { RcSesTextField }
98
104
  export { DataPagination }
99
105
  export { ListWithIcons }
@@ -6,6 +6,7 @@ import {
6
6
  RcSesSegmentedControlProps,
7
7
  } from '@/components/common/SegmentedControl'
8
8
  import { RcSesSegmentButtonProps } from '@/components/common/SegmentedControl/components/SegmentButton'
9
+ import { RcSesTooltipProps } from '@/components/common/Tooltip'
9
10
  import { RcSesFormControlLabelProps } from '@/components/form/inputs/FormControlLabel'
10
11
  import { SimpleCheckboxProps } from '@/components/form/inputs/SimpleCheckbox'
11
12
  import { RcSesCardFormContainerProps } from '@/components/layout/ServiceFormContainer/CardFormContainer'
@@ -41,6 +42,7 @@ export type {
41
42
  RcSesFormControlLabelProps,
42
43
  RcSesLoadingSpinnerProps,
43
44
  RcSesSpinnerColor,
45
+ RcSesTooltipProps,
44
46
  }
45
47
  export type { RcSesDialogProps, DialogSize }
46
48
  export type { RcSesModalProps, ModalVariant }
@@ -0,0 +1,165 @@
1
+ import { Box, Typography } from '@mui/material'
2
+ import { Meta, StoryObj } from '@storybook/react'
3
+ import { Fragment } from 'react'
4
+
5
+ import RcSesBadge, { RcSesBadgeProps } from '@/components/common/Badge'
6
+ import FieldPreview from '@/components/storybook/FieldPreview'
7
+ import FieldView from '@/components/storybook/FieldView'
8
+ import Fields from '@/components/storybook/Fields'
9
+ import PreviewTitle from '@/components/storybook/PreviewTitle'
10
+
11
+ const variants: RcSesBadgeProps['variant'][] = [
12
+ 'neutral',
13
+ 'success',
14
+ 'warning',
15
+ 'error',
16
+ 'info',
17
+ 'brand',
18
+ ]
19
+
20
+ const sizes: RcSesBadgeProps['size'][] = ['small', 'regular']
21
+
22
+ const meta: Meta<typeof RcSesBadge> = {
23
+ title: 'components/display/Badge',
24
+ component: RcSesBadge,
25
+ tags: ['autodocs'],
26
+ }
27
+
28
+ export default meta
29
+
30
+ type Story = StoryObj<typeof RcSesBadge>
31
+
32
+ // ---------------------------------------------------------------------------
33
+ // Main (interactive / configurable via Controls panel)
34
+ // ---------------------------------------------------------------------------
35
+
36
+ export const Main: Story = {
37
+ render: (args) => (
38
+ <Fields>
39
+ <FieldView>
40
+ <RcSesBadge {...args} />
41
+ </FieldView>
42
+ </Fields>
43
+ ),
44
+ args: {
45
+ label: 'Dabartinė',
46
+ variant: 'success',
47
+ size: 'regular',
48
+ showIcon: true,
49
+ showClose: false,
50
+ },
51
+ }
52
+
53
+ // ---------------------------------------------------------------------------
54
+ // Matrix — all 6 Type x 2 Size x show icon x show close combinations
55
+ // ---------------------------------------------------------------------------
56
+
57
+ const combos: { key: string; label: string; showIcon: boolean; showClose: boolean }[] = [
58
+ { key: 'icon', label: 'Icon', showIcon: true, showClose: false },
59
+ { key: 'close', label: 'Close', showIcon: false, showClose: true },
60
+ { key: 'both', label: 'Icon + Close', showIcon: true, showClose: true },
61
+ { key: 'plain', label: 'Plain', showIcon: false, showClose: false },
62
+ ]
63
+
64
+ export const AllCombinations: Story = {
65
+ render: () => (
66
+ <>
67
+ <PreviewTitle>
68
+ 6 types × 2 sizes × show icon × show close = 48 variants
69
+ </PreviewTitle>
70
+ <Box
71
+ sx={{
72
+ display: 'grid',
73
+ gridTemplateColumns: '90px 70px repeat(4, 1fr)',
74
+ rowGap: 1.5,
75
+ columnGap: 2,
76
+ alignItems: 'center',
77
+ maxWidth: 720,
78
+ }}
79
+ >
80
+ <Box />
81
+ <Box />
82
+ {combos.map((combo) => (
83
+ <Typography
84
+ key={combo.key}
85
+ align='center'
86
+ color='text.secondary'
87
+ variant='body2'
88
+ >
89
+ {combo.label}
90
+ </Typography>
91
+ ))}
92
+ {variants.map((variant) =>
93
+ sizes.map((size, sizeIndex) => (
94
+ <Fragment key={`${variant}-${size}`}>
95
+ {sizeIndex === 0 && (
96
+ <Typography sx={{ gridRow: 'span 2' }} variant='body2' fontWeight={600}>
97
+ {variant}
98
+ </Typography>
99
+ )}
100
+ <Typography color='text.secondary' variant='body2'>
101
+ {size}
102
+ </Typography>
103
+ {combos.map((combo) => (
104
+ <Box key={combo.key} display='flex' justifyContent='center'>
105
+ <RcSesBadge
106
+ label='Label'
107
+ variant={variant}
108
+ size={size}
109
+ showIcon={combo.showIcon}
110
+ showClose={combo.showClose}
111
+ onClose={combo.showClose ? () => {} : undefined}
112
+ />
113
+ </Box>
114
+ ))}
115
+ </Fragment>
116
+ )),
117
+ )}
118
+ </Box>
119
+ </>
120
+ ),
121
+ }
122
+
123
+ // ---------------------------------------------------------------------------
124
+ // Edge cases
125
+ // ---------------------------------------------------------------------------
126
+
127
+ export const LongLabel: Story = {
128
+ render: () => (
129
+ <Fields>
130
+ <FieldView>
131
+ <PreviewTitle>
132
+ truncated in a constrained container (hover/focus for full text)
133
+ </PreviewTitle>
134
+ <Box sx={{ maxWidth: 160 }}>
135
+ <RcSesBadge
136
+ label='Labai ilgas būsenos pavadinimas, kuris netelpa'
137
+ variant='info'
138
+ size='regular'
139
+ showClose
140
+ onClose={() => {}}
141
+ />
142
+ </Box>
143
+ </FieldView>
144
+ <FieldPreview>
145
+ <PreviewTitle>grows freely when space allows</PreviewTitle>
146
+ <RcSesBadge
147
+ label='Labai ilgas būsenos pavadinimas, kuris netelpa'
148
+ variant='info'
149
+ size='regular'
150
+ />
151
+ </FieldPreview>
152
+ </Fields>
153
+ ),
154
+ }
155
+
156
+ export const BaselineAlignment: Story = {
157
+ render: () => (
158
+ <FieldView>
159
+ <Typography variant='body1' component='p'>
160
+ Įrašo būsena: <RcSesBadge label='Dabartinė' variant='success' size='small' />{' '}
161
+ greta teksto eilutėje.
162
+ </Typography>
163
+ </FieldView>
164
+ ),
165
+ }
@@ -55,6 +55,14 @@ const meta = {
55
55
  title: 'components/display/SelectableCardList',
56
56
  component: SelectableCardList,
57
57
  tags: ['autodocs'],
58
+ parameters: {
59
+ docs: {
60
+ description: {
61
+ component:
62
+ 'Paginates items client-side, showing 5 per page on desktop and 3 per page on mobile (below the `md` breakpoint). The page resets to 1 whenever the page size changes, e.g. when resizing across the breakpoint.',
63
+ },
64
+ },
65
+ },
58
66
  args: {
59
67
  items: buildItems(),
60
68
  selectedId: null,
@@ -101,6 +109,14 @@ export const Main: Story = {
101
109
  render: (args) => (
102
110
  <SelectableCardListStory {...args} onSelect={args.onSelect ?? (() => {})} />
103
111
  ),
112
+ parameters: {
113
+ docs: {
114
+ description: {
115
+ story:
116
+ 'Responsive page size: desktop shows 5 cards per page, mobile (below md) shows 3 cards per page. When page size changes across breakpoints, current page is reset to 1.',
117
+ },
118
+ },
119
+ },
104
120
  }
105
121
 
106
122
  export const Loading: Story = {
@@ -0,0 +1,67 @@
1
+ import { Button, Typography } from '@mui/material'
2
+ import type { Meta } from '@storybook/react'
3
+
4
+ import RcSesTooltip from '../../../components/common/Tooltip'
5
+
6
+ const meta = {
7
+ title: 'components/display/Tooltip',
8
+ component: RcSesTooltip,
9
+ parameters: {
10
+ layout: 'centered',
11
+ },
12
+ tags: ['autodocs'],
13
+ argTypes: {
14
+ title: {
15
+ control: 'text',
16
+ description: 'Tooltip content',
17
+ },
18
+ placement: {
19
+ control: 'select',
20
+ options: ['top-start', 'top', 'top-end', 'bottom-start', 'bottom', 'bottom-end'],
21
+ description: 'Popper placement relative to the trigger',
22
+ },
23
+ slotProps: {
24
+ control: false,
25
+ description: 'Overrides for default trigger button',
26
+ },
27
+ children: {
28
+ control: false,
29
+ description: 'Custom trigger element, must forward ref!',
30
+ },
31
+ },
32
+ } satisfies Meta<typeof RcSesTooltip>
33
+
34
+ export default meta
35
+
36
+ export const Default = {
37
+ args: {
38
+ title:
39
+ 'Deklaruojant išvykimą iš Lietuvos nurodoma užsienio valstybė, į kurią išvykstama.',
40
+ },
41
+ render: (args: any) => (
42
+ <Typography>
43
+ Išvykimo valstybė
44
+ <RcSesTooltip {...args} />
45
+ </Typography>
46
+ ),
47
+ } as const
48
+
49
+ export const CustomTrigger = {
50
+ args: {
51
+ title: 'Papildoma informacija apie paslaugą.',
52
+ },
53
+ render: (args: any) => (
54
+ <RcSesTooltip {...args}>
55
+ <Button variant='text'>Mygtukas</Button>
56
+ </RcSesTooltip>
57
+ ),
58
+ parameters: {
59
+ docs: {
60
+ source: {
61
+ code: `<RcSesTooltip title="Papildoma informacija apie paslaugą.">
62
+ <Button variant="text">Mygtukas</Button>
63
+ </RcSesTooltip>`,
64
+ },
65
+ },
66
+ },
67
+ } as const