odaptos_design_system 2.0.95 → 2.0.97
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/RatingScale/RatingScale.d.ts +0 -1
- package/dist/Organisms/SingleSelect/SingleSelectWithoutFilter.d.ts +31 -0
- package/dist/Organisms/TimePicker/TimePicker.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/odaptos_design_system.cjs.development.js +235 -10
- 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 +235 -11
- package/dist/odaptos_design_system.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/Organisms/DatePicker/DatePicker.tsx +2 -1
- package/src/Organisms/MultiSelect/MultiSelect.tsx +1 -1
- package/src/Organisms/MultiSelect/MultiSelectWithCategories.tsx +1 -1
- package/src/Organisms/MultiSelect/MultiSelectWithoutFilter.tsx +1 -1
- package/src/Organisms/RatingScale/RatingScale.tsx +0 -1
- package/src/Organisms/SingleSelect/SingleSelect.tsx +1 -1
- package/src/Organisms/SingleSelect/SingleSelectWithoutFilter.tsx +284 -0
- package/src/Organisms/TimePicker/TimePicker.tsx +3 -1
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -162,6 +162,7 @@ export const DatePicker: React.FC<DatePickerProps> = ({
|
|
|
162
162
|
maxDate,
|
|
163
163
|
minDate,
|
|
164
164
|
required,
|
|
165
|
+
error,
|
|
165
166
|
errorText,
|
|
166
167
|
helperText,
|
|
167
168
|
views = ['day', 'month', 'year'],
|
|
@@ -244,7 +245,7 @@ export const DatePicker: React.FC<DatePickerProps> = ({
|
|
|
244
245
|
}
|
|
245
246
|
}}
|
|
246
247
|
/>
|
|
247
|
-
{errorText && (
|
|
248
|
+
{error && errorText && (
|
|
248
249
|
<Text
|
|
249
250
|
size="xs"
|
|
250
251
|
color="#F54C4C"
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
|
|
2
|
+
import { TextField } from '@mui/material';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import React, { useEffect, useState } from 'react';
|
|
5
|
+
import {
|
|
6
|
+
Text,
|
|
7
|
+
TextForButton,
|
|
8
|
+
ArrowLineDownIcon,
|
|
9
|
+
RemoveCircledIcon,
|
|
10
|
+
colors,
|
|
11
|
+
} from '../..';
|
|
12
|
+
import styles from './SingleSelect.modules.scss';
|
|
13
|
+
|
|
14
|
+
interface OptionType {
|
|
15
|
+
label: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const filter = createFilterOptions<OptionType>();
|
|
20
|
+
|
|
21
|
+
const CssTextField = styled(TextField)({
|
|
22
|
+
'& .MuiInputBase-input': {
|
|
23
|
+
color: '#26292E',
|
|
24
|
+
fontFamily: `'Open Sans' !important`,
|
|
25
|
+
fontSize: '1rem',
|
|
26
|
+
},
|
|
27
|
+
'& .MuiInputBase-input.Mui-disabled': {
|
|
28
|
+
color: '#26292E',
|
|
29
|
+
fontFamily: `'Open Sans' !important`,
|
|
30
|
+
fontSize: '1rem',
|
|
31
|
+
},
|
|
32
|
+
'& .MuiInputBase-input.MuiOutlinedInput-input.Mui-disabled': {
|
|
33
|
+
WebkitTextFillColor: colors.neutral_600,
|
|
34
|
+
},
|
|
35
|
+
'& .Mui-error': {
|
|
36
|
+
color: '#26292E',
|
|
37
|
+
},
|
|
38
|
+
'& .MuiFormHelperText-root': {
|
|
39
|
+
color: '#F54C4C',
|
|
40
|
+
},
|
|
41
|
+
'& .MuiFormLabel-asterisk': {
|
|
42
|
+
color: '#F54C4C',
|
|
43
|
+
},
|
|
44
|
+
'& .MuiOutlinedInput-root.Mui-disabled': {
|
|
45
|
+
cursor: 'not-allowed',
|
|
46
|
+
color: '#26292E',
|
|
47
|
+
fieldset: {
|
|
48
|
+
borderColor: '#BCBDBE',
|
|
49
|
+
},
|
|
50
|
+
'&:hover fieldset': {
|
|
51
|
+
borderColor: '#BCBDBE',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
'& label': {
|
|
55
|
+
color: '#26292E',
|
|
56
|
+
fontFamily: `'Open Sans' !important`,
|
|
57
|
+
fontSize: '1rem',
|
|
58
|
+
},
|
|
59
|
+
'& label.Mui-disabled.Mui-error': {
|
|
60
|
+
color: '#26292E',
|
|
61
|
+
opacity: 0.5,
|
|
62
|
+
fontFamily: `'Open Sans' !important`,
|
|
63
|
+
fontSize: '1rem',
|
|
64
|
+
},
|
|
65
|
+
'& label.Mui-focused': {
|
|
66
|
+
color: '#26292E',
|
|
67
|
+
fontFamily: `'Open Sans' !important`,
|
|
68
|
+
fontSize: '1rem',
|
|
69
|
+
backgroundColor: 'transparent',
|
|
70
|
+
marginRight: 5,
|
|
71
|
+
paddingRight: 5,
|
|
72
|
+
},
|
|
73
|
+
'& .MuiOutlinedInput-root': {
|
|
74
|
+
fontFamily: `'Open Sans' !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
|
+
height: '99%',
|
|
98
|
+
marginTop: '-0.20rem',
|
|
99
|
+
'& .MuiButtonBase-root': {
|
|
100
|
+
height: '99%',
|
|
101
|
+
'&:hover': {
|
|
102
|
+
background: 'transparent',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
interface SingleSelectWithoutFilterProps {
|
|
109
|
+
label: string;
|
|
110
|
+
placeholder?: string;
|
|
111
|
+
name?: string;
|
|
112
|
+
className?: string;
|
|
113
|
+
id?: string;
|
|
114
|
+
inputId?: string;
|
|
115
|
+
topLabel?: string;
|
|
116
|
+
topLabelWeight?: 'semi-bold' | 'bold' | 'regular';
|
|
117
|
+
topLabelSize?: 'xs' | 'sm' | 'base' | 'lg' | 'xl' | 'xxl' | 'xxxl' | 'xxxxl';
|
|
118
|
+
disabled?: boolean;
|
|
119
|
+
required?: boolean;
|
|
120
|
+
error?: boolean;
|
|
121
|
+
helperText?: string;
|
|
122
|
+
errorText?: string;
|
|
123
|
+
canAddNewOption?: boolean;
|
|
124
|
+
defaultValue: any;
|
|
125
|
+
options: any[];
|
|
126
|
+
onChange: (value: any) => void;
|
|
127
|
+
onBlur?: () => void;
|
|
128
|
+
isLoading?: boolean;
|
|
129
|
+
fetchOptions?: (search: string) => void;
|
|
130
|
+
searchTerm: string;
|
|
131
|
+
setSearchTerm: (value: string) => void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Use this component for single selection !!
|
|
136
|
+
*/
|
|
137
|
+
export const SingleSelectWithoutFilter = ({
|
|
138
|
+
options,
|
|
139
|
+
label,
|
|
140
|
+
placeholder,
|
|
141
|
+
name,
|
|
142
|
+
className,
|
|
143
|
+
onChange,
|
|
144
|
+
disabled,
|
|
145
|
+
defaultValue,
|
|
146
|
+
topLabel,
|
|
147
|
+
topLabelWeight,
|
|
148
|
+
topLabelSize,
|
|
149
|
+
id,
|
|
150
|
+
inputId,
|
|
151
|
+
required,
|
|
152
|
+
error,
|
|
153
|
+
helperText,
|
|
154
|
+
errorText,
|
|
155
|
+
canAddNewOption,
|
|
156
|
+
onBlur,
|
|
157
|
+
fetchOptions,
|
|
158
|
+
isLoading,
|
|
159
|
+
searchTerm,
|
|
160
|
+
setSearchTerm,
|
|
161
|
+
...props
|
|
162
|
+
}: SingleSelectWithoutFilterProps) => {
|
|
163
|
+
const [value, setValue] = useState(
|
|
164
|
+
defaultValue === undefined ? null : defaultValue
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
setValue(defaultValue === undefined ? null : defaultValue);
|
|
169
|
+
}, [defaultValue]);
|
|
170
|
+
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
// Call API only if searchTerm and fetchOptions are defined
|
|
173
|
+
if (searchTerm.length >= 3 && fetchOptions) {
|
|
174
|
+
fetchOptions(searchTerm);
|
|
175
|
+
}
|
|
176
|
+
}, [searchTerm]);
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<div
|
|
180
|
+
className={`${className && className}`}
|
|
181
|
+
style={{ width: '100%' }}
|
|
182
|
+
id={id}
|
|
183
|
+
>
|
|
184
|
+
{topLabel && (
|
|
185
|
+
<Text
|
|
186
|
+
text={`${topLabel ? topLabel : ''}`}
|
|
187
|
+
weight={topLabelWeight || 'bold'}
|
|
188
|
+
size={topLabelSize || 'base'}
|
|
189
|
+
className={styles.input_top_label}
|
|
190
|
+
required={required}
|
|
191
|
+
/>
|
|
192
|
+
)}
|
|
193
|
+
|
|
194
|
+
<Autocomplete
|
|
195
|
+
id={inputId}
|
|
196
|
+
value={value}
|
|
197
|
+
onInputChange={(_event, value) => setSearchTerm(value)}
|
|
198
|
+
onChange={(_event, newValue) => {
|
|
199
|
+
const e = {
|
|
200
|
+
target: { name: name, value: newValue },
|
|
201
|
+
};
|
|
202
|
+
setValue(newValue);
|
|
203
|
+
onChange(e);
|
|
204
|
+
}}
|
|
205
|
+
options={options}
|
|
206
|
+
multiple={false}
|
|
207
|
+
autoComplete={options.length > 10}
|
|
208
|
+
size="small"
|
|
209
|
+
fullWidth
|
|
210
|
+
disabled={disabled}
|
|
211
|
+
getOptionLabel={(option) => {
|
|
212
|
+
return option.label;
|
|
213
|
+
}}
|
|
214
|
+
isOptionEqualToValue={(option, value) => {
|
|
215
|
+
if (value._id && option._id) return option._id === value._id;
|
|
216
|
+
else if (value && value !== '') return option.value === value.value;
|
|
217
|
+
else return false;
|
|
218
|
+
}}
|
|
219
|
+
renderInput={(params) => (
|
|
220
|
+
<CssTextField
|
|
221
|
+
{...params}
|
|
222
|
+
variant="outlined"
|
|
223
|
+
fullWidth
|
|
224
|
+
label={`${label && topLabel === undefined ? label : ''}`}
|
|
225
|
+
placeholder={placeholder}
|
|
226
|
+
size="small"
|
|
227
|
+
required={required}
|
|
228
|
+
error={error}
|
|
229
|
+
onBlur={onBlur}
|
|
230
|
+
/>
|
|
231
|
+
)}
|
|
232
|
+
clearIcon={
|
|
233
|
+
<RemoveCircledIcon fill="black" className={`${styles.icon}`} />
|
|
234
|
+
}
|
|
235
|
+
popupIcon={
|
|
236
|
+
<ArrowLineDownIcon fill="black" className={`${styles.icon}`} />
|
|
237
|
+
}
|
|
238
|
+
className={`${styles.newAutocomplete}`}
|
|
239
|
+
renderOption={(props, option) => {
|
|
240
|
+
return (
|
|
241
|
+
<li {...props} key={option.value} id={option.value}>
|
|
242
|
+
<TextForButton text={option.label} size="sm" />
|
|
243
|
+
</li>
|
|
244
|
+
);
|
|
245
|
+
}}
|
|
246
|
+
filterOptions={(options, params) => {
|
|
247
|
+
const filtered = filter(options, params);
|
|
248
|
+
|
|
249
|
+
const { inputValue } = params;
|
|
250
|
+
// Suggest the creation of a new value
|
|
251
|
+
const isExisting = options.some(
|
|
252
|
+
(option) => inputValue === option.title
|
|
253
|
+
);
|
|
254
|
+
if (inputValue !== '' && !isExisting) {
|
|
255
|
+
if (canAddNewOption)
|
|
256
|
+
filtered.push({
|
|
257
|
+
value: inputValue,
|
|
258
|
+
label: inputValue,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
return filtered;
|
|
262
|
+
}}
|
|
263
|
+
{...props}
|
|
264
|
+
/>
|
|
265
|
+
{error && errorText && (
|
|
266
|
+
<Text
|
|
267
|
+
size="xs"
|
|
268
|
+
color="#F54C4C"
|
|
269
|
+
italic
|
|
270
|
+
text={errorText}
|
|
271
|
+
className={styles.text_below}
|
|
272
|
+
/>
|
|
273
|
+
)}
|
|
274
|
+
{helperText && (
|
|
275
|
+
<Text
|
|
276
|
+
size="xs"
|
|
277
|
+
italic
|
|
278
|
+
text={helperText}
|
|
279
|
+
className={styles.text_below}
|
|
280
|
+
/>
|
|
281
|
+
)}
|
|
282
|
+
</div>
|
|
283
|
+
);
|
|
284
|
+
};
|
|
@@ -135,6 +135,7 @@ export interface TimePickerProps {
|
|
|
135
135
|
disabled?: boolean;
|
|
136
136
|
locale?: string | 'en' | 'en-gb' | 'fr' | 'it' | 'de' | 'es';
|
|
137
137
|
required?: boolean;
|
|
138
|
+
error?: boolean;
|
|
138
139
|
errorText?: string;
|
|
139
140
|
helperText?: string;
|
|
140
141
|
onChange?: (date: Date | Dayjs | null) => void;
|
|
@@ -164,6 +165,7 @@ export const TimePicker: React.FC<TimePickerProps> = ({
|
|
|
164
165
|
disabled,
|
|
165
166
|
locale = 'en',
|
|
166
167
|
required,
|
|
168
|
+
error,
|
|
167
169
|
errorText,
|
|
168
170
|
helperText,
|
|
169
171
|
onChange,
|
|
@@ -218,7 +220,7 @@ export const TimePicker: React.FC<TimePickerProps> = ({
|
|
|
218
220
|
disabled={disabled}
|
|
219
221
|
onChange={onChange}
|
|
220
222
|
/>
|
|
221
|
-
{errorText && (
|
|
223
|
+
{error && errorText && (
|
|
222
224
|
<Text
|
|
223
225
|
size="xs"
|
|
224
226
|
color="#F54C4C"
|
package/src/index.ts
CHANGED
|
@@ -47,6 +47,7 @@ export * from './Atoms/Radio/Radio';
|
|
|
47
47
|
export * from './Organisms/RatingScale/RatingScale';
|
|
48
48
|
export * from './Atoms/Search/Search';
|
|
49
49
|
export * from './Organisms/SingleSelect/SingleSelect';
|
|
50
|
+
export * from './Organisms/SingleSelect/SingleSelectWithoutFilter';
|
|
50
51
|
export * from './Molecules/StarRating/StarRating';
|
|
51
52
|
export * from './Atoms/Switch/Switch';
|
|
52
53
|
export * from './Organisms/Table/TableFooter';
|