@dubix/ui 0.10.0 → 0.12.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 (44) hide show
  1. package/README.md +496 -15
  2. package/dist/checkbox/Checkbox.d.ts +61 -0
  3. package/dist/checkbox/Checkbox.js +41 -0
  4. package/dist/checkbox/index.d.ts +2 -0
  5. package/dist/checkbox/index.js +1 -0
  6. package/dist/filter-bar/AppliedFilters.d.ts +41 -0
  7. package/dist/filter-bar/AppliedFilters.js +123 -0
  8. package/dist/filter-bar/FilterAmountRange.d.ts +27 -0
  9. package/dist/filter-bar/FilterAmountRange.js +86 -0
  10. package/dist/filter-bar/FilterBar.d.ts +32 -0
  11. package/dist/filter-bar/FilterBar.js +21 -0
  12. package/dist/filter-bar/FilterOptions.d.ts +71 -0
  13. package/dist/filter-bar/FilterOptions.js +181 -0
  14. package/dist/filter-bar/FilterPanel.d.ts +63 -0
  15. package/dist/filter-bar/FilterPanel.js +50 -0
  16. package/dist/filter-bar/FilterPeriod.d.ts +25 -0
  17. package/dist/filter-bar/FilterPeriod.js +71 -0
  18. package/dist/filter-bar/FilterSearch.d.ts +54 -0
  19. package/dist/filter-bar/FilterSearch.js +100 -0
  20. package/dist/filter-bar/FilterToggle.d.ts +16 -0
  21. package/dist/filter-bar/FilterToggle.js +24 -0
  22. package/dist/filter-bar/format.d.ts +53 -0
  23. package/dist/filter-bar/format.js +104 -0
  24. package/dist/filter-bar/index.d.ts +18 -0
  25. package/dist/filter-bar/index.js +9 -0
  26. package/dist/pagination/Pagination.d.ts +13 -8
  27. package/dist/pagination/Pagination.js +8 -3
  28. package/dist/popover/Popover.d.ts +65 -0
  29. package/dist/popover/Popover.js +87 -0
  30. package/dist/popover/index.d.ts +2 -0
  31. package/dist/popover/index.js +1 -0
  32. package/dist/search-input/SearchInput.d.ts +4 -2
  33. package/dist/search-input/SearchInput.js +5 -3
  34. package/dist/select/Select.d.ts +5 -1
  35. package/dist/select/Select.js +2 -2
  36. package/dist/select/index.d.ts +1 -1
  37. package/dist/skip-link/SkipLink.d.ts +11 -0
  38. package/dist/skip-link/SkipLink.js +9 -0
  39. package/dist/skip-link/index.d.ts +2 -0
  40. package/dist/skip-link/index.js +1 -0
  41. package/dist/styles.css +955 -68
  42. package/dist/tooltip/Tooltip.d.ts +6 -1
  43. package/dist/tooltip/Tooltip.js +5 -4
  44. package/package.json +17 -1
