playbook_ui 15.3.0.pre.alpha.play199912042 → 15.3.0.pre.alpha.play202412165

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 (83) 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/Utilities/RowUtils.ts +1 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +4 -4
  5. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +68 -5
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +4 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +1 -1
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.jsx +3 -1
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +2 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers.jsx +1 -1
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +1 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +2 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.jsx +9 -1
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.md +1 -1
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.jsx +16 -0
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.html.erb +104 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.md +1 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.html.erb +1 -1
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
  20. data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +2 -2
  21. data/app/pb_kits/playbook/pb_advanced_table/index.js +7 -7
  22. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +2 -2
  23. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +90 -20
  24. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +32 -3
  25. data/app/pb_kits/playbook/pb_background/background.html.erb +10 -2
  26. data/app/pb_kits/playbook/pb_currency/_currency.tsx +20 -7
  27. data/app/pb_kits/playbook/pb_currency/currency.rb +35 -8
  28. data/app/pb_kits/playbook/pb_currency/currency.test.js +47 -0
  29. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.html.erb +1 -1
  30. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.jsx +1 -1
  31. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.md +1 -0
  32. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +16 -4
  33. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.jsx +38 -0
  34. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.md +14 -0
  35. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -1
  36. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -1
  37. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +1 -0
  38. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +111 -6
  39. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.jsx +18 -0
  40. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.md +4 -0
  41. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.jsx +18 -0
  42. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.md +1 -0
  43. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.jsx +19 -0
  44. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.md +1 -0
  45. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.jsx +38 -0
  46. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.md +14 -0
  47. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +5 -0
  48. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +5 -1
  49. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +148 -2
  50. data/app/pb_kits/playbook/pb_dropdown/quickpick/index.ts +60 -0
  51. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +15 -1
  52. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.html.erb +9 -8
  53. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_positions.html.erb +11 -10
  54. data/app/pb_kits/playbook/pb_form/pb_form_validation.js +44 -11
  55. data/app/pb_kits/playbook/pb_nav/_item.tsx +18 -4
  56. data/app/pb_kits/playbook/pb_nav/_nav.scss +30 -5
  57. data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +192 -0
  58. data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +1 -1
  59. data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.html.erb +21 -0
  60. data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.jsx +113 -0
  61. data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.md +1 -0
  62. data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.html.erb +30 -0
  63. data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.jsx +117 -0
  64. data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.md +1 -0
  65. data/app/pb_kits/playbook/pb_nav/docs/example.yml +4 -0
  66. data/app/pb_kits/playbook/pb_nav/docs/index.js +3 -1
  67. data/app/pb_kits/playbook/pb_nav/item.html.erb +6 -4
  68. data/app/pb_kits/playbook/pb_nav/item.rb +11 -2
  69. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +110 -17
  70. data/dist/chunks/{_line_graph-BmABJlze.js → _line_graph-B4qHP_oq.js} +1 -1
  71. data/dist/chunks/{_typeahead-57mB4EsR.js → _typeahead-NlACFNiN.js} +2 -2
  72. data/dist/chunks/_weekday_stacked-NviJgRIS.js +37 -0
  73. data/dist/chunks/{lib-CGxXTQ75.js → lib-BXBHAZMY.js} +1 -1
  74. data/dist/chunks/pb_form_validation-BNfSnIUF.js +1 -0
  75. data/dist/chunks/vendor.js +1 -1
  76. data/dist/playbook-doc.js +1 -1
  77. data/dist/playbook-rails-react-bindings.js +1 -1
  78. data/dist/playbook-rails.js +1 -1
  79. data/dist/playbook.css +1 -1
  80. data/lib/playbook/version.rb +1 -1
  81. metadata +27 -7
  82. data/dist/chunks/_weekday_stacked-Bjc5rN-H.js +0 -37
  83. data/dist/chunks/pb_form_validation-DebqlUKZ.js +0 -1
@@ -8,13 +8,13 @@ const ERROR_MESSAGE_SELECTOR = '.pb_body_kit_negative'
8
8
  // Validation selectors
9
9
  const FORM_SELECTOR = 'form[data-pb-form-validation="true"]'
10
10
  const REQUIRED_FIELDS_SELECTOR = 'input[required],textarea[required],select[required]'
11
+ const PHONE_NUMBER_VALIDATION_ERROR_SELECTOR = '[data-pb-phone-validation-error="true"]'
11
12
 
12
13
  const FIELD_EVENTS = [
13
14
  'change',
14
15
  'valid',
15
16
  'invalid',
16
17
  ]
