@umituz/web-dashboard 10.4.0 → 11.1.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 +5 -3
- package/src/domains/layouts/components/index.ts +0 -20
- package/src/domains/pages/components/ListPage.test.tsx +129 -0
- package/src/domains/pages/components/ListPage.tsx +194 -0
- package/src/domains/pages/components/index.ts +1 -0
- package/src/domains/pages/index.ts +12 -0
- package/src/domains/pages/types.ts +74 -0
- package/src/index.ts +1 -0
- package/src/styles/chrome.css +0 -343
- package/src/domains/layouts/components/FilterBar.test.tsx +0 -33
- package/src/domains/layouts/components/FilterBar.tsx +0 -38
- package/src/domains/layouts/components/FilterPanel.test.tsx +0 -76
- package/src/domains/layouts/components/FilterPanel.tsx +0 -129
- package/src/domains/layouts/components/FilterSelect.test.tsx +0 -28
- package/src/domains/layouts/components/FilterSelect.tsx +0 -47
- package/src/domains/layouts/components/NextSteps.test.tsx +0 -25
- package/src/domains/layouts/components/NextSteps.tsx +0 -36
- package/src/domains/layouts/components/PageHeader.test.tsx +0 -63
- package/src/domains/layouts/components/PageHeader.tsx +0 -67
- package/src/domains/layouts/components/SectionHeader.test.tsx +0 -29
- package/src/domains/layouts/components/SectionHeader.tsx +0 -36
- package/src/domains/layouts/components/TabNav.test.tsx +0 -33
- package/src/domains/layouts/components/TabNav.tsx +0 -31
package/src/styles/chrome.css
CHANGED
|
@@ -561,28 +561,6 @@
|
|
|
561
561
|
.udb-scroll-lock {
|
|
562
562
|
overflow: hidden;
|
|
563
563
|
}
|
|
564
|
-
.udb-filter-bar {
|
|
565
|
-
display: flex;
|
|
566
|
-
flex-wrap: wrap;
|
|
567
|
-
align-items: flex-end;
|
|
568
|
-
gap: var(--udb-space-3);
|
|
569
|
-
}
|
|
570
|
-
.udb-filter-bar__search {
|
|
571
|
-
min-width: 200px;
|
|
572
|
-
flex: 0 1 240px;
|
|
573
|
-
}
|
|
574
|
-
.udb-filter-bar__fields {
|
|
575
|
-
display: flex;
|
|
576
|
-
flex-wrap: wrap;
|
|
577
|
-
align-items: center;
|
|
578
|
-
gap: var(--udb-space-2);
|
|
579
|
-
flex: 1;
|
|
580
|
-
}
|
|
581
|
-
.udb-filter-bar__actions {
|
|
582
|
-
display: flex;
|
|
583
|
-
align-items: center;
|
|
584
|
-
gap: var(--udb-space-2);
|
|
585
|
-
}
|
|
586
564
|
@keyframes udb-pop {
|
|
587
565
|
from {
|
|
588
566
|
opacity: 0;
|
|
@@ -1466,159 +1444,6 @@
|
|
|
1466
1444
|
color: var(--color-muted-foreground);
|
|
1467
1445
|
opacity: 0.5;
|
|
1468
1446
|
}
|
|
1469
|
-
.udb-audit {
|
|
1470
|
-
display: flex;
|
|
1471
|
-
flex-direction: column;
|
|
1472
|
-
margin: 0;
|
|
1473
|
-
padding: 0;
|
|
1474
|
-
list-style: none;
|
|
1475
|
-
border: 1px solid var(--color-border);
|
|
1476
|
-
border-radius: var(--radius-lg);
|
|
1477
|
-
background: var(--color-card);
|
|
1478
|
-
overflow: hidden;
|
|
1479
|
-
}
|
|
1480
|
-
.udb-audit__item {
|
|
1481
|
-
display: flex;
|
|
1482
|
-
align-items: baseline;
|
|
1483
|
-
gap: var(--udb-space-4);
|
|
1484
|
-
padding: var(--udb-space-3) var(--udb-space-4);
|
|
1485
|
-
border-bottom: 1px solid var(--color-border);
|
|
1486
|
-
font-size: var(--udb-font-size-md);
|
|
1487
|
-
}
|
|
1488
|
-
.udb-audit__item:last-child {
|
|
1489
|
-
border-bottom: none;
|
|
1490
|
-
}
|
|
1491
|
-
.udb-audit__at {
|
|
1492
|
-
flex-shrink: 0;
|
|
1493
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
1494
|
-
font-size: var(--udb-font-size-sm);
|
|
1495
|
-
color: var(--color-muted-foreground);
|
|
1496
|
-
}
|
|
1497
|
-
.udb-audit__actor {
|
|
1498
|
-
flex-shrink: 0;
|
|
1499
|
-
font-weight: var(--font-weight-medium);
|
|
1500
|
-
color: var(--color-foreground);
|
|
1501
|
-
}
|
|
1502
|
-
.udb-audit__action {
|
|
1503
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
1504
|
-
font-size: var(--udb-font-size-sm);
|
|
1505
|
-
color: var(--color-primary);
|
|
1506
|
-
}
|
|
1507
|
-
.udb-audit__target {
|
|
1508
|
-
min-width: 0;
|
|
1509
|
-
overflow: hidden;
|
|
1510
|
-
text-overflow: ellipsis;
|
|
1511
|
-
white-space: nowrap;
|
|
1512
|
-
color: var(--color-muted-foreground);
|
|
1513
|
-
}
|
|
1514
|
-
.udb-pageheader__breadcrumbs .udb-pageheader__crumb + .udb-pageheader__crumb::before {
|
|
1515
|
-
content: "/";
|
|
1516
|
-
margin-right: 0.375rem;
|
|
1517
|
-
color: var(--color-muted-foreground);
|
|
1518
|
-
opacity: 0.6;
|
|
1519
|
-
}
|
|
1520
|
-
.udb-pageheader__breadcrumbs a {
|
|
1521
|
-
color: inherit;
|
|
1522
|
-
text-decoration: none;
|
|
1523
|
-
}
|
|
1524
|
-
.udb-pageheader__breadcrumbs a:hover {
|
|
1525
|
-
text-decoration: underline;
|
|
1526
|
-
}
|
|
1527
|
-
.udb-pageheader__breadcrumbs {
|
|
1528
|
-
display: flex;
|
|
1529
|
-
align-items: center;
|
|
1530
|
-
gap: 0.375rem;
|
|
1531
|
-
font-size: 0.8125rem;
|
|
1532
|
-
color: var(--color-muted-foreground);
|
|
1533
|
-
}
|
|
1534
|
-
.udb-pageheader {
|
|
1535
|
-
display: flex;
|
|
1536
|
-
flex-wrap: wrap;
|
|
1537
|
-
align-items: flex-start;
|
|
1538
|
-
justify-content: space-between;
|
|
1539
|
-
gap: 0.75rem;
|
|
1540
|
-
margin-bottom: 1.25rem;
|
|
1541
|
-
}
|
|
1542
|
-
.udb-pageheader__main {
|
|
1543
|
-
min-width: 0;
|
|
1544
|
-
}
|
|
1545
|
-
.udb-pageheader__kicker {
|
|
1546
|
-
margin: 0 0 0.25rem;
|
|
1547
|
-
font-size: 0.6875rem;
|
|
1548
|
-
font-weight: 600;
|
|
1549
|
-
letter-spacing: 0.08em;
|
|
1550
|
-
text-transform: uppercase;
|
|
1551
|
-
color: var(--color-muted-foreground);
|
|
1552
|
-
}
|
|
1553
|
-
.udb-pageheader__title {
|
|
1554
|
-
margin: 0;
|
|
1555
|
-
font-size: 1.375rem;
|
|
1556
|
-
font-weight: 600;
|
|
1557
|
-
line-height: 1.2;
|
|
1558
|
-
letter-spacing: -0.01em;
|
|
1559
|
-
color: var(--color-foreground);
|
|
1560
|
-
}
|
|
1561
|
-
.udb-pageheader__subtitle {
|
|
1562
|
-
margin: 0.25rem 0 0;
|
|
1563
|
-
font-size: 0.875rem;
|
|
1564
|
-
line-height: 1.45;
|
|
1565
|
-
color: var(--color-muted-foreground);
|
|
1566
|
-
}
|
|
1567
|
-
.udb-pageheader__actions {
|
|
1568
|
-
display: flex;
|
|
1569
|
-
flex-wrap: wrap;
|
|
1570
|
-
align-items: center;
|
|
1571
|
-
gap: 0.5rem;
|
|
1572
|
-
}
|
|
1573
|
-
.udb-pageheader__meta {
|
|
1574
|
-
display: flex;
|
|
1575
|
-
flex-wrap: wrap;
|
|
1576
|
-
align-items: center;
|
|
1577
|
-
gap: 0.5rem;
|
|
1578
|
-
margin: 0.5rem 0 0;
|
|
1579
|
-
font-size: 0.75rem;
|
|
1580
|
-
color: var(--color-muted-foreground);
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
.udb-sectionheader {
|
|
1584
|
-
display: flex;
|
|
1585
|
-
flex-wrap: wrap;
|
|
1586
|
-
align-items: flex-start;
|
|
1587
|
-
justify-content: space-between;
|
|
1588
|
-
gap: 0.75rem;
|
|
1589
|
-
margin-bottom: 0.875rem;
|
|
1590
|
-
}
|
|
1591
|
-
.udb-sectionheader__main {
|
|
1592
|
-
min-width: 0;
|
|
1593
|
-
}
|
|
1594
|
-
.udb-sectionheader__kicker {
|
|
1595
|
-
margin: 0 0 0.25rem;
|
|
1596
|
-
font-size: 0.6875rem;
|
|
1597
|
-
font-weight: 600;
|
|
1598
|
-
letter-spacing: 0.08em;
|
|
1599
|
-
text-transform: uppercase;
|
|
1600
|
-
color: var(--color-muted-foreground);
|
|
1601
|
-
}
|
|
1602
|
-
.udb-sectionheader__title {
|
|
1603
|
-
margin: 0;
|
|
1604
|
-
font-size: 1.0625rem;
|
|
1605
|
-
font-weight: 600;
|
|
1606
|
-
line-height: 1.25;
|
|
1607
|
-
letter-spacing: -0.01em;
|
|
1608
|
-
color: var(--color-foreground);
|
|
1609
|
-
}
|
|
1610
|
-
.udb-sectionheader__subtitle {
|
|
1611
|
-
margin: 0.25rem 0 0;
|
|
1612
|
-
font-size: 0.8125rem;
|
|
1613
|
-
line-height: 1.45;
|
|
1614
|
-
color: var(--color-muted-foreground);
|
|
1615
|
-
}
|
|
1616
|
-
.udb-sectionheader__actions {
|
|
1617
|
-
display: flex;
|
|
1618
|
-
flex-wrap: wrap;
|
|
1619
|
-
align-items: center;
|
|
1620
|
-
gap: 0.5rem;
|
|
1621
|
-
}
|
|
1622
1447
|
|
|
1623
1448
|
.udb-onb,
|
|
1624
1449
|
.udb-onb *,
|
|
@@ -2446,174 +2271,6 @@
|
|
|
2446
2271
|
font-size: var(--udb-font-size-sm);
|
|
2447
2272
|
}
|
|
2448
2273
|
|
|
2449
|
-
|
|
2450
|
-
.udb-tabnav {
|
|
2451
|
-
display: flex;
|
|
2452
|
-
gap: var(--udb-space-1);
|
|
2453
|
-
border-bottom: 1px solid var(--color-border);
|
|
2454
|
-
overflow-x: auto;
|
|
2455
|
-
scrollbar-width: none;
|
|
2456
|
-
}
|
|
2457
|
-
.udb-tabnav::-webkit-scrollbar {
|
|
2458
|
-
display: none;
|
|
2459
|
-
}
|
|
2460
|
-
.udb-tabnav__tab {
|
|
2461
|
-
position: relative;
|
|
2462
|
-
padding: var(--udb-space-3) var(--udb-space-4);
|
|
2463
|
-
font-size: var(--udb-font-size-md);
|
|
2464
|
-
font-weight: var(--font-weight-medium);
|
|
2465
|
-
color: var(--color-muted-foreground);
|
|
2466
|
-
white-space: nowrap;
|
|
2467
|
-
transition: color 0.15s ease-out;
|
|
2468
|
-
}
|
|
2469
|
-
.udb-tabnav__tab:hover {
|
|
2470
|
-
color: var(--color-foreground);
|
|
2471
|
-
}
|
|
2472
|
-
.udb-tabnav__tab--active {
|
|
2473
|
-
color: var(--color-primary);
|
|
2474
|
-
}
|
|
2475
|
-
.udb-tabnav__tab--active::after {
|
|
2476
|
-
content: '';
|
|
2477
|
-
position: absolute;
|
|
2478
|
-
left: var(--udb-space-3);
|
|
2479
|
-
right: var(--udb-space-3);
|
|
2480
|
-
bottom: -1px;
|
|
2481
|
-
height: 2px;
|
|
2482
|
-
border-radius: var(--udb-radius-pill);
|
|
2483
|
-
background: var(--color-primary);
|
|
2484
|
-
}
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
.udb-filter-panel {
|
|
2488
|
-
background: var(--color-card);
|
|
2489
|
-
border: 1px solid var(--color-border);
|
|
2490
|
-
border-radius: var(--radius-lg);
|
|
2491
|
-
padding: var(--udb-space-4);
|
|
2492
|
-
}
|
|
2493
|
-
.udb-filter-panel__header {
|
|
2494
|
-
display: flex;
|
|
2495
|
-
align-items: center;
|
|
2496
|
-
justify-content: space-between;
|
|
2497
|
-
margin-bottom: var(--udb-space-3);
|
|
2498
|
-
}
|
|
2499
|
-
.udb-filter-panel__title {
|
|
2500
|
-
font-size: var(--udb-font-size-sm);
|
|
2501
|
-
font-weight: var(--font-weight-bold);
|
|
2502
|
-
}
|
|
2503
|
-
.udb-filter-panel__clear {
|
|
2504
|
-
border: none;
|
|
2505
|
-
background: transparent;
|
|
2506
|
-
padding: 0;
|
|
2507
|
-
font-family: inherit;
|
|
2508
|
-
font-size: var(--udb-font-size-xs);
|
|
2509
|
-
font-weight: var(--font-weight-medium);
|
|
2510
|
-
color: var(--color-primary);
|
|
2511
|
-
cursor: pointer;
|
|
2512
|
-
}
|
|
2513
|
-
.udb-filter-panel__clear:hover:not(:disabled) {
|
|
2514
|
-
text-decoration: underline;
|
|
2515
|
-
}
|
|
2516
|
-
.udb-filter-panel__clear:disabled {
|
|
2517
|
-
opacity: 0.45;
|
|
2518
|
-
cursor: default;
|
|
2519
|
-
}
|
|
2520
|
-
.udb-filter-panel__sections {
|
|
2521
|
-
display: flex;
|
|
2522
|
-
flex-direction: column;
|
|
2523
|
-
gap: var(--udb-space-4);
|
|
2524
|
-
}
|
|
2525
|
-
.udb-filter-section__title {
|
|
2526
|
-
margin: 0 0 var(--udb-space-2);
|
|
2527
|
-
font-size: var(--udb-font-size-xs);
|
|
2528
|
-
font-weight: var(--font-weight-bold);
|
|
2529
|
-
text-transform: uppercase;
|
|
2530
|
-
letter-spacing: 0.08em;
|
|
2531
|
-
color: var(--color-muted-foreground);
|
|
2532
|
-
}
|
|
2533
|
-
.udb-filter-section__body {
|
|
2534
|
-
display: flex;
|
|
2535
|
-
flex-direction: column;
|
|
2536
|
-
gap: var(--udb-space-2);
|
|
2537
|
-
}
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
.udb-check-filter {
|
|
2541
|
-
list-style: none;
|
|
2542
|
-
padding: 0;
|
|
2543
|
-
margin: 0;
|
|
2544
|
-
display: flex;
|
|
2545
|
-
flex-direction: column;
|
|
2546
|
-
gap: 2px;
|
|
2547
|
-
}
|
|
2548
|
-
.udb-check-filter__item {
|
|
2549
|
-
display: flex;
|
|
2550
|
-
align-items: center;
|
|
2551
|
-
gap: var(--udb-space-2);
|
|
2552
|
-
width: 100%;
|
|
2553
|
-
padding: 6px var(--udb-space-2);
|
|
2554
|
-
margin-left: calc(var(--udb-space-2) * -1);
|
|
2555
|
-
border: none;
|
|
2556
|
-
border-radius: var(--radius-sm);
|
|
2557
|
-
background: transparent;
|
|
2558
|
-
font-family: inherit;
|
|
2559
|
-
font-size: var(--udb-font-size-md);
|
|
2560
|
-
color: var(--color-muted-foreground);
|
|
2561
|
-
text-align: left;
|
|
2562
|
-
cursor: pointer;
|
|
2563
|
-
transition: background 0.15s ease-out, color 0.15s ease-out;
|
|
2564
|
-
}
|
|
2565
|
-
.udb-check-filter__item:hover {
|
|
2566
|
-
background: var(--color-muted);
|
|
2567
|
-
color: var(--color-foreground);
|
|
2568
|
-
}
|
|
2569
|
-
.udb-check-filter__item--checked {
|
|
2570
|
-
color: var(--color-foreground);
|
|
2571
|
-
font-weight: var(--font-weight-medium);
|
|
2572
|
-
}
|
|
2573
|
-
.udb-check-filter__box {
|
|
2574
|
-
display: inline-flex;
|
|
2575
|
-
align-items: center;
|
|
2576
|
-
justify-content: center;
|
|
2577
|
-
width: 16px;
|
|
2578
|
-
height: 16px;
|
|
2579
|
-
border: 1.5px solid var(--color-border);
|
|
2580
|
-
border-radius: 4px;
|
|
2581
|
-
background: var(--color-card);
|
|
2582
|
-
color: var(--color-primary-foreground, #fff);
|
|
2583
|
-
flex: none;
|
|
2584
|
-
transition: background 0.15s ease-out, border-color 0.15s ease-out;
|
|
2585
|
-
}
|
|
2586
|
-
.udb-check-filter__item--checked .udb-check-filter__box {
|
|
2587
|
-
background: var(--color-primary);
|
|
2588
|
-
border-color: var(--color-primary);
|
|
2589
|
-
}
|
|
2590
|
-
.udb-check-filter__box--radio {
|
|
2591
|
-
border-radius: 50%;
|
|
2592
|
-
}
|
|
2593
|
-
.udb-check-filter__radio-dot {
|
|
2594
|
-
width: 6px;
|
|
2595
|
-
height: 6px;
|
|
2596
|
-
border-radius: 50%;
|
|
2597
|
-
background: var(--color-primary-foreground, #fff);
|
|
2598
|
-
}
|
|
2599
|
-
.udb-check-filter__label {
|
|
2600
|
-
flex: 1;
|
|
2601
|
-
min-width: 0;
|
|
2602
|
-
overflow: hidden;
|
|
2603
|
-
text-overflow: ellipsis;
|
|
2604
|
-
white-space: nowrap;
|
|
2605
|
-
}
|
|
2606
|
-
.udb-check-filter__count {
|
|
2607
|
-
font-size: var(--udb-font-size-xs);
|
|
2608
|
-
color: var(--color-muted-foreground);
|
|
2609
|
-
font-variant-numeric: tabular-nums;
|
|
2610
|
-
}
|
|
2611
|
-
.udb-check-filter__more {
|
|
2612
|
-
padding: 2px var(--udb-space-2);
|
|
2613
|
-
font-size: var(--udb-font-size-xs);
|
|
2614
|
-
color: var(--color-muted-foreground);
|
|
2615
|
-
}
|
|
2616
|
-
|
|
2617
2274
|
.udb-notif-list {
|
|
2618
2275
|
list-style: none;
|
|
2619
2276
|
margin: 0;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { renderToString } from "react-dom/server";
|
|
3
|
-
import { FilterBar } from "./FilterBar";
|
|
4
|
-
|
|
5
|
-
describe("FilterBar", () => {
|
|
6
|
-
it("renders search, children and actions in their slots", () => {
|
|
7
|
-
const html = renderToString(
|
|
8
|
-
<FilterBar
|
|
9
|
-
search={{ value: "", onChange: () => {}, placeholder: "Find…" }}
|
|
10
|
-
actions={<button type="button">Sort</button>}
|
|
11
|
-
|
|
12
|
-
>
|
|
13
|
-
<span>a chip</span>
|
|
14
|
-
|
|
15
|
-
</FilterBar>
|
|
16
|
-
|
|
17
|
-
);
|
|
18
|
-
expect(html).toContain("udb-filter-bar");
|
|
19
|
-
expect(html).toContain("udb-filter-bar__search");
|
|
20
|
-
expect(html).toContain("udb-filter-bar__fields");
|
|
21
|
-
expect(html).toContain("a chip");
|
|
22
|
-
expect(html).toContain("udb-filter-bar__actions");
|
|
23
|
-
expect(html).toContain("Sort");
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("omits absent slots entirely", () => {
|
|
27
|
-
const html = renderToString(<FilterBar />);
|
|
28
|
-
expect(html).toContain("udb-filter-bar");
|
|
29
|
-
expect(html).not.toContain("udb-filter-bar__search");
|
|
30
|
-
expect(html).not.toContain("udb-filter-bar__fields");
|
|
31
|
-
expect(html).not.toContain("udb-filter-bar__actions");
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import { SearchBox } from "@umituz/web-design-system/molecules";
|
|
3
|
-
import { cn } from "@umituz/web-design-system/utils/cn";
|
|
4
|
-
import type { BaseProps } from "@umituz/web-design-system/types";
|
|
5
|
-
|
|
6
|
-
export interface FilterBarSearch {
|
|
7
|
-
value: string;
|
|
8
|
-
onChange: (value: string) => void;
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface FilterBarProps extends BaseProps {
|
|
13
|
-
search?: FilterBarSearch;
|
|
14
|
-
children?: ReactNode;
|
|
15
|
-
actions?: ReactNode;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const FilterBar = ({ search, children, actions, className, ...props }: FilterBarProps) => {
|
|
19
|
-
return (
|
|
20
|
-
<div className={cn("udb-filter-bar", className)} {...props}>
|
|
21
|
-
{search && (
|
|
22
|
-
<SearchBox
|
|
23
|
-
value={search.value}
|
|
24
|
-
onChange={search.onChange}
|
|
25
|
-
placeholder={search.placeholder}
|
|
26
|
-
className="udb-filter-bar__search"
|
|
27
|
-
/>
|
|
28
|
-
)}
|
|
29
|
-
{children && <div className="udb-filter-bar__fields">{children}</div>}
|
|
30
|
-
|
|
31
|
-
{actions && <div className="udb-filter-bar__actions">{actions}</div>}
|
|
32
|
-
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
FilterBar.displayName = "FilterBar";
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { renderToString } from "react-dom/server";
|
|
3
|
-
import {
|
|
4
|
-
FilterPanel,
|
|
5
|
-
FilterSection,
|
|
6
|
-
CheckFilterList,
|
|
7
|
-
SingleSelectFilterList,
|
|
8
|
-
} from "./FilterPanel";
|
|
9
|
-
|
|
10
|
-
describe("FilterPanel", () => {
|
|
11
|
-
it("renders the header, clear action and sections", () => {
|
|
12
|
-
const html = renderToString(
|
|
13
|
-
<FilterPanel title="Program filters" onClear={() => undefined}>
|
|
14
|
-
<FilterSection title="Status">
|
|
15
|
-
<span>body</span>
|
|
16
|
-
</FilterSection>
|
|
17
|
-
</FilterPanel>,
|
|
18
|
-
);
|
|
19
|
-
expect(html).toContain('aria-label="Program filters"');
|
|
20
|
-
expect(html).toContain("Program filters");
|
|
21
|
-
expect(html).toContain("Clear all");
|
|
22
|
-
expect(html).toContain("Status");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("can disable and label the clear action", () => {
|
|
26
|
-
const html = renderToString(
|
|
27
|
-
<FilterPanel onClear={() => undefined} clearDisabled clearLabel="Temizle">
|
|
28
|
-
<span>body</span>
|
|
29
|
-
</FilterPanel>,
|
|
30
|
-
);
|
|
31
|
-
expect(html).toContain("Temizle");
|
|
32
|
-
expect(html).toContain("disabled");
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe("CheckFilterList", () => {
|
|
37
|
-
const options = Array.from({ length: 10 }, (_, i) => ({
|
|
38
|
-
value: `v${i}`,
|
|
39
|
-
label: `Option ${i}`,
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
it("marks selected options checked", () => {
|
|
43
|
-
const html = renderToString(
|
|
44
|
-
<CheckFilterList options={options.slice(0, 3)} selected={["v1"]} onToggle={() => undefined} />,
|
|
45
|
-
);
|
|
46
|
-
expect(html).toContain('aria-checked="true"');
|
|
47
|
-
expect(html).toContain("Option 1");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("caps visible options, keeps hidden selected ones and notes the rest", () => {
|
|
51
|
-
const html = renderToString(
|
|
52
|
-
<CheckFilterList options={options} selected={["v9"]} onToggle={() => undefined} maxVisible={4} />,
|
|
53
|
-
);
|
|
54
|
-
expect(html).toContain("Option 3");
|
|
55
|
-
expect(html).toContain("Option 9");
|
|
56
|
-
expect(html).not.toContain("Option 5<");
|
|
57
|
-
expect(html).toContain("+5 more");
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe("SingleSelectFilterList", () => {
|
|
62
|
-
const options = [
|
|
63
|
-
{ value: "all", label: "All", count: 42 },
|
|
64
|
-
{ value: "open", label: "Open", count: 7 },
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
it("marks the active option as the checked radio", () => {
|
|
68
|
-
const html = renderToString(
|
|
69
|
-
<SingleSelectFilterList options={options} value="open" onChange={() => undefined} />,
|
|
70
|
-
);
|
|
71
|
-
expect(html).toContain('role="radio"');
|
|
72
|
-
expect(html).toContain('aria-checked="true"');
|
|
73
|
-
expect(html).toContain(">7</span>");
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { Check } from 'lucide-react';
|
|
3
|
-
|
|
4
|
-
export interface FilterPanelProps {
|
|
5
|
-
title?: string;
|
|
6
|
-
onClear?: () => void;
|
|
7
|
-
clearDisabled?: boolean;
|
|
8
|
-
clearLabel?: string;
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
className?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function FilterPanel({
|
|
14
|
-
title = 'Filters',
|
|
15
|
-
onClear,
|
|
16
|
-
clearDisabled,
|
|
17
|
-
clearLabel = 'Clear all',
|
|
18
|
-
children,
|
|
19
|
-
className,
|
|
20
|
-
}: FilterPanelProps) {
|
|
21
|
-
return (
|
|
22
|
-
<aside className={className !== undefined ? `udb-filter-panel ${className}` : 'udb-filter-panel'} aria-label={title}>
|
|
23
|
-
<div className="udb-filter-panel__header">
|
|
24
|
-
<span className="udb-filter-panel__title">{title}</span>
|
|
25
|
-
{onClear !== undefined && (
|
|
26
|
-
<button type="button" className="udb-filter-panel__clear" onClick={onClear} disabled={clearDisabled}>
|
|
27
|
-
{clearLabel}
|
|
28
|
-
</button>
|
|
29
|
-
)}
|
|
30
|
-
</div>
|
|
31
|
-
<div className="udb-filter-panel__sections">{children}</div>
|
|
32
|
-
</aside>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface FilterSectionProps {
|
|
37
|
-
title: string;
|
|
38
|
-
children: ReactNode;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function FilterSection({ title, children }: FilterSectionProps) {
|
|
42
|
-
return (
|
|
43
|
-
<section className="udb-filter-section">
|
|
44
|
-
<h4 className="udb-filter-section__title">{title}</h4>
|
|
45
|
-
<div className="udb-filter-section__body">{children}</div>
|
|
46
|
-
</section>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface FilterListOption {
|
|
51
|
-
value: string;
|
|
52
|
-
label: string;
|
|
53
|
-
count?: number;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface CheckFilterListProps {
|
|
57
|
-
options: readonly FilterListOption[];
|
|
58
|
-
selected: readonly string[];
|
|
59
|
-
onToggle: (value: string) => void;
|
|
60
|
-
maxVisible?: number;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function CheckFilterList({ options, selected, onToggle, maxVisible = 8 }: CheckFilterListProps) {
|
|
64
|
-
const visible = options.slice(0, maxVisible);
|
|
65
|
-
const hasMore = options.length > maxVisible;
|
|
66
|
-
const hiddenSelected = options.slice(maxVisible).filter((option) => selected.includes(option.value));
|
|
67
|
-
const shown = hasMore ? [...visible, ...hiddenSelected] : visible;
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<ul className="udb-check-filter" role="group">
|
|
71
|
-
{shown.map((option) => {
|
|
72
|
-
const isSelected = selected.includes(option.value);
|
|
73
|
-
return (
|
|
74
|
-
<li key={option.value}>
|
|
75
|
-
<button
|
|
76
|
-
type="button"
|
|
77
|
-
role="checkbox"
|
|
78
|
-
aria-checked={isSelected}
|
|
79
|
-
className={isSelected ? 'udb-check-filter__item udb-check-filter__item--checked' : 'udb-check-filter__item'}
|
|
80
|
-
onClick={() => onToggle(option.value)}
|
|
81
|
-
>
|
|
82
|
-
<span className="udb-check-filter__box" aria-hidden="true">
|
|
83
|
-
{isSelected && <Check size={12} strokeWidth={3} />}
|
|
84
|
-
</span>
|
|
85
|
-
<span className="udb-check-filter__label">{option.label}</span>
|
|
86
|
-
{option.count !== undefined && <span className="udb-check-filter__count">{option.count}</span>}
|
|
87
|
-
</button>
|
|
88
|
-
</li>
|
|
89
|
-
);
|
|
90
|
-
})}
|
|
91
|
-
{hasMore && (
|
|
92
|
-
<li className="udb-check-filter__more">{`+${options.length - shown.length} more`}</li>
|
|
93
|
-
)}
|
|
94
|
-
</ul>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export interface SingleSelectFilterListProps {
|
|
99
|
-
options: readonly FilterListOption[];
|
|
100
|
-
value: string | null;
|
|
101
|
-
onChange: (value: string | null) => void;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function SingleSelectFilterList({ options, value, onChange }: SingleSelectFilterListProps) {
|
|
105
|
-
return (
|
|
106
|
-
<ul className="udb-check-filter" role="group">
|
|
107
|
-
{options.map((option) => {
|
|
108
|
-
const isActive = value === option.value;
|
|
109
|
-
return (
|
|
110
|
-
<li key={option.value}>
|
|
111
|
-
<button
|
|
112
|
-
type="button"
|
|
113
|
-
role="radio"
|
|
114
|
-
aria-checked={isActive}
|
|
115
|
-
className={isActive ? 'udb-check-filter__item udb-check-filter__item--checked' : 'udb-check-filter__item'}
|
|
116
|
-
onClick={() => onChange(isActive ? null : option.value)}
|
|
117
|
-
>
|
|
118
|
-
<span className="udb-check-filter__box udb-check-filter__box--radio" aria-hidden="true">
|
|
119
|
-
{isActive && <span className="udb-check-filter__radio-dot" />}
|
|
120
|
-
</span>
|
|
121
|
-
<span className="udb-check-filter__label">{option.label}</span>
|
|
122
|
-
{option.count !== undefined && <span className="udb-check-filter__count">{option.count}</span>}
|
|
123
|
-
</button>
|
|
124
|
-
</li>
|
|
125
|
-
);
|
|
126
|
-
})}
|
|
127
|
-
</ul>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { renderToString } from "react-dom/server";
|
|
3
|
-
import { FilterSelect } from "./FilterSelect";
|
|
4
|
-
|
|
5
|
-
describe("FilterSelect", () => {
|
|
6
|
-
const options = [
|
|
7
|
-
{ value: "open", label: "Open" },
|
|
8
|
-
{ value: "closed", label: "Closed" },
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
it("renders the all-entry plus options and reports the chosen value", () => {
|
|
12
|
-
const chosen: string[] = [];
|
|
13
|
-
const html = renderToString(
|
|
14
|
-
<FilterSelect
|
|
15
|
-
value="open"
|
|
16
|
-
options={options}
|
|
17
|
-
ariaLabel="Filter by status"
|
|
18
|
-
allLabel="Any status"
|
|
19
|
-
onChange={(v) => chosen.push(v)}
|
|
20
|
-
/>,
|
|
21
|
-
);
|
|
22
|
-
expect(html).toContain('aria-label="Filter by status"');
|
|
23
|
-
expect(html).toContain("Any status");
|
|
24
|
-
expect(html).toContain("Open");
|
|
25
|
-
expect(html).toContain("Closed");
|
|
26
|
-
expect(chosen).toEqual([]);
|
|
27
|
-
});
|
|
28
|
-
});
|