@directo-ui/astro 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.
- package/README.md +16 -0
- package/components.css +661 -0
- package/index.d.ts +31 -31
- package/index.js +31 -31
- package/package.json +29 -7
- package/src/components/Accordion.astro +8 -8
- package/src/components/AccordionItem.astro +14 -14
- package/src/components/Alert.astro +42 -42
- package/src/components/Avatar.astro +21 -21
- package/src/components/Badge.astro +13 -13
- package/src/components/BottomSheet.astro +23 -23
- package/src/components/Breadcrumb.astro +18 -18
- package/src/components/Button.astro +31 -31
- package/src/components/Card.astro +25 -25
- package/src/components/Checkbox.astro +14 -14
- package/src/components/DatePicker.astro +25 -25
- package/src/components/Divider.astro +11 -11
- package/src/components/Dropdown.astro +71 -71
- package/src/components/EmptyState.astro +15 -15
- package/src/components/IconButton.astro +18 -18
- package/src/components/Modal.astro +34 -34
- package/src/components/MultiSelect.astro +108 -0
- package/src/components/Pagination.astro +30 -30
- package/src/components/Progress.astro +20 -20
- package/src/components/RadioGroup.astro +24 -24
- package/src/components/Select.astro +29 -29
- package/src/components/Skeleton.astro +13 -13
- package/src/components/Spinner.astro +17 -17
- package/src/components/StatusTag.astro +18 -0
- package/src/components/Switch.astro +13 -13
- package/src/components/Tabs.astro +60 -60
- package/src/components/TextField.astro +24 -24
- package/src/components/Textarea.astro +41 -41
- package/src/components/Toaster.astro +8 -8
- package/src/components/Tooltip.astro +31 -31
- package/src/components/WariClientDetails.astro +87 -0
- package/src/components/WariClientSearch.astro +88 -0
- package/src/components/WariDateField.astro +56 -0
- package/src/components/WariPassengerField.astro +84 -0
- package/src/components/WariRoute.astro +49 -0
- package/src/components/WariSchedule.astro +48 -0
- package/src/components/WariSelect.astro +76 -0
- package/src/components/WariServiceMeta.astro +19 -0
- package/src/components/WariStatusSelect.astro +20 -0
- package/src/components/WariStepper.astro +45 -0
- package/src/components/WariSwitchList.astro +111 -0
- package/src/components/WariTimeField.astro +50 -0
- package/src/components/WariTripAttributes.astro +60 -0
- package/src/modal.d.ts +3 -3
- package/src/modal.js +39 -39
- package/src/pagination.d.ts +2 -2
- package/src/pagination.js +16 -16
- package/src/toast.d.ts +9 -9
- package/src/toast.js +66 -66
- package/src/wari/datetime.d.ts +57 -0
- package/src/wari/datetime.js +151 -0
- package/src/wari/logic.d.ts +8 -0
- package/src/wari/logic.js +41 -0
- package/src/wari/motion.d.ts +14 -0
- package/src/wari/motion.js +60 -0
- package/src/wari/multiselect.d.ts +2 -0
- package/src/wari/multiselect.js +169 -0
- package/src/wari/pickers.d.ts +2 -0
- package/src/wari/pickers.js +369 -0
- package/src/wari/route-client.d.ts +10 -0
- package/src/wari/route-client.js +270 -0
- package/src/wari/route.d.ts +48 -0
- package/src/wari/route.js +71 -0
- package/src/wari/statuses.d.ts +14 -0
- package/src/wari/statuses.js +15 -0
- package/src/wari/trip-client.d.ts +4 -0
- package/src/wari/trip-client.js +370 -0
- package/src/wari/trip.d.ts +107 -0
- package/src/wari/trip.js +129 -0
- package/styles.css +3 -3
- package/wari.d.ts +26 -0
- package/wari.js +21 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
title?: string;
|
|
4
|
+
headingLevel?: 2 | 3 | 4;
|
|
5
|
+
/** Texto inicial del buscador. */
|
|
6
|
+
value?: string;
|
|
7
|
+
/** Muestra "Crear usuario" como botón (emite `ds-create`). */
|
|
8
|
+
showCreate?: boolean;
|
|
9
|
+
/** Convierte "Crear usuario" en un enlace. */
|
|
10
|
+
createHref?: string;
|
|
11
|
+
createLabel?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
searchLabel?: string;
|
|
14
|
+
/** Nombre del campo (por defecto "q"). */
|
|
15
|
+
name?: string;
|
|
16
|
+
/** Si se indica, el formulario se envía de forma nativa a esa URL (GET). */
|
|
17
|
+
action?: string;
|
|
18
|
+
/** Barra de carga al cargar la página. En el cliente, activa o quita `aria-busy="true"` en la tarjeta. */
|
|
19
|
+
loading?: boolean;
|
|
20
|
+
loadingLabel?: string;
|
|
21
|
+
/** "auto" (por defecto): "Crear usuario" solo con el buscador vacío y sin cargar, como en Figma. */
|
|
22
|
+
createMode?: 'auto' | 'always' | 'never';
|
|
23
|
+
/** Oculta el buscador (estado bloqueado: solo se ven los datos del cliente). */
|
|
24
|
+
showSearch?: boolean;
|
|
25
|
+
hoverable?: boolean;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
class?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
title = 'Cliente / usuario', headingLevel = 3, value = '', showCreate = true, createHref, createLabel = 'Crear usuario',
|
|
32
|
+
placeholder = 'Puedes filtrar por nombre o número', searchLabel = 'Buscar cliente por nombre o número', name = 'q', action,
|
|
33
|
+
hoverable = true, disabled = false, loading = false, loadingLabel = 'Buscando cliente…', createMode = 'auto', showSearch = true,
|
|
34
|
+
class: className,
|
|
35
|
+
} = Astro.props;
|
|
36
|
+
const createHidden = createMode === 'never' || (createMode === 'auto' && (value.trim() !== '' || loading));
|
|
37
|
+
const id = `ds-wclient-${Math.random().toString(36).slice(2, 9)}`;
|
|
38
|
+
const Heading = `h${headingLevel}`;
|
|
39
|
+
const plus = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M12 4v16M4 12h16"/></svg>';
|
|
40
|
+
---
|
|
41
|
+
<section class:list={['ds-wcard', 'ds-wclient', className]} aria-labelledby={`${id}-title`} data-hover={hoverable ? 'lift' : undefined}
|
|
42
|
+
aria-busy={loading ? 'true' : undefined} data-create={createMode} data-ds-wclient>
|
|
43
|
+
<header class="ds-wcard-header">
|
|
44
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3.5" y="3.5" width="17" height="17" rx="2.5"/><circle cx="12" cy="10" r="3"/><path d="M6.5 20c.9-2.7 3-4 5.5-4s4.6 1.3 5.5 4"/></svg>
|
|
45
|
+
<Heading id={`${id}-title`} class="ds-wcard-title" title={title}>{title}</Heading>
|
|
46
|
+
{createHref
|
|
47
|
+
? <a class="ds-wcard-action" href={createHref} data-ds-create hidden={createHidden}><Fragment set:html={plus} />{createLabel}</a>
|
|
48
|
+
: showCreate && <button type="button" class="ds-wcard-action" data-ds-create hidden={createHidden} disabled={disabled}><Fragment set:html={plus} />{createLabel}</button>}
|
|
49
|
+
</header>
|
|
50
|
+
{showSearch && <form role="search" class="ds-input ds-wsearch" action={action} data-native={action ? 'true' : undefined}>
|
|
51
|
+
<label for={id} class="ds-wvisually-hidden">{searchLabel}</label>
|
|
52
|
+
<div class="ds-input-shell">
|
|
53
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><circle cx="10.5" cy="10.5" r="6.5"/><path d="m20 20-4.8-4.8"/></svg>
|
|
54
|
+
<input id={id} type="search" name={name} value={value} placeholder={placeholder} autocomplete="off" enterkeyhint="search" disabled={disabled} />
|
|
55
|
+
</div>
|
|
56
|
+
</form>}
|
|
57
|
+
<div class="ds-wclient-progress" role="progressbar" aria-label={loadingLabel} data-ds-progress></div>
|
|
58
|
+
<div class="ds-wclient-results"><slot /></div>
|
|
59
|
+
</section>
|
|
60
|
+
|
|
61
|
+
<script>
|
|
62
|
+
// Emits on the card: "ds-change" (texto en cada tecla), "ds-search" (Enter) and "ds-create" (botón).
|
|
63
|
+
function initClientSearch() {
|
|
64
|
+
document.querySelectorAll<HTMLElement>('[data-ds-wclient]:not([data-ds-ready])').forEach(root => {
|
|
65
|
+
root.dataset.dsReady = '';
|
|
66
|
+
const form = root.querySelector<HTMLFormElement>('form');
|
|
67
|
+
const input = form?.querySelector<HTMLInputElement>('input');
|
|
68
|
+
const create = root.querySelector<HTMLElement>('[data-ds-create]');
|
|
69
|
+
const emit = (type: string, detail?: string) => root.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));
|
|
70
|
+
// "Crear usuario": data-create="auto" lo oculta al escribir o mientras carga; "never" / "always" lo fuerzan.
|
|
71
|
+
// Puedes cambiar data-create o aria-busy desde tu código y el botón se actualiza solo.
|
|
72
|
+
const syncCreate = () => {
|
|
73
|
+
if (!create) return;
|
|
74
|
+
const mode = root.dataset.create;
|
|
75
|
+
create.hidden = mode === 'never' || (mode === 'auto' && (Boolean(input?.value.trim()) || root.getAttribute('aria-busy') === 'true'));
|
|
76
|
+
};
|
|
77
|
+
new MutationObserver(syncCreate).observe(root, { attributes: true, attributeFilter: ['aria-busy', 'data-create'] });
|
|
78
|
+
input?.addEventListener('input', () => { syncCreate(); emit('ds-change', input.value); });
|
|
79
|
+
form?.addEventListener('submit', event => {
|
|
80
|
+
if (!form.dataset.native) event.preventDefault();
|
|
81
|
+
emit('ds-search', input?.value.trim() ?? '');
|
|
82
|
+
});
|
|
83
|
+
create?.addEventListener('click', () => emit('ds-create'));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
initClientSearch();
|
|
87
|
+
document.addEventListener('astro:page-load', initClientSearch);
|
|
88
|
+
</script>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { formatDisplayDate, longDateLabel } from '../wari/datetime.js';
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
label?: string;
|
|
6
|
+
/** Fecha inicial ISO "YYYY-MM-DD". */
|
|
7
|
+
value?: string;
|
|
8
|
+
min?: string;
|
|
9
|
+
max?: string;
|
|
10
|
+
/** Nombre del campo enviado en el <form> (valor ISO). */
|
|
11
|
+
name?: string;
|
|
12
|
+
id?: string;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
supportingText?: string;
|
|
15
|
+
error?: boolean;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
locale?: string;
|
|
19
|
+
/** 0 = domingo (como en Figma), 1 = lunes. */
|
|
20
|
+
weekStartsOn?: 0 | 1;
|
|
21
|
+
cancelLabel?: string;
|
|
22
|
+
okLabel?: string;
|
|
23
|
+
align?: 'start' | 'end';
|
|
24
|
+
class?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
label, value = '', min, max, name, placeholder = 'dd/mm/aa', supportingText, error = false, required = false,
|
|
29
|
+
disabled = false, locale = 'es', weekStartsOn = 0, cancelLabel = 'Cancelar', okLabel = 'Aceptar', align = 'start',
|
|
30
|
+
class: className,
|
|
31
|
+
} = Astro.props;
|
|
32
|
+
const id = Astro.props.id ?? `ds-wdate-${Math.random().toString(36).slice(2, 9)}`;
|
|
33
|
+
---
|
|
34
|
+
<div class:list={['ds-input', 'ds-wfield', className]} data-ds-wfield="date" data-open="false" data-align={align}
|
|
35
|
+
data-error={String(error)} data-disabled={String(disabled)} data-min={min} data-max={max} data-locale={locale}
|
|
36
|
+
data-week-start={weekStartsOn} data-cancel-label={cancelLabel} data-ok-label={okLabel}>
|
|
37
|
+
{label && <label for={id}>{label}{required && <span class="ds-input-required" aria-hidden="true">*</span>}</label>}
|
|
38
|
+
<div class="ds-wfield-anchor">
|
|
39
|
+
<div class="ds-input-shell">
|
|
40
|
+
<input id={id} type="text" inputmode="numeric" autocomplete="off" placeholder={placeholder} value={formatDisplayDate(value)}
|
|
41
|
+
disabled={disabled} required={required} aria-invalid={error ? 'true' : undefined} aria-describedby={supportingText ? `${id}-hint` : undefined} />
|
|
42
|
+
<button type="button" class="ds-wfield-trigger" disabled={disabled} aria-haspopup="dialog" aria-expanded="false"
|
|
43
|
+
aria-label={`Elegir fecha${value ? `, ${longDateLabel(value, locale)}` : ''}`}>
|
|
44
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3.5" y="5" width="17" height="15.5" rx="2.5"/><path d="M3.5 9.5h17M8 3v4M16 3v4"/><rect x="11" y="13" width="2.4" height="2.4" rx=".6" fill="currentColor" stroke="none"/></svg>
|
|
45
|
+
</button>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
{supportingText && <small id={`${id}-hint`}>{supportingText}</small>}
|
|
49
|
+
<input type="hidden" name={name} value={value} data-ds-value />
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
import { initWariFields } from '../wari/pickers.js';
|
|
54
|
+
initWariFields();
|
|
55
|
+
document.addEventListener('astro:page-load', () => initWariFields());
|
|
56
|
+
</script>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
/** `{ name, phone }` inicial. */
|
|
4
|
+
value?: { name?: string; phone?: string };
|
|
5
|
+
/** Barra de carga al cargar la página. En el cliente, activa o quita `aria-busy="true"` en el grupo. */
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
loadingLabel?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
namePlaceholder?: string;
|
|
10
|
+
phonePlaceholder?: string;
|
|
11
|
+
nameLabel?: string;
|
|
12
|
+
phoneLabel?: string;
|
|
13
|
+
clearLabel?: string;
|
|
14
|
+
showClear?: boolean;
|
|
15
|
+
/** Nombres de los campos al enviar un formulario. */
|
|
16
|
+
nameInputName?: string;
|
|
17
|
+
phoneInputName?: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
id?: string;
|
|
20
|
+
class?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
value = {}, loading = false, loadingLabel = 'Buscando pasajero…', label = 'Pasajero', namePlaceholder = 'Nombre del pasajero',
|
|
25
|
+
phonePlaceholder = 'Ingresa el número del pasajero', nameLabel = 'Nombre del pasajero', phoneLabel = 'Número del pasajero',
|
|
26
|
+
clearLabel = 'Quitar pasajero', showClear = true, nameInputName, phoneInputName, disabled = false, id, class: className,
|
|
27
|
+
} = Astro.props;
|
|
28
|
+
const name = value.name ?? '';
|
|
29
|
+
const phone = value.phone ?? '';
|
|
30
|
+
const phonePath = 'M5 3.5h3.2l1.6 4-2 1.3a10.5 10.5 0 0 0 5.4 5.4l1.3-2 4 1.6V17a2 2 0 0 1-2 2A15.5 15.5 0 0 1 3 5.5a2 2 0 0 1 2-2Z';
|
|
31
|
+
---
|
|
32
|
+
<div id={id} class:list={['ds-wpassenger', className]} role="group" aria-label={label} aria-busy={loading ? 'true' : undefined} data-ds-wpassenger>
|
|
33
|
+
<div class="ds-wpassenger-row">
|
|
34
|
+
<label class="ds-wpassenger-field">
|
|
35
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="8" r="3.5"/><path d="M5 20c.8-3.5 3.6-5.5 7-5.5s6.2 2 7 5.5"/></svg>
|
|
36
|
+
<input class="ds-wpassenger-input" type="text" autocomplete="name" name={nameInputName} placeholder={namePlaceholder} aria-label={nameLabel}
|
|
37
|
+
value={name} disabled={disabled} data-field="name" />
|
|
38
|
+
</label>
|
|
39
|
+
<label class="ds-wpassenger-field">
|
|
40
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-icon="empty" hidden={phone !== ''}><path d={phonePath}/></svg>
|
|
41
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-icon="filled" hidden={phone === ''}><path d={phonePath}/><path d="M15 4h5M15 7h5M17 10h3"/></svg>
|
|
42
|
+
<input class="ds-wpassenger-input" type="tel" autocomplete="tel" inputmode="tel" name={phoneInputName} placeholder={phonePlaceholder} aria-label={phoneLabel}
|
|
43
|
+
value={phone} disabled={disabled} data-field="phone" />
|
|
44
|
+
</label>
|
|
45
|
+
{showClear && <button type="button" class="ds-wpassenger-clear" aria-label={clearLabel} title={clearLabel} disabled={disabled} data-ds-clear>
|
|
46
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="12" r="9.5" fill="currentColor"/><path d="m9 9 6 6M15 9l-6 6" stroke="#fff" stroke-width="2"/></svg>
|
|
47
|
+
</button>}
|
|
48
|
+
</div>
|
|
49
|
+
<div class="ds-wclient-progress ds-wpassenger-progress" role="progressbar" aria-label={loadingLabel} data-ds-progress></div>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
// Emits on the group: "ds-change" ({ name, phone } en cada tecla) and "ds-clear" (botón ⓧ, después de vaciar los campos).
|
|
54
|
+
// Carga: group.setAttribute('aria-busy', 'true') / removeAttribute('aria-busy'). Valor desde tu código: group.dsSetValue({ name, phone }).
|
|
55
|
+
type PassengerRoot = HTMLElement & { dsSetValue?: (value: { name?: string; phone?: string }) => void };
|
|
56
|
+
function initPassengerFields() {
|
|
57
|
+
document.querySelectorAll<PassengerRoot>('[data-ds-wpassenger]:not([data-ds-ready])').forEach(root => {
|
|
58
|
+
root.dataset.dsReady = '';
|
|
59
|
+
const name = root.querySelector<HTMLInputElement>('[data-field="name"]')!;
|
|
60
|
+
const phone = root.querySelector<HTMLInputElement>('[data-field="phone"]')!;
|
|
61
|
+
const read = () => ({ name: name.value, phone: phone.value });
|
|
62
|
+
const syncIcon = () => {
|
|
63
|
+
root.querySelector<SVGElement>('[data-icon="empty"]')?.toggleAttribute('hidden', phone.value !== '');
|
|
64
|
+
root.querySelector<SVGElement>('[data-icon="filled"]')?.toggleAttribute('hidden', phone.value === '');
|
|
65
|
+
};
|
|
66
|
+
const emit = (type: string, detail?: unknown) => root.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));
|
|
67
|
+
for (const input of [name, phone]) input.addEventListener('input', () => { syncIcon(); emit('ds-change', read()); });
|
|
68
|
+
root.querySelector('[data-ds-clear]')?.addEventListener('click', () => {
|
|
69
|
+
name.value = '';
|
|
70
|
+
phone.value = '';
|
|
71
|
+
syncIcon();
|
|
72
|
+
emit('ds-change', read());
|
|
73
|
+
emit('ds-clear');
|
|
74
|
+
});
|
|
75
|
+
root.dsSetValue = value => {
|
|
76
|
+
name.value = value.name ?? '';
|
|
77
|
+
phone.value = value.phone ?? '';
|
|
78
|
+
syncIcon();
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
initPassengerFields();
|
|
83
|
+
document.addEventListener('astro:page-load', initPassengerFields);
|
|
84
|
+
</script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { routeHtml } from '../wari/route-client.js';
|
|
3
|
+
import { normalizeRoute } from '../wari/route.js';
|
|
4
|
+
import type { WariRouteValue } from '../wari/route';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
/** Ruta inicial: { stops, passenger, tolls }. Sin valor: origen, un destino y un peaje vacío. */
|
|
8
|
+
value?: Partial<WariRouteValue>;
|
|
9
|
+
title?: string;
|
|
10
|
+
headingLevel?: 2 | 3 | 4;
|
|
11
|
+
maxStops?: number;
|
|
12
|
+
maxTolls?: number;
|
|
13
|
+
showPassengers?: boolean;
|
|
14
|
+
showTolls?: boolean;
|
|
15
|
+
/** Envía la ruta como JSON en un campo oculto con este nombre. */
|
|
16
|
+
name?: string;
|
|
17
|
+
/** Simula "Invirtiendo direcciones..." durante estos milisegundos (para maquetas). En tu app pon aria-busy="true". */
|
|
18
|
+
invertDelay?: number;
|
|
19
|
+
invertingLabel?: string;
|
|
20
|
+
invertedMessage?: string;
|
|
21
|
+
routePassengerNote?: string;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
class?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
value, title = 'Ruta', headingLevel = 3, maxStops = 10, maxTolls = 5, showPassengers = true, showTolls = true, name, invertDelay,
|
|
29
|
+
invertingLabel, invertedMessage, routePassengerNote, disabled = false, class: className, id,
|
|
30
|
+
} = Astro.props;
|
|
31
|
+
const baseId = `ds-wroute-${Math.random().toString(36).slice(2, 9)}`;
|
|
32
|
+
const route = normalizeRoute(value);
|
|
33
|
+
const options = { title, headingLevel, maxStops, maxTolls, showPassengers, showTolls, disabled, invertingLabel, invertedMessage, routePassengerNote };
|
|
34
|
+
const definedOptions = Object.fromEntries(Object.entries(options).filter(([, v]) => v !== undefined));
|
|
35
|
+
---
|
|
36
|
+
<section id={id} class:list={['ds-wcard', 'ds-wroute', className]} data-ds-wroute aria-labelledby={`${baseId}-title`} data-base-id={baseId}
|
|
37
|
+
data-value={JSON.stringify(route)} data-title={title} data-heading-level={headingLevel} data-max-stops={maxStops} data-max-tolls={maxTolls}
|
|
38
|
+
data-show-passengers={String(showPassengers)} data-show-tolls={String(showTolls)} data-disabled={String(disabled)}
|
|
39
|
+
data-invert-delay={invertDelay} data-inverting-label={invertingLabel} data-inverted-message={invertedMessage}
|
|
40
|
+
data-route-passenger-note={routePassengerNote}>
|
|
41
|
+
{name && <input type="hidden" name={name} value={JSON.stringify(route)} data-ds-value />}
|
|
42
|
+
<div data-ds-route-content style="display:contents" set:html={routeHtml(route, definedOptions, baseId)} />
|
|
43
|
+
</section>
|
|
44
|
+
|
|
45
|
+
<script>
|
|
46
|
+
import { initWariRoute } from '../wari/route-client.js';
|
|
47
|
+
initWariRoute();
|
|
48
|
+
document.addEventListener('astro:page-load', () => initWariRoute());
|
|
49
|
+
</script>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
import WariDateField from './WariDateField.astro';
|
|
3
|
+
import WariTimeField from './WariTimeField.astro';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
title?: string;
|
|
7
|
+
headingLevel?: 2 | 3 | 4;
|
|
8
|
+
/** Fecha inicial ISO "YYYY-MM-DD". */
|
|
9
|
+
date?: string;
|
|
10
|
+
/** Hora inicial "HH:mm" (24 h). */
|
|
11
|
+
time?: string;
|
|
12
|
+
dateLabel?: string;
|
|
13
|
+
timeLabel?: string;
|
|
14
|
+
minDate?: string;
|
|
15
|
+
maxDate?: string;
|
|
16
|
+
dateName?: string;
|
|
17
|
+
timeName?: string;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
dateError?: boolean;
|
|
21
|
+
timeError?: boolean;
|
|
22
|
+
dateSupportingText?: string;
|
|
23
|
+
timeSupportingText?: string;
|
|
24
|
+
locale?: string;
|
|
25
|
+
weekStartsOn?: 0 | 1;
|
|
26
|
+
class?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
title = 'Horario', headingLevel = 3, date, time, dateLabel = 'Fecha', timeLabel = 'Hora de recojo', minDate, maxDate,
|
|
31
|
+
dateName, timeName, required = true, disabled = false, dateError, timeError, dateSupportingText, timeSupportingText,
|
|
32
|
+
locale, weekStartsOn, class: className,
|
|
33
|
+
} = Astro.props;
|
|
34
|
+
const titleId = `ds-wschedule-${Math.random().toString(36).slice(2, 9)}`;
|
|
35
|
+
const Heading = `h${headingLevel}`;
|
|
36
|
+
---
|
|
37
|
+
<section class:list={['ds-wschedule', className]} aria-labelledby={titleId}>
|
|
38
|
+
<header class="ds-wschedule-header">
|
|
39
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="8.5"/><path d="M12 7.5V12l3 2"/></svg>
|
|
40
|
+
<Heading id={titleId} class="ds-wschedule-title">{title}</Heading>
|
|
41
|
+
</header>
|
|
42
|
+
<div class="ds-wschedule-fields">
|
|
43
|
+
<WariDateField label={dateLabel} value={date} min={minDate} max={maxDate} name={dateName} required={required} disabled={disabled}
|
|
44
|
+
error={dateError} supportingText={dateSupportingText} locale={locale} weekStartsOn={weekStartsOn} />
|
|
45
|
+
<WariTimeField label={timeLabel} value={time} name={timeName} required={required} disabled={disabled} error={timeError}
|
|
46
|
+
supportingText={timeSupportingText} align="end" />
|
|
47
|
+
</div>
|
|
48
|
+
</section>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
import WariServiceMeta from './WariServiceMeta.astro';
|
|
3
|
+
import { serviceMeta } from '../wari/trip.js';
|
|
4
|
+
import type { WariService } from '../wari/trip';
|
|
5
|
+
|
|
6
|
+
export interface WariSelectOption {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Muestra el detalle de un servicio (capacidad, "Envío", "Desde S/…") a la derecha. */
|
|
11
|
+
service?: WariService;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Props {
|
|
15
|
+
label?: string;
|
|
16
|
+
ariaLabel?: string;
|
|
17
|
+
options: WariSelectOption[];
|
|
18
|
+
value?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
supportingText?: string;
|
|
21
|
+
error?: boolean;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** Nombre del campo enviado en el <form>. */
|
|
25
|
+
name?: string;
|
|
26
|
+
id?: string;
|
|
27
|
+
/** Modo para el detalle de los servicios. */
|
|
28
|
+
hourly?: boolean;
|
|
29
|
+
delivery?: boolean;
|
|
30
|
+
class?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
label, ariaLabel, options, value = '', placeholder = 'Seleccionar', supportingText, error = false, required = false,
|
|
35
|
+
disabled = false, name, hourly = false, delivery = false, class: className,
|
|
36
|
+
} = Astro.props;
|
|
37
|
+
const id = Astro.props.id ?? `ds-wselect-${Math.random().toString(36).slice(2, 9)}`;
|
|
38
|
+
const selected = options.find(option => option.value === value);
|
|
39
|
+
const metaLabel = (option?: WariSelectOption) => (option?.service ? serviceMeta(option.service, { hourly, delivery }).label : undefined);
|
|
40
|
+
const selectedMeta = metaLabel(selected);
|
|
41
|
+
---
|
|
42
|
+
<div class:list={['ds-input', 'ds-wfield', 'ds-wselect', className]} data-ds-wselect data-open="false" data-error={String(error)}
|
|
43
|
+
data-disabled={String(disabled)} data-label="lg" data-placeholder={placeholder}>
|
|
44
|
+
{label && <label id={`${id}-label`}>{label}{required && <span class="ds-input-required" aria-hidden="true">*</span>}</label>}
|
|
45
|
+
<div class="ds-wfield-anchor">
|
|
46
|
+
<div class="ds-input-shell" role="combobox" tabindex={disabled ? -1 : 0} aria-haspopup="listbox" aria-expanded="false"
|
|
47
|
+
aria-controls={`${id}-listbox`} aria-labelledby={label ? `${id}-label ${id}-value` : undefined} aria-label={label ? undefined : ariaLabel}
|
|
48
|
+
aria-disabled={disabled ? 'true' : undefined} aria-required={required ? 'true' : undefined} aria-invalid={error ? 'true' : undefined}
|
|
49
|
+
aria-describedby={supportingText ? `${id}-hint` : undefined}>
|
|
50
|
+
<span id={`${id}-value`} class="ds-wselect-value" data-placeholder={String(!selected)}>{selected ? selected.label : placeholder}<span class="ds-wvisually-hidden">{selectedMeta ? `, ${selectedMeta}` : ''}</span></span>
|
|
51
|
+
<span aria-hidden="true" style="display:contents" data-ds-value-meta>{selected?.service && <WariServiceMeta service={selected.service} hourly={hourly} delivery={delivery} />}</span>
|
|
52
|
+
<span class="ds-wselect-caret" aria-hidden="true"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9.5 6 6 6-6"/></svg></span>
|
|
53
|
+
</div>
|
|
54
|
+
<ul id={`${id}-listbox`} class="ds-wselect-list" role="listbox" hidden aria-labelledby={label ? `${id}-label` : undefined} aria-label={label ? undefined : ariaLabel}>
|
|
55
|
+
{options.map((option, index) => {
|
|
56
|
+
const meta = metaLabel(option);
|
|
57
|
+
return (
|
|
58
|
+
<li id={`${id}-option-${index}`} role="option" class="ds-wselect-option" data-value={option.value} data-label={option.label}
|
|
59
|
+
data-meta-label={meta} aria-selected={String(option.value === value)} aria-disabled={option.disabled ? 'true' : undefined}
|
|
60
|
+
aria-label={meta ? `${option.label}, ${meta}` : undefined}>
|
|
61
|
+
<span class="ds-wselect-label">{option.label}</span>
|
|
62
|
+
{option.service && <span aria-hidden="true" style="display:contents"><WariServiceMeta service={option.service} hourly={hourly} delivery={delivery} /></span>}
|
|
63
|
+
</li>
|
|
64
|
+
);
|
|
65
|
+
})}
|
|
66
|
+
</ul>
|
|
67
|
+
</div>
|
|
68
|
+
{supportingText && <small id={`${id}-hint`}>{supportingText}</small>}
|
|
69
|
+
<input type="hidden" name={name} value={value} data-ds-value />
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<script>
|
|
73
|
+
import { initWariTripFields } from '../wari/trip-client.js';
|
|
74
|
+
initWariTripFields();
|
|
75
|
+
document.addEventListener('astro:page-load', () => initWariTripFields());
|
|
76
|
+
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { serviceMeta } from '../wari/trip.js';
|
|
3
|
+
import type { WariService } from '../wari/trip';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
service: WariService;
|
|
7
|
+
hourly?: boolean;
|
|
8
|
+
delivery?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { service, hourly = false, delivery = false } = Astro.props;
|
|
12
|
+
const meta = serviceMeta(service, { hourly, delivery });
|
|
13
|
+
const user = '<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="8" r="4" fill="currentColor"/><path d="M4.5 20.5c1-4 4-6 7.5-6s6.5 2 7.5 6" fill="currentColor"/></svg>';
|
|
14
|
+
const luggage = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><rect x="6" y="7" width="12" height="13" rx="2" fill="currentColor" stroke="none"/><path d="M9.5 7V4.5h5V7M9 22v-2M15 22v-2"/></svg>';
|
|
15
|
+
const bag = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><rect x="2.5" y="8.5" width="19" height="11" rx="2" fill="currentColor" stroke="none"/><path d="M9 8.5V6.5h6v2"/></svg>';
|
|
16
|
+
---
|
|
17
|
+
<span class="ds-wmeta">{meta.delivery && <span class="ds-wmeta-badge">Envío</span>}{meta.price && <span class="ds-wmeta-item">{meta.price}</span>}{meta.capacity && (
|
|
18
|
+
<Fragment><span class="ds-wmeta-item"><Fragment set:html={user} />{meta.capacity.passengers}</span><span class="ds-wmeta-item"><Fragment set:html={luggage} />{meta.capacity.luggage}</span>{meta.capacity.luggageAlt != null && <span class="ds-wmeta-item">o <Fragment set:html={bag} />{meta.capacity.luggageAlt}</span>}</Fragment>
|
|
19
|
+
)}</span>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
import MultiSelect from './MultiSelect.astro';
|
|
3
|
+
import type { Props as MultiSelectProps } from './MultiSelect.astro';
|
|
4
|
+
import { wariStatuses } from '../wari/statuses.js';
|
|
5
|
+
|
|
6
|
+
type WariStatus = (typeof wariStatuses)[number]['value'];
|
|
7
|
+
|
|
8
|
+
interface Props extends Omit<MultiSelectProps, 'options'> {
|
|
9
|
+
/** Estados a mostrar (por defecto todos, en el orden de Wari). */
|
|
10
|
+
statuses?: string[];
|
|
11
|
+
/** Texto a la derecha de cada estado, por ejemplo la cantidad de servicios. */
|
|
12
|
+
descriptions?: Partial<Record<WariStatus | string, string>>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { statuses, descriptions = {}, label = 'Estado', ...props } = Astro.props;
|
|
16
|
+
const options = wariStatuses
|
|
17
|
+
.filter(item => !statuses || statuses.includes(item.value))
|
|
18
|
+
.map(item => ({ value: item.value, label: item.label, status: item.value, description: descriptions[item.value] }));
|
|
19
|
+
---
|
|
20
|
+
<MultiSelect {...props} label={label} options={options} />
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { clampCount } from '../wari/trip.js';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
label?: string;
|
|
6
|
+
/** Nombre accesible cuando no hay `label` visible. */
|
|
7
|
+
ariaLabel?: string;
|
|
8
|
+
/** 'outlined': botones con borde y más alto, como el contador del Booster en Figma. */
|
|
9
|
+
variant?: 'filled' | 'outlined';
|
|
10
|
+
value?: number;
|
|
11
|
+
min?: number;
|
|
12
|
+
max?: number;
|
|
13
|
+
/** Nombre del campo enviado en el <form>. */
|
|
14
|
+
name?: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
class?: string;
|
|
18
|
+
[attribute: `data-${string}`]: unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const { label, ariaLabel, variant = 'filled', value = 1, min = 1, max = 99, name, disabled = false, class: className, id: _id, ...rest } = Astro.props;
|
|
22
|
+
const id = Astro.props.id ?? `ds-wstepper-${Math.random().toString(36).slice(2, 9)}`;
|
|
23
|
+
const current = clampCount(value, min, max);
|
|
24
|
+
const subject = (label ?? ariaLabel ?? 'cantidad').toLowerCase();
|
|
25
|
+
---
|
|
26
|
+
<div class:list={['ds-input', 'ds-wfield', 'ds-wstepper', className]} data-ds-wstepper data-min={min} data-max={max}
|
|
27
|
+
data-disabled={String(disabled)} data-label="lg" data-variant={variant} {...rest}>
|
|
28
|
+
{label && <label for={id}>{label}</label>}
|
|
29
|
+
<div class="ds-input-shell">
|
|
30
|
+
<button type="button" class="ds-wstepper-button" aria-label={`Disminuir ${subject}`} aria-controls={id} disabled={disabled || current <= min}>
|
|
31
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M5 12h14"/></svg>
|
|
32
|
+
</button>
|
|
33
|
+
<input id={id} type="text" inputmode="numeric" role="spinbutton" name={name} value={String(current)} disabled={disabled} aria-label={label ? undefined : ariaLabel}
|
|
34
|
+
aria-valuenow={current} aria-valuemin={min} aria-valuemax={max} />
|
|
35
|
+
<button type="button" class="ds-wstepper-button" aria-label={`Aumentar ${subject}`} aria-controls={id} disabled={disabled || current >= max}>
|
|
36
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>
|
|
37
|
+
</button>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<script>
|
|
42
|
+
import { initWariTripFields } from '../wari/trip-client.js';
|
|
43
|
+
initWariTripFields();
|
|
44
|
+
document.addEventListener('astro:page-load', () => initWariTripFields());
|
|
45
|
+
</script>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
import WariSelect from './WariSelect.astro';
|
|
3
|
+
import WariStepper from './WariStepper.astro';
|
|
4
|
+
import type { WariOption } from '../wari/trip';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
/** Nombre del grupo para lectores de pantalla (no se muestra). */
|
|
8
|
+
legend: string;
|
|
9
|
+
/**
|
|
10
|
+
* Interruptores. Con `description`, `note`, `maxQuantity` o `choices`, al activarlo se despliega su panel:
|
|
11
|
+
* contador (Booster) o una lista por unidad con + y papelera (Carseat).
|
|
12
|
+
*/
|
|
13
|
+
items: WariOption[];
|
|
14
|
+
/** Valores activos al cargar. */
|
|
15
|
+
value?: string[];
|
|
16
|
+
/** Cantidad inicial de cada interruptor activo con `maxQuantity` (p. ej. { booster: 2 }). */
|
|
17
|
+
quantities?: Record<string, number>;
|
|
18
|
+
/** Opciones iniciales de cada interruptor activo con `choices` (p. ej. { carseat: ['0-2', '3-5'] }). */
|
|
19
|
+
choices?: Record<string, string[]>;
|
|
20
|
+
/** Texto inicial de los campos de cada interruptor activo con `fields` (p. ej. { carga: { weight: '20' } }). */
|
|
21
|
+
fields?: Record<string, Record<string, string>>;
|
|
22
|
+
orientation?: 'vertical' | 'horizontal';
|
|
23
|
+
/** Envía cada interruptor activo como name=value y su cantidad u opciones como name.value. */
|
|
24
|
+
name?: string;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
class?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
legend, items, value = [], quantities = {}, choices = {}, fields = {}, orientation = 'vertical', name, disabled = false, class: className,
|
|
31
|
+
} = Astro.props;
|
|
32
|
+
const baseId = `ds-wswitches-${Math.random().toString(36).slice(2, 9)}`;
|
|
33
|
+
const trash = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4.5 6.5h15M9.5 6.5V4.5h5v2M6.5 6.5l1 13h9l1-13M10.5 10v6M13.5 10v6"/></svg>';
|
|
34
|
+
const plus = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>';
|
|
35
|
+
---
|
|
36
|
+
<fieldset class:list={['ds-wswitches', className]} data-ds-wswitches data-orientation={orientation} disabled={disabled}>
|
|
37
|
+
<legend>{legend}</legend>
|
|
38
|
+
{items.map((item, index) => {
|
|
39
|
+
const checked = value.includes(item.value);
|
|
40
|
+
const hasChoices = Boolean(item.choices?.length);
|
|
41
|
+
const hasFields = Boolean(item.fields?.length);
|
|
42
|
+
const expandable = Boolean(item.description || item.note || item.maxQuantity || hasChoices || hasFields);
|
|
43
|
+
const panelId = `${baseId}-panel-${index}`;
|
|
44
|
+
const descId = `${baseId}-desc-${index}`;
|
|
45
|
+
const max = item.maxQuantity ?? 1;
|
|
46
|
+
const units = checked && hasChoices ? (choices[item.value]?.length ? choices[item.value] : [item.choices![0].value]).slice(0, max) : [];
|
|
47
|
+
const fieldName = name ? `${name}.${item.value}` : undefined;
|
|
48
|
+
return (
|
|
49
|
+
<div class="ds-wswitch-item">
|
|
50
|
+
<label class="ds-wswitch">
|
|
51
|
+
<span>{item.label}</span>
|
|
52
|
+
<input type="checkbox" role="switch" name={name} value={item.value} checked={checked} disabled={item.disabled}
|
|
53
|
+
aria-controls={expandable ? panelId : undefined} aria-expanded={expandable ? String(checked) : undefined}
|
|
54
|
+
aria-describedby={expandable && item.description ? descId : undefined} />
|
|
55
|
+
</label>
|
|
56
|
+
{expandable && (
|
|
57
|
+
<div id={panelId} class="ds-wswitch-panel" hidden={!checked}>
|
|
58
|
+
{item.description && <p id={descId} class="ds-wswitch-desc">{item.description}</p>}
|
|
59
|
+
{hasChoices && (
|
|
60
|
+
<div class="ds-wswitch-units" role="group" aria-label={item.label} data-ds-units={item.value} data-label={item.label} data-max={max}>
|
|
61
|
+
{units.map((unit, unitIndex) => (
|
|
62
|
+
<div class="ds-wswitch-unit">
|
|
63
|
+
<WariSelect ariaLabel={`${item.label} ${unitIndex + 1}`} options={item.choices!} value={unit} name={fieldName}
|
|
64
|
+
disabled={disabled || item.disabled} />
|
|
65
|
+
<button type="button" class="ds-wswitch-unit-button" data-ds-unit-remove hidden={units.length < 2}
|
|
66
|
+
aria-label={`Quitar ${item.label} ${unitIndex + 1}`} disabled={disabled || item.disabled}><Fragment set:html={trash} /></button>
|
|
67
|
+
<button type="button" class="ds-wswitch-unit-button" data-ds-unit-add hidden={unitIndex !== units.length - 1 || units.length >= max}
|
|
68
|
+
aria-label={`Agregar otro ${item.label}`} disabled={disabled || item.disabled}><Fragment set:html={plus} /></button>
|
|
69
|
+
</div>
|
|
70
|
+
))}
|
|
71
|
+
<template data-ds-unit-template>
|
|
72
|
+
<div class="ds-wswitch-unit">
|
|
73
|
+
<WariSelect ariaLabel={`${item.label} 1`} options={item.choices!} value={item.choices![0].value} name={fieldName}
|
|
74
|
+
disabled={disabled || item.disabled} />
|
|
75
|
+
<button type="button" class="ds-wswitch-unit-button" data-ds-unit-remove aria-label={`Quitar ${item.label} 1`}
|
|
76
|
+
disabled={disabled || item.disabled}><Fragment set:html={trash} /></button>
|
|
77
|
+
<button type="button" class="ds-wswitch-unit-button" data-ds-unit-add aria-label={`Agregar otro ${item.label}`}
|
|
78
|
+
disabled={disabled || item.disabled}><Fragment set:html={plus} /></button>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
{hasFields && (
|
|
84
|
+
<div class="ds-wswitch-fields" role="group" aria-label={item.label} data-ds-fields={item.value}>
|
|
85
|
+
{item.fields!.map(field => (
|
|
86
|
+
<input class="ds-wswitch-field" type="text" inputmode={field.inputMode ?? 'text'} autocomplete="off"
|
|
87
|
+
aria-label={field.label} placeholder={field.placeholder} data-field={field.name}
|
|
88
|
+
data-fixed={field.width ? 'true' : undefined} style={field.width ? `width:${field.width}` : undefined}
|
|
89
|
+
value={checked ? (fields[item.value]?.[field.name] ?? '') : ''} disabled={disabled || item.disabled || !checked}
|
|
90
|
+
name={fieldName ? `${fieldName}.${field.name}` : undefined} />
|
|
91
|
+
))}
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
{!hasChoices && item.maxQuantity != null && (
|
|
95
|
+
<WariStepper ariaLabel={`Cantidad de ${item.label}`} variant="outlined" min={1} max={item.maxQuantity}
|
|
96
|
+
value={quantities[item.value] ?? 1} name={fieldName}
|
|
97
|
+
disabled={disabled || item.disabled || !checked} data-ds-quantity={item.value} />
|
|
98
|
+
)}
|
|
99
|
+
{item.note && <p class="ds-wswitch-note" role="note">{item.note}</p>}
|
|
100
|
+
</div>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
})}
|
|
105
|
+
</fieldset>
|
|
106
|
+
|
|
107
|
+
<script>
|
|
108
|
+
import { initWariTripFields } from '../wari/trip-client.js';
|
|
109
|
+
initWariTripFields();
|
|
110
|
+
document.addEventListener('astro:page-load', () => initWariTripFields());
|
|
111
|
+
</script>
|