@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.
Files changed (67) hide show
  1. package/README.md +14 -0
  2. package/components.css +326 -0
  3. package/index.d.ts +31 -31
  4. package/index.js +31 -31
  5. package/package.json +19 -1
  6. package/src/components/Accordion.astro +8 -8
  7. package/src/components/AccordionItem.astro +14 -14
  8. package/src/components/Alert.astro +42 -42
  9. package/src/components/Avatar.astro +21 -21
  10. package/src/components/Badge.astro +13 -13
  11. package/src/components/BottomSheet.astro +23 -23
  12. package/src/components/Breadcrumb.astro +18 -18
  13. package/src/components/Button.astro +31 -31
  14. package/src/components/Card.astro +25 -25
  15. package/src/components/Checkbox.astro +14 -14
  16. package/src/components/DatePicker.astro +25 -25
  17. package/src/components/Divider.astro +11 -11
  18. package/src/components/Dropdown.astro +71 -71
  19. package/src/components/EmptyState.astro +15 -15
  20. package/src/components/IconButton.astro +18 -18
  21. package/src/components/Modal.astro +34 -34
  22. package/src/components/MultiSelect.astro +108 -0
  23. package/src/components/Pagination.astro +30 -30
  24. package/src/components/Progress.astro +20 -20
  25. package/src/components/RadioGroup.astro +24 -24
  26. package/src/components/Select.astro +29 -29
  27. package/src/components/Skeleton.astro +13 -13
  28. package/src/components/Spinner.astro +17 -17
  29. package/src/components/StatusTag.astro +18 -0
  30. package/src/components/Switch.astro +13 -13
  31. package/src/components/Tabs.astro +60 -60
  32. package/src/components/TextField.astro +24 -24
  33. package/src/components/Textarea.astro +41 -41
  34. package/src/components/Toaster.astro +8 -8
  35. package/src/components/Tooltip.astro +31 -31
  36. package/src/components/WariDateField.astro +56 -0
  37. package/src/components/WariSchedule.astro +48 -0
  38. package/src/components/WariSelect.astro +76 -0
  39. package/src/components/WariServiceMeta.astro +19 -0
  40. package/src/components/WariStatusSelect.astro +20 -0
  41. package/src/components/WariStepper.astro +40 -0
  42. package/src/components/WariSwitchList.astro +33 -0
  43. package/src/components/WariTimeField.astro +50 -0
  44. package/src/components/WariTripAttributes.astro +60 -0
  45. package/src/modal.d.ts +3 -3
  46. package/src/modal.js +39 -39
  47. package/src/pagination.d.ts +2 -2
  48. package/src/pagination.js +16 -16
  49. package/src/toast.d.ts +9 -9
  50. package/src/toast.js +66 -66
  51. package/src/wari/datetime.d.ts +57 -0
  52. package/src/wari/datetime.js +151 -0
  53. package/src/wari/logic.d.ts +8 -0
  54. package/src/wari/logic.js +41 -0
  55. package/src/wari/multiselect.d.ts +2 -0
  56. package/src/wari/multiselect.js +169 -0
  57. package/src/wari/pickers.d.ts +2 -0
  58. package/src/wari/pickers.js +369 -0
  59. package/src/wari/statuses.d.ts +14 -0
  60. package/src/wari/statuses.js +15 -0
  61. package/src/wari/trip-client.d.ts +4 -0
  62. package/src/wari/trip-client.js +222 -0
  63. package/src/wari/trip.d.ts +56 -0
  64. package/src/wari/trip.js +69 -0
  65. package/styles.css +3 -3
  66. package/wari.d.ts +20 -0
  67. package/wari.js +16 -0
