@arquimedes.co/eureka-forms 3.0.68-test → 3.0.68

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 (134) hide show
  1. package/README +33 -1
  2. package/dist/@Types/AvailabilityFormStep.d.ts +48 -0
  3. package/dist/@Types/AvailabilityFormStep.js +24 -0
  4. package/dist/@Types/BankAccountFormStep.d.ts +67 -0
  5. package/dist/@Types/BankAccountFormStep.js +14 -0
  6. package/dist/@Types/BookingFormStep.d.ts +187 -0
  7. package/dist/@Types/BookingFormStep.js +44 -0
  8. package/dist/@Types/CalendarFormStep.d.ts +209 -0
  9. package/dist/@Types/CalendarFormStep.js +55 -0
  10. package/dist/@Types/CommunicationChannelFormStep.d.ts +51 -0
  11. package/dist/@Types/CommunicationChannelFormStep.js +15 -0
  12. package/dist/@Types/ConsentFormStep.d.ts +36 -0
  13. package/dist/@Types/ConsentFormStep.js +8 -0
  14. package/dist/@Types/EntityFormFormStep.d.ts +66 -0
  15. package/dist/@Types/EntityFormFormStep.js +20 -0
  16. package/dist/@Types/EventFormStep.d.ts +52 -0
  17. package/dist/@Types/EventFormStep.js +13 -0
  18. package/dist/@Types/ExternalReferenceFormStep.d.ts +74 -0
  19. package/dist/@Types/ExternalReferenceFormStep.js +20 -0
  20. package/dist/@Types/FormStep.d.ts +7 -2
  21. package/dist/@Types/FormStep.js +2 -1
  22. package/dist/@Types/LocationFormStep.d.ts +159 -0
  23. package/dist/@Types/LocationFormStep.js +46 -0
  24. package/dist/@Types/NumericFormSteps.d.ts +108 -0
  25. package/dist/@Types/NumericFormSteps.js +20 -0
  26. package/dist/@Types/PredefinedSelectorFormStep.d.ts +51 -0
  27. package/dist/@Types/PredefinedSelectorFormStep.js +39 -0
  28. package/dist/@Types/StepRef.d.ts +135 -0
  29. package/dist/@Types/StepRef.js +49 -0
  30. package/dist/App/App.stories.d.ts +10 -0
  31. package/dist/App/App.stories.js +189 -0
  32. package/dist/App/AppHooks.js +8 -0
  33. package/dist/App/AppHooks.test.js +8 -0
  34. package/dist/Form/Form.js +7 -6
  35. package/dist/Form/FormFunctions.d.ts +17 -0
  36. package/dist/Form/FormFunctions.js +22 -0
  37. package/dist/Form/FormFunctions.test.js +28 -1
  38. package/dist/FormSteps/AvailabilityStep/AvailabilityStep.d.ts +7 -0
  39. package/dist/FormSteps/AvailabilityStep/AvailabilityStep.js +14 -0
  40. package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.d.ts +8 -0
  41. package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.js +32 -0
  42. package/dist/FormSteps/BookingStep/BookingStep.d.ts +17 -0
  43. package/dist/FormSteps/BookingStep/BookingStep.js +14 -0
  44. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.d.ts +7 -0
  45. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +32 -0
  46. package/dist/FormSteps/CheckBoxStep/CheckBoxStep.mobileLabel.test.js +20 -12
  47. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +6 -13
  48. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +2 -13
  49. package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.d.ts +1 -0
  50. package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.js +70 -0
  51. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +3 -1
  52. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +26 -26
  53. package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.d.ts +12 -0
  54. package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.js +35 -0
  55. package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.test.d.ts +1 -0
  56. package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.test.js +31 -0
  57. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.d.ts +27 -0
  58. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.js +64 -0
  59. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.d.ts +1 -0
  60. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.js +95 -0
  61. package/dist/FormSteps/LocationStep/LocationStep.d.ts +10 -0
  62. package/dist/FormSteps/LocationStep/LocationStep.js +14 -0
  63. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.d.ts +3 -0
  64. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.js +54 -0
  65. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.module.css +18 -0
  66. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.d.ts +3 -0
  67. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.js +170 -0
  68. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +96 -0
  69. package/dist/FormSteps/NumberStep/NumberStep.d.ts +10 -0
  70. package/dist/FormSteps/NumberStep/NumberStep.js +14 -0
  71. package/dist/FormSteps/Step.js +16 -0
  72. package/dist/FormSteps/StepFunctions.js +14 -0
  73. package/dist/FormSteps/StepFunctions.test.js +54 -0
  74. package/dist/FormSteps/StepHooks.d.ts +21 -0
  75. package/dist/FormSteps/StepHooks.js +55 -8
  76. package/dist/FormSteps/StepHooks.test.d.ts +1 -0
  77. package/dist/FormSteps/StepHooks.test.js +92 -0
  78. package/dist/FormSteps/isStepHiddenByCondition.test.d.ts +1 -0
  79. package/dist/FormSteps/isStepHiddenByCondition.test.js +42 -0
  80. package/dist/Icons/AddIcon.d.ts +3 -0
  81. package/dist/Icons/AddIcon.js +7 -0
  82. package/dist/Icons/EditIcon.d.ts +3 -0
  83. package/dist/Icons/EditIcon.js +7 -0
  84. package/dist/Icons/RemoveIcon.d.ts +3 -0
  85. package/dist/Icons/RemoveIcon.js +7 -0
  86. package/dist/Icons/ViewDayIcon.d.ts +3 -0
  87. package/dist/Icons/ViewDayIcon.js +7 -0
  88. package/dist/Icons/ViewWeekIcon.d.ts +3 -0
  89. package/dist/Icons/ViewWeekIcon.js +7 -0
  90. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.d.ts +19 -0
  91. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.js +80 -0
  92. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.module.css +88 -0
  93. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +29 -0
  94. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +139 -0
  95. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.d.ts +25 -0
  96. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.js +112 -0
  97. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.module.css +88 -0
  98. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.d.ts +1 -0
  99. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.js +73 -0
  100. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.d.ts +31 -0
  101. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.js +228 -0
  102. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.module.css +608 -0
  103. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.d.ts +28 -0
  104. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.js +117 -0
  105. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.d.ts +1 -0
  106. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.js +49 -0
  107. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.d.ts +1 -0
  108. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.js +107 -0
  109. package/dist/Shared/ErkDatePicker/ErkDatePicker.js +1 -3
  110. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +2 -3
  111. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +1 -2
  112. package/dist/Shared/ErkIconButton/ErkIconButton.d.ts +17 -0
  113. package/dist/Shared/ErkIconButton/ErkIconButton.js +11 -0
  114. package/dist/Shared/ErkIconButton/ErkIconButton.module.css +41 -0
  115. package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +24 -0
  116. package/dist/Shared/ErkLocationField/ErkLocationField.js +128 -0
  117. package/dist/Shared/ErkLocationField/ErkLocationField.module.css +164 -0
  118. package/dist/Shared/ErkLocationField/ErkLocationField.test.d.ts +1 -0
  119. package/dist/Shared/ErkLocationField/ErkLocationField.test.js +82 -0
  120. package/dist/Shared/ErkLocationField/addressFields.d.ts +12 -0
  121. package/dist/Shared/ErkLocationField/addressFields.js +34 -0
  122. package/dist/Shared/ErkLocationField/locationRestrictions.d.ts +6 -0
  123. package/dist/Shared/ErkLocationField/locationRestrictions.js +51 -0
  124. package/dist/Shared/ErkLocationInput/ErkLocationInput.d.ts +15 -0
  125. package/dist/Shared/ErkLocationInput/ErkLocationInput.js +502 -0
  126. package/dist/Shared/ErkLocationInput/ErkLocationInput.module.css +128 -0
  127. package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +42 -0
  128. package/dist/Shared/ErkNumberField/ErkNumberField.js +169 -0
  129. package/dist/Utils/AxiosWidget.js +9 -1
  130. package/dist/constants/FormStepTypes.d.ts +5 -1
  131. package/dist/constants/FormStepTypes.js +4 -0
  132. package/dist/index.lib.d.ts +4 -2
  133. package/dist/index.lib.js +3 -1
  134. package/package.json +2 -1
