@arquimedes.co/eureka-forms 3.0.69 → 3.0.71-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README +1 -33
  2. package/dist/@Types/FormStep.d.ts +2 -7
  3. package/dist/@Types/FormStep.js +1 -2
  4. package/dist/App/App.stories.d.ts +0 -10
  5. package/dist/App/App.stories.js +0 -189
  6. package/dist/App/AppHooks.js +0 -8
  7. package/dist/App/AppHooks.test.js +0 -8
  8. package/dist/Form/Form.js +6 -7
  9. package/dist/Form/FormFunctions.d.ts +0 -17
  10. package/dist/Form/FormFunctions.js +0 -22
  11. package/dist/Form/FormFunctions.test.js +1 -28
  12. package/dist/FormSteps/AYFStepMapper.js +2 -24
  13. package/dist/FormSteps/CheckBoxStep/CheckBoxStep.mobileLabel.test.js +12 -20
  14. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +13 -6
  15. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +13 -2
  16. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +1 -3
  17. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +26 -26
  18. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +11 -1
  19. package/dist/FormSteps/SmartSelectStep/SmartSelectStep.staleOptions.test.js +100 -0
  20. package/dist/FormSteps/Step.js +0 -16
  21. package/dist/FormSteps/StepFunctions.js +0 -14
  22. package/dist/FormSteps/StepFunctions.test.js +0 -54
  23. package/dist/FormSteps/StepHooks.d.ts +0 -21
  24. package/dist/FormSteps/StepHooks.js +8 -55
  25. package/dist/FormSteps/ciudadesICAQuery.d.ts +8 -0
  26. package/dist/FormSteps/ciudadesICAQuery.js +31 -0
  27. package/dist/FormSteps/ciudadesICAQuery.test.js +39 -0
  28. package/dist/Shared/ErkDatePicker/ErkDatePicker.js +3 -1
  29. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +3 -2
  30. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +2 -1
  31. package/dist/Shared/ErkSmartSelect/ErkSmartSelect.js +4 -14
  32. package/dist/Shared/ErkSmartSelect/ErkSmartSelect.test.js +21 -1
  33. package/dist/Utils/AxiosWidget.js +1 -9
  34. package/dist/constants/FormStepTypes.d.ts +1 -5
  35. package/dist/constants/FormStepTypes.js +0 -4
  36. package/dist/index.lib.d.ts +2 -4
  37. package/dist/index.lib.js +1 -3
  38. package/package.json +1 -2
  39. package/dist/@Types/AvailabilityFormStep.d.ts +0 -48
  40. package/dist/@Types/AvailabilityFormStep.js +0 -24
  41. package/dist/@Types/BankAccountFormStep.d.ts +0 -67
  42. package/dist/@Types/BankAccountFormStep.js +0 -14
  43. package/dist/@Types/BookingFormStep.d.ts +0 -197
  44. package/dist/@Types/BookingFormStep.js +0 -44
  45. package/dist/@Types/CalendarFormStep.d.ts +0 -209
  46. package/dist/@Types/CalendarFormStep.js +0 -55
  47. package/dist/@Types/CommunicationChannelFormStep.d.ts +0 -51
  48. package/dist/@Types/CommunicationChannelFormStep.js +0 -15
  49. package/dist/@Types/ConsentFormStep.d.ts +0 -36
  50. package/dist/@Types/ConsentFormStep.js +0 -8
  51. package/dist/@Types/EntityFormFormStep.d.ts +0 -66
  52. package/dist/@Types/EntityFormFormStep.js +0 -20
  53. package/dist/@Types/EventFormStep.d.ts +0 -52
  54. package/dist/@Types/EventFormStep.js +0 -13
  55. package/dist/@Types/ExternalReferenceFormStep.d.ts +0 -74
  56. package/dist/@Types/ExternalReferenceFormStep.js +0 -20
  57. package/dist/@Types/LocationFormStep.d.ts +0 -159
  58. package/dist/@Types/LocationFormStep.js +0 -46
  59. package/dist/@Types/NumericFormSteps.d.ts +0 -108
  60. package/dist/@Types/NumericFormSteps.js +0 -20
  61. package/dist/@Types/PredefinedSelectorFormStep.d.ts +0 -51
  62. package/dist/@Types/PredefinedSelectorFormStep.js +0 -39
  63. package/dist/@Types/StepRef.d.ts +0 -135
  64. package/dist/@Types/StepRef.js +0 -49
  65. package/dist/FormSteps/AvailabilityStep/AvailabilityStep.d.ts +0 -7
  66. package/dist/FormSteps/AvailabilityStep/AvailabilityStep.js +0 -14
  67. package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.d.ts +0 -8
  68. package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.js +0 -32
  69. package/dist/FormSteps/BookingStep/BookingStep.d.ts +0 -17
  70. package/dist/FormSteps/BookingStep/BookingStep.js +0 -14
  71. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.d.ts +0 -14
  72. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +0 -129
  73. package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.js +0 -70
  74. package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.d.ts +0 -12
  75. package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.js +0 -35
  76. package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.test.js +0 -31
  77. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.d.ts +0 -27
  78. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.js +0 -64
  79. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.d.ts +0 -1
  80. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.js +0 -95
  81. package/dist/FormSteps/LocationStep/LocationStep.d.ts +0 -10
  82. package/dist/FormSteps/LocationStep/LocationStep.js +0 -14
  83. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.d.ts +0 -3
  84. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.js +0 -54
  85. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.module.css +0 -18
  86. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.d.ts +0 -3
  87. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.js +0 -170
  88. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +0 -96
  89. package/dist/FormSteps/NumberStep/NumberStep.d.ts +0 -10
  90. package/dist/FormSteps/NumberStep/NumberStep.js +0 -14
  91. package/dist/FormSteps/StepHooks.test.d.ts +0 -1
  92. package/dist/FormSteps/StepHooks.test.js +0 -92
  93. package/dist/FormSteps/isStepHiddenByCondition.test.d.ts +0 -1
  94. package/dist/FormSteps/isStepHiddenByCondition.test.js +0 -42
  95. package/dist/Icons/AddIcon.d.ts +0 -3
  96. package/dist/Icons/AddIcon.js +0 -7
  97. package/dist/Icons/EditIcon.d.ts +0 -3
  98. package/dist/Icons/EditIcon.js +0 -7
  99. package/dist/Icons/RemoveIcon.d.ts +0 -3
  100. package/dist/Icons/RemoveIcon.js +0 -7
  101. package/dist/Icons/ViewDayIcon.d.ts +0 -3
  102. package/dist/Icons/ViewDayIcon.js +0 -7
  103. package/dist/Icons/ViewWeekIcon.d.ts +0 -3
  104. package/dist/Icons/ViewWeekIcon.js +0 -7
  105. package/dist/Services/BookingService.d.ts +0 -79
  106. package/dist/Services/BookingService.js +0 -66
  107. package/dist/Services/BookingService.test.d.ts +0 -1
  108. package/dist/Services/BookingService.test.js +0 -57
  109. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.d.ts +0 -19
  110. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.js +0 -80
  111. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.module.css +0 -88
  112. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +0 -29
  113. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +0 -139
  114. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.d.ts +0 -25
  115. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.js +0 -112
  116. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.module.css +0 -88
  117. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.d.ts +0 -1
  118. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.js +0 -73
  119. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.d.ts +0 -52
  120. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.js +0 -292
  121. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.module.css +0 -608
  122. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.d.ts +0 -28
  123. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.js +0 -117
  124. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.d.ts +0 -1
  125. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.js +0 -49
  126. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.d.ts +0 -1
  127. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.js +0 -157
  128. package/dist/Shared/ErkIconButton/ErkIconButton.d.ts +0 -17
  129. package/dist/Shared/ErkIconButton/ErkIconButton.js +0 -11
  130. package/dist/Shared/ErkIconButton/ErkIconButton.module.css +0 -41
  131. package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +0 -24
  132. package/dist/Shared/ErkLocationField/ErkLocationField.js +0 -128
  133. package/dist/Shared/ErkLocationField/ErkLocationField.module.css +0 -164
  134. package/dist/Shared/ErkLocationField/ErkLocationField.test.d.ts +0 -1
  135. package/dist/Shared/ErkLocationField/ErkLocationField.test.js +0 -82
  136. package/dist/Shared/ErkLocationField/addressFields.d.ts +0 -12
  137. package/dist/Shared/ErkLocationField/addressFields.js +0 -34
  138. package/dist/Shared/ErkLocationField/locationRestrictions.d.ts +0 -6
  139. package/dist/Shared/ErkLocationField/locationRestrictions.js +0 -51
  140. package/dist/Shared/ErkLocationInput/ErkLocationInput.d.ts +0 -15
  141. package/dist/Shared/ErkLocationInput/ErkLocationInput.js +0 -502
  142. package/dist/Shared/ErkLocationInput/ErkLocationInput.module.css +0 -128
  143. package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +0 -42
  144. package/dist/Shared/ErkNumberField/ErkNumberField.js +0 -169
  145. /package/dist/FormSteps/{ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.d.ts → SmartSelectStep/SmartSelectStep.staleOptions.test.d.ts} +0 -0
  146. /package/dist/FormSteps/{EntityValueStep/entityValueDependencyValue.test.d.ts → ciudadesICAQuery.test.d.ts} +0 -0
