@arquimedes.co/eureka-forms 3.0.57-new-steps → 3.0.57

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 (120) hide show
  1. package/dist/@Types/FormStep.d.ts +2 -7
  2. package/dist/@Types/FormStep.js +1 -2
  3. package/dist/@Types/GenericFormSteps.d.ts +7 -0
  4. package/dist/App/App.cbr.test.js +78 -0
  5. package/dist/App/App.d.ts +6 -1
  6. package/dist/App/AppHooks.js +2 -2
  7. package/dist/FormSteps/CheckBoxStep/CheckBoxStep.mobileLabel.test.js +123 -0
  8. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +34 -7
  9. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +30 -0
  10. package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.js +1 -1
  11. package/dist/FormSteps/PhoneInputStep/MaterialTextInputStep/MaterialPhoneInputStep.js +5 -4
  12. package/dist/FormSteps/Step.js +4 -19
  13. package/dist/FormSteps/StepFunctions.d.ts +16 -1
  14. package/dist/FormSteps/StepFunctions.js +58 -14
  15. package/dist/FormSteps/StepFunctions.test.js +32 -55
  16. package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +5 -4
  17. package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +4 -4
  18. package/dist/FormSteps/Utils/@StepFiller/StepFiller.js +5 -4
  19. package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.js +5 -4
  20. package/dist/Shared/ErkDatePicker/ErkDatePicker.js +7 -5
  21. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +3 -2
  22. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +5 -4
  23. package/dist/Utils/CBRFunctions.js +4 -2
  24. package/dist/Utils/CBRFunctions.test.d.ts +1 -0
  25. package/dist/Utils/CBRFunctions.test.js +123 -0
  26. package/dist/Utils/MaterialProviders.js +6 -0
  27. package/dist/constants/FormStepTypes.d.ts +1 -5
  28. package/dist/constants/FormStepTypes.js +0 -4
  29. package/dist/hooks.d.ts +1 -0
  30. package/dist/hooks.js +1 -0
  31. package/dist/index.lib.d.ts +2 -4
  32. package/dist/index.lib.js +1 -3
  33. package/package.json +7 -8
  34. package/dist/@Types/AvailabilityFormStep.d.ts +0 -48
  35. package/dist/@Types/AvailabilityFormStep.js +0 -24
  36. package/dist/@Types/BankAccountFormStep.d.ts +0 -67
  37. package/dist/@Types/BankAccountFormStep.js +0 -14
  38. package/dist/@Types/BookingFormStep.d.ts +0 -166
  39. package/dist/@Types/BookingFormStep.js +0 -44
  40. package/dist/@Types/CalendarFormStep.d.ts +0 -209
  41. package/dist/@Types/CalendarFormStep.js +0 -55
  42. package/dist/@Types/CommunicationChannelFormStep.d.ts +0 -51
  43. package/dist/@Types/CommunicationChannelFormStep.js +0 -15
  44. package/dist/@Types/ConsentFormStep.d.ts +0 -36
  45. package/dist/@Types/ConsentFormStep.js +0 -8
  46. package/dist/@Types/EntityFormFormStep.d.ts +0 -66
  47. package/dist/@Types/EntityFormFormStep.js +0 -20
  48. package/dist/@Types/EventFormStep.d.ts +0 -52
  49. package/dist/@Types/EventFormStep.js +0 -13
  50. package/dist/@Types/ExternalReferenceFormStep.d.ts +0 -74
  51. package/dist/@Types/ExternalReferenceFormStep.js +0 -20
  52. package/dist/@Types/LocationFormStep.d.ts +0 -159
  53. package/dist/@Types/LocationFormStep.js +0 -46
  54. package/dist/@Types/NumericFormSteps.d.ts +0 -108
  55. package/dist/@Types/NumericFormSteps.js +0 -20
  56. package/dist/@Types/PredefinedSelectorFormStep.d.ts +0 -51
  57. package/dist/@Types/PredefinedSelectorFormStep.js +0 -39
  58. package/dist/@Types/StepRef.d.ts +0 -135
  59. package/dist/@Types/StepRef.js +0 -49
  60. package/dist/FormSteps/AvailabilityStep/AvailabilityStep.d.ts +0 -7
  61. package/dist/FormSteps/AvailabilityStep/AvailabilityStep.js +0 -14
  62. package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.d.ts +0 -8
  63. package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.js +0 -32
  64. package/dist/FormSteps/BookingStep/BookingStep.d.ts +0 -17
  65. package/dist/FormSteps/BookingStep/BookingStep.js +0 -14
  66. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.d.ts +0 -7
  67. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +0 -32
  68. package/dist/FormSteps/LocationStep/LocationStep.d.ts +0 -10
  69. package/dist/FormSteps/LocationStep/LocationStep.js +0 -14
  70. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.d.ts +0 -3
  71. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.js +0 -54
  72. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.module.css +0 -18
  73. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.d.ts +0 -3
  74. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.js +0 -168
  75. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +0 -94
  76. package/dist/FormSteps/NumberStep/NumberStep.d.ts +0 -10
  77. package/dist/FormSteps/NumberStep/NumberStep.js +0 -14
  78. package/dist/Icons/AddIcon.d.ts +0 -3
  79. package/dist/Icons/AddIcon.js +0 -7
  80. package/dist/Icons/EditIcon.d.ts +0 -3
  81. package/dist/Icons/EditIcon.js +0 -7
  82. package/dist/Icons/RemoveIcon.d.ts +0 -3
  83. package/dist/Icons/RemoveIcon.js +0 -7
  84. package/dist/Icons/ViewDayIcon.d.ts +0 -3
  85. package/dist/Icons/ViewDayIcon.js +0 -7
  86. package/dist/Icons/ViewWeekIcon.d.ts +0 -3
  87. package/dist/Icons/ViewWeekIcon.js +0 -7
  88. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.d.ts +0 -19
  89. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.js +0 -80
  90. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.module.css +0 -82
  91. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +0 -29
  92. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +0 -139
  93. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.d.ts +0 -25
  94. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.js +0 -112
  95. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.module.css +0 -88
  96. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.js +0 -75
  97. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.d.ts +0 -31
  98. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.js +0 -223
  99. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.module.css +0 -608
  100. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.d.ts +0 -28
  101. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.js +0 -117
  102. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.js +0 -49
  103. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.d.ts +0 -1
  104. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.js +0 -107
  105. package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +0 -24
  106. package/dist/Shared/ErkLocationField/ErkLocationField.js +0 -125
  107. package/dist/Shared/ErkLocationField/ErkLocationField.module.css +0 -153
  108. package/dist/Shared/ErkLocationField/ErkLocationField.test.d.ts +0 -1
  109. package/dist/Shared/ErkLocationField/ErkLocationField.test.js +0 -82
  110. package/dist/Shared/ErkLocationField/addressFields.d.ts +0 -12
  111. package/dist/Shared/ErkLocationField/addressFields.js +0 -34
  112. package/dist/Shared/ErkLocationField/locationRestrictions.d.ts +0 -6
  113. package/dist/Shared/ErkLocationField/locationRestrictions.js +0 -51
  114. package/dist/Shared/ErkLocationInput/ErkLocationInput.d.ts +0 -15
  115. package/dist/Shared/ErkLocationInput/ErkLocationInput.js +0 -502
  116. package/dist/Shared/ErkLocationInput/ErkLocationInput.module.css +0 -115
  117. package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +0 -42
  118. package/dist/Shared/ErkNumberField/ErkNumberField.js +0 -170
  119. /package/dist/{Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.d.ts → App/App.cbr.test.d.ts} +0 -0
  120. /package/dist/{Shared/ErkBookingPicker/ErkBookingPicker.stories.test.d.ts → FormSteps/CheckBoxStep/CheckBoxStep.mobileLabel.test.d.ts} +0 -0