@@ -4,6 +4,23 @@ import { CustomStep } from '../FormSteps/CustomStep';
4
4
  import { CBRFormStep } from '../@Types/CBRFormStep';
5
5
  import { MapperElement } from '../@Types/MapperElement';
6
6
  import { ValuesStore } from '../States/SiteSlice';
7
+ /** The reCAPTCHA widget surface a submission needs: the response it holds, and the challenge that mints one. */
8
+ export interface CaptchaWidget {
9
+ getValue(): string | null;
10
+ executeAsync(): Promise<string | null>;
11
+ }
12
+ /**
13
+ * Resolve the reCAPTCHA response to send with a submission, running the invisible challenge when the widget
14
+ * is not holding one yet.
15
+ *
16
+ * An unsolved invisible widget answers `getValue()` with an EMPTY STRING rather than null, so emptiness —
17
+ * not nullishness — is what decides whether the challenge still has to run. A submission that skips the
18
+ * challenge carries no token, and the API rejects every captcha-protected public form with a 403.
19
+ *
20
+ * Yields null when no widget is mounted, leaving the caller to submit tokenless rather than throwing out of
21
+ * the submit handler.
22
+ */
23
+ export declare function resolveCaptchaToken(captcha: CaptchaWidget | null | undefined): Promise<string | null>;
7
24
  /**
8
25
  * Function that cals the value of a step to output on submit
9
26
  */
@@ -3,6 +3,28 @@ import FormStepTypes, { EntityValueDataTypes } from '../constants/FormStepTypes'
3
3
  import { calcStepDeps } from '../FormSteps/StepHooks';
4
4
  import { calcRecursiveData } from '../Utils/FormStepFunctions';
5
5
  import { isValidPhoneNumber } from '../Utils/PhoneFunctions';
