@terpjs/react-core 0.30.0 → 0.32.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 -14
- package/package.json +5 -5
- package/src/DashboardPage.tsx +34 -0
- package/src/Field.test.tsx +26 -1
- package/src/Field.tsx +15 -5
- package/src/HubPage.tsx +7 -2
- package/src/ModuleNav.test.tsx +29 -1
- package/src/ModuleNav.tsx +5 -1
- package/src/Page.test.tsx +192 -0
- package/src/Page.tsx +141 -55
- package/src/PageActions.test.tsx +64 -3
- package/src/PageActions.tsx +40 -15
- package/src/PageSequence.tsx +114 -0
- package/src/Stat.test.tsx +376 -0
- package/src/Stat.tsx +316 -0
- package/src/Timeline.test.tsx +74 -0
- package/src/Timeline.tsx +71 -0
- package/src/admin/AdminHub.tsx +233 -78
- package/src/admin/AuditLogAdmin.tsx +3 -1
- package/src/admin/GroupCreate.tsx +3 -1
- package/src/admin/GroupDetail.tsx +72 -67
- package/src/admin/GroupsAdmin.tsx +3 -1
- package/src/admin/ModuleAccessPanel.tsx +13 -12
- package/src/admin/RecordHistory.tsx +88 -0
- package/src/admin/UserCreate.tsx +3 -1
- package/src/admin/UserDetail.tsx +8 -1
- package/src/admin/UsersAdmin.tsx +3 -0
- package/src/admin/admin.test.tsx +389 -19
- package/src/bootstrap.test.tsx +31 -7
- package/src/bootstrap.tsx +30 -4
- package/src/charts/BarChart.tsx +74 -0
- package/src/charts/ProportionBar.tsx +118 -0
- package/src/charts/StatusHistory.tsx +75 -0
- package/src/charts/TrendChart.tsx +232 -0
- package/src/charts/charts.test.tsx +409 -0
- package/src/charts/scale.ts +103 -0
- package/src/currentInView.ts +28 -0
- package/src/dataview/DataView.test.tsx +303 -1
- package/src/dataview/DataView.tsx +53 -3
- package/src/dataview/DataViewCardList.tsx +21 -13
- package/src/dataview/DataViewTable.tsx +5 -6
- package/src/dataview/DataViewToolbar.tsx +4 -1
- package/src/dataview/README.md +18 -0
- package/src/dataview/index.ts +1 -0
- package/src/dataview/internal.tsx +112 -5
- package/src/dataview/types.ts +39 -10
- package/src/errorMessages.test.tsx +17 -0
- package/src/errorMessages.tsx +18 -0
- package/src/format.ts +15 -0
- package/src/index.ts +24 -1
- package/src/layout.manifest.json +2 -9
- package/src/layout.manifest.test.ts +4 -2
- package/src/layout.test.tsx +74 -6
- package/src/layout.tsx +85 -25
- package/src/layoutContract.test.tsx +239 -1
- package/src/layoutContract.ts +131 -5
- package/src/layoutDeclaration.test.ts +31 -10
- package/src/layoutDeclaration.ts +9 -4
- package/src/locale.tsx +28 -3
- package/src/markers.test.ts +70 -2
- package/src/router.test.tsx +15 -3
- package/src/router.tsx +11 -2
- package/src/ssr.test.tsx +18 -0
- package/src/styles.test.ts +288 -190
- package/src/styles.ts +1379 -361
- package/src/theme.test.tsx +44 -18
- package/src/theme.themes.test.ts +22 -2
- package/src/theme.tsx +22 -14
- package/src/themes.ts +39 -4
- package/src/tokens.guard.test.ts +13 -15
- package/src/typography.tsx +5 -1
- package/src/ui/Alert.test.tsx +24 -1
- package/src/ui/Alert.tsx +10 -1
- package/src/ui/Card.tsx +5 -4
- package/src/ui/Tabs.test.tsx +44 -0
- package/src/ui/Tabs.tsx +5 -2
- package/src/ui/Tooltip.test.tsx +171 -2
- package/src/ui/Tooltip.tsx +144 -8
- package/src/ui/controlMessages.tsx +20 -7
- package/src/uiText.test.tsx +16 -0
- package/src/uiText.tsx +105 -7
- package/src/viewerTimeZone.ts +15 -0
package/src/styles.test.ts
CHANGED
|
@@ -371,15 +371,15 @@ describe("cascade structure", () => {
|
|
|
371
371
|
}
|
|
372
372
|
// And the content measure, which no structural check can reach through a marker: it is the
|
|
373
373
|
// one shell rule keyed on a descendant of an attribute rather than on a marker of its own,
|
|
374
|
-
// because the mechanism is deliberately NOT a new element (ADR 0097 §2). The `:not(
|
|
375
|
-
//
|
|
376
|
-
// the measure.
|
|
374
|
+
// because the mechanism is deliberately NOT a new element (ADR 0097 §2). The `:not()` is the
|
|
375
|
+
// whole band: the frame's two bands -- the title band and the summary band (ADR 0169 §4) --
|
|
376
|
+
// keep the page grid's full track while their siblings take the measure.
|
|
377
377
|
// Selector AND declaration read out of ONE rule body, not as two independent substrings
|
|
378
378
|
// of the layer. Asserted separately, an empty measure rule plus the declaration moved onto
|
|
379
379
|
// some other rule during a consolidation would satisfy both — and the only baseline that
|
|
380
380
|
// moved would read as an intentional layout change.
|
|
381
381
|
const measureRule =
|
|
382
|
-
/\[data-terp="appshell"\]\[data-content-width="measured"\]\s*\n?\s*\[data-terp="page"\] > \*:not\(\[data-terp="page-header"\]\) \{([^}]*)\}/.exec(
|
|
382
|
+
/\[data-terp="appshell"\]\[data-content-width="measured"\]\s*\n?\s*\[data-terp="page"\] > \*:not\(\[data-terp="page-header"\], \[data-terp="page-summary"\]\) \{([^}]*)\}/.exec(
|
|
383
383
|
base,
|
|
384
384
|
);
|
|
385
385
|
expect(measureRule, "the content measure must be one rule keyed on the shell's attribute").not
|
|
@@ -533,30 +533,43 @@ describe("cascade structure", () => {
|
|
|
533
533
|
expect(chrome, "the band is what separates chrome from content").toContain(
|
|
534
534
|
"border-block-end: 1px solid var(--color-neutral-200)",
|
|
535
535
|
);
|
|
536
|
-
// The block padding, and
|
|
537
|
-
//
|
|
538
|
-
//
|
|
539
|
-
//
|
|
540
|
-
//
|
|
541
|
-
//
|
|
542
|
-
//
|
|
536
|
+
// The block padding is ONE INSET, and the row gap is the same inset: every control's line
|
|
537
|
+
// of the band at least a control tall (pinned below), with the inset at the edges and
|
|
538
|
+
// between lines alike. The inset is what the header height leaves around one control, halved, so
|
|
539
|
+
// a one-line band is inset + control + inset + rule = the header's height, which is what
|
|
540
|
+
// the computed lane reads back. Two earlier shapes each got half of it wrong: zero padding
|
|
541
|
+
// with content-sized lines crammed a wrapped band against its border, and full 47px lines
|
|
542
|
+
// doubled the space between them.
|
|
543
543
|
//
|
|
544
|
-
//
|
|
545
|
-
//
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
expect(chrome, "the band's block padding is the app header's").toContain(
|
|
550
|
-
"padding-block: var(--space-0)",
|
|
544
|
+
// On EVERY chrome band, not only the kinds known to wrap: the band is a flex line now, and
|
|
545
|
+
// whether its cluster wraps depends on content no selector can see.
|
|
546
|
+
const inset = "calc((var(--shell-header-height) - 1px - var(--density-control-min-height)) / 2)";
|
|
547
|
+
expect(chrome, "the inset above the first line and below the last").toContain(
|
|
548
|
+
`padding-block: ${inset}`,
|
|
551
549
|
);
|
|
552
|
-
expect(
|
|
553
|
-
bodyFor('[data-terp="appshell-header"]'),
|
|
554
|
-
"both chrome rows spend the same block padding under the floor they share",
|
|
555
|
-
).toContain("padding: var(--space-0) var(--shell-gutter)");
|
|
550
|
+
expect(chrome, "and once between lines, not twice").toContain(`row-gap: ${inset}`);
|
|
556
551
|
expect(
|
|
557
552
|
/padding-inline|padding:/.test(chrome),
|
|
558
553
|
"an inline pad with no bleed would inset the band from the body beneath it",
|
|
559
554
|
).toBe(false);
|
|
555
|
+
const line = "min-height: var(--density-control-min-height)";
|
|
556
|
+
for (const item of [
|
|
557
|
+
'[data-terp="page"]:not([data-measure="narrow"]) > [data-terp="page-header"] [data-terp="breadcrumbs"]',
|
|
558
|
+
'[data-terp="page"]:not([data-measure="narrow"]) > [data-terp="page-header"] > [data-terp="page-actions"]',
|
|
559
|
+
]) {
|
|
560
|
+
expect(bodyFor(item), `${item}: a control's line at least a control tall`).toContain(line);
|
|
561
|
+
}
|
|
562
|
+
// The meta line is not a control's line (ADR 0135, amended 2026-10-04): it takes its own
|
|
563
|
+
// height, meets the line above it by cancelling the band's gap, and keeps --space-2 under
|
|
564
|
+
// its ink, so a lead sentence reads as the title's subtitle rather than as a line of its own.
|
|
565
|
+
const meta = bodyFor(
|
|
566
|
+
'[data-terp="page"]:not([data-measure="narrow"]) > [data-terp="page-header"] [data-terp="page-meta"]',
|
|
567
|
+
);
|
|
568
|
+
expect(meta, "the meta line takes its own height").not.toContain(line);
|
|
569
|
+
expect(meta, "and meets the line above it").toContain(
|
|
570
|
+
`margin-block-start: calc((var(--shell-header-height) - 1px - var(--density-control-min-height)) / -2)`,
|
|
571
|
+
);
|
|
572
|
+
expect(meta, "with room under its ink").toContain("padding-block-end: var(--space-2)");
|
|
560
573
|
|
|
561
574
|
// THE BLEED is gated, because the negative-margin idiom is only correct against a box
|
|
562
575
|
// that pads by exactly this token. ADR 0097 section 2 kept "it works with no shell above
|
|
@@ -643,6 +656,49 @@ describe("cascade structure", () => {
|
|
|
643
656
|
).toContain("height: 100%");
|
|
644
657
|
});
|
|
645
658
|
|
|
659
|
+
it("places a tooltip against the window and a card list against the view's own edge", () => {
|
|
660
|
+
const base = layerBody("terp.base");
|
|
661
|
+
const bodyFor = (selector: string): string => {
|
|
662
|
+
for (const match of base.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
|
|
663
|
+
const selectors = match[1].split(",").map((part) => part.trim().replace(/\s+/g, " "));
|
|
664
|
+
if (selectors.includes(selector)) return match[2];
|
|
665
|
+
}
|
|
666
|
+
throw new Error(`the sheet declares no rule for exactly ${selector}`);
|
|
667
|
+
};
|
|
668
|
+
// The bubble is portalled and placed from measured coordinates, so the sheet fixes it to
|
|
669
|
+
// the window and names no offset of its own. As an absolute child of its anchor it was
|
|
670
|
+
// clipped by any scroll container above it -- a DataView cell's tooltip ended at the
|
|
671
|
+
// table's edge -- and its available width was the trigger's, so a message on a button
|
|
672
|
+
// wrapped one button wide and grew off the top of the window.
|
|
673
|
+
const bubble = bodyFor('[data-terp="tooltip"]');
|
|
674
|
+
expect(bubble, "fixed to the window, where no scroll container can clip it").toContain(
|
|
675
|
+
"position: fixed",
|
|
676
|
+
);
|
|
677
|
+
expect(bubble, "the message's width, not the room a containing block leaves").toContain(
|
|
678
|
+
"inline-size: max-content",
|
|
679
|
+
);
|
|
680
|
+
// Portalled, its parent is the body, which no rule gives a typeface: without its own
|
|
681
|
+
// family the bubble rendered in the browser's default serif.
|
|
682
|
+
expect(bubble, "the bubble declares its typeface rather than inheriting the body's").toContain(
|
|
683
|
+
"font-family: var(--font-family-sans)",
|
|
684
|
+
);
|
|
685
|
+
expect(
|
|
686
|
+
/inset-|(^|[^-])(top|left|right|bottom):/.test(bubble),
|
|
687
|
+
"the coordinates are measured by the component; an offset here would fight them",
|
|
688
|
+
).toBe(false);
|
|
689
|
+
expect(
|
|
690
|
+
bodyFor('[data-terp="tooltip-anchor"]'),
|
|
691
|
+
"the anchor is no longer anything's containing block",
|
|
692
|
+
).not.toContain("position:");
|
|
693
|
+
// The card list sits beside the toolbar and the pagination, not inside the table's
|
|
694
|
+
// frame, so padding of its own inset every card from the edge they share. Measured at a
|
|
695
|
+
// phone width before: toolbar 16-394px, cards 24-386px.
|
|
696
|
+
expect(
|
|
697
|
+
bodyFor('[data-terp="dataview-card-list"]'),
|
|
698
|
+
"the cards line up with the toolbar and the pagination",
|
|
699
|
+
).toContain("padding: 0");
|
|
700
|
+
});
|
|
701
|
+
|
|
646
702
|
it("puts the DataView's surface on the full variant's TABLE, not on the root or the marker", () => {
|
|
647
703
|
// Both values of data-variant are stamped and only one has a rule, which is what keeps
|
|
648
704
|
// the embedded variant a bare grid. The alternative — surface on the marker, un-declared
|
|
@@ -787,6 +843,20 @@ describe("cascade structure", () => {
|
|
|
787
843
|
).not.toContain("box-shadow");
|
|
788
844
|
});
|
|
789
845
|
|
|
846
|
+
it("draws a control's outline in the boundary token, never in the raw ramp step", () => {
|
|
847
|
+
// ADR 0170 §4. --color-border-strong is the outline of every control, and the contrast
|
|
848
|
+
// gate's control-boundary pairings hold it at 3:1 against the surfaces controls sit on. The
|
|
849
|
+
// gate measures tokens, not rules, so it cannot see a rule that draws an edge in
|
|
850
|
+
// --color-neutral-300 instead — the step every control used before, at 1.4 to 2.4:1, which
|
|
851
|
+
// still paints the scrollbar and disabled ink. Any border drawn in the step is refused here,
|
|
852
|
+
// with one exception: the empty state's dashed outline frames no control, and WCAG sets no
|
|
853
|
+
// ratio for a decorative edge.
|
|
854
|
+
const offenders = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)]
|
|
855
|
+
.filter((rule) => /(?:^|;)\s*border[\w-]*\s*:[^;]*var\(--color-neutral-300\)/.test(rule[2]!))
|
|
856
|
+
.map((rule) => rule[1]!.trim().replace(/\s+/g, " "));
|
|
857
|
+
expect(offenders).toEqual(['[data-terp="empty-state"]']);
|
|
858
|
+
});
|
|
859
|
+
|
|
790
860
|
it("keeps the focus-within tint scoped to rows something will actually open", () => {
|
|
791
861
|
// The row marker is unconditional, so this selector reaches every row unless it says
|
|
792
862
|
// otherwise. Unguarded it paints a brand wash on any row holding focus — a selection
|
|
@@ -985,6 +1055,9 @@ describe("cascade structure", () => {
|
|
|
985
1055
|
// 500, near-black — and a card of five labelled values read as a wall of bold text with
|
|
986
1056
|
// nothing saying which half of a pair to read first.
|
|
987
1057
|
//
|
|
1058
|
+
// The ruled grid (ADR 0169 §5) joins the rule rather than taking a treatment of its own: a
|
|
1059
|
+
// grid cell is a stacked pair with rules around it.
|
|
1060
|
+
//
|
|
988
1061
|
// `inline` is deliberately excluded, and that is the half worth pinning: there the term is
|
|
989
1062
|
// part of a sentence (the colon comes from a ::after) and muting half a sentence is a
|
|
990
1063
|
// different defect. So this asserts the selector list exactly, in both directions.
|
|
@@ -1006,6 +1079,7 @@ describe("cascade structure", () => {
|
|
|
1006
1079
|
expect(muting[0]!.selectors).toEqual([
|
|
1007
1080
|
'[data-terp="detail-list"][data-layout="aligned"] [data-terp="detail-list-term"]',
|
|
1008
1081
|
'[data-terp="detail-list"][data-layout="stacked"] [data-terp="detail-list-term"]',
|
|
1082
|
+
'[data-terp="detail-list"][data-layout="grid"] [data-terp="detail-list-term"]',
|
|
1009
1083
|
]);
|
|
1010
1084
|
expect(muting[0]!.body).toContain("var(--font-size-xs)");
|
|
1011
1085
|
expect(muting[0]!.body).toContain("var(--font-weight-normal)");
|
|
@@ -1105,6 +1179,7 @@ describe("cascade structure", () => {
|
|
|
1105
1179
|
expect(value[0]!.selectors).toEqual([
|
|
1106
1180
|
'[data-terp="detail-list"][data-layout="aligned"] [data-terp="detail-list-value"]',
|
|
1107
1181
|
'[data-terp="detail-list"][data-layout="stacked"] [data-terp="detail-list-value"]',
|
|
1182
|
+
'[data-terp="detail-list"][data-layout="grid"] [data-terp="detail-list-value"]',
|
|
1108
1183
|
]);
|
|
1109
1184
|
expect(value[0]!.body, "the value takes the table body cell's step").toContain(cellStep!);
|
|
1110
1185
|
|
|
@@ -1113,20 +1188,24 @@ describe("cascade structure", () => {
|
|
|
1113
1188
|
expect(term[0]!.selectors).toEqual([
|
|
1114
1189
|
'[data-terp="detail-list"][data-layout="aligned"] [data-terp="detail-list-term"]',
|
|
1115
1190
|
'[data-terp="detail-list"][data-layout="stacked"] [data-terp="detail-list-term"]',
|
|
1191
|
+
'[data-terp="detail-list"][data-layout="grid"] [data-terp="detail-list-term"]',
|
|
1116
1192
|
]);
|
|
1117
1193
|
expect(term[0]!.body, "at the table header cell's step").toContain(headerStep!);
|
|
1118
1194
|
});
|
|
1119
1195
|
|
|
1120
|
-
it("gives a field row
|
|
1121
|
-
// The whole of FieldRow is that a field's
|
|
1122
|
-
//
|
|
1123
|
-
//
|
|
1124
|
-
//
|
|
1196
|
+
it("gives a field row two shared lines, and the narrow shape none of them", () => {
|
|
1197
|
+
// The whole of FieldRow is that a field's two parts -- its label, and its body (the
|
|
1198
|
+
// control with whatever the field says under it) -- land on the ROW's tracks rather than
|
|
1199
|
+
// on its own, so these declarations are one mechanism and a missing one breaks it
|
|
1200
|
+
// silently: a field that is not a subgrid simply measures itself again and the row looks
|
|
1201
|
+
// like an ordinary Stack.
|
|
1125
1202
|
//
|
|
1126
|
-
//
|
|
1127
|
-
//
|
|
1128
|
-
//
|
|
1129
|
-
// the
|
|
1203
|
+
// Two lines, not the three this used to be (label, control, messages): the messages moved
|
|
1204
|
+
// into the body, so a row where no field has a hint carries no empty line.
|
|
1205
|
+
//
|
|
1206
|
+
// The pairing that is easiest to get wrong is display: contents on the label, which is
|
|
1207
|
+
// what lifts the label TEXT and the body out of the <label> box so they can sit on
|
|
1208
|
+
// separate lines. Without it a field spans both tracks and puts everything on the first.
|
|
1130
1209
|
const wide = mediaBodies(layerBody("terp.base"), WIDE_VIEWPORT_QUERY);
|
|
1131
1210
|
const subgrid = /\[data-terp="field-row"\] > \[data-terp="field"\] \{([^}]*)\}/.exec(wide);
|
|
1132
1211
|
expect(subgrid, "each field subgrids the row").not.toBeNull();
|
|
@@ -1134,7 +1213,10 @@ describe("cascade structure", () => {
|
|
|
1134
1213
|
expect(subgrid![1], "and spans every line, or it subgrids one of them").toContain(
|
|
1135
1214
|
"grid-row: 1 / -1",
|
|
1136
1215
|
);
|
|
1137
|
-
expect(wide, "the row owns
|
|
1216
|
+
expect(wide, "the row owns two lines for them to share").toContain(
|
|
1217
|
+
"grid-template-rows: auto auto",
|
|
1218
|
+
);
|
|
1219
|
+
expect(wide, "not the three it had before the messages moved into the body").not.toContain(
|
|
1138
1220
|
"grid-template-rows: auto auto auto",
|
|
1139
1221
|
);
|
|
1140
1222
|
expect(
|
|
@@ -1212,198 +1294,148 @@ describe("cascade structure", () => {
|
|
|
1212
1294
|
expect(base.slice(textAt, base.indexOf("}", textAt))).not.toContain("font-weight");
|
|
1213
1295
|
});
|
|
1214
1296
|
|
|
1215
|
-
it("
|
|
1216
|
-
// The
|
|
1217
|
-
//
|
|
1218
|
-
//
|
|
1219
|
-
//
|
|
1220
|
-
//
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
const
|
|
1229
|
-
expect(
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
"flex: 1 1 0",
|
|
1233
|
-
);
|
|
1234
|
-
expect(heading, "min-width: 0 is what lets an unbreakable title shrink").toContain(
|
|
1235
|
-
"min-width: 0",
|
|
1297
|
+
it("gives a Card a header line of title and actions, and its description a line of its own", () => {
|
|
1298
|
+
// The page band's shape at a card's size. The card put its title and description in ONE
|
|
1299
|
+
// column and the actions in a second beside the pair, so the actions took their width out
|
|
1300
|
+
// of the description: a sentence wrapped in a narrow column next to one button, three
|
|
1301
|
+
// lines deep. Now the title and the actions share the header's line (the actions wrapping
|
|
1302
|
+
// under it only when they do not fit), and the description takes the next line, full width.
|
|
1303
|
+
const base = baseOnly(layerBody("terp.base")).replace(/\/\*[\s\S]*?\*\//g, "");
|
|
1304
|
+
const ruleFor = (selector: string) => {
|
|
1305
|
+
for (const match of base.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
|
|
1306
|
+
if (match[1].trim().replace(/\s+/g, " ") === selector) return match[2];
|
|
1307
|
+
}
|
|
1308
|
+
return null;
|
|
1309
|
+
};
|
|
1310
|
+
const header = ruleFor('[data-terp="card-header"]');
|
|
1311
|
+
expect(header, "a line that wraps on its content").toContain("flex-wrap: wrap");
|
|
1312
|
+
expect(header, "the title in the middle of the line it shares with a control").toContain(
|
|
1313
|
+
"align-items: center",
|
|
1236
1314
|
);
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
// block, where it floats the control in the middle instead of beside the title.
|
|
1240
|
-
expect(
|
|
1241
|
-
declaresRuleFor(base, '[data-terp="card-header"]:has([data-terp="card-description"])'),
|
|
1242
|
-
"the header's alignment must depend on whether there is a description",
|
|
1243
|
-
).toBe(true);
|
|
1244
|
-
const conditionalAt = base.indexOf(
|
|
1245
|
-
'[data-terp="card-header"]:has([data-terp="card-description"])',
|
|
1315
|
+
expect(ruleFor('[data-terp="card-heading"]'), "title and description are items of the header").toContain(
|
|
1316
|
+
"display: contents",
|
|
1246
1317
|
);
|
|
1247
|
-
expect(
|
|
1248
|
-
"
|
|
1318
|
+
expect(ruleFor('[data-terp="card-header"] [data-terp="card-title"]'), "the title first").toContain(
|
|
1319
|
+
"order: 1",
|
|
1249
1320
|
);
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
expect(
|
|
1321
|
+
const actions = ruleFor('[data-terp="card-actions"]');
|
|
1322
|
+
expect(actions, "the actions straight after it, so they can share its line").toContain("order: 2");
|
|
1323
|
+
expect(actions, "pushed to the end as one item").toContain("margin-inline-start: auto");
|
|
1324
|
+
expect(actions, "allowed to shrink to the line they are on").toContain("min-width: 0");
|
|
1325
|
+
expect(actions, "and wrapping their own buttons when they do").toContain("flex-wrap: wrap");
|
|
1326
|
+
const description = ruleFor('[data-terp="card-header"] [data-terp="card-description"]');
|
|
1327
|
+
expect(description, "the description last").toContain("order: 3");
|
|
1328
|
+
expect(description, "on a line of its own, never beside the actions").toContain("flex: 1 1 100%");
|
|
1329
|
+
expect(
|
|
1330
|
+
declaresRuleFor(layerBody("terp.base"), '[data-terp="card-header"]:has([data-terp="card-description"])'),
|
|
1331
|
+
"no alignment that depends on the description: it no longer shares the actions' line",
|
|
1332
|
+
).toBe(false);
|
|
1253
1333
|
});
|
|
1254
1334
|
|
|
1255
|
-
it("lays the page band out
|
|
1256
|
-
//
|
|
1257
|
-
//
|
|
1258
|
-
//
|
|
1259
|
-
//
|
|
1260
|
-
//
|
|
1261
|
-
//
|
|
1262
|
-
//
|
|
1263
|
-
//
|
|
1264
|
-
// wrap. Wrap order follows source order, so the meta group and the cluster cannot share a
|
|
1265
|
-
// row while staying two groups. And justify-content: space-between then has free space to
|
|
1266
|
-
// distribute, which scatters a page's buttons across the full width -- or left-aligns a
|
|
1267
|
-
// single cluster on the row whose whole job was to right-align it.
|
|
1335
|
+
it("lays the page band out as one wrapping line: trail, cluster when it fits, then meta", () => {
|
|
1336
|
+
// The third shape, and why. ADR 0135 made the band a grid of named areas, because a
|
|
1337
|
+
// source-ordered wrapping row could not keep the meta group and the cluster as two groups
|
|
1338
|
+
// and justify-content: space-between spread a wrapped cluster across the width. But areas
|
|
1339
|
+
// answer "where does the cluster go" per VIEWPORT, and the question is about CONTENT: above
|
|
1340
|
+
// the first cutover the cluster stayed beside the trail however wide it was, squeezing the
|
|
1341
|
+
// trail and running past the window with enough actions; below it, it took a row of its own
|
|
1342
|
+
// even when one button fitted beside a short title. Reported on the pages with one action
|
|
1343
|
+
// and one crumb.
|
|
1268
1344
|
//
|
|
1269
|
-
//
|
|
1270
|
-
//
|
|
1345
|
+
// A flex line wraps on what the items need, and the two old objections are answered
|
|
1346
|
+
// without areas: `order` puts the cluster straight after the trail and the meta group last,
|
|
1347
|
+
// and the cluster is one item pushed to the end by margin-inline-start: auto, so no free
|
|
1348
|
+
// space is distributed among buttons.
|
|
1271
1349
|
const base = layerBody("terp.base");
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1350
|
+
const flat = (body: string) => body.replace(/\s+/g, " ");
|
|
1351
|
+
// A rule whose WHOLE selector is this one -- not one that merely ends with it, which is
|
|
1352
|
+
// what a bare indexOf found first for page-actions inside the band's longer selector.
|
|
1353
|
+
const ruleFor = (selector: string) => {
|
|
1354
|
+
const all = flat(baseOnly(base).replace(/\/\*[\s\S]*?\*\//g, ""));
|
|
1355
|
+
for (const match of all.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
|
|
1356
|
+
if (match[1].trim() === selector) return `${selector} {${match[2]}`;
|
|
1357
|
+
}
|
|
1358
|
+
return null;
|
|
1359
|
+
};
|
|
1360
|
+
const header = ruleFor('[data-terp="page-header"]');
|
|
1361
|
+
expect(header, "page-header should have a base rule").not.toBeNull();
|
|
1362
|
+
expect(header, "a line that wraps on its content").toContain("display: flex");
|
|
1363
|
+
expect(header).toContain("flex-wrap: wrap");
|
|
1364
|
+
expect(header, "no areas left to place by viewport").not.toContain("grid-template-areas");
|
|
1365
|
+
|
|
1366
|
+
const trail = ruleFor('[data-terp="page-header"] [data-terp="breadcrumbs"]');
|
|
1367
|
+
expect(trail, "the trail comes first").toContain("order: 1");
|
|
1368
|
+
// What decides "fits": the trail's basis is its own full width, so the cluster joins its line
|
|
1369
|
+
// only when the whole trail fits beside it, and the trail grows into whatever is left.
|
|
1370
|
+
expect(trail, "the cluster shares the line only when the whole trail fits").toContain(
|
|
1371
|
+
"flex: 1 1 auto",
|
|
1281
1372
|
);
|
|
1282
|
-
expect(
|
|
1283
|
-
|
|
1373
|
+
expect(trail, "and it ellipsises inside its share rather than widening the line").toContain(
|
|
1374
|
+
"min-width: 0",
|
|
1284
1375
|
);
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
// wrapper (pinned below), so it never matched; the trail was auto-placed into column one
|
|
1290
|
-
// and truncated exactly as early as before. The cluster paid and the trail never
|
|
1291
|
-
// collected. Measured at 1280px on two crumbs, one badge and one button: the button on
|
|
1292
|
-
// line two with 1028px of free room beside the trail on line one, unchanged at 1440.
|
|
1293
|
-
//
|
|
1294
|
-
// So the cluster stays beside the trail and the meta group takes the row under it, which
|
|
1295
|
-
// is the one-row band's arrangement with a row added rather than a second arrangement.
|
|
1296
|
-
const metaAt = base.indexOf('[data-terp="page-header"][data-has-meta] {');
|
|
1297
|
-
expect(metaAt, "the two-row band should have a rule of its own").toBeGreaterThan(-1);
|
|
1298
|
-
const withMeta = base.slice(metaAt, base.indexOf("}", metaAt));
|
|
1299
|
-
// auto, not 1fr. Equal-height lines were the point of 1fr, and in an indefinite container
|
|
1300
|
-
// fr rows resolve to the LARGEST row's content -- so the taller line's item filled its
|
|
1301
|
-
// track exactly and, with the chrome row spending no block padding, sat flush on the
|
|
1302
|
-
// band's border. Measured 9px above the content and 0px below it on every two-row page.
|
|
1303
|
-
// Content-sized rows plus the multi-row band's own padding measure 4px and 4px.
|
|
1304
|
-
expect(withMeta, "rows sized to their content, so neither sits on the border").toContain(
|
|
1305
|
-
"grid-auto-rows: auto",
|
|
1376
|
+
|
|
1377
|
+
const cluster = ruleFor('[data-terp="page-header"] > [data-terp="page-actions"]');
|
|
1378
|
+
expect(cluster, "the cluster straight after the trail, so it can share its line").toContain(
|
|
1379
|
+
"order: 2",
|
|
1306
1380
|
);
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
// visible" below pins.
|
|
1310
|
-
const wideMeta = mediaBodies(base, WIDE_VIEWPORT_QUERY);
|
|
1311
|
-
expect(wideMeta, "above the cutover the cluster keeps its place beside the trail").toContain(
|
|
1312
|
-
'"trail actions"',
|
|
1381
|
+
expect(cluster, "pushed to the end as ONE item -- nothing spreads its buttons").toContain(
|
|
1382
|
+
"margin-inline-start: auto",
|
|
1313
1383
|
);
|
|
1314
|
-
|
|
1315
|
-
|
|
1384
|
+
// A flex item's automatic minimum is its content's: without these the cluster refuses to
|
|
1385
|
+
// shrink past its buttons and runs off the edge instead of wrapping them.
|
|
1386
|
+
expect(cluster, "it may shrink to its line").toContain("flex: 0 1 auto");
|
|
1387
|
+
expect(cluster).toContain("min-width: 0");
|
|
1388
|
+
expect(ruleFor('[data-terp="page-actions"]'), "and its own buttons wrap when it does").toContain(
|
|
1389
|
+
"flex-wrap: wrap",
|
|
1316
1390
|
);
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1391
|
+
|
|
1392
|
+
const meta = ruleFor('[data-terp="page-meta"]');
|
|
1393
|
+
expect(meta, "badges and the lead line last").toContain("order: 3");
|
|
1394
|
+
expect(meta, "on a line of their own, never beside the cluster").toContain("flex: 1 1 100%");
|
|
1395
|
+
|
|
1396
|
+
// The left group generates no box, which is what makes the trail and the meta group items
|
|
1397
|
+
// of the BAND, so they can sit on different lines. The marker survives for the scanner.
|
|
1398
|
+
expect(ruleFor('[data-terp="page-heading"]'), "a boxed wrapper would make them one item").toContain(
|
|
1399
|
+
"display: contents",
|
|
1320
1400
|
);
|
|
1321
|
-
|
|
1322
|
-
//
|
|
1323
|
-
|
|
1324
|
-
// and no h1 on screen at all. Dropping the ancestors takes their separators with them.
|
|
1401
|
+
|
|
1402
|
+
// The trail sheds its ancestors rather than its characters below the first cutover.
|
|
1403
|
+
const narrowBand = mediaBodies(base, NARROW_VIEWPORT);
|
|
1325
1404
|
expect(narrowBand, "the narrow trail keeps the leaf and one ancestor").toContain(
|
|
1326
1405
|
"li:not(:last-child):not(:nth-last-child(2))",
|
|
1327
1406
|
);
|
|
1328
|
-
|
|
1329
|
-
//
|
|
1330
|
-
//
|
|
1331
|
-
|
|
1332
|
-
'[data-terp="page-header"]:has(> [data-terp="page-actions"])',
|
|
1333
|
-
);
|
|
1334
|
-
// The left group generates no box, which is what lets its two children be grid items of
|
|
1335
|
-
// the BAND and therefore sit on different rows. The marker survives for the scanner.
|
|
1336
|
-
const headingAt = base.indexOf('[data-terp="page-heading"] {');
|
|
1337
|
-
expect(headingAt, "page-heading should have a base rule").toBeGreaterThan(-1);
|
|
1338
|
-
const heading = base.slice(headingAt, base.indexOf("}", headingAt));
|
|
1339
|
-
expect(heading, "a boxed wrapper would put the trail and the meta in one cell").toContain(
|
|
1340
|
-
"display: contents",
|
|
1341
|
-
);
|
|
1342
|
-
// The lead line is written as a correction, not a rule: hidden everywhere, shown again
|
|
1343
|
-
// above the SECOND cutover. That is what makes three regions out of two queries -- the
|
|
1344
|
-
// middle one is the width at which this correction has not applied yet.
|
|
1345
|
-
const descAt = base.indexOf('[data-terp="page-description"] {');
|
|
1346
|
-
expect(descAt, "page-description should have a base rule").toBeGreaterThan(-1);
|
|
1347
|
-
const description = base.slice(descAt, base.indexOf("}", descAt));
|
|
1407
|
+
|
|
1408
|
+
// The lead line is a correction, not a rule: hidden everywhere, shown again above the
|
|
1409
|
+
// SECOND cutover, which makes three regions out of two queries.
|
|
1410
|
+
const description = ruleFor('[data-terp="page-description"]');
|
|
1348
1411
|
expect(description, "the lead line is the first thing to go when room is short").toContain(
|
|
1349
1412
|
"display: none",
|
|
1350
1413
|
);
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
const
|
|
1354
|
-
expect(roomy, "the lead line comes back above the second cutover").toBeGreaterThan(descAt);
|
|
1355
|
-
// And the truncation, which still matters on the row it does get: the sentence shares
|
|
1356
|
-
// that row with the badges, so its max-content must not decide the row's width.
|
|
1357
|
-
const shown = base.slice(base.indexOf('[data-terp="page-description"] {', roomy));
|
|
1358
|
-
expect(shown).toContain("display: block");
|
|
1359
|
-
const full = base.slice(base.lastIndexOf('[data-terp="page-description"] {'));
|
|
1414
|
+
const roomy = mediaBodies(base, ROOMY_VIEWPORT_QUERY);
|
|
1415
|
+
expect(flat(roomy)).toContain('[data-terp="page-description"] { display: block; }');
|
|
1416
|
+
const full = flat(base.slice(base.lastIndexOf('[data-terp="page-description"] {')));
|
|
1360
1417
|
expect(full).toContain("min-width: 0");
|
|
1361
1418
|
expect(full).toContain("white-space: nowrap");
|
|
1362
1419
|
expect(full).toContain("text-overflow: ellipsis");
|
|
1363
1420
|
});
|
|
1364
1421
|
|
|
1365
|
-
it("
|
|
1422
|
+
it("shows the meta line only where its meta is visible", () => {
|
|
1366
1423
|
// A lead line is hidden below the second cutover, so a band whose ONLY meta is a lead line
|
|
1367
|
-
// has nothing to show on a
|
|
1368
|
-
//
|
|
1369
|
-
//
|
|
1370
|
-
//
|
|
1371
|
-
// their row everywhere; the lead-line kind earns it only where the lead line is shown.
|
|
1424
|
+
// has nothing to show on a meta line there. An empty flex item with a full-line basis is
|
|
1425
|
+
// still a line, with the band's gap above it -- the same defect the grid version had as an
|
|
1426
|
+
// empty row: measured below the first cutover, a lone title 6.8px off the band's centre.
|
|
1427
|
+
// Badges are visible everywhere; the lead-line kind's group leaves flow until it is shown.
|
|
1372
1428
|
const base = layerBody("terp.base");
|
|
1373
1429
|
const always = baseOnly(base);
|
|
1374
|
-
const wide = mediaBodies(base, WIDE_VIEWPORT_QUERY);
|
|
1375
|
-
const narrow = mediaBodies(base, NARROW_VIEWPORT);
|
|
1376
1430
|
const roomy = mediaBodies(base, ROOMY_VIEWPORT_QUERY);
|
|
1377
|
-
const badges = '[data-terp="page-header"][data-has-meta="badges"]';
|
|
1378
|
-
const lead = '[data-terp="page-header"][data-has-meta="description"]';
|
|
1379
|
-
|
|
1380
|
-
expect(wide, "badges keep their row above the first cutover").toContain(`${badges} {`);
|
|
1381
|
-
expect(narrow, "and below it").toContain(`${badges} {`);
|
|
1382
|
-
expect(wide, "a lead line alone earns no row where it is hidden").not.toContain(lead);
|
|
1383
|
-
expect(narrow, "including below the first cutover").not.toContain(lead);
|
|
1384
|
-
expect(roomy, "the lead line's row comes back with the lead line").toContain(`${lead} {`);
|
|
1385
|
-
|
|
1386
|
-
// The empty group has to leave flow, not just sit empty: its grid-area names an area the
|
|
1387
|
-
// one-row template lacks, and an item placed into a missing named area gets implicit lines.
|
|
1388
|
-
expect(
|
|
1389
|
-
declaresRuleFor(always, `${lead} [data-terp="page-meta"]`),
|
|
1390
|
-
"the lead-line group is out of flow wherever the lead line is",
|
|
1391
|
-
).toBe(true);
|
|
1392
1431
|
expect(always).toMatch(
|
|
1393
1432
|
/\[data-has-meta="description"\] \[data-terp="page-meta"\] \{\s*display: none;/,
|
|
1394
1433
|
);
|
|
1395
1434
|
expect(roomy).toMatch(
|
|
1396
1435
|
/\[data-has-meta="description"\] \[data-terp="page-meta"\] \{\s*display: flex;/,
|
|
1397
1436
|
);
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
// above the second cutover for a lead line alone.
|
|
1401
|
-
expect(always.replace(/\s+/g, " ")).toContain(
|
|
1402
|
-
`[data-terp="page"]:not([data-measure="narrow"]) > ${badges} { padding-block: var(--space-1);`,
|
|
1403
|
-
);
|
|
1404
|
-
expect(always).not.toContain(`> ${lead} {`);
|
|
1405
|
-
expect(roomy.replace(/\s+/g, " ")).toContain(
|
|
1406
|
-
`[data-terp="page"]:not([data-measure="narrow"]) > ${lead} { padding-block: var(--space-1);`,
|
|
1437
|
+
expect(always, "badges need no rule: their group is always shown").not.toMatch(
|
|
1438
|
+
/\[data-has-meta="badges"\] \[data-terp="page-meta"\] \{\s*display: none;/,
|
|
1407
1439
|
);
|
|
1408
1440
|
});
|
|
1409
1441
|
|
|
@@ -2384,3 +2416,69 @@ describe("cascade structure", () => {
|
|
|
2384
2416
|
}
|
|
2385
2417
|
});
|
|
2386
2418
|
});
|
|
2419
|
+
|
|
2420
|
+
describe("what a review of the screens in use changed", () => {
|
|
2421
|
+
const base = layerBody("terp.base");
|
|
2422
|
+
const always = baseOnly(base);
|
|
2423
|
+
const ruleBody = (body: string, selector: string) => {
|
|
2424
|
+
const match = [...body.matchAll(/([^{}]+)\{([^{}]*)\}/g)].find(
|
|
2425
|
+
(rule) => rule[1]!.trim().replace(/\s+/g, " ") === selector,
|
|
2426
|
+
);
|
|
2427
|
+
expect(match, `${selector} has no rule of its own`).toBeDefined();
|
|
2428
|
+
return match![2]!;
|
|
2429
|
+
};
|
|
2430
|
+
|
|
2431
|
+
it("lays a tab strip out as one line that scrolls, never a wrap", () => {
|
|
2432
|
+
for (const selector of ['[data-terp="tab-list"]', '[data-terp="module-nav-list"]']) {
|
|
2433
|
+
const rule = ruleBody(always, selector);
|
|
2434
|
+
// Mutation: flex-wrap back to wrap, which splits the strip and its rule apart on a phone.
|
|
2435
|
+
expect(rule, selector).toContain("flex-wrap: nowrap");
|
|
2436
|
+
expect(rule, selector).toContain("overflow-x: auto");
|
|
2437
|
+
// The focus ring's room inside the scroll container, given back outside it.
|
|
2438
|
+
expect(rule, selector).toContain("padding: var(--space-1)");
|
|
2439
|
+
expect(rule, selector).toContain("margin: calc(-1 * var(--space-1))");
|
|
2440
|
+
}
|
|
2441
|
+
// The tab strip's rule is drawn inside its content box: a border would be clipped by the
|
|
2442
|
+
// scroll container, and the selected tab's edge with it.
|
|
2443
|
+
const tabList = ruleBody(always, '[data-terp="tab-list"]');
|
|
2444
|
+
expect(tabList).not.toContain("border-block-end");
|
|
2445
|
+
expect(tabList).toContain("linear-gradient(var(--color-neutral-200), var(--color-neutral-200))");
|
|
2446
|
+
expect(ruleBody(always, '[data-terp="tab"]')).not.toContain("margin-block-end: -1px");
|
|
2447
|
+
expect(ruleBody(always, '[data-terp="module-nav-link"]')).toContain("white-space: nowrap");
|
|
2448
|
+
});
|
|
2449
|
+
|
|
2450
|
+
it("lets a badge wrap inside its container, and keeps one line a pill", () => {
|
|
2451
|
+
const badge = ruleBody(always, '[data-terp="badge"]');
|
|
2452
|
+
// Mutation: nowrap back, or no cap, which let a long label run out of a phone's column.
|
|
2453
|
+
expect(badge).not.toContain("white-space: nowrap");
|
|
2454
|
+
expect(badge).toContain("max-inline-size: 100%");
|
|
2455
|
+
// A radius above half a one-line badge's height clamps to a full round; a full radius
|
|
2456
|
+
// would make a two-line badge a lozenge.
|
|
2457
|
+
expect(badge).toContain("border-radius: var(--radius-lg)");
|
|
2458
|
+
});
|
|
2459
|
+
|
|
2460
|
+
it("breaks a badge inside a word only when the word alone does not fit", () => {
|
|
2461
|
+
const badge = ruleBody(always, '[data-terp="badge"]');
|
|
2462
|
+
// Measured in Chromium: with `anywhere` a badge's narrowest width is one glyph, so a
|
|
2463
|
+
// squeezed auto-layout table split "Cancelled" mid-word into a 43x56 box; with
|
|
2464
|
+
// break-word on an inline block it stays the 75x23 pill. An inline flex keeps the
|
|
2465
|
+
// longest word too, but no longer breaks a single word wider than its column.
|
|
2466
|
+
expect(badge).toContain("overflow-wrap: break-word");
|
|
2467
|
+
expect(badge).toContain("display: inline-block");
|
|
2468
|
+
expect(badge).not.toContain("anywhere");
|
|
2469
|
+
});
|
|
2470
|
+
|
|
2471
|
+
it("closes up a band's rows of figures on a narrow screen, two to a line still", () => {
|
|
2472
|
+
const narrow = mediaBodies(base, NARROW_VIEWPORT);
|
|
2473
|
+
const group = ruleBody(narrow, '[data-terp="stat-group"]');
|
|
2474
|
+
// Mutations: the full gap kept between rows on a phone, or the band's full padding.
|
|
2475
|
+
expect(group).toContain("row-gap: var(--space-2)");
|
|
2476
|
+
expect(ruleBody(narrow, '[data-terp="page-summary"]')).toContain("padding-block: var(--space-3)");
|
|
2477
|
+
// Two to a line stays: a third column broke a figure like "4 m 12 s" over two lines.
|
|
2478
|
+
// Mutation: a narrower floor for the phone.
|
|
2479
|
+
expect(group).not.toContain("grid-template-columns");
|
|
2480
|
+
expect(ruleBody(always, '[data-terp="stat-group"]')).toContain(
|
|
2481
|
+
"grid-template-columns: repeat(auto-fit, minmax(min(9.5rem, 100%), 1fr))",
|
|
2482
|
+
);
|
|
2483
|
+
});
|
|
2484
|
+
});
|