playbook_ui 15.3.0 → 15.4.0.pre.alpha.PLAY2465improvetruncation12292

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +2 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +3 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +18 -3
  5. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +71 -14
  6. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +3 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +1 -1
  8. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +4 -4
  9. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +12 -3
  10. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +127 -5
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +4 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +1 -1
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color.md +1 -1
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.md +1 -1
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.jsx +3 -1
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +2 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers.jsx +1 -1
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +1 -0
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +2 -0
  20. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.jsx +28 -0
  21. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.md +11 -2
  22. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.jsx +9 -1
  23. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.md +1 -1
  24. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +4 -1
  25. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.md +3 -2
  26. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_columns_and_header.md +1 -1
  27. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +1 -1
  28. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +1 -1
  29. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.jsx +16 -0
  30. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.html.erb +104 -0
  31. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.md +1 -0
  32. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.html.erb +1 -1
  33. data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data_inline_loading_empty_children.js +42 -0
  34. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
  35. data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +2 -2
  36. data/app/pb_kits/playbook/pb_advanced_table/index.js +7 -7
  37. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +2 -2
  38. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +90 -20
  39. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +32 -3
  40. data/app/pb_kits/playbook/pb_background/background.html.erb +10 -2
  41. data/app/pb_kits/playbook/pb_background/docs/_background_category.md +1 -1
  42. data/app/pb_kits/playbook/pb_badge/_badge.tsx +4 -1
  43. data/app/pb_kits/playbook/pb_badge/badge.test.js +13 -0
  44. data/app/pb_kits/playbook/pb_card/docs/_card_background.md +1 -1
  45. data/app/pb_kits/playbook/pb_card/docs/_card_header.md +1 -1
  46. data/app/pb_kits/playbook/pb_card/docs/_card_highlight.md +1 -1
  47. data/app/pb_kits/playbook/pb_card/docs/_card_light.md +1 -1
  48. data/app/pb_kits/playbook/pb_currency/_currency.tsx +20 -7
  49. data/app/pb_kits/playbook/pb_currency/currency.rb +35 -8
  50. data/app/pb_kits/playbook/pb_currency/currency.test.js +47 -0
  51. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.html.erb +1 -1
  52. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.jsx +1 -1
  53. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.md +1 -0
  54. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +25 -11
  55. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -0
  56. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +16 -4
  57. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.jsx +38 -0
  58. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.md +14 -0
  59. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -1
  60. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -1
  61. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_quick_pick_styles.scss +11 -30
  62. data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.tsx +20 -13
  63. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb +6 -4
  64. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.test.js +17 -0
  65. data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_show_current_year.html.erb +4 -0
  66. data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_show_current_year.jsx +43 -0
  67. data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_show_current_year.md +1 -0
  68. data/app/pb_kits/playbook/pb_date_range_inline/docs/_description.md +1 -1
  69. data/app/pb_kits/playbook/pb_date_range_inline/docs/example.yml +3 -2
  70. data/app/pb_kits/playbook/pb_date_range_inline/docs/index.js +1 -0
  71. data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.tsx +6 -4
  72. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +2 -3
  73. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.rb +11 -5
  74. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.test.js +26 -9
  75. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_current_year.html.erb +12 -0
  76. data/app/pb_kits/playbook/pb_date_stacked/docs/{_date_stacked_not_current_year.jsx → _date_stacked_current_year.jsx} +6 -5
  77. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_current_year.md +1 -0
  78. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_default.html.erb +1 -1
  79. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_default.jsx +1 -1
  80. data/app/pb_kits/playbook/pb_date_stacked/docs/_description.md +1 -1
  81. data/app/pb_kits/playbook/pb_date_stacked/docs/example.yml +2 -2
  82. data/app/pb_kits/playbook/pb_date_stacked/docs/index.js +1 -1
  83. data/app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_custom_colors.md +1 -1
  84. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +1 -0
  85. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +111 -6
  86. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.jsx +18 -0
  87. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.md +4 -0
  88. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.jsx +18 -0
  89. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.md +1 -0
  90. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.jsx +19 -0
  91. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.md +1 -0
  92. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.jsx +38 -0
  93. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.md +14 -0
  94. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options_react.md +1 -1
  95. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +5 -0
  96. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +5 -1
  97. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +148 -2
  98. data/app/pb_kits/playbook/pb_dropdown/index.js +1 -1
  99. data/app/pb_kits/playbook/pb_dropdown/quickpick/index.ts +60 -0
  100. data/app/pb_kits/playbook/pb_filter/docs/_filter_max_width.md +1 -1
  101. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +31 -9
  102. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +15 -1
  103. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.html.erb +9 -8
  104. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_positions.html.erb +11 -10
  105. data/app/pb_kits/playbook/pb_flex/_flex_item.tsx +12 -5
  106. data/app/pb_kits/playbook/pb_flex/docs/_flex_item_example.jsx +1 -0
  107. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
  108. data/app/pb_kits/playbook/pb_form/formHelper.js +1 -1
  109. data/app/pb_kits/playbook/pb_form/pb_form_validation.js +44 -11
  110. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +1 -1
  111. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md +1 -1
  112. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md +1 -1
  113. data/app/pb_kits/playbook/pb_icon/docs/_icon_color.md +1 -1
  114. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_color.md +1 -1
  115. data/app/pb_kits/playbook/pb_icon_stat_value/docs/_icon_stat_value_color.html.erb +7 -14
  116. data/app/pb_kits/playbook/pb_icon_stat_value/docs/_icon_stat_value_color.jsx +6 -15
  117. data/app/pb_kits/playbook/pb_layout/docs/_layout_collection.md +1 -1
  118. data/app/pb_kits/playbook/pb_nav/_item.tsx +18 -4
  119. data/app/pb_kits/playbook/pb_nav/_nav.scss +30 -5
  120. data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +192 -0
  121. data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +1 -1
  122. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_item_spacing.md +1 -1
  123. data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.html.erb +21 -0
  124. data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.jsx +113 -0
  125. data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.md +1 -0
  126. data/app/pb_kits/playbook/pb_nav/docs/_nav_with_spacing_control.md +1 -1
  127. data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.html.erb +30 -0
  128. data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.jsx +117 -0
  129. data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.md +1 -0
  130. data/app/pb_kits/playbook/pb_nav/docs/example.yml +4 -0
  131. data/app/pb_kits/playbook/pb_nav/docs/index.js +3 -1
  132. data/app/pb_kits/playbook/pb_nav/item.html.erb +6 -4
  133. data/app/pb_kits/playbook/pb_nav/item.rb +11 -2
  134. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_layout.md +1 -1
  135. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +110 -17
  136. data/app/pb_kits/playbook/pb_pill/docs/_description.md +1 -1
  137. data/app/pb_kits/playbook/pb_popover/_popover.tsx +69 -34
  138. data/app/pb_kits/playbook/pb_popover/docs/_popover_append_to.jsx +68 -0
  139. data/app/pb_kits/playbook/pb_popover/docs/_popover_append_to_react.md +1 -0
  140. data/app/pb_kits/playbook/pb_popover/docs/example.yml +1 -0
  141. data/app/pb_kits/playbook/pb_popover/docs/index.js +1 -0
  142. data/app/pb_kits/playbook/pb_popover/popover.test.js +80 -0
  143. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +1 -1
  144. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +61 -8
  145. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_description.md +1 -1
  146. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default_rails.md +7 -0
  147. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_focus.html.erb +10 -2
  148. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline_rails.md +1 -0
  149. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.html.erb +19 -11
  150. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_simple.html.erb +5 -1
  151. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky.html.erb +1 -1
  152. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky_rails.md +1 -0
  153. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -2
  154. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +16 -7
  155. data/app/pb_kits/playbook/pb_section_separator/docs/_description.md +1 -1
  156. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +29 -0
  157. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius_rails.md +1 -1
  158. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius_react.md +1 -1
  159. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md +1 -1
  160. data/app/pb_kits/playbook/pb_table/docs/_table_side_highlight.md +1 -1
  161. data/app/pb_kits/playbook/pb_table/docs/_table_sm.md +1 -1
  162. data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible.html.erb +63 -0
  163. data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible.jsx +89 -0
  164. data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible_rails.md +4 -0
  165. data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible_react.md +3 -0
  166. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  167. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  168. data/app/pb_kits/playbook/pb_text_input/text_input.rb +2 -2
  169. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +7 -0
  170. data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +105 -1
  171. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +23 -9
  172. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +33 -1
  173. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.html.erb +64 -0
  174. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.jsx +70 -0
  175. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.md +1 -0
  176. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_options.html.erb +67 -1
  177. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_value.jsx +68 -6
  178. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.md +1 -1
  179. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
  180. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +2 -1
  181. data/app/pb_kits/playbook/utilities/_truncate.scss +2 -0
  182. data/dist/chunks/{_line_graph-0IiTB9gA.js → _line_graph-eQNOB_GQ.js} +1 -1
  183. data/dist/chunks/_typeahead-vbfetkuE.js +24 -0
  184. data/dist/chunks/_weekday_stacked-CvJHyUq6.js +37 -0
  185. data/dist/chunks/{lib-izYrkvOQ.js → lib-BCrK6CFU.js} +2 -2
  186. data/dist/chunks/pb_form_validation-Cj4vdjWI.js +1 -0
  187. data/dist/chunks/vendor.js +1 -1
  188. data/dist/playbook-doc.js +1 -19
  189. data/dist/playbook-rails-react-bindings.js +1 -1
  190. data/dist/playbook-rails.js +1 -1
  191. data/dist/playbook.css +1 -1
  192. data/lib/playbook/version.rb +2 -2
  193. metadata +47 -10
  194. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_not_current_year.html.erb +0 -5
  195. data/dist/chunks/_typeahead-BvV7a9cR.js +0 -6
  196. data/dist/chunks/_weekday_stacked-BZ7z8ukT.js +0 -37
  197. data/dist/chunks/pb_form_validation-Cah5Z5J3.js +0 -1
  198. /data/app/pb_kits/playbook/pb_popover/docs/{_popover_append_to.md → _popover_append_to_rails.md} +0 -0
