@umituz/web-dashboard 11.11.0 → 11.12.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.
@@ -0,0 +1,115 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import { MemoryRouter } from 'react-router';
4
+ import { KanbanPage } from './KanbanPage';
5
+ import type { KanbanColumn, KanbanItem, KanbanKpi } from '../types';
6
+
7
+ interface ProjectDeal {
8
+ amount: number;
9
+ }
10
+
11
+ const COLUMNS: readonly KanbanColumn<ProjectDeal>[] = [
12
+ { id: 'lead', title: 'New Leads', tone: 'neutral' },
13
+ { id: 'qualified', title: 'Qualified', tone: 'info' },
14
+ { id: 'won', title: 'Closed Won', tone: 'success' },
15
+ ];
16
+
17
+ const ITEMS: readonly KanbanItem<ProjectDeal>[] = [
18
+ {
19
+ id: 'deal-1',
20
+ columnId: 'lead',
21
+ title: 'Acme Corp Contract',
22
+ description: 'Enterprise license',
23
+ meta: '$120,000',
24
+ payload: { amount: 120000 },
25
+ },
26
+ {
27
+ id: 'deal-2',
28
+ columnId: 'qualified',
29
+ title: 'Globex Deal',
30
+ meta: '$45,000',
31
+ payload: { amount: 45000 },
32
+ },
33
+ ];
34
+
35
+ const KPIS: readonly KanbanKpi[] = [
36
+ { label: 'Active Pipeline', value: '$165,000' },
37
+ { label: 'Deals in Progress', value: '2' },
38
+ ];
39
+
40
+ describe('KanbanPage', () => {
41
+ it('renders page header with kicker, title, and subtitle', () => {
42
+ render(
43
+ <MemoryRouter>
44
+ <KanbanPage<ProjectDeal>
45
+ kicker="Sales CRM"
46
+ title="Pipeline Deals"
47
+ subtitle="All active enterprise deals across stages"
48
+ columns={COLUMNS}
49
+ items={ITEMS}
50
+ />
51
+ </MemoryRouter>,
52
+ );
53
+
54
+ expect(screen.getByText('Sales CRM')).toBeDefined();
55
+ expect(screen.getByText('Pipeline Deals')).toBeDefined();
56
+ expect(screen.getByText('All active enterprise deals across stages')).toBeDefined();
57
+ });
58
+
59
+ it('renders KPI cards', () => {
60
+ render(
61
+ <MemoryRouter>
62
+ <KanbanPage<ProjectDeal>
63
+ title="Pipeline Deals"
64
+ kpis={KPIS}
65
+ columns={COLUMNS}
66
+ items={ITEMS}
67
+ />
68
+ </MemoryRouter>,
69
+ );
70
+
71
+ expect(screen.getByText('Active Pipeline')).toBeDefined();
72
+ expect(screen.getByText('$165,000')).toBeDefined();
73
+ expect(screen.getByText('Deals in Progress')).toBeDefined();
74
+ expect(screen.getByText('2')).toBeDefined();
75
+ });
76
+
77
+ it('renders search input and responds to change events', () => {
78
+ const handleSearch = vi.fn();
79
+ render(
80
+ <MemoryRouter>
81
+ <KanbanPage<ProjectDeal>
82
+ title="Pipeline Deals"
83
+ search={{
84
+ value: '',
85
+ onChange: handleSearch,
86
+ placeholder: 'Search deals...',
87
+ }}
88
+ columns={COLUMNS}
89
+ items={ITEMS}
90
+ />
91
+ </MemoryRouter>,
92
+ );
93
+
94
+ const input = screen.getByPlaceholderText('Search deals...');
95
+ expect(input).toBeDefined();
96
+
97
+ fireEvent.change(input, { target: { value: 'Acme' } });
98
+ expect(handleSearch).toHaveBeenCalledWith('Acme');
99
+ });
100
+
101
+ it('renders footer when provided', () => {
102
+ render(
103
+ <MemoryRouter>
104
+ <KanbanPage<ProjectDeal>
105
+ title="Pipeline Deals"
106
+ columns={COLUMNS}
107
+ items={ITEMS}
108
+ footer={<div data-testid="page-footer">Custom Footer Note</div>}
109
+ />
110
+ </MemoryRouter>,
111
+ );
112
+
113
+ expect(screen.getByTestId('page-footer')).toBeDefined();
114
+ });
115
+ });
@@ -0,0 +1,91 @@
1
+ import { type ReactNode } from 'react';
2
+ import { Search } from 'lucide-react';
3
+ import { PageHeader } from '@umituz/web-design-system/templates';
4
+ import type { KanbanPageProps } from '../types';
5
+ import { KanbanBoard } from './KanbanBoard';
6
+
7
+ export function KanbanPage<T = unknown>({
8
+ kicker,
9
+ title,
10
+ subtitle,
11
+ actions,
12
+ callout,
13
+ kpis,
14
+ search,
15
+ filterBar,
16
+ loading = false,
17
+ footer,
18
+ children,
19
+ className,
20
+ ...boardProps
21
+ }: KanbanPageProps<T>): ReactNode {
22
+ return (
23
+ <div className={`udb-kanban-page${className ? ` ${className}` : ''}`}>
24
+ <PageHeader
25
+ title={title}
26
+ subtitle={subtitle}
27
+ kicker={kicker}
28
+ actions={actions}
29
+ />
30
+
31
+ {callout && <div className="udb-kanban-callout">{callout}</div>}
32
+
33
+ {kpis && kpis.length > 0 && (
34
+ <div className="udb-kanban-kpis">
35
+ {kpis.map((kpi) => (
36
+ <div key={kpi.label} className="udb-kanban-kpi-card">
37
+ <div className="udb-kanban-kpi-label">{kpi.label}</div>
38
+ <div className="udb-kanban-kpi-value">{kpi.value}</div>
39
+ {kpi.hint && <div className="udb-kanban-kpi-hint">{kpi.hint}</div>}
40
+ </div>
41
+ ))}
42
+ </div>
43
+ )}
44
+
45
+ {(search || filterBar) && (
46
+ <div className="udb-kanban-toolbar">
47
+ {search ? (
48
+ <div className="udb-kanban-search-box">
49
+ <span className="udb-kanban-search-icon" aria-hidden="true">
50
+ <Search size={15} />
51
+ </span>
52
+ <input
53
+ type="text"
54
+ className="udb-kanban-search-input"
55
+ placeholder={search.placeholder ?? 'Filter cards…'}
56
+ value={search.value}
57
+ onChange={(e) => search.onChange(e.target.value)}
58
+ />
59
+ </div>
60
+ ) : (
61
+ <div />
62
+ )}
63
+
64
+ {filterBar}
65
+ </div>
66
+ )}
67
+
68
+ {loading ? (
69
+ <div className="udb-kanban-loading" aria-busy="true">
70
+ <div className="udb-kanban-board">
71
+ {boardProps.columns.map((col) => (
72
+ <div key={col.id} className="udb-kanban-col">
73
+ <div className="udb-kanban-col-head">
74
+ <span className="udb-kanban-col-title">{col.title}</span>
75
+ </div>
76
+ <div className="udb-kanban-col-body">
77
+ <div className="udb-kanban-empty-col">Loading…</div>
78
+ </div>
79
+ </div>
80
+ ))}
81
+ </div>
82
+ </div>
83
+ ) : (
84
+ <KanbanBoard<T> {...boardProps} />
85
+ )}
86
+
87
+ {footer && <div className="udb-kanban-footer">{footer}</div>}
88
+ {children}
89
+ </div>
90
+ );
91
+ }
@@ -0,0 +1,4 @@
1
+ export { KanbanBoard } from './KanbanBoard';
2
+ export { KanbanColumn, type KanbanColumnProps } from './KanbanColumn';
3
+ export { KanbanCard, type KanbanCardProps } from './KanbanCard';
4
+ export { KanbanPage } from './KanbanPage';
@@ -0,0 +1,12 @@
1
+ export type {
2
+ KanbanTone,
3
+ KanbanTag,
4
+ KanbanAssignee,
5
+ KanbanItem,
6
+ KanbanColumn,
7
+ KanbanCardActions,
8
+ KanbanBoardProps,
9
+ KanbanKpi,
10
+ KanbanPageProps,
11
+ } from './types';
12
+ export * from './components';
@@ -0,0 +1,406 @@
1
+ .udb-kanban-page {
2
+ display: flex;
3
+ flex-direction: column;
4
+ width: 100%;
5
+ gap: var(--udb-space-5, 20px);
6
+ }
7
+
8
+ .udb-kanban-callout {
9
+ width: 100%;
10
+ }
11
+
12
+ .udb-kanban-kpis {
13
+ display: grid;
14
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
15
+ gap: 16px;
16
+ width: 100%;
17
+ }
18
+
19
+ .udb-kanban-kpi-card {
20
+ padding: 16px 20px;
21
+ border-radius: var(--radius-lg, 12px);
22
+ border: 1px solid var(--color-border, #e2e8f0);
23
+ background: var(--color-card, #ffffff);
24
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
25
+ }
26
+
27
+ .udb-kanban-kpi-label {
28
+ font-size: 13px;
29
+ font-weight: 500;
30
+ color: var(--color-muted-foreground, #64748b);
31
+ margin-bottom: 6px;
32
+ }
33
+
34
+ .udb-kanban-kpi-value {
35
+ font-size: 24px;
36
+ font-weight: 700;
37
+ color: var(--color-foreground, #0f172a);
38
+ letter-spacing: -0.02em;
39
+ }
40
+
41
+ .udb-kanban-kpi-hint {
42
+ font-size: 12px;
43
+ color: var(--color-muted-foreground, #64748b);
44
+ margin-top: 4px;
45
+ }
46
+
47
+ .udb-kanban-toolbar {
48
+ display: flex;
49
+ flex-wrap: wrap;
50
+ align-items: center;
51
+ justify-content: space-between;
52
+ gap: 12px;
53
+ }
54
+
55
+ .udb-kanban-search-box {
56
+ position: relative;
57
+ min-width: 260px;
58
+ max-width: 380px;
59
+ flex: 1;
60
+ }
61
+
62
+ .udb-kanban-search-icon {
63
+ position: absolute;
64
+ left: 10px;
65
+ top: 50%;
66
+ transform: translateY(-50%);
67
+ pointer-events: none;
68
+ color: var(--color-muted-foreground, #64748b);
69
+ display: flex;
70
+ align-items: center;
71
+ justify-content: center;
72
+ }
73
+
74
+ .udb-kanban-search-input {
75
+ width: 100%;
76
+ height: 36px;
77
+ padding: 0 12px 0 34px;
78
+ font-size: 13px;
79
+ border-radius: var(--radius-md, 8px);
80
+ border: 1px solid var(--color-border, #e2e8f0);
81
+ background: var(--color-card, #ffffff);
82
+ color: var(--color-foreground, #0f172a);
83
+ transition: all 0.15s ease;
84
+ }
85
+
86
+ .udb-kanban-search-input:focus {
87
+ outline: none;
88
+ border-color: var(--color-primary, #2563eb);
89
+ box-shadow: 0 0 0 1px var(--color-primary, #2563eb);
90
+ }
91
+
92
+ .udb-kanban-board {
93
+ display: flex;
94
+ align-items: flex-start;
95
+ gap: 16px;
96
+ width: 100%;
97
+ overflow-x: auto;
98
+ padding-bottom: 16px;
99
+ scroll-behavior: smooth;
100
+ -webkit-overflow-scrolling: touch;
101
+ }
102
+
103
+ .udb-kanban-col {
104
+ display: flex;
105
+ flex-direction: column;
106
+ flex: 1 0 300px;
107
+ max-width: 360px;
108
+ min-width: 280px;
109
+ background: var(--color-muted, #f8fafc);
110
+ border: 1px solid var(--color-border, #e2e8f0);
111
+ border-radius: var(--radius-xl, 14px);
112
+ padding: 12px;
113
+ transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
114
+ }
115
+
116
+ .udb-kanban-col.is-drag-over {
117
+ border-color: var(--color-primary, #2563eb);
118
+ background: rgba(37, 99, 235, 0.04);
119
+ box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
120
+ }
121
+
122
+ .udb-kanban-col-head {
123
+ display: flex;
124
+ align-items: center;
125
+ justify-content: space-between;
126
+ padding: 4px 6px 12px 6px;
127
+ gap: 8px;
128
+ }
129
+
130
+ .udb-kanban-col-title-wrap {
131
+ display: flex;
132
+ align-items: center;
133
+ gap: 8px;
134
+ min-width: 0;
135
+ }
136
+
137
+ .udb-kanban-tone-dot {
138
+ width: 8px;
139
+ height: 8px;
140
+ border-radius: 9999px;
141
+ flex-shrink: 0;
142
+ background: var(--color-muted-foreground, #94a3b8);
143
+ }
144
+
145
+ .udb-kanban-tone-dot.tone-primary {
146
+ background: var(--color-primary, #2563eb);
147
+ }
148
+
149
+ .udb-kanban-tone-dot.tone-success {
150
+ background: #16a34a;
151
+ }
152
+
153
+ .udb-kanban-tone-dot.tone-warning {
154
+ background: #d97706;
155
+ }
156
+
157
+ .udb-kanban-tone-dot.tone-danger {
158
+ background: #dc2626;
159
+ }
160
+
161
+ .udb-kanban-tone-dot.tone-info {
162
+ background: #0284c7;
163
+ }
164
+
165
+ .udb-kanban-col-title {
166
+ font-size: 14px;
167
+ font-weight: 600;
168
+ color: var(--color-foreground, #0f172a);
169
+ white-space: nowrap;
170
+ overflow: hidden;
171
+ text-overflow: ellipsis;
172
+ }
173
+
174
+ .udb-kanban-col-count {
175
+ display: inline-flex;
176
+ align-items: center;
177
+ justify-content: center;
178
+ padding: 2px 7px;
179
+ font-size: 11px;
180
+ font-weight: 600;
181
+ border-radius: 9999px;
182
+ background: var(--color-border, #e2e8f0);
183
+ color: var(--color-muted-foreground, #64748b);
184
+ font-variant-numeric: tabular-nums;
185
+ }
186
+
187
+ .udb-kanban-col-limit {
188
+ font-size: 11px;
189
+ font-weight: 600;
190
+ color: var(--color-muted-foreground, #64748b);
191
+ font-variant-numeric: tabular-nums;
192
+ }
193
+
194
+ .udb-kanban-col-limit.is-exceeded {
195
+ color: #dc2626;
196
+ font-weight: 700;
197
+ }
198
+
199
+ .udb-kanban-col-actions {
200
+ display: flex;
201
+ align-items: center;
202
+ gap: 4px;
203
+ flex-shrink: 0;
204
+ }
205
+
206
+ .udb-kanban-col-btn {
207
+ display: inline-flex;
208
+ align-items: center;
209
+ justify-content: center;
210
+ width: 26px;
211
+ height: 26px;
212
+ border-radius: var(--radius-sm, 6px);
213
+ border: none;
214
+ background: transparent;
215
+ color: var(--color-muted-foreground, #64748b);
216
+ cursor: pointer;
217
+ transition: all 0.15s ease;
218
+ }
219
+
220
+ .udb-kanban-col-btn:hover {
221
+ background: var(--color-border, #e2e8f0);
222
+ color: var(--color-foreground, #0f172a);
223
+ }
224
+
225
+ .udb-kanban-col-body {
226
+ display: flex;
227
+ flex-direction: column;
228
+ gap: 10px;
229
+ min-height: 120px;
230
+ flex: 1;
231
+ }
232
+
233
+ .udb-kanban-card {
234
+ position: relative;
235
+ display: flex;
236
+ flex-direction: column;
237
+ gap: 8px;
238
+ padding: 14px;
239
+ border-radius: var(--radius-lg, 10px);
240
+ border: 1px solid var(--color-border, #e2e8f0);
241
+ background: var(--color-card, #ffffff);
242
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
243
+ cursor: grab;
244
+ user-select: none;
245
+ transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
246
+ }
247
+
248
+ .udb-kanban-card:active {
249
+ cursor: grabbing;
250
+ }
251
+
252
+ .udb-kanban-card:hover {
253
+ border-color: #cbd5e1;
254
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
255
+ transform: translateY(-1px);
256
+ }
257
+
258
+ .udb-kanban-card.is-dragging {
259
+ opacity: 0.35;
260
+ transform: scale(0.98);
261
+ }
262
+
263
+ .udb-kanban-card.is-disabled {
264
+ cursor: default;
265
+ opacity: 0.7;
266
+ }
267
+
268
+ .udb-kanban-card-head {
269
+ display: flex;
270
+ align-items: flex-start;
271
+ justify-content: space-between;
272
+ gap: 8px;
273
+ }
274
+
275
+ .udb-kanban-card-title {
276
+ font-size: 13px;
277
+ font-weight: 600;
278
+ line-height: 1.35;
279
+ color: var(--color-foreground, #0f172a);
280
+ word-break: break-word;
281
+ }
282
+
283
+ .udb-kanban-card-desc {
284
+ font-size: 12px;
285
+ line-height: 1.45;
286
+ color: var(--color-muted-foreground, #64748b);
287
+ display: -webkit-box;
288
+ -webkit-line-clamp: 2;
289
+ -webkit-box-orient: vertical;
290
+ overflow: hidden;
291
+ }
292
+
293
+ .udb-kanban-card-tags {
294
+ display: flex;
295
+ flex-wrap: wrap;
296
+ gap: 4px;
297
+ margin-top: 2px;
298
+ }
299
+
300
+ .udb-kanban-card-tag {
301
+ display: inline-flex;
302
+ align-items: center;
303
+ padding: 1px 7px;
304
+ font-size: 10.5px;
305
+ font-weight: 500;
306
+ border-radius: var(--radius-sm, 5px);
307
+ background: var(--color-muted, #f1f5f9);
308
+ color: var(--color-muted-foreground, #475569);
309
+ border: 1px solid var(--color-border, #e2e8f0);
310
+ }
311
+
312
+ .udb-kanban-card-foot {
313
+ display: flex;
314
+ align-items: center;
315
+ justify-content: space-between;
316
+ gap: 8px;
317
+ margin-top: 4px;
318
+ padding-top: 8px;
319
+ border-top: 1px solid rgba(226, 232, 240, 0.6);
320
+ }
321
+
322
+ .udb-kanban-card-meta {
323
+ display: flex;
324
+ align-items: center;
325
+ gap: 6px;
326
+ font-size: 11.5px;
327
+ color: var(--color-muted-foreground, #64748b);
328
+ min-width: 0;
329
+ }
330
+
331
+ .udb-kanban-card-assignee {
332
+ display: inline-flex;
333
+ align-items: center;
334
+ gap: 5px;
335
+ font-size: 11.5px;
336
+ font-weight: 500;
337
+ color: var(--color-foreground, #0f172a);
338
+ }
339
+
340
+ .udb-kanban-card-avatar {
341
+ display: inline-flex;
342
+ align-items: center;
343
+ justify-content: center;
344
+ width: 20px;
345
+ height: 20px;
346
+ border-radius: 9999px;
347
+ background: var(--color-primary, #2563eb);
348
+ color: #ffffff;
349
+ font-size: 9px;
350
+ font-weight: 700;
351
+ overflow: hidden;
352
+ text-transform: uppercase;
353
+ }
354
+
355
+ .udb-kanban-card-avatar img {
356
+ width: 100%;
357
+ height: 100%;
358
+ object-fit: cover;
359
+ }
360
+
361
+ .udb-kanban-stage-actions {
362
+ display: inline-flex;
363
+ align-items: center;
364
+ gap: 3px;
365
+ margin-left: auto;
366
+ }
367
+
368
+ .udb-kanban-stage-btn {
369
+ display: inline-flex;
370
+ align-items: center;
371
+ justify-content: center;
372
+ width: 22px;
373
+ height: 22px;
374
+ border-radius: var(--radius-sm, 4px);
375
+ border: 1px solid var(--color-border, #e2e8f0);
376
+ background: var(--color-card, #ffffff);
377
+ color: var(--color-muted-foreground, #64748b);
378
+ cursor: pointer;
379
+ transition: all 0.15s ease;
380
+ font-size: 12px;
381
+ }
382
+
383
+ .udb-kanban-stage-btn:hover:not(:disabled) {
384
+ background: var(--color-muted, #f1f5f9);
385
+ color: var(--color-foreground, #0f172a);
386
+ border-color: #cbd5e1;
387
+ }
388
+
389
+ .udb-kanban-stage-btn:disabled {
390
+ opacity: 0.3;
391
+ cursor: not-allowed;
392
+ }
393
+
394
+ .udb-kanban-empty-col {
395
+ display: flex;
396
+ align-items: center;
397
+ justify-content: center;
398
+ min-height: 80px;
399
+ border-radius: var(--radius-md, 8px);
400
+ border: 1px dashed var(--color-border, #cbd5e1);
401
+ color: var(--color-muted-foreground, #94a3b8);
402
+ font-size: 12px;
403
+ font-weight: 500;
404
+ text-align: center;
405
+ padding: 12px;
406
+ }