@arquimedes.co/eureka-forms 3.0.51-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/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/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 +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/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,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,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 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
|
+
};
|
|
25
|
+
const { ref, value, onChange, error } = useFormStep(step, {
|
|
26
|
+
defaultValue: null,
|
|
27
|
+
rules: { required: step.required ? 'Selecciona una cita' : undefined },
|
|
28
|
+
});
|
|
29
|
+
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 }) }));
|
|
30
|
+
}
|
|
31
|
+
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,269 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useState, useCallback, useRef, useMemo } from 'react';
|
|
3
|
+
import { startOfWeek, endOfWeek, addWeeks, addDays, addMonths, startOfMonth, endOfMonth, isSameMonth, isSameDay, isToday, format, parse, startOfDay, } from 'date-fns';
|
|
4
|
+
import { es } from 'date-fns/locale';
|
|
5
|
+
import { Popover } from '@mui/material';
|
|
6
|
+
import ArrowLeftIcon from '../../../Icons/ArrowLeftIcon';
|
|
7
|
+
import ArrowRightIcon from '../../../Icons/ArrowRightIcon';
|
|
8
|
+
import ViewWeekIcon from '../../../Icons/ViewWeekIcon';
|
|
9
|
+
import ViewDayIcon from '../../../Icons/ViewDayIcon';
|
|
10
|
+
import CalendarIcon from '../../../Icons/CalendarIcon';
|
|
11
|
+
import AddIcon from '../../../Icons/AddIcon';
|
|
12
|
+
import CloseIcon from '../../../Icons/CloseIcon';
|
|
13
|
+
import DeleteIcon from '../../../Icons/DeleteIcon';
|
|
14
|
+
import { CalendarEventCategory, CalendarDefaultView, } from '../../../@Types/CalendarFormStep';
|
|
15
|
+
import { useFormStep } from '../../StepHooks';
|
|
16
|
+
import FormContext from '../../../Contexts/FormContext';
|
|
17
|
+
import { selectBreakPoint, useAppSelector } from '../../../hooks';
|
|
18
|
+
import { calcStepWidth } from '../../StepFunctions';
|
|
19
|
+
import styles from './MaterialCalendarStep.module.css';
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Constants
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
const CELL_HEIGHT = 48; // px per hour
|
|
24
|
+
const WEEK_START = 1; // Monday
|
|
25
|
+
const CATEGORY_COLORS = {
|
|
26
|
+
[CalendarEventCategory.WORKING]: '#4CAF50',
|
|
27
|
+
[CalendarEventCategory.PHYSICAL]: '#2196F3',
|
|
28
|
+
[CalendarEventCategory.VIRTUAL]: '#9C27B0',
|
|
29
|
+
[CalendarEventCategory.SPECIFIC]: '#FF9800',
|
|
30
|
+
[CalendarEventCategory.MEETING]: '#E91E63',
|
|
31
|
+
[CalendarEventCategory.BUSY]: '#607D8B',
|
|
32
|
+
[CalendarEventCategory.CUSTOM]: '#795548',
|
|
33
|
+
};
|
|
34
|
+
const CATEGORY_LABELS = {
|
|
35
|
+
[CalendarEventCategory.WORKING]: 'Trabajo',
|
|
36
|
+
[CalendarEventCategory.PHYSICAL]: 'Presencial',
|
|
37
|
+
[CalendarEventCategory.VIRTUAL]: 'Virtual',
|
|
38
|
+
[CalendarEventCategory.SPECIFIC]: 'Específico',
|
|
39
|
+
[CalendarEventCategory.MEETING]: 'Reunión',
|
|
40
|
+
[CalendarEventCategory.BUSY]: 'Ocupado',
|
|
41
|
+
[CalendarEventCategory.CUSTOM]: 'Personalizado',
|
|
42
|
+
};
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Helpers
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
function parseTime(hhmm) {
|
|
47
|
+
const [h, m] = hhmm.split(':').map(Number);
|
|
48
|
+
return { h: h ?? 0, m: m ?? 0 };
|
|
49
|
+
}
|
|
50
|
+
function toMinutes(hhmm) {
|
|
51
|
+
const { h, m } = parseTime(hhmm);
|
|
52
|
+
return h * 60 + m;
|
|
53
|
+
}
|
|
54
|
+
function minutesToHHMM(mins) {
|
|
55
|
+
const h = Math.floor(mins / 60);
|
|
56
|
+
const m = mins % 60;
|
|
57
|
+
return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
|
|
58
|
+
}
|
|
59
|
+
function isoToHHMM(iso) {
|
|
60
|
+
// "2024-06-19T09:30:00" → "09:30"
|
|
61
|
+
return iso.slice(11, 16);
|
|
62
|
+
}
|
|
63
|
+
function dateAndTimeToISO(date, hhmm) {
|
|
64
|
+
const { h, m } = parseTime(hhmm);
|
|
65
|
+
const d = new Date(date);
|
|
66
|
+
d.setHours(h, m, 0, 0);
|
|
67
|
+
return d.toISOString().slice(0, 19);
|
|
68
|
+
}
|
|
69
|
+
function isoToDate(iso) {
|
|
70
|
+
// Treat as local time (no timezone shift)
|
|
71
|
+
return parse(iso.slice(0, 19), 'yyyy-MM-dd\'T\'HH:mm:ss', new Date());
|
|
72
|
+
}
|
|
73
|
+
function newEventId() {
|
|
74
|
+
return `evt-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
|
|
75
|
+
}
|
|
76
|
+
function EventBlock({ event, minHour, template, onDelete, readOnly }) {
|
|
77
|
+
const startMins = toMinutes(isoToHHMM(event.start));
|
|
78
|
+
const endMins = toMinutes(isoToHHMM(event.end));
|
|
79
|
+
const top = (startMins - minHour * 60) * (CELL_HEIGHT / 60);
|
|
80
|
+
const height = Math.max((endMins - startMins) * (CELL_HEIGHT / 60), 18);
|
|
81
|
+
const color = template?.color ?? CATEGORY_COLORS[event.category] ?? '#607D8B';
|
|
82
|
+
const label = event.title ?? template?.name ?? CATEGORY_LABELS[event.category];
|
|
83
|
+
return (_jsxs("div", { className: styles.eventBlock, style: { top, height, backgroundColor: color }, title: `${label} ${isoToHHMM(event.start)}–${isoToHHMM(event.end)}`, children: [_jsx("span", { className: styles.eventLabel, children: label }), _jsxs("span", { className: styles.eventTime, children: [isoToHHMM(event.start), "\u2013", isoToHHMM(event.end)] }), !readOnly && (_jsx("button", { type: "button", className: styles.eventDeleteBtn, onClick: (e) => { e.stopPropagation(); onDelete(event.id); }, "aria-label": "Eliminar", children: _jsx(DeleteIcon, { size: 13 }) }))] }));
|
|
84
|
+
}
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// Main component
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
function MaterialCalendarStep({ step, editable }) {
|
|
89
|
+
const currentBreakPoint = useAppSelector(selectBreakPoint);
|
|
90
|
+
const { postview } = useAppSelector((state) => state.global);
|
|
91
|
+
const form = useContext(FormContext);
|
|
92
|
+
const isReadOnly = !editable || postview;
|
|
93
|
+
const widthStyle = currentBreakPoint <= step.size ? '100%' : calcStepWidth(step.size, form.size);
|
|
94
|
+
// ------------------------------------------------------------------
|
|
95
|
+
// Resolve config
|
|
96
|
+
// ------------------------------------------------------------------
|
|
97
|
+
const minTimeStr = step.minTime ?? '00:00';
|
|
98
|
+
const maxTimeStr = step.maxTime ?? '23:00';
|
|
99
|
+
const minHour = parseTime(minTimeStr).h;
|
|
100
|
+
const maxHour = parseTime(maxTimeStr).h + 1;
|
|
101
|
+
const totalHours = maxHour - minHour;
|
|
102
|
+
const showWeekends = step.showWeekends ?? true;
|
|
103
|
+
const allowedCategories = (step.allowedCategories?.length ? step.allowedCategories : Object.values(CalendarEventCategory));
|
|
104
|
+
const defaultViewMode = (step.defaultView ?? CalendarDefaultView.WEEK);
|
|
105
|
+
// ------------------------------------------------------------------
|
|
106
|
+
// Form value
|
|
107
|
+
// ------------------------------------------------------------------
|
|
108
|
+
const { value, onChange } = useFormStep(step, {
|
|
109
|
+
defaultValue: null,
|
|
110
|
+
rules: {
|
|
111
|
+
required: step.required ? 'Este campo es obligatorio' : undefined,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
const events = useMemo(() => value?.events ?? [], [value?.events]);
|
|
115
|
+
const setEvents = useCallback((updater) => {
|
|
116
|
+
onChange({
|
|
117
|
+
type: 'CALENDAR_VALUE',
|
|
118
|
+
events: updater(events),
|
|
119
|
+
timezone: value?.timezone,
|
|
120
|
+
});
|
|
121
|
+
}, [events, value?.timezone, onChange]);
|
|
122
|
+
const deleteEvent = useCallback((id) => setEvents((prev) => prev.filter((e) => e.id !== id)), [setEvents]);
|
|
123
|
+
// ------------------------------------------------------------------
|
|
124
|
+
// Navigation state
|
|
125
|
+
// ------------------------------------------------------------------
|
|
126
|
+
const [viewMode, setViewMode] = useState(defaultViewMode);
|
|
127
|
+
const [current, setCurrent] = useState(() => startOfDay(new Date()));
|
|
128
|
+
const [createState, setCreate] = useState(null);
|
|
129
|
+
// Create form
|
|
130
|
+
const [newCategory, setNewCategory] = useState(allowedCategories[0] ?? CalendarEventCategory.WORKING);
|
|
131
|
+
const [newTitle, setNewTitle] = useState('');
|
|
132
|
+
const [newStart, setNewStart] = useState('09:00');
|
|
133
|
+
const [newEnd, setNewEnd] = useState('10:00');
|
|
134
|
+
const gridRef = useRef(null);
|
|
135
|
+
// ------------------------------------------------------------------
|
|
136
|
+
// Derived view dates
|
|
137
|
+
// ------------------------------------------------------------------
|
|
138
|
+
const weekStart = startOfWeek(current, { weekStartsOn: WEEK_START });
|
|
139
|
+
const weekEnd = endOfWeek(current, { weekStartsOn: WEEK_START });
|
|
140
|
+
const visibleDays = (() => {
|
|
141
|
+
if (viewMode === 'day')
|
|
142
|
+
return [current];
|
|
143
|
+
const days = Array.from({ length: 7 }, (_, i) => addDays(weekStart, i));
|
|
144
|
+
return showWeekends ? days : days.filter((d) => d.getDay() !== 0 && d.getDay() !== 6);
|
|
145
|
+
})();
|
|
146
|
+
// ------------------------------------------------------------------
|
|
147
|
+
// Navigate
|
|
148
|
+
// ------------------------------------------------------------------
|
|
149
|
+
const prev = () => {
|
|
150
|
+
if (viewMode === 'month')
|
|
151
|
+
setCurrent((d) => addMonths(d, -1));
|
|
152
|
+
else if (viewMode === 'week')
|
|
153
|
+
setCurrent((d) => addWeeks(d, -1));
|
|
154
|
+
else
|
|
155
|
+
setCurrent((d) => addDays(d, -1));
|
|
156
|
+
};
|
|
157
|
+
const next = () => {
|
|
158
|
+
if (viewMode === 'month')
|
|
159
|
+
setCurrent((d) => addMonths(d, 1));
|
|
160
|
+
else if (viewMode === 'week')
|
|
161
|
+
setCurrent((d) => addWeeks(d, 1));
|
|
162
|
+
else
|
|
163
|
+
setCurrent((d) => addDays(d, 1));
|
|
164
|
+
};
|
|
165
|
+
const navLabel = () => {
|
|
166
|
+
if (viewMode === 'month')
|
|
167
|
+
return format(current, 'MMMM yyyy', { locale: es });
|
|
168
|
+
if (viewMode === 'week') {
|
|
169
|
+
const s = format(weekStart, 'd MMM', { locale: es });
|
|
170
|
+
const e = format(weekEnd, 'd MMM yyyy', { locale: es });
|
|
171
|
+
return `${s} – ${e}`;
|
|
172
|
+
}
|
|
173
|
+
return format(current, 'EEEE d \'de\' MMMM yyyy', { locale: es });
|
|
174
|
+
};
|
|
175
|
+
// ------------------------------------------------------------------
|
|
176
|
+
// Events per day (for time-grid views)
|
|
177
|
+
// ------------------------------------------------------------------
|
|
178
|
+
const eventsForDay = (day) => events.filter((e) => isSameDay(isoToDate(e.start), day));
|
|
179
|
+
// ------------------------------------------------------------------
|
|
180
|
+
// Create flow
|
|
181
|
+
// ------------------------------------------------------------------
|
|
182
|
+
const handleGridClick = (e, day) => {
|
|
183
|
+
if (isReadOnly)
|
|
184
|
+
return;
|
|
185
|
+
const rect = (e.currentTarget).getBoundingClientRect();
|
|
186
|
+
const relY = e.clientY - rect.top;
|
|
187
|
+
const clickedMins = Math.round((relY / CELL_HEIGHT) * 60) * 30; // snap to 30min
|
|
188
|
+
const startMins = minHour * 60 + clickedMins;
|
|
189
|
+
const startHHMM = minutesToHHMM(Math.min(startMins, (maxHour - 1) * 60));
|
|
190
|
+
const endHHMM = minutesToHHMM(Math.min(startMins + 60, maxHour * 60));
|
|
191
|
+
setNewStart(startHHMM);
|
|
192
|
+
setNewEnd(endHHMM);
|
|
193
|
+
setNewCategory(allowedCategories[0] ?? CalendarEventCategory.WORKING);
|
|
194
|
+
setNewTitle('');
|
|
195
|
+
setCreate({ anchorEl: e.currentTarget, date: day, startMins });
|
|
196
|
+
};
|
|
197
|
+
const handleMonthDayClick = (day) => {
|
|
198
|
+
setCurrent(day);
|
|
199
|
+
setViewMode('day');
|
|
200
|
+
};
|
|
201
|
+
const handleCreate = () => {
|
|
202
|
+
if (!createState)
|
|
203
|
+
return;
|
|
204
|
+
const startISO = dateAndTimeToISO(createState.date, newStart);
|
|
205
|
+
const endISO = dateAndTimeToISO(createState.date, newEnd);
|
|
206
|
+
const template = step.eventTemplates?.find((t) => t.category === newCategory);
|
|
207
|
+
const evt = {
|
|
208
|
+
id: newEventId(),
|
|
209
|
+
category: newCategory,
|
|
210
|
+
start: startISO,
|
|
211
|
+
end: endISO,
|
|
212
|
+
title: newTitle || undefined,
|
|
213
|
+
eventTemplateId: template?.id,
|
|
214
|
+
};
|
|
215
|
+
setEvents((prev) => [...prev, evt]);
|
|
216
|
+
setCreate(null);
|
|
217
|
+
};
|
|
218
|
+
// ------------------------------------------------------------------
|
|
219
|
+
// Hour labels column
|
|
220
|
+
// ------------------------------------------------------------------
|
|
221
|
+
const hourLabels = Array.from({ length: totalHours }, (_, i) => minHour + i);
|
|
222
|
+
// ------------------------------------------------------------------
|
|
223
|
+
// Time-grid view (week / day)
|
|
224
|
+
// ------------------------------------------------------------------
|
|
225
|
+
const renderTimeGrid = () => (_jsxs("div", { className: styles.gridWrapper, children: [_jsxs("div", { className: styles.gridHeader, style: { gridTemplateColumns: `48px repeat(${visibleDays.length}, 1fr)` }, children: [_jsx("div", { className: styles.cornerCell }), visibleDays.map((day) => (_jsxs("div", { className: `${styles.dayHeader} ${isToday(day) ? styles.dayHeaderToday : ''}`, onClick: () => { setCurrent(day); setViewMode('day'); }, children: [_jsx("span", { className: styles.dayHeaderDow, children: format(day, 'EEE', { locale: es }) }), _jsx("span", { className: `${styles.dayHeaderNum} ${isToday(day) ? styles.todayCircle : ''}`, children: format(day, 'd') })] }, day.toISOString())))] }), _jsx("div", { className: styles.gridBody, ref: gridRef, children: _jsxs("div", { className: styles.gridInner, style: { gridTemplateColumns: `48px repeat(${visibleDays.length}, 1fr)` }, children: [_jsx("div", { className: styles.hourLabels, children: hourLabels.map((h) => (_jsx("div", { className: styles.hourLabel, style: { height: CELL_HEIGHT }, children: h > 0 && `${String(h).padStart(2, '0')}:00` }, h))) }), visibleDays.map((day) => (_jsxs("div", { className: styles.dayColumn, style: { height: totalHours * CELL_HEIGHT }, onClick: (e) => handleGridClick(e, day), children: [hourLabels.map((h) => (_jsx("div", { className: styles.hourLine, style: { top: (h - minHour) * CELL_HEIGHT } }, h))), eventsForDay(day).map((evt) => (_jsx(EventBlock, { event: evt, minHour: minHour, template: step.eventTemplates?.find((t) => t.category === evt.category), onDelete: deleteEvent, readOnly: isReadOnly }, evt.id)))] }, day.toISOString())))] }) })] }));
|
|
226
|
+
// ------------------------------------------------------------------
|
|
227
|
+
// Month view
|
|
228
|
+
// ------------------------------------------------------------------
|
|
229
|
+
const renderMonth = () => {
|
|
230
|
+
const mStart = startOfMonth(current);
|
|
231
|
+
const mEnd = endOfMonth(current);
|
|
232
|
+
const gridStart = startOfWeek(mStart, { weekStartsOn: WEEK_START });
|
|
233
|
+
const gridEnd = endOfWeek(mEnd, { weekStartsOn: WEEK_START });
|
|
234
|
+
const days = [];
|
|
235
|
+
let d = gridStart;
|
|
236
|
+
while (d <= gridEnd) {
|
|
237
|
+
days.push(d);
|
|
238
|
+
d = addDays(d, 1);
|
|
239
|
+
}
|
|
240
|
+
const DOW_LABELS = ['Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb', 'Dom'];
|
|
241
|
+
return (_jsxs("div", { className: styles.monthGrid, children: [DOW_LABELS.map((lbl) => (_jsx("div", { className: styles.monthDowHeader, children: lbl }, lbl))), days.map((day) => {
|
|
242
|
+
const dayEvts = eventsForDay(day);
|
|
243
|
+
const outside = !isSameMonth(day, current);
|
|
244
|
+
return (_jsxs("div", { className: [
|
|
245
|
+
styles.monthCell,
|
|
246
|
+
outside ? styles.monthCellOutside : '',
|
|
247
|
+
isToday(day) ? styles.monthCellToday : '',
|
|
248
|
+
].filter(Boolean).join(' '), onClick: () => handleMonthDayClick(day), children: [_jsx("span", { className: `${styles.monthCellNum} ${isToday(day) ? styles.todayCircle : ''}`, children: format(day, 'd') }), dayEvts.slice(0, 3).map((evt) => {
|
|
249
|
+
const color = CATEGORY_COLORS[evt.category] ?? '#607D8B';
|
|
250
|
+
return (_jsx("div", { className: styles.monthEventDot, style: { backgroundColor: color }, children: evt.title ?? CATEGORY_LABELS[evt.category] }, evt.id));
|
|
251
|
+
}), dayEvts.length > 3 && (_jsxs("div", { className: styles.monthMoreLabel, children: ["+", dayEvts.length - 3, " m\u00E1s"] }))] }, day.toISOString()));
|
|
252
|
+
})] }));
|
|
253
|
+
};
|
|
254
|
+
// ------------------------------------------------------------------
|
|
255
|
+
// Create popover
|
|
256
|
+
// ------------------------------------------------------------------
|
|
257
|
+
const needsTitle = newCategory === CalendarEventCategory.MEETING ||
|
|
258
|
+
newCategory === CalendarEventCategory.CUSTOM;
|
|
259
|
+
const renderCreatePopover = () => {
|
|
260
|
+
if (!createState)
|
|
261
|
+
return null;
|
|
262
|
+
return (_jsxs(Popover, { open: true, anchorEl: createState.anchorEl, onClose: () => setCreate(null), anchorOrigin: { vertical: 'top', horizontal: 'right' }, transformOrigin: { vertical: 'top', horizontal: 'left' }, slotProps: { paper: { className: styles.popoverPaper } }, children: [_jsxs("div", { className: styles.popoverHeader, children: [_jsx("span", { className: styles.popoverTitle, children: "Nuevo evento" }), _jsx("button", { type: "button", className: styles.popoverClose, onClick: () => setCreate(null), children: _jsx(CloseIcon, { size: 16 }) })] }), _jsxs("div", { className: styles.popoverBody, children: [_jsx("div", { className: styles.popoverLabel, children: "Tipo" }), _jsx("div", { className: styles.categoryGrid, children: allowedCategories.map((cat) => (_jsxs("button", { type: "button", className: `${styles.categoryChip} ${newCategory === cat ? styles.categoryChipActive : ''}`, style: newCategory === cat ? { backgroundColor: CATEGORY_COLORS[cat], color: '#fff' } : {}, onClick: () => setNewCategory(cat), children: [_jsx("span", { className: styles.categoryDot, style: { backgroundColor: CATEGORY_COLORS[cat] } }), CATEGORY_LABELS[cat]] }, cat))) }), needsTitle && (_jsxs(_Fragment, { children: [_jsx("div", { className: styles.popoverLabel, children: "Nombre" }), _jsx("input", { className: styles.popoverInput, value: newTitle, onChange: (e) => setNewTitle(e.target.value), placeholder: "Ej: Standup, Visita cliente\u2026", autoFocus: true })] })), _jsxs("div", { className: styles.timeRow, children: [_jsxs("div", { children: [_jsx("div", { className: styles.popoverLabel, children: "Inicio" }), _jsx("input", { type: "time", className: styles.popoverInput, value: newStart, onChange: (e) => setNewStart(e.target.value) })] }), _jsx("span", { className: styles.timeDash, children: "\u2013" }), _jsxs("div", { children: [_jsx("div", { className: styles.popoverLabel, children: "Fin" }), _jsx("input", { type: "time", className: styles.popoverInput, value: newEnd, onChange: (e) => setNewEnd(e.target.value) })] })] }), _jsxs("button", { type: "button", className: styles.createBtn, style: { backgroundColor: CATEGORY_COLORS[newCategory] }, onClick: handleCreate, children: [_jsx(AddIcon, { size: 16 }), "Agregar bloque"] })] })] }));
|
|
263
|
+
};
|
|
264
|
+
// ------------------------------------------------------------------
|
|
265
|
+
// Render
|
|
266
|
+
// ------------------------------------------------------------------
|
|
267
|
+
return (_jsxs("div", { className: styles.container, style: { width: widthStyle }, children: [_jsxs("div", { className: styles.toolbar, children: [_jsxs("div", { className: styles.viewSwitcher, children: [_jsx("button", { type: "button", className: `${styles.viewBtn} ${viewMode === 'day' ? styles.viewBtnActive : ''}`, onClick: () => setViewMode('day'), title: "D\u00EDa", children: _jsx(ViewDayIcon, { size: 18 }) }), _jsx("button", { type: "button", className: `${styles.viewBtn} ${viewMode === 'week' ? styles.viewBtnActive : ''}`, onClick: () => setViewMode('week'), title: "Semana", children: _jsx(ViewWeekIcon, { size: 18 }) }), _jsx("button", { type: "button", className: `${styles.viewBtn} ${viewMode === 'month' ? styles.viewBtnActive : ''}`, onClick: () => setViewMode('month'), title: "Mes", children: _jsx(CalendarIcon, { size: 18 }) })] }), _jsxs("div", { className: styles.navGroup, children: [_jsx("button", { type: "button", className: styles.navBtn, onClick: prev, children: _jsx(ArrowLeftIcon, { size: 20 }) }), _jsx("span", { className: styles.navLabel, children: navLabel() }), _jsx("button", { type: "button", className: styles.navBtn, onClick: next, children: _jsx(ArrowRightIcon, { size: 20 }) })] }), events.length > 0 && (_jsxs("span", { className: styles.eventBadge, children: [events.length, " evento", events.length !== 1 ? 's' : ''] })), !isReadOnly && viewMode !== 'month' && (_jsx("span", { className: styles.hintText, children: "Clic en el grid para agregar" }))] }), _jsx("div", { className: styles.calendarCard, children: viewMode === 'month' ? renderMonth() : renderTimeGrid() }), !isReadOnly && renderCreatePopover()] }));
|
|
268
|
+
}
|
|
269
|
+
export default MaterialCalendarStep;
|