@@ -5,6 +5,8 @@ import Nav from './_nav'
5
5
  import NavItem from './_item'
6
6
 
7
7
  const navTestId = 'nav'
8
+ const navDisabledTestId = 'nav-disabled'
9
+ const itemDisabledTestId = 'item-disabled'
8
10
  const itemTestId = 'item'
9
11
  const activeTestBorderlessId = 'activeborderless'
10
12
  const activeTestBorderId = 'active'
@@ -105,3 +107,193 @@ test('should have a left icon', () => {
105
107
  const icon = kit.querySelector(".pb_custom_icon.pb_nav_list_item_icon_left")
106
108
  expect(icon).toBeInTheDocument()
107
109
  })
110
+
111
+ test('should apply disabled class when disabled (horizontal nav)', () => {
112
+ [
113
+ "default",
114
+ "subtle",
115
+ "bold"
116
+ ].forEach((variant) => {
117
+ render(
118
+ <Nav
119
+ aria={{ label: navDisabledTestId }}
120
+ className={navClassName}
121
+ data={{ testid: navDisabledTestId }}
122
+ orientation="horizontal"
123
+ variant={variant}
124
+ >
125
+ <NavItem
126
+ aria={{ label: `${itemDisabledTestId}-${variant}` }}
127
+ className={itemClassName}
128
+ data={{ testid: `${itemDisabledTestId}-${variant}` }}
129
+ disabled
130
+ link="#"
131
+ text="Files"
132
+ />
133
+ </Nav>
134
+ )
135
+ const kit = screen.getByTestId(`${itemDisabledTestId}-${variant}`)
136
+ expect(kit).toHaveClass('pb_nav_item_disabled')
137
+ })
138
+ })
139
+
140
+ test('should set aria-disabled when disabled (horizontal nav)', () => {
141
+ [
142
+ "default",
143
+ "subtle",
144
+ "bold"
145
+ ].forEach((variant) => {
146
+ render(
147
+ <Nav
148
+ aria={{ label: navDisabledTestId }}
149
+ className={navClassName}
150
+ data={{ testid: navDisabledTestId }}
151
+ orientation="horizontal"
152
+ variant={variant}
153
+ >
154
+ <NavItem
155
+ aria={{ label: `${itemDisabledTestId}-${variant}` }}
156
+ className={itemClassName}
157
+ data={{ testid: `${itemDisabledTestId}-${variant}` }}
158
+ disabled
159
+ link="#"
160
+ text="Files"
161
+ />
162
+ </Nav>
163
+ )
164
+ const item = screen.getByTestId(`${itemDisabledTestId}-${variant}`)
165
+ expect(item).toHaveAttribute('aria-disabled', 'true')
166
+ })
167
+ })
168
+
169
+ test('should set tabIndex to -1 when disabled (horizontal nav)', () => {
170
+ [
171
+ "default",
172
+ "subtle",
173
+ "bold"
174
+ ].forEach((variant) => {
175
+ render(
176
+ <Nav
177
+ aria={{ label: navDisabledTestId }}
178
+ className={navClassName}
179
+ data={{ testid: navDisabledTestId }}
180
+ orientation="horizontal"
181
+ variant={variant}
182
+ >
183
+ <NavItem
184
+ aria={{ label: `${itemDisabledTestId}-${variant}` }}
185
+ className={itemClassName}
186
+ data={{ testid: `${itemDisabledTestId}-${variant}` }}
187
+ disabled
188
+ link="#"
189
+ text="Files"
190
+ />
191
+ </Nav>
192
+ )
193
+ const kit = screen.getByTestId(`${itemDisabledTestId}-${variant}`)
194
+ expect(kit).toHaveAttribute('tabIndex', '-1')
195
+ })
196
+ })
197
+
198
+ test('should prevent onClick when disabled', () => {
199
+ const handleClick = jest.fn()
200
+ render(
201
+ <NavItem
202
+ data={{ testid: 'disabled-click-item' }}
203
+ disabled
204
+ link="#"
205
+ onClick={handleClick}
206
+ text="Disabled Item"
207
+ />
208
+ )
209
+ const kit = screen.getByTestId('disabled-click-item')
210
+ kit.click()
211
+ expect(handleClick).not.toHaveBeenCalled()
212
+ })
213
+
214
+ test('should apply disabled class when disabled (vertical nav)', () => {
215
+ [
216
+ "default",
217
+ "subtle",
218
+ "bold"
219
+ ].forEach((variant) => {
220
+ render(
221
+ <Nav
222
+ aria={{ label: navDisabledTestId }}
223
+ className={navClassName}
224
+ data={{ testid: navDisabledTestId }}
225
+ orientation="vertical"
226
+ variant={variant}
227
+ >
228
+ <NavItem
229
+ aria={{ label: `${itemDisabledTestId}-${variant}` }}
230
+ className={itemClassName}
231
+ data={{ testid: `${itemDisabledTestId}-${variant}` }}
232
+ disabled
233
+ link="#"
234
+ text="Files"
235
+ />
236
+ </Nav>
237
+ )
238
+ const kit = screen.getByTestId(`${itemDisabledTestId}-${variant}`)
239
+ expect(kit).toHaveClass('pb_nav_item_disabled')
240
+ })
241
+ })
242
+
243
+ test('should set aria-disabled when disabled (vertical nav)', () => {
244
+ [
245
+ "default",
246
+ "subtle",
247
+ "bold"
248
+ ].forEach((variant) => {
249
+ render(
250
+ <Nav
251
+ aria={{ label: navDisabledTestId }}
252
+ className={navClassName}
253
+ data={{ testid: navDisabledTestId }}
254
+ orientation="vertical"
255
+ variant={variant}
256
+ >
257
+ <NavItem
258
+ aria={{ label: `${itemDisabledTestId}-${variant}` }}
259
+ className={itemClassName}
260
+ data={{ testid: `${itemDisabledTestId}-${variant}` }}
261
+ disabled
262
+ link="#"
263
+ text="Files"
264
+ />
265
+ </Nav>
266
+ )
267
+ const item = screen.getByTestId(`${itemDisabledTestId}-${variant}`)
268
+ expect(item).toHaveAttribute('aria-disabled', 'true')
269
+ })
270
+ })
271
+
272
+ test('should set tabIndex to -1 when disabled (vertical nav)', () => {
273
+ [
274
+ "default",
275
+ "subtle",
276
+ "bold"
277
+ ].forEach((variant) => {
278
+ render(
279
+ <Nav
280
+ aria={{ label: navDisabledTestId }}
281
+ className={navClassName}
282
+ data={{ testid: navDisabledTestId }}
283
+ orientation="vertical"
284
+ variant={variant}
285
+ >
286
+ <NavItem
287
+ aria={{ label: `${itemDisabledTestId}-${variant}` }}
288
+ className={itemClassName}
289
+ data={{ testid: `${itemDisabledTestId}-${variant}` }}
290
+ disabled
291
+ link="#"
292
+ text="Files"
293
+ />
294
+ </Nav>
295
+ )
296
+ const kit = screen.getByTestId(`${itemDisabledTestId}-${variant}`)
297
+ expect(kit).toHaveAttribute('tabIndex', '-1')
298
+ })
299
+ })
@@ -44,7 +44,7 @@ $selector: ".pb_nav_list";
44
44
  transition-duration: 0.15s;
