playbook_ui 13.24.0.pre.alpha.play1305drycontenttag2689 → 13.25.0.pre.alpha.PLAY761globalpaddingpropsbuttons2713

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +2 -0
  3. data/app/pb_kits/playbook/index.js +1 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +14 -10
  5. data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +9 -5
  6. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +6 -2
  7. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +6 -2
  8. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +6 -1
  9. data/app/pb_kits/playbook/pb_background/_background.tsx +7 -5
  10. data/app/pb_kits/playbook/pb_background/background.html.erb +10 -2
  11. data/app/pb_kits/playbook/pb_badge/badge.html.erb +6 -1
  12. data/app/pb_kits/playbook/pb_body/body.html.erb +6 -1
  13. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +6 -1
  14. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +7 -2
  15. data/app/pb_kits/playbook/pb_button/_button.scss +1 -1
  16. data/app/pb_kits/playbook/pb_button/button.html.erb +1 -1
  17. data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.html.erb +7 -2
  18. data/app/pb_kits/playbook/pb_caption/caption.html.erb +6 -1
  19. data/app/pb_kits/playbook/pb_card/card.html.erb +7 -1
  20. data/app/pb_kits/playbook/pb_card/card_body.html.erb +6 -1
  21. data/app/pb_kits/playbook/pb_card/card_header.html.erb +6 -1
  22. data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +6 -1
  23. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +6 -1
  24. data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +6 -1
  25. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +6 -1
  26. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +6 -1
  27. data/app/pb_kits/playbook/pb_contact/contact.html.erb +6 -1
  28. data/app/pb_kits/playbook/pb_currency/currency.html.erb +6 -1
  29. data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.html.erb +6 -1
  30. data/app/pb_kits/playbook/pb_date/date.html.erb +6 -1
  31. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +4 -1
  32. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.html.erb +5 -1
  33. data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.html.erb +5 -1
  34. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +5 -1
  35. data/app/pb_kits/playbook/pb_date_time/date_time.html.erb +6 -1
  36. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +7 -1
  37. data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.html.erb +5 -1
  38. data/app/pb_kits/playbook/pb_detail/detail.html.erb +6 -1
  39. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +6 -1
  40. data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +7 -2
  41. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +5 -1
  42. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +4 -1
  43. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +1 -1
  44. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +98 -0
  45. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +186 -0
  46. data/app/pb_kits/playbook/pb_dropdown/context/index.tsx +5 -0
  47. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.jsx +50 -0
  48. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +102 -0
  49. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.jsx +66 -0
  50. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx +77 -0
  51. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +9 -0
  52. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +4 -0
  53. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +17 -0
  54. data/app/pb_kits/playbook/pb_dropdown/hooks/useDropdown.tsx +17 -0
  55. data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +56 -0
  56. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +95 -0
  57. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +91 -0
  58. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +128 -0
  59. data/app/pb_kits/playbook/pb_dropdown/utilities/subComponentHelper.tsx +59 -0
  60. data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +6 -1
  61. data/app/pb_kits/playbook/pb_filter/filter.html.erb +5 -1
  62. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +6 -1
  63. data/app/pb_kits/playbook/pb_flex/flex.html.erb +5 -1
  64. data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +4 -1
  65. data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +6 -1
  66. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
  67. data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +6 -1
  68. data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +5 -1
  69. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +5 -1
  70. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.scss +1 -1
  71. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.tsx +1 -1
  72. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.html.erb +7 -2
  73. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.rb +1 -1
  74. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.test.js +3 -3
  75. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +6 -1
  76. data/app/pb_kits/playbook/pb_icon_value/icon_value.html.erb +6 -1
  77. data/app/pb_kits/playbook/pb_label_pill/label_pill.html.erb +6 -1
  78. data/app/pb_kits/playbook/pb_label_value/label_value.html.erb +6 -1
  79. data/app/pb_kits/playbook/pb_layout/body.html.erb +5 -1
  80. data/app/pb_kits/playbook/pb_layout/footer.html.erb +5 -1
  81. data/app/pb_kits/playbook/pb_layout/header.html.erb +5 -1
  82. data/app/pb_kits/playbook/pb_layout/item.html.erb +5 -1
  83. data/app/pb_kits/playbook/pb_layout/layout.html.erb +5 -1
  84. data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +5 -1
  85. data/app/pb_kits/playbook/pb_list/_list_item.tsx +2 -2
  86. data/app/pb_kits/playbook/pb_list/item.html.erb +8 -3
  87. data/app/pb_kits/playbook/pb_list/list.html.erb +5 -1
  88. data/app/pb_kits/playbook/pb_loading_inline/loading_inline.html.erb +6 -1
  89. data/app/pb_kits/playbook/pb_message/message.html.erb +6 -1
  90. data/app/pb_kits/playbook/pb_message/message_mention.html.erb +6 -1
  91. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +6 -1
  92. data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +6 -1
  93. data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +6 -1
  94. data/app/pb_kits/playbook/pb_nav/item.html.erb +10 -2
  95. data/app/pb_kits/playbook/pb_nav/nav.html.erb +6 -1
  96. data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +4 -1
  97. data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +6 -1
  98. data/app/pb_kits/playbook/pb_person/person.html.erb +12 -7
  99. data/app/pb_kits/playbook/pb_person_contact/person_contact.html.erb +6 -1
  100. data/app/pb_kits/playbook/pb_pill/pill.html.erb +6 -1
  101. data/app/pb_kits/playbook/pb_popover/popover.html.erb +6 -1
  102. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +4 -1
  103. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +6 -4
  104. data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +5 -1
  105. data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +5 -1
  106. data/app/pb_kits/playbook/pb_radio/radio.html.erb +6 -1
  107. data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +6 -1
  108. data/app/pb_kits/playbook/pb_select/select.html.erb +5 -1
  109. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +5 -1
  110. data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +4 -1
  111. data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +5 -1
  112. data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +6 -1
  113. data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +6 -1
  114. data/app/pb_kits/playbook/pb_source/source.html.erb +5 -1
  115. data/app/pb_kits/playbook/pb_source/source.test.js +2 -2
  116. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +5 -1
  117. data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +5 -1
  118. data/app/pb_kits/playbook/pb_stat_value/stat_value.html.erb +5 -1
  119. data/app/pb_kits/playbook/pb_table/table.html.erb +5 -1
  120. data/app/pb_kits/playbook/pb_table/table_body.html.erb +16 -6
  121. data/app/pb_kits/playbook/pb_table/table_cell.html.erb +16 -6
  122. data/app/pb_kits/playbook/pb_table/table_head.html.erb +16 -6
  123. data/app/pb_kits/playbook/pb_table/table_header.html.erb +11 -3
  124. data/app/pb_kits/playbook/pb_table/table_row.html.erb +16 -6
  125. data/app/pb_kits/playbook/pb_text_input/text_input.html.erb +5 -1
  126. data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +5 -1
  127. data/app/pb_kits/playbook/pb_time/time.html.erb +5 -1
  128. data/app/pb_kits/playbook/pb_time_range_inline/time_range_inline.html.erb +5 -1
  129. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +5 -1
  130. data/app/pb_kits/playbook/pb_timeline/item.html.erb +7 -3
  131. data/app/pb_kits/playbook/pb_timeline/timeline.html.erb +5 -1
  132. data/app/pb_kits/playbook/pb_timestamp/timestamp.html.erb +6 -1
  133. data/app/pb_kits/playbook/pb_title/title.html.erb +6 -3
  134. data/app/pb_kits/playbook/pb_title_count/title_count.html.erb +6 -1
  135. data/app/pb_kits/playbook/pb_title_detail/title_detail.html.erb +5 -1
  136. data/app/pb_kits/playbook/pb_toggle/toggle.html.erb +6 -1
  137. data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +5 -1
  138. data/app/pb_kits/playbook/pb_user/user.html.erb +6 -1
  139. data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +6 -1
  140. data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb +6 -1
  141. data/app/pb_kits/playbook/playbook-doc.js +2 -0
  142. data/dist/menu.yml +5 -1
  143. data/dist/playbook-rails.js +5 -5
  144. data/lib/playbook/version.rb +2 -2
  145. metadata +19 -3
  146. /data/app/pb_kits/playbook/pb_dialog/docs/{_dialog_props_table.md → _dialog_props_swift.md} +0 -0
