@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
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
import { pathKey, pathLabels, pileLabel, } from "./grouping.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* HOW TO READ A KEY of the axis, segment by segment.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* The key identifies —«2026-09» is what the engine writes and what is compared
|
|
6
|
+
* with what the server counted— and the label is read. They are two texts, as in
|
|
7
|
+
* a pile, and for the same reason: with the label as identity, two Septembers
|
|
8
|
+
* of different years would be the same one.
|
|
9
9
|
*
|
|
10
|
-
* `within`
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* `within` comes from the levels ABOVE of the same field: with the year outside, the
|
|
11
|
+
* month is said «Septiembre» and not «Septiembre de 2026», because that is already written
|
|
12
|
+
* two columns earlier.
|
|
13
13
|
*/
|
|
14
14
|
export function axisLabels(axis, key, label = pileLabel) {
|
|
15
15
|
return pathLabels(axis.levels, key, label);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* The separator between the two paths of a crossing.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* It is a different character from the one that separates a path's segments —that is the NUL
|
|
21
|
+
* of `pathKey`— because if it were the same, a row `["a"]` crossed with a
|
|
22
|
+
* column `["b","c"]` and a row `["a","b"]` crossed with `["c"]` would produce the
|
|
23
|
+
* same key, and they would be two different cells of the grid pointing at the same
|
|
24
|
+
* number.
|
|
25
25
|
*/
|
|
26
26
|
const CROSS = "";
|
|
27
27
|
function crossKey(row, column) {
|
|
28
28
|
return `${pathKey(row)}${CROSS}${pathKey(column)}`;
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
30
|
+
/** Only what a cell is, without the keys it traveled with. */
|
|
31
31
|
function cellOf(one) {
|
|
32
32
|
return { count: one.count, values: one.values };
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Indexes a pivot that arrives already folded.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
37
|
+
* Crossings travel as a list —it is what any transport knows how to serialize— and
|
|
38
|
+
* are drawn by asking one at a time, so an index is needed in between.
|
|
39
|
+
* It is built once here and not in every cell of every render: a grid of 288
|
|
40
|
+
* cells searching a list of 40 is 11,520 comparisons per paint.
|
|
41
41
|
*/
|
|
42
42
|
export function pivotOf(source) {
|
|
43
43
|
const crossings = new Map();
|
|
@@ -54,9 +54,9 @@ export function pivotOf(source) {
|
|
|
54
54
|
columns: source.columns,
|
|
55
55
|
measures: source.measures,
|
|
56
56
|
cell: (row, column) => crossings.get(crossKey(row, column)),
|
|
57
|
-
/*
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
/* Margins are offered only if they came. The alternative —always answering
|
|
58
|
+
and returning `undefined` inside— would make the grid draw a whole
|
|
59
|
+
totals band full of holes. */
|
|
60
60
|
...(source.rowMargins === undefined
|
|
61
61
|
? {}
|
|
62
62
|
: { rowTotal: (row) => rowMargins.get(pathKey(row)) }),
|
|
@@ -66,9 +66,9 @@ export function pivotOf(source) {
|
|
|
66
66
|
...(source.total === undefined ? {} : { total: source.total }),
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
69
|
+
/** The rows of an axis, grouped by their key, in order of first appearance.
|
|
70
|
+
* The order of the rows was already decided by somebody —a column, a criterion, the
|
|
71
|
+
* engine— and reordering the axes here would contradict it. */
|
|
72
72
|
function axisBuckets(items, levels, of) {
|
|
73
73
|
const out = new Map();
|
|
74
74
|
for (const item of items) {
|
|
@@ -89,17 +89,17 @@ function fold(measures, items) {
|
|
|
89
89
|
return { count: items.length, values };
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* Builds the pivot with the rows IN HAND.
|
|
93
93
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* `Pivot`
|
|
94
|
+
* It serves when the whole set is in the browser. When it is not, the
|
|
95
|
+
* pivot is folded by whoever stores the data and this is not used: the grid receives a
|
|
96
|
+
* `Pivot` from `pivotOf` and draws the same, because it draws the same type.
|
|
97
97
|
*
|
|
98
|
-
* **
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
98
|
+
* **Margins are folded over the rows of the base and not over the crossings**,
|
|
99
|
+
* which is rule 2 written as code: the margin of «Ferretería Sur» folds its 187
|
|
100
|
+
* invoices at once, not the twelve monthly numbers already drawn. It is
|
|
101
|
+
* the only thing that makes a measure that is not a sum —an average, a
|
|
102
|
+
* median, a distinct count— tell the truth at the edge.
|
|
103
103
|
*/
|
|
104
104
|
export function pivotFrom(items, spec) {
|
|
105
105
|
const label = (level) => spec.labelOf?.(level) ?? level.field;
|
|
@@ -141,28 +141,28 @@ export function pivotFrom(items, spec) {
|
|
|
141
141
|
total: fold(spec.measures, items),
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
144
|
+
/** Whether the pivot has not a single row to cross. An empty axis is not a small
|
|
145
|
+
* pivot: it is the empty view, and it is said with the set's phrase and not with a
|
|
146
|
+
* one-line grid. */
|
|
147
147
|
export function pivotIsEmpty(pivot) {
|
|
148
148
|
return pivot.rows.keys.length === 0 || pivot.columns.keys.length === 0;
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
-
*
|
|
151
|
+
* The segments of a key that must be WRITTEN, compared with the previous one.
|
|
152
152
|
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
153
|
+
* In a pivot's row area, a level's value is written only when it
|
|
154
|
+
* changes: repeating «Ferretería Sur» in the twelve rows of its twelve months turns the
|
|
155
|
+
* hierarchy into a column of noise and makes disappear precisely the cut that
|
|
156
|
+
* was asked for. Returns, per level, whether that segment starts here.
|
|
157
157
|
*/
|
|
158
158
|
export function keyStarts(key, previous) {
|
|
159
159
|
let broken = previous === undefined;
|
|
160
160
|
return key.map((part, level) => {
|
|
161
161
|
if (broken)
|
|
162
162
|
return true;
|
|
163
|
-
/*
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
/* Once a level above has changed, all those below start
|
|
164
|
+
anew even if they say the same: the «2026-09» of «Distribuidora Andina» is not the
|
|
165
|
+
continuation of the «2026-09» of «Ferretería Sur». */
|
|
166
166
|
if (part !== previous?.[level]) {
|
|
167
167
|
broken = true;
|
|
168
168
|
return true;
|
|
@@ -171,12 +171,12 @@ export function keyStarts(key, previous) {
|
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
|
-
*
|
|
174
|
+
* How much each segment of the horizontal axis spans, level by level.
|
|
175
175
|
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* —
|
|
179
|
-
*
|
|
176
|
+
* A pivot's header is a hierarchy lying on its side: one row per level, and
|
|
177
|
+
* each label covering the columns that hang from it. This resolves it once
|
|
178
|
+
* —in runs of consecutive equal segments, which is what makes «2026» cover its
|
|
179
|
+
* four quarters— and the grid only draws it.
|
|
180
180
|
*/
|
|
181
181
|
export function axisSpans(axis, level) {
|
|
182
182
|
const keys = axis.keys;
|
|
@@ -184,9 +184,9 @@ export function axisSpans(axis, level) {
|
|
|
184
184
|
keys.forEach((key, at) => {
|
|
185
185
|
const label = axisLabels(axis, key)[level] ?? "";
|
|
186
186
|
const last = out[out.length - 1];
|
|
187
|
-
/*
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
/* The whole PREFIX is compared and not the label: two «2026-09» under two
|
|
188
|
+
different customers are two spans, and merging them into one would draw a
|
|
189
|
+
cell spanning columns that are not siblings. */
|
|
190
190
|
const samePrefix = last !== undefined &&
|
|
191
191
|
last.label === label &&
|
|
192
192
|
key.slice(0, level).join(CROSS) === (keys[at - 1]?.slice(0, level).join(CROSS) ?? null);
|
|
@@ -1,61 +1,61 @@
|
|
|
1
1
|
import { type Pivot } from "./pivot.js";
|
|
2
2
|
import { type XlsxSheet } from "./xlsx.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* THE PIVOT AS A SPREADSHEET: the same grid, in a file.
|
|
5
5
|
*
|
|
6
|
-
* ──
|
|
6
|
+
* ── Why this exists and «exporting the table» is not enough ─────────
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* A grid that goes out to Excel as plain text loses the three things that
|
|
9
|
+
* made it a grid: the header stops being a hierarchy, the numbers stop
|
|
10
|
+
* adding up and the holes become zeros. All three are fixed here:
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
12
|
+
* the header goes with MERGED cells, so «2026» keeps covering its
|
|
13
|
+
* four quarters
|
|
14
|
+
* the numbers go in as numbers, with their format — not as text that
|
|
15
|
+
* looks like a number and cannot be summed
|
|
16
|
+
* the holes are not written. An absent cell in the file is the
|
|
17
|
+
* same as a crossing without rows on the screen
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* And the labels are frozen, for the same reason they stay stuck on the
|
|
20
|
+
* screen.
|
|
21
21
|
*
|
|
22
|
-
* ──
|
|
22
|
+
* ── What the file CANNOT say ────────────────────────────────────────
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* In the grid, an empty crossing and a measure that does not apply are drawn differently:
|
|
25
|
+
* blank the first, a dot the second. In the spreadsheet both are an empty
|
|
26
|
+
* cell, and that is deliberate — a dot inside a column of numbers turns it
|
|
27
|
+
* into a text column, and there the ability to sum it is lost, which is what
|
|
28
|
+
* somebody downloads a spreadsheet for.
|
|
29
29
|
*
|
|
30
|
-
* ──
|
|
30
|
+
* ── What this exports is what is in hand ────────────────────────────
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* Which is exactly everything, and that is why the pivot is the presentation where exporting
|
|
33
|
+
* from the browser does not lie: the whole grid has already come down —they are labels and numbers
|
|
34
|
+
* folded, not the records— so the file says the same as the screen.
|
|
35
|
+
* A paginated list is not that lucky and its export is another conversation.
|
|
36
36
|
*/
|
|
37
37
|
export type PivotSheetOptions = {
|
|
38
|
-
/**
|
|
38
|
+
/** The name of the tab, and of the file when it is downloaded. */
|
|
39
39
|
name?: string;
|
|
40
|
-
/**
|
|
40
|
+
/** A line above everything that says what this grid is. */
|
|
41
41
|
caption?: string;
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* The grid, as a spreadsheet.
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* It returns the SHAPE and not the file: the same data serves to download it here,
|
|
47
|
+
* to send it to a server that writes the workbook with more sheets, or to
|
|
48
|
+
* look at it in a test without unzipping anything.
|
|
49
49
|
*/
|
|
50
50
|
export declare function pivotSheet(pivot: Pivot, options?: PivotSheetOptions): XlsxSheet;
|
|
51
|
-
/**
|
|
51
|
+
/** The bytes of the `.xlsx` of a grid. */
|
|
52
52
|
export declare function pivotXlsx(pivot: Pivot, options?: PivotSheetOptions): Uint8Array;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Download the grid as a spreadsheet, in one line.
|
|
55
55
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
56
|
+
* It exists so that whoever uses it does not write the assembly again: three consumers
|
|
57
|
+
* chaining `pivotSheet → writeXlsx → downloadXlsx` by hand are three places
|
|
58
|
+
* where somebody forgets the title or the file name, and then the
|
|
59
|
+
* same grid downloads differently depending on which screen it came from.
|
|
60
60
|
*/
|
|
61
61
|
export declare function downloadPivot(pivot: Pivot, options?: PivotSheetOptions): void;
|
|
Binary file
|
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* THE SLOTS — how an archetype is written as a TREE.
|
|
4
4
|
*
|
|
5
|
-
* Context:
|
|
6
|
-
* props
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* Context: the shape of a screen is optional in a way that a list of
|
|
6
|
+
* props cannot express. Is there a rail? Are there tabs? Is there a pager? Can this list
|
|
7
|
+
* be seen as a table? A list of props answers that with `pager={undefined}`
|
|
8
|
+
* and with a second prop that declares which faces are offered — two places that
|
|
9
|
+
* can contradict each other. A tree says it out loud: **if it is not written, it is
|
|
10
|
+
* not there.**
|
|
11
11
|
*
|
|
12
12
|
* <Record>
|
|
13
13
|
* <Record.Rail>
|
|
14
|
-
* <Record.Pager index={12} total={80} /> ←
|
|
14
|
+
* <Record.Pager index={12} total={80} /> ← there is a pager
|
|
15
15
|
* </Record.Rail>
|
|
16
16
|
* </Record>
|
|
17
17
|
*
|
|
18
|
-
* ──
|
|
18
|
+
* ── Why a MARK and not the component's identity ─────────────────────
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* error.
|
|
20
|
+
* Recognising a slot by comparing `node.type === Record.Pager` fails
|
|
21
|
+
* silently the day there are two copies of the module in memory —hot reload,
|
|
22
|
+
* a badly deduplicated bundle— and then the tree is drawn empty without a single
|
|
23
|
+
* error. The mark travels with the component and survives that.
|
|
24
24
|
*
|
|
25
|
-
* ──
|
|
25
|
+
* ── This lives in `system/` and not inside an archetype ─────────────
|
|
26
26
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
27
|
+
* Because everything written as a tree speaks it. While it was
|
|
28
|
+
* hidden inside `Record.tsx`, being a tree was a privilege of
|
|
29
|
+
* records: any other archetype had to copy the mechanism or make do
|
|
30
|
+
* with thirty-six props.
|
|
31
31
|
*/
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
32
|
+
/** A component marked as a slot. The mark is the name, so a tree reads it
|
|
33
|
+
* without knowing where the component came from. */
|
|
34
34
|
export type Slotted<Name extends string> = {
|
|
35
35
|
__slot?: Name;
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Marks a component as a slot and returns it.
|
|
39
39
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
40
|
+
* The component draws NOTHING: it exists to be read by the archetype, which is
|
|
41
|
+
* the one deciding where what it carries goes. Returning `null` is right —
|
|
42
|
+
* a slot that drew itself would appear twice, once where it was written
|
|
43
|
+
* and once where the archetype put it.
|
|
44
44
|
*/
|
|
45
45
|
export declare function slot<Name extends string, P>(name: Name, component: (props: P) => ReactNode): ((props: P) => ReactNode) & Slotted<Name>;
|
|
46
|
-
/**
|
|
46
|
+
/** Which slot a node is, if any. */
|
|
47
47
|
export declare function slotOf<Name extends string>(node: ReactNode): Name | undefined;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* The children, with the fragments opened.
|
|
50
50
|
*
|
|
51
|
-
* `Children.toArray`
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* `Children.toArray` flattens arrays but NOT fragments, and a `<>…</>` in the
|
|
52
|
+
* middle of the tree —what anyone writes who puts two slots under a
|
|
53
|
+
* conditional— would hide the slots inside it.
|
|
54
54
|
*/
|
|
55
55
|
export declare function flatten(children: ReactNode, prefix?: string): ReactNode[];
|
|
56
|
-
/**
|
|
56
|
+
/** The first slot of that name. */
|
|
57
57
|
export declare function pick<Name extends string>(nodes: readonly ReactNode[], name: Name): ReactNode | undefined;
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
58
|
+
/** All the slots of that name, in the order they were written. Used by whoever
|
|
59
|
+
* accepts several sisters —a notebook's pages. */
|
|
60
60
|
export declare function pickAll<Name extends string>(nodes: readonly ReactNode[], name: Name): ReactNode[];
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
61
|
+
/** The props a slot was written with. It is the only thing the archetype
|
|
62
|
+
* needs from it: the slot does not draw, it declares. */
|
|
63
63
|
export declare function propsOf<P>(node: ReactNode | undefined): P | undefined;
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
64
|
+
/** What is NOT any of those slots. It is the escape hatch: what the archetype did not
|
|
65
|
+
* foresee is drawn anyway, and something showing up here is the sign that the
|
|
66
|
+
* archetype is missing a piece. */
|
|
67
67
|
export declare function loose<Name extends string>(nodes: readonly ReactNode[], names: readonly Name[]): ReactNode[];
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Children, cloneElement, Fragment, isValidElement } from "react";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Marks a component as a slot and returns it.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* The component draws NOTHING: it exists to be read by the archetype, which is
|
|
6
|
+
* the one deciding where what it carries goes. Returning `null` is right —
|
|
7
|
+
* a slot that drew itself would appear twice, once where it was written
|
|
8
|
+
* and once where the archetype put it.
|
|
9
9
|
*/
|
|
10
10
|
export function slot(name, component) {
|
|
11
11
|
const marked = component;
|
|
12
12
|
marked.__slot = name;
|
|
13
13
|
return marked;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/** Which slot a node is, if any. */
|
|
16
16
|
export function slotOf(node) {
|
|
17
17
|
if (!isValidElement(node))
|
|
18
18
|
return undefined;
|
|
@@ -20,11 +20,11 @@ export function slotOf(node) {
|
|
|
20
20
|
return typeof type === "string" ? undefined : type.__slot;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* The children, with the fragments opened.
|
|
24
24
|
*
|
|
25
|
-
* `Children.toArray`
|
|
26
|
-
*
|
|
27
|
-
*
|
|
25
|
+
* `Children.toArray` flattens arrays but NOT fragments, and a `<>…</>` in the
|
|
26
|
+
* middle of the tree —what anyone writes who puts two slots under a
|
|
27
|
+
* conditional— would hide the slots inside it.
|
|
28
28
|
*/
|
|
29
29
|
export function flatten(children, prefix = "") {
|
|
30
30
|
const out = [];
|
|
@@ -43,23 +43,23 @@ export function flatten(children, prefix = "") {
|
|
|
43
43
|
}
|
|
44
44
|
return out;
|
|
45
45
|
}
|
|
46
|
-
/**
|
|
46
|
+
/** The first slot of that name. */
|
|
47
47
|
export function pick(nodes, name) {
|
|
48
48
|
return nodes.find((node) => slotOf(node) === name);
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
50
|
+
/** All the slots of that name, in the order they were written. Used by whoever
|
|
51
|
+
* accepts several sisters —a notebook's pages. */
|
|
52
52
|
export function pickAll(nodes, name) {
|
|
53
53
|
return nodes.filter((node) => slotOf(node) === name);
|
|
54
54
|
}
|
|
55
|
-
/**
|
|
56
|
-
*
|
|
55
|
+
/** The props a slot was written with. It is the only thing the archetype
|
|
56
|
+
* needs from it: the slot does not draw, it declares. */
|
|
57
57
|
export function propsOf(node) {
|
|
58
58
|
return isValidElement(node) ? node.props : undefined;
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
60
|
+
/** What is NOT any of those slots. It is the escape hatch: what the archetype did not
|
|
61
|
+
* foresee is drawn anyway, and something showing up here is the sign that the
|
|
62
|
+
* archetype is missing a piece. */
|
|
63
63
|
export function loose(nodes, names) {
|
|
64
64
|
return nodes.filter((node) => {
|
|
65
65
|
const name = slotOf(node);
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { type CSSProperties, type RefObject } from "react";
|
|
2
|
-
/**
|
|
2
|
+
/** The variable that says at what height the next thing to stick starts. */
|
|
3
3
|
export declare const STICKY_TOP = "--sticky-top";
|
|
4
|
-
/**
|
|
4
|
+
/** What goes in the `style` of something sticky: it sticks below what is already there. */
|
|
5
5
|
export declare const stickyTop: CSSProperties;
|
|
6
|
-
/**
|
|
6
|
+
/** For a box with its own scroll: inside, the stack starts from zero. */
|
|
7
7
|
export declare function stickyReset(): CSSProperties;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* A TABLE'S BOX: when it has to be a scroll container and when not.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* `overflow-x: auto` **
|
|
14
|
-
* `visible`
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* The system's three tables have the same dilemma and used to solve it with three
|
|
12
|
+
* copies of the same measurement. The dilemma is CSS's and cannot be dodged:
|
|
13
|
+
* `overflow-x: auto` **forces** `overflow-y: auto` —the specification says that
|
|
14
|
+
* `visible` next to a value that is neither `visible` nor `clip` computes to `auto`—,
|
|
15
|
+
* so as soon as the box allows horizontal scroll it becomes the scroller, and
|
|
16
|
+
* the sticky header sticks to ITS edge instead of the page's.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
18
|
+
* From there come the three cases, and they are the only ones:
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
20
|
+
* own height the box really scrolls. `auto`, and the stack of sticky
|
|
21
|
+
* things starts from zero inside.
|
|
22
|
+
* no height, fits no box is needed. `clip` —trims the rounded corners
|
|
23
|
+
* without being a scroller— and the header sticks
|
|
24
|
+
* to the page, below the list bar.
|
|
25
|
+
* no height, does not fit horizontal scroll comes back, and the header goes
|
|
26
|
+
* away with the rows. It is the price, and it is what there is.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* Returns the class and the style already resolved so that no table has to
|
|
29
|
+
* decide it on its own again.
|
|
30
30
|
*/
|
|
31
31
|
export declare function useScrollBox<T extends HTMLElement>(options: {
|
|
32
|
-
/**
|
|
32
|
+
/** The declared height. `undefined` or `"auto"` = grows with the content. */
|
|
33
33
|
height?: number | string;
|
|
34
34
|
}): {
|
|
35
35
|
ref: RefObject<T | null>;
|
|
@@ -41,17 +41,17 @@ export declare function useScrollBox<T extends HTMLElement>(options: {
|
|
|
41
41
|
tabIndex: 0 | undefined;
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
44
|
+
* Measures an element's height and returns the style that pushes the stack for its
|
|
45
|
+
* siblings below.
|
|
46
46
|
*
|
|
47
|
-
* `useLayoutEffect`
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
* `useLayoutEffect` and `ResizeObserver` and not a declared height: the height depends
|
|
48
|
+
* on whether the search chips wrapped, and that is only known after
|
|
49
|
+
* painting.
|
|
50
50
|
*/
|
|
51
51
|
export declare function useStickyLayer<T extends HTMLElement>(): {
|
|
52
52
|
ref: RefObject<T | null>;
|
|
53
|
-
/**
|
|
53
|
+
/** Goes on the element that sticks. */
|
|
54
54
|
self: CSSProperties;
|
|
55
|
-
/**
|
|
55
|
+
/** Goes on what comes BELOW, so that it sticks even lower. */
|
|
56
56
|
below: CSSProperties;
|
|
57
57
|
};
|