@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
@@ -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>
@@ -1,60 +1,60 @@
1
- ---
2
- export interface TabItem { value: string; label: string; disabled?: boolean }
3
- interface Props {
4
- /** Each item renders the slot with the same name as its value. */
5
- items: TabItem[];
6
- value?: string;
7
- label?: string;
8
- variant?: 'default' | 'pills' | 'enclosed';
9
- }
10
-
11
- const { items, value, label, variant = 'default' } = Astro.props;
12
- const active = value ?? items.find(item => !item.disabled)?.value;
13
- const base = `ds-tabs-${Math.random().toString(36).slice(2, 9)}`;
14
- const panels = await Promise.all(items.map(item => Astro.slots.render(item.value)));
15
- ---
16
- <div class="ds-tabs" data-ds-tabs>
17
- <div class="ds-tabs-list" role="tablist" aria-label={label} data-variant={variant}>
18
- {items.map(item => (
19
- <button type="button" class="ds-tab" role="tab" id={`${base}-${item.value}-tab`} aria-controls={`${base}-${item.value}-panel`}
20
- aria-selected={String(item.value === active)} tabindex={item.value === active ? 0 : -1} disabled={item.disabled}
21
- data-value={item.value}>{item.label}</button>
22
- ))}
23
- </div>
24
- {items.map((item, index) => (
25
- <div class="ds-tab-panel" role="tabpanel" tabindex="0" id={`${base}-${item.value}-panel`}
26
- aria-labelledby={`${base}-${item.value}-tab`} hidden={item.value !== active} set:html={panels[index]} />
27
- ))}
28
- </div>
29
-
30
- <script>
31
- function initTabs() {
32
- document.querySelectorAll<HTMLElement>('[data-ds-tabs]:not([data-ds-ready])').forEach(root => {
33
- root.dataset.dsReady = '';
34
- const tabs = [...root.querySelectorAll<HTMLButtonElement>(':scope > .ds-tabs-list > [role="tab"]')];
35
- const select = (tab: HTMLButtonElement, focus = false) => {
36
- for (const item of tabs) {
37
- const selected = item === tab;
38
- item.setAttribute('aria-selected', String(selected));
39
- item.tabIndex = selected ? 0 : -1;
40
- const panel = document.getElementById(item.getAttribute('aria-controls') ?? '');
41
- if (panel) panel.hidden = !selected;
42
- }
43
- if (focus) tab.focus();
44
- root.dispatchEvent(new CustomEvent('ds-change', { detail: tab.dataset.value, bubbles: true }));
45
- };
46
- tabs.forEach(tab => tab.addEventListener('click', () => select(tab)));
47
- root.querySelector(':scope > .ds-tabs-list')?.addEventListener('keydown', event => {
48
- const key = (event as KeyboardEvent).key;
49
- const enabled = tabs.filter(tab => !tab.disabled);
50
- const index = enabled.indexOf(document.activeElement as HTMLButtonElement);
51
- const next = { ArrowRight: index + 1, ArrowLeft: index - 1, Home: 0, End: enabled.length - 1 }[key];
52
- if (next === undefined || !enabled.length) return;
53
- event.preventDefault();
54
- select(enabled[(next + enabled.length) % enabled.length], true);
55
- });
56
- });
57
- }
58
- initTabs();
59
- document.addEventListener('astro:page-load', initTabs);
60
- </script>
1
+ ---
2
+ export interface TabItem { value: string; label: string; disabled?: boolean }
3
+ interface Props {
4
+ /** Each item renders the slot with the same name as its value. */
5
+ items: TabItem[];
6
+ value?: string;
7
+ label?: string;
8
+ variant?: 'default' | 'pills' | 'enclosed';
9
+ }
10
+
11
+ const { items, value, label, variant = 'default' } = Astro.props;
12
+ const active = value ?? items.find(item => !item.disabled)?.value;
13
+ const base = `ds-tabs-${Math.random().toString(36).slice(2, 9)}`;
14
+ const panels = await Promise.all(items.map(item => Astro.slots.render(item.value)));
15
+ ---
16
+ <div class="ds-tabs" data-ds-tabs>
17
+ <div class="ds-tabs-list" role="tablist" aria-label={label} data-variant={variant}>
18
+ {items.map(item => (
19
+ <button type="button" class="ds-tab" role="tab" id={`${base}-${item.value}-tab`} aria-controls={`${base}-${item.value}-panel`}
20
+ aria-selected={String(item.value === active)} tabindex={item.value === active ? 0 : -1} disabled={item.disabled}
21
+ data-value={item.value}>{item.label}</button>
22
+ ))}
23
+ </div>
24
+ {items.map((item, index) => (
25
+ <div class="ds-tab-panel" role="tabpanel" tabindex="0" id={`${base}-${item.value}-panel`}
26
+ aria-labelledby={`${base}-${item.value}-tab`} hidden={item.value !== active} set:html={panels[index]} />
27
+ ))}
28
+ </div>
29
+
30
+ <script>
31
+ function initTabs() {
32
+ document.querySelectorAll<HTMLElement>('[data-ds-tabs]:not([data-ds-ready])').forEach(root => {
33
+ root.dataset.dsReady = '';
34
+ const tabs = [...root.querySelectorAll<HTMLButtonElement>(':scope > .ds-tabs-list > [role="tab"]')];
35
+ const select = (tab: HTMLButtonElement, focus = false) => {
36
+ for (const item of tabs) {
37
+ const selected = item === tab;
38
+ item.setAttribute('aria-selected', String(selected));
39
+ item.tabIndex = selected ? 0 : -1;
40
+ const panel = document.getElementById(item.getAttribute('aria-controls') ?? '');
41
+ if (panel) panel.hidden = !selected;
42
+ }
43
+ if (focus) tab.focus();
44
+ root.dispatchEvent(new CustomEvent('ds-change', { detail: tab.dataset.value, bubbles: true }));
45
+ };
46
+ tabs.forEach(tab => tab.addEventListener('click', () => select(tab)));
47
+ root.querySelector(':scope > .ds-tabs-list')?.addEventListener('keydown', event => {
48
+ const key = (event as KeyboardEvent).key;
49
+ const enabled = tabs.filter(tab => !tab.disabled);
50
+ const index = enabled.indexOf(document.activeElement as HTMLButtonElement);
51
+ const next = { ArrowRight: index + 1, ArrowLeft: index - 1, Home: 0, End: enabled.length - 1 }[key];
52
+ if (next === undefined || !enabled.length) return;
53
+ event.preventDefault();
54
+ select(enabled[(next + enabled.length) % enabled.length], true);
55
+ });
56
+ });
57
+ }
58
+ initTabs();
59
+ document.addEventListener('astro:page-load', initTabs);
60
+ </script>
@@ -1,24 +1,24 @@
1
- ---
2
- import type { HTMLAttributes } from 'astro/types';
3
-
4
- interface Props extends Omit<HTMLAttributes<'input'>, 'size'> {
5
- label?: string;
6
- supportingText?: string;
7
- error?: boolean;
8
- size?: 'sm' | 'md' | 'lg';
9
- }
10
-
11
- const { label, supportingText, error = false, size = 'md', id, disabled = false, required = false, type = 'text', ...rest } = Astro.props;
12
- const fieldId = id ?? `ds-field-${Math.random().toString(36).slice(2, 9)}`;
13
- const hintId = supportingText ? `${fieldId}-hint` : undefined;
14
- ---
15
- <div class="ds-input" data-error={String(error)} data-disabled={String(Boolean(disabled))} data-size={size}>
16
- {label && <label for={fieldId}>{label}{required && <span class="ds-input-required" aria-hidden="true">*</span>}</label>}
17
- <div class="ds-input-shell">
18
- {Astro.slots.has('start') && <span class="ds-input-icon" aria-hidden="true"><slot name="start" /></span>}
19
- <input {...rest} id={fieldId} type={type} disabled={disabled} required={required}
20
- aria-invalid={error ? 'true' : undefined} aria-describedby={hintId} />
21
- {Astro.slots.has('end') && <span class="ds-input-icon" aria-hidden="true"><slot name="end" /></span>}
22
- </div>
23
- {supportingText && <small id={hintId}>{supportingText}</small>}
24
- </div>
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends Omit<HTMLAttributes<'input'>, 'size'> {
5
+ label?: string;
6
+ supportingText?: string;
7
+ error?: boolean;
8
+ size?: 'sm' | 'md' | 'lg';
9
+ }
10
+
11
+ const { label, supportingText, error = false, size = 'md', id, disabled = false, required = false, type = 'text', ...rest } = Astro.props;
12
+ const fieldId = id ?? `ds-field-${Math.random().toString(36).slice(2, 9)}`;
13
+ const hintId = supportingText ? `${fieldId}-hint` : undefined;
14
+ ---
15
+ <div class="ds-input" data-error={String(error)} data-disabled={String(Boolean(disabled))} data-size={size}>
16
+ {label && <label for={fieldId}>{label}{required && <span class="ds-input-required" aria-hidden="true">*</span>}</label>}
17
+ <div class="ds-input-shell">
18
+ {Astro.slots.has('start') && <span class="ds-input-icon" aria-hidden="true"><slot name="start" /></span>}
19
+ <input {...rest} id={fieldId} type={type} disabled={disabled} required={required}
20
+ aria-invalid={error ? 'true' : undefined} aria-describedby={hintId} />
21
+ {Astro.slots.has('end') && <span class="ds-input-icon" aria-hidden="true"><slot name="end" /></span>}
22
+ </div>
23
+ {supportingText && <small id={hintId}>{supportingText}</small>}
24
+ </div>
@@ -1,41 +1,41 @@
1
- ---
2
- import type { HTMLAttributes } from 'astro/types';
3
-
4
- interface Props extends HTMLAttributes<'textarea'> {
5
- label?: string;
6
- supportingText?: string;
7
- error?: boolean;
8
- /** Live character counter (requires maxlength). */
9
- showCount?: boolean;
10
- value?: string;
11
- }
12
-
13
- const { label, supportingText, error = false, showCount = false, id, disabled = false, required = false, rows = 4, maxlength, value = '', ...rest } = Astro.props;
14
- const fieldId = id ?? `ds-field-${Math.random().toString(36).slice(2, 9)}`;
15
- const hintId = supportingText ? `${fieldId}-hint` : undefined;
16
- ---
17
- <div class="ds-input" data-multiline="true" data-error={String(error)} data-disabled={String(Boolean(disabled))}>
18
- {label && <label for={fieldId}>{label}{required && <span class="ds-input-required" aria-hidden="true">*</span>}</label>}
19
- <div class="ds-input-shell">
20
- <textarea {...rest} id={fieldId} rows={rows} maxlength={maxlength} disabled={disabled} required={required}
21
- aria-invalid={error ? 'true' : undefined} aria-describedby={hintId} data-ds-count={showCount && maxlength ? '' : undefined}>{value}</textarea>
22
- </div>
23
- {(supportingText || (showCount && maxlength)) && (
24
- <span style="display:flex;justify-content:space-between;gap:12px">
25
- {supportingText ? <small id={hintId}>{supportingText}</small> : <span />}
26
- {showCount && maxlength && <span class="ds-input-counter" data-ds-counter-for={fieldId}>{value.length}/{maxlength}</span>}
27
- </span>
28
- )}
29
- </div>
30
-
31
- <script>
32
- function initCounters() {
33
- document.querySelectorAll<HTMLTextAreaElement>('textarea[data-ds-count]:not([data-ds-ready])').forEach(area => {
34
- area.dataset.dsReady = '';
35
- const counter = document.querySelector(`[data-ds-counter-for="${area.id}"]`);
36
- area.addEventListener('input', () => { if (counter) counter.textContent = `${area.value.length}/${area.maxLength}`; });
37
- });
38
- }
39
- initCounters();
40
- document.addEventListener('astro:page-load', initCounters);
41
- </script>
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'textarea'> {
5
+ label?: string;
6
+ supportingText?: string;
7
+ error?: boolean;
8
+ /** Live character counter (requires maxlength). */
9
+ showCount?: boolean;
10
+ value?: string;
11
+ }
12
+
13
+ const { label, supportingText, error = false, showCount = false, id, disabled = false, required = false, rows = 4, maxlength, value = '', ...rest } = Astro.props;
14
+ const fieldId = id ?? `ds-field-${Math.random().toString(36).slice(2, 9)}`;
15
+ const hintId = supportingText ? `${fieldId}-hint` : undefined;
16
+ ---
17
+ <div class="ds-input" data-multiline="true" data-error={String(error)} data-disabled={String(Boolean(disabled))}>
18
+ {label && <label for={fieldId}>{label}{required && <span class="ds-input-required" aria-hidden="true">*</span>}</label>}
19
+ <div class="ds-input-shell">
20
+ <textarea {...rest} id={fieldId} rows={rows} maxlength={maxlength} disabled={disabled} required={required}
21
+ aria-invalid={error ? 'true' : undefined} aria-describedby={hintId} data-ds-count={showCount && maxlength ? '' : undefined}>{value}</textarea>
22
+ </div>
23
+ {(supportingText || (showCount && maxlength)) && (
24
+ <span style="display:flex;justify-content:space-between;gap:12px">
25
+ {supportingText ? <small id={hintId}>{supportingText}</small> : <span />}
26
+ {showCount && maxlength && <span class="ds-input-counter" data-ds-counter-for={fieldId}>{value.length}/{maxlength}</span>}
27
+ </span>
28
+ )}
29
+ </div>
30
+
31
+ <script>
32
+ function initCounters() {
33
+ document.querySelectorAll<HTMLTextAreaElement>('textarea[data-ds-count]:not([data-ds-ready])').forEach(area => {
34
+ area.dataset.dsReady = '';
35
+ const counter = document.querySelector(`[data-ds-counter-for="${area.id}"]`);
36
+ area.addEventListener('input', () => { if (counter) counter.textContent = `${area.value.length}/${area.maxLength}`; });
37
+ });
38
+ }
39
+ initCounters();
40
+ document.addEventListener('astro:page-load', initCounters);
41
+ </script>
@@ -1,8 +1,8 @@
1
- ---
2
- interface Props {
3
- position?: 'bottom-right' | 'top-right' | 'top-center' | 'bottom-center';
4
- }
5
-
6
- const { position = 'bottom-right' } = Astro.props;
7
- ---
8
- <ol class="ds-toaster" data-position={position} aria-label="Notificaciones" data-ds-toaster></ol>
1
+ ---
2
+ interface Props {
3
+ position?: 'bottom-right' | 'top-right' | 'top-center' | 'bottom-center';
4
+ }
5
+
6
+ const { position = 'bottom-right' } = Astro.props;
7
+ ---
8
+ <ol class="ds-toaster" data-position={position} aria-label="Notificaciones" data-ds-toaster></ol>
@@ -1,31 +1,31 @@
1
- ---
2
- interface Props {
3
- text: string;
4
- position?: 'top' | 'bottom' | 'left' | 'right';
5
- /** Milliseconds before showing. */
6
- delay?: number;
7
- }
8
-
9
- const { text, position = 'top', delay = 250 } = Astro.props;
10
- const id = `ds-tip-${Math.random().toString(36).slice(2, 9)}`;
11
- ---
12
- <span class="ds-tooltip-wrap" style={`--ds-tooltip-delay:${delay}ms`} data-ds-tooltip={id}>
13
- <slot />
14
- <span class="ds-tooltip" role="tooltip" id={id} data-side={position}>{text}</span>
15
- </span>
16
-
17
- <script>
18
- function initTooltips() {
19
- document.querySelectorAll<HTMLElement>('[data-ds-tooltip]:not([data-ds-ready])').forEach(wrap => {
20
- wrap.dataset.dsReady = '';
21
- const trigger = wrap.querySelector('a, button, input, select, textarea, [tabindex]');
22
- if (trigger && !trigger.hasAttribute('aria-describedby')) trigger.setAttribute('aria-describedby', wrap.dataset.dsTooltip ?? '');
23
- wrap.addEventListener('keydown', event => { if (event.key === 'Escape') wrap.dataset.dismissed = 'true'; });
24
- const reset = () => delete wrap.dataset.dismissed;
25
- wrap.addEventListener('mouseleave', reset);
26
- wrap.addEventListener('focusout', reset);
27
- });
28
- }
29
- initTooltips();
30
- document.addEventListener('astro:page-load', initTooltips);
31
- </script>
1
+ ---
2
+ interface Props {
3
+ text: string;
4
+ position?: 'top' | 'bottom' | 'left' | 'right';
5
+ /** Milliseconds before showing. */
6
+ delay?: number;
7
+ }
8
+
9
+ const { text, position = 'top', delay = 250 } = Astro.props;
10
+ const id = `ds-tip-${Math.random().toString(36).slice(2, 9)}`;
11
+ ---
12
+ <span class="ds-tooltip-wrap" style={`--ds-tooltip-delay:${delay}ms`} data-ds-tooltip={id}>
13
+ <slot />
14
+ <span class="ds-tooltip" role="tooltip" id={id} data-side={position}>{text}</span>
15
+ </span>
16
+
17
+ <script>
18
+ function initTooltips() {
19
+ document.querySelectorAll<HTMLElement>('[data-ds-tooltip]:not([data-ds-ready])').forEach(wrap => {
20
+ wrap.dataset.dsReady = '';
21
+ const trigger = wrap.querySelector('a, button, input, select, textarea, [tabindex]');
22
+ if (trigger && !trigger.hasAttribute('aria-describedby')) trigger.setAttribute('aria-describedby', wrap.dataset.dsTooltip ?? '');
23
+ wrap.addEventListener('keydown', event => { if (event.key === 'Escape') wrap.dataset.dismissed = 'true'; });
24
+ const reset = () => delete wrap.dataset.dismissed;
25
+ wrap.addEventListener('mouseleave', reset);
26
+ wrap.addEventListener('focusout', reset);
27
+ });
28
+ }
29
+ initTooltips();
30
+ document.addEventListener('astro:page-load', initTooltips);
31
+ </script>
@@ -0,0 +1,87 @@
1
+ ---
2
+ interface Props {
3
+ /** Nombre del cliente; se recorta con "…" y el texto completo queda en `title`. */
4
+ name: string;
5
+ company?: string;
6
+ /** Teléfono: se muestra como enlace `tel:`. */
7
+ phone?: string;
8
+ /** Cliente VIP: franja amarilla. vip={false}: franja celeste ("sin VIP" en Figma). */
9
+ vip?: boolean;
10
+ /** Color de la ficha a mano; si no se indica, lo decide `vip` (por defecto amarillo). */
11
+ tone?: 'warning' | 'info' | 'neutral';
12
+ showRates?: boolean;
13
+ showInfo?: boolean;
14
+ showEdit?: boolean;
15
+ ratesLabel?: string;
16
+ infoLabel?: string;
17
+ editLabel?: string;
18
+ /** Observaciones de solo lectura. */
19
+ notes?: string;
20
+ notesLabel?: string;
21
+ notesHint?: string;
22
+ disabled?: boolean;
23
+ class?: string;
24
+ }
25
+
26
+ const {
27
+ name, company, phone, vip, tone, showRates = true, showInfo = true, showEdit = true, ratesLabel = 'Tarifas',
28
+ infoLabel = 'Ver información del cliente', editLabel = 'Editar cliente', notes, notesLabel = 'Observaciones del cliente',
29
+ notesHint = '(no editable)', disabled = false, class: className,
30
+ } = Astro.props;
31
+ const hasFields = Astro.slots.has('default');
32
+ const bannerTone = tone ?? (vip === false ? 'info' : 'warning');
33
+ ---
34
+ <div class:list={['ds-wclient-details', className]} data-ds-wclient-details>
35
+ <div class="ds-wclient-summary">
36
+ <div class="ds-wclient-banner" data-tone={bannerTone}>
37
+ <p class="ds-wclient-name" title={name}>{name}</p>
38
+ {company && <span class="ds-wclient-company" title={company}>{company}</span>}
39
+ {phone && (
40
+ <a class="ds-wclient-phone" href={`tel:${phone.replace(/[^\d+]/g, '')}`}>
41
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 3.5h3.2l1.6 4-2 1.3a10.5 10.5 0 0 0 5.4 5.4l1.3-2 4 1.6V17a2 2 0 0 1-2 2A15.5 15.5 0 0 1 3 5.5a2 2 0 0 1 2-2Z"/></svg>{phone}
42
+ </a>
43
+ )}
44
+ </div>
45
+ {(showRates || showInfo || showEdit) && (
46
+ <div class="ds-wclient-actions">
47
+ {showRates && <button type="button" class="ds-wclient-rates" data-ds-action="rates" disabled={disabled}>{ratesLabel}</button>}
48
+ {(showInfo || showEdit) && (
49
+ <div>
50
+ {showInfo && (
51
+ <button type="button" class="ds-wclient-icon" data-ds-action="info" aria-label={infoLabel} title={infoLabel} disabled={disabled}>
52
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="12" r="9" fill="currentColor" stroke="none"/><path d="M12 11v5.5M12 7.6v.1" stroke="#fff" stroke-width="2.4"/></svg>
53
+ </button>
54
+ )}
55
+ {showEdit && (
56
+ <button type="button" class="ds-wclient-icon" data-ds-action="edit" aria-label={editLabel} title={editLabel} disabled={disabled}>
57
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M4 20h4.5L19 9.5 14.5 5 4 15.5z" fill="currentColor" stroke="none"/><path d="M13 20h7"/></svg>
58
+ </button>
59
+ )}
60
+ </div>
61
+ )}
62
+ </div>
63
+ )}
64
+ </div>
65
+ {hasFields && <div class="ds-wclient-fields"><slot /></div>}
66
+ {notes != null && (
67
+ <div class="ds-wclient-notes">
68
+ <span>{notesLabel} <em>{notesHint}</em></span>
69
+ <p>{notes}</p>
70
+ </div>
71
+ )}
72
+ </div>
73
+
74
+ <script>
75
+ // Emits on the details element: "ds-rates", "ds-info" and "ds-edit".
76
+ function initClientDetails() {
77
+ document.querySelectorAll<HTMLElement>('[data-ds-wclient-details]:not([data-ds-ready])').forEach(root => {
78
+ root.dataset.dsReady = '';
79
+ root.addEventListener('click', event => {
80
+ const action = (event.target as Element).closest<HTMLElement>('[data-ds-action]')?.dataset.dsAction;
81
+ if (action) root.dispatchEvent(new CustomEvent(`ds-${action}`, { bubbles: true }));
82
+ });
83
+ });
84
+ }
85
+ initClientDetails();
86
+ document.addEventListener('astro:page-load', initClientDetails);
87
+ </script>