playbook_ui 16.12.0.pre.rc.2 → 16.12.0.pre.rc.3

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/column_layout_helper.rb +76 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +5 -8
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +1 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +6 -3
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_width.md +6 -6
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_width_rails.html.erb +41 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_width_rails.md +49 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_both_rails.html.erb +57 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_both_rails.md +1 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_bottom_rails.html.erb +57 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_bottom_rails.md +1 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_rails.html.erb +5 -5
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_rails.md +3 -3
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +4 -1
  16. data/app/pb_kits/playbook/pb_advanced_table/index.js +28 -11
  17. data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +17 -5
  18. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +54 -17
  19. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +15 -3
  20. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +19 -2
  21. data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +4 -0
  22. data/app/pb_kits/playbook/pb_docs/kit_example.html.erb +7 -14
  23. data/app/pb_kits/playbook/pb_docs/kit_example.rb +2 -17
  24. data/app/pb_kits/playbook/pb_pill/_pill.scss +25 -4
  25. data/app/pb_kits/playbook/pb_pill/_pill.test.jsx +83 -0
  26. data/app/pb_kits/playbook/pb_pill/_pill.tsx +3 -1
  27. data/app/pb_kits/playbook/pb_pill/docs/_pill_size.html.erb +1 -0
  28. data/app/pb_kits/playbook/pb_pill/docs/_pill_size.jsx +16 -0
  29. data/app/pb_kits/playbook/pb_pill/docs/_pill_size.md +1 -0
  30. data/app/pb_kits/playbook/pb_pill/docs/_playground.json +11 -0
  31. data/app/pb_kits/playbook/pb_pill/docs/_playground.overrides.json +11 -1
  32. data/app/pb_kits/playbook/pb_pill/docs/example.yml +2 -0
  33. data/app/pb_kits/playbook/pb_pill/docs/index.js +1 -0
  34. data/app/pb_kits/playbook/pb_pill/kit.schema.json +13 -2
  35. data/app/pb_kits/playbook/pb_pill/pill.rb +4 -1
  36. data/dist/chunks/vendor.js +1 -1
  37. data/dist/menu.yml +1 -10
  38. data/dist/playbook-rails.js +1 -1
  39. data/dist/playbook.css +1 -1
  40. data/lib/playbook/pb_doc_helper.rb +0 -2
  41. data/lib/playbook/version.rb +1 -1
  42. metadata +13 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfd216d4f2b888b976c65a9d5a7a9f3b85c980873d2ea731f1f8e9e625b6bb7a
4
- data.tar.gz: ef14fc5a7b4c3674b796589c4ed64191c396cbbc0a8a2a5f01e5c4e86c7494b6
3
+ metadata.gz: 9b0119ac58cc850a5b4a3d11f95e5c8b74d97dd1789a75f7fabb7242e13cdcfd
4
+ data.tar.gz: 9241e64bb878507e3900607dff3ef6027bd394afa3fbf82aa9e6eb6079b826c5
5
5
  SHA512:
6
- metadata.gz: c1d9b48277949ea6ec17fe88bc0705fb3259f9f38338d2f3715aadc4213f63866f0a498dd55935e8d71a1d18da581fd64091a01d3f81a7b56f9b150d132ac8c4
7
- data.tar.gz: 6ac44566fc4ae3fd9122504aab547d6a1b2da04f29e1355092ceca453ef906bcaf176f73c36522746420f169624248fde9989cf923a7b6c4edf7f770c748037f
6
+ metadata.gz: 5f7af03e8b45e7b5ba253d7c17e31b565853a4d26a8145fa6885a8224ea59b325a777128fcaba8a4227b0a7b901376f5246e8227e3c63ddc5140048f7f58b2c0
7
+ data.tar.gz: f6359406f9719eb0212973ce8a21a1854fed773b81ca517d3259fd323fcd2ee5caf0ca623b9b9f2d24933eb14557114133e70f1f108b14ba34ba420505ce4542
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbAdvancedTable
5
+ # Mirrors React ColumnLayoutHelper: maps column_styling width keys to inline
6
+ # styles on header/body cells so columns stay stable when rows expand/collapse.
7
+ module ColumnLayoutHelper
8
+ # Converts a Playbook column width value to a CSS length string.
9
+ # Numbers are treated as pixels; strings are passed through (e.g. "12rem", "200px").
10
+ def css_length(value)
11
+ return nil if value.nil? || value == ""
12
+
13
+ return "#{value}px" if value.is_a?(Numeric)
14
+
15
+ value.to_s
16
+ end
17
+
18
+ # Reads a styling length from column_styling, accepting snake_case or camelCase keys.
19
+ def read_styling_length(styling, *keys)
20
+ return nil unless styling.is_a?(Hash)
21
+
22
+ keys.each do |key|
23
+ value = styling[key] || styling[key.to_s] || styling[key.to_sym]
24
+ return value unless value.nil?
25
+ end
26
+ nil
27
+ end
28
+
29
+ # Builds layout styles from a column definition that may include :column_styling.
30
+ def build_column_layout_styles_from_column(column)
31
+ return {} unless column.is_a?(Hash)
32
+
33
+ styling = column[:column_styling] || column["column_styling"] || {}
34
+ build_column_layout_styles(styling)
35
+ end
36
+
37
+ # Inline width styles for <th> / <td>. Returns a hash with :width, :min_width,
38
+ # and/or :max_width (CSS length strings). KitBase converts snake_case keys to
39
+ # kebab-case CSS properties.
40
+ #
41
+ # If only +width+ is set (no min/max), all three are locked to that value.
42
+ def build_column_layout_styles(styling)
43
+ return {} unless styling.is_a?(Hash) && styling.present?
44
+
45
+ styling_width = read_styling_length(styling, :width, "width")
46
+ styling_min = read_styling_length(styling, :min_width, "min_width", :minWidth, "minWidth")
47
+ styling_max = read_styling_length(styling, :max_width, "max_width", :maxWidth, "maxWidth")
48
+
49
+ has_width = !styling_width.nil? && styling_width != ""
50
+ has_min = !styling_min.nil? && styling_min != ""
51
+ has_max = !styling_max.nil? && styling_max != ""
52
+
53
+ width_value = has_width ? styling_width : nil
54
+ min_value = has_min ? styling_min : nil
55
+ max_value = has_max ? styling_max : nil
56
+
57
+ if has_width && !has_min && !has_max
58
+ min_value = styling_width
59
+ max_value = styling_width
60
+ width_value = styling_width
61
+ end
62
+
63
+ styles = {}
64
+ width_css = css_length(width_value)
65
+ min_css = css_length(min_value)
66
+ max_css = css_length(max_value)
67
+
68
+ styles[:width] = width_css if width_css
69
+ styles[:min_width] = min_css if min_css
70
+ styles[:max_width] = max_css if max_css
71
+
72
+ styles
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1,15 +1,12 @@
1
1
  The `columnStyling` prop is an optional item that can be used within `columnDefinitions` as shown in the code snippet below. It is an object that has several optional key/value pairs, this doc example highlights the following:
2
2
 
3
- 1) `headerAlignment`: This will allow you to control alignment of header content which is set to right aligned by default. you can set this to `left`, `right` or `center`.
4
-
5
- 2) `cellAlignment`: This will allow you to control alignment of content within all cells in the given column. This is set to right aligned by default. you can set this to `left`, `right` or `center`.
6
-
7
- 3) `fontColor`: This will allow you to control the font color for a given column.
8
-
9
- 4) Column width: optional keys on `columnStyling` are `minWidth`, `width`, and `maxWidth` (numbers = pixels; CSS strings allowed). This example sets `width` on Year for a fixed hierarchy column (see the width doc for `minWidth` and bands).
3
+ 1. `headerAlignment`: This will allow you to control alignment of header content which is set to right aligned by default. you can set this to `left`, `right` or `center`.
4
+ 2. `cellAlignment`: This will allow you to control alignment of content within all cells in the given column. This is set to right aligned by default. you can set this to `left`, `right` or `center`.
5
+ 3. `fontColor`: This will allow you to control the font color for a given column.
6
+ 4. Column width: optional keys on `columnStyling` are `minWidth`, `width`, and `maxWidth` (numbers = pixels; CSS strings allowed). This example sets `width` on Year for a fixed hierarchy column (see the width doc for `minWidth` and bands).
10
7
 
11
8
  Fixed width: pass `width` only (or TanStack `size` only) and Playbook sets min and max to the same value automatically — you do not need all three for an exact width.
12
9
 