@@ -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>
@@ -1,29 +1,29 @@
1
- ---
2
- import type { HTMLAttributes } from 'astro/types';
3
-
4
- export interface Option { value: string; label: string; disabled?: boolean }
5
- interface Props extends Omit<HTMLAttributes<'select'>, 'size'> {
6
- label?: string;
7
- supportingText?: string;
8
- error?: boolean;
9
- options?: Option[];
10
- value?: string;
11
- placeholder?: string;
12
- size?: 'sm' | 'md' | 'lg';
13
- }
14
-
15
- const { label, supportingText, error = false, options = [], value, placeholder, size = 'md', id, disabled = false, required = false, ...rest } = Astro.props;
16
- const fieldId = id ?? `ds-field-${Math.random().toString(36).slice(2, 9)}`;
17
- const hintId = supportingText ? `${fieldId}-hint` : undefined;
18
- ---
19
- <div class="ds-input" data-error={String(error)} data-disabled={String(Boolean(disabled))} data-size={size}>
20
- {label && <label for={fieldId}>{label}{required && <span class="ds-input-required" aria-hidden="true">*</span>}</label>}
21
- <div class="ds-input-shell ds-select-native">
22
- <select {...rest} id={fieldId} disabled={disabled} required={required} aria-invalid={error ? 'true' : undefined} aria-describedby={hintId}>
23
- {placeholder && <option value="" disabled selected={!value}>{placeholder}</option>}
24
- {options.map(option => <option value={option.value} disabled={option.disabled} selected={option.value === value}>{option.label}</option>)}
25
- <slot />
26
- </select>
27
- </div>
28
- {supportingText && <small id={hintId}>{supportingText}</small>}
29
- </div>
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ export interface Option { value: string; label: string; disabled?: boolean }
5
+ interface Props extends Omit<HTMLAttributes<'select'>, 'size'> {
6
+ label?: string;
7
+ supportingText?: string;
8
+ error?: boolean;
9
+ options?: Option[];
10
+ value?: string;
11
+ placeholder?: string;
12
+ size?: 'sm' | 'md' | 'lg';
13
+ }
14
+
15
+ const { label, supportingText, error = false, options = [], value, placeholder, size = 'md', id, disabled = false, required = false, ...rest } = Astro.props;
16
+ const fieldId = id ?? `ds-field-${Math.random().toString(36).slice(2, 9)}`;
17
+ const hintId = supportingText ? `${fieldId}-hint` : undefined;
18
+ ---
19
+ <div class="ds-input" data-error={String(error)} data-disabled={String(Boolean(disabled))} data-size={size}>
20
+ {label && <label for={fieldId}>{label}{required && <span class="ds-input-required" aria-hidden="true">*</span>}</label>}
21
+ <div class="ds-input-shell ds-select-native">
22
+ <select {...rest} id={fieldId} disabled={disabled} required={required} aria-invalid={error ? 'true' : undefined} aria-describedby={hintId}>
23
+ {placeholder && <option value="" disabled selected={!value}>{placeholder}</option>}
24
+ {options.map(option => <option value={option.value} disabled={option.disabled} selected={option.value === value}>{option.label}</option>)}
25
+ <slot />
26
+ </select>
27
+ </div>
28
+ {supportingText && <small id={hintId}>{supportingText}</small>}
29
+ </div>
@@ -1,13 +1,13 @@
1
- ---
2
- interface Props {
3
- lines?: number;
4
- avatar?: boolean;
5
- label?: string;
6
- }
7
-
8
- const { lines = 3, avatar = false, label = 'Cargando contenido' } = Astro.props;
9
- ---
10
- <div role="status" aria-label={label} style={avatar ? 'display:flex;gap:12px;align-items:flex-start' : undefined}>
11
- {avatar && <span class="ds-skeleton-circle" aria-hidden="true" />}
12
- <span class="ds-skeleton" aria-hidden="true">{Array.from({ length: Math.max(1, lines) }, () => <span />)}</span>
13
- </div>
1
+ ---
2
+ interface Props {
3
+ lines?: number;
4
+ avatar?: boolean;
5
+ label?: string;
6
+ }
7
+
8
+ const { lines = 3, avatar = false, label = 'Cargando contenido' } = Astro.props;
9
+ ---
10
+ <div role="status" aria-label={label} style={avatar ? 'display:flex;gap:12px;align-items:flex-start' : undefined}>
11
+ {avatar && <span class="ds-skeleton-circle" aria-hidden="true" />}
12
+ <span class="ds-skeleton" aria-hidden="true">{Array.from({ length: Math.max(1, lines) }, () => <span />)}</span>
13
+ </div>
@@ -1,17 +1,17 @@
1
- ---
2
- interface Props {
3
- size?: 'sm' | 'md' | 'lg';
4
- label?: string;
5
- showLabel?: boolean;
6
- /** "dots" renders three pulsing dots. */
7
- variant?: 'spinner' | 'dots';
8
- }
9
-
10
- const { size = 'md', label = 'Cargando', showLabel = false, variant = 'spinner' } = Astro.props;
11
- ---
12
- <span class="ds-loading" role="status" aria-label={showLabel ? undefined : label}>
13
- {variant === 'dots'
14
- ? <span class="ds-loading-dots" aria-hidden="true"><span /><span /><span /></span>
15
- : <span class="ds-spinner" data-size={size} aria-hidden="true" />}
16
- {showLabel && <span>{label}</span>}
17
- </span>
1
+ ---
2
+ interface Props {
3
+ size?: 'sm' | 'md' | 'lg';
4
+ label?: string;
5
+ showLabel?: boolean;
6
+ /** "dots" renders three pulsing dots. */
7
+ variant?: 'spinner' | 'dots';
8
+ }
9
+
10
+ const { size = 'md', label = 'Cargando', showLabel = false, variant = 'spinner' } = Astro.props;
11
+ ---
12
+ <span class="ds-loading" role="status" aria-label={showLabel ? undefined : label}>
13
+ {variant === 'dots'
14
+ ? <span class="ds-loading-dots" aria-hidden="true"><span /><span /><span /></span>
15
+ : <span class="ds-spinner" data-size={size} aria-hidden="true" />}
16
+ {showLabel && <span>{label}</span>}
17
+ </span>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { wariStatusLabel } from '../wari/statuses.js';
3
+
4
+ interface Props {
5
+ /** Estado de Wari ("libre", "aceptado"…) o "todos". Sin contenido, muestra su nombre. */
6
+ status?: string;
7
+ size?: 'sm' | 'md';
8
+ /** Colores propios para un estado que no está en la lista. */
9
+ color?: { background: string; foreground: string };
10
+ class?: string;
11
+ [attribute: `data-${string}`]: unknown;
12
+ }
13
+
14
+ const { status, size = 'md', color, class: className, ...rest } = Astro.props;
15
+ const style = color ? `--ds-status-bg:${color.background};--ds-status-fg:${color.foreground}` : undefined;
16
+ const fallback = status && status !== 'todos' ? wariStatusLabel(status) : 'Todos';
17
+ ---
18
+ <span class:list={['ds-status', className]} data-status={status} data-size={size} style={style} {...rest}><span><slot>{fallback}</slot></span></span>
@@ -1,13 +1,13 @@
1
- ---
2
- import type { HTMLAttributes } from 'astro/types';
3
-
4
- interface Props extends Omit<HTMLAttributes<'input'>, 'type' | 'role'> {
5
- label: string;
6
- }
7
-
8
- const { label, class: className, ...rest } = Astro.props;
9
- ---
10
- <label class:list={['ds-choice', className]}>
11
- <input {...rest} type="checkbox" role="switch" />
12
- {label}
13
- </label>
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends Omit<HTMLAttributes<'input'>, 'type' | 'role'> {
5
+ label: string;
6
+ }
7
+
8
+ const { label, class: className, ...rest } = Astro.props;
9
+ ---
10
+ <label class:list={['ds-choice', className]}>
11
+ <input {...rest} type="checkbox" role="switch" />
12
+ {label}
13
+ </label>