@faast-app/ui 0.0.0-stage → 0.7.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 (173) hide show
  1. package/README.md +13 -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/styles.css +4668 -0
  157. package/dist/theme/ThemeProvider.d.ts +33 -0
  158. package/dist/theme/ThemeProvider.js +77 -0
  159. package/dist/theme/ThemeToggle.d.ts +16 -0
  160. package/dist/theme/ThemeToggle.js +27 -0
  161. package/dist/utils/cx.d.ts +2 -0
  162. package/dist/utils/cx.js +4 -0
  163. package/dist/utils/devWarn.d.ts +2 -0
  164. package/dist/utils/devWarn.js +10 -0
  165. package/dist/utils/tourGeometry.d.ts +61 -0
  166. package/dist/utils/tourGeometry.js +135 -0
  167. package/dist/utils/useFloatingPosition.d.ts +9 -0
  168. package/dist/utils/useFloatingPosition.js +45 -0
  169. package/dist/utils/useModalDialog.d.ts +7 -0
  170. package/dist/utils/useModalDialog.js +49 -0
  171. package/dist/utils/useTourAnchorRect.d.ts +6 -0
  172. package/dist/utils/useTourAnchorRect.js +40 -0
  173. package/package.json +50 -4
@@ -0,0 +1,28 @@
1
+ import type { HTMLAttributes, ReactNode } from 'react';
2
+ export interface StickyActionBarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
3
+ /** Accessible name of the bar ("Enviar solicitud"). Required. */
4
+ label: string;
5
+ /** Small line on the left (12px): a summary or the reason the action is blocked. */
6
+ info?: ReactNode;
7
+ /** Emphasised figure under `info` (15px, accent), e.g. the net amount. */
8
+ value?: ReactNode;
9
+ /** The primary action, usually a `Button` with `softDisabled` while it is blocked. */
10
+ action: ReactNode;
11
+ /**
12
+ * Viewport width, in px, from which the bar is hidden because the screen shows the same
13
+ * action in the page header. `'never'` keeps it at every width. Default 900.
14
+ */
15
+ hideFrom?: 768 | 900 | 1024 | 'never';
16
+ /**
17
+ * Render an invisible spacer before the bar so the end of the page is not covered by it.
18
+ * Default `true`.
19
+ */
20
+ spacer?: boolean;
21
+ }
22
+ /**
23
+ * Phone action bar pinned to the bottom of the viewport (raised surface, top border, shadow,
24
+ * safe-area padding): a short summary on the left and the primary action on the right. It is
25
+ * not for content: never put the only copy of important information here. Sits below dialogs
26
+ * and toasts and, from 768px, to the right of the sidebar.
27
+ */
28
+ export declare function StickyActionBar({ label, info, value, action, hideFrom, spacer, className, ...rest }: StickyActionBarProps): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { cx } from '../utils/cx.js';
3
+ /**
4
+ * Phone action bar pinned to the bottom of the viewport (raised surface, top border, shadow,
5
+ * safe-area padding): a short summary on the left and the primary action on the right. It is
6
+ * not for content: never put the only copy of important information here. Sits below dialogs
7
+ * and toasts and, from 768px, to the right of the sidebar.
8
+ */
9
+ export function StickyActionBar({ label, info, value, action, hideFrom = 900, spacer = true, className, ...rest }) {
10
+ const hideClass = hideFrom === 'never' ? undefined : `faast-sticky-bar--hide-${hideFrom}`;
11
+ return (_jsxs(_Fragment, { children: [spacer && (_jsx("div", { "aria-hidden": "true", className: cx('faast-sticky-bar__spacer', hideClass && `faast-sticky-bar__spacer--${hideFrom}`) })), _jsxs("div", { role: "region", "aria-label": label, className: cx('faast-sticky-bar', hideClass, className), ...rest, children: [_jsxs("div", { className: "faast-sticky-bar__info", children: [info && _jsx("p", { className: "faast-sticky-bar__text", children: info }), value && _jsx("p", { className: "faast-sticky-bar__value faast-num", children: value })] }), _jsx("div", { className: "faast-sticky-bar__action", children: action })] })] }));
12
+ }
@@ -0,0 +1,69 @@
1
+ import { type HTMLAttributes, type Ref, type ReactNode, type TdHTMLAttributes, type ThHTMLAttributes } from 'react';
2
+ export interface TableProps extends HTMLAttributes<HTMLTableElement> {
3
+ /** Table caption (required for an accessible name). */
4
+ caption: ReactNode;
5
+ /** Keep the caption for assistive technology only. Default `false`. */
6
+ captionHidden?: boolean;
7
+ /**
8
+ * Phone strategy below the md breakpoint:
9
+ * - `scroll` (default): the table scrolls inside its own frame, first column sticky.
10
+ * - `stack`: each row becomes a two-column list (give every TableCell a `label`).
11
+ * - `cards`: each row becomes a card (give TableCells a `mobile` slot and a `label`). The
12
+ * page scrolls; the table never creates a vertical scroll container, and it scrolls
13
+ * horizontally only when a wide table really overflows.
14
+ */
15
+ responsive?: 'scroll' | 'stack' | 'cards';
16
+ /** Where `cards` start: below `md` (768px, default) or below `lg` (1024px). */
17
+ cardsBelow?: 'md' | 'lg';
18
+ /** Denser rows for long working sessions. Default `false`. */
19
+ dense?: boolean;
20
+ /** The content is being refreshed: sets `aria-busy`. */
21
+ busy?: boolean;
22
+ /** Ref to the `<caption>` (e.g. to focus it after a page change). */
23
+ captionRef?: Ref<HTMLTableCaptionElement>;
24
+ /**
25
+ * Make the caption a programmatic focus target (`tabIndex=-1`). Use it only with the
26
+ * `scroll` layout: a focusable caption is not allowed inside the explicit `table` role of
27
+ * `stack` and `cards` (focus the table itself with `tabIndex={-1}` there).
28
+ */
29
+ captionFocusable?: boolean;
30
+ }
31
+ /** Semantic data table: rules and alignment, no zebra stripes, numbers right-aligned. */
32
+ export declare const Table: import("react").ForwardRefExoticComponent<TableProps & import("react").RefAttributes<HTMLTableElement>>;
33
+ export declare function TableHead(props: HTMLAttributes<HTMLTableSectionElement>): import("react").JSX.Element;
34
+ export declare function TableBody(props: HTMLAttributes<HTMLTableSectionElement>): import("react").JSX.Element;
35
+ export declare function TableFoot(props: HTMLAttributes<HTMLTableSectionElement>): import("react").JSX.Element;
36
+ export interface TableRowProps extends HTMLAttributes<HTMLTableRowElement> {
37
+ /** Selected row: tinted background (the checked checkbox is the real signal). */
38
+ selected?: boolean;
39
+ /** Muted row, e.g. one that cannot be selected. */
40
+ disabled?: boolean;
41
+ /** `group`: a group heading row; `expanded`: the detail row attached to the row above. */
42
+ kind?: 'data' | 'group' | 'expanded';
43
+ }
44
+ export declare function TableRow({ selected, disabled, kind, className, ...rest }: TableRowProps): import("react").JSX.Element;
45
+ export type SortDirection = 'ascending' | 'descending' | 'none';
46
+ export interface TableHeaderCellProps extends ThHTMLAttributes<HTMLTableCellElement> {
47
+ /** Right-align (numbers). */
48
+ numeric?: boolean;
49
+ /** Current sort of this column. Provide with `onSort` to make the header sortable. */
50
+ sortDirection?: SortDirection;
51
+ onSort?: () => void;
52
+ /** Placement in the `cards` layout (a row header is usually `title`). */
53
+ mobile?: TableCellMobileSlot;
54
+ }
55
+ export declare function TableHeaderCell({ numeric, sortDirection, onSort, mobile, scope, className, children, ...rest }: TableHeaderCellProps): import("react").JSX.Element;
56
+ export interface TableCellProps extends TdHTMLAttributes<HTMLTableCellElement> {
57
+ numeric?: boolean;
58
+ /** Column name shown before the value in the `stack` layout on phones. */
59
+ label?: string;
60
+ /** Secondary text style. */
61
+ muted?: boolean;
62
+ /**
63
+ * Placement in the `cards` layout; ignored elsewhere. Default `meta`. `full` is its own
64
+ * full-width line without a label.
65
+ */
66
+ mobile?: TableCellMobileSlot;
67
+ }
68
+ export type TableCellMobileSlot = 'select' | 'title' | 'subtitle' | 'meta' | 'amount' | 'status' | 'actions' | 'expand' | 'detail' | 'full' | 'hidden';
69
+ export declare function TableCell({ numeric, label, muted, mobile, className, ...rest }: TableCellProps): import("react").JSX.Element;
@@ -0,0 +1,73 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, forwardRef, useContext, useEffect, useId, useRef, useState, } from 'react';
3
+ import { cx } from '../utils/cx.js';
4
+ import { Icon } from './Icon.js';
5
+ /**
6
+ * Layouts that switch the table to `display: block/grid` on phones drop the native table
7
+ * semantics in some browser and screen reader pairs, so they declare the roles explicitly.
8
+ */
9
+ const ExplicitRolesContext = createContext(false);
10
+ /** Semantic data table: rules and alignment, no zebra stripes, numbers right-aligned. */
11
+ export const Table = forwardRef(function Table({ caption, captionHidden = false, responsive = 'scroll', cardsBelow = 'md', dense = false, busy = false, captionRef, captionFocusable = false, className, children, ...rest }, ref) {
12
+ const captionId = `${useId()}-caption`;
13
+ const explicitRoles = responsive === 'stack' || responsive === 'cards';
14
+ const wrapRef = useRef(null);
15
+ const [overflowing, setOverflowing] = useState(false);
16
+ useEffect(() => {
17
+ const wrap = wrapRef.current;
18
+ if (responsive !== 'cards' || !wrap || typeof ResizeObserver === 'undefined')
19
+ return;
20
+ const measure = () => setOverflowing(wrap.scrollWidth > wrap.clientWidth + 1);
21
+ measure();
22
+ const observer = new ResizeObserver(measure);
23
+ observer.observe(wrap);
24
+ if (wrap.firstElementChild)
25
+ observer.observe(wrap.firstElementChild);
26
+ return () => observer.disconnect();
27
+ }, [responsive]);
28
+ const table = (_jsxs("table", { ref: ref, className: cx('faast-table', `faast-table--${responsive}`, responsive === 'cards' && cardsBelow === 'lg' && 'faast-table--cards-lg', dense && 'faast-table--dense', className), role: explicitRoles ? 'table' : undefined, "aria-busy": busy || undefined, ...rest, children: [_jsx("caption", { id: captionId, ref: captionRef, tabIndex: captionFocusable ? -1 : undefined, className: cx('faast-table__caption', captionHidden && 'faast-sr-only'), children: caption }), _jsx(ExplicitRolesContext.Provider, { value: explicitRoles, children: children })] }));
29
+ if (responsive === 'stack')
30
+ return _jsx("div", { className: "faast-table-wrap", children: table });
31
+ if (responsive === 'cards') {
32
+ // Only a table that really overflows becomes a focusable, named scroll region.
33
+ return (_jsx("div", { ref: wrapRef, className: cx('faast-table-wrap', 'faast-table-wrap--cards', cardsBelow === 'lg' && 'faast-table-wrap--cards-lg'), role: overflowing ? 'region' : undefined, "aria-labelledby": overflowing ? captionId : undefined,
34
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- only set together with role="region" while the table overflows
35
+ tabIndex: overflowing ? 0 : undefined, children: table }));
36
+ }
37
+ return (
38
+ // A focusable, named region lets keyboard users scroll a wide table (WCAG 2.1.1).
39
+ _jsx("div", { className: "faast-table-wrap faast-table-wrap--scroll", role: "region", "aria-labelledby": captionId, tabIndex: 0, children: table }));
40
+ });
41
+ export function TableHead(props) {
42
+ const explicit = useContext(ExplicitRolesContext);
43
+ return _jsx("thead", { role: explicit ? 'rowgroup' : undefined, ...props });
44
+ }
45
+ export function TableBody(props) {
46
+ const explicit = useContext(ExplicitRolesContext);
47
+ return _jsx("tbody", { role: explicit ? 'rowgroup' : undefined, ...props });
48
+ }
49
+ export function TableFoot(props) {
50
+ const explicit = useContext(ExplicitRolesContext);
51
+ return _jsx("tfoot", { role: explicit ? 'rowgroup' : undefined, ...props });
52
+ }
53
+ export function TableRow({ selected = false, disabled = false, kind = 'data', className, ...rest }) {
54
+ const explicit = useContext(ExplicitRolesContext);
55
+ return (_jsx("tr", { role: explicit ? 'row' : undefined, "data-selected": selected || undefined, className: cx('faast-table__row', selected && 'faast-table__row--selected', disabled && 'faast-table__row--disabled', kind !== 'data' && `faast-table__row--${kind}`, className), ...rest }));
56
+ }
57
+ export function TableHeaderCell({ numeric = false, sortDirection, onSort, mobile, scope = 'col', className, children, ...rest }) {
58
+ const explicit = useContext(ExplicitRolesContext);
59
+ const sorted = sortDirection === 'ascending' || sortDirection === 'descending';
60
+ return (_jsx("th", { scope: scope, role: explicit
61
+ ? scope === 'row' || scope === 'rowgroup'
62
+ ? 'rowheader'
63
+ : 'columnheader'
64
+ : undefined, "data-slot": mobile, "aria-sort": onSort && sorted ? sortDirection : undefined, className: cx('faast-table__th', numeric && 'faast-table__cell--numeric', className), ...rest, children: onSort ? (_jsxs("button", { type: "button", className: cx('faast-table__sort', sorted && 'faast-table__sort--active'), onClick: onSort, children: [_jsx("span", { children: children }), _jsx(Icon, { name: sortDirection === 'ascending'
65
+ ? 'arrow-up'
66
+ : sortDirection === 'descending'
67
+ ? 'arrow-down'
68
+ : 'arrow-up-down', size: 16 })] })) : (children) }));
69
+ }
70
+ export function TableCell({ numeric = false, label, muted = false, mobile, className, ...rest }) {
71
+ const explicit = useContext(ExplicitRolesContext);
72
+ return (_jsx("td", { role: explicit ? 'cell' : undefined, "data-label": label, "data-slot": mobile, className: cx('faast-table__cell', numeric && 'faast-table__cell--numeric', muted && 'faast-table__cell--muted', className), ...rest }));
73
+ }
@@ -0,0 +1,27 @@
1
+ import type { HTMLAttributes } from 'react';
2
+ export interface TenantMarkProps extends HTMLAttributes<HTMLSpanElement> {
3
+ /** Tenant display name: the text wordmark when there is no logo, and the default `alt`. */
4
+ name: string;
5
+ /** Tenant logo URL (from configuration). Without it the name is shown as text. */
6
+ logoSrc?: string;
7
+ /** Logo for dark surfaces; follows the theme like `Logo`. */
8
+ logoSrcOnDark?: string;
9
+ /** Logo accessible name. Default: `name`. Pass "" when the name is written next to it. */
10
+ alt?: string;
11
+ /** Maximum logo height in px; width follows the image. Default 32. */
12
+ maxHeight?: number;
13
+ /**
14
+ * Rendered logo width in px at `maxHeight`, when the configuration knows the logo's
15
+ * aspect ratio. Reserves the box before the image loads (no layout shift).
16
+ */
17
+ logoWidth?: number;
18
+ /** `default` for app surfaces, `on-brand` for the dark brand panel. */
19
+ tone?: 'default' | 'on-brand';
20
+ /** Text size of the wordmark fallback. Default `md`. */
21
+ size?: 'md' | 'lg';
22
+ }
23
+ /**
24
+ * The tenant's mark: its logo when configured, otherwise its name as a text wordmark
25
+ * (long names wrap to two lines). Generic installations use `Logo` (FaaST) instead.
26
+ */
27
+ export declare function TenantMark({ name, logoSrc, logoSrcOnDark, alt, maxHeight, logoWidth, tone, size, className, ...rest }: TenantMarkProps): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from '../utils/cx.js';
3
+ /**
4
+ * The tenant's mark: its logo when configured, otherwise its name as a text wordmark
5
+ * (long names wrap to two lines). Generic installations use `Logo` (FaaST) instead.
6
+ */
7
+ export function TenantMark({ name, logoSrc, logoSrcOnDark, alt, maxHeight = 32, logoWidth, tone = 'default', size = 'md', className, ...rest }) {
8
+ const classes = cx('faast-tenant-mark', `faast-tenant-mark--${tone}`, `faast-tenant-mark--${size}`, className);
9
+ if (!logoSrc) {
10
+ return (_jsx("span", { className: classes, translate: "no", ...rest, children: _jsx("span", { className: "faast-tenant-mark__text", children: name }) }));
11
+ }
12
+ const variant = logoSrcOnDark ? (tone === 'on-brand' ? 'dark' : 'auto') : 'light';
13
+ const imgStyle = { maxHeight, height: maxHeight };
14
+ return (_jsxs("span", { className: cx(classes, 'faast-logo', `faast-logo--${variant}`), translate: "no", ...rest, children: [_jsx("img", { className: "faast-tenant-mark__img faast-logo__img faast-logo__img--light", src: logoSrc, alt: alt ?? name, height: maxHeight, width: logoWidth, style: imgStyle, decoding: "async" }), logoSrcOnDark && (_jsx("img", { className: "faast-tenant-mark__img faast-logo__img faast-logo__img--dark", src: logoSrcOnDark, alt: alt ?? name, height: maxHeight, width: logoWidth, style: imgStyle, decoding: "async" }))] }));
15
+ }
@@ -0,0 +1,31 @@
1
+ import type { ReactNode } from 'react';
2
+ export type TimelineState = 'done' | 'current' | 'pending' | 'warning' | 'danger';
3
+ export interface TimelineItem {
4
+ id: string;
5
+ /** What happened or will happen ("Operación enviada"). */
6
+ title: ReactNode;
7
+ /** Date or note on its own line ("05/11/2026", "Pendiente", the reason of an observation). */
8
+ meta?: ReactNode;
9
+ state: TimelineState;
10
+ }
11
+ export interface TimelineStateLabels {
12
+ done: string;
13
+ current: string;
14
+ pending: string;
15
+ warning: string;
16
+ danger: string;
17
+ }
18
+ export interface TimelineProps {
19
+ items: readonly TimelineItem[];
20
+ /** Accessible name of the list ("Seguimiento de la operación"). Required. */
21
+ label: string;
22
+ /** State words read after each title (colour is never the only signal). Spanish by default. */
23
+ stateLabels?: Partial<TimelineStateLabels>;
24
+ className?: string;
25
+ }
26
+ /**
27
+ * Vertical steps joined by a rail: a dot per step (filled accent when done, ringed when
28
+ * current, status colour for warning and danger, hollow when pending), the title and the
29
+ * meta text on separate lines. An ordered list; the current step has `aria-current="step"`.
30
+ */
31
+ export declare function Timeline({ items, label, stateLabels, className }: TimelineProps): import("react").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from '../utils/cx.js';
3
+ const DEFAULT_STATE_LABELS = {
4
+ done: 'Completado',
5
+ current: 'En curso',
6
+ pending: 'Pendiente',
7
+ warning: 'Con observaciones',
8
+ danger: 'Con problemas',
9
+ };
10
+ /**
11
+ * Vertical steps joined by a rail: a dot per step (filled accent when done, ringed when
12
+ * current, status colour for warning and danger, hollow when pending), the title and the
13
+ * meta text on separate lines. An ordered list; the current step has `aria-current="step"`.
14
+ */
15
+ export function Timeline({ items, label, stateLabels, className }) {
16
+ const words = { ...DEFAULT_STATE_LABELS, ...stateLabels };
17
+ return (_jsx("ol", { className: cx('faast-timeline', className), "aria-label": label, children: items.map((item) => (_jsxs("li", { className: cx('faast-timeline__item', `faast-timeline__item--${item.state}`), "aria-current": item.state === 'current' ? 'step' : undefined, children: [_jsx("span", { className: "faast-timeline__dot", "aria-hidden": "true" }), _jsxs("p", { className: "faast-timeline__title", children: [item.title, _jsxs("span", { className: "faast-sr-only", children: [". ", words[item.state]] })] }), item.meta != null && _jsx("p", { className: "faast-timeline__meta", children: item.meta })] }, item.id))) }));
18
+ }
@@ -0,0 +1,43 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type IconName } from './Icon.js';
3
+ export interface ToastProps {
4
+ children: ReactNode;
5
+ icon?: IconName;
6
+ /**
7
+ * Milliseconds before `onDismiss` is called. Default 5000; `null` keeps the toast until
8
+ * dismissed. The timer pauses while the pointer or focus is on the toast.
9
+ */
10
+ duration?: number | null;
11
+ onDismiss?: () => void;
12
+ /** Accessible name of the close button. Default "Cerrar Aviso". Omit `onDismiss` to hide it. */
13
+ dismissLabel?: string;
14
+ className?: string;
15
+ }
16
+ /**
17
+ * Short, non-blocking confirmation (`role="status"`, polite). Not for errors that need
18
+ * action: use `Alert` for those.
19
+ */
20
+ export declare function Toast({ children, icon, duration, onDismiss, dismissLabel, className, }: ToastProps): import("react").JSX.Element;
21
+ export interface ToastOptions {
22
+ icon?: IconName;
23
+ duration?: number | null;
24
+ }
25
+ export interface ToastContextValue {
26
+ /** Shows a toast and returns its id. */
27
+ show: (message: ReactNode, options?: ToastOptions) => number;
28
+ dismiss: (id: number) => void;
29
+ }
30
+ export interface ToastProviderProps {
31
+ children: ReactNode;
32
+ /** Default duration for every toast. Default 5000 ms. */
33
+ duration?: number | null;
34
+ /** At most this many toasts are visible; older ones are dropped. Default 3. */
35
+ max?: number;
36
+ /** Name of the toast region. Default "Notificaciones". */
37
+ regionLabel?: string;
38
+ dismissLabel?: string;
39
+ }
40
+ /** Holds the toast queue and renders it in a fixed region at the bottom of the viewport. */
41
+ export declare function ToastProvider({ children, duration, max, regionLabel, dismissLabel, }: ToastProviderProps): import("react").JSX.Element;
42
+ /** `show` / `dismiss` from the nearest ToastProvider. */
43
+ export declare function useToast(): ToastContextValue;
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
3
+ import { cx } from '../utils/cx.js';
4
+ import { IconButton } from './Button.js';
5
+ import { Icon } from './Icon.js';
6
+ /**
7
+ * Short, non-blocking confirmation (`role="status"`, polite). Not for errors that need
8
+ * action: use `Alert` for those.
9
+ */
10
+ export function Toast({ children, icon, duration = 5000, onDismiss, dismissLabel = 'Cerrar Aviso', className, }) {
11
+ const [paused, setPaused] = useState(false);
12
+ const onDismissRef = useRef(onDismiss);
13
+ useEffect(() => {
14
+ onDismissRef.current = onDismiss;
15
+ });
16
+ useEffect(() => {
17
+ if (duration === null || paused)
18
+ return;
19
+ const timer = window.setTimeout(() => onDismissRef.current?.(), duration);
20
+ return () => window.clearTimeout(timer);
21
+ }, [duration, paused]);
22
+ return (_jsxs("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", className: cx('faast-toast', className), onPointerEnter: () => setPaused(true), onPointerLeave: () => setPaused(false), onFocus: () => setPaused(true), onBlur: () => setPaused(false), "data-testid": "toast", children: [icon && _jsx(Icon, { name: icon, className: "faast-toast__icon" }), _jsx("span", { className: "faast-toast__message", children: children }), onDismiss && (_jsx(IconButton, { className: "faast-toast__close", label: dismissLabel, icon: _jsx(Icon, { name: "x", size: 16 }), onClick: onDismiss }))] }));
23
+ }
24
+ const ToastContext = createContext(null);
25
+ /** Holds the toast queue and renders it in a fixed region at the bottom of the viewport. */
26
+ export function ToastProvider({ children, duration = 5000, max = 3, regionLabel = 'Notificaciones', dismissLabel, }) {
27
+ const [items, setItems] = useState([]);
28
+ const nextId = useRef(1);
29
+ const dismiss = useCallback((id) => {
30
+ setItems((current) => current.filter((item) => item.id !== id));
31
+ }, []);
32
+ const show = useCallback((message, options = {}) => {
33
+ const id = nextId.current++;
34
+ setItems((current) => [...current, { id, message, ...options }].slice(-max));
35
+ return id;
36
+ }, [max]);
37
+ const value = useMemo(() => ({ show, dismiss }), [show, dismiss]);
38
+ return (_jsxs(ToastContext.Provider, { value: value, children: [children, _jsx("section", { className: "faast-toaster", "aria-label": regionLabel, children: items.map((item) => (_jsx(Toast, { icon: item.icon, duration: item.duration === undefined ? duration : item.duration, onDismiss: () => dismiss(item.id), dismissLabel: dismissLabel, children: item.message }, item.id))) })] }));
39
+ }
40
+ /** `show` / `dismiss` from the nearest ToastProvider. */
41
+ export function useToast() {
42
+ const context = useContext(ToastContext);
43
+ if (!context)
44
+ throw new Error('useToast must be used inside a ToastProvider');
45
+ return context;
46
+ }
@@ -0,0 +1,26 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type FloatingPlacement } from '../utils/useFloatingPosition.js';
3
+ import { type IconName } from './Icon.js';
4
+ export interface ToggletipProps {
5
+ /** Text of the trigger button ("Ver motivo"). */
6
+ label: ReactNode;
7
+ /** Content of the popover: text, a list, an instruction. */
8
+ children: ReactNode;
9
+ /** Icon before the label. Default `info`. */
10
+ icon?: IconName;
11
+ /** Colour of the trigger. Default `neutral`. */
12
+ tone?: 'neutral' | 'danger' | 'warning';
13
+ /** Preferred side of the popover; it flips when there is no room. Default `bottom`. */
14
+ placement?: FloatingPlacement;
15
+ className?: string;
16
+ 'data-testid'?: string;
17
+ /** `data-testid` of the popover. */
18
+ panelTestId?: string;
19
+ }
20
+ /**
21
+ * Click or tap popover for richer content (a reasons list, an instruction): a text button with
22
+ * `aria-expanded` and a popover that stays open until Esc, an outside press, a second
23
+ * activation or focus leaving. Works with keyboard and touch; the popover follows the button in
24
+ * the DOM so it is read right after it. For a short hint on hover and focus use `Tooltip`.
25
+ */
26
+ export declare function Toggletip({ label, children, icon, tone, placement, className, 'data-testid': testId, panelTestId, }: ToggletipProps): import("react").JSX.Element;
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef, useState } from 'react';
3
+ import { cx } from '../utils/cx.js';
4
+ import { useFloatingPosition } from '../utils/useFloatingPosition.js';
5
+ import { Icon } from './Icon.js';
6
+ /**
7
+ * Click or tap popover for richer content (a reasons list, an instruction): a text button with
8
+ * `aria-expanded` and a popover that stays open until Esc, an outside press, a second
9
+ * activation or focus leaving. Works with keyboard and touch; the popover follows the button in
10
+ * the DOM so it is read right after it. For a short hint on hover and focus use `Tooltip`.
11
+ */
12
+ export function Toggletip({ label, children, icon = 'info', tone = 'neutral', placement = 'bottom', className, 'data-testid': testId, panelTestId, }) {
13
+ const panelId = `faast-toggletip-${useId()}`;
14
+ const [open, setOpen] = useState(false);
15
+ const wrapperRef = useRef(null);
16
+ const triggerRef = useRef(null);
17
+ const panelRef = useRef(null);
18
+ useFloatingPosition(triggerRef, panelRef, open, placement);
19
+ useEffect(() => {
20
+ if (!open)
21
+ return;
22
+ const onKeyDown = (event) => {
23
+ if (event.key !== 'Escape')
24
+ return;
25
+ event.stopPropagation();
26
+ event.preventDefault();
27
+ setOpen(false);
28
+ triggerRef.current?.focus();
29
+ };
30
+ const onPointerDown = (event) => {
31
+ if (!wrapperRef.current?.contains(event.target))
32
+ setOpen(false);
33
+ };
34
+ document.addEventListener('keydown', onKeyDown, true);
35
+ document.addEventListener('pointerdown', onPointerDown, true);
36
+ return () => {
37
+ document.removeEventListener('keydown', onKeyDown, true);
38
+ document.removeEventListener('pointerdown', onPointerDown, true);
39
+ };
40
+ }, [open]);
41
+ return (_jsxs("span", { ref: wrapperRef, className: cx('faast-toggletip', className), onBlur: (event) => {
42
+ if (open && !wrapperRef.current?.contains(event.relatedTarget))
43
+ setOpen(false);
44
+ }, children: [_jsxs("button", { ref: triggerRef, type: "button", className: cx('faast-toggletip__trigger', `faast-toggletip__trigger--${tone}`), "aria-expanded": open, "aria-controls": open ? panelId : undefined, "data-testid": testId, onClick: () => {
45
+ setOpen((value) => !value);
46
+ }, children: [_jsx(Icon, { name: icon, size: 14 }), _jsx("span", { children: label })] }), open && (_jsx("div", { ref: panelRef, id: panelId, className: "faast-toggletip__panel", "data-testid": panelTestId, children: children }))] }));
47
+ }
@@ -0,0 +1,24 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ import { type FloatingPlacement } from '../utils/useFloatingPosition.js';
3
+ export interface TooltipProps {
4
+ /** Short hint (one or two lines). Empty content turns the tooltip off but keeps the tree stable. */
5
+ content: ReactNode;
6
+ /** The one element the hint describes: it receives `aria-describedby`. */
7
+ children: ReactElement<{
8
+ 'aria-describedby'?: string;
9
+ }>;
10
+ /** Preferred side; it flips when there is no room. Default `top`. */
11
+ placement?: FloatingPlacement;
12
+ /** Id of the tooltip element, for another control that must also point at it. */
13
+ id?: string;
14
+ /** Taps and clicks on the trigger show the hint too (touch screens, soft-disabled buttons). Default `true`. */
15
+ showOnTap?: boolean;
16
+ className?: string;
17
+ }
18
+ /**
19
+ * Hover and focus tooltip for short hints. The text is always in the DOM (visually hidden while
20
+ * closed) and linked to the trigger with `aria-describedby`, so it is announced even if it is
21
+ * never shown. Esc closes it; it is hoverable and stays until pointer and focus leave.
22
+ * For richer content opened on demand use `Toggletip`.
23
+ */
24
+ export declare function Tooltip({ content, children, placement, id, showOnTap, className, }: TooltipProps): import("react").JSX.Element;
@@ -0,0 +1,73 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cloneElement, useEffect, useId, useRef, useState, } from 'react';
3
+ import { cx } from '../utils/cx.js';
4
+ import { useFloatingPosition } from '../utils/useFloatingPosition.js';
5
+ /**
6
+ * Hover and focus tooltip for short hints. The text is always in the DOM (visually hidden while
7
+ * closed) and linked to the trigger with `aria-describedby`, so it is announced even if it is
8
+ * never shown. Esc closes it; it is hoverable and stays until pointer and focus leave.
9
+ * For richer content opened on demand use `Toggletip`.
10
+ */
11
+ export function Tooltip({ content, children, placement = 'top', id, showOnTap = true, className, }) {
12
+ const auto = useId();
13
+ const tipId = id ?? `faast-tip-${auto}`;
14
+ const [hover, setHover] = useState(false);
15
+ const [focus, setFocus] = useState(false);
16
+ const [tap, setTap] = useState(false);
17
+ const wrapperRef = useRef(null);
18
+ const bubbleRef = useRef(null);
19
+ const active = content !== null && content !== undefined && content !== false && content !== '';
20
+ const open = active && (hover || focus || tap);
21
+ useFloatingPosition(wrapperRef, bubbleRef, open, placement);
22
+ useEffect(() => {
23
+ if (!open)
24
+ return;
25
+ const onKeyDown = (event) => {
26
+ if (event.key !== 'Escape')
27
+ return;
28
+ event.stopPropagation();
29
+ setHover(false);
30
+ setFocus(false);
31
+ setTap(false);
32
+ };
33
+ const onPointerDown = (event) => {
34
+ if (!wrapperRef.current?.contains(event.target))
35
+ setTap(false);
36
+ };
37
+ document.addEventListener('keydown', onKeyDown, true);
38
+ document.addEventListener('pointerdown', onPointerDown, true);
39
+ return () => {
40
+ document.removeEventListener('keydown', onKeyDown, true);
41
+ document.removeEventListener('pointerdown', onPointerDown, true);
42
+ };
43
+ }, [open]);
44
+ // A tap or click on the trigger shows the hint (touch screens, soft-disabled buttons).
45
+ useEffect(() => {
46
+ const wrapper = wrapperRef.current;
47
+ if (!wrapper || !showOnTap)
48
+ return;
49
+ const onClick = () => {
50
+ setTap(true);
51
+ };
52
+ wrapper.addEventListener('click', onClick);
53
+ return () => {
54
+ wrapper.removeEventListener('click', onClick);
55
+ };
56
+ }, [showOnTap]);
57
+ const own = children.props['aria-describedby'];
58
+ return (_jsxs("span", { ref: wrapperRef, className: cx('faast-tip', className), onMouseEnter: () => {
59
+ setHover(true);
60
+ }, onMouseLeave: () => {
61
+ setHover(false);
62
+ setTap(false);
63
+ }, onFocus: () => {
64
+ setFocus(true);
65
+ }, onBlur: (event) => {
66
+ if (!wrapperRef.current?.contains(event.relatedTarget))
67
+ setFocus(false);
68
+ }, children: [active
69
+ ? cloneElement(children, {
70
+ 'aria-describedby': [tipId, own].filter(Boolean).join(' '),
71
+ })
72
+ : children, active && (_jsx("span", { ref: bubbleRef, id: tipId, role: "tooltip", className: cx('faast-tip__bubble', open && 'faast-tip__bubble--open'), children: content }))] }));
73
+ }
@@ -0,0 +1,66 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type TourSide } from '../utils/tourGeometry.js';
3
+ export interface TourProgressProps {
4
+ /** Number of steps. */
5
+ count: number;
6
+ /** Zero-based index of the current step. */
7
+ current: number;
8
+ className?: string;
9
+ }
10
+ /** One dot per step: done, the current one as a pill, and pending. Decorative (`aria-hidden`). */
11
+ export declare function TourProgress({ count, current, className }: TourProgressProps): import("react").JSX.Element;
12
+ export interface TourSpotlightProps {
13
+ /**
14
+ * Elements to highlight; the hole covers their union. Keep the array stable between renders
15
+ * (state or `useMemo`). `null` or empty shows the full scrim without a hole.
16
+ */
17
+ targets: readonly Element[] | null;
18
+ /** Element made `inert` while the tour runs (the application root). */
19
+ inertRoot: HTMLElement | null;
20
+ /** Space around the target. Default 6. */
21
+ padding?: number;
22
+ /** Where to portal the layer. Default `document.body`. */
23
+ container?: HTMLElement;
24
+ }
25
+ /**
26
+ * Full-screen scrim with a cut-out around the target. Blocks interaction with the page: the
27
+ * `inertRoot` becomes inert, clicks on the blocker do nothing and `<html>` gets
28
+ * `faast-tour-active` (extra bottom padding on phones so the bottom sheet never hides content).
29
+ */
30
+ export declare function TourSpotlight({ targets, inertRoot, padding, container, }: TourSpotlightProps): import("react").ReactPortal | null;
31
+ export interface TourPopoverLabels {
32
+ previous: string;
33
+ next: string;
34
+ finish: string;
35
+ skip: string;
36
+ /** Accessible name of the skip button ("Omitir recorrido"). */
37
+ skipAccessible: string;
38
+ }
39
+ export interface TourPopoverProps {
40
+ open: boolean;
41
+ /** Union rect of the highlighted target (from `useTourAnchorRect`). */
42
+ anchorRect: DOMRectReadOnly | null;
43
+ /** Preferred side; flips when it does not fit. */
44
+ placement: TourSide;
45
+ /** Zero-based index of the current step. */
46
+ stepIndex: number;
47
+ stepCount: number;
48
+ /** "Paso 2 de 9". */
49
+ stepLabel: string;
50
+ title: ReactNode;
51
+ body: ReactNode;
52
+ labels: TourPopoverLabels;
53
+ onPrevious: () => void;
54
+ onNext: () => void;
55
+ onSkip: () => void;
56
+ /** Viewport width below which it becomes a bottom sheet. Default 640. */
57
+ sheetBelow?: 640 | 768 | 'never';
58
+ container?: HTMLElement;
59
+ }
60
+ /**
61
+ * The step card: a `dialog` (the page behind is inert) with the step label, progress, title,
62
+ * body and Omitir / Anterior / Siguiente. Esc skips, the arrows move, Tab stays inside, and
63
+ * focus returns to the card on every step. Below `sheetBelow` it is a bottom sheet (or a top
64
+ * sheet when the target sits in the lower half of the screen).
65
+ */
66
+ export declare function TourPopover({ open, anchorRect, placement, stepIndex, stepCount, stepLabel, title, body, labels, onPrevious, onNext, onSkip, sheetBelow, container, }: TourPopoverProps): import("react").ReactPortal | null;