@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.
- package/README.md +5 -0
- package/dist/components/Autocomplete.d.ts +17 -0
- package/dist/components/DataTable.d.ts +49 -0
- package/dist/components/DateRangePicker.d.ts +33 -0
- package/dist/components/Drawer.d.ts +23 -0
- package/dist/components/FileUpload.d.ts +26 -0
- package/dist/components/FilterBar.d.ts +27 -0
- package/dist/components/Sidebar.d.ts +32 -0
- package/dist/components/Timeline.d.ts +24 -0
- package/dist/components/index.d.ts +18 -0
- package/dist/core/files.d.ts +27 -0
- package/dist/figma-components-directo.js +831 -297
- package/dist/figma-components-directo.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/wari/WariClientDetails.d.ts +30 -0
- package/dist/wari/WariClientSearch.d.ts +41 -0
- package/dist/wari/WariPassengerField.d.ts +29 -0
- package/dist/wari/WariRoute.d.ts +25 -0
- package/dist/wari/WariStepper.d.ts +5 -1
- package/dist/wari/WariSwitchList.d.ts +23 -3
- package/dist/wari/icons.d.ts +19 -0
- package/dist/wari/index.d.ts +12 -2
- package/dist/wari/motion.d.ts +14 -0
- package/dist/wari/route.d.ts +48 -0
- package/dist/wari/trip.d.ts +51 -0
- package/dist/wari.js +1566 -527
- package/dist/wari.js.map +1 -1
- package/package.json +7 -8
package/README.md
CHANGED
|
@@ -33,6 +33,11 @@ const [statuses, setStatuses] = useState<WariStatus[]>([]);
|
|
|
33
33
|
<WariStatusSelect value={statuses} onChange={setStatuses} descriptions={{ libre: '12' }} />
|
|
34
34
|
<StatusTag status="aceptado" />
|
|
35
35
|
|
|
36
|
+
// Cliente / usuario: onChange en cada tecla, onSearch con Enter
|
|
37
|
+
<WariClientSearch value={query} onChange={setQuery} onSearch={buscar} onCreate={crearCliente} loading={cargando}>
|
|
38
|
+
{cliente && <WariClientDetails name={cliente.nombre} phone={cliente.telefono} notes={cliente.notas} onRates={verTarifas} />}
|
|
39
|
+
</WariClientSearch>
|
|
40
|
+
|
|
36
41
|
// Atributos del viaje: { service, hourly, delivery, extras, vehicles, payment }
|
|
37
42
|
<WariTripAttributes value={trip} onChange={setTrip} services={servicesFromApi} />
|
|
38
43
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TextFieldProps } from './TextField.js';
|
|
2
|
+
export interface AutocompleteProps extends Omit<TextFieldProps, 'list' | 'type' | 'onSelect'> {
|
|
3
|
+
options: readonly string[];
|
|
4
|
+
/** The value matches one of the options (picked from the list or typed in full). */
|
|
5
|
+
onSelect?: (option: string) => void;
|
|
6
|
+
/** Typing pause, to load options from your API. Fires after debounceMs and only with minChars or more. */
|
|
7
|
+
onSearch?: (query: string) => void;
|
|
8
|
+
debounceMs?: number;
|
|
9
|
+
minChars?: number;
|
|
10
|
+
/** Shows "Buscando…" while you load options. */
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
loadingText?: string;
|
|
13
|
+
/** When false, leaving the field with a value that is not in the list shows invalidMessage. */
|
|
14
|
+
allowCustomValue?: boolean;
|
|
15
|
+
invalidMessage?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function Autocomplete({ options, onSelect, onSearch, debounceMs, minChars, loading, loadingText, allowCustomValue, invalidMessage, onChange, onBlur, error, supportingText, ...props }: AutocompleteProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Key, KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
export type DataTableSortDirection = 'ascending' | 'descending';
|
|
3
|
+
export interface DataTableSort {
|
|
4
|
+
id: string;
|
|
5
|
+
direction: DataTableSortDirection;
|
|
6
|
+
}
|
|
7
|
+
export interface DataTableColumn<Row> {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
cell: (row: Row) => ReactNode;
|
|
11
|
+
sortValue?: (row: Row) => string | number;
|
|
12
|
+
/** Text alignment of the column (numbers and amounts read better at the end). */
|
|
13
|
+
align?: 'start' | 'center' | 'end';
|
|
14
|
+
}
|
|
15
|
+
export interface DataTableProps<Row> {
|
|
16
|
+
caption: string;
|
|
17
|
+
columns: readonly DataTableColumn<Row>[];
|
|
18
|
+
rows: readonly Row[];
|
|
19
|
+
rowKey: (row: Row) => Key;
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
loadingMessage?: string;
|
|
22
|
+
emptyMessage?: string;
|
|
23
|
+
pagination?: {
|
|
24
|
+
page: number;
|
|
25
|
+
onPageChange: (page: number) => void;
|
|
26
|
+
} & ({
|
|
27
|
+
pageSize: number;
|
|
28
|
+
totalPages?: never;
|
|
29
|
+
} | {
|
|
30
|
+
totalPages: number;
|
|
31
|
+
pageSize?: never;
|
|
32
|
+
});
|
|
33
|
+
/** Controlled sort. Pass null for no sort. */
|
|
34
|
+
sort?: DataTableSort | null;
|
|
35
|
+
/** Initial sort when the table controls it. */
|
|
36
|
+
defaultSort?: DataTableSort;
|
|
37
|
+
/** Called when a sortable header is pressed. With pageSize pagination the table also goes back to page 1. */
|
|
38
|
+
onSortChange?: (sort: DataTableSort) => void;
|
|
39
|
+
/** Do not reorder the rows locally (the server already sorts them using onSortChange). */
|
|
40
|
+
manualSort?: boolean;
|
|
41
|
+
/** Makes every row clickable (mouse, Enter or Space). Clicks on links, buttons or fields inside the row are ignored. */
|
|
42
|
+
onRowClick?: (row: Row, event: MouseEvent<HTMLTableRowElement> | KeyboardEvent<HTMLTableRowElement>) => void;
|
|
43
|
+
density?: 'comfortable' | 'compact';
|
|
44
|
+
/** Keeps the header visible while the table scrolls (give the table a max height with CSS). */
|
|
45
|
+
stickyHeader?: boolean;
|
|
46
|
+
id?: string;
|
|
47
|
+
className?: string;
|
|
48
|
+
}
|
|
49
|
+
export declare function DataTable<Row>({ caption, columns, rows, rowKey, loading, loadingMessage, emptyMessage, pagination, sort: sortProp, defaultSort, onSortChange, manualSort, onRowClick, density, stickyHeader, id, className, }: DataTableProps<Row>): import("react").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface DateRange {
|
|
2
|
+
start: string;
|
|
3
|
+
end: string;
|
|
4
|
+
}
|
|
5
|
+
export interface DateRangePreset {
|
|
6
|
+
label: string;
|
|
7
|
+
range: DateRange;
|
|
8
|
+
}
|
|
9
|
+
export interface DateRangePickerProps {
|
|
10
|
+
label?: string;
|
|
11
|
+
startLabel?: string;
|
|
12
|
+
endLabel?: string;
|
|
13
|
+
/** Controlled value (YYYY-MM-DD). Leave it out and use defaultValue to let the picker keep its own state. */
|
|
14
|
+
value?: DateRange;
|
|
15
|
+
defaultValue?: DateRange;
|
|
16
|
+
/** Every change of either date. */
|
|
17
|
+
onChange?: (value: DateRange) => void;
|
|
18
|
+
/** Both dates are filled and the end is not before the start: a good moment to search or load a report. */
|
|
19
|
+
onComplete?: (value: DateRange) => void;
|
|
20
|
+
min?: string;
|
|
21
|
+
max?: string;
|
|
22
|
+
startName?: string;
|
|
23
|
+
endName?: string;
|
|
24
|
+
required?: boolean;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** Your own error message. Without it the picker still warns when the end is before the start. */
|
|
27
|
+
error?: string;
|
|
28
|
+
/** Quick ranges shown as buttons, for example Hoy or Últimos 7 días. */
|
|
29
|
+
presets?: readonly DateRangePreset[];
|
|
30
|
+
id?: string;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function DateRangePicker({ label, startLabel, endLabel, value: valueProp, defaultValue, onChange, onComplete, min, max, startName, endName, required, disabled, error, presets, id: idProp, className, }: DateRangePickerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface DrawerProps {
|
|
3
|
+
title: string;
|
|
4
|
+
/** Optional text under the title; screen readers announce it with the title. */
|
|
5
|
+
description?: string;
|
|
6
|
+
/** Controlled state. Leave it out (and use defaultOpen) to let the drawer open and close by itself. */
|
|
7
|
+
open?: boolean;
|
|
8
|
+
defaultOpen?: boolean;
|
|
9
|
+
onOpenChange?: (open: boolean) => void;
|
|
10
|
+
side?: 'start' | 'end';
|
|
11
|
+
/** Width: sm 360px, md 440px, lg 640px (never wider than the screen). */
|
|
12
|
+
size?: 'sm' | 'md' | 'lg';
|
|
13
|
+
trigger?: ReactNode;
|
|
14
|
+
/** Fixed area under the content, for actions such as Guardar or Cancelar. */
|
|
15
|
+
footer?: ReactNode;
|
|
16
|
+
/** Close when the dimmed backdrop is clicked. */
|
|
17
|
+
closeOnBackdrop?: boolean;
|
|
18
|
+
closeOnEscape?: boolean;
|
|
19
|
+
closeLabel?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export declare function Drawer({ title, description, open: openProp, defaultOpen, onOpenChange, side, size, trigger, footer, closeOnBackdrop, closeOnEscape, closeLabel, className, children, }: DrawerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FileRejection } from '../core/files.js';
|
|
2
|
+
export interface FileUploadProps {
|
|
3
|
+
label: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
accept?: string;
|
|
6
|
+
multiple?: boolean;
|
|
7
|
+
/** Maximum size of each file, in bytes. */
|
|
8
|
+
maxBytes?: number;
|
|
9
|
+
/** Maximum number of files (with multiple). */
|
|
10
|
+
maxFiles?: number;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Help text under the label, for example "PDF o imagen, hasta 2 MB". */
|
|
14
|
+
supportingText?: string;
|
|
15
|
+
/** Allows dropping files onto the component. */
|
|
16
|
+
dropzone?: boolean;
|
|
17
|
+
id?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
/** Every time the list of valid files changes (select, drop or remove). */
|
|
20
|
+
onFilesChange?: (files: readonly File[]) => void;
|
|
21
|
+
/** Files that were left out and why (type, size or count). */
|
|
22
|
+
onReject?: (rejections: readonly FileRejection[]) => void;
|
|
23
|
+
/** A file was removed with its Quitar button. */
|
|
24
|
+
onFileRemove?: (file: File) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function FileUpload({ label, name, accept, multiple, maxBytes, maxFiles, required, disabled, supportingText, dropzone, id: idProp, className, onFilesChange, onReject, onFileRemove, }: FileUploadProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FormEvent, ReactNode } from 'react';
|
|
2
|
+
export interface ActiveFilter {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
/** Removes this filter. You can also handle every filter at once with onFilterRemove. */
|
|
6
|
+
onRemove?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface FilterBarProps {
|
|
9
|
+
label?: string;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
activeFilters?: readonly ActiveFilter[];
|
|
12
|
+
/** Called with the id of the removed filter (after its own onRemove). */
|
|
13
|
+
onFilterRemove?: (id: string) => void;
|
|
14
|
+
/** Shows the "Limpiar filtros" button. */
|
|
15
|
+
onClear?: () => void;
|
|
16
|
+
clearLabel?: string;
|
|
17
|
+
/** Number of results; it is announced to screen readers when it changes. */
|
|
18
|
+
resultCount?: number;
|
|
19
|
+
resultLabel?: (count: number) => string;
|
|
20
|
+
/** Renders the bar as a search form: Enter in a field submits it with the values of the named fields. */
|
|
21
|
+
onSubmit?: (data: FormData, event: FormEvent<HTMLFormElement>) => void;
|
|
22
|
+
/** Extra actions at the end of the bar (for example Exportar). */
|
|
23
|
+
actions?: ReactNode;
|
|
24
|
+
id?: string;
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function FilterBar({ label, children, activeFilters, onFilterRemove, onClear, clearLabel, resultCount, resultLabel, onSubmit, actions, id, className, }: FilterBarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MouseEvent, ReactNode } from 'react';
|
|
2
|
+
export interface SidebarLink {
|
|
3
|
+
label: string;
|
|
4
|
+
href: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
/** Small counter or text at the end, for example 3 pending trips. */
|
|
7
|
+
badge?: string | number;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface SidebarItem extends SidebarLink {
|
|
11
|
+
children?: readonly SidebarLink[];
|
|
12
|
+
}
|
|
13
|
+
export interface SidebarGroup {
|
|
14
|
+
label: string;
|
|
15
|
+
items: readonly SidebarItem[];
|
|
16
|
+
/** The group title opens and closes the group. */
|
|
17
|
+
collapsible?: boolean;
|
|
18
|
+
/** Initial state of a collapsible group (open by default). */
|
|
19
|
+
defaultOpen?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface SidebarProps {
|
|
22
|
+
groups: readonly SidebarGroup[];
|
|
23
|
+
activeHref?: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
/** A link was clicked. Call event.preventDefault() to navigate with your router instead. */
|
|
26
|
+
onNavigate?: (item: SidebarLink, event: MouseEvent<HTMLAnchorElement>) => void;
|
|
27
|
+
header?: ReactNode;
|
|
28
|
+
footer?: ReactNode;
|
|
29
|
+
id?: string;
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function Sidebar({ groups, activeHref, label, onNavigate, header, footer, id, className }: SidebarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type TimelineVariant = 'default' | 'info' | 'success' | 'warning' | 'error';
|
|
3
|
+
export interface TimelineItem {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
dateTime?: string;
|
|
7
|
+
dateLabel?: string;
|
|
8
|
+
actor?: string;
|
|
9
|
+
description?: ReactNode;
|
|
10
|
+
/** Color of the dot: info, success, warning or error. */
|
|
11
|
+
variant?: TimelineVariant;
|
|
12
|
+
/** Marks the step that is happening now (aria-current="step"). */
|
|
13
|
+
current?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface TimelineProps {
|
|
16
|
+
items: readonly TimelineItem[];
|
|
17
|
+
label?: string;
|
|
18
|
+
/** Text shown when there are no events. */
|
|
19
|
+
emptyMessage?: string;
|
|
20
|
+
density?: 'comfortable' | 'compact';
|
|
21
|
+
id?: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function Timeline({ items, label, emptyMessage, density, id, className }: TimelineProps): import("react").JSX.Element;
|
|
@@ -26,3 +26,21 @@ export { paginationRange } from '../core/pagination.js';
|
|
|
26
26
|
export { Divider } from './Divider.js';
|
|
27
27
|
export { ToastProvider } from './Toast.js';
|
|
28
28
|
export { useToast } from '../core/toast.js';
|
|
29
|
+
export { DataTable } from './DataTable.js';
|
|
30
|
+
export type { DataTableColumn, DataTableProps, DataTableSort, DataTableSortDirection } from './DataTable.js';
|
|
31
|
+
export { FilterBar } from './FilterBar.js';
|
|
32
|
+
export type { ActiveFilter, FilterBarProps } from './FilterBar.js';
|
|
33
|
+
export { Drawer } from './Drawer.js';
|
|
34
|
+
export type { DrawerProps } from './Drawer.js';
|
|
35
|
+
export { FileUpload } from './FileUpload.js';
|
|
36
|
+
export type { FileUploadProps } from './FileUpload.js';
|
|
37
|
+
export { acceptsFile, formatBytes, selectFiles } from '../core/files.js';
|
|
38
|
+
export type { FileRejection, FileRejectionReason, FileRules } from '../core/files.js';
|
|
39
|
+
export { Timeline } from './Timeline.js';
|
|
40
|
+
export type { TimelineItem, TimelineProps, TimelineVariant } from './Timeline.js';
|
|
41
|
+
export { DateRangePicker } from './DateRangePicker.js';
|
|
42
|
+
export type { DateRange, DateRangePickerProps, DateRangePreset } from './DateRangePicker.js';
|
|
43
|
+
export { Autocomplete } from './Autocomplete.js';
|
|
44
|
+
export type { AutocompleteProps } from './Autocomplete.js';
|
|
45
|
+
export { Sidebar } from './Sidebar.js';
|
|
46
|
+
export type { SidebarGroup, SidebarItem, SidebarLink, SidebarProps } from './Sidebar.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type FileRejectionReason = 'type' | 'size' | 'count';
|
|
2
|
+
export interface FileRejection {
|
|
3
|
+
file: File;
|
|
4
|
+
reason: FileRejectionReason;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FileRules {
|
|
8
|
+
/** Same syntax as the input accept attribute: ".pdf", "image/*", "application/pdf". */
|
|
9
|
+
accept?: string;
|
|
10
|
+
/** Maximum size of each file, in bytes. */
|
|
11
|
+
maxBytes?: number;
|
|
12
|
+
/** Maximum number of files kept at once (only with multiple). */
|
|
13
|
+
maxFiles?: number;
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** 1536 → "1.5 KB". */
|
|
17
|
+
export declare function formatBytes(bytes: number): string;
|
|
18
|
+
/** True when the file matches one of the accept rules (or there are none). */
|
|
19
|
+
export declare function acceptsFile(file: Pick<File, 'name' | 'type'>, accept?: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Adds `incoming` to the `current` selection: with multiple the files are appended (without duplicates),
|
|
22
|
+
* otherwise the first valid file replaces the selection. Returns the kept files and why the others were left out.
|
|
23
|
+
*/
|
|
24
|
+
export declare function selectFiles(current: readonly File[], incoming: readonly File[], rules?: FileRules): {
|
|
25
|
+
files: File[];
|
|
26
|
+
rejections: FileRejection[];
|
|
27
|
+
};
|