@arquimedes.co/eureka-forms 1.6.1-test → 1.6.3-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.
Files changed (24) hide show
  1. package/dist/@Types/Form.d.ts +1 -1
  2. package/dist/@Types/FormStep.d.ts +11 -2
  3. package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +1 -1
  4. package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +24 -16
  5. package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/MaterialRatingStep.d.ts +4 -0
  6. package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/MaterialRatingStep.js +38 -0
  7. package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/MaterialRatingStep.module.css +30 -0
  8. package/dist/FormComponents/Step/RatingStep/RatingStep.d.ts +9 -0
  9. package/dist/FormComponents/Step/RatingStep/RatingStep.js +25 -0
  10. package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +8 -7
  11. package/dist/FormComponents/Step/Step.js +4 -0
  12. package/dist/constants/FormStepTypes.d.ts +6 -0
  13. package/dist/constants/FormStepTypes.js +7 -0
  14. package/dist/shared/Rating/Rating.d.ts +15 -0
  15. package/dist/shared/Rating/Rating.js +41 -0
  16. package/dist/shared/Rating/Rating.module.css +32 -0
  17. package/dist/shared/Rating/Ratings/LikeRating.d.ts +4 -0
  18. package/dist/shared/Rating/Ratings/LikeRating.js +43 -0
  19. package/dist/shared/Rating/Ratings/SatisfactionRating.d.ts +4 -0
  20. package/dist/shared/Rating/Ratings/SatisfactionRating.js +61 -0
  21. package/dist/shared/Rating/Ratings/ScaleRating.d.ts +4 -0
  22. package/dist/shared/Rating/Ratings/ScaleRating.js +63 -0
  23. package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.js +8 -5
  24. package/package.json +1 -1
@@ -60,7 +60,7 @@ export interface MaterialStyle {
60
60
  descriptionTextColor: string;
61
61
  }
