@box/blueprint-web 9.17.1 → 9.18.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/lib-esm/index.css +114 -54
- package/lib-esm/list-item/cell/cell.d.ts +4 -0
- package/lib-esm/list-item/cell/cell.js +11 -1
- package/lib-esm/list-item/index.d.ts +6 -2
- package/lib-esm/list-item/index.js +2 -0
- package/lib-esm/list-item/list-item.d.ts +6 -2
- package/lib-esm/list-item/main.module.js +1 -1
- package/lib-esm/list-item/row.js +15 -6
- package/lib-esm/list-item/table-column.d.ts +9 -0
- package/lib-esm/list-item/table-column.js +50 -7
- package/lib-esm/list-item/table-header.d.ts +2 -1
- package/lib-esm/list-item/table-header.js +37 -6
- package/lib-esm/list-item/table.d.ts +35 -2
- package/lib-esm/list-item/table.js +24 -9
- package/lib-esm/list-item/utils/column-metadata.d.ts +10 -0
- package/lib-esm/list-item/utils/columnVisibilityContext.d.ts +20 -0
- package/lib-esm/list-item/utils/columnVisibilityContext.js +40 -0
- package/lib-esm/list-item/utils/useColumnVisibilityManager.d.ts +7 -0
- package/lib-esm/list-item/utils/useColumnVisibilityManager.js +84 -0
- package/lib-esm/list-item/utils/useThrottledContainerResize.d.ts +1 -0
- package/lib-esm/list-item/utils/useThrottledContainerResize.js +38 -0
- package/package.json +2 -2
package/lib-esm/index.css
CHANGED
|
@@ -2411,22 +2411,29 @@
|
|
|
2411
2411
|
.bp_list_checkbox_module_checkbox--d79fa[data-disabled]{
|
|
2412
2412
|
opacity:.4;
|
|
2413
2413
|
}
|
|
2414
|
-
|
|
2415
|
-
|
|
2414
|
+
|
|
2415
|
+
.bp_main_module_resizableTableContainer--c7e00{
|
|
2416
|
+
min-width:100%;
|
|
2416
2417
|
}
|
|
2417
|
-
.bp_main_module_resizableTableContainer--
|
|
2418
|
+
.bp_main_module_resizableTableContainer--c7e00 table{
|
|
2418
2419
|
--item-background:var(--background-background);
|
|
2419
|
-
--outline-offset-focus-row
|
|
2420
|
-
--outline-offset-focus-cell
|
|
2420
|
+
--outline-offset-focus-row:-.25rem;
|
|
2421
|
+
--outline-offset-focus-cell:-.1875rem;
|
|
2422
|
+
--outline-offset-focus-header:var(--space-1);
|
|
2423
|
+
--outline-offset-focus-resizer:1px;
|
|
2421
2424
|
--border-radius:var(--border-radius-datatable, var(--radius-4));
|
|
2422
|
-
--outline-offset-focus-and-selected-row:var(--outline-offset-focus-and-selected-row-datatable,
|
|
2425
|
+
--outline-offset-focus-and-selected-row:var(--outline-offset-focus-and-selected-row-datatable, -.35rem);
|
|
2423
2426
|
--outline-select-color:var(--outline-select-color-datatable, var(--box-blue-100));
|
|
2424
2427
|
--outline-focus-color:var(--outline-focus-on-light);
|
|
2425
2428
|
border-collapse:initial;
|
|
2426
2429
|
border-spacing:0;
|
|
2430
|
+
width:100% !important;
|
|
2431
|
+
}
|
|
2432
|
+
.bp_main_module_resizableTableContainer--c7e00 .bp_main_module_resizableTable--c7e00{
|
|
2433
|
+
table-layout:auto !important;
|
|
2427
2434
|
}
|
|
2428
2435
|
|
|
2429
|
-
.bp_main_module_tableHeader--
|
|
2436
|
+
.bp_main_module_tableHeader--c7e00 tr > th{
|
|
2430
2437
|
font-family:Lato, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
|
|
2431
2438
|
font-size:.75rem;
|
|
2432
2439
|
font-weight:400;
|
|
@@ -2439,59 +2446,108 @@
|
|
|
2439
2446
|
text-transform:none;
|
|
2440
2447
|
white-space:nowrap;
|
|
2441
2448
|
}
|
|
2442
|
-
.bp_main_module_tableHeader--
|
|
2449
|
+
.bp_main_module_tableHeader--c7e00 tr > th:first-child{
|
|
2443
2450
|
border-radius:var(--border-radius) 0 0 var(--border-radius);
|
|
2444
2451
|
}
|
|
2445
|
-
.bp_main_module_tableHeader--
|
|
2452
|
+
.bp_main_module_tableHeader--c7e00 tr > th:last-child{
|
|
2446
2453
|
border-radius:0 var(--border-radius) var(--border-radius) 0;
|
|
2447
2454
|
}
|
|
2448
|
-
.bp_main_module_tableHeader--
|
|
2455
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00{
|
|
2449
2456
|
color:var(--text-text-on-light-secondary);
|
|
2450
2457
|
outline:none;
|
|
2458
|
+
overflow:visible;
|
|
2451
2459
|
text-align:left;
|
|
2452
2460
|
}
|
|
2453
|
-
.bp_main_module_tableHeader--
|
|
2461
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_columnNameWrapper--c7e00{
|
|
2462
|
+
align-items:center;
|
|
2463
|
+
display:flex;
|
|
2464
|
+
flex:1 0 0;
|
|
2465
|
+
gap:var(--space-2);
|
|
2466
|
+
overflow:hidden;
|
|
2467
|
+
}
|
|
2468
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_columnNameWrapper--c7e00 .bp_main_module_columnName--c7e00{
|
|
2469
|
+
min-width:0;
|
|
2454
2470
|
overflow:hidden;
|
|
2455
2471
|
text-overflow:ellipsis;
|
|
2456
2472
|
white-space:nowrap;
|
|
2457
2473
|
}
|
|
2458
|
-
.bp_main_module_tableHeader--
|
|
2459
|
-
|
|
2474
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_columnNameWrapper--c7e00:focus-visible{
|
|
2475
|
+
outline:none;
|
|
2460
2476
|
}
|
|
2461
|
-
.bp_main_module_tableHeader--
|
|
2477
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_columnNameWrapper--c7e00.bp_main_module_focusVisible--c7e00{
|
|
2462
2478
|
outline:var(--border-2) solid var(--outline-focus-color);
|
|
2463
|
-
outline-offset:var(--outline-offset-focus-
|
|
2464
|
-
|
|
2479
|
+
outline-offset:var(--outline-offset-focus-header);
|
|
2480
|
+
}
|
|
2481
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00[colspan]{
|
|
2482
|
+
text-align:center;
|
|
2465
2483
|
}
|
|
2466
|
-
.bp_main_module_tableHeader--
|
|
2484
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_rotateArrow--c7e00{
|
|
2467
2485
|
transform:rotateX(180deg);
|
|
2468
2486
|
}
|
|
2469
|
-
.bp_main_module_tableHeader--
|
|
2487
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_sorted--c7e00{
|
|
2470
2488
|
color:var(--text-text-on-light);
|
|
2471
2489
|
font-weight:bold;
|
|
2472
2490
|
}
|
|
2473
|
-
.bp_main_module_tableHeader--
|
|
2474
|
-
align-items:
|
|
2491
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_sortingFlexWrapper--c7e00{
|
|
2492
|
+
align-items:center;
|
|
2475
2493
|
display:flex;
|
|
2476
2494
|
gap:var(--space-2);
|
|
2477
2495
|
padding:var(--space-2) var(--space-3);
|
|
2496
|
+
position:relative;
|
|
2478
2497
|
}
|
|
2479
|
-
.bp_main_module_tableHeader--
|
|
2498
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_sortingFlexWrapper--c7e00 svg{
|
|
2480
2499
|
flex-shrink:0;
|
|
2481
2500
|
}
|
|
2482
|
-
.bp_main_module_tableHeader--
|
|
2501
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_columnResizer--c7e00{
|
|
2502
|
+
background-color:var(--border-tab-border-hover);
|
|
2503
|
+
flex:0 0 auto;
|
|
2504
|
+
height:var(--size-6);
|
|
2505
|
+
position:absolute;
|
|
2506
|
+
right:0;
|
|
2507
|
+
touch-action:none;
|
|
2508
|
+
width:var(--border-2);
|
|
2509
|
+
}
|
|
2510
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_columnResizer--c7e00[data-resizable-direction=both]{
|
|
2511
|
+
cursor:ew-resize;
|
|
2512
|
+
}
|
|
2513
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_columnResizer--c7e00[data-resizable-direction=left]{
|
|
2514
|
+
cursor:e-resize;
|
|
2515
|
+
}
|
|
2516
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_columnResizer--c7e00[data-resizable-direction=right]{
|
|
2517
|
+
cursor:w-resize;
|
|
2518
|
+
}
|
|
2519
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00 .bp_main_module_columnResizer--c7e00[data-focus-visible]{
|
|
2520
|
+
outline:var(--border-2) solid var(--outline-focus-color);
|
|
2521
|
+
outline-offset:var(--outline-offset-focus-resizer);
|
|
2522
|
+
}
|
|
2523
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00:last-of-type .bp_main_module_columnResizer--c7e00{
|
|
2524
|
+
display:none;
|
|
2525
|
+
}
|
|
2526
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00:hover:not([data-sort-direction])[data-allows-sorting],.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00[data-focus-visible]:not([data-sort-direction])[data-allows-sorting]{
|
|
2483
2527
|
color:var(--text-text-on-light);
|
|
2484
2528
|
font-weight:bold;
|
|
2485
2529
|
}
|
|
2486
|
-
.bp_main_module_tableHeader--
|
|
2530
|
+
.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00:hover:not([data-sort-direction]) svg,.bp_main_module_tableHeader--c7e00 .bp_main_module_column--c7e00[data-focus-visible]:not([data-sort-direction]) svg{
|
|
2487
2531
|
transform:rotateX(180deg);
|
|
2488
2532
|
visibility:visible;
|
|
2489
2533
|
}
|
|
2490
2534
|
|
|
2491
|
-
.
|
|
2535
|
+
.bp_main_module_column--c7e00.bp_main_module_droppableColumn--c7e00{
|
|
2536
|
+
min-width:160px;
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
.bp_main_module_column--c7e00.bp_main_module_actionColumn--c7e00{
|
|
2540
|
+
min-width:1px;
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
.bp_main_module_column--c7e00.bp_main_module_hiddenColumn--c7e00{
|
|
2544
|
+
display:none;
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
.bp_main_module_tableBody--c7e00[data-empty]{
|
|
2492
2548
|
text-align:center;
|
|
2493
2549
|
}
|
|
2494
|
-
.bp_main_module_tableBody--
|
|
2550
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00{
|
|
2495
2551
|
background:var(--item-background);
|
|
2496
2552
|
border-radius:var(--border-radius);
|
|
2497
2553
|
color:var(--text-text-on-light);
|
|
@@ -2502,7 +2558,7 @@
|
|
|
2502
2558
|
position:relative;
|
|
2503
2559
|
transform:translateZ(0);
|
|
2504
2560
|
}
|
|
2505
|
-
.bp_main_module_tableBody--
|
|
2561
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00::after{
|
|
2506
2562
|
background:#0000;
|
|
2507
2563
|
border-top:var(--border-1) solid var(--gray-10);
|
|
2508
2564
|
box-sizing:border-box;
|
|
@@ -2515,20 +2571,21 @@
|
|
|
2515
2571
|
width:100%;
|
|
2516
2572
|
z-index:999;
|
|
2517
2573
|
}
|
|
2518
|
-
.bp_main_module_tableBody--
|
|
2574
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[aria-selected=true]{
|
|
2519
2575
|
--item-background:var(--box-blue-05);
|
|
2520
2576
|
}
|
|
2521
|
-
.bp_main_module_tableBody--
|
|
2577
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[aria-selected=true]::after{
|
|
2522
2578
|
border:var(--border-2) solid var(--outline-select-color);
|
|
2523
2579
|
border-radius:var(--border-radius);
|
|
2524
2580
|
}
|
|
2525
|
-
.bp_main_module_tableBody--
|
|
2581
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[aria-selected=true] .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00{
|
|
2526
2582
|
opacity:1;
|
|
2527
2583
|
}
|
|
2528
|
-
.bp_main_module_tableBody--
|
|
2584
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[aria-selected=true] .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00 .bp_main_module_actionChildren--c7e00{
|
|
2529
2585
|
display:none;
|
|
2530
2586
|
}
|
|
2531
|
-
.bp_main_module_tableBody--
|
|
2587
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00 .bp_main_module_cell--c7e00{
|
|
2588
|
+
max-width:0;
|
|
2532
2589
|
outline:none;
|
|
2533
2590
|
overflow:hidden;
|
|
2534
2591
|
padding:var(--space-2) var(--space-3);
|
|
@@ -2537,25 +2594,25 @@
|
|
|
2537
2594
|
transform:translateZ(0);
|
|
2538
2595
|
white-space:nowrap;
|
|
2539
2596
|
}
|
|
2540
|
-
.bp_main_module_tableBody--
|
|
2597
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00 .bp_main_module_cell--c7e00[data-focus-visible]{
|
|
2541
2598
|
outline:var(--border-2) solid var(--outline-focus-color);
|
|
2542
2599
|
outline-offset:var(--outline-offset-focus-cell);
|
|
2543
2600
|
position:relative;
|
|
2544
2601
|
}
|
|
2545
|
-
.bp_main_module_tableBody--
|
|
2602
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00 .bp_main_module_cell--c7e00:first-child{
|
|
2546
2603
|
border-radius:var(--border-radius) 0 0 var(--border-radius);
|
|
2547
2604
|
}
|
|
2548
|
-
.bp_main_module_tableBody--
|
|
2605
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00 .bp_main_module_cell--c7e00:last-child{
|
|
2549
2606
|
border-radius:0 var(--border-radius) var(--border-radius) 0;
|
|
2550
2607
|
}
|
|
2551
|
-
.bp_main_module_tableBody--
|
|
2608
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00 .bp_main_module_cell--c7e00.bp_main_module_actions--c7e00{
|
|
2552
2609
|
overflow:unset;
|
|
2553
2610
|
padding:0;
|
|
2554
2611
|
position:sticky;
|
|
2555
2612
|
right:0;
|
|
2556
2613
|
width:var(--size-6);
|
|
2557
2614
|
}
|
|
2558
|
-
.bp_main_module_tableBody--
|
|
2615
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00 .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00{
|
|
2559
2616
|
align-items:center;
|
|
2560
2617
|
background:var(--item-background);
|
|
2561
2618
|
bottom:0;
|
|
@@ -2569,7 +2626,7 @@
|
|
|
2569
2626
|
right:var(--size-4);
|
|
2570
2627
|
top:0;
|
|
2571
2628
|
}
|
|
2572
|
-
.bp_main_module_tableBody--
|
|
2629
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00 .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00::before{
|
|
2573
2630
|
box-shadow:-.25rem 0 .625rem .625rem var(--item-background);
|
|
2574
2631
|
content:"";
|
|
2575
2632
|
display:block;
|
|
@@ -2579,65 +2636,68 @@
|
|
|
2579
2636
|
width:0;
|
|
2580
2637
|
z-index:0;
|
|
2581
2638
|
}
|
|
2582
|
-
.bp_main_module_tableBody--
|
|
2639
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00 .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00[data-state=open]{
|
|
2583
2640
|
opacity:1;
|
|
2584
2641
|
}
|
|
2585
|
-
.bp_main_module_tableBody--
|
|
2642
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00 .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00[data-state=open] .bp_main_module_actionChildren--c7e00{
|
|
2586
2643
|
display:block;
|
|
2587
2644
|
}
|
|
2588
|
-
.bp_main_module_tableBody--
|
|
2645
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00 .bp_main_module_cell--c7e00.bp_main_module_isCellHidden--c7e00{
|
|
2646
|
+
display:none;
|
|
2647
|
+
}
|
|
2648
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-dragging]{
|
|
2589
2649
|
opacity:.5;
|
|
2590
2650
|
transform:translateZ(0);
|
|
2591
2651
|
}
|
|
2592
|
-
.bp_main_module_tableBody--
|
|
2652
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-focus-visible]{
|
|
2593
2653
|
outline:var(--border-2) solid var(--outline-focus-color);
|
|
2594
2654
|
outline-offset:var(--outline-offset-focus-row);
|
|
2595
2655
|
}
|
|
2596
|
-
.bp_main_module_tableBody--
|
|
2656
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-focus-visible][aria-selected=true]{
|
|
2597
2657
|
background:var(--item-background);
|
|
2598
2658
|
outline-offset:var(--outline-offset-focus-and-selected-row);
|
|
2599
2659
|
}
|
|
2600
|
-
.bp_main_module_tableBody--
|
|
2660
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00:last-child::after{
|
|
2601
2661
|
border-bottom:var(--border-1) solid var(--gray-10);
|
|
2602
2662
|
}
|
|
2603
|
-
.bp_main_module_tableBody--
|
|
2663
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00:last-child[aria-selected=true]::after{
|
|
2604
2664
|
border-bottom:var(--border-2) solid var(--outline-select-color);
|
|
2605
2665
|
}
|
|
2606
|
-
.bp_main_module_tableBody--
|
|
2666
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00:focus-within,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-focus-visible],.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-hovered]{
|
|
2607
2667
|
z-index:1;
|
|
2608
2668
|
}
|
|
2609
|
-
.bp_main_module_tableBody--
|
|
2669
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00:focus-within:not([aria-selected=true])::after,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-focus-visible]:not([aria-selected=true])::after,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-hovered]:not([aria-selected=true])::after{
|
|
2610
2670
|
border-bottom:var(--border-1) solid #0000;
|
|
2611
2671
|
border-radius:var(--border-radius);
|
|
2612
2672
|
border-top:var(--border-1) solid #0000;
|
|
2613
2673
|
box-shadow:var(--dropshadow-2);
|
|
2614
2674
|
}
|
|
2615
|
-
.bp_main_module_tableBody--
|
|
2675
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00:focus-within:last-child:not([aria-selected=true])::after,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-focus-visible]:last-child:not([aria-selected=true])::after,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-hovered]:last-child:not([aria-selected=true])::after{
|
|
2616
2676
|
border-bottom:var(--border-1) solid #0000;
|
|
2617
2677
|
}
|
|
2618
|
-
.bp_main_module_tableBody--
|
|
2678
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00:focus-within + :not([data-hovered], [data-focus-visible], [aria-selected=true])::after, .bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-focus-visible] + :not([data-hovered], [data-focus-visible], [aria-selected=true])::after, .bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-hovered] + :not([data-hovered], [data-focus-visible], [aria-selected=true])::after{
|
|
2619
2679
|
border-top:var(--border-1) solid #0000;
|
|
2620
2680
|
}
|
|
2621
|
-
.bp_main_module_tableBody--
|
|
2681
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00:focus-within[data-dragging] .bp_main_module_actionsWrapper--c7e00,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00:focus-within[data-pressed] .bp_main_module_actionsWrapper--c7e00,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-focus-visible][data-dragging] .bp_main_module_actionsWrapper--c7e00,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-focus-visible][data-pressed] .bp_main_module_actionsWrapper--c7e00,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-hovered][data-dragging] .bp_main_module_actionsWrapper--c7e00,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-hovered][data-pressed] .bp_main_module_actionsWrapper--c7e00{
|
|
2622
2682
|
opacity:1;
|
|
2623
2683
|
}
|
|
2624
|
-
.bp_main_module_tableBody--
|
|
2684
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00:focus-within:not(:is([data-focus-visible], [aria-selected=true]))::after, .bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-focus-visible]:not(:is([data-focus-visible], [aria-selected=true]))::after, .bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-hovered]:not(:is([data-focus-visible], [aria-selected=true]))::after{
|
|
2625
2685
|
border:var(--border-1) solid var(--gray-10);
|
|
2626
2686
|
border-radius:var(--border-radius);
|
|
2627
2687
|
}
|
|
2628
|
-
.bp_main_module_tableBody--
|
|
2688
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00:focus-within .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-focus-visible] .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-hovered] .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00{
|
|
2629
2689
|
opacity:1;
|
|
2630
2690
|
}
|
|
2631
|
-
.bp_main_module_tableBody--
|
|
2691
|
+
.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00:focus-within .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00 .bp_main_module_actionChildren--c7e00,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-focus-visible] .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00 .bp_main_module_actionChildren--c7e00,.bp_main_module_tableBody--c7e00 .bp_main_module_row--c7e00[data-hovered] .bp_main_module_cell--c7e00 .bp_main_module_actionsWrapper--c7e00 .bp_main_module_actionChildren--c7e00{
|
|
2632
2692
|
display:block;
|
|
2633
2693
|
}
|
|
2634
2694
|
@supports selector(:has(*)){
|
|
2635
|
-
.bp_main_module_row--
|
|
2695
|
+
.bp_main_module_row--c7e00[aria-selected=true] + .bp_main_module_dropIndicator--c7e00 + [aria-selected=true]::after,.bp_main_module_row--c7e00[aria-selected=true] + [aria-selected=true] .bp_main_module_cell--c7e00:first-child,.bp_main_module_row--c7e00[aria-selected=true] + [aria-selected=true] .bp_main_module_cell--c7e00:last-child,.bp_main_module_row--c7e00[aria-selected=true] + [aria-selected=true]::after{
|
|
2636
2696
|
border-start-end-radius:0;
|
|
2637
2697
|
border-start-start-radius:0;
|
|
2638
2698
|
border-top-width:var(--border-1);
|
|
2639
2699
|
}
|
|
2640
|
-
.bp_main_module_row--
|
|
2700
|
+
.bp_main_module_row--c7e00[aria-selected=true]:has(+ .bp_main_module_dropIndicator--c7e00 + [aria-selected=true]) .bp_main_module_cell--c7e00:last-child,.bp_main_module_row--c7e00[aria-selected=true]:has(+ .bp_main_module_dropIndicator--c7e00 + [aria-selected=true])::after,.bp_main_module_row--c7e00[aria-selected=true]:has(+ [aria-selected=true]) .bp_main_module_cell--c7e00:first-child,.bp_main_module_row--c7e00[aria-selected=true]:has(+ [aria-selected=true])::after{
|
|
2641
2701
|
border-bottom-width:var(--border-1);
|
|
2642
2702
|
border-end-end-radius:0;
|
|
2643
2703
|
border-end-start-radius:0;
|
|
@@ -4,6 +4,7 @@ import { forwardRef } from 'react';
|
|
|
4
4
|
import { Cell as Cell$1 } from 'react-aria-components';
|
|
5
5
|
import { Ghost } from '../../ghost/ghost.js';
|
|
6
6
|
import styles from '../main.module.js';
|
|
7
|
+
import { useColumnVisibilityContext } from '../utils/columnVisibilityContext.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Based on React Aria Components `Cell`
|
|
@@ -14,15 +15,24 @@ const Cell = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
14
15
|
children,
|
|
15
16
|
loading,
|
|
16
17
|
className,
|
|
18
|
+
__ordinal,
|
|
17
19
|
...rest
|
|
18
20
|
} = props;
|
|
21
|
+
const {
|
|
22
|
+
isColumnHidden
|
|
23
|
+
} = useColumnVisibilityContext();
|
|
24
|
+
// At this point, we know that the internal __ordinal prop exists
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
26
|
+
const hideCell = isColumnHidden(__ordinal);
|
|
19
27
|
const ghostState = jsx(Ghost, {
|
|
20
28
|
width: "80%"
|
|
21
29
|
});
|
|
22
30
|
return jsx(Cell$1, {
|
|
23
31
|
...rest,
|
|
24
32
|
ref: ref,
|
|
25
|
-
className: clsx(styles.cell,
|
|
33
|
+
className: clsx(styles.cell, {
|
|
34
|
+
[styles.isCellHidden]: hideCell
|
|
35
|
+
}, className),
|
|
26
36
|
children: loading ? ghostState : children
|
|
27
37
|
});
|
|
28
38
|
});
|
|
@@ -3,7 +3,11 @@ import { type TableProps } from './table';
|
|
|
3
3
|
import { type TableBodyProps } from './table-body';
|
|
4
4
|
import { type ColumnProps } from './table-column';
|
|
5
5
|
import { type TableHeaderProps } from './table-header';
|
|
6
|
-
export declare const Table: import("react").ForwardRefExoticComponent<import("react-aria-components").TableProps &
|
|
6
|
+
export declare const Table: import("react").ForwardRefExoticComponent<import("react-aria-components").TableProps & {
|
|
7
|
+
isColumnDroppingEnabled?: boolean;
|
|
8
|
+
isColumnResizingEnabled?: boolean;
|
|
9
|
+
onVisibleColumnsChange?: import("./utils/column-metadata").OnColumnVisibilityChange;
|
|
10
|
+
} & import("react").RefAttributes<HTMLTableElement>>;
|
|
7
11
|
export declare const Cell: import("react").ForwardRefExoticComponent<import("./cell/cell").CellProps & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
8
12
|
export declare const Column: (props: ColumnProps & {
|
|
9
13
|
ref?: import("react").ForwardedRef<HTMLTableCellElement>;
|
|
@@ -13,7 +17,7 @@ export declare const TableBody: <T extends object>(props: TableBodyProps<T> & {
|
|
|
13
17
|
}) => ReturnType<(<T_1 extends object>(props: TableBodyProps<T_1>, ref: import("react").ForwardedRef<HTMLTableSectionElement>) => import("react/jsx-runtime").JSX.Element)>;
|
|
14
18
|
export declare const TableHeader: <T extends object>(props: TableHeaderProps<T> & {
|
|
15
19
|
ref?: import("react").ForwardedRef<HTMLTableSectionElement>;
|
|
16
|
-
}) => ReturnType<(<T_1 extends
|
|
20
|
+
}) => ReturnType<(<T_1 extends ColumnProps>(props: TableHeaderProps<T_1>, ref: import("react").ForwardedRef<HTMLTableSectionElement>) => import("react/jsx-runtime").JSX.Element)>;
|
|
17
21
|
export declare const Row: <T extends object>(props: RowProps<T> & {
|
|
18
22
|
ref?: import("react").ForwardedRef<HTMLTableRowElement>;
|
|
19
23
|
}) => ReturnType<(<T_1 extends object>(props: RowProps<T_1>, ref: import("react").ForwardedRef<HTMLTableRowElement>) => import("react/jsx-runtime").JSX.Element)>;
|
|
@@ -3,7 +3,11 @@ import { type TableProps } from './table';
|
|
|
3
3
|
import { type TableBodyProps } from './table-body';
|
|
4
4
|
import { type ColumnProps } from './table-column';
|
|
5
5
|
import { type TableHeaderProps } from './table-header';
|
|
6
|
-
export declare const Table: import("react").ForwardRefExoticComponent<import("react-aria-components").TableProps &
|
|
6
|
+
export declare const Table: import("react").ForwardRefExoticComponent<import("react-aria-components").TableProps & {
|
|
7
|
+
isColumnDroppingEnabled?: boolean;
|
|
8
|
+
isColumnResizingEnabled?: boolean;
|
|
9
|
+
onVisibleColumnsChange?: import("./utils/column-metadata").OnColumnVisibilityChange;
|
|
10
|
+
} & import("react").RefAttributes<HTMLTableElement>>;
|
|
7
11
|
export declare const Cell: import("react").ForwardRefExoticComponent<import("./cell/cell").CellProps & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
8
12
|
export declare const Column: (props: ColumnProps & {
|
|
9
13
|
ref?: import("react").ForwardedRef<HTMLTableCellElement>;
|
|
@@ -13,7 +17,7 @@ export declare const TableBody: <T extends object>(props: TableBodyProps<T> & {
|
|
|
13
17
|
}) => ReturnType<(<T_1 extends object>(props: TableBodyProps<T_1>, ref: import("react").ForwardedRef<HTMLTableSectionElement>) => import("react/jsx-runtime").JSX.Element)>;
|
|
14
18
|
export declare const TableHeader: <T extends object>(props: TableHeaderProps<T> & {
|
|
15
19
|
ref?: import("react").ForwardedRef<HTMLTableSectionElement>;
|
|
16
|
-
}) => ReturnType<(<T_1 extends
|
|
20
|
+
}) => ReturnType<(<T_1 extends ColumnProps>(props: TableHeaderProps<T_1>, ref: import("react").ForwardedRef<HTMLTableSectionElement>) => import("react/jsx-runtime").JSX.Element)>;
|
|
17
21
|
export declare const Row: <T extends object>(props: RowProps<T> & {
|
|
18
22
|
ref?: import("react").ForwardedRef<HTMLTableRowElement>;
|
|
19
23
|
}) => ReturnType<(<T_1 extends object>(props: RowProps<T_1>, ref: import("react").ForwardedRef<HTMLTableRowElement>) => import("react/jsx-runtime").JSX.Element)>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"resizableTableContainer":"bp_main_module_resizableTableContainer--
|
|
2
|
+
var styles = {"resizableTableContainer":"bp_main_module_resizableTableContainer--c7e00","resizableTable":"bp_main_module_resizableTable--c7e00","tableHeader":"bp_main_module_tableHeader--c7e00","column":"bp_main_module_column--c7e00","columnNameWrapper":"bp_main_module_columnNameWrapper--c7e00","columnName":"bp_main_module_columnName--c7e00","focusVisible":"bp_main_module_focusVisible--c7e00","rotateArrow":"bp_main_module_rotateArrow--c7e00","sorted":"bp_main_module_sorted--c7e00","sortingFlexWrapper":"bp_main_module_sortingFlexWrapper--c7e00","columnResizer":"bp_main_module_columnResizer--c7e00","droppableColumn":"bp_main_module_droppableColumn--c7e00","actionColumn":"bp_main_module_actionColumn--c7e00","hiddenColumn":"bp_main_module_hiddenColumn--c7e00","tableBody":"bp_main_module_tableBody--c7e00","row":"bp_main_module_row--c7e00","cell":"bp_main_module_cell--c7e00","actionsWrapper":"bp_main_module_actionsWrapper--c7e00","actionChildren":"bp_main_module_actionChildren--c7e00","actions":"bp_main_module_actions--c7e00","isCellHidden":"bp_main_module_isCellHidden--c7e00","dropIndicator":"bp_main_module_dropIndicator--c7e00"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
package/lib-esm/list-item/row.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { forwardRef } from 'react';
|
|
4
|
-
import { Row as Row$1
|
|
3
|
+
import { forwardRef, Children, isValidElement, cloneElement } from 'react';
|
|
4
|
+
import { Row as Row$1 } from 'react-aria-components';
|
|
5
5
|
import styles from './main.module.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -16,15 +16,24 @@ const RowInner = (props, ref) => {
|
|
|
16
16
|
className,
|
|
17
17
|
...rest
|
|
18
18
|
} = props;
|
|
19
|
+
let newChildren = children;
|
|
20
|
+
if (typeof children === 'function' && columns) {
|
|
21
|
+
newChildren = Array.from(columns).map(children);
|
|
22
|
+
}
|
|
23
|
+
const childrenWithOrdinals = Children.map(newChildren, (child, index) => {
|
|
24
|
+
if (! /*#__PURE__*/isValidElement(child)) {
|
|
25
|
+
return child;
|
|
26
|
+
}
|
|
27
|
+
return /*#__PURE__*/cloneElement(child, {
|
|
28
|
+
__ordinal: index
|
|
29
|
+
});
|
|
30
|
+
});
|
|
19
31
|
return jsx(Row$1, {
|
|
20
32
|
...rest,
|
|
21
33
|
ref: ref,
|
|
22
34
|
className: clsx(styles.row, className),
|
|
23
35
|
id: id,
|
|
24
|
-
children:
|
|
25
|
-
items: columns,
|
|
26
|
-
children: children
|
|
27
|
-
})
|
|
36
|
+
children: childrenWithOrdinals
|
|
28
37
|
});
|
|
29
38
|
};
|
|
30
39
|
const Row = /*#__PURE__*/forwardRef(RowInner);
|
|
@@ -4,6 +4,15 @@ export interface ColumnProps extends PrimitiveColumnProps {
|
|
|
4
4
|
hideHeader?: boolean;
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
className?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Determine whether the column is an action column (a column containing action cells).
|
|
9
|
+
* Must be set to `true` for action column if `isColumnDroppingEnabled` or `isColumnResizingEnabled` is enabled.
|
|
10
|
+
*/
|
|
11
|
+
actionColumn?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Internal use only.
|
|
14
|
+
*/
|
|
15
|
+
__ordinal?: number;
|
|
7
16
|
}
|
|
8
17
|
/**
|
|
9
18
|
* Based on React Aria Components `Column`
|
|
@@ -3,9 +3,13 @@ import { ArrowUp, ArrowDown } from '@box/blueprint-web-assets/icons/Fill';
|
|
|
3
3
|
import { Gray100 } from '@box/blueprint-web-assets/tokens/tokens';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { forwardRef } from 'react';
|
|
6
|
-
import {
|
|
6
|
+
import { useFocusRing } from 'react-aria';
|
|
7
|
+
import { Column as Column$1, ColumnResizer } from 'react-aria-components';
|
|
8
|
+
import { Focusable } from '../focusable/focusable.js';
|
|
9
|
+
import { useBreakpoint, Breakpoint } from '../utils/useBreakpoint.js';
|
|
7
10
|
import { VisuallyHidden } from '../visually-hidden/visually-hidden.js';
|
|
8
11
|
import styles from './main.module.js';
|
|
12
|
+
import { useColumnVisibilityContext } from './utils/columnVisibilityContext.js';
|
|
9
13
|
|
|
10
14
|
function SortingArrowIcon({
|
|
11
15
|
visibility = 'visible',
|
|
@@ -49,12 +53,41 @@ const ColumnInner = (props, ref) => {
|
|
|
49
53
|
hideHeader,
|
|
50
54
|
children,
|
|
51
55
|
className,
|
|
56
|
+
__ordinal,
|
|
57
|
+
actionColumn,
|
|
52
58
|
...rest
|
|
53
59
|
} = props;
|
|
60
|
+
const {
|
|
61
|
+
isColumnHidden,
|
|
62
|
+
isColumnResizable,
|
|
63
|
+
isColumnDroppingEnabled
|
|
64
|
+
} = useColumnVisibilityContext();
|
|
65
|
+
const breakpoint = useBreakpoint();
|
|
66
|
+
const isMobile = breakpoint <= Breakpoint.Medium;
|
|
67
|
+
// Workaround for issue where a mouse click triggers :focus-visible styles
|
|
68
|
+
const {
|
|
69
|
+
isFocusVisible,
|
|
70
|
+
focusProps
|
|
71
|
+
} = useFocusRing();
|
|
72
|
+
// At this point, we know that the internal __ordinal prop exists
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
74
|
+
const hideColumn = isColumnHidden(__ordinal);
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
76
|
+
const showResizer = isColumnResizable(__ordinal);
|
|
54
77
|
return jsx(Column$1, {
|
|
55
78
|
...rest,
|
|
56
79
|
ref: ref,
|
|
57
|
-
className: clsx(styles.column,
|
|
80
|
+
className: clsx(styles.column, {
|
|
81
|
+
[styles.hiddenColumn]: hideColumn
|
|
82
|
+
}, {
|
|
83
|
+
[styles.droppableColumn]: isColumnDroppingEnabled
|
|
84
|
+
}, {
|
|
85
|
+
[styles.actionColumn]: isColumnDroppingEnabled && actionColumn
|
|
86
|
+
}, className),
|
|
87
|
+
minWidth: isColumnDroppingEnabled ? 160 : rest.minWidth,
|
|
88
|
+
...(isColumnDroppingEnabled && hideColumn === !isMobile ? {
|
|
89
|
+
width: '100%'
|
|
90
|
+
} : {}),
|
|
58
91
|
children: ({
|
|
59
92
|
allowsSorting,
|
|
60
93
|
sortDirection
|
|
@@ -64,11 +97,21 @@ const ColumnInner = (props, ref) => {
|
|
|
64
97
|
}),
|
|
65
98
|
children: [hideHeader ? jsx(VisuallyHidden, {
|
|
66
99
|
children: children
|
|
67
|
-
}) : jsx(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
100
|
+
}) : jsx(Focusable, {
|
|
101
|
+
children: jsxs("div", {
|
|
102
|
+
...focusProps,
|
|
103
|
+
className: clsx(styles.columnNameWrapper, {
|
|
104
|
+
[styles.focusVisible]: isFocusVisible
|
|
105
|
+
}),
|
|
106
|
+
children: [jsx("span", {
|
|
107
|
+
className: styles.columnName,
|
|
108
|
+
children: children
|
|
109
|
+
}), allowsSorting && jsx(SortIndicator, {
|
|
110
|
+
direction: sortDirection
|
|
111
|
+
})]
|
|
112
|
+
})
|
|
113
|
+
}), !hideHeader && showResizer && jsx(ColumnResizer, {
|
|
114
|
+
className: styles.columnResizer
|
|
72
115
|
})]
|
|
73
116
|
})
|
|
74
117
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type ForwardedRef } from 'react';
|
|
2
2
|
import { type TableHeaderProps as PrimitiveTableHeaderProps } from 'react-aria-components';
|
|
3
|
+
import { type ColumnProps } from './table-column';
|
|
3
4
|
export type TableHeaderProps<T> = PrimitiveTableHeaderProps<T>;
|
|
4
5
|
/**
|
|
5
6
|
* Based on React Aria Components `TableHeader`
|
|
6
7
|
* @see https://react-spectrum.adobe.com/react-aria/Table.html#tableheader
|
|
7
8
|
*/
|
|
8
|
-
declare const TableHeaderInner: <T extends
|
|
9
|
+
declare const TableHeaderInner: <T extends ColumnProps>(props: TableHeaderProps<T>, ref: ForwardedRef<HTMLTableSectionElement>) => import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export declare const TableHeader: <T extends object>(props: TableHeaderProps<T> & {
|
|
10
11
|
ref?: ForwardedRef<HTMLTableSectionElement>;
|
|
11
12
|
}) => ReturnType<typeof TableHeaderInner>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { forwardRef } from 'react';
|
|
4
|
-
import { TableHeader as TableHeader$1
|
|
3
|
+
import { forwardRef, useMemo, Children, isValidElement, cloneElement, useEffect } from 'react';
|
|
4
|
+
import { TableHeader as TableHeader$1 } from 'react-aria-components';
|
|
5
5
|
import styles from './main.module.js';
|
|
6
|
+
import { useColumnVisibilityContext } from './utils/columnVisibilityContext.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Based on React Aria Components `TableHeader`
|
|
@@ -15,14 +16,44 @@ const TableHeaderInner = (props, ref) => {
|
|
|
15
16
|
className,
|
|
16
17
|
...rest
|
|
17
18
|
} = props;
|
|
19
|
+
const {
|
|
20
|
+
setColumnsMetadata
|
|
21
|
+
} = useColumnVisibilityContext();
|
|
22
|
+
const newChildren = useMemo(() => {
|
|
23
|
+
// If `children` is a function, we are dynamically generating header cells.
|
|
24
|
+
// We iterate over `columns` and call `children(column)` for each one,
|
|
25
|
+
// creating a `Column` component for each column in the table.
|
|
26
|
+
// This ensures we can later assign an `__ordinal` property to each column.
|
|
27
|
+
if (typeof children === 'function' && columns) {
|
|
28
|
+
return columns.map(children);
|
|
29
|
+
}
|
|
30
|
+
return children;
|
|
31
|
+
}, [children, columns]);
|
|
32
|
+
const childrenWithOrdinals = useMemo(() => {
|
|
33
|
+
return Children.map(newChildren, (child, index) => {
|
|
34
|
+
if (! /*#__PURE__*/isValidElement(child)) {
|
|
35
|
+
return child;
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/cloneElement(child, {
|
|
38
|
+
__ordinal: index
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}, [newChildren]);
|
|
42
|
+
const columnsMetadata = useMemo(() => {
|
|
43
|
+
return Children.toArray(childrenWithOrdinals).map(child => ({
|
|
44
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
45
|
+
ordinal: child.props.__ordinal,
|
|
46
|
+
actionColumn: child.props.actionColumn
|
|
47
|
+
}));
|
|
48
|
+
}, [childrenWithOrdinals]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
setColumnsMetadata(columnsMetadata);
|
|
51
|
+
}, [columnsMetadata, setColumnsMetadata]);
|
|
18
52
|
return jsx(TableHeader$1, {
|
|
19
53
|
...rest,
|
|
20
54
|
ref: ref,
|
|
21
55
|
className: clsx(styles.tableHeader, className),
|
|
22
|
-
children:
|
|
23
|
-
items: columns,
|
|
24
|
-
children: children
|
|
25
|
-
})
|
|
56
|
+
children: childrenWithOrdinals
|
|
26
57
|
});
|
|
27
58
|
};
|
|
28
59
|
const TableHeader = /*#__PURE__*/forwardRef(TableHeaderInner);
|
|
@@ -1,7 +1,40 @@
|
|
|
1
1
|
import { type TableProps as PrimitiveTableProps } from 'react-aria-components';
|
|
2
|
-
|
|
2
|
+
import { type OnColumnVisibilityChange } from './utils/column-metadata';
|
|
3
|
+
export type TableProps = PrimitiveTableProps & {
|
|
4
|
+
/**
|
|
5
|
+
* Setting this to true enables the column dropping functionality.
|
|
6
|
+
*/
|
|
7
|
+
isColumnDroppingEnabled?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Setting this to true enables the column resizing functionality.
|
|
10
|
+
*/
|
|
11
|
+
isColumnResizingEnabled?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Callback fired when the visibility of columns changes.
|
|
14
|
+
* @param columnVisibility - An object containing:
|
|
15
|
+
* - `visibleColumns`: An array of column indexes that are currently visible.
|
|
16
|
+
* - `hiddenColumns`: An array of column indexes that are currently hidden.
|
|
17
|
+
*/
|
|
18
|
+
onVisibleColumnsChange?: OnColumnVisibilityChange;
|
|
19
|
+
};
|
|
3
20
|
/**
|
|
4
21
|
* Based on React Aria Components `Table`
|
|
5
22
|
* @see https://react-spectrum.adobe.com/react-aria/Table.html#table-1
|
|
6
23
|
*/
|
|
7
|
-
export declare const Table: import("react").ForwardRefExoticComponent<PrimitiveTableProps &
|
|
24
|
+
export declare const Table: import("react").ForwardRefExoticComponent<PrimitiveTableProps & {
|
|
25
|
+
/**
|
|
26
|
+
* Setting this to true enables the column dropping functionality.
|
|
27
|
+
*/
|
|
28
|
+
isColumnDroppingEnabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Setting this to true enables the column resizing functionality.
|
|
31
|
+
*/
|
|
32
|
+
isColumnResizingEnabled?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Callback fired when the visibility of columns changes.
|
|
35
|
+
* @param columnVisibility - An object containing:
|
|
36
|
+
* - `visibleColumns`: An array of column indexes that are currently visible.
|
|
37
|
+
* - `hiddenColumns`: An array of column indexes that are currently hidden.
|
|
38
|
+
*/
|
|
39
|
+
onVisibleColumnsChange?: OnColumnVisibilityChange;
|
|
40
|
+
} & import("react").RefAttributes<HTMLTableElement>>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import noop from 'lodash/noop';
|
|
3
|
-
import { forwardRef } from 'react';
|
|
3
|
+
import { forwardRef, useRef } from 'react';
|
|
4
4
|
import { ResizableTableContainer, Table as Table$1 } from 'react-aria-components';
|
|
5
|
+
import clsx from 'clsx';
|
|
5
6
|
import styles from './main.module.js';
|
|
7
|
+
import { ColumnVisibilityProvider } from './utils/columnVisibilityContext.js';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Based on React Aria Components `Table`
|
|
@@ -13,16 +15,29 @@ const Table = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
13
15
|
children,
|
|
14
16
|
className,
|
|
15
17
|
onRowAction = noop,
|
|
18
|
+
onVisibleColumnsChange,
|
|
19
|
+
isColumnDroppingEnabled = false,
|
|
20
|
+
isColumnResizingEnabled = false,
|
|
16
21
|
...rest
|
|
17
22
|
} = props;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const containerRef = useRef(null);
|
|
24
|
+
return jsx(ColumnVisibilityProvider, {
|
|
25
|
+
containerRef: containerRef,
|
|
26
|
+
isColumnDroppingEnabled: isColumnDroppingEnabled,
|
|
27
|
+
isColumnResizingEnabled: isColumnResizingEnabled,
|
|
28
|
+
onVisibleColumnsChange: onVisibleColumnsChange,
|
|
29
|
+
children: jsx(ResizableTableContainer, {
|
|
30
|
+
ref: containerRef,
|
|
31
|
+
className: styles.resizableTableContainer,
|
|
32
|
+
children: jsx(Table$1, {
|
|
33
|
+
...rest,
|
|
34
|
+
ref: ref,
|
|
35
|
+
className: clsx({
|
|
36
|
+
[styles.resizableTable]: isColumnResizingEnabled || isColumnDroppingEnabled
|
|
37
|
+
}, className),
|
|
38
|
+
onRowAction: onRowAction,
|
|
39
|
+
children: children
|
|
40
|
+
})
|
|
26
41
|
})
|
|
27
42
|
});
|
|
28
43
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Ordinal = number;
|
|
2
|
+
export interface ColumnMetadata {
|
|
3
|
+
ordinal: Ordinal;
|
|
4
|
+
actionColumn?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type ColumnMetadataSet = Array<ColumnMetadata>;
|
|
7
|
+
export type OnColumnVisibilityChange = (columnVisibility: {
|
|
8
|
+
visibleColumns: Ordinal[];
|
|
9
|
+
hiddenColumns: Ordinal[];
|
|
10
|
+
}) => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type MutableRefObject, type ReactNode } from 'react';
|
|
2
|
+
import { type ColumnMetadataSet, type OnColumnVisibilityChange, type Ordinal } from './column-metadata';
|
|
3
|
+
interface ColumnVisibilityContextValue {
|
|
4
|
+
isColumnHidden: (ordinal: Ordinal) => boolean;
|
|
5
|
+
setColumnsMetadata: (columnsMetadata: ColumnMetadataSet) => void;
|
|
6
|
+
isColumnResizable: (ordinal: Ordinal) => boolean;
|
|
7
|
+
columnsMetadata: ColumnMetadataSet;
|
|
8
|
+
isColumnDroppingEnabled: boolean;
|
|
9
|
+
isColumnResizingEnabled: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface ColumnVisibilityProviderProps {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
containerRef: MutableRefObject<HTMLDivElement | null>;
|
|
14
|
+
isColumnDroppingEnabled: boolean;
|
|
15
|
+
isColumnResizingEnabled: boolean;
|
|
16
|
+
onVisibleColumnsChange?: OnColumnVisibilityChange;
|
|
17
|
+
}
|
|
18
|
+
export declare const ColumnVisibilityProvider: ({ children, containerRef, onVisibleColumnsChange, isColumnDroppingEnabled, isColumnResizingEnabled, }: ColumnVisibilityProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare const useColumnVisibilityContext: () => ColumnVisibilityContextValue;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useContext, createContext } from 'react';
|
|
3
|
+
import { useColumnVisibilityManager } from './useColumnVisibilityManager.js';
|
|
4
|
+
|
|
5
|
+
const ColumnVisibilityContext = /*#__PURE__*/createContext(null);
|
|
6
|
+
const ColumnVisibilityProvider = ({
|
|
7
|
+
children,
|
|
8
|
+
containerRef,
|
|
9
|
+
onVisibleColumnsChange,
|
|
10
|
+
isColumnDroppingEnabled,
|
|
11
|
+
isColumnResizingEnabled
|
|
12
|
+
}) => {
|
|
13
|
+
const {
|
|
14
|
+
isColumnHidden,
|
|
15
|
+
setColumnsMetadata,
|
|
16
|
+
isColumnResizable,
|
|
17
|
+
columnsMetadata
|
|
18
|
+
} = useColumnVisibilityManager(containerRef, isColumnDroppingEnabled, isColumnResizingEnabled, onVisibleColumnsChange);
|
|
19
|
+
const value = {
|
|
20
|
+
isColumnHidden,
|
|
21
|
+
setColumnsMetadata,
|
|
22
|
+
isColumnResizable,
|
|
23
|
+
columnsMetadata,
|
|
24
|
+
isColumnDroppingEnabled,
|
|
25
|
+
isColumnResizingEnabled
|
|
26
|
+
};
|
|
27
|
+
return jsx(ColumnVisibilityContext.Provider, {
|
|
28
|
+
value: value,
|
|
29
|
+
children: children
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
const useColumnVisibilityContext = () => {
|
|
33
|
+
const context = useContext(ColumnVisibilityContext);
|
|
34
|
+
if (context === null) {
|
|
35
|
+
throw new Error('useColumnVisibilityContext must be used within a ColumnVisibilityProvider');
|
|
36
|
+
}
|
|
37
|
+
return context;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { ColumnVisibilityProvider, useColumnVisibilityContext };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ColumnMetadataSet, type OnColumnVisibilityChange, type Ordinal } from './column-metadata';
|
|
2
|
+
export declare const useColumnVisibilityManager: (containerRef: React.MutableRefObject<HTMLDivElement | null>, isColumnDroppingEnabled: boolean, isColumnResizingEnabled: boolean, onVisibleColumnsChange?: OnColumnVisibilityChange) => {
|
|
3
|
+
isColumnHidden: (ordinal: Ordinal) => boolean;
|
|
4
|
+
setColumnsMetadata: import("react").Dispatch<import("react").SetStateAction<ColumnMetadataSet>>;
|
|
5
|
+
isColumnResizable: (ordinal: Ordinal) => boolean;
|
|
6
|
+
columnsMetadata: ColumnMetadataSet;
|
|
7
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { useState, useMemo, useCallback, useEffect } from 'react';
|
|
2
|
+
import { useBreakpoint, Breakpoint } from '../../utils/useBreakpoint.js';
|
|
3
|
+
import { useThrottledContainerResize } from './useThrottledContainerResize.js';
|
|
4
|
+
|
|
5
|
+
const useColumnVisibilityManager = (containerRef, isColumnDroppingEnabled, isColumnResizingEnabled, onVisibleColumnsChange) => {
|
|
6
|
+
const containerWidth = useThrottledContainerResize(containerRef, isColumnDroppingEnabled);
|
|
7
|
+
const [columnsMetadata, setColumnsMetadata] = useState([]);
|
|
8
|
+
const minColumnWidth = 160;
|
|
9
|
+
const breakpoint = useBreakpoint();
|
|
10
|
+
const isMobile = breakpoint <= Breakpoint.Medium;
|
|
11
|
+
const maxVisibleColumns = useMemo(() => Math.floor(containerWidth / minColumnWidth - 1), [containerWidth]);
|
|
12
|
+
// Check whether the column and all its corresponding cells should be hidden based on the current container size
|
|
13
|
+
const isColumnHidden = useCallback(ordinal => {
|
|
14
|
+
// Do not hide any columns when dropping is disabled
|
|
15
|
+
if (!isColumnDroppingEnabled) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const column = columnsMetadata[ordinal];
|
|
19
|
+
if (ordinal === 0 || column?.actionColumn === true) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (isMobile) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
// For remaining columns, hide those beyond maxVisibleColumns
|
|
26
|
+
return ordinal > maxVisibleColumns;
|
|
27
|
+
}, [columnsMetadata, isColumnDroppingEnabled, isMobile, maxVisibleColumns]);
|
|
28
|
+
const {
|
|
29
|
+
visibleColumns,
|
|
30
|
+
hiddenColumns
|
|
31
|
+
} = useMemo(() => {
|
|
32
|
+
const visible = [];
|
|
33
|
+
const hidden = [];
|
|
34
|
+
columnsMetadata.forEach(({
|
|
35
|
+
ordinal
|
|
36
|
+
}) => {
|
|
37
|
+
if (isColumnHidden(ordinal)) {
|
|
38
|
+
hidden.push(ordinal);
|
|
39
|
+
} else {
|
|
40
|
+
visible.push(ordinal);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
visibleColumns: visible,
|
|
45
|
+
hiddenColumns: hidden
|
|
46
|
+
};
|
|
47
|
+
}, [columnsMetadata, isColumnHidden]);
|
|
48
|
+
const isColumnResizable = useCallback(ordinal => {
|
|
49
|
+
const column = columnsMetadata[ordinal];
|
|
50
|
+
// Columns are not resizable when resizing is disabled
|
|
51
|
+
if (!isColumnResizingEnabled) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
// Columns are not resizable in mobile view
|
|
55
|
+
if (isColumnDroppingEnabled) {
|
|
56
|
+
if (isMobile) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (column?.actionColumn) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
// Check if it's the second-last visible column and the last visible column is an action column
|
|
64
|
+
const lastIndex = visibleColumns.length - 1;
|
|
65
|
+
const isSecondLastWithActionLast = visibleColumns[lastIndex - 1] === ordinal && columnsMetadata[visibleColumns[lastIndex]]?.actionColumn;
|
|
66
|
+
return !(visibleColumns[lastIndex] === ordinal || isSecondLastWithActionLast);
|
|
67
|
+
}, [columnsMetadata, isColumnDroppingEnabled, isColumnResizingEnabled, isMobile, visibleColumns]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (onVisibleColumnsChange) {
|
|
70
|
+
onVisibleColumnsChange({
|
|
71
|
+
visibleColumns,
|
|
72
|
+
hiddenColumns
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}, [visibleColumns, hiddenColumns, onVisibleColumnsChange]);
|
|
76
|
+
return {
|
|
77
|
+
isColumnHidden,
|
|
78
|
+
setColumnsMetadata,
|
|
79
|
+
isColumnResizable,
|
|
80
|
+
columnsMetadata
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export { useColumnVisibilityManager };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useThrottledContainerResize: (containerRef: React.MutableRefObject<HTMLDivElement | null>, isColumnDroppingEnabled: boolean) => number;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import noop from 'lodash/noop';
|
|
2
|
+
import { useState, useRef, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
const useThrottledContainerResize = (containerRef, isColumnDroppingEnabled) => {
|
|
5
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
6
|
+
const animationFrameId = useRef(null);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!containerRef.current || !isColumnDroppingEnabled) {
|
|
9
|
+
return noop;
|
|
10
|
+
}
|
|
11
|
+
const handleResize = () => {
|
|
12
|
+
if (animationFrameId.current !== null) {
|
|
13
|
+
cancelAnimationFrame(animationFrameId.current);
|
|
14
|
+
}
|
|
15
|
+
animationFrameId.current = requestAnimationFrame(() => {
|
|
16
|
+
if (containerRef.current) {
|
|
17
|
+
setContainerWidth(containerRef.current.getBoundingClientRect().width);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const observer = new ResizeObserver(entries => {
|
|
22
|
+
const entry = entries[0];
|
|
23
|
+
if (entry?.contentRect) {
|
|
24
|
+
handleResize();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
observer.observe(containerRef.current);
|
|
28
|
+
return () => {
|
|
29
|
+
observer.disconnect();
|
|
30
|
+
if (animationFrameId.current !== null) {
|
|
31
|
+
cancelAnimationFrame(animationFrameId.current);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}, [containerRef, isColumnDroppingEnabled]);
|
|
35
|
+
return containerWidth;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { useThrottledContainerResize };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.18.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"publishConfig": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"react-stately": "^3.31.1",
|
|
63
63
|
"tsx": "^4.16.5"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "a2056d2f579edc055a85156efe0e93414840445e",
|
|
66
66
|
"module": "lib-esm/index.js",
|
|
67
67
|
"main": "lib-esm/index.js",
|
|
68
68
|
"types": "lib-esm/index.d.ts",
|