playbook_ui 18.3.0 → 18.4.0.pre.rc.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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/CollapsibleTrail.tsx +8 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +39 -8
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +24 -4
  5. data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +29 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +72 -5
  7. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +3 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +1 -1
  9. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +8 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +467 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_group_separators.jsx +67 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_group_separators.md +7 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_group_separators_rails.html.erb +78 -0
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_group_separators_rails.md +3 -0
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_playground.json +10 -1
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_playground.overrides.json +8 -1
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_group_separators.json +328 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -0
  20. data/app/pb_kits/playbook/pb_advanced_table/index.js +39 -2
  21. data/app/pb_kits/playbook/pb_advanced_table/kit.schema.json +8 -0
  22. data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +2 -2
  23. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +53 -23
  24. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +1 -1
  25. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +2 -0
  26. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +4 -4
  27. data/app/pb_kits/playbook/pb_collapsible/collapsible.test.js +81 -2
  28. data/app/pb_kits/playbook/pb_date/date.test.js +1 -1
  29. data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +4 -0
  30. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.test.js +1 -0
  31. data/app/pb_kits/playbook/pb_date_time/dateTime.test.js +1 -0
  32. data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.test.js +1 -0
  33. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +2 -1
  34. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.test.js +1 -2
  35. data/app/pb_kits/playbook/pb_icon/_icon.tsx +6 -1
  36. data/app/pb_kits/playbook/pb_icon/kit.schema.json +1 -0
  37. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.tsx +3 -1
  38. data/app/pb_kits/playbook/pb_icon_circle/kit.schema.json +1 -0
  39. data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +17 -0
  40. data/app/pb_kits/playbook/pb_pb_bar_graph/pbbargraph.test.jsx +1 -2
  41. data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.test.jsx +1 -2
  42. data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.test.jsx +1 -2
  43. data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.test.jsx +1 -2
  44. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +3 -7
  45. data/app/pb_kits/playbook/pb_phone_number_input/img/flags.webp +0 -0
  46. data/app/pb_kits/playbook/pb_phone_number_input/img/flags@2x.webp +0 -0
  47. data/app/pb_kits/playbook/pb_phone_number_input/img/globe.webp +0 -0
  48. data/app/pb_kits/playbook/pb_phone_number_input/img/globe@2x.webp +0 -0
  49. data/app/pb_kits/playbook/pb_phone_number_input/intlTelInput.scss +13 -6
  50. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input_assets.test.js +61 -0
  51. data/app/pb_kits/playbook/pb_popover/index.ts +47 -8
  52. data/app/pb_kits/playbook/pb_popover/popover_index.test.js +456 -0
  53. data/app/pb_kits/playbook/pb_timestamp/timestamp.test.js +1 -0
  54. data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.test.jsx +1 -0
  55. data/app/pb_kits/playbook/utilities/test/globalProps/onClick.test.js +169 -0
  56. data/app/pb_kits/playbook/utilities/test-utils.js +0 -1
  57. data/dist/ai/all-schemas.json +10 -0
  58. data/dist/ai/forms.json +1 -1
  59. data/dist/ai/index.json +2 -2
  60. data/dist/ai/kits/advanced_table.schema.json +8 -0
  61. data/dist/ai/kits/icon.schema.json +1 -0
  62. data/dist/ai/kits/icon_circle.schema.json +1 -0
  63. data/dist/ai/playgrounds/advanced_table.json +1 -1
  64. data/dist/ai/playgrounds/index.json +1 -1
  65. data/dist/chunks/_pagination-DZ0eQuH2.js +1 -0
  66. data/dist/chunks/{_pb_line_graph-BKwbOeqo.js → _pb_line_graph-DyvH5Zj1.js} +1 -1
  67. data/dist/chunks/{_tooltip-UkcgcThO.js → _tooltip-CFbtqu-E.js} +1 -1
  68. data/dist/chunks/{_typeahead-NYVJDWmJ.js → _typeahead-C3MN3apM.js} +1 -1
  69. data/dist/chunks/{globalProps-BivjwRew.js → globalProps-xfGTpdLP.js} +1 -1
  70. data/dist/chunks/{lib-C50eCpoN.js → lib-Cu_i0y0k.js} +1 -1
  71. data/dist/chunks/{time_picker_helper-DfKvHCJu.js → time_picker_helper-B82MORju.js} +1 -1
  72. data/dist/chunks/vendor.js +1 -1
  73. data/dist/menu.yml +1 -1
  74. data/dist/playbook-rails-react-bindings.js +1 -1
  75. data/dist/playbook-rails.js +1 -1
  76. data/dist/playbook.css +1 -1
  77. data/lib/playbook/version.rb +2 -2
  78. metadata +19 -8
  79. data/dist/chunks/_pagination-CARbC_IN.js +0 -1
