@terpjs/react-core 0.16.0 → 0.18.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.
@@ -99,6 +99,7 @@ export const LAYOUT_CONTRACTS: Readonly<Record<string, LayoutContractSpec>> = {
99
99
  DetailPage: {
100
100
  components: {
101
101
  DetailList: "detail-list",
102
+ DetailListGroup: "detail-list-group",
102
103
  Stack: "stack",
103
104
  Tabs: "tabs",
104
105
  ModuleNav: "module-nav",
@@ -132,6 +132,7 @@ const MARKERS = [
132
132
  "dataview-toolbar-spacer",
133
133
  "dataview-toolbar-status",
134
134
  "detail-list",
135
+ "detail-list-group",
135
136
  "detail-list-row",
136
137
  "detail-list-term",
137
138
  "detail-list-value",
@@ -140,6 +141,9 @@ const MARKERS = [
140
141
  "dialog-body",
141
142
  "dialog-description",
142
143
  "dialog-title",
144
+ "disclosure",
145
+ "disclosure-panel",
146
+ "disclosure-toggle",
143
147
  "divider",
144
148
  "drawer-focus-end",
145
149
  "drawer-focus-start",
@@ -464,6 +464,26 @@ describe("cascade structure", () => {
464
464
  expect(chrome, "the band is what separates chrome from content").toContain(
465
465
  "border-block-end: 1px solid var(--color-neutral-200)",
466
466
  );
467
+ // The block padding, and it has to be the same VALUE in both chrome rows rather than the
468
+ // same intention. A min-height is only a height while nothing legal can beat it, and
469
+ // var(--space-2) did not clear that bar: a 2.25rem control plus 8px of padding plus the
470
+ // 1px border is 53px against a floor of 48, so the app header (which always carries its
471
+ // toggle) was 53px, a band with an action button was 53px, and a band with only a title
472
+ // was 48px — the one row whose whole promise is that it matches the header above it,
473
+ // changing height per page.
474
+ //
475
+ // Zero, not a step: var(--space-1) leaves 39px of content box, which clears the 2.25rem
476
+ // control and not the 2.75rem one this package also ships, so a band with a large action
477
+ // button measured 53px again. Both rows spend the same value, and the resolved heights are
478
+ // pinned in the computed lane against the largest control there is; what belongs here is
479
+ // that neither row can move its padding without the other.
480
+ expect(chrome, "the band's block padding is the app header's").toContain(
481
+ "padding-block: var(--space-0)",
482
+ );
483
+ expect(
484
+ bodyFor('[data-terp="appshell-header"]'),
485
+ "both chrome rows spend the same block padding under the floor they share",
486
+ ).toContain("padding: var(--space-0) var(--shell-gutter)");
467
487
  expect(
468
488
  /padding-inline|padding:/.test(chrome),
469
489
  "an inline pad with no bleed would inset the band from the body beneath it",
@@ -860,7 +880,10 @@ describe("cascade structure", () => {
860
880
  '[data-terp="detail-list"][data-columns="2"]',
861
881
  '[data-terp="detail-list"][data-layout="aligned"]',
862
882
  '[data-terp="detail-list"][data-layout="aligned"][data-columns="2"]',
863
- '[data-terp="detail-list"][data-layout="aligned"] [data-terp="detail-list-row"]',
883
+ '[data-terp="detail-list"][data-layout="aligned"] [data-terp="detail-list-row"]:not([data-full="true"])',
884
+ // The group's subgrid is a property of the shared column, so it belongs to the width at
885
+ // which there IS one.
886
+ '[data-terp="detail-list-group"] > [data-terp="detail-list"][data-layout="aligned"]:not([data-columns])',
864
887
  ]) {
865
888
  expect(
866
889
  declaresRuleFor(wide, selector),
@@ -963,6 +986,174 @@ describe("cascade structure", () => {
963
986
  expect(base.slice(headerAt, base.indexOf("}", headerAt))).toContain("align-items: center");
964
987
  });
965
988
 
989
+ it("gives the breadcrumb trail one line box, leaf included", () => {
990
+ // The trail is a row of items that get CENTRED, so two line heights in it are two
991
+ // baselines. The leaf declared 1.3 while its ancestors inherited `normal`: measured at
992
+ // font-size-sm, a 19.00px ancestor line box against an 18.19px leaf, which left the
993
+ // page's own title 0.59px above the crumb it hangs off with the chevron centred on a
994
+ // third line. One declaration on the trail, inherited by every crumb and by the h1, is
995
+ // what makes the row share a baseline.
996
+ //
997
+ // The published step rather than a bare literal, and that is the second half of the fix
998
+ // rather than house style: `normal` is the FONT's metric, so the mismatch was as big as
999
+ // the app's typeface said it was, and an app on a webfont with taller natural leading got
1000
+ // a worse one than the system stack this was measured in.
1001
+ const base = layerBody("terp.base");
1002
+ const trail = base.slice(base.indexOf('[data-terp="breadcrumbs"] {'));
1003
+ expect(
1004
+ trail.slice(0, trail.indexOf("}")),
1005
+ "the trail declares the line box every crumb shares",
1006
+ ).toContain("line-height: var(--font-line-height-snug)");
1007
+ const leafAt = base.indexOf('[data-terp="page-title"] {');
1008
+ expect(leafAt, "the trail's leaf should have a rule").toBeGreaterThan(-1);
1009
+ expect(
1010
+ base.slice(leafAt, base.indexOf("}", leafAt)),
1011
+ "the leaf takes the trail's line box; a second value here is the misalignment",
1012
+ ).not.toContain("line-height");
1013
+ });
1014
+
1015
+ it("spans a full row across every track, and makes it a box that can", () => {
1016
+ // Two halves, and the second is the one that is easy to miss: a display: contents box
1017
+ // generates no box, so grid-column on it is DROPPED and the span silently does not happen.
1018
+ // The aligned row is a contents box above the cutover, so the full row has to become a
1019
+ // block again there — which also gives it the label-above-value reading, the same pair's
1020
+ // narrow shape.
1021
+ const base = layerBody("terp.base");
1022
+ // Anchored on the newline, because the wide block's rule ENDS with the same selector and
1023
+ // an unanchored search finds that one first — which is how this test first passed while
1024
+ // reading the wrong rule.
1025
+ const spanAt = base.indexOf('\n[data-terp="detail-list-row"][data-full="true"] {');
1026
+ expect(spanAt, "the full row should have a span rule").toBeGreaterThan(-1);
1027
+ expect(
1028
+ base.slice(spanAt, base.indexOf("}", spanAt)),
1029
+ "1 / -1, so the row need not know how many tracks the list has",
1030
+ ).toContain("grid-column: 1 / -1");
1031
+ // And the invariant that makes the span reach it: NO rule may turn a full row into a
1032
+ // display: contents box. Asserted over every such rule in the sheet rather than against
1033
+ // the two that exist, because the failure is silent and specificity-shaped — the first
1034
+ // version un-contents-ed the full row in a rule of its own, which tied with the auto
1035
+ // list's contents rule and lost to source order, so `full` did nothing in an auto list at
1036
+ // any width. An exclusion in the selector cannot lose that way; a third contents rule
1037
+ // added without one fails here.
1038
+ const contentsRules = [...base.matchAll(/([^{}]*detail-list-row[^{}]*)\{([^{}]*)\}/g)].filter(
1039
+ ([, , body]) => /display:\s*contents/.test(body!),
1040
+ );
1041
+ expect(contentsRules.length, "the sheet should have contents rules to check").toBeGreaterThan(
1042
+ 0,
1043
+ );
1044
+ for (const [, selector] of contentsRules) {
1045
+ expect(
1046
+ selector!.includes(':not([data-full="true"])'),
1047
+ `${selector!.trim()} would make a full row a contents box, which drops its span`,
1048
+ ).toBe(true);
1049
+ }
1050
+ });
1051
+
1052
+ it("floors both tracks of an auto pair, and caps each at a share of the container", () => {
1053
+ // The two failures this rule is shaped by, both measured rather than reasoned:
1054
+ //
1055
+ // A ZERO FLOOR makes an auto-fit repetition count unbounded — 35 pair repetitions with 31
1056
+ // collapsed to 0px, every pair on one row — so `auto` is the one place in this component
1057
+ // where a track may not be floored at zero. Hence a rem floor per track.
1058
+ //
1059
+ // A 100% CAP IS NOT ENOUGH FOR A PAIR. Grid's floor is min(16rem, 100%) because one track
1060
+ // wider than its container overflows it; two tracks at 100% each can sum to 200%, and the
1061
+ // list scrolled sideways in a narrow panel. The percentage shares are what keep one pair
1062
+ // inside one container, so they must stay strictly under 100% between them.
1063
+ const base = layerBody("terp.base");
1064
+ const at = base.indexOf('[data-terp="detail-list"][data-layout="aligned"][data-columns="auto"] {');
1065
+ expect(at, "aligned auto should have its own track list").toBeGreaterThan(-1);
1066
+ const body = base.slice(at, base.indexOf("}", at));
1067
+ const floors = [...body.matchAll(/min\((\d+)rem, (\d+)%\)/g)].map((match) => ({
1068
+ rem: Number(match[1]),
1069
+ share: Number(match[2]),
1070
+ }));
1071
+ expect(floors, "both tracks of the pair carry a floor").toHaveLength(2);
1072
+ expect(
1073
+ floors.every((floor) => floor.rem > 0),
1074
+ "a zero floor makes the repetition count unbounded",
1075
+ ).toBe(true);
1076
+ expect(
1077
+ floors.reduce((sum, floor) => sum + floor.share, 0),
1078
+ "the shares must leave room for the gap, or one pair overflows its container",
1079
+ ).toBeLessThan(100);
1080
+ // The layouts with no label column repeat ONE track, and at Grid's own floor, so a stacked
1081
+ // auto list and a grid of cards break at the same width by construction.
1082
+ const plainAt = base.indexOf('[data-terp="detail-list"][data-columns="auto"] {');
1083
+ expect(plainAt, "auto should have a no-label-column track list too").toBeGreaterThan(-1);
1084
+ expect(base.slice(plainAt, base.indexOf("}", plainAt))).toContain(
1085
+ "repeat(auto-fit, minmax(min(16rem, 100%), 1fr))",
1086
+ );
1087
+ // And the shared column for an auto list is declared at EVERY width, unlike the closed
1088
+ // counts': the cutover is what `auto` exists to not need.
1089
+ const rowAt = base.indexOf(
1090
+ '[data-terp="detail-list"][data-layout="aligned"][data-columns="auto"]\n [data-terp="detail-list-row"]',
1091
+ );
1092
+ expect(rowAt, "the auto row rule should exist").toBeGreaterThan(-1);
1093
+ const wideAt = base.indexOf("@media not all and (max-width: 768px)");
1094
+ expect(
1095
+ rowAt > wideAt && rowAt > base.indexOf("}", base.indexOf('[data-terp="detail-list"] {')),
1096
+ "the auto row rule belongs outside the wide block, at every width",
1097
+ ).toBe(true);
1098
+ });
1099
+
1100
+ it("gives the group the aligned track list verbatim, gutter included", () => {
1101
+ // A subgrid takes the PARENT's tracks and the parent's gutter along the axis it subgrids,
1102
+ // so these two declarations are one measure written twice — and a group whose tracks
1103
+ // disagreed with aligned's would line its lists up with each other and with nothing else
1104
+ // on the card. Compared rather than described, because the failure is invisible until two
1105
+ // cards are side by side.
1106
+ const base = layerBody("terp.base");
1107
+ const alignedAt = base.indexOf('[data-terp="detail-list"][data-layout="aligned"] {');
1108
+ const aligned = base.slice(alignedAt, base.indexOf("}", alignedAt));
1109
+ const groupAt = base.indexOf('[data-terp="detail-list-group"] {');
1110
+ expect(groupAt, "the group should have a base rule").toBeGreaterThan(-1);
1111
+ const group = base.slice(groupAt, base.indexOf("}", groupAt));
1112
+ const tracks = (body: string) => /grid-template-columns:\s*([^;]+);/.exec(body)?.[1]?.trim();
1113
+ const columnGap = (body: string) => /column-gap:\s*([^;]+);/.exec(body)?.[1]?.trim();
1114
+ expect(tracks(aligned), "aligned declares the shared track list").toBeTruthy();
1115
+ expect(tracks(group), "the group shares aligned's track list").toBe(tracks(aligned));
1116
+ expect(columnGap(group), "and its gutter, which the subgrid inherits").toBe(
1117
+ columnGap(aligned),
1118
+ );
1119
+ // Every child spans the group, or a subgridded list would occupy one track and its values
1120
+ // would land in the label column.
1121
+ const childAt = base.indexOf('[data-terp="detail-list-group"] > * {');
1122
+ expect(childAt, "the group's children should span it").toBeGreaterThan(-1);
1123
+ expect(base.slice(childAt, base.indexOf("}", childAt))).toContain("grid-column: 1 / -1");
1124
+ // And both of the group's rules reach its OWN children only. The child combinator looks
1125
+ // like a tightening that could be relaxed and is the opposite: subgrid needs the element to
1126
+ // be a grid item of the box owning the tracks, so as a descendant selector this would reach
1127
+ // a list nested in a Stack, compute to `none` for want of a parent grid, and take that
1128
+ // list's own label column with it. Not sharing is the correct outcome for a nested list;
1129
+ // losing its tracks is not.
1130
+ // Whitespace-normalised, because a selector this long is wrapped in the sheet and the
1131
+ // wrapping is not the contract.
1132
+ const flat = base.replace(/\s+/g, " ");
1133
+ for (const rule of [
1134
+ '[data-terp="detail-list-group"] > *',
1135
+ '[data-terp="detail-list-group"] > [data-terp="detail-list"][data-layout="aligned"]:not([data-columns])',
1136
+ ]) {
1137
+ expect(
1138
+ flat.includes(rule),
1139
+ `${rule} must stay a child combinator: subgrid on a nested list computes to none`,
1140
+ ).toBe(true);
1141
+ }
1142
+ // The group's gap is a row gap at every step, for the list's own reason: the column gap is
1143
+ // the shared measure and is not a caller's to move.
1144
+ for (const token of [0, 1, 2, 3, 4, 6, 8]) {
1145
+ const stepAt = base.indexOf(`[data-terp="detail-list-group"][data-gap="${token}"]`);
1146
+ expect(stepAt, `the group has no rule for gap ${token}`).toBeGreaterThan(-1);
1147
+ const step = base.slice(stepAt, base.indexOf("}", stepAt));
1148
+ expect(step, `gap ${token} must set the row gap only`).toContain(
1149
+ `row-gap: var(--space-${token})`,
1150
+ );
1151
+ expect(/[^-]column-gap|^column-gap/.test(step), `gap ${token} must not touch the columns`).toBe(
1152
+ false,
1153
+ );
1154
+ }
1155
+ });
1156
+
966
1157
  it("gives the page title, a card title and body copy three different steps", () => {
967
1158
  // The scale was flat: the single h1 of a view rendered at lg (18px) against a card title at
968
1159
  // base (16px) against 16px prose — one step from the h1 to a section heading, and a section
@@ -1255,12 +1446,18 @@ describe("cascade structure", () => {
1255
1446
  // and each of the six set cursor inline until it migrated. The day a calendar arrow gains
1256
1447
  // a min/max bound, this answer changes back.
1257
1448
  '[data-terp="iconbutton"]:disabled',
1258
- // HubPage was the condition for both of these, and it was the condition in the strongest
1259
- // form: hubcard-body's border and hubcard-title's colour were declared inline on the very
1260
- // elements these selectors match, so no layered rule could reach them at any specificity.
1261
- // Both surfaces come from terp.base now.
1449
+ // HubPage was the condition for this one, and it was the condition in the strongest
1450
+ // form: hubcard-body's border was declared inline on the very element this selector
1451
+ // matches, so no layered rule could reach it at any specificity. That surface comes from
1452
+ // terp.base now.
1453
+ //
1454
+ // Its twin was here until the hub card's hover state came down to the edge alone. The
1455
+ // title's accent colour faced the same inline declaration and retired the same way, so it
1456
+ // belonged in this list on the same evidence — but the selector itself is gone now, and a
1457
+ // rule that does not exist cannot witness anything. Dropping it costs no coverage: the
1458
+ // escalation it stood for retired for a reason this list still records once, in the entry
1459
+ // above, since both halves faced the same inline consumer in the same file.
1262
1460
  '[data-terp="hubcard"]:hover [data-terp="hubcard-body"]',
1263
- '[data-terp="hubcard"]:hover [data-terp="hubcard-title"]',
1264
1461
  // AppShell's, and it blocked these two on its own: toggleStyle declared background and
1265
1462
  // colour inline on the shell's two toggles, the last elements wearing the icon-button
1266
1463
  // marker able to out-rank a layered rule. Their resting look is a scoped base rule now,
@@ -1525,6 +1722,7 @@ describe("cascade structure", () => {
1525
1722
  "splitpage-panes",
1526
1723
  "splitpane",
1527
1724
  "detail-list",
1725
+ "detail-list-group",
1528
1726
  "combobox",
1529
1727
  "combobox-list",
1530
1728
  "combobox-option",