13
- See [Column Styling: Width](https://playbook.powerapp.cloud/kits/advanced_table/react#column-styling-width) for the full guide (Playbook ↔ TanStack mapping, floor-only vs bands, and when to use one vs three values).
10
+ See [Column Styling: Width](https://playbook.powerapp.cloud/kits/advanced_table/styling/react#column-styling-width) for the full guide (Playbook ↔ TanStack mapping, floor-only vs bands, and when to use one vs three values).
14
11
 
15
12
  `columnStyling` can be used within the columnDefinition of all the columns or some of them, as shown. Each column has its own individual control in this way.
@@ -3,6 +3,7 @@
3
3
  accessor: "year",
4
4
  label: "Year",
5
5
  cellAccessors: ["quarter", "month", "day"],
6
+ column_styling: { width: 124 },
6
7
  },
7
8
  {
8
9
  accessor: "newEnrollments",
@@ -1,9 +1,12 @@
1
1
  The `column_styling` prop is an optional item that can be used within `column_definitions` as shown in the code snippet below. It is an object that has several optional key/value pairs, this doc example highlights the following:
2
2
 
3
3
  1) `header_alignment`: This will allow you to control alignment of header content which is set to right aligned by default. you can set this to `left`, `right` or `center`.
4
-
5
4
  2) `cell_alignment`: This will allow you to control alignment of content within all cells in the given column. This is set to right aligned by default. you can set this to `left`, `right` or `center`.
6
-
7
5
  3) `font_color`: This will allow you to control the font color for a given column.
6
+ 4) Column width: optional keys on `column_styling` are `min_width`, `width`, and `max_width` (numbers = pixels; CSS strings allowed). This example sets `width` on Year for a fixed hierarchy column (see the width doc for `min_width` and bands).
7
+
8
+ Fixed width: pass `width` only and Playbook sets min and max to the same value automatically — you do not need all three for an exact width.
9
+
10
+ See [Column Styling: Width](https://playbook.powerapp.cloud/kits/advanced_table/styling/rails#column-styling-width) for the full guide (floor-only vs bands, and when to use one vs three values).
8
11
 
9
- `column_styling` can be used within the column_definition of all the columns or some of them, as shown. Each column has its own individual control in this way.
12
+ `column_styling` can be used within the column_definition of all the columns or some of them, as shown. Each column has its own individual control in this way.
@@ -1,6 +1,6 @@
1
1
  AdvancedTable column width is controlled in two equivalent places on each leaf `columnDefinitions` entry. Playbook maps them to inline styles on header and body cells (and forwards numeric values into TanStack Table’s column model).
2
2
 
3
- 1) Playbook `columnStyling` and TanStack `ColumnDef` use the same three ideas:
3
+ **1)** Playbook `columnStyling` and TanStack `ColumnDef` use the same three ideas:
4
4
 
5
5
  - Preferred / target width: `columnStyling` `width` maps to TanStack `size` on the same column object.
6
6
  - Minimum width (floor): `columnStyling` `minWidth` maps to TanStack `minSize`.
@@ -10,7 +10,7 @@ Numbers are pixels. You can also pass CSS length strings on `columnStyling` (e.g
10
10
 
11
11
  If both APIs set the same axis, `columnStyling` wins for that axis when Playbook builds cell styles.
12
12
 
13
- 2) Fixed width: set `width` only
13
+ **2)** Fixed width: set `width` only
14
14
 
15
15
  If you pass only `width` (or only `size`) and do not set `minWidth` / `maxWidth` (or `minSize` / `maxSize`), Playbook treats that as a fixed column: it sets all three to the same value under the hood so you do not have to repeat yourself.
16
16
 
@@ -26,7 +26,7 @@ size: 200
26
26
 
27
27
  Use this when the column should stay one width (e.g. a hierarchy column with expand controls).
28
28
 
29
- 3) Floor only: `minWidth` / `minSize`
29
+ **3)** Floor only: `minWidth` / `minSize`
30
30
 
31
31
  Set only a minimum when the column may grow with the table or content but must not shrink below a baseline (common fix for horizontal “jump” when rows expand):
32
32
 
@@ -34,7 +34,7 @@ Set only a minimum when the column may grow with the table or content but must n
34
34
  columnStyling: { minWidth: 160 }
35
35
  ```
36
36
 
37
- 4) Flexible band: min + preferred + max
37
+ **4)** Flexible band: min + preferred + max
38
38
 
39
39
  Set two or three values when you want a range. CSS uses preferred `width` clamped between `minWidth` and `maxWidth`:
40
40
 
@@ -46,7 +46,7 @@ Example from the table below (Attendance): `minWidth: 108`, `width: 124`, `maxWi
46
46
 
