@sincpro/web-ui 2.11.0 → 2.12.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 +35 -3
- package/dist/components/activity/Messages.d.ts +3 -23
- package/dist/components/activity/Messages.js +3 -17
- package/dist/components/activity/index.d.ts +2 -1
- package/dist/components/activity/index.js +2 -1
- package/dist/components/activity/messageKind.d.ts +23 -0
- package/dist/components/activity/messageKind.js +17 -0
- package/dist/components/assist/assist.d.ts +1 -1
- package/dist/components/assist/assist.js +1 -1
- package/dist/components/frame/model.js +1 -1
- package/dist/components/guide/index.d.ts +2 -1
- package/dist/components/guide/index.js +2 -1
- package/dist/components/guide/selector.d.ts +25 -0
- package/dist/components/guide/selector.js +14 -0
- package/dist/components/guide/target.d.ts +3 -25
- package/dist/components/guide/target.js +2 -14
- package/dist/components/listing/AxisLevels.d.ts +2 -5
- package/dist/components/listing/AxisLevels.js +5 -22
- package/dist/components/listing/ColumnsMenu.d.ts +3 -7
- package/dist/components/listing/ColumnsMenu.js +4 -8
- package/dist/components/listing/collapsed.d.ts +2 -0
- package/dist/components/listing/collapsed.js +8 -0
- package/dist/components/listing/columnSpecs.d.ts +34 -0
- package/dist/components/listing/columnSpecs.js +54 -0
- package/dist/components/listing/columns.d.ts +3 -21
- package/dist/components/listing/columns.js +2 -39
- package/dist/components/listing/index.d.ts +9 -5
- package/dist/components/listing/index.js +13 -6
- package/dist/components/listing/levels.d.ts +9 -0
- package/dist/components/listing/levels.js +27 -0
- package/dist/components/listing/pageSizes.d.ts +9 -0
- package/dist/components/listing/pageSizes.js +11 -0
- package/dist/components/listing/pages.d.ts +2 -9
- package/dist/components/listing/pages.js +5 -9
- package/dist/components/listing/tree.d.ts +2 -1
- package/dist/components/listing/tree.js +4 -5
- package/dist/components/preview/FilePreview.d.ts +3 -3
- package/dist/components/preview/FilePreview.js +3 -15
- package/dist/components/preview/index.d.ts +2 -1
- package/dist/components/preview/index.js +2 -1
- package/dist/components/preview/previewKind.d.ts +3 -0
- package/dist/components/preview/previewKind.js +17 -0
- package/dist/components/search/FilterBuilder.d.ts +5 -139
- package/dist/components/search/FilterBuilder.js +5 -579
- package/dist/components/search/JsonEditor.d.ts +2 -8
- package/dist/components/search/JsonEditor.js +5 -15
- package/dist/components/search/RuleValue.d.ts +2 -2
- package/dist/components/search/RuleValue.js +5 -4
- package/dist/components/search/datePeriods.js +1 -1
- package/dist/components/search/filterTree.d.ts +183 -0
- package/dist/components/search/filterTree.js +570 -0
- package/dist/components/search/formatJson.d.ts +8 -0
- package/dist/components/search/formatJson.js +17 -0
- package/dist/components/search/index.d.ts +5 -3
- package/dist/components/search/index.js +7 -3
- package/dist/components/search/query.js +1 -1
- package/dist/foundations/calendar.js +1 -1
- package/dist/foundations/catalog.d.ts +7 -8
- package/dist/foundations/catalog.js +10 -35
- package/dist/foundations/chart.js +1 -1
- package/dist/foundations/controlName.d.ts +12 -0
- package/dist/foundations/controlName.js +14 -0
- package/dist/foundations/copy.d.ts +3 -1130
- package/dist/foundations/copy.es.d.ts +1 -1
- package/dist/foundations/copy.js +13 -747
- package/dist/foundations/copyStore.d.ts +21 -0
- package/dist/foundations/copyStore.js +47 -0
- package/dist/foundations/density.d.ts +4 -8
- package/dist/foundations/density.js +2 -9
- package/dist/foundations/form.d.ts +2 -12
- package/dist/foundations/form.js +4 -14
- package/dist/foundations/index.d.ts +18 -11
- package/dist/foundations/index.js +21 -11
- package/dist/foundations/keys.d.ts +8 -0
- package/dist/foundations/keys.js +6 -0
- package/dist/foundations/pickBy.d.ts +16 -0
- package/dist/foundations/pickBy.js +17 -0
- package/dist/foundations/pivotSheet.js +0 -0
- package/dist/foundations/shortcut.d.ts +3 -9
- package/dist/foundations/shortcut.js +2 -7
- package/dist/foundations/sticky.d.ts +2 -6
- package/dist/foundations/sticky.js +5 -8
- package/dist/foundations/stickyStyle.d.ts +12 -0
- package/dist/foundations/stickyStyle.js +13 -0
- package/dist/foundations/surface.d.ts +2 -2
- package/dist/foundations/surface.js +4 -2
- package/dist/foundations/theme.d.ts +3 -13
- package/dist/foundations/theme.js +2 -15
- package/dist/foundations/themeChoice.d.ts +19 -0
- package/dist/foundations/themeChoice.js +22 -0
- package/dist/foundations/types.d.ts +3 -0
- package/dist/foundations/uiCopy.d.ts +1135 -0
- package/dist/foundations/uiCopy.js +749 -0
- package/dist/foundations/xlsx.d.ts +4 -10
- package/dist/foundations/xlsx.js +0 -0
- package/dist/foundations/xlsxDownload.d.ts +8 -0
- package/dist/foundations/xlsxDownload.js +28 -0
- package/dist/primitives/button/Button.d.ts +3 -15
- package/dist/primitives/button/Button.js +2 -65
- package/dist/primitives/button/classes.d.ts +21 -0
- package/dist/primitives/button/classes.js +65 -0
- package/dist/primitives/button/index.d.ts +2 -1
- package/dist/primitives/button/index.js +3 -1
- package/dist/primitives/field/Field.d.ts +2 -6
- package/dist/primitives/field/Field.js +4 -10
- package/dist/primitives/field/classes.d.ts +6 -0
- package/dist/primitives/field/classes.js +13 -0
- package/dist/primitives/field/index.d.ts +2 -1
- package/dist/primitives/field/index.js +3 -1
- package/dist/primitives/menu/Menu.d.ts +2 -19
- package/dist/primitives/menu/Menu.js +4 -30
- package/dist/primitives/menu/classes.d.ts +18 -0
- package/dist/primitives/menu/classes.js +33 -0
- package/dist/primitives/menu/index.d.ts +2 -1
- package/dist/primitives/menu/index.js +3 -1
- package/dist/primitives/table/EditableTable.d.ts +3 -37
- package/dist/primitives/table/EditableTable.js +2 -47
- package/dist/primitives/table/Table.d.ts +2 -4
- package/dist/primitives/table/Table.js +4 -11
- package/dist/primitives/table/cellTone.d.ts +5 -0
- package/dist/primitives/table/cellTone.js +13 -0
- package/dist/primitives/table/editRules.d.ts +43 -0
- package/dist/primitives/table/editRules.js +53 -0
- package/dist/primitives/table/index.d.ts +4 -2
- package/dist/primitives/table/index.js +4 -2
- package/dist/primitives/tag/Count.d.ts +2 -3
- package/dist/primitives/tag/Count.js +4 -5
- package/dist/primitives/tag/countText.d.ts +3 -0
- package/dist/primitives/tag/countText.js +7 -0
- package/dist/primitives/tag/index.d.ts +2 -1
- package/dist/primitives/tag/index.js +2 -1
- package/dist/primitives/value/DateValue.d.ts +2 -5
- package/dist/primitives/value/DateValue.js +6 -44
- package/dist/primitives/value/Meter.d.ts +3 -8
- package/dist/primitives/value/Meter.js +2 -9
- package/dist/primitives/value/RichText.d.ts +2 -4
- package/dist/primitives/value/RichText.js +5 -20
- package/dist/primitives/value/Value.d.ts +10 -7
- package/dist/primitives/value/Value.js +7 -24
- package/dist/primitives/value/format.d.ts +16 -0
- package/dist/primitives/value/format.js +81 -0
- package/dist/primitives/value/index.d.ts +7 -4
- package/dist/primitives/value/index.js +9 -4
- package/dist/primitives/value/meterLevel.d.ts +10 -0
- package/dist/primitives/value/meterLevel.js +12 -0
- package/dist/primitives/value/richTextPlain.d.ts +4 -0
- package/dist/primitives/value/richTextPlain.js +23 -0
- package/package.json +1 -1
|
@@ -9,42 +9,13 @@ import { stickyTop, useScrollBox } from "../../foundations/sticky.js";
|
|
|
9
9
|
import { IconButton } from "../button/Button.js";
|
|
10
10
|
import { NoteCard, NoteRegistryContext, } from "../field/note.js";
|
|
11
11
|
import { Flag } from "../notice/Flag.js";
|
|
12
|
+
import { sectionLines, stackPlaces, tabTarget, } from "./editRules.js";
|
|
12
13
|
import { useRowWindow } from "./rowWindow.js";
|
|
13
14
|
import { HEADER_TEXT } from "./Table.js";
|
|
14
15
|
import { AlertCircle, GripVertical, Plus, Trash2 } from "lucide-react";
|
|
15
16
|
import { Fragment, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
16
17
|
import { useKeyboard } from "react-aria";
|
|
17
|
-
|
|
18
|
-
* cut a section, and are not lines. */
|
|
19
|
-
export function sectionLines(rows, getRowId, kind) {
|
|
20
|
-
const out = new Map();
|
|
21
|
-
let current = null;
|
|
22
|
-
for (const row of rows) {
|
|
23
|
-
const k = kind(row);
|
|
24
|
-
if (k === "section") {
|
|
25
|
-
current = [];
|
|
26
|
-
out.set(getRowId(row), current);
|
|
27
|
-
}
|
|
28
|
-
else if (k === null)
|
|
29
|
-
current?.push(row);
|
|
30
|
-
}
|
|
31
|
-
return out;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Where each column goes in the stacked card, defaults resolved: a declared `stack`
|
|
35
|
-
* wins; otherwise the first undeclared column is the title (unless one was declared),
|
|
36
|
-
* the last undeclared numeric one is the amount (unless one was declared), and the rest
|
|
37
|
-
* are detail.
|
|
38
|
-
*/
|
|
39
|
-
export function stackPlaces(columns) {
|
|
40
|
-
const titleAt = columns.some((c) => c.stack === "title")
|
|
41
|
-
? -1
|
|
42
|
-
: columns.findIndex((c) => c.stack === undefined);
|
|
43
|
-
const amountAt = columns.some((c) => c.stack === "amount")
|
|
44
|
-
? -1
|
|
45
|
-
: columns.findLastIndex((c, i) => c.stack === undefined && c.numeric === true && i !== titleAt);
|
|
46
|
-
return columns.map((c, i) => c.stack ?? (i === titleAt ? "title" : i === amountAt ? "amount" : "detail"));
|
|
47
|
-
}
|
|
18
|
+
export { sectionLines, stackPlaces, tabTarget };
|
|
48
19
|
/** A brief that says nothing is left out of the line, separator included. */
|
|
49
20
|
function says(node) {
|
|
50
21
|
return node !== null && node !== undefined && node !== false && node !== "";
|
|
@@ -107,22 +78,6 @@ export function firstControl(row) {
|
|
|
107
78
|
function lastControl(row) {
|
|
108
79
|
return editStops(row).at(-1) ?? stopsIn(row, FOCUSABLE).at(-1) ?? null;
|
|
109
80
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Where `Tab` past the last control (`next`) or `Shift+Tab` before the first (`prev`) of
|
|
112
|
-
* the edited row `from` goes, over the rows in the order they are drawn.
|
|
113
|
-
*
|
|
114
|
-
* Past the last row it adds one when the table can — unless `from` is itself a row just
|
|
115
|
-
* added and still blank: one more `Tab` there means «I am done», not «another blank line».
|
|
116
|
-
*/
|
|
117
|
-
export function tabTarget(order, from, direction, { canAdd, blank }) {
|
|
118
|
-
const at = order.indexOf(from);
|
|
119
|
-
if (at === -1)
|
|
120
|
-
return { kind: "leave" };
|
|
121
|
-
const to = order[direction === "next" ? at + 1 : at - 1];
|
|
122
|
-
if (to !== undefined)
|
|
123
|
-
return { kind: "row", id: to };
|
|
124
|
-
return direction === "next" && canAdd && !blank ? { kind: "add" } : { kind: "leave" };
|
|
125
|
-
}
|
|
126
81
|
/** Keys a control inside the row already answers with `Enter`: a button presses, a
|
|
127
82
|
* link follows, a text area breaks the line, an open list picks its option. */
|
|
128
83
|
function ownsEnter(target) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Tone } from "../../foundations/types.js";
|
|
2
|
+
import { CELL_TONE } from "./cellTone.js";
|
|
2
3
|
import type { WindowedRow } from "./rowWindow.js";
|
|
3
4
|
import { type SortState } from "./sorting.js";
|
|
4
5
|
import { type ReactNode } from "react";
|
|
@@ -76,10 +77,7 @@ export declare function TrDetail({ children, detail, open, onToggle, columns, la
|
|
|
76
77
|
label: string;
|
|
77
78
|
selected?: boolean;
|
|
78
79
|
}): import("react").JSX.Element;
|
|
79
|
-
|
|
80
|
-
* a hovered row and a painted cell are two signals, and stacking them reads
|
|
81
|
-
* as a third color. */
|
|
82
|
-
export declare const CELL_TONE: Record<Tone, string>;
|
|
80
|
+
export { CELL_TONE };
|
|
83
81
|
/** The wash of the row a cell sits in: for cells drawn outside `Td`, like the row's actions. */
|
|
84
82
|
export declare function useRowWash(): string;
|
|
85
83
|
export declare function Td({ children, numeric, align,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
4
4
|
import { stickyTop, useScrollBox } from "../../foundations/sticky.js";
|
|
5
|
+
import { CELL_TONE } from "./cellTone.js";
|
|
5
6
|
import { pressSort, sortPosition, } from "./sorting.js";
|
|
6
7
|
import { ArrowDown, ArrowUp, ChevronRight, ChevronsUpDown } from "lucide-react";
|
|
7
8
|
import { createContext, useContext, useId } from "react";
|
|
@@ -129,17 +130,9 @@ export function TrDetail({ children, detail, open, onToggle, columns, label, sel
|
|
|
129
130
|
onToggle();
|
|
130
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
132
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
export const CELL_TONE = {
|
|
136
|
-
neutral: "bg-ink/6",
|
|
137
|
-
info: "bg-info/12",
|
|
138
|
-
good: "bg-good/12",
|
|
139
|
-
warn: "bg-warn/15",
|
|
140
|
-
bad: "bg-bad/12",
|
|
141
|
-
accent: "bg-accent/20",
|
|
142
|
-
};
|
|
133
|
+
/* `CELL_TONE` is a plain table (`cellTone.ts`), without the directive, so a server component
|
|
134
|
+
reads it; re-exported so every path that read it here keeps reading it. */
|
|
135
|
+
export { CELL_TONE };
|
|
143
136
|
/** The wash of the row a cell sits in: for cells drawn outside `Td`, like the row's actions. */
|
|
144
137
|
export function useRowWash() {
|
|
145
138
|
return rowWash(useContext(RowMark));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Tone } from "../../foundations/types.js";
|
|
2
|
+
/** The background of a cell, by tone. It replaces the row wash on that cell:
|
|
3
|
+
* a hovered row and a painted cell are two signals, and stacking them reads
|
|
4
|
+
* as a third color. */
|
|
5
|
+
export declare const CELL_TONE: Record<Tone, string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* Without `"use client"`, apart from `Table.tsx`: a cell a server component draws takes the
|
|
2
|
+
same tone. */
|
|
3
|
+
/** The background of a cell, by tone. It replaces the row wash on that cell:
|
|
4
|
+
* a hovered row and a painted cell are two signals, and stacking them reads
|
|
5
|
+
* as a third color. */
|
|
6
|
+
export const CELL_TONE = {
|
|
7
|
+
neutral: "bg-ink/6",
|
|
8
|
+
info: "bg-info/12",
|
|
9
|
+
good: "bg-good/12",
|
|
10
|
+
warn: "bg-warn/15",
|
|
11
|
+
bad: "bg-bad/12",
|
|
12
|
+
accent: "bg-accent/20",
|
|
13
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE RULES OF AN EDITABLE TABLE that need no browser: where a column goes in a stacked
|
|
3
|
+
* card, which lines a section heads, where `Tab` goes from the edge of a row. Apart from
|
|
4
|
+
* `EditableTable.tsx` and without `"use client"`, so a server component — and a test —
|
|
5
|
+
* reads them as plain functions.
|
|
6
|
+
*/
|
|
7
|
+
/** Where a column goes when the row is drawn as a stacked card (a narrow box).
|
|
8
|
+
* `trail` sits at the top right, beside the title — a state, the row's buttons. */
|
|
9
|
+
export type StackPlace = "title" | "detail" | "amount" | "trail" | "hidden";
|
|
10
|
+
/** The lines each section heads: the rows after it up to the next section. Notes do not
|
|
11
|
+
* cut a section, and are not lines. */
|
|
12
|
+
export declare function sectionLines<T>(rows: readonly T[], getRowId: (row: T) => string, kind: (row: T) => "section" | "note" | null): Map<string, T[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Where each column goes in the stacked card, defaults resolved: a declared `stack`
|
|
15
|
+
* wins; otherwise the first undeclared column is the title (unless one was declared),
|
|
16
|
+
* the last undeclared numeric one is the amount (unless one was declared), and the rest
|
|
17
|
+
* are detail.
|
|
18
|
+
*/
|
|
19
|
+
export declare function stackPlaces(columns: readonly {
|
|
20
|
+
stack?: StackPlace;
|
|
21
|
+
numeric?: boolean;
|
|
22
|
+
}[]): StackPlace[];
|
|
23
|
+
/** Where `Tab` goes from the edge of an edited row: the next or previous row opened, a new
|
|
24
|
+
* row added, or out of the table the browser's way. */
|
|
25
|
+
export type TabTarget = {
|
|
26
|
+
kind: "row";
|
|
27
|
+
id: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: "add";
|
|
30
|
+
} | {
|
|
31
|
+
kind: "leave";
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Where `Tab` past the last control (`next`) or `Shift+Tab` before the first (`prev`) of
|
|
35
|
+
* the edited row `from` goes, over the rows in the order they are drawn.
|
|
36
|
+
*
|
|
37
|
+
* Past the last row it adds one when the table can — unless `from` is itself a row just
|
|
38
|
+
* added and still blank: one more `Tab` there means «I am done», not «another blank line».
|
|
39
|
+
*/
|
|
40
|
+
export declare function tabTarget(order: readonly string[], from: string, direction: "next" | "prev", { canAdd, blank }: {
|
|
41
|
+
canAdd: boolean;
|
|
42
|
+
blank: boolean;
|
|
43
|
+
}): TabTarget;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE RULES OF AN EDITABLE TABLE that need no browser: where a column goes in a stacked
|
|
3
|
+
* card, which lines a section heads, where `Tab` goes from the edge of a row. Apart from
|
|
4
|
+
* `EditableTable.tsx` and without `"use client"`, so a server component — and a test —
|
|
5
|
+
* reads them as plain functions.
|
|
6
|
+
*/
|
|
7
|
+
/** The lines each section heads: the rows after it up to the next section. Notes do not
|
|
8
|
+
* cut a section, and are not lines. */
|
|
9
|
+
export function sectionLines(rows, getRowId, kind) {
|
|
10
|
+
const out = new Map();
|
|
11
|
+
let current = null;
|
|
12
|
+
for (const row of rows) {
|
|
13
|
+
const k = kind(row);
|
|
14
|
+
if (k === "section") {
|
|
15
|
+
current = [];
|
|
16
|
+
out.set(getRowId(row), current);
|
|
17
|
+
}
|
|
18
|
+
else if (k === null)
|
|
19
|
+
current?.push(row);
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Where each column goes in the stacked card, defaults resolved: a declared `stack`
|
|
25
|
+
* wins; otherwise the first undeclared column is the title (unless one was declared),
|
|
26
|
+
* the last undeclared numeric one is the amount (unless one was declared), and the rest
|
|
27
|
+
* are detail.
|
|
28
|
+
*/
|
|
29
|
+
export function stackPlaces(columns) {
|
|
30
|
+
const titleAt = columns.some((c) => c.stack === "title")
|
|
31
|
+
? -1
|
|
32
|
+
: columns.findIndex((c) => c.stack === undefined);
|
|
33
|
+
const amountAt = columns.some((c) => c.stack === "amount")
|
|
34
|
+
? -1
|
|
35
|
+
: columns.findLastIndex((c, i) => c.stack === undefined && c.numeric === true && i !== titleAt);
|
|
36
|
+
return columns.map((c, i) => c.stack ?? (i === titleAt ? "title" : i === amountAt ? "amount" : "detail"));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Where `Tab` past the last control (`next`) or `Shift+Tab` before the first (`prev`) of
|
|
40
|
+
* the edited row `from` goes, over the rows in the order they are drawn.
|
|
41
|
+
*
|
|
42
|
+
* Past the last row it adds one when the table can — unless `from` is itself a row just
|
|
43
|
+
* added and still blank: one more `Tab` there means «I am done», not «another blank line».
|
|
44
|
+
*/
|
|
45
|
+
export function tabTarget(order, from, direction, { canAdd, blank }) {
|
|
46
|
+
const at = order.indexOf(from);
|
|
47
|
+
if (at === -1)
|
|
48
|
+
return { kind: "leave" };
|
|
49
|
+
const to = order[direction === "next" ? at + 1 : at - 1];
|
|
50
|
+
if (to !== undefined)
|
|
51
|
+
return { kind: "row", id: to };
|
|
52
|
+
return direction === "next" && canAdd && !blank ? { kind: "add" } : { kind: "leave" };
|
|
53
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
export { CELL_TONE } from "./cellTone.js";
|
|
1
2
|
export { type Aggregate, type DataColumn, DataTable, type DataTableCreate, type GroupColumn, type YesNoColumn, } from "./DataTable.js";
|
|
2
|
-
export { EditableTable, type EditAdd, type EditBands, type EditCellState, type EditColumn, type EditFlag, type EditLayout, type EditRowState,
|
|
3
|
+
export { EditableTable, type EditAdd, type EditBands, type EditCellState, type EditColumn, type EditFlag, type EditLayout, type EditRowState, } from "./EditableTable.js";
|
|
4
|
+
export { sectionLines, type StackPlace, stackPlaces, type TabTarget, tabTarget, } from "./editRules.js";
|
|
3
5
|
export { PileFootLine } from "./PileFootLine.js";
|
|
4
6
|
export { PivotTable, type PivotTableProps, } from "./PivotTable.js";
|
|
5
7
|
export { type ReportColumn, type ReportRow, type ReportRowKind, ReportTable, } from "./ReportTable.js";
|
|
6
8
|
export { type RowAction, RowActions } from "./RowActions.js";
|
|
7
9
|
export { type SheetColumn, SheetTable } from "./SheetTable.js";
|
|
8
10
|
export { compareBy, flipSort, moveSort, pressSort, type SortDirection, sortPosition, type SortState, } from "./sorting.js";
|
|
9
|
-
export {
|
|
11
|
+
export { Table, Td, Th, THead, Tr } from "./Table.js";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/* The presentation (`Table`) is ours and is used on its own; `DataTable` is the
|
|
2
2
|
wiring to TanStack for grouping and sorting. See the note in `DataTable.tsx`. */
|
|
3
|
+
export { CELL_TONE } from "./cellTone.js";
|
|
3
4
|
export { DataTable, } from "./DataTable.js";
|
|
4
|
-
export { EditableTable,
|
|
5
|
+
export { EditableTable, } from "./EditableTable.js";
|
|
6
|
+
export { sectionLines, stackPlaces, tabTarget, } from "./editRules.js";
|
|
5
7
|
export { PileFootLine } from "./PileFootLine.js";
|
|
6
8
|
export { PivotTable, } from "./PivotTable.js";
|
|
7
9
|
export { ReportTable, } from "./ReportTable.js";
|
|
8
10
|
export { RowActions } from "./RowActions.js";
|
|
9
11
|
export { SheetTable } from "./SheetTable.js";
|
|
10
12
|
export { compareBy, flipSort, moveSort, pressSort, sortPosition, } from "./sorting.js";
|
|
11
|
-
export {
|
|
13
|
+
export { Table, Td, Th, THead, Tr } from "./Table.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Surface, Tone } from "../../foundations/types.js";
|
|
2
|
+
import { countText } from "./countText.js";
|
|
2
3
|
export type CountProps = {
|
|
3
4
|
/** How many. Without it the count is a dot: something is there, not counted. */
|
|
4
5
|
value?: number;
|
|
@@ -17,7 +18,5 @@ export type CountProps = {
|
|
|
17
18
|
* seen: hidden from assistive technology so it is not read twice. */
|
|
18
19
|
"aria-hidden"?: boolean;
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
-
* hosts that also need it in words — a button's `aria-label`, a `title`. */
|
|
22
|
-
export declare function countText(value: number, format: (n: number) => string, max?: number): string;
|
|
21
|
+
export { countText };
|
|
23
22
|
export declare function Count({ value, tone, solid, max, showZero, current, surface, "aria-hidden": hidden, }: CountProps): import("react").JSX.Element | null;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
4
|
import { useSurface } from "../../foundations/surface.js";
|
|
5
|
+
import { countText } from "./countText.js";
|
|
5
6
|
import { useMemo } from "react";
|
|
6
7
|
/* Static and in a table: Tailwind cannot compose `bg-${tone}/12`. The gold is never text on
|
|
7
8
|
the canvas (2.43:1), so there its count is ink on a gold wash — the same rule as `Tag`. */
|
|
@@ -32,11 +33,9 @@ const DOT = {
|
|
|
32
33
|
bad: { canvas: "bg-bad", chrome: "bg-chrome-bad" },
|
|
33
34
|
accent: { canvas: "bg-accent", chrome: "bg-chrome-accent" },
|
|
34
35
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export
|
|
38
|
-
return max !== undefined && value > max ? `${format(max)}+` : format(value);
|
|
39
|
-
}
|
|
36
|
+
/* `countText` is a plain function (`countText.ts`), without the directive, so a server
|
|
37
|
+
component reads it; re-exported so every path that read it here keeps reading it. */
|
|
38
|
+
export { countText };
|
|
40
39
|
function skinOf(tone, surface, { solid, current, zero }) {
|
|
41
40
|
if (solid)
|
|
42
41
|
return SOLID[tone][surface];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* Without `"use client"`, apart from `Count.tsx` (which reads its surface and its words from
|
|
2
|
+
context): a server component that writes a count in words calls it. */
|
|
3
|
+
/** The text of a count: formatted for the locale, and «99+» past `max`. Exported for the
|
|
4
|
+
* hosts that also need it in words — a button's `aria-label`, a `title`. */
|
|
5
|
+
export function countText(value, format, max) {
|
|
6
|
+
return max !== undefined && value > max ? `${format(max)}+` : format(value);
|
|
7
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
export { StatusDot, Tag } from "./Tag.js";
|
|
3
3
|
/* How many things are behind something, or that something asks for: one counter for the
|
|
4
4
|
sidebar, the tabs, the systray, a menu and an application's own button. */
|
|
5
|
-
export { Count
|
|
5
|
+
export { Count } from "./Count.js";
|
|
6
|
+
export { countText } from "./countText.js";
|
|
6
7
|
/* The strip of chips: the same in the bar, in the dropdown and anywhere
|
|
7
8
|
a list of short words is drawn. */
|
|
8
9
|
export { Tags } from "./Tags.js";
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* a component passes its branch's (`useUiCopy()`), so a provider reaches the sentence. */
|
|
4
|
-
export declare function formatRelative(when: Date, now?: Date, copy?: UiCopy): string;
|
|
5
|
-
export declare function formatDateTime(when: Date, locale?: string): string;
|
|
1
|
+
import { formatDateTime, formatRelative } from "./format.js";
|
|
2
|
+
export { formatDateTime, formatRelative };
|
|
6
3
|
export declare function DateValue({ when, format,
|
|
7
4
|
/** So it can be tested: without this, a story with «hace 2 min» changes its
|
|
8
5
|
* text every minute and no snapshot works as a reference. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { dateFormat, formatDateTime, formatRelative, } from "./format.js";
|
|
4
5
|
/* ==================================================================== *
|
|
5
6
|
* WHEN — a date says two things and they can't both be said together.
|
|
6
7
|
*
|
|
@@ -19,49 +20,10 @@ import { currentCopy, currentCopyLocale, useUiCopy, } from "../../foundations/co
|
|
|
19
20
|
* order two things or remember which one it was. From there on the date is
|
|
20
21
|
* drawn, which is what at that distance is really being asked.
|
|
21
22
|
* ==================================================================== */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return new Intl.DateTimeFormat(locale, {
|
|
27
|
-
day: "2-digit",
|
|
28
|
-
month: "2-digit",
|
|
29
|
-
year: "numeric",
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
function timeFormat(locale) {
|
|
33
|
-
return new Intl.DateTimeFormat(locale, {
|
|
34
|
-
hour: "2-digit",
|
|
35
|
-
minute: "2-digit",
|
|
36
|
-
hourCycle: "h23",
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
const MINUTE = 60_000;
|
|
40
|
-
const HOUR = 60 * MINUTE;
|
|
41
|
-
const DAY = 24 * HOUR;
|
|
42
|
-
/** The steps, from finest to coarsest. The first one that fits, wins. */
|
|
43
|
-
const STEPS = [
|
|
44
|
-
[MINUTE, "minute"],
|
|
45
|
-
[HOUR, "hour"],
|
|
46
|
-
[DAY, "day"],
|
|
47
|
-
];
|
|
48
|
-
/** Context: `copy` defaults to the installed words — what a caller outside a component has;
|
|
49
|
-
* a component passes its branch's (`useUiCopy()`), so a provider reaches the sentence. */
|
|
50
|
-
export function formatRelative(when, now = new Date(), copy = currentCopy()) {
|
|
51
|
-
const locale = copy.locale;
|
|
52
|
-
const delta = when.getTime() - now.getTime();
|
|
53
|
-
const abs = Math.abs(delta);
|
|
54
|
-
if (abs < MINUTE)
|
|
55
|
-
return copy.time.justNow;
|
|
56
|
-
if (abs > 7 * DAY)
|
|
57
|
-
return dateFormat(locale).format(when);
|
|
58
|
-
const step = STEPS.find(([ms]) => abs < ms * 60) ?? STEPS[STEPS.length - 1];
|
|
59
|
-
const [ms, unit] = step;
|
|
60
|
-
return relativeFormat(locale).format(Math.round(delta / ms), unit);
|
|
61
|
-
}
|
|
62
|
-
export function formatDateTime(when, locale = currentCopyLocale()) {
|
|
63
|
-
return `${dateFormat(locale).format(when)} ${timeFormat(locale).format(when)}`;
|
|
64
|
-
}
|
|
23
|
+
/* The formatters — `formatRelative`, `formatDateTime` — are `format.ts`, without the
|
|
24
|
+
directive, so a server component writes a date the same way; re-exported so every path that
|
|
25
|
+
read them here keeps reading them. */
|
|
26
|
+
export { formatDateTime, formatRelative };
|
|
65
27
|
/** A day written as `YYYY-MM-DD` (what a date field stores) is that day HERE. `new Date()`
|
|
66
28
|
* reads it as midnight in UTC, and west of Greenwich that is the evening before: a due date
|
|
67
29
|
* of the 15th was drawn as the 14th in La Paz. Anything else goes through `Date` as is. */
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
+
import { type MeterLevel, meterLevel, type MeterThresholds } from "./meterLevel.js";
|
|
1
2
|
import type { ReactNode } from "react";
|
|
2
|
-
export type MeterLevel
|
|
3
|
-
|
|
4
|
-
export type MeterThresholds = {
|
|
5
|
-
warn: number;
|
|
6
|
-
danger: number;
|
|
7
|
-
};
|
|
8
|
-
/** The level of a percentage: under `warn` is good, up to `danger` is warn, above is danger. */
|
|
9
|
-
export declare function meterLevel(percentage: number, thresholds?: MeterThresholds): MeterLevel;
|
|
3
|
+
export type { MeterLevel, MeterThresholds };
|
|
4
|
+
export { meterLevel };
|
|
10
5
|
export type MeterProps = {
|
|
11
6
|
/** What is measured: «Crédito usado», «Stock». */
|
|
12
7
|
label: string;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { AriaLocale } from "../../foundations/aria.js";
|
|
4
4
|
import { tv } from "../../foundations/variants.js";
|
|
5
|
+
import { DEFAULT_THRESHOLDS, meterLevel, } from "./meterLevel.js";
|
|
5
6
|
import { Meter as AriaMeter } from "react-aria-components";
|
|
6
7
|
/**
|
|
7
8
|
* Where a quantity stands against a known range: the credit used, the stock against the
|
|
@@ -29,15 +30,7 @@ const fill = tv({
|
|
|
29
30
|
},
|
|
30
31
|
},
|
|
31
32
|
});
|
|
32
|
-
|
|
33
|
-
/** The level of a percentage: under `warn` is good, up to `danger` is warn, above is danger. */
|
|
34
|
-
export function meterLevel(percentage, thresholds = DEFAULT_THRESHOLDS) {
|
|
35
|
-
if (percentage > thresholds.danger)
|
|
36
|
-
return "danger";
|
|
37
|
-
if (percentage >= thresholds.warn)
|
|
38
|
-
return "warn";
|
|
39
|
-
return "good";
|
|
40
|
-
}
|
|
33
|
+
export { meterLevel };
|
|
41
34
|
export function Meter({ label, value, minValue = 0, maxValue = 100, formatOptions, valueLabel, thresholds = DEFAULT_THRESHOLDS, showValue = true, width = "w-64", }) {
|
|
42
35
|
return (_jsx(AriaLocale, { children: _jsx(AriaMeter, { "aria-label": label, value: value, minValue: minValue, maxValue: maxValue, formatOptions: formatOptions, valueLabel: valueLabel, className: `flex max-w-full flex-col gap-1.5 ${width}`, children: ({ percentage, valueText }) => {
|
|
43
36
|
const level = meterLevel(percentage, thresholds);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { isRichTextEmpty, richTextPlain } from "./richTextPlain.js";
|
|
1
2
|
/** The HTML with everything that runs taken out, or `null` where there is no DOM to do it. */
|
|
2
3
|
export declare function sanitizeRichText(html: string): string | null;
|
|
3
|
-
|
|
4
|
-
export declare function richTextPlain(html: string): string;
|
|
5
|
-
/** Nothing written: no text and no image — «<p></p>» from an emptied editor counts as nothing. */
|
|
6
|
-
export declare function isRichTextEmpty(html: string | null | undefined): boolean;
|
|
4
|
+
export { isRichTextEmpty, richTextPlain };
|
|
7
5
|
/** The HTML of a note, read: cleaned, in the system's text style (`rich-text` in tokens.css). */
|
|
8
6
|
export declare function RichTextValue({ value }: {
|
|
9
7
|
value: string | null | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { isRichTextEmpty, richTextPlain, } from "./richTextPlain.js";
|
|
4
5
|
import DOMPurify from "dompurify";
|
|
5
6
|
import { useSyncExternalStore } from "react";
|
|
6
7
|
/* ==================================================================== *
|
|
@@ -93,26 +94,10 @@ export function sanitizeRichText(html) {
|
|
|
93
94
|
ALLOWED_URI_REGEXP: /^(?:https?:|mailto:|tel:|data:image\/(?:png|jpeg|gif|webp);)/i,
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
.replace(/<[^>]*>/g, "")
|
|
101
|
-
.replace(/ /g, " ")
|
|
102
|
-
.replace(/&/g, "&")
|
|
103
|
-
.replace(/</g, "<")
|
|
104
|
-
.replace(/>/g, ">")
|
|
105
|
-
.replace(/"/g, '"')
|
|
106
|
-
.replace(/'/g, "'")
|
|
107
|
-
.replace(/\s+/g, " ")
|
|
108
|
-
.trim();
|
|
109
|
-
}
|
|
110
|
-
/** Nothing written: no text and no image — «<p></p>» from an emptied editor counts as nothing. */
|
|
111
|
-
export function isRichTextEmpty(html) {
|
|
112
|
-
if (html === null || html === undefined)
|
|
113
|
-
return true;
|
|
114
|
-
return richTextPlain(html) === "" && !/<(?:img|hr|table)\b/i.test(html);
|
|
115
|
-
}
|
|
97
|
+
/* `richTextPlain` and `isRichTextEmpty` are plain functions (`richTextPlain.ts`), without the
|
|
98
|
+
directive, so a server component reads them; re-exported so every path that read them here
|
|
99
|
+
keeps reading them. `sanitizeRichText` stays: DOMPurify needs a DOM. */
|
|
100
|
+
export { isRichTextEmpty, richTextPlain };
|
|
116
101
|
const subscribe = () => () => { };
|
|
117
102
|
/** The HTML of a note, read: cleaned, in the system's text style (`rich-text` in tokens.css). */
|
|
118
103
|
export function RichTextValue({ value }) {
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import { formatCount, formatDistance, formatNumber, formatWith } from "./format.js";
|
|
1
2
|
import { type Rounding } from "./rounding.js";
|
|
2
3
|
import type { ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Context: the mono/sans rule decides everything in here. The label goes in
|
|
6
|
+
* PROPORTIONAL —«orígenes», «mediana» are words, not data— and the value in
|
|
7
|
+
* tabular monospace, which is what makes four of these in a row keep their
|
|
8
|
+
* digits in a column.
|
|
9
|
+
*
|
|
10
|
+
* Formats follow the session locale, not a baked-in Spanish `Intl`.
|
|
11
|
+
*/
|
|
12
|
+
export { formatCount, formatDistance, formatNumber, formatWith };
|
|
6
13
|
/** A label with its number, for the glance at the top of a view. */
|
|
7
14
|
export declare function KeyValue({ label, value }: {
|
|
8
15
|
label: string;
|
|
9
16
|
value: ReactNode;
|
|
10
17
|
}): import("react").JSX.Element;
|
|
11
|
-
/** A number written with any `Intl.NumberFormatOptions` — a currency, a percentage, fixed
|
|
12
|
-
* decimals — in the session locale. The same options `NumberInput` takes, so a value reads
|
|
13
|
-
* the same in its form and in the cell or the figure that shows it elsewhere. */
|
|
14
|
-
export declare const formatWith: (value: number, options: Intl.NumberFormatOptions, locale?: string) => string;
|
|
15
18
|
/**
|
|
16
19
|
* A number with its unit: right aligned, with tabular figures.
|
|
17
20
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { formatCount, formatDistance, formatNumber, formatWith, } from "./format.js";
|
|
4
5
|
import { roundTo } from "./rounding.js";
|
|
5
6
|
/**
|
|
6
7
|
* Context: the mono/sans rule decides everything in here. The label goes in
|
|
@@ -10,39 +11,21 @@ import { roundTo } from "./rounding.js";
|
|
|
10
11
|
*
|
|
11
12
|
* Formats follow the session locale, not a baked-in Spanish `Intl`.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return new Intl.NumberFormat(locale, { maximumFractionDigits: 2 });
|
|
18
|
-
}
|
|
19
|
-
/** Four decimals and not two for distances — they live near zero
|
|
20
|
-
* (`0.0696`, `0.0149`) and with two they turn into `0.07` and `0.01`, which is
|
|
21
|
-
* losing exactly the part that tells one column from another. */
|
|
22
|
-
function distanceFormat(locale) {
|
|
23
|
-
return new Intl.NumberFormat(locale, {
|
|
24
|
-
minimumFractionDigits: 4,
|
|
25
|
-
maximumFractionDigits: 4,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
export const formatCount = (value, locale = currentCopyLocale()) => integerFormat(locale).format(value);
|
|
29
|
-
export const formatNumber = (value, locale = currentCopyLocale()) => decimalFormat(locale).format(value);
|
|
30
|
-
export const formatDistance = (value, locale = currentCopyLocale()) => distanceFormat(locale).format(value);
|
|
14
|
+
/* The formatters — `formatCount`, `formatNumber`, `formatDistance`, `formatWith` — are
|
|
15
|
+
`format.ts`, without the directive, so a server component writes a number the same way;
|
|
16
|
+
re-exported so every path that read them here keeps reading them. */
|
|
17
|
+
export { formatCount, formatDistance, formatNumber, formatWith };
|
|
31
18
|
/** A label with its number, for the glance at the top of a view. */
|
|
32
19
|
export function KeyValue({ label, value }) {
|
|
33
20
|
return (_jsxs("div", { className: "min-w-0", children: [_jsx("dt", { className: "text-micro text-muted", children: label }), _jsx("dd", { className: "mt-0.5 truncate text-lead tabular-nums text-ink", children: value })] }));
|
|
34
21
|
}
|
|
35
22
|
/** The three presets, as the options they are — so `signed` and a custom format share one
|
|
36
|
-
* path. Kept in step with `integerFormat`, `decimalFormat` and `distanceFormat`
|
|
23
|
+
* path. Kept in step with `integerFormat`, `decimalFormat` and `distanceFormat` (`format.ts`). */
|
|
37
24
|
const PRESET = {
|
|
38
25
|
integer: { maximumFractionDigits: 0 },
|
|
39
26
|
decimal: { maximumFractionDigits: 2 },
|
|
40
27
|
distance: { minimumFractionDigits: 4, maximumFractionDigits: 4 },
|
|
41
28
|
};
|
|
42
|
-
/** A number written with any `Intl.NumberFormatOptions` — a currency, a percentage, fixed
|
|
43
|
-
* decimals — in the session locale. The same options `NumberInput` takes, so a value reads
|
|
44
|
-
* the same in its form and in the cell or the figure that shows it elsewhere. */
|
|
45
|
-
export const formatWith = (value, options, locale = currentCopyLocale()) => new Intl.NumberFormat(locale, options).format(value);
|
|
46
29
|
/**
|
|
47
30
|
* A number with its unit: right aligned, with tabular figures.
|
|
48
31
|
*
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type UiCopy } from "../../foundations/uiCopy.js";
|
|
2
|
+
export declare const formatCount: (value: number, locale?: string) => string;
|
|
3
|
+
export declare const formatNumber: (value: number, locale?: string) => string;
|
|
4
|
+
export declare const formatDistance: (value: number, locale?: string) => string;
|
|
5
|
+
/** A number written with any `Intl.NumberFormatOptions` — a currency, a percentage, fixed
|
|
6
|
+
* decimals — in the session locale. The same options `NumberInput` takes, so a value reads
|
|
7
|
+
* the same in its form and in the cell or the figure that shows it elsewhere. */
|
|
8
|
+
export declare const formatWith: (value: number, options: Intl.NumberFormatOptions, locale?: string) => string;
|
|
9
|
+
/** The day alone, in digits and in the locale's order. Exported for `DateValue`'s `date`
|
|
10
|
+
* format; not public. */
|
|
11
|
+
export declare function dateFormat(locale: string): Intl.DateTimeFormat;
|
|
12
|
+
/** Context: `copy` defaults to the installed words — what a caller outside a component has;
|
|
13
|
+
* a component passes its branch's (read with `useUiCopy`), so a provider reaches the
|
|
14
|
+
* sentence. */
|
|
15
|
+
export declare function formatRelative(when: Date, now?: Date, copy?: UiCopy): string;
|
|
16
|
+
export declare function formatDateTime(when: Date, locale?: string): string;
|