@faast-app/ui 0.0.0-stage → 0.8.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 (176) hide show
  1. package/README.md +16 -2
  2. package/dist/components/Alert.d.ts +30 -0
  3. package/dist/components/Alert.js +19 -0
  4. package/dist/components/AppShell.d.ts +63 -0
  5. package/dist/components/AppShell.js +80 -0
  6. package/dist/components/Avatar.d.ts +18 -0
  7. package/dist/components/Avatar.js +21 -0
  8. package/dist/components/Badge.d.ts +24 -0
  9. package/dist/components/Badge.js +10 -0
  10. package/dist/components/Button.d.ts +71 -0
  11. package/dist/components/Button.js +40 -0
  12. package/dist/components/Card.d.ts +23 -0
  13. package/dist/components/Card.js +17 -0
  14. package/dist/components/Chip.d.ts +16 -0
  15. package/dist/components/Chip.js +9 -0
  16. package/dist/components/Choice.d.ts +38 -0
  17. package/dist/components/Choice.js +53 -0
  18. package/dist/components/Dialog.d.ts +44 -0
  19. package/dist/components/Dialog.js +51 -0
  20. package/dist/components/EmptyState.d.ts +16 -0
  21. package/dist/components/EmptyState.js +8 -0
  22. package/dist/components/FileDropArea.d.ts +62 -0
  23. package/dist/components/FileDropArea.js +90 -0
  24. package/dist/components/FormField.d.ts +35 -0
  25. package/dist/components/FormField.js +32 -0
  26. package/dist/components/HelpMenu.d.ts +46 -0
  27. package/dist/components/HelpMenu.js +104 -0
  28. package/dist/components/Icon.d.ts +24 -0
  29. package/dist/components/Icon.js +195 -0
  30. package/dist/components/Input.d.ts +37 -0
  31. package/dist/components/Input.js +31 -0
  32. package/dist/components/KpiStrip.d.ts +32 -0
  33. package/dist/components/KpiStrip.js +14 -0
  34. package/dist/components/LockScreen.d.ts +34 -0
  35. package/dist/components/LockScreen.js +22 -0
  36. package/dist/components/Logo.d.ts +27 -0
  37. package/dist/components/Logo.js +12 -0
  38. package/dist/components/Navigation.d.ts +37 -0
  39. package/dist/components/Navigation.js +29 -0
  40. package/dist/components/OptionList.d.ts +27 -0
  41. package/dist/components/OptionList.js +18 -0
  42. package/dist/components/OtpInput.d.ts +31 -0
  43. package/dist/components/OtpInput.js +102 -0
  44. package/dist/components/Pagination.d.ts +31 -0
  45. package/dist/components/Pagination.js +41 -0
  46. package/dist/components/PasswordField.d.ts +32 -0
  47. package/dist/components/PasswordField.js +29 -0
  48. package/dist/components/SegmentedControl.d.ts +35 -0
  49. package/dist/components/SegmentedControl.js +52 -0
  50. package/dist/components/Select.d.ts +15 -0
  51. package/dist/components/Select.js +10 -0
  52. package/dist/components/SessionTimeoutDialog.d.ts +39 -0
  53. package/dist/components/SessionTimeoutDialog.js +62 -0
  54. package/dist/components/Spinner.d.ts +25 -0
  55. package/dist/components/Spinner.js +15 -0
  56. package/dist/components/StatTiles.d.ts +35 -0
  57. package/dist/components/StatTiles.js +12 -0
  58. package/dist/components/Stepper.d.ts +26 -0
  59. package/dist/components/Stepper.js +26 -0
  60. package/dist/components/StickyActionBar.d.ts +28 -0
  61. package/dist/components/StickyActionBar.js +12 -0
  62. package/dist/components/Table.d.ts +69 -0
  63. package/dist/components/Table.js +73 -0
  64. package/dist/components/TenantMark.d.ts +27 -0
  65. package/dist/components/TenantMark.js +15 -0
  66. package/dist/components/Timeline.d.ts +31 -0
  67. package/dist/components/Timeline.js +18 -0
  68. package/dist/components/Toast.d.ts +43 -0
  69. package/dist/components/Toast.js +46 -0
  70. package/dist/components/Toggletip.d.ts +26 -0
  71. package/dist/components/Toggletip.js +47 -0
  72. package/dist/components/Tooltip.d.ts +24 -0
  73. package/dist/components/Tooltip.js +73 -0
  74. package/dist/components/Tour.d.ts +66 -0
  75. package/dist/components/Tour.js +161 -0
  76. package/dist/components/TourOffer.d.ts +22 -0
  77. package/dist/components/TourOffer.js +33 -0
  78. package/dist/components/WelcomeDialog.d.ts +45 -0
  79. package/dist/components/WelcomeDialog.js +38 -0
  80. package/dist/data-table/components/ClientDataTable.d.ts +22 -0
  81. package/dist/data-table/components/ClientDataTable.js +29 -0
  82. package/dist/data-table/components/DataTableFooter.d.ts +11 -0
  83. package/dist/data-table/components/DataTableFooter.js +16 -0
  84. package/dist/data-table/components/DataTableView.d.ts +9 -0
  85. package/dist/data-table/components/DataTableView.js +95 -0
  86. package/dist/data-table/components/ServerDataTable.d.ts +16 -0
  87. package/dist/data-table/components/ServerDataTable.js +17 -0
  88. package/dist/data-table/core/columnVisibility.d.ts +15 -0
  89. package/dist/data-table/core/columnVisibility.js +34 -0
  90. package/dist/data-table/core/constants.d.ts +20 -0
  91. package/dist/data-table/core/constants.js +21 -0
  92. package/dist/data-table/core/filters/registry.d.ts +33 -0
  93. package/dist/data-table/core/filters/registry.js +393 -0
  94. package/dist/data-table/core/filters/types.d.ts +88 -0
  95. package/dist/data-table/core/filters/types.js +1 -0
  96. package/dist/data-table/core/group.d.ts +15 -0
  97. package/dist/data-table/core/group.js +73 -0
  98. package/dist/data-table/core/paginate.d.ts +13 -0
  99. package/dist/data-table/core/paginate.js +27 -0
  100. package/dist/data-table/core/query.d.ts +65 -0
  101. package/dist/data-table/core/query.js +138 -0
  102. package/dist/data-table/core/search.d.ts +10 -0
  103. package/dist/data-table/core/search.js +35 -0
  104. package/dist/data-table/core/selection.d.ts +24 -0
  105. package/dist/data-table/core/selection.js +59 -0
  106. package/dist/data-table/core/sort.d.ts +14 -0
  107. package/dist/data-table/core/sort.js +41 -0
  108. package/dist/data-table/core/text.d.ts +5 -0
  109. package/dist/data-table/core/text.js +27 -0
  110. package/dist/data-table/core/types.d.ts +40 -0
  111. package/dist/data-table/core/types.js +1 -0
  112. package/dist/data-table/core/url.d.ts +43 -0
  113. package/dist/data-table/core/url.js +194 -0
  114. package/dist/data-table/hooks/common.d.ts +14 -0
  115. package/dist/data-table/hooks/common.js +30 -0
  116. package/dist/data-table/hooks/small-hooks.d.ts +12 -0
  117. package/dist/data-table/hooks/small-hooks.js +111 -0
  118. package/dist/data-table/hooks/useClientDataTable.d.ts +35 -0
  119. package/dist/data-table/hooks/useClientDataTable.js +311 -0
  120. package/dist/data-table/hooks/useServerDataTable.d.ts +38 -0
  121. package/dist/data-table/hooks/useServerDataTable.js +209 -0
  122. package/dist/data-table/hooks/useServerRows.d.ts +27 -0
  123. package/dist/data-table/hooks/useServerRows.js +82 -0
  124. package/dist/data-table/hooks/useTableState.d.ts +39 -0
  125. package/dist/data-table/hooks/useTableState.js +219 -0
  126. package/dist/data-table/index.d.ts +42 -0
  127. package/dist/data-table/index.js +22 -0
  128. package/dist/data-table/labels.d.ts +77 -0
  129. package/dist/data-table/labels.js +77 -0
  130. package/dist/data-table/toolbar/ActiveFilters.d.ts +10 -0
  131. package/dist/data-table/toolbar/ActiveFilters.js +53 -0
  132. package/dist/data-table/toolbar/BulkActionBar.d.ts +15 -0
  133. package/dist/data-table/toolbar/BulkActionBar.js +22 -0
  134. package/dist/data-table/toolbar/ColumnVisibilityDialog.d.ts +7 -0
  135. package/dist/data-table/toolbar/ColumnVisibilityDialog.js +15 -0
  136. package/dist/data-table/toolbar/DataTableToolbar.d.ts +19 -0
  137. package/dist/data-table/toolbar/DataTableToolbar.js +12 -0
  138. package/dist/data-table/toolbar/FilterFields.d.ts +11 -0
  139. package/dist/data-table/toolbar/FilterFields.js +58 -0
  140. package/dist/data-table/toolbar/FiltersControl.d.ts +34 -0
  141. package/dist/data-table/toolbar/FiltersControl.js +70 -0
  142. package/dist/data-table/toolbar/PageSizeSelect.d.ts +7 -0
  143. package/dist/data-table/toolbar/PageSizeSelect.js +12 -0
  144. package/dist/data-table/toolbar/QuickFilters.d.ts +7 -0
  145. package/dist/data-table/toolbar/QuickFilters.js +9 -0
  146. package/dist/data-table/toolbar/ResultsCount.d.ts +7 -0
  147. package/dist/data-table/toolbar/ResultsCount.js +9 -0
  148. package/dist/data-table/toolbar/SearchField.d.ts +36 -0
  149. package/dist/data-table/toolbar/SearchField.js +64 -0
  150. package/dist/data-table/toolbar/SortSelect.d.ts +10 -0
  151. package/dist/data-table/toolbar/SortSelect.js +30 -0
  152. package/dist/data-table/types.d.ts +334 -0
  153. package/dist/data-table/types.js +1 -0
  154. package/dist/index.d.ts +91 -0
  155. package/dist/index.js +49 -0
  156. package/dist/kit/catalogo.html +5281 -0
  157. package/dist/kit/faast-kit.css +5129 -0
  158. package/dist/kit/markup.json +127 -0
  159. package/dist/styles.css +4668 -0
  160. package/dist/theme/ThemeProvider.d.ts +33 -0
  161. package/dist/theme/ThemeProvider.js +77 -0
  162. package/dist/theme/ThemeToggle.d.ts +16 -0
  163. package/dist/theme/ThemeToggle.js +27 -0
  164. package/dist/utils/cx.d.ts +2 -0
  165. package/dist/utils/cx.js +4 -0
  166. package/dist/utils/devWarn.d.ts +2 -0
  167. package/dist/utils/devWarn.js +10 -0
  168. package/dist/utils/tourGeometry.d.ts +61 -0
  169. package/dist/utils/tourGeometry.js +135 -0
  170. package/dist/utils/useFloatingPosition.d.ts +9 -0
  171. package/dist/utils/useFloatingPosition.js +45 -0
  172. package/dist/utils/useModalDialog.d.ts +7 -0
  173. package/dist/utils/useModalDialog.js +49 -0
  174. package/dist/utils/useTourAnchorRect.d.ts +6 -0
  175. package/dist/utils/useTourAnchorRect.js +40 -0
  176. package/package.json +53 -4
