@arquimedes.co/eureka-forms 3.0.66 → 3.0.68-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 (141) 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/CheckBoxStep/CheckBoxStep.mobileLabel.test.js +12 -20
  13. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +13 -6
  14. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +13 -2
  15. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +1 -3
  16. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +21 -10
  17. package/dist/FormSteps/Step.js +0 -16
  18. package/dist/FormSteps/StepFunctions.js +0 -14
  19. package/dist/FormSteps/StepFunctions.test.js +0 -54
  20. package/dist/FormSteps/StepHooks.d.ts +0 -14
  21. package/dist/FormSteps/StepHooks.js +8 -39
  22. package/dist/Shared/ErkDatePicker/ErkDatePicker.js +12 -4
  23. package/dist/Shared/ErkDatePicker/ErkDatePicker.locale.test.js +39 -0
  24. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +3 -2
  25. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +16 -11
  26. package/dist/Shared/ErkSelect/ErkSelect.js +9 -1
  27. package/dist/Shared/ErkSelect/ErkSelect.test.d.ts +2 -0
  28. package/dist/Shared/ErkSelect/ErkSelect.test.js +53 -0
  29. package/dist/Shared/ErkTimePicker/ErkTimePicker.js +8 -1
  30. package/dist/Shared/ErkTimePicker/ErkTimePicker.test.d.ts +2 -0
  31. package/dist/Shared/ErkTimePicker/ErkTimePicker.test.js +24 -0
  32. package/dist/Utils/AxiosWidget.js +1 -9
  33. package/dist/Utils/LocaleUtils.d.ts +1 -0
  34. package/dist/Utils/LocaleUtils.js +10 -3
  35. package/dist/constants/FormStepTypes.d.ts +1 -5
  36. package/dist/constants/FormStepTypes.js +0 -4
  37. package/dist/index.lib.d.ts +2 -4
  38. package/dist/index.lib.js +1 -3
  39. package/package.json +1 -2
  40. package/dist/@Types/AvailabilityFormStep.d.ts +0 -48
  41. package/dist/@Types/AvailabilityFormStep.js +0 -24
  42. package/dist/@Types/BankAccountFormStep.d.ts +0 -67
  43. package/dist/@Types/BankAccountFormStep.js +0 -14
  44. package/dist/@Types/BookingFormStep.d.ts +0 -187
  45. package/dist/@Types/BookingFormStep.js +0 -44
  46. package/dist/@Types/CalendarFormStep.d.ts +0 -209
  47. package/dist/@Types/CalendarFormStep.js +0 -55
  48. package/dist/@Types/CommunicationChannelFormStep.d.ts +0 -51
  49. package/dist/@Types/CommunicationChannelFormStep.js +0 -15
  50. package/dist/@Types/ConsentFormStep.d.ts +0 -36
  51. package/dist/@Types/ConsentFormStep.js +0 -8
  52. package/dist/@Types/EntityFormFormStep.d.ts +0 -66
  53. package/dist/@Types/EntityFormFormStep.js +0 -20
  54. package/dist/@Types/EventFormStep.d.ts +0 -52
  55. package/dist/@Types/EventFormStep.js +0 -13
  56. package/dist/@Types/ExternalReferenceFormStep.d.ts +0 -74
  57. package/dist/@Types/ExternalReferenceFormStep.js +0 -20
  58. package/dist/@Types/LocationFormStep.d.ts +0 -159
  59. package/dist/@Types/LocationFormStep.js +0 -46
  60. package/dist/@Types/NumericFormSteps.d.ts +0 -108
  61. package/dist/@Types/NumericFormSteps.js +0 -20
  62. package/dist/@Types/PredefinedSelectorFormStep.d.ts +0 -51
  63. package/dist/@Types/PredefinedSelectorFormStep.js +0 -39
  64. package/dist/@Types/StepRef.d.ts +0 -135
  65. package/dist/@Types/StepRef.js +0 -49
  66. package/dist/FormSteps/AvailabilityStep/AvailabilityStep.d.ts +0 -7
  67. package/dist/FormSteps/AvailabilityStep/AvailabilityStep.js +0 -14
  68. package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.d.ts +0 -8
  69. package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.js +0 -32
  70. package/dist/FormSteps/BookingStep/BookingStep.d.ts +0 -17
  71. package/dist/FormSteps/BookingStep/BookingStep.js +0 -14
  72. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.d.ts +0 -7
  73. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +0 -32
  74. package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.js +0 -70
  75. package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.d.ts +0 -12
  76. package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.js +0 -35
  77. package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.test.d.ts +0 -1
  78. package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.test.js +0 -31
  79. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.d.ts +0 -27
  80. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.js +0 -64
  81. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.d.ts +0 -1
  82. package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.js +0 -95
  83. package/dist/FormSteps/LocationStep/LocationStep.d.ts +0 -10
  84. package/dist/FormSteps/LocationStep/LocationStep.js +0 -14
  85. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.d.ts +0 -3
  86. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.js +0 -54
  87. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.module.css +0 -18
  88. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.d.ts +0 -3
  89. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.js +0 -170
  90. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +0 -96
  91. package/dist/FormSteps/NumberStep/NumberStep.d.ts +0 -10
  92. package/dist/FormSteps/NumberStep/NumberStep.js +0 -14
  93. package/dist/FormSteps/StepHooks.test.d.ts +0 -1
  94. package/dist/FormSteps/StepHooks.test.js +0 -92
  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/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.d.ts +0 -19
  106. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.js +0 -80
  107. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.module.css +0 -88
  108. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +0 -29
  109. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +0 -139
  110. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.d.ts +0 -25
  111. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.js +0 -112
  112. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.module.css +0 -88
  113. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.d.ts +0 -1
  114. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.js +0 -73
  115. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.d.ts +0 -31
  116. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.js +0 -228
  117. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.module.css +0 -608
  118. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.d.ts +0 -28
  119. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.js +0 -117
  120. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.d.ts +0 -1
  121. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.js +0 -49
  122. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.d.ts +0 -1
  123. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.js +0 -107
  124. package/dist/Shared/ErkIconButton/ErkIconButton.d.ts +0 -17
  125. package/dist/Shared/ErkIconButton/ErkIconButton.js +0 -11
  126. package/dist/Shared/ErkIconButton/ErkIconButton.module.css +0 -41
  127. package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +0 -24
  128. package/dist/Shared/ErkLocationField/ErkLocationField.js +0 -128
  129. package/dist/Shared/ErkLocationField/ErkLocationField.module.css +0 -164
  130. package/dist/Shared/ErkLocationField/ErkLocationField.test.d.ts +0 -1
  131. package/dist/Shared/ErkLocationField/ErkLocationField.test.js +0 -82
  132. package/dist/Shared/ErkLocationField/addressFields.d.ts +0 -12
  133. package/dist/Shared/ErkLocationField/addressFields.js +0 -34
  134. package/dist/Shared/ErkLocationField/locationRestrictions.d.ts +0 -6
  135. package/dist/Shared/ErkLocationField/locationRestrictions.js +0 -51
  136. package/dist/Shared/ErkLocationInput/ErkLocationInput.d.ts +0 -15
  137. package/dist/Shared/ErkLocationInput/ErkLocationInput.js +0 -502
  138. package/dist/Shared/ErkLocationInput/ErkLocationInput.module.css +0 -128
  139. package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +0 -42
  140. package/dist/Shared/ErkNumberField/ErkNumberField.js +0 -169
  141. /package/dist/{FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.d.ts → Shared/ErkDatePicker/ErkDatePicker.locale.test.d.ts} +0 -0
