@arquimedes.co/eureka-forms 3.0.3-refactor → 3.0.4-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/Icons/@ErkIcon.d.ts +2 -2
- package/dist/Icons/@ErkIcon.js +1 -2
- package/dist/Shared/ErkDatePicker/ErkDatePicker.d.ts +1 -1
- package/dist/Shared/ErkDatePicker/ErkDatePicker.js +48 -34
- package/dist/Shared/ErkPhoneInput/EkrPhoneInput.d.ts +1 -0
- package/dist/Shared/ErkPhoneInput/EkrPhoneInput.js +3 -5
- package/dist/Shared/ErkTextField/ErkTextField.d.ts +3 -2
- package/dist/Shared/ErkTextField/ErkTextField.js +21 -16
- package/dist/index.css +10 -0
- package/package.json +1 -1
- package/dist/Icons/@ErkIcon.css +0 -9
package/dist/Icons/@ErkIcon.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import './@ErkIcon.css';
|
|
2
1
|
export interface IconProps {
|
|
3
2
|
fill?: string;
|
|
4
3
|
contrast?: string;
|
|
@@ -6,9 +5,10 @@ export interface IconProps {
|
|
|
6
5
|
style?: React.CSSProperties;
|
|
7
6
|
className?: string;
|
|
8
7
|
size?: number;
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
preserveAspectRatio?: 'none';
|
|
9
10
|
}
|
|
10
11
|
export declare function useIconProps(props: IconProps): IconProps & {
|
|
11
12
|
width?: number;
|
|
12
13
|
height?: number;
|
|
13
|
-
color?: string;
|
|
14
14
|
};
|
package/dist/Icons/@ErkIcon.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MobileDatePickerProps as MuiDatePickerProps, PickerValidDate } from '@mui/x-date-pickers';
|
|
3
3
|
import { ErkTextFieldProps } from '../ErkTextField/ErkTextField';
|
|
4
|
-
interface ErkDatePickerProps extends Omit<MuiDatePickerProps<PickerValidDate>, 'ref' | 'onChange'>, Pick<ErkTextFieldProps, 'error' | 'required' | 'helperText'> {
|
|
4
|
+
interface ErkDatePickerProps extends Omit<MuiDatePickerProps<PickerValidDate>, 'ref' | 'onChange'>, Pick<ErkTextFieldProps, 'error' | 'required' | 'helperText' | 'size'> {
|
|
5
5
|
onChange?: (date: Date | null) => void;
|
|
6
6
|
/** If it should display the timePicker */
|
|
7
7
|
pickTime?: boolean;
|
|
@@ -22,7 +22,7 @@ const StyledDatePicker = styled(MuiDatePicker)(({ ...props }) => ({
|
|
|
22
22
|
},
|
|
23
23
|
}));
|
|
24
24
|
const StyledDateTimeToolBar = styled(MuiDateTimePickerToolbar)(({ theme }) => ({
|
|
25
|
-
'&.MuiPickersToolbar-root': {
|
|
25
|
+
'&.Erk-MuiPickersToolbar-root': {
|
|
26
26
|
backgroundColor: theme.palette.primary.main,
|
|
27
27
|
color: theme.palette.primary.contrastText,
|
|
28
28
|
'& span': {
|
|
@@ -30,17 +30,17 @@ const StyledDateTimeToolBar = styled(MuiDateTimePickerToolbar)(({ theme }) => ({
|
|
|
30
30
|
textTransform: 'capitalize',
|
|
31
31
|
color: theme.palette.primary.contrastText,
|
|
32
32
|
},
|
|
33
|
-
'& .MuiDateTimePickerToolbar-dateContainer': {
|
|
33
|
+
'& .Erk-MuiDateTimePickerToolbar-dateContainer': {
|
|
34
34
|
'& span': {
|
|
35
35
|
fontSize: '1.1rem',
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
|
-
'& .MuiDateTimePickerToolbar-timeDigitsContainer': {
|
|
38
|
+
'& .Erk-MuiDateTimePickerToolbar-timeDigitsContainer': {
|
|
39
39
|
'& span': {
|
|
40
40
|
fontSize: '2.3rem',
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
-
'& .MuiDateTimePickerToolbar-ampmSelection': {
|
|
43
|
+
'& .Erk-MuiDateTimePickerToolbar-ampmSelection': {
|
|
44
44
|
'& span': {
|
|
45
45
|
color: theme.palette.primary.contrastText + '8b',
|
|
46
46
|
'&.Mui-selected': {
|
|
@@ -51,13 +51,13 @@ const StyledDateTimeToolBar = styled(MuiDateTimePickerToolbar)(({ theme }) => ({
|
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
53
|
cursor: 'default',
|
|
54
|
-
'& .MuiTypography-root': {
|
|
54
|
+
'& .Erk-MuiTypography-root': {
|
|
55
55
|
textTransform: 'capitalize',
|
|
56
56
|
color: theme.palette.primary.contrastText,
|
|
57
57
|
},
|
|
58
58
|
}));
|
|
59
59
|
const StyledDateToolBar = styled(MuiDatePickerToolbar)(({ theme }) => ({
|
|
60
|
-
'&.MuiPickersToolbar-root': {
|
|
60
|
+
'&.Erk-MuiPickersToolbar-root': {
|
|
61
61
|
backgroundColor: theme.palette.primary.main,
|
|
62
62
|
color: theme.palette.primary.contrastText,
|
|
63
63
|
'& span': {
|
|
@@ -67,55 +67,36 @@ const StyledDateToolBar = styled(MuiDatePickerToolbar)(({ theme }) => ({
|
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
69
|
cursor: 'default',
|
|
70
|
-
'& .MuiTypography-root': {
|
|
70
|
+
'& .Erk-MuiTypography-root': {
|
|
71
71
|
textTransform: 'capitalize',
|
|
72
72
|
color: theme.palette.primary.contrastText,
|
|
73
73
|
},
|
|
74
74
|
}));
|
|
75
75
|
const StyledDialog = styled(MuiDialog)(({ theme }) => ({
|
|
76
|
-
'& .MuiDialog-paper': {
|
|
76
|
+
'& .Erk-MuiDialog-paper': {
|
|
77
77
|
borderRadius: '5px',
|
|
78
78
|
backgroundColor: 'transparent',
|
|
79
79
|
},
|
|
80
80
|
'& .Erk-MuiDialogActions-root': {
|
|
81
81
|
'& .Erk-MuiButtonBase-root': { fontWeight: 700 },
|
|
82
82
|
},
|
|
83
|
-
'& .MuiDialogContent-root': { scrollbarColor: theme.palette.primary.main + ' white' },
|
|
84
|
-
'& .MuiDayCalendar-weekDayLabel': {
|
|
85
|
-
cursor: 'default',
|
|
86
|
-
},
|
|
87
|
-
'& .MuiPickersCalendarHeader-root': {
|
|
88
|
-
marginTop: 5,
|
|
89
|
-
},
|
|
90
|
-
'& .MuiDateCalendar-root': {
|
|
91
|
-
height: 'fit-content',
|
|
92
|
-
},
|
|
93
|
-
'& .MuiPickersSlideTransition-root': {
|
|
94
|
-
minHeight: '195px',
|
|
95
|
-
},
|
|
96
|
-
'& .MuiClock-root': {
|
|
97
|
-
marginTop: '34px',
|
|
98
|
-
marginBottom: '30px',
|
|
99
|
-
},
|
|
100
|
-
'& .MuiTimeClock-arrowSwitcher': {
|
|
101
|
-
top: 5,
|
|
102
|
-
},
|
|
83
|
+
'& .Erk-MuiDialogContent-root': { scrollbarColor: theme.palette.primary.main + ' white' },
|
|
103
84
|
}));
|
|
104
85
|
const StyledDay = styled(MuiPickerDay)(({ theme }) => ({
|
|
105
86
|
fontWeight: 500,
|
|
106
87
|
fontSize: '0.9rem',
|
|
107
88
|
lineHeight: 'normal',
|
|
108
|
-
'&.MuiPickersDay-today': {
|
|
89
|
+
'&.Erk-MuiPickersDay-today': {
|
|
109
90
|
backgroundColor: theme.palette.primary.main + '33',
|
|
110
91
|
},
|
|
111
|
-
'&.MuiPickersDay-dayOutsideMonth': {
|
|
92
|
+
'&.Erk-MuiPickersDay-dayOutsideMonth': {
|
|
112
93
|
color: 'rgb(0,0,0,0.4)',
|
|
113
94
|
'&.Mui-selected': {
|
|
114
95
|
color: theme.palette.primary.contrastText,
|
|
115
96
|
},
|
|
116
97
|
},
|
|
117
98
|
}));
|
|
118
|
-
function CustomDatePicker({ error, required, disabled, readOnly, helperText, pickTime = false, ...others }) {
|
|
99
|
+
function CustomDatePicker({ error, required, disabled, readOnly, helperText, size = 'small', pickTime = false, ...others }) {
|
|
119
100
|
if (pickTime) {
|
|
120
101
|
return (_jsx(StyledDateTimePicker, { ampm: true, ...others, disabled: disabled ?? readOnly, defaultValue: required ? new Date() : undefined, showDaysOutsideCurrentMonth: true, slotProps: {
|
|
121
102
|
actionBar: {
|
|
@@ -123,8 +104,30 @@ function CustomDatePicker({ error, required, disabled, readOnly, helperText, pic
|
|
|
123
104
|
},
|
|
124
105
|
layout: {
|
|
125
106
|
sx: {
|
|
107
|
+
//Pasar esto al componente de layout?
|
|
126
108
|
backgroundColor: '#ffffff',
|
|
127
109
|
textTransform: 'capitalize',
|
|
110
|
+
'& .Erk-MuiDayCalendar-weekDayLabel': {
|
|
111
|
+
gridColumn: 1,
|
|
112
|
+
gridRow: 2,
|
|
113
|
+
},
|
|
114
|
+
'& .Erk-MuiPickersLayout-root': {
|
|
115
|
+
backgroundColor: 'red',
|
|
116
|
+
},
|
|
117
|
+
'& .Erk-MuiPickersCalendarHeader-root': {
|
|
118
|
+
marginTop: '5px',
|
|
119
|
+
},
|
|
120
|
+
'& .Erk-MuiDateCalendar-root': {
|
|
121
|
+
height: 'fit-content',
|
|
122
|
+
},
|
|
123
|
+
'& .Erk-MuiClock-root': {
|
|
124
|
+
fontSize: 16,
|
|
125
|
+
marginTop: '34px',
|
|
126
|
+
marginBottom: '30px',
|
|
127
|
+
},
|
|
128
|
+
'& .Erk-MuiTimeClock-arrowSwitcher': {
|
|
129
|
+
top: 5,
|
|
130
|
+
},
|
|
128
131
|
},
|
|
129
132
|
},
|
|
130
133
|
monthButton: {
|
|
@@ -139,12 +142,13 @@ function CustomDatePicker({ error, required, disabled, readOnly, helperText, pic
|
|
|
139
142
|
},
|
|
140
143
|
textField: {
|
|
141
144
|
error,
|
|
145
|
+
size,
|
|
142
146
|
disabled,
|
|
143
147
|
helperText,
|
|
144
148
|
placeholder: '',
|
|
145
149
|
InputProps: {
|
|
146
150
|
disabled: disabled ?? readOnly,
|
|
147
|
-
endAdornment: _jsx(CalendarIcon, { fill: "#000000a0" }),
|
|
151
|
+
endAdornment: _jsx(CalendarIcon, { fill: "#000000a0", size: 22 }),
|
|
148
152
|
},
|
|
149
153
|
},
|
|
150
154
|
}, slots: {
|
|
@@ -163,6 +167,15 @@ function CustomDatePicker({ error, required, disabled, readOnly, helperText, pic
|
|
|
163
167
|
sx: {
|
|
164
168
|
backgroundColor: '#ffffff',
|
|
165
169
|
textTransform: 'capitalize',
|
|
170
|
+
'& .Erk-MuiDayCalendar-weekDayLabel': {
|
|
171
|
+
cursor: 'default',
|
|
172
|
+
},
|
|
173
|
+
'& .Erk-MuiPickersCalendarHeader-root': {
|
|
174
|
+
marginTop: '5px',
|
|
175
|
+
},
|
|
176
|
+
'& .Erk-MuiDateCalendar-root': {
|
|
177
|
+
height: 'fit-content',
|
|
178
|
+
},
|
|
166
179
|
},
|
|
167
180
|
},
|
|
168
181
|
monthButton: {
|
|
@@ -176,16 +189,17 @@ function CustomDatePicker({ error, required, disabled, readOnly, helperText, pic
|
|
|
176
189
|
toolbarPlaceholder: '– –',
|
|
177
190
|
},
|
|
178
191
|
textField: {
|
|
192
|
+
size,
|
|
179
193
|
error,
|
|
180
194
|
disabled,
|
|
181
195
|
helperText,
|
|
182
196
|
placeholder: '',
|
|
183
197
|
InputProps: {
|
|
184
198
|
disabled: disabled ?? readOnly,
|
|
185
|
-
endAdornment: _jsx(CalendarIcon, { fill: "#000000a0" }),
|
|
199
|
+
endAdornment: _jsx(CalendarIcon, { fill: "#000000a0", size: 22 }),
|
|
186
200
|
},
|
|
187
201
|
},
|
|
188
|
-
},
|
|
202
|
+
}, slots: {
|
|
189
203
|
day: StyledDay,
|
|
190
204
|
dialog: StyledDialog,
|
|
191
205
|
toolbar: StyledDateToolBar,
|
|
@@ -2,7 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import parse from 'libphonenumber-js/max';
|
|
4
4
|
import { defaultCountries, FlagImage, parseCountry, usePhoneInput } from 'react-international-phone';
|
|
5
|
-
import { useAppSelector } from '../../hooks';
|
|
6
5
|
import isoCountries from 'i18n-iso-countries';
|
|
7
6
|
import es from 'i18n-iso-countries/langs/es.json';
|
|
8
7
|
import { InputAdornment, Select, styled } from '@mui/material';
|
|
@@ -30,12 +29,11 @@ const StyledSelect = styled(Select)(({ theme }) => ({
|
|
|
30
29
|
borderBottom: 'none',
|
|
31
30
|
},
|
|
32
31
|
}));
|
|
33
|
-
function CustomPhoneInput({ value, onChange, inputRef, readOnly = false, disabled = false, ...others }) {
|
|
34
|
-
const defaultCountry = useAppSelector((state) => state.global.countryCode);
|
|
32
|
+
function CustomPhoneInput({ value, onChange, inputRef, readOnly = false, disabled = false, defaultCountry, ...others }) {
|
|
35
33
|
const { inputValue, handlePhoneValueChange, inputRef: phoneRef, country, setCountry, } = usePhoneInput({
|
|
36
34
|
value: '+' + value,
|
|
37
35
|
inputRef,
|
|
38
|
-
defaultCountry: defaultCountry.toLowerCase(),
|
|
36
|
+
defaultCountry: (defaultCountry ?? 'CO').toLowerCase(),
|
|
39
37
|
disableDialCodePrefill: true,
|
|
40
38
|
disableDialCodeAndPrefix: true,
|
|
41
39
|
onChange: (data) => onChange(data.phone.replace('+', '')),
|
|
@@ -49,7 +47,7 @@ function CustomPhoneInput({ value, onChange, inputRef, readOnly = false, disable
|
|
|
49
47
|
};
|
|
50
48
|
})
|
|
51
49
|
.sort((a, b) => a.name.localeCompare(b.name)), []);
|
|
52
|
-
return (_jsx("div", { style: { position: 'relative', width: '100%', maxWidth: '100%' }, children: _jsx(StyledTextField, { ...others, value: inputValue, readOnly: readOnly, disabled: disabled, fullWidth: true,
|
|
50
|
+
return (_jsx("div", { style: { position: 'relative', width: '100%', maxWidth: '100%' }, children: _jsx(StyledTextField, { ...others, value: inputValue, readOnly: readOnly, disabled: disabled, fullWidth: true, variant: "outlined", onChange: handlePhoneValueChange, type: "tel", padding: "6px 12px 6px 6px", autoComplete: "tel", inputRef: phoneRef, onPaste: (e) => {
|
|
53
51
|
const value = e.clipboardData.getData('Text');
|
|
54
52
|
if (!value.startsWith('+')) {
|
|
55
53
|
const phone = parse('+' + value);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OutlinedTextFieldProps as MuiTextFieldProps } from '@mui/material';
|
|
2
2
|
import React, { CSSProperties } from 'react';
|
|
3
3
|
interface StyleProps {
|
|
4
|
+
fontSize?: CSSProperties['fontSize'];
|
|
4
5
|
padding?: CSSProperties['padding'];
|
|
5
6
|
readOnly?: boolean;
|
|
6
7
|
}
|
|
@@ -10,10 +11,10 @@ export declare const StyledTextField: import("@emotion/styled").StyledComponent<
|
|
|
10
11
|
export type ErkTextFieldSlotProps = Omit<ErkTextFieldProps, 'value' | 'onChange'>;
|
|
11
12
|
export interface ErkTextFieldProps extends Omit<MuiTextFieldProps, 'variant' | 'onChange'>, StyleProps {
|
|
12
13
|
/** The value of the textfield */
|
|
13
|
-
value?: string;
|
|
14
|
+
value?: string | number;
|
|
14
15
|
onChange?: (value: string) => void;
|
|
15
16
|
/** The icon to display */
|
|
16
|
-
IconComponent?: React.ElementType;
|
|
17
|
+
IconComponent?: React.ElementType | React.ReactNode;
|
|
17
18
|
/** The max length of the string */
|
|
18
19
|
maxLength?: number;
|
|
19
20
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { styled, TextField as MuiTextField, } from '@mui/material';
|
|
2
|
+
import { styled, TextField as MuiTextField, useTheme, } from '@mui/material';
|
|
3
3
|
import React, { useCallback, useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
export const StyledTextField = styled(MuiTextField)(({ theme, padding = '6px 12px', ...props }) => ({
|
|
4
|
+
export const StyledTextField = styled(MuiTextField)(({ theme, label, size, fontSize = '1rem', padding = '6px 12px', ...props }) => ({
|
|
6
5
|
borderRadius: 10,
|
|
7
6
|
opacity: props.disabled ? 0.5 : 1,
|
|
8
|
-
|
|
7
|
+
marginTop: label ? 5 : undefined,
|
|
8
|
+
minHeight: size === 'small' ? 31 : size === 'medium' ? 40 : undefined,
|
|
9
9
|
'& input, textarea': {
|
|
10
|
+
fontSize,
|
|
10
11
|
cursor: props.disabled || props.readOnly ? 'default' : 'text',
|
|
11
12
|
padding,
|
|
12
13
|
fontWeight: 400,
|
|
13
14
|
color: theme.palette.text.primary,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
height: '1.188em', //Esto.
|
|
15
|
+
lineHeight: size === 'small' ? '1.188em' : size === 'medium' ? '1.75em' : undefined,
|
|
16
|
+
height: size === 'small' ? '1.188em' : size === 'medium' ? '1.75em' : undefined,
|
|
17
17
|
borderRadius: 10,
|
|
18
18
|
},
|
|
19
19
|
'& .Erk-MuiFormLabel-root:not(.Erk-MuiInputLabel-shrink)': {
|
|
20
|
-
transform:
|
|
20
|
+
transform: `translate(12px, ${size === 'small' ? 5 : 9}px) scale(1)`,
|
|
21
21
|
},
|
|
22
22
|
'& label': {
|
|
23
23
|
color: theme.palette.text.primary + '8a',
|
|
@@ -56,6 +56,7 @@ export const StyledTextField = styled(MuiTextField)(({ theme, padding = '6px 12p
|
|
|
56
56
|
position: 'relative',
|
|
57
57
|
marginRight: props.maxLength ? 40 : 14,
|
|
58
58
|
overflow: 'hidden',
|
|
59
|
+
minHeight: 20,
|
|
59
60
|
textOverflow: 'ellipsis',
|
|
60
61
|
},
|
|
61
62
|
'& .Erk-MuiFormHelperText-root.Mui-error': {
|
|
@@ -65,37 +66,41 @@ export const StyledTextField = styled(MuiTextField)(({ theme, padding = '6px 12p
|
|
|
65
66
|
padding: 0,
|
|
66
67
|
},
|
|
67
68
|
'& .Erk-MuiInputAdornment-root': {
|
|
68
|
-
paddingTop: 2,
|
|
69
|
+
paddingTop: size === 'small' ? 2 : 0,
|
|
69
70
|
marginRight: 0,
|
|
70
71
|
},
|
|
71
72
|
}));
|
|
72
|
-
function CustomTextfield({ value = '',
|
|
73
|
+
function CustomTextfield({ onChange, value = '', IconComponent, size = 'small', ...others }) {
|
|
73
74
|
const { readOnly, disabled, maxLength } = others;
|
|
74
|
-
const {
|
|
75
|
+
const { palette } = useTheme();
|
|
75
76
|
const handleChange = useCallback((event) => {
|
|
76
77
|
onChange?.(event.target.value);
|
|
77
78
|
}, [onChange]);
|
|
78
79
|
const inputProps = useMemo(() => ({
|
|
80
|
+
...others.inputProps,
|
|
79
81
|
spellCheck: true,
|
|
80
82
|
endAdornment: IconComponent,
|
|
81
83
|
disabled: !!readOnly || !!disabled,
|
|
82
|
-
}), [
|
|
83
|
-
const length = maxLength ? value?.length : null;
|
|
84
|
+
}), [others.inputProps, IconComponent, readOnly, disabled]);
|
|
85
|
+
const length = maxLength ? value.toString()?.length : null;
|
|
84
86
|
if (maxLength) {
|
|
85
87
|
inputProps.inputProps = { maxLength };
|
|
86
88
|
}
|
|
87
|
-
|
|
89
|
+
const helperText = others.helperText ?? (others.error === false ? ' ' : undefined);
|
|
90
|
+
return (_jsxs("div", { style: { position: 'relative', width: '100%', maxWidth: '100%' }, children: [_jsx(StyledTextField, { ...others, value: value, fullWidth: true, size: size, helperText: helperText, variant: "outlined", onChange: handleChange, slotProps: { input: inputProps } }), length !== null && (_jsxs("div", { style: helperText
|
|
88
91
|
? {
|
|
89
92
|
position: 'absolute',
|
|
90
93
|
bottom: '3px',
|
|
91
94
|
right: '8px',
|
|
95
|
+
minHeight: '20px',
|
|
92
96
|
fontSize: '12px',
|
|
93
|
-
color:
|
|
97
|
+
color: palette.helperText.primary,
|
|
94
98
|
}
|
|
95
99
|
: {
|
|
96
100
|
fontSize: '12px',
|
|
97
|
-
color:
|
|
101
|
+
color: palette.helperText.primary,
|
|
98
102
|
textAlign: 'right',
|
|
103
|
+
minHeight: '20px',
|
|
99
104
|
paddingRight: '8px',
|
|
100
105
|
paddingTop: '2px',
|
|
101
106
|
paddingBottom: '2px',
|
package/dist/index.css
CHANGED
package/package.json
CHANGED