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,23 +1,9 @@
1
1
  examples:
2
- rails:
3
- - dropdown_default: Default
4
- - dropdown_subcomponent_structure: Subcomponent Structure
5
- - dropdown_with_label: With Label
6
- - dropdown_with_custom_options: Custom Options
7
- - dropdown_with_custom_display: Custom Display
8
- - dropdown_with_custom_trigger: Custom Trigger
9
- - dropdown_with_custom_padding: Custom Padding for Dropdown Options
10
-
2
+
3
+
11
4
  react:
12
5
  - dropdown_default: Default
13
- - dropdown_subcomponent_structure: Subcomponent Structure
14
- - dropdown_with_label: With Label
15
6
  - dropdown_with_custom_options: Custom Options
16
7
  - dropdown_with_custom_display: Custom Display
17
8
  - dropdown_with_custom_trigger: Custom Trigger
18
- - dropdown_with_custom_padding: Custom Padding for Dropdown Options
19
- # - dropdown_with_autocomplete: Autocomplete
20
- # - dropdown_with_autocomplete_and_custom_display: Autocomplete with Custom Display
21
- # - dropdown_with_external_control: useDropdown Hook
22
- # - dropdown_with_hook: useDropdown Hook with Any Trigger
23
9
 
@@ -2,10 +2,3 @@ export { default as DropdownDefault } from './_dropdown_default.jsx'
2
2
  export { default as DropdownWithCustomDisplay } from './_dropdown_with_custom_display.jsx'
3
3
  export { default as DropdownWithCustomOptions } from './_dropdown_with_custom_options.jsx'
4
4
  export { default as DropdownWithCustomTrigger } from './_dropdown_with_custom_trigger.jsx'
5
- export { default as DropdownWithAutocomplete } from './_dropdown_with_autocomplete.jsx'
6
- export { default as DropdownWithAutocompleteAndCustomDisplay } from './_dropdown_with_autocomplete_and_custom_display.jsx'
7
- export { default as DropdownWithCustomPadding } from './_dropdown_with_custom_padding.jsx'
8
- export { default as DropdownWithLabel } from './_dropdown_with_label.jsx'
9
- export { default as DropdownWithExternalControl } from './_dropdown_with_external_control.jsx'
10
- export { default as DropdownWithHook } from './_dropdown_with_hook.jsx'
11
- export { default as DropdownSubcomponentStructure } from './_dropdown_subcomponent_structure.jsx'
@@ -1,207 +1,17 @@
1
- import React from "react"
2
- import { render, screen } from "../utilities/test-utils"
1
+ import { renderKit } from '../utilities/test-utils'
3
2
 
4
- import { Dropdown, Icon } from '../'
3
+ import { Dropdown } from '../'
5
4
 
5
+ /* See these resources for more testing info:
6
+ - https://github.com/testing-library/jest-dom#usage for useage and examples
7
+ - https://jestjs.io/docs/en/using-matchers
8
+ */
6
9
 
