playbook_ui 14.11.1.pre.alpha.PBNTR7495495 → 14.11.1.pre.alpha.PLAY1720phonenumberinputformatAsYouType5377
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +2 -18
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +5 -27
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +2 -17
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +1 -23
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +0 -29
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +4 -61
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -6
- data/app/pb_kits/playbook/pb_button/button.html.erb +3 -2
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +6 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +6 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.md +1 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.html.erb +9 -3
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +12 -7
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +14 -9
- data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +11 -6
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +14 -8
- data/app/pb_kits/playbook/pb_list/item.html.erb +8 -30
- data/app/pb_kits/playbook/pb_list/item.rb +0 -7
- data/app/pb_kits/playbook/pb_list/list.html.erb +11 -31
- data/app/pb_kits/playbook/pb_list/list.rb +0 -4
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +3 -17
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list.rb +0 -3
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +4 -11
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.rb +0 -3
- data/app/pb_kits/playbook/pb_table/_table.tsx +3 -2
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_rails.md +2 -2
- data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_table/index.ts +34 -93
- data/app/pb_kits/playbook/pb_table/table.html.erb +1 -1
- data/app/pb_kits/playbook/pb_table/table.rb +2 -17
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +30 -30
- data/dist/chunks/_typeahead-DWVCHt1f.js +36 -0
- data/dist/chunks/_weekday_stacked-0vGR_2wj.js +45 -0
- data/dist/chunks/{lib-OFT985dg.js → lib-B7sgJtGS.js} +2 -2
- data/dist/chunks/{pb_form_validation-CrsXd1-Y.js → pb_form_validation-C5Cc0-1v.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +6 -39
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_no_subrows.jsx +0 -50
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.jsx +0 -60
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.md +0 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.jsx +0 -78
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header.jsx +0 -53
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.jsx +0 -52
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_no_subrows.json +0 -42
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_with_id.json +0 -299
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.md +0 -5
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_rails.html.erb +0 -38
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_rails.md +0 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.html.erb +0 -74
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns_rails.md +0 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.html.erb +0 -74
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns_rails.md +0 -3
- data/app/pb_kits/playbook/pb_table/utilities/addDataTitle.ts +0 -22
- data/dist/chunks/_typeahead-D_mMNEad.js +0 -36
- data/dist/chunks/_weekday_stacked-CGe59pJD.js +0 -45
@@ -1,10 +1,15 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.option[:id],
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<%= pb_rails("list/item", props: {
|
3
|
-
display: "flex",
|
4
|
-
justify_content: "center",
|
5
|
-
padding:"none",
|
8
|
+
display: "flex",
|
9
|
+
justify_content: "center",
|
10
|
+
padding:"none",
|
6
11
|
cursor: "pointer"
|
7
|
-
}) do %>
|
12
|
+
}) do %>
|
8
13
|
<div class="dropdown_option_wrapper">
|
9
14
|
<% if content.present? %>
|
10
15
|
<%= content.presence %>
|
@@ -13,4 +18,4 @@
|
|
13
18
|
<% end %>
|
14
19
|
</div>
|
15
20
|
<% end %>
|
16
|
-
<% end %>
|
21
|
+
<% end %>
|
@@ -1,16 +1,21 @@
|
|
1
|
-
<%=
|
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
|
<% if content.present? %>
|
3
8
|
<div style="display: inline-block" tabindex="0" data-dropdown-custom-trigger>
|
4
9
|
<%= content.presence %>
|
5
10
|
</div>
|
6
11
|
<% else %>
|
7
12
|
<%= pb_rails("flex", props: {
|
8
|
-
align: "center",
|
9
|
-
border_radius:"lg",
|
10
|
-
classname: object.trigger_wrapper_classes,
|
11
|
-
cursor: "pointer",
|
12
|
-
justify: "between",
|
13
|
-
padding_x:"sm",
|
13
|
+
align: "center",
|
14
|
+
border_radius:"lg",
|
15
|
+
classname: object.trigger_wrapper_classes,
|
16
|
+
cursor: "pointer",
|
17
|
+
justify: "between",
|
18
|
+
padding_x:"sm",
|
14
19
|
padding_y:"xs",
|
15
20
|
html_options: {tabindex:"0"}
|
16
21
|
}) do %>
|
@@ -18,7 +23,7 @@
|
|
18
23
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
19
24
|
<% if object.custom_display.present? %>
|
20
25
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
21
|
-
<div id="dropdown_trigger_custom_display" style="display: none;">
|
26
|
+
<div id="dropdown_trigger_custom_display" style="display: none;">
|
22
27
|
<%= object.custom_display %>
|
23
28
|
</div>
|
24
29
|
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display"}) %>
|
@@ -35,3 +40,4 @@
|
|
35
40
|
<% end %>
|
36
41
|
<% end %>
|
37
42
|
<% end %>
|
43
|
+
|
@@ -1,32 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
**combined_html_options
|
10
|
-
) do %>
|
11
|
-
<% if object.drag_handle %>
|
12
|
-
<span style="vertical-align: middle;">
|
13
|
-
<%= pb_rails("body") do %>
|
14
|
-
<svg width="auto" height="auto" viewBox="0 0 31 25" fill="none" xmlns="http://www.w3.org/2000/svg" color="currentColor" class="pb_custom_icon svg-inline--fa vertical_align_middle svg_fw"><path d="M12.904 6.355a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm0 7.5a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm1.5 6c0 .844-.703 1.5-1.5 1.5a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5zm4.5-13.5a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm1.5 6c0 .844-.703 1.5-1.5 1.5a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5zm-1.5 9a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5z" fill="#242B42"></path></svg>
|
15
|
-
<% end %>
|
16
|
-
</span>
|
17
|
-
<% end %>
|
18
|
-
<%= content.presence %>
|
19
|
-
<% end %>
|
20
|
-
<% end %>
|
21
|
-
<% else %>
|
22
|
-
<%= content_tag(:li,
|
23
|
-
aria: object.aria,
|
24
|
-
class: object.classname,
|
25
|
-
data: object.data,
|
26
|
-
id: object.id,
|
27
|
-
tabindex: object.tabindex,
|
28
|
-
**combined_html_options
|
29
|
-
) do %>
|
1
|
+
<%= content_tag(:li,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
tabindex: object.tabindex,
|
7
|
+
**combined_html_options
|
8
|
+
) do %>
|
30
9
|
<%= content.presence %>
|
31
|
-
<% end %>
|
32
10
|
<% end %>
|
@@ -3,18 +3,11 @@
|
|
3
3
|
module Playbook
|
4
4
|
module PbList
|
5
5
|
class Item < Playbook::KitBase
|
6
|
-
prop :drag_handle, type: Playbook::Props::Boolean,
|
7
|
-
default: true
|
8
|
-
prop :drag_id, type: Playbook::Props::String
|
9
6
|
prop :tabindex
|
10
7
|
|
11
8
|
def classname
|
12
9
|
generate_classname("pb_item_kit")
|
13
10
|
end
|
14
|
-
|
15
|
-
def draggable?
|
16
|
-
drag_id.present?
|
17
|
-
end
|
18
11
|
end
|
19
12
|
end
|
20
13
|
end
|
@@ -1,33 +1,13 @@
|
|
1
|
-
|
2
|
-
<%=
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
**combined_html_options
|
13
|
-
) do %>
|
14
|
-
<%= content.presence %>
|
15
|
-
<% end %>
|
16
|
-
<% end %>
|
17
|
-
<% end %>
|
18
|
-
<% end %>
|
19
|
-
<% else %>
|
20
|
-
<%= content_tag(:div, class: object.list_classname) do %>
|
21
|
-
<%= content_tag(:"#{object.ordered_class}",
|
22
|
-
aria: object.aria,
|
23
|
-
class: object.classname,
|
24
|
-
data: object.data,
|
25
|
-
id: object.id,
|
26
|
-
role: object.role,
|
27
|
-
tabindex: object.tabindex,
|
28
|
-
**combined_html_options
|
29
|
-
) do %>
|
30
|
-
<%= content.presence %>
|
31
|
-
<% end %>
|
1
|
+
<%= content_tag(:div, class: object.list_classname) do %>
|
2
|
+
<%= content_tag(:"#{object.ordered_class}",
|
3
|
+
aria: object.aria,
|
4
|
+
class: object.classname,
|
5
|
+
data: object.data,
|
6
|
+
id: object.id,
|
7
|
+
role: object.role,
|
8
|
+
tabindex: object.tabindex,
|
9
|
+
**combined_html_options
|
10
|
+
) do %>
|
11
|
+
<%= content.presence %>
|
32
12
|
<% end %>
|
33
13
|
<% end %>
|
@@ -7,10 +7,6 @@ module Playbook
|
|
7
7
|
default: false
|
8
8
|
prop :dark, type: Playbook::Props::Boolean,
|
9
9
|
default: false
|
10
|
-
prop :enable_drag, type: Playbook::Props::Boolean,
|
11
|
-
default: false
|
12
|
-
prop :items, type: Playbook::Props::Array,
|
13
|
-
default: []
|
14
10
|
prop :layout, type: Playbook::Props::Enum,
|
15
11
|
values: ["left", "right", ""],
|
16
12
|
default: ""
|
@@ -4,23 +4,9 @@
|
|
4
4
|
data: object.data,
|
5
5
|
id: object.id,
|
6
6
|
**combined_html_options) do %>
|
7
|
-
|
8
|
-
|
9
|
-
<%= pb_rails("
|
10
|
-
<%= pb_rails("list", props: {ordered: false}) do %>
|
11
|
-
<% object.items.each do |item| %>
|
12
|
-
<%= pb_rails("draggable/draggable_item", props: {drag_id: item[:drag_id]}) do %>
|
13
|
-
<%= pb_rails("selectable_list/selectable_list_item", props: item.merge(variant: object.variant, id: object.get_id(item), drag_id: item[:drag_id]) )%>
|
14
|
-
<% end %>
|
15
|
-
<% end %>
|
16
|
-
<% end %>
|
17
|
-
<% end %>
|
18
|
-
<% end %>
|
19
|
-
<% else %>
|
20
|
-
<%= pb_rails("list") do %>
|
21
|
-
<% object.items.each do |item| %>
|
22
|
-
<%= pb_rails("selectable_list/selectable_list_item", props: item.merge(variant: object.variant, id: object.get_id(item)) )%>
|
23
|
-
<% end %>
|
7
|
+
<%= pb_rails("list") do %>
|
8
|
+
<% object.items.each do |item| %>
|
9
|
+
<%= pb_rails("selectable_list/selectable_list_item", props: item.merge(variant: object.variant, id: object.get_id(item)) )%>
|
24
10
|
<% end %>
|
25
11
|
<% end %>
|
26
12
|
<% end %>
|
@@ -4,13 +4,6 @@
|
|
4
4
|
data: object.data,
|
5
5
|
id: object.id,
|
6
6
|
**combined_html_options) do %>
|
7
|
-
<% if object.drag_id && object.drag_handle %>
|
8
|
-
<span style="vertical-align: middle;">
|
9
|
-
<%= pb_rails("body") do %>
|
10
|
-
<svg width="auto" height="auto" viewBox="0 0 31 25" fill="none" xmlns="http://www.w3.org/2000/svg" color="currentColor" class="pb_custom_icon svg-inline--fa vertical_align_middle svg_fw"><path d="M12.904 6.355a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm0 7.5a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm1.5 6c0 .844-.703 1.5-1.5 1.5a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5zm4.5-13.5a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm1.5 6c0 .844-.703 1.5-1.5 1.5a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5zm-1.5 9a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5z" fill="#242B42"></path></svg>
|
11
|
-
<% end %>
|
12
|
-
</span>
|
13
|
-
<% end %>
|
14
7
|
<% if object.variant == "radio"%>
|
15
8
|
<%= pb_rails("radio", props: { text: object.text, checked: object.checked, input_options: object.input_options } ) %>
|
16
9
|
<% if content.present? %>
|
@@ -26,10 +19,10 @@
|
|
26
19
|
<% if object.variant == "checkbox"%>
|
27
20
|
<script>
|
28
21
|
var checkboxElement = document.querySelector("#<%=object.id%> input[type=checkbox]")
|
29
|
-
|
22
|
+
|
30
23
|
checkboxElement.addEventListener("change", (evt) => {
|
31
24
|
var listItemElement = document.querySelector("#<%=object.id%>")
|
32
|
-
|
25
|
+
|
33
26
|
if (evt.target.checked) {
|
34
27
|
listItemElement.classList.add("checked_item");
|
35
28
|
} else {
|
@@ -41,9 +34,9 @@
|
|
41
34
|
<script>
|
42
35
|
var radioElement = document.querySelector("#<%=object.id%> input[type=radio]")
|
43
36
|
|
44
|
-
radioElement.addEventListener("change", () => {
|
37
|
+
radioElement.addEventListener("change", () => {
|
45
38
|
var radios = radioElement.closest("ul").querySelectorAll("input[type=radio]")
|
46
|
-
|
39
|
+
|
47
40
|
radios.forEach((radio) => {
|
48
41
|
if (radio.checked) {
|
49
42
|
radio.closest("li").classList.add("checked_item");
|
@@ -6,9 +6,6 @@ module Playbook
|
|
6
6
|
prop :tabindex
|
7
7
|
prop :checked, type: Playbook::Props::Boolean,
|
8
8
|
default: false
|
9
|
-
prop :drag_handle, type: Playbook::Props::Boolean,
|
10
|
-
default: true
|
11
|
-
prop :drag_id, type: Playbook::Props::String
|
12
9
|
prop :name, type: Playbook::Props::String
|
13
10
|
prop :text, type: Playbook::Props::String
|
14
11
|
prop :value, type: Playbook::Props::String
|
@@ -2,6 +2,7 @@ import React, { useEffect } from 'react'
|
|
2
2
|
import classnames from 'classnames'
|
3
3
|
import { buildAriaProps, buildDataProps, buildHtmlProps } from '../utilities/props'
|
4
4
|
import { globalProps, GlobalProps, globalInlineProps } from '../utilities/globalProps'
|
5
|
+
import PbTable from '.'
|
5
6
|
import {
|
6
7
|
TableHead,
|
7
8
|
TableHeader,
|
@@ -9,7 +10,6 @@ import {
|
|
9
10
|
TableRow,
|
10
11
|
TableCell,
|
11
12
|
} from "./subcomponents";
|
12
|
-
import { addDataTitle } from './utilities/addDataTitle'
|
13
13
|
|
14
14
|
type TableProps = {
|
15
15
|
aria?: { [key: string]: string },
|
@@ -196,7 +196,8 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
196
196
|
}, [stickyRightColumn]);
|
197
197
|
|
198
198
|
useEffect(() => {
|
199
|
-
|
199
|
+
const instance = new PbTable()
|
200
|
+
instance.connect()
|
200
201
|
}, [])
|
201
202
|
|
202
203
|
return (
|
@@ -1,3 +1,3 @@
|
|
1
|
-
The `
|
1
|
+
The `stickyLeftColumn` prop expects an array of the column ids you want to be sticky. Make sure to add the corresponding id to the `<th>` and `<td>`.
|
2
2
|
|
3
|
-
Please ensure that unique ids are used for all columns across multiple tables. Using the same columns ids on multiple tables can lead to issues when using the `
|
3
|
+
Please ensure that unique ids are used for all columns across multiple tables. Using the same columns ids on multiple tables can lead to issues when using the `stickyLeftColumn`.
|
@@ -5,8 +5,6 @@ examples:
|
|
5
5
|
- table_lg: Large
|
6
6
|
- table_sticky: Sticky Header
|
7
7
|
- table_sticky_left_columns: Sticky Left Column
|
8
|
-
- table_sticky_right_columns: Sticky Right Column
|
9
|
-
- table_sticky_columns: Sticky Left and Right Columns
|
10
8
|
- table_header: Table Header
|
11
9
|
- table_alignment_row_rails: Row Alignment
|
12
10
|
- table_alignment_column_rails: Cell Alignment
|
@@ -1,67 +1,73 @@
|
|
1
1
|
import PbEnhancedElement from '../pb_enhanced_element'
|
2
2
|
|
3
|
-
const TABLE_WRAPPER_SELECTOR = "[data-pb-table-wrapper]";
|
4
|
-
|
5
3
|
export default class PbTable extends PbEnhancedElement {
|
6
|
-
stickyLeftColumns: string[] = [];
|
7
|
-
|
8
|
-
stickyRightColumnsReversed: string[] = [];
|
4
|
+
private stickyLeftColumns: string[] = [];
|
5
|
+
private handleStickyLeftColumnsRef: () => void;
|
9
6
|
|
10
7
|
static get selector(): string {
|
11
|
-
return
|
8
|
+
return '.table-responsive-collapse'
|
12
9
|
}
|
13
10
|
|
14
|
-
connect() {
|
15
|
-
|
11
|
+
connect(): void {
|
12
|
+
const tables = document.querySelectorAll('.table-responsive-collapse');
|
13
|
+
// Each Table
|
14
|
+
[].forEach.call(tables, (table: HTMLTableElement) => {
|
15
|
+
// Header Titles
|
16
16
|
const headers: string[] = [];
|
17
|
-
|
18
|
-
[].forEach.call(this.element.querySelectorAll('th'), (header: HTMLTableCellElement) => {
|
17
|
+
[].forEach.call(table.querySelectorAll('th'), (header: HTMLTableCellElement) => {
|
19
18
|
const colSpan = header.colSpan
|
20
19
|
for (let i = 0; i < colSpan; i++) {
|
21
20
|
headers.push(header.textContent.replace(/\r?\n|\r/, ''));
|
22
21
|
}
|
23
22
|
});
|
24
|
-
|
25
|
-
[].forEach.call(
|
23
|
+
// for each row in tbody
|
24
|
+
[].forEach.call(table.querySelectorAll('tbody tr'), (row: HTMLTableRowElement) => {
|
25
|
+
// for each cell
|
26
26
|
[].forEach.call(row.cells, (cell: HTMLTableCellElement, headerIndex: number) => {
|
27
|
+
// apply the attribute
|
27
28
|
cell.setAttribute('data-title', headers[headerIndex])
|
28
29
|
})
|
29
30
|
})
|
30
|
-
}
|
31
|
+
});
|
31
32
|
|
33
|
+
// New sticky columns logic
|
32
34
|
this.initStickyLeftColumns();
|
33
|
-
this.initStickyRightColumns();
|
34
35
|
}
|
35
36
|
|
36
|
-
initStickyLeftColumns() {
|
37
|
-
|
37
|
+
private initStickyLeftColumns(): void {
|
38
|
+
// Find tables with sticky-left-column class
|
39
|
+
const tables = document.querySelectorAll('.sticky-left-column');
|
38
40
|
|
39
|
-
|
41
|
+
tables.forEach((table) => {
|
42
|
+
// Extract sticky left column IDs by looking at the component's class
|
40
43
|
const classList = Array.from(table.classList);
|
41
|
-
const stickyColumnClass = classList.find(cls => cls.startsWith('sticky-left-columns-ids-'));
|
42
44
|
|
45
|
+
// Look for classes in the format sticky-left-column-{ids}
|
46
|
+
const stickyColumnClass = classList.find(cls => cls.startsWith('sticky-columns-'));
|
43
47
|
if (stickyColumnClass) {
|
48
|
+
// Extract the IDs from the class name
|
44
49
|
this.stickyLeftColumns = stickyColumnClass
|
45
|
-
|
46
|
-
|
50
|
+
.replace('sticky-columns-', '')
|
51
|
+
.split('-');
|
47
52
|
|
48
53
|
if (this.stickyLeftColumns.length > 0) {
|
49
54
|
setTimeout(() => {
|
55
|
+
this.handleStickyLeftColumnsRef = this.handleStickyLeftColumns.bind(this);
|
50
56
|
this.handleStickyLeftColumns();
|
51
|
-
window.addEventListener('resize',
|
57
|
+
window.addEventListener('resize', this.handleStickyLeftColumnsRef);
|
52
58
|
}, 10);
|
53
59
|
}
|
54
60
|
}
|
55
|
-
}
|
61
|
+
});
|
56
62
|
}
|
57
63
|
|
58
|
-
handleStickyLeftColumns() {
|
64
|
+
private handleStickyLeftColumns(): void {
|
59
65
|
let accumulatedWidth = 0;
|
60
66
|
|
61
67
|
this.stickyLeftColumns.forEach((colId, index) => {
|
62
68
|
const isLastColumn = index === this.stickyLeftColumns.length - 1;
|
63
|
-
const header =
|
64
|
-
const cells =
|
69
|
+
const header = document.querySelector(`th[id="${colId}"]`);
|
70
|
+
const cells = document.querySelectorAll(`td[id="${colId}"]`);
|
65
71
|
|
66
72
|
if (header) {
|
67
73
|
header.classList.add('sticky');
|
@@ -93,75 +99,10 @@ export default class PbTable extends PbEnhancedElement {
|
|
93
99
|
});
|
94
100
|
}
|
95
101
|
|
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
|
-
}
|
115
|
-
}
|
116
|
-
}
|
117
|
-
}
|
118
|
-
|
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`;
|
130
|
-
|
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
|
-
}
|
138
|
-
|
139
|
-
accumulatedWidth += (header as HTMLElement).offsetWidth;
|
140
|
-
}
|
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
|
-
}
|
153
|
-
});
|
154
|
-
});
|
155
|
-
}
|
156
|
-
|
157
102
|
// Cleanup method to remove event listener
|
158
|
-
disconnect() {
|
159
|
-
if (this.
|
160
|
-
window.removeEventListener('resize',
|
161
|
-
}
|
162
|
-
|
163
|
-
if (this.stickyRightColumns.length > 0) {
|
164
|
-
window.removeEventListener('resize', () => this.handleStickyRightColumns());
|
103
|
+
disconnect(): void {
|
104
|
+
if (this.handleStickyLeftColumnsRef) {
|
105
|
+
window.removeEventListener('resize', this.handleStickyLeftColumnsRef);
|
165
106
|
}
|
166
107
|
}
|
167
108
|
}
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<% responsive_class = nil %>
|
5
5
|
<% end %>
|
6
6
|
|
7
|
-
<%= content_tag(:div, class: responsive_class
|
7
|
+
<%= content_tag(:div, class: responsive_class) do %>
|
8
8
|
<% if object.tag == "table" %>
|
9
9
|
<%= content_tag(:table,
|
10
10
|
aria: object.aria,
|
@@ -25,8 +25,6 @@ module Playbook
|
|
25
25
|
default: false
|
26
26
|
prop :sticky_left_column, type: Playbook::Props::Array,
|
27
27
|
default: []
|
28
|
-
prop :sticky_right_column, type: Playbook::Props::Array,
|
29
|
-
default: []
|
30
28
|
prop :vertical_border, type: Playbook::Props::Boolean,
|
31
29
|
default: false
|
32
30
|
prop :striped, type: Playbook::Props::Boolean,
|
@@ -42,7 +40,7 @@ module Playbook
|
|
42
40
|
generate_classname(
|
43
41
|
"pb_table", "table-#{size}", single_line_class, dark_class,
|
44
42
|
disable_hover_class, container_class, data_table_class, sticky_class, sticky_left_column_class,
|
45
|
-
|
43
|
+
collapse_class, vertical_border_class, striped_class, outer_padding_class,
|
46
44
|
"table-responsive-#{responsive}", separator: " "
|
47
45
|
)
|
48
46
|
end
|
@@ -85,7 +83,7 @@ module Playbook
|
|
85
83
|
if sticky_left_column.empty?
|
86
84
|
nil
|
87
85
|
else
|
88
|
-
sticky_col_classname = "sticky-left-column sticky-
|
86
|
+
sticky_col_classname = "sticky-left-column sticky-columns"
|
89
87
|
sticky_left_column.each do |id|
|
90
88
|
sticky_col_classname += "-#{id}"
|
91
89
|
end
|
@@ -94,19 +92,6 @@ module Playbook
|
|
94
92
|
end
|
95
93
|
end
|
96
94
|
|
97
|
-
def sticky_right_column_class
|
98
|
-
if sticky_right_column.empty?
|
99
|
-
nil
|
100
|
-
else
|
101
|
-
sticky_col_classname = "sticky-right-column sticky-right-columns-ids"
|
102
|
-
sticky_right_column.each do |id|
|
103
|
-
sticky_col_classname += "-#{id}"
|
104
|
-
end
|
105
|
-
|
106
|
-
sticky_col_classname
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
95
|
def striped_class
|
111
96
|
striped ? "striped" : nil
|
112
97
|
end
|