@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.
Files changed (77) hide show
  1. package/README.md +16 -0
  2. package/components.css +661 -0
  3. package/index.d.ts +31 -31
  4. package/index.js +31 -31
  5. package/package.json +29 -7
  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/WariClientDetails.astro +87 -0
  37. package/src/components/WariClientSearch.astro +88 -0
  38. package/src/components/WariDateField.astro +56 -0
  39. package/src/components/WariPassengerField.astro +84 -0
  40. package/src/components/WariRoute.astro +49 -0
  41. package/src/components/WariSchedule.astro +48 -0
  42. package/src/components/WariSelect.astro +76 -0
  43. package/src/components/WariServiceMeta.astro +19 -0
  44. package/src/components/WariStatusSelect.astro +20 -0
  45. package/src/components/WariStepper.astro +45 -0
  46. package/src/components/WariSwitchList.astro +111 -0
  47. package/src/components/WariTimeField.astro +50 -0
  48. package/src/components/WariTripAttributes.astro +60 -0
  49. package/src/modal.d.ts +3 -3
  50. package/src/modal.js +39 -39
  51. package/src/pagination.d.ts +2 -2
  52. package/src/pagination.js +16 -16
  53. package/src/toast.d.ts +9 -9
  54. package/src/toast.js +66 -66
  55. package/src/wari/datetime.d.ts +57 -0
  56. package/src/wari/datetime.js +151 -0
  57. package/src/wari/logic.d.ts +8 -0
  58. package/src/wari/logic.js +41 -0
  59. package/src/wari/motion.d.ts +14 -0
  60. package/src/wari/motion.js +60 -0
  61. package/src/wari/multiselect.d.ts +2 -0
  62. package/src/wari/multiselect.js +169 -0
  63. package/src/wari/pickers.d.ts +2 -0
  64. package/src/wari/pickers.js +369 -0
  65. package/src/wari/route-client.d.ts +10 -0
  66. package/src/wari/route-client.js +270 -0
  67. package/src/wari/route.d.ts +48 -0
  68. package/src/wari/route.js +71 -0
  69. package/src/wari/statuses.d.ts +14 -0
  70. package/src/wari/statuses.js +15 -0
  71. package/src/wari/trip-client.d.ts +4 -0
  72. package/src/wari/trip-client.js +370 -0
  73. package/src/wari/trip.d.ts +107 -0
  74. package/src/wari/trip.js +129 -0
  75. package/styles.css +3 -3
  76. package/wari.d.ts +26 -0
  77. package/wari.js +21 -0