@@ -0,0 +1,95 @@
1
+ import React, { useContext } from "react";
2
+ import classnames from "classnames";
3
+ import {
4
+ buildAriaProps,
5
+ buildCss,
6
+ buildDataProps,
7
+ } from "../../utilities/props";
8
+ import { globalProps } from "../../utilities/globalProps";
9
+
10
+ import DropdownContext from "../context";
11
+
12
+ import List from "../../pb_list/_list";
13
+ import ListItem from "../../pb_list/_list_item";
14
+ import TextInput from "../../pb_text_input/_text_input";
15
+ import Body from "../../pb_body/_body";
16
+
17
+ type DropdownContainerProps = {
18
+ aria?: { [key: string]: string };
19
+ className?: string;
20
+ children?: React.ReactChild[] | React.ReactChild;
21
+ data?: { [key: string]: string };
22
+ id?: string;
23
+ searchbar?: boolean;
24
+ };
25
+
26
+ const DropdownContainer = (props: DropdownContainerProps) => {
27
+ const {
28
+ aria = {},
29
+ className,
30
+ children,
31
+ data = {},
32
+ id,
33
+ searchbar = false,
34
+ } = props;
35
+
36
+ const {
37
+ isDropDownClosed,
38
+ handleChange,
39
+ filterItem,
40
+ filteredOptions,
41
+ inputRef,
42
+ setFocusedOptionIndex,
43
+ } = useContext(DropdownContext);
44
+
45
+ const ariaProps = buildAriaProps(aria);
46
+ const dataProps = buildDataProps(data);
47
+ const classes = classnames(
48
+ buildCss("pb_dropdown_container"),
49
+ `${isDropDownClosed ? "close" : "open"}`,
50
+ globalProps(props),
51
+ className
52
+ );
53
+
54
+ return (
55
+ <div {...ariaProps}
56
+ {...dataProps}
57
+ className={classes}
58
+ id={id}
59
+ onMouseEnter={() => setFocusedOptionIndex(-1)}
60
+ >
61
+ {searchbar && (
62
+ <TextInput paddingTop="xs"
63
+ paddingX="xs"
64
+ >
65
+ <input
66
+ onChange={handleChange}
67
+ placeholder="Select..."
68
+ ref={inputRef}
69
+ value={filterItem}
70
+ />
71
+ </TextInput>
72
+ )}
73
+ <List>{
74
+ filteredOptions?.length === 0 ? (
75
+ <ListItem
76
+ display="flex"
77
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
78
+ // @ts-ignore
79
+ justifyContent="center"
80
+ padding="xs"
81
+ >
82
+ <Body color="light"
83
+ text="no option"
84
+ />
85
+ </ListItem>
86
+ ): (
87
+ children
88
+ )
89
+ }
90
+ </List>
91
+ </div>
92
+ );
93
+ };
94
+
95
+ export default DropdownContainer;
@@ -0,0 +1,91 @@
1
+ import React, { useContext } from "react";
2
+ import classnames from "classnames";
3
+ import {
4
+ buildAriaProps,
5
+ buildCss,
6
+ buildDataProps,
7
+ } from "../../utilities/props";
8
+ import { globalProps } from "../../utilities/globalProps";
9
+
10
+ import DropdownContext from "../context";
11
+
12
+ import Flex from "../../pb_flex/_flex";
13
+ import Body from "../../pb_body/_body";
14
+ import ListItem from "../../pb_list/_list_item";
15
+ import { GenericObject } from "../../types";
16
+
17
+ type DropdownOptionProps = {
18
+ aria?: { [key: string]: string };
19
+ className?: string;
20
+ children?: React.ReactChild[] | React.ReactChild;
21
+ data?: { [key: string]: string };
22
+ id?: string;
23
+ option?: GenericObject;
24
+ key?: string;
25
+ };
26
+
27
+ const DropdownOption = (props: DropdownOptionProps) => {
28
+ const { aria = {}, className, children, data = {}, id, option, key } = props;
29
+
30
+ const { handleOptionClick, selected, filterItem, filteredOptions, focusedOptionIndex } =
31
+ useContext(DropdownContext);
32
+
33
+ const isItemMatchingFilter = (option: GenericObject) =>
34
+ option?.label.toLowerCase().includes(filterItem.toLowerCase());
35
+
36
+ if (!isItemMatchingFilter(option)) {
37
+ return null;
38
+ }
39
+ const isFocused = focusedOptionIndex >= 0 && filteredOptions[focusedOptionIndex].label === option.label
40
+ const focusedClass = isFocused && "dropdown_option_focused"
41
+
42
+ const selectedClass = `${
43
+ selected.label === option.label
44
+ ? "dropdown_option_selected"
45
+ : "dropdown_option_list"
46
+ }`
47
+ const ariaProps = buildAriaProps(aria);
48
+ const dataProps = buildDataProps(data);
49
+ const classes = classnames(
50
+ buildCss("pb_dropdown_option"),
51
+ selectedClass,
52
+ focusedClass,
53
+ globalProps(props),
54
+ className
55
+ );
56
+
57
+ return (
58
+ <div {...ariaProps}
59
+ {...dataProps}
60
+ className={classes}
61
+ id={id}
62
+ key={key}
63
+ >
64
+ <ListItem
65
+ cursor="pointer"
66
+ data-name={option.value}
67
+ htmlOptions={{ onClick: () => handleOptionClick(option) }}
68
+ key={option.label}
69
+ padding="xs"
70
+ >
71
+ <Flex
72
+ align="center"
73
+ className="dropdown_option"
74
+ justify="between"
75
+ paddingX="sm"
76
+ paddingY="xxs"
77
+ >
78
+ {
79
+ children ? (
80
+ children
81
+ ) : (
82
+ <Body text={option.label}/>
83
+ )
84
+ }
85
+ </Flex>
86
+ </ListItem>
87
+ </div>
88
+ );
89
+ };
90
+
91
+ export default DropdownOption;
@@ -0,0 +1,128 @@
1
+ import React, { useContext } from "react";
2
+ import classnames from "classnames";
3
+ import {
4
+ buildAriaProps,
5
+ buildCss,
6
+ buildDataProps,
7
+ } from "../../utilities/props";
8
+ import { globalProps } from "../../utilities/globalProps";
9
+ import { useHandleOnKeyDown } from "../hooks/useHandleOnKeydown";
10
+
11
+ import DropdownContext from "../context";
12
+
13
+ import Body from "../../pb_body/_body";
14
+ import Icon from "../../pb_icon/_icon";
15
+ import Flex from "../../pb_flex/_flex";
16
+ import FlexItem from "../../pb_flex/_flex_item";
17
+
18
+ type DropdownTriggerProps = {
19
+ aria?: { [key: string]: string };
20
+ children?: React.ReactChild[] | React.ReactChild;
21
+ className?: string;
22
+ customDisplay?: React.ReactChild[] | React.ReactChild;
23
+ data?: { [key: string]: string };
24
+ id?: string;
25
+ };
26
+
27
+ const DropdownTrigger = (props: DropdownTriggerProps) => {
28
+ const { aria = {}, className, children, customDisplay, data = {}, id } = props;
29
+
30
+ const {
31
+ autocomplete,
32
+ handleWrapperClick,
33
+ selected,
34
+ filterItem,
35
+ handleChange,
36
+ toggleDropdown,
37
+ isDropDownClosed,
38
+ inputRef,
39
+ isInputFocused,
40
+ setIsInputFocused
41
+ } = useContext(DropdownContext);
42
+
43
+ const handleKeyDown = useHandleOnKeyDown();
44
+
45
+ const ariaProps = buildAriaProps(aria);
46
+ const dataProps = buildDataProps(data);
47
+ const classes = classnames(
48
+ buildCss("pb_dropdown_trigger"),
49
+ globalProps(props),
50
+ className
51
+ );
52
+
53
+ return (
54
+ <div {...ariaProps}
55
+ {...dataProps}
56
+ className={classes}
57
+ id={id}
58
+ >
59
+ {children ? (
60
+ <div
61
+ onClick={() => toggleDropdown()}
62
+ style={{ display: "inline-block" }}
63
+ >
64
+ {children}
65
+ </div>
66
+ ) : (
67
+ <>
68
+ <Flex align="center"
69
+ borderRadius="lg"
70
+ className={`dropdown_trigger_wrapper ${isInputFocused && 'dropdown_trigger_wrapper_focus'}`}
71
+ cursor="pointer"
72
+ htmlOptions={{
73
+ onClick: () => handleWrapperClick(),
74
+ onKeyDown: handleKeyDown,
75
+ tabIndex:"0",
76
+ }}
77
+ justify="between"
78
+ paddingX="sm"
79
+ paddingY="xs"
80
+ >
81
+ <FlexItem>
82
+ <Flex align="center">
83
+ {customDisplay ? (
84
+ <Flex align="center">
85
+ {customDisplay}
86
+ <Body paddingLeft={`${selected.label ? "xs" : "none"}`}>
87
+ {selected.label ? <b>{selected.label}</b> : autocomplete ? "" : "Select..." }
88
+ </Body>
89
+ </Flex>
90
+ ) : (
91
+ <Body text={selected.label ? selected.label : autocomplete ? "" : "Select..."} />
92
+ )
93
+ }
94
+ {
95
+ autocomplete && (
96
+ <input
97
+ className="dropdown_input"
98
+ onChange={handleChange}
99
+ onClick={() => toggleDropdown()}
100
+ onFocus={() => setIsInputFocused(true)}
101
+ onKeyDown={handleKeyDown}
102
+ placeholder={selected.label ? "" : "Select..."}
103
+ ref={inputRef}
104
+ value={filterItem}
105
+ />
106
+ )
107
+ }
108
+
109
+ </Flex>
110
+ </FlexItem>
111
+ <FlexItem>
112
+ <Body display="flex"
113
+ key={`${isDropDownClosed ? "chevron-down" : 'chevron-up'}`}
114
+ >
115
+ <Icon cursor="pointer"
116
+ icon={`${isDropDownClosed ? "chevron-down" : 'chevron-up'}`}
117
+ size="sm"
118
+ />
119
+ </Body>
120
+ </FlexItem>
121
+ </Flex>
122
+ </>
123
+ )}
124
+ </div>
125
+ );
126
+ };
127
+
128
+ export default DropdownTrigger;
@@ -0,0 +1,59 @@
1
+ import React, { ReactElement } from "react";
2
+ import DropdownTrigger from "../subcomponents/DropdownTrigger";
3
+ import DropdownContainer from "../subcomponents/DropdownContainer";
4
+
5
+ type PrepareComponentsProps = {
6
+ children: React.ReactChild[] | React.ReactChild;
7
+ hasTriggerSubcomponent: boolean;
8
+ hasContainerSubcomponent: boolean;
9
+ trigger: React.ReactChild;
10
+ container: React.ReactChild;
11
+ otherChildren: React.ReactChild[];
12
+ };
13
+
14
+ export const separateChildComponents = (children: React.ReactChild[] | React.ReactChild | ReactElement[]) => {
15
+ let trigger: React.ReactChild = null;
16
+ let container: React.ReactChild = null;
17
+ const otherChildren: React.ReactChild[] = [];
18
+
19
+ React.Children.forEach(children, (child) => {
20
+ if (child && (child as ReactElement).type === DropdownTrigger) {
21
+ trigger = child;
22
+ } else if (child && (child as ReactElement).type === DropdownContainer) {
23
+ container = child;
24
+ } else {
25
+ otherChildren.push(child);
26
+ }
27
+ });
28
+
29
+ return { trigger, container, otherChildren };
30
+ };
31
+
32
+ export const prepareSubcomponents = ({
33
+ children,
34
+ hasTriggerSubcomponent,
35
+ hasContainerSubcomponent,
36
+ trigger,
37
+ container,
38
+ otherChildren,
39
+ }: PrepareComponentsProps) => {
40
+ const componentsToRender = [];
41
+
42
+ if (!hasTriggerSubcomponent && !hasContainerSubcomponent) {
43
+ componentsToRender.push(<DropdownTrigger />);
44
+ componentsToRender.push(<DropdownContainer>{children}</DropdownContainer>);
45
+ } else if (!hasTriggerSubcomponent && hasContainerSubcomponent) {
46
+ componentsToRender.push(<DropdownTrigger />);
47
+ componentsToRender.push(children);
48
+ } else if (hasTriggerSubcomponent && !hasContainerSubcomponent) {
49
+ componentsToRender.push(trigger);
50
+ componentsToRender.push(
51
+ <DropdownContainer>{otherChildren}</DropdownContainer>
52
+ );
53
+ } else {
54
+ componentsToRender.push(trigger);
55
+ componentsToRender.push(container);
56
+ }
57
+
58
+ return componentsToRender;
59
+ };
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag("div",
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id,
6
+ **combined_html_options) do %>
2
7
  <%= pb_rails("form_group", props: {cursor: "pointer", full_width: object.full_width}) do %>
