@sincpro/web-ui 2.12.0 → 2.13.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 (73) hide show
  1. package/README.md +42 -17
  2. package/dist/components/index.d.ts +1 -0
  3. package/dist/components/index.js +1 -0
  4. package/dist/components/listing/BoardColumns.js +10 -6
  5. package/dist/components/listing/Listing.js +3 -1
  6. package/dist/components/listing/ListingBar.d.ts +16 -94
  7. package/dist/components/listing/ListingBar.js +24 -2
  8. package/dist/components/listing/RecordCard.d.ts +41 -3
  9. package/dist/components/listing/RecordCard.js +63 -22
  10. package/dist/components/listing/Row.js +5 -2
  11. package/dist/components/listing/index.d.ts +2 -2
  12. package/dist/components/listing/index.js +2 -2
  13. package/dist/components/listing/set.d.ts +1 -1
  14. package/dist/components/receipt/Receipt.d.ts +51 -0
  15. package/dist/components/receipt/Receipt.js +23 -0
  16. package/dist/components/receipt/index.d.ts +1 -0
  17. package/dist/components/receipt/index.js +3 -0
  18. package/dist/components/search/CriteriaChips.js +5 -3
  19. package/dist/components/shell/KioskFrame.d.ts +35 -0
  20. package/dist/components/shell/KioskFrame.js +39 -0
  21. package/dist/components/shell/SearchEntry.js +1 -1
  22. package/dist/components/shell/index.d.ts +1 -0
  23. package/dist/components/shell/index.js +1 -0
  24. package/dist/foundations/clock.d.ts +3 -0
  25. package/dist/foundations/clock.js +41 -0
  26. package/dist/foundations/copy.es.js +26 -0
  27. package/dist/foundations/idle.d.ts +1 -0
  28. package/dist/foundations/idle.js +34 -0
  29. package/dist/foundations/index.d.ts +3 -0
  30. package/dist/foundations/index.js +7 -0
  31. package/dist/foundations/pointer.d.ts +25 -0
  32. package/dist/foundations/pointer.js +28 -0
  33. package/dist/foundations/uiCopy.d.ts +38 -0
  34. package/dist/foundations/uiCopy.js +26 -0
  35. package/dist/primitives/choice/RadioGroup.d.ts +8 -1
  36. package/dist/primitives/choice/RadioGroup.js +9 -1
  37. package/dist/primitives/choice/options.d.ts +3 -0
  38. package/dist/primitives/field/Keypad.d.ts +43 -0
  39. package/dist/primitives/field/Keypad.js +62 -0
  40. package/dist/primitives/field/Stepper.d.ts +28 -0
  41. package/dist/primitives/field/Stepper.js +52 -0
  42. package/dist/primitives/field/clipboard.js +1 -1
  43. package/dist/primitives/field/index.d.ts +3 -0
  44. package/dist/primitives/field/index.js +6 -0
  45. package/dist/primitives/field/keypadKeys.d.ts +24 -0
  46. package/dist/primitives/field/keypadKeys.js +80 -0
  47. package/dist/primitives/hint/Hint.js +1 -1
  48. package/dist/primitives/notice/Flag.js +1 -1
  49. package/dist/primitives/notice/Outcome.d.ts +28 -0
  50. package/dist/primitives/notice/Outcome.js +28 -0
  51. package/dist/primitives/notice/index.d.ts +1 -0
  52. package/dist/primitives/notice/index.js +2 -0
  53. package/dist/primitives/table/CellCopy.js +1 -1
  54. package/dist/primitives/table/ReportTable.js +1 -1
  55. package/dist/primitives/table/RowActions.js +1 -1
  56. package/dist/primitives/table/Table.js +9 -5
  57. package/dist/primitives/tag/Tags.d.ts +22 -1
  58. package/dist/primitives/tag/Tags.js +57 -14
  59. package/dist/primitives/tag/index.d.ts +1 -1
  60. package/dist/primitives/value/Elapsed.d.ts +16 -0
  61. package/dist/primitives/value/Elapsed.js +37 -0
  62. package/dist/primitives/value/elapsedTime.d.ts +26 -0
  63. package/dist/primitives/value/elapsedTime.js +32 -0
  64. package/dist/primitives/value/index.d.ts +2 -0
  65. package/dist/primitives/value/index.js +4 -0
  66. package/dist/tokens.css +87 -1
  67. package/dist/views/list/List.d.ts +11 -0
  68. package/dist/views/list/List.js +14 -3
  69. package/dist/views/list/ListView.d.ts +1 -1
  70. package/dist/views/list/ListView.js +26 -6
  71. package/dist/views/list/types.d.ts +7 -0
  72. package/dist/views/record/Record.js +1 -1
  73. package/package.json +1 -1
