@registrucentras/rc-ses-react-components 1.6.4 → 1.6.5
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/IconProps.d.ts +2 -0
- package/dist/assets/icons/CheckIcon.d.ts +3 -0
- package/dist/assets/icons/PencilSimpleLineIcon.d.ts +3 -0
- package/dist/components/common/Card/index.d.ts +4 -1
- package/dist/components/form/inputs/Select/Select.types.d.ts +5 -0
- package/dist/components/form/inputs/Select/hooks/useFilteredOptions.d.ts +3 -0
- package/dist/components/form/inputs/Select/hooks/useSelectAllLogic.d.ts +7 -0
- package/dist/components/form/inputs/{Select.d.ts → Select/index.d.ts} +12 -12
- package/dist/library/icons.d.ts +2 -1
- package/dist/registrucentras-rc-ses-react-components.cjs +11 -11
- package/dist/registrucentras-rc-ses-react-components.js +3154 -2747
- package/dist/stories/components/display/Card.stories.d.ts +6 -47
- package/dist/stories/components/display/ImageCard.stories.d.ts +6 -6
- package/dist/stories/components/feedback/Alert.stories.d.ts +7 -16
- package/dist/stories/components/form/CardFormContainer.stories.d.ts +5 -5
- package/dist/stories/components/form/CheckboxFormControl.stories.d.ts +3 -23
- package/dist/stories/components/form/ServiceFormActions.stories.d.ts +3 -9
- package/dist/stories/components/icons/Icons.stories.d.ts +3 -2
- package/dist/stories/components/inputs/FileDropzone.stories.d.ts +3 -29
- package/dist/stories/components/inputs/NumberStepper.stories.d.ts +3 -31
- package/dist/stories/components/inputs/RadioButtonGroup.stories.d.ts +4 -32
- package/dist/stories/components/inputs/SearchableField.stories.d.ts +3 -332
- package/dist/stories/components/inputs/Select.stories.d.ts +4 -871
- package/dist/stories/components/inputs/TextField.stories.d.ts +3 -610
- package/dist/stories/components/layout/Footer.stories.d.ts +3 -5
- package/dist/stories/components/navigation/Breadcrumbs.stories.d.ts +4 -6
- package/dist/stories/components/navigation/ServiceWizardStepper.stories.d.ts +5 -5
- package/package.json +1 -1
- package/src/assets/IconProps.ts +2 -0
- package/src/assets/icons/CheckIcon.tsx +23 -0
- package/src/assets/icons/PencilSimpleLineIcon.tsx +17 -0
- package/src/components/common/Card/index.test.tsx +8 -0
- package/src/components/common/Card/index.tsx +64 -25
- package/src/components/common/SelectableCardList/index.tsx +2 -1
- package/src/components/form/components/FormControlWrapper/index.tsx +6 -1
- package/src/components/form/inputs/PhoneInputFormControl/index.tsx +11 -3
- package/src/components/form/inputs/Select/Select.types.ts +5 -0
- package/src/components/form/inputs/Select/hooks/useFilteredOptions.ts +18 -0
- package/src/components/form/inputs/Select/hooks/useSelectAllLogic.ts +22 -0
- package/src/components/form/inputs/Select/index.tsx +494 -0
- package/src/library/icons.ts +2 -0
- package/src/stories/components/display/Card.stories.tsx +64 -47
- package/src/stories/components/display/ImageCard.stories.tsx +29 -27
- package/src/stories/components/feedback/Alert.stories.tsx +59 -50
- package/src/stories/components/form/CardFormContainer.stories.tsx +77 -63
- package/src/stories/components/form/CheckboxFormControl.stories.tsx +29 -71
- package/src/stories/components/form/ServiceFormActions.stories.tsx +18 -21
- package/src/stories/components/form/ServiceFormContainer.stories.tsx +1 -1
- package/src/stories/components/icons/Icons.stories.tsx +6 -2
- package/src/stories/components/inputs/FileDropzone.stories.tsx +17 -34
- package/src/stories/components/inputs/NumberStepper.stories.tsx +32 -60
- package/src/stories/components/inputs/RadioButtonGroup.stories.tsx +22 -20
- package/src/stories/components/inputs/SearchableField.stories.tsx +16 -14
- package/src/stories/components/inputs/Select.stories.tsx +245 -13
- package/src/stories/components/inputs/TextField.stories.tsx +47 -47
- package/src/stories/components/layout/Footer.stories.tsx +6 -6
- package/src/stories/components/navigation/Breadcrumbs.stories.tsx +6 -8
- package/src/stories/components/navigation/ServiceWizardStepper.stories.tsx +29 -22
- package/src/theme/light/MuiAutocomplete.ts +52 -3
- package/src/components/form/inputs/Select.tsx +0 -152
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
import { Box, Checkbox, Chip, TextField } from '@mui/material'
|
|
2
|
+
import Autocomplete, { AutocompleteProps } from '@mui/material/Autocomplete'
|
|
3
|
+
import React, { useMemo } from 'react'
|
|
4
|
+
import { UseControllerProps, useController } from 'react-hook-form'
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
6
|
+
|
|
7
|
+
import CheckBoldIcon from '@/assets/icons/CheckBoldIcon'
|
|
8
|
+
import CheckIcon from '@/assets/icons/CheckIcon'
|
|
9
|
+
import CheckUncheckedBoldIcon from '@/assets/icons/CheckUncheckedBoldIcon'
|
|
10
|
+
import MagnifyingGlassIcon from '@/assets/icons/MagnifyingGlassIcon'
|
|
11
|
+
import palette from '@/theme/palette'
|
|
12
|
+
|
|
13
|
+
import RcSesFormControlWrapper, {
|
|
14
|
+
RcSesFormControlWrapperProps,
|
|
15
|
+
} from '../../components/FormControlWrapper'
|
|
16
|
+
import { Option } from './Select.types'
|
|
17
|
+
import useFilteredOptions from './hooks/useFilteredOptions'
|
|
18
|
+
import useSelectAll from './hooks/useSelectAllLogic'
|
|
19
|
+
|
|
20
|
+
type TControllerProps = UseControllerProps<any, any>
|
|
21
|
+
type ImmediateControllerProps = 'control' | 'rules' | 'name' | 'disabled'
|
|
22
|
+
|
|
23
|
+
type TWrapperProps = RcSesFormControlWrapperProps
|
|
24
|
+
type ImmediateWrapperProps = 'id' | 'label' | 'errors'
|
|
25
|
+
type AutocompleteValue<T, Multiple extends boolean> = Multiple extends true
|
|
26
|
+
? T[]
|
|
27
|
+
: T | null
|
|
28
|
+
|
|
29
|
+
type Props = Pick<TControllerProps, ImmediateControllerProps> &
|
|
30
|
+
Pick<TWrapperProps, ImmediateWrapperProps> & {
|
|
31
|
+
multiple?: boolean
|
|
32
|
+
clearable?: boolean
|
|
33
|
+
limitTags?: number
|
|
34
|
+
loading?: boolean
|
|
35
|
+
options: Option[]
|
|
36
|
+
placeholder?: string
|
|
37
|
+
dropdownLabel?: string
|
|
38
|
+
dropdownSearch?: boolean
|
|
39
|
+
dropdownSearchPlaceholder?: string
|
|
40
|
+
selectAll?: boolean
|
|
41
|
+
|
|
42
|
+
onInputChange?: AutocompleteProps<Option, boolean, boolean, false>['onInputChange']
|
|
43
|
+
|
|
44
|
+
slotProps?: {
|
|
45
|
+
field?: Partial<
|
|
46
|
+
Omit<
|
|
47
|
+
AutocompleteProps<Option, boolean, boolean, false>,
|
|
48
|
+
'renderInput' | 'options' | 'value'
|
|
49
|
+
>
|
|
50
|
+
>
|
|
51
|
+
wrapper?: Partial<Omit<TWrapperProps, ImmediateWrapperProps>>
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function RcSesSelect(props: Props) {
|
|
56
|
+
const [inputValue, setInputValue] = React.useState('')
|
|
57
|
+
const [dropdownSearchValue, setDropdownSearchValue] = React.useState('')
|
|
58
|
+
const [open, setOpen] = React.useState(false)
|
|
59
|
+
const dropdownSearchOptionValue = '__dropdown-search-option__'
|
|
60
|
+
const wrapperRef = React.useRef<HTMLDivElement>(null)
|
|
61
|
+
|
|
62
|
+
const {
|
|
63
|
+
multiple = false,
|
|
64
|
+
clearable,
|
|
65
|
+
limitTags = 1,
|
|
66
|
+
control,
|
|
67
|
+
errors,
|
|
68
|
+
label,
|
|
69
|
+
loading,
|
|
70
|
+
onInputChange,
|
|
71
|
+
options,
|
|
72
|
+
placeholder,
|
|
73
|
+
rules,
|
|
74
|
+
slotProps,
|
|
75
|
+
dropdownLabel,
|
|
76
|
+
dropdownSearch = false,
|
|
77
|
+
dropdownSearchPlaceholder = 'Ieškoti',
|
|
78
|
+
selectAll = false,
|
|
79
|
+
...fieldProps
|
|
80
|
+
} = props
|
|
81
|
+
|
|
82
|
+
const { disabled, name } = fieldProps
|
|
83
|
+
|
|
84
|
+
const id = useMemo(() => fieldProps.id ?? uuidv4(), [fieldProps.id])
|
|
85
|
+
|
|
86
|
+
const {
|
|
87
|
+
field: { onChange, value },
|
|
88
|
+
} = useController({
|
|
89
|
+
control,
|
|
90
|
+
name,
|
|
91
|
+
rules,
|
|
92
|
+
shouldUnregister: true,
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const hasError = !!errors
|
|
96
|
+
const hasCustomGroupBy = typeof slotProps?.field?.groupBy === 'function'
|
|
97
|
+
|
|
98
|
+
const resolvedValue = useMemo(() => {
|
|
99
|
+
if (multiple) {
|
|
100
|
+
if (!Array.isArray(value)) return []
|
|
101
|
+
return options.filter((o) => value.includes(o.value))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return options.find((o) => o.value === value) ?? null
|
|
105
|
+
}, [value, options, multiple])
|
|
106
|
+
|
|
107
|
+
const searchRowOption = useMemo<Option>(
|
|
108
|
+
() => ({ label: '', value: dropdownSearchOptionValue }),
|
|
109
|
+
[dropdownSearchOptionValue],
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
const resolvedOptions = useMemo(
|
|
113
|
+
() => (dropdownSearch && !hasCustomGroupBy ? [searchRowOption, ...options] : options),
|
|
114
|
+
[dropdownSearch, hasCustomGroupBy, options, searchRowOption],
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
const handleChange = (
|
|
118
|
+
_: React.SyntheticEvent,
|
|
119
|
+
selected: AutocompleteValue<Option, typeof multiple>,
|
|
120
|
+
) => {
|
|
121
|
+
if (multiple) {
|
|
122
|
+
const values = (selected as Option[])
|
|
123
|
+
.filter((item) => item.value !== dropdownSearchOptionValue)
|
|
124
|
+
.map((item) => item.value)
|
|
125
|
+
|
|
126
|
+
onChange(values)
|
|
127
|
+
} else {
|
|
128
|
+
const val = selected as Option | null
|
|
129
|
+
if (val?.value === dropdownSearchOptionValue) return
|
|
130
|
+
onChange(val?.value ?? null)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const filteredOptions = useFilteredOptions(options, dropdownSearchValue)
|
|
135
|
+
|
|
136
|
+
const selectedValues = Array.isArray(value) ? value : []
|
|
137
|
+
const { allSelected: allFilteredSelected, toggle: handleSelectAll } = useSelectAll(
|
|
138
|
+
filteredOptions,
|
|
139
|
+
selectedValues,
|
|
140
|
+
onChange,
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
const filterOptions = (opts: Option[]) => {
|
|
144
|
+
if (!dropdownSearch || hasCustomGroupBy) return opts
|
|
145
|
+
|
|
146
|
+
const [searchOption, ...realOptions] = opts
|
|
147
|
+
if (!dropdownSearchValue.trim()) return opts
|
|
148
|
+
|
|
149
|
+
const filteredValues = new Set(filteredOptions.map((o) => o.value))
|
|
150
|
+
const filtered = realOptions.filter((opt) => filteredValues.has(opt.value))
|
|
151
|
+
|
|
152
|
+
return [searchOption, ...filtered]
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const closeDropdown = () => {
|
|
156
|
+
setOpen(false)
|
|
157
|
+
setDropdownSearchValue('')
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const shouldKeepDropdownOpen = () => {
|
|
161
|
+
const activeEl = document.activeElement
|
|
162
|
+
if (!(activeEl instanceof Element)) return false
|
|
163
|
+
|
|
164
|
+
const listbox = document.getElementById(`${id}-listbox`)
|
|
165
|
+
return !!listbox?.contains(activeEl) || !!wrapperRef.current?.contains(activeEl)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const deferCloseCheck = () => {
|
|
169
|
+
requestAnimationFrame(() => {
|
|
170
|
+
if (!shouldKeepDropdownOpen()) {
|
|
171
|
+
closeDropdown()
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
return (
|
|
176
|
+
<RcSesFormControlWrapper
|
|
177
|
+
id={id}
|
|
178
|
+
errors={errors}
|
|
179
|
+
label={label}
|
|
180
|
+
required={!!rules?.required}
|
|
181
|
+
{...slotProps?.wrapper}
|
|
182
|
+
>
|
|
183
|
+
<Autocomplete
|
|
184
|
+
id={id}
|
|
185
|
+
ref={wrapperRef}
|
|
186
|
+
open={open}
|
|
187
|
+
onOpen={() => setOpen(true)}
|
|
188
|
+
multiple={multiple}
|
|
189
|
+
limitTags={multiple ? limitTags : undefined}
|
|
190
|
+
disableCloseOnSelect={multiple}
|
|
191
|
+
disabled={disabled}
|
|
192
|
+
disableClearable={clearable === false}
|
|
193
|
+
options={resolvedOptions}
|
|
194
|
+
filterOptions={(opts) => filterOptions(opts)}
|
|
195
|
+
disableListWrap
|
|
196
|
+
blurOnSelect={false}
|
|
197
|
+
clearOnBlur={false}
|
|
198
|
+
handleHomeEndKeys={false}
|
|
199
|
+
ListboxProps={{
|
|
200
|
+
onMouseDown: (e) => {
|
|
201
|
+
e.preventDefault()
|
|
202
|
+
},
|
|
203
|
+
}}
|
|
204
|
+
loading={loading}
|
|
205
|
+
value={resolvedValue}
|
|
206
|
+
inputValue={dropdownSearch ? undefined : inputValue}
|
|
207
|
+
onChange={handleChange}
|
|
208
|
+
onInputChange={(event, val, reason) => {
|
|
209
|
+
if (dropdownSearch) return
|
|
210
|
+
|
|
211
|
+
setInputValue(val ?? '')
|
|
212
|
+
onInputChange?.(event, val, reason)
|
|
213
|
+
}}
|
|
214
|
+
onClose={(_event, reason) => {
|
|
215
|
+
if (dropdownSearch && reason === 'blur') {
|
|
216
|
+
deferCloseCheck()
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
closeDropdown()
|
|
220
|
+
}}
|
|
221
|
+
isOptionEqualToValue={(option, val) => option.value === val.value}
|
|
222
|
+
getOptionLabel={(option) => option.label}
|
|
223
|
+
groupBy={() => ''} // to prevent default grouping when groupBy is not provided but dropdownSearch is enabled
|
|
224
|
+
renderGroup={(params) => (
|
|
225
|
+
<React.Fragment key={params.key}>
|
|
226
|
+
{!!params.group && (
|
|
227
|
+
<Box className='MuiAutocomplete-groupLabel'>{params.group}</Box>
|
|
228
|
+
)}
|
|
229
|
+
|
|
230
|
+
{!params.group && !!dropdownLabel && (
|
|
231
|
+
<Box
|
|
232
|
+
sx={{
|
|
233
|
+
padding: '1.1875rem 1.125rem .8125rem 1.125rem',
|
|
234
|
+
fontSize: '.9375rem',
|
|
235
|
+
color: palette.grey[600],
|
|
236
|
+
}}
|
|
237
|
+
>
|
|
238
|
+
{dropdownLabel}
|
|
239
|
+
</Box>
|
|
240
|
+
)}
|
|
241
|
+
|
|
242
|
+
{params.children}
|
|
243
|
+
</React.Fragment>
|
|
244
|
+
)}
|
|
245
|
+
renderInput={(params) => (
|
|
246
|
+
<TextField
|
|
247
|
+
{...params}
|
|
248
|
+
disabled={disabled}
|
|
249
|
+
error={hasError}
|
|
250
|
+
placeholder={placeholder}
|
|
251
|
+
sx={{
|
|
252
|
+
...(dropdownSearch
|
|
253
|
+
? {
|
|
254
|
+
'& .MuiInputBase-input': {
|
|
255
|
+
caretColor: 'transparent',
|
|
256
|
+
},
|
|
257
|
+
}
|
|
258
|
+
: {}),
|
|
259
|
+
...(multiple
|
|
260
|
+
? {
|
|
261
|
+
'& .MuiAutocomplete-inputRoot': {
|
|
262
|
+
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,
|
|
274
|
+
},
|
|
275
|
+
'& .MuiAutocomplete-tag': {
|
|
276
|
+
alignSelf: 'center',
|
|
277
|
+
m: '0 .25rem 0 .35rem',
|
|
278
|
+
maxWidth: 'calc(100% - 3.5rem)',
|
|
279
|
+
},
|
|
280
|
+
'& .MuiAutocomplete-input': {
|
|
281
|
+
minWidth: 0,
|
|
282
|
+
},
|
|
283
|
+
}
|
|
284
|
+
: {}),
|
|
285
|
+
}}
|
|
286
|
+
InputProps={{
|
|
287
|
+
...params.InputProps,
|
|
288
|
+
inputProps: {
|
|
289
|
+
...params.inputProps,
|
|
290
|
+
readOnly: dropdownSearch,
|
|
291
|
+
},
|
|
292
|
+
}}
|
|
293
|
+
/>
|
|
294
|
+
)}
|
|
295
|
+
renderOption={(optionProps, option, { selected }) => {
|
|
296
|
+
const { key, ...rest } = optionProps as any
|
|
297
|
+
|
|
298
|
+
if (option.value === dropdownSearchOptionValue) {
|
|
299
|
+
return (
|
|
300
|
+
<Box
|
|
301
|
+
key={key}
|
|
302
|
+
component='li'
|
|
303
|
+
{...rest}
|
|
304
|
+
onMouseDown={(event: React.MouseEvent) => {
|
|
305
|
+
event.preventDefault()
|
|
306
|
+
}}
|
|
307
|
+
onClick={(event: React.MouseEvent) => {
|
|
308
|
+
event.stopPropagation()
|
|
309
|
+
}}
|
|
310
|
+
sx={{
|
|
311
|
+
'&:hover': { backgroundColor: 'transparent !important' },
|
|
312
|
+
alignItems: 'center',
|
|
313
|
+
borderBottom: `1px solid ${palette.grey['200']}`,
|
|
314
|
+
display: 'flex',
|
|
315
|
+
flexDirection: 'row !important',
|
|
316
|
+
gap: '.75rem',
|
|
317
|
+
mb: '.25rem',
|
|
318
|
+
pb: '.5rem',
|
|
319
|
+
pt: 0,
|
|
320
|
+
px: '.75rem',
|
|
321
|
+
}}
|
|
322
|
+
>
|
|
323
|
+
{multiple && selectAll && (
|
|
324
|
+
<Checkbox
|
|
325
|
+
checked={allFilteredSelected}
|
|
326
|
+
checkedIcon={
|
|
327
|
+
<CheckBoldIcon fillColor={palette.primary.main} size={24} />
|
|
328
|
+
}
|
|
329
|
+
icon={
|
|
330
|
+
<CheckUncheckedBoldIcon fillColor={palette.grey['500']} size={24} />
|
|
331
|
+
}
|
|
332
|
+
disableRipple
|
|
333
|
+
onMouseDown={(e) => {
|
|
334
|
+
e.preventDefault()
|
|
335
|
+
e.stopPropagation()
|
|
336
|
+
}}
|
|
337
|
+
onClick={(e) => {
|
|
338
|
+
e.stopPropagation()
|
|
339
|
+
handleSelectAll()
|
|
340
|
+
}}
|
|
341
|
+
sx={{
|
|
342
|
+
flexShrink: 0,
|
|
343
|
+
alignSelf: 'center',
|
|
344
|
+
height: '1.5rem',
|
|
345
|
+
m: 0,
|
|
346
|
+
p: 0,
|
|
347
|
+
width: '1.5rem',
|
|
348
|
+
}}
|
|
349
|
+
/>
|
|
350
|
+
)}
|
|
351
|
+
<TextField
|
|
352
|
+
fullWidth
|
|
353
|
+
value={dropdownSearchValue}
|
|
354
|
+
onChange={(event) => setDropdownSearchValue(event.target.value)}
|
|
355
|
+
placeholder={dropdownSearchPlaceholder}
|
|
356
|
+
size='small'
|
|
357
|
+
onMouseDown={(e) => {
|
|
358
|
+
e.stopPropagation()
|
|
359
|
+
}}
|
|
360
|
+
onClick={(e) => {
|
|
361
|
+
e.stopPropagation()
|
|
362
|
+
}}
|
|
363
|
+
onFocus={(e) => {
|
|
364
|
+
e.stopPropagation()
|
|
365
|
+
}}
|
|
366
|
+
onBlur={deferCloseCheck}
|
|
367
|
+
onKeyDown={(event) => {
|
|
368
|
+
event.stopPropagation()
|
|
369
|
+
}}
|
|
370
|
+
sx={{
|
|
371
|
+
'& .MuiInputBase-input::placeholder': {
|
|
372
|
+
color: palette.grey.main,
|
|
373
|
+
opacity: 1,
|
|
374
|
+
},
|
|
375
|
+
}}
|
|
376
|
+
InputProps={{
|
|
377
|
+
inputProps: {
|
|
378
|
+
onKeyDown: (event) => event.stopPropagation(),
|
|
379
|
+
},
|
|
380
|
+
startAdornment: (
|
|
381
|
+
<Box sx={{ display: 'flex', m: '.625rem' }}>
|
|
382
|
+
<MagnifyingGlassIcon size={20} fillColor={palette.grey['900']} />
|
|
383
|
+
</Box>
|
|
384
|
+
),
|
|
385
|
+
}}
|
|
386
|
+
/>
|
|
387
|
+
</Box>
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return (
|
|
392
|
+
<Box
|
|
393
|
+
key={key}
|
|
394
|
+
component='li'
|
|
395
|
+
{...rest}
|
|
396
|
+
display='flex'
|
|
397
|
+
alignItems='center'
|
|
398
|
+
gap={multiple ? '.75rem' : '.5rem'}
|
|
399
|
+
sx={{
|
|
400
|
+
flexDirection: 'row !important',
|
|
401
|
+
justifyContent: 'space-between',
|
|
402
|
+
minWidth: 0,
|
|
403
|
+
}}
|
|
404
|
+
>
|
|
405
|
+
{multiple && (
|
|
406
|
+
<Checkbox
|
|
407
|
+
checked={selected}
|
|
408
|
+
checkedIcon={
|
|
409
|
+
<CheckBoldIcon fillColor={palette.primary.main} size={24} />
|
|
410
|
+
}
|
|
411
|
+
icon={
|
|
412
|
+
<CheckUncheckedBoldIcon fillColor={palette.grey['500']} size={24} />
|
|
413
|
+
}
|
|
414
|
+
tabIndex={-1}
|
|
415
|
+
disableRipple
|
|
416
|
+
sx={{
|
|
417
|
+
alignSelf: 'center',
|
|
418
|
+
height: '1.5rem',
|
|
419
|
+
m: 0,
|
|
420
|
+
p: 0,
|
|
421
|
+
pointerEvents: 'none',
|
|
422
|
+
width: '1.5rem',
|
|
423
|
+
}}
|
|
424
|
+
/>
|
|
425
|
+
)}
|
|
426
|
+
|
|
427
|
+
<Box
|
|
428
|
+
flex={1}
|
|
429
|
+
sx={{
|
|
430
|
+
minWidth: 0,
|
|
431
|
+
...(multiple && !option.description
|
|
432
|
+
? {
|
|
433
|
+
alignItems: 'center',
|
|
434
|
+
display: 'flex',
|
|
435
|
+
minHeight: '1.5rem',
|
|
436
|
+
}
|
|
437
|
+
: {}),
|
|
438
|
+
}}
|
|
439
|
+
>
|
|
440
|
+
<span className='rc-ses-select-option-label'>{option.label}</span>
|
|
441
|
+
|
|
442
|
+
{option.description && (
|
|
443
|
+
<span className='rc-ses-select-option-description'>
|
|
444
|
+
{option.description}
|
|
445
|
+
</span>
|
|
446
|
+
)}
|
|
447
|
+
</Box>
|
|
448
|
+
|
|
449
|
+
{!multiple && selected && (
|
|
450
|
+
<CheckIcon
|
|
451
|
+
size={16}
|
|
452
|
+
fillColor={palette.primary.main}
|
|
453
|
+
aria-hidden
|
|
454
|
+
weight='bold'
|
|
455
|
+
style={{ flexShrink: 0, marginLeft: 'auto', alignSelf: 'center' }}
|
|
456
|
+
/>
|
|
457
|
+
)}
|
|
458
|
+
</Box>
|
|
459
|
+
)
|
|
460
|
+
}}
|
|
461
|
+
renderTags={(tagValues, getTagProps) => {
|
|
462
|
+
const visible = tagValues.slice(0, limitTags)
|
|
463
|
+
const hiddenCount = tagValues.length - visible.length
|
|
464
|
+
return (
|
|
465
|
+
<>
|
|
466
|
+
{visible.map((option, index) => {
|
|
467
|
+
const { key, ...tagProps } = getTagProps({ index })
|
|
468
|
+
return <Chip key={key} label={option.label} size='small' {...tagProps} />
|
|
469
|
+
})}
|
|
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}
|
|
483
|
+
</Box>
|
|
484
|
+
)}
|
|
485
|
+
</>
|
|
486
|
+
)
|
|
487
|
+
}}
|
|
488
|
+
{...slotProps?.field}
|
|
489
|
+
/>
|
|
490
|
+
</RcSesFormControlWrapper>
|
|
491
|
+
)
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
export default RcSesSelect
|
package/src/library/icons.ts
CHANGED
|
@@ -23,6 +23,7 @@ import InfoFillIcon from '@/assets/icons/InfoFillIcon'
|
|
|
23
23
|
import MagnifyingGlassIcon from '@/assets/icons/MagnifyingGlassIcon'
|
|
24
24
|
import MapPinAreaIcon from '@/assets/icons/MapPinAreaIcon'
|
|
25
25
|
import MinusBoldIcon from '@/assets/icons/MinusBoldIcon'
|
|
26
|
+
import PencilSimpleLineIcon from '@/assets/icons/PencilSimpleLineIcon'
|
|
26
27
|
import PlusBoldIcon from '@/assets/icons/PlusBoldIcon'
|
|
27
28
|
import QuestionFillIcon from '@/assets/icons/QuestionFillIcon'
|
|
28
29
|
import QuestionIcon from '@/assets/icons/QuestionIcon'
|
|
@@ -61,6 +62,7 @@ export {
|
|
|
61
62
|
MagnifyingGlassIcon,
|
|
62
63
|
MapPinAreaIcon,
|
|
63
64
|
MinusBoldIcon,
|
|
65
|
+
PencilSimpleLineIcon,
|
|
64
66
|
PlusBoldIcon,
|
|
65
67
|
QuestionFillIcon,
|
|
66
68
|
QuestionIcon,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/* eslint-disable react/function-component-definition */
|
|
2
1
|
import { Box, Typography } from '@mui/material'
|
|
3
|
-
import type { Meta,
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
4
3
|
|
|
5
4
|
import CaretLeftIcon from '@/assets/icons/CaretLeftIcon'
|
|
6
5
|
import MagnifyingGlassIcon from '@/assets/icons/MagnifyingGlassIcon'
|
|
6
|
+
import PencilSimpleLineIcon from '@/assets/icons/PencilSimpleLineIcon'
|
|
7
7
|
import RcSesButton from '@/components/common/Button'
|
|
8
8
|
import RcSesCard from '@/components/common/Card'
|
|
9
9
|
import palette from '@/theme/palette'
|
|
@@ -16,54 +16,71 @@ const meta: Meta<typeof RcSesCard> = {
|
|
|
16
16
|
|
|
17
17
|
export default meta
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
type Story = StoryObj<typeof RcSesCard>
|
|
20
20
|
|
|
21
|
-
export const Main =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Button
|
|
43
|
-
</RcSesButton>
|
|
44
|
-
),
|
|
45
|
-
trailingActions: (
|
|
46
|
-
<>
|
|
47
|
-
<RcSesButton color='grey' variant='outlined'>
|
|
21
|
+
export const Main: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
title: 'Pavadinimas',
|
|
24
|
+
description: 'Papildomas aprasymo tekstas',
|
|
25
|
+
children: (
|
|
26
|
+
<Box
|
|
27
|
+
sx={{
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
color: 'text.primary',
|
|
30
|
+
display: 'flex',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
minHeight: { xs: '9.625rem', md: '11.5rem' },
|
|
33
|
+
px: 3,
|
|
34
|
+
width: '100%',
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
<Typography align='center'>Vidinis paslaugu front-end sprendimas</Typography>
|
|
38
|
+
</Box>
|
|
39
|
+
),
|
|
40
|
+
leadingActions: (
|
|
41
|
+
<RcSesButton startIcon={<CaretLeftIcon />} color='grey' variant='outlined'>
|
|
48
42
|
Button
|
|
49
43
|
</RcSesButton>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
),
|
|
45
|
+
trailingActions: (
|
|
46
|
+
<>
|
|
47
|
+
<RcSesButton color='grey' variant='outlined'>
|
|
48
|
+
Button
|
|
49
|
+
</RcSesButton>
|
|
50
|
+
<RcSesButton>Button</RcSesButton>
|
|
51
|
+
</>
|
|
52
|
+
),
|
|
53
|
+
},
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
export const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
export const WithHeaderAction: Story = {
|
|
57
|
+
args: {
|
|
58
|
+
title: 'Juridinis asmuo',
|
|
59
|
+
description: 'UAB "Telia Lietuva", 121215434',
|
|
60
|
+
contentBackground: false,
|
|
61
|
+
headerAction: (
|
|
62
|
+
<RcSesButton startIcon={<PencilSimpleLineIcon />} variant='text' size='small'>
|
|
63
|
+
Redaguoti
|
|
64
|
+
</RcSesButton>
|
|
65
|
+
),
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const WithImage: Story = {
|
|
70
|
+
args: {
|
|
71
|
+
variant: 'elevation',
|
|
72
|
+
centered: true,
|
|
73
|
+
title: 'Place heading text here',
|
|
74
|
+
description:
|
|
75
|
+
'Additional description text elaborating on situation and what to do next.',
|
|
76
|
+
image: (
|
|
77
|
+
<Box
|
|
78
|
+
sx={{ color: palette.grey[400], position: 'relative', display: 'inline-flex' }}
|
|
79
|
+
>
|
|
80
|
+
<MagnifyingGlassIcon size={64} fillColor={palette.grey[400]} />
|
|
81
|
+
</Box>
|
|
82
|
+
),
|
|
83
|
+
children: <RcSesButton>Button</RcSesButton>,
|
|
84
|
+
contentBackground: false,
|
|
85
|
+
},
|
|
69
86
|
}
|