@directo-ui/web 1.0.0 → 1.2.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.
@@ -0,0 +1,32 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface WariScheduleProps {
3
+ title?: ReactNode;
4
+ /** Nivel del título para respetar la jerarquía de la página. */
5
+ headingLevel?: 2 | 3 | 4;
6
+ /** Fecha ISO "YYYY-MM-DD". */
7
+ date?: string;
8
+ defaultDate?: string;
9
+ onDateChange?: (value: string) => void;
10
+ /** Hora "HH:mm" (24 h). */
11
+ time?: string;
12
+ defaultTime?: string;
13
+ onTimeChange?: (value: string) => void;
14
+ dateLabel?: string;
15
+ timeLabel?: string;
16
+ minDate?: string;
17
+ maxDate?: string;
18
+ /** Nombres de los campos ocultos para enviar en un <form>. */
19
+ dateName?: string;
20
+ timeName?: string;
21
+ required?: boolean;
22
+ disabled?: boolean;
23
+ dateError?: boolean;
24
+ timeError?: boolean;
25
+ dateSupportingText?: string;
26
+ timeSupportingText?: string;
27
+ locale?: string;
28
+ weekStartsOn?: 0 | 1;
29
+ className?: string;
30
+ }
31
+ /** Tarjeta "Horario" de Wari: fecha y hora de recojo con sus selectores. */
32
+ export declare function WariSchedule({ title, headingLevel, date, defaultDate, onDateChange, time, defaultTime, onTimeChange, dateLabel, timeLabel, minDate, maxDate, dateName, timeName, required, disabled, dateError, timeError, dateSupportingText, timeSupportingText, locale, weekStartsOn, className, }: WariScheduleProps): import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface WariSelectOption {
3
+ value: string;
4
+ label: string;
5
+ disabled?: boolean;
6
+ /** Contenido a la derecha (capacidad, precio…). Se muestra también en el campo cerrado. */
7
+ meta?: ReactNode;
8
+ /** Texto del `meta` para lectores de pantalla. */
9
+ metaLabel?: string;
10
+ }
11
+ export interface WariSelectProps {
12
+ label?: string;
13
+ 'aria-label'?: string;
14
+ options: readonly WariSelectOption[];
15
+ value?: string;
16
+ defaultValue?: string;
17
+ onChange?: (value: string) => void;
18
+ placeholder?: string;
19
+ supportingText?: string;
20
+ error?: boolean;
21
+ required?: boolean;
22
+ disabled?: boolean;
23
+ /** Envía el valor en un campo oculto dentro de un <form>. */
24
+ name?: string;
25
+ id?: string;
26
+ className?: string;
27
+ }
28
+ /** Selector de una opción con lista propia (patrón combobox de solo selección de WAI-ARIA). */
29
+ export declare function WariSelect({ label, 'aria-label': ariaLabel, options, value, defaultValue, onChange, placeholder, supportingText, error, required, disabled, name, id, className, }: WariSelectProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { WariService } from './trip.js';
2
+ export interface WariServiceMetaProps {
3
+ service: WariService;
4
+ hourly?: boolean;
5
+ delivery?: boolean;
6
+ }
7
+ /** Detalle a la derecha de un servicio: capacidad, insignia "Envío" o "Desde S/…" según el modo. */
8
+ export declare function WariServiceMeta({ service, hourly, delivery }: WariServiceMetaProps): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { MultiSelectProps } from './MultiSelect.js';
3
+ import type { WariStatus } from './statuses.js';
4
+ export interface WariStatusSelectProps extends Omit<MultiSelectProps, 'options' | 'value' | 'defaultValue' | 'onChange'> {
5
+ value?: WariStatus[];
6
+ defaultValue?: WariStatus[];
7
+ onChange?: (value: WariStatus[]) => void;
8
+ /** Estados a mostrar (por defecto todos, en el orden de Wari). */
9
+ statuses?: readonly WariStatus[];
10
+ /** Texto a la derecha de cada estado, por ejemplo la cantidad de servicios. */
11
+ descriptions?: Partial<Record<WariStatus, ReactNode>>;
12
+ }
13
+ /** Filtro de estados de Wari: MultiSelect con las etiquetas de color de cada estado. */
14
+ export declare function WariStatusSelect({ statuses, descriptions, onChange, label, ...props }: WariStatusSelectProps): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ export interface WariStepperProps {
2
+ label?: string;
3
+ /** Nombre accesible cuando no hay `label` visible. */
4
+ 'aria-label'?: string;
5
+ /** 'outlined': botones con borde y más alto, como el contador del Booster en Figma. */
6
+ variant?: 'filled' | 'outlined';
7
+ value?: number;
8
+ defaultValue?: number;
9
+ onChange?: (value: number) => void;
10
+ min?: number;
11
+ max?: number;
12
+ /** Envía el número en un <form>. */
13
+ name?: string;
14
+ id?: string;
15
+ disabled?: boolean;
16
+ supportingText?: string;
17
+ className?: string;
18
+ }
19
+ /** Contador con botones − y + (Cantidad de vehículos). También se puede escribir el número. */
20
+ export declare function WariStepper({ label, 'aria-label': ariaLabel, variant, value, defaultValue, onChange, min, max, name, id, disabled, supportingText, className, }: WariStepperProps): import("react").JSX.Element;
@@ -0,0 +1,37 @@
1
+ import type { WariOption } from './trip.js';
2
+ export interface WariSwitchListProps {
3
+ /** Nombre del grupo para lectores de pantalla (no se muestra). */
4
+ legend: string;
5
+ /**
6
+ * Interruptores. Con `description`, `note`, `maxQuantity`, `choices` o `fields`, al activarlo se despliega su panel:
7
+ * contador (Booster), una lista por unidad con + y papelera (Carseat) o campos de texto (Carga).
8
+ */
9
+ items: readonly WariOption[];
10
+ /** Valores activos. */
11
+ value?: string[];
12
+ defaultValue?: string[];
13
+ /** Al activar o desactivar: los valores activos y las cantidades/opciones ya ajustadas (un extra nuevo empieza con 1). */
14
+ onChange?: (value: string[], quantities: Record<string, number>, choices: Record<string, string[]>, fields: Record<string, Record<string, string>>) => void;
15
+ /** Cantidad de cada interruptor activo con `maxQuantity` (p. ej. { booster: 2 }). */
16
+ quantities?: Record<string, number>;
17
+ defaultQuantities?: Record<string, number>;
18
+ /** Al usar el contador de un extra. */
19
+ onQuantitiesChange?: (quantities: Record<string, number>) => void;
20
+ /** Opción de cada unidad de los interruptores activos con `choices` (p. ej. { carseat: ['0-2', '3-5'] }). */
21
+ choices?: Record<string, string[]>;
22
+ defaultChoices?: Record<string, string[]>;
23
+ /** Al elegir, agregar o quitar una unidad; también entrega las cantidades (número de unidades). */
24
+ onChoicesChange?: (choices: Record<string, string[]>, quantities: Record<string, number>) => void;
25
+ /** Texto de los campos de los interruptores activos con `fields` (p. ej. { carga: { weight: '20', value: '150' } }). */
26
+ fields?: Record<string, Record<string, string>>;
27
+ defaultFields?: Record<string, Record<string, string>>;
28
+ /** Al escribir en los campos de un extra. */
29
+ onFieldsChange?: (fields: Record<string, Record<string, string>>) => void;
30
+ orientation?: 'vertical' | 'horizontal';
31
+ /** Envía cada interruptor activo como `name=value` (y su cantidad u opciones como `name.value`) dentro de un <form>. */
32
+ name?: string;
33
+ disabled?: boolean;
34
+ className?: string;
35
+ }
36
+ /** Interruptores agrupados en un recuadro con divisores (Por horas / Envíos, Carseat / Booster / Carga). */
37
+ export declare function WariSwitchList({ legend, items, value, defaultValue, onChange, quantities, defaultQuantities, onQuantitiesChange, choices, defaultChoices, onChoicesChange, fields, defaultFields, onFieldsChange, orientation, name, disabled, className, }: WariSwitchListProps): import("react").JSX.Element;
@@ -0,0 +1,23 @@
1
+ export interface WariTimeFieldProps {
2
+ label?: string;
3
+ /** Hora "HH:mm" en formato 24 h (modo controlado). Cadena vacía = sin hora. */
4
+ value?: string;
5
+ defaultValue?: string;
6
+ onChange?: (value: string) => void;
7
+ placeholder?: string;
8
+ supportingText?: string;
9
+ error?: boolean;
10
+ required?: boolean;
11
+ disabled?: boolean;
12
+ /** Envía la hora "HH:mm" en un campo oculto dentro de un <form>. */
13
+ name?: string;
14
+ id?: string;
15
+ /** Título del selector. */
16
+ title?: string;
17
+ cancelLabel?: string;
18
+ okLabel?: string;
19
+ /** Alinea el selector al borde izquierdo o derecho del campo. */
20
+ align?: 'start' | 'end';
21
+ className?: string;
22
+ }
23
+ export declare function WariTimeField({ label, value, defaultValue, onChange, placeholder, supportingText, error, required, disabled, name, id, title, cancelLabel, okLabel, align, className, }: WariTimeFieldProps): import("react").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { WariOption, WariService, WariTripAttributesValue } from './trip.js';
3
+ export interface WariTripAttributesProps {
4
+ title?: ReactNode;
5
+ headingLevel?: 2 | 3 | 4;
6
+ value?: WariTripAttributesValue;
7
+ defaultValue?: Partial<WariTripAttributesValue>;
8
+ onChange?: (value: WariTripAttributesValue) => void;
9
+ services?: readonly WariService[];
10
+ extras?: readonly WariOption[];
11
+ paymentMethods?: readonly WariOption[];
12
+ maxVehicles?: number;
13
+ /** Prefijo de los campos del <form>: `${name}.service`, `${name}.hourly`, `${name}.extras`… */
14
+ name?: string;
15
+ disabled?: boolean;
16
+ serviceLabel?: string;
17
+ vehiclesLabel?: string;
18
+ paymentLabel?: string;
19
+ hourlyLabel?: string;
20
+ deliveryLabel?: string;
21
+ className?: string;
22
+ }
23
+ /** Tarjeta "Atributos del viaje" de Wari: servicio, por horas / envíos, extras, vehículos y método de pago. */
24
+ export declare function WariTripAttributes({ title, headingLevel, value, defaultValue, onChange, services, extras, paymentMethods, maxVehicles, name, disabled, serviceLabel, vehiclesLabel, paymentLabel, hourlyLabel, deliveryLabel, className, }: WariTripAttributesProps): import("react").JSX.Element;
@@ -0,0 +1,57 @@
1
+ export interface CalendarDay {
2
+ iso: string;
3
+ day: number;
4
+ /** Belongs to the previous or next month. */
5
+ outside: boolean;
6
+ }
7
+ export interface TimeParts {
8
+ hours: number;
9
+ minutes: number;
10
+ }
11
+ export type Period = 'AM' | 'PM';
12
+ export declare function toISODate(year: number, month: number, day: number): string;
13
+ /** Returns { year, month (0-11), day } or null when the string is not a real date. */
14
+ export declare function parseISODate(value: string | null | undefined): {
15
+ year: number;
16
+ month: number;
17
+ day: number;
18
+ } | null;
19
+ export declare function todayISO(now?: Date): string;
20
+ /** "2026-05-27" → "27/05/26" (formato del diseño de Wari). */
21
+ export declare function formatDisplayDate(iso: string | null | undefined): string;
22
+ /** Accepts d/m/aa, d/m/aaaa, d-m-aaaa or d.m.aa. Two-digit years are 2000-2099. */
23
+ export declare function parseDisplayDate(text: string): string | null;
24
+ export declare function isDateInRange(iso: string, min?: string | null, max?: string | null): boolean;
25
+ export declare function addMonths(year: number, month: number, delta: number): {
26
+ year: number;
27
+ month: number;
28
+ };
29
+ /** Always 6 weeks × 7 days, like the design (days of the neighbour months are marked `outside`). */
30
+ export declare function calendarWeeks(year: number, month: number, weekStartsOn?: 0 | 1): CalendarDay[][];
31
+ /** Day `delta` days after `iso` (negative goes back). */
32
+ export declare function shiftDate(iso: string, delta: number): string;
33
+ /** Same day in another month, clamped to that month's length (31 ene + 1 mes → 28/29 feb). */
34
+ export declare function shiftMonth(iso: string, delta: number): string;
35
+ export declare function monthNames(locale?: string, format?: 'long' | 'short'): string[];
36
+ /** Narrow weekday names starting on `weekStartsOn` (0 = domingo). */
37
+ export declare function weekdayNames(locale?: string, weekStartsOn?: 0 | 1, format?: 'narrow' | 'long'): string[];
38
+ export declare function longDateLabel(iso: string, locale?: string): string;
39
+ export declare function parseTime24(value: string | null | undefined): TimeParts | null;
40
+ export declare function formatTime24(hours: number, minutes: number): string;
41
+ export declare function to12h(hours: number): {
42
+ hour: number;
43
+ period: Period;
44
+ };
45
+ export declare function from12h(hour: number, period: Period): number;
46
+ /** "23:50" → "11:50 PM" (formato del diseño de Wari). */
47
+ export declare function formatDisplayTime(value: string | null | undefined): string;
48
+ /** Accepts "11:50 pm", "11:50PM", "23:50", "7 pm", "7", "0730". Returns "HH:mm" or null. */
49
+ export declare function parseDisplayTime(text: string): string | null;
50
+ /** Position (px) of a dial number. `step` is 12 for hours and 60 for minutes. */
51
+ export declare function dialPoint(value: number, step: 12 | 60, radius: number, center: number): {
52
+ x: number;
53
+ y: number;
54
+ };
55
+ /** Hour (1-12) or minute (0-59) under a pointer at (x, y) relative to the dial's top-left corner. */
56
+ export declare function dialValue(x: number, y: number, center: number, mode: 'hour' | 'minute'): number;
57
+ export declare const pad2: (value: number) => string;
@@ -0,0 +1,35 @@
1
+ export declare const CalendarIcon: () => import("react").JSX.Element;
2
+ export declare const ClockIcon: ({ size }: {
3
+ size?: number;
4
+ }) => import("react").JSX.Element;
5
+ export declare const ChevronLeft: () => import("react").JSX.Element;
6
+ export declare const ChevronRight: () => import("react").JSX.Element;
7
+ export declare const CaretDown: () => import("react").JSX.Element;
8
+ export declare const CheckIcon: () => import("react").JSX.Element;
9
+ export declare const KeyboardIcon: () => import("react").JSX.Element;
10
+ export declare const FadersIcon: () => import("react").JSX.Element;
11
+ export declare const ChevronDown: () => import("react").JSX.Element;
12
+ export declare const MinusIcon: () => import("react").JSX.Element;
13
+ export declare const PlusIcon: () => import("react").JSX.Element;
14
+ export declare const UserIcon: () => import("react").JSX.Element;
15
+ export declare const LuggageIcon: () => import("react").JSX.Element;
16
+ export declare const BagIcon: () => import("react").JSX.Element;
17
+ export declare const UserSquareIcon: () => import("react").JSX.Element;
18
+ export declare const SearchIcon: () => import("react").JSX.Element;
19
+ export declare const PlusThinIcon: () => import("react").JSX.Element;
20
+ export declare const PhoneIcon: () => import("react").JSX.Element;
21
+ export declare const InfoIcon: () => import("react").JSX.Element;
22
+ export declare const PencilIcon: () => import("react").JSX.Element;
23
+ export declare const TrashIcon: () => import("react").JSX.Element;
24
+ export declare const RouteIcon: () => import("react").JSX.Element;
25
+ export declare const SwapIcon: () => import("react").JSX.Element;
26
+ export declare const HandleIcon: () => import("react").JSX.Element;
27
+ export declare const CloseIcon: () => import("react").JSX.Element;
28
+ export declare const CircleMarker: () => import("react").JSX.Element;
29
+ export declare const SquareMarker: () => import("react").JSX.Element;
30
+ export declare const UserPlusIcon: () => import("react").JSX.Element;
31
+ export declare const UserLineIcon: () => import("react").JSX.Element;
32
+ export declare const PlusCircleIcon: () => import("react").JSX.Element;
33
+ export declare const ClearCircleIcon: () => import("react").JSX.Element;
34
+ /** Teléfono con líneas: el número ya está ingresado (Figma "pasajero"). */
35
+ export declare const PhoneListIcon: () => import("react").JSX.Element;
@@ -0,0 +1,40 @@
1
+ export { StatusTag } from './StatusTag.js';
2
+ export { MultiSelect } from './MultiSelect.js';
3
+ export { WariStatusSelect } from './WariStatusSelect.js';
4
+ export { WariDateField } from './WariDateField.js';
5
+ export { WariTimeField } from './WariTimeField.js';
6
+ export { WariSchedule } from './WariSchedule.js';
7
+ export { WariSelect } from './WariSelect.js';
8
+ export { WariSwitchList } from './WariSwitchList.js';
9
+ export { WariStepper } from './WariStepper.js';
10
+ export { WariServiceMeta } from './WariServiceMeta.js';
11
+ export { WariTripAttributes } from './WariTripAttributes.js';
12
+ export { WariClientSearch } from './WariClientSearch.js';
13
+ export { WariClientDetails } from './WariClientDetails.js';
14
+ export { WariRoute } from './WariRoute.js';
15
+ export { WariPassengerField } from './WariPassengerField.js';
16
+ export { addStop, addToll, createStop, defaultRouteValue, emptyPassenger, invertRoute, moveStop, normalizeRoute, removeStop, removeToll, stopLabel, stopPlaceholder, tollsTotal, updateStop, } from './route.js';
17
+ export { clampCount, defaultTripAttributes, formatSoles, serviceMeta, syncExtraChoices, syncExtraFields, syncExtraQuantities, syncExtras, toggleExtra, typeaheadIndex, wariExtras, wariPaymentMethods, wariServices, } from './trip.js';
18
+ export { wariStatuses, wariStatusLabel } from './statuses.js';
19
+ export { calendarWeeks, formatDisplayDate, formatDisplayTime, parseDisplayDate, parseDisplayTime, parseISODate, parseTime24, toISODate, todayISO, } from './datetime.js';
20
+ export { filterOptions, normalizeSearch, selectionState, selectionSummary, toggleAll, toggleValue } from './logic.js';
21
+ export type { StatusTagProps } from './StatusTag.js';
22
+ export type { MultiSelectProps, MultiSelectOption } from './MultiSelect.js';
23
+ export type { WariStatusSelectProps } from './WariStatusSelect.js';
24
+ export type { WariStatus } from './statuses.js';
25
+ export type { WariDateFieldProps } from './WariDateField.js';
26
+ export type { WariTimeFieldProps } from './WariTimeField.js';
27
+ export type { WariScheduleProps } from './WariSchedule.js';
28
+ export type { WariSelectProps, WariSelectOption } from './WariSelect.js';
29
+ export type { WariSwitchListProps } from './WariSwitchList.js';
30
+ export type { WariStepperProps } from './WariStepper.js';
31
+ export type { WariServiceMetaProps } from './WariServiceMeta.js';
32
+ export type { WariTripAttributesProps } from './WariTripAttributes.js';
33
+ export type { WariClientSearchProps } from './WariClientSearch.js';
34
+ export type { WariClientDetailsProps } from './WariClientDetails.js';
35
+ export type { WariRouteProps } from './WariRoute.js';
36
+ export type { WariPassengerFieldProps } from './WariPassengerField.js';
37
+ export type { WariPassenger, WariRouteStop, WariRouteValue } from './route.js';
38
+ export type { WariService, WariOption, WariExtraField, WariExtrasState, WariTripAttributesValue, ServiceMeta } from './trip.js';
39
+ export type { CalendarDay, TimeParts, Period } from './datetime.js';
40
+ export type { SelectableOption, SelectionState } from './logic.js';
@@ -0,0 +1,14 @@
1
+ export interface SelectableOption {
2
+ value: string;
3
+ label: string;
4
+ disabled?: boolean;
5
+ }
6
+ export type SelectionState = 'none' | 'some' | 'all';
7
+ /** Lowercase and strip accents so "inicio" finds "Inició". */
8
+ export declare function normalizeSearch(text: string): string;
9
+ export declare function filterOptions<T extends SelectableOption>(options: readonly T[], query: string): T[];
10
+ export declare function toggleValue(values: readonly string[], value: string, options: readonly SelectableOption[]): string[];
11
+ export declare function selectionState(values: readonly string[], options: readonly SelectableOption[]): SelectionState;
12
+ /** "Todos": selects every enabled option, or clears them when all were already selected. Disabled ones keep their state. */
13
+ export declare function toggleAll(values: readonly string[], options: readonly SelectableOption[]): string[];
14
+ export declare function selectionSummary(count: number): string;
@@ -0,0 +1,14 @@
1
+ export type MotionSnapshot = Map<string, DOMRect>;
2
+ export declare function prefersReducedMotion(): boolean;
3
+ /** Positions of every [data-motion] element inside `root`, before a change. */
4
+ export declare function snapshot(root: Element | null | undefined): MotionSnapshot;
5
+ /**
6
+ * After the DOM changed: moved elements slide from their old position, new ones fade in (staggered).
7
+ * Nested [data-motion] elements only fade in; they already move with their parent.
8
+ */
9
+ export declare function animateFrom(root: Element | null | undefined, before: MotionSnapshot): void;
10
+ /**
11
+ * Fades an element out, then runs `remove` (your state change). The fade is cleared on the next frames, so an element that
12
+ * is reused for other content (for example a list keyed by index) shows up again.
13
+ */
14
+ export declare function leave(el: Element | null | undefined, remove: () => void): void;
@@ -0,0 +1,48 @@
1
+ export interface WariPassenger {
2
+ name: string;
3
+ phone: string;
4
+ }
5
+ export interface WariRouteStop {
6
+ /** Identificador estable (para reordenar sin perder el foco ni el texto). */
7
+ id: string;
8
+ address: string;
9
+ reference: string;
10
+ /** Zona calculada por tu app al elegir la dirección; sin zona se muestra "Sin definir". */
11
+ zone?: string;
12
+ /** Tarifa de la parada en soles; sin precio no se muestra. */
13
+ price?: number;
14
+ /** Pasajero solo de esta parada ("Añadir Pasajero" en la parada); null = sin pasajero propio. */
15
+ passenger?: WariPassenger | null;
16
+ }
17
+ export interface WariRouteValue {
18
+ /** La primera parada es el origen; las demás, destinos. */
19
+ stops: WariRouteStop[];
20
+ /** Pasajero para toda la ruta ("Añadir pasajero (ruta completa)"); null = sin pasajero. */
21
+ passenger: WariPassenger | null;
22
+ /** Montos de los peajes, como texto (p. ej. ['4.50', '']). */
23
+ tolls: string[];
24
+ }
25
+ export declare function createStop(partial?: Partial<WariRouteStop>): WariRouteStop;
26
+ /** Ruta vacía: origen, un destino y un peaje sin monto. */
27
+ export declare function defaultRouteValue(): WariRouteValue;
28
+ export declare const emptyPassenger: () => WariPassenger;
29
+ /** Mueve una parada de `from` a `to` (índices); fuera de rango no cambia nada. */
30
+ export declare function moveStop(stops: readonly WariRouteStop[], from: number, to: number): WariRouteStop[];
31
+ /** "Invertir": el último destino pasa a ser el origen y viceversa. */
32
+ export declare function invertRoute(value: WariRouteValue): WariRouteValue;
33
+ /** Agrega un destino al final, sin pasar de `maxStops`. */
34
+ export declare function addStop(stops: readonly WariRouteStop[], maxStops?: number): WariRouteStop[];
35
+ /** Quita una parada; con solo dos (origen y un destino) la vacía en lugar de quitarla. */
36
+ export declare function removeStop(stops: readonly WariRouteStop[], index: number): WariRouteStop[];
37
+ export declare function updateStop(stops: readonly WariRouteStop[], index: number, patch: Partial<WariRouteStop>): WariRouteStop[];
38
+ /** Agrega un peaje vacío, sin pasar de `maxTolls`. */
39
+ export declare function addToll(tolls: readonly string[], maxTolls?: number): string[];
40
+ /** Quita un peaje; el primero nunca se quita (se vacía). */
41
+ export declare function removeToll(tolls: readonly string[], index: number): string[];
42
+ /** Suma de los peajes válidos (acepta coma o punto decimal). */
43
+ export declare function tollsTotal(tolls: readonly string[]): number;
44
+ export declare function stopPlaceholder(index: number): string;
45
+ /** Nombre accesible de una parada: "Origen" o "Destino 1", "Destino 2"… */
46
+ export declare function stopLabel(index: number): string;
47
+ /** Acepta valores parciales o de versiones anteriores y los completa. */
48
+ export declare function normalizeRoute(value: Partial<WariRouteValue> | null | undefined): WariRouteValue;
@@ -0,0 +1,34 @@
1
+ /** Estados de un servicio en Wari, en el orden en que aparecen en Figma. */
2
+ export declare const wariStatuses: readonly [{
3
+ readonly value: "libre";
4
+ readonly label: "Libre";
5
+ }, {
6
+ readonly value: "aceptado";
7
+ readonly label: "Aceptado";
8
+ }, {
9
+ readonly value: "contacto";
10
+ readonly label: "Contacto";
11
+ }, {
12
+ readonly value: "inicio";
13
+ readonly label: "Inició";
14
+ }, {
15
+ readonly value: "llego";
16
+ readonly label: "Llegó";
17
+ }, {
18
+ readonly value: "terminado";
19
+ readonly label: "Terminado";
20
+ }, {
21
+ readonly value: "preasignado";
22
+ readonly label: "Preasignado";
23
+ }, {
24
+ readonly value: "anulado-operador";
25
+ readonly label: "Anulado Operador";
26
+ }, {
27
+ readonly value: "anulado-usuario";
28
+ readonly label: "Anulado Usuario";
29
+ }, {
30
+ readonly value: "empalmado";
31
+ readonly label: "Empalmado";
32
+ }];
33
+ export type WariStatus = (typeof wariStatuses)[number]['value'];
34
+ export declare const wariStatusLabel: (status: WariStatus) => string;
@@ -0,0 +1,107 @@
1
+ export interface WariService {
2
+ value: string;
3
+ label: string;
4
+ /** Pasajeros. */
5
+ passengers: number;
6
+ /** Maletas. */
7
+ luggage: number;
8
+ /** Capacidad alternativa que muestra el diseño tras "o" (XL: 4 o 6, Van: 6 o 10). */
9
+ luggageAlt?: number;
10
+ /** Tarifa por horas desde la que se cobra (se muestra como "Desde S/80"). */
11
+ hourlyPrice?: number;
12
+ disabled?: boolean;
13
+ }
14
+ export interface WariOption {
15
+ value: string;
16
+ label: string;
17
+ disabled?: boolean;
18
+ /** Extras: texto que aparece al activarlo (p. ej. "Para niños de 4 hasta 12 años"). */
19
+ description?: string;
20
+ /** Extras: aviso oscuro que aparece al activarlo (p. ej. "Solicítalo con al menos 2 horas de anticipación…"). */
21
+ note?: string;
22
+ /** Extras: cantidad máxima; si se indica, al activarlo aparece un contador de 1 a este número. */
23
+ maxQuantity?: number;
24
+ /**
25
+ * Extras: opciones de cada unidad (p. ej. edades del Carseat). Con `choices`, en lugar del contador cada unidad
26
+ * se elige en una lista; se agregan con + hasta `maxQuantity` y se quitan con la papelera.
27
+ */
28
+ choices?: {
29
+ value: string;
30
+ label: string;
31
+ }[];
32
+ /** Extras: campos de texto que aparecen al activarlo (p. ej. peso y valor de la Carga). */
33
+ fields?: WariExtraField[];
34
+ }
35
+ export interface WariExtraField {
36
+ /** Clave del valor (p. ej. 'weight'). */
37
+ name: string;
38
+ /** Nombre accesible del campo (el placeholder desaparece al escribir y no sirve como etiqueta). */
39
+ label: string;
40
+ placeholder?: string;
41
+ inputMode?: 'text' | 'decimal' | 'numeric';
42
+ /** Ancho fijo (p. ej. '96px'); sin ancho, el campo ocupa el espacio restante. */
43
+ width?: string;
44
+ }
45
+ export interface WariTripAttributesValue {
46
+ service: string;
47
+ hourly: boolean;
48
+ delivery: boolean;
49
+ /** Valores de los extras activos (por defecto: carseat, booster, carga). */
50
+ extras: string[];
51
+ /** Cantidad de cada extra activo que tiene `maxQuantity` (p. ej. { booster: 2 }). */
52
+ extraQuantities: Record<string, number>;
53
+ /** Opción de cada unidad de los extras activos con `choices` (p. ej. { carseat: ['0-2', '3-5'] }). */
54
+ extraChoices: Record<string, string[]>;
55
+ /** Texto de los campos de los extras activos con `fields` (p. ej. { carga: { weight: '20', value: '150' } }). */
56
+ extraFields: Record<string, Record<string, string>>;
57
+ vehicles: number;
58
+ payment: string;
59
+ }
60
+ /** Servicios del diseño de Figma. Reemplázalos con los datos de tu API. */
61
+ export declare const wariServices: WariService[];
62
+ export declare const wariExtras: WariOption[];
63
+ export declare const wariPaymentMethods: WariOption[];
64
+ export declare const defaultTripAttributes: WariTripAttributesValue;
65
+ export interface ServiceMeta {
66
+ /** Mostrar la insignia "Envío". */
67
+ delivery: boolean;
68
+ /** "Desde S/80" cuando el viaje es por horas. */
69
+ price: string | null;
70
+ /** Capacidad cuando no es por horas ni envío. */
71
+ capacity: {
72
+ passengers: number;
73
+ luggage: number;
74
+ luggageAlt?: number;
75
+ } | null;
76
+ /** Texto completo para lectores de pantalla. */
77
+ label: string;
78
+ }
79
+ export declare const formatSoles: (amount: number) => string;
80
+ /** Lo que muestra el diseño a la derecha de cada servicio, según "Por horas" y "Envíos". */
81
+ export declare function serviceMeta(service: WariService, mode: {
82
+ hourly: boolean;
83
+ delivery: boolean;
84
+ }): ServiceMeta;
85
+ export declare function clampCount(value: number, min?: number, max?: number): number;
86
+ /** Type-ahead for select-only comboboxes: next enabled option whose label starts with `query`, after `from`. */
87
+ export declare function typeaheadIndex(options: readonly WariOption[], query: string, from: number): number;
88
+ export declare function toggleExtra(extras: readonly string[], value: string, options?: readonly WariOption[]): string[];
89
+ /** Cantidades solo de los extras activos con `maxQuantity`; un extra recién activado empieza en 1. */
90
+ export declare function syncExtraQuantities(extras: readonly string[], quantities: Readonly<Record<string, number>>, options?: readonly WariOption[]): Record<string, number>;
91
+ /**
92
+ * Opciones por unidad solo de los extras activos con `choices`: un extra recién activado empieza con una unidad
93
+ * (la primera opción), se descartan valores que ya no existen y nunca hay más de `maxQuantity` unidades.
94
+ */
95
+ export declare function syncExtraChoices(extras: readonly string[], choices: Readonly<Record<string, readonly string[]>>, options?: readonly WariOption[]): Record<string, string[]>;
96
+ /** Texto de los campos solo de los extras activos con `fields`; un extra recién activado empieza con los campos vacíos. */
97
+ export declare function syncExtraFields(extras: readonly string[], fields: Readonly<Record<string, Readonly<Record<string, string>>>>, options?: readonly WariOption[]): Record<string, Record<string, string>>;
98
+ export interface WariExtrasState {
99
+ extraQuantities: Record<string, number>;
100
+ extraChoices: Record<string, string[]>;
101
+ extraFields: Record<string, Record<string, string>>;
102
+ }
103
+ /**
104
+ * Cantidades, opciones y campos coherentes con los extras activos. La cantidad de un extra con `choices` es su número
105
+ * de unidades; los extras inactivos no guardan nada.
106
+ */
107
+ export declare function syncExtras(extras: readonly string[], current?: Partial<WariExtrasState>, options?: readonly WariOption[]): WariExtrasState;