@arquimedes.co/eureka-forms 3.0.30-test → 3.0.31

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 (56) hide show
  1. package/dist/@Types/FormStep.d.ts +4 -1
  2. package/dist/@Types/GenericFormSteps.d.ts +6 -0
  3. package/dist/App/AppHooks.js +13 -12
  4. package/dist/Form/Form.js +2 -6
  5. package/dist/Form/FormHooks.js +0 -1
  6. package/dist/Form/FormTypes/ColumnForm/ColumnForm.js +0 -2
  7. package/dist/Form/FormTypes/StepperForm/StepperForm.js +0 -2
  8. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +0 -1
  9. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +1 -5
  10. package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +1 -3
  11. package/dist/FormSteps/DatePickerRangeStep/DatePickerRangeStep.d.ts +10 -0
  12. package/dist/FormSteps/DatePickerRangeStep/DatePickerRangeStep.js +14 -0
  13. package/dist/FormSteps/DatePickerRangeStep/MaterialDatePickerRangeStep/MaterialDatePickerRangeStep.d.ts +3 -0
  14. package/dist/FormSteps/DatePickerRangeStep/MaterialDatePickerRangeStep/MaterialDatePickerRangeStep.js +27 -0
  15. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +0 -1
  16. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +0 -1
  17. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.js +0 -1
  18. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PagedMapperElement/PagedMapperElement.js +1 -5
  19. package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +3 -12
  20. package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +1 -5
  21. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +2 -9
  22. package/dist/FormSteps/Step.js +4 -0
  23. package/dist/FormSteps/StepFunctions.js +1 -0
  24. package/dist/FormSteps/StepFunctions.test.js +7 -0
  25. package/dist/FormSteps/StepHooks.js +3 -11
  26. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/DraftEditor.css +2 -2
  27. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +1 -3
  28. package/dist/FormSteps/Utils/@StepFiller/StepFiller.js +0 -1
  29. package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.d.ts +2 -2
  30. package/dist/Shared/CustomBtn/CustomBtn.js +0 -1
  31. package/dist/Shared/ErkButton/ErkButton.stories.d.ts +2 -1
  32. package/dist/Shared/ErkButton/ErkButton.stories.js +2 -0
  33. package/dist/Shared/ErkCheckbox/ErkCheckBox.stories.d.ts +1 -1
  34. package/dist/Shared/ErkDatePicker/ErkDatePicker.stories.d.ts +1 -1
  35. package/dist/Shared/ErkDatePicker/ErkDatePicker.stories.js +6 -11
  36. package/dist/Shared/ErkDatePickerRange/ErkDatePickerRange.d.ts +18 -0
  37. package/dist/Shared/ErkDatePickerRange/ErkDatePickerRange.js +160 -0
  38. package/dist/Shared/ErkDatePickerRange/ErkDatePickerRange.stories.d.ts +36 -0
  39. package/dist/Shared/ErkDatePickerRange/ErkDatePickerRange.stories.js +274 -0
  40. package/dist/Shared/ErkSelect/ErkSelect.stories.d.ts +5 -2
  41. package/dist/Shared/ErkSelect/ErkSelect.stories.js +28 -5
  42. package/dist/Shared/ErkSmartSelect/ErkSmartSelect.stories.d.ts +1 -1
  43. package/dist/Shared/ErkSmartSelect/ErkSmartSelect.stories.js +10 -18
  44. package/dist/Shared/ErkTextField/ErkTextField.stories.d.ts +1 -1
  45. package/dist/Shared/ErkTextField/ErkTextField.stories.js +5 -11
  46. package/dist/Shared/Navbar/Navbar.stories.d.ts +1 -1
  47. package/dist/Shared/Rating/Rating.stories.d.ts +1 -1
  48. package/dist/Shared/Toggle/Toggle.js +1 -1
  49. package/dist/Utils/AxiosAPI.js +1 -1
  50. package/dist/Utils/LocaleUtils.js +1 -1
  51. package/dist/Utils/MaterialProviders.js +2 -2
  52. package/dist/Utils/store.d.ts +1 -10
  53. package/dist/constants/FormStepTypes.d.ts +1 -0
  54. package/dist/constants/FormStepTypes.js +1 -0
  55. package/dist/index.css +1 -0
  56. package/package.json +46 -58
@@ -4,7 +4,7 @@ import { Condition } from './Condition';
4
4
  import { EurekaDraft } from './Draft/Draft';
5
5
  import * as GSteps from './GenericFormSteps';
6
6
  import { Time } from './Time';
