react-resizable-panels 4.13.2 → 4.14.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/README.md
CHANGED
|
@@ -71,7 +71,7 @@ None
|
|
|
71
71
|
<td>id</td>
|
|
72
72
|
<td><p>Uniquely identifies this group within an application.
|
|
73
73
|
Falls back to <code>useId</code> when not provided.</p>
|
|
74
|
-
<p>ℹ️ This value will also be assigned to the <code>data-
|
|
74
|
+
<p>ℹ️ This value will also be assigned to the <code>id</code> and <code>data-testid</code> attributes.</p>
|
|
75
75
|
</td>
|
|
76
76
|
</tr>
|
|
77
77
|
<tr>
|
|
@@ -225,7 +225,7 @@ None
|
|
|
225
225
|
<td><p>Uniquely identifies this panel within the parent group.
|
|
226
226
|
Falls back to <code>useId</code> when not provided.</p>
|
|
227
227
|
<p>ℹ️ This prop is used to associate persisted group layouts with the original panel.</p>
|
|
228
|
-
<p>ℹ️ This value will also be assigned to the <code>data-
|
|
228
|
+
<p>ℹ️ This value will also be assigned to the <code>id</code> and <code>data-testid</code> attributes.</p>
|
|
229
229
|
</td>
|
|
230
230
|
</tr>
|
|
231
231
|
<tr>
|
|
@@ -390,7 +390,7 @@ None
|
|
|
390
390
|
<td>id</td>
|
|
391
391
|
<td><p>Uniquely identifies the separator within the parent group.
|
|
392
392
|
Falls back to <code>useId</code> when not provided.</p>
|
|
393
|
-
<p>ℹ️ This value will also be assigned to the <code>data-
|
|
393
|
+
<p>ℹ️ This value will also be assigned to the <code>id</code> and <code>data-testid</code> attributes.</p>
|
|
394
394
|
</td>
|
|
395
395
|
</tr>
|
|
396
396
|
<tr>
|
|
@@ -426,3 +426,392 @@ To prevent a panel from being resized at all, it needs to also be disabled.</p>
|
|
|
426
426
|
</table>
|
|
427
427
|
|
|
428
428
|
<!-- Separator:optional-props:end -->
|
|
429
|
+
|
|
430
|
+
### Grid
|
|
431
|
+
|
|
432
|
+
<!-- Grid:description:begin -->
|
|
433
|
+
A Grid arranges resizable Cells in two dimensions.
|
|
434
|
+
Columns can be resized horizontally and rows can be resized vertically;
|
|
435
|
+
dragging the point where a column boundary and a row boundary intersect resizes both.
|
|
436
|
+
|
|
437
|
+
Size constraints (e.g. min/max size, collapsible) are specified per track (column or row),
|
|
438
|
+
using the same format as Panel props.
|
|
439
|
+
|
|
440
|
+
Cells can span multiple columns and/or rows.
|
|
441
|
+
Track boundaries cannot be resized alongside of a cell that spans across them.
|
|
442
|
+
|
|
443
|
+
Grid elements always include the following attributes:
|
|
444
|
+
|
|
445
|
+
```html
|
|
446
|
+
<div data-grid data-testid="grid-id-prop" id="grid-id-prop">
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
ℹ️ [Test id](https://testing-library.com/docs/queries/bytestid/) can be used to narrow selection when unit testing.
|
|
450
|
+
<!-- Grid:description:end -->
|
|
451
|
+
|
|
452
|
+
#### Required props
|
|
453
|
+
|
|
454
|
+
<!-- Grid:required-props:begin -->
|
|
455
|
+
|
|
456
|
+
<table>
|
|
457
|
+
<thead>
|
|
458
|
+
<tr>
|
|
459
|
+
<th>Name</th>
|
|
460
|
+
<th>Description</th>
|
|
461
|
+
</tr>
|
|
462
|
+
</thead>
|
|
463
|
+
<tbody>
|
|
464
|
+
<tr>
|
|
465
|
+
<td>columns</td>
|
|
466
|
+
<td><p>Grid columns; either the number of columns or an array of size constraints (one per column).</p>
|
|
467
|
+
</td>
|
|
468
|
+
</tr>
|
|
469
|
+
<tr>
|
|
470
|
+
<td>rows</td>
|
|
471
|
+
<td><p>Grid rows; either the number of rows or an array of size constraints (one per row).</p>
|
|
472
|
+
</td>
|
|
473
|
+
</tr>
|
|
474
|
+
</tbody>
|
|
475
|
+
</table>
|
|
476
|
+
|
|
477
|
+
<!-- Grid:required-props:end -->
|
|
478
|
+
|
|
479
|
+
#### Optional props
|
|
480
|
+
|
|
481
|
+
<!-- Grid:optional-props:begin -->
|
|
482
|
+
|
|
483
|
+
<table>
|
|
484
|
+
<thead>
|
|
485
|
+
<tr>
|
|
486
|
+
<th>Name</th>
|
|
487
|
+
<th>Description</th>
|
|
488
|
+
</tr>
|
|
489
|
+
</thead>
|
|
490
|
+
<tbody>
|
|
491
|
+
<tr>
|
|
492
|
+
<td>className</td>
|
|
493
|
+
<td><p>CSS class name.</p>
|
|
494
|
+
</td>
|
|
495
|
+
</tr>
|
|
496
|
+
<tr>
|
|
497
|
+
<td>id</td>
|
|
498
|
+
<td><p>Uniquely identifies this grid within an application.
|
|
499
|
+
Falls back to <code>useId</code> when not provided.</p>
|
|
500
|
+
<p>ℹ️ This value will also be assigned to the <code>id</code> and <code>data-testid</code> attributes.</p>
|
|
501
|
+
</td>
|
|
502
|
+
</tr>
|
|
503
|
+
<tr>
|
|
504
|
+
<td>style</td>
|
|
505
|
+
<td><p>CSS properties.</p>
|
|
506
|
+
<p>⚠️ Grid template and display properties are managed by the Grid and cannot be overridden.</p>
|
|
507
|
+
</td>
|
|
508
|
+
</tr>
|
|
509
|
+
<tr>
|
|
510
|
+
<td>children</td>
|
|
511
|
+
<td><p>Cell and Gridline components that comprise this grid.</p>
|
|
512
|
+
<p>⚠️ Cell and Gridline elements must be direct DOM children of their parent Grid element.</p>
|
|
513
|
+
</td>
|
|
514
|
+
</tr>
|
|
515
|
+
<tr>
|
|
516
|
+
<td>defaultLayout</td>
|
|
517
|
+
<td><p>Default layout for either or both of the Grid's axes.</p>
|
|
518
|
+
<p>ℹ️ This value allows layouts to be remembered between page reloads.</p>
|
|
519
|
+
</td>
|
|
520
|
+
</tr>
|
|
521
|
+
<tr>
|
|
522
|
+
<td>disableCursor</td>
|
|
523
|
+
<td><p>This library sets custom mouse cursor styles to indicate drag state.
|
|
524
|
+
Use this prop to disable that behavior for this grid.</p>
|
|
525
|
+
</td>
|
|
526
|
+
</tr>
|
|
527
|
+
<tr>
|
|
528
|
+
<td>disabled</td>
|
|
529
|
+
<td><p>Disable resize functionality.</p>
|
|
530
|
+
</td>
|
|
531
|
+
</tr>
|
|
532
|
+
<tr>
|
|
533
|
+
<td>elementRef</td>
|
|
534
|
+
<td><p>Ref attached to the root <code>HTMLDivElement</code>.</p>
|
|
535
|
+
</td>
|
|
536
|
+
</tr>
|
|
537
|
+
<tr>
|
|
538
|
+
<td>gridRef</td>
|
|
539
|
+
<td><p>Exposes the following imperative API:</p>
|
|
540
|
+
<ul>
|
|
541
|
+
<li><code>getLayout(): GridLayout</code></li>
|
|
542
|
+
<li><code>getTrackById(axis: "column" | "row", id: string | number): GridTrackImperativeHandle</code></li>
|
|
543
|
+
<li><code>getTrackByIndex(axis: "column" | "row", index: number): GridTrackImperativeHandle</code></li>
|
|
544
|
+
<li><code>setLayout(layout: Partial<GridLayout>): GridLayout</code></li>
|
|
545
|
+
</ul>
|
|
546
|
+
<p>ℹ️ The <code>useGridRef</code> and <code>useGridCallbackRef</code> hooks are exported for convenience use in TypeScript projects.</p>
|
|
547
|
+
</td>
|
|
548
|
+
</tr>
|
|
549
|
+
<tr>
|
|
550
|
+
<td>onLayoutChange</td>
|
|
551
|
+
<td><p>Called when the Grid's layout is changing.</p>
|
|
552
|
+
<p>⚠️ For layout changes caused by pointer events, this method is called each time the pointer is moved.
|
|
553
|
+
For most cases, it is recommended to use the <code>onLayoutChanged</code> callback instead.</p>
|
|
554
|
+
</td>
|
|
555
|
+
</tr>
|
|
556
|
+
<tr>
|
|
557
|
+
<td>onLayoutChanged</td>
|
|
558
|
+
<td><p>Called after the Grid's layout has been changed.</p>
|
|
559
|
+
<p>ℹ️ For layout changes caused by pointer events, this method is not called until the pointer has been released.
|
|
560
|
+
This method is recommended when saving layouts to some storage api.</p>
|
|
561
|
+
</td>
|
|
562
|
+
</tr>
|
|
563
|
+
<tr>
|
|
564
|
+
<td>resizeTargetMinimumSize</td>
|
|
565
|
+
<td><p>Minimum size of the resizable hit target area (either a <code>Gridline</code> or a <code>Cell</code> edge)
|
|
566
|
+
This threshold ensures targets are large enough to avoid mis-clicks.</p>
|
|
567
|
+
<p>ℹ️ Refer to the <code>Group</code> prop of the same name for more information.</p>
|
|
568
|
+
</td>
|
|
569
|
+
</tr>
|
|
570
|
+
</tbody>
|
|
571
|
+
</table>
|
|
572
|
+
|
|
573
|
+
<!-- Grid:optional-props:end -->
|
|
574
|
+
|
|
575
|
+
### Cell
|
|
576
|
+
|
|
577
|
+
<!-- Cell:description:begin -->
|
|
578
|
+
A Cell occupies one or more tracks (columns and rows) within a Grid.
|
|
579
|
+
Cells are resized along with the tracks they occupy.
|
|
580
|
+
|
|
581
|
+
Cell elements always include the following attributes:
|
|
582
|
+
|
|
583
|
+
```html
|
|
584
|
+
<div data-cell data-testid="cell-id-prop" id="cell-id-prop">
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
ℹ️ [Test id](https://testing-library.com/docs/queries/bytestid/) can be used to narrow selection when unit testing.
|
|
588
|
+
|
|
589
|
+
⚠️ Cell elements must be direct DOM children of their parent Grid elements.
|
|
590
|
+
<!-- Cell:description:end -->
|
|
591
|
+
|
|
592
|
+
#### Required props
|
|
593
|
+
|
|
594
|
+
<!-- Cell:required-props:begin -->
|
|
595
|
+
|
|
596
|
+
<table>
|
|
597
|
+
<thead>
|
|
598
|
+
<tr>
|
|
599
|
+
<th>Name</th>
|
|
600
|
+
<th>Description</th>
|
|
601
|
+
</tr>
|
|
602
|
+
</thead>
|
|
603
|
+
<tbody>
|
|
604
|
+
<tr>
|
|
605
|
+
<td>column</td>
|
|
606
|
+
<td><p>Index of the (first) column this cell occupies.</p>
|
|
607
|
+
</td>
|
|
608
|
+
</tr>
|
|
609
|
+
<tr>
|
|
610
|
+
<td>row</td>
|
|
611
|
+
<td><p>Index of the (first) row this cell occupies.</p>
|
|
612
|
+
</td>
|
|
613
|
+
</tr>
|
|
614
|
+
</tbody>
|
|
615
|
+
</table>
|
|
616
|
+
|
|
617
|
+
<!-- Cell:required-props:end -->
|
|
618
|
+
|
|
619
|
+
#### Optional props
|
|
620
|
+
|
|
621
|
+
<!-- Cell:optional-props:begin -->
|
|
622
|
+
|
|
623
|
+
<table>
|
|
624
|
+
<thead>
|
|
625
|
+
<tr>
|
|
626
|
+
<th>Name</th>
|
|
627
|
+
<th>Description</th>
|
|
628
|
+
</tr>
|
|
629
|
+
</thead>
|
|
630
|
+
<tbody>
|
|
631
|
+
<tr>
|
|
632
|
+
<td>className</td>
|
|
633
|
+
<td><p>CSS class name.</p>
|
|
634
|
+
</td>
|
|
635
|
+
</tr>
|
|
636
|
+
<tr>
|
|
637
|
+
<td>id</td>
|
|
638
|
+
<td><p>Uniquely identifies this cell within the parent grid.
|
|
639
|
+
Falls back to <code>useId</code> when not provided.</p>
|
|
640
|
+
<p>ℹ️ This value will also be assigned to the <code>id</code> and <code>data-testid</code> attributes.</p>
|
|
641
|
+
</td>
|
|
642
|
+
</tr>
|
|
643
|
+
<tr>
|
|
644
|
+
<td>style</td>
|
|
645
|
+
<td><p>CSS properties.</p>
|
|
646
|
+
<p>⚠️ Grid placement properties are managed by the Cell and cannot be overridden.</p>
|
|
647
|
+
</td>
|
|
648
|
+
</tr>
|
|
649
|
+
<tr>
|
|
650
|
+
<td>children</td>
|
|
651
|
+
<td><p>Cell contents.</p>
|
|
652
|
+
</td>
|
|
653
|
+
</tr>
|
|
654
|
+
<tr>
|
|
655
|
+
<td>columnSpan</td>
|
|
656
|
+
<td><p>Number of columns this cell spans; defaults to 1.</p>
|
|
657
|
+
</td>
|
|
658
|
+
</tr>
|
|
659
|
+
<tr>
|
|
660
|
+
<td>elementRef</td>
|
|
661
|
+
<td><p>Ref attached to the root <code>HTMLDivElement</code>.</p>
|
|
662
|
+
</td>
|
|
663
|
+
</tr>
|
|
664
|
+
<tr>
|
|
665
|
+
<td>rowSpan</td>
|
|
666
|
+
<td><p>Number of rows this cell spans; defaults to 1.</p>
|
|
667
|
+
</td>
|
|
668
|
+
</tr>
|
|
669
|
+
</tbody>
|
|
670
|
+
</table>
|
|
671
|
+
|
|
672
|
+
<!-- Cell:optional-props:end -->
|
|
673
|
+
|
|
674
|
+
### Gridline
|
|
675
|
+
|
|
676
|
+
<!-- Gridline:description:begin -->
|
|
677
|
+
Resizes the columns (or rows) of a Grid.
|
|
678
|
+
|
|
679
|
+
For example:
|
|
680
|
+
|
|
681
|
+
```tsx
|
|
682
|
+
// Rendered between columns 0 and 1 and spans all rows
|
|
683
|
+
<Gridline type="column" column={1} />
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
```tsx
|
|
687
|
+
// Rendered between rows 0 and 1 and spans all columns
|
|
688
|
+
<Gridline type="row" row={1} />
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
```tsx
|
|
692
|
+
// Rendered between columns 0 and 1 alongside of row 2 only
|
|
693
|
+
<Gridline type="column" column={1} row={2} rowSpan={1} />
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
A gridline should not be rendered alongside of a Cell that spans across its boundary
|
|
697
|
+
(this includes disabled gridlines; an error will be logged to the console);
|
|
698
|
+
render multiple gridlines along the same boundary instead (e.g. before and after the spanning Cell).
|
|
699
|
+
|
|
700
|
+
ℹ️ Once a boundary contains a gridline, it can only be resized using gridlines;
|
|
701
|
+
the parts of the boundary that aren't alongside of a gridline can't be dragged.
|
|
702
|
+
|
|
703
|
+
Where column and row gridlines intersect, dragging resizes both axes.
|
|
704
|
+
|
|
705
|
+
Gridlines are not _required_ but they are _recommended_ as they improve keyboard accessibility.
|
|
706
|
+
|
|
707
|
+
Gridline elements always include the following attributes:
|
|
708
|
+
|
|
709
|
+
```html
|
|
710
|
+
<div aria-orientation="vertical" data-separator role="separator">
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
ℹ️ Column gridlines are vertical (`aria-orientation="vertical"`) and row gridlines are horizontal (`aria-orientation="horizontal"`).
|
|
714
|
+
|
|
715
|
+
ℹ️ In addition to the attributes shown above, gridlines also render all required [WAI-ARIA properties](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/separator_role#associated_wai-aria_roles_states_and_properties).
|
|
716
|
+
|
|
717
|
+
⚠️ Gridline elements must be direct DOM children of their parent Grid elements.
|
|
718
|
+
|
|
719
|
+
ℹ️ Gridlines rendered by another component (rather than directly within the Grid) aren't detected until they mount, so server-rendered layouts may shift slightly during hydration.
|
|
720
|
+
<!-- Gridline:description:end -->
|
|
721
|
+
|
|
722
|
+
#### Required props
|
|
723
|
+
|
|
724
|
+
<!-- Gridline:required-props:begin -->
|
|
725
|
+
|
|
726
|
+
<table>
|
|
727
|
+
<thead>
|
|
728
|
+
<tr>
|
|
729
|
+
<th>Name</th>
|
|
730
|
+
<th>Description</th>
|
|
731
|
+
</tr>
|
|
732
|
+
</thead>
|
|
733
|
+
<tbody>
|
|
734
|
+
<tr>
|
|
735
|
+
<td>type</td>
|
|
736
|
+
<td><p>Column gridlines are vertical; they resize the columns on either side of them.
|
|
737
|
+
Row gridlines are horizontal; they resize the rows on either side of them.</p>
|
|
738
|
+
</td>
|
|
739
|
+
</tr>
|
|
740
|
+
</tbody>
|
|
741
|
+
</table>
|
|
742
|
+
|
|
743
|
+
<!-- Gridline:required-props:end -->
|
|
744
|
+
|
|
745
|
+
#### Optional props
|
|
746
|
+
|
|
747
|
+
<!-- Gridline:optional-props:begin -->
|
|
748
|
+
|
|
749
|
+
<table>
|
|
750
|
+
<thead>
|
|
751
|
+
<tr>
|
|
752
|
+
<th>Name</th>
|
|
753
|
+
<th>Description</th>
|
|
754
|
+
</tr>
|
|
755
|
+
</thead>
|
|
756
|
+
<tbody>
|
|
757
|
+
<tr>
|
|
758
|
+
<td>children</td>
|
|
759
|
+
<td><p>Gridline contents (e.g. a drag handle icon).</p>
|
|
760
|
+
</td>
|
|
761
|
+
</tr>
|
|
762
|
+
<tr>
|
|
763
|
+
<td>className</td>
|
|
764
|
+
<td><p>CSS class name.</p>
|
|
765
|
+
<p>ℹ️ Use the <code>data-separator</code> attribute for custom <em>hover</em> and <em>active</em> styles</p>
|
|
766
|
+
</td>
|
|
767
|
+
</tr>
|
|
768
|
+
<tr>
|
|
769
|
+
<td>disabled</td>
|
|
770
|
+
<td><p>When disabled, the gridline cannot be used to resize its neighboring tracks.</p>
|
|
771
|
+
<p>ℹ️ The tracks may still be resized indirectly (e.g. by an intersecting gridline or another boundary).
|
|
772
|
+
To prevent a track from being resized at all, it needs to also be disabled.</p>
|
|
773
|
+
</td>
|
|
774
|
+
</tr>
|
|
775
|
+
<tr>
|
|
776
|
+
<td>elementRef</td>
|
|
777
|
+
<td><p>Ref attached to the root <code>HTMLDivElement</code>.</p>
|
|
778
|
+
</td>
|
|
779
|
+
</tr>
|
|
780
|
+
<tr>
|
|
781
|
+
<td>style</td>
|
|
782
|
+
<td><p>CSS properties.</p>
|
|
783
|
+
<p>⚠️ Grid placement properties are managed by the gridline and cannot be overridden.</p>
|
|
784
|
+
</td>
|
|
785
|
+
</tr>
|
|
786
|
+
<tr>
|
|
787
|
+
<td>column</td>
|
|
788
|
+
<td><p>When <code>type</code> is "column", the gridline is rendered along the leading (left) edge of this column
|
|
789
|
+
(between it and the previous column); must be greater than 0 and less than the number of columns.
|
|
790
|
+
When <code>type</code> is "row", index of the first column the gridline is rendered alongside of; defaults to 0.</p>
|
|
791
|
+
</td>
|
|
792
|
+
</tr>
|
|
793
|
+
<tr>
|
|
794
|
+
<td>row</td>
|
|
795
|
+
<td><p>When <code>type</code> is "column", index of the first row the gridline is rendered alongside of; defaults to 0.
|
|
796
|
+
When <code>type</code> is "row", the gridline is rendered along the leading (top) edge of this row
|
|
797
|
+
(between it and the previous row); must be greater than 0 and less than the number of rows.</p>
|
|
798
|
+
</td>
|
|
799
|
+
</tr>
|
|
800
|
+
<tr>
|
|
801
|
+
<td>rowSpan</td>
|
|
802
|
+
<td><p>Number of rows a column gridline spans; defaults to all rows (starting from <code>row</code>).</p>
|
|
803
|
+
<p>ℹ️ Gridlines can span a subset of rows in order to avoid cells that span across the boundary they sit on;
|
|
804
|
+
multiple gridlines can be rendered along the same boundary (e.g. above and below a spanning cell).</p>
|
|
805
|
+
</td>
|
|
806
|
+
</tr>
|
|
807
|
+
<tr>
|
|
808
|
+
<td>columnSpan</td>
|
|
809
|
+
<td><p>Number of columns a row gridline spans; defaults to all columns (starting from <code>column</code>).</p>
|
|
810
|
+
<p>ℹ️ Gridlines can span a subset of columns in order to avoid cells that span across the boundary they sit on;
|
|
811
|
+
multiple gridlines can be rendered along the same boundary (e.g. before and after a spanning cell).</p>
|
|
812
|
+
</td>
|
|
813
|
+
</tr>
|
|
814
|
+
</tbody>
|
|
815
|
+
</table>
|
|
816
|
+
|
|
817
|
+
<!-- Gridline:optional-props:end -->
|