@faast-app/ui 0.7.0 → 0.9.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.
@@ -1,4 +1,5 @@
1
1
  import { type InputHTMLAttributes, type ReactNode, type TextareaHTMLAttributes } from 'react';
2
+ import { type FieldMessagePlacement } from './FormField.js';
2
3
  import { type IconName } from './Icon.js';
3
4
  /** Props a control takes from the surrounding FormField unless set explicitly. */
4
5
  export declare function useFieldProps<P extends {
@@ -12,7 +13,14 @@ export declare function useFieldProps<P extends {
12
13
  'aria-describedby': string | undefined;
13
14
  'aria-invalid': boolean | "false" | "true" | "grammar" | "spelling" | undefined;
14
15
  };
16
+ export type ControlSize = 'md' | 'lg';
15
17
  export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
18
+ /**
19
+ * `lg` is a 48px field on every pointer (DSN-005 N15), only for surfaces whose design
20
+ * contract fixes 48px (the sign-in). Default `md` (44px; 36px with a fine pointer from 768px).
21
+ * It is `controlSize` and not `size` because `size` is the native numeric attribute.
22
+ */
23
+ controlSize?: ControlSize;
16
24
  /** Decorative icon inside the field, before the text. Tinted with the accent on focus. */
17
25
  leadingIcon?: IconName;
18
26
  /**
@@ -29,6 +37,10 @@ export interface TextFieldProps extends InputProps {
29
37
  label: ReactNode;
30
38
  hint?: ReactNode;
31
39
  error?: ReactNode;
40
+ /** `inside` shows the error in the field's box (DSN-005 N11). See `FormField`. */
41
+ messagePlacement?: FieldMessagePlacement;
42
+ /** Second line of an `inside` message. See `FormField`. */
43
+ errorDetail?: ReactNode;
32
44
  fieldClassName?: string;
33
45
  /** Content right under the control, before hint and error (e.g. password requirements). */
34
46
  afterControl?: ReactNode;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, } from 'react';
3
3
  import { cx } from '../utils/cx.js';
4
- import { FormField, mergeDescribedBy, useFormField } from './FormField.js';
4
+ import { FormField, mergeDescribedBy, useFormField, } from './FormField.js';
5
5
  import { Icon } from './Icon.js';
6
6
  /** Props a control takes from the surrounding FormField unless set explicitly. */
7
7
  export function useFieldProps(props) {
@@ -14,18 +14,18 @@ export function useFieldProps(props) {
14
14
  };
15
15
  }
16
16
  /** Text input. 16px text (no iOS zoom), 44px tall on touch. */
