playbook_ui 14.19.0.pre.alpha.PLAY1973formpillinternalsizing7728 → 14.19.0.pre.alpha.PLAY2033atactionbarrails7751

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 (26) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +16 -8
  3. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +9 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.html.erb +138 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.md +3 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.html.erb +40 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.md +1 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/index.js +355 -52
  10. data/app/pb_kits/playbook/pb_advanced_table/table_action_bar.html.erb +23 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/table_action_bar.rb +19 -0
  12. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +11 -0
  13. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.md +1 -1
  14. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.html.erb +33 -2
  15. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.md +3 -1
  16. data/app/pb_kits/playbook/pb_dropdown/index.js +14 -1
  17. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +1 -1
  18. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +12 -19
  19. data/dist/chunks/_weekday_stacked-DAixNLfd.js +45 -0
  20. data/dist/chunks/vendor.js +1 -1
  21. data/dist/playbook-doc.js +1 -1
  22. data/dist/playbook-rails.js +1 -1
  23. data/dist/playbook.css +1 -1
  24. data/lib/playbook/version.rb +1 -1
  25. metadata +9 -3
  26. data/dist/chunks/_weekday_stacked-PfWrqC3z.js +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb03eeb6d4f6845e9a28ad2d458559cb1f0efc49c982e66a49e9c94dde91a5d3
4
- data.tar.gz: 5c8d3da2bcce5b6ee616e1ce946ed8c2cb38357c18d99fdb373a9f1d2dd84d1f
3
+ metadata.gz: 17e10404283155ad2d2767e2acdf52c0bfae50af100e565e31adf7f403b3ac9a
4
+ data.tar.gz: fb8e75bd6a39e92574e9755db531c9bc09fa1c79d3a33537458535c57613b329
5
5
  SHA512:
6
- metadata.gz: 9d9c9d3367dc7b29172ae603ede775506ce76e2285547e769be6348e4e59185ba316e78ffccc1377a5baf79a73b1c4212596098498683c370a9405aaa89afffc
7
- data.tar.gz: 70a2d58d2832f1a98f0652b980b9b3bc396eada7fd1cee732e848096c17db18cae3637bf6f218c927c839c543cad4c8a13b9f6aa63febd0669ab8543c19becc8
6
+ metadata.gz: e1779f126d2b890116939dcb70297381a7a470f1c2fdc6e5efbc628d196ac4316c25d7ea1da587fe6b70f12ddb5d075b026622f812bf96e98079a49356d3d6be
7
+ data.tar.gz: bb1ef7cb05876677bc259b0efb1801415d2c0d288550142e1e59af0a81a1b12bc5e49e2b0646e891a4b2224221780a37b288a8fbc34a90d2117648b893320dec
@@ -1,10 +1,18 @@
1
1
  <%= pb_content_tag do %>
2
- <%= pb_rails("table", props: { size: "sm", data_table: true, number_spacing:"tabular", responsive:"none", dark: dark, classname: object.loading ? "content-loading" : "" }.merge(object.table_props)) do %>
3
- <% if content.present? %>
4
- <% content.presence %>
5
- <% else %>
6
- <%= pb_rails("advanced_table/table_header", props: { column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows }) %>
7
- <%= pb_rails("advanced_table/table_body", props: { id: object.id, table_data: object.table_data, column_definitions: object.column_definitions, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, enable_toggle_expansion: object.enable_toggle_expansion }) %>
8
- <% end %>
9
- <% end %>
2
+ <% if object.selectable_rows && object.show_actions_bar %>
3
+ <%= pb_rails("advanced_table/table_action_bar", props: {
4
+ actions: object.actions,
5
+ is_visible: false,
6
+ selected_count: 0
7
+ }) %>
8
+ <% end %>
9
+
10
+ <%= pb_rails("table", props: { size: "sm", data_table: true, number_spacing:"tabular", responsive:"none", dark: dark, classname: object.loading ? "content-loading" : "" }.merge(object.table_props)) do %>
11
+ <% if content.present? %>
12
+ <% content.presence %>
13
+ <% else %>
14
+ <%= pb_rails("advanced_table/table_header", props: { column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows }) %>
15
+ <%= pb_rails("advanced_table/table_body", props: { id: object.id, table_data: object.table_data, column_definitions: object.column_definitions, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, enable_toggle_expansion: object.enable_toggle_expansion }) %>
16
+ <% end %>
17
+ <% end %>
10
18
  <% end %>
@@ -25,6 +25,10 @@ module Playbook
25
25
  default: "auto"
26
26
  prop :selectable_rows, type: Playbook::Props::Boolean,
27
27
  default: false
28
+ prop :show_actions_bar, type: Playbook::Props::Boolean,
29
+ default: true
30
+ prop :actions, type: Playbook::Props::Array,
31
+ default: []
28
32
 
29
33
  def classname
30
34
  additional_classes = [responsive_classname, max_height_classname]
@@ -47,6 +51,11 @@ module Playbook
47
51
  def selected_rows_length
48
52
  selected_rows.length
49
53
  end
54
+
55
+ def is_action_bar_visible
56
+ # Action bar visibility is controlled by JS based on selection
57
+ false
58
+ end
50
59
  end
51
60
  end
52
61
  end
