-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathuseTableGroupedRows.doc.mjs
More file actions
72 lines (69 loc) · 3.07 KB
/
Copy pathuseTableGroupedRows.doc.mjs
File metadata and controls
72 lines (69 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) Meta Platforms, Inc. and affiliates.
/** @type {import('@astryxdesign/cli/authoring').ComponentDoc} */
export const docs = {
name: 'useTableGroupedRows',
subComponentOf: 'Table',
displayName: 'useTableGroupedRows',
description:
"Hook that groups a flat data array into collapsible section rows. Each distinct groupBy value becomes a full-width section-header row with a chevron toggle, the group label, and a member count; collapsing hides that group's data rows while keeping the header visible. Mirrors useTableTreeState: the consumer owns the collapsedGroups set and the hook returns {data, plugin, idKey, isGroupHeader}: pass the first three to Table (data, plugins, and idKey respectively), and use isGroupHeader to guard any row-level plugin or handler of your own that would otherwise treat a synthetic header as a real row.",
props: [
{
name: 'data',
type: 'T[]',
description: 'The flat data to group.',
required: true,
},
{
name: 'groupBy',
type: '(item: T) => string',
description:
'Derive the group key for a row. Rows with the same key share a section.',
required: true,
},
{
name: 'collapsedGroups',
type: 'Set<string>',
description: 'Set of currently-collapsed group keys.',
required: true,
},
{
name: 'onToggleGroup',
type: '(groupKey: string) => void',
description: 'Called with a group key when its header is toggled.',
required: true,
},
{
name: 'renderGroupHeader',
type: '(groupKey: string, count: number, collapsed: boolean) => ReactNode',
description:
"Custom renderer for a group header's content (right of the chevron). Defaults to `<groupKey> (<count>)`.",
},
{
name: 'getRowKey',
type: '(item: T) => string',
description:
'Stable key for a real row. Falls back to a positional key when omitted.',
},
{
name: 'groupOrder',
type: 'string[]',
description:
'Explicit group ordering; groups not listed keep first-seen order after these.',
},
],
};
/** @type {import('@astryxdesign/cli/authoring').ComponentTranslationDoc} */
export const docsDense = {
description:
'Groups a flat data array into collapsible section rows. Each groupBy value becomes a full-width header (chevron + label + count); collapsing hides its rows. Returns {data, plugin, idKey, isGroupHeader}: pass the first three to Table data / plugins / idKey; use isGroupHeader to guard your own row-level plugins. Consumer owns the collapsedGroups set.',
propDescriptions: {
data: 'The flat data to group.',
groupBy: "Derive a row's group key. Same key = same section.",
collapsedGroups: 'Set of currently-collapsed group keys.',
onToggleGroup: 'Called with the group key when a header is toggled.',
renderGroupHeader:
"Custom header content (right of chevron). Default '<key> (<count>)'.",
getRowKey: 'Stable key for a real row; positional fallback when omitted.',
groupOrder: 'Pin these group keys first; others keep first-seen order.',
},
};