@@ -1,9 +1,8 @@
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';
5
4
  import { describe, expect, test, vi } from 'vitest';
6
- import { calcDefaultValue, calcFillerSize, calcStepWidth, calcSubSteps, iterateNestedSteps } from './StepFunctions';
5
+ import { calcDefaultValue, calcFillerSize, calcStepWidth, calcSubSteps, iterateNestedSteps, resolveStepSpan, } from './StepFunctions';
7
6
  import { stringToDraft } from '../Utils/DraftFunctions';
8
7
  describe('StepFunctions', function () {
9
8
  describe('calcFillerSize', function () {
@@ -412,6 +411,37 @@ describe('StepFunctions', function () {
412
411
  expect(size).toBe(440);
413
412
  });
414
413
  });
414
+ describe('resolveStepSpan', function () {
415
+ const fourColumns = { blockNum: 4, blockSize: 210, spacingSize: 20 };
416
+ const desktop = { currentBreakPoint: 4, isMobile: false };
417
+ const threeColumns = { currentBreakPoint: 3, isMobile: false };
418
+ const tablet = { currentBreakPoint: 2, isMobile: false };
419
+ const mobile = { currentBreakPoint: 1, isMobile: true };
420
+ test('Legacy step derives every screen from the scalar size', async () => {
421
+ const step = { size: 3 };
422
+ expect(resolveStepSpan(step, desktop, fourColumns)).toBe(3);
423
+ expect(resolveStepSpan(step, tablet, fourColumns)).toBe(2);
424
+ expect(resolveStepSpan(step, mobile, fourColumns)).toBe(1);
425
+ });
426
+ test('Step without size falls back to full width', async () => {
427
+ expect(resolveStepSpan({}, desktop, fourColumns)).toBe(4);
428
+ expect(resolveStepSpan({}, tablet, fourColumns)).toBe(2);
429
+ });
430
+ test('Tablet override applies once at most 2 columns fit', async () => {
431
+ const step = { size: 2, sizes: { tablet: 1 } };
432
+ expect(resolveStepSpan(step, tablet, fourColumns)).toBe(1);
433
+ expect(resolveStepSpan(step, desktop, fourColumns)).toBe(2);
434
+ });
435
+ test('Reduced-but-wider states keep the desktop span', async () => {
436
+ const step = { size: 3, sizes: { tablet: 1 } };
437
+ expect(resolveStepSpan(step, threeColumns, fourColumns)).toBe(3);
438
+ });
439
+ test('Overrides are clamped to the columns of their screen', async () => {
440
+ const step = { size: 1, sizes: { tablet: 4, mobile: 3 } };
441
+ expect(resolveStepSpan(step, tablet, fourColumns)).toBe(2);
442
+ expect(resolveStepSpan(step, mobile, fourColumns)).toBe(1);
443
+ });
444
+ });
415
445
  describe('calcDefaultValue', function () {
416
446
  test('CheckBox', async () => {
417
447
  const defaultValue = calcDefaultValue({
@@ -497,13 +527,6 @@ describe('StepFunctions', function () {
497
527
  const defaultValue = calcDefaultValue(step);
498
528
  expect(defaultValue).toBe(null);
499
529
  });
500
- test('Location step type', async () => {
501
- const step = {
502
- type: FormStepTypes.LOCATION,
503
- };
504
- const defaultValue = calcDefaultValue(step);
505
- expect(defaultValue).toBe(null);
506
- });
507
530
  test('Mapper, FileUpload, CBRFormStep types', async () => {
508
531
  const step1 = {
509
532
  type: FormStepTypes.MAPPER,
@@ -535,52 +558,6 @@ describe('StepFunctions', function () {
535
558
  const defaultValue = calcDefaultValue(step);
536
559
  expect(defaultValue).toBeUndefined();
537
560
  });
538
- test('Number step type without defaultValue', async () => {
539
- const step1 = {
540
- type: FormStepTypes.NUMBER,
541
- numberType: Steps.NumberStepType.INTEGER,
542
- };
543
- const step2 = {
544
- type: FormStepTypes.NUMBER,
545
- numberType: Steps.NumberStepType.DECIMAL,
546
- };
547
- const step3 = {
548
- type: FormStepTypes.NUMBER,
549
- numberType: Steps.NumberStepType.PERCENTAGE,
550
- };
551
- const step4 = {
552
- type: FormStepTypes.NUMBER,
553
- numberType: Steps.NumberStepType.MONEY,
554
- };
555
- const step5 = {
556
- type: FormStepTypes.NUMBER,
557
- numberType: Steps.NumberStepType.MEASURE,
558
- };
559
- const step6 = {
560
- type: FormStepTypes.NUMBER,
561
- numberType: Steps.NumberStepType.UNIT_PRICE,
562
- };
563
- expect(calcDefaultValue(step1)).toBe('');
564
- expect(calcDefaultValue(step2)).toBe('');
565
- expect(calcDefaultValue(step3)).toBe('');
566
- expect(calcDefaultValue(step4)).toBe(null);
567
- expect(calcDefaultValue(step5)).toBe(null);
568
- expect(calcDefaultValue(step6)).toBe(null);
569
- });
570
- test('Number step type with defaultValue', async () => {
571
- const step1 = {
572
- type: FormStepTypes.NUMBER,
573
- numberType: Steps.NumberStepType.INTEGER,
574
- defaultValue: 42,
575
- };
576
- const step2 = {
577
- type: FormStepTypes.NUMBER,
578
- numberType: Steps.NumberStepType.MONEY,
579
- defaultValue: { value: 100, currency: 'USD' },
580
- };
581
- expect(calcDefaultValue(step1)).toBe(42);
582
- expect(calcDefaultValue(step2)).toEqual({ value: 100, currency: 'USD' });
583
- });
584
561
  });
585
562
  describe('iterateNestedSteps', function () {
586
563
  test('should iterate over nested steps', async () => {
@@ -1,15 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import ErkTextField from '../../../Shared/ErkTextField/ErkTextField';
3
3
  import styles from './MaterialTextInputStep.module.css';
4
- import { calcStepWidth } from '../../StepFunctions';
4
+ import { calcStepWidth, resolveStepSpan } from '../../StepFunctions';
5
5
  import { useContext } from 'react';
6
6
  import FormContext from '../../../Contexts/FormContext';
7
- import { selectBreakPoint, useAppSelector } from '../../../hooks';
7
+ import { selectWidthStats, useAppSelector } from '../../../hooks';
8
8
  import { useFormStep } from '../../StepHooks';
9
9
  function TextInputStep({ step, editable, maxLength, IconComponent, defaultValue = step.defaultValue, validation = step.validation, }) {
10
- const currentBreakPoint = useAppSelector(selectBreakPoint);
10
+ const widthStats = useAppSelector(selectWidthStats);
11
11
  const { postview } = useAppSelector((state) => state.global);
12
12
  const form = useContext(FormContext);
13
+ const span = resolveStepSpan(step, widthStats, form.size);
13
14
  const { ref, value, onChange, error, field } = useFormStep(step, {
14
15
  defaultValue: defaultValue ?? '',
15
16
  debounce: true,
@@ -27,7 +28,7 @@ function TextInputStep({ step, editable, maxLength, IconComponent, defaultValue
27
28
  },
28
29
  });
29
30
  return (_jsx("div", { className: styles.container, style: {
30
- width: currentBreakPoint <= step.size ? '100%' : calcStepWidth(step.size, form.size),
31
+ width: widthStats.currentBreakPoint <= span ? '100%' : calcStepWidth(span, form.size),
31
32
  minHeight: step.description || (!postview && editable && (step.required || validation)) ? '55px' : '43px',
32
33
  }, children: _jsx(ErkTextField, { ...field, value: value, inputRef: ref, labelMargin: 0, error: !!error, label: step.label, onChange: onChange, maxLength: maxLength, "data-testid": step.id, required: step.required, readOnly: !editable || postview, helperText: error?.message ?? step.description, IconComponent: step.showIcon ? IconComponent : undefined }) }));
33
34
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { calcStepWidth } from '../../StepFunctions';
2
+ import { calcStepWidth, resolveStepSpan } from '../../StepFunctions';
3
3
  import styles from './MaterialTitleStep.module.css';
4
4
  import { useAppSelector } from '../../../hooks';
5
5
  import FormContext from '../../../Contexts/FormContext';
@@ -16,7 +16,7 @@ function TitleStep({ step }) {
16
16
  const { formStyle } = useAppSelector((state) => state.global);
17
17
  const form = useContext(FormContext);
18
18
  const widthStats = useAppSelector((state) => state.widthStats);
19
- const size = step.size ?? form.size.blockNum;
19
+ const span = resolveStepSpan(step, widthStats, form.size);
20
20
  const title = useMemo(() => calcBaseDraft(value?.title ?? step.title), //Usa por defecto lo que venga en el value, pero no escucha cambios
21
21
  [step.title, value?.title]);
22
22
  const sourceTitle = useMemo(() => calcBaseDraft(step.title), [step.title]);
@@ -36,9 +36,9 @@ function TitleStep({ step }) {
36
36
  const path = useMemo(() => [...step.stepPath, step.id].join('.'), [step.stepPath, step.id]);
37
37
  return (_jsxs("div", { className: styles.container, style: {
38
38
  color: formStyle.textColor,
39
- width: widthStats.currentBreakPoint <= size ? '100%' : calcStepWidth(size, form.size),
39
+ width: widthStats.currentBreakPoint <= span ? '100%' : calcStepWidth(span, form.size),
40
40
  }, children: [_jsx("div", { className: styles.titleLbl, style: {
41
- textAlign: widthStats.isMobile && widthStats.currentBreakPoint <= size ? 'center' : 'start',
41
+ textAlign: widthStats.isMobile && widthStats.currentBreakPoint <= span ? 'center' : 'start',
42
42
  }, children: _jsx(SmartDraftRenderer, { draft: title, sourceDraft: sourceTitle, dependencies: values, property: `${path}.title`, onChange: (title) => onChange({ ...value, title }) }) }), _jsx("div", { className: styles.descriptionPar, children: _jsx(SmartDraftRenderer, { draft: description, sourceDraft: sourceDescription, dependencies: values, margin: title ? '10px 0px' : '0px 0px 5px 0px', property: `${path}.description`, onChange: (description) => onChange({ ...value, description }) }) })] }));
43
43
  }
44
44
  export default TitleStep;
@@ -1,23 +1,24 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useCallback, useContext, useState } from 'react';
3
3
  import { useFormContext } from 'react-hook-form';
4
- import { calcFillerSize } from '../../StepFunctions';
4
+ import { calcFillerSize, resolveStepSpan } from '../../StepFunctions';
5
5
  import FormContext from '../../../Contexts/FormContext';
6
6
  import styles from './StepFiller.module.css';
7
- import { selectBreakPoint, useAppSelector } from '../../../hooks';
7
+ import { selectWidthStats, useAppSelector } from '../../../hooks';
8
8
  import { SizeChangeContext } from './StepFillerContext';
9
9
  function StepFiller({ step, children }) {
10
10
  const { getValues } = useFormContext();
11
11
  const form = useContext(FormContext);
12
12
  const [fillerSize, setFillerSize] = useState(calcFillerSize(step, form.steps, getValues(), form.size));
13
- const currentBreakPoint = useAppSelector(selectBreakPoint);
13
+ const widthStats = useAppSelector(selectWidthStats);
14
+ const span = resolveStepSpan(step, widthStats, form.size);
14
15
  const handleSizeChange = useCallback(() => {
15
16
  setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
16
17
  // eslint-disable-next-line react-hooks/exhaustive-deps
17
18
  }, []);
18
19
  if (step.maxSize && step.maxSize < form.size.blockNum) {
19
20
  return (_jsxs("div", { className: styles.firstLvlContainer, style: {
20
- width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
21
+ width: widthStats.currentBreakPoint <= span ? '100%' : 'fit-content',
21
22
  }, children: [_jsx(SizeChangeContext.Provider, { value: handleSizeChange, children: children }), fillerSize > 0 && (_jsx("div", { className: styles.smallSeparator, style: {
22
23
  width: fillerSize,
23
24
  } }))] }));
@@ -1,15 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useContext } from 'react';
3
3
  import FormContext from '../../../Contexts/FormContext';
4
- import { useAppSelector, selectBreakPoint } from '../../../hooks';
5
- import { calcStepWidth } from '../../StepFunctions';
4
+ import { useAppSelector, selectWidthStats } from '../../../hooks';
5
+ import { calcStepWidth, resolveStepSpan } from '../../StepFunctions';
6
6
  import styles from './MaterialInputContainer.module.css';
7
7
  function MaterialInputContainer({ step, editable, children, onClick, maxHeight = true, }) {
8
8
  const form = useContext(FormContext);
9
- const currentBreakPoint = useAppSelector(selectBreakPoint);
9
+ const widthStats = useAppSelector(selectWidthStats);
10
10
  const postview = useAppSelector((state) => state.global.postview);
11
+ const span = resolveStepSpan(step, widthStats, form.size);
11
12
  return (_jsx("div", { className: styles.container, style: {
12
- width: currentBreakPoint <= step.size ? '100%' : calcStepWidth(step.size, form.size),
13
+ width: widthStats.currentBreakPoint <= span ? '100%' : calcStepWidth(span, form.size),
13
14
  minHeight: maxHeight
14
15
  ? step.description || (!postview && editable && step.required)
15
16
  ? '55px'
@@ -2,9 +2,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React, { useMemo } from 'react';
3
3
  import { format as dateFnsFormat, 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, } 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 }) => ({
@@ -126,10 +128,10 @@ const StyledDay = styled(MuiPickerDay)(({ theme }) => ({
126
128
  fontWeight: 500,
127
129
  fontSize: '0.9rem',
128
130
  lineHeight: 'normal',
129
- '&.Erk-MuiPickersDay-today': {
131
+ '&.Erk-MuiPickerDay-today': {
130
132
  backgroundColor: theme.palette.primary.main + '33',
131
133
  },
132
- '&.Erk-MuiPickersDay-dayOutsideMonth': {
134
+ '&.Erk-MuiPickerDay-dayOutsideMonth': {
133
135
  color: 'rgb(0,0,0,0.4)',
134
136
  '&.Mui-selected': {
135
137
  color: theme.palette.primary.contrastText,
@@ -169,7 +171,7 @@ function CustomDatePicker({ error, required, disabled, readOnly, helperText, siz
169
171
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
170
172
  orientation: _orientation, ...others }) {
171
173
  if (pickTime) {
172
- return (_jsx(StyledDateTimePicker, { ampm: true, size: size, reduceAnimations: true, ...others, label: label, disabled: disabled, readOnly: readOnly, showDaysOutsideCurrentMonth: true, slotProps: {
174
+ return (_jsx(StyledDateTimePicker, { ampm: true, size: size, reduceAnimations: true, orientation: "portrait", ...others, label: label, disabled: disabled, readOnly: readOnly, showDaysOutsideCurrentMonth: true, slotProps: {
173
175
  actionBar: {
174
176
  actions: ['clear', 'accept'],
175
177
  },
@@ -229,7 +231,7 @@ orientation: _orientation, ...others }) {
229
231
  } }));
230
232
  }
231
233
  else {
232
- return (_jsx(StyledDatePicker, { ...others, label: label, size: size, reduceAnimations: true, readOnly: readOnly, disabled: disabled, showDaysOutsideCurrentMonth: true, views: ['year', 'month', 'day'], slotProps: {
234
+ return (_jsx(StyledDatePicker, { ...others, label: label, size: size, reduceAnimations: true, orientation: "portrait", readOnly: readOnly, disabled: disabled, showDaysOutsideCurrentMonth: true, views: ['year', 'month', 'day'], slotProps: {
233
235
  actionBar: {
234
236
  actions: ['clear', 'accept'],
235
237
  },
@@ -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, } 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 { format, isValid } from 'date-fns';
7
8
  import { StyledTextField } from '../ErkTextField/ErkTextField';
8
9
  import CalendarIcon from '../../Icons/CalendarIcon';
@@ -70,10 +71,10 @@ const StyledDay = styled(MuiDateRangePickerDay)(({ theme }) => ({
70
71
  fontWeight: 500,
71
72
  fontSize: '0.9rem',
72
73
  lineHeight: 'normal',
73
- '&.Erk-MuiPickersDay-today:not(.Erk-MuiDateRangePickerDay-rangeIntervalDayHighlight)': {
74
+ '&.Erk-MuiDateRangePickerDay-today:not(.Erk-MuiDateRangePickerDay-rangeIntervalDayHighlight)': {
74
75
  backgroundColor: theme.palette.primary.main + '33',
75
76
  },
76
- '&.Erk-MuiPickersDay-dayOutsideMonth': {
77
+ '&.Erk-MuiDateRangePickerDay-dayOutsideMonth': {
77
78
  color: 'rgb(0,0,0,0.4)',
78
79
  '&.Mui-selected': {
79
80
  color: theme.palette.primary.contrastText,
@@ -83,7 +84,7 @@ const StyledDay = styled(MuiDateRangePickerDay)(({ theme }) => ({
83
84
  backgroundColor: theme.palette.primary.main + '1a',
84
85
  },
85
86
  }));
86
- const CustomRangePickerField = React.forwardRef(function CustomRangePickerField({ error, required, helperText, size = 'small', labelMargin = 5, fullWidth = true, inputRef, }, ref) {
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();
88
89
  const { displayValue, isInvalid } = useMemo(() => {
89
90
  const [startDate, endDate] = value ?? [null, null];
@@ -1,17 +1,19 @@
1
1
  import CBRFormStepTypes from '../constants/CBRFormStepTypes';
2
2
  export const calcCbrForm = (form, formValues) => {
3
+ /** Callers pass the form straight out of `createNextState`, whose result Immer deep-freezes. */
4
+ const steps = { ...form.steps };
3
5
  for (const step of Object.values(form.steps)) {
4
6
  if (step.type === CBRFormStepTypes.CBR_INCIDENCIAS) {
5
7
  const incidentStep = step;
6
8
  const incValue = formValues[incidentStep.id ?? ''];
7
9
  if (incValue) {
8
10
  for (const incident of incValue) {
9
- handleAddIncident(incident, incidentStep, form.steps, formValues);
11
+ handleAddIncident(incident, incidentStep, steps, formValues);
10
12
  }
11
13
  }
12
14
  }
13
15
  }
14
- return form;
16
+ return { ...form, steps };
15
17
  };
16
18
  const handleAddIncident = (incident, step, steps, formValues) => {
17
19
  const spaceStep = {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,123 @@
1
+ import { createNextState } from '@reduxjs/toolkit';
2
+ import { describe, expect, test } from 'vitest';
3
+ import CBRFormStepTypes from '../constants/CBRFormStepTypes';
4
+ import { calcCbrForm } from './CBRFunctions';
5
+ const INCIDENT = {
6
+ idSpaceStep: 'CBR_TIPO_ESPACIO-space1',
7
+ idElementStep: 'CBR_LOCATIVAS-element1',
8
+ idCommentStep: 'CBR_COMENTARIO-comment1',
9
+ num: 1,
10
+ };
11
+ /** Second element level, reached through the element value's `subStep` pointer. */
12
+ const ID_SUB_ELEMENT_STEP = 'CBR_LOCATIVAS-subElement1';
13
+ const FORM_VALUES = {
14
+ CBR_INCIDENCIAS: [INCIDENT],
15
+ [INCIDENT.idSpaceStep]: { id: '35362', label: 'Sala' },
16
+ [INCIDENT.idCommentStep]: 'GRAN HUMEDAD',
17
+ [INCIDENT.idElementStep]: {
18
+ id: '06',
19
+ label: 'CIELOS',
20
+ subStep: ID_SUB_ELEMENT_STEP,
21
+ },
22
+ [ID_SUB_ELEMENT_STEP]: { id: '0601', label: 'Cielo Falso' },
23
+ };
24
+ function buildForm() {
25
+ return {
26
+ name: 'Formulario PosVenta',
27
+ firstSection: 'FIRST',
28
+ sections: {
29
+ FIRST: {
30
+ id: 'FIRST',
31
+ name: '',
32
+ nextSection: null,
33
+ steps: ['CBR_INCIDENCIAS'],
34
+ },
35
+ },
36
+ steps: {
37
+ CBR_INCIDENCIAS: {
38
+ id: 'CBR_INCIDENCIAS',
39
+ type: CBRFormStepTypes.CBR_INCIDENCIAS,
40
+ label: 'Incidencias',
41
+ description: null,
42
+ addBtnLabel: 'Agregar',
43
+ required: true,
44
+ unitLabel: 'Incidencia',
45
+ dependencies: ['CBR_PROYECTO'],
46
+ spaceStep: {
47
+ label: 'Espacio',
48
+ description: null,
49
+ size: 1,
50
+ required: true,
51
+ showIcon: true,
52
+ searchable: true,
53
+ },
54
+ commentStep: {
55
+ label: 'Comentario',
56
+ description: null,
57
+ size: 1,
58
+ required: true,
59
+ },
60
+ elementStep: {
61
+ label: 'Elemento',
62
+ description: null,
63
+ size: 1,
64
+ required: true,
65
+ showIcon: true,
66
+ searchable: true,
67
+ subStep: {
68
+ label: 'Elemento Hijo',
69
+ description: null,
70
+ size: 1,
71
+ required: true,
72
+ showIcon: true,
73
+ searchable: true,
74
+ },
75
+ },
76
+ },
77
+ },
78
+ size: { blockNum: 4, blockSize: 210, spacingSize: 20 },
79
+ };
80
+ }
81
+ describe('calcCbrForm', function () {
82
+ test('expands every incident into its own space, comment and element steps', () => {
83
+ const result = calcCbrForm(buildForm(), FORM_VALUES);
84
+ expect(result.steps[INCIDENT.idSpaceStep]).toMatchObject({
85
+ id: INCIDENT.idSpaceStep,
86
+ type: CBRFormStepTypes.CBR_TIPO_ESPACIO,
87
+ });
88
+ expect(result.steps[INCIDENT.idCommentStep]).toMatchObject({
89
+ id: INCIDENT.idCommentStep,
90
+ type: CBRFormStepTypes.CBR_COMENTARIO,
91
+ });
92
+ expect(result.steps[INCIDENT.idElementStep]).toMatchObject({
93
+ id: INCIDENT.idElementStep,
94
+ type: CBRFormStepTypes.CBR_LOCATIVAS,
95
+ subStep: ID_SUB_ELEMENT_STEP,
96
+ });
97
+ expect(result.steps[ID_SUB_ELEMENT_STEP]).toMatchObject({
98
+ id: ID_SUB_ELEMENT_STEP,
99
+ type: CBRFormStepTypes.CBR_LOCATIVAS,
100
+ });
101
+ });
102
+ test('leaves the form it was given untouched', () => {
103
+ const form = buildForm();
104
+ calcCbrForm(form, FORM_VALUES);
105
+ expect(Object.keys(form.steps)).toEqual(['CBR_INCIDENCIAS']);
106
+ });
107
+ /**
108
+ * The caller hands the form straight out of `createNextState`, whose result Immer deep-freezes, so
109
+ * expanding the incidents by writing into that same `steps` object throws and leaves the form stuck
110
+ * loading forever.
111
+ */
112
+ test('expands a form frozen by createNextState', () => {
113
+ const frozenForm = createNextState(buildForm(), (draft) => {
114
+ draft.steps.CBR_INCIDENCIAS.idSection = 'FIRST';
115
+ });
116
+ expect(Object.isFrozen(frozenForm.steps)).toBe(true);
117
+ const result = calcCbrForm(frozenForm, FORM_VALUES);
118
+ expect(result.steps[INCIDENT.idSpaceStep]).toBeDefined();
119
+ expect(result.steps[INCIDENT.idCommentStep]).toBeDefined();
120
+ expect(result.steps[INCIDENT.idElementStep]).toBeDefined();
121
+ expect(result.steps[ID_SUB_ELEMENT_STEP]).toBeDefined();
122
+ });
123
+ });
@@ -42,6 +42,12 @@ function MaterialProviders({ children, formStyle = InternalFormStyle }) {
42
42
  primary: formStyle.textColor,
43
43
  secondary: formStyle.descriptionTextColor,
44
44
  },
45
+ // Paper follows the form surface so menus, pickers and dialogs match a non-white form
46
+ // (the admin's dark scheme in particular) instead of MUI's default white.
47
+ background: {
48
+ default: formStyle.standAloneBackgroundColor,
49
+ paper: formStyle.backgroundColor,
50
+ },
45
51
  },
46
52
  }, DatePickersEs //Potencialmente cambiar esto dependiendo de la empresa?
47
53
  ), children: _jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, adapterLocale: getLocale(), children: children }) }));
@@ -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) {
package/dist/hooks.d.ts CHANGED
@@ -5,4 +5,5 @@ import { QueryActionCreatorResult, QueryDefinition, ResultTypeFrom } from '@redu
5
5
  export declare const useAppDispatch: () => AppDispatch;
6
6
  export declare const useAppSelector: TypedUseSelectorHook<RootState>;
7
7
  export declare const selectBreakPoint: (state: RootState) => number;
8
+ export declare const selectWidthStats: (state: RootState) => RootState["widthStats"];
8
9
  export declare function useApiSubscribe(): <D extends QueryDefinition<any, any, any, any>>(subscription: ThunkAction<QueryActionCreatorResult<D>, any, any, any>) => Promise<ResultTypeFrom<D> | undefined>;
package/dist/hooks.js CHANGED
@@ -20,6 +20,7 @@ export const useAppSelector = (selector, options) => {
20
20
  return useSelector((state) => selector(state.forms[idForm] ?? defaultRootState), options);
21
21
  };
22
22
  export const selectBreakPoint = (state) => state.widthStats.currentBreakPoint;
23
+ export const selectWidthStats = (state) => state.widthStats;
23
24
  export function useApiSubscribe() {
24
25
  const dispatch = useAppDispatch();
25
26
  const subscriptions = useRef([]);
@@ -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.57-new-steps",
4
+ "version": "3.0.57",
5
5
  "scripts": {
6
6
  "watch": "tsgo --noEmit --watch --project tsconfig.app.json",
7
7
  "start": "vite",
@@ -16,7 +16,6 @@
16
16
  "build-storybook": "storybook build"
17
17
  },
18
18
  "dependencies": {
19
- "@base-ui/react": "^1.6.0",
20
19
  "@reduxjs/toolkit": "2.11.2",
21
20
  "axios": "1.16.0",
22
21
  "date-fns": "4.1.0",
@@ -51,10 +50,10 @@
51
50
  "@eslint/eslintrc": "3.3.3",
52
51
  "@eslint/js": "9.39.1",
53
52
  "@faker-js/faker": "10.1.0",
54
- "@mui/material": "^9.0.1",
55
- "@mui/x-data-grid-pro": "^9.3.0",
56
- "@mui/x-date-pickers": "^9.3.0",
57
- "@mui/x-date-pickers-pro": "^9.3.0",
53
+ "@mui/material": "^9.2.0",
54
+ "@mui/x-data-grid-pro": "^9.10.1",
55
+ "@mui/x-date-pickers": "^9.10.1",
56
+ "@mui/x-date-pickers-pro": "^9.10.1",
58
57
  "@storybook/addon-docs": "^10.4.0",
59
58
  "@storybook/addon-onboarding": "^10.4.0",
60
59
  "@storybook/addon-themes": "^10.4.0",
@@ -98,8 +97,8 @@
98
97
  "peerDependencies": {
99
98
  "@emotion/react": "11.x.x",
100
99
  "@emotion/styled": "11.x.x",
101
- "@mui/material": "^9.0.1",
102
- "@mui/x-date-pickers": "^9.3.0",
100
+ "@mui/material": "^9.2.0",
101
+ "@mui/x-date-pickers": "^9.10.1",
103
102
  "react": "18 || 19",
104
103
  "react-dom": "18 || 19"
105
104
  },
@@ -1,48 +0,0 @@
1
- /**
2
- * @deprecated Renombrado a CalendarFormStep.
3
- * Este archivo existe solo para compatibilidad retroactiva.
4
- * Usar `CalendarFormStep.ts` directamente.
5
- */
6
- export type { AvailabilityStep } from './CalendarFormStep';
7
- export type { CalendarValue as AvailabilityValue } from './CalendarFormStep';
8
- export { CalendarEventCategory as AvailabilityEventCategory } from './CalendarFormStep';
9
- export { CalendarDefaultView } from './CalendarFormStep';
10
- export type { CalendarEventTemplate } from './CalendarFormStep';
11
- export type { CalendarEvent } from './CalendarFormStep';
12
- export declare enum AvailabilityMode {
13
- WEEKLY = "WEEKLY",
14
- SPECIFIC_DATES = "SPECIFIC_DATES",
15
- COMBINED = "COMBINED"
16
- }
17
- export declare enum AvailabilityDayOfWeek {
18
- MONDAY = 1,
19
- TUESDAY = 2,
20
- WEDNESDAY = 3,
21
- THURSDAY = 4,
22
- FRIDAY = 5,
23
- SATURDAY = 6,
24
- SUNDAY = 7
25
- }
26
- export interface AvailabilitySlot {
27
- start: string;
28
- end: string;
29
- }
30
- export interface AvailabilityDay {
31
- day: AvailabilityDayOfWeek;
32
- slots: AvailabilitySlot[];
33
- recurrence?: string;
34
- }
35
- export interface AvailabilitySpecificDate {
36
- date: string;
37
- slots: AvailabilitySlot[];
38
- }
39
- export interface AvailabilityExclusion {
40
- date?: string;
41
- dateRange?: {
42
- start: string;
43
- end: string;
44
- };
45
- dayOfWeek?: AvailabilityDayOfWeek;
46
- slots?: AvailabilitySlot[];
47
- reason?: string;
48
- }