6
+ /**
7
+ * Resolve the reCAPTCHA response to send with a submission, running the invisible challenge when the widget
8
+ * is not holding one yet.
9
+ *
10
+ * An unsolved invisible widget answers `getValue()` with an EMPTY STRING rather than null, so emptiness —
11
+ * not nullishness — is what decides whether the challenge still has to run. A submission that skips the
12
+ * challenge carries no token, and the API rejects every captcha-protected public form with a 403.
13
+ *
14
+ * Yields null when no widget is mounted, leaving the caller to submit tokenless rather than throwing out of
15
+ * the submit handler.
16
+ */
17
+ export async function resolveCaptchaToken(captcha) {
18
+ if (!captcha)
19
+ return null;
20
+ const held = captcha.getValue();
21
+ if (held)
22
+ return held;
23
+ const solved = await captcha.executeAsync();
24
+ if (solved)
25
+ return solved;
26
+ return null;
27
+ }
6
28
  /**
7
29
  * Function that cals the value of a step to output on submit
8
30
  */
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/require-await */
2
2
  import { ContentState, EditorState } from 'draft-js';
3
3
  import FormStepTypes, { EntityValueDataTypes } from '../constants/FormStepTypes';
4
- import { calcDependencies, calcValue } from './FormFunctions';
4
+ import { calcDependencies, calcValue, resolveCaptchaToken } from './FormFunctions';
5
5
  import { stringToDraft } from '../Utils/DraftFunctions';
6
6
  import { describe, expect, test } from 'vitest';
7
7
  describe('FormFunctions', function () {
@@ -455,4 +455,31 @@ describe('FormFunctions', function () {
455
455
  expect(dependencyStore.idStep.dependents.length).toBe(1);
456
456
  });
457
457
  });
458
+ describe('resolveCaptchaToken', function () {
459
+ test('Uses the token the widget already holds without re-running the challenge', async () => {
460
+ let executed = false;
461
+ const token = await resolveCaptchaToken({
462
+ getValue: () => 'already-solved',
463
+ executeAsync: async () => {
464
+ executed = true;
465
+ return 'freshly-solved';
466
+ },
467
+ });
468
+ expect(token).toBe('already-solved');
469
+ expect(executed).toBe(false);
470
+ });
471
+ test('Runs the challenge when the invisible widget reports an empty response', async () => {
472
+ // An unsolved invisible captcha answers `getValue()` with '' — not null — so emptiness is what
473
+ // must decide whether the challenge still has to run. Treating only nullish as unsolved leaves
474
+ // the submission tokenless and the API answers 403.
475
+ const token = await resolveCaptchaToken({
476
+ getValue: () => '',
477
+ executeAsync: async () => 'freshly-solved',
478
+ });
479
+ expect(token).toBe('freshly-solved');
480
+ });
481
+ test('Yields no token when the widget is not mounted', async () => {
482
+ expect(await resolveCaptchaToken(null)).toBeNull();
483
+ });
484
+ });
458
485
  });
