@arquimedes.co/eureka-forms 3.0.5-refactor → 3.0.7-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.
@@ -10,7 +10,6 @@ import { isEmptyPhoneNumber, isValidPhoneNumber } from '../../../Utils/PhoneFunc
10
10
  function PhoneInputStep({ step, editable, defaultValue = step.defaultValue }) {
11
11
  const currentBreakPoint = useAppSelector(selectBreakPoint);
12
12
  const postview = useAppSelector((state) => state.global.postview);
13
- const defaultCountry = useAppSelector((state) => state.global.countryCode);
14
13
  const form = useContext(FormContext);
15
14
  const { ref, value, onChange, error, field } = useFormStep(step, {
16
15
  defaultValue: defaultValue ?? '',
@@ -29,6 +28,6 @@ function PhoneInputStep({ step, editable, defaultValue = step.defaultValue }) {
29
28
  return (_jsx("div", { className: styles.container, style: {
30
29
  width: currentBreakPoint <= step.size ? '100%' : calcStepWidth(step.size, form.size),
31
30
  minHeight: step.description || (!postview && editable) ? '55px' : '43px',
32
- }, children: _jsx(ErkPhoneInput, { ...field, value: value, inputRef: ref, error: !!error, label: step.label, onChange: onChange, "data-testid": step.id, required: step.required, defaultCountry: defaultCountry, readOnly: !editable || postview, helperText: error?.message ?? step.description }) }));
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 }) }));
33
32
  }
34
33
  export default PhoneInputStep;
