@arquimedes.co/eureka-forms 3.0.33-test → 3.0.34-react-compiler

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 (34) hide show
  1. package/dist/App/AppHooks.js +3 -0
  2. package/dist/Form/Form.d.ts +1 -1
  3. package/dist/Form/Form.js +5 -2
  4. package/dist/Form/FormHooks.d.ts +1 -1
  5. package/dist/Form/FormHooks.js +1 -0
  6. package/dist/Form/FormTypes/ColumnForm/ColumnForm.js +2 -0
  7. package/dist/Form/FormTypes/StepperForm/StepperForm.js +2 -0
  8. package/dist/Form/Terms/Terms.js +7 -3
  9. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +22 -28
  10. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/addRecursiveElementStep.d.ts +2 -0
  11. package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/addRecursiveElementStep.js +22 -0
  12. package/dist/FormSteps/@Construction/CBRPropertyStep/CBRPropertyStep.js +2 -2
  13. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +3 -3
  14. package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +15 -7
  15. package/dist/FormSteps/DatePickerRangeStep/MaterialDatePickerRangeStep/MaterialDatePickerRangeStep.js +1 -1
  16. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +1 -0
  17. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +44 -43
  18. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.js +4 -4
  19. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PagedMapperElement/PagedMapperElement.js +10 -4
  20. package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +10 -4
  21. package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +7 -1
  22. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +47 -16
  23. package/dist/FormSteps/StepHooks.js +11 -4
  24. package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +3 -1
  25. package/dist/FormSteps/Utils/@StepFiller/StepFiller.js +1 -0
  26. package/dist/Shared/CustomBtn/CustomBtn.js +1 -0
  27. package/dist/Shared/ErkDatePickerRange/ErkDatePickerRange.js +15 -4
  28. package/dist/Shared/ErkMenuItem.d.ts +1 -3
  29. package/dist/Shared/ErkSelect/ErkSelect.d.ts +2 -6
  30. package/dist/Shared/ErkSmartSelect/ErkSmartSelect.js +1 -1
  31. package/dist/Shared/ErkTextField/ErkTextField.js +13 -10
  32. package/dist/Shared/ErkTimePicker/ErkTimePicker.js +4 -4
  33. package/dist/Widget.js +3 -3
  34. package/package.json +72 -65
@@ -125,6 +125,7 @@ export const useSetupApp = (isEmbedded, props) => {
125
125
  // Use stringified keys for stable comparison - only changes when content changes
126
126
  // Other object/function props (classifiers) are still
127
127
  // intentionally excluded to prevent re-renders when parent re-creates these objects
128
+ // eslint-disable-next-line react-hooks/exhaustive-deps
128
129
  }, [
129
130
  apiKey,
130
131
  partial,
@@ -149,6 +150,7 @@ export const useSetupApp = (isEmbedded, props) => {
149
150
  if (handleConfirmed) {
150
151
  handleConfirmed();
151
152
  }
153
+ // eslint-disable-next-line react-hooks/exhaustive-deps
152
154
  }, [form]);
153
155
  return {
154
156
  form,
@@ -174,5 +176,6 @@ export const useLogRocket = (organization, form, { apiKey, internal, postview, p
174
176
  };
175
177
  useEffect(() => {
176
178
  void loadLogRocket();
179
+ // eslint-disable-next-line react-hooks/exhaustive-deps
177
180
  }, [organization, form]);
178
181
  };
@@ -29,7 +29,7 @@ export interface BaseFormProps extends CustomAppProps {
29
29
  isWidget: boolean;
30
30
  apiKey: string | undefined;
31
31
  customSubmit: AppProps['customSubmit'];
32
- containerRef: React.RefObject<HTMLDivElement>;
32
+ containerRef: React.RefObject<HTMLDivElement | null>;
33
33
  scrollToTop?: () => void;
34
34
  }
35
35
  export interface FormComponentProps extends CustomAppProps {
package/dist/Form/Form.js CHANGED
@@ -25,7 +25,7 @@ function FormComponent({ form, apiKey, reload, isWidget, branding, setSubmit, sc
25
25
  shouldFocusError: true,
26
26
  });
27
27
  const idForm = useContext(IdFormContext);
28
- const recaptchaRef = useRef();
28
+ const recaptchaRef = useRef(null);
29
29
  const dispatch = useAppDispatch();
30
30
  const [showConfirmation, setShowConfirmation] = useState();
31
31
  const idFocusStep = useAppSelector((state) => state.site.focusStep);
@@ -34,6 +34,7 @@ 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
37
38
  }, [idFocusStep]);
38
39
  const onSubmit = useCallback(async (values) => {
39
40
  let token = null;
@@ -76,7 +77,9 @@ function FormComponent({ form, apiKey, reload, isWidget, branding, setSubmit, sc
76
77
  catch (error) {
77
78
  console.error(error);
78
79
  }
79
- }, [customSteps, internal, customSubmit, idOrganization, idForm]);
80
+ },
81
+ // eslint-disable-next-line react-hooks/exhaustive-deps
82
+ [customSteps, internal, customSubmit, idOrganization, idForm]);
80
83
  useWidthStats(containerRef, form, postview, internal);
81
84
  const isResponsive = useAppSelector((state) => state.widthStats.isResponsive);
82
85
  const renderForm = () => {
@@ -1,2 +1,2 @@
1
1
  import { Form } from '../@Types';
2
- export declare function useWidthStats(containerRef: React.RefObject<HTMLDivElement>, form: Form, postview: boolean, internal: boolean): void;
2
+ export declare function useWidthStats(containerRef: React.RefObject<HTMLDivElement | null>, form: Form, postview: boolean, internal: boolean): void;
@@ -30,5 +30,6 @@ 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
33
34
  }, []);
34
35
  }
@@ -25,6 +25,7 @@ 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
28
29
  }, [props.setSubmit]);
29
30
  /** Esto se usa para no tener que escuchar todo el tiempo los errores del formulario */
30
31
  const handleErrors = handleSubmit(() => { }, (errors) => {
@@ -46,6 +47,7 @@ function ColumnForm({ onSubmit, customSubmitBtns, ...props }) {
46
47
  values = await onSubmit(values);
47
48
  setLoading(false);
48
49
  return values;
50
+ // eslint-disable-next-line react-hooks/exhaustive-deps
49
51
  }, [form]);
50
52
  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)] }))] }));
51
53
  }
@@ -29,6 +29,7 @@ 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
32
33
  }, []);