17
-
18
18
  class PbFormValidation extends PbEnhancedElement {
19
19
  static get selector() {
20
20
  return FORM_SELECTOR
@@ -22,12 +22,27 @@ class PbFormValidation extends PbEnhancedElement {
22
22
 
23
23
  connect() {
24
24
  this.formValidationFields.forEach((field) => {
25
+ // Skip phone number inputs - they handle their own validation
26
+ const isPhoneNumberInput = field.closest('.pb_phone_number_input')
27
+ if (isPhoneNumberInput) return
28
+
25
29
  FIELD_EVENTS.forEach((e) => {
26
30
  field.addEventListener(e, debounce((event) => {
27
31
  this.validateFormField(event)
28
32
  }, 250), false)
29
33
  })
30
34
  })
35
+
36
+ // Add event listener to check for phone number validation errors
37
+ this.element.addEventListener('submit', (event) => {
38
+ // Use setTimeout to ensure React state updates have completed
39
+ setTimeout(() => {
40
+ if (this.hasPhoneNumberValidationErrors()) {
41
+ event.preventDefault()
42
+ return false
43
+ }
44
+ }, 0)
45
+ })
31
46
  }
32
47
 
33
48
  validateFormField(event) {
@@ -45,40 +60,58 @@ class PbFormValidation extends PbEnhancedElement {
45
60
 
46
61
  showValidationMessage(target) {
47
62
  const { parentElement } = target
63
+ const kitElement = parentElement.closest(KIT_SELECTOR)
64
+
65
+ // FIX: Add null check for kitElement
66
+ if (!kitElement) return
67
+
68
+ // Check if this is a phone number input
69
+ const isPhoneNumberInput = kitElement.classList.contains('pb_phone_number_input')
48
70
 
49
71
  // ensure clean error message state
50
72
  this.clearError(target)
51
- parentElement.closest(KIT_SELECTOR).classList.add('error')
73
+ kitElement.classList.add('error')
52
74
 
53
- // set the error message element
54
- const errorMessageContainer = this.errorMessageContainer
75
+ // Only add error message if it's NOT a phone number input
76
+ if (!isPhoneNumberInput) {
77
+ // set the error message element
78
+ const errorMessageContainer = this.errorMessageContainer
55
79
 
56
- if (target.dataset.message) target.setCustomValidity(target.dataset.message)
80
+ if (target.dataset.message) target.setCustomValidity(target.dataset.message)
57
81
 
58
- errorMessageContainer.innerHTML = target.validationMessage
82
+ errorMessageContainer.innerHTML = target.validationMessage
59
83
 
60
- // add the error message element to the dom tree
61
- parentElement.appendChild(errorMessageContainer)
84
+ // add the error message element to the dom tree
85
+ parentElement.appendChild(errorMessageContainer)
86
+ }
62
87
  }
63
88
 
64
89
  clearError(target) {
65
90
  const { parentElement } = target
66
- parentElement.closest(KIT_SELECTOR).classList.remove('error')
91
+ const kitElement = parentElement.closest(KIT_SELECTOR)
92
+ // Remove error class from kit element
93
+ if (kitElement) kitElement.classList.remove('error')
94
+ // Remove error message from parent element
67
95
  const errorMessageContainer = parentElement.querySelector(ERROR_MESSAGE_SELECTOR)
68
96
  if (errorMessageContainer) errorMessageContainer.remove()
69
97
  }
70
98
 
99
+ // Check if there are phone number input errors
100
+ hasPhoneNumberValidationErrors() {
101
+ const phoneNumberErrors = this.element.querySelectorAll(PHONE_NUMBER_VALIDATION_ERROR_SELECTOR)
102
+ return phoneNumberErrors.length > 0
103
+ }
104
+
71
105
  get errorMessageContainer() {
72
106
  const errorContainer = document.createElement('div')
73
107
  const kitClassName = ERROR_MESSAGE_SELECTOR.replace(/\./, '')
74
108
  errorContainer.classList.add(kitClassName)
75
109
  return errorContainer
76
110
  }
77
-
78
111
  get formValidationFields() {
79
112
  return this._formValidationFields =
80
113
  this._formValidationFields || this.element.querySelectorAll(REQUIRED_FIELDS_SELECTOR)
81
114
  }
82
115
  }
83
116
 
84
- window.PbFormValidation = PbFormValidation
117
+ window.PbFormValidation = PbFormValidation
@@ -43,6 +43,7 @@ type NavItemProps = {
43
43
  marginLeft?: Spacing;
44
44
  marginX?: Spacing;
45
45
  marginY?: Spacing;
46
+ disabled?: boolean;
46
47
  } & GlobalProps;
47
48
 
48
49
  const NavItem = (props: NavItemProps) => {
@@ -89,6 +90,7 @@ const NavItem = (props: NavItemProps) => {
89
90
  marginLeft,
90
91
  marginX,
91
92
  marginY,
93
+ disabled = false,
92
94
  } = props;
93
95
 
94
96
  const spacingMarginProps = {
@@ -140,11 +142,12 @@ const { filteredPadding, filteredMargin } = filterItemSpacing(itemSpacing);
140
142
  delete filteredProps?.marginLeft;
141
143
 
142
144
 
143
- const isLink = !!link
145
+ const isLink = !!link && !disabled
144
146
  const Tag = isLink ? "a" : "div"
145
147
  const activeClass = active === true ? "active" : "";
146
148
  const highlightedBorderClass = active === true && highlighted_border === false ? "highlighted_border_none" : "";
147
149
  const collapsibleTrailClass = collapsible && collapsibleTrail ? "collapsible_trail" : "";
150
+ const disabledClass = disabled ? "pb_nav_item_disabled" : "";
148
151
 
149
152
  const fontSizeMapping = {
150
153
  "small": "font_size_small",
@@ -177,6 +180,7 @@ const { filteredPadding, filteredMargin } = filterItemSpacing(itemSpacing);
177
180
  fontWeightClass,
178
181
  tagClasses,
179
182
  collapsible ? globalProps(filteredProps, {...filteredPadding}) : globalProps(props, {...itemSpacing}),
183
+ disabledClass,
180
184
  className
181
185
  );
182
186
 
@@ -202,12 +206,21 @@ const { filteredPadding, filteredMargin } = filterItemSpacing(itemSpacing);
202
206
  const collapsibleClasses = buildCss("collapsible_nav_wrapper", activeClass, highlightedBorderClass, collapsibleTrailClass)
203
207
 
204
208
  const handleKeyDown = (e: React.KeyboardEvent) => {
205
- if (!isLink && (e.key === "Enter" || e.key === " ")) {
209
+ if (!disabled && !isLink && (e.key === "Enter" || e.key === " ")) {
206
210
  e.preventDefault()
207
211
  onClick?.()
208
212
  }
209
213
  }
210
214
 
215
+ const handleClick = (e: React.MouseEvent) => {
216
+ if (disabled) {
217
+ e.preventDefault()
218
+ e.stopPropagation()
219
+ return
220
+ }
221
+ onClick?.()
222
+ }
223
+
211
224
  return (
212
225
  <>
213
226
  {collapsible ? (
@@ -275,13 +288,14 @@ const { filteredPadding, filteredMargin } = filterItemSpacing(itemSpacing);
275
288
  {...ariaProps}
276
289
  {...dataProps}
277
290
  {...htmlProps}
291
+ aria-disabled={disabled}
278
292
  className={classes}
279
293
  href={isLink ? link : undefined}
280
294
  id={id}
281
- onClick={onClick}
295
+ onClick={handleClick}
282
296
  onKeyDown={!isLink ? handleKeyDown : undefined}
283
297
  role={!isLink ? "button" : undefined}
284
- tabIndex={!isLink ? 0 : undefined}
298
+ tabIndex={disabled ? -1 : (!isLink ? 0 : undefined)}
285
299
  target={isLink ? target : undefined}
286
300
  >
287
301
  {imageUrl && (
@@ -45,16 +45,18 @@
45
45
 
46
46
  [class*="pb_nav_list_kit_item"],
47
47
  [class*="pb_nav_list_item"] {
48
- &:hover { cursor: pointer; }
48
+ &:hover {
49
+ cursor: pointer;
50
+ }
49
51
  }
50
52
  }
51
53
 
52
54
  .pb_nav_extended_underline {
53
55
  position: relative;
54
-
56
+
55
57
  // Add full-width border using pseudo-element so as not to break the active item border
56
58
  &::after {
57
- content: '';
59
+ content: "";
58
60
  position: absolute;
59
61
  bottom: 0;
60
62
  left: 0;
@@ -65,8 +67,8 @@
65
67
  }
66
68
 
67
69
  .pb_nav_list_kit_item_active.pb_nav_list_item_link {
68
- position: relative;
69
- z-index: 2;
70
+ position: relative;
71
+ z-index: 2;
70
72
  }
71
73
 
72
74
  &.dark {
@@ -75,3 +77,26 @@
75
77
  }
76
78
  }
77
79
  }
80
+
81
+ // Disabled scss
82
+ .pb_nav_item_disabled {
83
+ cursor: not-allowed !important;
84
+ .pb_nav_list_item_text,
85
+ .pb_nav_list_item_icon_left,
86
+ .pb_nav_list_item_icon_right,
87
+ .pb_nav_list_item_icon_section {
88
+ color: $text_lt_lighter !important;
89
+ cursor: not-allowed !important;
90
+ }
91
+ @media (hover: hover) {
92
+ &:hover {
93
+ background-color: unset !important;
94
+ color: $text_lt_lighter !important;
95
+ .pb_nav_list_item_text,
96
+ .pb_nav_list_item_icon_left,
97
+ .pb_nav_list_item_icon_right {
98
+ color: $text_lt_lighter !important;
99
+ }
100
+ }
101
+ }
102
+ }
@@ -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;
@@ -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.
@@ -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 %>