playbook_ui 14.11.1.pre.alpha.PLAY1751pbcontenttagpt25529 → 14.11.1.pre.alpha.pbntr703collapsiblerowsrails5536

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_collapsible/collapsible.html.erb +3 -1
  3. data/app/pb_kits/playbook/pb_collapsible/collapsible.rb +3 -0
  4. data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +6 -1
  5. data/app/pb_kits/playbook/pb_filter/filter.html.erb +5 -1
  6. data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +6 -1
  7. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
  8. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible.html.erb +47 -0
  9. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_rails.md +2 -0
  10. data/app/pb_kits/playbook/pb_table/docs/example.yml +1 -0
  11. data/app/pb_kits/playbook/pb_table/index.ts +177 -137
  12. data/app/pb_kits/playbook/pb_table/styles/_collapsible.scss +12 -0
  13. data/app/pb_kits/playbook/pb_table/table_row.html.erb +20 -1
  14. data/app/pb_kits/playbook/pb_table/table_row.rb +5 -0
  15. data/dist/chunks/{_typeahead-TN5aDUj9.js → _typeahead-DjGX1O4K.js} +1 -1
  16. data/dist/chunks/{_weekday_stacked-BcnpLG66.js → _weekday_stacked-s8bX_aFg.js} +1 -1
  17. data/dist/chunks/{lib-OFT985dg.js → lib-kMuhBuU7.js} +1 -1
  18. data/dist/chunks/{pb_form_validation-CrsXd1-Y.js → pb_form_validation-DBJ0wZuS.js} +1 -1
  19. data/dist/chunks/vendor.js +1 -1
  20. data/dist/playbook-doc.js +1 -1
  21. data/dist/playbook-rails-react-bindings.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 +8 -6
  26. /data/app/pb_kits/playbook/pb_table/docs/{_table_with_collapsible.md → _table_with_collapsible_react.md} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e7aeb4eded2d7207beaad9aaac806a7287567e5fa319c711e37c0b6e7fb5a06
4
- data.tar.gz: af7059a43605656c61fea4ee409ae64a7adf807fb655aafdc760027c45b0afcf
3
+ metadata.gz: 6a968d08aaa4af48a9fac9eb0fc5191c8d738b7fd5a6514064cc864a25a1e283
4
+ data.tar.gz: af0da5b80ce2adb3d94a96caf5d5ed489d35a01f5b15e00a50eb6691ab9f95ff
5
5
  SHA512:
6
- metadata.gz: 855ee14b770f338f48795930c8aa870974b3a524b6a2d87cafd20b8d397cc08343acc0005ff6a7e49cfa0b287dc6153154e7ef361ea01e26f050a7ee47eadf5b
7
- data.tar.gz: 7cf27552a3d85aa92fb440ee752fe8cf5b2b7cd153ee4ca558209ecb6821075e461f41e852ab1714ddbbf87d27c610c3da9d0b9765c666e03d4d0b1830764b96
6
+ metadata.gz: 42767c7d834ab7d1da43a081d310276dd141f23a53a9ad1a6cb48c52f57f713e802d2e490e6956ecfe6f835b10fe3bf54d953d406fd1054c05e40d55fec12b24
7
+ data.tar.gz: c37bd39bfbbfcafa7905258522be6c18c9d96734530a99ae7467c6a2bc427f1cca041b3efdfee89352fc99cc0d51b9fe8e6d7b96da65ec5872bbe3f3feab3bbc
@@ -1,3 +1,5 @@
1
- <%= pb_content_tag do %>
1
+ <%= pb_content_tag(
2
+ object.tag
3
+ ) do %>
2
4
  <%= content.presence %>
3
5
  <% end %>
@@ -3,6 +3,9 @@
3
3
  module Playbook
4
4
  module PbCollapsible
5
5
  class Collapsible < Playbook::KitBase
6
+ prop :tag, type: Playbook::Props::Enum,
7
+ values: %w[h1 h2 h3 h4 h5 h6 p div span tr th td thead col],
8
+ default: "div"
6
9
  def classname
7
10
  generate_classname("pb_collapsible_kit")
8
11
  end
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag(:div) do %>
1
+ <%= content_tag("div",
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id,
6
+ **combined_html_options) do %>
2
7
  <%= pb_rails("form_group", props: {cursor: "pointer", full_width: object.full_width}) do %>
3
8
  <label
4
9
  for="upload-<%= object.id %>"
@@ -1,4 +1,8 @@
1
- <%= pb_content_tag(:div) do %>
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= object.wrapper do %>
3
7
  <%= pb_rails("flex", props: { orientation: "row", padding_right: "lg", vertical: "center" }) do %>
4
8
  <% if (object.template != "sort_only") %>
@@ -1,3 +1,8 @@
1
- <%= pb_content_tag(:div) do %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id,
6
+ **combined_html_options) do %>
2
7
  <%= content.presence %>
3
8
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= pb_content_tag(:div, class: object.classname + object.size_class, tabindex: object.tabindex) do %>
1
+ <%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, tabindex: object.tabindex, **combined_html_options) do %>
2
2
  <% if object.name.present? %>
3
3
  <%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "xxs" }) %>
4
4
  <% if object.truncate %>