@@ -0,0 +1,53 @@
1
+ /** Un período con nombre (la clave de un preset); la app calcula qué fechas son. */
2
+ export interface FilterPeriodPresetValue {
3
+ preset: string;
4
+ }
5
+ /** Un rango de fechas en ISO (aaaa-mm-dd). Puede faltar una punta: solo `from` es «desde», solo `to` es «hasta». */
6
+ export interface FilterPeriodRangeValue {
7
+ from?: string | undefined;
8
+ to?: string | undefined;
9
+ }
10
+ /** Valor de FilterPeriod: un período con nombre, un rango o nada. */
11
+ export type FilterPeriodValue = FilterPeriodPresetValue | FilterPeriodRangeValue | null;
12
+ /** Un período de la lista. */
13
+ export interface FilterPeriodPreset {
14
+ value: string;
15
+ label: string;
16
+ }
17
+ /** Los períodos por defecto de FilterPeriod, en este orden. */
18
+ export declare const FILTER_PERIOD_PRESETS: readonly FilterPeriodPreset[];
19
+ /** Valor de FilterAmountRange: importe mínimo y máximo (puede faltar uno) o nada. */
20
+ export type FilterAmountRangeValue = {
21
+ min?: number | undefined;
22
+ max?: number | undefined;
23
+ } | null;
24
+ /** El valor es un período con nombre. */
25
+ export declare const isPeriodPreset: (value: FilterPeriodValue) => value is FilterPeriodPresetValue;
26
+ /** aaaa-mm-dd → dd/mm/aaaa, sin pasar por Date (sin husos horarios). Un texto que no es una fecha ISO queda igual. */
27
+ export declare function formatDate(iso: string): string;
28
+ /**
29
+ * Texto de un período para el chip o la URL: el nombre del período («Mes actual»; si la clave no está en `presets`, la
30
+ * clave), o el rango: «01/11/2026 al 15/11/2026», «desde el 01/11/2026» o «hasta el 15/11/2026». Sin valor, `''`.
31
+ */
32
+ export declare function formatPeriod(value: FilterPeriodValue, presets?: readonly FilterPeriodPreset[]): string;
33
+ /**
34
+ * Interno (no está en el index): el resumen de varios valores de FilterChip y FilterField. Los primeros `max` separados
35
+ * por coma y, si hay más, « y N más»: «Mayorista, Distribuidor y 2 más». Sin valores, `''`.
36
+ */
37
+ export declare function summarizeValues(values: readonly string[], max?: number): string;
38
+ /**
39
+ * Importe con el formato de los campos: punto de miles, coma decimal y siempre dos decimales, sin el signo $
40
+ * (1234.5 → «1.234,50»; -1000 → «-1.000,00»). Redondea a centavos.
41
+ */
42
+ export declare function formatAmount(amount: number): string;
43
+ /**
44
+ * Texto de un rango de importes para el chip o la URL: «$ 1.000 a $ 5.000», «desde $ 1.000» o «hasta $ 5.000». Los centavos
45
+ * solo se muestran si hay («$ 1.234,50»). Sin valor (o sin ninguna punta), `''`.
46
+ */
47
+ export declare function formatAmountRange(value: FilterAmountRangeValue): string;
48
+ /**
49
+ * Lee un importe escrito en formato es-AR, con o sin puntos de miles: «1.234,5», «1234,50», «1.234.567,89», «-1.000».
50
+ * Acepta un «$» adelante y espacios. Un punto nunca es decimal: «12.34» no es un importe (los puntos van en grupos de 3), y
51
+ * más de dos decimales tampoco («1,234»). Devuelve el número, o `null` si el texto está vacío o no es un importe.
52
+ */
53
+ export declare function parseAmount(text: string): number | null;
@@ -0,0 +1,104 @@
1
+ // Funciones puras, sin hooks ni 'use client': la app las usa para el texto del chip y de la URL, también en el servidor.
2
+ // Formato es-AR sin Intl: fechas dd/mm/aaaa e importes con punto de miles y coma decimal ($ 1.234.567,89).
3
+ /** Los períodos por defecto de FilterPeriod, en este orden. */
4
+ export const FILTER_PERIOD_PRESETS = [
5
+ { value: 'hoy', label: 'Hoy' },
6
+ { value: 'semana-actual', label: 'Semana actual' },
7
+ { value: 'mes-actual', label: 'Mes actual' },
8
+ { value: 'anio-actual', label: 'Año actual' },
9
+ { value: 'ultimos-7-dias', label: 'Últimos 7 días' },
10
+ { value: 'ultimo-mes', label: 'Último mes' },
11
+ { value: 'ultimos-3-meses', label: 'Últimos 3 meses' },
12
+ { value: 'ultimo-anio', label: 'Último año' },
13
+ ];
14
+ /** El valor es un período con nombre. */
15
+ export const isPeriodPreset = (value) => value !== null && 'preset' in value;
16
+ const ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
17
+ /** aaaa-mm-dd → dd/mm/aaaa, sin pasar por Date (sin husos horarios). Un texto que no es una fecha ISO queda igual. */
18
+ export function formatDate(iso) {
19
+ const m = ISO_DATE.exec(iso);
20
+ if (!m)
21
+ return iso;
22
+ const [, y = '', mo = '', d = ''] = m;
23
+ return d + '/' + mo + '/' + y;
24
+ }
25
+ /**
26
+ * Texto de un período para el chip o la URL: el nombre del período («Mes actual»; si la clave no está en `presets`, la
27
+ * clave), o el rango: «01/11/2026 al 15/11/2026», «desde el 01/11/2026» o «hasta el 15/11/2026». Sin valor, `''`.
28
+ */
29
+ export function formatPeriod(value, presets = FILTER_PERIOD_PRESETS) {
30
+ if (value === null)
31
+ return '';
32
+ if (isPeriodPreset(value))
33
+ return presets.find((p) => p.value === value.preset)?.label ?? value.preset;
34
+ const from = value.from ? formatDate(value.from) : '';
35
+ const to = value.to ? formatDate(value.to) : '';
36
+ if (from && to)
37
+ return from + ' al ' + to;
38
+ if (from)
39
+ return 'desde el ' + from;
40
+ if (to)
41
+ return 'hasta el ' + to;
42
+ return '';
43
+ }
44
+ /**
45
+ * Interno (no está en el index): el resumen de varios valores de FilterChip y FilterField. Los primeros `max` separados
46
+ * por coma y, si hay más, « y N más»: «Mayorista, Distribuidor y 2 más». Sin valores, `''`.
47
+ */
48
+ export function summarizeValues(values, max = 2) {
49
+ const limit = Math.max(1, Math.floor(max));
50
+ const extra = Math.max(values.length - limit, 0);
51
+ return values.slice(0, limit).join(', ') + (extra > 0 ? ' y ' + String(extra) + ' más' : '');
52
+ }
53
+ /** Miles con punto: 1234567 → «1.234.567». */
54
+ const groupThousands = (digits) => digits.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
55
+ /**
56
+ * Importe con el formato de los campos: punto de miles, coma decimal y siempre dos decimales, sin el signo $
57
+ * (1234.5 → «1.234,50»; -1000 → «-1.000,00»). Redondea a centavos.
58
+ */
59
+ export function formatAmount(amount) {
60
+ const [int = '0', dec = '00'] = Math.abs(amount).toFixed(2).split('.');
61
+ const negative = amount < 0 && Number(int + dec) !== 0;
62
+ return (negative ? '-' : '') + groupThousands(int) + ',' + dec;
63
+ }
64
+ /** Importe con signo $ y los centavos solo si hay: «$ 1.000», «$ 1.234,50», «-$ 1.000». */
65
+ function formatMoney(amount) {
66
+ const text = formatAmount(amount);
67
+ const negative = text.startsWith('-');
68
+ const body = (negative ? text.slice(1) : text).replace(/,00$/, '');
69
+ return (negative ? '-' : '') + '$ ' + body;
70
+ }
71
+ /**
72
+ * Texto de un rango de importes para el chip o la URL: «$ 1.000 a $ 5.000», «desde $ 1.000» o «hasta $ 5.000». Los centavos
73
+ * solo se muestran si hay («$ 1.234,50»). Sin valor (o sin ninguna punta), `''`.
74
+ */
75
+ export function formatAmountRange(value) {
76
+ if (value === null)
77
+ return '';
78
+ const { min, max } = value;
79
+ const hasMin = min !== undefined && Number.isFinite(min);
80
+ const hasMax = max !== undefined && Number.isFinite(max);
81
+ if (hasMin && hasMax)
82
+ return formatMoney(min) + ' a ' + formatMoney(max);
83
+ if (hasMin)
84
+ return 'desde ' + formatMoney(min);
85
+ if (hasMax)
86
+ return 'hasta ' + formatMoney(max);
87
+ return '';
88
+ }
89
+ /** Un importe es-AR: signo opcional, miles con punto (en grupos de 3) o sin puntos, y hasta dos decimales con coma. */
90
+ const AMOUNT = /^(-)?(\d{1,3}(?:\.\d{3})+|\d+)(?:,(\d{1,2}))?$/;
91
+ /**
92
+ * Lee un importe escrito en formato es-AR, con o sin puntos de miles: «1.234,5», «1234,50», «1.234.567,89», «-1.000».
93
+ * Acepta un «$» adelante y espacios. Un punto nunca es decimal: «12.34» no es un importe (los puntos van en grupos de 3), y
94
+ * más de dos decimales tampoco («1,234»). Devuelve el número, o `null` si el texto está vacío o no es un importe.
95
+ */
96
+ export function parseAmount(text) {
97
+ const clean = text.replace(/\s+/g, '').replace(/^(-?)\$/, '$1').replace(/^\$(-)/, '$1').replace(/^−/, '-');
98
+ const m = AMOUNT.exec(clean);
99
+ if (!m)
100
+ return null;
101
+ const [, sign, int = '', dec = ''] = m;
102
+ const n = Number(int.replace(/\./g, '') + (dec ? '.' + dec : ''));
103
+ return sign && n !== 0 ? -n : n;
104
+ }
@@ -0,0 +1,18 @@
1
+ export { FilterBar, FilterButton } from './FilterBar.js';
2
+ export type { FilterBarProps, FilterButtonProps } from './FilterBar.js';
3
+ export { FilterToggle } from './FilterToggle.js';
4
+ export type { FilterToggleProps } from './FilterToggle.js';
5
+ export { AppliedFilters, FilterChip } from './AppliedFilters.js';
6
+ export { FilterOptions } from './FilterOptions.js';
7
+ export { FilterField, FilterPanel, FilterPanelSection } from './FilterPanel.js';
8
+ export type { FilterFieldProps, FilterPanelProps, FilterPanelSectionProps } from './FilterPanel.js';
9
+ export { FilterSearch } from './FilterSearch.js';
10
+ export type { FilterSearchLoader, FilterSearchMultipleProps, FilterSearchProps, FilterSearchSingleProps } from './FilterSearch.js';
11
+ export { FilterPeriod } from './FilterPeriod.js';
12
+ export type { FilterPeriodProps } from './FilterPeriod.js';
13
+ export { FilterAmountRange } from './FilterAmountRange.js';
14
+ export type { FilterAmountRangeProps } from './FilterAmountRange.js';
15
+ export { FILTER_PERIOD_PRESETS, formatAmount, formatAmountRange, formatDate, formatPeriod, isPeriodPreset, parseAmount } from './format.js';
16
+ export type { FilterAmountRangeValue, FilterPeriodPreset, FilterPeriodPresetValue, FilterPeriodRangeValue, FilterPeriodValue } from './format.js';
17
+ export type { FilterOption, FilterOptionsMultipleProps, FilterOptionsProps, FilterOptionsSingleProps } from './FilterOptions.js';
18
+ export type { AppliedFiltersProps, FilterChipProps } from './AppliedFilters.js';
@@ -0,0 +1,9 @@
1
+ export { FilterBar, FilterButton } from './FilterBar.js';
2
+ export { FilterToggle } from './FilterToggle.js';
3
+ export { AppliedFilters, FilterChip } from './AppliedFilters.js';
4
+ export { FilterOptions } from './FilterOptions.js';
5
+ export { FilterField, FilterPanel, FilterPanelSection } from './FilterPanel.js';
6
+ export { FilterSearch } from './FilterSearch.js';
7
+ export { FilterPeriod } from './FilterPeriod.js';
8
+ export { FilterAmountRange } from './FilterAmountRange.js';
9
+ export { FILTER_PERIOD_PRESETS, formatAmount, formatAmountRange, formatDate, formatPeriod, isPeriodPreset, parseAmount } from './format.js';
@@ -1,4 +1,4 @@
1
- import type { ComponentPropsWithRef } from 'react';
1
+ import { type ComponentPropsWithRef } from 'react';
2
2
  /** Un lugar de la fila de páginas: un número de página (1-based) o el «…» de las que faltan. */
