@arquimedes.co/eureka-forms 1.7.7 → 1.7.9-test

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/App.js CHANGED
@@ -67,6 +67,7 @@ import axiosInstance from './AxiosAPI';
67
67
  import widgetInstance from './AxiosWidget';
68
68
  import InternalFormStyle from './constants/InternalFormStyle';
69
69
  import { calcCbrForm } from './utils/CbrFunctions';
70
+ import CBRStepTypes from './constants/CBRFormStepTypes';
70
71
  function App(_a) {
71
72
  var _this = this;
72
73
  var _b, _c, _d, _e;
@@ -293,6 +294,20 @@ var migrateForm = function (form) {
293
294
  if (step.size && isNaN(step.size)) {
294
295
  step.size = getStaticWidth(step);
295
296
  }
297
+ if (step.type === CBRStepTypes.CBR_EMAIL) {
298
+ step.validation = {
299
+ value: /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
300
+ .source,
301
+ message: 'El correo no es válido',
302
+ };
303
+ }
304
+ else if (step.type === CBRStepTypes.CBR_PHONE ||
305
+ step.type === CBRStepTypes.CBR_CEL) {
306
+ step.validation = {
307
+ value: /^(\+[0-9])|([0-9])$/.source,
308
+ message: 'El teléfono no es válido',
309
+ };
310
+ }
296
311
  steps[idStep] = step;
297
312
  }
298
313
  var newForm = __assign(__assign({}, form), { steps: steps });
@@ -24,6 +24,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
24
  import styles from './Incident.module.css';
25
25
  import StepComponent from '../../../../Step';
26
26
  import DeleteRoundedIcon from '@material-ui/icons/DeleteRounded';
27
+ import TextAreaStep from '../../../../TextAreaStep/TextAreaStep';
27
28
  function IncidentComponent(_a) {
28
29
  var step = _a.step, form = _a.form, level = _a.level, incident = _a.incident, formStyle = _a.formStyle, handleDelete = _a.handleDelete, others = __rest(_a, ["step", "form", "level", "incident", "formStyle", "handleDelete"]);
29
30
  var spaceStep = form.steps[incident.idSpaceStep];
@@ -43,6 +44,6 @@ function IncidentComponent(_a) {
43
44
  if (others.editable && !others.postview) {
44
45
  handleDelete();
45
46
  }
46
- } }, { children: _jsx(DeleteRoundedIcon, { fontSize: "inherit" }, void 0) }), void 0), _jsx(StepComponent, __assign({}, others, { formStyle: formStyle, form: form, step: spaceStep, handleSizeChange: function () { }, level: level + 1 }), void 0), _jsx(StepComponent, __assign({}, others, { form: form, formStyle: formStyle, step: elementStep, handleSizeChange: function () { }, level: level + 1 }), void 0), _jsx(StepComponent, __assign({}, others, { form: form, formStyle: formStyle, step: commentStep, handleSizeChange: function () { }, level: level + 1 }), void 0)] }), void 0) }), void 0));
47
+ } }, { children: _jsx(DeleteRoundedIcon, { fontSize: "inherit" }, void 0) }), void 0), _jsx(StepComponent, __assign({}, others, { formStyle: formStyle, form: form, step: spaceStep, handleSizeChange: function () { }, level: level + 1 }), void 0), _jsx(StepComponent, __assign({}, others, { form: form, formStyle: formStyle, step: elementStep, handleSizeChange: function () { }, level: level + 1 }), void 0), _jsx(TextAreaStep, __assign({}, others, { form: form, backgroundColor: 'transparent', formStyle: formStyle, step: commentStep, maxLength: 200, handleSizeChange: function () { }, level: level + 1 }), void 0)] }), void 0) }), void 0));
47
48
  }
48
49
  export default IncidentComponent;
@@ -3,7 +3,7 @@ import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
3
3
  import './DraftEditor.css';