@@ -0,0 +1,47 @@
1
+ <% content = capture do %>
2
+ <%= pb_rails("card", props: { border_none: true, border_radius: "none", padding: "md" }) do %>
3
+ <%= pb_rails("body", props: { text: "Nested content inside a Table Row" }) %>
4
+ <% end %>
5
+ <% end %>
6
+
7
+ <%= pb_rails("table", props: { size: "sm" }) do %>
8
+ <%= pb_rails("table/table_head") do %>
9
+ <%= pb_rails("table/table_row") do %>
10
+ <%= pb_rails("table/table_header", props: { text: "Column 1"}) %>
11
+ <%= pb_rails("table/table_header", props: { text: "Column 2"}) %>
12
+ <%= pb_rails("table/table_header", props: { text: "Column 3"}) %>
13
+ <%= pb_rails("table/table_header", props: { text: "Column 4"}) %>
14
+ <%= pb_rails("table/table_header", props: { text: "Column 5"}) %>
15
+ <%= pb_rails("table/table_header", props: { text: ""}) %>
16
+ <% end %>
17
+ <% end %>
18
+ <%= pb_rails("table/table_body") do %>
19
+ <%= pb_rails("table/table_row", props: { collapsible: true, collapsible_content: content, collapsible_side_highlight: true, id: "1" }) do %>
20
+ <%= pb_rails("table/table_cell", props: { text: "Value 1"}) %>
21
+ <%= pb_rails("table/table_cell", props: { text: "Value 2"}) %>
22
+ <%= pb_rails("table/table_cell", props: { text: "Value 3"}) %>
23
+ <%= pb_rails("table/table_cell", props: { text: "Value 4"}) %>
24
+ <%= pb_rails("table/table_cell", props: { text: "Value 5"}) %>
25
+ <%= pb_rails("table/table_cell", props: { text_align: "right"}) do %>
26
+ <%= pb_rails("icon", props: { icon: "chevron-down", fixed_width: true, color: "primary" }) %>
27
+ <% end %>
28
+ <% end %>
29
+ <%= pb_rails("table/table_row") do %>
30
+ <%= pb_rails("table/table_cell", props: { text: "Value 1"}) %>
31
+ <%= pb_rails("table/table_cell", props: { text: "Value 2"}) %>
32
+ <%= pb_rails("table/table_cell", props: { text: "Value 3"}) %>
33
+ <%= pb_rails("table/table_cell", props: { text: "Value 4"}) %>
34
+ <%= pb_rails("table/table_cell", props: { text: "Value 5"}) %>
35
+ <%= pb_rails("table/table_cell", props: { text: ""}) %>
36
+ <% end %>
37
+ <%= pb_rails("table/table_row") do %>
38
+ <%= pb_rails("table/table_cell", props: { text: "Value 1"}) %>
39
+ <%= pb_rails("table/table_cell", props: { text: "Value 2"}) %>
40
+ <%= pb_rails("table/table_cell", props: { text: "Value 3"}) %>
41
+ <%= pb_rails("table/table_cell", props: { text: "Value 4"}) %>
42
+ <%= pb_rails("table/table_cell", props: { text: "Value 5"}) %>
43
+ <%= pb_rails("table/table_cell", props: { text: ""}) %>
44
+ <% end %>
45
+ <% end %>
46
+ <% end %>
47
+
@@ -0,0 +1,2 @@
1
+ The `collapsible` prop can be used on any Table Row to add a collapsible area. Use the additional `collapsible_content` prop to add any content to the collapsible Row.
2
+ Please be aware that you will need to pass in an `id` to any table rows you want to be collapsible. Make sure every `id` is unique if you are using multipe collapsibles.
@@ -30,6 +30,7 @@ examples:
30
30
  - table_with_subcomponents_rails: Table with Sub Components (Table Elements)
31
31
  - table_with_subcomponents_as_divs: Table with Sub Components (Divs)
32
32
  - table_outer_padding: Outer Padding
33
+ - table_with_collapsible: Table with Collapsible
33
34
 
34
35
  react:
35
36
  - table_sm: Small
@@ -1,167 +1,207 @@
1
1
  import PbEnhancedElement from '../pb_enhanced_element'
2
2
 
3
3
  const TABLE_WRAPPER_SELECTOR = "[data-pb-table-wrapper]";
4
+ const TABLE_COLLAPSIBLE_WRAPPER_SELECTOR = "[data-pb-table-collapsible-wrapper]";
4
5
 