@@ -77,6 +77,10 @@ const StyledDialog = styled(MuiDialog)(({ theme }) => ({
77
77
  borderRadius: '5px',
78
78
  backgroundColor: 'transparent',
79
79
  },
80
+ '& .Erk-MuiPickersLayout-root': {
81
+ display: 'flex',
82
+ flexDirection: 'column',
83
+ },
80
84
  '& .Erk-MuiDialogActions-root': {
81
85
  '& .Erk-MuiButtonBase-root': { fontWeight: 700 },
82
86
  },
@@ -98,7 +102,7 @@ const StyledDay = styled(MuiPickerDay)(({ theme }) => ({
98
102
  }));
99
103
  function CustomDatePicker({ error, required, disabled, readOnly, helperText, size = 'small', pickTime = false, ...others }) {
100
104
  if (pickTime) {
101
- return (_jsx(StyledDateTimePicker, { ampm: true, ...others, disabled: disabled ?? readOnly, defaultValue: required ? new Date() : undefined, showDaysOutsideCurrentMonth: true, slotProps: {
105
+ return (_jsx(StyledDateTimePicker, { ampm: true, reduceAnimations: true, ...others, disabled: disabled ?? readOnly, defaultValue: required ? new Date() : undefined, showDaysOutsideCurrentMonth: true, slotProps: {
102
106
  actionBar: {
103
107
  actions: ['clear', 'accept'],
104
108
  },
@@ -159,7 +163,7 @@ function CustomDatePicker({ error, required, disabled, readOnly, helperText, siz
159
163
  } }));
160
164
  }
161
165
  else {
162
- return (_jsx(StyledDatePicker, { ...others, readOnly: readOnly, disabled: disabled ?? readOnly, defaultValue: required ? new Date() : undefined, showDaysOutsideCurrentMonth: true, views: ['year', 'month', 'day'], slotProps: {
166
+ return (_jsx(StyledDatePicker, { ...others, reduceAnimations: true, readOnly: readOnly, disabled: disabled ?? readOnly, defaultValue: required ? new Date() : undefined, showDaysOutsideCurrentMonth: true, views: ['year', 'month', 'day'], slotProps: {
163
167
  actionBar: {
164
168
  actions: ['clear', 'accept'],
165
169
  },
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import { TextFieldProps as MuiTextFieldProps } from '@mui/material';
3
- interface ErkPhoneInputProps {
3
+ import { ErkTextFieldProps } from '../ErkTextField/ErkTextField';
4
+ export interface ErkPhoneInputProps extends Omit<ErkTextFieldProps, 'onChange' | 'ref'> {
4
5
  /** The value of the phoneinput */
5
6
  value?: string;
6
7
  onChange: (value: string) => void;
7
8
  inputRef?: any;
8
9
  readOnly?: boolean;
9
- defaultCountry: string;
10
10
  }
11
11
  /**
12
12
  * Generic phoneinput with apps designs. Is class due to the use in the react-hook-forms library
@@ -7,8 +7,9 @@ import es from 'i18n-iso-countries/langs/es.json';
7
7
  import { InputAdornment, Select, styled } from '@mui/material';
8
8
  import { MenuItem } from '@mui/material';
9
9
  import { StyledTextField } from '../ErkTextField/ErkTextField';
10
+ import { useAppSelector } from '../../hooks';
10
11
  isoCountries.registerLocale(es);
11
- const StyledSelect = styled(Select)(({ theme }) => ({
12
+ const StyledSelect = styled(Select)(() => ({
12
13
  padding: 0,
13
14
  input: {
14
15
  padding: 0,
@@ -17,7 +18,7 @@ const StyledSelect = styled(Select)(({ theme }) => ({
17
18
  paddingBottom: 0,
18
19
  borderBottom: 'none',
19
20
  },
20
- backgroundColor: theme.palette.stepBackgroundColor.default,
21
+ backgroundColor: 'transparent',
21
22
  '& input': {
22
23
  padding: 0,
23
24
  margin: 0,
@@ -29,7 +30,8 @@ const StyledSelect = styled(Select)(({ theme }) => ({
29
30
  borderBottom: 'none',
30
31
  },
31
32
  }));
32
- function CustomPhoneInput({ value, onChange, inputRef, readOnly = false, disabled = false, defaultCountry, ...others }) {
33
+ function CustomPhoneInput({ value, onChange, inputRef, size = 'small', readOnly = false, disabled = false, ...others }) {
34
+ const defaultCountry = useAppSelector((state) => state.global.countryCode);
33
35
  const { inputValue, handlePhoneValueChange, inputRef: phoneRef, country, setCountry, } = usePhoneInput({
34
36
  value: '+' + value,
35
37
  inputRef,
@@ -47,7 +49,7 @@ function CustomPhoneInput({ value, onChange, inputRef, readOnly = false, disable
47
49
  };
48
50
  })
49
51
  .sort((a, b) => a.name.localeCompare(b.name)), []);
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) => {
52
+ return (_jsx("div", { style: { position: 'relative', width: '100%', maxWidth: '100%' }, children: _jsx(StyledTextField, { ...others, value: inputValue, readOnly: readOnly, disabled: disabled, fullWidth: true, size: size, variant: "outlined", onChange: handlePhoneValueChange, type: "tel", padding: "6px 12px 6px 6px", autoComplete: "tel", inputRef: phoneRef, onPaste: (e) => {
51
53
  const value = e.clipboardData.getData('Text');
52
54
  if (!value.startsWith('+')) {
53
55
  const phone = parse('+' + value);
@@ -60,8 +62,9 @@ function CustomPhoneInput({ value, onChange, inputRef, readOnly = false, disable
60
62
  }
61
63
  }, slotProps: {
62
64
  input: {
65
+ readOnly,
63
66
  disabled: readOnly || disabled,
64
- startAdornment: (_jsx(InputAdornment, { position: "start", children: _jsx(StyledSelect, { size: "small", variant: "standard", value: country.iso2, inputProps: { 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 }) => {
67
+ startAdornment: (_jsx(InputAdornment, { position: "start", children: _jsx(StyledSelect, { size: size, variant: "standard", 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 }) => {
65
68
  return (_jsxs(MenuItem, { value: country.iso2, children: [_jsx(FlagImage, { iso2: country.iso2, size: 20 }), _jsx("span", { style: {
66
69
  marginLeft: '8px',
67
70
  marginRight: '8px',
@@ -4,7 +4,7 @@ export interface SelectorStyleProps {
4
4
  /** If input is readOnly */
5
5
  readOnly?: boolean;
6
6
  }
7
- export declare const StyledSelect: import("@emotion/styled").StyledComponent<MuiSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
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
10
  }, "required" | "size" | "color" | "children" | "className" | "style" | "classes" | "disabled" | "error" | "margin" | "sx" | "filled" | "variant" | "focused" | "disableAnimation" | "shrink"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
@@ -1,20 +1,21 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { useState } from 'react';
3
3
  import { FormControl, FormHelperText as MuiFormHelperText, InputLabel as MuiInputLabel, Select as MuiSelect, styled, InputAdornment, } from '@mui/material';
4
- export const StyledSelect = styled(MuiSelect)(({ theme, ...props }) => ({
4
+ export const StyledSelect = styled(MuiSelect)(({ theme, size, ...props }) => ({
5
5
  borderRadius: 10,
6
6
  opacity: props.disabled ? 0.5 : 1,
7
7
  backgroundColor: theme.palette.background.default,
8
+ minHeight: size === 'small' ? 31 : size === 'medium' ? 40 : undefined,
8
9
  '&.Erk-MuiInputBase-adornedEnd': {
9
10
  paddingRight: 7,
10
11
  },
11
12
  '& .Erk-MuiSelect-select': {
12
13
  fontSize: '1rem',
13
14
  padding: '6px 12px',
14
- lineHeight: '1.188em',
15
- height: '1.188em',
15
+ lineHeight: size === 'small' ? '1.188em' : size === 'medium' ? '1.75em' : undefined,
16
+ height: size === 'small' ? '1.188em' : size === 'medium' ? '1.75em' : undefined,
16
17
  '&.Erk-MuiInputBase-inputAdornedEnd': {
17
- paddingRight: 0,
18
+ paddingRight: '0px !important',
18
19
  },
19
20
  whiteSpace: 'nowrap',
20
21
  overflow: 'hidden',
@@ -39,18 +40,20 @@ export const StyledSelect = styled(MuiSelect)(({ theme, ...props }) => ({
39
40
  '& .Erk-MuiInputAdornment-root': {
40
41
  marginLeft: 0,
41
42
  color: theme.palette.text.primary + 'a0',
43
+ fill: theme.palette.text.primary + 'a0',
44
+ cursor: props.disabled || props.readOnly ? 'default' : 'pointer',
42
45
  },
43
46
  '& .Erk-MuiSelect-iconOpen': {
44
47
  transform: props.IconComponent ? 'none' : undefined,
45
48
  },
46
49
  }));
47
- export const StyledInputLabel = styled(MuiInputLabel)(({ theme, ...props }) => ({
50
+ export const StyledInputLabel = styled(MuiInputLabel)(({ theme, size = 'small', ...props }) => ({
48
51
  color: theme.palette.text.primary + '8a',
49
52
  '&.Erk-MuiInputLabel-root.Mui-focused': {
50
53
  color: theme.palette.primary.main,
51
54
  },
52
55
  '&.Erk-MuiFormLabel-root:not(.Erk-MuiInputLabel-shrink)': {
53
- transform: 'translate(12px, 5px) scale(1)',
56
+ transform: `translate(12px, ${size === 'small' ? 5 : 9}px) scale(1)`,
54
57
  maxWidth: 'calc(100% - 40px)',
55
58
  },
56
59
  '&.Mui-error': {
@@ -25,4 +25,4 @@ export interface ErkSmartSelectProps extends Omit<MuiSelectProps, 'ref' | 'onInv
25
25
  readOnly?: boolean;
26
26
  onFocus?: React.FocusEventHandler;
27
27
  }
28
- export default function ErkSmartSelect({ options, value, onChange, label, getValueString, loading, getOptionSelected, IconComponent, disabled, readOnly, searchable, inputRef, ...others }: ErkSmartSelectProps): JSX.Element;
28
+ export default function ErkSmartSelect({ options, value, onChange, label, getValueString, loading, getOptionSelected, IconComponent, size, disabled, readOnly, searchable, inputRef, ...others }: ErkSmartSelectProps): JSX.Element;
@@ -23,9 +23,9 @@ const StyledAutoComplete = styled(MuiAutocomplete)(({ theme, ...props }) => ({
23
23
  transform: props.popupIcon ? 'none' : undefined,
24
24
  },
25
25
  }));
26
- export default function ErkSmartSelect({ options, value = '', onChange, label, getValueString = (value) => value?.value, loading = false, getOptionSelected, IconComponent, disabled = false, readOnly = false, searchable = false, inputRef, ...others }) {
26
+ export default function ErkSmartSelect({ options, value = '', onChange, label, getValueString = (value) => value?.value, loading = false, getOptionSelected, IconComponent, size = 'small', disabled = false, readOnly = false, searchable = false, inputRef, ...others }) {
27
27
  if (searchable) {
28
- return (_jsx(StyledAutoComplete, { fullWidth: true, openOnFocus: true, loading: loading, options: options ?? [], loadingText: "Cargando...", onFocus: others.onFocus, "data-testid": "smart-select", noOptionsText: "No hay opciones", disabled: readOnly || disabled, value: !loading && value ? value : null, onChange: (_event, newValue) => onChange?.(newValue), popupIcon: loading ? _jsx(CircularProgress, { size: 22 }) : IconComponent ? _jsx(IconComponent, {}) : undefined, filterOptions: (options, params) => {
28
+ return (_jsx(StyledAutoComplete, { fullWidth: true, openOnFocus: true, size: size, loading: loading, options: options ?? [], loadingText: "Cargando...", onFocus: others.onFocus, "data-testid": "smart-select", noOptionsText: "No hay opciones", disabled: readOnly || disabled, value: !loading && value ? value : null, onChange: (_event, newValue) => onChange?.(newValue), popupIcon: loading ? _jsx(CircularProgress, { size: 22 }) : IconComponent ? _jsx(IconComponent, {}) : undefined, filterOptions: (options, params) => {
29
29
  if (value && value.label === params?.inputValue) {
30
30
  return options;
31
31
  }
@@ -48,7 +48,7 @@ export default function ErkSmartSelect({ options, value = '', onChange, label, g
48
48
  popper: {
49
49
  sx: { zIndex: 1305 },
50
50
  },
51
- }, renderInput: (params) => (_jsx(StyledTextField, { ...params, label: label, name: others.name, readOnly: readOnly, disabled: disabled, inputRef: inputRef, error: others.error, onBlur: others.onBlur, required: others.required, helperText: others.helperText })) }));
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
52
  }
53
53
  else {
54
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(MenuItem, { value: '', "data-testid": 'smart-select-empty', style: { whiteSpace: 'normal' }, children: _jsx("em", { children: options ? 'Sin Seleccionar' : 'Cargando...' }) }, 'EMPTY'), options?.map((option) => (_jsx(MenuItem, { value: getValueString(option), style: { whiteSpace: 'normal' }, "data-testid": 'smart-select-' + getValueString(option), children: option.label }, getValueString(option)))), options === undefined && value && !loading && (_jsx(MenuItem, { value: getValueString(value), style: { whiteSpace: 'normal' }, children: value.label ?? '' }, getValueString(value)))] }));
@@ -1,10 +1,9 @@
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)(({ theme, label, size, fontSize = '1rem', padding = '6px 12px', ...props }) => ({
4
+ export const StyledTextField = styled(MuiTextField)(({ theme, size, fontSize = '1rem', padding = '6px 12px', ...props }) => ({
5
5
  borderRadius: 10,
6
6
  opacity: props.disabled ? 0.5 : 1,
7
- marginTop: label ? 5 : undefined,
8
7
  minHeight: size === 'small' ? 31 : size === 'medium' ? 40 : undefined,
9
8
  '& input, textarea': {
10
9
  fontSize,
@@ -5,11 +5,13 @@ declare module '@mui/material/styles' {
5
5
  interface Palette {
6
6
  outline: Palette['primary'];
7
7
  helperText: Palette['text'];
8
+ greyBtn: Palette['primary'];
8
9
  stepBackgroundColor: Palette['background'];
9
10
  }
10
11
  interface PaletteOptions {
11
12
  outline: PaletteOptions['primary'];
12
13
  helperText: PaletteOptions['text'];
14
+ greyBtn: PaletteOptions['primary'];
13
15
  stepBackgroundColor: PaletteOptions['background'];
14
16
  }
15
17
  }
@@ -25,6 +25,10 @@ function MaterialProviders({ children, formStyle }) {
25
25
  outline: {
26
26
  main: formStyle.outlineColor,
27
27
  },
28
+ greyBtn: {
29
+ main: '#d6d6d6',
30
+ contrastText: '#293241',
31
+ },
28
32
  helperText: {
29
33
  primary: formStyle.descriptionTextColor,
30
34
  },
@@ -4,11 +4,3 @@ import * as StepFunctions from './FormSteps/StepFunctions';
4
4
  export type { StepProps, EurekaFormProps };
5
5
  export { EurekaForm, StepFunctions };
6
6
  export default EurekaForm;
7
- export { default as ReactFromModule } from 'react';
8
- import ErkDatePicker from './Shared/ErkDatePicker/ErkDatePicker';
9
- import ErkPhoneInput from './Shared/ErkPhoneInput/EkrPhoneInput';
10
- import ErkTextField from './Shared/ErkTextField/ErkTextField';
11
- import ErkCheckBox from './Shared/ErkCheckbox/ErkCheckBox';
12
- import ErkSelect from './Shared/ErkSelect/ErkSelect';
13
- import ErkTimePicker from './Shared/ErkTimePicker/ErkTimePicker';
14
- export { ErkDatePicker, ErkPhoneInput, ErkTextField, ErkCheckBox, ErkSelect, ErkTimePicker };
package/dist/index.lib.js CHANGED
@@ -2,11 +2,3 @@ import EurekaForm from './App/App';
2
2
  import * as StepFunctions from './FormSteps/StepFunctions';
3
3
  export { EurekaForm, StepFunctions };
4
4
  export default EurekaForm;
5
- export { default as ReactFromModule } from 'react';
6
- import ErkDatePicker from './Shared/ErkDatePicker/ErkDatePicker';
7
- import ErkPhoneInput from './Shared/ErkPhoneInput/EkrPhoneInput';
8
- import ErkTextField from './Shared/ErkTextField/ErkTextField';
9
- import ErkCheckBox from './Shared/ErkCheckbox/ErkCheckBox';
10
- import ErkSelect from './Shared/ErkSelect/ErkSelect';
11
- import ErkTimePicker from './Shared/ErkTimePicker/ErkTimePicker';
12
- export { ErkDatePicker, ErkPhoneInput, ErkTextField, ErkCheckBox, ErkSelect, ErkTimePicker };
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.5-refactor",
4
+ "version":"3.0.7-refactor",
5
5
  "scripts": {
6
6
  "watch": "tsc --noEmit --watch --project tsconfig.app.json",
7
7
  "start": "vite",