33
34
  const handleNext = useCallback(async () => {
34
35
  setLoading('NEXT');
@@ -57,6 +58,7 @@ function StepperForm({ onSubmit, scrollToTop }) {
57
58
  const response = await onSubmit(values);
58
59
  setLoading(undefined);
59
60
  return response;
61
+ // eslint-disable-next-line react-hooks/exhaustive-deps
60
62
  }, [next]);
61
63
  if (!idCurrent)
62
64
  return _jsx(_Fragment, {});
@@ -14,10 +14,14 @@ function Terms() {
14
14
  useEffect(() => {
15
15
  if (!isSubmitting)
16
16
  return;
17
+ // eslint-disable-next-line react-hooks/set-state-in-effect
17
18
  setTempError(true);
18
- setTimeout(() => {
19
- setTempError(false);
20
- }, 500);
19
+ const timer = setTimeout(() => {
20
+ setTimeout(() => {
21
+ setTempError(false);
22
+ }, 500);
23
+ }, 0);
24
+ return () => clearTimeout(timer);
21
25
  }, [isSubmitting]);
22
26
  if (form.terms && (!internal || (internal && postview)) && !isInteralAgent) {
23
27
  return (_jsx("div", { className: styles.termsContainer, style: {
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useContext, useEffect, useState } from 'react';
2
+ import { useCallback, useContext, useEffect, useState } from 'react';
3
3
  import CBRFormStepTypes from '../../../../constants/CBRFormStepTypes';
4
4
  import IncidentComponent from './Incident/Incident';
5
5
  import styles from './MaterialCBRIncidentsStep.module.css';
6
6
  import { nanoid } from 'nanoid';
7
+ import { addRecursiveElementStep } from './addRecursiveElementStep';
7
8
  import ErkButton from '../../../../Shared/ErkButton/ErkButton';
8
9
  import FormContext from '../../../../Contexts/FormContext';
9
10
  import { addStepsDependencies } from '../../../../States/SiteSlice';
@@ -28,14 +29,10 @@ function CBRIncidentsStep({ step, editable, ...others }) {
28
29
  });
29
30
  const [firstRender, setFirstRender] = useState(false);
30
31
  useEffect(() => {
31
- setFirstRender(true);
32
+ const timer = setTimeout(() => setFirstRender(true), 0);
33
+ return () => clearTimeout(timer);
32
34
  }, []);
33
- useEffect(() => {
34
- if (firstRender && value.length === 0 && !postview && editable) {
35
- handleAddIncident();
36
- }
37
- }, [firstRender]);
38
- const handleAddIncident = () => {
35
+ const handleAddIncident = useCallback(() => {
39
36
  const current = value.filter((incident) => !incident.deleted);
40
37
  const newIncident = {
41
38
  idSpaceStep: CBRFormStepTypes.CBR_TIPO_ESPACIO + '-' + nanoid(),
@@ -65,27 +62,24 @@ function CBRIncidentsStep({ step, editable, ...others }) {
65
62
  customSteps,
66
63
  allSteps: { ...form.steps, ...localForm.steps, ...newSteps },
67
64
  }));
68
- };
69
- const addRecursiveElementStep = (idStep, step, idParent, steps, idProjectDep) => {
70
- const idSubStep = CBRFormStepTypes.CBR_LOCATIVAS + '-' + nanoid();
71
- const newSubStep = step.subStep ? { ...step.subStep } : undefined;
72
- const newStep = {
73
- ...step,
74
- id: idStep,
75
- type: CBRFormStepTypes.CBR_LOCATIVAS,
76
- dependencies: [idProjectDep],
77
- subStep: null,
78
- };
79
- if (idParent)
80
- newStep.dependencies.push(idParent);
81
- if (newSubStep) {
82
- newStep.subStep = idSubStep;
83
- }
84
- steps[idStep] = newStep;
85
- if (newSubStep) {
86
- addRecursiveElementStep(idSubStep, newSubStep, idStep, steps, idProjectDep);
65
+ }, [
66
+ customSteps,
67
+ dispatch,
68
+ form.steps,
69
+ localForm,
70
+ onChange,
71
+ step.commentStep,
72
+ step.dependencies,
73
+ step.elementStep,
74
+ step.spaceStep,
75
+ value,
76
+ ]);
77
+ useEffect(() => {
78
+ if (firstRender && value.length === 0 && !postview && editable) {
79
+ const timer = setTimeout(() => handleAddIncident(), 0);
80
+ return () => clearTimeout(timer);
87
81
  }
88
- };
82
+ }, [firstRender, value.length, postview, editable, handleAddIncident]);
89
83
  return (_jsxs("div", { className: styles.container, style: { color: formStyle.textColor }, children: [_jsx("div", { className: styles.titleLbl, children: step.label }), step.description && (_jsx("p", { className: styles.descriptionPar, style: {
90
84
  margin: step.description ? '10px 0px' : '0px 0px 5px 0px',
91
85
  }, children: step.description })), _jsx(FormContext.Provider, { value: localForm, children: value.map((incident, index) => (_jsx(IncidentComponent, { incident: incident, step: step, editable: editable, handleDelete: () => {
@@ -0,0 +1,2 @@
1
+ import { CBRFormStep, IncidentElementStep } from '../../../../@Types/CBRFormStep';
2
+ export declare const addRecursiveElementStep: (idStep: string, step: IncidentElementStep, idParent: string | null, steps: Record<string, CBRFormStep>, idProjectDep: string) => void;
@@ -0,0 +1,22 @@
1
+ import { nanoid } from 'nanoid';
2
+ import CBRFormStepTypes from '../../../../constants/CBRFormStepTypes';
3
+ export const addRecursiveElementStep = (idStep, step, idParent, steps, idProjectDep) => {
4
+ const idSubStep = CBRFormStepTypes.CBR_LOCATIVAS + '-' + nanoid();
5
+ const newSubStep = step.subStep ? { ...step.subStep } : undefined;
6
+ const newStep = {
7
+ ...step,
8
+ id: idStep,
9
+ type: CBRFormStepTypes.CBR_LOCATIVAS,
10
+ dependencies: [idProjectDep],
11
+ subStep: null,
12
+ };
13
+ if (idParent)
14
+ newStep.dependencies.push(idParent);
15
+ if (newSubStep) {
16
+ newStep.subStep = idSubStep;
17
+ }
18
+ steps[idStep] = newStep;
19
+ if (newSubStep) {
20
+ addRecursiveElementStep(idSubStep, newSubStep, idStep, steps, idProjectDep);
21
+ }
22
+ };
@@ -43,7 +43,7 @@ function CBRPropertyStepComponent(props) {
43
43
  return undefined;
44
44
  }, getValueString: (value) => value?.id, getValueWarning: props.step.validation
45
45
  ? (value) => {
46
- if (value && value.entrega !== undefined && props.step.validation) {
46
+ if (value?.entrega !== undefined && props.step.validation) {
47
47
  const date = new Date(value.entrega);
48
48
  const today = new Date();
49
49
  const time = today.getTime() - date.getTime();
@@ -56,7 +56,7 @@ function CBRPropertyStepComponent(props) {
56
56
  }
57
57
  : undefined, changeListener: props.step.validation
58
58
  ? (value) => {
59
- if (value && value.entrega !== undefined && props.step.validation) {
59
+ if (value?.entrega !== undefined && props.step.validation) {
60
60
  const date = new Date(value.entrega);
61
61
  const today = new Date();
62
62
  const time = today.getTime() - date.getTime();
@@ -25,7 +25,7 @@ function ClassifierSelectorStep({ step, editable }) {
25
25
  }
26
26
  }
27
27
  return dependencies;
28
- }, []);
28
+ }, [step]);
29
29
  const dependencies = useAppSelector((state) => selectDependencies(state, idDependencies));
30
30
  const { postview, preview } = useAppSelector((state) => state.global);
31
31
  const form = useContext(FormContext);
@@ -46,12 +46,12 @@ function ClassifierSelectorStep({ step, editable }) {
46
46
  label: classifier?.clientName?.trim?.() && preview ? classifier?.clientName : classifier?.name,
47
47
  };
48
48
  });
49
- }, idDependencies.map((id) => dependencies[id].value));
49
+ }, [classifier, form, dependencies, preview, step.options]);
50
50
  useEffect(() => {
51
51
  if (value && !options?.find((option) => option.value === value?.value)) {
52
52
  onChange('');
53
53
  }
54
- }, [options]);
54
+ }, [options, value, onChange]);
55
55
  if (!step.idClassifier || !classifier)
56
56
  return _jsx(_Fragment, {});
57
57
  const mapNestedOption = () => {
@@ -14,11 +14,23 @@ function Collapsible({ step, open, setOpen, ...others }) {
14
14
  const form = useContext(FormContext);
15
15
  const { formState: { errors }, } = useFormContext();
16
16
  const contentRef = React.useRef(null);
17
+ const [heightState, setHeightState] = useState(0);
18
+ React.useLayoutEffect(() => {
19
+ if (open) {
20
+ if (firstTime)
21
+ setHeightState('auto');
22
+ else
23
+ setHeightState(contentRef.current?.offsetHeight ?? 'auto');
24
+ }
25
+ else {
26
+ setHeightState(0);
27
+ }
28
+ }, [open, firstTime]);
17
29
  useEffect(() => {
18
30
  if (!open && step.dependencies?.find((dep) => !!errors[dep])) {
19
31
  setOpen(true);
20
32
  }
21
- }, step.dependencies?.map((dep) => errors[dep]) ?? []);
33
+ }, [open, step.dependencies, errors, setOpen]);
22
34
  return (_jsxs("div", { style: { maxWidth: '100%' }, children: [_jsxs("div", { className: styles.container, style: {
23
35
  color: formStyle.textColor,
24
36
  borderColor: formStyle.primaryColor,
@@ -31,14 +43,10 @@ function Collapsible({ step, open, setOpen, ...others }) {
31
43
  setFirstTime(false);
32
44
  setOpen(!open);
33
45
  }, children: _jsx("div", { className: styles.expandIcon, children: open ? (_jsx(ExpandLessIcon, { style: { fontSize: 'inherit' } })) : (_jsx(ExpandMoreIcon, { style: { fontSize: 'inherit' } })) }) })] }), _jsx("div", { className: styles.content, style: {
34
- height: open
35
- ? firstTime
36
- ? 'auto'
37
- : contentRef.current?.offsetHeight
38
- : 0,
46
+ height: heightState,
39
47
  }, children: _jsx("div", { className: styles.contentContainer, ref: contentRef, children: step.steps.map((idSubStep) => {
40
48
  const subStep = form.steps[idSubStep];
41
- return (_createElement(StepComponent, { ...others, step: subStep, key: idSubStep }));
49
+ return _createElement(StepComponent, { ...others, step: subStep, key: idSubStep });
42
50
  }) }) }), _jsx("div", { className: styles.separator, style: {
43
51
  backgroundColor: formStyle.primaryColor,
44
52
  } })] }));
@@ -28,7 +28,7 @@ function MaterialDatePickerRangeStep({ step, editable, defaultValue }) {
28
28
  }
29
29
  }, [onChange]);
30
30
  const [minDate, maxDate] = [safeDate(step.minDate), safeDate(step.maxDate)];
31
- const dateRangeValue = value && value.length === 2 ? [safeDate(value[0]) ?? null, safeDate(value[1]) ?? null] : [null, null];
31
+ const dateRangeValue = value?.length === 2 ? [safeDate(value[0]) ?? null, safeDate(value[1]) ?? null] : [null, null];
32
32
  return (_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkDatePickerRange, { ...field, value: dateRangeValue, inputRef: ref, error: !!error, minDate: minDate, maxDate: maxDate, labelMargin: 0, onChange: handleChange, required: step.required, readOnly: !editable || postview, helperText: error?.message ?? step.description }) }));
33
33
  }
34
34
  export default MaterialDatePickerRangeStep;
@@ -22,6 +22,7 @@ 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
25
26
  }, []);
