playbook_ui 15.7.0.pre.rc.2 → 15.7.0.pre.rc.3
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_date_picker/date_picker_helper.ts +16 -4
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern_rails.html.erb +23 -14
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern_rails.md +1 -1
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_overflow_visible.html.erb +71 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_overflow_visible.jsx +57 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_overflow_visible_rails.md +1 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_overflow_visible_react.md +1 -0
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_rails.html.erb +7 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.html.erb +19 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_rails.html.erb +12 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_rails.md +26 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end_rails.html.erb +19 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end_rails.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_default_rails.html.erb +30 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_default_rails.md +3 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_rails.html.erb +29 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_rails.md +13 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.html.erb +3 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +5 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +4 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +39 -5
- data/app/pb_kits/playbook/pb_dropdown/index.js +171 -3
- data/app/pb_kits/playbook/pb_dropdown/quickpick_helper.rb +75 -0
- data/dist/chunks/{_typeahead-CHwm9MTE.js → _typeahead-CbjBmIDu.js} +1 -1
- data/dist/chunks/{lib-Cugvy62C.js → lib-DxDBrGZX.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9a9291f49ac045055567a7467e7a215ceb588218f8f3d6779088848340964ee3
|
|
4
|
+
data.tar.gz: cc09327d3bc4ba91c31f73bea082ad8051c6ab26784ef19f461ec1c0caf62924
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ddb268ad685b64e4fbdf64bc3d2d20eaae16a6e31f0fa9d095abd53d01c82ed3eaad51022cbf81172fcebd3b259e91b83aacf5fc52ae61f5a2d2f2da92d2aa88
|
|
7
|
+
data.tar.gz: ce7b1b023da1876a66aa654a928bc1d0dff129f0f32b01b3d80dc73ce5b652a8d3002a2f4782f70588993649d709d7b2eb1ae4cf3839eb2fb04eabb5bd0b7d46
|
|
@@ -570,10 +570,16 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
570
570
|
picker.config.onClose.push((selectedDates: string) => {
|
|
571
571
|
if (selectedDates?.length) {
|
|
572
572
|
const element = document.querySelector(`#${syncStartWith}`) as any;
|
|
573
|
-
// Check if it's a Dropdown
|
|
573
|
+
// Check if it's a React Dropdown (has _dropdownRef)
|
|
574
574
|
if (element?._dropdownRef?.current) {
|
|
575
575
|
element._dropdownRef.current.clearSelected();
|
|
576
|
-
}
|
|
576
|
+
}
|
|
577
|
+
// Check if it's a Rails Dropdown (has _pbDropdownInstance)
|
|
578
|
+
else if (element?._pbDropdownInstance) {
|
|
579
|
+
element._pbDropdownInstance.clearSelected();
|
|
580
|
+
}
|
|
581
|
+
// Check if it's a DatePicker QuickPick (has _flatpickr)
|
|
582
|
+
else {
|
|
577
583
|
const quickpick = element?._flatpickr;
|
|
578
584
|
quickpick?.clear();
|
|
579
585
|
}
|
|
@@ -586,10 +592,16 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
586
592
|
picker.config.onClose.push((selectedDates: string) => {
|
|
587
593
|
if (selectedDates?.length) {
|
|
588
594
|
const element = document.querySelector(`#${syncEndWith}`) as any;
|
|
589
|
-
// Check if it's a Dropdown
|
|
595
|
+
// Check if it's a React Dropdown (has _dropdownRef)
|
|
590
596
|
if (element?._dropdownRef?.current) {
|
|
591
597
|
element._dropdownRef.current.clearSelected();
|
|
592
|
-
}
|
|
598
|
+
}
|
|
599
|
+
// Check if it's a Rails Dropdown (has _pbDropdownInstance)
|
|
600
|
+
else if (element?._pbDropdownInstance) {
|
|
601
|
+
element._pbDropdownInstance.clearSelected();
|
|
602
|
+
}
|
|
603
|
+
// Check if it's a DatePicker QuickPick (has _flatpickr)
|
|
604
|
+
else {
|
|
593
605
|
const quickpick = element?._flatpickr;
|
|
594
606
|
quickpick?.clear();
|
|
595
607
|
}
|
|
@@ -1,20 +1,29 @@
|
|
|
1
|
-
<%= pb_rails("
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
controls_start_id: "
|
|
1
|
+
<%= pb_rails("dropdown", props: {
|
|
2
|
+
id: "dropdown-quickpick-with-date-pickers-1",
|
|
3
|
+
label: "Date Range",
|
|
4
|
+
name: "date_range",
|
|
5
|
+
margin_bottom: "sm",
|
|
6
|
+
variant: "quickpick",
|
|
7
|
+
controls_start_id: "start-date-picker-1",
|
|
8
|
+
controls_end_id: "end-date-picker-1",
|
|
9
|
+
start_date_id: "quickpick_start_date_1",
|
|
10
|
+
start_date_name: "start_date",
|
|
11
|
+
end_date_id: "quickpick_end_date_1",
|
|
12
|
+
end_date_name: "end_date"
|
|
8
13
|
}) %>
|
|
9
14
|
|
|
10
15
|
<%= pb_rails("date_picker", props: {
|
|
11
|
-
picker_id: "
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
picker_id: "start-date-picker-1",
|
|
17
|
+
label: "Start Date",
|
|
18
|
+
name: "start_date_picker",
|
|
19
|
+
placeholder: "Select Start Date",
|
|
20
|
+
sync_start_with: "dropdown-quickpick-with-date-pickers-1"
|
|
14
21
|
}) %>
|
|
15
22
|
|
|
16
23
|
<%= pb_rails("date_picker", props: {
|
|
17
|
-
picker_id: "
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
picker_id: "end-date-picker-1",
|
|
25
|
+
label: "End Date",
|
|
26
|
+
name: "end_date_picker",
|
|
27
|
+
placeholder: "Select End Date",
|
|
28
|
+
sync_end_with: "dropdown-quickpick-with-date-pickers-1"
|
|
29
|
+
}) %>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
You can link a Quickpick
|
|
1
|
+
You can link a Quickpick Dropdown to standard DatePickers using the following props:
|
|
2
2
|
|
|
3
3
|
**For the Quickpick DatePicker**:
|
|
4
4
|
`controls_start_id`: ID of the DatePicker that should receive the start date.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<%
|
|
2
|
+
typeahead_options = [
|
|
3
|
+
{
|
|
4
|
+
label: "United States",
|
|
5
|
+
value: "unitedStates",
|
|
6
|
+
id: "us"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
label: "United Kingdom",
|
|
10
|
+
value: "unitedKingdom",
|
|
11
|
+
id: "gb"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: "Canada",
|
|
15
|
+
value: "canada",
|
|
16
|
+
id: "ca"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: "Australia",
|
|
20
|
+
value: "australia",
|
|
21
|
+
id: "au"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: "Germany",
|
|
25
|
+
value: "germany",
|
|
26
|
+
id: "de"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: "France",
|
|
30
|
+
value: "france",
|
|
31
|
+
id: "fr"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: "Japan",
|
|
35
|
+
value: "japan",
|
|
36
|
+
id: "jp"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "Brazil",
|
|
40
|
+
value: "brazil",
|
|
41
|
+
id: "br"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
%>
|
|
45
|
+
|
|
46
|
+
<%= pb_rails("button", props: { text: "Open Dialog with Overflow Visible", data: {"open-dialog": "dialog-overflow-visible"} }) %>
|
|
47
|
+
|
|
48
|
+
<%= pb_rails("dialog", props: {
|
|
49
|
+
id: "dialog-overflow-visible",
|
|
50
|
+
size: "md",
|
|
51
|
+
overflow: "visible"
|
|
52
|
+
}) do %>
|
|
53
|
+
<%= pb_rails("dialog/dialog_header", props: { id: "dialog-overflow-visible" } ) do %>
|
|
54
|
+
<%= pb_rails("body", props: { text: "Select Location" }) %>
|
|
55
|
+
<% end %>
|
|
56
|
+
<%= pb_rails("dialog/dialog_body") do %>
|
|
57
|
+
<%= pb_rails("typeahead", props: {
|
|
58
|
+
options: typeahead_options,
|
|
59
|
+
placeholder: "Select a location...",
|
|
60
|
+
id: "location-typeahead",
|
|
61
|
+
is_multi: false,
|
|
62
|
+
}) %>
|
|
63
|
+
<% end %>
|
|
64
|
+
<%= pb_rails("dialog/dialog_footer", props: {
|
|
65
|
+
cancel_button: "Cancel",
|
|
66
|
+
confirm_button: "Save",
|
|
67
|
+
confirm_button_id: "confirm-overflow-visible",
|
|
68
|
+
id: "dialog-overflow-visible"
|
|
69
|
+
}) %>
|
|
70
|
+
<% end %>
|
|
71
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import Body from '../../pb_body/_body'
|
|
4
|
+
import Button from '../../pb_button/_button'
|
|
5
|
+
import Dialog from '../../pb_dialog/_dialog'
|
|
6
|
+
import Typeahead from '../../pb_typeahead/_typeahead'
|
|
7
|
+
|
|
8
|
+
const DialogOverflowVisible = () => {
|
|
9
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
10
|
+
const close = () => setIsOpen(false)
|
|
11
|
+
const open = () => setIsOpen(true)
|
|
12
|
+
|
|
13
|
+
const typeaheadOptions = [
|
|
14
|
+
{ label: "United States", value: "unitedStates", id: "us" },
|
|
15
|
+
{ label: "United Kingdom", value: "unitedKingdom", id: "gb" },
|
|
16
|
+
{ label: "Canada", value: "canada", id: "ca" },
|
|
17
|
+
{ label: "Australia", value: "australia", id: "au" },
|
|
18
|
+
{ label: "Germany", value: "germany", id: "de" },
|
|
19
|
+
{ label: "France", value: "france", id: "fr" },
|
|
20
|
+
{ label: "Japan", value: "japan", id: "jp" },
|
|
21
|
+
{ label: "Brazil", value: "brazil", id: "br" },
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<Button onClick={open}>{'Open Dialog with Overflow Visible'}</Button>
|
|
27
|
+
<Dialog
|
|
28
|
+
onClose={close}
|
|
29
|
+
opened={isOpen}
|
|
30
|
+
overflow="visible"
|
|
31
|
+
size="md"
|
|
32
|
+
>
|
|
33
|
+
<Dialog.Header>
|
|
34
|
+
<Body>{'Select Location'}</Body>
|
|
35
|
+
</Dialog.Header>
|
|
36
|
+
<Dialog.Body>
|
|
37
|
+
<Typeahead
|
|
38
|
+
options={typeaheadOptions}
|
|
39
|
+
placeholder="Select a location..."
|
|
40
|
+
/>
|
|
41
|
+
</Dialog.Body>
|
|
42
|
+
<Dialog.Footer>
|
|
43
|
+
<Button onClick={close}>{'Save'}</Button>
|
|
44
|
+
<Button
|
|
45
|
+
onClick={close}
|
|
46
|
+
variant="link"
|
|
47
|
+
>
|
|
48
|
+
{'Cancel'}
|
|
49
|
+
</Button>
|
|
50
|
+
</Dialog.Footer>
|
|
51
|
+
</Dialog>
|
|
52
|
+
</>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default DialogOverflowVisible
|
|
57
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Use the `overflow: "visible"` global prop to allow Typeahead dropdown menus to appear outside the dialog boundaries. By default, dialogs clip content that extends beyond their edges, but this prop enables pop-up elements to render above the dialog overlay.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Use the `overflow="visible"` global prop to allow Date Picker and Typeahead dropdown menus to appear outside the dialog boundaries. By default, dialogs clip content that extends beyond their edges, but this prop enables pop-up elements to render above the dialog overlay.
|
|
@@ -12,6 +12,7 @@ examples:
|
|
|
12
12
|
- dialog_full_height_placement: Full Height Placement
|
|
13
13
|
- dialog_loading: Loading
|
|
14
14
|
- dialog_turbo_frames: Within Turbo Frames
|
|
15
|
+
- dialog_overflow_visible: Overflow Visible
|
|
15
16
|
- dialog_closeable: Close Button in Header
|
|
16
17
|
|
|
17
18
|
|
|
@@ -26,6 +27,7 @@ examples:
|
|
|
26
27
|
- dialog_full_height: Full Height
|
|
27
28
|
- dialog_full_height_placement: Full Height Placement
|
|
28
29
|
- dialog_loading: Loading
|
|
30
|
+
- dialog_overflow_visible: Overflow Visible
|
|
29
31
|
- dialog_closeable: Close Button in Header
|
|
30
32
|
|
|
31
33
|
swift:
|
|
@@ -9,4 +9,5 @@ export { default as DialogStackedAlert } from './_dialog_stacked_alert.jsx'
|
|
|
9
9
|
export { default as DialogFullHeight } from './_dialog_full_height.jsx'
|
|
10
10
|
export { default as DialogFullHeightPlacement } from './_dialog_full_height_placement.jsx'
|
|
11
11
|
export { default as DialogLoading } from './_dialog_loading.jsx'
|
|
12
|
-
export { default as
|
|
12
|
+
export { default as DialogOverflowVisible } from './_dialog_overflow_visible.jsx'
|
|
13
|
+
export { default as DialogCloseable } from './_dialog_closeable.jsx'
|
|
@@ -20,12 +20,14 @@
|
|
|
20
20
|
|
|
21
21
|
%>
|
|
22
22
|
|
|
23
|
-
<%= pb_rails("dropdown", props: {options: options}) %>
|
|
23
|
+
<%= pb_rails("dropdown", props: {id: "country-dropdown", options: options}) %>
|
|
24
24
|
|
|
25
25
|
<script>
|
|
26
26
|
document.addEventListener("pb:dropdown:selected", (e) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
if (e.target.id === "country-dropdown") {
|
|
28
|
+
const option = e.detail;
|
|
29
|
+
const dropdown = e.target;
|
|
30
|
+
console.log("Selected option:", option);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
31
33
|
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
<%= pb_rails("dropdown", props: {
|
|
3
|
+
id: "date-range-with-default",
|
|
4
|
+
label: "Date Range",
|
|
5
|
+
variant: "quickpick",
|
|
6
|
+
default_value: "This Year"
|
|
7
|
+
}) %>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
11
|
+
const dropdown = document.getElementById("date-range-with-default");
|
|
12
|
+
if (dropdown) {
|
|
13
|
+
dropdown.addEventListener("pb:dropdown:selected", (e) => {
|
|
14
|
+
const option = e.detail;
|
|
15
|
+
console.log("Selected option:", option);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<%= pb_rails("dropdown", props: {id: "date-range-quickpick-1", label: "Date Range", variant: "quickpick"}) %>
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<script>
|
|
5
|
+
const dropdown = document.getElementById("date-range-quickpick-1");
|
|
6
|
+
if (dropdown) {
|
|
7
|
+
dropdown.addEventListener("pb:dropdown:selected", (e) => {
|
|
8
|
+
const option = e.detail;
|
|
9
|
+
console.log("Selected option:", option);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
The `quickpick` variant provides predefined date based options when `variant:"quickpick"` is used.
|
|
2
|
+
|
|
3
|
+
Open the Dropdown above to see the default options.
|
|
4
|
+
|
|
5
|
+
The quickpick variant automatically generates hidden inputs for `start_date` and `end_date` which are populated when a date range is selected. These inputs are ready for form submission.
|
|
6
|
+
|
|
7
|
+
You can customize the input names and IDs using the following props:
|
|
8
|
+
- `start_date_name` - The name attribute for the start date input (default: `"start_date_name"`)
|
|
9
|
+
- `start_date_id` - The ID attribute for the start date input (default: `"start_date_id"`)
|
|
10
|
+
- `end_date_name` - The name attribute for the end date input (default: `"end_date_name"`)
|
|
11
|
+
- `end_date_id` - The ID attribute for the end date input (default: `"end_date_id"`)
|
|
12
|
+
|
|
13
|
+
Example with custom names:
|
|
14
|
+
```ruby
|
|
15
|
+
pb_rails("dropdown", props: {
|
|
16
|
+
variant: "quickpick",
|
|
17
|
+
start_date_name: "filter[start_date]",
|
|
18
|
+
start_date_id: "filter_start_date",
|
|
19
|
+
end_date_name: "filter[end_date]",
|
|
20
|
+
end_date_id: "filter_end_date"
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The Dropdown kit also comes with a custom event called "pb:dropdown:selected" which updates dynamically with the selection as it changes. See code snippet to see this in action.
|
|
25
|
+
|
|
26
|
+
In addition, a data attribute called data-option-selected with the selection is also rendered on the parent dropdown div.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
<%= pb_rails("dropdown", props: {
|
|
3
|
+
id: "date-range-quickpick-end-today",
|
|
4
|
+
label: "Date Range",
|
|
5
|
+
variant: "quickpick",
|
|
6
|
+
range_ends_today: true
|
|
7
|
+
}) %>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
11
|
+
const dropdown = document.getElementById("date-range-quickpick-end-today");
|
|
12
|
+
if (dropdown) {
|
|
13
|
+
dropdown.addEventListener("pb:dropdown:selected", (e) => {
|
|
14
|
+
const option = e.detail;
|
|
15
|
+
console.log("Selected option:", option);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The optional `range_ends_today` prop can be used with the `quickpick` variant to set end date on all ranges that start with 'this' to today's date. For instance, by default 'This Year' will set end day to 12/31/(current year), but if `range_ends_today` prop is used, end date on that range will be today's date.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<%= pb_rails("dropdown", props: {
|
|
2
|
+
id: "dropdown-quickpick-with-date-pickers-default",
|
|
3
|
+
label: "Date Range",
|
|
4
|
+
name: "date_range",
|
|
5
|
+
margin_bottom: "sm",
|
|
6
|
+
variant: "quickpick",
|
|
7
|
+
default_value: "This Month",
|
|
8
|
+
controls_start_id: "start-date-picker-default",
|
|
9
|
+
controls_end_id: "end-date-picker-default",
|
|
10
|
+
start_date_id: "quickpick_start_date_default",
|
|
11
|
+
start_date_name: "start_date",
|
|
12
|
+
end_date_id: "quickpick_end_date_default",
|
|
13
|
+
end_date_name: "end_date"
|
|
14
|
+
}) %>
|
|
15
|
+
|
|
16
|
+
<%= pb_rails("date_picker", props: {
|
|
17
|
+
picker_id: "start-date-picker-default",
|
|
18
|
+
label: "Start Date",
|
|
19
|
+
name: "start_date_picker",
|
|
20
|
+
placeholder: "Select Start Date",
|
|
21
|
+
sync_start_with: "dropdown-quickpick-with-date-pickers-default"
|
|
22
|
+
}) %>
|
|
23
|
+
|
|
24
|
+
<%= pb_rails("date_picker", props: {
|
|
25
|
+
picker_id: "end-date-picker-default",
|
|
26
|
+
label: "End Date",
|
|
27
|
+
name: "end_date_picker",
|
|
28
|
+
placeholder: "Select End Date",
|
|
29
|
+
sync_end_with: "dropdown-quickpick-with-date-pickers-default"
|
|
30
|
+
}) %>
|
data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_default_rails.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
This example demonstrates the 3-input pattern with a default value. The dropdown is initialized with "This Month" selected, and both DatePickers are automatically populated with the corresponding start and end dates.
|
|
2
|
+
|
|
3
|
+
The default value can be set using the `default_value` prop with any of the quickpick option labels.
|
data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_rails.html.erb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<%= pb_rails("dropdown", props: {
|
|
2
|
+
id: "dropdown-quickpick-with-date-pickers",
|
|
3
|
+
label: "Date Range",
|
|
4
|
+
name: "date_range",
|
|
5
|
+
margin_bottom: "sm",
|
|
6
|
+
variant: "quickpick",
|
|
7
|
+
controls_start_id: "start-date-picker",
|
|
8
|
+
controls_end_id: "end-date-picker",
|
|
9
|
+
start_date_id: "quickpick_start_date",
|
|
10
|
+
start_date_name: "start_date",
|
|
11
|
+
end_date_id: "quickpick_end_date",
|
|
12
|
+
end_date_name: "end_date"
|
|
13
|
+
}) %>
|
|
14
|
+
|
|
15
|
+
<%= pb_rails("date_picker", props: {
|
|
16
|
+
picker_id: "start-date-picker",
|
|
17
|
+
label: "Start Date",
|
|
18
|
+
name: "start_date_picker",
|
|
19
|
+
placeholder: "Select Start Date",
|
|
20
|
+
sync_start_with: "dropdown-quickpick-with-date-pickers"
|
|
21
|
+
}) %>
|
|
22
|
+
|
|
23
|
+
<%= pb_rails("date_picker", props: {
|
|
24
|
+
picker_id: "end-date-picker",
|
|
25
|
+
label: "End Date",
|
|
26
|
+
name: "end_date_picker",
|
|
27
|
+
placeholder: "Select End Date",
|
|
28
|
+
sync_end_with: "dropdown-quickpick-with-date-pickers"
|
|
29
|
+
}) %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
The quickpick variant can be synced with two DatePickers for a 3-input pattern. When a quickpick option is selected from the dropdown, both DatePickers are automatically populated. When either DatePicker is manually changed, the dropdown is cleared.
|
|
2
|
+
|
|
3
|
+
#### Props for 3-Input Pattern:
|
|
4
|
+
|
|
5
|
+
- `controls_start_id` - ID of the start DatePicker to sync with
|
|
6
|
+
- `controls_end_id` - ID of the end DatePicker to sync with
|
|
7
|
+
|
|
8
|
+
#### DatePicker Props:
|
|
9
|
+
|
|
10
|
+
- `sync_start_with` - ID of the dropdown to clear when start date changes
|
|
11
|
+
- `sync_end_with` - ID of the dropdown to clear when end date changes
|
|
12
|
+
|
|
13
|
+
This pattern allows users to quickly select common date ranges or manually pick specific dates.
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
%>
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
<%= pb_rails("dropdown", props: {options: options}) do %>
|
|
50
|
+
<%= pb_rails("dropdown", props: {id: "user-dropdown", options: options}) do %>
|
|
51
51
|
<%= pb_rails("dropdown/dropdown_trigger", props: {placeholder: "Select a User", custom_display: custom_display}) %>
|
|
52
52
|
<%= pb_rails("dropdown/dropdown_container") do %>
|
|
53
53
|
<% options.each do |option| %>
|
|
@@ -71,6 +71,8 @@
|
|
|
71
71
|
|
|
72
72
|
<script>
|
|
73
73
|
document.addEventListener("pb:dropdown:selected", (e) => {
|
|
74
|
+
if (e.target.id !== "user-dropdown") return;
|
|
75
|
+
|
|
74
76
|
const option = e.detail;
|
|
75
77
|
const dropdown = e.target;
|
|
76
78
|
|
|
@@ -22,6 +22,11 @@ examples:
|
|
|
22
22
|
- dropdown_multi_select_with_default: Multi Select Default Value
|
|
23
23
|
- dropdown_blank_selection: Blank Selection
|
|
24
24
|
- dropdown_separators_hidden: Separators Hidden
|
|
25
|
+
- dropdown_quickpick_rails: Quick Pick Variant
|
|
26
|
+
- dropdown_quickpick_range_end_rails: Quick Pick Variant (Range Ends Today)
|
|
27
|
+
- dropdown_quickpick_default_dates: Quick Pick Variant (Default Dates)
|
|
28
|
+
- dropdown_quickpick_with_date_pickers_rails: Quick Pick with Date Pickers
|
|
29
|
+
- dropdown_quickpick_with_date_pickers_default_rails: Quick Pick with Date Pickers (Default Value)
|
|
25
30
|
|
|
26
31
|
react:
|
|
27
32
|
- dropdown_default: Default
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
style="display: none"
|
|
11
11
|
<%= object.required ? "required" : ""%>
|
|
12
12
|
/>
|
|
13
|
+
<% if object.variant == "quickpick" %>
|
|
14
|
+
<input id="<%= object.start_date_id %>" name="<%= object.start_date_name %>" style="display: none">
|
|
15
|
+
<input id="<%= object.end_date_id %>" name="<%= object.end_date_name %>" style="display: none">
|
|
16
|
+
<% end %>
|
|
13
17
|
<% if content.present? %>
|
|
14
18
|
<%= content.presence %>
|
|
15
19
|
<%= pb_rails("body", props: { status: "negative", text: object.error }) %>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "quickpick_helper"
|
|
4
|
+
|
|
3
5
|
module Playbook
|
|
4
6
|
module PbDropdown
|
|
5
7
|
class Dropdown < Playbook::KitBase
|
|
@@ -14,7 +16,7 @@ module Playbook
|
|
|
14
16
|
prop :blank_selection, type: Playbook::Props::String,
|
|
15
17
|
default: ""
|
|
16
18
|
prop :variant, type: Playbook::Props::Enum,
|
|
17
|
-
values: %w[default subtle],
|
|
19
|
+
values: %w[default subtle quickpick],
|
|
18
20
|
default: "default"
|
|
19
21
|
prop :separators, type: Playbook::Props::Boolean,
|
|
20
22
|
default: true
|
|
@@ -26,13 +28,32 @@ module Playbook
|
|
|
26
28
|
default: false
|
|
27
29
|
prop :form_pill_props, type: Playbook::Props::HashProp,
|
|
28
30
|
default: {}
|
|
31
|
+
prop :range_ends_today, type: Playbook::Props::Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
prop :controls_end_id, type: Playbook::Props::String,
|
|
34
|
+
default: ""
|
|
35
|
+
prop :controls_start_id, type: Playbook::Props::String,
|
|
36
|
+
default: ""
|
|
37
|
+
prop :start_date_id, type: Playbook::Props::String,
|
|
38
|
+
default: "start_date_id"
|
|
39
|
+
prop :start_date_name, type: Playbook::Props::String,
|
|
40
|
+
default: "start_date_name"
|
|
41
|
+
prop :end_date_id, type: Playbook::Props::String,
|
|
42
|
+
default: "end_date_id"
|
|
43
|
+
prop :end_date_name, type: Playbook::Props::String,
|
|
44
|
+
default: "end_date_name"
|
|
29
45
|
|
|
30
46
|
def data
|
|
31
47
|
Hash(prop(:data)).merge(
|
|
32
48
|
pb_dropdown: true,
|
|
33
49
|
pb_dropdown_multi_select: multi_select,
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
pb_dropdown_variant: variant,
|
|
51
|
+
form_pill_props: form_pill_props.to_json,
|
|
52
|
+
start_date_id: variant == "quickpick" ? start_date_id : nil,
|
|
53
|
+
end_date_id: variant == "quickpick" ? end_date_id : nil,
|
|
54
|
+
controls_start_id: variant == "quickpick" && controls_start_id.present? ? controls_start_id : nil,
|
|
55
|
+
controls_end_id: variant == "quickpick" && controls_end_id.present? ? controls_end_id : nil
|
|
56
|
+
).compact
|
|
36
57
|
end
|
|
37
58
|
|
|
38
59
|
def classname
|
|
@@ -48,7 +69,15 @@ module Playbook
|
|
|
48
69
|
def input_default_value
|
|
49
70
|
return "" unless default_value.present?
|
|
50
71
|
|
|
51
|
-
if
|
|
72
|
+
if variant == "quickpick"
|
|
73
|
+
d = default_value.to_s.downcase
|
|
74
|
+
matched_option = quickpick_options.find do |opt|
|
|
75
|
+
opt[:label].downcase == d
|
|
76
|
+
end
|
|
77
|
+
return matched_option[:id] if matched_option
|
|
78
|
+
|
|
79
|
+
""
|
|
80
|
+
elsif multi_select
|
|
52
81
|
default_value.map { |v| v.transform_keys(&:to_s)["id"] }.join(",")
|
|
53
82
|
else
|
|
54
83
|
default_value.transform_keys(&:to_s)["id"]
|
|
@@ -60,7 +89,12 @@ module Playbook
|
|
|
60
89
|
end
|
|
61
90
|
|
|
62
91
|
def options_with_blank
|
|
63
|
-
|
|
92
|
+
dropdown_options = variant == "quickpick" ? quickpick_options : options
|
|
93
|
+
blank_selection.present? ? [{ id: "", value: "", label: blank_selection }] + dropdown_options : dropdown_options
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def quickpick_options
|
|
97
|
+
QuickpickHelper.get_quickpick_options(range_ends_today: range_ends_today)
|
|
64
98
|
end
|
|
65
99
|
end
|
|
66
100
|
end
|