17
- export const Input = forwardRef(function Input({ className, type = 'text', leadingIcon, trailingAction, ...rest }, ref) {
17
+ export const Input = forwardRef(function Input({ className, type = 'text', controlSize = 'md', leadingIcon, trailingAction, ...rest }, ref) {
18
18
  const field = useFieldProps(rest);
19
- const input = (_jsx("input", { ref: ref, type: type, className: cx('faast-input', leadingIcon && 'faast-input--leading', trailingAction != null && 'faast-input--trailing', className), ...rest, ...field }));
19
+ const input = (_jsx("input", { ref: ref, type: type, className: cx('faast-input', leadingIcon && 'faast-input--leading', trailingAction != null && 'faast-input--trailing', controlSize === 'lg' && 'faast-input--lg', className), ...rest, ...field }));
20
20
  if (!leadingIcon && trailingAction == null)
21
21
  return input;
22
- return (_jsxs("span", { className: "faast-input-wrap", children: [leadingIcon && _jsx(Icon, { name: leadingIcon, className: "faast-input-wrap__leading" }), input, trailingAction != null && (_jsx("span", { className: "faast-input-wrap__trailing", children: trailingAction }))] }));
22
+ return (_jsxs("span", { className: cx('faast-input-wrap', controlSize === 'lg' && 'faast-input-wrap--lg'), children: [leadingIcon && _jsx(Icon, { name: leadingIcon, className: "faast-input-wrap__leading" }), input, trailingAction != null && (_jsx("span", { className: "faast-input-wrap__trailing", children: trailingAction }))] }));
23
23
  });
24
24
  export const Textarea = forwardRef(function Textarea({ className, rows = 4, ...rest }, ref) {
25
25
  const field = useFieldProps(rest);
26
26
  return (_jsx("textarea", { ref: ref, rows: rows, className: cx('faast-input', 'faast-textarea', className), ...rest, ...field }));
27
27
  });
28
28
  /** FormField + Input in one component. */
29
- export const TextField = forwardRef(function TextField({ label, hint, error, required, id, fieldClassName, afterControl, ...rest }, ref) {
30
- return (_jsxs(FormField, { label: label, hint: hint, error: error, required: required, id: id, className: fieldClassName, children: [_jsx(Input, { ref: ref, ...rest }), afterControl] }));
29
+ export const TextField = forwardRef(function TextField({ label, hint, error, messagePlacement, errorDetail, required, id, fieldClassName, afterControl, ...rest }, ref) {
30
+ return (_jsxs(FormField, { label: label, hint: hint, error: error, messagePlacement: messagePlacement, errorDetail: errorDetail, afterBox: messagePlacement === 'inside' ? afterControl : undefined, required: required, id: id, className: fieldClassName, children: [_jsx(Input, { ref: ref, ...rest }), messagePlacement !== 'inside' && afterControl] }));
31
31
  });
@@ -1,5 +1,11 @@
1
1
  import type { ReactNode } from 'react';
2
2
  export type StepState = 'done' | 'current' | 'pending';
3
+ /**
4
+ * `responsive` (default): the row of markers from 640px of window width, the compact form below.
5
+ * `compact`: always the compact form, whatever the window width. For narrow panels (a 384px
6
+ * sign-in card) that stay narrow on a desktop window.
7
+ */
8
+ export type StepperVariant = 'responsive' | 'compact';
3
9
  export interface StepperStep {
4
10
  id: string;
5
11
  label: string;
@@ -16,6 +22,11 @@ export interface StepperProps {
16
22
  compactLabel?: (current: number, total: number, stepLabel: string) => ReactNode;
17
23
  /** Words read after each step name. Defaults are Spanish. */
18
24
  stateLabels?: Partial<Record<StepState, string>>;
25
+ /**
26
+ * `responsive` (default) keeps today's behaviour. `compact` renders only "Paso N de M · name"
27
+ * with the progress bar, without the list, at any width. `stateLabels` is not used then.
28
+ */
29
+ variant?: StepperVariant;
19
30
  className?: string;
20
31
  }
21
32
  /**
@@ -23,4 +34,4 @@ export interface StepperProps {
23
34
  * From 640px it is a full-width row of numbered markers joined by connectors; below 640px it
24
35
  * collapses to "Paso 1 de 3 · Nombre" with a thin progress bar. Not interactive.
25
36
  */
26
- export declare function Stepper({ steps, label, compactLabel, stateLabels, className, }: StepperProps): import("react").JSX.Element;
37
+ export declare function Stepper({ steps, label, compactLabel, stateLabels, variant, className, }: StepperProps): import("react").JSX.Element;
@@ -14,7 +14,7 @@ function defaultCompactLabel(current, total, stepLabel) {
14
14
  * From 640px it is a full-width row of numbered markers joined by connectors; below 640px it
15
15
  * collapses to "Paso 1 de 3 · Nombre" with a thin progress bar. Not interactive.
16
16
  */
17
- export function Stepper({ steps, label, compactLabel = defaultCompactLabel, stateLabels, className, }) {
17
+ export function Stepper({ steps, label, compactLabel = defaultCompactLabel, stateLabels, variant = 'responsive', className, }) {
18
18
  const words = { ...DEFAULT_STATE_LABELS, ...stateLabels };
19
19
  const total = steps.length;
20
20
  const currentIndex = steps.findIndex((step) => step.state === 'current');
@@ -22,5 +22,6 @@ export function Stepper({ steps, label, compactLabel = defaultCompactLabel, stat
22
22
  const position = currentIndex >= 0 ? currentIndex + 1 : Math.min(doneCount + 1, total);
23
23
  const currentStep = steps[position - 1];
24
24
  const progress = total === 0 ? 0 : Math.round((position / total) * 100);
25
- return (_jsxs("nav", { "aria-label": label, className: cx('faast-stepper', className), children: [_jsx("ol", { className: "faast-stepper__list", children: steps.map((step, index) => (_jsxs("li", { className: cx('faast-stepper__step', `faast-stepper__step--${step.state}`), "aria-current": step.state === 'current' ? 'step' : undefined, children: [_jsx("span", { className: "faast-stepper__marker", "aria-hidden": "true", children: step.state === 'done' ? (_jsx(Icon, { name: "check", size: 14, strokeWidth: 2.75 })) : (index + 1) }), _jsx("span", { className: "faast-stepper__label", children: step.label }), _jsx("span", { className: "faast-sr-only", children: `, ${words[step.state]}` })] }, step.id))) }), currentStep && (_jsxs("div", { className: "faast-stepper__compact", children: [_jsx("p", { className: "faast-stepper__compact-text", children: compactLabel(position, total, currentStep.label) }), _jsx("div", { className: "faast-stepper__bar", "aria-hidden": "true", children: _jsx("span", { style: { width: `${progress}%` } }) })] }))] }));
25
+ const isCompact = variant === 'compact';
26
+ return (_jsxs("nav", { "aria-label": label, className: cx('faast-stepper', isCompact && 'faast-stepper--compact', className), children: [!isCompact && (_jsx("ol", { className: "faast-stepper__list", children: steps.map((step, index) => (_jsxs("li", { className: cx('faast-stepper__step', `faast-stepper__step--${step.state}`), "aria-current": step.state === 'current' ? 'step' : undefined, children: [_jsx("span", { className: "faast-stepper__marker", "aria-hidden": "true", children: step.state === 'done' ? (_jsx(Icon, { name: "check", size: 14, strokeWidth: 2.75 })) : (index + 1) }), _jsx("span", { className: "faast-stepper__label", children: step.label }), _jsx("span", { className: "faast-sr-only", children: `, ${words[step.state]}` })] }, step.id))) })), currentStep && (_jsxs("div", { className: "faast-stepper__compact", children: [_jsx("p", { className: "faast-stepper__compact-text", children: compactLabel(position, total, currentStep.label) }), _jsx("div", { className: "faast-stepper__bar", "aria-hidden": "true", children: _jsx("span", { style: { width: `${progress}%` } }) })] }))] }));
26
27
  }
@@ -0,0 +1,90 @@
1
+ import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type HTMLAttributes, type ReactNode } from 'react';
2
+ import { type IconName } from './Icon.js';
3
+ export type SummaryCardVariant = 'default' | 'featured';
4
+ export type SummaryCardSize = 'md' | 'sm';
5
+ export interface SummaryCardProps extends HTMLAttributes<HTMLElement> {
6
+ /**
7
+ * The emphasis of the card, as `variant` is on `Button`: `default` is a white card; `featured`
8
+ * is the one highlighted card of a group, in the soft brand colour (`accent.soft`). Use one
9
+ * `featured` per group of cards, never several.
10
+ */
11
+ variant?: SummaryCardVariant;
12
+ /**
13
+ * `md` (default) is the card of a page, with the notch, the shadow and the diagonal blocks;
14
+ * `sm` is a flat mini card for a dialog or a dense panel: `bg.sunken`, a subtle border, no
15
+ * shadow and no blocks, so it does not read as a card inside a card.
16
+ */
17
+ size?: SummaryCardSize;
18
+ /** Heading level of the title (`SummaryCardHeader`). Default 2. */
19
+ level?: 2 | 3 | 4;
20
+ /**
21
+ * The figures are being refreshed: sets `aria-busy`, replaces the value, the footer and the note
22
+ * with placeholders of the same size (the card does not change height) and pauses the action.
23
+ */
24
+ busy?: boolean;
25
+ /** Text read in place of the value while `busy`. Default "Cargando…". */
26
+ busyLabel?: string;
27
+ }
28
+ /**
29
+ * One headline figure of a report: a title with an icon, a big number with its currency code,
30
+ * a footer line and, optionally, a round action in the notch of the top-right corner that takes
31
+ * the user to the list behind the figure. The notch is CSS (a radial mask on a decorative
32
+ * layer): no image, and it follows the theme, the tenant brand and dark mode.
33
+ *
34
+ * Compose the parts in this order: `SummaryCardHeader`, `SummaryCardValue`, `SummaryCardFooter`,
35
+ * `SummaryCardNote`, `SummaryCardAction`. It is an `article` named by its title. The app formats
36
+ * the figure (`Intl`) and never calculates it: the totals come from the backend.
37
+ *
38
+ * Without a `SummaryCardAction` the card has no notch and does not lift on hover.
39
+ */
40
+ export declare const SummaryCard: import("react").ForwardRefExoticComponent<SummaryCardProps & import("react").RefAttributes<HTMLElement>>;
41
+ export interface SummaryCardHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
42
+ /** A decorative `<Icon>` (it sits in a round bubble and is hidden from assistive technology). */
43
+ icon?: ReactNode;
44
+ /** What the figure is ("Saldo Documento"). It names the card. */
45
+ title: ReactNode;
46
+ }
47
+ export declare function SummaryCardHeader({ icon, title, className, ...rest }: SummaryCardHeaderProps): import("react").JSX.Element;
48
+ export interface SummaryCardValueProps extends Omit<HTMLAttributes<HTMLParagraphElement>, 'children'> {
49
+ /**
50
+ * The figure, already formatted by the app (`Intl.NumberFormat`, "5.935.306.693"). Never a
51
+ * calculation: the backend gives the total. `null` or `undefined` shows "—" and reads
52
+ * `emptyLabel`.
53
+ */
54
+ value?: ReactNode | null;
55
+ /** Currency or unit code next to the figure ("COP", "PEN"). */
56
+ unit?: ReactNode;
57
+ /** Text read for a missing figure. Default "Sin dato". */
58
+ emptyLabel?: string;
59
+ }
60
+ export declare function SummaryCardValue({ value, unit, emptyLabel, className, ...rest }: SummaryCardValueProps): import("react").JSX.Element;
61
+ export type SummaryCardFooterProps = HTMLAttributes<HTMLDivElement>;
62
+ /** One line under the figure: a `Badge` with the datum and a short text ("de 83 documentos"). */
63
+ export declare function SummaryCardFooter({ className, children, ...rest }: SummaryCardFooterProps): import("react").JSX.Element;
64
+ export interface SummaryCardNoteProps extends HTMLAttributes<HTMLParagraphElement> {
65
+ /** A decorative `<Icon>` before the text. */
66
+ icon?: ReactNode;
67
+ }
68
+ /**
69
+ * A line of small text under the footer, e.g. "Actualizado a las 14:32". While `busy` it becomes
70
+ * a placeholder line of the same height, so the card does not change size.
71
+ */
72
+ export declare function SummaryCardNote({ icon, className, children, ...rest }: SummaryCardNoteProps): import("react").JSX.Element;
73
+ interface SummaryCardActionBase {
74
+ /** Accessible name of the round button ("Ver documentos con saldo"). Required: it has no text. */
75
+ label: string;
76
+ /** Icon of the button. Default `arrow-up-right`. */
77
+ icon?: IconName;
78
+ }
79
+ export type SummaryCardActionProps = (SummaryCardActionBase & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'aria-label' | 'children'> & {
80
+ href?: undefined;
81
+ }) | (SummaryCardActionBase & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'aria-label' | 'children'> & {
82
+ href: string;
83
+ });
84
+ /**
85
+ * The round control in the notch of the corner. A `button` (`onClick`) or, with `href`, a link
86
+ * (for a router link pass its own `onClick` with `preventDefault()`). 44px, with its own focus
87
+ * ring. While the card is `busy` it is `aria-disabled` and ignores clicks.
88
+ */
89
+ export declare function SummaryCardAction(props: SummaryCardActionProps): import("react").JSX.Element;
90
+ export {};
@@ -0,0 +1,85 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { createContext, forwardRef, useContext, useId, } from 'react';
3
+ import { cx } from '../utils/cx.js';
4
+ import { Icon } from './Icon.js';
5
+ import { Skeleton } from './Spinner.js';
6
+ const SummaryCardContext = createContext(null);
7
+ function useSummaryCard(part) {
8
+ const ctx = useContext(SummaryCardContext);
9
+ if (!ctx)
10
+ throw new Error(`${part} must be rendered inside <SummaryCard>`);
11
+ return ctx;
12
+ }
13
+ /**
14
+ * One headline figure of a report: a title with an icon, a big number with its currency code,
15
+ * a footer line and, optionally, a round action in the notch of the top-right corner that takes
16
+ * the user to the list behind the figure. The notch is CSS (a radial mask on a decorative
17
+ * layer): no image, and it follows the theme, the tenant brand and dark mode.
18
+ *
19
+ * Compose the parts in this order: `SummaryCardHeader`, `SummaryCardValue`, `SummaryCardFooter`,
20
+ * `SummaryCardNote`, `SummaryCardAction`. It is an `article` named by its title. The app formats
21
+ * the figure (`Intl`) and never calculates it: the totals come from the backend.
22
+ *
23
+ * Without a `SummaryCardAction` the card has no notch and does not lift on hover.
24
+ */
25
+ export const SummaryCard = forwardRef(function SummaryCard({ variant = 'default', size = 'md', level = 2, busy = false, busyLabel = 'Cargando…', className, children, ...rest }, ref) {
26
+ const titleId = useId();
27
+ return (_jsx(SummaryCardContext.Provider, { value: { titleId, level, busy, busyLabel }, children: _jsxs("article", { ref: ref, "aria-labelledby": titleId, "aria-busy": busy || undefined, className: cx('faast-summary-card', variant === 'featured' && 'faast-summary-card--featured', size === 'sm' && 'faast-summary-card--sm', className), ...rest, children: [_jsx("span", { className: "faast-summary-card__surface", "aria-hidden": "true", children: _jsx("span", { className: "faast-summary-card__shape" }) }), _jsx("div", { className: "faast-summary-card__content", children: children })] }) }));
28
+ });
29
+ export function SummaryCardHeader({ icon, title, className, ...rest }) {
30
+ const { titleId, level } = useSummaryCard('SummaryCardHeader');
31
+ const Heading = `h${level}`;
32
+ return (_jsxs("div", { className: cx('faast-summary-card__top', className), ...rest, children: [icon && (_jsx("span", { className: "faast-summary-card__icon", "aria-hidden": "true", children: icon })), _jsx(Heading, { id: titleId, className: "faast-summary-card__title", children: title })] }));
33
+ }
34
+ export function SummaryCardValue({ value, unit, emptyLabel = 'Sin dato', className, ...rest }) {
35
+ const { busy, busyLabel } = useSummaryCard('SummaryCardValue');
36
+ const missing = value === null || value === undefined || value === '';
37
+ return (_jsx("p", { className: cx('faast-summary-card__value faast-num', className), ...rest, children: busy ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "faast-skeleton faast-skeleton--md faast-summary-card__value-placeholder", "aria-hidden": "true" }), _jsx("span", { className: "faast-sr-only", children: busyLabel })] })) : missing ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", children: "\u2014" }), _jsx("span", { className: "faast-sr-only", children: emptyLabel })] })) : (_jsxs(_Fragment, { children: [value, unit != null && _jsx("span", { className: "faast-summary-card__unit", children: unit })] })) }));
38
+ }
39
+ /** One line under the figure: a `Badge` with the datum and a short text ("de 83 documentos"). */
40
+ export function SummaryCardFooter({ className, children, ...rest }) {
41
+ const { busy } = useSummaryCard('SummaryCardFooter');
42
+ return (_jsx("div", { className: cx('faast-summary-card__footer', className), ...rest, children: busy ? _jsx(Skeleton, { width: "55%", height: "1.5rem", radius: "full" }) : children }));
43
+ }
44
+ /**
45
+ * A line of small text under the footer, e.g. "Actualizado a las 14:32". While `busy` it becomes
46
+ * a placeholder line of the same height, so the card does not change size.
47
+ */
48
+ export function SummaryCardNote({ icon, className, children, ...rest }) {
49
+ const { busy } = useSummaryCard('SummaryCardNote');
50
+ return (_jsx("p", { className: cx('faast-summary-card__note', className), ...rest, children: busy ? (_jsx("span", { className: "faast-skeleton faast-skeleton--xs faast-summary-card__note-placeholder", "aria-hidden": "true" })) : (_jsxs(_Fragment, { children: [icon && (_jsx("span", { className: "faast-summary-card__note-icon", "aria-hidden": "true", children: icon })), children] })) }));
51
+ }
52
+ /**
53
+ * The round control in the notch of the corner. A `button` (`onClick`) or, with `href`, a link
54
+ * (for a router link pass its own `onClick` with `preventDefault()`). 44px, with its own focus
55
+ * ring. While the card is `busy` it is `aria-disabled` and ignores clicks.
56
+ */
57
+ export function SummaryCardAction(props) {
58
+ const { busy } = useSummaryCard('SummaryCardAction');
59
+ const { label, icon = 'arrow-up-right', className, ...rest } = props;
60
+ const guard = (event) => {
61
+ if (busy)
62
+ event.preventDefault();
63
+ };
64
+ const common = {
65
+ 'aria-label': label,
66
+ 'aria-disabled': busy || undefined,
67
+ tabIndex: busy ? -1 : undefined,
68
+ className: cx('faast-summary-card__action', className),
69
+ };
70
+ const glyph = _jsx(Icon, { name: icon, size: 18 });
71
+ if ('href' in rest && rest.href !== undefined) {
72
+ const { onClick, href, ...anchor } = rest;
73
+ return (_jsx("a", { ...anchor, ...common, href: href, onClick: (event) => {
74
+ guard(event);
75
+ if (!busy)
76
+ onClick?.(event);
77
+ }, children: glyph }));
78
+ }
79
+ const { onClick, type = 'button', ...button } = rest;
80
+ return (_jsx("button", { ...button, ...common, type: type, onClick: (event) => {
81
+ guard(event);
82
+ if (!busy)
83
+ onClick?.(event);
84
+ }, children: glyph }));
85
+ }
@@ -1,5 +1,13 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import { type IconName } from './Icon.js';
3
+ /**
4
+ * `default`: the dark notice at the bottom. `flotante`: the glass notice (`faast-glass--pop`)
5
+ * that floats under the floating bar.
6
+ */
7
+ export type ToastVariant = 'default' | 'flotante';
8
+ /** Only changes the colour of the icon of a `flotante` toast. */
9
+ export type ToastTone = 'neutral' | 'success';
10
+ export type ToastPlacement = 'bottom' | 'top';
3
11
  export interface ToastProps {
4
12
  children: ReactNode;
5
13
  icon?: IconName;
@@ -11,21 +19,52 @@ export interface ToastProps {
11
19
  onDismiss?: () => void;
12
20
  /** Accessible name of the close button. Default "Cerrar Aviso". Omit `onDismiss` to hide it. */
13
21
  dismissLabel?: string;
22
+ /** Default `default`. `flotante` is the glass notice for the top of the page. */
23
+ variant?: ToastVariant;
24
+ /** Default `neutral`. `success` colours the icon of a `flotante` toast. */
25
+ tone?: ToastTone;
26
+ /**
27
+ * No timer and no close button, even with `onDismiss`; `duration` is ignored. For a notice
28
+ * that lasts while something lasts (a reconnection).
29
+ */
30
+ persistent?: boolean;
31
+ /** A decorative waiting ring instead of the icon (`icon` is ignored). */
32
+ pending?: boolean;
33
+ /** Shows the close button when there is an `onDismiss`. Default true. */
34
+ closable?: boolean;
35
+ /**
36
+ * Changing it restarts the timer even when `duration` does not change. The provider bumps it
37
+ * when a toast is updated.
38
+ *
39
+ * @internal Set by `ToastProvider`; applications do not pass it.
40
+ */
41
+ restartKey?: string | number;
14
42
  className?: string;
15
43
  }
16
44
  /**
17
45
  * Short, non-blocking confirmation (`role="status"`, polite). Not for errors that need
18
46
  * action: use `Alert` for those.
19
47
  */
20
- export declare function Toast({ children, icon, duration, onDismiss, dismissLabel, className, }: ToastProps): import("react").JSX.Element;
48
+ export declare function Toast({ children, icon, duration, onDismiss, dismissLabel, variant, tone, persistent, pending, closable, restartKey, className, }: ToastProps): import("react").JSX.Element;
21
49
  export interface ToastOptions {
22
50
  icon?: IconName;
23
51
  duration?: number | null;
52
+ variant?: ToastVariant;
53
+ tone?: ToastTone;
54
+ persistent?: boolean;
55
+ pending?: boolean;
56
+ closable?: boolean;
24
57
  }
25
58
  export interface ToastContextValue {
26
59
  /** Shows a toast and returns its id. */
27
60
  show: (message: ReactNode, options?: ToastOptions) => number;
28
61
  dismiss: (id: number) => void;
62
+ /**
63
+ * Changes the message of the toast `id` and merges `options` over its own, WITHOUT unmounting
64
+ * it (same node, same live region, so a screen reader announces the new text) and restarts
65
+ * its timer. An `id` that is not there is ignored.
66
+ */
67
+ update: (id: number, message: ReactNode, options?: ToastOptions) => void;
29
68
  }
30
69
  export interface ToastProviderProps {
31
70
  children: ReactNode;
@@ -36,8 +75,15 @@ export interface ToastProviderProps {
36
75
  /** Name of the toast region. Default "Notificaciones". */
37
76
  regionLabel?: string;
38
77
  dismissLabel?: string;
78
+ /** Where the region is drawn. Default `bottom`; `top` sits under the floating bar. */
79
+ placement?: ToastPlacement;
80
+ /** Variant of every toast of this provider unless its options say otherwise. Default `default`. */
81
+ variant?: ToastVariant;
39
82
  }
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. */
83
+ /**
84
+ * Holds the toast queue and renders it in a fixed region at the bottom (or, with
85
+ * `placement="top"`, under the floating bar) of the viewport.
86
+ */
87
+ export declare function ToastProvider({ children, duration, max, regionLabel, dismissLabel, placement, variant, }: ToastProviderProps): import("react").JSX.Element;
88
+ /** `show` / `dismiss` / `update` from the nearest ToastProvider. */
43
89
  export declare function useToast(): ToastContextValue;
@@ -2,28 +2,36 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
3
3
  import { cx } from '../utils/cx.js';
4
4
  import { IconButton } from './Button.js';
5
+ import { glassClassName } from './Glass.js';
5
6
  import { Icon } from './Icon.js';
6
7
  /**
7
8
  * Short, non-blocking confirmation (`role="status"`, polite). Not for errors that need
8
9
  * action: use `Alert` for those.
9
10
  */
10
- export function Toast({ children, icon, duration = 5000, onDismiss, dismissLabel = 'Cerrar Aviso', className, }) {
11
+ export function Toast({ children, icon, duration = 5000, onDismiss, dismissLabel = 'Cerrar Aviso', variant = 'default', tone = 'neutral', persistent = false, pending = false, closable = true, restartKey, className, }) {
11
12
  const [paused, setPaused] = useState(false);
12
13
  const onDismissRef = useRef(onDismiss);
13
14
  useEffect(() => {
14
15
  onDismissRef.current = onDismiss;
15
16
  });
17
+ const timed = !persistent && duration !== null;
16
18
  useEffect(() => {
17
- if (duration === null || paused)
19
+ if (!timed || paused)
18
20
  return;
19
21
  const timer = window.setTimeout(() => onDismissRef.current?.(), duration);
20
22
  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
+ }, [timed, duration, paused, restartKey]);
24
+ const floating = variant === 'flotante';
25
+ const showClose = Boolean(onDismiss) && closable && !persistent;
26
+ const leading = pending ? (_jsx("span", { className: "faast-toast__icon", "aria-hidden": "true", children: _jsx("span", { className: "faast-spinner faast-spinner--sm", children: _jsx("span", { className: "faast-spinner__ring" }) }) })) : icon ? (floating ? (_jsx("span", { className: "faast-toast__icon", "aria-hidden": "true", children: _jsx(Icon, { name: icon }) })) : (_jsx(Icon, { name: icon, className: "faast-toast__icon" }))) : null;
27
+ return (_jsxs("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", className: cx('faast-toast', floating && ['faast-toast--flotante', glassClassName('pop')].join(' '), floating && tone === 'success' && 'faast-toast--success', className), onPointerEnter: () => setPaused(true), onPointerLeave: () => setPaused(false), onFocus: () => setPaused(true), onBlur: () => setPaused(false), "data-testid": "toast", children: [leading, _jsx("span", { className: "faast-toast__message", children: children }), showClose && (_jsx(IconButton, { className: "faast-toast__close", label: dismissLabel, icon: _jsx(Icon, { name: "x", size: 16 }), onClick: onDismiss }))] }));
23
28
  }
24
29
  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, }) {
30
+ /**
31
+ * Holds the toast queue and renders it in a fixed region at the bottom (or, with
32
+ * `placement="top"`, under the floating bar) of the viewport.
33
+ */
34
+ export function ToastProvider({ children, duration = 5000, max = 3, regionLabel = 'Notificaciones', dismissLabel, placement = 'bottom', variant = 'default', }) {
27
35
  const [items, setItems] = useState([]);
28
36
  const nextId = useRef(1);
29
37
  const dismiss = useCallback((id) => {
@@ -31,13 +39,16 @@ export function ToastProvider({ children, duration = 5000, max = 3, regionLabel
31
39
  }, []);
32
40
  const show = useCallback((message, options = {}) => {
33
41
  const id = nextId.current++;
34
- setItems((current) => [...current, { id, message, ...options }].slice(-max));
42
+ setItems((current) => [...current, { id, message, revision: 0, ...options }].slice(-max));
35
43
  return id;
36
44
  }, [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))) })] }));
45
+ const update = useCallback((id, message, options = {}) => {
46
+ setItems((current) => current.map((item) => item.id === id ? { ...item, ...options, message, revision: item.revision + 1 } : item));
47
+ }, []);
48
+ const value = useMemo(() => ({ show, dismiss, update }), [show, dismiss, update]);
49
+ return (_jsxs(ToastContext.Provider, { value: value, children: [children, _jsx("section", { className: cx('faast-toaster', placement === 'top' && 'faast-toaster--top'), "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, variant: item.variant ?? variant, tone: item.tone, persistent: item.persistent, pending: item.pending, closable: item.closable, restartKey: item.revision, children: item.message }, item.id))) })] }));
39
50
  }
40
- /** `show` / `dismiss` from the nearest ToastProvider. */
51
+ /** `show` / `dismiss` / `update` from the nearest ToastProvider. */
41
52
  export function useToast() {
42
53
  const context = useContext(ToastContext);
43
54
  if (!context)
package/dist/index.d.ts CHANGED
@@ -8,11 +8,11 @@ export type { ResolvedTheme, ThemeContextValue, ThemeProviderProps } from './the
8
8
  export { ThemeToggle } from './theme/ThemeToggle.js';
9
9
  export type { ThemeToggleLabels, ThemeToggleProps } from './theme/ThemeToggle.js';
10
10
  export { Button, buttonClassName, IconButton } from './components/Button.js';
11
- export type { ButtonClassNameOptions, ButtonProps, ButtonSize, ButtonVariant, IconButtonProps, } from './components/Button.js';
11
+ export type { ButtonClassNameOptions, ButtonProps, ButtonShape, ButtonSize, ButtonVariant, IconButtonProps, } from './components/Button.js';
12
12
  export { FormField, useFormField } from './components/FormField.js';
13
- export type { FormFieldContextValue, FormFieldProps } from './components/FormField.js';
13
+ export type { FieldMessagePlacement, FormFieldContextValue, FormFieldProps, } from './components/FormField.js';
14
14
  export { Input, Textarea, TextField } from './components/Input.js';
15
- export type { InputProps, TextareaProps, TextFieldProps } from './components/Input.js';
15
+ export type { ControlSize, InputProps, TextareaProps, TextFieldProps } from './components/Input.js';
16
16
  export { Select } from './components/Select.js';
17
17
  export type { SelectOption, SelectProps } from './components/Select.js';
18
18
  export { Checkbox, Radio, RadioGroup, Switch } from './components/Choice.js';
@@ -22,11 +22,13 @@ export type { CardHeaderProps, CardProps } from './components/Card.js';
22
22
  export { SegmentedControl } from './components/SegmentedControl.js';
23
23
  export type { SegmentedControlProps, SegmentedOption } from './components/SegmentedControl.js';
24
24
  export { Stepper } from './components/Stepper.js';
25
- export type { StepperProps, StepperStep, StepState } from './components/Stepper.js';
25
+ export type { StepperProps, StepperStep, StepperVariant, StepState } from './components/Stepper.js';
26
26
  export { FileDropArea, useFileDrop, usePreventWindowFileDrop } from './components/FileDropArea.js';
27
27
  export type { FileDropAreaProps, FileDropProps, UseFileDropOptions, } from './components/FileDropArea.js';
28
28
  export { KpiStrip } from './components/KpiStrip.js';
29
29
  export type { KpiItem, KpiStripProps } from './components/KpiStrip.js';
30
+ export { SummaryCard, SummaryCardAction, SummaryCardFooter, SummaryCardHeader, SummaryCardNote, SummaryCardValue, } from './components/SummaryCard.js';
31
+ export type { SummaryCardActionProps, SummaryCardFooterProps, SummaryCardHeaderProps, SummaryCardNoteProps, SummaryCardProps, SummaryCardSize, SummaryCardVariant, SummaryCardValueProps, } from './components/SummaryCard.js';
30
32
  export { StatTiles } from './components/StatTiles.js';
31
33
  export type { StatTileItem, StatTilesProps, StatTileTone } from './components/StatTiles.js';
32
34
  export { Timeline } from './components/Timeline.js';
@@ -42,7 +44,7 @@ export type { ChipProps } from './components/Chip.js';
42
44
  export { Dialog } from './components/Dialog.js';
43
45
  export type { DialogCloseReason, DialogProps } from './components/Dialog.js';
44
46
  export { Badge, StatusBadge } from './components/Badge.js';
45
- export type { BadgeProps, Status, StatusBadgeProps } from './components/Badge.js';
47
+ export type { BadgeProps, Status, StatusBadgeDotProps, StatusBadgePillProps, StatusBadgeProps, } from './components/Badge.js';
46
48
  export { Alert, ErrorState } from './components/Alert.js';
47
49
  export type { AlertProps, AlertStatus, ErrorStateProps } from './components/Alert.js';
48
50
  export { EmptyState } from './components/EmptyState.js';
@@ -57,6 +59,12 @@ export { NavItem, NavSection, SideNav, TopBar } from './components/Navigation.js
57
59
  export type { NavItemProps, NavSectionProps, SideNavProps, TopBarProps, } from './components/Navigation.js';
58
60
  export { AppShell, SidebarFooter, SidebarPortal } from './components/AppShell.js';
59
61
  export type { AppShellLabels, AppShellProps, AppShellTourAnchors, SidebarFooterProps, SidebarPortalProps, } from './components/AppShell.js';
62
+ export { BarraFlotante, BarraHerramientas, BarraMarca, BarraModulos, } from './components/BarraFlotante.js';
63
+ export type { BarraFlotanteMarca, BarraFlotanteProps, BarraHerramientasProps, BarraMarcaProps, BarraModulo, BarraModulosLabels, BarraModulosProps, } from './components/BarraFlotante.js';
64
+ export { computeBarraOverflow } from './utils/barraOverflow.js';
65
+ export type { BarraOverflowInput } from './utils/barraOverflow.js';
66
+ export { Glass, glassClassName } from './components/Glass.js';
67
+ export type { GlassLevel, GlassProps } from './components/Glass.js';
60
68
  export { Logo } from './components/Logo.js';
61
69
  export type { LogoProps } from './components/Logo.js';
62
70
  export { TenantMark } from './components/TenantMark.js';
@@ -72,7 +80,7 @@ export type { SessionTimeoutDialogLabels, SessionTimeoutDialogProps, } from './c
72
80
  export { LockScreen, maskEmail } from './components/LockScreen.js';
73
81
  export type { LockScreenProps, LockScreenUser } from './components/LockScreen.js';
74
82
  export { Toast, ToastProvider, useToast } from './components/Toast.js';
75
- export type { ToastContextValue, ToastOptions, ToastProps, ToastProviderProps, } from './components/Toast.js';
83
+ export type { ToastContextValue, ToastOptions, ToastProps, ToastPlacement, ToastProviderProps, ToastTone, ToastVariant, } from './components/Toast.js';
76
84
  export { Avatar, getInitials } from './components/Avatar.js';
77
85
  export type { AvatarProps } from './components/Avatar.js';
78
86
  export { OptionList, OptionListItem } from './components/OptionList.js';
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ export { SegmentedControl } from './components/SegmentedControl.js';
15
15
  export { Stepper } from './components/Stepper.js';
16
16
  export { FileDropArea, useFileDrop, usePreventWindowFileDrop } from './components/FileDropArea.js';
17
17
  export { KpiStrip } from './components/KpiStrip.js';
18
+ export { SummaryCard, SummaryCardAction, SummaryCardFooter, SummaryCardHeader, SummaryCardNote, SummaryCardValue, } from './components/SummaryCard.js';
18
19
  export { StatTiles } from './components/StatTiles.js';
19
20
  export { Timeline } from './components/Timeline.js';
20
21
  export { StickyActionBar } from './components/StickyActionBar.js';
@@ -30,6 +31,9 @@ export { Table, TableBody, TableCell, TableFoot, TableHead, TableHeaderCell, Tab
30
31
  export { Pagination, paginationRange } from './components/Pagination.js';
31
32
  export { NavItem, NavSection, SideNav, TopBar } from './components/Navigation.js';
32
33
  export { AppShell, SidebarFooter, SidebarPortal } from './components/AppShell.js';
34
+ export { BarraFlotante, BarraHerramientas, BarraMarca, BarraModulos, } from './components/BarraFlotante.js';
35
+ export { computeBarraOverflow } from './utils/barraOverflow.js';
36
+ export { Glass, glassClassName } from './components/Glass.js';
33
37
  export { Logo } from './components/Logo.js';
34
38
  export { TenantMark } from './components/TenantMark.js';
35
39
  export { Icon, iconNames, isIconName } from './components/Icon.js';