5
6
  export default class PbTable extends PbEnhancedElement {
6
- stickyLeftColumns: string[] = [];
7
- stickyRightColumns: string[] = [];
8
- stickyRightColumnsReversed: string[] = [];
9
-
10
- static get selector(): string {
11
- return TABLE_WRAPPER_SELECTOR;
12
- }
13
-
14
- connect() {
15
- if (this.element.classList.contains('table-responsive-collapse')) {
16
- const headers: string[] = [];
7
+ stickyLeftColumns: string[] = [];
8
+ stickyRightColumns: string[] = [];
9
+ stickyRightColumnsReversed: string[] = [];
10
+
11
+ static get selector(): string {
12
+ return TABLE_WRAPPER_SELECTOR;
13
+ }
14
+
15
+ connect() {
16
+ if (this.element.classList.contains('table-responsive-collapse')) {
17
+ const headers: string[] = [];
18
+
19
+ [].forEach.call(this.element.querySelectorAll('th'), (header: HTMLTableCellElement) => {
20
+ const colSpan = header.colSpan
21
+ for (let i = 0; i < colSpan; i++) {
22
+ headers.push(header.textContent.replace(/\r?\n|\r/, ''));
23
+ }
24
+ });
17
25
 
18
- [].forEach.call(this.element.querySelectorAll('th'), (header: HTMLTableCellElement) => {
19
- const colSpan = header.colSpan
20
- for (let i = 0; i < colSpan; i++) {
21
- headers.push(header.textContent.replace(/\r?\n|\r/, ''));
22
- }
23
- });
24
-
25
- [].forEach.call(this.element.querySelectorAll('tbody tr'), (row: HTMLTableRowElement) => {
26
- [].forEach.call(row.cells, (cell: HTMLTableCellElement, headerIndex: number) => {
27
- cell.setAttribute('data-title', headers[headerIndex])
28
- })
26
+ [].forEach.call(this.element.querySelectorAll('tbody tr'), (row: HTMLTableRowElement) => {
27
+ [].forEach.call(row.cells, (cell: HTMLTableCellElement, headerIndex: number) => {
28
+ cell.setAttribute('data-title', headers[headerIndex])
29
29
  })
30
- }
31
-
32
- this.initStickyLeftColumns();
33
- this.initStickyRightColumns();
30
+ })
34
31
  }
35
32
 
36
- initStickyLeftColumns() {
37
- const table = this.element.querySelector('.sticky-left-column');
38
-
39
- if (table) {
40
- const classList = Array.from(table.classList);
41
- const stickyColumnClass = classList.find(cls => cls.startsWith('sticky-left-columns-ids-'));
42
-
43
- if (stickyColumnClass) {
44
- this.stickyLeftColumns = stickyColumnClass
45
- .replace('sticky-left-columns-ids-', '')
46
- .split('-');
47
-
48
- if (this.stickyLeftColumns.length > 0) {
49
- setTimeout(() => {
50
- this.handleStickyLeftColumns();
51
- window.addEventListener('resize', () => this.handleStickyLeftColumns());
52
- }, 10);
53
- }
33
+ this.initStickyLeftColumns();
34
+ this.initStickyRightColumns();
35
+ this.handleCollapsibleClick();
36
+ this.handleCollapsibleRow();
37
+ }
38
+
39
+ initStickyLeftColumns() {
40
+ const table = this.element.querySelector('.sticky-left-column');
41
+
42
+ if (table) {
43
+ const classList = Array.from(table.classList);
44
+ const stickyColumnClass = classList.find(cls => cls.startsWith('sticky-left-columns-ids-'));
45
+
46
+ if (stickyColumnClass) {
47
+ this.stickyLeftColumns = stickyColumnClass
48
+ .replace('sticky-left-columns-ids-', '')
49
+ .split('-');
50
+
51
+ if (this.stickyLeftColumns.length > 0) {
52
+ setTimeout(() => {
53
+ this.handleStickyLeftColumns();
54
+ window.addEventListener('resize', () => this.handleStickyLeftColumns());
55
+ }, 10);
54
56
  }
55
57
  }
56
58
  }
59
+ }
60
+
61
+ handleStickyLeftColumns() {
62
+ let accumulatedWidth = 0;
63
+
64
+ this.stickyLeftColumns.forEach((colId, index) => {
65
+ const isLastColumn = index === this.stickyLeftColumns.length - 1;
66
+ const header = this.element.querySelector(`th[id="${colId}"]`);
67
+ const cells = this.element.querySelectorAll(`td[id="${colId}"]`);
68
+
69
+ if (header) {
70
+ header.classList.add('sticky');
71
+ (header as HTMLElement).style.left = `${accumulatedWidth}px`;
72
+
73
+ if (!isLastColumn) {
74
+ header.classList.add('with-border-right');
75
+ header.classList.remove('sticky-left-shadow');
76
+ } else {
77
+ header.classList.remove('with-border-right');
78
+ header.classList.add('sticky-left-shadow');
79
+ }
57
80
 
58
- handleStickyLeftColumns() {
59
- let accumulatedWidth = 0;
60
-
61
- this.stickyLeftColumns.forEach((colId, index) => {
62
- const isLastColumn = index === this.stickyLeftColumns.length - 1;
63
- const header = this.element.querySelector(`th[id="${colId}"]`);
64
- const cells = this.element.querySelectorAll(`td[id="${colId}"]`);
65
-
66
- if (header) {
67
- header.classList.add('sticky');
68
- (header as HTMLElement).style.left = `${accumulatedWidth}px`;
81
+ accumulatedWidth += (header as HTMLElement).offsetWidth;
82
+ }
69
83
 
70
- if (!isLastColumn) {
71
- header.classList.add('with-border-right');
72
- header.classList.remove('sticky-left-shadow');
73
- } else {
74
- header.classList.remove('with-border-right');
75
- header.classList.add('sticky-left-shadow');
76
- }
84
+ cells.forEach((cell) => {
85
+ cell.classList.add('sticky');
86
+ (cell as HTMLElement).style.left = `${accumulatedWidth - (header as HTMLElement).offsetWidth}px`;
77
87
 
78
- accumulatedWidth += (header as HTMLElement).offsetWidth;
88
+ if (!isLastColumn) {
89
+ cell.classList.add('with-border-right');
90
+ cell.classList.remove('sticky-left-shadow');
91
+ } else {
92
+ cell.classList.remove('with-border-right');
93
+ cell.classList.add('sticky-left-shadow');
79
94
  }
80
-
81
- cells.forEach((cell) => {
82
- cell.classList.add('sticky');
83
- (cell as HTMLElement).style.left = `${accumulatedWidth - (header as HTMLElement).offsetWidth}px`;
84
-
85
- if (!isLastColumn) {
86
- cell.classList.add('with-border-right');
87
- cell.classList.remove('sticky-left-shadow');
88
- } else {
89
- cell.classList.remove('with-border-right');
90
- cell.classList.add('sticky-left-shadow');
91
- }
92
- });
93
95
  });
94
- }
95
-
96
- initStickyRightColumns() {
97
- const table = this.element.querySelector('.sticky-right-column');
98
-
99
- if (table) {
100
- const classList = Array.from(table.classList);
101
- const stickyColumnClass = classList.find(cls => cls.startsWith('sticky-right-columns-ids-'));
102
-
103
- if (stickyColumnClass) {
104
- this.stickyRightColumns = stickyColumnClass
105
- .replace('sticky-right-columns-ids-', '')
106
- .split('-');
107
- this.stickyRightColumnsReversed = this.stickyRightColumns.reverse();
108
-
109
- if (this.stickyRightColumns.length > 0) {
110
- setTimeout(() => {
111
- this.handleStickyRightColumns();
112
- window.addEventListener('resize', () => this.handleStickyRightColumns());
113
- }, 10);
114
- }
96
+ });
97
+ }
98
+
99
+ initStickyRightColumns() {
100
+ const table = this.element.querySelector('.sticky-right-column');
101
+
102
+ if (table) {
103
+ const classList = Array.from(table.classList);
104
+ const stickyColumnClass = classList.find(cls => cls.startsWith('sticky-right-columns-ids-'));
105
+
106
+ if (stickyColumnClass) {
107
+ this.stickyRightColumns = stickyColumnClass
108
+ .replace('sticky-right-columns-ids-', '')
109
+ .split('-');
110
+ this.stickyRightColumnsReversed = this.stickyRightColumns.reverse();
111
+
112
+ if (this.stickyRightColumns.length > 0) {
113
+ setTimeout(() => {
114
+ this.handleStickyRightColumns();
115
+ window.addEventListener('resize', () => this.handleStickyRightColumns());
116
+ }, 10);
115
117
  }
116
118
  }
117
119
  }
120
+ }
121
+
122
+ handleStickyRightColumns() {
123
+ let accumulatedWidth = 0;
124
+
125
+ this.stickyRightColumnsReversed.forEach((colId, index) => {
126
+ const isLastColumn = index === this.stickyRightColumns.length - 1;
127
+ const header = this.element.querySelector(`th[id="${colId}"]`);
128
+ const cells = this.element.querySelectorAll(`td[id="${colId}"]`);
129
+
130
+ if (header) {
131
+ header.classList.add('sticky');
132
+ (header as HTMLElement).style.right = `${accumulatedWidth}px`;
133
+
134
+ if (!isLastColumn) {
135
+ header.classList.add('with-border-left');
136
+ header.classList.remove('sticky-right-shadow');
137
+ } else {
138
+ header.classList.remove('with-border-right');
139
+ header.classList.add('sticky-right-shadow');
140
+ }
118
141
 
119
- handleStickyRightColumns() {
120
- let accumulatedWidth = 0;
121
-
122
- this.stickyRightColumnsReversed.forEach((colId, index) => {
123
- const isLastColumn = index === this.stickyRightColumns.length - 1;
124
- const header = this.element.querySelector(`th[id="${colId}"]`);
125
- const cells = this.element.querySelectorAll(`td[id="${colId}"]`);
126
-
127
- if (header) {
128
- header.classList.add('sticky');
129
- (header as HTMLElement).style.right = `${accumulatedWidth}px`;
142
+ accumulatedWidth += (header as HTMLElement).offsetWidth;
143
+ }
130
144
 
131
- if (!isLastColumn) {
132
- header.classList.add('with-border-left');
133
- header.classList.remove('sticky-right-shadow');
134
- } else {
135
- header.classList.remove('with-border-right');
136
- header.classList.add('sticky-right-shadow');
137
- }
145
+ cells.forEach((cell) => {
146
+ cell.classList.add('sticky');
147
+ (cell as HTMLElement).style.right = `${accumulatedWidth - (header as HTMLElement).offsetWidth}px`;
138
148
 
139
- accumulatedWidth += (header as HTMLElement).offsetWidth;
149
+ if (!isLastColumn) {
150
+ cell.classList.add('with-border-left');
151
+ cell.classList.remove('sticky-right-shadow');
152
+ } else {
153
+ cell.classList.remove('with-border-left');
154
+ cell.classList.add('sticky-right-shadow');
140
155
  }
141
-
142
- cells.forEach((cell) => {
143
- cell.classList.add('sticky');
144
- (cell as HTMLElement).style.right = `${accumulatedWidth - (header as HTMLElement).offsetWidth}px`;
145
-
146
- if (!isLastColumn) {
147
- cell.classList.add('with-border-left');
148
- cell.classList.remove('sticky-right-shadow');
149
- } else {
150
- cell.classList.remove('with-border-left');
151
- cell.classList.add('sticky-right-shadow');
152
- }
156
+ });
157
+ });
158
+ }
159
+
160
+ handleCollapsibleClick() {
161
+ const collapsibleElements = this.element.querySelectorAll(TABLE_COLLAPSIBLE_WRAPPER_SELECTOR);
162
+ collapsibleElements.forEach((collapsibleElement) => {
163
+ collapsibleElement.addEventListener('click', (event) => {
164
+ document.dispatchEvent(new CustomEvent(`collapsed-toggle${(event.currentTarget as HTMLElement).id}`))
165
+
166
+ const toggleElements = this.element.querySelectorAll(`.collapsible_border_toggle${(event.currentTarget as HTMLElement).id}`);
167
+ toggleElements.forEach(element => {
168
+ element.classList.toggle('no-border');
169
+ element.classList.toggle('border-active');
153
170
  });
171
+ })
172
+ })
173
+ }
174
+
175
+ handleCollapsibleRow() {
176
+ const collapsibleRows = this.element.querySelectorAll('.pb_table_collapsible_row');
177
+ if (collapsibleRows.length > 0) {
178
+ collapsibleRows.forEach((row) => {
179
+ const previousRow = row.previousElementSibling;
180
+
181
+ if (
182
+ previousRow &&
183
+ previousRow.tagName === 'TR'
184
+ ) {
185
+ const tdCount = previousRow.querySelectorAll('td').length;
186
+ const collapsibleTd = row.querySelector('td');
187
+ if (collapsibleTd) {
188
+ collapsibleTd.colSpan = tdCount;
189
+ }
190
+ } else {
191
+ return
192
+ }
154
193
  });
155
194
  }
195
+ }
156
196
 
157
- // Cleanup method to remove event listener
158
- disconnect() {
159
- if (this.stickyLeftColumns.length > 0) {
160
- window.removeEventListener('resize', () => this.handleStickyLeftColumns());
161
- }
197
+ // Cleanup method to remove event listener
198
+ disconnect() {
199
+ if (this.stickyLeftColumns.length > 0) {
200
+ window.removeEventListener('resize', () => this.handleStickyLeftColumns());
201
+ }
162
202
 
163
- if (this.stickyRightColumns.length > 0) {
164
- window.removeEventListener('resize', () => this.handleStickyRightColumns());
165
- }
203
+ if (this.stickyRightColumns.length > 0) {
204
+ window.removeEventListener('resize', () => this.handleStickyRightColumns());
166
205
  }
167
- }
206
+ }
207
+ }
@@ -32,4 +32,16 @@
32
32
  }
33
33
  }
34
34
  }
35
+
36
+ .collapsible-tr {
37
+ cursor: pointer;
38
+ }
39
+
40
+ .no-border {
41
+ border-bottom: none !important;
42
+ }
43
+
44
+ .border-active {
45
+ border-bottom: 1px;
46
+ }
35
47
  }
@@ -1,4 +1,23 @@
1
- <% if object.tag == "table" %>
1
+ <% if object.collapsible && object.tag == "table" %>
2
+ <%= content_tag(:tr,
3
+ aria: object.aria,
4
+ class: object.classname + " collapsible-tr",
5
+ data: object.data.merge(id: object.id),
6
+ id: object.id,
7
+ 'data-pb-table-collapsible-wrapper' => true,
8
+ **combined_html_options) do %>
9
+ <%= content.presence %>
10
+ <% end %>
11
+
12
+ <tr class="pb_table_collapsible_row">
13
+ <%= pb_rails("collapsible", props: { classname: "collapsible_border_toggle#{object.id}" + " no-border", name: "default-example", tag: "td", padding: "none" }) do %>
14
+ <%= pb_rails("flex", props: { data: { "collapsible-main": "true"} }) %>
15
+ <%= pb_rails("collapsible/collapsible_content", props: { classname: object.collapsible_side_highlight ? "table_collapsible_side_highlight" : "", padding: "none", margin: "none", id: "collapsed-toggle#{object.id}" }) do %>
16
+ <%= object.collapsible_content %>
17
+ <% end %>
18
+ <% end %>
19
+ </tr>
20
+ <% elsif object.tag == "table" %>
2
21
  <%= content_tag(:tr,
3
22
  aria: object.aria,
4
23
  class: object.classname,
@@ -8,6 +8,11 @@ module Playbook
8
8
  prop :tag, type: Playbook::Props::Enum,
9
9
  values: %w[table div],
10
10
  default: "table"
11
+ prop :collapsible, type: Playbook::Props::Boolean,
12
+ default: false
13
+ prop :collapsible_content
14
+ prop :collapsible_side_highlight, type: Playbook::Props::Boolean,
15
+ default: false
11
16
 
12
17
  def classname
13
18
  generate_classname("pb_table_row_kit", side_highlight_class) + tag_class
@@ -1,4 +1,4 @@
1
- import{jsx as jsx$1,Fragment,jsxs}from"react/jsx-runtime";import*as React from"react";import React__default,{createContext,useReducer,useEffect,useMemo,useContext,useRef,createElement,useState,forwardRef,useLayoutEffect,useCallback,useImperativeHandle,Component,Fragment as Fragment$1}from"react";import{r as getDefaultExportFromCjs,x as filter,y as omit,u as useCollapsible,j as getAllIcons,z as get,q as commonjsGlobal,w as colors$1,t as highchartsTheme,A as merge,s as highchartsDarkTheme,B as getAugmentedNamespace,C as createPopper,E as uniqueId,F as typography,G as cloneDeep,H as isString}from"./lib-OFT985dg.js";import*as ReactDOM from"react-dom";import ReactDOM__default,{createPortal}from"react-dom";import{TrixEditor}from"react-trix";import Trix from"trix";import require$$0 from"react-is";const initialState={items:[],dragData:{id:"",initialGroup:""},isDragging:"",activeContainer:""};const reducer=(state,action)=>{switch(action.type){case"SET_ITEMS":return Object.assign(Object.assign({},state),{items:action.payload});case"SET_DRAG_DATA":return Object.assign(Object.assign({},state),{dragData:action.payload});case"SET_IS_DRAGGING":return Object.assign(Object.assign({},state),{isDragging:action.payload});case"SET_ACTIVE_CONTAINER":return Object.assign(Object.assign({},state),{activeContainer:action.payload});case"CHANGE_CATEGORY":return Object.assign(Object.assign({},state),{items:state.items.map((item=>item.id===action.payload.itemId?Object.assign(Object.assign({},item),{container:action.payload.container}):item))});case"REORDER_ITEMS":{const{dragId:dragId,targetId:targetId}=action.payload;const newItems=[...state.items];const draggedItem=newItems.find((item=>item.id===dragId));const draggedIndex=newItems.indexOf(draggedItem);const targetIndex=newItems.findIndex((item=>item.id===targetId));newItems.splice(draggedIndex,1);newItems.splice(targetIndex,0,draggedItem);return Object.assign(Object.assign({},state),{items:newItems})}default:return state}};const DragContext=createContext({});const DraggableContext=()=>useContext(DragContext);const DraggableProvider=({children:children,initialItems:initialItems,onReorder:onReorder,onDragStart:onDragStart,onDragEnter:onDragEnter,onDragEnd:onDragEnd,onDrop:onDrop,onDragOver:onDragOver})=>{const[state,dispatch]=useReducer(reducer,initialState);useEffect((()=>{dispatch({type:"SET_ITEMS",payload:initialItems})}),[initialItems]);useEffect((()=>{onReorder(state.items)}),[state.items]);const handleDragStart=(id,container)=>{dispatch({type:"SET_DRAG_DATA",payload:{id:id,initialGroup:container}});dispatch({type:"SET_IS_DRAGGING",payload:id});if(onDragStart)onDragStart(id,container)};const handleDragEnter=(id,container)=>{if(state.dragData.id!==id){dispatch({type:"REORDER_ITEMS",payload:{dragId:state.dragData.id,targetId:id}});dispatch({type:"SET_DRAG_DATA",payload:{id:state.dragData.id,initialGroup:container}})}if(onDragEnter)onDragEnter(id,container)};const handleDragEnd=()=>{dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});if(onDragEnd)onDragEnd()};const changeCategory=(itemId,container)=>{dispatch({type:"CHANGE_CATEGORY",payload:{itemId:itemId,container:container}})};const handleDrop=container=>{dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});changeCategory(state.dragData.id,container);if(onDrop)onDrop(container)};const handleDragOver=(e,container)=>{e.preventDefault();dispatch({type:"SET_ACTIVE_CONTAINER",payload:container});if(onDragOver)onDragOver(e,container)};const contextValue=useMemo((()=>({items:state.items,dragData:state.dragData,isDragging:state.isDragging,activeContainer:state.activeContainer,handleDragStart:handleDragStart,handleDragEnter:handleDragEnter,handleDragEnd:handleDragEnd,handleDrop:handleDrop,handleDragOver:handleDragOver})),[state]);return jsx$1(DragContext.Provider,Object.assign({value:contextValue},{children:children}),void 0)};var classnames$1={exports:{}};
1
+ import{jsx as jsx$1,Fragment,jsxs}from"react/jsx-runtime";import*as React from"react";import React__default,{createContext,useReducer,useEffect,useMemo,useContext,useRef,createElement,useState,forwardRef,useLayoutEffect,useCallback,useImperativeHandle,Component,Fragment as Fragment$1}from"react";import{r as getDefaultExportFromCjs,x as filter,y as omit,u as useCollapsible,j as getAllIcons,z as get,q as commonjsGlobal,w as colors$1,t as highchartsTheme,A as merge,s as highchartsDarkTheme,B as getAugmentedNamespace,C as createPopper,E as uniqueId,F as typography,G as cloneDeep,H as isString}from"./lib-kMuhBuU7.js";import*as ReactDOM from"react-dom";import ReactDOM__default,{createPortal}from"react-dom";import{TrixEditor}from"react-trix";import Trix from"trix";import require$$0 from"react-is";const initialState={items:[],dragData:{id:"",initialGroup:""},isDragging:"",activeContainer:""};const reducer=(state,action)=>{switch(action.type){case"SET_ITEMS":return Object.assign(Object.assign({},state),{items:action.payload});case"SET_DRAG_DATA":return Object.assign(Object.assign({},state),{dragData:action.payload});case"SET_IS_DRAGGING":return Object.assign(Object.assign({},state),{isDragging:action.payload});case"SET_ACTIVE_CONTAINER":return Object.assign(Object.assign({},state),{activeContainer:action.payload});case"CHANGE_CATEGORY":return Object.assign(Object.assign({},state),{items:state.items.map((item=>item.id===action.payload.itemId?Object.assign(Object.assign({},item),{container:action.payload.container}):item))});case"REORDER_ITEMS":{const{dragId:dragId,targetId:targetId}=action.payload;const newItems=[...state.items];const draggedItem=newItems.find((item=>item.id===dragId));const draggedIndex=newItems.indexOf(draggedItem);const targetIndex=newItems.findIndex((item=>item.id===targetId));newItems.splice(draggedIndex,1);newItems.splice(targetIndex,0,draggedItem);return Object.assign(Object.assign({},state),{items:newItems})}default:return state}};const DragContext=createContext({});const DraggableContext=()=>useContext(DragContext);const DraggableProvider=({children:children,initialItems:initialItems,onReorder:onReorder,onDragStart:onDragStart,onDragEnter:onDragEnter,onDragEnd:onDragEnd,onDrop:onDrop,onDragOver:onDragOver})=>{const[state,dispatch]=useReducer(reducer,initialState);useEffect((()=>{dispatch({type:"SET_ITEMS",payload:initialItems})}),[initialItems]);useEffect((()=>{onReorder(state.items)}),[state.items]);const handleDragStart=(id,container)=>{dispatch({type:"SET_DRAG_DATA",payload:{id:id,initialGroup:container}});dispatch({type:"SET_IS_DRAGGING",payload:id});if(onDragStart)onDragStart(id,container)};const handleDragEnter=(id,container)=>{if(state.dragData.id!==id){dispatch({type:"REORDER_ITEMS",payload:{dragId:state.dragData.id,targetId:id}});dispatch({type:"SET_DRAG_DATA",payload:{id:state.dragData.id,initialGroup:container}})}if(onDragEnter)onDragEnter(id,container)};const handleDragEnd=()=>{dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});if(onDragEnd)onDragEnd()};const changeCategory=(itemId,container)=>{dispatch({type:"CHANGE_CATEGORY",payload:{itemId:itemId,container:container}})};const handleDrop=container=>{dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});changeCategory(state.dragData.id,container);if(onDrop)onDrop(container)};const handleDragOver=(e,container)=>{e.preventDefault();dispatch({type:"SET_ACTIVE_CONTAINER",payload:container});if(onDragOver)onDragOver(e,container)};const contextValue=useMemo((()=>({items:state.items,dragData:state.dragData,isDragging:state.isDragging,activeContainer:state.activeContainer,handleDragStart:handleDragStart,handleDragEnter:handleDragEnter,handleDragEnd:handleDragEnd,handleDrop:handleDrop,handleDragOver:handleDragOver})),[state]);return jsx$1(DragContext.Provider,Object.assign({value:contextValue},{children:children}),void 0)};var classnames$1={exports:{}};
2
2
  /*!
3
3
  Copyright (c) 2018 Jed Watson.
4
4
  Licensed under the MIT License (MIT), see
@@ -1,4 +1,4 @@
1
- import{r as requireLazysizes}from"./lazysizes-B7xYodB-.js";import{jsx,Fragment,jsxs}from"react/jsx-runtime";import*as React from"react";import React__default,{useEffect,createContext,useContext,useState,useCallback,createElement,forwardRef,useRef,useImperativeHandle,useMemo,useReducer,Fragment as Fragment$1,useLayoutEffect,isValidElement}from"react";import{h as buildAriaProps,i as buildDataProps,j as buildHtmlProps,k as classnames,l as globalProps,m as buildCss,n as Collapsible,o as globalInlineProps,F as Flex,I as Icon,p as FlexItem,q as Body$1,r as Caption,A as Avatar,s as domSafeProps,t as Title,S as SectionSeparator,u as DialogContext,v as Draggable,w as TextInput,x as PropTypes,y as Card,z as noop$4,E as isEmpty,H as PbReactPopover,J as CircleIconButton,K as Button,N as HighchartsReact,O as Badge,Q as joinPresent,U as titleize,V as IconCircle,W as Image,X as Checkbox,Y as Radio}from"./_typeahead-TN5aDUj9.js";import{u as useCollapsible,j as getAllIcons,D as DateTime$1,a as datePickerHelper,k as useDropdown,o as omitBy,l as isEmpty$1,m as map,p as partial,n as find$1,q as commonjsGlobal,r as getDefaultExportFromCjs,s as highchartsDarkTheme,t as highchartsTheme,v as noop$5,w as colors,i as PbTextarea}from"./lib-OFT985dg.js";import*as ReactDOM from"react-dom";import ReactDOM__default,{createPortal}from"react-dom";var ls_attrchange={exports:{}};(function(module){(function(window2,factory){if(!window2){return}var globalInstall=function(){factory(window2.lazySizes);window2.removeEventListener("lazyunveilread",globalInstall,true)};factory=factory.bind(null,window2,window2.document);if(module.exports){factory(requireLazysizes())}else if(window2.lazySizes){globalInstall()}else{window2.addEventListener("lazyunveilread",globalInstall,true)}})(typeof window!="undefined"?window:0,(function(window2,document2,lazySizes){var addObserver=function(){var connect,disconnect,observer,connected;var lsCfg=lazySizes.cfg;var attributes={"data-bgset":1,"data-include":1,"data-poster":1,"data-bg":1,"data-script":1};var regClassTest="(\\s|^)("+lsCfg.loadedClass;var docElem=document2.documentElement;var setClass=function(target){lazySizes.rAF((function(){lazySizes.rC(target,lsCfg.loadedClass);if(lsCfg.unloadedClass){lazySizes.rC(target,lsCfg.unloadedClass)}lazySizes.aC(target,lsCfg.lazyClass);if(target.style.display=="none"||target.parentNode&&target.parentNode.style.display=="none"){setTimeout((function(){lazySizes.loader.unveil(target)}),0)}}))};var onMutation=function(mutations){var i,len,mutation,target;for(i=0,len=mutations.length;i<len;i++){mutation=mutations[i];target=mutation.target;if(!target.getAttribute(mutation.attributeName)){continue}if(target.localName=="source"&&target.parentNode){target=target.parentNode.querySelector("img")}if(target&&regClassTest.test(target.className)){setClass(target)}}};if(lsCfg.unloadedClass){regClassTest+="|"+lsCfg.unloadedClass}regClassTest+="|"+lsCfg.loadingClass+")(\\s|$)";regClassTest=new RegExp(regClassTest);attributes[lsCfg.srcAttr]=1;attributes[lsCfg.srcsetAttr]=1;if(window2.MutationObserver){observer=new MutationObserver(onMutation);connect=function(){if(!connected){connected=true;observer.observe(docElem,{subtree:true,attributes:true,attributeFilter:Object.keys(attributes)})}};disconnect=function(){if(connected){connected=false;observer.disconnect()}}}else{docElem.addEventListener("DOMAttrModified",function(){var runs;var modifications=[];var callMutations=function(){onMutation(modifications);modifications=[];runs=false};return function(e){if(connected&&attributes[e.attrName]&&e.newValue){modifications.push({target:e.target,attributeName:e.attrName});if(!runs){setTimeout(callMutations);runs=true}}}}(),true);connect=function(){connected=true};disconnect=function(){connected=false}}addEventListener("lazybeforeunveil",disconnect,true);addEventListener("lazybeforeunveil",connect);addEventListener("lazybeforesizes",disconnect,true);addEventListener("lazybeforesizes",connect);connect();removeEventListener("lazybeforeunveil",addObserver)};addEventListener("lazybeforeunveil",addObserver)}))})(ls_attrchange);
1
+ import{r as requireLazysizes}from"./lazysizes-B7xYodB-.js";import{jsx,Fragment,jsxs}from"react/jsx-runtime";import*as React from"react";import React__default,{useEffect,createContext,useContext,useState,useCallback,createElement,forwardRef,useRef,useImperativeHandle,useMemo,useReducer,Fragment as Fragment$1,useLayoutEffect,isValidElement}from"react";import{h as buildAriaProps,i as buildDataProps,j as buildHtmlProps,k as classnames,l as globalProps,m as buildCss,n as Collapsible,o as globalInlineProps,F as Flex,I as Icon,p as FlexItem,q as Body$1,r as Caption,A as Avatar,s as domSafeProps,t as Title,S as SectionSeparator,u as DialogContext,v as Draggable,w as TextInput,x as PropTypes,y as Card,z as noop$4,E as isEmpty,H as PbReactPopover,J as CircleIconButton,K as Button,N as HighchartsReact,O as Badge,Q as joinPresent,U as titleize,V as IconCircle,W as Image,X as Checkbox,Y as Radio}from"./_typeahead-DjGX1O4K.js";import{u as useCollapsible,j as getAllIcons,D as DateTime$1,a as datePickerHelper,k as useDropdown,o as omitBy,l as isEmpty$1,m as map,p as partial,n as find$1,q as commonjsGlobal,r as getDefaultExportFromCjs,s as highchartsDarkTheme,t as highchartsTheme,v as noop$5,w as colors,i as PbTextarea}from"./lib-kMuhBuU7.js";import*as ReactDOM from"react-dom";import ReactDOM__default,{createPortal}from"react-dom";var ls_attrchange={exports:{}};(function(module){(function(window2,factory){if(!window2){return}var globalInstall=function(){factory(window2.lazySizes);window2.removeEventListener("lazyunveilread",globalInstall,true)};factory=factory.bind(null,window2,window2.document);if(module.exports){factory(requireLazysizes())}else if(window2.lazySizes){globalInstall()}else{window2.addEventListener("lazyunveilread",globalInstall,true)}})(typeof window!="undefined"?window:0,(function(window2,document2,lazySizes){var addObserver=function(){var connect,disconnect,observer,connected;var lsCfg=lazySizes.cfg;var attributes={"data-bgset":1,"data-include":1,"data-poster":1,"data-bg":1,"data-script":1};var regClassTest="(\\s|^)("+lsCfg.loadedClass;var docElem=document2.documentElement;var setClass=function(target){lazySizes.rAF((function(){lazySizes.rC(target,lsCfg.loadedClass);if(lsCfg.unloadedClass){lazySizes.rC(target,lsCfg.unloadedClass)}lazySizes.aC(target,lsCfg.lazyClass);if(target.style.display=="none"||target.parentNode&&target.parentNode.style.display=="none"){setTimeout((function(){lazySizes.loader.unveil(target)}),0)}}))};var onMutation=function(mutations){var i,len,mutation,target;for(i=0,len=mutations.length;i<len;i++){mutation=mutations[i];target=mutation.target;if(!target.getAttribute(mutation.attributeName)){continue}if(target.localName=="source"&&target.parentNode){target=target.parentNode.querySelector("img")}if(target&&regClassTest.test(target.className)){setClass(target)}}};if(lsCfg.unloadedClass){regClassTest+="|"+lsCfg.unloadedClass}regClassTest+="|"+lsCfg.loadingClass+")(\\s|$)";regClassTest=new RegExp(regClassTest);attributes[lsCfg.srcAttr]=1;attributes[lsCfg.srcsetAttr]=1;if(window2.MutationObserver){observer=new MutationObserver(onMutation);connect=function(){if(!connected){connected=true;observer.observe(docElem,{subtree:true,attributes:true,attributeFilter:Object.keys(attributes)})}};disconnect=function(){if(connected){connected=false;observer.disconnect()}}}else{docElem.addEventListener("DOMAttrModified",function(){var runs;var modifications=[];var callMutations=function(){onMutation(modifications);modifications=[];runs=false};return function(e){if(connected&&attributes[e.attrName]&&e.newValue){modifications.push({target:e.target,attributeName:e.attrName});if(!runs){setTimeout(callMutations);runs=true}}}}(),true);connect=function(){connected=true};disconnect=function(){connected=false}}addEventListener("lazybeforeunveil",disconnect,true);addEventListener("lazybeforeunveil",connect);addEventListener("lazybeforesizes",disconnect,true);addEventListener("lazybeforesizes",connect);connect();removeEventListener("lazybeforeunveil",addObserver)};addEventListener("lazybeforeunveil",addObserver)}))})(ls_attrchange);
2
2
  /**
3
3
  * table-core
4
4
  *