@@ -0,0 +1,7 @@
1
+ import { AvailabilityStep } from '../../@Types/CalendarFormStep';
2
+ import { StepProps } from '../Step';
3
+ export interface AvailabilityStepProps extends StepProps {
4
+ step: AvailabilityStep;
5
+ }
6
+ declare function AvailabilityStepComponent(props: AvailabilityStepProps): JSX.Element;
7
+ export default AvailabilityStepComponent;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FormStyleTypes } from '../../constants/FormStepTypes';
3
+ import MaterialAvailabilityStep from './MaterialAvailabilityStep/MaterialAvailabilityStep';
4
+ import { useAppSelector } from '../../hooks';
5
+ function AvailabilityStepComponent(props) {
6
+ const { formStyle } = useAppSelector((state) => state.global);
7
+ switch (formStyle.type) {
8
+ case FormStyleTypes.MATERIAL:
9
+ default: {
10
+ return _jsx(MaterialAvailabilityStep, { ...props });
11
+ }
12
+ }
13
+ }
14
+ export default AvailabilityStepComponent;
@@ -0,0 +1,8 @@
1
+ import { AvailabilityStepProps } from '../AvailabilityStep';
2
+ /**
3
+ * Conector del paso AVAILABILITY: pregunta de disponibilidad compacta
4
+ * (grid semanal día × hora). El calendario completo vive en el admin; el form
5
+ * solo captura ventanas disponibles que un paso BOOKING puede consumir.
6
+ */
7
+ declare function MaterialAvailabilityStep({ step, editable }: AvailabilityStepProps): JSX.Element;
8
+ export default MaterialAvailabilityStep;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext } from 'react';
3
+ import { useFormStep } from '../../StepHooks';
4
+ import FormContext from '../../../Contexts/FormContext';
5
+ import { selectBreakPoint, useAppSelector } from '../../../hooks';
6
+ import { calcStepWidth } from '../../StepFunctions';
7
+ import ErkAvailabilityPicker from '../../../Shared/ErkAvailabilityPicker/ErkAvailabilityPicker';
8
+ /**
9
+ * Conector del paso AVAILABILITY: pregunta de disponibilidad compacta
10
+ * (grid semanal día × hora). El calendario completo vive en el admin; el form
11
+ * solo captura ventanas disponibles que un paso BOOKING puede consumir.
12
+ */
13
+ function MaterialAvailabilityStep({ step, editable }) {
14
+ const currentBreakPoint = useAppSelector(selectBreakPoint);
15
+ const { postview, formStyle } = useAppSelector((state) => state.global);
16
+ const formCtx = useContext(FormContext);
17
+ const isReadOnly = !editable || postview;
18
+ const widthStyle = currentBreakPoint <= step.size ? '100%' : calcStepWidth(step.size, formCtx.size);
19
+ const cssVars = {
20
+ width: widthStyle,
21
+ '--eureka-outline': formStyle.outlineColor,
22
+ '--eureka-primary': formStyle.primaryColor,
23
+ '--eureka-text': formStyle.textColor,
24
+ '--eureka-bg': formStyle.standAloneBackgroundColor ?? '#fff',
25
+ };
26
+ const { ref, value, onChange, error } = useFormStep(step, {
27
+ defaultValue: null,
28
+ rules: { required: step.required ? 'Marca tu disponibilidad' : undefined },
29
+ });
30
+ return (_jsx("div", { ref: ref, style: cssVars, children: _jsx(ErkAvailabilityPicker, { value: value, onChange: onChange, label: step.label, description: step.description, minTime: step.minTime, maxTime: step.maxTime, showWeekends: step.showWeekends, timezone: step.timezone, readOnly: isReadOnly, error: error?.message }) }));
31
+ }
32
+ export default MaterialAvailabilityStep;
@@ -0,0 +1,17 @@
1
+ import { BookingStep } from '../../@Types/BookingFormStep';
2
+ import { BookingSlot } from '../../@Types/BookingFormStep';
3
+ import { StepProps } from '../Step';
4
+ export interface BookingStepProps extends StepProps {
5
+ step: BookingStep;
6
+ /**
7
+ * Callback to fetch available slots for a given person + date.
8
+ * The form host wires this to their availability API.
9
+ * If omitted, the component shows an empty slot list.
10
+ */
11
+ fetchSlots?: (params: {
12
+ personId?: string;
13
+ date: string;
14
+ }) => Promise<BookingSlot[]>;
15
+ }
16
+ declare function BookingStepComponent(props: BookingStepProps): JSX.Element;
17
+ export default BookingStepComponent;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FormStyleTypes } from '../../constants/FormStepTypes';
3
+ import MaterialBookingStep from './MaterialBookingStep/MaterialBookingStep';
4
+ import { useAppSelector } from '../../hooks';
5
+ function BookingStepComponent(props) {
6
+ const { formStyle } = useAppSelector((state) => state.global);
7
+ switch (formStyle.type) {
8
+ case FormStyleTypes.MATERIAL:
9
+ default: {
10
+ return _jsx(MaterialBookingStep, { ...props });
11
+ }
12
+ }
13
+ }
14
+ export default BookingStepComponent;
@@ -0,0 +1,7 @@
1
+ import { BookingStepProps } from '../BookingStep';
2
+ /**
3
+ * Conector del paso BOOKING: enlaza el estado del formulario (`useFormStep`) y el
4
+ * theming del form con el componente reutilizable `ErkBookingPicker` (en Shared).
5
+ */
6
+ declare function MaterialBookingStep({ step, editable, fetchSlots }: BookingStepProps): JSX.Element;
7
+ export default MaterialBookingStep;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext } from 'react';
3
+ import { useFormStep } from '../../StepHooks';
4
+ import FormContext from '../../../Contexts/FormContext';
5
+ import { selectBreakPoint, useAppSelector } from '../../../hooks';
6
+ import { calcStepWidth } from '../../StepFunctions';
7
+ import ErkBookingPicker from '../../../Shared/ErkBookingPicker/ErkBookingPicker';
8
+ /**
9
+ * Conector del paso BOOKING: enlaza el estado del formulario (`useFormStep`) y el
10
+ * theming del form con el componente reutilizable `ErkBookingPicker` (en Shared).
11
+ */
12
+ function MaterialBookingStep({ step, editable, fetchSlots }) {
13
+ const currentBreakPoint = useAppSelector(selectBreakPoint);
14
+ const { postview, formStyle } = useAppSelector((state) => state.global);
15
+ const formCtx = useContext(FormContext);
16
+ const isReadOnly = !editable || postview;
17
+ const widthStyle = currentBreakPoint <= step.size ? '100%' : calcStepWidth(step.size, formCtx.size);
18
+ const cssVars = {
19
+ width: widthStyle,
20
+ '--eureka-outline': formStyle.outlineColor,
21
+ '--eureka-primary': formStyle.primaryColor,
22
+ '--eureka-text': formStyle.textColor,
23
+ '--eureka-bg': formStyle.standAloneBackgroundColor ?? '#fff',
24
+ '--booking-accent': formStyle.secondaryContrastColor,
25
+ };
26
+ const { ref, value, onChange, error } = useFormStep(step, {
27
+ defaultValue: null,
28
+ rules: { required: step.required ? 'Selecciona una cita' : undefined },
29
+ });
30
+ return (_jsx("div", { ref: ref, style: cssVars, children: _jsx(ErkBookingPicker, { value: value, onChange: onChange, label: step.label, description: step.description, durationMinutes: step.durationMinutes, bufferMinutes: step.bufferMinutes, bookingMode: step.bookingMode, temporaryLockMinutes: step.temporaryLockMinutes, personSelectionMode: step.personSelectionMode, persons: step.persons, collectContact: step.collectContact, fetchSlots: fetchSlots, readOnly: isReadOnly, error: error?.message }) }));
31
+ }
32
+ export default MaterialBookingStep;
@@ -48,7 +48,7 @@ function makeStore(currentBreakPoint) {
48
48
  ...defaultRootState,
49
49
  widthStats: {
50
50
  currentBreakPoint,
51
- isMobile: currentBreakPoint <= checkBoxStep.size,
51
+ isMobile: currentBreakPoint <= 1,
52
52
  isResponsive: true,
53
53
  },
54
54
  },
