odaptos_design_system 2.0.73 → 2.0.76
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/Organisms/MultiSelect/MultiSelectWithoutFilter.d.ts +31 -0
- package/dist/index.d.ts +1 -0
- package/dist/odaptos_design_system.cjs.development.js +528 -287
- package/dist/odaptos_design_system.cjs.development.js.map +1 -1
- package/dist/odaptos_design_system.cjs.production.min.js +1 -1
- package/dist/odaptos_design_system.cjs.production.min.js.map +1 -1
- package/dist/odaptos_design_system.esm.js +518 -278
- package/dist/odaptos_design_system.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/Organisms/MultiSelect/MultiSelectWithoutFilter.modules.scss +83 -0
- package/src/Organisms/MultiSelect/MultiSelectWithoutFilter.tsx +300 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
.newAutocomplete {
|
|
2
|
+
width: 100%;
|
|
3
|
+
min-width: 16rem;
|
|
4
|
+
|
|
5
|
+
span {
|
|
6
|
+
font-family: 'Open Sans';
|
|
7
|
+
font-style: normal;
|
|
8
|
+
font-weight: 400;
|
|
9
|
+
font-size: 0.75rem;
|
|
10
|
+
line-height: 1.3;
|
|
11
|
+
letter-spacing: 0.03em;
|
|
12
|
+
text-align: left;
|
|
13
|
+
margin: unset;
|
|
14
|
+
}
|
|
15
|
+
label {
|
|
16
|
+
font-family: 'Open Sans';
|
|
17
|
+
font-style: normal;
|
|
18
|
+
font-weight: 400;
|
|
19
|
+
font-size: 0.75rem;
|
|
20
|
+
line-height: 1.3;
|
|
21
|
+
letter-spacing: 0.03em;
|
|
22
|
+
text-align: left;
|
|
23
|
+
margin: unset;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.MuiAutocomplete-endAdornment {
|
|
27
|
+
svg {
|
|
28
|
+
width: 1rem;
|
|
29
|
+
height: 1rem;
|
|
30
|
+
}
|
|
31
|
+
display: flex;
|
|
32
|
+
gap: 0.5rem;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.tags_container {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-wrap: wrap;
|
|
38
|
+
gap: 0.5rem;
|
|
39
|
+
padding: 0 0.25rem;
|
|
40
|
+
span {
|
|
41
|
+
font-size: 0.75rem;
|
|
42
|
+
}
|
|
43
|
+
.customBadge {
|
|
44
|
+
p {
|
|
45
|
+
text-overflow: ellipsis;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
white-space: nowrap;
|
|
48
|
+
width: 85%;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.MuiOutlinedInput-root.MuiInputBase-root.MuiInputBase-formControl {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: row;
|
|
58
|
+
align-items: center;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.no_scrollbar {
|
|
62
|
+
/* Hide scrollbar for Chrome, Safari and Opera */
|
|
63
|
+
&::-webkit-scrollbar {
|
|
64
|
+
display: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
68
|
+
scrollbar-width: none; /* Firefox */
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.input_top_label {
|
|
72
|
+
margin-bottom: 0.625rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.text_below {
|
|
76
|
+
margin: 0.25rem 0.5rem 0.25rem 0.75rem;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.icon {
|
|
80
|
+
width: 1rem !important;
|
|
81
|
+
height: 1rem !important;
|
|
82
|
+
margin-left: 0.25rem;
|
|
83
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { Autocomplete, TextField, CircularProgress } from '@mui/material';
|
|
3
|
+
import {
|
|
4
|
+
Text,
|
|
5
|
+
Badge,
|
|
6
|
+
RemoveCircledIcon,
|
|
7
|
+
colors,
|
|
8
|
+
Checkbox,
|
|
9
|
+
ArrowLineDownIcon,
|
|
10
|
+
TextForButton,
|
|
11
|
+
} from '../../index';
|
|
12
|
+
import styles from './MultiSelectWithoutFilter.modules.scss';
|
|
13
|
+
import { styled } from '@mui/material/styles';
|
|
14
|
+
|
|
15
|
+
interface Option {
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const CssTextField = styled(TextField)({
|
|
21
|
+
'& .MuiInputBase-input': {
|
|
22
|
+
color: '#26292E',
|
|
23
|
+
fontFamily: `'Open Sans' !important`,
|
|
24
|
+
fontSize: '1rem',
|
|
25
|
+
},
|
|
26
|
+
'& .MuiInputBase-input.Mui-disabled': {
|
|
27
|
+
color: '#26292E',
|
|
28
|
+
fontFamily: `'Open Sans' !important`,
|
|
29
|
+
fontSize: '1rem',
|
|
30
|
+
},
|
|
31
|
+
'& .MuiInputBase-input.MuiOutlinedInput-input.Mui-disabled': {
|
|
32
|
+
WebkitTextFillColor: colors.neutral_600,
|
|
33
|
+
},
|
|
34
|
+
'& .Mui-error': {
|
|
35
|
+
color: '#26292E',
|
|
36
|
+
},
|
|
37
|
+
'& .MuiFormHelperText-root': {
|
|
38
|
+
color: '#F54C4C',
|
|
39
|
+
},
|
|
40
|
+
'& .MuiFormLabel-asterisk': {
|
|
41
|
+
color: '#F54C4C',
|
|
42
|
+
},
|
|
43
|
+
'& .MuiOutlinedInput-root.Mui-disabled': {
|
|
44
|
+
cursor: 'not-allowed',
|
|
45
|
+
color: '#26292E',
|
|
46
|
+
fieldset: {
|
|
47
|
+
borderColor: '#BCBDBE',
|
|
48
|
+
},
|
|
49
|
+
'&:hover fieldset': {
|
|
50
|
+
borderColor: '#BCBDBE',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
'& label': {
|
|
54
|
+
color: '#26292E',
|
|
55
|
+
fontFamily: `'Open Sans' !important`,
|
|
56
|
+
fontSize: '1rem',
|
|
57
|
+
},
|
|
58
|
+
'& label.Mui-disabled.Mui-error': {
|
|
59
|
+
color: '#26292E',
|
|
60
|
+
opacity: 0.5,
|
|
61
|
+
fontFamily: `'Open Sans' !important`,
|
|
62
|
+
fontSize: '1rem',
|
|
63
|
+
},
|
|
64
|
+
'& label.Mui-focused': {
|
|
65
|
+
color: '#26292E',
|
|
66
|
+
fontFamily: `'Open Sans' !important`,
|
|
67
|
+
fontSize: '1rem',
|
|
68
|
+
backgroundColor: 'transparent',
|
|
69
|
+
marginRight: 5,
|
|
70
|
+
paddingRight: 5,
|
|
71
|
+
},
|
|
72
|
+
'& .MuiOutlinedInput-root': {
|
|
73
|
+
fontFamily: `'Open Sans' !important`,
|
|
74
|
+
paddingTop: '9px !important',
|
|
75
|
+
'& fieldset': {
|
|
76
|
+
borderColor: '#96989A',
|
|
77
|
+
},
|
|
78
|
+
'& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button': {
|
|
79
|
+
display: 'none',
|
|
80
|
+
},
|
|
81
|
+
'& input[type=number]': {
|
|
82
|
+
MozAppearance: 'textfield',
|
|
83
|
+
},
|
|
84
|
+
'&:hover fieldset': {
|
|
85
|
+
borderColor: '#0077FF',
|
|
86
|
+
},
|
|
87
|
+
'&.Mui-focused fieldset': {
|
|
88
|
+
borderColor: '#0077FF',
|
|
89
|
+
},
|
|
90
|
+
'&.Mui-error fieldset': {
|
|
91
|
+
borderColor: '#F54C4C',
|
|
92
|
+
},
|
|
93
|
+
'&.Mui-disabled .Mui-focused fieldset': {
|
|
94
|
+
borderColor: 'rgba(0, 119, 255, 0.5)',
|
|
95
|
+
},
|
|
96
|
+
'& .MuiAutocomplete-endAdornment': {
|
|
97
|
+
'& .MuiButtonBase-root': {
|
|
98
|
+
height: '99%',
|
|
99
|
+
'&:hover': {
|
|
100
|
+
background: 'transparent',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
MuiInput: {
|
|
105
|
+
input: {
|
|
106
|
+
'&::placeholder': {
|
|
107
|
+
fontSize: '1rem',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
interface MultiSelectWithoutFilterProps {
|
|
115
|
+
label: string;
|
|
116
|
+
placeholder?: string;
|
|
117
|
+
name?: string;
|
|
118
|
+
className?: string;
|
|
119
|
+
id?: string;
|
|
120
|
+
inputId?: string;
|
|
121
|
+
topLabel?: string;
|
|
122
|
+
topLabelWeight?: 'semi-bold' | 'bold' | 'regular';
|
|
123
|
+
topLabelSize?: 'xs' | 'sm' | 'base' | 'lg' | 'xl' | 'xxl' | 'xxxl' | 'xxxxl';
|
|
124
|
+
disabled?: boolean;
|
|
125
|
+
required?: boolean;
|
|
126
|
+
defaultValue: any[];
|
|
127
|
+
options: any[];
|
|
128
|
+
error?: boolean;
|
|
129
|
+
helperText?: string;
|
|
130
|
+
errorText?: string;
|
|
131
|
+
canAddNewOption?: boolean;
|
|
132
|
+
disableCloseOnSelect?: boolean;
|
|
133
|
+
onChange: (value: any) => void;
|
|
134
|
+
deleteOption: (value: any) => void;
|
|
135
|
+
limitTags?: number;
|
|
136
|
+
onBlur?: () => void;
|
|
137
|
+
isLoading?: boolean;
|
|
138
|
+
fetchOptions?: (search: string) => void;
|
|
139
|
+
searchTerm: string;
|
|
140
|
+
setSearchTerm: (search: string) => void;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const MultiSelectWithoutFilter = ({
|
|
144
|
+
options,
|
|
145
|
+
fetchOptions,
|
|
146
|
+
isLoading,
|
|
147
|
+
required,
|
|
148
|
+
disabled,
|
|
149
|
+
label,
|
|
150
|
+
placeholder,
|
|
151
|
+
name,
|
|
152
|
+
className,
|
|
153
|
+
id,
|
|
154
|
+
inputId,
|
|
155
|
+
topLabel,
|
|
156
|
+
topLabelWeight,
|
|
157
|
+
topLabelSize,
|
|
158
|
+
defaultValue,
|
|
159
|
+
error,
|
|
160
|
+
helperText,
|
|
161
|
+
errorText,
|
|
162
|
+
disableCloseOnSelect,
|
|
163
|
+
onChange,
|
|
164
|
+
deleteOption,
|
|
165
|
+
limitTags,
|
|
166
|
+
onBlur,
|
|
167
|
+
searchTerm,
|
|
168
|
+
setSearchTerm,
|
|
169
|
+
...props
|
|
170
|
+
}: MultiSelectWithoutFilterProps) => {
|
|
171
|
+
const [selectedOptions, setSelectedOptions] = useState<Option[]>([]);
|
|
172
|
+
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
// Call API only if searchTerm and fetchOptions are defined
|
|
175
|
+
if (searchTerm.length >= 3 && fetchOptions) {
|
|
176
|
+
fetchOptions(searchTerm);
|
|
177
|
+
}
|
|
178
|
+
}, [searchTerm]);
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<div className={`${className}`} style={{ width: '100%' }} id={id}>
|
|
182
|
+
{topLabel && (
|
|
183
|
+
<Text
|
|
184
|
+
text={`${topLabel ? topLabel : ''}`}
|
|
185
|
+
weight={topLabelWeight || 'bold'}
|
|
186
|
+
size={topLabelSize || 'base'}
|
|
187
|
+
className={styles.input_top_label}
|
|
188
|
+
required={required}
|
|
189
|
+
/>
|
|
190
|
+
)}
|
|
191
|
+
|
|
192
|
+
<Autocomplete
|
|
193
|
+
id={inputId}
|
|
194
|
+
multiple
|
|
195
|
+
options={options}
|
|
196
|
+
getOptionLabel={(option: Option) => {
|
|
197
|
+
return option.label;
|
|
198
|
+
}}
|
|
199
|
+
value={selectedOptions}
|
|
200
|
+
onChange={(_event, newValue) => setSelectedOptions(newValue)}
|
|
201
|
+
filterOptions={(x) => x} // Disable internal filter, we use an API search
|
|
202
|
+
onInputChange={(_event, value) => setSearchTerm(value)}
|
|
203
|
+
loading={isLoading}
|
|
204
|
+
size="small"
|
|
205
|
+
fullWidth
|
|
206
|
+
className={`${styles.newAutocomplete}`}
|
|
207
|
+
disableCloseOnSelect={disableCloseOnSelect}
|
|
208
|
+
disabled={disabled}
|
|
209
|
+
isOptionEqualToValue={(option: Option, value: Option) => {
|
|
210
|
+
return option.value === value.value;
|
|
211
|
+
}}
|
|
212
|
+
limitTags={limitTags}
|
|
213
|
+
renderInput={(params) => (
|
|
214
|
+
<CssTextField
|
|
215
|
+
{...params}
|
|
216
|
+
variant="outlined"
|
|
217
|
+
label={`${label && topLabel === undefined ? label : ''}`}
|
|
218
|
+
placeholder={placeholder}
|
|
219
|
+
size="small"
|
|
220
|
+
required={required}
|
|
221
|
+
name={name}
|
|
222
|
+
error={error}
|
|
223
|
+
onBlur={onBlur}
|
|
224
|
+
InputProps={{
|
|
225
|
+
...params.InputProps,
|
|
226
|
+
endAdornment: (
|
|
227
|
+
<>
|
|
228
|
+
{isLoading ? (
|
|
229
|
+
<CircularProgress color="inherit" size={20} />
|
|
230
|
+
) : null}
|
|
231
|
+
{params.InputProps.endAdornment}
|
|
232
|
+
</>
|
|
233
|
+
),
|
|
234
|
+
}}
|
|
235
|
+
/>
|
|
236
|
+
)}
|
|
237
|
+
renderTags={(value) => {
|
|
238
|
+
return (
|
|
239
|
+
<div className={`${styles.tags_container} ${styles.no_scrollbar}`}>
|
|
240
|
+
{value.map((option, index) => (
|
|
241
|
+
<Badge
|
|
242
|
+
text={option.label}
|
|
243
|
+
status="idle"
|
|
244
|
+
size="base"
|
|
245
|
+
key={`chipt-option-${index}`}
|
|
246
|
+
className={styles.customBadge}
|
|
247
|
+
canBeRemoved
|
|
248
|
+
iconRight={
|
|
249
|
+
<RemoveCircledIcon
|
|
250
|
+
fill={colors.neutral_700}
|
|
251
|
+
style={{ cursor: 'pointer !important' }}
|
|
252
|
+
onClick={() => deleteOption(option)}
|
|
253
|
+
/>
|
|
254
|
+
}
|
|
255
|
+
/>
|
|
256
|
+
))}
|
|
257
|
+
</div>
|
|
258
|
+
);
|
|
259
|
+
}}
|
|
260
|
+
renderOption={(props, option, { selected }) => {
|
|
261
|
+
return (
|
|
262
|
+
<li
|
|
263
|
+
{...props}
|
|
264
|
+
id={option.value}
|
|
265
|
+
key={`${props.id}`}
|
|
266
|
+
style={{ gap: '0.5rem' }}
|
|
267
|
+
>
|
|
268
|
+
<Checkbox checked={selected} onChange={() => null} />
|
|
269
|
+
<TextForButton text={option.label} size="sm" />
|
|
270
|
+
</li>
|
|
271
|
+
);
|
|
272
|
+
}}
|
|
273
|
+
clearIcon={
|
|
274
|
+
<RemoveCircledIcon fill="black" className={`${styles.icon}`} />
|
|
275
|
+
}
|
|
276
|
+
popupIcon={
|
|
277
|
+
<ArrowLineDownIcon fill="black" className={`${styles.icon}`} />
|
|
278
|
+
}
|
|
279
|
+
{...props}
|
|
280
|
+
/>
|
|
281
|
+
{errorText && (
|
|
282
|
+
<Text
|
|
283
|
+
size="xs"
|
|
284
|
+
color="#F54C4C"
|
|
285
|
+
italic
|
|
286
|
+
text={errorText}
|
|
287
|
+
className={styles.text_below}
|
|
288
|
+
/>
|
|
289
|
+
)}
|
|
290
|
+
{helperText && (
|
|
291
|
+
<Text
|
|
292
|
+
size="xs"
|
|
293
|
+
italic
|
|
294
|
+
text={helperText}
|
|
295
|
+
className={styles.text_below}
|
|
296
|
+
/>
|
|
297
|
+
)}
|
|
298
|
+
</div>
|
|
299
|
+
);
|
|
300
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -34,6 +34,7 @@ export * from './Molecules/LogoSlider/LogoSlider';
|
|
|
34
34
|
export * from './Organisms/Modal/Modal';
|
|
35
35
|
export * from './Organisms/MultiSelect/MultiSelect';
|
|
36
36
|
export * from './Organisms/MultiSelect/MultiSelectWithCategories';
|
|
37
|
+
export * from './Organisms/MultiSelect/MultiSelectWithoutFilter';
|
|
37
38
|
export * from './Molecules/Notifications/Banner';
|
|
38
39
|
export * from './Molecules/Notifications/NotificationIcon';
|
|
39
40
|
export * from './Molecules/Notifications/Toast';
|