7
- export type FormStep = Title | TimePicker | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | ApiSelector | Mapper;
7
+ export type FormStep = Title | TimePicker | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | ApiSelector | Mapper | DatePickerRange;
8
8
  export interface Title extends GSteps.GBaseStep {
9
9
  type: FormStepTypes.TITLE;
10
10
  title?: EurekaDraft;
@@ -48,6 +48,9 @@ export interface TextInput extends GSteps.GTextInput {
48
48
  export interface DatePicker extends GSteps.GDatePicker {
49
49
  type: FormStepTypes.DATEPICKER;
50
50
  }
51
+ export interface DatePickerRange extends GSteps.GDatePickerRange {
52
+ type: FormStepTypes.DATEPICKER_RANGE;
53
+ }
51
54
  export interface Collapsible extends GSteps.GBaseStep {
52
55
  type: FormStepTypes.COLLAPSIBLE;
53
56
  label: string;
@@ -51,6 +51,12 @@ export interface GDatePicker extends GBaseStep {
51
51
  required: boolean;
52
52
  size: 1 | 2 | 3 | 4;
53
53
  }
54
+ export interface GDatePickerRange extends GBaseStep {
55
+ label: string;
56
+ description: string | null;
57
+ required: boolean;
58
+ size: 1 | 2 | 3 | 4;
59
+ }
54
60
  export interface GTimePicker extends GBaseStep {
55
61
  label: string;
56
62
  description: string | null;
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useState } from 'react';
1
+ import { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import { reset } from '../States/GlobalSlice';
3
3
  import { fetchOrganization } from '../Services/OrganizationService';
4
4
  import { fetchForm } from '../Services/FormService';
@@ -15,6 +15,9 @@ export const useSetupApp = (isEmbedded, props) => {
15
15
  const [form, setForm] = useState(undefined);
16
16
  const [organization, setOrganization] = useState(undefined);
17
17
  const dispatch = useAppDispatch();
18
+ // Create stable stringified versions that only change when content changes
19
+ const valuesDataKey = useMemo(() => JSON.stringify(valuesData), [valuesData]);
20
+ const formDataKey = useMemo(() => JSON.stringify(formData), [formData]);
18
21
  const loadOrg = async (idOrganization) => {
19
22
  const organization = await fetchOrganization(idOrganization);
20
23
  if (organization) {
@@ -119,21 +122,21 @@ export const useSetupApp = (isEmbedded, props) => {
119
122
  return () => {
120
123
  dispatch({ type: 'CLEAR' });
121
124
  };
122
- // eslint-disable-next-line react-hooks/exhaustive-deps
125
+ // Use stringified keys for stable comparison - only changes when content changes
126
+ // Other object/function props (classifiers) are still
127
+ // intentionally excluded to prevent re-renders when parent re-creates these objects
123
128
  }, [
124
- dispatch,
129
+ apiKey,
130
+ partial,
125
131
  preview,
126
132
  internal,
127
133
  postview,
128
- partial,
129
134
  editable,
130
- handleConfirmed,
131
135
  customSteps,
132
- valuesData,
133
- apiKey,
134
- formData,
135
- classifiers,
136
+ formDataKey,
137
+ valuesDataKey,
136
138
  idCurrentAgent,
139
+ handleConfirmed,
137
140
  ]);
138
141
  const reload = useCallback(() => {
139
142
  if (!form)
@@ -146,12 +149,11 @@ export const useSetupApp = (isEmbedded, props) => {
146
149
  if (handleConfirmed) {
147
150
  handleConfirmed();
148
151
  }
149
- // eslint-disable-next-line react-hooks/exhaustive-deps
150
152
  }, [form]);
151
153
  return {
152
154
  form,
153
155
  organization,
154
- branding: organization?.customBrandings ? form?.branding ?? organization.branding : organization?.branding,
156
+ branding: organization?.customBrandings ? (form?.branding ?? organization.branding) : organization?.branding,
155
157
  reload,
156
158
  };
157
159
  };
@@ -172,6 +174,5 @@ export const useLogRocket = (organization, form, { apiKey, internal, postview, p
172
174
  };
173
175
  useEffect(() => {
174
176
  void loadLogRocket();
175
- // eslint-disable-next-line react-hooks/exhaustive-deps
176
177
  }, [organization, form]);
177
178
  };
package/dist/Form/Form.js CHANGED
@@ -34,14 +34,12 @@ function FormComponent({ form, apiKey, reload, isWidget, branding, setSubmit, sc
34
34
  formMethods.setFocus(idFocusStep);
35
35
  dispatch(focusStep(undefined));
36
36
  }
37
- // eslint-disable-next-line react-hooks/exhaustive-deps
38
37
  }, [idFocusStep]);
39
38
  const onSubmit = useCallback(async (values) => {
40
39
  let token = null;
41
40
  if (form.hasCaptcha && !internal && !customSubmit) {
42
41
  token = recaptchaRef.current?.getValue();
43
- if (!token)
44
- token = await recaptchaRef?.current.executeAsync();
42
+ token ?? (token = await recaptchaRef?.current.executeAsync());
45
43
  }
46
44
  const ApiKey = internal ? form.apiKey : apiKey;
47
45
  if (!ApiKey && !customSubmit && !customSubmitBtns)
@@ -78,9 +76,7 @@ function FormComponent({ form, apiKey, reload, isWidget, branding, setSubmit, sc
78
76
  catch (error) {
79
77
  console.error(error);
80
78
  }
81
- },
82
- // eslint-disable-next-line react-hooks/exhaustive-deps
83
- [customSteps, internal, customSubmit, idOrganization, idForm]);
79
+ }, [customSteps, internal, customSubmit, idOrganization, idForm]);
84
80
  useWidthStats(containerRef, form, postview, internal);
85
81
  const isResponsive = useAppSelector((state) => state.widthStats.isResponsive);
86
82
  const renderForm = () => {
@@ -30,6 +30,5 @@ export function useWidthStats(containerRef, form, postview, internal) {
30
30
  return () => {
31
31
  window.removeEventListener('resize', handleResize);
32
32
  };
33
- // eslint-disable-next-line react-hooks/exhaustive-deps
34
33
  }, []);
35
34
  }
@@ -25,7 +25,6 @@ function ColumnForm({ onSubmit, customSubmitBtns, ...props }) {
25
25
  useEffect(() => {
26
26
  if (props.setSubmit)
27
27
  props.setSubmit(submit);
28
- // eslint-disable-next-line react-hooks/exhaustive-deps
29
28
  }, [props.setSubmit]);
30
29
  /** Esto se usa para no tener que escuchar todo el tiempo los errores del formulario */
31
30
  const handleErrors = handleSubmit(() => { }, (errors) => {
@@ -47,7 +46,6 @@ function ColumnForm({ onSubmit, customSubmitBtns, ...props }) {
47
46
  values = await onSubmit(values);
48
47
  setLoading(false);
49
48
  return values;
50
- // eslint-disable-next-line react-hooks/exhaustive-deps
51
49
  }, [form]);
52
50
  return (_jsxs("div", { className: styles.container, style: { color: formStyle.textColor }, children: [loading && _jsx("div", { className: styles.curtain }), previous.map((idSection) => (_jsx(Section, { idSection: idSection }, idSection))), next.map((idSection) => (_jsx(Section, { idSection: idSection }, idSection))), _jsx(Terms, {}), !postview && editable && (_jsxs(React.Fragment, { children: [customSubmitBtns === undefined && (_jsx("div", { className: styles.submitBtnContainer, children: _jsx(CustomBtn, { onClick: () => void submit(), width: "calc(100% - 70px)", label: sendLabel ?? 'Enviar', backgroundColor: formStyle.primaryColor, color: formStyle.primaryContrastColor, loading: loading, "data-testid": "form__submit" }) })), customSubmitBtns?.(submit, loading)] }))] }));
53
51
  }
@@ -29,7 +29,6 @@ function StepperForm({ onSubmit, scrollToTop }) {
29
29
  const handlePrevious = useCallback(() => {
30
30
  dispatch(SiteReducer.handlePrevious({ values: getValues(), form }));
31
31
  scrollToTop?.();
32
- // eslint-disable-next-line react-hooks/exhaustive-deps
33
32
  }, []);
34
33
  const handleNext = useCallback(async () => {
35
34
  setLoading('NEXT');
@@ -58,7 +57,6 @@ function StepperForm({ onSubmit, scrollToTop }) {
58
57
  const response = await onSubmit(values);
59
58
  setLoading(undefined);
60
59
  return response;
61
- // eslint-disable-next-line react-hooks/exhaustive-deps
62
60
  }, [next]);
63
61
  if (!idCurrent)
64
62
  return _jsx(_Fragment, {});
@@ -34,7 +34,6 @@ function CBRIncidentsStep({ step, editable, ...others }) {
34
34
  if (firstRender && value.length === 0 && !postview && editable) {
35
35
  handleAddIncident();
36
36
  }
37
- // eslint-disable-next-line react-hooks/exhaustive-deps
38
37
  }, [firstRender]);
39
38
  const handleAddIncident = () => {
40
39
  const current = value.filter((incident) => !incident.deleted);
@@ -25,7 +25,6 @@ function ClassifierSelectorStep({ step, editable }) {
25
25
  }
26
26
  }
27
27
  return dependencies;
28
- // eslint-disable-next-line react-hooks/exhaustive-deps
29
28
  }, []);
30
29
  const dependencies = useAppSelector((state) => selectDependencies(state, idDependencies));
31
30
  const { postview, preview } = useAppSelector((state) => state.global);
@@ -47,14 +46,11 @@ function ClassifierSelectorStep({ step, editable }) {
47
46
  label: classifier?.clientName?.trim?.() && preview ? classifier?.clientName : classifier?.name,
48
47
  };
49
48
  });
50
- },
51
- // eslint-disable-next-line react-hooks/exhaustive-deps
52
- idDependencies.map((id) => dependencies[id].value));
49
+ }, idDependencies.map((id) => dependencies[id].value));
53
50
  useEffect(() => {
54
51
  if (value && !options?.find((option) => option.value === value?.value)) {
55
52
  onChange('');
56
53
  }
57
- // eslint-disable-next-line react-hooks/exhaustive-deps
58
54
  }, [options]);
