@umituz/web-dashboard 11.11.0 → 11.13.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/package.json +17 -1
- package/src/domains/activity/activity.css +229 -0
- package/src/domains/activity/components/ActivityFeed.test.tsx +61 -0
- package/src/domains/activity/components/ActivityFeed.tsx +132 -0
- package/src/domains/activity/components/ActivityTimeline.tsx +127 -0
- package/src/domains/activity/components/index.ts +2 -0
- package/src/domains/activity/index.ts +3 -0
- package/src/domains/activity/types.ts +59 -0
- package/src/domains/activity/utils.ts +73 -0
- package/src/domains/filters/components/DataToolbar.test.tsx +65 -0
- package/src/domains/filters/components/DataToolbar.tsx +119 -0
- package/src/domains/filters/components/index.ts +1 -0
- package/src/domains/filters/filters.css +128 -0
- package/src/domains/filters/index.ts +2 -0
- package/src/domains/filters/types.ts +48 -0
- package/src/domains/kanban/components/KanbanBoard.test.tsx +226 -0
- package/src/domains/kanban/components/KanbanBoard.tsx +135 -0
- package/src/domains/kanban/components/KanbanCard.tsx +160 -0
- package/src/domains/kanban/components/KanbanColumn.tsx +163 -0
- package/src/domains/kanban/components/KanbanPage.test.tsx +115 -0
- package/src/domains/kanban/components/KanbanPage.tsx +91 -0
- package/src/domains/kanban/components/index.ts +4 -0
- package/src/domains/kanban/index.ts +12 -0
- package/src/domains/kanban/kanban.css +406 -0
- package/src/domains/kanban/types.ts +103 -0
- package/src/domains/pages/components/DetailPage.test.tsx +96 -0
- package/src/domains/pages/components/DetailPage.tsx +227 -0
- package/src/domains/pages/components/index.ts +1 -0
- package/src/domains/pages/types.ts +60 -0
- package/src/domains/stepper/components/Stepper.test.tsx +71 -0
- package/src/domains/stepper/components/Stepper.tsx +74 -0
- package/src/domains/stepper/components/Wizard.tsx +84 -0
- package/src/domains/stepper/components/index.ts +2 -0
- package/src/domains/stepper/index.ts +2 -0
- package/src/domains/stepper/stepper.css +145 -0
- package/src/domains/stepper/types.ts +38 -0
- package/src/index.ts +4 -0
- package/src/styles/dashboard.css +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-dashboard",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.13.0",
|
|
4
4
|
"description": "Installable app skeleton for the fleet — layouts, analytics (dependency-free SVG charts), calendar, onboarding flow permissions/module registry; udb-* stylesheet on design-system tokens",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
],
|
|
11
11
|
"exports": {
|
|
12
12
|
".": "./src/index.ts",
|
|
13
|
+
"./activity": "./src/domains/activity/index.ts",
|
|
14
|
+
"./activity/activity.css": "./src/domains/activity/activity.css",
|
|
15
|
+
"./activity/components": "./src/domains/activity/components/index.ts",
|
|
16
|
+
"./activity/types": "./src/domains/activity/types.ts",
|
|
13
17
|
"./analytics": "./src/domains/analytics/index.ts",
|
|
14
18
|
"./analytics/components": "./src/domains/analytics/components/index.ts",
|
|
15
19
|
"./analytics/hooks": "./src/domains/analytics/hooks/index.ts",
|
|
@@ -25,6 +29,14 @@
|
|
|
25
29
|
"./calendar/utils": "./src/domains/calendar/utils/index.ts",
|
|
26
30
|
"./chrome.css": "./src/styles/chrome.css",
|
|
27
31
|
"./config": "./src/config/index.ts",
|
|
32
|
+
"./filters": "./src/domains/filters/index.ts",
|
|
33
|
+
"./filters/filters.css": "./src/domains/filters/filters.css",
|
|
34
|
+
"./filters/components": "./src/domains/filters/components/index.ts",
|
|
35
|
+
"./filters/types": "./src/domains/filters/types.ts",
|
|
36
|
+
"./kanban": "./src/domains/kanban/index.ts",
|
|
37
|
+
"./kanban/kanban.css": "./src/domains/kanban/kanban.css",
|
|
38
|
+
"./kanban/components": "./src/domains/kanban/components/index.ts",
|
|
39
|
+
"./kanban/types": "./src/domains/kanban/types.ts",
|
|
28
40
|
"./layouts": "./src/domains/layouts/index.ts",
|
|
29
41
|
"./layouts/components": "./src/domains/layouts/components/index.ts",
|
|
30
42
|
"./layouts/hooks": "./src/domains/layouts/hooks/index.ts",
|
|
@@ -46,6 +58,10 @@
|
|
|
46
58
|
"./settings/hooks": "./src/domains/settings/hooks/index.ts",
|
|
47
59
|
"./settings/types": "./src/domains/settings/types/index.ts",
|
|
48
60
|
"./settings/utils": "./src/domains/settings/utils/index.ts",
|
|
61
|
+
"./stepper": "./src/domains/stepper/index.ts",
|
|
62
|
+
"./stepper/stepper.css": "./src/domains/stepper/stepper.css",
|
|
63
|
+
"./stepper/components": "./src/domains/stepper/components/index.ts",
|
|
64
|
+
"./stepper/types": "./src/domains/stepper/types.ts",
|
|
49
65
|
"./timing": "./src/domains/timing/index.ts",
|
|
50
66
|
"./timing/hooks": "./src/domains/timing/hooks/index.ts",
|
|
51
67
|
"./tour": "./src/domains/tour/index.ts",
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
.udb-activity-feed {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.udb-activity-day-group {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.udb-activity-day-header {
|
|
14
|
+
font-size: 11px;
|
|
15
|
+
font-weight: 700;
|
|
16
|
+
text-transform: uppercase;
|
|
17
|
+
letter-spacing: 0.05em;
|
|
18
|
+
color: var(--text-tertiary, #94a3b8);
|
|
19
|
+
padding: 12px 0 6px;
|
|
20
|
+
position: sticky;
|
|
21
|
+
top: 0;
|
|
22
|
+
background: var(--surface, #ffffff);
|
|
23
|
+
z-index: 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.udb-activity-item {
|
|
27
|
+
display: flex;
|
|
28
|
+
gap: 12px;
|
|
29
|
+
padding: 12px 0;
|
|
30
|
+
border-bottom: 1px solid var(--line-border, rgba(0, 0, 0, 0.06));
|
|
31
|
+
align-items: flex-start;
|
|
32
|
+
transition: background-color 0.15s ease;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.udb-activity-item:last-child {
|
|
36
|
+
border-bottom: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.udb-activity-item--clickable {
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
padding-left: 8px;
|
|
42
|
+
padding-right: 8px;
|
|
43
|
+
border-radius: var(--r-md, 8px);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.udb-activity-item--clickable:hover {
|
|
47
|
+
background-color: var(--surface-hover, rgba(0, 0, 0, 0.03));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.udb-activity-item--dense {
|
|
51
|
+
padding: 8px 0;
|
|
52
|
+
gap: 8px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.udb-activity-icon {
|
|
56
|
+
display: inline-flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
width: 32px;
|
|
60
|
+
height: 32px;
|
|
61
|
+
border-radius: var(--r-md, 8px);
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
background: var(--surface-secondary, rgba(0, 0, 0, 0.04));
|
|
64
|
+
color: var(--text-secondary, #64748b);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.udb-activity-item--dense .udb-activity-icon {
|
|
68
|
+
width: 26px;
|
|
69
|
+
height: 26px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.udb-activity-tone--primary {
|
|
73
|
+
background: color-mix(in oklab, var(--signal-600, #3b82f6) 12%, transparent);
|
|
74
|
+
color: var(--signal-600, #3b82f6);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.udb-activity-tone--success {
|
|
78
|
+
background: color-mix(in oklab, #10b981 12%, transparent);
|
|
79
|
+
color: #10b981;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.udb-activity-tone--warning {
|
|
83
|
+
background: color-mix(in oklab, #f59e0b 12%, transparent);
|
|
84
|
+
color: #f59e0b;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.udb-activity-tone--danger {
|
|
88
|
+
background: color-mix(in oklab, #ef4444 12%, transparent);
|
|
89
|
+
color: #ef4444;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.udb-activity-tone--info {
|
|
93
|
+
background: color-mix(in oklab, #06b6d4 12%, transparent);
|
|
94
|
+
color: #06b6d4;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.udb-activity-tone--violet {
|
|
98
|
+
background: color-mix(in oklab, #8b5cf6 12%, transparent);
|
|
99
|
+
color: #8b5cf6;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.udb-activity-tone--neutral {
|
|
103
|
+
background: var(--surface-secondary, rgba(0, 0, 0, 0.05));
|
|
104
|
+
color: var(--text-tertiary, #64748b);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.udb-activity-body {
|
|
108
|
+
flex: 1;
|
|
109
|
+
min-width: 0;
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-direction: column;
|
|
112
|
+
gap: 3px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.udb-activity-title-row {
|
|
116
|
+
display: flex;
|
|
117
|
+
align-items: baseline;
|
|
118
|
+
justify-content: space-between;
|
|
119
|
+
gap: 8px;
|
|
120
|
+
flex-wrap: wrap;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.udb-activity-title {
|
|
124
|
+
font-size: 13px;
|
|
125
|
+
font-weight: 500;
|
|
126
|
+
color: var(--text-primary, #0f172a);
|
|
127
|
+
line-height: 1.4;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.udb-activity-desc {
|
|
131
|
+
font-size: 13px;
|
|
132
|
+
color: var(--text-secondary, #475569);
|
|
133
|
+
line-height: 1.45;
|
|
134
|
+
margin: 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.udb-activity-meta-row {
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
gap: 6px;
|
|
141
|
+
font-size: 11px;
|
|
142
|
+
color: var(--text-tertiary, #94a3b8);
|
|
143
|
+
flex-wrap: wrap;
|
|
144
|
+
margin-top: 2px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.udb-activity-actor {
|
|
148
|
+
font-weight: 600;
|
|
149
|
+
color: var(--text-secondary, #475569);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.udb-activity-target {
|
|
153
|
+
color: var(--signal-600, #3b82f6);
|
|
154
|
+
text-decoration: none;
|
|
155
|
+
font-weight: 500;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.udb-activity-target:hover {
|
|
159
|
+
text-decoration: underline;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.udb-activity-dot {
|
|
163
|
+
opacity: 0.5;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.udb-activity-timeline {
|
|
167
|
+
display: flex;
|
|
168
|
+
flex-direction: column;
|
|
169
|
+
position: relative;
|
|
170
|
+
width: 100%;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.udb-activity-timeline-item {
|
|
174
|
+
position: relative;
|
|
175
|
+
display: flex;
|
|
176
|
+
gap: 16px;
|
|
177
|
+
padding-bottom: 20px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.udb-activity-timeline-item:last-child {
|
|
181
|
+
padding-bottom: 4px;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.udb-activity-timeline-rail {
|
|
185
|
+
position: absolute;
|
|
186
|
+
left: 11px;
|
|
187
|
+
top: 22px;
|
|
188
|
+
bottom: 0;
|
|
189
|
+
width: 2px;
|
|
190
|
+
background-color: var(--line-border, rgba(0, 0, 0, 0.08));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.udb-activity-timeline-item:last-child .udb-activity-timeline-rail {
|
|
194
|
+
display: none;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.udb-activity-timeline-marker {
|
|
198
|
+
position: relative;
|
|
199
|
+
z-index: 1;
|
|
200
|
+
display: inline-flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
justify-content: center;
|
|
203
|
+
width: 24px;
|
|
204
|
+
height: 24px;
|
|
205
|
+
border-radius: 9999px;
|
|
206
|
+
border: 2px solid var(--surface, #ffffff);
|
|
207
|
+
box-shadow: 0 0 0 1px var(--line-border, rgba(0, 0, 0, 0.1));
|
|
208
|
+
background: var(--surface, #ffffff);
|
|
209
|
+
color: var(--text-secondary, #64748b);
|
|
210
|
+
flex-shrink: 0;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.udb-activity-timeline-content {
|
|
214
|
+
flex: 1;
|
|
215
|
+
min-width: 0;
|
|
216
|
+
padding-top: 2px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.udb-activity-empty {
|
|
220
|
+
display: flex;
|
|
221
|
+
flex-direction: column;
|
|
222
|
+
align-items: center;
|
|
223
|
+
justify-content: center;
|
|
224
|
+
padding: 32px 16px;
|
|
225
|
+
text-align: center;
|
|
226
|
+
color: var(--text-tertiary, #94a3b8);
|
|
227
|
+
font-size: 13px;
|
|
228
|
+
gap: 8px;
|
|
229
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { ActivityFeed } from './ActivityFeed';
|
|
4
|
+
import { ActivityTimeline } from './ActivityTimeline';
|
|
5
|
+
import type { ActivityItem } from '../types';
|
|
6
|
+
|
|
7
|
+
const sampleItems: ActivityItem[] = [
|
|
8
|
+
{
|
|
9
|
+
id: 'act-1',
|
|
10
|
+
timestamp: '2026-11-21T10:00:00Z',
|
|
11
|
+
title: 'Contract signed',
|
|
12
|
+
description: 'Master services agreement executed by client.',
|
|
13
|
+
actor: { name: 'Sarah Connor' },
|
|
14
|
+
target: { label: 'Matter #402', href: '/cases/402' },
|
|
15
|
+
tone: 'success',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'act-2',
|
|
19
|
+
timestamp: '2026-11-20T14:30:00Z',
|
|
20
|
+
title: 'Document uploaded',
|
|
21
|
+
actor: 'John Doe',
|
|
22
|
+
tone: 'info',
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
describe('ActivityFeed', () => {
|
|
27
|
+
it('renders empty state when items array is empty', () => {
|
|
28
|
+
render(<ActivityFeed items={[]} emptyTitle="No events found" emptyDescription="Check back later." />);
|
|
29
|
+
expect(screen.getByText('No events found')).toBeTruthy();
|
|
30
|
+
expect(screen.getByText('Check back later.')).toBeTruthy();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('renders items with titles, actors, and targets', () => {
|
|
34
|
+
render(<ActivityFeed items={sampleItems} groupByDay={false} />);
|
|
35
|
+
expect(screen.getByText('Contract signed')).toBeTruthy();
|
|
36
|
+
expect(screen.getByText('Document uploaded')).toBeTruthy();
|
|
37
|
+
expect(screen.getByText('Sarah Connor')).toBeTruthy();
|
|
38
|
+
expect(screen.getByText('John Doe')).toBeTruthy();
|
|
39
|
+
expect(screen.getByText('Matter #402')).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('handles item clicks when onItemClick is provided', () => {
|
|
43
|
+
const handleClick = vi.fn();
|
|
44
|
+
render(<ActivityFeed items={sampleItems} groupByDay={false} onItemClick={handleClick} />);
|
|
45
|
+
fireEvent.click(screen.getByText('Contract signed'));
|
|
46
|
+
expect(handleClick).toHaveBeenCalledWith(sampleItems[0]);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('ActivityTimeline', () => {
|
|
51
|
+
it('renders empty state when items array is empty', () => {
|
|
52
|
+
render(<ActivityTimeline items={[]} emptyTitle="Empty timeline" />);
|
|
53
|
+
expect(screen.getByText('Empty timeline')).toBeTruthy();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('renders timeline rail and items', () => {
|
|
57
|
+
render(<ActivityTimeline items={sampleItems} groupByDay={false} />);
|
|
58
|
+
expect(screen.getByText('Contract signed')).toBeTruthy();
|
|
59
|
+
expect(screen.getByText('Document uploaded')).toBeTruthy();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { EmptyState } from '@umituz/web-design-system/organisms';
|
|
4
|
+
import { Avatar } from '@umituz/web-design-system/molecules';
|
|
5
|
+
import { cn } from '@umituz/web-design-system/utils';
|
|
6
|
+
import type { ActivityFeedProps, ActivityItem, ActivityTarget } from '../types';
|
|
7
|
+
import { formatActivityRelativeTime, groupActivitiesByDay, toDate } from '../utils';
|
|
8
|
+
|
|
9
|
+
function renderActor(actor: ActivityItem['actor']) {
|
|
10
|
+
if (!actor) return null;
|
|
11
|
+
if (typeof actor === 'string') {
|
|
12
|
+
return <span className="udb-activity-actor">{actor}</span>;
|
|
13
|
+
}
|
|
14
|
+
return (
|
|
15
|
+
<span className="udb-activity-actor" style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}>
|
|
16
|
+
<Avatar name={actor.name} size="xs" />
|
|
17
|
+
<span>{actor.name}</span>
|
|
18
|
+
</span>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function renderTarget(target: ActivityItem['target']) {
|
|
23
|
+
if (!target) return null;
|
|
24
|
+
if (typeof target === 'object' && 'label' in target && !('type' in (target as object))) {
|
|
25
|
+
const t = target as ActivityTarget;
|
|
26
|
+
if (t.href) {
|
|
27
|
+
return (
|
|
28
|
+
<a href={t.href} className="udb-activity-target">
|
|
29
|
+
{t.label}
|
|
30
|
+
</a>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return <span className="udb-activity-target">{t.label}</span>;
|
|
34
|
+
}
|
|
35
|
+
return <span className="udb-activity-target">{target as ReactNode}</span>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function ActivityFeed<T = unknown>({
|
|
39
|
+
items,
|
|
40
|
+
groupByDay = true,
|
|
41
|
+
density = 'normal',
|
|
42
|
+
emptyTitle = 'No activity yet',
|
|
43
|
+
emptyDescription = 'Events and actions will appear here as they happen.',
|
|
44
|
+
emptyIcon,
|
|
45
|
+
onItemClick,
|
|
46
|
+
className,
|
|
47
|
+
}: ActivityFeedProps<T>) {
|
|
48
|
+
const groups = useMemo(() => {
|
|
49
|
+
if (!groupByDay) return [];
|
|
50
|
+
return groupActivitiesByDay(items);
|
|
51
|
+
}, [items, groupByDay]);
|
|
52
|
+
|
|
53
|
+
if (items.length === 0) {
|
|
54
|
+
return (
|
|
55
|
+
<EmptyState
|
|
56
|
+
title={emptyTitle}
|
|
57
|
+
description={emptyDescription}
|
|
58
|
+
icon={emptyIcon}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function renderFeedItem(item: ActivityItem<T>) {
|
|
64
|
+
const d = toDate(item.timestamp);
|
|
65
|
+
const relTime = formatActivityRelativeTime(d);
|
|
66
|
+
const fullTime = d.toLocaleString();
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<article
|
|
70
|
+
key={item.id}
|
|
71
|
+
className={cn(
|
|
72
|
+
'udb-activity-item',
|
|
73
|
+
density === 'dense' && 'udb-activity-item--dense',
|
|
74
|
+
Boolean(onItemClick) && 'udb-activity-item--clickable',
|
|
75
|
+
)}
|
|
76
|
+
onClick={() => onItemClick?.(item)}
|
|
77
|
+
>
|
|
78
|
+
{item.icon && (
|
|
79
|
+
<span
|
|
80
|
+
className={cn(
|
|
81
|
+
'udb-activity-icon',
|
|
82
|
+
item.tone && `udb-activity-tone--${item.tone}`,
|
|
83
|
+
)}
|
|
84
|
+
aria-hidden="true"
|
|
85
|
+
>
|
|
86
|
+
{item.icon}
|
|
87
|
+
</span>
|
|
88
|
+
)}
|
|
89
|
+
|
|
90
|
+
<div className="udb-activity-body">
|
|
91
|
+
<div className="udb-activity-title-row">
|
|
92
|
+
<span className="udb-activity-title">{item.title}</span>
|
|
93
|
+
{item.badge}
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
{item.description && <p className="udb-activity-desc">{item.description}</p>}
|
|
97
|
+
|
|
98
|
+
<div className="udb-activity-meta-row">
|
|
99
|
+
{renderActor(item.actor)}
|
|
100
|
+
{item.actor && item.target && <span className="udb-activity-dot" aria-hidden="true">·</span>}
|
|
101
|
+
{renderTarget(item.target)}
|
|
102
|
+
{(item.actor || item.target) && <span className="udb-activity-dot" aria-hidden="true">·</span>}
|
|
103
|
+
<time dateTime={d.toISOString()} title={fullTime}>
|
|
104
|
+
{relTime}
|
|
105
|
+
</time>
|
|
106
|
+
{item.meta && (
|
|
107
|
+
<>
|
|
108
|
+
<span className="udb-activity-dot" aria-hidden="true">·</span>
|
|
109
|
+
<span>{item.meta}</span>
|
|
110
|
+
</>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
</article>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div className={cn('udb-activity-feed', className)} role="feed" aria-label="Activity feed">
|
|
120
|
+
{groupByDay ? (
|
|
121
|
+
groups.map((group) => (
|
|
122
|
+
<section key={group.dateKey} className="udb-activity-day-group">
|
|
123
|
+
<header className="udb-activity-day-header">{group.label}</header>
|
|
124
|
+
{group.items.map(renderFeedItem)}
|
|
125
|
+
</section>
|
|
126
|
+
))
|
|
127
|
+
) : (
|
|
128
|
+
items.map(renderFeedItem)
|
|
129
|
+
)}
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { EmptyState } from '@umituz/web-design-system/organisms';
|
|
4
|
+
import { cn } from '@umituz/web-design-system/utils';
|
|
5
|
+
import type { ActivityItem, ActivityTarget, ActivityTimelineProps } from '../types';
|
|
6
|
+
import { formatActivityRelativeTime, groupActivitiesByDay, toDate } from '../utils';
|
|
7
|
+
|
|
8
|
+
function renderTarget(target: ActivityItem['target']) {
|
|
9
|
+
if (!target) return null;
|
|
10
|
+
if (typeof target === 'object' && 'label' in target && !('type' in (target as object))) {
|
|
11
|
+
const t = target as ActivityTarget;
|
|
12
|
+
if (t.href) {
|
|
13
|
+
return (
|
|
14
|
+
<a href={t.href} className="udb-activity-target">
|
|
15
|
+
{t.label}
|
|
16
|
+
</a>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return <span className="udb-activity-target">{t.label}</span>;
|
|
20
|
+
}
|
|
21
|
+
return <span className="udb-activity-target">{target as ReactNode}</span>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function ActivityTimeline<T = unknown>({
|
|
25
|
+
items,
|
|
26
|
+
groupByDay = false,
|
|
27
|
+
density = 'normal',
|
|
28
|
+
emptyTitle = 'No activity recorded',
|
|
29
|
+
emptyDescription = 'Events appear here as work progresses.',
|
|
30
|
+
emptyIcon,
|
|
31
|
+
newestFirst = true,
|
|
32
|
+
onItemClick,
|
|
33
|
+
className,
|
|
34
|
+
}: ActivityTimelineProps<T>) {
|
|
35
|
+
const sortedItems = useMemo(() => {
|
|
36
|
+
const arr = [...items];
|
|
37
|
+
return arr.sort((a, b) => {
|
|
38
|
+
const ta = toDate(a.timestamp).getTime();
|
|
39
|
+
const tb = toDate(b.timestamp).getTime();
|
|
40
|
+
return newestFirst ? tb - ta : ta - tb;
|
|
41
|
+
});
|
|
42
|
+
}, [items, newestFirst]);
|
|
43
|
+
|
|
44
|
+
const groups = useMemo(() => {
|
|
45
|
+
if (!groupByDay) return [];
|
|
46
|
+
return groupActivitiesByDay(sortedItems);
|
|
47
|
+
}, [sortedItems, groupByDay]);
|
|
48
|
+
|
|
49
|
+
if (items.length === 0) {
|
|
50
|
+
return (
|
|
51
|
+
<EmptyState
|
|
52
|
+
title={emptyTitle}
|
|
53
|
+
description={emptyDescription}
|
|
54
|
+
icon={emptyIcon}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function renderTimelineItem(item: ActivityItem<T>) {
|
|
60
|
+
const d = toDate(item.timestamp);
|
|
61
|
+
const relTime = formatActivityRelativeTime(d);
|
|
62
|
+
const actorName = typeof item.actor === 'string' ? item.actor : item.actor?.name;
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
key={item.id}
|
|
67
|
+
className={cn(
|
|
68
|
+
'udb-activity-timeline-item',
|
|
69
|
+
density === 'dense' && 'udb-activity-timeline-item--dense',
|
|
70
|
+
Boolean(onItemClick) && 'udb-activity-item--clickable',
|
|
71
|
+
)}
|
|
72
|
+
onClick={() => onItemClick?.(item)}
|
|
73
|
+
>
|
|
74
|
+
<span className="udb-activity-timeline-rail" aria-hidden="true" />
|
|
75
|
+
<span
|
|
76
|
+
className={cn(
|
|
77
|
+
'udb-activity-timeline-marker',
|
|
78
|
+
item.tone && `udb-activity-tone--${item.tone}`,
|
|
79
|
+
)}
|
|
80
|
+
aria-hidden="true"
|
|
81
|
+
>
|
|
82
|
+
{item.icon ?? <span style={{ width: 6, height: 6, borderRadius: 999, background: 'currentColor' }} />}
|
|
83
|
+
</span>
|
|
84
|
+
|
|
85
|
+
<div className="udb-activity-timeline-content">
|
|
86
|
+
<div className="udb-activity-title-row">
|
|
87
|
+
<span className="udb-activity-title">{item.title}</span>
|
|
88
|
+
{item.badge}
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
{item.description && <p className="udb-activity-desc">{item.description}</p>}
|
|
92
|
+
|
|
93
|
+
<div className="udb-activity-meta-row">
|
|
94
|
+
{actorName && <span className="udb-activity-actor">{actorName}</span>}
|
|
95
|
+
{actorName && item.target && <span className="udb-activity-dot" aria-hidden="true">·</span>}
|
|
96
|
+
{renderTarget(item.target)}
|
|
97
|
+
{(actorName || item.target) && <span className="udb-activity-dot" aria-hidden="true">·</span>}
|
|
98
|
+
<time dateTime={d.toISOString()} title={d.toLocaleString()}>
|
|
99
|
+
{relTime}
|
|
100
|
+
</time>
|
|
101
|
+
{item.meta && (
|
|
102
|
+
<>
|
|
103
|
+
<span className="udb-activity-dot" aria-hidden="true">·</span>
|
|
104
|
+
<span>{item.meta}</span>
|
|
105
|
+
</>
|
|
106
|
+
)}
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div className={cn('udb-activity-timeline', className)} role="region" aria-label="Activity timeline">
|
|
115
|
+
{groupByDay ? (
|
|
116
|
+
groups.map((group) => (
|
|
117
|
+
<section key={group.dateKey} className="udb-activity-day-group">
|
|
118
|
+
<header className="udb-activity-day-header">{group.label}</header>
|
|
119
|
+
{group.items.map(renderTimelineItem)}
|
|
120
|
+
</section>
|
|
121
|
+
))
|
|
122
|
+
) : (
|
|
123
|
+
sortedItems.map(renderTimelineItem)
|
|
124
|
+
)}
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export type ActivityTone = 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'neutral' | 'violet';
|
|
4
|
+
|
|
5
|
+
export interface ActivityActor {
|
|
6
|
+
readonly id?: string;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly avatarUrl?: string;
|
|
9
|
+
readonly initials?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ActivityTarget {
|
|
13
|
+
readonly label: ReactNode;
|
|
14
|
+
readonly href?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ActivityItem<T = unknown> {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly timestamp: string | number | Date;
|
|
20
|
+
readonly title: ReactNode;
|
|
21
|
+
readonly description?: ReactNode;
|
|
22
|
+
readonly actor?: ActivityActor | string;
|
|
23
|
+
readonly target?: ActivityTarget | ReactNode;
|
|
24
|
+
readonly icon?: ReactNode;
|
|
25
|
+
readonly tone?: ActivityTone;
|
|
26
|
+
readonly badge?: ReactNode;
|
|
27
|
+
readonly meta?: ReactNode;
|
|
28
|
+
readonly href?: string;
|
|
29
|
+
readonly payload?: T;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ActivityFeedProps<T = unknown> {
|
|
33
|
+
readonly items: readonly ActivityItem<T>[];
|
|
34
|
+
readonly groupByDay?: boolean;
|
|
35
|
+
readonly density?: 'normal' | 'dense';
|
|
36
|
+
readonly emptyTitle?: string;
|
|
37
|
+
readonly emptyDescription?: string;
|
|
38
|
+
readonly emptyIcon?: ReactNode;
|
|
39
|
+
readonly onItemClick?: (item: ActivityItem<T>) => void;
|
|
40
|
+
readonly className?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ActivityTimelineProps<T = unknown> {
|
|
44
|
+
readonly items: readonly ActivityItem<T>[];
|
|
45
|
+
readonly groupByDay?: boolean;
|
|
46
|
+
readonly density?: 'normal' | 'dense';
|
|
47
|
+
readonly emptyTitle?: string;
|
|
48
|
+
readonly emptyDescription?: string;
|
|
49
|
+
readonly emptyIcon?: ReactNode;
|
|
50
|
+
readonly newestFirst?: boolean;
|
|
51
|
+
readonly onItemClick?: (item: ActivityItem<T>) => void;
|
|
52
|
+
readonly className?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ActivityGroup<T = unknown> {
|
|
56
|
+
readonly dateKey: string;
|
|
57
|
+
readonly label: string;
|
|
58
|
+
readonly items: readonly ActivityItem<T>[];
|
|
59
|
+
}
|