@@ -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 () => {
@@ -67,20 +67,6 @@ export declare const selectStepDependencies: ((state: RootState, _step: GBaseSte
67
67
  memoize: typeof import("reselect").weakMapMemoize;
68
68
  argsMemoize: typeof import("reselect").weakMapMemoize;
69
69
  };
70
- /**
71
- * The steps `idStep` depends on, transitively: every dependency's own dependencies come before it,
72
- * and every id is answered exactly once. `idStep` itself is never listed — a step is not a
73
- * dependency of itself, even when a draft points it back at itself.
74
- *
75
- * A saved form is a DAG: the backend recomputes and validates `step.dependencies` on save. The
76
- * editor's live preview renders unsaved drafts though, where a filter or a path hop can still point
77
- * at the step that holds it, or close a cycle with another step. The walk must therefore terminate
78
- * on any graph, cyclic included: a step is marked visited before it is walked and is never walked
79
- * or listed twice, so every edge is followed at most once.
80
- *
81
- * Exported for the unit test; it is internal to this module and not part of the package's surface.
82
- */
83
- export declare const calcDeepDependencies: (idStep: string, form: Form) => string[];
84
70
  export interface UseFormStepOptions<ValueType> {
85
71
  defaultValue: ValueType;
86
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,
@@ -66,45 +65,15 @@ export const selectStepDependencies = createSelector([
66
65
  }
67
66
  return { invalids, emptyDep };
68
67
  });
69
- /**
70
- * The steps `idStep` depends on, transitively: every dependency's own dependencies come before it,
71
- * and every id is answered exactly once. `idStep` itself is never listed — a step is not a
72
- * dependency of itself, even when a draft points it back at itself.
73
- *
74
- * A saved form is a DAG: the backend recomputes and validates `step.dependencies` on save. The
75
- * editor's live preview renders unsaved drafts though, where a filter or a path hop can still point
76
- * at the step that holds it, or close a cycle with another step. The walk must therefore terminate
77
- * on any graph, cyclic included: a step is marked visited before it is walked and is never walked
78
- * or listed twice, so every edge is followed at most once.
79
- *
80
- * Exported for the unit test; it is internal to this module and not part of the package's surface.
81
- */
82
- export const calcDeepDependencies = (idStep, form) => {
83
- const deps = [];
84
- /** `idStep` starts out visited so a cycle back to it stops there and never lists it. */
85
- const visited = new Set([idStep]);
86
- const walk = (id) => {
87
- const step = form.steps[id];
88
- if (!step)
89
- return;
90
- /**
91
- * An entity picker also gives up (its options resolve to null) while a path hop or a
92
- * required STEP filter holds no value. Those are in `step.dependencies` once the form has
93
- * been saved, but not in an unsaved draft, so they are added here to read as a missing
94
- * dependency instead of as a failed load.
95
- */
96
- const idDeps = step.type === FormStepTypes.ENTITYVALUEPICKER
97
- ? [...(step.dependencies ?? []), ...entityValuePickerBlockingSteps(step)]
98
- : step.dependencies;
99
- for (const dep of idDeps ?? []) {
100
- if (visited.has(dep))
101
- continue;
102
- visited.add(dep);
103
- walk(dep);
104
- 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
+ }
105
75
  }
106
- };
107
- walk(idStep);
76
+ }
108
77
  return deps;
109
78
  };