59
55
  if (!step.idClassifier || !classifier)
60
56
  return _jsx(_Fragment, {});
@@ -18,9 +18,7 @@ function Collapsible({ step, open, setOpen, ...others }) {
18
18
  if (!open && step.dependencies?.find((dep) => !!errors[dep])) {
19
19
  setOpen(true);
20
20
  }
21
- },
22
- // eslint-disable-next-line react-hooks/exhaustive-deps
23
- step.dependencies?.map((dep) => errors[dep]) ?? []);
21
+ }, step.dependencies?.map((dep) => errors[dep]) ?? []);
24
22
  return (_jsxs("div", { style: { maxWidth: '100%' }, children: [_jsxs("div", { className: styles.container, style: {
25
23
  color: formStyle.textColor,
26
24
  borderColor: formStyle.primaryColor,
@@ -0,0 +1,10 @@
1
+ import { DatePickerRange } from '../../@Types/FormStep';
2
+ import { StepProps } from '../Step';
3
+ export interface DatePickerRangeStepProps extends StepProps {
4
+ /** The DatePickerRangeStep to display */
5
+ step: DatePickerRange;
6
+ /** Default value to display */
7
+ defaultValue?: string[] | null;
8
+ }
9
+ declare function DatePickerRangeStep(props: DatePickerRangeStepProps): JSX.Element;
10
+ export default DatePickerRangeStep;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FormStyleTypes } from '../../constants/FormStepTypes';
3
+ import MaterialDatePickerRangeStep from './MaterialDatePickerRangeStep/MaterialDatePickerRangeStep';
4
+ import { useAppSelector } from '../../hooks';
5
+ function DatePickerRangeStep(props) {
6
+ const { formStyle } = useAppSelector((state) => state.global);
7
+ switch (formStyle.type) {
8
+ case FormStyleTypes.MATERIAL:
9
+ default: {
10
+ return _jsx(MaterialDatePickerRangeStep, { ...props });
11
+ }
12
+ }
13
+ }
14
+ export default DatePickerRangeStep;
@@ -0,0 +1,3 @@
1
+ import { DatePickerRangeStepProps } from '../DatePickerRangeStep';
2
+ declare function MaterialDatePickerRangeStep({ step, editable, defaultValue }: DatePickerRangeStepProps): JSX.Element;
3
+ export default MaterialDatePickerRangeStep;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback } from 'react';
3
+ import ErkDatePickerRange from '../../../Shared/ErkDatePickerRange/ErkDatePickerRange';
4
+ import { useAppSelector } from '../../../hooks';
5
+ import { useFormStep } from '../../StepHooks';
6
+ import MaterialInputContainer from '../../Utils/MaterialInputContainer/MaterialInputContainer';
7
+ function MaterialDatePickerRangeStep({ step, editable, defaultValue }) {
8
+ const postview = useAppSelector((state) => state.global.postview);
9
+ const { ref, value, onChange, error, field } = useFormStep(step, {
10
+ defaultValue,
11
+ rules: {
12
+ required: step.required ? 'Este campo es obligatorio' : undefined,
13
+ },
14
+ });
15
+ const handleChange = useCallback((dateRange) => {
16
+ const [start, end] = dateRange;
17
+ if (start && end) {
18
+ onChange([start.toISOString(), end.toISOString()]);
19
+ }
20
+ else {
21
+ onChange(null);
22
+ }
23
+ }, [onChange]);
24
+ const dateRangeValue = value && value.length === 2 ? [new Date(value[0]), new Date(value[1])] : [null, null];
25
+ return (_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkDatePickerRange, { ...field, value: dateRangeValue, inputRef: ref, error: !!error, labelMargin: 0, onChange: handleChange, required: step.required, readOnly: !editable || postview, helperText: error?.message ?? step.description }) }));
26
+ }
27
+ export default MaterialDatePickerRangeStep;
@@ -22,7 +22,6 @@ function EntityValuePickerStep({ step, editable }) {
22
22
  ids.push(...recursivelyCalcConditionSteps(dialog.condition));
23
23
  }
24
24
  return ids;
25
- // eslint-disable-next-line react-hooks/exhaustive-deps
26
25
  }, []);