@@ -0,0 +1,43 @@
1
+ import type { ReactNode } from "react";
2
+ export type KeypadProps = {
3
+ /** The number being typed, in the machine's form: «1250.5». */
4
+ value: string;
5
+ onChange: (next: string) => void;
6
+ /** Decimals the number takes — `0` for units (no decimal key), `2` for money. */
7
+ decimals?: number;
8
+ /** The key beside the zero: the decimal point (default, unless `decimals` is 0), «00» for a
9
+ * till that types prices in cents, or «±» for an amount that can be negative. */
10
+ extra?: "decimal" | "double-zero" | "sign";
11
+ /** `lg` for a till or a kiosk — keys a thumb hits without looking; `md` beside a form. */
12
+ size?: "md" | "lg";
13
+ /** A wide key under the pad: «Cantidad», «Cobrar» — what the number is FOR. */
14
+ children?: ReactNode;
15
+ /**
16
+ * The pad's screen, on top, as a calculator has: what is being typed, big and right-aligned,
17
+ * and what it is («Capuchino · Cant.»). Without it the screen is the application's. `value`
18
+ * is already written for the person (`«12,50»`), the pad does not format it.
19
+ */
20
+ screen?: {
21
+ label?: ReactNode;
22
+ value: ReactNode;
23
+ };
24
+ /** The pad's accessible name, when no `Field` names it. */
25
+ "aria-label"?: string;
26
+ id?: string;
27
+ disabled?: boolean;
28
+ };
29
+ /**
30
+ * The on-screen number pad of a till, a kiosk, a scale — the calculator's layout (7 8 9 on
31
+ * top), keys a thumb hits.
32
+ *
33
+ * Context: a cashier types quantities and prices all day on a touch screen with no keyboard,
34
+ * and the phone's numeric keyboard covers half the ticket. The pad is a CONTROL: it edits a
35
+ * value (`value` / `onChange`, the machine's «1250.5»), and what it is for — quantity,
36
+ * discount, price — is the screen's, as a `SegmentedControl` over it. The rules of each key
37
+ * are pure (`applyKey`), the same ones a physical keyboard follows here: with the pad
38
+ * focused, digits, «,» or «.», Backspace, Delete and «-» do what their key does.
39
+ *
40
+ * The decimal key shows the person's separator («,» in Bolivia) but writes «.»: the screen
41
+ * formats, the value travels in one form.
42
+ */
43
+ export declare function Keypad({ value, onChange, decimals, extra, size, children, "aria-label": ariaLabel, id: ownId, disabled, screen, }: KeypadProps): import("react").JSX.Element;
@@ -0,0 +1,62 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useUiCopy } from "../../foundations/copy.js";
4
+ import { useFieldIds } from "../../foundations/form.js";
5
+ import { buttonClasses } from "../button/classes.js";
6
+ import { applyKey, keyOfKeyboard, } from "./keypadKeys.js";
7
+ import { Delete } from "lucide-react";
8
+ const ROWS = [
9
+ ["7", "8", "9"],
10
+ ["4", "5", "6"],
11
+ ["1", "2", "3"],
12
+ ];
13
+ /**
14
+ * The on-screen number pad of a till, a kiosk, a scale — the calculator's layout (7 8 9 on
15
+ * top), keys a thumb hits.
16
+ *
17
+ * Context: a cashier types quantities and prices all day on a touch screen with no keyboard,
18
+ * and the phone's numeric keyboard covers half the ticket. The pad is a CONTROL: it edits a
19
+ * value (`value` / `onChange`, the machine's «1250.5»), and what it is for — quantity,
20
+ * discount, price — is the screen's, as a `SegmentedControl` over it. The rules of each key
21
+ * are pure (`applyKey`), the same ones a physical keyboard follows here: with the pad
22
+ * focused, digits, «,» or «.», Backspace, Delete and «-» do what their key does.
23
+ *
24
+ * The decimal key shows the person's separator («,» in Bolivia) but writes «.»: the screen
25
+ * formats, the value travels in one form.
26
+ */
27
+ export function Keypad({ value, onChange, decimals, extra = decimals === 0 ? "double-zero" : "decimal", size = "lg", children, "aria-label": ariaLabel, id: ownId, disabled = false, screen, }) {
28
+ const copy = useUiCopy();
29
+ const { id, labelledBy, describedBy } = useFieldIds({ id: ownId });
30
+ const rules = decimals === undefined ? {} : { decimals };
31
+ const press = (key) => onChange(applyKey(value, key, rules));
32
+ const separator = new Intl.NumberFormat(copy.locale).formatToParts(1.5).find((p) => p.type === "decimal")
33
+ ?.value ?? ".";
34
+ const onKeyDown = (event) => {
35
+ if (disabled || event.altKey || event.ctrlKey || event.metaKey)
36
+ return;
37
+ const key = keyOfKeyboard(event.key);
38
+ if (key === null)
39
+ return;
40
+ if (key === "decimal" && extra !== "decimal")
41
+ return;
42
+ if (key === "sign" && extra !== "sign")
43
+ return;
44
+ event.preventDefault();
45
+ press(key);
46
+ };
47
+ const keyClass = `${buttonClasses("secondary", size)} w-full font-medium tabular-nums ${size === "lg" ? "h-14 text-title" : "text-lead"}`;
48
+ const key = (k, face, label) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => press(k), ...(label === undefined ? {} : { "aria-label": label }), "data-ui": "keypad.key", className: keyClass, children: face }, k));
49
+ const extraKey = extra === "decimal"
50
+ ? key("decimal", separator, copy.keypad.decimal)
51
+ : extra === "sign"
52
+ ? key("sign", "±", copy.keypad.sign)
53
+ : key("00", "00");
54
+ return (
55
+ /* A group, not a grid: the keys are reached by Tab in reading order, and the group itself
56
+ takes the physical keyboard while focus is inside it. */
57
+ _jsxs("div", { role: "group", "data-ui": "keypad", "data-size": size, ...(id === undefined ? {} : { id }), ...(labelledBy === undefined
58
+ ? { "aria-label": ariaLabel ?? copy.keypad.label }
59
+ : { "aria-labelledby": labelledBy }), ...(describedBy === undefined ? {} : { "aria-describedby": describedBy }), onKeyDown: onKeyDown, className: "grid w-full min-w-0 grid-cols-3 gap-1.5", children: [screen === undefined ? null : (
60
+ /* Live, so a screen reader hears the number as it is typed. */
61
+ _jsxs("div", { "data-ui": "keypad.screen", "aria-live": "polite", className: "col-span-3 flex min-w-0 flex-col items-end rounded-control border border-line bg-ink/4 px-3 py-2", children: [screen.label === undefined ? null : (_jsx("span", { className: "min-w-0 max-w-full truncate text-micro text-muted", children: screen.label })), _jsx("span", { className: "text-display leading-none font-semibold text-ink tabular-nums", children: screen.value })] })), ROWS.flat().map((k) => key(k, k)), extraKey, key("0", "0"), key("backspace", _jsx(Delete, { "aria-hidden": true, className: "size-(--size-icon-lg)" }), copy.keypad.backspace), children === undefined ? null : (_jsx("div", { className: "col-span-3 flex min-w-0", children: children }))] }));
62
+ }
@@ -0,0 +1,28 @@
1
+ import { type ControlProps } from "./Field.js";
2
+ export type StepperProps = Omit<ControlProps, "describedBy" | "invalid"> & {
3
+ value: number;
4
+ onChange: (next: number) => void;
5
+ min?: number;
6
+ max?: number;
7
+ step?: number;
8
+ /** `lg` for a kiosk or a till — targets a thumb hits; `md` in a line of a form or a cart. */
9
+ size?: "md" | "lg";
10
+ /**
11
+ * At the minimum, «−» becomes «remove» (a bin) and calls this: a cart's line goes from 1 to
12
+ * nothing in the same place, the way a shop's and a kiosk's do. Without it, «−» stops at
13
+ * `min`.
14
+ */
15
+ onRemove?: () => void;
16
+ /** What one unit is called, for the buttons' names: «Quitar un Capuchino». */
17
+ unitLabel?: string;
18
+ };
19
+ /**
20
+ * A quantity with «−» and «+» — a cart's line, a kiosk's item, the people at a table.
21
+ *
22
+ * Context: `NumberInput` is for typing a number; its small step buttons are for a mouse.
23
+ * On a touch screen a quantity is changed by pressing, not typing: two targets as big as a
24
+ * control, the figure between them in tabular digits so it does not jump. The arrows step it
25
+ * from the keyboard (the group is one stop, a spin button), Home and End go to the limits.
26
+ * With `onRemove`, «−» at the minimum is a bin and takes the line away — no second control.
27
+ */
28
+ export declare function Stepper({ value, onChange, min, max, step, size, onRemove, unitLabel, id: ownId, disabled, mode, "aria-label": ariaLabel, }: StepperProps): import("react").JSX.Element;
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { controlName } from "../../foundations/controlName.js";
4
+ import { useUiCopy } from "../../foundations/copy.js";
5
+ import { useFieldIds, useFormMode } from "../../foundations/form.js";
6
+ import { buttonClasses } from "../button/classes.js";
7
+ import { ReadValue } from "./Field.js";
8
+ import { Minus, Plus, Trash2 } from "lucide-react";
9
+ /**
10
+ * A quantity with «−» and «+» — a cart's line, a kiosk's item, the people at a table.
11
+ *
12
+ * Context: `NumberInput` is for typing a number; its small step buttons are for a mouse.
13
+ * On a touch screen a quantity is changed by pressing, not typing: two targets as big as a
14
+ * control, the figure between them in tabular digits so it does not jump. The arrows step it
15
+ * from the keyboard (the group is one stop, a spin button), Home and End go to the limits.
16
+ * With `onRemove`, «−» at the minimum is a bin and takes the line away — no second control.
17
+ */
18
+ export function Stepper({ value, onChange, min = 0, max, step = 1, size = "md", onRemove, unitLabel, id: ownId, disabled = false, mode, "aria-label": ariaLabel, }) {
19
+ const copy = useUiCopy();
20
+ const { id, labelledBy, describedBy } = useFieldIds({ id: ownId });
21
+ if (useFormMode(mode) === "read")
22
+ return _jsx(ReadValue, { value: value });
23
+ const atMin = value <= min;
24
+ const atMax = max !== undefined && value >= max;
25
+ const removes = atMin && onRemove !== undefined;
26
+ const clamp = (n) => Math.min(max ?? Number.POSITIVE_INFINITY, Math.max(min, n));
27
+ /* «Sumar uno: Capuchino» — the unit after the verb, so a list of steppers is told apart. */
28
+ const named = (verb) => (unitLabel === undefined ? verb : `${verb}: ${unitLabel}`);
29
+ const lower = () => (removes ? onRemove() : onChange(clamp(value - step)));
30
+ const raise = () => onChange(clamp(value + step));
31
+ const onKeyDown = (event) => {
32
+ if (disabled)
33
+ return;
34
+ const keys = {
35
+ ArrowUp: raise,
36
+ ArrowRight: raise,
37
+ ArrowDown: () => !atMin && onChange(clamp(value - step)),
38
+ ArrowLeft: () => !atMin && onChange(clamp(value - step)),
39
+ Home: () => onChange(min),
40
+ ...(max === undefined ? {} : { End: () => onChange(max) }),
41
+ };
42
+ const run = keys[event.key];
43
+ if (run === undefined)
44
+ return;
45
+ event.preventDefault();
46
+ run();
47
+ };
48
+ const button = `${buttonClasses("secondary", size === "lg" ? "lg" : "sm")} aspect-square px-0`;
49
+ return (_jsxs("div", { "data-ui": "stepper", "data-size": size, className: "inline-flex min-w-0 items-center gap-1.5", children: [_jsx("button", { type: "button", tabIndex: -1, disabled: disabled || (atMin && !removes), onClick: lower, "aria-label": named(removes ? copy.stepper.remove : copy.stepper.decrease), className: button, children: removes ? (_jsx(Trash2, { "aria-hidden": true, className: "size-(--size-icon-md)" })) : (_jsx(Minus, { "aria-hidden": true, className: "size-(--size-icon-md)" })) }), _jsx("div", { role: "spinbutton", tabIndex: disabled ? -1 : 0, ...(id === undefined ? {} : { id }), "aria-valuenow": value, "aria-valuemin": min, ...(max === undefined ? {} : { "aria-valuemax": max }), ...(labelledBy === undefined
50
+ ? { "aria-label": controlName(undefined, ariaLabel, copy.stepper.label) }
51
+ : { "aria-labelledby": labelledBy }), ...(describedBy === undefined ? {} : { "aria-describedby": describedBy }), "aria-disabled": disabled || undefined, onKeyDown: onKeyDown, className: `min-w-8 rounded-control text-center font-semibold text-ink tabular-nums outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary ${size === "lg" ? "text-title" : "text-body"}`, children: value }), _jsx("button", { type: "button", tabIndex: -1, disabled: disabled || atMax, onClick: raise, "aria-label": named(copy.stepper.increase), className: button, children: _jsx(Plus, { "aria-hidden": true, className: "size-(--size-icon-md)" }) })] }));
52
+ }
@@ -66,5 +66,5 @@ export function shownText(root) {
66
66
  /** The button by a field's label. `scope` is the field's value area. */
67
67
  export function FieldCopy({ label, scope, value, }) {
68
68
  const ui = useUiCopy();
69
- return (_jsx("span", { "data-copy-skip": "", className: "inline-flex shrink-0 opacity-0 transition-opacity duration-(--duration-instant) group-hover/field:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100", children: _jsx(CopyButton, { label: fillCopy(ui.copyable.field, { label }), value: () => value ?? (scope.current === null ? "" : shownText(scope.current)) }) }));
69
+ return (_jsx("span", { "data-copy-skip": "", className: "inline-flex shrink-0 opacity-0 transition-opacity duration-(--duration-instant) group-hover/field:opacity-100 focus-within:opacity-100 touch:opacity-100", children: _jsx(CopyButton, { label: fillCopy(ui.copyable.field, { label }), value: () => value ?? (scope.current === null ? "" : shownText(scope.current)) }) }));
70
70
  }
@@ -5,6 +5,9 @@ export { CodeInput } from "./CodeInput.js";
5
5
  export { ColorInput } from "./ColorInput.js";
6
6
  export { emailHref, isEmail, isUrl, telHref, urlHref, urlLabel, whatsappHref, } from "./contact.js";
7
7
  export { EmailInput, PhoneInput, UrlInput, } from "./ContactInputs.js";
8
+ export { Keypad, type KeypadProps } from "./Keypad.js";
9
+ export { applyKey, isKeypadKey, keyOfKeyboard, type KeypadKey, type KeypadRules, } from "./keypadKeys.js";
10
+ export { Stepper, type StepperProps } from "./Stepper.js";
8
11
  export { FieldCopyProvider, shownText, useFieldCopy, } from "./clipboard.js";
9
12
  export { DropZone, type DropZoneProps } from "./DropZone.js";
10
13
  export { formatDuration, parseDuration } from "./duration.js";
@@ -10,9 +10,15 @@ export { CardCodeInput, CardExpiryInput, CardNumberInput, } from "./CardNumberIn
10
10
  /* An address to reach someone: typed with its keyboard, read as a link. */
11
11
  export { Checkbox, CheckList, CheckMark, } from "./Checks.js";
12
12
  export { CodeInput } from "./CodeInput.js";
13
+ /* THE PAD — a till's or a kiosk's on-screen numbers. Its rules are pure (`keypadKeys.ts`), so a
14
+ physical keyboard or a test applies the same. */
13
15
  export { ColorInput } from "./ColorInput.js";
14
16
  export { emailHref, isEmail, isUrl, telHref, urlHref, urlLabel, whatsappHref, } from "./contact.js";
15
17
  export { EmailInput, PhoneInput, UrlInput, } from "./ContactInputs.js";
18
+ export { Keypad } from "./Keypad.js";
19
+ /* A QUANTITY pressed, not typed — a cart's line, a kiosk's item. */
20
+ export { applyKey, isKeypadKey, keyOfKeyboard, } from "./keypadKeys.js";
21
+ export { Stepper } from "./Stepper.js";
16
22
  /* The copy button every field carries by its label — on by default, off by field or by form. */
17
23
  export { FieldCopyProvider, shownText, useFieldCopy, } from "./clipboard.js";
18
24
  export { DropZone } from "./DropZone.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * WHAT A KEY OF THE PAD DOES TO THE NUMBER BEING TYPED — pure, so a test, a server or a
3
+ * keyboard handler applies the same rules as the on-screen pad (`Keypad`).
4
+ *
5
+ * Context: a till types quantities, discounts and prices with a thumb. The text is kept in
6
+ * the machine's form — digits, one «.», an optional leading «-» — and the screen formats it
7
+ * in the person's locale: what travels is «1250.5», what is read is «1.250,5». The rules
8
+ * are the ones a cashier expects from a calculator: «0» then «5» is «5», not «05»; a second
9
+ * decimal point does nothing; past the allowed decimals a digit does nothing; ⌫ on «-» leaves
10
+ * nothing.
11
+ */
12
+ export type KeypadKey = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "00" | "decimal" | "backspace" | "clear" | "sign";
13
+ export type KeypadRules = {
14
+ /** How many decimals the number takes — `0` for a quantity of units, `2` for money. A
15
+ * digit past them does nothing. Without it, any. */
16
+ decimals?: number;
17
+ };
18
+ /** True for a key of the pad: what comes from a physical keyboard is a string. */
19
+ export declare function isKeypadKey(key: string): key is KeypadKey;
20
+ /** The text after pressing `key`. */
21
+ export declare function applyKey(text: string, key: KeypadKey, rules?: KeypadRules): string;
22
+ /** The key a physical keyboard's key stands for, or `null`: digits, «.» and «,» (the decimal
23
+ * point whatever the locale), Backspace, Delete / Escape (clear), «-» (sign). */
24
+ export declare function keyOfKeyboard(key: string): KeypadKey | null;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * WHAT A KEY OF THE PAD DOES TO THE NUMBER BEING TYPED — pure, so a test, a server or a
3
+ * keyboard handler applies the same rules as the on-screen pad (`Keypad`).
4
+ *
5
+ * Context: a till types quantities, discounts and prices with a thumb. The text is kept in
6
+ * the machine's form — digits, one «.», an optional leading «-» — and the screen formats it
7
+ * in the person's locale: what travels is «1250.5», what is read is «1.250,5». The rules
8
+ * are the ones a cashier expects from a calculator: «0» then «5» is «5», not «05»; a second
9
+ * decimal point does nothing; past the allowed decimals a digit does nothing; ⌫ on «-» leaves
10
+ * nothing.
11
+ */
12
+ const DIGITS = new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]);
13
+ /** True for a key of the pad: what comes from a physical keyboard is a string. */
14
+ export function isKeypadKey(key) {
15
+ return (DIGITS.has(key) ||
16
+ key === "00" ||
17
+ key === "decimal" ||
18
+ key === "backspace" ||
19
+ key === "clear" ||
20
+ key === "sign");
21
+ }
22
+ function appendDigits(text, digits, rules) {
23
+ let next = text;
24
+ for (const digit of digits) {
25
+ const sign = next.startsWith("-") ? "-" : "";
26
+ const body = next.slice(sign.length);
27
+ const point = body.indexOf(".");
28
+ if (point >= 0 &&
29
+ rules.decimals !== undefined &&
30
+ body.length - point - 1 >= rules.decimals) {
31
+ return next;
32
+ }
33
+ /* A lone zero is replaced, not prefixed: «0» then «5» is «5». */
34
+ next = body === "0" ? `${sign}${digit}` : `${next}${digit}`;
35
+ }
36
+ return next;
37
+ }
38
+ /** The text after pressing `key`. */
39
+ export function applyKey(text, key, rules = {}) {
40
+ if (key === "clear")
41
+ return "";
42
+ if (key === "backspace") {
43
+ const next = text.slice(0, -1);
44
+ return next === "-" ? "" : next;
45
+ }
46
+ if (key === "sign") {
47
+ if (text === "")
48
+ return text;
49
+ return text.startsWith("-") ? text.slice(1) : `-${text}`;
50
+ }
51
+ if (key === "decimal") {
52
+ if (rules.decimals === 0 || text.includes("."))
53
+ return text;
54
+ const sign = text.startsWith("-") ? "-" : "";
55
+ const body = text.slice(sign.length);
56
+ return `${sign}${body === "" ? "0" : body}.`;
57
+ }
58
+ if (key === "00") {
59
+ /* Two zeros on nothing is still nothing typed: «00» is how a cashier writes hundreds. */
60
+ if (text === "" || text === "-" || text === "0")
61
+ return text;
62
+ return appendDigits(text, "00", rules);
63
+ }
64
+ return appendDigits(text, key, rules);
65
+ }
66
+ /** The key a physical keyboard's key stands for, or `null`: digits, «.» and «,» (the decimal
67
+ * point whatever the locale), Backspace, Delete / Escape (clear), «-» (sign). */
68
+ export function keyOfKeyboard(key) {
69
+ if (DIGITS.has(key))
70
+ return key;
71
+ if (key === "." || key === ",")
72
+ return "decimal";
73
+ if (key === "Backspace")
74
+ return "backspace";
75
+ if (key === "Delete" || key === "Escape")
76
+ return "clear";
77
+ if (key === "-")
78
+ return "sign";
79
+ return null;
80
+ }
@@ -6,7 +6,7 @@ import { CircleHelp } from "lucide-react";
6
6
  import { useId } from "react";
