playbook_ui 13.26.0 → 13.27.0.pre.alpha.PBNTR48phonenumberform2852
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_advanced_table/_advanced_table.scss +14 -0
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +14 -10
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.html.erb +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +24 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/index.js +78 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +9 -5
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +4 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +6 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +9 -4
- data/app/pb_kits/playbook/pb_avatar/Utilities/GetPlacementPropsHelper.tsx +44 -0
- data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +86 -21
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +26 -3
- data/app/pb_kits/playbook/pb_avatar/avatar.rb +41 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_badge_component_overlay.html.erb +71 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_badge_component_overlay.jsx +77 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_circle_icon_component_overlay.html.erb +71 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_circle_icon_component_overlay.jsx +77 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.jsx +20 -0
- data/app/pb_kits/playbook/pb_avatar/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_avatar/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +6 -1
- data/app/pb_kits/playbook/pb_background/background.html.erb +11 -2
- data/app/pb_kits/playbook/pb_badge/badge.html.erb +6 -1
- data/app/pb_kits/playbook/pb_body/body.html.erb +6 -1
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +6 -1
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +7 -2
- data/app/pb_kits/playbook/pb_button/button.html.erb +3 -2
- data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.html.erb +7 -2
- data/app/pb_kits/playbook/pb_caption/caption.html.erb +6 -1
- data/app/pb_kits/playbook/pb_card/card.html.erb +7 -1
- data/app/pb_kits/playbook/pb_card/card_body.html.erb +6 -1
- data/app/pb_kits/playbook/pb_card/card_header.html.erb +6 -1
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +6 -1
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +6 -1
- data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +6 -1
- data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +6 -1
- data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +7 -1
- data/app/pb_kits/playbook/pb_contact/contact.html.erb +6 -1
- data/app/pb_kits/playbook/pb_currency/currency.html.erb +6 -1
- data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.html.erb +6 -1
- data/app/pb_kits/playbook/pb_date/date.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_range_inline/date_range_inline.html.erb +5 -1
- data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.html.erb +5 -1
- data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +5 -1
- data/app/pb_kits/playbook/pb_date_time/date_time.html.erb +6 -1
- data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +7 -1
- data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.html.erb +5 -1
- data/app/pb_kits/playbook/pb_detail/detail.html.erb +6 -1
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +6 -1
- data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +7 -2
- data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +5 -1
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +6 -2
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.html.erb +10 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.html.erb +17 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.md +3 -3
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.html.erb +60 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.html.erb +45 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.html.erb +17 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.html.erb +47 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.html.erb +10 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +9 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +25 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +19 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +21 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +19 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +27 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_option.rb +22 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +43 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +30 -0
- data/app/pb_kits/playbook/pb_dropdown/index.js +152 -0
- data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +77 -0
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +6 -1
- data/app/pb_kits/playbook/pb_filter/filter.html.erb +5 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +6 -1
- data/app/pb_kits/playbook/pb_flex/flex.html.erb +5 -1
- data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +6 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +6 -1
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
- data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +6 -1
- data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +5 -1
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +5 -1
- data/app/pb_kits/playbook/pb_icon_circle/icon_circle.html.erb +7 -2
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +6 -1
- data/app/pb_kits/playbook/pb_icon_value/icon_value.html.erb +6 -1
- data/app/pb_kits/playbook/pb_label_pill/label_pill.html.erb +6 -1
- data/app/pb_kits/playbook/pb_label_value/label_value.html.erb +6 -1
- data/app/pb_kits/playbook/pb_layout/body.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/footer.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/header.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/item.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/layout.html.erb +5 -1
- data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +5 -1
- data/app/pb_kits/playbook/pb_list/item.html.erb +8 -2
- data/app/pb_kits/playbook/pb_list/list.html.erb +8 -2
- data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.tsx +3 -1
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_custom.html.erb +13 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_custom.jsx +26 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/{_loading_inline_light.html.erb → _loading_inline_default.html.erb} +2 -2
- data/app/pb_kits/playbook/pb_loading_inline/docs/{_loading_inline_light.jsx → _loading_inline_default.jsx} +2 -2
- data/app/pb_kits/playbook/pb_loading_inline/docs/example.yml +4 -2
- data/app/pb_kits/playbook/pb_loading_inline/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.html.erb +7 -2
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.rb +1 -0
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.test.js +14 -0
- data/app/pb_kits/playbook/pb_message/message.html.erb +6 -1
- data/app/pb_kits/playbook/pb_message/message_mention.html.erb +6 -1
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +6 -1
- data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +6 -1
- data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +6 -1
- data/app/pb_kits/playbook/pb_nav/item.html.erb +14 -3
- data/app/pb_kits/playbook/pb_nav/nav.html.erb +6 -1
- data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +6 -2
- data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +6 -1
- data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
- data/app/pb_kits/playbook/pb_person/person.html.erb +12 -7
- data/app/pb_kits/playbook/pb_person_contact/person_contact.html.erb +6 -1
- data/app/pb_kits/playbook/pb_pill/pill.html.erb +6 -1
- data/app/pb_kits/playbook/pb_popover/popover.html.erb +6 -1
- data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +6 -2
- data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +6 -3
- data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +5 -1
- data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +5 -1
- data/app/pb_kits/playbook/pb_radio/radio.html.erb +8 -2
- data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +6 -1
- data/app/pb_kits/playbook/pb_select/select.html.erb +5 -1
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +5 -1
- data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +4 -1
- data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +5 -1
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +6 -1
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +6 -1
- data/app/pb_kits/playbook/pb_source/source.html.erb +5 -1
- data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +5 -1
- data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +5 -1
- data/app/pb_kits/playbook/pb_stat_value/stat_value.html.erb +5 -1
- data/app/pb_kits/playbook/pb_table/table.html.erb +12 -2
- data/app/pb_kits/playbook/pb_table/table_body.html.erb +16 -6
- data/app/pb_kits/playbook/pb_table/table_cell.html.erb +16 -6
- data/app/pb_kits/playbook/pb_table/table_head.html.erb +16 -6
- data/app/pb_kits/playbook/pb_table/table_header.html.erb +13 -4
- data/app/pb_kits/playbook/pb_table/table_row.html.erb +16 -6
- data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +5 -1
- data/app/pb_kits/playbook/pb_time/time.html.erb +5 -1
- data/app/pb_kits/playbook/pb_time_range_inline/time_range_inline.html.erb +5 -1
- data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +5 -1
- data/app/pb_kits/playbook/pb_timeline/item.html.erb +7 -3
- data/app/pb_kits/playbook/pb_timeline/timeline.html.erb +5 -1
- data/app/pb_kits/playbook/pb_timestamp/timestamp.html.erb +6 -1
- data/app/pb_kits/playbook/pb_title/title.html.erb +6 -1
- data/app/pb_kits/playbook/pb_title_count/title_count.html.erb +6 -1
- data/app/pb_kits/playbook/pb_title_detail/title_detail.html.erb +5 -1
- data/app/pb_kits/playbook/pb_toggle/toggle.html.erb +6 -1
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +1 -1
- data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +5 -1
- data/app/pb_kits/playbook/pb_user/user.html.erb +6 -1
- data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +6 -1
- data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb +6 -1
- data/app/pb_kits/playbook/playbook-rails.js +6 -0
- data/dist/menu.yml +1 -1
- data/dist/playbook-rails.js +6 -6
- data/lib/playbook/forms/builder/phone_number_field.rb +12 -0
- data/lib/playbook/forms/builder.rb +1 -0
- data/lib/playbook/kit_base.rb +1 -1
- data/lib/playbook/version.rb +2 -2
- metadata +35 -8
- data/app/pb_kits/playbook/pb_advanced_table/docs/_description.md +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95ac0ea9e7bb139ef4d92f659e024423095eae94e41850491e67c604bf11166a
|
4
|
+
data.tar.gz: 5c7df5b7c03fe937e780f015f89c6f1b4d8a5444e0ad4c2b7403681d4d263df4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3610fe5c23968bb7313a2b1402347ddf034e97aced69a7add3bf4eb032ce0ac457cfb84a7e1d9bae10c460163fe8aeec71b680737f318105ab448e3c95770ae3
|
7
|
+
data.tar.gz: a3a8edacab61267f15694d6bce0c72e38f8915180b39d6e6b8f43a789634e46c0c897ca0d14b4a6013457efefd124a9e1ceb00dd4b6bc73450d946c7c054b9b6
|
@@ -94,6 +94,20 @@
|
|
94
94
|
position: relative;
|
95
95
|
}
|
96
96
|
|
97
|
+
.toggle-content {
|
98
|
+
display: none;
|
99
|
+
height: 0;
|
100
|
+
padding-bottom: 0 !important;
|
101
|
+
padding-top: 0 !important;
|
102
|
+
overflow: hidden;
|
103
|
+
transition: height 300ms, padding 300ms ease-in-out;
|
104
|
+
}
|
105
|
+
|
106
|
+
.toggle-content.is-visible {
|
107
|
+
display: contents;
|
108
|
+
height: auto;
|
109
|
+
}
|
110
|
+
|
97
111
|
&.dark {
|
98
112
|
.bg-white {
|
99
113
|
background: $bg_dark_card;
|
@@ -1,10 +1,14 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id) do %>
|
6
|
+
<%= pb_rails("table", props: { size: "sm", tag:"div", data_table: true, number_spacing:"tabular", responsive:"none" }) do %>
|
7
|
+
<% if content.present? %>
|
8
|
+
<% content.presence %>
|
9
|
+
<% else %>
|
10
|
+
<%= pb_rails("advanced_table/table_header", props: {column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion }) %>
|
11
|
+
<%= pb_rails("advanced_table/table_body", props: {table_data: object.table_data, column_definitions: object.column_definitions}) %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
@@ -0,0 +1,33 @@
|
|
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("advanced_table", props: {table_data: @table_data, column_definitions: column_definitions}) %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
**BETA VERSION**
|
2
|
+
This kit's Rails version is currently under development. Some features may not work as expected, and breaking changes may still occur; use with caution.
|
3
|
+
<br />
|
4
|
+
<br />
|
5
|
+
<br />
|
6
|
+
|
7
|
+
The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
|
8
|
+
|
9
|
+
### table_data
|
10
|
+
|
11
|
+
`table_data` accepts an array of objects as the table data. Each object is a table row, and each key:value pair within an object is a column value within that row. Nested children within a data object are automatically rendered as subrows under their parent row.
|
12
|
+
|
13
|
+
For a visual of the data structure needed for `table_data`, see [here](https://github.com/powerhome/playbook/tree/master/playbook/app/pb_kits/playbook/pb_advanced_table#readme).
|
14
|
+
|
15
|
+
### column_definitions
|
16
|
+
|
17
|
+
Column definitions are the single most important part of building a table as they are responsible for building the underlying data model that is used for all sorting, expansion, etc. `column_definitions` in the AdvancedTable kit is an array of objects as seen in the code snippet below. Each object within the array has two REQUIRED items:
|
18
|
+
|
19
|
+
- `accessor`: this is the key from your data for the value you want rendered in that column
|
20
|
+
- `label`: this is what will be rendered as the column header label
|
21
|
+
|
22
|
+
There is also one optional item that is only required if the table has nested data:
|
23
|
+
|
24
|
+
- `cellAccessors`: This is an array of strings that represent keys from your data object. This is only required for the first column in case of nested data. If you have nested data, the AdvancedTable needs to know what to render in that first column for nested items. This array represents the nested data in the order you want it rendered.
|
@@ -1,3 +1,8 @@
|
|
1
|
+
**NOTE:** The Advanced Table kit uses the [Tanstack Table v8](https://tanstack.com/table/v8/docs/introduction) under the hood to render advanced tables that allow for complex, nested data structures with expansion and sort options.
|
2
|
+
<br />
|
3
|
+
<br />
|
4
|
+
<br />
|
5
|
+
|
1
6
|
The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
|
2
7
|
|
3
8
|
### tableData
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import PbEnhancedElement from '../pb_enhanced_element'
|
2
|
+
|
3
|
+
const ADVANCED_TABLE_SELECTOR = '[data-advanced-table]'
|
4
|
+
const CONTENT_SELECTOR = '[data-advanced-table-content="id"]'
|
5
|
+
const DOWN_ARROW_SELECTOR = '#advanced-table_open_icon'
|
6
|
+
const UP_ARROW_SELECTOR = '#advanced-table_close_icon'
|
7
|
+
|
8
|
+
export default class PbAdvancedTable extends PbEnhancedElement {
|
9
|
+
static get selector() {
|
10
|
+
return ADVANCED_TABLE_SELECTOR
|
11
|
+
}
|
12
|
+
|
13
|
+
get target() {
|
14
|
+
return document.querySelector(CONTENT_SELECTOR.replace("id", this.element.id))
|
15
|
+
}
|
16
|
+
|
17
|
+
connect() {
|
18
|
+
this.element.addEventListener('click', () => {
|
19
|
+
this.toggleElement(this.target)
|
20
|
+
})
|
21
|
+
}
|
22
|
+
|
23
|
+
showElement(elem) {
|
24
|
+
const getHeight = () => {
|
25
|
+
elem.style.display = 'block'
|
26
|
+
const height = elem.scrollHeight + 'px'
|
27
|
+
elem.style.display = ''
|
28
|
+
return height
|
29
|
+
}
|
30
|
+
|
31
|
+
const height = getHeight()
|
32
|
+
elem.classList.add('is-visible')
|
33
|
+
elem.style.height = height
|
34
|
+
elem.style.overflow = "hidden"
|
35
|
+
|
36
|
+
window.setTimeout(() => {
|
37
|
+
elem.style.height = ''
|
38
|
+
elem.style.overflow = "visible"
|
39
|
+
}, 250)
|
40
|
+
}
|
41
|
+
|
42
|
+
hideElement(elem) {
|
43
|
+
elem.style.height = elem.scrollHeight + 'px'
|
44
|
+
|
45
|
+
window.setTimeout(() => {
|
46
|
+
elem.style.height = '0'
|
47
|
+
elem.style.paddingTop = '0'
|
48
|
+
elem.style.paddingBottom = '0'
|
49
|
+
elem.style.overflow = "hidden"
|
50
|
+
}, 1)
|
51
|
+
|
52
|
+
window.setTimeout(() => {
|
53
|
+
elem.classList.remove('is-visible')
|
54
|
+
elem.style.overflow = ""
|
55
|
+
}, 200)
|
56
|
+
}
|
57
|
+
|
58
|
+
toggleElement(elem) {
|
59
|
+
if (elem.classList.contains('is-visible')) {
|
60
|
+
this.hideElement(elem)
|
61
|
+
this.displayDownArrow()
|
62
|
+
return
|
63
|
+
}
|
64
|
+
|
65
|
+
this.showElement(elem)
|
66
|
+
this.displayUpArrow()
|
67
|
+
}
|
68
|
+
|
69
|
+
displayDownArrow() {
|
70
|
+
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = 'inline-block'
|
71
|
+
this.element.querySelector(UP_ARROW_SELECTOR).style.display = 'none'
|
72
|
+
}
|
73
|
+
|
74
|
+
displayUpArrow() {
|
75
|
+
this.element.querySelector(UP_ARROW_SELECTOR).style.display = 'inline-block'
|
76
|
+
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = 'none'
|
77
|
+
}
|
78
|
+
}
|
@@ -1,5 +1,9 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id) do %>
|
6
|
+
<% object.table_data.each do |row| %>
|
7
|
+
<%= render_row_and_children(row, object.column_definitions) %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
@@ -14,8 +14,10 @@ module Playbook
|
|
14
14
|
output << pb_rails("advanced_table/table_row", props: { row: row, column_definitions: column_definitions, depth: current_depth })
|
15
15
|
|
16
16
|
if row[:children].present?
|
17
|
-
row
|
18
|
-
|
17
|
+
output << content_tag(:div, class: "toggle-content", data: { advanced_table_content: row.object_id }) do
|
18
|
+
row[:children].map do |child_row|
|
19
|
+
render_row_and_children(child_row, column_definitions, current_depth + 1)
|
20
|
+
end.join.html_safe
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -1,4 +1,8 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id) do %>
|
2
6
|
<%= pb_rails("table/table_row", props: {tag:"div"}) do %>
|
3
7
|
<% object.column_definitions.each_with_index do |item, index| %>
|
4
8
|
<%= pb_rails("table/table_header", props: { tag:"div", id:item[:accessor], classname:object.th_classname}) do %>
|
@@ -13,4 +17,4 @@
|
|
13
17
|
<% end %>
|
14
18
|
<% end %>
|
15
19
|
<% end %>
|
16
|
-
<% end %>
|
20
|
+
<% end %>
|
@@ -1,12 +1,17 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id) do %>
|
2
6
|
<% object.column_definitions.each_with_index do |column, index| %>
|
3
7
|
<%= pb_rails("table/table_cell", props: { tag:"div", classname:object.td_classname}) do %>
|
4
8
|
<%= pb_rails("flex", props:{ align: "center", justify: index.zero? ? "start" : "end" }) do %>
|
5
9
|
<div style="padding-left: <%= depth * 1.25 %>em">
|
6
10
|
<%= pb_rails("flex", props:{align: "center", column_gap: "xs"}) do %>
|
7
11
|
<% if index.zero? && object.row[:children].present? %>
|
8
|
-
<button class="gray-icon expand-toggle-icon">
|
9
|
-
<%= pb_rails("icon", props: { icon: "circle-play", cursor: "pointer" }) %>
|
12
|
+
<button id="<%= object.row.object_id %>" class="gray-icon expand-toggle-icon" data-advanced-table="true" >
|
13
|
+
<%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
|
14
|
+
<%= pb_rails("icon", props: { id: "advanced-table_close_icon", display: "none", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
|
10
15
|
</button>
|
11
16
|
<% end %>
|
12
17
|
<%= pb_rails("flex/flex_item", props:{padding_left: index.zero? && object.row[:children].present? ? "none" : "xs"}) do %>
|
@@ -30,4 +35,4 @@
|
|
30
35
|
<% end %>
|
31
36
|
<% end %>
|
32
37
|
<% end %>
|
33
|
-
<% end %>
|
38
|
+
<% end %>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
export const getPlacementProps = (placement: string, size?: "md" | "lg" | "sm" | "xl" | "xs" | "xxs") => {
|
2
|
+
let placementMapping: { [key: string]: any } = {};
|
3
|
+
|
4
|
+
switch (size) {
|
5
|
+
case 'xxs':
|
6
|
+
case 'xs':
|
7
|
+
placementMapping = {
|
8
|
+
'top-right': { top: 'xs', right: 'xs' },
|
9
|
+
'bottom-left': { bottom: 'xs', left: 'xs' },
|
10
|
+
'top-left': { top: 'xs', left: 'xs' },
|
11
|
+
'bottom-right': { bottom: 'xs', right: 'xs' },
|
12
|
+
};
|
13
|
+
break;
|
14
|
+
|
15
|
+
case 'sm':
|
16
|
+
placementMapping = {
|
17
|
+
'top-right': { top: '0', right: 'xs' },
|
18
|
+
'bottom-left': { bottom: '0', left: 'xs' },
|
19
|
+
'top-left': { top: '0', left: 'xs' },
|
20
|
+
'bottom-right': { bottom: '0', right: 'xs' },
|
21
|
+
};
|
22
|
+
break;
|
23
|
+
|
24
|
+
case 'md':
|
25
|
+
case 'lg':
|
26
|
+
placementMapping = {
|
27
|
+
'top-right': { top: '0', right: '0' },
|
28
|
+
'bottom-left': { bottom: '0', left: '0' },
|
29
|
+
'top-left': { top: '0', left: '0' },
|
30
|
+
'bottom-right': { bottom: '0', right: '0' },
|
31
|
+
};
|
32
|
+
break;
|
33
|
+
|
34
|
+
case 'xl':
|
35
|
+
placementMapping = {
|
36
|
+
'top-right': { top: { value: "xxs", inset: true }, right: { value: "xxs", inset: true } },
|
37
|
+
'bottom-left': { bottom: { value: "xxs", inset: true }, left: { value: "xxs", inset: true } },
|
38
|
+
'top-left': { top: { value: "xxs", inset: true }, left: { value: "xxs", inset: true } },
|
39
|
+
'bottom-right': { bottom: { value: "xxs", inset: true }, right: { value: "xxs", inset: true } },
|
40
|
+
};
|
41
|
+
break;
|
42
|
+
}
|
43
|
+
return placementMapping[placement] || {};
|
44
|
+
};
|
@@ -3,13 +3,26 @@ import classnames from 'classnames'
|
|
3
3
|
|
4
4
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
5
5
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
6
|
+
import { getPlacementProps } from './Utilities/GetPlacementPropsHelper'
|
6
7
|
|
7
|
-
import Image from
|
8
|
-
import OnlineStatus from
|
8
|
+
import Image from "../pb_image/_image";
|
9
|
+
import OnlineStatus from "../pb_online_status/_online_status";
|
10
|
+
import Flex from "../pb_flex/_flex";
|
11
|
+
import Badge from "../pb_badge/_badge";
|
12
|
+
import IconCircle from "../pb_icon_circle/_icon_circle";
|
13
|
+
import Card from "../pb_card/_card";
|
9
14
|
|
10
15
|
export type AvatarProps = {
|
11
16
|
aria?: {[key: string]: string},
|
12
17
|
className?: string,
|
18
|
+
componentOverlay?: {
|
19
|
+
component: "badge" | "iconCircle",
|
20
|
+
placement: string,
|
21
|
+
size?: "md" | "lg" | "sm" | "xl" | "xs" | "xxs",
|
22
|
+
text?: string,
|
23
|
+
variant?: string,
|
24
|
+
icon?: string
|
25
|
+
},
|
13
26
|
data?: {[key: string]: string},
|
14
27
|
dark?: boolean,
|
15
28
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
@@ -19,7 +32,7 @@ export type AvatarProps = {
|
|
19
32
|
name?: string,
|
20
33
|
size?: "md" | "lg" | "sm" | "xl" | "xs" | "xxs",
|
21
34
|
status?: "away" | "offline" | "online",
|
22
|
-
} & GlobalProps
|
35
|
+
} & GlobalProps
|
23
36
|
|
24
37
|
const firstTwoInitials = (name: string) =>
|
25
38
|
name.split(/\s/).map((name) => name[0])
|
@@ -33,6 +46,7 @@ const Avatar = (props: AvatarProps): React.ReactElement => {
|
|
33
46
|
data = {},
|
34
47
|
htmlOptions = {},
|
35
48
|
name = undefined,
|
49
|
+
componentOverlay,
|
36
50
|
id = '',
|
37
51
|
imageAlt = '',
|
38
52
|
imageUrl,
|
@@ -65,24 +79,75 @@ const Avatar = (props: AvatarProps): React.ReactElement => {
|
|
65
79
|
className={classes}
|
66
80
|
id={id}
|
67
81
|
>
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
{componentOverlay ? (
|
83
|
+
<Flex display="display_inline_block"
|
84
|
+
position="relative"
|
85
|
+
>
|
86
|
+
<div className="avatar_wrapper"
|
87
|
+
data-initials={initials}
|
88
|
+
>
|
89
|
+
{canShowImage && (
|
90
|
+
<Image
|
91
|
+
alt={imageAlt ? imageAlt : name}
|
92
|
+
onError={handleError}
|
93
|
+
url={imageUrl}
|
94
|
+
/>
|
95
|
+
)}
|
96
|
+
</div>
|
97
|
+
|
98
|
+
{componentOverlay.component === "badge" && (
|
99
|
+
<Card
|
100
|
+
borderNone
|
101
|
+
borderRadius="rounded"
|
102
|
+
padding="none"
|
103
|
+
position="absolute"
|
104
|
+
{...getPlacementProps(componentOverlay.placement, size)}
|
105
|
+
>
|
106
|
+
|
107
|
+
<Badge
|
108
|
+
rounded
|
109
|
+
text={componentOverlay.text}
|
110
|
+
variant={componentOverlay.variant as "error" | "info" | "neutral" | "primary" | "success" | "warning" | "notification"}
|
111
|
+
/>
|
112
|
+
</Card>
|
113
|
+
)}
|
114
|
+
{componentOverlay.component === "iconCircle" && (
|
115
|
+
<Card
|
116
|
+
borderNone
|
117
|
+
borderRadius="rounded"
|
118
|
+
htmlOptions={{style: {padding:"2px"}}}
|
119
|
+
position="absolute"
|
120
|
+
{...getPlacementProps(componentOverlay.placement, size)}
|
121
|
+
>
|
122
|
+
<IconCircle
|
123
|
+
icon={componentOverlay.icon}
|
124
|
+
size="xxs"
|
125
|
+
variant={componentOverlay.variant as "default" | "royal" | "blue" | "purple" | "teal" | "red" | "yellow" | "orange" | "green"}
|
126
|
+
/>
|
127
|
+
</Card>
|
128
|
+
)}
|
129
|
+
</Flex>
|
130
|
+
) : (
|
131
|
+
<>
|
132
|
+
<div className="avatar_wrapper"
|
133
|
+
data-initials={initials}
|
134
|
+
>
|
135
|
+
{canShowImage && (
|
136
|
+
<Image
|
137
|
+
alt={imageAlt ? imageAlt : name}
|
138
|
+
onError={handleError}
|
139
|
+
url={imageUrl}
|
140
|
+
/>
|
141
|
+
)}
|
142
|
+
</div>
|
143
|
+
{status && (
|
144
|
+
<OnlineStatus
|
145
|
+
className={`size_${size}`}
|
146
|
+
dark={dark}
|
147
|
+
status={status}
|
148
|
+
/>
|
149
|
+
)}
|
150
|
+
</>
|
86
151
|
)}
|
87
152
|
</div>
|
88
153
|
)
|
@@ -1,6 +1,29 @@
|
|
1
|
+
|
1
2
|
<%= object.pb_content_tag(:div, data: object.data.merge(initials: object.initials)) do %>
|
2
|
-
|
3
|
-
<%= pb_rails("
|
3
|
+
<% if object.component_overlay && object.component_overlay[:component] == "icon_circle" %>
|
4
|
+
<%= pb_rails("flex", props: {display: "display_inline_block", position: "relative" }) do %>
|
5
|
+
<%= content_tag(:div, data: { initials: object.initials }, class: "avatar_wrapper") do %>
|
6
|
+
<%= pb_rails("image", props: { alt: object.alt_text, url: object.image_url, on_error: object.handle_img_error }) if object.image_url.present? %>
|
7
|
+
<% end %>
|
8
|
+
<%= pb_rails("card", props: { border_none: true, border_radius: "rounded", html_options: { style: "padding: 2px" }, position: "absolute" }.merge(specific_placement_style)) do %>
|
9
|
+
|
10
|
+
<%= pb_rails("icon_circle", props: { size: "xxs", icon: object.component_overlay[:icon] }) %>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<% elsif object.component_overlay && object.component_overlay[:component] == "badge" %>
|
14
|
+
<%= pb_rails("flex", props: {display: "display_inline_block", position: "relative" }) do %>
|
15
|
+
<%= content_tag(:div, data: { initials: object.initials }, class: "avatar_wrapper") do %>
|
16
|
+
<%= pb_rails("image", props: { alt: object.alt_text, url: object.image_url, on_error: object.handle_img_error }) if object.image_url.present? %>
|
17
|
+
<% end %>
|
18
|
+
<%= pb_rails("card", props: { border_none: true, border_radius: "rounded", padding: "none", position: "absolute" }.merge(specific_placement_style)) do %>
|
19
|
+
<%= pb_rails("badge", props: { rounded: true, text: object.component_overlay[:text], variant: object.component_overlay[:variant] }) %>
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
22
|
+
<% else %>
|
23
|
+
<%= content_tag(:div, data: { initials: object.initials }, class: "avatar_wrapper") do %>
|
24
|
+
<%= pb_rails("image", props: { alt: object.alt_text, url: object.image_url, on_error: object.handle_img_error }) if object.image_url.present? %>
|
25
|
+
<% end %>
|
26
|
+
<%= pb_rails("online_status", props: object.online_status_props) if object.status %>
|
4
27
|
<% end %>
|
5
|
-
<%= pb_rails("online_status", props: object.online_status_props) if object.status %>
|
6
28
|
<% end %>
|
29
|
+
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module Playbook
|
4
4
|
module PbAvatar
|
5
5
|
class Avatar < Playbook::KitBase
|
6
|
+
prop :component_overlay
|
6
7
|
prop :image_url, type: Playbook::Props::String
|
7
8
|
prop :image_alt, type: Playbook::Props::String,
|
8
9
|
default: ""
|
@@ -32,6 +33,46 @@ module Playbook
|
|
32
33
|
def handle_img_error
|
33
34
|
"this.style.display = 'none'"
|
34
35
|
end
|
36
|
+
|
37
|
+
def overlay_component
|
38
|
+
component_overlay && component_overlay[:component]
|
39
|
+
end
|
40
|
+
|
41
|
+
def specific_placement_style
|
42
|
+
placement = component_overlay[:placement] if component_overlay
|
43
|
+
placement_mapping[size][placement]
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def placement_mapping
|
49
|
+
xs_styles = placement_styles("xs")
|
50
|
+
{
|
51
|
+
"xxs" => xs_styles,
|
52
|
+
"xs" => xs_styles,
|
53
|
+
"sm" => placement_styles("xs"),
|
54
|
+
"md" => placement_styles("0"),
|
55
|
+
"lg" => placement_styles("0"),
|
56
|
+
"xl" => placement_styles({ value: "xxs", inset: true }),
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def placement_styles(offset)
|
61
|
+
top_bottom_offset = if offset == "xs"
|
62
|
+
"xs"
|
63
|
+
elsif offset == { value: "xxs", inset: true }
|
64
|
+
{ value: "xxs", inset: true }
|
65
|
+
else
|
66
|
+
"0"
|
67
|
+
end
|
68
|
+
|
69
|
+
{
|
70
|
+
"top-right" => { top: top_bottom_offset, right: offset },
|
71
|
+
"bottom-left" => { bottom: top_bottom_offset, left: offset },
|
72
|
+
"top-left" => { top: top_bottom_offset, left: offset },
|
73
|
+
"bottom-right" => { bottom: top_bottom_offset, right: offset },
|
74
|
+
}
|
75
|
+
end
|
35
76
|
end
|
36
77
|
end
|
37
78
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
<%= pb_rails("avatar", props: {
|
2
|
+
component_overlay: {
|
3
|
+
component: "badge",
|
4
|
+
text: "12",
|
5
|
+
placement: "top-left"
|
6
|
+
},
|
7
|
+
name: "Terry Johnson",
|
8
|
+
size: "xxs",
|
9
|
+
image_url: "https://randomuser.me/api/portraits/men/44.jpg",
|
10
|
+
margin_bottom: "sm"
|
11
|
+
}) %>
|
12
|
+
|
13
|
+
<%= pb_rails("avatar", props: {
|
14
|
+
component_overlay: {
|
15
|
+
component: "badge",
|
16
|
+
text: "12",
|
17
|
+
placement: "top-right"
|
18
|
+
},
|
19
|
+
name: "Terry Johnson",
|
20
|
+
size: "xs",
|
21
|
+
image_url: "https://randomuser.me/api/portraits/men/44.jpg",
|
22
|
+
margin_bottom: "sm"
|
23
|
+
}) %>
|
24
|
+
|
25
|
+
<%= pb_rails("avatar", props: {
|
26
|
+
component_overlay: {
|
27
|
+
component: "badge",
|
28
|
+
text: "12",
|
29
|
+
placement: "bottom-right"
|
30
|
+
},
|
31
|
+
name: "Terry Johnson",
|
32
|
+
size: "sm",
|
33
|
+
image_url: "https://randomuser.me/api/portraits/men/44.jpg",
|
34
|
+
margin_bottom: "sm"
|
35
|
+
}) %>
|
36
|
+
|
37
|
+
<%= pb_rails("avatar", props: {
|
38
|
+
component_overlay: {
|
39
|
+
component: "badge",
|
40
|
+
text: "12",
|
41
|
+
placement: "bottom-left"
|
42
|
+
},
|
43
|
+
name: "Terry Johnson",
|
44
|
+
size: "md",
|
45
|
+
image_url: "https://randomuser.me/api/portraits/men/44.jpg",
|
46
|
+
margin_bottom: "sm"
|
47
|
+
}) %>
|
48
|
+
|
49
|
+
<%= pb_rails("avatar", props: {
|
50
|
+
component_overlay: {
|
51
|
+
component: "badge",
|
52
|
+
text: "12",
|
53
|
+
placement: "top-left"
|
54
|
+
},
|
55
|
+
name: "Terry Johnson",
|
56
|
+
size: "lg",
|
57
|
+
image_url: "https://randomuser.me/api/portraits/men/44.jpg",
|
58
|
+
margin_bottom: "sm"
|
59
|
+
}) %>
|
60
|
+
|
61
|
+
<%= pb_rails("avatar", props: {
|
62
|
+
component_overlay: {
|
63
|
+
component: "badge",
|
64
|
+
text: "12",
|
65
|
+
placement: "top-right"
|
66
|
+
},
|
67
|
+
name: "Terry Johnson",
|
68
|
+
size: "xl",
|
69
|
+
image_url: "https://randomuser.me/api/portraits/men/44.jpg",
|
70
|
+
margin_bottom: "sm"
|
71
|
+
}) %>
|