@@ -5,7 +5,7 @@ import SmartSelect from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialS
5
5
  import widgetInstance from '../../../Utils/AxiosWidget';
6
6
  import FormContext, { IdFormContext } from '../../../Contexts/FormContext';
7
7
  import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
8
- import { isStepHiddenByCondition, recursivelyCalcConditionSteps, selectDependencies } from '../../StepHooks';
8
+ import { recursivelyCalcConditionSteps, selectDependencies } from '../../StepHooks';
9
9
  import { useApiSubscribe, useAppSelector } from '../../../hooks';
10
10
  import MaterialEntityValueDialog from './MaterialEntityValueDialog/MaterialEntityValueDialog';
11
11
  import InputIcon from '../../../Shared/InputIcon/InputIcon';
@@ -13,8 +13,6 @@ import { evaluateCondition } from '../../StepFunctions';
13
13
  import StepComponent from '../../Step';
14
14
  import ErkValueTypes from '../../../constants/ErkValueTypes';
15
15
  import { IntegrationsApi } from '../../../Services/IntegrationService';
16
- import { entityValueDependencyValue } from '../entityValueDependencyValue';
17
- import { entityValuePickerWatchedSteps } from '../entityValuePickerWatchedSteps';
18
16
  function EntityValuePickerStep({ step, editable }) {
19
17
  const form = useContext(FormContext);
20
18
  const subscribe = useApiSubscribe();
@@ -27,23 +25,8 @@ function EntityValuePickerStep({ step, editable }) {
27
25
  }))) ?? []);
28
26
  }, [subscribe, idForm]);
