@sincpro/web-ui 2.4.0 → 2.6.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 +75 -8
- package/dist/components/activity/Activity.d.ts +28 -2
- package/dist/components/activity/Activity.js +53 -11
- package/dist/components/activity/Messages.d.ts +4 -0
- package/dist/components/activity/index.d.ts +1 -1
- package/dist/components/attachments/Attachments.d.ts +1 -28
- package/dist/components/attachments/Attachments.js +5 -24
- package/dist/components/attachments/FileList.d.ts +28 -0
- package/dist/components/attachments/FileList.js +91 -0
- package/dist/components/attachments/FileThumb.d.ts +13 -0
- package/dist/components/attachments/FileThumb.js +34 -0
- package/dist/components/attachments/download.d.ts +9 -0
- package/dist/components/attachments/download.js +36 -0
- package/dist/components/attachments/files.d.ts +28 -0
- package/dist/components/attachments/index.d.ts +4 -2
- package/dist/components/attachments/index.js +4 -1
- package/dist/components/board/Board.d.ts +74 -2
- package/dist/components/board/Board.js +65 -2
- package/dist/components/board/index.d.ts +1 -1
- package/dist/components/board/index.js +1 -1
- package/dist/components/calendar/RecordCalendar.d.ts +2 -1
- package/dist/components/calendar/RecordCalendar.js +4 -1
- package/dist/components/calendar/calendar.css +37 -0
- package/dist/components/canvas/canvas.css +6 -1
- package/dist/components/chat/ChatThread.d.ts +8 -1
- package/dist/components/chat/ChatThread.js +9 -4
- package/dist/components/chat/model.d.ts +4 -0
- package/dist/components/form/Form.js +11 -0
- package/dist/components/form/FormIndex.d.ts +11 -0
- package/dist/components/form/FormIndex.js +96 -0
- package/dist/components/form/Sheet.js +5 -0
- package/dist/components/gantt/RecordGantt.d.ts +9 -1
- package/dist/components/gantt/RecordGantt.js +16 -3
- package/dist/components/gantt/gantt.css +52 -0
- package/dist/components/listing/ChartExplorer.js +10 -5
- package/dist/components/record/DirtyActions.d.ts +10 -1
- package/dist/components/record/DirtyActions.js +77 -6
- package/dist/components/record/RecordHeader.js +17 -11
- package/dist/foundations/calendar.d.ts +12 -0
- package/dist/foundations/calendar.js +50 -0
- package/dist/foundations/chart.d.ts +10 -1
- package/dist/foundations/chart.js +17 -1
- package/dist/foundations/copy.d.ts +26 -0
- package/dist/foundations/copy.es.js +12 -0
- package/dist/foundations/copy.js +12 -0
- package/dist/foundations/form.d.ts +6 -0
- package/dist/foundations/form.js +7 -0
- package/dist/foundations/index.d.ts +2 -2
- package/dist/foundations/index.js +2 -2
- package/dist/foundations/pivot.d.ts +6 -0
- package/dist/foundations/pivot.js +1 -0
- package/dist/primitives/button/Button.d.ts +5 -1
- package/dist/primitives/button/Button.js +9 -2
- package/dist/primitives/chart/BarList.d.ts +30 -0
- package/dist/primitives/chart/BarList.js +27 -0
- package/dist/primitives/chart/Chart.d.ts +13 -0
- package/dist/primitives/chart/Chart.js +71 -19
- package/dist/primitives/chart/Sparkline.d.ts +30 -0
- package/dist/primitives/chart/Sparkline.js +53 -0
- package/dist/primitives/chart/index.d.ts +2 -0
- package/dist/primitives/chart/index.js +2 -0
- package/dist/primitives/field/Field.d.ts +6 -2
- package/dist/primitives/field/Field.js +35 -6
- package/dist/primitives/value/Markdown.d.ts +1 -0
- package/dist/primitives/value/Markdown.js +1 -0
- package/dist/primitives/value/Metric.d.ts +7 -0
- package/dist/primitives/value/Metric.js +5 -2
- package/dist/tokens.css +59 -87
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A SPARKLINE: the shape of the last periods, drawn under a figure — no axis, no grid, no
|
|
3
|
+
* tooltip. It answers «and lately?» beside a number that answers «how much now?».
|
|
4
|
+
*
|
|
5
|
+
* Context: a board's headline figure said one number and nothing about its direction; the
|
|
6
|
+
* only way to see the trend was a whole chart. A sparkline is the trend at the size of a
|
|
7
|
+
* word. It is not a small chart, and it does not try to be one: no scale (its height is the
|
|
8
|
+
* series' own range), so it is never read for a value — the figure beside it says the
|
|
9
|
+
* value. That is why it draws in the soft data hue and marks only the LAST point in the full
|
|
10
|
+
* one: the current period is the one the figure talks about.
|
|
11
|
+
*
|
|
12
|
+
* - A series flat at zero is drawn flat on the floor, not in the middle: nothing happened,
|
|
13
|
+
* and the baseline is where nothing is.
|
|
14
|
+
* - A hole is a hole — the line breaks — because there is no axis here to say why.
|
|
15
|
+
* - With nothing to draw (no values, all holes) it draws nothing, not an empty frame.
|
|
16
|
+
*
|
|
17
|
+
* Pure SVG and no Recharts: a board with eight of them should not load a chart engine for
|
|
18
|
+
* lines without axes. The SVG stretches to its box (`preserveAspectRatio="none"`) with a
|
|
19
|
+
* stroke that does not stretch (`non-scaling-stroke`); the end dot is an HTML mark laid over
|
|
20
|
+
* it, so it stays round at any width.
|
|
21
|
+
*/
|
|
22
|
+
export type SparklineProps = {
|
|
23
|
+
/** The values, oldest first. `null` is a period with nothing recorded. */
|
|
24
|
+
values: readonly (number | null)[];
|
|
25
|
+
/** What it shows, for a screen reader: «Mensajes recibidos, últimas 24 horas». */
|
|
26
|
+
label: string;
|
|
27
|
+
/** The wash under the line, for a quantity read as an amount (memory, stock). */
|
|
28
|
+
area?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare function Sparkline({ values, label, area }: SparklineProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
const WIDTH = 100;
|
|
3
|
+
const HEIGHT = 40;
|
|
4
|
+
/* Room for the stroke and the end dot at the top and the bottom. */
|
|
5
|
+
const PAD = 4;
|
|
6
|
+
export function Sparkline({ values, label, area = true }) {
|
|
7
|
+
const known = values.filter((value) => value !== null);
|
|
8
|
+
if (known.length === 0)
|
|
9
|
+
return null;
|
|
10
|
+
/* Its own range, not from zero: memory between 40 and 66 MB drawn from 0 is a flat block
|
|
11
|
+
with a ripple on top, and the turn is what a sparkline is for. */
|
|
12
|
+
const low = Math.min(...known);
|
|
13
|
+
const high = Math.max(...known);
|
|
14
|
+
const range = high - low;
|
|
15
|
+
const x = (at) => values.length === 1 ? WIDTH / 2 : (at / (values.length - 1)) * WIDTH;
|
|
16
|
+
/* Flat at zero sits on the floor; flat anywhere else, in the middle. */
|
|
17
|
+
const y = (value) => range === 0
|
|
18
|
+
? high === 0
|
|
19
|
+
? HEIGHT - PAD
|
|
20
|
+
: HEIGHT / 2
|
|
21
|
+
: PAD + (1 - (value - low) / range) * (HEIGHT - 2 * PAD);
|
|
22
|
+
/* The runs between holes, each its own stroke. */
|
|
23
|
+
const runs = [];
|
|
24
|
+
values.forEach((value, at) => {
|
|
25
|
+
if (value === null)
|
|
26
|
+
return;
|
|
27
|
+
const previous = values[at - 1];
|
|
28
|
+
if (at === 0 || previous === null || previous === undefined)
|
|
29
|
+
runs.push([]);
|
|
30
|
+
runs[runs.length - 1].push({ at, value });
|
|
31
|
+
});
|
|
32
|
+
const point = (one) => `${x(one.at).toFixed(2)},${y(one.value).toFixed(2)}`;
|
|
33
|
+
const line = (run) => `M${run.map(point).join(" L")}`;
|
|
34
|
+
const wash = (run) => {
|
|
35
|
+
const first = run[0];
|
|
36
|
+
const last = run[run.length - 1];
|
|
37
|
+
return `${line(run)} L${x(last.at).toFixed(2)},${HEIGHT} L${x(first.at).toFixed(2)},${HEIGHT} Z`;
|
|
38
|
+
};
|
|
39
|
+
let lastAt = values.length - 1;
|
|
40
|
+
while (values[lastAt] === null)
|
|
41
|
+
lastAt -= 1;
|
|
42
|
+
const end = { x: x(lastAt), y: y(values[lastAt]) };
|
|
43
|
+
return (_jsxs("div", { className: "relative h-(--size-sparkline) w-full min-w-0", children: [_jsxs("svg", { role: "img", "aria-label": label, viewBox: `0 0 ${String(WIDTH)} ${String(HEIGHT)}`, preserveAspectRatio: "none", className: "block size-full overflow-visible", children: [area
|
|
44
|
+
? runs
|
|
45
|
+
.filter((run) => run.length > 1)
|
|
46
|
+
.map((run) => (_jsx("path", { d: wash(run), fill: "var(--color-data-soft)", fillOpacity: 0.1 }, `wash-${String(run[0].at)}`)))
|
|
47
|
+
: null, runs
|
|
48
|
+
.filter((run) => run.length > 1)
|
|
49
|
+
.map((run) => (_jsx("path", { d: line(run), fill: "none", stroke: "var(--color-data-soft)", strokeWidth: 1.5, strokeLinejoin: "round", strokeLinecap: "round", vectorEffect: "non-scaling-stroke" }, `line-${String(run[0].at)}`)))] }), _jsx("span", { "aria-hidden": true, className: "absolute size-2 -translate-x-1/2 -translate-y-1/2 rounded-pill bg-data ring-2 ring-surface", style: {
|
|
50
|
+
left: `${String((end.x / WIDTH) * 100)}%`,
|
|
51
|
+
top: `${String((end.y / HEIGHT) * 100)}%`,
|
|
52
|
+
} })] }));
|
|
53
|
+
}
|
|
@@ -3,9 +3,10 @@ import { type FormMode } from "../../foundations/form.js";
|
|
|
3
3
|
import { type FieldNote } from "./note.js";
|
|
4
4
|
import { type Rounding } from "../value/rounding.js";
|
|
5
5
|
import { type ReactNode } from "react";
|
|
6
|
-
export declare function Field({ label, hint, error, required, children, htmlFor, layout, action, mode, note, changed, copy: copyAs, }: {
|
|
6
|
+
export declare function Field({ label, hint, error, required, children, htmlFor, layout, action, mode, note, changed, optional, copy: copyAs, }: {
|
|
7
7
|
label: string;
|
|
8
|
-
/** What is expected. A `?` on the label that opens it on press
|
|
8
|
+
/** What is expected. A `?` on the label that opens it on press — in the «settings» form
|
|
9
|
+
* style, written out under the label. */
|
|
9
10
|
hint?: string;
|
|
10
11
|
/** What has to be corrected. It goes BELOW, close to the cursor, and it says
|
|
11
12
|
* what to put. */
|
|
@@ -37,6 +38,9 @@ export declare function Field({ label, hint, error, required, children, htmlFor,
|
|
|
37
38
|
* «2 cambios sin guardar» is about — in a form of twenty, the reason to look before
|
|
38
39
|
* saving — and it is read as part of the field's description. */
|
|
39
40
|
changed?: boolean;
|
|
41
|
+
/** It may stay empty: «(opcional)» beside the label — drawn only in the «settings» form
|
|
42
|
+
* style, where every row says what it asks. Ignored with `required`. */
|
|
43
|
+
optional?: boolean;
|
|
40
44
|
/** The copy button by the label (see `clipboard.tsx`): on by default, copying what the
|
|
41
45
|
* control shows. A string copies that instead; `false` removes the button from this
|
|
42
46
|
* field. */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as _jsxs,
|
|
2
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { AriaLocale } from "../../foundations/aria.js";
|
|
4
4
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
5
5
|
import { byDensity, useDensity } from "../../foundations/density.js";
|
|
6
6
|
import { FieldIdsContext, useFieldIds, } from "../../foundations/form.js";
|
|
7
|
-
import { controlName, FormModeProvider, useFormMode, } from "../../foundations/form.js";
|
|
7
|
+
import { controlName, FormModeProvider, useFormMode, useFormStyle, } from "../../foundations/form.js";
|
|
8
8
|
import { focusRing, tv } from "../../foundations/variants.js";
|
|
9
9
|
import { FieldGroup, listOptionStyles } from "./aria.js";
|
|
10
10
|
import { FieldCopy, useFieldCopy } from "./clipboard.js";
|
|
@@ -41,10 +41,25 @@ import { Button as AriaButton, Input, ListBox, ListBoxItem, NumberField as AriaN
|
|
|
41
41
|
* Help is a `?` next to the name, opened with a press. A paragraph above the
|
|
42
42
|
* control ate a line on every field. The error still goes below, close to
|
|
43
43
|
* the cursor, and it says what to put.
|
|
44
|
+
*
|
|
45
|
+
* ── In the «settings» style a field is a ROW that explains itself ───
|
|
46
|
+
*
|
|
47
|
+
* `FormStyleProvider value="settings"` (an application's choice, see `foundations/form`):
|
|
48
|
+
* the label and its help — written out, muted, under it — on the left, the control on the
|
|
49
|
+
* right, «(opcional)» beside a label that may stay empty. A form filled once in a while is
|
|
50
|
+
* read before it is typed into, and there the paragraph is the point, not a lost line.
|
|
51
|
+
* The ids do not change: the written help is still what describes the control.
|
|
44
52
|
* ==================================================================== */
|
|
45
|
-
|
|
53
|
+
/** The label of a field in the «settings» style: the name, `*` or «(opcional)», the
|
|
54
|
+
* field's marks, and the help written out under it — it describes the control (`hintId`). */
|
|
55
|
+
function SettingsLabel({ name, hint, hintId, optional, marks, inline, }) {
|
|
56
|
+
const copy = useUiCopy();
|
|
57
|
+
return (_jsxs("div", { "data-ui": "field.label", className: `flex min-w-0 flex-col gap-0.5 ${inline ? "pt-1.5" : ""}`, children: [_jsxs("span", { className: "flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5 text-meta font-medium text-ink transition-colors duration-(--duration-quick) group-focus-within/field:text-primary", children: [name, optional ? (_jsxs("span", { className: "text-micro font-normal text-muted", children: ["(", copy.field.optional, ")"] })) : null, marks] }), hint === undefined ? null : (_jsx("p", { id: hintId, className: "max-w-prose text-micro text-muted", children: hint }))] }));
|
|
58
|
+
}
|
|
59
|
+
export function Field({ label, hint, error, required = false, children, htmlFor, layout, action, mode, note, changed = false, optional = false, copy: copyAs, }) {
|
|
46
60
|
const d = useDensity();
|
|
47
61
|
const copy = useUiCopy();
|
|
62
|
+
const settings = useFormStyle() === "settings";
|
|
48
63
|
const copies = useFieldCopy() && copyAs !== false;
|
|
49
64
|
const shown = useRef(null);
|
|
50
65
|
const auto = useId();
|
|
@@ -57,10 +72,12 @@ export function Field({ label, hint, error, required = false, children, htmlFor,
|
|
|
57
72
|
const changedId = `${id}-changed`;
|
|
58
73
|
/* The error first: what has to be corrected is heard before what is worth knowing. */
|
|
59
74
|
const describedBy = describedByOf(hint === undefined ? null : hintId, error === undefined ? null : errorId, note === undefined ? null : noteId, changed ? changedId : null);
|
|
60
|
-
const
|
|
75
|
+
const name = (_jsxs("label", { id: `${id}-label`, htmlFor: id, className: inline && !settings ? "min-w-0 truncate" : "", children: [label, required ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "text-ink", "aria-hidden": true, children: [" ", "*"] }), _jsxs("span", { className: "sr-only", children: [", ", copy.field.required] })] })) : null] }));
|
|
76
|
+
const marks = (_jsxs(_Fragment, { children: [note === undefined ? null : _jsx(NoteFlag, { note: note }), changed ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, title: copy.field.changed, className: "size-1.5 shrink-0 rounded-pill bg-accent transition-transform duration-(--duration-quick) ease-(--ease-out) starting:scale-0" }), _jsx("span", { id: changedId, className: "sr-only", children: copy.field.changed })] })) : null, copies ? (_jsx(FieldCopy, { label: label, scope: shown, ...(typeof copyAs === "string" ? { value: copyAs } : {}) })) : null] }));
|
|
77
|
+
const labelNode = settings ? (_jsx(SettingsLabel, { name: name, hint: hint, hintId: hintId, optional: optional && !required, marks: marks, inline: inline })) : (
|
|
61
78
|
/* The label follows its control's focus: in a form of twenty fields, the eye finds the
|
|
62
79
|
row being written by its name as much as by the ring. */
|
|
63
|
-
_jsxs("span", { className: `flex min-w-0 items-center gap-1 text-micro font-medium text-muted transition-colors duration-(--duration-quick) group-focus-within/field:text-primary ${inline ? "pt-2" : ""}`, children: [
|
|
80
|
+
_jsxs("span", { className: `flex min-w-0 items-center gap-1 text-micro font-medium text-muted transition-colors duration-(--duration-quick) group-focus-within/field:text-primary ${inline ? "pt-2" : ""}`, children: [name, hint === undefined ? null : _jsx(Hint, { id: hintId, children: hint }), marks] }));
|
|
64
81
|
/* Last in the field so it is read last; absolutely placed, it still sits at the field's
|
|
65
82
|
top — the static position of an absolute child of a flex or grid box is its start. */
|
|
66
83
|
const noteCard = note === undefined ? null : _jsx(NoteCard, { note: note, id: noteId, owner: label });
|
|
@@ -78,6 +95,13 @@ export function Field({ label, hint, error, required = false, children, htmlFor,
|
|
|
78
95
|
inside it then also finds the label that names it, not only the id it is handed. */
|
|
79
96
|
const content = (_jsx(FieldIdsContext.Provider, { value: ids, children: _jsx("div", { ref: shown, className: "contents", children: typeof children === "function" ? children(ids) : children }) }));
|
|
80
97
|
const body = (_jsxs(_Fragment, { children: [mode === undefined ? (content) : (_jsx(FormModeProvider, { value: mode, children: content })), error === undefined ? null : (_jsxs("p", { id: errorId, role: "alert", className: "flex items-start gap-1.5 text-micro text-danger", children: [_jsx(AlertCircle, { className: "mt-px size-(--size-icon-sm) shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "max-w-prose", children: error }), _jsx(CopyButton, { label: copy.copyable.report, value: () => `${label}: ${error}` })] }))] }));
|
|
98
|
+
if (inline && settings) {
|
|
99
|
+
/* The row: what it asks on the left, the answer on the right (`grid-setting`). */
|
|
100
|
+
return (_jsxs("div", { "data-ui": "field", "data-style": "settings", className: "grid-setting grid min-w-0 items-start gap-x-8 gap-y-2 group/field", children: [labelNode, _jsx("div", { className: "flex min-w-0 flex-col gap-1", children: body }), action === undefined ? null : (_jsx("div", { "data-under-control": true, className: "flex items-center gap-2", children: action })), noteCard] }));
|
|
101
|
+
}
|
|
102
|
+
if (settings) {
|
|
103
|
+
return (_jsxs("div", { "data-ui": "field", "data-style": "settings", className: "group/field flex min-w-0 flex-col gap-2", children: [_jsxs("div", { className: "flex min-w-0 items-start gap-2", children: [labelNode, action === undefined ? null : _jsx("span", { className: "ml-auto shrink-0", children: action })] }), body, noteCard] }));
|
|
104
|
+
}
|
|
81
105
|
if (inline) {
|
|
82
106
|
return (_jsxs("div", { className: "grid-label grid min-w-0 items-start gap-x-4 gap-y-1 group/field", children: [labelNode, _jsx("div", { className: "flex min-w-0 flex-col gap-1", children: body }), action === undefined ? null : (_jsx("div", { "data-under-control": true, className: "flex items-center gap-2", children: action })), noteCard] }));
|
|
83
107
|
}
|
|
@@ -97,6 +121,7 @@ export function Field({ label, hint, error, required = false, children, htmlFor,
|
|
|
97
121
|
*/
|
|
98
122
|
export function DataField({ label, value, hint, layout, mono = false, action, note, copy: copyAs, }) {
|
|
99
123
|
const d = useDensity();
|
|
124
|
+
const settings = useFormStyle() === "settings";
|
|
100
125
|
const shown = useRef(null);
|
|
101
126
|
const allowed = useFieldCopy() && copyAs !== false;
|
|
102
127
|
const noteId = `${useId()}-note`;
|
|
@@ -104,9 +129,13 @@ export function DataField({ label, value, hint, layout, mono = false, action, no
|
|
|
104
129
|
const inline = layout === "inline" || (layout === undefined && sheetLayout === "horizontal");
|
|
105
130
|
const empty = value === undefined || value === null || value === "";
|
|
106
131
|
const unset = useUiCopy().field.unset;
|
|
107
|
-
const
|
|
132
|
+
const marks = (_jsxs(_Fragment, { children: [note === undefined ? null : _jsx(NoteFlag, { note: note }), allowed && !empty ? (_jsx(FieldCopy, { label: label, scope: shown, ...(typeof copyAs === "string" ? { value: copyAs } : {}) })) : null] }));
|
|
133
|
+
const labelNode = settings ? (_jsx(SettingsLabel, { name: _jsx("span", { children: label }), hint: hint, hintId: undefined, optional: false, marks: marks, inline: false })) : (_jsxs("span", { className: `flex min-w-0 items-center gap-1 text-micro font-medium text-muted ${inline ? "pt-0.5" : ""}`, children: [_jsx("span", { className: inline ? "min-w-0 truncate" : "", children: label }), hint === undefined ? null : _jsx(Hint, { children: hint }), marks] }));
|
|
108
134
|
const noteCard = note === undefined ? null : _jsx(NoteCard, { note: note, id: noteId, owner: label });
|
|
109
135
|
const valueNode = (_jsx("span", { ref: shown, ...(note === undefined ? {} : { "aria-describedby": noteId }), className: `min-w-0 text-meta ${empty ? "text-muted italic" : "text-ink"} ${mono ? "font-mono tabular-nums" : ""}`, children: empty ? unset : value }));
|
|
136
|
+
if (inline && settings) {
|
|
137
|
+
return (_jsxs("div", { "data-ui": "field", "data-style": "settings", className: "grid-setting grid min-w-0 items-start gap-x-8 gap-y-1 group/field", children: [labelNode, _jsxs("span", { className: "flex min-w-0 items-baseline gap-2", children: [valueNode, action] }), noteCard] }));
|
|
138
|
+
}
|
|
110
139
|
if (inline) {
|
|
111
140
|
return (_jsxs("div", { className: "grid-label grid min-w-0 items-baseline gap-x-4 gap-y-0.5 group/field", children: [labelNode, _jsxs("span", { className: "flex min-w-0 items-baseline gap-2", children: [valueNode, action] }), noteCard] }));
|
|
112
141
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import "streamdown/styles.css";
|
|
3
4
|
import { Streamdown } from "streamdown";
|
|
4
5
|
/* The document's own rhythm, in tokens. The arbitrary variants only select the
|
|
5
6
|
descendants; every value is a token. A heading is the same size as the rest
|
|
@@ -55,6 +55,13 @@ export type MetricProps = {
|
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
export declare function Metric({ value, label, detail, tone, icon: Icon, onClick, active, change, loading, }: MetricProps): import("react").JSX.Element;
|
|
58
|
+
/** How a figure moved against a named period: «↗ +18 % vs 2025». The arrow carries the
|
|
59
|
+
* direction and the words the period, so the colour is never the only channel. A board's
|
|
60
|
+
* stat tile says it the same way. */
|
|
61
|
+
export declare function MetricChange({ change, format, }: {
|
|
62
|
+
change: NonNullable<MetricProps["change"]>;
|
|
63
|
+
format: (value: number) => string;
|
|
64
|
+
}): import("react").JSX.Element;
|
|
58
65
|
/** The row of metrics. It wraps if they don't fit; it doesn't scroll: a hidden
|
|
59
66
|
* metric is a filter nobody finds. */
|
|
60
67
|
export declare function Metrics({ children }: {
|
|
@@ -40,7 +40,7 @@ export function Metric({ value, label, detail, tone = "neutral", icon: Icon, onC
|
|
|
40
40
|
const content = (_jsxs(_Fragment, { children: [_jsxs("span", { className: `flex items-center gap-1.5 text-title font-semibold tabular-nums ${t.text}`, children: [Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-md)", strokeWidth: 2, "aria-hidden": true })), loading ? (
|
|
41
41
|
/* A bar one line of the figure tall (`h-lh`), so the box is the size it will
|
|
42
42
|
be. It appears late, like every skeleton: a fast read never shows it. */
|
|
43
|
-
_jsx("span", { "aria-hidden": true, className: `inline-block h-lh w-16 animate-reveal-late rounded-control ${bySurface(sup, "bg-ink/8", "bg-chrome-ink/12")}` })) : (figure)] }), _jsx("span", { className: `text-micro ${bySurface(sup, "text-muted", "text-chrome-muted")}`, children: label }), detail === undefined || loading ? null : (_jsx("span", { "data-ui": "metric.detail", className: `text-micro tabular-nums ${bySurface(sup, "text-muted", "text-chrome-muted")}`, children: detail })), change === undefined || loading ? null : (_jsx(
|
|
43
|
+
_jsx("span", { "aria-hidden": true, className: `inline-block h-lh w-16 animate-reveal-late rounded-control ${bySurface(sup, "bg-ink/8", "bg-chrome-ink/12")}` })) : (figure)] }), _jsx("span", { className: `text-micro ${bySurface(sup, "text-muted", "text-chrome-muted")}`, children: label }), detail === undefined || loading ? null : (_jsx("span", { "data-ui": "metric.detail", className: `text-micro tabular-nums ${bySurface(sup, "text-muted", "text-chrome-muted")}`, children: detail })), change === undefined || loading ? null : (_jsx(MetricChange, { change: change, format: percent.format }))] }));
|
|
44
44
|
if (onClick === undefined) {
|
|
45
45
|
return (_jsx("div", { "data-ui": "metric", className: box, "aria-label": loading
|
|
46
46
|
? `${label}: ${copy.failed.loading}`
|
|
@@ -48,7 +48,10 @@ export function Metric({ value, label, detail, tone = "neutral", icon: Icon, onC
|
|
|
48
48
|
}
|
|
49
49
|
return (_jsxs("button", { type: "button", onClick: onClick, "aria-pressed": active, ...(loading ? { "aria-busy": true } : {}), "data-ui": "metric", className: box, children: [content, loading ? _jsx("span", { className: "sr-only", children: copy.failed.loading }) : null] }));
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
/** How a figure moved against a named period: «↗ +18 % vs 2025». The arrow carries the
|
|
52
|
+
* direction and the words the period, so the colour is never the only channel. A board's
|
|
53
|
+
* stat tile says it the same way. */
|
|
54
|
+
export function MetricChange({ change, format, }) {
|
|
52
55
|
const copy = useUiCopy();
|
|
53
56
|
const sup = useSurface();
|
|
54
57
|
const up = change.by > 0;
|
package/dist/tokens.css
CHANGED
|
@@ -11,15 +11,12 @@
|
|
|
11
11
|
@import "@fontsource/ibm-plex-mono/latin-ext-400.css";
|
|
12
12
|
@import "@fontsource/ibm-plex-mono/latin-500.css";
|
|
13
13
|
@import "@fontsource/ibm-plex-mono/latin-ext-500.css";
|
|
14
|
-
/*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/* The record Gantt (`RecordGantt`, SVAR): its styles, Willow theme included. Its variables
|
|
21
|
-
are pointed at web-ui's tokens below. */
|
|
22
|
-
@import "@svar-ui/react-gantt/all.css";
|
|
14
|
+
/* Only what every screen uses is imported here. A library's own stylesheet — the Gantt's
|
|
15
|
+
* (SVAR, ~160 KB), the calendar's (FullCalendar), markdown's (streamdown), React Flow's — is
|
|
16
|
+
* imported by the component that draws it, together with the mapping of its variables to
|
|
17
|
+
* these tokens (`gantt.css`, `calendar.css`, `canvas.css`), so it travels in that component's
|
|
18
|
+
* chunk: an application that never opens a Gantt never downloads its CSS.
|
|
19
|
+
* `tests/bundle.test.ts` keeps it that way. */
|
|
23
20
|
|
|
24
21
|
@import "tailwindcss";
|
|
25
22
|
|
|
@@ -342,6 +339,20 @@
|
|
|
342
339
|
--text-display: 1.75rem;
|
|
343
340
|
--text-display--line-height: 1.2;
|
|
344
341
|
|
|
342
|
+
/* Two steps for FIGURES, not for text. A number a board leads with is read before anything
|
|
343
|
+
else on the page, and at 19 px (`title`) it read as one more label — the board's headline
|
|
344
|
+
figures sat in chips the size of a tag. They are not titles either: a title is read, a
|
|
345
|
+
figure is compared, so they get their own steps, set tighter (a figure at display size
|
|
346
|
+
with text tracking looks loose: its digits drift apart).
|
|
347
|
+
figure — the value of a board's stat tile
|
|
348
|
+
hero — the ONE figure a board leads with (≥ 48 px), at most one per view */
|
|
349
|
+
--text-figure: 1.875rem;
|
|
350
|
+
--text-figure--line-height: 1.1;
|
|
351
|
+
--text-figure--letter-spacing: -0.02em;
|
|
352
|
+
--text-hero: 3rem;
|
|
353
|
+
--text-hero--line-height: 1;
|
|
354
|
+
--text-hero--letter-spacing: -0.03em;
|
|
355
|
+
|
|
345
356
|
/* ---------------------------------------------------------------- *
|
|
346
357
|
* THE RADIUS SCALE — «it is very square», and that was true.
|
|
347
358
|
*
|
|
@@ -533,6 +544,10 @@
|
|
|
533
544
|
to «Referencia del cli…», and a truncated label is a question. */
|
|
534
545
|
--container-label: 10rem;
|
|
535
546
|
|
|
547
|
+
/* The index of a «settings» form's sections (`FormIndex`), at the sheet's left: wide enough
|
|
548
|
+
for «Contacto y guía pública», narrow enough that the cards keep the page. */
|
|
549
|
+
--container-form-index: 12rem;
|
|
550
|
+
|
|
536
551
|
/* The tag column of a list row. It is what the column ASKS FOR, and it
|
|
537
552
|
belongs to the system: with a width of its own every tag starts where its
|
|
538
553
|
own ends and twelve rows give twelve indents. Asking for the same 8 rem,
|
|
@@ -596,6 +611,11 @@
|
|
|
596
611
|
its figure and label, so the tiles below do not move down when the numbers arrive. */
|
|
597
612
|
--size-metric: 3.75rem;
|
|
598
613
|
|
|
614
|
+
/* A stat tile's sparkline: the shape of the last periods under the figure, not a chart —
|
|
615
|
+
no axis, no grid. Tall enough to see a turn, short enough that the figure stays the
|
|
616
|
+
subject. */
|
|
617
|
+
--size-sparkline: 2.5rem;
|
|
618
|
+
|
|
599
619
|
/* The width of the peek drawer. It is a system decision and not a component
|
|
600
620
|
one: 30rem is what fits of a record without leaving the list behind it
|
|
601
621
|
—which has to stay clickable— reduced to a useless strip. */
|
|
@@ -783,11 +803,18 @@
|
|
|
783
803
|
--radius-ui-dialog: var(--ui-dialog-radius, var(--radius-panel));
|
|
784
804
|
--color-ui-dialog: var(--ui-dialog-bg, var(--color-surface));
|
|
785
805
|
|
|
786
|
-
/* A box of content: a block, a card of a list, a
|
|
806
|
+
/* A box of content: a block, a card of a list, a metric. */
|
|
787
807
|
--radius-ui-card: var(--ui-card-radius, var(--radius-box));
|
|
788
808
|
--color-ui-card: var(--ui-card-bg, var(--color-surface));
|
|
789
809
|
--color-ui-card-border: var(--ui-card-border, var(--color-line));
|
|
790
810
|
|
|
811
|
+
/* A board's tile and stat tile: a PANEL of a page, not a box inside one — the panel's
|
|
812
|
+
radius, like a window. Its colours fall back to the card's, so an application that
|
|
813
|
+
re-skinned its cards re-skins its boards too, and can still tell them apart. */
|
|
814
|
+
--radius-ui-tile: var(--ui-tile-radius, var(--radius-panel));
|
|
815
|
+
--color-ui-tile: var(--ui-tile-bg, var(--ui-card-bg, var(--color-surface)));
|
|
816
|
+
--color-ui-tile-border: var(--ui-tile-border, var(--ui-card-border, var(--color-line)));
|
|
817
|
+
|
|
791
818
|
/* A capsule: a tag, a chip of the search bar. */
|
|
792
819
|
--radius-ui-tag: var(--ui-tag-radius, var(--radius-pill));
|
|
793
820
|
|
|
@@ -1137,7 +1164,9 @@
|
|
|
1137
1164
|
--sc-accent: var(--color-primary);
|
|
1138
1165
|
--sc-danger: var(--color-danger);
|
|
1139
1166
|
--sc-on-danger: var(--color-surface);
|
|
1140
|
-
|
|
1167
|
+
/* `--color-scrim` is opaque — a veil is a share of it. Unmixed, ⌘K's palette (`.sc-scrim`)
|
|
1168
|
+
opened over a solid page (#43); both veils dim the page the way `Dialog` does. */
|
|
1169
|
+
--sc-scrim: color-mix(in srgb, var(--color-scrim) 40%, transparent);
|
|
1141
1170
|
--sc-modal-scrim: color-mix(in srgb, var(--color-scrim) 40%, transparent);
|
|
1142
1171
|
--sc-shadow: var(--shadow-window);
|
|
1143
1172
|
--sc-radius: var(--radius-panel);
|
|
@@ -1147,82 +1176,6 @@
|
|
|
1147
1176
|
--sc-icon: var(--size-icon-md);
|
|
1148
1177
|
}
|
|
1149
1178
|
|
|
1150
|
-
/* ====================================================================
|
|
1151
|
-
* THE RECORD CALENDAR (FullCalendar v7, `forma` theme) in these tokens.
|
|
1152
|
-
*
|
|
1153
|
-
* Context: the theme reads a palette of `--fc-forma-*` variables. Pointed at web-ui's tokens it
|
|
1154
|
-
* takes the theme — light, dark, a brand — with no dark block of its own: the tokens already
|
|
1155
|
-
* flip. Aliases, so no contrast of their own to measure; the translucent washes are mixed from
|
|
1156
|
-
* the ink so they read on either theme.
|
|
1157
|
-
* ==================================================================== */
|
|
1158
|
-
:root {
|
|
1159
|
-
--fc-forma-primary: var(--color-primary);
|
|
1160
|
-
--fc-forma-primary-over: var(--color-primary-hover);
|
|
1161
|
-
--fc-forma-primary-down: var(--color-primary-hover);
|
|
1162
|
-
--fc-forma-primary-foreground: var(--color-surface);
|
|
1163
|
-
--fc-forma-event: var(--color-primary);
|
|
1164
|
-
--fc-forma-event-contrast: var(--color-surface);
|
|
1165
|
-
--fc-forma-background-event: var(--color-primary);
|
|
1166
|
-
--fc-forma-highlight: color-mix(in srgb, var(--color-primary) 18%, transparent);
|
|
1167
|
-
--fc-forma-background: var(--color-surface);
|
|
1168
|
-
--fc-forma-faint: color-mix(in srgb, var(--color-ink) 3%, transparent);
|
|
1169
|
-
--fc-forma-muted: color-mix(in srgb, var(--color-ink) 7%, transparent);
|
|
1170
|
-
--fc-forma-strong: color-mix(in srgb, var(--color-ink) 12%, transparent);
|
|
1171
|
-
--fc-forma-stronger: color-mix(in srgb, var(--color-ink) 16%, transparent);
|
|
1172
|
-
--fc-forma-strongest: color-mix(in srgb, var(--color-ink) 20%, transparent);
|
|
1173
|
-
--fc-forma-foreground: var(--color-ink);
|
|
1174
|
-
--fc-forma-faint-foreground: var(--color-muted);
|
|
1175
|
-
--fc-forma-muted-foreground: var(--color-muted);
|
|
1176
|
-
--fc-forma-border: var(--color-line);
|
|
1177
|
-
--fc-forma-muted-border: var(--color-line);
|
|
1178
|
-
--fc-forma-strong-border: var(--color-line-strong);
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
/* ====================================================================
|
|
1182
|
-
* THE RECORD GANTT (SVAR, Willow theme) in these tokens.
|
|
1183
|
-
*
|
|
1184
|
-
* Context: Willow declares its `--wx-*` on `.wx-willow-theme`; redeclared on the same class
|
|
1185
|
-
* here, later, they win. Bars are the navy of the system, a summary the ink, a milestone the
|
|
1186
|
-
* info tone; the type is the system's. Aliases: they flip with the theme.
|
|
1187
|
-
* ==================================================================== */
|
|
1188
|
-
.wx-willow-theme {
|
|
1189
|
-
--wx-color-primary: var(--color-primary);
|
|
1190
|
-
--wx-color-primary-selected: color-mix(in srgb, var(--color-primary) 14%, transparent);
|
|
1191
|
-
--wx-color-primary-font: var(--color-surface);
|
|
1192
|
-
--wx-color-secondary-hover: color-mix(in srgb, var(--color-primary) 10%, transparent);
|
|
1193
|
-
--wx-color-success: var(--color-good);
|
|
1194
|
-
--wx-color-warning: var(--color-warn);
|
|
1195
|
-
--wx-color-info: var(--color-info);
|
|
1196
|
-
--wx-color-danger: var(--color-danger);
|
|
1197
|
-
--wx-color-font: var(--color-ink);
|
|
1198
|
-
--wx-color-font-alt: var(--color-muted);
|
|
1199
|
-
--wx-background: var(--color-surface);
|
|
1200
|
-
--wx-background-alt: var(--color-ground);
|
|
1201
|
-
--wx-background-hover: color-mix(in srgb, var(--color-ink) 5%, transparent);
|
|
1202
|
-
--wx-font-family: inherit;
|
|
1203
|
-
--wx-font-size: var(--text-meta);
|
|
1204
|
-
--wx-font-size-sm: var(--text-micro);
|
|
1205
|
-
--wx-icon-color: var(--color-muted);
|
|
1206
|
-
--wx-border-color: var(--color-line);
|
|
1207
|
-
--wx-border-radius: var(--radius-control);
|
|
1208
|
-
--wx-radius-major: var(--radius-box);
|
|
1209
|
-
--wx-gantt-border-color: var(--color-line);
|
|
1210
|
-
--wx-gantt-task-color: var(--color-primary);
|
|
1211
|
-
--wx-gantt-task-fill-color: var(--color-primary-hover);
|
|
1212
|
-
--wx-gantt-task-border-color: var(--color-primary-hover);
|
|
1213
|
-
--wx-gantt-task-font-color: var(--color-surface);
|
|
1214
|
-
--wx-gantt-summary-color: var(--color-line-strong);
|
|
1215
|
-
--wx-gantt-summary-fill-color: color-mix(in srgb, var(--color-ink) 45%, transparent);
|
|
1216
|
-
--wx-gantt-summary-border-color: var(--color-line-strong);
|
|
1217
|
-
--wx-gantt-summary-font-color: var(--color-ink);
|
|
1218
|
-
--wx-gantt-milestone-color: var(--color-info);
|
|
1219
|
-
--wx-gantt-select-color: color-mix(in srgb, var(--color-primary) 10%, transparent);
|
|
1220
|
-
--wx-gantt-link-color: var(--color-muted);
|
|
1221
|
-
--wx-gantt-link-color-hovered: var(--color-ink);
|
|
1222
|
-
--wx-gantt-holiday-background: var(--color-ground);
|
|
1223
|
-
--wx-gantt-holiday-color: var(--color-muted);
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
1179
|
@layer base {
|
|
1227
1180
|
/* No forced height anywhere: the document is exactly as tall as its content.
|
|
1228
1181
|
* The color still has to reach the bottom of the viewport on a short page —
|
|
@@ -1538,6 +1491,25 @@
|
|
|
1538
1491
|
}
|
|
1539
1492
|
}
|
|
1540
1493
|
|
|
1494
|
+
/* A field of the «settings» form style (`FormStyleProvider`): what it asks — the label and its
|
|
1495
|
+
help written out — on the left, two parts in five; the control on the right, three. The
|
|
1496
|
+
label column grows with the row because it holds a sentence, not one word. Below
|
|
1497
|
+
`--container-handheld` of the section it sits in, the row is one column: the help over a
|
|
1498
|
+
control squeezed beside it was two half-read things. */
|
|
1499
|
+
@utility grid-setting {
|
|
1500
|
+
grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
|
|
1501
|
+
& > [data-under-control] {
|
|
1502
|
+
grid-column-start: 2;
|
|
1503
|
+
}
|
|
1504
|
+
/* 40rem IS `--container-handheld`: a container query cannot read a custom property. */
|
|
1505
|
+
@container (width < 40rem) {
|
|
1506
|
+
grid-template-columns: minmax(0, 1fr);
|
|
1507
|
+
& > [data-under-control] {
|
|
1508
|
+
grid-column-start: auto;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1541
1513
|
/* ==================================================================== *
|
|
1542
1514
|
* TOUCH — the same controls, sized for a finger.
|
|
1543
1515
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "An enterprise web design system for business software — ERPs, back offices, management tools — in React and Tailwind: tokens, primitives, components and the two views every management screen is made of.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|