3
3
  export type PaginationItem = number | 'ellipsis';
4
4
  /** `onChange` de HTML queda fuera para no confundirlo con `onPageChange`; los hijos los arma el componente. */
@@ -13,6 +13,17 @@ export interface PaginationProps extends Omit<ComponentPropsWithRef<'nav'>, 'chi
13
13
  onPageChange: (page: number) => void;
14
14
  /** Qué se cuenta, en plural («empresas»): va al final del rango («51–75 de 312 empresas»). */
15
15
  itemLabel?: string | undefined;
16
+ /** Lo mismo en singular («empresa»): con `total` 1, el rango dice «1 empresa» en vez de «1–1 de 1 empresas». */
17
+ itemLabelSingular?: string | undefined;
18
+ /**
19
+ * Con `onPageSizeChange`, al lado del rango va «Filas por página» con un Select sm. Recibe las filas elegidas; la pantalla
20
+ * vuelve a la página 1. Sin `onPageSizeChange`, Pagination queda como siempre.
21
+ */
22
+ onPageSizeChange?: ((pageSize: number) => void) | undefined;
23
+ /** Las opciones de filas por página. Por defecto 25, 50 y 100 (si `pageSize` no está, se suma). */
24
+ pageSizeOptions?: readonly number[] | undefined;
25
+ /** Texto al lado del Select. Por defecto «Filas por página». */
26
+ pageSizeLabel?: string | undefined;
16
27
  }
17
28
  /**
18
29
  * Las páginas a mostrar: siempre la primera y la última, la actual y una a cada lado, y «…» donde faltan; nunca más de 7
@@ -20,10 +31,4 @@ export interface PaginationProps extends Omit<ComponentPropsWithRef<'nav'>, 'chi
20
31
  * 5 → 1 … 4 5 6 … 10; en la 10 → 1 … 6 7 8 9 10.
21
32
  */
22
33
  export declare function paginationRange(page: number, pageCount: number): PaginationItem[];
23
- /**
24
- * Pie de una tabla con paginación del servidor: el rango («51–75 de 312 empresas») a la izquierda y Anterior, las páginas y
25
- * Siguiente a la derecha, en una fila de 44px. En un contenedor de menos de 480px las páginas se reemplazan por «3 de 13».
26
- * No guarda estado: la página la tiene la pantalla. `className` se suma a `dx-pagination`; `ref` y el resto de las props
27
- * van al `<nav>`.
28
- */
29
- export declare function Pagination({ page, pageSize, total, onPageChange, itemLabel, className, 'aria-label': ariaLabel, ...rest }: PaginationProps): import("react").JSX.Element | null;
34
+ export declare function Pagination({ page, pageSize, total, onPageChange, itemLabel, itemLabelSingular, onPageSizeChange, pageSizeOptions, pageSizeLabel, className, 'aria-label': ariaLabel, ...rest }: PaginationProps): import("react").JSX.Element | null;
@@ -1,5 +1,7 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from 'react';
2
3
  import { Button } from '../button/index.js';