47
47
  You only need all three when you want that band. If min and max are omitted, `width` alone is enough for a fixed column.
48
48
 
49
- 5) TanStack band without `columnStyling`
49
+ **5)** TanStack band without `columnStyling`
50
50
 
51
51
  The Meetings column uses only TanStack fields:
52
52
 
@@ -56,7 +56,7 @@ The Meetings column uses only TanStack fields:
56
56
 
57
57
  Playbook applies the same min / preferred / max idea to cell styles. Setting only `size: 200` would lock all three to 200, same as `width: 200` in `columnStyling`.
58
58
 
59
- 6) What the example table shows
59
+ **6)** What the example table shows
60
60
 
61
61
  - Year (fixed): `columnStyling: { width: 128 }` — locked to 128px.
62
62
  - Enrollments (floor): `columnStyling: { minWidth: 160 }` — at least 160px; can grow.
@@ -0,0 +1,41 @@
1
+ <% column_definitions = [
2
+ {
3
+ accessor: "year",
4
+ label: "Year (fixed)",
5
+ cellAccessors: ["quarter", "month", "day"],
6
+ # width alone locks min + max to the same value (128px).
7
+ column_styling: { width: 128 },
8
+ },
9
+ {
10
+ accessor: "newEnrollments",
11
+ label: "Enrollments (floor)",
12
+ column_styling: { min_width: 160 },
13
+ },
14
+ {
15
+ accessor: "scheduledMeetings",
16
+ label: "Meetings (preferred)",
17
+ column_styling: { width: 200, min_width: 160, max_width: 240 },
18
+ },
19
+ {
20
+ accessor: "attendanceRate",
21
+ label: "Attendance (min / pref / max)",
22
+ column_styling: { min_width: 108, width: 124, max_width: 168 },
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Completion %",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated",
35
+ },
36
+ ] %>
37
+
38
+ <%= pb_rails("advanced_table", props: { id: "column-styling-width", table_data: @table_data, column_definitions: column_definitions }) do %>
39
+ <%= pb_rails("advanced_table/table_header", props: { table_id: "column-styling-width", column_definitions: column_definitions }) %>
40
+ <%= pb_rails("advanced_table/table_body", props: { table_id: "column-styling-width", table_data: @table_data, column_definitions: column_definitions }) %>
41
+ <% end %>
@@ -0,0 +1,49 @@
1
+ AdvancedTable column width is controlled on each leaf `column_definitions` entry via `column_styling`. Playbook maps these keys to inline styles on header and body cells.
2
+
3
+ **1)** `column_styling` width keys:
4
+
5
+ - Preferred / target width: `width`
6
+ - Minimum width (floor): `min_width`
7
+ - Maximum width (ceiling): `max_width`
8
+
9
+ Numbers are pixels. You can also pass CSS length strings (e.g. `"12rem"`, `"200px"`).
10
+
11
+ **2)** Fixed width: set `width` only
12
+
13
+ If you pass only `width` and do not set `min_width` / `max_width`, Playbook treats that as a fixed column: it sets all three to the same value under the hood so you do not have to repeat yourself.
14
+
15
+ ```ruby
16
+ column_styling: { width: 128 }
17
+ # Applied as width, min-width, and max-width: 128px
18
+ ```
19
+
20
+ Use this when the column should stay one width (e.g. a hierarchy column with expand controls).
21
+
22
+ **3)** Floor only: `min_width`
23
+
24
+ Set only a minimum when the column may grow with the table or content but must not shrink below a baseline (common fix for horizontal “jump” when rows expand):
25
+
26
+ ```ruby
27
+ column_styling: { min_width: 160 }
28
+ ```
29
+
30
+ **4)** Flexible band: min + preferred + max
31
+
32
+ Set two or three values when you want a range. CSS uses preferred `width` clamped between `min_width` and `max_width`:
33
+
34
+ - `min_width`: won’t shrink below this.
35
+ - `width`: preferred size when space allows.
36
+ - `max_width`: won’t grow above this.
37
+
38
+ Example from the table below (Attendance): `min_width: 108`, `width: 124`, `max_width: 168` → preferred 124px, allowed between 108 and 168.
39
+
40
+ You only need all three when you want that band. If min and max are omitted, `width` alone is enough for a fixed column.
41
+
42
+ **5)** What the example table shows
43
+
44
+ - Year (fixed): `column_styling: { width: 128 }` — locked to 128px.
45
+ - Enrollments (floor): `column_styling: { min_width: 160 }` — at least 160px; can grow.
46
+ - Meetings (preferred): `width` / `min_width` / `max_width` — preferred 200px, between 160–240.
47
+ - Attendance (min / pref / max): all three — preferred 124px, between 108–168.
48
+
49
+ Grouped columns: put width options on leaf definitions (columns with an `accessor`), not on parent group headers.
@@ -0,0 +1,57 @@
1
+ <%# Example sort method for demonstration purposes %>
2
+ <% if params["sort"] %>
3
+ <% sort_param = params["sort"].gsub(/_(asc|desc)\z/, "") %>
4
+ <% sort_direction = params["sort"].end_with?("_asc") ? 1 : -1 %>
5
+ <% @table_data_with_id.sort! do |a, b|
6
+ value_a = a[sort_param] || a[sort_param.to_sym]
7
+ value_b = b[sort_param] || b[sort_param.to_sym]
8
+
9
+ value_a = value_a.to_i if value_a.is_a?(String) && value_a.match?(/^\d+$/)
10
+ value_b = value_b.to_i if value_b.is_a?(String) && value_b.match?(/^\d+$/)
11
+
12
+ sort_direction * (value_a <=> value_b)
13
+ end %>
14
+ <% end %>
15
+
16
+ <% column_definitions = [
17
+ {
18
+ accessor: "year",
19
+ label: "Year",
20
+ cellAccessors: ["quarter", "month", "day"],
21
+ sort_menu: [
22
+ { item: "Year", link: "?sort=year_asc#pinned_rows_both_table", active: params["sort"] == "year_asc", direction: "asc" },
23
+ { item: "Year", link: "?sort=year_desc#pinned_rows_both_table", active: params["sort"] == "year_desc", direction: "desc" }
24
+ ],
25
+ },
26
+ {
27
+ accessor: "newEnrollments",
28
+ label: "New Enrollments",
29
+ },
30
+ {
31
+ accessor: "scheduledMeetings",
32
+ label: "Scheduled Meetings",
33
+ },
34
+ {
35
+ accessor: "attendanceRate",
36
+ label: "Attendance Rate",
37
+ },
38
+ {
39
+ accessor: "completedClasses",
40
+ label: "Completed Classes",
41
+ },
42
+ {
43
+ accessor: "classCompletionRate",
44
+ label: "Class Completion Rate",
45
+ },
46
+ {
47
+ accessor: "graduatedStudents",
48
+ label: "Graduated Students",
49
+ }
50
+ ] %>
51
+
52
+ <% pinned_rows = { top: ["8"], bottom: ["1"] } %>
53
+
54
+ <%= pb_rails("advanced_table", props: { id: "pinned_rows_both_table", table_data: @table_data_with_id, column_definitions: column_definitions, max_height: "xs", pinned_rows: pinned_rows, responsive: "none", table_props: { sticky: true }}) do %>
55
+ <%= pb_rails("advanced_table/table_header", props: { table_id: "pinned_rows_both_table", column_definitions: column_definitions }) %>
56
+ <%= pb_rails("advanced_table/table_body", props: { table_id: "pinned_rows_both_table", table_data: @table_data_with_id, column_definitions: column_definitions, pinned_rows: pinned_rows }) %>
57
+ <% end %>
@@ -0,0 +1 @@
1
+ This code snippet demonstrates `pinned_rows` taking a hash with an array of row ids to both the `top` and `bottom` keys.
@@ -0,0 +1,57 @@
1
+ <%# Example sort method for demonstration purposes %>
2
+ <% if params["sort"] %>
3
+ <% sort_param = params["sort"].gsub(/_(asc|desc)\z/, "") %>
4
+ <% sort_direction = params["sort"].end_with?("_asc") ? 1 : -1 %>
5
+ <% @table_data_with_id.sort! do |a, b|
6
+ value_a = a[sort_param] || a[sort_param.to_sym]
7
+ value_b = b[sort_param] || b[sort_param.to_sym]
8
+
9
+ value_a = value_a.to_i if value_a.is_a?(String) && value_a.match?(/^\d+$/)
10
+ value_b = value_b.to_i if value_b.is_a?(String) && value_b.match?(/^\d+$/)
11
+
12
+ sort_direction * (value_a <=> value_b)
13
+ end %>
14
+ <% end %>
15
+
16
+ <% column_definitions = [
17
+ {
18
+ accessor: "year",
19
+ label: "Year",
20
+ cellAccessors: ["quarter", "month", "day"],
21
+ sort_menu: [
22
+ { item: "Year", link: "?sort=year_asc#pinned_rows_bottom_table", active: params["sort"] == "year_asc", direction: "asc" },
23
+ { item: "Year", link: "?sort=year_desc#pinned_rows_bottom_table", active: params["sort"] == "year_desc", direction: "desc" }
24
+ ],
25
+ },
26
+ {
27
+ accessor: "newEnrollments",
28
+ label: "New Enrollments",
29
+ },
30
+ {
31
+ accessor: "scheduledMeetings",
32
+ label: "Scheduled Meetings",
33
+ },
34
+ {
35
+ accessor: "attendanceRate",
36
+ label: "Attendance Rate",
37
+ },
38
+ {
39
+ accessor: "completedClasses",
40
+ label: "Completed Classes",
41
+ },
42
+ {
43
+ accessor: "classCompletionRate",
44
+ label: "Class Completion Rate",
45
+ },
46
+ {
47
+ accessor: "graduatedStudents",
48
+ label: "Graduated Students",
49
+ }
50
+ ] %>
51
+
52
+ <% pinned_rows = { bottom: ["8"] } %>
53
+
54
+ <%= pb_rails("advanced_table", props: { id: "pinned_rows_bottom_table", table_data: @table_data_with_id, column_definitions: column_definitions, max_height: "xs", pinned_rows: pinned_rows, responsive: "none", table_props: { sticky: true }}) do %>
55
+ <%= pb_rails("advanced_table/table_header", props: { table_id: "pinned_rows_bottom_table", column_definitions: column_definitions }) %>
56
+ <%= pb_rails("advanced_table/table_body", props: { table_id: "pinned_rows_bottom_table", table_data: @table_data_with_id, column_definitions: column_definitions, pinned_rows: pinned_rows }) %>
57
+ <% end %>
@@ -0,0 +1 @@
1
+ This code snippet demonstrates `pinned_rows` taking a hash with an array of row ids to the `bottom` key.
@@ -19,8 +19,8 @@
19
19
  label: "Year",
