@arquimedes.co/eureka-forms 3.0.50-test → 3.0.52-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/App/App.stories.d.ts +30 -0
- package/dist/App/App.stories.js +298 -0
- package/dist/App/App.stories.test.d.ts +1 -0
- package/dist/App/App.stories.test.js +56 -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 +31 -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 +3 -0
- package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.js +269 -0
- package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.module.css +531 -0
- package/dist/FormSteps/DatePickerStep/DatePickerStep.required.test.d.ts +1 -0
- package/dist/FormSteps/DatePickerStep/DatePickerStep.required.test.js +94 -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/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +3 -1
- 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/ErkAutocompleteOption.d.ts +12 -0
- package/dist/Shared/ErkAutocompleteOption.js +37 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.d.ts +28 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.js +149 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.module.css +113 -0
- package/dist/Shared/ErkDatePicker/ErkDatePicker.js +3 -10
- package/dist/Shared/ErkDatePicker/ErkDatePicker.required.test.d.ts +1 -0
- package/dist/Shared/ErkDatePicker/ErkDatePicker.required.test.js +30 -0
- 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/Shared/ErkSmartSelect/ErkSmartSelect.js +2 -1
- package/dist/Shared/ErkSmartSelect/ErkSmartSelect.test.d.ts +1 -0
- package/dist/Shared/ErkSmartSelect/ErkSmartSelect.test.js +33 -0
- package/dist/Shared/SmartDraftRenderer/SmartDraftRenderer.d.ts +7 -1
- package/dist/Shared/SmartDraftRenderer/SmartDraftRenderer.js +2 -2
- package/dist/constants/FormStepTypes.d.ts +5 -1
- package/dist/constants/FormStepTypes.js +4 -0
- 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,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
3
|
+
import App from './App';
|
|
4
|
+
declare function FullHeight(Story: React.ComponentType): JSX.Element;
|
|
5
|
+
declare const meta: {
|
|
6
|
+
title: string;
|
|
7
|
+
component: typeof App;
|
|
8
|
+
decorators: (typeof FullHeight)[];
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: string;
|
|
11
|
+
};
|
|
12
|
+
args: {
|
|
13
|
+
isWidget: false;
|
|
14
|
+
idOrganization: string;
|
|
15
|
+
valuesData: {};
|
|
16
|
+
customSubmit: (values: Record<string, unknown>) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof meta>;
|
|
21
|
+
/** Parsed form, as the widget receives it from the API. */
|
|
22
|
+
export declare const Parseado: Story;
|
|
23
|
+
/** TITLE with an INTEGRATION entity depending on a TEXTINPUT step. */
|
|
24
|
+
export declare const IntegracionConStepDependencia: Story;
|
|
25
|
+
/** Parsed form pre-filled with values. */
|
|
26
|
+
export declare const ParseadoConValores: Story;
|
|
27
|
+
/** Raw builder form: EUREKA entities resolved locally via mapDraftEntities. */
|
|
28
|
+
export declare const PreParseado: Story;
|
|
29
|
+
/** Final view (postview): what the user submitted, rendered read-only. */
|
|
30
|
+
export declare const Postview: Story;
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import App from './App';
|
|
3
|
+
/**
|
|
4
|
+
* Stories to test full forms from a `{ form, values }` payload:
|
|
5
|
+
*
|
|
6
|
+
* - `Parseado`: a parsed form (what the widget receives, drafts are plain text).
|
|
7
|
+
* - `PreParseado`: a raw builder form (EUREKA/ENTITYVALUES entities still in the
|
|
8
|
+
* drafts, `rootSteps` instead of section steps). Entities are resolved locally
|
|
9
|
+
* with a stubbed `mapDraftEntities`, so no backend is needed.
|
|
10
|
+
*
|
|
11
|
+
* Paste any form JSON into `formData`/`valuesData` from the Controls panel.
|
|
12
|
+
*/
|
|
13
|
+
/** Raw builder form (pre-parsed): title draft still has EUREKA entities. */
|
|
14
|
+
const preParsedForm = {
|
|
15
|
+
steps: {
|
|
16
|
+
'TITLE-NkSFXOcH-z': {
|
|
17
|
+
id: 'TITLE-NkSFXOcH-z',
|
|
18
|
+
type: 'TITLE',
|
|
19
|
+
title: {
|
|
20
|
+
blocks: [
|
|
21
|
+
{
|
|
22
|
+
key: '2ri0w',
|
|
23
|
+
type: 'unstyled',
|
|
24
|
+
text: 'Razón social (Proveedor) ',
|
|
25
|
+
depth: 0,
|
|
26
|
+
inlineStyleRanges: [{ offset: 0, length: 24, style: 'BOLD' }],
|
|
27
|
+
entityRanges: [{ offset: 0, length: 24, key: 0 }],
|
|
28
|
+
data: {},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
entityMap: {
|
|
32
|
+
'0': {
|
|
33
|
+
type: 'EUREKA',
|
|
34
|
+
mutability: 'IMMUTABLE',
|
|
35
|
+
data: {
|
|
36
|
+
type: 'ENTITYVALUES',
|
|
37
|
+
idEntity: '6400adf810f16b8b68c24e72',
|
|
38
|
+
renderType: 'INLINE',
|
|
39
|
+
block: {
|
|
40
|
+
key: '2522g',
|
|
41
|
+
type: 'unstyled',
|
|
42
|
+
text: 'Razón social (Proveedor)',
|
|
43
|
+
depth: 0,
|
|
44
|
+
inlineStyleRanges: [{ offset: 0, length: 24, style: 'BOLD' }],
|
|
45
|
+
entityRanges: [{ offset: 0, length: 24, key: 0 }],
|
|
46
|
+
data: {},
|
|
47
|
+
},
|
|
48
|
+
entityMap: {
|
|
49
|
+
'0': {
|
|
50
|
+
type: 'EUREKA',
|
|
51
|
+
mutability: 'IMMUTABLE',
|
|
52
|
+
data: {
|
|
53
|
+
type: 'ENTITYVALUE_MAPPING',
|
|
54
|
+
idEntity: '6400adf810f16b8b68c24e72',
|
|
55
|
+
idProperty: 'NombreCompleto',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
'TEXTINPUT-lCmhOv5hYA': {
|
|
65
|
+
id: 'TEXTINPUT-lCmhOv5hYA',
|
|
66
|
+
type: 'TEXTINPUT',
|
|
67
|
+
label: 'name',
|
|
68
|
+
description: '',
|
|
69
|
+
required: false,
|
|
70
|
+
size: 2,
|
|
71
|
+
isSubject: false,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
size: {
|
|
75
|
+
blockNum: 4,
|
|
76
|
+
blockSize: 210,
|
|
77
|
+
spacingSize: 20,
|
|
78
|
+
},
|
|
79
|
+
rootSteps: ['TITLE-NkSFXOcH-z', 'TEXTINPUT-lCmhOv5hYA'],
|
|
80
|
+
label: 'Enviar',
|
|
81
|
+
firstSection: 'FIRST',
|
|
82
|
+
sections: {
|
|
83
|
+
FIRST: {
|
|
84
|
+
id: 'FIRST',
|
|
85
|
+
steps: ['TITLE-NkSFXOcH-z', 'TEXTINPUT-lCmhOv5hYA'],
|
|
86
|
+
name: '',
|
|
87
|
+
nextSection: null,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
/** The same form already parsed: drafts are plain text, no pending entities. */
|
|
92
|
+
const parsedForm = {
|
|
93
|
+
...preParsedForm,
|
|
94
|
+
steps: {
|
|
95
|
+
...preParsedForm.steps,
|
|
96
|
+
'TITLE-NkSFXOcH-z': {
|
|
97
|
+
id: 'TITLE-NkSFXOcH-z',
|
|
98
|
+
type: 'TITLE',
|
|
99
|
+
title: {
|
|
100
|
+
blocks: [
|
|
101
|
+
{
|
|
102
|
+
key: '2ri0w',
|
|
103
|
+
type: 'unstyled',
|
|
104
|
+
text: 'Razón social (Proveedor)',
|
|
105
|
+
depth: 0,
|
|
106
|
+
inlineStyleRanges: [{ offset: 0, length: 24, style: 'BOLD' }],
|
|
107
|
+
entityRanges: [],
|
|
108
|
+
data: {},
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
entityMap: {},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
const exampleValues = {
|
|
117
|
+
'TEXTINPUT-lCmhOv5hYA': 'Capta S.A.S.',
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Local replacement for the backend `/draft/mapFormEntities` call: resolves a
|
|
121
|
+
* draft by dropping its EUREKA entities and keeping the literal text, so
|
|
122
|
+
* pre-parsed forms render in Storybook without a server.
|
|
123
|
+
*/
|
|
124
|
+
function makeStoryMapDraftEntities(form) {
|
|
125
|
+
return (property) => {
|
|
126
|
+
const path = property.split('.');
|
|
127
|
+
const stepProperty = path.pop();
|
|
128
|
+
const idStep = path[0];
|
|
129
|
+
const step = form.steps[idStep];
|
|
130
|
+
const draft = stepProperty ? step?.[stepProperty] : undefined;
|
|
131
|
+
if (!draft)
|
|
132
|
+
return Promise.reject(new Error(`Storybook mapDraftEntities: draft not found for "${property}"`));
|
|
133
|
+
return Promise.resolve({
|
|
134
|
+
blocks: draft.blocks.map((block) => ({ ...block, entityRanges: [] })),
|
|
135
|
+
entityMap: {},
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function FullHeight(Story) {
|
|
140
|
+
return (_jsx("div", { style: { height: '100vh', display: 'flex', flexDirection: 'column' }, children: _jsx(Story, {}) }));
|
|
141
|
+
}
|
|
142
|
+
const meta = {
|
|
143
|
+
title: 'Form/FormRenderer',
|
|
144
|
+
component: App,
|
|
145
|
+
decorators: [FullHeight],
|
|
146
|
+
parameters: { layout: 'fullscreen' },
|
|
147
|
+
args: {
|
|
148
|
+
isWidget: false,
|
|
149
|
+
idOrganization: 'storybook',
|
|
150
|
+
valuesData: {},
|
|
151
|
+
customSubmit: (values) => {
|
|
152
|
+
// eslint-disable-next-line no-console
|
|
153
|
+
console.log('Storybook submit:', values);
|
|
154
|
+
return Promise.resolve();
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
export default meta;
|
|
159
|
+
/** Parsed form, as the widget receives it from the API. */
|
|
160
|
+
export const Parseado = {
|
|
161
|
+
args: {
|
|
162
|
+
formData: parsedForm,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Regression: TITLE whose title draft has an INTEGRATION entity parameterized by a
|
|
167
|
+
* TEXTINPUT step (`dependencies: [idStep]`). Mimics the backend contract of
|
|
168
|
+
* `/draft/mapFormEntities` (`keepNotMapped`): with the dependency unset the entity
|
|
169
|
+
* can't resolve and comes back untouched; with a value the text is resolved and the
|
|
170
|
+
* entity dropped. Production crashed with React #185 (max update depth) on render.
|
|
171
|
+
*/
|
|
172
|
+
const integrationTitleForm = {
|
|
173
|
+
steps: {
|
|
174
|
+
'TITLE-w4yCyiB1LM': {
|
|
175
|
+
id: 'TITLE-w4yCyiB1LM',
|
|
176
|
+
type: 'TITLE',
|
|
177
|
+
dependencies: ['TEXTINPUT-bwKwg_jKzD'],
|
|
178
|
+
description: {
|
|
179
|
+
blocks: [
|
|
180
|
+
{
|
|
181
|
+
depth: 0,
|
|
182
|
+
data: {},
|
|
183
|
+
inlineStyleRanges: [],
|
|
184
|
+
text: '',
|
|
185
|
+
type: 'unstyled',
|
|
186
|
+
key: '3hfq7',
|
|
187
|
+
entityRanges: [],
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
entityMap: {},
|
|
191
|
+
},
|
|
192
|
+
title: {
|
|
193
|
+
blocks: [
|
|
194
|
+
{
|
|
195
|
+
depth: 0,
|
|
196
|
+
data: {},
|
|
197
|
+
inlineStyleRanges: [{ offset: 7, length: 31, style: 'BOLD' }],
|
|
198
|
+
text: 'Título Test Draft Integration Con Step ',
|
|
199
|
+
type: 'unstyled',
|
|
200
|
+
key: '0',
|
|
201
|
+
entityRanges: [{ offset: 7, length: 31, key: 0 }],
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
entityMap: {
|
|
205
|
+
'0': {
|
|
206
|
+
type: 'EUREKA',
|
|
207
|
+
mutability: 'IMMUTABLE',
|
|
208
|
+
data: {
|
|
209
|
+
type: 'INTEGRATION',
|
|
210
|
+
idIntegration: '6960368e749b73499854bcac',
|
|
211
|
+
values: { param: { type: 'STEP', idStep: 'TEXTINPUT-bwKwg_jKzD' } },
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
'TEXTINPUT-bwKwg_jKzD': {
|
|
218
|
+
id: 'TEXTINPUT-bwKwg_jKzD',
|
|
219
|
+
type: 'TEXTINPUT',
|
|
220
|
+
label: 'Campo',
|
|
221
|
+
description: '',
|
|
222
|
+
required: false,
|
|
223
|
+
size: 2,
|
|
224
|
+
isSubject: false,
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
size: { blockNum: 4, blockSize: 210, spacingSize: 20 },
|
|
228
|
+
rootSteps: ['TITLE-w4yCyiB1LM', 'TEXTINPUT-bwKwg_jKzD'],
|
|
229
|
+
label: 'Enviar',
|
|
230
|
+
firstSection: 'FIRST',
|
|
231
|
+
sections: {
|
|
232
|
+
FIRST: {
|
|
233
|
+
id: 'FIRST',
|
|
234
|
+
steps: ['TITLE-w4yCyiB1LM', 'TEXTINPUT-bwKwg_jKzD'],
|
|
235
|
+
name: '',
|
|
236
|
+
nextSection: null,
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
function makeIntegrationMapDraftEntities(form) {
|
|
241
|
+
return (property, dependencies) => {
|
|
242
|
+
const path = property.split('.');
|
|
243
|
+
const stepProperty = path.pop();
|
|
244
|
+
const idStep = path[0];
|
|
245
|
+
const step = form.steps[idStep];
|
|
246
|
+
const draft = stepProperty ? step?.[stepProperty] : undefined;
|
|
247
|
+
if (!draft)
|
|
248
|
+
return Promise.reject(new Error(`Storybook mapDraftEntities: draft not found for "${property}"`));
|
|
249
|
+
const depValue = dependencies['TEXTINPUT-bwKwg_jKzD'];
|
|
250
|
+
// Unresolvable integration (dependency null): keepNotMapped — return the draft as-is.
|
|
251
|
+
if (depValue == null || depValue === '')
|
|
252
|
+
return Promise.resolve(JSON.parse(JSON.stringify(draft)));
|
|
253
|
+
// Resolved: replace each entity range with the integration result, drop the entities.
|
|
254
|
+
return Promise.resolve({
|
|
255
|
+
blocks: draft.blocks.map((block) => {
|
|
256
|
+
let text = block.text;
|
|
257
|
+
for (const range of [...block.entityRanges].sort((a, b) => b.offset - a.offset)) {
|
|
258
|
+
const chars = [...text];
|
|
259
|
+
chars.splice(range.offset, range.length, ...`[${depValue}]`);
|
|
260
|
+
text = chars.join('');
|
|
261
|
+
}
|
|
262
|
+
return { ...block, text, entityRanges: [], inlineStyleRanges: [] };
|
|
263
|
+
}),
|
|
264
|
+
entityMap: {},
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
/** TITLE with an INTEGRATION entity depending on a TEXTINPUT step. */
|
|
269
|
+
export const IntegracionConStepDependencia = {
|
|
270
|
+
args: {
|
|
271
|
+
formData: integrationTitleForm,
|
|
272
|
+
mapDraftEntities: makeIntegrationMapDraftEntities(integrationTitleForm),
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
/** Parsed form pre-filled with values. */
|
|
276
|
+
export const ParseadoConValores = {
|
|
277
|
+
args: {
|
|
278
|
+
formData: parsedForm,
|
|
279
|
+
valuesData: exampleValues,
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
/** Raw builder form: EUREKA entities resolved locally via mapDraftEntities. */
|
|
283
|
+
export const PreParseado = {
|
|
284
|
+
args: {
|
|
285
|
+
formData: preParsedForm,
|
|
286
|
+
mapDraftEntities: makeStoryMapDraftEntities(preParsedForm),
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
/** Final view (postview): what the user submitted, rendered read-only. */
|
|
290
|
+
export const Postview = {
|
|
291
|
+
args: {
|
|
292
|
+
formData: parsedForm,
|
|
293
|
+
valuesData: exampleValues,
|
|
294
|
+
postview: true,
|
|
295
|
+
internal: true,
|
|
296
|
+
editable: false,
|
|
297
|
+
},
|
|
298
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { composeStories } from '@storybook/react-vite';
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
import '@testing-library/jest-dom';
|
|
7
|
+
import * as stories from './App.stories';
|
|
8
|
+
const { Parseado, ParseadoConValores, PreParseado, Postview, IntegracionConStepDependencia } = composeStories(stories);
|
|
9
|
+
describe('FormRenderer stories', () => {
|
|
10
|
+
it('renders the parsed form with its title and input', async () => {
|
|
11
|
+
const { container } = render(_jsx(Parseado, {}));
|
|
12
|
+
await waitFor(() => {
|
|
13
|
+
expect(container.textContent).toContain('Razón social');
|
|
14
|
+
});
|
|
15
|
+
expect(screen.getAllByText('name').length).toBeGreaterThan(0);
|
|
16
|
+
});
|
|
17
|
+
it('renders the parsed form pre-filled with values', async () => {
|
|
18
|
+
render(_jsx(ParseadoConValores, {}));
|
|
19
|
+
await waitFor(() => {
|
|
20
|
+
expect(screen.getByDisplayValue('Capta S.A.S.')).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
it('renders the pre-parsed form resolving EUREKA entities locally', async () => {
|
|
24
|
+
const { container } = render(_jsx(PreParseado, {}));
|
|
25
|
+
await waitFor(() => {
|
|
26
|
+
expect(container.textContent).toContain('Razón social');
|
|
27
|
+
});
|
|
28
|
+
expect(screen.getAllByText('name').length).toBeGreaterThan(0);
|
|
29
|
+
});
|
|
30
|
+
it('renders the postview with the submitted value', async () => {
|
|
31
|
+
render(_jsx(Postview, {}));
|
|
32
|
+
await waitFor(() => {
|
|
33
|
+
expect(screen.getByDisplayValue('Capta S.A.S.')).toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
it('renders a title with an INTEGRATION entity depending on a step and reacts to typing', async () => {
|
|
37
|
+
const { container } = render(_jsx(IntegracionConStepDependencia, {}));
|
|
38
|
+
await waitFor(() => {
|
|
39
|
+
expect(container.textContent).toContain('Título');
|
|
40
|
+
});
|
|
41
|
+
const input = await screen.findByRole('textbox');
|
|
42
|
+
await userEvent.type(input, 'hola');
|
|
43
|
+
// The dependency dispatch is debounced (1s), so give the refetch room to land.
|
|
44
|
+
await waitFor(() => {
|
|
45
|
+
expect(container.textContent).toContain('[hola]');
|
|
46
|
+
}, { timeout: 5000 });
|
|
47
|
+
// Changing the dependency AFTER the first resolution must re-map the title:
|
|
48
|
+
// the stored value is a mapped copy with its entities stripped, so mapping
|
|
49
|
+
// has to keep keying off the original step draft.
|
|
50
|
+
await userEvent.clear(input);
|
|
51
|
+
await userEvent.type(input, 'chao');
|
|
52
|
+
await waitFor(() => {
|
|
53
|
+
expect(container.textContent).toContain('[chao]');
|
|
54
|
+
}, { timeout: 5000 });
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -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;
|