4
4
  import { RawDraftContentState } from 'draft-js';
5
5
  import { TextAreaStepProps } from '../TextAreaStep';
6
- declare function TextAreaStep({ step, errors, control, editable, postview, formStyle, originalValues, }: TextAreaStepProps): JSX.Element;
6
+ declare function TextAreaStep({ step, errors, control, editable, postview, formStyle, maxLength, originalValues, backgroundColor, }: TextAreaStepProps): JSX.Element;
7
7
  export default TextAreaStep;
8
8
  export declare function stringToDraft(text: string): RawDraftContentState;
9
9
  export declare const getRawText: (draft?: RawDraftContentState | undefined, text?: string | undefined) => RawDraftContentState;
@@ -20,7 +20,7 @@ import { convertFromRaw, EditorState } from 'draft-js';
20
20
  import { useState } from 'react';
21
21
  import { ClickAwayListener } from '@material-ui/core';
22
22
  function TextAreaStep(_a) {
23
- var step = _a.step, errors = _a.errors, control = _a.control, editable = _a.editable, postview = _a.postview, formStyle = _a.formStyle, originalValues = _a.originalValues;
23
+ var step = _a.step, errors = _a.errors, control = _a.control, editable = _a.editable, postview = _a.postview, formStyle = _a.formStyle, maxLength = _a.maxLength, originalValues = _a.originalValues, backgroundColor = _a.backgroundColor;
24
24
  var _b = useState(false), hovering = _b[0], setHovering = _b[1];
25
25
  var _c = useState(false), focus = _c[0], setFocus = _c[1];
26
26
  var calcStyle = function () {
@@ -149,7 +149,7 @@ function TextAreaStep(_a) {
149
149
  }, shouldUnregister: true, render: function (_a) {
150
150
  var _b;
151
151
  var field = _a.field;
152
- return (_jsx(RoundedTextField, __assign({}, field, { "data-testid": step.id, label: step.label, inputRef: field.ref, required: step.required, cantEdit: !canEdit, fontWeight: 400, multiline: true, minRows: 4, maxRows: 6, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, backgroundColor: formStyle.backgroundColor, innerBackgroundColor: formStyle.stepBackgroundColor, helperTextColor: formStyle.descriptionTextColor, helperText: errors[step.id]
152
+ return (_jsx(RoundedTextField, __assign({}, field, { "data-testid": step.id, maxLength: maxLength, label: step.label, inputRef: field.ref, required: step.required, cantEdit: !canEdit, fontWeight: 400, multiline: true, minRows: 4, maxRows: 6, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, textColor: formStyle.textColor, errorColor: formStyle.errorColor, backgroundColor: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : formStyle.backgroundColor, innerBackgroundColor: formStyle.stepBackgroundColor, helperTextColor: formStyle.descriptionTextColor, helperText: errors[step.id]
153
153
  ? errors[step.id].message
154
154
  : (_b = step.description) !== null && _b !== void 0 ? _b : (step.required ? ' ' : null), error: !!errors[step.id] }), void 0));
155
155
  } }, void 0) }), void 0));
@@ -4,6 +4,8 @@ import { StepProps } from '../Step';
4
4
  export interface TextAreaStepProps extends StepProps {
5
5
  /** The TextAreaStep to display */
6
6
  step: TextArea;
7
+ maxLength?: number;
8
+ backgroundColor?: string;
7
9
  }
8
10
  declare function TextAreaStep(props: TextAreaStepProps): JSX.Element;
9
11
  export default TextAreaStep;