7
7
  import { Button, Dialog, DialogTrigger } from "react-aria-components";
8
8
  const mark = tv({
9
- base: "inline-flex size-4 shrink-0 cursor-help items-center justify-center rounded-pill text-muted outline-0 transition-colors duration-(--duration-instant) hover:bg-ink/8 hover:text-ink aria-expanded:bg-ink/8 aria-expanded:text-ink forced-colors:text-[ButtonText]",
9
+ base: "hit-target inline-flex size-4 shrink-0 cursor-help items-center justify-center rounded-pill text-muted outline-0 transition-colors duration-(--duration-instant) hover:bg-ink/8 hover:text-ink aria-expanded:bg-ink/8 aria-expanded:text-ink forced-colors:text-[ButtonText]",
10
10
  variants: {
11
11
  isFocusVisible: {
12
12
  true: "outline-2 outline-offset-1 outline-primary forced-colors:outline-[Highlight]",
@@ -11,7 +11,7 @@ const ICON = {
11
11
  good: CircleCheck,
12
12
  };
13
13
  const mark = tv({
14
- base: "inline-flex size-5 shrink-0 cursor-default items-center justify-center rounded-pill outline-0 transition-colors duration-(--duration-instant) forced-colors:text-[ButtonText]",
14
+ base: "hit-target inline-flex size-5 shrink-0 cursor-default items-center justify-center rounded-pill outline-0 transition-colors duration-(--duration-instant) forced-colors:text-[ButtonText]",
15
15
  variants: {
16
16
  tone: {
17
17
  bad: "bg-bad/12 text-bad hover:bg-bad/20 aria-expanded:bg-bad/20",
@@ -0,0 +1,28 @@
1
+ import type { Tone } from "../../foundations/types.js";
2
+ import { type LucideIcon } from "lucide-react";
3
+ import type { ReactNode } from "react";
4
+ export type OutcomeProps = {
5
+ /** What happened, as a sentence: «Pedido confirmado». */
6
+ title: string;
7
+ /** The ONE thing to remember, big: the order's number, the change to hand back. */
8
+ figure?: ReactNode;
9
+ /** What the figure is, read before it — «Tu número». */
10
+ figureLabel?: string;
11
+ /** What follows: «Te llamamos en pantalla cuando esté listo». */
12
+ detail?: ReactNode;
13
+ /** The way on — «Nuevo pedido». Usually one button; the screen may also move on by itself. */
14
+ action?: ReactNode;
15
+ /** `good` for a success (the default), `warn` for «done, but…», `bad` for «it did not go». */
16
+ tone?: Tone;
17
+ icon?: LucideIcon;
18
+ };
19
+ /**
20
+ * The end of an operation, said big — the screen after paying, a kiosk's «tu número es 118».
21
+ *
22
+ * Context: a toast is enough for a cashier who keeps selling; it is not for the person at a
23
+ * kiosk who walks away, nor for a checkout whose end is the page. They need the end AS the
24
+ * screen: what happened, the one figure to remember, and the way on. It is a status
25
+ * (`role="status"`): a screen reader announces it when it appears, without moving the focus
26
+ * off the action that follows.
27
+ */
28
+ export declare function Outcome({ title, figure, figureLabel, detail, action, tone, icon, }: OutcomeProps): import("react").JSX.Element;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useUiCopy } from "../../foundations/copy.js";
4
+ import { CircleAlert, CircleCheck } from "lucide-react";
5
+ /* The icon's tone — and only the icon's: the sentence stays ink, so it reads at 4.5:1 on any
6
+ surface. */
7
+ const ICON_TONE = {
8
+ neutral: "text-muted",
9
+ info: "text-info",
10
+ good: "text-good",
11
+ warn: "text-warn",
12
+ bad: "text-bad",
13
+ accent: "text-primary",
14
+ };
15
+ /**
16
+ * The end of an operation, said big — the screen after paying, a kiosk's «tu número es 118».
17
+ *
18
+ * Context: a toast is enough for a cashier who keeps selling; it is not for the person at a
19
+ * kiosk who walks away, nor for a checkout whose end is the page. They need the end AS the
20
+ * screen: what happened, the one figure to remember, and the way on. It is a status
21
+ * (`role="status"`): a screen reader announces it when it appears, without moving the focus
22
+ * off the action that follows.
23
+ */
24
+ export function Outcome({ title, figure, figureLabel, detail, action, tone = "good", icon, }) {
25
+ const copy = useUiCopy();
26
+ const Icon = icon ?? (tone === "bad" || tone === "warn" ? CircleAlert : CircleCheck);
27
+ return (_jsxs("div", { role: "status", "data-ui": "outcome", "data-tone": tone, className: "flex min-w-0 flex-col items-center gap-3 px-4 py-10 text-center", children: [_jsx(Icon, { "aria-hidden": true, className: `size-12 ${ICON_TONE[tone]}`, strokeWidth: 1.75 }), _jsx("p", { className: "text-title font-semibold text-ink", children: title }), figure === undefined ? null : (_jsxs("p", { "data-ui": "outcome.figure", className: "flex flex-col items-center gap-1", children: [_jsx("span", { className: "text-meta text-muted", children: figureLabel ?? copy.outcome.figure }), _jsx("span", { className: "text-hero leading-none font-semibold text-ink tabular-nums", children: figure })] })), detail === undefined ? null : (_jsx("p", { className: "max-w-short text-body text-muted", children: detail })), action === undefined ? null : (_jsx("div", { className: "flex flex-wrap justify-center gap-2 pt-2", children: action }))] }));
28
+ }
@@ -1,4 +1,5 @@
1
1
  export { Callout, type CalloutProps } from "./Callout.js";
2
2
  export { Flag, type FlagProps, type FlagTone } from "./Flag.js";
3
3
  export { Empty, Failed, ICONO_ROTO, Missing, Skeleton, } from "./Notice.js";
4
+ export { Outcome, type OutcomeProps } from "./Outcome.js";
4
5
  export { ToastProvider, type ToastSpec, useToast, useToastIfAny, } from "./Toast.js";
@@ -3,4 +3,6 @@
3
3
  export { Callout } from "./Callout.js";
4
4
  export { Flag } from "./Flag.js";
5
5
  export { Empty, Failed, ICONO_ROTO, Missing, Skeleton, } from "./Notice.js";
6
+ /* The END of an operation, said big: a kiosk's «tu número es 118», a paid checkout. */
7
+ export { Outcome } from "./Outcome.js";
6
8
  export { ToastProvider, useToast, useToastIfAny, } from "./Toast.js";
@@ -18,6 +18,6 @@ import { useRef } from "react";
18
18
  export function CellCopy({ children, header, numeric = false, value, }) {
19
19
  const ui = useUiCopy();
20
20
  const shown = useRef(null);
21
- const button = (_jsx("span", { "data-copy-skip": "", className: "inline-flex shrink-0 opacity-0 transition-opacity duration-(--duration-instant) group-hover/cell:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100", children: _jsx(CopyButton, { label: fillCopy(ui.copyable.field, { label: header }), value: () => value ?? (shown.current === null ? "" : shownText(shown.current)) }) }));
21
+ const button = (_jsx("span", { "data-copy-skip": "", className: "inline-flex shrink-0 opacity-0 transition-opacity duration-(--duration-instant) group-hover/cell:opacity-100 focus-within:opacity-100 touch:opacity-100", children: _jsx(CopyButton, { label: fillCopy(ui.copyable.field, { label: header }), value: () => value ?? (shown.current === null ? "" : shownText(shown.current)) }) }));
22
22
  return (_jsxs("span", { className: `group/cell flex w-full min-w-0 items-center gap-1 ${numeric ? "justify-end" : ""}`, children: [numeric ? button : null, _jsx("span", { ref: shown, className: "min-w-0", children: children }), numeric ? null : button] }));
23
23
  }
@@ -68,7 +68,7 @@ function ReportLine({ row, columns, open, onToggle, compact, }) {
68
68
  onToggle(row.id);
69
69
  }, "aria-expanded": isOpen, "aria-label": fillCopy(isOpen ? copy.report.close : copy.report.open, {
70
70
  name: row.label,
71
- }), className: "-ml-1 inline-flex size-4 shrink-0 items-center justify-center rounded-pill text-muted transition-colors duration-(--duration-instant) hover:bg-ink/8 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: _jsx(ChevronRight, { className: `size-(--size-icon-sm) transition-transform duration-(--duration-instant) ${isOpen ? "rotate-90" : ""}`, strokeWidth: 2 }) })) : (
71
+ }), className: "hit-target -ml-1 inline-flex size-4 shrink-0 items-center justify-center rounded-pill text-muted transition-colors duration-(--duration-instant) hover:bg-ink/8 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: _jsx(ChevronRight, { className: `size-(--size-icon-sm) transition-transform duration-(--duration-instant) ${isOpen ? "rotate-90" : ""}`, strokeWidth: 2 }) })) : (
72
72
  /* The slot for the chevron is reserved anyway: without it, a leaf
73
73
  account and a collapsible one would start on different
74
74
  verticals and the hierarchy would stop reading. */
@@ -44,7 +44,7 @@ inline = 2, }) {
44
44
  return (
45
45
  /* The row's hairline runs under its actions too: without it the separators stopped one
46
46
  column short and the actions read as outside the table. */
47
- _jsx("td", { className: `w-0 border-b border-line py-1 pr-2 pl-1 align-middle whitespace-nowrap last:rounded-r-control ${wash}`, children: _jsxs("div", { onClick: (e) => e.stopPropagation(), className: "flex items-center justify-end gap-0.5 opacity-0 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100", children: [ways.length === 0 ? null : (_jsx("span", { "data-ui": "row.ways", "data-look": pill ? "pill" : "plain", className: `flex items-center gap-0.5 ${pill ? "rounded-pill border border-primary/20 bg-primary/8 p-0.5" : ""}`, children: ways.map((way) => (_jsx(WayButton, { way: way, pill: pill }, way.id))) })), inlineActions.map((a) => (_jsx(IconButton, { icon: a.icon, label: a.label, size: "sm", ...(a.tone === undefined ? {} : { tone: a.tone }), ...(a.disabled === undefined ? {} : { disabled: a.disabled }), onClick: a.onSelect }, a.id))), overflow.length === 0 ? null : (_jsx(Menu, { label: copy.selection.more, icon: MoreHorizontal, iconOnly: true, chevron: false, align: "end", groups: [
47
+ _jsx("td", { className: `w-0 border-b border-line py-1 pr-2 pl-1 align-middle whitespace-nowrap last:rounded-r-control ${wash}`, children: _jsxs("div", { onClick: (e) => e.stopPropagation(), className: "flex items-center justify-end gap-0.5 opacity-0 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 focus-within:opacity-100 touch:opacity-100", children: [ways.length === 0 ? null : (_jsx("span", { "data-ui": "row.ways", "data-look": pill ? "pill" : "plain", className: `flex items-center gap-0.5 ${pill ? "rounded-pill border border-primary/20 bg-primary/8 p-0.5" : ""}`, children: ways.map((way) => (_jsx(WayButton, { way: way, pill: pill }, way.id))) })), inlineActions.map((a) => (_jsx(IconButton, { icon: a.icon, label: a.label, size: "sm", ...(a.tone === undefined ? {} : { tone: a.tone }), ...(a.disabled === undefined ? {} : { disabled: a.disabled }), onClick: a.onSelect }, a.id))), overflow.length === 0 ? null : (_jsx(Menu, { label: copy.selection.more, icon: MoreHorizontal, iconOnly: true, chevron: false, align: "end", groups: [
48
48
  {
49
49
  options: overflow.map((a) => ({
50
50
  id: a.id,
@@ -128,7 +128,7 @@ export function TrDetail({ children, detail, open, onToggle, columns, label, sel
128
128
  return (_jsx(RowMark.Provider, { value: { selected, interactive: true }, children: _jsxs(_Fragment, { children: [_jsxs("tr", { onClick: onToggle, className: "group/row cursor-pointer", children: [_jsx("td", { className: `border-b border-line py-1.5 pr-0 pl-2.5 align-middle first:rounded-l-control ${rowWash({ selected, interactive: true })}`, children: _jsx("button", { type: "button", onClick: (e) => {
129
129
  e.stopPropagation();
130
130
  onToggle();
131
- }, "aria-expanded": open, "aria-controls": id, "aria-label": label, className: "inline-flex size-5 items-center justify-center rounded-pill text-muted transition-colors duration-(--duration-instant) hover:bg-ink/6 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary", children: _jsx(ChevronRight, { className: `size-(--size-icon-sm) transition-transform duration-(--duration-instant) ${open ? "rotate-90" : ""}`, strokeWidth: 2 }) }) }), children] }), _jsx("tr", { id: id, hidden: !open, children: _jsx("td", { colSpan: columns + 1, className: "border-b border-line bg-ground px-3 py-3", children: detail }) })] }) }));
131
+ }, "aria-expanded": open, "aria-controls": id, "aria-label": label, className: "hit-target inline-flex size-5 items-center justify-center rounded-pill text-muted transition-colors duration-(--duration-instant) hover:bg-ink/6 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary", children: _jsx(ChevronRight, { className: `size-(--size-icon-sm) transition-transform duration-(--duration-instant) ${open ? "rotate-90" : ""}`, strokeWidth: 2 }) }) }), children] }), _jsx("tr", { id: id, hidden: !open, children: _jsx("td", { colSpan: columns + 1, className: "border-b border-line bg-ground px-3 py-3", children: detail }) })] }) }));
132
132
  }
133
133
  /* `CELL_TONE` is a plain table (`cellTone.ts`), without the directive, so a server component
134
134
  reads it; re-exported so every path that read it here keeps reading it. */
@@ -159,8 +159,12 @@ tone, title, }) {
159
159
  * three of forty rows selected lies in both directions — empty says «none»
160
160
  * and filled says «all». */
161
161
  export function SelectBox({ checked, indeterminate = false, onChange, label, }) {
162
- return (_jsx("input", { type: "checkbox", checked: checked, "aria-label": label, ref: (el) => {
163
- if (el !== null)
164
- el.indeterminate = indeterminate && !checked;
165
- }, onChange: (e) => onChange?.(e.target.checked), onClick: (e) => e.stopPropagation(), className: "size-3.5 shrink-0 cursor-pointer accent-primary" }));
162
+ return (
163
+ /* The box is drawn small so a list keeps its density, and it answers to `--size-target`
164
+ around it (44px under a finger): the label is the target. A tap on it never reaches the
165
+ row, which would open the record instead of choosing it. */
166
+ _jsx("label", { className: "hit-target inline-flex shrink-0 cursor-pointer", onClick: (e) => e.stopPropagation(), children: _jsx("input", { type: "checkbox", checked: checked, "aria-label": label, ref: (el) => {
167
+ if (el !== null)
168
+ el.indeterminate = indeterminate && !checked;
169
+ }, onChange: (e) => onChange?.(e.target.checked), onClick: (e) => e.stopPropagation(), className: "size-3.5 shrink-0 cursor-pointer accent-primary touch:size-5" }) }));
166
170
  }
@@ -19,6 +19,9 @@ export type TagItem = {
19
19
  * the chip; this replaces the verb when the chip needs a more exact one
20
20
  * («quitar el filtro»). */
21
21
  removeLabel?: string;
22
+ /** How many records answer to it — «Bebidas 12», «Pagada 187». Drawn after the label in
23
+ * figures that line up, so a strip of filters reads as a small histogram. */
24
+ count?: number | string;
22
25
  /** It is chosen right now. */
23
26
  selected?: boolean;
24
27
  /** It is MARKED by the keyboard of someone else — the search input that
@@ -31,7 +34,18 @@ export type TagItem = {
31
34
  tone?: Tone;
32
35
  title?: string;
33
36
  };
34
- export declare function Tags({ items, surface, label, labelledBy, stack, multiple, }: {
37
+ /**
38
+ * How big a chip is drawn — a PLACE, like a button's size:
39
+ *
40
+ * sm a line of text: the chips of a field, of a search bar, of a row
41
+ * md a control of the bar: the quick filters over a list, a shop's facets
42
+ * lg a till's or a kiosk's categories — aimed at from arm's length
43
+ *
44
+ * `md` and `lg` are as tall as the controls (`--size-control-sm` / `-lg`), so under a finger
45
+ * they grow with the rest; `sm` grows to a size a thumb can aim at.
46
+ */
47
+ export type TagsSize = "sm" | "md" | "lg";
48
+ export declare function Tags({ items, surface, label, labelledBy, stack, multiple, size, scroll, }: {
35
49
  items: readonly TagItem[];
36
50
  /** By default it inherits the surface that wraps it. */
37
51
  surface?: Surface;
@@ -56,4 +70,11 @@ export declare function Tags({ items, surface, label, labelledBy, stack, multipl
56
70
  * default the choice is ONE — a join, a grain, a period — and the strip is
57
71
  * announced as single-select. */
58
72
  multiple?: boolean;
73
+ size?: TagsSize;
74
+ /**
75
+ * One line that scrolls sideways, instead of wrapping. The categories of a till are read
76
+ * in a row and found by position — wrapped into three lines they move every time one is
77
+ * added. The edges fade while there is more to see.
78
+ */
79
+ scroll?: boolean;
59
80
  }): import("react").JSX.Element | null;