@directo-ui/astro 1.2.0 → 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/components.css +231 -0
- package/index.d.ts +47 -31
- package/index.js +46 -31
- package/package.json +5 -1
- package/src/close-icon.d.ts +2 -0
- package/src/close-icon.js +9 -0
- package/src/components/Alert.astro +2 -1
- package/src/components/Autocomplete.astro +107 -0
- package/src/components/Badge.astro +28 -13
- package/src/components/BottomSheet.astro +2 -1
- package/src/components/CellText.astro +17 -0
- package/src/components/Chip.astro +21 -0
- package/src/components/ChipGroup.astro +30 -0
- package/src/components/CloseButton.astro +18 -0
- package/src/components/DataTable.astro +168 -0
- package/src/components/DatePicker.astro +2 -1
- package/src/components/DateRangePicker.astro +107 -0
- package/src/components/Drawer.astro +41 -0
- package/src/components/Dropdown.astro +3 -2
- package/src/components/FieldLabel.astro +14 -0
- package/src/components/FileUpload.astro +153 -0
- package/src/components/FilterBar.astro +68 -0
- package/src/components/Modal.astro +4 -2
- package/src/components/MultiSelect.astro +2 -1
- package/src/components/Select.astro +2 -1
- package/src/components/Sidebar.astro +64 -0
- package/src/components/StatusTag.astro +4 -2
- package/src/components/Tabs.astro +60 -60
- package/src/components/TextField.astro +2 -1
- package/src/components/Textarea.astro +2 -1
- package/src/components/Timeline.astro +25 -0
- package/src/components/WariDateField.astro +2 -1
- package/src/components/WariDriverInbox.astro +74 -0
- package/src/components/WariSelect.astro +2 -1
- package/src/components/WariTimeField.astro +2 -1
- package/src/files.d.ts +27 -0
- package/src/files.js +52 -0
- package/src/modal.d.ts +3 -3
- package/src/modal.js +50 -39
- package/src/toast.d.ts +2 -0
- package/src/toast.js +18 -7
- package/src/wari/inbox.d.ts +13 -0
- package/src/wari/inbox.js +28 -0
- package/wari.d.ts +3 -0
- package/wari.js +2 -0
package/src/modal.js
CHANGED
|
@@ -1,39 +1,50 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wires native <dialog data-ds-modal> elements:
|
|
3
|
-
* - any element with data-ds-open="<dialog id>" opens it as a modal,
|
|
4
|
-
* - any [data-ds-close] inside closes it, as does a backdrop click or Escape,
|
|
5
|
-
* - focus returns to the opener. Safe to call repeatedly.
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Wires native <dialog data-ds-modal> elements:
|
|
3
|
+
* - any element with data-ds-open="<dialog id>" opens it as a modal,
|
|
4
|
+
* - any [data-ds-close] inside closes it, as does a backdrop click or Escape,
|
|
5
|
+
* - focus returns to the opener. Safe to call repeatedly.
|
|
6
|
+
* - data-ds-backdrop="static" keeps it open on backdrop clicks; data-ds-escape="false" ignores Escape.
|
|
7
|
+
* - the dialog emits ds-open and ds-close (bubbling CustomEvents) besides the native close event.
|
|
8
|
+
* @param {ParentNode | Event} [root=document]
|
|
9
|
+
*/
|
|
10
|
+
export function initModals(root = document) {
|
|
11
|
+
// Also works as an event listener (astro:page-load passes an Event).
|
|
12
|
+
const scope = root && typeof root.querySelectorAll === 'function' ? root : document;
|
|
13
|
+
scope.querySelectorAll('[data-ds-open]:not([data-ds-ready])').forEach(trigger => {
|
|
14
|
+
trigger.dataset.dsReady = '';
|
|
15
|
+
trigger.setAttribute('aria-haspopup', 'dialog');
|
|
16
|
+
trigger.addEventListener('click', () => openModal(trigger.dataset.dsOpen ?? '', trigger));
|
|
17
|
+
});
|
|
18
|
+
scope.querySelectorAll('dialog[data-ds-modal]:not([data-ds-ready])').forEach(dialog => {
|
|
19
|
+
dialog.dataset.dsReady = '';
|
|
20
|
+
dialog.addEventListener('click', event => {
|
|
21
|
+
const target = event.target;
|
|
22
|
+
const backdrop = target === dialog && dialog.dataset.dsBackdrop !== 'static';
|
|
23
|
+
if (backdrop || (target instanceof Element && target.closest('[data-ds-close]'))) dialog.close();
|
|
24
|
+
});
|
|
25
|
+
dialog.addEventListener('cancel', event => { if (dialog.dataset.dsEscape === 'false') event.preventDefault(); });
|
|
26
|
+
dialog.addEventListener('close', () => dialog.dispatchEvent(new CustomEvent('ds-close', { bubbles: true })));
|
|
27
|
+
if (dialog.hasAttribute('data-ds-open-initially') && !dialog.open) {
|
|
28
|
+
dialog.showModal();
|
|
29
|
+
dialog.dispatchEvent(new CustomEvent('ds-open', { bubbles: true, detail: { opener: undefined } }));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const openers = new WeakMap();
|
|
35
|
+
|
|
36
|
+
/** @param {string} id @param {HTMLElement} [opener] */
|
|
37
|
+
export function openModal(id, opener) {
|
|
38
|
+
const dialog = document.getElementById(id);
|
|
39
|
+
if (!(dialog instanceof HTMLDialogElement) || dialog.open) return;
|
|
40
|
+
if (opener) openers.set(dialog, opener);
|
|
41
|
+
dialog.showModal();
|
|
42
|
+
dialog.dispatchEvent(new CustomEvent('ds-open', { bubbles: true, detail: { opener } }));
|
|
43
|
+
dialog.addEventListener('close', () => openers.get(dialog)?.focus({ preventScroll: true }), { once: true });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** @param {string} id */
|
|
47
|
+
export function closeModal(id) {
|
|
48
|
+
const dialog = document.getElementById(id);
|
|
49
|
+
if (dialog instanceof HTMLDialogElement) dialog.close();
|
|
50
|
+
}
|
package/src/toast.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export interface ToastOptions {
|
|
|
4
4
|
variant?: 'info' | 'success' | 'warning' | 'error';
|
|
5
5
|
/** Milliseconds before auto-dismiss; 0 keeps it until closed. Default 5000. */
|
|
6
6
|
duration?: number;
|
|
7
|
+
/** Text button inside the notification; it closes after onClick runs. */
|
|
8
|
+
action?: { label: string; onClick: () => void };
|
|
7
9
|
}
|
|
8
10
|
export declare function toast(options: ToastOptions): HTMLLIElement;
|
|
9
11
|
export declare function dismissToast(item: HTMLElement): void;
|
package/src/toast.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// import { toast } from '@directo-ui/astro/toast';
|
|
3
3
|
// toast({ title: 'Guardado', variant: 'success' });
|
|
4
4
|
|
|
5
|
+
import { closeButtonHtml } from './close-icon.js';
|
|
6
|
+
|
|
5
7
|
const paths = {
|
|
6
8
|
info: 'M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm-4 48a12 12 0 1 1-12 12 12 12 0 0 1 12-12Zm12 112a16 16 0 0 1-16-16v-40a8 8 0 0 1 0-16 16 16 0 0 1 16 16v40a8 8 0 0 1 0 16Z',
|
|
7
9
|
success: 'M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm45.66 85.66-56 56a8 8 0 0 1-11.32 0l-24-24a8 8 0 0 1 11.32-11.32L112 148.69l50.34-50.35a8 8 0 0 1 11.32 11.32Z',
|
|
@@ -27,8 +29,8 @@ export function dismissToast(item) {
|
|
|
27
29
|
setTimeout(() => item.remove(), 180);
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
/** @param {{ title: string, description?: string, variant?: 'info'|'success'|'warning'|'error', duration?: number }} options */
|
|
31
|
-
export function toast({ title, description, variant = 'info', duration = 5000 }) {
|
|
32
|
+
/** @param {{ title: string, description?: string, variant?: 'info'|'success'|'warning'|'error', duration?: number, action?: { label: string, onClick: () => void } }} options */
|
|
33
|
+
export function toast({ title, description, variant = 'info', duration = 5000, action }) {
|
|
32
34
|
const toaster = region();
|
|
33
35
|
while (toaster.children.length >= 5) toaster.firstElementChild?.remove();
|
|
34
36
|
const item = document.createElement('li');
|
|
@@ -53,11 +55,20 @@ export function toast({ title, description, variant = 'info', duration = 5000 })
|
|
|
53
55
|
text.textContent = description;
|
|
54
56
|
content.append(text);
|
|
55
57
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
if (action) {
|
|
59
|
+
const wrap = document.createElement('div');
|
|
60
|
+
wrap.className = 'ds-toast-action';
|
|
61
|
+
const button = document.createElement('button');
|
|
62
|
+
button.type = 'button';
|
|
63
|
+
button.className = 'ds-button';
|
|
64
|
+
button.dataset.variant = 'text';
|
|
65
|
+
button.dataset.size = 'xs';
|
|
66
|
+
button.textContent = action.label;
|
|
67
|
+
button.addEventListener('click', () => { action.onClick(); dismissToast(item); });
|
|
68
|
+
wrap.append(button);
|
|
69
|
+
content.append(wrap);
|
|
70
|
+
}
|
|
71
|
+
const close = document.createRange().createContextualFragment(closeButtonHtml('Cerrar notificación', 'xs', 'ds-toast-close')).firstElementChild;
|
|
61
72
|
close.addEventListener('click', () => dismissToast(item));
|
|
62
73
|
item.append(icon, content, close);
|
|
63
74
|
toaster.append(item);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface WariInboxOption {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Tabs of the Figma "Bandeja interna del conductor". */
|
|
7
|
+
export declare const wariInboxTabs: readonly WariInboxOption[];
|
|
8
|
+
/** Filters of each tab (tabs without filters show only the actions). */
|
|
9
|
+
export declare const wariInboxFilters: Readonly<Record<string, readonly WariInboxOption[]>>;
|
|
10
|
+
/** Filled funnel (Filtros avanzados), 24×24 viewBox. */
|
|
11
|
+
export declare const funnelIconPath = "M3.5 4.5h17a.8.8 0 0 1 .6 1.3L14.5 13v5.6a.8.8 0 0 1-.4.7l-3.4 1.9a.8.8 0 0 1-1.2-.7V13L2.9 5.8a.8.8 0 0 1 .6-1.3Z";
|
|
12
|
+
/** Four corner arrows (Ver lista completa), 24×24 viewBox, stroked. */
|
|
13
|
+
export declare const expandIconPath = "M15 4h5v5M20 4l-6 6M9 20H4v-5M4 20l6-6M4 9V4h5M4 4l6 6M20 15v5h-5M20 20l-6-6";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Bandeja interna del conductor: tabs, filters and icons shared by React, Angular and Astro (same file in the three packages).
|
|
2
|
+
/** Tabs of the Figma "Bandeja interna del conductor". */
|
|
3
|
+
export const wariInboxTabs = [
|
|
4
|
+
{ value: 'historial', label: 'Historial' },
|
|
5
|
+
{ value: 'mensajes', label: 'Mensajes' },
|
|
6
|
+
{ value: 'incidencias', label: 'Incidencias/ suspensiones/ bloqueos' },
|
|
7
|
+
{ value: 'equipo', label: 'Log. Equipo' },
|
|
8
|
+
];
|
|
9
|
+
/** Filters of each tab (tabs without filters show only the actions). */
|
|
10
|
+
export const wariInboxFilters = {
|
|
11
|
+
mensajes: [
|
|
12
|
+
{ value: 'todos', label: 'Todos' },
|
|
13
|
+
{ value: 'conductor', label: 'Del conductor' },
|
|
14
|
+
{ value: 'personales', label: 'Personales' },
|
|
15
|
+
{ value: 'masivos', label: 'Masivos' },
|
|
16
|
+
],
|
|
17
|
+
incidencias: [
|
|
18
|
+
{ value: 'todos', label: 'Todos' },
|
|
19
|
+
{ value: 'incidencia', label: 'Incidencia' },
|
|
20
|
+
{ value: 'suspension', label: 'Suspensión' },
|
|
21
|
+
{ value: 'bloqueo-cliente', label: 'Bloqueo cliente' },
|
|
22
|
+
{ value: 'bloqueo-empresa', label: 'Bloqueo empresa' },
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
/** Filled funnel (Filtros avanzados), 24×24 viewBox. */
|
|
26
|
+
export const funnelIconPath = 'M3.5 4.5h17a.8.8 0 0 1 .6 1.3L14.5 13v5.6a.8.8 0 0 1-.4.7l-3.4 1.9a.8.8 0 0 1-1.2-.7V13L2.9 5.8a.8.8 0 0 1 .6-1.3Z';
|
|
27
|
+
/** Four corner arrows (Ver lista completa), 24×24 viewBox, stroked. */
|
|
28
|
+
export const expandIconPath = 'M15 4h5v5M20 4l-6 6M9 20H4v-5M4 20l6-6M4 9V4h5M4 4l6 6M20 15v5h-5M20 20l-6-6';
|
package/wari.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export { default as WariClientSearch } from './src/components/WariClientSearch.a
|
|
|
13
13
|
export { default as WariClientDetails } from './src/components/WariClientDetails.astro';
|
|
14
14
|
export { default as WariRoute } from './src/components/WariRoute.astro';
|
|
15
15
|
export { default as WariPassengerField } from './src/components/WariPassengerField.astro';
|
|
16
|
+
export { default as WariDriverInbox } from './src/components/WariDriverInbox.astro';
|
|
17
|
+
export { wariInboxTabs, wariInboxFilters, funnelIconPath, expandIconPath } from './src/wari/inbox.js';
|
|
16
18
|
export type { WariSelectOption } from './src/components/WariSelect.astro';
|
|
17
19
|
export { clampCount, defaultTripAttributes, formatSoles, serviceMeta, syncExtraChoices, syncExtraFields, syncExtraQuantities, syncExtras, toggleExtra, typeaheadIndex, wariExtras, wariPaymentMethods, wariServices } from './src/wari/trip';
|
|
18
20
|
export type { WariService, WariOption, WariExtraField, WariExtrasState, WariTripAttributesValue, ServiceMeta } from './src/wari/trip';
|
|
@@ -24,3 +26,4 @@ export type { WariStatus } from './src/wari/statuses';
|
|
|
24
26
|
export * from './src/wari/logic';
|
|
25
27
|
export { addStop, addToll, createStop, defaultRouteValue, emptyPassenger, invertRoute, moveStop, normalizeRoute, removeStop, removeToll, stopLabel, stopPlaceholder, tollsTotal, updateStop } from './src/wari/route';
|
|
26
28
|
export type { WariPassenger, WariRouteStop, WariRouteValue } from './src/wari/route';
|
|
29
|
+
export type { WariInboxOption } from './src/wari/inbox.js';
|
package/wari.js
CHANGED
|
@@ -14,6 +14,8 @@ export { default as WariClientSearch } from './src/components/WariClientSearch.a
|
|
|
14
14
|
export { default as WariClientDetails } from './src/components/WariClientDetails.astro';
|
|
15
15
|
export { default as WariRoute } from './src/components/WariRoute.astro';
|
|
16
16
|
export { default as WariPassengerField } from './src/components/WariPassengerField.astro';
|
|
17
|
+
export { default as WariDriverInbox } from './src/components/WariDriverInbox.astro';
|
|
18
|
+
export { wariInboxTabs, wariInboxFilters, funnelIconPath, expandIconPath } from './src/wari/inbox.js';
|
|
17
19
|
export { clampCount, defaultTripAttributes, formatSoles, serviceMeta, syncExtraChoices, syncExtraFields, syncExtraQuantities, syncExtras, toggleExtra, typeaheadIndex, wariExtras, wariPaymentMethods, wariServices } from './src/wari/trip.js';
|
|
18
20
|
export { calendarWeeks, formatDisplayDate, formatDisplayTime, parseDisplayDate, parseDisplayTime, parseISODate, parseTime24, toISODate, todayISO } from './src/wari/datetime.js';
|
|
19
21
|
export { wariStatuses, wariStatusLabel } from './src/wari/statuses.js';
|