27
26
  const dialogDeps = useAppSelector((state) => selectDependencies(state, dialogsIdStepDeps));
28
27
  const handleCloseDialog = useCallback(() => {
@@ -64,7 +64,6 @@ function FileUploadStep({ step, editable }) {
64
64
  void getLinks(filesToFetchLink);
65
65
  onChange([...value, ...filesToFetchLink]);
66
66
  }
67
- // eslint-disable-next-line react-hooks/exhaustive-deps
68
67
  }, [fileChange]);
69
68
  async function getLinks(pFiles) {
70
69
  try {
@@ -19,7 +19,6 @@ function MapperElementComponent(props) {
19
19
  ...customContext,
20
20
  customStepProps: props.calcCustomStepProps(element, customContext.customStepProps),
21
21
  };
22
- // eslint-disable-next-line react-hooks/exhaustive-deps
23
22
  }, [element, customContext]);
24
23
  if (element.deleted)
25
24
  return _jsx(_Fragment, {});
@@ -29,7 +29,6 @@ function PagedMapperElement({ step, num, loading, element, children, editable, o
29
29
  }
30
30
  }
31
31
  return null;
32
- // eslint-disable-next-line react-hooks/exhaustive-deps
33
32
  }, [value]);
34
33
  const prevIndex = useMemo(() => {
35
34
  for (let i = page - 1; i >= 0; i--) {
@@ -39,7 +38,6 @@ function PagedMapperElement({ step, num, loading, element, children, editable, o
39
38
  }
40
39
  }
41
40
  return null;
42
- // eslint-disable-next-line react-hooks/exhaustive-deps
43
41
  }, [value]);
44
42
  /** Esto se usa para no tener que escuchar todo el tiempo los errores del formulario */
45
43
  const handleErrors = handleSubmit(() => { }, (errors) => {
@@ -70,9 +68,7 @@ function PagedMapperElement({ step, num, loading, element, children, editable, o
70
68
  page: index,
71
69
  });
72
70
  return;
73
- },
74
- // eslint-disable-next-line react-hooks/exhaustive-deps
75
- [elements]);
71
+ }, [elements]);
76
72
  const widthStats = useAppSelector((state) => state.widthStats);