26
27
  const dialogDeps = useAppSelector((state) => selectDependencies(state, dialogsIdStepDeps));
27
28
  const handleCloseDialog = useCallback(() => {
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styles from './MaterialFileUploadStep.module.css';
3
3
  import { useFormContext } from 'react-hook-form';
4
4
  import ErkButton from '../../../Shared/ErkButton/ErkButton';
5
- import { useContext, useEffect, useRef, useState } from 'react';
5
+ import { useCallback, useContext, useEffect, useRef, useState } from 'react';
6
6
  import { getAcceptedExtensions } from '../../../constants/Files/FileExtensions';
7
7
  import { getUploadUrls, postFile } from '../../../Services/FileService';
8
8
  import FileComponent from './FileComponent/FileComponent';
@@ -23,7 +23,47 @@ function FileUploadStep({ step, editable }) {
23
23
  const { clearErrors } = useFormContext();
24
24
  const [error, setError] = useState(undefined);
25
25
  const [fileChange, setFileChange] = useState([]);
26
- const inputRef = useRef();
26
+ const inputRef = useRef(null);
27
+ const getLinks = useCallback(async (pFiles) => {
28
+ try {
29
+ const fileLinks = await getUploadUrls(pFiles.map((file) => file.file), idOrganization);
30
+ const errorsExt = [];
31
+ setFileChange(pFiles.map((file, index) => {
32
+ if (fileLinks[index] === 'ERROR:INVALIDEXTENSION') {
33
+ errorsExt.push(file.file.name.split('.').pop() ?? '');
34
+ return { ...file, state: 'ERROR' };
35
+ }
36
+ else {
37
+ return {
38
+ ...file,
39
+ state: 'UPLOADING',
40
+ postInfo: fileLinks[index],
41
+ };
42
+ }
43
+ }));
44
+ if (errorsExt.length === 1) {
45
+ setError('La extención .' + errorsExt[0] + ' no es válida');
46
+ }
47
+ else if (errorsExt.length > 1) {
48
+ setError('Las extenciónes .' + errorsExt.join(',.') + ' no son válidas');
49
+ }
50
+ }
51
+ catch (error) {
52
+ console.error(error);
53
+ }
54
+ }, [idOrganization]);
55
+ const uploadFile = useCallback(async (pFile) => {
56
+ try {
57
+ const resp = await Promise.all([
58
+ postFile(pFile.file, pFile.postInfo),
59
+ new Promise((resolve) => setTimeout(resolve, 1000)),
60
+ ]);
61
+ setFileChange([{ ...pFile, state: 'DONE', ...resp[0] }]);
62
+ }
63
+ catch (error) {
64
+ console.error(error);
65
+ }
66
+ }, []);
27
67
  useEffect(() => {
28
68
  const filesToFetchLink = [];
29
69
  const filesChanged = [];
@@ -32,6 +72,7 @@ function FileUploadStep({ step, editable }) {
32
72
  filesToFetchLink.push(file);
33
73
  }
34
74
  if (file.state === 'UPLOADING') {
75
+ // eslint-disable-next-line
35
76
  void uploadFile(file);
36
77
  filesChanged.push(file);
37
78
  }
@@ -64,47 +105,7 @@ function FileUploadStep({ step, editable }) {
64
105
  void getLinks(filesToFetchLink);
65
106
  onChange([...value, ...filesToFetchLink]);
66
107
  }
67
- }, [fileChange]);
68
- async function getLinks(pFiles) {
69
- try {
70
- const fileLinks = await getUploadUrls(pFiles.map((file) => file.file), idOrganization);
71
- const errorsExt = [];
72
- setFileChange(pFiles.map((file, index) => {
73
- if (fileLinks[index] === 'ERROR:INVALIDEXTENSION') {
74
- errorsExt.push(file.file.name.split('.').pop() ?? '');
75
- return { ...file, state: 'ERROR' };
76
- }
77
- else {
78
- return {
79
- ...file,
80
- state: 'UPLOADING',
81
- postInfo: fileLinks[index],
82
- };
83
- }
84
- }));
85
- if (errorsExt.length === 1) {
86
- setError('La extención .' + errorsExt[0] + ' no es válida');
87
- }
88
- else if (errorsExt.length > 1) {
89
- setError('Las extenciónes .' + errorsExt.join(',.') + ' no son válidas');
90
- }
91
- }
92
- catch (error) {
93
- console.error(error);
94
- }
95
- }
96
- async function uploadFile(pFile) {
97
- try {
98
- const resp = await Promise.all([
99
- postFile(pFile.file, pFile.postInfo),
100
- new Promise((resolve) => setTimeout(resolve, 1000)),
101
- ]);
102
- setFileChange([{ ...pFile, state: 'DONE', ...resp[0] }]);
103
- }
104
- catch (error) {
105
- console.error(error);
106
- }
107
- }
108
+ }, [fileChange, getLinks, onChange, uploadFile, value]);
108
109
  const calcErrorMsg = () => {
109
110
  if (fieldError) {
110
111
  const errNum = value.filter((val) => val.state === 'ERROR').length;
@@ -9,17 +9,17 @@ import FormContext from '../../../../Contexts/FormContext';
9
9
  import CustomContext from '../../../../Contexts/CustomContext';
10
10
  import PagedMapperElement from './PagedMapperElement/PagedMapperElement';
11
11
  function MapperElementComponent(props) {
12
- const { step, element, editable } = props;
12
+ const { step, element, editable, calcCustomStepProps } = props;
13
13
  const customContext = useContext(CustomContext);
14
14
  const form = useContext(FormContext);
15
15
  const nestedCustomContext = useMemo(() => {
16
- if (!props.calcCustomStepProps)
16
+ if (!calcCustomStepProps)
17
17
  return customContext;
18
18
  return {
19
19
  ...customContext,
20
- customStepProps: props.calcCustomStepProps(element, customContext.customStepProps),
20
+ customStepProps: calcCustomStepProps(element, customContext.customStepProps),
21
21
  };
22
- }, [element, customContext]);
22
+ }, [element, customContext, calcCustomStepProps]);
23
23
  if (element.deleted)
24
24
  return _jsx(_Fragment, {});
25
25
  const mapSubSteps = () => {
@@ -29,7 +29,7 @@ function PagedMapperElement({ step, num, loading, element, children, editable, o
29
29
  }
30
30
  }
31
31
  return null;
32
- }, [value]);
32
+ }, [elements, page]);
33
33
  const prevIndex = useMemo(() => {
34
34
  for (let i = page - 1; i >= 0; i--) {
35
35
  const element = elements[i];
@@ -38,7 +38,7 @@ function PagedMapperElement({ step, num, loading, element, children, editable, o
38
38
  }
39
39
  }
40
40
  return null;
41
- }, [value]);
41
+ }, [elements, page]);
42
42
  /** Esto se usa para no tener que escuchar todo el tiempo los errores del formulario */