@@ -3,6 +3,7 @@ import { render, screen, waitFor } from "../utilities/test-utils"
3
3
 
4
4
  import { AdvancedTable } from "playbook-ui/advanced-table"
5
5
  import { Pill, colors } from "playbook-ui"
6
+ import { buildGroupSeparatorInsets } from "./Utilities/RowUtils"
6
7
 
7
8
  global.ResizeObserver = class {
8
9
  observe() {}
@@ -1520,3 +1521,469 @@ test("single header row does not mark every column as last-header-cell", () => {
1520
1521
  expect(kit.querySelector("tbody td.last-cell")).not.toBeInTheDocument()
1521
1522
  })
1522
1523
 
1524
+ const MOCK_DATA_GROUP_SEPARATORS = [
1525
+ {
1526
+ year: "2021",
1527
+ newEnrollments: "20",
1528
+ scheduledMeetings: "10",
1529
+ children: [
1530
+ {
1531
+ year: "2021",
1532
+ quarter: "Q1",
1533
+ newEnrollments: "5",
1534
+ scheduledMeetings: "2",
1535
+ children: [
1536
+ {
1537
+ year: "2021",
1538
+ quarter: "Q1",
1539
+ month: "January",
1540
+ newEnrollments: "2",
1541
+ scheduledMeetings: "1",
1542
+ },
1543
+ {
1544
+ year: "2021",
1545
+ quarter: "Q1",
1546
+ month: "February",
1547
+ newEnrollments: "3",
1548
+ scheduledMeetings: "1",
1549
+ },
1550
+ ],
1551
+ },
1552
+ {
1553
+ year: "2021",
1554
+ quarter: "Q2",
1555
+ newEnrollments: "6",
1556
+ scheduledMeetings: "3",
1557
+ children: [
1558
+ {
1559
+ year: "2021",
1560
+ quarter: "Q2",
1561
+ month: "April",
1562
+ newEnrollments: "3",
1563
+ scheduledMeetings: "1",
1564
+ },
1565
+ {
1566
+ year: "2021",
1567
+ quarter: "Q2",
1568
+ month: "May",
1569
+ newEnrollments: "3",
1570
+ scheduledMeetings: "2",
1571
+ },
1572
+ ],
1573
+ },
1574
+ ],
1575
+ },
1576
+ ]
1577
+
1578
+ test("groupSeparators=false (default) does not add group-separator-row", () => {
1579
+ render(
1580
+ <AdvancedTable
1581
+ columnDefinitions={columnDefinitions}
1582
+ data={{ testid: testId }}
1583
+ expandedControl={{ value: { "0": true, "0.0": true }, onChange: () => {} }}
1584
+ tableData={MOCK_DATA_GROUP_SEPARATORS}
1585
+ />
1586
+ )
1587
+
1588
+ const kit = screen.getByTestId(testId)
1589
+ expect(kit.querySelector(".group-separator-row")).not.toBeInTheDocument()
1590
+ })
1591
+
1592
+ test("groupSeparators marks last visible child of each nested group", () => {
1593
+ render(
1594
+ <AdvancedTable
1595
+ columnDefinitions={columnDefinitions}
1596
+ data={{ testid: testId }}
1597
+ expandedControl={{ value: { "0": true, "0.0": true, "0.1": true }, onChange: () => {} }}
1598
+ groupSeparators
1599
+ tableData={MOCK_DATA_GROUP_SEPARATORS}
1600
+ />
1601
+ )
1602
+
1603
+ const kit = screen.getByTestId(testId)
1604
+ const separatorRows = kit.querySelectorAll("tbody tr.group-separator-row")
1605
+ const separatorMonths = [...separatorRows].map((row) => row.textContent)
1606
+
1607
+ expect(separatorRows.length).toBe(2)
1608
+ expect(separatorMonths.some((text) => text.includes("February"))).toBe(true)
1609
+ expect(separatorMonths.some((text) => text.includes("May"))).toBe(true)
1610
+ expect(kit.querySelector("tbody tr.group-separator-row")?.textContent).not.toContain("January")
1611
+ expect(
1612
+ [...kit.querySelectorAll("tbody tr")].find((row) => row.textContent.includes("2021") && !row.classList.contains("depth-sub-row-1") && !row.classList.contains("depth-sub-row-2"))
1613
+ ).not.toHaveClass("group-separator-row")
1614
+ })
1615
+
1616
+ test("groupSeparators defers separator to last descendant when last sibling is expanded", () => {
1617
+ render(
1618
+ <AdvancedTable
1619
+ columnDefinitions={columnDefinitions}
1620
+ data={{ testid: testId }}
1621
+ expandedControl={{ value: { "0": true, "0.0": true }, onChange: () => {} }}
1622
+ groupSeparators
1623
+ tableData={MOCK_DATA_GROUP_SEPARATORS}
1624
+ />
1625
+ )
1626
+
1627
+ const kit = screen.getByTestId(testId)
1628
+ const q1Row = [...kit.querySelectorAll("tbody tr")].find((row) =>
1629
+ row.classList.contains("depth-sub-row-1") && row.textContent.includes("Q1")
1630
+ )
1631
+ const februaryRow = [...kit.querySelectorAll("tbody tr")].find((row) =>
1632
+ row.textContent.includes("February")
1633
+ )
1634
+
1635
+ expect(q1Row).not.toHaveClass("group-separator-row")
1636
+ expect(februaryRow).toHaveClass("group-separator-row")
1637
+ })
1638
+
1639
+ test("groupSeparators insets each closer to the outermost group it closes", () => {
1640
+ const data = [
1641
+ {
1642
+ year: "2022",
1643
+ newEnrollments: "1",
1644
+ scheduledMeetings: "1",
1645
+ children: [
1646
+ {
1647
+ year: "2022",
1648
+ quarter: "Q1",
1649
+ newEnrollments: "1",
1650
+ scheduledMeetings: "1",
1651
+ children: [
1652
+ {
1653
+ year: "2022",
1654
+ quarter: "Q1",
1655
+ month: "January",
1656
+ newEnrollments: "1",
1657
+ scheduledMeetings: "1",
1658
+ children: [
1659
+ { year: "2022", quarter: "Q1", month: "January", day: "15", newEnrollments: "1", scheduledMeetings: "1" },
1660
+ { year: "2022", quarter: "Q1", month: "January", day: "25", newEnrollments: "1", scheduledMeetings: "1" },
1661
+ ],
1662
+ },
1663
+ {
1664
+ year: "2022",
1665
+ quarter: "Q1",
1666
+ month: "May",
1667
+ newEnrollments: "1",
1668
+ scheduledMeetings: "1",
1669
+ children: [
1670
+ { year: "2022", quarter: "Q1", month: "May", day: "2", newEnrollments: "1", scheduledMeetings: "1" },
1671
+ ],
1672
+ },
1673
+ ],
1674
+ },
1675
+ {
1676
+ year: "2022",
1677
+ quarter: "Q2",
1678
+ newEnrollments: "1",
1679
+ scheduledMeetings: "1",
1680
+ children: [
1681
+ {
1682
+ year: "2022",
1683
+ quarter: "Q2",
1684
+ month: "June",
1685
+ newEnrollments: "1",
1686
+ scheduledMeetings: "1",
1687
+ children: [
1688
+ { year: "2022", quarter: "Q2", month: "June", day: "5", newEnrollments: "1", scheduledMeetings: "1" },
1689
+ ],
1690
+ },
1691
+ ],
1692
+ },
1693
+ ],
1694
+ },
1695
+ ]
1696
+
1697
+ render(
1698
+ <AdvancedTable
1699
+ columnDefinitions={columnDefinitions}
1700
+ data={{ testid: testId }}
1701
+ expandedControl={{
1702
+ value: { "0": true, "0.0": true, "0.0.0": true, "0.0.1": true, "0.1": true, "0.1.0": true },
1703
+ onChange: () => {},
1704
+ }}
1705
+ groupSeparators
1706
+ tableData={data}
1707
+ />
1708
+ )
1709
+
1710
+ const kit = screen.getByTestId(testId)
1711
+ const dayRow = (day) => [...kit.querySelectorAll("tbody tr.depth-sub-row-3")].find((row) =>
1712
+ row.querySelector("td")?.textContent.trim() === day
1713
+ )
1714
+
1715
+ // One stroke per row, inset to the outermost group it closes
1716
+ expect(dayRow("15")).not.toHaveClass("group-separator-row")
1717
+ // Closes January → January's trail
1718
+ expect(dayRow("25")).toHaveStyle({ "--group-separator-inset": "3.5em" })
1719
+ // Closes May + Q1 → Q1's trail
1720
+ expect(dayRow("2")).toHaveStyle({ "--group-separator-inset": "2.25em" })
1721
+ // Closes June + Q2 + 2022 → full-bleed
1722
+ expect(dayRow("5")).toHaveStyle({ "--group-separator-inset": "0em" })
1723
+ })
1724
+
1725
+ test("groupSeparators insets Q1 closer to the Q1 label, not the year gutter", () => {
1726
+ const data = [
1727
+ {
1728
+ year: "2022",
1729
+ newEnrollments: "25",
1730
+ scheduledMeetings: "1",
1731
+ children: [
1732
+ {
1733
+ year: "2022",
1734
+ quarter: "Q1",
1735
+ newEnrollments: "12",
1736
+ scheduledMeetings: "1",
1737
+ children: [
1738
+ { year: "2022", quarter: "Q1", month: "January", newEnrollments: "7", scheduledMeetings: "1" },
1739
+ { year: "2022", quarter: "Q1", month: "May", newEnrollments: "5", scheduledMeetings: "1" },
1740
+ ],
1741
+ },
1742
+ {
1743
+ year: "2022",
1744
+ quarter: "Q2",
1745
+ newEnrollments: "13",
1746
+ scheduledMeetings: "1",
1747
+ },
1748
+ ],
1749
+ },
1750
+ ]
1751
+
1752
+ render(
1753
+ <AdvancedTable
1754
+ columnDefinitions={columnDefinitions}
1755
+ data={{ testid: testId }}
1756
+ expandedControl={{ value: { "0": true, "0.0": true }, onChange: () => {} }}
1757
+ groupSeparators
1758
+ tableData={data}
1759
+ />
1760
+ )
1761
+
1762
+ const kit = screen.getByTestId(testId)
1763
+ const mayRow = [...kit.querySelectorAll("tbody tr")].find((row) =>
1764
+ row.classList.contains("group-separator-row") && row.textContent.includes("May")
1765
+ )
1766
+ const q2Row = [...kit.querySelectorAll("tbody tr")].find((row) =>
1767
+ row.classList.contains("group-separator-row") && row.textContent.includes("Q2")
1768
+ )
1769
+ // Q1 closer → deepest trail on May (depth 2) = 2.25em; year closer → 0 (full-bleed)
1770
+ expect(mayRow).toHaveStyle({ "--group-separator-inset": "2.25em" })
1771
+ expect(q2Row).toHaveStyle({ "--group-separator-inset": "0em" })
1772
+ })
1773
+
1774
+ test("groupSeparators marks last siblings in pinned nested rows", async () => {
1775
+ const data = [
1776
+ {
1777
+ id: "y1",
1778
+ year: "2021",
1779
+ newEnrollments: "20",
1780
+ scheduledMeetings: "10",
1781
+ children: [
1782
+ {
1783
+ id: "q1",
1784
+ year: "2021",
1785
+ quarter: "Q1",
1786
+ newEnrollments: "5",
1787
+ scheduledMeetings: "2",
1788
+ children: [
1789
+ {
1790
+ id: "jan",
1791
+ year: "2021",
1792
+ quarter: "Q1",
1793
+ month: "January",
1794
+ newEnrollments: "2",
1795
+ scheduledMeetings: "1",
1796
+ },
1797
+ {
1798
+ id: "feb",
1799
+ year: "2021",
1800
+ quarter: "Q1",
1801
+ month: "February",
1802
+ newEnrollments: "3",
1803
+ scheduledMeetings: "1",
1804
+ },
1805
+ ],
1806
+ },
1807
+ {
1808
+ id: "q2",
1809
+ year: "2021",
1810
+ quarter: "Q2",
1811
+ newEnrollments: "6",
1812
+ scheduledMeetings: "3",
1813
+ children: [
1814
+ {
1815
+ id: "apr",
1816
+ year: "2021",
1817
+ quarter: "Q2",
1818
+ month: "April",
1819
+ newEnrollments: "3",
1820
+ scheduledMeetings: "1",
1821
+ },
1822
+ {
1823
+ id: "may",
1824
+ year: "2021",
1825
+ quarter: "Q2",
1826
+ month: "May",
1827
+ newEnrollments: "3",
1828
+ scheduledMeetings: "2",
1829
+ },
1830
+ ],
1831
+ },
1832
+ ],
1833
+ },
1834
+ ]
1835
+
1836
+ const PinnedGroupSeparators = () => {
1837
+ const [pinned, setPinned] = useState({ top: ["y1"] })
1838
+ return (
1839
+ <AdvancedTable
1840
+ columnDefinitions={columnDefinitions}
1841
+ data={{ testid: testId }}
1842
+ expandedControl={{ value: { y1: true, q1: true, q2: true }, onChange: () => {} }}
1843
+ groupSeparators
1844
+ pinnedRows={{ value: pinned, onChange: setPinned }}
1845
+ tableData={data}
1846
+ />
1847
+ )
1848
+ }
1849
+
1850
+ render(<PinnedGroupSeparators />)
1851
+
1852
+ const kit = screen.getByTestId(testId)
1853
+ await waitFor(() => {
1854
+ const separatorRows = [...kit.querySelectorAll("tbody tr.pinned-row.group-separator-row")]
1855
+ const separatorText = separatorRows.map((row) => row.textContent)
1856
+
1857
+ expect(separatorRows.length).toBe(2)
1858
+ expect(separatorText.some((text) => text.includes("February"))).toBe(true)
1859
+ expect(separatorText.some((text) => text.includes("May"))).toBe(true)
1860
+ })
1861
+ })
1862
+
1863
+ test("groupSeparators keeps separator on expanded last sibling with empty children (inlineRowLoading)", () => {
1864
+ const data = [
1865
+ {
1866
+ year: "2021",
1867
+ newEnrollments: "10",
1868
+ scheduledMeetings: "1",
1869
+ children: [
1870
+ {
1871
+ year: "2021",
1872
+ quarter: "Q1",
1873
+ newEnrollments: "5",
1874
+ scheduledMeetings: "1",
1875
+ children: [],
1876
+ },
1877
+ {
1878
+ year: "2021",
1879
+ quarter: "Q2",
1880
+ newEnrollments: "5",
1881
+ scheduledMeetings: "1",
1882
+ children: [],
1883
+ },
1884
+ ],
1885
+ },
1886
+ ]
1887
+
1888
+ render(
1889
+ <AdvancedTable
1890
+ columnDefinitions={columnDefinitions}
1891
+ data={{ testid: testId }}
1892
+ expandedControl={{ value: { "0": true, "0.1": true }, onChange: () => {} }}
1893
+ groupSeparators
1894
+ inlineRowLoading
1895
+ tableData={data}
1896
+ />
1897
+ )
1898
+
1899
+ const kit = screen.getByTestId(testId)
1900
+ const q2Row = [...kit.querySelectorAll("tbody tr")].find((row) =>
1901
+ row.classList.contains("depth-sub-row-1") && row.textContent.includes("Q2")
1902
+ )
1903
+
1904
+ expect(q2Row).toHaveClass("group-separator-row")
1905
+ })
1906
+
1907
+ test("groupSeparators follows sorted visible sibling order", async () => {
1908
+ const data = [
1909
+ {
1910
+ year: "2021",
1911
+ newEnrollments: "10",
1912
+ scheduledMeetings: "1",
1913
+ children: [
1914
+ {
1915
+ year: "2021",
1916
+ quarter: "Q1",
1917
+ newEnrollments: "30",
1918
+ scheduledMeetings: "1",
1919
+ },
1920
+ {
1921
+ year: "2021",
1922
+ quarter: "Q2",
1923
+ newEnrollments: "10",
1924
+ scheduledMeetings: "1",
1925
+ },
1926
+ ],
1927
+ },
1928
+ ]
1929
+
1930
+ const sortColumnDefinitions = [
1931
+ {
1932
+ accessor: "year",
1933
+ label: "Year",
1934
+ cellAccessors: ["quarter", "month", "day"],
1935
+ },
1936
+ {
1937
+ accessor: "newEnrollments",
1938
+ label: "New Enrollments",
1939
+ enableSort: true,
1940
+ },
1941
+ {
1942
+ accessor: "scheduledMeetings",
1943
+ label: "Scheduled Meetings",
1944
+ },
1945
+ ]
1946
+
1947
+ render(
1948
+ <AdvancedTable
1949
+ columnDefinitions={sortColumnDefinitions}
1950
+ data={{ testid: testId }}
1951
+ expandedControl={{ value: { "0": true }, onChange: () => {} }}
1952
+ groupSeparators
1953
+ tableData={data}
1954
+ />
1955
+ )
1956
+
1957
+ const kit = screen.getByTestId(testId)
1958
+ // Original data order: Q2 is last sibling → separator on Q2
1959
+ expect(
1960
+ [...kit.querySelectorAll("tbody tr.group-separator-row")].some((row) =>
1961
+ row.textContent.includes("Q2")
1962
+ )
1963
+ ).toBe(true)
1964
+
1965
+ const sortButton = kit.querySelector(".header-sort-secondary-columns")
1966
+ expect(sortButton).toBeInTheDocument()
1967
+ // sortDescFirst: first click is desc (Q1=30, Q2=10) — Q2 still last.
1968
+ // Second click is asc (Q2=10, Q1=30) — separator should move to Q1.
1969
+ sortButton.click()
1970
+ sortButton.click()
1971
+
1972
+ await waitFor(() => {
1973
+ const separatorRows = [...kit.querySelectorAll("tbody tr.group-separator-row")]
1974
+ expect(separatorRows.some((row) => row.textContent.includes("Q1"))).toBe(true)
1975
+ expect(separatorRows.some((row) => row.textContent.includes("Q2"))).toBe(false)
1976
+ })
1977
+ })
1978
+
1979
+
1980
+ test("groupSeparators insets follow the trail formula past 3 levels", () => {
1981
+ const rowsAt = (depths) => depths.map((depth, index) => ({ id: `${index}`, depth }))
1982
+
1983
+ // Depth-5 leaf closing only its depth-4 parent → 5th trail (5 + 4 * 0.25)
1984
+ expect(buildGroupSeparatorInsets(rowsAt([0, 1, 2, 3, 4, 5, 4])).get("5")).toBe(6)
1985
+ // Depth-5 leaf closing up to the depth-1 group → 2nd trail
1986
+ expect(buildGroupSeparatorInsets(rowsAt([0, 1, 2, 3, 4, 5, 1])).get("5")).toBe(2.25)
1987
+ // Depth-5 leaf closing the year → full-bleed
1988
+ expect(buildGroupSeparatorInsets(rowsAt([0, 1, 2, 3, 4, 5, 0])).get("5")).toBe(0)
1989
+ })
@@ -0,0 +1,67 @@
1
+ import React, { useState } from "react"
2
+ import AdvancedTable from '../../pb_advanced_table/_advanced_table'
3
+ import MOCK_DATA_GROUP_SEPARATORS from "./advanced_table_mock_data_group_separators.json"
4
+
5
+ const AdvancedTableGroupSeparators = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ]
37
+
38
+ // Match design screenshot: 2022 → Q1 → January open; May/Q2 collapsed; 2023 open to quarters
39
+ const [expanded, setExpanded] = useState({
40
+ "1": true,
41
+ "1.0": true,
42
+ "1.0.0": true,
43
+ "2": true,
44
+ })
45
+
46
+ const expandedControl = {
47
+ onChange: setExpanded,
48
+ value: expanded,
49
+ }
50
+
51
+ return (
52
+ <div>
53
+ <AdvancedTable
54
+ columnDefinitions={columnDefinitions}
55
+ expandedControl={expandedControl}
56
+ groupSeparators
57
+ onRowToggleClick={(row) => {
58
+ setExpanded({ ...expanded, [row.id]: !expanded[row.id] })
59
+ }}
60
+ tableData={MOCK_DATA_GROUP_SEPARATORS}
61
+ {...props}
62
+ />
63
+ </div>
64
+ )
65
+ }
66
+
67
+ export default AdvancedTableGroupSeparators
@@ -0,0 +1,7 @@
1
+ `groupSeparators` (default `false`) draws a higher-contrast `2px` stroke (`$input_border_default`) on the last visible row of each nested child group, replacing the default row border.
2
+
3
+ - When one row closes several groups at once, a single stroke insets to the outermost group it closes (its collapsible-trail); closing a year is full-bleed left
4
+ - Expanded parents defer the separator to their last visible descendant
5
+ - Root rows never get a separator; the break before the next root is the previous tree’s last child
6
+
7
+ This example defaults to **2022 → Q1 → January** open (May/Q2 collapsed) and **2023** open to its quarters, so you can see nested insets and a year-level full-bleed separator together.
@@ -0,0 +1,78 @@
1
+ <% column_definitions = [
2
+ {
3
+ accessor: "year",
4
+ label: "Year",
5
+ cellAccessors: ["quarter", "month", "day"],
6
+ },
7
+ {
8
+ accessor: "newEnrollments",
9
+ label: "New Enrollments",
10
+ },
11
+ {
12
+ accessor: "scheduledMeetings",
13
+ label: "Scheduled Meetings",
14
+ },
15
+ {
16
+ accessor: "attendanceRate",
17
+ label: "Attendance Rate",
18
+ },
19
+ {
20
+ accessor: "completedClasses",
21
+ label: "Completed Classes",
22
+ },
23
+ {
24
+ accessor: "classCompletionRate",
25
+ label: "Class Completion Rate",
26
+ },
27
+ {
28
+ accessor: "graduatedStudents",
29
+ label: "Graduated Students",
30
+ }
31
+ ] %>
32
+
33
+ <%= pb_rails("advanced_table", props: { id: "group_separators", table_data: @table_data_group_separators, column_definitions: column_definitions, group_separators: true }) %>
34
+
35
+ <%# Mirror React default expand: 2022 → Q1 → January; 2023 year open (quarters collapsed) %>
36
+ <script>
37
+ (function () {
38
+ // Expand a path like ["2022", "Q1", "January"], searching each label only
39
+ // within the previous row's subtree so e.g. 2021's Q1 is never matched.
40
+ function expandPath(root, labels) {
41
+ var rows = root.querySelectorAll("tr[data-row-depth]");
42
+ var start = 0;
43
+
44
+ for (var depth = 0; depth < labels.length; depth++) {
45
+ var row = null;
46
+ for (var i = start; i < rows.length; i++) {
47
+ var rowDepth = Number(rows[i].getAttribute("data-row-depth"));
48
+ if (rowDepth < depth) break;
49
+ var cell = rows[i].querySelector("td");
50
+ if (rowDepth === depth && cell && cell.textContent.indexOf(labels[depth]) !== -1) {
51
+ row = rows[i];
52
+ start = i + 1;
53
+ break;
54
+ }
55
+ }
56
+ if (!row) return;
57
+
58
+ var toggle = row.querySelector("[data-advanced-table]");
59
+ if (toggle && !row.classList.contains("group-separator-expanded")) toggle.click();
60
+ }
61
+ }
62
+
63
+ function expandGroupSeparatorsExample() {
64
+ var root = document.getElementById("group_separators");
65
+ if (!root) return;
66
+
67
+ expandPath(root, ["2022", "Q1", "January"]);
68
+ expandPath(root, ["2023"]);
69
+ }
70
+
71
+ if (document.readyState === "loading") {
72
+ document.addEventListener("DOMContentLoaded", expandGroupSeparatorsExample);
73
+ } else {
74
+ expandGroupSeparatorsExample();
75
+ }
76
+ setTimeout(expandGroupSeparatorsExample, 0);
77
+ })();
78
+ </script>
@@ -0,0 +1,3 @@
1
+ `group_separators` (default `false`) mirrors React `groupSeparators`: a `2px` `$input_border_default` stroke on the last sibling of each nested child group (replacing the default border; inset to the outermost group it closes, full-bleed when that is a year).
2
+
3
+ This example defaults to **2022 → Q1 → January** open (May/Q2 collapsed) and **2023** open to its quarters, matching the React example. Expanded last-sibling parents defer to the last visible descendant.
@@ -10,6 +10,7 @@
10
10
  "columnGroupBorderColor": "none",
