@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
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
-
|
|
4
|
-
interface Props extends Omit<HTMLAttributes<'input'>, 'type'> {
|
|
5
|
-
label?: string;
|
|
6
|
-
supportingText?: string;
|
|
7
|
-
error?: boolean;
|
|
8
|
-
/** ISO dates: YYYY-MM-DD */
|
|
9
|
-
value?: string;
|
|
10
|
-
min?: string;
|
|
11
|
-
max?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const { label, supportingText, error = false, id, disabled = false, required = false, ...rest } = Astro.props;
|
|
15
|
-
const fieldId = id ?? `ds-field-${Math.random().toString(36).slice(2, 9)}`;
|
|
16
|
-
const hintId = supportingText ? `${fieldId}-hint` : undefined;
|
|
17
|
-
---
|
|
18
|
-
<div class="ds-input" data-error={String(error)} data-disabled={String(Boolean(disabled))}>
|
|
19
|
-
{label && <label for={fieldId}>{label}{required && <span class="ds-input-required" aria-hidden="true">*</span>}</label>}
|
|
20
|
-
<div class="ds-input-shell">
|
|
21
|
-
<input {...rest} id={fieldId} type="date" disabled={disabled} required={required}
|
|
22
|
-
aria-invalid={error ? 'true' : undefined} aria-describedby={hintId} />
|
|
23
|
-
</div>
|
|
24
|
-
{supportingText && <small id={hintId}>{supportingText}</small>}
|
|
25
|
-
</div>
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
+
|
|
4
|
+
interface Props extends Omit<HTMLAttributes<'input'>, 'type'> {
|
|
5
|
+
label?: string;
|
|
6
|
+
supportingText?: string;
|
|
7
|
+
error?: boolean;
|
|
8
|
+
/** ISO dates: YYYY-MM-DD */
|
|
9
|
+
value?: string;
|
|
10
|
+
min?: string;
|
|
11
|
+
max?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { label, supportingText, error = false, id, disabled = false, required = false, ...rest } = Astro.props;
|
|
15
|
+
const fieldId = id ?? `ds-field-${Math.random().toString(36).slice(2, 9)}`;
|
|
16
|
+
const hintId = supportingText ? `${fieldId}-hint` : undefined;
|
|
17
|
+
---
|
|
18
|
+
<div class="ds-input" data-error={String(error)} data-disabled={String(Boolean(disabled))}>
|
|
19
|
+
{label && <label for={fieldId}>{label}{required && <span class="ds-input-required" aria-hidden="true">*</span>}</label>}
|
|
20
|
+
<div class="ds-input-shell">
|
|
21
|
+
<input {...rest} id={fieldId} type="date" disabled={disabled} required={required}
|
|
22
|
+
aria-invalid={error ? 'true' : undefined} aria-describedby={hintId} />
|
|
23
|
+
</div>
|
|
24
|
+
{supportingText && <small id={hintId}>{supportingText}</small>}
|
|
25
|
+
</div>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
---
|
|
2
|
-
interface Props {
|
|
3
|
-
orientation?: 'horizontal' | 'vertical';
|
|
4
|
-
label?: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const { orientation = 'horizontal', label } = Astro.props;
|
|
8
|
-
---
|
|
9
|
-
{label
|
|
10
|
-
? <div class="ds-divider" role="separator" data-label={label}>{label}</div>
|
|
11
|
-
: <div class="ds-divider" role="separator" aria-orientation={orientation} data-orientation={orientation} />}
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
orientation?: 'horizontal' | 'vertical';
|
|
4
|
+
label?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const { orientation = 'horizontal', label } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
{label
|
|
10
|
+
? <div class="ds-divider" role="separator" data-label={label}>{label}</div>
|
|
11
|
+
: <div class="ds-divider" role="separator" aria-orientation={orientation} data-orientation={orientation} />}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
---
|
|
2
|
-
export interface MenuItem { id: string; label: string; href?: string; disabled?: boolean; danger?: boolean; divider?: boolean; shortcut?: string }
|
|
3
|
-
interface Props {
|
|
4
|
-
label: string;
|
|
5
|
-
items: MenuItem[];
|
|
6
|
-
variant?: 'primary' | 'secondary' | 'tertiary' | 'text';
|
|
7
|
-
align?: 'start' | 'end';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const { label, items, variant = 'secondary', align = 'start' } = Astro.props;
|
|
11
|
-
const id = `ds-menu-${Math.random().toString(36).slice(2, 9)}`;
|
|
12
|
-
---
|
|
13
|
-
<div class="ds-menu" data-align={align} data-ds-menu>
|
|
14
|
-
<button type="button" class="ds-button" data-variant={variant} data-size="md" aria-haspopup="menu" aria-expanded="false" aria-controls={id}>
|
|
15
|
-
{label}<span aria-hidden="true" style="font-size:10px">▼</span>
|
|
16
|
-
</button>
|
|
17
|
-
<div class="ds-dropdown" role="menu" id={id} aria-label={label} hidden>
|
|
18
|
-
{items.map(item => item.divider
|
|
19
|
-
? <div class="ds-dropdown-separator" role="separator" />
|
|
20
|
-
: item.href
|
|
21
|
-
? <a class="ds-dropdown-item" role="menuitem" tabindex="-1" href={item.href} data-id={item.id} data-variant={item.danger ? 'danger' : undefined}>{item.label}</a>
|
|
22
|
-
: <button type="button" class="ds-dropdown-item" role="menuitem" tabindex="-1" disabled={item.disabled} data-id={item.id} data-variant={item.danger ? 'danger' : undefined}>
|
|
23
|
-
{item.label}{item.shortcut && <span class="ds-dropdown-shortcut">{item.shortcut}</span>}
|
|
24
|
-
</button>)}
|
|
25
|
-
</div>
|
|
26
|
-
</div>
|
|
27
|
-
|
|
28
|
-
<script>
|
|
29
|
-
// Emits a bubbling "ds-select" CustomEvent with the item id as detail.
|
|
30
|
-
function initMenus() {
|
|
31
|
-
document.querySelectorAll<HTMLElement>('[data-ds-menu]:not([data-ds-ready])').forEach(root => {
|
|
32
|
-
root.dataset.dsReady = '';
|
|
33
|
-
const trigger = root.querySelector<HTMLButtonElement>(':scope > button')!;
|
|
34
|
-
const menu = root.querySelector<HTMLElement>('[role="menu"]')!;
|
|
35
|
-
const items = () => [...menu.querySelectorAll<HTMLElement>('[role="menuitem"]:not(:disabled)')];
|
|
36
|
-
const focusAt = (index: number) => { const list = items(); list[(index + list.length) % list.length]?.focus(); };
|
|
37
|
-
const setOpen = (open: boolean, returnFocus = true) => {
|
|
38
|
-
menu.hidden = !open;
|
|
39
|
-
trigger.setAttribute('aria-expanded', String(open));
|
|
40
|
-
if (open) requestAnimationFrame(() => focusAt(0));
|
|
41
|
-
else if (returnFocus) trigger.focus();
|
|
42
|
-
};
|
|
43
|
-
trigger.addEventListener('click', () => setOpen(menu.hidden));
|
|
44
|
-
trigger.addEventListener('keydown', event => {
|
|
45
|
-
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
46
|
-
event.preventDefault(); setOpen(true);
|
|
47
|
-
if (event.key === 'ArrowUp') requestAnimationFrame(() => focusAt(-1));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
menu.addEventListener('keydown', event => {
|
|
51
|
-
const list = items();
|
|
52
|
-
const index = list.indexOf(document.activeElement as HTMLElement);
|
|
53
|
-
const moves: Record<string, number> = { ArrowDown: index + 1, ArrowUp: index - 1, Home: 0, End: -1 };
|
|
54
|
-
if (event.key in moves) { event.preventDefault(); focusAt(moves[event.key]); }
|
|
55
|
-
if (event.key === 'Escape') { event.preventDefault(); setOpen(false); }
|
|
56
|
-
if (event.key === 'Tab') setOpen(false, false);
|
|
57
|
-
});
|
|
58
|
-
menu.addEventListener('click', event => {
|
|
59
|
-
const item = (event.target as Element).closest<HTMLElement>('[role="menuitem"]');
|
|
60
|
-
if (!item) return;
|
|
61
|
-
root.dispatchEvent(new CustomEvent('ds-select', { detail: item.dataset.id, bubbles: true }));
|
|
62
|
-
setOpen(false);
|
|
63
|
-
});
|
|
64
|
-
document.addEventListener('click', event => {
|
|
65
|
-
if (!menu.hidden && !root.contains(event.target as Node)) setOpen(false, false);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
initMenus();
|
|
70
|
-
document.addEventListener('astro:page-load', initMenus);
|
|
71
|
-
</script>
|
|
1
|
+
---
|
|
2
|
+
export interface MenuItem { id: string; label: string; href?: string; disabled?: boolean; danger?: boolean; divider?: boolean; shortcut?: string }
|
|
3
|
+
interface Props {
|
|
4
|
+
label: string;
|
|
5
|
+
items: MenuItem[];
|
|
6
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'text';
|
|
7
|
+
align?: 'start' | 'end';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { label, items, variant = 'secondary', align = 'start' } = Astro.props;
|
|
11
|
+
const id = `ds-menu-${Math.random().toString(36).slice(2, 9)}`;
|
|
12
|
+
---
|
|
13
|
+
<div class="ds-menu" data-align={align} data-ds-menu>
|
|
14
|
+
<button type="button" class="ds-button" data-variant={variant} data-size="md" aria-haspopup="menu" aria-expanded="false" aria-controls={id}>
|
|
15
|
+
{label}<span aria-hidden="true" style="font-size:10px">▼</span>
|
|
16
|
+
</button>
|
|
17
|
+
<div class="ds-dropdown" role="menu" id={id} aria-label={label} hidden>
|
|
18
|
+
{items.map(item => item.divider
|
|
19
|
+
? <div class="ds-dropdown-separator" role="separator" />
|
|
20
|
+
: item.href
|
|
21
|
+
? <a class="ds-dropdown-item" role="menuitem" tabindex="-1" href={item.href} data-id={item.id} data-variant={item.danger ? 'danger' : undefined}>{item.label}</a>
|
|
22
|
+
: <button type="button" class="ds-dropdown-item" role="menuitem" tabindex="-1" disabled={item.disabled} data-id={item.id} data-variant={item.danger ? 'danger' : undefined}>
|
|
23
|
+
{item.label}{item.shortcut && <span class="ds-dropdown-shortcut">{item.shortcut}</span>}
|
|
24
|
+
</button>)}
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
// Emits a bubbling "ds-select" CustomEvent with the item id as detail.
|
|
30
|
+
function initMenus() {
|
|
31
|
+
document.querySelectorAll<HTMLElement>('[data-ds-menu]:not([data-ds-ready])').forEach(root => {
|
|
32
|
+
root.dataset.dsReady = '';
|
|
33
|
+
const trigger = root.querySelector<HTMLButtonElement>(':scope > button')!;
|
|
34
|
+
const menu = root.querySelector<HTMLElement>('[role="menu"]')!;
|
|
35
|
+
const items = () => [...menu.querySelectorAll<HTMLElement>('[role="menuitem"]:not(:disabled)')];
|
|
36
|
+
const focusAt = (index: number) => { const list = items(); list[(index + list.length) % list.length]?.focus(); };
|
|
37
|
+
const setOpen = (open: boolean, returnFocus = true) => {
|
|
38
|
+
menu.hidden = !open;
|
|
39
|
+
trigger.setAttribute('aria-expanded', String(open));
|
|
40
|
+
if (open) requestAnimationFrame(() => focusAt(0));
|
|
41
|
+
else if (returnFocus) trigger.focus();
|
|
42
|
+
};
|
|
43
|
+
trigger.addEventListener('click', () => setOpen(menu.hidden));
|
|
44
|
+
trigger.addEventListener('keydown', event => {
|
|
45
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
46
|
+
event.preventDefault(); setOpen(true);
|
|
47
|
+
if (event.key === 'ArrowUp') requestAnimationFrame(() => focusAt(-1));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
menu.addEventListener('keydown', event => {
|
|
51
|
+
const list = items();
|
|
52
|
+
const index = list.indexOf(document.activeElement as HTMLElement);
|
|
53
|
+
const moves: Record<string, number> = { ArrowDown: index + 1, ArrowUp: index - 1, Home: 0, End: -1 };
|
|
54
|
+
if (event.key in moves) { event.preventDefault(); focusAt(moves[event.key]); }
|
|
55
|
+
if (event.key === 'Escape') { event.preventDefault(); setOpen(false); }
|
|
56
|
+
if (event.key === 'Tab') setOpen(false, false);
|
|
57
|
+
});
|
|
58
|
+
menu.addEventListener('click', event => {
|
|
59
|
+
const item = (event.target as Element).closest<HTMLElement>('[role="menuitem"]');
|
|
60
|
+
if (!item) return;
|
|
61
|
+
root.dispatchEvent(new CustomEvent('ds-select', { detail: item.dataset.id, bubbles: true }));
|
|
62
|
+
setOpen(false);
|
|
63
|
+
});
|
|
64
|
+
document.addEventListener('click', event => {
|
|
65
|
+
if (!menu.hidden && !root.contains(event.target as Node)) setOpen(false, false);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
initMenus();
|
|
70
|
+
document.addEventListener('astro:page-load', initMenus);
|
|
71
|
+
</script>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
---
|
|
2
|
-
interface Props {
|
|
3
|
-
title: string;
|
|
4
|
-
description?: string;
|
|
5
|
-
variant?: 'default' | 'no-data' | 'error' | 'no-results';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const { title, description, variant = 'default' } = Astro.props;
|
|
9
|
-
---
|
|
10
|
-
<div class="ds-empty-state" data-variant={variant}>
|
|
11
|
-
<div class="ds-empty-state-icon" aria-hidden="true"><slot name="icon" /></div>
|
|
12
|
-
<h3>{title}</h3>
|
|
13
|
-
{description && <p>{description}</p>}
|
|
14
|
-
<div class="ds-empty-state-action"><slot /></div>
|
|
15
|
-
</div>
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
title: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
variant?: 'default' | 'no-data' | 'error' | 'no-results';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { title, description, variant = 'default' } = Astro.props;
|
|
9
|
+
---
|
|
10
|
+
<div class="ds-empty-state" data-variant={variant}>
|
|
11
|
+
<div class="ds-empty-state-icon" aria-hidden="true"><slot name="icon" /></div>
|
|
12
|
+
<h3>{title}</h3>
|
|
13
|
+
{description && <p>{description}</p>}
|
|
14
|
+
<div class="ds-empty-state-action"><slot /></div>
|
|
15
|
+
</div>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
-
|
|
4
|
-
interface Props extends Omit<HTMLAttributes<'button'>, 'type'> {
|
|
5
|
-
/** Accessible name (required: the button has no visible text). */
|
|
6
|
-
label: string;
|
|
7
|
-
variant?: 'primary' | 'secondary' | 'tertiary' | 'icon';
|
|
8
|
-
size?: 'sm' | 'md' | 'lg';
|
|
9
|
-
type?: 'button' | 'submit' | 'reset';
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const { label, variant = 'icon', size = 'md', type = 'button', disabled = false, class: className, ...rest } = Astro.props;
|
|
14
|
-
---
|
|
15
|
-
<button {...rest} type={type} class:list={['ds-icon-button', className]} data-variant={variant} data-size={size}
|
|
16
|
-
aria-label={label} disabled={disabled}>
|
|
17
|
-
<span aria-hidden="true"><slot /></span>
|
|
18
|
-
</button>
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
+
|
|
4
|
+
interface Props extends Omit<HTMLAttributes<'button'>, 'type'> {
|
|
5
|
+
/** Accessible name (required: the button has no visible text). */
|
|
6
|
+
label: string;
|
|
7
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'icon';
|
|
8
|
+
size?: 'sm' | 'md' | 'lg';
|
|
9
|
+
type?: 'button' | 'submit' | 'reset';
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { label, variant = 'icon', size = 'md', type = 'button', disabled = false, class: className, ...rest } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
<button {...rest} type={type} class:list={['ds-icon-button', className]} data-variant={variant} data-size={size}
|
|
16
|
+
aria-label={label} disabled={disabled}>
|
|
17
|
+
<span aria-hidden="true"><slot /></span>
|
|
18
|
+
</button>
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
---
|
|
2
|
-
interface Props {
|
|
3
|
-
/** Used by triggers: <Button data-ds-open="my-id">. */
|
|
4
|
-
id: string;
|
|
5
|
-
title: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
size?: 'sm' | 'md' | 'lg';
|
|
8
|
-
/** Secondary close button text; empty string hides it. */
|
|
9
|
-
closeLabel?: string;
|
|
10
|
-
/** Opens on page load (useful for server-driven confirmations). */
|
|
11
|
-
open?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const { id, title, description, size = 'md', closeLabel = 'Cerrar', open = false } = Astro.props;
|
|
15
|
-
---
|
|
16
|
-
<dialog id={id} class="ds-dialog" data-size={size} data-ds-modal data-ds-open-initially={open ? '' : undefined}
|
|
17
|
-
aria-labelledby={`${id}-title`} aria-describedby={description ? `${id}-description` : undefined}>
|
|
18
|
-
<div class="ds-modal-header">
|
|
19
|
-
<h2 class="ds-modal-title" id={`${id}-title`}>{title}</h2>
|
|
20
|
-
{description && <p class="ds-modal-description" id={`${id}-description`}>{description}</p>}
|
|
21
|
-
</div>
|
|
22
|
-
<div class="ds-modal-body"><slot /></div>
|
|
23
|
-
<div class="ds-modal-footer">
|
|
24
|
-
<slot name="footer" />
|
|
25
|
-
{closeLabel && <button type="button" class="ds-button" data-variant="secondary" data-size="md" data-ds-close>{closeLabel}</button>}
|
|
26
|
-
</div>
|
|
27
|
-
<button type="button" class="ds-modal-close" aria-label="Cerrar diálogo" data-ds-close>×</button>
|
|
28
|
-
</dialog>
|
|
29
|
-
|
|
30
|
-
<script>
|
|
31
|
-
import { initModals } from '../modal.js';
|
|
32
|
-
initModals();
|
|
33
|
-
document.addEventListener('astro:page-load', initModals);
|
|
34
|
-
</script>
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Used by triggers: <Button data-ds-open="my-id">. */
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
size?: 'sm' | 'md' | 'lg';
|
|
8
|
+
/** Secondary close button text; empty string hides it. */
|
|
9
|
+
closeLabel?: string;
|
|
10
|
+
/** Opens on page load (useful for server-driven confirmations). */
|
|
11
|
+
open?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { id, title, description, size = 'md', closeLabel = 'Cerrar', open = false } = Astro.props;
|
|
15
|
+
---
|
|
16
|
+
<dialog id={id} class="ds-dialog" data-size={size} data-ds-modal data-ds-open-initially={open ? '' : undefined}
|
|
17
|
+
aria-labelledby={`${id}-title`} aria-describedby={description ? `${id}-description` : undefined}>
|
|
18
|
+
<div class="ds-modal-header">
|
|
19
|
+
<h2 class="ds-modal-title" id={`${id}-title`}>{title}</h2>
|
|
20
|
+
{description && <p class="ds-modal-description" id={`${id}-description`}>{description}</p>}
|
|
21
|
+
</div>
|
|
22
|
+
<div class="ds-modal-body"><slot /></div>
|
|
23
|
+
<div class="ds-modal-footer">
|
|
24
|
+
<slot name="footer" />
|
|
25
|
+
{closeLabel && <button type="button" class="ds-button" data-variant="secondary" data-size="md" data-ds-close>{closeLabel}</button>}
|
|
26
|
+
</div>
|
|
27
|
+
<button type="button" class="ds-modal-close" aria-label="Cerrar diálogo" data-ds-close>×</button>
|
|
28
|
+
</dialog>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
import { initModals } from '../modal.js';
|
|
32
|
+
initModals();
|
|
33
|
+
document.addEventListener('astro:page-load', initModals);
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StatusTag from './StatusTag.astro';
|
|
3
|
+
import { selectionState, selectionSummary } from '../wari/logic.js';
|
|
4
|
+
|
|
5
|
+
export interface MultiSelectOption {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
/** Muestra la opción como etiqueta de estado con ese color (p. ej. "libre"). */
|
|
9
|
+
status?: string;
|
|
10
|
+
color?: { background: string; foreground: string };
|
|
11
|
+
/** Texto secundario a la derecha de la etiqueta. */
|
|
12
|
+
description?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface Props {
|
|
17
|
+
options: MultiSelectOption[];
|
|
18
|
+
/** Valores seleccionados al cargar la página. */
|
|
19
|
+
value?: string[];
|
|
20
|
+
label?: string;
|
|
21
|
+
ariaLabel?: string;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
searchPlaceholder?: string;
|
|
24
|
+
/** Texto de la fila que marca todo; `false` la oculta. */
|
|
25
|
+
allLabel?: string | false;
|
|
26
|
+
maxTags?: number;
|
|
27
|
+
/** Texto de ayuda fijo; si no se indica se muestra "N elementos seleccionados". */
|
|
28
|
+
supportingText?: string;
|
|
29
|
+
summary?: boolean;
|
|
30
|
+
emptyMessage?: string;
|
|
31
|
+
error?: boolean;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
required?: boolean;
|
|
34
|
+
/** Envía un campo oculto por valor seleccionado dentro de un <form>. */
|
|
35
|
+
name?: string;
|
|
36
|
+
id?: string;
|
|
37
|
+
size?: 'sm' | 'md' | 'lg';
|
|
38
|
+
class?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
options, value = [], label, ariaLabel, placeholder = 'Seleccionar', searchPlaceholder = 'Buscar…', allLabel = 'Todos',
|
|
43
|
+
maxTags = 2, supportingText, summary = true, emptyMessage = 'Sin coincidencias', error = false, disabled = false,
|
|
44
|
+
required = false, name, size = 'md', class: className,
|
|
45
|
+
} = Astro.props;
|
|
46
|
+
const id = Astro.props.id ?? `ds-multiselect-${Math.random().toString(36).slice(2, 9)}`;
|
|
47
|
+
const selected = options.filter(option => value.includes(option.value));
|
|
48
|
+
const state = selectionState(value, options);
|
|
49
|
+
const asTags = options.some(option => option.status || option.color);
|
|
50
|
+
const hint = supportingText || (summary ? selectionSummary(selected.length) : '');
|
|
51
|
+
const showAll = Boolean(allLabel) && options.length > 0;
|
|
52
|
+
const allSelected = state === 'all' && Boolean(allLabel);
|
|
53
|
+
---
|
|
54
|
+
<div class:list={['ds-input', 'ds-multiselect', className]} data-ds-multiselect data-open="false"
|
|
55
|
+
data-error={String(error)} data-disabled={String(disabled)} data-size={size}
|
|
56
|
+
data-max-tags={maxTags} data-summary={String(summary)} data-supporting-text={supportingText}
|
|
57
|
+
data-name={name} data-placeholder={placeholder} data-search-placeholder={searchPlaceholder}>
|
|
58
|
+
{label && <label id={`${id}-label`} for={id}>{label}{required && <span class="ds-input-required" aria-hidden="true">*</span>}</label>}
|
|
59
|
+
<div class="ds-multiselect-anchor">
|
|
60
|
+
<div class="ds-input-shell">
|
|
61
|
+
<div class="ds-multiselect-values" aria-hidden="true" hidden={selected.length === 0}>
|
|
62
|
+
{allSelected
|
|
63
|
+
? (asTags ? <StatusTag status="todos" data-tag>{allLabel}</StatusTag> : <span class="ds-multiselect-option-label" data-tag>{allLabel}</span>)
|
|
64
|
+
: selected.slice(0, maxTags).map(option => asTags
|
|
65
|
+
? <StatusTag status={option.status} color={option.color} data-tag>{option.label}</StatusTag>
|
|
66
|
+
: <span class="ds-multiselect-option-label" data-tag>{option.label}</span>)}
|
|
67
|
+
{!allSelected && selected.length > maxTags && <span class="ds-multiselect-more">+{selected.length - maxTags}</span>}
|
|
68
|
+
</div>
|
|
69
|
+
<input id={id} class="ds-multiselect-input" type="text" role="combobox" autocomplete="off"
|
|
70
|
+
aria-expanded="false" aria-controls={`${id}-listbox`} aria-autocomplete="list"
|
|
71
|
+
aria-label={label ? undefined : ariaLabel} aria-invalid={error ? 'true' : undefined} aria-required={required ? 'true' : undefined}
|
|
72
|
+
aria-describedby={hint ? `${id}-hint` : undefined}
|
|
73
|
+
placeholder={selected.length ? '' : placeholder} disabled={disabled} />
|
|
74
|
+
<button type="button" class="ds-multiselect-caret" tabindex="-1" aria-hidden="true" disabled={disabled}>
|
|
75
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m4 6 4 4 4-4" /></svg>
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
<ul id={`${id}-listbox`} class="ds-multiselect-list" role="listbox" aria-multiselectable="true" hidden
|
|
79
|
+
aria-labelledby={label ? `${id}-label` : undefined} aria-label={label ? undefined : ariaLabel}>
|
|
80
|
+
{showAll && (
|
|
81
|
+
<li id={`${id}-option-all`} role="option" class="ds-multiselect-option" data-all
|
|
82
|
+
aria-selected={String(state === 'all')} data-indeterminate={String(state === 'some')}>
|
|
83
|
+
<span class="ds-multiselect-check" aria-hidden="true"></span>
|
|
84
|
+
{asTags ? <StatusTag status="todos" data-tag>{allLabel}</StatusTag> : <span class="ds-multiselect-option-label" data-tag>{allLabel}</span>}
|
|
85
|
+
</li>
|
|
86
|
+
)}
|
|
87
|
+
{options.map((option, index) => (
|
|
88
|
+
<li id={`${id}-option-${index}`} role="option" class="ds-multiselect-option" data-value={option.value} data-label={option.label}
|
|
89
|
+
aria-selected={String(value.includes(option.value))} aria-disabled={option.disabled ? 'true' : undefined}>
|
|
90
|
+
<span class="ds-multiselect-check" aria-hidden="true"></span>
|
|
91
|
+
{asTags
|
|
92
|
+
? <StatusTag status={option.status} color={option.color} data-tag>{option.label}</StatusTag>
|
|
93
|
+
: <span class="ds-multiselect-option-label" data-tag>{option.label}</span>}
|
|
94
|
+
{option.description && <span class="ds-multiselect-option-label">{option.description}</span>}
|
|
95
|
+
</li>
|
|
96
|
+
))}
|
|
97
|
+
<li class="ds-multiselect-empty" role="presentation" hidden>{emptyMessage}</li>
|
|
98
|
+
</ul>
|
|
99
|
+
</div>
|
|
100
|
+
<small id={`${id}-hint`} class="ds-multiselect-hint" aria-live="polite" hidden={!hint}>{hint}</small>
|
|
101
|
+
<span class="ds-multiselect-inputs">{name && value.map(item => <input type="hidden" name={name} value={item} />)}</span>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<script>
|
|
105
|
+
import { initMultiSelects } from '../wari/multiselect.js';
|
|
106
|
+
initMultiSelects();
|
|
107
|
+
document.addEventListener('astro:page-load', () => initMultiSelects());
|
|
108
|
+
</script>
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { paginationRange } from '../pagination.js';
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
page: number;
|
|
6
|
-
totalPages: number;
|
|
7
|
-
/** URL pattern; "{page}" is replaced, e.g. "/blog/{page}" or "?page={page}". */
|
|
8
|
-
href: string;
|
|
9
|
-
siblings?: number;
|
|
10
|
-
variant?: 'default' | 'outlined';
|
|
11
|
-
label?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const { page, totalPages, href, siblings = 1, variant = 'default', label = 'Paginación' } = Astro.props;
|
|
15
|
-
const url = (target: number) => href.replace('{page}', String(target));
|
|
16
|
-
const tokens = paginationRange(page, totalPages, siblings);
|
|
17
|
-
---
|
|
18
|
-
<nav class="ds-pagination" aria-label={label} data-variant={variant}>
|
|
19
|
-
<ul>
|
|
20
|
-
<li>{page > 1
|
|
21
|
-
? <a class="ds-page" href={url(page - 1)} rel="prev" aria-label="Página anterior">‹</a>
|
|
22
|
-
: <span class="ds-page" aria-disabled="true" aria-hidden="true">‹</span>}</li>
|
|
23
|
-
{tokens.map(token => typeof token === 'number'
|
|
24
|
-
? <li><a class="ds-page" href={url(token)} aria-current={token === page ? 'page' : undefined} aria-label={`Página ${token}`}>{token}</a></li>
|
|
25
|
-
: <li><span class="ds-page-ellipsis" aria-hidden="true">…</span></li>)}
|
|
26
|
-
<li>{page < totalPages
|
|
27
|
-
? <a class="ds-page" href={url(page + 1)} rel="next" aria-label="Página siguiente">›</a>
|
|
28
|
-
: <span class="ds-page" aria-disabled="true" aria-hidden="true">›</span>}</li>
|
|
29
|
-
</ul>
|
|
30
|
-
</nav>
|
|
1
|
+
---
|
|
2
|
+
import { paginationRange } from '../pagination.js';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
page: number;
|
|
6
|
+
totalPages: number;
|
|
7
|
+
/** URL pattern; "{page}" is replaced, e.g. "/blog/{page}" or "?page={page}". */
|
|
8
|
+
href: string;
|
|
9
|
+
siblings?: number;
|
|
10
|
+
variant?: 'default' | 'outlined';
|
|
11
|
+
label?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { page, totalPages, href, siblings = 1, variant = 'default', label = 'Paginación' } = Astro.props;
|
|
15
|
+
const url = (target: number) => href.replace('{page}', String(target));
|
|
16
|
+
const tokens = paginationRange(page, totalPages, siblings);
|
|
17
|
+
---
|
|
18
|
+
<nav class="ds-pagination" aria-label={label} data-variant={variant}>
|
|
19
|
+
<ul>
|
|
20
|
+
<li>{page > 1
|
|
21
|
+
? <a class="ds-page" href={url(page - 1)} rel="prev" aria-label="Página anterior">‹</a>
|
|
22
|
+
: <span class="ds-page" aria-disabled="true" aria-hidden="true">‹</span>}</li>
|
|
23
|
+
{tokens.map(token => typeof token === 'number'
|
|
24
|
+
? <li><a class="ds-page" href={url(token)} aria-current={token === page ? 'page' : undefined} aria-label={`Página ${token}`}>{token}</a></li>
|
|
25
|
+
: <li><span class="ds-page-ellipsis" aria-hidden="true">…</span></li>)}
|
|
26
|
+
<li>{page < totalPages
|
|
27
|
+
? <a class="ds-page" href={url(page + 1)} rel="next" aria-label="Página siguiente">›</a>
|
|
28
|
+
: <span class="ds-page" aria-disabled="true" aria-hidden="true">›</span>}</li>
|
|
29
|
+
</ul>
|
|
30
|
+
</nav>
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
---
|
|
2
|
-
interface Props {
|
|
3
|
-
value?: number;
|
|
4
|
-
max?: number;
|
|
5
|
-
label?: string;
|
|
6
|
-
showValue?: boolean;
|
|
7
|
-
size?: 'sm' | 'md' | 'lg';
|
|
8
|
-
variant?: 'primary' | 'success' | 'warning' | 'error';
|
|
9
|
-
indeterminate?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const { value = 0, max = 100, label, showValue = true, size = 'md', variant = 'primary', indeterminate = false } = Astro.props;
|
|
13
|
-
const safeMax = max > 0 ? max : 100;
|
|
14
|
-
const percentage = Math.round(Math.min(100, Math.max(0, (Number.isFinite(value) ? value : 0) / safeMax * 100)));
|
|
15
|
-
---
|
|
16
|
-
<div class="ds-progress" role="progressbar" data-size={size} data-variant={variant} data-indeterminate={indeterminate ? 'true' : undefined}
|
|
17
|
-
aria-label={label ?? 'Progreso'} aria-valuemin="0" aria-valuemax="100" aria-valuenow={indeterminate ? undefined : percentage}>
|
|
18
|
-
{label && <span class="ds-progress-header"><span>{label}</span>{showValue && !indeterminate && <span>{percentage}%</span>}</span>}
|
|
19
|
-
<span class="ds-progress-track" aria-hidden="true"><span class="ds-progress-value" style={`width:${percentage}%`} /></span>
|
|
20
|
-
</div>
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
value?: number;
|
|
4
|
+
max?: number;
|
|
5
|
+
label?: string;
|
|
6
|
+
showValue?: boolean;
|
|
7
|
+
size?: 'sm' | 'md' | 'lg';
|
|
8
|
+
variant?: 'primary' | 'success' | 'warning' | 'error';
|
|
9
|
+
indeterminate?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { value = 0, max = 100, label, showValue = true, size = 'md', variant = 'primary', indeterminate = false } = Astro.props;
|
|
13
|
+
const safeMax = max > 0 ? max : 100;
|
|
14
|
+
const percentage = Math.round(Math.min(100, Math.max(0, (Number.isFinite(value) ? value : 0) / safeMax * 100)));
|
|
15
|
+
---
|
|
16
|
+
<div class="ds-progress" role="progressbar" data-size={size} data-variant={variant} data-indeterminate={indeterminate ? 'true' : undefined}
|
|
17
|
+
aria-label={label ?? 'Progreso'} aria-valuemin="0" aria-valuemax="100" aria-valuenow={indeterminate ? undefined : percentage}>
|
|
18
|
+
{label && <span class="ds-progress-header"><span>{label}</span>{showValue && !indeterminate && <span>{percentage}%</span>}</span>}
|
|
19
|
+
<span class="ds-progress-track" aria-hidden="true"><span class="ds-progress-value" style={`width:${percentage}%`} /></span>
|
|
20
|
+
</div>
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
---
|
|
2
|
-
export interface Option { value: string; label: string; disabled?: boolean }
|
|
3
|
-
interface Props {
|
|
4
|
-
name: string;
|
|
5
|
-
options: Option[];
|
|
6
|
-
label?: string;
|
|
7
|
-
value?: string;
|
|
8
|
-
orientation?: 'vertical' | 'horizontal';
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const { name, options, label, value, orientation = 'vertical', disabled = false, required = false } = Astro.props;
|
|
14
|
-
---
|
|
15
|
-
<fieldset class="ds-radio-group" data-orientation={orientation} disabled={disabled}>
|
|
16
|
-
{label && <legend>{label}</legend>}
|
|
17
|
-
{options.map((option, index) => (
|
|
18
|
-
<label class="ds-choice">
|
|
19
|
-
<input type="radio" name={name} value={option.value} checked={option.value === value}
|
|
20
|
-
disabled={option.disabled} required={required && index === 0} />
|
|
21
|
-
{option.label}
|
|
22
|
-
</label>
|
|
23
|
-
))}
|
|
24
|
-
</fieldset>
|
|
1
|
+
---
|
|
2
|
+
export interface Option { value: string; label: string; disabled?: boolean }
|
|
3
|
+
interface Props {
|
|
4
|
+
name: string;
|
|
5
|
+
options: Option[];
|
|
6
|
+
label?: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
orientation?: 'vertical' | 'horizontal';
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { name, options, label, value, orientation = 'vertical', disabled = false, required = false } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
<fieldset class="ds-radio-group" data-orientation={orientation} disabled={disabled}>
|
|
16
|
+
{label && <legend>{label}</legend>}
|
|
17
|
+
{options.map((option, index) => (
|
|
18
|
+
<label class="ds-choice">
|
|
19
|
+
<input type="radio" name={name} value={option.value} checked={option.value === value}
|
|
20
|
+
disabled={option.disabled} required={required && index === 0} />
|
|
21
|
+
{option.label}
|
|
22
|
+
</label>
|
|
23
|
+
))}
|
|
24
|
+
</fieldset>
|