@arquimedes.co/eureka-forms 3.0.6-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.
@@ -1,6 +1,7 @@
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;
@@ -9,7 +9,7 @@ import { MenuItem } from '@mui/material';
9
9
  import { StyledTextField } from '../ErkTextField/ErkTextField';
10
10
  import { useAppSelector } from '../../hooks';
11
11
  isoCountries.registerLocale(es);
12
- const StyledSelect = styled(Select)(({ theme }) => ({
12
+ const StyledSelect = styled(Select)(() => ({
13
13
  padding: 0,
14
14
  input: {
15
15
  padding: 0,
@@ -18,7 +18,7 @@ const StyledSelect = styled(Select)(({ theme }) => ({
18
18
  paddingBottom: 0,
19
19
  borderBottom: 'none',
20
20
  },
21
- backgroundColor: theme.palette.stepBackgroundColor.default,
21
+ backgroundColor: 'transparent',
22
22
  '& input': {
23
23
  padding: 0,
24
24
  margin: 0,
@@ -30,7 +30,7 @@ const StyledSelect = styled(Select)(({ theme }) => ({
30
30
  borderBottom: 'none',
31
31
  },
32
32
  }));
33
- function CustomPhoneInput({ value, onChange, inputRef, readOnly = false, disabled = false, ...others }) {
33
+ function CustomPhoneInput({ value, onChange, inputRef, size = 'small', readOnly = false, disabled = false, ...others }) {
34
34
  const defaultCountry = useAppSelector((state) => state.global.countryCode);
35
35
  const { inputValue, handlePhoneValueChange, inputRef: phoneRef, country, setCountry, } = usePhoneInput({
36
36
  value: '+' + value,
@@ -49,7 +49,7 @@ function CustomPhoneInput({ value, onChange, inputRef, readOnly = false, disable
49
49
  };
50
50
  })
51
51
  .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, 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) => {
53
53
  const value = e.clipboardData.getData('Text');
54
54
  if (!value.startsWith('+')) {
55
55
  const phone = parse('+' + value);
@@ -62,8 +62,9 @@ function CustomPhoneInput({ value, onChange, inputRef, readOnly = false, disable
62
62
  }
63
63
  }, slotProps: {
64
64
  input: {
65
+ readOnly,
65
66
  disabled: readOnly || disabled,
66
- 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 }) => {
67
68
  return (_jsxs(MenuItem, { value: country.iso2, children: [_jsx(FlagImage, { iso2: country.iso2, size: 20 }), _jsx("span", { style: {
68
69
  marginLeft: '8px',
69
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
  },
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.6-refactor",
4
+ "version":"3.0.7-refactor",
5
5
  "scripts": {
6
6
  "watch": "tsc --noEmit --watch --project tsconfig.app.json",
7
7
  "start": "vite",