@arquimedes.co/eureka-forms 3.0.68-test → 3.0.69
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/README +33 -1
- 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 +197 -0
- package/dist/@Types/BookingFormStep.js +44 -0
- package/dist/@Types/CalendarFormStep.d.ts +209 -0
- package/dist/@Types/CalendarFormStep.js +55 -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 +10 -0
- package/dist/App/App.stories.js +189 -0
- package/dist/App/AppHooks.js +8 -0
- package/dist/App/AppHooks.test.js +8 -0
- package/dist/Form/Form.js +7 -6
- package/dist/Form/FormFunctions.d.ts +17 -0
- package/dist/Form/FormFunctions.js +22 -0
- package/dist/Form/FormFunctions.test.js +28 -1
- package/dist/FormSteps/AvailabilityStep/AvailabilityStep.d.ts +7 -0
- package/dist/FormSteps/AvailabilityStep/AvailabilityStep.js +14 -0
- package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.d.ts +8 -0
- package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.js +32 -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 +14 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +129 -0
- package/dist/FormSteps/CheckBoxStep/CheckBoxStep.mobileLabel.test.js +20 -12
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +6 -13
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +2 -13
- package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.d.ts +1 -0
- package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.js +70 -0
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +3 -1
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +26 -26
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.d.ts +12 -0
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.js +35 -0
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.test.d.ts +1 -0
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.test.js +31 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.d.ts +27 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.js +64 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.d.ts +1 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.js +95 -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 +54 -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 +170 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +96 -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/StepHooks.d.ts +21 -0
- package/dist/FormSteps/StepHooks.js +55 -8
- package/dist/FormSteps/StepHooks.test.d.ts +1 -0
- package/dist/FormSteps/StepHooks.test.js +92 -0
- package/dist/FormSteps/isStepHiddenByCondition.test.d.ts +1 -0
- package/dist/FormSteps/isStepHiddenByCondition.test.js +42 -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/Services/BookingService.d.ts +79 -0
- package/dist/Services/BookingService.js +66 -0
- package/dist/Services/BookingService.test.d.ts +1 -0
- package/dist/Services/BookingService.test.js +57 -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 +88 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +29 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +139 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.d.ts +25 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.js +112 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.module.css +88 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.d.ts +1 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.js +73 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.d.ts +52 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.js +292 -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 +157 -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/ErkIconButton/ErkIconButton.d.ts +17 -0
- package/dist/Shared/ErkIconButton/ErkIconButton.js +11 -0
- package/dist/Shared/ErkIconButton/ErkIconButton.module.css +41 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +24 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.js +128 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.module.css +164 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.test.d.ts +1 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.test.js +82 -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 +128 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +42 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.js +169 -0
- package/dist/Utils/AxiosWidget.js +9 -1
- 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,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NumericFormSteps types
|
|
3
|
+
* Cubre el paso relacionado con números y sus múltiples subtipos.
|
|
4
|
+
*/
|
|
5
|
+
import { GBaseStep } from './GenericFormSteps';
|
|
6
|
+
import FormStepTypes from '../constants/FormStepTypes';
|
|
7
|
+
/** Subtipo del paso numérico — discriminante secundario */
|
|
8
|
+
export declare enum NumberStepType {
|
|
9
|
+
INTEGER = "INTEGER",
|
|
10
|
+
DECIMAL = "DECIMAL",
|
|
11
|
+
PERCENTAGE = "PERCENTAGE",
|
|
12
|
+
/** Monto de dinero en una divisa (ej: 1500 COP). */
|
|
13
|
+
MONEY = "MONEY",
|
|
14
|
+
/** Magnitud con unidad de medida (ej: 5 kg). */
|
|
15
|
+
MEASURE = "MEASURE",
|
|
16
|
+
/** Precio por unidad: divisa sobre unidad (ej: 20 USD / hora). */
|
|
17
|
+
UNIT_PRICE = "UNIT_PRICE"
|
|
18
|
+
}
|
|
19
|
+
/** Campos base compartidos por todos los subtipos numéricos */
|
|
20
|
+
interface GNumberStep extends GBaseStep {
|
|
21
|
+
type: FormStepTypes.NUMBER;
|
|
22
|
+
numberType: NumberStepType;
|
|
23
|
+
label: string;
|
|
24
|
+
description: string | null;
|
|
25
|
+
required: boolean;
|
|
26
|
+
min?: number;
|
|
27
|
+
max?: number;
|
|
28
|
+
/** Cantidad de decimales permitidos (0 = entero). Default: 2 */
|
|
29
|
+
decimals?: number;
|
|
30
|
+
/** Sufijo de unidad estático que se muestra junto al valor (solo visual, no afecta el número guardado). */
|
|
31
|
+
suffix?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Mostrar u ocultar los botones +/− de incremento/decremento.
|
|
34
|
+
* Default: true
|
|
35
|
+
*/
|
|
36
|
+
spinner?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Tamaño de cada incremento/decremento al usar los botones o las flechas del teclado.
|
|
39
|
+
* Útil para monedas (0.01), cantidades grandes (100) o porcentajes (5).
|
|
40
|
+
* Default: 1
|
|
41
|
+
*/
|
|
42
|
+
step?: number;
|
|
43
|
+
/** Texto de placeholder del campo numérico. */
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
size: 1 | 2 | 3 | 4;
|
|
46
|
+
}
|
|
47
|
+
export interface IntegerStep extends GNumberStep {
|
|
48
|
+
numberType: NumberStepType.INTEGER;
|
|
49
|
+
/** Siempre 0 para enteros, pero puede dejarse undefined */
|
|
50
|
+
decimals?: 0;
|
|
51
|
+
defaultValue?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface DecimalStep extends GNumberStep {
|
|
54
|
+
numberType: NumberStepType.DECIMAL;
|
|
55
|
+
defaultValue?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface PercentageStep extends GNumberStep {
|
|
58
|
+
numberType: NumberStepType.PERCENTAGE;
|
|
59
|
+
defaultValue?: number;
|
|
60
|
+
}
|
|
61
|
+
export interface MoneyStep extends GNumberStep {
|
|
62
|
+
numberType: NumberStepType.MONEY;
|
|
63
|
+
/** Moneda fija (ej: "COP", "USD", "EUR") */
|
|
64
|
+
currency?: string;
|
|
65
|
+
allowCurrencyChange?: boolean;
|
|
66
|
+
availableCurrencies?: string[];
|
|
67
|
+
defaultValue?: MoneyValue | null;
|
|
68
|
+
}
|
|
69
|
+
export interface MeasureStep extends GNumberStep {
|
|
70
|
+
numberType: NumberStepType.MEASURE;
|
|
71
|
+
/** Unidad fija (ej: "kg", "m", "hrs") */
|
|
72
|
+
unit?: string;
|
|
73
|
+
allowUnitChange?: boolean;
|
|
74
|
+
availableUnits?: string[];
|
|
75
|
+
defaultValue?: MeasureValue | null;
|
|
76
|
+
}
|
|
77
|
+
export interface UnitPriceStep extends GNumberStep {
|
|
78
|
+
numberType: NumberStepType.UNIT_PRICE;
|
|
79
|
+
/** Moneda del precio (ej: "USD") */
|
|
80
|
+
currency?: string;
|
|
81
|
+
/** Unidad base del precio (ej: "hrs", "km", "mes") */
|
|
82
|
+
unit?: string;
|
|
83
|
+
allowCurrencyChange?: boolean;
|
|
84
|
+
allowUnitChange?: boolean;
|
|
85
|
+
availableCurrencies?: string[];
|
|
86
|
+
availableUnits?: string[];
|
|
87
|
+
defaultValue?: UnitPriceValue | null;
|
|
88
|
+
}
|
|
89
|
+
/** Unión discriminada del paso NUMBER — narrowing por numberType */
|
|
90
|
+
export type NumberStep = IntegerStep | DecimalStep | PercentageStep | MoneyStep | MeasureStep | UnitPriceStep;
|
|
91
|
+
export type IntegerValue = number;
|
|
92
|
+
export type DecimalValue = number;
|
|
93
|
+
export type PercentageValue = number;
|
|
94
|
+
export interface MoneyValue {
|
|
95
|
+
value: number;
|
|
96
|
+
currency: string;
|
|
97
|
+
}
|
|
98
|
+
export interface MeasureValue {
|
|
99
|
+
value: number;
|
|
100
|
+
unit: string;
|
|
101
|
+
}
|
|
102
|
+
export interface UnitPriceValue {
|
|
103
|
+
value: number;
|
|
104
|
+
currency: string;
|
|
105
|
+
unit: string;
|
|
106
|
+
}
|
|
107
|
+
export type NumberStepValue = number | MoneyValue | MeasureValue | UnitPriceValue;
|
|
108
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NumericFormSteps types
|
|
3
|
+
* Cubre el paso relacionado con números y sus múltiples subtipos.
|
|
4
|
+
*/
|
|
5
|
+
// ===========================================================================
|
|
6
|
+
// NUMBER
|
|
7
|
+
// ===========================================================================
|
|
8
|
+
/** Subtipo del paso numérico — discriminante secundario */
|
|
9
|
+
export var NumberStepType;
|
|
10
|
+
(function (NumberStepType) {
|
|
11
|
+
NumberStepType["INTEGER"] = "INTEGER";
|
|
12
|
+
NumberStepType["DECIMAL"] = "DECIMAL";
|
|
13
|
+
NumberStepType["PERCENTAGE"] = "PERCENTAGE";
|
|
14
|
+
/** Monto de dinero en una divisa (ej: 1500 COP). */
|
|
15
|
+
NumberStepType["MONEY"] = "MONEY";
|
|
16
|
+
/** Magnitud con unidad de medida (ej: 5 kg). */
|
|
17
|
+
NumberStepType["MEASURE"] = "MEASURE";
|
|
18
|
+
/** Precio por unidad: divisa sobre unidad (ej: 20 USD / hora). */
|
|
19
|
+
NumberStepType["UNIT_PRICE"] = "UNIT_PRICE";
|
|
20
|
+
})(NumberStepType || (NumberStepType = {}));
|
|
@@ -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
|
+
}
|
|
@@ -28,3 +28,13 @@ export declare const ParseadoConValores: Story;
|
|
|
28
28
|
export declare const PreParseado: Story;
|
|
29
29
|
/** Final view (postview): what the user submitted, rendered read-only. */
|
|
30
30
|
export declare const Postview: Story;
|
|
31
|
+
/**
|
|
32
|
+
* Every checkbox variant in one form: sizes 1–4, required, description, list mode, long
|
|
33
|
+
* labels, nested `steps` / `uncheckedSteps`, and a checkbox inside a collapsible. Resize the
|
|
34
|
+
* preview below ~900px to see the collapsed label mode (100% width, 1-line clamp, "ver más").
|
|
35
|
+
* Inside the collapsible, close/reopen it and then check the checkbox to reproduce the clipped
|
|
36
|
+
* nested steps.
|
|
37
|
+
*/
|
|
38
|
+
export declare const Checkboxes: Story;
|
|
39
|
+
/** Same checkboxes form in postview, read-only. */
|
|
40
|
+
export declare const CheckboxesPostview: Story;
|
package/dist/App/App.stories.js
CHANGED
|
@@ -296,3 +296,192 @@ export const Postview = {
|
|
|
296
296
|
editable: false,
|
|
297
297
|
},
|
|
298
298
|
};
|
|
299
|
+
// ---------------------------------------------------------------------------------------------
|
|
300
|
+
// Checkboxes: a full form exercising every checkbox variant side by side (sizes, required,
|
|
301
|
+
// description, list mode, long label, nested steps, uncheckedSteps and a checkbox inside a
|
|
302
|
+
// collapsible). Resize the preview to see the collapsed (100% width, 1-line clamp) label mode.
|
|
303
|
+
// ---------------------------------------------------------------------------------------------
|
|
304
|
+
const cbTextInput = (id, label, size = 2) => ({
|
|
305
|
+
id,
|
|
306
|
+
type: 'TEXTINPUT',
|
|
307
|
+
label,
|
|
308
|
+
description: '',
|
|
309
|
+
required: false,
|
|
310
|
+
size,
|
|
311
|
+
isSubject: false,
|
|
312
|
+
});
|
|
313
|
+
const checkboxesForm = {
|
|
314
|
+
steps: {
|
|
315
|
+
'CHECKBOX-size-1': {
|
|
316
|
+
id: 'CHECKBOX-size-1',
|
|
317
|
+
type: 'CHECKBOX',
|
|
318
|
+
label: 'Tamaño 1',
|
|
319
|
+
description: null,
|
|
320
|
+
required: false,
|
|
321
|
+
size: 1,
|
|
322
|
+
},
|
|
323
|
+
'CHECKBOX-size-2': {
|
|
324
|
+
id: 'CHECKBOX-size-2',
|
|
325
|
+
type: 'CHECKBOX',
|
|
326
|
+
label: 'Tamaño 2 con descripción',
|
|
327
|
+
description: 'Texto de ayuda debajo del checkbox.',
|
|
328
|
+
required: false,
|
|
329
|
+
size: 2,
|
|
330
|
+
},
|
|
331
|
+
'CHECKBOX-size-1-required': {
|
|
332
|
+
id: 'CHECKBOX-size-1-required',
|
|
333
|
+
type: 'CHECKBOX',
|
|
334
|
+
label: 'Obligatorio',
|
|
335
|
+
description: null,
|
|
336
|
+
required: true,
|
|
337
|
+
size: 1,
|
|
338
|
+
},
|
|
339
|
+
'CHECKBOX-size-3': {
|
|
340
|
+
id: 'CHECKBOX-size-3',
|
|
341
|
+
type: 'CHECKBOX',
|
|
342
|
+
label: 'Tamaño 3 con un label bastante largo que en escritorio se corta con puntos suspensivos',
|
|
343
|
+
description: null,
|
|
344
|
+
required: false,
|
|
345
|
+
size: 3,
|
|
346
|
+
},
|
|
347
|
+
'CHECKBOX-size-1-checked': {
|
|
348
|
+
id: 'CHECKBOX-size-1-checked',
|
|
349
|
+
type: 'CHECKBOX',
|
|
350
|
+
label: 'Marcado',
|
|
351
|
+
description: null,
|
|
352
|
+
required: false,
|
|
353
|
+
size: 1,
|
|
354
|
+
defaultValue: true,
|
|
355
|
+
},
|
|
356
|
+
'CHECKBOX-size-4': {
|
|
357
|
+
id: 'CHECKBOX-size-4',
|
|
358
|
+
type: 'CHECKBOX',
|
|
359
|
+
label: 'Tamaño 4 (ancho completo): confirmo que la información suministrada es veraz, que he leído la ' +
|
|
360
|
+
'política de tratamiento de datos personales y autorizo el uso de mis datos para los fines ' +
|
|
361
|
+
'descritos en el presente formulario',
|
|
362
|
+
description: null,
|
|
363
|
+
required: true,
|
|
364
|
+
size: 4,
|
|
365
|
+
},
|
|
366
|
+
'CHECKBOX-list': {
|
|
367
|
+
id: 'CHECKBOX-list',
|
|
368
|
+
type: 'CHECKBOX',
|
|
369
|
+
label: 'Modo lista (isList): el checkbox va antes del label y sin dos puntos',
|
|
370
|
+
description: null,
|
|
371
|
+
required: false,
|
|
372
|
+
size: 4,
|
|
373
|
+
isList: true,
|
|
374
|
+
},
|
|
375
|
+
'CHECKBOX-nested': {
|
|
376
|
+
id: 'CHECKBOX-nested',
|
|
377
|
+
type: 'CHECKBOX',
|
|
378
|
+
label: '¿Desea agregar una dirección de envío distinta?',
|
|
379
|
+
description: 'Al marcarlo aparecen los campos de la dirección.',
|
|
380
|
+
required: false,
|
|
381
|
+
size: 4,
|
|
382
|
+
steps: ['TEXTINPUT-shipping-address', 'TEXTINPUT-shipping-city'],
|
|
383
|
+
},
|
|
384
|
+
'TEXTINPUT-shipping-address': cbTextInput('TEXTINPUT-shipping-address', 'Dirección de envío', 2),
|
|
385
|
+
'TEXTINPUT-shipping-city': cbTextInput('TEXTINPUT-shipping-city', 'Ciudad', 2),
|
|
386
|
+
'CHECKBOX-unchecked-steps': {
|
|
387
|
+
id: 'CHECKBOX-unchecked-steps',
|
|
388
|
+
type: 'CHECKBOX',
|
|
389
|
+
label: 'Usar los datos de contacto registrados',
|
|
390
|
+
description: 'Al desmarcarlo aparecen los campos de contacto (uncheckedSteps).',
|
|
391
|
+
required: false,
|
|
392
|
+
size: 4,
|
|
393
|
+
defaultValue: true,
|
|
394
|
+
uncheckedSteps: ['TEXTINPUT-contact-phone', 'TEXTINPUT-contact-email'],
|
|
395
|
+
},
|
|
396
|
+
'TEXTINPUT-contact-phone': cbTextInput('TEXTINPUT-contact-phone', 'Teléfono', 2),
|
|
397
|
+
'TEXTINPUT-contact-email': cbTextInput('TEXTINPUT-contact-email', 'Correo', 2),
|
|
398
|
+
'COLLAPSIBLE-checkbox': {
|
|
399
|
+
id: 'COLLAPSIBLE-checkbox',
|
|
400
|
+
type: 'COLLAPSIBLE',
|
|
401
|
+
label: 'Colapsable con checkbox anidado',
|
|
402
|
+
defaultValue: true,
|
|
403
|
+
steps: ['CHECKBOX-in-collapsible'],
|
|
404
|
+
},
|
|
405
|
+
'CHECKBOX-in-collapsible': {
|
|
406
|
+
id: 'CHECKBOX-in-collapsible',
|
|
407
|
+
type: 'CHECKBOX',
|
|
408
|
+
label: '¿Desea agregar información adicional?',
|
|
409
|
+
description: null,
|
|
410
|
+
required: false,
|
|
411
|
+
size: 4,
|
|
412
|
+
steps: ['TEXTINPUT-extra-1', 'TEXTINPUT-extra-2'],
|
|
413
|
+
},
|
|
414
|
+
'TEXTINPUT-extra-1': cbTextInput('TEXTINPUT-extra-1', 'Información adicional 1', 2),
|
|
415
|
+
'TEXTINPUT-extra-2': cbTextInput('TEXTINPUT-extra-2', 'Información adicional 2', 2),
|
|
416
|
+
},
|
|
417
|
+
size: { blockNum: 4, blockSize: 210, spacingSize: 20 },
|
|
418
|
+
rootSteps: [
|
|
419
|
+
'CHECKBOX-size-1',
|
|
420
|
+
'CHECKBOX-size-2',
|
|
421
|
+
'CHECKBOX-size-1-required',
|
|
422
|
+
'CHECKBOX-size-3',
|
|
423
|
+
'CHECKBOX-size-1-checked',
|
|
424
|
+
'CHECKBOX-size-4',
|
|
425
|
+
'CHECKBOX-list',
|
|
426
|
+
'CHECKBOX-nested',
|
|
427
|
+
'CHECKBOX-unchecked-steps',
|
|
428
|
+
'COLLAPSIBLE-checkbox',
|
|
429
|
+
],
|
|
430
|
+
label: 'Enviar',
|
|
431
|
+
firstSection: 'FIRST',
|
|
432
|
+
sections: {
|
|
433
|
+
FIRST: {
|
|
434
|
+
id: 'FIRST',
|
|
435
|
+
steps: [
|
|
436
|
+
'CHECKBOX-size-1',
|
|
437
|
+
'CHECKBOX-size-2',
|
|
438
|
+
'CHECKBOX-size-1-required',
|
|
439
|
+
'CHECKBOX-size-3',
|
|
440
|
+
'CHECKBOX-size-1-checked',
|
|
441
|
+
'CHECKBOX-size-4',
|
|
442
|
+
'CHECKBOX-list',
|
|
443
|
+
'CHECKBOX-nested',
|
|
444
|
+
'CHECKBOX-unchecked-steps',
|
|
445
|
+
'COLLAPSIBLE-checkbox',
|
|
446
|
+
],
|
|
447
|
+
name: '',
|
|
448
|
+
nextSection: null,
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* Every checkbox variant in one form: sizes 1–4, required, description, list mode, long
|
|
454
|
+
* labels, nested `steps` / `uncheckedSteps`, and a checkbox inside a collapsible. Resize the
|
|
455
|
+
* preview below ~900px to see the collapsed label mode (100% width, 1-line clamp, "ver más").
|
|
456
|
+
* Inside the collapsible, close/reopen it and then check the checkbox to reproduce the clipped
|
|
457
|
+
* nested steps.
|
|
458
|
+
*/
|
|
459
|
+
export const Checkboxes = {
|
|
460
|
+
args: {
|
|
461
|
+
formData: checkboxesForm,
|
|
462
|
+
},
|
|
463
|
+
};
|
|
464
|
+
/** Same checkboxes form in postview, read-only. */
|
|
465
|
+
export const CheckboxesPostview = {
|
|
466
|
+
args: {
|
|
467
|
+
formData: checkboxesForm,
|
|
468
|
+
valuesData: {
|
|
469
|
+
'CHECKBOX-size-1': true,
|
|
470
|
+
'CHECKBOX-size-2': false,
|
|
471
|
+
'CHECKBOX-size-1-required': true,
|
|
472
|
+
'CHECKBOX-size-3': true,
|
|
473
|
+
'CHECKBOX-size-1-checked': true,
|
|
474
|
+
'CHECKBOX-size-4': true,
|
|
475
|
+
'CHECKBOX-list': true,
|
|
476
|
+
'CHECKBOX-nested': true,
|
|
477
|
+
'TEXTINPUT-shipping-address': 'Calle 123 # 45-67',
|
|
478
|
+
'TEXTINPUT-shipping-city': 'Bogotá',
|
|
479
|
+
'CHECKBOX-unchecked-steps': true,
|
|
480
|
+
'COLLAPSIBLE-checkbox': true,
|
|
481
|
+
'CHECKBOX-in-collapsible': false,
|
|
482
|
+
},
|
|
483
|
+
postview: true,
|
|
484
|
+
internal: true,
|
|
485
|
+
editable: false,
|
|
486
|
+
},
|
|
487
|
+
};
|
package/dist/App/AppHooks.js
CHANGED
|
@@ -158,6 +158,14 @@ export const useSetupApp = (isEmbedded, props) => {
|
|
|
158
158
|
idCurrentAgent,
|
|
159
159
|
handleConfirmed,
|
|
160
160
|
]);
|
|
161
|
+
// The host may resolve the classifiers asynchronously (the admin fetches them while the form is
|
|
162
|
+
// already mounted). `loadData` only copies the prop it saw when it ran, so patch the form whenever a
|
|
163
|
+
// new dictionary arrives — without re-running the load, which would reset what the user typed.
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
if (!classifiers || !form || form.classifiers === classifiers)
|
|
166
|
+
return;
|
|
167
|
+
setForm({ ...form, classifiers });
|
|
168
|
+
}, [classifiers, form]);
|
|
161
169
|
const reload = useCallback(() => {
|
|
162
170
|
if (!form)
|
|
163
171
|
return;
|
|
@@ -81,6 +81,14 @@ describe('AppHooks', function () {
|
|
|
81
81
|
expect(result.current.organization).toBeNull();
|
|
82
82
|
expect(result.current.branding).toBeUndefined();
|
|
83
83
|
});
|
|
84
|
+
test('picks up classifiers that arrive after the first render', async () => {
|
|
85
|
+
const classifier = { _id: 'tipo', name: 'Tipo de solicitud', children: [] };
|
|
86
|
+
const { result, rerender } = renderHookWithProviders((props) => useSetupApp(false, { formData: BaseForm, internal: true, classifiers: props.classifiers }), { initialProps: { classifiers: {} } });
|
|
87
|
+
await waitFor(() => expect(result.current.form).toBeTruthy());
|
|
88
|
+
expect(result.current.form?.classifiers).toEqual({});
|
|
89
|
+
rerender({ classifiers: { tipo: classifier } });
|
|
90
|
+
await waitFor(() => expect(result.current.form?.classifiers?.tipo).toEqual(classifier));
|
|
91
|
+
});
|
|
84
92
|
test('Apikey Default', async () => {
|
|
85
93
|
mocks.get.mockImplementation((a) => {
|
|
86
94
|
if (a === '/organization') {
|
package/dist/Form/Form.js
CHANGED
|
@@ -6,7 +6,7 @@ import InternalFormStyle from '../constants/InternalFormStyle';
|
|
|
6
6
|
import ColumnForm from './FormTypes/ColumnForm/ColumnForm';
|
|
7
7
|
import StepperForm from './FormTypes/StepperForm/StepperForm';
|
|
8
8
|
import { FormStyleTypes, FormTypes } from '../constants/FormStepTypes';
|
|
9
|
-
import { calcValue } from './FormFunctions';
|
|
9
|
+
import { calcValue, resolveCaptchaToken } from './FormFunctions';
|
|
10
10
|
import { FormProvider, useForm } from 'react-hook-form';
|
|
11
11
|
import widgetInstance from '../Utils/AxiosWidget';
|
|
12
12
|
import axiosInstance from '../Utils/AxiosAPI';
|
|
@@ -38,15 +38,16 @@ function FormComponent({ form, apiKey, reload, isWidget, branding, setSubmit, sc
|
|
|
38
38
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
39
|
}, [idFocusStep]);
|
|
40
40
|
const onSubmit = useCallback(async (values) => {
|
|
41
|
-
let token = null;
|
|
42
|
-
if (form.hasCaptcha && !internal && !customSubmit) {
|
|
43
|
-
token = recaptchaRef.current?.getValue();
|
|
44
|
-
token ?? (token = await recaptchaRef?.current.executeAsync());
|
|
45
|
-
}
|
|
46
41
|
const ApiKey = internal ? form.apiKey : apiKey;
|
|
47
42
|
if (!ApiKey && !customSubmit && !customSubmitBtns)
|
|
48
43
|
return;
|
|
49
44
|
try {
|
|
45
|
+
// Resolved inside the try so a captcha that cannot mint a token surfaces through the same
|
|
46
|
+
// error path as any other submit failure, rather than rejecting out of the handler and
|
|
47
|
+
// leaving the submitter with no feedback at all.
|
|
48
|
+
const token = form.hasCaptcha && !internal && !customSubmit
|
|
49
|
+
? await resolveCaptchaToken(recaptchaRef.current)
|
|
50
|
+
: null;
|
|
50
51
|
const state = await dispatch(getAppState({ idForm })).unwrap();
|
|
51
52
|
const newValues = {
|
|
52
53
|
...state.site.values.global,
|