@@ -57,15 +57,15 @@ function makeStore(currentBreakPoint) {
57
57
  middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(RootApi.middleware),
58
58
  });
59
59
  }
60
- function Harness({ currentBreakPoint }) {
60
+ function Harness({ currentBreakPoint, step = checkBoxStep, }) {
61
61
  const methods = useForm({ mode: 'onTouched' });
62
- return (_jsx(MaterialProviders, { formStyle: InternalFormStyle, children: _jsx(Provider, { store: makeStore(currentBreakPoint), context: StoreContext, children: _jsx(IdFormContext.Provider, { value: STORY_FORM_ID, children: _jsx(FormContext.Provider, { value: form, children: _jsx(SectionContext.Provider, { value: "SECTION_1", children: _jsx(FormProvider, { ...methods, children: _jsx(CheckBoxStep, { step: checkBoxStep, editable: true }) }) }) }) }) }) }));
62
+ return (_jsx(MaterialProviders, { formStyle: InternalFormStyle, children: _jsx(Provider, { store: makeStore(currentBreakPoint), context: StoreContext, children: _jsx(IdFormContext.Provider, { value: STORY_FORM_ID, children: _jsx(FormContext.Provider, { value: { ...form, steps: { ...form.steps, [step.id]: step } }, children: _jsx(SectionContext.Provider, { value: "SECTION_1", children: _jsx(FormProvider, { ...methods, children: _jsx(CheckBoxStep, { step: step, editable: true }) }) }) }) }) }) }));
63
63
  }
64
64
  function getLabelDiv() {
65
65
  // the leaf div holding only the label text (the wrapping column also matches by textContent)
66
66
  return screen.getByText((_, element) => element?.tagName === 'DIV' && element.children.length === 0 && element.textContent === `${LONG_LABEL}:`);
67
67
  }
68
- /** Makes every element report a 2-line-clamped overflow (jsdom has no layout). */
68
+ /** Makes every element report a 1-line-clamped overflow (jsdom has no layout). */
69
69
  function mockLabelOverflow() {
70
70
  Object.defineProperty(HTMLElement.prototype, 'scrollHeight', {
71
71
  configurable: true,
@@ -76,7 +76,7 @@ function mockLabelOverflow() {
76
76
  Object.defineProperty(HTMLElement.prototype, 'clientHeight', {
77
77
  configurable: true,
78
78
  get() {
79
- return 48;
79
+ return 24;
80
80
  },
81
81
  });
82
82
  }
@@ -85,22 +85,30 @@ afterEach(() => {
85
85
  delete HTMLElement.prototype.scrollHeight;
86
86
  delete HTMLElement.prototype.clientHeight;
87
87
  });
88
- describe('CheckBoxStep label on collapsed (mobile) breakpoints', () => {
89
- it('wraps the label (2-line clamp) instead of single-line truncating it when the step collapses to 100% width', () => {
88
+ describe('CheckBoxStep long labels', () => {
89
+ it('clamps the label to 1 line with a toggle instead of a plain ellipsis when the step collapses to 100% width', () => {
90
90
  // breakpoint 1 <= size 2 → MaterialInputContainer renders the step at width: 100%
91
91
  render(_jsx(Harness, { currentBreakPoint: 1 }));
92
92
  const label = getLabelDiv();
93
93
  expect(label.className).toBe(styles.clampLbl);
94
- expect(label.className).not.toBe(styles.overflowLbl);
95
- // the fixed desktop pixel maxWidth must not constrain the collapsed label
94
+ // no fixed desktop pixel maxWidth constrains the label
96
95
  expect(label.style.maxWidth).toBe('');
97
96
  });
98
- it('keeps the single-line ellipsis label on desktop widths (control)', () => {
97
+ it('also clamps (with "ver más") when the step keeps a fixed width on a phone where 2 columns fit', () => {
98
+ // regression: a size-1 checkbox at breakpoint 2 used to render a single-line ellipsis with
99
+ // no way to read the full label
100
+ mockLabelOverflow();
101
+ render(_jsx(Harness, { currentBreakPoint: 2, step: { ...checkBoxStep, size: 1 } }));
102
+ const label = getLabelDiv();
103
+ expect(label.className).toBe(styles.clampLbl);
104
+ expect(label.style.maxWidth).toBe('');
105
+ expect(screen.getByRole('button', { name: 'ver más' })).toBeInTheDocument();
106
+ });
107
+ it('clamps on desktop widths too, without a toggle while the label fits', () => {
99
108
  // breakpoint 4 > size 2 → the step keeps its fixed desktop width
100
109
  render(_jsx(Harness, { currentBreakPoint: 4 }));
101
110
  const label = getLabelDiv();
102
- expect(label.className).toBe(styles.overflowLbl);
103
- expect(label.style.maxWidth).not.toBe('');
111
+ expect(label.className).toBe(styles.clampLbl);
104
112
  expect(screen.queryByRole('button', { name: 'ver más' })).not.toBeInTheDocument();
105
113
  });
106
114
  it('shows no "ver más" toggle when the label fits in the clamp', () => {
@@ -8,7 +8,6 @@ import { useAppSelector, selectWidthStats } from '../../../hooks';
8
8
  import { useFormStep } from '../../StepHooks';
9
9
  import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
10
10
  import MaterialInputContainer from '../../Utils/MaterialInputContainer/MaterialInputContainer';
11
- import { calcStepWidth, resolveStepSpan } from '../../StepFunctions';
12
11
  function CheckBoxStep({ step, editable }) {
13
12
  const { ref, value, onChange, error, field } = useFormStep(step, {
14
13
  defaultValue: step.defaultValue ?? false,
@@ -20,15 +19,15 @@ function CheckBoxStep({ step, editable }) {
20
19
  const { formStyle, postview } = useAppSelector((state) => state.global);
21
20
  const form = useContext(FormContext);
22
21
  const widthStats = useAppSelector(selectWidthStats);
23
- const span = resolveStepSpan(step, widthStats, form.size);
24
- // when the breakpoint collapses the step to width: 100% (see MaterialInputContainer),
25
- // the fixed desktop pixel width no longer matches the real available space
26
- const collapsed = widthStats.currentBreakPoint <= span;
22
+ // The label is clamped to 1 line with a "ver más" toggle at every width. A plain
23
+ // ellipsis was used while the step kept its fixed desktop pixel width, but that left long
24
+ // labels unreadable wherever the step is narrow (e.g. a size-1 checkbox on a phone where 2
25
+ // columns fit).
27
26
  const labelRef = useRef(null);
28
27
  const [expanded, setExpanded] = useState(false);
29
28
  const [clamped, setClamped] = useState(false);
30
29
  useLayoutEffect(() => {
31
- if (!collapsed || expanded)
30
+ if (expanded)
32
31
  return;
33
32
  const measure = () => {
34
33
  const label = labelRef.current;
@@ -38,7 +37,7 @@ function CheckBoxStep({ step, editable }) {
38
37
  measure();
39
38
  window.addEventListener('resize', measure);
40
39
  return () => window.removeEventListener('resize', measure);
41
- }, [collapsed, expanded, step.label]);
40
+ }, [expanded, step.label, widthStats.currentBreakPoint]);
42
41
  const renderNested = () => {
43
42
  const steps = value ? step.steps : step.uncheckedSteps;
44
43
  return (_jsx(React.Fragment, { children: steps?.map((idStep) => {
@@ -48,18 +47,12 @@ function CheckBoxStep({ step, editable }) {
48
47
  };
49
48
  const renderLabel = (colon = false) => {
50
49
  const label = `${step.label}${step.required ? ' *' : ''}${colon ? ':' : ''}`;
51
- if (!collapsed) {
52
- return (_jsx("div", { className: span === 4 ? styles.checkboxLbl : styles.overflowLbl, style: {
53
- maxWidth: calcStepWidth(span, form.size) - 45,
54
- }, children: label }));
55
- }
56
50
  return (_jsxs("div", { className: styles.labelColumn, children: [_jsx("div", { ref: labelRef, className: expanded ? styles.expandedLbl : styles.clampLbl, children: label }), (clamped || expanded) && (_jsx("button", { type: "button", className: styles.toggleLbl, style: { color: formStyle.primaryColor }, onClick: (event) => {
57
51
  event.stopPropagation();
58
52
  setExpanded(!expanded);
59
53
  }, children: expanded ? 'ver menos' : 'ver más' }))] }));
60
54
  };
61
55
  return (_jsxs(StepFillerContainer, { step: step, children: [_jsx(MaterialInputContainer, { step: step, editable: editable, maxHeight: step.size < 4, children: _jsxs("div", { className: styles.container, children: [_jsxs("div", { className: styles.labelCheckBoxContainer, style: {
62
- height: span < 4 && !collapsed ? 31 : undefined,
63
56
  minHeight: 31,
64
57
  alignItems: step.isList ? 'start' : 'center',
65
58
  }, children: [step.label && !step.isList && renderLabel(true), _jsx(ErkCheckBox, { ...field, padding: "0px", inputRef: ref, error: !!error, checked: value, onChange: onChange, "data-testid": step.id, readOnly: !editable || postview }), step.label && step.isList && renderLabel()] }), (step.description ?? !!error) && (_jsx("div", { className: styles.descriptionPar, style: {
@@ -3,17 +3,6 @@
3
3
  flex-direction: column;
4
4
  max-width: 100%;
5
5
  }
6
- .checkboxLbl,
7
- .overflowLbl {
8
- font-size: 18px;
9
- margin-right: 10px;
10
- margin-left: 10px;
11
- }
12
- .overflowLbl {
13
- white-space: nowrap;
14
- overflow: hidden;
15
- text-overflow: ellipsis;
16
- }
17
6
  .labelColumn {
18
7
  display: flex;
19
8
  flex-direction: column;
@@ -30,8 +19,8 @@
30
19
  .clampLbl {
31
20
  display: -webkit-box;
32
21
  -webkit-box-orient: vertical;
33
- -webkit-line-clamp: 2;
34
- line-clamp: 2;
22
+ -webkit-line-clamp: 1;
23
+ line-clamp: 1;
35
24
  overflow: hidden;
36
25
  }
37
26
  .toggleLbl {
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
@@ -0,0 +1,70 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { describe, expect, it } from 'vitest';
5
+ import '@testing-library/jest-dom';
6
+ import { Provider } from 'react-redux';
7
+ import { FormProvider, useForm } from 'react-hook-form';
8
+ import { configureStore } from '@reduxjs/toolkit';
9
+ import { EurekaFormsReducer, defaultRootState } from '../../Utils/store';
10
+ import { RootApi } from '../../Utils/_api';
11
+ import FormStepTypes from '../../constants/FormStepTypes';
12
+ import { StoreContext } from '../../Utils/StoreContext';
13
+ import FormContext, { IdFormContext } from '../../Contexts/FormContext';
14
+ import SectionContext from '../../Contexts/SectionContext';
15
+ import MaterialProviders from '../../Utils/MaterialProviders';
16
+ import InternalFormStyle from '../../constants/InternalFormStyle';
17
+ import ClassifierSelectorStep from './ClassifierSelectorStep';
18
+ const ID_FORM = 'LATE_CLASSIFIERS_FORM';
19
+ const step = {
20
+ id: 'tipo-step',
21
+ idSection: 'SECTION_1',
22
+ stepPath: ['tipo-step'],
23
+ type: FormStepTypes.CLASSIFIER_SELECTOR,
24
+ idClassifier: 'tipo',
25
+ label: 'Tipo de solicitud',
26
+ description: '',
27
+ searchable: true,
28
+ options: {},
29
+ required: false,
30
+ size: 2,
31
+ };
32
+ /** The project's classifiers, as the host resolves them (asynchronously) and passes them to the form. */
33
+ const classifiers = {
34
+ tipo: { _id: 'tipo', name: 'Tipo de solicitud', children: ['bug', 'mejora'] },
35
+ bug: { _id: 'bug', name: 'Error / Bug', children: [] },
36
+ mejora: { _id: 'mejora', name: 'Propuesta de mejora', children: [] },
37
+ };
38
+ const form = {
39
+ firstSection: 'SECTION_1',
40
+ sections: {
41
+ SECTION_1: { id: 'SECTION_1', name: 'Sección 1', steps: ['tipo-step'], nextSection: null },
42
+ },
43
+ steps: { 'tipo-step': step },
44
+ confirmationMessage: { blocks: [], entityMap: {} },
45
+ showLink: false,
46
+ size: { blockSize: 200, blockNum: 4, spacingSize: 10 },
47
+ };
48
+ function makeStore() {
49
+ return configureStore({
50
+ reducer: { forms: EurekaFormsReducer, [RootApi.reducerPath]: RootApi.reducer },
51
+ preloadedState: { forms: { [ID_FORM]: { ...defaultRootState } } },
52
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(RootApi.middleware),
53
+ });
54
+ }
55
+ function Harness({ store, formClassifiers, }) {
56
+ const methods = useForm({ mode: 'onTouched' });
57
+ 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, classifiers: formClassifiers }, children: _jsx(SectionContext.Provider, { value: "SECTION_1", children: _jsx(FormProvider, { ...methods, children: _jsx(ClassifierSelectorStep, { step: step, editable: true }) }) }) }) }) }) }));
58
+ }
59
+ describe('ClassifierSelectorStep with classifiers that arrive after the first render', () => {
60
+ it('renders nothing while the classifiers are unknown, then the selector with its options', async () => {
61
+ const user = userEvent.setup();
62
+ const store = makeStore();
63
+ const { rerender } = render(_jsx(Harness, { store: store, formClassifiers: undefined }));
64
+ expect(screen.queryByRole('combobox')).not.toBeInTheDocument();
65
+ rerender(_jsx(Harness, { store: store, formClassifiers: classifiers }));
66
+ await user.click(await screen.findByRole('combobox'));
67
+ expect(await screen.findByRole('option', { name: 'Error / Bug' })).toBeInTheDocument();
68
+ expect(screen.getByRole('option', { name: 'Propuesta de mejora' })).toBeInTheDocument();
69
+ });
70
+ });
@@ -50,8 +50,10 @@ function ClassifierSelectorStep({ step, editable }) {
50
50
  };
51
51
  }) ?? []);
52
52
  },
53
+ // The classifiers dictionary can arrive after the first render (see useSetupApp), so the
54
+ // options must follow it, not only the dependency values.
53
55
  // eslint-disable-next-line react-hooks/exhaustive-deps
54
- [dependenciesValues]);
56
+ [dependenciesValues, classifier, form.classifiers]);
55
57
  useEffect(() => {
56
58
  if (value && !options?.find((option) => option.value === value?.value)) {
57
59
  onChange('');
@@ -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 { recursivelyCalcConditionSteps, selectDependencies } from '../../StepHooks';
8
+ import { isStepHiddenByCondition, 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,6 +13,8 @@ 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';
16
18
  function EntityValuePickerStep({ step, editable }) {
17
19
  const form = useContext(FormContext);
18
20
  const subscribe = useApiSubscribe();
@@ -25,8 +27,23 @@ function EntityValuePickerStep({ step, editable }) {
25
27
  }))) ?? []);
26
28
  }, [subscribe, idForm]);
27
29
  const getOptions = useCallback(async (step, dependencyStore, ids) => {
28
- return await getEntityValueOptions(step, dependencyStore, ids, fetchFilterIntegration);
29
- }, [fetchFilterIntegration]);
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]);
30
47
  const [dialogs, setDialogs] = useState();
31
48
  const dialogsIdStepDeps = useMemo(() => {
32
49
  const ids = [];
@@ -111,7 +128,7 @@ function EntityValuePickerStep({ step, editable }) {
111
128
  } }) })] }));
112
129
  }
113
130
  export default EntityValuePickerStep;
114
- const getEntityValueOptions = async (step, dependencyStore, { idOrganization, idCurrentAgent, }, fetchFilterIntegration) => {
131
+ const getEntityValueOptions = async (step, dependencyStore, { idOrganization, idCurrentAgent, }, fetchFilterIntegration, form) => {
115
132
  if (!idOrganization)
116
133
  return null;
117
134
  let urlPath = '';
@@ -173,14 +190,12 @@ const getEntityValueOptions = async (step, dependencyStore, { idOrganization, id
173
190
  break;
174
191
  }
175
192
  case EntityValueDataTypes.STEP: {
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);
193
+ const currentValue = entityValueDependencyValue(dependencyStore[filter.idStep]);
194
+ if (currentValue !== undefined) {
195
+ params.set(filter.idProperty, currentValue);
182
196
  }
183
- else if (filter.required) {
197
+ else if (filter.required && !isStepHiddenByCondition(filter.idStep, form, dependencyStore)) {
198
+ // A required filter blocks only while its step can still be answered.
184
199
  return null;
185
200
  }
186
201
  break;
@@ -201,18 +216,3 @@ const getEntityValueOptions = async (step, dependencyStore, { idOrganization, id
201
216
  });
202
217
  return response.data.filter((option) => step.options[option._id]?.type !== EntityValueOptionTypes.HIDE);
203
218
  };
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
- };
@@ -0,0 +1,12 @@
1
+ import { StepDependency } from '../../Form/Form';
2
+ /**
3
+ * Serializes the current value of a dependency step into the string an entity-picker STEP filter
4
+ * sends as `values.<idProperty>` query param.
5
+ *
6
+ * Entity values (and any id-bearing object) resolve to their id. The answer of a Selector or
7
+ * Classifier step is a `{ label, value }` option: a Selector keeps `value === label`, so its `value`
8
+ * is the text the entity property stores; a Classifier's `value` is the classifier id, which no
9
+ * entity property holds, so it resolves to its `label`. Returns undefined when the dependency has
10
+ * no usable value, so the caller treats the filter as unresolved.
11
+ */
12
+ export declare function entityValueDependencyValue(dependency: StepDependency | undefined): string | undefined;
@@ -0,0 +1,35 @@
1
+ import FormStepTypes from '../../constants/FormStepTypes';
2
+ /**
3
+ * Serializes the current value of a dependency step into the string an entity-picker STEP filter
4
+ * sends as `values.<idProperty>` query param.
5
+ *
6
+ * Entity values (and any id-bearing object) resolve to their id. The answer of a Selector or
7
+ * Classifier step is a `{ label, value }` option: a Selector keeps `value === label`, so its `value`
8
+ * is the text the entity property stores; a Classifier's `value` is the classifier id, which no
9
+ * entity property holds, so it resolves to its `label`. Returns undefined when the dependency has
10
+ * no usable value, so the caller treats the filter as unresolved.
11
+ */
12
+ export function entityValueDependencyValue(dependency) {
13
+ const currentValue = dependency?.value;
14
+ if (currentValue === null || currentValue === undefined || currentValue === '')
15
+ return undefined;
16
+ if (typeof currentValue === 'string')
17
+ return currentValue;
18
+ if (typeof currentValue === 'number' || typeof currentValue === 'boolean')
19
+ return String(currentValue);
20
+ if (currentValue instanceof Date)
21
+ return currentValue.toISOString();
22
+ if (typeof currentValue !== 'object')
23
+ return undefined;
24
+ const record = currentValue;
25
+ // A Selector's `value` is the stored text; every other step's `value` may be an id, so its `label` wins.
26
+ const keys = dependency?.type === FormStepTypes.SELECTOR ? ['_id', 'id', 'value', 'label'] : ['_id', 'id', 'label', 'value'];
27
+ for (const key of keys) {
28
+ const candidate = record[key];
29
+ if (typeof candidate === 'string' && candidate !== '')
30
+ return candidate;
31
+ if (typeof candidate === 'number')
32
+ return String(candidate);
33
+ }
34
+ return undefined;
35
+ }