@astryxdesign/cli 0.7.11 → 0.7.12-canary.0edaed8
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/api/build/kit/rank.mjs +21 -4
- package/api/build/kit/words.d.mts +1 -0
- package/api/build/kit/words.mjs +1 -1
- package/api/component/__fixtures__/resolutions/modules.txt +3 -3
- package/api/docs/_adapter.d.mts +22 -0
- package/api/docs/_adapter.mjs +81 -3
- package/api/docs/docs.doc.mjs +5 -5
- package/api/docs/docs.type.d.mts +21 -0
- package/api/docs/docs.type.mjs +11 -0
- package/api/docs/list/list.d.mts +5 -1
- package/api/docs/list/list.mjs +72 -6
- package/api/docs/node/node.mjs +2 -40
- package/api/icon/_adapter.d.mts +3 -2
- package/api/icon/_adapter.mjs +8 -2
- package/api/icon/_authoring.d.mts +1 -0
- package/api/icon/_authoring.mjs +586 -66
- package/api/icon/_default-look.d.mts +155 -0
- package/api/icon/_default-look.mjs +474 -0
- package/api/icon/_records.d.mts +1 -1
- package/api/icon/_records.mjs +1 -0
- package/api/icon/add/add.mjs +224 -38
- package/api/icon/icon.type.d.mts +22 -2
- package/api/icon/icon.type.mjs +6 -2
- package/api/icon/iconAdd.doc.mjs +2 -2
- package/api/icon/iconNewDefinition.doc.mjs +3 -2
- package/api/icon/iconNewSet.doc.mjs +4 -4
- package/api/icon/search/search.mjs +10 -9
- package/api/index.d.mts +1 -0
- package/api/index.mjs +1 -0
- package/api/integration/add-helpers.d.mts +11 -1
- package/api/integration/add-helpers.mjs +5 -2
- package/api/integration/authoring-checks.d.mts +0 -2
- package/api/integration/authoring-checks.mjs +1 -6
- package/api/logger.mjs +2 -1
- package/api/render/_adapter.mjs +9 -0
- package/api/render/render.doc.mjs +2 -2
- package/api/search/_adapter.d.mts +22 -1
- package/api/search/_adapter.mjs +37 -20
- package/api/search/exportSearchIndex.doc.d.mts +10 -0
- package/api/search/exportSearchIndex.doc.mjs +58 -0
- package/api/search/rankSearchIndex.doc.d.mts +10 -0
- package/api/search/rankSearchIndex.doc.mjs +79 -0
- package/api/search/search-index.d.mts +44 -0
- package/api/search/search-index.mjs +270 -0
- package/api/search/search.type.d.mts +28 -0
- package/api/search/search.type.mjs +17 -0
- package/api/swizzle/_adapter.d.mts +1 -0
- package/api/swizzle/_adapter.mjs +4 -1
- package/api/swizzle/_moduleGraph.d.mts +178 -0
- package/api/swizzle/_moduleGraph.mjs +903 -0
- package/api/swizzle/copy/copy.d.mts +2 -43
- package/api/swizzle/copy/copy.mjs +287 -315
- package/api/swizzle/swizzle.d.mts +0 -2
- package/api/swizzle/swizzle.doc.mjs +13 -4
- package/api/swizzle/swizzle.mjs +3 -7
- package/api/swizzle/swizzle.type.d.mts +7 -1
- package/api/swizzle/swizzle.type.mjs +4 -2
- package/api/template/template.mjs +1 -0
- package/assets/discover/official-packages.json +32 -0
- package/assets/docs/browser-support.doc.mjs +2 -2
- package/assets/docs/styling-overview.doc.mjs +4 -0
- package/assets/docs/tree/icon-sets.doc.mjs +11 -5
- package/assets/docs/tree/render-pages.doc.mjs +2 -2
- package/assets/docs/tree/type-scale.doc.mjs +19 -2
- package/assets/templates/blocks/components/Calendar/useCalendarConstraintsHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Calendar/useCalendarConstraintsHookUsage.tsx +146 -0
- package/assets/templates/blocks/components/Calendar/useCalendarNavigationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Calendar/useCalendarNavigationHookUsage.tsx +173 -0
- package/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.tsx +1 -0
- package/assets/templates/blocks/components/Table/RowsVirtualizationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/RowsVirtualizationHookUsage.tsx +35 -0
- package/assets/templates/blocks/components/Table/TableRowIndexTable.doc.mjs +1 -1
- package/assets/templates/blocks/components/Table/TableRowIndexTable.tsx +2 -2
- package/assets/templates/blocks/components/Table/useTableColumnSettingsStateHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/useTableColumnSettingsStateHookUsage.tsx +97 -0
- package/assets/templates/pages/course-detail/page.tsx +699 -0
- package/assets/templates/pages/course-detail/template.doc.mjs +37 -0
- package/assets/templates/pages/file-explorer/page.tsx +103 -79
- package/assets/templates/pages/table-filter/page.tsx +15 -23
- package/assets/templates/pages/table-grouped/page.tsx +160 -232
- package/assets/templates/pages/table-grouped/template.doc.mjs +0 -2
- package/assets/templates/pages/table-inbox/page.tsx +3 -6
- package/assets/templates/pages/theme-showcase/page.tsx +724 -792
- package/assets/templates/pages/theme-showcase/template.doc.mjs +4 -5
- package/assets/templates/themes/butter/butterTheme.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +1 -1
- package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
- package/authoring/doctypes/template/type.ts +1 -0
- package/clients/cli/commands/docs.doc.mjs +5 -1
- package/clients/cli/commands/docs.mjs +30 -2
- package/clients/cli/commands/experimental/icon.mjs +31 -10
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +2 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +2 -2
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +33 -9
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/doc-types.mjs +9 -2
- package/foundation/discovery/hook-discovery.mjs +31 -8
- package/foundation/discovery/icon-ranking.d.mts +27 -3
- package/foundation/discovery/icon-ranking.mjs +125 -8
- package/foundation/discovery/icon-set-checks.mjs +44 -35
- package/foundation/discovery/icon-set-discovery.d.mts +13 -0
- package/foundation/discovery/icon-set-discovery.mjs +25 -0
- package/foundation/discovery/icon-set-writer.d.mts +238 -16
- package/foundation/discovery/icon-set-writer.mjs +676 -79
- package/foundation/discovery/module-exports.d.mts +3 -2
- package/foundation/discovery/module-exports.mjs +167 -37
- package/foundation/fs/paths.d.mts +2 -1
- package/foundation/fs/paths.mjs +3 -4
- package/foundation/render/charts.d.mts +59 -0
- package/foundation/render/charts.mjs +216 -0
- package/foundation/render/embedded-imports.d.mts +7 -7
- package/foundation/render/embedded-imports.mjs +63 -54
- package/foundation/render/page-worker.mjs +339 -52
- package/foundation/render/render-page.mjs +26 -10
- package/foundation/render/ts-paths.d.mts +63 -0
- package/foundation/render/ts-paths.mjs +138 -0
- package/foundation/response/error-codes.doc.mjs +2 -2
- package/foundation/response/error-codes.mjs +3 -2
- package/foundation/text/levenshtein.d.mts +6 -1
- package/foundation/text/levenshtein.mjs +25 -9
- package/foundation/text/shell-arg.d.mts +14 -0
- package/foundation/text/shell-arg.mjs +17 -0
- package/foundation/text/suggest-order.d.mts +8 -1
- package/foundation/text/suggest-order.mjs +72 -6
- package/package.json +7 -6
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useEffect, useRef, useState} from 'react';
|
|
6
|
+
import {
|
|
7
|
+
useCalendarDays,
|
|
8
|
+
useCalendarNavigation,
|
|
9
|
+
type CalendarDay,
|
|
10
|
+
type ISODateString,
|
|
11
|
+
} from '@astryxdesign/core/Calendar';
|
|
12
|
+
import {Button} from '@astryxdesign/core/Button';
|
|
13
|
+
import {HStack, VStack} from '@astryxdesign/core/Layout';
|
|
14
|
+
import {Text} from '@astryxdesign/core/Text';
|
|
15
|
+
|
|
16
|
+
export default function UseCalendarNavigationHookUsage() {
|
|
17
|
+
const [focusDate, setFocusDate] = useState<ISODateString>(
|
|
18
|
+
'2026-06-01' as ISODateString,
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
monthYearLabel,
|
|
23
|
+
visibleCalendarMonths,
|
|
24
|
+
navigateMonth,
|
|
25
|
+
pendingFocus,
|
|
26
|
+
clearPendingFocus,
|
|
27
|
+
} = useCalendarNavigation({
|
|
28
|
+
focusDate,
|
|
29
|
+
onFocusDateChange: setFocusDate,
|
|
30
|
+
numberOfMonths: 1,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const {weeks, dayNames} = useCalendarDays({
|
|
34
|
+
...visibleCalendarMonths[0],
|
|
35
|
+
weekStartsOn: 0,
|
|
36
|
+
hasVariableRowCount: true,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const dayButtonRefs = useRef<Map<string, HTMLButtonElement>>(new Map());
|
|
40
|
+
|
|
41
|
+
// Move focus to target date when navigating across month boundaries
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (pendingFocus) {
|
|
44
|
+
const el = dayButtonRefs.current.get(pendingFocus);
|
|
45
|
+
if (el) {
|
|
46
|
+
el.focus();
|
|
47
|
+
clearPendingFocus();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, [pendingFocus, clearPendingFocus, weeks]);
|
|
51
|
+
|
|
52
|
+
// Arrow key navigation moving across days and month boundaries with RTL awareness (DR6, DR11)
|
|
53
|
+
const handleKeyDown = (
|
|
54
|
+
e: React.KeyboardEvent<HTMLButtonElement>,
|
|
55
|
+
day: CalendarDay,
|
|
56
|
+
) => {
|
|
57
|
+
if (day.isOutside) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const isRtl =
|
|
62
|
+
typeof window !== 'undefined' &&
|
|
63
|
+
getComputedStyle(e.currentTarget).direction === 'rtl';
|
|
64
|
+
|
|
65
|
+
const isNext = isRtl ? e.key === 'ArrowLeft' : e.key === 'ArrowRight';
|
|
66
|
+
const isPrev = isRtl ? e.key === 'ArrowRight' : e.key === 'ArrowLeft';
|
|
67
|
+
|
|
68
|
+
if (isNext) {
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
const inMonthDays = weeks.flatMap(w => w.filter(d => !d.isOutside));
|
|
71
|
+
const currentIndex = inMonthDays.findIndex(d => d.iso === day.iso);
|
|
72
|
+
if (currentIndex === inMonthDays.length - 1) {
|
|
73
|
+
// Last day of month: advance month and focus next day across boundary
|
|
74
|
+
navigateMonth(1, day.iso, 1);
|
|
75
|
+
} else {
|
|
76
|
+
const nextDay = inMonthDays[currentIndex + 1];
|
|
77
|
+
dayButtonRefs.current.get(nextDay.iso)?.focus();
|
|
78
|
+
}
|
|
79
|
+
} else if (isPrev) {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
const inMonthDays = weeks.flatMap(w => w.filter(d => !d.isOutside));
|
|
82
|
+
const currentIndex = inMonthDays.findIndex(d => d.iso === day.iso);
|
|
83
|
+
if (currentIndex === 0) {
|
|
84
|
+
// First day of month: step back month and focus previous day across boundary
|
|
85
|
+
navigateMonth(-1, day.iso, 1);
|
|
86
|
+
} else {
|
|
87
|
+
const prevDay = inMonthDays[currentIndex - 1];
|
|
88
|
+
dayButtonRefs.current.get(prevDay.iso)?.focus();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<VStack gap={3} style={{width: 280}}>
|
|
95
|
+
<HStack gap={2} vAlign="center" hAlign="between">
|
|
96
|
+
<Button
|
|
97
|
+
label="Previous"
|
|
98
|
+
size="sm"
|
|
99
|
+
variant="secondary"
|
|
100
|
+
onClick={() => navigateMonth(-1)}
|
|
101
|
+
aria-label="Previous month"
|
|
102
|
+
/>
|
|
103
|
+
<Text type="body" weight="bold">
|
|
104
|
+
{monthYearLabel}
|
|
105
|
+
</Text>
|
|
106
|
+
<Button
|
|
107
|
+
label="Next"
|
|
108
|
+
size="sm"
|
|
109
|
+
variant="secondary"
|
|
110
|
+
onClick={() => navigateMonth(1)}
|
|
111
|
+
aria-label="Next month"
|
|
112
|
+
/>
|
|
113
|
+
</HStack>
|
|
114
|
+
|
|
115
|
+
<table style={{tableLayout: 'fixed', width: 280}}>
|
|
116
|
+
<thead>
|
|
117
|
+
<tr>
|
|
118
|
+
{dayNames.map((name, i) => (
|
|
119
|
+
<th key={i} scope="col">
|
|
120
|
+
<Text type="supporting" color="secondary">
|
|
121
|
+
{name}
|
|
122
|
+
</Text>
|
|
123
|
+
</th>
|
|
124
|
+
))}
|
|
125
|
+
</tr>
|
|
126
|
+
</thead>
|
|
127
|
+
<tbody>
|
|
128
|
+
{weeks.map(week => (
|
|
129
|
+
<tr key={week[0].iso}>
|
|
130
|
+
{week.map(day => (
|
|
131
|
+
<td key={day.iso} align="center">
|
|
132
|
+
<button
|
|
133
|
+
type="button"
|
|
134
|
+
ref={el => {
|
|
135
|
+
if (el) {
|
|
136
|
+
dayButtonRefs.current.set(day.iso, el);
|
|
137
|
+
} else {
|
|
138
|
+
dayButtonRefs.current.delete(day.iso);
|
|
139
|
+
}
|
|
140
|
+
}}
|
|
141
|
+
disabled={day.isOutside}
|
|
142
|
+
aria-hidden={day.isOutside || undefined}
|
|
143
|
+
onKeyDown={e => handleKeyDown(e, day)}
|
|
144
|
+
aria-label={
|
|
145
|
+
day.isOutside
|
|
146
|
+
? undefined
|
|
147
|
+
: `${monthYearLabel} ${day.dayNumber}`
|
|
148
|
+
}
|
|
149
|
+
tabIndex={day.isOutside ? -1 : 0}
|
|
150
|
+
style={{
|
|
151
|
+
width: 32,
|
|
152
|
+
height: 32,
|
|
153
|
+
borderRadius: 6,
|
|
154
|
+
border: 'none',
|
|
155
|
+
background: 'transparent',
|
|
156
|
+
opacity: day.isOutside ? 0.35 : 1,
|
|
157
|
+
cursor: day.isOutside ? 'not-allowed' : 'pointer',
|
|
158
|
+
}}>
|
|
159
|
+
<Text
|
|
160
|
+
type="body"
|
|
161
|
+
color={day.isOutside ? 'secondary' : 'primary'}>
|
|
162
|
+
{day.dayNumber}
|
|
163
|
+
</Text>
|
|
164
|
+
</button>
|
|
165
|
+
</td>
|
|
166
|
+
))}
|
|
167
|
+
</tr>
|
|
168
|
+
))}
|
|
169
|
+
</tbody>
|
|
170
|
+
</table>
|
|
171
|
+
</VStack>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
|
|
4
|
+
export const doc = {
|
|
5
|
+
type: 'block',
|
|
6
|
+
exampleFor: 'useTableRowsVirtualization',
|
|
7
|
+
name: 'useTableRowsVirtualization - Fixed Height Rows',
|
|
8
|
+
displayName: 'useTableRowsVirtualization - Fixed Height Rows',
|
|
9
|
+
description:
|
|
10
|
+
'A Table with 1,000 product rows in a fixed-height viewport. Scroll vertically to mount the visible rows. The caller keeps all data and columns; this hook does not virtualize columns.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
aspectRatio: 16 / 9,
|
|
13
|
+
componentsUsed: ['Table'],
|
|
14
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Table,
|
|
7
|
+
useTableRowsVirtualization,
|
|
8
|
+
type TableColumn,
|
|
9
|
+
} from '@astryxdesign/core/Table';
|
|
10
|
+
|
|
11
|
+
interface Product extends Record<string, unknown> {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const products: Product[] = Array.from({length: 1000}, (_, index) => ({
|
|
17
|
+
id: `product-${index}`,
|
|
18
|
+
name: `Product ${index + 1}`,
|
|
19
|
+
}));
|
|
20
|
+
const columns: TableColumn<Product>[] = [{key: 'name', header: 'Product'}];
|
|
21
|
+
|
|
22
|
+
export default function RowsVirtualizationHookUsage() {
|
|
23
|
+
const virtualization = useTableRowsVirtualization({
|
|
24
|
+
rowHeight: 56,
|
|
25
|
+
viewportHeight: 320,
|
|
26
|
+
});
|
|
27
|
+
return (
|
|
28
|
+
<Table
|
|
29
|
+
data={products}
|
|
30
|
+
columns={columns}
|
|
31
|
+
idKey="id"
|
|
32
|
+
virtualization={virtualization}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -7,7 +7,7 @@ export const doc = {
|
|
|
7
7
|
name: 'useTableRowIndex — Numbered Rows',
|
|
8
8
|
displayName: 'useTableRowIndex — Numbered Rows',
|
|
9
9
|
description:
|
|
10
|
-
'A table with a prepended row-number column via useTableRowIndex. Numbering is monospaced, right-aligned, and follows the
|
|
10
|
+
'A table with a prepended row-number column via useTableRowIndex. Numbering is monospaced, right-aligned, and follows the rows the table renders.',
|
|
11
11
|
isReady: true,
|
|
12
12
|
aspectRatio: 16 / 9,
|
|
13
13
|
componentsUsed: ['Table'],
|
|
@@ -32,8 +32,8 @@ const columns: TableColumn<Track>[] = [
|
|
|
32
32
|
];
|
|
33
33
|
|
|
34
34
|
export default function TableRowIndexTable() {
|
|
35
|
-
//
|
|
36
|
-
const rowIndex = useTableRowIndex<Track>(
|
|
35
|
+
// Table gives each row its position, so numbering follows the rendered rows.
|
|
36
|
+
const rowIndex = useTableRowIndex<Track>();
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
<Table
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
|
|
4
|
+
export const doc = {
|
|
5
|
+
type: 'block',
|
|
6
|
+
exampleFor: 'useTableColumnSettingsState',
|
|
7
|
+
name: 'useTableColumnSettingsState — Column Visibility Picker',
|
|
8
|
+
displayName: 'useTableColumnSettingsState — Column Visibility Picker',
|
|
9
|
+
description:
|
|
10
|
+
'A Table toolbar with a Columns menu of checkboxes: toggling Email updates active columns, Reset restores defaults, and the config is passed directly to useTableColumnSettings.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
aspectRatio: 16 / 9,
|
|
13
|
+
componentsUsed: ['Button', 'CheckboxInput', 'Popover', 'Table', 'Layout'],
|
|
14
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useState} from 'react';
|
|
6
|
+
import {Button} from '@astryxdesign/core/Button';
|
|
7
|
+
import {CheckboxInput} from '@astryxdesign/core/CheckboxInput';
|
|
8
|
+
import {HStack, VStack} from '@astryxdesign/core/Layout';
|
|
9
|
+
import {Popover} from '@astryxdesign/core/Popover';
|
|
10
|
+
import {
|
|
11
|
+
Table,
|
|
12
|
+
useTableColumnSettings,
|
|
13
|
+
useTableColumnSettingsState,
|
|
14
|
+
} from '@astryxdesign/core/Table';
|
|
15
|
+
import type {TableColumn} from '@astryxdesign/core/Table';
|
|
16
|
+
|
|
17
|
+
interface Member extends Record<string, unknown> {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
email: string;
|
|
21
|
+
role: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const members: Member[] = [
|
|
25
|
+
{id: '1', name: 'Alice', email: 'alice@example.com', role: 'Engineer'},
|
|
26
|
+
{id: '2', name: 'Bob', email: 'bob@example.com', role: 'Designer'},
|
|
27
|
+
{id: '3', name: 'Charlie', email: 'charlie@example.com', role: 'Manager'},
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const allColumns: TableColumn<Member>[] = [
|
|
31
|
+
{key: 'name', header: 'Name'},
|
|
32
|
+
{key: 'email', header: 'Email'},
|
|
33
|
+
{key: 'role', header: 'Role'},
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const columnOptions = [
|
|
37
|
+
{key: 'name' as const, label: 'Name', isAlwaysVisible: true},
|
|
38
|
+
{key: 'email' as const, label: 'Email'},
|
|
39
|
+
{key: 'role' as const, label: 'Role'},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const defaultKeys = ['name', 'email', 'role'];
|
|
43
|
+
|
|
44
|
+
export default function UseTableColumnSettingsStateHookUsage() {
|
|
45
|
+
const [activeKeys, setActiveKeys] =
|
|
46
|
+
useState<ReadonlyArray<string>>(defaultKeys);
|
|
47
|
+
|
|
48
|
+
const state = useTableColumnSettingsState({
|
|
49
|
+
columns: columnOptions,
|
|
50
|
+
activeColumnKeys: activeKeys,
|
|
51
|
+
onChangeActiveColumnKeys: setActiveKeys,
|
|
52
|
+
defaultColumnKeys: defaultKeys,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const plugin = useTableColumnSettings<Member>(state.columnSettingsConfig);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<VStack gap={3}>
|
|
59
|
+
<HStack hAlign="start">
|
|
60
|
+
<Popover
|
|
61
|
+
placement="below"
|
|
62
|
+
label="Column settings"
|
|
63
|
+
width={200}
|
|
64
|
+
content={
|
|
65
|
+
<VStack gap={2}>
|
|
66
|
+
{columnOptions.map(col => (
|
|
67
|
+
<CheckboxInput
|
|
68
|
+
key={col.key}
|
|
69
|
+
label={col.label}
|
|
70
|
+
value={state.isColumnActive(col.key)}
|
|
71
|
+
isDisabled={!state.isColumnToggleable(col.key)}
|
|
72
|
+
onChange={() => state.toggleColumn(col.key)}
|
|
73
|
+
/>
|
|
74
|
+
))}
|
|
75
|
+
<Button
|
|
76
|
+
label="Reset"
|
|
77
|
+
size="sm"
|
|
78
|
+
variant="secondary"
|
|
79
|
+
onClick={state.resetToDefault}>
|
|
80
|
+
Reset
|
|
81
|
+
</Button>
|
|
82
|
+
</VStack>
|
|
83
|
+
}>
|
|
84
|
+
<Button label="Columns" size="sm">
|
|
85
|
+
Columns
|
|
86
|
+
</Button>
|
|
87
|
+
</Popover>
|
|
88
|
+
</HStack>
|
|
89
|
+
<Table
|
|
90
|
+
data={members}
|
|
91
|
+
columns={allColumns}
|
|
92
|
+
idKey="id"
|
|
93
|
+
plugins={{columnSettings: plugin}}
|
|
94
|
+
/>
|
|
95
|
+
</VStack>
|
|
96
|
+
);
|
|
97
|
+
}
|