playbook_ui 15.4.0 → 15.5.0.pre.alpha.PLAY2581aggressivevalidation12651
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +96 -6
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.jsx +2 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_fullscreen.jsx +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.jsx +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling.jsx +2 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +1 -1
- data/app/pb_kits/playbook/pb_copy_button/_copy_button.tsx +21 -8
- data/app/pb_kits/playbook/pb_copy_button/copy_button.html.erb +6 -2
- data/app/pb_kits/playbook/pb_copy_button/copy_button.rb +3 -0
- data/app/pb_kits/playbook/pb_copy_button/copy_button.test.jsx +24 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_button_variant.html.erb +9 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_button_variant.jsx +24 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_button_variant_rails.md +1 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_button_variant_react.md +1 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.html.erb +2 -2
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.jsx +1 -2
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.html.erb +2 -2
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.jsx +2 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_copy_button/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_abbreviated.md +1 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_matching_decimals_rails.md +1 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_matching_decimals_react.md +1 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_negative.html.erb +10 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_negative.jsx +10 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_negative.md +1 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_no_symbol_rails.md +1 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_no_symbol_react.md +1 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.html.erb +7 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.jsx +7 -0
- data/app/pb_kits/playbook/pb_currency/docs/_description.md +2 -2
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +25 -11
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +44 -3
- data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.tsx +20 -13
- data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb +6 -4
- data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.test.js +17 -0
- data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_show_current_year.html.erb +4 -0
- data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_show_current_year.jsx +43 -0
- data/app/pb_kits/playbook/pb_date_range_inline/docs/_date_range_inline_show_current_year.md +1 -0
- data/app/pb_kits/playbook/pb_date_range_inline/docs/_description.md +1 -1
- data/app/pb_kits/playbook/pb_date_range_inline/docs/example.yml +3 -2
- data/app/pb_kits/playbook/pb_date_range_inline/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.tsx +6 -4
- data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +2 -3
- data/app/pb_kits/playbook/pb_date_stacked/date_stacked.rb +11 -5
- data/app/pb_kits/playbook/pb_date_stacked/date_stacked.test.js +26 -9
- data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_current_year.html.erb +12 -0
- data/app/pb_kits/playbook/pb_date_stacked/docs/{_date_stacked_not_current_year.jsx → _date_stacked_current_year.jsx} +6 -5
- data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_current_year.md +1 -0
- data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_date_stacked/docs/_description.md +1 -1
- data/app/pb_kits/playbook/pb_date_stacked/docs/example.yml +2 -2
- data/app/pb_kits/playbook/pb_date_stacked/docs/index.js +1 -1
- data/app/pb_kits/playbook/pb_date_time/_date_time.tsx +3 -0
- data/app/pb_kits/playbook/pb_date_time/date_time.html.erb +1 -0
- data/app/pb_kits/playbook/pb_date_time/date_time.rb +1 -0
- data/app/pb_kits/playbook/pb_date_time/docs/_date_time_show_current_year.html.erb +4 -0
- data/app/pb_kits/playbook/pb_date_time/docs/_date_time_show_current_year.jsx +14 -0
- data/app/pb_kits/playbook/pb_date_time/docs/_date_time_show_current_year_rails.md +1 -0
- data/app/pb_kits/playbook/pb_date_time/docs/_date_time_show_current_year_react.md +1 -0
- data/app/pb_kits/playbook/pb_date_time/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_date_time/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.tsx +3 -0
- data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +2 -2
- data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.rb +2 -0
- data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.test.js +33 -0
- data/app/pb_kits/playbook/pb_date_time_stacked/docs/_date_time_stacked_show_current_year.html.erb +4 -0
- data/app/pb_kits/playbook/pb_date_time_stacked/docs/_date_time_stacked_show_current_year.jsx +22 -0
- data/app/pb_kits/playbook/pb_date_time_stacked/docs/_date_time_stacked_show_current_year.md +1 -0
- data/app/pb_kits/playbook/pb_date_time_stacked/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_date_time_stacked/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +2 -2
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +156 -6
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +8 -3
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_dropzone.jsx +180 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_dropzone.md +22 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +3 -2
- data/app/pb_kits/playbook/pb_draggable/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +77 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +32 -14
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_alignment.jsx +2 -1
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_default.jsx +2 -1
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_orientation.jsx +2 -1
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_size.jsx +2 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +31 -9
- data/app/pb_kits/playbook/pb_flex/_flex_item.tsx +12 -5
- data/app/pb_kits/playbook/pb_flex/docs/_flex_item_example.jsx +1 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.jsx +4 -1
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_variant.jsx +1 -1
- data/app/pb_kits/playbook/pb_nav/_item.tsx +18 -4
- data/app/pb_kits/playbook/pb_nav/_nav.scss +30 -5
- data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +192 -0
- data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +1 -1
- data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.html.erb +21 -0
- data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.jsx +113 -0
- data/app/pb_kits/playbook/pb_nav/docs/_horizontal_nav_disabled.md +1 -0
- data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.html.erb +30 -0
- data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.jsx +117 -0
- data/app/pb_kits/playbook/pb_nav/docs/_vertical_nav_disabled.md +1 -0
- data/app/pb_kits/playbook/pb_nav/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_nav/docs/index.js +3 -1
- data/app/pb_kits/playbook/pb_nav/item.html.erb +6 -4
- data/app/pb_kits/playbook/pb_nav/item.rb +11 -2
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_description.md +3 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_colors.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_default.md +1 -0
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_height.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_horizontal.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend_non_clickable.jsx +1 -2
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend_position.html.erb +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend_position.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend_position.md +11 -0
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_negative_numbers.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_secondary_y_axis.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_spline.jsx +1 -2
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_stacked.jsx +1 -2
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_description.md +3 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_block_content.jsx +2 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_color_overrides.jsx +2 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_custom_tooltip.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_custom_tooltip.md +2 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_data_legend_position.jsx +2 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_data_with_labels.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_data_with_legend.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_default.md +1 -0
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_inner_sizes.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_live_data.jsx +2 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_rounded.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_with_title.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_description.md +3 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.md +2 -2
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.jsx +2 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.md +1 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_full_circle.jsx +2 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_height.jsx +2 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.jsx +2 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.jsx +2 -1
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_description.md +3 -1
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.md +1 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.html.erb +1 -1
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +32 -9
- data/app/pb_kits/playbook/pb_popover/docs/_popover_append_to.jsx +4 -1
- data/app/pb_kits/playbook/pb_progress_step/_progress_step.scss +384 -262
- data/app/pb_kits/playbook/pb_progress_step/docs/_description.md +1 -5
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_color.html.erb +14 -0
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_color.jsx +29 -0
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_color.md +3 -0
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_custom_icon.jsx +31 -0
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_custom_icon.md +1 -0
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_default.html.erb +4 -1
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_default.jsx +14 -3
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_default.md +3 -0
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_tracker.md +3 -0
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_vertical.html.erb +1 -7
- data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_vertical.md +1 -0
- data/app/pb_kits/playbook/pb_progress_step/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_progress_step/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_progress_step/progress_step.test.js +41 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.jsx +3 -1
- data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.jsx +3 -1
- data/app/pb_kits/playbook/pb_table/_table.tsx +28 -26
- data/app/pb_kits/playbook/pb_table/styles/_vertical_border.scss +49 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.jsx +4 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +4 -0
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.jsx +2 -1
- data/app/pb_kits/playbook/pb_user/docs/_user_font_options.jsx +1 -1
- data/app/pb_kits/playbook/utilities/_truncate.scss +2 -0
- data/app/pb_kits/playbook/utilities/globalProps.ts +26 -8
- data/app/pb_kits/playbook/utilities/test/globalProps/alignContent.test.js +18 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/alignItems.test.js +18 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/alignSelf.test.js +18 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/display.test.js +18 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/flex.test.js +18 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/flexDirection.test.js +18 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/flexGrow.test.js +18 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/flexShrink.test.js +18 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/flexWrap.test.js +18 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/justifyContent.test.js +18 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/justifySelf.test.js +18 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/order.test.js +18 -0
- data/dist/chunks/_typeahead-DrZthFaf.js +6 -0
- data/dist/chunks/lib-CgpqUb6l.js +29 -0
- data/dist/chunks/vendor.js +37 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +2 -2
- metadata +48 -12
- data/app/pb_kits/playbook/pb_bar_graph/BarGraphStyles.scss +0 -58
- data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_not_current_year.html.erb +0 -5
- data/dist/chunks/_line_graph-r__oOO2H.js +0 -1
- data/dist/chunks/_typeahead-B7c52zVj.js +0 -6
- data/dist/chunks/_weekday_stacked-DgiIj2w3.js +0 -37
- data/dist/chunks/componentRegistry-DzmmLR2x.js +0 -1
- data/dist/chunks/lib-CRUXizZe.js +0 -29
- data/dist/chunks/pb_form_validation-CywJN0ej.js +0 -1
- data/dist/playbook-doc.js +0 -19
|
@@ -255,4 +255,80 @@ test("line dropZone with horizontal direction applies 'line_horizontal' class to
|
|
|
255
255
|
const container = kit.querySelector(".pb_draggable_container");
|
|
256
256
|
|
|
257
257
|
expect(container).toHaveClass("line_horizontal");
|
|
258
|
-
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// Cross-container drag tests
|
|
261
|
+
const multiContainerData = [
|
|
262
|
+
{ id: "1", container: "To Do", text: "Task 1" },
|
|
263
|
+
{ id: "2", container: "To Do", text: "Task 2" },
|
|
264
|
+
{ id: "3", container: "In Progress", text: "Task 3" },
|
|
265
|
+
{ id: "4", container: "Done", text: "Task 4" },
|
|
266
|
+
];
|
|
267
|
+
|
|
268
|
+
const containers = ["To Do", "In Progress", "Done"];
|
|
269
|
+
|
|
270
|
+
const DraggableMultipleContainers = () => {
|
|
271
|
+
const [initialState, setInitialState] = useState(multiContainerData);
|
|
272
|
+
|
|
273
|
+
return (
|
|
274
|
+
<div data-testid={testId}>
|
|
275
|
+
<DraggableProvider
|
|
276
|
+
dropZone={{ type: "outline" }}
|
|
277
|
+
initialItems={multiContainerData}
|
|
278
|
+
onReorder={(items) => setInitialState(items)}
|
|
279
|
+
>
|
|
280
|
+
{containers.map((container) => (
|
|
281
|
+
<Draggable.Container
|
|
282
|
+
container={container}
|
|
283
|
+
data={{testid:`container-${container}`}}
|
|
284
|
+
key={container}
|
|
285
|
+
>
|
|
286
|
+
{initialState
|
|
287
|
+
.filter((item) => item.container === container)
|
|
288
|
+
.map(({ id, text }) => (
|
|
289
|
+
<Draggable.Item
|
|
290
|
+
container={container}
|
|
291
|
+
data-testid={`item-${id}`}
|
|
292
|
+
dragId={id}
|
|
293
|
+
key={id}
|
|
294
|
+
>
|
|
295
|
+
{text}
|
|
296
|
+
</Draggable.Item>
|
|
297
|
+
))}
|
|
298
|
+
</Draggable.Container>
|
|
299
|
+
))}
|
|
300
|
+
</DraggableProvider>
|
|
301
|
+
</div>
|
|
302
|
+
);
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
test("renders multiple containers with correct items", () => {
|
|
306
|
+
render(<DraggableMultipleContainers />);
|
|
307
|
+
|
|
308
|
+
const kit = screen.getByTestId(testId);
|
|
309
|
+
expect(kit).toBeInTheDocument();
|
|
310
|
+
|
|
311
|
+
containers.forEach((container) => {
|
|
312
|
+
const containerEl = kit.querySelector(`[data-testid="container-${container}"]`);
|
|
313
|
+
expect(containerEl).toBeInTheDocument();
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// Check items are in correct containers
|
|
317
|
+
expect(screen.getByText("Task 1")).toBeInTheDocument();
|
|
318
|
+
expect(screen.getByText("Task 2")).toBeInTheDocument();
|
|
319
|
+
expect(screen.getByText("Task 3")).toBeInTheDocument();
|
|
320
|
+
expect(screen.getByText("Task 4")).toBeInTheDocument();
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
test("items have correct container association", () => {
|
|
324
|
+
const { container } = render(<DraggableMultipleContainers />);
|
|
325
|
+
|
|
326
|
+
// items rendered within their respective containers
|
|
327
|
+
const todoContainer = container.querySelector('[data-testid="container-To Do"]');
|
|
328
|
+
const inProgressContainer = container.querySelector('[data-testid="container-In Progress"]');
|
|
329
|
+
const doneContainer = container.querySelector('[data-testid="container-Done"]');
|
|
330
|
+
|
|
331
|
+
expect(todoContainer.querySelectorAll('.pb_draggable_item')).toHaveLength(2);
|
|
332
|
+
expect(inProgressContainer.querySelectorAll('.pb_draggable_item')).toHaveLength(1);
|
|
333
|
+
expect(doneContainer.querySelectorAll('.pb_draggable_item')).toHaveLength(1);
|
|
334
|
+
})
|
|
@@ -33,6 +33,8 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
|
33
33
|
this.formPillProps = this.element.dataset.formPillProps
|
|
34
34
|
? JSON.parse(this.element.dataset.formPillProps)
|
|
35
35
|
: {};
|
|
36
|
+
const baseInput = this.element.querySelector(DROPDOWN_INPUT);
|
|
37
|
+
this.wasOriginallyRequired = baseInput && baseInput.hasAttribute("required");
|
|
36
38
|
this.setDefaultValue();
|
|
37
39
|
this.bindEventListeners();
|
|
38
40
|
this.bindSearchInput();
|
|
@@ -126,7 +128,7 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
|
126
128
|
.label.toString()
|
|
127
129
|
.toLowerCase();
|
|
128
130
|
|
|
129
|
-
|
|
131
|
+
// hide or show option
|
|
130
132
|
const match = label.includes(lcTerm);
|
|
131
133
|
opt.style.display = match ? "" : "none";
|
|
132
134
|
if (match) hasMatch = true
|
|
@@ -356,17 +358,6 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
|
356
358
|
}
|
|
357
359
|
|
|
358
360
|
clearFormValidation(input) {
|
|
359
|
-
if (input.checkValidity()) {
|
|
360
|
-
const dropdownWrapperElement = input.closest(".dropdown_wrapper");
|
|
361
|
-
dropdownWrapperElement.classList.remove("error");
|
|
362
|
-
|
|
363
|
-
const errorLabelElement = dropdownWrapperElement.querySelector(
|
|
364
|
-
".pb_body_kit_negative"
|
|
365
|
-
);
|
|
366
|
-
if (errorLabelElement) {
|
|
367
|
-
errorLabelElement.remove();
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
361
|
if (this.isMultiSelect) {
|
|
371
362
|
if (this.selectedOptions.size > 0) {
|
|
372
363
|
const dropdownWrapperElement = input.closest(".dropdown_wrapper");
|
|
@@ -377,6 +368,19 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
|
377
368
|
if (errorLabelElement) {
|
|
378
369
|
errorLabelElement.remove();
|
|
379
370
|
}
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (input.checkValidity()) {
|
|
376
|
+
const dropdownWrapperElement = input.closest(".dropdown_wrapper");
|
|
377
|
+
dropdownWrapperElement.classList.remove("error");
|
|
378
|
+
|
|
379
|
+
const errorLabelElement = dropdownWrapperElement.querySelector(
|
|
380
|
+
".pb_body_kit_negative"
|
|
381
|
+
);
|
|
382
|
+
if (errorLabelElement) {
|
|
383
|
+
errorLabelElement.remove();
|
|
380
384
|
}
|
|
381
385
|
}
|
|
382
386
|
}
|
|
@@ -585,7 +589,9 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
|
585
589
|
// for multi_select, for each selectedOption, create a hidden input
|
|
586
590
|
const name = baseInput.getAttribute("name");
|
|
587
591
|
this.selectedOptions.forEach((raw) => {
|
|
588
|
-
const
|
|
592
|
+
const optionData = JSON.parse(raw);
|
|
593
|
+
// Use id if available, otherwise fall back to value
|
|
594
|
+
const id = optionData.id || optionData.value;
|
|
589
595
|
const inp = document.createElement("input");
|
|
590
596
|
inp.type = "hidden";
|
|
591
597
|
inp.name = name;
|
|
@@ -593,7 +599,19 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
|
593
599
|
inp.dataset.generated = "true";
|
|
594
600
|
baseInput.insertAdjacentElement("afterend", inp);
|
|
595
601
|
});
|
|
596
|
-
|
|
602
|
+
|
|
603
|
+
// For multi-select, remove required from base input when there are selections
|
|
604
|
+
// The generated inputs handle the form submission with actual values
|
|
605
|
+
// Restore required attribute when there are no selections (if it was originally required)
|
|
606
|
+
if (this.selectedOptions.size > 0) {
|
|
607
|
+
baseInput.value = "";
|
|
608
|
+
baseInput.removeAttribute("required");
|
|
609
|
+
} else {
|
|
610
|
+
baseInput.value = "";
|
|
611
|
+
if (this.wasOriginallyRequired) {
|
|
612
|
+
baseInput.setAttribute("required", "");
|
|
613
|
+
}
|
|
614
|
+
}
|
|
597
615
|
}
|
|
598
616
|
|
|
599
617
|
handleBackspaceClear() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
1
|
+
import React, { useEffect, useState, useRef } from "react";
|
|
2
2
|
import classnames from "classnames";
|
|
3
3
|
|
|
4
4
|
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
|
@@ -36,6 +36,7 @@ type FixedConfirmationToastProps = {
|
|
|
36
36
|
|
|
37
37
|
const FixedConfirmationToast = (props: FixedConfirmationToastProps): React.ReactElement => {
|
|
38
38
|
const [showToast, toggleToast] = useState(true);
|
|
39
|
+
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
39
40
|
|
|
40
41
|
const {
|
|
41
42
|
autoClose = 0,
|
|
@@ -67,21 +68,42 @@ const FixedConfirmationToast = (props: FixedConfirmationToastProps): React.React
|
|
|
67
68
|
|
|
68
69
|
const htmlProps = buildHtmlProps(htmlOptions);
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
toggleToast(open);
|
|
73
|
+
}, [open]);
|
|
74
|
+
|
|
75
|
+
// Manage auto-close timeout separately
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
// Clear any existing timeout
|
|
78
|
+
if (timeoutRef.current) {
|
|
79
|
+
clearTimeout(timeoutRef.current);
|
|
80
|
+
timeoutRef.current = null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Set new timeout if autoClose is enabled and toast is open
|
|
84
|
+
if (autoClose && open && showToast) {
|
|
85
|
+
timeoutRef.current = setTimeout(() => {
|
|
73
86
|
toggleToast(false);
|
|
74
87
|
onClose();
|
|
88
|
+
timeoutRef.current = null;
|
|
75
89
|
}, autoClose);
|
|
76
90
|
}
|
|
77
|
-
};
|
|
78
91
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
92
|
+
// Cleanup function to clear timeout on unmount or when dependencies change
|
|
93
|
+
return () => {
|
|
94
|
+
if (timeoutRef.current) {
|
|
95
|
+
clearTimeout(timeoutRef.current);
|
|
96
|
+
timeoutRef.current = null;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}, [autoClose, open, showToast, onClose]);
|
|
83
100
|
|
|
84
101
|
const handleClick = () => {
|
|
102
|
+
// Clear autoClose timeout when manually closing
|
|
103
|
+
if (timeoutRef.current) {
|
|
104
|
+
clearTimeout(timeoutRef.current);
|
|
105
|
+
timeoutRef.current = null;
|
|
106
|
+
}
|
|
85
107
|
toggleToast(!closeable);
|
|
86
108
|
onClose();
|
|
87
109
|
};
|
|
@@ -2,6 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import classnames from 'classnames'
|
|
3
3
|
import { buildCss, buildHtmlProps } from '../utilities/props'
|
|
4
4
|
import { globalProps, GlobalProps, globalInlineProps} from '../utilities/globalProps'
|
|
5
|
+
|
|
5
6
|
type FlexItemPropTypes = {
|
|
6
7
|
children: React.ReactNode[] | React.ReactNode,
|
|
7
8
|
fixedSize?: string,
|
|
@@ -28,22 +29,28 @@ const FlexItem = (props: FlexItemPropTypes): React.ReactElement => {
|
|
|
28
29
|
alignSelf,
|
|
29
30
|
displayFlex
|
|
30
31
|
} = props
|
|
32
|
+
|
|
31
33
|
const growClass = grow === true ? 'pb_flex_item_kit_grow' : ''
|
|
32
34
|
const displayFlexClass = displayFlex === true ? 'pb_flex_item_kit_display_flex' : ''
|
|
33
35
|
const flexClass = flex !== 'none' ? `pb_flex_item_kit_flex_${flex}` : ''
|
|
34
36
|
const shrinkClass = shrink === true ? 'pb_flex_item_kit_shrink' : ''
|
|
35
37
|
const alignSelfClass = alignSelf ? `pb_flex_item_kit_align_self_${alignSelf}` : ''
|
|
36
|
-
const fixedStyle =
|
|
37
|
-
fixedSize !== undefined ? { flexBasis: `${fixedSize}` } : null
|
|
38
|
+
const fixedStyle = fixedSize !== undefined ? { flexBasis: `${fixedSize}` } : null
|
|
38
39
|
const orderClass = order !== 'none' ? `pb_flex_item_kit_order_${order}` : ''
|
|
39
40
|
const dynamicInlineProps = globalInlineProps(props)
|
|
41
|
+
|
|
42
|
+
// Extract style from htmlOptions and remove it
|
|
43
|
+
const { style: htmlStyle, ...htmlOptionsWithoutStyle } = htmlOptions
|
|
44
|
+
const htmlStyleObj = htmlStyle && typeof htmlStyle === 'object' ? htmlStyle : {}
|
|
45
|
+
|
|
46
|
+
// Merge all styles
|
|
40
47
|
const combinedStyles = {
|
|
48
|
+
...htmlStyleObj,
|
|
41
49
|
...fixedStyle,
|
|
42
50
|
...dynamicInlineProps
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
const htmlProps = buildHtmlProps(
|
|
46
|
-
|
|
53
|
+
const htmlProps = buildHtmlProps(htmlOptionsWithoutStyle)
|
|
47
54
|
|
|
48
55
|
return (
|
|
49
56
|
<div
|
|
@@ -66,4 +73,4 @@ const FlexItem = (props: FlexItemPropTypes): React.ReactElement => {
|
|
|
66
73
|
)
|
|
67
74
|
}
|
|
68
75
|
|
|
69
|
-
export default FlexItem
|
|
76
|
+
export default FlexItem
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import
|
|
2
|
+
import Card from '../../pb_card/_card'
|
|
3
|
+
import Caption from '../../pb_caption/_caption'
|
|
4
|
+
import FormPill from '../_form_pill'
|
|
5
|
+
import Typeahead from '../../pb_typeahead/_typeahead'
|
|
3
6
|
|
|
4
7
|
const names = [
|
|
5
8
|
{ label: 'Alexander Nathaniel Montgomery', value: 'Alexander Nathaniel Montgomery' },
|
|
@@ -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={
|
|
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 {
|
|
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
|
-
|
|
69
|
-
|
|
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
|
+
})
|