45
45
  transition-timing-function: $bezier;
46
46
  @media (hover: hover) {
47
- &:hover {
47
+ &:hover:not(.pb_nav_item_disabled) {
48
48
  background-color: rgba($primary, 0.03);
49
49
  [class*="_icon"] {
50
50
  color: $primary;
@@ -1 +1 @@
1
- The `itemSpacing` prop can optionally be applied to the `Nav` parent element and accepts an object through which any of our [Spacing](https://playbook.powerapp.cloud/visual_guidelines/spacing) (padding, margin) global prop values can be passed as an object. All spacing values passed to `itemSpacing` will be applied to all navItems within the nav. Spacing (padding, margin) global props can still be used on nested navItems in conjunction with `itenSpacing` on the Nav for customized control. Any Spacing (padding,margin) global props applied directly to a navItem will override any competing `itemSpacing` value.
1
+ The `itemSpacing` prop can optionally be applied to the `Nav` parent element and accepts an object through which any of our Spacing ([padding](https://playbook.powerapp.cloud/global_props/padding), [margin](https://playbook.powerapp.cloud/global_props/margin)) global prop values can be passed as an object. All spacing values passed to `itemSpacing` will be applied to all navItems within the nav. Spacing (padding, margin) global props can still be used on nested navItems in conjunction with `itenSpacing` on the Nav for customized control. Any Spacing (padding,margin) global props applied directly to a navItem will override any competing `itemSpacing` value.
@@ -0,0 +1,21 @@
1
+ <%= pb_rails("caption", props: { margin_bottom: "sm", text: "Default Variant" }) %>
2
+ <%= pb_rails("nav", props: { orientation: "horizontal" }) do %>
3
+ <%= pb_rails("nav/item", props: { text: "About", link: "#" }) %>
4
+ <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true }) %>
5
+ <%= pb_rails("nav/item", props: { text: "Service ", link: "#", disabled: true }) %>
6
+ <%= pb_rails("nav/item", props: { text: "Contacts", link: "#" }) %>
7
+ <% end %>
8
+ <%= pb_rails("caption", props: { margin_bottom: "sm", margin_top:"lg", text: "Subtle Variant" }) %>
9
+ <%= pb_rails("nav", props: { orientation: "horizontal", variant: "subtle" }) do %>
10
+ <%= pb_rails("nav/item", props: { text: "About", link: "#" }) %>
11
+ <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true }) %>
12
+ <%= pb_rails("nav/item", props: { text: "Service ", link: "#", disabled: true }) %>
13
+ <%= pb_rails("nav/item", props: { text: "Contacts", link: "#" }) %>
14
+ <% end %>
15
+ <%= pb_rails("caption", props: { margin_bottom: "sm", margin_top:"lg", text: "Bold Variant" }) %>
16
+ <%= pb_rails("nav", props: { orientation: "horizontal", variant: "bold" }) do %>
17
+ <%= pb_rails("nav/item", props: { text: "About", link: "#" }) %>
18
+ <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true }) %>
19
+ <%= pb_rails("nav/item", props: { text: "Service ", link: "#", disabled: true }) %>
20
+ <%= pb_rails("nav/item", props: { text: "Contacts", link: "#" }) %>
21
+ <% end %>
@@ -0,0 +1,113 @@
1
+ import React from 'react'
2
+
3
+ import Nav from '../_nav'
4
+ import NavItem from '../_item'
5
+ import Caption from '../../pb_caption/_caption'
6
+
7
+ const HorizontalNavDisabled = (props) => {
8
+ return (
9
+ <>
10
+ <Caption marginBottom="sm">Default Variant</Caption>
11
+ <Nav
12
+ link="#"
13
+ orientation="horizontal"
14
+ {...props}
15
+ >
16
+ <NavItem
17
+ link="#"
18
+ text="About"
19
+ {...props}
20
+ />
21
+ <NavItem
22
+ active
23
+ link="#"
24
+ text="Case Studies"
25
+ {...props}
26
+ />
27
+ <NavItem
28
+ disabled
29
+ link="#"
30
+ text="Service"
31
+ {...props}
32
+ />
33
+ <NavItem
34
+ link="#"
35
+ text="Contacts"
36
+ {...props}
37
+ />
38
+ </Nav>
39
+ <Caption
40
+ marginBottom="sm"
41
+ marginTop="lg"
42
+ >
43
+ Subtle Variant
44
+ </Caption>
45
+ <Nav
46
+ link="#"
47
+ orientation="horizontal"
48
+ variant="subtle"
49
+ {...props}
50
+ >
51
+ <NavItem
52
+ link="#"
53
+ text="About"
54
+ {...props}
55
+ />
56
+ <NavItem
57
+ active
58
+ link="#"
59
+ text="Case Studies"
60
+ {...props}
61
+ />
62
+ <NavItem
63
+ disabled
64
+ link="#"
65
+ text="Service"
66
+ {...props}
67
+ />
68
+ <NavItem
69
+ link="#"
70
+ text="Contacts"
71
+ {...props}
72
+ />
73
+ </Nav>
74
+ <Caption
75
+ marginBottom="sm"
76
+ marginTop="lg"
77
+ >
78
+ Bold Variant
79
+ </Caption>
80
+ <Nav
81
+ link="#"
82
+ orientation="horizontal"
83
+ variant="bold"
84
+ {...props}
85
+ >
86
+ <NavItem
87
+ link="#"
88
+ text="About"
89
+ {...props}
90
+ />
91
+ <NavItem
92
+ active
93
+ link="#"
94
+ text="Case Studies"
95
+ {...props}
96
+ />
97
+ <NavItem
98
+ disabled
99
+ link="#"
100
+ text="Service"
101
+ {...props}
102
+ />
103
+ <NavItem
104
+ link="#"
105
+ text="Contacts"
106
+ {...props}
107
+ />
108
+ </Nav>
109
+ </>
110
+ )
111
+ }
112
+
113
+ export default HorizontalNavDisabled
@@ -0,0 +1 @@
1
+ Use the `disabled` prop on a `navItem`/`nav_item` within a horizontal nav to set it as disabled. This will render the UI as disabled, prevent clicks and not allow for tabIndex to access the item.
@@ -1 +1 @@
1
- All Nav variants' navItems accept our [global Spacing](https://playbook.powerapp.cloud/visual_guidelines/spacing) (padding, margin) props for custom spacing requirements. This example uses paddingY="xxs" and margin="none" on the bold variant to show this in action!
1
+ All Nav variants' navItems accept our global Spacing ([padding](https://playbook.powerapp.cloud/global_props/padding), [margin](https://playbook.powerapp.cloud/global_props/margin)) props for custom spacing requirements. This example uses paddingY="xxs" and margin="none" on the bold variant to show this in action!
@@ -0,0 +1,30 @@
1
+ <%= pb_rails("flex", props: { justify: "between" }) do %>
2
+ <%= pb_rails("flex", props: { orientation:"column", wrap: true }) do %>
3
+ <%= pb_rails("caption", props: { margin_bottom: "sm", text: "Default Variant" }) %>
4
+ <%= pb_rails("nav") do %>
5
+ <%= pb_rails("nav/item", props: { text: "About", link: "#" }) %>
6
+ <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true }) %>
7
+ <%= pb_rails("nav/item", props: { text: "Service ", link: "#", disabled: true }) %>
8
+ <%= pb_rails("nav/item", props: { text: "Contacts", link: "#" }) %>
9
+ <% end %>
10
+ <% end %>
11
+ <%= pb_rails("flex", props: { orientation:"column", wrap: true }) do %>
12
+ <%= pb_rails("caption", props: { margin_bottom: "sm", text: "Subtle Variant" }) %>
13
+ <%= pb_rails("nav", props:{variant: "subtle"}) do %>
14
+ <%= pb_rails("nav/item", props: { text: "About", link: "#" }) %>
15
+ <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true }) %>
16
+ <%= pb_rails("nav/item", props: { text: "Service ", link: "#", disabled: true }) %>
17
+ <%= pb_rails("nav/item", props: { text: "Contacts", link: "#" }) %>
18
+ <% end %>
19
+ <% end %>
20
+ <%= pb_rails("flex", props: { orientation:"column", wrap: true }) do %>
21
+ <%= pb_rails("caption", props: { margin_bottom: "sm", text: "Bold Variant" }) %>
22
+ <%= pb_rails("nav", props:{variant: "bold"}) do %>
23
+ <%= pb_rails("nav/item", props: { text: "About", link: "#" }) %>
24
+ <%= pb_rails("nav/item", props: { text: "Case Studies", link: "#", active: true }) %>
25
+ <%= pb_rails("nav/item", props: { text: "Service ", link: "#", disabled: true }) %>
26
+ <%= pb_rails("nav/item", props: { text: "Contacts", link: "#" }) %>
27
+ <% end %>
28
+ <% end %>
29
+
30
+ <% end %>
@@ -0,0 +1,117 @@
1
+ import React from 'react'
2
+
3
+ import Nav from '../_nav'
4
+ import NavItem from '../_item'
5
+ import Caption from '../../pb_caption/_caption'
6
+ import Flex from '../../pb_flex/_flex'
7
+
8
+ const VerticalNavDisabled = (props) => {
9
+ return (
10
+ <Flex justify="between"
11
+ wrap
12
+ >
13
+ <Flex orientation="column">
14
+ <Caption marginBottom="sm">Default Variant</Caption>
15
+ <Nav
16
+ link="#"
17
+ {...props}
18
+ >
19
+ <NavItem
20
+ link="#"
21
+ text="About"
22
+ {...props}
23
+ />
24
+ <NavItem
25
+ active
26
+ link="#"
27
+ text="Case Studies"
28
+ {...props}
29
+ />
30
+ <NavItem
31
+ disabled
32
+ link="#"
33
+ text="Service"
34
+ {...props}
35
+ />
36
+ <NavItem
37
+ link="#"
38
+ text="Contacts"
39
+ {...props}
40
+ />
41
+ </Nav>
42
+ </Flex>
43
+ <Flex orientation="column">
44
+ <Caption
45
+ marginBottom="sm"
46
+ >
47
+ Subtle Variant
48
+ </Caption>
49
+ <Nav
50
+ link="#"
51
+ variant="subtle"
52
+ {...props}
53
+ >
54
+ <NavItem
55
+ link="#"
56
+ text="About"
57
+ {...props}
58
+ />
59
+ <NavItem
60
+ active
61
+ link="#"
62
+ text="Case Studies"
63
+ {...props}
64
+ />
65
+ <NavItem
66
+ disabled
67
+ link="#"
68
+ text="Service"
69
+ {...props}
70
+ />
71
+ <NavItem
72
+ link="#"
73
+ text="Contacts"
74
+ {...props}
75
+ />
76
+ </Nav>
77
+ </Flex>
78
+ <Flex orientation="column">
79
+ <Caption
80
+ marginBottom="sm"
81
+ >
82
+ Bold Variant
83
+ </Caption>
84
+ <Nav
85
+ link="#"
86
+ variant="bold"
87
+ {...props}
88
+ >
89
+ <NavItem
90
+ link="#"
91
+ text="About"
92
+ {...props}
93
+ />
94
+ <NavItem
95
+ active
96
+ link="#"
97
+ text="Case Studies"
98
+ {...props}
99
+ />
100
+ <NavItem
101
+ disabled
102
+ link="#"
103
+ text="Service"
104
+ {...props}
105
+ />
106
+ <NavItem
107
+ link="#"
108
+ text="Contacts"
109
+ {...props}
110
+ />
111
+ </Nav>
112
+ </Flex>
113
+ </Flex>
114
+ )
115
+ }
116
+
117
+ export default VerticalNavDisabled
@@ -0,0 +1 @@
1
+ Use the `disabled` prop on a `navItem`/`nav_item` within a vertical nav to set it as disabled. This will render the UI as disabled, prevent clicks and not allow for tabIndex to access the item.
@@ -18,6 +18,8 @@ examples:
18
18
  - subtle_horizontal_nav: Subtle Horizontal Nav
