@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.
- package/README.md +42 -17
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/listing/BoardColumns.js +10 -6
- package/dist/components/listing/Listing.js +3 -1
- package/dist/components/listing/ListingBar.d.ts +16 -94
- package/dist/components/listing/ListingBar.js +24 -2
- package/dist/components/listing/RecordCard.d.ts +41 -3
- package/dist/components/listing/RecordCard.js +63 -22
- package/dist/components/listing/Row.js +5 -2
- package/dist/components/listing/index.d.ts +2 -2
- package/dist/components/listing/index.js +2 -2
- package/dist/components/listing/set.d.ts +1 -1
- package/dist/components/receipt/Receipt.d.ts +51 -0
- package/dist/components/receipt/Receipt.js +23 -0
- package/dist/components/receipt/index.d.ts +1 -0
- package/dist/components/receipt/index.js +3 -0
- package/dist/components/search/CriteriaChips.js +5 -3
- package/dist/components/shell/KioskFrame.d.ts +35 -0
- package/dist/components/shell/KioskFrame.js +39 -0
- package/dist/components/shell/SearchEntry.js +1 -1
- package/dist/components/shell/index.d.ts +1 -0
- package/dist/components/shell/index.js +1 -0
- package/dist/foundations/clock.d.ts +3 -0
- package/dist/foundations/clock.js +41 -0
- package/dist/foundations/copy.es.js +26 -0
- package/dist/foundations/idle.d.ts +1 -0
- package/dist/foundations/idle.js +34 -0
- package/dist/foundations/index.d.ts +3 -0
- package/dist/foundations/index.js +7 -0
- package/dist/foundations/pointer.d.ts +25 -0
- package/dist/foundations/pointer.js +28 -0
- package/dist/foundations/uiCopy.d.ts +38 -0
- package/dist/foundations/uiCopy.js +26 -0
- package/dist/primitives/choice/RadioGroup.d.ts +8 -1
- package/dist/primitives/choice/RadioGroup.js +9 -1
- package/dist/primitives/choice/options.d.ts +3 -0
- package/dist/primitives/field/Keypad.d.ts +43 -0
- package/dist/primitives/field/Keypad.js +62 -0
- package/dist/primitives/field/Stepper.d.ts +28 -0
- package/dist/primitives/field/Stepper.js +52 -0
- package/dist/primitives/field/clipboard.js +1 -1
- package/dist/primitives/field/index.d.ts +3 -0
- package/dist/primitives/field/index.js +6 -0
- package/dist/primitives/field/keypadKeys.d.ts +24 -0
- package/dist/primitives/field/keypadKeys.js +80 -0
- package/dist/primitives/hint/Hint.js +1 -1
- package/dist/primitives/notice/Flag.js +1 -1
- package/dist/primitives/notice/Outcome.d.ts +28 -0
- package/dist/primitives/notice/Outcome.js +28 -0
- package/dist/primitives/notice/index.d.ts +1 -0
- package/dist/primitives/notice/index.js +2 -0
- package/dist/primitives/table/CellCopy.js +1 -1
- package/dist/primitives/table/ReportTable.js +1 -1
- package/dist/primitives/table/RowActions.js +1 -1
- package/dist/primitives/table/Table.js +9 -5
- package/dist/primitives/tag/Tags.d.ts +22 -1
- package/dist/primitives/tag/Tags.js +57 -14
- package/dist/primitives/tag/index.d.ts +1 -1
- package/dist/primitives/value/Elapsed.d.ts +16 -0
- package/dist/primitives/value/Elapsed.js +37 -0
- package/dist/primitives/value/elapsedTime.d.ts +26 -0
- package/dist/primitives/value/elapsedTime.js +32 -0
- package/dist/primitives/value/index.d.ts +2 -0
- package/dist/primitives/value/index.js +4 -0
- package/dist/tokens.css +87 -1
- package/dist/views/list/List.d.ts +11 -0
- package/dist/views/list/List.js +14 -3
- package/dist/views/list/ListView.d.ts +1 -1
- package/dist/views/list/ListView.js +26 -6
- package/dist/views/list/types.d.ts +7 -0
- package/dist/views/record/Record.js +1 -1
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@ import { type Pages } from "./pages.js";
|
|
|
35
35
|
* chart the same pivot, drawn: bars, lines or pie. The
|
|
36
36
|
* first grouping is the axis and the second, the series.
|
|
37
37
|
*/
|
|
38
|
-
export type BuiltInPresent = "rows" | "table" | "board" | "sheet" | "report" | "pivot" | "chart" | "calendar" | "gantt" | "timeline";
|
|
38
|
+
export type BuiltInPresent = "rows" | "table" | "board" | "tiles" | "sheet" | "report" | "pivot" | "chart" | "calendar" | "gantt" | "timeline";
|
|
39
39
|
/** A presentation of a list: one the package draws, or the `id` of a `List.Present` the
|
|
40
40
|
* application wrote. `string & {}` keeps the built-in names in autocomplete. */
|
|
41
41
|
export type ListPresent = BuiltInPresent | (string & {});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/** One line of the ticket: how many, of what, for how much (already written). */
|
|
3
|
+
export type ReceiptLine = {
|
|
4
|
+
quantity: number | string;
|
|
5
|
+
name: string;
|
|
6
|
+
/** The line's amount, written for the person: «Bs 40,00». */
|
|
7
|
+
amount: ReactNode;
|
|
8
|
+
/** A note under it: «sin cebolla», «2 × Bs 20,00». */
|
|
9
|
+
note?: string;
|
|
10
|
+
};
|
|
11
|
+
/** A fact or a total: «Subtotal · Bs 76,00». `total` is the line that closes it, bigger. */
|
|
12
|
+
export type ReceiptRow = {
|
|
13
|
+
label: string;
|
|
14
|
+
value: ReactNode;
|
|
15
|
+
total?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type ReceiptProps = {
|
|
18
|
+
/** Who sells: the business name on top, big. */
|
|
19
|
+
issuer: string;
|
|
20
|
+
/** Under it, small and centred: the tax id, the address, the branch. */
|
|
21
|
+
issuerLines?: readonly string[];
|
|
22
|
+
/** The document's name — «FACTURA», «NOTA DE VENTA», «PEDIDO» — between rules. */
|
|
23
|
+
document: string;
|
|
24
|
+
/** Its facts: number, date, cashier, customer and tax id. */
|
|
25
|
+
facts?: readonly ReceiptRow[];
|
|
26
|
+
lines: readonly ReceiptLine[];
|
|
27
|
+
totals: readonly ReceiptRow[];
|
|
28
|
+
/** The closing words: the legend the law asks for, «¡Gracias por su compra!». */
|
|
29
|
+
footer?: readonly string[];
|
|
30
|
+
/** Something to scan or copy under everything — a QR the application draws, a control
|
|
31
|
+
* code. Drawn centred. */
|
|
32
|
+
code?: ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* `paper` is the printed ticket: the width of an 80 mm roll, monospaced figures, what a
|
|
35
|
+
* thermal printer gives. `screen` is the same document read on a screen across the counter
|
|
36
|
+
* (a customer display, a kiosk's summary): bigger, in the system's type.
|
|
37
|
+
*/
|
|
38
|
+
look?: "paper" | "screen";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The ticket a till prints — a sale note, an invoice, a kitchen order — and the same document
|
|
42
|
+
* shown on a screen.
|
|
43
|
+
*
|
|
44
|
+
* Context: a POS reprints, a customer asks for the receipt by email, a kiosk shows what was
|
|
45
|
+
* ordered before paying. Each drew its own ticket, and a ticket is a fixed form people already
|
|
46
|
+
* know how to read: who sells, which document, the lines (how many, what, how much), the
|
|
47
|
+
* totals, the legend. It is a document, so it prints as itself — `print:` drops the rest of
|
|
48
|
+
* the page's chrome (`AppFrame` already does) and the ticket keeps its width. No domain: the
|
|
49
|
+
* application writes the words (a Bolivian invoice's legend, a control code).
|
|
50
|
+
*/
|
|
51
|
+
export declare function Receipt({ issuer, issuerLines, document, facts, lines, totals, footer, code, look, }: ReceiptProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* The ticket a till prints — a sale note, an invoice, a kitchen order — and the same document
|
|
5
|
+
* shown on a screen.
|
|
6
|
+
*
|
|
7
|
+
* Context: a POS reprints, a customer asks for the receipt by email, a kiosk shows what was
|
|
8
|
+
* ordered before paying. Each drew its own ticket, and a ticket is a fixed form people already
|
|
9
|
+
* know how to read: who sells, which document, the lines (how many, what, how much), the
|
|
10
|
+
* totals, the legend. It is a document, so it prints as itself — `print:` drops the rest of
|
|
11
|
+
* the page's chrome (`AppFrame` already does) and the ticket keeps its width. No domain: the
|
|
12
|
+
* application writes the words (a Bolivian invoice's legend, a control code).
|
|
13
|
+
*/
|
|
14
|
+
export function Receipt({ issuer, issuerLines = [], document, facts = [], lines, totals, footer = [], code, look = "paper", }) {
|
|
15
|
+
const paper = look === "paper";
|
|
16
|
+
const text = paper ? "text-micro" : "text-body";
|
|
17
|
+
const rule = paper ? "border-dashed border-line-strong" : "border-line";
|
|
18
|
+
return (_jsxs("article", { "data-ui": "receipt", "data-look": look, className: `mx-auto flex w-full min-w-0 flex-col gap-2 bg-surface text-ink ${paper
|
|
19
|
+
? "max-w-(--container-receipt) border border-line px-4 py-5 font-mono shadow-raised print:border-0 print:shadow-none"
|
|
20
|
+
: "max-w-(--container-short) px-1 py-2"}`, children: [_jsxs("header", { className: "flex flex-col items-center gap-0.5 text-center", children: [_jsx("h3", { className: `${paper ? "text-body" : "text-title"} font-semibold`, children: issuer }), issuerLines.map((one) => (_jsx("p", { className: `${text} text-muted`, children: one }, one)))] }), _jsx("p", { "data-ui": "receipt.document", className: `border-y py-1 text-center ${text} font-semibold tracking-wide ${rule}`, children: document }), facts.length === 0 ? null : (_jsx("dl", { className: `flex flex-col gap-0.5 ${text}`, children: facts.map((one) => (_jsxs("div", { className: "flex min-w-0 justify-between gap-3", children: [_jsx("dt", { className: "shrink-0 text-muted", children: one.label }), _jsx("dd", { className: "min-w-0 truncate text-right", children: one.value })] }, one.label))) })), _jsx("ul", { "data-ui": "receipt.lines", className: `flex flex-col gap-1 border-t pt-2 ${text} ${rule}`, children: lines.map((one, at) => (_jsxs("li", { className: "flex min-w-0 flex-col", children: [_jsxs("span", { className: "flex min-w-0 items-baseline gap-2", children: [_jsx("span", { className: "shrink-0 tabular-nums", children: one.quantity }), _jsx("span", { className: "min-w-0 flex-1", children: one.name }), _jsx("span", { className: "shrink-0 tabular-nums", children: one.amount })] }), one.note === undefined ? null : (_jsx("span", { className: "pl-6 text-muted", children: one.note }))] }, `${one.name}-${at}`))) }), _jsx("dl", { "data-ui": "receipt.totals", className: `flex flex-col gap-0.5 border-t pt-2 ${rule}`, children: totals.map((one) => (_jsxs("div", { className: `flex min-w-0 items-baseline justify-between gap-3 ${one.total === true
|
|
21
|
+
? `${paper ? "text-body" : "text-title"} font-semibold`
|
|
22
|
+
: `${text} text-muted`}`, children: [_jsx("dt", { className: "shrink-0", children: one.label }), _jsx("dd", { className: "min-w-0 truncate text-right text-ink tabular-nums", children: one.value })] }, one.label))) }), code === undefined ? null : (_jsx("div", { className: `flex justify-center border-t pt-2 ${rule}`, children: code })), footer.length === 0 ? null : (_jsx("footer", { className: `flex flex-col items-center gap-0.5 pt-1 text-center ${text} text-muted`, children: footer.map((one) => (_jsx("p", { children: one }, one))) }))] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Receipt, type ReceiptLine, type ReceiptProps, type ReceiptRow, } from "./Receipt.js";
|
|
@@ -77,7 +77,7 @@ function labelOf(node, joins) {
|
|
|
77
77
|
function GroupChain({ groups, onOpen, onRemoveMany, surface, }) {
|
|
78
78
|
const copy = useUiCopy();
|
|
79
79
|
const chain = groups.map((one) => one.label).join(" › ");
|
|
80
|
-
return (_jsxs("span", { role: "group", "aria-label": `${copy.search.groupedBy} ${chain}`, title: `${copy.search.groupedBy} ${chain}`, className: `inline-flex min-w-0 max-w-(--container-chain) items-center gap-1 rounded-ui-tag border py-0.5 pl-1.5 text-micro ${bySurface(surface, "border-line-strong bg-surface text-ink", "border-chrome-ink/30 bg-chrome-ink/8 text-chrome-ink")} ${onRemoveMany === undefined ? "pr-2" : "pr-0.5"}`, children: [_jsx(Layers, { className: `size-3 shrink-0 ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "min-w-0 truncate", children: groups.map((one, at) => (_jsxs(Fragment, { children: [at === 0 ? null : (_jsx(ChevronRight, { className: `mx-0.5 inline size-3 align-middle ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true })), onOpen === undefined ? (_jsx("span", { children: one.label })) : (_jsx("button", { type: "button", onClick: () => onOpen(one.path), title: copy.search.openBuilderHere, className: "inline rounded-control hover:underline hover:underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: one.label }))] }, one.path.join(".")))) }), onRemoveMany === undefined ? null : (_jsx("button", { type: "button", onClick: () => onRemoveMany(groups.map((one) => one.path)), "aria-label": copy.search.removeGrouping, title: copy.search.removeGrouping, className: `inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${bySurface(surface, "hover:bg-ink/10", "hover:bg-chrome-ink/20")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }))] }));
|
|
80
|
+
return (_jsxs("span", { role: "group", "aria-label": `${copy.search.groupedBy} ${chain}`, title: `${copy.search.groupedBy} ${chain}`, className: `inline-flex min-w-0 max-w-(--container-chain) items-center gap-1 rounded-ui-tag border py-0.5 pl-1.5 text-micro ${bySurface(surface, "border-line-strong bg-surface text-ink", "border-chrome-ink/30 bg-chrome-ink/8 text-chrome-ink")} ${onRemoveMany === undefined ? "pr-2" : "pr-0.5"}`, children: [_jsx(Layers, { className: `size-3 shrink-0 ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "min-w-0 truncate", children: groups.map((one, at) => (_jsxs(Fragment, { children: [at === 0 ? null : (_jsx(ChevronRight, { className: `mx-0.5 inline size-3 align-middle ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true })), onOpen === undefined ? (_jsx("span", { children: one.label })) : (_jsx("button", { type: "button", onClick: () => onOpen(one.path), title: copy.search.openBuilderHere, className: "inline rounded-control hover:underline hover:underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: one.label }))] }, one.path.join(".")))) }), onRemoveMany === undefined ? null : (_jsx("button", { type: "button", onClick: () => onRemoveMany(groups.map((one) => one.path)), "aria-label": copy.search.removeGrouping, title: copy.search.removeGrouping, className: `hit-target inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors touch:size-6 duration-(--duration-instant) ${bySurface(surface, "hover:bg-ink/10", "hover:bg-chrome-ink/20")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }))] }));
|
|
81
81
|
}
|
|
82
82
|
function Node({ node, path, onOpen, onJoin, onRemove, open, surface, }) {
|
|
83
83
|
const copy = useUiCopy();
|
|
@@ -98,13 +98,15 @@ function Node({ node, path, onOpen, onJoin, onRemove, open, surface, }) {
|
|
|
98
98
|
}
|
|
99
99
|
function Chip({ label, path, onOpen, onRemove, surface, }) {
|
|
100
100
|
const copy = useUiCopy();
|
|
101
|
-
|
|
101
|
+
/* Under a finger the chip grows to a size a thumb can aim at (32px, the label in the
|
|
102
|
+
reading size); with a mouse it stays a line of the bar. */
|
|
103
|
+
const shell = `inline-flex min-w-0 max-w-(--container-facet) items-center gap-1 rounded-ui-tag py-0.5 text-micro touch:min-h-8 touch:text-meta ${chosenTone(surface)} ${onRemove === undefined ? "px-2" : "pr-0.5 pl-2"}`;
|
|
102
104
|
const remove = onRemove === undefined ? null : (_jsx("button", { type: "button", onClick: (event) => {
|
|
103
105
|
/* Without this, removing it also opens it: the click arrives here and then
|
|
104
106
|
bubbles up. */
|
|
105
107
|
event.stopPropagation();
|
|
106
108
|
onRemove(path);
|
|
107
|
-
}, "aria-label": copy.search.removeFilter.replace("{label}", label), className: `inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${bySurface(surface, "hover:bg-primary/20", "hover:bg-chrome-link/25")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }));
|
|
109
|
+
}, "aria-label": copy.search.removeFilter.replace("{label}", label), className: `hit-target inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors touch:size-6 duration-(--duration-instant) ${bySurface(surface, "hover:bg-primary/20", "hover:bg-chrome-link/25")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }));
|
|
108
110
|
if (onOpen === undefined) {
|
|
109
111
|
return (_jsxs("span", { "data-ui": "search.chip", className: shell, children: [_jsx("span", { className: "min-w-0 truncate", children: label }), remove] }));
|
|
110
112
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type LucideIcon } from "lucide-react";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
export type KioskFrameProps = {
|
|
4
|
+
/** The self-service flow: the menu, the steps, the payment. */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** The screen that waits for someone: a title that invites, a line under it, and the call
|
|
7
|
+
* — «Tocá para pedir». Pressing anywhere on it starts. */
|
|
8
|
+
attract: {
|
|
9
|
+
title: string;
|
|
10
|
+
subtitle?: string;
|
|
11
|
+
call?: string;
|
|
12
|
+
icon?: LucideIcon;
|
|
13
|
+
};
|
|
14
|
+
/** Seconds without a touch before the kiosk goes back to `attract` and calls `onIdle` (to
|
|
15
|
+
* drop the abandoned order). 0 never. */
|
|
16
|
+
idleAfter?: number;
|
|
17
|
+
onIdle?: () => void;
|
|
18
|
+
/** Controlled: whether the attract screen is showing. Uncontrolled it starts on it. */
|
|
19
|
+
waiting?: boolean;
|
|
20
|
+
onWaitingChange?: (waiting: boolean) => void;
|
|
21
|
+
/** Who runs the kiosk, in its corner: the brand. */
|
|
22
|
+
brand?: ReactNode;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The frame of a self-service screen — a kiosk at a café, a check-in totem, a pickup point.
|
|
26
|
+
*
|
|
27
|
+
* Context: a kiosk is not an application someone opens: it waits for a stranger, is used once
|
|
28
|
+
* standing up, and is left half-way. So the frame does three things no screen inside should
|
|
29
|
+
* have to: it WAITS (an attract screen, pressed anywhere to start), it FORGETS (after
|
|
30
|
+
* `idleAfter` seconds without a touch it goes back and tells the application to drop the
|
|
31
|
+
* order), and it REACHES (a button in the corner brings the content down to the lower half
|
|
32
|
+
* for someone seated, the way the big chains' kiosks do). It says «touch» for its whole area
|
|
33
|
+
* (`data-pointer`): a kiosk's screen may report a mouse.
|
|
34
|
+
*/
|
|
35
|
+
export declare function KioskFrame({ children, attract, idleAfter, onIdle, waiting: controlled, onWaitingChange, brand, }: KioskFrameProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { useIdle } from "../../foundations/idle.js";
|
|
5
|
+
import { POINTER_ATTRIBUTE } from "../../foundations/pointer.js";
|
|
6
|
+
import { buttonClasses } from "../../primitives/button/classes.js";
|
|
7
|
+
import { Accessibility, Hand } from "lucide-react";
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
/**
|
|
10
|
+
* The frame of a self-service screen — a kiosk at a café, a check-in totem, a pickup point.
|
|
11
|
+
*
|
|
12
|
+
* Context: a kiosk is not an application someone opens: it waits for a stranger, is used once
|
|
13
|
+
* standing up, and is left half-way. So the frame does three things no screen inside should
|
|
14
|
+
* have to: it WAITS (an attract screen, pressed anywhere to start), it FORGETS (after
|
|
15
|
+
* `idleAfter` seconds without a touch it goes back and tells the application to drop the
|
|
16
|
+
* order), and it REACHES (a button in the corner brings the content down to the lower half
|
|
17
|
+
* for someone seated, the way the big chains' kiosks do). It says «touch» for its whole area
|
|
18
|
+
* (`data-pointer`): a kiosk's screen may report a mouse.
|
|
19
|
+
*/
|
|
20
|
+
export function KioskFrame({ children, attract, idleAfter = 90, onIdle, waiting: controlled, onWaitingChange, brand, }) {
|
|
21
|
+
const copy = useUiCopy();
|
|
22
|
+
const [own, setOwn] = useState(true);
|
|
23
|
+
const waiting = controlled ?? own;
|
|
24
|
+
const [low, setLow] = useState(false);
|
|
25
|
+
const setWaiting = (next) => {
|
|
26
|
+
if (controlled === undefined)
|
|
27
|
+
setOwn(next);
|
|
28
|
+
onWaitingChange?.(next);
|
|
29
|
+
};
|
|
30
|
+
useIdle(idleAfter, () => {
|
|
31
|
+
setWaiting(true);
|
|
32
|
+
setLow(false);
|
|
33
|
+
onIdle?.();
|
|
34
|
+
}, !waiting);
|
|
35
|
+
const Icon = attract.icon ?? Hand;
|
|
36
|
+
return (_jsx("div", { "data-ui": "kiosk", [POINTER_ATTRIBUTE]: "touch", className: "relative flex h-dvh min-h-0 min-w-0 flex-col bg-ground", children: waiting ? (
|
|
37
|
+
/* The whole screen is the button: a stranger does not look for a target. */
|
|
38
|
+
_jsxs("button", { type: "button", "data-ui": "kiosk.attract", onClick: () => setWaiting(false), className: "flex min-h-0 flex-1 cursor-pointer flex-col items-center justify-center gap-4 px-6 text-center outline-none focus-visible:outline-4 focus-visible:-outline-offset-8 focus-visible:outline-primary", children: [brand === undefined ? null : _jsx("span", { className: "text-meta text-muted", children: brand }), _jsx("span", { className: "text-hero leading-tight font-semibold text-ink", children: attract.title }), attract.subtitle === undefined ? null : (_jsx("span", { className: "max-w-short text-lead text-muted", children: attract.subtitle })), _jsxs("span", { className: `${buttonClasses("primary", "lg")} mt-6 gap-3`, children: [_jsx(Icon, { "aria-hidden": true, className: "size-(--size-icon-lg)" }), attract.call ?? copy.kiosk.start] })] })) : (_jsxs(_Fragment, { children: [low ? _jsx("div", { "aria-hidden": true, className: "h-(--size-kiosk-reach) shrink-0" }) : null, _jsx("div", { "data-ui": "kiosk.content", className: "flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto", children: children }), _jsx("button", { type: "button", "data-ui": "kiosk.reach", "aria-pressed": low, onClick: () => setLow((now) => !now), title: low ? copy.kiosk.reachOff : copy.kiosk.reach, "aria-label": low ? copy.kiosk.reachOff : copy.kiosk.reach, className: `${buttonClasses("secondary", "lg")} absolute bottom-4 left-4 z-30 aspect-square rounded-pill px-0 shadow-float`, children: _jsx(Accessibility, { "aria-hidden": true, className: "size-(--size-icon-lg)" }) })] })) }));
|
|
39
|
+
}
|
|
@@ -30,5 +30,5 @@ export function SearchEntry({ onSearch, label, shortcut = "K", layout = "row", s
|
|
|
30
30
|
}, ...(keys === null ? {} : { "aria-keyshortcuts": keys.aria }), className: `flex h-(--size-control-sm) min-w-0 cursor-pointer items-center gap-2 rounded-ui-control border px-2 text-meta transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 ${bar ? "shrink-0 max-sm:w-(--size-control-sm) max-sm:justify-center" : "w-full"} ${skin.box}`, "data-ui": "search-entry", "data-surface": sup, children: [_jsx(Search, { className: "size-(--size-icon-md) shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: `min-w-0 flex-1 truncate text-left ${bar ? "max-sm:sr-only" : ""}`, children: label ?? copy.shell.search }), keys === null ? null : (
|
|
31
31
|
/* Seen, not heard: `aria-keyshortcuts` already tells a screen reader, and «⌘K» read
|
|
32
32
|
aloud is noise after the name. Not drawn for a finger: a phone has no ⌘. */
|
|
33
|
-
_jsx("kbd", { "aria-hidden": true, className: `shrink-0 rounded-control border px-1.5 font-mono text-micro
|
|
33
|
+
_jsx("kbd", { "aria-hidden": true, className: `shrink-0 rounded-control border px-1.5 font-mono text-micro touch:hidden ${bar ? "max-sm:hidden" : ""} ${skin.keys}`, "data-ui": "search-entry.keys", children: keys.label }))] }));
|
|
34
34
|
}
|
|
@@ -4,4 +4,5 @@ export { Sidebar, type SidebarAction, type SidebarProps, } from "./Sidebar.js";
|
|
|
4
4
|
export { SearchEntry, type SearchEntryProps, } from "./SearchEntry.js";
|
|
5
5
|
export { type SidebarDrawer, SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
|
|
6
6
|
export { type AppEntry, SystrayButton, TopBar, type TopMenu, } from "./TopBar.js";
|
|
7
|
+
export { KioskFrame, type KioskFrameProps, } from "./KioskFrame.js";
|
|
7
8
|
export { Pane, Panes } from "./Panes.js";
|
|
@@ -11,4 +11,5 @@ export { SearchEntry, } from "./SearchEntry.js";
|
|
|
11
11
|
export { SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
|
|
12
12
|
export { SystrayButton, TopBar, } from "./TopBar.js";
|
|
13
13
|
/* A screen of N sets side by side — the reconciliation: each pane scrolls on its own. */
|
|
14
|
+
export { KioskFrame, } from "./KioskFrame.js";
|
|
14
15
|
export { Pane, Panes } from "./Panes.js";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useSyncExternalStore } from "react";
|
|
3
|
+
const tickers = new Map();
|
|
4
|
+
function tickerOf(every) {
|
|
5
|
+
let ticker = tickers.get(every);
|
|
6
|
+
if (ticker === undefined) {
|
|
7
|
+
ticker = { now: Date.now(), listeners: new Set() };
|
|
8
|
+
tickers.set(every, ticker);
|
|
9
|
+
}
|
|
10
|
+
return ticker;
|
|
11
|
+
}
|
|
12
|
+
function subscribe(every, listener) {
|
|
13
|
+
const ticker = tickerOf(every);
|
|
14
|
+
ticker.listeners.add(listener);
|
|
15
|
+
if (ticker.timer === undefined) {
|
|
16
|
+
/* «now» moves only on a tick: changing it while subscribing would change the snapshot
|
|
17
|
+
React just read, and it would render, resubscribe and change it again, forever. */
|
|
18
|
+
ticker.timer = setInterval(() => {
|
|
19
|
+
ticker.now = Date.now();
|
|
20
|
+
for (const one of ticker.listeners)
|
|
21
|
+
one();
|
|
22
|
+
}, every);
|
|
23
|
+
}
|
|
24
|
+
return () => {
|
|
25
|
+
ticker.listeners.delete(listener);
|
|
26
|
+
if (ticker.listeners.size === 0 && ticker.timer !== undefined) {
|
|
27
|
+
clearInterval(ticker.timer);
|
|
28
|
+
ticker.timer = undefined;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** The time now, in epoch milliseconds, refreshed every `every` ms (a second by default) — or
|
|
33
|
+
* `null` on the server and while hydrating. */
|
|
34
|
+
export function useNow(every = 1000) {
|
|
35
|
+
/* Stable per interval: a new `subscribe` on every render makes React unsubscribe and
|
|
36
|
+
subscribe again on each one. */
|
|
37
|
+
const listen = useCallback((listener) => subscribe(every, listener), [every]);
|
|
38
|
+
const read = useCallback(() => tickerOf(every).now, [every]);
|
|
39
|
+
return useSyncExternalStore(listen, read, serverNow);
|
|
40
|
+
}
|
|
41
|
+
const serverNow = () => null;
|
|
@@ -28,6 +28,7 @@ export const SPANISH_COPY = {
|
|
|
28
28
|
rows: "Filas",
|
|
29
29
|
table: "Tabla",
|
|
30
30
|
board: "Tablero",
|
|
31
|
+
tiles: "Mosaicos",
|
|
31
32
|
sheet: "Planilla",
|
|
32
33
|
report: "Reporte",
|
|
33
34
|
pivot: "Pivote",
|
|
@@ -566,6 +567,31 @@ export const SPANISH_COPY = {
|
|
|
566
567
|
addColumn: "Agregar etapa",
|
|
567
568
|
addColumnPlaceholder: "Nombre de la etapa… (Enter agrega)",
|
|
568
569
|
},
|
|
570
|
+
elapsed: {
|
|
571
|
+
label: "Esperando",
|
|
572
|
+
waiting: "Esperando hace {time}",
|
|
573
|
+
},
|
|
574
|
+
stepper: {
|
|
575
|
+
label: "Cantidad",
|
|
576
|
+
decrease: "Uno menos",
|
|
577
|
+
increase: "Uno más",
|
|
578
|
+
remove: "Quitar",
|
|
579
|
+
},
|
|
580
|
+
outcome: {
|
|
581
|
+
figure: "Número",
|
|
582
|
+
},
|
|
583
|
+
kiosk: {
|
|
584
|
+
reach: "Bajar la pantalla al alcance",
|
|
585
|
+
reachOff: "Volver a la altura completa",
|
|
586
|
+
start: "Tocá para empezar",
|
|
587
|
+
},
|
|
588
|
+
keypad: {
|
|
589
|
+
label: "Teclado numérico",
|
|
590
|
+
backspace: "Borrar el último dígito",
|
|
591
|
+
clear: "Borrar todo",
|
|
592
|
+
decimal: "Coma decimal",
|
|
593
|
+
sign: "Cambiar el signo",
|
|
594
|
+
},
|
|
569
595
|
timeline: {
|
|
570
596
|
prev: "Anterior",
|
|
571
597
|
next: "Siguiente",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIdle(seconds: number, onIdle: () => void, active?: boolean): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
/* ==================================================================== *
|
|
4
|
+
* IDLE — nobody has touched it for a while.
|
|
5
|
+
*
|
|
6
|
+
* Context: a kiosk is left half-way — two coffees in the order and the person gone — and the
|
|
7
|
+
* next one finds someone else's order. After `seconds` without a touch, a key or a scroll,
|
|
8
|
+
* `onIdle` runs once; the next touch starts the count again. Off while `active` is false (on
|
|
9
|
+
* the attract screen there is nothing to abandon).
|
|
10
|
+
* ==================================================================== */
|
|
11
|
+
const EVENTS = ["pointerdown", "keydown", "wheel", "touchstart"];
|
|
12
|
+
export function useIdle(seconds, onIdle, active = true) {
|
|
13
|
+
/* The latest callback, without restarting the count when the screen re-renders. */
|
|
14
|
+
const callback = useRef(onIdle);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
callback.current = onIdle;
|
|
17
|
+
});
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!active || seconds <= 0)
|
|
20
|
+
return;
|
|
21
|
+
let timer = setTimeout(() => callback.current(), seconds * 1000);
|
|
22
|
+
const restart = () => {
|
|
23
|
+
clearTimeout(timer);
|
|
24
|
+
timer = setTimeout(() => callback.current(), seconds * 1000);
|
|
25
|
+
};
|
|
26
|
+
for (const name of EVENTS)
|
|
27
|
+
window.addEventListener(name, restart, { passive: true });
|
|
28
|
+
return () => {
|
|
29
|
+
clearTimeout(timer);
|
|
30
|
+
for (const name of EVENTS)
|
|
31
|
+
window.removeEventListener(name, restart);
|
|
32
|
+
};
|
|
33
|
+
}, [seconds, active]);
|
|
34
|
+
}
|
|
@@ -2,6 +2,8 @@ export { type CopyCatalog, createCopy } from "./catalog.js";
|
|
|
2
2
|
export { UiCopyProvider, useUiCopy } from "./copy.js";
|
|
3
3
|
export { type CopyOverride, mergeCopyOver } from "./copyStore.js";
|
|
4
4
|
export { DensityProvider, useDensity } from "./density.js";
|
|
5
|
+
export { useNow } from "./clock.js";
|
|
6
|
+
export { useIdle } from "./idle.js";
|
|
5
7
|
export { byDensity, bySurface } from "./pickBy.js";
|
|
6
8
|
export { currentCopy, currentCopyLocale, ENGLISH_COPY, fillCopy, installCopy, mergeCopy, type UiCopy, type UiCopyOverride, } from "./uiCopy.js";
|
|
7
9
|
export { useViewStyle, type ViewStyle, ViewStyleProvider, } from "./viewStyle.js";
|
|
@@ -9,6 +11,7 @@ export { controlName } from "./controlName.js";
|
|
|
9
11
|
export { FieldBoundary, type FieldIds, type FormMode, FormModeProvider, type FormStyle, FormStyleProvider, useFieldIds, useFormMode, useFormStyle, } from "./form.js";
|
|
10
12
|
export { type KeyPress, type Keys, keysAria, keysLabel, matchesKeys, type ModShortcut, modShortcut, needsModifier, type ParsedKeys, parseKeys, } from "./keys.js";
|
|
11
13
|
export { type KeyboardPlatform, type Shortcut, useKeyboardPlatform, useKeysHint, useShortcuts, } from "./shortcut.js";
|
|
14
|
+
export { isPointer, type Pointer, POINTER_ATTRIBUTE, pointerAttributes, POINTERS, } from "./pointer.js";
|
|
12
15
|
export { SurfaceProvider, useSurface } from "./surface.js";
|
|
13
16
|
export { applyTheme, ThemeProvider, type ThemeProviderProps, useTheme, } from "./theme.js";
|
|
14
17
|
export { isTheme, type ResolvedTheme, resolveTheme, type Theme, THEME_ATTRIBUTE, THEMES, } from "./themeChoice.js";
|
|
@@ -7,6 +7,10 @@ export { createCopy } from "./catalog.js";
|
|
|
7
7
|
export { UiCopyProvider, useUiCopy } from "./copy.js";
|
|
8
8
|
export { mergeCopyOver } from "./copyStore.js";
|
|
9
9
|
export { DensityProvider, useDensity } from "./density.js";
|
|
10
|
+
/* NOW, live — one shared ticking clock per interval, `null` on the server. */
|
|
11
|
+
export { useNow } from "./clock.js";
|
|
12
|
+
/* IDLE — nobody touched it for a while: a kiosk forgets the abandoned order. */
|
|
13
|
+
export { useIdle } from "./idle.js";
|
|
10
14
|
export { byDensity, bySurface } from "./pickBy.js";
|
|
11
15
|
export { currentCopy, currentCopyLocale, ENGLISH_COPY, fillCopy, installCopy, mergeCopy, } from "./uiCopy.js";
|
|
12
16
|
/* How a whole application draws its views — `traditional` or `modern` (the direction): the
|
|
@@ -21,6 +25,9 @@ export { FieldBoundary, FormModeProvider, FormStyleProvider, useFieldIds, useFor
|
|
|
21
25
|
mounted wins. A combination is written once («Alt+D», «Mod+S») and read by `foundations/keys`. */
|
|
22
26
|
export { keysAria, keysLabel, matchesKeys, modShortcut, needsModifier, parseKeys, } from "./keys.js";
|
|
23
27
|
export { useKeyboardPlatform, useKeysHint, useShortcuts, } from "./shortcut.js";
|
|
28
|
+
/* THE POINTER — a finger or a mouse, when the application knows better than the device (a till
|
|
29
|
+
is a touch monitor with a mouse plugged in). `tokens.css` reads `data-pointer`. */
|
|
30
|
+
export { isPointer, POINTER_ATTRIBUTE, pointerAttributes, POINTERS, } from "./pointer.js";
|
|
24
31
|
/* THE THEME — light, dark or the operating system's. The palettes live in `tokens.css`; this
|
|
25
32
|
only writes `data-theme`. */
|
|
26
33
|
export { SurfaceProvider, useSurface } from "./surface.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE POINTER — what the person presses with, when the application knows better than the
|
|
3
|
+
* device.
|
|
4
|
+
*
|
|
5
|
+
* Context: the stylesheet sizes every control for a finger under `pointer: coarse`, and that
|
|
6
|
+
* is the browser's answer for the PRIMARY pointer. A till is a touch monitor with a mouse
|
|
7
|
+
* plugged in, a kiosk a touch screen the browser may report as a mouse: there the cashier gets
|
|
8
|
+
* 30 px targets. The application says it instead — `data-pointer` on `<html>` (or on a zone):
|
|
9
|
+
*
|
|
10
|
+
* touch sized for a finger, whatever the device reports
|
|
11
|
+
* fine sized for a mouse, even on a tablet (a back office driven with a trackpad)
|
|
12
|
+
* auto the device decides — the same as writing nothing
|
|
13
|
+
*
|
|
14
|
+
* Pure and without `"use client"`: a server layout writes `<html data-pointer>` itself, so the
|
|
15
|
+
* first paint already has the right sizes.
|
|
16
|
+
*/
|
|
17
|
+
export type Pointer = "auto" | "touch" | "fine";
|
|
18
|
+
export declare const POINTERS: readonly Pointer[];
|
|
19
|
+
/** The attribute the stylesheet reads. */
|
|
20
|
+
export declare const POINTER_ATTRIBUTE = "data-pointer";
|
|
21
|
+
/** True for one of the three values — what comes from a setting or a URL is a string. */
|
|
22
|
+
export declare function isPointer(value: unknown): value is Pointer;
|
|
23
|
+
/** The attributes to spread on an element (`<html {...pointerAttributes("touch")}>`): `auto`
|
|
24
|
+
* writes none, so the device decides. */
|
|
25
|
+
export declare function pointerAttributes(pointer: Pointer): Record<string, string>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE POINTER — what the person presses with, when the application knows better than the
|
|
3
|
+
* device.
|
|
4
|
+
*
|
|
5
|
+
* Context: the stylesheet sizes every control for a finger under `pointer: coarse`, and that
|
|
6
|
+
* is the browser's answer for the PRIMARY pointer. A till is a touch monitor with a mouse
|
|
7
|
+
* plugged in, a kiosk a touch screen the browser may report as a mouse: there the cashier gets
|
|
8
|
+
* 30 px targets. The application says it instead — `data-pointer` on `<html>` (or on a zone):
|
|
9
|
+
*
|
|
10
|
+
* touch sized for a finger, whatever the device reports
|
|
11
|
+
* fine sized for a mouse, even on a tablet (a back office driven with a trackpad)
|
|
12
|
+
* auto the device decides — the same as writing nothing
|
|
13
|
+
*
|
|
14
|
+
* Pure and without `"use client"`: a server layout writes `<html data-pointer>` itself, so the
|
|
15
|
+
* first paint already has the right sizes.
|
|
16
|
+
*/
|
|
17
|
+
export const POINTERS = ["auto", "touch", "fine"];
|
|
18
|
+
/** The attribute the stylesheet reads. */
|
|
19
|
+
export const POINTER_ATTRIBUTE = "data-pointer";
|
|
20
|
+
/** True for one of the three values — what comes from a setting or a URL is a string. */
|
|
21
|
+
export function isPointer(value) {
|
|
22
|
+
return value === "auto" || value === "touch" || value === "fine";
|
|
23
|
+
}
|
|
24
|
+
/** The attributes to spread on an element (`<html {...pointerAttributes("touch")}>`): `auto`
|
|
25
|
+
* writes none, so the device decides. */
|
|
26
|
+
export function pointerAttributes(pointer) {
|
|
27
|
+
return pointer === "auto" ? {} : { [POINTER_ATTRIBUTE]: pointer };
|
|
28
|
+
}
|
|
@@ -26,6 +26,7 @@ export type UiCopy = {
|
|
|
26
26
|
rows: string;
|
|
27
27
|
table: string;
|
|
28
28
|
board: string;
|
|
29
|
+
tiles: string;
|
|
29
30
|
/** The sheet: the raw data, with the file's columns. */
|
|
30
31
|
sheet: string;
|
|
31
32
|
/** The one that SUMS: a hierarchy that ends in totals. */
|
|
@@ -844,6 +845,43 @@ export type UiCopy = {
|
|
|
844
845
|
addColumn: string;
|
|
845
846
|
addColumnPlaceholder: string;
|
|
846
847
|
};
|
|
848
|
+
/** How long something has been waiting (`Elapsed`, a card's `elapsed`). */
|
|
849
|
+
elapsed: {
|
|
850
|
+
/** Read before the figure by a screen reader: «Esperando 4:05». */
|
|
851
|
+
label: string;
|
|
852
|
+
/** The figure's title. `{time}` is «4:05». */
|
|
853
|
+
waiting: string;
|
|
854
|
+
};
|
|
855
|
+
/** A quantity with «−» and «+» (`Stepper`). The unit goes after: «Sumar uno: Capuchino». */
|
|
856
|
+
stepper: {
|
|
857
|
+
label: string;
|
|
858
|
+
decrease: string;
|
|
859
|
+
increase: string;
|
|
860
|
+
/** «−» at the minimum, when it takes the line away. */
|
|
861
|
+
remove: string;
|
|
862
|
+
};
|
|
863
|
+
/** A finished operation, said big (`Outcome`). */
|
|
864
|
+
outcome: {
|
|
865
|
+
/** Read before the figure: «Tu número: 118». */
|
|
866
|
+
figure: string;
|
|
867
|
+
};
|
|
868
|
+
/** A self-service frame (`KioskFrame`). */
|
|
869
|
+
kiosk: {
|
|
870
|
+
/** The button that brings the content down to a seated person's reach. */
|
|
871
|
+
reach: string;
|
|
872
|
+
reachOff: string;
|
|
873
|
+
/** The attract screen's call, when the application gives none. */
|
|
874
|
+
start: string;
|
|
875
|
+
};
|
|
876
|
+
/** The on-screen number pad of a till or a kiosk (`Keypad`). */
|
|
877
|
+
keypad: {
|
|
878
|
+
/** The pad's name when nothing names it. */
|
|
879
|
+
label: string;
|
|
880
|
+
backspace: string;
|
|
881
|
+
clear: string;
|
|
882
|
+
decimal: string;
|
|
883
|
+
sign: string;
|
|
884
|
+
};
|
|
847
885
|
/** A timeline of records and its toolbar (`RecordTimeline`, `TimelineToolbar`). */
|
|
848
886
|
timeline: {
|
|
849
887
|
prev: string;
|
|
@@ -5,6 +5,7 @@ export const ENGLISH_COPY = {
|
|
|
5
5
|
rows: "Rows",
|
|
6
6
|
table: "Table",
|
|
7
7
|
board: "Board",
|
|
8
|
+
tiles: "Tiles",
|
|
8
9
|
sheet: "Sheet",
|
|
9
10
|
report: "Report",
|
|
10
11
|
pivot: "Pivot",
|
|
@@ -551,6 +552,31 @@ export const ENGLISH_COPY = {
|
|
|
551
552
|
addColumn: "Add a stage",
|
|
552
553
|
addColumnPlaceholder: "Stage name… (Enter adds)",
|
|
553
554
|
},
|
|
555
|
+
elapsed: {
|
|
556
|
+
label: "Waiting",
|
|
557
|
+
waiting: "Waiting for {time}",
|
|
558
|
+
},
|
|
559
|
+
stepper: {
|
|
560
|
+
label: "Quantity",
|
|
561
|
+
decrease: "One less",
|
|
562
|
+
increase: "One more",
|
|
563
|
+
remove: "Remove",
|
|
564
|
+
},
|
|
565
|
+
outcome: {
|
|
566
|
+
figure: "Number",
|
|
567
|
+
},
|
|
568
|
+
kiosk: {
|
|
569
|
+
reach: "Bring it down within reach",
|
|
570
|
+
reachOff: "Back to full height",
|
|
571
|
+
start: "Touch to start",
|
|
572
|
+
},
|
|
573
|
+
keypad: {
|
|
574
|
+
label: "Number pad",
|
|
575
|
+
backspace: "Delete the last digit",
|
|
576
|
+
clear: "Clear",
|
|
577
|
+
decimal: "Decimal point",
|
|
578
|
+
sign: "Change the sign",
|
|
579
|
+
},
|
|
554
580
|
timeline: {
|
|
555
581
|
prev: "Previous",
|
|
556
582
|
next: "Next",
|
|
@@ -14,5 +14,12 @@ export type RadioGroupProps = {
|
|
|
14
14
|
invalid?: boolean;
|
|
15
15
|
/** Forces the mode. By default it inherits the form's: in read mode it draws the label. */
|
|
16
16
|
mode?: FormMode;
|
|
17
|
+
/**
|
|
18
|
+
* `cards` draws each option as a box pressed whole, with its icon — the payment methods of
|
|
19
|
+
* a till, «Comer aquí / Para llevar» on a kiosk, the shipping of a shop: few options, chosen
|
|
20
|
+
* by a finger, where the dot of a list is too small a target. The grid fits as many as the
|
|
21
|
+
* width takes. It is still one radio group: arrows move, one is chosen.
|
|
22
|
+
*/
|
|
23
|
+
look?: "list" | "cards";
|
|
17
24
|
};
|
|
18
|
-
export declare function RadioGroup({ value, onChange, options, orientation, disabled, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, mode, }: RadioGroupProps): import("react").JSX.Element;
|
|
25
|
+
export declare function RadioGroup({ value, onChange, options, orientation, disabled, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, mode, look, }: RadioGroupProps): import("react").JSX.Element;
|
|
@@ -33,7 +33,7 @@ const mark = tv({
|
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
|
-
export function RadioGroup({ value, onChange, options, orientation = "vertical", disabled = false, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, mode, }) {
|
|
36
|
+
export function RadioGroup({ value, onChange, options, orientation = "vertical", disabled = false, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, mode, look = "list", }) {
|
|
37
37
|
const { id, labelledBy, describedBy, invalid } = useFieldIds({
|
|
38
38
|
id: ownId,
|
|
39
39
|
describedBy: ownDescribedBy,
|
|
@@ -41,6 +41,14 @@ export function RadioGroup({ value, onChange, options, orientation = "vertical",
|
|
|
41
41
|
});
|
|
42
42
|
if (useFormMode(mode) === "read")
|
|
43
43
|
return _jsx(ReadValue, { value: labelOf(options, value) });
|
|
44
|
+
if (look === "cards") {
|
|
45
|
+
return (_jsx(AriaRadioGroup, { id: id, "aria-labelledby": labelledBy, "aria-describedby": describedBy, value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, "data-ui": "radio-group", "data-look": "cards", className: "grid min-w-0 grid-cols-(--grid-tiles-sm) gap-2", children: options.map((o) => {
|
|
46
|
+
const Icon = o.icon;
|
|
47
|
+
return (_jsx(RadioField, { value: o.value, isDisabled: o.disabled, className: "flex min-w-0", children: _jsx(RadioButton, { "data-ui": "radio-group.card", className: ({ isSelected, isFocusVisible, isDisabled }) => `relative flex min-h-(--size-control-lg) w-full min-w-0 cursor-pointer flex-col items-start gap-1 rounded-ui-record-card border p-3 text-left transition-colors duration-(--duration-instant) ${isSelected
|
|
48
|
+
? "border-primary bg-primary/6 ring-1 ring-primary"
|
|
49
|
+
: "border-line-strong bg-surface hover:border-ink/40"} ${isFocusVisible ? "outline-2 outline-offset-2 outline-primary" : ""} ${isDisabled ? "cursor-not-allowed opacity-45" : ""}`, children: (state) => (_jsxs(_Fragment, { children: [_jsx("span", { className: `absolute top-3 right-3 ${mark(state)}`, children: _jsx("span", { className: `size-1.5 rounded-pill bg-surface transition-transform duration-(--duration-instant) ${state.isSelected ? "scale-100" : "scale-0"}` }) }), Icon === undefined ? null : (_jsx(Icon, { "aria-hidden": true, className: `size-(--size-icon-lg) ${state.isSelected ? "text-primary" : "text-muted"}`, strokeWidth: 1.75 })), _jsx("span", { className: "min-w-0 pr-6 text-body font-medium text-ink", children: o.label }), o.description === undefined ? null : (_jsx("span", { className: "min-w-0 text-micro text-muted", children: o.description }))] })) }) }, o.value));
|
|
50
|
+
}) }));
|
|
51
|
+
}
|
|
44
52
|
return (_jsx(AriaRadioGroup, { id: id, "aria-labelledby": labelledBy, "aria-describedby": describedBy, value: value, onChange: (next) => onChange?.(next), orientation: orientation, isInvalid: invalid, isDisabled: disabled,
|
|
45
53
|
/* `py-2` puts the first label on the same line a text input's would sit on, so the
|
|
46
54
|
field does not look shorter than its neighbours in the same row. */
|
|
@@ -12,6 +12,9 @@ export interface ChoiceOption {
|
|
|
12
12
|
/** A second, muted line: what the option IS (a tax id, a city), not a second name. */
|
|
13
13
|
description?: string;
|
|
14
14
|
disabled?: boolean;
|
|
15
|
+
/** Drawn on the option when the choice is shown as cards (`RadioGroup look="cards"`): the
|
|
16
|
+
* card of «Efectivo», «QR», «Tarjeta». Beside the label, never instead of it. */
|
|
17
|
+
icon?: LucideIcon;
|
|
15
18
|
}
|
|
16
19
|
/** One segment of a `SegmentedControl`. The icon goes before the label, never instead of it. */
|
|
17
20
|
export interface SegmentOption {
|