29
27
  const getOptions = useCallback(async (step, dependencyStore, ids) => {
30
- return await getEntityValueOptions(step, dependencyStore, ids, fetchFilterIntegration, form);
31
- }, [fetchFilterIntegration, form]);
32
- // The visibility of a filter's step decides whether that filter applies, so the steps its condition
33
- // reads must trigger a refetch too — see `isStepHiddenByCondition`.
34
- const getOptionalDependencies = useCallback((picker) => {
35
- const watched = entityValuePickerWatchedSteps(picker);
36
- for (const idWatched of [...watched]) {
37
- for (const idCondition of recursivelyCalcConditionSteps(form.steps[idWatched]?.condition)) {
38
- if (idCondition === picker.id || watched.includes(idCondition))
39
- continue;
40
- if (picker.dependencies?.includes(idCondition))
41
- continue;
42
- watched.push(idCondition);
43
- }
44
- }
45
- return watched;
46
- }, [form]);
28
+ return await getEntityValueOptions(step, dependencyStore, ids, fetchFilterIntegration);
29
+ }, [fetchFilterIntegration]);
47
30
  const [dialogs, setDialogs] = useState();
48
31
  const dialogsIdStepDeps = useMemo(() => {
49
32
  const ids = [];
@@ -128,7 +111,7 @@ function EntityValuePickerStep({ step, editable }) {
128
111
  } }) })] }));
129
112
  }
130
113
  export default EntityValuePickerStep;