43
43
  const handleErrors = handleSubmit(() => { }, (errors) => {
44
44
  console.error('Errors:', errors);
@@ -68,10 +68,16 @@ function PagedMapperElement({ step, num, loading, element, children, editable, o
68
68
  page: index,
69
69
  });
70
70
  return;
71
- }, [elements]);
71
+ }, [dispatch, element.id, elements, getValues, handleErrors, onChange, step.id, trigger]);
72
72
  const widthStats = useAppSelector((state) => state.widthStats);
73
73
  const { calcName } = customElementModifiers ?? {};
74
74
  const name = calcName ? calcName(element) : step.unitLabel ? step.unitLabel + ' ' + (num + 1) : '';
75
+ const [pagingWidth, setPagingWidth] = React.useState(0);
76
+ React.useLayoutEffect(() => {
77
+ if (pagingRef.current) {
78
+ setPagingWidth(pagingRef.current.clientWidth);
79
+ }
80
+ }, []);
75
81
  const renderElement = (renderElementButtons) => {
76
82
  return (_jsx("div", { className: widthStats.isMobile ? styles.mobileContainer : styles.container, ref: containerRef, children: _jsxs("div", { className: styles.contentContainer, style: {
77
83
  width: (size.blockSize + size.spacingSize) * (step.style?.size ?? size.blockNum - 1),
@@ -79,7 +85,7 @@ function PagedMapperElement({ step, num, loading, element, children, editable, o
79
85
  if (editable && !postview) {
80
86
  handleDelete?.();
81
87
  }
82
- }, children: _jsx(DeleteIcon, { style: { fontSize: 'inherit' } }) }))] }), children, totalElements.length > 0 && (_jsx("div", { className: styles.pagingContainer, ref: pagingRef, children: _jsx(CustomStepper, { totalElements: totalElements.length, position: position, handleNext: nextIndex !== null ? () => void handleChangePage(nextIndex) : undefined, handlePrev: prevIndex !== null ? () => void handleChangePage(prevIndex) : undefined, width: pagingRef.current?.clientWidth }) }))] }) }));
88
+ }, children: _jsx(DeleteIcon, { style: { fontSize: 'inherit' } }) }))] }), children, totalElements.length > 0 && (_jsx("div", { className: styles.pagingContainer, ref: pagingRef, children: _jsx(CustomStepper, { totalElements: totalElements.length, position: position, handleNext: nextIndex !== null ? () => void handleChangePage(nextIndex) : undefined, handlePrev: prevIndex !== null ? () => void handleChangePage(prevIndex) : undefined, width: pagingWidth }) }))] }) }));
83
89
  };
84
90
  return (_jsx("div", { className: styles.containerContainer, children: customElementRender ? customElementRender(element, num, renderElement) : renderElement() }));
85
91
  }
@@ -33,7 +33,9 @@ function MapperComponent({ form, step, error, value, loading, inputRef, editable
33
33
  elements: tempElements,
34
34
  page: page === index ? newPage : page,
35
35
  });
36
- }, [elements, onChange]);
36
+ },
37
+ // eslint-disable-next-line react-hooks/exhaustive-deps
38
+ [elements, onChange]);
37
39
  const inputValue = useMemo(() => JSON.stringify(elements), [elements]);
38
40
  const { formStyle, postview } = useAppSelector((state) => state.global);
39
41
  const { container } = useMemo(() => {
@@ -87,6 +89,7 @@ function MapperStep(props) {
87
89
  if (!customAdd)
88
90
  handleAddElement();
89
91
  }
92
+ // eslint-disable-next-line react-hooks/exhaustive-deps
90
93
  }, []);
91
94
  const handleAddElement = useCallback((elementValue) => {
92
95
  const { element, steps, mappers } = addMapperStep(step, customSteps);
@@ -106,7 +109,10 @@ function MapperStep(props) {
106
109
  customSteps,
107
110
  allSteps: { ...form.steps, ...steps },
108
111
  }));
109
- }, [step, form, customSteps, value, onChange]);
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
110
116
  const subForm = useMemo(() => ({ ...form, steps: { ...form.steps, ...localSteps } }), [localSteps]);
111
117
  return (_jsx(MapperComponent, { ...props, error: error, inputRef: ref, onChange: onChange, value: value, handleAddElement: handleAddElement, form: subForm }));
112
118
  }
@@ -136,8 +142,8 @@ export function CustomMapperStep(props) {
136
142
  customSteps,
137
143
  allSteps: { ...form.steps, ...steps },
138
144
  }));