77
73
  const { calcName } = customElementModifiers ?? {};
78
74
  const name = calcName ? calcName(element) : step.unitLabel ? step.unitLabel + ' ' + (num + 1) : '';
@@ -33,9 +33,7 @@ function MapperComponent({ form, step, error, value, loading, inputRef, editable
33
33
  elements: tempElements,
34
34
  page: page === index ? newPage : page,
35
35
  });
36
- },
37
- // eslint-disable-next-line react-hooks/exhaustive-deps
38
- [elements, onChange]);
36
+ }, [elements, onChange]);
39
37
  const inputValue = useMemo(() => JSON.stringify(elements), [elements]);
40
38
  const { formStyle, postview } = useAppSelector((state) => state.global);
41
39
  const { container } = useMemo(() => {
@@ -89,7 +87,6 @@ function MapperStep(props) {
89
87
  if (!customAdd)
90
88
  handleAddElement();
91
89
  }
92
- // eslint-disable-next-line react-hooks/exhaustive-deps
93
90
  }, []);
94
91
  const handleAddElement = useCallback((elementValue) => {
95
92
  const { element, steps, mappers } = addMapperStep(step, customSteps);
@@ -109,10 +106,7 @@ function MapperStep(props) {
109
106
  customSteps,
110
107
  allSteps: { ...form.steps, ...steps },
111
108
  }));
112
- },
113
- // eslint-disable-next-line react-hooks/exhaustive-deps
114
- [step, form, customSteps, value, onChange]);
115
- // eslint-disable-next-line react-hooks/exhaustive-deps
109
+ }, [step, form, customSteps, value, onChange]);
116
110
  const subForm = useMemo(() => ({ ...form, steps: { ...form.steps, ...localSteps } }), [localSteps]);
117
111
  return (_jsx(MapperComponent, { ...props, error: error, inputRef: ref, onChange: onChange, value: value, handleAddElement: handleAddElement, form: subForm }));
118
112
  }
@@ -142,10 +136,7 @@ export function CustomMapperStep(props) {
142
136
  customSteps,
143
137
  allSteps: { ...form.steps, ...steps },
144
138
  }));
145
- },
146
- // eslint-disable-next-line react-hooks/exhaustive-deps
147
- [step, form, customSteps, elements, onChange]);
148
- // eslint-disable-next-line react-hooks/exhaustive-deps
139
+ }, [step, form, customSteps, elements, onChange]);
149
140
  const subForm = useMemo(() => ({ ...form, steps: { ...form.steps, ...localSteps } }), [localSteps]);