20
20
  cellAccessors: ["quarter", "month", "day"],
21
21
  sort_menu: [
22
- { item: "Year", link: "?sort=year_asc#pinned_rows_table", active: params["sort"] == "year_asc", direction: "asc" },
23
- { item: "Year", link: "?sort=year_desc#pinned_rows_table", active: params["sort"] == "year_desc", direction: "desc" }
22
+ { item: "Year", link: "?sort=year_asc#pinned_rows_top_table", active: params["sort"] == "year_asc", direction: "asc" },
23
+ { item: "Year", link: "?sort=year_desc#pinned_rows_top_table", active: params["sort"] == "year_desc", direction: "desc" }
24
24
  ],
25
25
  },
26
26
  {
@@ -51,7 +51,7 @@
51
51
 
52
52
  <% pinned_rows = { top: ["8"] } %>
53
53
 
54
- <%= pb_rails("advanced_table", props: { id: "pinned_rows_table", table_data: @table_data_with_id, column_definitions: column_definitions, max_height: "xs", pinned_rows: pinned_rows, responsive: "none", table_props: { sticky: true }}) do %>
55
- <%= pb_rails("advanced_table/table_header", props: { table_id: "pinned_rows_table", column_definitions: column_definitions }) %>
56
- <%= pb_rails("advanced_table/table_body", props: { table_id: "pinned_rows_table", table_data: @table_data_with_id, column_definitions: column_definitions, pinned_rows: pinned_rows }) %>
54
+ <%= pb_rails("advanced_table", props: { id: "pinned_rows_top_table", table_data: @table_data_with_id, column_definitions: column_definitions, max_height: "xs", pinned_rows: pinned_rows, responsive: "none", table_props: { sticky: true }}) do %>
55
+ <%= pb_rails("advanced_table/table_header", props: { table_id: "pinned_rows_top_table", column_definitions: column_definitions }) %>
56
+ <%= pb_rails("advanced_table/table_body", props: { table_id: "pinned_rows_top_table", table_data: @table_data_with_id, column_definitions: column_definitions, pinned_rows: pinned_rows }) %>
57
57
  <% end %>
@@ -1,7 +1,7 @@
1
- Use the `pinned_rows` prop to pin specific rows to the top of an Advanced Table. Pinned rows will remain at the top when scrolling through table data and will not change position if sorting is used.
1
+ Use the `pinned_rows` prop to pin specific rows to the top or bottom of an Advanced Table. Pinned rows will remain at the top or bottom when scrolling through table data and will not change position if sorting is used.
2
2
 
3
3
  **NOTE:**
4
4
  - Sticky header required: Pinned rows must be used with `sticky: true` via `table_props` (works with both responsive and non-responsive tables)
5
5
  - Row ids required: Each object within the `table_data` array must contain a unique `id` in order to attach an id to all Rows for this to function.
6
- - `pinned_rows` takes a hash with a `top` key containing an array of row ids, as shown in the code snippet below.
7
- - For expandable rows, use the parent id in `pinned_rows[:top]`; all its children will automatically be pinned with it. If a child id is passed without the parent being pinned, nothing will be pinned.
6
+ - `pinned_rows` takes a hash with a `top` and/or `bottom` key containing an array of row ids, as shown in the code snippet below.
7
+ - For expandable rows, use the parent id in `pinned_rows[:top]` or `pinned_rows[:bottom]`; all its children will automatically be pinned with it. If a child id is passed without the parent being pinned, nothing will be pinned.
@@ -9,7 +9,9 @@ examples:
9
9
  - advanced_table_table_props: Table Props
10
10
  - advanced_table_sticky_header_rails: Sticky Header
11
11
  - advanced_table_table_props_sticky_header: Sticky Header for Responsive Table
12
- - advanced_table_pinned_rows_rails: Pinned Rows
12
+ - advanced_table_pinned_rows_rails: Pinned Rows (Top)
13
+ - advanced_table_pinned_rows_bottom_rails: Pinned Rows (Bottom)
14
+ - advanced_table_pinned_rows_both_rails: Pinned Rows (Both)
13
15
  - advanced_table_beta_sort: Enable Sorting
14
16
  - advanced_table_responsive: Responsive Tables
15
17
  - advanced_table_custom_cell_rails: Custom Components for Cells
@@ -28,6 +30,7 @@ examples:
28
30
  - advanced_table_row_styling: Row Styling
29
31
  - advanced_table_padding_control_per_row_rails: Padding Control using Row Styling
30
32
  - advanced_table_column_styling_rails: Column Styling
33
+ - advanced_table_column_styling_width_rails: Column Styling Width
31
34
  - advanced_table_column_styling_column_headers_rails: Column Styling with Multiple Headers
32
35
  - advanced_table_padding_control_rails: Padding Control using Column Styling
33
36
  - advanced_table_background_control_rails: Column Styling Background Color
@@ -356,23 +356,40 @@ export default class PbAdvancedTable extends PbEnhancedElement {
356
356
  }
357
357
 
358
358
  /**
359
- * Recompute sticky top for visible pinned rows so collapsed rows don't leave a gap.
359
+ * Recompute sticky top/bottom for visible pinned rows so collapsed rows don't leave a gap.
360
360
  * Call after expand/collapse and on load.
361
361
  */
362
362
  static updatePinnedRowsStickyTops(advancedTableWrapper) {
363
- const pinnedTbody = advancedTableWrapper?.querySelector("tbody.pinned-rows-tbody");
364
- if (!pinnedTbody) return;
363
+ const headerOffset =
364
+ "calc(var(--advanced-table-header-height, 44px) + var(--advanced-table-action-bar-height, 0px))";
365
+
366
+ const pinnedTopTbody = advancedTableWrapper?.querySelector("tbody.pinned-rows-tbody");
367
+ if (pinnedTopTbody) {
368
+ const pinnedRows = Array.from(pinnedTopTbody.querySelectorAll("tr.pinned-row"));
369
+ const visibleRows = pinnedRows.filter(
370
+ (tr) => tr.style.display !== "none" && tr.offsetParent !== null
371
+ );
372
+
373
+ visibleRows.forEach((tr, index) => {
374
+ tr.style.top = `calc(${headerOffset} + 2.5em * ${index})`;
375
+ tr.style.bottom = "";
376
+ });
377
+ }
365
378
 
366
- const pinnedRows = Array.from(pinnedTbody.querySelectorAll("tr.pinned-row"));
367
- const visibleRows = pinnedRows.filter(
368
- (tr) => tr.style.display !== "none" && tr.offsetParent !== null
379
+ const pinnedBottomTbody = advancedTableWrapper?.querySelector(
380
+ "tbody.pinned-rows-tbody-bottom"
369
381
  );
382
+ if (pinnedBottomTbody) {
383
+ const pinnedRows = Array.from(pinnedBottomTbody.querySelectorAll("tr.pinned-row"));
384
+ const visibleRows = pinnedRows.filter(
385
+ (tr) => tr.style.display !== "none" && tr.offsetParent !== null
386
+ );
370
387
 
371
- const headerOffset =
372
- "calc(var(--advanced-table-header-height, 44px) + var(--advanced-table-action-bar-height, 0px))";
373
- visibleRows.forEach((tr, index) => {
374
- tr.style.top = `calc(${headerOffset} + 2.5em * ${index})`;
375
- });
388
+ visibleRows.forEach((tr, index) => {
389
+ tr.style.bottom = `calc(2.5em * ${visibleRows.length - 1 - index})`;
390
+ tr.style.top = "";
391
+ });
392
+ }
376
393
  }
377
394
 
378
395
  hideCloseIcon() {
@@ -1,10 +1,12 @@
1
1
  <% table_data = object.table_data || [] %>
2
2
  <% if object.has_pinned_rows? %>
3
- <%= pb_content_tag(:tbody, class: "pinned-rows-tbody") do %>
4
- <% next_index = 0 %>
5
- <% object.pinned_root_rows.each do |root_info| %>
6
- <% row_output, next_index = object.render_row_and_children(root_info[:row], object.column_definitions, root_info[:depth], root_info[:depth] > 0, root_info[:ancestor_ids] || [], root_info[:ancestor_ids]&.first, immediate_parent_row_id: object.row_id_for(root_info[:parent_row]), is_pinned_row: true, pinned_index: next_index, initial_table_data_attributes: root_info[:depth].to_i > 0 ? object.pinned_root_initial_data_attributes(root_info) : nil) %>
7
- <%= row_output %>
3
+ <% if object.has_pinned_top_rows? %>
4
+ <%= pb_content_tag(:tbody, class: "pinned-rows-tbody") do %>
5
+ <% next_index = 0 %>
6
+ <% object.pinned_top_root_rows.each do |root_info| %>
7
+ <% row_output, next_index = object.render_row_and_children(root_info[:row], object.column_definitions, root_info[:depth], root_info[:depth] > 0, root_info[:ancestor_ids] || [], root_info[:ancestor_ids]&.first, immediate_parent_row_id: object.row_id_for(root_info[:parent_row]), is_pinned_row: true, pinned_index: next_index, pinned_position: "top", initial_table_data_attributes: root_info[:depth].to_i > 0 ? object.pinned_root_initial_data_attributes(root_info) : nil) %>
8
+ <%= row_output %>
9
+ <% end %>
8
10
  <% end %>
9
11
  <% end %>
10
12
  <%= pb_content_tag(:tbody) do %>
@@ -13,6 +15,16 @@
13
15
  <%= result.is_a?(Array) ? result[0] : result %>
14
16
  <% end %>
15
17
  <% end %>
18
+ <% if object.has_pinned_bottom_rows? %>
19
+ <%= pb_content_tag(:tbody, class: "pinned-rows-tbody-bottom") do %>
20
+ <% next_index = 0 %>
21
+ <% bottom_total = object.pinned_bottom_row_count %>
22
+ <% object.pinned_bottom_root_rows.each do |root_info| %>
23
+ <% row_output, next_index = object.render_row_and_children(root_info[:row], object.column_definitions, root_info[:depth], root_info[:depth] > 0, root_info[:ancestor_ids] || [], root_info[:ancestor_ids]&.first, immediate_parent_row_id: object.row_id_for(root_info[:parent_row]), is_pinned_row: true, pinned_index: next_index, pinned_position: "bottom", pinned_bottom_total: bottom_total, initial_table_data_attributes: root_info[:depth].to_i > 0 ? object.pinned_root_initial_data_attributes(root_info) : nil) %>
24
+ <%= row_output %>
25
+ <% end %>
26
+ <% end %>
27
+ <% end %>
16
28
  <% else %>
17
29
  <%= pb_content_tag(:tbody) do %>
18
30
  <% table_data.each do |row| %>