playbook_ui 14.12.0.pre.rc.6 → 14.12.0.pre.rc.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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 +3 -9
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.md +5 -0
- data/app/pb_kits/playbook/pb_list/item.html.erb +30 -8
- data/app/pb_kits/playbook/pb_list/item.rb +7 -0
- data/app/pb_kits/playbook/pb_list/list.html.erb +31 -11
- data/app/pb_kits/playbook/pb_list/list.rb +4 -0
- data/app/pb_kits/playbook/pb_table/_table.tsx +2 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.html.erb +74 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns_rails.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_rails.md +2 -2
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.html.erb +74 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns_rails.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_table/index.ts +93 -34
- data/app/pb_kits/playbook/pb_table/table.html.erb +1 -1
- data/app/pb_kits/playbook/pb_table/table.rb +17 -2
- data/app/pb_kits/playbook/pb_table/utilities/addDataTitle.ts +22 -0
- data/dist/chunks/{_typeahead-BNULwihE.js → _typeahead-DCD3NrAk.js} +1 -1
- data/dist/chunks/_weekday_stacked-aUbMqVRj.js +45 -0
- data/dist/chunks/{lib-B7sgJtGS.js → lib-OFT985dg.js} +2 -2
- data/dist/chunks/{pb_form_validation-C5Cc0-1v.js → pb_form_validation-CrsXd1-Y.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/lib/playbook/version.rb +1 -1
- metadata +12 -6
- data/dist/chunks/_weekday_stacked-BKWemDAe.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dde2f316d84b4ddc9cc0377b283b36fd9c59cca4d76e16392696c5daf0b91b74
|
4
|
+
data.tar.gz: f91a51386632b5cd58edc7e946d582bf49c9fe22c58a932a01d3b82b7c21a0f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44737f2c553969cbfc368ccc5d781ce4f08eca1f39d4a61c30bb185b6ca2836d63ee389005fa44e0dde65b39d62835ec2c1d7f216f322fbe05f54b28c8206ca8
|
7
|
+
data.tar.gz: 163371a4bf7d5c68446346237baf84ea638c173fe841091ec13190dac3e422dce14ea3564a08c78e69b6d4a036fa50de986a27108ffadcb3c4a2cd9f2f8465d7
|
@@ -2,4 +2,4 @@ The `defaultDate`/`default_date` prop has a null or empty string value by defaul
|
|
2
2
|
|
3
3
|
If you use a Date object without UTC time standardization the Date Picker kit may misinterpret that date as yesterdays date (consequence of timezone differentials and the Javascript Date Object constructor). See [this GitHub issue for more information](https://github.com/powerhome/playbook/issues/1167) and the anti-pattern examples below.
|
4
4
|
|
5
|
-
|
5
|
+
You can leverage the `defaultDate`/`default_date` prop with custom logic in your filter or controller files where the determination of the default value changes based on user interaction. The page can load with an initial default date picker value or placeholder text, then after filter submission save the submitted values as the "new default" (via state or params).
|
@@ -6,14 +6,8 @@
|
|
6
6
|
|
7
7
|
] %>
|
8
8
|
|
9
|
-
<%= pb_rails("
|
10
|
-
|
11
|
-
<%= pb_rails("list", props:
|
12
|
-
<% initial_items.each do |item| %>
|
13
|
-
<%= pb_rails("draggable/draggable_item", props:{drag_id: item[:id]}) do %>
|
14
|
-
<%= pb_rails("list/item") do %><%= item[:name] %><% end %>
|
15
|
-
<% end %>
|
16
|
-
<% end %>
|
17
|
-
<% end %>
|
9
|
+
<%= pb_rails("list", props: { enable_drag: true, items: initial_items }) do %>
|
10
|
+
<% initial_items.each do |item| %>
|
11
|
+
<%= pb_rails("list/item", props:{drag_id: item[:id]}) do %><%= item[:name] %><% end %>
|
18
12
|
<% end %>
|
19
13
|
<% end %>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
For a simplified version of the Draggable API for the List kit, you can do the following:
|
2
|
+
|
3
|
+
The List kit is optimized to work with the draggable kit. To enable drag, use the `enable_drag` prop on List kit with an array of the included items AND `drag_id` prop on ListItems. You will also need to include the `items` prop containing your array of listed items for the Draggable API.
|
4
|
+
|
5
|
+
An additional optional boolean prop (set to true by default) of `drag_handle` is also available on ListItem kit to show the drag handle icon.
|
@@ -1,10 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
<% if object.draggable? %>
|
2
|
+
<%= pb_rails("draggable/draggable_item", props:{drag_id: object.drag_id}) do %>
|
3
|
+
<%= content_tag(:li,
|
4
|
+
aria: object.aria,
|
5
|
+
class: object.classname,
|
6
|
+
data: object.data,
|
7
|
+
id: object.id,
|
8
|
+
tabindex: object.tabindex,
|
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 %>
|
9
30
|
<%= content.presence %>
|
31
|
+
<% end %>
|
10
32
|
<% end %>
|
@@ -3,11 +3,18 @@
|
|
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
|
6
9
|
prop :tabindex
|
7
10
|
|
8
11
|
def classname
|
9
12
|
generate_classname("pb_item_kit")
|
10
13
|
end
|
14
|
+
|
15
|
+
def draggable?
|
16
|
+
drag_id.present?
|
17
|
+
end
|
11
18
|
end
|
12
19
|
end
|
13
20
|
end
|
@@ -1,13 +1,33 @@
|
|
1
|
-
|
2
|
-
<%=
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
<% if object.enable_drag %>
|
2
|
+
<%= pb_rails("draggable", props: {initial_items: object.items}) do %>
|
3
|
+
<%= pb_rails("draggable/draggable_container") do %>
|
4
|
+
<%= content_tag(:div, class: object.list_classname) do %>
|
5
|
+
<%= content_tag(:"#{object.ordered_class}",
|
6
|
+
aria: object.aria,
|
7
|
+
class: object.classname,
|
8
|
+
data: object.data,
|
9
|
+
id: object.id,
|
10
|
+
role: object.role,
|
11
|
+
tabindex: object.tabindex,
|
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 %>
|
12
32
|
<% end %>
|
13
33
|
<% end %>
|
@@ -7,6 +7,10 @@ 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: []
|
10
14
|
prop :layout, type: Playbook::Props::Enum,
|
11
15
|
values: ["left", "right", ""],
|
12
16
|
default: ""
|
@@ -2,7 +2,6 @@ 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 '.'
|
6
5
|
import {
|
7
6
|
TableHead,
|
8
7
|
TableHeader,
|
@@ -10,6 +9,7 @@ import {
|
|
10
9
|
TableRow,
|
11
10
|
TableCell,
|
12
11
|
} from "./subcomponents";
|
12
|
+
import { addDataTitle } from './utilities/addDataTitle'
|
13
13
|
|
14
14
|
type TableProps = {
|
15
15
|
aria?: { [key: string]: string },
|
@@ -196,8 +196,7 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
196
196
|
}, [stickyRightColumn]);
|
197
197
|
|
198
198
|
useEffect(() => {
|
199
|
-
|
200
|
-
instance.connect()
|
199
|
+
addDataTitle()
|
201
200
|
}, [])
|
202
201
|
|
203
202
|
return (
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<%= pb_rails("table", props: { size: "md", responsive: "scroll", sticky_left_column: ["a"], sticky_right_column: ["b"] }) do %>
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th id="a">Column 1</th>
|
5
|
+
<th>Column 2</th>
|
6
|
+
<th>Column 3</th>
|
7
|
+
<th>Column 4</th>
|
8
|
+
<th>Column 5</th>
|
9
|
+
<th>Column 6</th>
|
10
|
+
<th>Column 7</th>
|
11
|
+
<th>Column 8</th>
|
12
|
+
<th>Column 9</th>
|
13
|
+
<th>Column 10</th>
|
14
|
+
<th>Column 11</th>
|
15
|
+
<th>Column 12</th>
|
16
|
+
<th>Column 13</th>
|
17
|
+
<th>Column 14</th>
|
18
|
+
<th id="b">Column 15</th>
|
19
|
+
</tr>
|
20
|
+
</thead>
|
21
|
+
<tbody>
|
22
|
+
<tr>
|
23
|
+
<td id="a">Value 1</td>
|
24
|
+
<td>Value 2</td>
|
25
|
+
<td>Value 3</td>
|
26
|
+
<td>Value 4</td>
|
27
|
+
<td>Value 5</td>
|
28
|
+
<td>Value 6</td>
|
29
|
+
<td>Value 7</td>
|
30
|
+
<td>Value 8</td>
|
31
|
+
<td>Value 9</td>
|
32
|
+
<td>Value 10</td>
|
33
|
+
<td>Value 11</td>
|
34
|
+
<td>Value 12</td>
|
35
|
+
<td>Value 13</td>
|
36
|
+
<td>Value 14</td>
|
37
|
+
<td id="b">Value 15</td>
|
38
|
+
</tr>
|
39
|
+
<tr>
|
40
|
+
<td id="a">Value 1</td>
|
41
|
+
<td>Value 2</td>
|
42
|
+
<td>Value 3</td>
|
43
|
+
<td>Value 4</td>
|
44
|
+
<td>Value 5</td>
|
45
|
+
<td>Value 6</td>
|
46
|
+
<td>Value 7</td>
|
47
|
+
<td>Value 8</td>
|
48
|
+
<td>Value 9</td>
|
49
|
+
<td>Value 10</td>
|
50
|
+
<td>Value 11</td>
|
51
|
+
<td>Value 12</td>
|
52
|
+
<td>Value 13</td>
|
53
|
+
<td>Value 14</td>
|
54
|
+
<td id="b">Value 15</td>
|
55
|
+
</tr>
|
56
|
+
<tr>
|
57
|
+
<td id="a">Value 1</td>
|
58
|
+
<td>Value 2</td>
|
59
|
+
<td>Value 3</td>
|
60
|
+
<td>Value 4</td>
|
61
|
+
<td>Value 5</td>
|
62
|
+
<td>Value 6</td>
|
63
|
+
<td>Value 7</td>
|
64
|
+
<td>Value 8</td>
|
65
|
+
<td>Value 9</td>
|
66
|
+
<td>Value 10</td>
|
67
|
+
<td>Value 11</td>
|
68
|
+
<td>Value 12</td>
|
69
|
+
<td>Value 13</td>
|
70
|
+
<td>Value 14</td>
|
71
|
+
<td id="b">Value 15</td>
|
72
|
+
</tr>
|
73
|
+
</tbody>
|
74
|
+
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
The `
|
1
|
+
The `sticky_left_column` 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 `sticky_left_column`.
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<%= pb_rails("table", props: { size: "md", responsive: "scroll", sticky_right_column: ["13", "14", "15"] }) do %>
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Column 1</th>
|
5
|
+
<th>Column 2</th>
|
6
|
+
<th>Column 3</th>
|
7
|
+
<th>Column 4</th>
|
8
|
+
<th>Column 5</th>
|
9
|
+
<th>Column 6</th>
|
10
|
+
<th>Column 7</th>
|
11
|
+
<th>Column 8</th>
|
12
|
+
<th>Column 9</th>
|
13
|
+
<th>Column 10</th>
|
14
|
+
<th>Column 11</th>
|
15
|
+
<th>Column 12</th>
|
16
|
+
<th id="13">Column 13</th>
|
17
|
+
<th id="14">Column 14</th>
|
18
|
+
<th id="15">Column 15</th>
|
19
|
+
</tr>
|
20
|
+
</thead>
|
21
|
+
<tbody>
|
22
|
+
<tr>
|
23
|
+
<td>Value 1</td>
|
24
|
+
<td>Value 2</td>
|
25
|
+
<td>Value 3</td>
|
26
|
+
<td>Value 4</td>
|
27
|
+
<td>Value 5</td>
|
28
|
+
<td>Value 6</td>
|
29
|
+
<td>Value 7</td>
|
30
|
+
<td>Value 8</td>
|
31
|
+
<td>Value 9</td>
|
32
|
+
<td>Value 10</td>
|
33
|
+
<td>Value 11</td>
|
34
|
+
<td>Value 12</td>
|
35
|
+
<td id="13">Value 13</td>
|
36
|
+
<td id="14">Value 14</td>
|
37
|
+
<td id="15">Value 15</td>
|
38
|
+
</tr>
|
39
|
+
<tr>
|
40
|
+
<td>Value 1</td>
|
41
|
+
<td>Value 2</td>
|
42
|
+
<td>Value 3</td>
|
43
|
+
<td>Value 4</td>
|
44
|
+
<td>Value 5</td>
|
45
|
+
<td>Value 6</td>
|
46
|
+
<td>Value 7</td>
|
47
|
+
<td>Value 8</td>
|
48
|
+
<td>Value 9</td>
|
49
|
+
<td>Value 10</td>
|
50
|
+
<td>Value 11</td>
|
51
|
+
<td>Value 12</td>
|
52
|
+
<td id="13">Value 13</td>
|
53
|
+
<td id="14">Value 14</td>
|
54
|
+
<td id="15">Value 15</td>
|
55
|
+
</tr>
|
56
|
+
<tr>
|
57
|
+
<td>Value 1</td>
|
58
|
+
<td>Value 2</td>
|
59
|
+
<td>Value 3</td>
|
60
|
+
<td>Value 4</td>
|
61
|
+
<td>Value 5</td>
|
62
|
+
<td>Value 6</td>
|
63
|
+
<td>Value 7</td>
|
64
|
+
<td>Value 8</td>
|
65
|
+
<td>Value 9</td>
|
66
|
+
<td>Value 10</td>
|
67
|
+
<td>Value 11</td>
|
68
|
+
<td>Value 12</td>
|
69
|
+
<td id="13">Value 13</td>
|
70
|
+
<td id="14">Value 14</td>
|
71
|
+
<td id="15">Value 15</td>
|
72
|
+
</tr>
|
73
|
+
</tbody>
|
74
|
+
<% end %>
|
@@ -0,0 +1,3 @@
|
|
1
|
+
The `sticky_right_column` prop works in the same way as the above `sticky_left_column` prop. It 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
|
+
|
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 `sticky_right_column` prop.
|
@@ -5,6 +5,8 @@ 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
|
8
10
|
- table_header: Table Header
|
9
11
|
- table_alignment_row_rails: Row Alignment
|
10
12
|
- table_alignment_column_rails: Cell Alignment
|
@@ -1,73 +1,67 @@
|
|
1
1
|
import PbEnhancedElement from '../pb_enhanced_element'
|
2
2
|
|
3
|
+
const TABLE_WRAPPER_SELECTOR = "[data-pb-table-wrapper]";
|
4
|
+
|
3
5
|
export default class PbTable extends PbEnhancedElement {
|
4
|
-
|
5
|
-
|
6
|
+
stickyLeftColumns: string[] = [];
|
7
|
+
stickyRightColumns: string[] = [];
|
8
|
+
stickyRightColumnsReversed: string[] = [];
|
6
9
|
|
7
10
|
static get selector(): string {
|
8
|
-
return
|
11
|
+
return TABLE_WRAPPER_SELECTOR;
|
9
12
|
}
|
10
13
|
|
11
|
-
connect()
|
12
|
-
|
13
|
-
// Each Table
|
14
|
-
[].forEach.call(tables, (table: HTMLTableElement) => {
|
15
|
-
// Header Titles
|
14
|
+
connect() {
|
15
|
+
if (this.element.classList.contains('table-responsive-collapse')) {
|
16
16
|
const headers: string[] = [];
|
17
|
-
|
17
|
+
|
18
|
+
[].forEach.call(this.element.querySelectorAll('th'), (header: HTMLTableCellElement) => {
|
18
19
|
const colSpan = header.colSpan
|
19
20
|
for (let i = 0; i < colSpan; i++) {
|
20
21
|
headers.push(header.textContent.replace(/\r?\n|\r/, ''));
|
21
22
|
}
|
22
23
|
});
|
23
|
-
|
24
|
-
[].forEach.call(
|
25
|
-
// for each cell
|
24
|
+
|
25
|
+
[].forEach.call(this.element.querySelectorAll('tbody tr'), (row: HTMLTableRowElement) => {
|
26
26
|
[].forEach.call(row.cells, (cell: HTMLTableCellElement, headerIndex: number) => {
|
27
|
-
// apply the attribute
|
28
27
|
cell.setAttribute('data-title', headers[headerIndex])
|
29
28
|
})
|
30
29
|
})
|
31
|
-
}
|
30
|
+
}
|
32
31
|
|
33
|
-
// New sticky columns logic
|
34
32
|
this.initStickyLeftColumns();
|
33
|
+
this.initStickyRightColumns();
|
35
34
|
}
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
const tables = document.querySelectorAll('.sticky-left-column');
|
36
|
+
initStickyLeftColumns() {
|
37
|
+
const table = this.element.querySelector('.sticky-left-column');
|
40
38
|
|
41
|
-
|
42
|
-
// Extract sticky left column IDs by looking at the component's class
|
39
|
+
if (table) {
|
43
40
|
const classList = Array.from(table.classList);
|
41
|
+
const stickyColumnClass = classList.find(cls => cls.startsWith('sticky-left-columns-ids-'));
|
44
42
|
|
45
|
-
// Look for classes in the format sticky-left-column-{ids}
|
46
|
-
const stickyColumnClass = classList.find(cls => cls.startsWith('sticky-columns-'));
|
47
43
|
if (stickyColumnClass) {
|
48
|
-
// Extract the IDs from the class name
|
49
44
|
this.stickyLeftColumns = stickyColumnClass
|
50
|
-
|
51
|
-
|
45
|
+
.replace('sticky-left-columns-ids-', '')
|
46
|
+
.split('-');
|
52
47
|
|
53
48
|
if (this.stickyLeftColumns.length > 0) {
|
54
49
|
setTimeout(() => {
|
55
|
-
this.handleStickyLeftColumnsRef = this.handleStickyLeftColumns.bind(this);
|
56
50
|
this.handleStickyLeftColumns();
|
57
|
-
window.addEventListener('resize', this.
|
51
|
+
window.addEventListener('resize', () => this.handleStickyLeftColumns());
|
58
52
|
}, 10);
|
59
53
|
}
|
60
54
|
}
|
61
|
-
}
|
55
|
+
}
|
62
56
|
}
|
63
57
|
|
64
|
-
|
58
|
+
handleStickyLeftColumns() {
|
65
59
|
let accumulatedWidth = 0;
|
66
60
|
|
67
61
|
this.stickyLeftColumns.forEach((colId, index) => {
|
68
62
|
const isLastColumn = index === this.stickyLeftColumns.length - 1;
|
69
|
-
const header =
|
70
|
-
const cells =
|
63
|
+
const header = this.element.querySelector(`th[id="${colId}"]`);
|
64
|
+
const cells = this.element.querySelectorAll(`td[id="${colId}"]`);
|
71
65
|
|
72
66
|
if (header) {
|
73
67
|
header.classList.add('sticky');
|
@@ -99,10 +93,75 @@ export default class PbTable extends PbEnhancedElement {
|
|
99
93
|
});
|
100
94
|
}
|
101
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
|
+
}
|
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
|
+
|
102
157
|
// Cleanup method to remove event listener
|
103
|
-
disconnect()
|
104
|
-
if (this.
|
105
|
-
window.removeEventListener('resize', this.
|
158
|
+
disconnect() {
|
159
|
+
if (this.stickyLeftColumns.length > 0) {
|
160
|
+
window.removeEventListener('resize', () => this.handleStickyLeftColumns());
|
161
|
+
}
|
162
|
+
|
163
|
+
if (this.stickyRightColumns.length > 0) {
|
164
|
+
window.removeEventListener('resize', () => this.handleStickyRightColumns());
|
106
165
|
}
|
107
166
|
}
|
108
167
|
}
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<% responsive_class = nil %>
|
5
5
|
<% end %>
|
6
6
|
|
7
|
-
<%= content_tag(:div, class: responsive_class) do %>
|
7
|
+
<%= content_tag(:div, class: responsive_class, 'data-pb-table-wrapper' => true) do %>
|
8
8
|
<% if object.tag == "table" %>
|
9
9
|
<%= content_tag(:table,
|
10
10
|
aria: object.aria,
|
@@ -25,6 +25,8 @@ 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: []
|
28
30
|
prop :vertical_border, type: Playbook::Props::Boolean,
|
29
31
|
default: false
|
30
32
|
prop :striped, type: Playbook::Props::Boolean,
|
@@ -40,7 +42,7 @@ module Playbook
|
|
40
42
|
generate_classname(
|
41
43
|
"pb_table", "table-#{size}", single_line_class, dark_class,
|
42
44
|
disable_hover_class, container_class, data_table_class, sticky_class, sticky_left_column_class,
|
43
|
-
collapse_class, vertical_border_class, striped_class, outer_padding_class,
|
45
|
+
sticky_right_column_class, collapse_class, vertical_border_class, striped_class, outer_padding_class,
|
44
46
|
"table-responsive-#{responsive}", separator: " "
|
45
47
|
)
|
46
48
|
end
|
@@ -83,7 +85,7 @@ module Playbook
|
|
83
85
|
if sticky_left_column.empty?
|
84
86
|
nil
|
85
87
|
else
|
86
|
-
sticky_col_classname = "sticky-left-column sticky-columns"
|
88
|
+
sticky_col_classname = "sticky-left-column sticky-left-columns-ids"
|
87
89
|
sticky_left_column.each do |id|
|
88
90
|
sticky_col_classname += "-#{id}"
|
89
91
|
end
|
@@ -92,6 +94,19 @@ module Playbook
|
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
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
|
+
|
95
110
|
def striped_class
|
96
111
|
striped ? "striped" : nil
|
97
112
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
export const addDataTitle = () => {
|
2
|
+
const tables = document.querySelectorAll('.table-responsive-collapse');
|
3
|
+
// Each Table
|
4
|
+
[].forEach.call(tables, (table: HTMLTableElement) => {
|
5
|
+
// Header Titles
|
6
|
+
const headers: string[] = [];
|
7
|
+
[].forEach.call(table.querySelectorAll('th'), (header: HTMLTableCellElement) => {
|
8
|
+
const colSpan = header.colSpan
|
9
|
+
for (let i = 0; i < colSpan; i++) {
|
10
|
+
headers.push(header.textContent.replace(/\r?\n|\r/, ''));
|
11
|
+
}
|
12
|
+
});
|
13
|
+
// for each row in tbody
|
14
|
+
[].forEach.call(table.querySelectorAll('tbody tr'), (row: HTMLTableRowElement) => {
|
15
|
+
// for each cell
|
16
|
+
[].forEach.call(row.cells, (cell: HTMLTableCellElement, headerIndex: number) => {
|
17
|
+
// apply the attribute
|
18
|
+
cell.setAttribute('data-title', headers[headerIndex])
|
19
|
+
})
|
20
|
+
})
|
21
|
+
});
|
22
|
+
}
|
@@ -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-
|
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:{}};
|
2
2
|
/*!
|
3
3
|
Copyright (c) 2018 Jed Watson.
|
4
4
|
Licensed under the MIT License (MIT), see
|