3
8
  <label for="upload-<%= object.id %>" class="pb_button_kit_secondary_inline_enabled"><%= "#{object.label}" %></label>
4
9
  <%= pb_rails("text_input", props: {
@@ -1,4 +1,8 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= object.wrapper do %>
3
7
  <%= pb_rails("flex", props: { orientation: "row", padding_right: "lg", vertical: "center" }) do %>
4
8
  <% if (object.template != "sort_only") %>
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ id: object.id,
4
+ data: object.data,
5
+ class: object.classname,
6
+ **combined_html_options) do %>
2
7
  <%= pb_rails("icon", props: { icon: object.icon_value, classname: "pb_icon", fixed_width: true }) %>
3
8
 
4
9
  <% if content %>
@@ -1,3 +1,7 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= content.presence %>
3
7
  <% end %>
@@ -1,4 +1,7 @@
1
- <%= pb_content_tag(:div,
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
2
5
  style: object.style_value,
3
6
  **combined_html_options) do %>
4
7
  <%= content.presence %>
@@ -1,3 +1,8 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id,
6
+ **combined_html_options) do %>
2
7
  <%= content.presence %>
3
8
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= pb_content_tag(:div, class: object.classname + object.size_class, **combined_html_options) do %>
1
+ <%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, **combined_html_options) do %>
2
2
  <% if object.name.present? %>
