@arquimedes.co/eureka-forms 3.0.60 → 3.0.62-new-steps

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 (110) 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 +166 -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/FormSteps/AvailabilityStep/AvailabilityStep.d.ts +7 -0
  33. package/dist/FormSteps/AvailabilityStep/AvailabilityStep.js +14 -0
  34. package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.d.ts +8 -0
  35. package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.js +32 -0
  36. package/dist/FormSteps/BookingStep/BookingStep.d.ts +17 -0
  37. package/dist/FormSteps/BookingStep/BookingStep.js +14 -0
  38. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.d.ts +7 -0
  39. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +32 -0
  40. package/dist/FormSteps/CheckBoxStep/CheckBoxStep.mobileLabel.test.js +20 -12
  41. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +6 -13
  42. package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +2 -13
  43. package/dist/FormSteps/LocationStep/LocationStep.d.ts +10 -0
  44. package/dist/FormSteps/LocationStep/LocationStep.js +14 -0
  45. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.d.ts +3 -0
  46. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.js +54 -0
  47. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.module.css +18 -0
  48. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.d.ts +3 -0
  49. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.js +170 -0
  50. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +96 -0
  51. package/dist/FormSteps/NumberStep/NumberStep.d.ts +10 -0
  52. package/dist/FormSteps/NumberStep/NumberStep.js +14 -0
  53. package/dist/FormSteps/Step.js +16 -0
  54. package/dist/FormSteps/StepFunctions.js +14 -0
  55. package/dist/FormSteps/StepFunctions.test.js +54 -0
  56. package/dist/Icons/AddIcon.d.ts +3 -0
  57. package/dist/Icons/AddIcon.js +7 -0
  58. package/dist/Icons/EditIcon.d.ts +3 -0
  59. package/dist/Icons/EditIcon.js +7 -0
  60. package/dist/Icons/RemoveIcon.d.ts +3 -0
  61. package/dist/Icons/RemoveIcon.js +7 -0
  62. package/dist/Icons/ViewDayIcon.d.ts +3 -0
  63. package/dist/Icons/ViewDayIcon.js +7 -0
  64. package/dist/Icons/ViewWeekIcon.d.ts +3 -0
  65. package/dist/Icons/ViewWeekIcon.js +7 -0
  66. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.d.ts +19 -0
  67. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.js +80 -0
  68. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.module.css +88 -0
  69. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +29 -0
  70. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +139 -0
  71. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.d.ts +25 -0
  72. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.js +112 -0
  73. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.module.css +88 -0
  74. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.d.ts +1 -0
  75. package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.js +73 -0
  76. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.d.ts +31 -0
  77. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.js +228 -0
  78. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.module.css +608 -0
  79. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.d.ts +28 -0
  80. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.js +117 -0
  81. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.d.ts +1 -0
  82. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.js +49 -0
  83. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.d.ts +1 -0
  84. package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.js +107 -0
  85. package/dist/Shared/ErkDatePicker/ErkDatePicker.js +1 -3
  86. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +2 -3
  87. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +1 -2
  88. package/dist/Shared/ErkIconButton/ErkIconButton.d.ts +17 -0
  89. package/dist/Shared/ErkIconButton/ErkIconButton.js +11 -0
  90. package/dist/Shared/ErkIconButton/ErkIconButton.module.css +41 -0
  91. package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +24 -0
  92. package/dist/Shared/ErkLocationField/ErkLocationField.js +128 -0
  93. package/dist/Shared/ErkLocationField/ErkLocationField.module.css +164 -0
  94. package/dist/Shared/ErkLocationField/ErkLocationField.test.d.ts +1 -0
  95. package/dist/Shared/ErkLocationField/ErkLocationField.test.js +82 -0
  96. package/dist/Shared/ErkLocationField/addressFields.d.ts +12 -0
  97. package/dist/Shared/ErkLocationField/addressFields.js +34 -0
  98. package/dist/Shared/ErkLocationField/locationRestrictions.d.ts +6 -0
  99. package/dist/Shared/ErkLocationField/locationRestrictions.js +51 -0
  100. package/dist/Shared/ErkLocationInput/ErkLocationInput.d.ts +15 -0
  101. package/dist/Shared/ErkLocationInput/ErkLocationInput.js +502 -0
  102. package/dist/Shared/ErkLocationInput/ErkLocationInput.module.css +128 -0
  103. package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +42 -0
  104. package/dist/Shared/ErkNumberField/ErkNumberField.js +169 -0
  105. package/dist/Utils/AxiosWidget.js +9 -1
  106. package/dist/constants/FormStepTypes.d.ts +5 -1
  107. package/dist/constants/FormStepTypes.js +4 -0
  108. package/dist/index.lib.d.ts +4 -2
  109. package/dist/index.lib.js +3 -1
  110. package/package.json +2 -1