7
- const testId = 'dropdown'
8
-
9
- const options = [
10
- {
11
- label: "United States",
12
- value: "United States",
13
- areaCode: "+1",
14
- icon: "🇺🇸",
15
- id: "United-states"
16
- },
17
- {
18
- label: "Canada",
19
- value: "Canada",
20
- areaCode: "+1",
21
- icon: "🇨🇦",
22
- id: "canada"
23
- },
24
- {
25
- label: "Pakistan",
26
- value: "Pakistan",
27
- areaCode: "+92",
28
- icon: "🇵🇰",
29
- id: "pakistan"
10
+ test('generated scaffold test - update me', () => {
11
+ const props = {
12
+ data: { testid: 'default' }
30
13
  }
31
- ];
32
-
33
- const DefaultDropdownKit = () => {
34
- return (
35
- <Dropdown
36
- data={{ testid: testId }}
37
- options={options}
38
- >
39
- {options.map((option) => (
40
- <Dropdown.Option key={option.id}
41
- option={option}
42
- />
43
- ))}
44
- </Dropdown>
45
- )
46
- }
47
14
 
48
- test('generated default kit and classname', () => {
49
- render(<DefaultDropdownKit/>)
50
-
51
- const kit = screen.getByTestId(testId)
15
+ const kit = renderKit(Dropdown , props)
52
16
  expect(kit).toBeInTheDocument()
53
- expect(kit).toHaveClass('pb_dropdown')
54
- })
55
-
56
- test('generated default Trigger and Container when none passed in', () => {
57
- render(<DefaultDropdownKit/>)
58
-
59
- const kit = screen.getByTestId(testId)
60
-
61
- const trigger = kit.querySelector('.pb_dropdown_trigger')
62
- expect(trigger).toBeInTheDocument()
63
-
64
- const container = kit.querySelector('.pb_dropdown_container')
65
- expect(container).toBeInTheDocument()
66
-
67
- const defaultTrigger = kit.querySelector('.dropdown_trigger_wrapper_select_only')
68
- expect(defaultTrigger).toBeInTheDocument()
69
- })
70
-
71
- test('generated Options', () => {
72
- render(<DefaultDropdownKit/>)
73
-
74
- const kit = screen.getByTestId(testId)
75
- const option = kit.querySelector('.pb_dropdown_option_list')
76
- expect(option).toBeInTheDocument()
77
- })
78
-
79
- test('generated customDisplay for trigger', () => {
80
- render (
81
- <Dropdown
82
- data={{ testid: testId }}
83
- options={options}
84
- >
85
- <Dropdown.Trigger
86
- customDisplay={<Icon icon="flag" />}
87
- />
88
- {options.map((option) => (
89
- <Dropdown.Option key={option.id}
90
- option={option}
91
- />
92
- ))}
93
- </Dropdown>
94
- )
95
-
96
- const kit = screen.getByTestId(testId)
97
- const trigger = kit.querySelector('.pb_dropdown_trigger')
98
- const customDisplay = trigger.querySelector('.fa-flag.pb_icon_kit.fa-fw')
99
- expect(customDisplay).toBeInTheDocument()
100
17
  })
101
-
102
- test('generated placeholder prop', () => {
103
- render (
104
- <Dropdown
105
- data={{ testid: testId }}
106
- options={options}
107
- >
108
- <Dropdown.Trigger
109
- placeholder="Select a country"
110
- />
111
- {options.map((option) => (
112
- <Dropdown.Option key={option.id}
113
- option={option}
114
- />
115
- ))}
116
- </Dropdown>
117
- )
118
-
119
- const kit = screen.getByTestId(testId)
120
- const trigger = kit.querySelector('.pb_dropdown_trigger')
121
- expect(trigger).toHaveTextContent('Select a country')
122
-
123
- })
124
-
125
- test('generated label prop', () => {
126
- render (
127
- <Dropdown
128
- data={{ testid: testId }}
129
- label="Countries"
130
- options={options}
131
- >
132
- {options.map((option) => (
133
- <Dropdown.Option key={option.id}
134
- option={option}
135
- />
136
- ))}
137
- </Dropdown>
138
- )
139
-
140
- const kit = screen.getByTestId(testId)
141
- const label = kit.querySelector('.pb_caption_kit_md')
142
- expect(label).toHaveTextContent('Countries')
143
- })
144
-
145
- test('generated custom option', () => {
146
- render (
147
- <Dropdown
148
- data={{ testid: testId }}
149
- options={options}
150
- >
151
- {options.map((option) => (
152
- <Dropdown.Option key={option.id}
153
- option={option}
154
- >
155
- <Icon icon={option.icon} />
156
- </Dropdown.Option>
157
- ))}
158
- </Dropdown>
159
- )
160
-
161
- const kit = screen.getByTestId(testId)
162
- const customOption = kit.querySelector('.pb_icon_kit_emoji')
163
- expect(customOption).toBeInTheDocument()
164
- })
165
-
166
- test('generated custom Trigger', () => {
167
- render (
168
- <Dropdown
169
- data={{ testid: testId }}
170
- options={options}
171
- >
172
- <Dropdown.Trigger>
173
- <Icon icon="home" />
174
- </Dropdown.Trigger>
175
- {options.map((option) => (
176
- <Dropdown.Option key={option.id}
177
- option={option}
178
- />
179
- ))}
180
- </Dropdown>
181
- )
182
-
183
- const kit = screen.getByTestId(testId)
184
- const trigger = kit.querySelector('.pb_dropdown_trigger')
185
- const customTrigger = trigger.querySelector('.fa-home.pb_icon_kit.fa-fw')
186
- expect(customTrigger).toBeInTheDocument()
187
- })
188
-
189
- test('selected option on click', () => {
190
- render (
191
- <Dropdown
192
- data={{ testid: testId }}
193
- options={options}
194
- >
195
- {options.map((option) => (
196
- <Dropdown.Option key={option.id}
197
- option={option}
198
- />
199
- ))}
200
- </Dropdown>
201
- )
202
-
203
- const kit = screen.getByTestId(testId)
204
- const option = kit.querySelector('.pb_dropdown_option_list')
205
- option.click()
206
- expect(option).toHaveClass('pb_dropdown_option_selected p_xs')
207
- })
@@ -1,11 +1,11 @@
1
1
  import {useState} from 'react';
2
2
 
3
3
 
4
- const useDropdown = (initial= true) => {
4
+ const useDropdown = (initial=true) => {
5
5
 
6
6
  const [isDropDownClosed, setIsDropDownClosed] = useState(initial);
7
7
 
8
- const toggleDropdown = () => setIsDropDownClosed((prev) => !prev);
8
+ const toggleDropdown = () => setIsDropDownClosed(!isDropDownClosed);
9
9
 
10
10
  return [
11
11
  isDropDownClosed,
@@ -6,21 +6,16 @@ export const useHandleOnKeyDown = () => {
6
6
 
7
7
  const {
8
8
  autocomplete,
9
- filteredOptions,
10
9
  focusedOptionIndex,
11
- handleBackspace,
12
- handleOptionClick,
13
- selected,
10
+ filteredOptions,
14
11
  setFocusedOptionIndex,
12
+ handleOptionClick,
15
13
  setIsDropDownClosed,
14
+ handleBackspace,
15
+ selected
16
16
  }= useContext(DropdownContext)
17
17
 
18
18
  return (e: React.KeyboardEvent) => {
19
-
20
- if (e.key !== "Tab" && autocomplete && selected && selected.label) {
21
- handleBackspace();
22
- }
23
-
24
19
  switch (e.key) {
25
20
  case "Backspace":
26
21
  case "Delete":
@@ -48,13 +43,13 @@ const {
48
43
  e.preventDefault();
49
44
  handleOptionClick(filteredOptions[focusedOptionIndex]);
50
45
  setFocusedOptionIndex(-1)
51
- } else if (focusedOptionIndex === -1) {
52
- setIsDropDownClosed(false)
53
46
  }
54
47
  break;
55
- case "Tab":
56
- setIsDropDownClosed(true);
57
- setFocusedOptionIndex(-1)
48
+ default:
49
+ if (selected && selected.label) {
50
+ e.preventDefault();
51
+ handleBackspace();
52
+ }
58
53
  break;
59
54
  }
60
55
  }
@@ -4,7 +4,6 @@ import {
4
4
  buildAriaProps,
5
5
  buildCss,
6
6
  buildDataProps,
7
- buildHtmlProps
8
7
  } from "../../utilities/props";
9
8
  import { globalProps } from "../../utilities/globalProps";
10
9
 
@@ -17,11 +16,9 @@ import Body from "../../pb_body/_body";
17
16
 
18
17
  type DropdownContainerProps = {
19
18
  aria?: { [key: string]: string };
20
- children?: React.ReactChild[] | React.ReactChild;
21
19
  className?: string;
22
- dark?: boolean;
20
+ children?: React.ReactChild[] | React.ReactChild;
23
21
  data?: { [key: string]: string };
24
- htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
25
22
  id?: string;
26
23
  searchbar?: boolean;
27
24
  };
@@ -29,29 +26,24 @@ type DropdownContainerProps = {
29
26
  const DropdownContainer = (props: DropdownContainerProps) => {
30
27
  const {
31
28
  aria = {},
32
- children,
33
29
  className,
34
- dark = false,
30
+ children,
35
31
  data = {},
36
- htmlOptions = {},
37
32
  id,
38
33
  searchbar = false,
39
34
  } = props;
40
35
 
41
36
  const {
42
- dropdownContainerRef,
43
- filteredOptions,
44
- filterItem,
37
+ isDropDownClosed,
45
38
  handleChange,
39
+ filterItem,
40
+ filteredOptions,
46
41
  inputRef,
47
- isDropDownClosed,
48
42
  setFocusedOptionIndex,
49
- triggerRef
50
43
  } = useContext(DropdownContext);
51
44
 
52
45
  const ariaProps = buildAriaProps(aria);
53
46
  const dataProps = buildDataProps(data);
54
- const htmlProps = buildHtmlProps(htmlOptions);
55
47
  const classes = classnames(
56
48
  buildCss("pb_dropdown_container"),
57
49
  `${isDropDownClosed ? "close" : "open"}`,
@@ -62,16 +54,12 @@ const DropdownContainer = (props: DropdownContainerProps) => {
62
54
  return (
63
55
  <div {...ariaProps}
64
56
  {...dataProps}
65
- {...htmlProps}
66
57
  className={classes}
67
58
  id={id}
68
59
  onMouseEnter={() => setFocusedOptionIndex(-1)}
69
- ref={dropdownContainerRef}
70
- style={triggerRef ? {} : { position: "absolute"}}
71
60
  >
72
61
  {searchbar && (
73
- <TextInput dark={dark}
74
- paddingTop="xs"
62
+ <TextInput paddingTop="xs"
75
63
  paddingX="xs"
76
64
  >
77
65
  <input
@@ -82,10 +70,9 @@ const DropdownContainer = (props: DropdownContainerProps) => {
82
70
  />
83
71
  </TextInput>
84
72
  )}
85
- <List dark={dark}>
86
- {
73
+ <List>{
87
74
  filteredOptions?.length === 0 ? (
88
- <ListItem dark={dark}
75
+ <ListItem
89
76
  display="flex"
90
77
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
91
78
  // @ts-ignore
@@ -93,7 +80,6 @@ const DropdownContainer = (props: DropdownContainerProps) => {
93
80
  padding="xs"
94
81
  >
95
82
  <Body color="light"
96
- dark={dark}
97
83
  text="no option"
98
84
  />
99
85
  </ListItem>
@@ -4,9 +4,8 @@ import {
4
4
  buildAriaProps,
5
5
  buildCss,
6
6
  buildDataProps,
7
- buildHtmlProps,
8
7
  } from "../../utilities/props";
9
- import { globalProps, GlobalProps } from "../../utilities/globalProps";
8
+ import { globalProps } from "../../utilities/globalProps";
10
9
 
11
10
  import DropdownContext from "../context";
12
11
 
@@ -17,38 +16,19 @@ import { GenericObject } from "../../types";
17
16
 
18
17
  type DropdownOptionProps = {
19
18
  aria?: { [key: string]: string };
20
- children?: React.ReactChild[] | React.ReactChild;
21
19
  className?: string;
22
- dark?: boolean;
20
+ children?: React.ReactChild[] | React.ReactChild;
23
21
  data?: { [key: string]: string };
24
- htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
25
22
  id?: string;
26
- key?: string;
27
23
  option?: GenericObject;
28
- padding?: string;
29
- } & GlobalProps;
24
+ key?: string;
25
+ };
30
26
 
31
27
  const DropdownOption = (props: DropdownOptionProps) => {
32
- const {
33
- aria = {},
34
- children,
35
- className,
36
- dark = false,
37
- data = {},
38
- htmlOptions = {},
39
- id,
40
- key,
41
- option,
42
- padding = "xs",
43
- } = props;
28
+ const { aria = {}, className, children, data = {}, id, option, key } = props;
44
29
 
45
- const {
46
- filteredOptions,
47
- filterItem,
48
- focusedOptionIndex,
49
- handleOptionClick,
50
- selected,
51
- } = useContext(DropdownContext);
30
+ const { handleOptionClick, selected, filterItem, filteredOptions, focusedOptionIndex } =
31
+ useContext(DropdownContext);
52
32
 
53
33
  const isItemMatchingFilter = (option: GenericObject) =>
54
34
  option?.label.toLowerCase().includes(filterItem.toLowerCase());
@@ -56,58 +36,51 @@ const DropdownOption = (props: DropdownOptionProps) => {
56
36
  if (!isItemMatchingFilter(option)) {
57
37
  return null;
58
38
  }
59
- const isFocused =
60
- focusedOptionIndex >= 0 &&
61
- filteredOptions[focusedOptionIndex].label === option.label;
62
- const focusedClass = isFocused && "focused";
39
+ const isFocused = focusedOptionIndex >= 0 && filteredOptions[focusedOptionIndex].label === option.label
40
+ const focusedClass = isFocused && "dropdown_option_focused"
63
41
 
64
42
  const selectedClass = `${
65
43
  selected.label === option.label
66
- ? "selected"
67
- : "list"
68
- }`;
44
+ ? "dropdown_option_selected"
45
+ : "dropdown_option_list"
46
+ }`
69
47
  const ariaProps = buildAriaProps(aria);
70
48
  const dataProps = buildDataProps(data);
71
- const htmlProps = buildHtmlProps(htmlOptions);
72
49
  const classes = classnames(
73
- buildCss(
74
- "pb_dropdown_option",
75
- selectedClass,
76
- focusedClass,
77
- ),
78
- globalProps(props, {padding}),
50
+ buildCss("pb_dropdown_option"),
51
+ selectedClass,
52
+ focusedClass,
53
+ globalProps(props),
79
54
  className
80
55
  );
81
56
 
82
57
  return (
83
- <div
84
- {...ariaProps}
85
- {...dataProps}
86
- {...htmlProps}
87
- className={classes}
88
- id={id}
58
+ <div {...ariaProps}
59
+ {...dataProps}
60
+ className={classes}
61
+ id={id}
89
62
  key={key}
90
- onClick= {() => handleOptionClick(option)}
91
63
  >
92
64
  <ListItem
93
65
  cursor="pointer"
94
- dark={dark}
95
66
  data-name={option.value}
67
+ htmlOptions={{ onClick: () => handleOptionClick(option) }}
96
68
  key={option.label}
97
- padding="none"
69
+ padding="xs"
98
70
  >
99
71
  <Flex
100
72
  align="center"
101
- className="dropdown_option_wrapper"
73
+ className="dropdown_option"
102
74
  justify="between"
103
75
  paddingX="sm"
104
76
  paddingY="xxs"
105
77
  >
106
- {children ?
107
- children :
108
- <Body dark={dark}
109
- text={option.label}
110
- />
78
+ {
79
+ children ? (
80
+ children
81
+ ) : (
82
+ <Body text={option.label}/>
83
+ )
111
84
  }
112
85
  </Flex>
113
86
  </ListItem>