@reservi/preact 1.3.2 → 1.4.0
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +137 -4
- package/dist/index.js +984 -565
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CalendarApi } from '@reservi/core';
|
|
2
2
|
import { CalendarOptions } from '@reservi/core';
|
|
3
|
+
import { CalendarViewAdapter } from '@reservi/core';
|
|
3
4
|
import { ComponentChildren } from 'preact';
|
|
4
5
|
import { DayGridModel } from '@reservi/core';
|
|
5
6
|
import { dayGridPlugin } from '@reservi/core';
|
|
@@ -8,6 +9,7 @@ import { defineTheme } from '@reservi/core';
|
|
|
8
9
|
import { EventDef } from '@reservi/core';
|
|
9
10
|
import { EventInput } from '@reservi/core';
|
|
10
11
|
import { eventsToICS } from '@reservi/core';
|
|
12
|
+
import { KeyboardAction } from '@reservi/core';
|
|
11
13
|
import { ListModel } from '@reservi/core';
|
|
12
14
|
import { listPlugin } from '@reservi/core';
|
|
13
15
|
import { MultiMonthModel } from '@reservi/core';
|
|
@@ -39,15 +41,25 @@ declare interface CalendarProps {
|
|
|
39
41
|
options: ReserviCalendarOptions;
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
export { CalendarViewAdapter }
|
|
45
|
+
|
|
46
|
+
export declare function callDidMount<Arg extends {
|
|
47
|
+
el: HTMLElement;
|
|
48
|
+
}>(el: Element | null, hook: ((arg: Arg) => void) | undefined, buildArg: () => Omit<Arg, "el">): void;
|
|
49
|
+
|
|
42
50
|
/** Une clases base con las del usuario (filtra vacíos). */
|
|
43
51
|
export declare function cx(...classes: (string | undefined | false)[]): string;
|
|
44
52
|
|
|
53
|
+
/** Formateador de fecha para cabeceras; `false` significa "sin texto". */
|
|
54
|
+
export declare function dateFormatter(locale: string, options: Intl.DateTimeFormatOptions | false | undefined, fallback: Intl.DateTimeFormatOptions): ((date: Date) => string) | null;
|
|
55
|
+
|
|
45
56
|
/** Argumento del slot de celda de día. */
|
|
46
57
|
export declare interface DayCellContentArg {
|
|
47
58
|
date: Date;
|
|
48
59
|
dayNumber: number;
|
|
49
60
|
isToday: boolean;
|
|
50
61
|
isOther: boolean;
|
|
62
|
+
view: ViewArg;
|
|
51
63
|
}
|
|
52
64
|
|
|
53
65
|
export { dayGridPlugin }
|
|
@@ -65,6 +77,12 @@ declare interface DayGridViewProps {
|
|
|
65
77
|
export declare interface DayHeaderContentArg {
|
|
66
78
|
date: Date;
|
|
67
79
|
text: string;
|
|
80
|
+
/** Día de la semana, 0 = domingo … 6 = sábado. */
|
|
81
|
+
dayOfWeek: number;
|
|
82
|
+
/** Día del mes (1–31). */
|
|
83
|
+
dayNumber: number;
|
|
84
|
+
isToday: boolean;
|
|
85
|
+
view: ViewArg;
|
|
68
86
|
}
|
|
69
87
|
|
|
70
88
|
export { definePlugin }
|
|
@@ -93,6 +111,7 @@ export declare interface EventContentArg {
|
|
|
93
111
|
isAllDay: boolean;
|
|
94
112
|
/** Texto de hora ya formateado (vacío si allDay). */
|
|
95
113
|
timeText: string;
|
|
114
|
+
view: ViewArg;
|
|
96
115
|
}
|
|
97
116
|
|
|
98
117
|
export { EventDef }
|
|
@@ -105,11 +124,43 @@ export declare type GridKind = "dayGrid" | "timeGrid";
|
|
|
105
124
|
|
|
106
125
|
export declare function handleEventKeydown(e: KeyboardEvent, opts: KeydownOptions): void;
|
|
107
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Puente para pintar contenido del framework anfitrión dentro del árbol de
|
|
129
|
+
* Preact. Lo implementan los wrappers (p. ej. `@reservi/react` con portales).
|
|
130
|
+
*/
|
|
131
|
+
export declare interface HostBridge {
|
|
132
|
+
/** Un hueco ha entrado en el DOM: pinta `node` dentro de `el`. */
|
|
133
|
+
mount(id: string, el: HTMLElement, node: unknown): void;
|
|
134
|
+
/** El contenido del hueco `id` ha cambiado. */
|
|
135
|
+
update(id: string, node: unknown): void;
|
|
136
|
+
/** El hueco `id` ha salido del DOM: libera lo que se pintó en él. */
|
|
137
|
+
unmount(id: string): void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Crea el marcador de contenido delegado al framework anfitrión. */
|
|
141
|
+
export declare function hostSlot(node: unknown): HostSlotResult;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Marcador que puede devolver un slot cuando el contenido lo pinta el
|
|
145
|
+
* framework anfitrión (React, Vue…). La capa Preact NO interpreta `node`:
|
|
146
|
+
* solo reserva un hueco en el DOM y delega en el `hostBridge`.
|
|
147
|
+
*/
|
|
148
|
+
export declare interface HostSlotResult {
|
|
149
|
+
readonly __rsvHost: true;
|
|
150
|
+
/** Nodo del framework anfitrión (opaco para esta capa). */
|
|
151
|
+
readonly node: unknown;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** ¿El resultado de un slot delega el render en el anfitrión? */
|
|
155
|
+
export declare function isHostSlot(value: unknown): value is HostSlotResult;
|
|
156
|
+
|
|
108
157
|
declare interface KeydownOptions {
|
|
109
158
|
api: CalendarApi;
|
|
110
159
|
event: EventDef;
|
|
111
160
|
kind: GridKind;
|
|
112
161
|
snap?: string | undefined;
|
|
162
|
+
/** Override de atajos (se mergea sobre `DEFAULT_SHORTCUTS` por acción). */
|
|
163
|
+
shortcuts?: Partial<Record<KeyboardAction, string[]>> | undefined;
|
|
113
164
|
}
|
|
114
165
|
|
|
115
166
|
export { listPlugin }
|
|
@@ -123,6 +174,21 @@ declare interface ListViewProps {
|
|
|
123
174
|
options: ReserviCalendarOptions;
|
|
124
175
|
}
|
|
125
176
|
|
|
177
|
+
/** "HH:mm" a partir de minutos desde medianoche. */
|
|
178
|
+
export declare function minutesToLabel(minutes: number): string;
|
|
179
|
+
|
|
180
|
+
/** "HH:mm:ss" a partir de minutos desde medianoche (sin envolver a 24h). */
|
|
181
|
+
export declare function minutesToTimeString(minutes: number): string;
|
|
182
|
+
|
|
183
|
+
/** Argumento del slot del botón "+N more" (popover de eventos ocultos). */
|
|
184
|
+
export declare interface MoreLinkContentArg {
|
|
185
|
+
date: Date;
|
|
186
|
+
moreCount: number;
|
|
187
|
+
allEvents: EventDef[];
|
|
188
|
+
hiddenEvents: EventDef[];
|
|
189
|
+
view: ViewArg;
|
|
190
|
+
}
|
|
191
|
+
|
|
126
192
|
/**
|
|
127
193
|
* Monta un calendario Reservi en un elemento del DOM. API agnóstica usada
|
|
128
194
|
* directamente (vanilla/Preact) y por los wrappers de framework.
|
|
@@ -154,12 +220,22 @@ declare interface Props_2 {
|
|
|
154
220
|
options: ReserviCalendarOptions;
|
|
155
221
|
}
|
|
156
222
|
|
|
223
|
+
/** Rango en curso (minutos absolutos del dia) para dibujar el `selectMirror`. */
|
|
224
|
+
export declare interface RangePreview {
|
|
225
|
+
startMin: number;
|
|
226
|
+
endMin: number;
|
|
227
|
+
}
|
|
228
|
+
|
|
157
229
|
/**
|
|
158
230
|
* Resuelve un slot de contenido: si el usuario aportó una función, usa su
|
|
159
231
|
* resultado; si no, usa el contenido por defecto. Unifica el contrato de los
|
|
160
232
|
* render hooks para todos los frameworks (en wrappers se adapta a su idioma).
|
|
233
|
+
*
|
|
234
|
+
* Si el slot devuelve `hostSlot(node)`, se reserva un hueco en el DOM y el
|
|
235
|
+
* `bridge` del framework anfitrión pinta el contenido dentro (React usa
|
|
236
|
+
* portales). Sin bridge se cae al contenido por defecto.
|
|
161
237
|
*/
|
|
162
|
-
export declare function renderSlot<Arg>(slot: ((arg: Arg) => SlotResult) | undefined, arg: Arg, fallback: ComponentChildren): ComponentChildren;
|
|
238
|
+
export declare function renderSlot<Arg>(slot: ((arg: Arg) => SlotResult) | undefined, arg: Arg, fallback: ComponentChildren, bridge?: HostBridge | undefined): ComponentChildren;
|
|
163
239
|
|
|
164
240
|
export declare interface ReserviCalendarHandle {
|
|
165
241
|
/** API del calendario (navegación, eventos, callbacks). */
|
|
@@ -171,7 +247,13 @@ export declare interface ReserviCalendarHandle {
|
|
|
171
247
|
/** Opciones de la capa Preact = opciones de núcleo + presentación. */
|
|
172
248
|
export declare interface ReserviCalendarOptions extends CalendarOptions {
|
|
173
249
|
slots?: ReserviSlots;
|
|
250
|
+
hooks?: ReserviHooks;
|
|
174
251
|
classNames?: ReserviClassNames;
|
|
252
|
+
/**
|
|
253
|
+
* Puente de render del framework anfitrión. Lo inyecta el wrapper; no es
|
|
254
|
+
* necesario configurarlo a mano en uso vanilla/Preact.
|
|
255
|
+
*/
|
|
256
|
+
hostBridge?: HostBridge;
|
|
175
257
|
/**
|
|
176
258
|
* Vistas a mostrar como pestañas en la segunda fila de la toolbar
|
|
177
259
|
* (p. ej. ["dayGridMonth", "timeGridWeek", "listWeek"]). Si se omite, se
|
|
@@ -185,19 +267,52 @@ export declare interface ReserviCalendarOptions extends CalendarOptions {
|
|
|
185
267
|
onAddClick?: () => void;
|
|
186
268
|
/** Texto del botón "Añadir" (def. "+" sin etiqueta). */
|
|
187
269
|
addButtonText?: string;
|
|
270
|
+
/**
|
|
271
|
+
* Cambia de vista automáticamente al redimensionar el contenedor (p. ej.
|
|
272
|
+
* mes → lista en mobile). Se evalúa el `breakpoint` más alto que sea
|
|
273
|
+
* `<= ancho actual` (estilo media query `min-width`).
|
|
274
|
+
*/
|
|
275
|
+
responsiveViews?: {
|
|
276
|
+
breakpoint: number;
|
|
277
|
+
view: string;
|
|
278
|
+
}[];
|
|
188
279
|
}
|
|
189
280
|
|
|
190
281
|
/** Clases por slot, fusionadas con las base. */
|
|
191
282
|
export declare interface ReserviClassNames {
|
|
192
283
|
root?: string;
|
|
193
284
|
toolbar?: string;
|
|
285
|
+
/** Celda de día (dayGrid/multiMonth). */
|
|
194
286
|
day?: string;
|
|
195
287
|
event?: string;
|
|
288
|
+
/** Cabecera de día (nombre del día / columna). */
|
|
289
|
+
dayHeader?: string;
|
|
290
|
+
/** Etiqueta del eje horario (timeGrid). */
|
|
291
|
+
slotLabel?: string;
|
|
196
292
|
}
|
|
197
293
|
|
|
198
294
|
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
295
|
+
* Hooks de ciclo de vida sobre el DOM ya montado (equivalentes a los
|
|
296
|
+
* `*DidMount` de FullCalendar). Se invocan UNA vez por elemento del DOM.
|
|
297
|
+
*/
|
|
298
|
+
export declare interface ReserviHooks {
|
|
299
|
+
eventDidMount?: (arg: EventContentArg & {
|
|
300
|
+
el: HTMLElement;
|
|
301
|
+
}) => void;
|
|
302
|
+
dayCellDidMount?: (arg: DayCellContentArg & {
|
|
303
|
+
el: HTMLElement;
|
|
304
|
+
}) => void;
|
|
305
|
+
dayHeaderDidMount?: (arg: DayHeaderContentArg & {
|
|
306
|
+
el: HTMLElement;
|
|
307
|
+
}) => void;
|
|
308
|
+
slotLabelDidMount?: (arg: SlotLabelContentArg & {
|
|
309
|
+
el: HTMLElement;
|
|
310
|
+
}) => void;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Slots de render (patrón de "content" de FullCalendar). Cada slot devuelve
|
|
315
|
+
* contenido Preact, una cadena, o `hostSlot(...)` para delegar en el anfitrión.
|
|
201
316
|
*/
|
|
202
317
|
export declare interface ReserviSlots {
|
|
203
318
|
eventContent?: (arg: EventContentArg) => SlotResult;
|
|
@@ -205,6 +320,12 @@ export declare interface ReserviSlots {
|
|
|
205
320
|
dayHeaderContent?: (arg: DayHeaderContentArg) => SlotResult;
|
|
206
321
|
/** Personaliza la etiqueta del eje horario (timeGrid). */
|
|
207
322
|
slotLabelContent?: (arg: SlotLabelContentArg) => SlotResult;
|
|
323
|
+
/**
|
|
324
|
+
* Personaliza el contenido del botón "+N more" (dayGrid/multiMonth). El
|
|
325
|
+
* `<button>` que abre el popover se conserva; el slot solo reemplaza su
|
|
326
|
+
* contenido interno (mismo patrón que `dayCellContent`).
|
|
327
|
+
*/
|
|
328
|
+
moreLinkContent?: (arg: MoreLinkContentArg) => SlotResult;
|
|
208
329
|
/**
|
|
209
330
|
* Contenido libre al inicio de la toolbar (zona "Filtrar/Personal" del diseño).
|
|
210
331
|
* El usuario decide qué botones poner y qué hacen; si no se define, no se
|
|
@@ -247,14 +368,21 @@ export declare interface SlotLabelContentArg {
|
|
|
247
368
|
minutes: number;
|
|
248
369
|
/** Si es una marca mayor (etiquetada). */
|
|
249
370
|
isMajor: boolean;
|
|
371
|
+
view: ViewArg;
|
|
250
372
|
}
|
|
251
373
|
|
|
252
|
-
export declare type SlotResult = ComponentChildren | string;
|
|
374
|
+
export declare type SlotResult = ComponentChildren | string | HostSlotResult;
|
|
253
375
|
|
|
254
376
|
export declare function startEventDrag(ev: PointerEvent, options: DragOptions): void;
|
|
255
377
|
|
|
256
378
|
export { themeToStyle }
|
|
257
379
|
|
|
380
|
+
/**
|
|
381
|
+
* Formateador de hora: usa `Intl` si hay opciones, y si no el 24h por defecto
|
|
382
|
+
* que ya produce el núcleo. Devuelve null si no hay que sobreescribir nada.
|
|
383
|
+
*/
|
|
384
|
+
export declare function timeFormatter(locale: string, options: Intl.DateTimeFormatOptions | undefined): ((date: Date) => string) | null;
|
|
385
|
+
|
|
258
386
|
export { timeGridPlugin }
|
|
259
387
|
|
|
260
388
|
/** Vista con eje temporal vertical (semana/día). */
|
|
@@ -296,4 +424,9 @@ declare interface ToolbarProps {
|
|
|
296
424
|
options: ReserviCalendarOptions;
|
|
297
425
|
}
|
|
298
426
|
|
|
427
|
+
/** Vista activa tal como la reciben los slots y los hooks `*DidMount`. */
|
|
428
|
+
export declare interface ViewArg {
|
|
429
|
+
readonly type: string;
|
|
430
|
+
}
|
|
431
|
+
|
|
299
432
|
export { }
|