131
- const getEntityValueOptions = async (step, dependencyStore, { idOrganization, idCurrentAgent, }, fetchFilterIntegration, form) => {
114
+ const getEntityValueOptions = async (step, dependencyStore, { idOrganization, idCurrentAgent, }, fetchFilterIntegration) => {
132
115
  if (!idOrganization)
133
116
  return null;
134
117
  let urlPath = '';
@@ -190,12 +173,14 @@ const getEntityValueOptions = async (step, dependencyStore, { idOrganization, id
190
173
  break;
191
174
  }
192
175
  case EntityValueDataTypes.STEP: {
193
- const currentValue = entityValueDependencyValue(dependencyStore[filter.idStep]);
194
- if (currentValue !== undefined) {
195
- params.set(filter.idProperty, currentValue);
176
+ const currentValue = dependencyStore[filter.idStep]?.value;
177
+ if (currentValue) {
178
+ if (typeof currentValue === 'string')
179
+ params.set(filter.idProperty, currentValue);
180
+ else
181
+ params.set(filter.idProperty, currentValue._id ?? currentValue.id);
196
182
  }
197
- else if (filter.required && !isStepHiddenByCondition(filter.idStep, form, dependencyStore)) {
198
- // A required filter blocks only while its step can still be answered.
183
+ else if (filter.required) {
199
184
  return null;
200
185
  }
201
186
  break;
@@ -216,3 +201,18 @@ const getEntityValueOptions = async (step, dependencyStore, { idOrganization, id
216
201
  });
217
202
  return response.data.filter((option) => step.options[option._id]?.type !== EntityValueOptionTypes.HIDE);
218
203
  };
204
+ const getOptionalDependencies = (step) => {
205
+ const optional = [];
206
+ for (const filter of step.filters) {
207
+ switch (filter.type) {
208
+ case EntityValueDataTypes.STEP: {
209
+ if (filter.idStep && !filter.required && !step.dependencies?.includes(filter.idStep))
210
+ optional.push(filter.idStep);
211
+ break;
212
+ }
213
+ default:
214
+ break;
215
+ }
216
+ }
217
+ return optional;
218
+ };
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useFormContext } from 'react-hook-form';
3
3
  import ErkSmartSelect from '../../../Shared/ErkSmartSelect/ErkSmartSelect';
4
- import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
4
+ import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import React from 'react';
6
6
  import FormContext from '../../../Contexts/FormContext';
7
7
  import { useAppDispatch, useAppSelector } from '../../../hooks';
@@ -28,6 +28,11 @@ function SmartSelectStep({ step, editable, getOptions, calcDepError, defaultValu
28
28
  const [loading, setLoading] = useState(false);
29
29
  const [firstTime, setFirstTime] = useState(true);
30
30
  const [touched, setTouched] = useState(false);
31
+ /**
32
+ * Every dependency change (each keystroke of a NIT, say) starts a new request without cancelling the
33
+ * ones in flight, and they can resolve in any order. Only the latest request may touch the options.
34
+ */
35
+ const lastRequest = useRef(0);
31
36
  const dispatch = useAppDispatch();
32
37
  const allDeps = useMemo(() => [...(step.dependencies ?? []), ...getOptionalDependencies(step)], [getOptionalDependencies, step]);
33
38
  const idDependencies = useMemo(() => getOptionsConditionsIdSteps(step), [getOptionsConditionsIdSteps, step]);
@@ -52,6 +57,7 @@ function SmartSelectStep({ step, editable, getOptions, calcDepError, defaultValu
52
57
  // eslint-disable-next-line react-hooks/exhaustive-deps
53
58
  }, [allDepsValues]);
54
59
  const calcOptions = async (firstTime) => {
60
+ const request = ++lastRequest.current;
55
61
  if (!firstTime)
56
62
  setOptions(undefined);
57
63
  if (value && !firstTime)
@@ -61,6 +67,8 @@ function SmartSelectStep({ step, editable, getOptions, calcDepError, defaultValu
61
67
  idOrganization,
62
68
  idCurrentAgent: postview ? undefined : idCurrentAgent,
63
69
  });
70
+ if (request !== lastRequest.current)
71
+ return;
64
72
  if (value) {
65
73
  /** If the value is still valid select it */
66
74
  if (resp && getValueString(value) !== undefined) {
@@ -82,6 +90,8 @@ function SmartSelectStep({ step, editable, getOptions, calcDepError, defaultValu
82
90
  }
83
91
  }
84
92
  catch (error) {
93
+ if (request !== lastRequest.current)
94
+ return;
85
95
  console.error(error);
86
96
  setOptions(null);
87
97
  }
@@ -0,0 +1,100 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { act, render } from '@testing-library/react';
3
+ import { describe, expect, it } from 'vitest';
4
+ import '@testing-library/jest-dom';
5
+ import { Provider } from 'react-redux';
6
+ import { FormProvider, useForm } from 'react-hook-form';
7
+ import { configureStore } from '@reduxjs/toolkit';
8
+ import { EurekaFormsReducer, defaultRootState } from '../../Utils/store';
9
+ import { RootApi } from '../../Utils/_api';
10
+ import FormStepTypes from '../../constants/FormStepTypes';
11
+ import { StoreContext } from '../../Utils/StoreContext';
12
+ import FormContext, { IdFormContext } from '../../Contexts/FormContext';
13
+ import SectionContext from '../../Contexts/SectionContext';
14
+ import MaterialProviders from '../../Utils/MaterialProviders';
15
+ import InternalFormStyle from '../../constants/InternalFormStyle';
16
+ import { setStepDependency } from '../../States/SiteSlice';
17
+ import SmartSelectStep from './SmartSelectStep';
18
+ const ID_FORM = 'STALE_OPTIONS_FORM';
19
+ const nitStep = {
20
+ id: 'nit-step',
21
+ idSection: 'SECTION_1',
22
+ stepPath: ['nit-step'],
23
+ type: FormStepTypes.TEXTINPUT,
24
+ label: 'NIT',
25
+ description: '',
26
+ required: true,
27
+ size: 1,
28
+ maxLength: 20,
29
+ };
30
+ /** A city-like selector whose options come from the NIT the user is still typing. */
31
+ const cityStep = {
32
+ id: 'city-step',
33
+ idSection: 'SECTION_1',
34
+ stepPath: ['city-step'],
35
+ type: 'AYF_ICA_CITY',
36
+ label: 'Ciudad',
37
+ description: '',
38
+ showIcon: false,
39
+ required: false,
40
+ searchable: false,
41
+ size: 1,
42
+ dependencies: ['nit-step'],
43
+ };
44
+ const form = {
45
+ firstSection: 'SECTION_1',
46
+ sections: {
47
+ SECTION_1: { id: 'SECTION_1', name: 'Sección 1', steps: ['nit-step', 'city-step'], nextSection: null },
48
+ },
49
+ steps: { 'nit-step': nitStep, 'city-step': cityStep },
50
+ confirmationMessage: { blocks: [], entityMap: {} },
51
+ showLink: false,
52
+ size: { blockSize: 200, blockNum: 4, spacingSize: 10 },
53
+ };
54
+ const dependencies = {
55
+ 'nit-step': { idOriginal: 'nit-step', dependents: [cityStep], value: '', type: FormStepTypes.TEXTINPUT },
56
+ };
57
+ function makeStore() {
58
+ return configureStore({
59
+ reducer: { forms: EurekaFormsReducer, [RootApi.reducerPath]: RootApi.reducer },
60
+ preloadedState: {
61
+ forms: { [ID_FORM]: { ...defaultRootState, site: { ...defaultRootState.site, dependencies } } },
62
+ },
63
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(RootApi.middleware),
64
+ });
65
+ }
66
+ function Harness({ store, requests }) {
67
+ const methods = useForm({ mode: 'onTouched' });
68
+ return (_jsx(MaterialProviders, { formStyle: InternalFormStyle, children: _jsx(Provider, { store: store, context: StoreContext, children: _jsx(IdFormContext.Provider, { value: ID_FORM, children: _jsx(FormContext.Provider, { value: form, children: _jsx(SectionContext.Provider, { value: "SECTION_1", children: _jsx(FormProvider, { ...methods, children: _jsx(SmartSelectStep, { step: cityStep, editable: true, getOptions: (_step, deps) => new Promise((resolve) => {
69
+ requests.push({ nit: deps['nit-step']?.value, resolve });
70
+ }), getOptionSelected: (option, value) => option === value, getValueString: (value) => value }) }) }) }) }) }) }));
71
+ }
72
+ const optionTexts = () => Array.from(document.querySelectorAll('[role=option]')).map((option) => option.textContent ?? '');
73
+ describe('SmartSelectStep when a dependency changes faster than its options load', () => {
74
+ it('keeps the options of the latest dependency value when an older request resolves last', async () => {
75
+ const store = makeStore();
76
+ const requests = [];
77
+ render(_jsx(Harness, { store: store, requests: requests }));
78
+ const typeNit = (value) => {
79
+ act(() => {
80
+ store.dispatch({ ...setStepDependency({ step: nitStep, value }), meta: { idForm: ID_FORM } });
81
+ });
82
+ };
83
+ typeNit('9');
84
+ typeNit('901379420');
85
+ const byNit = (nit) => requests.find((request) => request.nit === nit);
86
+ expect(byNit('9')).toBeDefined();
87
+ expect(byNit('901379420')).toBeDefined();
88
+ // The full NIT answers first with cities; the partial NIT straggles in afterwards with nothing.
89
+ const settle = (pending, options) => act(async () => {
90
+ pending.resolve(options);
91
+ await Promise.resolve();
92
+ });
93
+ await settle(byNit('901379420'), ['BELLO', 'MEDELLIN']);
94
+ await settle(byNit('9'), []);
95
+ act(() => {
96
+ document.querySelector('[role=combobox]').dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
97
+ });
98
+ expect(optionTexts()).toEqual(expect.arrayContaining(['BELLO', 'MEDELLIN']));
99
+ });
100
+ });
@@ -24,10 +24,6 @@ import CustomContext from '../Contexts/CustomContext';
24
24
  import { selectOriginalValue, useCondition } from './StepHooks';
25
25
  import TimePickerStep from './TimePickerStep/TimePickerStep';
26
26
  import PhoneInputStep from './PhoneInputStep/PhoneInputStep';
27
- import LocationStepComponent from './LocationStep/LocationStep';
28
- import NumberStepComponent from './NumberStep/NumberStep';
29
- import BookingStepComponent from './BookingStep/BookingStep';
30
- import AvailabilityStepComponent from './AvailabilityStep/AvailabilityStep';
31
27
  function StepComponent({ step, ...props }) {
32
28
  const { postview, partial } = useAppSelector((state) => state.global);
33
29
  const { customSteps, customClientInfoStep } = useContext(CustomContext);
@@ -79,18 +75,6 @@ function StepComponent({ step, ...props }) {
79
75
  case FormStepTypes.DATEPICKER: {
80
76
  return _jsx(DatePickerStep, { ...props, step: step, editable: editable });
81
77
  }
82
- case FormStepTypes.LOCATION: {
83
- return _jsx(LocationStepComponent, { ...props, step: step, editable: editable });
84
- }
85
- case FormStepTypes.NUMBER: {
86
- return _jsx(NumberStepComponent, { ...props, step: step, editable: editable });
87
- }
88
- case FormStepTypes.BOOKING: {
89
- return _jsx(BookingStepComponent, { ...props, step: step, editable: editable });
90
- }
91
- case FormStepTypes.AVAILABILITY: {
92
- return _jsx(AvailabilityStepComponent, { ...props, step: step, editable: editable });
93
- }
94
78
  case FormStepTypes.DATEPICKER_RANGE: {
95
79
  return _jsx(DatePickerRangeStep, { ...props, step: step, editable: editable });
96
80
  }
@@ -1,4 +1,3 @@
1
- import { NumberStepType, } from '../@Types/FormStep';
2
1
  import FormStepTypes, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueDataTypes, EntityValueOptionTypes, OptionTypes, } from '../constants/FormStepTypes';
3
2
  import CBRFormStepTypes from '../constants/CBRFormStepTypes';
4
3
  import AYFFormStepTypes from '../constants/AYFFormStepTypes';
@@ -88,8 +87,6 @@ function recursivelyCheckOpenSize(idStep, steps, values) {
88
87
  return size;
89
88
  }
90
89
  case FormStepTypes.DATEPICKER:
91
- case FormStepTypes.LOCATION:
92
- case FormStepTypes.NUMBER:
93
90
  case FormStepTypes.TEXTINPUT: {
94
91
  return step.size;
95
92
  }
@@ -178,17 +175,6 @@ export const calcDefaultValue = (step) => {
178
175
  return getRawText();
179
176
  else
180
177
  return '';
181
- case FormStepTypes.LOCATION:
182
- return step.defaultValue ?? null;
183
- case FormStepTypes.NUMBER: {
184
- const numStep = step;
185
- if (numStep.numberType === NumberStepType.MONEY ||
186
- numStep.numberType === NumberStepType.MEASURE ||
187
- numStep.numberType === NumberStepType.UNIT_PRICE) {
188
- return numStep.defaultValue ?? null;
189
- }
190
- return numStep.defaultValue ?? '';
191
- }
192
178
  case FormStepTypes.RATING:
193
179
  case FormStepTypes.DATEPICKER:
194
180
  case FormStepTypes.DATEPICKER_RANGE:
@@ -1,4 +1,3 @@
1
- import * as Steps from '../@Types/FormStep';
2
1
  import AYFFormStepTypes from '../constants/AYFFormStepTypes';
3
2
  import CBRFormStepTypes from '../constants/CBRFormStepTypes';
4
3
  import FormStepTypes, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueOptionTypes, OptionTypes, } from '../constants/FormStepTypes';
@@ -528,13 +527,6 @@ describe('StepFunctions', function () {
528
527
  const defaultValue = calcDefaultValue(step);
529
528
  expect(defaultValue).toBe(null);
530
529
  });
531
- test('Location step type', async () => {
532
- const step = {
533
- type: FormStepTypes.LOCATION,
534
- };
535
- const defaultValue = calcDefaultValue(step);
536
- expect(defaultValue).toBe(null);
537
- });
538
530
  test('Mapper, FileUpload, CBRFormStep types', async () => {
539
531
  const step1 = {
540
532
  type: FormStepTypes.MAPPER,
@@ -566,52 +558,6 @@ describe('StepFunctions', function () {
566
558
  const defaultValue = calcDefaultValue(step);
567
559
  expect(defaultValue).toBeUndefined();
568
560
  });
569
- test('Number step type without defaultValue', async () => {
570
- const step1 = {
571
- type: FormStepTypes.NUMBER,
572
- numberType: Steps.NumberStepType.INTEGER,
573
- };
574
- const step2 = {
575
- type: FormStepTypes.NUMBER,
576
- numberType: Steps.NumberStepType.DECIMAL,
577
- };
578
- const step3 = {
579
- type: FormStepTypes.NUMBER,
580
- numberType: Steps.NumberStepType.PERCENTAGE,
581
- };
582
- const step4 = {
583
- type: FormStepTypes.NUMBER,
584
- numberType: Steps.NumberStepType.MONEY,
585
- };
586
- const step5 = {
587
- type: FormStepTypes.NUMBER,
588
- numberType: Steps.NumberStepType.MEASURE,
589
- };
590
- const step6 = {
591
- type: FormStepTypes.NUMBER,
592
- numberType: Steps.NumberStepType.UNIT_PRICE,
593
- };
594
- expect(calcDefaultValue(step1)).toBe('');
595
- expect(calcDefaultValue(step2)).toBe('');
596
- expect(calcDefaultValue(step3)).toBe('');
597
- expect(calcDefaultValue(step4)).toBe(null);
598
- expect(calcDefaultValue(step5)).toBe(null);
599
- expect(calcDefaultValue(step6)).toBe(null);
600
- });
601
- test('Number step type with defaultValue', async () => {
602
- const step1 = {
603
- type: FormStepTypes.NUMBER,
604
- numberType: Steps.NumberStepType.INTEGER,
605
- defaultValue: 42,
606
- };
607
- const step2 = {
608
- type: FormStepTypes.NUMBER,
609
- numberType: Steps.NumberStepType.MONEY,
610
- defaultValue: { value: 100, currency: 'USD' },
611
- };
612
- expect(calcDefaultValue(step1)).toBe(42);
613
- expect(calcDefaultValue(step2)).toEqual({ value: 100, currency: 'USD' });
614
- });
615
561
  });
616
562
  describe('iterateNestedSteps', function () {
617
563
  test('should iterate over nested steps', async () => {
@@ -34,13 +34,6 @@ export interface StepDependency {
34
34
  handleStepDep: (value: any) => void;
35
35
  }
36
36
  export declare const useStepDependency: (step: GBaseStep, defaultValue?: any) => StepDependency;
37
- /**
38
- * Whether `idStep` is currently kept off the form by its own visibility condition. A step that is not
39
- * shown cannot be answered, so nothing may wait for it: a required entity filter pointing at it does
40
- * not apply, and it never reads as a missing dependency. When the condition cannot be decided yet (a
41
- * step it reads is not in the store) the step counts as shown, keeping the conservative behaviour.
42
- */
43
- export declare const isStepHiddenByCondition: (idStep: string, form: Form, dependencies: DependencyStore) => boolean;
44
37
  export declare const selectStepDependencies: ((state: RootState, _step: GBaseStep, form: Form) => {
45
38
  invalids: string[];
46
39
  emptyDep: boolean;
@@ -74,20 +67,6 @@ export declare const selectStepDependencies: ((state: RootState, _step: GBaseSte
74
67
  memoize: typeof import("reselect").weakMapMemoize;
75
68
  argsMemoize: typeof import("reselect").weakMapMemoize;
76
69
  };
77
- /**
78
- * The steps `idStep` depends on, transitively: every dependency's own dependencies come before it,
79
- * and every id is answered exactly once. `idStep` itself is never listed — a step is not a
80
- * dependency of itself, even when a draft points it back at itself.
81
- *
82
- * A saved form is a DAG: the backend recomputes and validates `step.dependencies` on save. The
83
- * editor's live preview renders unsaved drafts though, where a filter or a path hop can still point
84
- * at the step that holds it, or close a cycle with another step. The walk must therefore terminate
85
- * on any graph, cyclic included: a step is marked visited before it is walked and is never walked
86
- * or listed twice, so every edge is followed at most once.
87
- *
88
- * Exported for the unit test; it is internal to this module and not part of the package's surface.
89
- */
90
- export declare const calcDeepDependencies: (idStep: string, form: Form) => string[];
91
70
  export interface UseFormStepOptions<ValueType> {
92
71
  defaultValue: ValueType;
93
72
  /** If true, will not trigger onChange until the user has finished typing */
@@ -8,7 +8,6 @@ import { useController } from 'react-hook-form';
8
8
  import ConditionTypes from '../constants/ConditionTypes';
9
9
  import FormStepTypes, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueOptionTypes, } from '../constants/FormStepTypes';
10
10
  import { SizeChangeContext } from './Utils/@StepFiller/StepFillerContext';
11
- import { entityValuePickerBlockingSteps } from './EntityValueStep/entityValuePickerWatchedSteps';
12
11
  const selectIsDependency = createSelector([
13
12
  (state) => state.site.dependencies,
14
13
  (_state, step) => step,
@@ -48,20 +47,6 @@ export const useStepDependency = (step, defaultValue) => {
48
47
  originalValue: originalValue ?? defaultValue ?? calcDefaultValue(step),
49
48
  };
50
49
  };
51
- /**
52
- * Whether `idStep` is currently kept off the form by its own visibility condition. A step that is not
53
- * shown cannot be answered, so nothing may wait for it: a required entity filter pointing at it does
54
- * not apply, and it never reads as a missing dependency. When the condition cannot be decided yet (a
55
- * step it reads is not in the store) the step counts as shown, keeping the conservative behaviour.
56
- */
57
- export const isStepHiddenByCondition = (idStep, form, dependencies) => {
58
- const target = form.steps[idStep];
59
- if (!target?.condition)
60
- return false;
61
- if (recursivelyCalcConditionSteps(target.condition).some((id) => dependencies[id] === undefined))
62
- return false;
63
- return !evaluateCondition(target.condition, dependencies);
64
- };
65
50
  export const selectStepDependencies = createSelector([
66
51
  (state) => state.site.dependencies,
67
52
  (_state, step) => step,
@@ -71,8 +56,6 @@ export const selectStepDependencies = createSelector([
71
56
  let emptyDep = false;
72
57
  /** Show deep error changes even if not in dependencies */
73
58
  for (const idDep of calcDeepDependencies(step.id, form)) {
74
- if (isStepHiddenByCondition(idDep, form, dependencies))
75
- continue;
76
59
  const dependency = dependencies[idDep];
77
60
  if (dependency?.value === null && form.steps[idDep]) {
78
61
  invalids.push(idDep);
@@ -82,45 +65,15 @@ export const selectStepDependencies = createSelector([
82
65
  }
83
66
  return { invalids, emptyDep };
84
67
  });
85
- /**
86
- * The steps `idStep` depends on, transitively: every dependency's own dependencies come before it,
87
- * and every id is answered exactly once. `idStep` itself is never listed — a step is not a
88
- * dependency of itself, even when a draft points it back at itself.
89
- *
90
- * A saved form is a DAG: the backend recomputes and validates `step.dependencies` on save. The
91
- * editor's live preview renders unsaved drafts though, where a filter or a path hop can still point
92
- * at the step that holds it, or close a cycle with another step. The walk must therefore terminate
93
- * on any graph, cyclic included: a step is marked visited before it is walked and is never walked
94
- * or listed twice, so every edge is followed at most once.
95
- *
96
- * Exported for the unit test; it is internal to this module and not part of the package's surface.
97
- */
98
- export const calcDeepDependencies = (idStep, form) => {
99
- const deps = [];
100
- /** `idStep` starts out visited so a cycle back to it stops there and never lists it. */
101
- const visited = new Set([idStep]);
102
- const walk = (id) => {
103
- const step = form.steps[id];
104
- if (!step)
105
- return;
106
- /**
107
- * An entity picker also gives up (its options resolve to null) while a path hop or a
108
- * required STEP filter holds no value. Those are in `step.dependencies` once the form has
109
- * been saved, but not in an unsaved draft, so they are added here to read as a missing
110
- * dependency instead of as a failed load.
111
- */
112
- const idDeps = step.type === FormStepTypes.ENTITYVALUEPICKER
113
- ? [...(step.dependencies ?? []), ...entityValuePickerBlockingSteps(step)]
114
- : step.dependencies;
115
- for (const dep of idDeps ?? []) {
116
- if (visited.has(dep))
117
- continue;
118
- visited.add(dep);
119
- walk(dep);
120
- deps.push(dep);
68
+ const calcDeepDependencies = (idStep, form, deps = []) => {
69
+ const step = form.steps[idStep];
70
+ if (step?.dependencies) {
71
+ for (const dep of step.dependencies) {
72
+ if (!deps.includes(dep)) {
73
+ deps.push(...calcDeepDependencies(dep, form, deps), dep);
74
+ }
121
75
  }
122
- };
123
- walk(idStep);
76
+ }
124
77
  return deps;
125
78
  };
126
79
  export const useFormStep = (step, { rules, debounce, sizeChange, defaultValue }) => {
@@ -0,0 +1,8 @@
1
+ import { GSmartSelect } from '../@Types/GenericFormSteps';
2
+ import { DependencyStore } from '../Form/Form';
3
+ /**
4
+ * Query for `CiudadesICA`. The NIT dependency is `null` until the user types it; it must be left out of the
5
+ * query rather than serialised as the text "null", which the integrations API would take as a real NIT (and
6
+ * SINCO answers that with no cities instead of the organisation's main city).
7
+ */
8
+ export declare function ciudadesICAQuery(step: GSmartSelect, dependencyStore: DependencyStore, idOrganization: string): URLSearchParams;
@@ -0,0 +1,31 @@
1
+ import AYFFormStepTypes from '../constants/AYFFormStepTypes';
2
+ /**
3
+ * Query for `CiudadesICA`. The NIT dependency is `null` until the user types it; it must be left out of the
4
+ * query rather than serialised as the text "null", which the integrations API would take as a real NIT (and
5
+ * SINCO answers that with no cities instead of the organisation's main city).
6
+ */
7
+ export function ciudadesICAQuery(step, dependencyStore, idOrganization) {
8
+ const params = new URLSearchParams({ idOrganization, nit: 'true' });
9
+ const nit = dependencyStore[step.idNitStep]?.value;
10
+ if (nit)
11
+ params.set('idCompany', nit);
12
+ for (const dep of step.dependencies ?? []) {
13
+ const value = dependencyStore[dep]?.value;
14
+ if (value && dep.startsWith('AYF')) {
15
+ switch (dep.split('-')?.[0]) {
16
+ case AYFFormStepTypes.AYF_START_MONTH:
17
+ params.set('startMonth', value.id);
18
+ break;
19
+ case AYFFormStepTypes.AYF_END_MONTH:
20
+ params.set('endMonth', value.id);
21
+ break;
22
+ case AYFFormStepTypes.AYF_YEAR:
23
+ params.set('year', value);
24
+ break;
25
+ default:
26
+ break;
27
+ }
28
+ }
29
+ }
30
+ return params;
31
+ }
@@ -0,0 +1,39 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import AYFFormStepTypes from '../constants/AYFFormStepTypes';
3
+ import FormStepTypes from '../constants/FormStepTypes';
4
+ import { ciudadesICAQuery } from './ciudadesICAQuery';
5
+ const cityStep = {
6
+ id: 'AYF_ICA_CITY-1',
7
+ idSection: 'SECTION_1',
8
+ stepPath: ['AYF_ICA_CITY-1'],
9
+ type: AYFFormStepTypes.AYF_ICA_CITY,
10
+ label: 'Ciudad',
11
+ description: '',
12
+ showIcon: false,
13
+ required: false,
14
+ size: 1,
15
+ idNitStep: 'TEXTINPUT-nit',
16
+ dependencies: ['TEXTINPUT-nit', 'AYF_YEAR-1'],
17
+ };
18
+ const storeWithNit = (value) => ({
19
+ 'TEXTINPUT-nit': { idOriginal: 'TEXTINPUT-nit', dependents: [], value, type: FormStepTypes.TEXTINPUT },
20
+ 'AYF_YEAR-1': { idOriginal: 'AYF_YEAR-1', dependents: [], value: '2026', type: AYFFormStepTypes.AYF_YEAR },
21
+ });
22
+ describe('ciudadesICAQuery', () => {
23
+ it('sends the NIT as idCompany once the user has typed it', () => {
24
+ const params = ciudadesICAQuery(cityStep, storeWithNit('901379420'), 'casa');
25
+ expect(params.get('idCompany')).toBe('901379420');
26
+ expect(params.get('nit')).toBe('true');
27
+ expect(params.get('year')).toBe('2026');
28
+ });
29
+ /**
30
+ * The NIT dependency is `null` until the user types something. Serialising that as the text "null"
31
+ * makes the integrations API query SINCO for a provider literally called "null", which answers with no
32
+ * cities instead of the organisation's main city.
33
+ */
34
+ it.each([null, undefined, ''])('omits idCompany while the NIT is %s', (nit) => {
35
+ const params = ciudadesICAQuery(cityStep, storeWithNit(nit), 'casa');
36
+ expect(params.has('idCompany')).toBe(false);
37
+ expect(params.get('idOrganization')).toBe('casa');
38
+ });
39
+ });
@@ -2,9 +2,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React, { useMemo } from 'react';
3
3
  import { isValid } from 'date-fns';
4
4
  import { InputAdornment, styled, Dialog as MuiDialog } from '@mui/material';
5
- import { MobileDatePicker as MuiDatePicker, MobileDateTimePicker as MuiDateTimePicker, DatePickerToolbar as MuiDatePickerToolbar, DateTimePickerToolbar as MuiDateTimePickerToolbar, usePickerContext, usePickerAdapter, PickerDay as MuiPickerDay, renderTimeViewClock, } from '@mui/x-date-pickers';
5
+ import { MobileDatePicker as MuiDatePicker, MobileDateTimePicker as MuiDateTimePicker, DatePickerToolbar as MuiDatePickerToolbar, DateTimePickerToolbar as MuiDateTimePickerToolbar, usePickerContext, usePickerAdapter, } from '@mui/x-date-pickers';
6
+ import { PickerDay as MuiPickerDay } from '@mui/x-date-pickers/PickerDay';
6
7
  import { StyledTextField } from '../ErkTextField/ErkTextField';
7
8
  import CalendarIcon from '../../Icons/CalendarIcon';
9
+ import { renderTimeViewClock } from '@mui/x-date-pickers/timeViewRenderers';
8
10
  const StyledDateTimePicker = styled(MuiDateTimePicker, {
9
11
  shouldForwardProp: (propName) => propName !== 'size',
10
12
  })(({ disabled, readOnly, size }) => ({
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
- import { PickersShortcutsItem } from '@mui/x-date-pickers';
3
- import { MobileDateRangePickerProps as MuiDateRangePickerProps, DateRange } from '@mui/x-date-pickers-pro';
2
+ import { MobileDateRangePickerProps as MuiDateRangePickerProps } from '@mui/x-date-pickers-pro/MobileDateRangePicker';
3
+ import { DateRange } from '@mui/x-date-pickers-pro';
4
+ import { PickersShortcutsItem } from '@mui/x-date-pickers/PickersShortcuts';
4
5
  import { ErkTextFieldProps } from '../ErkTextField/ErkTextField';
5
6
  interface ErkDateRangePickerProps extends Omit<MuiDateRangePickerProps, 'ref' | 'onChange' | 'value' | 'slotProps'>, Pick<ErkTextFieldProps, 'error' | 'required' | 'helperText' | 'size'> {
6
7
  onChange?: (dateRange: DateRange<Date>) => void;
@@ -2,7 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React, { useMemo } from 'react';
3
3
  import { InputAdornment, styled, Dialog as MuiDialog } from '@mui/material';
4
4
  import { DatePickerToolbar as MuiDatePickerToolbar, usePickerContext, usePickerAdapter, } from '@mui/x-date-pickers';
5
- import { MobileDateRangePicker as MuiDateRangePicker, DateRangePickerDay as MuiDateRangePickerDay, } from '@mui/x-date-pickers-pro';
5
+ import { MobileDateRangePicker as MuiDateRangePicker, } from '@mui/x-date-pickers-pro/MobileDateRangePicker';
6
+ import { DateRangePickerDay as MuiDateRangePickerDay } from '@mui/x-date-pickers-pro';
6
7
  import { isValid } from 'date-fns';
7
8
  import { StyledTextField } from '../ErkTextField/ErkTextField';
8
9
  import CalendarIcon from '../../Icons/CalendarIcon';