139
- }, [step, form, customSteps, elements, onChange]);
140
- const subForm = useMemo(() => ({ ...form, steps: { ...form.steps, ...localSteps } }), [localSteps]);
145
+ }, [step, form, customSteps, elements, onChange, dispatch, setValue]);
146
+ const subForm = useMemo(() => ({ ...form, steps: { ...form.steps, ...localSteps } }), [localSteps, form]);
141
147
  return _jsx(MapperComponent, { ...props, form: subForm, onChange: onChange, handleAddElement: handleAddElement });
142
148
  }
143
149
  export default MapperStep;
@@ -27,6 +27,7 @@ function SelectorStep({ step, editable }) {
27
27
  }
28
28
  }
29
29
  return dependencies;
30
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30
31
  }, []);
31
32
  const dependencies = useAppSelector((state) => selectDependencies(state, idDependencies));
32
33
  const mapNestedOption = () => {
@@ -47,17 +48,22 @@ function SelectorStep({ step, editable }) {
47
48
  }
48
49
  return null;
49
50
  };
51
+ const dependenciesValues = useMemo(() => {
52
+ return idDependencies.map((id) => dependencies[id].value);
53
+ }, [dependencies, idDependencies]);
50
54
  const filteredOptions = useMemo(() => {
51
55
  return step.options.filter((option) => {
52
56
  if (!option.condition || evaluateCondition(option.condition, dependencies))
53
57
  return true;
54
58
  return false;
55
59
  });
56
- }, idDependencies.map((id) => dependencies[id].value));
60
+ // eslint-disable-next-line react-hooks/exhaustive-deps
61
+ }, [dependenciesValues]);
57
62
  useEffect(() => {
58
63
  if (value && !filteredOptions.find((option) => option.value === value?.value)) {
59
64
  onChange('');
60
65
  }
66
+ // eslint-disable-next-line react-hooks/exhaustive-deps
61
67
  }, [filteredOptions]);
62
68
  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()] }));
63
69
  }
@@ -32,21 +32,11 @@ 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, idDependencies.map((id) => deps[id]));
35
+ const conditionDependencies = useMemo(() => deps, [deps]);
36
36
  const { emptyDep, invalids } = useAppSelector((state) => selectStepDependencies(state, step, form));
37
37
  const { getValues, setFocus } = useFormContext();
38
38
  const isEmpty = useAppSelector((state) => state.site.dependencies[step.id]?.empty);
39
- useEffect(() => {
40
- if (!postview && editable) {
41
- void calcOptions(firstTime);
42
- if (firstTime)
43
- setFirstTime(false);
44
- }
45
- else if (value && !step.searchable) {
46
- setOptions([value]);
47
- }
48
- }, allDeps.map((dep) => dependencies[dep]?.value) ?? []);
49
- const calcOptions = async (firstTime) => {
39
+ const calcOptions = useCallback(async (firstTime) => {
50
40
  if (!firstTime)
51
41
  setOptions(undefined);
52
42
  if (value && !firstTime)
@@ -81,7 +71,34 @@ function SmartSelectStep({ step, editable, getOptions, calcDepError, defaultValu
81
71
  setOptions(null);
82
72
  }
83
73
  setLoading(false);
84
- };
74
+ }, [
75
+ dependencies,
76
+ dispatch,
77
+ getOptions,
78
+ getValueString,
79
+ idCurrentAgent,
80
+ idOrganization,
81
+ isEmpty,
82
+ onChange,
83
+ postview,
84
+ step,
85
+ value,
86
+ ]);
87
+ useEffect(() => {
88
+ if (!postview && editable) {
89
+ const timer = setTimeout(() => {
90
+ void calcOptions(firstTime);
91
+ if (firstTime)
92
+ setFirstTime(false);
93
+ }, 0);
94
+ return () => clearTimeout(timer);
95
+ }
96
+ else if (value && !step.searchable) {
97
+ setTimeout(() => {
98
+ setOptions([value]);
99
+ }, 0);
100
+ }
101
+ }, [allDeps, dependencies, editable, firstTime, postview, step.searchable, value, calcOptions]);
85
102
  const warning = useMemo(() => getValueWarning?.(value), [value, getValueWarning]);
86
103
  const onFocus = useCallback(() => {
87
104
  if (emptyDep || !editable || postview)
@@ -110,12 +127,26 @@ function SmartSelectStep({ step, editable, getOptions, calcDepError, defaultValu
110
127
  }
111
128
  if (!touched)
112
129
  setTouched(true);
113
- }, [options, emptyDep, postview, editable, invalids, touched]);
130
+ }, [
131
+ options,
132
+ emptyDep,
133
+ postview,
134
+ editable,
135
+ invalids,
136
+ touched,
137
+ dispatch,
138
+ form.steps,
139
+ form.type,
140
+ getValues,
141
+ setFocus,
142
+ step.idSection,
143
+ value,
144
+ ]);
114
145
  const filteredOptions = useMemo(() => {
115
146
  if (!options || !filterOptions)
116
147
  return options;
117
148
  return filterOptions(options, conditionDependencies);
118
- }, [options, conditionDependencies]);
149
+ }, [options, conditionDependencies, filterOptions]);
119
150
  const errorMsg = useMemo(() => {
120
151
  if (postview || loading)
121
152
  return undefined;
@@ -132,7 +163,7 @@ function SmartSelectStep({ step, editable, getOptions, calcDepError, defaultValu
132
163
  return 'Error al cargar las opciones';
133
164
  }
134
165
  return undefined;
135
- }, [invalids, touched, value, filteredOptions]);
166
+ }, [invalids, touched, value, filteredOptions, calcDepError, form.steps, getOptionSelected, loading, postview]);
136
167
  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)] }));
137
168
  }
138
169
  export default SmartSelectStep;
@@ -28,6 +28,7 @@ export const useStepDependency = (step, defaultValue) => {
28
28
  return () => {
29
29
  dispatch(clearDependency(step));
30
30
  };
31
+ // eslint-disable-next-line react-hooks/exhaustive-deps
31
32
  }, [isDependency]);
32
33
  const handleStepDep = useCallback((value) => {
33
34
  if (!isDependency)
@@ -36,7 +37,9 @@ export const useStepDependency = (step, defaultValue) => {
36
37
  step,
37
38
  value: value ?? null,
38
39
  }));
39
- }, [step.id, step.type, isDependency]);
40
+ },
41
+ // eslint-disable-next-line react-hooks/exhaustive-deps
42
+ [step.id, step.type, isDependency]);
40
43
  return {
41
44
  handleStepDep,
42
45
  isDependency,
@@ -102,7 +105,9 @@ export const useFormStep = (step, { rules, debounce, sizeChange, defaultValue })
102
105
  fieldOnChange(value);
103
106
  if (sizeChange)
104
107
  handleSizeChange?.();
105
- }, [handleStepDep, isDependency, fieldOnChange]);
108
+ },
109
+ // eslint-disable-next-line react-hooks/exhaustive-deps
110
+ [handleStepDep, isDependency, fieldOnChange]);
106
111
  return {
107
112
  ref,
108
113
  value,
@@ -120,11 +125,13 @@ export const selectDependencies = createSelector([
120
125
  [idDep]: dependencies[idDep],
121
126
  }), {}));
122
127
  export const useCondition = (condition) => {
123
- const ids = useMemo(() => recursivelyCalcConditionSteps(condition), []);
128
+ const ids = useMemo(() => recursivelyCalcConditionSteps(condition), [condition]);
124
129
  const dependencies = useAppSelector((state) => selectDependencies(state, ids));
130
+ const dependenciesValues = useMemo(() => ids.map((id) => dependencies[id].value), [dependencies, ids]);
125
131
  return useMemo(() => {
126
132
  return !condition || evaluateCondition(condition, dependencies);
127
- }, ids.map((id) => dependencies[id].value));
133
+ // eslint-disable-next-line react-hooks/exhaustive-deps
134
+ }, [dependenciesValues]);
128
135
  };
