@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
@@ -77,7 +77,7 @@ function SelectDemo(args: any) {
77
77
  formState: { errors },
78
78
  } = useForm<SingleStepFormModel>({ mode: 'all', defaultValues: { selection: '' } })
79
79
 
80
- const { label, disabled, slotProps } = args
80
+ const { label, disabled, placeholder, slotProps } = args
81
81
 
82
82
  return (
83
83
  <Fields>
@@ -88,6 +88,7 @@ function SelectDemo(args: any) {
88
88
  control={control}
89
89
  label={label}
90
90
  disabled={disabled}
91
+ placeholder={placeholder}
91
92
  slotProps={slotProps}
92
93
  options={[
93
94
  { value: 'pasirinkimas-1', label: 'Pasirinkimas #1' },
@@ -104,6 +105,7 @@ function SelectDemo(args: any) {
104
105
  control={control}
105
106
  rules={{ required: true }}
106
107
  label='Active'
108
+ placeholder={placeholder}
107
109
  errors={errors?.selection}
108
110
  options={[
109
111
  { value: 'pasirinkimas-1', label: 'Pasirinkimas #1' },
@@ -117,6 +119,7 @@ function SelectDemo(args: any) {
117
119
  rules={{ required: true }}
118
120
  label='Disabled'
119
121
  disabled
122
+ placeholder={placeholder}
120
123
  errors={errors?.selection}
121
124
  options={[
122
125
  { value: 'pasirinkimas-1', label: 'Pasirinkimas #1' },
@@ -129,6 +132,7 @@ function SelectDemo(args: any) {
129
132
  control={control}
130
133
  rules={{ required: true }}
131
134
  label='Error'
135
+ placeholder={placeholder}
132
136
  errors={{ message: 'Error Message', type: 'required' }}
133
137
  options={[
134
138
  { value: 'pasirinkimas-1', label: 'Pasirinkimas #1' },
@@ -146,6 +150,7 @@ function SelectDemo(args: any) {
146
150
  rules={{ required: true }}
147
151
  label='Active'
148
152
  slotProps={{ wrapper: { labelOnTop: true } }}
153
+ placeholder={placeholder}
149
154
  errors={errors?.selection}
150
155
  options={[
151
156
  { value: 'pasirinkimas-1', label: 'Pasirinkimas #1' },
@@ -160,6 +165,7 @@ function SelectDemo(args: any) {
160
165
  label='Disabled'
161
166
  disabled
162
167
  slotProps={{ wrapper: { labelOnTop: true } }}
168
+ placeholder={placeholder}
163
169
  errors={errors?.selection}
164
170
  options={[
165
171
  { value: 'pasirinkimas-1', label: 'Pasirinkimas #1' },
@@ -173,6 +179,7 @@ function SelectDemo(args: any) {
173
179
  rules={{ required: true }}
174
180
  label='Error'
175
181
  slotProps={{ wrapper: { labelOnTop: true } }}
182
+ placeholder={placeholder}
176
183
  errors={{ message: 'Error', type: 'required' }}
177
184
  options={[
178
185
  { value: 'pasirinkimas-1', label: 'Pasirinkimas #1' },
@@ -185,7 +192,7 @@ function SelectDemo(args: any) {
185
192
  }
186
193
 
187
194
  const codeBlock = (args: any) => {
188
- const { label, disabled, slotProps } = args
195
+ const { label, disabled, placeholder, slotProps } = args
189
196
  return `
190
197
  import RcSesSelect from '@/components/form/inputs/Select'
191
198
 
@@ -201,6 +208,7 @@ const codeBlock = (args: any) => {
201
208
  rules={{ required: true }}
202
209
  label="${label}"
203
210
  disabled={${disabled}}
211
+ placeholder="${placeholder ?? ''}"
204
212
  errors={errors?.selection}
205
213
  slotProps=${slotProps.wrapper.labelOnTop ? '{{ wrapper: { labelOnTop: true } }}' : '{{ wrapper: { labelOnTop: false} }}'}
206
214
  options={[
@@ -236,6 +244,7 @@ type VariantsFormModel = {
236
244
  singleSearchSelect: string | null
237
245
  descriptionSelect: string | null
238
246
  multiSelect: string[]
247
+ limitedMultiSelect: string[]
239
248
  multiSearchSelect: string[]
240
249
  phoneInput: string
241
250
  }
@@ -246,6 +255,16 @@ const variantOptions = [
246
255
  { value: 'option-3', label: '3rd option' },
247
256
  { value: 'option-4', label: '4th option' },
248
257
  { value: 'option-5', label: '5th option' },
258
+ {
259
+ value: 'long-option-1',
260
+ label:
261
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
262
+ },
263
+ {
264
+ value: 'long-option-2',
265
+ label:
266
+ 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
267
+ },
249
268
  ]
250
269
 
251
270
  const groupedVariantOptions: Array<
@@ -320,6 +339,7 @@ export const AllVariants: Story = {
320
339
  singleSearchSelect: null,
321
340
  descriptionSelect: 'option-3',
322
341
  multiSelect: ['option-1', 'option-3'],
342
+ limitedMultiSelect: ['option-1', 'option-2', 'option-3'],
323
343
  multiSearchSelect: ['option-1', 'option-3', 'option-4', 'option-5'],
324
344
  phoneInput: '',
325
345
  },
@@ -416,6 +436,22 @@ export const AllVariants: Story = {
416
436
  />
417
437
  </VariantCard>
418
438
 
439
+ <VariantCard
440
+ title='Multi select + limit tags'
441
+ description='Daugybinis pasirinkimas su limitTags={1}, kai pertekliniai pasirinkimai sutraukiami i +N.'
442
+ >
443
+ <RcSesSelect
444
+ id='limited-multi-select'
445
+ name='limitedMultiSelect'
446
+ control={control}
447
+ label='Pasirinkti'
448
+ slotProps={{ wrapper: { labelOnTop: true } }}
449
+ multiple
450
+ limitTags={1}
451
+ options={variantOptions}
452
+ />
453
+ </VariantCard>
454
+
419
455
  <VariantCard
420
456
  title='Multi select + search'
421
457
  description='Daugybinis pasirinkimas su paieska ir select all.'
@@ -0,0 +1,70 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import { useState } from 'react'
3
+
4
+ import RcSesSwitch from '@/components/common/Switch'
5
+
6
+ const meta = {
7
+ title: 'components/inputs/Switch',
8
+ component: RcSesSwitch,
9
+ parameters: {
10
+ layout: 'centered',
11
+ },
12
+ tags: ['autodocs'],
13
+ } satisfies Meta<typeof RcSesSwitch>
14
+
15
+ export default meta
16
+ type Story = StoryObj<typeof meta>
17
+
18
+ type ControlledDemoProps = {
19
+ initialChecked?: boolean
20
+ disabled?: boolean
21
+ label?: string
22
+ }
23
+
24
+ function ControlledDemo({
25
+ initialChecked = false,
26
+ disabled = false,
27
+ label = 'Notifications',
28
+ }: ControlledDemoProps) {
29
+ const [checked, setChecked] = useState(initialChecked)
30
+ return (
31
+ <RcSesSwitch
32
+ label={label}
33
+ checked={checked}
34
+ disabled={disabled}
35
+ onChange={(_event, value) => setChecked(value)}
36
+ />
37
+ )
38
+ }
39
+
40
+ export const On: Story = {
41
+ args: { label: 'Notifications', checked: true, onChange: () => {} },
42
+ render: () => <ControlledDemo initialChecked />,
43
+ }
44
+
45
+ export const Off: Story = {
46
+ args: { label: 'Notifications', checked: false, onChange: () => {} },
47
+ render: () => <ControlledDemo />,
48
+ }
49
+
50
+ export const OnDisabled: Story = {
51
+ name: 'On, Disabled',
52
+ args: { label: 'Notifications', checked: true, onChange: () => {} },
53
+ render: () => <ControlledDemo initialChecked disabled />,
54
+ }
55
+
56
+ export const OffDisabled: Story = {
57
+ name: 'Off, Disabled',
58
+ args: { label: 'Notifications', checked: false, onChange: () => {} },
59
+ render: () => <ControlledDemo disabled />,
60
+ }
61
+
62
+ export const LongLabel: Story = {
63
+ name: 'Long label',
64
+ args: { label: 'Notifications', checked: false, onChange: () => {} },
65
+ render: () => (
66
+ <div style={{ maxWidth: '16rem' }}>
67
+ <ControlledDemo label='Send me an email whenever there is a new comment on any of my open service requests' />
68
+ </div>
69
+ ),
70
+ }
@@ -82,15 +82,17 @@ const MuiAutocomplete: Components['MuiAutocomplete'] = {
82
82
 
83
83
  '.rc-ses-select-option-label': {
84
84
  display: 'block',
85
+ overflowWrap: 'anywhere',
85
86
  },
86
87
  '.rc-ses-select-option-description': {
87
88
  color: palette.grey['600'],
88
89
  display: 'block',
89
90
  fontSize: '.75rem',
90
91
  fontStyle: 'italic',
92
+ fontWeight: 500,
91
93
  lineHeight: '1rem',
92
94
  marginTop: '.25rem',
93
- fontWeight: 500,
95
+ overflowWrap: 'anywhere',
94
96
  },
95
97
  },
96
98
  },
@@ -76,6 +76,10 @@ const MuiInputBase: Components['MuiInputBase'] = {
76
76
  },
77
77
  multiline: {
78
78
  padding: '0 !important',
79
+
80
+ '.MuiInputBase-inputMultiline': {
81
+ overflowWrap: 'anywhere',
82
+ },
79
83
  },
80
84
  adornedStart: {
81
85
  paddingLeft: '0 !important',
@@ -0,0 +1,77 @@
1
+ import { Components } from '@mui/material'
2
+
3
+ import palette, { common } from '../palette'
4
+
5
+ const MuiSwitch: Components['MuiSwitch'] = {
6
+ defaultProps: {
7
+ disableRipple: true,
8
+ },
9
+ styleOverrides: {
10
+ root: {
11
+ width: '2.25rem',
12
+ height: '1.25rem',
13
+ padding: 0,
14
+ },
15
+ switchBase: {
16
+ padding: 0,
17
+ margin: '0.125rem',
18
+ transition: 'transform 200ms ease-in-out',
19
+
20
+ '@media (prefers-reduced-motion: reduce)': {
21
+ transition: 'none',
22
+ },
23
+
24
+ '&:hover': {
25
+ backgroundColor: 'transparent',
26
+ },
27
+ '&:hover + .MuiSwitch-track': {
28
+ backgroundColor: palette.grey['500'], // unchecked hover
29
+ },
30
+ '&.Mui-focusVisible + .MuiSwitch-track': {
31
+ boxShadow: `0 0 0 2px ${common.white}, 0 0 0 4px ${palette.grey['950']}`, // DS focus ring, >=3:1 against surrounding background
32
+ },
33
+ '&.Mui-disabled + .MuiSwitch-track': {
34
+ backgroundColor: palette.grey['200'], // unchecked disabled
35
+ opacity: 1,
36
+ },
37
+ '&.Mui-disabled .MuiSwitch-thumb': {
38
+ color: common.white,
39
+ },
40
+
41
+ '&.Mui-checked': {
42
+ transform: 'translateX(1rem)',
43
+ color: common.white,
44
+
45
+ '& + .MuiSwitch-track': {
46
+ backgroundColor: palette.primary['500'], // checked default
47
+ opacity: 1,
48
+ border: 0,
49
+ },
50
+ '&:hover + .MuiSwitch-track': {
51
+ backgroundColor: palette.primary['600'], // checked hover
52
+ },
53
+ '&.Mui-disabled + .MuiSwitch-track': {
54
+ backgroundColor: palette.grey['500'], // checked disabled
55
+ opacity: 1,
56
+ },
57
+ },
58
+ },
59
+ thumb: {
60
+ boxSizing: 'border-box',
61
+ width: '1rem',
62
+ height: '1rem',
63
+ borderRadius: '9999px',
64
+ backgroundColor: common.white,
65
+ boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.18)',
66
+ },
67
+ track: {
68
+ borderRadius: '9999px',
69
+ backgroundColor: palette.grey['400'], // unchecked default
70
+ opacity: 1,
71
+ // kept active under prefers-reduced-motion: only the sliding transform is suppressed
72
+ transition: 'background-color 200ms ease-in-out',
73
+ },
74
+ },
75
+ }
76
+
77
+ export default MuiSwitch
@@ -0,0 +1,40 @@
1
+ import { Components } from '@mui/material'
2
+
3
+ import palette, { common } from '../palette'
4
+
5
+ const MuiTooltip: Components['MuiTooltip'] = {
6
+ styleOverrides: {
7
+ tooltip: {
8
+ backgroundColor: common.white,
9
+ color: palette.grey['900'],
10
+ maxWidth: 480,
11
+ padding: '12px 16px',
12
+ fontSize: '.875rem',
13
+ fontWeight: 400,
14
+ lineHeight: 1.5,
15
+ borderRadius: '8px',
16
+ boxShadow: 'none',
17
+ filter: 'drop-shadow(0 6px 24px rgba(0, 0, 0, 0.16))',
18
+
19
+ '@keyframes rcses-tooltip': {
20
+ from: { transform: 'translate3d(0, var(--rcses-tooltip-shift, 6px), 0)' },
21
+ to: { transform: 'none' },
22
+ },
23
+
24
+ '@media (prefers-reduced-motion: no-preference)': {
25
+ animation: 'rcses-tooltip 160ms ease-out',
26
+ },
27
+
28
+ '[data-popper-placement*="bottom"] &': {
29
+ '--rcses-tooltip-shift': '-6px',
30
+ },
31
+ },
32
+
33
+ arrow: {
34
+ color: common.white,
35
+ fontSize: '1rem',
36
+ },
37
+ },
38
+ }
39
+
40
+ export default MuiTooltip
@@ -33,11 +33,13 @@ import MuiRadio from '@/theme/light/MuiRadio'
33
33
  import MuiSelect from '@/theme/light/MuiSelect'
34
34
  import MuiStepper from '@/theme/light/MuiStepper'
35
35
  import MuiSvgIcon from '@/theme/light/MuiSvgIcon'
36
+ import MuiSwitch from '@/theme/light/MuiSwitch'
36
37
  import MuiTab from '@/theme/light/MuiTab'
37
38
  import MuiTable from '@/theme/light/MuiTable'
38
39
  import MuiTableCell from '@/theme/light/MuiTableCell'
39
40
  import MuiTabs from '@/theme/light/MuiTabs'
40
41
  import MuiTextField from '@/theme/light/MuiTextField'
42
+ import MuiTooltip from '@/theme/light/MuiTooltip'
41
43
  import MuiTypography from '@/theme/light/MuiTypography'
42
44
  import themePalette from '@/theme/light/themePalette'
43
45
 
@@ -124,11 +126,13 @@ const theme = createTheme(themePalette, ltLT, enUS, {
124
126
  MuiSelect,
125
127
  MuiStepper,
126
128
  MuiSvgIcon,
129
+ MuiSwitch,
127
130
  MuiTab,
128
131
  MuiTabs,
129
132
  MuiTable,
130
133
  MuiTableCell,
131
134
  MuiTextField,
135
+ MuiTooltip,
132
136
  MuiTypography,
133
137
  },
134
138
  })