@arquimedes.co/eureka-forms 3.0.52-test → 3.0.53-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.
- package/dist/@Types/AvailabilityFormStep.d.ts +48 -0
- package/dist/@Types/AvailabilityFormStep.js +24 -0
- package/dist/@Types/BankAccountFormStep.d.ts +67 -0
- package/dist/@Types/BankAccountFormStep.js +14 -0
- package/dist/@Types/BookingFormStep.d.ts +166 -0
- package/dist/@Types/BookingFormStep.js +44 -0
- package/dist/@Types/CalendarFormStep.d.ts +192 -0
- package/dist/@Types/CalendarFormStep.js +48 -0
- package/dist/@Types/CommunicationChannelFormStep.d.ts +51 -0
- package/dist/@Types/CommunicationChannelFormStep.js +15 -0
- package/dist/@Types/ConsentFormStep.d.ts +36 -0
- package/dist/@Types/ConsentFormStep.js +8 -0
- package/dist/@Types/EntityFormFormStep.d.ts +66 -0
- package/dist/@Types/EntityFormFormStep.js +20 -0
- package/dist/@Types/EventFormStep.d.ts +52 -0
- package/dist/@Types/EventFormStep.js +13 -0
- package/dist/@Types/ExternalReferenceFormStep.d.ts +74 -0
- package/dist/@Types/ExternalReferenceFormStep.js +20 -0
- package/dist/@Types/FormStep.d.ts +7 -2
- package/dist/@Types/FormStep.js +2 -1
- package/dist/@Types/LocationFormStep.d.ts +159 -0
- package/dist/@Types/LocationFormStep.js +46 -0
- package/dist/@Types/NumericFormSteps.d.ts +108 -0
- package/dist/@Types/NumericFormSteps.js +20 -0
- package/dist/@Types/PredefinedSelectorFormStep.d.ts +51 -0
- package/dist/@Types/PredefinedSelectorFormStep.js +39 -0
- package/dist/@Types/StepRef.d.ts +135 -0
- package/dist/@Types/StepRef.js +49 -0
- package/dist/FormSteps/BookingStep/BookingStep.d.ts +17 -0
- package/dist/FormSteps/BookingStep/BookingStep.js +14 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.d.ts +7 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +32 -0
- package/dist/FormSteps/CalendarStep/CalendarStep.d.ts +7 -0
- package/dist/FormSteps/CalendarStep/CalendarStep.js +14 -0
- package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.d.ts +7 -0
- package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.js +31 -0
- package/dist/FormSteps/LocationStep/LocationStep.d.ts +10 -0
- package/dist/FormSteps/LocationStep/LocationStep.js +14 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.d.ts +3 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.js +47 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.module.css +18 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.d.ts +3 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.js +168 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +94 -0
- package/dist/FormSteps/NumberStep/NumberStep.d.ts +10 -0
- package/dist/FormSteps/NumberStep/NumberStep.js +14 -0
- package/dist/FormSteps/Step.js +16 -0
- package/dist/FormSteps/StepFunctions.js +14 -0
- package/dist/FormSteps/StepFunctions.test.js +54 -0
- package/dist/Icons/AddIcon.d.ts +3 -0
- package/dist/Icons/AddIcon.js +7 -0
- package/dist/Icons/EditIcon.d.ts +3 -0
- package/dist/Icons/EditIcon.js +7 -0
- package/dist/Icons/RemoveIcon.d.ts +3 -0
- package/dist/Icons/RemoveIcon.js +7 -0
- package/dist/Icons/ViewDayIcon.d.ts +3 -0
- package/dist/Icons/ViewDayIcon.js +7 -0
- package/dist/Icons/ViewWeekIcon.d.ts +3 -0
- package/dist/Icons/ViewWeekIcon.js +7 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.d.ts +19 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.js +80 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.module.css +82 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +29 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +139 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.d.ts +31 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.js +223 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.module.css +608 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.d.ts +28 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.js +117 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.d.ts +1 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.js +49 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.d.ts +1 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.js +107 -0
- package/dist/Shared/ErkCalendar/CalendarFunctions.d.ts +28 -0
- package/dist/Shared/ErkCalendar/CalendarFunctions.js +121 -0
- package/dist/Shared/ErkCalendar/CalendarPopovers.d.ts +45 -0
- package/dist/Shared/ErkCalendar/CalendarPopovers.js +110 -0
- package/dist/Shared/ErkCalendar/ErkCalendar.d.ts +73 -0
- package/dist/Shared/ErkCalendar/ErkCalendar.js +293 -0
- package/dist/Shared/ErkCalendar/ErkCalendar.module.css +775 -0
- package/dist/Shared/ErkCalendar/ErkCalendar.test.d.ts +1 -0
- package/dist/Shared/ErkCalendar/ErkCalendar.test.js +171 -0
- package/dist/Shared/ErkDatePicker/ErkDatePicker.js +1 -3
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +2 -3
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +1 -2
- package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +23 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.js +73 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.module.css +29 -0
- package/dist/Shared/ErkLocationField/addressFields.d.ts +12 -0
- package/dist/Shared/ErkLocationField/addressFields.js +34 -0
- package/dist/Shared/ErkLocationField/locationRestrictions.d.ts +6 -0
- package/dist/Shared/ErkLocationField/locationRestrictions.js +51 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.d.ts +15 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.js +502 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.module.css +115 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +42 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.js +170 -0
- package/dist/constants/FormStepTypes.d.ts +5 -1
- package/dist/constants/FormStepTypes.js +4 -0
- package/dist/index.lib.d.ts +4 -2
- package/dist/index.lib.js +3 -1
- package/package.json +2 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DRAFT — PredefinedSelectorFormStep types
|
|
3
|
+
*
|
|
4
|
+
* Paso que reemplaza tener que configurar manualmente opciones de selectores
|
|
5
|
+
* para listas fijas y controladas por Capta (países, ciudades, monedas, etc.).
|
|
6
|
+
* Las opciones vienen de APIs internas — el formulario no necesita configurarlas.
|
|
7
|
+
*
|
|
8
|
+
* También resuelve la cascada Country → State → City via parentStepId.
|
|
9
|
+
*/
|
|
10
|
+
import { GSmartSelect } from './GenericFormSteps';
|
|
11
|
+
export declare enum PredefinedOptionType {
|
|
12
|
+
/** ISO 3166-1 — lista de países */
|
|
13
|
+
COUNTRY = "COUNTRY",
|
|
14
|
+
/**
|
|
15
|
+
* Departamento / provincia / estado.
|
|
16
|
+
* Requiere parentStepId apuntando a un step COUNTRY.
|
|
17
|
+
*/
|
|
18
|
+
STATE = "STATE",
|
|
19
|
+
/**
|
|
20
|
+
* Ciudad / municipio.
|
|
21
|
+
* Requiere parentStepId apuntando a un step STATE (o COUNTRY si no hay STATE).
|
|
22
|
+
*/
|
|
23
|
+
CITY = "CITY",
|
|
24
|
+
/** ISO 4217 — monedas (USD, COP, EUR, etc.) */
|
|
25
|
+
CURRENCY = "CURRENCY",
|
|
26
|
+
/** BCP 47 — idiomas (es, en, pt, etc.) */
|
|
27
|
+
LANGUAGE = "LANGUAGE",
|
|
28
|
+
/** Tipos de canal de comunicación (WhatsApp, Email, Teléfono) */
|
|
29
|
+
COMMUNICATION_CHANNEL_TYPE = "COMMUNICATION_CHANNEL_TYPE",
|
|
30
|
+
/** Tipos de documento de identidad por país (CC, NIT, Pasaporte, etc.) */
|
|
31
|
+
DOCUMENT_TYPE = "DOCUMENT_TYPE",
|
|
32
|
+
/** Días de la semana */
|
|
33
|
+
DAY_OF_WEEK = "DAY_OF_WEEK",
|
|
34
|
+
/** Meses del año */
|
|
35
|
+
MONTH = "MONTH"
|
|
36
|
+
}
|
|
37
|
+
export interface PredefinedSelectorStep extends GSmartSelect {
|
|
38
|
+
type: 'PREDEFINED_SELECTOR';
|
|
39
|
+
predefinedType: PredefinedOptionType;
|
|
40
|
+
/**
|
|
41
|
+
* Solo para STATE y CITY: id del step padre que filtra las opciones.
|
|
42
|
+
* - COUNTRY step → filtra estados del país seleccionado
|
|
43
|
+
* - STATE step → filtra ciudades del estado seleccionado
|
|
44
|
+
*
|
|
45
|
+
* Si no se especifica, se listan todas las opciones sin filtrar.
|
|
46
|
+
*/
|
|
47
|
+
parentStepId?: string;
|
|
48
|
+
maxSize?: number;
|
|
49
|
+
defaultValue?: string;
|
|
50
|
+
}
|
|
51
|
+
export type PredefinedSelectorValue = string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DRAFT — PredefinedSelectorFormStep types
|
|
3
|
+
*
|
|
4
|
+
* Paso que reemplaza tener que configurar manualmente opciones de selectores
|
|
5
|
+
* para listas fijas y controladas por Capta (países, ciudades, monedas, etc.).
|
|
6
|
+
* Las opciones vienen de APIs internas — el formulario no necesita configurarlas.
|
|
7
|
+
*
|
|
8
|
+
* También resuelve la cascada Country → State → City via parentStepId.
|
|
9
|
+
*/
|
|
10
|
+
// ===========================================================================
|
|
11
|
+
// Tipos predefinidos disponibles
|
|
12
|
+
// ===========================================================================
|
|
13
|
+
export var PredefinedOptionType;
|
|
14
|
+
(function (PredefinedOptionType) {
|
|
15
|
+
/** ISO 3166-1 — lista de países */
|
|
16
|
+
PredefinedOptionType["COUNTRY"] = "COUNTRY";
|
|
17
|
+
/**
|
|
18
|
+
* Departamento / provincia / estado.
|
|
19
|
+
* Requiere parentStepId apuntando a un step COUNTRY.
|
|
20
|
+
*/
|
|
21
|
+
PredefinedOptionType["STATE"] = "STATE";
|
|
22
|
+
/**
|
|
23
|
+
* Ciudad / municipio.
|
|
24
|
+
* Requiere parentStepId apuntando a un step STATE (o COUNTRY si no hay STATE).
|
|
25
|
+
*/
|
|
26
|
+
PredefinedOptionType["CITY"] = "CITY";
|
|
27
|
+
/** ISO 4217 — monedas (USD, COP, EUR, etc.) */
|
|
28
|
+
PredefinedOptionType["CURRENCY"] = "CURRENCY";
|
|
29
|
+
/** BCP 47 — idiomas (es, en, pt, etc.) */
|
|
30
|
+
PredefinedOptionType["LANGUAGE"] = "LANGUAGE";
|
|
31
|
+
/** Tipos de canal de comunicación (WhatsApp, Email, Teléfono) */
|
|
32
|
+
PredefinedOptionType["COMMUNICATION_CHANNEL_TYPE"] = "COMMUNICATION_CHANNEL_TYPE";
|
|
33
|
+
/** Tipos de documento de identidad por país (CC, NIT, Pasaporte, etc.) */
|
|
34
|
+
PredefinedOptionType["DOCUMENT_TYPE"] = "DOCUMENT_TYPE";
|
|
35
|
+
/** Días de la semana */
|
|
36
|
+
PredefinedOptionType["DAY_OF_WEEK"] = "DAY_OF_WEEK";
|
|
37
|
+
/** Meses del año */
|
|
38
|
+
PredefinedOptionType["MONTH"] = "MONTH";
|
|
39
|
+
})(PredefinedOptionType || (PredefinedOptionType = {}));
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DRAFT — Sistema de referencias dinámicas entre steps
|
|
3
|
+
*
|
|
4
|
+
* Permite que la configuración de un paso use el valor en tiempo de ejecución
|
|
5
|
+
* de otro step del mismo formulario, en lugar de un literal fijo.
|
|
6
|
+
*
|
|
7
|
+
* Patrón de uso:
|
|
8
|
+
*
|
|
9
|
+
* // Valor fijo definido en la configuración del formulario
|
|
10
|
+
* suffix: { type: 'FIXED', value: 'km' }
|
|
11
|
+
*
|
|
12
|
+
* // Valor tomado del step 'step_unidad' cuando el usuario interactúa
|
|
13
|
+
* suffix: { type: 'STEP_REF', idStep: 'step_unidad', fallback: 'm' }
|
|
14
|
+
*
|
|
15
|
+
* Se puede aplicar a cualquier campo de configuración cuyo valor deba
|
|
16
|
+
* responder a la selección previa del usuario: sufijos, unidades, monedas,
|
|
17
|
+
* títulos dinámicos, límites numéricos, etc.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Representa un valor estático/literal configurado en tiempo de diseño.
|
|
21
|
+
* No cambia dinámicamente según las respuestas del usuario.
|
|
22
|
+
*
|
|
23
|
+
* @typeParam T - Tipo de dato del valor estático.
|
|
24
|
+
*/
|
|
25
|
+
export interface FixedRef<T> {
|
|
26
|
+
/**
|
|
27
|
+
* Indica que el valor es fijo.
|
|
28
|
+
*/
|
|
29
|
+
type: 'FIXED';
|
|
30
|
+
/**
|
|
31
|
+
* El valor estático de tipo T.
|
|
32
|
+
* @example "km"
|
|
33
|
+
* @example 50
|
|
34
|
+
*/
|
|
35
|
+
value: T;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Referencia dinámica al valor actual de otro step en el mismo formulario.
|
|
39
|
+
* El runtime del formulario sustituye esta referencia por el valor que el usuario
|
|
40
|
+
* haya ingresado en el step indicado.
|
|
41
|
+
*
|
|
42
|
+
* @typeParam TAllowed - Literal(es) de tipo de step permitidos como origen.
|
|
43
|
+
* Por defecto es `string` (cualquier tipo de step). Pasar un literal union
|
|
44
|
+
* permite al Form Builder filtrar la lista de steps disponibles en la UI.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* // Referencia a cualquier tipo de step
|
|
49
|
+
* const ref: StepRef = {
|
|
50
|
+
* type: 'STEP_REF',
|
|
51
|
+
* idStep: 'step_unidad_medida',
|
|
52
|
+
* fallback: 'm'
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* // Referencia restringida únicamente a pasos de tipo LOCATION
|
|
56
|
+
* const refLocation: StepRef<'LOCATION'> = {
|
|
57
|
+
* type: 'STEP_REF',
|
|
58
|
+
* idStep: 'step_destino_cliente',
|
|
59
|
+
* allowedStepTypes: ['LOCATION']
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export interface StepRef<TAllowed extends string = string> {
|
|
64
|
+
/**
|
|
65
|
+
* Indica que el valor se toma dinámicamente de otro paso.
|
|
66
|
+
*/
|
|
67
|
+
type: 'STEP_REF';
|
|
68
|
+
/**
|
|
69
|
+
* ID del paso origen en el formulario del cual se leerá el valor en tiempo de ejecución.
|
|
70
|
+
* @example "step_ubicacion_cliente"
|
|
71
|
+
*/
|
|
72
|
+
idStep: string;
|
|
73
|
+
/**
|
|
74
|
+
* Valor de respaldo (fallback) en formato de texto a utilizar mientras el paso referenciado
|
|
75
|
+
* no contenga ningún valor (ej: porque el usuario aún no llega a ese paso).
|
|
76
|
+
* Si se omite, el campo referenciador se comportará como vacío o sin unidad.
|
|
77
|
+
*
|
|
78
|
+
* @example "m"
|
|
79
|
+
*/
|
|
80
|
+
fallback?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Lista de tipos de pasos permitidos para esta referencia.
|
|
83
|
+
* Ayuda al Form Builder a filtrar la interfaz de selección de campos y es
|
|
84
|
+
* validada por el backend al guardar la configuración del formulario.
|
|
85
|
+
* Si no se define, se permite referenciar cualquier tipo de paso.
|
|
86
|
+
*
|
|
87
|
+
* @example ["LOCATION"]
|
|
88
|
+
* @example ["PREDEFINED_SELECTOR", "CHECKBOX"]
|
|
89
|
+
*/
|
|
90
|
+
allowedStepTypes?: TAllowed[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Tipo genérico para campos que admiten tanto un valor estático como una referencia dinámica.
|
|
94
|
+
*
|
|
95
|
+
* @typeParam T - Tipo del valor cuando es FIXED (ej: `string`, `number`, `boolean`).
|
|
96
|
+
* @typeParam TAllowed - Tipos de paso de origen permitidos si es STEP_REF.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* // Un sufijo de texto dinámico:
|
|
101
|
+
* const sufijo: DynamicRef<string> = { type: 'FIXED', value: 'km' };
|
|
102
|
+
*
|
|
103
|
+
* // Una coordenada geográfica que debe venir de un paso de mapa:
|
|
104
|
+
* const origen: DynamicRef<LocationCoords, 'LOCATION'> = {
|
|
105
|
+
* type: 'STEP_REF',
|
|
106
|
+
* idStep: 'step_mapa_inicio',
|
|
107
|
+
* allowedStepTypes: ['LOCATION']
|
|
108
|
+
* };
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export type DynamicRef<T, TAllowed extends string = string> = FixedRef<T> | StepRef<TAllowed>;
|
|
112
|
+
/**
|
|
113
|
+
* Comprueba si la referencia dinámica recibida es de tipo FIXED.
|
|
114
|
+
* Funciona como Type Guard para TypeScript.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* if (isFixedRef(miRef)) {
|
|
119
|
+
* console.log("El valor es:", miRef.value);
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare function isFixedRef<T, TAllowed extends string = string>(ref: DynamicRef<T, TAllowed>): ref is FixedRef<T>;
|
|
124
|
+
/**
|
|
125
|
+
* Comprueba si la referencia dinámica recibida es de tipo STEP_REF.
|
|
126
|
+
* Funciona como Type Guard para TypeScript.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* if (isStepRef(miRef)) {
|
|
131
|
+
* console.log("Apunta al step:", miRef.idStep);
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export declare function isStepRef<T, TAllowed extends string = string>(ref: DynamicRef<T, TAllowed>): ref is StepRef<TAllowed>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DRAFT — Sistema de referencias dinámicas entre steps
|
|
3
|
+
*
|
|
4
|
+
* Permite que la configuración de un paso use el valor en tiempo de ejecución
|
|
5
|
+
* de otro step del mismo formulario, en lugar de un literal fijo.
|
|
6
|
+
*
|
|
7
|
+
* Patrón de uso:
|
|
8
|
+
*
|
|
9
|
+
* // Valor fijo definido en la configuración del formulario
|
|
10
|
+
* suffix: { type: 'FIXED', value: 'km' }
|
|
11
|
+
*
|
|
12
|
+
* // Valor tomado del step 'step_unidad' cuando el usuario interactúa
|
|
13
|
+
* suffix: { type: 'STEP_REF', idStep: 'step_unidad', fallback: 'm' }
|
|
14
|
+
*
|
|
15
|
+
* Se puede aplicar a cualquier campo de configuración cuyo valor deba
|
|
16
|
+
* responder a la selección previa del usuario: sufijos, unidades, monedas,
|
|
17
|
+
* títulos dinámicos, límites numéricos, etc.
|
|
18
|
+
*/
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Helpers de narrowing
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
/**
|
|
23
|
+
* Comprueba si la referencia dinámica recibida es de tipo FIXED.
|
|
24
|
+
* Funciona como Type Guard para TypeScript.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* if (isFixedRef(miRef)) {
|
|
29
|
+
* console.log("El valor es:", miRef.value);
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function isFixedRef(ref) {
|
|
34
|
+
return ref.type === 'FIXED';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Comprueba si la referencia dinámica recibida es de tipo STEP_REF.
|
|
38
|
+
* Funciona como Type Guard para TypeScript.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* if (isStepRef(miRef)) {
|
|
43
|
+
* console.log("Apunta al step:", miRef.idStep);
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function isStepRef(ref) {
|
|
48
|
+
return ref.type === 'STEP_REF';
|
|
49
|
+
}
|
|
@@ -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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CalendarStep } from '../../@Types/CalendarFormStep';
|
|
2
|
+
import { StepProps } from '../Step';
|
|
3
|
+
export interface CalendarStepProps extends StepProps {
|
|
4
|
+
step: CalendarStep;
|
|
5
|
+
}
|
|
6
|
+
declare function CalendarStepComponent(props: CalendarStepProps): JSX.Element;
|
|
7
|
+
export default CalendarStepComponent;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FormStyleTypes } from '../../constants/FormStepTypes';
|
|
3
|
+
import MaterialCalendarStep from './MaterialCalendarStep/MaterialCalendarStep';
|
|
4
|
+
import { useAppSelector } from '../../hooks';
|
|
5
|
+
function CalendarStepComponent(props) {
|
|
6
|
+
const { formStyle } = useAppSelector((state) => state.global);
|
|
7
|
+
switch (formStyle.type) {
|
|
8
|
+
case FormStyleTypes.MATERIAL:
|
|
9
|
+
default: {
|
|
10
|
+
return _jsx(MaterialCalendarStep, { ...props });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default CalendarStepComponent;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CalendarStepProps } from '../CalendarStep';
|
|
2
|
+
/**
|
|
3
|
+
* Conector del paso CALENDAR: enlaza el estado del formulario (`useFormStep`) y el
|
|
4
|
+
* theming del form con el componente reutilizable `ErkCalendar` (en Shared).
|
|
5
|
+
*/
|
|
6
|
+
declare function MaterialCalendarStep({ step, editable }: CalendarStepProps): JSX.Element;
|
|
7
|
+
export default MaterialCalendarStep;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 ErkCalendar from '../../../Shared/ErkCalendar/ErkCalendar';
|
|
8
|
+
/**
|
|
9
|
+
* Conector del paso CALENDAR: enlaza el estado del formulario (`useFormStep`) y el
|
|
10
|
+
* theming del form con el componente reutilizable `ErkCalendar` (en Shared).
|
|
11
|
+
*/
|
|
12
|
+
function MaterialCalendarStep({ step, editable }) {
|
|
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
|
+
};
|
|
25
|
+
const { ref, value, onChange, error } = useFormStep(step, {
|
|
26
|
+
defaultValue: null,
|
|
27
|
+
rules: { required: step.required ? 'Este campo es obligatorio' : undefined },
|
|
28
|
+
});
|
|
29
|
+
return (_jsx("div", { ref: ref, style: cssVars, children: _jsx(ErkCalendar, { value: value, onChange: onChange, defaultView: step.defaultView, enabledViews: step.enabledViews, allowedCategories: step.allowedCategories, eventTemplates: step.eventTemplates, showWeekends: step.showWeekends, minTime: step.minTime, maxTime: step.maxTime, allowRecurring: step.allowRecurring, timezone: step.timezone, readOnly: isReadOnly, error: error?.message }) }));
|
|
30
|
+
}
|
|
31
|
+
export default MaterialCalendarStep;
|
|
@@ -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,47 @@
|
|
|
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 } = 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: { width: widthStyle }, 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 })] }));
|
|
46
|
+
}
|
|
47
|
+
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
|
+
}
|