11
11
  "enableToggleExpansion": "header",
12
12
  "fullWidthCell": false,
13
+ "groupSeparators": false,
13
14
  "inlineRowLoading": false,
14
15
  "loading": false,
15
16
  "maxHeight": "auto",
@@ -117,7 +118,8 @@
117
118
  {
118
119
  "name": "Styling",
119
120
  "props": [
120
- "rowStyling"
121
+ "rowStyling",
122
+ "groupSeparators"
121
123
  ]
122
124
  },
123
125
  {
@@ -315,6 +317,13 @@
315
317
  "message": "When cascadeCollapse is true, collapsing any parent row itself or by using the toggle expansion buttons in any header or subheader row also collapses all descendants and clears their expansion state. Re-expanding then shows only direct children until the user expands deeper levels again.",
316
318
  "type": "info"
317
319
  },
320
+ "group_separators_info": {
321
+ "when": {
322
+ "groupSeparators": true
323
+ },
324
+ "message": "groupSeparators adds a 2px higher-contrast bottom border on the last visible row of each nested child group. Expand multi-level rows to see separators between sibling groups.",
325
+ "type": "info"
326
+ },
318
327
  "column_styling_info": {
319
328
  "presetName": "Column Styling",
320
329
  "message": "This sample uses columnStyling on column definitions. Year uses width for a fixed hierarchy column; other columns show background colors. See the Column Styling Width doc for minWidth and min/pref/max bands.",
@@ -180,7 +180,7 @@
180
180
  },
181
181
  {
182
182
  "name": "Styling",
183
- "props": ["rowStyling"]
183
+ "props": ["rowStyling", "groupSeparators"]
184
184
  },
185
185
  {
186
186
  "name": "Selection & Actions",
@@ -370,6 +370,13 @@
370
370
  "message": "When cascadeCollapse is true, collapsing any parent row itself or by using the toggle expansion buttons in any header or subheader row also collapses all descendants and clears their expansion state. Re-expanding then shows only direct children until the user expands deeper levels again.",
371
371
  "type": "info"
372
372
  },
373
+ "group_separators_info": {
374
+ "when": {
375
+ "groupSeparators": true
376
+ },
377
+ "message": "groupSeparators adds a 2px higher-contrast bottom border on the last visible row of each nested child group. Expand multi-level rows to see separators between sibling groups.",
378
+ "type": "info"
379
+ },
373
380
  "column_styling_info": {
374
381
  "presetName": "Column Styling",
375
382
  "message": "This sample uses columnStyling on column definitions. Year uses width for a fixed hierarchy column; other columns show background colors. See the Column Styling Width doc for minWidth and min/pref/max bands.",