@registrucentras/rc-ses-react-components 2.0.0-rc.0 → 2.0.0-rc.2
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/README.md +5 -1
- package/dist/assets/icons/CaretUpBoldIcon.d.ts +3 -0
- package/dist/assets/icons/CaretUpIcon.d.ts +3 -0
- package/dist/assets/icons/ListIcon.d.ts +3 -0
- package/dist/assets/icons/MinusIcon.d.ts +3 -0
- package/dist/assets/icons/NotePencilIcon.d.ts +3 -0
- package/dist/assets/icons/PlusIcon.d.ts +3 -0
- package/dist/assets/icons/TrashIcon.d.ts +3 -0
- package/dist/assets/icons/UserIcon.d.ts +3 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/AdvancedListItem.types.d.ts +106 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.d.ts +12 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.d.ts +7 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion.d.ts +2 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/index.d.ts +4 -0
- package/dist/components/common/AdvancedList/index.d.ts +11 -0
- package/dist/components/common/Button/index.d.ts +13 -3
- package/dist/components/common/SelectableCardList/components/SelectableCardListItem.d.ts +4 -1
- package/dist/components/common/SelectableCardList/index.d.ts +4 -1
- package/dist/components/common/Tooltip/index.d.ts +20 -0
- package/dist/components/form/inputs/Select/index.d.ts +1 -0
- package/dist/library/icons.d.ts +9 -1
- package/dist/library/index.d.ts +5 -0
- package/dist/library/types.d.ts +2 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +4137 -3249
- package/dist/stories/components/actions/Button.stories.d.ts +4 -3
- package/dist/stories/components/display/AdvancedList.stories.d.ts +33 -0
- package/dist/stories/components/display/AdvancedListItem.stories.d.ts +33 -0
- package/dist/stories/components/display/SelectableCardList.stories.d.ts +8 -1
- package/dist/stories/components/display/Tooltip.stories.d.ts +48 -0
- package/dist/stories/components/inputs/DatePicker.stories.d.ts +23 -0
- package/dist/stories/components/loaders/LoadingSpinner.stories.d.ts +3 -3
- package/dist/stories/components/overlays/Dialog.stories.d.ts +6 -0
- package/dist/stories/components/overlays/Popover.stories.d.ts +12 -0
- package/dist/stories/theme/ThemedMuiComponents.stories.d.ts +25 -0
- package/dist/theme/light/MuiTooltip.d.ts +3 -0
- package/dist/theme/motion.d.ts +16 -0
- package/package.json +2 -1
- package/src/assets/icons/CaretUpBoldIcon.tsx +17 -0
- package/src/assets/icons/CaretUpIcon.tsx +9 -0
- package/src/assets/icons/ListIcon.tsx +17 -0
- package/src/assets/icons/MinusIcon.tsx +9 -0
- package/src/assets/icons/NotePencilIcon.tsx +9 -0
- package/src/assets/icons/PlusIcon.tsx +9 -0
- package/src/assets/icons/TrashIcon.tsx +23 -0
- package/src/assets/icons/UserIcon.tsx +17 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/AdvancedListItem.types.ts +100 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.tsx +228 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.tsx +270 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion.test.ts +80 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/hooks/usePrefersReducedMotion.ts +28 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/index.test.tsx +631 -0
- package/src/components/common/AdvancedList/components/AdvancedListItem/index.tsx +340 -0
- package/src/components/common/AdvancedList/index.test.tsx +97 -0
- package/src/components/common/AdvancedList/index.tsx +52 -0
- package/src/components/common/Button/index.tsx +15 -1
- package/src/components/common/Card/index.tsx +2 -2
- package/src/components/common/ListWithIcons/components/ListWithIconsItem.tsx +7 -5
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.test.tsx +50 -0
- package/src/components/common/SelectableCardList/components/SelectableCardListItem.tsx +34 -0
- package/src/components/common/SelectableCardList/index.test.tsx +56 -2
- package/src/components/common/SelectableCardList/index.tsx +29 -10
- package/src/components/common/Tooltip/index.test.tsx +85 -0
- package/src/components/common/Tooltip/index.tsx +168 -0
- package/src/components/form/inputs/FileDropzone.tsx +1 -0
- package/src/components/form/inputs/FileUpload.tsx +1 -0
- package/src/components/form/inputs/NumberStepper.tsx +1 -0
- package/src/components/form/inputs/PhoneInputFormControl/index.tsx +1 -1
- package/src/components/form/inputs/RadioButtonGroup.test.tsx +71 -0
- package/src/components/form/inputs/RadioButtonGroup.tsx +1 -0
- package/src/components/form/inputs/Select/index.test.tsx +159 -0
- package/src/components/form/inputs/Select/index.tsx +107 -52
- package/src/components/layout/Footer/index.test.tsx +13 -0
- package/src/components/layout/Footer/index.tsx +5 -2
- package/src/i18n/namespaces/common/en.json +14 -0
- package/src/i18n/namespaces/common/lt.json +14 -0
- package/src/library/icons.ts +16 -0
- package/src/library/index.ts +5 -0
- package/src/library/types.ts +2 -0
- package/src/setupTests.ts +7 -1
- package/src/stories/components/display/AdvancedList.stories.tsx +660 -0
- package/src/stories/components/display/AdvancedListItem.stories.tsx +653 -0
- package/src/stories/components/display/SelectableCardList.stories.tsx +19 -0
- package/src/stories/components/display/Tooltip.stories.tsx +67 -0
- package/src/stories/components/inputs/DatePicker.stories.tsx +36 -1
- package/src/stories/components/inputs/Select.stories.tsx +38 -2
- package/src/stories/components/overlays/Dialog.stories.tsx +34 -0
- package/src/stories/components/overlays/Popover.stories.tsx +65 -0
- package/src/stories/theme/ThemedMuiComponents.stories.tsx +177 -0
- package/src/theme/light/MuiAutocomplete.ts +3 -1
- package/src/theme/light/MuiInputBase.ts +4 -0
- package/src/theme/light/MuiTooltip.ts +40 -0
- package/src/theme/light/index.tsx +2 -0
- package/src/theme/motion.tsx +10 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { ThemeProvider } from '@mui/material/styles'
|
|
2
|
+
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
|
|
3
|
+
import { useState } from 'react'
|
|
4
|
+
import { useForm } from 'react-hook-form'
|
|
5
|
+
|
|
6
|
+
import theme from '@/theme/light'
|
|
7
|
+
|
|
8
|
+
import RcSesSelect from '.'
|
|
9
|
+
|
|
10
|
+
type TestWrapperProps = {
|
|
11
|
+
defaultValue?: string | null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const options = [
|
|
15
|
+
{
|
|
16
|
+
value: 'long-option',
|
|
17
|
+
label: 'Juridiniu asmenu registro isplestinis pavadinimas su ilgu tekstu',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: 'short-option',
|
|
21
|
+
label: 'Trumpas pasirinkimas',
|
|
22
|
+
},
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
type UnregisterTestWrapperProps = {
|
|
26
|
+
shouldUnregister?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const UnregisterTestWrapper = ({ shouldUnregister }: UnregisterTestWrapperProps) => {
|
|
30
|
+
const { control, getValues } = useForm({
|
|
31
|
+
defaultValues: { selection: 'short-option' as string | null },
|
|
32
|
+
})
|
|
33
|
+
const [mounted, setMounted] = useState(true)
|
|
34
|
+
const [formValues, setFormValues] = useState('')
|
|
35
|
+
|
|
36
|
+
const slotProps =
|
|
37
|
+
shouldUnregister === undefined ? undefined : { controller: { shouldUnregister } }
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<ThemeProvider theme={theme}>
|
|
41
|
+
{mounted && (
|
|
42
|
+
<RcSesSelect
|
|
43
|
+
id='selection'
|
|
44
|
+
name='selection'
|
|
45
|
+
control={control}
|
|
46
|
+
label='Pasirinkti'
|
|
47
|
+
options={options}
|
|
48
|
+
slotProps={slotProps}
|
|
49
|
+
/>
|
|
50
|
+
)}
|
|
51
|
+
|
|
52
|
+
<button type='button' onClick={() => setMounted(false)}>
|
|
53
|
+
Hide
|
|
54
|
+
</button>
|
|
55
|
+
<button type='button' onClick={() => setFormValues(JSON.stringify(getValues()))}>
|
|
56
|
+
Read
|
|
57
|
+
</button>
|
|
58
|
+
<div data-testid='form-values'>{formValues}</div>
|
|
59
|
+
</ThemeProvider>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const TestWrapper = ({ defaultValue = null }: TestWrapperProps) => {
|
|
64
|
+
const { control } = useForm({
|
|
65
|
+
defaultValues: {
|
|
66
|
+
selection: defaultValue,
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<ThemeProvider theme={theme}>
|
|
72
|
+
<RcSesSelect
|
|
73
|
+
id='selection'
|
|
74
|
+
name='selection'
|
|
75
|
+
control={control}
|
|
76
|
+
label='Pasirinkti'
|
|
77
|
+
options={options}
|
|
78
|
+
/>
|
|
79
|
+
</ThemeProvider>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
describe('RcSesSelect', () => {
|
|
84
|
+
test('single select rodo pilna pasirinktos reiksmes label', () => {
|
|
85
|
+
render(<TestWrapper defaultValue='long-option' />)
|
|
86
|
+
|
|
87
|
+
expect(
|
|
88
|
+
screen.getByText(
|
|
89
|
+
'Juridiniu asmenu registro isplestinis pavadinimas su ilgu tekstu',
|
|
90
|
+
),
|
|
91
|
+
).toBeInTheDocument()
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('single select lieka pasirenkamas klaviatura kai niekas nepasirinkta', async () => {
|
|
95
|
+
render(<TestWrapper />)
|
|
96
|
+
|
|
97
|
+
const input = screen.getByRole('combobox')
|
|
98
|
+
expect(input).not.toHaveAttribute('readonly')
|
|
99
|
+
|
|
100
|
+
fireEvent.mouseDown(input)
|
|
101
|
+
fireEvent.keyDown(input, { key: 'ArrowDown' })
|
|
102
|
+
fireEvent.keyDown(input, { key: 'Enter' })
|
|
103
|
+
|
|
104
|
+
await waitFor(() => {
|
|
105
|
+
expect(
|
|
106
|
+
screen.getByText(
|
|
107
|
+
'Juridiniu asmenu registro isplestinis pavadinimas su ilgu tekstu',
|
|
108
|
+
),
|
|
109
|
+
).toBeInTheDocument()
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
test('single select siulo visas parinktis kai reiksme jau pasirinkta', async () => {
|
|
114
|
+
render(<TestWrapper defaultValue='long-option' />)
|
|
115
|
+
|
|
116
|
+
fireEvent.mouseDown(screen.getByRole('combobox'))
|
|
117
|
+
|
|
118
|
+
await waitFor(() => {
|
|
119
|
+
expect(screen.getAllByRole('option')).toHaveLength(options.length)
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
test('single select leidzia pakeisti jau pasirinkta reiksme', async () => {
|
|
124
|
+
render(<TestWrapper defaultValue='long-option' />)
|
|
125
|
+
|
|
126
|
+
fireEvent.mouseDown(screen.getByRole('combobox'))
|
|
127
|
+
fireEvent.click(await screen.findByRole('option', { name: 'Trumpas pasirinkimas' }))
|
|
128
|
+
|
|
129
|
+
await waitFor(() => {
|
|
130
|
+
expect(
|
|
131
|
+
screen.getByText('Trumpas pasirinkimas', { selector: 'div' }),
|
|
132
|
+
).toBeInTheDocument()
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
test('single select neleidzia rasti kai reiksme jau pasirinkta', () => {
|
|
137
|
+
render(<TestWrapper defaultValue='long-option' />)
|
|
138
|
+
|
|
139
|
+
expect(screen.getByRole('combobox')).toHaveAttribute('readonly')
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
test('drops the value from the form by default when the field unmounts', () => {
|
|
143
|
+
render(<UnregisterTestWrapper />)
|
|
144
|
+
|
|
145
|
+
fireEvent.click(screen.getByRole('button', { name: 'Hide' }))
|
|
146
|
+
fireEvent.click(screen.getByRole('button', { name: 'Read' }))
|
|
147
|
+
|
|
148
|
+
expect(screen.getByTestId('form-values')).not.toHaveTextContent('short-option')
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
test('keeps the value when slotProps.controller turns shouldUnregister off', () => {
|
|
152
|
+
render(<UnregisterTestWrapper shouldUnregister={false} />)
|
|
153
|
+
|
|
154
|
+
fireEvent.click(screen.getByRole('button', { name: 'Hide' }))
|
|
155
|
+
fireEvent.click(screen.getByRole('button', { name: 'Read' }))
|
|
156
|
+
|
|
157
|
+
expect(screen.getByTestId('form-values')).toHaveTextContent('short-option')
|
|
158
|
+
})
|
|
159
|
+
})
|
|
@@ -42,6 +42,7 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
|
|
|
42
42
|
onInputChange?: AutocompleteProps<Option, boolean, boolean, false>['onInputChange']
|
|
43
43
|
|
|
44
44
|
slotProps?: {
|
|
45
|
+
controller?: Partial<Omit<TControllerProps, ImmediateControllerProps>>
|
|
45
46
|
field?: Partial<
|
|
46
47
|
Omit<
|
|
47
48
|
AutocompleteProps<Option, boolean, boolean, false>,
|
|
@@ -53,19 +54,22 @@ type Props = Pick<TControllerProps, ImmediateControllerProps> &
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
function RcSesSelect(props: Props) {
|
|
56
|
-
const [inputValue, setInputValue] = React.useState('')
|
|
57
57
|
const [dropdownSearchValue, setDropdownSearchValue] = React.useState('')
|
|
58
58
|
const [open, setOpen] = React.useState(false)
|
|
59
59
|
const dropdownSearchOptionValue = '__dropdown-search-option__'
|
|
60
|
+
// rem widths reserved at the end of the input for the clear and dropdown adornments
|
|
61
|
+
const reservedSingleEndAdornmentWidth = 2
|
|
62
|
+
const reservedMultipleTagsEndAdornmentWidth = 2.2
|
|
63
|
+
const reservedMultipleWithCounterEndAdornmentWidth = 3
|
|
60
64
|
const wrapperRef = React.useRef<HTMLDivElement>(null)
|
|
61
65
|
|
|
62
66
|
const {
|
|
63
67
|
multiple = false,
|
|
64
68
|
clearable,
|
|
65
|
-
limitTags = 1,
|
|
66
69
|
control,
|
|
67
70
|
errors,
|
|
68
71
|
label,
|
|
72
|
+
limitTags,
|
|
69
73
|
loading,
|
|
70
74
|
onInputChange,
|
|
71
75
|
options,
|
|
@@ -82,6 +86,7 @@ function RcSesSelect(props: Props) {
|
|
|
82
86
|
const { disabled, name } = fieldProps
|
|
83
87
|
|
|
84
88
|
const id = useMemo(() => fieldProps.id ?? uuidv4(), [fieldProps.id])
|
|
89
|
+
const selectedValueId = useMemo(() => `rc-ses-select-single-value-${id}`, [id])
|
|
85
90
|
|
|
86
91
|
const {
|
|
87
92
|
field: { onChange, value },
|
|
@@ -90,6 +95,7 @@ function RcSesSelect(props: Props) {
|
|
|
90
95
|
name,
|
|
91
96
|
rules,
|
|
92
97
|
shouldUnregister: true,
|
|
98
|
+
...slotProps?.controller,
|
|
93
99
|
})
|
|
94
100
|
|
|
95
101
|
const hasError = !!errors
|
|
@@ -104,6 +110,20 @@ function RcSesSelect(props: Props) {
|
|
|
104
110
|
return options.find((o) => o.value === value) ?? null
|
|
105
111
|
}, [value, options, multiple])
|
|
106
112
|
|
|
113
|
+
const selectedSingleLabel =
|
|
114
|
+
!multiple && resolvedValue && !Array.isArray(resolvedValue) ? resolvedValue.label : ''
|
|
115
|
+
|
|
116
|
+
const selectedTagCount =
|
|
117
|
+
multiple && Array.isArray(resolvedValue) ? resolvedValue.length : 0
|
|
118
|
+
const hasLimitTagCounter =
|
|
119
|
+
multiple && (limitTags ?? -1) > -1 && selectedTagCount > (limitTags ?? -1)
|
|
120
|
+
const reservedMultipleEndAdornmentWidth = hasLimitTagCounter
|
|
121
|
+
? reservedMultipleWithCounterEndAdornmentWidth
|
|
122
|
+
: reservedMultipleTagsEndAdornmentWidth
|
|
123
|
+
|
|
124
|
+
const [inputValue, setInputValue] = React.useState('')
|
|
125
|
+
const resolvedInputValue = dropdownSearch ? '' : inputValue
|
|
126
|
+
|
|
107
127
|
const searchRowOption = useMemo<Option>(
|
|
108
128
|
() => ({ label: '', value: dropdownSearchOptionValue }),
|
|
109
129
|
[dropdownSearchOptionValue],
|
|
@@ -131,7 +151,10 @@ function RcSesSelect(props: Props) {
|
|
|
131
151
|
}
|
|
132
152
|
}
|
|
133
153
|
|
|
134
|
-
const filteredOptions = useFilteredOptions(
|
|
154
|
+
const filteredOptions = useFilteredOptions(
|
|
155
|
+
options,
|
|
156
|
+
dropdownSearch ? dropdownSearchValue : inputValue,
|
|
157
|
+
)
|
|
135
158
|
|
|
136
159
|
const selectedValues = Array.isArray(value) ? value : []
|
|
137
160
|
const { allSelected: allFilteredSelected, toggle: handleSelectAll } = useSelectAll(
|
|
@@ -141,15 +164,22 @@ function RcSesSelect(props: Props) {
|
|
|
141
164
|
)
|
|
142
165
|
|
|
143
166
|
const filterOptions = (opts: Option[]) => {
|
|
144
|
-
if (
|
|
167
|
+
if (dropdownSearch && !hasCustomGroupBy) {
|
|
168
|
+
const [searchOption, ...realOptions] = opts
|
|
169
|
+
if (!dropdownSearchValue.trim()) return opts
|
|
145
170
|
|
|
146
|
-
|
|
147
|
-
|
|
171
|
+
const filteredValues = new Set(filteredOptions.map((o) => o.value))
|
|
172
|
+
const filtered = realOptions.filter((opt) => filteredValues.has(opt.value))
|
|
148
173
|
|
|
149
|
-
|
|
150
|
-
|
|
174
|
+
return [searchOption, ...filtered]
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (dropdownSearch && hasCustomGroupBy) return opts
|
|
151
178
|
|
|
152
|
-
return
|
|
179
|
+
if (!inputValue.trim() || inputValue === selectedSingleLabel) return opts
|
|
180
|
+
|
|
181
|
+
const filteredValues = new Set(filteredOptions.map((o) => o.value))
|
|
182
|
+
return opts.filter((opt) => filteredValues.has(opt.value))
|
|
153
183
|
}
|
|
154
184
|
|
|
155
185
|
const closeDropdown = () => {
|
|
@@ -157,6 +187,13 @@ function RcSesSelect(props: Props) {
|
|
|
157
187
|
setDropdownSearchValue('')
|
|
158
188
|
}
|
|
159
189
|
|
|
190
|
+
// clear input when dropdown closes
|
|
191
|
+
const closeDropdownWithClear = () => {
|
|
192
|
+
setOpen(false)
|
|
193
|
+
setDropdownSearchValue('')
|
|
194
|
+
setInputValue('')
|
|
195
|
+
}
|
|
196
|
+
|
|
160
197
|
const shouldKeepDropdownOpen = () => {
|
|
161
198
|
const activeEl = document.activeElement
|
|
162
199
|
if (!(activeEl instanceof Element)) return false
|
|
@@ -186,7 +223,7 @@ function RcSesSelect(props: Props) {
|
|
|
186
223
|
open={open}
|
|
187
224
|
onOpen={() => setOpen(true)}
|
|
188
225
|
multiple={multiple}
|
|
189
|
-
limitTags={multiple ? limitTags : undefined}
|
|
226
|
+
limitTags={multiple ? (limitTags ?? -1) : undefined}
|
|
190
227
|
disableCloseOnSelect={multiple}
|
|
191
228
|
disabled={disabled}
|
|
192
229
|
disableClearable={clearable === false}
|
|
@@ -198,12 +235,11 @@ function RcSesSelect(props: Props) {
|
|
|
198
235
|
handleHomeEndKeys={false}
|
|
199
236
|
loading={loading}
|
|
200
237
|
value={resolvedValue}
|
|
201
|
-
inputValue={
|
|
238
|
+
inputValue={resolvedInputValue}
|
|
202
239
|
onChange={handleChange}
|
|
203
240
|
onInputChange={(event, val, reason) => {
|
|
204
241
|
if (dropdownSearch) return
|
|
205
|
-
|
|
206
|
-
setInputValue(val ?? '')
|
|
242
|
+
setInputValue(val)
|
|
207
243
|
onInputChange?.(event, val, reason)
|
|
208
244
|
}}
|
|
209
245
|
onClose={(_event, reason) => {
|
|
@@ -211,7 +247,7 @@ function RcSesSelect(props: Props) {
|
|
|
211
247
|
deferCloseCheck()
|
|
212
248
|
return
|
|
213
249
|
}
|
|
214
|
-
|
|
250
|
+
closeDropdownWithClear()
|
|
215
251
|
}}
|
|
216
252
|
isOptionEqualToValue={(option, val) => option.value === val.value}
|
|
217
253
|
getOptionLabel={(option) => option.label}
|
|
@@ -243,9 +279,9 @@ function RcSesSelect(props: Props) {
|
|
|
243
279
|
{...params}
|
|
244
280
|
disabled={disabled}
|
|
245
281
|
error={hasError}
|
|
246
|
-
placeholder={placeholder}
|
|
282
|
+
placeholder={!multiple && selectedSingleLabel ? undefined : placeholder}
|
|
247
283
|
sx={{
|
|
248
|
-
...(dropdownSearch
|
|
284
|
+
...(dropdownSearch || (!multiple && selectedSingleLabel)
|
|
249
285
|
? {
|
|
250
286
|
'& .MuiInputBase-input': {
|
|
251
287
|
caretColor: 'transparent',
|
|
@@ -256,36 +292,47 @@ function RcSesSelect(props: Props) {
|
|
|
256
292
|
? {
|
|
257
293
|
'& .MuiAutocomplete-inputRoot': {
|
|
258
294
|
alignItems: 'center',
|
|
259
|
-
|
|
260
|
-
pt: '0 !important',
|
|
261
|
-
},
|
|
262
|
-
'& .MuiOutlinedInput-root': {
|
|
263
|
-
alignItems: 'center',
|
|
264
|
-
flexWrap: 'nowrap',
|
|
265
|
-
height: '2.75rem',
|
|
266
|
-
minHeight: '2.75rem',
|
|
267
|
-
overflow: 'hidden',
|
|
268
|
-
pl: '.375rem',
|
|
269
|
-
py: 0,
|
|
295
|
+
pr: `calc(${reservedMultipleEndAdornmentWidth}rem) !important`,
|
|
270
296
|
},
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
297
|
+
}
|
|
298
|
+
: {
|
|
299
|
+
'& .rc-ses-select-single-value': {
|
|
300
|
+
boxSizing: 'border-box',
|
|
301
|
+
display: 'block',
|
|
302
|
+
overflowWrap: 'anywhere',
|
|
303
|
+
paddingLeft: '.75rem',
|
|
304
|
+
pointerEvents: 'none',
|
|
305
|
+
width: '100%',
|
|
275
306
|
},
|
|
276
307
|
'& .MuiAutocomplete-input': {
|
|
277
|
-
|
|
308
|
+
marginRight: `calc(${reservedSingleEndAdornmentWidth}rem) !important`,
|
|
278
309
|
},
|
|
279
|
-
}
|
|
280
|
-
: {}),
|
|
310
|
+
}),
|
|
281
311
|
}}
|
|
282
312
|
slotProps={{
|
|
283
313
|
// Spreading params.slotProps keeps `input`, which carries the ref
|
|
284
314
|
// and classes Autocomplete relies on.
|
|
285
315
|
...params.slotProps,
|
|
316
|
+
input: {
|
|
317
|
+
...params.slotProps.input,
|
|
318
|
+
startAdornment:
|
|
319
|
+
!multiple && selectedSingleLabel ? (
|
|
320
|
+
<Box id={selectedValueId} className='rc-ses-select-single-value'>
|
|
321
|
+
{selectedSingleLabel}
|
|
322
|
+
</Box>
|
|
323
|
+
) : (
|
|
324
|
+
params.slotProps.input.startAdornment
|
|
325
|
+
),
|
|
326
|
+
},
|
|
286
327
|
htmlInput: {
|
|
287
328
|
...params.slotProps.htmlInput,
|
|
288
|
-
|
|
329
|
+
'aria-describedby':
|
|
330
|
+
!multiple && selectedSingleLabel ? selectedValueId : undefined,
|
|
331
|
+
value:
|
|
332
|
+
!multiple && selectedSingleLabel
|
|
333
|
+
? ''
|
|
334
|
+
: params.slotProps.htmlInput?.value,
|
|
335
|
+
readOnly: dropdownSearch || (!multiple && !!selectedSingleLabel),
|
|
289
336
|
},
|
|
290
337
|
}}
|
|
291
338
|
/>
|
|
@@ -468,7 +515,7 @@ function RcSesSelect(props: Props) {
|
|
|
468
515
|
</Box>
|
|
469
516
|
)
|
|
470
517
|
}}
|
|
471
|
-
renderValue={(tagValues, getItemProps) => {
|
|
518
|
+
renderValue={(tagValues, getItemProps, ownerState) => {
|
|
472
519
|
// MUI 9 merged renderTags into renderValue, so this now runs for
|
|
473
520
|
// single-select too where v7's renderTags did not. Single-select must
|
|
474
521
|
// keep showing the plain label - rendering a deletable Chip there both
|
|
@@ -478,32 +525,40 @@ function RcSesSelect(props: Props) {
|
|
|
478
525
|
return selected[0]?.label ?? ''
|
|
479
526
|
}
|
|
480
527
|
|
|
481
|
-
const
|
|
482
|
-
const
|
|
528
|
+
const visibleTagLimit = ownerState.limitTags ?? -1
|
|
529
|
+
const shouldLimitTags =
|
|
530
|
+
visibleTagLimit > -1 && selected.length > visibleTagLimit
|
|
531
|
+
const visibleTags = shouldLimitTags
|
|
532
|
+
? selected.slice(0, visibleTagLimit)
|
|
533
|
+
: selected
|
|
534
|
+
const hiddenTagCount = selected.length - visibleTags.length
|
|
535
|
+
|
|
483
536
|
return (
|
|
484
537
|
<>
|
|
485
|
-
{
|
|
538
|
+
{visibleTags.map((option, index) => (
|
|
486
539
|
// getItemProps no longer returns a key, so it comes from the option.
|
|
487
540
|
<Chip
|
|
488
541
|
key={option.value ?? index}
|
|
489
542
|
label={option.label}
|
|
490
543
|
size='small'
|
|
544
|
+
sx={{
|
|
545
|
+
height: 'auto',
|
|
546
|
+
maxWidth: `calc(100% - ${reservedMultipleEndAdornmentWidth}rem)`,
|
|
547
|
+
'& .MuiChip-label': {
|
|
548
|
+
display: 'block',
|
|
549
|
+
overflowWrap: 'anywhere',
|
|
550
|
+
py: '.25rem',
|
|
551
|
+
textOverflow: 'clip',
|
|
552
|
+
whiteSpace: 'normal',
|
|
553
|
+
},
|
|
554
|
+
}}
|
|
491
555
|
{...getItemProps({ index })}
|
|
492
556
|
/>
|
|
493
557
|
))}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
alignSelf: 'center',
|
|
499
|
-
color: 'text.secondary',
|
|
500
|
-
flexShrink: 0,
|
|
501
|
-
fontSize: '.8125rem',
|
|
502
|
-
ml: '.25rem',
|
|
503
|
-
whiteSpace: 'nowrap',
|
|
504
|
-
}}
|
|
505
|
-
>
|
|
506
|
-
+{hiddenCount}
|
|
558
|
+
|
|
559
|
+
{hiddenTagCount > 0 && (
|
|
560
|
+
<Box component='span' className='MuiAutocomplete-tag'>
|
|
561
|
+
{ownerState.getLimitTagsText?.(hiddenTagCount) ?? `+${hiddenTagCount}`}
|
|
507
562
|
</Box>
|
|
508
563
|
)}
|
|
509
564
|
</>
|
|
@@ -17,4 +17,17 @@ describe('RcSesFooter', () => {
|
|
|
17
17
|
|
|
18
18
|
expect(screen.getByText('Footer text')).toBeInTheDocument()
|
|
19
19
|
})
|
|
20
|
+
|
|
21
|
+
// The footer sits on grey[900], so if the text colour is ever dropped it turns
|
|
22
|
+
// black on near black and the footer reads as an empty band. That is how it
|
|
23
|
+
// shipped in 2.0.0-rc.1: MUI 9 takes `color` only as a palette key, so a raw
|
|
24
|
+
// value handed to it is discarded. The visual suite does not catch this - the
|
|
25
|
+
// text is ~6.5k pixels of a 921k full page shot, under the 1% diff budget.
|
|
26
|
+
test('renders the text in grey[200] rather than inheriting', () => {
|
|
27
|
+
renderFooter(<RcSesFooter text='Footer text' />)
|
|
28
|
+
|
|
29
|
+
expect(window.getComputedStyle(screen.getByText('Footer text')).color).toBe(
|
|
30
|
+
'rgb(220, 224, 229)',
|
|
31
|
+
)
|
|
32
|
+
})
|
|
20
33
|
})
|
|
@@ -18,9 +18,12 @@ function RcSesFooter({ text }: Props) {
|
|
|
18
18
|
>
|
|
19
19
|
<Container>
|
|
20
20
|
<Typography
|
|
21
|
-
color={palette.grey['200']}
|
|
22
21
|
component='div'
|
|
23
|
-
sx={{
|
|
22
|
+
sx={{
|
|
23
|
+
color: palette.grey['200'],
|
|
24
|
+
lineHeight: '1.25rem',
|
|
25
|
+
whiteSpace: 'pre-line',
|
|
26
|
+
}}
|
|
24
27
|
variant='caption'
|
|
25
28
|
>
|
|
26
29
|
{text}
|
|
@@ -14,6 +14,20 @@
|
|
|
14
14
|
"SegmentedControl": {
|
|
15
15
|
"options": "Options",
|
|
16
16
|
"tabs": "Tabs"
|
|
17
|
+
},
|
|
18
|
+
"AdvancedListItemTrailing": {
|
|
19
|
+
"decrease": "Decrease",
|
|
20
|
+
"increase": "Increase",
|
|
21
|
+
"delete": "Delete",
|
|
22
|
+
"toggle": "Toggle",
|
|
23
|
+
"vat": "incl. VAT"
|
|
24
|
+
},
|
|
25
|
+
"Tooltip": {
|
|
26
|
+
"trigger": "Explanation"
|
|
27
|
+
},
|
|
28
|
+
"AdvancedListItemLeading": {
|
|
29
|
+
"moveUp": "Move up",
|
|
30
|
+
"moveDown": "Move down"
|
|
17
31
|
}
|
|
18
32
|
}
|
|
19
33
|
}
|
|
@@ -14,6 +14,20 @@
|
|
|
14
14
|
"SegmentedControl": {
|
|
15
15
|
"options": "Parinktys",
|
|
16
16
|
"tabs": "Skirtukai"
|
|
17
|
+
},
|
|
18
|
+
"AdvancedListItemTrailing": {
|
|
19
|
+
"decrease": "Sumažinti",
|
|
20
|
+
"increase": "Padidinti",
|
|
21
|
+
"delete": "Pašalinti",
|
|
22
|
+
"toggle": "Perjungti",
|
|
23
|
+
"vat": "su PVM"
|
|
24
|
+
},
|
|
25
|
+
"Tooltip": {
|
|
26
|
+
"trigger": "Paaiškinimas"
|
|
27
|
+
},
|
|
28
|
+
"AdvancedListItemLeading": {
|
|
29
|
+
"moveUp": "Perkelti aukštyn",
|
|
30
|
+
"moveDown": "Perkelti žemyn"
|
|
17
31
|
}
|
|
18
32
|
}
|
|
19
33
|
}
|
package/src/library/icons.ts
CHANGED
|
@@ -12,6 +12,8 @@ import CaretDownIcon from '@/assets/icons/CaretDownIcon'
|
|
|
12
12
|
import CaretLeftBoldIcon from '@/assets/icons/CaretLeftBoldIcon'
|
|
13
13
|
import CaretLeftIcon from '@/assets/icons/CaretLeftIcon'
|
|
14
14
|
import CaretRightBoldIcon from '@/assets/icons/CaretRightBoldIcon'
|
|
15
|
+
import CaretUpBoldIcon from '@/assets/icons/CaretUpBoldIcon'
|
|
16
|
+
import CaretUpIcon from '@/assets/icons/CaretUpIcon'
|
|
15
17
|
import CheckBoldIcon from '@/assets/icons/CheckBoldIcon'
|
|
16
18
|
import CheckCircleFillIcon from '@/assets/icons/CheckCircleFillIcon'
|
|
17
19
|
import CheckIcon from '@/assets/icons/CheckIcon'
|
|
@@ -23,11 +25,15 @@ import CopyIcon from '@/assets/icons/CopyIcon'
|
|
|
23
25
|
import DotCircleFilledIcon from '@/assets/icons/DotCircleFilledIcon'
|
|
24
26
|
import ExpandChevronsIcon from '@/assets/icons/ExpandChevronsIcon'
|
|
25
27
|
import InfoFillIcon from '@/assets/icons/InfoFillIcon'
|
|
28
|
+
import ListIcon from '@/assets/icons/ListIcon'
|
|
26
29
|
import MagnifyingGlassIcon from '@/assets/icons/MagnifyingGlassIcon'
|
|
27
30
|
import MapPinAreaIcon from '@/assets/icons/MapPinAreaIcon'
|
|
28
31
|
import MinusBoldIcon from '@/assets/icons/MinusBoldIcon'
|
|
32
|
+
import MinusIcon from '@/assets/icons/MinusIcon'
|
|
33
|
+
import NotePencilIcon from '@/assets/icons/NotePencilIcon'
|
|
29
34
|
import PencilSimpleLineIcon from '@/assets/icons/PencilSimpleLineIcon'
|
|
30
35
|
import PlusBoldIcon from '@/assets/icons/PlusBoldIcon'
|
|
36
|
+
import PlusIcon from '@/assets/icons/PlusIcon'
|
|
31
37
|
import QuestionFillIcon from '@/assets/icons/QuestionFillIcon'
|
|
32
38
|
import QuestionIcon from '@/assets/icons/QuestionIcon'
|
|
33
39
|
import ScalesIcon from '@/assets/icons/ScalesIcon'
|
|
@@ -35,7 +41,9 @@ import ScrollIcon from '@/assets/icons/ScrollIcon'
|
|
|
35
41
|
import SearchHelpIcon from '@/assets/icons/SearchHelpIcon'
|
|
36
42
|
import SearchXIcon from '@/assets/icons/SearchXIcon'
|
|
37
43
|
import SpinnerGapBoldIcon from '@/assets/icons/SpinnerGapBoldIcon'
|
|
44
|
+
import TrashIcon from '@/assets/icons/TrashIcon'
|
|
38
45
|
import UploadSimpleIcon from '@/assets/icons/UploadSimpleIcon'
|
|
46
|
+
import UserIcon from '@/assets/icons/UserIcon'
|
|
39
47
|
import WarningCircleIcon from '@/assets/icons/WarningCircleIcon'
|
|
40
48
|
import WarningDiamondFillIcon from '@/assets/icons/WarningDiamondFillIcon'
|
|
41
49
|
import WarningFillIcon from '@/assets/icons/WarningFillIcon'
|
|
@@ -56,6 +64,8 @@ export {
|
|
|
56
64
|
CaretLeftBoldIcon,
|
|
57
65
|
CaretLeftIcon,
|
|
58
66
|
CaretRightBoldIcon,
|
|
67
|
+
CaretUpIcon,
|
|
68
|
+
CaretUpBoldIcon,
|
|
59
69
|
CheckBoldIcon,
|
|
60
70
|
CheckCircleFillIcon,
|
|
61
71
|
CheckIcon,
|
|
@@ -67,11 +77,15 @@ export {
|
|
|
67
77
|
DotCircleFilledIcon,
|
|
68
78
|
ExpandChevronsIcon,
|
|
69
79
|
InfoFillIcon,
|
|
80
|
+
ListIcon,
|
|
70
81
|
MagnifyingGlassIcon,
|
|
71
82
|
MapPinAreaIcon,
|
|
72
83
|
MinusBoldIcon,
|
|
84
|
+
MinusIcon,
|
|
85
|
+
NotePencilIcon,
|
|
73
86
|
PencilSimpleLineIcon,
|
|
74
87
|
PlusBoldIcon,
|
|
88
|
+
PlusIcon,
|
|
75
89
|
QuestionFillIcon,
|
|
76
90
|
QuestionIcon,
|
|
77
91
|
ScalesIcon,
|
|
@@ -79,7 +93,9 @@ export {
|
|
|
79
93
|
SearchHelpIcon,
|
|
80
94
|
SearchXIcon,
|
|
81
95
|
SpinnerGapBoldIcon,
|
|
96
|
+
TrashIcon,
|
|
82
97
|
UploadSimpleIcon,
|
|
98
|
+
UserIcon,
|
|
83
99
|
WarningDiamondFillIcon,
|
|
84
100
|
WarningFillIcon,
|
|
85
101
|
WarningCircleIcon,
|
package/src/library/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type {} from '@mui/x-date-pickers/themeAugmentation'
|
|
|
5
5
|
import RcSesIconProps from '@/assets/IconProps'
|
|
6
6
|
import RcSesAccordion from '@/components/common/Accordion'
|
|
7
7
|
import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
|
|
8
|
+
import RcSesAdvancedList from '@/components/common/AdvancedList'
|
|
9
|
+
import RcSesAdvancedListItem from '@/components/common/AdvancedList/components/AdvancedListItem'
|
|
8
10
|
import RcSesAlert from '@/components/common/Alert'
|
|
9
11
|
import RcSesBadge from '@/components/common/Badge'
|
|
10
12
|
import RcSesBreadcrumbs from '@/components/common/Breadcrumbs'
|
|
@@ -26,6 +28,7 @@ import RcSesTab from '@/components/common/Tabs/Tab'
|
|
|
26
28
|
import RcSesTabPanel from '@/components/common/Tabs/TabPanel'
|
|
27
29
|
import RcSesTabs from '@/components/common/Tabs/Tabs'
|
|
28
30
|
import RcSesTabsWrapper from '@/components/common/Tabs/TabsWrapper'
|
|
31
|
+
import RcSesTooltip from '@/components/common/Tooltip'
|
|
29
32
|
import RcSesFormControlWrapper from '@/components/form/components/FormControlWrapper'
|
|
30
33
|
import RcSesCheckbox from '@/components/form/inputs/Checkbox'
|
|
31
34
|
import RcSesCheckboxFormControl from '@/components/form/inputs/CheckboxFormControl'
|
|
@@ -67,6 +70,7 @@ declare module '@mui/x-date-pickers/models' {
|
|
|
67
70
|
|
|
68
71
|
export { RcSesPalette, RcSesTheme }
|
|
69
72
|
export { RcSesAccordion, useAccordionController }
|
|
73
|
+
export { RcSesAdvancedList, RcSesAdvancedListItem }
|
|
70
74
|
export {
|
|
71
75
|
RcSesAlert,
|
|
72
76
|
RcSesBadge,
|
|
@@ -98,6 +102,7 @@ export { RcSesSearchInput }
|
|
|
98
102
|
export { RcSesSearchableField }
|
|
99
103
|
export { RcSesSelect }
|
|
100
104
|
export { RcSesTab, RcSesTabPanel, RcSesTabs, RcSesTabsWrapper }
|
|
105
|
+
export { RcSesTooltip }
|
|
101
106
|
export { RcSesTextField }
|
|
102
107
|
export { DataPagination }
|
|
103
108
|
export { ListWithIcons }
|
package/src/library/types.ts
CHANGED
|
@@ -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 }
|
package/src/setupTests.ts
CHANGED
|
@@ -2,13 +2,19 @@ import '@testing-library/jest-dom/vitest'
|
|
|
2
2
|
import i18n from 'i18next'
|
|
3
3
|
import { initReactI18next } from 'react-i18next'
|
|
4
4
|
|
|
5
|
+
import commonEn from '@/i18n/namespaces/common/en.json'
|
|
6
|
+
import commonLt from '@/i18n/namespaces/common/lt.json'
|
|
7
|
+
import inputEn from '@/i18n/namespaces/input/en.json'
|
|
8
|
+
import inputLt from '@/i18n/namespaces/input/lt.json'
|
|
9
|
+
|
|
5
10
|
if (!i18n.isInitialized) {
|
|
6
11
|
i18n.use(initReactI18next).init({
|
|
7
12
|
fallbackLng: 'lt',
|
|
8
13
|
interpolation: { escapeValue: false },
|
|
9
14
|
lng: 'lt',
|
|
10
15
|
resources: {
|
|
11
|
-
lt: {
|
|
16
|
+
lt: { common: commonLt, input: inputLt },
|
|
17
|
+
en: { common: commonEn, input: inputEn },
|
|
12
18
|
},
|
|
13
19
|
})
|
|
14
20
|
}
|