playbook_ui 18.2.0 → 18.3.0.pre.alpha.forwardrefwarnings20879
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/table_header.rb +1 -1
- data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +3 -1
- data/app/pb_kits/playbook/pb_avatar/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_collapsible/collapsible.test.js +1 -2
- data/app/pb_kits/playbook/pb_contact/_contact.tsx +4 -1
- data/app/pb_kits/playbook/pb_contact/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_date/_date.tsx +3 -1
- data/app/pb_kits/playbook/pb_date/date.test.js +1 -1
- data/app/pb_kits/playbook/pb_date/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +4 -0
- data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.tsx +3 -1
- data/app/pb_kits/playbook/pb_date_range_inline/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_date_range_stacked/_date_range_stacked.tsx +3 -1
- data/app/pb_kits/playbook/pb_date_range_stacked/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.tsx +4 -1
- data/app/pb_kits/playbook/pb_date_stacked/date_stacked.test.js +1 -0
- data/app/pb_kits/playbook/pb_date_stacked/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_date_time/_date_time.tsx +3 -1
- data/app/pb_kits/playbook/pb_date_time/dateTime.test.js +1 -0
- data/app/pb_kits/playbook/pb_date_time/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.tsx +2 -1
- data/app/pb_kits/playbook/pb_date_time_stacked/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.tsx +3 -1
- data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.test.js +1 -0
- data/app/pb_kits/playbook/pb_date_year_stacked/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_draggable/utilities/touchDrag.ts +10 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +112 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +121 -15
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_draggable_pills.html.erb +51 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_draggable_pills.jsx +62 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_draggable_pills_rails.md +9 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_draggable_pills_react.md +9 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_form.jsx +50 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_form_react.md +9 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_option_creation.html.erb +16 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_option_creation.jsx +27 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_option_creation_rails.md +9 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_option_creation_react.md +9 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_playground.json +33 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/_playground.overrides.json +13 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +5 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +4 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +2 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +24 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +235 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown_creation.test.jsx +414 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_form.test.jsx +173 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_index.test.js +545 -0
- data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +22 -5
- data/app/pb_kits/playbook/pb_dropdown/index.js +260 -37
- data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +3 -1
- data/app/pb_kits/playbook/pb_dropdown/kit.schema.json +42 -2
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +43 -25
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownFormFields.tsx +83 -0
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +13 -5
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/MultiSelectTriggerDisplay.tsx +336 -31
- data/app/pb_kits/playbook/pb_dropdown/utilities/optionCreation.ts +21 -0
- data/app/pb_kits/playbook/pb_dropdown/utilities/pillReorder.js +281 -0
- data/app/pb_kits/playbook/pb_dropdown/utilities/quickpickDateSync.test.ts +24 -0
- data/app/pb_kits/playbook/pb_dropdown/utilities/usePillDropIndicator.ts +144 -0
- data/app/pb_kits/playbook/pb_filter/Filter/SortMenu.tsx +8 -1
- data/app/pb_kits/playbook/pb_filter/docs/_filter_one_click.html.erb +38 -0
- data/app/pb_kits/playbook/pb_filter/docs/_filter_one_click.jsx +69 -0
- data/app/pb_kits/playbook/pb_filter/docs/_filter_one_click.md +1 -0
- data/app/pb_kits/playbook/pb_filter/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_filter/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_filter/filter.html.erb +4 -4
- data/app/pb_kits/playbook/pb_filter/filter.rb +28 -0
- data/app/pb_kits/playbook/pb_filter/filter.test.js +41 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.test.js +1 -2
- data/app/pb_kits/playbook/pb_form/docs/_description_react.md +3 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_default_values.jsx +898 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_default_values_react.md +3 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_defaults.jsx +879 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_defaults_react.md +29 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_loading.jsx +75 -0
- data/app/pb_kits/playbook/pb_form/docs/{_form_loading.md → _form_loading_rails.md} +1 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_loading_react.md +1 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_model_values.jsx +147 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_model_values_react.md +16 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_multi_column.jsx +164 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_multi_column_react.md +3 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_validation.jsx +1057 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_validation_react.md +26 -0
- data/app/pb_kits/playbook/pb_form/docs/example.yml +7 -0
- data/app/pb_kits/playbook/pb_form/pb_form_validation.js +1 -0
- data/app/pb_kits/playbook/pb_form_group/_form_group.scss +1 -4
- data/app/pb_kits/playbook/pb_full_screen/_full_screen.scss +6 -0
- data/app/pb_kits/playbook/pb_full_screen/_full_screen.tsx +11 -2
- data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_advanced_table_sticky_header.jsx +73 -0
- data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_advanced_table_sticky_header.md +1 -0
- data/app/pb_kits/playbook/pb_full_screen/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_full_screen/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_full_screen/full_screen.test.jsx +4 -2
- data/app/pb_kits/playbook/pb_image/_image.tsx +3 -1
- data/app/pb_kits/playbook/pb_image/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_label_pill/_label_pill.tsx +3 -1
- data/app/pb_kits/playbook/pb_label_pill/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_legend/_legend.tsx +3 -1
- data/app/pb_kits/playbook/pb_legend/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_list/_list_item.tsx +6 -3
- data/app/pb_kits/playbook/pb_map/docs/_map_default.md +22 -3
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +4 -1
- data/app/pb_kits/playbook/pb_online_status/_online_status.tsx +3 -1
- data/app/pb_kits/playbook/pb_online_status/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_pb_bar_graph/pbbargraph.test.jsx +1 -2
- data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.test.jsx +1 -2
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.test.jsx +1 -2
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.test.jsx +1 -2
- data/app/pb_kits/playbook/pb_person/_person.tsx +3 -1
- data/app/pb_kits/playbook/pb_person/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_pill/_pill.tsx +3 -1
- data/app/pb_kits/playbook/pb_pill/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_progress_step/_progress_step_item.tsx +3 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_playground.json +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_playground.overrides.json +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_required_indicator.md +2 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_rails_default.md +3 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_rails_extensions.md +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_rails_markdown_support.md +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_rails_required_indicator.html.erb +9 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_rails_required_indicator.md +3 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +3 -7
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor_rails.js +26 -21
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor_rails.test.js +85 -1
- data/app/pb_kits/playbook/pb_selectable_card_icon/_selectable_card_icon.scss +0 -9
- data/app/pb_kits/playbook/pb_selectable_card_icon/docs/_selectable_card_icon_custom.jsx +1 -1
- data/app/pb_kits/playbook/pb_selectable_icon/_selectable_icon.scss +0 -7
- data/app/pb_kits/playbook/pb_source/_source.tsx +3 -1
- data/app/pb_kits/playbook/pb_source/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_source/source.rb +1 -1
- data/app/pb_kits/playbook/pb_stat_change/_stat_change.tsx +3 -1
- data/app/pb_kits/playbook/pb_stat_change/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +4 -1
- data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +3 -1
- data/app/pb_kits/playbook/pb_time_range_inline/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.tsx +3 -1
- data/app/pb_kits/playbook/pb_time_stacked/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_timeline/_item.tsx +3 -1
- data/app/pb_kits/playbook/pb_timestamp/_timestamp.tsx +3 -1
- data/app/pb_kits/playbook/pb_timestamp/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_timestamp/timestamp.test.js +1 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +73 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +285 -12
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +22 -14
- data/app/pb_kits/playbook/pb_typeahead/components/PillRenderer.tsx +15 -11
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +29 -30
- data/app/pb_kits/playbook/pb_typeahead/components/usePillDropIndicator.ts +155 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_playground.json +5 -5
- data/app/pb_kits/playbook/pb_typeahead/docs/_playground.overrides.json +2 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.html.erb +0 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.jsx +0 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills_rails.md +3 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills_react.md +7 -0
- data/app/pb_kits/playbook/pb_typeahead/kit.schema.json +3 -3
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +3 -3
- data/app/pb_kits/playbook/pb_user/_user.tsx +3 -1
- data/app/pb_kits/playbook/pb_user/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_user_badge/_user_badge.tsx +3 -1
- data/app/pb_kits/playbook/pb_user_badge/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +3 -1
- data/app/pb_kits/playbook/pb_weekday_stacked/kit.schema.json +1 -0
- data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.test.jsx +1 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/onClick.test.js +302 -0
- data/app/pb_kits/playbook/utilities/test-utils.js +0 -1
- data/dist/ai/all-schemas.json +108 -15
- data/dist/ai/external-dependencies.json +1 -1
- data/dist/ai/forms.json +2 -2
- data/dist/ai/index.json +3 -3
- data/dist/ai/kits/avatar.schema.json +1 -0
- data/dist/ai/kits/contact.schema.json +1 -0
- data/dist/ai/kits/date.schema.json +1 -0
- data/dist/ai/kits/date_range_inline.schema.json +1 -0
- data/dist/ai/kits/date_range_stacked.schema.json +1 -0
- data/dist/ai/kits/date_stacked.schema.json +1 -0
- data/dist/ai/kits/date_time.schema.json +1 -0
- data/dist/ai/kits/date_time_stacked.schema.json +1 -0
- data/dist/ai/kits/date_year_stacked.schema.json +1 -0
- data/dist/ai/kits/dropdown.schema.json +81 -11
- data/dist/ai/kits/image.schema.json +1 -0
- data/dist/ai/kits/label_pill.schema.json +1 -0
- data/dist/ai/kits/legend.schema.json +1 -0
- data/dist/ai/kits/online_status.schema.json +1 -0
- data/dist/ai/kits/person.schema.json +1 -0
- data/dist/ai/kits/pill.schema.json +1 -0
- data/dist/ai/kits/rich_text_editor.schema.json +1 -1
- data/dist/ai/kits/source.schema.json +1 -0
- data/dist/ai/kits/stat_change.schema.json +1 -0
- data/dist/ai/kits/time_range_inline.schema.json +1 -0
- data/dist/ai/kits/time_stacked.schema.json +1 -0
- data/dist/ai/kits/timestamp.schema.json +1 -0
- data/dist/ai/kits/typeahead.schema.json +3 -3
- data/dist/ai/kits/user.schema.json +1 -0
- data/dist/ai/kits/user_badge.schema.json +1 -0
- data/dist/ai/kits/weekday_stacked.schema.json +1 -0
- data/dist/ai/playgrounds/dropdown.json +1 -1
- data/dist/ai/playgrounds/index.json +1 -1
- data/dist/ai/playgrounds/rich_text_editor.json +1 -1
- data/dist/ai/playgrounds/typeahead.json +1 -1
- data/dist/chunks/_pagination-CARbC_IN.js +1 -0
- data/dist/chunks/{_pb_line_graph-Du7xE9vl.js → _pb_line_graph-BKwbOeqo.js} +1 -1
- data/dist/chunks/{_detail-Bsvl694i.js → _tooltip-UkcgcThO.js} +2 -2
- data/dist/chunks/_typeahead-D_li2Zx8.js +1 -0
- data/dist/chunks/{globalProps-B120NbSJ.js → globalProps-BivjwRew.js} +1 -1
- data/dist/chunks/index-4jrZjexD.js +1 -0
- data/dist/chunks/index-BAy61y8S.js +1 -0
- data/dist/chunks/index-Cb_SDipk.js +1 -0
- data/dist/chunks/index-D3RdsDp7.js +1 -0
- data/dist/chunks/index-D8PZIesy.js +1 -0
- data/dist/chunks/index-DIoc-aua.js +1 -0
- data/dist/chunks/index-qex65UMn.js +1 -0
- data/dist/chunks/lib-C50eCpoN.js +29 -0
- data/dist/chunks/{time_picker_helper-CYGg0UQ0.js → time_picker_helper-DfKvHCJu.js} +1 -1
- data/dist/chunks/vendor.js +2 -2
- data/dist/menu.yml +1 -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 +80 -21
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.md +0 -7
- data/dist/chunks/_table-Bf6LGyL9.js +0 -1
- data/dist/chunks/_typeahead-w6S5Vx4b.js +0 -1
- data/dist/chunks/lib-Buo6zHEw.js +0 -29
- /data/app/pb_kits/playbook/pb_form/docs/{_description.md → _description_rails.md} +0 -0
- /data/app/pb_kits/playbook/pb_form/docs/{_form_default_values.md → _form_default_values_rails.md} +0 -0
- /data/app/pb_kits/playbook/pb_form/docs/{_form_defaults.md → _form_defaults_rails.md} +0 -0
- /data/app/pb_kits/playbook/pb_form/docs/{_form_model_values.md → _form_model_values_rails.md} +0 -0
- /data/app/pb_kits/playbook/pb_form/docs/{_form_multi_column.md → _form_multi_column_rails.md} +0 -0
- /data/app/pb_kits/playbook/pb_form/docs/{_form_validation.md → _form_validation_rails.md} +0 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
const ROW_TOLERANCE = 80;
|
|
2
|
+
const DRAG_THRESHOLD_PX = 5;
|
|
3
|
+
const DRAG_HANDLE_SELECTOR = ".pb_draggable_handle, .pb_dropdown_external_drag_handle";
|
|
4
|
+
const CLOSE_SELECTOR = ".pb_form_pill_close";
|
|
5
|
+
const PILL_FOCUS_SELECTOR = ".pb_form_pill_kit, .pb_form_pill_kit_icon";
|
|
6
|
+
|
|
7
|
+
let lastPointer = null;
|
|
8
|
+
let pointerTrackingInstalled = false;
|
|
9
|
+
|
|
10
|
+
const ensurePointerTracking = () => {
|
|
11
|
+
if (pointerTrackingInstalled || typeof document === "undefined") return;
|
|
12
|
+
pointerTrackingInstalled = true;
|
|
13
|
+
|
|
14
|
+
document.addEventListener("mousemove", (event) => {
|
|
15
|
+
if (event.buttons === 0) return;
|
|
16
|
+
lastPointer = { x: event.clientX, y: event.clientY };
|
|
17
|
+
}, true);
|
|
18
|
+
|
|
19
|
+
document.addEventListener("touchmove", (event) => {
|
|
20
|
+
const touch = event.touches[0];
|
|
21
|
+
if (touch) lastPointer = { x: touch.clientX, y: touch.clientY };
|
|
22
|
+
}, { capture: true, passive: true });
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getVerticalDistance = (rect, y) => Math.max(rect.top - y, y - rect.bottom, 0);
|
|
26
|
+
|
|
27
|
+
export const getDropTarget = (pills, x, y) => {
|
|
28
|
+
if (pills.length === 0) return null;
|
|
29
|
+
|
|
30
|
+
const rects = pills.map((pill) => pill.getBoundingClientRect());
|
|
31
|
+
const nearestRect = rects.reduce((nearest, rect) => (
|
|
32
|
+
getVerticalDistance(rect, y) < getVerticalDistance(nearest, y) ? rect : nearest
|
|
33
|
+
));
|
|
34
|
+
if (getVerticalDistance(nearestRect, y) > ROW_TOLERANCE) return null;
|
|
35
|
+
|
|
36
|
+
const rowIndexes = rects
|
|
37
|
+
.map((rect, index) => ({ index, rect }))
|
|
38
|
+
.filter(({ rect }) => rect.top < nearestRect.bottom && rect.bottom > nearestRect.top)
|
|
39
|
+
.map(({ index }) => index);
|
|
40
|
+
|
|
41
|
+
const pillAfterPointer = rowIndexes.find((index) => x < rects[index].left + rects[index].width / 2);
|
|
42
|
+
if (pillAfterPointer !== undefined) {
|
|
43
|
+
return { after: false, index: pillAfterPointer };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { after: true, index: rowIndexes[rowIndexes.length - 1] };
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const clearDropLines = (pills) => {
|
|
50
|
+
pills.forEach((pill) => {
|
|
51
|
+
pill.classList.remove("pb_dropdown_drop_before", "pb_dropdown_drop_after");
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const applyDropLine = (pills, target) => {
|
|
56
|
+
clearDropLines(pills);
|
|
57
|
+
if (!target) return;
|
|
58
|
+
pills[target.index]?.classList.add(
|
|
59
|
+
target.after ? "pb_dropdown_drop_after" : "pb_dropdown_drop_before",
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const focusPillInItem = (item) => {
|
|
64
|
+
const pill = item?.querySelector(PILL_FOCUS_SELECTOR);
|
|
65
|
+
if (pill instanceof HTMLElement) {
|
|
66
|
+
pill.focus({ preventScroll: true });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const getClientPoint = (event) => {
|
|
71
|
+
if (event.touches?.[0]) {
|
|
72
|
+
return { x: event.touches[0].clientX, y: event.touches[0].clientY };
|
|
73
|
+
}
|
|
74
|
+
if (event.changedTouches?.[0]) {
|
|
75
|
+
return { x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY };
|
|
76
|
+
}
|
|
77
|
+
return { x: event.clientX, y: event.clientY };
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Bind pointer-drag reordering for multi-select pills (mouse + touch).
|
|
82
|
+
* @returns {() => void} cleanup
|
|
83
|
+
*/
|
|
84
|
+
export const bindPillReorder = ({
|
|
85
|
+
container,
|
|
86
|
+
getOrderedIds,
|
|
87
|
+
onReorder,
|
|
88
|
+
externalDragHandle = false,
|
|
89
|
+
}) => {
|
|
90
|
+
if (!container) return () => undefined;
|
|
91
|
+
|
|
92
|
+
ensurePointerTracking();
|
|
93
|
+
|
|
94
|
+
let pendingReorder = null;
|
|
95
|
+
let activeItem = null;
|
|
96
|
+
let ghost = null;
|
|
97
|
+
let dragId = null;
|
|
98
|
+
let startX = 0;
|
|
99
|
+
let startY = 0;
|
|
100
|
+
let dragging = false;
|
|
101
|
+
const cleanups = [];
|
|
102
|
+
|
|
103
|
+
const removeGhost = () => {
|
|
104
|
+
ghost?.remove();
|
|
105
|
+
ghost = null;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const endDrag = () => {
|
|
109
|
+
const pills = Array.from(container.querySelectorAll(".pb_draggable_item"));
|
|
110
|
+
clearDropLines(pills);
|
|
111
|
+
container.classList.remove("active");
|
|
112
|
+
activeItem?.classList.remove("is_dragging");
|
|
113
|
+
removeGhost();
|
|
114
|
+
|
|
115
|
+
if (pendingReorder) {
|
|
116
|
+
onReorder(pendingReorder);
|
|
117
|
+
pendingReorder = null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
activeItem = null;
|
|
121
|
+
dragId = null;
|
|
122
|
+
dragging = false;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const updatePointer = (x, y) => {
|
|
126
|
+
if (!dragging || !activeItem || !ghost) return;
|
|
127
|
+
|
|
128
|
+
const pills = Array.from(container.querySelectorAll(".pb_draggable_item"));
|
|
129
|
+
const orderedIds = getOrderedIds();
|
|
130
|
+
const sourceIndex = orderedIds.indexOf(dragId);
|
|
131
|
+
if (sourceIndex < 0) return;
|
|
132
|
+
|
|
133
|
+
const originX = parseFloat(ghost.dataset.originX || "0");
|
|
134
|
+
const originY = parseFloat(ghost.dataset.originY || "0");
|
|
135
|
+
ghost.style.translate = `${x - originX}px ${y - originY}px`;
|
|
136
|
+
|
|
137
|
+
const target = getDropTarget(pills, x, y);
|
|
138
|
+
const targetSlot = target ? target.index + Number(target.after) : -1;
|
|
139
|
+
const isCurrentPosition = targetSlot === sourceIndex || targetSlot === sourceIndex + 1;
|
|
140
|
+
|
|
141
|
+
if (!target || isCurrentPosition) {
|
|
142
|
+
pendingReorder = null;
|
|
143
|
+
clearDropLines(pills);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const reordered = orderedIds.filter((id) => id !== dragId);
|
|
148
|
+
reordered.splice(targetSlot > sourceIndex ? targetSlot - 1 : targetSlot, 0, dragId);
|
|
149
|
+
pendingReorder = reordered;
|
|
150
|
+
applyDropLine(pills, target);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const startDrag = (item, clientX, clientY) => {
|
|
154
|
+
dragging = true;
|
|
155
|
+
activeItem = item;
|
|
156
|
+
dragId = item.getAttribute("data-pb-drag-id");
|
|
157
|
+
pendingReorder = null;
|
|
158
|
+
container.classList.add("active");
|
|
159
|
+
item.classList.add("is_dragging");
|
|
160
|
+
|
|
161
|
+
const sourceRect = item.getBoundingClientRect();
|
|
162
|
+
ghost = item.cloneNode(true);
|
|
163
|
+
ghost.className = "pb_dropdown_pill_drag_preview";
|
|
164
|
+
ghost.setAttribute("inert", "");
|
|
165
|
+
ghost.style.left = `${sourceRect.left}px`;
|
|
166
|
+
ghost.style.top = `${sourceRect.top}px`;
|
|
167
|
+
ghost.style.width = `${sourceRect.width}px`;
|
|
168
|
+
ghost.dataset.originX = String(sourceRect.left + sourceRect.width / 2);
|
|
169
|
+
ghost.dataset.originY = String(sourceRect.top + sourceRect.height / 2);
|
|
170
|
+
document.body.appendChild(ghost);
|
|
171
|
+
|
|
172
|
+
updatePointer(clientX, clientY);
|
|
173
|
+
if (lastPointer) updatePointer(lastPointer.x, lastPointer.y);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const shouldIgnorePointerDown = (event) => {
|
|
177
|
+
const item = event.target.closest(".pb_draggable_item");
|
|
178
|
+
if (!item || !container.contains(item)) return true;
|
|
179
|
+
if (event.target.closest(CLOSE_SELECTOR)) return true;
|
|
180
|
+
if (externalDragHandle && !event.target.closest(DRAG_HANDLE_SELECTOR)) return true;
|
|
181
|
+
return false;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const beginPointerGesture = (item, clientX, clientY) => {
|
|
185
|
+
// Do not preventDefault here — that would block click-to-focus for keyboard reorder.
|
|
186
|
+
// stopPropagation still keeps the Dropdown trigger from toggling.
|
|
187
|
+
activeItem = item;
|
|
188
|
+
dragId = item.getAttribute("data-pb-drag-id");
|
|
189
|
+
startX = clientX;
|
|
190
|
+
startY = clientY;
|
|
191
|
+
dragging = false;
|
|
192
|
+
pendingReorder = null;
|
|
193
|
+
focusPillInItem(item);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const movePointerGesture = (clientX, clientY, event) => {
|
|
197
|
+
if (!activeItem) return false;
|
|
198
|
+
|
|
199
|
+
if (!dragging) {
|
|
200
|
+
const deltaX = clientX - startX;
|
|
201
|
+
const deltaY = clientY - startY;
|
|
202
|
+
if (Math.hypot(deltaX, deltaY) < DRAG_THRESHOLD_PX) return false;
|
|
203
|
+
startDrag(activeItem, clientX, clientY);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
updatePointer(clientX, clientY);
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
return true;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const handleMouseMove = (event) => {
|
|
212
|
+
movePointerGesture(event.clientX, event.clientY, event);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const handleMouseUp = () => {
|
|
216
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
217
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
218
|
+
endDrag();
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const handleMouseDown = (event) => {
|
|
222
|
+
if (event.button !== 0) return;
|
|
223
|
+
if (shouldIgnorePointerDown(event)) return;
|
|
224
|
+
|
|
225
|
+
const item = event.target.closest(".pb_draggable_item");
|
|
226
|
+
event.stopPropagation();
|
|
227
|
+
beginPointerGesture(item, event.clientX, event.clientY);
|
|
228
|
+
|
|
229
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
230
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const handleTouchMove = (event) => {
|
|
234
|
+
const touch = event.touches[0];
|
|
235
|
+
if (!touch) return;
|
|
236
|
+
movePointerGesture(touch.clientX, touch.clientY, event);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const handleTouchEnd = (event) => {
|
|
240
|
+
document.removeEventListener("touchmove", handleTouchMove);
|
|
241
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
242
|
+
document.removeEventListener("touchcancel", handleTouchEnd);
|
|
243
|
+
|
|
244
|
+
const point = getClientPoint(event);
|
|
245
|
+
if (dragging) updatePointer(point.x, point.y);
|
|
246
|
+
endDrag();
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const handleTouchStart = (event) => {
|
|
250
|
+
if (shouldIgnorePointerDown(event)) return;
|
|
251
|
+
|
|
252
|
+
const touch = event.touches[0];
|
|
253
|
+
if (!touch) return;
|
|
254
|
+
|
|
255
|
+
const item = event.target.closest(".pb_draggable_item");
|
|
256
|
+
event.stopPropagation();
|
|
257
|
+
beginPointerGesture(item, touch.clientX, touch.clientY);
|
|
258
|
+
|
|
259
|
+
// Non-passive so we can prevent page scroll once the drag threshold is crossed
|
|
260
|
+
document.addEventListener("touchmove", handleTouchMove, { passive: false });
|
|
261
|
+
document.addEventListener("touchend", handleTouchEnd);
|
|
262
|
+
document.addEventListener("touchcancel", handleTouchEnd);
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
container.addEventListener("mousedown", handleMouseDown);
|
|
266
|
+
container.addEventListener("touchstart", handleTouchStart, { passive: true });
|
|
267
|
+
cleanups.push(() => {
|
|
268
|
+
container.removeEventListener("mousedown", handleMouseDown);
|
|
269
|
+
container.removeEventListener("touchstart", handleTouchStart);
|
|
270
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
271
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
272
|
+
document.removeEventListener("touchmove", handleTouchMove);
|
|
273
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
274
|
+
document.removeEventListener("touchcancel", handleTouchEnd);
|
|
275
|
+
removeGhost();
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
return () => {
|
|
279
|
+
cleanups.forEach((cleanup) => cleanup());
|
|
280
|
+
};
|
|
281
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { setQuickPickDateOnPicker } from './quickpickDateSync'
|
|
2
|
+
|
|
3
|
+
describe('Quickpick DatePicker synchronization', () => {
|
|
4
|
+
test('date-only pickers retain their formatted string submission', () => {
|
|
5
|
+
const picker = { config: { enableTime: false }, setDate: jest.fn() }
|
|
6
|
+
setQuickPickDateOnPicker(picker, '10/21/2026', 'end')
|
|
7
|
+
expect(picker.setDate).toHaveBeenCalledWith('10/21/2026', true, 'm/d/Y')
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
test.each([
|
|
11
|
+
['start', 0, 0],
|
|
12
|
+
['end', 23, 59],
|
|
13
|
+
] as const)('timed pickers use the %s boundary for date-only values', (bound, hours, minutes) => {
|
|
14
|
+
const picker = { config: { enableTime: true }, setDate: jest.fn() }
|
|
15
|
+
setQuickPickDateOnPicker(picker, '10/21/2026', bound)
|
|
16
|
+
expect(picker.setDate).toHaveBeenCalledWith(new Date(2026, 9, 21, hours, minutes), true)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('explicit custom times are preserved for the end boundary', () => {
|
|
20
|
+
const picker = { config: { enableTime: true }, setDate: jest.fn() }
|
|
21
|
+
setQuickPickDateOnPicker(picker, '10/21/2026 2:30 PM', 'end')
|
|
22
|
+
expect(picker.setDate).toHaveBeenCalledWith(new Date(2026, 9, 21, 14, 30), true)
|
|
23
|
+
})
|
|
24
|
+
})
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { GenericObject } from '../../types'
|
|
4
|
+
|
|
5
|
+
export type PillDropTarget = {
|
|
6
|
+
after: boolean
|
|
7
|
+
index: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Vertical reach (px) above/below a pill row that still targets a drop position in that row.
|
|
11
|
+
const ROW_TOLERANCE = 80
|
|
12
|
+
|
|
13
|
+
let lastPointer: { x: number, y: number } | null = null
|
|
14
|
+
let pointerTrackingInstalled = false
|
|
15
|
+
|
|
16
|
+
const ensurePointerTracking = () => {
|
|
17
|
+
if (pointerTrackingInstalled || typeof document === 'undefined') return
|
|
18
|
+
pointerTrackingInstalled = true
|
|
19
|
+
|
|
20
|
+
document.addEventListener('mousemove', (event: MouseEvent) => {
|
|
21
|
+
if (event.buttons === 0) return
|
|
22
|
+
lastPointer = { x: event.clientX, y: event.clientY }
|
|
23
|
+
}, true)
|
|
24
|
+
|
|
25
|
+
document.addEventListener('touchmove', (event: TouchEvent) => {
|
|
26
|
+
const touch = event.touches[0]
|
|
27
|
+
if (touch) lastPointer = { x: touch.clientX, y: touch.clientY }
|
|
28
|
+
}, { capture: true, passive: true })
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const getVerticalDistance = (rect: DOMRect, y: number): number => (
|
|
32
|
+
Math.max(rect.top - y, y - rect.bottom, 0)
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const getDropTarget = (pills: Element[], x: number, y: number): PillDropTarget | null => {
|
|
36
|
+
if (pills.length === 0) return null
|
|
37
|
+
|
|
38
|
+
const rects = pills.map((pill) => pill.getBoundingClientRect())
|
|
39
|
+
const nearestRect = rects.reduce((nearest, rect) => (
|
|
40
|
+
getVerticalDistance(rect, y) < getVerticalDistance(nearest, y) ? rect : nearest
|
|
41
|
+
))
|
|
42
|
+
if (getVerticalDistance(nearestRect, y) > ROW_TOLERANCE) return null
|
|
43
|
+
|
|
44
|
+
const rowIndexes = rects
|
|
45
|
+
.map((rect, index) => ({ index, rect }))
|
|
46
|
+
.filter(({ rect }) => rect.top < nearestRect.bottom && rect.bottom > nearestRect.top)
|
|
47
|
+
.map(({ index }) => index)
|
|
48
|
+
|
|
49
|
+
const pillAfterPointer = rowIndexes.find((index) => x < rects[index].left + rects[index].width / 2)
|
|
50
|
+
if (pillAfterPointer !== undefined) {
|
|
51
|
+
return { after: false, index: pillAfterPointer }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { after: true, index: rowIndexes[rowIndexes.length - 1] }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const usePillDropIndicator = (
|
|
58
|
+
dragId: string,
|
|
59
|
+
value: GenericObject[],
|
|
60
|
+
getItemId: (item: GenericObject) => string,
|
|
61
|
+
pendingReorderRef: React.MutableRefObject<GenericObject[] | null>,
|
|
62
|
+
containerSelector = '.pb_dropdown_draggable_pills',
|
|
63
|
+
): PillDropTarget | null => {
|
|
64
|
+
const [dropTarget, setDropTarget] = useState<PillDropTarget | null>(null)
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
ensurePointerTracking()
|
|
68
|
+
}, [])
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const source = document.querySelector<HTMLElement>(`${containerSelector} .is_dragging`)
|
|
72
|
+
if (!dragId || !source?.parentElement) return undefined
|
|
73
|
+
|
|
74
|
+
const pills = Array.from(source.parentElement.children)
|
|
75
|
+
const sourceIndex = value.findIndex((item) => getItemId(item) === dragId)
|
|
76
|
+
if (sourceIndex < 0 || pills.length === 0) return undefined
|
|
77
|
+
|
|
78
|
+
const sourceRect = source.getBoundingClientRect()
|
|
79
|
+
|
|
80
|
+
const ghost = source.cloneNode(true) as HTMLElement
|
|
81
|
+
ghost.className = 'pb_dropdown_pill_drag_preview'
|
|
82
|
+
ghost.setAttribute('inert', '')
|
|
83
|
+
ghost.style.left = `${sourceRect.left}px`
|
|
84
|
+
ghost.style.top = `${sourceRect.top}px`
|
|
85
|
+
ghost.style.width = `${sourceRect.width}px`
|
|
86
|
+
document.body.appendChild(ghost)
|
|
87
|
+
|
|
88
|
+
const pointerOrigin = {
|
|
89
|
+
x: sourceRect.left + sourceRect.width / 2,
|
|
90
|
+
y: sourceRect.top + sourceRect.height / 2,
|
|
91
|
+
}
|
|
92
|
+
pendingReorderRef.current = null
|
|
93
|
+
|
|
94
|
+
const handlePointerMove = (x: number, y: number) => {
|
|
95
|
+
ghost.style.translate = `${x - pointerOrigin.x}px ${y - pointerOrigin.y}px`
|
|
96
|
+
|
|
97
|
+
const target = getDropTarget(pills, x, y)
|
|
98
|
+
const targetSlot = target ? target.index + Number(target.after) : -1
|
|
99
|
+
const isCurrentPosition = targetSlot === sourceIndex || targetSlot === sourceIndex + 1
|
|
100
|
+
|
|
101
|
+
if (!target || isCurrentPosition) {
|
|
102
|
+
pendingReorderRef.current = null
|
|
103
|
+
setDropTarget(null)
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const reordered = value.filter((item) => getItemId(item) !== dragId)
|
|
108
|
+
reordered.splice(targetSlot > sourceIndex ? targetSlot - 1 : targetSlot, 0, value[sourceIndex])
|
|
109
|
+
pendingReorderRef.current = reordered
|
|
110
|
+
|
|
111
|
+
setDropTarget((current) => {
|
|
112
|
+
const isSameTarget = current?.index === target.index && current.after === target.after
|
|
113
|
+
return isSameTarget ? current : target
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const handleMouseMove = (event: MouseEvent) => {
|
|
118
|
+
handlePointerMove(event.clientX, event.clientY)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const handleTouchMove = (event: TouchEvent) => {
|
|
122
|
+
const touch = event.touches[0]
|
|
123
|
+
if (touch) handlePointerMove(touch.clientX, touch.clientY)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
document.addEventListener('mousemove', handleMouseMove)
|
|
127
|
+
document.addEventListener('touchmove', handleTouchMove, { passive: true })
|
|
128
|
+
|
|
129
|
+
if (lastPointer) {
|
|
130
|
+
handlePointerMove(lastPointer.x, lastPointer.y)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return () => {
|
|
134
|
+
document.removeEventListener('mousemove', handleMouseMove)
|
|
135
|
+
document.removeEventListener('touchmove', handleTouchMove)
|
|
136
|
+
ghost.remove()
|
|
137
|
+
setDropTarget(null)
|
|
138
|
+
}
|
|
139
|
+
}, [containerSelector, dragId, getItemId, pendingReorderRef, value])
|
|
140
|
+
|
|
141
|
+
return dropTarget
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export default usePillDropIndicator
|
|
@@ -48,18 +48,23 @@ export type SortMenuProps = {
|
|
|
48
48
|
}
|
|
49
49
|
const SortMenu = ({ dark, options, value, onChange }: SortMenuProps): React.ReactElement => {
|
|
50
50
|
const [hide, updateHide] = useState(true)
|
|
51
|
+
const optionNames = options ? Object.keys(options) : []
|
|
52
|
+
const singleOptionName = optionNames.length === 1 ? optionNames[0] : undefined
|
|
51
53
|
const toggle = () => updateHide(!hide)
|
|
52
54
|
const handleChange = (value: SortValue) => {
|
|
53
55
|
updateHide(true)
|
|
54
56
|
onChange([value])
|
|
55
57
|
}
|
|
58
|
+
const handleClick = singleOptionName
|
|
59
|
+
? () => onChange([nextValue(value || [], singleOptionName)])
|
|
60
|
+
: toggle
|
|
56
61
|
|
|
57
62
|
const sortButton = (
|
|
58
63
|
<Button
|
|
59
64
|
dark={dark}
|
|
60
65
|
htmlType={undefined}
|
|
61
66
|
id="sort-button"
|
|
62
|
-
onClick={
|
|
67
|
+
onClick={handleClick}
|
|
63
68
|
paddingRight="none"
|
|
64
69
|
variant="link"
|
|
65
70
|
>
|
|
@@ -75,6 +80,8 @@ const SortMenu = ({ dark, options, value, onChange }: SortMenuProps): React.Reac
|
|
|
75
80
|
</Button>
|
|
76
81
|
)
|
|
77
82
|
|
|
83
|
+
if (singleOptionName) return sortButton
|
|
84
|
+
|
|
78
85
|
return (
|
|
79
86
|
<PbReactPopover
|
|
80
87
|
className="pb_filter_sort_menu"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<%=
|
|
2
|
+
pb_rails("filter", props: {
|
|
3
|
+
min_width: "360px",
|
|
4
|
+
id: "one-click",
|
|
5
|
+
filters: [
|
|
6
|
+
{ name: "name", value: "John Wick" }
|
|
7
|
+
],
|
|
8
|
+
sort_menu: [
|
|
9
|
+
{ item: "Popularity", link: "?q[sorts]=managers_popularity+asc", active: true, direction: "desc" },
|
|
10
|
+
],
|
|
11
|
+
results: 546,
|
|
12
|
+
template: "single"
|
|
13
|
+
}) do
|
|
14
|
+
%>
|
|
15
|
+
<%
|
|
16
|
+
example_collection = [
|
|
17
|
+
OpenStruct.new(name: "USA", value: 1),
|
|
18
|
+
OpenStruct.new(name: "Canada", value: 2),
|
|
19
|
+
OpenStruct.new(name: "Brazil", value: 3),
|
|
20
|
+
OpenStruct.new(name: "Philippines", value: 4),
|
|
21
|
+
OpenStruct.new(name: "A galaxy far far away...", value: 5)
|
|
22
|
+
]
|
|
23
|
+
%>
|
|
24
|
+
|
|
25
|
+
<%= pb_rails("form", props: { form_system_options: { scope: :example, method: :get } }) do |form| %>
|
|
26
|
+
<%= form.text_field :example_text_field, props: { label: true } %>
|
|
27
|
+
<%= form.collection_select :example_collection_select, example_collection, :value, :name, props: { label: true } %>
|
|
28
|
+
|
|
29
|
+
<%= form.actions do |action| %>
|
|
30
|
+
<%= action.submit props: {
|
|
31
|
+
text: "Apply",
|
|
32
|
+
data: {
|
|
33
|
+
disable_with: "pb_rails('icon', props: { icon: 'spinner', spin: true, fixed_width: true })Searching...".html_safe
|
|
34
|
+
},}%>
|
|
35
|
+
<%= action.button props: { type: "reset", text: "Clear", variant: "secondary" } %>
|
|
36
|
+
<% end %>
|
|
37
|
+
<% end %>
|
|
38
|
+
<% end %>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import Button from '../../pb_button/_button'
|
|
4
|
+
import Filter from '../../pb_filter/_filter'
|
|
5
|
+
import Flex from '../../pb_flex/_flex'
|
|
6
|
+
import Select from '../../pb_select/_select'
|
|
7
|
+
import TextInput from '../../pb_text_input/_text_input'
|
|
8
|
+
|
|
9
|
+
const FilterOneClick = (props) => {
|
|
10
|
+
const [sortValue, setSortValue] = useState([{ name: 'popularity', dir: 'desc' }])
|
|
11
|
+
const options = [
|
|
12
|
+
{ value: 'USA' },
|
|
13
|
+
{ value: 'Canada' },
|
|
14
|
+
{ value: 'Brazil' },
|
|
15
|
+
{ value: 'Philippines' },
|
|
16
|
+
{ value: 'A galaxy far far away...' },
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Filter
|
|
21
|
+
filters={{
|
|
22
|
+
'Full Name': 'John Wick',
|
|
23
|
+
}}
|
|
24
|
+
minWidth="360px"
|
|
25
|
+
onSortChange={setSortValue}
|
|
26
|
+
results={546}
|
|
27
|
+
sortOptions={{
|
|
28
|
+
popularity: 'Popularity',
|
|
29
|
+
}}
|
|
30
|
+
sortValue={sortValue}
|
|
31
|
+
{...props}
|
|
32
|
+
>
|
|
33
|
+
{({ closePopover }) => (
|
|
34
|
+
<form>
|
|
35
|
+
<TextInput
|
|
36
|
+
label="Full Name"
|
|
37
|
+
placeholder="Enter name"
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
<Select
|
|
42
|
+
blankSelection="Select One..."
|
|
43
|
+
label="Territory"
|
|
44
|
+
name="location"
|
|
45
|
+
options={options}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
<Flex
|
|
49
|
+
spacing="between"
|
|
50
|
+
{...props}
|
|
51
|
+
>
|
|
52
|
+
<Button
|
|
53
|
+
onClick={closePopover}
|
|
54
|
+
text="Apply"
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
<Button
|
|
58
|
+
text="Clear"
|
|
59
|
+
variant="secondary"
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
</Flex>
|
|
63
|
+
</form>
|
|
64
|
+
)}
|
|
65
|
+
</Filter>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default FilterOneClick
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
When `sortOptions` / `sort_menu` only has one option, the sort button toggles that option (the sorting popover does not open).
|
|
@@ -7,6 +7,7 @@ examples:
|
|
|
7
7
|
- filter_no_sort: No Sort
|
|
8
8
|
- filter_only: Filter Only
|
|
9
9
|
- sort_only: Sort Only
|
|
10
|
+
- filter_one_click: One Click Sort
|
|
10
11
|
- filter_max_width: Max Width for Popover Inside of Filter
|
|
11
12
|
- filter_max_height: Max Height for Popover Inside of Filter
|
|
12
13
|
- filter_placement: Filter Placement
|
|
@@ -22,6 +23,7 @@ examples:
|
|
|
22
23
|
- filter_no_sort: No Sort
|
|
23
24
|
- filter_only: Filter Only
|
|
24
25
|
- sort_only: Sort Only
|
|
26
|
+
- filter_one_click: One Click Sort
|
|
25
27
|
- filter_max_width: Max Width for Popover Inside of Filter
|
|
26
28
|
- filter_max_height: Max Height for Popover Inside of Filter
|
|
27
29
|
- filter_placement: Filter Placement
|
|
@@ -10,4 +10,5 @@ export { default as FilterPlacement } from './_filter_placement.jsx'
|
|
|
10
10
|
export { default as FilterPopoverProps } from './_filter_popover_props.jsx'
|
|
11
11
|
export { default as FilterResponsive } from './_filter_responsive.jsx'
|
|
12
12
|
export { default as FilterSidebar } from './_filter_sidebar.jsx'
|
|
13
|
-
export { default as FilterInteractiveReact } from './_filter_interactive_react.jsx'
|
|
13
|
+
export { default as FilterInteractiveReact } from './_filter_interactive_react.jsx'
|
|
14
|
+
export { default as FilterOneClick } from './_filter_one_click.jsx'
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
<div class="pb_filter_responsive_sort">
|
|
131
131
|
<%= pb_rails("caption", props: { text: "sort by:", classname: "pb_filter_responsive_sort_label"}) %>
|
|
132
132
|
<% unless object.sort_menu == [{}] %>
|
|
133
|
-
<%= pb_rails("button", props:
|
|
133
|
+
<%= pb_rails("button", props: object.sort_button_props) do %>
|
|
134
134
|
<% object.sort_menu.each do |item| %>
|
|
135
135
|
<% if item[:active] == true %>
|
|
136
136
|
<%= item[:item] %>
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
|
|
154
154
|
<% if (object.template == "single" ) || (object.template == "sort_only") %>
|
|
155
155
|
<% unless object.sort_menu == [{}] %>
|
|
156
|
-
<%= pb_rails("button", props:
|
|
156
|
+
<%= pb_rails("button", props: object.sort_button_props) do %>
|
|
157
157
|
<% object.sort_menu.each do |item| %>
|
|
158
158
|
<% if item[:active] == true %>
|
|
159
159
|
<%= item[:item] %>
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
<%= pb_rails("title_count", props: {title: "Results:",count: object.results, align:"center"}) %>
|
|
172
172
|
<%= pb_rails("flex", props: {orientation: "row", vertical: "center"}) do %>
|
|
173
173
|
<%= pb_rails("caption", props: { text: "sort by:"}) %>
|
|
174
|
-
<%= pb_rails("button", props:
|
|
174
|
+
<%= pb_rails("button", props: object.sort_button_props) do %>
|
|
175
175
|
<% object.sort_menu.each do |item| %>
|
|
176
176
|
<% if item[:active] == true %>
|
|
177
177
|
<%= item[:item] %>
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
<% end %>
|
|
192
192
|
<%end%>
|
|
193
193
|
|
|
194
|
-
<% if object.template != "filter_only"%>
|
|
194
|
+
<% if object.template != "filter_only" && !object.single_sort_option? %>
|
|
195
195
|
<%= pb_rails("popover", props: {max_height: object.max_height, classname: "pb_filter_sort_menu", close_on_click: "outside", trigger_element_id: "sort-button#{object.id}", tooltip_id: "sort-filter-btn-tooltip#{object.id}", position: object.placement , padding: 'none'}.merge(object.popover_props)) do %>
|
|
196
196
|
<%= pb_rails("list") do %>
|
|
197
197
|
<% object.sort_menu.each do |item| %>
|