playbook_ui 13.25.0.pre.alpha.PBNTR291Dropdownrailsv22812 → 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 (210) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/index.js +0 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +14 -10
  4. data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +9 -5
  5. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +6 -2
  6. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +6 -2
  7. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +6 -1
  8. data/app/pb_kits/playbook/pb_background/background.html.erb +11 -2
  9. data/app/pb_kits/playbook/pb_badge/badge.html.erb +6 -1
  10. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +1 -1
  11. data/app/pb_kits/playbook/pb_body/_body.tsx +1 -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.html.erb +3 -2
  16. data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.html.erb +7 -2
  17. data/app/pb_kits/playbook/pb_caption/caption.html.erb +6 -1
  18. data/app/pb_kits/playbook/pb_card/card.html.erb +7 -1
  19. data/app/pb_kits/playbook/pb_card/card_body.html.erb +6 -1
  20. data/app/pb_kits/playbook/pb_card/card_header.html.erb +6 -1
  21. data/app/pb_kits/playbook/pb_checkbox/_checkbox.scss +0 -49
  22. data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +0 -3
  23. data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +6 -1
  24. data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +1 -2
  25. data/app/pb_kits/playbook/pb_checkbox/checkbox.test.js +0 -14
  26. data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +0 -2
  27. data/app/pb_kits/playbook/pb_checkbox/docs/index.js +0 -1
  28. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +6 -1
  29. data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +6 -1
  30. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +6 -1
  31. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +7 -1
  32. data/app/pb_kits/playbook/pb_contact/contact.html.erb +6 -1
  33. data/app/pb_kits/playbook/pb_currency/currency.html.erb +6 -1
  34. data/app/pb_kits/playbook/pb_currency/docs/example.yml +0 -5
  35. data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.html.erb +6 -1
  36. data/app/pb_kits/playbook/pb_date/date.html.erb +6 -1
  37. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +6 -2
  38. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.md +1 -3
  39. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_close.md +1 -3
  40. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_range_limit.md +1 -1
  41. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.html.erb +5 -1
  42. data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.html.erb +5 -1
  43. data/app/pb_kits/playbook/pb_date_range_stacked/docs/example.yml +0 -4
  44. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +5 -1
  45. data/app/pb_kits/playbook/pb_date_time/date_time.html.erb +6 -1
  46. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +7 -1
  47. data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.html.erb +5 -1
  48. data/app/pb_kits/playbook/pb_detail/detail.html.erb +6 -1
  49. data/app/pb_kits/playbook/pb_dialog/_dialog.scss +2 -4
  50. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +6 -1
  51. data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +7 -2
  52. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +5 -1
  53. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +6 -2
  54. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +35 -101
  55. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +26 -93
  56. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.jsx +22 -4
  57. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +4 -6
  58. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.jsx +9 -6
  59. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.jsx +5 -5
  60. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +2 -16
  61. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +0 -7
  62. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +10 -200
  63. data/app/pb_kits/playbook/pb_dropdown/hooks/useDropdown.tsx +2 -2
  64. data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +9 -14
  65. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +8 -22
  66. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +29 -56
  67. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +68 -130
  68. data/app/pb_kits/playbook/pb_dropdown/utilities/subComponentHelper.tsx +7 -9
  69. data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +6 -1
  70. data/app/pb_kits/playbook/pb_filter/filter.html.erb +5 -1
  71. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +6 -1
  72. data/app/pb_kits/playbook/pb_flex/flex.html.erb +5 -1
  73. data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +6 -2
  74. data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +6 -1
  75. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
  76. data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +6 -1
  77. data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +5 -1
  78. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +5 -1
  79. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.html.erb +7 -2
  80. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +6 -1
  81. data/app/pb_kits/playbook/pb_icon_value/icon_value.html.erb +6 -1
  82. data/app/pb_kits/playbook/pb_label_pill/label_pill.html.erb +6 -1
  83. data/app/pb_kits/playbook/pb_label_value/label_value.html.erb +6 -1
  84. data/app/pb_kits/playbook/pb_layout/body.html.erb +5 -1
  85. data/app/pb_kits/playbook/pb_layout/footer.html.erb +5 -1
  86. data/app/pb_kits/playbook/pb_layout/header.html.erb +5 -1
  87. data/app/pb_kits/playbook/pb_layout/item.html.erb +5 -1
  88. data/app/pb_kits/playbook/pb_layout/layout.html.erb +5 -1
  89. data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +5 -1
  90. data/app/pb_kits/playbook/pb_list/item.html.erb +8 -2
  91. data/app/pb_kits/playbook/pb_list/list.html.erb +8 -2
  92. data/app/pb_kits/playbook/pb_loading_inline/loading_inline.html.erb +6 -1
  93. data/app/pb_kits/playbook/pb_message/message.html.erb +6 -1
  94. data/app/pb_kits/playbook/pb_message/message_mention.html.erb +6 -1
  95. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +6 -1
  96. data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +6 -1
  97. data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +6 -1
  98. data/app/pb_kits/playbook/pb_nav/item.html.erb +14 -3
  99. data/app/pb_kits/playbook/pb_nav/nav.html.erb +6 -1
  100. data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +6 -2
  101. data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +6 -1
  102. data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
  103. data/app/pb_kits/playbook/pb_person/person.html.erb +12 -7
  104. data/app/pb_kits/playbook/pb_person_contact/person_contact.html.erb +6 -1
  105. data/app/pb_kits/playbook/pb_pill/pill.html.erb +6 -1
  106. data/app/pb_kits/playbook/pb_popover/popover.html.erb +6 -1
  107. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +6 -2
  108. data/app/pb_kits/playbook/pb_progress_simple/docs/example.yml +0 -2
  109. data/app/pb_kits/playbook/pb_progress_simple/docs/index.js +0 -1
  110. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +6 -3
  111. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.rb +1 -1
  112. data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +5 -1
  113. data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +5 -1
  114. data/app/pb_kits/playbook/pb_radio/_radio.scss +0 -35
  115. data/app/pb_kits/playbook/pb_radio/_radio.tsx +0 -3
  116. data/app/pb_kits/playbook/pb_radio/docs/_radio_alignment.jsx +1 -4
  117. data/app/pb_kits/playbook/pb_radio/docs/_radio_default.jsx +1 -4
  118. data/app/pb_kits/playbook/pb_radio/docs/_radio_error.jsx +1 -2
  119. data/app/pb_kits/playbook/pb_radio/docs/example.yml +0 -2
  120. data/app/pb_kits/playbook/pb_radio/docs/index.js +0 -1
  121. data/app/pb_kits/playbook/pb_radio/radio.html.erb +8 -2
  122. data/app/pb_kits/playbook/pb_radio/radio.rb +0 -5
  123. data/app/pb_kits/playbook/pb_radio/radio.test.js +0 -17
  124. data/app/pb_kits/playbook/pb_section_separator/_section_separator.scss +2 -6
  125. data/app/pb_kits/playbook/pb_section_separator/_section_separator_mixin.scss +1 -11
  126. data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +6 -1
  127. data/app/pb_kits/playbook/pb_select/select.html.erb +5 -1
  128. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +5 -1
  129. data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +4 -1
  130. data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +5 -1
  131. data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +6 -1
  132. data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +6 -1
  133. data/app/pb_kits/playbook/pb_source/source.html.erb +5 -1
  134. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +5 -1
  135. data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +5 -1
  136. data/app/pb_kits/playbook/pb_stat_value/stat_value.html.erb +5 -1
  137. data/app/pb_kits/playbook/pb_table/table.html.erb +12 -2
  138. data/app/pb_kits/playbook/pb_table/table_body.html.erb +16 -6
  139. data/app/pb_kits/playbook/pb_table/table_cell.html.erb +16 -6
  140. data/app/pb_kits/playbook/pb_table/table_head.html.erb +16 -6
  141. data/app/pb_kits/playbook/pb_table/table_header.html.erb +13 -4
  142. data/app/pb_kits/playbook/pb_table/table_row.html.erb +16 -6
  143. data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +5 -1
  144. data/app/pb_kits/playbook/pb_time/time.html.erb +5 -1
  145. data/app/pb_kits/playbook/pb_time_range_inline/time_range_inline.html.erb +5 -1
  146. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +5 -1
  147. data/app/pb_kits/playbook/pb_timeline/item.html.erb +7 -3
  148. data/app/pb_kits/playbook/pb_timeline/timeline.html.erb +5 -1
  149. data/app/pb_kits/playbook/pb_timestamp/timestamp.html.erb +6 -1
  150. data/app/pb_kits/playbook/pb_title/title.html.erb +6 -1
  151. data/app/pb_kits/playbook/pb_title_count/title_count.html.erb +6 -1
  152. data/app/pb_kits/playbook/pb_title_detail/title_detail.html.erb +5 -1
  153. data/app/pb_kits/playbook/pb_toggle/toggle.html.erb +6 -1
  154. data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +5 -1
  155. data/app/pb_kits/playbook/pb_user/user.html.erb +6 -1
  156. data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +6 -1
  157. data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb +6 -1
  158. data/app/pb_kits/playbook/playbook-rails.js +0 -3
  159. data/dist/playbook-rails.js +5 -5
  160. data/lib/playbook/kit_base.rb +1 -1
  161. data/lib/playbook/version.rb +1 -1
  162. metadata +2 -50
  163. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_disabled.html.erb +0 -23
  164. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_disabled.jsx +0 -29
  165. data/app/pb_kits/playbook/pb_currency/docs/_currency_alignment_swift.md +0 -43
  166. data/app/pb_kits/playbook/pb_currency/docs/_currency_props_swift.md +0 -12
  167. data/app/pb_kits/playbook/pb_currency/docs/_currency_size_swift.md +0 -31
  168. data/app/pb_kits/playbook/pb_date_range_stacked/docs/_date_range_stacked_default_swift.md +0 -14
  169. data/app/pb_kits/playbook/pb_date_range_stacked/docs/_date_range_stacked_props_swift.md +0 -9
  170. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.html.erb +0 -10
  171. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.md +0 -1
  172. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.html.erb +0 -17
  173. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.jsx +0 -42
  174. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.md +0 -7
  175. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +0 -84
  176. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.md +0 -1
  177. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx +0 -101
  178. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.md +0 -1
  179. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.html.erb +0 -60
  180. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.md +0 -5
  181. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.html.erb +0 -45
  182. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.md +0 -1
  183. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.html.erb +0 -17
  184. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.jsx +0 -48
  185. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.md +0 -1
  186. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.html.erb +0 -47
  187. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.md +0 -1
  188. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_external_control.jsx +0 -59
  189. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx +0 -72
  190. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.html.erb +0 -10
  191. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.jsx +0 -39
  192. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.md +0 -1
  193. data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +0 -21
  194. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +0 -20
  195. data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +0 -15
  196. data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +0 -19
  197. data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +0 -22
  198. data/app/pb_kits/playbook/pb_dropdown/dropdown_option.rb +0 -22
  199. data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +0 -38
  200. data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +0 -30
  201. data/app/pb_kits/playbook/pb_dropdown/index.js +0 -154
  202. data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +0 -77
  203. data/app/pb_kits/playbook/pb_dropdown/scss_partials/_dropdown_animation.scss +0 -18
  204. data/app/pb_kits/playbook/pb_dropdown/utilities/clickOutsideHelper.tsx +0 -41
  205. data/app/pb_kits/playbook/pb_dropdown/utilities/index.ts +0 -2
  206. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_flex.html.erb +0 -3
  207. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_flex.jsx +0 -16
  208. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_flex.md +0 -1
  209. data/app/pb_kits/playbook/pb_radio/docs/_radio_disabled.html.erb +0 -26
  210. data/app/pb_kits/playbook/pb_radio/docs/_radio_disabled.jsx +0 -31
