@arquimedes.co/eureka-forms 3.0.7-refactor → 3.0.10-refactor
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/FormSteps/AYFStepMapper.js +1 -1
- package/dist/FormSteps/DatePickerStep/DatePickerStep.d.ts +1 -1
- package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +3 -1
- package/dist/FormSteps/PhoneInputStep/MaterialTextInputStep/MaterialPhoneInputStep.js +1 -1
- package/dist/FormSteps/StepHooks.js +1 -1
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +1 -1
- package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +1 -1
- package/dist/FormSteps/TimePickerStep/MaterialTimePickerStep/MaterialTimePickerStep.js +1 -1
- package/dist/FormSteps/Utils/@StepFiller/StepFiller.d.ts +0 -1
- package/dist/FormSteps/Utils/@StepFiller/StepFiller.js +2 -2
- package/dist/FormSteps/Utils/@StepFiller/StepFillerContext.d.ts +1 -0
- package/dist/FormSteps/Utils/@StepFiller/StepFillerContext.js +2 -0
- package/dist/Shared/ErkDatePicker/ErkDatePicker.d.ts +2 -0
- package/dist/Shared/ErkDatePicker/ErkDatePicker.js +12 -9
- package/dist/Shared/ErkMenuItem.d.ts +4 -0
- package/dist/Shared/ErkMenuItem.js +18 -0
- package/dist/Shared/ErkPhoneInput/EkrPhoneInput.d.ts +1 -1
- package/dist/Shared/ErkPhoneInput/EkrPhoneInput.js +13 -4
- package/dist/Shared/ErkSelect/ErkSelect.d.ts +21 -8
- package/dist/Shared/ErkSelect/ErkSelect.js +48 -8
- package/dist/Shared/ErkSelect/ErkSelect.stories.js +4 -4
- package/dist/Shared/ErkSmartSelect/ErkSmartSelect.js +5 -4
- package/dist/Shared/ErkTextField/ErkTextField.d.ts +12 -5
- package/dist/Shared/ErkTextField/ErkTextField.js +45 -15
- package/dist/Shared/ErkTimePicker/ErkTimePicker.d.ts +2 -1
- package/dist/Shared/ErkTimePicker/ErkTimePicker.js +8 -32
- package/dist/Shared/Toggle/Toggle.d.ts +5 -4
- package/dist/Shared/Toggle/Toggle.js +26 -6
- package/package.json +5 -1
|
@@ -76,7 +76,7 @@ function AYFStepMapper(props) {
|
|
|
76
76
|
message: 'No se permiten espacios',
|
|
77
77
|
}, maxLength: 30, IconComponent: () => _jsx(FileIcon, { style: { fontSize: 23 } }) }));
|
|
78
78
|
case AYFFormStepTypes.AYF_CUT_OFF_DATE:
|
|
79
|
-
return _jsx(DatePickerStep, { ...props, step: props.step, defaultValue: new Date() });
|
|
79
|
+
return _jsx(DatePickerStep, { ...props, step: props.step, defaultValue: new Date().toString() });
|
|
80
80
|
case AYFFormStepTypes.AYF_ICA_CITY:
|
|
81
81
|
return (_jsx(SmartSelectStep, { ...props, step: props.step, getOptions: getCiudadesOptions, getOptionSelected: (option, value) => option === value, getValueString: (value) => value, IconComponent: () => _jsx(LocationIcon, {}) }));
|
|
82
82
|
default:
|
|
@@ -4,7 +4,7 @@ export interface DatePickerStepProps extends StepProps {
|
|
|
4
4
|
/** The DatePickerStep to display */
|
|
5
5
|
step: DatePicker;
|
|
6
6
|
/** Default value to display */
|
|
7
|
-
defaultValue?:
|
|
7
|
+
defaultValue?: string | null;
|
|
8
8
|
}
|
|
9
9
|
declare function DatePickerStep(props: DatePickerStepProps): JSX.Element;
|
|
10
10
|
export default DatePickerStep;
|
|
@@ -3,6 +3,7 @@ import ErkDatePicker from '../../../Shared/ErkDatePicker/ErkDatePicker';
|
|
|
3
3
|
import { useAppSelector } from '../../../hooks';
|
|
4
4
|
import { useFormStep } from '../../StepHooks';
|
|
5
5
|
import MaterialInputContainer from '../../Utils/MaterialInputContainer/MaterialInputContainer';
|
|
6
|
+
import { useCallback } from 'react';
|
|
6
7
|
function DatePickerStep({ step, editable, defaultValue }) {
|
|
7
8
|
const postview = useAppSelector((state) => state.global.postview);
|
|
8
9
|
const { ref, value, onChange, error, field } = useFormStep(step, {
|
|
@@ -11,6 +12,7 @@ function DatePickerStep({ step, editable, defaultValue }) {
|
|
|
11
12
|
required: step.required ? 'Este campo es obligatorio' : undefined,
|
|
12
13
|
},
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
+
const handleChange = useCallback((date) => onChange(date?.toISOString() ?? null), [onChange]);
|
|
16
|
+
return (_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkDatePicker, { ...field, value: value ? new Date(value) : null, inputRef: ref, error: !!error, labelMargin: 0, label: step.label, onChange: handleChange, pickTime: step.pickTime, required: step.required, readOnly: !editable || postview, helperText: error?.message ?? step.description }) }));
|
|
15
17
|
}
|
|
16
18
|
export default DatePickerStep;
|
|
@@ -28,6 +28,6 @@ function PhoneInputStep({ step, editable, defaultValue = step.defaultValue }) {
|
|
|
28
28
|
return (_jsx("div", { className: styles.container, style: {
|
|
29
29
|
width: currentBreakPoint <= step.size ? '100%' : calcStepWidth(step.size, form.size),
|
|
30
30
|
minHeight: step.description || (!postview && editable) ? '55px' : '43px',
|
|
31
|
-
}, children: _jsx(ErkPhoneInput, { ...field, value: value, inputRef: ref, error: !!error, label: step.label, onChange: onChange, "data-testid": step.id, required: step.required, readOnly: !editable || postview, helperText: error?.message ?? step.description }) }));
|
|
31
|
+
}, children: _jsx(ErkPhoneInput, { ...field, value: value, inputRef: ref, error: !!error, labelMargin: 0, label: step.label, onChange: onChange, "data-testid": step.id, required: step.required, readOnly: !editable || postview, helperText: error?.message ?? step.description }) }));
|
|
32
32
|
}
|
|
33
33
|
export default PhoneInputStep;
|
|
@@ -4,9 +4,9 @@ import { clearDependency, setStepDependency } from '../States/SiteSlice';
|
|
|
4
4
|
import { createSelector } from '@reduxjs/toolkit';
|
|
5
5
|
import { calcDefaultValue, evaluateCondition } from './StepFunctions';
|
|
6
6
|
import { useController } from 'react-hook-form';
|
|
7
|
-
import { SizeChangeContext } from './Utils/@StepFiller/StepFiller';
|
|
8
7
|
import ConditionTypes from '../constants/ConditionTypes';
|
|
9
8
|
import FormStepTypes, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueOptionTypes, } from '../constants/FormStepTypes';
|
|
9
|
+
import { SizeChangeContext } from './Utils/@StepFiller/StepFillerContext';
|
|
10
10
|
const selectIsDependency = createSelector([
|
|
11
11
|
(state) => state.site.dependencies,
|
|
12
12
|
(_state, step) => step,
|
|
@@ -15,7 +15,7 @@ function TextAreaStep({ step, editable, maxLength }) {
|
|
|
15
15
|
});
|
|
16
16
|
return (_jsxs("div", { className: styles.container, style: {
|
|
17
17
|
paddingBottom: step.required || step.description || !!error ? '0px' : '5px',
|
|
18
|
-
}, children: [_jsx("div", { className: styles.erkTextArea, children: _jsx(ErkTextField, { ...field, multiline: true, value: value, inputRef: ref, error: !!error, label: step.label, onChange: onChange, "data-testid": step.id, maxLength: maxLength, required: step.required, disabled: !editable || postview, minRows: postview && partial ? undefined : 4, helperText: error?.message ?? step.description ?? (step.required ? ' ' : null) }) }), _jsxs("div", { className: styles.print, children: [value && (_jsxs(React.Fragment, { children: [_jsx("div", { className: styles.printLbl, style: {
|
|
18
|
+
}, children: [_jsx("div", { className: styles.erkTextArea, children: _jsx(ErkTextField, { ...field, multiline: true, value: value, inputRef: ref, error: !!error, labelMargin: 0, label: step.label, onChange: onChange, "data-testid": step.id, maxLength: maxLength, required: step.required, disabled: !editable || postview, minRows: postview && partial ? undefined : 4, helperText: error?.message ?? step.description ?? (step.required ? ' ' : null) }) }), _jsxs("div", { className: styles.print, children: [value && (_jsxs(React.Fragment, { children: [_jsx("div", { className: styles.printLbl, style: {
|
|
19
19
|
color: formStyle.descriptionTextColor,
|
|
20
20
|
}, children: step.label }), _jsx("div", { className: styles.printLine, style: {
|
|
21
21
|
color: formStyle.stepBackgroundColor,
|
|
@@ -29,6 +29,6 @@ function TextInputStep({ step, editable, maxLength, IconComponent, defaultValue
|
|
|
29
29
|
return (_jsx("div", { className: styles.container, style: {
|
|
30
30
|
width: currentBreakPoint <= step.size ? '100%' : calcStepWidth(step.size, form.size),
|
|
31
31
|
minHeight: step.description || (!postview && editable && (step.required || validation)) ? '55px' : '43px',
|
|
32
|
-
}, children: _jsx(ErkTextField, { ...field, inputRef: ref,
|
|
32
|
+
}, children: _jsx(ErkTextField, { ...field, value: value, inputRef: ref, labelMargin: 0, error: !!error, label: step.label, onChange: onChange, maxLength: maxLength, "data-testid": step.id, required: step.required, readOnly: !editable || postview, helperText: error?.message ?? step.description, IconComponent: step.showIcon ? IconComponent : undefined }) }));
|
|
33
33
|
}
|
|
34
34
|
export default TextInputStep;
|
|
@@ -18,6 +18,6 @@ function TimePickerStep({ step, editable, defaultValue }) {
|
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
|
-
return (_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkTimePicker, { ...field, value: value, onChange: onChange, inputRef: ref, readOnly: !editable || postview, label: step.label, helperText: error?.message ?? step.description, error: !!error, required: step.required, pickDays: step.pickDays, minDays: step.minDays, maxDays: step.maxDays, pickHours: step.pickHours, minHours: step.minHours, maxHours: step.maxHours, pickMinutes: step.pickMinutes, minMinutes: step.minMinutes, maxMinutes: step.maxMinutes, working: step.working }) }));
|
|
21
|
+
return (_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkTimePicker, { ...field, value: value, onChange: onChange, inputRef: ref, labelMargin: 0, readOnly: !editable || postview, label: step.label, helperText: error?.message ?? step.description, error: !!error, required: step.required, pickDays: step.pickDays, minDays: step.minDays, maxDays: step.maxDays, pickHours: step.pickHours, minHours: step.minHours, maxHours: step.maxHours, pickMinutes: step.pickMinutes, minMinutes: step.minMinutes, maxMinutes: step.maxMinutes, working: step.working }) }));
|
|
22
22
|
}
|
|
23
23
|
export default TimePickerStep;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useCallback, useContext, useState } from 'react';
|
|
3
3
|
import { useFormContext } from 'react-hook-form';
|
|
4
4
|
import { calcFillerSize } from '../../StepFunctions';
|
|
5
5
|
import FormContext from '../../../Contexts/FormContext';
|
|
6
6
|
import styles from './StepFiller.module.css';
|
|
7
7
|
import { selectBreakPoint, useAppSelector } from '../../../hooks';
|
|
8
|
-
|
|
8
|
+
import { SizeChangeContext } from './StepFillerContext';
|
|
9
9
|
function StepFiller({ step, children }) {
|
|
10
10
|
const { getValues } = useFormContext();
|
|
11
11
|
const form = useContext(FormContext);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SizeChangeContext: import("react").Context<(() => void) | undefined>;
|
|
@@ -6,6 +6,8 @@ interface ErkDatePickerProps extends Omit<MuiDatePickerProps<PickerValidDate>, '
|
|
|
6
6
|
/** If it should display the timePicker */
|
|
7
7
|
pickTime?: boolean;
|
|
8
8
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
9
|
+
/** labelMargin */
|
|
10
|
+
labelMargin?: number;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* Generic datepicker with apps designs. Is class due to the use in the react-hook-forms library
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import
|
|
4
|
-
import { styled, Dialog as MuiDialog } from '@mui/material';
|
|
3
|
+
import { styled, Dialog as MuiDialog, InputAdornment } from '@mui/material';
|
|
5
4
|
import { MobileDatePicker as MuiDatePicker, MobileDateTimePicker as MuiDateTimePicker, DatePickerToolbar as MuiDatePickerToolbar, DateTimePickerToolbar as MuiDateTimePickerToolbar, PickersDay as MuiPickerDay, } from '@mui/x-date-pickers';
|
|
6
5
|
import { StyledTextField } from '../ErkTextField/ErkTextField';
|
|
6
|
+
import CalendarIcon from '../../Icons/CalendarIcon';
|
|
7
7
|
const StyledDateTimePicker = styled(MuiDateTimePicker)(({ ...props }) => ({
|
|
8
8
|
'& .Erk-MuiInputBase-root': {
|
|
9
9
|
cursor: props.disabled ? 'default' : 'pointer',
|
|
@@ -84,7 +84,9 @@ const StyledDialog = styled(MuiDialog)(({ theme }) => ({
|
|
|
84
84
|
'& .Erk-MuiDialogActions-root': {
|
|
85
85
|
'& .Erk-MuiButtonBase-root': { fontWeight: 700 },
|
|
86
86
|
},
|
|
87
|
-
'& .Erk-MuiDialogContent-root': {
|
|
87
|
+
'& .Erk-MuiDialogContent-root': {
|
|
88
|
+
scrollbarColor: theme.palette.primary.main + ' white',
|
|
89
|
+
},
|
|
88
90
|
}));
|
|
89
91
|
const StyledDay = styled(MuiPickerDay)(({ theme }) => ({
|
|
90
92
|
fontWeight: 500,
|
|
@@ -100,7 +102,7 @@ const StyledDay = styled(MuiPickerDay)(({ theme }) => ({
|
|
|
100
102
|
},
|
|
101
103
|
},
|
|
102
104
|
}));
|
|
103
|
-
function CustomDatePicker({ error, required, disabled, readOnly, helperText, size = 'small', pickTime = false, ...others }) {
|
|
105
|
+
function CustomDatePicker({ error, required, disabled, readOnly, helperText, size = 'small', labelMargin = 5, pickTime = false, ...others }) {
|
|
104
106
|
if (pickTime) {
|
|
105
107
|
return (_jsx(StyledDateTimePicker, { ampm: true, reduceAnimations: true, ...others, disabled: disabled ?? readOnly, defaultValue: required ? new Date() : undefined, showDaysOutsideCurrentMonth: true, slotProps: {
|
|
106
108
|
actionBar: {
|
|
@@ -115,9 +117,6 @@ function CustomDatePicker({ error, required, disabled, readOnly, helperText, siz
|
|
|
115
117
|
gridColumn: 1,
|
|
116
118
|
gridRow: 2,
|
|
117
119
|
},
|
|
118
|
-
'& .Erk-MuiPickersLayout-root': {
|
|
119
|
-
backgroundColor: 'red',
|
|
120
|
-
},
|
|
121
120
|
'& .Erk-MuiPickersCalendarHeader-root': {
|
|
122
121
|
marginTop: '5px',
|
|
123
122
|
},
|
|
@@ -149,10 +148,12 @@ function CustomDatePicker({ error, required, disabled, readOnly, helperText, siz
|
|
|
149
148
|
size,
|
|
150
149
|
disabled,
|
|
151
150
|
helperText,
|
|
151
|
+
labelMargin,
|
|
152
152
|
placeholder: '',
|
|
153
|
+
fullWidth: true,
|
|
153
154
|
InputProps: {
|
|
154
155
|
disabled: disabled ?? readOnly,
|
|
155
|
-
endAdornment: _jsx(
|
|
156
|
+
endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(CalendarIcon, { size: size === 'small' ? 22 : 26 }) })),
|
|
156
157
|
},
|
|
157
158
|
},
|
|
158
159
|
}, slots: {
|
|
@@ -197,10 +198,12 @@ function CustomDatePicker({ error, required, disabled, readOnly, helperText, siz
|
|
|
197
198
|
error,
|
|
198
199
|
disabled,
|
|
199
200
|
helperText,
|
|
201
|
+
labelMargin,
|
|
202
|
+
fullWidth: true,
|
|
200
203
|
placeholder: '',
|
|
201
204
|
InputProps: {
|
|
202
205
|
disabled: disabled ?? readOnly,
|
|
203
|
-
endAdornment: _jsx(
|
|
206
|
+
endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(CalendarIcon, { size: size === 'small' ? 20 : 24 }) })),
|
|
204
207
|
},
|
|
205
208
|
},
|
|
206
209
|
}, slots: {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const Styled: import("@emotion/styled").StyledComponent<import("@mui/material").MenuItemOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & {
|
|
2
|
+
ref?: ((instance: HTMLLIElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLLIElement> | null | undefined;
|
|
3
|
+
}, "children" | "className" | "style" | "classes" | "autoFocus" | "tabIndex" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "dense" | "disableGutters" | "divider" | "selected"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
4
|
+
export default Styled;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MenuItem, styled } from '@mui/material';
|
|
2
|
+
const Styled = styled(MenuItem)(({ theme }) => ({
|
|
3
|
+
padding: '6px 12px',
|
|
4
|
+
whiteSpace: 'normal',
|
|
5
|
+
'& .Erk-MuiMenuItem-root:has(.ErkIcon) ': {
|
|
6
|
+
paddingLeft: '40px',
|
|
7
|
+
'& .ErkIcon': {
|
|
8
|
+
left: 12,
|
|
9
|
+
top: '50%',
|
|
10
|
+
position: 'absolute',
|
|
11
|
+
transform: 'translateY(-50%)',
|
|
12
|
+
fill: theme.palette.primary.main,
|
|
13
|
+
width: '20px',
|
|
14
|
+
height: '20px',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
export default Styled;
|
|
@@ -4,7 +4,7 @@ import { ErkTextFieldProps } from '../ErkTextField/ErkTextField';
|
|
|
4
4
|
export interface ErkPhoneInputProps extends Omit<ErkTextFieldProps, 'onChange' | 'ref'> {
|
|
5
5
|
/** The value of the phoneinput */
|
|
6
6
|
value?: string;
|
|
7
|
-
onChange
|
|
7
|
+
onChange?: (value: string) => void;
|
|
8
8
|
inputRef?: any;
|
|
9
9
|
readOnly?: boolean;
|
|
10
10
|
}
|
|
@@ -29,8 +29,16 @@ const StyledSelect = styled(Select)(() => ({
|
|
|
29
29
|
'&.Erk-MuiInput-underline::after': {
|
|
30
30
|
borderBottom: 'none',
|
|
31
31
|
},
|
|
32
|
+
'&.Mui-readOnly': {
|
|
33
|
+
'& .Erk-MuiSelect-select': {
|
|
34
|
+
paddingRight: 5,
|
|
35
|
+
},
|
|
36
|
+
'& .Erk-MuiSelect-icon': {
|
|
37
|
+
display: 'none',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
32
40
|
}));
|
|
33
|
-
function CustomPhoneInput({ value, onChange, inputRef, size = 'small', readOnly = false, disabled = false, ...others }) {
|
|
41
|
+
function CustomPhoneInput({ value, onChange, inputRef, IconComponent, size = 'small', readOnly = false, disabled = false, ...others }) {
|
|
34
42
|
const defaultCountry = useAppSelector((state) => state.global.countryCode);
|
|
35
43
|
const { inputValue, handlePhoneValueChange, inputRef: phoneRef, country, setCountry, } = usePhoneInput({
|
|
36
44
|
value: '+' + value,
|
|
@@ -38,7 +46,7 @@ function CustomPhoneInput({ value, onChange, inputRef, size = 'small', readOnly
|
|
|
38
46
|
defaultCountry: (defaultCountry ?? 'CO').toLowerCase(),
|
|
39
47
|
disableDialCodePrefill: true,
|
|
40
48
|
disableDialCodeAndPrefix: true,
|
|
41
|
-
onChange: (data) => onChange(data.phone.replace('+', '')),
|
|
49
|
+
onChange: (data) => onChange?.(data.phone.replace('+', '')),
|
|
42
50
|
});
|
|
43
51
|
const countries = useMemo(() => defaultCountries
|
|
44
52
|
.map((c) => {
|
|
@@ -57,19 +65,20 @@ function CustomPhoneInput({ value, onChange, inputRef, size = 'small', readOnly
|
|
|
57
65
|
e.preventDefault();
|
|
58
66
|
if (phone.country)
|
|
59
67
|
setCountry(phone.country.toLowerCase());
|
|
60
|
-
onChange(phone.number);
|
|
68
|
+
onChange?.(phone.number);
|
|
61
69
|
}
|
|
62
70
|
}
|
|
63
71
|
}, slotProps: {
|
|
64
72
|
input: {
|
|
65
73
|
readOnly,
|
|
66
74
|
disabled: readOnly || disabled,
|
|
67
|
-
startAdornment: (_jsx(InputAdornment, { position: "start", children: _jsx(StyledSelect, { size:
|
|
75
|
+
startAdornment: (_jsx(InputAdornment, { position: "start", children: _jsx(StyledSelect, { size: 'small', variant: "standard", readOnly: readOnly, value: country.iso2, inputProps: { readOnly, disabled: readOnly || disabled }, onChange: (e) => setCountry(e.target.value), renderValue: (value) => (_jsx(FlagImage, { iso2: value, style: { display: 'flex' }, width: 20 })), children: countries.map(({ country, name }) => {
|
|
68
76
|
return (_jsxs(MenuItem, { value: country.iso2, children: [_jsx(FlagImage, { iso2: country.iso2, size: 20 }), _jsx("span", { style: {
|
|
69
77
|
marginLeft: '8px',
|
|
70
78
|
marginRight: '8px',
|
|
71
79
|
}, children: name }), _jsxs("span", { style: { color: 'grey' }, children: ["+", country.dialCode] })] }, country.iso2));
|
|
72
80
|
}) }) })),
|
|
81
|
+
endAdornment: IconComponent,
|
|
73
82
|
},
|
|
74
83
|
} }) }));
|
|
75
84
|
}
|
|
@@ -7,33 +7,46 @@ export interface SelectorStyleProps {
|
|
|
7
7
|
export declare const StyledSelect: import("@emotion/styled").StyledComponent<(import("@mui/material").FilledSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) | (import("@mui/material").StandardSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) | (import("@mui/material").OutlinedSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>), {}, {}>;
|
|
8
8
|
export declare const StyledInputLabel: import("@emotion/styled").StyledComponent<import("@mui/material").InputLabelOwnProps & Pick<import("@mui/material").FormLabelOwnProps, "color" | "filled"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & {
|
|
9
9
|
ref?: ((instance: HTMLLabelElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject<HTMLLabelElement> | null | undefined;
|
|
10
|
-
}, "required" | "size" | "color" | "children" | "className" | "style" | "classes" | "disabled" | "
|
|
10
|
+
}, "required" | "size" | "color" | "children" | "className" | "style" | "classes" | "disabled" | "sx" | "margin" | "error" | "filled" | "variant" | "focused" | "disableAnimation" | "shrink"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
11
11
|
component?: React.ElementType;
|
|
12
12
|
} & {
|
|
13
13
|
open: boolean;
|
|
14
14
|
}, {}, {}>;
|
|
15
15
|
export declare const StyledHelperText: import("@emotion/styled").StyledComponent<import("@mui/material").FormHelperTextOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & {
|
|
16
16
|
ref?: ((instance: HTMLParagraphElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject<HTMLParagraphElement> | null | undefined;
|
|
17
|
-
}, "required" | "children" | "className" | "style" | "classes" | "disabled" | "
|
|
17
|
+
}, "required" | "children" | "className" | "style" | "classes" | "disabled" | "sx" | "margin" | "error" | "filled" | "variant" | "focused"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
18
18
|
component?: React.ElementType;
|
|
19
19
|
}, {}, {}>;
|
|
20
|
-
|
|
20
|
+
export type ErkSelectValue<Type extends string | number, Multiple, Clearable> = Multiple extends true ? Type[] : Clearable extends true ? Type | undefined : Type;
|
|
21
|
+
export interface ErkSelectProps<Type extends string | number = string, Multiple extends boolean | undefined = false, Clearable extends boolean | undefined = true> extends Omit<MuiSelectProps, 'color' | 'onChange' | 'ref'>, SelectorStyleProps {
|
|
22
|
+
/** if selecting multiple values */
|
|
23
|
+
multiple?: Multiple;
|
|
24
|
+
/** If the usar can clear the value */
|
|
25
|
+
clearable?: Clearable;
|
|
26
|
+
/** If the input is loading */
|
|
27
|
+
loading?: boolean;
|
|
21
28
|
/** children to display in the options */
|
|
22
29
|
children?: React.ReactNode;
|
|
23
30
|
/** Currently selected value */
|
|
24
|
-
value?:
|
|
25
|
-
onChange?: (value:
|
|
31
|
+
value?: ErkSelectValue<Type, Multiple, Clearable>;
|
|
32
|
+
onChange?: (value: ErkSelectValue<Type, Multiple, Clearable>) => void;
|
|
26
33
|
/** String to place in the label */
|
|
27
34
|
label?: string;
|
|
28
35
|
/** The helper Text to display */
|
|
29
36
|
helperText?: string;
|
|
30
|
-
/**
|
|
31
|
-
|
|
37
|
+
/** Label to display on clearable */
|
|
38
|
+
clearLabel?: string;
|
|
39
|
+
/** labelMargin */
|
|
40
|
+
labelMargin?: number;
|
|
41
|
+
}
|
|
42
|
+
export type CustomErkSelectOnChangeType<ChangeType, Multiple extends boolean | undefined, Clearable extends boolean | undefined> = Multiple extends true ? ChangeType[] : Clearable extends true ? ChangeType | undefined : ChangeType;
|
|
43
|
+
export interface CustomErkSelectProps<ValueType extends string | number = string, ChangeType = any, Multiple extends boolean | undefined = false, Clearable extends boolean | undefined = true> extends Omit<ErkSelectProps<ValueType, Multiple, Clearable>, 'onChange'> {
|
|
44
|
+
onChange?: (value: CustomErkSelectOnChangeType<ChangeType, Multiple, Clearable>) => void;
|
|
32
45
|
}
|
|
33
46
|
/**
|
|
34
47
|
* Generic textfield with apps designs. Is class due to the use in the react-hook-forms library
|
|
35
48
|
*/
|
|
36
|
-
declare class ErkSelect extends React.Component<ErkSelectProps
|
|
49
|
+
declare class ErkSelect<Type extends string | number = string, Multiple extends boolean | undefined = false, Clearable extends boolean | undefined = true> extends React.Component<ErkSelectProps<Type, Multiple, Clearable>> {
|
|
37
50
|
render(): JSX.Element;
|
|
38
51
|
}
|
|
39
52
|
export default ErkSelect;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useState } from 'react';
|
|
2
|
+
import React, { useCallback, useState } from 'react';
|
|
3
3
|
import { FormControl, FormHelperText as MuiFormHelperText, InputLabel as MuiInputLabel, Select as MuiSelect, styled, InputAdornment, } from '@mui/material';
|
|
4
|
+
import ErkMenuItem from '../ErkMenuItem';
|
|
4
5
|
export const StyledSelect = styled(MuiSelect)(({ theme, size, ...props }) => ({
|
|
5
6
|
borderRadius: 10,
|
|
6
7
|
opacity: props.disabled ? 0.5 : 1,
|
|
7
|
-
backgroundColor: theme.palette.
|
|
8
|
+
backgroundColor: theme.palette.stepBackgroundColor.default,
|
|
8
9
|
minHeight: size === 'small' ? 31 : size === 'medium' ? 40 : undefined,
|
|
9
10
|
'&.Erk-MuiInputBase-adornedEnd': {
|
|
10
11
|
paddingRight: 7,
|
|
@@ -39,6 +40,7 @@ export const StyledSelect = styled(MuiSelect)(({ theme, size, ...props }) => ({
|
|
|
39
40
|
},
|
|
40
41
|
'& .Erk-MuiInputAdornment-root': {
|
|
41
42
|
marginLeft: 0,
|
|
43
|
+
marginRight: size === 'medium' ? 2 : 0,
|
|
42
44
|
color: theme.palette.text.primary + 'a0',
|
|
43
45
|
fill: theme.palette.text.primary + 'a0',
|
|
44
46
|
cursor: props.disabled || props.readOnly ? 'default' : 'pointer',
|
|
@@ -46,6 +48,18 @@ export const StyledSelect = styled(MuiSelect)(({ theme, size, ...props }) => ({
|
|
|
46
48
|
'& .Erk-MuiSelect-iconOpen': {
|
|
47
49
|
transform: props.IconComponent ? 'none' : undefined,
|
|
48
50
|
},
|
|
51
|
+
'& .Erk-MuiInputBase-input:has(.ErkIcon) ': {
|
|
52
|
+
paddingLeft: 40,
|
|
53
|
+
'& .ErkIcon': {
|
|
54
|
+
left: 12,
|
|
55
|
+
top: '50%',
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
transform: 'translateY(-50%)',
|
|
58
|
+
fill: theme.palette.primary.main,
|
|
59
|
+
width: '20px',
|
|
60
|
+
height: '20px',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
49
63
|
}));
|
|
50
64
|
export const StyledInputLabel = styled(MuiInputLabel)(({ theme, size = 'small', ...props }) => ({
|
|
51
65
|
color: theme.palette.text.primary + '8a',
|
|
@@ -70,17 +84,43 @@ export const StyledHelperText = styled(MuiFormHelperText)(({ theme, ...props })
|
|
|
70
84
|
color: theme.palette.error.main,
|
|
71
85
|
},
|
|
72
86
|
}));
|
|
73
|
-
function CustomSelect({ label, error, onChange, children, required,
|
|
87
|
+
function CustomSelect({ label, error, value, loading, onChange, children, required, inputRef, MenuProps, helperText, IconComponent, size = 'small', labelMargin = 5, multiple = false, readOnly = false, disabled = false, clearable = true, fullWidth = true, clearLabel = 'Sin Seleccionar', ...others }) {
|
|
74
88
|
const [open, setOpen] = useState(false);
|
|
75
|
-
|
|
89
|
+
const handleChange = useCallback((event) => onChange?.(event.target.value), [onChange]);
|
|
90
|
+
return (_jsxs(FormControl, { size: size, error: error, variant: "outlined", required: required, fullWidth: fullWidth, style: { marginTop: label ? labelMargin : undefined, maxWidth: '100%' }, children: [label && (_jsx(StyledInputLabel, { disabled: disabled, open: open, size: size === 'small' ? 'small' : 'normal', children: label })), _jsxs(StyledSelect, { ...others, size: size, ref: inputRef, autoWidth: false, open: others.open ?? open, label: label, readOnly: readOnly, disabled: disabled, multiple: multiple, onChange: handleChange, value: value ?? (multiple ? [] : ''), IconComponent: IconComponent ? () => _jsx(_Fragment, {}) : undefined, endAdornment: IconComponent ? (_jsx(InputAdornment, { position: "end", onClick: (e) => {
|
|
76
91
|
e.stopPropagation();
|
|
77
|
-
if (!readOnly && !disabled)
|
|
78
|
-
|
|
79
|
-
|
|
92
|
+
if (!readOnly && !disabled) {
|
|
93
|
+
if (others.open !== undefined) {
|
|
94
|
+
if (others.open)
|
|
95
|
+
others.onClose?.(e);
|
|
96
|
+
else
|
|
97
|
+
others.onOpen?.(e);
|
|
98
|
+
}
|
|
99
|
+
else
|
|
100
|
+
setOpen((open) => !open);
|
|
101
|
+
}
|
|
102
|
+
}, children: _jsx(IconComponent, { size: size === 'small' ? 22 : 26 }) })) : undefined, onFocus: (e) => {
|
|
80
103
|
if (!e.relatedTarget?.closest('.Erk-MuiPaper-root')) {
|
|
81
104
|
setOpen(true);
|
|
82
105
|
}
|
|
83
|
-
|
|
106
|
+
others.onFocus?.(e);
|
|
107
|
+
}, MenuProps: {
|
|
108
|
+
disablePortal: true,
|
|
109
|
+
sx: (theme) => ({
|
|
110
|
+
'& .Erk-MuiMenuItem-root:has(.ErkIcon) ': {
|
|
111
|
+
gap: '10px',
|
|
112
|
+
padding: '6px 12px',
|
|
113
|
+
display: 'flex',
|
|
114
|
+
maxWidth: '100%',
|
|
115
|
+
alignItems: 'center',
|
|
116
|
+
'& .ErkIcon': {
|
|
117
|
+
width: '20px',
|
|
118
|
+
fill: theme.palette.primary.main,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
...MenuProps,
|
|
123
|
+
}, onOpen: others.onOpen ?? (() => setOpen(true)), onClose: others.onClose ?? (() => setOpen(false)), inputProps: { disabled: readOnly || disabled }, children: [((clearable && !multiple) || loading) && (_jsx(ErkMenuItem, { value: '', "data-testid": 'smart-select-empty', style: { whiteSpace: 'normal' }, children: _jsx("em", { children: loading ? 'Cargando...' : clearLabel }) }, 'EMPTY')), children] }), helperText && _jsx(StyledHelperText, { disabled: disabled, children: helperText })] }));
|
|
84
124
|
}
|
|
85
125
|
/**
|
|
86
126
|
* Generic textfield with apps designs. Is class due to the use in the react-hook-forms library
|
|
@@ -23,13 +23,13 @@ export const ValueAndLabel = {
|
|
|
23
23
|
label: 'Label',
|
|
24
24
|
value: 'option',
|
|
25
25
|
},
|
|
26
|
-
render: function Component({
|
|
26
|
+
render: function Component({ inputRef, ...args }) {
|
|
27
27
|
const [, setArgs] = useArgs();
|
|
28
28
|
const onValueChange = (value) => {
|
|
29
29
|
args.onChange?.(value);
|
|
30
30
|
setArgs({ value });
|
|
31
31
|
};
|
|
32
|
-
return (_jsx(ErkSelect, { ...args, onChange: onValueChange, inputRef:
|
|
32
|
+
return (_jsx(ErkSelect, { ...args, onChange: onValueChange, inputRef: inputRef, children: _jsx(MenuItem, { value: 'option', style: { whiteSpace: 'normal' }, children: "Option" }) }));
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
35
|
export const Full = {
|
|
@@ -58,7 +58,7 @@ export const DifferentColors = {
|
|
|
58
58
|
value: 'option',
|
|
59
59
|
helperText: 'Helper text',
|
|
60
60
|
},
|
|
61
|
-
render: function Component({
|
|
62
|
-
return (_jsx(ErkSelect, { ...args, inputRef:
|
|
61
|
+
render: function Component({ inputRef, ...args }) {
|
|
62
|
+
return (_jsx(ErkSelect, { ...args, inputRef: inputRef, children: _jsx(MenuItem, { value: 'option', style: { whiteSpace: 'normal' }, children: "Option" }) }));
|
|
63
63
|
},
|
|
64
64
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createFilterOptions,
|
|
2
|
+
import { createFilterOptions, CircularProgress, Autocomplete as MuiAutocomplete, styled, } from '@mui/material';
|
|
3
3
|
import ErkSelect from '../ErkSelect/ErkSelect';
|
|
4
4
|
import { StyledTextField } from '../ErkTextField/ErkTextField';
|
|
5
|
+
import ErkMenuItem from '../ErkMenuItem';
|
|
5
6
|
const filter = createFilterOptions();
|
|
6
7
|
const StyledAutoComplete = styled(MuiAutocomplete)(({ theme, ...props }) => ({
|
|
7
8
|
'& .Erk-MuiInputBase-root': {
|
|
@@ -32,7 +33,7 @@ export default function ErkSmartSelect({ options, value = '', onChange, label, g
|
|
|
32
33
|
else {
|
|
33
34
|
return filter(options, params);
|
|
34
35
|
}
|
|
35
|
-
}, renderOption: ({ key, ...props }, option) => (_jsx(
|
|
36
|
+
}, renderOption: ({ key, ...props }, option) => (_jsx(ErkMenuItem, { ...props, children: option.label }, key)), getOptionLabel: (option) => {
|
|
36
37
|
// Value selected with enter, right from the input
|
|
37
38
|
if (typeof option === 'string') {
|
|
38
39
|
return option;
|
|
@@ -48,9 +49,9 @@ export default function ErkSmartSelect({ options, value = '', onChange, label, g
|
|
|
48
49
|
popper: {
|
|
49
50
|
sx: { zIndex: 1305 },
|
|
50
51
|
},
|
|
51
|
-
}, renderInput: (params) => (_jsx(StyledTextField, { ...params, size: size, label: label, name: others.name, readOnly: readOnly, disabled: disabled, inputRef: inputRef, error: others.error, onBlur: others.onBlur, required: others.required, helperText: others.helperText })) }));
|
|
52
|
+
}, renderInput: (params) => (_jsx(StyledTextField, { ...params, size: size, label: label, labelMargin: 0, name: others.name, readOnly: readOnly, disabled: disabled, inputRef: inputRef, error: others.error, onBlur: others.onBlur, required: others.required, helperText: others.helperText })) }));
|
|
52
53
|
}
|
|
53
54
|
else {
|
|
54
|
-
return (_jsxs(ErkSelect, { ...others, inputRef: inputRef, onChange: (value) => onChange?.(options?.find((option) => getValueString(option) === value)), value: loading ? '' : getValueString(value), label: label, IconComponent: loading ? () => _jsx(CircularProgress, { size: 22 }) : IconComponent, children: [_jsx(
|
|
55
|
+
return (_jsxs(ErkSelect, { ...others, labelMargin: 0, inputRef: inputRef, onChange: (value) => onChange?.(options?.find((option) => getValueString(option) === value)), value: loading ? '' : getValueString(value), label: label, IconComponent: loading ? () => _jsx(CircularProgress, { size: 22 }) : IconComponent, children: [_jsx(ErkMenuItem, { value: '', "data-testid": 'smart-select-empty', children: _jsx("em", { children: options ? 'Sin Seleccionar' : 'Cargando...' }) }, 'EMPTY'), options?.map((option) => (_jsx(ErkMenuItem, { value: getValueString(option), "data-testid": 'smart-select-' + getValueString(option), children: option.label }, getValueString(option)))), options === undefined && value && !loading && (_jsx(ErkMenuItem, { value: getValueString(value), children: value.label ?? '' }, getValueString(value)))] }));
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { OutlinedTextFieldProps as MuiTextFieldProps } from '@mui/material';
|
|
2
2
|
import React, { CSSProperties } from 'react';
|
|
3
|
-
interface StyleProps {
|
|
4
|
-
fontSize?: CSSProperties['fontSize'];
|
|
5
|
-
padding?: CSSProperties['padding'];
|
|
3
|
+
interface StyleProps extends Pick<CSSProperties, 'textAlign' | 'fontSize' | 'padding' | 'fontWeight' | 'backgroundColor' | 'borderRadius'> {
|
|
6
4
|
readOnly?: boolean;
|
|
7
5
|
}
|
|
6
|
+
declare module '@mui/material/TextField' {
|
|
7
|
+
interface TextFieldPropsSizeOverrides {
|
|
8
|
+
large: true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
8
11
|
export declare const StyledTextField: import("@emotion/styled").StyledComponent<{
|
|
9
12
|
variant?: import("@mui/material").TextFieldVariants | undefined;
|
|
10
13
|
} & Omit<import("@mui/material").FilledTextFieldProps | MuiTextFieldProps | import("@mui/material").StandardTextFieldProps, "variant"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & Omit<ErkTextFieldProps, "onChange"> & StyleProps, {}, {}>;
|
|
11
|
-
export type ErkTextFieldSlotProps = Omit<ErkTextFieldProps, 'value' | 'onChange'>;
|
|
12
|
-
export interface ErkTextFieldProps extends Omit<MuiTextFieldProps, 'variant' | 'onChange'>, StyleProps {
|
|
14
|
+
export type ErkTextFieldSlotProps = Omit<ErkTextFieldProps, 'value' | 'onChange' | 'fullWidth'>;
|
|
15
|
+
export interface ErkTextFieldProps extends Omit<MuiTextFieldProps, 'variant' | 'onChange' | 'ref'>, StyleProps {
|
|
13
16
|
/** The value of the textfield */
|
|
14
17
|
value?: string | number;
|
|
15
18
|
onChange?: (value: string) => void;
|
|
@@ -17,6 +20,10 @@ export interface ErkTextFieldProps extends Omit<MuiTextFieldProps, 'variant' | '
|
|
|
17
20
|
IconComponent?: React.ElementType | React.ReactNode;
|
|
18
21
|
/** The max length of the string */
|
|
19
22
|
maxLength?: number;
|
|
23
|
+
/** Show red border on error */
|
|
24
|
+
errorBorder?: boolean;
|
|
25
|
+
/** labelMargin */
|
|
26
|
+
labelMargin?: number;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* Generic textfield with apps designs. Is class due to the use in the react-hook-forms library
|
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { styled, TextField as MuiTextField, useTheme, } from '@mui/material';
|
|
3
3
|
import React, { useCallback, useMemo } from 'react';
|
|
4
|
-
export const StyledTextField = styled(MuiTextField
|
|
5
|
-
|
|
4
|
+
export const StyledTextField = styled(MuiTextField, {
|
|
5
|
+
shouldForwardProp: (propName) => !['textAlign', 'errorBorder', 'labelMargin', 'minWidth', 'borderRadius'].includes(propName),
|
|
6
|
+
})(({ theme, label, size, error, textAlign, errorBorder, labelMargin = 5, borderRadius = 10, fontSize = size === 'large' ? '1.5rem' : '1rem', padding = '6px 12px', fontWeight = 400, backgroundColor = theme.palette.stepBackgroundColor.default, ...props }) => ({
|
|
7
|
+
borderRadius,
|
|
6
8
|
opacity: props.disabled ? 0.5 : 1,
|
|
9
|
+
marginTop: label ? labelMargin : undefined,
|
|
7
10
|
minHeight: size === 'small' ? 31 : size === 'medium' ? 40 : undefined,
|
|
11
|
+
'& .Erk-MuiInputBase-root': {
|
|
12
|
+
borderRadius,
|
|
13
|
+
backgroundColor,
|
|
14
|
+
},
|
|
8
15
|
'& input, textarea': {
|
|
9
16
|
fontSize,
|
|
10
|
-
|
|
17
|
+
textAlign,
|
|
11
18
|
padding,
|
|
12
|
-
fontWeight
|
|
19
|
+
fontWeight,
|
|
20
|
+
borderRadius,
|
|
21
|
+
backgroundColor,
|
|
13
22
|
color: theme.palette.text.primary,
|
|
23
|
+
cursor: props.disabled || props.readOnly ? 'default' : 'text',
|
|
14
24
|
lineHeight: size === 'small' ? '1.188em' : size === 'medium' ? '1.75em' : undefined,
|
|
15
25
|
height: size === 'small' ? '1.188em' : size === 'medium' ? '1.75em' : undefined,
|
|
16
|
-
|
|
26
|
+
'&.Mui-readOnly': {
|
|
27
|
+
color: theme.palette.text.primary,
|
|
28
|
+
WebkitTextFillColor: theme.palette.text.primary,
|
|
29
|
+
},
|
|
17
30
|
},
|
|
18
31
|
'& .Erk-MuiFormLabel-root:not(.Erk-MuiInputLabel-shrink)': {
|
|
19
|
-
|
|
32
|
+
fontSize,
|
|
33
|
+
transform: `translate(12px, ${size === 'small' ? 5 : size === 'medium' ? 9 : 7}px) scale(1)`,
|
|
34
|
+
},
|
|
35
|
+
'& .Erk-MuiInputLabel-shrink': {
|
|
36
|
+
color: error && errorBorder ? theme.palette.error.main : undefined,
|
|
20
37
|
},
|
|
21
38
|
'& label': {
|
|
22
39
|
color: theme.palette.text.primary + '8a',
|
|
@@ -24,28 +41,34 @@ export const StyledTextField = styled(MuiTextField)(({ theme, size, fontSize = '
|
|
|
24
41
|
overflow: 'hidden',
|
|
25
42
|
textOverflow: 'ellipsis',
|
|
26
43
|
},
|
|
27
|
-
'& input + fieldset': {},
|
|
28
44
|
'& .Erk-MuiOutlinedInput-root': {
|
|
29
45
|
'&.Mui-focused fieldset': {
|
|
30
|
-
borderColor: theme.palette.primary.main,
|
|
46
|
+
borderColor: error && errorBorder ? theme.palette.error.main : theme.palette.primary.main,
|
|
31
47
|
borderWidth: 2,
|
|
32
48
|
},
|
|
33
49
|
'& .Erk-MuiOutlinedInput-notchedOutline': {
|
|
34
|
-
borderRadius
|
|
35
|
-
borderColor: theme.palette.outline.main,
|
|
50
|
+
borderRadius,
|
|
51
|
+
borderColor: error && errorBorder ? theme.palette.error.main : theme.palette.outline.main,
|
|
36
52
|
'& legend': {
|
|
37
53
|
fontSize: '0.75rem',
|
|
38
54
|
},
|
|
39
55
|
},
|
|
40
56
|
},
|
|
41
57
|
'& .Erk-MuiOutlinedInput-root:hover:not(.Mui-readOnly) .Erk-MuiOutlinedInput-notchedOutline': {
|
|
42
|
-
borderColor: props.disabled || props.readOnly
|
|
58
|
+
borderColor: props.disabled || props.readOnly
|
|
59
|
+
? theme.palette.outline.main
|
|
60
|
+
: error && errorBorder
|
|
61
|
+
? theme.palette.error.main
|
|
62
|
+
: theme.palette.primary.main,
|
|
43
63
|
},
|
|
44
64
|
'& label.Mui-focused': {
|
|
45
65
|
color: theme.palette.primary.main,
|
|
46
66
|
},
|
|
47
67
|
'& .Mui-error': {
|
|
48
68
|
color: theme.palette.error.main,
|
|
69
|
+
'& fieldset': {
|
|
70
|
+
borderWidth: error && errorBorder ? 2 : undefined,
|
|
71
|
+
},
|
|
49
72
|
},
|
|
50
73
|
'& .Erk-MuiInputBase-adornedEnd': {
|
|
51
74
|
paddingRight: '7px',
|
|
@@ -65,11 +88,13 @@ export const StyledTextField = styled(MuiTextField)(({ theme, size, fontSize = '
|
|
|
65
88
|
padding: 0,
|
|
66
89
|
},
|
|
67
90
|
'& .Erk-MuiInputAdornment-root': {
|
|
68
|
-
|
|
69
|
-
marginRight: 0,
|
|
91
|
+
marginLeft: 0,
|
|
92
|
+
marginRight: size === 'medium' ? 2 : 0,
|
|
93
|
+
fill: theme.palette.text.primary + 'a0',
|
|
94
|
+
color: theme.palette.text.primary + 'a0',
|
|
70
95
|
},
|
|
71
96
|
}));
|
|
72
|
-
function CustomTextfield({ onChange, value = '', IconComponent, size = 'small', ...others }) {
|
|
97
|
+
function CustomTextfield({ onChange, value = '', IconComponent, size = 'small', fullWidth = true, ...others }) {
|
|
73
98
|
const { readOnly, disabled, maxLength } = others;
|
|
74
99
|
const { palette } = useTheme();
|
|
75
100
|
const handleChange = useCallback((event) => {
|
|
@@ -79,6 +104,7 @@ function CustomTextfield({ onChange, value = '', IconComponent, size = 'small',
|
|
|
79
104
|
...others.inputProps,
|
|
80
105
|
spellCheck: true,
|
|
81
106
|
endAdornment: IconComponent,
|
|
107
|
+
readOnly: !!readOnly,
|
|
82
108
|
disabled: !!readOnly || !!disabled,
|
|
83
109
|
}), [others.inputProps, IconComponent, readOnly, disabled]);
|
|
84
110
|
const length = maxLength ? value.toString()?.length : null;
|
|
@@ -86,7 +112,11 @@ function CustomTextfield({ onChange, value = '', IconComponent, size = 'small',
|
|
|
86
112
|
inputProps.inputProps = { maxLength };
|
|
87
113
|
}
|
|
88
114
|
const helperText = others.helperText ?? (others.error === false ? ' ' : undefined);
|
|
89
|
-
return (_jsxs("div", { style: {
|
|
115
|
+
return (_jsxs("div", { style: {
|
|
116
|
+
position: 'relative',
|
|
117
|
+
width: fullWidth ? '100%' : 'fit-content',
|
|
118
|
+
maxWidth: '100%',
|
|
119
|
+
}, children: [_jsx(StyledTextField, { ...others, size: size, value: value, variant: "outlined", fullWidth: fullWidth, helperText: helperText, onChange: handleChange, slotProps: { input: inputProps } }), length !== null && (_jsxs("div", { style: helperText
|
|
90
120
|
? {
|
|
91
121
|
position: 'absolute',
|
|
92
122
|
bottom: '3px',
|
|
@@ -4,7 +4,7 @@ import { SelectProps as MuiSelectProps } from '@mui/material';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
interface ErkTimePickerProps extends Omit<MuiSelectProps, 'color' | 'onChange'>, SelectorStyleProps {
|
|
6
6
|
/** Currently selected value */
|
|
7
|
-
value
|
|
7
|
+
value?: Time;
|
|
8
8
|
/** function called when value changes */
|
|
9
9
|
onChange?: (time: Time) => void;
|
|
10
10
|
/** Strig to place in the label */
|
|
@@ -21,6 +21,7 @@ interface ErkTimePickerProps extends Omit<MuiSelectProps, 'color' | 'onChange'>,
|
|
|
21
21
|
minMinutes?: number;
|
|
22
22
|
maxMinutes?: number;
|
|
23
23
|
working?: boolean;
|
|
24
|
+
labelMargin?: number;
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* Generic textfield with apps designs. Is class due to the use in the react-hook-forms library
|
|
@@ -3,12 +3,12 @@ import { StyledHelperText, StyledInputLabel, StyledSelect } from '../ErkSelect/E
|
|
|
3
3
|
import styles from './ErkTimePicker.module.css';
|
|
4
4
|
import ClockIcon from '../../Icons/ClockIcon';
|
|
5
5
|
import { ClickAwayListener, FormControl, InputAdornment, MenuItem, Popper, useTheme, } from '@mui/material';
|
|
6
|
-
import React, { useCallback, useState } from 'react';
|
|
6
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
7
7
|
import { StyledTextField } from '../ErkTextField/ErkTextField';
|
|
8
|
-
import
|
|
9
|
-
function CustomSelect({ value, onChange, label, error, required, pickDays, helperText, readOnly = false, disabled = false, minDays = 0, maxDays, pickHours, minHours = 0, maxHours, pickMinutes, minMinutes = 0, maxMinutes, working, ...others }) {
|
|
8
|
+
import ErkToggle from '../Toggle/Toggle';
|
|
9
|
+
function CustomSelect({ value, onChange, label, error, required, pickDays, helperText, readOnly = false, disabled = false, minDays = 0, maxDays, pickHours, minHours = 0, maxHours, pickMinutes, minMinutes = 0, maxMinutes, working, labelMargin = 5, size = 'small', ...others }) {
|
|
10
10
|
const [open, setOpen] = useState(false);
|
|
11
|
-
const ref =
|
|
11
|
+
const ref = useRef(null);
|
|
12
12
|
const { palette } = useTheme();
|
|
13
13
|
const handleChange = useCallback((value) => {
|
|
14
14
|
const time = { ...value };
|
|
@@ -34,7 +34,7 @@ function CustomSelect({ value, onChange, label, error, required, pickDays, helpe
|
|
|
34
34
|
parts.push('*');
|
|
35
35
|
return parts.join(' ');
|
|
36
36
|
};
|
|
37
|
-
return (_jsxs(
|
|
37
|
+
return (_jsxs(_Fragment, { children: [open && (_jsx(ClickAwayListener, { mouseEvent: "onMouseDown", onClickAway: () => setOpen(false), children: _jsx(Popper, { open: true, anchorEl: ref.current, placement: 'bottom-start', modifiers: [
|
|
38
38
|
{
|
|
39
39
|
name: 'preventOverflow',
|
|
40
40
|
enabled: true,
|
|
@@ -48,43 +48,19 @@ function CustomSelect({ value, onChange, label, error, required, pickDays, helpe
|
|
|
48
48
|
paddingTop: error && helperText ? '0px' : '30px',
|
|
49
49
|
}, children: [error && helperText && (_jsx("div", { className: styles.errorMessage, style: {
|
|
50
50
|
color: palette.error.main,
|
|
51
|
-
}, children: helperText })), pickDays && (_jsx("div", { className: styles.numberPickerContainer, children: _jsx(StyledTextField, { label: "D\u00EDas", type: "number", inputProps: {
|
|
52
|
-
min: minDays,
|
|
53
|
-
max: maxDays,
|
|
54
|
-
}, value: (value?.days ?? minDays) + '', onChange: (event) => {
|
|
55
|
-
handleChange({
|
|
56
|
-
...value,
|
|
57
|
-
days: parseInt(event.target.value),
|
|
58
|
-
});
|
|
59
|
-
} }) })), pickHours && (_jsx("div", { className: styles.numberPickerContainer, children: _jsx(StyledTextField, { label: "Horas", type: "number", inputProps: {
|
|
60
|
-
min: minHours,
|
|
61
|
-
max: maxHours,
|
|
62
|
-
}, value: (value?.hours ?? minHours) + '', onChange: (event) => {
|
|
63
|
-
handleChange({
|
|
64
|
-
...value,
|
|
65
|
-
hours: parseInt(event.target.value),
|
|
66
|
-
});
|
|
67
|
-
} }) })), pickMinutes && (_jsx("div", { className: styles.numberPickerContainer, children: _jsx(StyledTextField, { label: "Minutos", type: "number", inputProps: {
|
|
68
|
-
min: minMinutes,
|
|
69
|
-
max: maxMinutes,
|
|
70
|
-
}, value: (value?.minutes ?? minMinutes) + '', onChange: (event) => {
|
|
71
|
-
handleChange({
|
|
72
|
-
...value,
|
|
73
|
-
minutes: parseInt(event.target.value),
|
|
74
|
-
});
|
|
75
|
-
} }) })), working === undefined && (_jsxs("div", { className: styles.workingContainer, children: ["H\u00E1biles:", _jsx(Toggle, { checked: !!value?.working, disabled: working !== undefined, onChange: (working) => {
|
|
51
|
+
}, children: helperText })), pickDays && (_jsx("div", { className: styles.numberPickerContainer, children: _jsx(StyledTextField, { label: "D\u00EDas", type: "number", labelMargin: 0, value: (value?.days ?? minDays) + '', onChange: (event) => handleChange({ ...value, days: parseInt(event.target.value) }), inputProps: { min: minDays, max: maxDays } }) })), pickHours && (_jsx("div", { className: styles.numberPickerContainer, children: _jsx(StyledTextField, { label: "Horas", type: "number", labelMargin: 0, value: (value?.hours ?? minHours) + '', onChange: (event) => handleChange({ ...value, hours: parseInt(event.target.value) }), inputProps: { min: minHours, max: maxHours } }) })), pickMinutes && (_jsx("div", { className: styles.numberPickerContainer, children: _jsx(StyledTextField, { type: "number", label: "Minutos", labelMargin: 0, inputProps: { min: minMinutes, max: maxMinutes }, value: (value?.minutes ?? minMinutes) + '', onChange: (event) => handleChange({ ...value, minutes: parseInt(event.target.value) }) }) })), working === undefined && (_jsxs("div", { className: styles.workingContainer, children: ["H\u00E1biles:", _jsx(ErkToggle, { checked: !!value?.working, disabled: working !== undefined, onChange: (working) => {
|
|
76
52
|
handleChange({
|
|
77
53
|
...value,
|
|
78
54
|
working,
|
|
79
55
|
});
|
|
80
|
-
} })] }))] }) }) })), _jsxs(FormControl, { fullWidth: true, size:
|
|
56
|
+
} })] }))] }) }) })), _jsxs(FormControl, { fullWidth: true, size: size, error: error, variant: "outlined", required: required, style: { marginTop: label ? labelMargin : undefined, maxWidth: '100%' }, children: [label && (_jsx(StyledInputLabel, { disabled: disabled, open: open, size: size === 'small' ? 'small' : 'normal', children: label })), _jsx(StyledSelect, { ...others, ref: ref, open: open, size: size, readOnly: readOnly, disabled: disabled, onBlur: () => {
|
|
81
57
|
if (!readOnly && !disabled)
|
|
82
58
|
setOpen(false);
|
|
83
59
|
}, label: label ? calcLabel() : undefined, value: value ? 0 : '', title: calcTimeString(value), IconComponent: () => _jsx(_Fragment, {}), MenuProps: { sx: { visibility: 'hidden' } }, endAdornment: _jsx(InputAdornment, { position: "end", onClick: (e) => {
|
|
84
60
|
e.stopPropagation();
|
|
85
61
|
if (!readOnly && !disabled)
|
|
86
62
|
setOpen(!open);
|
|
87
|
-
}, children: _jsx(ClockIcon, {}) }), onFocus: (e) => {
|
|
63
|
+
}, children: _jsx(ClockIcon, { size: size === 'small' ? 22 : 26 }) }), onFocus: (e) => {
|
|
88
64
|
if (!e.relatedTarget?.closest('.Erk-MuiPaper-root') && !readOnly && !disabled) {
|
|
89
65
|
setOpen(true);
|
|
90
66
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
interface ToggleProps {
|
|
2
|
-
checked
|
|
3
|
-
|
|
2
|
+
checked?: boolean;
|
|
3
|
+
size?: 'small' | 'medium';
|
|
4
|
+
onChange?: (checked: boolean) => void | Promise<void>;
|
|
4
5
|
/** If the Toggle is disabled */
|
|
5
6
|
disabled?: boolean;
|
|
6
7
|
}
|
|
7
|
-
declare function
|
|
8
|
-
export default
|
|
8
|
+
declare function ErkToggle({ checked, onChange, size, ...others }: ToggleProps): JSX.Element;
|
|
9
|
+
export default ErkToggle;
|
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { styled, Switch as MuiSwitch } from '@mui/material';
|
|
3
|
-
const Styled = styled(MuiSwitch)(({ theme, checked }) => ({
|
|
4
|
-
marginTop: -6,
|
|
5
|
-
marginBottom: -6,
|
|
3
|
+
const Styled = styled(MuiSwitch)(({ theme, checked, size }) => ({
|
|
4
|
+
marginTop: size === 'medium' ? -6 : undefined,
|
|
5
|
+
marginBottom: size === 'medium' ? -6 : undefined,
|
|
6
|
+
overflow: 'visible',
|
|
7
|
+
'& .Erk-MuiSwitch-switchBase': {
|
|
8
|
+
marginTop: size === 'small' ? -5 : undefined,
|
|
9
|
+
transform: size === 'small' ? 'translateX(-5px)' : undefined,
|
|
10
|
+
color: 'var(--outlineGrey)',
|
|
11
|
+
'&.Mui-checked': {
|
|
12
|
+
transform: size === 'small' ? 'translateX(12px)' : undefined,
|
|
13
|
+
'& .Erk-MuiSwitch-thumb': {
|
|
14
|
+
backgroundColor: theme.palette.primary.main,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
'& .Erk-MuiSwitch-thumb': {
|
|
18
|
+
width: size === 'small' ? 16 : 20,
|
|
19
|
+
height: size === 'small' ? 16 : 20,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
6
22
|
'& .Erk-MuiSwitch-track': {
|
|
7
23
|
backgroundColor: checked ? theme.palette.primary.main : undefined,
|
|
24
|
+
opacity: checked ? 0.5 : undefined,
|
|
8
25
|
},
|
|
9
26
|
}));
|
|
10
|
-
function
|
|
11
|
-
return _jsx(Styled, { checked: checked, onChange: () =>
|
|
27
|
+
function ErkToggle({ checked, onChange, size = 'medium', ...others }) {
|
|
28
|
+
return (_jsx(Styled, { ...others, checked: checked, onChange: () => {
|
|
29
|
+
if (onChange)
|
|
30
|
+
void onChange(!checked);
|
|
31
|
+
}, size: size }));
|
|
12
32
|
}
|
|
13
|
-
export default
|
|
33
|
+
export default ErkToggle;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arquimedes.co/eureka-forms",
|
|
3
3
|
"repository": "git://github.com/Arquimede5/Eureka-Forms.git",
|
|
4
|
-
"version":"3.0.
|
|
4
|
+
"version":"3.0.10-refactor",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"watch": "tsc --noEmit --watch --project tsconfig.app.json",
|
|
7
7
|
"start": "vite",
|
|
@@ -45,6 +45,10 @@
|
|
|
45
45
|
]
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
+
"@mui/material": "^6.3.0",
|
|
49
|
+
"@mui/x-data-grid-pro": "^7.23.5",
|
|
50
|
+
"@mui/x-date-pickers": "^7.23.3",
|
|
51
|
+
"@mui/x-date-pickers-pro": "^7.23.3",
|
|
48
52
|
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
49
53
|
"@babel/preset-env": "^7.26.0",
|
|
50
54
|
"@babel/preset-react": "^7.25.9",
|