110
79
  export const useFormStep = (step, { rules, debounce, sizeChange, defaultValue }) => {
@@ -1,10 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React, { useMemo } from 'react';
3
- import { format as dateFnsFormat, isValid } from 'date-fns';
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, 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 }) => ({
@@ -138,18 +140,24 @@ const StyledDay = styled(MuiPickerDay)(({ theme }) => ({
138
140
  }));
139
141
  function CustomPickerField({ error, required, helperText, size = 'small', labelMargin = 5, inputRef, fullWidth = true, }) {
140
142
  const { value, fieldFormat, setOpen, disabled, readOnly, label } = usePickerContext();
143
+ // Format through the adapter so the LocalizationProvider locale applies (a bare date-fns
144
+ // `format` always used en-US, so Spanish users saw MM/dd/yyyy).
145
+ const adapter = usePickerAdapter();
141
146
  const { displayValue, isInvalid } = useMemo(() => {
142
147
  if (!value)
143
148
  return { displayValue: '', isInvalid: false };
144
149
  if (!isValid(value))
145
150
  return { displayValue: '', isInvalid: true };
146
151
  try {
147
- return { displayValue: dateFnsFormat(value, fieldFormat ?? 'P'), isInvalid: false };
152
+ return {
153
+ displayValue: adapter.formatByString(value, fieldFormat ?? adapter.formats.keyboardDate),
154
+ isInvalid: false,
155
+ };
148
156
  }
149
157
  catch {
150
158
  return { displayValue: '', isInvalid: true };
151
159
  }
152
- }, [value, fieldFormat]);
160
+ }, [value, fieldFormat, adapter]);
153
161
  const handleClick = () => {
154
162
  if (!disabled && !readOnly) {
155
163
  setOpen((prev) => !prev);
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render } from '@testing-library/react';
3
+ import { afterEach, describe, expect, it, vi } from 'vitest';
4
+ import '@testing-library/jest-dom';
5
+ import MaterialProviders from '../../Utils/MaterialProviders';
6
+ import InternalFormStyle from '../../constants/InternalFormStyle';
7
+ import ErkDatePicker from './ErkDatePicker';
8
+ import ErkDateRangePicker from '../ErkDateRangePicker/ErkDateRangePicker';
9
+ /**
10
+ * The field text used to be built with a bare date-fns `format`, which ignores the
11
+ * LocalizationProvider locale and always printed en-US dates (MM/dd/yyyy).
12
+ */
13
+ const setLanguages = (languages) => {
14
+ vi.spyOn(navigator, 'languages', 'get').mockReturnValue(languages);
15
+ };
16
+ const date = new Date(2026, 2, 9, 14, 5); // 9 de marzo de 2026, 14:05
17
+ describe('date pickers follow the browser locale', () => {
18
+ afterEach(() => vi.restoreAllMocks());
19
+ it('shows dd/MM/yyyy for a Spanish browser', () => {
20
+ setLanguages(['es-CO', 'es']);
21
+ render(_jsx(MaterialProviders, { formStyle: InternalFormStyle, children: _jsx(ErkDatePicker, { label: "Fecha", value: date, onChange: vi.fn() }) }));
22
+ expect(document.querySelector('input')?.value).toBe('09/03/2026');
23
+ });
24
+ it('shows MM/dd/yyyy for a US browser', () => {
25
+ setLanguages(['en-US', 'en']);
26
+ render(_jsx(MaterialProviders, { formStyle: InternalFormStyle, children: _jsx(ErkDatePicker, { label: "Fecha", value: date, onChange: vi.fn() }) }));
27
+ expect(document.querySelector('input')?.value).toBe('03/09/2026');
28
+ });
29
+ it('shows a localized date-time for a Spanish browser', () => {
30
+ setLanguages(['es']);
31
+ render(_jsx(MaterialProviders, { formStyle: InternalFormStyle, children: _jsx(ErkDatePicker, { pickTime: true, label: "Fecha y hora", value: date, onChange: vi.fn() }) }));
32
+ expect(document.querySelector('input')?.value).toMatch(/^09\/03\/2026 02:05 (p\. ?m\.|PM)$/i);
33
+ });
34
+ it('shows a dd/MM/yyyy range for a Spanish browser', () => {
35
+ setLanguages(['es-MX']);
36
+ render(_jsx(MaterialProviders, { formStyle: InternalFormStyle, children: _jsx(ErkDateRangePicker, { label: "Rango", value: [date, new Date(2026, 2, 20)], onChange: vi.fn() }) }));
37
+ expect(document.querySelector('input')?.value).toBe('09/03/2026 – 20/03/2026');
38
+ });
39
+ });
@@ -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;
@@ -1,9 +1,10 @@
1
1
  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
- import { DatePickerToolbar as MuiDatePickerToolbar, usePickerContext, } from '@mui/x-date-pickers';
5
- import { MobileDateRangePicker as MuiDateRangePicker, DateRangePickerDay as MuiDateRangePickerDay, } from '@mui/x-date-pickers-pro';
6
- import { format, isValid } from 'date-fns';
4
+ import { DatePickerToolbar as MuiDatePickerToolbar, usePickerContext, usePickerAdapter, } from '@mui/x-date-pickers';
5
+ import { MobileDateRangePicker as MuiDateRangePicker, } from '@mui/x-date-pickers-pro/MobileDateRangePicker';
6
+ import { DateRangePickerDay as MuiDateRangePickerDay } from '@mui/x-date-pickers-pro';
7
+ import { isValid } from 'date-fns';
7
8
  import { StyledTextField } from '../ErkTextField/ErkTextField';
8
9
  import CalendarIcon from '../../Icons/CalendarIcon';
9
10
  const StyledDateRangePicker = styled(MuiDateRangePicker, {
@@ -85,6 +86,9 @@ const StyledDay = styled(MuiDateRangePickerDay)(({ theme }) => ({
85
86
  }));
86
87
  const CustomRangePickerField = React.forwardRef(function CustomRangePickerField({ error, required, helperText, size = 'small', labelMargin = 5, fullWidth = true, inputRef }, ref) {
87
88
  const { value, fieldFormat, setOpen, disabled, readOnly, label } = usePickerContext();
89
+ // Format through the adapter so the LocalizationProvider locale applies (a bare date-fns
90
+ // `format` always used en-US, so Spanish users saw MM/dd/yyyy).
91
+ const adapter = usePickerAdapter();
88
92
  const { displayValue, isInvalid } = useMemo(() => {
89
93
  const [startDate, endDate] = value ?? [null, null];
90
94
  if (!startDate)
@@ -94,15 +98,15 @@ const CustomRangePickerField = React.forwardRef(function CustomRangePickerField(
94
98
  if (endDate && !isValid(endDate))
95
99
  return { displayValue: '', isInvalid: true };
96
100
  try {
97
- const fmt = fieldFormat ?? 'P';
98
- const start = format(startDate, fmt);
99
- const end = endDate ? format(endDate, fmt) : '';
101
+ const fmt = fieldFormat ?? adapter.formats.keyboardDate;
102
+ const start = adapter.formatByString(startDate, fmt);
103
+ const end = endDate ? adapter.formatByString(endDate, fmt) : '';
100
104
  return { displayValue: end ? `${start} – ${end}` : start, isInvalid: false };
101
105
  }
102
106
  catch {
103
107
  return { displayValue: '', isInvalid: true };
104
108
  }
105
- }, [value, fieldFormat]);
109
+ }, [value, fieldFormat, adapter]);
106
110
  const handleClick = () => {
107
111
  if (!disabled && !readOnly) {
108
112
  setOpen((prev) => !prev);
@@ -118,10 +122,10 @@ const CustomRangePickerField = React.forwardRef(function CustomRangePickerField(
118
122
  },
119
123
  } }));
120
124
  });
121
- const formatDate = (date, showYear) => {
125
+ const formatDate = (adapter, date, showYear) => {
122
126
  if (!date || !isValid(date))
123
127
  return '';
124
- return format(date, showYear ? 'PP' : 'dd MMM');
128
+ return adapter.formatByString(date, showYear ? adapter.formats.fullDate : 'dd MMM');
125
129
  };
126
130
  function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = 'small', labelMargin = 5, value, onChange, inputRef, shortcuts, label, required, ...others }) {
127
131
  // MUI X v9 no longer forwards `required` to the field-slot label when the field is a Material
@@ -129,6 +133,7 @@ function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = '
129
133
  // The picker's `label` does propagate to the field via the picker context, so bake the marker
130
134
  // into the label to keep the required indicator visible.
131
135
  const displayLabel = required && typeof label === 'string' ? `${label} *` : label;
136
+ const adapter = usePickerAdapter();
132
137
  const [startDate, endDate] = value ?? [null, null];
133
138
  const hasCompleteRange = Boolean(startDate) && Boolean(endDate);
134
139
  const showYear = startDate &&
@@ -136,8 +141,8 @@ function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = '
136
141
  isValid(startDate) &&
137
142
  isValid(endDate) &&
138
143
  startDate.getFullYear() !== endDate.getFullYear();
139
- const formattedStartDate = formatDate(startDate, Boolean(showYear));
140
- const formattedEndDate = formatDate(endDate, Boolean(showYear));
144
+ const formattedStartDate = formatDate(adapter, startDate, Boolean(showYear));
145
+ const formattedEndDate = formatDate(adapter, endDate, Boolean(showYear));
141
146
  const toolbarText = hasCompleteRange ? `${formattedStartDate} – ${formattedEndDate}` : '– –';
142
147
  return (_jsx(StyledDateRangePicker, { ...others, label: displayLabel, value: value, onChange: onChange, size: size, disabled: disabled, readOnly: readOnly, reduceAnimations: true, showDaysOutsideCurrentMonth: true, slots: {
143
148
  field: CustomRangePickerField,
@@ -109,7 +109,15 @@ function CustomSelect({ label, error, value, loading, onChange, children, requir
109
109
  setOpen((open) => !open);
110
110
  }
111
111
  }, children: _jsx(IconComponent, { size: size === 'small' ? 22 : 26 }) })) : undefined, onFocus: (e) => {
112
- if (!e.relatedTarget?.closest('.Erk-MuiPaper-root')) {
112
+ // Open only when focus arrives by keyboard from another control. A focus with no
113
+ // relatedTarget is either a mouse press (MUI's own mousedown already opens the menu)
114
+ // or the focus trap handing focus back after the menu closed; opening on that one
115
+ // reopened the menu right after a backdrop click and kept it stuck open.
116
+ const from = e.relatedTarget;
117
+ const cameFromAnotherControl = from !== null &&
118
+ from.closest('.Erk-MuiPaper-root') === null &&
119
+ !e.currentTarget.parentElement?.contains(from);
120
+ if (cameFromAnotherControl) {
113
121
  setOpen(true);
114
122
  }
115
123
  others.onFocus?.(e);
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ import '../../Utils/MuiClassnameSetup';
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { render, screen, fireEvent, act } from '@testing-library/react';
3
+ import { describe, expect, it, vi } from 'vitest';
4
+ import '@testing-library/jest-dom';
5
+ import '../../Utils/MuiClassnameSetup';
6
+ import MaterialProviders from '../../Utils/MaterialProviders';
7
+ import InternalFormStyle from '../../constants/InternalFormStyle';
8
+ import ErkSelect from './ErkSelect';
9
+ import ErkMenuItem from '../ErkMenuItem';
10
+ function renderSelect() {
11
+ render(_jsxs(MaterialProviders, { formStyle: InternalFormStyle, children: [_jsx("input", { "data-testid": "before" }), _jsxs(ErkSelect, { label: "Opci\u00F3n", onChange: vi.fn(), children: [_jsx(ErkMenuItem, { value: "a", children: "A" }), _jsx(ErkMenuItem, { value: "b", children: "B" })] })] }));
12
+ }
13
+ // The inline (disablePortal) menu marks the rest of the tree aria-hidden while open, so the
14
+ // combobox is read from the raw DOM; the paper also stays mounted through its exit transition,
15
+ // so the open state comes from aria-expanded rather than from the listbox being present.
16
+ const combobox = () => document.querySelector('[role=combobox]');
17
+ const isOpen = () => combobox().getAttribute('aria-expanded') === 'true';
18
+ const openSelect = () => {
19
+ fireEvent.mouseDown(combobox());
20
+ };
21
+ const flush = () => act(() => new Promise((resolve) => setTimeout(resolve, 50)));
22
+ describe('ErkSelect open/close', () => {
23
+ it('opens on mouse down', () => {
24
+ renderSelect();
25
+ openSelect();
26
+ expect(isOpen()).toBe(true);
27
+ });
28
+ it('stays closed after clicking the backdrop (does not reopen on focus restore)', async () => {
29
+ renderSelect();
30
+ openSelect();
31
+ const backdrop = document.querySelector('.Erk-MuiBackdrop-root');
32
+ fireEvent.click(backdrop);
33
+ await flush();
34
+ // The focus trap gives focus back to the combobox with no relatedTarget (the mouse left focus on body).
35
+ fireEvent.focus(combobox(), { relatedTarget: null });
36
+ await flush();
37
+ expect(isOpen()).toBe(false);
38
+ });
39
+ it('stays closed after picking an option', async () => {
40
+ renderSelect();
41
+ openSelect();
42
+ fireEvent.click(document.querySelector('[role=option][data-value=b]'));
43
+ await flush();
44
+ expect(isOpen()).toBe(false);
45
+ });
46
+ it('opens when reached by keyboard from another field', () => {
47
+ renderSelect();
48
+ const before = screen.getByTestId('before');
49
+ before.focus();
50
+ fireEvent.focus(combobox(), { relatedTarget: before });
51
+ expect(isOpen()).toBe(true);
52
+ });
53
+ });
@@ -62,7 +62,14 @@ function CustomSelect({ value, onChange, label, error, required, pickDays, helpe
62
62
  if (!readOnly && !disabled)
63
63
  setOpen(!open);
64
64
  }, children: _jsx(ClockIcon, { size: size === 'small' ? 22 : 26 }) }), onFocus: (e) => {
65
- if (!e.relatedTarget?.closest('.Erk-MuiPaper-root') && !readOnly && !disabled) {
65
+ // Same rule as ErkSelect: open only when focus arrives from another control. A focus
66
+ // with no relatedTarget is the hidden menu handing focus back on close, and opening on
67
+ // it reopened the popper right after every click away.
68
+ const from = e.relatedTarget;
69
+ const cameFromAnotherControl = from !== null &&
70
+ from.closest('.Erk-MuiPaper-root') === null &&
71
+ !e.currentTarget.parentElement?.contains(from);
72
+ if (cameFromAnotherControl && !readOnly && !disabled) {
66
73
  setOpen(true);
67
74
  }
68
75
  }, onOpen: () => {
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ import '../../Utils/MuiClassnameSetup';
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { render, fireEvent, act } from '@testing-library/react';
3
+ import { describe, expect, it, vi } from 'vitest';
4
+ import '@testing-library/jest-dom';
5
+ import '../../Utils/MuiClassnameSetup';
6
+ import MaterialProviders from '../../Utils/MaterialProviders';
7
+ import InternalFormStyle from '../../constants/InternalFormStyle';
8
+ import ErkTimePicker from './ErkTimePicker';
9
+ const combobox = () => document.querySelector('[role=combobox]');
10
+ const isOpen = () => combobox().getAttribute('aria-expanded') === 'true';
11
+ const flush = () => act(() => new Promise((resolve) => setTimeout(resolve, 50)));
12
+ describe('ErkTimePicker open/close', () => {
13
+ it('closes on click away and stays closed when focus returns to the trigger', async () => {
14
+ render(_jsxs(MaterialProviders, { formStyle: InternalFormStyle, children: [_jsx("button", { "data-testid": "outside", children: "fuera" }), _jsx(ErkTimePicker, { label: "Tiempo", pickHours: true, pickMinutes: true, onChange: vi.fn() })] }));
15
+ fireEvent.mouseDown(combobox());
16
+ await flush();
17
+ expect(isOpen()).toBe(true);
18
+ fireEvent.mouseDown(document.querySelector('[data-testid=outside]'));
19
+ await flush();
20
+ fireEvent.focus(combobox(), { relatedTarget: null });
21
+ await flush();
22
+ expect(isOpen()).toBe(false);
23
+ });
24
+ });
@@ -1,15 +1,7 @@
1
1
  import axios from 'axios';
2
2
  const headers = {};
3
- /**
4
- * Embedded mode calls the API by absolute URL, because the form runs inside a page that is not ours.
5
- * Against local lambdas there is no such host: the dev server proxies `/api`, so the request has to come
6
- * back through it — same-origin, with no CORS allowlist to satisfy.
7
- */
8
- const baseURL = import.meta.env.VITE_LOCAL_LAMBDAS
9
- ? '/api'
10
- : `https://api.forms.${import.meta.env.VITE_REACT_APP_DOMAIN}/api`;
11
3
  const widgetInstance = axios.create({
12
- baseURL,
4
+ baseURL: `https://api.forms.${import.meta.env.VITE_REACT_APP_DOMAIN}/api`,
13
5
  timeout: 30000,
14
6
  headers,
15
7
  });
@@ -1,2 +1,3 @@
1
1
  import { Locale } from 'date-fns';
2
+ /** date-fns locale for the browser language: exact tag first, then its base language (es-CO → es), else Spanish. */
2
3
  export declare const getLocale: () => Locale;
@@ -1,12 +1,19 @@
1
1
  import { enUS } from 'date-fns/locale/en-US';
2
+ import { enGB } from 'date-fns/locale/en-GB';
2
3
  import { es } from 'date-fns/locale/es';
3
4
  const localeMap = {
4
5
  en: enUS,
5
6
  'en-US': enUS,
7
+ 'en-GB': enGB,
6
8
  es,
7
9
  };
10
+ const browserLanguage = () => navigator.languages?.length
11
+ ? navigator.languages[0]
12
+ : (navigator.userLanguage ?? navigator.language ?? navigator.browserLanguage);
13
+ /** date-fns locale for the browser language: exact tag first, then its base language (es-CO → es), else Spanish. */
8
14
  export const getLocale = () => {
9
- return (localeMap[navigator.languages?.length
10
- ? navigator.languages[0]
11
- : (navigator.userLanguage ?? navigator.language ?? navigator.browserLanguage)] ?? localeMap.es);
15
+ const language = browserLanguage();
16
+ if (!language)
17
+ return es;
18
+ return localeMap[language] ?? localeMap[language.split('-')[0]] ?? es;
12
19
  };
@@ -21,11 +21,7 @@ export declare enum FormStepTypes {
21
21
  COLLAPSIBLE = "COLLAPSIBLE",
22
22
  MAPPER = "MAPPER",
23
23
  ENTITYVALUEPICKER = "ENTITYVALUEPICKER",
24
- API_SELECTOR = "API_SELECTOR",
25
- LOCATION = "LOCATION",
26
- NUMBER = "NUMBER",
27
- AVAILABILITY = "AVAILABILITY",
28
- BOOKING = "BOOKING"
24
+ API_SELECTOR = "API_SELECTOR"
29
25
  }
30
26
  export declare enum OptionTypes {
31
27
  DEFAULT = "DEFAULT",
@@ -25,10 +25,6 @@ export var FormStepTypes;
25
25
  FormStepTypes["MAPPER"] = "MAPPER";
26
26
  FormStepTypes["ENTITYVALUEPICKER"] = "ENTITYVALUEPICKER";
27
27
  FormStepTypes["API_SELECTOR"] = "API_SELECTOR";
28
- FormStepTypes["LOCATION"] = "LOCATION";
29
- FormStepTypes["NUMBER"] = "NUMBER";
30
- FormStepTypes["AVAILABILITY"] = "AVAILABILITY";
31
- FormStepTypes["BOOKING"] = "BOOKING";
32
28
  })(FormStepTypes || (FormStepTypes = {}));
33
29
  export var OptionTypes;
34
30
  (function (OptionTypes) {
@@ -1,8 +1,6 @@
1
1
  import EurekaForm, { AppProps as EurekaFormProps } from './App/App';
2
2
  import { StepProps } from './FormSteps/Step';
3
3
  import * as StepFunctions from './FormSteps/StepFunctions';
4
- import ErkBookingPicker, { ErkBookingPickerProps } from './Shared/ErkBookingPicker/ErkBookingPicker';
5
- import ErkAvailabilityPicker, { ErkAvailabilityPickerProps } from './Shared/ErkAvailabilityPicker/ErkAvailabilityPicker';
6
- export type { StepProps, EurekaFormProps, ErkBookingPickerProps, ErkAvailabilityPickerProps };
7
- export { EurekaForm, StepFunctions, ErkBookingPicker, ErkAvailabilityPicker };
4
+ export type { StepProps, EurekaFormProps };
5
+ export { EurekaForm, StepFunctions };
8
6
  export default EurekaForm;
package/dist/index.lib.js CHANGED
@@ -1,6 +1,4 @@
1
1
  import EurekaForm from './App/App';
2
2
  import * as StepFunctions from './FormSteps/StepFunctions';
3
- import ErkBookingPicker from './Shared/ErkBookingPicker/ErkBookingPicker';
4
- import ErkAvailabilityPicker from './Shared/ErkAvailabilityPicker/ErkAvailabilityPicker';
5
- export { EurekaForm, StepFunctions, ErkBookingPicker, ErkAvailabilityPicker };
3
+ export { EurekaForm, StepFunctions };
6
4
  export default EurekaForm;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arquimedes.co/eureka-forms",
3
3
  "repository": "git://github.com/Arquimede5/Eureka-Forms.git",
4
- "version": "3.0.66",
4
+ "version":"3.0.68-test",
5
5
  "scripts": {
6
6
  "watch": "node node_modules/@typescript/native/bin/tsc --noEmit --watch --project tsconfig.app.json",
7
7
  "start": "vite",
@@ -17,7 +17,6 @@
17
17
  "format:check": "oxfmt --check ./src"
18
18
  },
19
19
  "dependencies": {
20
- "@base-ui/react": "^1.6.0",
21
20
  "@reduxjs/toolkit": "2.11.2",
22
21
  "axios": "1.16.0",
23
22
  "date-fns": "4.1.0",