@@ -1,154 +0,0 @@
1
- import PbEnhancedElement from "../pb_enhanced_element";
2
- import { PbDropdownKeyboard } from "./keyboard_accessibility";
3
-
4
- const DROPDOWN_SELECTOR = "[data-pb-dropdown]";
5
- const TRIGGER_SELECTOR = "[data-dropdown-trigger]";
6
- const CONTAINER_SELECTOR = "[data-dropdown-container]";
7
- const DOWN_ARROW_SELECTOR = "#dropdown_open_icon";
8
- const UP_ARROW_SELECTOR = "#dropdown_close_icon";
9
- const OPTION_SELECTOR = "[data-dropdown-option-label]";
10
- const CUSTOM_DISPLAY_SELECTOR = "[data-dropdown-custom-trigger]";
11
-
12
- export default class PbDropdown extends PbEnhancedElement {
13
- static get selector() {
14
- return DROPDOWN_SELECTOR;
15
- }
16
-
17
- connect() {
18
- this.keyboardHandler = new PbDropdownKeyboard(this);
19
- this.bindEventListeners();
20
- this.updateArrowDisplay(false);
21
- }
22
-
23
- bindEventListeners() {
24
- const customTrigger =
25
- this.element.querySelector(CUSTOM_DISPLAY_SELECTOR) || this.element;
26
- customTrigger.addEventListener("click", () =>
27
- this.toggleElement(this.target)
28
- );
29
-
30
- this.target.addEventListener("click", this.handleOptionClick.bind(this));
31
- document.addEventListener(
32
- "click",
33
- this.handleDocumentClick.bind(this),
34
- true
35
- );
36
- }
37
-
38
- handleOptionClick(event) {
39
- const option = event.target.closest(OPTION_SELECTOR);
40
- const hiddenInput = this.element.querySelector("#dropdown-selected-option");
41
- if (option) {
42
- const value = option.dataset.dropdownOptionLabel;
43
- hiddenInput.value = JSON.parse(value).id;
44
- this.onOptionSelected(value, option);
45
- }
46
- }
47
-
48
- handleDocumentClick(event) {
49
- if (this.isClickOutside(event) && this.target.classList.contains("open")) {
50
- this.hideElement(this.target);
51
- this.updateArrowDisplay(false);
52
- }
53
- }
54
-
55
- isClickOutside(event) {
56
- const customTrigger = this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);
57
- if (customTrigger) {
58
- return !customTrigger.contains(event.target);
59
- } else {
60
- const triggerElement = this.element.querySelector(TRIGGER_SELECTOR);
61
- const containerElement =
62
- this.element.parentNode.querySelector(CONTAINER_SELECTOR);
63
-
64
- const isOutsideTrigger = triggerElement
65
- ? !triggerElement.contains(event.target)
66
- : true;
67
- const isOutsideContainer = containerElement
68
- ? !containerElement.contains(event.target)
69
- : true;
70
-
71
- return isOutsideTrigger && isOutsideContainer;
72
- }
73
- }
74
-
75
- onOptionSelected(value, selectedOption) {
76
- const triggerElement = this.element.querySelector(
77
- "#dropdown_trigger_display"
78
- );
79
- const customDisplayElement = this.element.querySelector(
80
- "#dropdown_trigger_custom_display"
81
- );
82
- if (triggerElement) {
83
- const selectedLabel = JSON.parse(value).label;
84
- triggerElement.textContent = selectedLabel;
85
- if (customDisplayElement) {
86
- customDisplayElement.style.display = "block";
87
- customDisplayElement.style.paddingRight = "8px";
88
- }
89
- }
90
-
91
- const customTrigger = this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);
92
- if (customTrigger) {
93
- if (this.target.classList.contains("open")) {
94
- this.hideElement(this.target);
95
- this.updateArrowDisplay(false);
96
- }
97
- }
98
-
99
- const options = this.element.querySelectorAll(OPTION_SELECTOR);
100
- options.forEach((option) => {
101
- option.classList.remove("pb_dropdown_option_selected");
102
- });
103
- selectedOption.classList.add("pb_dropdown_option_selected");
104
- console.log(`Selected value: ${value}`);
105
- }
106
-
107
- get target() {
108
- return this.element.parentNode.querySelector(CONTAINER_SELECTOR);
109
- }
110
-
111
- showElement(elem) {
112
- elem.classList.remove("close");
113
- elem.classList.add("open");
114
- elem.style.height = elem.scrollHeight + "px";
115
- }
116
-
117
- hideElement(elem) {
118
- elem.style.height = elem.scrollHeight + "px";
119
- window.setTimeout(() => {
120
- elem.classList.add("close");
121
- elem.classList.remove("open");
122
- this.resetFocus();
123
- }, 0);
124
- }
125
-
126
- resetFocus() {
127
- if (this.keyboardHandler) {
128
- this.keyboardHandler.focusedOptionIndex = -1;
129
- const options = this.element.querySelectorAll(OPTION_SELECTOR);
130
- options.forEach((option) =>
131
- option.classList.remove("pb_dropdown_option_focused")
132
- );
133
- }
134
- }
135
-
136
- toggleElement(elem) {
137
- if (elem.classList.contains("open")) {
138
- this.hideElement(elem);
139
- this.updateArrowDisplay(false);
140
- return;
141
- }
142
- this.showElement(elem);
143
- this.updateArrowDisplay(true);
144
- }
145
-
146
- updateArrowDisplay(isOpen) {
147
- const downArrow = this.element.querySelector(DOWN_ARROW_SELECTOR);
148
- const upArrow = this.element.querySelector(UP_ARROW_SELECTOR);
149
- if (downArrow && upArrow) {
150
- downArrow.style.display = isOpen ? "none" : "inline-block";
151
- upArrow.style.display = isOpen ? "inline-block" : "none";
152
- }
153
- }
154
- }
@@ -1,77 +0,0 @@
1
- const OPTION_SELECTOR = "[data-dropdown-option-label]";
2
- export class PbDropdownKeyboard {
3
- constructor(dropdown) {
4
- this.dropdown = dropdown;
5
- this.dropdownElement = dropdown.element;
6
- this.options = Array.from(
7
- this.dropdownElement.querySelectorAll(OPTION_SELECTOR)
8
- );
9
- this.focusedOptionIndex = -1;
10
- this.init();
11
- }
12
-
13
- init() {
14
- this.dropdownElement.addEventListener(
15
- "keydown",
16
- this.handleKeyDown.bind(this)
17
- );
18
- }
19
-
20
- handleKeyDown(event) {
21
- switch (event.key) {
22
- case "ArrowDown":
23
- event.preventDefault();
24
- if (!this.dropdown.target.classList.contains("open")) {
25
- this.dropdown.showElement(this.dropdown.target);
26
- this.dropdown.updateArrowDisplay(true);
27
- }
28
- this.moveFocus(1);
29
- break;
30
- case "ArrowUp":
31
- event.preventDefault();
32
- this.moveFocus(-1);
33
- break;
34
- case "Enter":
35
- event.preventDefault();
36
- if (this.focusedOptionIndex !== -1) {
37
- this.selectOption();
38
- } else {
39
- if (!this.dropdown.target.classList.contains("open")) {
40
- this.dropdown.showElement(this.dropdown.target);
41
- this.dropdown.updateArrowDisplay(true);
42
- }
43
- }
44
- break;
45
- case "Escape":
46
- this.dropdown.hideElement(this.dropdown.target);
47
- break;
48
- case "Tab":
49
- this.dropdown.hideElement(this.dropdown.target);
50
- this.dropdown.updateArrowDisplay(false);
51
- this.resetFocus();
52
- break;
53
- default:
54
- break;
55
- }
56
- }
57
-
58
- moveFocus(direction) {
59
- if (this.focusedOptionIndex !== -1) {
60
- this.options[this.focusedOptionIndex].classList.remove(
61
- "pb_dropdown_option_focused"
62
- );
63
- }
64
- this.focusedOptionIndex =
65
- (this.focusedOptionIndex + direction + this.options.length) %
66
- this.options.length;
67
- this.options[this.focusedOptionIndex].classList.add(
68
- "pb_dropdown_option_focused"
69
- );
70
- }
71
-
72
- selectOption() {
73
- const option = this.options[this.focusedOptionIndex];
74
- this.dropdown.onOptionSelected(option.dataset.dropdownOptionLabel, option);
75
- this.dropdown.hideElement(this.dropdown.target);
76
- }
77
- }
@@ -1,18 +0,0 @@
1
- @keyframes fadeIn {
2
- from {
3
- opacity: 0;
4
- }
5
-
6
- to {
7
- opacity: 1;
8
- }
9
- }
10
- @keyframes fadeOut {
11
- from {
12
- opacity: 1;
13
- }
14
-
15
- to {
16
- opacity: 0;
17
- }
18
- }
@@ -1,41 +0,0 @@
1
- type HandleClickOutsideType = {
2
- inputWrapperRef?: React.RefObject<HTMLDivElement>;
3
- dropdownContainerRef?: React.RefObject<HTMLDivElement>;
4
- setIsDropDownClosed?: (value: boolean) => void;
5
- setFocusedOptionIndex?: (value: number) => void;
6
- setIsInputFocused?: (value: boolean) => void;
7
- };
8
-
9
- export const handleClickOutside =
10
- ({
11
- inputWrapperRef,
12
- dropdownContainerRef,
13
- setIsDropDownClosed,
14
- setFocusedOptionIndex,
15
- setIsInputFocused,
16
- }: HandleClickOutsideType) =>
17
- (e: MouseEvent) => {
18
- let targetElement = e.target as HTMLElement;
19
- let shouldClose = true;
20
-
21
- //Only needed for when useDropdown hook used with external trigger
22
- while (targetElement && shouldClose) {
23
- if (
24
- targetElement.getAttribute("data-dropdown") === "pb-dropdown-trigger"
25
- ) {
26
- shouldClose = false;
27
- }
28
- targetElement = targetElement.parentElement as HTMLElement;
29
- }
30
- if (
31
- inputWrapperRef.current &&
32
- !inputWrapperRef.current.contains((e.target as HTMLElement)) &&
33
- dropdownContainerRef.current &&
34
- !dropdownContainerRef.current.contains((e.target as HTMLElement)) &&
35
- shouldClose
36
- ) {
37
- setIsDropDownClosed(true);
38
- setFocusedOptionIndex(-1);
39
- setIsInputFocused(false);
40
- }
41
- };
@@ -1,2 +0,0 @@
1
- export { separateChildComponents, prepareSubcomponents } from './subComponentHelper';
2
- export { handleClickOutside } from './clickOutsideHelper';
@@ -1,3 +0,0 @@
1
- <%= pb_rails("flex") do %>
2
- <%= pb_rails("progress_simple", props: { flex: "1", percent: 50 }) %>
3
- <% end %>
@@ -1,16 +0,0 @@
1
- import React from 'react'
2
- import { Flex, ProgressSimple } from '../..'
3
-
4
- const ProgressSimpleFlex = () => {
5
- return (
6
- <Flex>
7
- <ProgressSimple
8
- align="left"
9
- flex="1"
10
- percent={68}
11
- />
12
- </Flex>
13
- )
14
- }
15
-
16
- export default ProgressSimpleFlex
@@ -1 +0,0 @@
1
- When rendering a Progress Simple through within a Flex container, you must pass `flex="1"` to the kit itself so that it fills the available space
@@ -1,26 +0,0 @@
1
- <%= pb_rails("flex", props: {orientation: "column"}) do %>
2
- <%= pb_rails("flex/flex_item") do %>
3
- <%= pb_rails("radio", props: {
4
- text: "Disabled unselected",
5
- input_options: {
6
- tabindex: 0,
7
- disabled: true,
8
- },
9
- margin_bottom: "xs",
10
- name: "DisabledGroup",
11
- value: "Disabled unselected",
12
- }) %>
13
- <% end %>
14
- <%= pb_rails("flex/flex_item") do %>
15
- <%= pb_rails("radio", props: {
16
- text: "Disabled selected",
17
- input_options: {
18
- tabindex: 0,
19
- disabled: true,
20
- },
21
- checked: true,
22
- name: "DisabledGroup",
23
- value: "Disabled selected"
24
- }) %>
25
- <% end %>
26
- <% end %>
@@ -1,31 +0,0 @@
1
- import React from 'react'
2
-
3
- import Radio from '../_radio'
4
-
5
- const RadioDisabled = (props) => {
6
- const ref = React.createRef()
7
-
8
- return (
9
- <div style={{ display: "flex", flexDirection: "column" }}>
10
- <Radio
11
- disabled
12
- label="Disabled unselected"
13
- marginBottom="xs"
14
- name="DisabledGroup"
15
- ref={ref}
16
- tabIndex={0}
17
- value="Disabled unselected"
18
- {...props}
19
- />
20
- <Radio
21
- checked
22
- disabled
23
- label="Disabled selected"
24
- name="DisabledGroup"
25
- value="Disabled selected"
26
- {...props}
27
- />
28
- </div>
29
- )
30
- }
31
- export default RadioDisabled