@@ -0,0 +1,11 @@
1
+ import type { DataTableLabels } from '../labels.js';
2
+ import type { FilterDef } from '../types.js';
3
+ export interface FilterFieldProps<TRow> {
4
+ def: FilterDef<TRow>;
5
+ value: unknown;
6
+ onChange: (value: unknown) => void;
7
+ error?: string;
8
+ labels: DataTableLabels;
9
+ }
10
+ /** One field of the filter form, chosen by the definition's `kind`. */
11
+ export declare function FilterField<TRow>({ def, value, onChange, error, labels }: FilterFieldProps<TRow>): import("react").JSX.Element;
@@ -0,0 +1,58 @@
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useId } from 'react';
3
+ import { Checkbox } from '../../components/Choice.js';
4
+ import { Chip } from '../../components/Chip.js';
5
+ import { FormField } from '../../components/FormField.js';
6
+ import { Input } from '../../components/Input.js';
7
+ import { Select } from '../../components/Select.js';
8
+ function Legend({ text, hint }) {
9
+ return (_jsxs("legend", { className: "faast-field__label", children: [text, hint && _jsxs("span", { className: "faast-dt__legend-hint", children: [" ", hint] })] }));
10
+ }
11
+ function RangeFieldset({ legend, legendHint, hint, hintId, error, errorId, children, }) {
12
+ const describedBy = [error ? errorId : undefined, hint ? hintId : undefined].filter(Boolean);
13
+ return (_jsxs("fieldset", { className: error ? 'faast-fieldset faast-field--invalid' : 'faast-fieldset', "aria-describedby": describedBy.length > 0 ? describedBy.join(' ') : undefined, children: [_jsx(Legend, { text: legend, hint: legendHint }), _jsx("div", { className: "faast-dt__range", children: children }), hint && (_jsx("p", { className: "faast-field__hint", id: hintId, children: hint })), error && (_jsx("p", { className: "faast-field__error", id: errorId, children: error }))] }));
14
+ }
15
+ /** An input with a symbol inside, before the value ("S/"). The symbol is decorative. */
16
+ function AffixInput({ prefix, children }) {
17
+ if (!prefix)
18
+ return _jsx(_Fragment, { children: children });
19
+ return (_jsxs("span", { className: "faast-dt__affix", children: [_jsx("span", { className: "faast-dt__affix-prefix", "aria-hidden": "true", children: prefix }), children] }));
20
+ }
21
+ /** One field of the filter form, chosen by the definition's `kind`. */
22
+ export function FilterField({ def, value, onChange, error, labels }) {
23
+ const baseId = useId();
24
+ const errorId = `${baseId}-error`;
25
+ const hintId = `${baseId}-hint`;
26
+ const invalid = error ? true : undefined;
27
+ switch (def.kind) {
28
+ case 'text':
29
+ return (_jsx(FormField, { label: def.label, error: error, children: _jsx(Input, { value: typeof value === 'string' ? value : '', maxLength: def.maxLength ?? 100, onChange: (event) => onChange(event.target.value) }) }));
30
+ case 'select':
31
+ return (_jsx(FormField, { label: def.label, error: error, children: _jsx(Select, { value: typeof value === 'string' ? value : '', placeholder: labels.anyOption, options: def.options.map((o) => ({ value: o.value, label: o.label })), onChange: (event) => onChange(event.target.value) }) }));
32
+ case 'multiselect': {
33
+ const selected = Array.isArray(value) ? value : [];
34
+ const toggle = (optionValue) => onChange(selected.includes(optionValue)
35
+ ? selected.filter((v) => v !== optionValue)
36
+ : [...selected, optionValue]);
37
+ const asChips = (def.display ?? (def.options.length <= 8 ? 'chips' : 'checkboxes')) === 'chips';
38
+ return (_jsxs("fieldset", { className: error ? 'faast-fieldset faast-field--invalid' : 'faast-fieldset', "aria-describedby": error ? errorId : undefined, children: [_jsx(Legend, { text: def.label, hint: def.legendHint }), _jsx("div", { className: asChips ? 'faast-dt__options-chips' : 'faast-dt__options-list', children: def.options.map((option) => asChips ? (_jsx(Chip, { label: option.tone ? (_jsxs(_Fragment, { children: [_jsx("span", { className: `faast-dt__tone-dot faast-dt__tone-dot--${option.tone}`, "aria-hidden": "true" }), option.label] })) : (option.label), pressed: selected.includes(option.value), onClick: () => toggle(option.value) }, option.value)) : (_jsx(Checkbox, { label: option.label, checked: selected.includes(option.value), onChange: () => toggle(option.value) }, option.value))) }), error && (_jsx("p", { className: "faast-field__error", id: errorId, children: error }))] }));
39
+ }
40
+ case 'dateRange': {
41
+ const range = (value ?? {});
42
+ return (_jsxs(RangeFieldset, { legend: def.label, legendHint: def.legendHint, error: error, errorId: errorId, children: [_jsx(FormField, { label: labels.from, children: _jsx(Input, { type: "date", min: def.min, max: def.max, "aria-invalid": invalid, "aria-describedby": error ? errorId : undefined, value: range.from ?? '', onChange: (event) => onChange({ ...range, from: event.target.value }) }) }), _jsx(FormField, { label: labels.to, children: _jsx(Input, { type: "date", min: def.min, max: def.max, "aria-invalid": invalid, "aria-describedby": error ? errorId : undefined, value: range.to ?? '', onChange: (event) => onChange({ ...range, to: event.target.value }) }) })] }));
43
+ }
44
+ case 'numberRange': {
45
+ const range = (value ?? {});
46
+ return (_jsxs(RangeFieldset, { legend: def.label, legendHint: def.legendHint, hint: def.hint, hintId: hintId, error: error, errorId: errorId, children: [_jsx(FormField, { label: labels.min, children: _jsx(AffixInput, { prefix: def.prefix, children: _jsx(Input, { type: "text", inputMode: "decimal", autoComplete: "off", "aria-invalid": invalid, "aria-describedby": error ? errorId : undefined, value: range.min === undefined ? '' : String(range.min), onChange: (event) => onChange({ ...range, min: event.target.value }) }) }) }), _jsx(FormField, { label: labels.max, children: _jsx(AffixInput, { prefix: def.prefix, children: _jsx(Input, { type: "text", inputMode: "decimal", autoComplete: "off", "aria-invalid": invalid, "aria-describedby": error ? errorId : undefined, value: range.max === undefined ? '' : String(range.max), onChange: (event) => onChange({ ...range, max: event.target.value }) }) }) })] }));
47
+ }
48
+ case 'boolean':
49
+ return (_jsx(Checkbox, { label: def.label, checked: value === true, onChange: (event) => onChange(event.target.checked ? true : undefined) }));
50
+ case 'custom':
51
+ return (_jsx("div", { className: "faast-dt__custom-field", children: def.renderField({
52
+ value: value,
53
+ onChange: onChange,
54
+ id: baseId,
55
+ error,
56
+ }) }));
57
+ }
58
+ }
@@ -0,0 +1,34 @@
1
+ import type { TableController } from '../types.js';
2
+ export interface FilterPanelProps<TRow> {
3
+ table: TableController<TRow>;
4
+ /** Id of the `<form>`; the sheet's footer buttons point at it. */
5
+ formId: string;
6
+ /** Called after the filters were applied (to close the sheet). */
7
+ onApplied?: () => void;
8
+ /** Called after "Limpiar filtros". */
9
+ onCleared?: () => void;
10
+ /** Render the action buttons inside the form (the desktop panel). */
11
+ showActions?: boolean;
12
+ className?: string;
13
+ }
14
+ /**
15
+ * The filter form. Fields edit a draft; nothing is applied until "Aplicar filtros" (or
16
+ * Enter in a field). Invalid fields show an error and the first one receives focus.
17
+ */
18
+ export declare function FilterPanel<TRow>({ table, formId, onApplied, onCleared, showActions, className, }: FilterPanelProps<TRow>): import("react").JSX.Element;
19
+ export interface FiltersDialogProps<TRow> {
20
+ table: TableController<TRow>;
21
+ open: boolean;
22
+ onClose: () => void;
23
+ }
24
+ /** Bottom sheet with the filter form (phones). Closing without applying discards the draft. */
25
+ export declare function FiltersDialog<TRow>({ table, open, onClose }: FiltersDialogProps<TRow>): import("react").JSX.Element;
26
+ export interface FiltersControlProps<TRow> {
27
+ table: TableController<TRow>;
28
+ className?: string;
29
+ }
30
+ /**
31
+ * The "Filtros" button with a count badge and a chevron. From 768px it discloses an inline panel under the toolbar; below
32
+ * it opens a bottom sheet. Filters are applied only with "Aplicar filtros".
33
+ */
34
+ export declare function FiltersControl<TRow>({ table, className }: FiltersControlProps<TRow>): import("react").JSX.Element | null;
@@ -0,0 +1,70 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef, useState } from 'react';
3
+ import { Button } from '../../components/Button.js';
4
+ import { Dialog } from '../../components/Dialog.js';
5
+ import { Icon } from '../../components/Icon.js';
6
+ import { cx } from '../../utils/cx.js';
7
+ import { useMediaQuery } from '../hooks/small-hooks.js';
8
+ import { FilterField } from './FilterFields.js';
9
+ /**
10
+ * The filter form. Fields edit a draft; nothing is applied until "Aplicar filtros" (or
11
+ * Enter in a field). Invalid fields show an error and the first one receives focus.
12
+ */
13
+ export function FilterPanel({ table, formId, onApplied, onCleared, showActions = true, className, }) {
14
+ const { labels, draft, filterDefs } = table;
15
+ const formRef = useRef(null);
16
+ const [focusRequest, setFocusRequest] = useState(0);
17
+ useEffect(() => {
18
+ if (focusRequest === 0)
19
+ return;
20
+ formRef.current?.querySelector('[aria-invalid="true"]')?.focus();
21
+ }, [focusRequest]);
22
+ const submit = (event) => {
23
+ event.preventDefault();
24
+ if (draft.apply())
25
+ onApplied?.();
26
+ else
27
+ setFocusRequest((n) => n + 1);
28
+ };
29
+ return (_jsxs("form", { id: formId, ref: formRef, className: cx('faast-dt__filter-form', className), onSubmit: submit, noValidate: true, children: [_jsx("div", { className: "faast-dt__filter-fields", children: filterDefs.map((def) => (_jsx(FilterField, { def: def, labels: labels, value: draft.values[def.id], error: draft.errors[def.id], onChange: (value) => draft.set(def.id, value) }, def.id))) }), draft.isDirty && (_jsx("p", { className: "faast-dt__unapplied", role: "status", children: labels.unappliedChanges })), showActions && (_jsxs("div", { className: "faast-dt__filter-actions", children: [_jsx(Button, { variant: "ghost", onClick: () => {
30
+ table.clearFilterFields();
31
+ onCleared?.();
32
+ }, children: labels.clearFilters }), _jsx(Button, { type: "submit", variant: "primary", children: labels.applyFilters })] }))] }));
33
+ }
34
+ /** Bottom sheet with the filter form (phones). Closing without applying discards the draft. */
35
+ export function FiltersDialog({ table, open, onClose }) {
36
+ const formId = useId();
37
+ const { labels } = table;
38
+ const close = () => {
39
+ table.draft.discard();
40
+ onClose();
41
+ };
42
+ return (_jsx(Dialog, { open: open, onClose: close, title: labels.filters, mobile: "sheet", closeLabel: labels.close, footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", onClick: () => {
43
+ table.clearFilterFields();
44
+ onClose();
45
+ }, children: labels.clearFilters }), _jsx(Button, { type: "submit", form: formId, variant: "primary", children: labels.applyFilters })] }), children: _jsx(FilterPanel, { table: table, formId: formId, showActions: false, onApplied: onClose }) }));
46
+ }
47
+ /**
48
+ * The "Filtros" button with a count badge and a chevron. From 768px it discloses an inline panel under the toolbar; below
49
+ * it opens a bottom sheet. Filters are applied only with "Aplicar filtros".
50
+ */
51
+ export function FiltersControl({ table, className }) {
52
+ const panelId = useId();
53
+ const [open, setOpen] = useState(false);
54
+ const desktop = useMediaQuery('(min-width: 768px)');
55
+ // Crossing the breakpoint swaps panel and sheet: close instead of popping the sheet open.
56
+ const [seenDesktop, setSeenDesktop] = useState(desktop);
57
+ if (seenDesktop !== desktop) {
58
+ setSeenDesktop(desktop);
59
+ setOpen(false);
60
+ }
61
+ const { labels, activeFilterCount, a11y } = table;
62
+ if (table.filterDefs.length === 0)
63
+ return null;
64
+ const toggle = () => {
65
+ if (!open)
66
+ table.draft.discard();
67
+ setOpen(!open);
68
+ };
69
+ return (_jsxs("div", { className: cx('faast-dt__filters', className), children: [_jsxs(Button, { ref: (element) => a11y.registerTarget('filters', element), variant: "secondary", className: "faast-dt__filters-button", leadingIcon: _jsx(Icon, { name: "sliders-horizontal", size: 16 }), trailingIcon: desktop ? (_jsx(Icon, { name: "chevron-down", size: 16, className: "faast-dt__filters-chevron" })) : undefined, "aria-label": activeFilterCount > 0 ? labels.filtersWithCount(activeFilterCount) : undefined, "aria-expanded": desktop ? open : undefined, "aria-controls": desktop && open ? panelId : undefined, "aria-haspopup": desktop ? undefined : 'dialog', onClick: toggle, children: [_jsx("span", { className: "faast-dt__filters-text", children: labels.filters }), activeFilterCount > 0 && (_jsx("span", { className: "faast-dt__filters-count", "aria-hidden": "true", children: activeFilterCount }))] }), desktop && open && (_jsx("div", { id: panelId, className: "faast-dt__filter-panel", children: _jsx(FilterPanel, { table: table, formId: `${panelId}-form` }) })), !desktop && _jsx(FiltersDialog, { table: table, open: open, onClose: () => setOpen(false) })] }));
70
+ }
@@ -0,0 +1,7 @@
1
+ import type { TableController } from '../types.js';
2
+ export interface PageSizeSelectProps<TRow> {
3
+ table: TableController<TRow>;
4
+ className?: string;
5
+ }
6
+ /** Rows per page (10, 25, 50, 100). Focus stays on the control after changing it. */
7
+ export declare function PageSizeSelect<TRow>({ table, className }: PageSizeSelectProps<TRow>): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from 'react';
3
+ import { Select } from '../../components/Select.js';
4
+ import { cx } from '../../utils/cx.js';
5
+ /** Rows per page (10, 25, 50, 100). Focus stays on the control after changing it. */
6
+ export function PageSizeSelect({ table, className }) {
7
+ const id = useId();
8
+ return (_jsxs("div", { className: cx('faast-dt__page-size', className), children: [_jsx("label", { className: "faast-dt__page-size-label", htmlFor: id, children: table.labels.pageSize }), _jsx(Select, { id: id, value: String(table.query.pageSize), onChange: (event) => table.setPageSize(Number(event.target.value)), options: table.pageSizeOptions.map((size) => ({
9
+ value: String(size),
10
+ label: String(size),
11
+ })) })] }));
12
+ }
@@ -0,0 +1,7 @@
1
+ import type { TableController } from '../types.js';
2
+ export interface QuickFiltersProps<TRow> {
3
+ table: TableController<TRow>;
4
+ className?: string;
5
+ }
6
+ /** Mutually exclusive presets with counts ("Todos 24", "Con XML 18"), as toggle chips. */
7
+ export declare function QuickFilters<TRow>({ table, className }: QuickFiltersProps<TRow>): import("react").JSX.Element | null;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Chip } from '../../components/Chip.js';
3
+ import { cx } from '../../utils/cx.js';
4
+ /** Mutually exclusive presets with counts ("Todos 24", "Con XML 18"), as toggle chips. */
5
+ export function QuickFilters({ table, className }) {
6
+ if (table.quickFilterDefs.length === 0)
7
+ return null;
8
+ return (_jsx("div", { role: "group", "aria-label": table.labels.quickFilters, className: cx('faast-dt__quick', className), children: table.quickFilterDefs.map((def) => (_jsx(Chip, { label: def.label, count: table.quickFilterCounts?.[def.id], pressed: table.query.quickFilter === def.id, onClick: () => table.setQuickFilter(def.id) }, def.id))) }));
9
+ }
@@ -0,0 +1,7 @@
1
+ import type { TableController } from '../types.js';
2
+ export interface ResultsCountProps<TRow> {
3
+ table: TableController<TRow>;
4
+ className?: string;
5
+ }
6
+ /** "230 resultados" and, when the page does not cover everything, "Mostrando 11–20 de 230". */
7
+ export declare function ResultsCount<TRow>({ table, className }: ResultsCountProps<TRow>): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx } from '../../utils/cx.js';
3
+ /** "230 resultados" and, when the page does not cover everything, "Mostrando 11–20 de 230". */
4
+ export function ResultsCount({ table, className }) {
5
+ const { labels, rowCount, range } = table;
6
+ return (_jsx("p", { className: cx('faast-dt__results', className), children: _jsx("span", { className: "faast-num", children: rowCount > table.query.pageSize
7
+ ? labels.range(range.from, range.to, rowCount)
8
+ : labels.results(rowCount) }) }));
9
+ }
@@ -0,0 +1,36 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { TableController } from '../types.js';
3
+ export interface SearchFieldProps<TRow> {
4
+ table: TableController<TRow>;
5
+ /** What can be searched ("Buscar por RUC, proveedor o serie"). */
6
+ placeholder?: string;
7
+ /** Accessible name. Default: the table's `search` label. */
8
+ label?: string;
9
+ /**
10
+ * `outlined` (default) is a bordered field. `filled` is a sunken, borderless field that
11
+ * lifts to the surface with a focus ring (a search bar inside a card), 44px tall, 15px text.
12
+ */
13
+ variant?: 'outlined' | 'filled';
14
+ /**
15
+ * A single key that focuses the field from anywhere on the page (e.g. `/`). Shown as a
16
+ * `<kbd>` hint that hides while the field has focus or text, on touch screens and below
17
+ * 640px. Ignored while typing in a field and while a dialog is open.
18
+ */
19
+ shortcut?: string;
20
+ /**
21
+ * Text shown after the input and announced politely ("12 resultados"). Leave empty to
22
+ * hide the slot. See `showResultCount` for the common case.
23
+ */
24
+ status?: ReactNode;
25
+ /**
26
+ * Show the table's result count (`labels.results`) in the status slot while a search is
27
+ * applied. Ignored when `status` is set.
28
+ */
29
+ showResultCount?: boolean;
30
+ className?: string;
31
+ }
32
+ /**
33
+ * Search box. Typing applies after 300 ms idle; Enter applies now; Esc or the clear button
34
+ * empties it. The clear button keeps focus in the field.
35
+ */
36
+ export declare function SearchField<TRow>({ table, placeholder, label, variant, shortcut, status, showResultCount, className, }: SearchFieldProps<TRow>): import("react").JSX.Element;
@@ -0,0 +1,64 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef } from 'react';
3
+ import { IconButton } from '../../components/Button.js';
4
+ import { Icon } from '../../components/Icon.js';
5
+ import { MAX_SEARCH_LENGTH } from '../core/constants.js';
6
+ import { cx } from '../../utils/cx.js';
7
+ function isTypingTarget(target) {
8
+ if (!(target instanceof HTMLElement))
9
+ return false;
10
+ return (target.isContentEditable ||
11
+ target.closest('input, textarea, select, [contenteditable=""], [contenteditable="true"]') !==
12
+ null);
13
+ }
14
+ /**
15
+ * Search box. Typing applies after 300 ms idle; Enter applies now; Esc or the clear button
16
+ * empties it. The clear button keeps focus in the field.
17
+ */
18
+ export function SearchField({ table, placeholder, label, variant = 'outlined', shortcut, status, showResultCount = false, className, }) {
19
+ const id = useId();
20
+ const statusId = `${id}-status`;
21
+ const inputRef = useRef(null);
22
+ const { labels, searchInput, a11y } = table;
23
+ useEffect(() => {
24
+ if (!shortcut)
25
+ return;
26
+ const onKey = (event) => {
27
+ if (event.key !== shortcut || event.defaultPrevented)
28
+ return;
29
+ if (event.ctrlKey || event.metaKey || event.altKey)
30
+ return;
31
+ if (isTypingTarget(event.target))
32
+ return;
33
+ if (document.querySelector('dialog[open]'))
34
+ return;
35
+ const input = inputRef.current;
36
+ if (!input)
37
+ return;
38
+ event.preventDefault();
39
+ input.focus();
40
+ };
41
+ document.addEventListener('keydown', onKey);
42
+ return () => document.removeEventListener('keydown', onKey);
43
+ }, [shortcut]);
44
+ const onKeyDown = (event) => {
45
+ if (event.key === 'Enter') {
46
+ event.preventDefault();
47
+ table.flushSearch();
48
+ }
49
+ else if (event.key === 'Escape' && searchInput !== '') {
50
+ event.preventDefault();
51
+ table.clearSearch();
52
+ }
53
+ };
54
+ const statusContent = status ?? (showResultCount && table.query.search !== '' ? labels.results(table.rowCount) : null);
55
+ const hasStatus = statusContent !== null && statusContent !== undefined && statusContent !== '';
56
+ const hasText = searchInput !== '';
57
+ return (_jsxs("div", { role: "search", className: cx('faast-dt__search', className), children: [_jsx("label", { className: "faast-sr-only", htmlFor: id, children: label ?? labels.search }), _jsxs("div", { className: cx('faast-dt__searchbox', variant === 'filled' && 'faast-dt__searchbox--filled', hasText && 'faast-dt__searchbox--has-text'), children: [_jsx(Icon, { name: "search", size: 18, className: "faast-dt__searchbox-icon" }), _jsx("input", { id: id, ref: (element) => {
58
+ inputRef.current = element;
59
+ a11y.registerTarget('search', element);
60
+ }, type: "search", autoComplete: "off", enterKeyHint: "search", maxLength: MAX_SEARCH_LENGTH, placeholder: placeholder ?? labels.search, className: "faast-dt__searchbox-input", value: searchInput, "aria-describedby": hasStatus ? statusId : undefined, "aria-keyshortcuts": shortcut, onChange: (event) => table.setSearchInput(event.target.value), onKeyDown: onKeyDown }), _jsx("span", { id: statusId, className: "faast-dt__searchbox-status", role: "status", "aria-live": "polite", children: hasStatus ? statusContent : null }), hasText && (_jsx(IconButton, { size: "sm", label: labels.searchClear, icon: _jsx(Icon, { name: "x", size: 16 }), className: "faast-dt__searchbox-clear", onClick: () => {
61
+ table.clearSearch();
62
+ a11y.focusTarget('search');
63
+ } })), shortcut && (_jsx("kbd", { className: "faast-dt__searchbox-kbd", "aria-hidden": "true", children: shortcut }))] })] }));
64
+ }
@@ -0,0 +1,10 @@
1
+ import type { TableController } from '../types.js';
2
+ export interface SortSelectProps<TRow> {
3
+ table: TableController<TRow>;
4
+ className?: string;
5
+ }
6
+ /**
7
+ * Labelled native select that sorts the table. Column headers are hidden in the cards layout,
8
+ * so this is how phones sort; it is shown below 768px only.
9
+ */
10
+ export declare function SortSelect<TRow>({ table, className }: SortSelectProps<TRow>): import("react").JSX.Element | null;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from 'react';
3
+ import { Select } from '../../components/Select.js';
4
+ import { cx } from '../../utils/cx.js';
5
+ const encode = (columnId, direction) => `${columnId}:${direction === 'ascending' ? 'asc' : 'desc'}`;
6
+ /**
7
+ * Labelled native select that sorts the table. Column headers are hidden in the cards layout,
8
+ * so this is how phones sort; it is shown below 768px only.
9
+ */
10
+ export function SortSelect({ table, className }) {
11
+ const id = useId();
12
+ const { labels, query } = table;
13
+ const sortable = table.visibleColumns.filter((column) => column.sort);
14
+ if (sortable.length === 0)
15
+ return null;
16
+ const options = [
17
+ { value: '', label: labels.sortDefault },
18
+ ...sortable.flatMap((column) => ['ascending', 'descending'].map((direction) => ({
19
+ value: encode(column.id, direction),
20
+ label: column.sort?.labels?.[direction] ?? labels.sortOption(column.header, direction),
21
+ }))),
22
+ ];
23
+ return (_jsxs("div", { className: cx('faast-dt__sort-select', className), children: [_jsx("label", { htmlFor: id, className: "faast-dt__sort-label", children: labels.sortBy }), _jsx(Select, { id: id, value: query.sort ? encode(query.sort.columnId, query.sort.direction) : '', options: options, onChange: (event) => {
24
+ const [columnId, dir] = event.target.value.split(':');
25
+ if (!columnId || !dir)
26
+ table.setSort(null);
27
+ else
28
+ table.setSort({ columnId, direction: dir === 'asc' ? 'ascending' : 'descending' });
29
+ } })] }));
30
+ }