package/index.d.ts CHANGED
@@ -1,31 +1,31 @@
1
- // @directo-ui/astro — import components from here and '@directo-ui/astro/styles.css' once in your layout.
2
- export { default as Button } from './src/components/Button.astro';
3
- export { default as IconButton } from './src/components/IconButton.astro';
4
- export { default as TextField } from './src/components/TextField.astro';
5
- export { default as Textarea } from './src/components/Textarea.astro';
6
- export { default as Select } from './src/components/Select.astro';
7
- export { default as Checkbox } from './src/components/Checkbox.astro';
8
- export { default as Switch } from './src/components/Switch.astro';
9
- export { default as RadioGroup } from './src/components/RadioGroup.astro';
10
- export { default as DatePicker } from './src/components/DatePicker.astro';
11
- export { default as Card } from './src/components/Card.astro';
12
- export { default as Badge } from './src/components/Badge.astro';
13
- export { default as Alert } from './src/components/Alert.astro';
14
- export { default as Avatar } from './src/components/Avatar.astro';
15
- export { default as Modal } from './src/components/Modal.astro';
16
- export { default as BottomSheet } from './src/components/BottomSheet.astro';
17
- export { default as Tabs } from './src/components/Tabs.astro';
18
- export { default as Tooltip } from './src/components/Tooltip.astro';
19
- export { default as Dropdown } from './src/components/Dropdown.astro';
20
- export { default as Spinner } from './src/components/Spinner.astro';
21
- export { default as Skeleton } from './src/components/Skeleton.astro';
22
- export { default as Progress } from './src/components/Progress.astro';
23
- export { default as EmptyState } from './src/components/EmptyState.astro';
24
- export { default as Accordion } from './src/components/Accordion.astro';
25
- export { default as AccordionItem } from './src/components/AccordionItem.astro';
26
- export { default as Breadcrumb } from './src/components/Breadcrumb.astro';
27
- export { default as Pagination } from './src/components/Pagination.astro';
28
- export { default as Divider } from './src/components/Divider.astro';
29
- export { default as Toaster } from './src/components/Toaster.astro';
30
- export { initModals, openModal, closeModal } from './src/modal';
31
- export { paginationRange } from './src/pagination';
1
+ // @directo-ui/astro — import components from here and '@directo-ui/astro/styles.css' once in your layout.
2
+ export { default as Button } from './src/components/Button.astro';
3
+ export { default as IconButton } from './src/components/IconButton.astro';
4
+ export { default as TextField } from './src/components/TextField.astro';
5
+ export { default as Textarea } from './src/components/Textarea.astro';
6
+ export { default as Select } from './src/components/Select.astro';
7
+ export { default as Checkbox } from './src/components/Checkbox.astro';
8
+ export { default as Switch } from './src/components/Switch.astro';
9
+ export { default as RadioGroup } from './src/components/RadioGroup.astro';
10
+ export { default as DatePicker } from './src/components/DatePicker.astro';
11
+ export { default as Card } from './src/components/Card.astro';
12
+ export { default as Badge } from './src/components/Badge.astro';
13
+ export { default as Alert } from './src/components/Alert.astro';
14
+ export { default as Avatar } from './src/components/Avatar.astro';
15
+ export { default as Modal } from './src/components/Modal.astro';
16
+ export { default as BottomSheet } from './src/components/BottomSheet.astro';
17
+ export { default as Tabs } from './src/components/Tabs.astro';
18
+ export { default as Tooltip } from './src/components/Tooltip.astro';
19
+ export { default as Dropdown } from './src/components/Dropdown.astro';
20
+ export { default as Spinner } from './src/components/Spinner.astro';
21
+ export { default as Skeleton } from './src/components/Skeleton.astro';
22
+ export { default as Progress } from './src/components/Progress.astro';
23
+ export { default as EmptyState } from './src/components/EmptyState.astro';
24
+ export { default as Accordion } from './src/components/Accordion.astro';
25
+ export { default as AccordionItem } from './src/components/AccordionItem.astro';
26
+ export { default as Breadcrumb } from './src/components/Breadcrumb.astro';
27
+ export { default as Pagination } from './src/components/Pagination.astro';
28
+ export { default as Divider } from './src/components/Divider.astro';
29
+ export { default as Toaster } from './src/components/Toaster.astro';
30
+ export { initModals, openModal, closeModal } from './src/modal';
31
+ export { paginationRange } from './src/pagination';
package/index.js CHANGED
@@ -1,31 +1,31 @@
1
- // @directo-ui/astro — import components from here and '@directo-ui/astro/styles.css' once in your layout.
2
- export { default as Button } from './src/components/Button.astro';
3
- export { default as IconButton } from './src/components/IconButton.astro';
4
- export { default as TextField } from './src/components/TextField.astro';
5
- export { default as Textarea } from './src/components/Textarea.astro';
6
- export { default as Select } from './src/components/Select.astro';
7
- export { default as Checkbox } from './src/components/Checkbox.astro';
8
- export { default as Switch } from './src/components/Switch.astro';
9
- export { default as RadioGroup } from './src/components/RadioGroup.astro';
10
- export { default as DatePicker } from './src/components/DatePicker.astro';
11
- export { default as Card } from './src/components/Card.astro';
12
- export { default as Badge } from './src/components/Badge.astro';
13
- export { default as Alert } from './src/components/Alert.astro';
14
- export { default as Avatar } from './src/components/Avatar.astro';
15
- export { default as Modal } from './src/components/Modal.astro';
16
- export { default as BottomSheet } from './src/components/BottomSheet.astro';
17
- export { default as Tabs } from './src/components/Tabs.astro';
18
- export { default as Tooltip } from './src/components/Tooltip.astro';
19
- export { default as Dropdown } from './src/components/Dropdown.astro';
20
- export { default as Spinner } from './src/components/Spinner.astro';
21
- export { default as Skeleton } from './src/components/Skeleton.astro';
22
- export { default as Progress } from './src/components/Progress.astro';
23
- export { default as EmptyState } from './src/components/EmptyState.astro';
24
- export { default as Accordion } from './src/components/Accordion.astro';
25
- export { default as AccordionItem } from './src/components/AccordionItem.astro';
26
- export { default as Breadcrumb } from './src/components/Breadcrumb.astro';
27
- export { default as Pagination } from './src/components/Pagination.astro';
28
- export { default as Divider } from './src/components/Divider.astro';
29
- export { default as Toaster } from './src/components/Toaster.astro';
30
- export { initModals, openModal, closeModal } from './src/modal.js';
31
- export { paginationRange } from './src/pagination.js';
1
+ // @directo-ui/astro — import components from here and '@directo-ui/astro/styles.css' once in your layout.
2
+ export { default as Button } from './src/components/Button.astro';
3
+ export { default as IconButton } from './src/components/IconButton.astro';
4
+ export { default as TextField } from './src/components/TextField.astro';
5
+ export { default as Textarea } from './src/components/Textarea.astro';
6
+ export { default as Select } from './src/components/Select.astro';
7
+ export { default as Checkbox } from './src/components/Checkbox.astro';
8
+ export { default as Switch } from './src/components/Switch.astro';
9
+ export { default as RadioGroup } from './src/components/RadioGroup.astro';
10
+ export { default as DatePicker } from './src/components/DatePicker.astro';
11
+ export { default as Card } from './src/components/Card.astro';
12
+ export { default as Badge } from './src/components/Badge.astro';
13
+ export { default as Alert } from './src/components/Alert.astro';
14
+ export { default as Avatar } from './src/components/Avatar.astro';
15
+ export { default as Modal } from './src/components/Modal.astro';
16
+ export { default as BottomSheet } from './src/components/BottomSheet.astro';
17
+ export { default as Tabs } from './src/components/Tabs.astro';
18
+ export { default as Tooltip } from './src/components/Tooltip.astro';
19
+ export { default as Dropdown } from './src/components/Dropdown.astro';
20
+ export { default as Spinner } from './src/components/Spinner.astro';
21
+ export { default as Skeleton } from './src/components/Skeleton.astro';
22
+ export { default as Progress } from './src/components/Progress.astro';
23
+ export { default as EmptyState } from './src/components/EmptyState.astro';
24
+ export { default as Accordion } from './src/components/Accordion.astro';
25
+ export { default as AccordionItem } from './src/components/AccordionItem.astro';
26
+ export { default as Breadcrumb } from './src/components/Breadcrumb.astro';
27
+ export { default as Pagination } from './src/components/Pagination.astro';
28
+ export { default as Divider } from './src/components/Divider.astro';
29
+ export { default as Toaster } from './src/components/Toaster.astro';
30
+ export { initModals, openModal, closeModal } from './src/modal.js';
31
+ export { paginationRange } from './src/pagination.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directo-ui/astro",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Componentes Astro del sistema de diseño Directo (HTML semántico, sin framework en el cliente)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -8,6 +8,26 @@
8
8
  "types": "./index.d.ts",
