-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathaction-render.tsx
More file actions
81 lines (75 loc) · 1.88 KB
/
action-render.tsx
File metadata and controls
81 lines (75 loc) · 1.88 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
73
74
75
76
77
78
79
80
81
import type { KoliBriTableCell, KoliBriTableHeaderCellWithLogic } from '@public-ui/components';
import { KolTableStateful } from '@public-ui/react-v19';
import type { FC } from 'react';
import React from 'react';
import { SampleDescription } from '../SampleDescription';
type ProjectTask = {
id: string;
project: string;
owner: string;
react: string;
};
const HEADERS: { horizontal: KoliBriTableHeaderCellWithLogic[][] } = {
horizontal: [
[
{ key: 'project', label: 'Project' },
{ key: 'owner', label: 'Owner', width: 140 },
{
label: 'ID',
key: 'id',
width: 100,
render: (_el, cell: KoliBriTableCell) => {
const { label } = cell as { label: string };
return `Index: ${label}`;
},
},
{
type: 'action',
key: 'actions',
label: 'Actions',
width: 100,
actions: (row) => {
const simpleRow = row as ProjectTask;
return [
{
type: 'button',
_label: 'Details',
_icons: 'kolicon-eye',
_hideLabel: true,
_on: {
onClick: () => alert(`Details: ${simpleRow.id} - ${simpleRow.project}`),
},
},
];
},
},
],
],
};
const DATA: ProjectTask[] = [
{
id: 'T-01',
project: 'Onboarding checklist',
owner: 'Alex Rivera',
react: 'test',
},
{
id: 'T-02',
project: 'Accessibility audit',
owner: 'Jamie Chen',
react: 'test',
},
];
export const TableActionAndRenderColumns: FC = () => (
<>
<SampleDescription>
<p>
Simple example using the refactored action column: Actions are defined once in the column header definition using a factory function. Two rows with
inline action buttons demonstrate clean separation between data and UI behavior.
</p>
</SampleDescription>
<section className="w-full">
<KolTableStateful _label="Tasks with action buttons" _headers={HEADERS} _data={DATA} className="block" _hasSettingsMenu />
</section>
</>
);