@directo-ui/web 1.0.0 → 1.1.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,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,16 @@
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;
@@ -0,0 +1,30 @@
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 { clampCount, defaultTripAttributes, formatSoles, serviceMeta, toggleExtra, typeaheadIndex, wariExtras, wariPaymentMethods, wariServices, } from './trip.js';
13
+ export { wariStatuses, wariStatusLabel } from './statuses.js';
14
+ export { calendarWeeks, formatDisplayDate, formatDisplayTime, parseDisplayDate, parseDisplayTime, parseISODate, parseTime24, toISODate, todayISO, } from './datetime.js';
15
+ export { filterOptions, normalizeSearch, selectionState, selectionSummary, toggleAll, toggleValue } from './logic.js';
16
+ export type { StatusTagProps } from './StatusTag.js';
17
+ export type { MultiSelectProps, MultiSelectOption } from './MultiSelect.js';
18
+ export type { WariStatusSelectProps } from './WariStatusSelect.js';
19
+ export type { WariStatus } from './statuses.js';
20
+ export type { WariDateFieldProps } from './WariDateField.js';
21
+ export type { WariTimeFieldProps } from './WariTimeField.js';
22
+ export type { WariScheduleProps } from './WariSchedule.js';
23
+ export type { WariSelectProps, WariSelectOption } from './WariSelect.js';
24
+ export type { WariSwitchListProps } from './WariSwitchList.js';
25
+ export type { WariStepperProps } from './WariStepper.js';
26
+ export type { WariServiceMetaProps } from './WariServiceMeta.js';
27
+ export type { WariTripAttributesProps } from './WariTripAttributes.js';
28
+ export type { WariService, WariOption, WariTripAttributesValue, ServiceMeta } from './trip.js';
29
+ export type { CalendarDay, TimeParts, Period } from './datetime.js';
30
+ 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,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,56 @@
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
+ }
19
+ export interface WariTripAttributesValue {
20
+ service: string;
21
+ hourly: boolean;
22
+ delivery: boolean;
23
+ /** Valores de los extras activos (por defecto: carseat, booster, carga). */
24
+ extras: string[];
25
+ vehicles: number;
26
+ payment: string;
27
+ }
28
+ /** Servicios del diseño de Figma. Reemplázalos con los datos de tu API. */
29
+ export declare const wariServices: WariService[];
30
+ export declare const wariExtras: WariOption[];
31
+ export declare const wariPaymentMethods: WariOption[];
32
+ export declare const defaultTripAttributes: WariTripAttributesValue;
33
+ export interface ServiceMeta {
34
+ /** Mostrar la insignia "Envío". */
35
+ delivery: boolean;
36
+ /** "Desde S/80" cuando el viaje es por horas. */
37
+ price: string | null;
38
+ /** Capacidad cuando no es por horas ni envío. */
39
+ capacity: {
40
+ passengers: number;
41
+ luggage: number;
42
+ luggageAlt?: number;
43
+ } | null;
44
+ /** Texto completo para lectores de pantalla. */
45
+ label: string;
46
+ }
47
+ export declare const formatSoles: (amount: number) => string;
48
+ /** Lo que muestra el diseño a la derecha de cada servicio, según "Por horas" y "Envíos". */
49
+ export declare function serviceMeta(service: WariService, mode: {
50
+ hourly: boolean;
51
+ delivery: boolean;
52
+ }): ServiceMeta;
53
+ export declare function clampCount(value: number, min?: number, max?: number): number;
54
+ /** Type-ahead for select-only comboboxes: next enabled option whose label starts with `query`, after `from`. */
55
+ export declare function typeaheadIndex(options: readonly WariOption[], query: string, from: number): number;
56
+ export declare function toggleExtra(extras: readonly string[], value: string, options?: readonly WariOption[]): string[];