playbook_ui 16.0.0 → 16.1.0.pre.alpha.PLAY2744dropdownquickpickpt113851
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/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.md +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading_rails.html.erb +64 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading_rails.md +18 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +51 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +34 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +19 -0
- data/app/pb_kits/playbook/pb_background/docs/_background_responsive.jsx +30 -0
- data/app/pb_kits/playbook/pb_background/docs/_background_responsive.md +1 -0
- data/app/pb_kits/playbook/pb_background/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_background/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +6 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +37 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection_rails.md +3 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection_react.md +3 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_clearable.html.erb +52 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_clearable.jsx +72 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_clearable.md +5 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height.jsx +33 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height_rails.html.erb +20 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height_rails.md +8 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height_react.md +8 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_placeholder.html.erb +9 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_placeholder.jsx +33 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_placeholder.md +3 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +6 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +4 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +2 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +6 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +94 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +5 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +59 -4
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +3 -0
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +2 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_with_required_indicator.html.erb +3 -1
- data/app/pb_kits/playbook/pb_icon/icon.rb +6 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +7 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled_options.md +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_input_display.html.erb +74 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_input_display.jsx +87 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_input_display.md +3 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_disabled.html.erb +135 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_disabled.jsx +147 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_disabled.md +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +35 -31
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.test.jsx +402 -27
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select_options.tsx +1 -0
- data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_with_tooltip.html.erb +30 -0
- data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_with_tooltip.jsx +1 -1
- data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_with_tooltip.md +1 -1
- data/app/pb_kits/playbook/pb_multiple_users/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +51 -7
- data/app/pb_kits/playbook/pb_multiple_users/multiple_users.rb +1 -0
- data/app/pb_kits/playbook/pb_radio/_radio.scss +8 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +33 -6
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_required_indicator.jsx +35 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_required_indicator.md +3 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.html.erb +10 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.jsx +21 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.md +3 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +5 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.test.js +33 -18
- data/app/pb_kits/playbook/pb_table/docs/_sections.yml +68 -0
- data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +29 -11
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_input_options.html.erb +39 -0
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_input_options.md +3 -0
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_required_indicator.html.erb +5 -0
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_required_indicator.jsx +25 -0
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_required_indicator.md +3 -0
- data/app/pb_kits/playbook/pb_textarea/docs/example.yml +4 -1
- data/app/pb_kits/playbook/pb_textarea/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_textarea/index.ts +12 -5
- data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +10 -10
- data/app/pb_kits/playbook/pb_textarea/textarea.rb +30 -0
- data/app/pb_kits/playbook/pb_textarea/textarea.test.js +18 -1
- data/app/pb_kits/playbook/utilities/test/globalProps/borderRadius.test.js +33 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/bottom.test.js +60 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/cursor.test.js +42 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/dark.test.js +33 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/gap.test.js +87 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/globalProps.integration.test.js +936 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/height.test.js +68 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/htmlOptions.test.js +510 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/left.test.js +60 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/lineHeight.test.js +33 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/margin.test.js +95 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/numberSpacing.test.js +33 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/overflow.test.js +68 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/padding.test.js +95 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/position.test.js +33 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/right.test.js +60 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/shadow.test.js +33 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/textAlign.test.js +41 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/top.test.js +60 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/verticalAlign.test.js +40 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/width.test.js +66 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/zIndex.test.js +50 -0
- data/dist/chunks/{_pb_line_graph-ByQFYuFO.js → _pb_line_graph-BgKF_zz1.js} +1 -1
- data/dist/chunks/_typeahead-B9a6ZsEP.js +1 -0
- data/dist/chunks/{globalProps-D6R2eJnp.js → globalProps-BhVYCqRf.js} +1 -1
- data/dist/chunks/lib-DD34ZrWL.js +29 -0
- data/dist/chunks/vendor.js +3 -3
- 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 +2 -2
- metadata +62 -6
- data/dist/chunks/_typeahead-Bl8_gWmz.js +0 -1
- data/dist/chunks/lib-C8h70OzX.js +0 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a651c96ee595f7b6a08eea9b91af25f3ac942c55d128dbec4123fa1c0412ec2d
|
|
4
|
+
data.tar.gz: 29e8e76eac8ade8f52d4aa1a6a1af0d7c13e309a08b91c46e7722bbe5035e8ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 335b54761f101a5e30c4622868911d79b0bf396b6d54f6337a807dd9b146face6bc099f0d5d93286ba0fe3115116e749b792313a2ae683ab395372a1e28f57b1
|
|
7
|
+
data.tar.gz: 485f67ff1f34460b1f9f644f96908222a6b543f9ec0b61c7e3b8e0e03848586426b3ea577045b8dd82446926dbd7d5fcad1dca4eb42bce584c9260e5c1d7eb2e
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
<% if content.present? %>
|
|
12
12
|
<% content.presence %>
|
|
13
13
|
<% else %>
|
|
14
|
-
<%= pb_rails("advanced_table/table_header", props: { table_id: object.id, column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, show_actions_bar: object.show_actions_bar }) %>
|
|
15
|
-
<%= pb_rails("advanced_table/table_body", props: { table_id: object.id, table_data: object.table_data, column_definitions: object.column_definitions, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, enable_toggle_expansion: object.enable_toggle_expansion, row_styling: object.row_styling }) %>
|
|
14
|
+
<%= pb_rails("advanced_table/table_header", props: { table_id: object.id, column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, show_actions_bar: object.show_actions_bar, inline_row_loading: object.inline_row_loading, persist_toggle_expansion_button: object.persist_toggle_expansion_button, table_data: object.table_data }) %>
|
|
15
|
+
<%= pb_rails("advanced_table/table_body", props: { table_id: object.id, table_data: object.table_data, column_definitions: object.column_definitions, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, enable_toggle_expansion: object.enable_toggle_expansion, row_styling: object.row_styling, inline_row_loading: object.inline_row_loading }) %>
|
|
16
16
|
<% end %>
|
|
17
17
|
<% end %>
|
|
18
18
|
<% end %>
|
|
@@ -33,6 +33,10 @@ module Playbook
|
|
|
33
33
|
default: false
|
|
34
34
|
prop :row_styling, type: Playbook::Props::Array,
|
|
35
35
|
default: []
|
|
36
|
+
prop :inline_row_loading, type: Playbook::Props::Boolean,
|
|
37
|
+
default: false
|
|
38
|
+
prop :persist_toggle_expansion_button, type: Playbook::Props::Boolean,
|
|
39
|
+
default: false
|
|
36
40
|
|
|
37
41
|
def classname
|
|
38
42
|
additional_classes = [
|
|
@@ -6,9 +6,9 @@ In the first Advanced Table in this code example, 2021 has an empty children arr
|
|
|
6
6
|
This prop is set to `false` by default.
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
###
|
|
9
|
+
### persistToggleExpansionButton
|
|
10
10
|
The `persistToggleExpansionButton` is a boolean prop that renders the toggle-all icon in the top left header cell for complex datasets with empty `children` arrays and advanced querying logic explained in the preceeding doc example. Your logic may require an additional query helper file to update data specifically from requerying via toggle all buttons.
|
|
11
11
|
|
|
12
12
|
In the second and third Advanced Tables in this code example, all 3 rows have empty children arrays. The second Advanced Table demonstrates that the toggle all button does not render (prior to an initial row expansion) without `persistToggleExpansionButton` in place. The third Advanced Table shows the toggle all button due to `persistToggleExpansionButton`.
|
|
13
13
|
|
|
14
|
-
This prop is set to false by default and should only be used in conjunction with `inlineRowLoading`.
|
|
14
|
+
This prop is set to `false` by default and should only be used in conjunction with `inlineRowLoading`.
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading_rails.html.erb
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<% column_definitions = [
|
|
2
|
+
{
|
|
3
|
+
accessor: "year",
|
|
4
|
+
label: "Year",
|
|
5
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
accessor: "newEnrollments",
|
|
9
|
+
label: "New Enrollments",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
accessor: "scheduledMeetings",
|
|
13
|
+
label: "Scheduled Meetings",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
accessor: "attendanceRate",
|
|
17
|
+
label: "Attendance Rate",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
accessor: "completedClasses",
|
|
21
|
+
label: "Completed Classes",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
accessor: "classCompletionRate",
|
|
25
|
+
label: "Class Completion Rate",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
accessor: "graduatedStudents",
|
|
29
|
+
label: "Graduated Students",
|
|
30
|
+
}
|
|
31
|
+
] %>
|
|
32
|
+
|
|
33
|
+
<%= pb_rails("caption", props: { text: "Inline Row Loading - Demonstrated in Row 1 (Rows 2 and 3 have data)" }) %>
|
|
34
|
+
|
|
35
|
+
<%= pb_rails("advanced_table", props: {
|
|
36
|
+
id: "inline-loading-table-1",
|
|
37
|
+
table_data: @table_data_inline_loading,
|
|
38
|
+
column_definitions: column_definitions,
|
|
39
|
+
enable_toggle_expansion: "all",
|
|
40
|
+
inline_row_loading: true,
|
|
41
|
+
margin_bottom: "md"
|
|
42
|
+
}) %>
|
|
43
|
+
|
|
44
|
+
<%= pb_rails("caption", props: { text: "Inline Row Loading with No Subrow Data - All Rows Display Inline Row Loading and the Toggle All Button is not rendered" }) %>
|
|
45
|
+
|
|
46
|
+
<%= pb_rails("advanced_table", props: {
|
|
47
|
+
id: "inline-loading-table-2",
|
|
48
|
+
table_data: @table_data_inline_loading_empty_children,
|
|
49
|
+
column_definitions: column_definitions,
|
|
50
|
+
enable_toggle_expansion: "all",
|
|
51
|
+
inline_row_loading: true,
|
|
52
|
+
margin_bottom: "md"
|
|
53
|
+
}) %>
|
|
54
|
+
|
|
55
|
+
<%= pb_rails("caption", props: { text: "Inline Row Loading and Persist Toggle Expansion Button with No Subrow Data - All Rows Display Inline Row Loading and the Toggle All Button is rendered" }) %>
|
|
56
|
+
|
|
57
|
+
<%= pb_rails("advanced_table", props: {
|
|
58
|
+
id: "inline-loading-table-3",
|
|
59
|
+
table_data: @table_data_inline_loading_empty_children,
|
|
60
|
+
column_definitions: column_definitions,
|
|
61
|
+
enable_toggle_expansion: "all",
|
|
62
|
+
inline_row_loading: true,
|
|
63
|
+
persist_toggle_expansion_button: true
|
|
64
|
+
}) %>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
### inline_row_loading
|
|
2
|
+
By default, the kit assumes that the initial dataset is complete, rendering expansion controls only when children are present. If, however, you want to implement lazy-loading patterns where children are fetched only when a parent is expanded, use the `inline_row_loading` prop.
|
|
3
|
+
|
|
4
|
+
When `inline_row_loading` is set to `true`:
|
|
5
|
+
- Expansion controls are rendered for rows with empty `children` arrays (you must pass `children: []` to any row that will have children loaded later)
|
|
6
|
+
- When such a row is expanded, an inline loading indicator appears until the child data is loaded
|
|
7
|
+
- This enables lazy-loading patterns without one-off hacks
|
|
8
|
+
|
|
9
|
+
In the first table above, row "2021" has an empty `children` array. Click to expand it and see the inline loading state. Rows 2 and 3 have actual child data.
|
|
10
|
+
|
|
11
|
+
This prop is set to `false` by default.
|
|
12
|
+
|
|
13
|
+
### persist_toggle_expansion_button
|
|
14
|
+
The `persist_toggle_expansion_button` is a boolean prop that renders the toggle-all icon in the top left header cell for complex datasets with empty `children` arrays and advanced querying logic explained in the preceding doc example. Your logic may require an additional query helper file to update data specifically from requerying via toggle all buttons.
|
|
15
|
+
|
|
16
|
+
In the second and third Advanced Tables in this code example, all 3 rows have empty children arrays. The second Advanced Table demonstrates that the toggle all button does not render (prior to an initial row expansion) without `persist_toggle_expansion_button` in place. The third Advanced Table shows the toggle all button due to `persist_toggle_expansion_button`.
|
|
17
|
+
|
|
18
|
+
This prop is set to `false` by default and should only be used in conjunction with `inline_row_loading`.
|
|
@@ -29,6 +29,7 @@ examples:
|
|
|
29
29
|
- advanced_table_background_control_rails: Column Styling Background Color
|
|
30
30
|
- advanced_table_background_colors_rails: Column Styling Individual Cell Background Color
|
|
31
31
|
- advanced_table_column_border_color_rails: Column Group Border Color
|
|
32
|
+
- advanced_table_inline_row_loading_rails: Inline Row Loading
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
react:
|
|
@@ -25,6 +25,8 @@ module Playbook
|
|
|
25
25
|
default: false
|
|
26
26
|
prop :row_styling, type: Playbook::Props::Array,
|
|
27
27
|
default: []
|
|
28
|
+
prop :inline_row_loading, type: Playbook::Props::Boolean,
|
|
29
|
+
default: false
|
|
28
30
|
|
|
29
31
|
def flatten_columns(columns)
|
|
30
32
|
columns.flat_map do |col|
|
|
@@ -69,7 +71,24 @@ module Playbook
|
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
# Additional class and data attributes needed for toggle logic
|
|
72
|
-
output << pb_rails("advanced_table/table_row", props: { table_id: table_id, row: row, column_definitions: leaf_columns, depth: current_depth, collapsible_trail: collapsible_trail, classname: additional_classes, table_data_attributes: current_data_attributes, responsive: responsive, loading: loading, selectable_rows: selectable_rows, row_id: row[:id], enable_toggle_expansion: enable_toggle_expansion, row_styling: row_styling, last_row: last_row, immediate_parent_row_id: immediate_parent_row_id })
|
|
74
|
+
output << pb_rails("advanced_table/table_row", props: { table_id: table_id, row: row, column_definitions: leaf_columns, depth: current_depth, collapsible_trail: collapsible_trail, classname: additional_classes, table_data_attributes: current_data_attributes, responsive: responsive, loading: loading, selectable_rows: selectable_rows, row_id: row[:id], enable_toggle_expansion: enable_toggle_expansion, row_styling: row_styling, last_row: last_row, immediate_parent_row_id: immediate_parent_row_id, inline_row_loading: inline_row_loading })
|
|
75
|
+
|
|
76
|
+
# Render inline loading row when inline_row_loading is enabled and row has empty children
|
|
77
|
+
if inline_row_loading
|
|
78
|
+
children = row_children_for(row)
|
|
79
|
+
if children.is_a?(::Array) && children.empty?
|
|
80
|
+
max_depth = cell_accessors_length(column_definitions)
|
|
81
|
+
if current_depth < max_depth
|
|
82
|
+
loading_row_data_attributes = {
|
|
83
|
+
advanced_table_content: "#{new_ancestor_ids.join('-')}-loading",
|
|
84
|
+
row_depth: current_depth + 1,
|
|
85
|
+
row_parent: "#{table_id}_#{row.object_id}",
|
|
86
|
+
inline_loading_row: true,
|
|
87
|
+
}
|
|
88
|
+
output << render_inline_loading_row(leaf_columns.length, current_depth, loading_row_data_attributes)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
73
92
|
|
|
74
93
|
if row[:children].present?
|
|
75
94
|
row[:children].each do |child_row|
|
|
@@ -104,6 +123,37 @@ module Playbook
|
|
|
104
123
|
""
|
|
105
124
|
end
|
|
106
125
|
|
|
126
|
+
# 3 helper methods for inline row loading
|
|
127
|
+
def render_inline_loading_row(column_count, depth, data_attributes)
|
|
128
|
+
padding_left = depth.zero? ? "0.5em" : "#{(depth + 1) * 2}em"
|
|
129
|
+
|
|
130
|
+
content_tag(:tr, class: "toggle-content inline-loading-row", data: data_attributes) do
|
|
131
|
+
content_tag(:td, colspan: column_count, style: "padding-left: #{padding_left}") do
|
|
132
|
+
pb_rails("loading_inline")
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def row_children_for(row)
|
|
138
|
+
if row.respond_to?(:children)
|
|
139
|
+
row.children
|
|
140
|
+
elsif row.respond_to?(:[])
|
|
141
|
+
row[:children] || row["children"]
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def cell_accessors_length(col_defs)
|
|
146
|
+
first_col = col_defs.first
|
|
147
|
+
return 0 unless first_col
|
|
148
|
+
|
|
149
|
+
accessors = if first_col.respond_to?(:cellAccessors)
|
|
150
|
+
first_col.cellAccessors
|
|
151
|
+
elsif first_col.respond_to?(:[])
|
|
152
|
+
first_col[:cellAccessors] || first_col["cellAccessors"]
|
|
153
|
+
end
|
|
154
|
+
accessors&.length || 0
|
|
155
|
+
end
|
|
156
|
+
|
|
107
157
|
private
|
|
108
158
|
|
|
109
159
|
def has_grouped_headers?
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<%= object.render_select_all_checkbox %>
|
|
15
15
|
<% end %>
|
|
16
16
|
<% end %>
|
|
17
|
-
<% if object.
|
|
17
|
+
<% if object.show_toggle_all_button? %>
|
|
18
18
|
<% if loading %>
|
|
19
19
|
<div class="<%= object.loading ? 'loading-toggle-icon' : '' %>"></div>
|
|
20
20
|
<% else %>
|
|
@@ -19,6 +19,12 @@ module Playbook
|
|
|
19
19
|
default: false
|
|
20
20
|
prop :show_actions_bar, type: Playbook::Props::Boolean,
|
|
21
21
|
default: true
|
|
22
|
+
prop :inline_row_loading, type: Playbook::Props::Boolean,
|
|
23
|
+
default: false
|
|
24
|
+
prop :persist_toggle_expansion_button, type: Playbook::Props::Boolean,
|
|
25
|
+
default: false
|
|
26
|
+
prop :table_data, type: Playbook::Props::Array,
|
|
27
|
+
default: []
|
|
22
28
|
|
|
23
29
|
def classname
|
|
24
30
|
additional_classes = []
|
|
@@ -135,6 +141,20 @@ module Playbook
|
|
|
135
141
|
original_def.dig(:column_styling, :header_font_color)
|
|
136
142
|
end
|
|
137
143
|
|
|
144
|
+
# Check if any row in the table has children
|
|
145
|
+
def has_any_sub_rows?
|
|
146
|
+
return false if table_data.blank?
|
|
147
|
+
|
|
148
|
+
table_data.any? { |row| row_has_children?(row) }
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Determines if the toggle-all button should be shown in the header based on inline row loading and persist toggle expansion button props
|
|
152
|
+
def show_toggle_all_button?
|
|
153
|
+
return false unless enable_toggle_expansion == "header" || enable_toggle_expansion == "all"
|
|
154
|
+
|
|
155
|
+
has_any_sub_rows? || (inline_row_loading && persist_toggle_expansion_button)
|
|
156
|
+
end
|
|
157
|
+
|
|
138
158
|
# Check if header has custom background color
|
|
139
159
|
def has_custom_header_background_color?(cell)
|
|
140
160
|
cell[:header_background_color].present?
|
|
@@ -317,6 +337,20 @@ module Playbook
|
|
|
317
337
|
end
|
|
318
338
|
nil
|
|
319
339
|
end
|
|
340
|
+
|
|
341
|
+
# 2 inline row loading helper methods
|
|
342
|
+
def row_has_children?(row)
|
|
343
|
+
children = row_children_for(row)
|
|
344
|
+
children.present? && children.is_a?(::Array) && !children.empty?
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
def row_children_for(row)
|
|
348
|
+
if row.respond_to?(:children)
|
|
349
|
+
row.children
|
|
350
|
+
elsif row.respond_to?(:[])
|
|
351
|
+
row[:children] || row["children"]
|
|
352
|
+
end
|
|
353
|
+
end
|
|
320
354
|
end
|
|
321
355
|
end
|
|
322
356
|
end
|
|
@@ -33,6 +33,8 @@ module Playbook
|
|
|
33
33
|
default: false
|
|
34
34
|
prop :immediate_parent_row_id, type: Playbook::Props::String,
|
|
35
35
|
default: ""
|
|
36
|
+
prop :inline_row_loading, type: Playbook::Props::Boolean,
|
|
37
|
+
default: false
|
|
36
38
|
|
|
37
39
|
def data
|
|
38
40
|
Hash(prop(:data)).merge(table_data_attributes)
|
|
@@ -186,6 +188,23 @@ module Playbook
|
|
|
186
188
|
end
|
|
187
189
|
end
|
|
188
190
|
|
|
191
|
+
# Determines if the row should show an expand button (true if row has children or inline_row_loading true and row has empty children array)
|
|
192
|
+
def show_expand_button?
|
|
193
|
+
children = row_children
|
|
194
|
+
return true if children.present?
|
|
195
|
+
return true if inline_row_loading && children.is_a?(::Array) && children.empty?
|
|
196
|
+
|
|
197
|
+
false
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def row_children
|
|
201
|
+
if row.respond_to?(:children)
|
|
202
|
+
row.children
|
|
203
|
+
elsif row.respond_to?(:[])
|
|
204
|
+
row[:children] || row["children"]
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
189
208
|
private
|
|
190
209
|
|
|
191
210
|
def custom_renderer_value(column, index)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import Background from '../../pb_background/_background'
|
|
3
|
+
|
|
4
|
+
const BackgroundResponsive = (props) => (
|
|
5
|
+
<>
|
|
6
|
+
<Background
|
|
7
|
+
alt="colorful background"
|
|
8
|
+
backgroundColor={{ xs: "primary", sm: "warning", md: "success", lg: "error", xl: "category_1" }}
|
|
9
|
+
className="background lazyload"
|
|
10
|
+
padding="xl"
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
<br/>
|
|
14
|
+
<Background
|
|
15
|
+
alt="colorful background"
|
|
16
|
+
className="background lazyload"
|
|
17
|
+
imageUrl={{
|
|
18
|
+
xs: "https://unsplash.it/500/400/?image=633",
|
|
19
|
+
sm: "https://images.unsplash.com/photo-1528459801416-a9e53bbf4e17?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80",
|
|
20
|
+
md: "https://unsplash.it/500/400/?image=633",
|
|
21
|
+
lg: "https://images.unsplash.com/photo-1528459801416-a9e53bbf4e17?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80",
|
|
22
|
+
xl: "https://unsplash.it/500/400/?image=633"
|
|
23
|
+
}}
|
|
24
|
+
padding="xl"
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
</>
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
export default BackgroundResponsive
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The `backgroundColor`, `backgroundSize`, `backgroundPosition`, `backgroundRepeat`, and `imageUrl` props support responsive sizes. To use them, pass an object to the prop containing your values relative to responsive break points. To test this here, resize your browser window to responsively change these Backgrounds' `backgroundColor` and `imageUrl`.
|
|
@@ -7,3 +7,4 @@ export { default as BackgroundStatusSubtle } from './_background_status_subtle.j
|
|
|
7
7
|
export { default as BackgroundCategory } from './_background_category.jsx'
|
|
8
8
|
export { default as BackgroundSize } from './_background_size.jsx'
|
|
9
9
|
export { default as BackgroundOverlay } from './_background_overlay.jsx'
|
|
10
|
+
export { default as BackgroundResponsive } from './_background_responsive.jsx'
|
|
@@ -36,6 +36,8 @@ type DropdownProps = {
|
|
|
36
36
|
blankSelection?: string;
|
|
37
37
|
children?: React.ReactChild[] | React.ReactChild | React.ReactElement[];
|
|
38
38
|
className?: string;
|
|
39
|
+
clearable?: boolean;
|
|
40
|
+
constrainHeight?: boolean;
|
|
39
41
|
customQuickPickDates?: CustomQuickPickDates;
|
|
40
42
|
formPillProps?: GenericObject;
|
|
41
43
|
dark?: boolean;
|
|
@@ -49,6 +51,7 @@ type DropdownProps = {
|
|
|
49
51
|
multiSelect?: boolean;
|
|
50
52
|
onSelect?: (arg: GenericObject) => null;
|
|
51
53
|
options?: GenericObject;
|
|
54
|
+
placeholder?: string;
|
|
52
55
|
separators?: boolean;
|
|
53
56
|
variant?: "default" | "subtle" | "quickpick";
|
|
54
57
|
rangeEndsToday?: boolean;
|
|
@@ -74,6 +77,8 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
74
77
|
blankSelection = '',
|
|
75
78
|
children,
|
|
76
79
|
className,
|
|
80
|
+
clearable = true,
|
|
81
|
+
constrainHeight = false,
|
|
77
82
|
customQuickPickDates,
|
|
78
83
|
dark = false,
|
|
79
84
|
data = {},
|
|
@@ -87,6 +92,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
87
92
|
formPillProps,
|
|
88
93
|
onSelect,
|
|
89
94
|
options,
|
|
95
|
+
placeholder,
|
|
90
96
|
rangeEndsToday = false,
|
|
91
97
|
controlsStartId,
|
|
92
98
|
controlsEndId,
|
|
@@ -211,6 +217,34 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
211
217
|
}
|
|
212
218
|
}, [isDropDownClosed]);
|
|
213
219
|
|
|
220
|
+
// Auto-position dropdown above/below based on available space
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
if (!isDropDownClosed && dropdownContainerRef.current) {
|
|
223
|
+
const container = dropdownContainerRef.current;
|
|
224
|
+
const wrapper = container.closest('.dropdown_wrapper') as HTMLElement;
|
|
225
|
+
if (!wrapper) return;
|
|
226
|
+
|
|
227
|
+
const wrapperRect = wrapper.getBoundingClientRect();
|
|
228
|
+
const h = container.getBoundingClientRect().height || container.scrollHeight;
|
|
229
|
+
const spaceBelow = window.innerHeight - wrapperRect.bottom;
|
|
230
|
+
const spaceAbove = wrapperRect.top;
|
|
231
|
+
|
|
232
|
+
// If not enough space below but enough space above, position above
|
|
233
|
+
if (spaceBelow < h + 10 && spaceAbove >= h + 10) {
|
|
234
|
+
container.style.top = "auto";
|
|
235
|
+
container.style.bottom = "calc(100% + 5px)";
|
|
236
|
+
container.style.marginTop = "0";
|
|
237
|
+
container.style.marginBottom = "0";
|
|
238
|
+
} else {
|
|
239
|
+
// Default: position below
|
|
240
|
+
container.style.top = "";
|
|
241
|
+
container.style.bottom = "";
|
|
242
|
+
container.style.marginTop = "";
|
|
243
|
+
container.style.marginBottom = "";
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}, [isDropDownClosed, dropdownContainerRef]);
|
|
247
|
+
|
|
214
248
|
|
|
215
249
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
216
250
|
setFilterItem(e.target.value);
|
|
@@ -375,6 +409,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
375
409
|
value={{
|
|
376
410
|
activeStyle,
|
|
377
411
|
autocomplete,
|
|
412
|
+
clearable,
|
|
378
413
|
dropdownContainerRef,
|
|
379
414
|
filteredOptions,
|
|
380
415
|
filterItem,
|
|
@@ -426,8 +461,8 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
426
461
|
</>
|
|
427
462
|
) : (
|
|
428
463
|
<>
|
|
429
|
-
<DropdownTrigger />
|
|
430
|
-
<DropdownContainer>
|
|
464
|
+
<DropdownTrigger placeholder={placeholder} />
|
|
465
|
+
<DropdownContainer constrainHeight={constrainHeight}>
|
|
431
466
|
{optionsWithBlankSelection &&
|
|
432
467
|
optionsWithBlankSelection?.map((option: GenericObject) => (
|
|
433
468
|
<DropdownOption key={option.id}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
The `blank_selection` prop adds a blank option at the top of the dropdown options list. This allows users to explicitly clear their selection by choosing the blank option.
|
|
2
|
+
|
|
3
|
+
The blank selection option appears as the first item in the dropdown and has an empty value (`id: ""`, `value: ""`). When selected, it effectively clears the dropdown selection.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
The `blankSelection` prop adds a blank option at the top of the dropdown options list. This allows users to explicitly clear their selection by choosing the blank option.
|
|
2
|
+
|
|
3
|
+
The blank selection option appears as the first item in the dropdown and has an empty value (`id: ""`, `value: ""`). When selected, it effectively clears the dropdown selection.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<%
|
|
2
|
+
options = [
|
|
3
|
+
{ label: 'United States', value: 'unitedStates', id: 'us' },
|
|
4
|
+
{ label: 'Canada', value: 'canada', id: 'ca' },
|
|
5
|
+
{ label: 'Pakistan', value: 'pakistan', id: 'pk' },
|
|
6
|
+
]
|
|
7
|
+
%>
|
|
8
|
+
|
|
9
|
+
<%= pb_rails("dropdown", props: {
|
|
10
|
+
id: "date-range-quickpick-reset-closeable",
|
|
11
|
+
label: "Quick Pick",
|
|
12
|
+
variant: "quickpick",
|
|
13
|
+
clearable: false
|
|
14
|
+
}) %>
|
|
15
|
+
|
|
16
|
+
<%= pb_rails("button", props: {
|
|
17
|
+
margin_y: "md",
|
|
18
|
+
text: "Reset",
|
|
19
|
+
html_options: {
|
|
20
|
+
onclick: "handleReset()"
|
|
21
|
+
}
|
|
22
|
+
}) %>
|
|
23
|
+
|
|
24
|
+
<%= pb_rails("dropdown", props: {
|
|
25
|
+
id: "closeable-default",
|
|
26
|
+
options: options,
|
|
27
|
+
clearable: false,
|
|
28
|
+
default_value: options.last,
|
|
29
|
+
margin_bottom: "md",
|
|
30
|
+
label: "Default"
|
|
31
|
+
}) %>
|
|
32
|
+
|
|
33
|
+
<%= pb_rails("dropdown", props: {
|
|
34
|
+
id: "closeable-subtle",
|
|
35
|
+
options: options,
|
|
36
|
+
clearable: false,
|
|
37
|
+
default_value: options.second,
|
|
38
|
+
variant: "subtle",
|
|
39
|
+
separators: false,
|
|
40
|
+
label: "Subtle"
|
|
41
|
+
}) %>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
function handleReset() {
|
|
45
|
+
const dropdown = document.querySelector("#date-range-quickpick-reset-closeable[data-pb-dropdown]");
|
|
46
|
+
const instance = dropdown?._pbDropdownInstance;
|
|
47
|
+
|
|
48
|
+
if (instance) {
|
|
49
|
+
instance.clearSelection();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React, { useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import Button from '../../pb_button/_button'
|
|
4
|
+
import Dropdown from '../../pb_dropdown/_dropdown'
|
|
5
|
+
|
|
6
|
+
const DropdownWithClearable = (props) => {
|
|
7
|
+
const dropdownRef = useRef(null)
|
|
8
|
+
|
|
9
|
+
const options = [
|
|
10
|
+
{
|
|
11
|
+
label: "United States",
|
|
12
|
+
value: "unitedStates",
|
|
13
|
+
id: "us"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: "Canada",
|
|
17
|
+
value: "canada",
|
|
18
|
+
id: "ca"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: "Pakistan",
|
|
22
|
+
value: "pakistan",
|
|
23
|
+
id: "pk"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
const handleReset = () => {
|
|
28
|
+
if (dropdownRef.current) {
|
|
29
|
+
dropdownRef.current.clearSelected()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<Dropdown
|
|
36
|
+
clearable={false}
|
|
37
|
+
label="Quick Pick"
|
|
38
|
+
onSelect={() => {}}
|
|
39
|
+
ref={dropdownRef}
|
|
40
|
+
variant="quickpick"
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
<Button
|
|
44
|
+
marginY="md"
|
|
45
|
+
onClick={handleReset}
|
|
46
|
+
text="Reset"
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<Dropdown
|
|
50
|
+
clearable={false}
|
|
51
|
+
defaultValue={options[options.length - 1]}
|
|
52
|
+
label="Default"
|
|
53
|
+
marginBottom="md"
|
|
54
|
+
options={options}
|
|
55
|
+
variant="default"
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
|
|
59
|
+
<Dropdown
|
|
60
|
+
clearable={false}
|
|
61
|
+
defaultValue={options[1]}
|
|
62
|
+
label="Subtle"
|
|
63
|
+
options={options}
|
|
64
|
+
separators={false}
|
|
65
|
+
variant="subtle"
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
</>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default DropdownWithClearable
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
The `clearable` prop controls whether the clear (X) button appears in the dropdown. When set to `false`, the clear button is hidden.
|
|
2
|
+
|
|
3
|
+
This is useful in two scenarios:
|
|
4
|
+
1. When you have a separate "Reset" or "Defaults" button that handles clearing the selection (as shown in the Quick Pick example)
|
|
5
|
+
2. When you don't want to provide any way to clear the selection (as shown in the Default and Subtle examples)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import Dropdown from '../../pb_dropdown/_dropdown'
|
|
3
|
+
|
|
4
|
+
const DropdownWithConstrainHeight = (props) => {
|
|
5
|
+
// Create a long list of options to demonstrate height constraint
|
|
6
|
+
const options = Array.from({ length: 30 }, (_, i) => ({
|
|
7
|
+
label: `Option ${i + 1}`,
|
|
8
|
+
value: `option_${i + 1}`,
|
|
9
|
+
id: `opt_${i + 1}`
|
|
10
|
+
}))
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
<Dropdown
|
|
15
|
+
data={{ testid: "dropdown-no-constrain" }}
|
|
16
|
+
label="Without Constrain Height (Default)"
|
|
17
|
+
marginBottom="md"
|
|
18
|
+
options={options}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
<Dropdown
|
|
23
|
+
constrainHeight
|
|
24
|
+
data={{ testid: "dropdown-constrain" }}
|
|
25
|
+
label="With Constrain Height"
|
|
26
|
+
options={options}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
</>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default DropdownWithConstrainHeight
|