@terpjs/react-core 0.30.0 → 0.31.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/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 +341 -0
- package/src/Stat.tsx +314 -0
- package/src/Timeline.test.tsx +74 -0
- package/src/Timeline.tsx +71 -0
- package/src/admin/AdminHub.tsx +11 -3
- 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 +83 -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 +208 -5
- 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/dataview/DataView.test.tsx +255 -0
- package/src/dataview/DataView.tsx +35 -0
- package/src/dataview/DataViewCardList.tsx +21 -13
- package/src/dataview/DataViewTable.tsx +5 -6
- 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 +20 -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 +222 -190
- package/src/styles.ts +1268 -328
- 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/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 +76 -7
|
@@ -108,7 +108,7 @@ describe("resolveLayoutDeclaration", () => {
|
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
contract: "standard",
|
|
111
|
-
defaultTheme: "
|
|
111
|
+
defaultTheme: "evening",
|
|
112
112
|
density: "compact",
|
|
113
113
|
navPlacement: "header",
|
|
114
114
|
},
|
|
@@ -137,9 +137,30 @@ describe("resolveLayoutDeclaration", () => {
|
|
|
137
137
|
it("supplies the palette from the file, narrowed to the published list", () => {
|
|
138
138
|
// The point of the key: which palette an app opens on used to be reachable only by editing
|
|
139
139
|
// that app's own code, which put it out of reach of anything that edits files.
|
|
140
|
+
expect(resolveLayoutDeclaration({ defaultTheme: "night" }, {})).toEqual({
|
|
141
|
+
defaultTheme: "night",
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("accepts a palette's earlier name, and resolves it to the theme it now names", () => {
|
|
146
|
+
// The themes were renamed for the time of day they suit, and an app's checked-in file that
|
|
147
|
+
// says "dark" was written before that. Refusing it would break every such app on upgrade
|
|
148
|
+
// for a change that did not touch its palette: the sheet paints "dark" as evening, and the
|
|
149
|
+
// resolver hands the router the name the provider and the control use.
|
|
150
|
+
// Mutation: check against THEMES alone again, and the first line throws.
|
|
151
|
+
expect(resolveLayoutDeclaration({ defaultTheme: "dark" }, {})).toEqual({
|
|
152
|
+
defaultTheme: "evening",
|
|
153
|
+
});
|
|
140
154
|
expect(resolveLayoutDeclaration({ defaultTheme: "midnight" }, {})).toEqual({
|
|
141
|
-
defaultTheme: "
|
|
155
|
+
defaultTheme: "night",
|
|
156
|
+
});
|
|
157
|
+
expect(resolveLayoutDeclaration({ defaultTheme: "light" }, {})).toEqual({
|
|
158
|
+
defaultTheme: "midday",
|
|
142
159
|
});
|
|
160
|
+
// Own names only: a prototype key is not an earlier theme.
|
|
161
|
+
expect(() => resolveLayoutDeclaration({ defaultTheme: "constructor" }, {})).toThrow(
|
|
162
|
+
/"defaultTheme" is "constructor"/,
|
|
163
|
+
);
|
|
143
164
|
});
|
|
144
165
|
|
|
145
166
|
it("accepts every palette the framework publishes, and nothing else", () => {
|
|
@@ -166,11 +187,11 @@ describe("resolveLayoutDeclaration", () => {
|
|
|
166
187
|
defaultTheme: "system",
|
|
167
188
|
});
|
|
168
189
|
expect(() =>
|
|
169
|
-
resolveLayoutDeclaration({ defaultTheme: "system" }, { defaultTheme: "
|
|
170
|
-
).toThrow(/both declare "defaultTheme" \(file: "system", code: "
|
|
190
|
+
resolveLayoutDeclaration({ defaultTheme: "system" }, { defaultTheme: "evening" }),
|
|
191
|
+
).toThrow(/both declare "defaultTheme" \(file: "system", code: "evening"\)/);
|
|
171
192
|
// And an absent key does leave the option in force, which is the half that was true.
|
|
172
|
-
expect(resolveLayoutDeclaration({}, { defaultTheme: "
|
|
173
|
-
defaultTheme: "
|
|
193
|
+
expect(resolveLayoutDeclaration({}, { defaultTheme: "evening" })).toEqual({
|
|
194
|
+
defaultTheme: "evening",
|
|
174
195
|
});
|
|
175
196
|
});
|
|
176
197
|
|
|
@@ -180,16 +201,16 @@ describe("resolveLayoutDeclaration", () => {
|
|
|
180
201
|
// matches no block in the stylesheet, so the app renders the base palette and nothing
|
|
181
202
|
// anywhere reports that the file was ignored.
|
|
182
203
|
expect(() => resolveLayoutDeclaration({ defaultTheme: "midnite" }, {})).toThrow(
|
|
183
|
-
/"defaultTheme" is "midnite"; expected one of "
|
|
204
|
+
/"defaultTheme" is "midnite"; expected one of "midday", "twilight", "evening", "night", "contrast", "system" \(or an earlier name: "light", "dark", "midnight"\)/,
|
|
184
205
|
);
|
|
185
206
|
});
|
|
186
207
|
|
|
187
208
|
it("refuses the palette declared twice, like every other key", () => {
|
|
188
209
|
expect(() =>
|
|
189
|
-
resolveLayoutDeclaration({ defaultTheme: "
|
|
190
|
-
).toThrow(/"defaultTheme" \(file: "
|
|
210
|
+
resolveLayoutDeclaration({ defaultTheme: "night" }, { defaultTheme: "evening" }),
|
|
211
|
+
).toThrow(/"defaultTheme" \(file: "night", code: "evening"\)/);
|
|
191
212
|
expect(() =>
|
|
192
|
-
resolveLayoutDeclaration({ defaultTheme: "
|
|
213
|
+
resolveLayoutDeclaration({ defaultTheme: "evening" }, { defaultTheme: "evening" }),
|
|
193
214
|
).toThrow(/both declare/);
|
|
194
215
|
});
|
|
195
216
|
|
package/src/layoutDeclaration.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NavGroup } from "@terpjs/contract";
|
|
2
2
|
|
|
3
|
-
import { THEMES } from "./themes";
|
|
3
|
+
import { THEME_ALIASES, THEMES, resolveTheme } from "./themes";
|
|
4
4
|
import type { Theme } from "./themes";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -464,10 +464,15 @@ export function resolveLayoutDeclaration(
|
|
|
464
464
|
// outright: a fallback is how a declaration ends up doing nothing while looking like it
|
|
465
465
|
// works — `data-theme="midnite"` matches no block, so the app renders the base palette and
|
|
466
466
|
// nothing anywhere says the file was ignored.
|
|
467
|
-
|
|
467
|
+
//
|
|
468
|
+
// A name a theme HAD before the rename ("dark", "midnight", "light") is not unknown: it
|
|
469
|
+
// resolves to the theme it now names, as it does everywhere else a theme is named.
|
|
470
|
+
const theme = resolveTheme(declaration.defaultTheme);
|
|
471
|
+
if (theme === null) {
|
|
468
472
|
throw new Error(
|
|
469
473
|
`${FILE}: "defaultTheme" is "${declaration.defaultTheme}"; expected one of ` +
|
|
470
|
-
`${THEMES.map((
|
|
474
|
+
`${THEMES.map((name) => `"${name}"`).join(", ")} (or an earlier name: ` +
|
|
475
|
+
`${Object.keys(THEME_ALIASES).map((name) => `"${name}"`).join(", ")}).`,
|
|
471
476
|
);
|
|
472
477
|
}
|
|
473
478
|
if (explicit.defaultTheme !== undefined) {
|
|
@@ -475,7 +480,7 @@ export function resolveLayoutDeclaration(
|
|
|
475
480
|
`"defaultTheme" (file: "${declaration.defaultTheme}", code: "${explicit.defaultTheme}")`,
|
|
476
481
|
);
|
|
477
482
|
}
|
|
478
|
-
resolved.defaultTheme =
|
|
483
|
+
resolved.defaultTheme = theme;
|
|
479
484
|
}
|
|
480
485
|
|
|
481
486
|
const declaredBrand = shell.brand;
|
package/src/locale.tsx
CHANGED
|
@@ -218,6 +218,19 @@ export const LOCALE_NL: LocaleCatalog = {
|
|
|
218
218
|
breadcrumbsLabel: "Kruimelpad",
|
|
219
219
|
moduleNavigationLabel: "Modulenavigatie",
|
|
220
220
|
moreActions: "Meer acties",
|
|
221
|
+
pageSequencePrevious: "Vorige: {label}",
|
|
222
|
+
pageSequenceNext: "Volgende: {label}",
|
|
223
|
+
pageSequencePosition: "{current} van {total}",
|
|
224
|
+
statFavourable: "gunstig",
|
|
225
|
+
statUnfavourable: "ongunstig",
|
|
226
|
+
statTrend: "Verloop: {points}",
|
|
227
|
+
adminHubTotal: "Totaal",
|
|
228
|
+
statusHistoryRuns: "{label}, oudste eerst: {runs}",
|
|
229
|
+
recordHistory: "Geschiedenis",
|
|
230
|
+
auditActionCreated: "Aangemaakt",
|
|
231
|
+
auditActionUpdated: "Gewijzigd",
|
|
232
|
+
auditActionDeleted: "Verwijderd",
|
|
233
|
+
auditActionDisclosed: "Ingezien",
|
|
221
234
|
errorTitle: "Er is iets misgegaan.",
|
|
222
235
|
backendUnreachableTitle: "De applicatie kan de server niet bereiken.",
|
|
223
236
|
backendUnreachableDescription:
|
|
@@ -240,9 +253,9 @@ export const LOCALE_NL: LocaleCatalog = {
|
|
|
240
253
|
openNavigation: "Navigatie openen",
|
|
241
254
|
closeNavigation: "Navigatie sluiten",
|
|
242
255
|
theme: "Thema",
|
|
243
|
-
themeLight: "
|
|
244
|
-
themeDark: "
|
|
245
|
-
themeMidnight: "
|
|
256
|
+
themeLight: "Middag",
|
|
257
|
+
themeDark: "Avond",
|
|
258
|
+
themeMidnight: "Nacht",
|
|
246
259
|
themeTwilight: "Schemering",
|
|
247
260
|
themeContrast: "Hoog contrast",
|
|
248
261
|
themeSystem: "Systeem",
|
|
@@ -375,6 +388,10 @@ export const LOCALE_NL: LocaleCatalog = {
|
|
|
375
388
|
"Dit botst met de huidige stand van zaken. Vernieuw de pagina en probeer het opnieuw.",
|
|
376
389
|
errorCodeStaleData:
|
|
377
390
|
"Iemand anders heeft dit item intussen gewijzigd. Vernieuw de pagina en probeer het opnieuw.",
|
|
391
|
+
errorCodeRateLimited: "Te veel verzoeken tegelijk. Wacht even en probeer het opnieuw.",
|
|
392
|
+
errorCodeRequestTooLarge: "Dit is te groot om te versturen. Maak het kleiner en probeer het opnieuw.",
|
|
393
|
+
errorCodeInternalError: "Er ging iets mis op de server. Probeer het zo opnieuw.",
|
|
394
|
+
errorCodeStillProcessing: "Dit wordt nog verwerkt. Wacht even en kijk dan opnieuw.",
|
|
378
395
|
},
|
|
379
396
|
};
|
|
380
397
|
|
package/src/markers.test.ts
CHANGED
|
@@ -42,6 +42,7 @@ const MARKERS = [
|
|
|
42
42
|
"admin-form",
|
|
43
43
|
"admin-section-title",
|
|
44
44
|
"alert",
|
|
45
|
+
"alert-actions",
|
|
45
46
|
"alert-body",
|
|
46
47
|
"alert-icon",
|
|
47
48
|
"alert-title",
|
|
@@ -65,6 +66,13 @@ const MARKERS = [
|
|
|
65
66
|
"appshell-skip-link",
|
|
66
67
|
"avatar",
|
|
67
68
|
"badge",
|
|
69
|
+
"bar-chart",
|
|
70
|
+
"bar-chart-bar",
|
|
71
|
+
"bar-chart-label",
|
|
72
|
+
"bar-chart-mark",
|
|
73
|
+
"bar-chart-name",
|
|
74
|
+
"bar-chart-table",
|
|
75
|
+
"bar-chart-value",
|
|
68
76
|
"breadcrumbs",
|
|
69
77
|
"breadcrumbs-current",
|
|
70
78
|
"breadcrumbs-separator",
|
|
@@ -83,6 +91,17 @@ const MARKERS = [
|
|
|
83
91
|
"card-header",
|
|
84
92
|
"card-heading",
|
|
85
93
|
"card-title",
|
|
94
|
+
"chart-axis",
|
|
95
|
+
"chart-body",
|
|
96
|
+
"chart-caption",
|
|
97
|
+
"chart-gridline",
|
|
98
|
+
"chart-labels",
|
|
99
|
+
"chart-legend",
|
|
100
|
+
"chart-legend-item",
|
|
101
|
+
"chart-legend-value",
|
|
102
|
+
"chart-plot",
|
|
103
|
+
"chart-swatch",
|
|
104
|
+
"chart-table",
|
|
86
105
|
"checkbox",
|
|
87
106
|
"code",
|
|
88
107
|
"code-block",
|
|
@@ -112,6 +131,7 @@ const MARKERS = [
|
|
|
112
131
|
"dataview-column-settings",
|
|
113
132
|
"dataview-column-settings-title",
|
|
114
133
|
"dataview-column-sort",
|
|
134
|
+
"dataview-count",
|
|
115
135
|
"dataview-error",
|
|
116
136
|
"dataview-expand-cell",
|
|
117
137
|
"dataview-expanded-cell",
|
|
@@ -124,7 +144,10 @@ const MARKERS = [
|
|
|
124
144
|
"dataview-scroll",
|
|
125
145
|
"dataview-select-cell",
|
|
126
146
|
"dataview-skeleton",
|
|
147
|
+
"dataview-status",
|
|
148
|
+
"dataview-status-dot",
|
|
127
149
|
"dataview-table",
|
|
150
|
+
"dataview-title",
|
|
128
151
|
"dataview-toolbar",
|
|
129
152
|
"dataview-toolbar-actions",
|
|
130
153
|
"dataview-toolbar-count",
|
|
@@ -157,6 +180,7 @@ const MARKERS = [
|
|
|
157
180
|
"error-state-icon",
|
|
158
181
|
"error-state-title",
|
|
159
182
|
"field",
|
|
183
|
+
"field-body",
|
|
160
184
|
"field-error",
|
|
161
185
|
"field-hint",
|
|
162
186
|
"field-label",
|
|
@@ -216,12 +240,22 @@ const MARKERS = [
|
|
|
216
240
|
"page-header",
|
|
217
241
|
"page-heading",
|
|
218
242
|
"page-meta",
|
|
243
|
+
"page-sequence",
|
|
244
|
+
"page-sequence-label",
|
|
245
|
+
"page-sequence-next",
|
|
246
|
+
"page-sequence-position",
|
|
247
|
+
"page-sequence-previous",
|
|
248
|
+
"page-summary",
|
|
219
249
|
"page-title",
|
|
220
250
|
"popover",
|
|
221
251
|
"popover-panel",
|
|
222
252
|
"profile-card",
|
|
223
253
|
"profile-email",
|
|
224
254
|
"profile-role",
|
|
255
|
+
"proportion-bar",
|
|
256
|
+
"proportion-bar-gap",
|
|
257
|
+
"proportion-bar-part",
|
|
258
|
+
"proportion-bar-track",
|
|
225
259
|
"quiet-actions",
|
|
226
260
|
"quiet-actions-slot",
|
|
227
261
|
"radio",
|
|
@@ -238,6 +272,26 @@ const MARKERS = [
|
|
|
238
272
|
"splitpage-panes",
|
|
239
273
|
"splitpane",
|
|
240
274
|
"stack",
|
|
275
|
+
"stat",
|
|
276
|
+
"stat-arrow",
|
|
277
|
+
"stat-caption",
|
|
278
|
+
"stat-change",
|
|
279
|
+
"stat-delta",
|
|
280
|
+
"stat-delta-label",
|
|
281
|
+
"stat-group",
|
|
282
|
+
"stat-label",
|
|
283
|
+
"stat-sentiment",
|
|
284
|
+
"stat-trend",
|
|
285
|
+
"stat-trend-area",
|
|
286
|
+
"stat-trend-chart",
|
|
287
|
+
"stat-trend-data",
|
|
288
|
+
"stat-trend-line",
|
|
289
|
+
"stat-value",
|
|
290
|
+
"status-history",
|
|
291
|
+
"status-history-cell",
|
|
292
|
+
"status-history-cells",
|
|
293
|
+
"status-history-data",
|
|
294
|
+
"status-history-latest",
|
|
241
295
|
"switch",
|
|
242
296
|
"tab",
|
|
243
297
|
"tab-list",
|
|
@@ -252,6 +306,12 @@ const MARKERS = [
|
|
|
252
306
|
"tile-group",
|
|
253
307
|
"tile-label",
|
|
254
308
|
"tile-note",
|
|
309
|
+
"timeline",
|
|
310
|
+
"timeline-detail",
|
|
311
|
+
"timeline-event",
|
|
312
|
+
"timeline-label",
|
|
313
|
+
"timeline-marker",
|
|
314
|
+
"timeline-when",
|
|
255
315
|
"toast",
|
|
256
316
|
"toast-body",
|
|
257
317
|
"toast-icon",
|
|
@@ -259,6 +319,12 @@ const MARKERS = [
|
|
|
259
319
|
"toast-viewport",
|
|
260
320
|
"tooltip",
|
|
261
321
|
"tooltip-anchor",
|
|
322
|
+
"trend-chart",
|
|
323
|
+
"trend-chart-area",
|
|
324
|
+
"trend-chart-column",
|
|
325
|
+
"trend-chart-comparison",
|
|
326
|
+
"trend-chart-dot",
|
|
327
|
+
"trend-chart-line",
|
|
262
328
|
"user-menu",
|
|
263
329
|
"user-menu-email",
|
|
264
330
|
"user-menu-header",
|
|
@@ -399,8 +465,9 @@ const INLINE_BASE_STYLES: Record<string, number> = {};
|
|
|
399
465
|
* - A measured value the sheet has no business owning. `icons.tsx` and `LoadingState.tsx`
|
|
400
466
|
* size a box from a prop taking any CSS length; `layout.tsx` passes Stack's `align` /
|
|
401
467
|
* `justify`, an open vocabulary CSS already has; `ui/Popover.tsx` positions its panel
|
|
402
|
-
* from a rect measured at runtime
|
|
403
|
-
*
|
|
468
|
+
* from a rect measured at runtime, and `ui/Tooltip.tsx` its bubble the same way, for the
|
|
469
|
+
* same reason (a portalled, fixed bubble has no box the sheet could place it against);
|
|
470
|
+
* `dataview/DataViewTable.tsx` carries a column's width while it is being dragged.
|
|
404
471
|
* - The caller's own `style` prop, forwarded to a root. `ui/Checkbox.tsx`, `ui/Radio.tsx`,
|
|
405
472
|
* `ui/Switch.tsx` and `ui/Combobox.tsx` do this and nothing else — it is not the
|
|
406
473
|
* component styling itself, it is the escape a framework component owes its caller, and
|
|
@@ -428,6 +495,7 @@ const INLINE_STYLE_SITES: Record<string, number> = {
|
|
|
428
495
|
"./ui/Popover.tsx": 1,
|
|
429
496
|
"./ui/Radio.tsx": 1,
|
|
430
497
|
"./ui/Switch.tsx": 1,
|
|
498
|
+
"./ui/Tooltip.tsx": 1,
|
|
431
499
|
};
|
|
432
500
|
|
|
433
501
|
/**
|
package/src/router.test.tsx
CHANGED
|
@@ -629,9 +629,9 @@ describe("buildAppRouter", () => {
|
|
|
629
629
|
});
|
|
630
630
|
|
|
631
631
|
it("refuses a routed view that skips the page archetypes (fail closed)", async () => {
|
|
632
|
-
// The runtime half of the page-archetype control: a view rendering bare markup (no
|
|
633
|
-
//
|
|
634
|
-
vi.spyOn(console, "error").mockImplementation(() => undefined);
|
|
632
|
+
// The runtime half of the page-archetype control: a view rendering bare markup (no page
|
|
633
|
+
// archetype in its tree) is refused after mount, not shown.
|
|
634
|
+
const consoleError = vi.spyOn(console, "error").mockImplementation(() => undefined);
|
|
635
635
|
const fetchMock = vi.fn<typeof fetch>(async (input) => {
|
|
636
636
|
const url = (input as Request).url;
|
|
637
637
|
if (url.endsWith("/api/v1/auth/login")) {
|
|
@@ -660,10 +660,22 @@ describe("buildAppRouter", () => {
|
|
|
660
660
|
// The bare view mounts, the post-mount check bites, and the screen is torn down. The
|
|
661
661
|
// timeout clears the guard's grace budget: this is the one test that waits out the whole
|
|
662
662
|
// window, because it is the one asserting the refusal actually arrives.
|
|
663
|
+
// Seen first: a check that only waited for the heading's absence passed before the view had
|
|
664
|
+
// mounted at all, while sign-in was still on its way.
|
|
665
|
+
await screen.findByRole("heading", { name: "Bare view" }, { timeout: 4000 });
|
|
663
666
|
await waitFor(
|
|
664
667
|
() => expect(screen.queryByRole("heading", { name: "Bare view" })).not.toBeInTheDocument(),
|
|
665
668
|
{ timeout: 4000 },
|
|
666
669
|
);
|
|
670
|
+
// The refusal names every archetype there is, read from the contract's table. Mutation: write
|
|
671
|
+
// the list out by hand again, and it names the four it once did.
|
|
672
|
+
const logged = consoleError.mock.calls
|
|
673
|
+
.flat()
|
|
674
|
+
.map((argument) => (argument instanceof Error ? argument.message : String(argument)))
|
|
675
|
+
.join(" ");
|
|
676
|
+
expect(`${logged} ${document.body.textContent ?? ""}`).toContain(
|
|
677
|
+
"(Page, HubPage, OverviewPage, FormPage, SettingsPage, SplitPage, DashboardPage or DetailPage)",
|
|
678
|
+
);
|
|
667
679
|
});
|
|
668
680
|
|
|
669
681
|
it("accepts a view whose page archetype lands on a follow-up commit", async () => {
|
package/src/router.tsx
CHANGED
|
@@ -81,6 +81,16 @@ export const PROFILE_PATH = "/profile";
|
|
|
81
81
|
*/
|
|
82
82
|
const ARCHETYPE_GRACE_MS = 2_000;
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Every page archetype by name, the plain `Page` first and the rest read from the standard
|
|
86
|
+
* contract's slot table, for the refusal's message: written out by hand, it named the four
|
|
87
|
+
* archetypes it was first written with for releases after four more shipped.
|
|
88
|
+
*/
|
|
89
|
+
const ARCHETYPE_NAMES = (() => {
|
|
90
|
+
const names = ["Page", ...Object.keys(LAYOUT_CONTRACTS.standard?.slots ?? {})];
|
|
91
|
+
return `${names.slice(0, -1).join(", ")} or ${names.at(-1)}`;
|
|
92
|
+
})();
|
|
93
|
+
|
|
84
94
|
/**
|
|
85
95
|
* Translate a manifest path into TanStack Router's dialect.
|
|
86
96
|
*
|
|
@@ -606,8 +616,7 @@ export function buildAppRouter(
|
|
|
606
616
|
if (unframed && !marked.current) {
|
|
607
617
|
throw new Error(
|
|
608
618
|
`Terp routed view "${viewName}" must render a react-core page archetype ` +
|
|
609
|
-
|
|
610
|
-
"breadcrumb/title/error frame.",
|
|
619
|
+
`(${ARCHETYPE_NAMES}) so every screen keeps the breadcrumb/title/error frame.`,
|
|
611
620
|
);
|
|
612
621
|
}
|
|
613
622
|
if (!allowed) {
|
package/src/ssr.test.tsx
CHANGED
|
@@ -5,6 +5,8 @@ import { AppShell } from "./AppShell";
|
|
|
5
5
|
import { DataView } from "./dataview/DataView";
|
|
6
6
|
import type { DataViewRepository } from "./dataview/types";
|
|
7
7
|
import { LOCALE_EN, LOCALE_NL, LocaleProvider } from "./locale";
|
|
8
|
+
import { Button } from "./ui/Button";
|
|
9
|
+
import { Tooltip } from "./ui/Tooltip";
|
|
8
10
|
|
|
9
11
|
interface Row {
|
|
10
12
|
id: string;
|
|
@@ -58,4 +60,20 @@ describe("server rendering", () => {
|
|
|
58
60
|
|
|
59
61
|
expect(view).toContain('aria-label="Laden…"');
|
|
60
62
|
});
|
|
63
|
+
|
|
64
|
+
it("renders a tooltip's trigger without a body to portal its bubble into", () => {
|
|
65
|
+
// The bubble is portalled to document.body so no scroll container clips it, and there is
|
|
66
|
+
// no body on the server. The portal waits for the mount, so the server and the first
|
|
67
|
+
// client render agree: the trigger, described by an id the bubble takes once mounted.
|
|
68
|
+
// Moved into the render body, createPortal(..., document.body) throws here.
|
|
69
|
+
const markup = renderToString(
|
|
70
|
+
<Tooltip content="More information" defaultOpen>
|
|
71
|
+
<Button>Help</Button>
|
|
72
|
+
</Tooltip>,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
expect(markup).toContain('data-terp="tooltip-anchor"');
|
|
76
|
+
expect(markup).toContain("Help");
|
|
77
|
+
expect(markup).not.toContain('role="tooltip"');
|
|
78
|
+
});
|
|
61
79
|
});
|