@directo-ui/web 1.1.0 → 1.3.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.
@@ -2,16 +2,36 @@ import type { WariOption } from './trip.js';
2
2
  export interface WariSwitchListProps {
3
3
  /** Nombre del grupo para lectores de pantalla (no se muestra). */
4
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
+ */
5
9
  items: readonly WariOption[];
6
10
  /** Valores activos. */
7
11
  value?: string[];
8
12
  defaultValue?: string[];
9
- onChange?: (value: string[]) => void;
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;
10
30
  orientation?: 'vertical' | 'horizontal';
11
- /** Envía cada interruptor activo como `name=value` dentro de un <form>. */
31
+ /** Envía cada interruptor activo como `name=value` (y su cantidad u opciones como `name.value`) dentro de un <form>. */
12
32
  name?: string;
13
33
  disabled?: boolean;
14
34
  className?: string;
15
35
  }
16
36
  /** Interruptores agrupados en un recuadro con divisores (Por horas / Envíos, Carseat / Booster / Carga). */
17
- export declare function WariSwitchList({ legend, items, value, defaultValue, onChange, orientation, name, disabled, className, }: WariSwitchListProps): import("react").JSX.Element;
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;
@@ -14,3 +14,22 @@ export declare const PlusIcon: () => import("react").JSX.Element;
14
14
  export declare const UserIcon: () => import("react").JSX.Element;
15
15
  export declare const LuggageIcon: () => import("react").JSX.Element;
16
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;
@@ -9,7 +9,12 @@ export { WariSwitchList } from './WariSwitchList.js';
9
9
  export { WariStepper } from './WariStepper.js';
10
10
  export { WariServiceMeta } from './WariServiceMeta.js';
11
11
  export { WariTripAttributes } from './WariTripAttributes.js';
12
- export { clampCount, defaultTripAttributes, formatSoles, serviceMeta, toggleExtra, typeaheadIndex, wariExtras, wariPaymentMethods, wariServices, } from './trip.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';
13
18
  export { wariStatuses, wariStatusLabel } from './statuses.js';
14
19
  export { calendarWeeks, formatDisplayDate, formatDisplayTime, parseDisplayDate, parseDisplayTime, parseISODate, parseTime24, toISODate, todayISO, } from './datetime.js';
15
20
  export { filterOptions, normalizeSearch, selectionState, selectionSummary, toggleAll, toggleValue } from './logic.js';
@@ -25,6 +30,11 @@ export type { WariSwitchListProps } from './WariSwitchList.js';
25
30
  export type { WariStepperProps } from './WariStepper.js';
26
31
  export type { WariServiceMetaProps } from './WariServiceMeta.js';
27
32
  export type { WariTripAttributesProps } from './WariTripAttributes.js';
28
- export type { WariService, WariOption, WariTripAttributesValue, ServiceMeta } from './trip.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';
29
39
  export type { CalendarDay, TimeParts, Period } from './datetime.js';
30
40
  export type { SelectableOption, SelectionState } from './logic.js';
@@ -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;
@@ -15,6 +15,32 @@ export interface WariOption {
15
15
  value: string;
16
16
  label: string;
17
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;
18
44
  }
19
45
  export interface WariTripAttributesValue {
20
46
  service: string;
@@ -22,6 +48,12 @@ export interface WariTripAttributesValue {
22
48
  delivery: boolean;
23
49
  /** Valores de los extras activos (por defecto: carseat, booster, carga). */
24
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>>;
25
57
  vehicles: number;
26
58
  payment: string;
27
59
  }
@@ -54,3 +86,22 @@ export declare function clampCount(value: number, min?: number, max?: number): n
54
86
  /** Type-ahead for select-only comboboxes: next enabled option whose label starts with `query`, after `from`. */
55
87
  export declare function typeaheadIndex(options: readonly WariOption[], query: string, from: number): number;
56
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;