@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.
package/README.md CHANGED
@@ -8,6 +8,9 @@ import '@faast-app/ui/styles.css' // after the tokens/themes stylesheets
8
8
  import { AppShell, Button, ThemeProvider } from '@faast-app/ui'
9
9
  ```
10
10
 
11
+ Static design proposals (no React): `@faast-app/ui/kit.css`, `@faast-app/ui/kit/markup.json` and
12
+ `@faast-app/ui/kit/catalogo.html`; see `docs/proposal-kit.md`.
13
+
11
14
  Data tables (`ClientDataTable`, `ServerDataTable`, toolbar and hooks): see `docs/data-tables.md`.
12
15
 
13
16
  Part of the FaaST shared libraries (`librerias`). Private package; see the repository docs
@@ -15,10 +15,37 @@ export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
15
15
  }
16
16
  /** Small pill for counts and labels inside rows. Never above a heading. */
17
17
  export declare function Badge({ tone, variant, className, ...rest }: BadgeProps): import("react").JSX.Element;
18
- export interface StatusBadgeProps extends HTMLAttributes<HTMLSpanElement> {
18
+ interface StatusBadgeBaseProps extends HTMLAttributes<HTMLSpanElement> {
19
+ /**
20
+ * The tone. In the pill it is the badge colour; in the `dot` variant it colours the dot and
21
+ * the note. `neutral` is "ink": the dot and the label stay in the text colours.
22
+ */
19
23
  status: Status;
20
24
  /** The status in words (colour is never the only signal). */
21
25
  children: ReactNode;
22
26
  }
23
- /** Status pill: a coloured dot plus the status in words. */
24
- export declare function StatusBadge({ status, className, children, ...rest }: StatusBadgeProps): import("react").JSX.Element;
27
+ /** The default status pill: a tinted rounded badge with a dot and the status in words. */
28
+ export interface StatusBadgePillProps extends StatusBadgeBaseProps {
29
+ variant?: 'pill';
30
+ }
31
+ /**
32
+ * Status as text (DSN-005 N4): an 8px dot and the status in words, with no pill and no fill,
33
+ * for tables, cards and lists. Shape carries what colour should not carry alone: a HOLLOW dot
34
+ * is "in progress", a SOLID dot is "already defined". Colour is reserved for what needs
35
+ * action or a result (`warning`, `danger`, `success`); the rest stay in ink (`neutral`).
36
+ *
37
+ * The app maps its own states to tones. For example the "ink" palette uses `neutral` for
38
+ * "En evaluación" (hollow) and "Aprobada" (solid); the library palette uses `info` and
39
+ * `violet` for the same two states.
40
+ */
41
+ export interface StatusBadgeDotProps extends StatusBadgeBaseProps {
42
+ variant: 'dot';
43
+ /** `hollow` = in progress, `solid` = already defined. Default `solid`. */
44
+ marker?: 'hollow' | 'solid';
45
+ /** Optional short line under the status ("Vence hoy a las 18:00"). Coloured for warning and danger. */
46
+ note?: ReactNode;
47
+ }
48
+ export type StatusBadgeProps = StatusBadgePillProps | StatusBadgeDotProps;
49
+ /** Status pill (default) or status as text (`variant="dot"`): the status in words, plus a dot. */
50
+ export declare function StatusBadge(props: StatusBadgeProps): import("react").JSX.Element;
51
+ export {};
@@ -4,7 +4,12 @@ import { cx } from '../utils/cx.js';
4
4
  export function Badge({ tone = 'neutral', variant = 'pill', className, ...rest }) {
5
5
  return (_jsx("span", { className: cx('faast-badge', `faast-badge--${tone}`, variant === 'tag' && 'faast-badge--tag', className), ...rest }));
6
6
  }
7
- /** Status pill: a coloured dot plus the status in words. */
8
- export function StatusBadge({ status, className, children, ...rest }) {
7
+ /** Status pill (default) or status as text (`variant="dot"`): the status in words, plus a dot. */
8
+ export function StatusBadge(props) {
9
+ if (props.variant === 'dot') {
10
+ const { variant: _variant, status, marker = 'solid', note, className, children, ...rest } = props;
11
+ return (_jsxs("span", { className: cx('faast-status-text', `faast-status-text--${status}`, `faast-status-text--${marker}`, className), ...rest, children: [_jsxs("span", { className: "faast-status-text__line", children: [_jsx("span", { className: "faast-status-text__dot", "aria-hidden": "true" }), children] }), note && _jsx("span", { className: "faast-status-text__note", children: note })] }));
12
+ }
13
+ const { variant: _variant, status, className, children, ...rest } = props;
9
14
  return (_jsxs("span", { className: cx('faast-badge', `faast-badge--${status}`, 'faast-status-badge', className), ...rest, children: [_jsx("span", { className: "faast-status-badge__dot", "aria-hidden": "true" }), children] }));
10
15
  }
@@ -0,0 +1,72 @@
1
+ import { type AnchorHTMLAttributes, type HTMLAttributes, type MouseEventHandler, type ReactNode } from 'react';
2
+ /**
3
+ * How the brand shows on the bar (an explicit variant, not a boolean):
4
+ * - `filo`: neutral glass bar with a 2px edge in `accent-base` on the bottom border.
5
+ * - `banda`: the bar is `accent-base` with `text-on-accent`, and the logo sits on a `bg-surface` plate.
6
+ */
7
+ export type BarraFlotanteMarca = 'filo' | 'banda';
8
+ export interface BarraFlotanteProps extends HTMLAttributes<HTMLElement> {
9
+ /** Brand variant. Default `filo`. Per tenant: it follows the tenant theme (`createTenantTheme`). */
10
+ marca?: BarraFlotanteMarca;
11
+ /**
12
+ * Whether the overlay shadow shows (only when content passes underneath). By default the
13
+ * bar watches the window scroll; pass a boolean to control it (a different scroll container).
14
+ */
15
+ elevated?: boolean;
16
+ }
17
+ /**
18
+ * Floating bar: a glass capsule that stays 12px from the top edge (sticky) and frames every
19
+ * screen. Compose it from `BarraMarca`, `BarraModulos` and `BarraHerramientas`. Place it as a
20
+ * direct child of the page container so sticky works. Its shadow (`--faast-overlay-shadow`)
21
+ * appears only while content scrolls underneath. It is a `header` landmark.
22
+ */
23
+ export declare function BarraFlotante({ marca, elevated, className, children, ...rest }: BarraFlotanteProps): import("react").JSX.Element;
24
+ export interface BarraMarcaProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
25
+ /** Accessible name of the home link (the logo inside is decorative for it). Default "Ir al inicio". */
26
+ label?: string;
27
+ /**
28
+ * Render your router's link instead of `<a>`: pass one element as the only child (holding
29
+ * the `Logo`), e.g. `<BarraMarca asChild><Link to="/"><Logo .../></Link></BarraMarca>`.
30
+ */
31
+ asChild?: boolean;
32
+ }
33
+ /** The logo slot of the bar: a link to the home screen. In `banda` it sits on a `bg-surface` plate. */
34
+ export declare function BarraMarca({ label, asChild, className, children, ...rest }: BarraMarcaProps): import("react").JSX.Element;
35
+ export interface BarraModulo {
36
+ id: string;
37
+ /** Text of the link. */
38
+ label: string;
39
+ href: string;
40
+ /** The current module: `aria-current="page"` and it never passes to "Más". */
41
+ active?: boolean;
42
+ /** For a router: navigate here and call `preventDefault()` (the `href` stays for new tabs). */
43
+ onClick?: MouseEventHandler<HTMLAnchorElement>;
44
+ }
45
+ export interface BarraModulosLabels {
46
+ /** Text of the overflow button. Default `(n) => "Más (n)"`. */
47
+ more: (hidden: number) => string;
48
+ /** Accessible name of the overflow list. Default "Más módulos". */
49
+ moreList: string;
50
+ /** Phone button and sheet title. Default "Módulos". */
51
+ menu: string;
52
+ }
53
+ export interface BarraModulosProps {
54
+ modules: readonly BarraModulo[];
55
+ /** Accessible name of the navigation landmark. Default "Principal". */
56
+ label?: string;
57
+ labels?: Partial<BarraModulosLabels>;
58
+ }
59
+ /**
60
+ * The modules of the app as text links. It measures the bar and moves what does not fit to a
61
+ * "Más (n)" menu, from the end of the list; the current module never moves. Below 768px the
62
+ * list is replaced by a "Módulos" button that opens the same links in a bottom sheet.
63
+ */
64
+ export declare function BarraModulos({ modules, label, labels }: BarraModulosProps): import("react").JSX.Element;
65
+ export interface BarraHerramientasProps extends HTMLAttributes<HTMLDivElement> {
66
+ children: ReactNode;
67
+ }
68
+ /**
69
+ * The right edge of the bar: search, notices, account (`IconButton`, `Button`, `Avatar`...).
70
+ * Give each button an accessible name; targets are 44px (36px with a fine pointer from 768px).
71
+ */
72
+ export declare function BarraHerramientas({ className, children, ...rest }: BarraHerramientasProps): import("react").JSX.Element;
@@ -0,0 +1,190 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { cloneElement, isValidElement, useCallback, useEffect, useId, useLayoutEffect, useRef, useState, useSyncExternalStore, } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import { computeBarraOverflow } from '../utils/barraOverflow.js';
5
+ import { cx } from '../utils/cx.js';
6
+ import { Dialog } from './Dialog.js';
7
+ import { glassClassName, Glass } from './Glass.js';
8
+ import { Icon } from './Icon.js';
9
+ const subscribeNothing = () => () => undefined;
10
+ const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
11
+ /**
12
+ * Floating bar: a glass capsule that stays 12px from the top edge (sticky) and frames every
13
+ * screen. Compose it from `BarraMarca`, `BarraModulos` and `BarraHerramientas`. Place it as a
14
+ * direct child of the page container so sticky works. Its shadow (`--faast-overlay-shadow`)
15
+ * appears only while content scrolls underneath. It is a `header` landmark.
16
+ */
17
+ export function BarraFlotante({ marca = 'filo', elevated, className, children, ...rest }) {
18
+ const [scrolled, setScrolled] = useState(false);
19
+ const controlled = elevated !== undefined;
20
+ useEffect(() => {
21
+ if (controlled)
22
+ return;
23
+ const update = () => setScrolled(window.scrollY > 4);
24
+ update();
25
+ window.addEventListener('scroll', update, { passive: true });
26
+ return () => window.removeEventListener('scroll', update);
27
+ }, [controlled]);
28
+ const isElevated = controlled ? elevated : scrolled;
29
+ return (_jsx("div", { className: "faast-bar-wrap", children: _jsx("header", { className: cx('faast-bar', glassClassName('bar'), className), "data-marca": marca, "data-elevada": isElevated ? '' : undefined, ...rest, children: children }) }));
30
+ }
31
+ /** The logo slot of the bar: a link to the home screen. In `banda` it sits on a `bg-surface` plate. */
32
+ export function BarraMarca({ label = 'Ir al inicio', asChild = false, className, children, ...rest }) {
33
+ const classes = cx('faast-bar__brand', className);
34
+ if (asChild && isValidElement(children)) {
35
+ const child = children;
36
+ return cloneElement(child, {
37
+ className: cx(classes, child.props.className),
38
+ 'aria-label': label,
39
+ });
40
+ }
41
+ return (_jsx("a", { className: classes, "aria-label": label, ...rest, children: children }));
42
+ }
43
+ const DEFAULT_LABELS = {
44
+ more: (n) => `Más (${n})`,
45
+ moreList: 'Más módulos',
46
+ menu: 'Módulos',
47
+ };
48
+ /**
49
+ * The modules of the app as text links. It measures the bar and moves what does not fit to a
50
+ * "Más (n)" menu, from the end of the list; the current module never moves. Below 768px the
51
+ * list is replaced by a "Módulos" button that opens the same links in a bottom sheet.
52
+ */
53
+ export function BarraModulos({ modules, label = 'Principal', labels }) {
54
+ const text = { ...DEFAULT_LABELS, ...labels };
55
+ const navRef = useRef(null);
56
+ const measureRef = useRef(null);
57
+ const moreRef = useRef(null);
58
+ const moreButtonRef = useRef(null);
59
+ const [hiddenIds, setHiddenIds] = useState([]);
60
+ const [moreOpen, setMoreOpen] = useState(false);
61
+ // Where the "Más" list renders: a sibling of the bar's `header`, inside `.faast-bar-wrap`.
62
+ const [refocus, setRefocus] = useState(0);
63
+ const [popHost, setPopHost] = useState(null);
64
+ const [sheetOpen, setSheetOpen] = useState(false);
65
+ // The sheet is portalled to <body> after mount: it must not inherit the bar's brand styles.
66
+ const mounted = useSyncExternalStore(subscribeNothing, () => true, () => false);
67
+ const listId = useId();
68
+ const measure = useCallback(() => {
69
+ const nav = navRef.current;
70
+ const list = measureRef.current;
71
+ if (!nav || !list)
72
+ return;
73
+ const items = Array.from(list.querySelectorAll('[data-measure="item"]'));
74
+ const more = list.querySelector('[data-measure="more"]');
75
+ const hidden = computeBarraOverflow({
76
+ widths: items.map((el) => el.getBoundingClientRect().width),
77
+ available: nav.clientWidth,
78
+ gap: parseFloat(getComputedStyle(list).columnGap) || 0,
79
+ moreWidth: more?.getBoundingClientRect().width ?? 0,
80
+ activeIndex: modules.findIndex((m) => m.active),
81
+ }).map((i) => modules[i]?.id ?? '');
82
+ if (hidden.length === 0)
83
+ setMoreOpen(false);
84
+ setHiddenIds((prev) => prev.length === hidden.length && prev.every((id, i) => id === hidden[i]) ? prev : hidden);
85
+ }, [modules]);
86
+ useIsomorphicLayoutEffect(() => {
87
+ measure();
88
+ const nav = navRef.current;
89
+ if (!nav)
90
+ return;
91
+ const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure);
92
+ observer?.observe(nav);
93
+ // The webfont changes the widths once it loads.
94
+ void document.fonts?.ready.then(measure);
95
+ return () => observer?.disconnect();
96
+ }, [measure]);
97
+ const hidden = modules.filter((m) => hiddenIds.includes(m.id));
98
+ // The overflow list is shown only while something overflows.
99
+ const showMore = moreOpen && hidden.length > 0;
100
+ const visible = modules.filter((m) => !hiddenIds.includes(m.id));
101
+ // The "Más" list: focus goes to its first link when it opens; it closes on an outside press,
102
+ // when the focus leaves it and on Esc (focus returns to its button).
103
+ useEffect(() => {
104
+ if (!showMore)
105
+ return;
106
+ const pop = () => document.getElementById(listId);
107
+ pop()?.querySelector('a')?.focus();
108
+ const inside = (target) => !!moreRef.current?.contains(target) || !!pop()?.contains(target);
109
+ const onPointerDown = (event) => {
110
+ if (!inside(event.target))
111
+ setMoreOpen(false);
112
+ };
113
+ const onFocusIn = (event) => {
114
+ if (!inside(event.target))
115
+ setMoreOpen(false);
116
+ };
117
+ const onKeyDown = (event) => {
118
+ if (event.key !== 'Escape')
119
+ return;
120
+ setMoreOpen(false);
121
+ moreButtonRef.current?.focus();
122
+ };
123
+ document.addEventListener('pointerdown', onPointerDown);
124
+ document.addEventListener('focusin', onFocusIn);
125
+ document.addEventListener('keydown', onKeyDown);
126
+ return () => {
127
+ document.removeEventListener('pointerdown', onPointerDown);
128
+ document.removeEventListener('focusin', onFocusIn);
129
+ document.removeEventListener('keydown', onKeyDown);
130
+ };
131
+ }, [showMore, listId]);
132
+ // After choosing a link the list closes and the focus returns to its button.
133
+ function closeMoreList() {
134
+ setMoreOpen(false);
135
+ setRefocus((n) => n + 1);
136
+ }
137
+ useEffect(() => {
138
+ if (refocus > 0)
139
+ moreButtonRef.current?.focus();
140
+ }, [refocus]);
141
+ // The list lives outside the bar's DOM order, so Tab at its edges hands the focus back to the
142
+ // "Más" button: Tab from the last link continues after the button, Shift+Tab from the first
143
+ // link lands on the button.
144
+ const onPopKeyDown = (event) => {
145
+ if (event.key !== 'Tab')
146
+ return;
147
+ const links = Array.from(event.currentTarget.querySelectorAll('a'));
148
+ const active = document.activeElement;
149
+ if (event.shiftKey && active === links[0]) {
150
+ event.preventDefault();
151
+ setMoreOpen(false);
152
+ moreButtonRef.current?.focus();
153
+ }
154
+ else if (!event.shiftKey && active === links[links.length - 1]) {
155
+ setMoreOpen(false);
156
+ moreButtonRef.current?.focus();
157
+ }
158
+ };
159
+ // The sheet is a phone presentation: close it if the bar grows back to the desktop layout.
160
+ useEffect(() => {
161
+ if (!sheetOpen)
162
+ return;
163
+ const query = window.matchMedia('(min-width: 768px)');
164
+ const onChange = (event) => {
165
+ if (event.matches)
166
+ setSheetOpen(false);
167
+ };
168
+ query.addEventListener('change', onChange);
169
+ return () => query.removeEventListener('change', onChange);
170
+ }, [sheetOpen]);
171
+ const link = (m, onDone) => (_jsx("a", { className: "faast-bar__item", href: m.href, "aria-current": m.active ? 'page' : undefined, onClick: (event) => {
172
+ m.onClick?.(event);
173
+ onDone();
174
+ }, children: _jsx("span", { className: "faast-bar__label", children: m.label }) }));
175
+ // Glass blurs what is behind it only when it is NOT inside another backdrop-filter element, so
176
+ // the list is portalled next to the `header` (which is glass itself) instead of into it.
177
+ const pop = (_jsx(Glass, { level: "pop", id: listId, className: "faast-bar__pop", role: "group", "aria-label": text.moreList, onKeyDown: onPopKeyDown, children: _jsx("ul", { className: "faast-bar__pop-list", children: hidden.map((m) => (_jsx("li", { children: link(m, closeMoreList) }, m.id))) }) }));
178
+ return (_jsxs(_Fragment, { children: [_jsxs("nav", { ref: navRef, className: "faast-bar__nav", "aria-label": label, children: [_jsxs("ul", { className: "faast-bar__list", children: [visible.map((m) => (_jsx("li", { children: link(m, () => undefined) }, m.id))), hidden.length > 0 && (_jsxs("li", { ref: moreRef, className: "faast-bar__more", children: [_jsxs("button", { ref: moreButtonRef, type: "button", className: "faast-bar__item", "aria-expanded": showMore, "aria-controls": showMore ? listId : undefined, onClick: () => {
179
+ setPopHost(navRef.current?.closest('.faast-bar-wrap') ?? null);
180
+ setMoreOpen((open) => !open);
181
+ }, children: [text.more(hidden.length), _jsx(Icon, { name: "chevron-down", size: 14 })] }), showMore && (popHost ? createPortal(pop, popHost) : pop)] }))] }), _jsxs("ul", { ref: measureRef, className: "faast-bar__list faast-bar__measure", "aria-hidden": "true", children: [modules.map((m) => (_jsx("li", { children: _jsx("span", { className: "faast-bar__item", "data-measure": "item", "aria-current": m.active ? 'page' : undefined, children: m.label }) }, m.id))), _jsx("li", { children: _jsxs("span", { className: "faast-bar__item", "data-measure": "more", children: [text.more(modules.length), _jsx(Icon, { name: "chevron-down", size: 14 })] }) })] })] }), _jsxs("button", { type: "button", className: "faast-bar__item faast-bar__menu-btn", "aria-haspopup": "dialog", onClick: () => setSheetOpen(true), children: [_jsx(Icon, { name: "menu", size: 16 }), _jsx("span", { className: "faast-bar__menu-label", children: text.menu })] }), mounted &&
182
+ createPortal(_jsx(Dialog, { open: sheetOpen, onClose: () => setSheetOpen(false), title: text.menu, size: "sm", className: "faast-bar__sheet", children: _jsx("nav", { "aria-label": label, children: _jsx("ul", { className: "faast-bar__sheet-list", children: modules.map((m) => (_jsx("li", { children: link(m, () => setSheetOpen(false)) }, m.id))) }) }) }), document.body)] }));
183
+ }
184
+ /**
185
+ * The right edge of the bar: search, notices, account (`IconButton`, `Button`, `Avatar`...).
186
+ * Give each button an accessible name; targets are 44px (36px with a fine pointer from 768px).
187
+ */
188
+ export function BarraHerramientas({ className, children, ...rest }) {
189
+ return (_jsx("div", { className: cx('faast-bar__tools', className), ...rest, children: children }));
190
+ }
@@ -1,14 +1,24 @@
1
1
  import { type ButtonHTMLAttributes, type MouseEvent, type ReactNode } from 'react';
2
2
  export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
3
- export type ButtonSize = 'md' | 'sm';
3
+ export type ButtonSize = 'md' | 'sm' | 'lg';
4
+ /** `pill` is the capsule shape (DSN-005 N14): fully rounded ends. Default `default` (6px). */
5
+ export type ButtonShape = 'default' | 'pill';
4
6
  export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
5
7
  /** `primary` is the one main action of a view. Default `secondary`. */
6
8
  variant?: ButtonVariant;
7
9
  /**
8
10
  * `md` keeps the 44px touch target everywhere; `sm` is 36px only for fine pointers from
9
- * the md breakpoint up (it stays 44px on touch screens). Default `md`.
11
+ * the md breakpoint up (it stays 44px on touch screens); `lg` is 48px on every pointer
12
+ * (DSN-005 N15), only for surfaces whose design contract fixes 48px (the sign-in).
13
+ * Default `md`.
10
14
  */
11
15
  size?: ButtonSize;
16
+ /**
17
+ * `pill` rounds the ends fully (`--faast-radius-full`). Only for surfaces whose design
18
+ * contract asks for capsule buttons (the sign-in); everything else keeps `default` (6px).
19
+ * Colour, height and states do not change. Default `default`.
20
+ */
21
+ shape?: ButtonShape;
12
22
  /** Shows a spinner, sets `aria-busy` and blocks clicks while keeping the label. */
13
23
  loading?: boolean;
14
24
  /** Text announced while loading. Default "Cargando…". */
@@ -28,6 +38,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
28
38
  export interface ButtonClassNameOptions {
29
39
  variant?: ButtonVariant;
30
40
  size?: ButtonSize;
41
+ shape?: ButtonShape;
31
42
  fullWidth?: boolean;
32
43
  className?: string;
33
44
  }
@@ -36,7 +47,7 @@ export interface ButtonClassNameOptions {
36
47
  * `<a>`): `<Link className={buttonClassName({ variant: 'primary' })}>`. Put icons and the
37
48
  * text in a `<span className="faast-button__label">` as `Button` does.
38
49
  */
39
- export declare function buttonClassName({ variant, size, fullWidth, className, }?: ButtonClassNameOptions): string;
50
+ export declare function buttonClassName({ variant, size, shape, fullWidth, className, }?: ButtonClassNameOptions): string;
40
51
  /** Action button. Labels use Title Case ("Guardar Cambios"). */
41
52
  export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
42
53
  export interface IconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
@@ -7,12 +7,12 @@ import { Spinner } from './Spinner.js';
7
7
  * `<a>`): `<Link className={buttonClassName({ variant: 'primary' })}>`. Put icons and the
8
8
  * text in a `<span className="faast-button__label">` as `Button` does.
9
9
  */
10
- export function buttonClassName({ variant = 'secondary', size = 'md', fullWidth = false, className, } = {}) {
11
- return cx('faast-button', `faast-button--${variant}`, `faast-button--${size}`, fullWidth && 'faast-button--full', className);
10
+ export function buttonClassName({ variant = 'secondary', size = 'md', shape = 'default', fullWidth = false, className, } = {}) {
11
+ return cx('faast-button', `faast-button--${variant}`, `faast-button--${size}`, shape === 'pill' && 'faast-button--pill', fullWidth && 'faast-button--full', className);
12
12
  }
13
13
  /** Action button. Labels use Title Case ("Guardar Cambios"). */
14
- export const Button = forwardRef(function Button({ variant = 'secondary', size = 'md', loading = false, loadingLabel = 'Cargando…', leadingIcon, trailingIcon, fullWidth = false, softDisabled = false, onSoftDisabledClick, disabled, type = 'button', className, children, onClick, ...rest }, ref) {
15
- return (_jsxs("button", { ref: ref, type: type, className: cx(buttonClassName({ variant, size, fullWidth }), loading && 'faast-button--loading', softDisabled && 'faast-button--soft-disabled', className), disabled: disabled, "aria-busy": loading || undefined, "aria-disabled": loading || softDisabled || undefined, onClick: (event) => {
14
+ export const Button = forwardRef(function Button({ variant = 'secondary', size = 'md', shape = 'default', loading = false, loadingLabel = 'Cargando…', leadingIcon, trailingIcon, fullWidth = false, softDisabled = false, onSoftDisabledClick, disabled, type = 'button', className, children, onClick, ...rest }, ref) {
15
+ return (_jsxs("button", { ref: ref, type: type, className: cx(buttonClassName({ variant, size, shape, fullWidth }), loading && 'faast-button--loading', softDisabled && 'faast-button--soft-disabled', className), disabled: disabled, "aria-busy": loading || undefined, "aria-disabled": loading || softDisabled || undefined, onClick: (event) => {
16
16
  if (loading) {
17
17
  event.preventDefault();
18
18
  return;
@@ -12,6 +12,7 @@ export interface FormFieldContextValue {
12
12
  export declare function useFormField(): FormFieldContextValue | null;
13
13
  /** Merges the field's describedby ids with any the control already has. */
14
14
  export declare function mergeDescribedBy(...ids: Array<string | undefined>): string | undefined;
15
+ export type FieldMessagePlacement = 'below' | 'inside';
15
16
  export interface FormFieldProps {
16
17
  /** Visible label (always shown above the control; never a placeholder substitute). */
17
18
  label: ReactNode;
@@ -19,6 +20,17 @@ export interface FormFieldProps {
19
20
  hint?: ReactNode;
20
21
  /** Error message. Sets `aria-invalid` on the control and is linked with `aria-describedby`. */
21
22
  error?: ReactNode;
23
+ /**
24
+ * Where the error is shown. `below` (default) is a line under the control. `inside`
25
+ * (DSN-005 N11) puts it inside the field's box, under a thin rule: icon, the `error` as the
26
+ * title and `errorDetail` as the next step, without a tinted box. The box wraps the control
27
+ * and the message; use it with `Input`, `TextField` and `PasswordField`.
28
+ */
29
+ messagePlacement?: FieldMessagePlacement;
30
+ /** Second line of an `inside` message (what to do next), in `text-secondary`. */
31
+ errorDetail?: ReactNode;
32
+ /** `inside` only: content right under the box (e.g. password requirements), before the hint. */
33
+ afterBox?: ReactNode;
22
34
  required?: boolean;
23
35
  /** Text after the label for required fields. Default "(obligatorio)". */
24
36
  requiredLabel?: string;
@@ -32,4 +44,4 @@ export interface FormFieldProps {
32
44
  * Label, hint and error wiring for one control. Controls from this library read the
33
45
  * context automatically (id, `aria-describedby`, `aria-invalid`, `required`).
34
46
  */
35
- export declare function FormField({ label, hint, error, required, requiredLabel, id, className, children, }: FormFieldProps): import("react").JSX.Element;
47
+ export declare function FormField({ label, hint, error, messagePlacement, errorDetail, afterBox, required, requiredLabel, id, className, children, }: FormFieldProps): import("react").JSX.Element;
@@ -1,6 +1,7 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createContext, useContext, useId } from 'react';
3
3
  import { cx } from '../utils/cx.js';
4
+ import { Icon } from './Icon.js';
4
5
  const FormFieldContext = createContext(null);
5
6
  /** Field wiring for custom controls. Returns `null` outside a FormField. */
6
7
  export function useFormField() {
@@ -15,7 +16,8 @@ export function mergeDescribedBy(...ids) {
15
16
  * Label, hint and error wiring for one control. Controls from this library read the
16
17
  * context automatically (id, `aria-describedby`, `aria-invalid`, `required`).
17
18
  */
18
- export function FormField({ label, hint, error, required = false, requiredLabel = '(obligatorio)', id, className, children, }) {
19
+ export function FormField({ label, hint, error, messagePlacement = 'below', errorDetail, afterBox, required = false, requiredLabel = '(obligatorio)', id, className, children, }) {
20
+ const inside = messagePlacement === 'inside';
19
21
  const autoId = useId();
20
22
  const controlId = id ?? `faast-field-${autoId}`;
21
23
  const hintId = hint ? `${controlId}-hint` : undefined;
@@ -28,5 +30,5 @@ export function FormField({ label, hint, error, required = false, requiredLabel
28
30
  invalid: Boolean(error),
29
31
  required,
30
32
  };
31
- return (_jsx(FormFieldContext.Provider, { value: value, children: _jsxs("div", { className: cx('faast-field', Boolean(error) && 'faast-field--invalid', className), children: [_jsxs("label", { className: "faast-field__label", htmlFor: controlId, children: [label, required && _jsxs("span", { className: "faast-field__required", children: [" ", requiredLabel] })] }), children, hint && (_jsx("p", { className: "faast-field__hint", id: hintId, children: hint })), _jsx("p", { className: "faast-field__error", id: `${controlId}-error`, "aria-live": "polite", children: error })] }) }));
33
+ return (_jsx(FormFieldContext.Provider, { value: value, children: _jsxs("div", { className: cx('faast-field', Boolean(error) && 'faast-field--invalid', inside && 'faast-field--inside', className), children: [_jsxs("label", { className: "faast-field__label", htmlFor: controlId, children: [label, required && _jsxs("span", { className: "faast-field__required", children: [" ", requiredLabel] })] }), inside ? (_jsxs("div", { className: "faast-field__box", children: [children, error && (_jsxs("div", { className: "faast-field__message", id: errorId, role: "alert", children: [_jsx(Icon, { name: "circle-alert", size: 16 }), _jsxs("span", { className: "faast-field__message-text", children: [_jsx("span", { className: "faast-field__message-title", children: error }), errorDetail && (_jsx("span", { className: "faast-field__message-detail", children: errorDetail }))] })] }))] })) : (children), inside && afterBox, hint && (_jsx("p", { className: "faast-field__hint", id: hintId, children: hint })), !inside && (_jsx("p", { className: "faast-field__error", id: `${controlId}-error`, "aria-live": "polite", children: error }))] }) }));
32
34
  }
@@ -0,0 +1,22 @@
1
+ import type { HTMLAttributes } from 'react';
2
+ /**
3
+ * `bar` (88% opaque) is for the floating bar; `pop` (92%) is for the layers that open from it
4
+ * (menus, floating notices, the sign-in plate).
5
+ */
6
+ export type GlassLevel = 'bar' | 'pop';
7
+ export interface GlassProps extends HTMLAttributes<HTMLDivElement> {
8
+ /** How translucent the surface is. Default `bar`. */
9
+ level?: GlassLevel;
10
+ }
11
+ /** The classes of the glass material, for a landmark element that is not a `<div>`. */
12
+ export declare function glassClassName(level?: GlassLevel, className?: string): string;
13
+ /**
14
+ * Glass material: a translucent, blurred surface with a 1px border, ONLY for things that
15
+ * float over content (the bar, menus, a floating notice). Never the page canvas or content.
16
+ *
17
+ * It is solid (the plain `bg-surface` role) when the browser has no `backdrop-filter`, with
18
+ * `prefers-reduced-transparency`, and when the app sets `data-vidrio="solido"` on `<html>`
19
+ * (the "Reducir transparencia" switch). It sets no radius and no shadow: the floating layer
20
+ * decides both (`--faast-radius-xl`, `--faast-overlay-shadow`).
21
+ */
22
+ export declare function Glass({ level, className, ...rest }: GlassProps): import("react").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx } from '../utils/cx.js';
3
+ /** The classes of the glass material, for a landmark element that is not a `<div>`. */
4
+ export function glassClassName(level = 'bar', className) {
5
+ return cx('faast-glass', level === 'pop' && 'faast-glass--pop', className);
6
+ }
7
+ /**
8
+ * Glass material: a translucent, blurred surface with a 1px border, ONLY for things that
9
+ * float over content (the bar, menus, a floating notice). Never the page canvas or content.
10
+ *
11
+ * It is solid (the plain `bg-surface` role) when the browser has no `backdrop-filter`, with
12
+ * `prefers-reduced-transparency`, and when the app sets `data-vidrio="solido"` on `<html>`
13
+ * (the "Reducir transparencia" switch). It sets no radius and no shadow: the floating layer
14
+ * decides both (`--faast-radius-xl`, `--faast-overlay-shadow`).
15
+ */
16
+ export function Glass({ level = 'bar', className, ...rest }) {
17
+ return _jsx("div", { className: glassClassName(level, className), ...rest });
18
+ }
@@ -4,7 +4,7 @@ import type { SVGProps } from 'react';
4
4
  * exactly this set. Applications validate backend icon ids with `isIconName` before
5
5
  * rendering; an unknown id is a configuration error, never rendered.
6
6
  */
7
- export declare const iconNames: readonly ["arrow-down", "arrow-left-right", "arrow-right", "arrow-up", "arrow-up-down", "ban", "bell", "bell-off", "book-open", "building-2", "calculator", "calendar", "calendar-cog", "check", "check-check", "check-circle-2", "chevron-down", "chevron-left", "chevron-right", "chevron-up", "chevrons-up-down", "circle-alert", "circle-check", "circle-help", "circle-x", "coins", "columns-3-cog", "download", "eraser", "eye", "eye-off", "file-check", "file-code-2", "file-plus", "file-spreadsheet", "file-text", "file-up", "file-warning", "file-x", "files", "fingerprint", "folder-clock", "globe", "history", "house", "image", "info", "key-round", "layout-dashboard", "list", "lock", "log-in", "log-out", "mail", "menu", "monitor", "moon", "palette", "panel-left", "paperclip", "pencil", "play", "plus", "refresh-cw", "repeat", "replace", "rotate-cw", "route", "search", "search-x", "send", "settings", "shield-alert", "shield-check", "sliders-horizontal", "sun", "timer", "trash-2", "triangle-alert", "undo-2", "upload", "user-round", "users", "x", "x-circle"];
7
+ export declare const iconNames: readonly ["arrow-down", "arrow-left-right", "arrow-right", "arrow-up", "arrow-up-down", "arrow-up-right", "ban", "bell", "bell-off", "book-open", "building-2", "calculator", "calendar", "calendar-cog", "check", "check-check", "check-circle-2", "chevron-down", "chevron-left", "chevron-right", "chevron-up", "chevrons-up-down", "circle-alert", "circle-check", "circle-help", "circle-x", "coins", "columns-3-cog", "download", "ellipsis", "eraser", "eye", "eye-off", "file-check", "file-code-2", "file-plus", "file-spreadsheet", "file-text", "file-up", "file-warning", "file-x", "files", "fingerprint", "folder-clock", "globe", "history", "house", "image", "info", "key-round", "layers", "layout-dashboard", "list", "lock", "log-in", "log-out", "mail", "menu", "monitor", "moon", "palette", "panel-left", "paperclip", "pencil", "play", "plus", "printer", "refresh-cw", "repeat", "replace", "rotate-cw", "route", "search", "search-x", "send", "settings", "shield-alert", "shield-check", "sliders-horizontal", "star", "sun", "timer", "trash-2", "triangle-alert", "undo-2", "upload", "user-round", "users", "wallet", "wrench", "x", "x-circle"];
8
8
  export type IconName = (typeof iconNames)[number];
9
9
  /** Type guard for icon ids that come from configuration (e.g. backend navigation). */
10
10
  export declare function isIconName(value: unknown): value is IconName;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ArrowDown, ArrowLeftRight, ArrowRight, ArrowUp, ArrowUpDown, Ban, Bell, BellOff, BookOpen, Building2, Calculator, Calendar, CalendarCog, Check, CheckCheck, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, ChevronsUpDown, ChevronUp, CircleAlert, CircleCheck, CircleHelp, CircleX, Coins, Columns3Cog, Download, Eraser, Eye, EyeOff, FileCheck, FileCode2, FilePlus, Files, FileSpreadsheet, FileText, FileUp, FileWarning, FileX, Fingerprint, FolderClock, Globe, History, House, Image, Info, KeyRound, LayoutDashboard, List, Lock, LogIn, LogOut, Mail, Menu, Monitor, Moon, Palette, PanelLeft, Paperclip, Pencil, Play, Plus, RefreshCw, Repeat, Replace, RotateCw, Route, Search, SearchX, Send, Settings, ShieldAlert, ShieldCheck, SlidersHorizontal, Sun, Timer, Trash2, TriangleAlert, Undo2, Upload, UserRound, Users, X, XCircle, } from 'lucide-react';
2
+ import { ArrowDown, ArrowLeftRight, ArrowRight, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Bell, BellOff, BookOpen, Building2, Calculator, Calendar, CalendarCog, Check, CheckCheck, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, ChevronsUpDown, ChevronUp, CircleAlert, CircleCheck, CircleHelp, CircleX, Coins, Columns3Cog, Download, Ellipsis, Eraser, Eye, EyeOff, FileCheck, FileCode2, FilePlus, Files, FileSpreadsheet, FileText, FileUp, FileWarning, FileX, Fingerprint, FolderClock, Globe, History, House, Image, Info, KeyRound, Layers, LayoutDashboard, List, Lock, LogIn, LogOut, Mail, Menu, Monitor, Moon, Palette, PanelLeft, Paperclip, Pencil, Play, Plus, Printer, RefreshCw, Repeat, Replace, RotateCw, Route, Search, SearchX, Send, Settings, ShieldAlert, ShieldCheck, SlidersHorizontal, Star, Sun, Timer, Trash2, TriangleAlert, Undo2, Upload, UserRound, Users, Wallet, Wrench, X, XCircle, } from 'lucide-react';
3
3
  import { cx } from '../utils/cx.js';
4
4
  /**
5
5
  * The closed set of icon names. Only these Lucide icons are imported, so a bundler keeps
@@ -12,6 +12,7 @@ export const iconNames = [
12
12
  'arrow-right',
13
13
  'arrow-up',
14
14
  'arrow-up-down',
15
+ 'arrow-up-right',
15
16
  'ban',
16
17
  'bell',
17
18
  'bell-off',
@@ -35,6 +36,7 @@ export const iconNames = [
35
36
  'coins',
36
37
  'columns-3-cog',
37
38
  'download',
39
+ 'ellipsis',
38
40
  'eraser',
39
41
  'eye',
40
42
  'eye-off',
@@ -55,6 +57,7 @@ export const iconNames = [
55
57
  'image',
56
58
  'info',
57
59
  'key-round',
60
+ 'layers',
58
61
  'layout-dashboard',
59
62
  'list',
60
63
  'lock',
@@ -70,6 +73,7 @@ export const iconNames = [
70
73
  'pencil',
71
74
  'play',
72
75
  'plus',
76
+ 'printer',
73
77
  'refresh-cw',
74
78
  'repeat',
75
79
  'replace',
@@ -82,6 +86,7 @@ export const iconNames = [
82
86
  'shield-alert',
83
87
  'shield-check',
84
88
  'sliders-horizontal',
89
+ 'star',
85
90
  'sun',
86
91
  'timer',
87
92
  'trash-2',
@@ -90,6 +95,8 @@ export const iconNames = [
90
95
  'upload',
91
96
  'user-round',
92
97
  'users',
98
+ 'wallet',
99
+ 'wrench',
93
100
  'x',
94
101
  'x-circle',
95
102
  ];
@@ -99,6 +106,7 @@ const ICONS = {
99
106
  'arrow-right': ArrowRight,
100
107
  'arrow-up': ArrowUp,
101
108
  'arrow-up-down': ArrowUpDown,
109
+ 'arrow-up-right': ArrowUpRight,
102
110
  ban: Ban,
103
111
  bell: Bell,
104
112
  'bell-off': BellOff,
@@ -122,6 +130,7 @@ const ICONS = {
122
130
  coins: Coins,
123
131
  'columns-3-cog': Columns3Cog,
124
132
  download: Download,
133
+ ellipsis: Ellipsis,
125
134
  eraser: Eraser,
126
135
  eye: Eye,
127
136
  'eye-off': EyeOff,
@@ -142,6 +151,7 @@ const ICONS = {
142
151
  image: Image,
143
152
  info: Info,
144
153
  'key-round': KeyRound,
154
+ layers: Layers,
145
155
  'layout-dashboard': LayoutDashboard,
146
156
  list: List,
147
157
  lock: Lock,
@@ -157,6 +167,7 @@ const ICONS = {
157
167
  pencil: Pencil,
158
168
  play: Play,
159
169
  plus: Plus,
170
+ printer: Printer,
160
171
  'refresh-cw': RefreshCw,
161
172
  repeat: Repeat,
162
173
  replace: Replace,
@@ -169,6 +180,7 @@ const ICONS = {
169
180
  'shield-alert': ShieldAlert,
170
181
  'shield-check': ShieldCheck,
171
182
  'sliders-horizontal': SlidersHorizontal,
183
+ star: Star,
172
184
  sun: Sun,
173
185
  timer: Timer,
174
186
  'trash-2': Trash2,
@@ -177,6 +189,8 @@ const ICONS = {
177
189
  upload: Upload,
178
190
  'user-round': UserRound,
179
191
  users: Users,
192
+ wallet: Wallet,
193
+ wrench: Wrench,
180
194
  x: X,
181
195
  'x-circle': XCircle,
182
196
  };