@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,161 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useLayoutEffect, useMemo, useRef, useSyncExternalStore, } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import { cx } from '../utils/cx.js';
5
+ import { placeTourPopover, TOUR_PADDING } from '../utils/tourGeometry.js';
6
+ import { useTourAnchorRect } from '../utils/useTourAnchorRect.js';
7
+ import { Button } from './Button.js';
8
+ /** One dot per step: done, the current one as a pill, and pending. Decorative (`aria-hidden`). */
9
+ export function TourProgress({ count, current, className }) {
10
+ return (_jsx("span", { className: cx('faast-tour-progress', className), "aria-hidden": "true", children: Array.from({ length: count }, (_, index) => (_jsx("i", { className: cx(index < current && 'faast-tour-progress--done', index === current && 'faast-tour-progress--current') }, index))) }));
11
+ }
12
+ /**
13
+ * Full-screen scrim with a cut-out around the target. Blocks interaction with the page: the
14
+ * `inertRoot` becomes inert, clicks on the blocker do nothing and `<html>` gets
15
+ * `faast-tour-active` (extra bottom padding on phones so the bottom sheet never hides content).
16
+ */
17
+ export function TourSpotlight({ targets, inertRoot, padding = TOUR_PADDING, container, }) {
18
+ const rect = useTourAnchorRect(targets);
19
+ const holeRef = useRef(null);
20
+ useEffect(() => {
21
+ if (!inertRoot)
22
+ return;
23
+ const wasInert = inertRoot.hasAttribute('inert');
24
+ inertRoot.setAttribute('inert', '');
25
+ return () => {
26
+ if (!wasInert)
27
+ inertRoot.removeAttribute('inert');
28
+ };
29
+ }, [inertRoot]);
30
+ useEffect(() => {
31
+ const root = document.documentElement;
32
+ root.classList.add('faast-tour-active');
33
+ return () => root.classList.remove('faast-tour-active');
34
+ }, []);
35
+ // Positioned through the CSSOM (never a style attribute) so a strict CSP is satisfied.
36
+ useLayoutEffect(() => {
37
+ const hole = holeRef.current;
38
+ if (!hole || !rect)
39
+ return;
40
+ hole.style.left = `${String(rect.left - padding)}px`;
41
+ hole.style.top = `${String(rect.top - padding)}px`;
42
+ hole.style.width = `${String(rect.width + padding * 2)}px`;
43
+ hole.style.height = `${String(rect.height + padding * 2)}px`;
44
+ }, [rect, padding]);
45
+ if (typeof document === 'undefined')
46
+ return null;
47
+ return createPortal(_jsxs("div", { className: "faast-tour", children: [_jsx("div", { className: "faast-tour__blocker", "aria-hidden": "true" }), rect && _jsx("div", { ref: holeRef, className: "faast-tour__hole", "aria-hidden": "true" })] }), container ?? document.body);
48
+ }
49
+ function useBelow(width) {
50
+ const query = width === 'never' ? null : `(max-width: ${String(width - 0.02)}px)`;
51
+ const [subscribe, read] = useMemo(() => {
52
+ const canMatch = query !== null && typeof window.matchMedia === 'function';
53
+ return [
54
+ (notify) => {
55
+ if (!canMatch)
56
+ return () => undefined;
57
+ const list = window.matchMedia(query);
58
+ list.addEventListener('change', notify);
59
+ return () => list.removeEventListener('change', notify);
60
+ },
61
+ () => canMatch && window.matchMedia(query).matches,
62
+ ];
63
+ }, [query]);
64
+ return useSyncExternalStore(subscribe, read, () => false);
65
+ }
66
+ function focusables(root) {
67
+ return Array.from(root.querySelectorAll('button, [href], [tabindex]')).filter((el) => !el.hidden && !el.hasAttribute('disabled') && el.tabIndex >= 0);
68
+ }
69
+ /**
70
+ * The step card: a `dialog` (the page behind is inert) with the step label, progress, title,
71
+ * body and Omitir / Anterior / Siguiente. Esc skips, the arrows move, Tab stays inside, and
72
+ * focus returns to the card on every step. Below `sheetBelow` it is a bottom sheet (or a top
73
+ * sheet when the target sits in the lower half of the screen).
74
+ */
75
+ export function TourPopover({ open, anchorRect, placement, stepIndex, stepCount, stepLabel, title, body, labels, onPrevious, onNext, onSkip, sheetBelow = 640, container, }) {
76
+ const ref = useRef(null);
77
+ const id = useId();
78
+ const titleId = `${id}-title`;
79
+ const bodyId = `${id}-body`;
80
+ const sheet = useBelow(sheetBelow);
81
+ const sheetTop = sheet && anchorRect !== null && anchorRect.top > window.innerHeight / 2;
82
+ const handlers = useRef({ onPrevious, onNext, onSkip, stepIndex });
83
+ useEffect(() => {
84
+ handlers.current = { onPrevious, onNext, onSkip, stepIndex };
85
+ });
86
+ useLayoutEffect(() => {
87
+ const el = ref.current;
88
+ if (!open || !el)
89
+ return;
90
+ if (sheet || !anchorRect) {
91
+ el.style.left = '';
92
+ el.style.top = '';
93
+ el.dataset.side = 'none';
94
+ return;
95
+ }
96
+ const placed = placeTourPopover({
97
+ anchor: anchorRect,
98
+ size: { width: el.offsetWidth, height: el.offsetHeight },
99
+ viewport: { width: window.innerWidth, height: window.innerHeight },
100
+ preferred: placement,
101
+ });
102
+ el.style.left = `${String(placed.x)}px`;
103
+ el.style.top = `${String(placed.y)}px`;
104
+ el.style.setProperty('--faast-tour-arrow-x', `${String(placed.arrowX)}px`);
105
+ el.style.setProperty('--faast-tour-arrow-y', `${String(placed.arrowY)}px`);
106
+ el.dataset.side = placed.side;
107
+ }, [open, anchorRect, placement, sheet, stepIndex]);
108
+ useEffect(() => {
109
+ if (open)
110
+ ref.current?.focus({ preventScroll: true });
111
+ }, [open, stepIndex]);
112
+ useEffect(() => {
113
+ if (!open)
114
+ return;
115
+ const onKeyDown = (event) => {
116
+ const current = handlers.current;
117
+ if (event.key === 'Escape') {
118
+ event.preventDefault();
119
+ current.onSkip();
120
+ }
121
+ else if (event.key === 'ArrowRight') {
122
+ event.preventDefault();
123
+ current.onNext();
124
+ }
125
+ else if (event.key === 'ArrowLeft') {
126
+ event.preventDefault();
127
+ if (current.stepIndex > 0)
128
+ current.onPrevious();
129
+ }
130
+ else if (event.key === 'Tab') {
131
+ const root = ref.current;
132
+ if (!root)
133
+ return;
134
+ const items = focusables(root);
135
+ const first = items[0];
136
+ const last = items[items.length - 1];
137
+ if (!first || !last)
138
+ return;
139
+ const active = document.activeElement;
140
+ if (!(active instanceof Node) || !root.contains(active)) {
141
+ event.preventDefault();
142
+ first.focus();
143
+ }
144
+ else if (event.shiftKey && (active === first || active === root)) {
145
+ event.preventDefault();
146
+ last.focus();
147
+ }
148
+ else if (!event.shiftKey && active === last) {
149
+ event.preventDefault();
150
+ first.focus();
151
+ }
152
+ }
153
+ };
154
+ document.addEventListener('keydown', onKeyDown);
155
+ return () => document.removeEventListener('keydown', onKeyDown);
156
+ }, [open]);
157
+ if (!open || typeof document === 'undefined')
158
+ return null;
159
+ const isLast = stepIndex >= stepCount - 1;
160
+ return createPortal(_jsxs("div", { ref: ref, className: cx('faast-tour-popover', sheet && 'faast-tour-popover--sheet', sheetTop && 'faast-tour-popover--sheet-top'), role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, "aria-describedby": bodyId, tabIndex: -1, "data-side": "none", children: [_jsx("span", { className: "faast-tour-popover__arrow", "aria-hidden": "true" }), _jsx("span", { className: "faast-tour-popover__grab", "aria-hidden": "true" }), _jsxs("div", { className: "faast-tour-popover__top", children: [_jsx("span", { className: "faast-tour-popover__step", "aria-live": "polite", children: stepLabel }), _jsx(TourProgress, { count: stepCount, current: stepIndex })] }), _jsx("h2", { className: "faast-tour-popover__title", id: titleId, children: title }), _jsx("p", { className: "faast-tour-popover__body", id: bodyId, children: body }), _jsxs("div", { className: "faast-tour-popover__actions", children: [_jsx(Button, { variant: "ghost", size: "sm", "aria-label": labels.skipAccessible, onClick: onSkip, children: labels.skip }), _jsx("span", { className: "faast-tour-popover__spacer" }), stepIndex > 0 && (_jsx(Button, { variant: "secondary", size: "sm", onClick: onPrevious, children: labels.previous })), _jsx(Button, { variant: "primary", size: "sm", onClick: onNext, children: isLast ? labels.finish : labels.next })] })] }), container ?? document.body);
161
+ }
@@ -0,0 +1,22 @@
1
+ import { type IconName } from './Icon.js';
2
+ export interface TourOfferProps {
3
+ open: boolean;
4
+ /** Accessible name of the region ("Recorrido sugerido"). */
5
+ label: string;
6
+ title: string;
7
+ description: string;
8
+ startLabel: string;
9
+ laterLabel: string;
10
+ /** Icon tile. Default `route`. */
11
+ icon?: IconName;
12
+ onStart: () => void;
13
+ onLater: () => void;
14
+ /** Esc pressed while focus is inside the card. */
15
+ onEscape?: () => void;
16
+ className?: string;
17
+ }
18
+ /**
19
+ * A small card, top end of the screen, that offers a contextual tour ("Primera vez en
20
+ * Confirming"). A region, not a dialog: it never takes focus or blocks the page.
21
+ */
22
+ export declare function TourOffer({ open, label, title, description, startLabel, laterLabel, icon, onStart, onLater, onEscape, className, }: TourOfferProps): import("react").ReactPortal | null;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import { cx } from '../utils/cx.js';
5
+ import { Button } from './Button.js';
6
+ import { Icon } from './Icon.js';
7
+ /**
8
+ * A small card, top end of the screen, that offers a contextual tour ("Primera vez en
9
+ * Confirming"). A region, not a dialog: it never takes focus or blocks the page.
10
+ */
11
+ export function TourOffer({ open, label, title, description, startLabel, laterLabel, icon = 'route', onStart, onLater, onEscape, className, }) {
12
+ const ref = useRef(null);
13
+ const onEscapeRef = useRef(onEscape);
14
+ useEffect(() => {
15
+ onEscapeRef.current = onEscape;
16
+ });
17
+ useEffect(() => {
18
+ const el = ref.current;
19
+ if (!open || !el)
20
+ return;
21
+ const onKeyDown = (event) => {
22
+ if (event.key === 'Escape' && onEscapeRef.current) {
23
+ event.stopPropagation();
24
+ onEscapeRef.current();
25
+ }
26
+ };
27
+ el.addEventListener('keydown', onKeyDown);
28
+ return () => el.removeEventListener('keydown', onKeyDown);
29
+ }, [open]);
30
+ if (!open || typeof document === 'undefined')
31
+ return null;
32
+ return createPortal(_jsxs("aside", { ref: ref, className: cx('faast-tour-offer', className), role: "region", "aria-label": label, "data-faast-onboarding": "", children: [_jsxs("div", { className: "faast-tour-offer__head", children: [_jsx("span", { className: "faast-tour-offer__icon", "aria-hidden": "true", children: _jsx(Icon, { name: icon, size: 18 }) }), _jsxs("div", { children: [_jsx("b", { className: "faast-tour-offer__title", children: title }), _jsx("p", { className: "faast-tour-offer__description", children: description })] })] }), _jsxs("div", { className: "faast-tour-offer__actions", children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: onLater, children: laterLabel }), _jsx(Button, { variant: "primary", size: "sm", onClick: onStart, children: startLabel })] })] }), document.body);
33
+ }
@@ -0,0 +1,45 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type IconName } from './Icon.js';
3
+ export interface WelcomeCapability {
4
+ icon: IconName;
5
+ title: string;
6
+ description: string;
7
+ }
8
+ export interface WelcomeDialogProps {
9
+ open: boolean;
10
+ /** The primary action: start the guided tour. */
11
+ onStart: () => void;
12
+ /** "Ahora no": also called on Esc. There is no backdrop close and no X. */
13
+ onLater: () => void;
14
+ /** Small line above the title (the portal name). */
15
+ eyebrow: string;
16
+ title: string;
17
+ description: string;
18
+ /** What the user can do here: short cards. */
19
+ capabilities: readonly WelcomeCapability[];
20
+ /** Accessible name of the capabilities list. */
21
+ capabilitiesLabel: string;
22
+ /** Line under the cards, with an info icon ("Dura menos de 2 minutos..."). */
23
+ note?: ReactNode;
24
+ startLabel: string;
25
+ laterLabel: string;
26
+ /** Icon of the primary button. Default `route`. */
27
+ startIcon?: IconName;
28
+ /** Replaces the default illustration; it is decorative and sits on the dark art band. */
29
+ art?: ReactNode;
30
+ className?: string;
31
+ }
32
+ /**
33
+ * Welcome dialog of a first visit: illustration, title, capability cards and the choice
34
+ * between starting the guided tour and leaving it for later. Native `<dialog>` (focus trap,
35
+ * inert page); the primary button takes focus. Marked `data-faast-onboarding` so the
36
+ * application can tell it apart from foreign modals. A bottom sheet on phones.
37
+ */
38
+ export declare function WelcomeDialog({ open, onStart, onLater, eyebrow, title, description, capabilities, capabilitiesLabel, note, startLabel, laterLabel, startIcon, art, className, }: WelcomeDialogProps): import("react").JSX.Element;
39
+ /**
40
+ * The default welcome illustration: concentric rings, two pulses, a central check tile, two
41
+ * invoices and two coins. Decorative (`aria-hidden`). Colours are the `--faast-welcome-art-*`
42
+ * custom properties of `.faast-welcome-dialog__art`; motion runs only without
43
+ * `prefers-reduced-motion`.
44
+ */
45
+ export declare function WelcomeArt(): import("react").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useId, useRef } from 'react';
3
+ import { cx } from '../utils/cx.js';
4
+ import { useModalDialog } from '../utils/useModalDialog.js';
5
+ import { Button } from './Button.js';
6
+ import { Icon } from './Icon.js';
7
+ /**
8
+ * Welcome dialog of a first visit: illustration, title, capability cards and the choice
9
+ * between starting the guided tour and leaving it for later. Native `<dialog>` (focus trap,
10
+ * inert page); the primary button takes focus. Marked `data-faast-onboarding` so the
11
+ * application can tell it apart from foreign modals. A bottom sheet on phones.
12
+ */
13
+ export function WelcomeDialog({ open, onStart, onLater, eyebrow, title, description, capabilities, capabilitiesLabel, note, startLabel, laterLabel, startIcon = 'route', art, className, }) {
14
+ const ref = useRef(null);
15
+ const startRef = useRef(null);
16
+ const onLaterRef = useRef(onLater);
17
+ const id = useId();
18
+ const titleId = `${id}-title`;
19
+ const descriptionId = `${id}-description`;
20
+ useEffect(() => {
21
+ onLaterRef.current = onLater;
22
+ });
23
+ const focusStart = useCallback(() => startRef.current?.focus(), []);
24
+ useModalDialog(ref, open, focusStart);
25
+ return (_jsx("dialog", { ref: ref, className: cx('faast-welcome-dialog', className), "data-faast-onboarding": "", "aria-modal": "true", "aria-labelledby": titleId, "aria-describedby": descriptionId, onCancel: (event) => {
26
+ event.preventDefault();
27
+ onLaterRef.current();
28
+ }, children: open && (_jsxs(_Fragment, { children: [_jsx("div", { className: "faast-welcome-dialog__art", "aria-hidden": "true", children: art ?? _jsx(WelcomeArt, {}) }), _jsxs("div", { className: "faast-welcome-dialog__body", children: [_jsx("span", { className: "faast-welcome-dialog__eyebrow", children: eyebrow }), _jsx("h2", { className: "faast-welcome-dialog__title", id: titleId, children: title }), _jsx("p", { className: "faast-welcome-dialog__description", id: descriptionId, children: description }), _jsx("ul", { className: "faast-welcome-dialog__caps", "aria-label": capabilitiesLabel, children: capabilities.map((capability) => (_jsxs("li", { children: [_jsx("span", { className: "faast-welcome-dialog__cap-icon", "aria-hidden": "true", children: _jsx(Icon, { name: capability.icon, size: 18 }) }), _jsxs("div", { children: [_jsx("b", { children: capability.title }), _jsx("span", { children: capability.description })] })] }, capability.title))) }), note && (_jsxs("p", { className: "faast-welcome-dialog__note", children: [_jsx(Icon, { name: "info", size: 16 }), _jsx("span", { children: note })] }))] }), _jsxs("div", { className: "faast-welcome-dialog__footer", children: [_jsx(Button, { variant: "ghost", onClick: onLater, children: laterLabel }), _jsx(Button, { ref: startRef, variant: "primary", leadingIcon: _jsx(Icon, { name: startIcon, size: 18 }), onClick: onStart, children: startLabel })] })] })) }));
29
+ }
30
+ /**
31
+ * The default welcome illustration: concentric rings, two pulses, a central check tile, two
32
+ * invoices and two coins. Decorative (`aria-hidden`). Colours are the `--faast-welcome-art-*`
33
+ * custom properties of `.faast-welcome-dialog__art`; motion runs only without
34
+ * `prefers-reduced-motion`.
35
+ */
36
+ export function WelcomeArt() {
37
+ return (_jsxs("svg", { className: "faast-welcome-art", viewBox: "0 0 600 116", preserveAspectRatio: "xMidYMid slice", "aria-hidden": "true", focusable: "false", children: [_jsxs("g", { transform: "translate(300 100)", children: [_jsx("ellipse", { className: "faast-welcome-art__ring faast-welcome-art__ring--1", rx: "90", ry: "26" }), _jsx("ellipse", { className: "faast-welcome-art__ring faast-welcome-art__ring--2", rx: "160", ry: "44" }), _jsx("ellipse", { className: "faast-welcome-art__ring faast-welcome-art__ring--3", rx: "240", ry: "62" })] }), _jsx("path", { className: "faast-welcome-art__link", d: "M130 70 C190 40 240 60 270 62" }), _jsx("path", { className: "faast-welcome-art__pulse", pathLength: "100", d: "M130 70 C190 40 240 60 270 62" }), _jsx("path", { className: "faast-welcome-art__link", d: "M330 62 C370 60 420 40 470 70" }), _jsx("path", { className: "faast-welcome-art__pulse faast-welcome-art__pulse--2", pathLength: "100", d: "M330 62 C370 60 420 40 470 70" }), _jsx("rect", { className: "faast-welcome-art__core", x: "270", y: "30", width: "60", height: "60", rx: "14" }), _jsx("circle", { className: "faast-welcome-art__ok", cx: "300", cy: "60", r: "14" }), _jsx("path", { className: "faast-welcome-art__ok-tick", d: "m293 60 5 5 9-10" }), _jsxs("g", { className: "faast-welcome-art__float faast-welcome-art__float--1", children: [_jsx("rect", { className: "faast-welcome-art__tile", x: "96", y: "46", width: "34", height: "42", rx: "4" }), _jsx("rect", { className: "faast-welcome-art__line", x: "102", y: "55", width: "20", height: "3.5", rx: "1.7" }), _jsx("rect", { className: "faast-welcome-art__line", x: "102", y: "63", width: "22", height: "3.5", rx: "1.7" }), _jsx("rect", { className: "faast-welcome-art__line", x: "102", y: "71", width: "14", height: "3.5", rx: "1.7" })] }), _jsxs("g", { className: "faast-welcome-art__float faast-welcome-art__float--2", children: [_jsx("rect", { className: "faast-welcome-art__tile faast-welcome-art__tile--back", x: "62", y: "64", width: "30", height: "38", rx: "4" }), _jsx("rect", { className: "faast-welcome-art__line", x: "67", y: "72", width: "18", height: "3.5", rx: "1.7" }), _jsx("rect", { className: "faast-welcome-art__line", x: "67", y: "80", width: "14", height: "3.5", rx: "1.7" })] }), _jsxs("g", { className: "faast-welcome-art__float faast-welcome-art__float--3", children: [_jsx("ellipse", { className: "faast-welcome-art__coin-edge", cx: "480", cy: "74", rx: "15", ry: "9" }), _jsx("ellipse", { className: "faast-welcome-art__coin", cx: "480", cy: "70", rx: "15", ry: "9" }), _jsx("text", { className: "faast-welcome-art__coin-text", x: "480", y: "73", textAnchor: "middle", children: "S/" })] }), _jsxs("g", { className: "faast-welcome-art__float faast-welcome-art__float--4", children: [_jsx("ellipse", { className: "faast-welcome-art__coin-edge", cx: "520", cy: "58", rx: "12", ry: "7" }), _jsx("ellipse", { className: "faast-welcome-art__coin", cx: "520", cy: "55", rx: "12", ry: "7" }), _jsx("text", { className: "faast-welcome-art__coin-text faast-welcome-art__coin-text--sm", x: "520", y: "58", textAnchor: "middle", children: "S/" })] })] }));
38
+ }
@@ -0,0 +1,22 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { ClientTableController, DataTableRenderProps } from '../types.js';
3
+ export interface ClientDataTableProps<TRow> extends DataTableRenderProps<TRow> {
4
+ table: ClientTableController<TRow>;
5
+ /** Summary of a whole group across pages, shown in its header row. The app computes and formats it. */
6
+ renderGroupSummary?: (ctx: {
7
+ key: string;
8
+ rows: readonly TRow[];
9
+ selectedRows: readonly TRow[];
10
+ }) => ReactNode;
11
+ /**
12
+ * Summary of the whole result (table footer). With more than one group key render one line
13
+ * per key: never sum amounts of different currencies.
14
+ */
15
+ renderResultSummary?: (ctx: {
16
+ rows: readonly TRow[];
17
+ selectedRows: readonly TRow[];
18
+ groupKeys: readonly string[];
19
+ }) => ReactNode;
20
+ }
21
+ /** Table for a batch the app already holds: sorts, filters, searches and paginates itself. */
22
+ export declare function ClientDataTable<TRow>({ table, renderGroupSummary, renderResultSummary, ...view }: ClientDataTableProps<TRow>): import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { groupKeysOf } from '../core/group.js';
4
+ import { DataTableView } from './DataTableView.js';
5
+ /** Table for a batch the app already holds: sorts, filters, searches and paginates itself. */
6
+ export function ClientDataTable({ table, renderGroupSummary, renderResultSummary, ...view }) {
7
+ const selectedRows = table.selection?.selectedRows;
8
+ const keyOf = table.activeGroup?.key;
9
+ const groupKeys = useMemo(() => (keyOf ? groupKeysOf(table.resultRows, keyOf) : []), [keyOf, table.resultRows]);
10
+ const none = useMemo(() => [], []);
11
+ const groupSummary = renderGroupSummary
12
+ ? (group) => {
13
+ const selectedInGroup = selectedRows && keyOf ? selectedRows.filter((row) => keyOf(row) === group.key) : none;
14
+ return renderGroupSummary({
15
+ key: group.key,
16
+ rows: table.groupRows(group.key),
17
+ selectedRows: selectedInGroup,
18
+ });
19
+ }
20
+ : undefined;
21
+ const resultSummary = renderResultSummary
22
+ ? () => renderResultSummary({
23
+ rows: table.resultRows,
24
+ selectedRows: selectedRows ?? none,
25
+ groupKeys,
26
+ })
27
+ : undefined;
28
+ return (_jsx(DataTableView, { table: table, groupSummary: groupSummary, resultSummary: resultSummary, ...view }));
29
+ }
@@ -0,0 +1,11 @@
1
+ import type { TableController } from '../types.js';
2
+ export interface DataTableFooterProps<TRow> {
3
+ table: TableController<TRow>;
4
+ className?: string;
5
+ }
6
+ /**
7
+ * Result count, rows per page and page navigation. Always rendered under the table,
8
+ * grouped or not: groups are paginated as one list. A page change moves focus to the
9
+ * table caption so keyboard and screen reader users land on the new rows.
10
+ */
11
+ export declare function DataTableFooter<TRow>({ table, className }: DataTableFooterProps<TRow>): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pagination } from '../../components/Pagination.js';
3
+ import { cx } from '../../utils/cx.js';
4
+ import { PageSizeSelect } from '../toolbar/PageSizeSelect.js';
5
+ import { ResultsCount } from '../toolbar/ResultsCount.js';
6
+ /**
7
+ * Result count, rows per page and page navigation. Always rendered under the table,
8
+ * grouped or not: groups are paginated as one list. A page change moves focus to the
9
+ * table caption so keyboard and screen reader users land on the new rows.
10
+ */
11
+ export function DataTableFooter({ table, className }) {
12
+ return (_jsxs("div", { className: cx('faast-dt__footer', className), children: [_jsxs("div", { className: "faast-dt__footer-info", children: [_jsx(ResultsCount, { table: table }), _jsx(PageSizeSelect, { table: table })] }), _jsx(Pagination, { page: table.query.page, pageCount: table.pageCount, live: false, labels: table.labels.pagination, onPageChange: (page) => {
13
+ table.setPage(page);
14
+ table.a11y.focusTable();
15
+ } })] }));
16
+ }
@@ -0,0 +1,9 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { DataTableRenderProps, PageGroup, TableController } from '../types.js';
3
+ export interface DataTableViewProps<TRow> extends DataTableRenderProps<TRow> {
4
+ table: TableController<TRow>;
5
+ groupSummary?: (group: PageGroup<TRow>) => ReactNode;
6
+ resultSummary?: () => ReactNode;
7
+ }
8
+ /** Internal renderer shared by `ClientDataTable` and `ServerDataTable`. */
9
+ export declare function DataTableView<TRow>({ table, caption, captionHidden, mobileLayout, cardsBelow, dense, renderExpanded, expandStyle, actionsHeader, cardActions, renderRowActions, getRowClassName, getRowAttributes, stickyActions, empty, noResults, error, loadingRows, className, groupSummary, resultSummary, }: DataTableViewProps<TRow>): import("react").JSX.Element;
@@ -0,0 +1,95 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment, useEffect, useId, useRef } from 'react';
3
+ import { Alert, ErrorState } from '../../components/Alert.js';
4
+ import { Button } from '../../components/Button.js';
5
+ import { Checkbox } from '../../components/Choice.js';
6
+ import { EmptyState } from '../../components/EmptyState.js';
7
+ import { Icon } from '../../components/Icon.js';
8
+ import { Skeleton } from '../../components/Spinner.js';
9
+ import { Badge } from '../../components/Badge.js';
10
+ import { Tooltip } from '../../components/Tooltip.js';
11
+ import { Table, TableBody, TableCell, TableFoot, TableHead, TableHeaderCell, TableRow, } from '../../components/Table.js';
12
+ import { cx } from '../../utils/cx.js';
13
+ import { sortDirectionOf } from '../core/query.js';
14
+ /** Internal renderer shared by `ClientDataTable` and `ServerDataTable`. */
15
+ export function DataTableView({ table, caption, captionHidden, mobileLayout = 'cards', cardsBelow = 'md', dense, renderExpanded, expandStyle = 'button', actionsHeader = 'hidden', cardActions = 'end', renderRowActions, getRowClassName, getRowAttributes, stickyActions = false, empty, noResults, error, loadingRows, className, groupSummary, resultSummary, }) {
16
+ const baseId = useId();
17
+ const { labels, selection, expansion, visibleColumns, rowModel, status, query } = table;
18
+ const hasActions = Boolean(renderRowActions);
19
+ const columnCount = (selection ? 1 : 0) + (expansion ? 1 : 0) + visibleColumns.length + (hasActions ? 1 : 0);
20
+ const hasRows = table.pageRows.length > 0;
21
+ const chevron = expandStyle === 'chevron';
22
+ // Announce the new sort once, not on first render.
23
+ const sortKey = query.sort ? `${query.sort.columnId}:${query.sort.direction}` : '';
24
+ const lastSort = useRef(null);
25
+ const { announce, registerTable } = table.a11y;
26
+ useEffect(() => {
27
+ if (lastSort.current !== null && lastSort.current !== sortKey && query.sort) {
28
+ const column = table.columns.find((c) => c.id === query.sort?.columnId);
29
+ if (column)
30
+ announce(labels.sortedAnnouncement(column.header, query.sort.direction));
31
+ }
32
+ lastSort.current = sortKey;
33
+ }, [sortKey, query.sort, table.columns, labels, announce]);
34
+ const renderRow = (row, index) => {
35
+ const id = rowModel.getRowId(row);
36
+ const rowLabel = rowModel.getRowLabel(row);
37
+ const selectability = selection?.selectability(row);
38
+ const isSelected = selection?.isSelected(id) ?? false;
39
+ const expandable = Boolean(expansion && rowModel.isRowExpandable?.(row));
40
+ const expanded = expandable && (expansion?.isExpanded(id) ?? false);
41
+ const detailId = `${baseId}-detail-${index}`;
42
+ const reasonId = `${baseId}-reason-${index}`;
43
+ const ctx = {
44
+ rowId: id,
45
+ rowLabel,
46
+ selected: isSelected,
47
+ expanded,
48
+ layout: 'table',
49
+ };
50
+ const blocked = selectability && !selectability.selectable ? selectability : null;
51
+ return (_jsxs(Fragment, { children: [_jsxs(TableRow, { selected: isSelected, disabled: Boolean(blocked), className: cx(getRowClassName?.(row, ctx), expanded && 'faast-table__row--open'), ...getRowAttributes?.(row, { index }), children: [selection && (_jsx(TableCell, { mobile: "select", className: "faast-dt__select", children: _jsx(Checkbox, { labelHidden: true, label: labels.selectRow(rowLabel), checked: isSelected, "aria-disabled": blocked ? true : undefined, "aria-describedby": blocked ? reasonId : undefined,
52
+ // Blocked rows ignore the change; the controlled `checked` restores the box.
53
+ onChange: () => selection.toggleRow(row), onKeyDown: blocked
54
+ ? (event) => {
55
+ if (event.key === ' ')
56
+ event.preventDefault();
57
+ }
58
+ : undefined }) })), expansion && (_jsx(TableCell, { mobile: "expand", className: cx('faast-dt__expand', chevron && 'faast-dt__expand--chevron'), children: expandable && (_jsx("button", { type: "button", className: cx('faast-dt__expand-button', chevron && 'faast-dt__expand-button--chevron'), "aria-expanded": expanded, "aria-controls": expanded ? detailId : undefined, "aria-label": expanded ? labels.collapse(rowLabel) : labels.expand(rowLabel), onClick: () => expansion.toggle(id), children: chevron ? (_jsx(Icon, { name: "chevron-right", size: 18 })) : (_jsxs(_Fragment, { children: [_jsx(Icon, { name: expanded ? 'chevron-up' : 'chevron-down', size: 16 }), _jsx("span", { className: "faast-dt__expand-text", children: expanded ? labels.hideDetail : labels.showDetail })] })) })) })), visibleColumns.map((column) => renderCell(column, row, ctx, blocked, reasonId)), hasActions && (_jsx(TableCell, { mobile: "actions", className: "faast-dt__actions", children: renderRowActions?.(row, ctx) }))] }), expanded && renderExpanded && (_jsx(TableRow, { kind: "expanded", children: _jsx(TableCell, { colSpan: columnCount, children: _jsx("div", { id: detailId, role: "region", "aria-label": labels.detailOf(rowLabel), className: "faast-dt__expanded", children: renderExpanded(row) }) }) }))] }, id));
59
+ };
60
+ const renderCell = (column, row, ctx, blocked, reasonId) => {
61
+ const content = column.cell(row, ctx);
62
+ const slot = column.mobile ?? (column.rowHeader ? 'title' : 'meta');
63
+ if (column.rowHeader) {
64
+ return (_jsxs(TableHeaderCell, { scope: "row", mobile: slot, numeric: column.numeric, className: cx('faast-dt__row-header', column.className), children: [content, blocked &&
65
+ (blocked.shortReason ? (_jsx("span", { className: "faast-dt__reason faast-dt__reason--short", children: _jsx(Tooltip, { content: blocked.reason, id: reasonId, placement: "bottom", children: _jsxs(Badge, { tone: "warning", tabIndex: 0, children: [_jsx(Icon, { name: "triangle-alert", size: 12 }), blocked.shortReason] }) }) })) : (_jsx("span", { id: reasonId, className: "faast-dt__reason", children: blocked.reason })))] }, column.id));
66
+ }
67
+ return (_jsx(TableCell, { mobile: slot, label: column.header, numeric: column.numeric, className: column.className, children: content }, column.id));
68
+ };
69
+ const stateRow = (content) => (_jsx(TableBody, { children: _jsx(TableRow, { children: _jsx(TableCell, { colSpan: columnCount, className: "faast-dt__state", children: content }) }) }));
70
+ const retry = table.retry;
71
+ let body;
72
+ if (status === 'loading' && !hasRows) {
73
+ const count = loadingRows ?? Math.min(query.pageSize, 5);
74
+ body = (_jsx(TableBody, { "aria-hidden": "true", children: Array.from({ length: count }, (_, i) => (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columnCount, className: "faast-dt__state faast-dt__skeleton", children: _jsx(Skeleton, { height: "1.25rem" }) }) }, i))) }));
75
+ }
76
+ else if (status === 'error' && !hasRows) {
77
+ body = stateRow(error ? (error(retry)) : (_jsx(ErrorState, { title: labels.error, onRetry: retry, retryLabel: labels.retry })));
78
+ }
79
+ else if (table.isEmpty) {
80
+ body = stateRow(empty ?? _jsx(EmptyState, { title: labels.emptyTitle }));
81
+ }
82
+ else if (!hasRows && table.rowCount === 0 && status !== 'loading') {
83
+ body = stateRow(noResults ?? (_jsx(EmptyState, { title: labels.noResultsTitle, description: labels.noResultsDescription, action: table.hasActiveQuery ? (_jsx(Button, { variant: "secondary", onClick: table.clearFilters, children: labels.clearFilters })) : undefined })));
84
+ }
85
+ else if (table.pageGroups) {
86
+ body = table.pageGroups.map((group) => (_jsxs(TableBody, { children: [_jsx(TableRow, { kind: "group", children: _jsx(TableHeaderCell, { scope: "rowgroup", colSpan: columnCount, children: _jsxs("span", { className: "faast-dt__group", children: [_jsxs("span", { className: "faast-dt__group-label", children: [group.label, group.continuesFromPreviousPage && (_jsxs("span", { className: "faast-dt__group-continues", children: [" ", labels.groupContinues] }))] }), groupSummary && (_jsx("span", { className: "faast-dt__group-summary", children: groupSummary(group) }))] }) }) }), group.rows.map((row) => renderRow(row, table.pageRows.indexOf(row)))] }, group.key)));
87
+ }
88
+ else {
89
+ body = _jsx(TableBody, { children: table.pageRows.map((row, i) => renderRow(row, i)) });
90
+ }
91
+ const summary = hasRows && resultSummary ? resultSummary() : null;
92
+ return (_jsxs("div", { className: cx('faast-dt', stickyActions && 'faast-dt--sticky-actions', chevron && 'faast-dt--expand-chevron', cardActions === 'start' && 'faast-dt--actions-start', className), "data-kind": table.kind, children: [_jsx("div", { className: "faast-sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true", children: table.a11y.liveMessage }), status === 'error' && hasRows && (_jsx(Alert, { status: "danger", className: "faast-dt__alert", action: retry ? (_jsx(Button, { variant: "secondary", onClick: retry, children: labels.retry })) : undefined, children: labels.refreshError })), status === 'refreshing' && _jsx("div", { className: "faast-dt__progress", "aria-hidden": "true" }), _jsxs(Table, { caption: caption, captionHidden: captionHidden, ref: registerTable, tabIndex: -1, responsive: mobileLayout === 'scroll' ? 'scroll' : 'cards', cardsBelow: cardsBelow, busy: status === 'refreshing', dense: dense, className: "faast-dt__table", children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [selection && (_jsx(TableHeaderCell, { mobile: "hidden", className: "faast-dt__select", children: _jsx(Checkbox, { labelHidden: true, label: selection.scope === 'results'
93
+ ? labels.selectAllResults(selection.header.scopeCount)
94
+ : labels.selectPage(selection.header.scopeCount), checked: selection.header.state === 'all', indeterminate: selection.header.state === 'some', disabled: selection.header.state === 'disabled', onChange: selection.header.toggle }) })), expansion && (_jsx(TableHeaderCell, { mobile: "hidden", className: "faast-dt__expand", children: _jsx("span", { className: "faast-sr-only", children: labels.expandColumn }) })), visibleColumns.map((column) => (_jsx(TableHeaderCell, { numeric: column.numeric, mobile: "hidden", sortDirection: column.sort ? sortDirectionOf(query.sort, column.id) : undefined, onSort: column.sort ? () => table.toggleSort(column.id) : undefined, children: column.headerHidden ? (_jsx("span", { className: "faast-sr-only", children: column.header })) : ((column.headerContent ?? column.header)) }, column.id))), hasActions && (_jsx(TableHeaderCell, { mobile: "hidden", className: cx('faast-dt__actions-head', actionsHeader === 'visible' && 'is-visible'), children: actionsHeader === 'visible' ? (labels.rowActions) : (_jsx("span", { className: "faast-sr-only", children: labels.rowActions })) }))] }) }), body, summary && (_jsx(TableFoot, { children: _jsx(TableRow, { children: _jsx(TableCell, { colSpan: columnCount, className: "faast-dt__summary", children: summary }) }) }))] })] }));
95
+ }
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { DataTableRenderProps, ServerTableController } from '../types.js';
3
+ export interface ServerDataTableProps<TRow, TSummary = never> extends DataTableRenderProps<TRow> {
4
+ table: ServerTableController<TRow, TSummary>;
5
+ /** Summary of a group from the response (`summaries.byGroup[key]`). */
6
+ renderGroupSummary?: (ctx: {
7
+ key: string;
8
+ summary: TSummary | undefined;
9
+ }) => ReactNode;
10
+ /** Summary of the whole result from the response (`summaries.total`). */
11
+ renderResultSummary?: (ctx: {
12
+ summary: TSummary | undefined;
13
+ }) => ReactNode;
14
+ }
15
+ /** Table that renders one page the app fetched for the query the table produces. */
16
+ export declare function ServerDataTable<TRow, TSummary = never>({ table, renderGroupSummary, renderResultSummary, ...view }: ServerDataTableProps<TRow, TSummary>): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { DataTableView } from './DataTableView.js';
3
+ /** Table that renders one page the app fetched for the query the table produces. */
4
+ export function ServerDataTable({ table, renderGroupSummary, renderResultSummary, ...view }) {
5
+ // Keys come from the backend: only own properties, never `constructor` or `__proto__`.
6
+ const groupSummaryOf = (key) => {
7
+ const byGroup = table.summaries?.byGroup;
8
+ return byGroup && Object.prototype.hasOwnProperty.call(byGroup, key) ? byGroup[key] : undefined;
9
+ };
10
+ const groupSummary = renderGroupSummary
11
+ ? (group) => renderGroupSummary({ key: group.key, summary: groupSummaryOf(group.key) })
12
+ : undefined;
13
+ const resultSummary = renderResultSummary
14
+ ? () => renderResultSummary({ summary: table.summaries?.total })
15
+ : undefined;
16
+ return (_jsx(DataTableView, { table: table, groupSummary: groupSummary, resultSummary: resultSummary, ...view }));
17
+ }
@@ -0,0 +1,15 @@
1
+ export interface VisibilityColumn {
2
+ id: string;
3
+ hideable?: boolean;
4
+ defaultHidden?: boolean;
5
+ rowHeader?: boolean;
6
+ }
7
+ export declare const isHideable: (column: VisibilityColumn) => boolean;
8
+ export declare function defaultHiddenColumns(columns: readonly VisibilityColumn[]): ReadonlySet<string>;
9
+ /**
10
+ * Validates JSON the app read from `localStorage` (untrusted): an array of at most 50
11
+ * known, hideable ids. Anything else yields the defaults.
12
+ */
13
+ export declare function parseColumnVisibility(raw: unknown, columns: readonly VisibilityColumn[]): ReadonlySet<string>;
14
+ /** Toggles a column; never hides the last visible column nor a non-hideable one. */
15
+ export declare function toggleColumnHidden(hidden: ReadonlySet<string>, id: string, columns: readonly VisibilityColumn[]): ReadonlySet<string>;
@@ -0,0 +1,34 @@
1
+ const MAX_STORED_IDS = 50;
2
+ export const isHideable = (column) => column.hideable !== false && !column.rowHeader;
3
+ export function defaultHiddenColumns(columns) {
4
+ return new Set(columns.filter((c) => isHideable(c) && c.defaultHidden).map((c) => c.id));
5
+ }
6
+ /**
7
+ * Validates JSON the app read from `localStorage` (untrusted): an array of at most 50
8
+ * known, hideable ids. Anything else yields the defaults.
9
+ */
10
+ export function parseColumnVisibility(raw, columns) {
11
+ if (!Array.isArray(raw) || raw.length > MAX_STORED_IDS)
12
+ return defaultHiddenColumns(columns);
13
+ const hideable = new Set(columns.filter(isHideable).map((c) => c.id));
14
+ const hidden = new Set();
15
+ for (const id of raw) {
16
+ if (typeof id !== 'string' || !hideable.has(id))
17
+ return defaultHiddenColumns(columns);
18
+ hidden.add(id);
19
+ }
20
+ return hidden;
21
+ }
22
+ /** Toggles a column; never hides the last visible column nor a non-hideable one. */
23
+ export function toggleColumnHidden(hidden, id, columns) {
24
+ const column = columns.find((c) => c.id === id);
25
+ if (!column || !isHideable(column))
26
+ return hidden;
27
+ const next = new Set(hidden);
28
+ if (next.has(id)) {
29
+ next.delete(id);
30
+ return next;
31
+ }
32
+ next.add(id);
33
+ return columns.every((c) => next.has(c.id)) ? hidden : next;
34
+ }
@@ -0,0 +1,20 @@
1
+ export declare const PAGE_SIZE_OPTIONS: readonly [10, 25, 50, 100];
2
+ export type PageSize = (typeof PAGE_SIZE_OPTIONS)[number];
3
+ export declare const DEFAULT_PAGE_SIZE: PageSize;
4
+ /** Hard maximum rows per page. Nothing in the data tables renders more. */
5
+ export declare const MAX_PAGE_SIZE = 100;
6
+ /** Idle time before typing in the search field is applied. */
7
+ export declare const SEARCH_DEBOUNCE_MS = 300;
8
+ /** The "Cargando…" announcement waits this long so fast loads stay silent. */
9
+ export declare const LOADING_ANNOUNCE_DELAY_MS = 400;
10
+ export declare const MAX_SEARCH_LENGTH = 100;
11
+ /** Ids of columns, filters, groups and quick filters (URLs, storage keys, React keys). */
12
+ export declare const ID_PATTERN: RegExp;
13
+ /** Values of select/multiselect options. */
14
+ export declare const OPTION_VALUE_PATTERN: RegExp;
15
+ export declare const MAX_MULTISELECT_VALUES = 20;
16
+ export declare const MAX_URL_VALUE_LENGTH = 256;
17
+ export declare const MAX_URL_PARAMS_READ = 50;
18
+ /** Reserved quick filter id meaning "no quick filter". */
19
+ export declare const ALL_QUICK_FILTER = "all";
20
+ export declare function isPageSize(value: unknown): value is PageSize;