@arquimedes.co/eureka-forms 1.6.7-test → 1.6.8

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.
@@ -15,6 +15,7 @@ export interface Rating extends GSteps.GBaseStep {
15
15
  description: string;
16
16
  required: boolean;
17
17
  ratingType: RatingTypes;
18
+ nestedSteps: string[][] | null;
18
19
  }
19
20
  export interface FileUpload extends GSteps.GBaseStep {
20
21
  type: Types.FILEUPLOAD;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { RatingStepProps } from '../RatingStep';
3
- declare function MaterialRatingStep({ step, errors, editable, control, postview, formStyle, widthStats, }: RatingStepProps): JSX.Element;
4
- export default MaterialRatingStep;
3
+ declare function RatingStep(props: RatingStepProps): JSX.Element;
4
+ export default RatingStep;
@@ -9,30 +9,63 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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
+ };
12
23
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import { createElement as _createElement } from "react";
13
25
  import styles from './MaterialRatingStep.module.css';
14
26
  import { Controller } from 'react-hook-form';
15
27
  import React from 'react';
16
28
  import Rating from '../../../../shared/Rating/Rating';
29
+ import { RatingTypes } from '../../../../constants/FormStepTypes';
30
+ import StepComponent from '../../Step';
17
31
  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: null, 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, { name: step.id, 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));
32
+ var _b, _c, _d, _e, _f;
33
+ var form = _a.form, step = _a.step, value = _a.value, level = _a.level, errors = _a.errors, onChange = _a.onChange, inputRef = _a.inputRef, editable = _a.editable, postview = _a.postview, formStyle = _a.formStyle, widthStats = _a.widthStats, others = __rest(_a, ["form", "step", "value", "level", "errors", "onChange", "inputRef", "editable", "postview", "formStyle", "widthStats"]);
34
+ var renderNestedOption = function () {
35
+ var currentOption;
36
+ if (value && step.nestedSteps) {
37
+ if (step.ratingType === RatingTypes.LIKE) {
38
+ currentOption = step.nestedSteps[value];
39
+ }
40
+ else {
41
+ currentOption = step.nestedSteps[value - 1];
42
+ }
43
+ if (currentOption && currentOption.length > 0) {
44
+ return (_jsx(React.Fragment, { children: currentOption.map(function (idSubStep, index) {
45
+ var subStep = form.steps[idSubStep];
46
+ return (_createElement(StepComponent, __assign({}, others, { form: form, postview: postview, editable: editable, formStyle: formStyle, errors: errors, widthStats: widthStats, step: subStep, key: index, level: level + 1 })));
47
+ }) }, void 0));
48
+ }
49
+ }
50
+ };
51
+ return (_jsxs(React.Fragment, { children: [_jsxs("div", __assign({ className: styles.container, style: {
52
+ paddingBottom: step.description || step.required ? 0 : 15,
53
+ } }, { children: [_jsx("div", __assign({ className: styles.labelLabel }, { children: step.label + (step.required ? ' *' : '') }), void 0), _jsx("div", __assign({ className: styles.ratingContainer }, { children: _jsx(Rating, { name: step.id, 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: value, onChange: onChange, inputRef: inputRef }, void 0) }), void 0), (step.description || step.required) && (_jsx("div", __assign({ className: styles.stepDescriptionLabel, style: {
54
+ color: !!errors[step.id] && value === null
55
+ ? (_d = formStyle.errorColor) !== null && _d !== void 0 ? _d : '#cc2936'
56
+ : (_e = formStyle.descriptionTextColor) !== null && _e !== void 0 ? _e : '#989898',
57
+ } }, { children: !!errors[step.id] && value === null
58
+ ? (_f = errors[step.id]) === null || _f === void 0 ? void 0 : _f.message
59
+ : step.description }), void 0))] }), void 0), renderNestedOption()] }, void 0));
60
+ }
61
+ function RatingStep(props) {
62
+ return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: null, rules: {
63
+ required: props.step.required
64
+ ? 'Este campo es obligatorio'
65
+ : undefined,
66
+ }, shouldUnregister: true, render: function (_a) {
67
+ var field = _a.field;
68
+ return (_jsx(MaterialRatingStep, __assign({}, props, { inputRef: field.ref, value: field.value, onChange: field.onChange }), void 0));
69
+ } }, void 0));
37
70
  }
38
- export default MaterialRatingStep;
71
+ export default RatingStep;
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.7-test",
4
+ "version": "1.6.8",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",