@flamingo-stack/openframe-frontend-core 0.0.615 → 0.0.616-snapshot.20260912195615
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/dist/{chunk-KIQNMCOO.cjs → chunk-2OJVGAGX.cjs} +4 -4
- package/dist/{chunk-KIQNMCOO.cjs.map → chunk-2OJVGAGX.cjs.map} +1 -1
- package/dist/{chunk-TDA355L7.cjs → chunk-332JHI2D.cjs} +3 -3
- package/dist/{chunk-TDA355L7.cjs.map → chunk-332JHI2D.cjs.map} +1 -1
- package/dist/{chunk-A6ZMLRBR.js → chunk-45OAW4M2.js} +4 -4
- package/dist/{chunk-RRGQTQ6T.js → chunk-5KKLN7Q2.js} +2 -2
- package/dist/{chunk-N3G3YG3V.cjs → chunk-67XFJ442.cjs} +271 -235
- package/dist/chunk-67XFJ442.cjs.map +1 -0
- package/dist/{chunk-L3H6VYDB.js → chunk-6RMFEGJ4.js} +2 -2
- package/dist/{chunk-5WHUUHSH.cjs → chunk-7FFKXXWY.cjs} +50 -50
- package/dist/{chunk-5WHUUHSH.cjs.map → chunk-7FFKXXWY.cjs.map} +1 -1
- package/dist/{chunk-TOAJWB3V.js → chunk-7YHUP5BR.js} +2 -2
- package/dist/{chunk-F7R7J4HK.cjs → chunk-BJDQZH62.cjs} +3 -3
- package/dist/{chunk-F7R7J4HK.cjs.map → chunk-BJDQZH62.cjs.map} +1 -1
- package/dist/{chunk-NLKYBYPV.js → chunk-CGCV4QT2.js} +5 -5
- package/dist/{chunk-XJ5KH37F.js → chunk-CXEGV3ZS.js} +2 -2
- package/dist/{chunk-H6TOSMGU.cjs → chunk-FMNS5NN2.cjs} +13 -13
- package/dist/{chunk-H6TOSMGU.cjs.map → chunk-FMNS5NN2.cjs.map} +1 -1
- package/dist/{chunk-4C3BOBV6.js → chunk-GH4F4ODL.js} +4 -4
- package/dist/{chunk-UMVCVMCG.js → chunk-HGPGF6SF.js} +2 -2
- package/dist/{chunk-L6UVTIJP.cjs → chunk-HR6CHKD6.cjs} +4 -4
- package/dist/{chunk-L6UVTIJP.cjs.map → chunk-HR6CHKD6.cjs.map} +1 -1
- package/dist/{chunk-YSG26SQ7.cjs → chunk-JZELYIFZ.cjs} +33 -33
- package/dist/{chunk-YSG26SQ7.cjs.map → chunk-JZELYIFZ.cjs.map} +1 -1
- package/dist/{chunk-NLYWRJ6J.cjs → chunk-LFLJ3IHE.cjs} +17 -17
- package/dist/{chunk-NLYWRJ6J.cjs.map → chunk-LFLJ3IHE.cjs.map} +1 -1
- package/dist/{chunk-HIMST6NK.js → chunk-RZURBPBS.js} +2 -2
- package/dist/{chunk-BESOUYM7.cjs → chunk-TRY3CUWJ.cjs} +18 -18
- package/dist/{chunk-BESOUYM7.cjs.map → chunk-TRY3CUWJ.cjs.map} +1 -1
- package/dist/{chunk-TOXJS4HN.cjs → chunk-ULM5FCFN.cjs} +3 -3
- package/dist/{chunk-TOXJS4HN.cjs.map → chunk-ULM5FCFN.cjs.map} +1 -1
- package/dist/{chunk-X6G7JIX6.cjs → chunk-USP3UWID.cjs} +34 -34
- package/dist/{chunk-X6G7JIX6.cjs.map → chunk-USP3UWID.cjs.map} +1 -1
- package/dist/{chunk-OKWHWDA3.js → chunk-UVK7AQAG.js} +2 -2
- package/dist/{chunk-646YZIUK.js → chunk-UVXMIZYK.js} +5 -5
- package/dist/{chunk-RJT7I2Y4.cjs → chunk-V23BJC2Q.cjs} +10 -10
- package/dist/{chunk-RJT7I2Y4.cjs.map → chunk-V23BJC2Q.cjs.map} +1 -1
- package/dist/{chunk-AJRHEX5D.js → chunk-VHS3OYE4.js} +61 -25
- package/dist/chunk-VHS3OYE4.js.map +1 -0
- package/dist/{chunk-JYHDJD3U.js → chunk-VJJ7LGOI.js} +3 -3
- package/dist/{chunk-GHMTJJCC.cjs → chunk-VNNIRX23.cjs} +3 -3
- package/dist/{chunk-GHMTJJCC.cjs.map → chunk-VNNIRX23.cjs.map} +1 -1
- package/dist/{chunk-KKYE3E66.js → chunk-WFM5OAM6.js} +2 -2
- package/dist/{chunk-TWE6KYQM.js → chunk-ZJYZOOTU.js} +2 -2
- package/dist/{chunk-FBL32U6S.cjs → chunk-ZQOK4TCN.cjs} +17 -17
- package/dist/{chunk-FBL32U6S.cjs.map → chunk-ZQOK4TCN.cjs.map} +1 -1
- package/dist/components/case-studies/index.cjs +8 -8
- package/dist/components/case-studies/index.js +2 -2
- package/dist/components/contact/index.cjs +3 -3
- package/dist/components/contact/index.js +2 -2
- package/dist/components/docs/index.cjs +6 -6
- package/dist/components/docs/index.js +5 -5
- package/dist/components/embeds/index.cjs +3 -3
- package/dist/components/embeds/index.js +2 -2
- package/dist/components/faq/index.cjs +3 -3
- package/dist/components/faq/index.js +2 -2
- package/dist/components/features/index.cjs +2 -2
- package/dist/components/features/index.js +1 -1
- package/dist/components/help-center-pages/index.cjs +22 -22
- package/dist/components/help-center-pages/index.js +13 -13
- package/dist/components/index.cjs +31 -31
- package/dist/components/index.js +12 -12
- package/dist/components/meeting-scheduler/index.cjs +21 -21
- package/dist/components/meeting-scheduler/index.js +1 -1
- package/dist/components/navigation/index.cjs +5 -5
- package/dist/components/navigation/index.js +4 -4
- package/dist/components/onboarding-guides/index.cjs +5 -5
- package/dist/components/onboarding-guides/index.js +4 -4
- package/dist/components/tickets/index.cjs +6 -6
- package/dist/components/tickets/index.js +5 -5
- package/dist/components/ui/data-table/data-table-header.d.ts +9 -1
- package/dist/components/ui/data-table/data-table-header.d.ts.map +1 -1
- package/dist/components/ui/data-table/types.d.ts +9 -0
- package/dist/components/ui/data-table/types.d.ts.map +1 -1
- package/dist/components/ui/index.cjs +2 -2
- package/dist/components/ui/index.js +1 -1
- package/dist/components/ui/table/table-header.d.ts.map +1 -1
- package/dist/components/ui/table/types.d.ts +7 -0
- package/dist/components/ui/table/types.d.ts.map +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +5 -5
- package/dist/types/design-doc.d.ts +34 -43
- package/dist/types/design-doc.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/data-table-header-hint.test.tsx +69 -0
- package/src/components/ui/data-table/data-table-header.tsx +47 -11
- package/src/components/ui/data-table/types.ts +9 -0
- package/src/components/ui/table/__tests__/header-hint.test.tsx +85 -0
- package/src/components/ui/table/table-header.tsx +34 -9
- package/src/components/ui/table/types.ts +7 -0
- package/src/types/design-doc.ts +59 -51
- package/dist/chunk-AJRHEX5D.js.map +0 -1
- package/dist/chunk-N3G3YG3V.cjs.map +0 -1
- /package/dist/{chunk-A6ZMLRBR.js.map → chunk-45OAW4M2.js.map} +0 -0
- /package/dist/{chunk-RRGQTQ6T.js.map → chunk-5KKLN7Q2.js.map} +0 -0
- /package/dist/{chunk-L3H6VYDB.js.map → chunk-6RMFEGJ4.js.map} +0 -0
- /package/dist/{chunk-TOAJWB3V.js.map → chunk-7YHUP5BR.js.map} +0 -0
- /package/dist/{chunk-NLKYBYPV.js.map → chunk-CGCV4QT2.js.map} +0 -0
- /package/dist/{chunk-XJ5KH37F.js.map → chunk-CXEGV3ZS.js.map} +0 -0
- /package/dist/{chunk-4C3BOBV6.js.map → chunk-GH4F4ODL.js.map} +0 -0
- /package/dist/{chunk-UMVCVMCG.js.map → chunk-HGPGF6SF.js.map} +0 -0
- /package/dist/{chunk-HIMST6NK.js.map → chunk-RZURBPBS.js.map} +0 -0
- /package/dist/{chunk-OKWHWDA3.js.map → chunk-UVK7AQAG.js.map} +0 -0
- /package/dist/{chunk-646YZIUK.js.map → chunk-UVXMIZYK.js.map} +0 -0
- /package/dist/{chunk-JYHDJD3U.js.map → chunk-VJJ7LGOI.js.map} +0 -0
- /package/dist/{chunk-KKYE3E66.js.map → chunk-WFM5OAM6.js.map} +0 -0
- /package/dist/{chunk-TWE6KYQM.js.map → chunk-ZJYZOOTU.js.map} +0 -0
|
@@ -5,7 +5,7 @@ import type { EmployeeDirectoryRow } from './employee';
|
|
|
5
5
|
import type { EntityAuthor } from './entity-author';
|
|
6
6
|
/** One value of `design_doc_vocabulary.kind` — the STRUCTURAL list (one per
|
|
7
7
|
* value column), the only design-doc vocabulary that is code. */
|
|
8
|
-
export type DesignDocVocabularyKind = '
|
|
8
|
+
export type DesignDocVocabularyKind = 'tier' | 'spec_mode' | 'participant_status' | 'comment_type' | 'comment_status' | 'link_type' | 'media_type';
|
|
9
9
|
/** A `design_doc_vocabulary` row, as the DAL and the vocabulary API return it. */
|
|
10
10
|
export interface DesignDocVocabularyOption {
|
|
11
11
|
id: number;
|
|
@@ -15,13 +15,13 @@ export interface DesignDocVocabularyOption {
|
|
|
15
15
|
/** A `StatusBadge` colorScheme name (validated against the badge's own union
|
|
16
16
|
* when the hub reads the row — an unknown scheme degrades to 'default'). */
|
|
17
17
|
color_scheme: string;
|
|
18
|
-
/** Human copy for surfaces that
|
|
19
|
-
*
|
|
18
|
+
/** Human copy for surfaces that EXPLAIN a value rather than just naming it —
|
|
19
|
+
* the spec-mode picker's per-option hint. Display only. */
|
|
20
20
|
description: string | null;
|
|
21
21
|
display_order: number;
|
|
22
22
|
is_active: boolean;
|
|
23
|
-
/** Engine capabilities this member claims (`complete`, `
|
|
24
|
-
*
|
|
23
|
+
/** Engine capabilities this member claims (`complete`, `blocks_ready`, …).
|
|
24
|
+
* The names live in the hub's gate module. */
|
|
25
25
|
roles: string[];
|
|
26
26
|
/** link_type only: which renderer previews it. */
|
|
27
27
|
render: DesignDocLinkRender | null;
|
|
@@ -32,31 +32,19 @@ export interface DesignDocVocabularyOption {
|
|
|
32
32
|
/** link_type only: where the artifact comes from, shown beside the label. */
|
|
33
33
|
source: string | null;
|
|
34
34
|
placeholder: string | null;
|
|
35
|
-
/** status only: the verb on the button that moves a doc INTO this status. */
|
|
36
|
-
action_label: string | null;
|
|
37
35
|
}
|
|
38
36
|
/** How the doc page previews a link type. A CAPABILITY (each key is a
|
|
39
37
|
* component in the renderer), so this one IS code — a DB row binds to it. */
|
|
40
38
|
export type DesignDocLinkRender = 'task' | 'figma' | 'claude' | 'link';
|
|
41
|
-
/**
|
|
42
|
-
export interface DesignDocStatusTransition {
|
|
43
|
-
from: string;
|
|
44
|
-
to: string;
|
|
45
|
-
/** From-specific button copy when it differs from the target's verb
|
|
46
|
-
* (`abandoned -> draft` reads "Reopen", not "Back to draft"). */
|
|
47
|
-
action_label: string | null;
|
|
48
|
-
display_order: number;
|
|
49
|
-
}
|
|
50
|
-
/** The whole vocabulary in one payload — what every surface (server gate,
|
|
39
|
+
/** The whole vocabulary in one payload — what every surface (server rules,
|
|
51
40
|
* client badges, pickers, validators) reads instead of a literal list. */
|
|
52
41
|
export interface DesignDocVocabulary {
|
|
53
42
|
options: DesignDocVocabularyOption[];
|
|
54
|
-
transitions: DesignDocStatusTransition[];
|
|
55
43
|
}
|
|
56
|
-
/** A `design_doc_vocabulary.value` of kind `status`. */
|
|
57
|
-
export type DesignDocStatus = string;
|
|
58
44
|
/** A `design_doc_vocabulary.value` of kind `tier`. */
|
|
59
45
|
export type DesignDocTier = string;
|
|
46
|
+
/** A `design_doc_vocabulary.value` of kind `spec_mode`. */
|
|
47
|
+
export type DesignDocSpecMode = string;
|
|
60
48
|
/** A `design_doc_vocabulary.value` of kind `participant_status`. */
|
|
61
49
|
export type DesignDocParticipantStatus = string;
|
|
62
50
|
/** A `design_doc_vocabulary.value` of kind `comment_type`. */
|
|
@@ -114,7 +102,7 @@ export interface DesignDocMedia {
|
|
|
114
102
|
}
|
|
115
103
|
/**
|
|
116
104
|
* A comment. ROOT comments (`parent_comment_id === null`) carry `comment_type`
|
|
117
|
-
* + `status` and
|
|
105
|
+
* + `status` and keep the doc from being ready when `blocking` + `open`; REPLIES carry neither
|
|
118
106
|
* (single-level threads — a reply to a reply is re-parented to the root).
|
|
119
107
|
*/
|
|
120
108
|
export interface DesignDocComment {
|
|
@@ -179,19 +167,15 @@ export interface DesignDoc {
|
|
|
179
167
|
title: string;
|
|
180
168
|
slug: string;
|
|
181
169
|
tier: DesignDocTier;
|
|
170
|
+
/**
|
|
171
|
+
* How much of the solution is knowable before build starts — spec-first
|
|
172
|
+
* (settled up front) or discovery-first (engineering resolves the design
|
|
173
|
+
* while building). A LABEL on the doc: no rule reads it.
|
|
174
|
+
*/
|
|
175
|
+
spec_mode: DesignDocSpecMode;
|
|
182
176
|
summary: string | null;
|
|
183
177
|
content: string | null;
|
|
184
|
-
status: DesignDocStatus;
|
|
185
178
|
author_id: string | null;
|
|
186
|
-
/**
|
|
187
|
-
* EVERYONE who has handed the DRI role away on this doc (appended, never
|
|
188
|
-
* overwritten). The third-party break-glass excludes all of them: a DRI who
|
|
189
|
-
* also holds management could otherwise vacate the seat, act as a "third
|
|
190
|
-
* party" on their own doc and approve it alone — and with a single scalar,
|
|
191
|
-
* simply hand the seat on twice to erase the memory of their own vacating.
|
|
192
|
-
*/
|
|
193
|
-
dri_vacated_by: string[];
|
|
194
|
-
approved_at: string | null;
|
|
195
179
|
created_at: string;
|
|
196
180
|
updated_at: string;
|
|
197
181
|
/** DRI, hydrated via the shared author hydrator. */
|
|
@@ -200,8 +184,8 @@ export interface DesignDoc {
|
|
|
200
184
|
* Engineering feature leads — the people reviewing the doc alongside the
|
|
201
185
|
* department sign-off sections. DISPLAY-ONLY attribution, like
|
|
202
186
|
* `how_i_work_participants`: being listed grants NO rights (nothing in the
|
|
203
|
-
* hub's `design-doc-gate.ts` reads it) and is NOT an input to
|
|
204
|
-
*
|
|
187
|
+
* hub's `design-doc-gate.ts` reads it) and is NOT an input to readiness.
|
|
188
|
+
* The doc-level owner with actual levers is the DRI (`author_id`).
|
|
205
189
|
*
|
|
206
190
|
* Carried on BOTH the list and the detail payload — the dashboard renders
|
|
207
191
|
* their avatars in its own column.
|
|
@@ -242,6 +226,8 @@ export interface CreateDesignDocData {
|
|
|
242
226
|
title: string;
|
|
243
227
|
slug: string;
|
|
244
228
|
tier: DesignDocTier;
|
|
229
|
+
/** Defaults to the `spec_mode` row claiming `default` when omitted. */
|
|
230
|
+
spec_mode?: DesignDocSpecMode;
|
|
245
231
|
summary?: string | null;
|
|
246
232
|
/** Spec markdown (Why / What / How); the create screen carries the same body editor as edit. */
|
|
247
233
|
content?: string | null;
|
|
@@ -253,20 +239,21 @@ export interface CreateDesignDocData {
|
|
|
253
239
|
links: DesignDocLinkInput[];
|
|
254
240
|
}
|
|
255
241
|
/**
|
|
256
|
-
* Doc-level allowlist (PUT). `
|
|
257
|
-
*
|
|
242
|
+
* Doc-level allowlist (PUT). `participants` are NOT here — they only move
|
|
243
|
+
* through their own routes.
|
|
258
244
|
*/
|
|
259
245
|
export interface UpdateDesignDocData {
|
|
260
246
|
title?: string;
|
|
261
247
|
slug?: string;
|
|
262
248
|
tier?: DesignDocTier;
|
|
249
|
+
spec_mode?: DesignDocSpecMode;
|
|
263
250
|
summary?: string | null;
|
|
264
251
|
content?: string | null;
|
|
265
252
|
author_id?: string | null;
|
|
266
253
|
/**
|
|
267
254
|
* Replaces the whole feature-lead set (`[]` clears it); omitted leaves it
|
|
268
255
|
* untouched. Display-only, so it rides the STANDING floor like the title —
|
|
269
|
-
* not the DRI-only levers
|
|
256
|
+
* not the DRI-only levers.
|
|
270
257
|
*/
|
|
271
258
|
feature_lead_ids?: string[];
|
|
272
259
|
links?: DesignDocLinkInput[];
|
|
@@ -296,8 +283,12 @@ export interface AddDesignDocCommentData {
|
|
|
296
283
|
title?: string | null;
|
|
297
284
|
body: string;
|
|
298
285
|
}
|
|
286
|
+
/** The dashboard's readiness filter (`?ready=`). */
|
|
287
|
+
export type DesignDocReadyFilter = 'ready' | 'not_ready';
|
|
299
288
|
export interface DesignDocFilters {
|
|
300
|
-
|
|
289
|
+
ready?: DesignDocReadyFilter;
|
|
290
|
+
/** One or more `spec_mode` values (CSV on the wire). */
|
|
291
|
+
spec_mode?: string;
|
|
301
292
|
search?: string;
|
|
302
293
|
mine?: 'open';
|
|
303
294
|
limit?: number;
|
|
@@ -306,17 +297,17 @@ export interface DesignDocFilters {
|
|
|
306
297
|
export interface DesignDocListResponse {
|
|
307
298
|
data: DesignDoc[];
|
|
308
299
|
count: number;
|
|
309
|
-
/** Server-computed
|
|
300
|
+
/** Server-computed spec-mode counts over the scope, MINUS the spec-mode
|
|
301
|
+
* filter itself — so a filtered row still shows what the other value holds. */
|
|
310
302
|
facets: {
|
|
311
|
-
|
|
303
|
+
spec_mode: Record<string, number>;
|
|
312
304
|
};
|
|
313
305
|
}
|
|
314
306
|
export interface DesignDocStats {
|
|
315
307
|
total: number;
|
|
316
|
-
/**
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
by_status: Record<string, number>;
|
|
308
|
+
/** Docs whose every section is signed off with no open blocking comment. */
|
|
309
|
+
ready: number;
|
|
310
|
+
not_ready: number;
|
|
320
311
|
waiting_on_me_docs: number;
|
|
321
312
|
waiting_on_me_tasks: number;
|
|
322
313
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-doc.d.ts","sourceRoot":"","sources":["../../src/types/design-doc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"design-doc.d.ts","sourceRoot":"","sources":["../../src/types/design-doc.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAuBpD;kEACkE;AAClE,MAAM,MAAM,uBAAuB,GACjC,MAAM,GAAG,WAAW,GAAG,oBAAoB,GAAG,cAAc,GAAG,gBAAgB,GAAG,WAAW,GAAG,YAAY,CAAC;AAE/G,kFAAkF;AAClF,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,uBAAuB,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAA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AE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd;oFACgF;IAChF,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;CAC/C;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;CAC7B"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createColumnHelper } from '@tanstack/react-table';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { DataTable } from '../components/ui/data-table';
|
|
5
|
+
import { DATA_TABLE_HEADER_LABEL_CLASS } from '../components/ui/data-table/data-table-header';
|
|
6
|
+
import { useDataTable } from '../components/ui/data-table/use-data-table';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `meta.hint` draws a header's definition in an InfoHint named after the
|
|
10
|
+
* column, and a header label wraps inside its cell rather than painting across
|
|
11
|
+
* the next column. Both used to be hand-rolled per table with a node header.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface Row {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const columnHelper = createColumnHelper<Row>();
|
|
20
|
+
|
|
21
|
+
function HintTable({ hint, filterable = false }: { hint?: string; filterable?: boolean }) {
|
|
22
|
+
const columns = [
|
|
23
|
+
columnHelper.accessor('name', {
|
|
24
|
+
id: 'name',
|
|
25
|
+
header: 'Implementation owners',
|
|
26
|
+
meta: {
|
|
27
|
+
hint,
|
|
28
|
+
...(filterable ? { filter: { options: [{ id: 'a', label: 'A', value: 'a' }] } } : {}),
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
];
|
|
32
|
+
const table = useDataTable({ data: [{ id: '1', name: 'Alpha' }], columns });
|
|
33
|
+
return (
|
|
34
|
+
<DataTable table={table}>
|
|
35
|
+
<DataTable.Header />
|
|
36
|
+
</DataTable>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe('DataTable header hint', () => {
|
|
41
|
+
it('draws the definition beside a plain header, named after the column', () => {
|
|
42
|
+
render(<HintTable hint="Engineers building it." />);
|
|
43
|
+
expect(screen.getByRole('button', { name: 'About Implementation owners' })).toBeTruthy();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('draws it beside a FILTER header too', () => {
|
|
47
|
+
render(<HintTable hint="Engineers building it." filterable />);
|
|
48
|
+
expect(screen.getByRole('button', { name: 'About Implementation owners' })).toBeTruthy();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('draws nothing extra without a hint', () => {
|
|
52
|
+
render(<HintTable />);
|
|
53
|
+
expect(screen.queryByRole('button', { name: /^About / })).toBeNull();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('the shared label class wraps inside the cell', () => {
|
|
57
|
+
expect(DATA_TABLE_HEADER_LABEL_CLASS).not.toContain('whitespace-nowrap');
|
|
58
|
+
expect(DATA_TABLE_HEADER_LABEL_CLASS).toContain('min-w-0');
|
|
59
|
+
// A GOOD break: even lines, never one word stranded on its own.
|
|
60
|
+
expect(DATA_TABLE_HEADER_LABEL_CLASS).toContain('text-balance');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('pins the hint to the first line of a label that breaks onto two', () => {
|
|
64
|
+
// The assertion is about a CLASS reaching the DOM, which has no
|
|
65
|
+
// accessible-name equivalent to query by.
|
|
66
|
+
const { container } = render(<HintTable hint="Engineers building it." />);
|
|
67
|
+
expect(container.innerHTML).toContain('flex min-w-0 items-start gap-[var(--spacing-system-xxs)]');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -4,6 +4,7 @@ import { flexRender, type Header } from '@tanstack/react-table';
|
|
|
4
4
|
import type { ReactNode } from 'react';
|
|
5
5
|
import { cn } from '../../../utils/cn';
|
|
6
6
|
import { Arrow01DownIcon, Arrow01UpIcon, SwitchVrIcon } from '../../icons-v2-generated';
|
|
7
|
+
import { InfoHint } from '../info-hint';
|
|
7
8
|
import { useDataTableContext } from './data-table';
|
|
8
9
|
import { DataTableColumnFilter } from './data-table-column-filter';
|
|
9
10
|
import type { TailwindBreakpoint } from './types';
|
|
@@ -217,6 +218,17 @@ function HeaderCell({ header, sort, onSortChange }: HeaderCellProps) {
|
|
|
217
218
|
// the `sort` prop; we do not consult TanStack's sort APIs here.
|
|
218
219
|
const canSort = meta?.sortable === true;
|
|
219
220
|
const sortDir: false | 'asc' | 'desc' = sort?.id === column.id ? (sort.desc ? 'desc' : 'asc') : false;
|
|
221
|
+
// Built once: rendered bare, or beside the column's hint.
|
|
222
|
+
const filterTrigger = filter ? (
|
|
223
|
+
<DataTableColumnFilter
|
|
224
|
+
column={column}
|
|
225
|
+
options={filter.options}
|
|
226
|
+
placement={filter.placement}
|
|
227
|
+
pending={filter.pending}
|
|
228
|
+
label={resolveHeaderLabel(header)}
|
|
229
|
+
align={align}
|
|
230
|
+
/>
|
|
231
|
+
) : null;
|
|
220
232
|
|
|
221
233
|
return (
|
|
222
234
|
<div
|
|
@@ -247,15 +259,18 @@ function HeaderCell({ header, sort, onSortChange }: HeaderCellProps) {
|
|
|
247
259
|
meta?.headerClassName,
|
|
248
260
|
)}
|
|
249
261
|
>
|
|
250
|
-
{
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
262
|
+
{filterTrigger ? (
|
|
263
|
+
// Only a column that HAS a hint gets the extra row, so every existing
|
|
264
|
+
// filter header keeps its exact structure — the trigger stays a direct
|
|
265
|
+
// child of the cell.
|
|
266
|
+
meta?.hint ? (
|
|
267
|
+
<div className="flex items-start gap-[var(--spacing-system-xxs)]">
|
|
268
|
+
{filterTrigger}
|
|
269
|
+
<InfoHint label={resolveHeaderLabel(header)}>{meta.hint}</InfoHint>
|
|
270
|
+
</div>
|
|
271
|
+
) : (
|
|
272
|
+
filterTrigger
|
|
273
|
+
)
|
|
259
274
|
) : (
|
|
260
275
|
<div
|
|
261
276
|
className={cn(
|
|
@@ -269,7 +284,20 @@ function HeaderCell({ header, sort, onSortChange }: HeaderCellProps) {
|
|
|
269
284
|
)}
|
|
270
285
|
onClick={canSort ? () => onSortChange?.(column.id) : undefined}
|
|
271
286
|
>
|
|
272
|
-
|
|
287
|
+
{meta?.hint ? (
|
|
288
|
+
// The hint shares a LABEL GROUP with the text, pinned to the FIRST
|
|
289
|
+
// line (`items-start`): on a label that breaks onto a second line it
|
|
290
|
+
// reads beside the opening word instead of floating in the gap
|
|
291
|
+
// between the two. Only a column WITH a hint gets the group, so a
|
|
292
|
+
// hint-less header keeps its DOM. The sort icon stays outside it,
|
|
293
|
+
// centred on the row.
|
|
294
|
+
<span className="flex min-w-0 items-start gap-[var(--spacing-system-xxs)]">
|
|
295
|
+
<HeaderLabel header={header} />
|
|
296
|
+
<InfoHint label={resolveHeaderLabel(header)}>{meta.hint}</InfoHint>
|
|
297
|
+
</span>
|
|
298
|
+
) : (
|
|
299
|
+
<HeaderLabel header={header} />
|
|
300
|
+
)}
|
|
273
301
|
{canSort && <SortIcon sorted={sortDir} />}
|
|
274
302
|
</div>
|
|
275
303
|
)}
|
|
@@ -281,9 +309,17 @@ function HeaderCell({ header, sort, onSortChange }: HeaderCellProps) {
|
|
|
281
309
|
* THE header label styling. Exported because a column may supply a NODE header
|
|
282
310
|
* (an icon beside the text), and without this those headers rendered unstyled
|
|
283
311
|
* beside the string ones — same row, two different type treatments.
|
|
312
|
+
*
|
|
313
|
+
* The label WRAPS inside its own cell (`min-w-0`, no `whitespace-nowrap`). A
|
|
314
|
+
* nowrapped label longer than its column does not truncate — it paints straight
|
|
315
|
+
* across the next column's header, which is how "Implementation owners" landed
|
|
316
|
+
* on top of "Updated". `text-balance` makes the break a GOOD one: the lines come
|
|
317
|
+
* out even ("IMPLEMENTATION / OWNERS") instead of one word stranded on its own.
|
|
318
|
+
* Two lines of the 20px label still fit the fixed 48px header, and a label that
|
|
319
|
+
* fits on one line looks exactly as it did.
|
|
284
320
|
*/
|
|
285
321
|
export const DATA_TABLE_HEADER_LABEL_CLASS =
|
|
286
|
-
'
|
|
322
|
+
'min-w-0 text-balance uppercase text-ods-text-secondary transition-colors duration-200 text-h5 group-hover:text-ods-text-primary';
|
|
287
323
|
|
|
288
324
|
function HeaderLabel({ header }: { header: AnyHeader }) {
|
|
289
325
|
const headerDef = header.column.columnDef.header;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RowData } from '@tanstack/react-table';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
export type TailwindBreakpoint = 'md' | 'lg' | 'xl' | '2xl';
|
|
4
5
|
|
|
@@ -61,5 +62,13 @@ declare module '@tanstack/react-table' {
|
|
|
61
62
|
cellClassName?: string;
|
|
62
63
|
/** Extra class names applied to the header cell wrapper. */
|
|
63
64
|
headerClassName?: string;
|
|
65
|
+
/**
|
|
66
|
+
* A definition shown in an `InfoHint` beside the header label — for a
|
|
67
|
+
* column whose NAME is a term of art a reader may not know. The header owns
|
|
68
|
+
* the icon, its spacing and its accessible name (`About <label>`), so every
|
|
69
|
+
* table explains a column the same way instead of each hand-rolling a node
|
|
70
|
+
* header to fit one in.
|
|
71
|
+
*/
|
|
72
|
+
hint?: ReactNode;
|
|
64
73
|
}
|
|
65
74
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { Table } from '../table';
|
|
5
|
+
import type { TableColumn } from '../types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Two header behaviours a screen used to hand-roll per table, pinned at the
|
|
9
|
+
* primitive so every table gets them:
|
|
10
|
+
*
|
|
11
|
+
* · `column.hint` draws the header's definition in an InfoHint, named after
|
|
12
|
+
* the column (`About <label>`).
|
|
13
|
+
* · the label WRAPS inside its cell. A nowrapped label longer than its column
|
|
14
|
+
* does not truncate — it paints across the next column's header.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface Row {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const data: Row[] = [{ id: '1', name: 'Alpha' }];
|
|
23
|
+
|
|
24
|
+
// The header only draws plain columns from lg up; the global setup stubs the
|
|
25
|
+
// narrow branch, so this file opts into the wide one for its own cases.
|
|
26
|
+
const realMatchMedia = window.matchMedia;
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
window.matchMedia = ((query: string) => ({
|
|
29
|
+
matches: true,
|
|
30
|
+
media: query,
|
|
31
|
+
onchange: null,
|
|
32
|
+
addEventListener: () => {},
|
|
33
|
+
removeEventListener: () => {},
|
|
34
|
+
addListener: () => {},
|
|
35
|
+
removeListener: () => {},
|
|
36
|
+
dispatchEvent: () => false,
|
|
37
|
+
})) as typeof window.matchMedia;
|
|
38
|
+
});
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
window.matchMedia = realMatchMedia;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('Table column hint', () => {
|
|
44
|
+
it('draws the definition beside the label, named after the column', () => {
|
|
45
|
+
const columns: TableColumn<Row>[] = [
|
|
46
|
+
{ key: 'name', label: 'Implementation owners', hint: 'Engineers building it.' },
|
|
47
|
+
];
|
|
48
|
+
render(<Table data={data} columns={columns} rowKey="id" />);
|
|
49
|
+
expect(screen.getByRole('button', { name: 'About Implementation owners' })).toBeTruthy();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('draws nothing extra for a column without a hint', () => {
|
|
53
|
+
const columns: TableColumn<Row>[] = [{ key: 'name', label: 'Name' }];
|
|
54
|
+
render(<Table data={data} columns={columns} rowKey="id" />);
|
|
55
|
+
expect(screen.queryByRole('button', { name: /^About / })).toBeNull();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('leaves a custom renderHeader in charge of its whole contents', () => {
|
|
59
|
+
const columns: TableColumn<Row>[] = [
|
|
60
|
+
{ key: 'name', label: 'Name', hint: 'ignored', renderHeader: () => <span>Custom</span> },
|
|
61
|
+
];
|
|
62
|
+
render(<Table data={data} columns={columns} rowKey="id" />);
|
|
63
|
+
expect(screen.queryByRole('button', { name: 'About Name' })).toBeNull();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('lets a long label wrap inside its cell instead of painting across the next one', () => {
|
|
67
|
+
const columns: TableColumn<Row>[] = [{ key: 'name', label: 'Implementation owners', width: 'w-32' }];
|
|
68
|
+
render(<Table data={data} columns={columns} rowKey="id" />);
|
|
69
|
+
const label = screen.getAllByText('Implementation owners')[0];
|
|
70
|
+
expect(label.className).not.toContain('whitespace-nowrap');
|
|
71
|
+
expect(label.className).toContain('min-w-0');
|
|
72
|
+
// A GOOD break: even lines, never one word stranded on its own.
|
|
73
|
+
expect(label.className).toContain('text-balance');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('pins the hint to the first line of a label that breaks onto two', () => {
|
|
77
|
+
const columns: TableColumn<Row>[] = [
|
|
78
|
+
{ key: 'name', label: 'Implementation owners', hint: 'Engineers building it.' },
|
|
79
|
+
];
|
|
80
|
+
// The assertion is about a CLASS reaching the DOM, which has no
|
|
81
|
+
// accessible-name equivalent to query by — the actions-column test's shape.
|
|
82
|
+
const { container } = render(<Table data={data} columns={columns} rowKey="id" />);
|
|
83
|
+
expect(container.innerHTML).toContain('flex min-w-0 items-start gap-[var(--spacing-system-xxs)]');
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -6,8 +6,12 @@ import { Arrow01DownIcon } from '../../icons-v2-generated/arrows/arrow-01-down-i
|
|
|
6
6
|
import { Arrow01UpIcon } from '../../icons-v2-generated/arrows/arrow-01-up-icon';
|
|
7
7
|
import { SwitchVrIcon } from '../../icons-v2-generated/arrows/switch-vr-icon';
|
|
8
8
|
import { Checkbox } from '../checkbox';
|
|
9
|
+
import { InfoHint } from '../info-hint';
|
|
9
10
|
import { TableColumnFilterDropdown } from './table-column-filter-dropdown';
|
|
10
11
|
import type { TableColumn, TableHeaderProps, TableRowData } from './types';
|
|
12
|
+
|
|
13
|
+
/** The default header label: wraps inside its cell with a balanced split. */
|
|
14
|
+
const TABLE_HEADER_LABEL_CLASS = 'min-w-0 text-balance uppercase text-ods-text-secondary text-h5';
|
|
11
15
|
import { getHideClasses } from './utils';
|
|
12
16
|
|
|
13
17
|
/** @deprecated Use `DataTableHeader` from `data-table` instead. */
|
|
@@ -120,18 +124,23 @@ export function TableHeader<T = TableRowData>({
|
|
|
120
124
|
)
|
|
121
125
|
) : column.filterable && column.filterOptions && onFilterChange ? (
|
|
122
126
|
/* Filterable column — label + icon are both inside the dropdown trigger */
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
<>
|
|
128
|
+
<TableColumnFilterDropdown
|
|
129
|
+
columnKey={column.key}
|
|
130
|
+
columnLabel={column.label}
|
|
131
|
+
filterOptions={column.filterOptions}
|
|
132
|
+
filters={filters}
|
|
133
|
+
onFilterChange={onFilterChange}
|
|
134
|
+
/>
|
|
135
|
+
{column.hint ? <InfoHint label={column.label}>{column.hint}</InfoHint> : null}
|
|
136
|
+
</>
|
|
130
137
|
) : (
|
|
131
138
|
/* Non-filterable column — regular label with optional sort */
|
|
132
139
|
<div
|
|
133
140
|
className={cn(
|
|
134
|
-
|
|
141
|
+
// `min-w-0` lets the row shrink to its column, so a long label
|
|
142
|
+
// wraps inside the cell instead of forcing the row past it.
|
|
143
|
+
'flex min-w-0 items-center gap-2',
|
|
135
144
|
column.sortable && 'cursor-pointer transition-colors hover:text-ods-text-primary',
|
|
136
145
|
)}
|
|
137
146
|
onClick={() => handleSort(column)}
|
|
@@ -143,7 +152,23 @@ export function TableHeader<T = TableRowData>({
|
|
|
143
152
|
</>
|
|
144
153
|
) : (
|
|
145
154
|
<>
|
|
146
|
-
|
|
155
|
+
{/* Wraps inside the cell, with a BALANCED split — "IMPLEMENTATION
|
|
156
|
+
/ OWNERS", never one word stranded on a line of its own. A
|
|
157
|
+
nowrapped label longer than its column paints straight
|
|
158
|
+
across the next column's header. */}
|
|
159
|
+
{column.hint ? (
|
|
160
|
+
/* The hint sits in a LABEL GROUP with the text, pinned to the
|
|
161
|
+
FIRST line (`items-start`): on a label that breaks onto a
|
|
162
|
+
second line it reads beside the opening word instead of
|
|
163
|
+
floating in the gap between the two. Added only when a
|
|
164
|
+
hint exists, so a hint-less header keeps its DOM. */
|
|
165
|
+
<span className="flex min-w-0 items-start gap-[var(--spacing-system-xxs)]">
|
|
166
|
+
<span className={TABLE_HEADER_LABEL_CLASS}>{column.label}</span>
|
|
167
|
+
<InfoHint label={column.label}>{column.hint}</InfoHint>
|
|
168
|
+
</span>
|
|
169
|
+
) : (
|
|
170
|
+
<span className={TABLE_HEADER_LABEL_CLASS}>{column.label}</span>
|
|
171
|
+
)}
|
|
147
172
|
{getSortIcon(column)}
|
|
148
173
|
</>
|
|
149
174
|
)}
|
|
@@ -22,6 +22,13 @@ export interface TableColumn<T = TableRowData> {
|
|
|
22
22
|
hideAt?: TailwindBreakpoint | TailwindBreakpoint[];
|
|
23
23
|
renderCell?: (item: T, column: TableColumn<T>) => ReactNode;
|
|
24
24
|
renderHeader?: () => ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* A definition shown in an `InfoHint` beside the header label. The header
|
|
27
|
+
* owns the icon, spacing and accessible name, so a column never needs a
|
|
28
|
+
* hand-rolled `renderHeader` just to explain itself. Ignored when
|
|
29
|
+
* `renderHeader` is set — a custom header owns its whole contents.
|
|
30
|
+
*/
|
|
31
|
+
hint?: ReactNode;
|
|
25
32
|
className?: string;
|
|
26
33
|
// Sorting
|
|
27
34
|
sortKey?: string;
|