@directo-ui/astro 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/components.css +326 -0
- package/index.d.ts +31 -31
- package/index.js +31 -31
- package/package.json +19 -1
- 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/WariDateField.astro +56 -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 +40 -0
- package/src/components/WariSwitchList.astro +33 -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/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/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 +222 -0
- package/src/wari/trip.d.ts +56 -0
- package/src/wari/trip.js +69 -0
- package/styles.css +3 -3
- package/wari.d.ts +20 -0
- package/wari.js +16 -0
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
---
|
|
2
|
-
interface Props {
|
|
3
|
-
variant?: 'info' | 'success' | 'warning' | 'error';
|
|
4
|
-
title: string;
|
|
5
|
-
description?: string;
|
|
6
|
-
dismissible?: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const { variant = 'info', title, description, dismissible = false } = Astro.props;
|
|
10
|
-
const paths = {
|
|
11
|
-
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',
|
|
12
|
-
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',
|
|
13
|
-
warning: 'M236.8 188.09 149.35 36.22a24.76 24.76 0 0 0-42.7 0L19.2 188.09a23.51 23.51 0 0 0 0 23.72A24.35 24.35 0 0 0 40.55 224h174.9a24.35 24.35 0 0 0 21.33-12.19 23.51 23.51 0 0 0 .02-23.72ZM120 104a8 8 0 0 1 16 0v40a8 8 0 0 1-16 0Zm8 88a12 12 0 1 1 12-12 12 12 0 0 1-12 12Z',
|
|
14
|
-
error: 'M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm-8 56a8 8 0 0 1 16 0v56a8 8 0 0 1-16 0Zm8 104a12 12 0 1 1 12-12 12 12 0 0 1-12 12Z',
|
|
15
|
-
};
|
|
16
|
-
---
|
|
17
|
-
<div class="ds-alert" data-variant={variant} role={variant === 'error' ? 'alert' : 'status'} data-ds-alert>
|
|
18
|
-
<span class="ds-alert-icon" aria-hidden="true"><svg viewBox="0 0 256 256" fill="currentColor"><path d={paths[variant]} /></svg></span>
|
|
19
|
-
<div class="ds-alert-content">
|
|
20
|
-
<p class="ds-alert-title">{title}</p>
|
|
21
|
-
{description && <div class="ds-alert-description">{description}</div>}
|
|
22
|
-
<slot />
|
|
23
|
-
{Astro.slots.has('actions') && <div class="ds-alert-actions"><slot name="actions" /></div>}
|
|
24
|
-
</div>
|
|
25
|
-
{dismissible && <button type="button" class="ds-alert-close" aria-label="Cerrar alerta" data-ds-alert-close>×</button>}
|
|
26
|
-
</div>
|
|
27
|
-
|
|
28
|
-
<script>
|
|
29
|
-
function initAlerts() {
|
|
30
|
-
document.querySelectorAll<HTMLButtonElement>('[data-ds-alert-close]:not([data-ds-ready])').forEach(button => {
|
|
31
|
-
button.dataset.dsReady = '';
|
|
32
|
-
button.addEventListener('click', () => {
|
|
33
|
-
const alert = button.closest<HTMLElement>('[data-ds-alert]');
|
|
34
|
-
if (!alert) return;
|
|
35
|
-
alert.hidden = true;
|
|
36
|
-
alert.dispatchEvent(new CustomEvent('ds-close', { bubbles: true }));
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
initAlerts();
|
|
41
|
-
document.addEventListener('astro:page-load', initAlerts);
|
|
42
|
-
</script>
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
variant?: 'info' | 'success' | 'warning' | 'error';
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
dismissible?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { variant = 'info', title, description, dismissible = false } = Astro.props;
|
|
10
|
+
const paths = {
|
|
11
|
+
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',
|
|
12
|
+
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',
|
|
13
|
+
warning: 'M236.8 188.09 149.35 36.22a24.76 24.76 0 0 0-42.7 0L19.2 188.09a23.51 23.51 0 0 0 0 23.72A24.35 24.35 0 0 0 40.55 224h174.9a24.35 24.35 0 0 0 21.33-12.19 23.51 23.51 0 0 0 .02-23.72ZM120 104a8 8 0 0 1 16 0v40a8 8 0 0 1-16 0Zm8 88a12 12 0 1 1 12-12 12 12 0 0 1-12 12Z',
|
|
14
|
+
error: 'M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm-8 56a8 8 0 0 1 16 0v56a8 8 0 0 1-16 0Zm8 104a12 12 0 1 1 12-12 12 12 0 0 1-12 12Z',
|
|
15
|
+
};
|
|
16
|
+
---
|
|
17
|
+
<div class="ds-alert" data-variant={variant} role={variant === 'error' ? 'alert' : 'status'} data-ds-alert>
|
|
18
|
+
<span class="ds-alert-icon" aria-hidden="true"><svg viewBox="0 0 256 256" fill="currentColor"><path d={paths[variant]} /></svg></span>
|
|
19
|
+
<div class="ds-alert-content">
|
|
20
|
+
<p class="ds-alert-title">{title}</p>
|
|
21
|
+
{description && <div class="ds-alert-description">{description}</div>}
|
|
22
|
+
<slot />
|
|
23
|
+
{Astro.slots.has('actions') && <div class="ds-alert-actions"><slot name="actions" /></div>}
|
|
24
|
+
</div>
|
|
25
|
+
{dismissible && <button type="button" class="ds-alert-close" aria-label="Cerrar alerta" data-ds-alert-close>×</button>}
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
function initAlerts() {
|
|
30
|
+
document.querySelectorAll<HTMLButtonElement>('[data-ds-alert-close]:not([data-ds-ready])').forEach(button => {
|
|
31
|
+
button.dataset.dsReady = '';
|
|
32
|
+
button.addEventListener('click', () => {
|
|
33
|
+
const alert = button.closest<HTMLElement>('[data-ds-alert]');
|
|
34
|
+
if (!alert) return;
|
|
35
|
+
alert.hidden = true;
|
|
36
|
+
alert.dispatchEvent(new CustomEvent('ds-close', { bubbles: true }));
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
initAlerts();
|
|
41
|
+
document.addEventListener('astro:page-load', initAlerts);
|
|
42
|
+
</script>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
---
|
|
2
|
-
interface Props {
|
|
3
|
-
name: string;
|
|
4
|
-
src?: string;
|
|
5
|
-
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
6
|
-
shape?: 'circle' | 'rounded' | 'square';
|
|
7
|
-
status?: 'online' | 'offline' | 'away' | 'busy';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const { name, src, size = 'md', shape = 'circle', status } = Astro.props;
|
|
11
|
-
const statusLabels = { online: 'En línea', offline: 'Desconectado', away: 'Ausente', busy: 'Ocupado' };
|
|
12
|
-
const initials = name.trim().split(/\s+/).filter(Boolean).slice(0, 2).map(part => part.charAt(0).toUpperCase()).join('') || '?';
|
|
13
|
-
const label = [name, status ? statusLabels[status] : ''].filter(Boolean).join(', ');
|
|
14
|
-
---
|
|
15
|
-
<span class="ds-avatar" data-size={size} data-shape={shape} role="img" aria-label={label}>
|
|
16
|
-
{src
|
|
17
|
-
? <img src={src} alt="" loading="lazy" onerror="this.hidden=true;this.nextElementSibling.hidden=false" />
|
|
18
|
-
: null}
|
|
19
|
-
<span class="ds-avatar-fallback" aria-hidden="true" hidden={Boolean(src)}>{initials}</span>
|
|
20
|
-
{status && <span class="ds-avatar-status" data-status={status} aria-hidden="true" />}
|
|
21
|
-
</span>
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
name: string;
|
|
4
|
+
src?: string;
|
|
5
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
6
|
+
shape?: 'circle' | 'rounded' | 'square';
|
|
7
|
+
status?: 'online' | 'offline' | 'away' | 'busy';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { name, src, size = 'md', shape = 'circle', status } = Astro.props;
|
|
11
|
+
const statusLabels = { online: 'En línea', offline: 'Desconectado', away: 'Ausente', busy: 'Ocupado' };
|
|
12
|
+
const initials = name.trim().split(/\s+/).filter(Boolean).slice(0, 2).map(part => part.charAt(0).toUpperCase()).join('') || '?';
|
|
13
|
+
const label = [name, status ? statusLabels[status] : ''].filter(Boolean).join(', ');
|
|
14
|
+
---
|
|
15
|
+
<span class="ds-avatar" data-size={size} data-shape={shape} role="img" aria-label={label}>
|
|
16
|
+
{src
|
|
17
|
+
? <img src={src} alt="" loading="lazy" onerror="this.hidden=true;this.nextElementSibling.hidden=false" />
|
|
18
|
+
: null}
|
|
19
|
+
<span class="ds-avatar-fallback" aria-hidden="true" hidden={Boolean(src)}>{initials}</span>
|
|
20
|
+
{status && <span class="ds-avatar-status" data-status={status} aria-hidden="true" />}
|
|
21
|
+
</span>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
---
|
|
2
|
-
interface Props {
|
|
3
|
-
variant?: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error' | 'neutral' | 'solid' | 'outline';
|
|
4
|
-
size?: 'sm' | 'md' | 'lg';
|
|
5
|
-
dot?: boolean;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const { variant = 'primary', size = 'md', dot = false } = Astro.props;
|
|
9
|
-
---
|
|
10
|
-
<span class="ds-badge" data-variant={variant} data-size={size}>
|
|
11
|
-
{dot && <span class="ds-badge-dot" aria-hidden="true" />}
|
|
12
|
-
<slot />
|
|
13
|
-
</span>
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
variant?: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error' | 'neutral' | 'solid' | 'outline';
|
|
4
|
+
size?: 'sm' | 'md' | 'lg';
|
|
5
|
+
dot?: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { variant = 'primary', size = 'md', dot = false } = Astro.props;
|
|
9
|
+
---
|
|
10
|
+
<span class="ds-badge" data-variant={variant} data-size={size}>
|
|
11
|
+
{dot && <span class="ds-badge-dot" aria-hidden="true" />}
|
|
12
|
+
<slot />
|
|
13
|
+
</span>
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
---
|
|
2
|
-
interface Props {
|
|
3
|
-
/** Used by triggers: <Button data-ds-open="my-id">. */
|
|
4
|
-
id: string;
|
|
5
|
-
title?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const { id, title = 'Información' } = Astro.props;
|
|
9
|
-
---
|
|
10
|
-
<dialog id={id} class="ds-sheet" data-ds-modal aria-labelledby={`${id}-title`}>
|
|
11
|
-
<div class="ds-sheet-handle" aria-hidden="true"></div>
|
|
12
|
-
<header class="ds-sheet-header">
|
|
13
|
-
<h2 id={`${id}-title`}>{title}</h2>
|
|
14
|
-
<button type="button" class="ds-sheet-close" aria-label="Cerrar panel" data-ds-close>×</button>
|
|
15
|
-
</header>
|
|
16
|
-
<div class="ds-sheet-body"><slot /></div>
|
|
17
|
-
</dialog>
|
|
18
|
-
|
|
19
|
-
<script>
|
|
20
|
-
import { initModals } from '../modal.js';
|
|
21
|
-
initModals();
|
|
22
|
-
document.addEventListener('astro:page-load', initModals);
|
|
23
|
-
</script>
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Used by triggers: <Button data-ds-open="my-id">. */
|
|
4
|
+
id: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { id, title = 'Información' } = Astro.props;
|
|
9
|
+
---
|
|
10
|
+
<dialog id={id} class="ds-sheet" data-ds-modal aria-labelledby={`${id}-title`}>
|
|
11
|
+
<div class="ds-sheet-handle" aria-hidden="true"></div>
|
|
12
|
+
<header class="ds-sheet-header">
|
|
13
|
+
<h2 id={`${id}-title`}>{title}</h2>
|
|
14
|
+
<button type="button" class="ds-sheet-close" aria-label="Cerrar panel" data-ds-close>×</button>
|
|
15
|
+
</header>
|
|
16
|
+
<div class="ds-sheet-body"><slot /></div>
|
|
17
|
+
</dialog>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
import { initModals } from '../modal.js';
|
|
21
|
+
initModals();
|
|
22
|
+
document.addEventListener('astro:page-load', initModals);
|
|
23
|
+
</script>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
---
|
|
2
|
-
export interface BreadcrumbItem { label: string; href?: string }
|
|
3
|
-
interface Props {
|
|
4
|
-
items: BreadcrumbItem[];
|
|
5
|
-
separator?: 'chevron' | 'slash';
|
|
6
|
-
label?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const { items, separator = 'chevron', label = 'Ruta de navegación' } = Astro.props;
|
|
10
|
-
---
|
|
11
|
-
<nav class="ds-breadcrumb" aria-label={label} data-separator={separator}>
|
|
12
|
-
<ol>
|
|
13
|
-
{items.map((item, index) => {
|
|
14
|
-
const last = index === items.length - 1;
|
|
15
|
-
return <li>{last || !item.href ? <span aria-current={last ? 'page' : undefined}>{item.label}</span> : <a href={item.href}>{item.label}</a>}</li>;
|
|
16
|
-
})}
|
|
17
|
-
</ol>
|
|
18
|
-
</nav>
|
|
1
|
+
---
|
|
2
|
+
export interface BreadcrumbItem { label: string; href?: string }
|
|
3
|
+
interface Props {
|
|
4
|
+
items: BreadcrumbItem[];
|
|
5
|
+
separator?: 'chevron' | 'slash';
|
|
6
|
+
label?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { items, separator = 'chevron', label = 'Ruta de navegación' } = Astro.props;
|
|
10
|
+
---
|
|
11
|
+
<nav class="ds-breadcrumb" aria-label={label} data-separator={separator}>
|
|
12
|
+
<ol>
|
|
13
|
+
{items.map((item, index) => {
|
|
14
|
+
const last = index === items.length - 1;
|
|
15
|
+
return <li>{last || !item.href ? <span aria-current={last ? 'page' : undefined}>{item.label}</span> : <a href={item.href}>{item.label}</a>}</li>;
|
|
16
|
+
})}
|
|
17
|
+
</ol>
|
|
18
|
+
</nav>
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
-
|
|
4
|
-
interface Props extends Omit<HTMLAttributes<'button'>, 'type'> {
|
|
5
|
-
variant?: 'primary' | 'secondary' | 'tertiary' | 'text' | 'danger';
|
|
6
|
-
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
7
|
-
type?: 'button' | 'submit' | 'reset';
|
|
8
|
-
/** Renders an <a> with button styling. */
|
|
9
|
-
href?: string;
|
|
10
|
-
loading?: boolean;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
fullWidth?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const { variant = 'primary', size = 'md', type = 'button', href, loading = false, disabled = false, fullWidth = false, class: className, ...rest } = Astro.props;
|
|
16
|
-
const common = {
|
|
17
|
-
class: ['ds-button', className].filter(Boolean).join(' '),
|
|
18
|
-
'data-variant': variant, 'data-size': size, 'data-full-width': fullWidth ? 'true' : undefined,
|
|
19
|
-
};
|
|
20
|
-
---
|
|
21
|
-
{href ? (
|
|
22
|
-
<a {...rest as HTMLAttributes<'a'>} {...common} href={disabled ? undefined : href} aria-disabled={disabled ? 'true' : undefined}>
|
|
23
|
-
<slot name="icon-start" /><slot /><slot name="icon-end" />
|
|
24
|
-
</a>
|
|
25
|
-
) : (
|
|
26
|
-
<button {...rest} {...common} type={type} disabled={disabled || loading} aria-busy={loading ? 'true' : undefined}>
|
|
27
|
-
{loading ? <span class="ds-spinner" data-size="sm" aria-hidden="true" /> : <slot name="icon-start" />}
|
|
28
|
-
<slot />
|
|
29
|
-
{!loading && <slot name="icon-end" />}
|
|
30
|
-
</button>
|
|
31
|
-
)}
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
+
|
|
4
|
+
interface Props extends Omit<HTMLAttributes<'button'>, 'type'> {
|
|
5
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'text' | 'danger';
|
|
6
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
7
|
+
type?: 'button' | 'submit' | 'reset';
|
|
8
|
+
/** Renders an <a> with button styling. */
|
|
9
|
+
href?: string;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
fullWidth?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { variant = 'primary', size = 'md', type = 'button', href, loading = false, disabled = false, fullWidth = false, class: className, ...rest } = Astro.props;
|
|
16
|
+
const common = {
|
|
17
|
+
class: ['ds-button', className].filter(Boolean).join(' '),
|
|
18
|
+
'data-variant': variant, 'data-size': size, 'data-full-width': fullWidth ? 'true' : undefined,
|
|
19
|
+
};
|
|
20
|
+
---
|
|
21
|
+
{href ? (
|
|
22
|
+
<a {...rest as HTMLAttributes<'a'>} {...common} href={disabled ? undefined : href} aria-disabled={disabled ? 'true' : undefined}>
|
|
23
|
+
<slot name="icon-start" /><slot /><slot name="icon-end" />
|
|
24
|
+
</a>
|
|
25
|
+
) : (
|
|
26
|
+
<button {...rest} {...common} type={type} disabled={disabled || loading} aria-busy={loading ? 'true' : undefined}>
|
|
27
|
+
{loading ? <span class="ds-spinner" data-size="sm" aria-hidden="true" /> : <slot name="icon-start" />}
|
|
28
|
+
<slot />
|
|
29
|
+
{!loading && <slot name="icon-end" />}
|
|
30
|
+
</button>
|
|
31
|
+
)}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
-
|
|
4
|
-
interface Props extends HTMLAttributes<'div'> {
|
|
5
|
-
variant?: 'default' | 'elevated' | 'outlined' | 'filled' | 'interactive';
|
|
6
|
-
padding?: 'none' | 'sm' | 'md' | 'lg';
|
|
7
|
-
title?: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
/** Makes the whole card a link (use variant="interactive"). */
|
|
10
|
-
href?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const { variant = 'default', padding = 'md', title, description, href, class: className, ...rest } = Astro.props;
|
|
14
|
-
const Tag = href ? 'a' : 'div';
|
|
15
|
-
---
|
|
16
|
-
<Tag {...rest} href={href} class:list={['ds-card', className]} data-variant={variant} data-padding={padding}>
|
|
17
|
-
{(title || description) && (
|
|
18
|
-
<div class="ds-card-header">
|
|
19
|
-
{title && <h3 class="ds-card-title">{title}</h3>}
|
|
20
|
-
{description && <p class="ds-card-description">{description}</p>}
|
|
21
|
-
</div>
|
|
22
|
-
)}
|
|
23
|
-
<div class="ds-card-content"><slot /></div>
|
|
24
|
-
{Astro.slots.has('footer') && <div class="ds-card-footer"><slot name="footer" /></div>}
|
|
25
|
-
</Tag>
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
+
|
|
4
|
+
interface Props extends HTMLAttributes<'div'> {
|
|
5
|
+
variant?: 'default' | 'elevated' | 'outlined' | 'filled' | 'interactive';
|
|
6
|
+
padding?: 'none' | 'sm' | 'md' | 'lg';
|
|
7
|
+
title?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
/** Makes the whole card a link (use variant="interactive"). */
|
|
10
|
+
href?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { variant = 'default', padding = 'md', title, description, href, class: className, ...rest } = Astro.props;
|
|
14
|
+
const Tag = href ? 'a' : 'div';
|
|
15
|
+
---
|
|
16
|
+
<Tag {...rest} href={href} class:list={['ds-card', className]} data-variant={variant} data-padding={padding}>
|
|
17
|
+
{(title || description) && (
|
|
18
|
+
<div class="ds-card-header">
|
|
19
|
+
{title && <h3 class="ds-card-title">{title}</h3>}
|
|
20
|
+
{description && <p class="ds-card-description">{description}</p>}
|
|
21
|
+
</div>
|
|
22
|
+
)}
|
|
23
|
+
<div class="ds-card-content"><slot /></div>
|
|
24
|
+
{Astro.slots.has('footer') && <div class="ds-card-footer"><slot name="footer" /></div>}
|
|
25
|
+
</Tag>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
-
|
|
4
|
-
interface Props extends Omit<HTMLAttributes<'input'>, 'type'> {
|
|
5
|
-
label: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const { label, description, class: className, ...rest } = Astro.props;
|
|
10
|
-
---
|
|
11
|
-
<label class:list={['ds-choice', className]}>
|
|
12
|
-
<input {...rest} type="checkbox" />
|
|
13
|
-
{description ? <span class="ds-choice-text"><span>{label}</span><span class="ds-choice-description">{description}</span></span> : label}
|
|
14
|
-
</label>
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
+
|
|
4
|
+
interface Props extends Omit<HTMLAttributes<'input'>, 'type'> {
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { label, description, class: className, ...rest } = Astro.props;
|
|
10
|
+
---
|
|
11
|
+
<label class:list={['ds-choice', className]}>
|
|
12
|
+
<input {...rest} type="checkbox" />
|
|
13
|
+
{description ? <span class="ds-choice-text"><span>{label}</span><span class="ds-choice-description">{description}</span></span> : label}
|
|
14
|
+
</label>
|
|
@@ -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>
|