@@ -0,0 +1,138 @@
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
+ actions = [
34
+ pb_rails("circle_icon_button", props: {
35
+ icon: "file-csv",
36
+ variant: "link",
37
+ id: "export-selected-rows-btn",
38
+ data: {
39
+ action_type: "export"
40
+ }
41
+ }),
42
+ pb_rails("circle_icon_button", props: {
43
+ icon: "trash-alt",
44
+ variant: "link",
45
+ id: "delete-selected-rows-btn",
46
+ data: {
47
+ action_type: "delete"
48
+ }
49
+ })
50
+ ]
51
+ %>
52
+
53
+ <%= pb_rails("advanced_table", props: {
54
+ id: "selectable_rows_with_actions",
55
+ table_data: @table_data_no_subrows,
56
+ column_definitions: column_definitions,
57
+ selectable_rows: true,
58
+ enable_toggle_expansion: "none",
59
+ actions: actions,
60
+ show_actions_bar: true
61
+ }) %>
62
+
63
+ <script>
64
+ // Handle action clicks using the data-selected-rows attribute
65
+ window.handleActionClick = function(actionType) {
66
+ const tableContainer = document.getElementById('selectable_rows_with_actions');
67
+ if (!tableContainer) return;
68
+
69
+ // Get selected rows from the data attribute
70
+ const selectedRowsJSON = tableContainer.getAttribute('data-selected-rows');
71
+ let selectedRowIds = [];
72
+
73
+ try {
74
+ // Parse the JSON string from the data attribute
75
+ if (selectedRowsJSON) {
76
+ selectedRowIds = JSON.parse(selectedRowsJSON);
77
+ }
78
+ } catch (e) {
79
+ // Fallback if JSON parsing fails
80
+ const checkboxes = tableContainer.querySelectorAll('input[type="checkbox"]:checked');
81
+ const selectedCheckboxes = Array.from(checkboxes).filter(checkbox =>
82
+ checkbox.id !== 'select-all-rows' &&
83
+ !checkbox.closest('#select-all-rows')
84
+ );
85
+ selectedRowIds = selectedCheckboxes.map(checkbox => checkbox.id);
86
+ }
87
+
88
+ // Show appropriate message
89
+ if (!selectedRowIds || selectedRowIds.length === 0) {
90
+ alert('No Selection Made');
91
+ } else {
92
+ if (actionType === 'export') {
93
+ alert(`Row ids ${selectedRowIds.join(', ')} will be exported!`);
94
+ } else if (actionType === 'delete') {
95
+ alert(`Row ids ${selectedRowIds.join(', ')} will be deleted!`);
96
+ }
97
+ }
98
+ };
99
+
100
+ // Add event listeners when the DOM is ready
101
+ document.addEventListener('DOMContentLoaded', function() {
102
+ // Get the buttons
103
+ const exportBtn = document.getElementById('export-selected-rows-btn');
104
+ const deleteBtn = document.getElementById('delete-selected-rows-btn');
105
+
106
+ // Add click event listeners
107
+ if (exportBtn) {
108
+ exportBtn.addEventListener('click', function(e) {
109
+ e.preventDefault();
110
+ window.handleActionClick('export');
111
+ });
112
+ }
113
+
114
+ if (deleteBtn) {
115
+ deleteBtn.addEventListener('click', function(e) {
116
+ e.preventDefault();
117
+ window.handleActionClick('delete');
118
+ });
119
+ }
120
+
121
+ // Optional: Event delegation through the action bar
122
+ const actionBar = document.querySelector('.row-selection-actions-card');
123
+ if (actionBar) {
124
+ actionBar.addEventListener('click', function(e) {
125
+ const exportButton = e.target.closest('#export-selected-rows-btn');
126
+ const deleteButton = e.target.closest('#delete-selected-rows-btn');
127
+
128
+ if (exportButton) {
129
+ e.preventDefault();
130
+ window.handleActionClick('export');
131
+ } else if (deleteButton) {
132
+ e.preventDefault();
133
+ window.handleActionClick('delete');
134
+ }
135
+ });
136
+ }
137
+ });
138
+ </script>
@@ -0,0 +1,3 @@
1
+ Custom actions content can be rendered within the Actions Bar as shown in this doc example. The component passed to `actions` will be rendered on the right of the actionsBar.
2
+
3
+ You can utilize script tags with your actions to provide your buttons with any clickable events needed.
@@ -0,0 +1,40 @@
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: {
34
+ id: "selectable_rows_with_actions",
35
+ table_data: @table_data_no_subrows,
36
+ column_definitions: column_definitions,
37
+ selectable_rows: true,
38
+ enable_toggle_expansion: "none",
39
+ show_actions_bar: false
40
+ }) %>
@@ -0,0 +1 @@
1
+ `show_actions_bar` is an optional prop that renders the header at the top showing the row count. This is set to `true` by default but can be toggled off by setting it to `false`
@@ -15,6 +15,8 @@ examples:
15
15
  - advanced_table_column_border_color_rails: Column Group Border Color
16
16
  - advanced_table_selectable_rows_rails: Selectable Rows
17
17
  - advanced_table_selectable_rows_no_subrows_rails: Selectable Rows (No Subrows)
18
+ - advanced_table_selectable_rows_actions_rails: Selectable Rows (With Actions)
19
+ - advanced_table_selectable_rows_header_rails: Selectable Rows (No Actions Bar)
18
20
 
19
21
  react:
20
22
  - advanced_table_default: Default (Required Props)