150
141
  return _jsx(MapperComponent, { ...props, form: subForm, onChange: onChange, handleAddElement: handleAddElement });
151
142
  }
@@ -27,7 +27,6 @@ function SelectorStep({ step, editable }) {
27
27
  }
28
28
  }
29
29
  return dependencies;
30
- // eslint-disable-next-line react-hooks/exhaustive-deps
31
30
  }, []);
32
31
  const dependencies = useAppSelector((state) => selectDependencies(state, idDependencies));
33
32
  const mapNestedOption = () => {
@@ -54,14 +53,11 @@ function SelectorStep({ step, editable }) {
54
53
  return true;
55
54
  return false;
56
55
  });
57
- },
58
- // eslint-disable-next-line react-hooks/exhaustive-deps
59
- idDependencies.map((id) => dependencies[id].value));
56
+ }, idDependencies.map((id) => dependencies[id].value));
60
57
  useEffect(() => {
61
58
  if (value && !filteredOptions.find((option) => option.value === value?.value)) {
62
59
  onChange('');
63
60
  }
64
- // eslint-disable-next-line react-hooks/exhaustive-deps
65
61
  }, [filteredOptions]);
66
62
  return (_jsxs(React.Fragment, { children: [_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkSmartSelect, { ...field, value: value, inputRef: ref, error: !!error, label: step.label, onChange: onChange, required: step.required, options: filteredOptions, searchable: step.searchable, readOnly: !editable || postview, helperText: error?.message?.toString() ?? step.description, getOptionSelected: (option, value) => option?.value === value?.value }) }), value && mapNestedOption()] }));
67
63
  }
@@ -32,9 +32,7 @@ function SmartSelectStep({ step, editable, getOptions, calcDepError, defaultValu
32
32
  const idDependencies = useMemo(() => getOptionsConditionsIdSteps(step), [getOptionsConditionsIdSteps, step]);
33
33
  const dependencies = useAppSelector((state) => selectDependencies(state, allDeps));
34
34
  const deps = useAppSelector((state) => selectDependencies(state, idDependencies));
35
- const conditionDependencies = useMemo(() => deps,
36
- // eslint-disable-next-line react-hooks/exhaustive-deps
37
- idDependencies.map((id) => deps[id]));
35
+ const conditionDependencies = useMemo(() => deps, idDependencies.map((id) => deps[id]));
38
36
  const { emptyDep, invalids } = useAppSelector((state) => selectStepDependencies(state, step, form));
39
37
  const { getValues, setFocus } = useFormContext();
40
38
  const isEmpty = useAppSelector((state) => state.site.dependencies[step.id]?.empty);
@@ -47,9 +45,7 @@ function SmartSelectStep({ step, editable, getOptions, calcDepError, defaultValu
47
45
  else if (value && !step.searchable) {
48
46
  setOptions([value]);
49
47
  }
50
- },
51
- // eslint-disable-next-line react-hooks/exhaustive-deps
52
- allDeps.map((dep) => dependencies[dep]?.value) ?? []);
48
+ }, allDeps.map((dep) => dependencies[dep]?.value) ?? []);
53
49
  const calcOptions = async (firstTime) => {
54
50
  if (!firstTime)
55
51
  setOptions(undefined);
@@ -114,13 +110,11 @@ function SmartSelectStep({ step, editable, getOptions, calcDepError, defaultValu
114
110
  }
115
111
  if (!touched)
116
112
  setTouched(true);
117
- // eslint-disable-next-line react-hooks/exhaustive-deps
118
113
  }, [options, emptyDep, postview, editable, invalids, touched]);
119
114
  const filteredOptions = useMemo(() => {
120
115
  if (!options || !filterOptions)
121
116
  return options;
122
117
  return filterOptions(options, conditionDependencies);
123
- // eslint-disable-next-line react-hooks/exhaustive-deps
124
118
  }, [options, conditionDependencies]);
125
119
  const errorMsg = useMemo(() => {
126
120
  if (postview || loading)
@@ -138,7 +132,6 @@ function SmartSelectStep({ step, editable, getOptions, calcDepError, defaultValu
138
132
  return 'Error al cargar las opciones';
139
133
  }
140
134
  return undefined;
141
- // eslint-disable-next-line react-hooks/exhaustive-deps
142
135
  }, [invalids, touched, value, filteredOptions]);
143
136
  return (_jsxs(React.Fragment, { children: [_jsx(MaterialInputContainer, { step: step, onClick: onFocus, editable: editable, children: _jsx(ErkSmartSelect, { ...field, value: value, inputRef: ref, onFocus: onFocus, loading: loading, label: step.label, onChange: onChange, required: step.required, searchable: step.searchable, getValueString: getValueString, disabled: emptyDep, getOptionSelected: getOptionSelected, options: filteredOptions ?? undefined, IconComponent: step.showIcon ? IconComponent : undefined, error: !!errorMsg || !!warning || !!error, readOnly: !editable || postview || emptyDep || filteredOptions === null, helperText: errorMsg ?? warning ?? error?.message?.toString() ?? step.description ?? undefined }) }), renderNestedSteps?.(value)] }));
144
137
  }