129
136
  export const calcStepDeps = (step) => {
130
137
  const dependencies = [...(step.dependencies ?? [])];
@@ -35,7 +35,9 @@ function TextAreaStep({ step, editable }) {
35
35
  }, 1000));
36
36
  }
37
37
  onChange(value);
38
- }, [handleStepDep, isDependency, onChange]);
38
+ },
39
+ // eslint-disable-next-line react-hooks/exhaustive-deps
40
+ [handleStepDep, isDependency, onChange]);
39
41
  const calcStyle = () => {
40
42
  const backgroundColor = formStyle.stepBackgroundColor;
41
43
  if (focus) {
@@ -13,6 +13,7 @@ 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
16
17
  }, []);
17
18
  if (step.maxSize && step.maxSize < form.size.blockNum) {
18
19
  return (_jsxs("div", { className: styles.firstLvlContainer, style: {
@@ -9,6 +9,7 @@ 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
12
13
  }, [label]);
13
14
  return (_jsxs("button", { className: styles.customBtn, style: {
14
15
  width,
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
3
  import { styled, Dialog as MuiDialog } from '@mui/material';
4
- import { DatePickerToolbar as MuiDatePickerToolbar, } from '@mui/x-date-pickers';
4
+ import { DatePickerToolbar as MuiDatePickerToolbar, usePickerContext, } from '@mui/x-date-pickers';
5
5
  import { MobileDateRangePicker as MuiDateRangePicker, } from '@mui/x-date-pickers-pro/MobileDateRangePicker';
6
6
  import { DateRangePickerDay as MuiDateRangePickerDay } from '@mui/x-date-pickers-pro';
7
7
  import { SingleInputDateRangeField } from '@mui/x-date-pickers-pro/SingleInputDateRangeField';
8
- import { format } from 'date-fns';
8
+ import { format, isValid } from 'date-fns';
9
+ import { StyledTextField } from '../ErkTextField/ErkTextField';
9
10
  import CalendarIcon from '../../Icons/CalendarIcon';
10
11
  const StyledDateRangePicker = styled(MuiDateRangePicker, {
11
12
  shouldForwardProp: (propName) => propName !== 'size',
@@ -83,15 +84,24 @@ const StyledDay = styled(MuiDateRangePickerDay)(({ theme }) => ({
83
84
  backgroundColor: theme.palette.primary.main + '1a',
84
85
  },
85
86
  }));
87
+ // eslint-disable-next-line react/display-name
88
+ const CustomTextField = React.forwardRef((props, ref) => {
89
+ const pickerContext = usePickerContext();
90
+ return _jsx(StyledTextField, { ...props, inputRef: ref, onClick: () => pickerContext.setOpen((prev) => !prev) });
91
+ });
86
92
  const formatDate = (date, showYear) => {
87
- if (!date)
93
+ if (!date || !isValid(date))
88
94
  return '';
89
95
  return format(date, showYear ? 'PP' : 'dd MMM');
90
96
  };
91
97
  function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = 'small', labelMargin = 5, value, onChange, ...others }) {
92
98
  const [startDate, endDate] = value ?? [null, null];
93
99
  const hasCompleteRange = Boolean(startDate) && Boolean(endDate);
94
- const showYear = startDate && endDate && startDate.getFullYear() !== endDate.getFullYear();
100
+ const showYear = startDate &&
101
+ endDate &&
102
+ isValid(startDate) &&
103
+ isValid(endDate) &&
104
+ startDate.getFullYear() !== endDate.getFullYear();
95
105
  const formattedStartDate = formatDate(startDate, Boolean(showYear));
96
106
  const formattedEndDate = formatDate(endDate, Boolean(showYear));
97
107
  const toolbarText = hasCompleteRange ? `${formattedStartDate} – ${formattedEndDate}` : '– –';
@@ -103,6 +113,7 @@ function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = '
103
113
  dialog: StyledDialog,
104
114
  toolbar: StyledDateToolBar,
105
115
  openPickerIcon: CalendarIcon,
116
+ textField: CustomTextField,
106
117
  }, slotProps: {
107
118
  actionBar: {
108
119
  actions: ['clear', 'accept'],
@@ -1,4 +1,2 @@
1
- declare const Styled: import("@emotion/styled").StyledComponent<import("@mui/material").MenuItemOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & {
2
- ref?: ((instance: HTMLLIElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLLIElement> | null | undefined;
3
- }, "children" | "className" | "style" | "classes" | "autoFocus" | "tabIndex" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "dense" | "disableGutters" | "divider" | "selected"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
1
+ declare const Styled: import("@emotion/styled").StyledComponent<import("@mui/material").MenuItemOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "children" | "className" | "style" | "classes" | "autoFocus" | "tabIndex" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "dense" | "disableGutters" | "divider" | "selected"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
4
2
  export default Styled;
@@ -5,16 +5,12 @@ export interface SelectorStyleProps {
5
5
  readOnly?: boolean;
6
6
  }
7
7
  export declare const StyledSelect: import("@emotion/styled").StyledComponent<(import("@mui/material").FilledSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) | (import("@mui/material").StandardSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) | (import("@mui/material").OutlinedSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>), {}, {}>;
8
- export declare const StyledInputLabel: import("@emotion/styled").StyledComponent<import("@mui/material").InputLabelOwnProps & Pick<import("@mui/material").FormLabelOwnProps, "color" | "filled"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & {
9
- ref?: ((instance: HTMLLabelElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject<HTMLLabelElement> | null | undefined;
10
- }, "required" | "size" | "color" | "children" | "className" | "style" | "classes" | "disabled" | "sx" | "margin" | "error" | "filled" | "variant" | "focused" | "disableAnimation" | "shrink"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
8
+ export declare const StyledInputLabel: import("@emotion/styled").StyledComponent<import("@mui/material").InputLabelOwnProps & Pick<import("@mui/material").FormLabelOwnProps, "color" | "filled"> & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "required" | "size" | "color" | "children" | "className" | "style" | "classes" | "disabled" | "sx" | "margin" | "error" | "filled" | "variant" | "focused" | "disableAnimation" | "shrink"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
11
9
  component?: React.ElementType;
12
10
  } & {
13
11
  open: boolean;
14
12
  }, {}, {}>;
15
- export declare const StyledHelperText: import("@emotion/styled").StyledComponent<import("@mui/material").FormHelperTextOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & {
16
- ref?: ((instance: HTMLParagraphElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject<HTMLParagraphElement> | null | undefined;
17
- }, "required" | "children" | "className" | "style" | "classes" | "disabled" | "sx" | "margin" | "error" | "filled" | "variant" | "focused"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
13
+ export declare const StyledHelperText: import("@emotion/styled").StyledComponent<import("@mui/material").FormHelperTextOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "required" | "children" | "className" | "style" | "classes" | "disabled" | "sx" | "margin" | "error" | "filled" | "variant" | "focused"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
18
14
  component?: React.ElementType;
19
15
  }, {}, {}>;
20
16
  export type ErkSelectValue<Type extends string | number, Multiple, Clearable> = Multiple extends true ? Type[] : Clearable extends true ? Type | undefined : Type;
@@ -28,7 +28,7 @@ const StyledAutoComplete = styled(MuiAutocomplete)(({ theme, readOnly, ...props
28
28
  export default function ErkSmartSelect({ options, value = '', onChange, label, getValueString = (value) => value?.value, loading = false, getOptionSelected, IconComponent, size = 'small', disabled = false, readOnly = false, searchable = false, inputRef, ...others }) {
29
29
  if (searchable) {
30
30
  return (_jsx(StyledAutoComplete, { fullWidth: true, openOnFocus: true, size: size, loading: loading, disabled: disabled || readOnly, readOnly: readOnly, options: options ?? [], loadingText: "Cargando...", onFocus: others.onFocus, "data-testid": "smart-select", noOptionsText: "No hay opciones", value: !loading && value ? value : null, onChange: (_event, newValue) => onChange?.(newValue), popupIcon: loading ? _jsx(CircularProgress, { size: 22 }) : IconComponent ? _jsx(IconComponent, {}) : undefined, filterOptions: (options, params) => {
31
- if (value && value.label === params?.inputValue) {
31
+ if (value?.label === params?.inputValue) {
32
32
  return options;
33
33
  }
34
34
  else {
@@ -100,17 +100,20 @@ function CustomTextfield({ onChange, value = '', IconComponent, size = 'small',
100
100
  const handleChange = useCallback((event) => {
101
101
  onChange?.(event.target.value);
102
102
  }, [onChange]);
103
- const inputProps = useMemo(() => ({
104
- ...others.inputProps,
105
- spellCheck: true,
106
- endAdornment: IconComponent,
107
- readOnly: !!readOnly,
108
- disabled: !!readOnly || !!disabled,
109
- }), [others.inputProps, IconComponent, readOnly, disabled]);
103
+ const inputProps = useMemo(() => {
104
+ const mergedInputProps = {
105
+ ...others.inputProps,
106
+ spellCheck: true,
107
+ endAdornment: IconComponent,
108
+ readOnly: !!readOnly,
109
+ disabled: !!readOnly || !!disabled,
110
+ };
111
+ if (maxLength) {
112
+ mergedInputProps.inputProps = { maxLength };
113
+ }
114
+ return mergedInputProps;
115
+ }, [others.inputProps, IconComponent, readOnly, disabled, maxLength]);
110
116
  const length = maxLength ? value.toString()?.length : null;
111
- if (maxLength) {
112
- inputProps.inputProps = { maxLength };
113
- }
114
117
  const helperText = others.helperText ?? (others.error === false && !others.readOnly ? ' ' : undefined);
115
118
  return (_jsxs("div", { style: {
116
119
  position: 'relative',
@@ -3,12 +3,12 @@ import { StyledHelperText, StyledInputLabel, StyledSelect } from '../ErkSelect/E
3
3
  import styles from './ErkTimePicker.module.css';
4
4
  import ClockIcon from '../../Icons/ClockIcon';
5
5
  import { ClickAwayListener, FormControl, InputAdornment, MenuItem, Popper, useTheme, } from '@mui/material';
6
- import React, { useCallback, useRef, useState } from 'react';
6
+ import React, { useCallback, useState } from 'react';
7
7
  import { StyledTextField } from '../ErkTextField/ErkTextField';
8
8
  import ErkToggle from '../Toggle/Toggle';
9
9
  function CustomSelect({ value, onChange, label, error, required, pickDays, helperText, readOnly = false, disabled = false, minDays = 0, maxDays, pickHours, minHours = 0, maxHours, pickMinutes, minMinutes = 0, maxMinutes, working, labelMargin = 5, size = 'small', ...others }) {
10
10
  const [open, setOpen] = useState(false);
11
- const ref = useRef(null);
11
+ const [anchorEl, setAnchorEl] = useState(null);
12
12
  const { palette } = useTheme();
13
13
  const handleChange = useCallback((value) => {
14
14
  const time = { ...value };
@@ -34,7 +34,7 @@ function CustomSelect({ value, onChange, label, error, required, pickDays, helpe
34
34
  parts.push('*');
35
35
  return parts.join(' ');
36
36
  };
37
- return (_jsxs(_Fragment, { children: [open && (_jsx(ClickAwayListener, { mouseEvent: "onMouseDown", onClickAway: () => setOpen(false), children: _jsx(Popper, { open: true, anchorEl: ref.current, placement: 'bottom-start', modifiers: [
37
+ return (_jsxs(_Fragment, { children: [open && (_jsx(ClickAwayListener, { mouseEvent: "onMouseDown", onClickAway: () => setOpen(false), children: _jsx(Popper, { open: true, anchorEl: anchorEl, placement: 'bottom-start', modifiers: [
38
38
  {
39
39
  name: 'preventOverflow',
40
40
  enabled: true,
@@ -53,7 +53,7 @@ function CustomSelect({ value, onChange, label, error, required, pickDays, helpe
53
53
  ...value,
54
54
  working,
55
55
  });
56
- } })] }))] }) }) })), _jsxs(FormControl, { fullWidth: true, size: size, error: error, variant: "outlined", required: required, style: { marginTop: label ? labelMargin : undefined, maxWidth: '100%' }, children: [label && (_jsx(StyledInputLabel, { disabled: disabled, open: open, size: size === 'small' ? 'small' : undefined, children: label })), _jsx(StyledSelect, { ...others, ref: ref, open: open, size: size, readOnly: readOnly, disabled: disabled, onBlur: () => {
56
+ } })] }))] }) }) })), _jsxs(FormControl, { fullWidth: true, size: size, error: error, variant: "outlined", required: required, style: { marginTop: label ? labelMargin : undefined, maxWidth: '100%' }, children: [label && (_jsx(StyledInputLabel, { disabled: disabled, open: open, size: size === 'small' ? 'small' : undefined, children: label })), _jsx(StyledSelect, { ...others, ref: setAnchorEl, open: open, size: size, readOnly: readOnly, disabled: disabled, onBlur: () => {
57
57
  if (!readOnly && !disabled)
58
58
  setOpen(false);
59
59
  }, label: label ? calcLabel() : undefined, value: value ? 0 : '', title: calcTimeString(value), IconComponent: () => _jsx(_Fragment, {}), MenuProps: { sx: { visibility: 'hidden' } }, endAdornment: _jsx(InputAdornment, { position: "end", onClick: (e) => {
package/dist/Widget.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import ReactDOM from 'react-dom';
2
+ import { createRoot } from 'react-dom/client';
3
3
  import App from './App/App';
4
4
  import './Utils/MuiClassnameSetup';
5
5
  const WIDGET_ID = document.currentScript?.getAttribute('data-id') ?? 'widget:eureka';
@@ -45,5 +45,5 @@ if (element) {
45
45
  props.partial = true;
46
46
  }
47
47
  }
48
- // eslint-disable-next-line react/no-deprecated
49
- ReactDOM.render(_jsx(App, { isWidget: true, ...props }), document.getElementById(WIDGET_ID));
48
+ const root = createRoot(document.getElementById(WIDGET_ID));
49
+ root.render(_jsx(App, { isWidget: true, ...props }));
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@arquimedes.co/eureka-forms",
3
3
  "repository": "git://github.com/Arquimede5/Eureka-Forms.git",
4
- "version":"3.0.33-test",
4
+ "version":"3.0.34-react-compiler",
5
5
  "scripts": {
6
- "watch": "tsc --noEmit --watch --project tsconfig.app.json",
6
+ "watch": "tsgo --noEmit --watch --project tsconfig.app.json",
7
7
  "start": "vite",
8
8
  "build": "tsc -b && vite build",
9
9
  "format": "prettier --write ./src",
@@ -16,20 +16,20 @@
16
16
  "build-storybook": "storybook build"
17
17
  },
18
18
  "dependencies": {
19
- "@reduxjs/toolkit": "^2.9.0",
20
- "axios": "^1.12.2",
21
- "date-fns": "^4.1.0",
22
- "draft-js": "^0.11.7",
23
- "i18n-iso-countries": "^7.14.0",
24
- "libphonenumber-js": "^1.12.23",
25
- "logrocket": "^10.1.0",
26
- "nanoid": "^5.1.6",
27
- "react-draft-wysiwyg": "^1.15.0",
28
- "react-google-recaptcha": "^3.1.0",
29
- "react-hook-form": "^7.64.0",
30
- "react-international-phone": "^4.6.0",
31
- "react-redux": "^9.2.0",
32
- "typescript": "^5.9.3"
19
+ "@reduxjs/toolkit": "2.11.0",
20
+ "axios": "1.12.2",
21
+ "date-fns": "4.1.0",
22
+ "draft-js": "0.11.7",
23
+ "i18n-iso-countries": "7.14.0",
24
+ "libphonenumber-js": "1.12.31",
25
+ "logrocket": "10.1.1",
26
+ "nanoid": "5.1.6",
27
+ "react-draft-wysiwyg": "1.15.0",
28
+ "react-google-recaptcha": "3.1.0",
29
+ "react-hook-form": "7.68.0",
30
+ "react-international-phone": "4.6.1",
31
+ "react-redux": "9.2.0",
32
+ "typescript": "5.9.3"
33
33
  },
34
34
  "eslintConfig": {},
35
35
  "browserslist": {
@@ -45,61 +45,68 @@
45
45
  ]
46
46
  },
47
47
  "devDependencies": {
48
- "@eslint/compat": "^1.4.0",
49
- "@eslint/eslintrc": "^3.3.1",
50
- "@eslint/js": "^9.37.0",
51
- "@faker-js/faker": "^10.0.0",
52
- "@mui/material": "^7.3.4",
53
- "@mui/x-data-grid-pro": "^8.13.1",
54
- "@mui/x-date-pickers": "^8.12.0",
55
- "@mui/x-date-pickers-pro": "^8.12.0",
56
- "@storybook/addon-docs": "^9.1.10",
57
- "@storybook/addon-onboarding": "^9.1.10",
58
- "@storybook/addon-themes": "^9.1.10",
59
- "@storybook/react-vite": "^9.1.10",
60
- "@testing-library/dom": "^10.4.1",
61
- "@testing-library/jest-dom": "^6.9.1",
62
- "@testing-library/react": "^16.3.0",
63
- "@testing-library/user-event": "^14.6.1",
64
- "@types/draft-js": "^0.11.18",
65
- "@types/react": "^18.3.18",
66
- "@types/react-dom": "^18.3.5",
67
- "@types/react-draft-wysiwyg": "^1.13.8",
68
- "@types/react-google-recaptcha": "^2.1.9",
69
- "@typescript-eslint/eslint-plugin": "^8.46.0",
70
- "@typescript-eslint/parser": "^8.26.0",
71
- "@vitejs/plugin-react-swc": "^4.1.0",
72
- "css-loader": "^7.1.2",
73
- "cypress": "^15.3.0",
74
- "dotenv-webpack": "^8.1.1",
75
- "eslint": "^9.37.0",
76
- "eslint-config-prettier": "^10.1.8",
77
- "eslint-plugin-react": "^7.37.5",
78
- "eslint-plugin-react-hooks": "^6.1.1",
79
- "eslint-plugin-react-refresh": "^0.4.23",
80
- "eslint-plugin-storybook": "^9.1.10",
81
- "globals": "^16.4.0",
82
- "identity-obj-proxy": "^3.0.0",
83
- "jsdom": "^27.0.0",
84
- "prettier": "3.6.2",
85
- "react-refresh": "^0.18.0",
86
- "storybook": "^9.1.10",
87
- "style-loader": "^4.0.0",
88
- "vite": "^7.1.9",
89
- "vite-plugin-svgr": "^4.5.0",
90
- "vitest": "^3.2.4"
48
+ "@eslint/compat": "1.4.0",
49
+ "@eslint/eslintrc": "3.3.3",
50
+ "@eslint/js": "9.39.1",
51
+ "@faker-js/faker": "10.1.0",
52
+ "@mui/material": "7.3.6",
53
+ "@mui/x-data-grid-pro": "8.21.0",
54
+ "@mui/x-date-pickers": "8.21.0",
55
+ "@mui/x-date-pickers-pro": "8.21.0",
56
+ "@storybook/addon-docs": "^9.1.16",
57
+ "@storybook/addon-onboarding": "^9.1.16",
58
+ "@storybook/addon-themes": "^9.1.16",
59
+ "@storybook/react-vite": "^9.1.16",
60
+ "@testing-library/dom": "10.4.1",
61
+ "@testing-library/jest-dom": "6.9.1",
62
+ "@testing-library/react": "16.3.0",
63
+ "@testing-library/user-event": "14.6.1",
64
+ "@types/draft-js": "0.11.20",
65
+ "@types/react": "19.2.7",
66
+ "@types/react-dom": "19.2.3",
67
+ "@types/react-draft-wysiwyg": "1.13.9",
68
+ "@types/react-google-recaptcha": "2.1.9",
69
+ "@typescript-eslint/eslint-plugin": "8.48.1",
70
+ "@typescript-eslint/parser": "8.48.1",
71
+ "@vitejs/plugin-react": "^5.1.1",
72
+ "babel-plugin-react-compiler": "^1.0.0",
73
+ "css-loader": "7.1.2",
74
+ "cypress": "15.7.1",
75
+ "dotenv-webpack": "8.1.1",
76
+ "eslint": "9.39.1",
77
+ "eslint-config-prettier": "10.1.8",
78
+ "eslint-plugin-react": "7.37.5",
79
+ "eslint-plugin-react-hooks": "7.0.1",
80
+ "eslint-plugin-react-refresh": "0.4.24",
81
+ "eslint-plugin-storybook": "9.1.16",
82
+ "globals": "16.4.0",
83
+ "identity-obj-proxy": "3.0.0",
84
+ "jsdom": "27.2.0",
85
+ "prettier": "3.7.4",
86
+ "react": "19.2.1",
87
+ "react-dom": "19.2.1",
88
+ "react-refresh": "0.18.0",
89
+ "storybook": "^9.1.16",
90
+ "style-loader": "4.0.0",
91
+ "vite": "7.1.9",
92
+ "vite-plugin-svgr": "4.5.0",
93
+ "vitest": "3.2.4"
91
94
  },
92
95
  "peerDependencies": {
93
- "@emotion/react": "^11.x.x",
94
- "@emotion/styled": "^11.x.x",
95
- "@mui/material": "^7.x.x",
96
- "@mui/x-date-pickers": "^8.x.x",
97
- "react": "^18.x.x",
98
- "react-dom": "^18.x.x"
96
+ "@emotion/react": "11.x.x",
97
+ "@emotion/styled": "11.x.x",
98
+ "@mui/material": "7.3.6",
99
+ "@mui/x-date-pickers": "8.21.0",
100
+ "react": "18 || 19",
101
+ "react-dom": "18 || 19"
99
102
  },
100
103
  "publishConfig": {
101
104
  "access": "public"
102
105
  },
106
+ "overrides": {
107
+ "react": "$react",
108
+ "react-dom": "$react-dom"
109
+ },
103
110
  "main": "./dist/index.lib.js",
104
111
  "files": [
105
112
  "/dist"