@terpjs/react-core 0.24.0 → 0.27.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/src/styles.ts CHANGED
@@ -103,7 +103,7 @@
103
103
  * touched.
104
104
  */
105
105
 
106
- import { ROOMY_VIEWPORT_QUERY, WIDE_VIEWPORT_QUERY } from "./breakpoints";
106
+ import { NARROW_VIEWPORT, ROOMY_VIEWPORT_QUERY, WIDE_VIEWPORT_QUERY } from "./breakpoints";
107
107
 
108
108
  /** The `<style>` element id used to detect a prior injection. */
109
109
  export const TERP_STYLES_ID = "terp-core-styles";
@@ -569,10 +569,11 @@ textarea[data-terp="input"] {
569
569
  two halves of the cutover partition the viewport by construction. Written out here they
570
570
  would be two literals that agree until someone edits one.
571
571
 
572
- There are TWO \${…} in this sheet now, one per cutover — this one and the page band's
573
- ROOMY block. Both come from ./breakpoints and neither spells a number, which is the
574
- property worth grepping for: a third interpolation is fine if it names a constant from
575
- that module, and a literal pixel width in a media query here is not. */
572
+ There are FOUR \${…} in this sheet now: this one, the page band's ROOMY block, and the
573
+ two halves of the band's own cutover (its WIDE two-row form and its NARROW single
574
+ column). Every one of them comes from ./breakpoints and none spells a number, which is
575
+ the property worth grepping for: a further interpolation is fine if it names a constant
576
+ from that module, and a literal pixel width in a media query here is not. */
576
577
  @media ${WIDE_VIEWPORT_QUERY} {
577
578
  [data-terp="stack"][data-direction-wide="column"] { flex-direction: column; }
578
579
  [data-terp="stack"][data-direction-wide="row"] { flex-direction: row; }
@@ -2015,12 +2016,22 @@ textarea[data-terp="input"] {
2015
2016
  gap: var(--space-2) var(--space-4);
2016
2017
  min-width: 0;
2017
2018
  }
2018
- /* The two-row band, and it costs nothing to the pages that get it. A page with badges or a
2019
- lead line ALREADY spends a second row on them; putting the action cluster there too fills
2020
- space that was empty, and it buys the trail the whole of the first row -- which is what
2021
- stops a deep trail having to truncate at all. A page with neither keeps the single row,
2022
- and with it the promise the chrome is measured against: the band matches the app header
2023
- above it.
2019
+ /* The two-row band. It used to move the action cluster onto the meta row at every width, on
2020
+ the reasoning that a page with badges or a lead line ALREADY spends a second row, so the
2021
+ cluster joining them costs no height and buys the trail the whole first row.
2022
+
2023
+ The second half of that was never true, because the rule that gave the trail the first row
2024
+ never matched (see the trail's own rule below). So the cluster was paying the whole price
2025
+ and the trail collected none of it: measured on a 1280px viewport, an ordinary detail page
2026
+ -- two crumbs, one badge, one button -- put the button on line two with 1028px of empty
2027
+ room beside the trail on line one. That is what "the button wraps before the breadcrumb is
2028
+ long" turns out to be, and it is width-independent: the same at 1440.
2029
+
2030
+ So the cluster keeps its place beside the trail and the meta group takes the row below it,
2031
+ which is also what the one-row band does and therefore one rule for where a page's actions
2032
+ live rather than two. Below the first cutover the band becomes a single column instead --
2033
+ there the cluster genuinely cannot share a line with the title, and the row it used to take
2034
+ from the trail was squeezing the h1 to nothing.
2024
2035
 
2025
2036
  A grid rather than the flex-wrap this was: wrap order follows source order, so the meta
2026
2037
  group and the cluster could not share a row while staying two groups, and the moment the
@@ -2029,15 +2040,67 @@ textarea[data-terp="input"] {
2029
2040
  whose whole job was to right-align it. Areas say where things go and no free space is
2030
2041
  distributed anywhere, so neither failure has anywhere to happen. */
2031
2042
  [data-terp="page-header"][data-has-meta] {
2032
- grid-template-areas:
2033
- "trail trail"
2034
- "meta actions";
2035
- /* Same-height lines, and 1fr is what spells that in a box whose height nobody declared:
2036
- with an indefinite container the fr rows resolve to the LARGEST row's content rather
2037
- than to a share of a height that does not exist, so both rows come out at the taller
2038
- one. A band of two content-sized rows would otherwise be a short trail line above a
2039
- tall control line, which reads as two different bands rather than one of two lines. */
2040
- grid-auto-rows: 1fr;
2043
+ /* auto, not 1fr. Equal-height lines read as one band of two lines, which is why they were
2044
+ here -- but fr rows in an indefinite container resolve to the LARGEST row's content, so
2045
+ the shorter line's item was centred in a track sized by the taller one and the taller
2046
+ line's item filled its track exactly. With no block padding under it (the chrome row
2047
+ spends none, by the invariant below) that put the bottom row flush against the band's
2048
+ border: measured 9px above the content and 0px below it on every two-row page. Rows sized
2049
+ to their content, plus the padding the multi-row band now spends, give 4px and 4px. */
2050
+ grid-auto-rows: auto;
2051
+ }
2052
+ @media ${WIDE_VIEWPORT_QUERY} {
2053
+ [data-terp="page-header"][data-has-meta] {
2054
+ grid-template-areas:
2055
+ "trail actions"
2056
+ "meta meta";
2057
+ }
2058
+ }
2059
+ /* Below the first cutover the band is one column and nothing competes for a line. The trail
2060
+ keeps the leaf and one ancestor: every crumb carries min-width: 0 and an ellipsis while the
2061
+ separators are flex: 0 0 auto, so a trail with no room does not degrade to short labels --
2062
+ it degrades to a row of bare chevrons with the h1 among the casualties. Measured at 360px
2063
+ on a six-crumb page: six labels under 8px, no page title on screen at all, and the cluster
2064
+ overlapping the badges by 24px. Dropping the ancestors takes their separators with them,
2065
+ which is the only degradation here that leaves something readable.
2066
+
2067
+ The actions row is declared only when there IS a cluster -- :has() for the same reason
2068
+ card-header and control-label use it, that the alternative is an attribute the component
2069
+ would have to stamp. A named row with nothing in it is still a row, and with the band's
2070
+ gap under it that is 8px of empty space wedged under the trail on every page that has no
2071
+ actions. */
2072
+ @media ${NARROW_VIEWPORT} {
2073
+ [data-terp="page-header"] {
2074
+ grid-template-columns: minmax(0, 1fr);
2075
+ grid-template-areas: "trail";
2076
+ }
2077
+ [data-terp="page-header"]:has(> [data-terp="page-actions"]) {
2078
+ grid-template-areas:
2079
+ "trail"
2080
+ "actions";
2081
+ }
2082
+ /* Written AFTER the :has() rule and not before it: the two selectors tie at (0,2,0), so
2083
+ source order is what decides a page that carries meta and no cluster, and it belongs to
2084
+ this one. The combined selector below outranks both at (0,3,0). */
2085
+ [data-terp="page-header"][data-has-meta] {
2086
+ grid-template-areas:
2087
+ "trail"
2088
+ "meta";
2089
+ }
2090
+ [data-terp="page-header"][data-has-meta]:has(> [data-terp="page-actions"]) {
2091
+ grid-template-areas:
2092
+ "trail"
2093
+ "meta"
2094
+ "actions";
2095
+ }
2096
+ [data-terp="breadcrumbs"] li:not(:last-child):not(:nth-last-child(2)) {
2097
+ display: none;
2098
+ }
2099
+ [data-terp="breadcrumbs"] li:nth-last-child(2):not(:first-child)::before {
2100
+ content: "…";
2101
+ margin-inline-end: var(--space-2);
2102
+ color: var(--color-neutral-600);
2103
+ }
2041
2104
  }
2042
2105
  /* The band's left group, and it generates NO box. The trail and the meta group have to be
2043
2106
  grid items of the band itself -- they sit on different rows -- but the marker is published
@@ -2053,8 +2116,16 @@ textarea[data-terp="input"] {
2053
2116
  [data-terp="page-heading"] {
2054
2117
  display: contents;
2055
2118
  }
2056
- /* The trail owns the first row outright once there is a second one to own. */
2057
- [data-terp="page-header"] > [data-terp="breadcrumbs"] {
2119
+ /* The trail's placement, and the combinator is the whole of it. This was a CHILD selector,
2120
+ and the trail is not a child of the band: Page renders it inside page-heading, which is
2121
+ display: contents. That removes the BOX and not the node, and selectors match the tree, so
2122
+ the rule matched nothing at all and the trail was auto-placed with its automatic minimum
2123
+ intact. Both halves below were therefore dead from the day the heading group arrived, and
2124
+ the two-row band above was justified by a benefit this rule was supposed to deliver.
2125
+
2126
+ Descendant, not child, and scoped to the band: page-header holds the heading group and the
2127
+ cluster and nothing else, so there is no second trail here to catch by accident. */
2128
+ [data-terp="page-header"] [data-terp="breadcrumbs"] {
2058
2129
  grid-area: trail;
2059
2130
  min-width: 0;
2060
2131
  }
@@ -2171,6 +2242,26 @@ textarea[data-terp="input"] {
2171
2242
  box-sizing: border-box;
2172
2243
  border-block-end: 1px solid var(--color-neutral-200);
2173
2244
  }
2245
+ /* The block padding the ONE-ROW band cannot have, spent on the bands that are already more
2246
+ than one row. The rule above stays at var(--space-0) and stays tied to the app header's
2247
+ own padding, because that row is the one making the claim: 48px, the same as the header
2248
+ above it, and the largest control this package ships (2.75rem) has to fit inside it. A band
2249
+ that carries meta has broken that height already and makes no such claim, so it can afford
2250
+ the 4px — and it is the only band where the missing padding was ever visible, since the
2251
+ one-row band centres its single line inside the floor and reads as padded either way.
2252
+ Below the cutover the same is true of a band whose cluster has taken a row of its own.
2253
+
2254
+ The narrow rule weighs (0,3,0) plus :has()'s argument, so (0,4,0) — the same as the meta
2255
+ rule, and they declare the same value, so the tie decides nothing. */
2256
+ [data-terp="page"]:not([data-measure="narrow"]) > [data-terp="page-header"][data-has-meta] {
2257
+ padding-block: var(--space-1);
2258
+ }
2259
+ @media ${NARROW_VIEWPORT} {
2260
+ [data-terp="page"]:not([data-measure="narrow"])
2261
+ > [data-terp="page-header"]:has(> [data-terp="page-actions"]) {
2262
+ padding-block: var(--space-1);
2263
+ }
2264
+ }
2174
2265
  /* The BLEED, which does need a shell, because the negative-margin idiom is only correct when
2175
2266
  the box being escaped is appshell-main and that box pads by exactly --shell-gutter. ADR
2176
2267
  0097 §2 kept "it works with no shell above it at all" as a property of the mechanism, and
@@ -4080,6 +4171,14 @@ button[data-terp="input"][data-placeholder="true"] {
4080
4171
  z-index: var(--z-index-toast);
4081
4172
  max-width: min(22.5rem, calc(100vw - 2 * var(--space-4)));
4082
4173
  }
4174
+ /* The font-family is declared here, and it is not decoration: this package sets the family
4175
+ per ROOT — on appshell and on login-view — and never on body, so a box outside both
4176
+ inherits the UA default and renders the platform's confirmations in a serif. The toast
4177
+ viewport is exactly that box. ToastProvider wraps the router rather than living inside a
4178
+ page, and a context provider emits no DOM, so the viewport is a SIBLING of appshell, not a
4179
+ descendant; position: fixed has nothing to do with it, since inheritance follows the tree
4180
+ and not the box. The portalled popover panel already carries this declaration for the same
4181
+ reason and says so; this is the one surface that escaped the shell without it. */
4083
4182
  [data-terp="toast"] {
4084
4183
  display: grid;
4085
4184
  grid-template-columns: auto 1fr auto;
@@ -4091,6 +4190,7 @@ button[data-terp="input"][data-placeholder="true"] {
4091
4190
  border-inline-start-width: 3px;
4092
4191
  background: var(--color-neutral-0);
4093
4192
  color: var(--color-neutral-900);
4193
+ font-family: var(--font-family-sans);
4094
4194
  font-size: var(--font-size-sm);
4095
4195
  box-shadow: var(--shadow-md);
4096
4196
  }
package/vite.config.ts CHANGED
@@ -18,14 +18,21 @@ export default defineConfig({
18
18
  // the setup file configured 3s, and a comment that misstates the code it explains is
19
19
  // worse than none.
20
20
  testTimeout: 15_000,
21
- // These tests contend for the machine rather than with each other, and losing that
22
- // contention is how they fail: four different fetch-bound assertions across four CI
23
- // runs, always one file of eighty-one, each passing on its own. Widening the async
24
- // budget was tried first and did not fix it (1s to 3s to 4s), and it has nowhere left
25
- // to go -- a toast's 5s lifetime is the ceiling. So remove the cause rather than the
26
- // tolerance: a jsdom + React + fetch file is heavy, a small runner has four vCPUs, and
27
- // eighty-one of them at once starve each other's timers. It costs wall clock and buys
28
- // a green that means something.
29
- fileParallelism: false,
21
+ // `fileParallelism: false` used to be here, and is deliberately gone. It was added
22
+ // against an intermittent "unable to find element" -- four different fetch-bound
23
+ // assertions across four CI runs, always one file of eighty-one, each passing on its
24
+ // own -- after widening the async budget had already failed to fix it (1s to 3s to 4s,
25
+ // vitest.setup.ts). A serial run did measurably help, which is why it looked like the
26
+ // answer. The actual cause was a structural race in four admin tests: they clicked a
27
+ // submit control that is disabled until an ambient fetch lands, having waited only on
28
+ // the page heading, so jsdom raised no submit event and the click was LOST rather than
29
+ // late. Serialising widened the odds of winning that race; it did not remove it.
30
+ //
31
+ // With the race removed (`enabledSubmitControl`, admin/admin.test.tsx), the suite was
32
+ // re-measured on a four-vCPU machine -- the class of runner the flag was added for --
33
+ // and ran green nine times out of nine in parallel, in ~33s against ~80s serial. So the
34
+ // wall clock is given back. If this suite starts failing intermittently again, do NOT
35
+ // reach for this flag or the async budget first: find out what the failing test is
36
+ // waiting on, and whether the thing it clicks can be clicked yet.
30
37
  },
31
38
  });
package/vitest.setup.ts CHANGED
@@ -7,31 +7,38 @@ import { configure } from "@testing-library/dom";
7
7
 
8
8
  // `findBy*` and `waitFor` default to a 1000ms budget, and the component tests spend it on
9
9
  // a path that is not a render: a mocked fetch resolving, then the state it sets, then the
10
- // re-render that finally puts the text on screen. One second is enough on an idle machine
11
- // and not on a loaded one, so the suite failed intermittently — five times across one day,
12
- // four different tests, every one passing alone and on a re-run, and one of them red in CI
13
- // on a branch whose own change was fine.
10
+ // re-render that finally puts the text on screen. One second does not reliably cover that,
11
+ // so the budget is raised. `testTimeout` (vite.config.ts) sits above it, so a matcher that
12
+ // cannot find its element loses first and says which element; equal budgets report an
13
+ // unhelpful "test timed out" instead.
14
14
  //
15
- // The budget is raised rather than the tests retried. A retry would hide a genuinely
16
- // intermittent product bug, and these assertions are not flaky in what they claim: the
17
- // text does appear, and a matcher that waits longer asserts exactly the same thing. What
18
- // it costs is that a test which SHOULD fail now takes longer to say so, which is why
19
- // `testTimeout` moves too — the matcher must lose before the test does, or the failure
20
- // arrives as an unhelpful "test timed out" instead of naming the element it could not find.
15
+ // READ THE HISTORY BELOW AS A TOLERANCE, NOT AS A DIAGNOSIS. This lever was raised twice
16
+ // (1s to 3s to 4s) against an intermittent "unable to find element" — five failures across
17
+ // one day, four different fetch-bound tests, always one file of eighty-one, each passing
18
+ // alone and on a re-run. Neither raise stopped it, and the cause is now known and removed:
19
+ // four admin tests held a structural race. They clicked a submit control that `UserCreate`
20
+ // disables until an ambient access-model fetch has landed AND the effect it feeds has run,
21
+ // having waited on nothing but the page heading — which renders before either. jsdom raises
22
+ // no submit event for a click on a disabled control, so the click was LOST, not late, and
23
+ // the failure surfaced several lines later on whatever was waiting for the POST's result.
24
+ // No budget can close that. Those tests now wait on the control being enabled
25
+ // (`enabledSubmitControl`, admin/admin.test.tsx), and the window itself is pinned by a
26
+ // dedicated test there.
21
27
  //
22
- // It has a CEILING, and the first attempt at this walked straight into it. A toast
28
+ // Contention is real and is a different thing: it widens the window such a race needs, and
29
+ // a serial run measurably helped (see vite.config.ts). But a test waiting on the wrong
30
+ // thing fails on an idle machine too, only more rarely. So before this lever is reached for
31
+ // a third time: check what the failing test is waiting on, and whether the thing it clicks
32
+ // can even be clicked yet.
33
+ //
34
+ // The budget has a CEILING, and the first attempt at this walked straight into it. A toast
23
35
  // auto-dismisses after `DEFAULT_DURATION_MS` (5s, toast.tsx), and several admin tests wait
24
36
  // for a field error and then assert the toast SYNCHRONOUSLY. Set the budget to 5s and a
25
37
  // wait that takes long enough outlives the toast the next line is about to look for — one
26
38
  // flake traded for another, and a worse one, because it looks like a product bug. So the
27
39
  // budget sits between the two: comfortably past a fetch and a re-render, comfortably short
28
- // of a toast's life. `async-budget.test.ts` holds both ends.
29
- //
30
- // Raised from 3s to 4s on 2026-09-08: 3s was still not enough under CI load. Two
31
- // consecutive runs failed on two different fetch-bound tests, and main failed a third
32
- // time in the same window -- always "unable to find element", always one file of
33
- // eighty-one. 4s keeps a full second below the toast, which is the last of the
34
- // headroom this lever has: the next move is less contention, not a longer wait.
40
+ // of a toast's life. `async-budget.test.ts` holds the lower end, and
41
+ // `test_frontend_async_budget.py` the ordering across all three files.
35
42
  configure({ asyncUtilTimeout: 4_000 });
36
43
 
37
44
  // jsdom's File / Blob / FormData are structurally incompatible with Node's built-in