19
19
  - bold_horizontal_nav: Bold Horizontal Nav
20
20
  - horizontal_nav_extendedunderline: Horizontal Nav With Extended Underline
21
+ - horizontal_nav_disabled: Horizontal Nav With Disabled Item
22
+ - vertical_nav_disabled: Vertical Nav With Disabled Item
21
23
  - block_nav: Block
22
24
  - block_no_title_nav: Without Title
23
25
  - new_tab: Open in a New Tab
@@ -44,6 +46,8 @@ examples:
44
46
  - subtle_horizontal_nav: Subtle Horizontal Nav
45
47
  - bold_horizontal_nav: Bold Horizontal Nav
46
48
  - horizontal_nav_extendedunderline: Horizontal Nav With Extended Underline
49
+ - horizontal_nav_disabled: Horizontal Nav With Disabled Item
50
+ - vertical_nav_disabled: Vertical Nav With Disabled Item
47
51
  - block_nav: Block
48
52
  - block_no_title_nav: Without Title
49
53
  - new_tab: Open in a New Tab
@@ -20,4 +20,6 @@ export { default as NavWithFontControl } from "./_nav_with_font_control.jsx"
20
20
  export { default as NavWithSpacingControl } from "./_nav_with_spacing_control.jsx"
21
21
  export { default as CollapsibleNavItemSpacing } from "./_collapsible_nav_item_spacing.jsx"