@@ -23,8 +23,6 @@ interface StyleProps {
23
23
  fontSize?: number | string;
24
24
  /** The weight of the font of the value and the placeholder */
25
25
  fontWeight?: number | string;
26
- /** The fontsize of the shrunken label */
27
- shrunkenFontSize?: number | string;
28
26
  /** If the input is multiline */
29
27
  multiline?: boolean;
30
28
  /** Cant edit */
@@ -33,8 +31,12 @@ interface StyleProps {
33
31
  helperTextColor?: string;
34
32
  /** The icon to display */
35
33
  icon?: React.ReactNode;
34
+ /** The max length of the string */
35
+ maxLength?: number;
36
36
  }
37
37
  interface RoundedTextFieldProps extends StyleProps {
38
+ /** The value of the textfield */
39
+ value?: any;
38
40
  }
39
41
  /**
40
42
  * Generic textfield with apps designs. Is class do to the use in the react-hook-forms library
@@ -35,7 +35,7 @@ var __rest = (this && this.__rest) || function (s, e) {
35
35
  }
36
36
  return t;
37
37
  };
38
- import { jsx as _jsx } from "react/jsx-runtime";
38
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
39
39
  import React from 'react';
40
40
  import { makeStyles } from '@material-ui/core/styles';
41
41
  import TextField from '@material-ui/core/TextField';
@@ -82,6 +82,9 @@ var useTextfieldStyles = function (props) {
82
82
  },
83
83
  '& .EF-MuiOutlinedInput-notchedOutline': {
84
84
  borderColor: props.outlineColor,
85
+ '& legend': {
86
+ fontSize: 'calc(' + props.fontSize + ' * 0.75)',
87
+ },
85
88
  },
86
89
  },
87
90
  '& .EF-MuiOutlinedInput-root:hover .EF-MuiOutlinedInput-notchedOutline': {
@@ -100,12 +103,17 @@ var useTextfieldStyles = function (props) {
100
103
  },
101
104
  '& .EF-MuiFormHelperText-root': {
102
105
  color: props.helperTextColor,
106
+ marginRight: props.maxLength ? 40 : 14,
107
+ },
108
+ '& .EF-MuiOutlinedInput-multiline': {
109
+ padding: props.padding,
110
+ backgroundColor: props.innerBackgroundColor,
103
111
  },
104
112
  },
105
113
  }); });
106
114
  };
107
115
  function CustomTextfield(_a) {
108
- var _b = _a.focusColor, focusColor = _b === void 0 ? '#3d5a7f' : _b, _c = _a.helperTextColor, helperTextColor = _c === void 0 ? '#989898' : _c, _d = _a.outlineColor, outlineColor = _d === void 0 ? '#0000003b' : _d, _e = _a.backgroundColor, backgroundColor = _e === void 0 ? 'white' : _e, innerBackgroundColor = _a.innerBackgroundColor, _f = _a.textColor, textColor = _f === void 0 ? '#293241' : _f, _g = _a.readOnly, readOnly = _g === void 0 ? false : _g, _h = _a.borderRadius, borderRadius = _h === void 0 ? 10 : _h, _j = _a.padding, padding = _j === void 0 ? '6px 12px' : _j, _k = _a.fontSize, fontSize = _k === void 0 ? '1rem' : _k, _l = _a.shrunkenFontSize, shrunkenFontSize = _l === void 0 ? '1rem' : _l, _m = _a.errorColor, errorColor = _m === void 0 ? '#cc2936' : _m, _o = _a.fontWeight, fontWeight = _o === void 0 ? '300' : _o, _p = _a.multiline, multiline = _p === void 0 ? false : _p, _q = _a.cantEdit, cantEdit = _q === void 0 ? false : _q, inputProps = _a.inputProps, value = _a.value, icon = _a.icon, others = __rest(_a, ["focusColor", "helperTextColor", "outlineColor", "backgroundColor", "innerBackgroundColor", "textColor", "readOnly", "borderRadius", "padding", "fontSize", "shrunkenFontSize", "errorColor", "fontWeight", "multiline", "cantEdit", "inputProps", "value", "icon"]);
116
+ var _b = _a.focusColor, focusColor = _b === void 0 ? '#3d5a7f' : _b, _c = _a.helperTextColor, helperTextColor = _c === void 0 ? '#989898' : _c, _d = _a.outlineColor, outlineColor = _d === void 0 ? '#0000003b' : _d, _e = _a.backgroundColor, backgroundColor = _e === void 0 ? 'transparent' : _e, _f = _a.innerBackgroundColor, innerBackgroundColor = _f === void 0 ? 'white' : _f, _g = _a.textColor, textColor = _g === void 0 ? '#293241' : _g, _h = _a.readOnly, readOnly = _h === void 0 ? false : _h, _j = _a.borderRadius, borderRadius = _j === void 0 ? 10 : _j, _k = _a.padding, padding = _k === void 0 ? '6px 12px' : _k, _l = _a.fontSize, fontSize = _l === void 0 ? '1rem' : _l, _m = _a.errorColor, errorColor = _m === void 0 ? '#cc2936' : _m, _o = _a.fontWeight, fontWeight = _o === void 0 ? '300' : _o, _p = _a.multiline, multiline = _p === void 0 ? false : _p, _q = _a.cantEdit, cantEdit = _q === void 0 ? false : _q, maxLength = _a.maxLength, value = _a.value, icon = _a.icon, others = __rest(_a, ["focusColor", "helperTextColor", "outlineColor", "backgroundColor", "innerBackgroundColor", "textColor", "readOnly", "borderRadius", "padding", "fontSize", "errorColor", "fontWeight", "multiline", "cantEdit", "maxLength", "value", "icon"]);
109
117
  var classes = useTextfieldStyles({
110
118
  padding: padding,
111
119
  textColor: textColor,
@@ -118,17 +126,36 @@ function CustomTextfield(_a) {
118
126
  borderRadius: borderRadius,
119
127
  readOnly: readOnly,
120
128
  fontSize: fontSize,
121
- shrunkenFontSize: shrunkenFontSize,
122
129
  fontWeight: fontWeight,
123
130
  multiline: multiline,
124
131
  cantEdit: cantEdit,
132
+ maxLength: maxLength,
125
133
  })();
126
- return (_jsx(TextField, __assign({ classes: classes }, others, { value: value !== null && value !== void 0 ? value : '', multiline: multiline, variant: "outlined", size: "small", fullWidth: true, InputProps: {
127
- readOnly: readOnly,
128
- disabled: cantEdit,
129
- inputProps: inputProps,
130
- endAdornment: icon,
131
- } }), void 0));
134
+ var length = maxLength ? value.length : null;
135
+ var inputProps = {
136
+ readOnly: readOnly,
137
+ disabled: cantEdit,
138
+ endAdornment: icon,
139
+ };
140
+ if (maxLength) {
141
+ inputProps.inputProps = { maxLength: maxLength };
142
+ }
143
+ return (_jsxs("div", __assign({ style: { position: 'relative', width: '100%', maxWidth: '100%' } }, { children: [_jsx(TextField, __assign({ classes: classes }, others, { value: value !== null && value !== void 0 ? value : '', multiline: multiline, variant: "outlined", size: "small", fullWidth: true, InputProps: inputProps }), void 0), length !== null && (_jsxs("div", __assign({ style: others.helperText
144
+ ? {
145
+ position: 'absolute',
146
+ bottom: '3px',
147
+ right: '8px',
148
+ fontSize: '12px',
149
+ color: helperTextColor,
150
+ }
151
+ : {
152
+ fontSize: '12px',
153
+ color: helperTextColor,
154
+ textAlign: 'right',
155
+ paddingRight: '8px',
156
+ paddingTop: '2px',
157
+ paddingBottom: '2px',
158
+ } }, { children: [length, "/", maxLength] }), void 0))] }), void 0));
132
159
  }
133
160
  /**
134
161
  * Generic textfield with apps designs. Is class do to the use in the react-hook-forms library
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": "1.7.7",
4
+ "version":"1.7.9-test",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",