@sincpro/web-ui 2.0.0 → 2.2.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 +45 -0
- package/dist/components/activity/Activity.d.ts +13 -14
- package/dist/components/activity/Activity.js +1 -1
- package/dist/components/activity/Messages.d.ts +5 -5
- package/dist/components/activity/Messages.js +8 -8
- package/dist/components/attachments/Attachments.d.ts +7 -1
- package/dist/components/attachments/Attachments.js +8 -2
- package/dist/components/board/Board.d.ts +32 -2
- package/dist/components/board/Board.js +27 -4
- package/dist/components/board/index.d.ts +1 -1
- package/dist/components/board/index.js +2 -1
- package/dist/components/form/Form.js +6 -6
- package/dist/components/form/index.js +2 -2
- package/dist/components/frame/FrameView.d.ts +5 -5
- package/dist/components/frame/FrameView.js +4 -4
- package/dist/components/listing/GroupingLevels.d.ts +22 -22
- package/dist/components/listing/GroupingLevels.js +9 -9
- package/dist/components/listing/Listing.d.ts +11 -11
- package/dist/components/listing/Listing.js +11 -11
- package/dist/components/listing/ListingBar.js +11 -11
- package/dist/components/listing/Row.d.ts +19 -19
- package/dist/components/listing/Row.js +27 -27
- package/dist/components/listing/SortMenu.d.ts +36 -36
- package/dist/components/listing/SortMenu.js +6 -6
- package/dist/components/listing/grouping.d.ts +16 -16
- package/dist/components/listing/grouping.js +6 -6
- package/dist/components/listing/index.js +1 -1
- package/dist/components/listing/modelColumns.d.ts +25 -25
- package/dist/components/listing/modelColumns.js +24 -24
- package/dist/components/listing/pages.js +4 -4
- package/dist/components/listing/set.d.ts +18 -18
- package/dist/components/navigation/NavigationTree.js +2 -2
- package/dist/components/navigation/index.js +2 -2
- package/dist/components/record/RecordSkeleton.js +7 -7
- package/dist/components/search/CriteriaBuilder.d.ts +22 -22
- package/dist/components/search/CriteriaBuilder.js +31 -31
- package/dist/components/search/CriteriaChips.d.ts +9 -9
- package/dist/components/search/CriteriaChips.js +12 -12
- package/dist/components/search/FilterBuilder.d.ts +67 -67
- package/dist/components/search/FilterBuilder.js +104 -104
- package/dist/components/search/JoinWord.d.ts +1 -1
- package/dist/components/search/JoinWord.js +14 -14
- package/dist/components/search/JsonEditor.d.ts +8 -8
- package/dist/components/search/JsonEditor.js +16 -16
- package/dist/components/search/SearchBar.d.ts +34 -34
- package/dist/components/search/SearchBar.js +140 -117
- package/dist/components/search/criteria.d.ts +61 -61
- package/dist/components/search/criteria.js +39 -39
- package/dist/components/search/datePeriods.d.ts +47 -48
- package/dist/components/search/datePeriods.js +29 -29
- package/dist/components/search/dateRanges.d.ts +27 -27
- package/dist/components/search/dateRanges.js +16 -16
- package/dist/components/search/index.js +13 -13
- package/dist/components/search/model.d.ts +28 -28
- package/dist/components/search/model.js +21 -21
- package/dist/components/search/query.d.ts +71 -71
- package/dist/components/search/query.js +119 -119
- package/dist/components/shell/AppFrame.d.ts +9 -2
- package/dist/components/shell/AppFrame.js +102 -14
- package/dist/components/shell/Sidebar.d.ts +34 -0
- package/dist/components/shell/Sidebar.js +32 -0
- package/dist/components/shell/TopBar.d.ts +2 -0
- package/dist/components/shell/TopBar.js +13 -9
- package/dist/components/shell/index.d.ts +2 -0
- package/dist/components/shell/index.js +5 -1
- package/dist/components/shell/sidebarDrawer.d.ts +26 -0
- package/dist/components/shell/sidebarDrawer.js +22 -0
- package/dist/foundations/calendar.d.ts +27 -27
- package/dist/foundations/calendar.js +72 -72
- package/dist/foundations/chart.d.ts +57 -57
- package/dist/foundations/chart.js +27 -27
- package/dist/foundations/copy.d.ts +109 -94
- package/dist/foundations/copy.es.js +10 -2
- package/dist/foundations/copy.js +10 -2
- package/dist/foundations/grouping.d.ts +175 -175
- package/dist/foundations/grouping.js +0 -0
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +21 -21
- package/dist/foundations/pivot.d.ts +133 -131
- package/dist/foundations/pivot.js +54 -54
- package/dist/foundations/pivotSheet.d.ts +36 -36
- package/dist/foundations/pivotSheet.js +0 -0
- package/dist/foundations/slots.d.ts +38 -38
- package/dist/foundations/slots.js +18 -18
- package/dist/foundations/sticky.d.ts +28 -28
- package/dist/foundations/sticky.js +59 -59
- package/dist/foundations/xlsx.d.ts +47 -47
- package/dist/foundations/xlsx.js +0 -0
- package/dist/primitives/block/Line.d.ts +4 -4
- package/dist/primitives/block/Line.js +28 -28
- package/dist/primitives/block/index.js +2 -2
- package/dist/primitives/cell/index.js +2 -2
- package/dist/primitives/choice/index.js +3 -3
- package/dist/primitives/date/Calendar.d.ts +7 -1
- package/dist/primitives/date/Calendar.js +13 -3
- package/dist/primitives/date/DatePicker.d.ts +4 -1
- package/dist/primitives/date/DatePicker.js +2 -2
- package/dist/primitives/date/index.js +3 -3
- package/dist/primitives/disclosure/index.js +1 -1
- package/dist/primitives/field/DropZone.d.ts +22 -3
- package/dist/primitives/field/DropZone.js +33 -12
- package/dist/primitives/menu/Menu.d.ts +10 -6
- package/dist/primitives/menu/Menu.js +4 -3
- package/dist/primitives/notice/Callout.d.ts +30 -30
- package/dist/primitives/notice/Callout.js +6 -6
- package/dist/primitives/overlay/index.js +3 -3
- package/dist/primitives/picker/Picker.d.ts +6 -0
- package/dist/primitives/picker/Picker.js +27 -4
- package/dist/primitives/picker/index.js +2 -2
- package/dist/primitives/table/DataTable.d.ts +32 -32
- package/dist/primitives/table/DataTable.js +24 -24
- package/dist/primitives/table/EditableTable.d.ts +10 -10
- package/dist/primitives/table/EditableTable.js +9 -9
- package/dist/primitives/table/ReportTable.js +7 -7
- package/dist/primitives/table/SheetTable.d.ts +13 -13
- package/dist/primitives/table/SheetTable.js +14 -14
- package/dist/primitives/table/Table.js +8 -8
- package/dist/primitives/tabs/Tabs.d.ts +46 -46
- package/dist/primitives/tabs/Tabs.js +4 -30
- package/dist/primitives/tag/Count.d.ts +23 -0
- package/dist/primitives/tag/Count.js +59 -0
- package/dist/primitives/tag/index.d.ts +1 -0
- package/dist/primitives/tag/index.js +5 -2
- package/dist/primitives/toolbar/index.js +1 -1
- package/dist/primitives/value/Copyable.d.ts +22 -22
- package/dist/primitives/value/Copyable.js +9 -9
- package/dist/primitives/value/Metric.d.ts +7 -2
- package/dist/primitives/value/Metric.js +12 -4
- package/dist/tokens.css +164 -57
- package/dist/views/list/List.d.ts +36 -36
- package/dist/views/list/List.js +19 -19
- package/dist/views/list/ListView.js +74 -74
- package/dist/views/list/columns.d.ts +10 -10
- package/dist/views/list/columns.js +10 -10
- package/dist/views/list/derive.d.ts +30 -30
- package/dist/views/list/derive.js +49 -49
- package/dist/views/list/index.js +2 -2
- package/dist/views/list/presentations.js +3 -3
- package/dist/views/list/types.d.ts +109 -109
- package/dist/views/record/Record.d.ts +14 -14
- package/dist/views/record/Record.js +24 -24
- package/dist/views/record/index.js +1 -1
- package/package.json +1 -1
|
@@ -92,15 +92,15 @@ const FEATURES = tableFeatures({
|
|
|
92
92
|
aggregationFns,
|
|
93
93
|
});
|
|
94
94
|
/**
|
|
95
|
-
*
|
|
95
|
+
* The aggregate of a column over a set of rows.
|
|
96
96
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
97
|
+
* It lives outside the component because three places ask for it: the table's
|
|
98
|
+
* foot, a pile's band in the sheet, and the line of a report built
|
|
99
|
+
* from the piles. Three implementations of «how much does this add up to» means
|
|
100
|
+
* the foot says one number and the pile another.
|
|
101
101
|
*
|
|
102
|
-
* `null`
|
|
103
|
-
*
|
|
102
|
+
* `null` when the column declared no aggregate, is not numeric, or there is no
|
|
103
|
+
* number to add — which is not the same as adding zero.
|
|
104
104
|
*/
|
|
105
105
|
export function aggregateOf(column, rows) {
|
|
106
106
|
if (column.aggregate === undefined || column.numeric !== true)
|
|
@@ -214,22 +214,22 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
214
214
|
id: c.id,
|
|
215
215
|
header: c.header,
|
|
216
216
|
enableSorting: c.sortable !== false,
|
|
217
|
-
/*
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
/* No column groups. What splits the set are the LEVELS, and
|
|
218
|
+
each one comes in as a column of its own —below— that exists only for
|
|
219
|
+
that: nobody draws it and nobody sorts it. */
|
|
220
220
|
enableGrouping: false,
|
|
221
221
|
aggregationFn: c.aggregate ?? "count",
|
|
222
222
|
})),
|
|
223
|
-
/*
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
223
|
+
/* One column per LEVEL, not per field. It is the only way for «by month and
|
|
224
|
+
inside it by day» to be two cuts: with the column's id, the two levels
|
|
225
|
+
of `registered_at` were the same id repeated, and one id cannot be
|
|
226
|
+
grouped twice.
|
|
227
227
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
228
|
+
And the key is set by the level, not the column: `value` is the SORT
|
|
229
|
+
key —for a date, the milliseconds— and grouping by it leaves one
|
|
230
|
+
pile per instant, with «1789294903895» as its label. Here goes the same
|
|
231
|
+
key the other five presentations build, so the table's piles
|
|
232
|
+
are THE SAME ones and what is folded holds for all. */
|
|
233
233
|
...(levels ?? []).map((level) => helper.accessor((row) => level.keyOf(row), {
|
|
234
234
|
id: level.id,
|
|
235
235
|
header: level.label,
|
|
@@ -316,8 +316,8 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
316
316
|
const key = pathKey(path);
|
|
317
317
|
const depth = path.length - 1;
|
|
318
318
|
const level = levels?.find((one) => one.id === row.groupingColumnId);
|
|
319
|
-
/*
|
|
320
|
-
|
|
319
|
+
/* The pile's KEY —the engine's— and the label, which the level sets: they are two
|
|
320
|
+
texts and only the second changes with the language. */
|
|
321
321
|
const value = path[depth] ?? key;
|
|
322
322
|
return {
|
|
323
323
|
kind: "pile",
|
|
@@ -325,9 +325,9 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
325
325
|
depth,
|
|
326
326
|
level: level?.label,
|
|
327
327
|
label: level === undefined ? value : level.labelOf(value),
|
|
328
|
-
/*
|
|
329
|
-
|
|
330
|
-
|
|
328
|
+
/* The rows INSIDE, not the subgroups: `subRows` of a pile with levels
|
|
329
|
+
below are the piles of the next level, and counting them said «2» where there are
|
|
330
|
+
forty rows. */
|
|
331
331
|
count: row.getLeafRows().filter((leaf) => leaf.subRows.length === 0).length,
|
|
332
332
|
detail: undefined,
|
|
333
333
|
open: collapsed === undefined ? row.getIsExpanded() : !collapsed.includes(key),
|
|
@@ -167,9 +167,9 @@ export declare function EditableTable<T>({ rows, columns, getRowId, onChange, on
|
|
|
167
167
|
* knows what adding up means in their domain —a percentage is not summed, it
|
|
168
168
|
* is averaged. */
|
|
169
169
|
totals, empty, grouping,
|
|
170
|
-
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
170
|
+
/** A column's total INSIDE a pile, already formatted. Whoever composes
|
|
171
|
+
* computes it, for the same reason as `totals`: adding up means different things
|
|
172
|
+
* depending on the domain, and a percentage is averaged, not added. */
|
|
173
173
|
groupTotal, height, layout, onOpen, onDiscard, bands, adds, flag, onReorder, cellState, rowState, }: {
|
|
174
174
|
rows: readonly T[];
|
|
175
175
|
columns: readonly EditColumn<T>[];
|
|
@@ -188,14 +188,14 @@ groupTotal, height, layout, onOpen, onDiscard, bands, adds, flag, onReorder, cel
|
|
|
188
188
|
totals?: readonly (ReactNode | null)[];
|
|
189
189
|
empty?: string;
|
|
190
190
|
/**
|
|
191
|
-
*
|
|
191
|
+
* Grouping, with the same contract as the rest of the data views.
|
|
192
192
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
193
|
+
* Editing and grouping do not get in each other's way: the row being edited is still a row,
|
|
194
|
+
* and the pile only decides where it lands. What is not inherited is the order — the
|
|
195
|
+
* rows of a pile stay together, so adding a new row puts it at the
|
|
196
|
+
* end of everything and not inside the pile you were looking at, which is the
|
|
197
|
+
* honest behaviour: it does not have a value yet in the field it is
|
|
198
|
+
* grouped by.
|
|
199
199
|
*/
|
|
200
200
|
grouping?: Grouping<T>;
|
|
201
201
|
groupTotal?: (column: EditColumn<T>, rows: readonly T[]) => ReactNode | null;
|
|
@@ -280,9 +280,9 @@ export function EditableTable({ rows, columns, getRowId, onChange, onRemove, onA
|
|
|
280
280
|
* knows what adding up means in their domain —a percentage is not summed, it
|
|
281
281
|
* is averaged. */
|
|
282
282
|
totals, empty, grouping,
|
|
283
|
-
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
283
|
+
/** A column's total INSIDE a pile, already formatted. Whoever composes
|
|
284
|
+
* computes it, for the same reason as `totals`: adding up means different things
|
|
285
|
+
* depending on the domain, and a percentage is averaged, not added. */
|
|
286
286
|
groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReorder, cellState, rowState, }) {
|
|
287
287
|
const copy = useUiCopy();
|
|
288
288
|
const bandOf = (row) => bands?.kind(row) ?? null;
|
|
@@ -367,8 +367,8 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
|
|
|
367
367
|
const [arriving, setArriving] = useState(null);
|
|
368
368
|
const addButton = useRef(null);
|
|
369
369
|
const rowById = useMemo(() => new Map(rows.map((row) => [getRowId(row), row])), [rows, getRowId]);
|
|
370
|
-
/*
|
|
371
|
-
|
|
370
|
+
/* The sequence that gets drawn: piles and rows interleaved. Without grouping, the
|
|
371
|
+
rows as they are — a table that does not group pays nothing for being able to. */
|
|
372
372
|
const drawn = useMemo(() => {
|
|
373
373
|
const piles = pilesOf(rows, grouping);
|
|
374
374
|
if (piles === null)
|
|
@@ -852,10 +852,10 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
|
|
|
852
852
|
const inside = pile.piles.length === 0 ? pile.items : pileItems(pile.piles);
|
|
853
853
|
return [
|
|
854
854
|
gap,
|
|
855
|
-
/*
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
855
|
+
/* The band respects the grid: the label in the first
|
|
856
|
+
column and each total under its own. A total in a corner
|
|
857
|
+
forces you to look for which column it belongs to; aligned there is nothing to
|
|
858
|
+
look for. */
|
|
859
859
|
_jsxs("tr", { ...windowed, children: [reorderable ? _jsx("td", { className: "w-0 bg-ground" }) : null, columns.map((c, ci) => (_jsx("td", { className: `bg-ground text-meta ${cell} ${c.numeric === true ? "text-right tabular-nums" : ""}`, style: ci === 0 && pile.depth > 0
|
|
860
860
|
? {
|
|
861
861
|
paddingLeft: `calc(var(--spacing-indent) * ${pile.depth} + 0.625rem)`,
|
|
@@ -97,12 +97,12 @@ defaultOpen, caption, height, }) {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
return (
|
|
100
|
-
/*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
/* Same decision as the other two tables, in the same place: with a height the
|
|
101
|
+
box scrolls and the stack starts from zero inside; without a height and fitting, there is no
|
|
102
|
+
box and the header sticks below the list's bar. This used
|
|
103
|
+
to be `overflow-auto` always, so the header inherited the
|
|
104
|
+
bar's offset and ended up pushed 68 px into its
|
|
105
|
+
own box — a blank band on top and column titles falling between
|
|
106
|
+
the rows. */
|
|
107
107
|
_jsx("div", { ref: caja.ref, tabIndex: caja.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, style: caja.style, children: _jsxs("table", { className: "w-full border-collapse px-1", children: [caption === undefined ? null : (_jsx("caption", { className: `text-left text-meta text-muted ${byDensity(d, "px-3 pb-2", "px-2 pb-1.5")}`, children: caption })), _jsx("thead", { className: "sticky z-20 bg-ground", style: stickyTop, children: _jsxs("tr", { className: "border-b border-line-strong", children: [_jsx("th", { className: `sticky left-0 z-10 bg-ground text-left ${compact ? "px-2 py-1.5" : "px-3 py-2"}`, children: _jsx("span", { className: "sr-only", children: copy.report.concept }) }), columns.map((c) => (_jsx("th", { scope: "col", className: `text-right ${HEADER_TEXT} ${compact ? "px-2 py-1.5" : "px-3 py-2"}`, children: c.header }, c.id))), _jsx("td", { className: "w-0" })] }) }), _jsx("tbody", { children: rows.map((r) => (_jsx(ReportLine, { row: r, columns: columns, open: open, onToggle: toggle, compact: compact }, r.id))) })] }) }));
|
|
108
108
|
}
|
|
@@ -31,16 +31,16 @@ note, height, rowLabel, band, onBandToggle, caption, onCommit, editable, onAddRo
|
|
|
31
31
|
height?: number | "auto";
|
|
32
32
|
rowLabel?: (row: number) => string;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* This row is not a row: it is the header of the pile that begins here.
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* Grouping without losing virtualisation is this — **a band is one more
|
|
37
|
+
* row, of another kind**. The alternative was one sheet per pile, and that is
|
|
38
|
+
* N grids with N headers and N scrolls for a single set.
|
|
39
39
|
*
|
|
40
|
-
* `depth`
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
40
|
+
* `depth` is how deep the pile is. The sheet cannot take a
|
|
41
|
+
* tree —it is virtualised by index, and an index is a position in a
|
|
42
|
+
* sequence—, so the hierarchy is told by each band's indentation and not by the
|
|
43
|
+
* nesting of the markup.
|
|
44
44
|
*/
|
|
45
45
|
band?: (row: number) => {
|
|
46
46
|
field?: string;
|
|
@@ -49,12 +49,12 @@ note, height, rowLabel, band, onBandToggle, caption, onCommit, editable, onAddRo
|
|
|
49
49
|
open: boolean;
|
|
50
50
|
depth?: number;
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* What the pile adds up IN EACH COLUMN, at that column's position.
|
|
53
53
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
54
|
+
* A band that puts its total in a corner forces you to look for which column
|
|
55
|
+
* the number belongs to. Aligned under its column there is nothing to look for:
|
|
56
|
+
* the grid already says what it means, which is what a
|
|
57
|
+
* grid is for. `null` in a column that does not add up — which is most of them.
|
|
58
58
|
*/
|
|
59
59
|
total?: (column: SheetColumn, columnIndex: number) => string | number | null;
|
|
60
60
|
} | undefined;
|
|
@@ -29,11 +29,11 @@ tone,
|
|
|
29
29
|
note, height = 420, rowLabel, band, onBandToggle, caption, onCommit, editable, onAddRow, }) {
|
|
30
30
|
const copy = useUiCopy();
|
|
31
31
|
const labelOf = rowLabel ?? ((i) => (i + 1).toLocaleString(copy.locale));
|
|
32
|
-
/* `"auto"`
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
/* `"auto"` is for a set that already came CUT —a page of eighty— and
|
|
33
|
+
in effect stops virtualising: with no scroll of its own, the visible window is the
|
|
34
|
+
whole box and every row is drawn. For raw data —where there are
|
|
35
|
+
a million— a height must be declared, and then only the ~30 in
|
|
36
|
+
view are drawn. When the box is a scroll container is decided by `useScrollBox`. */
|
|
37
37
|
const caja = useScrollBox(height === "auto" ? {} : { height });
|
|
38
38
|
const v = useVirtualizer({
|
|
39
39
|
count: rows,
|
|
@@ -173,16 +173,16 @@ note, height = 420, rowLabel, band, onBandToggle, caption, onCommit, editable, o
|
|
|
173
173
|
}, children: [_jsxs("div", { className: "sticky z-20 flex border-b border-line-strong bg-ground", style: stickyTop, role: "row", children: [_jsx("div", { className: "sticky left-0 z-30 shrink-0 border-r border-line bg-ground", style: { width: ROW_LABEL_WIDTH } }), columns.map((c) => (_jsxs("div", { role: "columnheader", style: { width: c.width ?? WIDTH }, className: `flex shrink-0 flex-col justify-center gap-0.5 border-r border-line px-2.5 py-1.5 ${c.numeric === true ? "items-end" : "items-start"}`, children: [_jsx("span", { className: "max-w-full truncate text-meta font-medium text-ink", title: c.header, children: c.header }), c.type === undefined ? null : (_jsx("span", { className: "max-w-full truncate font-mono text-micro text-muted", children: c.type }))] }, c.id))), _jsx("div", { className: "flex-1" })] }), _jsx("div", { style: { height: v.getTotalSize(), position: "relative" }, children: items.map((item) => {
|
|
174
174
|
const montón = band?.(item.index);
|
|
175
175
|
if (montón !== undefined) {
|
|
176
|
-
/*
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
/* The band sticks to the LEFT like the row number:
|
|
177
|
+
with forty columns, a label that goes away with the horizontal
|
|
178
|
+
scroll stops saying which pile you are in just when
|
|
179
|
+
you are furthest from it. */
|
|
180
180
|
return (
|
|
181
|
-
/*
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
/* The band RESPECTS the grid: label in the fixed column on
|
|
182
|
+
the left, and then one cell per column —empty, unless
|
|
183
|
+
that column adds something up—. It used to be a loose label that
|
|
184
|
+
ignored the columns, and then a total sat in a
|
|
185
|
+
corner without saying which column it was. */
|
|
186
186
|
_jsxs("div", { role: "row", "aria-rowindex": item.index + 1, className: "absolute top-0 left-0 flex w-full border-b border-line-strong bg-ground", style: { height: item.size, transform: `translateY(${item.start}px)` }, children: [_jsx("div", { role: "gridcell", className: "sticky left-0 z-10 shrink-0 border-r border-line bg-ground", style: { height: "100%", width: ROW_LABEL_WIDTH }, children: onBandToggle === undefined ? null : (_jsx("button", { type: "button", onClick: () => onBandToggle(item.index), "aria-expanded": montón.open, "aria-label": fillCopy(montón.open ? copy.report.close : copy.report.open, {
|
|
187
187
|
name: montón.label,
|
|
188
188
|
}), className: "flex h-full w-full min-w-0 items-center gap-1.5 px-2.5 text-left focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary", style: montón.depth === undefined || montón.depth === 0
|
|
@@ -47,10 +47,10 @@ export function Table({ children,
|
|
|
47
47
|
height, rowCount, }) {
|
|
48
48
|
const caja = useScrollBox(height === undefined ? {} : { height });
|
|
49
49
|
return (
|
|
50
|
-
/*
|
|
51
|
-
`useScrollBox`:
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
/* When this box is a scroll container and when it is not is decided by
|
|
51
|
+
`useScrollBox`: the whole dilemma lives there, and so does its explanation. The
|
|
52
|
+
three tables of the system solved it with three copies of the same
|
|
53
|
+
measurement. */
|
|
54
54
|
_jsx("div", { ref: caja.ref, tabIndex: caja.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, style: caja.style, children: _jsx("table", { "aria-rowcount": rowCount, className: "w-full border-separate border-spacing-0 px-1 text-left", children: children }) }));
|
|
55
55
|
}
|
|
56
56
|
/** The text of a column header, shared by every table of the family. Ink and semibold, not
|
|
@@ -58,10 +58,10 @@ height, rowCount, }) {
|
|
|
58
58
|
export const HEADER_TEXT = "text-meta font-semibold whitespace-nowrap text-ink";
|
|
59
59
|
export function THead({ children, rowIndex, }) {
|
|
60
60
|
return (
|
|
61
|
-
/*
|
|
62
|
-
|
|
63
|
-
`Table`
|
|
64
|
-
|
|
61
|
+
/* It sticks BELOW whatever is already stuck —the application bar and the
|
|
62
|
+
list's— and not at `top: 0`, which tucked it behind both. Without a height on
|
|
63
|
+
`Table` the page is what scrolls, and there the difference is exactly
|
|
64
|
+
what made the column names disappear. See `system/sticky.tsx`. */
|
|
65
65
|
_jsx("thead", { className: "sticky z-10 bg-ground", style: stickyTop, children: _jsx("tr", { "aria-rowindex": rowIndex, children: children }) }));
|
|
66
66
|
}
|
|
67
67
|
/** A column. If it gets a `sortKey`, it can be sorted.
|
|
@@ -2,78 +2,78 @@ import type { Tone } from "../../foundations/types.js";
|
|
|
2
2
|
import type { LucideIcon } from "lucide-react";
|
|
3
3
|
import { type ReactNode } from "react";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* A STRIP OF TABS. The same across the whole system.
|
|
6
6
|
*
|
|
7
|
-
* Context:
|
|
8
|
-
* `Aspects`,
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* Context: this lived inside the record's header and was called
|
|
8
|
+
* `Aspects`, so the activity —which needs exactly the same— could not
|
|
9
|
+
* use it: a context does not import from another context. The result was a second-hand
|
|
10
|
+
* strip of tabs, with the active one marked differently, on the same
|
|
11
|
+
* screen as the good one.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* It is a primitive because it does not know what it is separating: a record's
|
|
14
|
+
* faces, the two sources of a history, or whatever comes.
|
|
15
15
|
*
|
|
16
|
-
* ──
|
|
16
|
+
* ── Why the active one is a folder TAB ──────────────────────────────
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* And not an underline. An underline says «this is chosen»; a tab that sticks out
|
|
19
|
+
* of the border and covers the line says «this is OPEN and what is below is its
|
|
20
|
+
* content», which is the real relationship. The difference matters when there are three and
|
|
21
|
+
* the content below does not change shape when switching from one to another.
|
|
22
22
|
*
|
|
23
|
-
* ──
|
|
23
|
+
* ── The counter muted at zero ───────────────────────────────────────
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
25
|
+
* A zero is drawn, and muted. Hiding it forces you to open the tab to
|
|
26
|
+
* find out it is empty; painting it like the others makes it look as if it has
|
|
27
|
+
* something. «There are none» is information and it is said.
|
|
28
28
|
*
|
|
29
|
-
* ──
|
|
29
|
+
* ── The counter and the NOTIFICATION are two things ─────────────────
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* The counter says HOW MANY things are behind, and is neutral: «pagos 0» is an
|
|
32
|
+
* answer as valid as «pagos 5». The notification says that something in there
|
|
33
|
+
* ASKS you to look —it failed, changed, arrived— and that is why it has colour and why a
|
|
34
|
+
* zero is not drawn: there is nothing to ask.
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
* Confusing them looks like this: a tab with «3» beside it and nobody knows whether it is three
|
|
37
|
+
* things or three problems. They are two marks because they are two questions.
|
|
38
38
|
*/
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* SOMETHING IN THIS TAB ASKS FOR ATTENTION.
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
42
|
+
* It is not a count: a count says how many things there are and this says there is something to
|
|
43
|
+
* look at. That is why it has colour, why it is not drawn at zero, and why it can
|
|
44
|
+
* live alongside the counter — «pagos 4 ⬤» is four things, one of them
|
|
45
|
+
* rejected.
|
|
46
46
|
*/
|
|
47
47
|
export type TabNotice = {
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* What asks for attention, in the product's voice: «3 sin leer», «la
|
|
50
50
|
* factura no se pudo enviar».
|
|
51
51
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
52
|
+
* Required, and for the same reason as in `StatusDot`: a coloured dot without
|
|
53
|
+
* its word beside it forces learning a legend that is written nowhere,
|
|
54
|
+
* and tells nothing to someone who cannot tell red from green. Here
|
|
55
|
+
* the mark speeds up scanning and the word informs — it is read on hover
|
|
56
|
+
* and a screen reader reads it.
|
|
57
57
|
*/
|
|
58
58
|
label: string;
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
59
|
+
/** How many things ask for it. Without this it is a dot, which is what is used when
|
|
60
|
+
* something new arrived and counting it adds nothing. A `0` draws nothing: there is
|
|
61
|
+
* nothing to ask. */
|
|
62
62
|
count?: number;
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
63
|
+
/** Of what kind: `bad` something failed, `warn` something warns, `accent` or `info` something
|
|
64
|
+
* arrived. Without this, `bad` — which is the case this exists for. */
|
|
65
65
|
tone?: Tone;
|
|
66
66
|
};
|
|
67
67
|
export type TabItem = {
|
|
68
68
|
id: string;
|
|
69
69
|
label: string;
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
70
|
+
/** The tab's mark. With three or more, the icon is what is recognised without
|
|
71
|
+
* reading — and in a narrow strip it is the only thing that survives truncation. */
|
|
72
72
|
icon?: LucideIcon;
|
|
73
|
-
/**
|
|
74
|
-
*
|
|
73
|
+
/** How many things are behind. `undefined` = not counted; `0` is drawn
|
|
74
|
+
* muted, which is different from not counting. */
|
|
75
75
|
count?: number;
|
|
76
|
-
/**
|
|
76
|
+
/** That something in here asks you to look. Apart from the counter: see `TabNotice`. */
|
|
77
77
|
notice?: TabNotice;
|
|
78
78
|
};
|
|
79
79
|
/**
|
|
@@ -104,6 +104,6 @@ export declare function Tabs({ tabs, current, onSelect, label, }: {
|
|
|
104
104
|
tabs: readonly TabItem[];
|
|
105
105
|
current: string;
|
|
106
106
|
onSelect?: (id: string) => void;
|
|
107
|
-
/**
|
|
107
|
+
/** The strip's accessible label. Without this, «las caras del registro». */
|
|
108
108
|
label?: string;
|
|
109
109
|
}): import("react").JSX.Element;
|
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { Count } from "../tag/Count.js";
|
|
4
5
|
import { createContext, useContext, useId, useRef, } from "react";
|
|
5
|
-
/* El color de la notificación. Estático y en una tabla porque Tailwind no puede
|
|
6
|
-
componer una clase con un pedazo variable: `bg-${tone}/12` no existe en la
|
|
7
|
-
hoja. */
|
|
8
|
-
const NOTICE_TONE = {
|
|
9
|
-
neutral: "bg-ink/8 text-muted",
|
|
10
|
-
info: "bg-info/12 text-info",
|
|
11
|
-
good: "bg-good/12 text-good",
|
|
12
|
-
warn: "bg-warn/14 text-warn",
|
|
13
|
-
bad: "bg-bad/12 text-bad",
|
|
14
|
-
accent: "bg-accent/14 text-accent",
|
|
15
|
-
};
|
|
16
|
-
const NOTICE_DOT = {
|
|
17
|
-
neutral: "bg-muted",
|
|
18
|
-
info: "bg-info",
|
|
19
|
-
good: "bg-good",
|
|
20
|
-
warn: "bg-warn",
|
|
21
|
-
bad: "bg-bad",
|
|
22
|
-
accent: "bg-accent",
|
|
23
|
-
};
|
|
24
6
|
/**
|
|
25
7
|
* The strip only: what each tab opens is drawn by whoever uses it (`Record`, `Activity`).
|
|
26
8
|
*
|
|
@@ -89,22 +71,14 @@ export function Tabs({ tabs, current, onSelect, label, }) {
|
|
|
89
71
|
};
|
|
90
72
|
return (_jsx("div", { ref: strip, role: "tablist", "aria-label": label ?? copy.record.faces, onKeyDown: onKeyDown, className: "flex min-w-0 flex-wrap items-end gap-1", children: tabs.map((a) => {
|
|
91
73
|
const Icon = a.icon;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
contador, donde «0» es una respuesta. */
|
|
74
|
+
/* A zero asks for nothing, so it is not drawn. That is the difference from the
|
|
75
|
+
counter, where «0» is an answer. */
|
|
95
76
|
const notice = a.notice?.count === 0 ? undefined : a.notice;
|
|
96
77
|
const isSelected = a.id === current;
|
|
97
78
|
return (_jsx("button", { type: "button", role: "tab", "data-tab": a.id, "aria-selected": isSelected, tabIndex: isSelected ? 0 : -1, ...(base === null
|
|
98
79
|
? {}
|
|
99
80
|
: { id: tabIdOf(base, a.id), "aria-controls": panelIdOf(base, a.id) }), onClick: () => onSelect?.(a.id), className: `inline-flex shrink-0 cursor-default items-center px-3 py-2 text-meta outline-0 transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${isSelected
|
|
100
81
|
? "-mb-px rounded-t-control border border-b-0 border-line-strong bg-surface font-medium text-ink"
|
|
101
|
-
: "border border-transparent text-muted hover:text-ink"}`, children: _jsxs("span", { className: "inline-flex items-center gap-1.5", ...(notice === undefined ? {} : { title: notice.label }), children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-sm) shrink-0 ${isSelected ? "text-ink" : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), a.label, a.count === undefined ? null : (_jsx("span", { className:
|
|
102
|
-
? "bg-ink/5 text-muted"
|
|
103
|
-
: isSelected
|
|
104
|
-
? "bg-ink/8 text-ink"
|
|
105
|
-
: "bg-ink/8 text-muted"}`, children: a.count.toLocaleString(copy.locale) })), notice === undefined ? null : (_jsx("span", { className: "sr-only", children: ` · ${notice.label}` })), notice === undefined ? null : notice.count === undefined ? (
|
|
106
|
-
/* Sin número, un punto. La palabra no se dibuja pero está: en el
|
|
107
|
-
`title` y en el nombre accesible de la pestaña. */
|
|
108
|
-
_jsx("span", { className: `size-1.5 shrink-0 rounded-pill ${NOTICE_DOT[notice.tone ?? "bad"]}`, "aria-hidden": true })) : (_jsx("span", { className: `rounded-pill px-1.5 text-micro font-medium tabular-nums ${NOTICE_TONE[notice.tone ?? "bad"]}`, "aria-hidden": true, children: notice.count.toLocaleString(copy.locale) }))] }) }, a.id));
|
|
82
|
+
: "border border-transparent text-muted hover:text-ink"}`, children: _jsxs("span", { className: "inline-flex items-center gap-1.5", ...(notice === undefined ? {} : { title: notice.label }), children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-sm) shrink-0 ${isSelected ? "text-ink" : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), a.label, a.count === undefined ? null : (_jsx(Count, { value: a.count, showZero: true, current: isSelected })), notice === undefined ? null : (_jsx("span", { className: "sr-only", children: ` · ${notice.label}` })), notice === undefined ? null : (_jsx(Count, { ...(notice.count === undefined ? {} : { value: notice.count }), tone: notice.tone ?? "bad", "aria-hidden": true }))] }) }, a.id));
|
|
109
83
|
}) }));
|
|
110
84
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Surface, Tone } from "../../foundations/types.js";
|
|
2
|
+
export type CountProps = {
|
|
3
|
+
/** How many. Without it the count is a dot: something is there, not counted. */
|
|
4
|
+
value?: number;
|
|
5
|
+
/** `neutral` counts; any other tone says that something asks for attention. */
|
|
6
|
+
tone?: Tone;
|
|
7
|
+
/** Filled: the badge over an icon (a bell, a cart), which has to read on its own. */
|
|
8
|
+
solid?: boolean;
|
|
9
|
+
/** Past this it reads «99+». Without it every number is written in full. */
|
|
10
|
+
max?: number;
|
|
11
|
+
/** Draw the zero, fainter: where «0» is an answer and not noise (a tab). */
|
|
12
|
+
showZero?: boolean;
|
|
13
|
+
/** The thing it counts is the current one — the count takes its host's colour. */
|
|
14
|
+
current?: boolean;
|
|
15
|
+
surface?: Surface;
|
|
16
|
+
/** When the host already says the number in its name (`aria-label`), the count is only
|
|
17
|
+
* seen: hidden from assistive technology so it is not read twice. */
|
|
18
|
+
"aria-hidden"?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** The text of a count: formatted for the locale, and «99+» past `max`. Exported for the
|
|
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;
|
|
23
|
+
export declare function Count({ value, tone, solid, max, showZero, current, surface, "aria-hidden": hidden, }: CountProps): import("react").JSX.Element | null;
|