playbook_ui 13.5.0.pre.alpha.PLAY823globalpropoverflow1191 → 13.5.0.pre.alpha.play984collapsiblekithidestooltips1203
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_body/_body.tsx +1 -1
- data/app/pb_kits/playbook/pb_caption/_caption.tsx +1 -1
- data/app/pb_kits/playbook/pb_card/card.rb +1 -1
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +1 -1
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +0 -1
- data/app/pb_kits/playbook/pb_collapsible/_helper_functions.ts +26 -22
- data/app/pb_kits/playbook/pb_collapsible/index.js +4 -0
- data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.rb +2 -2
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +1 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -2
- data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.tsx +1 -1
- data/app/pb_kits/playbook/pb_file_upload/file_upload.rb +1 -1
- data/app/pb_kits/playbook/pb_flex/_flex_item.tsx +0 -1
- data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +6 -6
- data/app/pb_kits/playbook/pb_passphrase/passphrase.rb +1 -1
- data/app/pb_kits/playbook/pb_radio/radio.rb +1 -1
- data/app/pb_kits/playbook/pb_select/select.rb +1 -1
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.rb +1 -1
- data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.rb +1 -1
- data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.rb +1 -1
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.rb +1 -1
- data/app/pb_kits/playbook/pb_source/source.rb +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_header.html.erb +31 -27
- data/app/pb_kits/playbook/pb_table/docs/_table_header.md +8 -1
- data/app/pb_kits/playbook/pb_table/styles/_table_header.scss +20 -1
- data/app/pb_kits/playbook/pb_table/table_header.html.erb +23 -49
- data/app/pb_kits/playbook/pb_table/table_header.rb +34 -6
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +2 -2
- data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.tsx +1 -1
- data/app/pb_kits/playbook/pb_title/_title.tsx +1 -1
- data/app/pb_kits/playbook/pb_toggle/toggle.rb +1 -1
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +1 -1
- data/app/pb_kits/playbook/utilities/globalProps.ts +7 -7
- data/dist/playbook-rails.js +3 -3
- data/lib/playbook/kit_base.rb +2 -2
- data/lib/playbook/props/base.rb +1 -1
- data/lib/playbook/props/hash.rb +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aab7a2026fea0f718678e51045ec994772216ad74e0a9a41e5899de34a405009
|
4
|
+
data.tar.gz: a9c6819da8a20bed50ed2024b4a598514d637b5cc497969b8c2a42552147f794
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1d017c3592b3531ea82d819e6e34222f4ebad899cb3c9a3950506a3588f94827d90e18c82405d5eab5ed6a7f12fee4caaadd67fe09ca4622f638c29302ac895
|
7
|
+
data.tar.gz: 8600414aea6c3ebf852b80b1c6566e601bf7dab8abdcc4e9d343a90872190658fc4f88f384925d1112bbe2233a1f8190b76ae22ba224bbe0e4550236efff4a50
|
@@ -24,7 +24,7 @@ type BodyProps = {
|
|
24
24
|
} & GlobalProps
|
25
25
|
|
26
26
|
const Body = (props: BodyProps): React.ReactElement => {
|
27
|
-
if (props.variant) deprecatedProps(
|
27
|
+
if (props.variant) deprecatedProps() //status prop is deprecated, use color instead please
|
28
28
|
const {
|
29
29
|
aria = {},
|
30
30
|
children,
|
@@ -17,7 +17,7 @@ type CaptionProps = {
|
|
17
17
|
} & GlobalProps;
|
18
18
|
|
19
19
|
const Caption = (props: CaptionProps): React.ReactElement => {
|
20
|
-
if (props.variant) deprecatedProps(
|
20
|
+
if (props.variant) deprecatedProps() //variant prop is deprecated, use color instead
|
21
21
|
const {
|
22
22
|
aria = {},
|
23
23
|
children,
|
@@ -4,7 +4,7 @@ module Playbook
|
|
4
4
|
module PbCard
|
5
5
|
class Card < Playbook::KitBase
|
6
6
|
prop :selected, type: Playbook::Props::Boolean, default: false
|
7
|
-
prop :highlight, type: Playbook::Props::
|
7
|
+
prop :highlight, type: Playbook::Props::HashProp,
|
8
8
|
default: {}
|
9
9
|
prop :tag, type: Playbook::Props::Enum,
|
10
10
|
values: %w[div section footer header article aside main nav],
|
@@ -1,25 +1,29 @@
|
|
1
|
-
export const showElement = (elem:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
export const showElement = (elem:any) => {
|
2
|
+
elem.style.display = 'block';
|
3
|
+
const height = elem.scrollHeight + 'px'; // Get its height
|
4
|
+
elem.style.height = height; // Update the max-height
|
5
|
+
elem.classList.add('is-visible');
|
6
|
+
elem.style.overflow = "hidden"
|
7
|
+
// Once the transition is complete, remove the inline max-height so the content can scale responsively
|
8
|
+
window.setTimeout(() => {
|
9
|
+
elem.style.height = '';
|
10
|
+
elem.style.overflow = "visible"
|
11
|
+
}, 300);
|
12
|
+
};
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
export const hideElement = (elem:any) => {
|
15
|
+
elem.style.height = elem.scrollHeight + 'px';
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
window.setTimeout(() => {
|
18
|
+
elem.style.height = '0';
|
19
|
+
elem.style.paddingTop = '0';
|
20
|
+
elem.style.paddingBottom = '0';
|
21
|
+
elem.style.overflow = "hidden"
|
22
|
+
}, 1);
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
};
|
24
|
+
// When the transition is complete, hide it
|
25
|
+
window.setTimeout(() => {
|
26
|
+
elem.classList.remove('is-visible');
|
27
|
+
elem.style.overflow = ""
|
28
|
+
}, 300);
|
29
|
+
};
|
@@ -33,10 +33,12 @@ export default class PbCollapsible extends PbEnhancedElement {
|
|
33
33
|
const height = getHeight()
|
34
34
|
elem.classList.add('is-visible')
|
35
35
|
elem.style.height = height // Update the max-height
|
36
|
+
elem.style.overflow = "hidden"
|
36
37
|
|
37
38
|
// Once the transition is complete, remove the inline max-height so the content can scale responsively
|
38
39
|
window.setTimeout(() => {
|
39
40
|
elem.style.height = ''
|
41
|
+
elem.style.overflow = ""
|
40
42
|
}, 300)
|
41
43
|
}
|
42
44
|
|
@@ -48,11 +50,13 @@ export default class PbCollapsible extends PbEnhancedElement {
|
|
48
50
|
elem.style.height = '0'
|
49
51
|
elem.style.paddingTop = '0'
|
50
52
|
elem.style.paddingBottom = '0'
|
53
|
+
elem.style.overflow = "hidden"
|
51
54
|
}, 1)
|
52
55
|
|
53
56
|
// When the transition is complete, hide it
|
54
57
|
window.setTimeout(() => {
|
55
58
|
elem.classList.remove('is-visible')
|
59
|
+
elem.style.overflow = ""
|
56
60
|
}, 300)
|
57
61
|
}
|
58
62
|
|
@@ -6,10 +6,10 @@ module Playbook
|
|
6
6
|
prop :align, type: Playbook::Props::Enum,
|
7
7
|
values: %w[left center right],
|
8
8
|
default: "left"
|
9
|
-
prop :stat_change, type: Playbook::Props::
|
9
|
+
prop :stat_change, type: Playbook::Props::HashProp,
|
10
10
|
default: {}
|
11
11
|
prop :stat_label
|
12
|
-
prop :stat_value, type: Playbook::Props::
|
12
|
+
prop :stat_value, type: Playbook::Props::HashProp,
|
13
13
|
default: {}
|
14
14
|
|
15
15
|
def formatted_stat_value
|
@@ -49,7 +49,7 @@ type DatePickerProps = {
|
|
49
49
|
} & GlobalProps
|
50
50
|
|
51
51
|
const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
52
|
-
if (props.plugins) deprecatedProps(
|
52
|
+
if (props.plugins) deprecatedProps()
|
53
53
|
|
54
54
|
const {
|
55
55
|
allowInput = false,
|
@@ -34,9 +34,9 @@ module Playbook
|
|
34
34
|
default: false
|
35
35
|
prop :label, type: Playbook::Props::String,
|
36
36
|
default: "Date Picker"
|
37
|
-
prop :input_aria, type: Playbook::Props::
|
37
|
+
prop :input_aria, type: Playbook::Props::HashProp,
|
38
38
|
default: {}
|
39
|
-
prop :input_data, type: Playbook::Props::
|
39
|
+
prop :input_data, type: Playbook::Props::HashProp,
|
40
40
|
default: {}
|
41
41
|
prop :max_date, type: Playbook::Props::String
|
42
42
|
prop :min_date, type: Playbook::Props::String
|
@@ -8,7 +8,6 @@ type FlexItemPropTypes = {
|
|
8
8
|
grow?: boolean,
|
9
9
|
shrink?: boolean,
|
10
10
|
className?: string,
|
11
|
-
// overflow?: "auto" | "hidden" | "initial" | "inherit" | "scroll" | "visible",
|
12
11
|
order?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 'first' | 'none',
|
13
12
|
alignSelf?: "start" | "end" | "center" | "stretch" | null,
|
14
13
|
displayFlex?: boolean
|
@@ -33,7 +33,7 @@
|
|
33
33
|
margin: 0;
|
34
34
|
}
|
35
35
|
&[class*="_active"] {
|
36
|
-
|
36
|
+
>.pb_collapsible_main_kit {
|
37
37
|
background-color: $active_light;
|
38
38
|
}
|
39
39
|
}
|
@@ -46,7 +46,7 @@
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
&[class*="_active"] {
|
49
|
-
|
49
|
+
>.pb_collapsible_main_kit {
|
50
50
|
background-color: mix($white, $card_dark, 20%);
|
51
51
|
.pb_nav_list_item_text_collapsible,
|
52
52
|
svg {
|
@@ -63,7 +63,7 @@
|
|
63
63
|
.pb_collapsible_kit {
|
64
64
|
&[class*="_active"] {
|
65
65
|
background-color: unset;
|
66
|
-
|
66
|
+
>.pb_collapsible_main_kit {
|
67
67
|
background-color: $primary;
|
68
68
|
border-radius: $border_rad_heavier;
|
69
69
|
.pb_nav_list_item_text_collapsible,
|
@@ -94,7 +94,7 @@
|
|
94
94
|
&.dark {
|
95
95
|
.pb_collapsible_kit {
|
96
96
|
&[class*="_active"] {
|
97
|
-
|
97
|
+
>.pb_collapsible_main_kit {
|
98
98
|
background-color: $primary;
|
99
99
|
}
|
100
100
|
.pb_nav_list_item_link {
|
@@ -112,7 +112,7 @@
|
|
112
112
|
.pb_collapsible_kit {
|
113
113
|
&[class*="_active"] {
|
114
114
|
background-color: unset;
|
115
|
-
|
115
|
+
>.pb_collapsible_main_kit {
|
116
116
|
background-color: $active_light;
|
117
117
|
border-radius: $border_rad_heavier;
|
118
118
|
.pb_nav_list_item_text_collapsible,
|
@@ -128,7 +128,7 @@
|
|
128
128
|
&.dark {
|
129
129
|
.pb_collapsible_kit {
|
130
130
|
&[class*="_active"] {
|
131
|
-
|
131
|
+
>.pb_collapsible_main_kit {
|
132
132
|
background-color: mix($white, $card_dark, 20%) !important;
|
133
133
|
.pb_nav_list_item_text_collapsible,
|
134
134
|
svg {
|
@@ -4,7 +4,7 @@ module Playbook
|
|
4
4
|
module PbPassphrase
|
5
5
|
class Passphrase < Playbook::KitBase
|
6
6
|
prop :confirmation, type: Playbook::Props::Boolean, default: false
|
7
|
-
prop :input_props, type: Playbook::Props::
|
7
|
+
prop :input_props, type: Playbook::Props::HashProp, default: {}
|
8
8
|
prop :label
|
9
9
|
prop :show_tips_below, type: Playbook::Props::Enum,
|
10
10
|
values: %w[always xs sm md lg xl],
|
@@ -11,7 +11,7 @@ module Playbook
|
|
11
11
|
default: false
|
12
12
|
prop :error, type: Playbook::Props::Boolean,
|
13
13
|
default: false
|
14
|
-
prop :input_options, type: Playbook::Props::
|
14
|
+
prop :input_options, type: Playbook::Props::HashProp,
|
15
15
|
default: {}
|
16
16
|
prop :name, type: Playbook::Props::String,
|
17
17
|
default: "radio_name"
|
@@ -6,7 +6,7 @@ require "action_view"
|
|
6
6
|
module Playbook
|
7
7
|
module PbSelect
|
8
8
|
class Select < Playbook::KitBase
|
9
|
-
prop :attributes, type: Playbook::Props::
|
9
|
+
prop :attributes, type: Playbook::Props::HashProp,
|
10
10
|
default: {}
|
11
11
|
prop :blank_selection
|
12
12
|
prop :compact, type: Playbook::Props::Boolean, default: false
|
@@ -10,7 +10,7 @@ module Playbook
|
|
10
10
|
prop :type, type: Playbook::Props::Enum,
|
11
11
|
values: %w[user retail inbound outbound prospecting events referral],
|
12
12
|
default: "inbound"
|
13
|
-
prop :user, type: Playbook::Props::
|
13
|
+
prop :user, type: Playbook::Props::HashProp, default: {}
|
14
14
|
|
15
15
|
def type_text
|
16
16
|
if type == "user" || (type == "referral" && user.present?)
|
@@ -2,27 +2,31 @@
|
|
2
2
|
<thead>
|
3
3
|
<tr>
|
4
4
|
<%= pb_rails("table/table_header", props: {
|
5
|
-
|
6
|
-
|
5
|
+
text: "Territory",
|
6
|
+
id: "territory",
|
7
7
|
sort_menu: [
|
8
|
-
{ item: "
|
9
|
-
{ item: "
|
8
|
+
{ item: "Territory", link: "?sort=territory_desc", active: params["sort"] == "territory_desc", direction: "desc" },
|
9
|
+
{ item: "Territory", link: "?sort=territory_asc", active: params["sort"] == "territory_asc", direction: "asc" }
|
10
10
|
],
|
11
11
|
}) %>
|
12
12
|
<%= pb_rails("table/table_header", props: {
|
13
|
-
|
14
|
-
|
13
|
+
id: "name",
|
14
|
+
text: "Full Name",
|
15
|
+
colspan: 2,
|
15
16
|
sort_menu: [
|
16
|
-
{ item: "
|
17
|
-
{ item: "
|
17
|
+
{ item: "First Name Descending", link: "?sort=firstname_desc", active: params["sort"] == "firstname_desc", direction: "desc" },
|
18
|
+
{ item: "First Name Ascending", link: "?sort=firstname_asc", active: params["sort"] == "firstname_asc", direction: "asc" },
|
19
|
+
{ item: "Last Name Descending", link: "?sort=lastname_desc", active: params["sort"] == "lastname_desc", direction: "desc" },
|
20
|
+
{ item: "Last Name Ascending", link: "?sort=lastname_asc", active: params["sort"] == "lastname_asc", direction: "asc" }
|
18
21
|
],
|
19
22
|
}) %>
|
20
23
|
<%= pb_rails("table/table_header", props: {
|
21
|
-
text: "
|
22
|
-
id: "
|
24
|
+
text: "Age",
|
25
|
+
id: "age",
|
26
|
+
sort_dropdown: true,
|
23
27
|
sort_menu: [
|
24
|
-
{ item: "
|
25
|
-
{ item: "
|
28
|
+
{ item: "Age Descending", link: "?sort=age_desc", active: params["sort"] == "age_desc", direction: "desc" },
|
29
|
+
{ item: "Age Ascending", link: "?sort=age_asc", active: params["sort"] == "age_asc", direction: "asc" }
|
26
30
|
],
|
27
31
|
}) %>
|
28
32
|
<%= pb_rails("table/table_header", props: { text: "Job Title" }) %>
|
@@ -30,25 +34,25 @@
|
|
30
34
|
</thead>
|
31
35
|
<tbody>
|
32
36
|
<tr>
|
33
|
-
<td>
|
34
|
-
<td>Name
|
35
|
-
<td>
|
36
|
-
<td>
|
37
|
-
<td>
|
37
|
+
<td>Ter 1</td>
|
38
|
+
<td>First Name 1</td>
|
39
|
+
<td>Last Name 1</td>
|
40
|
+
<td>Age 1</td>
|
41
|
+
<td>Job 1</td>
|
38
42
|
</tr>
|
39
43
|
<tr>
|
40
|
-
<td>
|
41
|
-
<td>Name 2</td>
|
42
|
-
<td>
|
43
|
-
<td>
|
44
|
-
<td>
|
44
|
+
<td>Ter 2</td>
|
45
|
+
<td>First Name 2</td>
|
46
|
+
<td>Last Name 2</td>
|
47
|
+
<td>Age 2</td>
|
48
|
+
<td>Job 2</td>
|
45
49
|
</tr>
|
46
50
|
<tr>
|
47
|
-
<td>
|
48
|
-
<td>Name
|
49
|
-
<td>
|
50
|
-
<td>
|
51
|
-
<td>
|
51
|
+
<td>Ter 3</td>
|
52
|
+
<td>First Name 3</td>
|
53
|
+
<td>Last Name 3</td>
|
54
|
+
<td>Age 3</td>
|
55
|
+
<td>Job 3</td>
|
52
56
|
</tr>
|
53
57
|
</tbody>
|
54
58
|
<% end %>
|
@@ -1 +1,8 @@
|
|
1
|
-
|
1
|
+
The `table_header` subcomponent creates `<th>` elements and optionally accepts:
|
2
|
+
|
3
|
+
* `colspan` (number) for setting column span
|
4
|
+
* `sort_menu` accepts sort options as an array of `item` objects.
|
5
|
+
presence of `sort_menu` enables the sort link within the header
|
6
|
+
* `sort_dropdown` (boolean) optionally declares that (true) clicking a header's sort link opens a dropdown of sort options, or (false) each sort link click cycles through available sort_menu items in the order they are passed
|
7
|
+
* passing a valid `colspan` will render sort options within a dropdown by default, without requiring `sort_dropdown` explicitly. Alternatively, the default sort dropdown can be prevented on headers with `colspan` by setting `sort_dropdown: false`, which reverts the column to sorting to multi-click default (each click of the sort link cycles through the available sort_menu items in the order they are passed)
|
8
|
+
* `id` (string) is required for headers that have a dropdown (for popover reference); otherwise they are optional
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
$text_align_values: (
|
3
2
|
start: start,
|
4
3
|
end: end,
|
@@ -22,6 +21,15 @@ $text_align_values: (
|
|
22
21
|
}
|
23
22
|
}
|
24
23
|
|
24
|
+
.pb_th_link:hover {
|
25
|
+
background-color: rgba($primary, 0.03);
|
26
|
+
color: $primary !important;
|
27
|
+
}
|
28
|
+
|
29
|
+
.pb_th_link, .pb_th_nolink{
|
30
|
+
padding: $space_xxs;
|
31
|
+
}
|
32
|
+
|
25
33
|
[class^=pb_table] {
|
26
34
|
thead {
|
27
35
|
[class^=pb_th_active] {
|
@@ -29,3 +37,14 @@ $text_align_values: (
|
|
29
37
|
}
|
30
38
|
}
|
31
39
|
}
|
40
|
+
|
41
|
+
[class*="pb_table_header_dropdown"][class*="_vertical"] {
|
42
|
+
&[class*="_normal"] {
|
43
|
+
[class*="pb_nav_list_kit_item"][class*="pb_nav_list_item"] {
|
44
|
+
&[class*="_link"] {
|
45
|
+
border-left-width: 0px;
|
46
|
+
background-color: #fff !important;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
@@ -4,61 +4,35 @@
|
|
4
4
|
class: object.classname,
|
5
5
|
data: object.data,
|
6
6
|
id: "pb-th#{object.id}") do %>
|
7
|
-
<%
|
8
|
-
|
9
|
-
<%= pb_rails("flex", props:{ align: object.align_content }) do %>
|
10
|
-
<%= content.presence || content_tag(:span, item[:item], class: "pb_th_active") %>
|
11
|
-
<span class="pb_th_active">
|
12
|
-
<%= pb_rails("icon", props: { icon: object.sort_icon(item[:direction]),
|
13
|
-
fixed_width: true,
|
14
|
-
classname: "pb_th_active",
|
15
|
-
padding_left: "xs" }) %>
|
16
|
-
</span>
|
17
|
-
<% end %>
|
18
|
-
<% end %>
|
19
|
-
<% end %>
|
20
|
-
<% if object.sort_menu.all? { |item| item[:active] == false } %>
|
21
|
-
<%= pb_rails("flex", props:{ align: object.align_content }) do %>
|
7
|
+
<% unless sorting_style? %>
|
8
|
+
<%= pb_rails("flex", props:{ align: object.align_content, justify: object.justify_sort_icon, classname: "pb_th_nolink" }) do %>
|
22
9
|
<%= content.presence || object.text %>
|
23
|
-
<%= pb_rails("icon", props: { icon: "arrow-up-arrow-down",
|
24
|
-
fixed_width: true,
|
25
|
-
padding_left: "xs" }) %>
|
26
10
|
<% end %>
|
27
11
|
<% else %>
|
28
|
-
<%=
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
12
|
+
<%= link_to next_link, style: link_style do %>
|
13
|
+
<%= pb_rails("flex", props:{ align: object.align_content, justify: object.justify_sort_icon, classname: "pb_th_link" }) do %>
|
14
|
+
<%= content.presence || object.text %>
|
15
|
+
<% if sorting_style? %>
|
16
|
+
<%= pb_rails("icon", props: { icon: object.sort_icon(active_item[:direction], active_item[:active]),
|
17
|
+
fixed_width: true,
|
18
|
+
classname: active_item.any? ? "pb_th_active" : "",
|
19
|
+
padding_left: "xs" }) %>
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
<% if use_dropdown_select %>
|
24
|
+
<%= pb_rails("popover", props: { classname: "pb_filter_sort_menu",
|
25
|
+
close_on_click: "outside",
|
26
|
+
trigger_element_id: "pb-th#{object.id}",
|
27
|
+
tooltip_id: "sort-filter-btn-tooltip#{object.id}",
|
28
|
+
position: object.placement ,
|
29
|
+
padding: 'none'}) do %>
|
30
|
+
<%= pb_rails("nav", props: {classname: "pb_table_header_dropdown"}) do %>
|
31
|
+
<% object.sort_menu.each do |item| %>
|
32
|
+
<%= pb_rails("nav/item", props: { text: item[:item], link: item[:link], icon_right: sort_icon(item[:direction], item[:active]), active: item[:active] }) %>
|
46
33
|
<% end %>
|
47
34
|
<% end %>
|
48
35
|
<% end %>
|
49
36
|
<% end %>
|
50
37
|
<% end %>
|
51
38
|
<% end %>
|
52
|
-
<% if object.sort_menu != [{}] && object.colspan == 1 %>
|
53
|
-
<script>
|
54
|
-
document.addEventListener("DOMContentLoaded", function() {
|
55
|
-
var thId = `<%= "#pb-th#{object.id}" %>`
|
56
|
-
var firstLink = `<%= next_link %>`
|
57
|
-
var thElement = document.querySelector(thId);
|
58
|
-
|
59
|
-
thElement.addEventListener("click", function() {
|
60
|
-
window.location.href = firstLink;
|
61
|
-
});
|
62
|
-
});
|
63
|
-
</script>
|
64
|
-
<% end %>
|
@@ -9,15 +9,20 @@ module Playbook
|
|
9
9
|
prop :align_content, type: Playbook::Props::Enum,
|
10
10
|
values: %w[start center end stretch baseline none],
|
11
11
|
default: "center"
|
12
|
+
prop :justify_sort_icon, type: Playbook::Props::Enum,
|
13
|
+
values: %w[start center end stretch around between evenly none],
|
14
|
+
default: "between"
|
12
15
|
prop :colspan, type: Playbook::Props::Number,
|
13
16
|
default: 1
|
14
17
|
prop :placement, type: Playbook::Props::Enum,
|
15
18
|
values: %w[top bottom left right top-start top-end bottom-start bottom-end right-start right-end left-start left-end],
|
16
|
-
default: "bottom-
|
19
|
+
default: "bottom-end"
|
17
20
|
prop :sort_menu, type: Playbook::Props::HashArray,
|
18
21
|
default: [{}]
|
19
22
|
prop :text, type: Playbook::Props::String,
|
20
23
|
default: ""
|
24
|
+
prop :sort_dropdown, type: Playbook::Props::Boolean,
|
25
|
+
default: false
|
21
26
|
|
22
27
|
def classname
|
23
28
|
generate_classname("pb_table_header_kit", align_class)
|
@@ -30,23 +35,46 @@ module Playbook
|
|
30
35
|
def next_link
|
31
36
|
return sort_menu[0][:link] if sort_menu.all? { |item| item[:active] == false }
|
32
37
|
|
38
|
+
link = ""
|
39
|
+
|
33
40
|
sort_menu.each_with_index do |item, index|
|
34
41
|
if item[:active] == true
|
35
42
|
next_index = (index + 1) % sort_menu.length
|
36
|
-
sort_menu[next_index][:link]
|
43
|
+
link = sort_menu[next_index][:link]
|
37
44
|
end
|
38
45
|
end
|
46
|
+
link
|
47
|
+
end
|
48
|
+
|
49
|
+
def sorting_style?
|
50
|
+
sort_menu != [{}]
|
51
|
+
end
|
52
|
+
|
53
|
+
def use_dropdown_select
|
54
|
+
sort_menu != [{}] && (object.colspan > 1 || sort_dropdown)
|
39
55
|
end
|
40
56
|
|
41
|
-
def sort_icon(direction)
|
57
|
+
def sort_icon(direction, active)
|
42
58
|
case direction
|
43
59
|
when "asc"
|
44
|
-
"sort-amount-up"
|
60
|
+
active ? "sort-amount-up" : ""
|
45
61
|
when "desc"
|
46
|
-
"sort-amount-down"
|
62
|
+
active ? "sort-amount-down" : ""
|
47
63
|
else
|
48
|
-
""
|
64
|
+
"arrow-up-arrow-down"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def link_style
|
69
|
+
active_item.any? ? "" : "color: #687887;"
|
70
|
+
end
|
71
|
+
|
72
|
+
def active_item
|
73
|
+
active_item = {}
|
74
|
+
sort_menu.each do |item|
|
75
|
+
active_item = item if item[:active] == true
|
49
76
|
end
|
77
|
+
active_item
|
50
78
|
end
|
51
79
|
end
|
52
80
|
end
|