22
22
  export { default as CollapsibleNavNoIcon } from "./_collapsible_nav_no_icon.jsx"
23
- export { default as HorizontalNavExtendedunderline } from './_horizontal_nav_extendedunderline.jsx'
23
+ export { default as HorizontalNavExtendedunderline } from './_horizontal_nav_extendedunderline.jsx'
24
+ export { default as HorizontalNavDisabled } from './_horizontal_nav_disabled.jsx'
25
+ export { default as VerticalNavDisabled } from './_vertical_nav_disabled.jsx'
@@ -24,10 +24,12 @@
24
24
  <% end %>
25
25
  <% else %>
26
26
  <%= pb_content_tag( object.tag,
27
- href: object.link && object.link,
28
- target: object.link && object.target,
29
- onkeydown: !object.link ? "if(event.key==='Enter'||event.key===' '){event.preventDefault(); this.click();}" : nil,
30
- tabindex: object.link ? nil : 0,
27
+ aria: { disabled: object.disabled },
28
+ href: object.is_link ? object.link : nil,
29
+ target: object.is_link ? object.target : nil,
30
+ onclick: object.disabled ? "event.preventDefault(); event.stopPropagation(); return false;" : nil,
31
+ onkeydown: object.disabled ? nil : (!object.is_link ? "if(event.key==='Enter'||event.key===' '){event.preventDefault(); this.click();}" : nil),
32
+ tabindex: object.disabled ? -1 : (object.is_link ? nil : 0),
31
33
  ) do %>