62
62
  export interface Section {
63
- _id: string;
63
+ id: string;
64
64
  name: string;
65
65
  title?: string;
66
66
  steps: string[];
@@ -1,6 +1,6 @@
1
- import Types, { ClassifierOptionTypes, OptionTypes } from '../constants/FormStepTypes';
1
+ import Types, { ClassifierOptionTypes, OptionTypes, RatingTypes } from '../constants/FormStepTypes';
2
2
  import * as GSteps from './GenericFormSteps';
3
- export declare type FormStep = Title | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector;
3
+ export declare type FormStep = Title | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector;
4
4
  export interface Title extends GSteps.GBaseStep {
5
5
  type: Types.TITLE;
6
6
  title: string;
@@ -9,6 +9,13 @@ export interface Title extends GSteps.GBaseStep {
9
9
  export interface CheckBox extends GSteps.GCheckBox {
10
10
  type: Types.CHECKBOX;
11
11
  }
12
+ export interface Rating extends GSteps.GBaseStep {
13
+ type: Types.RATING;
14
+ label: string;
15
+ description: string;
16
+ required: boolean;
17
+ ratingType: RatingTypes;
18
+ }
12
19
  export interface FileUpload extends GSteps.GBaseStep {
13
20
  type: Types.FILEUPLOAD;
14
21
  label: string;
@@ -33,6 +40,7 @@ export interface FormSelector extends GSteps.GBaseStep {
33
40
  label: string;
34
41
  description: string;
35
42
  required: boolean;
43
+ searchable: boolean;
36
44
  options: FormSelectorOption[];
37
45
  size: 1 | 2 | 3 | 4;
38
46
  maxSize: number;
@@ -60,6 +68,7 @@ export interface ClassifierSelector extends GSteps.GBaseStep {
60
68
  idClassifier: string | null;
61
69
  label: string;
62
70
  description: string;
71
+ searchable: boolean;
63
72
  options: Record<string, FormClassifierSelectorOption>;
64
73
  required: boolean;
65
74
  size: 1 | 2 | 3 | 4;
@@ -95,7 +95,7 @@ function ColumnForm(_a) {
95
95
  return __generator(this, function (_c) {
96
96
  switch (_c.label) {
97
97
  case 0:
98
- if (!(apiKey || internal)) return [3 /*break*/, 11];
98
+ if (!(apiKey || internal || customSend)) return [3 /*break*/, 11];
99
99
  return [4 /*yield*/, trigger(undefined, { shouldFocus: true })];
100
100
  case 1:
101
101
  valid = _c.sent();
@@ -24,12 +24,11 @@ import { createElement as _createElement } from "react";
24
24
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
25
  import React, { useState } from 'react';
26
26
  import { ClassifierOptionTypes } from '../../../../constants/FormStepTypes';
27
- import RoundedSelect from '../../../../shared/RoundedSelect/RoundedSelect';
28
- import { MenuItem } from '@material-ui/core';
29
27
  import styles from './MaterialClassifierSelectorStep.module.css';
30
28
  import StepComponent from '../../Step';
31
29
  import { Controller } from 'react-hook-form';
32
30
  import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
31
+ import RoundedSmartSelect from '../../../../shared/RoundedSmartSelect/RoundedSmartSelect';
33
32
  function ClassifierSelector(_a) {
34
33
  var step = _a.step, form = _a.form, level = _a.level, errors = _a.errors, value = _a.value, onBlur = _a.onBlur, control = _a.control, editable = _a.editable, onChange = _a.onChange, postview = _a.postview, inputRef = _a.inputRef, formStyle = _a.formStyle, getValues = _a.getValues, widthStats = _a.widthStats, handleSizeChange = _a.handleSizeChange, others = __rest(_a, ["step", "form", "level", "errors", "value", "onBlur", "control", "editable", "onChange", "postview", "inputRef", "formStyle", "getValues", "widthStats", "handleSizeChange"]);
35
34
  var _b = useState(level === 0
@@ -42,6 +41,21 @@ function ClassifierSelector(_a) {
42
41
  if (!classifier) {
43
42
  return _jsx("div", {}, void 0);
44
43
  }
44
+ var options = classifier.children
45
+ .filter(function (classifier) {
46
+ var _a;
47
+ return ((_a = step.options[classifier._id]) === null || _a === void 0 ? void 0 : _a.type) !==
48
+ ClassifierOptionTypes.HIDE;
49
+ })
50
+ .map(function (classifier) {
51
+ var _a;
52
+ return typeof classifier === 'string'
53
+ ? {
54
+ value: classifier,
55
+ label: (_a = form.classifiers[classifier]) === null || _a === void 0 ? void 0 : _a.name,
56
+ }
57
+ : { value: classifier._id, label: classifier.name };
58
+ });
45
59
  var sizeChange = function () {
46
60
  handleSizeChange();
47
61
  if (level === 0) {
@@ -49,30 +63,24 @@ function ClassifierSelector(_a) {
49
63
  }
50
64
  };
51
65
  var renderSelect = function () {
66
+ var _a;
52
67
  return (_jsx("div", __assign({ className: styles.container, style: {
53
68
  width: widthStats.currentBreakPoint <= step.size
54
69
  ? '100%'
55
70
  : calcStepWidth(step.size, form.size),
56
71
  minHeight: step.description || step.required ? '55px' : '43px',
57
- } }, { children: _jsxs(RoundedSelect, __assign({ fullWidth: true, value: value, cantEdit: !editable || postview, helperTextColor: formStyle.descriptionTextColor, errorColor: formStyle.errorColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, label: step.label ? step.label : classifier.name, required: step.required, containerMargin: "0px", height: '31px', onBlur: onBlur, handleUpdate: function (event) {
58
- onChange(event.target.value);
72
+ } }, { children: _jsx(RoundedSmartSelect, { value: value, onBlur: onBlur, disabled: false, loading: false, options: options, inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: "transparent", innerBackgroundColor: (_a = formStyle.stepBackgroundColor) !== null && _a !== void 0 ? _a : 'white', label: step.label ? step.label : classifier.name, required: step.required, height: '31px', searchable: step.searchable, icon: undefined, iconComponent: undefined, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, containerMargin: "0px", handleUpdate: function (value) {
73
+ onChange(value);
59
74
  sizeChange();
60
- }, "data-testid": step.id, inputRef: inputRef, helperText: errors[step.id]
75
+ }, getOptionSelected: function (option, value) {
76
+ return option.value === (value === null || value === void 0 ? void 0 : value.value);
77
+ }, helperText: errors[step.id]
61
78
  ? errors[step.id].message
62
- : step.description, error: !!errors[step.id] }, { children: [_jsx(MenuItem, __assign({ value: '', style: { whiteSpace: 'normal' } }, { children: _jsx("em", { children: "Sin Seleccionar" }, void 0) }), 'EMPTY'), classifier.children
63
- .filter(function (classifier) {
64
- var _a;
65
- return ((_a = step.options[classifier._id]) === null || _a === void 0 ? void 0 : _a.type) !==
66
- ClassifierOptionTypes.HIDE;
67
- })
68
- .map(function (classifier) {
69
- var _a;
70
- return typeof classifier === 'string' ? (_jsx(MenuItem, __assign({ value: classifier, style: { whiteSpace: 'normal' } }, { children: (_a = form.classifiers[classifier]) === null || _a === void 0 ? void 0 : _a.name }), classifier)) : (_jsx(MenuItem, __assign({ value: classifier._id, style: { whiteSpace: 'normal' } }, { children: classifier.name }), classifier._id));
71
- })] }), void 0) }), step.id));
79
+ : step.description, error: !!errors[step.id] }, void 0) }), step.id));
72
80
  };
73
81
  var mapNestedOption = function () {
74
82
  if (value) {
75
- var currentOption = step.options[value];
83
+ var currentOption = step.options[step.searchable ? value.value : value];
76
84
  if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === ClassifierOptionTypes.NESTED) {
77
85
  return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep, index) {
78
86
  var subStep = form.steps[idStep];
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { RatingStepProps } from '../RatingStep';
3
+ declare function MaterialRatingStep({ step, errors, editable, control, postview, formStyle, widthStats, }: RatingStepProps): JSX.Element;
4
+ export default MaterialRatingStep;
@@ -0,0 +1,38 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import styles from './MaterialRatingStep.module.css';
14
+ import { Controller } from 'react-hook-form';
15
+ import React from 'react';
16
+ import Rating from '../../../../shared/Rating/Rating';
17
+ function MaterialRatingStep(_a) {
18
+ var step = _a.step, errors = _a.errors, editable = _a.editable, control = _a.control, postview = _a.postview, formStyle = _a.formStyle, widthStats = _a.widthStats;
19
+ return (_jsxs("div", __assign({ className: styles.container, style: {
20
+ paddingBottom: step.description || step.required ? 0 : 15,
21
+ } }, { children: [_jsx("div", __assign({ className: styles.labelLabel }, { children: step.label + (step.required ? ' *' : '') }), void 0), _jsx(Controller, { name: step.id, control: control, defaultValue: 1, rules: {
22
+ required: step.required
23
+ ? 'Este campo es obligatorio'
24
+ : undefined,
25
+ }, shouldUnregister: true, render: function (_a) {
26
+ var _b, _c, _d, _e, _f;
27
+ var field = _a.field;
28
+ return (_jsxs(React.Fragment, { children: [_jsx("div", __assign({ className: styles.ratingContainer }, { children: _jsx(Rating, { type: step.ratingType, isMobile: widthStats.isMobile, focusColor: (_b = formStyle.primaryColor) !== null && _b !== void 0 ? _b : '#3d5a7f', unSelectedColor: (_c = formStyle.outlineColor) !== null && _c !== void 0 ? _c : '#b8b8b8', disabled: !editable || postview, value: field.value, onChange: field.onChange, inputRef: field.ref }, void 0) }), void 0), (step.description || step.required) && (_jsx("div", __assign({ className: styles.stepDescriptionLabel, style: {
29
+ color: !!errors[step.id] &&
30
+ field.value === null
31
+ ? (_d = formStyle.errorColor) !== null && _d !== void 0 ? _d : '#cc2936'
32
+ : (_e = formStyle.descriptionTextColor) !== null && _e !== void 0 ? _e : '#989898',
33
+ } }, { children: !!errors[step.id] && field.value === null
34
+ ? (_f = errors[step.id]) === null || _f === void 0 ? void 0 : _f.message
35
+ : step.description }), void 0))] }, void 0));
36
+ } }, void 0)] }), void 0));
37
+ }
38
+ export default MaterialRatingStep;
@@ -0,0 +1,30 @@
1
+ .container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ width: 100%;
5
+ max-width: calc(100% - 20px);
6
+ padding: 5px 10px;
7
+ padding-bottom: 15px;
8
+ }
9
+ .labelLabel {
10
+ font-size: 16px;
11
+ margin-bottom: 10px;
12
+ text-align: center;
13
+ }
14
+ .ratingContainer {
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ }
19
+
20
+ .stepDescriptionLabel {
21
+ font-size: 0.75rem;
22
+ margin-top: 5px;
23
+ font-weight: 400;
24
+ line-height: 1.66;
25
+ max-width: 100%;
26
+ overflow: hidden;
27
+ text-overflow: ellipsis;
28
+ text-align: center;
29
+ min-height: 20px;
30
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { Rating } from '../../../@Types/FormStep';
3
+ import { StepProps } from '../Step';
4
+ export interface RatingStepProps extends StepProps {
5
+ /** The RatingStep to display */
6
+ step: Rating;
7
+ }
8
+ declare function RatingStep(props: RatingStepProps): JSX.Element;
9
+ export default RatingStep;
@@ -0,0 +1,25 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { FormStyleTypes } from '../../../constants/FormStepTypes';
14
+ import MaterialRatingStep from './MaterialRatingStep/MaterialRatingStep';
15
+ function RatingStep(props) {
16
+ switch (props.formStyle.type) {
17
+ case FormStyleTypes.MATERIAL: {
18
+ return _jsx(MaterialRatingStep, __assign({}, props), void 0);
19
+ }
20
+ default: {
21
+ return _jsx(MaterialRatingStep, __assign({}, props), void 0);
22
+ }
23
+ }
24
+ }
25
+ export default RatingStep;
@@ -24,12 +24,11 @@ import { createElement as _createElement } from "react";
24
24
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
25
  import React, { useState } from 'react';
26
26
  import { OptionTypes } from '../../../../constants/FormStepTypes';
27
- import RoundedSelect from '../../../../shared/RoundedSelect/RoundedSelect';
28
- import { MenuItem } from '@material-ui/core';
29
27
  import styles from './MaterialSelectorStep.module.css';
30
28
  import StepComponent from '../../Step';
31
29
  import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
32
30
  import { Controller } from 'react-hook-form';
31
+ import RoundedSmartSelect from '../../../../shared/RoundedSmartSelect/RoundedSmartSelect';
33
32
  function Selector(_a) {
34
33
  var step = _a.step, form = _a.form, value = _a.value, level = _a.level, onBlur = _a.onBlur, control = _a.control, editable = _a.editable, onChange = _a.onChange, postview = _a.postview, formStyle = _a.formStyle, getValues = _a.getValues, widthStats = _a.widthStats, handleSizeChange = _a.handleSizeChange, errors = _a.errors, inputRef = _a.inputRef, others = __rest(_a, ["step", "form", "value", "level", "onBlur", "control", "editable", "onChange", "postview", "formStyle", "getValues", "widthStats", "handleSizeChange", "errors", "inputRef"]);
35
34
  var _b = useState(level === 0
@@ -42,24 +41,26 @@ function Selector(_a) {
42
41
  }
43
42
  };
44
43
  var renderSelect = function () {
44
+ var _a;
45
45
  return (_jsx("div", __assign({ className: styles.container, style: {
46
46
  width: widthStats.currentBreakPoint <= step.size
47
47
  ? '100%'
48
48
  : calcStepWidth(step.size, form.size),
49
49
  minHeight: step.description || step.required ? '55px' : '43px',
50
- } }, { children: _jsxs(RoundedSelect, __assign({ value: value, fullWidth: true, inputRef: inputRef, cantEdit: !editable || postview, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, label: step.label, "data-testid": step.id, required: step.required, containerMargin: "0px", height: '31px', onBlur: onBlur, handleUpdate: function (event) {
51
- onChange(event.target.value);
52
- sizeChange();
50
+ } }, { children: _jsx(RoundedSmartSelect, { value: value, onBlur: onBlur, disabled: false, loading: false, options: step.options, inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: "transparent", innerBackgroundColor: (_a = formStyle.stepBackgroundColor) !== null && _a !== void 0 ? _a : 'white', label: step.label, required: step.required, height: '31px', searchable: step.searchable, icon: undefined, iconComponent: undefined, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, containerMargin: "0px", handleUpdate: function (value) {
51
+ onChange(value);
52
+ }, getOptionSelected: function (option, value) {
53
+ return option.value === (value === null || value === void 0 ? void 0 : value.value);
53
54
  }, helperText: errors[step.id]
54
55
  ? errors[step.id].message
55
- : step.description, error: !!errors[step.id] }, { children: [_jsx(MenuItem, __assign({ value: '', style: { whiteSpace: 'normal' } }, { children: _jsx("em", { children: "Sin Seleccionar" }, void 0) }), 'EMPTY'), step.options.map(function (option) { return (_jsx(MenuItem, __assign({ value: option.value, style: { whiteSpace: 'normal' } }, { children: option.label }), option.value)); })] }), void 0) }), void 0));
56
+ : step.description, error: !!errors[step.id] }, void 0) }), void 0));
56
57
  };
57
58
  var mapNestedOption = function () {
58
59
  var currentOptionIndex = null;
59
60
  var currentOption = null;
60
61
  for (var i = 0; i < step.options.length; i++) {
61
62
  var option = step.options[i];
62
- if (option.value === value) {
63
+ if (option.value === (step.searchable ? value.value : value)) {
63
64
  currentOptionIndex = i;
64
65
  currentOption = option;
65
66
  }
@@ -32,6 +32,7 @@ import DatePickerStep from './DatePickerStep/DatePickerStep';
32
32
  import FileUploadStep from './FileUploadStep/FileUploadStep';
33
33
  import CheckBoxStep from './CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep';
34
34
  import CBRStepMapper from './CBRStepMapper';
35
+ import RatingStep from './RatingStep/RatingStep';
35
36
  function StepComponent(_a) {
36
37
  var _b;
37
38
  var step = _a.step, props = __rest(_a, ["step"]);
@@ -67,6 +68,9 @@ function StepComponent(_a) {
67
68
  case Types.FILEUPLOAD: {
68
69
  return _jsx(FileUploadStep, __assign({ step: step }, props), void 0);
69
70
  }
71
+ case Types.RATING: {
72
+ return _jsx(RatingStep, __assign({ step: step }, props), void 0);
73
+ }
70
74
  default:
71
75
  break;
72
76
  }
@@ -7,6 +7,7 @@ export declare enum FormStyleTypes {
7
7
  }
8
8
  declare enum TYPES {
9
9
  TITLE = "TITLE",
10
+ RATING = "RATING",
10
11
  CHECKBOX = "CHECKBOX",
11
12
  TEXTAREA = "TEXTAREA",
12
13
  DATEPICKER = "DATEPICKER",
@@ -25,4 +26,9 @@ export declare enum ClassifierOptionTypes {
25
26
  HIDE = "CLASSIFIER_HIDE",
26
27
  NESTED = "CLASSIFIER_NESTED"
27
28
  }
29
+ export declare enum RatingTypes {
30
+ SCALE = "SCALE",
31
+ SATISFACTION = "SATISFACTION",
32
+ LIKE = "LIKE"
33
+ }
28
34
  export default TYPES;
@@ -10,6 +10,7 @@ export var FormStyleTypes;
10
10
  var TYPES;
11
11
  (function (TYPES) {
12
12
  TYPES["TITLE"] = "TITLE";
13
+ TYPES["RATING"] = "RATING";
13
14
  TYPES["CHECKBOX"] = "CHECKBOX";
14
15
  TYPES["TEXTAREA"] = "TEXTAREA";
15
16
  TYPES["DATEPICKER"] = "DATEPICKER";
@@ -30,4 +31,10 @@ export var ClassifierOptionTypes;
30
31
  ClassifierOptionTypes["HIDE"] = "CLASSIFIER_HIDE";
31
32
  ClassifierOptionTypes["NESTED"] = "CLASSIFIER_NESTED";
32
33
  })(ClassifierOptionTypes || (ClassifierOptionTypes = {}));
34
+ export var RatingTypes;
35
+ (function (RatingTypes) {
36
+ RatingTypes["SCALE"] = "SCALE";
37
+ RatingTypes["SATISFACTION"] = "SATISFACTION";
38
+ RatingTypes["LIKE"] = "LIKE";
39
+ })(RatingTypes || (RatingTypes = {}));
33
40
  export default TYPES;
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { RatingTypes } from '../../constants/FormStepTypes';
3
+ export interface RatingProps {
4
+ disabled?: boolean;
5
+ isMobile?: boolean;
6
+ value: any;
7
+ onChange: Function;
8
+ inputRef: any;
9
+ focusColor: string;
10
+ unSelectedColor: string;
11
+ }
12
+ declare function Rating({ type, ...others }: RatingProps & {
13
+ type: RatingTypes;
14
+ }): JSX.Element;
15
+ export default Rating;
@@ -0,0 +1,41 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
+ import LikeRating from './Ratings/LikeRating';
25
+ import ScaleRating from './Ratings/ScaleRating';
26
+ import SatisfactionRating from './Ratings/SatisfactionRating';
27
+ import { RatingTypes } from '../../constants/FormStepTypes';
28
+ function Rating(_a) {
29
+ var type = _a.type, others = __rest(_a, ["type"]);
30
+ switch (type) {
31
+ case RatingTypes.LIKE:
32
+ return _jsx(LikeRating, __assign({}, others), void 0);
33
+ case RatingTypes.SATISFACTION:
34
+ return _jsx(SatisfactionRating, __assign({}, others), void 0);
35
+ case RatingTypes.SCALE:
36
+ return _jsx(ScaleRating, __assign({}, others), void 0);
37
+ default:
38
+ return _jsx("div", {}, void 0);
39
+ }
40
+ }
41
+ export default Rating;
@@ -0,0 +1,32 @@
1
+ .ratingContainer {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ }
6
+
7
+ .disabledSentimentContainer,
8
+ .sentimentContainer {
9
+ font-size: 60px;
10
+ height: 60px;
11
+ color: var(--eureka-outline);
12
+ }
13
+ .disabledLikeContainer,
14
+ .likeContainer {
15
+ font-size: 60px;
16
+ height: 75px;
17
+ color: var(--eureka-outline);
18
+ }
19
+
20
+ .likeContainer:hover,
21
+ .sentimentContainer:hover {
22
+ transform: scale(1.2);
23
+ cursor: pointer;
24
+ color: var(--eureka-primary);
25
+ }
26
+
27
+ .hiddenInput {
28
+ height: 0;
29
+ width: 0;
30
+ padding: 0;
31
+ border-width: 0;
32
+ }
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { RatingProps } from '../Rating';
3
+ declare function LikeRating({ disabled, inputRef, value, onChange, focusColor, unSelectedColor, }: RatingProps): JSX.Element;
4
+ export default LikeRating;
@@ -0,0 +1,43 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import ThumbDownRoundedIcon from '@material-ui/icons/ThumbDownRounded';
14
+ import ThumbUpRoundedIcon from '@material-ui/icons/ThumbUpRounded';
15
+ import styles from '../Rating.module.css';
16
+ function LikeRating(_a) {
17
+ var disabled = _a.disabled, inputRef = _a.inputRef, value = _a.value, onChange = _a.onChange, focusColor = _a.focusColor, unSelectedColor = _a.unSelectedColor;
18
+ return (_jsxs("div", __assign({ className: styles.ratingContainer, style: {
19
+ '--eureka-primary': focusColor,
20
+ '--eureka-outline': unSelectedColor,
21
+ } }, { children: [_jsx("input", { ref: inputRef, className: styles.hiddenInput }, void 0), _jsx("div", __assign({ className: disabled
22
+ ? styles.disabledLikeContainer
23
+ : styles.likeContainer, onClick: function () {
24
+ if (!disabled)
25
+ onChange(value === 1 ? null : 1);
26
+ } }, { children: _jsx(ThumbUpRoundedIcon, { fontSize: "inherit", style: value === 1
27
+ ? {
28
+ color: focusColor,
29
+ }
30
+ : {} }, void 0) }), void 0), _jsx("div", __assign({ className: disabled
31
+ ? styles.disabledLikeContainer
32
+ : styles.likeContainer, onClick: function () {
33
+ if (!disabled)
34
+ onChange(value === 0 ? null : 0);
35
+ } }, { children: _jsx(ThumbDownRoundedIcon, { fontSize: "inherit", style: value === 0
36
+ ? {
37
+ color: focusColor,
38
+ marginTop: 14,
39
+ marginLeft: 15,
40
+ }
41
+ : { marginTop: 14, marginLeft: 15 } }, void 0) }), void 0)] }), void 0));
42
+ }
43
+ export default LikeRating;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { RatingProps } from '../Rating';
3
+ declare function SatisfactionRating({ value, inputRef, disabled, onChange, focusColor, unSelectedColor, }: RatingProps): JSX.Element;
4
+ export default SatisfactionRating;
@@ -0,0 +1,61 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import styles from '../Rating.module.css';
14
+ import SentimentVeryDissatisfiedIcon from '@material-ui/icons/SentimentVeryDissatisfied';
15
+ import SentimentDissatisfiedIcon from '@material-ui/icons/SentimentDissatisfied';
16
+ import SentimentSatisfiedAltIcon from '@material-ui/icons/SentimentSatisfiedAltOutlined';
17
+ import SentimentVerySatisfiedIcon from '@material-ui/icons/SentimentVerySatisfied';
18
+ function SatisfactionRating(_a) {
19
+ var value = _a.value, inputRef = _a.inputRef, disabled = _a.disabled, onChange = _a.onChange, focusColor = _a.focusColor, unSelectedColor = _a.unSelectedColor;
20
+ return (_jsxs("div", __assign({ className: styles.ratingContainer, style: {
21
+ '--eureka-primary': focusColor,
22
+ '--eureka-outline': unSelectedColor,
23
+ } }, { children: [_jsx("input", { ref: inputRef, className: styles.hiddenInput }, void 0), _jsx("div", __assign({ className: disabled
24
+ ? styles.disabledSentimentContainer
25
+ : styles.sentimentContainer, onClick: function () {
26
+ if (!disabled)
27
+ onChange(value === 1 ? null : 1);
28
+ } }, { children: _jsx(SentimentVeryDissatisfiedIcon, { fontSize: "inherit", style: value === 1
29
+ ? {
30
+ color: focusColor,
31
+ }
32
+ : {} }, void 0) }), void 0), _jsx("div", __assign({ className: disabled
33
+ ? styles.disabledSentimentContainer
34
+ : styles.sentimentContainer, onClick: function () {
35
+ if (!disabled)
36
+ onChange(value === 2 ? null : 2);
37
+ } }, { children: _jsx(SentimentDissatisfiedIcon, { fontSize: "inherit", style: value === 2
38
+ ? {
39
+ color: focusColor,
40
+ }
41
+ : {} }, void 0) }), void 0), _jsx("div", __assign({ className: disabled
42
+ ? styles.disabledSentimentContainer
43
+ : styles.sentimentContainer, onClick: function () {
44
+ if (!disabled)
45
+ onChange(value === 3 ? null : 3);
46
+ } }, { children: _jsx(SentimentSatisfiedAltIcon, { fontSize: "inherit", style: value === 3
47
+ ? {
48
+ color: focusColor,
49
+ }
50
+ : {} }, void 0) }), void 0), _jsx("div", __assign({ className: disabled
51
+ ? styles.disabledSentimentContainer
52
+ : styles.sentimentContainer, onClick: function () {
53
+ if (!disabled)
54
+ onChange(value === 4 ? null : 4);
55
+ } }, { children: _jsx(SentimentVerySatisfiedIcon, { fontSize: "inherit", style: value === 4
56
+ ? {
57
+ color: focusColor,
58
+ }
59
+ : {} }, void 0) }), void 0)] }), void 0));
60
+ }
61
+ export default SatisfactionRating;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { RatingProps } from '../Rating';
3
+ declare function ScaleRating({ value, inputRef, disabled, onChange, isMobile, focusColor, unSelectedColor, }: RatingProps): JSX.Element;
4
+ export default ScaleRating;
@@ -0,0 +1,63 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import styles from '../Rating.module.css';
25
+ import { Rating } from '@material-ui/lab';
26
+ import GradeRoundedIcon from '@material-ui/icons/GradeRounded';
27
+ import { makeStyles } from '@material-ui/core';
28
+ import React from 'react';
29
+ var useRatingStyles = function (props) {
30
+ return makeStyles({
31
+ root: {
32
+ '&.Mui-disabled': {
33
+ opacity: 1,
34
+ },
35
+ '& .EF-MuiRating-iconFilled': {
36
+ color: props.focusColor,
37
+ },
38
+ '& .EF-MuiRating-iconEmpty': {
39
+ color: props.unSelectedColor,
40
+ },
41
+ },
42
+ });
43
+ };
44
+ function ScaleRating(_a) {
45
+ var value = _a.value, inputRef = _a.inputRef, disabled = _a.disabled, onChange = _a.onChange, isMobile = _a.isMobile, focusColor = _a.focusColor, unSelectedColor = _a.unSelectedColor;
46
+ var ratingClasses = useRatingStyles({
47
+ unSelectedColor: unSelectedColor,
48
+ focusColor: focusColor,
49
+ })();
50
+ return (_jsxs(React.Fragment, { children: [_jsx("input", { ref: inputRef, className: styles.hiddenInput }, void 0), _jsx(Rating, { value: value, onChange: function (_event, newValue) {
51
+ if (!disabled)
52
+ onChange(newValue);
53
+ }, disabled: disabled, classes: ratingClasses, name: "customized-icons", size: "large", defaultValue: 0, getLabelText: function (value) { return value + '/5'; }, max: 5, IconContainerComponent: isMobile ? SmallIconContainer : IconContainer }, void 0)] }, void 0));
54
+ }
55
+ function IconContainer(_a) {
56
+ var value = _a.value, other = __rest(_a, ["value"]);
57
+ return (_jsx("span", __assign({ className: 'icon' + value }, other, { children: _jsx(GradeRoundedIcon, { style: { fontSize: 60 } }, void 0) }), void 0));
58
+ }
59
+ function SmallIconContainer(_a) {
60
+ var value = _a.value, other = __rest(_a, ["value"]);
61
+ return (_jsx("span", __assign({ className: 'icon' + value }, other, { children: _jsx(GradeRoundedIcon, { style: { fontSize: 50 } }, void 0) }), void 0));
62
+ }
63
+ export default ScaleRating;
@@ -20,11 +20,11 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import { jsx as _jsx } from "react/jsx-runtime";
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
24
  import Autocomplete, { createFilterOptions, } from '@material-ui/lab/Autocomplete';
25
25
  import { makeStyles } from '@material-ui/core/styles';
26
26
  import TextField from '@material-ui/core/TextField';
27
- import { Popper } from '@material-ui/core';
27
+ import { MenuItem, Popper } from '@material-ui/core';
28
28
  import RoundedSelect from '../RoundedSelect/RoundedSelect';
29
29
  var filter = createFilterOptions();
30
30
  var useTextfieldStyles = function (props) {
@@ -113,6 +113,9 @@ var useTextfieldStyles = function (props) {
113
113
  '& .EF-MuiAutocomplete-popupIndicatorOpen': {
114
114
  transform: props.showIcon ? 'none' : 'rotate(180deg)',
115
115
  },
116
+ '& .EF-MuiAutocomplete-clearIndicator': {
117
+ display: 'none',
118
+ },
116
119
  },
117
120
  }); });
118
121
  };
@@ -157,7 +160,7 @@ export default function RoundedSmartSelect(_a) {
157
160
  }, value: value ? value : null, onChange: function (event, newValue) {
158
161
  handleUpdate === null || handleUpdate === void 0 ? void 0 : handleUpdate(newValue);
159
162
  }, filterOptions: function (options, params) {
160
- if (value) {
163
+ if (value && value.label === (params === null || params === void 0 ? void 0 : params.inputValue)) {
161
164
  return options;
162
165
  }
163
166
  else {
@@ -166,8 +169,8 @@ export default function RoundedSmartSelect(_a) {
166
169
  }, renderOption: function (option) { return option.label; }, renderInput: function (params) { return (_jsx(TextField, __assign({ classes: textFieldClasses }, params, { inputRef: inputRef, onBlur: onBlur, name: name, variant: "outlined", label: label, required: required, error: error, helperText: helperText }), void 0)); }, style: { pointerEvents: 'none' }, noOptionsText: "No hay opciones" }, void 0));
167
170
  }
168
171
  else {
169
- return (_jsx(RoundedSelect, { onBlur: onBlur, inputRef: inputRef, name: name, fullWidth: true, handleUpdate: handleUpdate, onOpen: function () {
172
+ return (_jsxs(RoundedSelect, __assign({ onBlur: onBlur, inputRef: inputRef, name: name, fullWidth: true, handleUpdate: handleUpdate, onOpen: function () {
170
173
  //Show loading icon if loading
171
- }, value: value, color: color, errorColor: errorColor, focusColor: focusColor, helperTextColor: helperTextColor, outlineColor: outlineColor, cantEdit: cantEdit, label: label, required: required, readOnly: readOnly, helperText: helperText, containerMargin: containerMargin, height: height, error: error, iconComponent: iconComponent, showIcon: showIcon }, void 0));
174
+ }, value: value, color: color, errorColor: errorColor, focusColor: focusColor, helperTextColor: helperTextColor, outlineColor: outlineColor, cantEdit: cantEdit, label: label, required: required, readOnly: readOnly, helperText: helperText, containerMargin: containerMargin, height: height, error: error, iconComponent: iconComponent, showIcon: showIcon }, { children: [_jsx(MenuItem, __assign({ value: '', style: { whiteSpace: 'normal' } }, { children: _jsx("em", { children: "Sin Seleccionar" }, void 0) }), 'EMPTY'), options.map(function (option) { return (_jsx(MenuItem, __assign({ value: option.value, style: { whiteSpace: 'normal' } }, { children: option.label }), option.value)); })] }), void 0));
172
175
  }
173
176
  }
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.6.1-test",
4
+ "version":"1.6.3-test",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",