@@ -7,6 +7,7 @@ import TitleStep from './TitleStep/TitleStep';
7
7
  import ClassifierSelectorStep from './ClassifierSelectorStep/ClassifierSelectorStep';
8
8
  import TextAreaStep from './TextAreaStep/TextAreaStep';
9
9
  import DatePickerStep from './DatePickerStep/DatePickerStep';
10
+ import DatePickerRangeStep from './DatePickerRangeStep/DatePickerRangeStep';
10
11
  import FileUploadStep from './FileUploadStep/FileUploadStep';
11
12
  import CheckBoxStep from './CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep';
12
13
  import CBRStepMapper from './CBRStepMapper';
@@ -73,6 +74,9 @@ function StepComponent({ step, ...props }) {
73
74
  case FormStepTypes.DATEPICKER: {
74
75
  return _jsx(DatePickerStep, { ...props, step: step, editable: editable });
75
76
  }
77
+ case FormStepTypes.DATEPICKER_RANGE: {
78
+ return _jsx(DatePickerRangeStep, { ...props, step: step, editable: editable });
79
+ }
76
80
  case FormStepTypes.SEPARATOR: {
77
81
  return _jsx(SeparatorStep, { ...props, step: step, editable: editable });
78
82
  }
@@ -119,6 +119,7 @@ export const calcDefaultValue = (step) => {
119
119
  return '';
120
120
  case FormStepTypes.RATING:
121
121
  case FormStepTypes.DATEPICKER:
122
+ case FormStepTypes.DATEPICKER_RANGE:
122
123
  case FormStepTypes.API_SELECTOR:
123
124
  case FormStepTypes.ENTITYVALUEPICKER:
124
125
  return null;
@@ -489,6 +489,13 @@ describe('StepFunctions', function () {
489
489
  expect(defaultValue3).toBe(null);
490
490
  expect(defaultValue4).toBe(null);
491
491
  });
492
+ test('DatePickerRange step type', async () => {
493
+ const step = {
494
+ type: FormStepTypes.DATEPICKER_RANGE,
495
+ };
496
+ const defaultValue = calcDefaultValue(step);
497
+ expect(defaultValue).toBe(null);
498
+ });
492
499
  test('Mapper, FileUpload, CBRFormStep types', async () => {
493
500
  const step1 = {
494
501
  type: FormStepTypes.MAPPER,
@@ -28,7 +28,6 @@ export const useStepDependency = (step, defaultValue) => {
28
28
  return () => {
29
29
  dispatch(clearDependency(step));
30
30
  };
31
- // eslint-disable-next-line react-hooks/exhaustive-deps
32
31
  }, [isDependency]);
33
32
  const handleStepDep = useCallback((value) => {
34
33
  if (!isDependency)
@@ -37,9 +36,7 @@ export const useStepDependency = (step, defaultValue) => {
37
36
  step,
38
37
  value: value ?? null,
39
38
  }));
40
- },
41
- // eslint-disable-next-line react-hooks/exhaustive-deps
42
- [step.id, step.type, isDependency]);
39
+ }, [step.id, step.type, isDependency]);
43
40
  return {
44
41
  handleStepDep,
45
42
  isDependency,
@@ -105,9 +102,7 @@ export const useFormStep = (step, { rules, debounce, sizeChange, defaultValue })
105
102
  fieldOnChange(value);
106
103
  if (sizeChange)
107
104
  handleSizeChange?.();
108
- },
109
- // eslint-disable-next-line react-hooks/exhaustive-deps
110
- [handleStepDep, isDependency, fieldOnChange]);
105
+ }, [handleStepDep, isDependency, fieldOnChange]);
111
106
  return {
112
107
  ref,
113
108
  value,
@@ -125,14 +120,11 @@ export const selectDependencies = createSelector([
125
120
  [idDep]: dependencies[idDep],
126
121
  }), {}));
127
122
  export const useCondition = (condition) => {
128
- // eslint-disable-next-line react-hooks/exhaustive-deps
129
123
  const ids = useMemo(() => recursivelyCalcConditionSteps(condition), []);
130
124
  const dependencies = useAppSelector((state) => selectDependencies(state, ids));
131
125
  return useMemo(() => {
132
126
  return !condition || evaluateCondition(condition, dependencies);
133
- },
134
- // eslint-disable-next-line react-hooks/exhaustive-deps
135
- ids.map((id) => dependencies[id].value));
127
+ }, ids.map((id) => dependencies[id].value));
136
128
  };