32
34
  <% if object.image_url %>
33
35
  <%= pb_rails("image", props: { url: object.image_url, classname: "pb_nav_img_wrapper" }) %>
@@ -4,6 +4,7 @@ module Playbook
4
4
  module PbNav
5
5
  class Item < Playbook::KitBase
6
6
  prop :active, type: Playbook::Props::Boolean, default: false
7
+ prop :disabled, type: Playbook::Props::Boolean, default: false
7
8
  prop :font_size, type: Playbook::Props::Enum,
8
9
  values: %w[normal small],
9
10
  default: "normal"
@@ -26,7 +27,7 @@ module Playbook
26
27
  if collapsible
27
28
  "#{generate_classname('pb_nav_list_kit_item', active_class, highlighted_border_class)} #{generate_classname('pb_collapsible_nav_item', active_class, collapsible_trail_class)} #{font_size_class} #{font_weight_class} pb_nav_list_item_link_collapsible"
28
29
  else
29
- "#{generate_classname('pb_nav_list_kit_item', active_class, highlighted_border_class)} #{font_size_class} #{font_weight_class} pb_nav_list_item_link"
30
+ "#{generate_classname('pb_nav_list_kit_item', active_class, highlighted_border_class)} #{font_size_class} #{font_weight_class} pb_nav_list_item_link#{disabled_class}"
30
31
  end