@@ -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,10 @@
1
+ import { LocationStep } from '../../@Types/LocationFormStep';
2
+ import { StepProps } from '../Step';
3
+ export interface LocationStepProps extends StepProps {
4
+ /** The LocationStep to display */
5
+ step: LocationStep;
6
+ /** The icon to display */
7
+ IconComponent?: React.ElementType;
8
+ }
9
+ declare function LocationStepComponent(props: LocationStepProps): JSX.Element;
10
+ export default LocationStepComponent;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FormStyleTypes } from '../../constants/FormStepTypes';
3
+ import MaterialLocationStep from './MaterialLocationStep/MaterialLocationStep';
4
+ import { useAppSelector } from '../../hooks';
5
+ function LocationStepComponent(props) {
6
+ const { formStyle } = useAppSelector((state) => state.global);
7
+ switch (formStyle.type) {
8
+ case FormStyleTypes.MATERIAL:
9
+ default: {
10
+ return _jsx(MaterialLocationStep, { ...props });
11
+ }
12
+ }
13
+ }
14
+ export default LocationStepComponent;
@@ -0,0 +1,3 @@
1
+ import { LocationStepProps } from '../LocationStep';
2
+ declare function MaterialLocationStep({ step, editable }: LocationStepProps): JSX.Element;
3
+ export default MaterialLocationStep;
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useContext } from 'react';
3
+ import { AddressFieldMode, LocationInputMode } from '../../../@Types/LocationFormStep';
4
+ import { useFormStep } from '../../StepHooks';
5
+ import FormContext from '../../../Contexts/FormContext';
6
+ import { selectBreakPoint, useAppSelector } from '../../../hooks';
7
+ import { calcStepWidth } from '../../StepFunctions';
8
+ import ErkLocationField from '../../../Shared/ErkLocationField/ErkLocationField';
9
+ import { fieldConfig } from '../../../Shared/ErkLocationField/addressFields';
10
+ import { validateRestrictions } from '../../../Shared/ErkLocationField/locationRestrictions';
11
+ import styles from './MaterialLocationStep.module.css';
12
+ function MaterialLocationStep({ step, editable }) {
13
+ const currentBreakPoint = useAppSelector(selectBreakPoint);
14
+ const { postview, formStyle } = useAppSelector((state) => state.global);
15
+ const form = useContext(FormContext);
16
+ const isReadOnly = !editable || postview;
17
+ const widthStyle = currentBreakPoint <= step.size ? '100%' : calcStepWidth(step.size, form.size);
18
+ const { ref, value, onChange, error } = useFormStep(step, {
19
+ defaultValue: step.defaultValue ?? null,
20
+ rules: {
21
+ required: step.required ? 'La ubicación es obligatoria' : undefined,
22
+ validate: (val) => {
23
+ if (!val)
24
+ return step.required ? 'La ubicación es obligatoria' : true;
25
+ if (val.source === LocationInputMode.MANUAL) {
26
+ // Un campo es obligatorio en manual solo si no está omitido (FIXED lo llena solo).
27
+ const detail = val.addressDetail;
28
+ const isRequired = (key) => fieldConfig(step.addressFields, key).mode !== AddressFieldMode.OMIT;
29
+ if (step.required && isRequired('street') && !detail?.street)
30
+ return 'Por favor completa la calle en el formulario manual.';
31
+ if (step.required && isRequired('city') && !detail?.city)
32
+ return 'Por favor completa la ciudad en el formulario manual.';
33
+ if (step.required && isRequired('country') && !detail?.country)
34
+ return 'Por favor completa el país en el formulario manual.';
35
+ return true;
36
+ }
37
+ if (val.latitude === undefined || val.longitude === undefined) {
38
+ return step.required ? 'Coordenadas geográficas no capturadas.' : true;
39
+ }
40
+ // Restricciones geográficas (radio / geofence).
41
+ return validateRestrictions(val.latitude, val.longitude, step.restrictions) ?? true;
42
+ },
43
+ },
44
+ });
45
+ return (_jsxs("div", { className: styles.container, style: {
46
+ width: widthStyle,
47
+ '--eureka-outline': formStyle.outlineColor,
48
+ '--eureka-primary': formStyle.primaryColor,
49
+ '--eureka-text': formStyle.textColor,
50
+ '--eureka-error': formStyle.errorColor,
51
+ '--eureka-bg': formStyle.standAloneBackgroundColor ?? '#fff',
52
+ }, children: [step.label && (_jsxs("div", { className: styles.label, children: [step.label, step.required && _jsx("span", { className: styles.required, children: " *" })] })), _jsx(ErkLocationField, { value: value, onChange: onChange, allowedModes: step.allowedModes, defaultMode: step.defaultMode, addressFields: step.addressFields, helperText: error?.message ?? step.description, required: step.required, error: !!error, readOnly: isReadOnly, inputRef: ref })] }));
53
+ }
54
+ export default MaterialLocationStep;
@@ -0,0 +1,18 @@
1
+ .container {
2
+ max-width: 100%;
3
+ display: flex;
4
+ flex-direction: column;
5
+ gap: 6px;
6
+ padding: 5px 10px 0;
7
+ box-sizing: border-box;
8
+ }
9
+
10
+ .label {
11
+ font-size: 14px;
12
+ font-weight: 500;
13
+ color: var(--eureka-text, #333);
14
+ }
15
+
16
+ .required {
17
+ color: var(--eureka-error, #e53935);
18
+ }
@@ -0,0 +1,3 @@
1
+ import { NumberStepProps } from '../NumberStep';
2
+ declare function MaterialNumberStep({ step, editable }: NumberStepProps): JSX.Element;
3
+ export default MaterialNumberStep;
@@ -0,0 +1,170 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useContext, useState, useEffect } from 'react';
3
+ import { NumberStepType, } from '../../../@Types/NumericFormSteps';
4
+ import { useFormStep } from '../../StepHooks';
5
+ import FormContext from '../../../Contexts/FormContext';
6
+ import { selectBreakPoint, useAppSelector } from '../../../hooks';
7
+ import { calcStepWidth } from '../../StepFunctions';
8
+ import ErkNumberField from '../../../Shared/ErkNumberField/ErkNumberField';
9
+ import ErkSelect from '../../../Shared/ErkSelect/ErkSelect';
10
+ import ErkMenuItem from '../../../Shared/ErkMenuItem';
11
+ import styles from './MaterialNumberStep.module.css';
12
+ const DEFAULT_CURRENCIES = ['COP', 'USD', 'EUR', 'MXN', 'CLP', 'BRL'];
13
+ const DEFAULT_UNITS = ['unidades', 'kg', 'g', 'm', 'cm', 'l', 'ml', 'hrs', 'mes', 'año'];
14
+ // ---------------------------------------------------------------------------
15
+ // Helpers
16
+ // ---------------------------------------------------------------------------
17
+ function getNumericValue(value) {
18
+ if (value === null || value === undefined)
19
+ return null;
20
+ if (typeof value === 'number')
21
+ return value;
22
+ return value.value;
23
+ }
24
+ // ---------------------------------------------------------------------------
25
+ // Component
26
+ // ---------------------------------------------------------------------------
27
+ function MaterialNumberStep({ step, editable }) {
28
+ const currentBreakPoint = useAppSelector(selectBreakPoint);
29
+ const { postview, formStyle } = useAppSelector((state) => state.global);
30
+ const form = useContext(FormContext);
31
+ const isReadOnly = !editable || postview;
32
+ const widthStyle = currentBreakPoint <= step.size ? '100%' : calcStepWidth(step.size, form.size);
33
+ const isComposite = step.numberType === NumberStepType.MONEY ||
34
+ step.numberType === NumberStepType.MEASURE ||
35
+ step.numberType === NumberStepType.UNIT_PRICE;
36
+ // Narrowed views — only used after the corresponding numberType check
37
+ const asMoney = step;
38
+ const asMeasure = step;
39
+ const asUnitPrice = step;
40
+ const { ref, value, onChange, error } = useFormStep(step, {
41
+ defaultValue: step.defaultValue ?? null,
42
+ rules: {
43
+ required: step.required ? 'Este campo es obligatorio' : undefined,
44
+ validate: (val) => {
45
+ if (!step.required && (val === null || val === undefined || val === ''))
46
+ return true;
47
+ if (step.required && (val === null || val === undefined || val === ''))
48
+ return 'Este campo es obligatorio';
49
+ const numVal = getNumericValue(val);
50
+ if (numVal === null)
51
+ return 'Formato numérico inválido';
52
+ if (step.min !== undefined && numVal < step.min)
53
+ return `El valor mínimo es ${step.min}`;
54
+ if (step.max !== undefined && numVal > step.max)
55
+ return `El valor máximo es ${step.max}`;
56
+ return true;
57
+ },
58
+ },
59
+ });
60
+ // Currency/unit selectors
61
+ const [selectedCurrency, setSelectedCurrency] = useState(() => {
62
+ const v = value;
63
+ return v?.currency ?? asMoney.currency ?? asUnitPrice.currency ?? 'COP';
64
+ });
65
+ const [selectedUnit, setSelectedUnit] = useState(() => {
66
+ const v = value;
67
+ return v?.unit ?? asMeasure.unit ?? asUnitPrice.unit ?? 'unidades';
68
+ });
69
+ // Sync when value changes externally
70
+ useEffect(() => {
71
+ if (value && typeof value === 'object') {
72
+ if ('currency' in value && value.currency && value.currency !== selectedCurrency) {
73
+ void Promise.resolve().then(() => setSelectedCurrency(value.currency));
74
+ }
75
+ if ('unit' in value && value.unit && value.unit !== selectedUnit) {
76
+ void Promise.resolve().then(() => setSelectedUnit(value.unit));
77
+ }
78
+ }
79
+ }, [value, selectedCurrency, selectedUnit]);
80
+ // ---------------------------------------------------------------------------
81
+ // Handlers: wrap ErkNumberField's (number | null) into the step value shape
82
+ // ---------------------------------------------------------------------------
83
+ const handleNumberChange = (num) => {
84
+ if (num === null) {
85
+ onChange(null);
86
+ return;
87
+ }
88
+ if (step.numberType === NumberStepType.MONEY) {
89
+ onChange({ value: num, currency: selectedCurrency });
90
+ }
91
+ else if (step.numberType === NumberStepType.MEASURE) {
92
+ onChange({ value: num, unit: selectedUnit });
93
+ }
94
+ else if (step.numberType === NumberStepType.UNIT_PRICE) {
95
+ onChange({ value: num, currency: selectedCurrency, unit: selectedUnit });
96
+ }
97
+ else {
98
+ onChange(num);
99
+ }
100
+ };
101
+ const handleCurrencyChange = (curr) => {
102
+ const next = curr ?? 'USD';
103
+ setSelectedCurrency(next);
104
+ const num = getNumericValue(value);
105
+ if (num !== null) {
106
+ onChange(step.numberType === NumberStepType.UNIT_PRICE
107
+ ? { value: num, currency: next, unit: selectedUnit }
108
+ : { value: num, currency: next });
109
+ }
110
+ };
111
+ const handleUnitChange = (u) => {
112
+ const next = u ?? 'unidades';
113
+ setSelectedUnit(next);
114
+ const num = getNumericValue(value);
115
+ if (num !== null) {
116
+ onChange(step.numberType === NumberStepType.UNIT_PRICE
117
+ ? { value: num, currency: selectedCurrency, unit: next }
118
+ : { value: num, unit: next });
119
+ }
120
+ };
121
+ // ---------------------------------------------------------------------------
122
+ // Static suffix text shown inside ErkNumberField
123
+ // ---------------------------------------------------------------------------
124
+ const staticSuffix = () => {
125
+ if (step.numberType === NumberStepType.PERCENTAGE)
126
+ return '%';
127
+ if (step.numberType === NumberStepType.MONEY && !asMoney.allowCurrencyChange)
128
+ return asMoney.currency ?? 'USD';
129
+ if (step.numberType === NumberStepType.MEASURE && !asMeasure.allowUnitChange)
130
+ return asMeasure.unit ?? 'unidades';
131
+ // UNIT_PRICE renders its adornment fully inside the field only when neither part is editable.
132
+ if (step.numberType === NumberStepType.UNIT_PRICE &&
133
+ !asUnitPrice.allowCurrencyChange &&
134
+ !asUnitPrice.allowUnitChange)
135
+ return `${asUnitPrice.currency ?? 'USD'} / ${asUnitPrice.unit ?? 'unidades'}`;
136
+ if (!isComposite && step.suffix)
137
+ return step.suffix;
138
+ return undefined;
139
+ };
140
+ // ---------------------------------------------------------------------------
141
+ // Resolved selector lists
142
+ // ---------------------------------------------------------------------------
143
+ const currenciesList = step.numberType === NumberStepType.MONEY || step.numberType === NumberStepType.UNIT_PRICE
144
+ ? (step.availableCurrencies ?? DEFAULT_CURRENCIES)
145
+ : [];
146
+ const unitsList = step.numberType === NumberStepType.MEASURE || step.numberType === NumberStepType.UNIT_PRICE
147
+ ? (step.availableUnits ?? DEFAULT_UNITS)
148
+ : [];
149
+ const isMoneyDynamic = step.numberType === NumberStepType.MONEY && asMoney.allowCurrencyChange;
150
+ const isMeasureDynamic = step.numberType === NumberStepType.MEASURE && asMeasure.allowUnitChange;
151
+ // UNIT_PRICE has two independent toggles: currency and unit can each be fixed or selectable.
152
+ const isUnitPriceCurrencyDynamic = step.numberType === NumberStepType.UNIT_PRICE && !!asUnitPrice.allowCurrencyChange;
153
+ const isUnitPriceUnitDynamic = step.numberType === NumberStepType.UNIT_PRICE && !!asUnitPrice.allowUnitChange;
154
+ const isUnitPriceDynamic = isUnitPriceCurrencyDynamic || isUnitPriceUnitDynamic;
155
+ // ---------------------------------------------------------------------------
156
+ // Shared CSS vars
157
+ // ---------------------------------------------------------------------------
158
+ const cssVars = {
159
+ width: widthStyle,
160
+ '--eureka-outline': formStyle.outlineColor,
161
+ '--eureka-primary': formStyle.primaryColor,
162
+ '--eureka-text': formStyle.textColor,
163
+ '--eureka-bg': formStyle.standAloneBackgroundColor ?? '#fff',
164
+ };
165
+ // ---------------------------------------------------------------------------
166
+ // Read-only view
167
+ // ---------------------------------------------------------------------------
168
+ return (_jsx("div", { className: styles.container, style: cssVars, children: _jsxs("div", { className: styles.inputRow, children: [_jsx("div", { style: { flex: 1 }, children: _jsx(ErkNumberField, { label: step.label, value: getNumericValue(value), onChange: handleNumberChange, error: !!error, errorBorder: true, required: step.required, helperText: error?.message ?? step.description ?? undefined, inputRef: ref, min: step.min, max: step.max, decimals: step.numberType === NumberStepType.INTEGER ? 0 : (step.decimals ?? 2), suffix: staticSuffix(), readOnly: isReadOnly, spinner: step.spinner, step: step.step, placeholder: step.placeholder }) }), isMoneyDynamic && (_jsx("div", { className: styles.selectWrapper, children: _jsx(ErkSelect, { value: selectedCurrency, onChange: handleCurrencyChange, clearable: false, children: currenciesList.map((c) => (_jsx(ErkMenuItem, { value: c, children: c }, c))) }) })), isMeasureDynamic && (_jsx("div", { className: styles.selectWrapper, children: _jsx(ErkSelect, { value: selectedUnit, onChange: handleUnitChange, clearable: false, children: unitsList.map((u) => (_jsx(ErkMenuItem, { value: u, children: u }, u))) }) })), isUnitPriceDynamic && (_jsxs(_Fragment, { children: [isUnitPriceCurrencyDynamic ? (_jsx("div", { className: styles.selectWrapper, children: _jsx(ErkSelect, { value: selectedCurrency, onChange: handleCurrencyChange, clearable: false, children: currenciesList.map((c) => (_jsx(ErkMenuItem, { value: c, children: c }, c))) }) })) : (_jsx("span", { className: styles.suffixText, children: asUnitPrice.currency ?? 'USD' })), _jsx("span", { className: styles.dividerSlash, children: "/" }), isUnitPriceUnitDynamic ? (_jsx("div", { className: styles.selectWrapper, children: _jsx(ErkSelect, { value: selectedUnit, onChange: handleUnitChange, clearable: false, children: unitsList.map((u) => (_jsx(ErkMenuItem, { value: u, children: u }, u))) }) })) : (_jsx("span", { className: styles.suffixText, children: asUnitPrice.unit ?? 'unidades' }))] }))] }) }));
169
+ }
170
+ export default MaterialNumberStep;
@@ -0,0 +1,96 @@
1
+ .container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ width: 100%;
5
+ }
6
+
7
+ .inputRow {
8
+ display: flex;
9
+ align-items: flex-start;
10
+ gap: 12px;
11
+ width: 100%;
12
+ }
13
+
14
+ .selectWrapper {
15
+ width: 100px;
16
+ min-width: 90px;
17
+ }
18
+
19
+ .dividerSlash {
20
+ align-self: flex-start;
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: center;
24
+ height: 40px;
25
+ font-size: 20px;
26
+ font-weight: bold;
27
+ color: var(--eureka-text, #333);
28
+ opacity: 0.6;
29
+ margin-left: 2px;
30
+ margin-right: 2px;
31
+ }
32
+
33
+ .suffixText {
34
+ align-self: flex-start;
35
+ display: flex;
36
+ align-items: center;
37
+ height: 40px;
38
+ font-size: 14px;
39
+ font-weight: 600;
40
+ color: var(--eureka-primary, #1976d2);
41
+ padding: 0 4px;
42
+ user-select: none;
43
+ }
44
+
45
+ /* Read-Only Styles */
46
+ .readOnlyContainer {
47
+ width: 100%;
48
+ margin-bottom: 8px;
49
+ }
50
+
51
+ .readOnlyCard {
52
+ display: flex;
53
+ align-items: center;
54
+ padding: 12px 16px;
55
+ border: 1px solid var(--eureka-outline, #e0e0e0);
56
+ border-radius: 12px;
57
+ background-color: var(--eureka-bg, #ffffff);
58
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
59
+ transition:
60
+ box-shadow 0.2s ease,
61
+ border-color 0.2s ease;
62
+ }
63
+
64
+ .readOnlyCard:hover {
65
+ border-color: var(--eureka-primary, #1976d2);
66
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
67
+ }
68
+
69
+ .readOnlyDetails {
70
+ display: flex;
71
+ flex-direction: column;
72
+ gap: 2px;
73
+ width: 100%;
74
+ }
75
+
76
+ .readOnlyLabel {
77
+ font-size: 11px !important;
78
+ text-transform: uppercase;
79
+ letter-spacing: 0.5px;
80
+ color: var(--eureka-text, #333) !important;
81
+ opacity: 0.6;
82
+ font-weight: 600 !important;
83
+ }
84
+
85
+ .readOnlyValue {
86
+ font-size: 16px !important;
87
+ font-weight: 600 !important;
88
+ color: var(--eureka-primary, #1976d2) !important;
89
+ }
90
+
91
+ .readOnlyDesc {
92
+ font-size: 12px !important;
93
+ color: var(--eureka-text, #333) !important;
94
+ opacity: 0.5;
95
+ margin-top: 2px !important;
96
+ }
@@ -0,0 +1,10 @@
1
+ import { NumberStep } from '../../@Types/FormStep';
2
+ import { StepProps } from '../Step';
3
+ export interface NumberStepProps extends StepProps {
4
+ /** The NumberStep to display */
5
+ step: NumberStep;
6
+ /** The icon to display */
7
+ IconComponent?: React.ElementType;
8
+ }
9
+ declare function NumberStepComponent(props: NumberStepProps): JSX.Element;
10
+ export default NumberStepComponent;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FormStyleTypes } from '../../constants/FormStepTypes';
3
+ import MaterialNumberStep from './MaterialNumberStep/MaterialNumberStep';
4
+ import { useAppSelector } from '../../hooks';
5
+ function NumberStepComponent(props) {
6
+ const { formStyle } = useAppSelector((state) => state.global);
7
+ switch (formStyle.type) {
8
+ case FormStyleTypes.MATERIAL:
9
+ default: {
10
+ return _jsx(MaterialNumberStep, { ...props });
11
+ }
12
+ }
13
+ }
14
+ export default NumberStepComponent;