3
3
  <%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "xs" }) %>
4
4
  <%= pb_rails("title", props: { text: object.name, size: 4, classname: "pb_form_pill_text" }) %>
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag(:span, **combined_html_options) do %>
1
+ <%= content_tag(:span,
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id,
6
+ **combined_html_options) do %>
2
7
  <%= link_to object.url, target: object.link_option do %>
3
8
  <%= pb_rails("badge", props: { dark: object.dark, variant: "primary", text: object.hashtag_text }) %>
4
9
  <% end %>
@@ -1,4 +1,8 @@
1
- <%= pb_content_tag(:span, **combined_html_options) do %>
1
+ <%= content_tag(:span,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <mark>
3
7
  <%= content.presence || object.text %>
4
8
  </mark>
@@ -1,4 +1,8 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= pb_rails("home_address_street/#{emphasis}_emphasis", props: object.send("#{emphasis}_emphasis_props")) %>
3
7
  <% end %>
4
8
 
@@ -51,7 +51,7 @@ $pb_icon_circle_sizes: (
51
51
  }
52
52
 
53
53
  @each $name, $size in $pb_icon_circle_sizes {
54
- &[class*=_#{$name}] {
54
+ &[class*=_size_#{$name}] {
55
55
  width: $size;
56
56
  height: $size;
57
57
  border-radius: $size/2;
@@ -43,7 +43,7 @@ const IconCircle = (props: IconCircleProps) => {
43
43
  const ariaProps = buildAriaProps(aria)
44
44
  const dataProps = buildDataProps(data)
45
45
  const htmlProps = buildHtmlProps(htmlOptions)
46
- const classes = classnames(buildCss('pb_icon_circle_kit', size, variant), globalProps(props), className)
46
+ const classes = classnames(buildCss('pb_icon_circle_kit', `size_${size}`, variant), globalProps(props), className)
47
47
 
48
48
 
49
49
  return (
@@ -1,3 +1,8 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
2
- <%= pb_rails("icon", props: { dark: object.dark, icon: object.icon, fixed_width: true }) %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id,
6
+ **combined_html_options) do %>
7
+ <%= pb_rails("icon", props: { dark: object.dark, icon: object.icon, fixed_width: true }) %>
3
8
  <% end %>
@@ -14,7 +14,7 @@ module Playbook
14
14
  default: "default"
15
15
 
16
16
  def classname
17
- generate_classname("pb_icon_circle_kit", size, variant)
17
+ generate_classname("pb_icon_circle_kit", "size_#{size}", variant)
18
18
  end
19
19
  end
20
20
  end
@@ -16,7 +16,7 @@ describe("IconCircle Kit", () => {
16
16
  )
17
17
 
18
18
  const kit = screen.getByTestId(testId)
19
- expect(kit).toHaveClass("pb_icon_circle_kit_md_default")
19
+ expect(kit).toHaveClass("pb_icon_circle_kit_size_md_default")
20
20
  })
21
21
 
22
22
  test("renders icon", () => {
@@ -66,7 +66,7 @@ describe("IconCircle Kit", () => {
66
66
  />
67
67
  )
68
68
  const kit = screen.getByTestId(testId)
69
- expect(kit).toHaveClass(`pb_icon_circle_kit_sm_${colorVariant}`)
69
+ expect(kit).toHaveClass(`pb_icon_circle_kit_size_sm_${colorVariant}`)
70
70
 
71
71
  cleanup()
72
72
  })
@@ -89,7 +89,7 @@ describe("IconCircle Kit", () => {
89
89
  />
90
90
  )
91
91
  const kit = screen.getByTestId(testId)
92
- expect(kit).toHaveClass(`pb_icon_circle_kit_${sizeVariant}_default`)
92
+ expect(kit).toHaveClass(`pb_icon_circle_kit_size_${sizeVariant}_default`)
93
93
 
94
94
  cleanup()
95
95
  })
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ id: object.id,
4
+ data: object.data,
5
+ class: object.classname,
6
+ **combined_html_options) do %>
2
7
 
3
8
  <%= pb_rails("icon_circle", props: {
4
9
  dark: object.dark,
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id,
6
+ **combined_html_options) do %>
2
7
  <%= pb_rails("body", props: { color: "light", dark: object.dark }) do %>
3
8
  <%= pb_rails("icon", props: { icon: object.icon, fixed_width: true }) %>
4
9
  <%= object.text %>
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ id: object.id,
4
+ data: object.data,
5
+ class: object.classname,
6
+ **combined_html_options) do %>
2
7
  <%= pb_rails("caption", props: { text: object.label, classname: "pb_label_pill_label"}) %>
3
8
  <%= pb_rails("pill", props: { text: object.pill_value, variant: object.variant, classname: "pb_label_pill_pill" }) %>
4
9
  <% end %>
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ id: object.id,
4
+ data: object.data,
5
+ class: object.classname,
6
+ **combined_html_options) do %>
2
7
  <%= pb_rails("caption", props: { text: object.label, dark: object.dark }) %>
3
8
  <% if object.variant == "details" %>
4
9
  <%= pb_rails("flex", props: {inline: true, vertical: "center"}) do %>
@@ -1,3 +1,7 @@
1
- <%= pb_content_tag(object.tag, **combined_html_options) do %>
1
+ <%= content_tag(object.tag,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= content.presence %>
3
7
  <% end %>
@@ -1,3 +1,7 @@
1
- <%= pb_content_tag(object.tag, **combined_html_options) do %>
1
+ <%= content_tag(object.tag,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= content.presence %>
3
7
  <% end %>
@@ -1,3 +1,7 @@
1
- <%= pb_content_tag(object.tag, **combined_html_options) do %>
1
+ <%= content_tag(object.tag,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= content.presence %>
3
7
  <% end %>
@@ -1,3 +1,7 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= content %>
3
7
  <% end %>
@@ -1,3 +1,7 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= content.presence %>
3
7
  <% end %>
@@ -1,3 +1,7 @@
1
- <%= pb_content_tag(:div, **combined_html_options) do %>
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= content.presence %>
3
7
  <% end %>