31
32
  end
32
33
 
@@ -81,7 +82,11 @@ module Playbook
81
82
  end
82
83
 
83
84
  def tag
84
- link ? "a" : "div"
85
+ link && !disabled ? "a" : "div"
86
+ end
87
+
88
+ def is_link
89
+ link && !disabled
85
90
  end
86
91
 
87
92
  def collapsible_icons
@@ -98,6 +103,10 @@ module Playbook
98
103
  active ? "active" : nil
99
104
  end
100
105
 
106
+ def disabled_class
107
+ disabled ? " pb_nav_item_disabled" : nil
108
+ end
109
+
101
110
  def highlighted_border_class
102
111
  !highlighted_border && active ? "highlighted_border_none" : nil
103
112
  end
@@ -2,4 +2,4 @@ The optional `layout` prop accepts the `position` and `size` of the overlay as a
2
2
 
3
3
  The `position` key accepts `bottom` (default), `top`, `y` (for both top and bottom) `right`, `left`, or `x` (for both left and right), which sets the side(s) where the `color` overlay starts. The direction of the overlay is always toward the opposite side of the position. For example, the default position of `bottom` starts the overlay on the bottom edge of your container and extends it toward the opposite side: the top.
4
4
 
5
- The `size` value is `full` (100%) by default, but accepts our [spacing tokens](https://playbook.powerapp.cloud/visual_guidelines/spacing) or a percentage value as a string, and literally translates to how much of the container is covered by the overlay(s).
5
+ The `size` value is `full` (100%) by default, but accepts our spacing tokens([padding](https://playbook.powerapp.cloud/global_props/padding), [margin](https://playbook.powerapp.cloud/global_props/margin)) or a percentage value as a string, and literally translates to how much of the container is covered by the overlay(s).