@registrucentras/rc-ses-react-components 1.6.3 → 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/assets/Logo.stories.d.ts +12 -0
- package/dist/stories/components/actions/ButtonWithPopover.stories.d.ts +7 -0
- 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/FormControlWrapper.stories.d.ts +6 -0
- package/dist/stories/components/form/ServiceFormActions.stories.d.ts +3 -9
- package/dist/stories/components/form/ServiceFormContainer.stories.d.ts +11 -12
- package/dist/stories/components/icons/IconWithCircularBackground.stories.d.ts +6 -0
- package/dist/stories/components/icons/Icons.stories.d.ts +3 -2
- package/dist/stories/components/inputs/Checkbox.stories.d.ts +17 -22
- package/dist/stories/components/inputs/DatePicker.stories.d.ts +18 -20
- package/dist/stories/components/inputs/FileDropzone.stories.d.ts +3 -29
- package/dist/stories/components/inputs/FileUpload.stories.d.ts +14 -26
- package/dist/stories/components/inputs/NumberStepper.stories.d.ts +3 -31
- package/dist/stories/components/inputs/PhoneInput.stories.d.ts +6 -20
- package/dist/stories/components/inputs/PhoneInputFormControl.stories.d.ts +6 -0
- 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/layout/ServiceHeader.stories.d.ts +6 -0
- package/dist/stories/components/layout/ServicePage.stories.d.ts +6 -0
- package/dist/stories/components/navigation/Accordion.stories.d.ts +15 -27
- package/dist/stories/components/navigation/Breadcrumbs.stories.d.ts +4 -6
- package/dist/stories/components/navigation/ServiceWizardStepper.stories.d.ts +5 -5
- package/dist/stories/components/tabs/Tab.stories.d.ts +8 -0
- package/dist/stories/components/tabs/TabPanel.stories.d.ts +7 -0
- package/dist/stories/components/tabs/Tabs.stories.d.ts +7 -0
- package/dist/stories/components/tabs/TabsWrapper.stories.d.ts +6 -0
- 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/Welcome.mdx +87 -0
- package/src/stories/assets/Logo.stories.tsx +16 -0
- package/src/stories/components/actions/ButtonWithPopover.stories.tsx +33 -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/FormControlWrapper.stories.tsx +35 -0
- package/src/stories/components/form/ServiceFormActions.stories.tsx +18 -21
- package/src/stories/components/form/ServiceFormContainer.stories.tsx +11 -11
- package/src/stories/components/icons/IconWithCircularBackground.stories.tsx +39 -0
- package/src/stories/components/icons/Icons.stories.tsx +6 -2
- package/src/stories/components/inputs/Checkbox.stories.tsx +17 -16
- package/src/stories/components/inputs/DatePicker.stories.tsx +16 -15
- package/src/stories/components/inputs/FileDropzone.stories.tsx +17 -34
- package/src/stories/components/inputs/FileUpload.stories.tsx +14 -29
- package/src/stories/components/inputs/NumberStepper.stories.tsx +32 -60
- package/src/stories/components/inputs/PhoneInput.stories.tsx +7 -5
- package/src/stories/components/inputs/PhoneInputFormControl.stories.tsx +33 -0
- 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/layout/ServiceHeader.stories.tsx +36 -0
- package/src/stories/components/layout/ServicePage.stories.tsx +26 -0
- package/src/stories/components/navigation/Accordion.stories.tsx +14 -13
- package/src/stories/components/navigation/Breadcrumbs.stories.tsx +6 -8
- package/src/stories/components/navigation/DataPagination.stories.tsx +19 -17
- package/src/stories/components/navigation/ServiceWizardStepper.stories.tsx +29 -22
- package/src/stories/components/tabs/Tab.stories.tsx +32 -0
- package/src/stories/components/tabs/TabPanel.stories.tsx +31 -0
- package/src/stories/components/tabs/Tabs.stories.tsx +62 -0
- package/src/stories/components/tabs/TabsWrapper.stories.tsx +34 -0
- 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,
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks'
|
|
2
|
+
import { grey, primary } from '../theme/palette'
|
|
3
|
+
|
|
4
|
+
import Logo from '@/assets/Logo'
|
|
5
|
+
|
|
6
|
+
<Meta title='Welcome' />
|
|
7
|
+
|
|
8
|
+
<div style={{ padding: '32px', fontFamily: 'Public sans, sans-serif, Arial' }}>
|
|
9
|
+
<div style={{ maxWidth: '1000px', margin: '0 auto', backgroundColor: 'white', borderRadius: '16px', padding: '48px', boxShadow: `0 10px 40px rgba(0, 0, 0, 0.1)` }}>
|
|
10
|
+
{/* Header */}
|
|
11
|
+
<div style={{ textAlign: 'center', marginBottom: '40px', paddingBottom: '0' }}>
|
|
12
|
+
<div style={{ paddingBottom: '24px' }}>
|
|
13
|
+
<Logo />
|
|
14
|
+
</div>
|
|
15
|
+
<h1 style={{
|
|
16
|
+
margin: '0',
|
|
17
|
+
fontSize: '35px',
|
|
18
|
+
color: grey['900'],
|
|
19
|
+
fontWeight: '600'
|
|
20
|
+
}}>
|
|
21
|
+
### 👋 Welcome to RC SES React Components
|
|
22
|
+
</h1>
|
|
23
|
+
<p style={{ margin: '12px 0 0 0', fontSize: '15px', color: grey['600'], fontWeight: '500' }}>
|
|
24
|
+
A React 18 and Material-UI component library for RC SES applications
|
|
25
|
+
</p>
|
|
26
|
+
</div>
|
|
27
|
+
{/* Overview */}
|
|
28
|
+
<div style={{ marginBottom: '24px', padding: '24px', backgroundColor: grey['100'], borderRadius: '12px' }}>
|
|
29
|
+
<p style={{ color: primary['600'], lineHeight: '1.7', margin: '0 0 16px 0', fontSize: '15px', fontWeight: '500' }}>
|
|
30
|
+
This is a comprehensive component library for RC SES React applications. All components are built with React 18, TypeScript, and styled with Material-UI (MUI) v5.
|
|
31
|
+
</p>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
{/* Features */}
|
|
35
|
+
<div>
|
|
36
|
+
|
|
37
|
+
<h2 style={{ marginTop: '0', color: grey['900'], marginBottom: '20px', fontSize: '18px', fontWeight: '600' }}>Library Features:</h2>
|
|
38
|
+
|
|
39
|
+
<div>
|
|
40
|
+
<div style={{
|
|
41
|
+
display: 'grid',
|
|
42
|
+
gridTemplateColumns: '1fr 1fr 1fr 1fr',
|
|
43
|
+
gap: '20px'
|
|
44
|
+
}}>
|
|
45
|
+
{[
|
|
46
|
+
{ icon: '📖', title: 'Documentation', desc: 'Props, usage, and best practices', color: '#e3f2fd' },
|
|
47
|
+
{ icon: '🎮', title: 'Interactive Testing', desc: 'Play with props and see changes live', color: '#f3e5f5' },
|
|
48
|
+
{ icon: '💻', title: 'Code Samples', desc: 'Copy working code examples', color: '#e8f5e9' },
|
|
49
|
+
{ icon: '✨', title: 'Use Cases', desc: 'Real-world component examples', color: '#fff3e0' }
|
|
50
|
+
].map((feature, idx) => (
|
|
51
|
+
<div key={idx} style={{
|
|
52
|
+
padding: '1.25rem',
|
|
53
|
+
backgroundColor: feature.color,
|
|
54
|
+
borderRadius: '10px',
|
|
55
|
+
border: '1px solid #e0e0e0',
|
|
56
|
+
transition: 'all 0.3s ease',
|
|
57
|
+
cursor: 'pointer',
|
|
58
|
+
textAlign: 'center'
|
|
59
|
+
}}
|
|
60
|
+
onMouseEnter={(e) => {
|
|
61
|
+
e.currentTarget.style.transform = 'translateY(-4px)';
|
|
62
|
+
e.currentTarget.style.boxShadow = '0 8px 16px rgba(0, 0, 0, 0.12)';
|
|
63
|
+
}}
|
|
64
|
+
onMouseLeave={(e) => {
|
|
65
|
+
e.currentTarget.style.transform = 'translateY(0)';
|
|
66
|
+
e.currentTarget.style.boxShadow = 'none';
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
<div style={{ fontSize: '2rem', marginBottom: '0.75rem' }}>{feature.icon}</div>
|
|
70
|
+
<h4 style={{ margin: '0 0 0.5rem 0', color: '#333', fontSize: '0.95rem', fontWeight: '600' }}>{feature.title}</h4>
|
|
71
|
+
<p style={{ margin: '0', fontSize: '0.8rem', color: '#666', lineHeight: '1.4' }}>{feature.desc}</p>
|
|
72
|
+
</div>
|
|
73
|
+
))}
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
{/* Getting Started */}
|
|
79
|
+
<div style={{ marginTop: '2rem', padding: '1.5rem', backgroundColor: '#f0f8ff', borderRadius: '12px', borderLeft: '4px solid #0969da' }}>
|
|
80
|
+
<h3 style={{ marginTop: '0', color: '#0969da', marginBottom: '0.75rem', fontSize: '1rem', fontWeight: '600' }}>🚀 Getting Started:</h3>
|
|
81
|
+
<p style={{ color: '#555', lineHeight: '1.6', margin: '0', fontSize: '0.95rem' }}>
|
|
82
|
+
Use the sidebar navigation to explore components by category. Each component includes documentation, interactive examples, and code samples you can copy directly into your projects.
|
|
83
|
+
</p>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
|
|
3
|
+
import Logo from '@/assets/Logo'
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'assets/Logo',
|
|
7
|
+
component: Logo,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'centered',
|
|
10
|
+
},
|
|
11
|
+
} satisfies Meta<typeof Logo>
|
|
12
|
+
|
|
13
|
+
export default meta
|
|
14
|
+
type Story = StoryObj<typeof meta>
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
|
|
3
|
+
import RcSesButtonWithPopover from '@/components/common/Button/ButtonWithPopover'
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof RcSesButtonWithPopover> = {
|
|
6
|
+
title: 'components/actions/ButtonWithPopover',
|
|
7
|
+
component: RcSesButtonWithPopover,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
argTypes: {
|
|
10
|
+
popoverHeader: { control: 'text' },
|
|
11
|
+
popoverContent: { control: 'text' },
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default meta
|
|
16
|
+
type Story = StoryObj<typeof meta>
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
popoverHeader: 'Information',
|
|
21
|
+
popoverContent: 'Hover or click the question icon to see this popover content',
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const WithCustomContent: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
popoverHeader: 'Help',
|
|
28
|
+
popoverContent: 'This is custom content inside the popover',
|
|
29
|
+
},
|
|
30
|
+
render: (args) => (
|
|
31
|
+
<RcSesButtonWithPopover {...args}>Custom Button</RcSesButtonWithPopover>
|
|
32
|
+
),
|
|
33
|
+
}
|