4
+ import { Select, SelectItem } from '../select/index.js';
3
5
  /** Cantidad máxima de lugares en la fila de páginas (números y «…»). */
4
6
  const MAX_ITEMS = 7;
5
7
  const numberFormat = new Intl.NumberFormat('es-AR');
@@ -30,7 +32,10 @@ const Chevron = ({ d }) => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", st
30
32
  * No guarda estado: la página la tiene la pantalla. `className` se suma a `dx-pagination`; `ref` y el resto de las props
31
33
  * van al `<nav>`.
32
34
  */
33
- export function Pagination({ page, pageSize, total, onPageChange, itemLabel, className, 'aria-label': ariaLabel = 'Paginación', ...rest }) {
35
+ /** Las filas por página por defecto. */
36
+ const PAGE_SIZE_OPTIONS = [25, 50, 100];
37
+ export function Pagination({ page, pageSize, total, onPageChange, itemLabel, itemLabelSingular, onPageSizeChange, pageSizeOptions = PAGE_SIZE_OPTIONS, pageSizeLabel = 'Filas por página', className, 'aria-label': ariaLabel = 'Paginación', ...rest }) {
38
+ const sizeLabelId = useId();
34
39
  // TypeScript no lo frena (es un number); un error claro en vez de un rango con NaN o Infinity.
35
40
  if (!(pageSize > 0) || !Number.isFinite(pageSize))
36
41
  throw new Error('Pagination: pageSize tiene que ser un número mayor que 0 (recibió ' + String(pageSize) + ').');
@@ -43,5 +48,5 @@ export function Pagination({ page, pageSize, total, onPageChange, itemLabel, cla
43
48
  const go = (target) => () => { onPageChange(target); };
44
49
  const first = current === 1;
45
50
  const last = current === pageCount;
46
- return (_jsxs("nav", { ...rest, "aria-label": ariaLabel, className: className ? `dx-pagination ${className}` : 'dx-pagination', children: [_jsxs("p", { className: "dx-pagination__range", "aria-live": "polite", "aria-atomic": "true", children: [fmt(from), "\u2013", fmt(to), " de ", fmt(total), itemLabel ? ' ' + itemLabel : null] }), pageCount > 1 && (_jsxs("div", { className: "dx-pagination__controls", children: [_jsx(Button, { variant: "ghost", size: "sm", className: "dx-pagination__step", "data-step": "prev", iconStart: _jsx(Chevron, { d: "m15 18-6-6 6-6" }), "aria-disabled": first ? true : undefined, onClick: first ? undefined : go(current - 1), children: _jsx("span", { className: "dx-pagination__label", children: "Anterior" }) }), _jsx("span", { className: "dx-pagination__pages", children: paginationRange(current, pageCount).map((item, i) => item === 'ellipsis' ? (_jsx("span", { className: "dx-pagination__ellipsis", "aria-hidden": "true", children: "\u2026" }, i < 3 ? 'ellipsis-start' : 'ellipsis-end')) : (_jsx(Button, { variant: "ghost", size: "sm", className: "dx-pagination__page", "aria-label": 'Página ' + String(item), "aria-current": item === current ? 'page' : undefined, onClick: item === current ? undefined : go(item), children: fmt(item) }, item))) }), _jsxs("span", { className: "dx-pagination__status", children: [fmt(current), " de ", fmt(pageCount)] }), _jsx(Button, { variant: "ghost", size: "sm", className: "dx-pagination__step", "data-step": "next", iconEnd: _jsx(Chevron, { d: "m9 18 6-6-6-6" }), "aria-disabled": last ? true : undefined, onClick: last ? undefined : go(current + 1), children: _jsx("span", { className: "dx-pagination__label", children: "Siguiente" }) })] }))] }));
51
+ return (_jsxs("nav", { ...rest, "aria-label": ariaLabel, className: className ? `dx-pagination ${className}` : 'dx-pagination', children: [_jsx("p", { className: "dx-pagination__range", "aria-live": "polite", "aria-atomic": "true", children: total === 1 && itemLabelSingular ? '1 ' + itemLabelSingular : _jsxs(_Fragment, { children: [fmt(from), "\u2013", fmt(to), " de ", fmt(total), itemLabel ? ' ' + itemLabel : null] }) }), onPageSizeChange && (_jsxs("div", { className: "dx-pagination__size", children: [_jsx("span", { className: "dx-pagination__size-label", id: sizeLabelId, children: pageSizeLabel }), _jsx(Select, { size: "sm", className: "dx-pagination__size-select", "aria-labelledby": sizeLabelId, value: String(pageSize), onValueChange: (next) => { onPageSizeChange(Number(next)); }, children: [...new Set([...pageSizeOptions, pageSize])].sort((a, b) => a - b).map((n) => (_jsx(SelectItem, { value: String(n), children: fmt(n) }, n))) })] })), pageCount > 1 && (_jsxs("div", { className: "dx-pagination__controls", children: [_jsx(Button, { variant: "ghost", size: "sm", className: "dx-pagination__step", "data-step": "prev", iconStart: _jsx(Chevron, { d: "m15 18-6-6 6-6" }), "aria-disabled": first ? true : undefined, onClick: first ? undefined : go(current - 1), children: _jsx("span", { className: "dx-pagination__label", children: "Anterior" }) }), _jsx("span", { className: "dx-pagination__pages", children: paginationRange(current, pageCount).map((item, i) => item === 'ellipsis' ? (_jsx("span", { className: "dx-pagination__ellipsis", "aria-hidden": "true", children: "\u2026" }, i < 3 ? 'ellipsis-start' : 'ellipsis-end')) : (_jsx(Button, { variant: "ghost", size: "sm", className: "dx-pagination__page", "aria-label": 'Página ' + String(item), "aria-current": item === current ? 'page' : undefined, onClick: item === current ? undefined : go(item), children: fmt(item) }, item))) }), _jsxs("span", { className: "dx-pagination__status", children: [fmt(current), " de ", fmt(pageCount)] }), _jsx(Button, { variant: "ghost", size: "sm", className: "dx-pagination__step", "data-step": "next", iconEnd: _jsx(Chevron, { d: "m9 18 6-6-6-6" }), "aria-disabled": last ? true : undefined, onClick: last ? undefined : go(current + 1), children: _jsx("span", { className: "dx-pagination__label", children: "Siguiente" }) })] }))] }));
47
52
  }
@@ -0,0 +1,65 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ /** Lado del disparador (o del ancla) donde se abre el popover (si no entra, Radix lo da vuelta). */
3
+ export type PopoverSide = 'top' | 'right' | 'bottom' | 'left';
4
+ /** Alineación contra el disparador (o el ancla), sobre el lado elegido. */
5
+ export type PopoverAlign = 'start' | 'center' | 'end';
6
+ export interface PopoverProps {
7
+ children: ReactNode;
8
+ /** Abierto (controlado). Sin `open`, el popover maneja su propio estado. */
9
+ open?: boolean | undefined;
10
+ /** Abierto al montar (no controlado). */
11
+ defaultOpen?: boolean | undefined;
12
+ onOpenChange?: ((open: boolean) => void) | undefined;
13
+ }
14
+ export interface PopoverTriggerProps {
15
+ /** Un único elemento focalizable (un `<button>`, un Button): recibe los eventos, `aria-haspopup`, `aria-expanded` y `data-state`. */
16
+ children: ReactElement;
17
+ }
18
+ export interface PopoverAnchorProps {
19
+ /** Un único elemento: el popover se posiciona contra él y no contra el disparador (p. ej. el chip de un filtro aplicado). */
20
+ children: ReactElement;
21
+ }
22
+ export interface PopoverContentProps {
23
+ children: ReactNode;
24
+ /** Por defecto `bottom`. */
25
+ side?: PopoverSide | undefined;
26
+ /** Por defecto `start`. */
27
+ align?: PopoverAlign | undefined;
28
+ /** Separación del disparador, en px. Por defecto 6 (`--dx-space-1_5`), la de DropdownMenu. */
29
+ sideOffset?: number | undefined;
30
+ /** Ancho: número en px o string CSS. Sin `width`, el del contenido, con el mínimo del menú (`--dx-size-menu-min`). Nunca más ancho que la ventana. */
31
+ width?: number | string | undefined;
32
+ /** Como mínimo, el ancho del disparador (o del ancla), p. ej. el popover de un campo del panel de filtros. */
33
+ matchTriggerWidth?: boolean | undefined;
34
+ /** Nombre del diálogo para lectores de pantalla (p. ej. «Período»), si no lo nombra un título visible con `aria-labelledby`. */
35
+ 'aria-label'?: string | undefined;
36
+ 'aria-labelledby'?: string | undefined;
37
+ /** Se suma a `dx-popover`. */
38
+ className?: string | undefined;
39
+ }
40
+ export interface PopoverCloseProps {
41
+ /** Un único elemento focalizable (un `<button>`, un Button): al hacer clic, cierra el popover. */
42
+ children: ReactElement;
43
+ }
44
+ /**
45
+ * Raíz del popover (Radix Popover, no modal). Guarda el disparador y el ancla para montar el contenido en el ancestro que fija
46
+ * el tema; el foco, el teclado, el cierre y el posicionamiento son los de Radix.
47
+ */
48
+ export declare function Popover({ children, open, defaultOpen, onOpenChange }: PopoverProps): import("react").JSX.Element;
49
+ /**
50
+ * Interno (no está en el index de la entrada): cierra el Popover que envuelve al componente, o null fuera de un Popover. Lo
51
+ * usa FilterOptions para cerrar al elegir una opción de un valor; el foco vuelve a lo que abrió el popover, como con Esc.
52
+ */
53
+ export declare function usePopoverClose(): (() => void) | null;
54
+ /** Disparador: le pasa los eventos y los atributos de Radix a su único hijo (`asChild`), sin agregar nada alrededor. */
55
+ export declare function PopoverTrigger({ children }: PopoverTriggerProps): import("react").JSX.Element;
56
+ /** Ancla: el popover se posiciona contra su único hijo en lugar del disparador. No agrega nada alrededor. */
57
+ export declare function PopoverAnchor({ children }: PopoverAnchorProps): import("react").JSX.Element;
58
+ /** Cierra el popover al hacer clic en su único hijo (`asChild`). */
59
+ export declare function PopoverClose({ children }: PopoverCloseProps): import("react").JSX.Element;
60
+ /**
61
+ * Contenido del popover, en un portal: `role="dialog"`, no modal. Al abrir, el foco va al primer elemento focalizable (o al
62
+ * contenido). Al cerrar sin interactuar afuera (Esc o PopoverClose), el foco vuelve a lo que tenía el foco al abrir —el
63
+ * disparador, o el chip desde el que la app lo abrió— y, si no queda nada, al disparador.
64
+ */
65
+ export declare function PopoverContent({ children, side, align, sideOffset, width, matchTriggerWidth, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, className, }: PopoverContentProps): import("react").JSX.Element;
@@ -0,0 +1,87 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useLayoutEffect, useRef, useState } from 'react';
4
+ import { Popover as PopoverPrimitive } from 'radix-ui';
5
+ import { themeRoot } from '../internal/theme-root.js';
6
+ /** Distancia mínima al borde de la ventana antes de mover o dar vuelta el popover: 8px (`--dx-space-2`), como DropdownMenu. */
7
+ const COLLISION_PADDING = 8;
8
+ /**
9
+ * Alto máximo: lo que queda hasta el borde de la ventana (Radix lo calcula con el margen de 8px); el resto se desplaza.
10
+ * Va acá porque check:css no admite `var(--radix-*)`.
11
+ */
12
+ const AVAILABLE_HEIGHT = 'var(--radix-popover-content-available-height)';
13
+ /** Con matchTriggerWidth: el ancho del disparador (o del ancla), y no menos que el del menú, sin pasar de la ventana. */
14
+ const TRIGGER_MIN_WIDTH = 'min(max(var(--dx-size-menu-min), var(--radix-popover-trigger-width)), calc(100vw - 16px))';
15
+ const Ctx = createContext(null);
16
+ const cx = (base, extra) => (extra ? base + ' ' + extra : base);
17
+ /**
18
+ * Raíz del popover (Radix Popover, no modal). Guarda el disparador y el ancla para montar el contenido en el ancestro que fija
19
+ * el tema; el foco, el teclado, el cierre y el posicionamiento son los de Radix.
20
+ */
21
+ export function Popover({ children, open, defaultOpen = false, onOpenChange }) {
22
+ const trigger = useRef(null); // Radix lo tipa como botón; en la práctica es el hijo, sea cual sea
23
+ const anchor = useRef(null);
24
+ const [container, setContainer] = useState(null);
25
+ const [ownOpen, setOwnOpen] = useState(defaultOpen);
26
+ const locate = () => { setContainer(themeRoot(anchor.current ?? trigger.current)); };
27
+ // Al montar, con el disparador o el ancla ya en el DOM y antes de pintar: así también un popover abierto de entrada, o
28
+ // abierto por la app desde otro lugar (controlado), va al tema correcto.
29
+ useLayoutEffect(locate, []);
30
+ const setOpen = (next) => {
31
+ if (next)
32
+ locate();
33
+ if (open === undefined)
34
+ setOwnOpen(next);
35
+ onOpenChange?.(next);
36
+ };
37
+ return (_jsx(PopoverPrimitive.Root, { open: open ?? ownOpen, onOpenChange: setOpen, modal: false, children: _jsx(Ctx, { value: { trigger, anchor, container, close: () => { setOpen(false); } }, children: children }) }));
38
+ }
39
+ const usePopover = (part) => {
40
+ const ctx = useContext(Ctx);
41
+ if (!ctx)
42
+ throw new Error(part + ' tiene que ir dentro de <Popover>.');
43
+ return ctx;
44
+ };
45
+ /**
46
+ * Interno (no está en el index de la entrada): cierra el Popover que envuelve al componente, o null fuera de un Popover. Lo
47
+ * usa FilterOptions para cerrar al elegir una opción de un valor; el foco vuelve a lo que abrió el popover, como con Esc.
48
+ */
49
+ export function usePopoverClose() {
50
+ return useContext(Ctx)?.close ?? null;
51
+ }
52
+ /** Disparador: le pasa los eventos y los atributos de Radix a su único hijo (`asChild`), sin agregar nada alrededor. */
53
+ export function PopoverTrigger({ children }) {
54
+ const { trigger } = usePopover('PopoverTrigger');
55
+ return _jsx(PopoverPrimitive.Trigger, { asChild: true, ref: trigger, children: children });
56
+ }
57
+ /** Ancla: el popover se posiciona contra su único hijo en lugar del disparador. No agrega nada alrededor. */
58
+ export function PopoverAnchor({ children }) {
59
+ const { anchor } = usePopover('PopoverAnchor');
60
+ return _jsx(PopoverPrimitive.Anchor, { asChild: true, ref: anchor, children: children });
61
+ }
62
+ /** Cierra el popover al hacer clic en su único hijo (`asChild`). */
63
+ export function PopoverClose({ children }) {
64
+ usePopover('PopoverClose');
65
+ return _jsx(PopoverPrimitive.Close, { asChild: true, children: children });
66
+ }
67
+ /**
68
+ * Contenido del popover, en un portal: `role="dialog"`, no modal. Al abrir, el foco va al primer elemento focalizable (o al
69
+ * contenido). Al cerrar sin interactuar afuera (Esc o PopoverClose), el foco vuelve a lo que tenía el foco al abrir —el
70
+ * disparador, o el chip desde el que la app lo abrió— y, si no queda nada, al disparador.
71
+ */
72
+ export function PopoverContent({ children, side = 'bottom', align = 'start', sideOffset = 6, width, matchTriggerWidth = false, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, className, }) {
73
+ const { container } = usePopover('PopoverContent');
74
+ const opener = useRef(null);
75
+ const outside = useRef(false);
76
+ const style = { maxHeight: AVAILABLE_HEIGHT, ...(width === undefined ? {} : { width }), ...(matchTriggerWidth ? { minWidth: TRIGGER_MIN_WIDTH } : {}) };
77
+ return (_jsx(PopoverPrimitive.Portal, { container: container, children: _jsx(PopoverPrimitive.Content, { className: cx('dx-popover', className), side: side, align: align, sideOffset: sideOffset, collisionPadding: COLLISION_PADDING, style: style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby,
78
+ // Radix avisa antes de mover el foco adentro: lo que tiene el foco todavía es lo que abrió el popover.
79
+ onOpenAutoFocus: () => { opener.current = document.activeElement; outside.current = false; }, onInteractOutside: () => { outside.current = true; }, onCloseAutoFocus: (event) => {
80
+ // Con un clic o un foco afuera, Radix no mueve el foco; sin opener útil, Radix lo devuelve al disparador.
81
+ const el = opener.current;
82
+ if (outside.current || !(el instanceof HTMLElement) || !el.isConnected || el === el.ownerDocument.body)
83
+ return;
84
+ event.preventDefault();
85
+ el.focus();
86
+ }, children: children }) }));
87
+ }
@@ -0,0 +1,2 @@
1
+ export { Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger } from './Popover.js';
2
+ export type { PopoverAlign, PopoverAnchorProps, PopoverCloseProps, PopoverContentProps, PopoverProps, PopoverSide, PopoverTriggerProps, } from './Popover.js';
@@ -0,0 +1 @@
1
+ export { Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger } from './Popover.js';
@@ -14,6 +14,8 @@ export interface SearchInputProps extends Omit<ComponentPropsWithRef<'input'>, '
14
14
  /**
15
15
  * Campo de búsqueda (Search md del DS v1): un Input `type="search"` con el ícono de búsqueda al principio, fondo
16
16
  * `--dx-bg-sunken` y, cuando hay texto, un IconButton para limpiar al final. Las props van al `<input>` (también `ref`);
17
- * `className`, al contenedor `.dx-search-input`. Sin debounce: lo hace la pantalla.
17
+ * `className`, al contenedor `.dx-search-input`. Sin debounce: lo hace la pantalla. Sin corrector ortográfico, autocorrección
18
+ * ni mayúsculas automáticas (lo que se busca son nombres, códigos y CUIT): la app los vuelve a prender con `spellCheck`,
19
+ * `autoCorrect` y `autoCapitalize`.
18
20
  */
19
- export declare function SearchInput({ value, defaultValue, onValueChange, onClear, clearLabel, onChange, onKeyDown, className, ref, ...rest }: SearchInputProps): import("react").JSX.Element;
21
+ export declare function SearchInput({ value, defaultValue, onValueChange, onClear, clearLabel, spellCheck, autoCorrect, autoCapitalize, onChange, onKeyDown, className, ref, ...rest }: SearchInputProps): import("react").JSX.Element;
@@ -21,9 +21,11 @@ const keepFocus = (event) => { event.preventDefault(); };
21
21
  /**
22
22
  * Campo de búsqueda (Search md del DS v1): un Input `type="search"` con el ícono de búsqueda al principio, fondo
23
23
  * `--dx-bg-sunken` y, cuando hay texto, un IconButton para limpiar al final. Las props van al `<input>` (también `ref`);
24
- * `className`, al contenedor `.dx-search-input`. Sin debounce: lo hace la pantalla.
24
+ * `className`, al contenedor `.dx-search-input`. Sin debounce: lo hace la pantalla. Sin corrector ortográfico, autocorrección
25
+ * ni mayúsculas automáticas (lo que se busca son nombres, códigos y CUIT): la app los vuelve a prender con `spellCheck`,
26
+ * `autoCorrect` y `autoCapitalize`.
25
27
  */
26
- export function SearchInput({ value, defaultValue = '', onValueChange, onClear, clearLabel = 'Limpiar búsqueda', onChange, onKeyDown, className, ref, ...rest }) {
28
+ export function SearchInput({ value, defaultValue = '', onValueChange, onClear, clearLabel = 'Limpiar búsqueda', spellCheck = false, autoCorrect = 'off', autoCapitalize = 'off', onChange, onKeyDown, className, ref, ...rest }) {
27
29
  const [uncontrolled, setUncontrolled] = useState(defaultValue);
28
30
  const input = useRef(null);
29
31
  const controlled = value !== undefined;
@@ -53,5 +55,5 @@ export function SearchInput({ value, defaultValue = '', onValueChange, onClear,
53
55
  event.stopPropagation();
54
56
  clear();
55
57
  };
56
- return (_jsxs("div", { className: className ? `dx-search-input ${className}` : 'dx-search-input', children: [_jsx(Input, { ...rest, ref: mergeRefs(input, ref), type: "search", value: text, onChange: handleChange, onKeyDown: handleKeyDown, iconStart: _jsx(SearchIcon, {}), className: "dx-search-input__field" }), canClear && (_jsx(IconButton, { label: clearLabel, icon: _jsx(ClearIcon, {}), variant: "ghost", size: "xs", className: "dx-search-input__clear", onMouseDown: keepFocus, onClick: clear }))] }));
58
+ return (_jsxs("div", { className: className ? `dx-search-input ${className}` : 'dx-search-input', children: [_jsx(Input, { ...rest, ref: mergeRefs(input, ref), type: "search", spellCheck: spellCheck, autoCorrect: autoCorrect, autoCapitalize: autoCapitalize, value: text, onChange: handleChange, onKeyDown: handleKeyDown, iconStart: _jsx(SearchIcon, {}), className: "dx-search-input__field" }), canClear && (_jsx(IconButton, { label: clearLabel, icon: _jsx(ClearIcon, {}), variant: "ghost", size: "xs", className: "dx-search-input__clear", onMouseDown: keepFocus, onClick: clear }))] }));
57
59
  }
@@ -1,5 +1,7 @@
1
1
  import { type AriaAttributes, type ComponentPropsWithRef, type ReactNode, type Ref } from 'react';
2
2
  import { Select as SelectPrimitive } from 'radix-ui';
3
+ /** Alto del disparador. */
4
+ export type SelectSize = 'md' | 'sm';
3
5
  export interface SelectProps {
4
6
  /** Las opciones: SelectItem, y si hace falta SelectGroup (con SelectLabel) y SelectSeparator. */
5
7
  children: ReactNode;
@@ -22,6 +24,8 @@ export interface SelectProps {
22
24
  'aria-labelledby'?: string | undefined;
23
25
  'aria-describedby'?: string | undefined;
24
26
  'aria-invalid'?: AriaAttributes['aria-invalid'];
27
+ /** Alto del disparador: `md` (38px, por defecto) o `sm` (32px y `--dx-text-sm`, p. ej. las filas por página de Pagination). */
28
+ size?: SelectSize | undefined;
25
29
  /** Se suma a `dx-select`, en el disparador. */
26
30
  className?: string | undefined;
27
31
  /** El disparador (`<button role="combobox">`). */
@@ -36,7 +40,7 @@ export type SelectSeparatorProps = Omit<ComponentPropsWithRef<typeof SelectPrimi
36
40
  * búsqueda por letra, foco y el `<select>` nativo oculto para formularios. Controlado (`value` + `onValueChange`) o no
37
41
  * (`defaultValue`). id, aria-* y `className` van al disparador; `ref` también.
38
42
  */
39
- export declare function Select({ children, value, defaultValue, onValueChange, placeholder, name, required, disabled, form, className, ref, ...trigger }: SelectProps): import("react").JSX.Element;
43
+ export declare function Select({ children, value, defaultValue, onValueChange, placeholder, name, required, disabled, form, size, className, ref, ...trigger }: SelectProps): import("react").JSX.Element;
40
44
  /**
41
45
  * Una opción (`role="option"`): el texto y, si está elegida, la marca a la derecha. `value` no puede ser `""`. `textValue`
42
46
  * es el texto de la búsqueda por letra cuando `children` no es texto. `className` se suma a `dx-select__item`.
@@ -40,7 +40,7 @@ const Check = () => (_jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "1
40
40
  * búsqueda por letra, foco y el `<select>` nativo oculto para formularios. Controlado (`value` + `onValueChange`) o no
41
41
  * (`defaultValue`). id, aria-* y `className` van al disparador; `ref` también.
42
42
  */
43
- export function Select({ children, value, defaultValue, onValueChange, placeholder, name, required, disabled, form, className, ref, ...trigger }) {
43
+ export function Select({ children, value, defaultValue, onValueChange, placeholder, name, required, disabled, form, size = 'md', className, ref, ...trigger }) {
44
44
  // Select siempre le pasa el valor a Radix (controlado): así sabe qué texto poner en el disparador, también en el servidor.
45
45
  const [own, setOwn] = useState(defaultValue ?? '');
46
46
  const current = value ?? own;
@@ -63,7 +63,7 @@ export function Select({ children, value, defaultValue, onValueChange, placehold
63
63
  }, [ref]);
64
64
  const content = current === '' ? undefined : findItemContent(children, current);
65
65
  return (_jsxs(SelectPrimitive.Root, { value: current, onValueChange: change, onOpenChange: (open) => { if (open)
66
- locate(); }, ...(name === undefined ? {} : { name }), ...(required === undefined ? {} : { required }), ...(disabled === undefined ? {} : { disabled }), ...(form === undefined ? {} : { form }), children: [_jsxs(SelectPrimitive.Trigger, { ...trigger, ref: setTrigger, className: cx('dx-select', className), children: [_jsx("span", { className: "dx-select__value", children: _jsx(SelectPrimitive.Value, { placeholder: placeholder, children: content }) }), _jsx(SelectPrimitive.Icon, { className: "dx-select__icon", children: _jsx(Chevron, {}) })] }), _jsx(SelectPrimitive.Portal, { container: container, children: _jsxs(SelectPrimitive.Content, { className: "dx-select__content", position: "popper", side: "bottom", align: "start", sideOffset: SIDE_OFFSET, collisionPadding: COLLISION_PADDING, style: CONTENT_STYLE, children: [_jsx(SelectPrimitive.ScrollUpButton, { className: "dx-select__scroll", children: _jsx(Chevron, { up: true }) }), _jsx(SelectPrimitive.Viewport, { className: "dx-select__viewport", children: children }), _jsx(SelectPrimitive.ScrollDownButton, { className: "dx-select__scroll", children: _jsx(Chevron, {}) })] }) })] }));
66
+ locate(); }, ...(name === undefined ? {} : { name }), ...(required === undefined ? {} : { required }), ...(disabled === undefined ? {} : { disabled }), ...(form === undefined ? {} : { form }), children: [_jsxs(SelectPrimitive.Trigger, { ...trigger, ref: setTrigger, className: cx('dx-select', className), "data-size": size === 'sm' ? 'sm' : undefined, children: [_jsx("span", { className: "dx-select__value", children: _jsx(SelectPrimitive.Value, { placeholder: placeholder, children: content }) }), _jsx(SelectPrimitive.Icon, { className: "dx-select__icon", children: _jsx(Chevron, {}) })] }), _jsx(SelectPrimitive.Portal, { container: container, children: _jsxs(SelectPrimitive.Content, { className: "dx-select__content", position: "popper", side: "bottom", align: "start", sideOffset: SIDE_OFFSET, collisionPadding: COLLISION_PADDING, style: CONTENT_STYLE, children: [_jsx(SelectPrimitive.ScrollUpButton, { className: "dx-select__scroll", children: _jsx(Chevron, { up: true }) }), _jsx(SelectPrimitive.Viewport, { className: "dx-select__viewport", children: children }), _jsx(SelectPrimitive.ScrollDownButton, { className: "dx-select__scroll", children: _jsx(Chevron, {}) })] }) })] }));
67
67
  }
68
68
  /**
69
69
  * Una opción (`role="option"`): el texto y, si está elegida, la marca a la derecha. `value` no puede ser `""`. `textValue`
@@ -1,2 +1,2 @@
1
1
  export { Select, SelectGroup, SelectItem, SelectLabel, SelectSeparator } from './Select.js';
2
- export type { SelectGroupProps, SelectItemProps, SelectLabelProps, SelectProps, SelectSeparatorProps } from './Select.js';
2
+ export type { SelectGroupProps, SelectItemProps, SelectLabelProps, SelectProps, SelectSeparatorProps, SelectSize } from './Select.js';
@@ -0,0 +1,11 @@
1
+ import type { ComponentPropsWithRef } from 'react';
2
+ export interface SkipLinkProps extends ComponentPropsWithRef<'a'> {
3
+ /** A dónde salta: el `id` del contenido principal, con `#`. Por defecto `#contenido`. */
4
+ href?: string | undefined;
5
+ }
6
+ /**
7
+ * Enlace «Saltar al contenido»: el primer elemento enfocable de la página, que solo se ve con el foco del teclado, arriba a la
8
+ * izquierda. Lleva al contenido principal (por defecto `#contenido`) sin pasar por la barra lateral. El texto se cambia con
9
+ * `children`. `className` se suma a `dx-skip-link`; `ref` y el resto de las props van al `<a>`.
10
+ */
11
+ export declare function SkipLink({ href, children, className, ...rest }: SkipLinkProps): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Enlace «Saltar al contenido»: el primer elemento enfocable de la página, que solo se ve con el foco del teclado, arriba a la
4
+ * izquierda. Lleva al contenido principal (por defecto `#contenido`) sin pasar por la barra lateral. El texto se cambia con
5
+ * `children`. `className` se suma a `dx-skip-link`; `ref` y el resto de las props van al `<a>`.
6
+ */
7
+ export function SkipLink({ href = '#contenido', children = 'Saltar al contenido', className, ...rest }) {
8
+ return (_jsx("a", { ...rest, href: href, className: className ? `dx-skip-link ${className}` : 'dx-skip-link', children: children }));
9
+ }
@@ -0,0 +1,2 @@
1
+ export { SkipLink } from './SkipLink.js';
2
+ export type { SkipLinkProps } from './SkipLink.js';
@@ -0,0 +1 @@
1
+ export { SkipLink } from './SkipLink.js';