9
9
  "default": "./index.js"
10
10
  },
11
+ "./wari": {
12
+ "types": "./wari.d.ts",
13
+ "default": "./wari.js"
14
+ },
15
+ "./wari/client": {
16
+ "types": "./src/wari/multiselect.d.ts",
17
+ "default": "./src/wari/multiselect.js"
18
+ },
19
+ "./wari/pickers": {
20
+ "types": "./src/wari/pickers.d.ts",
21
+ "default": "./src/wari/pickers.js"
22
+ },
23
+ "./wari/trip": {
24
+ "types": "./src/wari/trip-client.d.ts",
25
+ "default": "./src/wari/trip-client.js"
26
+ },
27
+ "./wari/route": {
28
+ "types": "./src/wari/route-client.d.ts",
29
+ "default": "./src/wari/route-client.js"
30
+ },
11
31
  "./toast": {
12
32
  "types": "./src/toast.d.ts",
13
33
  "default": "./src/toast.js"
@@ -28,6 +48,8 @@
28
48
  "files": [
29
49
  "index.js",
30
50
  "index.d.ts",
51
+ "wari.js",
52
+ "wari.d.ts",
31
53
  "src",
32
54
  "styles.css",
33
55
  "tokens.css",
@@ -39,15 +61,15 @@
39
61
  "design-system",
40
62
  "directo"
41
63
  ],
42
- "scripts": {
43
- "build": "node ../../tokens/scripts/build-tokens.js && node ../../scripts/stage-astro-assets.mjs",
44
- "pack:dist": "corepack pnpm build && corepack pnpm pack --pack-destination ../../artifacts"
45
- },
46
64
  "peerDependencies": {
47
65
  "astro": ">=4.0.0"
48
66
  },
49
67
  "sideEffects": [
50
68
  "**/*.css"
51
69
  ],
52
- "license": "UNLICENSED"
53
- }
70
+ "license": "UNLICENSED",
71
+ "scripts": {
72
+ "build": "node ../../tokens/scripts/build-tokens.js && node ../../scripts/stage-astro-assets.mjs",
73
+ "pack:dist": "corepack pnpm build && corepack pnpm pack --pack-destination ../../artifacts"
74
+ }
75
+ }
@@ -1,8 +1,8 @@
1
- ---
2
- interface Props {
3
- variant?: 'default' | 'separated';
4
- }
5
-
6
- const { variant = 'default' } = Astro.props;
7
- ---
8
- <div class="ds-accordion" data-variant={variant}><slot /></div>
1
+ ---
2
+ interface Props {
3
+ variant?: 'default' | 'separated';
4
+ }
5
+
6
+ const { variant = 'default' } = Astro.props;
7
+ ---
8
+ <div class="ds-accordion" data-variant={variant}><slot /></div>
@@ -1,14 +1,14 @@
1
- ---
2
- interface Props {
3
- title: string;
4
- open?: boolean;
5
- /** Items sharing a name behave exclusively (one open at a time). */
6
- name?: string;
7
- }
8
-
9
- const { title, open = false, name } = Astro.props;
10
- ---
11
- <details class="ds-accordion-item" open={open} name={name}>
12
- <summary class="ds-accordion-trigger">{title}</summary>
13
- <div class="ds-accordion-content"><slot /></div>
14
- </details>
1
+ ---
2
+ interface Props {
3
+ title: string;
4
+ open?: boolean;
5
+ /** Items sharing a name behave exclusively (one open at a time). */
6
+ name?: string;
7
+ }
8
+
9
+ const { title, open = false, name } = Astro.props;
10
+ ---
11
+ <details class="ds-accordion-item" open={open} name={name}>
12
+ <summary class="ds-accordion-trigger">{title}</summary>
13
+ <div class="ds-accordion-content"><slot /></div>
14
+ </details>
@@ -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>