137
129
  export const calcStepDeps = (step) => {
138
130
  const dependencies = [...(step.dependencies ?? [])];
@@ -63,7 +63,7 @@
63
63
  margin-left: -5px;
64
64
  }
65
65
  .Erk-DraftContainer .rdw-editing-image {
66
- border: 1px solid var(--secondary);
66
+ border: 1px solid var(--eureka-primary);
67
67
  }
68
68
 
69
69
  .Erk-DraftContainer .DraftEditor-root figure {
@@ -80,7 +80,7 @@
80
80
  display: flex;
81
81
  align-items: center;
82
82
  justify-content: center;
83
- border: 1px solid var(--light-grey);
83
+ border: 1px solid var(--eureka-outline);
84
84
  }
85
85
 
86
86
  .Erk-DraftContainer .rdw-image-alignment-options-popup {
@@ -35,9 +35,7 @@ function TextAreaStep({ step, editable }) {
35
35
  }, 1000));
36
36
  }
37
37
  onChange(value);
38
- },
39
- // eslint-disable-next-line react-hooks/exhaustive-deps
40
- [handleStepDep, isDependency, onChange]);
38
+ }, [handleStepDep, isDependency, onChange]);
41
39
  const calcStyle = () => {
42
40
  const backgroundColor = formStyle.stepBackgroundColor;
43
41
  if (focus) {
@@ -13,7 +13,6 @@ function StepFiller({ step, children }) {
13
13
  const currentBreakPoint = useAppSelector(selectBreakPoint);
14
14
  const handleSizeChange = useCallback(() => {
15
15
  setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
16
- // eslint-disable-next-line react-hooks/exhaustive-deps
17
16
  }, []);
18
17
  if (step.maxSize && step.maxSize < form.size.blockNum) {
19
18
  return (_jsxs("div", { className: styles.firstLvlContainer, style: {
@@ -1,7 +1,7 @@
1
1
  import { GSmartSelect } from '../../../@Types/GenericFormSteps';
2
- import { CheckBox, DatePicker, ClassifierSelector, FormSelector, TimePicker } from '../../../@Types/FormStep';
2
+ import { CheckBox, DatePicker, ClassifierSelector, FormSelector, TimePicker, DatePickerRange } from '../../../@Types/FormStep';
3
3
  interface MaterialInputProps {
4
- step: GSmartSelect | CheckBox | ClassifierSelector | DatePicker | TimePicker | FormSelector;
4
+ step: GSmartSelect | CheckBox | ClassifierSelector | DatePicker | TimePicker | FormSelector | DatePickerRange;
5
5
  editable: boolean;
6
6
  onClick?: () => void;
7
7
  children: React.ReactNode;
@@ -9,7 +9,6 @@ function CustomBtn({ label, onClick, backgroundColor, color, loading = false, di
9
9
  if (coords)
10
10
  setCoords(undefined);
11
11
  return () => setMounted(false);
12
- // eslint-disable-next-line react-hooks/exhaustive-deps
13
12
  }, [label]);
14
13
  return (_jsxs("button", { className: styles.customBtn, style: {
15
14
  width,
@@ -1,4 +1,4 @@
1
- import type { StoryObj } from '@storybook/react';
1
+ import type { StoryObj } from '@storybook/react-vite';
2
2
  import ErkButton from './ErkButton';
3
3
  declare const meta: {
4
4
  component: typeof ErkButton;
@@ -6,6 +6,7 @@ declare const meta: {
6
6
  args: {
7
7
  text: string;
8
8
  disabled: false;
9
+ onClick: import("vitest").Mock<(...args: any[]) => any>;
9
10
  };
10
11
  };
11
12
  export default meta;
@@ -1,3 +1,4 @@
1
+ import { fn } from 'storybook/test';
1
2
  import ErkButton from './ErkButton';
2
3
  const meta = {
3
4
  component: ErkButton,
@@ -5,6 +6,7 @@ const meta = {
5
6
  args: {
6
7
  text: 'Label',
7
8
  disabled: false,
9
+ onClick: fn(),
8
10
  },
9
11
  };
10
12
  export default meta;
@@ -1,4 +1,4 @@
1
- import type { StoryObj } from '@storybook/react';
1
+ import type { StoryObj } from '@storybook/react-vite';
2
2
  import ErkCheckBox from './ErkCheckBox';
3
3
  declare const meta: {
4
4
  component: typeof ErkCheckBox;
@@ -1,4 +1,4 @@
1
- import type { StoryObj } from '@storybook/react';
1
+ import type { StoryObj } from '@storybook/react-vite';
2
2
  import ErkDatePicker from './ErkDatePicker';
3
3
  declare const meta: {
4
4
  component: typeof ErkDatePicker;