@arquimedes.co/eureka-forms 1.6.0-test → 1.6.2-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/@Types/Form.d.ts +1 -1
- package/dist/@Types/FormStep.d.ts +11 -2
- package/dist/App.js +1 -1
- package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +24 -16
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/MaterialRatingStep.d.ts +4 -0
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/MaterialRatingStep.js +65 -0
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/MaterialRatingStep.module.css +55 -0
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/Ratings/LikeRating.d.ts +8 -0
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/Ratings/LikeRating.js +45 -0
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/Ratings/SatisfactionRating.d.ts +8 -0
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/Ratings/SatisfactionRating.js +63 -0
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/Ratings/ScaleRating.d.ts +8 -0
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/Ratings/ScaleRating.js +65 -0
- package/dist/FormComponents/Step/RatingStep/RatingStep.d.ts +9 -0
- package/dist/FormComponents/Step/RatingStep/RatingStep.js +25 -0
- package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +8 -7
- package/dist/FormComponents/Step/Step.js +4 -0
- package/dist/constants/FormStepTypes.d.ts +6 -0
- package/dist/constants/FormStepTypes.js +7 -0
- package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.js +8 -5
- package/package.json +1 -1
package/dist/@Types/Form.d.ts
CHANGED
|
@@ -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;
|
package/dist/App.js
CHANGED
|
@@ -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:
|
|
58
|
-
onChange(
|
|
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
|
-
},
|
|
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] },
|
|
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,65 @@
|
|
|
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 './MaterialRatingStep.module.css';
|
|
25
|
+
import { RatingTypes } from '../../../../constants/FormStepTypes';
|
|
26
|
+
import LikeRating from './Ratings/LikeRating';
|
|
27
|
+
import ScaleRating from './Ratings/ScaleRating';
|
|
28
|
+
import SatisfactionRating from './Ratings/SatisfactionRating';
|
|
29
|
+
import { Controller } from 'react-hook-form';
|
|
30
|
+
import React from 'react';
|
|
31
|
+
function MaterialRatingStep(_a) {
|
|
32
|
+
var step = _a.step, errors = _a.errors, others = __rest(_a, ["step", "errors"]);
|
|
33
|
+
var mapRating = function (field) {
|
|
34
|
+
switch (step.ratingType) {
|
|
35
|
+
case RatingTypes.LIKE:
|
|
36
|
+
return (_jsx(LikeRating, __assign({ step: step, errors: errors }, others, { inputRef: field.ref, value: field.value, onChange: field.onChange }), void 0));
|
|
37
|
+
case RatingTypes.SATISFACTION:
|
|
38
|
+
return (_jsx(SatisfactionRating, __assign({ step: step, errors: errors }, others, { inputRef: field.ref, value: field.value, onChange: field.onChange }), void 0));
|
|
39
|
+
case RatingTypes.SCALE:
|
|
40
|
+
return (_jsx(ScaleRating, __assign({ step: step, errors: errors }, others, { inputRef: field.ref, value: field.value, onChange: field.onChange }), void 0));
|
|
41
|
+
default:
|
|
42
|
+
return _jsx("div", {}, void 0);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return (_jsxs("div", __assign({ className: styles.container, style: {
|
|
46
|
+
paddingBottom: step.description || step.required ? 0 : 15,
|
|
47
|
+
} }, { children: [_jsx("div", __assign({ className: styles.labelLabel }, { children: step.label + (step.required ? ' *' : '') }), void 0), _jsx(Controller, { name: step.id, control: others.control, defaultValue: 1, rules: {
|
|
48
|
+
required: step.required
|
|
49
|
+
? 'Este campo es obligatorio'
|
|
50
|
+
: undefined,
|
|
51
|
+
}, shouldUnregister: true, render: function (_a) {
|
|
52
|
+
var _b, _c, _d;
|
|
53
|
+
var field = _a.field;
|
|
54
|
+
return (_jsxs(React.Fragment, { children: [_jsx("div", __assign({ className: styles.ratingContainer }, { children: mapRating(field) }), void 0), (step.description || step.required) && (_jsx("div", __assign({ className: styles.stepDescriptionLabel, style: {
|
|
55
|
+
color: !!errors[step.id] &&
|
|
56
|
+
field.value === null
|
|
57
|
+
? (_b = others.formStyle.errorColor) !== null && _b !== void 0 ? _b : '#cc2936'
|
|
58
|
+
: (_c = others.formStyle
|
|
59
|
+
.descriptionTextColor) !== null && _c !== void 0 ? _c : '#989898',
|
|
60
|
+
} }, { children: !!errors[step.id] && field.value === null
|
|
61
|
+
? (_d = errors[step.id]) === null || _d === void 0 ? void 0 : _d.message
|
|
62
|
+
: step.description }), void 0))] }, void 0));
|
|
63
|
+
} }, void 0)] }), void 0));
|
|
64
|
+
}
|
|
65
|
+
export default MaterialRatingStep;
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
}
|
|
31
|
+
.disabledSentimentContainer,
|
|
32
|
+
.sentimentContainer {
|
|
33
|
+
font-size: 60px;
|
|
34
|
+
height: 60px;
|
|
35
|
+
color: var(--eureka-outline);
|
|
36
|
+
}
|
|
37
|
+
.disabledLikeContainer,
|
|
38
|
+
.likeContainer {
|
|
39
|
+
font-size: 60px;
|
|
40
|
+
height: 75px;
|
|
41
|
+
color: var(--eureka-outline);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.likeContainer:hover,
|
|
45
|
+
.sentimentContainer:hover {
|
|
46
|
+
transform: scale(1.2);
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
color: var(--eureka-primary);
|
|
49
|
+
}
|
|
50
|
+
.hiddenInput {
|
|
51
|
+
height: 0;
|
|
52
|
+
width: 0;
|
|
53
|
+
padding: 0;
|
|
54
|
+
border-width: 0;
|
|
55
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { RatingStepProps } from '../../RatingStep';
|
|
3
|
+
declare function LikeRating({ value, inputRef, editable, postview, onChange, formStyle, }: RatingStepProps & {
|
|
4
|
+
value: any;
|
|
5
|
+
onChange: Function;
|
|
6
|
+
inputRef: any;
|
|
7
|
+
}): JSX.Element;
|
|
8
|
+
export default LikeRating;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 '../MaterialRatingStep.module.css';
|
|
16
|
+
function LikeRating(_a) {
|
|
17
|
+
var _b, _c, _d, _e;
|
|
18
|
+
var value = _a.value, inputRef = _a.inputRef, editable = _a.editable, postview = _a.postview, onChange = _a.onChange, formStyle = _a.formStyle;
|
|
19
|
+
var cantEdit = !editable || postview;
|
|
20
|
+
return (_jsxs("div", __assign({ className: styles.ratingContainer, style: {
|
|
21
|
+
'--eureka-primary': (_b = formStyle.primaryColor) !== null && _b !== void 0 ? _b : '#3d5a7f',
|
|
22
|
+
'--eureka-outline': (_c = formStyle.outlineColor) !== null && _c !== void 0 ? _c : '#b8b8b8',
|
|
23
|
+
} }, { children: [_jsx("input", { ref: inputRef, className: styles.hiddenInput }, void 0), _jsx("div", __assign({ className: cantEdit
|
|
24
|
+
? styles.disabledLikeContainer
|
|
25
|
+
: styles.likeContainer, onClick: function () {
|
|
26
|
+
if (!cantEdit)
|
|
27
|
+
onChange(value === 1 ? null : 1);
|
|
28
|
+
} }, { children: _jsx(ThumbUpRoundedIcon, { fontSize: "inherit", style: value === 1
|
|
29
|
+
? {
|
|
30
|
+
color: (_d = formStyle.primaryColor) !== null && _d !== void 0 ? _d : '#3d5a7f',
|
|
31
|
+
}
|
|
32
|
+
: {} }, void 0) }), void 0), _jsx("div", __assign({ className: cantEdit
|
|
33
|
+
? styles.disabledLikeContainer
|
|
34
|
+
: styles.likeContainer, onClick: function () {
|
|
35
|
+
if (!cantEdit)
|
|
36
|
+
onChange(value === 0 ? null : 0);
|
|
37
|
+
} }, { children: _jsx(ThumbDownRoundedIcon, { fontSize: "inherit", style: value === 0
|
|
38
|
+
? {
|
|
39
|
+
color: (_e = formStyle.primaryColor) !== null && _e !== void 0 ? _e : '#3d5a7f',
|
|
40
|
+
marginTop: 14,
|
|
41
|
+
marginLeft: 15,
|
|
42
|
+
}
|
|
43
|
+
: { marginTop: 14, marginLeft: 15 } }, void 0) }), void 0)] }), void 0));
|
|
44
|
+
}
|
|
45
|
+
export default LikeRating;
|
package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/Ratings/SatisfactionRating.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { RatingStepProps } from '../../RatingStep';
|
|
3
|
+
declare function SatisfactionRating({ value, inputRef, editable, postview, onChange, formStyle, }: RatingStepProps & {
|
|
4
|
+
value: any;
|
|
5
|
+
onChange: Function;
|
|
6
|
+
inputRef: any;
|
|
7
|
+
}): JSX.Element;
|
|
8
|
+
export default SatisfactionRating;
|
|
@@ -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
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import styles from '../MaterialRatingStep.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 _b, _c, _d, _e, _f, _g;
|
|
20
|
+
var value = _a.value, inputRef = _a.inputRef, editable = _a.editable, postview = _a.postview, onChange = _a.onChange, formStyle = _a.formStyle;
|
|
21
|
+
var cantEdit = !editable || postview;
|
|
22
|
+
return (_jsxs("div", __assign({ className: styles.ratingContainer, style: {
|
|
23
|
+
'--eureka-primary': (_b = formStyle.primaryColor) !== null && _b !== void 0 ? _b : '#3d5a7f',
|
|
24
|
+
'--eureka-outline': (_c = formStyle.outlineColor) !== null && _c !== void 0 ? _c : '#b8b8b8',
|
|
25
|
+
} }, { children: [_jsx("input", { ref: inputRef, className: styles.hiddenInput }, void 0), _jsx("div", __assign({ className: cantEdit
|
|
26
|
+
? styles.disabledSentimentContainer
|
|
27
|
+
: styles.sentimentContainer, onClick: function () {
|
|
28
|
+
if (!cantEdit)
|
|
29
|
+
onChange(value === 1 ? null : 1);
|
|
30
|
+
} }, { children: _jsx(SentimentVeryDissatisfiedIcon, { fontSize: "inherit", style: value === 1
|
|
31
|
+
? {
|
|
32
|
+
color: (_d = formStyle.primaryColor) !== null && _d !== void 0 ? _d : '#3d5a7f',
|
|
33
|
+
}
|
|
34
|
+
: {} }, void 0) }), void 0), _jsx("div", __assign({ className: cantEdit
|
|
35
|
+
? styles.disabledSentimentContainer
|
|
36
|
+
: styles.sentimentContainer, onClick: function () {
|
|
37
|
+
if (!cantEdit)
|
|
38
|
+
onChange(value === 2 ? null : 2);
|
|
39
|
+
} }, { children: _jsx(SentimentDissatisfiedIcon, { fontSize: "inherit", style: value === 2
|
|
40
|
+
? {
|
|
41
|
+
color: (_e = formStyle.primaryColor) !== null && _e !== void 0 ? _e : '#3d5a7f',
|
|
42
|
+
}
|
|
43
|
+
: {} }, void 0) }), void 0), _jsx("div", __assign({ className: cantEdit
|
|
44
|
+
? styles.disabledSentimentContainer
|
|
45
|
+
: styles.sentimentContainer, onClick: function () {
|
|
46
|
+
if (!cantEdit)
|
|
47
|
+
onChange(value === 3 ? null : 3);
|
|
48
|
+
} }, { children: _jsx(SentimentSatisfiedAltIcon, { fontSize: "inherit", style: value === 3
|
|
49
|
+
? {
|
|
50
|
+
color: (_f = formStyle.primaryColor) !== null && _f !== void 0 ? _f : '#3d5a7f',
|
|
51
|
+
}
|
|
52
|
+
: {} }, void 0) }), void 0), _jsx("div", __assign({ className: cantEdit
|
|
53
|
+
? styles.disabledSentimentContainer
|
|
54
|
+
: styles.sentimentContainer, onClick: function () {
|
|
55
|
+
if (!cantEdit)
|
|
56
|
+
onChange(value === 4 ? null : 4);
|
|
57
|
+
} }, { children: _jsx(SentimentVerySatisfiedIcon, { fontSize: "inherit", style: value === 4
|
|
58
|
+
? {
|
|
59
|
+
color: (_g = formStyle.primaryColor) !== null && _g !== void 0 ? _g : '#3d5a7f',
|
|
60
|
+
}
|
|
61
|
+
: {} }, void 0) }), void 0)] }), void 0));
|
|
62
|
+
}
|
|
63
|
+
export default SatisfactionRating;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { RatingStepProps } from '../../RatingStep';
|
|
3
|
+
declare function ScaleRating({ value, inputRef, editable, postview, onChange, widthStats, formStyle, }: RatingStepProps & {
|
|
4
|
+
value: any;
|
|
5
|
+
onChange: Function;
|
|
6
|
+
inputRef: any;
|
|
7
|
+
}): JSX.Element;
|
|
8
|
+
export default ScaleRating;
|
|
@@ -0,0 +1,65 @@
|
|
|
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 '../MaterialRatingStep.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
|
+
var _a, _b;
|
|
31
|
+
return makeStyles({
|
|
32
|
+
root: {
|
|
33
|
+
'&.Mui-disabled': {
|
|
34
|
+
opacity: 1,
|
|
35
|
+
},
|
|
36
|
+
'& .EF-MuiRating-iconFilled': {
|
|
37
|
+
color: (_a = props.focusColor) !== null && _a !== void 0 ? _a : '#3d5a7f',
|
|
38
|
+
},
|
|
39
|
+
'& .EF-MuiRating-iconEmpty': {
|
|
40
|
+
color: (_b = props.outlineColor) !== null && _b !== void 0 ? _b : '#b8b8b8',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
function ScaleRating(_a) {
|
|
46
|
+
var value = _a.value, inputRef = _a.inputRef, editable = _a.editable, postview = _a.postview, onChange = _a.onChange, widthStats = _a.widthStats, formStyle = _a.formStyle;
|
|
47
|
+
var cantEdit = !editable || postview;
|
|
48
|
+
var ratingClasses = useRatingStyles({
|
|
49
|
+
outlineColor: formStyle.outlineColor,
|
|
50
|
+
focusColor: formStyle.primaryColor,
|
|
51
|
+
})();
|
|
52
|
+
return (_jsxs(React.Fragment, { children: [_jsx("input", { ref: inputRef, className: styles.hiddenInput }, void 0), _jsx(Rating, { value: value, onChange: function (_event, newValue) {
|
|
53
|
+
if (!cantEdit)
|
|
54
|
+
onChange(newValue);
|
|
55
|
+
}, disabled: cantEdit, classes: ratingClasses, name: "customized-icons", size: "large", defaultValue: 0, getLabelText: function (value) { return value + '/5'; }, max: 5, IconContainerComponent: widthStats.isMobile ? SmallIconContainer : IconContainer }, void 0)] }, void 0));
|
|
56
|
+
}
|
|
57
|
+
function IconContainer(_a) {
|
|
58
|
+
var value = _a.value, other = __rest(_a, ["value"]);
|
|
59
|
+
return (_jsx("span", __assign({ className: 'icon' + value }, other, { children: _jsx(GradeRoundedIcon, { style: { fontSize: 60 } }, void 0) }), void 0));
|
|
60
|
+
}
|
|
61
|
+
function SmallIconContainer(_a) {
|
|
62
|
+
var value = _a.value, other = __rest(_a, ["value"]);
|
|
63
|
+
return (_jsx("span", __assign({ className: 'icon' + value }, other, { children: _jsx(GradeRoundedIcon, { style: { fontSize: 50 } }, void 0) }), void 0));
|
|
64
|
+
}
|
|
65
|
+
export default ScaleRating;
|
|
@@ -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:
|
|
51
|
-
onChange(
|
|
52
|
-
|
|
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] },
|
|
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;
|
|
@@ -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 (
|
|
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